summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
6 files changed, 34 insertions, 0 deletions
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"))