Pārlūkot izejas kodu

get rid of global debug macros.

AlexVinS 10 gadi atpakaļ
vecāks
revīzija
aa5e9fc959
5 mainītis faili ar 35 papildinājumiem un 40 dzēšanām
  1. 0 29
      Global.h
  2. 6 1
      client/CPreGame.cpp
  3. 17 3
      client/Client.cpp
  4. 6 6
      lib/VCMI_Lib.cpp
  5. 6 1
      server/CGameHandler.cpp

+ 0 - 29
Global.h

@@ -220,35 +220,6 @@ typedef boost::lock_guard<boost::recursive_mutex> TLockGuardRec;
 
 #define ASSERT_IF_CALLED_WITH_PLAYER if(!player) {logGlobal->errorStream() << BOOST_CURRENT_FUNCTION; assert(0);}
 
-//XXX pls dont - 'debug macros' are usually more trouble than it's worth
-#define HANDLE_EXCEPTION  \
-    catch (const std::exception& e) {	\
-	logGlobal->errorStream() << e.what();		\
-    throw;								\
-}									\
-    catch (const std::exception * e)	\
-{									\
-	logGlobal->errorStream() << e->what();	\
-    throw;							\
-}									\
-    catch (const std::string& e) {		\
-	logGlobal->errorStream() << e;		\
-    throw;							\
-}
-
-#define HANDLE_EXCEPTIONC(COMMAND)  \
-    catch (const std::exception& e) {	\
-    COMMAND;						\
-	logGlobal->errorStream() << e.what();	\
-    throw;							\
-}									\
-    catch (const std::string &e)	\
-{									\
-    COMMAND;						\
-	logGlobal->errorStream() << e;	\
-    throw;							\
-}
-
 // can be used for counting arrays
 template<typename T, size_t N> char (&_ArrayCountObj(const T (&)[N]))[N];
 #define ARRAY_COUNT(arr)    (sizeof(_ArrayCountObj(arr)))

+ 6 - 1
client/CPreGame.cpp

@@ -974,12 +974,17 @@ void CSelectionScreen::handleConnection()
 				upcomingPacks.push_back(pack);
 			}
 		}
-	} HANDLE_EXCEPTION
+	}
 	catch(int i)
 	{
 		if(i != 666)
 			throw;
 	}
+	catch(...)
+	{
+		handleException();
+		throw;
+	}
 }
 
 void CSelectionScreen::setSInfo(const StartInfo &si)

+ 17 - 3
client/Client.cpp

@@ -150,7 +150,11 @@ void CClient::waitForMoveAndSend(PlayerColor color)
         logNetwork->debugStream() << "Wait for move thread was interrupted and no action will be send. Was a battle ended by spell?";
 		return;
 	}
-	HANDLE_EXCEPTION
+	catch(...)
+	{
+		handleException();
+		return;
+	}
     logNetwork->errorStream() << "We should not be here!";
 }
 
@@ -787,7 +791,11 @@ void CClient::commenceTacticPhaseForInt(shared_ptr<CBattleGameInterface> battleI
 			MakeAction ma(BattleAction::makeEndOFTacticPhase(gs->curB->playerToSide(battleInt->playerID)));
 			sendRequest(&ma, battleInt->playerID);
 		}
-	} HANDLE_EXCEPTION
+	}
+	catch(...)
+	{
+		handleException();
+	}	
 }
 
 void CClient::invalidatePaths()
@@ -964,7 +972,13 @@ CServerHandler::CServerHandler(bool runServer /*= false*/)
 	try
 	{
 		shared = new SharedMem();
-    } HANDLE_EXCEPTIONC(logNetwork->errorStream() << "Cannot open interprocess memory: ";)
+    }
+    catch(...)
+    {
+    	logNetwork->error("Cannot open interprocess memory.");
+    	handleException();
+    	throw;
+    }
 #endif
 }
 

+ 6 - 6
lib/VCMI_Lib.cpp

@@ -40,16 +40,16 @@ DLL_LINKAGE void preinitDLL(CConsoleHandler *Console)
 	{
 		VLC->loadFilesystem();
 	}
-	HANDLE_EXCEPTION;
+	catch(...)
+	{
+		handleException();
+		throw;
+	}
 }
 
 DLL_LINKAGE void loadDLLClasses()
 {
-	//try
-	{
-		VLC->init();
-	}
-	//HANDLE_EXCEPTION;
+	VLC->init();
 }
 
 const IBonusTypeHandler * LibClasses::getBth() const

+ 6 - 1
server/CGameHandler.cpp

@@ -942,7 +942,12 @@ void CGameHandler::handleConnection(std::set<PlayerColor> players, CConnection &
         logGlobal->errorStream() << e.what();
 		end2 = true;
 	}
-	HANDLE_EXCEPTION(end2 = true);
+	catch(...)
+	{
+		end2 = true;
+		handleException();
+		throw;
+	}
 
     logGlobal->errorStream() << "Ended handling connection";
 }