Spellforce-Spell-framework
Loading...
Searching...
No Matches
sf_building_entry_hook.c
Go to the documentation of this file.
3
4typedef void (__thiscall *fun006c3ca0_ptr)(void *autoclass30, uint16_t param_1, uint16_t owner,
5 SF_CGdTargetData *source, SF_CGdTargetData *target);
6
8
9bool isBuildingDamaged(SF_CGdBuilding *_this, uint16_t building_id)
10{
11 return (_this->buildings[building_id].health_current != _this->buildings[building_id].life_current_max);
12}
14
15void __thiscall job_start_working_at_building_hook (SF_CGdFigureJobs *_this, uint16_t figure_id)
16{
17 uint16_t building_id = _this->CGdFigure->figures[figure_id].building;
18 if (((_this->CGdBuilding->buildings[building_id].flags & 0x1) == 0) ||
19 (isBuildingDamaged(_this->CGdBuilding, building_id) &&
20 (_this->CGdFigure->figures[figure_id].current_job.flags & 0x4000) == 0))
21 {
22 building_repair(_this,figure_id, building_id);
23 return;
24 }
25 _this->CGdFigure->figures[figure_id].current_job.flags &= ~(0x4000);
26 uint16_t owner = _this->CGdFigure->figures[figure_id].owner;
27 SF_CGdTargetData source = {0, 0, {0, 0}};
28 SF_CGdTargetData target;
29 target.entity_index = figure_id;
30 target.entity_type = 1;
31 target.position = {0, 0};
32 fun006c3ca0(_this->AutoClass30, 0x24, owner, &source, &target);
33 uint8_t building_type = _this->CGdBuilding->buildings[building_id].type;
35 handler(_this, figure_id, building_id);
36}
BuildingFunctions buildingAPI
Definition sf_hooks.c:47
fun006c3ca0_ptr fun006c3ca0
void(__thiscall * fun006c3ca0_ptr)(void *autoclass30, uint16_t param_1, uint16_t owner, SF_CGdTargetData *source, SF_CGdTargetData *target)
void __thiscall job_start_working_at_building_hook(SF_CGdFigureJobs *_this, uint16_t figure_id)
fun006c3ca0_ptr fun006c3ca0
bool isBuildingDamaged(SF_CGdBuilding *_this, uint16_t building_id)
building_entry_handler_ptr get_building_entry_handler(uint8_t building_type)
void(__thiscall * building_entry_handler_ptr)(SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
void __thiscall building_repair(SF_CGdFigureJobs *_this, uint16_t figure_id, uint16_t building_id)
FigureJobData current_job
GdBuilding buildings[1000]
GdFigure figures[2000]
SF_CGdBuilding * CGdBuilding