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,
15 refresh_handler_ptr handler)
16{
17 auto check = s_spellrefresh_handler_map.find(spell_line_id);
18 if (check != s_spellrefresh_handler_map.end())
19 {
20 char message[256];
21 sprintf(message,
22 "%s (v%s) has replaced an Spell Refresh Handler [%d] (Was this on purpose?)",
24 spell_line_id);
25 log_warning(message);
26 }
27
28 s_spellrefresh_handler_map[spell_line_id] = handler;
29}
30
32{
33 auto it = s_spellrefresh_handler_map.find(spell_line_id);
34 if (it == s_spellrefresh_handler_map.end())
35 {
36 char message[256];
37 sprintf(message, "Unknown Spell Line ID [%d] for Spell Refresh Handler",
38 spell_line_id);
39 log_warning(message);
40 it = s_spellrefresh_handler_map.emplace(spell_line_id,
42 first;
43 }
44 return it->second;
45}
46
48{
49 // Vanilla spell refresh handlers
50 int firstblock_cases[] = {
51 0x06,
52 0x0c,
53 0x0f,
54 0x15,
55 0x19,
56 0x20,
57 0x24,
58 0x29,
59 0x2f,
60 0x38,
61 0x48,
62 0x4f,
63 0x8c,
64 0x95,
65 0x99,
66 0x9c,
67 0x9d,
68 0x9e,
69 0xa1,
70 0xa4,
71 0xa7,
72 0xbd,
73 0xd5,
74 0xdd,
75 0xde,
76 };
77
78 int vanilla_domination_cases[] = {0x2e, 0x6c, 0x78, 0x7a, 0xc5, 0xed};
79
80 for (int i = 0; i < sizeof(firstblock_cases) / sizeof(firstblock_cases[0]);
81 i++)
82 {
83 registerSpellRefreshHandler(firstblock_cases[i],
85 }
86
96 registerSpellRefreshHandler(0x63, &suffocation_refresh_handler); // 99 and 100 in ghidra switch case respectivly
110 registerSpellRefreshHandler(0xc7, &mutation_refresh_handler); // 199 in ghidra switch case
113
116
119
122
124
125 for (int i = 0;
126 i <
127 sizeof(vanilla_domination_cases) / sizeof(vanilla_domination_cases[0]);
128 i++)
129 {
130 registerSpellRefreshHandler(vanilla_domination_cases[i],
132 }
133
135}
void log_warning(const char *message)
Definition sf_wrappers.c:81
SFMod * g_current_mod
int(__thiscall * refresh_handler_ptr)(SF_CGdSpell *, uint16_t)
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)
char mod_id[64]
char mod_version[24]