summaryrefslogtreecommitdiff
path: root/src/map/clif.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/clif.c')
-rw-r--r--src/map/clif.c215
1 files changed, 172 insertions, 43 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 28b20c9e2..088c92ea8 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -679,7 +679,7 @@ void clif_authok(struct map_session_data *sd)
p.font = sd->status.font;
#endif
// Some clients smaller than 20160330 cant be tested [4144]
-#if PACKETVER >= 20141016 && PACKETVER < 20160330
+#if PACKETVER >= 20141022 && PACKETVER < 20160330
p.sex = sd->status.sex;
#endif
clif->send(&p,sizeof(p),&sd->bl,SELF);
@@ -888,8 +888,8 @@ void clif_get_weapon_view(struct map_session_data* sd, unsigned short *rhand, un
}
#if PACKETVER < 4
- *rhand = sd->status.weapon;
- *lhand = sd->status.shield;
+ *rhand = sd->status.look.weapon;
+ *lhand = sd->status.look.shield;
#else
if (sd->equip_index[EQI_HAND_R] >= 0 &&
sd->inventory_data[sd->equip_index[EQI_HAND_R]])
@@ -1491,8 +1491,8 @@ bool clif_spawn(struct block_list *bl)
}
if (sd->charm_type != CHARM_TYPE_NONE && sd->charm_count > 0)
clif->spiritcharm(sd);
- if (sd->status.robe)
- clif->refreshlook(bl,bl->id,LOOK_ROBE,sd->status.robe,AREA);
+ if (sd->status.look.robe != 0)
+ clif->refreshlook(bl, bl->id, LOOK_ROBE, sd->status.look.robe, AREA);
}
break;
case BL_MOB:
@@ -2414,9 +2414,9 @@ void clif_addcards2(unsigned short *cards, struct item* item) {
int clif_add_item_options(struct ItemOptions *buf, const struct item *it)
{
int i = 0, j = 0, total_options = 0;
-
+
nullpo_ret(buf);
-
+
// Append the buffer with existing options first.
for (i = 0; i < MAX_ITEM_OPTIONS; i++) {
if (it->option[i].index) {
@@ -2433,7 +2433,7 @@ void clif_addcards2(unsigned short *cards, struct item* item) {
WBUFW(buf, j * 5 + 2) = 0;
WBUFB(buf, j * 5 + 4) = 0;
}
-
+
return total_options;
}
@@ -2488,7 +2488,7 @@ void clif_additem(struct map_session_data *sd, int n, int amount, int fail)
#endif
#if PACKETVER >= 20160921
p.favorite = sd->status.inventory[n].favorite;
- p.look = sd->inventory_data[n]->look;
+ p.look = sd->inventory_data[n]->view_sprite;
#endif
}
p.result = (unsigned char)fail;
@@ -2597,7 +2597,7 @@ void clif_item_equip(short idx, struct EQUIPITEM_INFO *p, struct item *it, struc
#endif
#if PACKETVER >= 20100629
- p->wItemSpriteNumber = (id->equip&EQP_VISIBLE) ? id->look : 0;
+ p->wItemSpriteNumber = (id->equip&EQP_VISIBLE) ? id->view_sprite : 0;
#endif
#if PACKETVER >= 20120925
@@ -3033,27 +3033,50 @@ void clif_updatestatus(struct map_session_data *sd,int type)
WFIFOL(fd,4)=sd->status.zeny;
len = packet_len(0xb1);
break;
+// [4144] unconfirment exact version can be from 20170405 to 20170913
+#if PACKETVER >= 20170830
case SP_BASEEXP:
- WFIFOW(fd,0)=0xb1;
- WFIFOL(fd,4)=sd->status.base_exp;
+ WFIFOW(fd, 0) = 0xacb;
+ WFIFOQ(fd, 4) = sd->status.base_exp;
+ len = packet_len(0xacb);
+ break;
+ case SP_JOBEXP:
+ WFIFOW(fd, 0) = 0xacb;
+ WFIFOQ(fd, 4) = sd->status.job_exp;
+ len = packet_len(0xacb);
+ break;
+ case SP_NEXTBASEEXP:
+ WFIFOW(fd, 0) = 0xacb;
+ WFIFOQ(fd, 4) = pc->nextbaseexp(sd);
+ len = packet_len(0xacb);
+ break;
+ case SP_NEXTJOBEXP:
+ WFIFOW(fd, 0) = 0xacb;
+ WFIFOQ(fd, 4) = pc->nextjobexp(sd);
+ len = packet_len(0xacb);
+ break;
+#else
+ case SP_BASEEXP:
+ WFIFOW(fd, 0) = 0xb1;
+ WFIFOL(fd, 4) = (uint32)(sd->status.base_exp);
len = packet_len(0xb1);
break;
case SP_JOBEXP:
- WFIFOW(fd,0)=0xb1;
- WFIFOL(fd,4)=sd->status.job_exp;
+ WFIFOW(fd, 0) = 0xb1;
+ WFIFOL(fd, 4) = (uint32)(sd->status.job_exp);
len = packet_len(0xb1);
break;
case SP_NEXTBASEEXP:
- WFIFOW(fd,0)=0xb1;
- WFIFOL(fd,4)=pc->nextbaseexp(sd);
+ WFIFOW(fd, 0) = 0xb1;
+ WFIFOL(fd, 4) = (uint32)pc->nextbaseexp(sd);
len = packet_len(0xb1);
break;
case SP_NEXTJOBEXP:
- WFIFOW(fd,0)=0xb1;
- WFIFOL(fd,4)=pc->nextjobexp(sd);
+ WFIFOW(fd, 0) = 0xb1;
+ WFIFOL(fd, 4) = (uint32)pc->nextjobexp(sd);
len = packet_len(0xb1);
break;
-
+#endif
/**
* SP_U<STAT> are used to update the amount of points necessary to increase that stat
**/
@@ -3183,7 +3206,9 @@ void clif_changelook(struct block_list *bl,int type,int val)
struct status_change* sc;
struct view_data* vd;
enum send_target target = AREA;
+#if PACKETVER >= 4
int val2 = 0;
+#endif
nullpo_retv(bl);
sd = BL_CAST(BL_PC, bl);
@@ -3527,7 +3552,7 @@ void clif_equipitemack(struct map_session_data *sd,int n,int pos,enum e_EQUIP_IT
p.wearLocation = pos;
#if PACKETVER >= 20100629
if (result == EIA_SUCCESS && sd->inventory_data[n]->equip&EQP_VISIBLE)
- p.wItemSpriteNumber = sd->inventory_data[n]->look;
+ p.wItemSpriteNumber = sd->inventory_data[n]->view_sprite;
else
p.wItemSpriteNumber = 0;
#endif
@@ -4309,8 +4334,8 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) {
clif->specialeffect_single(bl,421,sd->fd);
if (tsd->bg_id != 0 && map->list[tsd->bl.m].flag.battleground)
clif->sendbgemblem_single(sd->fd,tsd);
- if (tsd->status.robe)
- clif->refreshlook(&sd->bl,bl->id,LOOK_ROBE,tsd->status.robe,SELF);
+ if (tsd->status.look.robe != 0)
+ clif->refreshlook(&sd->bl, bl->id, LOOK_ROBE, tsd->status.look.robe, SELF);
}
break;
case BL_MER: // Devotion Effects
@@ -6402,7 +6427,7 @@ void clif_vendinglist(struct map_session_data* sd, unsigned int id, struct s_ven
// [4144] date 20160921 not confirmend. Can be bigger or smaller
#if PACKETVER >= 20160921
WFIFOL(fd, offset + 47 + i * item_length) = pc->item_equippoint(sd, data);
- WFIFOW(fd, offset + 51 + i * item_length) = data->look;
+ WFIFOW(fd, offset + 51 + i * item_length) = data->view_sprite;
#endif
}
WFIFOSET(fd,WFIFOW(fd,2));
@@ -9449,8 +9474,8 @@ void clif_parse_LoadEndAck(int fd, struct map_session_data *sd) {
// Character Looks
#if PACKETVER < 4
- clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
- clif->changelook(&sd->bl,LOOK_SHIELD,sd->status.shield);
+ clif->changelook(&sd->bl, LOOK_WEAPON, sd->status.look.weapon);
+ clif->changelook(&sd->bl, LOOK_SHIELD, sd->status.look.shield);
#else
clif->changelook(&sd->bl,LOOK_WEAPON,0);
#endif
@@ -14025,7 +14050,7 @@ void clif_parse_NoviceExplosionSpirits(int fd, struct map_session_data *sd)
/* it sends the request when the criteria doesn't match (and of course we let it fail) */
/* so restoring the old parse_globalmes method. */
if ((sd->job & MAPID_UPPERMASK) == MAPID_SUPER_NOVICE) {
- unsigned int next = pc->nextbaseexp(sd);
+ uint64 next = pc->nextbaseexp(sd);
if( next == 0 ) next = pc->thisbaseexp(sd);
if( next ) {
int percent = (int)( ( (float)sd->status.base_exp/(float)next )*1000. );
@@ -16695,20 +16720,34 @@ void clif_party_show_picker(struct map_session_data * sd, struct item * item_dat
/// exp type:
/// 0 = normal exp gain/loss
/// 1 = quest exp gain/loss
-void clif_displayexp(struct map_session_data *sd, unsigned int exp, char type, bool is_quest) {
+void clif_displayexp(struct map_session_data *sd, uint64 exp, char type, bool is_quest)
+{
int fd;
+// [4144] unconfirment exact version can be from 20170405 to 20170913
+#if PACKETVER >= 20170830
+ const int cmd = 0xacc;
+#else
+ const int cmd = 0x7f6;
+#endif
nullpo_retv(sd);
fd = sd->fd;
- WFIFOHEAD(fd, packet_len(0x7f6));
- WFIFOW(fd,0) = 0x7f6;
- WFIFOL(fd,2) = sd->bl.id;
- WFIFOL(fd,6) = exp;
- WFIFOW(fd,10) = type;
- WFIFOW(fd,12) = is_quest?1:0;// Normal exp is shown in yellow, quest exp is shown in purple.
- WFIFOSET(fd,packet_len(0x7f6));
+ WFIFOHEAD(fd, packet_len(cmd));
+ WFIFOW(fd, 0) = cmd;
+ WFIFOL(fd, 2) = sd->bl.id;
+// [4144] unconfirment exact version can be from 20170405 to 20170913
+#if PACKETVER >= 20170830
+ WFIFOQ(fd, 6) = exp;
+ WFIFOW(fd, 14) = type;
+ WFIFOW(fd, 16) = is_quest ? 1 : 0; // Normal exp is shown in yellow, quest exp is shown in purple.
+#else
+ WFIFOL(fd, 6) = (uint32)exp;
+ WFIFOW(fd, 10) = type;
+ WFIFOW(fd, 12) = is_quest ? 1 : 0; // Normal exp is shown in yellow, quest exp is shown in purple.
+#endif
+ WFIFOSET(fd, packet_len(cmd));
}
/// Displays digital clock digits on top of the screen (ZC_SHOWDIGIT).
@@ -19344,7 +19383,7 @@ void clif_parse_rodex_checkname(int fd, struct map_session_data *sd)
int char_id = 0, base_level = 0;
short class = 0;
char name[NAME_LENGTH];
-
+
safestrncpy(name, rPacket->Name, NAME_LENGTH);
rodex->check_player(sd, name, &base_level, &char_id, &class);
@@ -19431,8 +19470,9 @@ void clif_rodex_send_maillist(int fd, struct map_session_data *sd, int8 open_typ
WFIFOHEAD(fd, sizeof(*packet) + (sizeof(*inner) + RODEX_TITLE_LENGTH) * RODEX_MAIL_PER_PAGE);
packet = WFIFOP(fd, 0);
packet->PacketType = ((page_start == (VECTOR_LENGTH(sd->rodex.messages) - 1)) ? rodexmailList : rodexnextpage);
+#if PACKETVER < 20170419
packet->opentype = open_type;
-
+#endif
inner = WFIFOP(fd, size);
while (page_start >= 0 && count < RODEX_MAIL_PER_PAGE) {
@@ -19445,7 +19485,11 @@ void clif_rodex_send_maillist(int fd, struct map_session_data *sd, int8 open_typ
inner->MailID = msg->id;
inner->Isread = msg->is_read == true ? 1 : 0;
inner->type = msg->type;
+#if PACKETVER >= 20170419
+ inner->openType = msg->opentype;
+#else
inner->regDateTime = (int)time(NULL) - msg->send_date;
+#endif
inner->expireDateTime = msg->expire_date - (int)time(NULL);
if (open_type == RODEX_OPENTYPE_RETURN) {
inner->expireDateTime += RODEX_EXPIRE;
@@ -19463,12 +19507,80 @@ void clif_rodex_send_maillist(int fd, struct map_session_data *sd, int8 open_typ
}
packet->PacketLength = size;
+#if PACKETVER < 20170419
packet->cnt = count;
+#endif
packet->IsEnd = page_start > 0 ? 0 : 1;
WFIFOSET(fd, size);
#endif
}
+void clif_rodex_send_mails_all(int fd, struct map_session_data *sd)
+{
+#if PACKETVER >= 20170419
+ struct PACKET_ZC_MAIL_LIST *packet;
+ struct maillistinfo *inner;
+ int16 size = sizeof(*packet);
+ int packetMailCount = 0;
+ int mailListCount = 0;
+ int mailsSize = VECTOR_LENGTH(sd->rodex.messages);
+ int i;
+
+ nullpo_retv(sd);
+
+ WFIFOHEAD(fd, sizeof(*packet) + (sizeof(*inner) + RODEX_TITLE_LENGTH) * RODEX_MAIL_PER_PAGE);
+ packet = WFIFOP(fd, 0);
+ packet->PacketType = rodexmailList;
+ inner = WFIFOP(fd, size);
+
+ i = mailsSize - 1;
+ while (i >= 0) {
+ struct rodex_message *msg = &VECTOR_INDEX(sd->rodex.messages, i);
+ --i;
+
+ if (msg->is_deleted)
+ continue;
+
+ inner->MailID = msg->id;
+ inner->Isread = msg->is_read == true ? 1 : 0;
+ inner->type = msg->type;
+ inner->openType = msg->opentype;
+ inner->expireDateTime = msg->expire_date - (int)time(NULL);
+ if (msg->opentype == RODEX_OPENTYPE_RETURN) {
+ inner->expireDateTime += RODEX_EXPIRE;
+ }
+ inner->Titlelength = (int16)strlen(msg->title) + 1;
+ if (msg->opentype != RODEX_OPENTYPE_RETURN) {
+ strncpy(inner->SenderName, msg->sender_name, sizeof(msg->sender_name));
+ } else {
+ strncpy(inner->SenderName, msg->receiver_name, sizeof(msg->receiver_name));
+ }
+ strncpy(inner->title, msg->title, inner->Titlelength);
+ size += sizeof(*inner) + inner->Titlelength;
+ inner = WFIFOP(fd, size);
+ packetMailCount ++;
+ mailListCount ++;
+ if (packetMailCount == RODEX_MAIL_PER_PAGE) {
+ packet->PacketLength = size;
+ packet->IsEnd = mailListCount > mailsSize ? 1 : 0;
+ WFIFOSET(fd, size);
+ WFIFOHEAD(fd, sizeof(*packet) + (sizeof(*inner) + RODEX_TITLE_LENGTH) * RODEX_MAIL_PER_PAGE);
+ packet = WFIFOP(fd, 0);
+ packet->PacketType = rodexmailList;
+ size = sizeof(*packet);
+ inner = WFIFOP(fd, size);
+ packetMailCount = 0;
+ }
+ }
+
+ if (packetMailCount > 0 || mailListCount == 0) {
+ packet->PacketLength = size;
+ packet->IsEnd = 1;
+ WFIFOSET(fd, size);
+ }
+#endif
+}
+
void clif_rodex_send_refresh(int fd, struct map_session_data *sd, int8 open_type, int count)
{
#if PACKETVER >= 20131218
@@ -19482,8 +19594,9 @@ void clif_rodex_send_refresh(int fd, struct map_session_data *sd, int8 open_type
WFIFOHEAD(fd, sizeof(*packet) + (sizeof(*inner) + RODEX_TITLE_LENGTH) * RODEX_MAIL_PER_PAGE);
packet = WFIFOP(fd, 0);
packet->PacketType = rodexmailList;
+#if PACKETVER < 20170419
packet->opentype = open_type;
-
+#endif
inner = WFIFOP(fd, size);
i = VECTOR_LENGTH(sd->rodex.messages) - 1;
@@ -19498,7 +19611,11 @@ void clif_rodex_send_refresh(int fd, struct map_session_data *sd, int8 open_type
inner->MailID = msg->id;
inner->Isread = msg->is_read == true ? 1 : 0;
inner->type = msg->type;
+#if PACKETVER >= 20170419
+ inner->openType = msg->opentype;
+#else
inner->regDateTime = (int)time(NULL) - msg->send_date;
+#endif
inner->expireDateTime = msg->expire_date - (int)time(NULL);
if (open_type == RODEX_OPENTYPE_RETURN) {
inner->expireDateTime += RODEX_EXPIRE;
@@ -19516,7 +19633,9 @@ void clif_rodex_send_refresh(int fd, struct map_session_data *sd, int8 open_type
}
packet->PacketLength = size;
+#if PACKETVER < 20170419
packet->cnt = count;
+#endif
packet->IsEnd = 1;
WFIFOSET(fd, size);
#endif
@@ -19547,7 +19666,7 @@ void clif_rodex_read_mail(struct map_session_data *sd, int8 opentype, struct rod
nullpo_retv(sd);
nullpo_retv(msg);
-
+
fd = sd->fd;
body_len = (int)strlen(msg->body) + 1;
size = sizeof(*sPacket);
@@ -19624,7 +19743,7 @@ void clif_parse_rodex_request_zeny(int fd, struct map_session_data *sd) __attrib
void clif_parse_rodex_request_zeny(int fd, struct map_session_data *sd)
{
const struct PACKET_CZ_REQ_ZENY_FROM_MAIL *rPacket = RFIFOP(fd, 0);
-
+
rodex->get_zeny(sd, rPacket->opentype, rPacket->MailID);
}
@@ -19665,7 +19784,7 @@ void clif_rodex_request_items(struct map_session_data *sd, int8 opentype, int64
nullpo_retv(sd);
fd = sd->fd;
-
+
WFIFOHEAD(fd, sizeof(*sPacket));
sPacket = WFIFOP(fd, 0);
sPacket->PacketType = rodexgetitem;
@@ -19679,7 +19798,7 @@ void clif_rodex_request_items(struct map_session_data *sd, int8 opentype, int64
void clif_rodex_icon(int fd, bool show)
{
// packet add date is 20140716, but from players reports it wrong. Using closer known correct version.
-#if PACKETVER >= 20150513
+#if PACKETVER >= 20141112
WFIFOHEAD(fd, 3);
WFIFOW(fd, 0) = rodexicon;
WFIFOB(fd, 2) = (show == true ? 1 : 0);
@@ -19691,14 +19810,22 @@ void clif_parse_rodex_refresh_maillist(int fd, struct map_session_data *sd) __at
void clif_parse_rodex_refresh_maillist(int fd, struct map_session_data *sd)
{
const struct PACKET_CZ_REQ_REFRESH_MAIL_LIST *packet = RFIFOP(fd, 0);
+#if PACKETVER >= 20170419
+ rodex->refresh(sd, RODEX_OPENTYPE_UNSET, packet->Upper_MailID);
+#else
rodex->refresh(sd, packet->opentype, packet->Upper_MailID);
+#endif
}
void clif_parse_rodex_open_mailbox(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
void clif_parse_rodex_open_mailbox(int fd, struct map_session_data *sd)
{
const struct PACKET_CZ_REQ_OPEN_MAIL *packet = RFIFOP(fd, 0);
- rodex->open(sd, packet->opentype);
+#if PACKETVER >= 20170419
+ rodex->open(sd, RODEX_OPENTYPE_UNSET, packet->Upper_MailID);
+#else
+ rodex->open(sd, packet->opentype, packet->Upper_MailID);
+#endif
rodex->clean(sd, 1);
}
@@ -19926,9 +20053,10 @@ void packetdb_loaddb(void) {
memset(packet_db,0,sizeof(packet_db));
#define packet(id, size, ...) packetdb_addpacket((id), (size), ##__VA_ARGS__, 0xFFFF)
-#define packetKeys(a,b,c) do { clif->cryptKey[0] = (a); clif->cryptKey[1] = (b); clif->cryptKey[2] = (c); } while(0)
#include "packets.h" /* load structure data */
#undef packet
+#define packetKeys(a,b,c) do { clif->cryptKey[0] = (a); clif->cryptKey[1] = (b); clif->cryptKey[2] = (c); } while(0)
+#include "packets_keys.h"
#undef packetKeys
}
void clif_bc_ready(void) {
@@ -20782,4 +20910,5 @@ void clif_defaults(void) {
clif->pRodexRequestItems = clif_parse_rodex_request_items;
clif->rodex_request_items = clif_rodex_request_items;
clif->rodex_icon = clif_rodex_icon;
+ clif->rodex_send_mails_all = clif_rodex_send_mails_all;
}