Skip to content

Commit ea4e304

Browse files
committed
regeneration modifiers to optional
1 parent dab4637 commit ea4e304

File tree

2 files changed

+2
-71
lines changed

2 files changed

+2
-71
lines changed

src/monstergenerator.cpp

Lines changed: 2 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -894,23 +894,8 @@ void mtype::load( const JsonObject &jo, const std::string &src )
894894
optional( jo, was_loaded, "regenerates_in_dark", regenerates_in_dark, false );
895895
optional( jo, was_loaded, "regen_morale", regen_morale, false );
896896

897-
if( !was_loaded || jo.has_member( "regeneration_modifiers" ) ) {
898-
regeneration_modifiers.clear();
899-
add_regeneration_modifiers( jo, "regeneration_modifiers", src );
900-
} else {
901-
// Note: regeneration_modifers left as is, new modifiers are added to it!
902-
// Note: member name prefixes are compatible with those used by generic_typed_reader
903-
if( jo.has_object( "extend" ) ) {
904-
JsonObject tmp = jo.get_object( "extend" );
905-
tmp.allow_omitted_members();
906-
add_regeneration_modifiers( tmp, "regeneration_modifiers", src );
907-
}
908-
if( jo.has_object( "delete" ) ) {
909-
JsonObject tmp = jo.get_object( "delete" );
910-
tmp.allow_omitted_members();
911-
remove_regeneration_modifiers( tmp, "regeneration_modifiers", src );
912-
}
913-
}
897+
optional( jo, was_loaded, "regeneration_modifiers", regeneration_modifiers,
898+
weighted_string_id_reader<efftype_id, int> { 1 } );
914899

915900
optional( jo, was_loaded, "starting_ammo", starting_ammo );
916901
assign( jo, "luminance", luminance, true );
@@ -1452,52 +1437,6 @@ void mtype::remove_special_attacks( const JsonObject &jo, std::string_view membe
14521437
}
14531438
}
14541439

1455-
void mtype::add_regeneration_modifier( const JsonArray &inner, std::string_view )
1456-
{
1457-
const std::string effect_name = inner.get_string( 0 );
1458-
const efftype_id effect( effect_name );
1459-
//TODO: if invalid effect, throw error
1460-
// inner.throw_error( "Invalid regeneration_modifiers" );
1461-
1462-
if( regeneration_modifiers.count( effect ) > 0 ) {
1463-
regeneration_modifiers.erase( effect );
1464-
if( test_mode ) {
1465-
debugmsg( "%s specifies more than one regeneration modifier for effect %s, ignoring all but the last",
1466-
id.c_str(), effect_name );
1467-
}
1468-
}
1469-
int amount = inner.get_int( 1 );
1470-
regeneration_modifiers.emplace( effect, amount );
1471-
}
1472-
1473-
void mtype::add_regeneration_modifiers( const JsonObject &jo, std::string_view member,
1474-
std::string_view src )
1475-
{
1476-
if( !jo.has_array( member ) ) {
1477-
return;
1478-
}
1479-
1480-
for( const JsonValue entry : jo.get_array( member ) ) {
1481-
if( entry.test_array() ) {
1482-
add_regeneration_modifier( entry.get_array(), src );
1483-
// TODO: add support for regeneration_modifer objects
1484-
//} else if ( entry.test_object() ) {
1485-
// add_regeneration_modifier( entry.get_object(), src );
1486-
} else {
1487-
entry.throw_error( "array element is not an array " );
1488-
}
1489-
}
1490-
}
1491-
1492-
void mtype::remove_regeneration_modifiers( const JsonObject &jo, std::string_view member_name,
1493-
std::string_view )
1494-
{
1495-
for( const std::string &name : jo.get_tags( member_name ) ) {
1496-
const efftype_id effect( name );
1497-
regeneration_modifiers.erase( effect );
1498-
}
1499-
}
1500-
15011440
void MonsterGenerator::check_monster_definitions() const
15021441
{
15031442
for( const mtype &mon : mon_templates->get_all() ) {

src/mtype.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ using mon_action_death = void ( * )( monster & );
4444
using mon_action_attack = bool ( * )( monster * );
4545
using mon_action_defend = void ( * )( monster &, Creature *, dealt_projectile_attack const * );
4646
using bodytype_id = std::string;
47-
class JsonArray;
4847
class JsonObject;
4948

5049
// These are triggers which may affect the monster's anger or morale.
@@ -617,13 +616,6 @@ struct mtype {
617616

618617
void add_special_attack( const JsonArray &inner, std::string_view src );
619618
void add_special_attack( const JsonObject &obj, const std::string &src );
620-
621-
void add_regeneration_modifiers( const JsonObject &jo, std::string_view member_name,
622-
std::string_view src );
623-
void remove_regeneration_modifiers( const JsonObject &jo, std::string_view member_name,
624-
std::string_view src );
625-
626-
void add_regeneration_modifier( const JsonArray &inner, std::string_view src );
627619
};
628620

629621
#endif // CATA_SRC_MTYPE_H

0 commit comments

Comments
 (0)