Debian Codegraph @

Descent3/pilot.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.h $
21 * $Revision: 47 $
22 * $Date: 5/02/99 12:55a $
23 * $Author: Jeff $
24 *
25 * Player/Pilot configuration
26 *
27 * $Log: /DescentIII/main/pilot.h $
28 *
29 * 47 5/02/99 12:55a Jeff
30 * save ship permissions at highest level achieved and use that on restore
31 * to a level previously played
32 *
33 * 46 3/23/99 12:45p Jeff
34 * added preset control selection for pilot
35 *
36 * 45 3/22/99 6:22p Jeff
37 * added 2 more audio taunts. a mulitplayer event when someone plays an
38 * audio taunt. option to disable audio taunts.
39 *
40 * 44 3/15/99 9:25p Gwar
41 *
42 * 43 3/15/99 4:31p Jeff
43 * fixed some memory leaks
44 *
45 * 42 2/27/99 4:18p Jeff
46 * added support for .pld files (used to copy pilot default controls),
47 * audio taunt size import error fixed...removed dead code
48 *
49 * 41 2/25/99 4:30p Jeff
50 * mission data of pilot keeps track of all missions, not just after you
51 * beat a level
52 *
53 * 40 2/20/99 3:44a Jeff
54 * some more updates and bug fixes
55 *
56 * 39 2/15/99 7:50p Jeff
57 * new pilot file class and read/write system checked in...should be more
58 * robust than old
59 *
60 * 38 1/11/99 4:08p Jason
61 * added multiplayer taunt macros
62 *
63 * 37 12/16/98 1:57p Samir
64 * added finished field to mission data structure.
65 *
66 * 36 12/15/98 4:28p Jeff
67 * added mission data information to the pilot files to save what the
68 * highest level they achieved on a mission is. Added level select dialog
69 * (not hooked up) and level warp cheat.
70 *
71 * 35 12/03/98 11:06a Samir
72 * added axis sensitivity
73 *
74 * 34 12/01/98 5:47p Jeff
75 * created pilot picture selection dialog
76 *
77 * 33 11/30/98 11:57a Jeff
78 * fixed bug, allowing unlimited pilots
79 *
80 * 32 10/22/98 2:58p Chris
81 * Difficulty levels are in beta
82 *
83 * 31 10/21/98 11:54p Samir
84 * fixed typos.
85 *
86 * 30 10/21/98 7:15p Samir
87 * added joy and mouse sensitivities for pilot.
88 *
89 * 29 10/17/98 7:31p Samir
90 * added invertible axes
91 *
92 * 28 10/15/98 1:36p Jeff
93 * allow cancel out of pilot select menu
94 *
95 * 27 10/14/98 6:39p Samir
96 * save screen size for game.
97 *
98 * 26 10/12/98 3:02p Jeff
99 * added a verify function, give warning when they go into Multiplayer
100 * ship customize with a bad ship
101 *
102 * 25 10/08/98 6:41p Jeff
103 * when creating your first pilot it immediatly returns you to main menu
104 *
105 * 24 9/08/98 11:41a Jeff
106 * new pilot selection interface
107 *
108 * 23 9/04/98 3:52p Jeff
109 * changes made from UI meeting
110 *
111 * 22 9/04/98 1:20p Jeff
112 * updates to ship selection, now includes audio taunts, strips crc's from
113 * filenames when displaying
114 *
115 * 21 8/29/98 6:53p Jeff
116 * added single-player ship selection
117 *
118 * 20 7/27/98 6:26p Jeff
119 * basic implementation of ship configurations...needs to be purtied up
120 *
121 * 19 6/24/98 7:36p Samir
122 * made pilot structure cleaner.
123 *
124 * 18 6/19/98 5:39p Samir
125 * save out hud mode too.
126 *
127 * 17 6/19/98 3:30p Samir
128 * added hud layout info in pilot file.
129 *
130 * 16 6/18/98 4:48p Samir
131 * added changes for multiple configs for joystick controls.
132 *
133 * 15 6/17/98 3:28p Jeff
134 * localization changes. made an init function
135 *
136 * 14 5/24/98 2:56a Jeff
137 * Pilot dialogs up to date
138 *
139 * 13 4/23/98 11:14p Samir
140 * added read_controller flag to pilot.cpp
141 *
142 * 12 4/01/98 3:34p Jeff
143 * ship_model is now a string
144 *
145 * 11 3/20/98 1:19p Jeff
146 * Changes made to use Default_pilot string for pilot filename to use.
147 *
148 * 10 3/19/98 6:58p Jeff
149 * Pilot stuff reads and writes to the correct directories
150 *
151 * 9 3/13/98 8:55p Jeff
152 * Various changes to move control configuration into Pilot file
153 *
154 * 8 3/12/98 2:00p Jeff
155 * Various changes to improve pilot dialogs
156 *
157 * 7 3/10/98 7:08p Jeff
158 * Various changes due to new window class
159 *
160 * 6 3/10/98 11:57a Jeff
161 * Corrected some function comments and made '.' a valid filename
162 * character
163 *
164 * 5 3/10/98 11:50a Jeff
165 * Added filename field to pilot structure, which keeps track of the pilot
166 * filename...fixes any bugs that come with renaming a file. Made changes
167 * to take advantage of this.
168 *
169 * 4 3/09/98 6:27p Jeff
170 * Cleaned up code, made file operations more robust, pretty sturdy now
171 *
172 * 3 3/06/98 6:32p Jeff
173 * Added Pilot files and major functionality
174 *
175 * 2 3/05/98 4:28p Jeff
176 * Initial creation
177 *
178 * $NoKeywords: $
179 */
180
181 #ifndef __PILOT_H_
182 #define __PILOT_H_
183
184 #include <stdlib.h>
185 #include "pilot_class.h"
186
187 /*
188 #include "controls.h"
189 #include "Controller.h"
190 #include "ship.h"
191
192 #define PILOT_STRING_SIZE 20
193 #define PPIC_INVALID_ID 65535
194
195 //errors reported by PltWriteFile()
196 #define PLT_FILE_FATAL -3 //can't open file, possibly out of hd space
197 #define PLT_FILE_CANT_CREATE -2 //bad filename, most likely 0 length string for filename
198 #define PLT_FILE_EXISTS -1 //file already exists (will only return this if newpilot=true on
199 PltWriteFile #define PLT_FILE_NOERR 0 //no errors, success
200
201 // should be put somewhere else, but here for the demo.
202 #define N_MOUSE_AXIS 2
203 #define N_JOY_AXIS 6
204
205 #define MAX_PILOT_TAUNTS 8
206 #define PILOT_TAUNT_SIZE 60
207
208 struct cntrldata
209 {
210 int id;
211 ct_type type[2];
212 ct_config_data value;
213 uint8_t flags[2];
214 };
215
216 struct
217 {
218 uint8_t highest_level;
219 bool finished; // was mission finished?
220 (different than highest level,btw) char mission_name[MSN_NAMELEN]; } tMissionData;
221
222 struct
223 {
224 char filename[_MAX_FNAME]; //added because of some weird .plt renaming bugs that can happen
225 //not saved out
226 //Name of the Pilot
227 char name[PILOT_STRING_SIZE];
228 //number of kills and number of times killed
229 int kills,deaths;
230 //name of ship model
231 char ship_model[PAGENAME_LEN];
232 //filename of custom texture
233 char ship_logo[PAGENAME_LEN];
234 //filename of audio taunt 1 (including CRC)
235 char audio1_file[PAGENAME_LEN];
236 //filename of audio taunt 2 (including CRC)
237 char audio2_file[PAGENAME_LEN];
238 //difficulty setting (DIFFICULTY_*)
239 char difficulty;
240 //controller settings
241 cntrldata controls[NUM_CONTROLLER_FUNCTIONS];
242 // hud layout using the STAT mask
243 uint16_t hud_stat;
244 uint16_t hud_graphical_stat;
245 // hud display mode
246 uint8_t hud_mode;
247 // do we read the controller port also (beyond keyboard/mouse)
248 char read_controller;
249 // axis sensitivities
250 float mouse_sensitivity[N_MOUSE_AXIS], joy_sensitivity[N_JOY_AXIS];
251
252 int game_window_w, game_window_h;
253
254 //pilot picture image id
255 uint16_t picture_id;
256
257 //number of mission's flown
258 int num_missions_flown;
259 tMissionData *mission_data;
260
261 // taunt macros
262 char taunts[MAX_PILOT_TAUNTS][PILOT_TAUNT_SIZE];
263
264 }pilot;
265 */
266
267 // PilotSelect
268 //
269 // Brings up a window where you can select a pilot to use
270 void PilotSelect(void);
271
272 // Display the pilot display/selection screen
273 // void PilotDisplay(bool forceselection = false);
274
275 // brings up the configuration screen for a pilot
276 // Returns: true on success
277 // Pilot: pointer to pilot to configure
278 // newpilot: true if this is a new pilot, false if an existing pilot
279 bool PilotConfig(pilot *Pilot, bool newpilot, bool forceok = false);
280
281 // creates a new pilot (and pilot file) (if you call this you should call PilotConfig() after it)
282 // Returns: true on success
283 // Pilot: pointer to pilot structure to be filled in with name and filename (should then configure the rest)
284 bool PilotCreate(pilot *Pilot, bool dontallowcancel);
285
286 // copies a pilot to another
287 bool PilotCopy(pilot *Src, pilot *Dest);
288
289 // Write a Pilot out to file
290 // Pilot - Pilot to write (filename field is root of filename extension .plt)
291 // Make sure both filename and name are filled in before calling
292 // newpilot - Whether it is supposed to create a new file
293 // false = overwrite existing file
294 // true = don't overwrite any existing file, returns error if so
295 // Returns: PLT_FILE_*
296 int PltWriteFile(pilot *Pilot, bool newpilot = false);
297
298 // Reads a Pilot from file
299 // Pilot - pointer to structure to fill in...
300 // MAKE SURE filename field is filled in with correct filename to read in before calling!!
301 // keyconfig - whether to set the controls on load
302 void PltReadFile(pilot *Pilot, bool keyconfig = false, bool missiondata = false);
303
304 // Given a string it will make a valid filename out of it
305 void PltMakeFNValid(char *name);
306
307 void PilotInit(void);
308
309 void PltClearList(void);
310 char **PltGetPilots(int *count, char *ignore_filename = NULL, int display_default_configs = 0);
311 void PltGetPilotsFree(void);
312
313 // VerifyPilotData
314 //
315 // Call this function to check the data that is in the given pilot struct...it will verify that all files
316 // listed are available, if they are not, then it will set them to defaults. Returns true if it had to
317 // fix the data (you may want to save the pilot immediatly)
318 bool VerifyPilotData(pilot *Pilot);
319
320 // updates the current pilot's information (level played, mission played, etc)
321 // call after every successful mission completion (by passing false)
322 // call when a mission is loaded (pass true)
323 void CurrentPilotUpdateMissionStatus(bool just_add_data = false);
324
325 // gets highest level flown for mission
326 int PilotGetHighestLevelAchieved(pilot *Pilot, char *mission_name);
327 int GetPilotShipPermissions(pilot *Pilot, const char *mission_name);
328
329 bool HasPilotFinishedMission(pilot *Pilot, const char *mission_name);
330 bool HasPilotFlownMission(pilot *Pilot, const char *mission_name);
331
332 extern pilot Current_pilot;
333 extern char Default_pilot[_MAX_PATH];
334
335 // "Current Pilot" access functions
336 void dCurrentPilotName(char *buffer);
337 uint8_t dCurrentPilotDifficulty(void);
338
339 void IncrementPilotRestoredGamesForMission(pilot *Pilot, const char *mission_name);
340 void IncrementPilotSavedGamesForMission(pilot *Pilot, const char *mission_name);
341 int GetPilotNumRestoredGamesForMission(pilot *Pilot, const char *mission_name);
342 int GetPilotNumSavedGamesForMission(pilot *Pilot, const char *mission_name);
343
344 #endif