Author Topic: Multiplayer Key-Pressed (or equivalent) and increased TOKEN_LENGTH Test Build  (Read 5434 times)

0 Members and 1 Guest are viewing this topic.

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Multiplayer Key-Pressed (or equivalent) and increased TOKEN_LENGTH Test Build
Okay, two things in these builds.

1) 3 new SEXPs, player-input-delay, reset-input, and ignore-input. These SEXPs are roughly equivalent to the key-pressed, key-reset-multiple, and ignore-key SEXPs with two differences
 a) They work in multiplayer
 b) They work based on the name of the command i.e "Target next hostile" rather than the key.

2) Due to the fact that some of those command names are more than 32 characters in length, I've had to bump the value of TOKEN_LENGTH. This controls how long a string can be in many places in FRED and thus can cause a lot of potential bugs. I've bumped it from 32 to 64. I really need people to test and see if they can find them. If no one tests and only complains once the code hits trunk, I won't be as sympathetic about hunting down their bugs. :p

I know that FRED could load Diaspora M6 with these builds so if there are problems, hopefully they are minor.


The builds are based on my Diaspora source folder so ignore the interesting name choice and Diaspora FRED icons. :)

[attachment removed and sold on the black market]
« Last Edit: September 22, 2012, 05:26:27 am by karajorma »
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline Lester

  • 27
Multiplayer Key-Pressed (or equivalent) and increased TOKEN_LENGTH Test Build
i love you i love you i love you i love you i love you i love you i love you i love you i love you i love you i love you i love you i love you i love you




seriously this and this really makes me feel like erecting you a 10-metre statue out of platinum at a famous landmark picked by you

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
Re: Multiplayer Key-Pressed (or equivalent) and increased TOKEN_LENGTH Test Build
Anyone else preemptively cringe upon reading the word 'erecting' just now?
Fate of the Galaxy - Now Hiring!  Apply within | Diaspora | SCP Home | Collada Importer for PCS2
Karajorma's 'How to report bugs' | Mantis
#freespace | #scp-swc | #diaspora | #SCP | #hard-light on EsperNet

"You may not sell or otherwise commercially exploit the source or things you created based on the source." -- Excerpt from FSO license, for reference

Nuclear1:  Jesus Christ zack you're a little too hamyurger for HLP right now...
iamzack:  i dont have hamynerge i just want ptatoc hips D:
redsniper:  Platonic hips?!
iamzack:  lays

 

Offline MatthTheGeek

  • Captain Obvious
  • 212
  • Frenchie McFrenchface
Re: Multiplayer Key-Pressed (or equivalent) and increased TOKEN_LENGTH Test Build
Is it OUR fault if you have a dirty mind ? :p
People are stupid, therefore anything popular is at best suspicious.

Mod management tools     -     Wiki stuff!     -     Help us help you

666maslo666: Releasing a finished product is not a good thing! It is a modern fad.

SpardaSon21: it seems like you exist in a permanent state of half-joking misanthropy

Axem: when you put it like that, i sound like an insane person

bigchunk1: it's not retarded it's american!
bigchunk1: ...

batwota: steele's maneuvering for the coup de gras
MatthTheGeek: you mispelled grâce
Awaesaar: grace
batwota: oh right :P
Darius: ah!
Darius: yes, i like that
MatthTheGeek: the way you just spelled it it means fat
Awaesaar: +accent I forgot how to keyboard
MatthTheGeek: or grease
Darius: the killing fat!
Axem: jabba does the coup de gras
MatthTheGeek: XD
Axem: bring me solo and a cookie

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Multiplayer Key-Pressed (or equivalent) and increased TOKEN_LENGTH Test Build
I figured that sooner or later the multi team would realise that this was a cool development. :)
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline KyadCK

  • 29
  • Getting better with every game
    • Minecraft
    • Steam
Re: Multiplayer Key-Pressed (or equivalent) and increased TOKEN_LENGTH Test Build
I figured that sooner or later the multi team would realise that this was a cool development. :)

I don't check the test builds section as often as I used to.  :(

Hell, I even used to read the changelog every time a new nightly came out hoping for something that would help improve the performance of BPmulti. I actually feel slightly bad that I didn't even notice something this important until it was brought up in IRC.  :p



So, when's this hit trunk so we can use it with people? or do we have to wait for .15?
Freespace Wallpapers     BluePlanet Multi     Minecraft Deimos Build Log
Need help setting up Multi? Then join us on the Multi-Setup IRC channel!
Computers only fear those who know how to use them

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Multiplayer Key-Pressed (or equivalent) and increased TOKEN_LENGTH Test Build
I'll put this in trunk as soon as it gets some more testing. Changing TOKEN_LENGTH is a pretty big change. I need to know it doesn't break anything before I commit it.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Re: Multiplayer Key-Pressed (or equivalent) and increased TOKEN_LENGTH Test Build
Have you checked pilot and campaign file loading and saving?

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Multiplayer Key-Pressed (or equivalent) and increased TOKEN_LENGTH Test Build
I haven't checked it beyond loading in a couple of missions. Anything you particularly suggest trying?
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Re: Multiplayer Key-Pressed (or equivalent) and increased TOKEN_LENGTH Test Build
Playing a campaign for two or three missions, then exiting the game, then restarting and playing for another two or three missions.  That should exercise the files pretty effectively, methinks.

 

Offline niffiwan

  • 211
  • Eluder Class
Re: Multiplayer Key-Pressed (or equivalent) and increased TOKEN_LENGTH Test Build
what about checking a red-alert mission pair, exiting the game between the two missions?
Creating a fs2_open.log | Red Alert Bug = Hex Edit | MediaVPs 2014: Bigger HUD gauges | 32bit libs for 64bit Ubuntu
----
Debian Packages (testing/unstable): Freespace2 | wxLauncher
----
m|m: I think I'm suffering from Stockholm syndrome. Bmpman is starting to make sense and it's actually written reasonably well...

 

Offline Talon 1024

  • 29
  • How do you turn this on?
    • Mods, Games, and Stuff
Re: Multiplayer Key-Pressed (or equivalent) and increased TOKEN_LENGTH Test Build
Does this also mean I can have more than 32 characters in cutscene subtitles and/or directives and directive keypress texts?
To understand religion, you need to understand morality first. | WCSaga website | WCSaga Forum | 158th website | 158th forum | Project Leader: WC: Hostile Frontier | WCHF Thread at CIC | Wing Blender | Twist of Fate | Multipart turrets on angled surfaces, tutorial included. | My Google Drive stuff | To convert speeds from WC to WCS, multiply both the cruise speed and the Afterburner speed by 0.15625 (5/32)

FS2 Mods I'm waiting on: Inferno 10th Anniversary
Current Project: Contestant Android app, Learn4Life iOS app, Blender Commander (importer).
The FreeSpace Font Foundry is back in action!

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Multiplayer Key-Pressed (or equivalent) and increased TOKEN_LENGTH Test Build
No idea. Try it. :)
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline Talon 1024

  • 29
  • How do you turn this on?
    • Mods, Games, and Stuff
Re: Multiplayer Key-Pressed (or equivalent) and increased TOKEN_LENGTH Test Build
I played around with this build a little bit...

I played the first few missions of BP:AoA, following Goober's suggestion, and it seems to work just fine.

Also, I edited a mission with notepad to have directive texts longer than 32 characters.  I could load the mission using this build, but it doesn't display more than 32 characters on the directives gauge.
To understand religion, you need to understand morality first. | WCSaga website | WCSaga Forum | 158th website | 158th forum | Project Leader: WC: Hostile Frontier | WCHF Thread at CIC | Wing Blender | Twist of Fate | Multipart turrets on angled surfaces, tutorial included. | My Google Drive stuff | To convert speeds from WC to WCS, multiply both the cruise speed and the Afterburner speed by 0.15625 (5/32)

FS2 Mods I'm waiting on: Inferno 10th Anniversary
Current Project: Contestant Android app, Learn4Life iOS app, Blender Commander (importer).
The FreeSpace Font Foundry is back in action!

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Multiplayer Key-Pressed (or equivalent) and increased TOKEN_LENGTH Test Build
I suspect that uses a different limit than TOKEN_LENGTH (or at least did) which happens to also be 32 characters. It's this sort of issue that makes bumping TOKEN_LENGTH such a problem.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
Re: Multiplayer Key-Pressed (or equivalent) and increased TOKEN_LENGTH Test Build
Well, he had to manually bump that string in notepad, so if it can't be bumped higher than 32 in FRED yet, it's probably ok wouldn't you think?
Fate of the Galaxy - Now Hiring!  Apply within | Diaspora | SCP Home | Collada Importer for PCS2
Karajorma's 'How to report bugs' | Mantis
#freespace | #scp-swc | #diaspora | #SCP | #hard-light on EsperNet

"You may not sell or otherwise commercially exploit the source or things you created based on the source." -- Excerpt from FSO license, for reference

Nuclear1:  Jesus Christ zack you're a little too hamyurger for HLP right now...
iamzack:  i dont have hamynerge i just want ptatoc hips D:
redsniper:  Platonic hips?!
iamzack:  lays

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Multiplayer Key-Pressed (or equivalent) and increased TOKEN_LENGTH Test Build
In this case yes, but there is a general issue of 32+ character strings being put into smaller character arrays.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Multiplayer Key-Pressed (or equivalent) and increased TOKEN_LENGTH Test Build
:bump:

Niffiwan asked for a look at the code for this, and since it's probably a good idea to make sure that it exists in more places than my local PCs.

Code: [Select]
Index: code/controlconfig/controlsconfig.cpp
===================================================================
--- code/controlconfig/controlsconfig.cpp (revision 9214)
+++ code/controlconfig/controlsconfig.cpp (working copy)
@@ -22,6 +22,7 @@
 #include "missionui/missionscreencommon.h"
 #include "graphics/font.h"
 #include "playerman/managepilot.h"
+#include "playerman/player.h"
 #include "gamehelp/contexthelp.h"
 #include "popup/popup.h"
 #include "ui/uidefs.h"
@@ -2271,6 +2272,7 @@
 
  for (i=0; i<CCFG_MAX; i++) {
  Control_config[i].used = 0;
+ Player->inputs_used[i] = 0;
  }
 }
 
Index: code/controlconfig/controlsconfig.h
===================================================================
--- code/controlconfig/controlsconfig.h (revision 9214)
+++ code/controlconfig/controlsconfig.h (working copy)
@@ -240,6 +240,7 @@
 
 void control_config_reset_defaults();
 int translate_key_to_index(char *key);
+int translate_input_to_index(char *input_name);
 char *translate_key(char *key);
 char *textify_scancode(int code);
 float check_control_timef(int id);
@@ -251,4 +252,6 @@
 void control_check_indicate();
 void control_config_clear_used_status();
 
+void controls_send_to_server();
+
 #endif
Index: code/controlconfig/controlsconfigcommon.cpp
===================================================================
--- code/controlconfig/controlsconfigcommon.cpp (revision 9214)
+++ code/controlconfig/controlsconfigcommon.cpp (working copy)
@@ -15,7 +15,10 @@
 #include "io/key.h"
 #include "io/joy.h"
 #include "localization/localize.h"
+#include "network/multi.h"
+#include "network/multimsgs.h"
 #include "parse/parselo.h"
+#include "playerman/player.h"
 #include "globalincs/systemvars.h"
 #include "globalincs/def_files.h"
 
@@ -372,6 +375,19 @@
  }
 }
 
+int translate_input_to_index(char *input_name)
+{
+ int i;
+
+ for (i=0; i<CCFG_MAX; i++) {
+ if (!stricmp(Control_config[i].text, input_name)) {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
 int translate_key_to_index(char *key)
 {
  int i, index = -1, alt = 0, shift = 0, max_scan_codes;
@@ -785,3 +801,18 @@
     ADD_ENUM_TO_ENUM_MAP(WEAPON_TAB)
     ADD_ENUM_TO_ENUM_MAP(COMPUTER_TAB)
 }
+
+void controls_send_to_server() {
+ ushort i;
+
+ if (!MULTIPLAYER_CLIENT) {
+ return;
+ }
+
+ for (i = 0; i < CCFG_MAX; i++) {
+ if (Control_config[i].used && !Player->inputs_used[i]) {
+ send_input_packet(i);
+ break;
+ }
+ }
+}
\ No newline at end of file
Index: code/fred2/sexp_tree.cpp
===================================================================
--- code/fred2/sexp_tree.cpp (revision 9214)
+++ code/fred2/sexp_tree.cpp (working copy)
@@ -2596,6 +2596,7 @@
  case OPF_DOCKEE_POINT:
  case OPF_AI_GOAL:
  case OPF_KEYPRESS:
+ case OPF_PLAYER_INPUT:
  case OPF_AI_ORDER:
  case OPF_SKILL_LEVEL:
  case OPF_MEDAL_NAME:
@@ -4221,6 +4222,10 @@
  list = get_listing_opf_keypress();
  break;
 
+ case OPF_PLAYER_INPUT:
+ list = get_listing_opf_player_input();
+ break;
+
  case OPF_EVENT_NAME:
  list = get_listing_opf_event_name(parent_node);
  break;
@@ -5484,6 +5489,18 @@
  return head.next;
 }
 
+sexp_list_item *sexp_tree::get_listing_opf_player_input()
+{
+ int i;
+ sexp_list_item head;
+
+ for (i=0; i<CCFG_MAX; i++) {
+ head.add_data_dup(Control_config[i].text);
+ }
+
+ return head.next;
+}
+
 sexp_list_item *sexp_tree::get_listing_opf_event_name(int parent_node)
 {
  int i, m;
Index: code/fred2/sexp_tree.h
===================================================================
--- code/fred2/sexp_tree.h (revision 9214)
+++ code/fred2/sexp_tree.h (working copy)
@@ -219,6 +219,7 @@
  sexp_list_item *get_listing_opf_order_recipient();
  sexp_list_item *get_listing_opf_ship_type();
  sexp_list_item *get_listing_opf_keypress();
+ sexp_list_item *get_listing_opf_player_input();
  sexp_list_item *get_listing_opf_event_name(int parent_node);
  sexp_list_item *get_listing_opf_ai_order();
  sexp_list_item *get_listing_opf_skill_level();
Index: code/freespace2/freespace.cpp
===================================================================
--- code/freespace2/freespace.cpp (revision 9214)
+++ code/freespace2/freespace.cpp (working copy)
@@ -30,6 +30,7 @@
 #include "cfile/cfile.h"
 #include "cmdline/cmdline.h"
 #include "cmeasure/cmeasure.h"
+#include "controlconfig/controlsconfig.h"
 #include "cutscene/cutscenes.h"
 #include "cutscene/movie.h"
 #include "debris/debris.h"
@@ -4013,7 +4014,7 @@
  // move all objects - does interpolation now as well
  obj_move_all(flFrametime);
 
-
+ controls_send_to_server();
  }
 
  // only process the message queue when the player is "in" the game
Index: code/mission/missionparse.h
===================================================================
--- code/mission/missionparse.h (revision 9214)
+++ code/mission/missionparse.h (working copy)
@@ -648,7 +648,7 @@
 #define MAX_P_WINGS 16
 #define MAX_SHIP_LIST 16
 
-#define TOKEN_LENGTH 32
+#define TOKEN_LENGTH 64
 
 extern team_data Team_data[MAX_TVT_TEAMS];
 extern subsys_status *Subsys_status;
Index: code/network/multi.cpp
===================================================================
--- code/network/multi.cpp (revision 9214)
+++ code/network/multi.cpp (working copy)
@@ -926,6 +926,10 @@
  process_sexp_packet(data, header_info);
  break;
 
+ case CONTROLS_UPDATE:
+ process_input_packet(data, header_info);
+ break;
+
  default:
  nprintf(("Network", "Received packet with unknown type %d\n", data[0] ));
  header_info->bytes_processed = 10000;
Index: code/network/multi.h
===================================================================
--- code/network/multi.h (revision 9214)
+++ code/network/multi.h (working copy)
@@ -280,6 +280,7 @@
 #define WEAPON_OR_AMMO_CHANGED 0xF1 // Karajorma - The weapon or ammo of a fighter/bomber has been changed
 #define SEXP 0xF2 // Karajorma - a general packet which can be used to update clients with changes caused by SEXPs
 #define CHANGE_IFF_COLOR 0xF3 // Wanderer - change iff color
+#define CONTROLS_UPDATE 0xF4 // Karajorma - Send the server a list of keys pressed in this frame
 
 #define MAX_TYPE_ID 0xFF // better not try to send > 255 in a single byte buddy
 
Index: code/network/multimsgs.cpp
===================================================================
--- code/network/multimsgs.cpp (revision 9214)
+++ code/network/multimsgs.cpp (working copy)
@@ -7573,6 +7573,76 @@
  }
 }
 
+void send_input_packet(ushort start_index)
+{
+ ushort i;
+ ubyte data[MAX_PACKET_SIZE];
+ int packet_size = 0;
+ ubyte stop = 0;
+
+ Assert(start_index < CCFG_MAX);
+
+ if(Net_player == NULL){
+ return;
+ }
+
+ if(!MULTIPLAYER_CLIENT){
+ return;
+ }
+
+ // build the packet and add the data
+ BUILD_HEADER(CONTROLS_UPDATE);
+ ADD_USHORT(Player_obj->net_signature);
+
+ for (i = start_index; i < CCFG_MAX; i++) {
+ if (Control_config[i].used && !Player->inputs_used[i]) {
+ Player->inputs_used[i] = Control_config[i].used;
+ ADD_DATA(stop);
+ ADD_USHORT(i);
+ ADD_INT(Control_config[i].used);
+ }
+ }
+
+ stop = 1;
+ ADD_DATA(stop);
+
+ // send to the server
+ multi_io_send_reliable(Net_player, data, packet_size);
+}
+
+void process_input_packet( ubyte *data, header *hinfo)
+{
+ ubyte stop;
+ ushort net_signature, index;
+ int np_index, time_used;
+
+ int offset = HEADER_LENGTH;
+
+ // get the data
+ GET_USHORT(net_signature);
+ GET_DATA(stop);
+
+ Assert (MULTIPLAYER_MASTER);
+ np_index = multi_find_player_by_net_signature(net_signature);
+ if((np_index < 0) && (np_index >= MAX_PLAYERS)){
+ Error(LOCATION, "Received packet from player who doesn't exist! Only %d players allowed, received packet from player number %d", MAX_PLAYERS, np_index);
+ }
+
+
+ while (!stop) {
+ GET_USHORT(index);
+ GET_INT(time_used);
+ GET_DATA(stop);
+
+ Assertion((index < CCFG_MAX), "Received input type %d from client, only %d types supported", index, CCFG_MAX);
+ Net_players[np_index].m_player->inputs_used[index] = time_used;
+ }
+
+ PACKET_SET_SIZE();
+
+
+}
+
 void send_change_ai_class_packet(ushort net_signature, char *subsystem, int new_ai_class)
 {
  ubyte data[MAX_PACKET_SIZE];
Index: code/network/multimsgs.h
===================================================================
--- code/network/multimsgs.h (revision 9214)
+++ code/network/multimsgs.h (working copy)
@@ -547,4 +547,7 @@
 void send_sexp_packet(ubyte *sexp_packet, int num_ubytes);
 void process_sexp_packet(ubyte *data, header *hinfo);
 
+void send_input_packet(ushort start_index);
+void process_input_packet(ubyte *data, header *hinfo);
+
 #endif
Index: code/network/psnet2.cpp
===================================================================
--- code/network/psnet2.cpp (revision 9214)
+++ code/network/psnet2.cpp (working copy)
@@ -140,7 +140,7 @@
  // required in case of out of order packets
 #define NETRETRYTIME 0.75f // Time after sending before we resend
 #define MIN_NET_RETRYTIME 0.2f
-#define NETTIMEOUT 30 // Time after receiving the last packet before we drop that user
+#define NETTIMEOUT 120 // Time after receiving the last packet before we drop that user
 #define NETHEARTBEATTIME 3 // How often to send a heartbeat
 #define MAXRELIABLESOCKETS 40 // Max reliable sockets to open at once...
 #define NETBUFFERSIZE 600 // Max size of a network packet
Index: code/parse/sexp.cpp
===================================================================
--- code/parse/sexp.cpp (revision 9214)
+++ code/parse/sexp.cpp (working copy)
@@ -688,9 +688,12 @@
 
  //Training Category
  { "key-pressed", OP_KEY_PRESSED, 1, 2, },
+ { "player-input-delay", OP_PLAYER_INPUT_DELAY, 3, 3, },
+ { "reset-input", OP_RESET_INPUT, 2, INT_MAX, },
  { "key-reset", OP_KEY_RESET, 1, INT_MAX, },
  { "key-reset-multiple", OP_KEY_RESET_MULTIPLE, 1, INT_MAX, },
- { "ignore-key", OP_IGNORE_KEY, 2, INT_MAX }, // Karajorma
+ { "ignore-input", OP_IGNORE_INPUT, 3, INT_MAX }, // Karajorma
+ { "ignore-key", OP_IGNORE_KEY, 2, INT_MAX }, // Karajorma
  { "targeted", OP_TARGETED, 1, 3, },
  { "node-targeted", OP_NODE_TARGETED, 1, 2, }, // FUBAR
  { "missile-locked", OP_MISSILE_LOCKED, 1, 3 }, // Sesquipedalian
@@ -711,6 +714,7 @@
 
  { "set-training-context-fly-path", OP_SET_TRAINING_CONTEXT_FLY_PATH, 2, 2, },
  { "set-training-context-speed", OP_SET_TRAINING_CONTEXT_SPEED, 2, 2, },
+
 };
 
 sexp_ai_goal_link Sexp_ai_goal_links[] = {
@@ -2723,7 +2727,11 @@
  case OPF_KEYPRESS:
  if (type2 != SEXP_ATOM_STRING)
  return SEXP_CHECK_TYPE_MISMATCH;
+ break;
 
+ case OPF_PLAYER_INPUT:
+ if (type2 != SEXP_ATOM_STRING)
+ return SEXP_CHECK_TYPE_MISMATCH;
  break;
 
  case OPF_CARGO:
@@ -14020,7 +14028,9 @@
  int z, t;
 
  Assert(node != -1);
+
  z = translate_key_to_index(CTEXT(node));
+
  if (z < 0){
  return SEXP_FALSE;
  }
@@ -14048,7 +14058,7 @@
  Control_config[z].used = 0;
  }
 }
-
+
 void sexp_ignore_key(int node)
 {
  int ignore_count;
@@ -14088,6 +14098,179 @@
  }
 }
 
+int sexp_player_input(int node)
+{
+ int z, t;
+ player *pl;
+
+ // get the player
+ pl = get_player_from_ship_node(node);
+
+ // AI ships can't press keys!
+ if (pl == NULL) {
+ return SEXP_FALSE;
+ }
+
+ // get the delay
+ node = CDR(node);
+ t = eval_num(node);
+
+ node = CDR(node);
+ z = translate_input_to_index(CTEXT(node));
+
+ if (z < 0){
+ return SEXP_FALSE;
+ }
+
+ if (pl == Player) {
+ if (!Control_config[z].used){
+ return SEXP_FALSE;
+ }
+
+ return timestamp_has_time_elapsed(Control_config[z].used, t * 1000);
+ }
+ else {
+ if (pl->inputs_used[z]) {
+ return timestamp_has_time_elapsed(pl->inputs_used[z], t * 1000);
+ }
+
+ return SEXP_FALSE;
+ }
+}
+
+void sexp_reset_input(int node)
+{
+ int z, n;
+ player *pl;
+
+ // get the player
+ pl = get_player_from_ship_node(node);
+
+ // AI ships can't press keys!
+ if (pl == NULL) {
+ return;
+ }
+
+ node = CDR(node);
+ multi_start_callback();
+ multi_send_string(pl->callsign);
+
+ for (n =  node; n != -1; n = CDR(n)) {
+ z = translate_input_to_index(CTEXT(node));
+
+ if (z < 0) {
+ return;
+ }
+
+ if (pl == Player) {
+ Control_config[z].used = 0;
+ }
+ else {
+ pl->inputs_used[z] = 0;
+ multi_send_int(z);
+ }
+ }
+
+ multi_end_callback();
+}
+
+void multi_sexp_reset_input()
+{
+ char callsign[CALLSIGN_LEN + 1];
+ int index;
+ int net_player_index;
+
+ multi_get_string(callsign);
+ net_player_index = multi_find_player_by_callsign(callsign);
+
+ if (net_player_index == MY_NET_PLAYER_NUM) {
+ while (multi_get_int(index)) {
+ // bad index
+ if (index >= CCFG_MAX) {
+ Warning(LOCATION, "multi_sexp_reset_input() received instructions for an input that does not exist!");
+ continue;
+ }
+
+ Player->inputs_used[index] = 0;
+ Control_config[index].used = 0;
+ }
+ }
+ else {
+ while (multi_get_int(index)) {
+ // just eat the input since it doesn't apply to this player
+ }
+ }
+}
+
+void sexp_ignore_input(int node)
+{
+ int ignore_count;
+ int ignored_input;
+ player *pl;
+
+ // get the player
+ pl = get_player_from_ship_node(node);
+
+ // AI ships can't press keys!
+ if (pl == NULL) {
+ return;
+ }
+
+ node = CDR(node);
+ ignore_count = eval_num(node);
+
+ if (pl != Player) {
+ multi_start_callback();
+ multi_send_string(pl->callsign);
+ multi_send_int(ignore_count);
+ }
+
+ node = CDR(node);
+ while (node > -1) {
+ // get the key
+ ignored_input = translate_input_to_index(CTEXT(node));
+
+ if (ignored_input > -1) {
+ if (pl == Player) {
+ Ignored_keys[ignored_input] = ignore_count;
+ }
+ else {
+ multi_send_int(ignored_input);
+ }
+ }
+
+ node = CDR(node);
+ }
+
+ if (pl != Player) {
+ multi_end_callback();
+ }
+
+}
+
+void multi_sexp_ignore_input()
+{
+ int ignored_input, ignore_count;
+
+ char callsign[CALLSIGN_LEN + 1];
+ int net_player_index;
+
+ multi_get_string(callsign);
+ multi_get_int(ignore_count);
+ net_player_index = multi_find_player_by_callsign(callsign);
+
+ if (net_player_index == MY_NET_PLAYER_NUM) {
+ while (multi_get_int(ignored_input)) {
+ Ignored_keys[ignored_input] = ignore_count;
+ }
+ }
+ else {
+ while (multi_get_int(ignored_input)) {
+ // just eat the input since it doesn't apply to this player
+ }
+ }
+}
+
 int sexp_targeted(int node)
 {
  int z;
@@ -21774,6 +21957,11 @@
  sexp_val = SEXP_TRUE;
  break;
 
+ case OP_IGNORE_INPUT:
+ sexp_ignore_input(node);
+ sexp_val = SEXP_TRUE;
+ break;
+
  // Goober5000 - sigh, was this messed up all along?
  case OP_WARP_BROKEN:
  case OP_WARP_NOT_BROKEN:
@@ -21895,6 +22083,10 @@
  sexp_val = sexp_key_pressed(node);
  break;
 
+ case OP_PLAYER_INPUT_DELAY:
+ sexp_val = sexp_player_input(node);
+ break;
+
  case OP_SPECIAL_CHECK:
  sexp_val = sexp_special_training_check(node);
  break;
@@ -21909,6 +22101,11 @@
  sexp_val = SEXP_TRUE;
  break;
 
+ case OP_RESET_INPUT:
+ sexp_reset_input(node);
+ sexp_val = SEXP_KNOWN_TRUE;  // only do it first time in repeating events.
+ break;
+
  case OP_MISSILE_LOCKED:
  sexp_val = sexp_missile_locked(node);
  break;
@@ -23040,10 +23237,18 @@
  multi_sexp_set_jumpnode_name();
  break;
 
+ case OP_RESET_INPUT:
+ multi_sexp_reset_input();
+ break;
+
  case OP_IGNORE_KEY:
  multi_sexp_ignore_key();
  break;
 
+ case OP_IGNORE_INPUT:
+ multi_sexp_ignore_input();
+ break;
+
  case OP_JUMP_NODE_SET_JUMPNODE_COLOR:
  multi_sexp_set_jumpnode_color();
  break;
@@ -23266,6 +23471,7 @@
  case OP_SHIP_TYPE_DESTROYED:
  case OP_LAST_ORDER_TIME:
  case OP_KEY_PRESSED:
+ case OP_PLAYER_INPUT_DELAY:
  case OP_TARGETED:
  case OP_NODE_TARGETED:
  case OP_SPEED:
@@ -23451,6 +23657,7 @@
  case OP_SET_UNSCANNED:
  case OP_KEY_RESET:
  case OP_KEY_RESET_MULTIPLE:
+ case OP_RESET_INPUT:
  case OP_TRAINING_MSG:
  case OP_SET_TRAINING_CONTEXT_FLY_PATH:
  case OP_SET_TRAINING_CONTEXT_SPEED:
@@ -23551,6 +23758,7 @@
  case OP_SET_MOBILE:
  case OP_SET_IMMOBILE:
  case OP_IGNORE_KEY:
+ case OP_IGNORE_INPUT:
  case OP_CHANGE_SHIP_CLASS:
  case OP_SHIP_COPY_DAMAGE:
  case OP_DEACTIVATE_GLOW_POINTS:
@@ -24702,9 +24910,23 @@
  else
  return OPF_POSITIVE;
 
+ case OP_PLAYER_INPUT_DELAY:
+ if (argnum == 0)
+ return OPF_SHIP;
+ else if (argnum == 1)
+ return OPF_POSITIVE;
+ else
+ return OPF_PLAYER_INPUT;
+
  case OP_KEY_RESET:
  case OP_KEY_RESET_MULTIPLE:
  return OPF_KEYPRESS;
+
+ case OP_RESET_INPUT:
+ if (argnum == 0)
+ return OPF_SHIP;
+ else
+ return OPF_PLAYER_INPUT;
 
  case OP_EVENT_TRUE:
  case OP_EVENT_FALSE:
@@ -24825,7 +25047,15 @@
  else
  return OPF_KEYPRESS;
 
+ case OP_IGNORE_INPUT:
+ if (argnum == 0)
+ return OPF_SHIP;
+ else if (argnum == 1)
+ return OPF_NUMBER;
+ else
+ return OPF_PLAYER_INPUT;
 
+
  case OP_WARP_BROKEN:
  case OP_WARP_NOT_BROKEN:
  case OP_WARP_NEVER:
@@ -28739,6 +28969,13 @@
  "\t1:\tDefault key to check for.\r\n"
  "\t2:\tDelay before operator registers as true (optional).\r\n" },
 
+ { OP_PLAYER_INPUT_DELAY, "player-input-delay (Boolean training operator)\r\n"
+ "\tBecomes true when the specified input was used by the player specified. \r\n\r\n"
+ "Returns a boolean value.  Takes 1 or 2 arguments...\r\n"
+ "\t1:\tThe ship flown by the player in question.\r\n"
+ "\t2:\tDelay before operator registers as true.\r\n"
+ "\t3:\tThe input (as named in the English version of the control config screen) to check for.\r\n" },
+
  { OP_KEY_RESET, "Key-reset (Training operator)\r\n"
  "\tMarks the specified default key as having not been pressed, so key-pressed will be false "
  "until the player presses it again.  See key-pressed help for more information about "
@@ -28757,6 +28994,13 @@
  "Returns a boolean value.  Takes 1 or more arguments...\r\n"
  "\tAll:\tDefault key to reset." },
 
+ { OP_RESET_INPUT, "reset-input (Training operator)\r\n"
+ "\tMarks the specified input as never having been used, so player-input-delay will be false "
+ "until the player uses it again. \r\n\r\n"
+ "Returns a boolean value.  Takes 2 or more arguments...\r\n"
+ "\t1:\tName of the player's ship to check.\r\n"
+ "\tRest:\tInput to reset." },
+
  { OP_TARGETED, "Targeted (Boolean training operator)\r\n"
  "\tIs true as long as the player has the specified ship (or ship's subsystem) targeted, "
  "or has been targeted for the specified amount of time.\r\n\r\n"
@@ -29456,6 +29700,14 @@
  "\tRest: Which key(s) to ignore.\r\n"
  },
 
+ { OP_IGNORE_INPUT, "ignore-input\r\n"
+ "\tCauses the game to ignore (or stop ignoring) a certain kind of input.\r\n"
+ "Takes 3 or more arguments...\r\n"
+ "\t1:\tName of a ship being flown by a player\r\n"
+ "\t2: Number of times to ignore this type of input (-1 = forever, 0 = stop ignoring). \r\n"
+ "\tRest: Which inputs(s) to ignore.\r\n"
+ },
+
  { OP_WARP_BROKEN, "break-warp\r\n"
  "\tBreak the warp drive on the specified ship.  A broken warp drive can be repaired by "
  "a repair ship.  Takes 1 or more arguments...\r\n"
Index: code/parse/sexp.h
===================================================================
--- code/parse/sexp.h (revision 9214)
+++ code/parse/sexp.h (working copy)
@@ -18,7 +18,7 @@
 
 // bumped to 30 by Goober5000
 #define OPERATOR_LENGTH 30  // if this ever exceeds TOKEN_LENGTH, let JasonH know!
-#define TOKEN_LENGTH 32
+#define TOKEN_LENGTH 64
 
 #define MAX_SEXP_VARIABLES 250
 
@@ -106,6 +106,7 @@
 #define OPF_DAMAGE_TYPE 79 // FUBAR - Damage type or <none>
 #define OPF_SHIP_EFFECT 80 // The E - per-ship effects, as defined in post-processing.tbl
 #define OPF_ANIMATION_TYPE 81 // Goober5000 - as defined in modelanim.h
+#define OPF_PLAYER_INPUT 82 // Karajorma - A keypress but defined by the name of the action, not the key.
 
 // Operand return types
 #define OPR_NUMBER 1 // returns number
@@ -772,6 +773,9 @@
 #define OP_QUERY_ORDERS (0x0014 | OP_CATEGORY_TRAINING) // Karajorma
 #define OP_NODE_TARGETED (0x0015 | OP_CATEGORY_TRAINING) // FUBAR
 #define OP_IGNORE_KEY (0x0016 | OP_CATEGORY_TRAINING) // Karajorma
+#define OP_PLAYER_INPUT_DELAY (0x0017 | OP_CATEGORY_TRAINING) // Karajorma
+#define OP_RESET_INPUT (0x0018 | OP_CATEGORY_TRAINING) // Karajorma
+#define OP_IGNORE_INPUT (0x0019 | OP_CATEGORY_TRAINING) // Karajorma
 
 // defines for string constants
 #define SEXP_HULL_STRING "Hull"
Index: code/playerman/player.h
===================================================================
--- code/playerman/player.h (revision 9214)
+++ code/playerman/player.h (working copy)
@@ -119,6 +119,8 @@
  button_info bi; // structure that holds bit vectors for button presses
  control_info ci; // control info structure for this player
  scoring_struct stats; // scoring and stats info for the player (points to multi_stats or single_stats)
+
+ int inputs_used[CCFG_MAX + 1]; // stores a list of the controls the game is monitoring
 
  int friendly_hits; // Number of times hit a friendly ship this mission.
  float friendly_damage; // Total friendly damage done in mission.  Diminishes over time.




[attachment deleted by an evil time traveler]
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]