# HG changeset patch # User alfadur # Date 1538674008 14400 # Node ID ff468792298ac4a44f6700a137eeb8a62b905271 # Parent 664935d80668b4be5f8df7cd28beb4cc0b4d5dff# Parent acb8b5530aa847a94421826d58384b05a9173335 merge diff -r acb8b5530aa8 -r ff468792298a hedgewars/uChat.pas --- a/hedgewars/uChat.pas Thu Oct 04 20:04:32 2018 +0300 +++ b/hedgewars/uChat.pas Thu Oct 04 13:26:48 2018 -0400 @@ -1130,7 +1130,7 @@ if copy(s, 1, 4) = '/me ' then s:= #2 + '* ' + UserNick + ' ' + copy(s, 5, Length(s) - 4) else - s:= #1 + Format(trmsg[sidChat], [UserNick, s]); + s:= #1 + Format(trmsg[sidChat], UserNick, s); AddChatString(s) end; @@ -1139,7 +1139,7 @@ begin SendIPC('b' + s); - s:= #4 + Format(trmsg[sidChatTeam], [UserNick, s]); + s:= #4 + Format(trmsg[sidChatTeam], UserNick, s); AddChatString(s) end; diff -r acb8b5530aa8 -r ff468792298a hedgewars/uGears.pas --- a/hedgewars/uGears.pas Thu Oct 04 20:04:32 2018 +0300 +++ b/hedgewars/uGears.pas Thu Oct 04 13:26:48 2018 -0400 @@ -1221,7 +1221,7 @@ Gear^.Text:= text; Gear^.FrameTicks:= x end; - AddChatString(#9+FormatA(trmsg[sidChatHog], [HH^.Name, text])); + AddChatString(#9+FormatA(trmsg[sidChatHog], HH^.Name, text)); end end else if (x >= 4) then diff -r acb8b5530aa8 -r ff468792298a hedgewars/uGearsHedgehog.pas --- a/hedgewars/uGearsHedgehog.pas Thu Oct 04 20:04:32 2018 +0300 +++ b/hedgewars/uGearsHedgehog.pas Thu Oct 04 13:26:48 2018 -0400 @@ -582,7 +582,7 @@ speech^.Text:= SpeechText; speech^.Hedgehog:= Gear^.Hedgehog; speech^.FrameTicks:= SpeechType; - AddChatString(#9+FormatA(trmsg[sidChatHog], [Gear^.Hedgehog^.Name, SpeechText])); + AddChatString(#9+FormatA(trmsg[sidChatHog], Gear^.Hedgehog^.Name, SpeechText)); end; SpeechText:= '' end; diff -r acb8b5530aa8 -r ff468792298a hedgewars/uIO.pas --- a/hedgewars/uIO.pas Thu Oct 04 20:04:32 2018 +0300 +++ b/hedgewars/uIO.pas Thu Oct 04 13:26:48 2018 -0400 @@ -195,7 +195,7 @@ msg:= msg + s[i]; inc(i) end; - s:= 'b' + Format(trmsg[sidChatTeam], [nick, msg]); + s:= 'b' + Format(trmsg[sidChatTeam], nick, msg); if (nick = '') or (msg = '') then isProcessed:= false else diff -r acb8b5530aa8 -r ff468792298a hedgewars/uLandObjects.pas --- a/hedgewars/uLandObjects.pas Thu Oct 04 20:04:32 2018 +0300 +++ b/hedgewars/uLandObjects.pas Thu Oct 04 13:26:48 2018 -0400 @@ -204,7 +204,7 @@ pLandColor:= @LandPixels[(cpY + y) div 2, (cpX + x) div 2]; alpha:= (color and AMask) shr AShift; - if (alpha <> $FF) and (pLandColor^ <> 0) then + if ((alpha <> $FF) and ((pLandColor^) <> 0)) then begin landColor:= pLandColor^; color:= diff -r acb8b5530aa8 -r ff468792298a hedgewars/uLocale.pas --- a/hedgewars/uLocale.pas Thu Oct 04 20:04:32 2018 +0300 +++ b/hedgewars/uLocale.pas Thu Oct 04 13:26:48 2018 -0400 @@ -23,15 +23,31 @@ uses uTypes; const MAX_EVENT_STRINGS = 255; -const MAX_FORMAT_STRING_SYMBOLS = 9; procedure LoadLocale(FileName: shortstring); -function Format(fmt: shortstring; args: array of shortstring): shortstring; -function FormatA(fmt: ansistring; args: array of ansistring): ansistring; -function Format(fmt: shortstring; arg: shortstring): shortstring; -function FormatA(fmt: ansistring; arg: ansistring): ansistring; function GetEventString(e: TEventId): ansistring; +function Format(fmt: shortstring; arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9: shortstring; argCount: Byte): shortstring; +function Format(fmt: shortstring; arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9: shortstring): shortstring; +function Format(fmt: shortstring; arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8: shortstring): shortstring; +function Format(fmt: shortstring; arg1, arg2, arg3, arg4, arg5, arg6, arg7: shortstring): shortstring; +function Format(fmt: shortstring; arg1, arg2, arg3, arg4, arg5, arg6: shortstring): shortstring; +function Format(fmt: shortstring; arg1, arg2, arg3, arg4, arg5: shortstring): shortstring; +function Format(fmt: shortstring; arg1, arg2, arg3, arg4: shortstring): shortstring; +function Format(fmt: shortstring; arg1, arg2, arg3: shortstring): shortstring; +function Format(fmt: shortstring; arg1, arg2: shortstring): shortstring; +function Format(fmt: shortstring; arg1: shortstring): shortstring; +function FormatA(fmt: ansistring; arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9: ansistring; argCount: Byte): ansistring; +function FormatA(fmt: ansistring; arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9: ansistring): ansistring; +function FormatA(fmt: ansistring; arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8: ansistring): ansistring; +function FormatA(fmt: ansistring; arg1, arg2, arg3, arg4, arg5, arg6, arg7: ansistring): ansistring; +function FormatA(fmt: ansistring; arg1, arg2, arg3, arg4, arg5, arg6: ansistring): ansistring; +function FormatA(fmt: ansistring; arg1, arg2, arg3, arg4, arg5: ansistring): ansistring; +function FormatA(fmt: ansistring; arg1, arg2, arg3, arg4: ansistring): ansistring; +function FormatA(fmt: ansistring; arg1, arg2, arg3: ansistring): ansistring; +function FormatA(fmt: ansistring; arg1, arg2: ansistring): ansistring; +function FormatA(fmt: ansistring; arg1: ansistring): ansistring; + {$IFDEF HWLIBRARY} procedure LoadLocaleWrapper(path: pchar; userpath: pchar; filename: pchar); cdecl; export; {$ENDIF} @@ -119,60 +135,147 @@ end; // Format the string fmt. -// Take a shortstring with placeholders %1, %2, %3, etc. and replace +// Take a shortstring with placeholders %1, %2, %3, ... %9. and replace // them with the corresponding elements of an array with up to -// MAX_FORMAT_STRING_SYMBOLS. Important! Each placeholder can only be -// used exactly once and numbers MUST NOT be skipped (e.g. using %1 and %3 -// but not %2. -function Format(fmt: shortstring; args: array of shortstring): shortstring; +// argCount. ArgCount must not be larger than 9. +// Each placeholder must be used exactly once and numbers MUST NOT be +// skipped (e.g. using %1 and %3 but not %2. +function Format(fmt: shortstring; arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9: shortstring; argCount: Byte): shortstring; var i, p: LongInt; -tempstr: shortstring; +tempstr, curArg: shortstring; begin tempstr:= fmt; -for i:=0 to MAX_FORMAT_STRING_SYMBOLS - 1 do +for i:=0 to argCount - 1 do begin + case i of + 0: curArg:= arg1; + 1: curArg:= arg2; + 2: curArg:= arg3; + 3: curArg:= arg4; + 4: curArg:= arg5; + 5: curArg:= arg6; + 6: curArg:= arg7; + 7: curArg:= arg8; + 8: curArg:= arg9; + end; + p:= Pos('%'+IntToStr(i+1), tempstr); - if (p = 0) or (i >= Length(args)) then + if (p = 0) then break else begin delete(tempstr, p, 2); - insert(args[i], tempstr, p); + insert(curArg, tempstr, p); end; end; Format:= tempstr; end; // Same as Format, but for ansistring -function FormatA(fmt: ansistring; args: array of ansistring): ansistring; +function FormatA(fmt: ansistring; arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9: ansistring; argCount: Byte): ansistring; var i, p: LongInt; -tempstr: ansistring; +tempstr, curArg: ansistring; begin tempstr:= fmt; -for i:=0 to MAX_FORMAT_STRING_SYMBOLS - 1 do +for i:=0 to argCount - 1 do begin + case i of + 0: curArg:= arg1; + 1: curArg:= arg2; + 2: curArg:= arg3; + 3: curArg:= arg4; + 4: curArg:= arg5; + 5: curArg:= arg6; + 6: curArg:= arg7; + 7: curArg:= arg8; + 8: curArg:= arg9; + end; + p:= Pos('%'+IntToStr(i+1), tempstr); - if (p = 0) or (i >= Length(args)) then + if (p = 0) then break else begin delete(tempstr, p, 2); - insert(args[i], tempstr, p); + insert(curArg, tempstr, p); end; end; FormatA:= tempstr; end; -// Same as Format above, but with only one placeholder %1, replaced by arg. -function Format(fmt: shortstring; arg: shortstring): shortstring; +// The following functions are just shortcuts of Format/FormatA, with fewer argument counts +function Format(fmt: shortstring; arg1: shortstring): shortstring; +begin + Format:= Format(fmt, arg1, '', '', '', '', '', '', '', '', 1); +end; +function Format(fmt: shortstring; arg1, arg2: shortstring): shortstring; +begin + Format:= Format(fmt, arg1, arg2, '', '', '', '', '', '', '', 2); +end; +function Format(fmt: shortstring; arg1, arg2, arg3: shortstring): shortstring; +begin + Format:= Format(fmt, arg1, arg2, arg3, '', '', '', '', '', '', 3); +end; +function Format(fmt: shortstring; arg1, arg2, arg3, arg4: shortstring): shortstring; begin - Format:= Format(fmt, [arg]); + Format:= Format(fmt, arg1, arg2, arg3, arg4, '', '', '', '', '', 4); +end; +function Format(fmt: shortstring; arg1, arg2, arg3, arg4, arg5: shortstring): shortstring; +begin + Format:= Format(fmt, arg1, arg2, arg3, arg4, arg5, '', '', '', '', 5); +end; +function Format(fmt: shortstring; arg1, arg2, arg3, arg4, arg5, arg6: shortstring): shortstring; +begin + Format:= Format(fmt, arg1, arg2, arg3, arg4, arg5, arg6, '', '', '', 6); +end; +function Format(fmt: shortstring; arg1, arg2, arg3, arg4, arg5, arg6, arg7: shortstring): shortstring; +begin + Format:= Format(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, '', '', 7); +end; +function Format(fmt: shortstring; arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8: shortstring): shortstring; +begin + Format:= Format(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, '', 8); +end; +function Format(fmt: shortstring; arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9: shortstring): shortstring; +begin + Format:= Format(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, 9); end; -// Same as above, but for ansistring -function FormatA(fmt: ansistring; arg: ansistring): ansistring; +function FormatA(fmt: ansistring; arg1: ansistring): ansistring; +begin + FormatA:= FormatA(fmt, arg1, '', '', '', '', '', '', '', '', 1); +end; +function FormatA(fmt: ansistring; arg1, arg2: ansistring): ansistring; +begin + FormatA:= FormatA(fmt, arg1, arg2, '', '', '', '', '', '', '', 2); +end; +function FormatA(fmt: ansistring; arg1, arg2, arg3: ansistring): ansistring; +begin + FormatA:= FormatA(fmt, arg1, arg2, arg3, '', '', '', '', '', '', 3); +end; +function FormatA(fmt: ansistring; arg1, arg2, arg3, arg4: ansistring): ansistring; +begin + FormatA:= FormatA(fmt, arg1, arg2, arg3, arg4, '', '', '', '', '', 4); +end; +function FormatA(fmt: ansistring; arg1, arg2, arg3, arg4, arg5: ansistring): ansistring; begin - FormatA:= FormatA(fmt, [arg]); + FormatA:= FormatA(fmt, arg1, arg2, arg3, arg4, arg5, '', '', '', '', 5); +end; +function FormatA(fmt: ansistring; arg1, arg2, arg3, arg4, arg5, arg6: ansistring): ansistring; +begin + FormatA:= FormatA(fmt, arg1, arg2, arg3, arg4, arg5, arg6, '', '', '', 6); +end; +function FormatA(fmt: ansistring; arg1, arg2, arg3, arg4, arg5, arg6, arg7: ansistring): ansistring; +begin + FormatA:= FormatA(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, '', '', 7); +end; +function FormatA(fmt: ansistring; arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8: ansistring): ansistring; +begin + FormatA:= FormatA(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, '', 8); +end; +function FormatA(fmt: ansistring; arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9: ansistring): ansistring; +begin + FormatA:= FormatA(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, 9); end; {$IFDEF HWLIBRARY} diff -r acb8b5530aa8 -r ff468792298a hedgewars/uScript.pas --- a/hedgewars/uScript.pas Thu Oct 04 20:04:32 2018 +0300 +++ b/hedgewars/uScript.pas Thu Oct 04 13:26:48 2018 -0400 @@ -1651,7 +1651,7 @@ vgear^.Text:= lua_tostring(L, 2); if Gear^.Kind = gtHedgehog then begin - AddChatString(#9+FormatA(trmsg[sidChatHog], [gear^.Hedgehog^.Name, vgear^.text])); + AddChatString(#9+FormatA(trmsg[sidChatHog], gear^.Hedgehog^.Name, vgear^.text)); vgear^.Hedgehog:= gear^.Hedgehog end else vgear^.Frame:= gear^.uid; diff -r acb8b5530aa8 -r ff468792298a hedgewars/uStore.pas --- a/hedgewars/uStore.pas Thu Oct 04 20:04:32 2018 +0300 +++ b/hedgewars/uStore.pas Thu Oct 04 13:26:48 2018 -0400 @@ -511,7 +511,7 @@ AFKTexture:= RenderStringTex(trmsg[sidAFK], cCentralMessageColor, fntBig); keyConfirm:= KeyBindToName('confirm'); keyQuit:= KeyBindToName('quit'); - ConfirmTexture:= RenderStringTex(Format(trmsg[sidConfirm], [keyConfirm, keyQuit]), cCentralMessageColor, fntBig); + ConfirmTexture:= RenderStringTex(Format(trmsg[sidConfirm], keyConfirm, keyQuit), cCentralMessageColor, fntBig); SyncTexture:= RenderStringTex(trmsg[sidSync], cCentralMessageColor, fntBig); if not reload then diff -r acb8b5530aa8 -r ff468792298a hedgewars/uTeams.pas --- a/hedgewars/uTeams.pas Thu Oct 04 20:04:32 2018 +0300 +++ b/hedgewars/uTeams.pas Thu Oct 04 13:26:48 2018 -0400 @@ -129,7 +129,18 @@ end else if (TeamsNumber >= 2) and (TeamsNumber < cMaxTeams) then // List all winning teams in a list - s:= FormatA(trmsg[TMsgStrId(Ord(sidWinner2) + (TeamsNumber - 2))], ts); + if (TeamsNumber = 2) then + s:= FormatA(trmsg[TMsgStrId(sidWinner2)], ts[0], ts[1]) + else if (TeamsNumber = 3) then + s:= FormatA(trmsg[TMsgStrId(sidWinner3)], ts[0], ts[1], ts[2]) + else if (TeamsNumber = 4) then + s:= FormatA(trmsg[TMsgStrId(sidWinner4)], ts[0], ts[1], ts[2], ts[3]) + else if (TeamsNumber = 5) then + s:= FormatA(trmsg[TMsgStrId(sidWinner5)], ts[0], ts[1], ts[2], ts[3], ts[4]) + else if (TeamsNumber = 6) then + s:= FormatA(trmsg[TMsgStrId(sidWinner6)], ts[0], ts[1], ts[2], ts[3], ts[4], ts[5]) + else if (TeamsNumber = 7) then + s:= FormatA(trmsg[TMsgStrId(sidWinner7)], ts[0], ts[1], ts[2], ts[3], ts[4], ts[5], ts[6]); // The winner caption is the same as the stats message and not randomized cap:= s;