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