179 if (entry->spell_id == spell_line_id)
181 return entry->spell_tags;
191 if (entry->building_id == building_type)
193 return entry->building_tags;
203 if (entry->race == race)
207 return entry->building_id;
218 if (entry->race == race)
222 return entry->building_id;
233 if (entry->race == race)
237 return entry->building_id;
248 if (entry->race == race)
252 return entry->building_id;
263 if (entry->race == race)
267 return entry->building_id;
278 if (entry->race == race)
283 return entry->building_id;
293 if (entry->race == race)
297 return entry->building_id;
334 uint8_t spell_count_for_mod = 0;
337 uint16_t spell_id = spell_data->spell_id;
338 uint16_t spell_effect_id = spell_data->spell_effect_id;
339 handler_ptr spell_type_handler = spell_data->spell_type_handler;
340 handler_ptr spell_effect_handler = spell_data->spell_effect_handler;
341 handler_ptr spell_end_handler = spell_data->spell_end_handler;
353 OnHitPhase onhit_phase = spell_data->hit_phase;
354 SFMod *parent_mod = spell_data->parent_mod;
359 if (spell_count_for_mod != 0)
361 char spell_count_info[256];
362 snprintf(spell_count_info,
sizeof(spell_count_info),
363 "| - Finished Registration of %d spells for %s",
364 spell_count_for_mod, temp->
mod_id);
366 spell_count_for_mod = 0;
370 snprintf(info,
sizeof(info),
371 "| - Starting Registration for [%s by %s]",
378 spell_count_for_mod = spell_count_for_mod + 1;
385 if (spell_effect_id != 0x00)
388 0xa6,
"Spell Effect ID");
392 if (spell_type_handler !=
nullptr)
397 if (spell_effect_handler !=
nullptr)
402 if (spell_refresh_handler !=
nullptr)
407 if (spell_end_handler !=
nullptr)
412 if (sub_effect_handler !=
nullptr)
417 if (onhit_handler !=
nullptr)
422 if (deal_damage_handler !=
nullptr)
428 if(ai_single_handler !=
nullptr)
433 if(ai_aoe_handler !=
nullptr)
438 if(ai_avoidance_handler !=
nullptr)
442 if (phys_rain_handler !=
nullptr)
446 if (phys_effect_handler !=
nullptr)
450 if (enchant_handler !=
nullptr)
456 if (spell_count_for_mod != 0)
458 char spell_count_info[256];
459 snprintf(spell_count_info,
sizeof(spell_count_info),
460 "| - Finished Registration of %d spells for %s",
461 spell_count_for_mod, temp->
mod_id);
463 spell_count_for_mod = 0;
473 return (value * 140) / 0x10000;
494 for (
int i = 0; i<list_len; i++)
503 uint32_t *offset = list->
first;
504 offset[index*2] = (posX * 0x10000) / 140;
505 offset[index*2+1] = (posY * 0x10000) / 140;
532 bd.race = building->
race;
537 bd.name_id = building->
name_id;
538 bd.health = building->
health;
541 bd.flags = building->
flags;
552 for(
int k = 0; k < point_count; k++)
570 log_info(
"%s has successfully registered the [%s] building to the game using ID [%u]",
g_current_mod->mod_id,
576 if (!strncmp(
"wood",resource_name, 5))
580 if (!strncmp(
"stone",resource_name, 6))
584 if (!strncmp(
"moonsilver",resource_name, 11))
588 if (!strncmp(
"food",resource_name, 5))
592 if (!strncmp(
"iron",resource_name, 5))
596 if (!strncmp(
"aria",resource_name, 5))
600 if (!strncmp(
"lenya",resource_name, 5))
610 int building_count_for_mod = 0;
614 SFMod *parent_mod = building_data->parent_mod;
619 if (building_count_for_mod > 0)
622 snprintf(log_line,
sizeof(log_line),
"| - Finished Registration of %d buildings for %s",
623 building_count_for_mod, temp->
mod_id);
625 building_count_for_mod = 0;
629 snprintf(info,
sizeof(info),
"| - Starting Registration for [%s by %s]",
636 building_count_for_mod++;
640 if (strlen(building_data->building_json_name) != 0)
645 log_error(
"Building JSON structure invalid: %s", building_data->building_json_name);
649 building_data->race = parsed_building.
race;
650 building_data->can_enter = parsed_building.
can_enter;
651 building_data->slot_count = parsed_building.
slot_count;
653 building_data->worker_cycle = 0;
654 building_data->name_id = parsed_building.
name_id;
655 building_data->health = parsed_building.
health;
656 building_data->ext_description_id = parsed_building.
description_id;
657 building_data->initial_angle = 0;
658 building_data->flags = parsed_building.
flags;
659 building_data->centerX = parsed_building.
center_x;
660 building_data->centerY = parsed_building.
center_y;
667 if (building_data->resource_req_type[i] != 0)
669 building_data->resource_req_amount[i] = parsed_building.
resources[i].
amount;
673 building_data->resource_req_amount[i] = 0;
685 0xd1,
"Building ID");
687 if (building_data->done_handler !=
nullptr)
691 if (building_data->entry_handler !=
nullptr)
bool claim_numeric_id(ConflictDomain domain, uint32_t id, SFMod *mod, uint32_t vanilla_max, const char *id_label)
Claims a numeric ID within a domain for a mod.
@ CONFLICT_SPELL_EFFECT_ID
void log_error(const char *format,...)
void log_debug(DebugLevel level, const char *format,...)
void log_info(const char *format,...)
int AddrOf(int offset)
returns "real" virtual address of given memory offset
void registerAiAOEHandler(uint16_t spell_line, ai_aoe_handler_ptr handler)
void registerAiAvoidanceHandler(uint16_t spell_line, ai_avoidance_handler_ptr handler)
void registerAiSingleTargetHandler(uint16_t spell_line, ai_single_handler_ptr handler)
void registerBuildingDoneHandler(uint8_t building_type, building_done_handler_ptr handler)
void registerBuildingEntryHandler(uint8_t building_type, building_entry_handler_ptr handler)
bool parse_building_json_entrypoint(const char *building_json_name, const char *mod_id, Building *out_building)
void(__thiscall * addBuildingAuxData_ptr)(void *_this, BuildingAuxEntry_related *entry, uint8_t *building_id)
void(__thiscall * addBuilding_ptr)(void *_this, void *struct1, void *struct2)
void(__thiscall * setCollisionListSize_ptr)(uint_list_node *_this, uint8_t list_size)
void(__thiscall * sub_effect_handler_ptr)(SF_CGdEffect *, uint16_t effect_index)
void registerEnchantHandler(uint16_t spell_line, enchant_handler_ptr handler)
void addCollisionEntry(uint_list_node *list, int32_t posX, int32_t posY, int8_t index)
void __thiscall linkAOEAIHandler(SFSpell *spell, ai_aoe_handler_ptr handler)
void __thiscall linkEndHandler(SFSpell *spell, handler_ptr endHandler)
SFBuilding *__thiscall registerBuilding(uint8_t building_type)
uint8_t __thiscall getRacialIronMine(uint8_t race)
void __thiscall linkDealDamageHandler(SFSpell *spell, damage_handler_ptr handler, SpellDamagePhase phase)
uint8_t __thiscall getRacialWoodcutter(uint8_t race)
void dumpAuxEntry(BuildingAuxEntry_related *entry)
void __thiscall applySpellTag(SFSpell *spell, SpellTag tag)
uint8_t __thiscall getRacialStonecutter(uint8_t race)
void register_mod_buildings()
void __thiscall applyBuildingTag(SFBuilding *building, BuildingTag tag)
uint32_t __thiscall getBuildingTags(uint8_t building_type)
void __thiscall linkTypeHandler(SFSpell *spell, handler_ptr typeHandler)
int32_t recalcCoord(int32_t value)
void __thiscall linkEnchantChanceHandler(SFSpell *spell, enchant_handler_ptr handler)
void __thiscall linkOnHitHandler(SFSpell *spell, onhit_handler_ptr onhitHandler, OnHitPhase phase)
void __thiscall linkPhysEffectHandler(SFSpell *spell, phys_effect_handler_ptr handler)
std::list< SFBuilding * > g_internal_building_list
void __thiscall linkRefreshHandler(SFSpell *spell, refresh_handler_ptr handler)
uint8_t __thiscall getRacialFoodstore(uint8_t race)
std::list< SFSpell * > g_internal_spell_list
void __thiscall linkEffectHandler(SFSpell *spell, uint16_t spell_effect_id, handler_ptr effectHandler)
void __thiscall linkSingleTargetAIHandler(SFSpell *spell, ai_single_handler_ptr handler)
void __thiscall linkBuildingJSON(SFBuilding *building, const char *building_json_name)
setCollisionListSize_ptr setListSize
uint8_t __thiscall getRacialQuarry(uint8_t race)
uint8_t get_resource_id(const char *resource_name)
void register_mod_spells()
Registers the mod spells and performs basic conflict checking.
void __thiscall linkAvoidanceAIHandler(SFSpell *spell, ai_avoidance_handler_ptr handler)
void register_building_to_game(SFBuilding *building, const Building *src)
addBuildingAuxData_ptr AddAuxData
void __thiscall linkBuildingDoneHandler(SFBuilding *building, building_done_handler_ptr handler)
void __thiscall linkPhysRainHandler(SFSpell *spell, sub_effect_handler_ptr handler)
uint8_t __thiscall getRacialSawmill(uint8_t race)
void __thiscall linkSubEffectHandler(SFSpell *spell, sub_effect_handler_ptr handler)
SFSpell *__thiscall registerSpell(uint16_t spell_id)
uint8_t __thiscall getRacialSmelter(uint8_t race)
void __thiscall linkBuildingEntryHandler(SFBuilding *building, building_entry_handler_ptr handler)
addBuilding_ptr AddBuilding
uint16_t __thiscall getSpellTags(uint16_t spell_line_id)
void registerOnHitHandler(uint16_t spell_line_id, onhit_handler_ptr handler, OnHitPhase phase)
void registerPhysRainHandler(uint16_t spell_line_id, sub_effect_handler_ptr handler)
void registerPhysEffectHandler(uint16_t spell_line_id, phys_effect_handler_ptr handler)
void(__thiscall * building_done_handler_ptr)(SF_CGdBuildingToolbox *_this, uint16_t building_index)
uint16_t(__thiscall * phys_effect_handler_ptr)(SF_CGdEffect *_this, uint16_t source, uint16_t target, bool *isSpellDamage, uint16_t damage)
uint16_t(__thiscall * damage_handler_ptr)(SF_CGdFigureToolbox *_toolbox, uint16_t source, uint16_t target, uint16_t current_damage, uint16_t is_spell_damage, uint32_t is_ranged_damage, uint16_t spell_id)
uint32_t(__thiscall * ai_single_handler_ptr)(SF_CGdBattleDevelopment *_this, uint16_t target_index, uint16_t spell_line, SF_CGdResourceSpell *spell_data)
uint32_t(__thiscall * ai_aoe_handler_ptr)(SF_CGdBattleDevelopment *_this, SF_Coord *position, uint16_t spell_line, SF_CGdResourceSpell *spell_data)
void(__thiscall * building_entry_handler_ptr)(SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
uint16_t(__thiscall * enchant_handler_ptr)(SF_CGdFigure *_this, uint16_t figure_id)
uint32_t(__thiscall * ai_avoidance_handler_ptr)(CGdAIBattleData *_this, uint16_t figure_index, uint16_t spell_line)
uint16_t(__thiscall * onhit_handler_ptr)(SF_CGdFigureJobs *, uint16_t source, uint16_t target, uint16_t damage)
void registerSpellDamageHandler(uint16_t spell_line_id, damage_handler_ptr handler, SpellDamagePhase phase)
void registerEffectHandler(uint16_t spell_job, handler_ptr handler)
void registerSpellEndHandler(uint16_t spell_line, handler_ptr handler)
void registerSpellRefreshHandler(uint16_t spell_line_id, refresh_handler_ptr handler)
void registerSpellTypeHandler(uint16_t spell_index, handler_ptr handler)
void registerSubEffectHandler(uint16_t spell_line, sub_effect_handler_ptr handler)
int(__thiscall * refresh_handler_ptr)(SF_CGdSpell *, uint16_t)
void(__thiscall * handler_ptr)(SF_CGdSpell *, uint16_t)
uint8_t resource_req_type[5]
uint16_t resource_req_amount[5]
uint_list_node collisions[5]
char building_json_name[64]
building_done_handler_ptr done_handler
uint8_t building_required
building_entry_handler_ptr entry_handler
uint8_t resource_req_type[5]
uint16_t ext_description_id
uint16_t resource_req_amount[5]
enchant_handler_ptr spell_enchtant_handler
handler_ptr spell_effect_handler
ai_avoidance_handler_ptr ai_avoidance_handler
damage_handler_ptr deal_damage_handler
sub_effect_handler_ptr phys_rain_handler
ai_single_handler_ptr ai_single_handler
SpellDamagePhase damage_phase
refresh_handler_ptr spell_refresh_handler
handler_ptr spell_end_handler
sub_effect_handler_ptr sub_effect_handler
onhit_handler_ptr spell_onhit_handler
ai_aoe_handler_ptr ai_aoe_handler
handler_ptr spell_type_handler
phys_effect_handler_ptr phys_effect_handler
BuildingResource building