diff options
Diffstat (limited to 'src/char_sql/char.c')
-rw-r--r-- | src/char_sql/char.c | 74 |
1 files changed, 24 insertions, 50 deletions
diff --git a/src/char_sql/char.c b/src/char_sql/char.c index 46b645ce6..262f585d2 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -202,7 +202,7 @@ static void* create_online_char_data(DBKey key, va_list args) character->char_id = -1; character->server = -1; character->fd = -1; - character->waiting_disconnect = -1; + character->waiting_disconnect = INVALID_TIMER; return character; } @@ -219,9 +219,9 @@ void set_char_charselect(int account_id) character->char_id = -1; character->server = -1; - if(character->waiting_disconnect != -1) { + if(character->waiting_disconnect != INVALID_TIMER) { delete_timer(character->waiting_disconnect, chardb_waiting_disconnect); - character->waiting_disconnect = -1; + character->waiting_disconnect = INVALID_TIMER; } if (login_fd > 0 && !session[login_fd]->flag.eof) @@ -260,9 +260,9 @@ void set_char_online(int map_id, int char_id, int account_id) server[character->server].users++; //Get rid of disconnect timer - if(character->waiting_disconnect != -1) { + if(character->waiting_disconnect != INVALID_TIMER) { delete_timer(character->waiting_disconnect, chardb_waiting_disconnect); - character->waiting_disconnect = -1; + character->waiting_disconnect = INVALID_TIMER; } //Set char online in guild cache. If char is in memory, use the guild id on it, otherwise seek it. @@ -305,9 +305,9 @@ void set_char_offline(int char_id, int account_id) if( server[character->server].users > 0 ) // Prevent this value from going negative. server[character->server].users--; - if(character->waiting_disconnect != -1){ + if(character->waiting_disconnect != INVALID_TIMER){ delete_timer(character->waiting_disconnect, chardb_waiting_disconnect); - character->waiting_disconnect = -1; + character->waiting_disconnect = INVALID_TIMER; } if(character->char_id == char_id) @@ -336,9 +336,9 @@ static int char_db_setoffline(DBKey key, void* data, va_list ap) if (server == -1) { character->char_id = -1; character->server = -1; - if(character->waiting_disconnect != -1){ + if(character->waiting_disconnect != INVALID_TIMER){ delete_timer(character->waiting_disconnect, chardb_waiting_disconnect); - character->waiting_disconnect = -1; + character->waiting_disconnect = INVALID_TIMER; } } else if (character->server == server) character->server = -2; //In some map server that we aren't connected to. @@ -356,7 +356,7 @@ static int char_db_kickoffline(DBKey key, void* data, va_list ap) //Kick out any connected characters, and set them offline as appropiate. if (character->server > -1) mapif_disconnectplayer(server[character->server].fd, character->account_id, character->char_id, 1); - else if (character->waiting_disconnect == -1) + else if (character->waiting_disconnect == INVALID_TIMER) set_char_offline(character->char_id, character->account_id); else return 0; // fail @@ -1722,7 +1722,7 @@ static void char_auth_ok(int fd, struct char_session_data *sd) if (character->server > -1) { //Character already online. KICK KICK KICK mapif_disconnectplayer(server[character->server].fd, character->account_id, character->char_id, 2); - if (character->waiting_disconnect == -1) + if (character->waiting_disconnect == INVALID_TIMER) character->waiting_disconnect = add_timer(gettick()+20000, chardb_waiting_disconnect, character->account_id, 0); WFIFOW(fd,0) = 0x81; WFIFOB(fd,2) = 8; @@ -1801,7 +1801,7 @@ int parse_fromlogin(int fd) ShowStatus("Connected to login-server (connection #%d).\n", fd); //Send online accounts to login server. - send_accounts_tologin(-1, gettick(), 0, 0); + send_accounts_tologin(INVALID_TIMER, gettick(), 0, 0); // if no map-server already connected, display a message... ARR_FIND( 0, MAX_MAP_SERVERS, i, server[i].fd > 0 && server[i].map[0] ); @@ -2008,7 +2008,7 @@ int parse_fromlogin(int fd) if( character->server > -1 ) { //Kick it from the map server it is on. mapif_disconnectplayer(server[character->server].fd, character->account_id, character->char_id, 2); - if (character->waiting_disconnect == -1) + if (character->waiting_disconnect == INVALID_TIMER) character->waiting_disconnect = add_timer(gettick()+AUTH_TIMEOUT, chardb_waiting_disconnect, character->account_id, 0); } else @@ -3256,7 +3256,7 @@ int parse_char(int fd) ShowInfo(CL_RED"Request Char Deletion: "CL_GREEN"%d (%d)"CL_RESET"\n", sd->account_id, cid); memcpy(email, RFIFOP(fd,6), 40); - RFIFOSKIP(fd,RFIFOREST(fd)); // hack to make the other deletion packet work + RFIFOSKIP(fd,( cmd == 0x68) ? 46 : 56); // Check if e-mail is correct if(strcmpi(email, sd->email) && //email does not matches and @@ -3429,22 +3429,6 @@ int parse_char(int fd) } return 0; // avoid processing of followup packets here - // Athena info get - case 0x7530: - WFIFOHEAD(fd,10); - WFIFOW(fd,0) = 0x7531; - WFIFOB(fd,2) = ATHENA_MAJOR_VERSION; - WFIFOB(fd,3) = ATHENA_MINOR_VERSION; - WFIFOB(fd,4) = ATHENA_REVISION; - WFIFOB(fd,5) = ATHENA_RELEASE_FLAG; - WFIFOB(fd,6) = ATHENA_OFFICIAL_FLAG; - WFIFOB(fd,7) = ATHENA_SERVER_INTER | ATHENA_SERVER_CHAR; - WFIFOW(fd,8) = ATHENA_MOD_VERSION; - WFIFOSET(fd,10); - - RFIFOSKIP(fd,2); - break; - // unknown packet received default: ShowError("parse_char: Received unknown packet "CL_WHITE"0x%x"CL_RESET" from ip '"CL_WHITE"%s"CL_RESET"'! Disconnecting!\n", RFIFOW(fd,0), ip2str(ipl, NULL)); @@ -3458,29 +3442,19 @@ int parse_char(int fd) } // Console Command Parser [Wizputer] -int parse_console(char* buf) +int parse_console(const char* command) { - char command[256]; + ShowNotice("Console command: %s\n", command); - memset(command, 0, sizeof(command)); - - sscanf(buf, "%[^\n]", command); - - //login_log("Console command :%s\n", command); - - if( strcmpi("shutdown", command) == 0 || - strcmpi("exit", command) == 0 || - strcmpi("quit", command) == 0 || - strcmpi("end", command) == 0 ) + if( strcmpi("shutdown", command) == 0 || strcmpi("exit", command) == 0 || strcmpi("quit", command) == 0 || strcmpi("end", command) == 0 ) runflag = 0; - else if( strcmpi("alive", command) == 0 || - strcmpi("status", command) == 0 ) + else if( strcmpi("alive", command) == 0 || strcmpi("status", command) == 0 ) ShowInfo(CL_CYAN"Console: "CL_BOLD"I'm Alive."CL_RESET"\n"); - else if( strcmpi("help", command) == 0 ){ - ShowInfo(CL_BOLD"Help of commands:"CL_RESET"\n"); - ShowInfo(" To shutdown the server:\n"); - ShowInfo(" 'shutdown|exit|qui|end'\n"); - ShowInfo(" To know if server is alive:\n"); + else if( strcmpi("help", command) == 0 ) + { + ShowInfo("To shutdown the server:\n"); + ShowInfo(" 'shutdown|exit|quit|end'\n"); + ShowInfo("To know if server is alive:\n"); ShowInfo(" 'alive|status'\n"); } @@ -3654,7 +3628,7 @@ static int chardb_waiting_disconnect(int tid, unsigned int tick, int id, intptr struct online_char_data* character; if ((character = (struct online_char_data*)idb_get(online_char_db, id)) != NULL && character->waiting_disconnect == tid) { //Mark it offline due to timeout. - character->waiting_disconnect = -1; + character->waiting_disconnect = INVALID_TIMER; set_char_offline(character->char_id, character->account_id); } return 0; |