Files
WoWee/include/game/faction_hostility.hpp
Josh Anderson 624287983d refactor(faction): extract buildFactionHostilityMap into a shared free function
Application::buildFactionHostilityMap() (called from WorldLoader as
part of world-entry setup) had its entire DBC-driven implementation
inline, tightly coupled to Application's own assetManager/gameHandler
members. Extracted the logic (unchanged) into
game::buildFactionHostilityMap(), taking AssetManager&/GameHandler&
directly instead. Application::buildFactionHostilityMap() is now a
thin wrapper.

No behavior change for the existing call site - this is pure
de-duplication/reusability, making the DBC-driven hostility
computation (FactionTemplate.dbc/Faction.dbc reaction-group bitmasks,
matching what CMaNGOS computes server-side) callable from contexts
that don't have an Application instance.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-12 08:42:24 -05:00

26 lines
987 B
C++

#pragma once
#include <cstdint>
namespace wowee {
namespace pipeline { class AssetManager; }
namespace game {
class GameHandler;
// Builds the per-FactionTemplate hostility map from FactionTemplate.dbc/
// Faction.dbc (reaction-group bitmasks, explicit enemy faction IDs, and
// Faction.dbc base reputation - the same signals CMaNGOS uses server-side)
// and installs it via GameHandler::setFactionHostileMap().
//
// GameHandler::isHostileFaction() defaults an unrecognized faction template
// ID to hostile=true (a reasonable default once the map is actually
// populated, since anything left out by the DBC-driven loop below is
// genuinely unusual). Call this once per session, as soon as playerRace is
// known and the asset manager is initialized, or every faction template
// will fall through to that hostile default.
void buildFactionHostilityMap(pipeline::AssetManager& assetManager, GameHandler& gameHandler, uint8_t playerRace);
} // namespace game
} // namespace wowee