Skip to content

Commit

Permalink
Map Property Adjustment.
Browse files Browse the repository at this point in the history
* Dropped clif_maptypeproperty2() and merged it with clif_map_property().
* Renamed packet_maptypeproperty2 to packet_maptypeproperty and added support for 0x99b(ZC_MAPPROPERTY_R2).
* clif_map_property_mapall() now redirects its clif_send() job to clif_map_property() which has dummy bl.
  • Loading branch information
MrKeiKun committed Jun 2, 2022
1 parent 9ae6ddb commit ec2ed1d
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 94 deletions.
12 changes: 3 additions & 9 deletions src/map/atcommand.c
Original file line number Diff line number Diff line change
Expand Up @@ -1605,10 +1605,9 @@ ACMD(pvpoff)
map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone);
map->list[sd->bl.m].flag.pvp = 0;

if (!battle_config.pk_mode) {
if (!battle_config.pk_mode)
clif->map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP);
}

map->foreachinmap(atcommand->pvpoff_sub,sd->bl.m, BL_PC);
map->foreachinmap(atcommand->stopattack,sd->bl.m, BL_CHAR, 0);
clif->message(fd, msg_fd(fd,31)); // PvP: Off.
Expand Down Expand Up @@ -1647,9 +1646,8 @@ ACMD(pvpon)
map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_PVP_NAME));
map->list[sd->bl.m].flag.pvp = 1;

if (!battle_config.pk_mode) {// display pvp circle and rank
if (!battle_config.pk_mode) { // display pvp circle and rank
clif->map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP);
map->foreachinmap(atcommand->pvpon_sub,sd->bl.m, BL_PC);
}

Expand All @@ -1672,7 +1670,6 @@ ACMD(gvgoff)
map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone);
map->list[sd->bl.m].flag.gvg = 0;
clif->map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP);
map->foreachinmap(atcommand->stopattack,sd->bl.m, BL_CHAR, 0);
clif->message(fd, msg_fd(fd,33)); // GvG: Off.

Expand All @@ -1692,7 +1689,6 @@ ACMD(gvgon)
map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_GVG_NAME));
map->list[sd->bl.m].flag.gvg = 1;
clif->map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP);
clif->message(fd, msg_fd(fd,34)); // GvG: On.

return true;
Expand All @@ -1711,7 +1707,6 @@ ACMD(cvcoff)
map->zone_change2(sd->bl.m, map->list[sd->bl.m].prev_zone);
map->list[sd->bl.m].flag.cvc = 0;
clif->map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
clif->maptypeproperty2(&sd->bl, ALL_SAMEMAP);
map->foreachinmap(atcommand->stopattack, sd->bl.m, BL_CHAR, 0);
clif->message(fd, msg_fd(fd, 137)); // CvC: Off.

Expand All @@ -1731,7 +1726,6 @@ ACMD(cvcon)
map->zone_change2(sd->bl.m, strdb_get(map->zone_db, MAP_ZONE_CVC_NAME));
map->list[sd->bl.m].flag.cvc = 1;
clif->map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
clif->maptypeproperty2(&sd->bl, ALL_SAMEMAP);
clif->message(fd, msg_fd(fd, 138)); // CvC: On.

return true;
Expand Down
88 changes: 37 additions & 51 deletions src/map/clif.c
Original file line number Diff line number Diff line change
Expand Up @@ -6595,19 +6595,36 @@ static void clif_resurrection(struct block_list *bl, int type)
}
}

/// Sets the map property (ZC_NOTIFY_MAPPROPERTY).
/// 0199 <type>.W
static void clif_map_property(struct map_session_data *sd, enum map_property property)
/**
* Sets the map property(ZC_NOTIFY_MAPPROPERTY).
* 0199 <type>.W (ZC_NOTIFY_MAPPROPERTY)
* 099b <type>.W <Flags>
**/
static void clif_map_property(struct block_list *bl, enum map_property property, enum send_target target)
{
int fd;
struct packet_maptypeproperty p;

nullpo_retv(sd);
nullpo_retv(bl);

fd=sd->fd;
WFIFOHEAD(fd,packet_len(0x199));
WFIFOW(fd,0)=0x199;
WFIFOW(fd,2)=property;
WFIFOSET(fd,packet_len(0x199));
p.PacketType = maptypeproperty;
p.property = property;

#if PACKETVER >= 20121010
p.flag.party = map->list[bl->m].flag.pvp ? 1 : 0; //PARTY
p.flag.guild = (map->list[bl->m].flag.battleground || map_flag_gvg(bl->m)) ? 1 : 0; // GUILD
p.flag.siege = (map->list[bl->m].flag.battleground || map_flag_gvg2(bl->m)) ? 1 : 0; // SIEGE
p.flag.mineffect = map_flag_gvg2(bl->m) ? 1 : 0; // USE_SIMPLE_EFFECT - Automatically enable /mineffect in guild arenas and castles.
p.flag.nolockon = 0; // DISABLE_LOCKON - TODO
p.flag.countpk = map->list[bl->m].flag.pvp ? 1 : 0; // COUNT_PK
p.flag.nopartyformation = map->list[bl->m].flag.partylock ? 1 : 0; // NO_PARTY_FORMATION
p.flag.bg = map->list[bl->m].flag.battleground ? 1 : 0; // BATTLEFIELD
p.flag.nocostume = (map->list[bl->m].flag.noviewid & EQP_COSTUME) ? 1 : 0; // DISABLE_COSTUMEITEM - Disables Costume Sprite
p.flag.usecart = 1; // USECART - TODO
p.flag.summonstarmiracle = 0; // SUNMOONSTAR_MIRACLE - TODO
p.flag.SpareBits = 0; // UNUSED
#endif

clif->send(&p, sizeof(p), bl, target);
}

/// Set the map type (ZC_NOTIFY_MAPPROPERTY2).
Expand Down Expand Up @@ -6664,15 +6681,13 @@ static void clif_pvpset(struct map_session_data *sd, int pvprank, int pvpnum, in
static void clif_map_property_mapall(int mapid, enum map_property property)
{
struct block_list bl;
unsigned char buf[16];

memset(&bl, 0, sizeof(bl));
bl.id = 0;
bl.type = BL_NUL;
bl.m = mapid;
WBUFW(buf,0)=0x199;
WBUFW(buf,2)=property;
clif->send(buf,packet_len(0x199),&bl,ALL_SAMEMAP);

clif->map_property(&bl, property, ALL_SAMEMAP);
}

/// Notifies the client about the result of a refine attempt (ZC_ACK_ITEMREFINING).
Expand Down Expand Up @@ -11228,18 +11243,17 @@ static void clif_parse_LoadEndAck(int fd, struct map_session_data *sd)
sd->pvp_won = 0;
sd->pvp_lost = 0;
}

clif->map_property(sd, MAPPROPERTY_FREEPVPZONE);
clif->map_property(&sd->bl, MAPPROPERTY_FREEPVPZONE, SELF);
} else if(sd->duel_group != 0) { // Set flag, if it's a duel. [LuzZza]
clif->map_property(sd, MAPPROPERTY_FREEPVPZONE);
clif->map_property(&sd->bl, MAPPROPERTY_FREEPVPZONE, SELF);
} else if (map->list[sd->bl.m].flag.gvg_dungeon != 0) {
clif->map_property(&sd->bl, MAPPROPERTY_FREEPVPZONE, SELF); //TODO: Figure out the real packet to send here.
} else if (map_flag_gvg2(sd->bl.m)) {
clif->map_property(&sd->bl, MAPPROPERTY_AGITZONE, SELF);
} else {
clif->map_property(&sd->bl, MAPPROPERTY_NOTHING, SELF);
}

if (map->list[sd->bl.m].flag.gvg_dungeon != 0)
clif->map_property(sd, MAPPROPERTY_FREEPVPZONE); //TODO: Figure out the real packet to send here.

if (map_flag_gvg2(sd->bl.m))
clif->map_property(sd, MAPPROPERTY_AGITZONE);

// Info about nearby objects. Must use map->foreachinarea(). (CIRCULAR_AREA interferes with map->foreachinrange().)
map->foreachinarea(clif->getareachar, sd->bl.m, sd->bl.x - AREA_SIZE, sd->bl.y - AREA_SIZE,
sd->bl.x + AREA_SIZE, sd->bl.y + AREA_SIZE, BL_ALL, sd);
Expand Down Expand Up @@ -11437,7 +11451,6 @@ static void clif_parse_LoadEndAck(int fd, struct map_session_data *sd)
}

mail->clear(sd);
clif->maptypeproperty2(&sd->bl, SELF);

if (sd->guild != NULL) {
// Init guild aura.
Expand Down Expand Up @@ -21166,32 +21179,6 @@ static void clif_parse_cashShopReqTab(int fd, struct map_session_data *sd)
#endif
}

/* [Ind/Hercules] */
static void clif_maptypeproperty2(struct block_list *bl, enum send_target t)
{
#if PACKETVER >= 20121010
struct packet_maptypeproperty2 p;
nullpo_retv(bl);

p.PacketType = maptypeproperty2Type;
p.type = 0x28;
p.flag.party = map->list[bl->m].flag.pvp ? 1 : 0; //PARTY
p.flag.guild = (map->list[bl->m].flag.battleground || map_flag_gvg(bl->m)) ? 1 : 0; // GUILD
p.flag.siege = (map->list[bl->m].flag.battleground || map_flag_gvg2(bl->m)) ? 1: 0; // SIEGE
p.flag.mineffect = map_flag_gvg2(bl->m) ? 1 : 0; // USE_SIMPLE_EFFECT - Automatically enable /mineffect in guild arenas and castles.
p.flag.nolockon = 0; // DISABLE_LOCKON - TODO
p.flag.countpk = map->list[bl->m].flag.pvp ? 1 : 0; // COUNT_PK
p.flag.nopartyformation = map->list[bl->m].flag.partylock ? 1 : 0; // NO_PARTY_FORMATION
p.flag.bg = map->list[bl->m].flag.battleground ? 1 : 0; // BATTLEFIELD
p.flag.nocostume = (map->list[bl->m].flag.noviewid & EQP_COSTUME) ? 1 : 0; // DISABLE_COSTUMEITEM - Disables Costume Sprite
p.flag.usecart = 1; // USECART - TODO
p.flag.summonstarmiracle = 0; // SUNMOONSTAR_MIRACLE - TODO
p.flag.SpareBits = 0; // UNUSED

clif->send(&p,sizeof(p),bl,t);
#endif
}

static void clif_status_change2(struct block_list *bl, int tid, enum send_target target, int type, int val1, int val2, int val3)
{
struct packet_status_change2 p;
Expand Down Expand Up @@ -25854,7 +25841,6 @@ void clif_defaults(void)
clif->map_property_mapall = clif_map_property_mapall;
clif->bossmapinfo = clif_bossmapinfo;
clif->map_type = clif_map_type;
clif->maptypeproperty2 = clif_maptypeproperty2;
clif->crimson_marker = clif_crimson_marker;
/* multi-map-server */
clif->changemapserver = clif_changemapserver;
Expand Down
3 changes: 1 addition & 2 deletions src/map/clif.h
Original file line number Diff line number Diff line change
Expand Up @@ -1015,12 +1015,11 @@ struct clif_interface {
void (*changemap) (struct map_session_data *sd, short m, int x, int y);
void (*changemap_airship) (struct map_session_data *sd, short m, int x, int y);
void (*changemapcell) (int fd, int16 m, int x, int y, int type, enum send_target target);
void (*map_property) (struct map_session_data* sd, enum map_property property);
void (*map_property) (struct block_list *bl, enum map_property property, enum send_target target);
void (*pvpset) (struct map_session_data *sd, int pvprank, int pvpnum,int type);
void (*map_property_mapall) (int mapid, enum map_property property);
void (*bossmapinfo) (int fd, struct mob_data *md, enum bossmap_info_type flag);
void (*map_type) (struct map_session_data* sd, enum map_type type);
void (*maptypeproperty2) (struct block_list *bl,enum send_target t);
void (*crimson_marker) (struct map_session_data *sd, struct block_list *bl, bool remove);
/* multi-map-server */
void (*changemapserver) (struct map_session_data* sd, unsigned short map_index, int x, int y, uint32 ip, uint16 port, char *dnsHost);
Expand Down
10 changes: 4 additions & 6 deletions src/map/duel.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ static int duel_create(struct map_session_data *sd, const unsigned int maxpl)
safestrncpy(output, msg_sd(sd,372), sizeof(output)); // " -- Duel has been created (@invite/@leave) --"
clif_disp_onlyself(sd, output);

clif->map_property(sd, MAPPROPERTY_FREEPVPZONE);
clif->maptypeproperty2(&sd->bl,SELF);
clif->map_property(&sd->bl, MAPPROPERTY_FREEPVPZONE, SELF);
return i;
}

Expand Down Expand Up @@ -153,8 +152,8 @@ static void duel_leave(const unsigned int did, struct map_session_data *sd)

sd->duel_group = 0;
duel_savetime(sd);
clif->map_property(sd, MAPPROPERTY_NOTHING);
clif->maptypeproperty2(&sd->bl,SELF);
clif->map_property(&sd->bl, MAPPROPERTY_NOTHING, SELF);

}

static void duel_accept(const unsigned int did, struct map_session_data *sd)
Expand All @@ -171,8 +170,7 @@ static void duel_accept(const unsigned int did, struct map_session_data *sd)
sprintf(output, msg_sd(sd,376), sd->status.name);
clif->disp_message(&sd->bl, output, DUEL_WOS);

clif->map_property(sd, MAPPROPERTY_FREEPVPZONE);
clif->maptypeproperty2(&sd->bl,SELF);
clif->map_property(&sd->bl, MAPPROPERTY_FREEPVPZONE, SELF);
}

static void duel_reject(const unsigned int did, struct map_session_data *sd)
Expand Down
12 changes: 9 additions & 3 deletions src/map/packets_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,11 @@ enum packet_headers {
#endif
notifybindonequip = 0x2d3,
monsterhpType = 0x977,
maptypeproperty2Type = 0x99b,
#if PACKETVER >= 20121010
maptypeproperty = 0x99b, // ZC_MAPPROPERTY_R2 [KeiKun]
#else
maptypeproperty = 0x199,
#endif
#if PACKETVER >= 20131223 // version probably can be 20131030 [4144]
wisendType = 0x9df,
#else
Expand Down Expand Up @@ -964,9 +968,10 @@ struct packet_status_change2 {
int32 val3;
} __attribute__((packed));

struct packet_maptypeproperty2 {
struct packet_maptypeproperty {
int16 PacketType;
int16 type;
int16 property;
#if PACKETVER >= 20121010
struct {
uint32 party : 1; // Show attack cursor on non-party members (PvP)
uint32 guild : 1; // Show attack cursor on non-guild members (GvG)
Expand All @@ -981,6 +986,7 @@ struct packet_maptypeproperty2 {
uint32 summonstarmiracle : 1; // TODO: What does this do? Related to Taekwon Masters, but I have no idea.
uint32 SpareBits : 21; /// Currently ignored, reserved for future updates
} flag;
#endif
} __attribute__((packed));

struct packet_bgqueue_ack {
Expand Down
24 changes: 1 addition & 23 deletions src/map/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -14558,8 +14558,7 @@ static int script_mapflag_pvp_sub(struct block_list *bl, va_list ap)
sd->pvp_won = 0;
sd->pvp_lost = 0;
}
clif->map_property(sd, MAPPROPERTY_FREEPVPZONE);
clif->maptypeproperty2(&sd->bl,SELF);
clif->map_property(&sd->bl, MAPPROPERTY_FREEPVPZONE, SELF);
return 0;
}

Expand Down Expand Up @@ -14605,9 +14604,6 @@ static BUILDIN(setmapflag)
memset(&bl, 0, sizeof(bl));
map->list[m].flag.gvg = 1;
clif->map_property_mapall(m, MAPPROPERTY_AGITZONE);
bl.type = BL_NUL;
bl.m = m;
clif->maptypeproperty2(&bl, ALL_SAMEMAP);
}
break;
case MF_GVG_NOPARTY: map->list[m].flag.gvg_noparty = 1; break;
Expand Down Expand Up @@ -14695,11 +14691,8 @@ static BUILDIN(removemapflag)
{
struct block_list bl;
memset(&bl, 0, sizeof(bl));
bl.type = BL_NUL;
bl.m = m;
map->list[m].flag.pvp = 0;
clif->map_property_mapall(m, MAPPROPERTY_NOTHING);
clif->maptypeproperty2(&bl, ALL_SAMEMAP);
}
break;
case MF_PVP_NOPARTY: map->list[m].flag.pvp_noparty = 0; break;
Expand All @@ -14708,11 +14701,8 @@ static BUILDIN(removemapflag)
{
struct block_list bl;
memset(&bl, 0, sizeof(bl));
bl.type = BL_NUL;
bl.m = m;
map->list[m].flag.gvg = 0;
clif->map_property_mapall(m, MAPPROPERTY_NOTHING);
clif->maptypeproperty2(&bl, ALL_SAMEMAP);
}
break;
case MF_GVG_NOPARTY: map->list[m].flag.gvg_noparty = 0; break;
Expand Down Expand Up @@ -14794,9 +14784,6 @@ static BUILDIN(pvpon)
map->zone_change2(m, strdb_get(map->zone_db, MAP_ZONE_PVP_NAME));
map->list[m].flag.pvp = 1;
clif->map_property_mapall(m, MAPPROPERTY_FREEPVPZONE);
bl.type = BL_NUL;
bl.m = m;
clif->maptypeproperty2(&bl,ALL_SAMEMAP);

if(battle_config.pk_mode) // disable ranking functions if pk_mode is on [Valaris]
return true;
Expand Down Expand Up @@ -14850,9 +14837,6 @@ static BUILDIN(pvpoff)
map->zone_change2(m, map->list[m].prev_zone);
map->list[m].flag.pvp = 0;
clif->map_property_mapall(m, MAPPROPERTY_NOTHING);
bl.type = BL_NUL;
bl.m = m;
clif->maptypeproperty2(&bl,ALL_SAMEMAP);

if(battle_config.pk_mode) // disable ranking options if pk_mode is on [Valaris]
return true;
Expand Down Expand Up @@ -14880,9 +14864,6 @@ static BUILDIN(gvgon)
map->zone_change2(m, strdb_get(map->zone_db, MAP_ZONE_GVG_NAME));
map->list[m].flag.gvg = 1;
clif->map_property_mapall(m, MAPPROPERTY_AGITZONE);
bl.type = BL_NUL;
bl.m = m;
clif->maptypeproperty2(&bl,ALL_SAMEMAP);
}

return true;
Expand All @@ -14900,9 +14881,6 @@ static BUILDIN(gvgoff)
map->zone_change2(m, map->list[m].prev_zone);
map->list[m].flag.gvg = 0;
clif->map_property_mapall(m, MAPPROPERTY_NOTHING);
bl.type = BL_NUL;
bl.m = m;
clif->maptypeproperty2(&bl,ALL_SAMEMAP);
}

return true;
Expand Down

0 comments on commit ec2ed1d

Please sign in to comment.