Subversion Repositories Games.Descent

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * This file is part of the DXX-Rebirth project <https://www.dxx-rebirth.com/>.
  3.  * It is copyright by its individual contributors, as recorded in the
  4.  * project's Git history.  See COPYING.txt at the top level for license
  5.  * terms and a link to the Git history.
  6.  */
  7.  
  8. /*
  9.  *
  10.  * Player Stuff
  11.  *
  12.  */
  13.  
  14. #include "object.h"
  15. #include "player.h"
  16. #include "physfsx.h"
  17. #include "compiler-range_for.h"
  18.  
  19. namespace dsx {
  20.  
  21. #if defined(DXX_BUILD_DESCENT_II)
  22. const player &get_player_controlling_guidebot(const d_unique_buddy_state & /* reserved for future use */, const valptridx<player>::array_managed_type &Players)
  23. {
  24.         /* One day, the game may support letting someone other than player 0
  25.          * control the guidebot.  For now, only player 0 will ever control
  26.          * it.
  27.          */
  28.         return Players.front();
  29. }
  30. #endif
  31.  
  32. void player_rw_swap(player_rw *p, int swap)
  33. {
  34.         if (!swap)
  35.                 return;
  36.  
  37.         p->objnum = SWAPINT(p->objnum);
  38.         p->flags = SWAPINT(p->flags);
  39.         p->energy = SWAPINT(p->energy);
  40.         p->shields = SWAPINT(p->shields);
  41.         p->killer_objnum = SWAPSHORT(p->killer_objnum);
  42. #if defined(DXX_BUILD_DESCENT_II)
  43.         p->primary_weapon_flags = SWAPSHORT(p->primary_weapon_flags);
  44. #endif
  45.         p->vulcan_ammo = SWAPSHORT(p->vulcan_ammo);
  46.         for (int i = 0; i < MAX_SECONDARY_WEAPONS; i++)
  47.                 p->secondary_ammo[i] = SWAPSHORT(p->secondary_ammo[i]);
  48.         p->last_score = SWAPINT(p->last_score);
  49.         p->score = SWAPINT(p->score);
  50.         p->time_level = SWAPINT(p->time_level);
  51.         p->time_total = SWAPINT(p->time_total);
  52.         p->cloak_time = SWAPINT(p->cloak_time);
  53.         p->invulnerable_time = SWAPINT(p->invulnerable_time);
  54. #if defined(DXX_BUILD_DESCENT_II)
  55.         p->KillGoalCount = SWAPSHORT(p->KillGoalCount);
  56. #endif
  57.         p->net_killed_total = SWAPSHORT(p->net_killed_total);
  58.         p->net_kills_total = SWAPSHORT(p->net_kills_total);
  59.         p->num_kills_level = SWAPSHORT(p->num_kills_level);
  60.         p->num_kills_total = SWAPSHORT(p->num_kills_total);
  61.         p->num_robots_level = SWAPSHORT(p->num_robots_level);
  62.         p->num_robots_total = SWAPSHORT(p->num_robots_total);
  63.         p->hostages_rescued_total = SWAPSHORT(p->hostages_rescued_total);
  64.         p->hostages_total = SWAPSHORT(p->hostages_total);
  65.         p->homing_object_dist = SWAPINT(p->homing_object_dist);
  66. }
  67. }
  68.  
  69. /*
  70.  * reads a player_ship structure from a PHYSFS_File
  71.  */
  72. void player_ship_read(player_ship *ps, PHYSFS_File *fp)
  73. {
  74.         ps->model_num = PHYSFSX_readInt(fp);
  75.         ps->expl_vclip_num = PHYSFSX_readInt(fp);
  76.         ps->mass = PHYSFSX_readFix(fp);
  77.         ps->drag = PHYSFSX_readFix(fp);
  78.         ps->max_thrust = PHYSFSX_readFix(fp);
  79.         ps->reverse_thrust = PHYSFSX_readFix(fp);
  80.         ps->brakes = PHYSFSX_readFix(fp);
  81.         ps->wiggle = PHYSFSX_readFix(fp);
  82.         ps->max_rotthrust = PHYSFSX_readFix(fp);
  83.         range_for (auto &i, ps->gun_points)
  84.                 PHYSFSX_readVector(fp, i);
  85. }
  86.