| 1 |
/* |
| 2 |
* Portions of this file are copyright Rebirth contributors and licensed as |
| 3 |
* described in COPYING.txt. |
| 4 |
* Portions of this file are copyright Parallax Software and licensed |
| 5 |
* according to the Parallax license below. |
| 6 |
* See COPYING.txt for license details. |
| 7 |
|
| 8 |
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX |
| 9 |
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO |
| 10 |
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A |
| 11 |
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS |
| 12 |
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS |
| 13 |
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE |
| 14 |
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE |
| 15 |
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS |
| 16 |
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. |
| 17 |
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. |
| 18 |
*/ |
| 19 |
|
| 20 |
/* |
| 21 |
* |
| 22 |
* Structure information for the player |
| 23 |
* |
| 24 |
*/ |
| 25 |
|
| 26 |
#pragma once |
| 27 |
|
| 28 |
#include "fwd-player.h" |
| 29 |
|
| 30 |
#include <physfs.h> |
| 31 |
#include "vecmat.h" |
| 32 |
#include "fwd-weapon.h" |
| 33 |
|
| 34 |
#ifdef __cplusplus |
| 35 |
#include <algorithm> |
| 36 |
#include "pack.h" |
| 37 |
#include "dxxsconf.h" |
| 38 |
#include "objnum.h" |
| 39 |
#include "player-callsign.h" |
| 40 |
|
| 41 |
#ifdef DXX_BUILD_DESCENT |
| 42 |
#include "fwd-segment.h" |
| 43 |
#include "player-flags.h" |
| 44 |
#include "valptridx.h" |
| 45 |
#include <array> |
| 46 |
|
| 47 |
namespace dcx { |
| 48 |
|
| 49 |
enum class player_connection_status : uint8_t |
| 50 |
{ |
| 51 |
disconnected, |
| 52 |
playing, |
| 53 |
waiting, |
| 54 |
died_in_mine, |
| 55 |
found_secret, |
| 56 |
escape_tunnel, |
| 57 |
end_menu, |
| 58 |
}; |
| 59 |
|
| 60 |
enum class team_number : uint8_t |
| 61 |
{ |
| 62 |
blue, |
| 63 |
red, |
| 64 |
}; |
| 65 |
|
| 66 |
enum class player_gun_number : uint8_t |
| 67 |
{ |
| 68 |
_0, |
| 69 |
_1, |
| 70 |
_2, |
| 71 |
_3, |
| 72 |
_4, |
| 73 |
center = 6, |
| 74 |
_7, |
| 75 |
}; |
| 76 |
|
| 77 |
struct d_player_unique_endlevel_state |
| 78 |
{ |
| 79 |
segnum_t transition_segnum; |
| 80 |
segnum_t exit_segnum; |
| 81 |
}; |
| 82 |
|
| 83 |
extern d_player_unique_endlevel_state PlayerUniqueEndlevelState; |
| 84 |
|
| 85 |
// When this structure changes, increment the constant |
| 86 |
// SAVE_FILE_VERSION in playsave.c |
| 87 |
struct player : public prohibit_void_ptr<player> |
| 88 |
{ |
| 89 |
// Who am I data |
| 90 |
callsign_t callsign; // The callsign of this player, for net purposes. |
| 91 |
player_connection_status connected; // Is the player connected or not? |
| 92 |
objnum_t objnum; // What object number this player is. (made an int by mk because it's very often referenced) |
| 93 |
|
| 94 |
// -- make sure you're 4 byte aligned now! |
| 95 |
|
| 96 |
// Game data |
| 97 |
uint16_t lives; // Lives remaining, 0 = game over. |
| 98 |
sbyte level; // Current level player is playing. (must be signed for secret levels) |
| 99 |
sbyte starting_level; // What level the player started on. |
| 100 |
|
| 101 |
// Statistics... |
| 102 |
fix time_level; // Level time played |
| 103 |
fix time_total; // Game time played (high word = seconds) |
| 104 |
|
| 105 |
|
| 106 |
short num_kills_level; // Number of kills this level |
| 107 |
short num_kills_total; // Number of kills total |
| 108 |
uint8_t hours_level; // Hours played (since time_total can only go up to 9 hours) |
| 109 |
uint8_t hours_total; // Hours played (since time_total can only go up to 9 hours) |
| 110 |
}; |
| 111 |
|
| 112 |
DXX_VALPTRIDX_DEFINE_SUBTYPE_TYPEDEFS(player, player); |
| 113 |
DXX_VALPTRIDX_DEFINE_GLOBAL_FACTORIES(player, player, Players); |
| 114 |
} |
| 115 |
|
| 116 |
namespace dsx { |
| 117 |
|
| 118 |
// Same as above but structure how Savegames expect |
| 119 |
struct player_rw |
| 120 |
{ |
| 121 |
// Who am I data |
| 122 |
callsign_t callsign; // The callsign of this player, for net purposes. |
| 123 |
ubyte net_address[6]; // The network address of the player. |
| 124 |
uint8_t connected; // Is the player connected or not? |
| 125 |
int objnum; // What object number this player is. (made an int by mk because it's very often referenced) |
| 126 |
int n_packets_got; // How many packets we got from them |
| 127 |
int n_packets_sent; // How many packets we sent to them |
| 128 |
|
| 129 |
// -- make sure you're 4 byte aligned now! |
| 130 |
|
| 131 |
// Game data |
| 132 |
uint flags; // Powerup flags, see below... |
| 133 |
fix energy; // Amount of energy remaining. |
| 134 |
fix shields; // shields remaining (protection) |
| 135 |
ubyte lives; // Lives remaining, 0 = game over. |
| 136 |
sbyte level; // Current level player is playing. (must be signed for secret levels) |
| 137 |
ubyte laser_level; // Current level of the laser. |
| 138 |
sbyte starting_level; // What level the player started on. |
| 139 |
short killer_objnum; // Who killed me.... (-1 if no one) |
| 140 |
#if DXX_BUILD_DESCENT == 1 |
| 141 |
ubyte primary_weapon_flags; // bit set indicates the player has this weapon. |
| 142 |
ubyte secondary_weapon_flags; // bit set indicates the player has this weapon. |
| 143 |
#elif DXX_BUILD_DESCENT == 2 |
| 144 |
ushort primary_weapon_flags; // bit set indicates the player has this weapon. |
| 145 |
ushort secondary_weapon_flags; // bit set indicates the player has this weapon. |
| 146 |
#endif |
| 147 |
union { |
| 148 |
std::array<uint16_t, MAX_PRIMARY_WEAPONS> obsolete_primary_ammo; |
| 149 |
struct { |
| 150 |
uint16_t laser_ammo; |
| 151 |
uint16_t vulcan_ammo; |
| 152 |
}; |
| 153 |
}; |
| 154 |
ushort secondary_ammo[MAX_SECONDARY_WEAPONS]; // How much ammo of each type. |
| 155 |
|
| 156 |
#if DXX_BUILD_DESCENT == 2 |
| 157 |
ushort pad; // Pad because increased weapon_flags from byte to short -YW 3/22/95 |
| 158 |
#endif |
| 159 |
// -- make sure you're 4 byte aligned now |
| 160 |
|
| 161 |
// Statistics... |
| 162 |
int last_score; // Score at beginning of current level. |
| 163 |
int score; // Current score. |
| 164 |
fix time_level; // Level time played |
| 165 |
fix time_total; // Game time played (high word = seconds) |
| 166 |
|
| 167 |
fix cloak_time; // Time cloaked |
| 168 |
fix invulnerable_time; // Time invulnerable |
| 169 |
|
| 170 |
#if DXX_BUILD_DESCENT == 2 |
| 171 |
short KillGoalCount; // Num of players killed this level |
| 172 |
#endif |
| 173 |
short net_killed_total; // Number of times killed total |
| 174 |
short net_kills_total; // Number of net kills total |
| 175 |
short num_kills_level; // Number of kills this level |
| 176 |
short num_kills_total; // Number of kills total |
| 177 |
short num_robots_level; // Number of initial robots this level |
| 178 |
short num_robots_total; // Number of robots total |
| 179 |
ushort hostages_rescued_total; // Total number of hostages rescued. |
| 180 |
ushort hostages_total; // Total number of hostages. |
| 181 |
ubyte hostages_on_board; // Number of hostages on ship. |
| 182 |
ubyte hostages_level; // Number of hostages on this level. |
| 183 |
fix homing_object_dist; // Distance of nearest homing object. |
| 184 |
sbyte hours_level; // Hours played (since time_total can only go up to 9 hours) |
| 185 |
sbyte hours_total; // Hours played (since time_total can only go up to 9 hours) |
| 186 |
} __pack__; |
| 187 |
#if DXX_BUILD_DESCENT == 1 |
| 188 |
static_assert(sizeof(player_rw) == 116, "wrong size player_rw"); |
| 189 |
#elif DXX_BUILD_DESCENT == 2 |
| 190 |
static_assert(sizeof(player_rw) == 142, "wrong size player_rw"); |
| 191 |
#endif |
| 192 |
|
| 193 |
} |
| 194 |
|
| 195 |
#define get_local_player() (*vmplayerptr(Player_num)) |
| 196 |
#define get_local_plrobj() (*vmobjptr(get_local_player().objnum)) |
| 197 |
|
| 198 |
namespace dcx { |
| 199 |
|
| 200 |
struct player_ship |
| 201 |
{ |
| 202 |
polygon_model_index model_num; |
| 203 |
vclip_index expl_vclip_num; |
| 204 |
fix mass,drag; |
| 205 |
fix max_thrust,reverse_thrust,brakes; //low_thrust |
| 206 |
fix wiggle; |
| 207 |
fix max_rotthrust; |
| 208 |
enumerated_array<vms_vector, /* N_PLAYER_GUNS = */ 8, player_gun_number> gun_points; |
| 209 |
}; |
| 210 |
|
| 211 |
} |
| 212 |
|
| 213 |
/* |
| 214 |
* reads a player_ship structure from a PHYSFS_File |
| 215 |
*/ |
| 216 |
void player_ship_read(player_ship *ps, NamedPHYSFS_File fp); |
| 217 |
|
| 218 |
#endif |
| 219 |
|
| 220 |
#endif |