netserver/HWProto.hs
changeset 1333 b0b0510eb82d
parent 1332 19ff9bf7d69e
child 1334 b58afaadf7ae
--- a/netserver/HWProto.hs	Thu Oct 09 13:57:18 2008 +0000
+++ b/netserver/HWProto.hs	Thu Oct 09 15:54:09 2008 +0000
@@ -30,7 +30,7 @@
 answerWrongPassword = [(clientOnly, ["WARNING", "Wrong password"])]
 answerChatString nick msg = [(othersInRoom, ["CHAT_STRING", nick, msg])]
 answerConfigParam paramName paramStrs = [(othersInRoom, "CONFIG_PARAM" : paramName : paramStrs)]
-answerFullConfig room = map toAnswer (Map.toList $ params room)
+answerFullConfig room = map toAnswer (Map.toList $ params room) ++ [(clientOnly, ["MAP", gamemap room])]
 	where
 		toAnswer (paramName, paramStrs) =
 			(clientOnly, "CONFIG_PARAM" : paramName : paramStrs)
@@ -47,6 +47,7 @@
 			[(clientOnly, teamToNet team),
 			(clientOnly, ["TEAM_COLOR", teamname team, teamcolor team]),
 			(clientOnly, ["HH_NUM", teamname team, show $ hhnum team])]
+answerMap mapName = [(othersInRoom, ["MAP", mapName])]
 
 -- Main state-independent cmd handler
 handleCmd :: CmdHandler
@@ -103,7 +104,7 @@
 	if haveSameRoom then
 		(noChangeClients, noChangeRooms, answerRoomExists)
 	else
-		(modifyClient client{room = newRoom, isMaster = True}, addRoom (RoomInfo newRoom roomPassword (protocol client) [] Map.empty), answerJoined $ nick client)
+		(modifyClient client{room = newRoom, isMaster = True}, addRoom (RoomInfo newRoom roomPassword (protocol client) [] "+rnd+" Map.empty), answerJoined $ nick client)
 	where
 		haveSameRoom = isJust $ find (\room -> newRoom == name room) rooms
 
@@ -141,6 +142,14 @@
 	where
 		clRoom = roomByName (room client) rooms
 
+handleCmd_inRoom client _ rooms ["MAP", mapName] =
+	if isMaster client then
+		(noChangeClients, modifyRoom clRoom{gamemap = mapName}, answerMap mapName)
+	else
+		(noChangeClients, noChangeRooms, answerNotMaster)
+	where
+		clRoom = roomByName (room client) rooms
+
 handleCmd_inRoom client _ rooms ("ADD_TEAM" : name : color : grave : fort : difStr : hhsInfo)
 	| length hhsInfo == 16 =
 	if length (teams clRoom) == 6 || canAddNumber <= 0 || isJust findTeam then