瀏覽代碼

Compile fix for MSVC.
Fixed crash when no maps are present.
Fixed crash on opening the loading screen.
Fixed crash on starting the turn when Games/ subfolder is not present.

Michał W. Urbańczyk 13 年之前
父節點
當前提交
27f8408c52
共有 3 個文件被更改,包括 10 次插入5 次删除
  1. 5 1
      client/CPlayerInterface.cpp
  2. 4 3
      client/CPreGame.cpp
  3. 1 1
      client/UIFramework/CIntObject.cpp

+ 5 - 1
client/CPlayerInterface.cpp

@@ -1579,10 +1579,14 @@ int CPlayerInterface::getLastIndex( std::string namePrefix)
 	using namespace boost::filesystem;
 	using namespace boost::algorithm;
 
+	path gamesDir = GVCMIDirs.UserPath + "/Games";
 	std::map<std::time_t, int> dates; //save number => datestamp
 
 	directory_iterator enddir;
-	for (directory_iterator dir(GVCMIDirs.UserPath + "/Games"); dir!=enddir; dir++)
+	if(!exists(gamesDir))
+		create_directory(gamesDir);
+
+	for (directory_iterator dir(gamesDir); dir!=enddir; dir++)
 	{
 		if(is_regular(dir->status()))
 		{

+ 4 - 3
client/CPreGame.cpp

@@ -801,13 +801,14 @@ void CSelectionScreen::changeSelection(const CMapInfo * to)
 
 		if(screenType == CMenuScreen::newGame)
 		{
-			sInfo.createRandomMap = to->isRandomMap;
-			if(to->isRandomMap)
+			if(to && to->isRandomMap)
 			{
+				sInfo.createRandomMap = true;
 				sInfo.mapGenOptions = std::shared_ptr<CMapGenOptions>(new CMapGenOptions(randMapTab->getMapGenOptions()));
 			}
 			else
 			{
+				sInfo.createRandomMap = false;
 				sInfo.mapGenOptions.reset();
 			}
 		}
@@ -4025,7 +4026,7 @@ void CCampaignScreen::showAll(SDL_Surface *to)
 
 void CGPreGame::showLoadingScreen(boost::function<void()> loader)
 {
-	if (GH.listInt.front() == CGP) //pregame active
+	if (GH.listInt.size() && GH.listInt.front() == CGP) //pregame active
 		CGP->removeFromGui();
 	GH.pushInt(new CLoadingScreen(loader));
 }

+ 1 - 1
client/UIFramework/CIntObject.cpp

@@ -2,7 +2,7 @@
 #include "CIntObject.h"
 #include "CGuiHandler.h"
 #include "SDL_Extensions.h"
-#include "CMessage.h"
+#include "../CMessage.h"
 
 CIntObject::CIntObject(int used_, Point pos_):
 	parent_m(nullptr),