14#define LOG_BUFFER_SIZE 1024
26typedef uint32_t (__thiscall *
XDataGet_ptr)(
void *_this,uint16_t key,uint8_t keyType);
49 delta = (uint32_t)(uint16_t)pointA->
X - (uint32_t)(uint16_t)pointB->
X;
50 uVar2 = (int)delta >> 0x1f;
51 uVar2 = (delta ^ uVar2) - uVar2;
52 uVar4 = uVar2 & 0xffff;
53 delta = (uint32_t)(uint16_t)pointA->
Y - (uint32_t)(uint16_t)pointB->
Y;
54 uVar3 = (int)delta >> 0x1f;
55 uVar3 = (delta ^ uVar3) - uVar3;
56 uVar1 = uVar3 & 0xffff;
58 if ((uint16_t)uVar2 < (uint16_t)uVar3)
63 return ((delta * 0xd) >> 5) + uVar4;
91void log_message(
const char *filename,
const char *format, ...)
95 va_start(args, format);
99 FILE *file = fopen(filename,
"a");
102 fprintf(file,
"%s\n", buffer);
111static void log_warning_v(
DebugLevel level,
const char *format, va_list args)
127 va_start(args, format);
135 va_start(args, format);
136 log_warning_v(level, format, args);
144 va_start(args, format);
157 va_start(args, format);
161 int lastError = GetLastError();
165 "[ERROR] %s [(Win32 SysErr) Last Error: %d]", buffer, lastError);
178 default:
return "ERR";
189 va_start(args, format);
211 if ((_this->
type == 10000) || (_this->
type == 10001))
231 iteratorAPI.figureIteratorInit(iterator, 0x0, 0x0, 0x3ff, 0x3ff);
237 return spellAPI.getSpellTags(spell_id) & tag;
242 if ((
buildingAPI.getBuildingTags(building_type) & tag) != 0)
362 uint16_t spell_index,
364 uint16_t source_index,
365 uint16_t spell_index),
367 uint16_t source_index,
368 uint16_t spell_index))
370 if (!condition || !callback)
377 uint16_t current_index =
380 if ((*condition)(_this, current_index, spell_index))
382 (*callback)(_this, source_index, current_index);
604 figureAPI.addBonusMult(statistic, value);
614 spellAPI.figClrChkSplBfrChkBattle(_this, spell_id, 0);
619 spellAPI.figTryClrCHkSPlBfrJob2(_this, spell_id);
624 spellAPI.figTryUnfreeze(_this, spell_id, 0);
664 while (spell_node != 0)
SpellFunctions * spellAPI
FigureFunctions * figureAPI
ToolboxFunctions * toolboxAPI
void console_log(const char *message)
IteratorFunctions iteratorAPI
BuildingFunctions buildingAPI
void log_error(const char *format,...)
bool __thiscall buildingIsForge(SF_CGdBuilding *_this, uint16_t building_index)
bool __thiscall buildingIsMoonsilverMine(SF_CGdBuilding *_this, uint16_t building_index)
uint32_t(__thiscall * CGdXDataExists_ptr)(void *_this, uint16_t key, uint8_t keyType)
bool __thiscall buildingIsShrine(SF_CGdBuilding *_this, uint16_t building_index)
void __thiscall addBonusMultToStatistic(SF_CGdFigure *figure, StatisticDataKey key, uint16_t target, int8_t value)
bool __thiscall buildingIsSawmill(SF_CGdBuilding *_this, uint16_t building_index)
uint32_t __thiscall getDistance(SF_Coord *pointA, SF_Coord *pointB)
bool __thiscall buildingIsHabitable(SF_CGdBuilding *_this, uint16_t building_index)
void log_message(const char *filename, const char *format,...)
bool __thiscall buildingIsGatherer(SF_CGdBuilding *_this, uint16_t building_index)
bool __thiscall buildingIsHunter(SF_CGdBuilding *_this, uint16_t building_index)
void log_warning_level(DebugLevel level, const char *format,...)
Logs a warning that is only shown once the log level reaches level.
bool __thiscall buildingIsScavenger(SF_CGdBuilding *_this, uint16_t building_index)
void log_warning(const char *format,...)
Logs a warning at DEBUG_INFO, i.e. always shown.
void __thiscall spellEffectCallback(SF_CGdSpell *_this, uint16_t source_index, uint16_t spell_index, bool(*condition)(SF_CGdSpell *_this, uint16_t source_index, uint16_t spell_index), void(*callback)(SF_CGdSpell *_this, uint16_t source_index, uint16_t spell_index))
bool __thiscall buildingIsFisher(SF_CGdBuilding *_this, uint16_t building_index)
bool __thiscall buildingIsWoodcutter(SF_CGdBuilding *_this, uint16_t building_index)
uint16_t __thiscall getCurrentStat(SF_CGdFigure *_this, uint16_t target, StatisticDataKey key)
bool __thiscall XDataExists(SF_CGdEffect *_this, uint16_t effect_index, SpellDataKey data)
bool __thiscall buildingIsIronMine(SF_CGdBuilding *_this, uint16_t building_index)
int8_t __thiscall addBonusMultExt(FigureStatisticExt *_this, int8_t value)
void __thiscall setupFigureIterator(CGdFigureIterator *iterator, SF_CGdSpell *spell)
bool __thiscall buildingIsHQ(SF_CGdBuilding *_this, uint16_t building_index)
uint16_t __thiscall getPhysDamageReduction(SF_CGdFigureToolbox *_this, uint16_t source_index, uint16_t target_index, uint16_t action_id)
bool __thiscall buildingIsHabitableSingle(SF_CGdBuilding *_this, uint16_t building_index)
bool __thiscall hasBuildingTag(uint8_t building_type, BuildingTag tag)
bool __thiscall isSiegeUnit(SF_CGdFigure *_this, uint16_t figure_index)
bool __thiscall buildingIsFoodstore(SF_CGdBuilding *_this, uint16_t building_index)
has_spell_effect_ptr has_spell_effect
bool __thiscall buildingIsStonecutter(SF_CGdBuilding *_this, uint16_t building_index)
bool __thiscall buildingIsTemple(SF_CGdBuilding *_this, uint16_t building_index)
CGdXDataExists_ptr CGdXDataExists
void log_debug(DebugLevel level, const char *format,...)
bool __thiscall hasSpellTag(uint16_t spell_id, SpellTag tag)
const char * debug_level_to_string(DebugLevel level)
bool __thiscall hasAuraActive(SF_CGdFigureToolbox *_this, uint16_t figure_id)
SF_String_ctor_ptr g_create_sf_string
void __thiscall spellClearFigureFlag(SF_CGdSpell *_this, uint16_t spell_id, SpellFlagKey key)
void __thiscall tryClearCheckSpellsBeforeJob(SF_CGdSpell *_this, uint16_t spell_index, uint16_t figure_index)
bool __thiscall buildingIsQuarry(SF_CGdBuilding *_this, uint16_t building_index)
uint16_t __thiscall getMaxStat(SF_CGdFigure *_this, uint16_t target, StatisticDataKey key)
void __thiscall disposeFigureIterator(CGdFigureIterator *iterator)
FUN_0069eaf0_ptr FUN_0069eaf0
bool __thiscall buildingIsTower(SF_CGdBuilding *_this, uint16_t building_index)
void initialize_wrapper_data_hooks()
SF_String_dtor_ptr g_destroy_sf_string
uint16_t __thiscall sf_get_spell_id(SF_CGdSpell *_this, uint16_t spell_index)
void log_info(const char *format,...)
get_phys_damage_reduction_ptr g_get_damage_reduction
bool __thiscall isActionMelee(SF_SGtFigureAction *_this)
bool __thiscall buildingIsMaceCarver(SF_CGdBuilding *_this, uint16_t building_index)
uint32_t(__thiscall * XDataGet_ptr)(void *_this, uint16_t key, uint8_t keyType)
bool __thiscall buildingIsSmelter(SF_CGdBuilding *_this, uint16_t building_index)
uint32_t __thiscall getBuildingXData(SF_CGdBuildingToolbox *_this, uint16_t building_index, uint8_t key_type)
int AddrOf(int offset)
returns "real" virtual address of given memory offset
@ HABITABLE_SINGLE_BUILDING
void(* fidfree_ptr)(uint32_t *memory_ptr)
@ CHECK_SPELLS_BEFORE_JOB2
@ CHECK_SPELLS_BEFORE_CHECK_BATTLE
@ F_CHECK_SPELLS_BEFORE_JOB
uint32_t(__thiscall * FUN_0069eaf0_ptr)(void *ac69, void *ac69_2, void *ac69_3, void *ac69_4)
uint16_t __thiscall get_figure_statistic_current_black_res(SF_CGdFigure *_this, uint16_t figure_id)
uint16_t __thiscall get_figure_statistic_max_mp(SF_CGdFigure *_this, uint16_t figure_id)
uint16_t __thiscall get_figure_statistic_current_fire_res(SF_CGdFigure *_this, uint16_t figure_id)
uint16_t __thiscall get_figure_statistic_current_wis(SF_CGdFigure *_this, uint16_t figure_id)
uint16_t __thiscall get_figure_statistic_current_agi(SF_CGdFigure *_this, uint16_t figure_id)
uint16_t __thiscall get_figure_statistic_current_dex(SF_CGdFigure *_this, uint16_t figure_id)
uint16_t __thiscall get_figure_statistic_current_int(SF_CGdFigure *_this, uint16_t figure_id)
uint16_t __thiscall get_figure_statistic_current_hp(SF_CGdFigure *_this, uint16_t figure_id)
uint16_t __thiscall get_figure_statistic_current_fight_spd(SF_CGdFigure *_this, uint16_t figure_id)
uint16_t __thiscall get_figure_statistic_max_sta(SF_CGdFigure *_this, uint16_t figure_id)
uint16_t __thiscall get_figure_statistic_current_mp(SF_CGdFigure *_this, uint16_t figure_id)
uint16_t __thiscall get_figure_statistic_current_mental_res(SF_CGdFigure *_this, uint16_t figure_id)
uint16_t __thiscall get_figure_statistic_current_cha(SF_CGdFigure *_this, uint16_t figure_id)
uint16_t __thiscall get_figure_statistic_current_walk_spd(SF_CGdFigure *_this, uint16_t figure_id)
uint16_t __thiscall get_figure_statistic_current_cast_spd(SF_CGdFigure *_this, uint16_t figure_id)
uint16_t __thiscall get_figure_statistic_current_str(SF_CGdFigure *_this, uint16_t figure_id)
uint16_t __thiscall get_figure_statistic_max_hp(SF_CGdFigure *_this, uint16_t figure_id)
uint16_t __thiscall get_figure_statistic_current_ac(SF_CGdFigure *_this, uint16_t figure_id)
uint16_t __thiscall get_figure_statistic_current_sta(SF_CGdFigure *_this, uint16_t figure_id)
uint16_t __thiscall get_figure_statistic_current_ice_res(SF_CGdFigure *_this, uint16_t figure_id)
bool(__thiscall * has_spell_effect_ptr)(SF_CGdFigureToolbox *_this, uint16_t param_1, uint16_t param_2)
SF_String *(__thiscall * SF_String_ctor_ptr)(SF_String *, const char *)
void(__thiscall * SF_String_dtor_ptr)(SF_String *)
DebugLevel global_debug_level
uint16_t(__thiscall * get_phys_damage_reduction_ptr)(void *AutoClass34, uint16_t source_index, uint16_t target_index, uint16_t unkn)
GdBuilding buildings[1000]
SF_GdEffect effects[2000]
void * SF_CGdDoubleLinkedList
SF_CGdFigure * SF_CGdFigure
SF_CGdWorld * SF_CGdWorld
SF_GdSpell active_spell_list[800]