Files
runelite/runelite-client/src/main/java
Jordan Atwood 5ef3597486 timers plugin: Reset Teleblock on entering safe zone
The effects of the Tele Block spell expire on three possible conditions:

1. When a player leaves the wilderness on a non-PVP/DMM world
2. When a player enters a PVP/DMM world safe zone
3. When a player logs out

Leaving the wilderness can be detected via Varbits changes, entering
safe zones in PVP/DMM worlds can be detected via WidgetHiddenChanged
events, and logging out is already detected via GameStateChanged events.
With that said, addressing the first two cases is not a trvial effort as
there are certain race conditions that must be handled. The
WidgetHiddenChanged event triggers upon login to PVP worlds regardless
of where you log in, and the PVP widgets all initially load in a state
which would be reflective of being in a safe zone, and are later set to
the proper state before the first display frame is rendered. Similarly,
during world hops, GameStateChanged and VarbitChanged events trigger in
a pattern which causes the client to think that a player is always
outside the wilderness upon reaching a `LOGGED_IN` game state; that is,
the following events occur on world hopping:

1. Game state changes to `HOPPING`
2. Varbits are all reset to default values. In the case of the
   wilderness varbit, it is set to 0--the value representing being
   outside the wilderness.
3. Game state changes to `LOGGED_IN`
4. Varbits are set based on player information. Only at this point is
   the IN_WILDERNESS varbit set to its proper value.

To handle these race conditions, the event subscribers for game state
change and widget hidden events only set a flag which is checked once
per game tick to handle PVP safe zone (and wilderness varbit) checks.

Fixes runelite/runelite#2384
2018-09-23 14:45:21 -07:00
..