[atlantik-cvs] CVS: kdegames/atlantik/libatlantikclient atlantik_network.cpp, 1.95.2.4, 1.95.2.5

[email protected] Sun, 23 Nov 2003 18:24:04 +0100 (CET)
Newsgroups gmane.comp.kde.devel.atlantik
Message-ID <[email protected]>
Update of /home/kde/kdegames/atlantik/libatlantikclient
In directory office:/tmp/cvs-serv9127/libatlantikclient

Modified Files:
      Tag: atlantik_3_3_branch
	atlantik_network.cpp 
Log Message:
ensure setMaster succeeds by creating player object if necessary

Index: atlantik_network.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/libatlantikclient/atlantik_network.cpp,v
retrieving revision 1.95.2.4
retrieving revision 1.95.2.5
diff -u -d -r1.95.2.4 -r1.95.2.5
--- atlantik_network.cpp	17 Nov 2003 02:50:42 -0000	1.95.2.4
+++ atlantik_network.cpp	23 Nov 2003 17:24:02 -0000	1.95.2.5
@@ -351,7 +351,6 @@
 					if (game && !a.isNull())
 						game->setCanBeJoined(a.value().toInt());
 
-
 					a = e.attributeNode(QString("description"));
 					if (game && !a.isNull())
 						game->setDescription(a.value());
@@ -364,10 +363,15 @@
 					if (game && !a.isNull())
 						game->setPlayers(a.value().toInt());
 
-					// FIXME: create player if non-existant
 					a = e.attributeNode(QString("master"));
 					if (game && !a.isNull())
-						game->setMaster(m_atlanticCore->findPlayer(a.value().toInt()));
+					{
+						// Ensure setMaster succeeds by creating player if necessary
+						Player *player = m_atlanticCore->findPlayer( a.value().toInt() );
+						if ( !player )
+							player = m_atlanticCore->newPlayer( a.value().toInt() );
+						game->setMaster( player );
+					}
 
 					QString status = e.attributeNode(QString("status")).value();
 					if (status == "config")