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.c463
1 files changed, 315 insertions, 148 deletions
diff --git a/src/map/intif.c b/src/map/intif.c
index f31ab0f5a..6b39bd1a5 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -35,7 +35,7 @@
struct intif_interface intif_s;
-#define inter_fd chrif->fd // alias
+#define inter_fd (chrif->fd) // alias
//-----------------------------------------------------------------
// Send to inter server
@@ -125,7 +125,7 @@ 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|BC_COLOR_MASK) ? 4 : 0;
@@ -155,7 +155,7 @@ int intif_broadcast(const char* mes, int len, int type)
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);
@@ -192,7 +192,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 );
@@ -201,7 +201,7 @@ 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 (intif->CheckForCharServer())
@@ -247,7 +247,7 @@ 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;
+ size_t mes_len;
if (intif->CheckForCharServer())
return 0;
mes_len = strlen(mes) + 1; // + null
@@ -265,60 +265,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 (intif->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->var_db)
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->var_db);
+ 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;
}
@@ -327,10 +384,7 @@ 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 char server aint online it doesn't load, shouldn't we kill the session then? */
if (intif->CheckForCharServer())
return 0;
@@ -447,7 +501,7 @@ 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;
+ int16 m, map_index;
if (intif->CheckForCharServer())
return 0;
@@ -455,16 +509,16 @@ int intif_party_changemap(struct map_session_data *sd,int online) {
return 0;
if( (m=map->mapindex2mapid(sd->mapindex)) >= 0 && map->list[m].instance_id >= 0 )
- mapindex = map_id2index(map->list[m].instance_src_map);
+ 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);
@@ -560,7 +614,7 @@ 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 (intif->CheckForCharServer())
return 0;
@@ -893,7 +947,7 @@ int mapif_parse_WisToGM_sub(struct map_session_data* sd,va_list va) {
char *message;
int len;
- if (!pc->has_permission(sd, permission))
+ if (!pc_has_permission(sd, permission))
return 0;
wisp_name = va_arg(va, char*);
message = va_arg(va, char*);
@@ -927,54 +981,93 @@ void mapif_parse_WisToGM(int fd)
// Request player registre
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);
+ char type = RFIFOB(fd, 13);
+
if (node)
sd = node->sd;
else { //Normally registries should arrive for in log-in chars.
sd = map->id2sd(account_id);
- if (sd && RFIFOB(fd,12) == 3 && sd->status.char_id != char_id)
- sd = NULL; //Character registry from another character.
}
- if (!sd) return;
-
- 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;
}
- 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;
+
+ /**
+ * 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*)__64BPTRSIZE(ival), NULL);
+ }
+ }
}
- *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]
}
@@ -982,15 +1075,18 @@ 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;
sd=map->id2sd( RFIFOL(fd,4) );
- if(sd==NULL){
- ShowError("intif_parse_LoadGuildStorage: user not found %d\n",RFIFOL(fd,4));
- return;
+ 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=gstorage->id2storage(guild_id);
if(!gstor) {
@@ -998,21 +1094,22 @@ void intif_parse_LoadGuildStorage(int fd)
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);
+ 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);
+ 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;
+ if( RFIFOW(fd,2)-13 != sizeof(struct guild_storage) ){
+ ShowError("intif_parse_LoadGuildStorage: data size error %d %d\n",RFIFOW(fd,2)-13 , sizeof(struct guild_storage));
+ gstor->storage_status = 0;
return;
}
- memcpy(gstor,RFIFOP(fd,12),sizeof(struct guild_storage));
- gstorage->open(sd);
+ memcpy(gstor,RFIFOP(fd,13),sizeof(struct guild_storage));
+ if( flag )
+ gstorage->open(sd);
}
// ACK guild_storage saved
@@ -1307,50 +1404,80 @@ 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;
}
+/**
+ * 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);
- int i;
- TBL_PC * sd = map->charid2sd(char_id);
+ int char_id = RFIFOL(fd, 4), num_received = (RFIFOW(fd, 2)-8)/sizeof(struct quest);
+ TBL_PC *sd = map->charid2sd(char_id);
- //User not online anymore
- if(!sd)
+ if (!sd) // User not online anymore
return;
- sd->avail_quests = sd->num_quests = (RFIFOW(fd, 2)-8)/sizeof(struct quest);
-
- memset(&sd->quest_log, 0, sizeof(sd->quest_log));
+ sd->num_quests = sd->avail_quests = 0;
- for( i = 0; i < sd->num_quests; i++ )
- {
- memcpy(&sd->quest_log[i], RFIFOP(fd, i*sizeof(struct quest)+8), sizeof(struct quest));
-
- sd->quest_index[i] = quest->search_db(sd->quest_log[i].quest_id);
-
- 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);
}
+/**
+ * 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 = map->id2sd(cid);
@@ -1361,21 +1488,24 @@ void intif_parse_QuestSave(int fd) {
sd->save_quest = false;
}
-int intif_quest_save(TBL_PC *sd)
-{
- int len;
+/**
+ * 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;
if(intif->CheckForCharServer())
- return 0;
-
- len = sizeof(struct quest)*sd->num_quests + 8;
+ 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;
@@ -1429,7 +1559,7 @@ void intif_parse_MailInboxReceived(int fd) {
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));
}
}
/*------------------------------------------
@@ -1522,7 +1652,7 @@ void intif_parse_MailDelete(int fd) {
}
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);
@@ -1563,7 +1693,7 @@ void intif_parse_MailReturn(int fd) {
}
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);
@@ -1760,7 +1890,7 @@ void intif_parse_AuctionClose(int fd) {
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);
}
}
@@ -1797,7 +1927,7 @@ void intif_parse_AuctionBid(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);
}
}
@@ -1995,7 +2125,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);
@@ -2005,7 +2135,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.
@@ -2088,7 +2245,14 @@ int intif_parse(int fd)
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;
@@ -2127,7 +2291,7 @@ void intif_defaults(void) {
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,-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]
11,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3880
@@ -2216,6 +2380,8 @@ void intif_defaults(void) {
/* */
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;
@@ -2263,6 +2429,7 @@ void intif_defaults(void) {
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;