zen-mod / ZEN

Zeus enhancement mod for Arma 3
https://zen-mod.github.io/ZEN
GNU General Public License v3.0
108 stars 47 forks source link

Fix laser cycling too quickly #712

Closed ampersand38 closed 1 year ago

ampersand38 commented 1 year ago

When merged this pull request will:

mharis001 commented 1 year ago

@ampersand38 I changed it to check for ammo simulation which I think will be more generalized. Please merge if the changes look good to you.

ampersand38 commented 1 year ago

For high rof weapons, do we want to cache the magazine to avoid having config look up every round?

rautamiekka commented 1 year ago

I don't see why not always cache it. Or many other data, for that matter, especially if always local to the Server.

mharis001 commented 1 year ago

I don't think it is really needed (0.0011 ms improvement). Does not seem like the slow part of the function when testing with the laser designator turret. Can also revisit this later.

Result:
0.0021 ms

Cycles:
10000/10000

Code:
private _magazine = "Laserbatteries";
private _ammo = getText (configFile >> "CfgMagazines" >> _magazine >> "ammo"); 
private _ammoSimulation = getText (configFile >> "CfgAmmo" >> _ammo >> "simulation");
_ammoSimulation == "laserDesignate"
Result:
0.001 ms

Cycles:
10000/10000

Code:
private _magazine = "Laserbatteries";
private _ammoSimulation = a getOrDefaultCall [_magazine, {
    private _ammo = getText (configFile >> "CfgMagazines" >> _magazine >> "ammo"); 
    getText (configFile >> "CfgAmmo" >> _ammo >> "simulation")
}, true];

_ammoSimulation == "laserDesignate"
Result:
0.0269 ms

Cycles:
10000/10000

Code:
a call zen_common_fnc_fireWeapon
ampersand38 commented 1 year ago

I meant for when the weapon is a machinegun or autocannon, but yeah it's probably fine. Good to merge then?

rautamiekka commented 1 year ago

0.0021 ms [...] 0.001 ms

It's true that it ain't exactly very much, but since it only has a pro and no cons (AFAICT), and slowdowns eventually stack ... Plus the general good practices say that cache multiple-use stuff.