本文整理汇总了C++中WFIFOP函数的典型用法代码示例。如果您正苦于以下问题:C++ WFIFOP函数的具体用法?C++ WFIFOP怎么用?C++ WFIFOP使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了WFIFOP函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: chrif_save_scdata
int chrif_save_scdata(struct map_session_data *sd)
{ //parses the sc_data of the player and sends it to the char-server for saving. [Skotlex]
#ifdef ENABLE_SC_SAVING
int i, count=0;
unsigned int tick;
struct status_change_data data;
struct status_change *sc = &sd->sc;
const struct TimerData *timer;
chrif_check(-1);
tick = gettick();
WFIFOHEAD(char_fd, 14 + SC_MAX*sizeof(struct status_change_data));
WFIFOW(char_fd,0) = 0x2b1c;
WFIFOL(char_fd,4) = sd->status.account_id;
WFIFOL(char_fd,8) = sd->status.char_id;
for (i = 0; i < SC_MAX; i++)
{
if (!sc->data[i])
continue;
if (sc->data[i]->timer != INVALID_TIMER)
{
timer = get_timer(sc->data[i]->timer);
if (timer == NULL || timer->func != status_change_timer || DIFF_TICK(timer->tick,tick) < 0)
continue;
data.tick = DIFF_TICK(timer->tick,tick); //Duration that is left before ending.
} else
data.tick = -1; //Infinite duration
data.type = i;
data.val1 = sc->data[i]->val1;
data.val2 = sc->data[i]->val2;
data.val3 = sc->data[i]->val3;
data.val4 = sc->data[i]->val4;
memcpy(WFIFOP(char_fd,14 +count*sizeof(struct status_change_data)),
&data, sizeof(struct status_change_data));
count++;
}
if (count == 0)
return 0; //Nothing to save.
WFIFOW(char_fd,12) = count;
WFIFOW(char_fd,2) = 14 +count*sizeof(struct status_change_data); //Total packet size
WFIFOSET(char_fd,WFIFOW(char_fd,2));
#endif
return 0;
}
示例2: chrif_changesex
int chrif_changesex(struct map_session_data *sd)
{
chrif_check(-1);
WFIFOHEAD(char_fd,44);
WFIFOW(char_fd,0) = 0x2b0e;
WFIFOL(char_fd,2) = sd->status.account_id;
safestrncpy((char*)WFIFOP(char_fd,6), sd->status.name, NAME_LENGTH);
WFIFOW(char_fd,30) = 5;
WFIFOSET(char_fd,44);
clif_displaymessage(sd->fd, "Necess�rio desconectar para realizar a mudan�a de sexo...");
if (sd->fd)
clif_authfail_fd(sd->fd, 15);
else
map_quit(sd);
return 0;
}
示例3: chrif_changesex
int chrif_changesex(struct map_session_data *sd) {
chrif_check(-1);
WFIFOHEAD(char_fd,44);
WFIFOW(char_fd,0) = 0x2b0e;
WFIFOL(char_fd,2) = sd->status.account_id;
safestrncpy((char*)WFIFOP(char_fd,6), sd->status.name, NAME_LENGTH);
WFIFOW(char_fd,30) = 5;
WFIFOSET(char_fd,44);
clif->message(sd->fd, msg_txt(408)); //"Need disconnection to perform change-sex request..."
if (sd->fd)
clif->authfail_fd(sd->fd, 15);
else
map_quit(sd);
return 0;
}
示例4: intif_create_pet
// pet
int intif_create_pet(int account_id,int char_id,short pet_class,short pet_lv,short pet_egg_id,
short pet_equip,short intimate,short hungry,char rename_flag,char incuvate,char *pet_name)
{
WFIFOW(inter_fd,0) = 0x3080;
WFIFOL(inter_fd,2) = account_id;
WFIFOL(inter_fd,6) = char_id;
WFIFOW(inter_fd,10) = pet_class;
WFIFOW(inter_fd,12) = pet_lv;
WFIFOW(inter_fd,14) = pet_egg_id;
WFIFOW(inter_fd,16) = pet_equip;
WFIFOW(inter_fd,18) = intimate;
WFIFOW(inter_fd,20) = hungry;
WFIFOB(inter_fd,22) = rename_flag;
WFIFOB(inter_fd,23) = incuvate;
memcpy(WFIFOP(inter_fd,24),pet_name,24);
WFIFOSET(inter_fd,48);
return 0;
}
示例5: mapif_achievement_load
/**
* Sends the achievementlog of a character to the map-server.
*/
void mapif_achievement_load( int fd, uint32 char_id ){
struct achievement *tmp_achievementlog = NULL;
int num_achievements = 0;
tmp_achievementlog = mapif_achievements_fromsql(char_id, &num_achievements);
WFIFOHEAD(fd, num_achievements * sizeof(struct achievement) + 8);
WFIFOW(fd, 0) = 0x3862;
WFIFOW(fd, 2) = num_achievements * sizeof(struct achievement) + 8;
WFIFOL(fd, 4) = char_id;
if (num_achievements > 0)
memcpy(WFIFOP(fd, 8), tmp_achievementlog, sizeof(struct achievement) * num_achievements);
WFIFOSET(fd, num_achievements * sizeof(struct achievement) + 8);
if (tmp_achievementlog)
aFree(tmp_achievementlog);
}
示例6: inter_to_fd
/* extremely handy I believe it will serve other uses in the near future */
void inter_to_fd(int fd, int u_fd, int aid, char* msg, ...) {
char msg_out[512];
va_list ap;
va_start(ap,msg);
vsprintf(msg_out, msg, ap);
va_end(ap);
WFIFOHEAD(fd,522);
WFIFOW(fd,0) = 0x3807;
WFIFOL(fd,2) = u_fd;
WFIFOL(fd,6) = aid;
safestrncpy((char*)WFIFOP(fd,10), msg_out, 512);
WFIFOSET(fd,522);
return;
}
示例7: mapif_load_guild_storage
int mapif_load_guild_storage(int fd,int account_id,int guild_id)
{
struct guild_storage *gs=guild2storage(guild_id);
WFIFOHEAD(fd, sizeof(struct guild_storage)+12);
WFIFOW(fd,0)=0x3818;
if(gs) {
WFIFOW(fd,2)=sizeof(struct guild_storage)+12;
WFIFOL(fd,4)=account_id;
WFIFOL(fd,8)=guild_id;
memcpy(WFIFOP(fd,12),gs,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;
}
示例8: 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;
}
示例9: mapif_guild_castle_alldataload
int mapif_guild_castle_alldataload(int fd)
{
DBIterator* iter;
struct guild_castle* gc;
int len = 4;
WFIFOHEAD(fd, 4 + MAX_GUILDCASTLE*sizeof(struct guild_castle));
WFIFOW(fd,0) = 0x3842;
iter = castle_db->iterator(castle_db);
for( gc = (struct guild_castle*)iter->first(iter,NULL); iter->exists(iter); gc = (struct guild_castle*)iter->next(iter,NULL) )
{
memcpy(WFIFOP(fd,len), gc, sizeof(struct guild_castle));
len += sizeof(struct guild_castle);
}
iter->destroy(iter);
WFIFOW(fd,2) = len;
WFIFOSET(fd, len);
return 0;
}
示例10: inter_vmsg_to_fd
/**
* Argument-list version of inter_msg_to_fd
* @see inter_msg_to_fd
*/
void inter_vmsg_to_fd(int fd, int u_fd, int aid, char* msg, va_list ap) {
char msg_out[512];
va_list apcopy;
int len = 1;/* yes we start at 1 */
va_copy(apcopy, ap);
len += vsnprintf(msg_out, 512, msg, apcopy);
va_end(apcopy);
WFIFOHEAD(fd,12 + len);
WFIFOW(fd,0) = 0x3807;
WFIFOW(fd,2) = 12 + (unsigned short)len;
WFIFOL(fd,4) = u_fd;
WFIFOL(fd,8) = aid;
safestrncpy((char*)WFIFOP(fd,12), msg_out, len);
WFIFOSET(fd,12 + len);
return;
}
示例11: 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;
}
示例12: 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;
}
示例13: mapif_parse_achievement_load
//Send Achievements to map server
int mapif_parse_achievement_load(int fd)
{
int i, count, len, char_id = RFIFOL(fd,2);
struct s_achievement tmp_ad[ACHIEVEMENT_MAX];
memset(tmp_ad,0,sizeof(tmp_ad));
count = mapif_achievement_fromsql(char_id,tmp_ad);
len = count * sizeof(struct s_achievement) + 8;
WFIFOHEAD(fd,len);
WFIFOW(fd,0) = 0x385a;
WFIFOW(fd,2) = len;
WFIFOL(fd,4) = char_id;
for( i = 0; i < count; i++ )
{
memcpy(WFIFOP(fd,(i*sizeof(struct s_achievement))+8),&tmp_ad[i], sizeof(struct s_achievement));
}
WFIFOSET(fd,len);
return 0;
}
示例14: 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;
}
示例15: inter_accreg_fromsql
// Load account_reg from sql (type=2)
int inter_accreg_fromsql(int account_id,int char_id, int fd, int type)
{
char* data;
size_t len;
unsigned int plen = 0;
switch( type ) {
case 3: //char reg
if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `char_id`='%d'", char_reg_str_db, char_id) )
Sql_ShowDebug(sql_handle);
break;
case 2: //account reg
if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%d'", acc_reg_str_db, account_id) )
Sql_ShowDebug(sql_handle);
break;
case 1: //account2 reg
ShowError("inter_accreg_fromsql: Char server shouldn't handle type 1 registry values (##). That is the login server's work!\n");
return 0;
default:
ShowError("inter_accreg_fromsql: Invalid type %d\n", type);
return 0;
}
WFIFOHEAD(fd, 60000 + 300);
WFIFOW(fd, 0) = 0x3804;
/* 0x2 = length, set prior to being sent */
WFIFOL(fd, 4) = account_id;
WFIFOL(fd, 8) = char_id;
WFIFOB(fd, 12) = 0;/* var type (only set when all vars have been sent, regardless of type) */
WFIFOB(fd, 13) = 1;/* is string type */
WFIFOW(fd, 14) = 0;/* count */
plen = 16;
/**
* Vessel!
*
* str type
* { keyLength(B), key(<keyLength>), index(L), valLength(B), val(<valLength>) }
**/
while ( SQL_SUCCESS == SQL->NextRow(sql_handle) ) {
SQL->GetData(sql_handle, 0, &data, NULL);
len = strlen(data)+1;
WFIFOB(fd, plen) = (unsigned char)len;/* won't be higher; the column size is 32 */
plen += 1;
safestrncpy((char*)WFIFOP(fd,plen), data, len);
plen += len;
SQL->GetData(sql_handle, 1, &data, NULL);
WFIFOL(fd, plen) = (unsigned int)atol(data);
plen += 4;
SQL->GetData(sql_handle, 2, &data, NULL);
len = strlen(data)+1;
WFIFOB(fd, plen) = (unsigned char)len;/* won't be higher; the column size is 254 */
plen += 1;
safestrncpy((char*)WFIFOP(fd,plen), data, len);
plen += len;
WFIFOW(fd, 14) += 1;
if( plen > 60000 ) {
WFIFOW(fd, 2) = plen;
WFIFOSET(fd, plen);
/* prepare follow up */
WFIFOHEAD(fd, 60000 + 300);
WFIFOW(fd, 0) = 0x3804;
/* 0x2 = length, set prior to being sent */
WFIFOL(fd, 4) = account_id;
WFIFOL(fd, 8) = char_id;
WFIFOB(fd, 12) = 0;/* var type (only set when all vars have been sent, regardless of type) */
WFIFOB(fd, 13) = 1;/* is string type */
WFIFOW(fd, 14) = 0;/* count */
plen = 16;
}
}
/* mark & go. */
WFIFOW(fd, 2) = plen;
WFIFOSET(fd, plen);
SQL->FreeResult(sql_handle);
switch( type ) {
case 3: //char reg
if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `char_id`='%d'", char_reg_num_db, char_id) )
Sql_ShowDebug(sql_handle);
break;
case 2: //account reg
if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%d'", acc_reg_num_db, account_id) )
Sql_ShowDebug(sql_handle);
break;
case 1: //account2 reg
//.........这里部分代码省略.........