8
8
#include < string>
9
9
#include < string_view>
10
10
#include < utility>
11
+ #include < variant>
11
12
12
13
#include " debug.h"
13
14
#include " enum_conversions.h"
14
15
#include " flexbuffer_json.h"
15
16
#include " generic_factory.h"
17
+ #include " mapdata.h"
16
18
#include " map_extras.h"
17
19
#include " options.h"
18
20
#include " output.h"
22
24
23
25
class mapgendata ;
24
26
25
- ter_furn_id::ter_furn_id () : ter( ter_str_id::NULL_ID().id() ),
26
- furn( furn_str_id::NULL_ID().id() ) { }
27
27
28
28
template <typename T>
29
29
void read_and_set_or_throw ( const JsonObject &jo, const std::string &member, T &target,
@@ -894,18 +894,14 @@ void groundcover_extra::finalize() // FIXME: return bool for failure
894
894
895
895
for ( std::map<std::string, double >::const_iterator it = percent_str.begin ();
896
896
it != percent_str.end (); ++it ) {
897
- tf_id.ter = ter_str_id::NULL_ID ().id ();
898
- tf_id.furn = furn_str_id::NULL_ID ();
897
+ tf_id = ter_furn_id ();
899
898
if ( it->second < 0.0001 ) {
900
899
continue ;
901
900
}
902
- const ter_str_id tid ( it->first );
903
- const furn_str_id fid ( it->first );
904
- if ( tid.is_valid () ) {
905
- tf_id.ter = tid.id ();
906
- } else if ( fid.is_valid () ) {
907
- tf_id.furn = fid.id ();
908
- } else {
901
+
902
+ bool resolved = tf_id.resolve ( it->first );
903
+
904
+ if ( !resolved ) {
909
905
debugmsg ( " No clue what '%s' is! No such terrain or furniture" , it->first .c_str () );
910
906
continue ;
911
907
}
@@ -915,19 +911,15 @@ void groundcover_extra::finalize() // FIXME: return bool for failure
915
911
916
912
for ( std::map<std::string, double >::const_iterator it = boosted_percent_str.begin ();
917
913
it != boosted_percent_str.end (); ++it ) {
918
- tf_id.ter = ter_str_id::NULL_ID ().id ();
919
- tf_id.furn = furn_str_id::NULL_ID ();
914
+ tf_id = ter_furn_id ();
920
915
if ( it->second < 0.0001 ) {
921
916
continue ;
922
917
}
923
918
const ter_str_id tid ( it->first );
924
919
const furn_str_id fid ( it->first );
925
920
926
- if ( tid.is_valid () ) {
927
- tf_id.ter = tid.id ();
928
- } else if ( fid.is_valid () ) {
929
- tf_id.furn = fid.id ();
930
- } else {
921
+ bool resolved = tf_id.resolve ( it->first );
922
+ if ( !resolved ) {
931
923
debugmsg ( " No clue what '%s' is! No such terrain or furniture" , it->first .c_str () );
932
924
continue ;
933
925
}
@@ -956,8 +948,7 @@ void groundcover_extra::finalize() // FIXME: return bool for failure
956
948
debugmsg ( " boosted plant coverage total (%s=%de-4) exceeds 100%%" , ss.str (), btotal );
957
949
}
958
950
959
- tf_id.furn = furn_str_id::NULL_ID ();
960
- tf_id.ter = default_ter;
951
+ tf_id.ter_furn = default_ter;
961
952
weightlist[ 1000000 ] = tf_id;
962
953
boosted_weightlist[ 1000000 ] = tf_id;
963
954
@@ -977,15 +968,8 @@ void forest_biome_component::finalize()
977
968
{
978
969
for ( const std::pair<const std::string, int > &pr : unfinalized_types ) {
979
970
ter_furn_id tf_id;
980
- tf_id.ter = ter_str_id::NULL_ID ().id ();
981
- tf_id.furn = furn_str_id::NULL_ID ();
982
- const ter_str_id tid ( pr.first );
983
- const furn_str_id fid ( pr.first );
984
- if ( tid.is_valid () ) {
985
- tf_id.ter = tid.id ();
986
- } else if ( fid.is_valid () ) {
987
- tf_id.furn = fid.id ();
988
- } else {
971
+ bool resolved = tf_id.resolve ( pr.first );
972
+ if ( !resolved ) {
989
973
continue ;
990
974
}
991
975
types.add ( tf_id, pr.second );
0 commit comments