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.c1299
1 files changed, 820 insertions, 479 deletions
diff --git a/src/map/intif.c b/src/map/intif.c
index ec0251dad..a420b7204 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2015 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,6 +26,7 @@
#include "map/atcommand.h"
#include "map/battle.h"
#include "map/chrif.h"
+#include "map/clan.h"
#include "map/clif.h"
#include "map/elemental.h"
#include "map/guild.h"
@@ -38,7 +39,10 @@
#include "map/pc.h"
#include "map/pet.h"
#include "map/quest.h"
+#include "map/rodex.h"
#include "map/storage.h"
+#include "map/achievement.h"
+
#include "common/memmgr.h"
#include "common/nullpo.h"
#include "common/showmsg.h"
@@ -53,7 +57,7 @@
#include <string.h>
#include <sys/types.h>
-struct intif_interface intif_s;
+static struct intif_interface intif_s;
struct intif_interface *intif;
#define inter_fd (chrif->fd) // alias
@@ -61,37 +65,37 @@ struct intif_interface *intif;
//-----------------------------------------------------------------
// Send to inter server
-int CheckForCharServer(void)
+static int CheckForCharServer(void)
{
return ((chrif->fd <= 0) || sockt->session[chrif->fd] == NULL || sockt->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 incubate,char *pet_name)
+static int intif_create_pet(int account_id, int char_id, int pet_class, int pet_lv, int pet_egg_id,
+ int pet_equip, short intimate, short hungry, char rename_flag, char incubate, char *pet_name)
{
if (intif->CheckForCharServer())
return 0;
nullpo_ret(pet_name);
- WFIFOHEAD(inter_fd, 24 + NAME_LENGTH);
- WFIFOW(inter_fd,0) = 0x3080;
- WFIFOL(inter_fd,2) = account_id;
- WFIFOL(inter_fd,6) = char_id;
- WFIFOW(inter_fd,10) = pet_class;
- WFIFOW(inter_fd,12) = pet_lv;
- WFIFOW(inter_fd,14) = pet_egg_id;
- WFIFOW(inter_fd,16) = pet_equip;
- WFIFOW(inter_fd,18) = intimate;
- WFIFOW(inter_fd,20) = hungry;
- WFIFOB(inter_fd,22) = rename_flag;
- WFIFOB(inter_fd,23) = incubate;
- memcpy(WFIFOP(inter_fd,24),pet_name,NAME_LENGTH);
- WFIFOSET(inter_fd,24+NAME_LENGTH);
+ WFIFOHEAD(inter_fd, 32 + NAME_LENGTH);
+ WFIFOW(inter_fd, 0) = 0x3080;
+ WFIFOL(inter_fd, 2) = account_id;
+ WFIFOL(inter_fd, 6) = char_id;
+ WFIFOL(inter_fd, 10) = pet_class;
+ WFIFOL(inter_fd, 14) = pet_lv;
+ WFIFOL(inter_fd, 18) = pet_egg_id;
+ WFIFOL(inter_fd, 22) = pet_equip;
+ WFIFOW(inter_fd, 26) = intimate;
+ WFIFOW(inter_fd, 28) = hungry;
+ WFIFOB(inter_fd, 30) = rename_flag;
+ WFIFOB(inter_fd, 31) = incubate;
+ memcpy(WFIFOP(inter_fd, 32), pet_name, NAME_LENGTH);
+ WFIFOSET(inter_fd, 32 + NAME_LENGTH);
return 0;
}
-int intif_request_petdata(int account_id,int char_id,int pet_id)
+static int intif_request_petdata(int account_id, int char_id, int pet_id)
{
if (intif->CheckForCharServer())
return 0;
@@ -105,7 +109,7 @@ int intif_request_petdata(int account_id,int char_id,int pet_id)
return 0;
}
-int intif_save_petdata(int account_id,struct s_pet *p)
+static int intif_save_petdata(int account_id, struct s_pet *p)
{
if (intif->CheckForCharServer())
return 0;
@@ -120,7 +124,7 @@ int intif_save_petdata(int account_id,struct s_pet *p)
return 0;
}
-int intif_delete_petdata(int pet_id)
+static int intif_delete_petdata(int pet_id)
{
if (intif->CheckForCharServer())
return 0;
@@ -132,7 +136,7 @@ int intif_delete_petdata(int pet_id)
return 1;
}
-int intif_rename(struct map_session_data *sd, int type, const char *name)
+static int intif_rename(struct map_session_data *sd, int type, const char *name)
{
if (intif->CheckForCharServer())
return 1;
@@ -149,158 +153,8 @@ int intif_rename(struct map_session_data *sd, int type, const char *name)
return 0;
}
-// GM Send a message
-int intif_broadcast(const char* mes, size_t len, int type)
-{
- int lp = (type&BC_COLOR_MASK) ? 4 : 0;
-
- nullpo_ret(mes);
- Assert_ret(len < 32000);
- // Send to the local players
- clif->broadcast(NULL, mes, len, type, ALL_CLIENT);
-
- if (intif->CheckForCharServer())
- return 0;
-
- if (chrif->other_mapserver_count < 1)
- return 0; //No need to send.
-
- WFIFOHEAD(inter_fd, 16 + lp + len);
- WFIFOW(inter_fd,0) = 0x3000;
- WFIFOW(inter_fd,2) = 16 + lp + len;
- WFIFOL(inter_fd,4) = 0xFF000000; // 0xFF000000 color signals standard broadcast
- WFIFOW(inter_fd,8) = 0; // fontType not used with standard broadcast
- 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&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&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, size_t len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY)
-{
- nullpo_ret(mes);
- Assert_ret(len < 32000);
- // Send to the local players
- clif->broadcast2(NULL, mes, len, fontColor, fontType, fontSize, fontAlign, fontY, ALL_CLIENT);
-
- if (intif->CheckForCharServer())
- return 0;
-
- if (chrif->other_mapserver_count < 1)
- return 0; //No need to send.
-
- WFIFOHEAD(inter_fd, 16 + len);
- WFIFOW(inter_fd,0) = 0x3000;
- WFIFOW(inter_fd,2) = 16 + len;
- WFIFOL(inter_fd,4) = fontColor;
- WFIFOW(inter_fd,8) = fontType;
- WFIFOW(inter_fd,10) = fontSize;
- WFIFOW(inter_fd,12) = fontAlign;
- WFIFOW(inter_fd,14) = fontY;
- memcpy(WFIFOP(inter_fd,16), mes, len);
- WFIFOSET(inter_fd, WFIFOW(inter_fd,2));
- return 0;
-}
-
-/// send a message using the main chat system
-/// <sd> the source of message
-/// <message> the message that was sent
-int intif_main_message(struct map_session_data* sd, const char* message)
-{
- char output[256];
-
- nullpo_ret(sd);
- nullpo_ret(message);
-
- // format the message for main broadcasting
- 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 );
-
- // 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 );
-
- return 0;
-}
-
-// The transmission of Wisp/Page to inter-server (player not found on this server)
-int intif_wis_message(struct map_session_data *sd, const char *nick, const char *mes, size_t mes_len)
-{
- if (intif->CheckForCharServer())
- return 0;
- nullpo_ret(sd);
- nullpo_ret(nick);
- nullpo_ret(mes);
-
- if (chrif->other_mapserver_count < 1) {
- //Character not found.
- clif->wis_end(sd->fd, 1);
- return 0;
- }
-
- WFIFOHEAD(inter_fd,mes_len + 52);
- WFIFOW(inter_fd,0) = 0x3001;
- WFIFOW(inter_fd,2) = mes_len + 52;
- memcpy(WFIFOP(inter_fd,4), sd->status.name, NAME_LENGTH);
- memcpy(WFIFOP(inter_fd,4+NAME_LENGTH), nick, NAME_LENGTH);
- memcpy(WFIFOP(inter_fd,4+2*NAME_LENGTH), mes, mes_len);
- WFIFOSET(inter_fd, WFIFOW(inter_fd,2));
-
- if (battle_config.etc_log)
- ShowInfo("intif_wis_message from %s to %s (message: '%s')\n", sd->status.name, nick, mes);
-
- return 0;
-}
-
-// The reply of Wisp/page
-int intif_wis_replay(int id, int flag)
-{
- 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 whisper, 1: target character is not logged in?, 2: ignored by target
- WFIFOSET(inter_fd,7);
-
- if (battle_config.etc_log)
- ShowInfo("intif_wis_replay: id: %d, flag:%d\n", id, flag);
-
- return 0;
-}
-
-// 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)
-{
- size_t mes_len;
- if (intif->CheckForCharServer())
- return 0;
- nullpo_ret(wisp_name);
- nullpo_ret(mes);
- mes_len = strlen(mes) + 1; // + null
- WFIFOHEAD(inter_fd, mes_len + 32);
- WFIFOW(inter_fd,0) = 0x3003;
- WFIFOW(inter_fd,2) = mes_len + 32;
- memcpy(WFIFOP(inter_fd,4), wisp_name, NAME_LENGTH);
- WFIFOL(inter_fd,4+NAME_LENGTH) = permission;
- memcpy(WFIFOP(inter_fd,8+NAME_LENGTH), mes, mes_len);
- WFIFOSET(inter_fd, WFIFOW(inter_fd,2));
-
- if (battle_config.etc_log)
- ShowNotice("intif_wis_message_to_gm: from: '%s', required permission: %d, message: '%s'.\n", wisp_name, permission, mes);
-
- return 0;
-}
-
//Request for saving registry values.
-int intif_saveregistry(struct map_session_data *sd)
+static int intif_saveregistry(struct map_session_data *sd)
{
struct DBIterator *iter;
union DBKey key;
@@ -417,7 +271,7 @@ int intif_saveregistry(struct map_session_data *sd)
}
//Request the registries for this player.
-int intif_request_registry(struct map_session_data *sd, int flag)
+static int intif_request_registry(struct map_session_data *sd, int flag)
{
nullpo_ret(sd);
@@ -437,7 +291,137 @@ int intif_request_registry(struct map_session_data *sd, int flag)
return 0;
}
-int intif_request_guild_storage(int account_id,int guild_id)
+//=================================================================
+// Account Storage
+//-----------------------------------------------------------------
+
+/**
+ * Request the inter-server for a character's storage data.
+ * @packet 0x3010 [out] <account_id>.L
+ * @param sd [in] pointer to session data.
+ */
+static void intif_request_account_storage(const struct map_session_data *sd)
+{
+ nullpo_retv(sd);
+
+ /* Check for character server availability */
+ if (intif->CheckForCharServer())
+ return;
+
+ WFIFOHEAD(inter_fd, 6);
+ WFIFOW(inter_fd, 0) = 0x3010;
+ WFIFOL(inter_fd, 2) = sd->status.account_id;
+ WFIFOSET(inter_fd, 6);
+}
+
+/**
+ * Parse the reception of account storage from the inter-server.
+ * @packet 0x3805 [in] <packet_len>.W <account_id>.L <struct item[]>.P
+ * @param fd [in] file/socket descriptor.
+ */
+static void intif_parse_account_storage(int fd)
+{
+ int account_id = 0, payload_size = 0, storage_count = 0;
+ int i = 0;
+ struct map_session_data *sd = NULL;
+
+ Assert_retv(fd > 0);
+
+ payload_size = RFIFOW(fd, 2) - 8;
+
+ if ((account_id = RFIFOL(fd, 4)) == 0 || (sd = map->id2sd(account_id)) == NULL) {
+ ShowError("intif_parse_account_storage: Session pointer was null for account id %d!\n", account_id);
+ return;
+ }
+
+ if (sd->storage.received == true) {
+ ShowError("intif_parse_account_storage: Multiple calls from the inter-server received.\n");
+ return;
+ }
+
+ storage_count = (payload_size/sizeof(struct item));
+
+ VECTOR_ENSURE(sd->storage.item, storage_count, 1);
+
+ sd->storage.aggregate = storage_count; // Total items in storage.
+
+ for (i = 0; i < storage_count; i++) {
+ const struct item *it = RFIFOP(fd, 8 + i * sizeof(struct item));
+ VECTOR_PUSH(sd->storage.item, *it);
+ }
+
+ sd->storage.received = true; // Mark the storage state as received.
+ sd->storage.save = false; // Initialize the save flag as false.
+
+ pc->checkitem(sd); // re-check remaining items.
+}
+
+/**
+ * Send account storage information for saving.
+ * @packet 0x3011 [out] <packet_len>.W <account_id>.L <struct item[]>.P
+ * @param sd [in] pointer to session data.
+ */
+static void intif_send_account_storage(struct map_session_data *sd)
+{
+ int len = 0, i = 0, c = 0;
+
+ nullpo_retv(sd);
+
+ // Assert that at this point in the code, both flags are true.
+ Assert_retv(sd->storage.save == true);
+ Assert_retv(sd->storage.received == true);
+
+ if (intif->CheckForCharServer())
+ return;
+
+ len = 8 + sd->storage.aggregate * sizeof(struct item);
+
+ WFIFOHEAD(inter_fd, len);
+
+ WFIFOW(inter_fd, 0) = 0x3011;
+ WFIFOW(inter_fd, 2) = (uint16) len;
+ WFIFOL(inter_fd, 4) = sd->status.account_id;
+ for (i = 0, c = 0; i < VECTOR_LENGTH(sd->storage.item); i++) {
+ if (VECTOR_INDEX(sd->storage.item, i).nameid == 0)
+ continue;
+ memcpy(WFIFOP(inter_fd, 8 + c * sizeof(struct item)), &VECTOR_INDEX(sd->storage.item, i), sizeof(struct item));
+ c++;
+ }
+
+ WFIFOSET(inter_fd, len);
+
+ sd->storage.save = false; // Save request has been sent
+}
+
+/**
+ * Parse acknowledgement packet for the saving of an account's storage.
+ * @packet 0x3808 [in] <account_id>.L <saved_flag>.B
+ * @param fd [in] file/socket descriptor.
+ */
+static void intif_parse_account_storage_save_ack(int fd)
+{
+ int account_id = RFIFOL(fd, 2);
+ uint8 saved = RFIFOB(fd, 6);
+ struct map_session_data *sd = NULL;
+
+ Assert_retv(account_id > 0);
+ Assert_retv(fd > 0);
+
+ if ((sd = map->id2sd(account_id)) == NULL)
+ return; // character is most probably offline.
+
+ if (saved == 0) {
+ ShowError("intif_parse_account_storage_save_ack: Storage has not been saved! (AID: %d)\n", account_id);
+ sd->storage.save = true; // Flag it as unsaved, to re-attempt later
+ return;
+ }
+}
+
+//=================================================================
+// Guild Storage
+//-----------------------------------------------------------------
+
+static int intif_request_guild_storage(int account_id, int guild_id)
{
if (intif->CheckForCharServer())
return 0;
@@ -448,7 +432,7 @@ int intif_request_guild_storage(int account_id,int guild_id)
WFIFOSET(inter_fd,10);
return 0;
}
-int intif_send_guild_storage(int account_id,struct guild_storage *gstor)
+static int intif_send_guild_storage(int account_id, struct guild_storage *gstor)
{
if (intif->CheckForCharServer())
return 0;
@@ -464,7 +448,7 @@ int intif_send_guild_storage(int account_id,struct guild_storage *gstor)
}
// Party creation request
-int intif_create_party(struct party_member *member, const char *name, int item, int item2)
+static int intif_create_party(struct party_member *member, const char *name, int item, int item2)
{
if (intif->CheckForCharServer())
return 0;
@@ -483,7 +467,7 @@ int intif_create_party(struct party_member *member, const char *name, int item,
}
// Party information request
-int intif_request_partyinfo(int party_id, int char_id)
+static int intif_request_partyinfo(int party_id, int char_id)
{
if (intif->CheckForCharServer())
return 0;
@@ -496,7 +480,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)
+static int intif_party_addmember(int party_id, struct party_member *member)
{
if (intif->CheckForCharServer())
return 0;
@@ -511,7 +495,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)
+static int intif_party_changeoption(int party_id, int account_id, int exp, int item)
{
if (intif->CheckForCharServer())
return 0;
@@ -526,7 +510,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)
+static int intif_party_leave(int party_id, int account_id, int char_id)
{
if (intif->CheckForCharServer())
return 0;
@@ -540,7 +524,8 @@ 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) {
+static int intif_party_changemap(struct map_session_data *sd, int online)
+{
int16 m, map_index;
if (intif->CheckForCharServer())
@@ -566,7 +551,7 @@ int intif_party_changemap(struct map_session_data *sd,int online) {
}
// Request breaking party
-int intif_break_party(int party_id)
+static int intif_break_party(int party_id)
{
if (intif->CheckForCharServer())
return 0;
@@ -577,29 +562,8 @@ int intif_break_party(int party_id)
return 0;
}
-// Sending party chat
-int intif_party_message(int party_id,int account_id,const char *mes,int len)
-{
- if (intif->CheckForCharServer())
- return 0;
-
- if (chrif->other_mapserver_count < 1)
- return 0; //No need to send.
-
- nullpo_ret(mes);
- Assert_ret(len > 0 && len < 32000);
- WFIFOHEAD(inter_fd,len + 12);
- WFIFOW(inter_fd,0)=0x3027;
- WFIFOW(inter_fd,2)=len+12;
- WFIFOL(inter_fd,4)=party_id;
- WFIFOL(inter_fd,8)=account_id;
- memcpy(WFIFOP(inter_fd,12),mes,len);
- WFIFOSET(inter_fd,len+12);
- return 0;
-}
-
// Request a new leader for party
-int intif_party_leaderchange(int party_id,int account_id,int char_id)
+static int intif_party_leaderchange(int party_id, int account_id, int char_id)
{
if (intif->CheckForCharServer())
return 0;
@@ -612,8 +576,83 @@ int intif_party_leaderchange(int party_id,int account_id,int char_id)
return 0;
}
+//=========================
+// Clan System
+//-------------------------
+
+/**
+ * Request clan member count
+ *
+ * @param clan_id Id of the clan to have members counted
+ * @param kick_interval Interval of the inactivity kick
+ */
+static int intif_clan_membercount(int clan_id, int kick_interval)
+{
+ if (intif->CheckForCharServer() || clan_id == 0 || kick_interval <= 0)
+ return 0;
+
+ WFIFOHEAD(inter_fd, 10);
+ WFIFOW(inter_fd, 0) = 0x3044;
+ WFIFOL(inter_fd, 2) = clan_id;
+ WFIFOL(inter_fd, 6) = kick_interval;
+ WFIFOSET(inter_fd, 10);
+ return 1;
+}
+
+static int intif_clan_kickoffline(int clan_id, int kick_interval)
+{
+ if (intif->CheckForCharServer() || clan_id == 0 || kick_interval <= 0)
+ return 0;
+
+ WFIFOHEAD(inter_fd, 10);
+ WFIFOW(inter_fd, 0) = 0x3045;
+ WFIFOL(inter_fd, 2) = clan_id;
+ WFIFOL(inter_fd, 6) = kick_interval;
+ WFIFOSET(inter_fd, 10);
+ return 1;
+}
+
+static void intif_parse_RecvClanMemberAction(int fd)
+{
+ struct clan *c;
+ int clan_id = RFIFOL(fd, 2);
+ int count = RFIFOL(fd, 6);
+
+ if ((c = clan->search(clan_id)) == NULL) {
+ ShowError("intif_parse_RecvClanMemberAction: Received invalid clan_id '%d'\n", clan_id);
+ return;
+ }
+
+ if (count < 0) {
+ ShowError("intif_parse_RecvClanMemberAction: Received invalid member count value '%d'\n", count);
+ return;
+ }
+
+ c->received = true;
+ if (c->req_count_tid != INVALID_TIMER) {
+ timer->delete(c->req_count_tid, clan->request_membercount);
+ c->req_count_tid = INVALID_TIMER;
+ }
+
+ c->member_count = count;
+ switch (c->req_state) {
+ case CLAN_REQ_AFTER_KICK:
+ if (c->req_kick_tid != INVALID_TIMER) {
+ timer->delete(c->req_kick_tid, clan->request_kickoffline);
+ c->req_kick_tid = INVALID_TIMER;
+ }
+ break;
+ case CLAN_REQ_RELOAD:
+ map->foreachpc(clan->rejoin);
+ break;
+ default:
+ break;
+ }
+ c->req_state = CLAN_REQ_NONE;
+}
+
// Request a Guild creation
-int intif_guild_create(const char *name,const struct guild_member *master)
+static int intif_guild_create(const char *name, const struct guild_member *master)
{
if (intif->CheckForCharServer())
return 0;
@@ -631,7 +670,7 @@ int intif_guild_create(const char *name,const struct guild_member *master)
}
// Request Guild information
-int intif_guild_request_info(int guild_id)
+static int intif_guild_request_info(int guild_id)
{
if (intif->CheckForCharServer())
return 0;
@@ -643,7 +682,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)
+static int intif_guild_addmember(int guild_id, struct guild_member *m)
{
if (intif->CheckForCharServer())
return 0;
@@ -658,7 +697,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, size_t len)
+static int intif_guild_change_gm(int guild_id, const char *name, int len)
{
if (intif->CheckForCharServer())
return 0;
@@ -674,7 +713,7 @@ int intif_guild_change_gm(int guild_id, const char* name, size_t len)
}
// Request to leave guild
-int intif_guild_leave(int guild_id,int account_id,int char_id,int flag,const char *mes)
+static int intif_guild_leave(int guild_id, int account_id, int char_id, int flag, const char *mes)
{
if (intif->CheckForCharServer())
return 0;
@@ -691,24 +730,24 @@ 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_)
+static int intif_guild_memberinfoshort(int guild_id, int account_id, int char_id, int online, int lv, int class)
{
if (intif->CheckForCharServer())
return 0;
- WFIFOHEAD(inter_fd, 19);
+ WFIFOHEAD(inter_fd, 23);
WFIFOW(inter_fd, 0) = 0x3035;
WFIFOL(inter_fd, 2) = guild_id;
WFIFOL(inter_fd, 6) = account_id;
WFIFOL(inter_fd,10) = char_id;
WFIFOB(inter_fd,14) = online;
- WFIFOW(inter_fd,15) = lv;
- WFIFOW(inter_fd,17) = class_;
- WFIFOSET(inter_fd,19);
+ WFIFOL(inter_fd,15) = lv;
+ WFIFOL(inter_fd,19) = class;
+ WFIFOSET(inter_fd,23);
return 0;
}
//Guild disbanded notification
-int intif_guild_break(int guild_id)
+static int intif_guild_break(int guild_id)
{
if (intif->CheckForCharServer())
return 0;
@@ -719,33 +758,11 @@ int intif_guild_break(int guild_id)
return 0;
}
-// Send a guild message
-int intif_guild_message(int guild_id,int account_id,const char *mes,int len)
-{
- if (intif->CheckForCharServer())
- return 0;
-
- if (chrif->other_mapserver_count < 1)
- return 0; //No need to send.
-
- nullpo_ret(mes);
- Assert_ret(len > 0 && len < 32000);
- WFIFOHEAD(inter_fd, len + 12);
- WFIFOW(inter_fd,0)=0x3037;
- WFIFOW(inter_fd,2)=len+12;
- WFIFOL(inter_fd,4)=guild_id;
- WFIFOL(inter_fd,8)=account_id;
- memcpy(WFIFOP(inter_fd,12),mes,len);
- WFIFOSET(inter_fd,len+12);
-
- return 0;
-}
-
/**
* 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)
+static int intif_guild_change_basicinfo(int guild_id, int type, const void *data, int len)
{
if (intif->CheckForCharServer())
return 0;
@@ -762,8 +779,7 @@ int intif_guild_change_basicinfo(int guild_id,int type,const void *data,int len)
}
// Request a change of Guild member information
-int intif_guild_change_memberinfo(int guild_id,int account_id,int char_id,
- int type,const void *data,int len)
+static int intif_guild_change_memberinfo(int guild_id, int account_id, int char_id, int type, const void *data, int len)
{
if (intif->CheckForCharServer())
return 0;
@@ -782,7 +798,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)
+static int intif_guild_position(int guild_id, int idx, struct guild_position *p)
{
if (intif->CheckForCharServer())
return 0;
@@ -798,7 +814,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)
+static int intif_guild_skillup(int guild_id, uint16 skill_id, int account_id, int max)
{
if( intif->CheckForCharServer() )
return 0;
@@ -813,7 +829,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)
+static int intif_guild_alliance(int guild_id1, int guild_id2, int account_id1, int account_id2, int flag)
{
if (intif->CheckForCharServer())
return 0;
@@ -829,7 +845,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)
+static int intif_guild_notice(int guild_id, const char *mes1, const char *mes2)
{
if (intif->CheckForCharServer())
return 0;
@@ -845,7 +861,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)
+static int intif_guild_emblem(int guild_id, int len, const char *data)
{
if (intif->CheckForCharServer())
return 0;
@@ -868,7 +884,7 @@ int intif_guild_emblem(int guild_id,int len,const char *data)
* @param num Number of castles, size of castle_ids array.
* @param castle_ids Pointer to array of castle IDs.
*/
-int intif_guild_castle_dataload(int num, int *castle_ids)
+static int intif_guild_castle_dataload(int num, int *castle_ids)
{
if (intif->CheckForCharServer())
return 0;
@@ -882,7 +898,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)
+static int intif_guild_castle_datasave(int castle_id, int index, int value)
{
if (intif->CheckForCharServer())
return 0;
@@ -899,7 +915,7 @@ int intif_guild_castle_datasave(int castle_id,int index, int value)
// Homunculus Packets send to Inter server [albator]
//-----------------------------------------------------------------
-int intif_homunculus_create(int account_id, struct s_homunculus *sh)
+static int intif_homunculus_create(int account_id, struct s_homunculus *sh)
{
if (intif->CheckForCharServer())
return 0;
@@ -913,7 +929,8 @@ int intif_homunculus_create(int account_id, struct s_homunculus *sh)
return 0;
}
-bool intif_homunculus_requestload(int account_id, int homun_id) {
+static bool intif_homunculus_requestload(int account_id, int homun_id)
+{
if (intif->CheckForCharServer())
return false;
WFIFOHEAD(inter_fd, 10);
@@ -924,7 +941,7 @@ bool intif_homunculus_requestload(int account_id, int homun_id) {
return true;
}
-int intif_homunculus_requestsave(int account_id, struct s_homunculus* sh)
+static int intif_homunculus_requestsave(int account_id, struct s_homunculus *sh)
{
if (intif->CheckForCharServer())
return 0;
@@ -939,7 +956,7 @@ int intif_homunculus_requestsave(int account_id, struct s_homunculus* sh)
}
-int intif_homunculus_requestdelete(int homun_id)
+static int intif_homunculus_requestdelete(int homun_id)
{
if (intif->CheckForCharServer())
return 0;
@@ -954,98 +971,8 @@ int intif_homunculus_requestdelete(int homun_id)
//-----------------------------------------------------------------
// Packets receive from inter server
-// Wisp/Page reception // rewritten by [Yor]
-void intif_parse_WisMessage(int fd) {
- struct map_session_data* sd;
- const char *wisp_source;
- char name[NAME_LENGTH];
- int id, i;
-
- id=RFIFOL(fd,4);
-
- safestrncpy(name, RFIFOP(fd,32), NAME_LENGTH);
- sd = map->nick2sd(name);
- if(sd == NULL || strcmp(sd->status.name, name) != 0) {
- //Not found
- intif_wis_replay(id,1);
- return;
- }
- if(sd->state.ignoreAll) {
- intif_wis_replay(id, 2);
- return;
- }
- wisp_source = RFIFOP(fd,8); // speed up [Yor]
- for(i=0; i < MAX_IGNORE_LIST &&
- sd->ignore[i].name[0] != '\0' &&
- strcmp(sd->ignore[i].name, wisp_source) != 0
- ; i++);
-
- if (i < MAX_IGNORE_LIST && sd->ignore[i].name[0] != '\0') {
- //Ignored
- intif_wis_replay(id, 2);
- return;
- }
- //Success to send whisper.
- clif->wis_message(sd->fd, wisp_source, RFIFOP(fd,56),RFIFOW(fd,2)-56);
- intif_wis_replay(id,0); // success
-}
-
-// Wisp/page transmission result reception
-void intif_parse_WisEnd(int fd)
-{
- struct map_session_data* sd;
- const char *playername = RFIFOP(fd, 2);
-
- if (battle_config.etc_log)
- ShowInfo("intif_parse_wisend: player: %s, flag: %d\n", playername, RFIFOB(fd,26)); // flag: 0: success to send whisper, 1: target character is not logged in?, 2: ignored by target
- sd = map->nick2sd(playername);
- if (sd != NULL)
- clif->wis_end(sd->fd, RFIFOB(fd,26));
-
- return;
-}
-
-int mapif_parse_WisToGM_sub(struct map_session_data* sd,va_list va) {
- int permission = va_arg(va, int);
- char *wisp_name;
- char *message;
- int len;
-
- nullpo_ret(sd);
- if (!pc_has_permission(sd, permission))
- return 0;
- wisp_name = va_arg(va, char*);
- message = va_arg(va, char*);
- len = va_arg(va, int);
- clif->wis_message(sd->fd, wisp_name, message, len);
- return 1;
-}
-
-// Received wisp message from map-server via char-server for ALL gm
-// 0x3003/0x3803 <packet_len>.w <wispname>.24B <permission>.l <message>.?B
-void mapif_parse_WisToGM(int fd)
-{
- int permission, mes_len;
- char Wisp_name[NAME_LENGTH];
- char mbuf[255] = { 0 };
- char *message;
-
- mes_len = RFIFOW(fd,2) - 32;
- Assert_retv(mes_len > 0 && mes_len < 32000);
- message = (char *) (mes_len >= 255 ? (char *) aMalloc(mes_len) : mbuf);
-
- permission = RFIFOL(fd,28);
- safestrncpy(Wisp_name, RFIFOP(fd,4), NAME_LENGTH);
- safestrncpy(message, RFIFOP(fd,32), mes_len);
- // information is sent to all online GM
- map->foreachpc(mapif_parse_WisToGM_sub, permission, Wisp_name, message, mes_len);
-
- if (message != mbuf)
- aFree(message);
-}
-
// Request player registre
-void intif_parse_Registers(int fd)
+static void intif_parse_Registers(int fd)
{
int flag;
struct map_session_data *sd;
@@ -1111,7 +1038,7 @@ void intif_parse_Registers(int fd)
safestrncpy(sval, RFIFOP(fd, cursor + 1), min((int)sizeof(sval), len));
cursor += len + 1;
- script->set_reg(NULL,sd,reference_uid(script->add_str(key), index), key, sval, NULL);
+ script->set_reg(NULL,sd,reference_uid(script->add_variable(key), index), key, sval, NULL);
}
/**
* Vessel!
@@ -1133,7 +1060,7 @@ void intif_parse_Registers(int fd)
ival = RFIFOL(fd, cursor);
cursor += 4;
- script->set_reg(NULL,sd,reference_uid(script->add_str(key), index), key, (const void *)h64BPTRSIZE(ival), NULL);
+ script->set_reg(NULL,sd,reference_uid(script->add_variable(key), index), key, (const void *)h64BPTRSIZE(ival), NULL);
}
}
script->parser_current_file = NULL;/* reset */
@@ -1146,7 +1073,7 @@ void intif_parse_Registers(int fd)
pc->reg_received(sd); //Received all registry values, execute init scripts and what-not. [Skotlex]
}
-void intif_parse_LoadGuildStorage(int fd)
+static void intif_parse_LoadGuildStorage(int fd)
{
struct guild_storage *gstor;
struct map_session_data *sd;
@@ -1188,13 +1115,13 @@ void intif_parse_LoadGuildStorage(int fd)
}
// ACK guild_storage saved
-void intif_parse_SaveGuildStorage(int fd)
+static void intif_parse_SaveGuildStorage(int fd)
{
gstorage->saved(/*RFIFOL(fd,2), */RFIFOL(fd,6));
}
// ACK party creation
-void intif_parse_PartyCreated(int fd)
+static void intif_parse_PartyCreated(int fd)
{
if(battle_config.etc_log)
ShowInfo("intif: party created by account %u\n\n", RFIFOL(fd,2));
@@ -1202,7 +1129,8 @@ void intif_parse_PartyCreated(int fd)
}
// Receive party info
-void intif_parse_PartyInfo(int fd) {
+static void intif_parse_PartyInfo(int fd)
+{
if (RFIFOW(fd,2) == 12) {
ShowWarning("intif: party noinfo (char_id=%u party_id=%u)\n", RFIFOL(fd,4), RFIFOL(fd,8));
party->recv_noinfo(RFIFOL(fd,8), RFIFOL(fd,4));
@@ -1216,7 +1144,7 @@ void intif_parse_PartyInfo(int fd) {
}
// ACK adding party member
-void intif_parse_PartyMemberAdded(int fd)
+static void intif_parse_PartyMemberAdded(int fd)
{
if(battle_config.etc_log)
ShowInfo("intif: party member added Party (%u), Account(%u), Char(%u)\n", RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10));
@@ -1224,13 +1152,13 @@ void intif_parse_PartyMemberAdded(int fd)
}
// ACK changing party option
-void intif_parse_PartyOptionChanged(int fd)
+static void intif_parse_PartyOptionChanged(int fd)
{
party->optionchanged(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOW(fd,10),RFIFOW(fd,12),RFIFOB(fd,14));
}
// ACK member leaving party
-void intif_parse_PartyMemberWithdraw(int fd)
+static void intif_parse_PartyMemberWithdraw(int fd)
{
if(battle_config.etc_log)
ShowInfo("intif: party member withdraw: Party(%u), Account(%u), Char(%u)\n", RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10));
@@ -1238,28 +1166,26 @@ void intif_parse_PartyMemberWithdraw(int fd)
}
// ACK party break
-void intif_parse_PartyBroken(int fd) {
+static void intif_parse_PartyBroken(int fd)
+{
party->broken(RFIFOL(fd,2));
}
// ACK party on new map
-void intif_parse_PartyMove(int fd)
+static 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));
}
-// ACK party messages
-void intif_parse_PartyMessage(int fd) {
- party->recv_message(RFIFOL(fd,4), RFIFOL(fd,8), RFIFOP(fd,12), RFIFOW(fd,2)-12);
-}
-
// ACK guild creation
-void intif_parse_GuildCreated(int fd) {
+static void intif_parse_GuildCreated(int fd)
+{
guild->created(RFIFOL(fd,2),RFIFOL(fd,6));
}
// ACK guild infos
-void intif_parse_GuildInfo(int fd) {
+static void intif_parse_GuildInfo(int fd)
+{
if (RFIFOW(fd,2) == 8) {
ShowWarning("intif: guild noinfo %u\n", RFIFOL(fd,4));
guild->recv_noinfo(RFIFOL(fd,4));
@@ -1272,30 +1198,35 @@ void intif_parse_GuildInfo(int fd) {
}
// ACK adding guild member
-void intif_parse_GuildMemberAdded(int fd) {
+static void intif_parse_GuildMemberAdded(int fd)
+{
if(battle_config.etc_log)
ShowInfo("intif: guild member added %u %u %u %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));
}
// ACK member leaving guild
-void intif_parse_GuildMemberWithdraw(int fd) {
+static void intif_parse_GuildMemberWithdraw(int fd)
+{
guild->member_withdraw(RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOB(fd,14), RFIFOP(fd,55), RFIFOP(fd,15));
}
// ACK guild member basic info
-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));
+static void intif_parse_GuildMemberInfoShort(int fd)
+{
+ guild->recv_memberinfoshort(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),RFIFOW(fd,15),RFIFOL(fd,17),RFIFOL(fd,21));
}
// ACK guild break
-void intif_parse_GuildBroken(int fd) {
+static void intif_parse_GuildBroken(int fd)
+{
guild->broken(RFIFOL(fd,2),RFIFOB(fd,6));
}
// basic guild info change notice
// 0x3839 <packet len>.w <guild id>.l <type>.w <data>.?b
-void intif_parse_GuildBasicInfoChanged(int fd) {
+static void intif_parse_GuildBasicInfoChanged(int fd)
+{
//int len = RFIFOW(fd,2) - 10;
int guild_id = RFIFOL(fd,4);
int type = RFIFOW(fd,8);
@@ -1331,7 +1262,8 @@ void intif_parse_GuildBasicInfoChanged(int fd) {
// guild member info change notice
// 0x383a <packet len>.w <guild id>.l <account id>.l <char id>.l <type>.w <data>.?b
-void intif_parse_GuildMemberInfoChanged(int fd) {
+static void intif_parse_GuildMemberInfoChanged(int fd)
+{
//int len = RFIFOW(fd,2) - 18;
int guild_id = RFIFOL(fd,4);
int account_id = RFIFOL(fd,8);
@@ -1356,13 +1288,14 @@ void intif_parse_GuildMemberInfoChanged(int fd) {
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_CLASS: g->member[idx].class = RFIFOW(fd,18); break;
case GMI_LEVEL: g->member[idx].lv = RFIFOW(fd,18); break;
}
}
// ACK change of guild title
-void intif_parse_GuildPosition(int fd) {
+static void intif_parse_GuildPosition(int fd)
+{
if (RFIFOW(fd,2)!=sizeof(struct guild_position)+12)
ShowError("intif: guild info: data size mismatch (%u) %d != %"PRIuS"\n",
RFIFOL(fd,4), RFIFOW(fd,2), sizeof(struct guild_position) + 12);
@@ -1370,47 +1303,50 @@ void intif_parse_GuildPosition(int fd) {
}
// ACK change of guild skill update
-void intif_parse_GuildSkillUp(int fd) {
+static void intif_parse_GuildSkillUp(int fd)
+{
guild->skillupack(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
}
// ACK change of guild relationship
-void intif_parse_GuildAlliance(int fd) {
+static void intif_parse_GuildAlliance(int fd)
+{
guild->allianceack(RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14), RFIFOB(fd,18), RFIFOP(fd,19), RFIFOP(fd,43));
}
// ACK change of guild notice
-void intif_parse_GuildNotice(int fd) {
+static void intif_parse_GuildNotice(int fd)
+{
guild->notice_changed(RFIFOL(fd,2), RFIFOP(fd,6), RFIFOP(fd,66));
}
// ACK change of guild emblem
-void intif_parse_GuildEmblem(int fd) {
+static void intif_parse_GuildEmblem(int fd)
+{
guild->emblem_changed(RFIFOW(fd,2)-12, RFIFOL(fd,4), RFIFOL(fd,8), RFIFOP(fd,12));
}
-// ACK guild message
-void intif_parse_GuildMessage(int fd) {
- guild->recv_message(RFIFOL(fd,4), RFIFOL(fd,8), RFIFOP(fd,12), RFIFOW(fd,2)-12);
-}
-
// Reply guild castle data request
-void intif_parse_GuildCastleDataLoad(int fd) {
+static void intif_parse_GuildCastleDataLoad(int fd)
+{
guild->castledataloadack(RFIFOW(fd,2), RFIFOP(fd,4));
}
// ACK change of guildmaster
-void intif_parse_GuildMasterChanged(int fd) {
+static void intif_parse_GuildMasterChanged(int fd)
+{
guild->gm_changed(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
}
// Request pet creation
-void intif_parse_CreatePet(int fd) {
- pet->get_egg(RFIFOL(fd,2), RFIFOW(fd,6), RFIFOL(fd,8));
+static void intif_parse_CreatePet(int fd)
+{
+ pet->get_egg(RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOL(fd, 10));
}
// ACK pet data
-void intif_parse_RecvPetData(int fd) {
+static void intif_parse_RecvPetData(int fd)
+{
struct s_pet p;
int len;
len=RFIFOW(fd,2);
@@ -1424,19 +1360,21 @@ void intif_parse_RecvPetData(int fd) {
}
/* Really? Whats the point, shouldn't be sent when successful then [Ind] */
// ACK pet save data
-void intif_parse_SavePetOk(int fd) {
+static void intif_parse_SavePetOk(int fd)
+{
if(RFIFOB(fd,6) == 1)
ShowError("pet data save failure\n");
}
/* Really? Whats the point, shouldn't be sent when successful then [Ind] */
// ACK deleting pet
-void intif_parse_DeletePetOk(int fd) {
+static void intif_parse_DeletePetOk(int fd)
+{
if(RFIFOB(fd,2) == 1)
ShowError("pet data delete failure\n");
}
// ACK changing name request, players,pets,homun
-void intif_parse_ChangeNameOk(int fd)
+static void intif_parse_ChangeNameOk(int fd)
{
struct map_session_data *sd = NULL;
if((sd=map->id2sd(RFIFOL(fd,2)))==NULL ||
@@ -1459,7 +1397,8 @@ void intif_parse_ChangeNameOk(int fd)
//----------------------------------------------------------------
// Homunculus recv packets [albator]
-void intif_parse_CreateHomunculus(int fd) {
+static void intif_parse_CreateHomunculus(int fd)
+{
int len = RFIFOW(fd,2)-9;
if (sizeof(struct s_homunculus) != len) {
if (battle_config.etc_log)
@@ -1469,7 +1408,8 @@ void intif_parse_CreateHomunculus(int fd) {
homun->recv_data(RFIFOL(fd,4), RFIFOP(fd,9), RFIFOB(fd,8)) ;
}
-void intif_parse_RecvHomunculusData(int fd) {
+static void intif_parse_RecvHomunculusData(int fd)
+{
int len = RFIFOW(fd,2)-9;
if (sizeof(struct s_homunculus) != len) {
@@ -1481,29 +1421,122 @@ void intif_parse_RecvHomunculusData(int fd) {
}
/* Really? Whats the point, shouldn't be sent when successful then [Ind] */
-void intif_parse_SaveHomunculusOk(int fd) {
+static void intif_parse_SaveHomunculusOk(int fd)
+{
if(RFIFOB(fd,6) != 1)
ShowError("homunculus data save failure for account %u\n", RFIFOL(fd,2));
}
/* Really? Whats the point, shouldn't be sent when successful then [Ind] */
-void intif_parse_DeleteHomunculusOk(int fd) {
+static void intif_parse_DeleteHomunculusOk(int fd)
+{
if(RFIFOB(fd,2) != 1)
ShowError("Homunculus data delete failure\n");
}
-/**************************************
+/***************************************
+ * ACHIEVEMENT SYSTEM FUNCTIONS
+ ***************************************/
+/**
+ * Sends a request to the inter-server to load
+ * and send a character's achievement data.
+ * @packet [out] 0x3012 <char_id>.L
+ * @param sd pointer to map_session_data.
+ */
+static void intif_achievements_request(struct map_session_data *sd)
+{
+ nullpo_retv(sd);
-QUESTLOG SYSTEM FUNCTIONS
+ if (intif->CheckForCharServer())
+ return;
-***************************************/
+ WFIFOHEAD(inter_fd, 6);
+ WFIFOW(inter_fd, 0) = 0x3012;
+ WFIFOL(inter_fd, 2) = sd->status.char_id;
+ WFIFOSET(inter_fd, 6);
+}
+
+/**
+ * Handles reception of achievement data for a character from the inter-server.
+ * @packet [in] 0x3810 <packet_len>.W <char_id>.L <char_achievements[]>.P
+ * @param fd socket descriptor.
+ */
+static void intif_parse_achievements_load(int fd)
+{
+ int size = RFIFOW(fd, 2);
+ int char_id = RFIFOL(fd, 4);
+ int payload_count = (size - 8) / sizeof(struct achievement);
+ struct map_session_data *sd = map->charid2sd(char_id);
+ int i = 0;
+
+ if (sd == NULL) {
+ ShowError("intif_parse_achievements_load: Parse request for achievements received but character is offline!\n");
+ return;
+ }
+
+ if (VECTOR_LENGTH(sd->achievement) > 0) {
+ ShowError("intif_parse_achievements_load: Achievements already loaded! Possible multiple calls from the inter-server received.\n");
+ return;
+ }
+
+ VECTOR_ENSURE(sd->achievement, payload_count, 1);
+
+ for (i = 0; i < payload_count; i++) {
+ struct achievement t_ach = { 0 };
+
+ memcpy(&t_ach, RFIFOP(fd, 8 + i * sizeof(struct achievement)), sizeof(struct achievement));
+
+ if (achievement->get(t_ach.id) == NULL) {
+ ShowError("intif_parse_achievements_load: Invalid Achievement %d received from character %d. Ignoring...\n", t_ach.id, char_id);
+ continue;
+ }
+
+ VECTOR_PUSH(sd->achievement, t_ach);
+ }
+
+ achievement->init_titles(sd);
+ clif->achievement_send_list(fd, sd);
+ sd->achievements_received = true;
+}
+
+/**
+ * Send character's achievement data to the inter-server.
+ * @packet 0x3013 <packet_len>.W <char_id>.L <achievements[]>.P
+ * @param sd pointer to map session data.
+ */
+static void intif_achievements_save(struct map_session_data *sd)
+{
+ int packet_len = 0, payload_size = 0, i = 0;
+
+ nullpo_retv(sd);
+ /* check for character server. */
+ if (intif->CheckForCharServer())
+ return;
+ /* Return if no data. */
+ if (!(payload_size = VECTOR_LENGTH(sd->achievement) * sizeof(struct achievement)))
+ return;
+
+ packet_len = payload_size + 8;
+
+ WFIFOHEAD(inter_fd, packet_len);
+ WFIFOW(inter_fd, 0) = 0x3013;
+ WFIFOW(inter_fd, 2) = packet_len;
+ WFIFOL(inter_fd, 4) = sd->status.char_id;
+ for (i = 0; i < VECTOR_LENGTH(sd->achievement); i++)
+ memcpy(WFIFOP(inter_fd, 8 + i * sizeof(struct achievement)), &VECTOR_INDEX(sd->achievement, i), sizeof(struct achievement));
+ WFIFOSET(inter_fd, packet_len);
+}
+
+/**************************************
+ * QUESTLOG SYSTEM FUNCTIONS *
+ **************************************/
/**
* Requests a character's quest log entries to the inter server.
*
* @param sd Character's data
*/
-void intif_request_questlog(struct map_session_data *sd)
+static void intif_request_questlog(struct map_session_data *sd)
{
nullpo_retv(sd);
WFIFOHEAD(inter_fd,6);
@@ -1519,7 +1552,8 @@ void intif_request_questlog(struct map_session_data *sd)
*
* @see intif_parse
*/
-void intif_parse_QuestLog(int fd) {
+static void intif_parse_QuestLog(int fd)
+{
int char_id = RFIFOL(fd, 4), num_received = (RFIFOW(fd, 2)-8)/sizeof(struct quest);
struct map_session_data *sd = map->charid2sd(char_id);
@@ -1574,7 +1608,8 @@ void intif_parse_QuestLog(int fd) {
*
* @see intif_parse
*/
-void intif_parse_QuestSave(int fd) {
+static void intif_parse_QuestSave(int fd)
+{
int cid = RFIFOL(fd, 2);
struct map_session_data *sd = map->id2sd(cid);
@@ -1590,7 +1625,7 @@ void intif_parse_QuestSave(int fd) {
* @param sd Character's data
* @return 0 in case of success, nonzero otherwise
*/
-int intif_quest_save(struct map_session_data *sd)
+static int intif_quest_save(struct map_session_data *sd)
{
int len = sizeof(struct quest)*sd->num_quests + 8;
@@ -1617,7 +1652,7 @@ int intif_quest_save(struct map_session_data *sd)
* Inbox Request
* flag: 0 Update Inbox | 1 OpenMail
*------------------------------------------*/
-int intif_Mail_requestinbox(int char_id, unsigned char flag)
+static int intif_Mail_requestinbox(int char_id, unsigned char flag)
{
if (intif->CheckForCharServer())
return 0;
@@ -1631,7 +1666,8 @@ int intif_Mail_requestinbox(int char_id, unsigned char flag)
return 0;
}
-void intif_parse_MailInboxReceived(int fd) {
+static void intif_parse_MailInboxReceived(int fd)
+{
struct map_session_data *sd;
unsigned char flag = RFIFOB(fd,8);
@@ -1654,13 +1690,13 @@ 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_sd(sd,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);
}
}
/*------------------------------------------
* Mail Read
*------------------------------------------*/
-int intif_Mail_read(int mail_id)
+static int intif_Mail_read(int mail_id)
{
if (intif->CheckForCharServer())
return 0;
@@ -1675,7 +1711,7 @@ int intif_Mail_read(int mail_id)
/*------------------------------------------
* Get Attachment
*------------------------------------------*/
-int intif_Mail_getattach(int char_id, int mail_id)
+static int intif_Mail_getattach(int char_id, int mail_id)
{
if (intif->CheckForCharServer())
return 0;
@@ -1689,7 +1725,8 @@ int intif_Mail_getattach(int char_id, int mail_id)
return 0;
}
-void intif_parse_MailGetAttach(int fd) {
+static void intif_parse_MailGetAttach(int fd)
+{
struct map_session_data *sd;
struct item item;
int zeny = RFIFOL(fd,8);
@@ -1714,7 +1751,7 @@ void intif_parse_MailGetAttach(int fd) {
/*------------------------------------------
* Delete Message
*------------------------------------------*/
-int intif_Mail_delete(int char_id, int mail_id)
+static int intif_Mail_delete(int char_id, int mail_id)
{
if (intif->CheckForCharServer())
return 0;
@@ -1728,7 +1765,8 @@ int intif_Mail_delete(int char_id, int mail_id)
return 0;
}
-void intif_parse_MailDelete(int fd) {
+static void intif_parse_MailDelete(int fd)
+{
struct map_session_data *sd;
int char_id = RFIFOL(fd,2);
int mail_id = RFIFOL(fd,6);
@@ -1756,7 +1794,7 @@ void intif_parse_MailDelete(int fd) {
/*------------------------------------------
* Return Message
*------------------------------------------*/
-int intif_Mail_return(int char_id, int mail_id)
+static int intif_Mail_return(int char_id, int mail_id)
{
if (intif->CheckForCharServer())
return 0;
@@ -1770,7 +1808,8 @@ int intif_Mail_return(int char_id, int mail_id)
return 0;
}
-void intif_parse_MailReturn(int fd) {
+static 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);
@@ -1797,7 +1836,7 @@ void intif_parse_MailReturn(int fd) {
/*------------------------------------------
* Send Mail
*------------------------------------------*/
-int intif_Mail_send(int account_id, struct mail_message *msg)
+static int intif_Mail_send(int account_id, struct mail_message *msg)
{
int len = sizeof(struct mail_message) + 8;
@@ -1815,7 +1854,8 @@ int intif_Mail_send(int account_id, struct mail_message *msg)
return 1;
}
-void intif_parse_MailSend(int fd) {
+static void intif_parse_MailSend(int fd)
+{
struct mail_message msg;
struct map_session_data *sd;
bool fail;
@@ -1841,7 +1881,8 @@ void intif_parse_MailSend(int fd) {
}
}
-void intif_parse_MailNew(int fd) {
+static 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 = RFIFOP(fd,10);
@@ -1858,7 +1899,7 @@ void intif_parse_MailNew(int fd) {
* AUCTION SYSTEM
* By Zephyrus
*==========================================*/
-int intif_Auction_requestlist(int char_id, short type, int price, const char* searchtext, short page)
+static int intif_Auction_requestlist(int char_id, short type, int price, const char *searchtext, short page)
{
int len = NAME_LENGTH + 16;
@@ -1879,7 +1920,8 @@ int intif_Auction_requestlist(int char_id, short type, int price, const char* se
return 0;
}
-void intif_parse_AuctionResults(int fd) {
+static 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);
@@ -1891,7 +1933,7 @@ void intif_parse_AuctionResults(int fd) {
clif->auction_results(sd, count, pages, data);
}
-int intif_Auction_register(struct auction_data *auction)
+static int intif_Auction_register(struct auction_data *auction)
{
int len = sizeof(struct auction_data) + 4;
@@ -1908,7 +1950,8 @@ int intif_Auction_register(struct auction_data *auction)
return 1;
}
-void intif_parse_AuctionRegister(int fd) {
+static void intif_parse_AuctionRegister(int fd)
+{
struct map_session_data *sd;
struct auction_data auction;
@@ -1935,7 +1978,7 @@ void intif_parse_AuctionRegister(int fd) {
}
}
-int intif_Auction_cancel(int char_id, unsigned int auction_id)
+static int intif_Auction_cancel(int char_id, unsigned int auction_id)
{
if( intif->CheckForCharServer() )
return 0;
@@ -1949,7 +1992,8 @@ int intif_Auction_cancel(int char_id, unsigned int auction_id)
return 0;
}
-void intif_parse_AuctionCancel(int fd) {
+static void intif_parse_AuctionCancel(int fd)
+{
struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2));
int result = RFIFOB(fd,6);
@@ -1964,7 +2008,7 @@ void intif_parse_AuctionCancel(int fd) {
}
}
-int intif_Auction_close(int char_id, unsigned int auction_id)
+static int intif_Auction_close(int char_id, unsigned int auction_id)
{
if( intif->CheckForCharServer() )
return 0;
@@ -1978,7 +2022,8 @@ int intif_Auction_close(int char_id, unsigned int auction_id)
return 0;
}
-void intif_parse_AuctionClose(int fd) {
+static void intif_parse_AuctionClose(int fd)
+{
struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2));
unsigned char result = RFIFOB(fd,6);
@@ -1993,7 +2038,7 @@ void intif_parse_AuctionClose(int fd) {
}
}
-int intif_Auction_bid(int char_id, const char* name, unsigned int auction_id, int bid)
+static int intif_Auction_bid(int char_id, const char *name, unsigned int auction_id, int bid)
{
int len = 16 + NAME_LENGTH;
@@ -2013,7 +2058,8 @@ int intif_Auction_bid(int char_id, const char* name, unsigned int auction_id, in
return 0;
}
-void intif_parse_AuctionBid(int fd) {
+static 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);
@@ -2032,7 +2078,8 @@ void intif_parse_AuctionBid(int fd) {
}
// Used to send 'You have won the auction' and 'You failed to won the auction' messages
-void intif_parse_AuctionMessage(int fd) {
+static void intif_parse_AuctionMessage(int fd)
+{
struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2));
unsigned char result = RFIFOB(fd,6);
@@ -2045,7 +2092,7 @@ void intif_parse_AuctionMessage(int fd) {
/*==========================================
* Mercenary's System
*------------------------------------------*/
-int intif_mercenary_create(struct s_mercenary *merc)
+static int intif_mercenary_create(struct s_mercenary *merc)
{
int size = sizeof(struct s_mercenary) + 4;
@@ -2061,7 +2108,8 @@ int intif_mercenary_create(struct s_mercenary *merc)
return 0;
}
-void intif_parse_MercenaryReceived(int fd) {
+static void intif_parse_MercenaryReceived(int fd)
+{
int len = RFIFOW(fd,2) - 5;
if (sizeof(struct s_mercenary) != len) {
@@ -2073,7 +2121,7 @@ void intif_parse_MercenaryReceived(int fd) {
mercenary->data_received(RFIFOP(fd,5), RFIFOB(fd,4));
}
-int intif_mercenary_request(int merc_id, int char_id)
+static int intif_mercenary_request(int merc_id, int char_id)
{
if (intif->CheckForCharServer())
return 0;
@@ -2086,7 +2134,7 @@ int intif_mercenary_request(int merc_id, int char_id)
return 0;
}
-int intif_mercenary_delete(int merc_id)
+static int intif_mercenary_delete(int merc_id)
{
if (intif->CheckForCharServer())
return 0;
@@ -2098,12 +2146,13 @@ int intif_mercenary_delete(int merc_id)
return 0;
}
/* Really? Whats the point, shouldn't be sent when successful then [Ind] */
-void intif_parse_MercenaryDeleted(int fd) {
+static void intif_parse_MercenaryDeleted(int fd)
+{
if( RFIFOB(fd,2) != 1 )
ShowError("Mercenary data delete failure\n");
}
-int intif_mercenary_save(struct s_mercenary *merc)
+static int intif_mercenary_save(struct s_mercenary *merc)
{
int size = sizeof(struct s_mercenary) + 4;
@@ -2119,7 +2168,8 @@ int intif_mercenary_save(struct s_mercenary *merc)
return 0;
}
/* Really? Whats the point, shouldn't be sent when successful then [Ind] */
-void intif_parse_MercenarySaved(int fd) {
+static void intif_parse_MercenarySaved(int fd)
+{
if( RFIFOB(fd,2) != 1 )
ShowError("Mercenary data save failure\n");
}
@@ -2127,7 +2177,7 @@ void intif_parse_MercenarySaved(int fd) {
/*==========================================
* Elemental's System
*------------------------------------------*/
-int intif_elemental_create(struct s_elemental *ele)
+static int intif_elemental_create(struct s_elemental *ele)
{
int size = sizeof(struct s_elemental) + 4;
@@ -2143,7 +2193,8 @@ int intif_elemental_create(struct s_elemental *ele)
return 0;
}
-void intif_parse_ElementalReceived(int fd) {
+static void intif_parse_ElementalReceived(int fd)
+{
int len = RFIFOW(fd,2) - 5;
if (sizeof(struct s_elemental) != len) {
@@ -2155,7 +2206,7 @@ void intif_parse_ElementalReceived(int fd) {
elemental->data_received(RFIFOP(fd,5), RFIFOB(fd,4));
}
-int intif_elemental_request(int ele_id, int char_id)
+static int intif_elemental_request(int ele_id, int char_id)
{
if (intif->CheckForCharServer())
return 0;
@@ -2168,7 +2219,7 @@ int intif_elemental_request(int ele_id, int char_id)
return 0;
}
-int intif_elemental_delete(int ele_id)
+static int intif_elemental_delete(int ele_id)
{
if (intif->CheckForCharServer())
return 0;
@@ -2180,12 +2231,13 @@ int intif_elemental_delete(int ele_id)
return 0;
}
/* Really? Whats the point, shouldn't be sent when successful then [Ind] */
-void intif_parse_ElementalDeleted(int fd) {
+static void intif_parse_ElementalDeleted(int fd)
+{
if( RFIFOB(fd,2) != 1 )
ShowError("Elemental data delete failure\n");
}
-int intif_elemental_save(struct s_elemental *ele)
+static int intif_elemental_save(struct s_elemental *ele)
{
int size = sizeof(struct s_elemental) + 4;
@@ -2201,12 +2253,14 @@ int intif_elemental_save(struct s_elemental *ele)
return 0;
}
/* Really? Whats the point, shouldn't be sent when successful then [Ind] */
-void intif_parse_ElementalSaved(int fd) {
+static void intif_parse_ElementalSaved(int fd)
+{
if( RFIFOB(fd,2) != 1 )
ShowError("Elemental data save failure\n");
}
-void intif_request_accinfo( int u_fd, int aid, int group_lv, char* query ) {
+static void intif_request_accinfo(int u_fd, int aid, int group_lv, char *query)
+{
nullpo_retv(query);
WFIFOHEAD(inter_fd,2 + 4 + 4 + 4 + NAME_LENGTH);
@@ -2221,7 +2275,8 @@ void intif_request_accinfo( int u_fd, int aid, int group_lv, char* query ) {
return;
}
-void intif_parse_MessageToFD(int fd) {
+static void intif_parse_MessageToFD(int fd)
+{
int u_fd = RFIFOL(fd,4);
Assert_retv(sockt->session_is_valid(u_fd));
@@ -2242,7 +2297,8 @@ void intif_parse_MessageToFD(int fd) {
/*==========================================
* Item Bound System [Xantara][Mhalicot]
*------------------------------------------*/
-void intif_itembound_req(int char_id,int aid,int guild_id) {
+static void intif_itembound_req(int char_id, int aid, int guild_id)
+{
#ifdef GP_BOUND_ITEMS
struct guild_storage *gstor = idb_get(gstorage->db,guild_id);
WFIFOHEAD(inter_fd,12);
@@ -2257,7 +2313,8 @@ void intif_itembound_req(int char_id,int aid,int guild_id) {
}
//3856
-void intif_parse_Itembound_ack(int fd) {
+static void intif_parse_Itembound_ack(int fd)
+{
#ifdef GP_BOUND_ITEMS
struct guild_storage *gstor;
int guild_id = RFIFOW(fd,6);
@@ -2267,11 +2324,277 @@ void intif_parse_Itembound_ack(int fd) {
gstor->lock = 0; //Unlock now that operation is completed
#endif
}
+
+/*==========================================
+ * RoDEX System
+ *==========================================*/
+
+/*------------------------------------------
+ * Mail List
+ *------------------------------------------*/
+
+// Rodex Inbox Request
+// char_id: char_id
+// account_id: account_id (used by account mail)
+// flag: 0 - Open/Refresh ; 1 = Next Page
+static int intif_rodex_requestinbox(int char_id, int account_id, int8 flag, int8 opentype, int64 mail_id)
+{
+ if (intif->CheckForCharServer())
+ return 0;
+
+ WFIFOHEAD(inter_fd, 20);
+ WFIFOW(inter_fd, 0) = 0x3095;
+ WFIFOL(inter_fd, 2) = char_id;
+ WFIFOL(inter_fd, 6) = account_id;
+ WFIFOL(inter_fd, 10) = flag;
+ WFIFOB(inter_fd, 11) = opentype;
+ WFIFOQ(inter_fd, 12) = mail_id;
+ WFIFOSET(inter_fd, 20);
+
+ return 0;
+}
+
+static void intif_parse_RequestRodexOpenInbox(int fd)
+{
+ struct map_session_data *sd;
+#if PACKETVER < 20170419
+ int8 opentype = RFIFOB(fd, 8);
+#endif
+ int8 flag = RFIFOB(fd, 9);
+ int8 is_end = RFIFOB(fd, 10);
+ int is_first = RFIFOB(fd, 11);
+ int count = RFIFOL(fd, 12);
+#if PACKETVER >= 20170419
+ int64 mail_id = RFIFOQ(fd, 16);
+#endif
+ int i, j;
+
+ sd = map->charid2sd(RFIFOL(fd, 4));
+
+ if (sd == NULL) // user is not online anymore
+ return;
+
+ if (is_first == false && sd->rodex.total == 0) {
+ ShowError("intif_parse_RodexInboxOpenReceived: mail list received in wrong order.\n");
+ return;
+ }
+
+ if (is_first)
+ sd->rodex.total = count;
+ else
+ sd->rodex.total += count;
+
+ if (RFIFOW(fd, 2) - 24 != count * sizeof(struct rodex_message)) {
+ ShowError("intif_parse_RodexInboxOpenReceived: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd, 2) - 24, count * sizeof(struct rodex_message));
+ return;
+ }
+
+ if (flag == 0 && is_first)
+ VECTOR_CLEAR(sd->rodex.messages);
+
+ for (i = 0, j = 24; i < count; ++i, j += sizeof(struct rodex_message)) {
+ struct rodex_message msg = { 0 };
+ VECTOR_ENSURE(sd->rodex.messages, 1, 1);
+ memcpy(&msg, RFIFOP(fd, j), sizeof(struct rodex_message));
+ VECTOR_PUSH(sd->rodex.messages, msg);
+ }
+
+ if (is_end == true) {
+#if PACKETVER >= 20170419
+ clif->rodex_send_mails_all(sd->fd, sd, mail_id);
+#else
+ if (flag == 0)
+ clif->rodex_send_maillist(sd->fd, sd, opentype, VECTOR_LENGTH(sd->rodex.messages) - 1);
+ else
+ clif->rodex_send_refresh(sd->fd, sd, opentype, count);
+#endif
+ }
+}
+
+/*------------------------------------------
+ * Notifications
+ *------------------------------------------*/
+static int intif_rodex_hasnew(struct map_session_data *sd)
+{
+ nullpo_retr(0, sd);
+
+ if (intif->CheckForCharServer())
+ return 0;
+
+ WFIFOHEAD(inter_fd, 10);
+ WFIFOW(inter_fd, 0) = 0x3096;
+ WFIFOL(inter_fd, 2) = sd->status.char_id;
+ WFIFOL(inter_fd, 6) = sd->status.account_id;
+ WFIFOSET(inter_fd, 10);
+
+ return 0;
+}
+
+static void intif_parse_RodexNotifications(int fd)
+{
+ struct map_session_data *sd;
+ bool has_messages;
+
+ sd = map->charid2sd(RFIFOL(fd, 2));
+ has_messages = RFIFOB(fd, 6);
+
+ if (sd == NULL) // user is not online anymore
+ return;
+
+ clif->rodex_icon(sd->fd, has_messages);
+}
+
+/*------------------------------------------
+ * Update Mail
+ *------------------------------------------*/
+
+/// Updates a mail
+/// flag:
+/// 0 - receiver Read
+/// 1 - user got Zeny
+/// 2 - user got Items
+/// 3 - delete
+/// 4 - sender Read (returned mail)
+static int intif_rodex_updatemail(struct map_session_data *sd, int64 mail_id, uint8 opentype, int8 flag)
+{
+ nullpo_ret(sd);
+
+ if (intif->CheckForCharServer())
+ return 0;
+
+ WFIFOHEAD(inter_fd, 20);
+ WFIFOW(inter_fd, 0) = 0x3097;
+ WFIFOL(inter_fd, 2) = sd->status.account_id;
+ WFIFOL(inter_fd, 6) = sd->status.char_id;
+ WFIFOQ(inter_fd, 10) = mail_id;
+ WFIFOB(inter_fd, 18) = opentype;
+ WFIFOB(inter_fd, 19) = flag;
+ WFIFOSET(inter_fd, 20);
+
+ return 0;
+}
+
+/*------------------------------------------
+ * Send Mail
+ *------------------------------------------*/
+static int intif_rodex_sendmail(struct rodex_message *msg)
+{
+ if (intif->CheckForCharServer())
+ return 0;
+
+ nullpo_retr(0, msg);
+
+ WFIFOHEAD(inter_fd, 4 + sizeof(struct rodex_message));
+ WFIFOW(inter_fd, 0) = 0x3098;
+ WFIFOW(inter_fd, 2) = 4 + sizeof(struct rodex_message);
+ memcpy(WFIFOP(inter_fd, 4), msg, sizeof(struct rodex_message));
+ WFIFOSET(inter_fd, 4 + sizeof(struct rodex_message));
+
+ return 0;
+}
+
+static void intif_parse_RodexSendMail(int fd)
+{
+ struct map_session_data *ssd = NULL, *rsd = NULL;
+ int sender_id = RFIFOL(fd, 2);
+ int receiver_id = RFIFOL(fd, 6);
+ int receiver_accountid = RFIFOL(fd, 10);
+
+ if (sender_id > 0)
+ ssd = map->charid2sd(sender_id);
+
+ if (receiver_id > 0)
+ rsd = map->charid2sd(receiver_id);
+ else if (receiver_accountid > 0)
+ rsd = map->id2sd(receiver_accountid);
+
+ rodex->send_mail_result(ssd, rsd, RFIFOL(fd, 14));
+}
+
+/*------------------------------------------
+ * Check Player
+ *------------------------------------------*/
+static int intif_rodex_checkname(struct map_session_data *sd, const char *name)
+{
+ if (intif->CheckForCharServer())
+ return 0;
+
+ nullpo_retr(0, sd);
+ nullpo_retr(0, name);
+
+ WFIFOHEAD(inter_fd, 6 + NAME_LENGTH);
+ WFIFOW(inter_fd, 0) = 0x3099;
+ WFIFOL(inter_fd, 2) = sd->status.char_id;
+ safestrncpy(WFIFOP(inter_fd, 6), name, NAME_LENGTH);
+ WFIFOSET(inter_fd, 6 + NAME_LENGTH);
+
+ return 0;
+}
+
+static void intif_parse_RodexCheckName(int fd)
+{
+ struct map_session_data *sd = NULL;
+ int reqchar_id = RFIFOL(fd, 2);
+ int target_char_id = RFIFOL(fd, 6);
+ int target_class = RFIFOL(fd, 10);
+ int target_level = RFIFOL(fd, 14);
+ char name[NAME_LENGTH];
+
+ safestrncpy(name, RFIFOP(inter_fd, 18), NAME_LENGTH);
+
+ if (reqchar_id <= 0)
+ return;
+
+ sd = map->charid2sd(reqchar_id);
+
+ if (sd == NULL) // User is not online anymore
+ return;
+
+ if (target_char_id == 0) {
+ clif->rodex_checkname_result(sd, 0, 0, 0, name);
+ return;
+ }
+
+ sd->rodex.tmp.receiver_id = target_char_id;
+ safestrncpy(sd->rodex.tmp.receiver_name, name, NAME_LENGTH);
+
+ clif->rodex_checkname_result(sd, target_char_id, target_class, target_level, name);
+}
+
+static void intif_parse_GetZenyAck(int fd)
+{
+ int char_id = RFIFOL(fd, 2);
+ int64 zeny = RFIFOL(fd, 6);
+ int64 mail_id = RFIFOQ(fd, 14);
+ uint8 opentype = RFIFOB(fd, 22);
+ struct map_session_data *sd = map->charid2sd(char_id);
+
+ if (sd == NULL) // User is not online anymore
+ return;
+ rodex->getZenyAck(sd, mail_id, opentype, zeny);
+}
+
+static void intif_parse_GetItemsAck(int fd)
+{
+ int char_id = RFIFOL(fd, 2);
+
+ struct map_session_data *sd = map->charid2sd(char_id);
+ if (sd == NULL) // User is not online anymore
+ return;
+
+ int64 mail_id = RFIFOQ(fd, 6);
+ uint8 opentype = RFIFOB(fd, 14);
+ int count = RFIFOB(fd, 15);
+ struct rodex_item items[RODEX_MAX_ITEM];
+ memcpy(&items[0], RFIFOP(fd, 16), sizeof(struct rodex_item) * RODEX_MAX_ITEM);
+ rodex->getItemsAck(sd, mail_id, opentype, count, &items[0]);
+}
+
//-----------------------------------------------------------------
// Communication from the inter server
// Return a 0 (false) if there were any errors.
// 1, 2 if there are not enough to return the length of the packet if the packet processing
-int intif_parse(int fd)
+static int intif_parse(int fd)
{
int packet_len, cmd;
cmd = RFIFOW(fd,0);
@@ -2293,18 +2616,12 @@ int intif_parse(int fd)
}
// Processing branch
switch(cmd){
- case 0x3800:
- if (RFIFOL(fd,4) == 0xFF000000) //Normal announce.
- clif->broadcast(NULL, RFIFOP(fd,16), packet_len-16, BC_DEFAULT, ALL_CLIENT);
- else //Color announce.
- clif->broadcast2(NULL, 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 0x3805: intif->pAccountStorage(fd); break;
case 0x3806: intif->pChangeNameOk(fd); break;
case 0x3807: intif->pMessageToFD(fd); break;
+ case 0x3808: intif->pAccountStorageSaveAck(fd); break;
+ case 0x3810: intif->pAchievementsLoad(fd); break;
case 0x3818: intif->pLoadGuildStorage(fd); break;
case 0x3819: intif->pSaveGuildStorage(fd); break;
case 0x3820: intif->pPartyCreated(fd); break;
@@ -2314,14 +2631,12 @@ int intif_parse(int fd)
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;
@@ -2375,6 +2690,17 @@ int intif_parse(int fd)
case 0x3891: intif->pRecvHomunculusData(fd); break;
case 0x3892: intif->pSaveHomunculusOk(fd); break;
case 0x3893: intif->pDeleteHomunculusOk(fd); break;
+
+ // RoDEX
+ case 0x3895: intif->pRequestRodexOpenInbox(fd); break;
+ case 0x3896: intif->pRodexHasNew(fd); break;
+ case 0x3897: intif->pRodexSendMail(fd); break;
+ case 0x3898: intif->pRodexCheckName(fd); break;
+ case 0x3899: intif->pGetZenyAck(fd); break;
+ case 0x389a: intif->pGetItemsAck(fd); break;
+
+ // Clan System
+ case 0x3858: intif->pRecvClanMemberAction(fd); break;
default:
ShowError("intif_parse : unknown packet %d %x\n",fd,RFIFOW(fd,0));
return 0;
@@ -2385,22 +2711,23 @@ int intif_parse(int fd)
}
/*=====================================
-* Default Functions : intif.h
-* Generated by HerculesInterfaceMaker
-* created by Susu
-*-------------------------------------*/
-void intif_defaults(void) {
+ * 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
+ 0, 0, 0, 0, -1,-1,37,-1, 7, 0, 0, 0, 0, 0, 0, 0, //0x3800-0x380f
+ -1, 0, 0, 0, 0, 0, 0, 0, -1,11, 0, 0, 0, 0, 0, 0, //0x3810 Achievements [Smokexyz/Hercules]
+ 39,-1,15,15, 14,19, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3820
+ 10,-1,15, 0, 79,25, 7, 0, 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,-1, 7, 7, 7,11, 8, 0, 10, 0, 0, 0, 0, 0, 0, 0, //0x3850 Auctions [Zephyrus] itembound[Akinari] Clan System[Murilo BiO]
-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]
+ 14,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3880
+ -1,-1, 7, 3, 0,-1, 7, 15,18 + NAME_LENGTH, 23, 16 + sizeof(struct rodex_item) * RODEX_MAX_ITEM, 0, 0, 0, 0, 0, //0x3890 Homunculus [albator] / RoDEX [KirieZ]
};
intif = &intif_s;
@@ -2411,13 +2738,10 @@ void intif_defaults(void) {
/* 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_account_storage = intif_request_account_storage;
+ intif->send_account_storage = intif_send_account_storage;
intif->request_guild_storage = intif_request_guild_storage;
intif->send_guild_storage = intif_send_guild_storage;
intif->create_party = intif_create_party;
@@ -2427,7 +2751,6 @@ void intif_defaults(void) {
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;
@@ -2435,7 +2758,6 @@ void intif_defaults(void) {
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;
@@ -2480,20 +2802,30 @@ void intif_defaults(void) {
intif->elemental_request = intif_elemental_request;
intif->elemental_delete = intif_elemental_delete;
intif->elemental_save = intif_elemental_save;
+ // RoDEX
+ intif->rodex_requestinbox = intif_rodex_requestinbox;
+ intif->rodex_checkhasnew = intif_rodex_hasnew;
+ intif->rodex_updatemail = intif_rodex_updatemail;
+ intif->rodex_sendmail = intif_rodex_sendmail;
+ intif->rodex_checkname = intif_rodex_checkname;
+ /* Clan System */
+ intif->clan_kickoffline = intif_clan_kickoffline;
+ intif->clan_membercount = intif_clan_membercount;
/* @accinfo */
intif->request_accinfo = intif_request_accinfo;
/* */
intif->CheckForCharServer = CheckForCharServer;
/* */
intif->itembound_req = intif_itembound_req;
+ /* Achievement System */
+ intif->achievements_request = intif_achievements_request;
+ intif->achievements_save = intif_achievements_save;
/* 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->pAccountStorage = intif_parse_account_storage;
+ intif->pAccountStorageSaveAck = intif_parse_account_storage_save_ack;
intif->pLoadGuildStorage = intif_parse_LoadGuildStorage;
intif->pSaveGuildStorage = intif_parse_SaveGuildStorage;
intif->pPartyCreated = intif_parse_PartyCreated;
@@ -2503,14 +2835,12 @@ void intif_defaults(void) {
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;
@@ -2549,4 +2879,15 @@ void intif_defaults(void) {
intif->pRecvHomunculusData = intif_parse_RecvHomunculusData;
intif->pSaveHomunculusOk = intif_parse_SaveHomunculusOk;
intif->pDeleteHomunculusOk = intif_parse_DeleteHomunculusOk;
+ /* RoDEX */
+ intif->pRequestRodexOpenInbox = intif_parse_RequestRodexOpenInbox;
+ intif->pRodexHasNew = intif_parse_RodexNotifications;
+ intif->pRodexSendMail = intif_parse_RodexSendMail;
+ intif->pRodexCheckName = intif_parse_RodexCheckName;
+ intif->pGetZenyAck = intif_parse_GetZenyAck;
+ intif->pGetItemsAck = intif_parse_GetItemsAck;
+ /* Clan System */
+ intif->pRecvClanMemberAction = intif_parse_RecvClanMemberAction;
+ /* Achievement System */
+ intif->pAchievementsLoad = intif_parse_achievements_load;
}