1 #include "3dc.h"
2 #include "conscmnd.hpp"
3 #include "strutil.h"
4
5 // Includes for the actual commands:
6 //#include "consvar.hpp"
7 //#include "modcmds.hpp"
8 //#include "textexp.hpp"
9 //#include "trepgadg.hpp"
10
11 #define UseLocalAssert Yes
12 #include "ourasert.h"
13
14 extern "C"
15 {
16 #include "module.h"
17 #include "inline.h"
18
19 #include "stratdef.h"
20 #include "gamedef.h"
21 #include "gameplat.h"
22
23 #include "bh_types.h"
24
25 #include "showcmds.h"
26 #include "version.h"
27 #include "equipmnt.h"
28 #include "cheat.h"
29 #include "cd_player.h"
30 #include "dynblock.h"
31 #include "bh_rubberduck.h"
32 #include "pvisible.h"
33 #include "pldnet.h"
34
35 #include "lighting.h"
36 #include "paintball.h"
37 #include "decal.h"
38 #include "consolelog.hpp"
39 #include "psndplat.h"
40 #include "avp_menus.h"
41 #include "detaillevels.h"
42 #include "savegame.h"
43
44
45 int DebuggingCommandsActive=0;
46 extern void GimmeCharge(void);
47
48 // just change these to prototypes etc.
QuickLoad(void)49 extern void QuickLoad(void)
50 {
51 //set the load request
52 LoadGameRequest = 0; //(that's slot 0 - not false)
53 }
QuickSave(void)54 extern void QuickSave(void)
55 {
56 //set the save request
57 SaveGameRequest = 0; //(that's slot 0 - not false)
58 }
59
ConsoleCommandLoad(int slot)60 void ConsoleCommandLoad(int slot)
61 {
62 if(slot>=1 && slot<=NUMBER_OF_SAVE_SLOTS)
63 {
64 LoadGameRequest = slot-1;
65 }
66 }
67
ConsoleCommandSave(int slot)68 void ConsoleCommandSave(int slot)
69 {
70 if(slot>=1 && slot<=NUMBER_OF_SAVE_SLOTS)
71 {
72 SaveGameRequest = slot-1;
73 }
74 }
75 extern void DisplaySavesLeft(void);
76
77
78
79 struct DEBUGGINGTEXTOPTIONS ShowDebuggingText;
80
81 extern void ChangeNetGameType_Individual();
82 extern void ChangeNetGameType_Coop();
83 extern void ChangeNetGameType_LastManStanding();
84 extern void ChangeNetGameType_PredatorTag();
85 extern void ShowNearestPlayersName(void);
86 extern void ScreenShot(void);
87 extern void CastAlienBot(void);
88 extern void CastMarineBot(int weapon);
89 extern void CastPredoBot(int weapon);
90 extern void CastPredAlienBot(void);
91 extern void CastPraetorianBot(void);
92 extern void CastXenoborg(void);
93
94 extern int ShowMultiplayerScoreTimer;
95
ShowFPS(void)96 static void ShowFPS(void)
97 {
98 ShowDebuggingText.FPS = ~ShowDebuggingText.FPS;
99 }
100 #if CONSOLE_DEBUGGING_COMMANDS_ACTIVATED
ShowEnvironment(void)101 static void ShowEnvironment(void)
102 {
103 ShowDebuggingText.Environment = ~ShowDebuggingText.Environment;
104 }
ShowCoords(void)105 static void ShowCoords(void)
106 {
107 ShowDebuggingText.Coords = ~ShowDebuggingText.Coords;
108 }
ShowModule(void)109 static void ShowModule(void)
110 {
111 ShowDebuggingText.Module = ~ShowDebuggingText.Module;
112 }
ShowTarget(void)113 static void ShowTarget(void)
114 {
115 ShowDebuggingText.Target = ~ShowDebuggingText.Target;
116 }
ShowNetworking(void)117 static void ShowNetworking(void)
118 {
119 ShowDebuggingText.Networking = ~ShowDebuggingText.Networking;
120 }
ShowDynamics(void)121 static void ShowDynamics(void)
122 {
123 ShowDebuggingText.Dynamics = ~ShowDebuggingText.Dynamics;
124 }
ShowGunPos(void)125 static void ShowGunPos(void)
126 {
127 ShowDebuggingText.GunPos = ~ShowDebuggingText.GunPos;
128 }
ShowTears(void)129 static void ShowTears(void)
130 {
131 ShowDebuggingText.Tears = ~ShowDebuggingText.Tears;
132 }
ShowSounds(void)133 static void ShowSounds(void)
134 {
135 ShowDebuggingText.Sounds = ~ShowDebuggingText.Sounds;
136 }
137 #endif
ShowPolyCount(void)138 static void ShowPolyCount(void)
139 {
140 ShowDebuggingText.PolyCount = ~ShowDebuggingText.PolyCount;
141 }
142
143
144 extern void ChangeToMarine();
145 #if CONSOLE_DEBUGGING_COMMANDS_ACTIVATED
ChangeToSpecialist_General()146 static void ChangeToSpecialist_General()
147 {
148 netGameData.myCharacterSubType=NGSCT_General;
149 ChangeToMarine();
150 }
ChangeToSpecialist_PulseRifle()151 static void ChangeToSpecialist_PulseRifle()
152 {
153 netGameData.myCharacterSubType=NGSCT_PulseRifle;
154 ChangeToMarine();
155 }
ChangeToSpecialist_Smartgun()156 static void ChangeToSpecialist_Smartgun()
157 {
158 if(netGameData.allowSmartgun)
159 {
160 netGameData.myCharacterSubType=NGSCT_Smartgun;
161 }
162 ChangeToMarine();
163 }
ChangeToSpecialist_Flamer()164 static void ChangeToSpecialist_Flamer()
165 {
166 if(netGameData.allowFlamer)
167 {
168 netGameData.myCharacterSubType=NGSCT_Flamer;
169 }
170 ChangeToMarine();
171 }
ChangeToSpecialist_Sadar()172 static void ChangeToSpecialist_Sadar()
173 {
174 if(netGameData.allowSadar)
175 {
176 netGameData.myCharacterSubType=NGSCT_Sadar;
177 }
178 ChangeToMarine();
179 }
ChangeToSpecialist_GrenadeLauncher()180 static void ChangeToSpecialist_GrenadeLauncher()
181 {
182 if(netGameData.allowGrenadeLauncher)
183 {
184 netGameData.myCharacterSubType=NGSCT_GrenadeLauncher;
185 }
186 ChangeToMarine();
187 }
ChangeToSpecialist_Minigun()188 static void ChangeToSpecialist_Minigun()
189 {
190 if(netGameData.allowMinigun)
191 {
192 netGameData.myCharacterSubType=NGSCT_Minigun;
193 }
194 ChangeToMarine();
195 }
ChangeToSpecialist_Frisbee()196 static void ChangeToSpecialist_Frisbee()
197 {
198 if(netGameData.allowSmartDisc)
199 {
200 netGameData.myCharacterSubType=NGSCT_Frisbee;
201 }
202 ChangeToMarine();
203 }
204
ChangeToSpecialist_Pistols()205 static void ChangeToSpecialist_Pistols()
206 {
207 if(netGameData.allowPistols)
208 {
209 netGameData.myCharacterSubType=NGSCT_Pistols;
210 }
211 ChangeToMarine();
212 }
213
ForceAssertionFailure(void)214 static void ForceAssertionFailure(void)
215 {
216 LOCALASSERT("This assertion has been forced to stop the game"==0);
217 }
218 #endif
219
ShowMultiplayerScores(void)220 extern void ShowMultiplayerScores(void)
221 {
222 ShowMultiplayerScoreTimer=5*ONE_FIXED;
223 }
224
225 extern void AddNetMsg_ChatBroadcast(char *string,BOOL same_species_only);
226
DoMultiplayerSay(char * string)227 static void DoMultiplayerSay(char* string)
228 {
229 AddNetMsg_ChatBroadcast(string,FALSE);
230 }
231
DoMultiplayerSaySpecies(char * string)232 static void DoMultiplayerSaySpecies(char* string)
233 {
234 AddNetMsg_ChatBroadcast(string,TRUE);
235 }
236
237
238
CDCommand_Play(int track)239 static void CDCommand_Play(int track)
240 {
241 if(!CDDA_IsOn()) CDDA_SwitchOn();
242
243 CDDA_Stop();
244 CDDA_Play(track);
245 }
CDCommand_PlayLoop(int track)246 void CDCommand_PlayLoop(int track)
247 {
248 if(!CDDA_IsOn()) CDDA_SwitchOn();
249
250 CDDA_Stop();
251 CDDA_PlayLoop(track);
252 }
253
CDCommand_Stop(void)254 static void CDCommand_Stop(void)
255 {
256 CDDA_Stop();
257 }
258
CDCommand_Volume(int volume)259 static void CDCommand_Volume(int volume)
260 {
261 if (volume>=0 && volume<=127)
262 {
263 CDDA_ChangeVolume(volume);
264 }
265 else
266 {
267 // say the volume setting is incorrect
268 }
269 }
270
271
272 #if CONSOLE_DEBUGGING_COMMANDS_ACTIVATED
GunX(int x)273 static void GunX(int x)
274 {
275 PLAYER_STATUS *playerStatusPtr= (PLAYER_STATUS *) (Player->ObStrategyBlock->SBdataptr);
276 PLAYER_WEAPON_DATA *weaponPtr = &(playerStatusPtr->WeaponSlot[playerStatusPtr->SelectedWeaponSlot]);
277 TEMPLATE_WEAPON_DATA *twPtr = &TemplateWeapon[weaponPtr->WeaponIDNumber];
278
279 twPtr->RestPosition.vx = x;
280 }
GunY(int y)281 static void GunY(int y)
282 {
283 PLAYER_STATUS *playerStatusPtr= (PLAYER_STATUS *) (Player->ObStrategyBlock->SBdataptr);
284 PLAYER_WEAPON_DATA *weaponPtr = &(playerStatusPtr->WeaponSlot[playerStatusPtr->SelectedWeaponSlot]);
285 TEMPLATE_WEAPON_DATA *twPtr = &TemplateWeapon[weaponPtr->WeaponIDNumber];
286
287 twPtr->RestPosition.vy = y;
288 }
GunZ(int z)289 static void GunZ(int z)
290 {
291 PLAYER_STATUS *playerStatusPtr= (PLAYER_STATUS *) (Player->ObStrategyBlock->SBdataptr);
292 PLAYER_WEAPON_DATA *weaponPtr = &(playerStatusPtr->WeaponSlot[playerStatusPtr->SelectedWeaponSlot]);
293 TEMPLATE_WEAPON_DATA *twPtr = &TemplateWeapon[weaponPtr->WeaponIDNumber];
294
295 twPtr->RestPosition.vz = z;
296 }
297 #endif
298
MakeRotatingLight(void)299 static void MakeRotatingLight(void)
300 {
301 MakeLightElement(&Player->ObWorld,LIGHTELEMENT_ROTATING);
302 }
303
304 #if CONSOLE_DEBUGGING_COMMANDS_ACTIVATED
RestartMultiplayer(void)305 static void RestartMultiplayer(void)
306 {
307 /* obviously have to be in a network game... */
308 if (AvP.Network==I_No_Network) return;
309
310 int seed=FastRandom();
311 AddNetMsg_RestartNetworkGame(seed);
312 RestartNetworkGame(seed);
313 }
314
CompleteLevel(void)315 static void CompleteLevel(void)
316 {
317 AvP.LevelCompleted = 1;
318 }
319 #endif
320
321
CreateGameSpecificConsoleCommands(void)322 void CreateGameSpecificConsoleCommands(void)
323 {
324 ShowDebuggingText.FPS = 0;
325 ShowDebuggingText.Environment = 0;
326 ShowDebuggingText.Coords = 0;
327 ShowDebuggingText.Module = 0;
328 ShowDebuggingText.Target = 0;
329 ShowDebuggingText.Networking = 0;
330 ShowDebuggingText.Dynamics = 0;
331 ShowDebuggingText.GunPos = 0;
332 ShowDebuggingText.Tears = 0;
333 ShowDebuggingText.PolyCount = 0;
334
335 #ifndef AVP_DEBUG_VERSION
336 BOOL IsACheat = TRUE;
337 #else
338 BOOL IsACheat = FALSE;
339 #endif
340
341 #ifndef AVP_DEBUG_VERSION // allow debug commands without -debug
342 #ifndef AVP_DEBUG_FOR_FOX // allow debug commands without -debug
343 if (DebuggingCommandsActive)
344 #endif
345 #endif
346 {
347 ConsoleCommand::Make
348 (
349 "GIVEALLWEAPONS",
350 "BE CAREFUL WHAT YOU WISH FOR",
351 GiveAllWeaponsCheat,
352 IsACheat
353 );
354
355
356 /* KJL 14:51:09 29/03/98 - show commands */
357 ConsoleCommand::Make
358 (
359 "SHOWFPS",
360 "DISPLAY THE FRAMERATE",
361 ShowFPS,
362 IsACheat
363 );
364
365 ConsoleCommand::Make
366 (
367 "SHOWPOLYCOUNT",
368 "DISPLAY NUMBER OF LANDSCAPE POLYS, AND NUMBER OF POLYS ACTUALLY RENDERED",
369 ShowPolyCount,
370 IsACheat
371 );
372 ConsoleCommand::Make
373 (
374 "LIGHT",
375 "CREATE A LIGHT",
376 MakeRotatingLight,
377 IsACheat
378 );
379 ConsoleCommand :: Make
380 (
381 "GIMME_CHARGE",
382 "GRANTS FULL FIELD CHARGE",
383 GimmeCharge,
384 IsACheat
385 );
386 ConsoleCommand :: Make
387 (
388 "ALIENBOT",
389 "CREATES ALIEN BOT. SAME AS ANY OTHER ALIEN.",
390 CastAlienBot,
391 IsACheat
392 );
393
394 ConsoleCommand :: Make
395 (
396 "MARINEBOT",
397 "CREATES MARINE BOT. SAME AS A GENERATED MARINE.",
398 CastMarineBot,
399 IsACheat
400 );
401
402 ConsoleCommand :: Make
403 (
404 "PREDOBOT",
405 "CREATES PREDATOR BOT.",
406 CastPredoBot,
407 IsACheat
408 );
409
410 ConsoleCommand :: Make
411 (
412 "PREDALIENBOT",
413 "CREATES PREDATOR ALIEN BOT.",
414 CastPredAlienBot,
415 IsACheat
416 );
417
418 ConsoleCommand :: Make
419 (
420 "PRAETORIANBOT",
421 "CREATES PRAETORIAN GUARD BOT.",
422 CastPraetorianBot,
423 IsACheat
424 );
425
426 ConsoleCommand :: Make
427 (
428 "XENOBORG",
429 "THEY'RE ALL BOTS ANYWAY...",
430 CastXenoborg,
431 IsACheat
432 );
433
434
435 }
436
437 #if CONSOLE_DEBUGGING_COMMANDS_ACTIVATED
438 ConsoleCommand::Make
439 (
440 "SHOWENV",
441 "DISPLAY THE ENVIRONMENT NAME",
442 ShowEnvironment
443 );
444
445 ConsoleCommand::Make
446 (
447 "SHOWCOORDS",
448 "DISPLAY THE PLAYERS CURRENT POSITION",
449 ShowCoords
450 );
451
452 ConsoleCommand::Make
453 (
454 "SHOWMODULE",
455 "DISPLAY THE PLAYERS CURRENT MODULE",
456 ShowModule
457 );
458
459 ConsoleCommand::Make
460 (
461 "SHOWTARGET",
462 "DISPLAY THE CURRENT TARGET POSITION",
463 ShowTarget
464 );
465
466 ConsoleCommand::Make
467 (
468 "SHOWNETWORKING",
469 "DISPLAY NETWORKING DEBUG TEXT",
470 ShowNetworking
471 );
472
473 ConsoleCommand::Make
474 (
475 "SHOWDYNAMICS",
476 "DISPLAY DYNAMICS DEBUG TEXT",
477 ShowDynamics
478 );
479
480 ConsoleCommand::Make
481 (
482 "SHOWGUNPOS",
483 "DISPLAY GUN OFFSET COORDS",
484 ShowGunPos
485 );
486
487 ConsoleCommand::Make
488 (
489 "SHOWTEARS",
490 "MAKE TEARS AND LINKING ERRORS APPEAR BRIGHT GREEN",
491 ShowTears
492 );
493
494 ConsoleCommand::Make
495 (
496 "SHOWSOUNDS",
497 "DISPLAY NUMBER OF ACTIVE SOUNDS",
498 ShowSounds
499 );
500
501
502 #if 1
503 ConsoleCommand::Make
504 (
505 "GUNX",
506 "CHANGE POSITION",
507 GunX
508 );
509 ConsoleCommand::Make
510 (
511 "GUNY",
512 "CHANGE POSITION",
513 GunY
514 );
515 ConsoleCommand::Make
516 (
517 "GUNZ",
518 "CHANGE POSITION",
519 GunZ
520 );
521 ConsoleCommand::Make
522 (
523 "DUCKBOT",
524 "MAKE A RUBBER DUCK",
525 CreateRubberDuckBot
526 );
527
528 ConsoleCommand::Make
529 (
530 "FORCEASSERTIONFAILURE",
531 "MAKE AN ASSERTION FIRE, EXITING THE GAME",
532 ForceAssertionFailure
533 );
534 #endif
535
536 ConsoleCommand::Make
537 (
538 "RESTARTMULTIPLAYER",
539 "RESTARTS A NETWORK GAME FROM SCRATCH",
540 RestartMultiplayer
541 );
542
543 ConsoleCommand::Make
544 (
545 "PAINTBALL",
546 "TOGGLES PAINTBALLMODE ON/OFF",
547 TogglePaintBallMode
548 );
549
550 ConsoleCommand::Make
551 (
552 "BUG",
553 "ADD A BUG REPORT TO CONSOLELOG.TXT",
554 OutputBugReportToConsoleLogfile
555 );
556 ConsoleCommand::Make
557 (
558 "REMOVEDECALS",
559 "DELETES ALL PRE-DECALS",
560 RemoveAllFixedDecals
561 );
562
563 ConsoleCommand::Make
564 (
565 "TURN3DSOUNDHARDWAREOFF",
566 "DEACTIVATES 3D SOUND IN HARDWARE",
567 PlatDontUse3DSoundHW
568 );
569 ConsoleCommand::Make
570 (
571 "TURN3DSOUNDHARDWAREON",
572 "ACTIVATES 3D SOUND IN HARDWARE",
573 PlatUse3DSoundHW
574 );
575
576 ConsoleCommand::Make
577 (
578 "NETGAME_INDIVIDUAL",
579 "CHANGE NETWORK GAME TYPE",
580 ChangeNetGameType_Individual
581 );
582 ConsoleCommand::Make
583 (
584 "NETGAME_COOP",
585 "CHANGE NETWORK GAME TYPE",
586 ChangeNetGameType_Coop
587 );
588 ConsoleCommand::Make
589 (
590 "NETGAME_LASTMANSTANDING",
591 "CHANGE NETWORK GAME TYPE",
592 ChangeNetGameType_LastManStanding
593 );
594 ConsoleCommand::Make
595 (
596 "NETGAME_PREDATORTAG",
597 "CHANGE NETWORK GAME TYPE",
598 ChangeNetGameType_PredatorTag
599 );
600
601
602 ConsoleCommand::Make
603 (
604 "TRIGGER_PLOT_FMV",
605 "",
606 StartTriggerPlotFMV
607 );
608
609
610 ConsoleCommand::Make
611 (
612 "SPECIALISTMARINE_GENERAL",
613 "Become a general marine (can use all weapons)",
614 ChangeToSpecialist_General
615 );
616 ConsoleCommand::Make
617 (
618 "SPECIALISTMARINE_PULSERIFLE",
619 "Become a pulserifle marine",
620 ChangeToSpecialist_PulseRifle
621 );
622 ConsoleCommand::Make
623 (
624 "SPECIALISTMARINE_SMARTGUN",
625 "Become a smartgun marine",
626 ChangeToSpecialist_Smartgun
627 );
628 ConsoleCommand::Make
629 (
630 "SPECIALISTMARINE_FLAMER",
631 "Become a flamethrower marine",
632 ChangeToSpecialist_Flamer
633 );
634 ConsoleCommand::Make
635 (
636 "SPECIALISTMARINE_SADAR",
637 "Become a sadar marine",
638 ChangeToSpecialist_Sadar
639 );
640 ConsoleCommand::Make
641 (
642 "SPECIALISTMARINE_GRENADELAUNCHER",
643 "Become a grenade launcher marine",
644 ChangeToSpecialist_GrenadeLauncher
645 );
646 ConsoleCommand::Make
647 (
648 "SPECIALISTMARINE_MINIGUN",
649 "Become a minigun marine",
650 ChangeToSpecialist_Minigun
651 );
652 ConsoleCommand::Make
653 (
654 "SPECIALISTMARINE_SD",
655 "Become an SD marine",
656 ChangeToSpecialist_Frisbee
657 );
658 ConsoleCommand::Make
659 (
660 "SPECIALISTMARINE_PISTOLS",
661 "Become a pistol marine",
662 ChangeToSpecialist_Pistols
663 );
664
665
666 #if 1
667 ConsoleCommand::Make
668 (
669 "COMPLETE_LEVEL",
670 "",
671 CompleteLevel
672 );
673 #endif
674 #endif
675
676 /* KJL 15:52:41 29/03/98 - version info */
677 ConsoleCommand::Make
678 (
679 "VERSION",
680 "",
681 GiveVersionDetails
682 );
683
684 ConsoleCommand::Make
685 (
686 "SAY",
687 "BROADCAST MESSAGE",
688 DoMultiplayerSay
689 );
690
691 ConsoleCommand::Make
692 (
693 "SAY_SPECIES",
694 "BROADCAST MESSAGE",
695 DoMultiplayerSaySpecies
696 );
697
698 ConsoleCommand::Make
699 (
700 "CDSTOP",
701 "STOP THE CD PLAYING",
702 CDCommand_Stop
703 );
704
705 ConsoleCommand::Make
706 (
707 "CDPLAY",
708 "SELECT A TRACK TO PLAY",
709 CDCommand_Play
710 );
711 ConsoleCommand::Make
712 (
713 "CDPLAYLOOP",
714 "SELECT A TRACK TO PLAY LOOPED",
715 CDCommand_PlayLoop
716 );
717
718 ConsoleCommand::Make
719 (
720 "CDVOLUME",
721 "SELECT SOUND LEVEL 0 TO 127",
722 CDCommand_Volume
723 );
724 ConsoleCommand::Make
725 (
726 "ID_PLAYER",
727 "Get name of player nearest centre of screen",
728 ShowNearestPlayersName
729 );
730 ConsoleCommand::Make
731 (
732 "SHOW_SCORE",
733 "Show frag table",
734 ShowMultiplayerScores
735 );
736
737 ConsoleCommand::Make
738 (
739 "DETAIL_LEVEL_MAX",
740 "",
741 SetToDefaultDetailLevels
742 );
743
744 ConsoleCommand::Make
745 (
746 "DETAIL_LEVEL_MIN",
747 "",
748 SetToMinimalDetailLevels
749 );
750
751 ConsoleCommand::Make
752 (
753 "SCREENSHOT",
754 "",
755 ScreenShot
756 );
757
758 ConsoleCommand::Make
759 (
760 "QUICKSAVE",
761 "",
762 QuickSave
763 );
764 ConsoleCommand::Make
765 (
766 "QUICKLOAD",
767 "",
768 QuickLoad
769 );
770 ConsoleCommand::Make
771 (
772 "SAVE",
773 "Save game to slot 1-8",
774 ConsoleCommandSave
775 );
776 ConsoleCommand::Make
777 (
778 "LOAD",
779 "Load game from slot 1-8",
780 ConsoleCommandLoad
781 );
782 ConsoleCommand::Make
783 (
784 "SAVESLEFT",
785 "",
786 DisplaySavesLeft
787 );
788
789 }
790
791 } // extern "C"
792