From 4e7a458308e2c3c6670489da43d06bd25c2db92c Mon Sep 17 00:00:00 2001
From: Fate <fate-tmw@googlemail.com>
Date: Thu, 14 May 2009 10:20:57 +0000
Subject: Added pc_logout() hook to process players who are logging out When
 poisoned and logging out, set hp to 1 to avoid cheap poison cure exploit

---
 src/map/clif.c |  1 +
 src/map/pc.c   | 11 +++++++++++
 src/map/pc.h   |  1 +
 3 files changed, 13 insertions(+)

diff --git a/src/map/clif.c b/src/map/clif.c
index e5fa002..ba9f6a5 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -8351,6 +8351,7 @@ static int clif_parse(int fd) {
 	// �ڑ����؂��Ă��̂Ō��n��
 	if (!chrif_isconnect() || session[fd]->eof) { // char�I�Ɍq����ĂȂ��Ԃ͐ڑ��֎~ (!chrif_isconnect())
 		if (sd && sd->state.auth) {
+                        pc_logout(sd);
 			clif_quitsave(fd, sd);
 			if (sd->status.name != NULL)
 				printf("Player [%s] has logged off your server.\n", sd->status.name); // Player logout display [Valaris]
diff --git a/src/map/pc.c b/src/map/pc.c
index 8933000..64e66d7 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -7704,3 +7704,14 @@ pc_invisibility(struct map_session_data *sd, int enabled)
                 pc_setpos(sd, map[sd->bl.m].name, sd->bl.x, sd->bl.y, 3);
         }
 }
+
+int pc_logout(struct map_session_data *sd) // [fate] Player logs out
+{
+        if (!sd)
+                return 0;
+
+        if (sd->sc_data[SC_POISON].timer != -1)
+                sd->status.hp = 1; // Logging out while poisoned -> bad
+
+        return 0;
+}
diff --git a/src/map/pc.h b/src/map/pc.h
index 8ecbeb3..0af9a20 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -184,6 +184,7 @@ int pc_setinvincibletimer(struct map_session_data *sd,int);
 int pc_delinvincibletimer(struct map_session_data *sd);
 int pc_addspiritball(struct map_session_data *sd,int,int);
 int pc_delspiritball(struct map_session_data *sd,int,int);
+int pc_logout(struct map_session_data *sd); // [fate] Player logs out
 
 int do_init_pc(void);
 
-- 
cgit v1.2.3-70-g09d2