From 9b91bf5c68ab8c6d0ff498e97fa7345f5fda406f Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sat, 9 Apr 2011 06:20:43 +0000 Subject: [PATCH] - modified lua method addConsoleText to look in scenario language file for text - added new commandline options to display CRC values for various items (like maps, tilesets etc) --- source/glest_game/game/console.cpp | 4 + source/glest_game/game/console.h | 1 + source/glest_game/main/main.cpp | 184 +++++++++++++++++++++++++++++ source/glest_game/world/world.cpp | 2 +- 4 files changed, 190 insertions(+), 1 deletion(-) diff --git a/source/glest_game/game/console.cpp b/source/glest_game/game/console.cpp index d6f82025..97c39698 100644 --- a/source/glest_game/game/console.cpp +++ b/source/glest_game/game/console.cpp @@ -46,6 +46,10 @@ void Console::addStdMessage(const string &s) { addLine(Lang::getInstance().get(s)); } +void Console::addStdScenarioMessage(const string &s) { + addLine(Lang::getInstance().getScenarioString(s)); +} + void Console::addLine(string line, bool playSound, int playerIndex, Vec3f textColor) { try { if(playSound == true) { diff --git a/source/glest_game/game/console.h b/source/glest_game/game/console.h index 589aaf43..6351fe79 100644 --- a/source/glest_game/game/console.h +++ b/source/glest_game/game/console.h @@ -93,6 +93,7 @@ public: void clearStoredLines(); void addStdMessage(const string &s); + void addStdScenarioMessage(const string &s); void addLine(string line, bool playSound= false,int playerIndex=-1,Vec3f textColor=Vec3f(1.f, 1.f, 1.f)); void addLine(string line, bool playSound,string playerName, Vec3f textColor=Vec3f(1.f, 1.f, 1.f)); void addLine(string line, bool playSound, Vec3f textColor){addLine(line,playSound,"",textColor);} diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 78d6b0ea..3d62ef43 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -112,6 +112,11 @@ const char *GAME_ARGS[] = { "--show-ini-settings", "--convert-models", "--use-language", + "--show-map-crc", + "--show-tileset-crc", + "--show-techtree-crc", + "--show-scenario-crc", + "--show-path-crc", "--disable-backtrace", "--disable-vbo", "--disable-sound", @@ -139,6 +144,13 @@ enum GAME_ARG_TYPE { GAME_ARG_SHOW_INI_SETTINGS, GAME_ARG_CONVERT_MODELS, GAME_ARG_USE_LANGUAGE, + + GAME_ARG_SHOW_MAP_CRC, + GAME_ARG_SHOW_TILESET_CRC, + GAME_ARG_SHOW_TECHTREE_CRC, + GAME_ARG_SHOW_SCENARIO_CRC, + GAME_ARG_SHOW_PATH_CRC, + GAME_ARG_DISABLE_BACKTRACE, GAME_ARG_DISABLE_VBO, GAME_ARG_DISABLE_SOUND, @@ -989,6 +1001,28 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) { printf("\n \t\tWhere x is a supported language (such as english)."); printf("\n \t\texample: %s %s=english",argv0,GAME_ARGS[GAME_ARG_USE_LANGUAGE]); + + printf("\n%s=x\t\tshow the calculated CRC for the map named x.",GAME_ARGS[GAME_ARG_SHOW_MAP_CRC]); + printf("\n \t\tWhere x is a map name."); + printf("\n \t\texample: %s %s=four_rivers",argv0,GAME_ARGS[GAME_ARG_SHOW_MAP_CRC]); + + printf("\n%s=x\t\tshow the calculated CRC for the tileset named x.",GAME_ARGS[GAME_ARG_SHOW_TILESET_CRC]); + printf("\n \t\tWhere x is a tileset name."); + printf("\n \t\texample: %s %s=forest",argv0,GAME_ARGS[GAME_ARG_SHOW_TILESET_CRC]); + + printf("\n%s=x\t\tshow the calculated CRC for the techtree named x.",GAME_ARGS[GAME_ARG_SHOW_TECHTREE_CRC]); + printf("\n \t\tWhere x is a techtree name."); + printf("\n \t\texample: %s %s=megapack",argv0,GAME_ARGS[GAME_ARG_SHOW_TECHTREE_CRC]); + + printf("\n%s=x\t\tshow the calculated CRC for the scenario named x.",GAME_ARGS[GAME_ARG_SHOW_SCENARIO_CRC]); + printf("\n \t\tWhere x is a scenario name."); + printf("\n \t\texample: %s %s=storming",argv0,GAME_ARGS[GAME_ARG_SHOW_SCENARIO_CRC]); + + printf("\n%s=x=y\t\tshow the calculated CRC for files in the path located in x using file filter y.",GAME_ARGS[GAME_ARG_SHOW_PATH_CRC]); + printf("\n \t\tWhere x is a path name."); + printf("\n \t\tand y is file(s) filter."); + printf("\n \t\texample: %s %s=techs/=megapack.7z",argv0,GAME_ARGS[GAME_ARG_SHOW_PATH_CRC]); + printf("\n%s\t\tdisables stack backtrace on errors.",GAME_ARGS[GAME_ARG_DISABLE_BACKTRACE]); printf("\n%s\t\t\tdisables trying to use Vertex Buffer Objects.",GAME_ARGS[GAME_ARG_DISABLE_VBO]); printf("\n%s\t\t\tdisables the sound system.",GAME_ARGS[GAME_ARG_DISABLE_SOUND]); @@ -2150,12 +2184,162 @@ int glestMain(int argc, char** argv) { language = paramPartTokens[1]; printf("Forcing language [%s]\n",language.c_str()); } + else { + printf("\nInvalid missing language specified on commandline [%s] value [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL)); + //printParameterHelp(argv[0],false); + return -1; + } } lang.loadStrings(language); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SHOW_MAP_CRC]) == true) { + int foundParamIndIndex = -1; + hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_SHOW_MAP_CRC]) + string("="),&foundParamIndIndex); + if(foundParamIndIndex < 0) { + hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_SHOW_MAP_CRC]),&foundParamIndIndex); + } + string paramValue = argv[foundParamIndIndex]; + vector paramPartTokens; + Tokenize(paramValue,paramPartTokens,"="); + if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) { + string itemName = paramPartTokens[1]; + + string file = Map::getMapPath(itemName,"",false); + if(file != "") { + Checksum checksum; + checksum.addFile(file); + int32 crcValue = checksum.getSum(); + + printf("CRC value for map [%s] file [%s] is [%d]\n",itemName.c_str(),file.c_str(),crcValue); + } + else { + printf("Map [%s] was NOT FOUND\n",itemName.c_str()); + } + return -1; + } + else { + printf("\nInvalid missing map specified on commandline [%s] value [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL)); + //printParameterHelp(argv[0],false); + return -1; + } + } + + if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SHOW_TILESET_CRC]) == true) { + int foundParamIndIndex = -1; + hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_SHOW_TILESET_CRC]) + string("="),&foundParamIndIndex); + if(foundParamIndIndex < 0) { + hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_SHOW_TILESET_CRC]),&foundParamIndIndex); + } + string paramValue = argv[foundParamIndIndex]; + vector paramPartTokens; + Tokenize(paramValue,paramPartTokens,"="); + if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) { + string itemName = paramPartTokens[1]; + int32 crcValue = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTilesets,""), string("/") + itemName + string("/*"), ".xml", NULL, true); + if(crcValue != 0) { + printf("CRC value for tileset [%s] is [%d]\n",itemName.c_str(),crcValue); + } + else { + printf("Tileset [%s] was NOT FOUND\n",itemName.c_str()); + } + return -1; + } + else { + printf("\nInvalid missing tileset specified on commandline [%s] value [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL)); + //printParameterHelp(argv[0],false); + return -1; + } + } + + if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SHOW_TECHTREE_CRC]) == true) { + int foundParamIndIndex = -1; + hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_SHOW_TECHTREE_CRC]) + string("="),&foundParamIndIndex); + if(foundParamIndIndex < 0) { + hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_SHOW_TECHTREE_CRC]),&foundParamIndIndex); + } + string paramValue = argv[foundParamIndIndex]; + vector paramPartTokens; + Tokenize(paramValue,paramPartTokens,"="); + if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) { + string itemName = paramPartTokens[1]; + int32 crcValue = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + itemName + "/*", ".xml", NULL, true); + if(crcValue != 0) { + printf("CRC value for techtree [%s] is [%d]\n",itemName.c_str(),crcValue); + } + else { + printf("Techtree [%s] was NOT FOUND\n",itemName.c_str()); + } + + return -1; + } + else { + printf("\nInvalid missing techtree specified on commandline [%s] value [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL)); + //printParameterHelp(argv[0],false); + return -1; + } + } + + if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SHOW_SCENARIO_CRC]) == true) { + int foundParamIndIndex = -1; + hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_SHOW_SCENARIO_CRC]) + string("="),&foundParamIndIndex); + if(foundParamIndIndex < 0) { + hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_SHOW_SCENARIO_CRC]),&foundParamIndIndex); + } + string paramValue = argv[foundParamIndIndex]; + vector paramPartTokens; + Tokenize(paramValue,paramPartTokens,"="); + if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) { + string itemName = paramPartTokens[1]; + int32 crcValue = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptScenarios,""), "/" + itemName + "/*", ".xml", NULL, true); + if(crcValue != 0) { + printf("CRC value for scenario [%s] is [%d]\n",itemName.c_str(),crcValue); + } + else { + printf("Scenario [%s] was NOT FOUND\n",itemName.c_str()); + } + + return -1; + } + else { + printf("\nInvalid missing scenario specified on commandline [%s] value [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL)); + //printParameterHelp(argv[0],false); + return -1; + } + } + + if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SHOW_PATH_CRC]) == true) { + int foundParamIndIndex = -1; + hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_SHOW_PATH_CRC]) + string("="),&foundParamIndIndex); + if(foundParamIndIndex < 0) { + hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_SHOW_PATH_CRC]),&foundParamIndIndex); + } + string paramValue = argv[foundParamIndIndex]; + vector paramPartTokens; + Tokenize(paramValue,paramPartTokens,"="); + if(paramPartTokens.size() >= 3 && paramPartTokens[1].length() > 0 && paramPartTokens[2].length() > 0) { + string itemName = paramPartTokens[1]; + string itemNameFilter = paramPartTokens[2]; + int32 crcValue = getFolderTreeContentsCheckSumRecursively(itemName, itemNameFilter, NULL, true); + + printf("CRC value for path [%s] filter [%s] is [%d]\n",itemName.c_str(),itemNameFilter.c_str(),crcValue); + return -1; + } + else { + if(paramPartTokens.size() < 2) { + printf("\nInvalid missing path and filter specified on commandline [%s] value [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL)); + } + if(paramPartTokens.size() < 3) { + printf("\nInvalid missing filter specified on commandline [%s] value [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 3 ? paramPartTokens[2].c_str() : NULL)); + } + + //printParameterHelp(argv[0],false); + return -1; + } + } + //vector techPaths; //vector techDataPaths = config.getPathListForType(ptTechs); //findDirs(techDataPaths, techPaths); diff --git a/source/glest_game/world/world.cpp b/source/glest_game/world/world.cpp index 9c8f29d3..24448ae6 100644 --- a/source/glest_game/world/world.cpp +++ b/source/glest_game/world/world.cpp @@ -986,7 +986,7 @@ void World::togglePauseGame(bool pauseStatus) { } void World::addConsoleText(const string &text) { - game->getConsole()->addStdMessage(text); + game->getConsole()->addStdScenarioMessage(text); } void World::giveUpgradeCommand(int unitId, const string &upgradeName) {