Debian Codegraph @

netcon/includes/con_dll.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
19
20 /*
21 * $Logfile: /DescentIII/Main/lib/con_dll.h $
22 * $Revision: 1.1.1.1 $
23 * $Date: 2003/08/26 03:58:12 $
24 * $Author: kevinb $
25 *
26 * Common header for connection DLLs.
27 *
28 * $Log: con_dll.h,v $
29 * Revision 1.1.1.1 2003/08/26 03:58:12 kevinb
30 * initial 1.5 import
31 *
32 *
33 * 78 5/09/00 5:11p Jeff
34 * fixed struct packing bug
35 *
36 * 77 3/26/00 10:30p Kevin
37 * MOD Downloader for 1.4 patch.
38 *
39 * 75 10/21/99 9:27p Jeff
40 * B.A. Macintosh code merge
41 *
42 * 74 8/02/99 11:47a Kevin
43 * don't display the d3 single mission twice!
44 *
45 * 73 7/12/99 4:15p Kevin
46 * Changed the way we determine if we should report stats or not in PXO
47 *
48 * 72 7/06/99 5:52p Kevin
49 * PXO & multiplayer fixes for the patch
50 *
51 * 71 6/23/99 3:35p Samir
52 * added pstypes.h
53 *
54 * 70 6/03/99 8:48a Kevin
55 * fixes for new OEM version....
56 *
57 * 69 5/24/99 4:21p Jason
58 * fixed difficultly level problem
59 *
60 * 68 4/28/99 6:39p Kevin
61 * Build 182 fixes
62 *
63 * 67 4/26/99 2:54p Kevin
64 * fixed team count & keyword system to work with dedicated server
65 *
66 * 66 4/25/99 5:02p Kevin
67 * Bunches of multiplayer UI improvements
68 *
69 * 65 4/25/99 12:11a Kevin
70 * game info dialog stuff
71 *
72 * 64 4/23/99 5:32p Kevin
73 * Fixed a few mission bugs.
74 *
75 * 63 4/23/99 3:33p Kevin
76 * mission file/multiplayer mod keyword system
77 *
78 * 62 4/19/99 7:56p Kevin
79 * ifdef'd out some win32 specific stuff
80 *
81 * 61 4/19/99 6:10p Kevin
82 * Demo now only has one multiplayer level
83 *
84 * 60 4/18/99 3:12p Jeff
85 * got working with linux
86 *
87 * 59 4/16/99 3:17p Kevin
88 * More mouselook support
89 *
90 * 58 4/14/99 3:06p Kevin
91 * Force main mission to list even on small installations
92 *
93 * 57 4/08/99 4:54p Kevin
94 * Display level warp dialog for multiplayer
95 *
96 * 56 4/08/99 3:42p Kevin
97 * Added some stuff for the scoring API. Not functional yet.
98 *
99 * 55 4/03/99 9:26p Jeff
100 * changed dialogs that weren't using UID_OK and UID_CANCEL to use and
101 * handle them properly
102 *
103 * 54 3/25/99 3:29p Jason
104 * added option to randomize powerup respawn points
105 *
106 * 53 3/25/99 3:26p Kevin
107 * Made PXO games be based on your chat channel
108 *
109 * 52 3/24/99 1:41p Jeff
110 * some dedicated server fixups...ability to set number of teams
111 *
112 * 51 3/17/99 4:08p Kevin
113 * Changed the way games appear and timeout in the game list.
114 *
115 * 50 3/04/99 6:11p Kevin
116 * Fixed mission name for OEM
117 *
118 * 49 3/02/99 5:50p Kevin
119 * Ouch. Duplicate structures existed and were conflicting.
120 *
121 * 48 3/02/99 1:18a Kevin
122 *
123 * 47 3/02/99 1:11a Kevin
124 *
125 * 46 3/01/99 9:37p Jeff
126 * fixed missing semicolon
127 *
128 * 45 3/01/99 9:03p Kevin
129 * OEM Beta 4
130 *
131 * 44 2/28/99 11:04p Jeff
132 * handle Capture The Flag->CTF in Demo/OEM
133 *
134 * 43 2/19/99 5:21p Kevin
135 * Fixed some connection DLLs and a Direct Sound bug with threads.
136 *
137 * 42 2/15/99 7:47p Jeff
138 * new pilot file class and read/write system checked in...should be more
139 * robust than old
140 *
141 * 41 2/04/99 11:40a Kevin
142 * Made listboxes sort
143 *
144 * 40 2/03/99 6:14p Kevin
145 * OEM changes
146 *
147 * 39 2/03/99 4:20p Kevin
148 * Got multiplayer working with .mn3 files, and setup autodownloading
149 *
150 * 38 1/11/99 12:29p Jeff
151 * changes made not to call the module library directly
152 *
153 * 37 1/07/99 11:51a Kevin
154 * Added support for joining servers on alternate ports and hosting behind
155 * a proxy/firewall
156 *
157 * 36 12/30/98 3:49p Kevin
158 * Moved multiplayer options out of DLL and into main app
159 *
160 * 35 12/30/98 12:16p Kevin
161 * Auto Mission Download system
162 *
163 * 34 12/23/98 6:38p Kevin
164 * All UDP data (except gamespy) now uses one (registered) port number
165 *
166 * 33 12/18/98 11:00a Jason
167 *
168 * 32 12/15/98 10:53a Jason
169 * yet more changes for 1.1
170 *
171 * 31 12/14/98 10:53a Jason
172 * added bright player ships option
173 *
174 * 30 12/01/98 12:47p Jason
175 * got rid of NF_DROPMISORDERED and added NF_USE_SMOOTHING
176 *
177 * 29 11/18/98 3:26p Kevin
178 * Put multiplayer options into con_dll.h
179 *
180 * 28 10/19/98 11:07p Kevin
181 * fixed bug
182 *
183 * 27 10/19/98 7:51p Kevin
184 * performance testing
185 *
186 * 26 10/19/98 1:08p Kevin
187 * Removed single player level from demo build
188 *
189 * 25 10/15/98 1:36p Jeff
190 * updated dllinfo struct
191 *
192 * 24 10/13/98 12:03p Kevin
193 * Changed use of preprocessors for debug, etc.
194 *
195 * 23 10/12/98 8:39p Kevin
196 * removed mprintf's and fixed some smallish bugs
197 *
198 * 22 10/08/98 12:05p Kevin
199 * Moved some start menu stuff around for Luke
200 *
201 * 21 10/07/98 11:45a Kevin
202 * changed demo mission name
203 *
204 * 20 10/06/98 11:00a Kevin
205 * Updated mission names for demo
206 *
207 * 19 10/01/98 11:37a Kevin
208 * UI fixes and stuff
209 *
210 * 18 9/29/98 2:23p Kevin
211 * More UI tweaks
212 *
213 * 17 9/28/98 9:53a Kevin
214 * Fixing misc UI problems, and fixed some bugs that VC 6 found
215 *
216 * 16 9/24/98 12:50p Kevin
217 * Added UI for rotational velocity and drop out of order packets in net
218 * games
219 *
220 * 15 9/23/98 6:33p Kevin
221 * Fixed load settings
222 *
223 * 14 9/23/98 2:55p Kevin
224 * Saved multi config and changed UI to conform
225 *
226 * 13 9/22/98 3:55p Kevin
227 * Removed obsolete function
228 *
229 * 12 9/22/98 2:29p Kevin
230 * moved ships allowed code out of dll and into main app. Also added
231 * powerup exclusions
232 *
233 * 11 9/21/98 11:19a Kevin
234 * check protocol before entering multiplayer screens
235 *
236 * 10 9/16/98 8:06p Jason
237 * got mastertracker working with the dedicated server
238 *
239 * 9 9/04/98 1:51p Kevin
240 * implemented asyncronous gethostbyname
241 *
242 * 8 9/02/98 6:54p Kevin
243 * Fixed general directplay support up, and got modem-modem working
244 *
245 * 7 8/31/98 10:14a Kevin
246 * Misc. multi-UI fixes
247 *
248 * 6 8/27/98 5:03p Kevin
249 * Prettied up multiplayer screens and fixed some bugs.
250 *
251 * 5 8/25/98 6:33p Kevin
252 * pxo
253 *
254 * 4 8/24/98 5:04p Kevin
255 * Made msn files have the option to not be playable in multiplayer
256 *
257 * 3 8/24/98 10:42a Kevin
258 * Updated DLL for directplay and PXO background
259 *
260 * 2 8/19/98 11:50a Kevin
261 * Got DirectPlay IPX working, and localized connection DLLs
262 *
263 * $NoKeywords: $
264 */
265 ///////////////////////////////////////////////
266
267 #include "ship.h"
268 #include "pstypes.h"
269
270 #if defined(POSIX)
271 #include <string.h>
272 #include "linux_fix.h"
273 #endif
274
275 // Uncomment out this line of code to build the demo version of the multiplayer connection dlls
276 // #define DEMO 1
277
278 // localization info
279 char **StringTable;
280 int StringTableSize = 0;
281 const char *_ErrorString = "Missing String";
282 const char *GetString(int d) {
283 if ((d < 0) || (d >= StringTableSize))
284 return _ErrorString;
285 else
286 return StringTable[d];
287 }
288 #define TXT(d) GetString(d)
289 ///////////////////////////////////////////////
290 #define CHAR_LEFT_ARROW 24
291 #define CHAR_UP_ARROW 25
292 #define CHAR_RIGHT_ARROW 26
293 #define CHAR_DOWN_ARROW 27
294 #define CHAR_CHECKBOX_OFF 28
295 #define CHAR_CHECKBOX_ON 29
296 #define CHAR_RADIO_OFF 30
297 #define CHAR_RADIO_ON 31
298
299 #define DLL_UI_CANCEL 99
300
301 #define DLL_BRIEFING_FONT 1
302 #define DLL_BIG_BRIEFING_FONT 2
303
304 struct dllinfo {
305 int me_handle;
306 int it_handle;
307 uint8_t *special_data;
308 char *input_string;
309 int input_key;
310 union {
311 int iRet;
312 float fRet;
313 };
314 float fParam;
315 ptrdiff_t iParam;
316 };
317
318 struct multi_api {
319 int *objs;
320 int *rooms;
321 int *terrain;
322 int *players;
323 int *netgame;
324 int *netplayers;
325 int *ships;
326 int *fp[200]; // function pointers
327 int *vp[200]; // variable pointers
328 };
329
330 typedef void (*GetMultiAPI_fp)(multi_api *api);
331 GetMultiAPI_fp DLLGetMultiAPI;
332
333 typedef void (*SetUITextItemText_fp)(void *uit, char *newtext, uint32_t color);
334 SetUITextItemText_fp DLLSetUITextItemText;
335
336 typedef void *(*NewUIWindowCreate_fp)(int x, int y, int w, int h, int flags);
337 NewUIWindowCreate_fp DLLNewUIWindowCreate;
338
339 typedef void (*NewUIWindowDestroy_fp)(void *deswin);
340 NewUIWindowDestroy_fp DLLNewUIWindowDestroy;
341
342 typedef void (*NewUIWindowOpen_fp)(void *deswin);
343 NewUIWindowOpen_fp DLLNewUIWindowOpen;
344
345 typedef void (*NewUIWindowClose_fp)(void *deswin);
346 NewUIWindowClose_fp DLLNewUIWindowClose;
347
348 typedef void *(*TextCreate_fp)(void *parentwin, void *textitem, int x, int y, int flags);
349 TextCreate_fp DLLTextCreate;
350
351 typedef void *(*EditCreate_fp)(void *parentwin, int id, int x, int y, int w, int h, int flags);
352 EditCreate_fp DLLEditCreate;
353
354 typedef void *(*ButtonCreate_fp)(void *parentwin, int id, void *titleitem, int x, int y, int w, int h, int flags);
355 ButtonCreate_fp DLLButtonCreate;
356
357 typedef void *(*ListCreate_fp)(void *parentwin, int id, int x, int y, int w, int h, int flags);
358 ListCreate_fp DLLListCreate;
359
360 typedef void (*ListRemoveAll_fp)(void *item);
361 ListRemoveAll_fp DLLListRemoveAll;
362
363 typedef void (*ListAddItem_fp)(void *item, void *uitext);
364 ListAddItem_fp DLLListAddItem;
365
366 typedef void (*ListRemoveItem_fp)(void *item, void *txtitem);
367 ListRemoveItem_fp DLLListRemoveItem;
368
369 typedef void (*ListSelectItem_fp)(void *item, void *txtitem);
370 ListSelectItem_fp DLLListSelectItem;
371
372 typedef char *(*ListGetItem_fp)(void *item, int index);
373 ListGetItem_fp DLLListGetItem;
374
375 typedef int (*ListGetSelectedIndex_fp)(void *item);
376 ListGetSelectedIndex_fp DLLListGetSelectedIndex;
377
378 typedef void (*EditSetText_fp)(void *item, const char *buff);
379 EditSetText_fp DLLEditSetText;
380
381 typedef void (*EditGetText_fp)(void *item, char *buff, int len);
382 EditGetText_fp DLLEditGetText;
383
384 typedef void (*DatabaseWrite_fp)(const char *label, const char *entry, int entrylen);
385 DatabaseWrite_fp DLLDatabaseWrite;
386
387 typedef void (*DatabaseRead_fp)(const char *label, char *entry, int *entrylen);
388 DatabaseRead_fp DLLDatabaseRead;
389
390 typedef void (*DescentDefer_fp)(void);
391 DescentDefer_fp DLLDescentDefer;
392
393 typedef void (*DoMessageBox_fp)(const char *title, const char *msg, int type, ddgr_color title_color,
394 ddgr_color text_color);
395 DoMessageBox_fp DLLDoMessageBoxFP;
396 static inline void DLLDoMessageBox(const char *title, const char *msg, int type, ddgr_color title_color = GR_WHITE,
397 ddgr_color text_color = GR_WHITE) {
398 DLLDoMessageBoxFP(title, msg, type, title_color, text_color);
399 }
400
401 typedef int (*DoUI_fp)(void);
402 DoUI_fp DLLDoUI;
403
404 typedef void (*Debug_ConsolePrintf_fp)(int n, const char *format, ...);
405 Debug_ConsolePrintf_fp DLLDebug_ConsolePrintf;
406
407 typedef void (*DedicatedServerPrintf_fp)(const char *format, ...);
408 DedicatedServerPrintf_fp DLLPrintDedicatedMessage;
409 /*
410 typedef int( *ValidateUser_fp) (validate_id_request *valid_id, char *trackerid);
411 ValidateUser_fp DLLValidateUser;
412
413 typedef void( *PollPTrackNet_fp) ();
414 PollPTrackNet_fp DLLPollPTrackNet;
415 */
416 typedef void *(*NewUIGameWindowCreate_fp)(int x, int y, int w, int h, int flags);
417 NewUIGameWindowCreate_fp DLLNewUIGameWindowCreate;
418
419 typedef void (*NewUIGameWindowDestroy_fp)(void *item);
420 NewUIGameWindowDestroy_fp DLLNewUIGameWindowDestroy;
421
422 typedef void (*NewUIGameWindowOpen_fp)(void *item);
423 NewUIGameWindowOpen_fp DLLNewUIGameWindowOpen;
424
425 typedef void (*NewUIGameWindowClose_fp)(void *item);
426 NewUIGameWindowClose_fp DLLNewUIGameWindowClose;
427
428 typedef void (*SetScreenMode_fp)(int);
429 SetScreenMode_fp DLLSetScreenMode;
430
431 typedef float (*timer_GetTime_fp)(void);
432 timer_GetTime_fp DLLtimer_GetTime;
433
434 typedef int (*TryToJoinServer_fp)(network_address *addr);
435 TryToJoinServer_fp DLLTryToJoinServer;
436
437 typedef void (*MultiStartClient_fp)(char *scriptname);
438 MultiStartClient_fp DLLMultiStartClient;
439
440 typedef void (*rend_GetRenderState_fp)(rendering_state *rstate);
441 rend_GetRenderState_fp DLLrend_GetRenderState;
442
443 typedef bool (*LoadMission_fp)(char *msn);
444 LoadMission_fp DLLLoadMission;
445
446 typedef void (*ddio_MakePath_fp)(char *newPath, const char *absolutePathHeader, const char *subDir, ...);
447 ddio_MakePath_fp DLLddio_MakePath;
448
449 typedef bool (*ddio_FindFileStart_fp)(const char *wildcard, char *namebuf);
450 ddio_FindFileStart_fp DLLddio_FindFileStart;
451
452 typedef void (*ddio_FindFileClose_fp)();
453 ddio_FindFileClose_fp DLLddio_FindFileClose;
454
455 typedef bool (*ddio_FindNextFile_fp)(char *namebuf);
456 ddio_FindNextFile_fp DLLddio_FindNextFile;
457
458 // typedef void( *MultiStartServer_fp) (int playing,char *scriptname,int dedicated_num_teams=-1);
459 typedef void (*MultiStartServer_fp)(int playing, char *scriptname, int dedicated_num_teams);
460 MultiStartServer_fp DLLMultiStartServerFP;
461 static inline void DLLMultiStartServer(int playing, char *scriptname, int dedicated_num_teams = -1) {
462 DLLMultiStartServerFP(playing, scriptname, dedicated_num_teams);
463 }
464
465 typedef void (*ShowProgressScreen_fp)(const char *, const char *);
466 ShowProgressScreen_fp DLLShowProgressScreen;
467
468 typedef int (*SearchForLocalGamesTCP_fp)(uint32_t, uint16_t);
469 SearchForLocalGamesTCP_fp DLLSearchForLocalGamesTCP;
470
471 typedef int (*nw_GetHostAddressFromNumbers_fp)(char *str);
472 nw_GetHostAddressFromNumbers_fp DLLnw_GetHostAddressFromNumbers;
473
474 typedef int (*nw_GetProtocolType_fp)(void);
475 nw_GetProtocolType_fp DLLnw_GetProtocolType;
476
477 typedef void *(*HotSpotCreate_fp)(void *parentwin, int id, int key, void *txtitemoff, void *txtitemon, int x, int y,
478 int w, int h, int flags);
479 HotSpotCreate_fp DLLHotSpotCreate;
480
481 typedef int (*PollUI_fp)(void);
482 PollUI_fp DLLPollUI;
483
484 typedef const char *(*GetMissionName_fp)(const char *mission);
485 GetMissionName_fp DLLGetMissionName;
486
487 typedef void (*RemoveUITextItem_fp)(void *item);
488 RemoveUITextItem_fp DLLRemoveUITextItem;
489
490 typedef void *(*CreateNewUITextItem_fp)(const char *newtext, uint32_t color, int font);
491 CreateNewUITextItem_fp DLLCreateNewUITextItemFP;
492 static inline void *DLLCreateNewUITextItem(const char *newtext, uint32_t color, int font = -1) {
493 return DLLCreateNewUITextItemFP(newtext, color, font);
494 }
495
496 typedef void *(*mem_malloc_fp)(int size);
497 mem_malloc_fp DLLmem_malloc;
498
499 typedef void (*mem_free_fp)(void *memblock);
500 mem_free_fp DLLmem_free;
501
502 typedef void (*CreateSplashScreen_fp)(const char *msg, int usecancel);
503 CreateSplashScreen_fp DLLCreateSplashScreen;
504
505 typedef void (*CloseSplashScreen_fp)(void);
506 CloseSplashScreen_fp DLLCloseSplashScreen;
507
508 typedef void *(*UIConsoleGadgetCreate_fp)(void *parentid, int id, int x, int y, int font, int cols, int rows,
509 int flags);
510 UIConsoleGadgetCreate_fp DLLUIConsoleGadgetCreate;
511
512 typedef void (*UIConsoleGadgetputs_fp)(void *item, const char *str);
513 UIConsoleGadgetputs_fp DLLUIConsoleGadgetputs;
514
515 typedef void (*NewUIWindowSetFocusOnEditGadget_fp)(void *item, void *parent);
516 NewUIWindowSetFocusOnEditGadget_fp DLLNewUIWindowSetFocusOnEditGadget;
517
518 typedef void *(*OldEditCreate_fp)(void *parentitem, int id, int x, int y, int w, int h, int flags);
519 OldEditCreate_fp DLLOldEditCreate;
520
521 typedef void *(*OldListCreate_fp)(void *parentitem, int id, int x, int y, int w, int h, int flags);
522 OldListCreate_fp DLLOldListCreate;
523
524 typedef void (*OldListRemoveAll_fp)(void *item);
525 OldListRemoveAll_fp DLLOldListRemoveAll;
526
527 typedef void (*OldListAddItem_fp)(void *item, void *uitext);
528 OldListAddItem_fp DLLOldListAddItem;
529
530 typedef void (*OldListRemoveItem_fp)(void *item, void *txtitem);
531 OldListRemoveItem_fp DLLOldListRemoveItem;
532
533 typedef void (*OldListSelectItem_fp)(void *item, void *txtitem);
534 OldListSelectItem_fp DLLOldListSelectItem;
535
536 typedef char *(*OldListGetItem_fp)(void *item, int index);
537 OldListGetItem_fp DLLOldListGetItem;
538
539 typedef int (*OldListGetSelectedIndex_fp)(void *item);
540 OldListGetSelectedIndex_fp DLLOldListGetSelectedIndex;
541
542 typedef void (*OldEditSetText_fp)(void *item, const char *newtext);
543 OldEditSetText_fp DLLOldEditSetText;
544
545 typedef void (*OldEditGetText_fp)(void *item, char *buff, int len);
546 OldEditGetText_fp DLLOldEditGetText;
547
548 typedef void (*ToggleUICallback_fp)(int state);
549 ToggleUICallback_fp DLLToggleUICallback;
550
551 typedef int (*SearchForGamesPXO_fp)(uint32_t ask, uint16_t port);
552 SearchForGamesPXO_fp DLLSearchForGamesPXO;
553
554 typedef void (*SetOldEditBufferLen_fp)(void *item, int len);
555 SetOldEditBufferLen_fp DLLSetOldEditBufferLen;
556
557 typedef void (*NewUIWindowLoadBackgroundImage_fp)(void *item, const char *image_name);
558 NewUIWindowLoadBackgroundImage_fp DLLNewUIWindowLoadBackgroundImage;
559
560 typedef void (*DeleteUIItem_fp)(void *delitem);
561 DeleteUIItem_fp DLLDeleteUIItem;
562
563 typedef int (*SearchForLocalGamesIPX_fp)(network_address *check_addr);
564 SearchForLocalGamesIPX_fp DLLSearchForLocalGamesIPX;
565
566 typedef void (*HotSpotSetStates_fp)(void *hotspot, void *texton, void *textoff);
567 HotSpotSetStates_fp DLLHotSpotSetStates;
568
569 typedef bool (*PlayerSetShipPermission_fp)(int pnum, char *ship_name, bool allowed);
570 PlayerSetShipPermission_fp DLLPlayerSetShipPermission;
571
572 typedef bool (*PlayerIsShipAllowed_fp)(int pnum, int ship_index);
573 PlayerIsShipAllowed_fp DLLPlayerIsShipAllowed;
574
575 #ifdef WIN32
576 typedef int (*dp_ListDirectPlayGames_fp)();
577 dp_ListDirectPlayGames_fp DLLdp_ListDirectPlayGames;
578
579 typedef int (*dp_InitDirectPlay_fp)(char *conn_name, void *parms, int num_elements);
580 dp_InitDirectPlay_fp DLLdp_InitDirectPlay;
581
582 typedef int (*dp_GetModemChoices_fp)(char *buffer, uint32_t *size);
583 dp_GetModemChoices_fp DLLdp_GetModemChoices;
584 #endif
585
586 // Given a filename, pointer to a char * array and a pointer to an int,
587 // it will load the string table and fill in the information
588 // returns true on success
589 typedef bool (*CreateStringTable_fp)(const char *filename, char ***table, int *size);
590 CreateStringTable_fp DLLCreateStringTable;
591
592 // Given a string table and it's count of strings, it will free up it's memory
593 typedef void (*DestroyStringTable_fp)(char **table, int size);
594 DestroyStringTable_fp DLLDestroyStringTable;
595
596 typedef void (*DatabaseReadInt_fp)(const char *label, int *val);
597 DatabaseReadInt_fp DLLDatabaseReadInt;
598
599 typedef void (*DatabaseWriteInt_fp)(const char *label, int val);
600 DatabaseWriteInt_fp DLLDatabaseWriteInt;
601
602 typedef void (*DoScreenshot_fp)();
603 DoScreenshot_fp DLLDoScreenshot;
604
605 typedef bool (*IsMissionMultiPlayable_fp)(char *mission);
606 IsMissionMultiPlayable_fp DLLIsMissionMultiPlayable;
607
608 // returns width of text in current font.
609 typedef int (*grtext_GetTextLineWidth_fp)(const char *str);
610 grtext_GetTextLineWidth_fp DLLgrtext_GetTextLineWidth;
611
612 typedef void (*GadgetDestroy_fp)(void *item);
613 GadgetDestroy_fp DLLGadgetDestroy;
614
615 #ifdef WIN32
616 typedef int (*dp_StartGame_fp)(char *gamename);
617 dp_StartGame_fp DLLdp_StartGame;
618
619 typedef void (*dp_EndGame_fp)();
620 dp_EndGame_fp DLLdp_EndGame;
621 #endif
622
623 typedef int (*nw_Asyncgethostbyname_fp)(uint32_t *ip, int command, const char *hostname);
624 nw_Asyncgethostbyname_fp DLLnw_Asyncgethostbyname;
625
626 typedef int (*nw_ReccomendPPS_fp)();
627 nw_ReccomendPPS_fp DLLnw_ReccomendPPS;
628
629 typedef void (*DoMultiAllowed_fp)(void);
630 DoMultiAllowed_fp DLLDoMultiAllowed;
631
632 typedef void (*MultiDoConfigSave_fp)(void);
633 MultiDoConfigSave_fp DLLMultiDoConfigSave;
634
635 typedef void (*MultiDoConfigLoad_fp)(void);
636 MultiDoConfigLoad_fp DLLMultiDoConfigLoad;
637
638 typedef int (*MultiLoadSettings_fp)(const char *filename);
639 MultiLoadSettings_fp DLLMultiLoadSettings;
640
641 typedef void *(*NetworkReceiveCallback)(uint8_t *data, int len, network_address *from);
642
643 typedef void (*HandleGamePacket_fp)(uint8_t *data, int len, network_address *from);
644
645 typedef int (*nw_RegisterCallback_fp)(HandleGamePacket_fp, uint8_t id);
646 nw_RegisterCallback_fp DLLnw_RegisterCallback;
647
648 typedef NetworkReceiveCallback (*nw_UnRegisterCallback_fp)(uint8_t id);
649 nw_UnRegisterCallback_fp DLLnw_UnRegisterCallback;
650
651 typedef int (*nw_SendWithID_fp)(uint8_t id, uint8_t *data, int len, network_address *who_to);
652 nw_SendWithID_fp DLLnw_SendWithID;
653
654 typedef int (*nw_DoReceiveCallbacks_fp)(void);
655 nw_DoReceiveCallbacks_fp DLLnw_DoReceiveCallbacks;
656
657 typedef int (*msn_CheckGetMission_fp)(network_address *net_addr, char *filename);
658 msn_CheckGetMission_fp DLLmsn_CheckGetMission;
659
660 typedef void (*MultiGameOptionsMenu_fp)(int alloptions);
661 MultiGameOptionsMenu_fp DLLMultiGameOptionsMenu;
662
663 // Loads a dynamic module into memory for use.
664 // Returns true on success, false otherwise
665 // typedef bool (*mod_LoadModule_fp)(module *handle,const char *modfilename,int flags=MODF_NOW);
666 typedef bool (*mod_LoadModule_fp)(module *handle, const char *modfilename, int flags);
667 mod_LoadModule_fp DLLmod_LoadModule;
668
669 // Frees a previously loaded module from memory, it can no longer be used
670 // Returns true on success, false otherwise
671 typedef bool (*mod_FreeModule_fp)(module *handle);
672 mod_FreeModule_fp DLLmod_FreeModule;
673
674 // Returns a pointer to a function within a loaded module. If it returns NULL there was an error. Check
675 // mod_GetLastError to see if there was an error symstr is the name of the function you want to get the symbol for (Do
676 // NOT give any pre/suffix to this name) parmbytes is the size (in bytes) of the parameter list the function should have
677 typedef MODPROCADDRESS (*mod_GetSymbol_fp)(module *handle, const char *symstr, uint8_t parmbytes);
678 mod_GetSymbol_fp DLLmod_GetSymbol;
679
680 // Returns an error code to what the last error was. When this function is called the last error is cleared, so by
681 // calling this function it not only returns the last error, but it removes it, so if you were to call this function
682 // again, it would return no error
683 typedef int (*mod_GetLastError_fp)(void);
684 mod_GetLastError_fp DLLmod_GetLastError;
685
686 // "Current Pilot" name access function
687 typedef void (*CurrentPilotName_fp)(char *buffer);
688 CurrentPilotName_fp CurrentPilotName;
689
690 typedef void (*UpdateAndPackGameList_fp)(void);
691 UpdateAndPackGameList_fp DLLUpdateAndPackGameList;
692
693 typedef int (*MultiLevelSelection_fp)(void);
694 MultiLevelSelection_fp DLLMultiLevelSelection;
695
696 typedef bool (*DoPlayerMouselookCheck_fp)(uint32_t flags);
697 DoPlayerMouselookCheck_fp DLLDoPlayerMouselookCheck;
698
699 typedef int (*CheckMissionForScript_fp)(char *mission, char *script, int dedicated_server_num_teams);
700 CheckMissionForScript_fp DLLCheckMissionForScript;
701
702 typedef void (*ShowNetgameInfo_fp)(network_game *game);
703 ShowNetgameInfo_fp DLLShowNetgameInfo;
704
705 typedef int (*CheckGetD3M_fp)(char *d3m);
706 CheckGetD3M_fp DLLCheckGetD3M;
707
708 int DLLUIClass_CurrID = 0xD0;
709
710 #define MAX_NET_GAMES 100
711 #define JEFF_RED GR_RGB(255, 40, 40)
712 #define JEFF_BLUE GR_RGB(40, 40, 255)
713 #define JEFF_GREEN GR_RGB(40, 255, 40)
714 #define NETPOLLINTERVAL 10.0
715
716 extern int MTAVersionCheck(uint32_t oldver, char *URL);
717
718 #define LOGIN_LEN 33
719 #define REAL_NAME_LEN 66
720 #define PASSWORD_LEN 17
721 #define EMAIL_LEN 100
722 #define TRACKER_ID_LEN 10
723 #define PILOT_NAME_LEN 20
724
725 #ifdef WIN32
726 #pragma pack(push, pxo)
727 #endif
728 #pragma pack(1)
729 struct vmt_descent3_struct {
730 char tracker_id[TRACKER_ID_LEN];
731 char pilot_name[PILOT_NAME_LEN];
732 int rank;
733
734 int kills;
735 int deaths;
736 int suicides;
737 int online_time;
738 int games_played;
739 uint32_t security;
740 uint8_t virgin_pilot; // This pilot was just created if TRUE
741 uint32_t lateral_thrust;
742 uint32_t rotational_thrust;
743 uint32_t sliding_pct; // Percentage of the time you were sliding
744 uint32_t checksum; // This value needs to be equal to whatever the checksum is once the packet is decoded
745 uint32_t pad; // just to provide room for out 4 byte encryption boundry only needed on the client side for now
746 };
747 #define DESCENT3_BLOCK_SIZE (sizeof(vmt_descent3_struct) - 4)
748 #ifdef WIN32
749 #pragma pack(pop, pxo)
750 #else
751 #pragma pack()
752 #endif
753
754 /////////////////////////////
755 // Defines
756 #ifndef RELEASE
757 #define DLLmprintf(...) DLLDebug_ConsolePrintf(__VA_ARGS__)
758 #else
759 #define DLLmprintf(...)
760 #endif
761
762 uint32_t MTClientVer = 100;
763
764 char MTUpdateURL[300] = "";
765
766 multi_api API;
767
768 player *DLLMPlayers;
769 ship *DLLShips;
770 vmt_descent3_struct *DLLMTPilotinfo;
771 int DLLPlayer_num;
772 int *DLLGame_is_master_tracker_game;
773 int DLLGame_mode;
774 char *DLLTracker_id;
775 int *DLLNum_directplay_games;
776 netgame_info *DLLNetgame;
777 char *DLLLocalD3Dir;
778 int *DLLMultiGameStarting;
779 netplayer *DLLMNetPlayers;
780 int MTWritingPilot, MTReadingPilot;
781 int UnvalidatedDLL = 0;
782 int *DLLNum_network_games_known;
783 bool *DLLDedicated_server;
784 network_game *DLLNetwork_games;
785 int MT_Initialized = 0;
786 uint8_t *DLLNewUIWindow_alpha;
787 float LastTrackerDataUpdate;
788 void *pconsole = NULL;
789 bool *DLLDP_active;
790 bool *DLLUse_DirectPlay;
791 bool *DLLMulti_Gamelist_changed;
792 bool *DLLSupports_score_api;
793 // bool * DLLMulti_no_stats_saved;
794 uint16_t DLLnw_ListenPort;
795
796 char szloginid[LOGIN_LEN] = "";
797 char sztrackerid[TRACKER_ID_LEN] = "";
798 char szpassword[PASSWORD_LEN] = "";
799
800 char *DLLHelpText1;
801 char *DLLHelpText2;
802 char *DLLHelpText3;
803 char *DLLHelpText4;
804
805 char *DLLPXO_hosted_lobby_name = NULL;
806
807 #define DLLMAX_SHIPS 30
808
809 #define PARENT0 0
810 #define PARENT1 1
811 #define PARENT2 2
812 #define PARENT3 3
813 #define PARENT4 4
814
815 char *DLLAuto_login_name;
816 char *DLLAuto_login_pass;
817 char *DLLAuto_login_addr;
818 char *DLLAuto_login_port;
819
820 bool Use_netgame_flags;
821
822 module MTAVDLLHandle = {NULL};
823
824 #if defined(WIN32)
825 typedef void(DLLFUNCCALL DLLAVInit_fp)(int *ptr);
826 typedef void(DLLFUNCCALL DLLAVCall_fp)(int eventnum);
827 typedef void(DLLFUNCCALL DLLAVClose_fp)();
828 typedef void(DLLFUNCCALL DLLAVGetVersion_fp)(int *version);
829 typedef void(DLLFUNCCALL DLLRunCheck_fp)(char *d3_path);
830 #elif defined(POSIX)
831 typedef void DLLFUNCCALL(DLLAVInit_fp)(int *ptr);
832 typedef void DLLFUNCCALL(DLLAVCall_fp)(int eventnum);
833 typedef void DLLFUNCCALL(DLLAVClose_fp)();
834 typedef void DLLFUNCCALL(DLLAVGetVersion_fp)(int *version);
835 typedef void DLLFUNCCALL(DLLRunCheck_fp)(char *d3_path);
836 #endif
837
838 DLLAVInit_fp *DLLAVInit = NULL;
839 DLLAVCall_fp *DLLAVCall = NULL;
840 DLLAVClose_fp *DLLAVClose = NULL;
841 DLLAVGetVersion_fp *DLLAVGetVersion = NULL;
842 DLLRunCheck_fp *DLLRunCheck = NULL;
843
844 struct msn_list {
845 char msn_name[_MAX_PATH];
846 char msn_file[_MAX_PATH];
847 void *ti;
848 struct msn_list *next;
849 };
850
851 msn_list *FirstMsn, *CurrMsn, *TmpMsn;
852
853 #ifdef WIN32
854 #include "directplay.h"
855
856 modem_list *DLLModems_found;
857 int *DLLNum_modems_found;
858
859 LPDPSESSIONDESC2 DLLDirectplay_sessions;
860 #endif
861
862 BOOL DLLTCP_active;
863 BOOL DLLIPX_active;
864
865 void AddMsnItem(msn_list *new_msn) {
866 CurrMsn = FirstMsn;
867 if (CurrMsn) {
868 while (CurrMsn->next) {
869 CurrMsn = CurrMsn->next;
870 }
871 CurrMsn->next = new_msn;
872 CurrMsn = CurrMsn->next;
873 } else {
874 FirstMsn = new_msn;
875 CurrMsn = FirstMsn;
876 }
877 CurrMsn->next = NULL;
878 }
879 void RemoveAllMsnItems(void) {
880 CurrMsn = FirstMsn;
881 if (CurrMsn) {
882 while (CurrMsn->next) {
883 TmpMsn = CurrMsn;
884 DLLRemoveUITextItem(CurrMsn->ti);
885 CurrMsn = CurrMsn->next;
886 DLLmem_free(TmpMsn);
887 }
888 DLLRemoveUITextItem(CurrMsn->ti);
889 DLLmem_free(CurrMsn);
890 }
891 FirstMsn = NULL;
892 }
893
894 msn_list *FindMsnItem(const char *name) {
895 CurrMsn = FirstMsn;
896 if (CurrMsn) {
897 while (CurrMsn->next) {
898 if (strcmp(CurrMsn->msn_name, name) == 0)
899 return CurrMsn;
900 CurrMsn = CurrMsn->next;
901 }
902 if (strcmp(CurrMsn->msn_name, name) == 0)
903 return CurrMsn;
904 }
905 return NULL;
906 }
907
908 void MultiplayerOptionsMenu();
909
910 // Draws a menu that inputs multiplayer game options
911 // Returns true if we are starting a game
912 #define MAX_DLLS 40
913 char dll_text[MAX_DLLS][_MAX_PATH];
914
915 int StartMultiplayerGameMenu() {
916 void *game_name_text = DLLCreateNewUITextItem(TXT(10), UICOL_TEXT_NORMAL, -1); // TXT_LC_GAMENAME
917 void *mission_name_text = DLLCreateNewUITextItem(TXT(11), UICOL_TEXT_NORMAL, -1); // TXT_LC_MSNNAME
918 void *script_name_text = DLLCreateNewUITextItem(TXT(12), UICOL_TEXT_NORMAL, -1); // TXT_LC_SCRIPTNAME
919
920 void *start_game_on_text = DLLCreateNewUITextItem(TXT(13), UICOL_HOTSPOT_HI, -1); // TXT_LC_STARTGAME
921 void *multiplayer_opts_on_text = DLLCreateNewUITextItem(TXT(14), UICOL_HOTSPOT_HI, -1); // TXT_LC_MPLYROPTIONS
922 void *exit_on_text = DLLCreateNewUITextItem(TXT(5), UICOL_HOTSPOT_HI, -1); // TXT_LC_PREVMENU
923
924 void *start_game_off_text = DLLCreateNewUITextItem(TXT(13), UICOL_HOTSPOT_LO, -1); // TXT_LC_STARTGAME
925 void *multiplayer_opts_off_text = DLLCreateNewUITextItem(TXT(14), UICOL_HOTSPOT_LO, -1); // TXT_LC_MPLYROPTIONS
926 void *exit_off_text = DLLCreateNewUITextItem(TXT(5), UICOL_HOTSPOT_LO, -1); // TXT_LC_PREVMENU
927
928 void *save_settings_txt_on = DLLCreateNewUITextItem(TXT_DLL_SAVESETTINGS, UICOL_HOTSPOT_HI, -1);
929 void *save_settings_txt_off = DLLCreateNewUITextItem(TXT_DLL_SAVESETTINGS, UICOL_HOTSPOT_LO, -1);
930
931 void *load_settings_txt_on = DLLCreateNewUITextItem(TXT_DLL_LOADSETTINGS, UICOL_HOTSPOT_HI, -1);
932 void *load_settings_txt_off = DLLCreateNewUITextItem(TXT_DLL_LOADSETTINGS, UICOL_HOTSPOT_LO, -1);
933
934 void *start_text = DLLCreateNewUITextItem(TXT(13), UICOL_WINDOW_TITLE, DLL_BIG_BRIEFING_FONT);
935
936 void *blank_text = DLLCreateNewUITextItem("", GR_BLACK, -1);
937 void *dll_txt_items[MAX_DLLS];
938 int a;
939 for (a = 0; a < MAX_DLLS; a++)
940 dll_txt_items[a] = NULL;
941 char str[100];
942 int exit_menu = 0;
943 int cury = 40;
944 int ret = 0;
945 int dllcount = 0;
946 int id = 100;
947
948 rendering_state rs;
949 DLLrend_GetRenderState(&rs);
950
951 void *main_wnd = DLLNewUIWindowCreate(0, 0, rs.screen_width, rs.screen_height, UIF_PROCESS_ALL);
952
953 void *start_title = DLLTextCreate(main_wnd, start_text, 0, cury, UIF_CENTER);
954 cury += 35;
955
956 // Mission name
957 void *mission_text = DLLTextCreate(main_wnd, game_name_text, 0, cury, UIF_CENTER);
958 cury += 15;
959 void *mission_name_edit = DLLEditCreate(main_wnd, id++, 10, cury, 300, 15, UIF_CENTER);
960 cury += 18;
961 cury += 30;
962
963 // mission name
964 void *game_name = DLLTextCreate(main_wnd, mission_name_text, 45, cury, 0);
965 cury += 15;
966
967 void *list_1 = DLLListCreate(main_wnd, id++, 40, cury, 200, 100, 0);
968
969 // Back up the the same line!
970 cury -= 15;
971
972 // Script box
973 void *script_name = DLLTextCreate(main_wnd, script_name_text, 370, cury, 0);
974 cury += 18;
975 void *script_list = DLLListCreate(main_wnd, id++, 360, cury, 200, 100, 0);
976 cury += 118;
977 cury += 40;
978
979 // Start button
980 int start_button = UID_OK;
981 void *start_hs = DLLHotSpotCreate(main_wnd, UID_OK, KEY_ENTER, start_game_off_text, start_game_on_text, 10, cury, 180,
982 30, UIF_FIT | UIF_CENTER);
983 cury += 18;
984
985 // Option button
986 int option_button = id;
987 void *option_hs = DLLHotSpotCreate(main_wnd, id++, KEY_O, multiplayer_opts_off_text, multiplayer_opts_on_text, 10,
988 cury, 180, 30, UIF_FIT | UIF_CENTER);
989 cury += 18;
990
991 // cancel button
992
993 int save_button = id;
994 void *save_hs = DLLHotSpotCreate(main_wnd, id++, 0, save_settings_txt_off, save_settings_txt_on, 10, cury, 180, 30,
995 UIF_FIT | UIF_CENTER);
996 cury += 18;
997 int load_button = id;
998 void *load_hs = DLLHotSpotCreate(main_wnd, id++, 0, load_settings_txt_off, load_settings_txt_on, 10, cury, 180, 30,
999 UIF_FIT | UIF_CENTER);
1000 cury += 18;
1001
1002 int cancel_button = UID_CANCEL;
1003 void *cancel_hs = DLLHotSpotCreate(main_wnd, UID_CANCEL, KEY_ESC, exit_off_text, exit_on_text, 10, cury, 180, 30,
1004 UIF_FIT | UIF_CENTER);
1005 // put the multiplayer dll's into the listbox
1006 dllcount = 1;
1007 char buffer[_MAX_PATH];
1008
1009 #if (!(defined(OEM) || defined(DEMO)))
1010 char search[256];
1011 DLLddio_MakePath(search, DLLLocalD3Dir, "netgames", "*.d3m", NULL);
1012 if (DLLddio_FindFileStart(search, buffer)) {
1013 dllcount = 1;
1014 buffer[strlen(buffer) - 4] = '\0'; // Strip out the extention
1015 strcpy(dll_text[dllcount - 1], buffer);
1016 while ((DLLddio_FindNextFile(buffer)) && (dllcount < MAX_DLLS)) {
1017 buffer[strlen(buffer) - 4] = '\0'; // Strip out the extention
1018 strcpy(dll_text[dllcount], buffer);
1019 dllcount++;
1020 }
1021 } else {
1022 dllcount = 0;
1023 }
1024 DLLddio_FindFileClose();
1025 #else
1026 strcpy(dll_text[0], "Anarchy");
1027 strcpy(dll_text[1], "Capture The Flag");
1028 dllcount = 2;
1029 #endif
1030 DLLListRemoveAll(script_list);
1031
1032 int index;
1033
1034 for (index = 0; index < dllcount; index++) {
1035 dll_txt_items[index] = DLLCreateNewUITextItem(dll_text[index], UICOL_LISTBOX_LO, -1);
1036 DLLListAddItem(script_list, dll_txt_items[index]);
1037 }
1038 #if (!(defined(OEM) || defined(DEMO)))
1039 msn_list *mi;
1040
1041 DLLddio_MakePath(search, DLLLocalD3Dir, "data", "levels", "*.msn", NULL);
1042 // DLLmprintf((0,search));
1043 if (DLLddio_FindFileStart(search, buffer)) {
1044 if (DLLIsMissionMultiPlayable(buffer)) {
1045 DLLmprintf(0, "Found a mission: %s\n", buffer);
1046 mi = (msn_list *)DLLmem_malloc(sizeof(msn_list));
1047 strcpy(mi->msn_name, DLLGetMissionName(buffer));
1048 strcpy(mi->msn_file, buffer);
1049 mi->ti = DLLCreateNewUITextItem(mi->msn_name, UICOL_LISTBOX_LO, -1);
1050 AddMsnItem(mi);
1051 DLLListAddItem(list_1, mi->ti);
1052 }
1053 while (DLLddio_FindNextFile(buffer)) {
1054 if (DLLIsMissionMultiPlayable(buffer)) {
1055 DLLmprintf(0, "Found a mission: %s\n", buffer);
1056 mi = (msn_list *)DLLmem_malloc(sizeof(msn_list));
1057 strcpy(mi->msn_name, DLLGetMissionName(buffer));
1058 strcpy(mi->msn_file, buffer);
1059 mi->ti = DLLCreateNewUITextItem(mi->msn_name, UICOL_LISTBOX_LO, -1);
1060 AddMsnItem(mi);
1061 DLLListAddItem(list_1, mi->ti);
1062 }
1063 }
1064 }
1065 DLLddio_FindFileClose();
1066
1067 // char mn3_path[_MAX_PATH*2];
1068 DLLddio_MakePath(search, DLLLocalD3Dir, "missions", "*.mn3", NULL);
1069 // DLLmprintf(0,search);
1070 if (DLLddio_FindFileStart(search, buffer)) {
1071 // DLLddio_MakePath(mn3_path,DLLLocalD3Dir,"missions",buffer,NULL);
1072
1073 if (DLLIsMissionMultiPlayable(buffer) && (stricmp("d3_2.mn3", buffer) != 0)) {
1074 DLLmprintf(0, "Found a mission: %s\n", buffer);
1075 mi = (msn_list *)DLLmem_malloc(sizeof(msn_list));
1076 strcpy(mi->msn_name, DLLGetMissionName(buffer));
1077 strcpy(mi->msn_file, buffer);
1078 mi->ti = DLLCreateNewUITextItem(mi->msn_name, UICOL_LISTBOX_LO, -1);
1079 AddMsnItem(mi);
1080 DLLListAddItem(list_1, mi->ti);
1081 }
1082 while (DLLddio_FindNextFile(buffer)) {
1083 if (stricmp("d3_2.mn3", buffer) == 0)
1084 continue;
1085 // DLLddio_MakePath(mn3_path,DLLLocalD3Dir,"missions",buffer,NULL);
1086 if (DLLIsMissionMultiPlayable(buffer)) {
1087 DLLmprintf(0, "Found a mission: %s\n", buffer);
1088 mi = (msn_list *)DLLmem_malloc(sizeof(msn_list));
1089 strcpy(mi->msn_name, DLLGetMissionName(buffer));
1090 strcpy(mi->msn_file, buffer);
1091 mi->ti = DLLCreateNewUITextItem(mi->msn_name, UICOL_LISTBOX_LO, -1);
1092 AddMsnItem(mi);
1093 DLLListAddItem(list_1, mi->ti);
1094 }
1095 }
1096 }
1097 DLLddio_FindFileClose();
1098 #ifdef RELEASE
1099 // TODO: Make sure the main mission is always listed -- even on a minimal install
1100 if (!FindMsnItem("Descent 3: Retribution")) {
1101 mi = (msn_list *)DLLmem_malloc(sizeof(msn_list));
1102
1103 strcpy(mi->msn_name, "Descent 3: Retribution");
1104 strcpy(mi->msn_file, "d3.mn3");
1105 AddMsnItem(mi);
1106 mi->ti = DLLCreateNewUITextItem(mi->msn_name, UICOL_LISTBOX_LO);
1107 DLLListAddItem(list_1, mi->ti);
1108 }
1109 #endif
1110 const char *p;
1111 #else
1112 void *msn_single_ti = DLLCreateNewUITextItem("Polaris", UICOL_LISTBOX_LO);
1113 void *msn_multi_ti = DLLCreateNewUITextItem("The Core", UICOL_LISTBOX_LO);
1114 void *msn_multi_2 = DLLCreateNewUITextItem("Taurus", UICOL_LISTBOX_LO);
1115 DLLListAddItem(list_1, msn_single_ti);
1116 DLLListAddItem(list_1, msn_multi_ti);
1117 DLLListAddItem(list_1, msn_multi_2);
1118 #endif
1119 // Bash some values to default
1120 char pilot_name[PILOT_STRING_SIZE];
1121 CurrentPilotName(pilot_name);
1122
1123 strcpy(DLLMPlayers[DLLPlayer_num].callsign, pilot_name);
1124 snprintf(str, sizeof(str), "%s's Game", DLLMPlayers[DLLPlayer_num].callsign);
1125 DLLEditSetText(mission_name_edit, str);
1126
1127 DLLNetgame->max_players = 8;
1128 DLLNetgame->packets_per_second = DLLnw_ReccomendPPS();
1129 DLLNetgame->respawn_time = 60;
1130 DLLNetgame->difficulty = 2;
1131 DLLNetgame->flags = NF_RANDOMIZE_RESPAWN;
1132 DLLNewUIWindowLoadBackgroundImage(main_wnd, "multimain.ogf");
1133 DLLNewUIWindowOpen(main_wnd);
1134 char dftset[_MAX_PATH * 2];
1135 DLLddio_MakePath(dftset, DLLLocalD3Dir, "custom", "settings", "default.mps", NULL);
1136 if (DLLMultiLoadSettings(dftset)) {
1137 DLLEditSetText(mission_name_edit, DLLNetgame->name);
1138 #if (!(defined(OEM) || defined(DEMO)))
1139 p = DLLGetMissionName(DLLNetgame->mission);
1140 mi = FindMsnItem(p);
1141
1142 if (mi)
1143 DLLListSelectItem(list_1, mi->ti);
1144 #endif
1145 for (index = 0; index < dllcount; index++) {
1146 if (stricmp(dll_text[index], DLLNetgame->scriptname) == 0) {
1147 DLLListSelectItem(script_list, dll_txt_items[index]);
1148 break;
1149 }
1150 }
1151 }
1152 while (!exit_menu) {
1153 int res;
1154
1155 res = DLLDoUI();
1156
1157 // handle all UI results.
1158
1159 if (res == option_button) {
1160 DLLNewUIWindowClose(main_wnd);
1161 MultiplayerOptionsMenu();
1162 DLLNewUIWindowOpen(main_wnd);
1163 } else if (res == start_button) {
1164 // Get Game name
1165 DLLEditGetText(mission_name_edit, DLLNetgame->name, NETGAME_NAME_LEN);
1166 // Get mission name
1167 #if (!(defined(OEM) || defined(DEMO)))
1168 mi = FindMsnItem(DLLListGetItem(list_1, DLLListGetSelectedIndex(list_1)));
1169 if (!mi)
1170 break;
1171 strncpy(DLLNetgame->mission, mi->msn_file, MSN_NAMELEN);
1172 DLLNetgame->mission[MSN_NAMELEN - 1] = '\0';
1173 strncpy(DLLNetgame->mission_name, mi->msn_name, MISSION_NAME_LEN);
1174 DLLNetgame->mission_name[MISSION_NAME_LEN - 1] = '\0';
1175 #else
1176 // strcpy(DLLNetgame->mission,DLLListGetSelectedIndex(list_1)?"thecore.d3l":"polaris.d3l");
1177
1178 switch (DLLListGetSelectedIndex(list_1)) {
1179 case 0:
1180 strcpy(DLLNetgame->mission, "polaris.d3l");
1181 strncpy(DLLNetgame->mission_name, "Polaris", MISSION_NAME_LEN);
1182 break;
1183 case 1:
1184 strcpy(DLLNetgame->mission, "thecore.d3l");
1185 strncpy(DLLNetgame->mission_name, "The Core", MISSION_NAME_LEN);
1186 break;
1187 case 2:
1188
1189 strcpy(DLLNetgame->mission, "taurus.d3l");
1190 strncpy(DLLNetgame->mission_name, "Taurus", MISSION_NAME_LEN);
1191
1192 break;
1193 default:;
1194 }
1195
1196 // strcpy(DLLNetgame->name,DLLListGetSelectedIndex(list_1)?"The Core":"Polaris");
1197 #endif
1198 // Get script
1199 strcpy(buffer, DLLListGetItem(script_list, DLLListGetSelectedIndex(script_list)));
1200 if (strcmp(buffer, "None")) {
1201 // remove file extension
1202 for (int d = strlen(buffer) - 1; d >= 0; d--) {
1203 if (buffer[d] == '.') {
1204 buffer[d] = '\0';
1205 break;
1206 }
1207 }
1208
1209 #if (defined(OEM) || defined(DEMO))
1210 if (!stricmp(buffer, "Capture The Flag"))
1211 strcpy(buffer, "CTF");
1212 #endif
1213
1214 strcpy(DLLNetgame->scriptname, buffer);
1215 }
1216
1217 // Actually start the game
1218 // DAJ commen out next line if problems
1219 int teams = DLLCheckMissionForScript(DLLNetgame->mission, DLLNetgame->scriptname, 0);
1220 // int teams = 1;
1221 if (teams >= 0)
1222 #if (!(defined(OEM) || defined(DEMO)))
1223 {
1224 if (DLLLoadMission(DLLNetgame->mission))
1225 #else
1226 {
1227 if (DLLLoadMission(DLLNetgame->mission))
1228 #endif
1229 {
1230 // Do warp dialog here if needed
1231 if (-1 != DLLMultiLevelSelection()) {
1232 DLLmprintf(0, "Mission loaded successfully!\n");
1233 DLLMultiStartServer(1, DLLNetgame->scriptname, teams);
1234 exit_menu = 1;
1235 ret = 1;
1236 }
1237 }
1238 }
1239 } else if (res == cancel_button) {
1240 exit_menu = 1;
1241 } else if (res == save_button) {
1242 // Get Game name
1243 DLLEditGetText(mission_name_edit, DLLNetgame->name, NETGAME_NAME_LEN);
1244 #if (!(defined(OEM) || defined(DEMO)))
1245 // Get mission name
1246 mi = FindMsnItem(DLLListGetItem(list_1, DLLListGetSelectedIndex(list_1)));
1247 if (!mi)
1248 break;
1249 strcpy(DLLNetgame->mission, mi->msn_file);
1250 #endif
1251 // Get script
1252 strcpy(buffer, DLLListGetItem(script_list, DLLListGetSelectedIndex(script_list)));
1253 if (strcmp(buffer, "None")) {
1254 // remove file extension
1255 for (int d = strlen(buffer) - 1; d >= 0; d--) {
1256 if (buffer[d] == '.') {
1257 buffer[d] = '\0';
1258 break;
1259 }
1260 }
1261
1262 strcpy(DLLNetgame->scriptname, buffer);
1263 }
1264 DLLMultiDoConfigSave();
1265 } else if (res == load_button) {
1266 // Get Game name
1267 DLLEditGetText(mission_name_edit, DLLNetgame->name, NETGAME_NAME_LEN);
1268 #if (!(defined(OEM) || defined(DEMO)))
1269 // Get mission name
1270 mi = FindMsnItem(DLLListGetItem(list_1, DLLListGetSelectedIndex(list_1)));
1271 if (!mi)
1272 break;
1273 strcpy(DLLNetgame->mission, mi->msn_file);
1274 #endif
1275 // Get script
1276 strcpy(buffer, DLLListGetItem(script_list, DLLListGetSelectedIndex(script_list)));
1277 if (strcmp(buffer, "None")) {
1278 // remove file extension
1279 for (int d = strlen(buffer) - 1; d >= 0; d--) {
1280 if (buffer[d] == '.') {
1281 buffer[d] = '\0';
1282 break;
1283 }
1284 }
1285
1286 strcpy(DLLNetgame->scriptname, buffer);
1287 }
1288 DLLMultiDoConfigLoad();
1289 if (!Use_netgame_flags) {
1290 DLLNetgame->flags = 0;
1291 }
1292 DLLEditSetText(mission_name_edit, DLLNetgame->name);
1293 #if (!(defined(OEM) || defined(DEMO)))
1294 p = DLLGetMissionName(DLLNetgame->mission);
1295 mi = FindMsnItem(p);
1296
1297 if (mi)
1298 DLLListSelectItem(list_1, mi->ti);
1299 #endif
1300 for (index = 0; index < dllcount; index++) {
1301 if (stricmp(dll_text[index], DLLNetgame->scriptname) == 0) {
1302 DLLListSelectItem(script_list, dll_txt_items[index]);
1303 break;
1304 }
1305 }
1306 }
1307 }
1308
1309 DLLNewUIWindowClose(main_wnd);
1310 DLLNewUIWindowDestroy(main_wnd);
1311 for (a = 0; a < MAX_DLLS; a++)
1312 if (dll_txt_items[a])
1313 DLLRemoveUITextItem(dll_txt_items[a]);
1314 RemoveAllMsnItems();
1315 // cleanup
1316 #ifdef DEMO
1317 DLLRemoveUITextItem(msn_multi_ti);
1318 DLLRemoveUITextItem(msn_single_ti);
1319 DLLRemoveUITextItem(msn_multi_2);
1320 #endif
1321 DLLRemoveUITextItem(game_name_text);
1322 DLLRemoveUITextItem(mission_name_text);
1323 DLLRemoveUITextItem(script_name_text);
1324 DLLRemoveUITextItem(start_game_on_text);
1325 DLLRemoveUITextItem(multiplayer_opts_on_text);
1326 DLLRemoveUITextItem(exit_on_text);
1327 DLLRemoveUITextItem(start_game_off_text);
1328 DLLRemoveUITextItem(multiplayer_opts_off_text);
1329 DLLRemoveUITextItem(exit_off_text);
1330 DLLRemoveUITextItem(blank_text);
1331 DLLRemoveUITextItem(save_settings_txt_on);
1332 DLLRemoveUITextItem(save_settings_txt_off);
1333 DLLRemoveUITextItem(load_settings_txt_on);
1334 DLLRemoveUITextItem(load_settings_txt_off);
1335
1336 DLLRemoveUITextItem(start_text);
1337
1338 DLLDeleteUIItem(start_title);
1339 DLLDeleteUIItem(save_hs);
1340 DLLDeleteUIItem(load_hs);
1341 DLLDeleteUIItem(main_wnd);
1342 DLLDeleteUIItem(game_name);
1343 DLLDeleteUIItem(list_1);
1344 DLLDeleteUIItem(mission_text);
1345 DLLDeleteUIItem(mission_name_edit);
1346 DLLDeleteUIItem(script_name);
1347 DLLDeleteUIItem(script_list);
1348 DLLDeleteUIItem(option_hs);
1349 DLLDeleteUIItem(start_hs);
1350 DLLDeleteUIItem(cancel_hs);
1351
1352 return ret;
1353 }
1354
1355 void MultiplayerOptionsMenu() {
1356 #ifndef MULTI_USE_ALL_OPTIONS
1357 DLLMultiGameOptionsMenu(0);
1358 #else
1359 DLLMultiGameOptionsMenu(1);
1360 #endif
1361 }