Arma 3
Freestyles Crash Landing
Leopard20 18 Sep, 2020 @ 3:45am
Performance Improvements
Hi. Thanks for this useful mod!

If you don't mind, I'd like to share some tips to improve the performance of your mod. There were a couple of issues I noticed at first glance:

1. You always execVM or call compile your code, which is a bit slow (especially compile preprocessFileLineNumbers, which is really, really slow).

I recommend that you define these codes as functions and use the functions instead:
https://community.bistudio.com/wiki/Arma_3_Functions_Library#Adding_a_Function

so Instead of:
[] execVM "someFile.sqf" [] call compile preprocessFileLineNumbers "somefile.sqf"
You can write:
[] spawn TAG_fnc_someFnc [] call TAG_fnc_someFnc

This can improve the performance a lot.

2. At the end of your FCL_effects.sqf file, I recommend using waitUntil instead:
waitUntil {!(alive _veh and (((getPos _veh) # 2) > 2))};

3. Instead of something like: private _veh = param[0]; write:
params ["_veh"];
It does the exact same thing and it is shorter.

I hope it helps.

Regards
Last edited by Leopard20; 18 Sep, 2020 @ 3:27pm
< >
Showing 1-13 of 13 comments
Freestyle_Build  [developer] 18 Sep, 2020 @ 5:24am 
Thank you very much for your suggestions! I will look into improving my code in the next days.
I never thought that much about the performance... Thanks for reminding me!
Brazzer 21 Sep, 2020 @ 1:30am 
Hello,
nice mod! I would like to contribute by suggesting some more code optimization:

Since you're using CBA, you can filter out unwanted classes from your XEH. Moreover, I would switch to a "initPost" XEH in the case there are other "HandleDamage" kind EHs applied somewhere (because only the last one returns the damage to apply).

class Extended_InitPost_EventHandlers { class Air { class FSCL_customDamage { init = "(_this select 0) addEventHandler ["HandleDamage", {call FSCL_fnc_handleDamage})]"; exclude[] = {"ParachuteBase", "CruiseMissile1"}; }; }; };

This should work and prevent parachutes to show your custom effects. Please note that the form "addEventHandler ["type", {call myFunction}]" is faster than "addEventHandler ["type", {all my code here}]" and that I assume you implemented functions as suggested above (an alternative could be building your mod by following a CBA template so that your functions would be compiled at their manner).

Going on, when you set your "state" variable you should make its value public by setting the third parameter of setVariable as true (or again with CBA by using CBA_fnc_setVarNet). At the moment you set the variable where the aircraft is local and if there is a pilot change your variable would not exist for the new pilot causing the aircraft to potentially take more damage than the set treshold!

Lastly, you should set a default value when you use getVariable (private _state = _unit getVariable ["FSCL_state", 0];) and you should NOT remoteExec call or spawn since they could be blocked by battleye filters. Instead remoteExec a function (remoteExec is already scheduled when calling for functions, so suspension is allowed as for spawn).

Please consider adding your mod to github even if small in code amount :)

thank you!
Last edited by Brazzer; 21 Sep, 2020 @ 1:36am
Freestyle_Build  [developer] 21 Sep, 2020 @ 3:36am 
@Brazzer, thank you for your sugestions! I will definetely look into optimising my code. Also I will upload the source code to github in the next days and publish the link here and in the mods description.
Freestyle_Build  [developer] 21 Sep, 2020 @ 11:18am 
@Brazzer, here is the link to the mods GitHub[github.com]
Brazzer 22 Sep, 2020 @ 2:24am 
I made a pull request, please have a look at github :) I also sent you a friendship request
Freestyle_Build  [developer] 22 Sep, 2020 @ 3:08am 
@Brazzer, thank you! It look really cool, I am already readign the documentation and trying out hemmt!
Freestyle_Build  [developer] 22 Sep, 2020 @ 3:56am 
@Brazzer, when after building the addon using hemmt, which works fine, I got an error while launching arma:
'x\fscl\addons\main\functions\script_component.hpp' not found.
I fixed it by copying the script_component.hpp file into the functions folder. However I still receive an error about a misisng file called "XEH_preStart.sqf"
Brazzer 22 Sep, 2020 @ 5:36am 
that's my fault, let me fix it
Brazzer 22 Sep, 2020 @ 5:41am 
made a pull request, if you prefer, we can continue with private messages, anyway XEH_preStart is needed for function caching. Solved.
Freestyle_Build  [developer] 22 Sep, 2020 @ 6:04am 
@Brazzer, I will look into it later, I changed some things myself already. There were some minor errors in the scripts (like < and > being swapped) which I changed already, as well as defining the settings inside the XEH_preInit.sqf file. I will push thoses changes tomorow, when I am sure everything works. Additionally I plan on creating a dev branch a GitHub, so that potential problems can be addressed before pushing it to the main/release branch
Brazzer 22 Sep, 2020 @ 11:15am 
seems legit to me :) thank you for considering my help. Have a nice day :)
VedKay 15 Oct, 2020 @ 1:53am 
I bloody enjoyed reading this.. Love this community, good on ya fellas! :steamhappy:
jjhhytt 16 Oct, 2020 @ 9:47am 
excellent feedback
< >
Showing 1-13 of 13 comments
Per page: 1530 50