diff options
author | shennetsind <ind@henn.et> | 2013-11-18 22:16:54 -0200 |
---|---|---|
committer | shennetsind <ind@henn.et> | 2013-11-18 22:16:54 -0200 |
commit | 39f1ad79f93bfc72aa6c9512c21e92d52c983426 (patch) | |
tree | 6f941b7df0cc53d2a44e4efd6bd1fe5366f1660f | |
parent | ea7dd2157c6d92eb42da567032578ad47e790a8e (diff) | |
download | hercules-39f1ad79f93bfc72aa6c9512c21e92d52c983426.tar.gz hercules-39f1ad79f93bfc72aa6c9512c21e92d52c983426.tar.bz2 hercules-39f1ad79f93bfc72aa6c9512c21e92d52c983426.tar.xz hercules-39f1ad79f93bfc72aa6c9512c21e92d52c983426.zip |
Follow up aee2f6317e1c927847993801b5973d7e2e27a418
Fixed glitch that'd occur in clients with login screen where even after logging out the client would still remember previously sent banned timestamps, keeping the char banned until client was reopened.
Also dropped a error message map server would show up when banning offline characters.
Special Thanks to Mvmbles for pointing it out, Haruna for testing and helping fix it.
Signed-off-by: shennetsind <ind@henn.et>
-rw-r--r-- | src/char/char.c | 26 | ||||
-rw-r--r-- | src/map/chrif.c | 4 |
2 files changed, 20 insertions, 10 deletions
diff --git a/src/char/char.c b/src/char/char.c index ce05f32f4..f1b95474e 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -1004,7 +1004,7 @@ int mmo_chars_fromsql(struct char_session_data* sd, uint8* buf) struct mmo_charstatus p; int j = 0, i; char last_map[MAP_NAME_LENGTH_EXT]; - size_t unban_time; + time_t unban_time; stmt = SQL->StmtMalloc(sql_handle); if( stmt == NULL ) { @@ -1949,9 +1949,9 @@ void mmo_char_send099d(int fd, struct char_session_data *sd) { void mmo_char_send020d(int fd, struct char_session_data *sd) { int i; time_t now = time(NULL); - - ARR_FIND(0, MAX_CHARS, i, sd->unban_time[i] > now); - + + ARR_FIND(0, MAX_CHARS, i, sd->unban_time[i]); + if( i != MAX_CHARS ) { int c; @@ -1960,9 +1960,19 @@ void mmo_char_send020d(int fd, struct char_session_data *sd) { WFIFOW(fd, 0) = 0x20d; for(i = 0, c = 0; i < MAX_CHARS; i++) { - if( sd->unban_time[i] > now ) { - WFIFOL(fd, 4 + (24*c)) = sd->found_char[i]; + if( sd->unban_time[i] ) { timestamp2string((char*)WFIFOP(fd,8 + (28*c)), 20, sd->unban_time[i], "%Y-%m-%d %H:%M:%S"); + + if( sd->unban_time[i] > now ) + WFIFOL(fd, 4 + (24*c)) = sd->found_char[i]; + else { + /* reset -- client keeps this information even if you logout so we need to clear */ + WFIFOL(fd, 4 + (24*c)) = 0; + /* also update on mysql */ + sd->unban_time[i] = 0; + if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `unban_time`='0' WHERE `char_id`='%d' LIMIT 1", char_db, sd->found_char[i]) ) + Sql_ShowDebug(sql_handle); + } c++; } } @@ -2338,7 +2348,7 @@ int parse_fromlogin(int fd) { #else mmo_char_send006b(i, sd); #endif - #if PACKETVER >= 20080000 + #if PACKETVER >= 20060819 mmo_char_send020d(i, sd); #endif #if PACKETVER >= 20110309 @@ -3301,7 +3311,7 @@ int parse_frommap(int fd) unsigned char buf[11]; WBUFW(buf,0) = 0x2b14; - WBUFL(buf,2) = account_id; + WBUFL(buf,2) = char_id; WBUFB(buf,6) = 2; WBUFL(buf,7) = (unsigned int)timestamp; mapif_sendall(buf, 11); diff --git a/src/map/chrif.c b/src/map/chrif.c index 8e6034ef2..5927e31bf 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -979,8 +979,8 @@ int chrif_idbanned(int fd) { sd = ( RFIFOB(fd,6) == 2 ) ? map->charid2sd(id) : map->id2sd(id); - if ( id < 0 || sd == NULL ) {/* ?___? is this worth showing a error for? you might wanna ban a player that is not online, this is not a error and the operation is still valid */ - ShowError("chrif_idbanned failed - player not online.\n"); + if ( id < 0 || sd == NULL ) { + /* player not online or unknown id, either way no error is necessary (since if you try to ban a offline char it still works) */ return 0; } |