From e3672654b00c81e0a171e40a2683ffb904d4f540 Mon Sep 17 00:00:00 2001 From: remoitnane Date: Sat, 28 Aug 2010 23:23:18 -0700 Subject: Prevent players from bypassing a spell's cast time --- src/map/pc.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/map/pc.c') diff --git a/src/map/pc.c b/src/map/pc.c index 5db11ca..5814c08 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -817,7 +817,8 @@ int pc_authok (int id, int login_id2, time_t connect_until_time, sd->canact_tick = tick; sd->canmove_tick = tick; sd->attackabletime = tick; - sd->cast_tick = tick; + /* We don't want players bypassing spell restrictions. [remoitnane] */ + sd->cast_tick = tick + pc_readglobalreg (sd, "MAGIC_CAST_TICK"); sd->doridori_counter = 0; @@ -9009,11 +9010,25 @@ void pc_invisibility (struct map_session_data *sd, int enabled) int pc_logout (struct map_session_data *sd) // [fate] Player logs out { + unsigned int tick = gettick (); + if (!sd) return 0; if (sd->sc_data[SC_POISON].timer != -1) sd->status.hp = 1; // Logging out while poisoned -> bad + /* + * Trying to rapidly sign out/in or switch characters to avoid a spell's + * cast time is also bad. [remoitnane] + */ + if (sd->cast_tick > tick) + { + if (pc_setglobalreg (sd, "MAGIC_CAST_TICK", sd->cast_tick - tick)) + sd->status.sp = 1; + } + else + pc_setglobalreg (sd, "MAGIC_CAST_TICK", 0); + MAP_LOG_STATS (sd, "LOGOUT") return 0; } -- cgit v1.2.3-60-g2f50