# HG changeset patch # User Wuzzy # Date 1548046295 -3600 # Node ID 7de65fa1f68623c8c548c63c802de066d71eb45e # Parent e6363b84b3fe2fffb0074639fe43624af4558c4e Fix SetClanColor causing crashes and rendering bugs diff -r e6363b84b3fe -r 7de65fa1f686 ChangeLog.txt --- a/ChangeLog.txt Mon Jan 21 02:52:09 2019 +0100 +++ b/ChangeLog.txt Mon Jan 21 05:51:35 2019 +0100 @@ -88,6 +88,7 @@ + Params explode, poison in the SpawnFake*Crate functions now optional and default to false + New global: InitHealth: Initial hog health value from game scheme (read-only) + Animate library: AnimOutOfNowhere: destX and destY are now optional (default: current position) + * Fix SetClanColor causing crashes and severe rendering bugs * Fix SetAmmoDelay not working properly when called after onGameStart * Fix DismissTeam not clearing team properly diff -r e6363b84b3fe -r 7de65fa1f686 hedgewars/uScript.pas --- a/hedgewars/uScript.pas Mon Jan 21 02:52:09 2019 +0100 +++ b/hedgewars/uScript.pas Mon Jan 21 05:51:35 2019 +0100 @@ -1358,7 +1358,8 @@ function lc_setclancolor(L : Plua_State) : LongInt; Cdecl; var clan : PClan; team : PTeam; - hh : THedgehog; + hht : THedgehog; + hhp : PHedgehog; i, j : LongInt; begin if CheckLuaParamCount(L, 2, 'SetClanColor', 'clan, color') then @@ -1373,12 +1374,17 @@ team:= clan^.Teams[i]; for j:= 0 to cMaxHHIndex do begin - hh:= team^.Hedgehogs[j]; - if (hh.Gear <> nil) or (hh.GearHidden <> nil) then + 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 begin - FreeAndNilTexture(hh.NameTagTex); - hh.NameTagTex:= RenderStringTex(ansistring(hh.Name), clan^.Color, fnt16); - RenderHealth(hh); + FreeAndNilTexture(hhp^.NameTagTex); + hhp^.NameTagTex:= RenderStringTex(ansistring(hhp^.Name), clan^.Color, fnt16); + RenderHealth(hhp^); end; end; FreeAndNilTexture(team^.NameTagTex); diff -r e6363b84b3fe -r 7de65fa1f686 hedgewars/uStore.pas --- a/hedgewars/uStore.pas Mon Jan 21 02:52:09 2019 +0100 +++ b/hedgewars/uStore.pas Mon Jan 21 05:51:35 2019 +0100 @@ -619,8 +619,13 @@ procedure RenderHealth(var Hedgehog: THedgehog); var s: shortstring; begin -s:= IntToStr(Hedgehog.Gear^.Health); FreeAndNilTexture(Hedgehog.HealthTagTex); +if Hedgehog.Gear <> nil then + s:= IntToStr(Hedgehog.Gear^.Health) +else if Hedgehog.GearHidden <> nil then + s:= IntToStr(Hedgehog.GearHidden^.Health) +else + exit; Hedgehog.HealthTagTex:= RenderStringTex(ansistring(s), Hedgehog.Team^.Clan^.Color, fnt16) end;