Spellforce-Spell-framework
Loading...
Searching...
No Matches
sf_phys_effect_registry.cpp
Go to the documentation of this file.
3
4#include <map>
5
6static std::map<uint16_t, sub_effect_handler_ptr> s_rain_handlers_map;
7static std::map<uint16_t, phys_effect_handler_ptr> s_phys_effect_handlers_map;
8
9
10void __thiscall default_rain_handler(SF_CGdEffect *_this, uint16_t effect_index)
11{
12 return;
13}
14
15uint16_t __thiscall default_phys_effect_handler (SF_CGdEffect *_this, uint16_t source, uint16_t target,
16 bool *isSpellDamage, uint16_t damage)
17{
18 return damage;
19}
20
21void registerPhysRainHandler(uint16_t spell_line_id, sub_effect_handler_ptr handler)
22{
23 auto check = s_rain_handlers_map.find(spell_line_id);
24 if (check != s_rain_handlers_map.end())
25 {
26 log_warning("%s (v%s) has replaced a Phys Rain Handler [%d] (Was this on purpose?)",
27 g_current_mod->mod_id, g_current_mod->mod_version, spell_line_id);
28 }
29
30 s_rain_handlers_map[spell_line_id] = handler;
31}
32
33void registerPhysEffectHandler(uint16_t spell_line_id, phys_effect_handler_ptr handler)
34{
35 auto check = s_phys_effect_handlers_map.find(spell_line_id);
36 if (check != s_phys_effect_handlers_map.end())
37 {
38 log_warning("%s (v%s) has replaced a Phys Effect Handler [%d] (Was this on purpose?)",
39 g_current_mod->mod_id, g_current_mod->mod_version, spell_line_id);
40 }
41 s_phys_effect_handlers_map[spell_line_id] = handler;
42}
43
44
46{
47 auto it = s_rain_handlers_map.find(spell_line_id);
48 if (it == s_rain_handlers_map.end())
49 {
50 log_warning("Unknown Spell Line ID [%d] for Phys Rain Handler", spell_line_id);
51 it = s_rain_handlers_map.emplace(spell_line_id, &default_rain_handler).first;
52 }
53 return it->second;
54}
55
57{
58 auto it = s_phys_effect_handlers_map.find(spell_line_id);
59 if (it == s_phys_effect_handlers_map.end())
60 {
61 log_warning("Unknown Spell Line ID [%d] for Phys Effect Handler", spell_line_id);
62 it = s_phys_effect_handlers_map.emplace(spell_line_id, &default_phys_effect_handler).first;
63 }
64 return it->second;
65}
void log_warning(const char *format,...)
Logs a warning at DEBUG_INFO, i.e. always shown.
void(__thiscall * sub_effect_handler_ptr)(SF_CGdEffect *, uint16_t effect_index)
SFMod * g_current_mod
sub_effect_handler_ptr get_rain_handler(uint16_t spell_line_id)
void registerPhysRainHandler(uint16_t spell_line_id, sub_effect_handler_ptr handler)
uint16_t __thiscall default_phys_effect_handler(SF_CGdEffect *_this, uint16_t source, uint16_t target, bool *isSpellDamage, uint16_t damage)
void __thiscall default_rain_handler(SF_CGdEffect *_this, uint16_t effect_index)
void registerPhysEffectHandler(uint16_t spell_line_id, phys_effect_handler_ptr handler)
phys_effect_handler_ptr get_phys_effect_handler(uint16_t spell_line_id)
uint16_t(__thiscall * phys_effect_handler_ptr)(SF_CGdEffect *_this, uint16_t source, uint16_t target, bool *isSpellDamage, uint16_t damage)