Spellforce-Spell-framework
Toggle main menu visibility
Loading...
Searching...
No Matches
sf_phys_effect_registry.cpp
Go to the documentation of this file.
1
#include "
sf_phys_effect_registry.h
"
2
#include "
../../core/sf_modloader.h
"
3
4
#include <map>
5
6
static
std::map<uint16_t, sub_effect_handler_ptr> s_rain_handlers_map;
7
static
std::map<uint16_t, phys_effect_handler_ptr> s_phys_effect_handlers_map;
8
9
10
void
__thiscall
default_rain_handler
(
SF_CGdEffect
*_this, uint16_t effect_index)
11
{
12
return
;
13
}
14
15
uint16_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
21
void
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
33
void
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
45
sub_effect_handler_ptr
get_rain_handler
(uint16_t spell_line_id)
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
56
phys_effect_handler_ptr
get_phys_effect_handler
(uint16_t spell_line_id)
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
}
log_warning
void log_warning(const char *format,...)
Logs a warning at DEBUG_INFO, i.e. always shown.
Definition
sf_wrappers.c:124
sub_effect_handler_ptr
void(__thiscall * sub_effect_handler_ptr)(SF_CGdEffect *, uint16_t effect_index)
Definition
sf_effect_functions.h:13
sf_modloader.h
g_current_mod
SFMod * g_current_mod
Definition
sf_registry.cpp:45
get_rain_handler
sub_effect_handler_ptr get_rain_handler(uint16_t spell_line_id)
Definition
sf_phys_effect_registry.cpp:45
registerPhysRainHandler
void registerPhysRainHandler(uint16_t spell_line_id, sub_effect_handler_ptr handler)
Definition
sf_phys_effect_registry.cpp:21
default_phys_effect_handler
uint16_t __thiscall default_phys_effect_handler(SF_CGdEffect *_this, uint16_t source, uint16_t target, bool *isSpellDamage, uint16_t damage)
Definition
sf_phys_effect_registry.cpp:15
default_rain_handler
void __thiscall default_rain_handler(SF_CGdEffect *_this, uint16_t effect_index)
Definition
sf_phys_effect_registry.cpp:10
registerPhysEffectHandler
void registerPhysEffectHandler(uint16_t spell_line_id, phys_effect_handler_ptr handler)
Definition
sf_phys_effect_registry.cpp:33
get_phys_effect_handler
phys_effect_handler_ptr get_phys_effect_handler(uint16_t spell_line_id)
Definition
sf_phys_effect_registry.cpp:56
sf_phys_effect_registry.h
phys_effect_handler_ptr
uint16_t(__thiscall * phys_effect_handler_ptr)(SF_CGdEffect *_this, uint16_t source, uint16_t target, bool *isSpellDamage, uint16_t damage)
Definition
sf_registration_structures.h:20
SF_CGdEffect
Definition
sf_effect_structures.h:22
src
internal
registry
spell_data_registries
sf_phys_effect_registry.cpp
Generated by
1.17.0