diff --git a/source/g3d_viewer/main.cpp b/source/g3d_viewer/main.cpp index 8ab82fa25..330bee247 100644 --- a/source/g3d_viewer/main.cpp +++ b/source/g3d_viewer/main.cpp @@ -1263,7 +1263,7 @@ namespace Shared { } } catch (std::runtime_error &e) { std::cout << e.what() << std::endl; - wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Glest particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal(); + wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a valid particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal(); } } @@ -1514,7 +1514,7 @@ namespace Shared { } } catch (std::runtime_error &e) { std::cout << e.what() << std::endl; - wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Glest projectile particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal(); + wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a valid projectile particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal(); } if (timer) timer->Start(100); if (SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] after load [%s]\n", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__, path.c_str()); @@ -1619,7 +1619,7 @@ namespace Shared { } } catch (std::runtime_error &e) { std::cout << e.what() << std::endl; - wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Glest projectile particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal(); + wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a valid projectile particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal(); } if (timer) timer->Start(100); if (SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] after load [%s] particleSplashPathList.size() = " SIZE_T_SPECIFIER "\n", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__, path.c_str(), this->particleSplashPathList.size()); diff --git a/source/game/ai/ai.cpp b/source/game/ai/ai.cpp index 5bfe17cf9..c9ba59a26 100644 --- a/source/game/ai/ai.cpp +++ b/source/game/ai/ai.cpp @@ -1166,7 +1166,7 @@ namespace Game { glestResourceAttack = (aiInterface->getControlType() == ctCpuGlest) && random.randRange(0, 1) == 1; - if (glestResourceAttack || ultraResourceAttack) { + if (ultraResourceAttack || glestResourceAttack) { Map * map = aiInterface->getMap(); diff --git a/source/game/game/script_manager.cpp b/source/game/game/script_manager.cpp index f3825b776..b4275c580 100644 --- a/source/game/game/script_manager.cpp +++ b/source/game/game/script_manager.cpp @@ -571,23 +571,6 @@ namespace Game { } } - //!!! - // string data_path= getGameReadWritePath(GameConstants::path_data_CacheLookupKey); - // if(data_path != ""){ - // endPathWithSlash(data_path); - // } - // string sandboxScriptFilename = data_path + "data/core/scripts/sandbox.lua"; - // string sandboxLuaCode = getFileTextContents(sandboxScriptFilename); - // - // //luaScript.loadCode(sandboxLuaCode + "\n", "glest_lua_sandbox"); - // luaScript.setSandboxWrapperFunctionName("runsandboxed"); - // luaScript.setSandboxCode(sandboxLuaCode); - // luaScript.runCode(sandboxLuaCode); - - // // Setup the lua security sandbox here - // luaScript.beginCall("glest_lua_sandbox"); - // luaScript.endCall(); - //setup message box messageBox.init(Lang::getInstance().getString("Ok")); messageBox.setEnabled(false); diff --git a/source/game/global/config.cpp b/source/game/global/config.cpp index 746fa22dd..b015db9ff 100644 --- a/source/game/global/config.cpp +++ b/source/game/global/config.cpp @@ -1001,12 +1001,12 @@ namespace Game { string map_path = pathList[idx]; endPathWithSlash(map_path); - const string mega = map_path + mapName + ".mgm"; - const string glest = map_path + mapName + ".gbm"; - if (fileExists(mega)) { - return mega; - } else if (fileExists(glest)) { - return glest; + const string newFormat = map_path + mapName + ".mgm"; + const string oldFormat = map_path + mapName + ".gbm"; + if (fileExists(newFormat)) { + return newFormat; + } else if (fileExists(oldFormat)) { + return oldFormat; } } diff --git a/source/game/global/lang.cpp b/source/game/global/lang.cpp index 72bf5b028..96c6965cf 100644 --- a/source/game/global/lang.cpp +++ b/source/game/global/lang.cpp @@ -737,7 +737,7 @@ namespace Game { } pair < string, - string > Lang::getNavtiveNameFromLanguageName(string langName) { + string > Lang::getNativeNameFromLanguageName(string langName) { pair < string, string > result; //printf("looking for language [%s]\n",langName.c_str()); diff --git a/source/game/global/lang.h b/source/game/global/lang.h index 5c8edab08..ae31d81f3 100644 --- a/source/game/global/lang.h +++ b/source/game/global/lang.h @@ -108,7 +108,7 @@ namespace Game { map < string, string > getDiscoveredLanguageList(bool searchKeyIsLangName = false); pair < string, - string > getNavtiveNameFromLanguageName(string langName); + string > getNativeNameFromLanguageName(string langName); string getLanguageFile(string uselanguage); }; diff --git a/source/game/gui/gui.cpp b/source/game/gui/gui.cpp index 0eaacbe20..faa188e4a 100644 --- a/source/game/gui/gui.cpp +++ b/source/game/gui/gui.cpp @@ -324,6 +324,7 @@ namespace Game { selectionQuad.disable(); } } + lastToggledUnits.clear(); } void Gui::mouseMoveGraphics(int x, int y) { @@ -1154,24 +1155,32 @@ namespace Game { } } - bool shiftDown = isKeyDown(vkShift); - bool controlDown = isKeyDown(vkControl); - - if (!shiftDown && !controlDown) { - //if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] about to call selection.clear()\n",__FILE__,__FUNCTION__,__LINE__); - selection.clear(); - } - - if (!controlDown) { - //if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] about to call selection.select(units)\n",__FILE__,__FUNCTION__,__LINE__); - selection.select(units, shiftDown); - if (!selection.isEmpty()) { - selectedResourceObject = NULL; + if (isKeyDown(vkControl)) + selection.unSelect(units); + else if (isKeyDown(vkShift)) { + int j; + Unit* unit; + bool alreadyToggled; + for (int i = 0; i < units.size(); i++) { + unit = units[i]; + alreadyToggled = false; + for (j = 0; j < lastToggledUnits.size(); j++) { + if (lastToggledUnits[j] == unit) { + alreadyToggled = true; + break; + } + } + if (!alreadyToggled) { + selection.select(unit, true, true); + lastToggledUnits.push_back(unit); + } } } else { - //if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] selection.unSelect(units)\n",__FILE__,__FUNCTION__,__LINE__); - selection.unSelect(units); + selection.clear(); + selection.select(units, false); } + if (!selection.isEmpty()) + selectedResourceObject = NULL; } } diff --git a/source/game/gui/gui.h b/source/game/gui/gui.h index 67a524201..3ac77420a 100644 --- a/source/game/gui/gui.h +++ b/source/game/gui/gui.h @@ -160,6 +160,7 @@ namespace Game { bool selectingBuilding; bool selectingPos; bool selectingMeetingPoint; + vector lastToggledUnits; CardinalDir selectedBuildingFacing; Vec2i selectedResourceObjectPos; diff --git a/source/game/gui/selection.cpp b/source/game/gui/selection.cpp index 62622fe5d..3609c6b19 100644 --- a/source/game/gui/selection.cpp +++ b/source/game/gui/selection.cpp @@ -58,12 +58,25 @@ namespace Game { return true; } - bool Selection::select(Unit *unit, bool addToSelection) { + bool Selection::isSelected(Unit* unit) const { + if (unit == NULL) + return false; + //check if already selected + for (int index = 0; index < (int) selectedUnits.size(); ++index) { + if (selectedUnits[index] == unit) { + return true; + } + } + } + + bool Selection::select(Unit *unit, bool addToSelection, bool toggleSelection) { bool result = false; if (unit != NULL) { //check if already selected for (int index = 0; index < (int) selectedUnits.size(); ++index) { if (selectedUnits[index] == unit) { + if (toggleSelection) + unSelect(index); return true; } } @@ -143,11 +156,11 @@ namespace Game { return result; } - void Selection::select(const UnitContainer &units, bool addToSelection) { + void Selection::select(const UnitContainer &units, bool addToSelection, bool toggleSelection) { //add units to gui for (UnitIterator it = units.begin(); it != units.end(); ++it) { - select(*it, addToSelection); + select(*it, addToSelection, toggleSelection); } } diff --git a/source/game/gui/selection.h b/source/game/gui/selection.h index 475605ddd..5e41f1760 100644 --- a/source/game/gui/selection.h +++ b/source/game/gui/selection.h @@ -74,12 +74,14 @@ namespace Game { void init(Gui *gui, int factionIndex, int teamIndex, bool allowSharedTeamUnits); virtual ~Selection(); - bool select(Unit *unit, bool addToSelection); - void select(const UnitContainer &units, bool addToSelection); + bool select(Unit *unit, bool addToSelection, bool toggleSelection = false); + void select(const UnitContainer &units, bool addToSelection, bool toggleSelection = false); void unSelect(const UnitContainer &units); void unSelect(int unitIndex); void clear(); + bool isSelected(Unit* unit) const; + bool isEmpty() const { return selectedUnits.empty(); } diff --git a/source/game/main/main.cpp b/source/game/main/main.cpp index efc85d482..4f1f0c9b2 100644 --- a/source/game/main/main.cpp +++ b/source/game/main/main.cpp @@ -5699,7 +5699,7 @@ namespace Game { } int - glestMain(int argc, char **argv) { + gameMain(int argc, char **argv) { #ifdef SL_LEAK_DUMP //AllocInfo::set_application_binary(executable_path(argv[0],true)); string & app = AllocInfo::get_application_binary(); @@ -5721,8 +5721,6 @@ namespace Game { Thread::setEnableVerboseMode(true); //LuaScript::setDebugModeEnabled(true); } - // DEbug testing threads - //Thread::setEnableVerboseMode(true); PlatformExceptionHandler::application_binary = executable_path(argv[0], true); @@ -5915,68 +5913,6 @@ namespace Game { (::Shared::PlatformByteOrder::isBigEndian() == true ? "big" : "little")); - // printf("\n\nData type sizes int8 = " SIZE_T_SPECIFIER " int16 = " SIZE_T_SPECIFIER " int32 = " SIZE_T_SPECIFIER " int64 = " SIZE_T_SPECIFIER "\n\n",sizeof(int8),sizeof(int16),sizeof(int32),sizeof(int64)); - // - // Config::getInstance().setBool("DebugNetworkPackets",true,true); - // NetworkMessageIntro data(424336, "mg_version_x","player_x", 3, nmgstOk,444444, 555555, "english"); - // unsigned char *buf = data.packMessage(); - // printf("\nSend packet size = %u\n%s\n",data.getPackedSize(),data.toString().c_str()); - // data.dump_packet("Send data", buf, data.getPackedSize()); - // //delete [] buf; - // - // NetworkMessageIntro data2; - // data2.unpackMessage(buf); - // printf("\nReceive packet size = %u\n%s\n",data2.getPackedSize(),data2.toString().c_str()); - // data2.dump_packet("nReceive data", buf, data2.getPackedSize()); - // delete [] buf; - - // SwitchSetupRequest data("factionname", 3,-1,2,"softcoder",10, 11,"eng"); - // - // unsigned char *buf = data.packMessage(); - // printf("\nSend packet size = %u\n%s\nTeam = %d faction [%s] currentFactionIndex = %d toFactionIndex = %d [%s] [%s] %d %d\n",data.getPackedSize(),buf,data.getToTeam(),data.getSelectedFactionName().c_str(),data.getCurrentFactionIndex(),data.getToFactionIndex(),data.getNetworkPlayerLanguage().c_str(),data.getNetworkPlayerName().c_str(),data.getNetworkPlayerStatus(),data.getSwitchFlags()); - // //delete [] buf; - // - // data.unpackMessage(buf); - // printf("\nGot packet size = %u\n%s\nTeam = %d faction [%s] currentFactionIndex = %d toFactionIndex = %d [%s] [%s] %d %d\n",data.getPackedSize(),buf,data.getToTeam(),data.getSelectedFactionName().c_str(),data.getCurrentFactionIndex(),data.getToFactionIndex(),data.getNetworkPlayerLanguage().c_str(),data.getNetworkPlayerName().c_str(),data.getNetworkPlayerStatus(),data.getSwitchFlags()); - // delete [] buf; - - // int8 a = 1; - // uint8 b = 2; - // int16 c = 3; - // uint16 d = 4; - // int32 e = 5; - // uint32 f = 6; - // - // printf("\nPack test #1: [%d][%u][%d][%u][%d][%u]\n,",a,b,c,d,e,f); - // - // unsigned char *buf = new unsigned char[100]; - // unsigned int packedsize = pack(buf, "cChHlL", - // a, - // b, - // c, - // d, - // e, - // f); - // - // printf("Pack test #2: [%u][%s]\n,",packedsize,buf); - // - // int8 a1 = 0; - // uint8 b1 = 0; - // int16 c1 = 0; - // uint16 d1 = 0; - // int32 e1 = 0; - // uint32 f1 = 0; - // - // unpack(buf, "cChHlL", - // &a1, - // &b1, - // &c1, - // &d1, - // &e1, - // &f1); - // - // printf("UnPack test #3: [%d][%u][%d][%u][%d][%u]\n,",a1,b1,c1,d1,e1,f1); - if (SystemFlags::VERBOSE_MODE_ENABLED == true) { int8 testVar = 111; @@ -6213,8 +6149,16 @@ namespace Game { } SystemFlags::init(haveSpecialOutputCommandLineOption); - //SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled = true; + //SystemFlags::getSystemSettingType(SystemFlags::debugError).enabled = true; + //SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled = true; //SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled = true; + //SystemFlags::getSystemSettingType(SystemFlags::debugPathFinder).enabled = true; + //SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled = true; + //SystemFlags::getSystemSettingType(SystemFlags::debugSound).enabled = true; + //SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled = true; + SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled = true; + //SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled = true; + //SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynchMax).enabled = true; MainWindow * mainWindow = NULL; @@ -8270,7 +8214,7 @@ namespace Game { #endif int - glestMainSEHWrapper(int argc, char **argv) { + gameMainSEHWrapper(int argc, char **argv) { int result = 0; #ifdef WIN32_STACK_TRACE @@ -8297,7 +8241,7 @@ namespace Game { IRCThread::setGlobalCacheContainerName (GameConstants::ircClientCacheLookupKey); - result = glestMain(argc, argv); + result = gameMain(argc, argv); if (SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n", __FILE__, __FUNCTION__, __LINE__); @@ -8330,7 +8274,7 @@ namespace Game { } int - glestMainWrapper(int argc, char **argv) { + gameMainWrapper(int argc, char **argv) { //setlocale(LC_ALL, "zh_TW.UTF-8"); //setlocale(LC_ALL, ""); @@ -8412,7 +8356,7 @@ namespace Game { } int - result = glestMainSEHWrapper(argc, argv); + result = gameMainSEHWrapper(argc, argv); if (isSteamMode == true) { printf("\nSteam API deinit.\n"); @@ -8431,6 +8375,6 @@ int main(int argc, char **argv) { #endif int result = mainSetup(argc,argv); if (result == 0) - result = Game::glestMainWrapper(argc, argv); + result = Game::gameMainWrapper(argc, argv); return result; } diff --git a/source/game/menu/menu_state_connected_game.cpp b/source/game/menu/menu_state_connected_game.cpp index 5971ea47d..0c138cc44 100644 --- a/source/game/menu/menu_state_connected_game.cpp +++ b/source/game/menu/menu_state_connected_game.cpp @@ -3907,7 +3907,7 @@ namespace Game { string newLabelConnectionInfo = lang.getString("WaitingHost"); if (clientInterface != NULL && clientInterface->getJoinGameInProgress() == true) { - newLabelConnectionInfo = lang.getString("MGGameStatus2"); + newLabelConnectionInfo = lang.getString("GameStatus2"); } // Test progress bar //MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); diff --git a/source/game/menu/menu_state_masterserver.cpp b/source/game/menu/menu_state_masterserver.cpp index 59a97c5bf..1fb08d65c 100644 --- a/source/game/menu/menu_state_masterserver.cpp +++ b/source/game/menu/menu_state_masterserver.cpp @@ -168,42 +168,32 @@ namespace Game { //general info: //i+=10; - glestVersionLabel.registerGraphicComponent(containerName, - "glestVersionLabel"); - glestVersionLabel.init(i, startOffset - lineOffset); - glestVersionLabel.setText(lang.getString("MGVersion")); + versionLabel.registerGraphicComponent(containerName, + "versionLabel"); + versionLabel.init(i, startOffset - lineOffset); + versionLabel.setText(lang.getString("Version")); i += 80; platformLabel.registerGraphicComponent(containerName, "platformLabel"); platformLabel.init(i + 15, startOffset - lineOffset); - platformLabel.setText(lang.getString("MGPlatform")); + platformLabel.setText(lang.getString("Platform")); - // i+=50; - // binaryCompileDateLabel.registerGraphicComponent(containerName,"binaryCompileDateLabel"); - // binaryCompileDateLabel.init(i,startOffset-lineOffset); - // binaryCompileDateLabel.setText(lang.getString("MGBuildDateTime")); - - //game info: + //game info: i += 120; serverTitleLabel.registerGraphicComponent(containerName, "serverTitleLabel"); serverTitleLabel.init(i, startOffset - lineOffset); - serverTitleLabel.setText(lang.getString("MGGameTitle")); + serverTitleLabel.setText(lang.getString("GameTitle")); i += 170; countryLabel.registerGraphicComponent(containerName, "countryLabel"); countryLabel.init(i - 10, startOffset - lineOffset); - countryLabel.setText(lang.getString("MGGameCountry")); + countryLabel.setText(lang.getString("GameCountry")); i += 60; - // ipAddressLabel.registerGraphicComponent(containerName,"ipAddressLabel"); - // ipAddressLabel.init(i,startOffset-lineOffset); - // ipAddressLabel.setText(lang.getString("MGGameIP")); - // i+=100; - - //game setup info: + //game setup info: techLabel.registerGraphicComponent(containerName, "techLabel"); techLabel.init(i, startOffset - lineOffset); techLabel.setText(lang.getString("TechTree")); @@ -214,15 +204,11 @@ namespace Game { mapLabel.setText(lang.getString("Map")); i += 95; - // tilesetLabel.registerGraphicComponent(containerName,"tilesetLabel"); - // tilesetLabel.init(i,startOffset-lineOffset); - // tilesetLabel.setText(lang.getString("Tileset")); - // i+=100; activeSlotsLabel.registerGraphicComponent(containerName, "activeSlotsLabel"); activeSlotsLabel.init(i, startOffset - lineOffset); - activeSlotsLabel.setText(lang.getString("MGGameSlots")); + activeSlotsLabel.setText(lang.getString("GameSlots")); i += 50; //externalConnectPort.registerGraphicComponent(containerName,"externalConnectPort"); @@ -232,12 +218,12 @@ namespace Game { i += 30; statusLabel.registerGraphicComponent(containerName, "statusLabel"); statusLabel.init(i + 5, startOffset - lineOffset); - statusLabel.setText(lang.getString("MGGameStatus")); + statusLabel.setText(lang.getString("GameStatus")); i += 130; selectButton.registerGraphicComponent(containerName, "selectButton"); selectButton.init(i - 5, startOffset - lineOffset); - selectButton.setText(lang.getString("MGJoinGameSlots")); + selectButton.setText(lang.getString("JoinGameSlots")); // Titles for current games - END @@ -448,25 +434,25 @@ namespace Game { labelTitle.setText("*** " + lang.getString("AvailableServers")); } - glestVersionLabel.setText(lang.getString("MGVersion")); + versionLabel.setText(lang.getString("Version")); - platformLabel.setText(lang.getString("MGPlatform")); + platformLabel.setText(lang.getString("Platform")); - serverTitleLabel.setText(lang.getString("MGGameTitle")); + serverTitleLabel.setText(lang.getString("GameTitle")); - countryLabel.setText(lang.getString("MGGameCountry")); + countryLabel.setText(lang.getString("GameCountry")); techLabel.setText(lang.getString("TechTree")); mapLabel.setText(lang.getString("Map")); - activeSlotsLabel.setText(lang.getString("MGGameSlots")); + activeSlotsLabel.setText(lang.getString("GameSlots")); //externalConnectPort.setText(lang.getString("Port")); - statusLabel.setText(lang.getString("MGGameStatus")); + statusLabel.setText(lang.getString("GameStatus")); - selectButton.setText(lang.getString("MGJoinGameSlots")); + selectButton.setText(lang.getString("JoinGameSlots")); // Titles for current games - END @@ -1012,7 +998,7 @@ namespace Game { const Vec4f titleLabelColor = CYAN; //general info: - renderer.renderLabel(&glestVersionLabel, &titleLabelColor); + renderer.renderLabel(&versionLabel, &titleLabelColor); renderer.renderLabel(&platformLabel, &titleLabelColor); //renderer.renderLabel(&binaryCompileDateLabel,&titleLabelColor); @@ -1367,7 +1353,7 @@ namespace Game { MasterServerInfo *masterServerInfo = new MasterServerInfo(); //general info: - masterServerInfo->setGlestVersion(serverEntities[0]); + masterServerInfo->setVersion(serverEntities[0]); masterServerInfo->setPlatform(serverEntities[1]); masterServerInfo->setBinaryCompileDate(serverEntities[2]); diff --git a/source/game/menu/menu_state_masterserver.h b/source/game/menu/menu_state_masterserver.h index 3659e1c05..11b239300 100644 --- a/source/game/menu/menu_state_masterserver.h +++ b/source/game/menu/menu_state_masterserver.h @@ -54,7 +54,7 @@ namespace Game { GraphicLine lines[3]; - GraphicLabel glestVersionLabel; + GraphicLabel versionLabel; GraphicLabel platformLabel; //GraphicLabel binaryCompileDateLabel; diff --git a/source/game/menu/menu_state_options.cpp b/source/game/menu/menu_state_options.cpp index ccb140128..c721c9e31 100644 --- a/source/game/menu/menu_state_options.cpp +++ b/source/game/menu/menu_state_options.cpp @@ -206,13 +206,13 @@ namespace Game { string, string > defaultLang = - Lang::getInstance().getNavtiveNameFromLanguageName(config. + Lang::getInstance().getNativeNameFromLanguageName(config. getString ("Lang")); if (defaultLang.first == "" && defaultLang.second == "") { defaultLang = Lang::getInstance(). - getNavtiveNameFromLanguageName(Lang::getInstance(). + getNativeNameFromLanguageName(Lang::getInstance(). getDefaultLanguage()); } listBoxLang. @@ -379,7 +379,7 @@ namespace Game { currentLine -= lineOffset; labelShowDeveloperConsoleOnWindows.init(currentLabelStart, currentLine); - labelShowDeveloperConsoleOnWindows.setText("Show developer console on Windows"); + labelShowDeveloperConsoleOnWindows.setText(lang.getString("ShowDevConsoleWin")); checkBoxShowDeveloperConsoleOnWindows.init(currentColumnStart, currentLine); @@ -491,7 +491,7 @@ namespace Game { labelChatStaysActive.setText(lang.getString("ChatStaysActive")); labelTimeDisplay.setText(lang.getString("TimeDisplay")); - labelShowDeveloperConsoleOnWindows.setText("Show developer console on Windows"); + labelShowDeveloperConsoleOnWindows.setText(lang.getString("ShowDevConsoleWin")); labelLang.setText(lang.getString("Language")); labelPlayerNameLabel.setText(lang.getString("Playername")); labelFontSizeAdjustment.setText(lang.getString("FontSizeAdjustment")); diff --git a/source/game/menu/server_line.cpp b/source/game/menu/server_line.cpp index cac4e29f1..d248e8037 100644 --- a/source/game/menu/server_line.cpp +++ b/source/game/menu/server_line.cpp @@ -58,14 +58,14 @@ namespace Game { //general info: //i+= 10; - glestVersionLabel.init(i, baseY - lineOffset); - glestVersionLabel.setRenderBackground(true); - glestVersionLabel.setMaxEditRenderWidth(970); // use background for whole line - glestVersionLabel.setTextColor(color); - glestVersionLabel.setText(" " + masterServerInfo.getGlestVersion()); - glestVersionLabel.setFont(CoreData::getInstance(). + versionLabel.init(i, baseY - lineOffset); + versionLabel.setRenderBackground(true); + versionLabel.setMaxEditRenderWidth(970); // use background for whole line + versionLabel.setTextColor(color); + versionLabel.setText(" " + masterServerInfo.getVersion()); + versionLabel.setFont(CoreData::getInstance(). getDisplayFontSmall()); - glestVersionLabel.setFont3D(CoreData::getInstance(). + versionLabel.setFont3D(CoreData::getInstance(). getDisplayFontSmall3D()); i += 80; @@ -182,7 +182,7 @@ namespace Game { status.init(i - 10, baseY - lineOffset); status.setTextColor(color); status.setText(lang. - getString("MGGameStatus" + + getString("GameStatus" + intToStr(masterServerInfo.getStatus()))); i += 130; @@ -190,8 +190,7 @@ namespace Game { selectButton.setText(">"); selectButton.setAlwaysLighted(true); - //printf("glestVersionString [%s] masterServerInfo->getGlestVersion() [%s]\n",glestVersionString.c_str(),masterServerInfo->getGlestVersion().c_str()); - compatible = checkVersionCompatibility(GameVersionString, masterServerInfo.getGlestVersion()); + compatible = checkVersionCompatibility(GameVersionString, masterServerInfo.getVersion()); selectButton.setEnabled(compatible); selectButton.setEditable(compatible); @@ -200,7 +199,7 @@ namespace Game { void ServerLine::reloadUI() { Lang & lang = Lang::getInstance(); - glestVersionLabel.setText(masterServerInfo.getGlestVersion()); + versionLabel.setText(masterServerInfo.getVersion()); string platform = masterServerInfo.getPlatform(); size_t revOffset = platform.find("-Rev"); @@ -227,7 +226,7 @@ namespace Game { //externalConnectPort.setText(intToStr(masterServerInfo.getExternalConnectPort())); status.setText(lang. - getString("MGGameStatus" + + getString("GameStatus" + intToStr(masterServerInfo.getStatus()))); GraphicComponent:: @@ -269,7 +268,7 @@ namespace Game { void ServerLine::render() { Renderer & renderer = Renderer::getInstance(); //general info: - renderer.renderLabel(&glestVersionLabel); + renderer.renderLabel(&versionLabel); renderer.renderLabel(&platformLabel); //renderer.renderLabel(&binaryCompileDateLabel); @@ -320,7 +319,7 @@ namespace Game { selectButton.setY(y); //general info: - glestVersionLabel.setY(y); + versionLabel.setY(y); platformLabel.setY(y); //binaryCompileDateLabel.setY(y); diff --git a/source/game/menu/server_line.h b/source/game/menu/server_line.h index f5be80d26..0500e2c27 100644 --- a/source/game/menu/server_line.h +++ b/source/game/menu/server_line.h @@ -48,7 +48,7 @@ namespace Game { GraphicLabel wrongVersionLabel; //general info: - GraphicLabel glestVersionLabel; + GraphicLabel versionLabel; GraphicLabel platformLabel; //GraphicLabel binaryCompileDateLabel; diff --git a/source/game/network/masterserver_info.h b/source/game/network/masterserver_info.h index be609f889..a8e4974f1 100644 --- a/source/game/network/masterserver_info.h +++ b/source/game/network/masterserver_info.h @@ -36,7 +36,7 @@ namespace Game { class MasterServerInfo { protected: //general info: - string glestVersion; + string version; string platform; string binaryCompileDate; @@ -56,8 +56,8 @@ namespace Game { int status; public: - const string &getGlestVersion() const { - return glestVersion; + const string &getVersion() const { + return version; } const string &getPlatform() const { return platform; @@ -101,10 +101,9 @@ namespace Game { return status; } - //general info: - void setGlestVersion(string value) { - glestVersion = value; + void setVersion(string value) { + version = value; } void setPlatform(string value) { platform = value; diff --git a/source/game/type_instances/unit.cpp b/source/game/type_instances/unit.cpp index c4b1740e3..f130c18e4 100644 --- a/source/game/type_instances/unit.cpp +++ b/source/game/type_instances/unit.cpp @@ -645,7 +645,7 @@ namespace Game { Game *Unit::game = NULL; - Unit::Unit(int id, UnitPathInterface * unitpath, const Vec2i & pos, + Unit::Unit(int id, UnitPathInterface * unitpath, const Vec2i & position, const UnitType * type, Faction * faction, Map * map, CardinalDir placeFacing) :BaseColorPickEntity(), id(id) { #ifdef LEAK_CHECK_UNITS @@ -690,13 +690,12 @@ namespace Game { pathFindRefreshCellCount = random.randRange(10, 20, intToStr(__LINE__)); - if (map->isInside(pos) == false - || map->isInsideSurface(map->toSurfCoords(pos)) == false) { - throw game_runtime_error("#2 Invalid path position = " + - pos.getString()); - } - - this->pos = pos; + if (map->isInside(position) == false + || map->isInsideSurface(map->toSurfCoords(position)) == false) { + printf("\n#2 Invalid path position = %s\n", position.getString().c_str()); + this->pos = Vec2i(); + } else + this->pos = position; this->faction = faction; this->preMorph_type = NULL; @@ -1606,13 +1605,7 @@ namespace Game { return &random; } - void Unit::setPos(const Vec2i & pos, bool clearPathFinder, bool threaded) { - if (map->isInside(pos) == false - || map->isInsideSurface(map->toSurfCoords(pos)) == false) { - throw game_runtime_error("#3 Invalid path position = " + - pos.getString()); - } - + void Unit::setPos(const Vec2i & position, bool clearPathFinder, bool threaded) { static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__); MutexSafeWrapper safeMutex(mutexCommands, mutexOwnerId); @@ -1628,9 +1621,15 @@ namespace Game { if (clearPathFinder == true && this->unitPath != NULL) { this->unitPath->clear(); } - //Vec2i oldLastPos = this->lastPos; + this->lastPos = this->pos; - this->pos = pos; + + if (map->isInside(position) == false + || map->isInsideSurface(map->toSurfCoords(position)) == false) { + printf("\n#3 Invalid path position = %s\n", position.getString().c_str()); + this->pos = Vec2i(); + } else + this->pos = position; map->clampPos(this->pos); this->meetingPos = pos - Vec2i(1); @@ -1710,14 +1709,15 @@ namespace Game { } void Unit::setTargetPos(const Vec2i & targetPos, bool threaded) { - + Vec2i newTargetPos; if (map->isInside(targetPos) == false || map->isInsideSurface(map->toSurfCoords(targetPos)) == false) { - throw game_runtime_error("#4 Invalid path position = " + - targetPos.getString()); - } + printf("\n#3 Invalid path position = %s\n", targetPos.getString().c_str()); + newTargetPos = Vec2i(); + } else + newTargetPos = targetPos; - Vec2i relPos = targetPos - pos; + Vec2i relPos = newTargetPos - pos; //map->clampPos(relPos); Vec2f relPosf = Vec2f((float) relPos.x, (float) relPos.y); @@ -1733,7 +1733,7 @@ namespace Game { targetRef = NULL; - this->targetPos = targetPos; + this->targetPos = newTargetPos; map->clampPos(this->targetPos); if (threaded) { @@ -2152,7 +2152,7 @@ namespace Game { // we just queue it! } else { - //Delete all lower-prioirty commands + //Delete all lower-priority commands for (list < Command * >::iterator i = commands.begin(); i != commands.end();) { if ((*i)->getPriority() < command_priority) { @@ -2310,6 +2310,7 @@ namespace Game { //push back command if (result.first == crSuccess) { + printf("Success\n"); static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__); MutexSafeWrapper safeMutex(mutexCommands, mutexOwnerId); @@ -2645,16 +2646,18 @@ namespace Game { highlight = 1.f; } - const CommandType *Unit::computeCommandType(const Vec2i & pos, + const CommandType *Unit::computeCommandType(const Vec2i & position, const Unit * targetUnit) const { const CommandType *commandType = NULL; - if (map->isInside(pos) == false - || map->isInsideSurface(map->toSurfCoords(pos)) == false) { - throw game_runtime_error("#6 Invalid path position = " + - pos.getString()); - } + Vec2i pos; + if (map->isInside(position) == false + || map->isInsideSurface(map->toSurfCoords(position)) == false) { + printf("\n#6 Invalid path position = %s\n", position.getString().c_str()); + pos = Vec2i(); + } else + pos = position; SurfaceCell *sc = map->getSurfaceCell(Map::toSurfCoords(pos)); @@ -2740,9 +2743,6 @@ namespace Game { if (this->getType()->hasSkillClass(scAttack) && (targetUnit == NULL || this->getTeam() != targetUnit->getTeam())) command = ccAttack; commandType = type->getFirstCtOfClass(command); - - // FIXME: I think a better solution would be to have a hotkey for this, - // the user can decide, and toggle in-game -andy5995 2018-02-03 } return commandType; @@ -4594,16 +4594,14 @@ namespace Game { // ==================== PRIVATE ==================== - float Unit::computeHeight(const Vec2i & pos) const { - //printf("CRASHING FOR UNIT: %d alive = %d\n",this->getId(),this->isAlive()); - //printf("[%s]\n",this->getType()->getName().c_str()); - if (map->isInside(pos) == false - || map->isInsideSurface(map->toSurfCoords(pos)) == false) { - //printf("CRASHING FOR UNIT: %d [%s] alive = %d\n",this->getId(),this->getType()->getName().c_str(),this->isAlive()); - //abort(); - throw game_runtime_error("#7 Invalid path position = " + - pos.getString()); - } + float Unit::computeHeight(const Vec2i & position) const { + Vec2i pos; + if (map->isInside(position) == false + || map->isInsideSurface(map->toSurfCoords(position)) == false) { + printf("\n#7 Invalid path position = %s\n", position.getString().c_str()); + pos = Vec2i(); + } else + pos = position; float height = map->getCell(pos)->getHeight(); @@ -5453,15 +5451,15 @@ namespace Game { } void Unit::setMeetingPos(const Vec2i & meetingPos) { - this->meetingPos = meetingPos; - map->clampPos(this->meetingPos); + Vec2i pos; + if (map->isInside(meetingPos) == false + || map->isInsideSurface(map->toSurfCoords(meetingPos)) == false) { + printf("\n#8 Invalid path position = %s\n", meetingPos.getString().c_str()); + this->meetingPos = Vec2i(); + } else + this->meetingPos = meetingPos; - if (map->isInside(this->meetingPos) == false - || map->isInsideSurface(map->toSurfCoords(this->meetingPos)) == - false) { - throw game_runtime_error("#8 Invalid path position = " + - this->meetingPos.getString()); - } + map->clampPos(this->meetingPos); logSynchData(extractFileFromDirectoryPath(__FILE__).c_str(), __LINE__); diff --git a/source/map_editor/main.cpp b/source/map_editor/main.cpp index 882a58782..767e65906 100644 --- a/source/map_editor/main.cpp +++ b/source/map_editor/main.cpp @@ -1274,7 +1274,7 @@ wxT("Help")).ShowModal(); switch (enabledGroup) { case ctHeight: - program->glestChangeMapHeight(x, y, height, radius); + program->changeMapHeight(x, y, height, radius); break; case ctSurface: program->changeMapSurface(x, y, surface, radius); diff --git a/source/map_editor/program.cpp b/source/map_editor/program.cpp index a97be58c7..fe8f63bef 100644 --- a/source/map_editor/program.cpp +++ b/source/map_editor/program.cpp @@ -210,8 +210,8 @@ namespace MapEditor { } } - void Program::glestChangeMapHeight(int x, int y, int Height, int radius) { - if (map) map->glestChangeHeight((x - ofsetX) / cellSize, (y + ofsetY) / cellSize, Height, radius); + void Program::changeMapHeight(int x, int y, int Height, int radius) { + if (map) map->changeHeight((x - ofsetX) / cellSize, (y + ofsetY) / cellSize, Height, radius); } void Program::pirateChangeMapHeight(int x, int y, int Height, int radius) { diff --git a/source/map_editor/program.h b/source/map_editor/program.h index f6d4632d3..b3508f7d2 100644 --- a/source/map_editor/program.h +++ b/source/map_editor/program.h @@ -133,7 +133,7 @@ namespace MapEditor { } //map cell change - void glestChangeMapHeight(int x, int y, int Height, int radius); + void changeMapHeight(int x, int y, int Height, int radius); void pirateChangeMapHeight(int x, int y, int Height, int radius); void changeMapSurface(int x, int y, int surface, int radius); void changeMapObject(int x, int y, int object, int radius); diff --git a/source/shared_lib/include/map/map_preview.h b/source/shared_lib/include/map/map_preview.h index 51bbc254b..f43d08af8 100644 --- a/source/shared_lib/include/map/map_preview.h +++ b/source/shared_lib/include/map/map_preview.h @@ -222,7 +222,7 @@ namespace Shared { return author; } - void glestChangeHeight(int x, int y, int height, int radius); + void changeHeight(int x, int y, int height, int radius); void pirateChangeHeight(int x, int y, int height, int radius); void changeSurface(int x, int y, MapSurfaceType surface, int radius); void changeObject(int x, int y, int object, int radius); diff --git a/source/shared_lib/include/platform/sdl/gl_wrap.h b/source/shared_lib/include/platform/sdl/gl_wrap.h index b0cdc8d8d..977845888 100644 --- a/source/shared_lib/include/platform/sdl/gl_wrap.h +++ b/source/shared_lib/include/platform/sdl/gl_wrap.h @@ -20,19 +20,10 @@ #ifndef _SHARED_PLATFORM_GLWRAP_H_ #define _SHARED_PLATFORM_GLWRAP_H_ +#include + #ifdef WIN32 - #include - -#include - -#define GLEST_GLPROC(X, Y) inline X( static a= wglGetProcAddress(a); return a;) - -#else - -#include -#define GL_GLEXT_PROTOTYPES - #endif #include diff --git a/source/shared_lib/sources/feathery_ftp/ftpCmds.c b/source/shared_lib/sources/feathery_ftp/ftpCmds.c index 2156be5ea..27cc8ebaa 100644 --- a/source/shared_lib/sources/feathery_ftp/ftpCmds.c +++ b/source/shared_lib/sources/feathery_ftp/ftpCmds.c @@ -456,7 +456,7 @@ LOCAL int ftpCmdRetr(int sessionId, const char* args, int len) { if (ftpIsClientAllowedToGetFile != NULL) { if (ftpIsClientAllowedToGetFile(ftpGetSession(sessionId)->remoteIp, ftpFindAccountById(ftpGetSession(sessionId)->userId), realPath) != 1) { - if (VERBOSE_MODE_ENABLED) printf("ERROR In ftpCmdRetr FILE DISALLOWED By MGserver [file not available] args [%s] realPath [%s]\n", args, realPath); + if (VERBOSE_MODE_ENABLED) printf("ERROR In ftpCmdRetr FILE DISALLOWED By server [file not available] args [%s] realPath [%s]\n", args, realPath); ftpSendMsg(MSG_NORMAL, sessionId, 550, ftpMsg032); return 2; diff --git a/source/shared_lib/sources/graphics/font.cpp b/source/shared_lib/sources/graphics/font.cpp index 589bf1dc3..af9fe7bd2 100644 --- a/source/shared_lib/sources/graphics/font.cpp +++ b/source/shared_lib/sources/graphics/font.cpp @@ -609,11 +609,11 @@ namespace Shared { } // Get user-specified font path - string glest_font = safeCharPtrCopy(getenv("GAME_FONT"), 8095); - string glest_font_family = safeCharPtrCopy(getenv("GAME_FONT_FAMILY"), 8095); - if (glest_font != "" || glest_font_family != "") { - if (glest_font != "") { - tryFont = glest_font; + string game_font = safeCharPtrCopy(getenv("GAME_FONT"), 8095); + string game_font_family = safeCharPtrCopy(getenv("GAME_FONT_FAMILY"), 8095); + if (game_font != "" || game_font_family != "") { + if (game_font != "") { + tryFont = game_font; if (Text::DEFAULT_FONT_PATH_ABSOLUTE != "") { tryFont = Text::DEFAULT_FONT_PATH_ABSOLUTE + "/" + extractFileFromDirectoryPath(tryFont); @@ -622,9 +622,9 @@ namespace Shared { replaceAll(tryFont, "/", "\\"); #endif - CHECK_FONT_PATH(tryFont.c_str(), glest_font_family.c_str(), &font, &path); + CHECK_FONT_PATH(tryFont.c_str(), game_font_family.c_str(), &font, &path); } else { - CHECK_FONT_PATH(NULL, glest_font_family.c_str(), &font, &path); + CHECK_FONT_PATH(NULL, game_font_family.c_str(), &font, &path); } } diff --git a/source/shared_lib/sources/map/map_preview.cpp b/source/shared_lib/sources/map/map_preview.cpp index d66cca38a..0f856ccbd 100644 --- a/source/shared_lib/sources/map/map_preview.cpp +++ b/source/shared_lib/sources/map/map_preview.cpp @@ -129,8 +129,7 @@ namespace Shared { #endif } - void MapPreview::glestChangeHeight(int x, int y, int height, int radius) { - + void MapPreview::changeHeight(int x, int y, int height, int radius) { for (int i = x - radius + 1; i < x + radius; i++) { for (int j = y - radius + 1; j < y + radius; j++) { if (inside(i, j)) { diff --git a/source/shared_lib/sources/platform/sdl/gl_wrap.cpp b/source/shared_lib/sources/platform/sdl/gl_wrap.cpp index 8595377b9..1913d8d71 100644 --- a/source/shared_lib/sources/platform/sdl/gl_wrap.cpp +++ b/source/shared_lib/sources/platform/sdl/gl_wrap.cpp @@ -254,7 +254,6 @@ namespace Shared { icon = NULL; } - //printf("Loading icon [%s]\n",mg_icon_file.c_str()); if (extractExtension(icon_file) == "bmp") { icon = SDL_LoadBMP(icon_file.c_str()); } else { diff --git a/update.sh b/update.sh new file mode 100644 index 000000000..bddc158df --- /dev/null +++ b/update.sh @@ -0,0 +1 @@ +git pull \ No newline at end of file