bugfixes for loading saved games with bad data or wrong game version
This commit is contained in:
parent
fe151abcc5
commit
7cd6dfbdca
|
@ -6183,7 +6183,7 @@ void Game::loadGame(string name,Program *programPtr,bool isMasterserverMode,cons
|
|||
if(gameVer != glestVersionString && checkVersionComptability(gameVer, glestVersionString) == false) {
|
||||
char szBuf[8096]="";
|
||||
snprintf(szBuf,8096,lang.get("SavedGameBadVersion").c_str(),gameVer.c_str(),glestVersionString.c_str());
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
throw megaglest_runtime_error(szBuf,true);
|
||||
}
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Found saved game version that matches your application version: [%s] --> [%s]\n",gameVer.c_str(),glestVersionString.c_str());
|
||||
|
@ -6244,7 +6244,7 @@ void Game::loadGame(string name,Program *programPtr,bool isMasterserverMode,cons
|
|||
if(gameVer != glestVersionString && checkVersionComptability(gameVer, glestVersionString) == false) {
|
||||
char szBuf[8096]="";
|
||||
snprintf(szBuf,8096,lang.get("SavedGameBadVersion").c_str(),gameVer.c_str(),glestVersionString.c_str());
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
throw megaglest_runtime_error(szBuf,true);
|
||||
}
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Found saved game version that matches your application version: [%s] --> [%s]\n",gameVer.c_str(),glestVersionString.c_str());
|
||||
|
|
|
@ -121,6 +121,10 @@ MenuStateLoadGame::MenuStateLoadGame(Program *program, MainMenu *mainMenu):
|
|||
listFiles();
|
||||
slotsScrollBar.setElementCount(filenames.size());
|
||||
|
||||
mainMessageBox.registerGraphicComponent(containerName,"mainMessageBox");
|
||||
mainMessageBox.init(lang.get("Ok"),450);
|
||||
mainMessageBox.setEnabled(false);
|
||||
|
||||
GraphicComponent::applyAllCustomProperties(containerName);
|
||||
}
|
||||
|
||||
|
@ -183,6 +187,8 @@ void MenuStateLoadGame::reloadUI() {
|
|||
deleteButton.setText(lang.get("Delete"));
|
||||
loadButton.setText(lang.get("LoadGame"));
|
||||
|
||||
mainMessageBox.init(lang.get("Ok"),450);
|
||||
|
||||
GraphicComponent::reloadFontsForRegisterGraphicComponents(containerName);
|
||||
}
|
||||
|
||||
|
@ -191,6 +197,15 @@ void MenuStateLoadGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||
CoreData &coreData= CoreData::getInstance();
|
||||
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
||||
|
||||
if(mainMessageBox.getEnabled()) {
|
||||
int button= 0;
|
||||
if(mainMessageBox.mouseClick(x, y, button)) {
|
||||
mainMessageBox.setEnabled(false);
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
mainMessageBox.init(lang.get("Ok"),450);
|
||||
}
|
||||
}
|
||||
if(abortButton.mouseClick(x, y)) {
|
||||
soundRenderer.playFx(coreData.getClickSoundB());
|
||||
mainMenu->setState(new MenuStateRoot(program, mainMenu));
|
||||
|
@ -245,7 +260,12 @@ void MenuStateLoadGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||
snprintf(szBuf,8096,lang.get("LoadGameLoadingFile","",true).c_str(),filename.c_str());
|
||||
console.addLineOnly(szBuf);
|
||||
|
||||
Game::loadGame(filename,program,false);
|
||||
try {
|
||||
Game::loadGame(filename,program,false);
|
||||
}
|
||||
catch(const megaglest_runtime_error &ex) {
|
||||
showMessageBox(ex.what(), lang.get("Notice"), true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
//mainMenu->setState(new MenuStateRoot(program, mainMenu));
|
||||
|
@ -389,6 +409,9 @@ void MenuStateLoadGame::render(){
|
|||
renderer.renderTextureQuad(550,slotLinesYBase-300+slotsLineHeight,400,300,previewTexture,1.0f);
|
||||
}
|
||||
|
||||
if(mainMessageBox.getEnabled()) {
|
||||
renderer.renderMessageBox(&mainMessageBox);
|
||||
}
|
||||
|
||||
renderer.renderConsole(&console,false,false);
|
||||
if(program != NULL) program->renderProgramMsgBox();
|
||||
|
@ -423,4 +446,19 @@ void MenuStateLoadGame::keyDown(SDL_KeyboardEvent key) {
|
|||
}
|
||||
}
|
||||
|
||||
void MenuStateLoadGame::showMessageBox(const string &text, const string &header, bool toggle) {
|
||||
if(toggle == false) {
|
||||
mainMessageBox.setEnabled(false);
|
||||
}
|
||||
|
||||
if(mainMessageBox.getEnabled() == false) {
|
||||
mainMessageBox.setText(text);
|
||||
mainMessageBox.setHeader(header);
|
||||
mainMessageBox.setEnabled(true);
|
||||
}
|
||||
else{
|
||||
mainMessageBox.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
}}//end namespace
|
||||
|
|
|
@ -45,6 +45,8 @@ private:
|
|||
|
||||
GraphicLine lines[2];
|
||||
|
||||
GraphicMessageBox mainMessageBox;
|
||||
|
||||
string saveGameDir;
|
||||
int slotLinesYBase;
|
||||
int slotsLineHeight;
|
||||
|
@ -61,10 +63,14 @@ public:
|
|||
virtual void keyDown(SDL_KeyboardEvent key);
|
||||
|
||||
void reloadUI();
|
||||
|
||||
private:
|
||||
|
||||
void clearSlots();
|
||||
void deleteSlot(int i);
|
||||
void listFiles();
|
||||
|
||||
void showMessageBox(const string &text, const string &header, bool toggle);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -4179,7 +4179,7 @@ Unit * Unit::loadGame(const XmlNode *rootNode, GameSettings *settings, Faction *
|
|||
// int deadCount;
|
||||
result->deadCount = unitNode->getAttribute("deadCount")->getIntValue();
|
||||
// float progress; //between 0 and 1
|
||||
result->progress = unitNode->getAttribute("progress")->getIntValue();
|
||||
result->progress = unitNode->getAttribute("progress")->getFloatValue();
|
||||
// float lastAnimProgress; //between 0 and 1
|
||||
result->lastAnimProgress = unitNode->getAttribute("lastAnimProgress")->getFloatValue();
|
||||
// float animProgress; //between 0 and 1
|
||||
|
|
Loading…
Reference in New Issue
Block a user