- Fix bug with kicking players
authorunc0rr
Sat, 28 Mar 2009 10:42:00 +0000
changeset 1929 7e6cc8da1c58
parent 1928 9bf8f4f30d6b
child 1930 e71c24f11483
- Fix bug with kicking players - Fix one ready state bug - Improve client's ping handler
QTfrontend/newnetclient.cpp
gameServer/Actions.hs
gameServer/HWProtoCore.hs
gameServer/HWProtoInRoomState.hs
--- a/QTfrontend/newnetclient.cpp	Fri Mar 27 20:36:50 2009 +0000
+++ b/QTfrontend/newnetclient.cpp	Sat Mar 28 10:42:00 2009 +0000
@@ -241,7 +241,10 @@
 	}
 
 	if (lst[0] == "PING") {
-		RawSendNet(QString("PONG"));
+		if (lst.size() > 1)
+			RawSendNet(QString("PONG%1%2").arg(delimeter).arg(lst[1]));
+		else
+			RawSendNet(QString("PONG"));
 		return;
 	}
 
--- a/gameServer/Actions.hs	Fri Mar 27 20:36:50 2009 +0000
+++ b/gameServer/Actions.hs	Sat Mar 28 10:42:00 2009 +0000
@@ -111,17 +111,21 @@
 
 
 processAction (clID, serverInfo, clients, rooms) (ByeClient msg) = do
-	mapM_ (processAction (clID, serverInfo, clients, rooms)) $ answerOthersQuit ++ answerInformRoom
+	(_, _, newClients, newRooms) <-
+			processAction  (clID, serverInfo, clients, rooms)
+					(if isMaster client then RemoveRoom else RemoveClientTeams clID)
+
+	mapM_ (processAction (clID, serverInfo, newClients, newRooms)) $ answerOthersQuit ++ answerInformRoom
 	writeChan (sendChan $ clients ! clID) ["BYE", msg]
 	return (
 			0,
 			serverInfo,
-			delete clID clients,
+			delete clID newClients,
 			adjust (\r -> r{
 					playersIDs = IntSet.delete clID (playersIDs r),
 					playersIn = (playersIn r) - 1,
 					readyPlayers = if isReady client then readyPlayers r - 1 else readyPlayers r
-					}) rID rooms
+					}) rID newRooms
 			)
 	where
 		client = clients ! clID
@@ -180,7 +184,7 @@
 	return (
 		clID,
 		serverInfo,
-		adjust (\cl -> cl{roomID = 0}) clID clients,
+		adjust (\cl -> cl{roomID = 0, isMaster = False, isReady = False}) clID clients,
 		adjust (\r -> r{
 				playersIDs = IntSet.delete clID (playersIDs r),
 				playersIn = (playersIn r) - 1,
--- a/gameServer/HWProtoCore.hs	Fri Mar 27 20:36:50 2009 +0000
+++ b/gameServer/HWProtoCore.hs	Sat Mar 28 10:42:00 2009 +0000
@@ -16,11 +16,8 @@
 handleCmd clID _ _ ["PING"] = [AnswerThisClient ["PONG"]]
 
 handleCmd clID clients rooms ("QUIT" : xs) =
-	(if isMaster client then [RemoveRoom] else [RemoveClientTeams clID])
-	++ [ByeClient msg]
+	[ByeClient msg]
 	where
-		client = clients IntMap.! clID
-		clientNick = nick client
 		msg = if not $ null xs then head xs else ""
 
 
--- a/gameServer/HWProtoInRoomState.hs	Fri Mar 27 20:36:50 2009 +0000
+++ b/gameServer/HWProtoInRoomState.hs	Sat Mar 28 10:42:00 2009 +0000
@@ -205,8 +205,7 @@
 			if (kickID == clID) || (roomID client /= roomID kickClient) then
 				[]
 			else
-				[RemoveClientTeams kickID,
-				KickRoomClient kickID]
+				[KickRoomClient kickID]
 	where
 		client = clients IntMap.! clID
 		maybeClient = Foldable.find (\cl -> kickNick == nick cl) clients