]> icculus.org git repositories - taylor/freespace2.git/blob - include/management.h
Initial revision
[taylor/freespace2.git] / include / management.h
1 /*
2  * $Logfile: /Freespace2/code/Fred2/Management.h $
3  * $Revision$
4  * $Date$
5  * $Author$
6  *
7  * This file handles the management of Objects, Ships, Wings, etc.  Basically
8  * all the little structures we have that usually inter-relate that need to
9  * be handled in a standard way, and thus should be handled by a single
10  * function.
11  *
12  * $Log$
13  * Revision 1.1  2002/05/03 03:28:12  root
14  * Initial revision
15  *
16  * 
17  * 6     5/20/99 6:59p Dave
18  * Added alternate type names for ships. Changed swarm missile table
19  * entries.
20  * 
21  * 5     4/07/99 6:21p Dave
22  * Fred and Freespace support for multiple background bitmaps and suns.
23  * Fixed link errors on all subprojects. Moved encrypt_init() to
24  * cfile_init() and lcl_init(), since its safe to call twice.
25  * 
26  * 4     3/20/99 5:09p Dave
27  * Fixed release build fred warnings and unhandled exception.
28  * 
29  * 3     10/29/98 10:41a Dave
30  * Change the way cfile initializes exe directory.
31  * 
32  * 2     10/07/98 6:28p Dave
33  * Initial checkin. Renamed all relevant stuff to be Fred2 instead of
34  * Fred. Globalized mission and campaign file extensions. Removed Silent
35  * Threat specific code.
36  * 
37  * 1     10/07/98 3:01p Dave
38  * 
39  * 1     10/07/98 3:00p Dave
40  * 
41  * 56    12/05/97 4:07p Hoffoss
42  * Changed code to allow WHO_FROM type ship sources to only show flyable
43  * ships in list.
44  * 
45  * 55    11/21/97 2:55p Hoffoss
46  * Added Nebula support to Fred.  Implemented loading and saving nebula
47  * info to/from mission files.
48  * 
49  * 54    11/17/97 6:41p Lawrance
50  * moved bitmask_2_bitnum to ship lib
51  * 
52  * 53    11/11/97 2:13p Allender
53  * docking bay support for Fred and Freespace.  Added hook to ai code for
54  * arrival/departure from dock bays.  Fred support now sufficient.
55  * 
56  * 52    10/08/97 11:47a Hoffoss
57  * Added better fred handling of Weaponry_pool.
58  * 
59  * 51    9/16/97 9:41p Hoffoss
60  * Changed Fred code around to stop using Parse_player structure for
61  * player information, and use actual ships instead.
62  * 
63  * 50    9/09/97 10:29a Hoffoss
64  * Added support for neutral team, and fixed changes made to how team is
65  * used in ship structure.
66  * 
67  * 49    8/22/97 4:16p Hoffoss
68  * added support for arrival and departure info in ship editor using
69  * wing's info if editing marked ships in a wing instead of using ship's.
70  * 
71  * 48    8/17/97 10:22p Hoffoss
72  * Fixed several bugs in Fred with Undo feature.  In the process, recoded
73  * a lot of CFile.cpp.
74  * 
75  * 47    8/16/97 9:24p Hoffoss
76  * Added support for team of players in multiplayer.
77  * 
78  * 46    8/16/97 4:51p Hoffoss
79  * Fixed bugs with wing deletion and removing ships from a wing.
80  * 
81  * 45    8/16/97 2:02a Hoffoss
82  * Made docked objects move together in Fred.
83  * 
84  * 44    8/15/97 5:14p Hoffoss
85  * Completely changed around how initial orders dialog worked.  It's
86  * pretty awesome now.
87  * 
88  * 43    8/15/97 11:09a Hoffoss
89  * Created a list of order types that can be used for several things, and
90  * yet easily changable.  Added order error checking against ship types.
91  * 
92  * 42    8/14/97 2:32p Hoffoss
93  * fixed bug where controlling an object doesn't cause screen updates, and
94  * added a number of cool features to viewpoint/control object code.
95  * 
96  * 41    8/12/97 3:33p Hoffoss
97  * Fixed the "press cancel to go to reference" code to work properly.
98  * 
99  * 40    8/12/97 1:55a Hoffoss
100  * Made extensive changes to object reference checking and handling for
101  * object deletion call.
102  * 
103  * 39    8/08/97 1:31p Hoffoss
104  * Added syncronization protection to cur_object_index changes.
105  * 
106  * 38    8/05/97 5:12p Jasen
107  * Added advanced_stricmp() function to handle NULL pointers gracefully,
108  * and utilized it in message editor query update function.
109  * 
110  * 37    8/05/97 1:28p Hoffoss
111  * Fixed bug: if dockee ship deleted, docker becomes undocked.  Other
112  * little changes.
113  * 
114  * 36    7/09/97 2:38p Allender
115  * organized ship/wing editor dialogs.  Added protect ship and ignore
116  * count checkboxes to those dialogs.  Changed flag code for
117  * parse_objects.  Added unprotect sexpressions
118  * 
119  * 35    6/18/97 11:46a Hoffoss
120  * Fixed initial order object reference updating and added briefing dialog
121  * window tracking data.
122  * 
123  * 34    5/30/97 4:43p Hoffoss
124  * Added code for allowing ships to be initially docked at mission start.
125  * 
126  * 33    5/05/97 5:44p Hoffoss
127  * Added specialized popup menu choices, save before running FreeSpace,
128  * and display filters.
129  * 
130  * 32    4/29/97 1:58p Hoffoss
131  * Added some debugging to Fred to try and track down sexp corruption
132  * causes.
133  * 
134  * 31    4/24/97 5:15p Hoffoss
135  * fixes to Fred.
136  * 
137  * 30    4/23/97 11:55a Hoffoss
138  * Fixed many bugs uncovered while trying to create Mission 6.
139  * 
140  * 29    3/28/97 5:39p Hoffoss
141  * Player ships treated like other ships in sexp tree editor now.
142  * 
143  * 28    3/27/97 1:43p Hoffoss
144  * Ship duplication (cloning) supported now.
145  * 
146  * 27    3/20/97 3:55p Hoffoss
147  * Major changes to how dialog boxes initialize (load) and update (save)
148  * their internal data.  This should simplify things and create less
149  * problems.
150  * 
151  * 26    3/12/97 12:40p Hoffoss
152  * Fixed bugs in wing object management functions, several small additions
153  * and rearrangements.
154  * 
155  * 25    3/04/97 6:27p Hoffoss
156  * Changes to Fred to handle new wing structure.
157  * 
158  * 24    3/03/97 4:32p Hoffoss
159  * Initial orders supports new docking stuff Allender added.
160  * 
161  * 23    2/25/97 6:10p Hoffoss
162  * Fixed bug with modeless dialog box errors on update.
163  * 
164  * 22    2/20/97 4:28p Hoffoss
165  * Added modification tracking to ship editor dialog box, and support
166  * functions.
167  * 
168  * 21    2/20/97 4:03p Hoffoss
169  * Several ToDo items: new reinforcement clears arrival cue, reinforcement
170  * control from ship and wing dialogs, show grid toggle.
171  * 
172  * 20    2/12/97 5:50p Hoffoss
173  * Expanded on error checking.
174  * 
175  * 19    2/12/97 12:26p Hoffoss
176  * Expanded on global error checker, added initial orders conflict
177  * checking and warning, added waypoint editor dialog and code.
178  * 
179  * 18    2/06/97 3:42p Hoffoss
180  * Added mission critical checking in deletion handler.
181  * 
182  * 17    2/04/97 3:09p Hoffoss
183  * Background bitmap editor implemented fully.
184  * 
185  * 16    1/27/97 10:03a Hoffoss
186  * 
187  * 15    1/10/97 3:56p Hoffoss
188  * Added a recursive menu graying function.
189  * 
190  * 14    1/02/97 3:50p Hoffoss
191  * More fixes to player start support in Fred.
192  * 
193  * 13    12/11/96 3:29p Hoffoss
194  * Worked on getting the Wing dialog changes updated when focus moves.
195  * Works now.
196  * 
197  * 12    12/03/96 3:58p Hoffoss
198  * Added Wing editor to Fred.
199  * 
200  * 11    11/20/96 10:01a Hoffoss
201  * A few minor improvements.
202  * 
203  * 10    11/19/96 9:50a Hoffoss
204  * New interface working, but not finished yet.
205  * 
206  * 9     11/15/96 1:43p Hoffoss
207  * Improvements to the Ship Dialog editor window.  It is now an
208  * independant window that updates data correctly.
209  * 
210  * 8     11/14/96 10:43a Hoffoss
211  * Made changes to grid display and how it works, etc.
212  * 
213  * 7     11/13/96 10:15a Hoffoss
214  * Waypoint editing added, but not quite finished yet.
215  * 
216  * 6     11/11/96 9:59a Hoffoss
217  * Many great improvements.
218  * 
219  * 5     11/05/96 2:46p Hoffoss
220  * Lots of Fred changes (getting ready for milestone)
221  * 
222  * 4     10/29/96 6:20p Hoffoss
223  * Added ability to delete selected or marked ships.
224  * 
225  * 3     10/28/96 5:28p Hoffoss
226  * Extensive rearrangement, modifications and fixes of the Editor system.
227  * 
228  * 2     10/25/96 12:05p Hoffoss
229  * This new files added to makefile.
230  * 
231  * 1     10/25/96 12:02p Hoffoss
232  *
233  * $NoKeywords: $
234  */
235
236 #ifndef __MANAGEMENT_H__
237 #define __MANAGEMENT_H__
238
239 #include <afxmt.h>
240 #include "pstypes.h"
241
242 #define SHIP_FILTER_PLAYERS     (1<<0)  // set: add players to list as well
243 #define SHIP_FILTER_FLYABLE     (1<<1)  // set: filter out non-flyable ships
244
245 typedef struct {
246         char *name;
247         int def;
248 } ai_goal_list;
249
250 extern int cur_object_index;
251 extern int cur_ship;
252 extern int cur_wing;
253 extern int cur_wing_index;
254 extern int cur_model_index;
255 extern int cur_waypoint;
256 extern int cur_waypoint_list;
257 extern int Update_ship;
258 extern int Update_wing;
259 extern int Fred_font;
260
261 // alternate ship name stuff
262 extern char Fred_alt_names[MAX_SHIPS][NAME_LENGTH+1];
263
264 extern int      wing_objects[MAX_WINGS][MAX_SHIPS_PER_WING];
265
266 extern char     *Docking_bay_list[];
267
268 extern char Fred_exe_dir[512];
269
270 extern CCriticalSection CS_cur_object_index;
271
272 extern ai_goal_list Ai_goal_list[];
273 extern int Ai_goal_list_size;
274
275 void    string_copy(char *dest, CString &src, int max_len, int modify = 0);
276 CString convert_multiline_string(char *src);
277 void    deconvert_multiline_string(char *buf, CString &str, int max_len);
278 void    fred_init();
279 void    set_physics_controls();
280 int     dup_object(object *objp);
281 int     create_object_on_grid(int list);
282 int     create_object(vector *pos, int list = cur_waypoint_list);
283 int     create_player(int num, vector *pos, matrix *orient, int type = -1, int init = 1);
284 void    create_new_mission();
285 void    reset_mission();
286 void    clear_mission();
287 int     query_valid_object(int index = cur_object_index);
288 int     query_valid_ship(int index = cur_object_index);
289 int     query_valid_waypoint(int index = cur_object_index);
290 void    set_cur_indices(int obj = -1);
291 void    set_cur_object_index(int obj = -1);
292 int     delete_object(int obj);
293 int     delete_object(object *ptr);
294 int     delete_ship(int ship);
295 void    delete_marked();
296 void    delete_reinforcement(int num);
297 int     delete_ship_from_wing(int ship = cur_ship);
298 int     find_free_wing();
299 void    add_ship_to_wing();
300 int     query_object_in_wing(int obj = cur_object_index);
301 void    mark_object(int obj);
302 void    unmark_object(int obj);
303 void    unmark_all();
304 void    clear_menu(CMenu *ptr);
305 void    generate_wing_popup_menu(CMenu *mptr, int first_id, int state);
306 void    generate_ship_popup_menu(CMenu *mptr, int first_id, int state, int filter = 0);
307 int     string_lookup(CString str1, char *strlist[], int max);
308 int     update_dialog_boxes();
309 void    set_cur_wing(int wing);
310 int     gray_menu_tree(CMenu *base);
311 int     query_initial_orders_conflict(int wing);
312 int     query_initial_orders_empty(ai_goal *ai_goals);
313 int     set_reinforcement(char *name, int state);
314 int     get_docking_list(int model_index);
315 int     rename_ship(int ship, char *name);
316 void    fix_ship_name(int ship);
317 int     internal_integrity_check();
318 void    correct_marking();
319 int     get_ship_from_obj(int obj);
320 int     get_ship_from_obj(object *objp);
321 void    set_valid_dock_points(int ship, int type, CComboBox *box);
322 void    ai_update_goal_references(int type, char *old_name, char *new_name);
323 int     query_referenced_in_ai_goals(int type, char *name);
324 int     advanced_stricmp(char *one, char *two);
325 int     reference_handler(char *name, int type, int obj);
326 int     orders_reference_handler(int code, char *msg);
327 int     sexp_reference_handler(int node, int code, char *msg);
328 char    *object_name(int obj);
329 char    *get_order_name(int order);
330 void    object_moved(object *ptr, int mark = 0);
331 int     invalidate_references(char *name, int type);
332 int     query_whole_wing_marked(int wing);
333 void    generate_weaponry_usage_list(int *arr);
334
335 // function and defines to use when adding ships to combo boxes
336 #define SHIPS_2_COMBO_SPECIAL                                   (1<<0)
337 #define SHIPS_2_COMBO_ALL_SHIPS                         (1<<1)
338 #define SHIPS_2_COMBO_DOCKING_BAY_ONLY          (1<<2)
339
340 extern void management_add_ships_to_combo( CComboBox *box, int flags );
341
342 #endif
343