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.c224
1 files changed, 184 insertions, 40 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index de0f0573f..4dc36be6d 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -293,7 +293,11 @@ unsigned char clif_bl_type(struct block_list *bl)
case BL_NPC:
vd = status->get_viewdata(bl);
nullpo_retr(CLUT_NPC, vd);
+#if PACKETVER >= 20170726
+ return CLUT_EVENT;
+#else
return pc->db_checkid(vd->class) ? CLUT_PC : CLUT_EVENT;
+#endif
case BL_PET:
vd = status->get_viewdata(bl);
nullpo_retr(CLUT_NPC, vd);
@@ -1067,14 +1071,17 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu
#endif
#if PACKETVER >= 20120221
if (battle_config.show_monster_hp_bar && bl->type == BL_MOB && status_get_hp(bl) < status_get_max_hp(bl)) {
- const struct mob_data *md = BL_UCCAST(BL_MOB, bl);
p.maxHP = status_get_max_hp(bl);
p.HP = status_get_hp(bl);
- p.isBoss = (md->spawn != NULL && md->spawn->state.boss) ? 1 : 0;
} else {
p.maxHP = -1;
p.HP = -1;
- p.isBoss = 0;
+ }
+ if (bl->type == BL_MOB) {
+ const struct mob_data *md = BL_UCCAST(BL_MOB, bl);
+ p.isBoss = (md->spawn != NULL) ? md->spawn->state.boss : BTYPE_NONE;
+ } else {
+ p.isBoss = BTYPE_NONE;
}
#endif
#if PACKETVER >= 20150513
@@ -1216,14 +1223,17 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) {
#endif
#if PACKETVER >= 20120221
if (battle_config.show_monster_hp_bar && bl->type == BL_MOB && status_get_hp(bl) < status_get_max_hp(bl)) {
- const struct mob_data *md = BL_UCCAST(BL_MOB, bl);
p.maxHP = status_get_max_hp(bl);
p.HP = status_get_hp(bl);
- p.isBoss = (md->spawn != NULL && md->spawn->state.boss) ? 1 : 0;
} else {
p.maxHP = -1;
p.HP = -1;
- p.isBoss = 0;
+ }
+ if (bl->type == BL_MOB) {
+ const struct mob_data *md = BL_UCCAST(BL_MOB, bl);
+ p.isBoss = (md->spawn != NULL) ? md->spawn->state.boss : BTYPE_NONE;
+ } else {
+ p.isBoss = BTYPE_NONE;
}
#endif
#if PACKETVER >= 20150513
@@ -1315,14 +1325,17 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd,
#endif
#if PACKETVER >= 20120221
if (battle_config.show_monster_hp_bar && bl->type == BL_MOB && status_get_hp(bl) < status_get_max_hp(bl)) {
- const struct mob_data *md = BL_UCCAST(BL_MOB, bl);
p.maxHP = status_get_max_hp(bl);
p.HP = status_get_hp(bl);
- p.isBoss = (md->spawn != NULL && md->spawn->state.boss) ? 1 : 0;
} else {
p.maxHP = -1;
p.HP = -1;
- p.isBoss = 0;
+ }
+ if (bl->type == BL_MOB) {
+ const struct mob_data *md = BL_UCCAST(BL_MOB, bl);
+ p.isBoss = (md->spawn != NULL) ? md->spawn->state.boss : BTYPE_NONE;
+ } else {
+ p.isBoss = BTYPE_NONE;
}
#endif
#if PACKETVER >= 20150513
@@ -3033,27 +3046,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)=(uint32)(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)=(uint32)(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
**/
@@ -3309,17 +3345,22 @@ void clif_changelook(struct block_list *bl,int type,int val)
#if PACKETVER < 4
clif->sendlook(bl, bl->id, type, val, 0, target);
#else
- if(type == LOOK_WEAPON || type == LOOK_SHIELD) {
- nullpo_retv(vd);
- type = LOOK_WEAPON;
- val = vd->weapon;
- val2 = vd->shield;
- }
- if (clif->isdisguised(bl)) {
- clif->sendlook(bl, bl->id, type, val, val2, AREA_WOS);
- clif->sendlook(bl, -bl->id, type, val, val2, SELF);
+ if (bl->type != BL_NPC) {
+ if(type == LOOK_WEAPON || type == LOOK_SHIELD) {
+ nullpo_retv(vd);
+ type = LOOK_WEAPON;
+ val = vd->weapon;
+ val2 = vd->shield;
+ }
+ if (clif->isdisguised(bl)) {
+ clif->sendlook(bl, bl->id, type, val, val2, AREA_WOS);
+ clif->sendlook(bl, -bl->id, type, val, val2, SELF);
+ } else {
+ clif->sendlook(bl, bl->id, type, val, val2, target);
+ }
} else {
- clif->sendlook(bl, bl->id, type, val, val2, target);
+ struct npc_data *nd = BL_UCAST(BL_NPC, bl);
+ npc->refresh(nd);
}
#endif
}
@@ -14027,7 +14068,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. );
@@ -16697,20 +16738,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).
@@ -19433,8 +19488,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) {
@@ -19447,7 +19503,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;
@@ -19465,12 +19525,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
@@ -19484,8 +19612,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;
@@ -19500,7 +19629,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;
@@ -19518,7 +19651,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
@@ -19693,14 +19828,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);
}
@@ -20785,4 +20928,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;
}