Skip to content

Conversation

@devw4r
Copy link
Contributor

@devw4r devw4r commented Jan 18, 2026

Re-add thread synchronization to UpdatePacketFactory and ObjectManager.

This commit re-introduces RLock-based synchronization for the update field mechanism, effectively reverting the removal of locks that occurred in commit #f392c50f

The synchronization is required to prevent race conditions that the Python Global Interpreter Lock (GIL) does not cover:

  1. Atomicity of 64-bit updates: These are split into two 32-bit operations. Without locks, a thread generating a packet could capture a corrupted state where only half of a 64-bit value is updated.

  2. Consistent Snapshots: When generating update packets, the iteration over bitmasks and field values must be atomic relative to writers to ensure the client receives a consistent "point-in-time" state of the object.

  3. Atomic "Check-then-Set": Logical sequences that check if a field should be updated before applying the change are not atomic at the bytecode level and require protection to prevent interleaved updates from different threads (e.g., Network handlers, Player tick, Creature tick or Go's tick).

These changes fix bugs where multiple observers would occasionally see inconsistent state (such as a creature appearing alive for one player and dead for another) due to shared-state mutation or partial updates during packet generation.

  • World socket optimizations. (Remove Nagle's algorithm)
  • New unified WorldServerTicker for deterministic execution and improved synchronization.
  • Fix case were auras like Devotion Aura were wrongfully removed from the player upon killing something.
  • Fix case in which players received duplicate update packets upon spawning from teleport.
  • Fix issues with ObjectManager value setters and UpdatePacketFactory, which caused some fields to always return should_update as TRUE, spamming clients with updates every tick.
  • Fix Resurrection Sickness causing health regeneration to kill the player.
  • Make sure unit.die() is called where set_health() calls are made if necessary.

Re-add thread synchronization to UpdatePacketFactory and ObjectManager.

This commit re-introduces RLock-based synchronization for the update field
mechanism, effectively reverting the removal of locks that occurred in
commit #f392c50f

The synchronization is required to prevent race conditions that the Python
Global Interpreter Lock (GIL) does not cover:

1. Atomicity of 64-bit updates: These are split into two 32-bit operations.
   Without locks, a thread generating a packet could capture a corrupted
   state where only half of a 64-bit value is updated.

2. Consistent Snapshots: When generating update packets, the iteration over
   bitmasks and field values must be atomic relative to writers to ensure
   the client receives a consistent "point-in-time" state of the object.

3. Atomic "Check-then-Set": Logical sequences that check if a field should
   be updated before applying the change are not atomic at the bytecode
   level and require protection to prevent interleaved updates from
   different threads (e.g., Network, Player Tick, and Creature Tick).

These changes fix the bug where multiple observers would occasionally see
inconsistent state (such as a creature appearing alive for one player and
dead for another) due to shared-state mutation or partial updates during
packet generation.
@devw4r devw4r marked this pull request as draft January 19, 2026 03:29
…ker for deterministic execution and improved synchronization.
@devw4r devw4r marked this pull request as ready for review January 20, 2026 02:02
@devw4r devw4r marked this pull request as draft January 20, 2026 05:37
- Fix case were auras like Devotion Auras were wrongfully removed from the player upon killing something.
- Fix case in which players received duplicate update packets upon spawning from teleport.
- Make sure we always pass the proper value type to UpdatePacketFactory, this fixes some issues in which some fields were always returning should_update as TRUE, spamming clients with updates every tick.
- Fix Resurrection Sickness causing health regeneration to kill the player.
- Make sure unit.die() is called if necessary where set_health() calls are made.
@devw4r devw4r marked this pull request as ready for review January 21, 2026 05:18
devw4r added 13 commits January 20, 2026 23:36
…ess.

- Enhance process initialization to prevent hanging in the event of a segmentation fault.
- Persistent auras which are not periodic should not apply effect each tick spamming apply_bonuses. e.g. Devotion Aura
- Better fix for SPELL_AURA_DAMAGE_SHIELD.
- Loot - Both loops should check if they need to remove quest items.
- Avoid duplicate selection for pool entries.
- Parse spell targets aligned with the client code. 'SpellPutCastTargets'
- Use SMSG_RESISTLOG instead of SMSG_SPELL_GO.
- Put only real misses in SMSG_SPELL_GO.
- Fix distract effect not making the unit turn and face angle.
- Add optional fix for sitting on chairs/benches nudge.
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.

1 participant