2014-06-01 17:55:23 +00:00
/*
2018-09-02 00:57:29 +00:00
* This file is part of the DXX - Rebirth project < https : //www.dxx-rebirth.com/>.
2014-06-01 17:55:23 +00:00
* It is copyright by its individual contributors , as recorded in the
* project ' s Git history . See COPYING . txt at the top level for license
* terms and a link to the Git history .
*/
2006-03-20 17:12:09 +00:00
/*
*
* Player Stuff
*
*/
2019-06-27 03:26:20 +00:00
# include "object.h"
2006-03-20 17:12:09 +00:00
# include "player.h"
2014-07-20 01:09:55 +00:00
# include "physfsx.h"
2016-10-02 19:35:34 +00:00
# include "compiler-range_for.h"
2006-03-20 17:12:09 +00:00
2016-08-25 04:05:32 +00:00
namespace dsx {
2019-06-27 03:26:20 +00:00
# if defined(DXX_BUILD_DESCENT_II)
const player & get_player_controlling_guidebot ( const d_unique_buddy_state & /* reserved for future use */ , const valptridx < player > : : array_managed_type & Players )
{
/* One day, the game may support letting someone other than player 0
* control the guidebot . For now , only player 0 will ever control
* it .
*/
return Players . front ( ) ;
}
# endif
2010-12-22 00:17:59 +00:00
void player_rw_swap ( player_rw * p , int swap )
2009-10-05 02:51:37 +00:00
{
if ( ! swap )
return ;
2013-02-21 00:20:26 +00:00
2009-10-05 02:51:37 +00:00
p - > objnum = SWAPINT ( p - > objnum ) ;
p - > flags = SWAPINT ( p - > flags ) ;
p - > energy = SWAPINT ( p - > energy ) ;
p - > shields = SWAPINT ( p - > shields ) ;
p - > killer_objnum = SWAPSHORT ( p - > killer_objnum ) ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2009-10-05 02:51:37 +00:00
p - > primary_weapon_flags = SWAPSHORT ( p - > primary_weapon_flags ) ;
2013-03-03 01:03:33 +00:00
# endif
2013-09-20 23:12:54 +00:00
p - > vulcan_ammo = SWAPSHORT ( p - > vulcan_ammo ) ;
2014-09-26 02:42:10 +00:00
for ( int i = 0 ; i < MAX_SECONDARY_WEAPONS ; i + + )
2009-10-05 02:51:37 +00:00
p - > secondary_ammo [ i ] = SWAPSHORT ( p - > secondary_ammo [ i ] ) ;
p - > last_score = SWAPINT ( p - > last_score ) ;
p - > score = SWAPINT ( p - > score ) ;
p - > time_level = SWAPINT ( p - > time_level ) ;
p - > time_total = SWAPINT ( p - > time_total ) ;
p - > cloak_time = SWAPINT ( p - > cloak_time ) ;
p - > invulnerable_time = SWAPINT ( p - > invulnerable_time ) ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2009-10-05 02:51:37 +00:00
p - > KillGoalCount = SWAPSHORT ( p - > KillGoalCount ) ;
2013-03-03 01:03:33 +00:00
# endif
2009-10-05 02:51:37 +00:00
p - > net_killed_total = SWAPSHORT ( p - > net_killed_total ) ;
p - > net_kills_total = SWAPSHORT ( p - > net_kills_total ) ;
p - > num_kills_level = SWAPSHORT ( p - > num_kills_level ) ;
p - > num_kills_total = SWAPSHORT ( p - > num_kills_total ) ;
p - > num_robots_level = SWAPSHORT ( p - > num_robots_level ) ;
p - > num_robots_total = SWAPSHORT ( p - > num_robots_total ) ;
p - > hostages_rescued_total = SWAPSHORT ( p - > hostages_rescued_total ) ;
p - > hostages_total = SWAPSHORT ( p - > hostages_total ) ;
p - > homing_object_dist = SWAPINT ( p - > homing_object_dist ) ;
}
2016-08-25 04:05:32 +00:00
}
2009-10-05 02:51:37 +00:00
2006-03-20 17:12:09 +00:00
/*
2016-01-09 16:38:14 +00:00
* reads a player_ship structure from a PHYSFS_File
2006-03-20 17:12:09 +00:00
*/
2016-01-09 16:38:14 +00:00
void player_ship_read ( player_ship * ps , PHYSFS_File * fp )
2006-03-20 17:12:09 +00:00
{
2011-06-01 07:59:55 +00:00
ps - > model_num = PHYSFSX_readInt ( fp ) ;
ps - > expl_vclip_num = PHYSFSX_readInt ( fp ) ;
ps - > mass = PHYSFSX_readFix ( fp ) ;
ps - > drag = PHYSFSX_readFix ( fp ) ;
ps - > max_thrust = PHYSFSX_readFix ( fp ) ;
ps - > reverse_thrust = PHYSFSX_readFix ( fp ) ;
ps - > brakes = PHYSFSX_readFix ( fp ) ;
ps - > wiggle = PHYSFSX_readFix ( fp ) ;
ps - > max_rotthrust = PHYSFSX_readFix ( fp ) ;
2016-10-02 19:35:34 +00:00
range_for ( auto & i , ps - > gun_points )
PHYSFSX_readVector ( fp , i ) ;
2006-03-20 17:12:09 +00:00
}