From a924564bf34ecd3eb1a35197000237ff477b72a8 Mon Sep 17 00:00:00 2001 From: ZZYZX Date: Fri, 3 Mar 2017 23:21:12 +0200 Subject: [PATCH] Implemented hard separation between playsim ConsoleEvent and networked ConsoleEvent (ConsoleProcess, NetworkProcess) --- src/events.cpp | 50 +++++++++++++++++++++++--------- wadsrc/static/zscript/events.txt | 3 +- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/src/events.cpp b/src/events.cpp index 4522f1989..bb7b34f66 100755 --- a/src/events.cpp +++ b/src/events.cpp @@ -630,6 +630,7 @@ DEFINE_EMPTY_HANDLER(DStaticEventHandler, UiProcess); DEFINE_EMPTY_HANDLER(DStaticEventHandler, InputProcess); DEFINE_EMPTY_HANDLER(DStaticEventHandler, ConsoleProcess); +DEFINE_EMPTY_HANDLER(DStaticEventHandler, NetworkProcess); // =========================================== // @@ -1040,22 +1041,45 @@ static DConsoleEvent* E_SetupConsoleEvent() void DStaticEventHandler::ConsoleProcess(int player, FString name, int arg1, int arg2, int arg3) { - IFVIRTUAL(DStaticEventHandler, ConsoleProcess) + if (player < 0) { - // don't create excessive DObjects if not going to be processed anyway - if (func == DStaticEventHandler_ConsoleProcess_VMPtr) - return; - DConsoleEvent* e = E_SetupConsoleEvent(); + IFVIRTUAL(DStaticEventHandler, ConsoleProcess) + { + // don't create excessive DObjects if not going to be processed anyway + if (func == DStaticEventHandler_ConsoleProcess_VMPtr) + return; + DConsoleEvent* e = E_SetupConsoleEvent(); - // - e->Player = player; - e->Name = name; - e->Args[0] = arg1; - e->Args[1] = arg2; - e->Args[2] = arg3; + // + e->Player = player; + e->Name = name; + e->Args[0] = arg1; + e->Args[1] = arg2; + e->Args[2] = arg3; - VMValue params[2] = { (DStaticEventHandler*)this, e }; - GlobalVMStack.Call(func, params, 2, nullptr, 0, nullptr); + VMValue params[2] = { (DStaticEventHandler*)this, e }; + GlobalVMStack.Call(func, params, 2, nullptr, 0, nullptr); + } + } + else + { + IFVIRTUAL(DStaticEventHandler, NetworkProcess) + { + // don't create excessive DObjects if not going to be processed anyway + if (func == DStaticEventHandler_NetworkProcess_VMPtr) + return; + DConsoleEvent* e = E_SetupConsoleEvent(); + + // + e->Player = player; + e->Name = name; + e->Args[0] = arg1; + e->Args[1] = arg2; + e->Args[2] = arg3; + + VMValue params[2] = { (DStaticEventHandler*)this, e }; + GlobalVMStack.Call(func, params, 2, nullptr, 0, nullptr); + } } } diff --git a/wadsrc/static/zscript/events.txt b/wadsrc/static/zscript/events.txt index 664438f0d..5b5e067f4 100755 --- a/wadsrc/static/zscript/events.txt +++ b/wadsrc/static/zscript/events.txt @@ -321,7 +321,8 @@ class StaticEventHandler : Object native play virtual native bool InputProcess(InputEvent e); // - virtual native clearscope void ConsoleProcess(ConsoleEvent e); + virtual native ui void ConsoleProcess(ConsoleEvent e); + virtual native void NetworkProcess(ConsoleEvent e); // this value will be queried on Register() to decide the relative order of this handler to every other. // this is most useful in UI systems.