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 Utils.cpp to new Math.cpp.
Added include guard to sfall.h and main.h in modders pack.
This commit is contained in:
NovaRain
2020-02-02 21:02:06 +08:00
parent eb204f0a04
commit 53b407b8a5
18 changed files with 214 additions and 117 deletions
+3
View File
@@ -584,6 +584,9 @@ StartGDialogFix=0
;attacker_results - unused, must be 0 or not equal to the target_results argument when specifying result flags for the target
AttackComplexFix=0
;Set to 1 to fix the issue with the division operator treating negative integers as unsigned
DivisionOperatorFix=1
;Set to 1 to enable the balanced bullet distribution formula for burst attacks
ComputeSprayMod=0
+4
View File
@@ -1,3 +1,5 @@
#ifndef MAIN_H
#define MAIN_H
#include "..\scripting\headers\sfall.h"
#include "..\scripting\headers\define_lite.h"
@@ -71,3 +73,5 @@ end
procedure InitConfigs begin
translationIni := GetIniConfigStr("Main", "TranslationsINI", "Translations.ini", "ddraw.ini");
end
#endif
@@ -344,6 +344,7 @@ There are several changes in this version of sslc which may result in problems f
- fixed compiler giving "assignment operator expected" error when a variable-like macro is not being defined properly
- added new logical operators "AndAlso", "OrElse" for short-circuit evaluation of logical expressions
- added an alternative (C/Java-style) assignment operator "="
- added support for new "div" operator (unsigned integer division)
> sfall 4.2.2
- added support for new opcode "reg_anim_callback"
+1 -1
View File
@@ -112,7 +112,7 @@
#define MSGBOX_SMALL (0x2)
#define MSGBOX_ALIGN_LEFT (0x4) // text aligned to left
#define MSGBOX_ALIGN_TOP (0x8) // text aligned to top
#define MSGBOX_YESNO (0x10) // uses YES/NO buttons instead of DONE
#define MSGBOX_YESNO (0x10) // use YES/NO buttons instead of DONE
#define MSGBOX_CLEAN (0x20) // no buttons
//remove inven obj defines
+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)
@@ -354,3 +357,5 @@
#define set_fake_perk_npc(npc, perk, level, image, desc) sfall_func5("set_fake_perk_npc", npc, perk, level, image, desc)
#define set_fake_trait_npc(npc, trait, active, image, desc) sfall_func5("set_fake_trait_npc", npc, trait, active, image, desc)
#define set_selectable_perk_npc(npc, perk, active, image, desc) sfall_func5("set_selectable_perk_npc", npc, perk, active, image, desc)
#endif
@@ -360,6 +360,8 @@
0x827d - void register_hook_proc_spec(int hook, procedure proc)
0x827e - void reg_anim_callback(procedure proc)
0x827f - div operator (unsigned integer division)
* These functions require AllowUnsafeScripting to be enabled in ddraw.ini