summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorremoitnane <remoit(DOT)nane(AT)gmail(DOT)com>2010-08-28 23:23:18 -0700
committerremoitnane <remoit(DOT)nane(AT)gmail(DOT)com>2010-08-28 23:23:18 -0700
commite3672654b00c81e0a171e40a2683ffb904d4f540 (patch)
treeb9faa02ab253f30885668ca24efa21815cfed68b
parente6958780f0266e20f86de79c50aa227a5612d605 (diff)
downloadtmwa-e3672654b00c81e0a171e40a2683ffb904d4f540.tar.gz
tmwa-e3672654b00c81e0a171e40a2683ffb904d4f540.tar.bz2
tmwa-e3672654b00c81e0a171e40a2683ffb904d4f540.tar.xz
tmwa-e3672654b00c81e0a171e40a2683ffb904d4f540.zip
Prevent players from bypassing a spell's cast time
-rw-r--r--src/map/pc.c17
1 files changed, 16 insertions, 1 deletions
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;
}