diff options
author | wizputer <wizputer@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2004-11-28 04:42:06 +0000 |
---|---|---|
committer | wizputer <wizputer@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2004-11-28 04:42:06 +0000 |
commit | bd6e84abfbb76a56b93597761fd5158a3aa265d5 (patch) | |
tree | ffea4c2b24c62217d87e54364b497f2e632ec5ed /src/map/chrif.c | |
parent | eb542a6335c6b6c91a9429f8975e7feab84ce4ff (diff) | |
download | hercules-bd6e84abfbb76a56b93597761fd5158a3aa265d5.tar.gz hercules-bd6e84abfbb76a56b93597761fd5158a3aa265d5.tar.bz2 hercules-bd6e84abfbb76a56b93597761fd5158a3aa265d5.tar.xz hercules-bd6e84abfbb76a56b93597761fd5158a3aa265d5.zip |
* Fixed a few map crashes when char-server crashes [Wizputer]
* Added fix of 0x2aff and 0x2af8 flooding [Wizputer - thanks Toster]
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@395 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/chrif.c')
-rw-r--r-- | src/map/chrif.c | 51 |
1 files changed, 37 insertions, 14 deletions
diff --git a/src/map/chrif.c b/src/map/chrif.c index a0706f594..479b328f5 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -98,7 +98,7 @@ int chrif_save(struct map_session_data *sd) { nullpo_retr(-1, sd); - if (char_fd < 0) + if (char_fd < 1) return -1; pc_makesavestatus(sd); @@ -184,7 +184,10 @@ int chrif_changemapserver(struct map_session_data *sd, char *name, int x, int y, int i, s_ip; nullpo_retr(-1, sd); - + + if (!sd || char_fd < 1 ) + return -1; + s_ip = 0; for(i = 0; i < fd_max; i++) if (session[i] && session[i]->session_data == sd) { @@ -283,7 +286,7 @@ int chrif_authreq(struct map_session_data *sd) nullpo_retr(-1, sd); - if (!sd || !char_fd || !sd->bl.id || !sd->login_id1) + if (!sd || char_fd < 1 || !sd->bl.id || !sd->login_id1) return -1; for(i = 0; i < fd_max; i++) @@ -311,7 +314,7 @@ int chrif_charselectreq(struct map_session_data *sd) nullpo_retr(-1, sd); - if(!sd || !char_fd || !sd->bl.id || !sd->login_id1) + if(!sd || char_fd < 1 || !sd->bl.id || !sd->login_id1) return -1; s_ip = 0; @@ -337,7 +340,7 @@ int chrif_charselectreq(struct map_session_data *sd) */ int chrif_searchcharid(int char_id) { - if (!char_id) + if (!char_id || char_fd < 1) return -1; WFIFOW(char_fd,0) = 0x2b08; @@ -355,6 +358,9 @@ int chrif_changegm(int id, const char *pass, int len) { if (battle_config.etc_log) printf("chrif_changegm: account: %d, password: '%s'.\n", id, pass); + + if (char_fd < 1 ) + return -1; WFIFOW(char_fd,0) = 0x2b0a; WFIFOW(char_fd,2) = len + 8; @@ -373,7 +379,10 @@ int chrif_changeemail(int id, const char *actual_email, const char *new_email) { if (battle_config.etc_log) printf("chrif_changeemail: account: %d, actual_email: '%s', new_email: '%s'.\n", id, actual_email, new_email); - + + if (char_fd < 1 ) + return -1; + WFIFOW(char_fd,0) = 0x2b0c; WFIFOL(char_fd,2) = id; memcpy(WFIFOP(char_fd,6), actual_email, 40); @@ -396,6 +405,9 @@ int chrif_changeemail(int id, const char *actual_email, const char *new_email) */ int chrif_char_ask_name(int id, char * character_name, short operation_type, int year, int month, int day, int hour, int minute, int second) { + if (char_fd < 1 ) + return -1; + WFIFOW(char_fd, 0) = 0x2b0e; WFIFOL(char_fd, 2) = id; // account_id of who ask (for answer) -1 if nobody memcpy(WFIFOP(char_fd,6), character_name, 24); @@ -419,6 +431,9 @@ int chrif_char_ask_name(int id, char * character_name, short operation_type, int *------------------------------------------ */ int chrif_changesex(int id, int sex) { + if (char_fd < 1 ) + return -1; + WFIFOW(char_fd,0) = 0x3000; WFIFOW(char_fd,2) = 9; WFIFOL(char_fd,4) = id; @@ -649,7 +664,10 @@ int chrif_saveaccountreg2(struct map_session_data *sd) { int p, j; nullpo_retr(-1, sd); - + + if (char_fd < 1 ) + return -1; + p = 8; for(j = 0; j < sd->status.account_reg2_num; j++) { struct global_reg *reg = &sd->status.account_reg2[j]; @@ -820,7 +838,7 @@ int chrif_chardisconnect(struct map_session_data *sd) { nullpo_retr(-1, sd); - if(char_fd<=0) + if(char_fd < 1) return -1; WFIFOW(char_fd,0)=0x2b18; @@ -849,7 +867,9 @@ int chrif_recvgmaccounts(int fd) */ int chrif_reloadGMdb(void) { - + if (char_fd < 1 ) + return -1; + WFIFOW(char_fd,0) = 0x2af7; WFIFOSET(char_fd, 2); @@ -865,7 +885,10 @@ int chrif_reloadGMdb(void) char buf[256]; FILE *fp; int i; - + + if (char_fd < 1 ) + return -1; + WFIFOW(char_fd,0) = 0x2b16; WFIFOW(char_fd,2) = base_rate; WFIFOW(char_fd,4) = job_rate; @@ -899,7 +922,7 @@ int chrif_reloadGMdb(void) int chrif_char_offline(struct map_session_data *sd) { - if (char_fd < 0) + if (char_fd < 1) return -1; WFIFOW(char_fd,0) = 0x2b17; @@ -915,7 +938,7 @@ int chrif_char_offline(struct map_session_data *sd) *----------------------------------------- */ int chrif_char_reset_offline(void) { - if (char_fd < 0) + if (char_fd < 1) return -1; WFIFOW(char_fd,0) = 0x2b18; @@ -931,7 +954,7 @@ int chrif_char_reset_offline(void) { int chrif_char_online(struct map_session_data *sd) { - if (char_fd < 0) + if (char_fd < 1) return -1; WFIFOW(char_fd,0) = 0x2b19; @@ -1025,7 +1048,7 @@ int send_users_tochar(int tid, unsigned int tick, int id, int data) { int users = 0, i; struct map_session_data *sd; - if (char_fd <= 0 || session[char_fd] == NULL) + if (char_fd < 1 || session[char_fd] == NULL || !chrif_isconnect()) // Thanks to Toster return 0; WFIFOW(char_fd,0) = 0x2aff; |