@ -6,6 +6,7 @@
# include "modules/World.h"
# include "modules/World.h"
# include "modules/Translation.h"
# include "modules/Translation.h"
# include "modules/Materials.h"
# include "modules/Materials.h"
# include "modules/Maps.h"
# include "modules/Items.h"
# include "modules/Items.h"
# include "DataDefs.h"
# include "DataDefs.h"
@ -19,6 +20,8 @@
# include "df/historical_figure.h"
# include "df/historical_figure.h"
# include "df/general_ref_is_nemesisst.h"
# include "df/general_ref_is_nemesisst.h"
# include "df/general_ref_contains_itemst.h"
# include "df/general_ref_contains_itemst.h"
# include "df/general_ref_contained_in_itemst.h"
# include "df/general_ref_unit_holderst.h"
# include "df/general_ref_building_civzone_assignedst.h"
# include "df/general_ref_building_civzone_assignedst.h"
# include "df/material.h"
# include "df/material.h"
# include "df/craft_material_class.h"
# include "df/craft_material_class.h"
@ -421,7 +424,7 @@ bool isWeaponArmor(df::item *item)
}
}
}
}
int containsMetalItems ( df : : item * item , bool all , bool non_trader )
int containsMetalItems ( df : : item * item , bool all , bool non_trader , bool rec = false )
{
{
int cnt = 0 ;
int cnt = 0 ;
@ -429,13 +432,19 @@ int containsMetalItems(df::item *item, bool all, bool non_trader)
for ( size_t i = 0 ; i < refs . size ( ) ; i + + )
for ( size_t i = 0 ; i < refs . size ( ) ; i + + )
{
{
auto ref = refs [ i ] ;
auto ref = refs [ i ] ;
if ( ! strict_virtual_cast < df : : general_ref_contains_itemst > ( ref ) )
continue ;
if ( strict_virtual_cast < df : : general_ref_unit_holderst > ( ref ) )
return 0 ;
if ( ! rec & & strict_virtual_cast < df : : general_ref_contained_in_itemst > ( ref ) )
return 0 ;
if ( strict_virtual_cast < df : : general_ref_contains_itemst > ( ref ) )
{
df : : item * child = ref - > getItem ( ) ;
df : : item * child = ref - > getItem ( ) ;
if ( ! child ) continue ;
if ( ! child ) continue ;
cnt + = containsMetalItems ( child , all , non_trader ) ;
cnt + = containsMetalItems ( child , all , non_trader , true ) ;
}
}
}
if ( ! non_trader & & ! isShopItem ( item ) )
if ( ! non_trader & & ! isShopItem ( item ) )
@ -787,20 +796,19 @@ command_result adv_tools (Core * c, std::vector <std::string> & parameters)
int total = 0 ;
int total = 0 ;
std : : map < df : : coord , int > counts ;
std : : map < df : : coord , int > counts ;
for ( size_t i = 0 ; i < world - > map . map_blocks . size ( ) ; i + + )
auto & items = world - > items . all ;
{
for ( size_t i = 0 ; i < items . size ( ) ; i + + )
df : : map_block * block = world - > map . map_blocks [ i ] ;
for ( size_t j = 0 ; j < block - > items . size ( ) ; j + + )
{
{
df : : item * item = df : : item : : find ( block - > items [ j ] ) ;
df : : item * item = items [ i ] ;
if ( ! item )
continue ;
int num = containsMetalItems ( item , all , non_trader ) ;
int num = containsMetalItems ( item , all , non_trader ) ;
if ( ! num )
if ( ! num )
continue ;
continue ;
df : : map_block * block = Maps : : getBlockAbs ( item - > pos ) ;
if ( ! block )
continue ;
total + = num ;
total + = num ;
counts [ ( item - > pos - player_pos ) / 10 ] + = num ;
counts [ ( item - > pos - player_pos ) / 10 ] + = num ;
@ -810,7 +818,6 @@ command_result adv_tools (Core * c, std::vector <std::string> & parameters)
dgn . bits . hidden = 0 ; // revealed
dgn . bits . hidden = 0 ; // revealed
dgn . bits . pile = 1 ; // visible
dgn . bits . pile = 1 ; // visible
}
}
}
joinCounts ( counts ) ;
joinCounts ( counts ) ;