summaryrefslogtreecommitdiff
path: root/src/map/intif.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/intif.c')
-rw-r--r--src/map/intif.c1567
1 files changed, 891 insertions, 676 deletions
diff --git a/src/map/intif.c b/src/map/intif.c
index f3931e79e..be82a7583 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -1,67 +1,58 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
-#include "../common/showmsg.h"
-#include "../common/socket.h"
-#include "../common/timer.h"
-#include "../common/nullpo.h"
-#include "../common/malloc.h"
-#include "../common/strlib.h"
-#include "map.h"
+#define HERCULES_CORE
+
+#include "../config/core.h" // GP_BOUND_ITEMS
+#include "intif.h"
+
+#include <fcntl.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+
+#include "atcommand.h"
#include "battle.h"
#include "chrif.h"
#include "clif.h"
-#include "pc.h"
-#include "intif.h"
-#include "log.h"
-#include "storage.h"
-#include "party.h"
+#include "elemental.h"
#include "guild.h"
-#include "pet.h"
-#include "atcommand.h"
-#include "mercenary.h"
#include "homunculus.h"
-#include "elemental.h"
+#include "log.h"
#include "mail.h"
+#include "map.h"
+#include "mercenary.h"
+#include "party.h"
+#include "pc.h"
+#include "pet.h"
#include "quest.h"
+#include "storage.h"
+#include "../common/malloc.h"
+#include "../common/nullpo.h"
+#include "../common/showmsg.h"
+#include "../common/socket.h"
+#include "../common/strlib.h"
+#include "../common/timer.h"
-#include <sys/types.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <string.h>
-
-
-static const int packet_len_table[]={
- -1,-1,27,-1, -1, 0,37,-1, 0, 0, 0, 0, 0, 0, 0, 0, //0x3800-0x380f
- 0, 0, 0, 0, 0, 0, 0, 0, -1,11, 0, 0, 0, 0, 0, 0, //0x3810
- 39,-1,15,15, 14,19, 7,-1, 0, 0, 0, 0, 0, 0, 0, 0, //0x3820
- 10,-1,15, 0, 79,19, 7,-1, 0,-1,-1,-1, 14,67,186,-1, //0x3830
- -1, 0, 0,14, 0, 0, 0, 0, -1,74,-1,11, 11,-1, 0, 0, //0x3840
- -1,-1, 7, 7, 7,11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3850 Auctions [Zephyrus]
- -1, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3860 Quests [Kevin] [Inkfish]
- -1, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 3, 3, 0, //0x3870 Mercenaries [Zephyrus] / Elemental [pakpil]
- 11,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3880
- -1,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3890 Homunculus [albator]
-};
+struct intif_interface intif_s;
-extern int char_fd; // inter server Fd used for char_fd
-#define inter_fd char_fd // alias
+#define inter_fd (chrif->fd) // alias
//-----------------------------------------------------------------
// Send to inter server
int CheckForCharServer(void)
{
- return ((char_fd <= 0) || session[char_fd] == NULL || session[char_fd]->wdata == NULL);
+ return ((chrif->fd <= 0) || session[chrif->fd] == NULL || session[chrif->fd]->wdata == NULL);
}
// 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)
+ short pet_equip,short intimate,short hungry,char rename_flag,char incubate,char *pet_name)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd, 24 + NAME_LENGTH);
WFIFOW(inter_fd,0) = 0x3080;
@@ -74,7 +65,7 @@ int intif_create_pet(int account_id,int char_id,short pet_class,short pet_lv,sho
WFIFOW(inter_fd,18) = intimate;
WFIFOW(inter_fd,20) = hungry;
WFIFOB(inter_fd,22) = rename_flag;
- WFIFOB(inter_fd,23) = incuvate;
+ WFIFOB(inter_fd,23) = incubate;
memcpy(WFIFOP(inter_fd,24),pet_name,NAME_LENGTH);
WFIFOSET(inter_fd,24+NAME_LENGTH);
@@ -83,7 +74,7 @@ int intif_create_pet(int account_id,int char_id,short pet_class,short pet_lv,sho
int intif_request_petdata(int account_id,int char_id,int pet_id)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd, 14);
WFIFOW(inter_fd,0) = 0x3081;
@@ -97,7 +88,7 @@ int intif_request_petdata(int account_id,int char_id,int pet_id)
int intif_save_petdata(int account_id,struct s_pet *p)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd, sizeof(struct s_pet) + 8);
WFIFOW(inter_fd,0) = 0x3082;
@@ -111,7 +102,7 @@ int intif_save_petdata(int account_id,struct s_pet *p)
int intif_delete_petdata(int pet_id)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd,6);
WFIFOW(inter_fd,0) = 0x3083;
@@ -123,7 +114,7 @@ int intif_delete_petdata(int pet_id)
int intif_rename(struct map_session_data *sd, int type, char *name)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 1;
WFIFOHEAD(inter_fd,NAME_LENGTH+12);
@@ -137,17 +128,17 @@ int intif_rename(struct map_session_data *sd, int type, char *name)
}
// GM Send a message
-int intif_broadcast(const char* mes, int len, int type)
+int intif_broadcast(const char* mes, size_t len, int type)
{
- int lp = type ? 4 : 0;
+ int lp = (type|BC_COLOR_MASK) ? 4 : 0;
// Send to the local players
clif->broadcast(NULL, mes, len, type, ALL_CLIENT);
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
- if (other_mapserver_count < 1)
+ if (chrif->other_mapserver_count < 1)
return 0; //No need to send.
WFIFOHEAD(inter_fd, 16 + lp + len);
@@ -158,24 +149,24 @@ int intif_broadcast(const char* mes, int len, int type)
WFIFOW(inter_fd,10) = 0; // fontSize not used with standard broadcast
WFIFOW(inter_fd,12) = 0; // fontAlign not used with standard broadcast
WFIFOW(inter_fd,14) = 0; // fontY not used with standard broadcast
- if (type == 0x10) // bc_blue
+ if( type|BC_BLUE )
WFIFOL(inter_fd,16) = 0x65756c62; //If there's "blue" at the beginning of the message, game client will display it in blue instead of yellow.
- else if (type == 0x20) // bc_woe
+ else if( type|BC_WOE )
WFIFOL(inter_fd,16) = 0x73737373; //If there's "ssss", game client will recognize message as 'WoE broadcast'.
memcpy(WFIFOP(inter_fd,16 + lp), mes, len);
WFIFOSET(inter_fd, WFIFOW(inter_fd,2));
return 0;
}
-int intif_broadcast2(const char* mes, int len, unsigned long fontColor, short fontType, short fontSize, short fontAlign, short fontY)
+int intif_broadcast2(const char* mes, size_t len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY)
{
// Send to the local players
clif->broadcast2(NULL, mes, len, fontColor, fontType, fontSize, fontAlign, fontY, ALL_CLIENT);
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
- if (other_mapserver_count < 1)
+ if (chrif->other_mapserver_count < 1)
return 0; //No need to send.
WFIFOHEAD(inter_fd, 16 + len);
@@ -204,7 +195,7 @@ int intif_main_message(struct map_session_data* sd, const char* message)
snprintf( output, sizeof(output), msg_txt(386), sd->status.name, message );
// send the message using the inter-server broadcast service
- intif_broadcast2( output, strlen(output) + 1, 0xFE000000, 0, 0, 0, 0 );
+ intif->broadcast2( output, strlen(output) + 1, 0xFE000000, 0, 0, 0, 0 );
// log the chat message
logs->chat( LOG_CHAT_MAINCHAT, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message );
@@ -213,13 +204,13 @@ int intif_main_message(struct map_session_data* sd, const char* message)
}
// The transmission of Wisp/Page to inter-server (player not found on this server)
-int intif_wis_message(struct map_session_data *sd, char *nick, char *mes, int mes_len)
+int intif_wis_message(struct map_session_data *sd, char *nick, char *mes, size_t mes_len)
{
nullpo_ret(sd);
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
- if (other_mapserver_count < 1)
+ if (chrif->other_mapserver_count < 1)
{ //Character not found.
clif->wis_end(sd->fd, 1);
return 0;
@@ -242,12 +233,12 @@ int intif_wis_message(struct map_session_data *sd, char *nick, char *mes, int me
// The reply of Wisp/page
int intif_wis_replay(int id, int flag)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd,7);
WFIFOW(inter_fd,0) = 0x3002;
WFIFOL(inter_fd,2) = id;
- WFIFOB(inter_fd,6) = flag; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
+ WFIFOB(inter_fd,6) = flag; // flag: 0: success to send whisper, 1: target character is not logged in?, 2: ignored by target
WFIFOSET(inter_fd,7);
if (battle_config.etc_log)
@@ -259,8 +250,8 @@ int intif_wis_replay(int id, int flag)
// The transmission of GM only Wisp/Page from server to inter-server
int intif_wis_message_to_gm(char *wisp_name, int permission, char *mes)
{
- int mes_len;
- if (CheckForCharServer())
+ size_t mes_len;
+ if (intif->CheckForCharServer())
return 0;
mes_len = strlen(mes) + 1; // + null
WFIFOHEAD(inter_fd, mes_len + 32);
@@ -277,60 +268,117 @@ int intif_wis_message_to_gm(char *wisp_name, int permission, char *mes)
return 0;
}
-int intif_regtostr(char* str, struct global_reg *reg, int qty)
-{
- int len =0, i;
-
- for (i = 0; i < qty; i++) {
- len+= sprintf(str+len, "%s", reg[i].str)+1; //We add 1 to consider the '\0' in place.
- len+= sprintf(str+len, "%s", reg[i].value)+1;
- }
- return len;
-}
-
//Request for saving registry values.
-int intif_saveregistry(struct map_session_data *sd, int type)
-{
- struct global_reg *reg;
- int count;
- int i, p;
-
- if (CheckForCharServer())
+int intif_saveregistry(struct map_session_data *sd) {
+ DBIterator *iter;
+ DBKey key;
+ DBData *data;
+ int plen = 0;
+ size_t len;
+
+ if (intif->CheckForCharServer() || !sd->regs.vars)
return -1;
+
+ WFIFOHEAD(inter_fd, 60000 + 300);
+ WFIFOW(inter_fd,0) = 0x3004;
+ /* 0x2 = length (set later) */
+ WFIFOL(inter_fd,4) = sd->status.account_id;
+ WFIFOL(inter_fd,8) = sd->status.char_id;
+ WFIFOW(inter_fd,12) = 0;/* count */
+
+ plen = 14;
+
+ iter = db_iterator(sd->regs.vars);
+ for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) {
+ const char *varname = NULL;
+ struct script_reg_state *src = NULL;
+
+ if( data->type != DB_DATA_PTR ) /* its a @number */
+ continue;
+
+ varname = script->get_str(script_getvarid(key.i64));
+
+ if( varname[0] == '@' ) /* @string$ can get here, so we skip */
+ continue;
+
+ src = DB->data2ptr(data);
- switch (type) {
- case 3: //Character reg
- reg = sd->save_reg.global;
- count = sd->save_reg.global_num;
- sd->state.reg_dirty &= ~0x4;
- break;
- case 2: //Account reg
- reg = sd->save_reg.account;
- count = sd->save_reg.account_num;
- sd->state.reg_dirty &= ~0x2;
- break;
- case 1: //Account2 reg
- reg = sd->save_reg.account2;
- count = sd->save_reg.account2_num;
- sd->state.reg_dirty &= ~0x1;
- break;
- default: //Broken code?
- ShowError("intif_saveregistry: Invalid type %d\n", type);
- return -1;
- }
- WFIFOHEAD(inter_fd, 288 * MAX_REG_NUM+13);
- WFIFOW(inter_fd,0)=0x3004;
- WFIFOL(inter_fd,4)=sd->status.account_id;
- WFIFOL(inter_fd,8)=sd->status.char_id;
- WFIFOB(inter_fd,12)=type;
- for( p = 13, i = 0; i < count; i++ ) {
- if (reg[i].str[0] != '\0' && reg[i].value[0] != '\0') {
- p+= sprintf((char*)WFIFOP(inter_fd,p), "%s", reg[i].str)+1; //We add 1 to consider the '\0' in place.
- p+= sprintf((char*)WFIFOP(inter_fd,p), "%s", reg[i].value)+1;
+ /* no need! */
+ if( !src->update )
+ continue;
+
+ src->update = false;
+
+ len = strlen(varname)+1;
+
+ WFIFOB(inter_fd, plen) = (unsigned char)len;/* won't be higher; the column size is 32 */
+ plen += 1;
+
+ safestrncpy((char*)WFIFOP(inter_fd,plen), varname, len);
+ plen += len;
+
+ WFIFOL(inter_fd, plen) = script_getvaridx(key.i64);
+ plen += 4;
+
+ if( src->type ) {
+ struct script_reg_str *p = (struct script_reg_str *)src;
+
+ WFIFOB(inter_fd, plen) = p->value ? 2 : 3;
+ plen += 1;
+
+ if( p->value ) {
+ len = strlen(p->value)+1;
+
+ WFIFOB(inter_fd, plen) = (unsigned char)len;/* won't be higher; the column size is 254 */
+ plen += 1;
+
+ safestrncpy((char*)WFIFOP(inter_fd,plen), p->value, len);
+ plen += len;
+ } else {
+ script->reg_destroy_single(sd,key.i64,&p->flag);
+ }
+
+ } else {
+ struct script_reg_num *p = (struct script_reg_num *)src;
+
+ WFIFOB(inter_fd, plen) = p->value ? 0 : 1;
+ plen += 1;
+
+ if( p->value ) {
+ WFIFOL(inter_fd, plen) = p->value;
+ plen += 4;
+ } else {
+ script->reg_destroy_single(sd,key.i64,&p->flag);
+ }
+
+ }
+
+ WFIFOW(inter_fd,12) += 1;
+
+ if( plen > 60000 ) {
+ WFIFOW(inter_fd, 2) = plen;
+ WFIFOSET(inter_fd, plen);
+
+ /* prepare follow up */
+ WFIFOHEAD(inter_fd, 60000 + 300);
+ WFIFOW(inter_fd,0) = 0x3004;
+ /* 0x2 = length (set later) */
+ WFIFOL(inter_fd,4) = sd->status.account_id;
+ WFIFOL(inter_fd,8) = sd->status.char_id;
+ WFIFOW(inter_fd,12) = 0;/* count */
+
+ plen = 14;
}
+
}
- WFIFOW(inter_fd,2)=p;
- WFIFOSET(inter_fd,WFIFOW(inter_fd,2));
+ dbi_destroy(iter);
+
+ /* mark & go. */
+ WFIFOW(inter_fd, 2) = plen;
+ WFIFOSET(inter_fd, plen);
+
+ sd->vars_dirty = false;
+
return 0;
}
@@ -339,11 +387,8 @@ int intif_request_registry(struct map_session_data *sd, int flag)
{
nullpo_ret(sd);
- sd->save_reg.account2_num = -1;
- sd->save_reg.account_num = -1;
- sd->save_reg.global_num = -1;
-
- if (CheckForCharServer())
+ /* if char server ain't online it doesn't load, shouldn't we kill the session then? */
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd,6);
@@ -360,7 +405,7 @@ int intif_request_registry(struct map_session_data *sd, int flag)
int intif_request_guild_storage(int account_id,int guild_id)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd,10);
WFIFOW(inter_fd,0) = 0x3018;
@@ -371,7 +416,7 @@ int intif_request_guild_storage(int account_id,int guild_id)
}
int intif_send_guild_storage(int account_id,struct guild_storage *gstor)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd,sizeof(struct guild_storage)+12);
WFIFOW(inter_fd,0) = 0x3019;
@@ -386,7 +431,7 @@ int intif_send_guild_storage(int account_id,struct guild_storage *gstor)
// Party creation request
int intif_create_party(struct party_member *member,char *name,int item,int item2)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
nullpo_ret(member);
@@ -404,7 +449,7 @@ int intif_create_party(struct party_member *member,char *name,int item,int item2
// Party information request
int intif_request_partyinfo(int party_id, int char_id)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd,10);
WFIFOW(inter_fd,0) = 0x3021;
@@ -417,7 +462,7 @@ int intif_request_partyinfo(int party_id, int char_id)
// Request to add a member to party
int intif_party_addmember(int party_id,struct party_member *member)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd,42);
WFIFOW(inter_fd,0)=0x3022;
@@ -431,7 +476,7 @@ int intif_party_addmember(int party_id,struct party_member *member)
// Request to change party configuration (exp,item share)
int intif_party_changeoption(int party_id,int account_id,int exp,int item)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd,14);
WFIFOW(inter_fd,0)=0x3023;
@@ -446,7 +491,7 @@ int intif_party_changeoption(int party_id,int account_id,int exp,int item)
// Request to leave party
int intif_party_leave(int party_id,int account_id, int char_id)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd,14);
WFIFOW(inter_fd,0)=0x3024;
@@ -458,26 +503,25 @@ int intif_party_leave(int party_id,int account_id, int char_id)
}
// Request keeping party for new map ??
-int intif_party_changemap(struct map_session_data *sd,int online)
-{
- int16 m, mapindex;
+int intif_party_changemap(struct map_session_data *sd,int online) {
+ int16 m, map_index;
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
if(!sd)
return 0;
- if( (m=iMap->mapindex2mapid(sd->mapindex)) >= 0 && map[m].instance_id >= 0 )
- mapindex = map[map[m].instance_src_map].index;
+ if( (m=map->mapindex2mapid(sd->mapindex)) >= 0 && map->list[m].instance_id >= 0 )
+ map_index = map_id2index(map->list[m].instance_src_map);
else
- mapindex = sd->mapindex;
+ map_index = sd->mapindex;
WFIFOHEAD(inter_fd,19);
WFIFOW(inter_fd,0)=0x3025;
WFIFOL(inter_fd,2)=sd->status.party_id;
WFIFOL(inter_fd,6)=sd->status.account_id;
WFIFOL(inter_fd,10)=sd->status.char_id;
- WFIFOW(inter_fd,14)=mapindex;
+ WFIFOW(inter_fd,14)=map_index;
WFIFOB(inter_fd,16)=online;
WFIFOW(inter_fd,17)=sd->status.base_level;
WFIFOSET(inter_fd,19);
@@ -487,7 +531,7 @@ int intif_party_changemap(struct map_session_data *sd,int online)
// Request breaking party
int intif_break_party(int party_id)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd,6);
WFIFOW(inter_fd,0)=0x3026;
@@ -499,10 +543,10 @@ int intif_break_party(int party_id)
// Sending party chat
int intif_party_message(int party_id,int account_id,const char *mes,int len)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
- if (other_mapserver_count < 1)
+ if (chrif->other_mapserver_count < 1)
return 0; //No need to send.
WFIFOHEAD(inter_fd,len + 12);
@@ -518,7 +562,7 @@ int intif_party_message(int party_id,int account_id,const char *mes,int len)
// Request a new leader for party
int intif_party_leaderchange(int party_id,int account_id,int char_id)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd,14);
WFIFOW(inter_fd,0)=0x3029;
@@ -532,7 +576,7 @@ int intif_party_leaderchange(int party_id,int account_id,int char_id)
// Request a Guild creation
int intif_guild_create(const char *name,const struct guild_member *master)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
nullpo_ret(master);
@@ -549,7 +593,7 @@ int intif_guild_create(const char *name,const struct guild_member *master)
// Request Guild information
int intif_guild_request_info(int guild_id)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd,6);
WFIFOW(inter_fd,0) = 0x3031;
@@ -561,7 +605,7 @@ int intif_guild_request_info(int guild_id)
// Request to add member to the guild
int intif_guild_addmember(int guild_id,struct guild_member *m)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd,sizeof(struct guild_member)+8);
WFIFOW(inter_fd,0) = 0x3032;
@@ -573,9 +617,9 @@ int intif_guild_addmember(int guild_id,struct guild_member *m)
}
// Request a new leader for guild
-int intif_guild_change_gm(int guild_id, const char* name, int len)
+int intif_guild_change_gm(int guild_id, const char* name, size_t len)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd, len + 8);
WFIFOW(inter_fd, 0)=0x3033;
@@ -589,7 +633,7 @@ int intif_guild_change_gm(int guild_id, const char* name, int len)
// Request to leave guild
int intif_guild_leave(int guild_id,int account_id,int char_id,int flag,const char *mes)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd, 55);
WFIFOW(inter_fd, 0) = 0x3034;
@@ -605,7 +649,7 @@ int intif_guild_leave(int guild_id,int account_id,int char_id,int flag,const cha
//Update request / Lv online status of the guild members
int intif_guild_memberinfoshort(int guild_id,int account_id,int char_id,int online,int lv,int class_)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd, 19);
WFIFOW(inter_fd, 0) = 0x3035;
@@ -622,7 +666,7 @@ int intif_guild_memberinfoshort(int guild_id,int account_id,int char_id,int onli
//Guild disbanded notification
int intif_guild_break(int guild_id)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd, 6);
WFIFOW(inter_fd, 0) = 0x3036;
@@ -634,10 +678,10 @@ int intif_guild_break(int guild_id)
// Send a guild message
int intif_guild_message(int guild_id,int account_id,const char *mes,int len)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
- if (other_mapserver_count < 1)
+ if (chrif->other_mapserver_count < 1)
return 0; //No need to send.
WFIFOHEAD(inter_fd, len + 12);
@@ -651,10 +695,13 @@ int intif_guild_message(int guild_id,int account_id,const char *mes,int len)
return 0;
}
-// Request a change of Guild basic information
+/**
+ * Requests to change a basic guild information, it is parsed via mapif_parse_GuildBasicInfoChange
+ * To see the information types that can be changed see mmo.h::guild_basic_info
+ **/
int intif_guild_change_basicinfo(int guild_id,int type,const void *data,int len)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd, len + 10);
WFIFOW(inter_fd,0)=0x3039;
@@ -670,7 +717,7 @@ int intif_guild_change_basicinfo(int guild_id,int type,const void *data,int len)
int intif_guild_change_memberinfo(int guild_id,int account_id,int char_id,
int type,const void *data,int len)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd, len + 18);
WFIFOW(inter_fd, 0)=0x303a;
@@ -687,7 +734,7 @@ int intif_guild_change_memberinfo(int guild_id,int account_id,int char_id,
// Request a change of Guild title
int intif_guild_position(int guild_id,int idx,struct guild_position *p)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd, sizeof(struct guild_position)+12);
WFIFOW(inter_fd,0)=0x303b;
@@ -702,7 +749,7 @@ int intif_guild_position(int guild_id,int idx,struct guild_position *p)
// Request an update of Guildskill skill_id
int intif_guild_skillup(int guild_id, uint16 skill_id, int account_id, int max)
{
- if( CheckForCharServer() )
+ if( intif->CheckForCharServer() )
return 0;
WFIFOHEAD(inter_fd, 18);
WFIFOW(inter_fd, 0) = 0x303c;
@@ -717,7 +764,7 @@ int intif_guild_skillup(int guild_id, uint16 skill_id, int account_id, int max)
// Request a new guild relationship
int intif_guild_alliance(int guild_id1,int guild_id2,int account_id1,int account_id2,int flag)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd,19);
WFIFOW(inter_fd, 0)=0x303d;
@@ -733,7 +780,7 @@ int intif_guild_alliance(int guild_id1,int guild_id2,int account_id1,int account
// Request to change guild notice
int intif_guild_notice(int guild_id,const char *mes1,const char *mes2)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd,186);
WFIFOW(inter_fd,0)=0x303e;
@@ -747,7 +794,7 @@ int intif_guild_notice(int guild_id,const char *mes1,const char *mes2)
// Request to change guild emblem
int intif_guild_emblem(int guild_id,int len,const char *data)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
if(guild_id<=0 || len<0 || len>2000)
return 0;
@@ -768,7 +815,7 @@ int intif_guild_emblem(int guild_id,int len,const char *data)
*/
int intif_guild_castle_dataload(int num, int *castle_ids)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd, 4 + num * sizeof(int));
WFIFOW(inter_fd, 0) = 0x3040;
@@ -782,7 +829,7 @@ int intif_guild_castle_dataload(int num, int *castle_ids)
// Request change castle guild owner and save data
int intif_guild_castle_datasave(int castle_id,int index, int value)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd,9);
WFIFOW(inter_fd,0)=0x3041;
@@ -799,7 +846,7 @@ int intif_guild_castle_datasave(int castle_id,int index, int value)
int intif_homunculus_create(int account_id, struct s_homunculus *sh)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd, sizeof(struct s_homunculus)+8);
WFIFOW(inter_fd,0) = 0x3090;
@@ -811,7 +858,7 @@ int intif_homunculus_create(int account_id, struct s_homunculus *sh)
}
bool intif_homunculus_requestload(int account_id, int homun_id) {
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return false;
WFIFOHEAD(inter_fd, 10);
WFIFOW(inter_fd,0) = 0x3091;
@@ -823,7 +870,7 @@ bool intif_homunculus_requestload(int account_id, int homun_id) {
int intif_homunculus_requestsave(int account_id, struct s_homunculus* sh)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd, sizeof(struct s_homunculus)+8);
WFIFOW(inter_fd,0) = 0x3092;
@@ -837,7 +884,7 @@ int intif_homunculus_requestsave(int account_id, struct s_homunculus* sh)
int intif_homunculus_requestdelete(int homun_id)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd, 6);
WFIFOW(inter_fd, 0) = 0x3093;
@@ -852,8 +899,7 @@ int intif_homunculus_requestdelete(int homun_id)
// Packets receive from inter server
// Wisp/Page reception // rewritten by [Yor]
-int intif_parse_WisMessage(int fd)
-{
+void intif_parse_WisMessage(int fd) {
struct map_session_data* sd;
char *wisp_source;
char name[NAME_LENGTH];
@@ -862,15 +908,15 @@ int intif_parse_WisMessage(int fd)
id=RFIFOL(fd,4);
safestrncpy(name, (char*)RFIFOP(fd,32), NAME_LENGTH);
- sd = iMap->nick2sd(name);
- if(sd == NULL || strcmp(sd->status.name, name) != 0)
- { //Not found
+ sd = map->nick2sd(name);
+ if(sd == NULL || strcmp(sd->status.name, name) != 0) {
+ //Not found
intif_wis_replay(id,1);
- return 0;
+ return;
}
if(sd->state.ignoreAll) {
intif_wis_replay(id, 2);
- return 0;
+ return;
}
wisp_source = (char *) RFIFOP(fd,8); // speed up [Yor]
for(i=0; i < MAX_IGNORE_LIST &&
@@ -881,30 +927,27 @@ int intif_parse_WisMessage(int fd)
if (i < MAX_IGNORE_LIST && sd->ignore[i].name[0] != '\0')
{ //Ignored
intif_wis_replay(id, 2);
- return 0;
+ return;
}
//Success to send whisper.
clif->wis_message(sd->fd, wisp_source, (char*)RFIFOP(fd,56),RFIFOW(fd,2)-56);
- intif_wis_replay(id,0); // succes
- return 0;
+ intif_wis_replay(id,0); // success
}
// Wisp/page transmission result reception
-int intif_parse_WisEnd(int fd)
-{
+void intif_parse_WisEnd(int fd) {
struct map_session_data* sd;
if (battle_config.etc_log)
- ShowInfo("intif_parse_wisend: player: %s, flag: %d\n", RFIFOP(fd,2), RFIFOB(fd,26)); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
- sd = (struct map_session_data *)iMap->nick2sd((char *) RFIFOP(fd,2));
+ ShowInfo("intif_parse_wisend: player: %s, flag: %d\n", RFIFOP(fd,2), RFIFOB(fd,26)); // flag: 0: success to send whisper, 1: target character is not logged in?, 2: ignored by target
+ sd = (struct map_session_data *)map->nick2sd((char *) RFIFOP(fd,2));
if (sd != NULL)
clif->wis_end(sd->fd, RFIFOB(fd,26));
- return 0;
+ return;
}
-static int mapif_parse_WisToGM_sub(struct map_session_data* sd,va_list va)
-{
+int mapif_parse_WisToGM_sub(struct map_session_data* sd,va_list va) {
int permission = va_arg(va, int);
char *wisp_name;
char *message;
@@ -921,7 +964,7 @@ static int mapif_parse_WisToGM_sub(struct map_session_data* sd,va_list va)
// Received wisp message from map-server via char-server for ALL gm
// 0x3003/0x3803 <packet_len>.w <wispname>.24B <permission>.l <message>.?B
-int mapif_parse_WisToGM(int fd)
+void mapif_parse_WisToGM(int fd)
{
int permission, mes_len;
char Wisp_name[NAME_LENGTH];
@@ -935,238 +978,259 @@ int mapif_parse_WisToGM(int fd)
safestrncpy(Wisp_name, (char*)RFIFOP(fd,4), NAME_LENGTH);
safestrncpy(message, (char*)RFIFOP(fd,32), mes_len);
// information is sent to all online GM
- iMap->map_foreachpc(mapif_parse_WisToGM_sub, permission, Wisp_name, message, mes_len);
+ map->foreachpc(mapif_parse_WisToGM_sub, permission, Wisp_name, message, mes_len);
if (message != mbuf)
aFree(message);
- return 0;
}
// Request player registre
-int intif_parse_Registers(int fd)
+void intif_parse_Registers(int fd)
{
- int j,p,len,max, flag;
+ int i, flag;
struct map_session_data *sd;
- struct global_reg *reg;
- int *qty;
int account_id = RFIFOL(fd,4), char_id = RFIFOL(fd,8);
- struct auth_node *node = chrif_auth_check(account_id, char_id, ST_LOGIN);
+ struct auth_node *node = chrif->auth_check(account_id, char_id, ST_LOGIN);
+ char type = RFIFOB(fd, 13);
+
if (node)
sd = node->sd;
else { //Normally registries should arrive for in log-in chars.
- sd = iMap->id2sd(account_id);
- if (sd && RFIFOB(fd,12) == 3 && sd->status.char_id != char_id)
- sd = NULL; //Character registry from another character.
+ sd = map->id2sd(account_id);
}
- if (!sd) return 1;
-
- flag = (sd->save_reg.global_num == -1 || sd->save_reg.account_num == -1 || sd->save_reg.account2_num == -1);
-
+
+ if (!sd || sd->status.char_id != char_id) {
+ return; //Character registry from another character.
+ }
+
+ flag = ( sd->vars_received&PRL_ACCG && sd->vars_received&PRL_ACCL && sd->vars_received&PRL_CHAR ) ? 0 : 1;
+
switch (RFIFOB(fd,12)) {
case 3: //Character Registry
- reg = sd->save_reg.global;
- qty = &sd->save_reg.global_num;
- max = GLOBAL_REG_NUM;
- break;
+ sd->vars_received |= PRL_CHAR;
+ break;
case 2: //Account Registry
- reg = sd->save_reg.account;
- qty = &sd->save_reg.account_num;
- max = ACCOUNT_REG_NUM;
- break;
+ sd->vars_received |= PRL_ACCL;
+ break;
case 1: //Account2 Registry
- reg = sd->save_reg.account2;
- qty = &sd->save_reg.account2_num;
- max = ACCOUNT_REG2_NUM;
- break;
+ sd->vars_received |= PRL_ACCG;
+ break;
+ case 0:
+ break;
default:
ShowError("intif_parse_Registers: Unrecognized type %d\n",RFIFOB(fd,12));
- return 0;
+ return;
}
- for(j=0,p=13;j<max && p<RFIFOW(fd,2);j++){
- sscanf((char*)RFIFOP(fd,p), "%31c%n", reg[j].str,&len);
- reg[j].str[len]='\0';
- p += len+1; //+1 to skip the '\0' between strings.
- sscanf((char*)RFIFOP(fd,p), "%255c%n", reg[j].value,&len);
- reg[j].value[len]='\0';
- p += len+1;
+ /* have it not complain about insertion of vars before loading, and not set those vars as new or modified */
+ pc->reg_load = true;
+
+ if( RFIFOW(fd, 14) ) {
+ char key[32], sval[254];
+ unsigned int index;
+ int max = RFIFOW(fd, 14), cursor = 16, ival;
+
+ script->parser_current_file = "loading char/acc variables";//for script_add_str to refer to here in case errors occur
+
+ /**
+ * Vessel!char_reg_num_db
+ *
+ * str type
+ * { keyLength(B), key(<keyLength>), index(L), valLength(B), val(<valLength>) }
+ **/
+ if( type ) {
+ for(i = 0; i < max; i++) {
+ safestrncpy(key, (char*)RFIFOP(fd, cursor + 1), RFIFOB(fd, cursor));
+ cursor += RFIFOB(fd, cursor) + 1;
+
+ index = RFIFOL(fd, cursor);
+ cursor += 4;
+
+ safestrncpy(sval, (char*)RFIFOP(fd, cursor + 1), RFIFOB(fd, cursor));
+ cursor += RFIFOB(fd, cursor) + 1;
+
+ script->set_reg(NULL,sd,reference_uid(script->add_str(key), index), key, (void*)sval, NULL);
+ }
+ /**
+ * Vessel!
+ *
+ * int type
+ * { keyLength(B), key(<keyLength>), index(L), value(L) }
+ **/
+ } else {
+ for(i = 0; i < max; i++) {
+ safestrncpy(key, (char*)RFIFOP(fd, cursor + 1), RFIFOB(fd, cursor));
+ cursor += RFIFOB(fd, cursor) + 1;
+
+ index = RFIFOL(fd, cursor);
+ cursor += 4;
+
+ ival = RFIFOL(fd, cursor);
+ cursor += 4;
+
+ script->set_reg(NULL,sd,reference_uid(script->add_str(key), index), key, (void*)h64BPTRSIZE(ival), NULL);
+ }
+ }
+
+ script->parser_current_file = NULL;/* reset */
}
- *qty = j;
-
- if (flag && sd->save_reg.global_num > -1 && sd->save_reg.account_num > -1 && sd->save_reg.account2_num > -1)
+
+ /* flag it back */
+ pc->reg_load = false;
+
+ if (flag && sd->vars_received&PRL_ACCG && sd->vars_received&PRL_ACCL && sd->vars_received&PRL_CHAR)
pc->reg_received(sd); //Received all registry values, execute init scripts and what-not. [Skotlex]
- return 1;
}
-int intif_parse_LoadGuildStorage(int fd)
+void intif_parse_LoadGuildStorage(int fd)
{
struct guild_storage *gstor;
struct map_session_data *sd;
- int guild_id;
+ int guild_id, flag;
guild_id = RFIFOL(fd,8);
+ flag = RFIFOL(fd,12);
if(guild_id <= 0)
- return 1;
- sd=iMap->id2sd( RFIFOL(fd,4) );
- if(sd==NULL){
- ShowError("intif_parse_LoadGuildStorage: user not found %d\n",RFIFOL(fd,4));
- return 1;
+ return;
+ sd=map->id2sd( RFIFOL(fd,4) );
+ if( flag ){ //If flag != 0, we attach a player and open the storage
+ if(sd==NULL){
+ ShowError("intif_parse_LoadGuildStorage: user not found %d\n",RFIFOL(fd,4));
+ return;
+ }
}
- gstor=guild2storage(guild_id);
+ gstor=gstorage->id2storage(guild_id);
if(!gstor) {
ShowWarning("intif_parse_LoadGuildStorage: error guild_id %d not exist\n",guild_id);
- return 1;
+ return;
}
if (gstor->storage_status == 1) { // Already open.. lets ignore this update
- ShowWarning("intif_parse_LoadGuildStorage: storage received for a client already open (User %d:%d)\n", sd->status.account_id, sd->status.char_id);
- return 1;
+ ShowWarning("intif_parse_LoadGuildStorage: storage received for a client already open (User %d:%d)\n", flag?sd->status.account_id:0, flag?sd->status.char_id:0);
+ return;
}
if (gstor->dirty) { // Already have storage, and it has been modified and not saved yet! Exploit! [Skotlex]
- ShowWarning("intif_parse_LoadGuildStorage: received storage for an already modified non-saved storage! (User %d:%d)\n", sd->status.account_id, sd->status.char_id);
- return 1;
+ ShowWarning("intif_parse_LoadGuildStorage: received storage for an already modified non-saved storage! (User %d:%d)\n", flag?sd->status.account_id:0, flag?sd->status.char_id:0);
+ return;
}
- if( RFIFOW(fd,2)-12 != sizeof(struct guild_storage) ){
- ShowError("intif_parse_LoadGuildStorage: data size error %d %d\n",RFIFOW(fd,2)-12 , sizeof(struct guild_storage));
- gstor->storage_status = 0;
- return 1;
+ if (RFIFOW(fd,2)-13 != sizeof(struct guild_storage)) {
+ ShowError("intif_parse_LoadGuildStorage: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd,2)-13, sizeof(struct guild_storage));
+ gstor->storage_status = 0;
+ return;
}
- memcpy(gstor,RFIFOP(fd,12),sizeof(struct guild_storage));
- storage_guild_storageopen(sd);
- return 0;
+ memcpy(gstor,RFIFOP(fd,13),sizeof(struct guild_storage));
+ if( flag )
+ gstorage->open(sd);
}
// ACK guild_storage saved
-int intif_parse_SaveGuildStorage(int fd)
+void intif_parse_SaveGuildStorage(int fd)
{
- storage_guild_storagesaved(/*RFIFOL(fd,2), */RFIFOL(fd,6));
- return 0;
+ gstorage->saved(/*RFIFOL(fd,2), */RFIFOL(fd,6));
}
// ACK party creation
-int intif_parse_PartyCreated(int fd)
+void intif_parse_PartyCreated(int fd)
{
if(battle_config.etc_log)
ShowInfo("intif: party created by account %d\n\n", RFIFOL(fd,2));
party->created(RFIFOL(fd,2), RFIFOL(fd,6),RFIFOB(fd,10),RFIFOL(fd,11), (char *)RFIFOP(fd,15));
- return 0;
}
// Receive party info
-int intif_parse_PartyInfo(int fd)
-{
- if( RFIFOW(fd,2) == 12 ){
+void intif_parse_PartyInfo(int fd) {
+ if (RFIFOW(fd,2) == 12) {
ShowWarning("intif: party noinfo (char_id=%d party_id=%d)\n", RFIFOL(fd,4), RFIFOL(fd,8));
party->recv_noinfo(RFIFOL(fd,8), RFIFOL(fd,4));
- return 0;
+ return;
}
- if( RFIFOW(fd,2) != 8+sizeof(struct party) )
- ShowError("intif: party info : data size error (char_id=%d party_id=%d packet_len=%d expected_len=%d)\n", RFIFOL(fd,4), RFIFOL(fd,8), RFIFOW(fd,2), 8+sizeof(struct party));
+ if (RFIFOW(fd,2) != 8+sizeof(struct party))
+ ShowError("intif: party info: data size mismatch (char_id=%d party_id=%d packet_len=%d expected_len=%"PRIuS")\n",
+ RFIFOL(fd,4), RFIFOL(fd,8), RFIFOW(fd,2), 8+sizeof(struct party));
party->recv_info((struct party *)RFIFOP(fd,8), RFIFOL(fd,4));
- return 0;
}
// ACK adding party member
-int intif_parse_PartyMemberAdded(int fd)
+void intif_parse_PartyMemberAdded(int fd)
{
if(battle_config.etc_log)
ShowInfo("intif: party member added Party (%d), Account(%d), Char(%d)\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
party->member_added(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10), RFIFOB(fd, 14));
- return 0;
}
// ACK changing party option
-int intif_parse_PartyOptionChanged(int fd)
+void intif_parse_PartyOptionChanged(int fd)
{
party->optionchanged(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOW(fd,10),RFIFOW(fd,12),RFIFOB(fd,14));
- return 0;
}
// ACK member leaving party
-int intif_parse_PartyMemberWithdraw(int fd)
+void intif_parse_PartyMemberWithdraw(int fd)
{
if(battle_config.etc_log)
ShowInfo("intif: party member withdraw: Party(%d), Account(%d), Char(%d)\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
party->member_withdraw(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
- return 0;
}
// ACK party break
-int intif_parse_PartyBroken(int fd)
-{
+void intif_parse_PartyBroken(int fd) {
party->broken(RFIFOL(fd,2));
- return 0;
}
// ACK party on new map
-int intif_parse_PartyMove(int fd)
+void intif_parse_PartyMove(int fd)
{
party->recv_movemap(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOW(fd,14),RFIFOB(fd,16),RFIFOW(fd,17));
- return 0;
}
// ACK party messages
-int intif_parse_PartyMessage(int fd)
-{
+void intif_parse_PartyMessage(int fd) {
party->recv_message(RFIFOL(fd,4),RFIFOL(fd,8),(char *) RFIFOP(fd,12),RFIFOW(fd,2)-12);
- return 0;
}
// ACK guild creation
-int intif_parse_GuildCreated(int fd)
-{
+void intif_parse_GuildCreated(int fd) {
guild->created(RFIFOL(fd,2),RFIFOL(fd,6));
- return 0;
}
// ACK guild infos
-int intif_parse_GuildInfo(int fd)
-{
- if(RFIFOW(fd,2) == 8) {
+void intif_parse_GuildInfo(int fd) {
+ if (RFIFOW(fd,2) == 8) {
ShowWarning("intif: guild noinfo %d\n",RFIFOL(fd,4));
guild->recv_noinfo(RFIFOL(fd,4));
- return 0;
+ return;
}
- if( RFIFOW(fd,2)!=sizeof(struct guild)+4 )
- ShowError("intif: guild info : data size error Gid: %d recv size: %d Expected size: %d\n",RFIFOL(fd,4),RFIFOW(fd,2),sizeof(struct guild)+4);
+ if (RFIFOW(fd,2)!=sizeof(struct guild)+4)
+ ShowError("intif: guild info: data size mismatch - Gid: %d recv size: %d Expected size: %"PRIuS"\n",
+ RFIFOL(fd,4),RFIFOW(fd,2),sizeof(struct guild)+4);
guild->recv_info((struct guild *)RFIFOP(fd,4));
- return 0;
}
// ACK adding guild member
-int intif_parse_GuildMemberAdded(int fd)
-{
+void intif_parse_GuildMemberAdded(int fd) {
if(battle_config.etc_log)
ShowInfo("intif: guild member added %d %d %d %d\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14));
guild->member_added(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14));
- return 0;
}
// ACK member leaving guild
-int intif_parse_GuildMemberWithdraw(int fd)
-{
+void intif_parse_GuildMemberWithdraw(int fd) {
guild->member_withdraw(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),(char *)RFIFOP(fd,55),(char *)RFIFOP(fd,15));
- return 0;
}
// ACK guild member basic info
-int intif_parse_GuildMemberInfoShort(int fd)
-{
+void intif_parse_GuildMemberInfoShort(int fd) {
guild->recv_memberinfoshort(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),RFIFOW(fd,15),RFIFOW(fd,17));
- return 0;
}
// ACK guild break
-int intif_parse_GuildBroken(int fd)
-{
+void intif_parse_GuildBroken(int fd) {
guild->broken(RFIFOL(fd,2),RFIFOB(fd,6));
- return 0;
}
// basic guild info change notice
// 0x3839 <packet len>.w <guild id>.l <type>.w <data>.?b
-int intif_parse_GuildBasicInfoChanged(int fd)
-{
+void intif_parse_GuildBasicInfoChanged(int fd) {
//int len = RFIFOW(fd,2) - 10;
int guild_id = RFIFOL(fd,4);
int type = RFIFOW(fd,8);
@@ -1174,21 +1238,33 @@ int intif_parse_GuildBasicInfoChanged(int fd)
struct guild* g = guild->search(guild_id);
if( g == NULL )
- return 0;
+ return;
switch(type) {
- case GBI_EXP: g->exp = RFIFOQ(fd,10); break;
- case GBI_GUILDLV: g->guild_lv = RFIFOW(fd,10); break;
- case GBI_SKILLPOINT: g->skill_point = RFIFOL(fd,10); break;
+ case GBI_EXP: g->exp = RFIFOQ(fd,10); break;
+ case GBI_GUILDLV: g->guild_lv = RFIFOW(fd,10); break;
+ case GBI_SKILLPOINT: g->skill_point = RFIFOL(fd,10); break;
+ case GBI_SKILLLV: {
+ int idx, max;
+ struct guild_skill *gs = (struct guild_skill *)RFIFOP(fd,10);
+
+ if( gs == NULL )
+ return;
+
+ idx = gs->id - GD_SKILLBASE;
+ max = guild->skill_get_max(gs->id);
+ if( gs->lv > max )
+ gs->lv = max;
+
+ memcpy(&(g->skill[idx]), gs, sizeof(g->skill[idx]));
+ break;
+ }
}
-
- return 0;
}
// guild member info change notice
// 0x383a <packet len>.w <guild id>.l <account id>.l <char id>.l <type>.w <data>.?b
-int intif_parse_GuildMemberInfoChanged(int fd)
-{
+void intif_parse_GuildMemberInfoChanged(int fd) {
//int len = RFIFOW(fd,2) - 18;
int guild_id = RFIFOL(fd,4);
int account_id = RFIFOL(fd,8);
@@ -1201,189 +1277,152 @@ int intif_parse_GuildMemberInfoChanged(int fd)
g = guild->search(guild_id);
if( g == NULL )
- return 0;
+ return;
idx = guild->getindex(g,account_id,char_id);
if( idx == -1 )
- return 0;
+ return;
switch( type ) {
- case GMI_POSITION: g->member[idx].position = RFIFOW(fd,18); guild->memberposition_changed(g,idx,RFIFOW(fd,18)); break;
- case GMI_EXP: g->member[idx].exp = RFIFOQ(fd,18); break;
- case GMI_HAIR: g->member[idx].hair = RFIFOW(fd,18); break;
- case GMI_HAIR_COLOR: g->member[idx].hair_color = RFIFOW(fd,18); break;
- case GMI_GENDER: g->member[idx].gender = RFIFOW(fd,18); break;
- case GMI_CLASS: g->member[idx].class_ = RFIFOW(fd,18); break;
- case GMI_LEVEL: g->member[idx].lv = RFIFOW(fd,18); break;
+ case GMI_POSITION: g->member[idx].position = RFIFOW(fd,18); guild->memberposition_changed(g,idx,RFIFOW(fd,18)); break;
+ case GMI_EXP: g->member[idx].exp = RFIFOQ(fd,18); break;
+ case GMI_HAIR: g->member[idx].hair = RFIFOW(fd,18); break;
+ case GMI_HAIR_COLOR: g->member[idx].hair_color = RFIFOW(fd,18); break;
+ case GMI_GENDER: g->member[idx].gender = RFIFOW(fd,18); break;
+ case GMI_CLASS: g->member[idx].class_ = RFIFOW(fd,18); break;
+ case GMI_LEVEL: g->member[idx].lv = RFIFOW(fd,18); break;
}
- return 0;
}
// ACK change of guild title
-int intif_parse_GuildPosition(int fd)
-{
- if( RFIFOW(fd,2)!=sizeof(struct guild_position)+12 )
- ShowError("intif: guild info : data size error\n %d %d %d",RFIFOL(fd,4),RFIFOW(fd,2),sizeof(struct guild_position)+12);
+void intif_parse_GuildPosition(int fd) {
+ if (RFIFOW(fd,2)!=sizeof(struct guild_position)+12)
+ ShowError("intif: guild info: data size mismatch (%d) %d != %"PRIuS"\n",
+ RFIFOL(fd,4),RFIFOW(fd,2),sizeof(struct guild_position)+12);
guild->position_changed(RFIFOL(fd,4),RFIFOL(fd,8),(struct guild_position *)RFIFOP(fd,12));
- return 0;
}
// ACK change of guild skill update
-int intif_parse_GuildSkillUp(int fd)
-{
+void intif_parse_GuildSkillUp(int fd) {
guild->skillupack(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
- return 0;
}
// ACK change of guild relationship
-int intif_parse_GuildAlliance(int fd)
-{
+void intif_parse_GuildAlliance(int fd) {
guild->allianceack(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOL(fd,14),RFIFOB(fd,18),(char *) RFIFOP(fd,19),(char *) RFIFOP(fd,43));
- return 0;
}
// ACK change of guild notice
-int intif_parse_GuildNotice(int fd)
-{
+void intif_parse_GuildNotice(int fd) {
guild->notice_changed(RFIFOL(fd,2),(char *) RFIFOP(fd,6),(char *) RFIFOP(fd,66));
- return 0;
}
// ACK change of guild emblem
-int intif_parse_GuildEmblem(int fd)
-{
+void intif_parse_GuildEmblem(int fd) {
guild->emblem_changed(RFIFOW(fd,2)-12,RFIFOL(fd,4),RFIFOL(fd,8), (char *)RFIFOP(fd,12));
- return 0;
}
// ACK guild message
-int intif_parse_GuildMessage(int fd)
-{
+void intif_parse_GuildMessage(int fd) {
guild->recv_message(RFIFOL(fd,4),RFIFOL(fd,8),(char *) RFIFOP(fd,12),RFIFOW(fd,2)-12);
- return 0;
}
// Reply guild castle data request
-int intif_parse_GuildCastleDataLoad(int fd)
-{
- return guild->castledataloadack(RFIFOW(fd,2), (struct guild_castle *)RFIFOP(fd,4));
+void intif_parse_GuildCastleDataLoad(int fd) {
+ guild->castledataloadack(RFIFOW(fd,2), (struct guild_castle *)RFIFOP(fd,4));
}
// ACK change of guildmaster
-int intif_parse_GuildMasterChanged(int fd)
-{
- return guild->gm_changed(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
+void intif_parse_GuildMasterChanged(int fd) {
+ guild->gm_changed(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
}
// Request pet creation
-int intif_parse_CreatePet(int fd)
-{
- pet_get_egg(RFIFOL(fd,2),RFIFOL(fd,7),RFIFOB(fd,6));
- return 0;
+void intif_parse_CreatePet(int fd) {
+ pet->get_egg(RFIFOL(fd,2), RFIFOW(fd,6), RFIFOL(fd,8));
}
// ACK pet data
-int intif_parse_RecvPetData(int fd)
-{
+void intif_parse_RecvPetData(int fd) {
struct s_pet p;
int len;
len=RFIFOW(fd,2);
- if(sizeof(struct s_pet)!=len-9) {
- if(battle_config.etc_log)
- ShowError("intif: pet data: data size error %d %d\n",sizeof(struct s_pet),len-9);
- }
- else{
+ if (sizeof(struct s_pet) != len-9) {
+ if (battle_config.etc_log)
+ ShowError("intif: pet data: data size mismatch %d != %"PRIuS"\n", len-9, sizeof(struct s_pet));
+ } else {
memcpy(&p,RFIFOP(fd,9),sizeof(struct s_pet));
- pet_recv_petdata(RFIFOL(fd,4),&p,RFIFOB(fd,8));
+ pet->recv_petdata(RFIFOL(fd,4),&p,RFIFOB(fd,8));
}
-
- return 0;
}
-
+/* Really? Whats the point, shouldn't be sent when successful then [Ind] */
// ACK pet save data
-int intif_parse_SavePetOk(int fd)
-{
+void intif_parse_SavePetOk(int fd) {
if(RFIFOB(fd,6) == 1)
ShowError("pet data save failure\n");
-
- return 0;
}
-
+/* Really? Whats the point, shouldn't be sent when successful then [Ind] */
// ACK deleting pet
-int intif_parse_DeletePetOk(int fd)
-{
+void intif_parse_DeletePetOk(int fd) {
if(RFIFOB(fd,2) == 1)
ShowError("pet data delete failure\n");
-
- return 0;
}
-// ACK changing name resquest, players,pets,hommon
-int intif_parse_ChangeNameOk(int fd)
+// ACK changing name request, players,pets,homun
+void intif_parse_ChangeNameOk(int fd)
{
struct map_session_data *sd = NULL;
- if((sd=iMap->id2sd(RFIFOL(fd,2)))==NULL ||
+ if((sd=map->id2sd(RFIFOL(fd,2)))==NULL ||
sd->status.char_id != RFIFOL(fd,6))
- return 0;
+ return;
switch (RFIFOB(fd,10)) {
case 0: //Players [NOT SUPPORTED YET]
break;
case 1: //Pets
- pet_change_name_ack(sd, (char*)RFIFOP(fd,12), RFIFOB(fd,11));
+ pet->change_name_ack(sd, (char*)RFIFOP(fd,12), RFIFOB(fd,11));
break;
case 2: //Hom
homun->change_name_ack(sd, (char*)RFIFOP(fd,12), RFIFOB(fd,11));
break;
}
- return 0;
+ return;
}
//----------------------------------------------------------------
// Homunculus recv packets [albator]
-int intif_parse_CreateHomunculus(int fd)
-{
- int len;
- len=RFIFOW(fd,2)-9;
- if(sizeof(struct s_homunculus)!=len) {
- if(battle_config.etc_log)
- ShowError("intif: create homun data: data size error %d != %d\n",sizeof(struct s_homunculus),len);
- return 0;
+void intif_parse_CreateHomunculus(int fd) {
+ int len = RFIFOW(fd,2)-9;
+ if (sizeof(struct s_homunculus) != len) {
+ if (battle_config.etc_log)
+ ShowError("intif: create homun data: data size mismatch %d != %"PRIuS"\n", len, sizeof(struct s_homunculus));
+ return;
}
homun->recv_data(RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,9), RFIFOB(fd,8)) ;
- return 0;
}
-int intif_parse_RecvHomunculusData(int fd)
-{
- int len;
-
- len=RFIFOW(fd,2)-9;
+void intif_parse_RecvHomunculusData(int fd) {
+ int len = RFIFOW(fd,2)-9;
- if(sizeof(struct s_homunculus)!=len) {
- if(battle_config.etc_log)
- ShowError("intif: homun data: data size error %d %d\n",sizeof(struct s_homunculus),len);
- return 0;
+ if (sizeof(struct s_homunculus) != len) {
+ if (battle_config.etc_log)
+ ShowError("intif: homun data: data size mismatch %d != %"PRIuS"\n", len, sizeof(struct s_homunculus));
+ return;
}
homun->recv_data(RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,9), RFIFOB(fd,8));
- return 0;
}
-int intif_parse_SaveHomunculusOk(int fd)
-{
+/* Really? Whats the point, shouldn't be sent when successful then [Ind] */
+void intif_parse_SaveHomunculusOk(int fd) {
if(RFIFOB(fd,6) != 1)
ShowError("homunculus data save failure for account %d\n", RFIFOL(fd,2));
-
- return 0;
}
-int intif_parse_DeleteHomunculusOk(int fd)
-{
+/* Really? Whats the point, shouldn't be sent when successful then [Ind] */
+void intif_parse_DeleteHomunculusOk(int fd) {
if(RFIFOB(fd,2) != 1)
ShowError("Homunculus data delete failure\n");
-
- return 0;
}
/**************************************
@@ -1392,81 +1431,108 @@ QUESTLOG SYSTEM FUNCTIONS
***************************************/
-int intif_request_questlog(TBL_PC *sd)
-{
+/**
+ * Requests a character's quest log entries to the inter server.
+ *
+ * @param sd Character's data
+ */
+void intif_request_questlog(TBL_PC *sd) {
WFIFOHEAD(inter_fd,6);
WFIFOW(inter_fd,0) = 0x3060;
WFIFOL(inter_fd,2) = sd->status.char_id;
WFIFOSET(inter_fd,6);
- return 0;
}
-int intif_parse_questlog(int fd)
-{
- int char_id = RFIFOL(fd, 4);
- int i;
- TBL_PC * sd = iMap->charid2sd(char_id);
-
- //User not online anymore
- if(!sd)
- return -1;
-
- sd->avail_quests = sd->num_quests = (RFIFOW(fd, 2)-8)/sizeof(struct quest);
-
- memset(&sd->quest_log, 0, sizeof(sd->quest_log));
+/**
+ * Parses the received quest log entries for a character from the inter server.
+ *
+ * Received in reply to the requests made by intif_request_questlog.
+ *
+ * @see intif_parse
+ */
+void intif_parse_QuestLog(int fd) {
+ int char_id = RFIFOL(fd, 4), num_received = (RFIFOW(fd, 2)-8)/sizeof(struct quest);
+ TBL_PC *sd = map->charid2sd(char_id);
- for( i = 0; i < sd->num_quests; i++ )
- {
- memcpy(&sd->quest_log[i], RFIFOP(fd, i*sizeof(struct quest)+8), sizeof(struct quest));
+ if (!sd) // User not online anymore
+ return;
- sd->quest_index[i] = quest_search_db(sd->quest_log[i].quest_id);
+ sd->num_quests = sd->avail_quests = 0;
- if( sd->quest_index[i] < 0 )
- {
- ShowError("intif_parse_questlog: quest %d not found in DB.\n",sd->quest_log[i].quest_id);
- sd->avail_quests--;
- sd->num_quests--;
- i--;
- continue;
+ if (num_received == 0) {
+ if (sd->quest_log) {
+ aFree(sd->quest_log);
+ sd->quest_log = NULL;
+ }
+ } else {
+ struct quest *received = (struct quest *)RFIFOP(fd, 8);
+ int i, k = num_received;
+ if (sd->quest_log) {
+ RECREATE(sd->quest_log, struct quest, num_received);
+ } else {
+ CREATE(sd->quest_log, struct quest, num_received);
}
- if( sd->quest_log[i].state == Q_COMPLETE )
- sd->avail_quests--;
+ for (i = 0; i < num_received; i++) {
+ if( quest->db(received[i].quest_id) == &quest->dummy ) {
+ ShowError("intif_parse_QuestLog: quest %d not found in DB.\n", received[i].quest_id);
+ continue;
+ }
+ if (received[i].state != Q_COMPLETE) {
+ // Insert at the beginning
+ memcpy(&sd->quest_log[sd->avail_quests++], &received[i], sizeof(struct quest));
+ } else {
+ // Insert at the end
+ memcpy(&sd->quest_log[--k], &received[i], sizeof(struct quest));
+ }
+ sd->num_quests++;
+ }
+ if (sd->avail_quests < k) {
+ // sd->avail_quests and k didn't meet in the middle: some entries were skipped
+ if (k < num_received) // Move the entries at the end to fill the gap
+ memmove(&sd->quest_log[k], &sd->quest_log[sd->avail_quests], sizeof(struct quest)*(num_received - k));
+ sd->quest_log = aRealloc(sd->quest_log, sizeof(struct quest)*sd->num_quests);
+ }
}
- quest_pc_login(sd);
-
- return 0;
+ quest->pc_login(sd);
}
-int intif_parse_questsave(int fd)
-{
+/**
+ * Parses the quest log save ack for a character from the inter server.
+ *
+ * Received in reply to the requests made by intif_quest_save.
+ *
+ * @see intif_parse
+ */
+void intif_parse_QuestSave(int fd) {
int cid = RFIFOL(fd, 2);
- TBL_PC *sd = iMap->id2sd(cid);
+ TBL_PC *sd = map->id2sd(cid);
if( !RFIFOB(fd, 6) )
- ShowError("intif_parse_questsave: Failed to save quest(s) for character %d!\n", cid);
+ ShowError("intif_parse_QuestSave: Failed to save quest(s) for character %d!\n", cid);
else if( sd )
sd->save_quest = false;
-
- return 0;
}
-int intif_quest_save(TBL_PC *sd)
-{
- int len;
-
- if(CheckForCharServer())
- return 0;
+/**
+ * Requests to the inter server to save a character's quest log entries.
+ *
+ * @param sd Character's data
+ * @return 0 in case of success, nonzero otherwise
+ */
+int intif_quest_save(TBL_PC *sd) {
+ int len = sizeof(struct quest)*sd->num_quests + 8;
- len = sizeof(struct quest)*sd->num_quests + 8;
+ if(intif->CheckForCharServer())
+ return 1;
WFIFOHEAD(inter_fd, len);
WFIFOW(inter_fd,0) = 0x3061;
WFIFOW(inter_fd,2) = len;
WFIFOL(inter_fd,4) = sd->status.char_id;
if( sd->num_quests )
- memcpy(WFIFOP(inter_fd,8), &sd->quest_log, sizeof(struct quest)*sd->num_quests);
+ memcpy(WFIFOP(inter_fd,8), sd->quest_log, sizeof(struct quest)*sd->num_quests);
WFIFOSET(inter_fd, len);
return 0;
@@ -1483,7 +1549,7 @@ int intif_quest_save(TBL_PC *sd)
*------------------------------------------*/
int intif_Mail_requestinbox(int char_id, unsigned char flag)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd,7);
@@ -1495,23 +1561,20 @@ int intif_Mail_requestinbox(int char_id, unsigned char flag)
return 0;
}
-int intif_parse_Mail_inboxreceived(int fd)
-{
+void intif_parse_MailInboxReceived(int fd) {
struct map_session_data *sd;
unsigned char flag = RFIFOB(fd,8);
- sd = iMap->charid2sd(RFIFOL(fd,4));
+ sd = map->charid2sd(RFIFOL(fd,4));
- if (sd == NULL)
- {
- ShowError("intif_parse_Mail_inboxreceived: char not found %d\n",RFIFOL(fd,4));
- return 1;
+ if (sd == NULL) {
+ ShowError("intif_parse_MailInboxReceived: char not found %d\n",RFIFOL(fd,4));
+ return;
}
- if (RFIFOW(fd,2) - 9 != sizeof(struct mail_data))
- {
- ShowError("intif_parse_Mail_inboxreceived: data size error %d %d\n", RFIFOW(fd,2) - 9, sizeof(struct mail_data));
- return 1;
+ if (RFIFOW(fd,2) - 9 != sizeof(struct mail_data)) {
+ ShowError("intif_parse_MailInboxReceived: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd,2) - 9, sizeof(struct mail_data));
+ return;
}
//FIXME: this operation is not safe [ultramage]
@@ -1520,20 +1583,18 @@ int intif_parse_Mail_inboxreceived(int fd)
if (flag)
clif->mail_refreshinbox(sd);
- else if( battle_config.mail_show_status && ( battle_config.mail_show_status == 1 || sd->mail.inbox.unread ) )
- {
+ else if( battle_config.mail_show_status && ( battle_config.mail_show_status == 1 || sd->mail.inbox.unread ) ) {
char output[128];
sprintf(output, msg_txt(510), sd->mail.inbox.unchecked, sd->mail.inbox.unread + sd->mail.inbox.unchecked);
- clif->disp_onlyself(sd, output, strlen(output));
+ clif_disp_onlyself(sd, output, strlen(output));
}
- return 0;
}
/*------------------------------------------
* Mail Read
*------------------------------------------*/
int intif_Mail_read(int mail_id)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd,6);
@@ -1548,7 +1609,7 @@ int intif_Mail_read(int mail_id)
*------------------------------------------*/
int intif_Mail_getattach(int char_id, int mail_id)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd,10);
@@ -1560,37 +1621,33 @@ int intif_Mail_getattach(int char_id, int mail_id)
return 0;
}
-int intif_parse_Mail_getattach(int fd)
-{
+void intif_parse_MailGetAttach(int fd) {
struct map_session_data *sd;
struct item item;
int zeny = RFIFOL(fd,8);
- sd = iMap->charid2sd( RFIFOL(fd,4) );
+ sd = map->charid2sd( RFIFOL(fd,4) );
- if (sd == NULL)
- {
- ShowError("intif_parse_Mail_getattach: char not found %d\n",RFIFOL(fd,4));
- return 1;
+ if (sd == NULL) {
+ ShowError("intif_parse_MailGetAttach: char not found %d\n",RFIFOL(fd,4));
+ return;
}
- if (RFIFOW(fd,2) - 12 != sizeof(struct item))
- {
- ShowError("intif_parse_Mail_getattach: data size error %d %d\n", RFIFOW(fd,2) - 16, sizeof(struct item));
- return 1;
+ if (RFIFOW(fd,2) - 12 != sizeof(struct item)) {
+ ShowError("intif_parse_MailGetAttach: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd,2) - 16, sizeof(struct item));
+ return;
}
memcpy(&item, RFIFOP(fd,12), sizeof(struct item));
mail->getattachment(sd, zeny, &item);
- return 0;
}
/*------------------------------------------
* Delete Message
*------------------------------------------*/
int intif_Mail_delete(int char_id, int mail_id)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd,10);
@@ -1602,42 +1659,37 @@ int intif_Mail_delete(int char_id, int mail_id)
return 0;
}
-int intif_parse_Mail_delete(int fd)
-{
+void intif_parse_MailDelete(int fd) {
+ struct map_session_data *sd;
int char_id = RFIFOL(fd,2);
int mail_id = RFIFOL(fd,6);
bool failed = RFIFOB(fd,10);
-
- struct map_session_data *sd = iMap->charid2sd(char_id);
- if (sd == NULL)
- {
- ShowError("intif_parse_Mail_delete: char not found %d\n", char_id);
- return 1;
+
+ if ( (sd = map->charid2sd(char_id)) == NULL) {
+ ShowError("intif_parse_MailDelete: char not found %d\n", char_id);
+ return;
}
- if (!failed)
- {
+ if (!failed) {
int i;
ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id);
- if( i < MAIL_MAX_INBOX )
- {
+ if( i < MAIL_MAX_INBOX ) {
memset(&sd->mail.inbox.msg[i], 0, sizeof(struct mail_message));
sd->mail.inbox.amount--;
}
if( sd->mail.inbox.full )
- intif_Mail_requestinbox(sd->status.char_id, 1); // Free space is available for new mails
+ intif->Mail_requestinbox(sd->status.char_id, 1); // Free space is available for new mails
}
clif->mail_delete(sd->fd, mail_id, failed);
- return 0;
}
/*------------------------------------------
* Return Message
*------------------------------------------*/
int intif_Mail_return(int char_id, int mail_id)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd,10);
@@ -1649,34 +1701,29 @@ int intif_Mail_return(int char_id, int mail_id)
return 0;
}
-int intif_parse_Mail_return(int fd)
-{
- struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2));
+void intif_parse_MailReturn(int fd) {
+ struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2));
int mail_id = RFIFOL(fd,6);
short fail = RFIFOB(fd,10);
- if( sd == NULL )
- {
- ShowError("intif_parse_Mail_return: char not found %d\n",RFIFOL(fd,2));
- return 1;
+ if( sd == NULL ) {
+ ShowError("intif_parse_MailReturn: char not found %d\n",RFIFOL(fd,2));
+ return;
}
- if( !fail )
- {
+ if( !fail ) {
int i;
ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id);
- if( i < MAIL_MAX_INBOX )
- {
+ if( i < MAIL_MAX_INBOX ) {
memset(&sd->mail.inbox.msg[i], 0, sizeof(struct mail_message));
sd->mail.inbox.amount--;
}
if( sd->mail.inbox.full )
- intif_Mail_requestinbox(sd->status.char_id, 1); // Free space is available for new mails
+ intif->Mail_requestinbox(sd->status.char_id, 1); // Free space is available for new mails
}
clif->mail_return(sd->fd, mail_id, fail);
- return 0;
}
/*------------------------------------------
* Send Mail
@@ -1685,7 +1732,7 @@ int intif_Mail_send(int account_id, struct mail_message *msg)
{
int len = sizeof(struct mail_message) + 8;
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd,len);
@@ -1698,15 +1745,13 @@ int intif_Mail_send(int account_id, struct mail_message *msg)
return 1;
}
-static void intif_parse_Mail_send(int fd)
-{
+void intif_parse_MailSend(int fd) {
struct mail_message msg;
struct map_session_data *sd;
bool fail;
- if( RFIFOW(fd,2) - 4 != sizeof(struct mail_message) )
- {
- ShowError("intif_parse_Mail_send: data size error %d %d\n", RFIFOW(fd,2) - 4, sizeof(struct mail_message));
+ if( RFIFOW(fd,2) - 4 != sizeof(struct mail_message) ) {
+ ShowError("intif_parse_MailSend: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd,2) - 4, sizeof(struct mail_message));
return;
}
@@ -1714,23 +1759,20 @@ static void intif_parse_Mail_send(int fd)
fail = (msg.id == 0);
// notify sender
- sd = iMap->charid2sd(msg.send_id);
- if( sd != NULL )
- {
+ sd = map->charid2sd(msg.send_id);
+ if( sd != NULL ) {
if( fail )
mail->deliveryfail(sd, &msg);
- else
- {
+ else {
clif->mail_send(sd->fd, false);
- if( iMap->save_settings&16 )
- chrif_save(sd, 0);
+ if( map->save_settings&16 )
+ chrif->save(sd, 0);
}
}
}
-static void intif_parse_Mail_new(int fd)
-{
- struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2));
+void intif_parse_MailNew(int fd) {
+ struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2));
int mail_id = RFIFOL(fd,6);
const char* sender_name = (char*)RFIFOP(fd,10);
const char* title = (char*)RFIFOP(fd,34);
@@ -1750,7 +1792,7 @@ int intif_Auction_requestlist(int char_id, short type, int price, const char* se
{
int len = NAME_LENGTH + 16;
- if( CheckForCharServer() )
+ if( intif->CheckForCharServer() )
return 0;
WFIFOHEAD(inter_fd,len);
@@ -1766,9 +1808,8 @@ int intif_Auction_requestlist(int char_id, short type, int price, const char* se
return 0;
}
-static void intif_parse_Auction_results(int fd)
-{
- struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,4));
+void intif_parse_AuctionResults(int fd) {
+ struct map_session_data *sd = map->charid2sd(RFIFOL(fd,4));
short count = RFIFOW(fd,8);
short pages = RFIFOW(fd,10);
uint8* data = RFIFOP(fd,12);
@@ -1783,7 +1824,7 @@ int intif_Auction_register(struct auction_data *auction)
{
int len = sizeof(struct auction_data) + 4;
- if( CheckForCharServer() )
+ if( intif->CheckForCharServer() )
return 0;
WFIFOHEAD(inter_fd,len);
@@ -1795,29 +1836,24 @@ int intif_Auction_register(struct auction_data *auction)
return 1;
}
-static void intif_parse_Auction_register(int fd)
-{
+void intif_parse_AuctionRegister(int fd) {
struct map_session_data *sd;
struct auction_data auction;
- if( RFIFOW(fd,2) - 4 != sizeof(struct auction_data) )
- {
- ShowError("intif_parse_Auction_register: data size error %d %d\n", RFIFOW(fd,2) - 4, sizeof(struct auction_data));
+ if (RFIFOW(fd,2) - 4 != sizeof(struct auction_data)) {
+ ShowError("intif_parse_AuctionRegister: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd,2) - 4, sizeof(struct auction_data));
return;
}
memcpy(&auction, RFIFOP(fd,4), sizeof(struct auction_data));
- if( (sd = iMap->charid2sd(auction.seller_id)) == NULL )
+ if( (sd = map->charid2sd(auction.seller_id)) == NULL )
return;
- if( auction.auction_id > 0 )
- {
+ if( auction.auction_id > 0 ) {
clif->auction_message(sd->fd, 1); // Confirmation Packet ??
- if( iMap->save_settings&32 )
- chrif_save(sd,0);
- }
- else
- {
+ if( map->save_settings&32 )
+ chrif->save(sd,0);
+ } else {
int zeny = auction.hours*battle_config.auction_feeperhour;
clif->auction_message(sd->fd, 4);
@@ -1829,7 +1865,7 @@ static void intif_parse_Auction_register(int fd)
int intif_Auction_cancel(int char_id, unsigned int auction_id)
{
- if( CheckForCharServer() )
+ if( intif->CheckForCharServer() )
return 0;
WFIFOHEAD(inter_fd,10);
@@ -1841,26 +1877,24 @@ int intif_Auction_cancel(int char_id, unsigned int auction_id)
return 0;
}
-static void intif_parse_Auction_cancel(int fd)
-{
- struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2));
+void intif_parse_AuctionCancel(int fd) {
+ struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2));
int result = RFIFOB(fd,6);
if( sd == NULL )
return;
- switch( result )
- {
- case 0: clif->auction_message(sd->fd, 2); break;
- case 1: clif->auction_close(sd->fd, 2); break;
- case 2: clif->auction_close(sd->fd, 1); break;
- case 3: clif->auction_message(sd->fd, 3); break;
+ switch( result ) {
+ case 0: clif->auction_message(sd->fd, 2); break;
+ case 1: clif->auction_close(sd->fd, 2); break;
+ case 2: clif->auction_close(sd->fd, 1); break;
+ case 3: clif->auction_message(sd->fd, 3); break;
}
}
int intif_Auction_close(int char_id, unsigned int auction_id)
{
- if( CheckForCharServer() )
+ if( intif->CheckForCharServer() )
return 0;
WFIFOHEAD(inter_fd,10);
@@ -1872,20 +1906,18 @@ int intif_Auction_close(int char_id, unsigned int auction_id)
return 0;
}
-static void intif_parse_Auction_close(int fd)
-{
- struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2));
+void intif_parse_AuctionClose(int fd) {
+ struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2));
unsigned char result = RFIFOB(fd,6);
if( sd == NULL )
return;
clif->auction_close(sd->fd, result);
- if( result == 0 )
- {
+ if( result == 0 ) {
// FIXME: Leeching off a parse function
clif->pAuction_cancelreg(fd, sd);
- intif_Auction_requestlist(sd->status.char_id, 6, 0, "", 1);
+ intif->Auction_requestlist(sd->status.char_id, 6, 0, "", 1);
}
}
@@ -1893,7 +1925,7 @@ int intif_Auction_bid(int char_id, const char* name, unsigned int auction_id, in
{
int len = 16 + NAME_LENGTH;
- if( CheckForCharServer() )
+ if( intif->CheckForCharServer() )
return 0;
WFIFOHEAD(inter_fd,len);
@@ -1908,9 +1940,8 @@ int intif_Auction_bid(int char_id, const char* name, unsigned int auction_id, in
return 0;
}
-static void intif_parse_Auction_bid(int fd)
-{
- struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2));
+void intif_parse_AuctionBid(int fd) {
+ struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2));
int bid = RFIFOL(fd,6);
unsigned char result = RFIFOB(fd,10);
@@ -1923,14 +1954,13 @@ static void intif_parse_Auction_bid(int fd)
}
if( result == 1 ) { // To update the list, display your buy list
clif->pAuction_cancelreg(fd, sd);
- intif_Auction_requestlist(sd->status.char_id, 7, 0, "", 1);
+ intif->Auction_requestlist(sd->status.char_id, 7, 0, "", 1);
}
}
// Used to send 'You have won the auction' and 'You failed to won the auction' messages
-static void intif_parse_Auction_message(int fd)
-{
- struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2));
+void intif_parse_AuctionMessage(int fd) {
+ struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2));
unsigned char result = RFIFOB(fd,6);
if( sd == NULL )
@@ -1946,7 +1976,7 @@ int intif_mercenary_create(struct s_mercenary *merc)
{
int size = sizeof(struct s_mercenary) + 4;
- if( CheckForCharServer() )
+ if( intif->CheckForCharServer() )
return 0;
WFIFOHEAD(inter_fd,size);
@@ -1957,23 +1987,21 @@ int intif_mercenary_create(struct s_mercenary *merc)
return 0;
}
-int intif_parse_mercenary_received(int fd)
-{
+void intif_parse_MercenaryReceived(int fd) {
int len = RFIFOW(fd,2) - 5;
- if( sizeof(struct s_mercenary) != len )
- {
- if( battle_config.etc_log )
- ShowError("intif: create mercenary data size error %d != %d\n", sizeof(struct s_mercenary), len);
- return 0;
+
+ if (sizeof(struct s_mercenary) != len) {
+ if (battle_config.etc_log)
+ ShowError("intif: create mercenary data size mismatch %d != %"PRIuS"\n", len, sizeof(struct s_mercenary));
+ return;
}
- merc_data_received((struct s_mercenary*)RFIFOP(fd,5), RFIFOB(fd,4));
- return 0;
+ mercenary->data_received((struct s_mercenary*)RFIFOP(fd,5), RFIFOB(fd,4));
}
int intif_mercenary_request(int merc_id, int char_id)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd,10);
@@ -1986,7 +2014,7 @@ int intif_mercenary_request(int merc_id, int char_id)
int intif_mercenary_delete(int merc_id)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd,6);
@@ -1995,20 +2023,17 @@ int intif_mercenary_delete(int merc_id)
WFIFOSET(inter_fd,6);
return 0;
}
-
-int intif_parse_mercenary_deleted(int fd)
-{
+/* Really? Whats the point, shouldn't be sent when successful then [Ind] */
+void intif_parse_MercenaryDeleted(int fd) {
if( RFIFOB(fd,2) != 1 )
ShowError("Mercenary data delete failure\n");
-
- return 0;
}
int intif_mercenary_save(struct s_mercenary *merc)
{
int size = sizeof(struct s_mercenary) + 4;
- if( CheckForCharServer() )
+ if( intif->CheckForCharServer() )
return 0;
WFIFOHEAD(inter_fd,size);
@@ -2018,13 +2043,10 @@ int intif_mercenary_save(struct s_mercenary *merc)
WFIFOSET(inter_fd,size);
return 0;
}
-
-int intif_parse_mercenary_saved(int fd)
-{
+/* Really? Whats the point, shouldn't be sent when successful then [Ind] */
+void intif_parse_MercenarySaved(int fd) {
if( RFIFOB(fd,2) != 1 )
ShowError("Mercenary data save failure\n");
-
- return 0;
}
/*==========================================
@@ -2034,7 +2056,7 @@ int intif_elemental_create(struct s_elemental *ele)
{
int size = sizeof(struct s_elemental) + 4;
- if( CheckForCharServer() )
+ if( intif->CheckForCharServer() )
return 0;
WFIFOHEAD(inter_fd,size);
@@ -2045,23 +2067,21 @@ int intif_elemental_create(struct s_elemental *ele)
return 0;
}
-int intif_parse_elemental_received(int fd)
-{
+void intif_parse_ElementalReceived(int fd) {
int len = RFIFOW(fd,2) - 5;
- if( sizeof(struct s_elemental) != len )
- {
- if( battle_config.etc_log )
- ShowError("intif: create elemental data size error %d != %d\n", sizeof(struct s_elemental), len);
- return 0;
+
+ if (sizeof(struct s_elemental) != len) {
+ if (battle_config.etc_log)
+ ShowError("intif: create elemental data size mismatch %d != %"PRIuS"\n", len, sizeof(struct s_elemental));
+ return;
}
- elemental_data_received((struct s_elemental*)RFIFOP(fd,5), RFIFOB(fd,4));
- return 0;
+ elemental->data_received((struct s_elemental*)RFIFOP(fd,5), RFIFOB(fd,4));
}
int intif_elemental_request(int ele_id, int char_id)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd,10);
@@ -2074,7 +2094,7 @@ int intif_elemental_request(int ele_id, int char_id)
int intif_elemental_delete(int ele_id)
{
- if (CheckForCharServer())
+ if (intif->CheckForCharServer())
return 0;
WFIFOHEAD(inter_fd,6);
@@ -2083,20 +2103,17 @@ int intif_elemental_delete(int ele_id)
WFIFOSET(inter_fd,6);
return 0;
}
-
-int intif_parse_elemental_deleted(int fd)
-{
+/* Really? Whats the point, shouldn't be sent when successful then [Ind] */
+void intif_parse_ElementalDeleted(int fd) {
if( RFIFOB(fd,2) != 1 )
ShowError("Elemental data delete failure\n");
-
- return 0;
}
int intif_elemental_save(struct s_elemental *ele)
{
int size = sizeof(struct s_elemental) + 4;
- if( CheckForCharServer() )
+ if( intif->CheckForCharServer() )
return 0;
WFIFOHEAD(inter_fd,size);
@@ -2106,13 +2123,10 @@ int intif_elemental_save(struct s_elemental *ele)
WFIFOSET(inter_fd,size);
return 0;
}
-
-int intif_parse_elemental_saved(int fd)
-{
+/* Really? Whats the point, shouldn't be sent when successful then [Ind] */
+void intif_parse_ElementalSaved(int fd) {
if( RFIFOB(fd,2) != 1 )
ShowError("Elemental data save failure\n");
-
- return 0;
}
void intif_request_accinfo( int u_fd, int aid, int group_lv, char* query ) {
@@ -2138,7 +2152,7 @@ void intif_parse_MessageToFD(int fd) {
int aid = RFIFOL(fd,8);
struct map_session_data * sd = session[u_fd]->session_data;
/* matching e.g. previous fd owner didn't dc during request or is still the same */
- if( sd->bl.id == aid ) {
+ if( sd && sd->bl.id == aid ) {
char msg[512];
safestrncpy(msg, (char*)RFIFOP(fd,12), RFIFOW(fd,2) - 12);
clif->message(u_fd,msg);
@@ -2148,7 +2162,34 @@ void intif_parse_MessageToFD(int fd) {
return;
}
+/*==========================================
+ * Item Bound System [Xantara][Mhalicot]
+ *------------------------------------------*/
+void intif_itembound_req(int char_id,int aid,int guild_id) {
+#ifdef GP_BOUND_ITEMS
+ struct guild_storage *gstor = gstorage->id2storage2(guild_id);
+ WFIFOHEAD(inter_fd,12);
+ WFIFOW(inter_fd,0) = 0x3056;
+ WFIFOL(inter_fd,2) = char_id;
+ WFIFOL(inter_fd,6) = aid;
+ WFIFOW(inter_fd,10) = guild_id;
+ WFIFOSET(inter_fd,12);
+ if(gstor)
+ gstor->lock = 1; //Lock for retrieval process
+#endif
+}
+
+//3856
+void intif_parse_Itembound_ack(int fd) {
+#ifdef GP_BOUND_ITEMS
+ struct guild_storage *gstor;
+ int guild_id = RFIFOW(fd,6);
+ gstor = gstorage->id2storage2(guild_id);
+ if(gstor)
+ gstor->lock = 0; //Unlock now that operation is completed
+#endif
+}
//-----------------------------------------------------------------
// Communication from the inter server
// Return a 0 (false) if there were any errors.
@@ -2158,12 +2199,12 @@ int intif_parse(int fd)
int packet_len, cmd;
cmd = RFIFOW(fd,0);
// Verify ID of the packet
- if(cmd<0x3800 || cmd>=0x3800+(sizeof(packet_len_table)/sizeof(packet_len_table[0])) ||
- packet_len_table[cmd-0x3800]==0){
+ if(cmd<0x3800 || cmd>=0x3800+(sizeof(intif->packet_len_table)/sizeof(intif->packet_len_table[0])) ||
+ intif->packet_len_table[cmd-0x3800]==0){
return 0;
}
// Check the length of the packet
- packet_len = packet_len_table[cmd-0x3800];
+ packet_len = intif->packet_len_table[cmd-0x3800];
if(packet_len==-1){
if(RFIFOREST(fd)<4)
return 2;
@@ -2174,81 +2215,88 @@ int intif_parse(int fd)
}
// Processing branch
switch(cmd){
- case 0x3800:
- if (RFIFOL(fd,4) == 0xFF000000) //Normal announce.
- clif->broadcast(NULL, (char *) RFIFOP(fd,16), packet_len-16, 0, ALL_CLIENT);
- else //Color announce.
- clif->broadcast2(NULL, (char *) RFIFOP(fd,16), packet_len-16, RFIFOL(fd,4), RFIFOW(fd,8), RFIFOW(fd,10), RFIFOW(fd,12), RFIFOW(fd,14), ALL_CLIENT);
- break;
- case 0x3801: intif_parse_WisMessage(fd); break;
- case 0x3802: intif_parse_WisEnd(fd); break;
- case 0x3803: mapif_parse_WisToGM(fd); break;
- case 0x3804: intif_parse_Registers(fd); break;
- case 0x3806: intif_parse_ChangeNameOk(fd); break;
- case 0x3807: intif_parse_MessageToFD(fd); break;
- case 0x3818: intif_parse_LoadGuildStorage(fd); break;
- case 0x3819: intif_parse_SaveGuildStorage(fd); break;
- case 0x3820: intif_parse_PartyCreated(fd); break;
- case 0x3821: intif_parse_PartyInfo(fd); break;
- case 0x3822: intif_parse_PartyMemberAdded(fd); break;
- case 0x3823: intif_parse_PartyOptionChanged(fd); break;
- case 0x3824: intif_parse_PartyMemberWithdraw(fd); break;
- case 0x3825: intif_parse_PartyMove(fd); break;
- case 0x3826: intif_parse_PartyBroken(fd); break;
- case 0x3827: intif_parse_PartyMessage(fd); break;
- case 0x3830: intif_parse_GuildCreated(fd); break;
- case 0x3831: intif_parse_GuildInfo(fd); break;
- case 0x3832: intif_parse_GuildMemberAdded(fd); break;
- case 0x3834: intif_parse_GuildMemberWithdraw(fd); break;
- case 0x3835: intif_parse_GuildMemberInfoShort(fd); break;
- case 0x3836: intif_parse_GuildBroken(fd); break;
- case 0x3837: intif_parse_GuildMessage(fd); break;
- case 0x3839: intif_parse_GuildBasicInfoChanged(fd); break;
- case 0x383a: intif_parse_GuildMemberInfoChanged(fd); break;
- case 0x383b: intif_parse_GuildPosition(fd); break;
- case 0x383c: intif_parse_GuildSkillUp(fd); break;
- case 0x383d: intif_parse_GuildAlliance(fd); break;
- case 0x383e: intif_parse_GuildNotice(fd); break;
- case 0x383f: intif_parse_GuildEmblem(fd); break;
- case 0x3840: intif_parse_GuildCastleDataLoad(fd); break;
- case 0x3843: intif_parse_GuildMasterChanged(fd); break;
-
- //Quest system
- case 0x3860: intif_parse_questlog(fd); break;
- case 0x3861: intif_parse_questsave(fd); break;
-
-// Mail System
- case 0x3848: intif_parse_Mail_inboxreceived(fd); break;
- case 0x3849: intif_parse_Mail_new(fd); break;
- case 0x384a: intif_parse_Mail_getattach(fd); break;
- case 0x384b: intif_parse_Mail_delete(fd); break;
- case 0x384c: intif_parse_Mail_return(fd); break;
- case 0x384d: intif_parse_Mail_send(fd); break;
-// Auction System
- case 0x3850: intif_parse_Auction_results(fd); break;
- case 0x3851: intif_parse_Auction_register(fd); break;
- case 0x3852: intif_parse_Auction_cancel(fd); break;
- case 0x3853: intif_parse_Auction_close(fd); break;
- case 0x3854: intif_parse_Auction_message(fd); break;
- case 0x3855: intif_parse_Auction_bid(fd); break;
-
-// Mercenary System
- case 0x3870: intif_parse_mercenary_received(fd); break;
- case 0x3871: intif_parse_mercenary_deleted(fd); break;
- case 0x3872: intif_parse_mercenary_saved(fd); break;
-// Elemental System
- case 0x387c: intif_parse_elemental_received(fd); break;
- case 0x387d: intif_parse_elemental_deleted(fd); break;
- case 0x387e: intif_parse_elemental_saved(fd); break;
-
- case 0x3880: intif_parse_CreatePet(fd); break;
- case 0x3881: intif_parse_RecvPetData(fd); break;
- case 0x3882: intif_parse_SavePetOk(fd); break;
- case 0x3883: intif_parse_DeletePetOk(fd); break;
- case 0x3890: intif_parse_CreateHomunculus(fd); break;
- case 0x3891: intif_parse_RecvHomunculusData(fd); break;
- case 0x3892: intif_parse_SaveHomunculusOk(fd); break;
- case 0x3893: intif_parse_DeleteHomunculusOk(fd); break;
+ case 0x3800:
+ if (RFIFOL(fd,4) == 0xFF000000) //Normal announce.
+ clif->broadcast(NULL, (char *) RFIFOP(fd,16), packet_len-16, BC_DEFAULT, ALL_CLIENT);
+ else //Color announce.
+ clif->broadcast2(NULL, (char *) RFIFOP(fd,16), packet_len-16, RFIFOL(fd,4), RFIFOW(fd,8), RFIFOW(fd,10), RFIFOW(fd,12), RFIFOW(fd,14), ALL_CLIENT);
+ break;
+ case 0x3801: intif->pWisMessage(fd); break;
+ case 0x3802: intif->pWisEnd(fd); break;
+ case 0x3803: intif->pWisToGM(fd); break;
+ case 0x3804: intif->pRegisters(fd); break;
+ case 0x3806: intif->pChangeNameOk(fd); break;
+ case 0x3807: intif->pMessageToFD(fd); break;
+ case 0x3818: intif->pLoadGuildStorage(fd); break;
+ case 0x3819: intif->pSaveGuildStorage(fd); break;
+ case 0x3820: intif->pPartyCreated(fd); break;
+ case 0x3821: intif->pPartyInfo(fd); break;
+ case 0x3822: intif->pPartyMemberAdded(fd); break;
+ case 0x3823: intif->pPartyOptionChanged(fd); break;
+ case 0x3824: intif->pPartyMemberWithdraw(fd); break;
+ case 0x3825: intif->pPartyMove(fd); break;
+ case 0x3826: intif->pPartyBroken(fd); break;
+ case 0x3827: intif->pPartyMessage(fd); break;
+ case 0x3830: intif->pGuildCreated(fd); break;
+ case 0x3831: intif->pGuildInfo(fd); break;
+ case 0x3832: intif->pGuildMemberAdded(fd); break;
+ case 0x3834: intif->pGuildMemberWithdraw(fd); break;
+ case 0x3835: intif->pGuildMemberInfoShort(fd); break;
+ case 0x3836: intif->pGuildBroken(fd); break;
+ case 0x3837: intif->pGuildMessage(fd); break;
+ case 0x3839: intif->pGuildBasicInfoChanged(fd); break;
+ case 0x383a: intif->pGuildMemberInfoChanged(fd); break;
+ case 0x383b: intif->pGuildPosition(fd); break;
+ case 0x383c: intif->pGuildSkillUp(fd); break;
+ case 0x383d: intif->pGuildAlliance(fd); break;
+ case 0x383e: intif->pGuildNotice(fd); break;
+ case 0x383f: intif->pGuildEmblem(fd); break;
+ case 0x3840: intif->pGuildCastleDataLoad(fd); break;
+ case 0x3843: intif->pGuildMasterChanged(fd); break;
+
+ //Quest system
+ case 0x3860: intif->pQuestLog(fd); break;
+ case 0x3861: intif->pQuestSave(fd); break;
+
+ // Mail System
+ case 0x3848: intif->pMailInboxReceived(fd); break;
+ case 0x3849: intif->pMailNew(fd); break;
+ case 0x384a: intif->pMailGetAttach(fd); break;
+ case 0x384b: intif->pMailDelete(fd); break;
+ case 0x384c: intif->pMailReturn(fd); break;
+ case 0x384d: intif->pMailSend(fd); break;
+ // Auction System
+ case 0x3850: intif->pAuctionResults(fd); break;
+ case 0x3851: intif->pAuctionRegister(fd); break;
+ case 0x3852: intif->pAuctionCancel(fd); break;
+ case 0x3853: intif->pAuctionClose(fd); break;
+ case 0x3854: intif->pAuctionMessage(fd); break;
+ case 0x3855: intif->pAuctionBid(fd); break;
+ //Bound items
+ case 0x3856:
+#ifdef GP_BOUND_ITEMS
+ intif->pItembound_ack(fd);
+#else
+ ShowWarning("intif_parse: Received 0x3856 with GP_BOUND_ITEMS disabled !!!\n");
+#endif
+ break;
+ // Mercenary System
+ case 0x3870: intif->pMercenaryReceived(fd); break;
+ case 0x3871: intif->pMercenaryDeleted(fd); break;
+ case 0x3872: intif->pMercenarySaved(fd); break;
+ // Elemental System
+ case 0x387c: intif->pElementalReceived(fd); break;
+ case 0x387d: intif->pElementalDeleted(fd); break;
+ case 0x387e: intif->pElementalSaved(fd); break;
+
+ case 0x3880: intif->pCreatePet(fd); break;
+ case 0x3881: intif->pRecvPetData(fd); break;
+ case 0x3882: intif->pSavePetOk(fd); break;
+ case 0x3883: intif->pDeletePetOk(fd); break;
+ case 0x3890: intif->pCreateHomunculus(fd); break;
+ case 0x3891: intif->pRecvHomunculusData(fd); break;
+ case 0x3892: intif->pSaveHomunculusOk(fd); break;
+ case 0x3893: intif->pDeleteHomunculusOk(fd); break;
default:
ShowError("intif_parse : unknown packet %d %x\n",fd,RFIFOW(fd,0));
return 0;
@@ -2257,3 +2305,170 @@ int intif_parse(int fd)
RFIFOSKIP(fd,packet_len);
return 1;
}
+
+/*=====================================
+* Default Functions : intif.h
+* Generated by HerculesInterfaceMaker
+* created by Susu
+*-------------------------------------*/
+void intif_defaults(void) {
+ const int packet_len_table [INTIF_PACKET_LEN_TABLE_SIZE] = {
+ -1,-1,27,-1, -1, 0,37,-1, 0, 0, 0, 0, 0, 0, 0, 0, //0x3800-0x380f
+ 0, 0, 0, 0, 0, 0, 0, 0, -1,11, 0, 0, 0, 0, 0, 0, //0x3810
+ 39,-1,15,15, 14,19, 7,-1, 0, 0, 0, 0, 0, 0, 0, 0, //0x3820
+ 10,-1,15, 0, 79,19, 7,-1, 0,-1,-1,-1, 14,67,186,-1, //0x3830
+ -1, 0, 0,14, 0, 0, 0, 0, -1,74,-1,11, 11,-1, 0, 0, //0x3840
+ -1,-1, 7, 7, 7,11, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3850 Auctions [Zephyrus] itembound[Akinari]
+ -1, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3860 Quests [Kevin] [Inkfish]
+ -1, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 3, 3, 0, //0x3870 Mercenaries [Zephyrus] / Elemental [pakpil]
+ 12,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3880
+ -1,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3890 Homunculus [albator]
+ };
+
+ intif = &intif_s;
+
+ /* */
+ memcpy(intif->packet_len_table,&packet_len_table,sizeof(intif->packet_len_table));
+
+ /* funcs */
+ intif->parse = intif_parse;
+ intif->create_pet = intif_create_pet;
+ intif->broadcast = intif_broadcast;
+ intif->broadcast2 = intif_broadcast2;
+ intif->main_message = intif_main_message;
+ intif->wis_message = intif_wis_message;
+ intif->wis_message_to_gm = intif_wis_message_to_gm;
+ intif->saveregistry = intif_saveregistry;
+ intif->request_registry = intif_request_registry;
+ intif->request_guild_storage = intif_request_guild_storage;
+ intif->send_guild_storage = intif_send_guild_storage;
+ intif->create_party = intif_create_party;
+ intif->request_partyinfo = intif_request_partyinfo;
+ intif->party_addmember = intif_party_addmember;
+ intif->party_changeoption = intif_party_changeoption;
+ intif->party_leave = intif_party_leave;
+ intif->party_changemap = intif_party_changemap;
+ intif->break_party = intif_break_party;
+ intif->party_message = intif_party_message;
+ intif->party_leaderchange = intif_party_leaderchange;
+ intif->guild_create = intif_guild_create;
+ intif->guild_request_info = intif_guild_request_info;
+ intif->guild_addmember = intif_guild_addmember;
+ intif->guild_leave = intif_guild_leave;
+ intif->guild_memberinfoshort = intif_guild_memberinfoshort;
+ intif->guild_break = intif_guild_break;
+ intif->guild_message = intif_guild_message;
+ intif->guild_change_gm = intif_guild_change_gm;
+ intif->guild_change_basicinfo = intif_guild_change_basicinfo;
+ intif->guild_change_memberinfo = intif_guild_change_memberinfo;
+ intif->guild_position = intif_guild_position;
+ intif->guild_skillup = intif_guild_skillup;
+ intif->guild_alliance = intif_guild_alliance;
+ intif->guild_notice = intif_guild_notice;
+ intif->guild_emblem = intif_guild_emblem;
+ intif->guild_castle_dataload = intif_guild_castle_dataload;
+ intif->guild_castle_datasave = intif_guild_castle_datasave;
+ intif->request_petdata = intif_request_petdata;
+ intif->save_petdata = intif_save_petdata;
+ intif->delete_petdata = intif_delete_petdata;
+ intif->rename = intif_rename;
+ intif->homunculus_create = intif_homunculus_create;
+ intif->homunculus_requestload = intif_homunculus_requestload;
+ intif->homunculus_requestsave = intif_homunculus_requestsave;
+ intif->homunculus_requestdelete = intif_homunculus_requestdelete;
+ /******QUEST SYTEM*******/
+ intif->request_questlog = intif_request_questlog;
+ intif->quest_save = intif_quest_save;
+ // MERCENARY SYSTEM
+ intif->mercenary_create = intif_mercenary_create;
+ intif->mercenary_request = intif_mercenary_request;
+ intif->mercenary_delete = intif_mercenary_delete;
+ intif->mercenary_save = intif_mercenary_save;
+ // MAIL SYSTEM
+ intif->Mail_requestinbox = intif_Mail_requestinbox;
+ intif->Mail_read = intif_Mail_read;
+ intif->Mail_getattach = intif_Mail_getattach;
+ intif->Mail_delete = intif_Mail_delete;
+ intif->Mail_return = intif_Mail_return;
+ intif->Mail_send = intif_Mail_send;
+ // AUCTION SYSTEM
+ intif->Auction_requestlist = intif_Auction_requestlist;
+ intif->Auction_register = intif_Auction_register;
+ intif->Auction_cancel = intif_Auction_cancel;
+ intif->Auction_close = intif_Auction_close;
+ intif->Auction_bid = intif_Auction_bid;
+ // ELEMENTAL SYSTEM
+ intif->elemental_create = intif_elemental_create;
+ intif->elemental_request = intif_elemental_request;
+ intif->elemental_delete = intif_elemental_delete;
+ intif->elemental_save = intif_elemental_save;
+ /* @accinfo */
+ intif->request_accinfo = intif_request_accinfo;
+ /* */
+ intif->CheckForCharServer = CheckForCharServer;
+ /* */
+ intif->itembound_req = intif_itembound_req;
+ /* parse functions */
+ intif->pWisMessage = intif_parse_WisMessage;
+ intif->pWisEnd = intif_parse_WisEnd;
+ intif->pWisToGM_sub = mapif_parse_WisToGM_sub;
+ intif->pWisToGM = mapif_parse_WisToGM;
+ intif->pRegisters = intif_parse_Registers;
+ intif->pChangeNameOk = intif_parse_ChangeNameOk;
+ intif->pMessageToFD = intif_parse_MessageToFD;
+ intif->pLoadGuildStorage = intif_parse_LoadGuildStorage;
+ intif->pSaveGuildStorage = intif_parse_SaveGuildStorage;
+ intif->pPartyCreated = intif_parse_PartyCreated;
+ intif->pPartyInfo = intif_parse_PartyInfo;
+ intif->pPartyMemberAdded = intif_parse_PartyMemberAdded;
+ intif->pPartyOptionChanged = intif_parse_PartyOptionChanged;
+ intif->pPartyMemberWithdraw = intif_parse_PartyMemberWithdraw;
+ intif->pPartyMove = intif_parse_PartyMove;
+ intif->pPartyBroken = intif_parse_PartyBroken;
+ intif->pPartyMessage = intif_parse_PartyMessage;
+ intif->pGuildCreated = intif_parse_GuildCreated;
+ intif->pGuildInfo = intif_parse_GuildInfo;
+ intif->pGuildMemberAdded = intif_parse_GuildMemberAdded;
+ intif->pGuildMemberWithdraw = intif_parse_GuildMemberWithdraw;
+ intif->pGuildMemberInfoShort = intif_parse_GuildMemberInfoShort;
+ intif->pGuildBroken = intif_parse_GuildBroken;
+ intif->pGuildMessage = intif_parse_GuildMessage;
+ intif->pGuildBasicInfoChanged = intif_parse_GuildBasicInfoChanged;
+ intif->pGuildMemberInfoChanged = intif_parse_GuildMemberInfoChanged;
+ intif->pGuildPosition = intif_parse_GuildPosition;
+ intif->pGuildSkillUp = intif_parse_GuildSkillUp;
+ intif->pGuildAlliance = intif_parse_GuildAlliance;
+ intif->pGuildNotice = intif_parse_GuildNotice;
+ intif->pGuildEmblem = intif_parse_GuildEmblem;
+ intif->pGuildCastleDataLoad = intif_parse_GuildCastleDataLoad;
+ intif->pGuildMasterChanged = intif_parse_GuildMasterChanged;
+ intif->pQuestLog = intif_parse_QuestLog;
+ intif->pQuestSave = intif_parse_QuestSave;
+ intif->pMailInboxReceived = intif_parse_MailInboxReceived;
+ intif->pMailNew = intif_parse_MailNew;
+ intif->pMailGetAttach = intif_parse_MailGetAttach;
+ intif->pMailDelete = intif_parse_MailDelete;
+ intif->pMailReturn = intif_parse_MailReturn;
+ intif->pMailSend = intif_parse_MailSend;
+ intif->pAuctionResults = intif_parse_AuctionResults;
+ intif->pAuctionRegister = intif_parse_AuctionRegister;
+ intif->pAuctionCancel = intif_parse_AuctionCancel;
+ intif->pAuctionClose = intif_parse_AuctionClose;
+ intif->pAuctionMessage = intif_parse_AuctionMessage;
+ intif->pAuctionBid = intif_parse_AuctionBid;
+ intif->pItembound_ack = intif_parse_Itembound_ack;
+ intif->pMercenaryReceived = intif_parse_MercenaryReceived;
+ intif->pMercenaryDeleted = intif_parse_MercenaryDeleted;
+ intif->pMercenarySaved = intif_parse_MercenarySaved;
+ intif->pElementalReceived = intif_parse_ElementalReceived;
+ intif->pElementalDeleted = intif_parse_ElementalDeleted;
+ intif->pElementalSaved = intif_parse_ElementalSaved;
+ intif->pCreatePet = intif_parse_CreatePet;
+ intif->pRecvPetData = intif_parse_RecvPetData;
+ intif->pSavePetOk = intif_parse_SavePetOk;
+ intif->pDeletePetOk = intif_parse_DeletePetOk;
+ intif->pCreateHomunculus = intif_parse_CreateHomunculus;
+ intif->pRecvHomunculusData = intif_parse_RecvHomunculusData;
+ intif->pSaveHomunculusOk = intif_parse_SaveHomunculusOk;
+ intif->pDeleteHomunculusOk = intif_parse_DeleteHomunculusOk;
+}