Skip to content

Commit 81da3ed

Browse files
committed
fix light positioning
1 parent ec61134 commit 81da3ed

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

source/light_drawer.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,13 @@ void LightDrawer::setGlobalLightColor(uint8_t color)
115115
global_color = colorFromEightBit(color);
116116
}
117117

118-
void LightDrawer::addLight(int map_x, int map_y, const SpriteLight& light)
118+
void LightDrawer::addLight(int map_x, int map_y, int map_z, const SpriteLight& light)
119119
{
120+
if (map_z <= GROUND_LAYER) {
121+
map_x -= (GROUND_LAYER - map_z);
122+
map_y -= (GROUND_LAYER - map_z);
123+
}
124+
120125
if (map_x <= 0 || map_x >= MAP_MAX_WIDTH || map_y <= 0 || map_y >= MAP_MAX_HEIGHT) {
121126
return;
122127
}

source/light_drawer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class LightDrawer
3737
void draw(int map_x, int map_y, int end_x, int end_y, int scroll_x, int scroll_y, bool fog);
3838

3939
void setGlobalLightColor(uint8_t color);
40-
void addLight(int map_x, int map_y, const SpriteLight& light);
40+
void addLight(int map_x, int map_y, int map_z, const SpriteLight& light);
4141
void clear() noexcept;
4242

4343
private:

source/map_drawer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,15 +1845,15 @@ void MapDrawer::AddLight(TileLocation* location)
18451845

18461846
if (tile->ground) {
18471847
if (tile->ground->hasLight()) {
1848-
light_drawer->addLight(position.x, position.y, tile->ground->getLight());
1848+
light_drawer->addLight(position.x, position.y, position.z, tile->ground->getLight());
18491849
}
18501850
}
18511851

18521852
bool hidden = options.hide_items_when_zoomed && zoom > 10.f;
18531853
if (!hidden && !tile->items.empty()) {
18541854
for (auto item : tile->items) {
18551855
if (item->hasLight()) {
1856-
light_drawer->addLight(position.x, position.y, item->getLight());
1856+
light_drawer->addLight(position.x, position.y, position.z, item->getLight());
18571857
}
18581858
}
18591859
}

0 commit comments

Comments
 (0)