/* * Client is requesting to move a charslot */ int chclif_parse_moveCharSlot( int fd, struct char_session_data* sd){ uint16 from, to; if( RFIFOREST(fd) < 8 ) return 0; from = RFIFOW(fd,2); to = RFIFOW(fd,4); //Cnt = RFIFOW(fd,6); //how many time we have left to change (client.. lol we don't trust him) RFIFOSKIP(fd,8); // Have we changed to often or is it disabled? if( (charserv_config.charmove_config.char_move_enabled)==0 || ( (charserv_config.charmove_config.char_moves_unlimited)==0 && sd->char_moves[from] <= 0 ) ){ chclif_moveCharSlotReply( fd, sd, from, 1 ); return 1; } // We don't even have a character on the chosen slot? if( sd->found_char[from] <= 0 || to >= sd->char_slots ){ chclif_moveCharSlotReply( fd, sd, from, 1 ); return 1; } if( sd->found_char[to] > 0 ){ // We want to move to a used position if( charserv_config.charmove_config.char_movetoused ){ // TODO: check if the target is in deletion process // Admin is friendly and uses triangle exchange if( SQL_ERROR == Sql_QueryStr(sql_handle, "START TRANSACTION") || SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `char_num`='%d' WHERE `char_id` = '%d'",schema_config.char_db, to, sd->found_char[from] ) || SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `char_num`='%d' WHERE `char_id` = '%d'", schema_config.char_db, from, sd->found_char[to] ) || SQL_ERROR == Sql_QueryStr(sql_handle, "COMMIT") ){ chclif_moveCharSlotReply( fd, sd, from, 1 ); Sql_ShowDebug(sql_handle); Sql_QueryStr(sql_handle,"ROLLBACK"); return 1; } }else{ // Admin doesn't allow us to chclif_moveCharSlotReply( fd, sd, from, 1 ); return 1; } }else if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `char_num`='%d' WHERE `char_id`='%d'", schema_config.char_db, to, sd->found_char[from] ) ){ Sql_ShowDebug(sql_handle); chclif_moveCharSlotReply( fd, sd, from, 1 ); return 1; } if( (charserv_config.charmove_config.char_moves_unlimited)==0 ){ sd->char_moves[from]--; Sql_Query(sql_handle, "UPDATE `%s` SET `moves`='%d' WHERE `char_id`='%d'", schema_config.char_db, sd->char_moves[from], sd->found_char[from] ); } // We successfully moved the char - time to notify the client chclif_moveCharSlotReply( fd, sd, from, 0 ); chclif_mmo_char_send(fd, sd); return 1; }
int chlogif_parse_reqaccdata(int fd, struct char_session_data* sd){ int u_fd; //user fd if (RFIFOREST(fd) < 79) return 0; // find the authenticated session with this account id ARR_FIND( 0, fd_max, u_fd, session[u_fd] && (sd = (struct char_session_data*)session[u_fd]->session_data) && sd->auth && sd->account_id == RFIFOL(fd,2) ); if( u_fd < fd_max ) { int server_id; memcpy(sd->email, RFIFOP(fd,6), 40); sd->expiration_time = (time_t)RFIFOL(fd,46); sd->group_id = RFIFOB(fd,50); sd->char_slots = RFIFOB(fd,51); if( sd->char_slots > MAX_CHARS ) { ShowError("Account '%d' `character_slots` column is higher than supported MAX_CHARS (%d), update MAX_CHARS in mmo.h! capping to MAX_CHARS...\n",sd->account_id,sd->char_slots); sd->char_slots = MAX_CHARS;/* cap to maximum */ } else if ( !sd->char_slots )/* no value aka 0 in sql */ sd->char_slots = MIN_CHARS;/* cap to minimum */ safestrncpy(sd->birthdate, (const char*)RFIFOP(fd,52), sizeof(sd->birthdate)); safestrncpy(sd->pincode, (const char*)RFIFOP(fd,63), sizeof(sd->pincode)); sd->pincode_change = (time_t)RFIFOL(fd,68); sd->bank_vault = RFIFOL(fd,72); sd->isvip = RFIFOB(fd,76); sd->chars_vip = RFIFOB(fd,77); sd->chars_billing = RFIFOB(fd,78); ARR_FIND( 0, ARRAYLENGTH(map_server), server_id, map_server[server_id].fd > 0 && map_server[server_id].map[0] ); // continued from char_auth_ok... if( server_id == ARRAYLENGTH(map_server) || //server not online, bugreport:2359 (charserv_config.max_connect_user == 0 && sd->group_id != charserv_config.gm_allow_group) || ( charserv_config.max_connect_user > 0 && char_count_users() >= charserv_config.max_connect_user && sd->group_id != charserv_config.gm_allow_group ) ) { // refuse connection (over populated) WFIFOHEAD(u_fd,3); WFIFOW(u_fd,0) = 0x6c; WFIFOW(u_fd,2) = 0; WFIFOSET(u_fd,3); } else { // send characters to player chclif_mmo_char_send(u_fd, sd); if(sd->version >= date2version(20110309)){ ShowInfo("Asking to start pincode\n"); chlogif_pincode_start(u_fd,sd); } } } RFIFOSKIP(fd,79); return 1; }
/// @param result /// 0 (0x718): An unknown error has occurred. /// 1: none/success /// 2 (0x71c): Due to system settings can not be deleted. /// 3 (0x719): A database error occurred. /// 4 (0x71d): Deleting not yet possible time. /// 5 (0x71e): Date of birth do not match. /// Any (0x718): An unknown error has occurred. /// HC: <082a>.W <char id>.L <Msg:0-5>.L void chclif_char_delete2_accept_ack(int fd, uint32 char_id, uint32 result) { if(result == 1 ){ struct char_session_data* sd; sd = (struct char_session_data*)session[fd]->session_data; if( sd->version >= date2version(20130000) ){ chclif_mmo_char_send(fd, sd); } } WFIFOHEAD(fd,10); WFIFOW(fd,0) = 0x82a; WFIFOL(fd,2) = char_id; WFIFOL(fd,6) = result; WFIFOSET(fd,10); }
/** * Receive account data from login-server * AH 0x2717 <aid>.L <email>.40B <expiration_time>.L <group_id>.B <birthdate>.11B <pincode>.5B <pincode_change>.L <isvip>.B <char_vip>.B <char_billing>.B **/ int chlogif_parse_reqaccdata(int fd, struct char_session_data* sd){ int u_fd; //user fd if (RFIFOREST(fd) < 75) return 0; // find the authenticated session with this account id ARR_FIND( 0, fd_max, u_fd, session[u_fd] && (sd = (struct char_session_data*)session[u_fd]->session_data) && sd->auth && sd->account_id == RFIFOL(fd,2) ); if( u_fd < fd_max ) { int server_id; memcpy(sd->email, RFIFOP(fd,6), 40); sd->expiration_time = (time_t)RFIFOL(fd,46); sd->group_id = RFIFOB(fd,50); sd->char_slots = RFIFOB(fd,51); if( sd->char_slots > MAX_CHARS ) { ShowError("Account '%d' `character_slots` column is higher than supported MAX_CHARS (%d), update MAX_CHARS in mmo.hpp! capping to MAX_CHARS...\n",sd->account_id,sd->char_slots); sd->char_slots = MAX_CHARS;/* cap to maximum */ } else if ( !sd->char_slots )/* no value aka 0 in sql */ sd->char_slots = MIN_CHARS;/* cap to minimum */ safestrncpy(sd->birthdate, RFIFOCP(fd,52), sizeof(sd->birthdate)); safestrncpy(sd->pincode, RFIFOCP(fd,63), sizeof(sd->pincode)); sd->pincode_change = (time_t)RFIFOL(fd,68); sd->isvip = RFIFOB(fd,72); sd->chars_vip = RFIFOB(fd,73); sd->chars_billing = RFIFOB(fd,74); ARR_FIND( 0, ARRAYLENGTH(map_server), server_id, map_server[server_id].fd > 0 && map_server[server_id].map[0] ); // continued from char_auth_ok... if( server_id == ARRAYLENGTH(map_server) || //server not online, bugreport:2359 (((charserv_config.max_connect_user == 0 || charserv_config.char_maintenance == 1) || (charserv_config.max_connect_user > 0 && char_count_users() >= charserv_config.max_connect_user)) && sd->group_id < charserv_config.gm_allow_group)) { // refuse connection (over populated) chclif_reject(u_fd,0); } else { // send characters to player chclif_mmo_char_send(u_fd, sd); #if PACKETVER_SUPPORTS_PINCODE chlogif_pincode_start(u_fd,sd); #endif } } RFIFOSKIP(fd,75); return 1; }