Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ Template for new versions:

## Fixes
- `stockpiles`: fix one-off error in item type when importing furniture stockpile settings
- `dig-now`: fix cases where boulders/rough gems of incorrect material were being generated when digging through walls
- `dig-now`: properly generate ice boulders when digging through ice walls

## Misc Improvements
- `spectate`: show dwarves' activities (like prayer)
Expand Down
58 changes: 30 additions & 28 deletions plugins/dig-now.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
#include "modules/World.h"

#include "df/building.h"
#include "df/builtin_mats.h"
#include "df/historical_entity.h"
#include "df/item.h"
#include "df/map_block.h"
#include "df/material.h"
#include "df/plotinfost.h"
#include "df/reaction_product_itemst.h"
#include "df/tile_designation.h"
Expand Down Expand Up @@ -391,7 +393,7 @@ struct dug_tile_info {
DFCoord pos;
df::tiletype_material tmat;
df::item_type itype;
int32_t imat; // mat idx of boulder/gem potentially generated at this pos
t_matpair imat; // matpair of boulder/gem potentially generated at this pos

dug_tile_info(MapExtras::MapCache &map, const DFCoord &pos) {
this->pos = pos;
Expand All @@ -403,32 +405,32 @@ struct dug_tile_info {
imat = -1;

df::tiletype_shape shape = tileShape(tt);
if (shape == df::tiletype_shape::WALL || shape == df::tiletype_shape::FORTIFICATION) {
switch (tmat) {
case df::tiletype_material::STONE:
case df::tiletype_material::MINERAL:
case df::tiletype_material::FEATURE:
imat = map.baseMaterialAt(pos).mat_index;
break;
case df::tiletype_material::LAVA_STONE:
{
MaterialInfo mi;
if (mi.findInorganic("OBSIDIAN"))
imat = mi.index;
return; // itype should always be BOULDER, regardless of vein
}
default:
break;
}
}

switch (map.BlockAtTile(pos)->veinTypeAt(pos)) {
case df::inclusion_type::CLUSTER_ONE:
case df::inclusion_type::CLUSTER_SMALL:
itype = df::item_type::ROUGH;
if (shape != df::tiletype_shape::WALL && shape != df::tiletype_shape::FORTIFICATION)
return;

switch (tmat) {
case df::tiletype_material::STONE:
case df::tiletype_material::MINERAL:
case df::tiletype_material::FEATURE:
case df::tiletype_material::LAVA_STONE:
imat = map.baseMaterialAt(pos);
break;
default:
case df::tiletype_material::FROZEN_LIQUID:
// assume frozen water
// we can't use baseMaterialAt here because it will return the underlying river bed material
imat = t_matpair(df::builtin_mats::WATER, -1);
break;
default:
return;
}

MaterialInfo mi;
mi.decode(imat);
if (mi.type == -1 || !mi.material)
return;

if (mi.material->isGem()) {
itype = df::item_type::ROUGH;
}
}
};
Expand Down Expand Up @@ -737,7 +739,7 @@ static bool produces_item(const boulder_percent_options &options,
return rng.random(100) < probability;
}

typedef std::map<std::pair<df::item_type, int32_t>, std::vector<DFCoord>>
typedef std::map<std::pair<df::item_type, t_matpair>, std::vector<DFCoord>>
item_coords_t;

static void do_dig(color_ostream &out, std::vector<DFCoord> &dug_coords,
Expand Down Expand Up @@ -876,8 +878,8 @@ static void create_boulders(color_ostream &out,

prod->item_type = entry.first.first;
prod->item_subtype = -1;
prod->mat_type = 0;
prod->mat_index = entry.first.second;
prod->mat_type = entry.first.second.mat_type;
prod->mat_index = entry.first.second.mat_index;
prod->probability = 100;
prod->product_dimension = 1;

Expand Down