- Fix bugs in net server
authorunc0rr
Thu, 08 Jan 2009 15:26:12 +0000
changeset 1598 c853e02ed663
parent 1597 24f2f9fa0160
child 1599 65b5d3cd3e01
- Fix bugs in net server - Frontend disconnection fixes
QTfrontend/hwform.cpp
doc/Release.txt
netserver/HWProto.hs
netserver/Miscutils.hs
netserver/hedgewars-server.hs
--- a/QTfrontend/hwform.cpp	Thu Jan 08 13:04:04 2009 +0000
+++ b/QTfrontend/hwform.cpp	Thu Jan 08 15:26:12 2009 +0000
@@ -315,7 +315,7 @@
 	ui.Pages->setCurrentIndex(id);
 	OnPageShown(id, curid);
 	
-	if (id == ID_PAGE_NETSERVER) {
+	if (id == ID_PAGE_NETSERVER || (id == ID_PAGE_ROOMSLIST && !hwnet)) {
 		GoBack();
 	}
 	if (id == ID_PAGE_NET) {
--- a/doc/Release.txt	Thu Jan 08 13:04:04 2009 +0000
+++ b/doc/Release.txt	Thu Jan 08 15:26:12 2009 +0000
@@ -2,9 +2,10 @@
 2. Update translations (check fireforge for patches)
 3. Check copyright headers
 4. Changelog
-5. Make a branch
-6. Make packages
-7. Test packages
-8. Upload (hedgewars.org, fireforge.net, gna.org)
-9. Post news (hedgewars.org, fireforge.net, gna.org, etc.)
-10. Make tag (svn copy svn+ssh://unc0rr@svn.fireforge.net/svnroot/hedgewars/branches/0.9.7 svn+ssh://unc0rr@svn.fireforge.net/svnroot/hedgewars/tags/0.9.7 -m "Tag for 0.9.7 release")
\ No newline at end of file
+5. Turn debug stuff off (frontend console output)
+6. Make a branch
+7. Make packages
+8. Test packages
+9. Upload (hedgewars.org, fireforge.net, gna.org)
+10. Post news (hedgewars.org, fireforge.net, gna.org, etc.)
+11. Make tag (svn copy svn+ssh://unc0rr@svn.fireforge.net/svnroot/hedgewars/branches/0.9.7 svn+ssh://unc0rr@svn.fireforge.net/svnroot/hedgewars/tags/0.9.7 -m "Tag for 0.9.7 release")
\ No newline at end of file
--- a/netserver/HWProto.hs	Thu Jan 08 13:04:04 2009 +0000
+++ b/netserver/HWProto.hs	Thu Jan 08 15:26:12 2009 +0000
@@ -21,7 +21,6 @@
 answerClientOnly  = makeAnswer clientOnly
 answerOthersRoom  = makeAnswer othersInRoom
 answerSameRoom    = makeAnswer sameRoom
-answerFromRoom roomName = makeAnswer (fromRoom roomName)
 answerSameProtoLobby = makeAnswer sameProtoLobbyClients
 answerAll         = makeAnswer allClients
 
@@ -70,7 +69,7 @@
 		else
 		answerOthersRoom ["LEFT", nick]
 
-answerPartInform nick roomName = answerFromRoom roomName ["LEFT", nick, "bye room"]
+answerPartInform nick = answerOthersRoom ["LEFT", nick, "bye room"]
 answerQuitLobby nick msg =
 	if not $ null nick then
 		if not $ null msg then
@@ -270,9 +269,9 @@
 
 handleCmd_inRoom client _ rooms ["PART"] =
 	if isMaster client then
-		(modifyRoomClients clRoom (\cl -> cl{room = [], isReady = False}), removeRoom (room client), (answerAbandoned $ protocol client) ++ (answerRoomDeleted $ room client))
+		(modifyRoomClients clRoom (\cl -> cl{room = [], isReady = False, isMaster = False}), removeRoom (room client), (answerAbandoned $ protocol client) ++ (answerRoomDeleted $ room client))
 	else
-		(modifyClient client{room = [], isReady = False}, modifyRoom clRoom{teams = othersTeams, playersIn = (playersIn clRoom) - 1, readyPlayers = newReadyPlayers}, (answerPartInform (room client) (nick client)) ++ answerRemoveClientTeams)
+		(modifyClient client{isReady = False, partRoom = True}, modifyRoom clRoom{teams = othersTeams, playersIn = (playersIn clRoom) - 1, readyPlayers = newReadyPlayers}, (answerPartInform (nick client)) ++ answerRemoveClientTeams)
 	where
 		clRoom = roomByName (room client) rooms
 		answerRemoveClientTeams = concatMap (\tn -> answerOthersRoom ["REMOVE_TEAM", teamname tn]) clientTeams
--- a/netserver/Miscutils.hs	Thu Jan 08 13:04:04 2009 +0000
+++ b/netserver/Miscutils.hs	Thu Jan 08 15:26:12 2009 +0000
@@ -23,7 +23,8 @@
 		room :: String,
 		isMaster :: Bool,
 		isReady :: Bool,
-		forceQuit :: Bool
+		forceQuit :: Bool,
+		partRoom :: Bool
 	}
 
 instance Eq ClientInfo where
--- a/netserver/hedgewars-server.hs	Thu Jan 08 13:04:04 2009 +0000
+++ b/netserver/hedgewars-server.hs	Thu Jan 08 15:26:12 2009 +0000
@@ -51,7 +51,21 @@
 	forkIO $ clientRecvLoop cHandle cChan
 	forkIO $ clientSendLoop cHandle cChan sendChan
 	
-	atomically $ writeTChan acceptChan (ClientInfo cChan sendChan cHandle host currentTime "" 0 "" False False False)
+	atomically $ writeTChan acceptChan
+			(ClientInfo
+				cChan
+				sendChan
+				cHandle
+				host
+				currentTime
+				""
+				0
+				""
+				False
+				False
+				False
+				False)
+
 	atomically $ writeTChan cChan ["ASKME"]
 	acceptLoop servSock acceptChan
 
@@ -123,8 +137,9 @@
 
 	clientsIn <- sendAnswers answers mclient mclients mrooms
 	mapM_ (\cl -> atomically $ writeTChan (chan cl) ["QUIT", "Kicked"]) $ filter forceQuit $ clientsIn
-	
-	return (clientsIn, mrooms)
+
+	let clientsFinal = map (\cl -> if partRoom cl then cl{room = [], partRoom = False} else cl) clientsIn
+	return (clientsFinal, mrooms)
 
 
 mainLoop :: ServerInfo -> TChan ClientInfo -> TChan [String] -> [ClientInfo] -> [RoomInfo] -> IO ()