Skip to content

Commit

Permalink
Adjust code according to suggestions.
Browse files Browse the repository at this point in the history
  • Loading branch information
John-Candlebury committed Sep 24, 2019
1 parent f26f024 commit ee8ecd7
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/bionics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ bool player::activate_bionic( int b, bool eff_only )
add_msg_if_player( m_info, _( "You cannot activate that while mounted." ) );
return false;
}
teleport::teleport( this );
teleport::teleport( *this );
add_effect( effect_teleglow, 30_minutes );
mod_moves( -100 );
} else if( bio.id == "bio_blood_anal" ) {
Expand Down
4 changes: 2 additions & 2 deletions src/iuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3432,7 +3432,7 @@ int iuse::teleport( player *p, item *it, bool, const tripoint & )
return 0;
}
p->moves -= to_moves<int>( 1_seconds );
teleport::teleport( p );
teleport::teleport( *p );
return it->type->charges_to_use();
}

Expand Down Expand Up @@ -5276,7 +5276,7 @@ int iuse::artifact( player *p, item *it, bool, const tripoint & )
break;

case AEA_TELEPORT:
teleport::teleport( p );
teleport::teleport( *p );
break;

case AEA_LIGHT:
Expand Down
2 changes: 1 addition & 1 deletion src/magic_spell_effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void spell_effect::teleport_random( const spell &sp, Creature &caster, const tri
debugmsg( "ERROR: Teleport argument(s) invalid" );
return;
}
teleport::teleport( &caster, min_distance, max_distance, safe, false );
teleport::teleport( caster, min_distance, max_distance, safe, false );
}

void spell_effect::pain_split( const spell &sp, Creature &caster, const tripoint & )
Expand Down
4 changes: 2 additions & 2 deletions src/map_field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1635,7 +1635,7 @@ void map::player_in_field( player &u )
if( rng( 0, 2 ) < cur.get_field_intensity() && u.is_player() ) {
add_msg( m_bad, _( "You're violently teleported!" ) );
u.hurtall( cur.get_field_intensity(), nullptr );
teleport::teleport( &u );
teleport::teleport( u );
}
}
// Why do these get removed???
Expand Down Expand Up @@ -1926,7 +1926,7 @@ void map::monster_in_field( monster &z )
if( cur_field_type == fd_fatigue ) {
if( rng( 0, 2 ) < cur.get_field_intensity() ) {
dam += cur.get_field_intensity();
teleport::teleport( &z );
teleport::teleport( z );
}
}
if( cur_field_type == fd_incendiary ) {
Expand Down
2 changes: 1 addition & 1 deletion src/player_hardcoded_effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ void player::hardcoded_effects( effect &it )
if( !is_npc() ) {
add_msg( _( "Glowing lights surround you, and you teleport." ) );
}
teleport::teleport( this );
teleport::teleport( *this );
g->events().send<event_type::teleglow_teleports>( getID() );
if( one_in( 10 ) ) {
// Set ourselves up for removal
Expand Down
24 changes: 12 additions & 12 deletions src/teleport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ const efftype_id effect_teleglow( "teleglow" );
bool teleport::teleport( Creature &critter, int min_distance, int max_distance, bool safe,
bool add_teleglow )
{
if( critter == nullptr || min_distance > max_distance ) {
if( min_distance > max_distance ) {
debugmsg( "ERROR: Function teleport::teleport called with invalid arguments." );
return false;
}

const bool c_is_u = &critter == &g->u;
player *const p = critter->as_player();
player *const p = critter.as_player();
int tries = 0;
tripoint origin = critter->pos();
tripoint origin = critter.pos();
tripoint new_pos = tripoint_zero;
do {
int rangle = rng( 0, 360 );
Expand All @@ -39,14 +39,14 @@ bool teleport::teleport( Creature &critter, int min_distance, int max_distance,
add_msg( m_bad, _( "You cannot teleport safely" ) );
}
return false;
} else {
critter->apply_damage( nullptr, bp_torso, 9999 );
if( c_is_u ) {
g->events().send<event_type::teleports_into_wall>( p->getID(), g->m.obstacle_name( new_pos ) );
add_msg( m_bad, _( "You die after teleporting into a solid." ) );
}
critter->check_dead_state();
}
critter.apply_damage( nullptr, bp_torso, 9999 );
if( c_is_u ) {
g->events().send<event_type::teleports_into_wall>( p->getID(), g->m.obstacle_name( new_pos ) );
add_msg( m_bad, _( "You die after teleporting into a solid." ) );
}
critter.check_dead_state();

}
//handles telefragging other creatures
if( Creature *const poor_soul = g->critter_at<Creature>( new_pos ) ) {
Expand All @@ -70,15 +70,15 @@ bool teleport::teleport( Creature &critter, int min_distance, int max_distance,
} else {
if( g->u.sees( *poor_soul ) ) {
add_msg( m_good, _( "%1$s teleports into %2$s, killing them!" ),
critter->disp_name(), poor_soul->disp_name() );
critter.disp_name(), poor_soul->disp_name() );
}
}
poor_soul->apply_damage( nullptr, bp_torso, 9999 ); //Splatter real nice.
poor_soul->check_dead_state();
}
}

critter->setpos( new_pos );
critter.setpos( new_pos );
//player and npc exclusive teleporting effects
if( p ) {
if( add_teleglow ) {
Expand Down
2 changes: 1 addition & 1 deletion src/teleport.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace teleport
/** Teleports a creature to a tile within min_distance and max_distance tiles. Limited to 2D.
*bool safe determines wether the teleported creature can telefrag others/itself.
*/
bool teleport( Creature *const critter, int min_distance = 2, int max_distance = 12,
bool teleport( Creature &critter, int min_distance = 2, int max_distance = 12,
bool safe = false,
bool add_teleglow = true );
}
Expand Down
2 changes: 1 addition & 1 deletion src/trapfunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ bool trapfunc::telepad( const tripoint &p, Creature *c, item * )
add_msg( _( "The air shimmers around %s..." ), c->disp_name() );
}
}
teleport::teleport( c );
teleport::teleport( *c );
return false;
}

Expand Down

0 comments on commit ee8ecd7

Please sign in to comment.