From 3338fb7f3321eff4e0180acca01c3072e79a4fba Mon Sep 17 00:00:00 2001 From: ZZYZX Date: Sat, 4 Mar 2017 00:57:41 +0200 Subject: [PATCH] Added SendNetworkEvent static method to EventHandler; Fixed qualified static method call from own class (previously was 'shadowed' by qualified virtual method call) --- src/events.cpp | 33 ++++++++++++++++++++++++++----- src/events.h | 3 +++ src/scripting/backend/codegen.cpp | 1 + wadsrc/static/zscript/events.txt | 2 ++ 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/events.cpp b/src/events.cpp index 75dd8cde8f..9946a10594 100755 --- a/src/events.cpp +++ b/src/events.cpp @@ -117,6 +117,21 @@ bool E_UnregisterHandler(DStaticEventHandler* handler) return true; } +bool E_SendNetworkEvent(FString name, int arg1, int arg2, int arg3) +{ + if (gamestate != GS_LEVEL) + return false; + + Net_WriteByte(DEM_NETEVENT); + Net_WriteString(name); + Net_WriteByte(3); + Net_WriteLong(arg1); + Net_WriteLong(arg2); + Net_WriteLong(arg3); + + return true; +} + bool E_CheckHandler(DStaticEventHandler* handler) { for (DStaticEventHandler* lhandler = E_FirstEventHandler; lhandler; lhandler = lhandler->next) @@ -521,6 +536,18 @@ DEFINE_ACTION_FUNCTION(DStaticEventHandler, SetOrder) return 0; } +DEFINE_ACTION_FUNCTION(DEventHandler, SendNetworkEvent) +{ + PARAM_PROLOGUE; + PARAM_STRING(name); + PARAM_INT(arg1); + PARAM_INT(arg2); + PARAM_INT(arg3); + // + + ACTION_RETURN_BOOL(E_SendNetworkEvent(name, arg1, arg2, arg3)); +} + DEFINE_ACTION_FUNCTION(DEventHandler, Create) { PARAM_PROLOGUE; @@ -1160,10 +1187,6 @@ CCMD(netevent) 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 < 3; i++) - Net_WriteLong(arg[i]); + E_SendNetworkEvent(argv[1], arg[0], arg[1], arg[2]); } } diff --git a/src/events.h b/src/events.h index fa63e73258..b838902235 100755 --- a/src/events.h +++ b/src/events.h @@ -60,6 +60,9 @@ bool E_Responder(event_t* ev); // splits events into InputProcess and UiProcess // this executes on console/net events. void E_Console(int player, FString name, int arg1, int arg2, int arg3); +// send networked event. unified function. +bool E_SendNetworkEvent(FString name, int arg1, int arg2, int arg3); + // check if there is anything that should receive GUI events bool E_CheckUiProcessors(); // check if we need native mouse due to UiProcessors diff --git a/src/scripting/backend/codegen.cpp b/src/scripting/backend/codegen.cpp index ad3ed7664f..1a212f5afa 100644 --- a/src/scripting/backend/codegen.cpp +++ b/src/scripting/backend/codegen.cpp @@ -7859,6 +7859,7 @@ FxExpression *FxMemberFunctionCall::Resolve(FCompileContext& ctx) Self = new FxSelf(ScriptPosition); Self->ValueType = NewPointer(cls); } + else novirtual = false; } } } diff --git a/wadsrc/static/zscript/events.txt b/wadsrc/static/zscript/events.txt index 5b5e067f4a..6452d19e05 100755 --- a/wadsrc/static/zscript/events.txt +++ b/wadsrc/static/zscript/events.txt @@ -343,4 +343,6 @@ class EventHandler : StaticEventHandler native static native bool Register(StaticEventHandler handler); static native bool Unregister(StaticEventHandler handler); + + clearscope static native void SendNetworkEvent(String name, int arg1 = 0, int arg2 = 0, int arg3 = 0); }