Skip to content

Commit ad179a7

Browse files
committed
eoc: fix loading time of value_or_var
1 parent f57a190 commit ad179a7

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

src/condition.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2157,7 +2157,7 @@ void string_mutator<translation>::deserialize( JsonValue const &jsin )
21572157
} );
21582158
if( !ret_func ) {
21592159
jo.allow_omitted_members();
2160-
jo.throw_error( "unrecognized string mutator in " + jo.str() );
2160+
throw JsonError( "invalid string mutator" );
21612161
}
21622162
}
21632163
}
@@ -2176,7 +2176,7 @@ void string_mutator<std::string>::deserialize( JsonValue const &jsin )
21762176
} );
21772177
if( !ret_func ) {
21782178
jo.allow_omitted_members();
2179-
jo.throw_error( "unrecognized string mutator in " + jo.str() );
2179+
throw JsonError( "invalid string mutator" );
21802180
}
21812181
}
21822182
}
@@ -2371,7 +2371,7 @@ void deferred_math::_validate_type() const
23712371
void eoc_math::from_json( const JsonObject &jo, std::string_view member, math_type_t type_ )
23722372
{
23732373
if( !jo.has_array( member ) ) {
2374-
jo.throw_error( "invalid math object" );
2374+
throw JsonError( "invalid math object" );
23752375
}
23762376
JsonArray const objects = jo.get_array( member );
23772377
std::string combined;

src/dialogue_helpers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ bool deserialize_variant( V &v, JsonValue const &jsin )
140140
template<typename valueT, typename... funcT>
141141
void value_or_var<valueT, funcT...>::deserialize( JsonValue const &jsin )
142142
{
143-
if( deserialize_variant<decltype( val ), funcT..., var_info, valueT>( val, jsin ) ) {
143+
if( deserialize_variant<decltype( val ), valueT, var_info, funcT...>( val, jsin ) ) {
144144

145145
if( std::holds_alternative<var_info>( val ) ) {
146146
JsonObject const &jo_vi = jsin.get_object();

src/game.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@
170170
#include "past_achievements_info.h"
171171
#include "path_info.h"
172172
#include "pathfinding.h"
173+
#include "perf.h"
173174
#include "pickup.h"
174175
#include "player_activity.h"
175176
#include "popup.h"
@@ -3427,8 +3428,10 @@ void game::load_packs( const std::string &msg, const std::vector<mod_id> &packs
34273428
if( mod.str() == "test_data" ) {
34283429
check_plural = check_plural_t::none;
34293430
}
3431+
cata_timer pack_timer( string_format( "%s pack load time:", mod->name() ) );
34303432
load_mod_data_from_dir( mod->path, mod.str() );
34313433
}
3434+
cata_timer::print_stats();
34323435

34333436
for( const auto &mod : packs ) {
34343437
if( !mod.is_valid() ) {

src/math_parser_diag_value.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ void diag_value::deserialize( const JsonValue &jsin )
354354
tripoint_abs_ms t;
355355
jo.read( "tripoint", t );
356356
data = t;
357-
} else if( jo.has_member( "str" ) ) {
357+
} else if( jo.has_member( "str" ) && !jo.get_bool( "i18n", false ) ) {
358358
std::string str;
359359
jo.read( "str", str );
360360
data = str;
@@ -363,6 +363,9 @@ void diag_value::deserialize( const JsonValue &jsin )
363363
std::string str;
364364
jo.read( "dbl", str );
365365
data = std::stof( str );
366+
} else {
367+
jo.allow_omitted_members();
368+
throw JsonError( "invalid diag_value object" );
366369
}
367370
}
368371
}

0 commit comments

Comments
 (0)