Spellforce-Spell-framework
Loading...
Searching...
No Matches
sf_ai_single_target_registry.cpp
Go to the documentation of this file.
2
3static std::map<uint16_t, ai_single_handler_ptr> s_ai_single_target_handler_map;
4
5void registerAiSingleTargetHandler(uint16_t spell_line,
7{
8 auto check = s_ai_single_target_handler_map.find(spell_line);
9 if (check != s_ai_single_target_handler_map.end())
10 {
11 log_debug(DEBUG_HIGH, "%s (v%s) has replaced a single target AI Handler [%d] (Was this on purpose?)",
12 g_current_mod->mod_id, g_current_mod->mod_version, spell_line);
13 }
14
15 s_ai_single_target_handler_map[spell_line] = handler;
16}
17
19{
20 auto it = s_ai_single_target_handler_map.find(spell_line);
21 if (it == s_ai_single_target_handler_map.end())
22 {
23 // Element doesn't exist, insert the default value
24 log_debug(DEBUG_HIGH, "%s Unknown spell line [%d], for ai single target handler, Assigning a default handler",
25 g_current_mod->mod_id, spell_line);
26 it = s_ai_single_target_handler_map.emplace(spell_line, &default_support_ai_handler).first;
27 }
28 return it->second;
29}
void log_debug(DebugLevel level, const char *format,...)
ai_single_handler_ptr get_single_ai_handler(uint16_t spell_line)
void registerAiSingleTargetHandler(uint16_t spell_line, ai_single_handler_ptr handler)
uint32_t __thiscall default_support_ai_handler(SF_CGdBattleDevelopment *_this, uint16_t target_index, uint16_t spell_line, SF_CGdResourceSpell *spell_data)
SFMod * g_current_mod
uint32_t(__thiscall * ai_single_handler_ptr)(SF_CGdBattleDevelopment *_this, uint16_t target_index, uint16_t spell_line, SF_CGdResourceSpell *spell_data)