Spellforce-Spell-framework
Loading...
Searching...
No Matches
sf_wrappers.c
Go to the documentation of this file.
1#include <windows.h>
2#include <stdio.h>
3#include <stdlib.h>
4#include <string.h>
5
6#include "sf_wrappers.h"
7#include "sf_hooks.h"
8
13
14#define LOG_BUFFER_SIZE 1024
15
25
26typedef uint32_t (__thiscall *XDataGet_ptr)(void *_this,uint16_t key,uint8_t keyType);
27typedef uint32_t (__thiscall *CGdXDataExists_ptr)(void *_this, uint16_t key, uint8_t keyType);
28
34
37
39
40//checky thiscall but not really. ~muddykat (fix this later add support for non thiscalls)
41uint32_t __thiscall getDistance(SF_Coord *pointA, SF_Coord *pointB)
42{
43 uint32_t delta;
44 uint32_t uVar1;
45 uint32_t uVar2;
46 uint32_t uVar3;
47 uint32_t uVar4;
48
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;
57 delta = uVar1;
58 if ((uint16_t)uVar2 < (uint16_t)uVar3)
59 {
60 delta = uVar4;
61 uVar4 = uVar1;
62 }
63 return ((delta * 0xd) >> 5) + uVar4;
64}
65
66bool __thiscall isSiegeUnit (SF_CGdFigure *_this, uint16_t figure_index)
67{
68 if ((_this->figures[figure_index].unit_data_id == 2236) ||
69 (_this->figures[figure_index].unit_data_id == 2238) ||
70 (_this->figures[figure_index].unit_data_id == 2239) ||
71 (_this->figures[figure_index].unit_data_id == 2244) ||
72 (_this->figures[figure_index].unit_data_id == 2245) ||
73 (_this->figures[figure_index].unit_data_id == 2249) )
74 {
75 return true;
76 }
77 return false;
78}
79
90
91void log_message(const char *filename, const char *format, ...)
92{
93 char buffer[LOG_BUFFER_SIZE];
94 va_list args;
95 va_start(args, format);
96 vsnprintf(buffer, LOG_BUFFER_SIZE, format, args);
97 va_end(args);
98
99 FILE *file = fopen(filename, "a");
100 if (file != NULL)
101 {
102 fprintf(file, "%s\n", buffer);
103 fclose(file);
104 }
105}
106
111static void log_warning_v(DebugLevel level, const char *format, va_list args)
112{
113 if (level > global_debug_level)
114 return;
115
116 char buffer[LOG_BUFFER_SIZE];
117 vsnprintf(buffer, LOG_BUFFER_SIZE, format, args);
118
119 char modifiedMessage[LOG_BUFFER_SIZE];
120 snprintf(modifiedMessage, LOG_BUFFER_SIZE, "[WARNING] %s", buffer);
121 console_log(modifiedMessage);
122}
123
124void log_warning(const char *format, ...)
125{
126 va_list args;
127 va_start(args, format);
128 log_warning_v(DEBUG_INFO, format, args);
129 va_end(args);
130}
131
132void log_warning_level(DebugLevel level, const char *format, ...)
133{
134 va_list args;
135 va_start(args, format);
136 log_warning_v(level, format, args);
137 va_end(args);
138}
139
140void log_info(const char *format, ...)
141{
142 char buffer[LOG_BUFFER_SIZE];
143 va_list args;
144 va_start(args, format);
145 vsnprintf(buffer, LOG_BUFFER_SIZE, format, args);
146 va_end(args);
147
148 char modifiedMessage[LOG_BUFFER_SIZE];
149 snprintf(modifiedMessage, LOG_BUFFER_SIZE, "[INFO] %s", buffer);
150 console_log(modifiedMessage);
151}
152
153void log_error(const char *format, ...)
154{
155 char buffer[LOG_BUFFER_SIZE];
156 va_list args;
157 va_start(args, format);
158 vsnprintf(buffer, LOG_BUFFER_SIZE, format, args);
159 va_end(args);
160
161 int lastError = GetLastError();
162
163 char modifiedMessage[LOG_BUFFER_SIZE];
164 snprintf(modifiedMessage, LOG_BUFFER_SIZE,
165 "[ERROR] %s [(Win32 SysErr) Last Error: %d]", buffer, lastError);
166 console_log(modifiedMessage);
167}
168
170{
171 switch (level)
172 {
173 case DEBUG_INFO: return "INFO";
174 case DEBUG_LOW: return "LOW";
175 case DEBUG_MED: return "MED";
176 case DEBUG_HIGH: return "HIGH";
177 case DEBUG_ALL: return "ALL";
178 default: return "ERR";
179 }
180}
181
182void log_debug(DebugLevel level, const char *format, ...)
183{
184 if (level > global_debug_level)
185 return;
186
187 char buffer[LOG_BUFFER_SIZE];
188 va_list args;
189 va_start(args, format);
190 vsnprintf(buffer, LOG_BUFFER_SIZE, format, args);
191 va_end(args);
192
193 char modifiedMessage[LOG_BUFFER_SIZE];
194 snprintf(modifiedMessage, LOG_BUFFER_SIZE, "[DEBUG %s] %s", debug_level_to_string(level), buffer);
195 console_log(modifiedMessage);
196}
197
200{
201 sf_logger.logError = &log_error;
202 sf_logger.logInfo = &log_info;
203 sf_logger.logWarning = &log_warning;
204 sf_logger.logDebug = &log_debug;
205 return &sf_logger;
206}
207
208// TODO: Parse me through an as an ActionAPI Wrapped Function
209bool __thiscall isActionMelee(SF_SGtFigureAction *_this)
210{
211 if ((_this->type == 10000) || (_this->type == 10001))
212 {
213 return 1;
214 }
215 return 0;
216}
217
218uint32_t __thiscall getBuildingXData(SF_CGdBuildingToolbox *_this, uint16_t building_index, uint8_t key_type)
219{
220 uint16_t key = _this->CGdBuilding->buildings[building_index].xdata_key;
221 if (key!=0)
222 {
223 return XDataGet(_this->CGdXDataList, key, key_type);
224 }
225 return 0;
226}
227
228void __thiscall setupFigureIterator(CGdFigureIterator *iterator,
229 SF_CGdSpell *spell)
230{
231 iteratorAPI.figureIteratorInit(iterator, 0x0, 0x0, 0x3ff, 0x3ff);
232 iteratorAPI.figureIteratorSetPointers(iterator, spell->SF_CGdFigure, spell->SF_CGdTile, spell->SF_CGdWorld);
233}
234
235bool __thiscall hasSpellTag(uint16_t spell_id, SpellTag tag)
236{
237 return spellAPI.getSpellTags(spell_id) & tag;
238}
239
240bool __thiscall hasBuildingTag(uint8_t building_type, BuildingTag tag)
241{
242 if ((buildingAPI.getBuildingTags(building_type) & tag) != 0)
243 {
244 return 1;
245 }
246 return 0;
247}
248
249bool __thiscall buildingIsScavenger(SF_CGdBuilding *_this, uint16_t building_index)
250{
251 return buildingAPI.hasBuildingTag(_this->buildings[building_index].type, BuildingTag::SCAVENGER_BUILDING);
252}
253
254bool __thiscall buildingIsHabitable(SF_CGdBuilding *_this, uint16_t building_index)
255{
256 return buildingAPI.hasBuildingTag(_this->buildings[building_index].type, BuildingTag::HABITABLE_BUILDING);
257}
258
259bool __thiscall buildingIsHabitableSingle(SF_CGdBuilding *_this, uint16_t building_index)
260{
261 return buildingAPI.hasBuildingTag(_this->buildings[building_index].type, BuildingTag::HABITABLE_SINGLE_BUILDING);
262}
263
264bool __thiscall buildingIsFisher(SF_CGdBuilding *_this, uint16_t building_index)
265{
266 return buildingAPI.hasBuildingTag(_this->buildings[building_index].type, BuildingTag::FISHER_BUILDING);
267}
268
269bool __thiscall buildingIsFoodstore(SF_CGdBuilding *_this, uint16_t building_index)
270{
271 return buildingAPI.hasBuildingTag(_this->buildings[building_index].type, BuildingTag::FOODSTORE_BUILDING);
272}
273
274bool __thiscall buildingIsForge(SF_CGdBuilding *_this, uint16_t building_index)
275{
276 return buildingAPI.hasBuildingTag(_this->buildings[building_index].type, BuildingTag::FORGE_BUILDING);
277}
278
279bool __thiscall buildingIsGatherer(SF_CGdBuilding *_this, uint16_t building_index)
280{
281 return buildingAPI.hasBuildingTag(_this->buildings[building_index].type, BuildingTag::GATHERER_BUILDING);
282}
283
284bool __thiscall buildingIsHQ(SF_CGdBuilding *_this, uint16_t building_index)
285{
286 return buildingAPI.hasBuildingTag(_this->buildings[building_index].type, BuildingTag::HQ_BUILDING);
287}
288
289bool __thiscall buildingIsHunter(SF_CGdBuilding *_this, uint16_t building_index)
290{
291 return buildingAPI.hasBuildingTag(_this->buildings[building_index].type, BuildingTag::HUNTER_BUILDING);
292}
293
294bool __thiscall buildingIsIronMine(SF_CGdBuilding *_this, uint16_t building_index)
295{
296 return (buildingAPI.hasBuildingTag(_this->buildings[building_index].type, BuildingTag::MINER_BUILDING)
297 && !buildingAPI.hasBuildingTag(_this->buildings[building_index].type, BuildingTag::MOONSILVER_BUILDING));
298}
299
300bool __thiscall buildingIsMaceCarver(SF_CGdBuilding *_this, uint16_t building_index)
301{
302 return buildingAPI.hasBuildingTag(_this->buildings[building_index].type, BuildingTag::MACE_CARVER_BUILDING);
303}
304
305bool __thiscall buildingIsMoonsilverMine(SF_CGdBuilding *_this, uint16_t building_index)
306{
307 return (buildingAPI.hasBuildingTag(_this->buildings[building_index].type, BuildingTag::MINER_BUILDING)
308 && buildingAPI.hasBuildingTag(_this->buildings[building_index].type, BuildingTag::MOONSILVER_BUILDING));
309}
310
311bool __thiscall buildingIsQuarry(SF_CGdBuilding *_this, uint16_t building_index)
312{
313 return buildingAPI.hasBuildingTag(_this->buildings[building_index].type, BuildingTag::QUARRY_BUILDING);
314}
315
316bool __thiscall buildingIsSawmill(SF_CGdBuilding *_this, uint16_t building_index)
317{
318 return buildingAPI.hasBuildingTag(_this->buildings[building_index].type, BuildingTag::SAWMILL_BUILDING);
319}
320
321bool __thiscall buildingIsSmelter(SF_CGdBuilding *_this, uint16_t building_index)
322{
323 return buildingAPI.hasBuildingTag(_this->buildings[building_index].type, BuildingTag::SMELTER_BUILDING);
324}
325
326bool __thiscall buildingIsStonecutter(SF_CGdBuilding *_this, uint16_t building_index)
327{
328 return buildingAPI.hasBuildingTag(_this->buildings[building_index].type, BuildingTag::STONEMASON_BUILDING);
329}
330
331bool __thiscall buildingIsTemple(SF_CGdBuilding *_this, uint16_t building_index)
332{
333 return buildingAPI.hasBuildingTag(_this->buildings[building_index].type, BuildingTag::TEMPLE_BUILDING);
334}
335
336bool __thiscall buildingIsTower(SF_CGdBuilding *_this, uint16_t building_index)
337{
338 return buildingAPI.hasBuildingTag(_this->buildings[building_index].type, BuildingTag::TOWER_BUILDING);
339}
340
341bool __thiscall buildingIsWoodcutter(SF_CGdBuilding *_this, uint16_t building_index)
342{
343 return buildingAPI.hasBuildingTag(_this->buildings[building_index].type, BuildingTag::WOODCUTTER_BUILDING);
344}
345
346bool __thiscall buildingIsShrine(SF_CGdBuilding *_this, uint16_t building_index)
347{
348 return buildingAPI.hasBuildingTag(_this->buildings[building_index].type, BuildingTag::SHRINE_BUILDING);
349}
350
351// Some funky stuff to clean up Iterator memory, not 100% sure if correct
352void __thiscall disposeFigureIterator(CGdFigureIterator *iterator)
353{
354 uint32_t unused;
355 FUN_0069eaf0(&(iterator->data.offset_0x30), &unused,
356 ((AutoClass69 *)iterator->data.offset_0x30.ac69_ptr1)->
357 ac69_ptr1, iterator->data.offset_0x30.ac69_ptr1);
359}
360
361void __thiscall spellEffectCallback(SF_CGdSpell *_this, uint16_t source_index,
362 uint16_t spell_index,
363 bool (*condition)(SF_CGdSpell *_this,
364 uint16_t source_index,
365 uint16_t spell_index),
366 void (*callback)(SF_CGdSpell *_this,
367 uint16_t source_index,
368 uint16_t spell_index))
369{
370 if (!condition || !callback)
371 return;
372
373 uint16_t node_id = figureAPI.getSpellJobStartNode(_this->SF_CGdFigure,
374 source_index);
375 while (node_id != 0)
376 {
377 uint16_t current_index =
378 toolboxAPI.getSpellIndexFromDLL(
379 (uint32_t *)_this->SF_CGdDoubleLinkedList, node_id);
380 if ((*condition)(_this, current_index, spell_index))
381 {
382 (*callback)(_this, source_index, current_index);
383 break;
384 }
385 node_id =
386 toolboxAPI.getNextNode((uint32_t *)_this->SF_CGdDoubleLinkedList,
387 node_id);
388 }
389}
390
391
392int8_t __thiscall addBonusMultExt (FigureStatisticExt *_this, int8_t value)
393{
394 if (value < 0)
395 {
396 if ((int)(_this->bonus_multiplier) + (int)value < -127)
397 {
398 _this->bonus_multiplier = 128;
399 return _this->bonus_multiplier;
400 }
401 _this->bonus_multiplier += value;
402 return _this->bonus_multiplier;
403 }
404 if ((int)_this->bonus_multiplier + (int)value > 126)
405 {
406 _this->bonus_multiplier = 127;
407 return _this->bonus_multiplier;
408 }
409 _this->bonus_multiplier += value;
410 return _this->bonus_multiplier;
411}
412
413
414uint16_t __thiscall getCurrentStat(SF_CGdFigure *_this, uint16_t target, StatisticDataKey key)
415{
416 switch (key)
417 {
418 case ARMOR:
419 {
420 return get_figure_statistic_current_ac(_this, target);
421 }
422 case AGILITY:
423 {
424 return get_figure_statistic_current_agi(_this, target);
425 }
426 case CHARISMA:
427 {
428 return get_figure_statistic_current_cha(_this, target);
429 }
430 case DEXTERITY:
431 {
432 return get_figure_statistic_current_dex(_this, target);
433 }
434 case INTELLIGENCE:
435 {
436 return get_figure_statistic_current_int(_this, target);
437 }
438 case STRENGTH:
439 {
440 return get_figure_statistic_current_str(_this, target);
441 }
442 case STAMINA:
443 {
444 return get_figure_statistic_current_sta(_this, target);
445 }
446 case MANA:
447 {
448 return get_figure_statistic_current_mp(_this, target);
449 }
450 case HEALTH:
451 {
452 return get_figure_statistic_current_hp(_this, target);
453 }
454 case WISDOM:
455 {
456 return get_figure_statistic_current_wis(_this, target);
457 }
458 case RESISTANCE_FIRE:
459 {
460 return get_figure_statistic_current_fire_res(_this, target);
461 }
462 case RESISTANCE_ICE:
463 {
464 return get_figure_statistic_current_ice_res(_this, target);
465 }
467 {
468 return get_figure_statistic_current_mental_res(_this, target);
469 }
470 case RESISTANCE_BLACK:
471 {
472 return get_figure_statistic_current_black_res(_this, target);
473 }
474 case WALK_SPEED:
475 {
476 return get_figure_statistic_current_walk_spd(_this, target);
477 }
478 case FIGHT_SPEED:
479 {
480 return get_figure_statistic_current_fight_spd(_this, target);
481 }
482 case CAST_SPEED:
483 {
484 return get_figure_statistic_current_cast_spd(_this, target);
485 }
486 default:
487 {
488 return 0;
489 }
490 }
491}
492
493
494uint16_t __thiscall getMaxStat(SF_CGdFigure *_this, uint16_t target, StatisticDataKey key)
495{
496 switch (key)
497 {
498 case ARMOR:
499 {
500 return get_figure_statistic_current_ac(_this, target);
501 }
502 case AGILITY:
503 {
504 return get_figure_statistic_current_agi(_this, target);
505 }
506 case CHARISMA:
507 {
508 return get_figure_statistic_current_cha(_this, target);
509 }
510 case DEXTERITY:
511 {
512 return get_figure_statistic_current_dex(_this, target);
513 }
514 case INTELLIGENCE:
515 {
516 return get_figure_statistic_current_int(_this, target);
517 }
518 case STRENGTH:
519 {
520 return get_figure_statistic_current_str(_this, target);
521 }
522 case STAMINA:
523 {
524 return get_figure_statistic_max_sta(_this, target);
525 }
526 case MANA:
527 {
528 return get_figure_statistic_max_mp(_this, target);
529 }
530 case HEALTH:
531 {
532 return get_figure_statistic_max_hp(_this, target);
533 }
534 case WISDOM:
535 {
536 return get_figure_statistic_current_wis(_this, target);
537 }
538 case RESISTANCE_FIRE:
539 {
540 return get_figure_statistic_current_fire_res(_this, target);
541 }
542 case RESISTANCE_ICE:
543 {
544 return get_figure_statistic_current_ice_res(_this, target);
545 }
547 {
548 return get_figure_statistic_current_mental_res(_this, target);
549 }
550 case RESISTANCE_BLACK:
551 {
552 return get_figure_statistic_current_black_res(_this, target);
553 }
554 case WALK_SPEED:
555 {
556 return get_figure_statistic_current_walk_spd(_this, target);
557 }
558 case FIGHT_SPEED:
559 {
560 return get_figure_statistic_current_fight_spd(_this, target);
561 }
562 case CAST_SPEED:
563 {
564 return get_figure_statistic_current_cast_spd(_this, target);
565 }
566 default:
567 {
568 return 0;
569 }
570 }
571}
572
573void __thiscall addBonusMultToStatistic(SF_CGdFigure *figure,
574 StatisticDataKey key, uint16_t target,
575 int8_t value)
576{
577 FigureStatistic *statistic = NULL;
578 switch (key)
579 {
580 case STAMINA: addBonusMultExt(&figure->figures[target].stamina, value); return;
581 case MANA: addBonusMultExt(&figure->figures[target].mana, value); return;
582 case HEALTH: addBonusMultExt(&figure->figures[target].health, value); return;
583
584 case ARMOR: statistic = &figure->figures[target].armor; break;
585 case AGILITY: statistic = &figure->figures[target].agility; break;
586 case CHARISMA: statistic = &figure->figures[target].charisma; break;
587 case DEXTERITY: statistic = &figure->figures[target].dexterity; break;
588 case INTELLIGENCE: statistic = &figure->figures[target].intelligence; break;
589 case STRENGTH: statistic = &figure->figures[target].strength; break;
590 case WISDOM: statistic = &figure->figures[target].wisdom; break;
591 case RESISTANCE_FIRE: statistic = &figure->figures[target].resistance_fire; break;
592 case RESISTANCE_ICE: statistic = &figure->figures[target].resistance_ice; break;
593 case RESISTANCE_MENTAL: statistic = &figure->figures[target].resistance_mental; break;
594 case RESISTANCE_BLACK: statistic = &figure->figures[target].resistance_black; break;
595 case WALK_SPEED: statistic = &figure->figures[target].walk_speed; break;
596 case FIGHT_SPEED: statistic = &figure->figures[target].fight_speed; break;
597 case CAST_SPEED: statistic = &figure->figures[target].cast_speed; break;
598
599 default:
600 log_warning("INVALID STATISTIC KEY: %d", key);
601 return;
602 }
603
604 figureAPI.addBonusMult(statistic, value);
605}
606
607void __thiscall spellClearFigureFlag(SF_CGdSpell *_this, uint16_t spell_id,
608 SpellFlagKey key)
609{
610 switch (key)
611 {
613 {
614 spellAPI.figClrChkSplBfrChkBattle(_this, spell_id, 0);
615 break;
616 }
618 {
619 spellAPI.figTryClrCHkSPlBfrJob2(_this, spell_id);
620 break;
621 }
622 case UNFREEZE:
623 {
624 spellAPI.figTryUnfreeze(_this, spell_id, 0);
625 break;
626 }
627 }
628}
629
630bool __thiscall hasAuraActive(SF_CGdFigureToolbox *_this, uint16_t figure_id)
631{
632 return has_spell_effect(_this, figure_id, 0x49);
633}
634
635uint16_t __thiscall getPhysDamageReduction(SF_CGdFigureToolbox *_this, uint16_t source_index, uint16_t target_index,
636 uint16_t action_id)
637{
638 return g_get_damage_reduction(_this->autoclass34, source_index, target_index, action_id);
639}
640
641bool __thiscall XDataExists(SF_CGdEffect *_this, uint16_t effect_index, SpellDataKey data)
642{
643 uint16_t xdata_key = _this->effects[effect_index].xdata_key;
644 if (xdata_key != 0)
645 {
646 uint32_t result = CGdXDataExists(_this->SF_CGdXDataList, xdata_key, data);
647 if (result != 0)
648 {
649 return 1;
650 }
651 }
652 return 0;
653}
654
655uint16_t __thiscall sf_get_spell_id(SF_CGdSpell *_this, uint16_t spell_index)
656{
657 return _this->active_spell_list[spell_index].spell_id;
658}
659
660
661void __thiscall tryClearCheckSpellsBeforeJob(SF_CGdSpell *_this, uint16_t spell_index, uint16_t figure_index)
662{
663 uint16_t spell_node = figureAPI.getSpellJobStartNode(_this->SF_CGdFigure, figure_index);
664 while (spell_node != 0)
665 {
666 uint16_t spell_id = toolboxAPI.getSpellIndexFromDLL(_this->SF_CGdDoubleLinkedList, spell_node);
667 if ((spell_index != spell_id) && ((_this->active_spell_list[spell_id].flags & 0x2) != 0))
668 {
669 return;
670 }
671 spell_node = toolboxAPI.getNextNode(_this->SF_CGdDoubleLinkedList, spell_node);
672 }
673 _this->SF_CGdFigure->figures[figure_index].flags &= ~(F_CHECK_SPELLS_BEFORE_JOB);
674
675}
SpellFunctions * spellAPI
Definition TestMod.cpp:11
FigureFunctions * figureAPI
Definition TestMod.cpp:13
ToolboxFunctions * toolboxAPI
Definition TestMod.cpp:12
void console_log(const char *message)
IteratorFunctions iteratorAPI
Definition sf_hooks.c:49
BuildingFunctions buildingAPI
Definition sf_hooks.c:47
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)
Definition sf_wrappers.c:27
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)
Definition sf_wrappers.c:41
bool __thiscall buildingIsHabitable(SF_CGdBuilding *_this, uint16_t building_index)
void log_message(const char *filename, const char *format,...)
Definition sf_wrappers.c:91
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)
SFLog sf_logger
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)
Definition sf_wrappers.c:66
bool __thiscall buildingIsFoodstore(SF_CGdBuilding *_this, uint16_t building_index)
has_spell_effect_ptr has_spell_effect
Definition sf_wrappers.c:31
bool __thiscall buildingIsStonecutter(SF_CGdBuilding *_this, uint16_t building_index)
bool __thiscall buildingIsTemple(SF_CGdBuilding *_this, uint16_t building_index)
CGdXDataExists_ptr CGdXDataExists
Definition sf_wrappers.c:36
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
Definition sf_wrappers.c:29
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)
fidfree_ptr fidFree
Definition sf_wrappers.c:33
FUN_0069eaf0_ptr FUN_0069eaf0
Definition sf_wrappers.c:32
bool __thiscall buildingIsTower(SF_CGdBuilding *_this, uint16_t building_index)
SFLog * setup_logger()
void initialize_wrapper_data_hooks()
Definition sf_wrappers.c:80
SF_String_dtor_ptr g_destroy_sf_string
Definition sf_wrappers.c:30
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
Definition sf_wrappers.c:38
bool __thiscall isActionMelee(SF_SGtFigureAction *_this)
XDataGet_ptr XDataGet
Definition sf_wrappers.c:35
bool __thiscall buildingIsMaceCarver(SF_CGdBuilding *_this, uint16_t building_index)
uint32_t(__thiscall * XDataGet_ptr)(void *_this, uint16_t key, uint8_t keyType)
Definition sf_wrappers.c:26
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
Definition sf_asi.h:135
@ SMELTER_BUILDING
@ MOONSILVER_BUILDING
@ HUNTER_BUILDING
@ MACE_CARVER_BUILDING
@ HABITABLE_SINGLE_BUILDING
@ WOODCUTTER_BUILDING
@ SHRINE_BUILDING
@ SCAVENGER_BUILDING
@ FOODSTORE_BUILDING
@ GATHERER_BUILDING
@ QUARRY_BUILDING
@ HABITABLE_BUILDING
@ TEMPLE_BUILDING
@ STONEMASON_BUILDING
@ FISHER_BUILDING
@ SAWMILL_BUILDING
@ RESISTANCE_FIRE
@ RESISTANCE_MENTAL
@ RESISTANCE_BLACK
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)
#define LOG_BUFFER_SIZE
Definition sf_wrappers.c:14
bool(__thiscall * has_spell_effect_ptr)(SF_CGdFigureToolbox *_this, uint16_t param_1, uint16_t param_2)
Definition sf_wrappers.h:15
SF_String *(__thiscall * SF_String_ctor_ptr)(SF_String *, const char *)
Definition sf_wrappers.h:13
void(__thiscall * SF_String_dtor_ptr)(SF_String *)
Definition sf_wrappers.h:14
DebugLevel global_debug_level
Definition sfsf.cpp:18
uint16_t(__thiscall * get_phys_damage_reduction_ptr)(void *AutoClass34, uint16_t source_index, uint16_t target_index, uint16_t unkn)
Definition sf_wrappers.h:95
CGdTileIterator_data data
FigureStatisticExt stamina
FigureStatistic strength
FigureStatistic dexterity
FigureStatistic resistance_mental
FigureStatistic charisma
FigureStatistic resistance_fire
FigureStatistic cast_speed
FigureStatisticExt health
FigureStatistic wisdom
uint16_t unit_data_id
FigureStatisticExt mana
FigureStatistic fight_speed
FigureStatistic resistance_ice
FigureStatistic agility
FigureStatistic resistance_black
FigureStatistic walk_speed
FigureStatistic armor
FigureStatistic intelligence
GdBuilding buildings[1000]
SF_GdEffect effects[2000]
A structure for the global list of figures and related statistics for them.
GdFigure figures[2000]
void * SF_CGdDoubleLinkedList
SF_CGdFigure * SF_CGdFigure
SF_CGdWorld * SF_CGdWorld
SF_GdSpell active_spell_list[800]