Merge pull request #2347 from myk002/myk_tiletypes_priority

[tiletypes] don't overwrite dig priority by accident
develop
Myk 2022-10-19 16:55:04 -07:00 committed by GitHub
commit 45c1fafa47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);