From d18f5bdb682a1d9c6e3a191926bfd46d36e813c1 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Wed, 17 Apr 2013 13:22:58 -0700 Subject: Force timers to be managed --- src/map/script.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/map/script.cpp') diff --git a/src/map/script.cpp b/src/map/script.cpp index 151175b..55c7d42 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -3570,7 +3570,7 @@ void builtin_pvpon(ScriptState *st) { if (m == pl_sd->bl.m && !pl_sd->pvp_timer) { - pl_sd->pvp_timer = add_timer(gettick() + std::chrono::milliseconds(200), + pl_sd->pvp_timer = Timer(gettick() + std::chrono::milliseconds(200), std::bind(pc_calc_pvprank_timer, ph::_1, ph::_2, pl_sd->bl.id)); pl_sd->pvp_rank = 0; @@ -3605,11 +3605,7 @@ void builtin_pvpoff(ScriptState *st) { if (m == pl_sd->bl.m) { - if (pl_sd->pvp_timer) - { - delete_timer(pl_sd->pvp_timer); - pl_sd->pvp_timer = nullptr; - } + pl_sd->pvp_timer.cancel(); } } } @@ -5109,9 +5105,10 @@ void do_init_script(void) { script_load_mapreg(); - add_timer_interval(gettick() + MAPREG_AUTOSAVE_INTERVAL, + Timer(gettick() + MAPREG_AUTOSAVE_INTERVAL, script_autosave_mapreg, - MAPREG_AUTOSAVE_INTERVAL); + MAPREG_AUTOSAVE_INTERVAL + ).detach(); } #define BUILTIN(func, args) \ -- cgit v1.2.3-60-g2f50