Debian Codegraph @

Descent3/multi_ui.cpp

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/multi_ui.cpp $
21 * $Revision: 105 $
22 * $Date: 7/09/01 3:34p $
23 * $Author: Matt $
24 *
25 *
26 *
27 * $Log: /DescentIII/main/multi_ui.cpp $
28 *
29 * 105 7/09/01 3:34p Matt
30 * Require at least one allowed ship when starting a netgame.
31 *
32 * 104 4/20/00 6:25p Matt
33 * Netgame info dialog was looking at wrong variable for the difficulty
34 * level.
35 *
36 * 103 8/02/99 9:57a Kevin
37 * fixed port parameter with -pxo
38 *
39 * 102 5/19/99 1:10p Kevin
40 * set the default (or previously selected) difficulty level
41 *
42 * 101 5/09/99 4:55p Kevin
43 * Added some options for directplay games
44 *
45 * 100 5/09/99 1:34p Kevin
46 * Added diffuculty level system to multiplayer
47 *
48 * 99 5/08/99 3:58p Kevin
49 * made ESC clear the game info dialog
50 *
51 * 98 5/06/99 6:11p Kevin
52 * fixes for save/load game syste. Also require CD again and added some
53 * heat.net stuff
54 *
55 * 97 5/06/99 1:04a Kevin
56 * Fixed stupid default selection problem
57 *
58 * 96 5/05/99 11:59p Kevin
59 * fixed command line parms for auto connecting
60 *
61 * 95 5/05/99 11:16p Kevin
62 * heat.net stuff among other things
63 *
64 * 94 4/28/99 10:04p Kevin
65 * doh! forgot to return a value
66 *
67 * 93 4/28/99 6:39p Kevin
68 * Build 182 fixes
69 *
70 * 92 4/26/99 9:11p Matt
71 * Use small font instead of old UI font.
72 *
73 * 91 4/25/99 5:02p Kevin
74 * Bunches of multiplayer UI improvements
75 *
76 * 90 4/25/99 9:44a Kevin
77 * localized remaining game info strings
78 *
79 * 89 4/25/99 8:58a Kevin
80 * fixes for server info dialog
81 *
82 * 88 4/24/99 11:58p Kevin
83 * Game info list (hit I in the pxo game list)
84 *
85 * 87 4/23/99 5:32p Kevin
86 * Fixed a few mission bugs.
87 *
88 * 86 4/20/99 11:47a Samir
89 * converted protocol help to newui and fixed connection menu so enter
90 * worked on listbox.
91 *
92 * 85 4/17/99 3:44p Kevin
93 * Demo2 changes & fixes
94 *
95 * 84 4/16/99 6:00p Kevin
96 * Bunches of Demo stuff
97 *
98 * 83 4/16/99 3:17p Kevin
99 * More mouselook support
100 *
101 * 82 4/16/99 11:56a Matt
102 * Changed directplay code to be "ifdef _WIN32" instead of "ifndef
103 * __LINUX__" so it will work on the Mac.
104 *
105 * 81 4/15/99 3:36p Kevin
106 * Added mouselook UI stuff to the multiplayer options menu
107 *
108 * 80 4/15/99 1:41a Jeff
109 * changes for linux compile
110 *
111 * 79 4/14/99 4:19a Jeff
112 * more case mismatch fixes in #includes
113 *
114 * 78 4/14/99 2:51a Jeff
115 * fixed some case mismatched #includes
116 *
117 * 77 4/08/99 4:54p Kevin
118 * Display level warp dialog for multiplayer
119 *
120 * 76 4/03/99 9:26p Jeff
121 * changed dialogs that weren't using UID_OK and UID_CANCEL to use and
122 * handle them properly
123 *
124 * 75 3/25/99 3:29p Jason
125 * added option to randomize powerup respawn points
126 *
127 * 74 3/03/99 12:44p Jason
128 * made options mirror that of the 1.1 demo
129 *
130 * 73 3/01/99 12:55a Matt
131 * Deleted some obsolete strings from the string table, and moved some
132 * formatting info from the table to the code.
133 *
134 * 72 2/28/99 6:00p Jeff
135 * converted to new ui
136 *
137 * 71 2/24/99 4:00p Jason
138 * fixed flush problem when going to the join menu
139 *
140 * 70 2/20/99 2:31p Kevin
141 * Made multiplayer DLLs return to the game list after a game.
142 *
143 * 69 2/15/99 7:50p Jeff
144 * new pilot file class and read/write system checked in...should be more
145 * robust than old
146 *
147 * 68 2/10/99 1:32p Kevin
148 * Added tablefile ignore thingy
149 *
150 * 67 2/08/99 2:39p Kevin
151 * Fixed command line joining & disabled gamespy launching in OEM builds
152 *
153 * 66 1/29/99 5:22p Jeff
154 * localization
155 *
156 * 65 1/23/99 3:21p Kevin
157 * Fixed default selection to work with new sorted listboxes
158 *
159 * 64 1/05/99 5:09p Jason
160 * added permissable server networking (ala Quake/Unreal) to Descent3
161 *
162 * 63 1/04/99 6:56p Kevin
163 * Fixed unmatched if/else
164 *
165 * 62 12/30/98 3:49p Kevin
166 * Moved multiplayer options out of DLL and into main app
167 *
168 * 61 11/20/98 11:16a Kevin
169 * Fixed command line game launching
170 *
171 * 60 11/19/98 5:40p Kevin
172 * Demo system
173 *
174 * 59 10/24/98 10:49a Kevin
175 * Fixed Direct Serial Game
176 *
177 * 58 10/20/98 5:47p Kevin
178 * Gunboy and other fixes
179 *
180 * 57 10/19/98 11:54a Kevin
181 *
182 * 56 10/19/98 10:54a Kevin
183 * Fixed help option
184 *
185 * 55 10/16/98 11:55a Kevin
186 * Made dlls loadable in a hog
187 *
188 * 54 10/15/98 10:58a Kevin
189 * fixed ~ thingy for the first file in the dir
190 *
191 * 53 10/14/98 2:48p Kevin
192 * Changed memory code to comply with mem lib
193 *
194 * 52 10/09/98 12:59a Craig
195 * Fixed ship name for demo
196 *
197 * 51 10/06/98 5:34p Jeff
198 * various UI changes/improvements
199 *
200 * 50 10/01/98 11:45a Kevin
201 * fixed hotspot colors in allow/disallow screen
202 *
203 * 49 9/30/98 10:36a Kevin
204 * Added command line launching of URLs and command line directory
205 * specification
206 *
207 * 48 9/29/98 2:23p Kevin
208 * More UI tweaks
209 *
210 * 47 9/28/98 6:53p Kevin
211 * localized some multiplayer menus
212 *
213 * 46 9/28/98 4:35p Jeff
214 * general UI changes and improvements
215 *
216 * 45 9/28/98 4:21p Kevin
217 * Redesigned game list menus
218 *
219 * 44 9/28/98 9:53a Kevin
220 * Fixing misc UI problems, and fixed some bugs that VC 6 found
221 *
222 * 43 9/25/98 11:07a Kevin
223 * fixed columns to line up and cleaned up some PXO bugs
224 *
225 * 42 9/23/98 6:33p Kevin
226 * Fixed load settings
227 *
228 * 41 9/23/98 2:54p Kevin
229 * Saved multi config and changed UI to conform
230 *
231 * 40 9/22/98 3:55p Kevin
232 * Removed obsolete function
233 *
234 * 39 9/22/98 2:29p Kevin
235 * moved ships allowed code out of dll and into main app. Also added
236 * powerup exclusions
237 *
238 * 38 8/26/98 1:31p Jason
239 * Flush buffers before starting a game
240 *
241 * 37 8/17/98 11:00a Kevin
242 * Moved DLLs into subdirectories
243 *
244 * 36 8/15/98 5:16p Matt
245 * Added new Base_directory variable. Got rid of D3_LOCAL check and
246 * 'local directory' registry variable.
247 *
248 * 35 7/10/98 10:47a Kevin
249 * Added command line connecting to games
250 *
251 * 34 7/01/98 2:52p Kevin
252 * coop -- adding sound index
253 *
254 * 33 6/24/98 6:40p Kevin
255 * Added help to main dll menu
256 *
257 * 32 6/18/98 4:49p Kevin
258 * Updated multiplayer menus
259 *
260 * 31 6/16/98 10:54a Jeff
261 *
262 * 30 6/11/98 2:33p Kevin
263 * Updated dsps for new dll names
264 *
265 * 29 6/11/98 2:11p Kevin
266 * New Main multiplayer menu & dlls renamed to d3c
267 *
268 * 28 6/01/98 12:09p Kevin
269 * closed the menu before loading DLLs
270 *
271 * 27 6/01/98 10:09a Kevin
272 * Added DLL connection interface and auto update DLL
273 *
274 * 26 5/12/98 5:59p Jason
275 * fixed stupid timer bug
276 *
277 * 25 5/05/98 3:02p Jason
278 * attempting to add different screen resolutions
279 *
280 * 24 5/04/98 10:56a Kevin
281 * Mastertracker fixes/enhancements
282 *
283 * 23 5/01/98 12:28p Kevin
284 * Added new user registration button for MT
285 *
286 * 22 4/30/98 3:50p Kevin
287 * Mastertracker pilot stats
288 *
289 * 21 4/28/98 12:50p Kevin
290 * Master tracker login
291 *
292 * 20 4/27/98 7:12p Kevin
293 * Mastertracker pilot tracker
294 *
295 * 19 4/24/98 3:50p Kevin
296 * Added mastertracker game tracking support
297 *
298 * 18 4/23/98 4:49p Kevin
299 * Added Master tracker Game tracker support
300 *
301 * 17 4/23/98 2:12p Kevin
302 * Adding Mastertracker stuff
303 *
304 * 16 4/14/98 7:56p Matt
305 * Moved MSN_NAMELEN from mission.h to descent,h, so multi.h didn't need
306 * to include mission.h.
307 * Changed code to use ddio_MakePath() instead of sprintf() to make file
308 * spec.
309 *
310 */
311
312 #include "args.h"
313 #include "ui.h"
314 #include "newui.h"
315 #include "game.h"
316 #include "gamefont.h"
317 #include "descent.h"
318 #include "multi.h"
319 #include "multi_ui.h"
320 #include "multi_server.h"
321 #include "multi_client.h"
322 #include "networking.h"
323 #include "player.h"
324 #include "manage.h"
325 #include "pilot.h"
326 #include <stdlib.h>
327 #include "ddio.h"
328 #include "objinfo.h"
329 #include "stringtable.h"
330 #include "ConfigItem.h"
331 #include "appdatabase.h"
332
333 // #define USE_DIRECTPLAY
334
335 #ifdef USE_DIRECTPLAY
336 #include "directplay.h"
337 #endif
338
339 #include "ship.h"
340
341 #include "multi_dll_mgr.h"
342 #include "Mission.h"
343 #include "menu.h"
344
345 #include "multi_save_settings.h"
346
347 #include <algorithm>
348
349 #define MAIN_MULTI_MENU_W 384
350 #define MAIN_MULTI_MENU_H 256
351 #define MAIN_MULTI_MENU_X 320 - (MAIN_MULTI_MENU_W / 2)
352 #define MAIN_MULTI_MENU_Y 240 - (MAIN_MULTI_MENU_H / 2)
353
354 #define HELP_MULTI_MENU_W 512
355 #define HELP_MULTI_MENU_H 192
356 #define HELP_MULTI_MENU_X 320 - (MAIN_MULTI_MENU_W / 2)
357 #define HELP_MULTI_MENU_Y 240 - (MAIN_MULTI_MENU_H / 2)
358
359 #define MAX_HELP_TEXT_LEN 1000
360 char HelpText1[MAX_HELP_TEXT_LEN];
361 char HelpText2[MAX_HELP_TEXT_LEN];
362 char HelpText3[MAX_HELP_TEXT_LEN];
363 char HelpText4[MAX_HELP_TEXT_LEN];
364
365 int MultiDLLGameStarting = 0;
366
367 void DisplayNetDLLHelp(const char *topic);
368 // The first multiplayer menu that the user will see...all multiplayer stuff is
369 // reached from this menu
370 // Returns true if we're starting a multiplayer game
371 #define MAX_DLLS 10
372 #define JEFF_RED GR_RGB(255, 40, 40)
373 #define MAX_NET_DLL_LEN 100
374
375 #define UID_MULTILB 0x1000
376
377 #define HEAT_NAME "HEAT.NET"
378 #define PXO_NAME "Parallax Online"
379
380 int MainMultiplayerMenu() {
381
382 mprintf(0, "Entering MainMultiplayerMenu()\n");
383
384 #ifdef USE_DIRECTPLAY
385 Num_directplay_games = 0;
386 #endif
387 int exit_menu = 0;
388 int ret = 0;
389 char sznetgame[MAX_NET_DLL_LEN] = "";
390 int netgamelen = MAX_NET_DLL_LEN;
391 int i;
392 uint32_t j;
393
394 for (i = 0; i < MAX_OBJECT_IDS; i++) {
395 if (Object_info[i].type == OBJ_POWERUP) {
396 Object_info[i].multi_allowed = 1;
397 }
398 }
399 for (i = 0; i < MAX_SHIPS; i++) {
400 if (Ships[i].used) {
401
402 #ifdef DEMO
403 if (stricmp(Ships[i].name, "pyro-gl") == 0)
404 #endif
405 PlayerSetShipPermission(-1, Ships[i].name, 1);
406 #ifdef DEMO
407 else
408 PlayerSetShipPermission(-1, Ships[i].name, 0);
409 #endif
410 }
411 }
412 // Clear out residual junk
413 MultiFlushAllIncomingBuffers();
414
415 SetScreenMode(SM_MENU);
416
417 Database->read("DefaultNetConn", sznetgame, &netgamelen);
418 if (*sznetgame == '\0') {
419 strcpy(sznetgame, "HEAT.NET");
420 Database->write("DefaultNetConn", sznetgame, strlen(sznetgame) + 1);
421 }
422
423 newuiTiledWindow menu_wnd;
424 newuiListBox *lists;
425 newuiSheet *sheet;
426
427 menu_wnd.Create(TXT_MULTIPLAYER, 0, 0, MAIN_MULTI_MENU_W, MAIN_MULTI_MENU_H);
428 sheet = menu_wnd.GetSheet();
429
430 sheet->NewGroup(TXT_MLTCHOOSETYPE, 25, 0);
431 lists = sheet->AddListBox(256, 128, UID_MULTILB, UILB_NOSORT);
432 lists->RemoveAll();
433
434 sheet->NewGroup(NULL, 75, 145);
435 sheet->AddLongButton(TXT_SETITEMDEFAULT, 0x30);
436
437 sheet->NewGroup(NULL, 55, 160, NEWUI_ALIGN_HORIZ);
438 sheet->AddButton(TXT_OK, UID_OK);
439 sheet->AddButton(TXT_REALHELP, 0x20);
440 sheet->AddButton(TXT_CANCEL, UID_CANCEL);
441
442 int dllcount = 1;
443 char buffer[_MAX_PATH], fname[_MAX_PATH], fext[_MAX_PATH], fdir[_MAX_PATH];
444 char search[256];
445
446 ddio_MakePath(search, Base_directory, "online", "*.d3c", NULL);
447
448 int dftidx = -1;
449 dllcount = 0;
450
451 // Put the HEAT on top.
452 if (ddio_FindFileStart(search, buffer)) {
453
454 ddio_SplitPath(buffer, fdir, fname, fext);
455
456 if (!stricmp(HEAT_NAME, fname)) {
457 lists->AddItem(fname);
458 dllcount++;
459 }
460 if (!stricmp(sznetgame, fname)) {
461 dftidx = 0;
462 }
463
464 while ((ddio_FindNextFile(buffer)) && (dllcount < MAX_DLLS)) {
465 ddio_SplitPath(buffer, fdir, fname, fext);
466 if (!stricmp(HEAT_NAME, fname)) {
467 lists->AddItem(fname);
468 dllcount++;
469 }
470 if (!stricmp(sznetgame, fname)) {
471 dftidx = 0;
472 }
473 }
474 }
475
476 // Put the PXO next.
477 if (ddio_FindFileStart(search, buffer)) {
478
479 ddio_SplitPath(buffer, fdir, fname, fext);
480
481 if (!stricmp(PXO_NAME, fname)) {
482 lists->AddItem(fname);
483 dllcount++;
484 }
485 if (!stricmp(sznetgame, fname)) {
486 dftidx = 1;
487 }
488
489 while ((ddio_FindNextFile(buffer)) && (dllcount < MAX_DLLS)) {
490 ddio_SplitPath(buffer, fdir, fname, fext);
491 if (!stricmp(PXO_NAME, fname)) {
492 lists->AddItem(fname);
493 dllcount++;
494 }
495 if (!stricmp(sznetgame, fname)) {
496 dftidx = 1;
497 }
498 }
499 }
500
501 if (ddio_FindFileStart(search, buffer)) {
502
503 ddio_SplitPath(buffer, fdir, fname, fext);
504
505 for (j = 0; j < strlen(fname); j++) {
506 if (fname[j] == '~') {
507 fname[j] = '/';
508 }
509 }
510
511 if ((stricmp(HEAT_NAME, fname) != 0) && (stricmp(PXO_NAME, fname) != 0)) {
512 lists->AddItem(fname);
513 if (!stricmp(sznetgame, fname)) {
514 dftidx = dllcount;
515 }
516 dllcount++;
517 }
518
519 uint32_t len;
520 while ((ddio_FindNextFile(buffer)) && (dllcount < MAX_DLLS)) {
521 ddio_SplitPath(buffer, fdir, fname, fext);
522 len = strlen(fname);
523
524 for (j = 0; j < len; j++) {
525 if (fname[j] == '~') {
526 fname[j] = '/';
527 }
528 }
529
530 if ((stricmp(HEAT_NAME, fname) != 0) && (stricmp(PXO_NAME, fname) != 0)) {
531 lists->AddItem(fname);
532 if (!stricmp(sznetgame, fname)) {
533 dftidx = dllcount;
534 }
535 dllcount++;
536 }
537 }
538 } else {
539 dllcount = 0;
540 }
541 ddio_FindFileClose();
542
543 if (dllcount == 0) {
544 DoMessageBox(TXT_MULTIPLAYER, TXT_MULTINOFILES, MSGBOX_OK, UICOL_WINDOW_TITLE, UICOL_TEXT_NORMAL);
545 exit_menu = 1;
546 menu_wnd.Destroy();
547 return 0;
548 }
549
550 if (dftidx != -1) {
551 lists->SetCurrentItem(sznetgame); //>SetCurrentIndex(dftidx);
552 }
553
554 MultiDLLGameStarting = 0;
555 menu_wnd.Open();
556
557 // Menu loop
558 char seldll[_MAX_PATH];
559
560 while (!exit_menu) {
561 int res;
562
563 res = menu_wnd.DoUI();
564
565 // handle all UI results.
566 switch (res) {
567 case UID_CANCEL:
568 menu_wnd.Close();
569 exit_menu = 1;
570 break;
571
572 case UID_MULTILB:
573 case UID_OK: {
574 menu_wnd.Close();
575 lists->GetCurrentItem(seldll, _MAX_PATH);
576 uint32_t len = strlen(seldll);
577
578 for (j = 0; j < len; j++) {
579 if (seldll[j] == '/') {
580 seldll[j] = '~';
581 }
582 }
583 // ddio_MakePath(fulldll,Base_directory,"online",seldll,NULL);
584 if (LoadMultiDLL(seldll)) {
585 CallMultiDLL(MT_EVT_LOGIN);
586 exit_menu = 1;
587 ret = MultiDLLGameStarting;
588 } else {
589 exit_menu = 1;
590 ret = 0;
591 }
592 } break;
593
594 case 0x20:
595 // Help
596 {
597 lists->GetCurrentItem(seldll, _MAX_PATH);
598 uint32_t len = strlen(seldll);
599 for (j = 0; j < len; j++) {
600 if (seldll[j] == '/') {
601 seldll[j] = '~';
602 }
603 }
604 // ddio_MakePath(fulldll,Base_directory,"online",seldll,NULL);
605 if (LoadMultiDLL(seldll)) {
606 CallMultiDLL(MT_EVT_GET_HELP);
607 DisplayNetDLLHelp(seldll);
608 FreeMultiDLL();
609 }
610 }
611 break;
612
613 case 0x30:
614 // case 3:
615 {
616 char fmtmsg[200];
617 char def[256];
618
619 // Mark this baby as default.
620 lists->GetCurrentItem(def, 256);
621
622 Database->write("DefaultNetConn", def, strlen(def) + 1);
623 snprintf(fmtmsg, sizeof(fmtmsg), TXT_SETDEFAULT, def);
624 DoMessageBox(TXT_MENUMULTIPLAYER, fmtmsg, MSGBOX_OK, UICOL_WINDOW_TITLE, UICOL_TEXT_NORMAL);
625 break;
626 }
627 }
628 }
629 menu_wnd.Destroy();
630
631 return ret;
632 }
633
634 void DisplayNetDLLHelp(const char *topic) {
635 // samir- converted to newui.
636 newuiTiledWindow menu_wnd;
637 newuiSheet *sheet;
638 int exit_menu = 0;
639 char str[128];
640
641 SetScreenMode(SM_MENU);
642
643 // Create our buttons
644 snprintf(str, sizeof(str), "%s: %s", TXT_REALHELP, topic);
645
646 menu_wnd.Create(str, 0, 0, HELP_MULTI_MENU_W, HELP_MULTI_MENU_H);
647 sheet = menu_wnd.GetSheet();
648
649 sheet->NewGroup(NULL, 10, 30);
650 sheet->AddText(HelpText1);
651 sheet->AddText(HelpText2);
652 sheet->AddText(HelpText3);
653 sheet->AddText(HelpText4);
654
655 sheet->NewGroup(NULL, (HELP_MULTI_MENU_W - 140), HELP_MULTI_MENU_H - 95, NEWUI_ALIGN_HORIZ);
656 sheet->AddButton(TXT_CLOSE, UID_OK);
657
658 menu_wnd.Open();
659
660 // Menu loop
661 while (!exit_menu) {
662 int res;
663
664 res = menu_wnd.DoUI();
665
666 // handle all UI results.
667 switch (res) {
668 case UID_OK:
669 exit_menu = 1;
670 break;
671 }
672 }
673
674 menu_wnd.Close();
675 menu_wnd.Destroy();
676 }
677
678 int AutoConnectPXO() {
679 // char seldll[_MAX_PATH];
680 int iparg;
681 int portarg;
682 MultiDLLGameStarting = 0;
683 iparg = FindArg("-pxo");
684 if (!iparg) {
685 return 0;
686 }
687
688 strcpy(Auto_login_addr, GameArgs[iparg + 1]);
689
690 char *port = strchr(Auto_login_addr, ':');
691 if (port) {
692 // terminate the hostname
693 *port = '\0';
694 // Increment to the first character of the port name
695 port++;
696 // get the port number
697 strcpy(Auto_login_port, port);
698 } else {
699 portarg = FindArg("port");
700 if (portarg) {
701 strcpy(Auto_login_port, GameArgs[portarg + 1]);
702 } else {
703 Auto_login_port[0] = '\0';
704 }
705 }
706
707 // ddio_MakePath(seldll,Base_directory,"online","parallax online.d3c",NULL);
708 if (LoadMultiDLL("parallax online")) {
709 CallMultiDLL(MT_AUTO_LOGIN);
710 }
711 return MultiDLLGameStarting;
712 }
713
714 int AutoConnectLANIP() {
715 // char seldll[_MAX_PATH];
716 int iparg;
717 int portarg;
718 MultiDLLGameStarting = 0;
719 iparg = FindArg("ip");
720 if (!iparg) {
721 int connarg = FindArg("-directip");
722
723 if (!connarg)
724 return 0;
725 strcpy(Auto_login_addr, GameArgs[connarg + 1]);
726 char *port = strchr(Auto_login_addr, ':');
727 if (port) {
728 // terminate the hostname
729 *port = '\0';
730 // Increment to the first character of the port name
731 port++;
732 // get the port number
733 strcpy(Auto_login_port, port);
734 }
735 } else {
736 strcpy(Auto_login_addr, GameArgs[iparg + 1]);
737
738 portarg = FindArg("port");
739 if (portarg) {
740 strcpy(Auto_login_port, GameArgs[portarg + 1]);
741 } else {
742 Auto_login_port[0] = '\0';
743 }
744 }
745 // ddio_MakePath(seldll,Base_directory,"online","Direct TCP~IP Game.d3c",NULL);
746 if (LoadMultiDLL("Direct TCP~IP")) {
747 CallMultiDLL(MT_AUTO_LOGIN);
748 }
749 return MultiDLLGameStarting;
750 }
751
752 int AutoConnectHeat() {
753 // char seldll[_MAX_PATH];
754 int iparg;
755 int portarg;
756 MultiDLLGameStarting = 0;
757 iparg = FindArg("ip");
758 if (!iparg) {
759 int connarg = FindArg("-heat");
760
761 if (!connarg)
762 return 0;
763 strcpy(Auto_login_addr, GameArgs[connarg + 1]);
764 char *port = strchr(Auto_login_addr, ':');
765 if (port) {
766 // terminate the hostname
767 *port = '\0';
768 // Increment to the first character of the port name
769 port++;
770 // get the port number
771 strcpy(Auto_login_port, port);
772 }
773 } else {
774 strcpy(Auto_login_addr, GameArgs[iparg + 1]);
775
776 portarg = FindArg("port");
777 if (portarg) {
778 strcpy(Auto_login_port, GameArgs[portarg + 1]);
779 } else {
780 Auto_login_port[0] = '\0';
781 }
782 }
783 if (LoadMultiDLL("HEAT.NET")) {
784 CallMultiDLL(MT_AUTO_LOGIN);
785 }
786 return MultiDLLGameStarting;
787 }
788
789 #include "mem.h"
790
791 void DoMultiAllowed(void) {
792 rendering_state rs;
793 rend_GetRenderState(&rs);
794 int cury = 30;
795 int i;
796 const char *p;
797 int objid;
798 int *index_to_id = NULL;
799 bool shipsallowed[MAX_SHIPS];
800 bool objsallowed[MAX_OBJECTS];
801 ConfigItem **ship_list = NULL;
802 size_t strMax = std::max(strlen(TXT_ALLOW), strlen(TXT_DISALLOW)) + 3;
803 char *str = (char *)mem_malloc(strMax);
804
805 // Create Text Items and Window
806 UITextItem cancel_on_text(TXT_CANCEL, UICOL_HOTSPOT_HI);
807 UITextItem cancel_off_text(TXT_CANCEL, UICOL_HOTSPOT_LO);
808
809 UITextItem exit_on_text(TXT_DONE, UICOL_HOTSPOT_HI);
810 UITextItem exit_off_text(TXT_DONE, UICOL_HOTSPOT_LO);
811
812 snprintf(str, strMax, "\x18 %s", TXT_ALLOW);
813 UITextItem add_on(str, UICOL_HOTSPOT_HI);
814 UITextItem add_off(str, UICOL_HOTSPOT_LO);
815
816 snprintf(str, strMax, "%s \x1a", TXT_DISALLOW);
817 UITextItem remove_on(str, UICOL_HOTSPOT_HI);
818 UITextItem remove_off(str, UICOL_HOTSPOT_LO);
819 mem_free(str);
820
821 UITextItem allowed_ships(TXT_ALLOWEDSHIPS, UICOL_TEXT_NORMAL);
822 UITextItem banned_ships(TXT_DISALLOWDSHIPS, UICOL_TEXT_NORMAL);
823
824 UITextItem allowed_gen(TXT_ALLOWEDITEMS, UICOL_TEXT_NORMAL);
825 UITextItem banned_gen(TXT_DISALLOWEDITEM, UICOL_TEXT_NORMAL);
826
827 UITextItem obj_ti[MAX_OBJECT_IDS];
828 UITextItem ship_ti[MAX_SHIPS];
829
830 NewUIWindow menu_wnd;
831 menu_wnd.Create(0, 0, rs.screen_width, rs.screen_height, UIF_PROCESS_ALL);
832
833 int xcol1 = 110;
834 int yrow1 = 50;
835 int xcol2 = 374;
836 int yrow2 = 250;
837 int list_xsize = 160;
838 int list_ysize = 160;
839
840 NewUIListBox lb_ships_allowed;
841 NewUIListBox lb_ships_banned;
842
843 NewUIListBox lb_generic_allowed;
844 NewUIListBox lb_generic_banned;
845 UIHotspot exit_hs;
846 UIHotspot add_ship_hs;
847 UIHotspot remove_ship_hs;
848 UIHotspot add_gen_hs;
849 UIHotspot remove_gen_hs;
850 UIHotspot cancel_hs;
851
852 UIText ship_allowed_txt;
853 UIText ship_banned_txt;
854 UIText gen_allowed_txt;
855 UIText gen_banned_txt;
856
857 int textw;
858 int startx;
859
860 grtext_SetFont(SMALL_FONT);
861
862 add_ship_hs.Create(&menu_wnd, 10, 0, &add_off, &add_on, 10, (yrow1 + (list_ysize / 2)) - 25, 130, 30,
863 UIF_FIT | UIF_CENTER);
864 remove_ship_hs.Create(&menu_wnd, 11, 0, &remove_off, &remove_on, 10, (yrow1 + (list_ysize / 2)) - 5, 130, 30,
865 UIF_FIT | UIF_CENTER);
866
867 add_gen_hs.Create(&menu_wnd, 12, 0, &add_off, &add_on, 10, (yrow2 + (list_ysize / 2)) - 25, 130, 30,
868 UIF_FIT | UIF_CENTER);
869 remove_gen_hs.Create(&menu_wnd, 13, 0, &remove_off, &remove_on, 10, (yrow2 + (list_ysize / 2)) - 5, 130, 30,
870 UIF_FIT | UIF_CENTER);
871
872 textw = grtext_GetTextLineWidth(allowed_ships.GetBuffer());
873 startx = ((list_xsize / 2) + xcol1) - (textw / 2);
874
875 ship_allowed_txt.Create(&menu_wnd, &allowed_ships, startx, yrow1 - 15, 0);
876 textw = grtext_GetTextLineWidth(banned_ships.GetBuffer());
877 startx = ((list_xsize / 2) + xcol2) - (textw / 2);
878
879 ship_banned_txt.Create(&menu_wnd, &banned_ships, startx, yrow1 - 15, 0);
880 textw = grtext_GetTextLineWidth(allowed_gen.GetBuffer());
881 startx = ((list_xsize / 2) + xcol1) - (textw / 2);
882
883 gen_allowed_txt.Create(&menu_wnd, &allowed_gen, startx, yrow2 - 15, 0);
884 textw = grtext_GetTextLineWidth(banned_gen.GetBuffer());
885 startx = ((list_xsize / 2) + xcol2) - (textw / 2);
886
887 gen_banned_txt.Create(&menu_wnd, &banned_gen, startx, yrow2 - 15, 0);
888
889 lb_ships_allowed.Create(&menu_wnd, 2, xcol1, yrow1, list_xsize, list_ysize, 0);
890 lb_ships_allowed.SetSelectedColor(UICOL_LISTBOX_HI);
891 lb_ships_allowed.SetHiliteColor(UICOL_LISTBOX_HI);
892 lb_ships_banned.Create(&menu_wnd, 3, xcol2, yrow1, list_xsize, list_ysize, 0);
893 lb_ships_banned.SetSelectedColor(UICOL_LISTBOX_HI);
894 lb_ships_banned.SetHiliteColor(UICOL_LISTBOX_HI);
895 lb_generic_allowed.Create(&menu_wnd, 4, xcol1, yrow2, list_xsize, list_ysize, 0);
896 lb_generic_allowed.SetSelectedColor(UICOL_LISTBOX_HI);
897 lb_generic_allowed.SetHiliteColor(UICOL_LISTBOX_HI);
898 lb_generic_banned.Create(&menu_wnd, 5, xcol2, yrow2, list_xsize, list_ysize, 0);
899 lb_generic_banned.SetSelectedColor(UICOL_LISTBOX_HI);
900 lb_generic_banned.SetHiliteColor(UICOL_LISTBOX_HI);
901
902 // Exit out Hotspot
903 exit_hs.Create(&menu_wnd, UID_OK, KEY_ESC, &exit_off_text, &exit_on_text, 10, 420, 180, 30, UIF_FIT | UIF_CENTER);
904 cury += 20;
905 cancel_hs.Create(&menu_wnd, UID_CANCEL, 0, &cancel_off_text, &cancel_on_text, 10, 445, 180, 30, UIF_FIT | UIF_CENTER);
906 cury += 20;
907
908 NewUIWindowLoadBackgroundImage(&menu_wnd, "multimain.ogf");
909
910 // Object_info[MAX_OBJECT_IDS];
911 //
912 // if(Object_info[i].type==OBJ_POWERUP)
913 for (i = 0; i < MAX_OBJECT_IDS; i++) {
914 if (Object_info[i].type == OBJ_POWERUP) {
915 obj_ti[i] = UITextItem(Object_info[i].name, UICOL_TEXT_NORMAL);
916 if (Object_info[i].multi_allowed) {
917 objsallowed[i] = true;
918 lb_generic_allowed.AddItem(&obj_ti[i]);
919 } else {
920 objsallowed[i] = false;
921 lb_generic_banned.AddItem(&obj_ti[i]);
922 }
923 }
924 }
925
926 for (i = 0; i < MAX_SHIPS; i++) {
927 if (Ships[i].used) {
928 ship_ti[i] = UITextItem(Ships[i].name, UICOL_TEXT_NORMAL);
929
930 if (PlayerIsShipAllowed(0, i)) {
931 shipsallowed[i] = true;
932 lb_ships_allowed.AddItem(&ship_ti[i]);
933 } else {
934 shipsallowed[i] = false;
935 lb_ships_banned.AddItem(&ship_ti[i]);
936 }
937 }
938 }
939 //
940 // Open the window and process
941 menu_wnd.Open();
942 int exit_menu = 0;
943
944 while (!exit_menu) {
945 int res;
946
947 res = DoUI();
948 switch (res) {
949 case UID_OK: {
950 // Check for at least one ship allowed
951 for (i = 0; i < MAX_SHIPS; i++) {
952 if (Ships[i].used && PlayerIsShipAllowed(0, i)) {
953 break;
954 }
955 }
956
957 // If no allowed ships found, put up message
958 if (i == MAX_SHIPS) {
959 DoMessageBox(TXT_MENUMULTIPLAYER, "You must have at least one allowed ship.", MSGBOX_OK, UICOL_WINDOW_TITLE,
960 UICOL_TEXT_NORMAL);
961 break;
962 }
963
964 // exit
965 exit_menu = true;
966
967 } break;
968 case UID_CANCEL:
969 // restore old settings
970 for (i = 0; i < MAX_OBJECT_IDS; i++) {
971 if (Object_info[i].type == OBJ_POWERUP) {
972 if (objsallowed[i]) {
973 Object_info[i].multi_allowed = 1;
974 } else {
975 Object_info[i].multi_allowed = 0;
976 }
977 }
978 }
979 for (i = 0; i < MAX_SHIPS; i++) {
980 if (Ships[i].used) {
981 if (shipsallowed[i]) {
982 PlayerSetShipPermission(-1, Ships[i].name, 1);
983 } else {
984 PlayerSetShipPermission(-1, Ships[i].name, 0);
985 }
986 }
987 }
988 // now exit
989 exit_menu = true;
990 break;
991 case 10:
992 #ifndef DEMO
993 {
994 // Make ship allowed
995 UITextItem *selti = (UITextItem *)lb_ships_banned.GetItem(lb_ships_banned.GetSelectedIndex());
996 if (!selti)
997 break;
998 p = selti->GetBuffer();
999 PlayerSetShipPermission(-1, (char *)p, 1);
1000 lb_ships_banned.RemoveItem(selti);
1001 lb_ships_allowed.AddItem(selti);
1002 break;
1003 }
1004 #else
1005 DoMessageBox(TXT_ERROR, TXT_WRONGVERSION, MSGBOX_OK, UICOL_WINDOW_TITLE, UICOL_TEXT_NORMAL);
1006 break;
1007 #endif
1008 case 11:
1009 #ifndef DEMO
1010 {
1011 // Make ship not allowed
1012 UITextItem *selti = (UITextItem *)lb_ships_allowed.GetItem(lb_ships_allowed.GetSelectedIndex());
1013 if (!selti)
1014 break;
1015 p = selti->GetBuffer();
1016 PlayerSetShipPermission(-1, (char *)p, 0);
1017 lb_ships_allowed.RemoveItem(selti);
1018 lb_ships_banned.AddItem(selti);
1019 break;
1020 }
1021 #else
1022 DoMessageBox(TXT_ERROR, TXT_WRONGVERSION, MSGBOX_OK, UICOL_WINDOW_TITLE, UICOL_TEXT_NORMAL);
1023 break;
1024 #endif
1025 case 12: {
1026 // make obj allowed
1027 UITextItem *selti = (UITextItem *)lb_generic_banned.GetItem(lb_generic_banned.GetSelectedIndex());
1028 if (!selti)
1029 break;
1030 p = selti->GetBuffer();
1031 objid = FindObjectIDName(IGNORE_TABLE(p));
1032 if (objid != -1) {
1033 ASSERT(Object_info[objid].type == OBJ_POWERUP);
1034 ASSERT(Object_info[objid].multi_allowed == 0);
1035 Object_info[objid].multi_allowed = 1;
1036 lb_generic_banned.RemoveItem(&obj_ti[objid]);
1037 lb_generic_allowed.AddItem(&obj_ti[objid]);
1038 }
1039 break;
1040 }
1041 case 13: {
1042 // make obj not allowed
1043 UITextItem *selti = (UITextItem *)lb_generic_allowed.GetItem(lb_generic_allowed.GetSelectedIndex());
1044 if (!selti)
1045 break;
1046 p = selti->GetBuffer();
1047 objid = FindObjectIDName(IGNORE_TABLE(p));
1048 if (objid != -1) {
1049 ASSERT(Object_info[objid].type == OBJ_POWERUP);
1050 ASSERT(Object_info[objid].multi_allowed == 1);
1051 Object_info[objid].multi_allowed = 0;
1052 lb_generic_allowed.RemoveItem(&obj_ti[objid]);
1053 lb_generic_banned.AddItem(&obj_ti[objid]);
1054 }
1055 break;
1056 }
1057 default: {
1058 }
1059 }
1060 }
1061 // handle all UI results.
1062 menu_wnd.Close();
1063 menu_wnd.Destroy();
1064 }
1065
1066 void MultiDoConfigSave(void) {
1067 char file[_MAX_PATH * 2];
1068
1069 ddio_MakePath(file, Base_directory_write, "custom", "settings", NULL);
1070 if (DoPathFileDialog(true, file, TXT_MULTISAVESET, "*.mps", 0)) {
1071 if (stricmp(file + (strlen(file) - 4), ".mps") != 0)
1072 strcat(file, ".mps");
1073 MultiSaveSettings(file);
1074 }
1075 }
1076
1077 void MultiDoConfigLoad(void) {
1078 char file[_MAX_PATH * 2];
1079
1080 ddio_MakePath(file, Base_directory_write, "custom", "settings", NULL);
1081 if (DoPathFileDialog(false, file, TXT_MULTILOADSET, "*.mps", PFDF_FILEMUSTEXIST))
1082 MultiLoadSettings(file);
1083 }
1084
1085 #define CHAR_LEFT_ARROW 24
1086 #define CHAR_UP_ARROW 25
1087 #define CHAR_RIGHT_ARROW 26
1088 #define CHAR_DOWN_ARROW 27
1089 #define CHAR_CHECKBOX_OFF 28
1090 #define CHAR_CHECKBOX_ON 29
1091 #define CHAR_RADIO_OFF 30
1092 #define CHAR_RADIO_ON 31
1093
1094 #define CS_MODE_HS_ID 20
1095 #define PP_MODE_HS_ID 21
1096 #define ROT_VEL_HS_ID 22
1097 #define ACC_WEAP_HS_ID 24
1098 #define BRIGHT_SHIP_HS_ID 25
1099 #define RAND_POWERUP_ID 26
1100 #define PS_MODE_HS_ID 27
1101 #define MLOOK_HS_ID 28
1102 #define DIFF_LIST_ID 30
1103 #define SHIP_ALLOW_HS_ID 0xdd
1104
1105 void MultiGameOptionsMenu(int alloptions) {
1106
1107 #define MULTI_OPT_TITLE_Y 30
1108 #define MULTI_OPT_EDITS_Y 80
1109 #define MULTI_OPT_EDITS_X_LCOL1 40
1110 #define MULTI_OPT_EDITS_X_COL1 160
1111 #define MULTI_OPT_EDITS_X_LCOL2 300
1112 #define MULTI_OPT_EDITS_X_COL2 460
1113 #define MULTI_OPT_TOGGLES_Y 210
1114 #define MULTI_OPT_TOGGLES_X 40
1115 #define MULTI_OPT_TOGGLES_COL2_X 300
1116 #define MULTI_OPT_LABEL_OFS 10
1117 #define MULTI_OPT_HOTSPOT_X_MID 410
1118 #define MULTI_OPT_HOTSPOT_Y 360
1119
1120 UITextItem options_title_text(BIG_BRIEFING_FONT, TXT_GEN_MPLYROPTIONS, UICOL_WINDOW_TITLE);
1121 UITextItem time_limit_text(TXT_GEN_TIMELIMIT, UICOL_TEXT_NORMAL);
1122 UITextItem kill_goal_text(TXT_GEN_KILLGOAL, UICOL_TEXT_NORMAL);
1123 UITextItem pps_text(TXT_GEN_PPS, UICOL_TEXT_NORMAL);
1124 UITextItem respawn_rate_text(TXT_GEN_RESPAWNRATE, UICOL_TEXT_NORMAL);
1125 UITextItem max_players_text(TXT_GEN_MAXPLAYERS, UICOL_TEXT_NORMAL);
1126
1127 UITextItem exit_on_text(TXT_DONE, UICOL_HOTSPOT_HI);
1128 UITextItem exit_off_text(TXT_DONE, UICOL_HOTSPOT_LO);
1129
1130 UITextItem cancel_on_text(TXT_CANCEL, UICOL_HOTSPOT_HI);
1131 UITextItem cancel_off_text(TXT_CANCEL, UICOL_HOTSPOT_LO);
1132
1133 UITextItem ship_on_text(TXT_GEN_CFGALLOWEDSHIP, UICOL_HOTSPOT_HI);
1134 UITextItem ship_off_text(TXT_GEN_CFGALLOWEDSHIP, UICOL_HOTSPOT_LO);
1135
1136 UITextItem blank_text("", UICOL_TEXT_NORMAL);
1137
1138 char str[100];
1139
1140 int cancel_id;
1141 rendering_state rs;
1142 rend_GetRenderState(&rs);
1143
1144 NewUIWindow main_wnd;
1145 main_wnd.Create(0, 0, rs.screen_width, rs.screen_height, UIF_PROCESS_ALL);
1146
1147 int num_text = 0, num_edit = 0;
1148 int return_id;
1149 int id = 0;
1150
1151 UIText title_txt;
1152 title_txt.Create(&main_wnd, &options_title_text, 0, MULTI_OPT_TITLE_Y, UIF_CENTER);
1153 int cury = MULTI_OPT_EDITS_Y;
1154 // Time limit
1155 UIText time_limit;
1156 time_limit.Create(&main_wnd, &time_limit_text, MULTI_OPT_EDITS_X_LCOL1, cury + MULTI_OPT_LABEL_OFS, 0);
1157 NewUIEdit time_limit_edit;
1158 time_limit_edit.Create(&main_wnd, id++, MULTI_OPT_EDITS_X_COL1, cury, 100, 15, 0);
1159 cury += 20;
1160 cury += 20;
1161
1162 // Kill goal
1163 UIText kill_goal;
1164 kill_goal.Create(&main_wnd, &kill_goal_text, MULTI_OPT_EDITS_X_LCOL1, cury + MULTI_OPT_LABEL_OFS, 0);
1165 NewUIEdit kill_goal_edit;
1166 kill_goal_edit.Create(&main_wnd, id++, MULTI_OPT_EDITS_X_COL1, cury, 100, 15, 0);
1167 cury += 20;
1168 cury += 20;
1169 NewUIEdit max_players_edit;
1170 UIText max_players;
1171 if (alloptions) {
1172 // Max Players
1173 max_players.Create(&main_wnd, &max_players_text, MULTI_OPT_EDITS_X_LCOL1, cury + MULTI_OPT_LABEL_OFS, 0);
1174 max_players_edit.Create(&main_wnd, id++, MULTI_OPT_EDITS_X_COL1, cury, 100, 15, 0);
1175 cury += 20;
1176 }
1177 cury += 20;
1178
1179 cury = MULTI_OPT_EDITS_Y;
1180
1181 // Packets per second
1182 UIText pps;
1183 pps.Create(&main_wnd, &pps_text, MULTI_OPT_EDITS_X_LCOL2, cury + MULTI_OPT_LABEL_OFS, 0);
1184 NewUIEdit pps_edit;
1185 pps_edit.Create(&main_wnd, id++, MULTI_OPT_EDITS_X_COL2, cury, 100, 15, 0);
1186 cury += 20;
1187 cury += 20;
1188
1189 // Respawn rate
1190 UIText respawn;
1191 respawn.Create(&main_wnd, &respawn_rate_text, MULTI_OPT_EDITS_X_LCOL2, cury + MULTI_OPT_LABEL_OFS, 0);
1192 NewUIEdit respawn_edit;
1193 respawn_edit.Create(&main_wnd, id++, MULTI_OPT_EDITS_X_COL2, cury, 100, 15, 0);
1194 cury += 20;
1195
1196 cury = MULTI_OPT_TOGGLES_Y;
1197 UIHotspot cs_mode_hs;
1198 UIHotspot pp_mode_hs;
1199 UIHotspot pcs_mode_hs;
1200 snprintf(str, sizeof(str), "%c %s", CHAR_CHECKBOX_ON, TXT_GEN_USEROTVEL);
1201 UITextItem rot_vel_sel_txt_on(str, UICOL_HOTSPOT_LO);
1202 UITextItem rot_vel_sel_txt_off(str, UICOL_HOTSPOT_LO);
1203
1204 snprintf(str, sizeof(str), "%c %s", CHAR_CHECKBOX_OFF, TXT_GEN_USEROTVEL);
1205 UITextItem rot_vel_unsel_txt_on(str, UICOL_HOTSPOT_LO);
1206 UITextItem rot_vel_unsel_txt_off(str, UICOL_HOTSPOT_LO);
1207
1208 snprintf(str, sizeof(str), "%c %s", CHAR_CHECKBOX_ON, TXT_GEN_BRIGHT_PLAYERS);
1209 UITextItem bright_players_sel_on(str, UICOL_HOTSPOT_LO);
1210 UITextItem bright_players_sel_off(str, UICOL_HOTSPOT_LO);
1211
1212 snprintf(str, sizeof(str), "%c %s", CHAR_CHECKBOX_OFF, TXT_GEN_BRIGHT_PLAYERS);
1213 UITextItem bright_players_unsel_on(str, UICOL_HOTSPOT_LO);
1214 UITextItem bright_players_unsel_off(str, UICOL_HOTSPOT_LO);
1215
1216 snprintf(str, sizeof(str), "%c %s", CHAR_RADIO_ON, TXT_GEN_CLIENTSERVER);
1217 UITextItem cs_mode_sel_text_on(str, UICOL_HOTSPOT_HI);
1218 UITextItem cs_mode_sel_text_off(str, UICOL_HOTSPOT_LO);
1219
1220 snprintf(str, sizeof(str), "%c %s", CHAR_RADIO_OFF, TXT_GEN_CLIENTSERVER);
1221 UITextItem cs_mode_unsel_text_on(str, UICOL_HOTSPOT_HI);
1222 UITextItem cs_mode_unsel_text_off(str, UICOL_HOTSPOT_LO);
1223
1224 snprintf(str, sizeof(str), "%c %s", CHAR_RADIO_ON, TXT_GEN_PEERPEER);
1225 UITextItem pp_mode_sel_text_on(str, UICOL_HOTSPOT_HI);
1226 UITextItem pp_mode_sel_text_off(str, UICOL_HOTSPOT_LO);
1227
1228 snprintf(str, sizeof(str), "%c %s", CHAR_RADIO_OFF, TXT_GEN_PEERPEER);
1229 UITextItem pp_mode_unsel_text_on(str, UICOL_HOTSPOT_HI);
1230 UITextItem pp_mode_unsel_text_off(str, UICOL_HOTSPOT_LO);
1231
1232 snprintf(str, sizeof(str), "%c %s", CHAR_RADIO_ON, TXT_GEN_PERMISSABLE_CS);
1233 UITextItem pcs_mode_sel_text_on(str, UICOL_HOTSPOT_HI);
1234 UITextItem pcs_mode_sel_text_off(str, UICOL_HOTSPOT_LO);
1235
1236 snprintf(str, sizeof(str), "%c %s", CHAR_RADIO_OFF, TXT_GEN_PERMISSABLE_CS);
1237 UITextItem pcs_mode_unsel_text_on(str, UICOL_HOTSPOT_HI);
1238 UITextItem pcs_mode_unsel_text_off(str, UICOL_HOTSPOT_LO);
1239
1240 snprintf(str, sizeof(str), TXT_GEN_ACC_WEAP_COLL, CHAR_CHECKBOX_ON);
1241 UITextItem acc_weap_coll_sel_off(str, UICOL_HOTSPOT_LO);
1242 UITextItem acc_weap_coll_sel_on(str, UICOL_HOTSPOT_HI);
1243
1244 snprintf(str, sizeof(str), TXT_GEN_ACC_WEAP_COLL, CHAR_CHECKBOX_OFF);
1245 UITextItem acc_weap_coll_unsel_off(str, UICOL_HOTSPOT_LO);
1246 UITextItem acc_weap_coll_unsel_on(str, UICOL_HOTSPOT_HI);
1247
1248 snprintf(str, sizeof(str), "%c %s", CHAR_CHECKBOX_ON, TXT_RANDOMPOWERUPRESPAWN);
1249 UITextItem powerup_respawn_sel_off(str, UICOL_HOTSPOT_LO);
1250 UITextItem powerup_respawn_sel_on(str, UICOL_HOTSPOT_HI);
1251
1252 snprintf(str, sizeof(str), "%c %s", CHAR_CHECKBOX_OFF, TXT_RANDOMPOWERUPRESPAWN);
1253 UITextItem powerup_respawn_unsel_off(str, UICOL_HOTSPOT_LO);
1254 UITextItem powerup_respawn_unsel_on(str, UICOL_HOTSPOT_HI);
1255
1256 snprintf(str, sizeof(str), "%c %s", CHAR_CHECKBOX_ON, TXT_ALLOWMLOOK);
1257 UITextItem mouselookers_sel_off(str, UICOL_HOTSPOT_LO);
1258 UITextItem mouselookers_sel_on(str, UICOL_HOTSPOT_HI);
1259
1260 snprintf(str, sizeof(str), "%c %s", CHAR_CHECKBOX_OFF, TXT_ALLOWMLOOK);
1261 UITextItem mouselookers_unsel_off(str, UICOL_HOTSPOT_LO);
1262 UITextItem mouselookers_unsel_on(str, UICOL_HOTSPOT_HI);
1263
1264 int cs_y;
1265 int pp_y;
1266 int pcs_y;
1267 UIHotspot rot_vel_hs;
1268 UIHotspot acc_weap_hs;
1269 UIHotspot powerup_hs;
1270 UIHotspot mlook_hs;
1271 UIHotspot bright_players_hs;
1272
1273 int rotvely;
1274 int acc_weap_y;
1275 int powerup_y;
1276 int mlook_y;
1277 int bright_players_y;
1278 int diff_y;
1279
1280 cury -= 15;
1281 diff_y = cury;
1282 if (alloptions) {
1283
1284 cury += 15;
1285 if (Netgame.flags & NF_PEER_PEER) {
1286 cs_mode_hs.Create(&main_wnd, CS_MODE_HS_ID, KEY_C, &cs_mode_unsel_text_off, &cs_mode_unsel_text_on,
1287 MULTI_OPT_TOGGLES_X, cury, 180, 30, UIF_FIT);
1288 cs_y = cury;
1289 cury += 20;
1290
1291 pp_mode_hs.Create(&main_wnd, PP_MODE_HS_ID, KEY_C, &pp_mode_sel_text_off, &pp_mode_sel_text_on,
1292 MULTI_OPT_TOGGLES_X, cury, 180, 30, UIF_FIT);
1293 pp_y = cury;
1294 cury += 20;
1295
1296 pcs_mode_hs.Create(&main_wnd, PS_MODE_HS_ID, KEY_C, &pcs_mode_unsel_text_off, &pcs_mode_unsel_text_on,
1297 MULTI_OPT_TOGGLES_X, cury, 180, 30, UIF_FIT);
1298 pcs_y = cury;
1299 cury += 20;
1300 } else if (Netgame.flags & NF_PERMISSABLE) {
1301 ////
1302 cs_mode_hs.Create(&main_wnd, CS_MODE_HS_ID, KEY_C, &cs_mode_unsel_text_off, &cs_mode_unsel_text_on,
1303 MULTI_OPT_TOGGLES_X, cury, 180, 30, UIF_FIT);
1304 cs_y = cury;
1305 cury += 20;
1306
1307 pp_mode_hs.Create(&main_wnd, PP_MODE_HS_ID, KEY_C, &pp_mode_unsel_text_off, &pp_mode_unsel_text_on,
1308 MULTI_OPT_TOGGLES_X, cury, 180, 30, UIF_FIT);
1309 pp_y = cury;
1310 cury += 20;
1311
1312 pcs_mode_hs.Create(&main_wnd, PS_MODE_HS_ID, KEY_C, &pcs_mode_sel_text_off, &pcs_mode_sel_text_on,
1313 MULTI_OPT_TOGGLES_X, cury, 180, 30, UIF_FIT);
1314 pcs_y = cury;
1315 cury += 20;
1316 } else {
1317 cs_mode_hs.Create(&main_wnd, CS_MODE_HS_ID, KEY_C, &cs_mode_sel_text_off, &cs_mode_sel_text_on,
1318 MULTI_OPT_TOGGLES_X, cury, 180, 30, UIF_FIT);
1319 cs_y = cury;
1320 cury += 20;
1321 pp_mode_hs.Create(&main_wnd, PP_MODE_HS_ID, KEY_C, &pp_mode_unsel_text_off, &pp_mode_unsel_text_on,
1322 MULTI_OPT_TOGGLES_X, cury, 180, 30, UIF_FIT);
1323 pp_y = cury;
1324 cury += 20;
1325
1326 pcs_mode_hs.Create(&main_wnd, PS_MODE_HS_ID, KEY_C, &pcs_mode_unsel_text_off, &pcs_mode_unsel_text_on,
1327 MULTI_OPT_TOGGLES_X, cury, 180, 30, UIF_FIT);
1328 pcs_y = cury;
1329 cury += 20;
1330 }
1331
1332 cury += 10;
1333 diff_y = cury;
1334
1335 // Rotvel toggle
1336
1337 cury = MULTI_OPT_TOGGLES_Y;
1338 if (Netgame.flags & NF_SENDROTVEL) {
1339 rot_vel_hs.Create(&main_wnd, ROT_VEL_HS_ID, 0, &rot_vel_sel_txt_off, &rot_vel_sel_txt_on,
1340 MULTI_OPT_TOGGLES_COL2_X, cury, 180, 30, UIF_FIT);
1341 } else {
1342 rot_vel_hs.Create(&main_wnd, ROT_VEL_HS_ID, 0, &rot_vel_unsel_txt_off, &rot_vel_unsel_txt_on,
1343 MULTI_OPT_TOGGLES_COL2_X, cury, 180, 30, UIF_FIT);
1344 }
1345 rotvely = cury;
1346 cury += 20;
1347 }
1348 // Accurate collisions toggle
1349 if (Netgame.flags & NF_USE_ACC_WEAP) {
1350 acc_weap_hs.Create(&main_wnd, ACC_WEAP_HS_ID, KEY_A, &acc_weap_coll_sel_off, &acc_weap_coll_sel_on,
1351 MULTI_OPT_TOGGLES_COL2_X, cury, 180, 30, UIF_FIT);
1352 } else {
1353 acc_weap_hs.Create(&main_wnd, ACC_WEAP_HS_ID, KEY_A, &acc_weap_coll_unsel_off, &acc_weap_coll_unsel_on,
1354 MULTI_OPT_TOGGLES_COL2_X, cury, 180, 30, UIF_FIT);
1355 }
1356 acc_weap_y = cury;
1357 cury += 20;
1358
1359 // Bright players toggle
1360
1361 if (Netgame.flags & NF_BRIGHT_PLAYERS) {
1362 bright_players_hs.Create(&main_wnd, BRIGHT_SHIP_HS_ID, KEY_B, &bright_players_sel_off, &bright_players_sel_on,
1363 MULTI_OPT_TOGGLES_COL2_X, cury, 180, 30, UIF_FIT);
1364 } else {
1365 bright_players_hs.Create(&main_wnd, BRIGHT_SHIP_HS_ID, KEY_B, &bright_players_unsel_off, &bright_players_unsel_on,
1366 MULTI_OPT_TOGGLES_COL2_X, cury, 180, 30, UIF_FIT);
1367 }
1368 bright_players_y = cury;
1369 cury += 20;
1370
1371 if (Netgame.flags & NF_RANDOMIZE_RESPAWN) {
1372 powerup_hs.Create(&main_wnd, RAND_POWERUP_ID, KEY_B, &powerup_respawn_sel_off, &powerup_respawn_sel_on,
1373 MULTI_OPT_TOGGLES_COL2_X, cury, 180, 30, UIF_FIT);
1374 } else {
1375 powerup_hs.Create(&main_wnd, RAND_POWERUP_ID, KEY_B, &powerup_respawn_unsel_off, &powerup_respawn_unsel_on,
1376 MULTI_OPT_TOGGLES_COL2_X, cury, 180, 30, UIF_FIT);
1377 }
1378 powerup_y = cury;
1379 cury += 20;
1380
1381 if (Netgame.flags & NF_ALLOW_MLOOK) {
1382 mlook_hs.Create(&main_wnd, MLOOK_HS_ID, KEY_B, &mouselookers_sel_off, &mouselookers_sel_on,
1383 MULTI_OPT_TOGGLES_COL2_X, cury, 180, 30, UIF_FIT);
1384 } else {
1385 mlook_hs.Create(&main_wnd, MLOOK_HS_ID, KEY_B, &mouselookers_unsel_off, &mouselookers_unsel_on,
1386 MULTI_OPT_TOGGLES_COL2_X, cury, 180, 30, UIF_FIT);
1387 }
1388 mlook_y = cury;
1389 cury += 20;
1390
1391 // Difficulty Listbox & title
1392 UITextItem diff_title_text(TXT_PLTDIFFICULT, UICOL_WINDOW_TITLE);
1393 UITextItem trainee(TXT_TRAINEE, GR_LIGHTGRAY);
1394 UITextItem rookie(TXT_ROOKIE, GR_LIGHTGRAY);
1395 UITextItem hotshot(TXT_HOTSHOT, GR_LIGHTGRAY);
1396 UITextItem ace(TXT_ACE, GR_LIGHTGRAY);
1397 UITextItem insane(TXT_INSANE, GR_LIGHTGRAY);
1398
1399 UIText diff_title;
1400
1401 diff_title.Create(&main_wnd, &diff_title_text, MULTI_OPT_TOGGLES_X, diff_y, 0);
1402 diff_y += 15;
1403 NewUIListBox diff_list;
1404
1405 diff_list.SetSelectedColor(UICOL_LISTBOX_HI);
1406 diff_list.SetHiliteColor(UICOL_LISTBOX_HI);
1407 diff_list.Create(&main_wnd, DIFF_LIST_ID, MULTI_OPT_TOGGLES_X, diff_y, 160, 96, UILB_NOSORT);
1408
1409 diff_list.AddItem(&trainee);
1410 diff_list.AddItem(&rookie);
1411 diff_list.AddItem(&hotshot);
1412 diff_list.AddItem(&ace);
1413 diff_list.AddItem(&insane);
1414
1415 switch (Netgame.difficulty) {
1416 case 0:
1417 diff_list.SelectItem(&trainee);
1418 break;
1419 case 1:
1420 diff_list.SelectItem(&rookie);
1421 break;
1422 case 2:
1423 diff_list.SelectItem(&hotshot);
1424 break;
1425 case 3:
1426 diff_list.SelectItem(&ace);
1427 break;
1428 case 4:
1429 diff_list.SelectItem(&insane);
1430 break;
1431 }
1432
1433 cury = MULTI_OPT_HOTSPOT_Y;
1434 // int hsmid = MULTI_OPT_HOTSPOT_X_MID - (DLLgrtext_GetTextLineWidth(TXT_GEN_CFGALLOWEDSHIP)/2);
1435 UIHotspot ship_hs;
1436 ship_hs.Create(&main_wnd, SHIP_ALLOW_HS_ID, KEY_S, &ship_off_text, &ship_on_text, 0, cury, 180, 30,
1437 UIF_FIT | UIF_CENTER);
1438 cury += 20;
1439 return_id = UID_OK;
1440 cury += 10;
1441 // hsmid = MULTI_OPT_HOTSPOT_X_MID - (DLLgrtext_GetTextLineWidth(TXT_GEN_PREVMENU)/2);
1442 UIHotspot exit_hs;
1443 exit_hs.Create(&main_wnd, UID_OK, KEY_ESC, &exit_off_text, &exit_on_text, 0, cury, 180, 30, UIF_FIT | UIF_CENTER);
1444 cury += 20;
1445 cancel_id = UID_CANCEL;
1446 /// hsmid = MULTI_OPT_HOTSPOT_X_MID - (DLLgrtext_GetTextLineWidth(TXT_GEN_CANCEL)/2);
1447 UIHotspot cancel_hs;
1448 cancel_hs.Create(&main_wnd, UID_CANCEL, 0, &cancel_off_text, &cancel_on_text, 0, cury, 180, 30, UIF_FIT | UIF_CENTER);
1449 cury += 20;
1450 // Bash some values
1451
1452 if (Netgame.flags & NF_TIMER)
1453 snprintf(str, sizeof(str), "%d", Netgame.timelimit);
1454 else
1455 snprintf(str, sizeof(str), "%d", 0);
1456
1457 time_limit_edit.SetText(str);
1458
1459 if (Netgame.flags & NF_KILLGOAL)
1460 snprintf(str, sizeof(str), "%d", Netgame.killgoal);
1461 else
1462 snprintf(str, sizeof(str), "%d", 0);
1463
1464 kill_goal_edit.SetText(str);
1465
1466 snprintf(str, sizeof(str), "%d", Netgame.packets_per_second);
1467 pps_edit.SetText(str);
1468
1469 snprintf(str, sizeof(str), "%d", Netgame.max_players);
1470 if (alloptions) {
1471 max_players_edit.SetText(str);
1472 }
1473
1474 snprintf(str, sizeof(str), "%d", Netgame.respawn_time);
1475 respawn_edit.SetText(str);
1476
1477 main_wnd.LoadBackgroundImage("multimain.ogf");
1478 main_wnd.Open();
1479 int exit_menu = 0;
1480
1481 while (!exit_menu) {
1482 int res;
1483
1484 res = DoUI();
1485 if (res == cancel_id) {
1486 exit_menu = true;
1487 break;
1488 }
1489 if (alloptions) {
1490 if (res == CS_MODE_HS_ID) {
1491 cs_mode_hs.Destroy();
1492 pp_mode_hs.Destroy();
1493 pcs_mode_hs.Destroy();
1494
1495 cs_mode_hs.Create(&main_wnd, CS_MODE_HS_ID, KEY_C, &cs_mode_sel_text_off, &cs_mode_sel_text_on,
1496 MULTI_OPT_TOGGLES_X, cs_y, 180, 30, UIF_FIT);
1497 pp_mode_hs.Create(&main_wnd, PP_MODE_HS_ID, KEY_C, &pp_mode_unsel_text_off, &pp_mode_unsel_text_on,
1498 MULTI_OPT_TOGGLES_X, pp_y, 180, 30, UIF_FIT);
1499 pcs_mode_hs.Create(&main_wnd, PS_MODE_HS_ID, KEY_C, &pcs_mode_unsel_text_off, &pcs_mode_unsel_text_on,
1500 MULTI_OPT_TOGGLES_X, pcs_y, 180, 30, UIF_FIT);
1501 Netgame.flags &= ~NF_PEER_PEER;
1502 Netgame.flags &= ~NF_PERMISSABLE;
1503 mprintf(0, "Using Client/Server model\n");
1504 } else if (res == PP_MODE_HS_ID) {
1505 cs_mode_hs.Destroy();
1506 pp_mode_hs.Destroy();
1507 pcs_mode_hs.Destroy();
1508
1509 cs_mode_hs.Create(&main_wnd, CS_MODE_HS_ID, KEY_C, &cs_mode_unsel_text_off, &cs_mode_unsel_text_on,
1510 MULTI_OPT_TOGGLES_X, cs_y, 180, 30, UIF_FIT);
1511 pp_mode_hs.Create(&main_wnd, PP_MODE_HS_ID, KEY_C, &pp_mode_sel_text_off, &pp_mode_sel_text_on,
1512 MULTI_OPT_TOGGLES_X, pp_y, 180, 30, UIF_FIT);
1513 pcs_mode_hs.Create(&main_wnd, PS_MODE_HS_ID, KEY_C, &pcs_mode_unsel_text_off, &pcs_mode_unsel_text_on,
1514 MULTI_OPT_TOGGLES_X, pcs_y, 180, 30, UIF_FIT);
1515 Netgame.flags |= NF_PEER_PEER;
1516 Netgame.flags &= ~NF_PERMISSABLE;
1517
1518 mprintf(0, "Using Peer/Peer model\n");
1519 } else if (res == PS_MODE_HS_ID) {
1520 cs_mode_hs.Destroy();
1521 pp_mode_hs.Destroy();
1522 pcs_mode_hs.Destroy();
1523
1524 cs_mode_hs.Create(&main_wnd, CS_MODE_HS_ID, KEY_C, &cs_mode_unsel_text_off, &cs_mode_unsel_text_on,
1525 MULTI_OPT_TOGGLES_X, cs_y, 180, 30, UIF_FIT);
1526 pp_mode_hs.Create(&main_wnd, PP_MODE_HS_ID, KEY_C, &pp_mode_unsel_text_off, &pp_mode_unsel_text_on,
1527 MULTI_OPT_TOGGLES_X, pp_y, 180, 30, UIF_FIT);
1528 pcs_mode_hs.Create(&main_wnd, PS_MODE_HS_ID, KEY_C, &pcs_mode_sel_text_off, &pcs_mode_sel_text_on,
1529 MULTI_OPT_TOGGLES_X, pcs_y, 180, 30, UIF_FIT);
1530 Netgame.flags |= NF_PERMISSABLE;
1531 Netgame.flags &= ~NF_PEER_PEER;
1532
1533 mprintf(0, "Using Permissable model\n");
1534 } else if (res == ROT_VEL_HS_ID) {
1535 rot_vel_hs.Destroy();
1536
1537 if (Netgame.flags & NF_SENDROTVEL) {
1538 rot_vel_hs.Create(&main_wnd, ROT_VEL_HS_ID, 0, &rot_vel_unsel_txt_off, &rot_vel_unsel_txt_on,
1539 MULTI_OPT_TOGGLES_COL2_X, rotvely, 180, 30, UIF_FIT);
1540 Netgame.flags &= ~NF_SENDROTVEL;
1541 } else {
1542 rot_vel_hs.Create(&main_wnd, ROT_VEL_HS_ID, 0, &rot_vel_sel_txt_off, &rot_vel_sel_txt_on,
1543 MULTI_OPT_TOGGLES_COL2_X, rotvely, 180, 30, UIF_FIT);
1544 Netgame.flags |= NF_SENDROTVEL;
1545 }
1546 }
1547 }
1548
1549 if (res == SHIP_ALLOW_HS_ID) {
1550 // Ships allowed
1551 main_wnd.Close();
1552 DoMultiAllowed();
1553 main_wnd.Open();
1554 } else if (res == ACC_WEAP_HS_ID) {
1555 acc_weap_hs.Destroy();
1556 if (Netgame.flags & NF_USE_ACC_WEAP) {
1557 acc_weap_hs.Create(&main_wnd, ACC_WEAP_HS_ID, KEY_A, &acc_weap_coll_unsel_off, &acc_weap_coll_unsel_on,
1558 MULTI_OPT_TOGGLES_COL2_X, acc_weap_y, 180, 30, UIF_FIT);
1559 Netgame.flags &= ~NF_USE_ACC_WEAP;
1560 } else {
1561 acc_weap_hs.Create(&main_wnd, ACC_WEAP_HS_ID, KEY_A, &acc_weap_coll_sel_off, &acc_weap_coll_sel_on,
1562 MULTI_OPT_TOGGLES_COL2_X, acc_weap_y, 180, 30, UIF_FIT);
1563 Netgame.flags |= NF_USE_ACC_WEAP;
1564 }
1565
1566 } else if (res == BRIGHT_SHIP_HS_ID) {
1567 bright_players_hs.Destroy();
1568
1569 if (Netgame.flags & NF_BRIGHT_PLAYERS) {
1570 bright_players_hs.Create(&main_wnd, BRIGHT_SHIP_HS_ID, KEY_B, &bright_players_unsel_off,
1571 &bright_players_unsel_on, MULTI_OPT_TOGGLES_COL2_X, bright_players_y, 180, 30,
1572 UIF_FIT);
1573 Netgame.flags &= ~NF_BRIGHT_PLAYERS;
1574 } else {
1575 bright_players_hs.Create(&main_wnd, BRIGHT_SHIP_HS_ID, KEY_B, &bright_players_sel_off, &bright_players_sel_on,
1576 MULTI_OPT_TOGGLES_COL2_X, bright_players_y, 180, 30, UIF_FIT);
1577 Netgame.flags |= NF_BRIGHT_PLAYERS;
1578 }
1579 }
1580
1581 else if (res == RAND_POWERUP_ID) {
1582 powerup_hs.Destroy();
1583
1584 if (Netgame.flags & NF_RANDOMIZE_RESPAWN) {
1585 powerup_hs.Create(&main_wnd, RAND_POWERUP_ID, KEY_B, &powerup_respawn_unsel_off, &powerup_respawn_unsel_on,
1586 MULTI_OPT_TOGGLES_COL2_X, powerup_y, 180, 30, UIF_FIT);
1587 Netgame.flags &= ~NF_RANDOMIZE_RESPAWN;
1588 } else {
1589 powerup_hs.Create(&main_wnd, RAND_POWERUP_ID, KEY_B, &powerup_respawn_sel_off, &powerup_respawn_sel_on,
1590 MULTI_OPT_TOGGLES_COL2_X, powerup_y, 180, 30, UIF_FIT);
1591 Netgame.flags |= NF_RANDOMIZE_RESPAWN;
1592 }
1593 }
1594
1595 else if (res == MLOOK_HS_ID) {
1596 mlook_hs.Destroy();
1597
1598 if (Netgame.flags & NF_ALLOW_MLOOK) {
1599 mlook_hs.Create(&main_wnd, MLOOK_HS_ID, KEY_B, &mouselookers_unsel_off, &mouselookers_unsel_on,
1600 MULTI_OPT_TOGGLES_COL2_X, mlook_y, 180, 30, UIF_FIT);
1601 Netgame.flags &= ~NF_ALLOW_MLOOK;
1602 } else {
1603 mlook_hs.Create(&main_wnd, MLOOK_HS_ID, KEY_B, &mouselookers_sel_off, &mouselookers_sel_on,
1604 MULTI_OPT_TOGGLES_COL2_X, mlook_y, 180, 30, UIF_FIT);
1605 Netgame.flags |= NF_ALLOW_MLOOK;
1606 }
1607 } else if (res == return_id) {
1608 int val;
1609
1610 // Get kill goal
1611 // edits[killgoal_edit].GetText (str,100);
1612 kill_goal_edit.GetText(str, 100);
1613 val = atoi(str);
1614 if (val > 1) {
1615 if (val > 10000)
1616 val = 10000;
1617 Netgame.flags |= NF_KILLGOAL;
1618 } else {
1619 Netgame.flags &= ~NF_KILLGOAL;
1620 val = 0;
1621 }
1622
1623 Netgame.killgoal = val;
1624
1625 // Get timelimit
1626 // edits[timer_edit].GetText (str,100);
1627 time_limit_edit.GetText(str, 100);
1628 val = atoi(str);
1629 if (val > 0) {
1630 if (val > 10000)
1631 val = 10000;
1632 Netgame.flags |= NF_TIMER;
1633 } else {
1634 Netgame.flags &= ~NF_TIMER;
1635 val = 0;
1636 }
1637
1638 Netgame.timelimit = val;
1639
1640 // Get packets per second
1641 pps_edit.GetText(str, 100);
1642 val = atoi(str);
1643 Netgame.packets_per_second = val;
1644 if (val > 20)
1645 val = 20;
1646 if (val < 2)
1647 val = 2;
1648
1649 if (alloptions) {
1650 // Get Max players
1651 max_players_edit.GetText(str, 100);
1652 val = atoi(str);
1653 Netgame.max_players = val;
1654 if (val > MAX_NET_PLAYERS)
1655 Netgame.max_players = MAX_NET_PLAYERS;
1656 if (val < 2)
1657 val = 2;
1658 }
1659 // Get respawn rate
1660 // edits[respawn_edit].GetText (str,100);
1661 respawn_edit.GetText(str, 100);
1662 val = atoi(str);
1663 if (val < 15)
1664 val = 15;
1665 if (val > 300)
1666 val = 300;
1667
1668 Netgame.respawn_time = val;
1669
1670 int difficulty = diff_list.GetSelectedIndex();
1671
1672 Netgame.difficulty = difficulty;
1673
1674 exit_menu = 1;
1675 }
1676 }
1677
1678 main_wnd.Close();
1679 main_wnd.Destroy();
1680 }
1681
1682 int ReturnMultiplayerGameMenu(void) {
1683 MultiFlushAllIncomingBuffers();
1684 CallMultiDLL(MT_RETURN_TO_GAME_LIST);
1685 return MultiDLLGameStarting;
1686 }
1687
1688 int MultiLevelSelection(void) {
1689 if (Current_mission.num_levels == 1)
1690 return 1;
1691
1692 Current_mission.cur_level = DisplayLevelWarpDlg(Current_mission.num_levels);
1693
1694 if (Current_mission.cur_level < 1) {
1695 Current_mission.cur_level = 1;
1696 return -1;
1697 }
1698 return Current_mission.cur_level;
1699 }
1700
1701 bool DoPlayerMouselookCheck(uint32_t flags) {
1702 if (Current_pilot.mouselook_control) {
1703 if (flags & NF_ALLOW_MLOOK) {
1704 return true;
1705 } else {
1706 int ret = DoMessageBox(TXT_NOMOUSELOOK, TXT_MLOOK_JOINANYWAY, MSGBOX_YESNO);
1707 return ret ? true : false;
1708 }
1709 }
1710
1711 return true;
1712 }
1713
1714 #define GAME_INFO_MENU_W 384
1715 #define GAME_INFO_MENU_H 384
1716 #define GAME_INFO_MENU_X 320 - (GAME_INFO_MENU_W / 2)
1717 #define GAME_INFO_MENU_Y 240 - (GAME_INFO_MENU_H / 2)
1718
1719 #define GAME_INFO_COL1 10
1720
1721 #define GAME_INFO_GOTO_NEXT_LINE cury += 13
1722
1723 #define UID_GAMEINFO_PLAYERS 1000
1724
1725 extern char *Multi_recieved_player_list;
1726 extern bool Multi_got_player_list;
1727
1728 void RequestPlayerList(network_address *addr);
1729
1730 #define ASK_PLAYERS_RETRY_INTERVAL 2.0
1731 #define ASK_PLAYERS_RETRIES 4
1732
1733 // Display a dialog box showing the information relating to this particular net game
1734 void ShowNetgameInfo(network_game *game) {
1735 char str[200];
1736 int cury = 10;
1737 int exit_menu = 0;
1738 newuiTiledWindow menu_wnd;
1739 newuiListBox *lists;
1740 newuiSheet *sheet;
1741 char *plyr;
1742
1743 ASSERT(game);
1744
1745 menu_wnd.Create(TXT_GAME_INFO, 0, 0, GAME_INFO_MENU_W, GAME_INFO_MENU_H);
1746 sheet = menu_wnd.GetSheet();
1747
1748 sheet->NewGroup(game->name, GAME_INFO_COL1, cury);
1749 cury += 15;
1750 snprintf(str, sizeof(str), TXT_GINFO_MISSION, game->mission_name);
1751 sheet->NewGroup(str, GAME_INFO_COL1, cury);
1752 GAME_INFO_GOTO_NEXT_LINE;
1753
1754 snprintf(str, sizeof(str), TXT_PLAYERS_X_OF_X, game->curr_num_players, game->max_num_players);
1755 sheet->NewGroup(str, GAME_INFO_COL1, cury);
1756 GAME_INFO_GOTO_NEXT_LINE;
1757
1758 const char *szdiff = TXT_ERROR;
1759
1760 switch (game->difficulty) {
1761 case 0:
1762 szdiff = TXT_TRAINEE;
1763 break;
1764 case 1:
1765 szdiff = TXT_ROOKIE;
1766 break;
1767 case 2:
1768 szdiff = TXT_HOTSHOT;
1769 break;
1770 case 3:
1771 szdiff = TXT_ACE;
1772 break;
1773 case 4:
1774 szdiff = TXT_INSANE;
1775 break;
1776 default:
1777 szdiff = TXT_ERROR;
1778 }
1779
1780 snprintf(str, sizeof(str), "%s: %s", TXT_PLTDIFFICULT, szdiff);
1781 sheet->NewGroup(str, GAME_INFO_COL1, cury);
1782 GAME_INFO_GOTO_NEXT_LINE;
1783
1784 const char *mode;
1785 if ((game->flags & NF_PEER_PEER)) {
1786 mode = TXT_GEN_PEERPEER;
1787 } else if ((game->flags & NF_PERMISSABLE)) {
1788 mode = TXT_GEN_PERMISSABLE_CS;
1789 } else {
1790 mode = TXT_GEN_CLIENTSERVER;
1791 }
1792
1793 if (game->dedicated_server)
1794 snprintf(str, sizeof(str), TXT_DEDICATED_SERVER, mode);
1795 else
1796 snprintf(str, sizeof(str), TXT_NONDEDICATED_SERVER, mode);
1797 sheet->NewGroup(str, GAME_INFO_COL1, cury);
1798 GAME_INFO_GOTO_NEXT_LINE;
1799
1800 snprintf(str, sizeof(str), TXT_GINFO_ALLOWMOUSELOOK, (game->flags & NF_ALLOW_MLOOK) ? TXT_DOES : TXT_DOESNOT);
1801 sheet->NewGroup(str, GAME_INFO_COL1, cury);
1802 GAME_INFO_GOTO_NEXT_LINE;
1803
1804 snprintf(str, sizeof(str), "%s: %s", TXT_GEN_BRIGHT_PLAYERS, (game->flags & NF_BRIGHT_PLAYERS) ? TXT_ON : TXT_OFF);
1805 sheet->NewGroup(str, GAME_INFO_COL1, cury);
1806 GAME_INFO_GOTO_NEXT_LINE;
1807
1808 snprintf(str, sizeof(str), TXT_GINFO_ACC_WEAPCOLL, (game->flags & NF_USE_ACC_WEAP) ? TXT_ON : TXT_OFF);
1809 sheet->NewGroup(str, GAME_INFO_COL1, cury);
1810 GAME_INFO_GOTO_NEXT_LINE;
1811
1812 snprintf(str, sizeof(str), TXT_USE_ROTATIONAL_VEL, (game->flags & NF_SENDROTVEL) ? TXT_ON : TXT_OFF);
1813 sheet->NewGroup(str, GAME_INFO_COL1, cury);
1814 GAME_INFO_GOTO_NEXT_LINE;
1815
1816 snprintf(str, sizeof(str), TXT_RANDOMIZEPOWERUPSPAWN, (game->flags & NF_RANDOMIZE_RESPAWN) ? TXT_ON : TXT_OFF);
1817 sheet->NewGroup(str, GAME_INFO_COL1, cury);
1818 GAME_INFO_GOTO_NEXT_LINE;
1819
1820 // GAME_INFO_GOTO_NEXT_LINE;
1821
1822 snprintf(str, sizeof(str), "%s:", TXT_GAMEINFOPLAYERSTITLE);
1823 sheet->NewGroup(str, GAME_INFO_COL1, cury);
1824 GAME_INFO_GOTO_NEXT_LINE;
1825
1826 lists = sheet->AddListBox(256, 128, UID_GAMEINFO_PLAYERS);
1827 lists->RemoveAll();
1828
1829 sheet->NewGroup(NULL, (GAME_INFO_MENU_W - 140), GAME_INFO_MENU_H - 95, NEWUI_ALIGN_HORIZ);
1830 sheet->AddButton(TXT_DONE, UID_CANCEL);
1831 // Get players
1832 Multi_recieved_player_list = (char *)mem_malloc(((CALLSIGN_LEN + 1) * MAX_NET_PLAYERS) + 1);
1833 memset(Multi_recieved_player_list, 0, ((CALLSIGN_LEN + 1) * MAX_NET_PLAYERS) + 1);
1834
1835 Multi_got_player_list = false;
1836
1837 CreateSplashScreen(TXT_GETTINGPLAYERLIST, 1);
1838
1839 RequestPlayerList(&game->addr);
1840 float last_asked_time = timer_GetTime();
1841 int retries = 0;
1842 do {
1843 MultiProcessIncoming();
1844 int res = PollUI();
1845 // If the user hit cancel...
1846 if (res == 99) {
1847 CloseSplashScreen();
1848 goto no_players;
1849 }
1850 if ((timer_GetTime() - last_asked_time) > ASK_PLAYERS_RETRY_INTERVAL) {
1851 last_asked_time = timer_GetTime();
1852 RequestPlayerList(&game->addr);
1853 retries++;
1854 }
1855 if (retries >= ASK_PLAYERS_RETRIES) {
1856 DoMessageBox(TXT_ERROR, TXT_CANTGETPLAYERLIST, MSGBOX_OK);
1857 CloseSplashScreen();
1858 goto no_players;
1859 }
1860
1861 } while (!Multi_got_player_list);
1862
1863 CloseSplashScreen();
1864
1865 // Ok, now we've got the list of players.. let's parse it and add the players to the list
1866 plyr = Multi_recieved_player_list;
1867
1868 while (*plyr) {
1869 lists->AddItem(plyr);
1870 // Move on to the next item
1871 while (*plyr) {
1872 plyr++;
1873 }
1874 // Move past the NULL
1875 plyr++;
1876 }
1877
1878 if (Multi_recieved_player_list) {
1879 mem_free(Multi_recieved_player_list);
1880 Multi_recieved_player_list = NULL;
1881 }
1882
1883 menu_wnd.Open();
1884
1885 while (!exit_menu) {
1886 int res;
1887
1888 res = menu_wnd.DoUI();
1889
1890 // handle all UI results.
1891 switch (res) {
1892 case UID_CANCEL:
1893 menu_wnd.Close();
1894 exit_menu = 1;
1895 break;
1896 }
1897 }
1898 menu_wnd.Destroy();
1899
1900 no_players:
1901 if (Multi_recieved_player_list) {
1902 mem_free(Multi_recieved_player_list);
1903 Multi_recieved_player_list = NULL;
1904 }
1905 }