本文整理汇总了C++中RFIFOREST函数的典型用法代码示例。如果您正苦于以下问题:C++ RFIFOREST函数的具体用法?C++ RFIFOREST怎么用?C++ RFIFOREST使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RFIFOREST函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: chmapif_parse_regmapuser
/**
* Map-serv sent us all his users info, (aid and cid) so we can update online_char_db
* @param fd: wich fd to parse from
* @param id: wich map_serv id
* @return : 0 not enough data received, 1 success
*/
int chmapif_parse_regmapuser(int fd, int id){
if (RFIFOREST(fd) < 6 || RFIFOREST(fd) < RFIFOW(fd,2))
return 0;
{
//TODO: When data mismatches memory, update guild/party online/offline states.
DBMap* online_char_db = char_get_onlinedb();
int i;
map_server[id].users = RFIFOW(fd,4);
online_char_db->foreach(online_char_db,char_db_setoffline,id); //Set all chars from this server as 'unknown'
for(i = 0; i < map_server[id].users; i++) {
int aid = RFIFOL(fd,6+i*8);
int cid = RFIFOL(fd,6+i*8+4);
struct online_char_data* character = idb_ensure(online_char_db, aid, char_create_online_data);
if( character->server > -1 && character->server != id )
{
ShowNotice("Set map user: Character (%d:%d) marked on map server %d, but map server %d claims to have (%d:%d) online!\n",
character->account_id, character->char_id, character->server, id, aid, cid);
mapif_disconnectplayer(map_server[character->server].fd, character->account_id, character->char_id, 2);
}
character->server = id;
character->char_id = cid;
}
//If any chars remain in -2, they will be cleaned in the cleanup timer.
RFIFOSKIP(fd,RFIFOW(fd,2));
}
return 1;
}
示例2: chmapif_parse_getmapname
/**
* This function is called when the map-serv initialise is chrif interface.
* Map-serv sent us his map indexes so we can transfert a player from a map-serv to another when necessary
* We reply by sending back the char_serv_wisp_name fame list and
* @param fd: wich fd to parse from
* @param id: wich map_serv id
* @return : 0 not enough data received, 1 success
*/
int chmapif_parse_getmapname(int fd, int id){
int j = 0, i = 0;
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
return 0;
//Retain what map-index that map-serv contains
memset(map_server[id].map, 0, sizeof(map_server[id].map));
for(i = 4; i < RFIFOW(fd,2); i += 4) {
map_server[id].map[j] = RFIFOW(fd,i);
j++;
}
ShowStatus("Map-Server %d connected: %d maps, from IP %d.%d.%d.%d port %d.\n",
id, j, CONVIP(map_server[id].ip), map_server[id].port);
ShowStatus("Map-server %d loading complete.\n", id);
// send name for wisp to player
WFIFOHEAD(fd, 3 + NAME_LENGTH);
WFIFOW(fd,0) = 0x2afb;
WFIFOB(fd,2) = 0; //0 succes, 1:failure
memcpy(WFIFOP(fd,3), charserv_config.wisp_server_name, NAME_LENGTH);
WFIFOSET(fd,3+NAME_LENGTH);
chmapif_send_fame_list(fd); //Send fame list.
{
int x;
if (j == 0) {
ShowWarning("Map-server %d has NO maps.\n", id);
} else {
unsigned char buf[16384];
// Transmitting maps information to the other map-servers
WBUFW(buf,0) = 0x2b04;
WBUFW(buf,2) = j * 4 + 10;
WBUFL(buf,4) = htonl(map_server[id].ip);
WBUFW(buf,8) = htons(map_server[id].port);
memcpy(WBUFP(buf,10), RFIFOP(fd,4), j * 4);
chmapif_sendallwos(fd, buf, WBUFW(buf,2));
}
// Transmitting the maps of the other map-servers to the new map-server
for(x = 0; x < ARRAYLENGTH(map_server); x++) {
if (map_server[x].fd > 0 && x != id) {
WFIFOHEAD(fd,10 +4*ARRAYLENGTH(map_server[x].map));
WFIFOW(fd,0) = 0x2b04;
WFIFOL(fd,4) = htonl(map_server[x].ip);
WFIFOW(fd,8) = htons(map_server[x].port);
j = 0;
for(i = 0; i < ARRAYLENGTH(map_server[x].map); i++)
if (map_server[x].map[i])
WFIFOW(fd,10+(j++)*4) = map_server[x].map[i];
if (j > 0) {
WFIFOW(fd,2) = j * 4 + 10;
WFIFOSET(fd,WFIFOW(fd,2));
}
}
}
}
RFIFOSKIP(fd,RFIFOW(fd,2));
return 1;
}
示例3: chmapif_parse_getmapname
/**
* This function is called when the map-serv initialise is chrif interface.
* Map-serv sent us his map indexes so we can transfert a player from a map-serv to another when necessary
* We reply by sending back the char_serv_wisp_name fame list and
* @param fd: wich fd to parse from
* @param id: wich map_serv id
* @return : 0 not enough data received, 1 success
*/
int chmapif_parse_getmapname(int fd, int id){
int i = 0, j = 0;
unsigned char *mapbuf;
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
return 0;
//Retain what map-index that map-serv contains
memset(map_server[id].map, 0, sizeof(map_server[id].map));
for(i = 4; i < RFIFOW(fd,2); i += 4) {
map_server[id].map[j] = RFIFOW(fd,i);
j++;
}
mapbuf = RFIFOP(fd,4);
RFIFOSKIP(fd,RFIFOW(fd,2));
ShowStatus("Map-Server %d connected: %d maps, from IP %d.%d.%d.%d port %d.\n",
id, j, CONVIP(map_server[id].ip), map_server[id].port);
ShowStatus("Map-server %d loading complete.\n", id);
chmapif_send_misc(fd);
chmapif_send_fame_list(fd); //Send fame list.
chmapif_send_maps(fd, id, j, mapbuf);
return 1;
}
示例4: chmapif_parse_req_saveskillcooldown
//Request to save skill cooldown data
int chmapif_parse_req_saveskillcooldown(int fd){
if( RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2) )
return 0;
else {
int count, aid, cid;
aid = RFIFOL(fd,4);
cid = RFIFOL(fd,8);
count = RFIFOW(fd,12);
if( count > 0 )
{
struct skill_cooldown_data data;
StringBuf buf;
int i;
StringBuf_Init(&buf);
StringBuf_Printf(&buf, "INSERT INTO `%s` (`account_id`, `char_id`, `skill`, `tick`) VALUES ", schema_config.skillcooldown_db);
for( i = 0; i < count; ++i )
{
memcpy(&data,RFIFOP(fd,14+i*sizeof(struct skill_cooldown_data)),sizeof(struct skill_cooldown_data));
if( i > 0 )
StringBuf_AppendStr(&buf, ", ");
StringBuf_Printf(&buf, "('%d','%d','%d','%d')", aid, cid, data.skill_id, data.tick);
}
if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) )
Sql_ShowDebug(sql_handle);
StringBuf_Destroy(&buf);
}
RFIFOSKIP(fd, RFIFOW(fd, 2));
}
return 1;
}
示例5: chlogif_parse_ack_global_accreg
int chlogif_parse_ack_global_accreg(int fd, struct char_session_data* sd){
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
return 0;
else { //Receive account_reg2 registry, forward to map servers.
RFIFOW(fd,0) = 0x3804;
chmapif_sendall(RFIFOP(fd,0), RFIFOW(fd,2));
RFIFOSKIP(fd, RFIFOW(fd,2));
}
return 1;
}
示例6: chlogif_parse_ackacc2req
int chlogif_parse_ackacc2req(int fd, struct char_session_data* sd){
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
return 0;
{ //Receive account_reg2 registry, forward to map servers.
unsigned char buf[13+ACCOUNT_REG2_NUM*sizeof(struct global_reg)];
memcpy(buf,RFIFOP(fd,0), RFIFOW(fd,2));
WBUFW(buf,0) = 0x3804; //Map server can now receive all kinds of reg values with the same packet. [Skotlex]
chmapif_sendall(buf, WBUFW(buf,2));
RFIFOSKIP(fd, RFIFOW(fd,2));
}
return 1;
}
示例7: inter_check_length
// RFIFOのパケット長確認
// 必要パケット長があればパケット長、まだ足りなければ0
int inter_check_length(int fd,int length)
{
if(length==-1){ // 可変パケット長
if(RFIFOREST(fd)<4) // パケット長が未着
return 0;
length = RFIFOW(fd,2);
}
if(RFIFOREST(fd)<length) // パケットが未着
return 0;
return length;
}
示例8: inter_check_length
// RFIFO check
int inter_check_length(int fd, int length)
{
if(length==-1){ // v-len packet
if(RFIFOREST(fd)<4) // packet not yet
return 0;
length = RFIFOW(fd, 2);
}
if((int)RFIFOREST(fd) < length) // packet not yet
return 0;
return length;
}
示例9: inter_check_length
/// Returns the length of the next complete packet to process,
/// or 0 if no complete packet exists in the queue.
///
/// @param length The minimum allowed length, or -1 for dynamic lookup
int inter_check_length(int fd, int length)
{
if( length == -1 )
{// variable-length packet
if( RFIFOREST(fd) < 4 )
return 0;
length = RFIFOW(fd,2);
}
if( (int)RFIFOREST(fd) < length )
return 0;
return length;
}
示例10: chmapif_parse_reqchangemapserv
/**
* Player requesting to change map-serv
* @param fd: wich fd to parse from
* @return : 0 not enough data received, 1 success
*/
int chmapif_parse_reqchangemapserv(int fd){
if (RFIFOREST(fd) < 39)
return 0;
{
int map_id, map_fd = -1;
struct mmo_charstatus* char_data;
struct mmo_charstatus char_dat;
DBMap* char_db_ = char_get_chardb();
map_id = char_search_mapserver(RFIFOW(fd,18), ntohl(RFIFOL(fd,24)), ntohs(RFIFOW(fd,28))); //Locate mapserver by ip and port.
if (map_id >= 0)
map_fd = map_server[map_id].fd;
//Char should just had been saved before this packet, so this should be safe. [Skotlex]
char_data = (struct mmo_charstatus*)uidb_get(char_db_,RFIFOL(fd,14));
if (char_data == NULL) { //Really shouldn't happen.
char_mmo_char_fromsql(RFIFOL(fd,14), &char_dat, true);
char_data = (struct mmo_charstatus*)uidb_get(char_db_,RFIFOL(fd,14));
}
if( runflag == CHARSERVER_ST_RUNNING &&
session_isActive(map_fd) &&
char_data )
{ //Send the map server the auth of this player.
struct online_char_data* data;
struct auth_node* node;
DBMap* auth_db = char_get_authdb();
DBMap* online_char_db = char_get_onlinedb();
int aid = RFIFOL(fd,2);
//Update the "last map" as this is where the player must be spawned on the new map server.
char_data->last_point.map = RFIFOW(fd,18);
char_data->last_point.x = RFIFOW(fd,20);
char_data->last_point.y = RFIFOW(fd,22);
char_data->sex = RFIFOB(fd,30);
// create temporary auth entry
CREATE(node, struct auth_node, 1);
node->account_id = aid;
node->char_id = RFIFOL(fd,14);
node->login_id1 = RFIFOL(fd,6);
node->login_id2 = RFIFOL(fd,10);
node->sex = RFIFOB(fd,30);
node->expiration_time = 0; // FIXME (this thing isn't really supported we could as well purge it instead of fixing)
node->ip = ntohl(RFIFOL(fd,31));
node->group_id = RFIFOL(fd,35);
node->changing_mapservers = 1;
idb_put(auth_db, aid, node);
data = idb_ensure(online_char_db, aid, char_create_online_data);
data->char_id = char_data->char_id;
data->server = map_id; //Update server where char is.
//Reply with an ack.
chmapif_changemapserv_ack(fd,0);
} else { //Reply with nak
chmapif_changemapserv_ack(fd,1);
}
RFIFOSKIP(fd,39);
}
示例11: chlogif_parse_keepalive
int chlogif_parse_keepalive(int fd, struct char_session_data* sd){
if (RFIFOREST(fd) < 2)
return 0;
RFIFOSKIP(fd,2);
session[fd]->flag.ping = 0;
return 1;
}
示例12: RFIFOFLUSH
/// clean up by discarding handled bytes
inline
void RFIFOFLUSH(int fd)
{
really_memmove(&session[fd]->rdata[0], &session[fd]->rdata[session[fd]->rdata_pos], RFIFOREST(fd));
session[fd]->rdata_size = RFIFOREST(fd);
session[fd]->rdata_pos = 0;
}
示例13: chclif_parse_pincode_change
/*
* Client request to change pincode
*/
int chclif_parse_pincode_change( int fd, struct char_session_data* sd ){
if( RFIFOREST(fd) < 14 )
return 0;
if( charserv_config.pincode_config.pincode_enabled==0 || RFIFOL(fd,2) != sd->account_id )
return 1;
else {
char oldpin[PINCODE_LENGTH+1];
char newpin[PINCODE_LENGTH+1];
memset(oldpin,0,PINCODE_LENGTH+1);
memset(newpin,0,PINCODE_LENGTH+1);
strncpy(oldpin, RFIFOCP(fd,6), PINCODE_LENGTH);
strncpy(newpin, RFIFOCP(fd,10), PINCODE_LENGTH);
RFIFOSKIP(fd,14);
char_pincode_decrypt(sd->pincode_seed,oldpin);
if( !char_pincode_compare( fd, sd, oldpin ) )
return 1;
char_pincode_decrypt(sd->pincode_seed,newpin);
if( pincode_allowed(newpin) ){
chlogif_pincode_notifyLoginPinUpdate( sd->account_id, newpin );
strncpy(sd->pincode, newpin, sizeof(newpin));
ShowInfo("Pincode changed for AID: %d\n", sd->account_id);
chclif_pincode_sendstate( fd, sd, PINCODE_PASSED );
}else{
chclif_pincode_sendstate( fd, sd, PINCODE_ILLEGAL );
}
}
return 1;
}
示例14: logchrif_parse_setaccoffline
/**
* Set account_id to offline.
* @author [Wizputer]
* @param fd: fd to parse from (char-serv)
* @return 0 not enough info transmitted, 1 success
*/
int logchrif_parse_setaccoffline(int fd){
if( RFIFOREST(fd) < 6 )
return 0;
login_remove_online_user(RFIFOL(fd,2));
RFIFOSKIP(fd,6);
return 1;
}
示例15: logchrif_parse_upd_global_accreg
/**
* We receive account_reg2 from a char-server, and we send them to other char-servers.
* @param fd: fd to parse from (char-serv)
* @param id: id of char-serv
* @param ip: char-serv ip (used for info)
* @return 0 not enough info transmitted, 1 success
*/
int logchrif_parse_upd_global_accreg(int fd, int id, char* ip){
if( RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2) )
return 0;
else{
struct mmo_account acc;
AccountDB* accounts = login_get_accounts_db();
uint32 account_id = RFIFOL(fd,4);
if( !accounts->load_num(accounts, &acc, account_id) )
ShowStatus("Char-server '%s': receiving (from the char-server) of account_reg2 (account: %d not found, ip: %s).\n", ch_server[id].name, account_id, ip);
else
mmo_save_global_accreg(accounts,fd,account_id,RFIFOL(fd, 8));
RFIFOSKIP(fd,RFIFOW(fd,2));
}
return 1;
}