MCPcopy Create free account
hub / github.com/CleverRaven/Cataclysm-DDA / is_normal_submap

Function is_normal_submap

tests/submap_load_test.cpp:798–854  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

796//static const submap_checks dont_care;
797
798static bool is_normal_submap( const submap &sm, submap_checks checks = {} )
799{
800 const bool terrain = checks.terrain;
801 const bool furniture = checks.furniture;
802 const bool traps = checks.traps;
803 const bool radiation = checks.radiation;
804 const bool items = checks.items;
805 const bool fields = checks.fields;
806 const bool cosmetics = checks.cosmetics;
807 const bool spawns = checks.spawns;
808 const bool vehicles = checks.vehicles;
809 const bool construction = checks.construction;
810 const bool computers = checks.computers;
811
812 // For every point on the submap
813 for( int y = 0; y < SEEY; ++y ) {
814 for( int x = 0; x < SEEX; ++x ) {
815 if( terrain && sm.get_ter( { x, y } ) != t_dirt ) {
816 return false;
817 }
818 if( furniture && sm.get_furn( { x, y } ) != f_null ) {
819 return false;
820 }
821 if( traps && sm.get_trap( {x, y} ) != tr_null ) {
822 return false;
823 }
824 if( radiation && sm.get_radiation( { x, y } ) != 0 ) {
825 return false;
826 }
827 if( items && !sm.get_items( {x, y} ).empty() ) {
828 return false;
829 }
830 if( fields && sm.get_field( { x, y } ).field_count() != 0 ) {
831 return false;
832 }
833 if( computers && sm.has_computer( {x, y} ) ) {
834 return false;
835 }
836 }
837 }
838
839 // Can be found without checking every point
840 if( cosmetics && !sm.cosmetics.empty() ) {
841 return false;
842 }
843 if( spawns && !sm.spawns.empty() ) {
844 return false;
845 }
846 if( vehicles && !sm.vehicles.empty() ) {
847 return false;
848 }
849 if( construction && !sm.partial_constructions.empty() ) {
850 return false;
851 }
852
853 return true;
854}
855

Callers 1

Calls 9

get_itemsMethod · 0.80
field_countMethod · 0.80
get_fieldMethod · 0.80
has_computerMethod · 0.80
get_terMethod · 0.45
get_furnMethod · 0.45
get_trapMethod · 0.45
get_radiationMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected