don't overwrite dig priority by accident

many callers of setDesignationAt simply didn't bother with the priority
parameter. change the default value of the priority param so that by
default we will keep the previous value instead of overwriting it
develop
myk002 2022-10-19 16:47:54 -07:00
parent f94cc3fda0
commit 666edd6d60
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
3 changed files with 11 additions and 4 deletions

@ -36,6 +36,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## New Plugins ## New Plugins
## Fixes ## Fixes
- `tiletypes`: no longer resets dig priority to the default when updating other properties of a tile
## Misc Improvements ## Misc Improvements
- `blueprint`: new ``--smooth`` option for recording all smoothed floors and walls instead of just the ones that require smoothing for later carving - `blueprint`: new ``--smooth`` option for recording all smoothed floors and walls instead of just the ones that require smoothing for later carving

@ -267,7 +267,7 @@ public:
{ {
return index_tile(designation,p); return index_tile(designation,p);
} }
bool setDesignationAt(df::coord2d p, df::tile_designation des, int32_t priority = 4000) bool setDesignationAt(df::coord2d p, df::tile_designation des, int32_t priority = 0)
{ {
if(!valid) return false; if(!valid) return false;
dirty_designations = true; dirty_designations = true;
@ -276,6 +276,12 @@ public:
index_tile(designation,p) = des; index_tile(designation,p) = des;
if((des.bits.dig || des.bits.smooth) && block) { if((des.bits.dig || des.bits.smooth) && block) {
block->flags.bits.designated = true; block->flags.bits.designated = true;
// if priority is not specified, keep the existing priority if it
// is set. otherwise default to 4000.
if (priority <= 0)
priority = priorityAt(p);
if (priority <= 0)
priority = 4000;
setPriorityAt(p, priority); setPriorityAt(p, priority);
} }
return true; return true;
@ -554,8 +560,8 @@ class DFHACK_EXPORT MapCache
Block * b= BlockAtTile(tilecoord); Block * b= BlockAtTile(tilecoord);
return b ? b->DesignationAt(tilecoord) : df::tile_designation(); return b ? b->DesignationAt(tilecoord) : df::tile_designation();
} }
// priority is optional, only set if >= 0 // if priority is 0, it is kept unchanged if previously set, otherwise 4000
bool setDesignationAt (DFCoord tilecoord, df::tile_designation des, int32_t priority = 4000) bool setDesignationAt (DFCoord tilecoord, df::tile_designation des, int32_t priority = 0)
{ {
if (Block *b = BlockAtTile(tilecoord)) if (Block *b = BlockAtTile(tilecoord))
{ {

@ -303,7 +303,7 @@ int32_t MapExtras::Block::priorityAt(df::coord2d pos)
bool MapExtras::Block::setPriorityAt(df::coord2d pos, int32_t priority) bool MapExtras::Block::setPriorityAt(df::coord2d pos, int32_t priority)
{ {
if (!block || priority < 0) if (!block || priority <= 0)
return false; return false;
auto event = getPriorityEvent(block, true); auto event = getPriorityEvent(block, true);