- Only team owner can remove team from the list
- Fix check for hedgehogs number overflow
--- a/QTfrontend/newnetclient.cpp Thu Oct 09 13:45:40 2008 +0000
+++ b/QTfrontend/newnetclient.cpp Thu Oct 09 13:48:06 2008 +0000
@@ -106,7 +106,7 @@
void HWNewNet::RemoveTeam(const HWTeam & team)
{
- RawSendNet(QString("REMOVETEAM") + delimeter + team.TeamName);
+ RawSendNet(QString("REMOVE_TEAM") + delimeter + team.TeamName);
}
void HWNewNet::Ready()
@@ -253,7 +253,7 @@
return;
}
- if (lst[0] == "REMOVETEAM") {
+ if (lst[0] == "REMOVE_TEAM") {
if(lst.size() < 3)
{
qWarning("Net: Bad REMOVETEAM message");
--- a/netserver/HWProto.hs Thu Oct 09 13:45:40 2008 +0000
+++ b/netserver/HWProto.hs Thu Oct 09 13:48:06 2008 +0000
@@ -37,6 +37,7 @@
hhsInfo = concatMap (\(HedgehogInfo name hat) -> [name, hat]) $ hedgehogs team
answerHHNum teamName hhNumber = [(othersInRoom, ["HH_NUM", teamName, show hhNumber])]
answerRemoveTeam teamName = [(othersInRoom, ["REMOVE_TEAM", teamName])]
+answerNotOwner = [(clientOnly, ["ERROR", "You do not own this team"])]
-- Main state-independent cmd handler
handleCmd :: CmdHandler
@@ -139,7 +140,7 @@
(noChangeClients, modifyRoom clRoom{teams = newTeam : teams clRoom}, answerTeamAccepted newTeam ++ answerAddTeam newTeam)
where
clRoom = roomByName (room client) rooms
- newTeam = (TeamInfo name color grave fort difficulty newTeamHHNum (hhsList hhsInfo))
+ newTeam = (TeamInfo (nick client) name color grave fort difficulty newTeamHHNum (hhsList hhsInfo))
findTeam = find (\t -> name == teamname t) $ teams clRoom
difficulty = fromMaybe 0 (maybeRead difStr :: Maybe Int)
hhsList [] = []
@@ -151,7 +152,7 @@
if not $ isMaster client then
(noChangeClients, noChangeRooms, answerNotMaster)
else
- if hhNumber < 1 || hhNumber > 8 || hhNumber > canAddNumber|| noSuchTeam then
+ if hhNumber < 1 || hhNumber > 8 || noSuchTeam || hhNumber > (canAddNumber + (hhnum team)) then
(noChangeClients, noChangeRooms, answerBadParam)
else
(noChangeClients, modifyRoom $ modifyTeam clRoom team{hhnum = hhNumber}, answerHHNum teamName hhNumber)
@@ -164,11 +165,11 @@
canAddNumber = 18 - (sum . map hhnum $ teams clRoom)
handleCmd_inRoom client _ rooms ["REMOVE_TEAM", teamName] =
- if not $ isMaster client then
- (noChangeClients, noChangeRooms, answerNotMaster)
+ if noSuchTeam then
+ (noChangeClients, noChangeRooms, answerBadParam)
else
- if noSuchTeam then
- (noChangeClients, noChangeRooms, answerBadParam)
+ if not $ nick client == teamowner team then
+ (noChangeClients, noChangeRooms, answerNotOwner)
else
(noChangeClients, modifyRoom clRoom{teams = filter (\t -> teamName /= teamname t) $ teams clRoom}, answerRemoveTeam teamName)
where
--- a/netserver/Miscutils.hs Thu Oct 09 13:45:40 2008 +0000
+++ b/netserver/Miscutils.hs Thu Oct 09 13:48:06 2008 +0000
@@ -28,6 +28,7 @@
data TeamInfo =
TeamInfo
{
+ teamowner :: String,
teamname :: String,
teamcolor :: String,
teamgrave :: String,