[atlantik-cvs] CVS: kdegames/atlantik/libatlantikui board.cpp, 1.96.6.12, 1.96.6.13

[email protected] Fri, 10 Oct 2003 04:18:34 +0200 (CEST)
Newsgroups gmane.comp.kde.devel.atlantik
Message-ID <[email protected]>
Update of /home/kde/kdegames/atlantik/libatlantikui
In directory office:/tmp/cvs-serv19302/libatlantikui

Modified Files:
      Tag: KDE_3_1_BRANCH
	board.cpp 
Log Message:
backported bugfix: atlantikdesigner crashed on startup because it uses the board without a Core, have proper checks on whether the core exists

Index: board.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/libatlantikui/board.cpp,v
retrieving revision 1.96.6.12
retrieving revision 1.96.6.13
diff -u -d -r1.96.6.12 -r1.96.6.13
--- board.cpp	14 Jul 2003 03:03:33 -0000	1.96.6.12
+++ board.cpp	10 Oct 2003 02:18:31 -0000	1.96.6.13
@@ -202,17 +202,15 @@
 		return;
 	}
 
-	Player *playerSelf = m_atlanticCore->playerSelf();
-	if (playerSelf)
+	Player *playerSelf = 0;
+	if (m_atlanticCore)
+		playerSelf = m_atlanticCore->playerSelf();
+
+	if (playerSelf && playerSelf->gameId() != player->gameId() )
 	{
-		if (playerSelf->gameId() != player->gameId())
-		{
-			kdDebug() << "addToken - not in same game" << endl;
-			return;
-		}
+		kdDebug() << "addToken ignored - not in same game as playerSelf" << endl;
+		return;
 	}
-	else
-		kdDebug() << "addToken - no playerSelf" << endl;
 
 	Token *token = new Token(player, this, "token");
 	m_tokens.append(token);
@@ -226,7 +224,9 @@
 
 void AtlantikBoard::playerChanged(Player *player)
 {
-	Player *playerSelf = m_atlanticCore->playerSelf();
+ 	Player *playerSelf = 0;
+ 	if (m_atlanticCore)
+ 		playerSelf = m_atlanticCore->playerSelf();
 
 	// Update token
 	Token *token = findToken(player);
@@ -368,6 +368,13 @@
 
 void AtlantikBoard::slotMoveToken()
 {
+	// Requires a core with estates to operate on
+	if (!m_atlanticCore)
+	{
+		kdDebug() << "slotMoveToken ignored - no atlanticCore" << endl;
+		return;
+	}
+
 	// Do we actually have a token to move?
 	if (!m_movingToken)
 	{