# HG changeset patch # User unc0rr # Date 1403952705 -14400 # Node ID fe9853dea6c4b22146692e13921d94d46ac9b768 # Parent 16122539d2eab0b9c7fb56a89891ba661a925074 Finish implementation of ability to take control over your team after being disconnected. Completely untested. diff -r 16122539d2ea -r fe9853dea6c4 gameServer/EngineInteraction.hs --- a/gameServer/EngineInteraction.hs Thu Jun 26 21:43:36 2014 +0400 +++ b/gameServer/EngineInteraction.hs Sat Jun 28 14:51:45 2014 +0400 @@ -67,9 +67,9 @@ if not $ tst timedMessages m' then n else if '+' /= m' then Just Nothing else Just . Just . B.pack . Base64.encode . BW.unpack $ m isNonEmpty = (/=) '+' . B.head . B.tail - legalMessages = Set.fromList $ "M#+LlRrUuDdZzAaSjJ,sNpPwtghbc12345" ++ slotMessages + legalMessages = Set.fromList $ "M#+LlRrUuDdZzAaSjJ,sNpPwtgfhbc12345" ++ slotMessages slotMessages = "\128\129\130\131\132\133\134\135\136\137\138" - timedMessages = Set.fromList $ "+LlRrUuDdZzAaSjJ,NpPwtgc12345" ++ slotMessages + timedMessages = Set.fromList $ "+LlRrUuDdZzAaSjJ,NpPwtgfc12345" ++ slotMessages replayToDemo :: [TeamInfo] -> Map.Map B.ByteString B.ByteString diff -r 16122539d2ea -r fe9853dea6c4 hedgewars/uIO.pas --- a/hedgewars/uIO.pas Thu Jun 26 21:43:36 2014 +0400 +++ b/hedgewars/uIO.pas Sat Jun 28 14:51:45 2014 +0400 @@ -221,7 +221,11 @@ function isSyncedCommand(c: char): boolean; begin case c of - '+', '#', 'L', 'l', 'R', 'r', 'U', 'u', 'D', 'd', 'Z', 'z', 'A', 'a', 'S', 'j', 'J', ',', 'c', 'N', 'p', 'P', 'w', 't', '1', '2', '3', '4', '5': isSyncedCommand:= true; + '+', '#', 'L', 'l', 'R', 'r', 'U' + , 'u', 'D', 'd', 'Z', 'z', 'A', 'a' + , 'S', 'j', 'J', ',', 'c', 'N', 'p' + , 'P', 'w', 't', '1', '2', '3', '4' + , '5', 'f', 'g': isSyncedCommand:= true; else isSyncedCommand:= ((byte(c) >= 128) and (byte(c) <= 128 + cMaxSlotIndex)) end @@ -324,7 +328,8 @@ or (headcmd^.cmd = 'h') // seems the hedgewars protocol does not allow remote synced commands or (headcmd^.cmd = '#') // must be synced for saves to work or (headcmd^.cmd = 'b') - or (headcmd^.cmd = 'F')) do + or (headcmd^.cmd = 'F') + or (headcmd^.cmd = 'G')) do begin case headcmd^.cmd of '+': ; // do nothing - it is just an empty packet @@ -362,8 +367,10 @@ ParseCommand('chatmsg ' + #4 + s, true); WriteLnToConsole(s) end; -// TODO: deprecate 'F' - 'F': ParseCommand('teamgone ' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true); + 'F': ParseCommand('teamgone u' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true); + 'G': ParseCommand('teamback u' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true); + 'f': ParseCommand('teamgone s' + copy(headcmd^.str, 2, headcmd^.len - 3), true); + 'g': ParseCommand('teamback s' + copy(headcmd^.str, 2, headcmd^.len - 3), true); 'N': begin tmpflag:= false; lastTurnChecksum:= SDLNet_Read32(@headcmd^.str[2]); diff -r 16122539d2ea -r fe9853dea6c4 hedgewars/uTeams.pas --- a/hedgewars/uTeams.pas Thu Jun 26 21:43:36 2014 +0400 +++ b/hedgewars/uTeams.pas Sat Jun 28 14:51:45 2014 +0400 @@ -630,21 +630,75 @@ procedure chTeamGone(var s:shortstring); var t: LongInt; + isSynced: boolean; begin -t:= 0; -while (t < cMaxTeams) and (TeamsArray[t] <> nil) and (TeamsArray[t]^.TeamName <> s) do - inc(t); -if (t = cMaxTeams) or (TeamsArray[t] = nil) then - exit; + isSynced:= s[1] = 's'; + + Delete(s, 1, 1); + + t:= 0; + while (t < cMaxTeams) and (TeamsArray[t] <> nil) and (TeamsArray[t]^.TeamName <> s) do + inc(t); + if (t = cMaxTeams) or (TeamsArray[t] = nil) then + exit; + + if isSynced then + begin + with TeamsArray[t]^ do + if not hasGone then + begin + AddChatString('** '+ TeamName + ' is gone'); + hasGone:= true; + + RecountTeamHealth(TeamsArray[t]) + end; + end + else + begin + if not CurrentTeam^.ExtDriven then + begin + SendIPC(_S'f' + s); + ParseCommand('/teamgone s' + s, true); + end; + end; +end; -with TeamsArray[t]^ do - if not hasGone then +procedure chTeamBack(var s:shortstring); +var t: LongInt; + isSynced: boolean; +begin + isSynced:= s[1] = 's'; + + Delete(s, 1, 1); + + t:= 0; + while (t < cMaxTeams) and (TeamsArray[t] <> nil) and (TeamsArray[t]^.TeamName <> s) do + inc(t); + if (t = cMaxTeams) or (TeamsArray[t] = nil) then + exit; + + if isSynced then begin - AddChatString('** '+ TeamName + ' is gone'); - hasGone:= true; + with TeamsArray[t]^ do + if hasGone then + begin + AddChatString('** '+ TeamName + ' is back'); + hasGone:= false; + + RecountTeamHealth(TeamsArray[t]); - RecountTeamHealth(TeamsArray[t]) + if Owner = UserNick then + ExtDriven:= false + end; + end + else + begin + if not CurrentTeam^.ExtDriven then + begin + SendIPC(_S'g' + s); + ParseCommand('/teamback s' + s, true); end; + end; end; @@ -747,6 +801,7 @@ RegisterVariable('hhcoords', @chSetHHCoords, false); RegisterVariable('bind', @chBind, true ); RegisterVariable('teamgone', @chTeamGone, true ); +RegisterVariable('teamback', @chTeamBack, true ); RegisterVariable('finish', @chFinish, true ); // all teams gone RegisterVariable('fort' , @chFort , false); RegisterVariable('grave' , @chGrave , false); diff -r 16122539d2ea -r fe9853dea6c4 hedgewars/uTypes.pas --- a/hedgewars/uTypes.pas Thu Jun 26 21:43:36 2014 +0400 +++ b/hedgewars/uTypes.pas Sat Jun 28 14:51:45 2014 +0400 @@ -399,10 +399,10 @@ DrawHealthY: LongInt; AttackBar: LongWord; HedgehogsNumber: Longword; - hasGone: boolean; voicepack: PVoicepack; PlayerHash: shortstring; // md5 hash of player name. For temporary enabling of hats as thank you. Hashed for privacy of players stats: TTeamStats; + hasGone: boolean; end; TClan = record