# HG changeset patch # User unc0rr # Date 1231878100 0 # Node ID cefb9d0f816fbaa3cb3a015fe7b93324b9f720d4 # Parent 08c6e36650253ad73e663774687ce7a7142a33a7 Support voicepack info in net server diff -r 08c6e3665025 -r cefb9d0f816f QTfrontend/team.cpp --- a/QTfrontend/team.cpp Tue Jan 13 20:13:36 2009 +0000 +++ b/QTfrontend/team.cpp Tue Jan 13 20:21:40 2009 +0000 @@ -55,15 +55,16 @@ m_isNetTeam(true) { // net teams are configured from QStringList - if(strLst.size() < 20) throw HWTeamConstructException(); + if(strLst.size() < 21) throw HWTeamConstructException(); TeamName = strLst[0]; Grave = strLst[1]; Fort = strLst[2]; - difficulty = strLst[3].toUInt(); + Voicepack = strLst[3]; + difficulty = strLst[4].toUInt(); for(int i = 0; i < 8; i++) { - HHName[i]=strLst[i * 2 + 4]; - HHHat[i]=strLst[i * 2 + 5]; + HHName[i]=strLst[i * 2 + 5]; + HHHat[i]=strLst[i * 2 + 6]; } } diff -r 08c6e3665025 -r cefb9d0f816f netserver/HWProto.hs --- a/netserver/HWProto.hs Tue Jan 13 20:13:36 2009 +0000 +++ b/netserver/HWProto.hs Tue Jan 13 20:21:40 2009 +0000 @@ -13,7 +13,11 @@ import qualified Data.Map as Map import Opts -teamToNet team = ["ADD_TEAM", teamname team, teamgrave team, teamfort team, show $ difficulty team] ++ hhsInfo +teamToNet protocol team = + if protocol == 21 then + ["ADD_TEAM", teamname team, teamgrave team, teamfort team, show $ difficulty team] ++ hhsInfo + else + ["ADD_TEAM", teamname team, teamgrave team, teamfort team, teamvoicepack team, show $ difficulty team] ++ hhsInfo where hhsInfo = concatMap (\(HedgehogInfo name hat) -> [name, hat]) $ hedgehogs team @@ -60,7 +64,7 @@ answerOthersRoom ["ROOMABANDONED"] answerChatString nick msg = answerOthersRoom ["CHAT_STRING", nick, msg] -answerAddTeam team = answerOthersRoom $ teamToNet team +answerAddTeam protocol team = answerOthersRoom $ teamToNet protocol team answerRemoveTeam teamName = answerOthersRoom ["REMOVE_TEAM", teamName] answerMap mapName = answerOthersRoom ["MAP", mapName] answerHHNum teamName hhNumber = answerOthersRoom ["HH_NUM", teamName, show hhNumber] @@ -95,10 +99,10 @@ toAnswer (paramName, paramStrs) = answerClientOnly $ "CONFIG_PARAM" : paramName : paramStrs -answerAllTeams room = concatMap toAnswer (teams room) +answerAllTeams protocol room = concatMap toAnswer (teams room) where toAnswer team = - (answerClientOnly $ teamToNet team) ++ + (answerClientOnly $ teamToNet protocol team) ++ (answerClientOnly ["TEAM_COLOR", teamname team, teamcolor team]) ++ (answerClientOnly ["HH_NUM", teamname team, show $ hhnum team]) @@ -236,7 +240,7 @@ else if isRestrictedJoins clRoom then (noChangeClients, noChangeRooms, answerRestricted) else - (modifyClient client{room = roomName}, modifyRoom clRoom{playersIn = 1 + playersIn clRoom}, (answerJoined $ nick client) ++ answerNicks ++ answerReady ++ (answerNotReady $ nick client) ++ answerFullConfig clRoom ++ answerAllTeams clRoom ++ watchRound) + (modifyClient client{room = roomName}, modifyRoom clRoom{playersIn = 1 + playersIn clRoom}, (answerJoined $ nick client) ++ answerNicks ++ answerReady ++ (answerNotReady $ nick client) ++ answerFullConfig clRoom ++ answerAllTeams (protocol client) clRoom ++ watchRound) where noSuchRoom = isNothing $ find (\room -> roomName == name room && roomProto room == protocol client) rooms answerNicks = answerClientOnly $ ["JOINED"] ++ (map nick $ sameRoomClients) @@ -290,7 +294,7 @@ where clRoom = roomByName (room client) rooms -handleCmd_inRoom client _ rooms ("ADD_TEAM" : name : color : grave : fort : difStr : hhsInfo) +handleCmd_inRoom client _ rooms ("ADD_TEAM" : name : color : grave : fort : voicepack : difStr : hhsInfo) | length hhsInfo == 16 = if length (teams clRoom) == 6 then (noChangeClients, noChangeRooms, answerCantAdd "too many teams") @@ -303,10 +307,10 @@ else if isRestrictedTeams clRoom then (noChangeClients, noChangeRooms, answerCantAdd "restricted") else - (noChangeClients, modifyRoom clRoom{teams = teams clRoom ++ [newTeam]}, answerTeamAccepted newTeam ++ answerAddTeam newTeam ++ answerTeamColor name color) + (noChangeClients, modifyRoom clRoom{teams = teams clRoom ++ [newTeam]}, answerTeamAccepted newTeam ++ answerAddTeam (protocol client) newTeam ++ answerTeamColor name color) where clRoom = roomByName (room client) rooms - newTeam = (TeamInfo (nick client) name color grave fort difficulty newTeamHHNum (hhsList hhsInfo)) + newTeam = (TeamInfo (nick client) name color grave fort voicepack difficulty newTeamHHNum (hhsList hhsInfo)) findTeam = find (\t -> name == teamname t) $ teams clRoom difficulty = fromMaybe 0 (maybeRead difStr :: Maybe Int) hhsList [] = [] @@ -314,6 +318,10 @@ canAddNumber = 18 - (sum . map hhnum $ teams clRoom) newTeamHHNum = min 4 canAddNumber +handleCmd_inRoom client clients rooms ("ADD_TEAM" : name : color : grave : fort : difStr : hhsInfo) = + handleCmd_inRoom client clients rooms ("ADD_TEAM" : name : color : grave : fort : "Default" : difStr : hhsInfo) + + handleCmd_inRoom client _ rooms ["HH_NUM", teamName, numberStr] = if not $ isMaster client then (noChangeClients, noChangeRooms, answerNotMaster) diff -r 08c6e3665025 -r cefb9d0f816f netserver/Miscutils.hs --- a/netserver/Miscutils.hs Tue Jan 13 20:13:36 2009 +0000 +++ b/netserver/Miscutils.hs Tue Jan 13 20:21:40 2009 +0000 @@ -42,6 +42,7 @@ teamcolor :: String, teamgrave :: String, teamfort :: String, + teamvoicepack :: String, difficulty :: Int, hhnum :: Int, hedgehogs :: [HedgehogInfo]