Skip to content

Fix for iterators not being cleared after a GMX#448

Open
mikecnr wants to merge 1 commit intopawn-lang:5.xfrom
mikecnr:foreachgmxfix
Open

Fix for iterators not being cleared after a GMX#448
mikecnr wants to merge 1 commit intopawn-lang:5.xfrom
mikecnr:foreachgmxfix

Conversation

@mikecnr
Copy link

@mikecnr mikecnr commented May 23, 2020

The code from OnScriptInit now runs after a 0ms timer is called, to ensure the gamemode is reloaded after a GMX before clearing and re-processing the default iterators (e.g. Player, Vehicle etc.) as Iter_Clear doesn't seem to work under OnScriptInit after a GMX. Exact cause unknown. Probably related to the fact that GMX is crap and should be avoided!

The code from OnScriptInit now runs after a 0ms timer is called, to ensure the gamemode is reloaded after a GMX before clearing and re-processing the default iterators (e.g. Player, Vehicle etc.) as Iter_Clear doesn't seem to work under OnScriptInit after a GMX. Exact cause unknown. Probably related to the fact that GMX is crap and should be avoided!
@Y-Less
Copy link
Member

Y-Less commented Jun 3, 2020

OK, my only concern with this is what happens if the iterators are used in OnGameModeInit - like CreateVehicle etc. They'll be added then instantly destroyed. There are several options:

  1. Clear them right at the end of OnGameModeExit instead.

  2. Add a check to any hooked function that would call Iter_Add - OnPlayerConnect, CreateVehicle, etc, and if the init code hasn't run yet do it there first. Of course that also relies on that check variable somehow being correctly reset.

  3. Figure out why Iter_Clear doesn't seem to work, especially since the timer is called so its not even a case of the callback not being called.

  4. Don't use Iter_Clear there, just replace it with something else entirely like inline code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants