Skip to content

Locality and JIP issues #41

@LewisSO

Description

@LewisSO

Usage of player reference in eventhandlers and functions in general.
When player is used, it references all players on the server. Need to ensure that all eventhandlers and functions intended to be ran on specific players only are referencing them correctly and locally rather than using the global player reference.

Example:

{ _player removeAllEventHandlers "Killed"; _player removeAllEventHandlers "Respawn"; _player setVariable["FIELD_HQ_Signed", true, true]; _player setVariable["FIELD_HQ_DES", _name, true]; player addEventHandler ["Killed",{[player, false] call PRAE_fnc_praeKilled}]; player addEventHandler ["Respawn",{[player, (player getVariable["FIELD_HQ_DES", Nil]), false] call PRAE_fnc_praeRespawned}]; };

In this case the references to player are global. So the new eventhandler would be added to all players, further, the reference to players inside of the eventhandler are looking at all players to check variables and run functions. BAD.

Instead:

{ _player removeAllEventHandlers "Killed"; _player removeAllEventHandlers "Respawn"; _player setVariable["FIELD_HQ_Signed", true, true]; _player setVariable["FIELD_HQ_DES", _name, true]; _player addEventHandler ["Killed",{[(_this select 0), false] call PRAE_fnc_praeKilled}]; _player addEventHandler ["Respawn",{[(_this select 0), ((_this select 0) getVariable["FIELD_HQ_DES", Nil]), false] call PRAE_fnc_praeRespawned}]; };

Replace player reference with a local one if it exists.

[_this select 0]; (_this select 0);

  • Repalce references to player inside of PRAE Field HQ
  • Repalce references to player inside of Multispawn (If not intended to be global)
  • Test Multispawn Module
  • Test PRAE Field HQ module combined with Multispawn

Metadata

Metadata

Labels

BugIssue is in relation to an unintended side effectPriority - CriticalIssue is of a critical priority and is mod breakingUpdateUpdate to an existing feature

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions