Commit Graph
193 Commits
Author SHA1 Message Date
StorM a667499035 fix compile linux 2026-02-02 17:32:30 +01:00
StorM 38cd4dfe71 fix compile linux 2026-02-02 17:32:28 +01:00
agathoandClaude Opus 4.5 c986da9c77 perf(mmap): Cache failed MMAP load attempts to prevent repeated retries
Similar to the VMAP fix, this caches failed MMAP load attempts using a
bitset per TerrainInfo instance. This prevents the server from repeatedly
attempting to load MMAP tiles that don't exist (e.g., unused dungeon maps,
boost experience maps, etc.), which was causing significant slowdowns.

Changes:
- Add _mmapLoadFailed bitset to TerrainInfo class
- Skip LoadMMapImpl early if grid already marked as failed
- Cache FileNotFound, VersionMismatch, ReadFromFileFailed, and
  LibraryError results
- Change expected "FileNotFound" log level from WARN to DEBUG
- Update analysis documentation with fix status

Impact: Near-instant returns for grids with missing MMAP data instead of
repeated file I/O attempts.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: luis <[email protected]>
2026-02-02 13:31:23 -03:00
agathoandClaude Opus 4.5 cfe60008d5 perf(vmap): Cache failed VMAP load attempts to prevent repeated retries
Problem: VMAP loading for maps without data (Boost Experience, phased zones,
newer dungeons) was retried on EVERY access, causing:
- Thousands of file access attempts per session
- Log spam with "Could not load VMAP" errors
- Server slowdown from repeated disk I/O

Solution: Added _vmapLoadFailed bitset to TerrainInfo that caches failed
VMAP load attempts, similar to existing _gridFileExists pattern for maps.

Changes:
- TerrainMgr.h: Added _vmapLoadFailed bitset
- TerrainMgr.cpp: Check bitset before load, cache failures, reduce log level

Maps affected: 1949, 1950 (8.0 Boost), 1554, 1557 (7.0 Boost), 1465 (Tanaan),
2648, 2649, 2662, 2669 (TWW dungeons), and others without VMAP data.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: luis <[email protected]>
2026-02-02 13:29:41 -03:00
agathoandClaude Opus 4.5 66ecfc7a2f perf(threading): Fix extreme lag with lock contention and throttling optimizations
Root cause analysis identified cumulative lock contention causing severe lag
after humanization implementation. Applied comprehensive fixes:

GenericEventBus (CRITICAL):
- Changed lock-per-handler pattern to single lock acquisition
- Reduced mutex acquisitions from 100+ per event to 2
- ~50x improvement in event dispatch performance

GameSystemsManager (HIGH):
- Added throttle timers to 11 managers updating every frame
- Mount (200ms), Riding (5s), BattlePet (500ms), ArenaAI (100ms)
- PvPCombat (100ms), Auction (5s), Banking (5s), bridges (2-5s)
- ~30x reduction in manager updates per second

SpatialGridManager (MEDIUM):
- Added double-checked locking to CreateGrid()
- Added optimized GetOrCreateGrid() method
- Eliminates thundering herd on 90+ call sites

CombatEventRouter (MEDIUM):
- Replaced mutex-protected stats map with lock-free atomic array
- Zero lock contention for per-type statistics

Map.cpp:
- Changed ASSERT to graceful skip for race condition in SendObjectUpdates

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: luis <[email protected]>
2026-02-02 13:28:56 -03:00
agathoandClaude Opus 4.5 22e6d29ddc fix(spatial): Fix data race and performance issues in SpatialGridManager
PROBLEM: Extreme lag with 100+ bots caused by SpatialGridManager issues:

1. DATA RACE BUG in GetGrid():
   - Writing lastAccessTime under shared_lock using const_cast
   - Multiple threads writing same memory location concurrently = undefined behavior
   - Could cause crashes, memory corruption, or silent data corruption

2. PERFORMANCE ISSUE in GetGrid():
   - Called thousands of times per second (100+ bots × multiple calls per update)
   - Each call: acquire shared_lock + chrono::steady_clock::now()
   - Unnecessary overhead for a keep-alive timestamp that's rarely checked

3. Same issues in UpdateGrid() and TouchGrid()

SOLUTION:

1. GetGrid(): Remove lastAccessTime update entirely
   - This method is for READ-ONLY grid access
   - lastAccessTime is only used for cleanup of inactive grids
   - No need to update on every access

2. UpdateGrid(): Split into 3 phases
   - Phase 1: Get grid pointer under shared_lock (fast)
   - Phase 2: Update grid WITHOUT holding manager lock
   - Phase 3: Update lastAccessTime under exclusive lock

3. TouchGrid(): Use unique_lock (exclusive) for write operation
   - This method explicitly updates lastAccessTime
   - Must use exclusive lock for write operations

IMPACT:
- Eliminates ~1000+ chrono::now() calls per second
- Fixes potential memory corruption from data race
- Reduces lock contention on SpatialGridManager

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: luis <[email protected]>
2026-02-02 13:27:52 -03:00
agathoandClaude Opus 4.5 5e9d455b5c fix(pool): Fix InstanceBotPool account_id persistence and login failures
PROBLEM 1: "Pool bot failed to login via BotSpawner"
- Bots in maintenance state after warmup failure

PROBLEM 2: "No account ID for bot (not in slot or CharacterCache)"
- Bots with account_id = 0 in playerbot_instance_pool table
- CharacterCache doesn't have the account association

ROOT CAUSE:
The ON DUPLICATE KEY UPDATE clause in SyncToDatabase() did NOT include
`account_id`, so:
1. Bot initially saved with account_id = 0 (bug in some code path)
2. WarmUpBot corrects it from CharacterCache and updates the slot
3. SyncToDatabase INSERTs the correct account_id, BUT
4. ON DUPLICATE KEY UPDATE doesn't update account_id column
5. On restart, LoadFromDatabase loads account_id = 0 again

SOLUTION:
1. Add `account_id = VALUES(account_id)` to ON DUPLICATE KEY UPDATE
   - Now account_id corrections are persisted properly

2. Add account_id repair in LoadFromDatabase()
   - If account_id = 0, try to get it from CharacterCache
   - Log warning if CharacterCache also has no account

This ensures bots with previously corrupted account_id values
will be repaired on next load and the fix will be persisted.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: luis <[email protected]>
2026-02-02 13:26:40 -03:00
agathoandClaude Opus 4.5 323ff2021f perf(quest): Fix mutex contention in QuestCompletion with shared_mutex
PROBLEM: QuestCompletion used std::mutex for read-heavy data structures
which blocked ALL readers when ANY read was happening. With 100+ bots
calling quest-related functions from ThreadPool workers, this caused
severe lock contention and task delays.

AFFECTED MUTEXES (all read-heavy patterns):
- _pausedBotsMutex: Checked on EVERY quest event (HandleQuestEvent)
- _questOrderMutex: Read frequently during quest prioritization
- _objectiveOrderMutex: Read during objective sequencing

SOLUTION:
1. Changed _pausedBotsMutex from std::mutex to std::shared_mutex
   - Read operations (find) use std::shared_lock (concurrent readers OK)
   - Write operations (insert/erase) use std::unique_lock (exclusive)

2. Changed _questOrderMutex from std::mutex to std::shared_mutex
   - All operations use std::unique_lock (mostly writes in current code)
   - Future optimization: use shared_lock for read-only accesses

3. Changed _objectiveOrderMutex from std::mutex to std::shared_mutex
   - All operations use std::unique_lock (writes only currently)

This eliminates a major ThreadPool bottleneck where every bot's
quest event processing was blocking on mutex acquisition.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: luis <[email protected]>
2026-02-02 13:26:00 -03:00
agathoandClaude Opus 4.5 018de94dc3 perf(humanization): Fix mutex contention in HumanizationConfig
PROBLEM: HumanizationConfig used std::mutex which blocked ALL readers
when ANY read was happening. With 100+ concurrent bots calling
GetActivityConfig() and GetHourlyActivityMultiplier() from ThreadPool
workers, this caused severe lock contention and task delays.

SOLUTION:
1. Changed std::mutex to std::shared_mutex for read-heavy access
2. Use std::unique_lock only during Load()/Reload() (rare operation)
3. Use std::shared_lock for GetActivityConfig() (multiple readers OK)
4. Made GetHourlyActivityMultiplier() lock-free since _hourlyMultipliers
   is set once during Load() and never modified at runtime
5. Changed C-array to std::array<float, 24> for better type safety

This eliminates a major ThreadPool bottleneck where every bot's
HumanizationManager::Update() was blocking on mutex acquisition.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: luis <[email protected]>
2026-02-02 13:24:54 -03:00
agathoandClaude Opus 4.5 7c68c7b4d0 fix(threadpool): Prevent FreezeDetector crash with shorter timeouts
Root cause: ThreadPool::WaitForCompletion could block world thread for
35+ seconds (5s + 30s), leaving insufficient buffer before FreezeDetector
triggers at 60 seconds. Combined with other World::Update operations,
total time exceeded 60s causing forced crash.

Changes:
- BotWorldSessionMgr: Reduce wait timeouts from 5s+30s to 2s+8s (10s max)
- ThreadPool::WaitForCompletion: Add hard cap of 15 seconds regardless
  of caller-specified timeout
- ThreadPool.h: Change default timeout from milliseconds::max() to 10s

This ensures world thread never blocks more than 15 seconds in
WaitForCompletion, leaving 45+ seconds buffer for FreezeDetector.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: luis <[email protected]>
2026-02-02 13:23:11 -03:00
luis 8ce4578e85 typo fix and add blizzlike fixes 2026-02-02 00:47:02 -03:00
luis 5504081897 blizzlike boss 2026-02-01 21:38:43 -03:00
luis 78c9561f7d init boss merge 2026-02-01 21:11:34 -03:00
Shauren bcf0f246bd Core/SAI: Remove unused field
Signed-off-by: luis <[email protected]>
2026-02-01 20:47:51 -03:00
luis 52b123a173 more logs to debug 2026-02-01 18:39:30 -03:00
luis 52251aac69 debug log 2026-02-01 18:19:31 -03:00
Aqua Deus d23e0a29ad Scripts/Spells: Implement dh talent "Shattered Restoration" (#31507)
Signed-off-by: luis <[email protected]>
2026-02-01 17:47:00 -03:00
Cristian Vintila 407bbb59a7 Scripts/Spells: Implement Rake stealth stun and multiplier (#31511)
Signed-off-by: luis <[email protected]>
2026-02-01 17:46:07 -03:00
Cristian Vintila dff034f0d1 Scripts/Spells: Use form-dependent bleed spells for druid spell Thrash (#31513)
Signed-off-by: luis <[email protected]>
2026-02-01 17:45:27 -03:00
Shauren 6c06fb77f4 Core/VMaps: Fixed loading vmap tiles that have destructible buildings on them
Closes #31649

Signed-off-by: luis <[email protected]>
2026-02-01 17:44:22 -03:00
Shauren 3636899681 Core/VMaps: Optimize vmap tile unload
Signed-off-by: luis <[email protected]>
2026-02-01 17:43:45 -03:00
Aqua Deus 9f69176cbb Scripts/Spells: Implement dh talent "Wave of Debilitation" (#31510)
Signed-off-by: luis <[email protected]>
2026-02-01 17:43:08 -03:00
Cristian Vintila fff848d87f Scrips/Spells: Implement druid talent Thorns of Iron (#31537)
Signed-off-by: luis <[email protected]>
2026-02-01 17:41:43 -03:00
Aqua Deus b74db3d733 Scripts/Spells: Handle demon hunter soul fragments counter (#31504)
Signed-off-by: luis <[email protected]>
2026-02-01 16:29:42 -03:00
luis 67b0f6bf0b Improved mob fanning 2026-02-01 12:03:01 -03:00
ReZaRrandModoX 2db00e5c7c Scripts/WanderingIsle: Implement Singing Pools AreaTriggers (#31629)
Co-authored-by: ModoX <[email protected]>
Signed-off-by: luis <[email protected]>
2026-02-01 11:33:53 -03:00
LuzifixandShantalya 31fafec809 Core/Emote: Lean now reset if player move (#31570)
Co-authored-by: Shantalya <[email protected]>
Signed-off-by: luis <[email protected]>
2026-02-01 11:28:45 -03:00
Naddley 287e047763 Scripts/IsleOfDorn: Implement Quest: "Vereesas Tale" (#31615)
Signed-off-by: luis <[email protected]>
2026-02-01 11:24:11 -03:00
Aqua Deus 8b86485cd6 Core/Auras: Implement SPELL_AURA_DISABLE_AUTOATTACK (#31542)
Signed-off-by: luis <[email protected]>
2026-02-01 11:23:26 -03:00
Golrag 244f675627 Scripts/Arenas: Implement Empyrean Domain (#31427)
Signed-off-by: luis <[email protected]>
2026-02-01 11:22:37 -03:00
Golrag 7b757c9175 Core/Movement: Added ActionResultSetter for MovementStopReason to LaunchMoveSpline
Signed-off-by: luis <[email protected]>
2026-02-01 11:11:36 -03:00
Aqua Deus 21415d1dc0 Core/Spells: Spells with attribute SPELL_ATTR2_IGNORE_LINE_OF_SIGHT can bypass SPELL_AURA_INTERFERE_ENEMY_TARGETING and SPELL_AURA_INTERFERE_ALL_TARGETING (#31548)
Signed-off-by: luis <[email protected]>
2026-02-01 11:10:55 -03:00
Aqua Deus 5289073a1e Scripts/EyeOfAzshara: Implement King Deepbeard encounter (#31420)
Signed-off-by: luis <[email protected]>
2026-02-01 11:10:10 -03:00
Aqua Deus d6423deebb Scripts/Spells: Implement dh talent "Soul Carver" (#31503)
Signed-off-by: luis <[email protected]>
2026-02-01 10:52:39 -03:00
Aqua Deus 243fde3c78 Scripts/NeltharionsLair: Implement Rokmora encounter (#31162)
Signed-off-by: luis <[email protected]>
2026-02-01 10:51:39 -03:00
Cristian Vintila 40d77c41d4 Scripts/Spells: Implement Void Volley (#31502)
Signed-off-by: luis <[email protected]>
2026-01-31 18:39:22 -03:00
luis 3681010c2e new 12x data 2026-01-31 18:30:40 -03:00
luis c66c3947fe 12x data 2026-01-31 18:20:43 -03:00
luis b4992b2f38 65655 2026-01-31 18:16:56 -03:00
Shauren 441a9ff35f Core/Misc: Update expansions enum
Signed-off-by: luis <[email protected]>
2026-01-31 18:16:49 -03:00
luis 41806f4a6b Mob fanning system 2026-01-31 18:08:29 -03:00
luis c3f6469c08 typo 2026-01-31 12:32:37 -03:00
luis 04109fc66d agatho 2026-01-30 20:37:05 -03:00
luis 540f699cc2 update latest 2026-01-30 18:07:10 -03:00
luis 21155f62f7 Mising data 2026-01-29 22:06:45 -03:00
luis 189f4b97d2 Fix all missing data for creature template 2026-01-29 21:14:34 -03:00
luis 3e23cd82ee missing data 2026-01-29 20:53:37 -03:00
luis 67343dc1fd Missing spawns 2026-01-29 20:45:42 -03:00
agathoandClaude Opus 4.5 9bee356c0b fix(playerbot): 12.0 API compatibility for InnkeeperInteractionManager and BotMovement
TrinityCore 12.0 API changes applied:

InnkeeperInteractionManager.cpp:
- REST API: Use RestMgr for rest flag management instead of Player methods
  - SetRestFlag/HasRestFlag now via player->GetRestMgr()
  - SetRestState takes (RestTypes, PlayerRestState) not old REST_TYPE_IN_TAVERN
  - GetRestBonus via RestMgr instead of GetRestState()
- Homebind: Use player->m_homebind directly (GetHomebind() removed)
- AreaFlags: Use LinkedChat instead of Capital for city detection
- Added DB2Stores.h and RestMgr.h includes

InnkeeperInteractionManager.h:
- Fixed CalculateDistanceToQuestZones signature to include mapId parameter

BotMovementController.cpp:
- Fixed include paths for BotMovement subdirectory structure

Co-Authored-By: Claude Opus 4.5 <[email protected]>
2026-01-30 00:11:08 +01:00
agathoandClaude Opus 4.5 5521736b07 feat(playerbot): Update to WoW 12.0 protocol compatibility
CRITICAL 12.0 API Changes:
- Difficulty enum: uint8 → int16
- CastItemUseSpell: int32[2] → std::array<int32, 3>
- SpellCastRequest.Misc: 2 → 3 elements
- MovementInfo: New gravityModifier field
- SpellTargetData: Unknown1127_1/2 → HousingGUID/HousingIsResident
- SpellCastRequest field renames:
  - OptionalCurrencies → ExtraCurrencyCosts
  - OptionalReagents → CraftingReagents
  - RemovedModifications → RemovedReagents
  - CraftingFlags → CraftingCastFlags
- WriteBit() → WorldPackets::Bits<1>() pattern in packet serialization

Files updated:
- SpellPacketBuilder.cpp: Complete 12.0 packet serialization update
- PlayerBotHooks.h: Difficulty enum forward declaration
- GroupCoordinator.h: Difficulty enum forward declaration
- Action.cpp, RestStrategy.cpp, WarlockAI.cpp, CombatBehaviorIntegration.cpp,
  InventoryManager.cpp, BotActionProcessor.cpp: CastItemUseSpell signature

Co-Authored-By: Claude Opus 4.5 <[email protected]>
2026-01-30 00:11:08 +01:00