Added SendNetworkEvent static method to EventHandler; Fixed qualified static method call from own class (previously was 'shadowed' by qualified virtual method call)

This commit is contained in:
ZZYZX 2017-03-04 00:57:41 +02:00
parent c9a994a885
commit 3338fb7f33
4 changed files with 34 additions and 5 deletions

View file

@ -117,6 +117,21 @@ bool E_UnregisterHandler(DStaticEventHandler* handler)
return true; 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) bool E_CheckHandler(DStaticEventHandler* handler)
{ {
for (DStaticEventHandler* lhandler = E_FirstEventHandler; lhandler; lhandler = lhandler->next) for (DStaticEventHandler* lhandler = E_FirstEventHandler; lhandler; lhandler = lhandler->next)
@ -521,6 +536,18 @@ DEFINE_ACTION_FUNCTION(DStaticEventHandler, SetOrder)
return 0; 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) DEFINE_ACTION_FUNCTION(DEventHandler, Create)
{ {
PARAM_PROLOGUE; PARAM_PROLOGUE;
@ -1160,10 +1187,6 @@ CCMD(netevent)
for (int i = 0; i < argn; i++) for (int i = 0; i < argn; i++)
arg[i] = atoi(argv[2 + i]); arg[i] = atoi(argv[2 + i]);
// call networked // call networked
Net_WriteByte(DEM_NETEVENT); E_SendNetworkEvent(argv[1], arg[0], arg[1], arg[2]);
Net_WriteString(argv[1]);
Net_WriteByte(argn);
for (int i = 0; i < 3; i++)
Net_WriteLong(arg[i]);
} }
} }

View file

@ -60,6 +60,9 @@ bool E_Responder(event_t* ev); // splits events into InputProcess and UiProcess
// this executes on console/net events. // this executes on console/net events.
void E_Console(int player, FString name, int arg1, int arg2, int arg3); 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 // check if there is anything that should receive GUI events
bool E_CheckUiProcessors(); bool E_CheckUiProcessors();
// check if we need native mouse due to UiProcessors // check if we need native mouse due to UiProcessors

View file

@ -7859,6 +7859,7 @@ FxExpression *FxMemberFunctionCall::Resolve(FCompileContext& ctx)
Self = new FxSelf(ScriptPosition); Self = new FxSelf(ScriptPosition);
Self->ValueType = NewPointer(cls); Self->ValueType = NewPointer(cls);
} }
else novirtual = false;
} }
} }
} }

View file

@ -343,4 +343,6 @@ class EventHandler : StaticEventHandler native
static native bool Register(StaticEventHandler handler); static native bool Register(StaticEventHandler handler);
static native bool Unregister(StaticEventHandler handler); static native bool Unregister(StaticEventHandler handler);
clearscope static native void SendNetworkEvent(String name, int arg1 = 0, int arg2 = 0, int arg3 = 0);
} }