mirror of
https://github.com/bol-van/zapret2.git
synced 2026-08-28 21:02:17 +04:00
nfqws2: replace timer in timer_set if it already exists
This commit is contained in:
+9
-2
@@ -3806,8 +3806,15 @@ static int luacall_timer_set(lua_State *L)
|
||||
lua_pop(L, 1);
|
||||
if (!is_f) luaL_error(L, "timer function '%s' does not exist", func);
|
||||
|
||||
const char *action;
|
||||
timer_pool *timer = TimerPoolSearch(params.timers, name);
|
||||
if (timer) luaL_error(L,"timer '%s' already present", name);
|
||||
if (timer)
|
||||
{
|
||||
TimerPoolDel(¶ms.timers, timer);
|
||||
action = "replaced";
|
||||
}
|
||||
else
|
||||
action = "created";
|
||||
|
||||
timer = TimerPoolAdd(¶ms.timers, name, func, period, oneshot);
|
||||
if (!timer) luaL_error(L,"could not create timer");
|
||||
@@ -3817,7 +3824,7 @@ static int luacall_timer_set(lua_State *L)
|
||||
lua_pushvalue(L, 5);
|
||||
timer->lua_ref = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||
}
|
||||
DLOG("timer: '%s' created. function '%s' period %llu oneshot %u\n", timer->str, timer->func, timer->period, timer->oneshot);
|
||||
DLOG("timer: '%s' %s. function '%s' period %llu oneshot %u\n", timer->str, action, timer->func, timer->period, timer->oneshot);
|
||||
|
||||
LUA_STACK_GUARD_RETURN(L,0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user