diff --git a/src/d_net.cpp b/src/d_net.cpp index 93f6a621b7..8b18efc7cd 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -64,6 +64,7 @@ #include "a_keys.h" #include "intermission/intermission.h" #include "g_levellocals.h" +#include "events.h" EXTERN_CVAR (Int, disableautosave) EXTERN_CVAR (Int, autosavecount) @@ -2678,6 +2679,17 @@ void Net_DoCommand (int type, BYTE **stream, int player) G_ChangeLevel(NULL, 0, 0); break; + case DEM_NETEVENT: + { + FString ename = ReadString(stream); + int argn = ReadByte(stream); + int arg[3] = { 0, 0, 0 }; + for (int i = 0; i < argn; i++) + arg[i] = ReadLong(stream); + E_Console(player, ename, arg[0], arg[1], arg[2]); + } + break; + default: I_Error ("Unknown net command: %d", type); break; diff --git a/src/d_protocol.h b/src/d_protocol.h index 2813b14dc5..27af1dae26 100644 --- a/src/d_protocol.h +++ b/src/d_protocol.h @@ -159,6 +159,7 @@ enum EDemoCommand DEM_SETSLOTPNUM, // 67 Byte: player number, the rest is the same as DEM_SETSLOT DEM_REMOVE, // 68 DEM_FINISHGAME, // 69 + DEM_NETEVENT // 70 String: Event name, Byte: Arg count; each arg is a 4-byte int }; // The following are implemented by cht_DoCheat in m_cheat.cpp diff --git a/src/events.cpp b/src/events.cpp index 4535f98f52..17cec36858 100755 --- a/src/events.cpp +++ b/src/events.cpp @@ -6,6 +6,7 @@ #include "v_text.h" #include "actor.h" #include "c_dispatch.h" +#include "d_net.h" DStaticEventHandler* E_FirstEventHandler = nullptr; DStaticEventHandler* E_LastEventHandler = nullptr; @@ -1088,5 +1089,23 @@ CCMD(event) CCMD(netevent) { + int argc = argv.argc(); + if (argc < 2 || argc > 5) + { + Printf("Usage: event [arg1] [arg2] [arg3]\n"); + } + else + { + int arg[3] = { 0, 0, 0 }; + int argn = MIN(argc - 2, countof(arg)); + for (int i = 0; i < argn; i++) + arg[i] = atoi(argv[2 + i]); + // call networked + Net_WriteByte(DEM_NETEVENT); + Net_WriteString(argv[1]); + Net_WriteByte(argn); + for (int i = 0; i < argn; i++) + Net_WriteLong(arg[i]); + } } \ No newline at end of file diff --git a/src/version.h b/src/version.h index 8ed9e56aaf..e50bdfd8d8 100644 --- a/src/version.h +++ b/src/version.h @@ -61,7 +61,7 @@ const char *GetVersionString(); // Protocol version used in demos. // Bump it if you change existing DEM_ commands or add new ones. // Otherwise, it should be safe to leave it alone. -#define DEMOGAMEVERSION 0x21E +#define DEMOGAMEVERSION 0x21F // Minimum demo version we can play. // Bump it whenever you change or remove existing DEM_ commands.