2020#include " modules/World.h"
2121
2222#include " df/building.h"
23+ #include " df/builtin_mats.h"
2324#include " df/historical_entity.h"
2425#include " df/item.h"
2526#include " df/map_block.h"
27+ #include " df/material.h"
2628#include " df/plotinfost.h"
2729#include " df/reaction_product_itemst.h"
2830#include " df/tile_designation.h"
@@ -391,7 +393,7 @@ struct dug_tile_info {
391393 DFCoord pos;
392394 df::tiletype_material tmat;
393395 df::item_type itype;
394- int32_t imat; // mat idx of boulder/gem potentially generated at this pos
396+ t_matpair imat; // matpair of boulder/gem potentially generated at this pos
395397
396398 dug_tile_info (MapExtras::MapCache &map, const DFCoord &pos) {
397399 this ->pos = pos;
@@ -403,32 +405,32 @@ struct dug_tile_info {
403405 imat = -1 ;
404406
405407 df::tiletype_shape shape = tileShape (tt);
406- if (shape == df::tiletype_shape::WALL || shape == df::tiletype_shape::FORTIFICATION) {
407- switch (tmat) {
408- case df::tiletype_material::STONE:
409- case df::tiletype_material::MINERAL:
410- case df::tiletype_material::FEATURE:
411- imat = map.baseMaterialAt (pos).mat_index ;
412- break ;
413- case df::tiletype_material::LAVA_STONE:
414- {
415- MaterialInfo mi;
416- if (mi.findInorganic (" OBSIDIAN" ))
417- imat = mi.index ;
418- return ; // itype should always be BOULDER, regardless of vein
419- }
420- default :
421- break ;
422- }
423- }
424-
425- switch (map.BlockAtTile (pos)->veinTypeAt (pos)) {
426- case df::inclusion_type::CLUSTER_ONE:
427- case df::inclusion_type::CLUSTER_SMALL:
428- itype = df::item_type::ROUGH;
408+ if (shape != df::tiletype_shape::WALL && shape != df::tiletype_shape::FORTIFICATION)
409+ return ;
410+
411+ switch (tmat) {
412+ case df::tiletype_material::STONE:
413+ case df::tiletype_material::MINERAL:
414+ case df::tiletype_material::FEATURE:
415+ case df::tiletype_material::LAVA_STONE:
416+ imat = map.baseMaterialAt (pos);
429417 break ;
430- default :
418+ case df::tiletype_material::FROZEN_LIQUID:
419+ // assume frozen water
420+ // we can't use baseMaterialAt here because it will return the underlying river bed material
421+ imat = t_matpair (df::builtin_mats::WATER, -1 );
431422 break ;
423+ default :
424+ return ;
425+ }
426+
427+ MaterialInfo mi;
428+ mi.decode (imat);
429+ if (mi.type == -1 || !mi.material )
430+ return ;
431+
432+ if (mi.material ->isGem ()) {
433+ itype = df::item_type::ROUGH;
432434 }
433435 }
434436};
@@ -737,7 +739,7 @@ static bool produces_item(const boulder_percent_options &options,
737739 return rng.random (100 ) < probability;
738740}
739741
740- typedef std::map<std::pair<df::item_type, int32_t >, std::vector<DFCoord>>
742+ typedef std::map<std::pair<df::item_type, t_matpair >, std::vector<DFCoord>>
741743 item_coords_t ;
742744
743745static void do_dig (color_ostream &out, std::vector<DFCoord> &dug_coords,
@@ -876,8 +878,8 @@ static void create_boulders(color_ostream &out,
876878
877879 prod->item_type = entry.first .first ;
878880 prod->item_subtype = -1 ;
879- prod->mat_type = 0 ;
880- prod->mat_index = entry.first .second ;
881+ prod->mat_type = entry. first . second . mat_type ;
882+ prod->mat_index = entry.first .second . mat_index ;
881883 prod->probability = 100 ;
882884 prod->product_dimension = 1 ;
883885
0 commit comments