Added DivisionOperatorFix option for signed integer division (#278)

* it changes the behavior of vanilla division operator to use signed
integer division. Before it used signed division for floats but
unsigned for integers.

Added a new "div" operator for unsigned integer division.
Moved mathematical script functions from ScriptUtils.hpp to new MathOps.
Added include guard to sfall.h and main.h in modders pack.
This commit is contained in:
NovaRain
2020-02-02 21:49:54 +08:00
parent 1354467059
commit 21bf1056ac
14 changed files with 435 additions and 358 deletions
+3 -3
View File
@@ -10,10 +10,10 @@
#define below(a, b) (unsigned_comp(a, b) < 0)
#define below_equal(a, b) (unsigned_comp(a, b) <= 0)
procedure unsigned_comp(variable a, variable b) begin
// for sfall 4.2.3/3.8.23
pure procedure unsigned_comp(variable a, variable b) begin
if ((a bwxor b) == 0) then return 0; // a == b
if (b == 0) then return 1;
return 1 if (a / b) else -1;
return 1 if ((b == 0) orElse a div b) else -1;
end
#define MAX(x, y) ((x > y) * x + (x <= y) * y)
+5
View File
@@ -1,3 +1,6 @@
#ifndef SFALL_H
#define SFALL_H
//Recognised modes for set_shader_mode and get_game_mode
#define WORLDMAP (0x1)
#define DIALOG (0x4)
@@ -305,3 +308,5 @@
#define unjam_lock(obj) sfall_func1("unjam_lock", obj)
#define unset_unique_id(obj) sfall_func2("set_unique_id", obj, -1)
#define unwield_slot(critter, slot) sfall_func2("unwield_slot", critter, slot)
#endif