# HG changeset patch # User Wuzzy # Date 1538665637 -7200 # Node ID 76a1d6275cd3d34230d9e17a95bd871b880f4ad0 # Parent 28a86816dc01ab318df75cebec8a647a279bd3f2 Teach engine to properly display clan message received from the net This fixes a bug that the word “Clan” was not translated when you received a clan message from the net. diff -r 28a86816dc01 -r 76a1d6275cd3 gameServer/HWProtoInRoomState.hs --- a/gameServer/HWProtoInRoomState.hs Thu Oct 04 14:54:57 2018 +0200 +++ b/gameServer/HWProtoInRoomState.hs Thu Oct 04 17:07:17 2018 +0200 @@ -382,9 +382,9 @@ chans <- roomSameClanChans return [AnswerClients chans ["EM", engineMsg cl]] where - -- FIXME: Use different method to send team message, without hardcoding the format. - -- The formatting should be decided by the engine, not the sever. This one cannot be localized. - engineMsg cl = toEngineMsg $ B.concat ["b", "[Clan] ", nick cl, ": ", msg, "\x20\x20"] + -- This is formatted in a way so it can parsed by engine to make it translatable + -- Format: b] + engineMsg cl = toEngineMsg $ B.concat ["b", nick cl, "]", msg, "\x20\x20"] handleCmd_inRoom ["BAN", banNick] = do diff -r 28a86816dc01 -r 76a1d6275cd3 hedgewars/uIO.pas --- a/hedgewars/uIO.pas Thu Oct 04 14:54:57 2018 +0200 +++ b/hedgewars/uIO.pas Thu Oct 04 17:07:17 2018 +0200 @@ -39,7 +39,7 @@ procedure doPut(putX, putY: LongInt; fromAI: boolean); implementation -uses uConsole, uConsts, uVariables, uCommands, uUtils, uDebug; +uses uConsole, uConsts, uVariables, uCommands, uUtils, uDebug, uLocale; const cSendEmptyPacketTime = 1000; @@ -147,6 +147,8 @@ procedure ParseIPCCommand(s: shortstring); var loTicks: Word; isProcessed: boolean; + nick, msg: shortstring; + i: LongInt; begin isProcessed := true; @@ -175,7 +177,30 @@ else isProcessed:= false; 'b': if gameType = gmtNet then - ParseChatCommand('chatmsg ' + #4, s, 2) + // parse team message from net + // expected format: ] + begin + i:= 2; + nick:= ''; + while (i <= length(s)) and (s[i] <> ']') do + begin + nick:= nick + s[i]; + inc(i) + end; + + inc(i); + msg:= ''; + while (i <= length(s)) do + begin + msg:= msg + s[i]; + inc(i) + end; + s:= 'b' + Format(trmsg[sidChatTeam], [nick, msg]); + if (nick = '') or (msg = '') then + isProcessed:= false + else + ParseChatCommand('chatmsg ' + #4, s, 2); + end else isProcessed:= false; else