Stub to run network game
authorunc0rr
Thu, 09 Oct 2008 17:28:22 +0000
changeset 1338 758c39a3dcfe
parent 1337 b652c002633b
child 1339 8a11157c6c81
Stub to run network game
QTfrontend/newnetclient.cpp
netserver/HWProto.hs
--- a/QTfrontend/newnetclient.cpp	Thu Oct 09 17:15:04 2008 +0000
+++ b/QTfrontend/newnetclient.cpp	Thu Oct 09 17:28:22 2008 +0000
@@ -255,15 +255,15 @@
 		return;
 	}
 
-  if (lst[0] == "REMOVE_TEAM") {
-    if(lst.size() != 2)
-    {
-      qWarning("Net: Bad REMOVETEAM message");
-      return;
-    }
-    m_pTeamSelWidget->removeNetTeam(HWTeam(lst[1]));
-    return;
-  }
+	if (lst[0] == "REMOVE_TEAM") {
+		if(lst.size() != 2)
+		{
+			qWarning("Net: Bad REMOVETEAM message");
+			return;
+		}
+		m_pTeamSelWidget->removeNetTeam(HWTeam(lst[1]));
+		return;
+	}
 
 	if(lst[0]=="JOINED") {
 		if(lst.size() < 2)
@@ -296,7 +296,7 @@
 		return;
 	}
 
-	if (lst[0] == "RUNGAME") {
+	if (lst[0] == "RUN_GAME") {
 		RunGame();
 		return;
 	}
--- a/netserver/HWProto.hs	Thu Oct 09 17:15:04 2008 +0000
+++ b/netserver/HWProto.hs	Thu Oct 09 17:28:22 2008 +0000
@@ -48,6 +48,7 @@
 			(clientOnly, ["TEAM_COLOR", teamname team, teamcolor team]),
 			(clientOnly, ["HH_NUM", teamname team, show $ hhnum team])]
 answerMap mapName = [(othersInRoom, ["MAP", mapName])]
+answerRunGame = [(sameRoom, ["RUN_GAME"])]
 
 -- Main state-independent cmd handler
 handleCmd :: CmdHandler
@@ -211,4 +212,13 @@
 		findTeam = find (\t -> teamName == teamname t) $ teams clRoom
 		clRoom = roomByName (room client) rooms
 
+handleCmd_inRoom client _ _ ["READY"] =
+	if not $ isMaster client then
+		(noChangeClients, noChangeRooms, answerNotMaster)
+	else
+		(noChangeClients, noChangeRooms, answerRunGame)
+
+handleCmd_inRoom client _ _ ["GAMEMSG", msg] =
+	(noChangeClients, noChangeRooms, [(othersInRoom, ["GAMEMSG", msg])])
+
 handleCmd_inRoom _ _ _ _ = (noChangeClients, noChangeRooms, answerBadCmd)