forked from mifki/df-twbt
-
Notifications
You must be signed in to change notification settings - Fork 4
/
units.hpp
53 lines (41 loc) · 2.31 KB
/
units.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "df/unit.h"
struct unit_hook : public df::unit
{
typedef df::unit interpose_base;
DEFINE_VMETHOD_INTERPOSE(uint8_t, getCreatureTile, ())
{
renderer_cool *r = (renderer_cool*)enabler->renderer;
df::coord _pos = Units::getPosition(this);
if (pos.x-mwindow_x >= 0 && pos.y-gwindow_y >= 0 && pos.x-mwindow_x < r->gdimx && pos.y-gwindow_y < r->gdimy)
// if (!((uint32_t*)screen_under_ptr)[(_pos.x-mwindow_x)*r->gdimy + _pos.y-gwindow_y])
((uint32_t*)screen_under_ptr)[(_pos.x-mwindow_x)*r->gdimy + _pos.y-gwindow_y] = ((uint32_t*)screen_ptr)[(_pos.x-mwindow_x)*r->gdimy + _pos.y-gwindow_y];
return INTERPOSE_NEXT(getCreatureTile)();
}
DEFINE_VMETHOD_INTERPOSE(uint8_t, getCorpseTile, ())
{
renderer_cool *r = (renderer_cool*)enabler->renderer;
df::coord _pos = Units::getPosition(this);
if (pos.x-mwindow_x >= 0 && pos.y-gwindow_y >= 0 && pos.x-mwindow_x < r->gdimx && pos.y-gwindow_y < r->gdimy)
// if (!((uint32_t*)screen_under_ptr)[(_pos.x-mwindow_x)*r->gdimy + _pos.y-gwindow_y])
((uint32_t*)screen_under_ptr)[(_pos.x-mwindow_x)*r->gdimy + _pos.y-gwindow_y] = ((uint32_t*)screen_ptr)[(_pos.x-mwindow_x)*r->gdimy + _pos.y-gwindow_y];
return INTERPOSE_NEXT(getCorpseTile)();
}
DEFINE_VMETHOD_INTERPOSE(uint8_t, getGlowTile, ())
{
renderer_cool *r = (renderer_cool*)enabler->renderer;
df::coord _pos = Units::getPosition(this);
if (pos.x-mwindow_x >= 0 && pos.y-gwindow_y >= 0 && pos.x-mwindow_x < r->gdimx && pos.y-gwindow_y < r->gdimy)
// if (!((uint32_t*)screen_under_ptr)[(_pos.x-mwindow_x)*r->gdimy + _pos.y-gwindow_y])
((uint32_t*)screen_under_ptr)[(_pos.x-mwindow_x)*r->gdimy + _pos.y-gwindow_y] = ((uint32_t*)screen_ptr)[(_pos.x-mwindow_x)*r->gdimy + _pos.y-gwindow_y];
return INTERPOSE_NEXT(getGlowTile)();
}
};
IMPLEMENT_VMETHOD_INTERPOSE(unit_hook, getCreatureTile);
IMPLEMENT_VMETHOD_INTERPOSE(unit_hook, getCorpseTile);
IMPLEMENT_VMETHOD_INTERPOSE(unit_hook, getGlowTile);
void enable_unit_hooks()
{
INTERPOSE_HOOK(unit_hook, getCreatureTile).apply(unit_transparency);
INTERPOSE_HOOK(unit_hook, getCorpseTile).apply(unit_transparency);
INTERPOSE_HOOK(unit_hook, getGlowTile).apply(unit_transparency);
}