本文整理汇总了C++中WFIFOSET函数的典型用法代码示例。如果您正苦于以下问题:C++ WFIFOSET函数的具体用法?C++ WFIFOSET怎么用?C++ WFIFOSET使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了WFIFOSET函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mapif_parse_quest_load
/**
* Sends questlog to the map server
*
* Note: Completed quests (state == Q_COMPLETE) are guaranteed to be sent last
* and the map server relies on this behavior (once the first Q_COMPLETE quest,
* all of them are considered to be Q_COMPLETE)
*
* @see inter_parse_frommap
*/
int mapif_parse_quest_load(int fd) {
int char_id = RFIFOL(fd,2);
struct quest *tmp_questlog = NULL;
int num_quests;
tmp_questlog = mapif_quests_fromsql(char_id, &num_quests);
WFIFOHEAD(fd,num_quests*sizeof(struct quest)+8);
WFIFOW(fd,0) = 0x3860;
WFIFOW(fd,2) = num_quests*sizeof(struct quest)+8;
WFIFOL(fd,4) = char_id;
if (num_quests > 0)
memcpy(WFIFOP(fd,8), tmp_questlog, sizeof(struct quest)*num_quests);
WFIFOSET(fd,num_quests*sizeof(struct quest)+8);
if (tmp_questlog)
aFree(tmp_questlog);
return 0;
}
示例2: mapif_Mail_delete
/*==========================================
* Delete Mail
*------------------------------------------*/
static void mapif_Mail_delete(int fd, uint32 char_id, int mail_id, bool deleted)
{
bool failed = false;
if( !deleted ) {
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", mail_db, mail_id)
|| SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", mail_attachment_db, mail_id) ) {
Sql_ShowDebug(sql_handle);
failed = true;
}
}
if( fd <= 0 )
return; // Only if the request came from a map-server and was not timer triggered for an offline character
WFIFOHEAD(fd,11);
WFIFOW(fd,0) = 0x384b;
WFIFOL(fd,2) = char_id;
WFIFOL(fd,6) = mail_id;
WFIFOB(fd,10) = failed;
WFIFOSET(fd,11);
}
示例3: chrif_char_ask_name
/*==========================================
* S 2b0e <accid>.l <name>.24B <type>.w { <year>.w <month>.w <day>.w <hour>.w <minute>.w <second>.w }
* Send an account modification request to the login server (via char server).
* type of operation:
* 1: block, 2: ban, 3: unblock, 4: unban, 5: changesex (use next function for 5)
*------------------------------------------*/
int chrif_char_ask_name(int acc, const char* character_name, unsigned short operation_type, int year, int month, int day, int hour, int minute, int second) {
chrif_check(-1);
WFIFOHEAD(char_fd,44);
WFIFOW(char_fd,0) = 0x2b0e;
WFIFOL(char_fd,2) = acc;
safestrncpy((char*)WFIFOP(char_fd,6), character_name, NAME_LENGTH);
WFIFOW(char_fd,30) = operation_type;
if ( operation_type == 2 ) {
WFIFOW(char_fd,32) = year;
WFIFOW(char_fd,34) = month;
WFIFOW(char_fd,36) = day;
WFIFOW(char_fd,38) = hour;
WFIFOW(char_fd,40) = minute;
WFIFOW(char_fd,42) = second;
}
WFIFOSET(char_fd,44);
return 0;
}
示例4: chrif_updatefamelist
/*==========================================
* Request/Receive top 10 Fame character list
*------------------------------------------*/
int chrif_updatefamelist(struct map_session_data* sd) {
char type;
chrif_check(-1);
switch(sd->class_ & MAPID_UPPERMASK) {
case MAPID_BLACKSMITH: type = 1; break;
case MAPID_ALCHEMIST: type = 2; break;
case MAPID_TAEKWON: type = 3; break;
default:
return 0;
}
WFIFOHEAD(char_fd, 11);
WFIFOW(char_fd,0) = 0x2b10;
WFIFOL(char_fd,2) = sd->status.char_id;
WFIFOL(char_fd,6) = sd->status.fame;
WFIFOB(char_fd,10) = type;
WFIFOSET(char_fd,11);
return 0;
}
示例5: chrif_char_ask_name
/*==========================================
* Send message to char-server with a character name to do some operations (by Yor)
* Used to ask Char-server about a character name to have the account number to modify account file in login-server.
* type of operation:
* 1: block
* 2: ban
* 3: unblock
* 4: unban
* 5: changesex
*------------------------------------------*/
int chrif_char_ask_name(int id, char * character_name, short operation_type, int year, int month, int day, int hour, int minute, int second)
{
chrif_check(-1);
WFIFOHEAD(char_fd, 44);
WFIFOW(char_fd, 0) = 0x2b0e;
WFIFOL(char_fd, 2) = id; // account_id of who ask (for answer) -1 if nobody
memcpy(WFIFOP(char_fd,6), character_name, NAME_LENGTH);
WFIFOW(char_fd, 30) = operation_type; // type of operation
if (operation_type == 2) {
WFIFOW(char_fd, 32) = year;
WFIFOW(char_fd, 34) = month;
WFIFOW(char_fd, 36) = day;
WFIFOW(char_fd, 38) = hour;
WFIFOW(char_fd, 40) = minute;
WFIFOW(char_fd, 42) = second;
}
// ShowInfo("chrif : sent 0x2b0e\n");
WFIFOSET(char_fd,44);
return 0;
}
示例6: chrif_authreq
/*==========================================
* Request auth confirmation
*------------------------------------------*/
void chrif_authreq(struct map_session_data *sd)
{
struct auth_node *node= chrif_search(sd->bl.id);
if( node != NULL || !chrif_isconnected() ) {
set_eof(sd->fd);
return;
}
if( !chrif_isconnected() )
return;
WFIFOHEAD(char_fd,19);
WFIFOW(char_fd,0) = 0x2b26;
WFIFOL(char_fd,2) = sd->status.account_id;
WFIFOL(char_fd,6) = sd->status.char_id;
WFIFOL(char_fd,10) = sd->login_id1;
WFIFOB(char_fd,14) = sd->status.sex;
WFIFOL(char_fd,15) = htonl(session[sd->fd]->client_addr);
WFIFOSET(char_fd,19);
chrif_sd_to_auth(sd, ST_LOGIN);
}
示例7: mapif_account_reg_reply
// Send the requested account_reg
int mapif_account_reg_reply(int fd,int account_id,int char_id, int type)
{
struct accreg *reg=accreg_pt;
inter_accreg_fromsql(account_id,char_id,reg,type);
WFIFOW(fd,0)=0x3804;
WFIFOL(fd,4)=account_id;
WFIFOL(fd,8)=char_id;
WFIFOB(fd,12)=type;
if(reg->reg_num==0) {
WFIFOW(fd,2)=13;
} else {
int i,p;
for (p=13,i = 0; i < reg->reg_num; i++) {
p+= sprintf(WFIFOP(fd,p), "%s", reg->reg[i].str)+1; //We add 1 to consider the '\0' in place.
p+= sprintf(WFIFOP(fd,p), "%s", reg->reg[i].value)+1;
}
WFIFOW(fd,2)=p;
}
WFIFOSET(fd,WFIFOW(fd,2));
return 0;
}
示例8: mapif_load_guild_storage
int mapif_load_guild_storage(int fd,int account_id,int guild_id)
{
int guild_exist=1;
WFIFOHEAD(fd, sizeof(struct guild_storage)+12);
WFIFOW(fd,0)=0x3818;
#if 0 // innodb guilds should render this check unnecessary [Aru]
// Check if guild exists, I may write a function for this later, coz I use it several times.
//printf("- Check if guild %d exists\n",g->guild_id);
sprintf(tmp_sql, "SELECT count(*) FROM `%s` WHERE `guild_id`='%d'",guild_db, guild_id);
if(mysql_query(&mysql_handle, tmp_sql) ) {
ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
}
sql_res = mysql_store_result(&mysql_handle) ;
if (sql_res!=NULL && mysql_num_rows(sql_res)>0) {
sql_row = mysql_fetch_row(sql_res);
guild_exist = atoi (sql_row[0]);
//printf("- Check if guild %d exists : %s\n",g->guild_id,((guild_exist==0)?"No":"Yes"));
}
mysql_free_result(sql_res) ; //resource free
#endif
if(guild_exist==1) {
guild_storage_fromsql(guild_id,guild_storage_pt);
WFIFOW(fd,2)=sizeof(struct guild_storage)+12;
WFIFOL(fd,4)=account_id;
WFIFOL(fd,8)=guild_id;
memcpy(WFIFOP(fd,12),guild_storage_pt,sizeof(struct guild_storage));
}
else {
WFIFOW(fd,2)=12;
WFIFOL(fd,4)=account_id;
WFIFOL(fd,8)=0;
}
WFIFOSET(fd,WFIFOW(fd,2));
return 0;
}
示例9: mapif_Mail_return
/*==========================================
* Return Mail
*------------------------------------------*/
static void mapif_Mail_return(int fd, int char_id, int mail_id)
{
struct mail_message msg;
int new_mail = 0;
if(mail_loadmessage(mail_id, &msg)) {
if(msg.dest_id != char_id)
return;
else if(SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", mail_db, mail_id))
Sql_ShowDebug(sql_handle);
else {
char temp_[MAIL_TITLE_LENGTH];
// swap sender and receiver
swap(msg.send_id, msg.dest_id);
safestrncpy(temp_, msg.send_name, NAME_LENGTH);
safestrncpy(msg.send_name, msg.dest_name, NAME_LENGTH);
safestrncpy(msg.dest_name, temp_, NAME_LENGTH);
// set reply message title
snprintf(temp_, MAIL_TITLE_LENGTH, "RE:%s", msg.title);
safestrncpy(msg.title, temp_, MAIL_TITLE_LENGTH);
msg.status = MAIL_NEW;
msg.timestamp = time(NULL);
new_mail = mail_savemessage(&msg);
mapif_Mail_new(&msg);
}
}
WFIFOHEAD(fd,11);
WFIFOW(fd,0) = 0x384c;
WFIFOL(fd,2) = char_id;
WFIFOL(fd,6) = mail_id;
WFIFOB(fd,10) = (new_mail == 0);
WFIFOSET(fd,11);
}
示例10: mapif_account_reg_reply
// アカウント変数要求返信
static
void mapif_account_reg_reply(int fd, int account_id)
{
struct accreg *reg = accreg_db.search(account_id);
WFIFOW(fd, 0) = 0x3804;
WFIFOL(fd, 4) = account_id;
if (reg == NULL)
{
WFIFOW(fd, 2) = 8;
}
else
{
int j, p;
for (j = 0, p = 8; j < reg->reg_num; j++, p += 36)
{
WFIFO_STRING(fd, p, reg->reg[j].str, 32);
WFIFOL(fd, p + 32) = reg->reg[j].value;
}
WFIFOW(fd, 2) = p;
}
WFIFOSET(fd, WFIFOW(fd, 2));
}
示例11: chclif_mmo_send006b
//----------------------------------------
// Function to send characters to a player
//----------------------------------------
int chclif_mmo_send006b(int fd, struct char_session_data* sd){
int j, offset = 0;
bool newvers = (sd->version >= date2version(20100413) );
if(newvers) //20100413
offset += 3;
if (charserv_config.save_log)
ShowInfo("Loading Char Data ("CL_BOLD"%d"CL_RESET")\n",sd->account_id);
j = 24 + offset; // offset
WFIFOHEAD(fd,j + MAX_CHARS*MAX_CHAR_BUF);
WFIFOW(fd,0) = 0x6b;
if(newvers){ //20100413
WFIFOB(fd,4) = MAX_CHARS; // Max slots.
WFIFOB(fd,5) = MIN_CHARS; // Available slots. (PremiumStartSlot)
WFIFOB(fd,6) = MIN_CHARS+sd->chars_vip; // Premium slots. (Any existent chars past sd->char_slots but within MAX_CHARS will show a 'Premium Service' in red)
}
memset(WFIFOP(fd,4 + offset), 0, 20); // unknown bytes
j+=char_mmo_chars_fromsql(sd, WFIFOP(fd,j));
WFIFOW(fd,2) = j; // packet len
WFIFOSET(fd,j);
return 0;
}
示例12: chmapif_send_maps
/**
* Sends maps to all map-server
* HZ 0x2b04 <size>.W <ip>.L <port>.W { <map>.?B }.?B
* @param fd
* @param map_id
* @param count Number of map from new map-server has
**/
static void chmapif_send_maps(int fd, int map_id, int count, unsigned char *mapbuf) {
uint16 x;
if (count == 0) {
ShowWarning("Map-server %d has NO maps.\n", map_id);
}
else {
unsigned char buf[16384];
// Transmitting maps information to the other map-servers
WBUFW(buf,0) = 0x2b04;
WBUFW(buf,2) = count * 4 + 10;
WBUFL(buf,4) = htonl(map_server[map_id].ip);
WBUFW(buf,8) = htons(map_server[map_id].port);
memcpy(WBUFP(buf,10), mapbuf, count * 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 != map_id) {
uint16 i, j;
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));
}
}
}
}
示例13: mapif_parse_quest_load
//Send questlog to map server
int mapif_parse_quest_load(int fd)
{
int char_id = RFIFOL(fd,2);
struct quest tmp_questlog[MAX_QUEST_DB];
int num_quests, i, num_complete = 0;
int complete[MAX_QUEST_DB];
memset(tmp_questlog, 0, sizeof(tmp_questlog));
memset(complete, 0, sizeof(complete));
num_quests = mapif_quests_fromsql(char_id, tmp_questlog);
WFIFOHEAD(fd,num_quests*sizeof(struct quest)+8);
WFIFOW(fd,0) = 0x3860;
WFIFOW(fd,2) = num_quests*sizeof(struct quest)+8;
WFIFOL(fd,4) = char_id;
//Active and inactive quests
for( i = 0; i < num_quests; i++ )
{
if( tmp_questlog[i].state == Q_COMPLETE )
{
complete[num_complete++] = i;
continue;
}
memcpy(WFIFOP(fd,(i-num_complete)*sizeof(struct quest)+8), &tmp_questlog[i], sizeof(struct quest));
}
// Completed quests
for( i = num_quests - num_complete; i < num_quests; i++ )
memcpy(WFIFOP(fd,i*sizeof(struct quest)+8), &tmp_questlog[complete[i-num_quests+num_complete]], sizeof(struct quest));
WFIFOSET(fd,num_quests*sizeof(struct quest)+8);
return 0;
}
示例14: mapif_party_created
// パーティ作成可否
int mapif_party_created (int fd, int account_id, int char_id, struct party *p)
{
WFIFOHEAD (fd, 39);
WFIFOW (fd, 0) = 0x3820;
WFIFOL (fd, 2) = account_id;
WFIFOL (fd, 6) = char_id;
if (p != NULL)
{
WFIFOB (fd, 10) = 0;
WFIFOL (fd, 11) = p->party_id;
memcpy (WFIFOP (fd, 15), p->name, NAME_LENGTH);
ShowInfo ("int_party: Party created (%d - %s)\n", p->party_id, p->name);
}
else
{
WFIFOB (fd, 10) = 1;
WFIFOL (fd, 11) = 0;
memset (WFIFOP (fd, 15), 0, NAME_LENGTH);
}
WFIFOSET (fd, 39);
return 0;
}
示例15: chlogif_prepsend_global_accreg
void chlogif_prepsend_global_accreg(void) {
if ( chlogif_isconnected() ){
WFIFOSET(login_fd, WFIFOW(login_fd,2));
}
}