Debian Codegraph @

Descent3/pilot_class.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/main/pilot_class.h $
21 * $Revision: 17 $
22 * $Date: 3/20/00 12:07p $
23 * $Author: Matt $
24 *
25 * Pilot class and access functions
26 *
27 * $Log: /DescentIII/main/pilot_class.h $
28 *
29 * 17 3/20/00 12:07p Matt
30 * Merge of Duane's post-1.3 changes.
31 * Changed difficulty level to be a global variable instead of a function
32 * call
33 *
34 * 16 10/21/99 9:28p Jeff
35 * B.A. Macintosh code merge
36 *
37 * 15 7/20/99 1:18p Samir
38 * save state of rearviews between game through the pilot file.
39 *
40 * 14 5/02/99 12:56a Jeff
41 * save ship permissions at highest level achieved and use that on restore
42 * to a level previously played
43 *
44 * 13 4/30/99 1:29p Samir
45 * added save for key ramping
46 *
47 * 12 4/27/99 1:56p Jeff
48 * audio taunts stuff in pilot menu, added stringtables
49 *
50 * 11 4/25/99 2:33a Jeff
51 * fixed bug trying to read pilot files that are too new
52 *
53 * 10 4/20/99 7:29p Jeff
54 * added guidebot name
55 *
56 * 9 4/15/99 2:55p Samir
57 * added UI for mouselook.
58 *
59 * 8 4/14/99 3:57a Jeff
60 * fixed case mismatch in #includes
61 *
62 * 7 4/05/99 5:13p Samir
63 * added game toggles.
64 *
65 * 6 4/03/99 2:19a Jeff
66 * added profanity filter stuff
67 *
68 * 5 3/22/99 6:22p Jeff
69 * added 2 more audio taunts. a mulitplayer event when someone plays an
70 * audio taunt. option to disable audio taunts.
71 *
72 * 4 3/15/99 9:24p Gwar
73 *
74 * 3 2/18/99 5:56p Jeff
75 * added weapon select data
76 *
77 * 2 2/15/99 7:50p Jeff
78 * new pilot file class and read/write system checked in...should be more
79 * robust than old
80 *
81 * 1 2/15/99 3:18a Jeff
82 * initial creation
83 *
84 * $NoKeywords: $
85 */
86
87 #ifndef __PILOT_CLASS_H_
88 #define __PILOT_CLASS_H_
89
90 #include "pstypes.h"
91 #include "controls.h"
92 #include "Controller.h"
93 #include "cfile.h"
94 #include "weapon.h"
95 #include "config.h"
96
97 // YUCK!
98 #include "descent.h" //just for MSN_NAMELEN
99
100 /*
101 =======================================================================
102
103 IIIIIIIII MM MM PPPP OOOO RRRR TTTTTTT AA NN NN TTTTTTT
104 II MM MM P P O O R R T AA NNN NN T
105 II M M M M P P O O R R T A A NN N NN T
106 II M M M M P P O O R R T A A NN N NN T
107 II M M M M PPP O O RRR T AAAAAA NN NNN T
108 II M M M P O O R R T A A NN NNN T
109 IIIIIIIII N N P OOOO R R T A A NN NN T
110
111 =======================================================================
112
113 If you add new data members to the pilot class, you _must_ do the following:
114
115 1) Add functionality to the pilot::initialize();
116 2) Add functionality to the pilot::clean();
117 3) Add functionality to the pilot::verify();
118 4) Create a pilot::write_ function
119 5) Create a corresponding pilot::read_ function
120 6) Add to calls to your write_ and read_ functions in pilot::flush() and pilot::read()
121 */
122
123 // Maximum size of the pilot name
124 #define PILOT_STRING_SIZE 20
125 // Invalid Pilot Pic ID
126 #define PPIC_INVALID_ID 65535
127 // should be put somewhere else, but here for the demo.
128 #define N_MOUSE_AXIS 2
129 #define N_JOY_AXIS 6
130
131 // Number of multiplayer taunts
132 #define MAX_PILOT_TAUNTS 8
133 // Maximum string length of a taunt
134 #define PILOT_TAUNT_SIZE 60
135
136 // file error codes
137 #define PLTW_NO_ERROR 0 // there was no error
138 #define PLTW_NO_FILENAME 1 // no filename has been set
139 #define PLTW_FILE_EXISTS 2 // the file already exists
140 #define PLTW_FILE_CANTOPEN 3 // file couldn't be opened
141 #define PLTW_CFILE_FATAL 4 // a CFILE error had occurred
142 #define PLTW_UNKNOWN_FATAL 5 // an unknown exception occurred
143
144 #define PLTR_NO_ERROR 0 // there was no error
145 #define PLTR_NO_FILENAME 1 // no filename has been set
146 #define PLTR_FILE_NOEXIST 2 // the file doesn't exist to read
147 #define PLTR_FILE_CANTOPEN 3 // file couldn't be opened
148 #define PLTR_CFILE_FATAL 4 // a CFILE error had occurred
149 #define PLTR_UNKNOWN_FATAL 5 // an uknown exception occurred
150 #define PLTR_TOO_NEW 6 // pilot file too new
151
152 struct tMissionData {
153 uint8_t highest_level; // highlest level completed in the mission
154 int ship_permissions; // Ship permissions at highest level achieved
155 bool finished; // was mission finished? (different than highest level,btw)
156 char mission_name[MSN_NAMELEN]; // name of the mission (from the mission file)
157 int num_restores; // number of game loads for this mission
158 int num_saves; // number of game saves for this mission
159 };
160
161 struct cntrldata {
162 int id;
163 ct_type type[2];
164 ct_config_data value;
165 uint8_t flags[2];
166 };
167
168 class pilot {
169
170 public:
171 ~pilot();
172 pilot();
173 pilot(pilot *copy);
174 pilot(char *fname);
175
176 // This function guts the data so it's virgin (fresh for reading)
177 // frees any memory that needs to be freed, etc.
178 // if reset is true, it resets all data to what it is at initialization
179 // else it is an unknown state
180 void clean(bool reset = true);
181
182 // This function verifies all the pilot data, making sure nothing is out of whack
183 // It will correct any messed data.
184 void verify(void);
185
186 // This function makes the pilot file so it's write pending, meaning that
187 // on the next call to flush, it will actually write out the data. There is
188 // no need to constantly do file access unless it's really needed
189 void write(void);
190
191 // This function makes certain that the pilot data is up to date with the
192 // actual pilot file, writing if needed.
193 int flush(bool new_file);
194
195 // This function sets the filename that is associated with this pilot
196 void set_filename(char *fname);
197 void get_filename(char *fname);
198
199 // This function reads in the data from file (from the filename associated)
200 // into the pilot data.
201 int read(bool skip_control_set, bool skip_mission_data);
202
203 public:
204 // data access functions
205 void set_name(const char *name);
206 void get_name(char *name);
207
208 void set_ship(const char *ship);
209 void get_ship(char *ship);
210
211 void set_multiplayer_data(const char *logo = NULL, const char *audio1 = NULL, const char *audio2 = NULL, const uint16_t *ppic = NULL,
212 const char *audio3 = NULL, const char *audio4 = NULL);
213 void get_multiplayer_data(char *logo = NULL, char *audio1 = NULL, char *audio2 = NULL, uint16_t *ppic = NULL,
214 char *audio3 = NULL, char *audio4 = NULL);
215
216 void set_difficulty(uint8_t diff);
217 void get_difficulty(uint8_t *diff);
218
219 void set_hud_data(uint8_t *hmode = NULL, uint16_t *hstat = NULL, uint16_t *hgraphicalstat = NULL, int *gw_w = NULL,
220 int *gw_h = NULL);
221 void get_hud_data(uint8_t *hmode = NULL, uint16_t *hstat = NULL, uint16_t *hgraphicalstat = NULL, int *gw_w = NULL,
222 int *gw_h = NULL);
223
224 void set_profanity_filter(bool enable);
225 void get_profanity_filter(bool *enabled);
226
227 void set_audiotaunts(bool enable);
228 void get_audiotaunts(bool *enabled);
229
230 void set_guidebot_name(char *name);
231 void get_guidebot_name(char *name);
232
233 void add_mission_data(tMissionData *data);
234 void edit_mission_data(int index, tMissionData *data);
235 void get_mission_data(int index, tMissionData *data);
236 int find_mission_data(const char *mission_name);
237
238 private:
239 void initialize(void); // initializes all the data (for constructors)
240 bool write_pending; // data has changed and pilot data is out of sync with file
241 private:
242 // internal file access functions
243 void write_name(CFILE *file);
244 void write_ship_info(CFILE *file);
245 void write_custom_multiplayer_data(CFILE *file);
246 void write_difficulty(CFILE *file);
247 void write_hud_data(CFILE *file);
248 void write_mission_data(CFILE *file);
249 void write_taunts(CFILE *file);
250 void write_weapon_select(CFILE *file);
251 void write_controls(CFILE *file);
252 void write_profanity_filter(CFILE *file);
253 void write_audiotaunts(CFILE *file);
254 void write_gameplay_toggles(CFILE *file);
255 void write_guidebot_name(CFILE *file);
256
257 // for the read functions, skip is true if the data should actually
258 // just be skipped and not processed
259 int file_version;
260 void read_name(CFILE *file, bool skip);
261 void read_ship_info(CFILE *file, bool skip);
262 void read_custom_multiplayer_data(CFILE *file, bool skip);
263 void read_difficulty(CFILE *file, bool skip);
264 void read_hud_data(CFILE *file, bool skip);
265 void read_mission_data(CFILE *file, bool skip);
266 void read_taunts(CFILE *file, bool skip);
267 void read_weapon_select(CFILE *file);
268 void read_controls(CFILE *file, bool skip);
269 void read_profanity_filter(CFILE *file, bool skip);
270 void read_audiotaunts(CFILE *file, bool skip);
271 void read_gameplay_toggles(CFILE *file, bool skip);
272 void read_guidebot_name(CFILE *file, bool skip);
273
274 private:
275 //--- Pilot data ---//
276 //--- Try to preserve alignment ---//
277 char *filename; // filename location of this pilot
278 char *name; // name of the pilot (used in the game)
279 char *ship_logo; // ship logo for multiplayer play (filename)
280 char *ship_model; // what ship does this pilot fly
281 char *audio1_file; // audio taunt #1 (filename)
282 char *audio2_file; // audio taunt #2 (filename)
283 char *audio3_file; // audio taunt #1 (filename)
284 char *audio4_file; // audio taunt #2 (filename)
285 char *guidebot_name; // guidebot name
286
287 uint16_t picture_id; // pilot picture image id
288 uint8_t difficulty; // difficulty setting for this pilot (DIFFICULTY_*)
289 uint8_t hud_mode; // hud display mode
290 bool profanity_filter_on, audiotaunts;
291
292 uint16_t hud_stat; // hud layout using the STAT mask
293 uint16_t hud_graphical_stat;
294
295 int game_window_w, game_window_h; // game window size
296
297 int num_missions_flown; // number of mission's flown
298 tMissionData *mission_data; // mission data
299
300 uint16_t PrimarySelectList[MAX_PRIMARY_WEAPONS];
301 uint16_t SecondarySelectList[MAX_SECONDARY_WEAPONS];
302
303 tGameToggles gameplay_toggles; // special options in config menu.
304
305 public:
306 char taunts[MAX_PILOT_TAUNTS][PILOT_TAUNT_SIZE]; // taunt macros
307
308 cntrldata controls[NUM_CONTROLLER_FUNCTIONS]; // controller settings
309 float mouse_sensitivity[N_MOUSE_AXIS]; // axis sensitivities
310 float joy_sensitivity[N_JOY_AXIS]; // axis sensitivities
311 float key_ramping;
312 char read_controller; // do we read the controller port also (beyond keyboard/mouse)
313 bool mouselook_control; // mouselook control.
314 bool lrearview_enabled;
315 bool rrearview_enabled; // are these small views enabled?
316
317 uint8_t ingame_difficulty; // DAJ for optimization
318 };
319
320 #endif