Skip to content

Commit 1983589

Browse files
committed
Fix uint32_t getting set to -1
1 parent 3800286 commit 1983589

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

plugins/building-hacks.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,26 @@
2323
#include "modules/Buildings.h"
2424

2525
#include <map>
26-
26+
#include <limits>
2727
using namespace DFHack;
2828
using namespace df::enums;
2929

3030
DFHACK_PLUGIN("building-hacks");
3131
REQUIRE_GLOBAL(world);
3232

33+
constexpr uint32_t invalid_tile = std::numeric_limits<uint32_t>::max();
3334
struct graphic_tile //could do just 31x31 and be done, but it's nicer to have flexible imho.
3435
{
3536
int16_t tile=-1; //originally uint8_t but we need to indicate non-animated tiles
3637
int8_t fore;
3738
int8_t back;
3839
int8_t bright;
3940
//index of texpos
40-
uint32_t graphics_tile = -1;
41-
uint32_t overlay_tile = -1;
42-
uint32_t item_tile = -1;
41+
uint32_t graphics_tile = invalid_tile;
42+
uint32_t overlay_tile = invalid_tile;
43+
uint32_t item_tile = invalid_tile;
4344
//only for first line
44-
uint32_t signpost_tile = -1;
45+
uint32_t signpost_tile = invalid_tile;
4546
};
4647
struct workshop_hack_data
4748
{
@@ -304,14 +305,14 @@ struct work_hook : df::building_workshopst{
304305
db->bright[tx][ty]= cf.bright;
305306
db->fore[tx][ty]= cf.fore;
306307
}
307-
if (cf.graphics_tile != -1)
308+
if (cf.graphics_tile != invalid_tile)
308309
db->building_one_texpos[tx][ty] = cf.graphics_tile;
309-
if (cf.overlay_tile != -1)
310+
if (cf.overlay_tile != invalid_tile)
310311
db->building_two_texpos[tx][ty] = cf.overlay_tile;
311-
if (cf.item_tile != -1)
312+
if (cf.item_tile != invalid_tile)
312313
db->item_texpos[tx][ty] = cf.item_tile;
313314
//only first line has signpost graphics
314-
if (cf.item_tile != -1 && ty==0)
315+
if (cf.item_tile != invalid_tile && ty==0)
315316
db->signpost_texpos[tx] = cf.signpost_tile;
316317
}
317318
}

0 commit comments

Comments
 (0)