FS2_Open
Open source remastering of the Freespace 2 engine
keycontrol.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on the
6  * source.
7  *
8 */
9 
10 
11 
12 
13 #include "globalincs/pstypes.h"
14 #include "globalincs/globals.h"
15 #include "globalincs/linklist.h"
16 #include "io/key.h"
17 #include "io/joy.h"
18 #include "io/timer.h"
19 #include "ship/ship.h"
20 #include "playerman/player.h"
21 #include "weapon/weapon.h"
22 #include "hud/hud.h"
24 #include "mission/missiongoals.h"
25 #include "hud/hudets.h"
26 #include "gamesnd/gamesnd.h"
27 #include "hud/hudsquadmsg.h"
28 #include "gamesnd/eventmusic.h"
29 #include "freespace2/freespace.h"
30 #include "mission/missionhotkey.h"
31 #include "hud/hudescort.h"
32 #include "hud/hudshield.h"
33 #include "io/keycontrol.h"
34 #include "ship/shiphit.h"
35 #include "ship/shipfx.h"
36 #include "mission/missionlog.h"
37 #include "hud/hudtargetbox.h"
38 #include "popup/popup.h"
39 #include "object/objcollide.h"
40 #include "object/object.h"
41 #include "hud/hudconfig.h"
42 #include "hud/hudmessage.h"
43 #include "network/multi_pmsg.h"
44 #include "starfield/supernova.h"
45 #include "mission/missionmessage.h"
46 #include "menuui/mainhallmenu.h"
47 #include "missionui/missionpause.h"
48 #include "hud/hudgauges.h"
49 #include "freespace2/freespace.h" //For time compression stuff
51 #include "asteroid/asteroid.h"
52 #include "iff_defs/iff_defs.h"
53 #include "network/multi.h"
54 #include "network/multiutil.h"
55 #include "network/multimsgs.h"
56 #include "network/multi_pause.h"
57 #include "network/multi_observer.h"
58 #include "network/multi_endgame.h"
59 #include "autopilot/autopilot.h"
60 #include "cmdline/cmdline.h"
61 #include "object/objectshield.h"
62 
67 {
68 public:
74  factor_table(size_t size = 6);
75 
79  ~factor_table();
80 
88  size_t getNext(size_t n, size_t current);
89 
90 private:
91 
93 
99  void resize(size_t size);
100 
107  static bool isNaturalNumberFactor(size_t factor, size_t n);
108 };
109 
111 {
112  resize(size);
113 }
114 
116 
117 size_t factor_table::getNext(size_t n, size_t current)
118 {
119  Assertion(n >= 1, "factor_table::getNext() called with " SIZE_T_ARG ", when only natural numbers make sense; get a coder!\n", n);
120 
121  // Resize lookup table if the value is greater than the current size
122  if (n > _lookup.size())
123  resize(n);
124 
125  int index = n - 1;
126  for (size_t i = 0; i < _lookup[index].size(); ++i)
127  {
128  if (_lookup[index][i] == current)
129  {
130  if (_lookup[index].size() == i + 1)
131  {
132  // Overflow back to 1
133  return 1;
134  }
135  else
136  {
137  // Next factor in the table
138  return _lookup[index][i + 1];
139  }
140  }
141  }
142 
143  Assertion(false, "For some reason, factor_table::getNext() was unable to locate the current factor. This should never happen; get a coder!\n");
144  return 1;
145 }
146 
147 void factor_table::resize(size_t size)
148 {
149  size_t oldSize = _lookup.size();
150  _lookup.resize(size);
151 
152  // Fill lookup table for the missing values
153  for (size_t i = oldSize; i < size; ++i)
154  {
155  for (size_t j = 1; j <= i + 1; ++j)
156  {
157  if (isNaturalNumberFactor(j, i + 1))
158  {
159  _lookup[i].push_back(j);
160  }
161  }
162  }
163 }
164 
165 bool factor_table::isNaturalNumberFactor(size_t factor, size_t n)
166 {
167  return ((float)n / (float)factor) == n / factor;
168 }
169 
170 // Natural number factor lookup table
172 
173 // --------------------------------------------------------------
174 // Global to file
175 // --------------------------------------------------------------
176 
177 // time compression/dilation values - Goober5000
178 // (Volition sez "can't compress below 0.25"... not sure if
179 // this is arbitrary or dictated by code)
180 #define MAX_TIME_MULTIPLIER 64
181 #define MAX_TIME_DIVIDER 4
182 
183 #define CHEAT_BUFFER_LEN 17
185 
186 enum cheatCode {
194 };
195 
196 struct Cheat {
198  char* data;
199 };
200 
201 static struct Cheat cheatsTable[] = {
202  { CHEAT_CODE_FREESPACE, "www.freespace2.com" },
203  { CHEAT_CODE_FISH, "vasudanswuvfishes" },
204  { CHEAT_CODE_HEADZ, "humanheadsinside." },
205  { CHEAT_CODE_TOOLED, "tooledworkedowned" },
206  { CHEAT_CODE_PIRATE, "arrrrwalktheplank" },
207  { CHEAT_CODE_SKIP, "skipmemymissionyo" }
208 };
209 
210 #define CHEATS_TABLE_LEN 6
211 
212 int Tool_enabled = 0;
215 
216 extern int AI_watch_object;
217 extern int Countermeasures_enabled;
218 
219 extern float do_subobj_hit_stuff(object *ship_obj, object *other_obj, vec3d *hitpos, int submodel_num, float damage, bool *hull_should_apply_armor);
220 
221 extern void mission_goal_mark_all_true( int type );
222 
223 int Normal_key_set[] = {
224  TARGET_NEXT,
225  TARGET_PREV,
241 
249 
256  FORM_MESSAGE,
259  WARP_MESSAGE,
263 
264  VIEW_CHASE,
266  VIEW_TOPDOWN,
268 
269  SHOW_GOALS,
270  END_MISSION,
271 
273  ESCORT_CLEAR,
275 
276  XFER_SHIELD,
277  XFER_LASER,
284  ETS_EQUALIZE,
290 
296 
299 
308  MAX_THROTTLE,
309 
311 
317 
320 
322 
325 
326  TOGGLE_HUD,
327 
330  NAV_CYCLE,
331 
334 };
335 
336 int Dead_key_set[] = {
337  TARGET_NEXT,
338  TARGET_PREV,
356 
357  VIEW_CHASE,
359  VIEW_TOPDOWN,
360 
361  SHOW_GOALS,
362 
364  ESCORT_CLEAR,
367 
373 
376 };
377 
389  ETS_EQUALIZE,
395  XFER_SHIELD,
396  XFER_LASER,
397 };
398 
402  TARGET_NEXT,
403  TARGET_PREV,
433  FORM_MESSAGE,
436  WARP_MESSAGE,
439  VIEW_CHASE,
443  VIEW_TOPDOWN,
447  SHOW_GOALS,
448  END_MISSION,
450  ESCORT_CLEAR,
458 
461 
462  TOGGLE_HUD,
463 
466  NAV_CYCLE,
469 };
470 
472 
473 // set sizes of the key sets automatically
474 int Normal_key_set_size = sizeof(Normal_key_set) / sizeof(int);
475 int Dead_key_set_size = sizeof(Dead_key_set) / sizeof(int);
476 int Critical_key_set_size = sizeof(Critical_key_set) / sizeof(int);
478 
479 // --------------------------------------------------------------
480 // routine to process keys used only for debugging
481 // --------------------------------------------------------------
482 
484 {
485  if ( Player_obj == NULL )
486  return;
487 
488  int si_index = Ships[Player_obj->instance].ship_info_index;
489  int sanity = 0;
490  ship_info *sip;
491  while ( TRUE ) {
492  si_index += delta;
493  if ( si_index >= static_cast<int>(Ship_info.size()) ){
494  si_index = 0;
495  }
496  if ( si_index < 0 ){
497  si_index = static_cast<int>(Ship_info.size() - 1);
498  }
499  sip = &Ship_info[si_index];
500  if ( sip->flags & SIF_PLAYER_SHIP ){
501  break;
502  }
503 
504  // just in case
505  sanity++;
506  if ( sanity >= static_cast<int>(Ship_info.size()) ){
507  break;
508  }
509  }
510 
512  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "Player ship changed to %s", 0), Ship_info[si_index].name);
513 }
514 
520 {
521  object *objp;
522  ship_info *sip;
523  int si_index, species;
524  char name[NAME_LENGTH];
525 
526  if ( Player_ai->target_objnum == -1 )
527  return;
528 
529  objp = &Objects[Player_ai->target_objnum];
530  if ( objp->type != OBJ_SHIP )
531  return;
532 
533  si_index = Ships[objp->instance].ship_info_index;
534  Assert(si_index != -1 );
535  species = Ship_info[si_index].species;
536 
537  int sanity = 0;
538 
539  while ( TRUE ) {
540  si_index += delta;
541  if ( si_index >= static_cast<int>(Ship_info.size()) )
542  si_index = 0;
543  if ( si_index < 0 )
544  si_index = static_cast<int>(Ship_info.size() - 1);
545 
546 
547  sip = &Ship_info[si_index];
548 
549  // if it has test in the name, jump over it
550  strcpy_s(name, sip->name);
551  _strlwr(name);
552  if ( strstr(name,NOX("test")) != NULL )
553  continue;
554 
555  if ( sip->species == species && (sip->flags & (SIF_FIGHTER | SIF_BOMBER | SIF_TRANSPORT) ) )
556  break;
557 
558  // just in case
559  sanity++;
560  if ( sanity >= static_cast<int>(Ship_info.size()) )
561  break;
562  }
563 
564  change_ship_type(objp->instance, si_index);
565  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "Changed player target to %s", 1), Ship_info[si_index].name);
566 }
567 
569 {
570  int index;
571  ship *shipp = &Ships[objp->instance];
572  ship_info *sip = &Ship_info[shipp->ship_info_index];
573  ship_weapon *swp = &shipp->weapons;
574 
575  for ( index = 0; index < MAX_SHIP_SECONDARY_BANKS; index++ )
576  {
578  }
579 }
580 
581 void debug_max_primary_weapons(object *objp) // Goober5000
582 {
583  Assert(objp); // Goober5000
584 
585  int index;
586  ship *shipp = &Ships[objp->instance];
587  ship_info *sip = &Ship_info[shipp->ship_info_index];
588  ship_weapon *swp = &shipp->weapons;
589  weapon_info *wip;
590 
591  if (sip->flags & SIF_BALLISTIC_PRIMARIES)
592  {
593  for ( index = 0; index < MAX_SHIP_PRIMARY_BANKS; index++ )
594  {
595  wip = &Weapon_info[swp->primary_bank_weapons[index]];
596  if (wip->wi_flags2 & WIF2_BALLISTIC)
597  {
598  float capacity, size;
599  capacity = (float) sip->primary_bank_ammo_capacity[index];
600  size = (float) wip->cargo_size;
601  swp->primary_bank_ammo[index] = fl2i((capacity / size)+0.5f);
602  }
603  }
604  }
605 }
606 
608 {
609  char buf[256];
610  if ( event_music_next_soundtrack(delta) != -1 ) {
612  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "Soundtrack changed to: %s", 2), buf);
613 
614  } else {
615  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "Event music is not playing", 3));
616  }
617 }
618 
619 extern void hud_target_asteroid();
620 extern int Framerate_delay;
621 
622 extern void snd_stop_any_sound();
623 
624 extern vec3d Eye_position;
625 extern matrix Eye_matrix;
626 extern void g3_set_view_matrix(const vec3d *view_pos, const matrix *view_matrix, float zoom);
627 
628 extern int Show_cpu;
629 
630 int get_prev_weapon_looped(int current_weapon, int subtype)
631 {
632  int i, new_index;
633 
634  for (i = 1; i < Num_weapon_types; i++)
635  {
636  new_index = (Num_weapon_types + current_weapon - i) % Num_weapon_types;
637 
638  if(Weapon_info[new_index].subtype == subtype)
639  {
640  return new_index;
641  }
642  }
643 
644  return current_weapon;
645 }
646 
647 int get_next_weapon_looped(int current_weapon, int subtype)
648 {
649  int i, new_index;
650 
651  for (i = 1; i < Num_weapon_types; i++)
652  {
653  new_index = (current_weapon + i) % Num_weapon_types;
654 
655  if(Weapon_info[new_index].subtype == subtype)
656  {
657  return new_index;
658  }
659  }
660 
661  return current_weapon;
662 }
663 
665 {
666  // Kazan -- NO CHEATS IN MULTI
668  {
669  Cheats_enabled = 0;
670  return;
671  }
672 
673  switch (k) {
674  case KEY_DEBUGGED + KEY_Q:
675  case KEY_DEBUGGED1 + KEY_Q:
676  Snapshot_all_events = true;
677  break;
678 
679  case KEY_DEBUGGED + KEY_H:
681  break;
682 
683  case KEY_DEBUGGED + KEY_F:
684  extern int wacky_scheme;
685  if(wacky_scheme == 3){
686  wacky_scheme = 0;
687  } else {
688  wacky_scheme++;
689  }
690  break;
691 
692  case KEY_DEBUGGED + KEY_ALTED + KEY_F:
693  Framerate_delay += 10;
694  HUD_printf(XSTR( "Framerate delay increased to %i milliseconds per frame.", 4), Framerate_delay);
695  break;
696 
698  Framerate_delay -= 10;
699  if (Framerate_delay < 0)
700  Framerate_delay = 0;
701 
702  HUD_printf(XSTR( "Framerate delay decreased to %i milliseconds per frame.", 5), Framerate_delay);
703  break;
704 
705  case KEY_DEBUGGED + KEY_X:
706  case KEY_DEBUGGED1 + KEY_X:
707  HUD_printf("Cloaking has been disabled, thank you for playing fs2_open, %s", Player->callsign);
708  break;
709 
710  case KEY_DEBUGGED + KEY_C:
711  case KEY_DEBUGGED1 + KEY_C:
714  HUD_sourced_printf(HUD_SOURCE_HIDDEN, "Player no longer collides");
715  } else {
717  HUD_sourced_printf(HUD_SOURCE_HIDDEN, "Player collides");
718  }
719  break;
720 
721  case KEY_DEBUGGED + KEY_SHIFTED + KEY_C:
723  Countermeasures_enabled = !Countermeasures_enabled;
724  HUD_printf(XSTR( "Countermeasure firing: %s", 6), Countermeasures_enabled ? XSTR( "ENABLED", 7) : XSTR( "DISABLED", 8));
725  break;
726 
727 // Goober5000: this should only be compiled in debug builds, since it crashes release
728 #ifndef NDEBUG
729  case KEY_DEBUGGED + KEY_E:
731  break;
732 #endif
733 
734  // Goober5000: handle time dilation in cheat section
737  if ( Game_mode & GM_NORMAL ) {
740  } else {
742  }
743  } else {
745  }
746  break;
747 
748  // Goober5000: handle as normal here
751  if ( Game_mode & GM_NORMAL ) {
754  } else {
756  }
757  } else {
759  }
760  break;
761 
762  // Kill! the currently targeted ship.
763  case KEY_DEBUGGED + KEY_K:
764  case KEY_DEBUGGED1 + KEY_K:
765  if (Player_ai->target_objnum != -1) {
766  object *objp = &Objects[Player_ai->target_objnum];
767 
768  switch (objp->type) {
769  case OBJ_SHIP:
770 
771  // remove guardian flag -- kazan
773 
774  ship_apply_local_damage( objp, Player_obj, &objp->pos, 100000.0f, MISS_SHIELDS, CREATE_SPARKS);
776  break;
777  case OBJ_WEAPON:
778  Weapons[objp->instance].lifeleft = 0.01f;
779  break;
780  }
781  }
782 
783  break;
784 
785  // play the next mission message
786  case KEY_DEBUGGED + KEY_V:
787  extern int Message_debug_index;
788  extern int Num_messages_playing;
789  // stop any other messages
790  if(Num_messages_playing){
791  message_kill_all(1);
792  }
793 
794  // next message
795  if(Message_debug_index >= Num_messages - 1){
796  Message_debug_index = Num_builtin_messages;
797  } else {
798  Message_debug_index++;
799  }
800 
801  // play the message
802  message_send_unique_to_player( Messages[Message_debug_index].name, Message_waves[Messages[Message_debug_index].wave_info.index].name, MESSAGE_SOURCE_SPECIAL, MESSAGE_PRIORITY_HIGH, 0, 0 );
803  if (Messages[Message_debug_index].avi_info.index == -1) {
804  HUD_printf("No anim set for message \"%s\"; None will play!", Messages[Message_debug_index].name);
805  }
806  break;
807 
808  // play the previous mission message
809  case KEY_DEBUGGED + KEY_SHIFTED + KEY_V:
810  extern int Message_debug_index;
811  extern int Num_messages_playing;
812  // stop any other messages
813  if(Num_messages_playing){
814  message_kill_all(1);
815  }
816 
817  // go maybe go down one
818  if(Message_debug_index == Num_builtin_messages - 1){
819  Message_debug_index = Num_builtin_messages;
820  } else if(Message_debug_index > Num_builtin_messages){
821  Message_debug_index--;
822  }
823 
824  // play the message
825  message_send_unique_to_player( Messages[Message_debug_index].name, Message_waves[Messages[Message_debug_index].wave_info.index].name, MESSAGE_SOURCE_SPECIAL, MESSAGE_PRIORITY_HIGH, 0, 0 );
826  if (Messages[Message_debug_index].avi_info.index == -1) {
827  HUD_printf("No avi associated with this message; None will play!");
828  }
829  break;
830 
831  // reset to the beginning of mission messages
832  case KEY_DEBUGGED + KEY_ALTED + KEY_V:
833  extern int Message_debug_index;
834  Message_debug_index = Num_builtin_messages - 1;
835  HUD_printf("Resetting to first mission message");
836  break;
837 
838  // Kill! the currently targeted ship.
841  if (Player_ai->target_objnum != -1) {
842  object *objp = &Objects[Player_ai->target_objnum];
843 
844  if (objp->type == OBJ_SHIP) {
846  }
847  }
848  break;
849 
850  // Kill the currently targeted subsystem.
851  case KEY_DEBUGGED + KEY_SHIFTED + KEY_K:
853  if ((Player_ai->target_objnum != -1) && (Player_ai->targeted_subsys != NULL)) {
854  object *objp = &Objects[Player_ai->target_objnum];
855  if ( objp->type == OBJ_SHIP ) {
856  ship *sp = &Ships[objp->instance];
857  vec3d g_subobj_pos;
858 
859  get_subsystem_world_pos(objp, Player_ai->targeted_subsys, &g_subobj_pos);
860 
862 
865  sp->flags |= SF_DISABLED; // add the disabled flag
866  }
867 
870  }
871  }
872  }
873  break;
874 
875  case KEY_DEBUGGED + KEY_ALTED + KEY_K:
876  case KEY_DEBUGGED1 + KEY_ALTED + KEY_K:
877  {
878  float shield, integrity;
879  vec3d pos, randvec;
880 
881  vm_vec_rand_vec_quick(&randvec);
882  vm_vec_scale_add(&pos, &Player_obj->pos, &randvec, Player_obj->radius);
884  hud_get_target_strength(Player_obj, &shield, &integrity);
885  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "You knocked yourself down to %7.3f percent hull.\n", 9), 100.0f * integrity);
886  break;
887  }
888 
889  // Whack down the player's shield and hull by a little more than 50%
890  // Select next object to be viewed by AI.
891  case KEY_DEBUGGED + KEY_I:
892  case KEY_DEBUGGED1 + KEY_I:
894  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "You are %s", 10), Player_obj->flags & OF_INVULNERABLE ? XSTR( "now INVULNERABLE!", 11) : XSTR( "no longer invulnerable...", 12));
895  break;
896 
897  case KEY_DEBUGGED + KEY_SHIFTED + KEY_I:
899  if (Player_ai->target_objnum != -1) {
900  object *objp = &Objects[Player_ai->target_objnum];
901 
902  objp->flags ^= OF_INVULNERABLE;
903  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "Player's target [%s] is %s", 13), Ships[objp->instance].ship_name, objp->flags & OF_INVULNERABLE ? XSTR( "now INVULNERABLE!", 11) : XSTR( "no longer invulnerable...", 12));
904  }
905  break;
906 
907  case KEY_DEBUGGED + KEY_N:
908  AI_watch_object++;
909  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "Spewing debug info about object #%d", 14), AI_watch_object);
910  break;
911 
912  case KEY_DEBUGGED + KEY_O:
913  case KEY_DEBUGGED1 + KEY_O:
915  break;
916 
917  case KEY_DEBUGGED + KEY_SHIFTED + KEY_O:
918  extern int Debug_octant;
919  if(Debug_octant == 7){
920  Debug_octant = -1;
921  } else {
922  Debug_octant++;
923  }
924  nprintf(("General", "Debug_octant == %d\n", Debug_octant));
925  break;
926 
927  case KEY_DEBUGGED + KEY_P:
928  supernova_start(20);
929  break;
930 
931  case KEY_DEBUGGED + KEY_W:
932  case KEY_DEBUGGED1 + KEY_W:
933  case KEY_DEBUGGED + KEY_SHIFTED + KEY_W:
935  // temp code for testing purposes, toggles weapon energy cheat
937  if (Weapon_energy_cheat) {
938  if (k & KEY_SHIFTED)
939  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "Weapon energy and missile count will always be at full ALL SHIPS!", 15));
940  else
941  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "Weapon energy and missile count will always be at full for player", 16));
942 
945  if (k & KEY_SHIFTED) {
946  object *objp;
947 
948  for ( objp = GET_FIRST(&obj_used_list); objp !=END_OF_LIST(&obj_used_list); objp = GET_NEXT(objp) )
949  if (objp->type == OBJ_SHIP) {
952  }
953  }
954 
955  } else
956  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "Normal weapon energy system / missile count restored", 17));
957 
958  break;
959 
960  case KEY_DEBUGGED + KEY_G:
961  case KEY_DEBUGGED1 + KEY_G:
963  break;
964 
965  case KEY_DEBUGGED + KEY_G + KEY_SHIFTED:
968  break;
969 
970  case KEY_DEBUGGED + KEY_G + KEY_ALTED:
971  case KEY_DEBUGGED1 + KEY_G + KEY_ALTED:
973  break;
974 
975  case KEY_DEBUGGED + KEY_9: {
976  case KEY_DEBUGGED1 + KEY_9:
977  ship* shipp;
978 
979  shipp = &Ships[Player_obj->instance];
980  int *weap = &shipp->weapons.secondary_bank_weapons[shipp->weapons.current_secondary_bank];
981  *weap = get_next_weapon_looped(*weap, WP_MISSILE);
982 
983  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "Secondary Weapon forced to %s", 18), Weapon_info[*weap].name);
984  break;
985  }
986 
987 
988  case KEY_DEBUGGED + KEY_SHIFTED + KEY_9: {
990  ship* shipp;
991 
992  shipp = &Ships[Player_obj->instance];
993  int *weap = &shipp->weapons.secondary_bank_weapons[shipp->weapons.current_secondary_bank];
994  *weap = get_prev_weapon_looped(*weap, WP_MISSILE);
995 
996  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "Secondary Weapon forced to %s", 18), Weapon_info[*weap].name);
997  break;
998  }
999 
1000  case KEY_DEBUGGED + KEY_U: {
1001  case KEY_DEBUGGED1 + KEY_U:
1002  // launch asteroid
1003  object *asteroid_create(asteroid_field *asfieldp, int asteroid_type, int subtype);
1004  object *objp = asteroid_create(&Asteroid_field, 0, 0);
1005  if(objp == NULL) {
1006  break;
1007  }
1008  vec3d vel;
1009  vm_vec_copy_scale(&vel, &Player_obj->orient.vec.fvec, 50.0f);
1010  objp->phys_info.vel = vel;
1011  objp->phys_info.desired_vel = vel;
1012  objp->pos = Player_obj->pos;
1013  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "Asteroid launched", 1595));
1014  break;
1015  }
1016 
1017  case KEY_DEBUGGED + KEY_0: {
1018  case KEY_DEBUGGED1 + KEY_0:
1019  ship* shipp;
1020 
1021  shipp = &Ships[Player_obj->instance];
1022  int *weap = &shipp->weapons.primary_bank_weapons[shipp->weapons.current_primary_bank];
1023  *weap = get_next_weapon_looped(*weap, WP_LASER);
1024 
1025  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "Primary Weapon forced to %s", 19), Weapon_info[*weap].name);
1026  break;
1027  }
1028 
1029  case KEY_DEBUGGED + KEY_SHIFTED + KEY_0: {
1030  case KEY_DEBUGGED1 + KEY_SHIFTED + KEY_0:
1031  ship* shipp;
1032 
1033  shipp = &Ships[Player_obj->instance];
1034  int *weap = &shipp->weapons.primary_bank_weapons[shipp->weapons.current_primary_bank];
1035  *weap = get_prev_weapon_looped(*weap, WP_LASER);
1036 
1037  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "Primary Weapon forced to %s", 19), Weapon_info[*weap].name);
1038  break;
1039  }
1040 
1041  case KEY_DEBUGGED + KEY_J: {
1042  int new_pattern = event_music_return_current_pattern();
1043 
1044  new_pattern++;
1045  if ( new_pattern >= MAX_PATTERNS )
1046  new_pattern = 0;
1047 
1048  event_music_change_pattern(new_pattern);
1049  break;
1050  }
1051 
1052  case KEY_DEBUGGED + KEY_M: {
1053  if ( Event_music_enabled ) {
1055  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "Event music disabled", 20));
1056 
1057  } else {
1059  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "Event music enabled", 21));
1060  }
1061 
1062  break;
1063  }
1064 
1065  case KEY_DEBUGGED + KEY_R:
1066  case KEY_DEBUGGED1 + KEY_R:
1067  {
1068  // rearm the target, if we have one
1069  object *obj_to_rearm = (Player_ai->target_objnum >= 0) ? &Objects[Player_ai->target_objnum] : Player_obj;
1070 
1071  if (is_support_allowed(obj_to_rearm))
1072  {
1073  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR("Issuing rearm request for %s", -1), Ships[obj_to_rearm->instance].ship_name);
1074  ai_issue_rearm_request(obj_to_rearm);
1075  }
1076  else
1077  {
1078  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR("Cannot issue rearm request for %s", -1), Ships[obj_to_rearm->instance].ship_name);
1079  }
1080 
1081  break;
1082  }
1083 
1084  case KEY_DEBUGGED + KEY_SHIFTED + KEY_UP:
1086  HUD_printf( XSTR( "Detail level set to %+d\n", 22), Game_detail_level );
1087  break;
1088 
1091  HUD_printf( XSTR( "Detail level set to %+d\n", 22), Game_detail_level );
1092  break;
1093 
1094 #ifndef NDEBUG
1095  case KEY_DEBUGGED + KEY_SHIFTED + KEY_T: {
1096  extern int Test_begin;
1097 
1098  if ( Test_begin == 1 )
1099  break;
1100 
1101  Test_begin = 1;
1102  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "Frame Rate test started", 23));
1103 
1104  break;
1105  }
1106 #endif
1107  case KEY_DEBUGGED + KEY_A: {
1108 
1109  HUD_printf("frame rate currently is %0.2 FPS", 1/flFrametime);
1110 
1111  break;
1112  }
1113 
1114 
1115  case KEY_DEBUGGED + KEY_D:
1116  extern int OO_update_index;
1117 
1118  if(MULTIPLAYER_MASTER){
1119  do {
1120  OO_update_index++;
1121  } while((OO_update_index < (MAX_PLAYERS-1)) && !MULTI_CONNECTED(Net_players[OO_update_index]));
1122  if(OO_update_index >= MAX_PLAYERS-1){
1123  OO_update_index = -1;
1124  }
1125  } else {
1126  if(OO_update_index < 0){
1127  OO_update_index = MY_NET_PLAYER_NUM;
1128  } else {
1129  OO_update_index = -1;
1130  }
1131  }
1132  break;
1133 
1134  // change player ship to next flyable type
1135  case KEY_DEBUGGED + KEY_RIGHT:
1137  break;
1138 
1139  // change player ship to previous flyable ship
1140  case KEY_DEBUGGED + KEY_LEFT:
1142  break;
1143 
1144  // cycle target to ship
1147  break;
1148 
1149  // cycle target to previous ship
1152  break;
1153 
1154  // change species of the targeted ship
1155  case KEY_DEBUGGED + KEY_S: {
1156  if ( Player_ai->target_objnum < 0 )
1157  break;
1158 
1159  object *objp;
1160  ship_info *sip;
1161 
1162  objp = &Objects[Player_ai->target_objnum];
1163  if ( objp->type != OBJ_SHIP )
1164  return;
1165 
1166  sip = &Ship_info[Ships[objp->instance].ship_info_index];
1167  sip->species++;
1168 
1169  if (sip->species >= (int)Species_info.size())
1170  sip->species = 0;
1171 
1172  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "Species of target changed to: %s", 24), Species_info[sip->species].species_name);
1173  break;
1174  }
1175 
1176  case KEY_DEBUGGED + KEY_SHIFTED + KEY_S:
1178  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "Skill level set to %s.", 25), Skill_level_names(Game_skill_level));
1179  break;
1180 
1181  case KEY_DEBUGGED + KEY_T: {
1182  char buf[256];
1183  event_music_get_info(buf);
1185  break;
1186  }
1187 
1188  case KEY_DEBUGGED + KEY_UP:
1189  case KEY_DEBUGGED1 + KEY_UP:
1190  debug_change_song(1);
1191  break;
1192 
1193  case KEY_DEBUGGED + KEY_DOWN:
1194  case KEY_DEBUGGED1 + KEY_DOWN:
1195  debug_change_song(-1);
1196  break;
1197 
1198  case KEY_PADMINUS: {
1199  int init_flag = 0;
1200 
1201  if ( keyd_pressed[KEY_1] ) {
1202  init_flag = 1;
1203  HUD_color_red -= 4;
1204  }
1205 
1206  if ( keyd_pressed[KEY_2] ) {
1207  init_flag = 1;
1208  HUD_color_green -= 4;
1209  }
1210 
1211  if ( keyd_pressed[KEY_3] ) {
1212  init_flag = 1;
1213  HUD_color_blue -= 4;
1214  }
1215 
1216  if (init_flag)
1217  HUD_init_colors();
1218 
1219  break;
1220  }
1221 
1222  case KEY_DEBUGGED + KEY_Y:
1223  extern int tst;
1224  tst = 2;
1225  break;
1226 
1227  case KEY_PADPLUS: {
1228  int init_flag = 0;
1229 
1230  if ( keyd_pressed[KEY_1] ) {
1231  init_flag = 1;
1232  HUD_color_red += 4;
1233  }
1234 
1235  if ( keyd_pressed[KEY_2] ) {
1236  init_flag = 1;
1237  HUD_color_green += 4;
1238  }
1239 
1240  if ( keyd_pressed[KEY_3] ) {
1241  init_flag = 1;
1242  HUD_color_blue += 4;
1243  }
1244 
1245  if (init_flag)
1246  HUD_init_colors();
1247 
1248  break;
1249  }
1250  case KEY_DEBUGGED + KEY_ALTED + KEY_EQUAL:
1252  {
1253  camera *cam = Main_camera.getCamera();
1254  if(cam == NULL)
1255  {
1256  HUD_sourced_printf(HUD_SOURCE_HIDDEN, "Couldn't get camera FOV");
1257  break;
1258  }
1259  cam->set_fov(cam->get_fov() + 0.1f);
1260  HUD_sourced_printf(HUD_SOURCE_HIDDEN, "Camera fov raised to %0.2f" , cam->get_fov());
1261  }
1262  break;
1263 
1264  case KEY_DEBUGGED + KEY_ALTED + KEY_MINUS:
1266  {
1267  camera *cam = Main_camera.getCamera();
1268  if(cam == NULL)
1269  {
1270  HUD_sourced_printf(HUD_SOURCE_HIDDEN, "Couldn't get camera FOV");
1271  break;
1272  }
1273  cam->set_fov(cam->get_fov() - 0.1f);
1274  HUD_sourced_printf(HUD_SOURCE_HIDDEN, "Camera fov lowered to %0.2f" , cam->get_fov());
1275  }
1276  break;
1277  case KEY_DEBUGGED + KEY_Z:
1278  case KEY_DEBUGGED1 + KEY_Z:
1279  {
1280  Show_cpu = !Show_cpu;
1281  }
1282  break;
1283 
1284  } // end switch
1285 }
1286 
1287 void ppsk_hotkeys(int k)
1288 {
1289  // use k to check for keys that can have Shift,Ctrl,Alt,Del status
1290  int hotkey_set;
1291 
1292 #ifndef NDEBUG
1293  k &= ~KEY_DEBUGGED; // since hitting F11 will set this bit
1294 #endif
1295 
1296  switch (k) {
1297  case KEY_F5:
1298  case KEY_F6:
1299  case KEY_F7:
1300  case KEY_F8:
1301  case KEY_F9:
1302  case KEY_F10:
1303  case KEY_F11:
1304  case KEY_F12:
1305  hotkey_set = mission_hotkey_get_set_num(k);
1307  hud_target_hotkey_select( hotkey_set );
1308  else
1309  hud_squadmsg_hotkey_select( hotkey_set );
1310 
1311  break;
1312 
1313  case KEY_F5 + KEY_SHIFTED:
1314  case KEY_F6 + KEY_SHIFTED:
1315  case KEY_F7 + KEY_SHIFTED:
1316  case KEY_F8 + KEY_SHIFTED:
1317  case KEY_F9 + KEY_SHIFTED:
1318  case KEY_F10 + KEY_SHIFTED:
1319  case KEY_F11 + KEY_SHIFTED:
1320  case KEY_F12 + KEY_SHIFTED:
1321  hotkey_set = mission_hotkey_get_set_num(k&(~KEY_SHIFTED));
1322  mprintf(("Adding to set %d\n", hotkey_set+1));
1323  if ( Player_ai->target_objnum == -1)
1324  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "No target to add/remove from set %d.", 26), hotkey_set+1);
1325  else {
1327  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "%s added to set %d. (F%d)", 27), Ships[Objects[Player_ai->target_objnum].instance].ship_name, hotkey_set, 4+hotkey_set+1);
1328  }
1329 
1330  break;
1331 
1332  case KEY_F5 + KEY_SHIFTED + KEY_ALTED:
1333  case KEY_F6 + KEY_SHIFTED + KEY_ALTED:
1334  case KEY_F7 + KEY_SHIFTED + KEY_ALTED:
1335  case KEY_F8 + KEY_SHIFTED + KEY_ALTED:
1336  case KEY_F9 + KEY_SHIFTED + KEY_ALTED:
1337  case KEY_F10 + KEY_SHIFTED + KEY_ALTED:
1338  case KEY_F11 + KEY_SHIFTED + KEY_ALTED:
1339  case KEY_F12 + KEY_SHIFTED + KEY_ALTED:
1340  hotkey_set = mission_hotkey_get_set_num(k & (~(KEY_SHIFTED+KEY_ALTED)));
1341  hud_target_hotkey_clear( hotkey_set );
1342  break;
1343 
1344  case KEY_SHIFTED + KEY_MINUS:
1346  HUD_color_alpha--;
1347  HUD_init_colors();
1348  }
1349  break;
1350 
1351  case KEY_SHIFTED + KEY_EQUAL:
1353  HUD_color_alpha++;
1354  HUD_init_colors();
1355  }
1356  break;
1357  } // end switch
1358 }
1359 
1368 void process_set_of_keys(int key, int count, int *list)
1369 {
1370  int i;
1371 
1372  for (i=0; i<count; i++)
1373  if (check_control(list[i], key))
1374  button_info_set(&Player->bi, list[i]);
1375 }
1376 
1381 {
1382  int masked_k;
1383 
1384  masked_k = k & ~KEY_CTRLED; // take out CTRL modifier only
1385 
1386  // moved this line to beginning of function since hotkeys now encompass
1387  // F5 - F12. We can return after using F11 as a hotkey.
1388  ppsk_hotkeys(masked_k);
1390  return;
1391  }
1392 
1393  // if we're in supernova mode. do nothing
1395  return;
1396  }
1397 
1398  // pass the key to the squadmate messaging code. If the messaging code took the key, then return
1399  // from here immediately since we don't want to do further key processing.
1400  if ( hud_squadmsg_read_key(k) )
1401  return;
1402 
1403  if ( Player->control_mode == PCM_NORMAL ) {
1404  // The following things are not legal to do while dead.
1405  if ( !(Game_mode & GM_DEAD) ) {
1406  process_set_of_keys(masked_k, Normal_key_set_size, Normal_key_set);
1407  } else {
1408  process_set_of_keys(masked_k, Dead_key_set_size, Dead_key_set);
1409  }
1411  // first clear all
1413 
1414  // then check the keys.
1415  int i;
1416  for(i = 0; i < CCFG_MAX; i++) {
1417  if (check_control(i, masked_k))
1419  }
1420  }
1421  } else {
1422 
1423  }
1424 }
1425 
1430 {
1431  int pf_flags, choice;
1432 
1433  // do the multiplayer version of this
1434  if(Game_mode & GM_MULTIPLAYER){
1436  } else {
1437  // single player version....
1438  // do housekeeping things.
1439  game_stop_time();
1441  snd_stop_all();
1442 
1443  quit_mission_popup_shown = true;
1444 
1446  choice = popup(pf_flags, 3, POPUP_NO, XSTR( "&Yes, Quit", 28), XSTR( "Yes, &Restart", 29), XSTR( "Do you really want to end the mission?", 30));
1447 
1448  switch (choice) {
1449  case 1:
1451  break;
1452 
1453  case 2:
1455  break;
1456 
1457  default:
1458  break; // do nothing
1459  }
1460  quit_mission_popup_shown = false;
1461 
1462  game_start_time();
1463  game_flush();
1464  }
1465 }
1466 
1471 {
1472  // special processing for multiplayer
1473  if (Game_mode & GM_MULTIPLAYER) {
1474  if(Multi_pause_status){
1476  } else {
1478  }
1479  } else {
1481  }
1482 }
1483 
1488 {
1489  size_t i;
1490 
1491  if ( k == 0 ){
1492  return;
1493  }
1494 
1495  // no cheats in multiplayer, ever
1496  if(Game_mode & GM_MULTIPLAYER){
1497  Cheats_enabled = 0;
1498  return;
1499  }
1500 
1501  for (i = 0; i < CHEAT_BUFFER_LEN; i++){
1502  CheatBuffer[i]=CheatBuffer[i+1];
1503  }
1504 
1505  CheatBuffer[CHEAT_BUFFER_LEN - 1] = (char)key_to_ascii(k);
1506 
1507  cheatCode detectedCheatCode = CHEAT_CODE_NONE;
1508 
1509  for(i=0; i < CHEATS_TABLE_LEN; i++) {
1510  Cheat cheat = cheatsTable[i];
1511 
1512  if(!strncmp(cheat.data, CheatBuffer, CHEAT_BUFFER_LEN)){
1513  detectedCheatCode = cheat.code;
1514  break;
1515  }
1516  }
1517 
1518  if(detectedCheatCode == CHEAT_CODE_FREESPACE){
1519  Cheats_enabled = 1;
1520 
1521  // cheating allows the changing of weapons so we have to grab anything
1522  // that we don't already have loaded, just in case
1523  extern void weapons_page_in_cheats();
1525 
1526  HUD_printf("Cheats enabled");
1527  }
1528  if(detectedCheatCode == CHEAT_CODE_FISH){
1529  // only enable in the Vasudan main hall
1531  extern void fishtank_start();
1532  fishtank_start();
1533  }
1534  }
1535  if(detectedCheatCode == CHEAT_CODE_HEADZ){
1536  // only enable in the Vasudan main hall
1539  }
1540  }
1541  if(detectedCheatCode == CHEAT_CODE_SKIP && (gameseq_get_state() == GS_STATE_MAIN_MENU)){
1542  extern void main_hall_campaign_cheat();
1544  }
1545  if(detectedCheatCode == CHEAT_CODE_TOOLED && (Game_mode & GM_IN_MISSION)){
1546  Tool_enabled = 1;
1547  HUD_printf("Prepare to be taken to school");
1548  }
1549  if(detectedCheatCode == CHEAT_CODE_PIRATE && (Game_mode & GM_IN_MISSION) && (Player_obj != NULL)){
1550  extern void prevent_spawning_collision(object *new_obj);
1551  ship_subsys *ptr;
1552  char name[NAME_LENGTH];
1553  int ship_idx, ship_class;
1554 
1555  // if not found, then don't create it :(
1556  ship_class = ship_info_lookup("Volition Bravos");
1557  if (ship_class < 0)
1558  return;
1559 
1560  HUD_printf(NOX("Walk the plank"));
1561 
1562  vec3d pos = Player_obj->pos;
1564  pos.xyz.x += frand_range(-700.0f, 700.0f);
1565  pos.xyz.y += frand_range(-700.0f, 700.0f);
1566  pos.xyz.z += frand_range(-700.0f, 700.0f);
1567 
1568  int objnum = ship_create(&orient, &pos, ship_class);
1569  if (objnum < 0)
1570  return;
1571 
1572  ship *shipp = &Ships[Objects[objnum].instance];
1573  shipp->ship_name[0] = '\0';
1574  shipp->orders_accepted = (1<<NUM_COMM_ORDER_ITEMS)-1;
1575 
1576  // Goober5000 - stolen from support ship creation
1577  // create a name for the ship. use "Volition Bravos #". look for collisions until one isn't found anymore
1578  ship_idx = 1;
1579  do {
1580  sprintf(name, NOX("Volition Bravos %d"), ship_idx);
1581  if ( (ship_name_lookup(name) == -1) && (ship_find_exited_ship_by_name(name) == -1) )
1582  {
1583  strcpy_s(shipp->ship_name, name);
1584  break;
1585  }
1586 
1587  ship_idx++;
1588  } while(1);
1589 
1590  shipp->flags |= SF_ESCORT;
1591  shipp->escort_priority = 1000 - ship_idx;
1592 
1593  // now make sure we're not colliding with anyone
1594  prevent_spawning_collision(&Objects[objnum]);
1595 
1596  // Goober5000 - beam free
1597  for (ptr = GET_FIRST(&shipp->subsys_list); ptr != END_OF_LIST(&shipp->subsys_list); ptr = GET_NEXT(ptr))
1598  {
1599  // mark all turrets as beam free
1600  if (ptr->system_info->type == SUBSYSTEM_TURRET)
1601  {
1603  ptr->turret_next_fire_stamp = timestamp((int) frand_range(50.0f, 4000.0f));
1604  }
1605  }
1606 
1607  // warpin
1608  shipfx_warpin_start(&Objects[objnum]);
1609  }
1610 }
1611 
1613 {
1614  int k;
1615 
1616  button_info_clear(&Player->bi); // clear out the button info struct for the player
1617  do
1618  {
1619  k = game_poll();
1620 
1621  if ( Game_mode & GM_DEAD_BLEW_UP ) {
1622  continue;
1623  }
1624 
1625  game_process_cheats( k );
1627  process_debug_keys(k);
1628 
1629  switch (k) {
1630  case 0:
1631  // No key
1632  break;
1633 
1634  case KEY_ESC:
1635  if ( Player->control_mode != PCM_NORMAL ) {
1638  } else {
1639  // too late to abort warp out!
1640  }
1641  } else {
1642  // let the ESC key break out of messaging mode
1645  break;
1646  }
1647 
1648  //If topdown view in non-2D mission, go back to cockpit view.
1649  if ( (Viewer_mode & VM_TOPDOWN) && !(The_mission.flags & MISSION_FLAG_2D_MISSION) && !(Perspective_locked) ) {
1650  Viewer_mode &= ~VM_TOPDOWN;
1651  break;
1652  }
1653 
1654  // if in external view or chase view, go back to cockpit view
1655  if ( (Viewer_mode & (VM_EXTERNAL|VM_CHASE|VM_OTHER_SHIP)) && !(Perspective_locked) ) {
1657  break;
1658  }
1659 
1660  if (!(Game_mode & GM_DEAD_DIED))
1662 
1663  }
1664  break;
1665 
1666  case KEY_Y:
1667  break;
1668 
1669  case KEY_N:
1670  break;
1671 
1672  case KEY_ALTED + KEY_SHIFTED+KEY_J:
1673  // treat the current joystick position as the center position
1674  joy_set_cen();
1675  break;
1676 
1677  case KEY_DEBUGGED | KEY_PAUSE:
1679  break;
1680 
1681  case KEY_ALTED + KEY_PAUSE:
1682  if( Game_mode & GM_DEAD_BLEW_UP ||
1683  Game_mode & GM_DEAD_DIED) {
1684  break;
1685  }
1686 
1689  break;
1690  case KEY_PAUSE:
1691  if( Game_mode & GM_DEAD_BLEW_UP ||
1692  Game_mode & GM_DEAD_DIED) {
1693  break;
1694  }
1695 
1698  break;
1699 
1700  } // end switch
1701  }
1702  while (k);
1703 
1704  // lua button command override goes here!!
1707  Player->bi = Player->lua_bi;
1708  Player->lua_bi = temp;
1709  } else if (lua_game_control & LGC_B_ADDITIVE) {
1710  // add the lua commands to current commands
1711  int i;
1712  for (i=0; i<NUM_BUTTON_FIELDS; i++)
1713  Player->bi.status[i] |= Player->lua_bi.status[i];
1714  Player->lua_bi = Player->bi;
1715  } else {
1716  // just copy over the values
1717  Player->lua_bi = Player->bi;
1718  }
1719  // there.. wasnt that bad hack was it?
1720 
1721  button_info_do(&Player->bi); // call functions based on status of button_info bit vectors
1722 }
1723 
1725 {
1726  object *objp;
1727  player *pl;
1728  net_player *npl;
1729  int at_self; // flag indicating the object is local (for hud messages, etc)
1730 
1731  Assert(n >= 0);
1732 
1733  // multiplayer clients should leave critical button bits alone and pass them to the server instead
1734  if (MULTIPLAYER_CLIENT) {
1735  // if this flag is set, we should apply the button itself (came from the server)
1736  if (!Multi_button_info_ok){
1737  return 0;
1738  }
1739  }
1740 
1741  // in single player mode make sure we're using the player object and the player himself, otherwise use the object and
1742  // player pertaining to the passed net_player
1743  npl = NULL;
1744  if (p == NULL) {
1745  objp = Player_obj;
1746  pl = Player;
1747 
1748  if(Game_mode & GM_MULTIPLAYER){
1749  npl = Net_player;
1750 
1751  // if we're the server in multiplayer and we're an observer, don't process our own critical button functions
1753  return 0;
1754  }
1755  }
1756 
1757  at_self = 1;
1758  } else {
1759  objp = &Objects[p->m_player->objnum];
1760  pl = p->m_player;
1761  npl = p;
1762  at_self = 0;
1763 
1764  if ( NETPLAYER_IS_DEAD(npl) || (Ships[Objects[pl->objnum].instance].flags & SF_DYING) )
1765  return 0;
1766  }
1767 
1768  switch (n) {
1769  // cycle num primaries to fire at once
1771  {
1772  int count;
1773  ship * shipp = &Ships[objp->instance];
1774  ship_weapon *swp = &shipp->weapons;
1775  ship_info *sip = &Ship_info[shipp->ship_info_index];
1776  if (sip->flags2 & SIF2_DYN_PRIMARY_LINKING) {
1777  polymodel *pm = model_get( sip->model_num );
1778  count = ftables.getNext( pm->gun_banks[ swp->current_primary_bank ].num_slots, swp->primary_bank_slot_count[ swp->current_primary_bank ] );
1780  shipp->last_fired_point[ swp->current_primary_bank ] += count - ( shipp->last_fired_point[ swp->current_primary_bank ] % count);
1781  shipp->last_fired_point[ swp->current_primary_bank ] -= 1;
1783  }
1784  }
1785  break;
1786 
1787  // cycle to next primary weapon
1788  case CYCLE_NEXT_PRIMARY:
1789  if (at_self) {
1791  }
1792 
1795  ship* shipp = &Ships[objp->instance];
1797  shipp->weapons.next_primary_fire_stamp[shipp->weapons.current_primary_bank] = timestamp(250); // 1/4 second delay until can fire
1798  }
1799 
1800  // multiplayer server should maintain bank/link status here
1801  if ( MULTIPLAYER_MASTER ) {
1802  Assert(npl != NULL);
1804  }
1805  }
1806  break;
1807 
1808  // cycle to previous primary weapon
1809  case CYCLE_PREV_PRIMARY:
1810  if (at_self) {
1812  }
1813 
1816  ship* shipp = &Ships[objp->instance];
1818  shipp->weapons.next_primary_fire_stamp[shipp->weapons.current_primary_bank] = timestamp(250); // 1/4 second delay until can fire
1819  }
1820 
1821  // multiplayer server should maintain bank/link status here
1822  if ( MULTIPLAYER_MASTER ) {
1823  Assert(npl != NULL);
1825  }
1826  }
1827  break;
1828 
1829  // cycle to next secondary weapon
1830  case CYCLE_SECONDARY:
1831  if(at_self)
1833 
1835  if (ship_select_next_secondary(objp)) {
1836  ship* shipp = &Ships[objp->instance];
1838  shipp->weapons.next_secondary_fire_stamp[shipp->weapons.current_secondary_bank] = timestamp(250); // 1/4 second delay until can fire
1839  }
1840 
1841  // multiplayer server should maintain bank/link status here
1842  if( MULTIPLAYER_MASTER ){
1843  Assert(npl != NULL);
1845  }
1846  }
1847  break;
1848 
1849  // cycle number of missiles
1850  case CYCLE_NUM_MISSLES: {
1851  if(at_self)
1853 
1854  if ( objp == Player_obj ) {
1855  if ( Player_ship->weapons.num_secondary_banks <= 0 ) {
1856  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "This ship has no secondary weapons", 33));
1858  break;
1859  }
1860  }
1861 
1863 
1864  int firepoints = pm->missile_banks[Ships[objp->instance].weapons.current_secondary_bank].num_slots;
1865 
1866  if ( Ships[objp->instance].flags & SF_SECONDARY_DUAL_FIRE || firepoints < 2) {
1867  Ships[objp->instance].flags &= ~SF_SECONDARY_DUAL_FIRE;
1868  if(at_self) {
1869  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "Secondary weapon set to normal fire mode", 34));
1872  }
1873  } else {
1874  Ships[objp->instance].flags |= SF_SECONDARY_DUAL_FIRE;
1875  if(at_self) {
1876  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "Secondary weapon set to dual fire mode", 35));
1879  }
1880  }
1881 
1882  // multiplayer server should maintain bank/link status here
1883  if( MULTIPLAYER_MASTER ){
1884  Assert(npl != NULL);
1885  multi_server_update_player_weapons(npl,&Ships[objp->instance]);
1886  }
1887  break;
1888  }
1889 
1890  // increase weapon recharge rate
1891  case INCREASE_WEAPON:
1892  if(at_self)
1895 
1896  // multiplayer server should maintain bank/link status here
1897  if( MULTIPLAYER_MASTER ){
1898  Assert(npl != NULL);
1900  }
1901  break;
1902 
1903  // decrease weapon recharge rate
1904  case DECREASE_WEAPON:
1905  if(at_self)
1908 
1909  // multiplayer server should maintain bank/link status here
1910  if( MULTIPLAYER_MASTER ){
1911  Assert(npl != NULL);
1913  }
1914  break;
1915 
1916  // increase shield recharge rate
1917  case INCREASE_SHIELD:
1918  if(at_self)
1921 
1922  // multiplayer server should maintain bank/link status here
1923  if( MULTIPLAYER_MASTER ){
1924  Assert(npl != NULL);
1926  }
1927  break;
1928 
1929  // decrease shield recharge rate
1930  case DECREASE_SHIELD:
1931  if(at_self)
1934 
1935  // multiplayer server should maintain bank/link status here
1936  if( MULTIPLAYER_MASTER ){
1937  Assert(npl != NULL);
1939  }
1940  break;
1941 
1942  // increase energy to engines
1943  case INCREASE_ENGINE:
1944  if(at_self)
1947 
1948  // multiplayer server should maintain bank/link status here
1949  if( MULTIPLAYER_MASTER ){
1950  Assert(npl != NULL);
1952  }
1953  break;
1954 
1955  // decrease energy to engines
1956  case DECREASE_ENGINE:
1957  if(at_self)
1960 
1961  // multiplayer server should maintain bank/link status here
1962  if( MULTIPLAYER_MASTER ){
1963  Assert(npl != NULL);
1965  }
1966  break;
1967 
1968  // equalize recharge rates
1969  case ETS_EQUALIZE:
1970  if (at_self) {
1972  }
1973 
1976 
1977  // multiplayer server should maintain bank/link status here
1978  if( MULTIPLAYER_MASTER ){
1979  Assert(npl != NULL);
1981  }
1982  break;
1983 
1984  // equalize shield energy to all quadrants
1985  case SHIELD_EQUALIZE:
1986  if(at_self){
1988  }
1989  hud_shield_equalize(objp, pl);
1990  break;
1991 
1992  // transfer shield energy to front
1993  case SHIELD_XFER_TOP:
1994  if(at_self){
1996  }
1998  break;
1999 
2000  // transfer shield energy to rear
2001  case SHIELD_XFER_BOTTOM:
2002  if(at_self)
2005  break;
2006 
2007  // transfer shield energy to left
2008  case SHIELD_XFER_LEFT:
2009  if(at_self)
2012  break;
2013 
2014  // transfer shield energy to right
2015  case SHIELD_XFER_RIGHT:
2016  if(at_self)
2019  break;
2020 
2021  // transfer energy to shield from weapons
2022  case XFER_SHIELD:
2023  if(at_self)
2026  break;
2027 
2028  // transfer energy to weapons from shield
2029  case XFER_LASER:
2030  if(at_self)
2033  break;
2034 
2035  // following are not handled here, but we need to bypass the Int3()
2036  case LAUNCH_COUNTERMEASURE:
2037  case VIEW_SLEW:
2038  case VIEW_EXTERNAL:
2040  case VIEW_TRACK_TARGET:
2041  case ONE_THIRD_THROTTLE:
2042  case TWO_THIRDS_THROTTLE:
2045  case ZERO_THROTTLE:
2046  case MAX_THROTTLE:
2047  case TOGGLE_GLIDING:
2048  return 0;
2049 
2050  default :
2051  Int3(); // bad bad bad
2052  break;
2053  }
2054 
2055  return 1;
2056 }
2057 
2064 {
2065  // by default, we'll return "not processed". ret will get set to 1, if this is one of the keys which is always allowed, even in demo
2066  // playback.
2067  int ret = 0;
2068 
2069  // No keys, not even targeting keys, when player in death roll. He can press keys after he blows up.
2070  if (Game_mode & GM_DEAD_DIED){
2071  return 0;
2072  }
2073 
2074  // any of these buttons are valid
2075  switch(n){
2076  case VIEW_CHASE:
2078  if(!Perspective_locked)
2079  {
2080  Viewer_mode ^= VM_CHASE;
2081  }
2082  else
2083  {
2085  }
2086  ret = 1;
2087  break;
2088 
2089  case VIEW_TRACK_TARGET: // Target padlock mode toggle (Swifty)
2091  if (!Perspective_locked) {
2092  if(Viewer_mode & VM_TRACK) {
2093  chase_slew_angles.h = 0;
2094  chase_slew_angles.p = 0;
2095  }
2096  Viewer_mode ^= VM_TRACK;
2097  } else {
2099  }
2100  ret = 1;
2101  break;
2102 
2103  case VIEW_EXTERNAL:
2105  if(!Perspective_locked)
2106  {
2108  Viewer_mode &= ~VM_EXTERNAL_CAMERA_LOCKED; // reset camera lock when leaving/entering external view
2109  }
2110  else
2111  {
2113  }
2114  ret = 1;
2115  break;
2116 
2117  case VIEW_TOPDOWN:
2119  if(!Perspective_locked)
2120  {
2122  }
2123  else
2124  {
2126  }
2127  ret = 1;
2128  break;
2129 
2132  if ( Viewer_mode & VM_EXTERNAL ) {
2135  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "External camera is locked, controls will move ship", 36));
2136  } else {
2137  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "External camera is free, controls will move the camera, not the ship", 37));
2138  }
2139  }
2140  ret = 1;
2141  break;
2142 
2143  case VIEW_OTHER_SHIP:
2145  if ( Player_ai->target_objnum < 0 || Perspective_locked) {
2147  } else {
2150  } else {
2152  }
2153  }
2154  ret = 1;
2155  break;
2156 
2157  case TIME_SLOW_DOWN:
2158  if ( Game_mode & GM_NORMAL ) {
2159  // Goober5000 - time dilation only available in cheat mode (see above);
2160  // now you can do it with or without pressing the tilde, per Kazan's request
2163  } else {
2165  }
2166  } else {
2168  }
2169  ret = 1;
2170  break;
2171 
2172  case TIME_SPEED_UP:
2173  if ( Game_mode & GM_NORMAL ) {
2176  } else {
2178  }
2179  } else {
2181  }
2182  ret = 1;
2183  break;
2184  }
2185 
2186  // done
2187  return ret;
2188 }
2189 
2190 bool key_is_targeting(int n)
2191 {
2192  switch(n) {
2193  case TARGET_NEXT:
2194  case TARGET_PREV:
2203  case TARGET_TARGETS_TARGET:
2205  case TARGET_PREV_SUBOBJECT:
2206  case TARGET_NEXT_SUBOBJECT:
2207  return true;
2208 
2209  default:
2210  return false;
2211  }
2212 }
2213 
2219 {
2220  Assert(n >= 0);
2221 
2222  if (Control_config[n].disabled)
2223  return 0;
2224 
2225  // check if the button has been set to be ignored by a SEXP
2226  if (Ignored_keys[n]) {
2227  if (Ignored_keys[n] > 0) {
2228  Ignored_keys[n]--;
2229  }
2230  return 0;
2231  }
2232 
2233  // No keys, not even targeting keys, when player in death roll. He can press keys after he blows up.
2234  if (Game_mode & GM_DEAD_DIED){
2235  return 0;
2236  }
2237 
2238  // Goober5000 - if the ship doesn't have subspace drive, jump key doesn't work: so test and exit early
2240  {
2241  switch(n)
2242  {
2243  case END_MISSION:
2244  control_used(n); // set the timestamp for when we used the control, in case we need it
2245  return 1; // pretend we took the action: if we return 0, strange stuff may happen
2246  }
2247  }
2248 
2249  // Goober5000 - if we have primitive sensors, some keys don't work: so test and exit early
2251  {
2252  switch (n)
2253  {
2254  case MATCH_TARGET_SPEED:
2256  case TOGGLE_AUTO_TARGETING:
2257  case TARGET_NEXT:
2258  case TARGET_PREV:
2267  case STOP_TARGETING_SHIP:
2269  case TARGET_TARGETS_TARGET:
2271  case TARGET_NEXT_SUBOBJECT:
2272  case TARGET_PREV_SUBOBJECT:
2274  case TARGET_NEXT_BOMB:
2275  case TARGET_PREV_BOMB:
2278  case TARGET_NEWEST_SHIP:
2282  control_used(n); // set the timestamp for when we used the control, in case we need it
2283  return 1; // pretend we took the action: if we return 0, strange stuff may happen
2284  }
2285  }
2286 
2287  switch(n) {
2288  // following are not handled here, but we need to bypass the Int3()
2289  case LAUNCH_COUNTERMEASURE:
2290  case VIEW_SLEW:
2291  case VIEW_TRACK_TARGET:
2292  case ONE_THIRD_THROTTLE:
2293  case TWO_THIRDS_THROTTLE:
2296  case ZERO_THROTTLE:
2297  case MAX_THROTTLE:
2298  case TOGGLE_GLIDING:
2299  case GLIDE_WHEN_PRESSED:
2300  return 0;
2301  }
2302 
2308  switch (n) {
2310  case CYCLE_NEXT_PRIMARY: // cycle to next primary weapon
2311  case CYCLE_PREV_PRIMARY: // cycle to previous primary weapon
2312  case CYCLE_SECONDARY: // cycle to next secondary weapon
2313  case CYCLE_NUM_MISSLES: // cycle number of missiles fired from secondary bank
2314  case SHIELD_EQUALIZE: // equalize shield energy to all quadrants
2315  case SHIELD_XFER_TOP: // transfer shield energy to front
2316  case SHIELD_XFER_BOTTOM: // transfer shield energy to rear
2317  case SHIELD_XFER_LEFT: // transfer shield energy to left
2318  case SHIELD_XFER_RIGHT: // transfer shield energy to right
2319  case XFER_SHIELD: // transfer energy to shield from weapons
2320  case XFER_LASER: // transfer energy to weapons from shield
2321  return button_function_critical(n);
2322  break;
2323 
2324  case INCREASE_WEAPON: // increase weapon recharge rate
2325  case DECREASE_WEAPON: // decrease weapon recharge rate
2326  case INCREASE_SHIELD: // increase shield recharge rate
2327  case DECREASE_SHIELD: // decrease shield recharge rate
2328  case INCREASE_ENGINE: // increase energy to engines
2329  case DECREASE_ENGINE: // decrease energy to engines
2330  case ETS_EQUALIZE:
2331  if ((Player_ship->flags2 & SF2_NO_ETS) == 0) {
2333  return button_function_critical(n);
2334  }
2335  return 1;
2336  break;
2337  }
2338 
2345  int keyHasBeenUsed = TRUE;
2346 
2347  switch(n) {
2348  // message all netplayers button
2349  case MULTI_MESSAGE_ALL:
2351  break;
2352 
2353  // message all friendlies button
2356  break;
2357 
2358  // message all hostiles button
2359  case MULTI_MESSAGE_HOSTILE:
2361  break;
2362 
2363  // message targeted ship (if player)
2364  case MULTI_MESSAGE_TARGET:
2366  break;
2367 
2368  // undefined in multiplayer for clients right now
2369  // toggle auto-match target speed
2371  // multiplayer observers can't match target speed
2373  break;
2374  }
2375 
2381  if ( !(Player->flags & PLAYER_FLAGS_MATCH_TARGET) ) {
2383  }
2384  }
2385  else
2386  {
2389  }
2390  break;
2391 
2394  break;
2395 
2398  break;
2399 
2400  case TARGET_NEWEST_SHIP:
2402  break;
2403 
2406  break;
2407 
2410  break;
2411 
2412  // end the mission
2413  case END_MISSION:
2414  // in multiplayer, all end mission requests should go through the server
2415  if (Game_mode & GM_MULTIPLAYER) {
2417  break;
2418  }
2419 
2421 
2424  && collide_predict_large_ship(Player_obj, 100000.0f)))
2425  {
2427  HUD_printf(XSTR( "** WARNING ** Collision danger. Subspace drive not activated.", 39));
2428  } else if (!ship_engine_ok_to_warp(Player_ship)) {
2430  HUD_printf(XSTR("Engine failure. Cannot engage subspace drive.", 40));
2431  } else if (!ship_navigation_ok_to_warp(Player_ship)) {
2433  HUD_printf(XSTR("Navigation failure. Cannot engage subspace drive.", 1596));
2434  } else if ( (Player_obj != NULL) && object_get_gliding(Player_obj)) {
2436  HUD_printf(XSTR("Cannot engage subspace drive while gliding.", 1597));
2437  } else {
2439  }
2440  break;
2441 
2442  case ADD_REMOVE_ESCORT:
2443  if ( Player_ai->target_objnum >= 0 ) {
2446  }
2447  break;
2448 
2449  // if i'm an observer, zoom to my targeted object
2452  break;
2453 
2454  // toggle between high and low HUD contrast
2455  case TOGGLE_HUD_CONTRAST:
2458  break;
2459 
2460  // toggle network info
2461  case MULTI_TOGGLE_NETINFO:
2462  extern int Multi_display_netinfo;
2463  Multi_display_netinfo = !Multi_display_netinfo;
2464  break;
2465 
2466  // self destruct (multiplayer only)
2467  case MULTI_SELF_DESTRUCT:
2468  if (!(Game_mode & GM_MULTIPLAYER)) {
2469  break;
2470  }
2471 
2472  // bogus netplayer
2473  if ( (Net_player == NULL) || (Net_player->m_player == NULL) ) {
2474  break;
2475  }
2476 
2477  // blow myself up, if I'm the server
2479  if ( (Net_player->m_player->objnum >= 0) &&
2482  (Objects[Net_player->m_player->objnum].instance >= 0) &&
2484  {
2485 
2487  }
2488  } else { // otherwise send a packet to the server
2490  }
2491  break;
2492 
2493  case TOGGLE_HUD:
2495  hud_toggle_draw();
2496  break;
2497 
2499  if (!Lock_targetbox_mode) {
2502  } else {
2504  }
2505  break;
2506 
2507  // Autopilot key control
2508  case AUTO_PILOT_TOGGLE:
2510  if (AutoPilotEngaged) {
2511  if (Cmdline_autopilot_interruptable == 1) //allow WCS to disable autopilot interrupt via commandline
2512  EndAutoPilot();
2513  } else {
2514  if (!StartAutopilot())
2516  }
2517  }
2518  break;
2519 
2520  case NAV_CYCLE:
2521  if (!Sel_NextNav())
2523  break;
2524  default:
2525  keyHasBeenUsed = FALSE;
2526  break;
2527  }
2528 
2532  if (keyHasBeenUsed) {
2533  return 1;
2534  }
2535 
2539  control_used(n);
2540 
2541  if ( hud_sensors_ok(Player_ship) ) {
2542  keyHasBeenUsed = TRUE;
2543  switch(n) {
2544  // target next
2545  case TARGET_NEXT:
2546  hud_target_next();
2547  break;
2548 
2549  // target previous
2550  case TARGET_PREV:
2551  hud_target_prev();
2552  break;
2553 
2554  // target the next hostile target
2557  break;
2558 
2559  // target the previous closest hostile
2561  hud_target_next_list(1,0);
2562  break;
2563 
2564  // target the next friendly ship
2567  break;
2568 
2569  // target the closest friendly ship
2571  hud_target_next_list(0,0);
2572  break;
2573 
2574  // target ship closest to center of reticle
2577  break;
2578 
2581  break;
2582 
2583  // target the closest ship attacking current target
2585  if (Player_ai->target_objnum < 0) {
2587  break;
2588  }
2589 
2591  break;
2592 
2593  // target closest ship that is attacking player
2596  break;
2597 
2598  // target your target's target
2599  case TARGET_TARGETS_TARGET:
2601  break;
2602 
2603  // target ships subsystem in reticle
2606  break;
2607 
2608  case TARGET_PREV_SUBOBJECT:
2610  break;
2611 
2612  // target next subsystem on current target
2613  case TARGET_NEXT_SUBOBJECT:
2615  break;
2616 
2617  default:
2618  keyHasBeenUsed = FALSE;
2619  break;
2620  };
2621  if (keyHasBeenUsed) {
2622  return 1;
2623  }
2624  }
2625  else
2626  {
2627  //if sensors are gone, and the passed key is one of the targeting keys, we need to exit here before we hit the Int3() later in this function
2628  if (key_is_targeting(n)) {
2629  return 1;
2630  }
2631  }
2632 
2633  keyHasBeenUsed = TRUE;
2634  switch(n) {
2635  // undefined in multiplayer for clients right now
2636  // match target speed
2637  case MATCH_TARGET_SPEED:
2638  // If player is auto-matching, break auto-match speed
2641  }
2643  break;
2644 
2645  // toggle auto-targeting
2646  case TOGGLE_AUTO_TARGETING:
2650  if (hud_sensors_ok(Player_ship)) {
2653  //HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "Auto targeting activated", -1));
2654  } else {
2656  }
2657  } else {
2659  //HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "Auto targeting deactivated", -1));
2660  }
2661  break;
2662 
2663  // target the closest repair ship
2665  // AL: Try to find the closest repair ship coming to repair the player... if no support
2666  // ships are coming to rearm the player, just try for the closest repair ship
2668  if ( hud_target_closest_repair_ship() == 0 ) {
2670  }
2671  }
2672  break;
2673 
2674  // stop targeting ship
2675  case STOP_TARGETING_SHIP:
2677  break;
2678 
2679  // stop targeting subsystems on ship
2682  break;
2683 
2684  case TARGET_NEXT_BOMB:
2686  break;
2687 
2688  case TARGET_PREV_BOMB:
2690  break;
2691 
2692  // wingman message: attack current target
2693  case ATTACK_MESSAGE:
2695  break;
2696 
2697  // wingman message: disarm current target
2698  case DISARM_MESSAGE:
2700  break;
2701 
2702  // wingman message: disable current target
2703  case DISABLE_MESSAGE:
2705  break;
2706 
2707  // wingman message: disable current target
2710  break;
2711 
2712  // wingman message: capture current target
2713  case CAPTURE_MESSAGE:
2715  break;
2716 
2717  // wingman message: engage enemy
2718  case ENGAGE_MESSAGE:
2720  break;
2721 
2722  // wingman message: form on my wing
2723  case FORM_MESSAGE:
2725  break;
2726 
2727  // wingman message: protect current target
2728  case PROTECT_MESSAGE:
2730  break;
2731 
2732  // wingman message: cover me
2733  case COVER_MESSAGE:
2735  break;
2736 
2737  // wingman message: warp out
2738  case WARP_MESSAGE:
2740  break;
2741 
2742  case IGNORE_MESSAGE:
2744  break;
2745 
2746  // rearm message
2747  case REARM_MESSAGE:
2749  break;
2750 
2751  // cycle to next radar range
2752  case RADAR_RANGE_CYCLE:
2753  HUD_config.rp_dist++;
2754  if ( HUD_config.rp_dist >= RR_MAX_RANGES )
2755  HUD_config.rp_dist = 0;
2756 
2757  HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "Radar range set to %s", 38), Radar_range_text(HUD_config.rp_dist));
2758  break;
2759 
2760  // toggle the squadmate messaging menu
2761  case SQUADMSG_MENU:
2762  hud_squadmsg_toggle(); // leave the details to the messaging code!!!
2763  break;
2764 
2765  // show the mission goals screen
2766  case SHOW_GOALS:
2768  break;
2769 
2770  // end the mission
2771  case END_MISSION:
2772  // in multiplayer, all end mission requests should go through the server
2773  if(Game_mode & GM_MULTIPLAYER){
2775  break;
2776  }
2777 
2779 
2782  && collide_predict_large_ship(Player_obj, 100000.0f)))
2783  {
2785  HUD_printf(XSTR( "** WARNING ** Collision danger. Subspace drive not activated.", 39));
2786  } else if (!ship_engine_ok_to_warp(Player_ship)) {
2788  HUD_printf(XSTR("Engine failure. Cannot engage subspace drive.", 40));
2789  } else if (!ship_navigation_ok_to_warp(Player_ship)) {
2791  HUD_printf(XSTR("Navigation failure. Cannot engage subspace drive.", 1572));
2792  } else if (Player_obj != NULL && object_get_gliding(Player_obj)) {
2794  HUD_printf(XSTR("Cannot engage subspace drive while gliding.", 1573));
2795  } else {
2797  }
2798  break;
2799 
2800  case ADD_REMOVE_ESCORT:
2801  if ( Player_ai->target_objnum >= 0 ) {
2804  }
2805  break;
2806 
2807  case ESCORT_CLEAR:
2808  hud_escort_clear_all(true);
2809  break;
2810 
2813  break;
2814 
2815  default:
2816  keyHasBeenUsed = FALSE;
2817  break;
2818  };
2819  if (keyHasBeenUsed) {
2820  return 1;
2821  }
2822 
2826  mprintf(("Unknown key %d at %s:%u\n", n, __FILE__, __LINE__));
2827  Int3();
2828 
2829  return 1;
2830 }
2831 
2837 {
2838  for (int i = 0; i < CCFG_MAX; i++) {
2839  if( button_info_query(bi, i) ) {
2840  int keyHasBeenUsed = FALSE;
2841 
2842  if( !keyHasBeenUsed ) {
2843  keyHasBeenUsed = button_function_demo_valid(i);
2844  }
2845 
2846  if( !keyHasBeenUsed ) {
2847  keyHasBeenUsed = button_function(i);
2848  }
2849 
2850  if( keyHasBeenUsed ) {
2851  button_info_unset(bi, i);
2852  }
2853  }
2854  }
2855 }
2856 
2857 
2862 {
2863  int field_num, bit_num;
2864 
2865  field_num = n / 32;
2866  bit_num = n % 32;
2867 
2868  bi->status[field_num] |= (1 << bit_num);
2869 }
2870 
2875 {
2876  int field_num, bit_num;
2877 
2878  field_num = n / 32;
2879  bit_num = n % 32;
2880 
2881  bi->status[field_num] &= ~(1 << bit_num);
2882 }
2883 
2885 {
2886  return bi->status[n / 32] & (1 << (n % 32));
2887 }
2888 
2893 {
2894  int i;
2895 
2896  for (i=0; i<NUM_BUTTON_FIELDS; i++) {
2897  bi->status[i] = 0;
2898  }
2899 }
2900 
2905 {
2906  int idx;
2907 
2908  // clear out all noncritical keys
2909  for(idx=0;idx<Non_critical_key_set_size;idx++){
2910  button_info_unset(bi,Non_critical_key_set[idx]);
2911  }
2912 }
#define KEY_0
Definition: key.h:71
#define GM_DEAD_DIED
Definition: systemvars.h:20
void game_flush()
Definition: fredstubs.cpp:83
void hud_get_target_strength(object *objp, float *shields, float *integrity)
void hud_shield_equalize(object *objp, player *pl)
Definition: hudshield.cpp:209
int Multi_button_info_ok
Definition: multi.cpp:100
void ppsk_hotkeys(int k)
#define OF_INVULNERABLE
Definition: object.h:107
target your target's target
#define KEY_K
Definition: key.h:92
int Critical_key_set_size
Definition: keycontrol.cpp:476
int flags
Definition: ship.h:150
int timestamp(int delta_ms)
Definition: timer.cpp:226
#define PLAYER_FLAGS_MATCH_TARGET
Definition: player.h:36
int Tool_enabled
Definition: keycontrol.cpp:212
#define CYCLE_PRIMARY_PREV
Definition: ship.h:63
#define MULTIPLAYER_CLIENT
Definition: multi.h:132
int ship_info_lookup(const char *token)
Definition: ship.cpp:12772
void snd_stop_all()
Definition: sound.cpp:905
#define MY_NET_PLAYER_NUM
Definition: multi.h:127
void obj_set_flags(object *obj, uint new_flags)
Definition: object.cpp:1000
int i
Definition: multi_pxo.cpp:466
float p
Definition: pstypes.h:111
TOGGLE_GLIDING.
void pause_set_type(int type)
model_subsystem * system_info
Definition: ship.h:314
int HUD_color_alpha
Definition: hud.cpp:76
weapon Weapons[MAX_WEAPONS]
Definition: weapons.cpp:78
int primary_bank_weapons[MAX_SHIP_PRIMARY_BANKS]
Definition: ship.h:103
int Normal_key_set[]
Definition: keycontrol.cpp:223
void hud_gauge_popup_start(int gauge_index, int time)
Start a gauge to pop-up.
Definition: hud.cpp:3036
#define MAX_SHIP_PRIMARY_BANKS
Definition: globals.h:62
void decrease_recharge_rate(object *obj, SYSTEM_TYPE ship_system)
Definition: hudets.cpp:473
#define BONUS_GOAL
Definition: missiongoals.h:30
toggle the squadmate messaging menu
ai_info * Player_ai
Definition: ai.cpp:24
increase energy to engines
int team
Definition: ship.h:606
int Framerate_delay
Definition: fredstubs.cpp:187
void hud_target_prev(int team_mask)
Definition: hudtarget.cpp:1252
#define KEY_DOWN
Definition: key.h:180
int ship_engine_ok_to_warp(ship *sp)
Definition: ship.cpp:14783
int flags
Definition: player.h:104
void multi_msg_key_down(int mode)
Definition: multi_pmsg.cpp:89
#define PCM_WARPOUT_STAGE1
Definition: player.h:59
TARGET_NEXT_ESCORT_SHIP.
#define KEY_F10
Definition: key.h:152
int iff_get_attacker_mask(int attackee_team)
Definition: iff_defs.cpp:583
#define KEY_Y
Definition: key.h:106
void mission_log_add_entry(int type, char *pname, char *sname, int info_index)
Definition: missionlog.cpp:184
void debug_cycle_player_ship(int delta)
Definition: keycontrol.cpp:483
#define PROTECT_TARGET_ITEM
Definition: hudsquadmsg.h:41
int Game_mode
Definition: systemvars.cpp:24
#define F1_0
Definition: fix.h:15
void vm_vec_scale_add(vec3d *dest, const vec3d *src1, const vec3d *src2, float k)
Definition: vecmat.cpp:266
#define SIF_PLAYER_SHIP
Definition: ship.h:875
#define KEY_LEFT
Definition: key.h:181
message all friendlies
void hud_squadmsg_rearm_shortcut()
energy transfer success
Definition: gamesnd.h:79
camid Main_camera
Definition: camera.cpp:25
#define KEY_F12
Definition: key.h:154
float frand_range(float min, float max)
Return a floating point number in the range min..max.
Definition: floating.cpp:50
#define MULTI_MSG_FRIENDLY
Definition: multi_pmsg.h:28
polymodel * model_get(int model_num)
Definition: modelread.cpp:3134
int obj_team(object *objp)
Definition: object.cpp:1843
weapon_info Weapon_info[MAX_WEAPON_TYPES]
Definition: weapons.cpp:79
void hud_target_subsystem_in_reticle()
Definition: hudtarget.cpp:2673
ship_weapon weapons
Definition: ship.h:658
TARGET_LAST_TRANMISSION_SENDER.
net_player * Net_player
Definition: multi.cpp:94
SCP_vector< game_snd > Snds
Definition: gamesnd.cpp:19
int Multi_pause_status
Definition: multi_pause.cpp:38
int HUD_color_green
Definition: hud.cpp:74
int wacky_scheme
Definition: neb.cpp:1288
VIEW_EXTERNAL_TOGGLE_CAMERA_LOCK.
void button_info_set(button_info *bi, int n)
decrease shield recharge rate
ZERO_THROTTLE.
float flFrametime
Definition: fredstubs.cpp:22
void send_self_destruct_packet()
Definition: multimsgs.cpp:8629
int escort_priority
Definition: ship.h:541
#define SF2_NO_SUBSPACE_DRIVE
Definition: ship.h:487
vec3d desired_vel
Definition: physics.h:70
GLuint index
Definition: Glext.h:5608
int Weapon_energy_cheat
Definition: hudets.cpp:27
void HUD_init_colors()
Definition: hud.cpp:219
int collide_predict_large_ship(object *objp, float distance)
Definition: objcollide.cpp:967
physics_info phys_info
Definition: object.h:157
player * m_player
Definition: multi.h:459
#define KEY_RIGHT
Definition: key.h:182
#define MAX_SHIPS
Definition: globals.h:37
bool Snapshot_all_events
#define WT_HYPERSPACE
Definition: ship.h:1111
int model_num
Definition: ship.h:1189
#define NUM_COMM_ORDER_ITEMS
Definition: hudsquadmsg.h:36
int next_primary_fire_stamp[MAX_SHIP_PRIMARY_BANKS]
Definition: ship.h:113
void prevent_spawning_collision(object *new_obj)
void increase_recharge_rate(object *obj, SYSTEM_TYPE ship_system)
Definition: hudets.cpp:349
#define KEY_Z
Definition: key.h:107
#define PCM_NORMAL
Definition: player.h:58
int next_secondary_fire_stamp[MAX_SHIP_SECONDARY_BANKS]
Definition: ship.h:115
int gameseq_get_state(void)
Definition: fredstubs.cpp:60
Assert(pm!=NULL)
int target_objnum
Definition: ai.h:339
#define KEY_1
Definition: key.h:72
wingman message: attack current target
#define KEY_F11
Definition: key.h:153
Definition: pstypes.h:88
#define mprintf(args)
Definition: pstypes.h:238
#define FRONT_QUAD
Definition: objectshield.h:16
IGNORE_MESSAGE.
#define NETINFO_FLAG_OBSERVER
Definition: multi.h:605
ship_weapon weapons
Definition: ship.h:362
cycle num primaries to fire at once
int button_function_demo_valid(int n)
w_bank * gun_banks
Definition: model.h:772
void hud_toggle_draw()
Definition: hud.cpp:1270
int Test_begin
Definition: fredstubs.cpp:185
int event_music_next_soundtrack(int delta)
target the closest ship attacking current target
general failure sound for any event
Definition: gamesnd.h:297
void event_music_enable()
#define VM_EXTERNAL
Definition: systemvars.h:31
REARM_MESSAGE.
matrix Eye_matrix
Definition: 3dsetup.cpp:26
int Multi_display_netinfo
Definition: multi.cpp:85
toggle auto-match target speed
#define KEY_E
Definition: key.h:86
#define VM_TRACK
Definition: systemvars.h:32
struct vec3d::@225::@227 xyz
void game_start_time()
Definition: fredstubs.cpp:188
#define KEY_U
Definition: key.h:102
#define SIF2_DYN_PRIMARY_LINKING
Definition: ship.h:933
void transfer_energy_to_weapons(object *obj)
Definition: hudets.cpp:632
void joy_set_cen()
Definition: joy-unix.cpp:544
GLclampf f
Definition: Glext.h:7097
#define KEY_F8
Definition: key.h:150
#define MAX_OBJECTS
Definition: globals.h:83
int button_info_query(button_info *bi, int n)
VIEW_TOPDOWN.
#define SIZE_T_ARG
Definition: clang.h:61
void process_debug_keys(int k)
Definition: keycontrol.cpp:664
#define KEY_F5
Definition: key.h:147
#define TRUE
Definition: pstypes.h:399
#define CAPTURE_TARGET_ITEM
Definition: hudsquadmsg.h:46
int Dead_key_set_size
Definition: keycontrol.cpp:475
void hud_cease_targeting()
Definition: hudtarget.cpp:4367
#define PRIMARY_GOAL
Definition: missiongoals.h:28
#define LGC_B_ADDITIVE
Definition: player.h:71
#define Assertion(expr, msg,...)
Definition: clang.h:41
float factor
Definition: lua.cpp:440
object obj_used_list
Definition: object.cpp:53
#define KEY_V
Definition: key.h:103
void event_music_get_info(char *outbuf)
#define COVER_ME_ITEM
Definition: hudsquadmsg.h:44
int current_primary_bank
Definition: ship.h:106
void set_default_recharge_rates(object *obj)
Definition: hudets.cpp:275
ship_subsys * targeted_subsys
Definition: ai.h:472
int hud_sensors_ok(ship *sp, int show_msg)
Check if targeting is possible based on sensors strength.
Definition: hudtarget.cpp:4578
int ship_find_exited_ship_by_name(char *name)
Definition: ship.cpp:5338
#define KEY_C
Definition: key.h:84
void multi_obs_zoom_to_target()
VIEW_OTHER_SHIP.
#define PLAYER_FLAGS_AUTO_TARGETING
Definition: player.h:38
#define OF_COLLIDES
Definition: object.h:104
factor_table ftables
Definition: keycontrol.cpp:171
uint flags
Definition: ship.h:644
int turret_next_fire_stamp
Definition: ship.h:336
hull_check orient
Definition: lua.cpp:5049
int flags
Definition: multi.h:463
#define VM_EXTERNAL_CAMERA_LOCKED
Definition: systemvars.h:36
toggle network info
int key
void set_fov(float in_fov, float in_fov_time=0.0f, float in_fov_acceleration_time=0.0f, float in_deceleration_time=0.0f)
Definition: camera.cpp:87
target next
object * objp
Definition: lua.cpp:3105
target closest ship that is attacking player
int ship_navigation_ok_to_warp(ship *sp)
Definition: ship.cpp:14809
float lifeleft
Definition: weapon.h:169
#define OBJ_OBSERVER
Definition: object.h:43
int current_secondary_bank
Definition: ship.h:107
GLsizeiptr size
Definition: Glext.h:5496
#define Int3()
Definition: pstypes.h:292
void debug_change_song(int delta)
Definition: keycontrol.cpp:607
void hud_target_hotkey_select(int k)
Definition: hudtarget.cpp:855
#define KEY_MINUS
Definition: key.h:109
void HUD_sourced_printf(int source, const char *format,...)
Definition: hudmessage.cpp:571
ship * shipp
Definition: lua.cpp:9162
vec3d pos
Definition: object.h:152
#define VM_TOPDOWN
Definition: systemvars.h:43
int key_to_ascii(int keycode)
Definition: key.cpp:336
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: Glext.h:7308
ship_subsys_info subsys_info[SUBSYSTEM_MAX]
Definition: ship.h:632
vec3d view_pos
Definition: fredrender.cpp:103
hull_check submodel_num
Definition: lua.cpp:5048
SCP_vector< message_extra > Message_waves
const char * Radar_range_text(int n)
Definition: hudconfig.cpp:102
char callsign[CALLSIGN_LEN+1]
Definition: player.h:91
factor_table(size_t size=6)
Definition: keycontrol.cpp:110
int subobj_num
Definition: model.h:175
VIEW_EXTERNAL.
#define PLAYER_FLAGS_AUTO_MATCH_SPEED
Definition: player.h:39
void hud_target_hotkey_clear(int k)
Definition: hudtarget.cpp:835
#define HUD_COLOR_ALPHA_USER_MAX
Definition: hud.h:70
GLenum type
Definition: Gl.h:1492
void game_increase_skill_level()
Definition: fredstubs.cpp:197
config_item Control_config[]
Stores the keyboard configuration.
#define KEY_I
Definition: key.h:90
void multi_handle_end_mission_request()
Definition: multiutil.cpp:2218
target previous
#define KEY_F7
Definition: key.h:149
match target speed
int iff_get_attackee_mask(int attacker_team)
Definition: iff_defs.cpp:561
transfer shield energy to right
void hud_target_hotkey_add_remove(int k, object *ctarget, int how_to_add)
Definition: hudtarget.cpp:771
int Countermeasures_enabled
Definition: cmeasure.cpp:23
char CheatBuffer[CHEAT_BUFFER_LEN+1]
Definition: keycontrol.cpp:184
stop targeting subsystems on ship
void process_player_ship_keys(int k)
int species
Definition: ship.h:1166
int Num_messages_playing
ship_subsys subsys_list
Definition: ship.h:630
#define KEY_A
Definition: key.h:82
player Players[MAX_PLAYERS]
#define DISARM_TARGET_ITEM
Definition: hudsquadmsg.h:40
message all hostiles
void game_process_keys()
#define IGNORE_TARGET_ITEM
Definition: hudsquadmsg.h:42
SCP_vector< MMessage > Messages
int OO_update_index
Definition: multi_obj.cpp:153
#define SIF_BOMBER
Definition: ship.h:886
void button_info_unset(button_info *bi, int n)
int orders_accepted
Definition: ship.h:624
#define MAX_SHIP_SECONDARY_BANKS
Definition: globals.h:63
#define CHEATS_TABLE_LEN
Definition: keycontrol.cpp:210
int instance
Definition: object.h:150
bool Time_compression_locked
Definition: fredstubs.cpp:225
#define ATTACK_TARGET_ITEM
Definition: hudsquadmsg.h:38
Definition: player.h:85
#define MISSION_FLAG_DEACTIVATE_AP
Definition: missionparse.h:90
int Debug_octant
Definition: fredstubs.cpp:186
#define KEY_9
Definition: key.h:80
struct matrix::@228::@230 vec
#define NETINFO_FLAG_AM_MASTER
Definition: multi.h:599
#define HUD_COLOR_ALPHA_USER_MIN
Definition: hud.h:71
#define ENGAGE_ENEMY_ITEM
Definition: hudsquadmsg.h:45
#define LOG_SHIP_DISABLED
Definition: missionlog.h:29
int subtype
Definition: lua.cpp:9763
float ship_max_hull_strength
Definition: ship.h:597
message targeted ship (if player)
#define HOTKEY_USER_ADDED
Definition: hudtarget.h:43
void event_music_get_soundtrack_name(char *outbuf)
#define nprintf(args)
Definition: pstypes.h:239
#define GM_MULTIPLAYER
Definition: systemvars.h:18
int Ignored_keys[CCFG_MAX]
Definition: keycontrol.cpp:471
float cargo_size
Definition: weapon.h:388
wingman message: cover me
int primary_bank_ammo[MAX_SHIP_PRIMARY_BANKS]
Definition: ship.h:121
void snd_stop_any_sound()
Definition: sound.cpp:1213
int lua_game_control
int Cheats_enabled
Definition: key.cpp:100
toggle between high and low HUD contrast
int flags
Definition: ship.h:1227
void g3_set_view_matrix(const vec3d *view_pos, const matrix *view_matrix, float zoom)
Definition: 3dsetup.cpp:152
increase shield recharge rate
void message_kill_all(int kill_all)
bool object_get_gliding(object *objp)
Definition: object.cpp:2059
int ship_get_sound(object *objp, GameSoundsIndex id)
Returns a ship-specific sound index.
Definition: ship.cpp:18614
int num_secondary_banks
Definition: ship.h:100
#define NUM_BUTTON_FIELDS
Definition: keycontrol.h:18
#define OBJ_WEAPON
Definition: object.h:33
#define KEY_SHIFTED
Definition: key.h:62
void process_set_of_keys(int key, int count, int *list)
int Non_critical_key_set[]
Definition: keycontrol.cpp:399
#define WP_LASER
Definition: weapon.h:27
void hud_target_targets_target()
Definition: hudtarget.cpp:2388
#define KEY_W
Definition: key.h:104
sprintf(buf,"(%f,%f,%f)", v3->xyz.x, v3->xyz.y, v3->xyz.z)
void toggle_player_object()
int Cmdline_autopilot_interruptable
Definition: cmdline.cpp:381
cheatCode code
Definition: keycontrol.cpp:197
decrease energy to engines
int hud_target_closest(int team_mask, int attacked_objnum, int play_fail_snd, int filter, int get_closest_turret_attacking_player)
Sets the Players[Player_num].current_target to the closest ship to the player that matches the team p...
Definition: hudtarget.cpp:2212
int Message_debug_index
#define SUBSYSTEM_TURRET
Definition: model.h:54
equalize recharge rates
#define KEY_N
Definition: key.h:95
int Dead_key_set[]
Definition: keycontrol.cpp:336
#define HUD_SOURCE_HIDDEN
Definition: hudmessage.h:23
wingman message: disarm current target
#define KEY_J
Definition: key.h:91
#define KEY_PAUSE
Definition: key.h:185
void hud_target_last_transmit()
Definition: hudtarget.cpp:5127
int snd_play(game_snd *gs, float pan, float vol_scale, int priority, bool is_voice_msg)
Definition: sound.cpp:517
TARGET_PREV_LIVE_TURRET.
button_info lua_bi_full
Definition: player.h:212
int secondary_bank_weapons[MAX_SHIP_SECONDARY_BANKS]
Definition: ship.h:104
TARGET_PREV_SUBOBJECT.
void button_info_clear(button_info *bi)
void game_stop_looped_sounds()
Definition: fredstubs.cpp:168
#define DISABLE_TARGET_ITEM
Definition: hudsquadmsg.h:39
#define MAX_PLAYERS
Definition: pstypes.h:32
float aggregate_current_hits
Definition: ship.h:419
wingman message: form on my wing
stop targeting ship
void debug_max_secondary_weapons(object *objp)
Definition: keycontrol.cpp:568
#define KEY_R
Definition: key.h:99
#define RR_MAX_RANGES
Definition: hudconfig.h:28
bool Perspective_locked
Definition: keycontrol.cpp:213
int flags2
Definition: ship.h:1228
#define RIGHT_QUAD
Definition: objectshield.h:19
target next subsystem on current target
int secondary_bank_ammo_capacity[MAX_SHIP_SECONDARY_BANKS]
Definition: ship.h:1300
Definition: ship.h:534
cycle number of missiles fired from secondary bank
#define KEY_DEBUG_KEY
Definition: key.h:69
VIEW_SLEW.
#define SIF_BALLISTIC_PRIMARIES
Definition: ship.h:880
void control_used(int id)
ADD_REMOVE_ESCORT.
ONE_THIRD_THROTTLE.
int num_slots
Definition: model.h:433
void hud_target_uninspected_object(int next_flag)
Definition: hudtarget.cpp:4977
#define NETPLAYER_IS_DEAD(player)
Definition: multi.h:627
int Show_cpu
Definition: fred.cpp:52
#define delta
Definition: fvi.cpp:418
void hud_target_live_turret(int next_flag, int auto_advance, int only_player_target)
Definition: hudtarget.cpp:1724
int idx
Definition: multiui.cpp:761
bool AutoPilotEngaged
Definition: autopilot.cpp:40
int secondary_bank_ammo[MAX_SHIP_SECONDARY_BANKS]
Definition: ship.h:134
#define KEY_P
Definition: key.h:97
cycle secondary weapon
Definition: gamesnd.h:71
#define KEY_T
Definition: key.h:101
int primary_bank_ammo_capacity[MAX_SHIP_PRIMARY_BANKS]
Definition: ship.h:1296
void hud_target_next_list(int hostile, int next_flag, int team_mask, int attacked_objnum, int play_fail_snd, int filter, int get_closest_turret_attacking_player)
Definition: hudtarget.cpp:4637
cycle to previous primary weapon
target ship closest to center of reticle
target the closest friendly ship
#define SF_DISABLED
Definition: ship.h:448
void debug_max_primary_weapons(object *objp)
Definition: keycontrol.cpp:581
int button_function(int n)
int ship_select_next_primary(object *objp, int direction)
Definition: ship.cpp:12317
char name[NAME_LENGTH]
Definition: ship.h:1163
int main_hall_is_vasudan()
object Objects[MAX_OBJECTS]
Definition: object.cpp:62
TIME_SLOW_DOWN.
void shipfx_warpin_start(object *objp)
Definition: shipfx.cpp:565
#define KEY_PADMINUS
Definition: key.h:166
transfer energy to shield from weapons
GLclampd n
Definition: Glext.h:7286
#define MISS_SHIELDS
Definition: shiphit.h:23
cycle to next secondary weapon
#define MULTI_MSG_ALL
Definition: multi_pmsg.h:27
int ship_create(matrix *orient, vec3d *pos, int ship_type, char *ship_name)
Definition: ship.cpp:9690
const char * XSTR(const char *str, int index)
Definition: localize.cpp:851
#define KEY_F6
Definition: key.h:148
#define GM_DEAD
Definition: systemvars.h:25
int objnum
Definition: player.h:124
#define OBJ_INDEX(objp)
Definition: object.h:235
target fail sound (i.e. press targeting key, but nothing happens)
Definition: gamesnd.h:96
#define KEY_O
Definition: key.h:96
#define SECONDARY_GOAL
Definition: missiongoals.h:29
user_click (mouse selects a control)
Definition: gamesnd.h:305
ship * Player_ship
Definition: ship.cpp:124
void hud_target_newest_ship()
Definition: hudtarget.cpp:1619
#define GM_IN_MISSION
Definition: systemvars.h:23
#define MULTI_MSG_HOSTILE
Definition: multi_pmsg.h:29
int AI_watch_object
Definition: aicode.cpp:199
matrix orient
Definition: object.h:153
int ship_guardian_threshold
Definition: ship.h:601
int wi_flags2
Definition: weapon.h:385
#define NOX(s)
Definition: pstypes.h:473
target the closest repair ship
int is_support_allowed(object *objp, bool do_simple_check)
Definition: ship.cpp:16749
void vm_vec_copy_scale(vec3d *dest, const vec3d *src, float s)
Definition: vecmat.cpp:257
int mission_hotkey_get_set_num(int k)
#define OBJ_SHIP
Definition: object.h:32
int hud_squadmsg_read_key(int k)
TARGET_NEXT_LIVE_TURRET.
angles chase_slew_angles
wingman message: engage enemy
#define MAX_TIME_MULTIPLIER
Definition: keycontrol.cpp:180
void hud_target_in_reticle_new()
Definition: hudtarget.cpp:2483
GLbitfield flags
Definition: Glext.h:6722
void vm_vec_rand_vec_quick(vec3d *rvec)
Definition: vecmat.cpp:1379
void hud_squadmsg_shortcut(int command)
int Num_weapon_types
Definition: weapons.cpp:105
#define HUD_AUTO_TARGET
Definition: hudgauges.h:32
if i'm an observer, zoom to my targeted object
bool StartAutopilot()
Definition: autopilot.cpp:230
int control_mode
Definition: player.h:134
GLuint const GLchar * name
Definition: Glext.h:5608
int hud_target_closest_repair_ship(int goal_objnum)
Definition: hudtarget.cpp:4858
#define KEY_COMMA
Definition: key.h:114
void hud_target_asteroid()
Definition: asteroid.cpp:1441
#define KEY_Q
Definition: key.h:98
int Num_builtin_messages
void fishtank_start()
Definition: fishtank.cpp:143
#define KEY_H
Definition: key.h:89
void multi_server_update_player_weapons(net_player *pl, ship *shipp)
Definition: multiutil.cpp:2737
int Game_detail_level
Definition: systemvars.cpp:51
void button_info_do(button_info *bi)
#define CYCLE_PRIMARY_NEXT
Definition: ship.h:62
#define SUBSYSTEM_ENGINE
Definition: model.h:53
vec3d vel
Definition: physics.h:77
void game_process_pause_key()
transfer energy to weapons from shield
void supernova_start(int seconds)
Definition: supernova.cpp:67
Definition: hudets.h:45
vec3d Eye_position
Definition: 3dsetup.cpp:27
char * data
Definition: keycontrol.cpp:198
int multi_quit_game(int prompt, int notify_code, int err_code, int wsa_error)
ship Ships[MAX_SHIPS]
Definition: ship.cpp:122
#define MAX_PATTERNS
Definition: eventmusic.h:37
wingman message: protect current target
#define MESSAGE_PRIORITY_HIGH
equalize shield energy to all quadrants
cheatCode
Definition: keycontrol.cpp:186
void player_match_target_speed(char *no_target_text=NULL, char *match_off_text=NULL, char *match_on_text=NULL)
if(aifft_max_checks<=0)
Definition: aiturret.cpp:1581
void hud_target_prev_subobject()
Definition: hudtarget.cpp:1142
typedef float(SCP_EXT_CALLCONV *SCPTRACKIR_PFFLOATVOID)()
TOGGLE_HUD.
void weapons_page_in_cheats()
Definition: weapons.cpp:6650
TARGET_NEWEST_SHIP.
#define KEY_EQUAL
Definition: key.h:110
NAV_CYCLE.
int ai_issue_rearm_request(object *requester_objp)
Definition: aicode.cpp:15446
int Non_critical_key_set_size
Definition: keycontrol.cpp:477
HUD_TARGETBOX_TOGGLE_WIREFRAME.
bool Sel_NextNav()
Definition: autopilot.cpp:75
object * asteroid_create(asteroid_field *asfieldp, int asteroid_type, int asteroid_subtype)
Definition: asteroid.cpp:231
void transfer_energy_to_shields(object *obj)
Definition: hudets.cpp:614
#define SF2_NO_ETS
Definition: ship.h:503
#define KEY_ESC
Definition: key.h:124
#define NAME_LENGTH
Definition: globals.h:15
#define SF_SECONDARY_DUAL_FIRE
Definition: ship.h:459
#define LEFT_QUAD
Definition: objectshield.h:18
#define WP_MISSILE
Definition: weapon.h:28
TARGET_PREV_BOMB.
int game_poll()
Definition: fredstubs.cpp:70
#define KEY_ALTED
Definition: key.h:63
target ships subsystem in reticle
#define KEY_DEBUGGED1
Definition: key.h:66
#define fl2i(fl)
Definition: floating.h:33
#define MULTI_CONNECTED(np)
Definition: multi.h:136
int HUD_color_red
Definition: hud.cpp:73
player * Player
ESCORT_CLEAR.
bool quit_mission_popup_shown
Definition: keycontrol.cpp:214
void hud_target_next(int team_mask)
Definition: hudtarget.cpp:1247
end the mission
TARGET_NEXT_BOMB.
int last_fired_point[MAX_SHIP_PRIMARY_BANKS]
Definition: ship.h:771
#define HUD_WEAPONS_GAUGE
Definition: hudgauges.h:34
Autopilot key control.
TWO_THIRDS_THROTTLE.
class camera * getCamera()
Definition: camera.cpp:833
#define DEPART_ITEM
Definition: hudsquadmsg.h:56
int hud_squadmsg_hotkey_select(int k)
#define CHEAT_BUFFER_LEN
Definition: keycontrol.cpp:183
int Num_messages
#define CREATE_SPARKS
Definition: shiphit.h:21
void mission_goal_mark_all_true(int type)
TIME_SPEED_UP.
#define GM_DEAD_BLEW_UP
Definition: systemvars.h:21
int status[NUM_BUTTON_FIELDS]
Definition: keycontrol.h:30
void main_hall_vasudan_funny()
cycle to next primary weapon
void hud_escort_target_next()
Definition: hudescort.cpp:1006
long Game_time_compression
Definition: fredstubs.cpp:202
int get_prev_weapon_looped(int current_weapon, int subtype)
Definition: keycontrol.cpp:630
int ship_info_index
Definition: ship.h:539
#define KEY_DEBUGGED
Definition: key.h:65
GLfloat GLfloat p
Definition: Glext.h:8373
#define MULTIPLAYER_MASTER
Definition: multi.h:130
HUD_CONFIG_TYPE HUD_config
Definition: hudconfig.cpp:49
void message_send_unique_to_player(char *id, void *data, int m_source, int priority, int group, int delay)
#define _strlwr(s)
Definition: config.h:274
ubyte keyd_pressed[NUM_KEYS]
Definition: key.cpp:42
void hud_augment_shield_quadrant(object *objp, int direction)
Definition: hudshield.cpp:278
SCP_vector< ship_info > Ship_info
Definition: ship.cpp:164
#define SIF_TRANSPORT
Definition: ship.h:890
void debug_cycle_targeted_ship(int delta)
Definition: keycontrol.cpp:519
decrease weapon recharge rate
#define SIF_FIGHTER
Definition: ship.h:885
const char * Skill_level_names(int skill_level, int translate=1)
Definition: aicode.cpp:208
The total number of defined control actions (or last define + 1)
void ship_apply_local_damage(object *ship_objp, object *other_obj, vec3d *hitpos, float damage, int quadrant, bool create_spark, int submodel_num, vec3d *hit_normal)
Definition: shiphit.cpp:2359
int Viewer_mode
Definition: systemvars.cpp:28
void gamesnd_play_error_beep()
Definition: gamesnd.cpp:1159
toggle auto-targeting
message all netplayers
#define timestamp_elapsed(stamp)
Definition: timer.h:102
SCP_vector< species_info > Species_info
MINUS_5_PERCENT_THROTTLE.
void hud_target_toggle_hidden_from_sensors()
Definition: hudtarget.cpp:4920
vec3d * get_subsystem_world_pos(object *parent_obj, ship_subsys *subsys, vec3d *world_pos)
Definition: hudtarget.cpp:4395
show the mission goals screen
hull_check pos
Definition: lua.cpp:5050
void button_strip_noncritical_keys(button_info *bi)
#define MISSION_FLAG_2D_MISSION
Definition: missionparse.h:82
#define PROMPT_ALL
Definition: multi_endgame.h:29
int Game_skill_level
Definition: fredstubs.cpp:170
transfer shield energy to left
int check_control(int id, int key)
#define MULTI_MSG_TARGET
Definition: multi_pmsg.h:30
float get_fov()
Definition: camera.cpp:284
target the next friendly ship
#define MAX_TIME_DIVIDER
Definition: keycontrol.cpp:181
#define KEY_CTRLED
Definition: key.h:64
int tst
Definition: fredstubs.cpp:213
wingman message: capture current target
VIEW_CHASE.
void change_ship_type(int n, int ship_type, int by_sexp)
Definition: ship.cpp:9983
target the previous closest hostile
#define PCM_SUPERNOVA
Definition: player.h:62
TARGET_PREV_UNINSPECTED_CARGO.
wingman message: disable current target
void hud_target_next_subobject()
Definition: hudtarget.cpp:1147
LAUNCH_COUNTERMEASURE.
bool key_is_targeting(int n)
GLint GLsizei count
Definition: Gl.h:1491
#define LGC_B_POLL_ALL
Definition: player.h:73
#define KEY_UP
Definition: key.h:179
float do_subobj_hit_stuff(object *ship_obj, object *other_obj, vec3d *hitpos, int submodel_num, float damage, bool *hull_should_apply_armor)
Definition: shiphit.cpp:447
void EndAutoPilot()
Definition: autopilot.cpp:869
void main_hall_campaign_cheat()
button_info lua_bi
Definition: player.h:211
void ship_self_destruct(object *objp)
Definition: shiphit.cpp:1697
object * Player_obj
Definition: object.cpp:56
#define SF_ESCORT
Definition: ship.h:438
self destruct (multiplayer only)
wingman message: warp out
void hud_target_missile(object *source_obj, int next_flag)
Definition: hudtarget.cpp:1425
uint flags2
Definition: ship.h:645
void hud_escort_clear_all(bool clear_flags)
Definition: hudescort.cpp:482
#define SF_DYING
Definition: ship.h:447
int temp
Definition: lua.cpp:4996
cycle to next radar range
VIEW_TRACK_TARGET.
#define WIF2_BALLISTIC
Definition: weapon.h:84
polymodel * pm
Definition: lua.cpp:1598
#define KEY_G
Definition: key.h:88
w_bank * missile_banks
Definition: model.h:773
int event_music_return_current_pattern()
Definition: camera.h:18
void HUD_printf(const char *format,...)
Definition: hudmessage.cpp:527
#define VM_OTHER_SHIP
Definition: systemvars.h:35
int Critical_key_set[]
Definition: keycontrol.cpp:378
#define SF2_PRIMITIVE_SENSORS
Definition: ship.h:483
asteroid_field Asteroid_field
Definition: asteroid.cpp:64
#define DISABLE_SUBSYSTEM_ITEM
Definition: hudsquadmsg.h:59
int ship_name_lookup(const char *name, int inc_players)
Definition: ship.cpp:12900
#define GM_NORMAL
Definition: systemvars.h:19
int get_next_weapon_looped(int current_weapon, int subtype)
Definition: keycontrol.cpp:647
uint flags
Definition: object.h:151
float radius
Definition: object.h:154
MAX_THROTTLE.
#define KEY_X
Definition: key.h:105
#define KEY_M
Definition: key.h:94
int Normal_key_set_size
Definition: keycontrol.cpp:474
void gamesnd_play_iface(int n)
Definition: gamesnd.cpp:260
#define FORMATION_ITEM
Definition: hudsquadmsg.h:43
mission The_mission
int ship_select_next_secondary(object *objp)
Definition: ship.cpp:12550
#define MESSAGE_SOURCE_SPECIAL
#define VM_CHASE
Definition: systemvars.h:34
void hud_targetbox_switch_wireframe_mode()
size_t getNext(size_t n, size_t current)
Definition: keycontrol.cpp:117
void hud_cease_subsystem_targeting(int print_message)
Definition: hudtarget.cpp:4346
void game_do_end_mission_popup()
wingman message: disable current target
float h
Definition: pstypes.h:111
shield quadrant transfer successful
Definition: gamesnd.h:111
#define KEY_PERIOD
Definition: key.h:115
char type
Definition: object.h:146
int Event_music_enabled
Definition: eventmusic.cpp:237
void event_music_change_pattern(int new_pattern)
void game_stop_time()
Definition: fredstubs.cpp:189
#define KEY_S
Definition: key.h:100
int button_function_critical(int n, net_player *p=NULL)
#define HUD_AUTO_SPEED
Definition: hudgauges.h:33
#define LGC_B_OVERRIDE
Definition: player.h:70
#define FALSE
Definition: pstypes.h:400
#define KEY_2
Definition: key.h:73
increase weapon recharge rate
net_player Net_players[MAX_PLAYERS]
Definition: multi.cpp:93
#define KEY_PADPLUS
Definition: key.h:167
void gameseq_post_event(int event)
TARGET_NEXT_UNINSPECTED_CARGO.
#define PLAYER_FLAGS_MSG_MODE
Definition: player.h:37
#define KEY_D
Definition: key.h:85
transfer shield energy to rear
button_info bi
Definition: player.h:125
void hud_add_remove_ship_escort(int objnum, int supress_feedback)
Definition: hudescort.cpp:917
int primary_bank_slot_count[MAX_SHIP_PRIMARY_BANKS]
Definition: ship.h:131
void hud_squadmsg_toggle()
void change_time_compression(float multiplier)
Definition: fredstubs.cpp:228
bool Lock_targetbox_mode
#define LOG_SHIP_DISARMED
Definition: missionlog.h:30
target the next hostile target
char ship_name[NAME_LENGTH]
Definition: ship.h:604
Definition: hudets.h:45
void game_process_cheats(int k)
transfer shield energy to front
void event_music_disable()
void multi_pause_request(int pause)
#define HUD_ETS_GAUGE
Definition: hudgauges.h:31
Definition: hudets.h:45
#define SW_FLAG_BEAM_FREE
Definition: ship.h:94
#define KEY_F9
Definition: key.h:151
PLUS_5_PERCENT_THROTTLE.
#define KEY_F
Definition: key.h:87
int Player_num
#define strcpy_s(...)
Definition: safe_strings.h:67
#define KEY_3
Definition: key.h:74
#define REAR_QUAD
Definition: objectshield.h:17
void hud_toggle_contrast()
Definition: hud.cpp:3682
int HUD_color_blue
Definition: hud.cpp:75