2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on
10 * $Logfile: /Freespace2/code/Playerman/ManagePilot.h $
15 * ManagePilot.h is a header file for code to load and save pilot files, and
16 * to select and manage the pilot
19 * Revision 1.2 2002/06/09 04:41:13 relnev
20 * added copyright header
22 * Revision 1.1.1.1 2002/05/03 03:28:12 root
26 * 5 1/12/99 3:15a Dave
27 * Barracks screen support for selecting squad logos. We need real artwork
30 * 4 12/14/98 12:13p Dave
31 * Spiffed up xfer system a bit. Put in support for squad logo file xfer.
34 * 3 10/09/98 5:17p Andsager
35 * move barracks screen into barracks.cpp
37 * 2 10/07/98 10:53a Dave
40 * 1 10/07/98 10:50a Dave
42 * 19 4/27/98 4:56p Hoffoss
43 * Added 'rank pips' to pilot names in barracks screen.
45 * 18 4/19/98 4:05p Dave
46 * Changed main hall region selection. Put an overwrite request in for new
47 * pilots with same callsign as existing pilots. Highlight local player by
48 * default in multi debriefing.
50 * 17 4/09/98 5:43p Dave
51 * Remove all command line processing from the demo. Began work fixing up
52 * the new multi host options screen.
54 * 16 3/25/98 2:16p Dave
55 * Select random default image for newly created pilots. Fixed several
56 * multi-pause messaging bugs. Begin work on online help for multiplayer
59 * 15 12/23/97 12:00p Allender
60 * change write_pilot_file to *not* take is_single as a default parameter.
61 * causing multiplayer pilots to get written to the single player folder
63 * 14 12/22/97 5:08p Hoffoss
64 * Changed inputbox class to be able to accept only certain keys, changed
65 * pilot screens to utilize this feature. Added to assert with pilot file
68 * 13 11/18/97 10:53a Hoffoss
70 * 12 11/12/97 4:40p Dave
71 * Put in multiplayer campaign support parsing, loading and saving. Made
72 * command-line variables better named. Changed some things on the initial
73 * pilot select screen.
75 * 11 11/11/97 4:57p Dave
76 * Put in support for single vs. multiplayer pilots. Began work on
77 * multiplayer campaign saving. Put in initial player select screen
79 * 10 10/24/97 10:59p Hoffoss
80 * Added in create pilot popup window and barracks screen.
82 * 9 10/21/97 7:18p Hoffoss
83 * Overhauled the key/joystick control structure and usage throughout the
84 * entire FreeSpace code. The whole system is very different now.
86 * 8 10/09/97 4:57p Lawrance
87 * store short_callsign in the player struct
89 * 7 12/18/96 10:18a Lawrance
90 * integrating joystick axis configuration
92 * 6 11/13/96 9:03a Lawrance
93 * Capitalized various global varibles
95 * 5 11/13/96 8:40a Lawrance
96 * fixed bug when a new campaign would not clear out the missions played
97 * from the previous campaign
99 * 4 11/05/96 8:30a Lawrance
100 * made backspace work while entering pilots names
102 * 3 11/04/96 2:56p Lawrance
103 * changed the way missions completed are read and written from .PLR file.
105 * 2 11/01/96 3:22p Lawrance
106 * implemented pilot selection, and pilot file save and restore
113 #include "controlsconfig.h"
116 #define VALID_PILOT_CHARS " _-"
118 #define MAX_PILOTS 20
119 #define MAX_PILOT_IMAGES 64
121 // pilot pic image list stuff ( call pilot_load_pic_list() to make these valid )
122 extern char Pilot_images_arr[MAX_PILOT_IMAGES][MAX_FILENAME_LEN];
123 extern char *Pilot_image_names[MAX_PILOT_IMAGES];
124 extern int Num_pilot_images;
126 // squad logo list stuff (call pilot_load_squad_pic_list() to make these valid )
127 extern char Pilot_squad_images_arr[MAX_PILOT_IMAGES][MAX_FILENAME_LEN];
128 extern char *Pilot_squad_image_names[MAX_PILOT_IMAGES];
129 extern int Num_pilot_squad_images;
131 // low-level read/writes to files
132 int read_int(CFILE *file);
133 short read_short(CFILE *file);
134 ubyte read_byte(CFILE *file);
135 void write_int(int i, CFILE *file);
136 void write_short(short s, CFILE *file);
137 void write_byte(ubyte i, CFILE *file);
139 void read_string(char *s, CFILE *f);
140 void write_string(char *s, CFILE *f);
142 // two ways of determining if a given pilot is multiplayer
143 // note, that the first version of this function can possibly return -1 if the file is invalid, etc.
144 int is_pilot_multi(CFILE *fp); // pass a newly opened (at the beginning) file pointer to the pilot file itself
145 int is_pilot_multi(player *p); // pass a pointer to a player struct
147 int verify_pilot_file(const char *filename, int single = 1, int *rank = NULL);
148 int read_pilot_file(const char* callsign, int single = 1, player *p = NULL);
149 int write_pilot_file(player *p = NULL);
151 // function to get default pilot callsign for game
154 void init_new_pilot(player *p, int reset = 1);
156 // load up the list of pilot image filenames (do this at game startup as well as barracks startup)
157 void pilot_load_pic_list();
159 // load up the list of pilot squad filenames
160 void pilot_load_squad_pic_list();
162 // set the truncated version of the callsign in the player struct
163 void pilot_set_short_callsign(player *p, int max_width);
165 // pick a random image for the passed player
166 void pilot_set_random_pic(player *p);
168 // pick a random squad logo for the passed player
169 void pilot_set_random_squad_pic(player *p);
171 // format a pilot's callsign into a "personal" form - ie, adding a 's or just an ' as appropriate
172 void pilot_format_callsign_personal(const char *in_callsign, char *out_callsign);
174 // throw up a popup asking the user to verify the overwrite of an existing pilot name
175 // 1 == ok to overwrite, 0 == not ok
176 int pilot_verify_overwrite();
178 // functions that update player information that is stored in PLR file
179 void update_missions_played(int mission_number);
180 void clear_missions_played();