mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-15 01:49:09 +00:00
fix: Replace static m_botReleaseTimes with per-bot storage to prevent race condition
Fixes a thread safety issue where multiple bots dying in battlegrounds simultaneously would corrupt the shared static unordered_map, causing segmentation faults. Changes: - Remove: static m_botReleaseTimes map from AutoReleaseSpiritAction - Add: bgReleaseAttemptTime member to PlayerbotAI (per-bot storage) - Update: All references to use per-bot storage instead of static map Why this fixes the crash: - Each PlayerbotAI instance is accessed by only one map update thread - No cross-thread access to shared data structures - No mutex/locking required - thread-safe by design - Automatic cleanup when bot is destroyed Thread-safe solution: Per-bot state eliminates race conditions without performance overhead. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -601,6 +601,7 @@ public:
|
||||
NewRpgInfo rpgInfo;
|
||||
NewRpgStatistic rpgStatistic;
|
||||
std::unordered_set<uint32> lowPriorityQuest;
|
||||
time_t bgReleaseAttemptTime = 0;
|
||||
|
||||
// Schedules a callback to run once after <delayMs> milliseconds.
|
||||
void AddTimedEvent(std::function<void()> callback, uint32 delayMs);
|
||||
|
||||
Reference in New Issue
Block a user