sethogname/hat need to wrap entire operation around test of hog/gear
authornemo
Tue, 03 Dec 2013 22:48:21 -0500
changeset 9748 b0286b0c91ce
parent 9747 abe0c8a2d573
child 9749 443d233316e5
sethogname/hat need to wrap entire operation around test of hog/gear
hedgewars/uScript.pas
--- a/hedgewars/uScript.pas	Wed Dec 04 02:08:46 2013 +0200
+++ b/hedgewars/uScript.pas	Tue Dec 03 22:48:21 2013 -0500
@@ -855,7 +855,6 @@
 
 function lc_sethogname(L : Plua_State) : LongInt; Cdecl;
 var gear : PGear;
-  hogName: ShortString;
 begin
     if lua_gettop(L) <> 2 then
         begin
@@ -866,13 +865,12 @@
         begin
         gear:= GearByUID(lua_tointeger(L, 1));
         if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
-
-        hogName:= lua_tostring(L, 2);
-            gear^.Hedgehog^.Name:= hogName;
+            begin
+            gear^.Hedgehog^.Name:= lua_tostring(L, 2);
 
-        FreeTexture(gear^.Hedgehog^.NameTagTex);
-        gear^.Hedgehog^.NameTagTex:= RenderStringTex(gear^.Hedgehog^.Name, gear^.Hedgehog^.Team^.Clan^.Color, fnt16);
-
+            FreeTexture(gear^.Hedgehog^.NameTagTex);
+            gear^.Hedgehog^.NameTagTex:= RenderStringTex(gear^.Hedgehog^.Name, gear^.Hedgehog^.Team^.Clan^.Color, fnt16)
+            end
         end;
     lc_sethogname:= 0;
 end;
@@ -1744,13 +1742,15 @@
         begin
         gear:= GearByUID(lua_tointeger(L, 1));
         if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
+            begin
             hat:= lua_tostring(L, 2);
             gear^.Hedgehog^.Hat:= hat;
-AddFileLog('Changed hat to: '+hat);
+            AddFileLog('Changed hat to: '+hat);
             if (Length(hat) > 39) and (Copy(hat,1,8) = 'Reserved') and (Copy(hat,9,32) = gear^.Hedgehog^.Team^.PlayerHash) then
                 LoadHedgehogHat(gear^.Hedgehog^, 'Reserved/' + Copy(hat,9,Length(hat)-8))
             else
-                LoadHedgehogHat(gear^.Hedgehog^, hat);
+                LoadHedgehogHat(gear^.Hedgehog^, hat)
+            end
         end;
     lc_sethoghat:= 0;
 end;