bunch more of those shortstring/ansistrings
authornemo
Tue, 09 Oct 2018 09:58:33 -0400
changeset 13882 8c702a4839ec
parent 13881 aa321e51da14
child 13883 0ce8aad17c24
bunch more of those shortstring/ansistrings
hedgewars/uChat.pas
hedgewars/uGearsHandlersMess.pas
hedgewars/uIO.pas
hedgewars/uLocale.pas
hedgewars/uTeams.pas
hedgewars/uUtils.pas
hedgewars/uWorld.pas
--- a/hedgewars/uChat.pas	Tue Oct 09 09:02:39 2018 -0400
+++ b/hedgewars/uChat.pas	Tue Oct 09 09:58:33 2018 -0400
@@ -468,7 +468,7 @@
     if (Length(s) <= 1) then
         begin
         // empty chat command
-        AddChatString(#0 + trcmd[sidCmdUnknown]);
+        AddChatString(#0 + shortstring(trcmd[sidCmdUnknown]));
         exit;
         end;
 
@@ -550,59 +550,59 @@
             if liveLua then
                 begin
                 AddFileLog('[Lua] chat input string parsing enabled');
-                AddChatString(#3 + trmsg[sidLuaParsingOn]);
+                AddChatString(#3 + shortstring(trmsg[sidLuaParsingOn]));
                 end
             else
                 begin
                 AddFileLog('[Lua] chat input string parsing disabled');
-                AddChatString(#3 + trmsg[sidLuaParsingOff]);
+                AddChatString(#3 + shortstring(trmsg[sidLuaParsingOff]));
                 end;
             UpdateInputLinePrefix();
             end
         else
-            AddChatString(#5 + trmsg[sidLuaParsingDenied]);
+            AddChatString(#5 + shortstring(trmsg[sidLuaParsingDenied]));
         exit
         end;
 
     // Help commands
     if (copy(s, 2, 11) = 'help taunts') then
         begin
-        AddChatString(#3 + trcmd[sidCmdHeaderTaunts]);
-        AddChatString(#3 + trcmd[sidCmdSpeech]);
-        AddChatString(#3 + trcmd[sidCmdThink]);
-        AddChatString(#3 + trcmd[sidCmdYell]);
-        AddChatString(#3 + trcmd[sidCmdSpeechNumberHint]);
-        AddChatString(#3 + trcmd[sidCmdHsa]);
-        AddChatString(#3 + trcmd[sidCmdHta]);
-        AddChatString(#3 + trcmd[sidCmdHya]);
-        AddChatString(#3 + trcmd[sidCmdHurrah]);
-        AddChatString(#3 + trcmd[sidCmdIlovelotsoflemonade]);
-        AddChatString(#3 + trcmd[sidCmdJuggle]);
-        AddChatString(#3 + trcmd[sidCmdRollup]);
-        AddChatString(#3 + trcmd[sidCmdShrug]);
-        AddChatString(#3 + trcmd[sidCmdWave]);
+        AddChatString(#3 + shortstring(trcmd[sidCmdHeaderTaunts]));
+        AddChatString(#3 + shortstring(trcmd[sidCmdSpeech]));
+        AddChatString(#3 + shortstring(trcmd[sidCmdThink]));
+        AddChatString(#3 + shortstring(trcmd[sidCmdYell]));
+        AddChatString(#3 + shortstring(trcmd[sidCmdSpeechNumberHint]));
+        AddChatString(#3 + shortstring(trcmd[sidCmdHsa]));
+        AddChatString(#3 + shortstring(trcmd[sidCmdHta]));
+        AddChatString(#3 + shortstring(trcmd[sidCmdHya]));
+        AddChatString(#3 + shortstring(trcmd[sidCmdHurrah]));
+        AddChatString(#3 + shortstring(trcmd[sidCmdIlovelotsoflemonade]));
+        AddChatString(#3 + shortstring(trcmd[sidCmdJuggle]));
+        AddChatString(#3 + shortstring(trcmd[sidCmdRollup]));
+        AddChatString(#3 + shortstring(trcmd[sidCmdShrug]));
+        AddChatString(#3 + shortstring(trcmd[sidCmdWave]));
         exit
         end;
 
     if (copy(s, 2, 4) = 'help') then
         begin
-        AddChatString(#3 + trcmd[sidCmdHeaderBasic]);
+        AddChatString(#3 + shortstring(trcmd[sidCmdHeaderBasic]));
         if gameType = gmtNet then
-            AddChatString(#3 + trcmd[sidCmdPauseNet])
+            AddChatString(#3 + shortstring(trcmd[sidCmdPauseNet]))
         else
-            AddChatString(#3 + trcmd[sidCmdPause]);
-        AddChatString(#3 + trcmd[sidCmdFullscreen]);
-        AddChatString(#3 + trcmd[sidCmdQuit]);
+            AddChatString(#3 + shortstring(trcmd[sidCmdPause]));
+        AddChatString(#3 + shortstring(trcmd[sidCmdFullscreen]));
+        AddChatString(#3 + shortstring(trcmd[sidCmdQuit]));
         if gameType <> gmtNet then
-            AddChatString(#3 + trcmd[sidLua]);
+            AddChatString(#3 + shortstring(trcmd[sidLua]));
         // history and help commands needs to be close to the end because they are always visible
         // with a short chat history length.
-        AddChatString(#3 + trcmd[sidCmdTeam]);
-        AddChatString(#3 + trcmd[sidCmdMe]);
-        AddChatString(#3 + trcmd[sidCmdTogglechat]);
-        AddChatString(#3 + trcmd[sidCmdHistory]);
-        AddChatString(#3 + trcmd[sidCmdHelp]);
-        AddChatString(#3 + trcmd[sidCmdHelpTaunts]);
+        AddChatString(#3 + shortstring(trcmd[sidCmdTeam]));
+        AddChatString(#3 + shortstring(trcmd[sidCmdMe]));
+        AddChatString(#3 + shortstring(trcmd[sidCmdTogglechat]));
+        AddChatString(#3 + shortstring(trcmd[sidCmdHistory]));
+        AddChatString(#3 + shortstring(trcmd[sidCmdHelp]));
+        AddChatString(#3 + shortstring(trcmd[sidCmdHelpTaunts]));
         exit
         end;
 
@@ -627,7 +627,7 @@
     if (gameType = gmtNet) then
         SendConsoleCommand(s)
     else
-        AddChatString(#0 + trcmd[sidCmdUnknown]);
+        AddChatString(#0 + shortstring(trcmd[sidCmdUnknown]));
     end
 else
     begin
@@ -1137,7 +1137,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(shortstring(trmsg[sidChat]), UserNick, s);
 
     AddChatString(s)
 end;
@@ -1146,7 +1146,7 @@
 begin
     SendIPC('b' + s);
 
-    s:= #4 + Format(trmsg[sidChatTeam], UserNick, s);
+    s:= #4 + Format(shortstring(trmsg[sidChatTeam]), UserNick, s);
 
     AddChatString(s)
 end;
--- a/hedgewars/uGearsHandlersMess.pas	Tue Oct 09 09:02:39 2018 -0400
+++ b/hedgewars/uGearsHandlersMess.pas	Tue Oct 09 09:58:33 2018 -0400
@@ -4337,7 +4337,7 @@
         Gear^.Damage:= i;
         FreeAndNilTexture(Gear^.Tex);
         if Gear^.Health <> JETPACK_FUEL_INFINITE then
-            Gear^.Tex := RenderStringTex(FormatA(trmsg[sidFuel], inttostr(i)), cWhiteColor, fntSmall)
+            Gear^.Tex := RenderStringTex(FormatA(trmsg[sidFuel], ansistring(inttostr(i))), cWhiteColor, fntSmall)
         end;
 
     if (HHGear^.Message and (gmAttack or gmUp or gmLeft or gmRight) <> 0) and
@@ -5563,7 +5563,7 @@
             begin
             Gear^.Damage:= i;
             FreeAndNilTexture(Gear^.Tex);
-            Gear^.Tex := RenderStringTex(FormatA(trmsg[sidFuel], inttostr(i)),
+            Gear^.Tex := RenderStringTex(FormatA(trmsg[sidFuel], ansistring(inttostr(i))),
                          cWhiteColor, fntSmall)
             end
         end
@@ -5646,7 +5646,7 @@
             begin
             Gear^.Damage:= i;
             FreeAndNilTexture(Gear^.Tex);
-            Gear^.Tex := RenderStringTex(FormatA(trmsg[sidFuel], inttostr(i)),
+            Gear^.Tex := RenderStringTex(FormatA(trmsg[sidFuel], ansistring(inttostr(i))),
                          cWhiteColor, fntSmall)
             end
         end
@@ -6262,7 +6262,7 @@
     begin
     Gear^.Damage:= t;
     FreeAndNilTexture(Gear^.Tex);
-    Gear^.Tex := RenderStringTex(FormatA(trmsg[sidFuel], inttostr(t)),
+    Gear^.Tex := RenderStringTex(FormatA(trmsg[sidFuel], ansistring(inttostr(t))),
               cWhiteColor, fntSmall)
     end;
     if Gear^.Message and (gmUp or gmDown) <> 0 then
--- a/hedgewars/uIO.pas	Tue Oct 09 09:02:39 2018 -0400
+++ b/hedgewars/uIO.pas	Tue Oct 09 09:58:33 2018 -0400
@@ -195,7 +195,7 @@
                 msg:= msg + s[i];
                 inc(i)
                 end;
-             s:= 'b' + Format(trmsg[sidChatTeam], nick, msg);
+             s:= 'b' + Format(shortstring(trmsg[sidChatTeam]), nick, msg);
              if (nick = '') or (msg = '') then
                  isProcessed:= false
              else
--- a/hedgewars/uLocale.pas	Tue Oct 09 09:02:39 2018 -0400
+++ b/hedgewars/uLocale.pas	Tue Oct 09 09:58:33 2018 -0400
@@ -243,35 +243,35 @@
 
 function FormatA(fmt: ansistring; arg1: ansistring): ansistring;
 begin
-    FormatA:= FormatA(fmt, arg1, '', '', '', '', '', '', '', '', 1);
+    FormatA:= FormatA(fmt, arg1, ansistring(''), ansistring(''), ansistring(''), ansistring(''), ansistring(''), ansistring(''), ansistring(''), ansistring(''), 1);
 end;
 function FormatA(fmt: ansistring; arg1, arg2: ansistring): ansistring;
 begin
-    FormatA:= FormatA(fmt, arg1, arg2, '', '', '', '', '', '', '', 2);
+    FormatA:= FormatA(fmt, arg1, arg2, ansistring(''), ansistring(''), ansistring(''), ansistring(''), ansistring(''), ansistring(''), ansistring(''), 2);
 end;
 function FormatA(fmt: ansistring; arg1, arg2, arg3: ansistring): ansistring;
 begin
-    FormatA:= FormatA(fmt, arg1, arg2, arg3, '', '', '', '', '', '', 3);
+    FormatA:= FormatA(fmt, arg1, arg2, arg3, ansistring(''), ansistring(''), ansistring(''), ansistring(''), ansistring(''), ansistring(''), 3);
 end;
 function FormatA(fmt: ansistring; arg1, arg2, arg3, arg4: ansistring): ansistring;
 begin
-    FormatA:= FormatA(fmt, arg1, arg2, arg3, arg4, '', '', '', '', '', 4);
+    FormatA:= FormatA(fmt, arg1, arg2, arg3, arg4, ansistring(''), ansistring(''), ansistring(''), ansistring(''), ansistring(''), 4);
 end;
 function FormatA(fmt: ansistring; arg1, arg2, arg3, arg4, arg5: ansistring): ansistring;
 begin
-    FormatA:= FormatA(fmt, arg1, arg2, arg3, arg4, arg5, '', '', '', '', 5);
+    FormatA:= FormatA(fmt, arg1, arg2, arg3, arg4, arg5, ansistring(''), ansistring(''), ansistring(''), ansistring(''), 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);
+    FormatA:= FormatA(fmt, arg1, arg2, arg3, arg4, arg5, arg6, ansistring(''), ansistring(''), ansistring(''), 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);
+    FormatA:= FormatA(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, ansistring(''), ansistring(''), 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);
+    FormatA:= FormatA(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, ansistring(''), 8);
 end;
 function FormatA(fmt: ansistring; arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9: ansistring): ansistring;
 begin
--- a/hedgewars/uTeams.pas	Tue Oct 09 09:02:39 2018 -0400
+++ b/hedgewars/uTeams.pas	Tue Oct 09 09:58:33 2018 -0400
@@ -782,7 +782,6 @@
 procedure chTeamGone(var s:shortstring);
 var t, i: LongInt;
     isSynced: boolean;
-    tmp: shortstring;
 begin
     isSynced:= s[1] = 's';
 
@@ -803,9 +802,7 @@
                 begin
                 if (not hasGone) and isGoneFlagPendingToBeSet then
                     begin
-                    tmp:= ' ' + trmsg[sidTeamGone];
-                    tmp:= '*' + tmp;
-                    AddChatString(#7 + Format(tmp, TeamName));
+                    AddChatString(#7 + Format('* '+shortstring(trmsg[sidTeamGone]), TeamName));
                     if not CurrentTeam^.ExtDriven then SendIPC(_S'f' + s);
                     hasGone:= true;
                     skippedTurns:= 0;
@@ -828,7 +825,6 @@
 procedure chTeamBack(var s:shortstring);
 var t: LongInt;
     isSynced: boolean;
-    tmp: shortstring;
 begin
     isSynced:= s[1] = 's';
 
@@ -845,9 +841,7 @@
         with TeamsArray[t]^ do
             if hasGone then
                 begin
-                tmp:= ' '+trmsg[sidTeamBack];
-                tmp:= '*'+tmp;
-                AddChatString(#8 + Format(tmp, TeamName));
+                AddChatString(#8 + Format('* '+shortstring(trmsg[sidTeamBack]), TeamName));
                 if not CurrentTeam^.ExtDriven then SendIPC(_S'g' + s);
                 hasGone:= false;
 
--- a/hedgewars/uUtils.pas	Tue Oct 09 09:02:39 2018 -0400
+++ b/hedgewars/uUtils.pas	Tue Oct 09 09:58:33 2018 -0400
@@ -336,10 +336,9 @@
 // Success will be set to false when conversion failed.
 // See documentation on Val procedure for syntax of s
 function StrToInt(s: shortstring; var success: boolean): LongInt;
-var Code: Word;
 begin
-val(s, StrToInt, Code);
-success:= Code = 0;
+val(s, StrToInt);
+success:= StrToInt <> nil;
 end;
 
 // Convert string to longint, without error checking
--- a/hedgewars/uWorld.pas	Tue Oct 09 09:02:39 2018 -0400
+++ b/hedgewars/uWorld.pas	Tue Oct 09 09:58:33 2018 -0400
@@ -1692,7 +1692,7 @@
             FPS:= Frames;
             Frames:= 0;
             CountTicks:= 0;
-            s:= Format(trmsg[sidFPS], inttostr(FPS));
+            s:= Format(shortstring(trmsg[sidFPS]), inttostr(FPS));
             tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels);
             tmpSurface:= doSurfaceConversion(tmpSurface);
             FreeAndNilTexture(fpsTexture);