瀏覽代碼

* fixed race condition crash
* no crash when there is no creature in dwelling (that should not happen at all... but)
* removed paths from vcxproj, use property sheets

Michał W. Urbańczyk 12 年之前
父節點
當前提交
124d732171
共有 3 個文件被更改,包括 15 次插入15 次删除
  1. 11 2
      client/CCastleInterface.cpp
  2. 4 0
      client/CPreGame.cpp
  3. 0 13
      client/VCMI_client.vcxproj

+ 11 - 2
client/CCastleInterface.cpp

@@ -205,8 +205,17 @@ std::string getBuildingSubtitle(const CStructure * structure)//hover text for bu
 		return t->town->buildings[structure->building->bid]->Name();
 	else//dwellings - recruit %creature%
 	{
-		int creaID = t->creatures[(bid-30)%GameConstants::CREATURES_PER_TOWN].second.back();//taking last of available creatures
-		return CGI->generaltexth->allTexts[16] + " " + CGI->creh->creatures[creaID]->namePl;
+		auto & availableCreatures = t->creatures[(bid-30)%GameConstants::CREATURES_PER_TOWN].second;
+		if(availableCreatures.size())
+		{
+			int creaID = availableCreatures.back();//taking last of available creatures
+			return CGI->generaltexth->allTexts[16] + " " + CGI->creh->creatures[creaID]->namePl;
+		}
+		else
+		{
+			tlog2 << "Problem: dwelling with id " << bid << " offers no creatures!\n";
+			return "#ERROR#";
+		}
 	}
 }
 

+ 4 - 0
client/CPreGame.cpp

@@ -471,9 +471,13 @@ CGPreGame::CGPreGame():
 
 CGPreGame::~CGPreGame()
 {
+	boost::unique_lock<boost::recursive_mutex> lock(*CPlayerInterface::pim); 
 	disposeGraphics();
 	if(CGP == this)
 		CGP = nullptr;
+
+	if(GH.curInt == this)
+		GH.curInt = nullptr;
 }
 
 void CGPreGame::openSel(CMenuScreen::EState screenType, CMenuScreen::EMultiMode multi /*= CMenuScreen::SINGLE_PLAYER*/)

+ 0 - 13
client/VCMI_client.vcxproj

@@ -92,19 +92,6 @@
     <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='RD|Win32'" />
     <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='RD|x64'" />
   </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <IncludePath>C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.0A\Include;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.0A\Include;$(SolutionDir)..\include;$(IncludePath)</IncludePath>
-    <LibraryPath>C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.0A\Lib;$(SolutionDir)..\libs\$(PlatformShortName);$(VCMI_Out);$(LibraryPath)</LibraryPath>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RD|Win32'">
-    <IncludePath>C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.0A\Include;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.0A\Include;$(SolutionDir)..\include;$(IncludePath)</IncludePath>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
-    <IncludePath>C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.0A\Include;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.0A\Include;$(SolutionDir)..\include;$(IncludePath)</IncludePath>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RD|x64'">
-    <IncludePath>C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.0A\Include;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.0A\Include;$(SolutionDir)..\include;$(IncludePath)</IncludePath>
-  </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <AdditionalOptions>/MP4 %(AdditionalOptions)</AdditionalOptions>