mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 16:10:36 +00:00
Flips a faction's at-war state by ID rather than by displayed-list position. A ClassicAPI extension -- Blizzard has no such call. The stock FactionToggleAtWar(index) resolves its index to a faction id and then reads, negates and writes through two helpers that already take an id, so the by-id form is that pair without the resolve. Every rule stays in the engine: the refusal to make peace below -3000 standing, the peace-forced flag, the loot-session bail, and CMSG_SET_FACTION_ATWAR. Going through the engine's setter also picks up UnitFactionPolyfill's hook on it, so UNIT_FACTION fires, and its change detection keeps that silent when the engine refuses the toggle. Declare the setter's newState as int, matching the polyfill's detour: a char argument defines only the low byte of EDX and would leave the detour's int parameter with undefined high bits. Also mirror the stock global into the namespace as C_Reputation.ToggleFactionAtWar, registering the engine's own handler rather than reimplementing it. Adds the getter and script-wrapper addresses, which existed only as comment references.