# HG changeset patch
# User unc0rr
# Date 1351453436 -14400
# Node ID bd76ca40db680ef5e3bb22938f837a613813ffac
# Parent a90936219ffad888bff85a5624c70e7ae8aa7f26
Choose first unused color for added team (addresses issue 431) + other small changes
diff -r a90936219ffa -r bd76ca40db68 gameServer/CoreTypes.hs
--- a/gameServer/CoreTypes.hs Sun Oct 28 20:35:08 2012 +0100
+++ b/gameServer/CoreTypes.hs Sun Oct 28 23:43:56 2012 +0400
@@ -142,7 +142,6 @@
latestReleaseVersion :: Word16,
earliestCompatibleVersion :: Word16,
listenPort :: PortNumber,
- --nextRoomID :: Int,
dbHost :: B.ByteString,
dbName :: B.ByteString,
dbLogin :: B.ByteString,
@@ -162,11 +161,10 @@
ServerInfo
True
"
http://www.hedgewars.org/
"
- "Hedgewars 0.9.17 is out! Please update.
Download page here
"
- 41
- 43 -- 0.9.18
+ "Hedgewars 0.9.18 is out! Please update.
Download page here
"
+ 43 -- latestReleaseVersion
+ 41 -- earliestCompatibleVersion
46631
- --0
""
""
""
diff -r a90936219ffa -r bd76ca40db68 gameServer/HWProtoInRoomState.hs
--- a/gameServer/HWProtoInRoomState.hs Sun Oct 28 20:35:08 2012 +0100
+++ b/gameServer/HWProtoInRoomState.hs Sun Oct 28 23:43:56 2012 +0400
@@ -3,7 +3,7 @@
import qualified Data.Map as Map
import Data.Sequence((|>))
-import Data.List
+import Data.List as L
import Data.Maybe
import qualified Data.ByteString.Char8 as B
import Control.Monad
@@ -52,6 +52,13 @@
clNick <- clientNick
clChan <- thisClientChans
othChans <- roomOthersChans
+ roomChans <- roomClientsChans
+ cl <- thisClient
+ teamColor <-
+ if clientProto cl < 42 then
+ return color
+ else
+ liftM (head . (L.\\) (map B.singleton ['0'..]) . map teamcolor . teams) thisRoom
return $
if not . null . drop (maxTeams rm - 1) $ teams rm then
[Warning "too many teams"]
@@ -64,16 +71,16 @@
else if isRestrictedTeams rm then
[Warning "restricted"]
else
- [ModifyRoom (\r -> r{teams = teams r ++ [newTeam ci clNick r]}),
- ModifyClient (\c -> c{teamsInGame = teamsInGame c + 1, clientClan = Just color}),
+ [ModifyRoom (\r -> r{teams = teams r ++ [newTeam ci clNick r teamColor]}),
+ ModifyClient (\c -> c{teamsInGame = teamsInGame c + 1, clientClan = Just teamColor}),
AnswerClients clChan ["TEAM_ACCEPTED", tName],
- AnswerClients othChans $ teamToNet $ newTeam ci clNick rm,
- AnswerClients othChans ["TEAM_COLOR", tName, color]
+ AnswerClients othChans $ teamToNet $ newTeam ci clNick rm teamColor,
+ AnswerClients roomChans ["TEAM_COLOR", tName, teamColor]
]
where
canAddNumber r = 48 - (sum . map hhnum $ teams r)
findTeam = find (\t -> tName == teamname t) . teams
- newTeam ci clNick r = TeamInfo ci clNick tName color grave fort voicepack flag dif (newTeamHHNum r) (hhsList hhsInfo)
+ newTeam ci clNick r tColor = TeamInfo ci clNick tName tColor grave fort voicepack flag dif (newTeamHHNum r) (hhsList hhsInfo)
dif = readInt_ difStr
hhsList [] = []
hhsList [_] = error "Hedgehogs list with odd elements number"
diff -r a90936219ffa -r bd76ca40db68 gameServer/HWProtoLobbyState.hs
--- a/gameServer/HWProtoLobbyState.hs Sun Oct 28 20:35:08 2012 +0100
+++ b/gameServer/HWProtoLobbyState.hs Sun Oct 28 23:43:56 2012 +0400
@@ -53,7 +53,7 @@
[
AddRoom rName roomPassword
, AnswerClients [sendChan cl] ["CLIENT_FLAGS", "+hr", nick cl]
- , ModifyClient (\cl -> cl{isMaster = True, isReady = True})
+ , ModifyClient (\c -> c{isMaster = True, isReady = True})
, ModifyRoom (\r -> r{readyPlayers = 1})
]
diff -r a90936219ffa -r bd76ca40db68 gameServer/Utils.hs
--- a/gameServer/Utils.hs Sun Oct 28 20:35:08 2012 +0100
+++ b/gameServer/Utils.hs Sun Oct 28 23:43:56 2012 +0400
@@ -88,6 +88,8 @@
, (40, "0.9.17-dev")
, (41, "0.9.17")
, (42, "0.9.18-dev")
+ , (43, "0.9.18")
+ , (44, "0.9.19-dev")
]
askFromConsole :: B.ByteString -> IO B.ByteString