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.c193
1 files changed, 163 insertions, 30 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 1c245ed43..33c003321 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -4789,9 +4789,9 @@ static void clif_getareachar_unit(struct map_session_data *sd, struct block_list
//Modifies the type of damage according to status changes [Skotlex]
//Aegis data specifies that: 4 endure against single hit sources, 9 against multi-hit.
-static inline int clif_calc_delay(int type, int div, int damage, int delay)
+static inline enum battle_dmg_type clif_calc_delay(enum battle_dmg_type type, int div, int damage, int delay)
{
- return ( delay == 0 && damage > 0 ) ? ( div > 1 ? 9 : 4 ) : type;
+ return ( delay == 0 && damage > 0 ) ? ( div > 1 ? BDT_MULTIENDURE : BDT_ENDURE ) : type;
}
/*==========================================
@@ -4822,7 +4822,7 @@ static int clif_calc_walkdelay(struct block_list *bl, int delay, int type, int d
/// 08c8 <src ID>.L <dst ID>.L <server tick>.L <src speed>.L <dst speed>.L <damage>.L <IsSPDamage>.B <div>.W <type>.B <damage2>.L (ZC_NOTIFY_ACT2)
/// type: @see enum battle_dmg_type
/// for BDT_NORMAL: [ damage: total damage, div: amount of hits, damage2: assassin dual-wield damage ]
-static int clif_damage(struct block_list *src, struct block_list *dst, int sdelay, int ddelay, int64 in_damage, short div, unsigned char type, int64 in_damage2)
+static int clif_damage(struct block_list *src, struct block_list *dst, int sdelay, int ddelay, int64 in_damage, short div, enum battle_dmg_type type, int64 in_damage2)
{
struct packet_damage p;
struct status_change *sc;
@@ -5268,7 +5268,7 @@ static void clif_playerSkillToPacket(struct map_session_data *sd, struct SKILLDA
skillData->sp = 0;
skillData->range2 = 0;
}
-#if PACKETVER_RE_NUM >= 20190807 || PACKETVER_ZERO_NUM >= 20190814
+#if PACKETVER_RE_NUM >= 20190807
if (newSkill)
skillData->level2 = 0;
else
@@ -5419,7 +5419,7 @@ static void clif_skillinfo(struct map_session_data *sd, int skill_id, int inf)
p->sp = 0;
p->range2 = 0;
}
-#if PACKETVER_RE_NUM >= 20190807 || PACKETVER_ZERO_NUM >= 20190814
+#if PACKETVER_RE_NUM >= 20190807
p->level2 = skill_lv;
#endif
if (sd->status.skill[idx].flag == SKILL_FLAG_PERMANENT)
@@ -5573,7 +5573,7 @@ static void clif_skill_cooldown(struct map_session_data *sd, uint16 skill_id, un
/// Skill attack effect and damage.
/// 0114 <skill id>.W <src id>.L <dst id>.L <tick>.L <src delay>.L <dst delay>.L <damage>.W <level>.W <div>.W <type>.B (ZC_NOTIFY_SKILL)
/// 01de <skill id>.W <src id>.L <dst id>.L <tick>.L <src delay>.L <dst delay>.L <damage>.L <level>.W <div>.W <type>.B (ZC_NOTIFY_SKILL2)
-static int clif_skill_damage(struct block_list *src, struct block_list *dst, int64 tick, int sdelay, int ddelay, int64 in_damage, int div, uint16 skill_id, uint16 skill_lv, int type)
+static int clif_skill_damage(struct block_list *src, struct block_list *dst, int64 tick, int sdelay, int ddelay, int64 in_damage, int div, uint16 skill_id, uint16 skill_lv, enum battle_dmg_type type)
{
unsigned char buf[64];
struct status_change *sc;
@@ -5675,7 +5675,7 @@ static int clif_skill_damage(struct block_list *src, struct block_list *dst, int
/// Ground skill attack effect and damage (ZC_NOTIFY_SKILL_POSITION).
/// 0115 <skill id>.W <src id>.L <dst id>.L <tick>.L <src delay>.L <dst delay>.L <x>.W <y>.W <damage>.W <level>.W <div>.W <type>.B
#if 0
-static int clif_skill_damage2(struct block_list *src, struct block_list *dst, int64 tick, int sdelay, int ddelay, int damage, int div, uint16 skill_id, uint16 skill_lv, int type)
+static int clif_skill_damage2(struct block_list *src, struct block_list *dst, int64 tick, int sdelay, int ddelay, int damage, int div, uint16 skill_id, uint16 skill_lv, enum battle_dmg_type type)
{
unsigned char buf[64];
struct status_change *sc;
@@ -8106,6 +8106,54 @@ static void clif_guild_allianceinfo(struct map_session_data *sd)
WFIFOSET(fd,WFIFOW(fd,2));
}
+static void clif_guild_castlelist(struct map_session_data *sd)
+{
+#if PACKETVER_MAIN_NUM >= 20190731 || PACKETVER_RE_NUM >= 20190717 || PACKETVER_ZERO_NUM >= 20190814
+ nullpo_retv(sd);
+
+ struct guild *g = sd->guild;
+ if (g == NULL)
+ return;
+
+ int castle_count = guild->checkcastles(g);
+ if (castle_count > 0) {
+ int len = sizeof(struct PACKET_ZC_GUILD_CASTLE_LIST) + castle_count;
+ struct PACKET_ZC_GUILD_CASTLE_LIST *p = aMalloc(len);
+ p->packetType = HEADER_ZC_GUILD_CASTLE_LIST;
+ p->packetLength = len;
+
+ int i = 0;
+ struct DBIterator *iter = db_iterator(guild->castle_db);
+ for (struct guild_castle *gc = dbi_first(iter); dbi_exists(iter); gc = dbi_next(iter)) {
+ if (gc->guild_id == g->guild_id) {
+ p->castle_list[i] = gc->castle_id;
+ ++i;
+ }
+ }
+ dbi_destroy(iter);
+
+ clif->send(p, len, &sd->bl, SELF);
+ aFree(p);
+ }
+#endif
+}
+
+static void clif_guild_castleinfo(struct map_session_data *sd, struct guild_castle *gc)
+{
+#if PACKETVER_MAIN_NUM >= 20190731 || PACKETVER_RE_NUM >= 20190717 || PACKETVER_ZERO_NUM >= 20190814
+
+ nullpo_retv(sd);
+ nullpo_retv(gc);
+
+ struct PACKET_ZC_CASTLE_INFO p = { 0 };
+ p.packetType = HEADER_ZC_CASTLE_INFO;
+ p.castle_id = gc->castle_id;
+ p.economy = gc->economy;
+ p.defense = gc->defense;
+ clif->send(&p, sizeof(p), &sd->bl, SELF);
+#endif
+}
+
/// Guild member manager information (ZC_MEMBERMGR_INFO).
/// 0154 <packet len>.W { <account>.L <char id>.L <hair style>.W <hair color>.W <gender>.W <class>.W <level>.W <contrib exp>.L <state>.L <position>.L <memo>.50B <name>.24B }*
/// state:
@@ -8689,14 +8737,14 @@ static void clif_emotion(struct block_list *bl, int type)
/// 0191 <id>.L <contents>.80B
static void clif_talkiebox(struct block_list *bl, const char *talkie)
{
- unsigned char buf[MESSAGE_SIZE+6];
nullpo_retv(bl);
nullpo_retv(talkie);
+ struct PACKET_ZC_TALKBOX_CHATCONTENTS p;
- WBUFW(buf,0) = 0x191;
- WBUFL(buf,2) = bl->id;
- safestrncpy(WBUFP(buf,6),talkie,MESSAGE_SIZE);
- clif->send(buf,packet_len(0x191),bl,AREA);
+ p.PacketType = HEADER_ZC_TALKBOX_CHATCONTENTS;
+ p.aid = bl->id;
+ safestrncpy(&p.message[0], talkie, TALKBOX_MESSAGE_SIZE);
+ clif->send(&p, sizeof(struct PACKET_ZC_TALKBOX_CHATCONTENTS), bl, AREA);
}
/// Displays wedding effect centered on an object (ZC_CONGRATULATION).
@@ -9298,9 +9346,6 @@ static void clif_pcname_ack(int fd, struct block_list *bl)
packet.gid = bl->id;
const struct map_session_data *ssd = BL_UCCAST(BL_PC, bl);
- const struct party_data *p = NULL;
- const struct guild *g = NULL;
- int ps = -1;
if (ssd->fakename[0] != '\0' && ssd->disguise != -1) {
packet.packet_id = reqName;
@@ -9326,9 +9371,12 @@ static void clif_pcname_ack(int fd, struct block_list *bl)
#endif
memcpy(packet.name, ssd->status.name, NAME_LENGTH);
+ const struct party_data *p = NULL;
+ int ps = -1;
if (ssd->status.party_id != 0) {
p = party->search(ssd->status.party_id);
}
+ const struct guild *g = NULL;
if (ssd->status.guild_id != 0) {
if ((g = ssd->guild) != NULL) {
int i;
@@ -9351,6 +9399,12 @@ static void clif_pcname_ack(int fd, struct block_list *bl)
memcpy(packet.guild_name, g->name,NAME_LENGTH);
memcpy(packet.position_name, g->position[ps].name, NAME_LENGTH);
}
+ else if (ssd->status.clan_id != 0) {
+ struct clan *c = clan->search(ssd->status.clan_id);
+ if (c != 0) {
+ memcpy(packet.position_name, c->name, NAME_LENGTH);
+ }
+ }
}
clif->send_selforarea(fd, bl, &packet, len);
@@ -12687,7 +12741,7 @@ static void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uin
return;
}
//You can't use Graffiti/TalkieBox AND have a vending open, so this is safe.
- safestrncpy(sd->message, RFIFOP(fd,skillmoreinfo), MESSAGE_SIZE);
+ safestrncpy(sd->message, RFIFOP(fd, skillmoreinfo), TALKBOX_MESSAGE_SIZE);
}
if( sd->ud.skilltimer != INVALID_TIMER )
@@ -14401,6 +14455,7 @@ static void clif_parse_GuildRequestInfo(int fd, struct map_session_data *sd)
case 0: // Basic Information Guild, hostile alliance information
clif->guild_basicinfo(sd);
clif->guild_allianceinfo(sd);
+ clif->guild_castlelist(sd);
break;
case 1: // Members list, list job title
clif->guild_positionnamelist(sd);
@@ -15978,18 +16033,18 @@ static void clif_ranklist_sub(struct PACKET_ZC_ACK_RANKING_sub *ranks, enum fame
if (list[i].id > 0) {
const char* name;
if (strcmp(list[i].name, "-") == 0 && (name = map->charid2nick(list[i].id)) != NULL) {
- strncpy(ranks[i].name, name, NAME_LENGTH);
+ strncpy(ranks->names[i].name, name, NAME_LENGTH);
} else {
- strncpy(ranks[i].name, list[i].name, NAME_LENGTH);
+ strncpy(ranks->names[i].name, list[i].name, NAME_LENGTH);
}
} else {
- strncpy(ranks[i].name, "None", 5);
+ strncpy(ranks->names[i].name, "None", 5);
}
- ranks[i].points = list[i].fame; //points
+ ranks->points[i].points = list[i].fame; //points
}
for (;i < 10; i++) { // In case the MAX is less than 10.
- strncpy(ranks[i].name, "Unavailable", 12);
- ranks[i].points = 0;
+ strncpy(ranks->names[i].name, "Unavailable", 12);
+ ranks->points[i].points = 0;
}
#endif
}
@@ -16038,7 +16093,7 @@ static void clif_ranklist(struct map_session_data *sd, enum fame_list_type type)
#if PACKETVER_MAIN_NUM >= 20190731 || PACKETVER_RE_NUM >= 20190703 || PACKETVER_ZERO_NUM >= 20190724
clif->ranklist_sub2(p->chars, p->points, type);
#else
- clif->ranklist_sub(p->ranks, type);
+ clif->ranklist_sub(&p->ranks, type);
#endif
if (pc->famelist_type(sd->job) == type) {
@@ -16398,10 +16453,14 @@ static void clif_parse_AutoRevive(int fd, struct map_session_data *sd)
{
if (pc_istrading(sd) || pc_isvending(sd))
return;
+
if (!pc_isdead(sd))
return;
- int item_position = pc->search_inventory(sd, ITEMID_TOKEN_OF_SIEGFRIED);
+ if (sd->sc.data[SC_HELLPOWER]) //Cannot res while under the effect of SC_HELLPOWER.
+ return;
+
+ int item_position = pc->have_item_chain(sd, ECC_SIEGFRIED);
int hpsp = 100;
if (item_position == INDEX_NOT_FOUND) {
@@ -16411,18 +16470,15 @@ static void clif_parse_AutoRevive(int fd, struct map_session_data *sd)
return;
}
- if (sd->sc.data[SC_HELLPOWER]) //Cannot res while under the effect of SC_HELLPOWER.
- return;
-
if (!status->revive(&sd->bl, hpsp, hpsp))
return;
if (item_position == INDEX_NOT_FOUND)
- status_change_end(&sd->bl,SC_LIGHT_OF_REGENE,INVALID_TIMER);
+ status_change_end(&sd->bl, SC_LIGHT_OF_REGENE, INVALID_TIMER);
else
pc->delitem(sd, item_position, 1, 0, DELITEM_SKILLUSE, LOG_TYPE_CONSUME);
- clif->skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION, 4, 1);
+ clif->skill_nodamage(&sd->bl, &sd->bl, ALL_RESURRECTION, 4, 1);
}
/// Information about character's status values (ZC_ACK_STATUS_GM).
@@ -20608,7 +20664,7 @@ static int clif_delay_damage_sub(int tid, int64 tick, int id, intptr_t data)
*
* @return clif->calc_walkdelay used in further processing
**/
-static int clif_delay_damage(int64 tick, struct block_list *src, struct block_list *dst, int sdelay, int ddelay, int64 in_damage, short div, unsigned char type)
+static int clif_delay_damage(int64 tick, struct block_list *src, struct block_list *dst, int sdelay, int ddelay, int64 in_damage, short div, enum battle_dmg_type type)
{
struct cdelayed_damage *dd;
struct status_change *sc;
@@ -23204,6 +23260,78 @@ static void clif_announce_refine_status(struct map_session_data *sd, int item_id
#endif
}
+static void clif_parse_GuildCastleTeleportRequest(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
+static void clif_parse_GuildCastleTeleportRequest(int fd, struct map_session_data *sd)
+{
+#if PACKETVER_MAIN_NUM >= 20190522 || PACKETVER_RE_NUM >= 20190522 || PACKETVER_ZERO_NUM >= 20190515
+ const struct PACKET_CZ_CASTLE_TELEPORT_REQUEST *p = RFIFO2PTR(fd);
+ struct guild *g = sd->guild;
+
+ if (g == NULL)
+ return;
+
+ struct guild_castle *gc = guild->castle_search(p->castle_id);
+ if (gc == NULL)
+ return;
+ if (gc->enable_client_warp == false)
+ return;
+ if (gc->guild_id != g->guild_id)
+ return;
+
+ if (map->list[sd->bl.m].flag.gvg_castle == 1)
+ return;
+
+ int zeny = gc->client_warp.zeny;
+ if (gc->siege_type == SIEGE_TYPE_FE && map->agit_flag == 1) {
+ zeny = gc->client_warp.zeny_siege;
+ } else if (gc->siege_type == SIEGE_TYPE_SE && map->agit2_flag == 1) {
+ zeny = gc->client_warp.zeny_siege;
+ } else if (gc->siege_type == SIEGE_TYPE_TE) {
+ clif->guild_castleteleport_res(sd, SIEGE_TP_INVALID_MODE);
+ return;
+ }
+
+ if (sd->status.zeny < zeny) {
+ clif->guild_castleteleport_res(sd, SIEGE_TP_NOT_ENOUGH_ZENY);
+ return;
+ }
+ sd->status.zeny -= zeny;
+ clif->updatestatus(sd, SP_ZENY);
+ pc->setpos(sd, gc->mapindex, gc->client_warp.x, gc->client_warp.y, CLR_OUTSIGHT);
+#endif
+}
+
+static void clif_guild_castleteleport_res(struct map_session_data *sd, enum siege_teleport_result result)
+{
+#if PACKETVER_MAIN_NUM >= 20190731 || PACKETVER_RE_NUM >= 20190717 || PACKETVER_ZERO_NUM >= 20190814
+
+ nullpo_retv(sd);
+
+ struct PACKET_ZC_CASTLE_TELEPORT_RESPONSE p = { 0 };
+ p.packetType = HEADER_ZC_CASTLE_TELEPORT_RESPONSE;
+ p.result = (int16)result;
+ clif->send(&p, sizeof(p), &sd->bl, SELF);
+#endif
+}
+static void clif_parse_GuildCastleInfoRequest(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
+static void clif_parse_GuildCastleInfoRequest(int fd, struct map_session_data *sd)
+{
+#if PACKETVER_MAIN_NUM >= 20190522 || PACKETVER_RE_NUM >= 20190522 || PACKETVER_ZERO_NUM >= 20190515
+ const struct PACKET_CZ_CASTLE_INFO_REQUEST *p = RFIFO2PTR(fd);
+ struct guild *g = sd->guild;
+
+ if (g == NULL)
+ return;
+
+ struct guild_castle *gc = guild->castle_search(p->castle_id);
+ if (gc == NULL)
+ return;
+ if (gc->guild_id != g->guild_id)
+ return;
+ clif->guild_castleinfo(sd, gc);
+#endif
+}
+
/*==========================================
* Main client packet processing function
*------------------------------------------*/
@@ -23888,6 +24016,8 @@ void clif_defaults(void)
clif->guild_masterormember = clif_guild_masterormember;
clif->guild_basicinfo = clif_guild_basicinfo;
clif->guild_allianceinfo = clif_guild_allianceinfo;
+ clif->guild_castlelist = clif_guild_castlelist;
+ clif->guild_castleinfo = clif_guild_castleinfo;
clif->guild_memberlist = clif_guild_memberlist;
clif->guild_skillinfo = clif_guild_skillinfo;
clif->guild_send_onlineinfo = clif_guild_send_onlineinfo;
@@ -24429,4 +24559,7 @@ void clif_defaults(void)
clif->pRefineryUIClose = clif_parse_RefineryUIClose;
clif->pRefineryUIRefine = clif_parse_RefineryUIRefine;
clif->announce_refine_status = clif_announce_refine_status;
+ clif->pGuildCastleTeleportRequest = clif_parse_GuildCastleTeleportRequest;
+ clif->pGuildCastleInfoRequest = clif_parse_GuildCastleInfoRequest;
+ clif->guild_castleteleport_res = clif_guild_castleteleport_res;
}