Lua API: Fix SetWind not updating flake direction
authorWuzzy <Wuzzy2@mail.ru>
Fri, 23 Feb 2018 14:26:58 +0100
changeset 13067 bcb87269867e
parent 13066 8d2087c85b8d
child 13068 dc77c2c679b2
Lua API: Fix SetWind not updating flake direction
ChangeLog.txt
hedgewars/uScript.pas
--- a/ChangeLog.txt	Fri Feb 23 14:10:03 2018 +0100
+++ b/ChangeLog.txt	Fri Feb 23 14:26:58 2018 +0100
@@ -80,6 +80,7 @@
  + New callback: onEndTurn(): Called at the end of a turn (when gears have settled)
  * AddAmmo now automatically unselects weapon if it would remove current ammo from current hedgehog
  * Fix call: SetWeapon(amNothing) now unselects weapon
+ * Fix call: SetWind did not update flake flying direction
  * Fix global: TotalRounds was stuck at -1 for several turns
 
 ====================== 0.9.23 ======================
--- a/hedgewars/uScript.pas	Fri Feb 23 14:10:03 2018 +0100
+++ b/hedgewars/uScript.pas	Fri Feb 23 14:26:58 2018 +0100
@@ -2514,14 +2514,17 @@
 end;
 
 function lc_setwind(L : Plua_State) : LongInt; Cdecl;
+var vg: PVisualGear;
 begin
     if CheckLuaParamCount(L, 1, 'SetWind', 'windSpeed') then
         begin
         cWindSpeed:= int2hwfloat(Trunc(lua_tonumber(L, 1))) / 100 * cMaxWindSpeed;
         cWindSpeedf:= SignAs(cWindSpeed,cWindSpeed).QWordValue / SignAs(_1,_1).QWordValue;
         if cWindSpeed.isNegative then
-            CWindSpeedf := -cWindSpeedf;
-        AddVisualGear(0, 0, vgtSmoothWindBar);
+            cWindSpeedf := -cWindSpeedf;
+        vg:= AddVisualGear(0, 0, vgtSmoothWindBar);
+        if vg <> nil then vg^.dAngle:= hwFloat2Float(cWindSpeed);
+            AddFileLog('Wind = '+FloatToStr(cWindSpeed));
         end;
     lc_setwind:= 0
 end;