[Server] Simplify native CallPublic & CreateTimerEx

pull/249/merge
Koncord 8 years ago
parent 1c09e0c255
commit 5292914325

@ -16,15 +16,12 @@ int ScriptFunctions::CreateTimer(ScriptFunc callback, int msec) noexcept
return mwmp::TimerAPI::CreateTimer(callback, msec, "", vector<boost::any>()); return mwmp::TimerAPI::CreateTimer(callback, msec, "", vector<boost::any>());
} }
int ScriptFunctions::CreateTimerEx(ScriptFunc callback, int msec, const char *types, ...) noexcept int ScriptFunctions::CreateTimerEx(ScriptFunc callback, int msec, const char *types, va_list args) noexcept
{ {
try try
{ {
vector<boost::any> params; vector<boost::any> params;
va_list args;
va_start(args, types);
GetArguments(params, args, types); GetArguments(params, args, types);
va_end(args);
return mwmp::TimerAPI::CreateTimer(callback, msec, types, params); return mwmp::TimerAPI::CreateTimer(callback, msec, types, params);
} }

@ -80,18 +80,14 @@ void ScriptFunctions::MakePublic(ScriptFunc _public, const char *name, char ret_
Public::MakePublic(_public, name, ret_type, def); Public::MakePublic(_public, name, ret_type, def);
} }
boost::any ScriptFunctions::CallPublic(const char *name, ...) noexcept boost::any ScriptFunctions::CallPublic(const char *name, va_list args) noexcept
{ {
vector<boost::any> params; vector<boost::any> params;
try try
{ {
string def = Public::GetDefinition(name); string def = Public::GetDefinition(name);
va_list args;
va_start(args, name);
GetArguments(params, args, def); GetArguments(params, args, def);
va_end(args);
return Public::Call(name, params); return Public::Call(name, params);
} }

@ -48,7 +48,7 @@ public:
static void StopServer(int code) noexcept; static void StopServer(int code) noexcept;
static void MakePublic(ScriptFunc _public, const char *name, char ret_type, const char *def) noexcept; static void MakePublic(ScriptFunc _public, const char *name, char ret_type, const char *def) noexcept;
static boost::any CallPublic(const char *name, ...) noexcept; static boost::any CallPublic(const char *name, va_list args) noexcept;
static void SendMessage(unsigned short pid, const char *message, bool broadcast) noexcept; static void SendMessage(unsigned short pid, const char *message, bool broadcast) noexcept;
static void CleanChatByPid(unsigned short pid); static void CleanChatByPid(unsigned short pid);
@ -61,7 +61,7 @@ public:
* \return return timer id * \return return timer id
*/ */
static int CreateTimer(ScriptFunc callback, int msec) noexcept; static int CreateTimer(ScriptFunc callback, int msec) noexcept;
static int CreateTimerEx(ScriptFunc callback, int msec, const char *types, ...) noexcept; static int CreateTimerEx(ScriptFunc callback, int msec, const char *types, va_list args) noexcept;
static void StartTimer(int timerId) noexcept; static void StartTimer(int timerId) noexcept;
static void StopTimer(int timerId) noexcept; static void StopTimer(int timerId) noexcept;

Loading…
Cancel
Save