Subversion Repositories Games.Descent

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 pmbaty 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 "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
#if defined(DXX_BUILD_DESCENT_I) || defined(DXX_BUILD_DESCENT_II)
42
#include "fwd-segment.h"
43
#include "player-flags.h"
44
#include "valptridx.h"
45
#include <array>
46
 
47
namespace dcx {
48
 
49
struct d_player_unique_endlevel_state
50
{
51
        segnum_t transition_segnum;
52
        segnum_t exit_segnum;
53
};
54
 
55
extern d_player_unique_endlevel_state PlayerUniqueEndlevelState;
56
 
57
// When this structure changes, increment the constant
58
// SAVE_FILE_VERSION in playsave.c
59
struct player : public prohibit_void_ptr<player>
60
{
61
        // Who am I data
62
        callsign_t callsign;   // The callsign of this player, for net purposes.
63
        sbyte   connected;              // Is the player connected or not?
64
        objnum_t     objnum;                 // What object number this player is. (made an int by mk because it's very often referenced)
65
 
66
        //  -- make sure you're 4 byte aligned now!
67
 
68
        // Game data
69
        uint16_t lives;                  // Lives remaining, 0 = game over.
70
        sbyte   level;                  // Current level player is playing. (must be signed for secret levels)
71
        sbyte   starting_level;         // What level the player started on.
72
 
73
        // Statistics...
74
        fix     time_level;             // Level time played
75
        fix     time_total;             // Game time played (high word = seconds)
76
 
77
 
78
        short   num_kills_level;        // Number of kills this level
79
        short   num_kills_total;        // Number of kills total
80
        sbyte   hours_level;            // Hours played (since time_total can only go up to 9 hours)
81
        sbyte   hours_total;            // Hours played (since time_total can only go up to 9 hours)
82
};
83
 
84
DXX_VALPTRIDX_DEFINE_SUBTYPE_TYPEDEFS(player, player);
85
DXX_VALPTRIDX_DEFINE_GLOBAL_FACTORIES(player, player, Players);
86
}
87
 
88
namespace dsx {
89
 
90
// Same as above but structure how Savegames expect
91
struct player_rw
92
{
93
        // Who am I data
94
        callsign_t callsign;   // The callsign of this player, for net purposes.
95
        ubyte   net_address[6];         // The network address of the player.
96
        sbyte   connected;              // Is the player connected or not?
97
        int     objnum;                 // What object number this player is. (made an int by mk because it's very often referenced)
98
        int     n_packets_got;          // How many packets we got from them
99
        int     n_packets_sent;         // How many packets we sent to them
100
 
101
        //  -- make sure you're 4 byte aligned now!
102
 
103
        // Game data
104
        uint    flags;                  // Powerup flags, see below...
105
        fix     energy;                 // Amount of energy remaining.
106
        fix     shields;                // shields remaining (protection)
107
        ubyte   lives;                  // Lives remaining, 0 = game over.
108
        sbyte   level;                  // Current level player is playing. (must be signed for secret levels)
109
        ubyte   laser_level;            // Current level of the laser.
110
        sbyte   starting_level;         // What level the player started on.
111
        short   killer_objnum;          // Who killed me.... (-1 if no one)
112
#if defined(DXX_BUILD_DESCENT_I)
113
        ubyte           primary_weapon_flags;                                   //      bit set indicates the player has this weapon.
114
        ubyte           secondary_weapon_flags;                                 //      bit set indicates the player has this weapon.
115
#elif defined(DXX_BUILD_DESCENT_II)
116
        ushort  primary_weapon_flags;   // bit set indicates the player has this weapon.
117
        ushort  secondary_weapon_flags; // bit set indicates the player has this weapon.
118
#endif
119
        union {
120
                std::array<uint16_t, MAX_PRIMARY_WEAPONS> obsolete_primary_ammo;
121
                struct {
122
                        uint16_t laser_ammo;
123
                        uint16_t vulcan_ammo;
124
                };
125
        };
126
        ushort  secondary_ammo[MAX_SECONDARY_WEAPONS]; // How much ammo of each type.
127
 
128
#if defined(DXX_BUILD_DESCENT_II)
129
        ushort  pad; // Pad because increased weapon_flags from byte to short -YW 3/22/95
130
#endif
131
        //  -- make sure you're 4 byte aligned now
132
 
133
        // Statistics...
134
        int     last_score;             // Score at beginning of current level.
135
        int     score;                  // Current score.
136
        fix     time_level;             // Level time played
137
        fix     time_total;             // Game time played (high word = seconds)
138
 
139
        fix     cloak_time;             // Time cloaked
140
        fix     invulnerable_time;      // Time invulnerable
141
 
142
#if defined(DXX_BUILD_DESCENT_II)
143
        short   KillGoalCount;          // Num of players killed this level
144
#endif
145
        short   net_killed_total;       // Number of times killed total
146
        short   net_kills_total;        // Number of net kills total
147
        short   num_kills_level;        // Number of kills this level
148
        short   num_kills_total;        // Number of kills total
149
        short   num_robots_level;       // Number of initial robots this level
150
        short   num_robots_total;       // Number of robots total
151
        ushort  hostages_rescued_total; // Total number of hostages rescued.
152
        ushort  hostages_total;         // Total number of hostages.
153
        ubyte   hostages_on_board;      // Number of hostages on ship.
154
        ubyte   hostages_level;         // Number of hostages on this level.
155
        fix     homing_object_dist;     // Distance of nearest homing object.
156
        sbyte   hours_level;            // Hours played (since time_total can only go up to 9 hours)
157
        sbyte   hours_total;            // Hours played (since time_total can only go up to 9 hours)
158
} __pack__;
159
#if defined(DXX_BUILD_DESCENT_I)
160
static_assert(sizeof(player_rw) == 116, "wrong size player_rw");
161
#elif defined(DXX_BUILD_DESCENT_II)
162
static_assert(sizeof(player_rw) == 142, "wrong size player_rw");
163
#endif
164
 
165
}
166
 
167
#define get_local_player()      (*vmplayerptr(Player_num))
168
#define get_local_plrobj()      (*vmobjptr(get_local_player().objnum))
169
 
170
namespace dcx {
171
 
172
struct player_ship
173
{
174
        int     model_num;
175
        int     expl_vclip_num;
176
        fix     mass,drag;
177
        fix     max_thrust,reverse_thrust,brakes;       //low_thrust
178
        fix     wiggle;
179
        fix     max_rotthrust;
180
        std::array<vms_vector, N_PLAYER_GUNS> gun_points;
181
};
182
 
183
}
184
 
185
#endif
186
 
187
#endif