- Remove client teams on exit
authorunc0rr
Fri, 20 Feb 2009 19:46:22 +0000
changeset 1814 e5391d901cff
parent 1813 cfe1481e0247
child 1815 3d62cf9c350e
- Remove client teams on exit - Improve protocol, break frontend compatibility with old server protocol
QTfrontend/newnetclient.cpp
gameServer/HWProtoCore.hs
gameServer/HWProtoInRoomState.hs
--- a/QTfrontend/newnetclient.cpp	Fri Feb 20 19:40:55 2009 +0000
+++ b/QTfrontend/newnetclient.cpp	Fri Feb 20 19:46:22 2009 +0000
@@ -437,23 +437,17 @@
 		return;
 	}
 
-	if (lst[0] == "MAP") {
-		if (lst.size() != 2)
-		{
-			qWarning("Net: Bad MAP message");
-			return;
-		}
-		emit mapChanged(lst[1]);
-		return;
-	}
 
-
-	if (lst[0] == "CONFIG_PARAM") {
+	if (lst[0] == "CFG") {
 		if(lst.size() < 3)
 		{
 			qWarning("Net: Bad CONFIG_PARAM message");
 			return;
 		}
+		if (lst[1] == "MAP") {
+			emit mapChanged(lst[2]);
+			return;
+		}
 		if (lst[1] == "SEED") {
 			emit seedChanged(lst[2]);
 			return;
@@ -614,7 +608,7 @@
 
 void HWNewNet::onMapChanged(const QString & map)
 {
-	if (isChief) RawSendNet(QString("MAP%1%2").arg(delimeter).arg(map));
+	if (isChief) RawSendNet(QString("CONFIG_PARAM%1MAP%1%2").arg(delimeter).arg(map));
 }
 
 void HWNewNet::onThemeChanged(const QString & theme)
--- a/gameServer/HWProtoCore.hs	Fri Feb 20 19:40:55 2009 +0000
+++ b/gameServer/HWProtoCore.hs	Fri Feb 20 19:46:22 2009 +0000
@@ -13,14 +13,16 @@
 
 handleCmd clID _ _ ["PING"] = [AnswerThisClient ["PONG"]]
 
-handleCmd clID clients _ ("QUIT" : xs) =
-	(if isMaster client then [RemoveRoom] else [])
+handleCmd clID clients rooms ("QUIT" : xs) =
+	(if isMaster client then [RemoveRoom] else removeClientTeams)
 	++ [ByeClient msg]
 	where
 		client = clients IntMap.! clID
 		clientNick = nick client
 		msg = if not $ null xs then head xs else ""
-
+		room = rooms IntMap.! (roomID client)
+		clientTeams = filter (\t -> teamowner t == nick client) $ teams room
+		removeClientTeams = map (RemoveTeam . teamname) clientTeams
 
 handleCmd clID clients rooms cmd =
 	if null (nick client) || clientProto client == 0 then
--- a/gameServer/HWProtoInRoomState.hs	Fri Feb 20 19:40:55 2009 +0000
+++ b/gameServer/HWProtoInRoomState.hs	Fri Feb 20 19:46:22 2009 +0000
@@ -19,13 +19,17 @@
 		clientNick = nick $ clients IntMap.! clID
 
 
-handleCmd_inRoom clID clients _ ["PART"] =
+handleCmd_inRoom clID clients rooms ["PART"] =
 	if isMaster client then
 		[RemoveRoom]
 	else
-		[RoomRemoveThisClient]
+		RoomRemoveThisClient
+		: removeClientTeams
 	where
 		client = clients IntMap.! clID
+		room = rooms IntMap.! (roomID client)
+		clientTeams = filter (\t -> teamowner t == nick client) $ teams room
+		removeClientTeams = map (RemoveTeam . teamname) clientTeams
 
 
 handleCmd_inRoom clID clients rooms ("CFG" : paramName : paramStrs) =
@@ -37,7 +41,6 @@
 	where
 		client = clients IntMap.! clID
 
-
 handleCmd_inRoom clID clients rooms ("ADD_TEAM" : name : color : grave : fort : voicepack : difStr : hhsInfo)
 	| length hhsInfo == 16 =
 	if length (teams room) == 6 then