diff --git a/Generals/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp b/Generals/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp index 92d3f2bd83..44f527814d 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp @@ -2146,19 +2146,17 @@ void GameLogic::loadMapINI( AsciiString mapName ) return; } - char filename[_MAX_PATH]; - char fullFledgeFilename[_MAX_PATH]; - // // if map name begins with a "SAVE_DIRECTORY\", then the map refers to a map // that has been extracted from a save game file ... in that case we need to get // the pristine map name string in order to manipulate and load the right map.ini // for that map from it's original location // - const char* pristineMapName = TheGameState->isInSaveDirectory(filename) + const char* pristineMapName = TheGameState->isInSaveDirectory(mapName.str()) ? TheGameState->getSaveGameInfo()->pristineMapName.str() : mapName.str(); + char filename[_MAX_PATH]; strlcpy(filename, pristineMapName, ARRAY_SIZE(filename)); // sanity @@ -2175,6 +2173,7 @@ void GameLogic::loadMapINI( AsciiString mapName ) *extension = 0; + char fullFledgeFilename[_MAX_PATH]; sprintf(fullFledgeFilename, "%s\\map.ini", filename); if (TheFileSystem->doesFileExist(fullFledgeFilename)) { DEBUG_LOG(("Loading map.ini")); diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp index 59e1c7e6d7..1275f07557 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp @@ -2463,19 +2463,17 @@ void GameLogic::loadMapINI( AsciiString mapName ) return; } - char filename[_MAX_PATH]; - char fullFledgeFilename[_MAX_PATH]; - // // if map name begins with a "SAVE_DIRECTORY\", then the map refers to a map // that has been extracted from a save game file ... in that case we need to get // the pristine map name string in order to manipulate and load the right map.ini // for that map from it's original location // - const char* pristineMapName = TheGameState->isInSaveDirectory(filename) + const char* pristineMapName = TheGameState->isInSaveDirectory(mapName.str()) ? TheGameState->getSaveGameInfo()->pristineMapName.str() : mapName.str(); + char filename[_MAX_PATH]; strlcpy(filename, pristineMapName, ARRAY_SIZE(filename)); // sanity @@ -2492,6 +2490,7 @@ void GameLogic::loadMapINI( AsciiString mapName ) *extension = 0; + char fullFledgeFilename[_MAX_PATH]; sprintf(fullFledgeFilename, "%s\\map.ini", filename); if (TheFileSystem->doesFileExist(fullFledgeFilename)) { DEBUG_LOG(("Loading map.ini"));