Spellforce-Spell-framework
Loading...
Searching...
No Matches
sf_building_entry_registry.cpp
Go to the documentation of this file.
3#include <cstdint>
4#include <map>
5#include <list>
6#include <utility>
7
8static std::map<uint8_t, building_entry_handler_ptr> s_bulding_entry_map;
9
10void registerBuildingEntryHandler(uint8_t building_type,
12{
13 auto check = s_bulding_entry_map.find(building_type);
14 if (check != s_bulding_entry_map.end())
15 {
16 log_warning("%s (v%s) has replaced a Building Entry Handler [%d] (Was this on purpose?)",
17 g_current_mod->mod_id, g_current_mod->mod_version, building_type);
18 }
19
20 s_bulding_entry_map[building_type] = handler;
21}
22
24{
25 auto it = s_bulding_entry_map.find(building_type);
26 if (it == s_bulding_entry_map.end())
27 {
28 // Element doesn't exist, insert the default value
29 log_warning("Unknown buidling type [%d] for done handler, Assigning a default handler.", building_type);
30 it = s_bulding_entry_map.emplace(building_type, &default_entry_handler).first;
31 }
32 return it->second;
33}
void log_warning(const char *format,...)
Logs a warning at DEBUG_INFO, i.e. always shown.
building_entry_handler_ptr get_building_entry_handler(uint8_t building_type)
void registerBuildingEntryHandler(uint8_t building_type, building_entry_handler_ptr handler)
SFMod * g_current_mod
void(__thiscall * building_entry_handler_ptr)(SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
void __thiscall default_entry_handler(SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)