Backed out changeset a62408ee8281. Allowing HedgewarsScriptLoad to not stop if script is missing is dumb
authorWuzzy <Wuzzy2@mail.ru>
Fri, 31 Aug 2018 21:22:12 +0200
changeset 13727 eeeea1cfaf08
parent 13726 a62408ee8281
child 13728 247d1bcf3c5e
Backed out changeset a62408ee8281. Allowing HedgewarsScriptLoad to not stop if script is missing is dumb
ChangeLog.txt
hedgewars/uScript.pas
--- a/ChangeLog.txt	Fri Aug 31 21:07:07 2018 +0200
+++ b/ChangeLog.txt	Fri Aug 31 21:22:12 2018 +0200
@@ -107,7 +107,6 @@
  + New call: GetLaserSight(): Returns true if laser sight (as utility) is currenctly active (ignoring sniper rifle)
  + New call: IsHogHidden(gear): Returns true if hog is hidden
  + Changed call: AddTeam: 2nd param. color: Accepts negative value to use a default clan color from player settings
- + Changed call: HedgewarsScriptLoad: Now returns true or false based on success
  + Change callback: onGearResurrect: 2nd parameter for visual gear spawned at resurrect position (might be nil)
  + New parameter: SetAmmoTexts: 5th param. showExtra: Set to false to hide texts like “Not yet available”
  + New parameter: ShowMission: 6th param. forceDisplay: Set to true to prevent this particular mission panel to be hidden manually by player
--- a/hedgewars/uScript.pas	Fri Aug 31 21:07:07 2018 +0200
+++ b/hedgewars/uScript.pas	Fri Aug 31 21:22:12 2018 +0200
@@ -34,7 +34,7 @@
 procedure ScriptPrintStack;
 procedure ScriptClearStack;
 
-function  ScriptLoad(name : shortstring; mustExist : boolean) : boolean;
+procedure ScriptLoad(name : shortstring; mustExist : boolean);
 procedure ScriptOnPreviewInit;
 procedure ScriptOnGameInit;
 procedure ScriptOnScreenResize;
@@ -3066,16 +3066,12 @@
 
 
 function lc_hedgewarsscriptload(L : Plua_State) : LongInt; Cdecl;
-var success : boolean;
 begin
     if CheckLuaParamCount(L, 1, 'HedgewarsScriptLoad', 'scriptPath') then
-        begin
-        success:= ScriptLoad(lua_tostring(L, 1), false);
-        lua_pushboolean(L, success);
-        end
+        ScriptLoad(lua_tostring(L, 1), true)
     else
-        lua_pushboolean(L, false);
-    lc_hedgewarsscriptload:= 1;
+        lua_pushnil(L);
+    lc_hedgewarsscriptload:= 0;
 end;
 
 
@@ -3564,7 +3560,7 @@
 end;
 // ⭒⭐⭒✨⭐⭒✨⭐☆✨⭐✨✧✨☆✨✧✨☆⭒✨☆⭐⭒☆✧✨⭒✨⭐✧⭒☆⭒✧☆✨✧⭐☆✨☆✧⭒✨✧⭒☆⭐☆✧
 
-function ScriptLoad(name : shortstring; mustExist : boolean) : boolean;
+procedure ScriptLoad(name : shortstring; mustExist : boolean);
 var ret : LongInt;
       s : shortstring;
       f : PFSFile;
@@ -3583,7 +3579,6 @@
         OutError('Script not found: ' + name, true)
     else
         AddFileLog('[LUA] Script not found: ' + name);
-    ScriptLoad:= false;
     exit;
     end;
 
@@ -3607,15 +3602,13 @@
     begin
     LuaError('Failed to load ' + name + '(error ' + IntToStr(ret) + ')');
     LuaError(lua_tostring(luaState, -1));
-    ScriptLoad:= false;
     end
 else
     begin
     WriteLnToConsole('Lua: ' + name + ' loaded');
     // call the script file
     lua_pcall(luaState, 0, 0, 0);
-    ScriptLoaded:= true;
-    ScriptLoad:= true;
+    ScriptLoaded:= true
     end;
 end;