Implemented hard separation between playsim ConsoleEvent and networked ConsoleEvent (ConsoleProcess, NetworkProcess)

This commit is contained in:
ZZYZX 2017-03-03 23:21:12 +02:00
parent 43d3e3e5c3
commit a924564bf3
2 changed files with 39 additions and 14 deletions

View file

@ -630,6 +630,7 @@ DEFINE_EMPTY_HANDLER(DStaticEventHandler, UiProcess);
DEFINE_EMPTY_HANDLER(DStaticEventHandler, InputProcess);
DEFINE_EMPTY_HANDLER(DStaticEventHandler, ConsoleProcess);
DEFINE_EMPTY_HANDLER(DStaticEventHandler, NetworkProcess);
// ===========================================
//
@ -1039,6 +1040,8 @@ static DConsoleEvent* E_SetupConsoleEvent()
}
void DStaticEventHandler::ConsoleProcess(int player, FString name, int arg1, int arg2, int arg3)
{
if (player < 0)
{
IFVIRTUAL(DStaticEventHandler, ConsoleProcess)
{
@ -1058,6 +1061,27 @@ void DStaticEventHandler::ConsoleProcess(int player, FString name, int arg1, int
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);
}
}
}
//
void DStaticEventHandler::OnDestroy()

View file

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