Skip to content

Commit

Permalink
Release 4.3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
NovaRain committed May 30, 2022
2 parents c8cd9ef + a4230c3 commit 6b97ad4
Show file tree
Hide file tree
Showing 41 changed files with 327 additions and 147 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
target-branch: "develop"
labels:
- "dependencies"
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ Original description: A set of engine modifications for the classic game Fallout

---
#### Fallout Engine IDA Database
**[Download](https://www.dropbox.com/s/tm0nyx0lnk4yui0/Fallout_1_and_2_IDA68.rar "Download from Dropbox")** (comments are in Russian)
[Download for IDA Pro 6.8](https://www.dropbox.com/s/tm0nyx0lnk4yui0/Fallout_1_and_2_IDA68.rar?dl=1 "Download from Dropbox")
| [Download for IDA Pro 7.0](https://www.dropbox.com/s/61srq09pn8grfpu/Fallout_1_and_2_IDA70.rar?dl=1 "Download from Dropbox") (comments are in Russian)
25 changes: 10 additions & 15 deletions artifacts/ddraw.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
;sfall configuration settings
;v4.3.4
;v4.3.5

[Main]
;Set to 1 to enable the built-in High Resolution Patch mode that is similar to the hi-res patch by Mash
;The required settings will be read from the f2_res.ini configuration file of the original hi-res patch
;This option is always read from the main ddraw.ini file
HiResMode=1

;Set to 1 if you want to use command line arguments to tell sfall to use another ini file
Expand Down Expand Up @@ -57,6 +58,7 @@ SpeedMultiInitial=100
;Set to 6 for DX9 fullscreen windowed (the resolution in f2_res.ini should be set to the same aspect ratio as your desktop resolution)
;A DX9 mode is required for any graphics related script extender functions to work (i.e. fullscreen shaders)
;Modes 1, 2 and 3 are no longer supported
;This option will always be read from the main ddraw.ini file when using the hi-res patch by Mash
Mode=0

;If using a DX9 mode, this changes the resolution
Expand Down Expand Up @@ -588,15 +590,12 @@ SuperStimExploitFix=0
InventoryApCost=4
QuickPocketsApCostReduction=2

;Set to 1 to enable the balanced bullet distribution formula for burst attacks
ComputeSprayMod=0

;These options modify the bullet distribution of burst attacks if ComputeSprayMod is 1
;All the bullets are divided into three groups: central, left and right
;These three groups will then travel along three parallel tracks, trying to hit targets on the way
;CenterMult/Div set the ratio of how many bullets go to the central group, and remaining bullets are divided equally to left and right sides
;TargetMult/Div set the ratio of how many bullets in the central group will attack the primary target directly
;Multipliers are capped at divisor values
;These options modify the bullet distribution of burst attacks
;All the bullets are divided into three groups: center, left, and right
;These groups will then travel along three parallel tracks, trying to hit targets on the way
;CenterMult/Div set the ratio of how many bullets go to the center group, and the remaining are divided equally to the left and right sides
;TargetMult/Div set the ratio of how many bullets in the center group will attack the primary target directly
;Multiplier values are capped at divisor values
ComputeSpray_CenterMult=1
ComputeSpray_CenterDiv=3
ComputeSpray_TargetMult=1
Expand Down Expand Up @@ -741,10 +740,6 @@ CreateObjectSidFix=0
;Note that enabling this option will cause problems for existing grave scripts
GraveContainersFix=0

;Set to 1 to fix the issue with the division operator treating negative integers as unsigned
;Note: To perform the unsigned integer division, use the new 'div' operator
DivisionOperatorFix=1

;Set to 1 to fix the priority score calculation for choosing the best weapon for NPCs
;Note that enabling this option can affect the weapon of choice for some NPCs
AIBestWeaponFix=1
Expand Down Expand Up @@ -828,7 +823,7 @@ GlobalScriptPaths=scripts\gl*.int,scripts\sfall\gl*.int
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[Debugging]
;Extra sfall configuration settings that can be used by modders
;This section is not effected by the 'UseCommandLine' option. It will always be read from the main ini
;This section is not affected by the 'UseCommandLine' option. It will always be read from the main ddraw.ini file

;Set to 1 to enable sfall debugging mode
Enable=0
Expand Down
Binary file modified artifacts/mods/gl_npcarmor.int
Binary file not shown.
11 changes: 6 additions & 5 deletions artifacts/mods/gl_npcarmor.ssl
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,13 @@ procedure update_armor_apperance begin
end

procedure canuseweapon_handler begin
variable critter, canWield;
variable critter, canUse;
critter := get_sfall_arg;
if (critter != dude_obj and get_sfall_arg_at(3)) then begin
canWield := check_weapon_change(critter, get_sfall_arg, true);
// override result
set_sfall_arg(3, canWield);
set_sfall_return(canWield);
canUse := check_weapon_change(critter, get_sfall_arg, true);
if (canUse == false) then begin
set_sfall_arg(3, 0);
set_sfall_return(0); // overrides the result of engine function. Any non-zero value allows using the weapon
end
end
end
Binary file modified artifacts/mods/gl_partycontrol.int
Binary file not shown.
2 changes: 1 addition & 1 deletion artifacts/mods/gl_partycontrol.ssl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ procedure CombatTurn_Handler begin

if (status == 1) then begin
set_dude_obj(critter);
intface_redraw;
//display_msg("Take control of: " + obj_name(critter));

if (critter != real_dude_obj) then begin
Expand All @@ -78,7 +79,6 @@ procedure CombatTurn_Handler begin
level := has_trait(TRAIT_PERK, real_dude_obj, perkID);
if (level) then critter_add_trait(critter, TRAIT_PERK, perkID, level);
end
intface_redraw;

obj_set_light_level(critter, 100, 4);
inControl := true;
Expand Down
4 changes: 2 additions & 2 deletions artifacts/scripting/compiler/sslc_readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ When compiling global or hook scripts for sfall 3.4 or below, you _must_ include

This version of compiler was designed primarily for new sfall functions, but it can safely (and is recommended) to be used with non-sfall scripts as well, as long as you don't use any of the arrays syntax and any sfall script functions.

The original unmodified sslc source is over here: [http://www.teamx.ru/site_arc/utils/index.html](http://www.teamx.ru/site_arc/utils/index.html)
The original unmodified sslc source is over here: [https://teamx.ru/site_arc/utils/index.html](https://teamx.ru/site_arc/utils/index.html)

### Command line options

Expand Down Expand Up @@ -121,7 +121,7 @@ Syntax which requires sfall for compiled scripts to be interpreted is marked by
```
__NOTE:__ If your expression starts with a constant (eg. `2 + 2`), enclose it in parentheses, otherwise compiler will be confused and give you errors.
- Hexadecimal numerical constants: Simply prefix a number with `0x` to create a hexadecimal. The numbers 0 to 9 and A-F are allowed in the number. The number may not have a decimal point.
- Hexadecimal numerical constants: Simply prefix a number with `0x` to create a hexadecimal. The numbers 0 to 9 and letters A to F are allowed in the number. The number may not have a decimal point.
- new:
```
a := 0x1000;
Expand Down
10 changes: 6 additions & 4 deletions artifacts/scripting/functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -542,11 +542,13 @@
- name: Audio
items:
- name: eax_available
detail: int eax_available
detail: int eax_available()
opcode: 0x81a3
doc: Obsolete since sfall 2.1a. Always returns 0.
- name: set_eax_environment
detail: void set_eax_environment(int environment)
opcode: 0x81a4
doc: Obsolete since sfall 2.1a. Has no effect.

- name: play_sfall_sound
detail: int play_sfall_sound(string file, int mode)
Expand Down Expand Up @@ -631,7 +633,7 @@
doc: Arctangent of x. Pass 1 as y (don't ask...).
opcode: 0x81f1
- name: ceil
detail: int ceil(float)
detail: int ceil(float x)
opcode: 0x8266
doc: Round x to the nearest integer that is not less than x.
- name: ^
Expand Down Expand Up @@ -948,7 +950,7 @@
- name: nb_create_char
detail: int nb_create_char()
opcode: 0x81f6
doc: "`nb_*` functions are reserved for the brotherhood tactical training mod, and should be avoided."
doc: "`nb_*` functions are reserved for the brotherhood tactical training mod, and should be avoided. Not implemented, always returns 0."

- name: get_proto_data
detail: int get_proto_data(int pid, int offset)
Expand Down Expand Up @@ -983,7 +985,7 @@
detail: int gdialog_get_barter_mod
opcode: 0x824c
- name: set_inven_ap_cost
detail: void set_inven_ap_cost
detail: void set_inven_ap_cost(int cost)
opcode: 0x824d
- name: game_loaded
detail: int game_loaded()
Expand Down
2 changes: 1 addition & 1 deletion artifacts/scripting/sfall opcode list.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ _^ - These functions require AllowUnsafeScripting to be enabled in ddraw.ini_

0x824b - `int tile_under_cursor()`\
0x824c - `int gdialog_get_barter_mod()`\
0x824d - `void set_inven_ap_cost()`
0x824d - `void set_inven_ap_cost(int cost)`

0x825c - `void reg_anim_combat_check(int enable)`\
0x825a - `void reg_anim_destroy(object object)`\
Expand Down
2 changes: 1 addition & 1 deletion artifacts/scripting/sfall opcode list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@

0x824b - int tile_under_cursor()
0x824c - int gdialog_get_barter_mod()
0x824d - void set_inven_ap_cost()
0x824d - void set_inven_ap_cost(int cost)

0x825c - void reg_anim_combat_check(int enable)
0x825a - void reg_anim_destroy(object object)
Expand Down
2 changes: 2 additions & 0 deletions artifacts/translations/german.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ PartyOrderAttackHuman=Ich k
PartyOrderAttackCreature=::Grrrr::
PartyOrderAttackRobot=::Piep::

HiResInfo=Diese Version von Sfall verfügt über einen integrierten High Resolution Patch-Modus, der mit den Einstellungen des Hi-Res-Patch von Mash kompatibel ist.\n\nWenn der Hi-Res Patch von Mash weiterhin verwenden soll, deaktiviere die 'HiResMode'-Option in der ddraw.ini.\nUm die Grafikverbesserungen von Sfall zu erhalten, muss der originale Hi-Res-Patch deaktiviert werden.\n\nSoll der Hi-Res-Patch von Mash deaktiviert werden?

[AppearanceMod]
RaceText=Geschlecht
StyleText=Stil
Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ Pay special attention to the [best practices]({{ site.baseurl }}/best-practices/
Next, proceed to discover new functions. They are categorized, use the menu to find the one you need. If you can't, check [uncategorized functions]({{ site.baseurl }}/other/) list and [sfall macros]({{ site.baseurl }}/sfall-funcx-macros/). Also, there's search at the top of the page.

## Questions and problems
* Report bugs and suggest features on [Github](https://github.com/phobos2077/sfall/issues).
* Ask questions and discuss on the [forum](https://nma-fallout.com/threads/fo2-engine-tweaks-sfall.178390/).
* Report bugs and suggest features on [Github](https://github.com/sfall-team/sfall/issues).
* Ask questions and discuss on the [forum](https://www.nma-fallout.com/threads/fo2-engine-tweaks-sfall.178390/).
62 changes: 38 additions & 24 deletions docs/optimization.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,48 @@ The executation speed of scripts is not typically important in an unmodded game,

## sslc -O option

The sfall build of sslc supports a -O command line option to perform an optimization pass over the generated code. This isn't a magic make-my-code-go-faster bullet; most of what it does is very limited in scope. It's primary purpose was to strip out the procedures and variables which get automatically pulled into every script that includes define.h, whether you use them or not, and to do something about the additional variables that get created by foreach loops.
The sfall build of sslc supports a `-O` command line option to perform an optimization pass over the generated code. This isn't a magic make-my-code-go-faster bullet; most of what it does is very limited in scope. It's primary purpose was to strip out the procedures and variables which get automatically pulled into every script that includes **define.h**, whether you use them or not, and to do something about the additional variables that get created by `foreach` loops.

There are several levels of optimization available:
**There are several levels of optimization available:**
- `-O1` - Basic, only removes unreferenced globals variables and procedures, code itself remains untouched.
- `-O2` - Full, most code optimizations are on, but only those that were tested on complex scripts.
- `-O3` - Experimental, provides most efficiency, but tend to break some complex code due to bugs.

The following optimizations are performed:
**The following optimizations are performed:**

- constant expression folding: if an expression depends only on values which are known at compile time, then the expression is replaced by its result.
`a:=2+2;` -> `a:=4;`
```
a := 2 + 2; -> a := 4;
```

- constant variable initialization: All variables are initialised to some value, ('0', if you don't specify anything else,) so sslc attempts to make use of that fact to remove the first assignment to a variable if the first assignment is a constant expression.
```
variable a; -> variable a:=4;
a:=4; ->
variable a; -> variable a := 4;
a := 4; ->
```

- constant propagation: checks for values assigned to variables which can be computed at compile time, and replaces relevent references to the symbol by the constant. The original store is not removed by this optimization. Global variables are considered for this optimization only if they are not marked import or export, and are not assigned to anywhere in the script.
```
a:=4 -> a:=4
a := 4; -> a := 4;
foo(a); -> foo(4);
```

- dead code removal: Checks for and removes code which cannot be reached, either because it is hidden behind a return or because the argument to an if statement can be computed at compile time.
```
if 1 then begin -> display_msg("foo");
if (True) then begin -> display_msg("foo");
display_msg("foo"); ->
end else begin ->
display_msg("bar"); ->
end ->
```
- unreferenced variable elimination: Checks for variables which are never referenced, and removes them. Also applies to global variables, as long as they are not marked for export.

- unreferenced variable elimination: Checks for variables which are never referenced, and removes them. Also applies to global variables, as long as they are not marked for export.
```
variable i, j, k; -> variable i;
i:=1; -> i:=1;
i := 1; -> i := 1;
return; -> return;
```

- unreferenced procedure elimination: Checks for any procedures which are never called, and removes them.
```
procedure foo begin return "foo"; end -> procedure foo begin return "foo"; end
Expand All @@ -59,47 +66,54 @@ The following optimizations are performed:
display_msg(foo); -> end
end ->
```
- dead store removal: Removes variable assignments if the result of the variable is unused, and if the expression used to compute the value of the variable is provably free of side effects. (See 'pure' keyword)

- dead store removal: Removes variable assignments if the result of the variable is unused, and if the expression used to compute the value of the variable is provably free of side effects. (See `pure` keyword)
```
a:="moo"; -> a:="foo";
a:="foo"; -> display_msg(a);
a := "moo"; -> a := "foo";
a := "foo"; -> display_msg(a);
display_msg(a); ->
a:="bar"; ->
a := "bar"; ->
```

- store combination: Where there are two stores in a row to the same variable, the two expressions are combined.
```
var1 := var2; -> var1 := var2 + var3;
var1 += var3; ->
var1 += var3; ->
```
- variable combination: Where usage regions of variables do not overlap, combine the variables to provide additional candidates for unreferenced variable elimination. Very useful for scripts containing multiple foreach loops, which generate 2 or 3 hidden variables each.

- variable combination: Where usage regions of variables do not overlap, combine the variables to provide additional candidates for unreferenced variable elimination. Very useful for scripts containing multiple `foreach` loops, which generate 2 or 3 hidden variables each.
```
a:="foo"; -> a:="foo";
a := "foo"; -> a := "foo";
display_msg(a); -> display_msg(a);
b:="bar"; -> a:="bar";
b := "bar"; -> a := "bar";
display_msg(b); -> display_msg(a);
```

- namelist compression: Fallout stores the names of all file scope variables and procedures in a namelist which is saved into the .int. Any of these that are unreferenced can be removed, and the names of global variables can be modified to make them shorter.

## Writing your own code

- Don't have global scripts running any more often that you need them to. Not everything needs to be run every single frame.
- Never concat constant strings with the '+' operator, as it forces the operation to be done at runtime. The compiler can cope with constant strings being placed next to each other without the need for a +, which results in far more efficient code as the combination is done at lex time.

- Never concat constant strings with the `+` operator, as it forces the operation to be done at runtime. The compiler can cope with constant strings being placed next to each other without the need for a `+`, which results in far more efficient code as the combination is done at lex time.
```
#define GLOB_PREFIX "ts__" -> #define GLOB_PREFIX "ts__"
procedure start begin -> procedure start begin
set_sfall_global(GLOB_PREFIX + "foo1", 0); -> set_sfall_global(GLOB_PREFIX "foo1", 0);
end -> end
```
- Avoid function calls in while loops. function calls are expensive in comparison to variable lookups, so it's more efficient to move the function call out of the loop and store the result in a variable

- Avoid function calls in `while` loops. Function calls are expensive in comparison to variable lookups, so it's more efficient to move the function call out of the loop and store the result in a variable.
```
while i < len_array(array) do begin -> tmp:= len_array(array);
while i < len_array(array) do begin -> tmp := len_array(array);
... -> while i < tmp do begin
end -> ...
-> end
```
- Mark functions with pure or inline where relevent.

'pure' is a hint to the optimizer that a procedure has no side effects. (i.e. there's no way to tell that it's been called aside from its return value.) Pure procedures cannot modify global variables, or call any other procedure that isn't itself pure. Functions marked with pure can only be used in expressions (i.e. you cannot use the `call <procedure>` syntax to call them.) If there are non-pure terms in an expression, it prevents that expression being considered for dead store removal. Where no such optimizations can be performed, or if optimization is disabled, marking a procedure with pure will have no effect on the compiled code.
- Mark functions with `pure` or `inline` where relevent.

* `pure` is a hint to the optimizer that a procedure has no side effects. (i.e. there's no way to tell that it's been called aside from its return value.) Pure procedures cannot modify global variables, or call any other procedure that isn't itself pure. Functions marked with pure can only be used in expressions (i.e. you cannot use the `call <procedure>` syntax to call them.) If there are non-pure terms in an expression, it prevents that expression being considered for dead store removal. Where no such optimizations can be performed, or if optimization is disabled, marking a procedure with pure will have no effect on the compiled code.

'inline' is an instruction to the compiler to replace calls to the marked procedure with a copy of the procedures code instead of having a seperate call. inlined procedures cannot use the 'return' command, cannot be predefined, and cannot be used as part of an expression. inlining if a procedure is only going to be called once is always a win, but if there are multiple calls to a procedure you will end up bloating the size of the generated code.
* `inline` is an instruction to the compiler to replace calls to the marked procedure with a copy of the procedures code instead of having a seperate call. Inlined procedures cannot use the `return` command, cannot be predefined, and cannot be used as part of an expression. Inlining if a procedure is only going to be called once is always a win, but if there are multiple calls to a procedure you will end up bloating the size of the generated code.
Loading

0 comments on commit 6b97ad4

Please sign in to comment.