This commit is contained in:
lenheart
2024-10-10 12:25:42 +08:00
parent 8089cd55a6
commit a328740e19
6 changed files with 950 additions and 5 deletions

View File

@@ -7,6 +7,7 @@
#include "sqstdstring.h"
#include "sqstdsystem.h"
#include "CConnectPool.h"
#include "croncpp.h"
#include "l_socket.h"
#include <openssl/md5.h>
#include <iostream>
@@ -868,10 +869,27 @@ static SQInteger AutoReload(HSQUIRRELVM v)
return 0;
}
static SQInteger L_Sq_Cron_Next(HSQUIRRELVM v)
{
const SQChar *Str;
sq_getstring(v, 2, &Str);
SQInteger Date;
sq_getinteger(v, 3, &Date);
auto cron = cron::make_cron(Str);
std::time_t next = cron::cron_next(cron, Date);
sq_pushinteger(v, next);
return 1;
}
static void RegisterGame(HSQUIRRELVM v)
{
getConfigPath(szGamePath, sizeof(szGamePath));
// 获取下一个cron
register_World_func(v, L_Sq_Cron_Next, _SC("Sq_Cron_Next"));
// int 和指针相互转换
register_World_func(v, RunScript, _SC("sq_RunScript"));