Skip to content

Commit af548ec

Browse files
committed
vpart_reqs to optional/mandatory
1 parent c88d0cd commit af548ec

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

src/veh_type.cpp

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -181,25 +181,11 @@ static void parse_vp_reqs( const JsonObject &obj, const vpart_id &id, const std:
181181
}
182182
JsonObject src = obj.get_object( key );
183183

184-
JsonArray sk = src.get_array( "skills" );
185-
if( !sk.empty() ) {
186-
skills.clear();
187-
for( JsonArray cur : sk ) {
188-
if( cur.size() != 2 ) {
189-
debugmsg( "vpart '%s' has requirement with invalid skill entry", id.str() );
190-
continue;
191-
}
192-
skills.emplace( skill_id( cur.get_string( 0 ) ), cur.get_int( 1 ) );
193-
}
194-
}
184+
optional( src, false, "skills", skills, weighted_string_id_reader<skill_id, int> { std::nullopt } );
195185

196-
if( src.has_string( "time" ) ) {
197-
assign( src, "time", time, /* strict = */ false );
198-
} else if( src.has_int( "time" ) ) { // remove in 0.H
199-
time = time_duration::from_moves( src.get_int( "time" ) );
200-
debugmsg( "vpart '%s' defines requirement time as integer, use time units string", id.str() );
201-
}
186+
optional( src, false, "time", time, time );
202187

188+
// FIXME: generic typed reader for requirements
203189
if( src.has_string( "using" ) ) {
204190
reqs = { { requirement_id( src.get_string( "using" ) ), 1 } };
205191
} else if( src.has_array( "using" ) ) {

0 commit comments

Comments
 (0)