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
## Fixes
- `tiletypes`: no longer resets dig priority to the default when updating other properties of a tile
## Misc Improvements
- `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);
}
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;
dirty_designations = true;
@ -276,6 +276,12 @@ public:
index_tile(designation,p) = des;
if((des.bits.dig || des.bits.smooth) && block) {
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);
}
return true;
@ -554,8 +560,8 @@ class DFHACK_EXPORT MapCache
Block * b= BlockAtTile(tilecoord);
return b ? b->DesignationAt(tilecoord) : df::tile_designation();
}
// priority is optional, only set if >= 0
bool setDesignationAt (DFCoord tilecoord, df::tile_designation des, int32_t priority = 4000)
// if priority is 0, it is kept unchanged if previously set, otherwise 4000
bool setDesignationAt (DFCoord tilecoord, df::tile_designation des, int32_t priority = 0)
{
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)
{
if (!block || priority < 0)
if (!block || priority <= 0)
return false;
auto event = getPriorityEvent(block, true);