only-stats should never create visual gears. and lua should never rely on visual gears being created. critical is just to help ensure ones important to gameplay don't get lost in fast-forward 0.9.24
authornemo
Tue, 21 Aug 2018 15:11:28 -0400
branch0.9.24
changeset 13682 f60b3998ba56
parent 13615 3561a457c11c
child 13683 6c0cf6b9eff8
only-stats should never create visual gears. and lua should never rely on visual gears being created. critical is just to help ensure ones important to gameplay don't get lost in fast-forward
hedgewars/uScript.pas
hedgewars/uVisualGearsList.pas
--- a/hedgewars/uScript.pas	Mon Aug 06 21:41:06 2018 +0200
+++ b/hedgewars/uScript.pas	Tue Aug 21 15:11:28 2018 -0400
@@ -835,7 +835,7 @@
     params = 'x, y, visualGearType, state, critical [, layer]';
 begin
     uid:= 0;
-    if CheckAndFetchParamCount(L, 5, 6, call, params, n) then
+    if not(cOnlyStats) and CheckAndFetchParamCount(L, 5, 6, call, params, n) then
         begin
         s:= LuaToVisualGearTypeOrd(L, 3, call, params);
         if s >= 0 then
@@ -904,7 +904,7 @@
 function lc_getvisualgearvalues(L : Plua_State) : LongInt; Cdecl;
 var vg: PVisualGear;
 begin
-    if CheckLuaParamCount(L, 1, 'GetVisualGearValues', 'vgUid') then
+    if not(cOnlyStats) and CheckLuaParamCount(L, 1, 'GetVisualGearValues', 'vgUid') then
         begin
         vg:= VisualGearByUID(Trunc(lua_tonumber(L, 1)));
         if vg <> nil then
@@ -937,6 +937,8 @@
 function lc_setvisualgearvalues(L : Plua_State) : LongInt; Cdecl;
 var vg : PVisualGear;
 begin
+    lc_setvisualgearvalues:= 0;
+	if cOnlyStats then exit;
 // Param count can be 1-11 at present
 //    if CheckLuaParamCount(L, 11, 'SetVisualGearValues', 'vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint') then
 //        begin
@@ -963,11 +965,10 @@
                 vg^.Timer:= Trunc(lua_tonumber(L, 10));
             if not lua_isnoneornil(L, 11) then
                 vg^.Tint:= Trunc(lua_tonumber(L, 11))
-            end;
+            end
 //        end
 //    else
 //        lua_pushnil(L); // return value on stack (nil)
-    lc_setvisualgearvalues:= 0
 end;
 
 // so. going to use this to get/set some of the more obscure gear values which were not already exposed elsewhere
--- a/hedgewars/uVisualGearsList.pas	Mon Aug 06 21:41:06 2018 +0200
+++ b/hedgewars/uVisualGearsList.pas	Tue Aug 21 15:11:28 2018 -0400
@@ -63,6 +63,7 @@
     sp: real;
 begin
 AddVisualGear:= nil;
+if cOnlyStats then exit;  // stats only should never ever create a visual gear
 if (GameType <> gmtRecord) and
    (((GameType = gmtSave) or (fastUntilLag and (GameType = gmtNet)) or fastScrolling) and // we are scrolling now
    (not Critical)) then