diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/atcommand.c | 16 | ||||
-rw-r--r-- | src/map/battle.c | 45 | ||||
-rw-r--r-- | src/map/battle.h | 5 | ||||
-rw-r--r-- | src/map/chrif.c | 7 | ||||
-rw-r--r-- | src/map/clif.c | 17 | ||||
-rw-r--r-- | src/map/guild.c | 4 | ||||
-rw-r--r-- | src/map/itemdb.c | 21 | ||||
-rw-r--r-- | src/map/magic-interpreter-parser.c | 2 | ||||
-rw-r--r-- | src/map/magic-interpreter.h | 1 | ||||
-rw-r--r-- | src/map/map.c | 8 | ||||
-rw-r--r-- | src/map/map.h | 3 | ||||
-rw-r--r-- | src/map/mob.c | 16 | ||||
-rw-r--r-- | src/map/npc.c | 5 | ||||
-rw-r--r-- | src/map/pc.c | 42 | ||||
-rw-r--r-- | src/map/script.c | 12 | ||||
-rw-r--r-- | src/map/skill.c | 17 | ||||
-rw-r--r-- | src/map/tmw.c | 33 | ||||
-rw-r--r-- | src/map/tmw.h | 1 |
18 files changed, 171 insertions, 84 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 0f44460..39e62da 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -576,9 +576,9 @@ void log_atcommand(struct map_session_data *sd, const char *fmt, ...) sprintf(fullname, "%s.%04d-%02d", gm_logfile_name, year, month); if (gm_logfile) - fclose(gm_logfile); + fclose_(gm_logfile); - gm_logfile = fopen(fullname, "a"); + gm_logfile = fopen_(fullname, "a"); free(fullname); if (!gm_logfile) { @@ -731,7 +731,7 @@ int msg_config_read(const char *cfgName) { char line[1024], w1[1024], w2[1024]; FILE *fp; - if ((fp = fopen(cfgName, "r")) == NULL) { + if ((fp = fopen_(cfgName, "r")) == NULL) { printf("Messages file not found: %s\n", cfgName); return 1; } @@ -750,7 +750,7 @@ int msg_config_read(const char *cfgName) { } } } - fclose(fp); + fclose_(fp); return 0; } @@ -778,7 +778,7 @@ int atcommand_config_read(const char *cfgName) { AtCommandInfo* p; FILE* fp; - if ((fp = fopen(cfgName, "r")) == NULL) { + if ((fp = fopen_(cfgName, "r")) == NULL) { printf("At commands configuration file not found: %s\n", cfgName); return 1; } @@ -805,7 +805,7 @@ int atcommand_config_read(const char *cfgName) { w2[0] != '%') // symbol of party chat speaking command_symbol = w2[0]; } - fclose(fp); + fclose_(fp); return 0; } @@ -1973,7 +1973,7 @@ int atcommand_help( memset(buf, '\0', sizeof(buf)); - if ((fp = fopen(help_txt, "r")) != NULL) { + if ((fp = fopen_(help_txt, "r")) != NULL) { clif_displaymessage(fd, msg_table[26]); // Help commands: gm_level = pc_isGM(sd); while(fgets(buf, sizeof(buf) - 1, fp) != NULL) { @@ -1990,7 +1990,7 @@ int atcommand_help( else if (gm_level >= atoi(w1)) clif_displaymessage(fd, w2); } - fclose(fp); + fclose_(fp); } else { clif_displaymessage(fd, msg_table[27]); // File help.txt not found. return -1; diff --git a/src/map/battle.c b/src/map/battle.c index 45524e5..c9f1b59 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -17,6 +17,7 @@ #include "mob.h" #include "pc.h" #include "skill.h" +#include "../common/socket.h" #ifdef MEMWATCH #include "memwatch.h" @@ -4520,9 +4521,14 @@ int battle_config_read(const char *cfgName) battle_config.chat_spam_ban = 1; battle_config.chat_spam_warn = 8; battle_config.chat_maxline = 255; + + battle_config.trade_spam_threshold = 10; + battle_config.trade_spam_flood = 10; + battle_config.trade_spam_ban = 1; + battle_config.trade_spam_warn = 8; } - fp = fopen(cfgName,"r"); + fp = fopen_(cfgName,"r"); if (fp == NULL) { printf("file not found: %s\n", cfgName); return 1; @@ -4722,12 +4728,16 @@ int battle_config_read(const char *cfgName) { "castrate_dex_scale", &battle_config.castrate_dex_scale }, // added by [MouseJstr] { "area_size", &battle_config.area_size }, // added by [MouseJstr] { "muting_players", &battle_config.muting_players}, // added by [Apple] - { "chat_lame_penalty", &battle_config.chat_lame_penalty }, - { "chat_spam_threshold", &battle_config.chat_spam_threshold }, - { "chat_spam_flood", &battle_config.chat_spam_flood }, - { "chat_spam_ban", &battle_config.chat_spam_ban }, - { "chat_spam_warn", &battle_config.chat_spam_warn }, - { "chat_maxline", &battle_config.chat_maxline } + { "chat_lame_penalty", &battle_config.chat_lame_penalty }, + { "chat_spam_threshold", &battle_config.chat_spam_threshold }, + { "chat_spam_flood", &battle_config.chat_spam_flood }, + { "chat_spam_ban", &battle_config.chat_spam_ban }, + { "chat_spam_warn", &battle_config.chat_spam_warn }, + { "chat_maxline", &battle_config.chat_maxline }, + { "trade_spam_threshold", &battle_config.trade_spam_threshold }, + { "trade_spam_flood", &battle_config.trade_spam_flood }, + { "trade_spam_ban", &battle_config.trade_spam_ban }, + { "trade_spam_warn", &battle_config.trade_spam_warn } }; if (line[0] == '/' && line[1] == '/') @@ -4741,7 +4751,7 @@ int battle_config_read(const char *cfgName) if (strcmpi(w1, "import") == 0) battle_config_read(w2); } - fclose(fp); + fclose_(fp); if (--count == 0) { if(battle_config.flooritem_lifetime < 1000) @@ -4868,6 +4878,25 @@ int battle_config_read(const char *cfgName) else if (battle_config.chat_maxline > 512) battle_config.chat_maxline = 512; + if (battle_config.trade_spam_ban < 0) + battle_config.trade_spam_ban = 0; + else if (battle_config.trade_spam_ban > 32767) + battle_config.trade_spam_ban = 32767; + + if (battle_config.trade_spam_flood < 0) + battle_config.trade_spam_flood = 0; + else if (battle_config.trade_spam_flood > 32767) + battle_config.trade_spam_flood = 32767; + + if (battle_config.trade_spam_warn < 0) + battle_config.trade_spam_warn = 0; + else if (battle_config.trade_spam_warn > 32767) + battle_config.trade_spam_warn = 32767; + + if (battle_config.trade_spam_threshold < 0) + battle_config.trade_spam_threshold = 0; + else if (battle_config.trade_spam_threshold > 32767) + battle_config.trade_spam_threshold = 32767; // at least 1 client must be accepted if ((battle_config.packet_ver_flag & 63) == 0) // added by [Yor] diff --git a/src/map/battle.h b/src/map/battle.h index 3c46586..cdce770 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -318,6 +318,11 @@ extern struct Battle_Config { int chat_spam_ban; int chat_spam_warn; int chat_maxline; + + int trade_spam_threshold; + int trade_spam_flood; + int trade_spam_ban; + int trade_spam_warn; int drop_pickup_safety_zone; // [Fate] Max. distance to an object dropped by a kill by self in which dropsteal protection works diff --git a/src/map/chrif.c b/src/map/chrif.c index cc9437a..4318d1a 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -864,7 +864,7 @@ int chrif_reloadGMdb(void) WFIFOW(char_fd,4) = job_rate; WFIFOW(char_fd,6) = drop_rate; - if ((fp = fopen(motd_txt, "r")) != NULL) { + if ((fp = fopen_(motd_txt, "r")) != NULL) { if (fgets(buf, 250, fp) != NULL) { for(i = 0; buf[i]; i++) { if (buf[i] == '\r' || buf[i] == '\n') { @@ -875,7 +875,7 @@ int chrif_reloadGMdb(void) WFIFOW(char_fd,8) = sizeof(buf) + 10; memcpy(WFIFOP(char_fd,10), buf, sizeof(buf)); } - fclose(fp); + fclose_(fp); } else { WFIFOW(char_fd,8) = sizeof(buf) + 10; memcpy(WFIFOP(char_fd,10), buf, sizeof(buf)); @@ -1113,7 +1113,8 @@ int check_connect_char_server(int tid, unsigned int tick, int id, int data) { if (char_fd <= 0 || session[char_fd] == NULL) { printf("Attempt to connect to char-server...\n"); chrif_state = 0; - char_fd = make_connection(char_ip, char_port); + if ((char_fd = make_connection(char_ip, char_port)) < 0) + return 0; session[char_fd]->func_parse = chrif_parse; realloc_fifo(char_fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK); diff --git a/src/map/clif.c b/src/map/clif.c index d10effb..9357084 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -7084,7 +7084,7 @@ void clif_parse_TradeRequest(int fd,struct map_session_data *sd) nullpo_retv(sd); if(battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 1){ - tmw_CheckChatSpam(sd, NULL); + tmw_CheckTradeSpam(sd); trade_traderequest(sd,RFIFOL(sd->fd,2)); } else clif_skill_fail(sd,1,0,0); @@ -8339,9 +8339,18 @@ static void (*clif_parse_func_table[0x220])() = { static int clif_parse(int fd) { int packet_len = 0, cmd=0; struct map_session_data *sd=NULL; - + sd = session[fd]->session_data; + if (!sd || (sd && !sd->state.auth)) { + if (RFIFOREST(fd) < 2) { // too small a packet disconnect + session[fd]->eof = 1; + } + if (RFIFOW(fd,0) != 0x72) { // first packet not auth, disconnect + session[fd]->eof = 1; + } + } + // �ڑ������Ă��̂Ō��n�� if (!chrif_isconnect() || session[fd]->eof) { // char�I�Ɍq����ĂȂ��Ԃ͐ڑ��֎~ (!chrif_isconnect()) if (sd && sd->state.auth) { @@ -8433,7 +8442,7 @@ static int clif_parse(int fd) { } else if (sd) // not authentified! (refused by char-server or disconnect before to be authentified) printf("\nAccount ID %d.\n", sd->bl.id); - if ((fp = fopen(packet_txt, "a")) == NULL) { + if ((fp = fopen_(packet_txt, "a")) == NULL) { printf("clif.c: cant write [%s] !!! data is lost !!!\n", packet_txt); return 1; } else { @@ -8454,7 +8463,7 @@ static int clif_parse(int fd) { fprintf(fp, "%02X ", RFIFOB(fd,i)); } fprintf(fp, "\n\n"); - fclose(fp); + fclose_(fp); } } #endif diff --git a/src/map/guild.c b/src/map/guild.c index 9e65c33..1509a37 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -64,7 +64,7 @@ static int guild_read_castledb(void) char *str[32],*p; struct guild_castle *gc; - if( (fp=fopen("db/castle_db.txt","r"))==NULL){ + if( (fp=fopen_("db/castle_db.txt","r"))==NULL){ printf("can't read db/castle_db.txt\n"); return -1; } @@ -97,7 +97,7 @@ static int guild_read_castledb(void) ln++; } - fclose(fp); + fclose_(fp); printf("read db/castle_db.txt done (count=%d)\n",ln); return 0; } diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 44b45ad..d9cb429 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -12,6 +12,7 @@ #include "itemdb.h" #include "script.h" #include "pc.h" +#include "../common/socket.h" #ifdef MEMWATCH #include "memwatch.h" @@ -280,7 +281,7 @@ static int itemdb_readdb(void) for(i=0;i<2;i++){ - fp=fopen(filename[i],"r"); + fp=fopen_(filename[i],"r"); if(fp==NULL){ if(i>0) continue; @@ -348,7 +349,7 @@ static int itemdb_readdb(void) continue; id->equip_script = parse_script(p,lines); } - fclose(fp); + fclose_(fp); printf("read %s done (count=%d)\n",filename[i],ln); } return 0; @@ -388,7 +389,7 @@ static int itemdb_read_randomitem() *pdefault = 0; - if( (fp=fopen(fn,"r"))==NULL ){ + if( (fp=fopen_(fn,"r"))==NULL ){ printf("can't read %s\n",fn); continue; } @@ -424,7 +425,7 @@ static int itemdb_read_randomitem() break; ln++; } - fclose(fp); + fclose_(fp); printf("read %s done (count=%d)\n",fn,*pc); } @@ -442,7 +443,7 @@ static int itemdb_read_itemavail(void) int nameid,j,k; char *str[10],*p; - if( (fp=fopen("db/item_avail.txt","r"))==NULL ){ + if( (fp=fopen_("db/item_avail.txt","r"))==NULL ){ printf("can't read db/item_avail.txt\n"); return -1; } @@ -473,7 +474,7 @@ static int itemdb_read_itemavail(void) id->flag.available = 0; ln++; } - fclose(fp); + fclose_(fp); printf("read db/item_avail.txt done (count=%d)\n",ln); return 0; } @@ -568,7 +569,7 @@ static int itemdb_read_noequip(void) char *str[32],*p; struct item_data *id; - if( (fp=fopen("db/item_noequip.txt","r"))==NULL ){ + if( (fp=fopen_("db/item_noequip.txt","r"))==NULL ){ printf("can't read db/item_noequip.txt\n"); return -1; } @@ -593,7 +594,7 @@ static int itemdb_read_noequip(void) ln++; } - fclose(fp); + fclose_(fp); printf("read db/item_noequip.txt done (count=%d)\n",ln); return 0; } @@ -650,9 +651,9 @@ static int itemdebug(void *key,void *data,va_list ap){ } void itemdebugtxt() { - dfp=fopen("itemdebug.txt","wt"); + dfp=fopen_("itemdebug.txt","wt"); numdb_foreach(item_db,itemdebug); - fclose(dfp); + fclose_(dfp); } */ diff --git a/src/map/magic-interpreter-parser.c b/src/map/magic-interpreter-parser.c index 8cf2312..7ff9fb4 100644 --- a/src/map/magic-interpreter-parser.c +++ b/src/map/magic-interpreter-parser.c @@ -3224,7 +3224,7 @@ magic_init(char *conffile) // must be called after itemdb initialisation INTERN_ASSERT("script_target", VAR_SCRIPTTARGET); INTERN_ASSERT("location", VAR_LOCATION); - magic_frontend_in = fopen(conffile, "r"); + magic_frontend_in = fopen_(conffile, "r"); if (!magic_frontend_in) { fprintf(stderr, "[magic-conf] Magic configuration file `%s' not found -> no magic.\n", conffile); return 0; diff --git a/src/map/magic-interpreter.h b/src/map/magic-interpreter.h index 515b120..4324e53 100644 --- a/src/map/magic-interpreter.h +++ b/src/map/magic-interpreter.h @@ -29,6 +29,7 @@ #include "trade.h" #include "../common/timer.h" +#include "../common/socket.h" #define SPELLARG_NONE 0 /* No spell parameter */ #define SPELLARG_PC 1 /* Spell parameter describes pc (defaults to self) */ diff --git a/src/map/map.c b/src/map/map.c index ee42d3d..86acb62 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1454,7 +1454,7 @@ static void map_readwater(char *watertxt) { FILE *fp=NULL; int n=0; - fp=fopen(watertxt,"r"); + fp=fopen_(watertxt,"r"); if(fp==NULL){ printf("file not found: %s\n",watertxt); return; @@ -1475,7 +1475,7 @@ static void map_readwater(char *watertxt) { waterlist[n].waterheight = 3; n++; } - fclose(fp); + fclose_(fp); } /*========================================== @@ -1665,7 +1665,7 @@ int map_config_read(char *cfgName) { FILE *fp; struct hostent *h = NULL; - fp = fopen(cfgName,"r"); + fp = fopen_(cfgName,"r"); if (fp == NULL) { printf("Map configuration file not found at: %s\n", cfgName); exit(1); @@ -1730,7 +1730,7 @@ int map_config_read(char *cfgName) { } } } - fclose(fp); + fclose_(fp); return 0; } diff --git a/src/map/map.h b/src/map/map.h index 7275734..1c49293 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -358,6 +358,9 @@ struct map_session_data { time_t chat_reset_due; int chat_lines_in; char chat_lastmsg[513]; + + time_t trade_reset_due; + int trades_in; }; struct npc_timerevent_list { diff --git a/src/map/mob.c b/src/map/mob.c index 51a83d2..09395f6 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -3833,7 +3833,7 @@ static int mob_readdb(void) for(i=0;i<2;i++){ - fp=fopen(filename[i],"r"); + fp=fopen_(filename[i],"r"); if(fp==NULL){ if(i>0) continue; @@ -3966,7 +3966,7 @@ static int mob_readdb(void) if (mob_db[class].base_exp == 0) mob_db[class].base_exp = mob_gen_exp(&mob_db[class]); } - fclose(fp); + fclose_(fp); printf("read %s done\n",filename[i]); } return 0; @@ -3984,7 +3984,7 @@ static int mob_readdb_mobavail(void) int class,j,k; char *str[20],*p,*np; - if( (fp=fopen("db/mob_avail.txt","r"))==NULL ){ + if( (fp=fopen_("db/mob_avail.txt","r"))==NULL ){ printf("can't read db/mob_avail.txt\n"); return -1; } @@ -4031,7 +4031,7 @@ static int mob_readdb_mobavail(void) ln++; } - fclose(fp); + fclose_(fp); printf("read db/mob_avail.txt done (count=%d)\n",ln); return 0; } @@ -4054,7 +4054,7 @@ static int mob_read_randommonster(void) for(i=0;i<MAX_RANDOMMONSTER;i++){ mob_db[0].summonper[i] = 1002; // ݒ肵Yꂽꍇ̓|o悤ɂĂ - fp=fopen(mobfile[i],"r"); + fp=fopen_(mobfile[i],"r"); if(fp==NULL){ printf("can't read %s\n",mobfile[i]); return -1; @@ -4078,7 +4078,7 @@ static int mob_read_randommonster(void) if((class>1000 && class<=2000) || class==0) mob_db[class].summonper[i]=per; } - fclose(fp); + fclose_(fp); printf("read %s done\n",mobfile[i]); } return 0; @@ -4153,7 +4153,7 @@ static int mob_readskilldb(void) for(x=0;x<2;x++){ - fp=fopen(filename[x],"r"); + fp=fopen_(filename[x],"r"); if(fp==NULL){ if(x==0) printf("can't read %s\n",filename[x]); @@ -4231,7 +4231,7 @@ static int mob_readskilldb(void) ms->emotion=-1; mob_db[mob_id].maxskill=i+1; } - fclose(fp); + fclose_(fp); printf("read %s done\n",filename[x]); } return 0; diff --git a/src/map/npc.c b/src/map/npc.c index 11725b3..5fe190b 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -21,6 +21,7 @@ #include "pc.h" #include "script.h" #include "skill.h" +#include "../common/socket.h" #ifdef MEMWATCH #include "memwatch.h" @@ -2008,7 +2009,7 @@ int do_init_npc(void) free(nsl->prev); nsl->prev = NULL; } - fp=fopen(nsl->name,"r"); + fp=fopen_(nsl->name,"r"); if (fp==NULL) { printf("file not found : %s\n",nsl->name); exit(1); @@ -2065,7 +2066,7 @@ int do_init_npc(void) npc_parse_mapflag(w1,w2,w3,w4); } } - fclose(fp); + fclose_(fp); printf("\rLoading NPCs [%d]: %-54s",npc_id-START_NPC_NUM,nsl->name); fflush(stdout); } diff --git a/src/map/pc.c b/src/map/pc.c index 630a15b..2e75294 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -798,7 +798,7 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, short tmw_versio { char buf[256]; FILE *fp; - if ((fp = fopen(motd_txt, "r")) != NULL) { + if ((fp = fopen_(motd_txt, "r")) != NULL) { while (fgets(buf, sizeof(buf)-1, fp) != NULL) { int i; for(i=0; buf[i]; i++) { @@ -809,12 +809,14 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, short tmw_versio } clif_displaymessage(sd->fd, buf); } - fclose(fp); + fclose_(fp); } } sd->chat_reset_due = sd->chat_lines_in = 0; sd->chat_lastmsg[0] = '\0'; + + sd->trade_reset_due = sd->trades_in = 0; // message of the limited time of the account if (connect_until_time != 0) { // don't display if it's unlimited or unknow value @@ -7328,7 +7330,7 @@ int pc_readdb(void) // �K�v�o���l�ǂݍ��� - fp=fopen("db/exp.txt","r"); + fp=fopen_("db/exp.txt","r"); if(fp==NULL){ printf("can't read db/exp.txt\n"); return 1; @@ -7358,11 +7360,11 @@ int pc_readdb(void) if(i >= battle_config.maximum_level) break; } - fclose(fp); + fclose_(fp); printf("read db/exp.txt done\n"); // JOB����l�P - fp=fopen("db/job_db1.txt","r"); + fp=fopen_("db/job_db1.txt","r"); if(fp==NULL){ printf("can't read db/job_db1.txt\n"); return 1; @@ -7392,11 +7394,11 @@ int pc_readdb(void) if(i==MAX_PC_CLASS) break; } - fclose(fp); + fclose_(fp); printf("read db/job_db1.txt done\n"); // JOB�{�[�i�X - fp=fopen("db/job_db2.txt","r"); + fp=fopen_("db/job_db2.txt","r"); if(fp==NULL){ printf("can't read db/job_db2.txt\n"); return 1; @@ -7420,11 +7422,11 @@ int pc_readdb(void) if(i==MAX_PC_CLASS) break; } - fclose(fp); + fclose_(fp); printf("read db/job_db2.txt done\n"); // JOB�{�[�i�X2 �]���E�p - fp=fopen("db/job_db2-2.txt","r"); + fp=fopen_("db/job_db2-2.txt","r"); if(fp==NULL){ printf("can't read db/job_db2-2.txt\n"); return 1; @@ -7444,12 +7446,12 @@ int pc_readdb(void) if(i==MAX_PC_CLASS) break; } - fclose(fp); + fclose_(fp); printf("read db/job_db2-2.txt done\n"); // �X�L���c���[ memset(skill_tree,0,sizeof(skill_tree)); - fp=fopen("db/skill_tree.txt","r"); + fp=fopen_("db/skill_tree.txt","r"); if(fp==NULL){ printf("can't read db/skill_tree.txt\n"); return 1; @@ -7478,7 +7480,7 @@ int pc_readdb(void) skill_tree[2][i][j].need[k].lv=atoi(split[k*2+4]); //�{�q�E�͗ǂ��������Ȃ��̂Ŏb�� } } - fclose(fp); + fclose_(fp); printf("read db/skill_tree.txt done\n"); // �����C���e�[�u�� @@ -7486,7 +7488,7 @@ int pc_readdb(void) for(j=0;j<10;j++) for(k=0;k<10;k++) attr_fix_table[i][j][k]=100; - fp=fopen("db/attr_fix.txt","r"); + fp=fopen_("db/attr_fix.txt","r"); if(fp==NULL){ printf("can't read db/attr_fix.txt\n"); return 1; @@ -7524,14 +7526,14 @@ int pc_readdb(void) i++; } } - fclose(fp); + fclose_(fp); printf("read db/attr_fix.txt done\n"); // �T�C�Y��e�[�u�� for(i=0;i<3;i++) for(j=0;j<20;j++) atkmods[i][j]=100; - fp=fopen("db/size_fix.txt","r"); + fp=fopen_("db/size_fix.txt","r"); if(fp==NULL){ printf("can't read db/size_fix.txt\n"); return 1; @@ -7553,7 +7555,7 @@ int pc_readdb(void) atkmods[i][j]=atoi(split[j]); i++; } - fclose(fp); + fclose_(fp); printf("read db/size_fix.txt done\n"); // ���B�f�[�^�e�[�u�� @@ -7564,7 +7566,7 @@ int pc_readdb(void) refinebonus[i][1]=0; refinebonus[i][2]=10; } - fp=fopen("db/refine_db.txt","r"); + fp=fopen_("db/refine_db.txt","r"); if(fp==NULL){ printf("can't read db/refine_db.txt\n"); return 1; @@ -7589,7 +7591,7 @@ int pc_readdb(void) percentrefinery[i][j]=atoi(split[j+3]); i++; } - fclose(fp); //Lupus. close this file!!! + fclose_(fp); //Lupus. close this file!!! printf("read db/refine_db.txt done\n"); return 0; @@ -7617,7 +7619,7 @@ static void pc_statpointdb(void) FILE *stp; - stp=fopen("db/statpoint.txt","r"); + stp=fopen_("db/statpoint.txt","r"); if(stp==NULL){ printf("can't read db/statpoint.txt\n"); @@ -7630,7 +7632,7 @@ static void pc_statpointdb(void) buf_stat = (char *) malloc (end + 1); l = fread(buf_stat,1,end,stp); - fclose(stp); + fclose_(stp); printf("read db/statpoint.txt done (size=%d)\n",l); for(i=0;i<255;i++) { diff --git a/src/map/script.c b/src/map/script.c index 94f03f7..218c3f3 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -1090,7 +1090,7 @@ static void read_constdb(void) char line[1024],name[1024]; int val,n,i,type; - fp=fopen("db/const.txt","r"); + fp=fopen_("db/const.txt","r"); if(fp==NULL){ printf("can't read db/const.txt\n"); return ; @@ -1111,7 +1111,7 @@ static void read_constdb(void) str_data[n].val=val; } } - fclose(fp); + fclose_(fp); } /*========================================== @@ -6549,7 +6549,7 @@ static int script_load_mapreg() FILE *fp; char line[1024]; - if( (fp=fopen(mapreg_txt,"rt"))==NULL ) + if( (fp=fopen_(mapreg_txt,"rt"))==NULL ) return -1; while(fgets(line,sizeof(line),fp)){ @@ -6576,7 +6576,7 @@ static int script_load_mapreg() numdb_insert(mapreg_db,(i<<24)|s,v); } } - fclose(fp); + fclose_(fp); mapreg_dirty=0; return 0; } @@ -6666,7 +6666,7 @@ int script_config_read(char *cfgName) script_config.check_cmdcount=8192; script_config.check_gotocount=512; - fp=fopen(cfgName,"r"); + fp=fopen_(cfgName,"r"); if(fp==NULL){ printf("file not found: %s\n",cfgName); return 1; @@ -6684,7 +6684,7 @@ int script_config_read(char *cfgName) script_config_read(w2); } } - fclose(fp); + fclose_(fp); return 0; } diff --git a/src/map/skill.c b/src/map/skill.c index 3a777ac..c661dc2 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -21,6 +21,7 @@ #include "pc.h" #include "script.h" #include "skill.h" +#include "../common/socket.h" #ifdef MEMWATCH #include "memwatch.h" @@ -9890,7 +9891,7 @@ int skill_readdb(void) /* The main skill database */ memset(skill_db,0,sizeof(skill_db)); - fp=fopen("db/skill_db.txt","r"); + fp=fopen_("db/skill_db.txt","r"); if(fp==NULL){ printf("can't read db/skill_db.txt\n"); return 1; @@ -9959,10 +9960,10 @@ int skill_readdb(void) for(k=0;k<MAX_SKILL_LEVEL;k++) skill_db[i].blewcount[k]=(split2[k])? atoi(split2[k]):atoi(split2[0]); } - fclose(fp); + fclose_(fp); printf("read db/skill_db.txt done\n"); - fp=fopen("db/skill_require_db.txt","r"); + fp=fopen_("db/skill_require_db.txt","r"); if(fp==NULL){ printf("can't read db/skill_require_db.txt\n"); return 1; @@ -10097,11 +10098,11 @@ int skill_readdb(void) skill_db[i].itemid[9]=atoi(split[28]); skill_db[i].amount[9]=atoi(split[29]); } - fclose(fp); + fclose_(fp); printf("read db/skill_require_db.txt done\n"); /* ? */ - fp=fopen("db/skill_cast_db.txt","r"); + fp=fopen_("db/skill_cast_db.txt","r"); if(fp==NULL){ printf("can't read db/skill_cast_db.txt\n"); return 1; @@ -10160,10 +10161,10 @@ int skill_readdb(void) for(k=0;k<MAX_SKILL_LEVEL;k++) skill_db[i].upkeep_time2[k]=(split2[k])? atoi(split2[k]):atoi(split2[0]); } - fclose(fp); + fclose_(fp); printf("read db/skill_cast_db.txt done\n"); - fp=fopen("db/skill_castnodex_db.txt","r"); + fp=fopen_("db/skill_castnodex_db.txt","r"); if(fp==NULL){ printf("can't read db/skill_castnodex_db.txt\n"); return 1; @@ -10193,7 +10194,7 @@ int skill_readdb(void) for(k=0;k<MAX_SKILL_LEVEL;k++) skill_db[i].castnodex[k]=(split2[k])? atoi(split2[k]):atoi(split2[0]); } - fclose(fp); + fclose_(fp); printf("read db/skill_castnodex_db.txt done\n"); return 0; diff --git a/src/map/tmw.c b/src/map/tmw.c index ba02189..5d4c991 100644 --- a/src/map/tmw.c +++ b/src/map/tmw.c @@ -116,3 +116,36 @@ void tmw_GmHackMsg(const char *fmt, ...) { intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, outbuf, strlen(outbuf) + 1); } + +int tmw_CheckTradeSpam(struct map_session_data *sd) { + nullpo_retr(1, sd); + time_t now = time(NULL); + + if (pc_isGM(sd)) return 0; + + if (now > sd->trade_reset_due) { + sd->trade_reset_due = now + battle_config.trade_spam_threshold; + sd->trades_in = 0; + } + + sd->trades_in++; + + if (sd->trades_in >= battle_config.trade_spam_flood) { + sd->trades_in = 0; + tmw_GmHackMsg("Trade spam detected from character '%s' (account: %d)", sd->status.name, sd->status.account_id); + + if (battle_config.trade_spam_ban > 0) { + clif_displaymessage(sd->fd, "You have been banned for trade spamming. Please do not trade spam."); + tmw_GmHackMsg("This player has been banned for %d hour(s).", battle_config.trade_spam_ban); + + chrif_char_ask_name(-1, sd->status.name, 2, 0, 0, 0, battle_config.trade_spam_ban, 0, 0); // type: 2 - ban (year, month, day, hour, minute, second) + clif_setwaitclose(sd->fd); + } + } + + if (battle_config.trade_spam_ban && sd->trades_in >= battle_config.trade_spam_warn) { + clif_displaymessage(sd->fd, "WARNING : You are about to be automaticly banned for trade spam!"); + } + + return 0; +} diff --git a/src/map/tmw.h b/src/map/tmw.h index 87066d9..92bcaf4 100644 --- a/src/map/tmw.h +++ b/src/map/tmw.h @@ -5,3 +5,4 @@ int tmw_CheckChatSpam(struct map_session_data *sd, char* message); int tmw_CheckChatLameness(struct map_session_data *sd, char *message); void tmw_GmHackMsg(const char *fmt, ...); +int tmw_CheckTradeSpam(struct map_session_data *sd); |