# HG changeset patch # User Wuzzy # Date 1535997710 -7200 # Node ID f1c66a34f2feff08b86cb7edf76b08484d20798b # Parent 5985ee7a4922eafd6dc8dceff7d74fed13a3758d Lua: Fix LeftX, RightX, TopY, LAND_WIDTH, LAND_HEIGHT being broken if onVisualGearAdd is set Fixes bug 585 diff -r 5985ee7a4922 -r f1c66a34f2fe ChangeLog.txt --- a/ChangeLog.txt Mon Sep 03 12:59:54 2018 +0200 +++ b/ChangeLog.txt Mon Sep 03 20:01:50 2018 +0200 @@ -134,6 +134,7 @@ * Animate library: Remove defunct follow argument for AnimVisualGear * Changed global: lfCurrentHog becomes lfCurHogCrate * Fixed variable: TotalRounds was -1 (instead of 0) in first real round after hog placement phase + * Fixed variables: LeftX, RightX, TopY, LAND_WIDTH, LAND_HEIGHT were broken if onVisualGearAdd was defined * AI sometimes intentionally shot hedgehogs with aihDoesntMatter set ====================== 0.9.24.1 ==================== diff -r 5985ee7a4922 -r f1c66a34f2fe hedgewars/uLand.pas --- a/hedgewars/uLand.pas Mon Sep 03 12:59:54 2018 +0200 +++ b/hedgewars/uLand.pas Mon Sep 03 20:01:50 2018 +0200 @@ -873,6 +873,7 @@ if (WorldEdge <> weNone) and (not hasBorder) then InitWorldEdges(); +ScriptSetMapGlobals; end; procedure GenPreview(out Preview: TPreview); @@ -889,6 +890,8 @@ OutError('Unknown mapgen', true); end; + ScriptSetMapGlobals; + // strict scaling needed here since preview assumes a rectangle rh:= max(LAND_HEIGHT,2048); rw:= max(LAND_WIDTH,4096); @@ -938,6 +941,8 @@ OutError('Unknown mapgen', true); end; + ScriptSetMapGlobals; + // strict scaling needed here since preview assumes a rectangle rh:= max(LAND_HEIGHT, 2048); rw:= max(LAND_WIDTH, 4096); diff -r 5985ee7a4922 -r f1c66a34f2fe hedgewars/uScript.pas --- a/hedgewars/uScript.pas Mon Sep 03 12:59:54 2018 +0200 +++ b/hedgewars/uScript.pas Mon Sep 03 20:01:50 2018 +0200 @@ -40,6 +40,7 @@ procedure ScriptOnScreenResize; procedure ScriptSetInteger(name : shortstring; value : LongInt); procedure ScriptSetString(name : shortstring; value : shortstring); +procedure ScriptSetMapGlobals; procedure ScriptCall(fname : shortstring); function ScriptCall(fname : shortstring; par1: LongInt) : LongInt; @@ -99,7 +100,6 @@ ScriptAmmoDelay : shortstring; ScriptAmmoReinforcement : shortstring; ScriptLoaded : boolean; - mapDims : boolean; PointsBuffer: shortstring; PrevCursorX, PrevCursorY: LongInt; PendingTurnTimeLeft, PendingReadyTimeLeft: LongWord; @@ -3540,7 +3540,6 @@ ScriptSetInteger('ClansCount', ClansCount); ScriptSetInteger('TeamsCount', TeamsCount); -mapDims:= false end; @@ -3709,21 +3708,21 @@ PrevCursorY:= NoPointX end; -if not mapDims then - begin - mapDims:= true; - ScriptSetInteger('LAND_WIDTH', LAND_WIDTH); - ScriptSetInteger('LAND_HEIGHT', LAND_HEIGHT); - ScriptSetInteger('LeftX', leftX); - ScriptSetInteger('RightX', rightX); - ScriptSetInteger('TopY', topY) - end; if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) then ScriptSetInteger('CurrentHedgehog', CurrentHedgehog^.Gear^.UID) else ScriptSetNil('CurrentHedgehog'); end; +procedure ScriptSetMapGlobals; +begin +ScriptSetInteger('LAND_WIDTH', LAND_WIDTH); +ScriptSetInteger('LAND_HEIGHT', LAND_HEIGHT); +ScriptSetInteger('LeftX', leftX); +ScriptSetInteger('RightX', rightX); +ScriptSetInteger('TopY', topY); +end; + procedure GetGlobals; var currentTTL, currentRTL, newTTL, newRTL: LongInt; begin @@ -4382,7 +4381,6 @@ procedure initModule; begin -mapDims:= false; PointsBuffer:= ''; PrevCursorX:= NoPointX; PrevCursorY:= NoPointX;