Simplify code for SetClanColor
authorWuzzy <Wuzzy2@mail.ru>
Mon, 21 Jan 2019 07:10:59 +0100
changeset 14645 9e7092e5990a
parent 14644 5fc5e4b79a5a
child 14646 e3e6b0c6543f
Simplify code for SetClanColor
hedgewars/uScript.pas
--- a/hedgewars/uScript.pas	Mon Jan 21 06:48:12 2019 +0100
+++ b/hedgewars/uScript.pas	Mon Jan 21 07:10:59 2019 +0100
@@ -1358,8 +1358,7 @@
 function lc_setclancolor(L : Plua_State) : LongInt; Cdecl;
 var clan : PClan;
     team : PTeam;
-    hht  : THedgehog;
-    hhp  : PHedgehog;
+    hh  : THedgehog;
     i, j : LongInt;
     colorArg: Int64;
     color: LongWord;
@@ -1390,17 +1389,13 @@
             team:= clan^.Teams[i];
             for j:= 0 to cMaxHHIndex do
                 begin
-                hht:= team^.Hedgehogs[j];
-                hhp:= nil;
-                if (hht.Gear <> nil) then
-                    hhp:= team^.Hedgehogs[j].Gear^.Hedgehog
-                else if (hht.GearHidden <> nil) then
-                    hhp:= team^.Hedgehogs[j].GearHidden^.Hedgehog;
-                if (hhp <> nil) then
+                hh:= team^.Hedgehogs[j];
+                if (hh.Gear <> nil) or (hh.GearHidden <> nil) then
                     begin
-                    FreeAndNilTexture(hhp^.NameTagTex);
-                    hhp^.NameTagTex:= RenderStringTex(ansistring(hhp^.Name), clan^.Color, fnt16);
-                    RenderHealth(hhp^);
+                    FreeAndNilTexture(hh.NameTagTex);
+                    hh.NameTagTex:= RenderStringTex(ansistring(hh.Name), clan^.Color, fnt16);
+                    RenderHealth(hh);
+                    team^.Hedgehogs[j]:= hh;
                     end;
                 end;
             FreeAndNilTexture(team^.NameTagTex);