Skip to content

Commit

Permalink
change emit_fields from set to map
Browse files Browse the repository at this point in the history
  • Loading branch information
Fris0uman committed Feb 10, 2020
1 parent e5139bf commit b82782c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
10 changes: 7 additions & 3 deletions src/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1941,16 +1941,20 @@ void monster::process_turn()
{
decrement_summon_timer();
if( !is_hallucination() ) {
for( const auto &e : type->emit_fields ) {
if( e == emit_id( "emit_shock_cloud" ) ) {
for( const std::pair<emit_id, time_duration> &e : type->emit_fields ) {
if( !calendar::once_every( e.second ) ) {
continue;
}
const emit_id emid = e.first;
if( emid == emit_id( "emit_shock_cloud" ) ) {
if( has_effect( effect_emp ) ) {
continue; // don't emit electricity while EMPed
} else if( has_effect( effect_supercharged ) ) {
g->m.emit_field( pos(), emit_id( "emit_shock_cloud_big" ) );
continue;
}
}
g->m.emit_field( pos(), e );
g->m.emit_field( pos(), emid );
}
}

Expand Down
12 changes: 8 additions & 4 deletions src/monstergenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,10 @@ void mtype::load( const JsonObject &jo, const std::string &src )
dies.push_back( mdeath::normal );
}

assign( jo, "emit_fields", emit_fields );
for( JsonArray ja : jo.get_array( "emit_fields" ) ) {
emit_fields.emplace( ja.get_string( 0 ), read_from_json_string<time_duration>( ja.get_string( 1 ),
time_duration::units ) );
}

if( jo.has_member( "special_when_hit" ) ) {
JsonArray jsarr = jo.get_array( "special_when_hit" );
Expand Down Expand Up @@ -1149,9 +1152,10 @@ void MonsterGenerator::check_monster_definitions() const
}
}

for( const auto &e : mon.emit_fields ) {
if( !e.is_valid() ) {
debugmsg( "monster %s has invalid emit source %s", mon.id.c_str(), e.c_str() );
for( const std::pair<emit_id, time_duration> &e : mon.emit_fields ) {
const emit_id emid = e.first;
if( !emid.is_valid() ) {
debugmsg( "monster %s has invalid emit source %s", mon.id.c_str(), emid.c_str() );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/mtype.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ struct mtype {
int mech_str_bonus = 0;

/** Emission sources that cycle each turn the monster remains alive */
std::set<emit_id> emit_fields;
std::map<emit_id, time_duration> emit_fields;

pathfinding_settings path_settings;

Expand Down

0 comments on commit b82782c

Please sign in to comment.