support multi-type and non-rectangular stockpiles

and add integration tests
develop
myk002 2021-10-02 12:30:08 -07:00 committed by Myk
parent 06916280f4
commit 12eb9e48c7
5 changed files with 71 additions and 20 deletions

@ -0,0 +1,12 @@
#dig label(dig)
d,d,d,d,d,d,d,d,d,d,d,d
d,d,d,d,d,d,d,d,d,d,d,d
d,d,d,d,d,d,d,d,d,d,d,d
d,d,d,d,d,d,d,d,d,d,d,d
d,d,d,d,d,d,d,d,d,d,d,d
d,d,d,d,d,d,d,d,d,d,d,d
d,d,d,d,d,d,d,d,d,d,d,d
d,d,d,d,d,d,d,d,d,d,d,d
d,d,d,d,d,d,d,d,d,d,d,d
d,d,d,d,d,d,d,d,d,d,d,d
d,d,d,d,d,d,d,d,d,d,d,d
1 #dig label(dig)
2 d,d,d,d,d,d,d,d,d,d,d,d
3 d,d,d,d,d,d,d,d,d,d,d,d
4 d,d,d,d,d,d,d,d,d,d,d,d
5 d,d,d,d,d,d,d,d,d,d,d,d
6 d,d,d,d,d,d,d,d,d,d,d,d
7 d,d,d,d,d,d,d,d,d,d,d,d
8 d,d,d,d,d,d,d,d,d,d,d,d
9 d,d,d,d,d,d,d,d,d,d,d,d
10 d,d,d,d,d,d,d,d,d,d,d,d
11 d,d,d,d,d,d,d,d,d,d,d,d
12 d,d,d,d,d,d,d,d,d,d,d,d

@ -0,0 +1,12 @@
#place label(place)
a(2x2),,f(2x2),,u(2x2),,n(2x2),,y(2x2),,r(2x2)
s(2x2),,w(2x2),,e(2x2),,b(2x2),,h(2x2),,l(2x2)
z(2x2),,S(2x2),,g(2x2),,p(2x2),,d(2x2),,afunyrswebhlzSgpd(2x2)
a,a,g,g,a,,,g,l,w,s,a
a,,,g,a,a,g,g,w,w,s,a
u,u,u,,,,,,s,s,s,a
u,z,u,,,,,,a,a,a,a
u,u,u
1 #place label(place)
2 a(2x2),,f(2x2),,u(2x2),,n(2x2),,y(2x2),,r(2x2)
3 s(2x2),,w(2x2),,e(2x2),,b(2x2),,h(2x2),,l(2x2)
4 z(2x2),,S(2x2),,g(2x2),,p(2x2),,d(2x2),,afunyrswebhlzSgpd(2x2)
5 a,a,g,g,a,,,g,l,w,s,a
6 a,,,g,a,a,g,g,w,w,s,a
7 u,u,u,,,,,,s,s,s,a
8 u,z,u,,,,,,a,a,a,a
9 u,u,u

@ -0,0 +1,4 @@
#notes
description=all the stockpiles, including multi-type
width=12
height=11
1 #notes
2 description=all the stockpiles, including multi-type
3 width=12
4 height=11

@ -1,4 +1,4 @@
#place label(place) #place label(place)
,f(1x1),,f(1x1) ,f,,f

1 #place label(place)
2 ,f(1x1),,f(1x1) ,f,,f
3
4

@ -189,6 +189,19 @@ static const char * if_pretty(const tile_context &ctx, const char *c) {
return ctx.pretty ? c : NULL; return ctx.pretty ? c : NULL;
} }
static bool is_rectangular(const tile_context &ctx) {
df::building_extents &room = ctx.b->room;
if (!room.extents)
return true;
for (int32_t y = 0; y < room.height; ++y) {
for (int32_t x = 0; x < room.width; ++x) {
if (!room.extents[y * room.width + x])
return false;
}
}
return true;
}
static const char * do_block_building(const tile_context &ctx, const char *s, static const char * do_block_building(const tile_context &ctx, const char *s,
bool at_target_pos, bool at_target_pos,
bool *add_size = NULL) { bool *add_size = NULL) {
@ -586,26 +599,33 @@ static const char * get_place_keys(const tile_context &ctx) {
return NULL; return NULL;
} }
switch (sp->settings.flags.whole) { string keys;
case df::stockpile_group_set::mask_animals: return "a"; df::stockpile_group_set &flags = sp->settings.flags;
case df::stockpile_group_set::mask_food: return "f"; if (flags.bits.animals) keys += 'a';
case df::stockpile_group_set::mask_furniture: return "u"; if (flags.bits.food) keys += 'f';
case df::stockpile_group_set::mask_corpses: return "y"; if (flags.bits.furniture) keys += 'u';
case df::stockpile_group_set::mask_refuse: return "r"; if (flags.bits.coins) keys += 'n';
case df::stockpile_group_set::mask_wood: return "w"; if (flags.bits.corpses) keys += 'y';
case df::stockpile_group_set::mask_stone: return "s"; if (flags.bits.refuse) keys += 'r';
case df::stockpile_group_set::mask_gems: return "e"; if (flags.bits.stone) keys += 's';
case df::stockpile_group_set::mask_bars_blocks: return "b"; if (flags.bits.wood) keys += 'w';
case df::stockpile_group_set::mask_cloth: return "h"; if (flags.bits.gems) keys += 'e';
case df::stockpile_group_set::mask_leather: return "l"; if (flags.bits.bars_blocks) keys += 'b';
case df::stockpile_group_set::mask_ammo: return "z"; if (flags.bits.cloth) keys += 'h';
case df::stockpile_group_set::mask_coins: return "n"; if (flags.bits.leather) keys += 'l';
case df::stockpile_group_set::mask_finished_goods: return "g"; if (flags.bits.ammo) keys += 'z';
case df::stockpile_group_set::mask_weapons: return "p"; if (flags.bits.sheet) keys += 'S';
case df::stockpile_group_set::mask_armor: return "d"; if (flags.bits.finished_goods) keys += 'g';
default: // TODO: handle stockpiles with multiple types if (flags.bits.weapons) keys += 'p';
if (flags.bits.armor) keys += 'd';
if (keys.empty())
return NULL; return NULL;
} return cache(keys);
}
static bool is_single_tile(const tile_context &ctx) {
return ctx.b->x1 == ctx.b->x2 && ctx.b->y1 == ctx.b->y2;
} }
static const char * get_tile_place(const df::coord &pos, static const char * get_tile_place(const df::coord &pos,
@ -613,6 +633,9 @@ static const char * get_tile_place(const df::coord &pos,
if (!ctx.b || ctx.b->getType() != building_type::Stockpile) if (!ctx.b || ctx.b->getType() != building_type::Stockpile)
return NULL; return NULL;
if (!is_rectangular(ctx) || is_single_tile(ctx))
return get_place_keys(ctx);
if (ctx.b->x1 != static_cast<int32_t>(pos.x) if (ctx.b->x1 != static_cast<int32_t>(pos.x)
|| ctx.b->y1 != static_cast<int32_t>(pos.y)) { || ctx.b->y1 != static_cast<int32_t>(pos.y)) {
return if_pretty(ctx, "`"); return if_pretty(ctx, "`");