--- a/CMakeLists.txt Thu Jan 22 20:34:26 2009 +0000
+++ b/CMakeLists.txt Sat Jan 24 12:40:30 2009 +0000
@@ -9,7 +9,7 @@
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "9")
-set(CPACK_PACKAGE_VERSION_PATCH "9-dev")
+set(CPACK_PACKAGE_VERSION_PATCH "10-dev")
if(DEFINED DATA_INSTALL_DIR)
set(SHAREPATH ${DATA_INSTALL_DIR}/hedgewars/)
--- a/QTfrontend/newnetclient.cpp Thu Jan 22 20:34:26 2009 +0000
+++ b/QTfrontend/newnetclient.cpp Sat Jan 24 12:40:30 2009 +0000
@@ -141,7 +141,7 @@
void HWNewNet::RawSendNet(const QByteArray & buf)
{
- //qDebug() << "Client: " << QString(buf).split("\n");
+ qDebug() << "Client: " << QString(buf).split("\n");
NetSocket.write(buf);
NetSocket.write("\n\n", 2);
}
@@ -191,7 +191,7 @@
void HWNewNet::ParseCmd(const QStringList & lst)
{
- //qDebug() << "Server: " << lst;
+ qDebug() << "Server: " << lst;
if(!lst.size())
{
--- a/netserver/HWProto.hs Thu Jan 22 20:34:26 2009 +0000
+++ b/netserver/HWProto.hs Sat Jan 24 12:40:30 2009 +0000
@@ -260,7 +260,7 @@
[]
else
(answerClientOnly ["RUN_GAME"]) ++
- answerClientOnly ("GAMEMSG" : "DGUkc3BlY3RhdGUgMQ==" : (toList $ roundMsgs clRoom))
+ answerClientOnly ("GAMEMSG" : toEngineMsg "e$spectate 1" : (toList $ roundMsgs clRoom))
handleCmd_noRoom client clients rooms ["JOIN", roomName] =
handleCmd_noRoom client clients rooms ["JOIN", roomName, ""]
@@ -368,12 +368,16 @@
if not $ nick client == teamowner team then
(noChangeClients, noChangeRooms, answerNotOwner)
else
- (noChangeClients, modifyRoom clRoom{teams = filter (\t -> teamName /= teamname t) $ teams clRoom}, answerRemoveTeam teamName)
+ if not $ gameinprogress clRoom then
+ (noChangeClients, modifyRoom clRoom{teams = filter (\t -> teamName /= teamname t) $ teams clRoom}, answerRemoveTeam teamName)
+ else
+ (noChangeClients, modifyRoom clRoom{leftTeams = teamName : leftTeams clRoom, roundMsgs = roundMsgs clRoom |> rmTeamMsg}, answerOthersRoom ["GAMEMSG", rmTeamMsg])
where
noSuchTeam = isNothing findTeam
team = fromJust findTeam
findTeam = find (\t -> teamName == teamname t) $ teams clRoom
clRoom = roomByName (room client) rooms
+ rmTeamMsg = toEngineMsg $ 'F' : teamName
handleCmd_inRoom client _ rooms ["TOGGLE_READY"] =
if isReady client then
@@ -387,7 +391,7 @@
handleCmd_inRoom client _ rooms ["START_GAME"] =
if isMaster client && (playersIn clRoom == readyPlayers clRoom) && (not $ gameinprogress clRoom) then
if enoughClans then
- (noChangeClients, modifyRoom clRoom{gameinprogress = True, roundMsgs = empty}, answerRunGame)
+ (noChangeClients, modifyRoom clRoom{gameinprogress = True, roundMsgs = empty, leftTeams = []}, answerRunGame)
else
(noChangeClients, noChangeRooms, answerTooFewClans)
else
@@ -416,13 +420,14 @@
handleCmd_inRoom client clients rooms ["ROUNDFINISHED"] =
if isMaster client then
- (modifyRoomClients clRoom (\cl -> cl{isReady = False}), modifyRoom clRoom{gameinprogress = False, readyPlayers = 0, roundMsgs = empty}, answerAllNotReady)
+ (modifyRoomClients clRoom (\cl -> cl{isReady = False}), modifyRoom clRoom{gameinprogress = False, readyPlayers = 0, roundMsgs = empty, leftTeams = []}, answerAllNotReady ++ answerRemovedTeams)
else
(noChangeClients, noChangeRooms, [])
where
clRoom = roomByName (room client) rooms
sameRoomClients = filter (\ci -> room ci == name clRoom) clients
answerAllNotReady = concatMap (\cl -> answerSameRoom ["NOT_READY", nick cl]) sameRoomClients
+ answerRemovedTeams = concatMap answerRemoveTeam $ leftTeams clRoom
handleCmd_inRoom client _ rooms ["GAMEMSG", msg] =
(noChangeClients, addMsg, answerOthersRoom ["GAMEMSG", msg])
--- a/netserver/Miscutils.hs Thu Jan 22 20:34:26 2009 +0000
+++ b/netserver/Miscutils.hs Sat Jan 24 12:40:30 2009 +0000
@@ -10,6 +10,8 @@
import Data.Time
import Data.Sequence(Seq, empty)
import Network
+import qualified Codec.Binary.Base64 as Base64
+import qualified Codec.Binary.UTF8.String as UTF8
data ClientInfo =
ClientInfo
@@ -62,6 +64,7 @@
isRestrictedJoins :: Bool,
isRestrictedTeams :: Bool,
roundMsgs :: Seq String,
+ leftTeams :: [String],
params :: Map.Map String [String]
}
createRoom = (
@@ -77,6 +80,7 @@
False
False
Data.Sequence.empty
+ []
Map.empty
)
@@ -200,3 +204,6 @@
proto2ver 23 = "0.9.9"
proto2ver 24 = "0.9.10-dev"
proto2ver _ = "Unknown"
+
+toEngineMsg :: String -> String
+toEngineMsg msg = Base64.encode (fromIntegral (length msg) : (UTF8.encode msg))