Spellforce-Spell-framework
Loading...
Searching...
No Matches
sf_spellrefresh_registry.cpp
Go to the documentation of this file.
5
8#include "../sf_registry.h"
9#include <map>
10#include <cstdio>
11
12static std::map<uint16_t, refresh_handler_ptr> s_spellrefresh_handler_map;
13
14void registerSpellRefreshHandler(uint16_t spell_line_id, refresh_handler_ptr handler)
15{
16 auto check = s_spellrefresh_handler_map.find(spell_line_id);
17 if (check != s_spellrefresh_handler_map.end())
18 {
19 log_debug(DEBUG_HIGH, "%s (v%s) has replaced an Spell Refresh Handler [%d] (Was this on purpose?)",
20 g_current_mod->mod_id, g_current_mod->mod_version, spell_line_id);
21 }
22 s_spellrefresh_handler_map[spell_line_id] = handler;
23}
24
26{
27 auto it = s_spellrefresh_handler_map.find(spell_line_id);
28 if (it == s_spellrefresh_handler_map.end())
29 {
30 log_debug(DEBUG_HIGH, "Unknown Spell Line ID [%d] for Spell Refresh Handler", spell_line_id);
31 it = s_spellrefresh_handler_map.emplace(spell_line_id, &first_block_refresh_handler).first;
32 }
33 return it->second;
34}
35
37{
38 // Vanilla spell refresh handlers
39 int firstblock_cases[] = {
40 0x06,
41 0x0c,
42 0x0f,
43 0x15,
44 0x19,
45 0x20,
46 0x24,
47 0x29,
48 0x2f,
49 0x38,
50 0x48,
51 0x4f,
52 0x8c,
53 0x95,
54 0x99,
55 0x9c,
56 0x9d,
57 0x9e,
58 0xa1,
59 0xa4,
60 0xa7,
61 0xbd,
62 0xd5,
63 0xdd,
64 0xde,
65 };
66
67 int vanilla_domination_cases[] = {0x2e, 0x6c, 0x78, 0x7a, 0xc5, 0xed};
68
69 for (uint32_t i = 0; i < sizeof(firstblock_cases) / sizeof(firstblock_cases[0]); i++)
70 {
72 }
73
83 registerSpellRefreshHandler(0x63, &suffocation_refresh_handler); // 99 and 100 in ghidra switch case respectivly
97 registerSpellRefreshHandler(0xc7, &mutation_refresh_handler); // 199 in ghidra switch case
100
103
106
109
111
112 for (uint32_t i = 0; i < sizeof(vanilla_domination_cases) / sizeof(vanilla_domination_cases[0]); i++)
113 {
114 registerSpellRefreshHandler(vanilla_domination_cases[i],
116 }
117
119}
void log_debug(DebugLevel level, const char *format,...)
SFMod * g_current_mod
int __thiscall endurance_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall case_da_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall domination_spell_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall black_almightness_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall enlightenment_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall dexterity_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall mutation_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall fast_fighting_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall quickness_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall flexibility_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall melt_resistance_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall inflexibility_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall warcry_berserk_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall first_block_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall slowness_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall strength_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall suffocation_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall charisma_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall endurance_durability_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall brilliance_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall eternity_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall white_almightness_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall chill_resistance_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall patronize_shelter_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall weaken_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall slow_fighting_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall decay_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall pestilence_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall inablility_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
void register_vanilla_spell_refresh_handlers()
void registerSpellRefreshHandler(uint16_t spell_line_id, refresh_handler_ptr handler)
refresh_handler_ptr get_spell_refresh(uint16_t spell_line_id)
int(__thiscall * refresh_handler_ptr)(SF_CGdSpell *, uint16_t)
Definition sfsf.h:31