From d09813419a02f0b07bad5629c593af881ed1461c Mon Sep 17 00:00:00 2001 From: BevapDin Date: Thu, 12 Dec 2019 18:37:05 +0100 Subject: [PATCH] Remove unnecessary emptiness check. There is a check for whether the array has more entries. That one will catch empty array. --- src/savegame_json.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/savegame_json.cpp b/src/savegame_json.cpp index 4629e0ea02a3f..8504c1b88d732 100644 --- a/src/savegame_json.cpp +++ b/src/savegame_json.cpp @@ -1826,20 +1826,18 @@ void monster::load( const JsonObject &data ) // sp_timeout indicates an old save, prior to the special_attacks refactor if( data.has_array( "sp_timeout" ) ) { JsonArray parray = data.get_array( "sp_timeout" ); - if( !parray.empty() ) { - int index = 0; - int ptimeout = 0; - while( parray.has_more() && index < static_cast( type->special_attacks_names.size() ) ) { - if( parray.read_next( ptimeout ) ) { - // assume timeouts saved in same order as current monsters.json listing - const std::string &aname = type->special_attacks_names[index++]; - auto &entry = special_attacks[aname]; - if( ptimeout >= 0 ) { - entry.cooldown = ptimeout; - } else { // -1 means disabled, unclear what <-1 values mean in old saves - entry.cooldown = type->special_attacks.at( aname )->cooldown; - entry.enabled = false; - } + int index = 0; + int ptimeout = 0; + while( parray.has_more() && index < static_cast( type->special_attacks_names.size() ) ) { + if( parray.read_next( ptimeout ) ) { + // assume timeouts saved in same order as current monsters.json listing + const std::string &aname = type->special_attacks_names[index++]; + auto &entry = special_attacks[aname]; + if( ptimeout >= 0 ) { + entry.cooldown = ptimeout; + } else { // -1 means disabled, unclear what <-1 values mean in old saves + entry.cooldown = type->special_attacks.at( aname )->cooldown; + entry.enabled = false; } } }