Skip to content

Commit 52d9077

Browse files
author
ZZYZX
committedFeb 6, 2017
Added playsim event (netevent CCMD)
1 parent 77546ad commit 52d9077

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed
 

‎src/d_net.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
#include "a_keys.h"
6565
#include "intermission/intermission.h"
6666
#include "g_levellocals.h"
67+
#include "events.h"
6768

6869
EXTERN_CVAR (Int, disableautosave)
6970
EXTERN_CVAR (Int, autosavecount)
@@ -2678,6 +2679,17 @@ void Net_DoCommand (int type, BYTE **stream, int player)
26782679
G_ChangeLevel(NULL, 0, 0);
26792680
break;
26802681

2682+
case DEM_NETEVENT:
2683+
{
2684+
FString ename = ReadString(stream);
2685+
int argn = ReadByte(stream);
2686+
int arg[3] = { 0, 0, 0 };
2687+
for (int i = 0; i < argn; i++)
2688+
arg[i] = ReadLong(stream);
2689+
E_Console(player, ename, arg[0], arg[1], arg[2]);
2690+
}
2691+
break;
2692+
26812693
default:
26822694
I_Error ("Unknown net command: %d", type);
26832695
break;

‎src/d_protocol.h

+1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ enum EDemoCommand
159159
DEM_SETSLOTPNUM, // 67 Byte: player number, the rest is the same as DEM_SETSLOT
160160
DEM_REMOVE, // 68
161161
DEM_FINISHGAME, // 69
162+
DEM_NETEVENT // 70 String: Event name, Byte: Arg count; each arg is a 4-byte int
162163
};
163164

164165
// The following are implemented by cht_DoCheat in m_cheat.cpp

‎src/events.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "v_text.h"
77
#include "actor.h"
88
#include "c_dispatch.h"
9+
#include "d_net.h"
910

1011
DStaticEventHandler* E_FirstEventHandler = nullptr;
1112
DStaticEventHandler* E_LastEventHandler = nullptr;
@@ -1088,5 +1089,23 @@ CCMD(event)
10881089

10891090
CCMD(netevent)
10901091
{
1092+
int argc = argv.argc();
10911093

1094+
if (argc < 2 || argc > 5)
1095+
{
1096+
Printf("Usage: event <name> [arg1] [arg2] [arg3]\n");
1097+
}
1098+
else
1099+
{
1100+
int arg[3] = { 0, 0, 0 };
1101+
int argn = MIN<int>(argc - 2, countof(arg));
1102+
for (int i = 0; i < argn; i++)
1103+
arg[i] = atoi(argv[2 + i]);
1104+
// call networked
1105+
Net_WriteByte(DEM_NETEVENT);
1106+
Net_WriteString(argv[1]);
1107+
Net_WriteByte(argn);
1108+
for (int i = 0; i < argn; i++)
1109+
Net_WriteLong(arg[i]);
1110+
}
10921111
}

‎src/version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const char *GetVersionString();
6161
// Protocol version used in demos.
6262
// Bump it if you change existing DEM_ commands or add new ones.
6363
// Otherwise, it should be safe to leave it alone.
64-
#define DEMOGAMEVERSION 0x21E
64+
#define DEMOGAMEVERSION 0x21F
6565

6666
// Minimum demo version we can play.
6767
// Bump it whenever you change or remove existing DEM_ commands.

0 commit comments

Comments
 (0)
Please sign in to comment.