summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-03-02 23:03:22 +0000
committerzephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-03-02 23:03:22 +0000
commitebf0ba7ddf1ef2c10515a1607ce7d4316e001a61 (patch)
tree51d030ed2e8e3c841690c3d879257270a2bb9064
parentc90e9f42da90183a0be9c29a11beec7db606d44f (diff)
downloadhercules-ebf0ba7ddf1ef2c10515a1607ce7d4316e001a61.tar.gz
hercules-ebf0ba7ddf1ef2c10515a1607ce7d4316e001a61.tar.bz2
hercules-ebf0ba7ddf1ef2c10515a1607ce7d4316e001a61.tar.xz
hercules-ebf0ba7ddf1ef2c10515a1607ce7d4316e001a61.zip
- The last, i hope, fix to the mail system.
* kRO have a possible way to read mail by just sending the open mail window packet to the client. This protection adds a mapflag town, to set the only maps that allow mail operations. because there is no way to know when client closes the mail inbox window. * git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12279 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--npc/other/mail.txt29
-rw-r--r--src/map/atcommand.h1
-rw-r--r--src/map/clif.c15
-rw-r--r--src/map/mail.c14
-rw-r--r--src/map/mail.h1
-rw-r--r--src/map/map.h1
-rw-r--r--src/map/npc.c2
7 files changed, 61 insertions, 2 deletions
diff --git a/npc/other/mail.txt b/npc/other/mail.txt
index 9dab1f409..7cf983c66 100644
--- a/npc/other/mail.txt
+++ b/npc/other/mail.txt
@@ -3,7 +3,7 @@
//===== By: ==================================================
//= L0ne_W0lf
//===== Current Version: =====================================
-//= 1.3a
+//= 1.4
//===== Compatible With: =====================================
//= eAthena SVN
//===== Description: =========================================
@@ -15,7 +15,32 @@
//= 1.2 Swapped "atcommand" for "Openmail". [L0ne_W0lf]
//= 1.3 Added Veins mail box. [L0ne_W0lf]
//= 1.3a Corrected a typo error. (bugreport:798) [Samuray22]
-//============================================================
+//= 1.4 Added a Mapflag to prevent mail operations in other maps [Zephyrus]
+//============================================================
+
+// Allow Mail Inbox reading from
+//============================================================
+prontera mapflag town
+izlude mapflag town
+morocc mapflag town
+geffen mapflag town
+payon mapflag town
+pay_arche mapflag town
+alberta mapflag town
+aldebaran mapflag town
+yuno mapflag town
+lighthalzen mapflag town
+einbroch mapflag town
+einbech mapflag town
+comodo mapflag town
+umbala mapflag town
+amatsu mapflag town
+gonryun mapflag town
+ayothaya mapflag town
+louyang mapflag town
+hugel mapflag town
+rachel mapflag town
+veins mapflag town
// Prontera
//============================================================
diff --git a/src/map/atcommand.h b/src/map/atcommand.h
index e8b629b6f..875b014a3 100644
--- a/src/map/atcommand.h
+++ b/src/map/atcommand.h
@@ -24,6 +24,7 @@ void do_init_atcommand(void);
void do_final_atcommand(void);
int atcommand_config_read(const char *cfgName);
+int atcommand_mail(const int fd, struct map_session_data* sd,const char* command, const char* message);
int atcommand_item(const int fd, struct map_session_data* sd,const char* command, const char* message);
int atcommand_mapmove(const int fd, struct map_session_data* sd,const char* command, const char* message);
int atcommand_monster(const int fd, struct map_session_data* sd, const char* command, const char* message);
diff --git a/src/map/clif.c b/src/map/clif.c
index 3c84b9df6..21e1d5e46 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -11441,6 +11441,9 @@ void clif_parse_Mail_refreshinbox(int fd, struct map_session_data *sd)
{
struct mail_data* md = &sd->mail.inbox;
+ if( mail_invalid_operation(sd) )
+ return;
+
if( md->amount < MAIL_MAX_INBOX && (md->full || md->changed) )
intif_Mail_requestinbox(sd->status.char_id, 1);
else
@@ -11517,6 +11520,9 @@ void clif_Mail_read(struct map_session_data *sd, int mail_id)
void clif_parse_Mail_read(int fd, struct map_session_data *sd)
{
+ if( mail_invalid_operation(sd) )
+ return;
+
clif_Mail_read(sd, RFIFOL(fd,2));
}
@@ -11528,6 +11534,9 @@ void clif_parse_Mail_getattach(int fd, struct map_session_data *sd)
int i, mail_id = RFIFOL(fd,2);
bool fail = false;
+ if( mail_invalid_operation(sd) )
+ return;
+
ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id);
if( i == MAIL_MAX_INBOX )
return;
@@ -11580,6 +11589,9 @@ void clif_parse_Mail_delete(int fd, struct map_session_data *sd)
{
int i, mail_id = RFIFOL(fd,2);
+ if( mail_invalid_operation(sd) )
+ return;
+
ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id);
if (i < MAIL_MAX_INBOX)
{
@@ -11602,6 +11614,9 @@ void clif_parse_Mail_return(int fd, struct map_session_data *sd)
{
int i, mail_id = RFIFOL(fd,2);
+ if( mail_invalid_operation(sd) )
+ return;
+
ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id);
if (i < MAIL_MAX_INBOX)
intif_Mail_return(sd->status.char_id, mail_id);
diff --git a/src/map/mail.c b/src/map/mail.c
index 0640fa521..b2a4697e5 100644
--- a/src/map/mail.c
+++ b/src/map/mail.c
@@ -4,8 +4,10 @@
#ifndef TXT_ONLY
#include "../common/nullpo.h"
+#include "../common/showmsg.h"
#include "mail.h"
+#include "atcommand.h"
#include "itemdb.h"
#include "clif.h"
#include "pc.h"
@@ -177,4 +179,16 @@ void mail_deliveryfail(struct map_session_data *sd, struct mail_message *msg)
clif_Mail_send(sd->fd, true);
}
+// This function only check if the mail operations are valid
+bool mail_invalid_operation(struct map_session_data *sd)
+{
+ if( !map[sd->bl.m].flag.town && pc_isGM(sd) < get_atcommand_level(atcommand_mail) )
+ {
+ ShowWarning("clif_parse_Mail: char '%s' trying to do invalid mail operations.\n", sd->status.name);
+ return true;
+ }
+
+ return false;
+}
+
#endif
diff --git a/src/map/mail.h b/src/map/mail.h
index 7940018b8..9a867daa5 100644
--- a/src/map/mail.h
+++ b/src/map/mail.h
@@ -16,5 +16,6 @@ bool mail_setattachment(struct map_session_data *sd, struct mail_message *msg);
void mail_getattachment(struct map_session_data* sd, int zeny, struct item* item);
int mail_openmail(struct map_session_data *sd);
void mail_deliveryfail(struct map_session_data *sd, struct mail_message *msg);
+bool mail_invalid_operation(struct map_session_data *sd);
#endif /* _MAIL_H_ */
diff --git a/src/map/map.h b/src/map/map.h
index 72f869f4e..687b89731 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -1164,6 +1164,7 @@ struct map_data {
int npc_num;
int users;
struct map_flag {
+ unsigned town : 1; // [Suggestion to protect Mail System]
unsigned autotrade : 1;
unsigned allowks : 1; // [Kill Steal Protection]
unsigned nomemo : 1;
diff --git a/src/map/npc.c b/src/map/npc.c
index b429b2ed0..a62f5679a 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -2414,6 +2414,8 @@ static const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, con
map[m].flag.autotrade=state;
else if (!strcmpi(w3,"allowks"))
map[m].flag.allowks=state; // [Kill Steal Protection]
+ else if (!strcmpi(w3,"town"))
+ map[m].flag.town=state;
else if (!strcmpi(w3,"nomemo"))
map[m].flag.nomemo=state;
else if (!strcmpi(w3,"noteleport"))