Browse Source

Fixed a compile error on MSVC with abs(ui64).
Fixed crash when quest object is removed.

Michał W. Urbańczyk 13 years ago
parent
commit
9207e4f4a4
2 changed files with 9 additions and 3 deletions
  1. 7 0
      client/UIFramework/SDL_Extensions.h
  2. 2 3
      lib/NetPacksLib.cpp

+ 7 - 0
client/UIFramework/SDL_Extensions.h

@@ -48,6 +48,13 @@ namespace Colors
 	const SDL_Color Maize = createColor(242, 226, 110); // http://en.wikipedia.org/wiki/Maize_%28color%29
 }
 
+//MSVC gives an error when calling abs with ui64 -> we add template that will match calls with unsigned arg and return it
+template<typename T>
+typename boost::enable_if_c<boost::is_unsigned<T>::type, T>::type abs(T arg)
+{
+	return arg;
+}
+
 template<typename IntType>
 std::string makeNumberShort(IntType number) //the output is a string containing at most 5 characters [4 if positive] (eg. intead 10000 it gives 10k)
 {

+ 2 - 3
lib/NetPacksLib.cpp

@@ -308,14 +308,13 @@ DLL_LINKAGE void RemoveObject::applyGs( CGameState *gs )
 
 		return;
 	}
-	//FIXME: for some reason this code causes crash in Bonus System ?!
 
 	auto quest = dynamic_cast<const CQuest *>(obj);
 	if (quest)
 	{
-		BOOST_FOREACH (auto player, gs->players)
+		BOOST_FOREACH (auto &player, gs->players)
 		{
-			BOOST_FOREACH (auto q, player.second.quests)
+			BOOST_FOREACH (auto &q, player.second.quests)
 			{
 				if (q.obj == obj)
 				{