//character selected, insert into auth db void chrif_authok(int fd) { struct auth_node *auth_data; TBL_PC* sd; //Check if we don't already have player data in our server //(prevents data that is to be saved from being overwritten by //this received status data if this auth is later successful) [Skotlex] if ((sd = map_id2sd(RFIFOL(fd, 4))) != NULL) { struct mmo_charstatus *status = (struct mmo_charstatus *)RFIFOP(fd, 20); //Auth check is because this could be the very same sd that is waiting char-server authorization. if (sd->state.auth && sd->status.char_id == status->char_id) return; } if ((auth_data =uidb_get(auth_db, RFIFOL(fd, 4))) != NULL) { //Is the character already awaiting authorization? if (auth_data->sd) { //First, check to see if the session data still exists (avoid dangling pointers) if(session[auth_data->fd] && session[auth_data->fd]->session_data == auth_data->sd) { if (auth_data->char_dat == NULL && auth_data->account_id == RFIFOL(fd, 4) && auth_data->login_id1 == RFIFOL(fd, 8)) { //Auth Ok pc_authok(auth_data->sd, RFIFOL(fd, 16), RFIFOL(fd, 12), (struct mmo_charstatus*)RFIFOP(fd, 20)); } else { //Auth Failed pc_authfail(auth_data->sd); chrif_char_offline(auth_data->sd); //Set him offline, the char server likely has it set as online already. } } //else: Character no longer exists, just go through. } //Delete the data of this node... if (auth_data->char_dat) aFree (auth_data->char_dat); uidb_remove(auth_db, RFIFOL(fd, 4)); return; } // Awaiting for client to connect. auth_data = (struct auth_node *)aCalloc(1,sizeof(struct auth_node)); auth_data->char_dat = (struct mmo_charstatus *) aCalloc(1,sizeof(struct mmo_charstatus)); auth_data->account_id=RFIFOL(fd, 4); auth_data->login_id1=RFIFOL(fd, 8); auth_data->connect_until_time=RFIFOL(fd, 12); auth_data->login_id2=RFIFOL(fd, 16); memcpy(auth_data->char_dat,RFIFOP(fd, 20),sizeof(struct mmo_charstatus)); auth_data->node_created=gettick(); uidb_put(auth_db, RFIFOL(fd, 4), auth_data); }
int login_clear_lockout(int i, int d) { uidb_remove(bf_lockout,(unsigned int)i); return 1; }