Skip to content

Commit

Permalink
Move splitting vehicle move into horizontal and vertical into map::mo…
Browse files Browse the repository at this point in the history
…ve_vehicle.

So the caller does not have to do it. At least one caller (from `monster::shove_vehicle`) did not do this.
  • Loading branch information
BevapDin committed Aug 24, 2019
1 parent b215f78 commit 7507200
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
16 changes: 16 additions & 0 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,22 @@ static bool sees_veh( const Creature &c, vehicle &veh, bool force_recalc )

vehicle *map::move_vehicle( vehicle &veh, const tripoint &dp, const tileray &facing )
{
// Split the movement into horizontal and vertical for easier processing
if( dp.xy() != point_zero && dp.z != 0 ) {
vehicle *const new_pointer = move_vehicle( veh, tripoint( dp.xy(), 0 ), facing );
if( !new_pointer ) {
return nullptr;
}

vehicle *const result = move_vehicle( *new_pointer, tripoint( 0, 0, dp.z ), facing );
if( !result ) {
return nullptr;
}

result->is_falling = false;
return result;
}

const bool vertical = dp.z != 0;
if( ( dp.x == 0 && dp.y == 0 && dp.z == 0 ) ||
( abs( dp.x ) > 1 || abs( dp.y ) > 1 || abs( dp.z ) > 1 ) ||
Expand Down
13 changes: 1 addition & 12 deletions src/vehicle_move.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1335,18 +1335,7 @@ vehicle *vehicle::act_on_map()
dp.z = -1;
}

vehicle *new_pointer = this;
// Split the movement into horizontal and vertical for easier processing
if( dp.x != 0 || dp.y != 0 ) {
new_pointer = g->m.move_vehicle( *new_pointer, tripoint( dp.xy(), 0 ), mdir );
}

if( new_pointer != nullptr && dp.z != 0 ) {
new_pointer = g->m.move_vehicle( *new_pointer, tripoint( 0, 0, dp.z ), mdir );
is_falling = false;
}

return new_pointer;
return g->m.move_vehicle( *this, dp, mdir );
}

void vehicle::check_falling_or_floating()
Expand Down

0 comments on commit 7507200

Please sign in to comment.