Added playsim event (netevent CCMD)

This commit is contained in:
ZZYZX 2017-02-06 16:02:44 +02:00
parent 77546ad5c2
commit 52d9077477
4 changed files with 33 additions and 1 deletions

View file

@ -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;

View file

@ -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

View file

@ -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 <name> [arg1] [arg2] [arg3]\n");
}
else
{
int arg[3] = { 0, 0, 0 };
int argn = MIN<int>(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]);
}
}

View file

@ -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.