diff --git a/source/glest_game/menu/main_menu.cpp b/source/glest_game/menu/main_menu.cpp index 03459af3..2dac09f4 100644 --- a/source/glest_game/menu/main_menu.cpp +++ b/source/glest_game/menu/main_menu.cpp @@ -409,15 +409,15 @@ bool MenuState::keyPressEditLabel(SDL_KeyboardEvent c, GraphicLabel **activeInpu } else if (newKey < 0x800) { buf[0] = (0xC0 | newKey >> 6); - buf[1] = (0x80 | newKey & 0x3F); + buf[1] = (0x80 | (newKey & 0x3F)); //textCharLength.push_back(2); activeInputLabel->addTextCharLengthToList(2); //printf("2 char, textCharLength = %d\n",textCharLength.size()); } else { buf[0] = (0xE0 | newKey >> 12); - buf[1] = (0x80 | newKey >> 6 & 0x3F); - buf[2] = (0x80 | newKey & 0x3F); + buf[1] = (0x80 | (newKey >> 6 & 0x3F)); + buf[2] = (0x80 | (newKey & 0x3F)); //textCharLength.push_back(3); activeInputLabel->addTextCharLengthToList(3); //printf("3 char, textCharLength = %d\n",textCharLength.size()); diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index 5daec95f..8eb6e33d 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -3552,8 +3552,6 @@ void MenuStateCustomGame::setupUIFromGameSettings(const GameSettings &gameSettin //gameSettings->setDefaultResources(true); //gameSettings->setDefaultVictoryConditions(true); - Lang &lang= Lang::getInstance(); - //FogOfWar if(checkBoxScenario.getValue() == false) { listBoxFogOfWar.setSelectedItemIndex(0); // default is 0! diff --git a/source/glest_game/menu/menu_state_options.cpp b/source/glest_game/menu/menu_state_options.cpp index 45056963..5f694162 100644 --- a/source/glest_game/menu/menu_state_options.cpp +++ b/source/glest_game/menu/menu_state_options.cpp @@ -1120,7 +1120,6 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){ setActiveInputLable(NULL); - bool gotDownloads = false; string orig_txnURLUser = Config::getInstance().getString("TranslationGetURLUser"); //string orig_txnURLPwd = Config::getInstance().getString("TranslationGetURLPassword",""); string orig_txnURLLang = Config::getInstance().getString("TranslationGetURLLanguage"); @@ -1166,10 +1165,11 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){ vector languageFileMappings; Tokenize(txnURLFileListMapping,languageFileMappings,"|"); - printf("URL5 file count = %lu, %lu [%s]\n",languageFiles.size(),languageFileMappings.size(),(languageFiles.size() > 0 ? languageFiles[0].c_str() : "")); + printf("URL5 file count = %lu, %lu [%s]\n",languageFiles.size(),languageFileMappings.size(),(languageFiles.empty() == false ? languageFiles[0].c_str() : "")); - if(languageFiles.size() > 0) { + if(languageFiles.empty() == false) { + bool gotDownloads = false; bool reloadLanguage = false; string langName = ""; diff --git a/source/glest_game/world/map.cpp b/source/glest_game/world/map.cpp index ae77a9c4..a0d7c39e 100644 --- a/source/glest_game/world/map.cpp +++ b/source/glest_game/world/map.cpp @@ -921,6 +921,9 @@ bool Map::aproxCanMove(const Unit *unit, const Vec2i &pos1, const Vec2i &pos2, s return false; } + if(unit == NULL) { + throw megaglest_runtime_error("unit == NULL"); + } int size= unit->getType()->getSize(); int teamIndex= unit->getTeam(); Field field= unit->getCurrField(); @@ -1038,17 +1041,15 @@ bool Map::aproxCanMove(const Unit *unit, const Vec2i &pos1, const Vec2i &pos2, s } bool isBadHarvestPos = false; - if(unit != NULL) { - Command *command= unit->getCurrCommand(); - if(command != NULL) { - const HarvestCommandType *hct = dynamic_cast(command->getCommandType()); - if(hct != NULL && unit->isBadHarvestPos(pos2) == true) { - isBadHarvestPos = true; - } + Command *command= unit->getCurrCommand(); + if(command != NULL) { + const HarvestCommandType *hct = dynamic_cast(command->getCommandType()); + if(hct != NULL && unit->isBadHarvestPos(pos2) == true) { + isBadHarvestPos = true; } } - if(unit == NULL || isBadHarvestPos == true) { + if(isBadHarvestPos == true) { if(lookupCache != NULL) { (*lookupCache)[pos1][pos2][teamIndex][size][field]=false; } diff --git a/source/glest_game/world/map.h b/source/glest_game/world/map.h index 0f3f8e57..5678deb9 100644 --- a/source/glest_game/world/map.h +++ b/source/glest_game/world/map.h @@ -399,6 +399,10 @@ public: return false; } + if(unit == NULL) { + throw megaglest_runtime_error("unit == NULL"); + } + int size= unit->getType()->getSize(); int teamIndex= unit->getTeam(); Field field= unit->getCurrField(); @@ -481,17 +485,15 @@ public: } bool isBadHarvestPos = false; - if(unit != NULL) { - Command *command= unit->getCurrCommand(); - if(command != NULL) { - const HarvestCommandType *hct = dynamic_cast(command->getCommandType()); - if(hct != NULL && unit->isBadHarvestPos(pos2) == true) { - isBadHarvestPos = true; - } + Command *command= unit->getCurrCommand(); + if(command != NULL) { + const HarvestCommandType *hct = dynamic_cast(command->getCommandType()); + if(hct != NULL && unit->isBadHarvestPos(pos2) == true) { + isBadHarvestPos = true; } } - if(unit == NULL || isBadHarvestPos == true) { + if(isBadHarvestPos == true) { //printf("[%s] Line: %d returning false\n",__FUNCTION__,__LINE__); unit->getFaction()->addAproxCanMoveSoonCached(size,field, pos1, pos2, false);