Skip to content

Commit

Permalink
Update packet version checks for new re clients
Browse files Browse the repository at this point in the history
  • Loading branch information
4144 committed Nov 5, 2021
1 parent 0b4d5ca commit ea1017d
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 46 deletions.
8 changes: 4 additions & 4 deletions src/char/char.c
Expand Up @@ -2068,7 +2068,7 @@ static int char_mmo_char_tobuf(uint8 *buffer, struct mmo_charstatus *p)
WBUFL(buf,32) = p->karma;
WBUFL(buf,36) = p->manner;
WBUFW(buf,40) = min(p->status_point, INT16_MAX);
#if PACKETVER_MAIN_NUM >= 20201007
#if PACKETVER_MAIN_NUM >= 20201007 || PACKETVER_RE_NUM >= 20211103
WBUFQ(buf, 42) = p->hp;
WBUFQ(buf, 50) = p->max_hp;
offset += 12;
Expand All @@ -2082,15 +2082,15 @@ static int char_mmo_char_tobuf(uint8 *buffer, struct mmo_charstatus *p)
WBUFW(buf,42) = min(p->hp, INT16_MAX);
WBUFW(buf,44) = min(p->max_hp, INT16_MAX);
#endif
#if PACKETVER_MAIN_NUM >= 20201007
#if PACKETVER_MAIN_NUM >= 20201007 || PACKETVER_RE_NUM >= 20211103
WBUFQ(buf, 46) = p->sp;
WBUFQ(buf, 54) = p->max_sp;
offset += 12;
buf = WBUFP(buffer, offset);
#else // PACKETVER_MAIN_NUM >= 20201007
#else // PACKETVER_MAIN_NUM >= 20201007 || PACKETVER_RE_NUM >= 20211103
WBUFW(buf, 46) = min(p->sp, INT16_MAX);
WBUFW(buf, 48) = min(p->max_sp, INT16_MAX);
#endif // PACKETVER_MAIN_NUM >= 20201007
#endif // PACKETVER_MAIN_NUM >= 20201007 || PACKETVER_RE_NUM >= 20211103
WBUFW(buf,50) = DEFAULT_WALK_SPEED; // p->speed;
WBUFW(buf,52) = p->class;
WBUFW(buf,54) = p->hair;
Expand Down
14 changes: 7 additions & 7 deletions src/char/packets_hc_struct.h
Expand Up @@ -29,7 +29,7 @@
#pragma pack(push, 1)
#endif // not NetBSD < 6 / Solaris

#if PACKETVER_MAIN_NUM >= 20201007
#if PACKETVER_MAIN_NUM >= 20201007 || PACKETVER_RE_NUM >= 20211103
struct PACKET_HC_ACK_CHARINFO_PER_PAGE {
int16 packetId;
int16 packetLen;
Expand All @@ -45,22 +45,22 @@ struct PACKET_HC_ACK_CHARINFO_PER_PAGE {
DEFINE_PACKET_HEADER(HC_ACK_CHARINFO_PER_PAGE, 0x099d);
#endif

#if PACKETVER_MAIN_NUM >= 20201007
#if PACKETVER_MAIN_NUM >= 20201007 || PACKETVER_RE_NUM >= 20211103
#define MAX_CHAR_BUF (PACKET_LEN_0x0b6f - 2)
#else // PACKETVER_MAIN_NUM >= 20201007
#else // PACKETVER_MAIN_NUM >= 20201007 || PACKETVER_RE_NUM >= 20211103
#define MAX_CHAR_BUF (PACKET_LEN_0x006d - 2)
#endif // // PACKETVER_MAIN_NUM >= 20201007
#endif // // PACKETVER_MAIN_NUM >= 20201007 || PACKETVER_RE_NUM >= 20211103

// because no structs set packet ids in define
#if PACKETVER_MAIN_NUM >= 20201007
#if PACKETVER_MAIN_NUM >= 20201007 || PACKETVER_RE_NUM >= 20211103
DEFINE_PACKET_ID(HC_ACCEPT_MAKECHAR, 0x0b6f)
DEFINE_PACKET_ID(HC_ACK_CHANGE_CHARACTER_SLOT, 0x0b70)
DEFINE_PACKET_ID(HC_UPDATE_CHARINFO, 0x0b71)
#else // PACKETVER_MAIN_NUM >= 20201007
#else // PACKETVER_MAIN_NUM >= 20201007 || PACKETVER_RE_NUM >= 20211103
DEFINE_PACKET_ID(HC_ACCEPT_MAKECHAR, 0x006d)
DEFINE_PACKET_ID(HC_ACK_CHANGE_CHARACTER_SLOT, 0x08d5)
DEFINE_PACKET_ID(HC_UPDATE_CHARINFO, 0x08e3)
#endif // // PACKETVER_MAIN_NUM >= 20201007
#endif // // PACKETVER_MAIN_NUM >= 20201007 || PACKETVER_RE_NUM >= 20211103

#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
#pragma pack(pop)
Expand Down
34 changes: 17 additions & 17 deletions src/map/clif.c
Expand Up @@ -1763,13 +1763,13 @@ static void clif_hominfo(struct map_session_data *sd, struct homun_data *hd, int
p.maxSp = hstatus->max_sp;
}
#endif // PACKETVER_MAIN_NUM >= 20200819 || PACKETVER_RE_NUM >= 20200723
#if PACKETVER_MAIN_NUM >= 20210303
#if PACKETVER_MAIN_NUM >= 20210303 || PACKETVER_RE_NUM >= 20211103
p.exp = hd->homunculus.exp;
p.expNext = hd->exp_next;
#else // PACKETVER_MAIN_NUM >= 20210303
#else // PACKETVER_MAIN_NUM >= 20210303 || PACKETVER_RE_NUM >= 20211103
p.exp = (uint32)min(hd->homunculus.exp, UINT32_MAX);
p.expNext = (uint32)min(hd->exp_next, UINT32_MAX);
#endif // PACKETVER_MAIN_NUM >= 20210303
#endif // PACKETVER_MAIN_NUM >= 20210303 || PACKETVER_RE_NUM >= 20211103

if (hd->homunculus.level >= homun->get_max_level(hd))
p.expNext = 0;
Expand Down Expand Up @@ -2235,7 +2235,7 @@ static void clif_buylist(struct map_session_data *sd, struct npc_data *nd)
p->items[c].discountPrice = pc->modifybuyvalue(sd, val, id->flag.ignore_discount);
p->items[c].itemType = itemtype(id->type);
p->items[c].itemId = (id->view_id > 0) ? id->view_id : id->nameid;
#if PACKETVER_MAIN_NUM >= 20210203
#if PACKETVER_MAIN_NUM >= 20210203 || PACKETVER_RE_NUM >= 20211103
p->items[c].viewSprite = id->view_sprite;
p->items[c].location = pc->item_equippoint(sd, id);
#endif // PACKETVER_MAIN_NUM >= 20210203
Expand Down Expand Up @@ -12541,7 +12541,7 @@ static void clif_parse_UnequipItem(int fd, struct map_session_data *sd)
static void clif_parse_UnequipAllItems(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
static void clif_parse_UnequipAllItems(int fd, struct map_session_data *sd)
{
#if PACKETVER_MAIN_NUM >= 20210818 || PACKETVER_ZERO_NUM >= 20210818
#if PACKETVER_MAIN_NUM >= 20210818 || PACKETVER_RE_NUM >= 20211103 || PACKETVER_ZERO_NUM >= 20210818
// commented because no fields in use
// struct PACKET_CZ_REQ_TAKEOFF_EQUIP_ALL *p = RFIFOP(fd, 0);

Expand Down Expand Up @@ -12574,17 +12574,17 @@ static void clif_parse_UnequipAllItems(int fd, struct map_session_data *sd)
atcommand->exec(sd->fd, sd, command, true);

clif->unequipAllItemsAck(sd, TAKEOFF_EQUIP_ALL_SUCCESS);
#endif // PACKETVER_MAIN_NUM >= 20210818 || PACKETVER_ZERO_NUM >= 20210818
#endif // PACKETVER_MAIN_NUM >= 20210818 || PACKETVER_RE_NUM >= 20211103 || PACKETVER_ZERO_NUM >= 20210818
}

static void clif_unequipAllItemsAck(struct map_session_data *sd, enum unequip_all result)
{
#if PACKETVER_MAIN_NUM >= 20210818
#if PACKETVER_MAIN_NUM >= 20210818 || PACKETVER_RE_NUM >= 20211103
struct PACKET_ZC_TAKEOFF_EQUIP_ALL_ACK packet = {0};
packet.PacketType = HEADER_ZC_TAKEOFF_EQUIP_ALL_ACK;
packet.result = result;
clif->send(&packet, sizeof(struct PACKET_ZC_TAKEOFF_EQUIP_ALL_ACK), &sd->bl, SELF);
#endif // PACKETVER_MAIN_NUM >= 20210818
#endif // PACKETVER_MAIN_NUM >= 20210818 || PACKETVER_RE_NUM >= 20211103
}

static void clif_parse_NpcClicked(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
Expand Down Expand Up @@ -13803,7 +13803,7 @@ static void clif_parse_NpcSelectMenu(int fd, struct map_session_data *sd)
static void clif_parse_NpcSelectMenuZero(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
static void clif_parse_NpcSelectMenuZero(int fd, struct map_session_data *sd)
{
#if PACKETVER_MAIN_NUM >= 20210317 || PACKETVER_ZERO_NUM >= 20210317
#if PACKETVER_MAIN_NUM >= 20210317 || PACKETVER_RE_NUM >= 20211103 || PACKETVER_ZERO_NUM >= 20210317
if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
return;

Expand Down Expand Up @@ -13832,7 +13832,7 @@ static void clif_parse_NpcSelectMenuZero(int fd, struct map_session_data *sd)

sd->npc_menu = select;
npc->scriptcont(sd, npc_id, false);
#endif // PACKETVER_MAIN_NUM >= 20210317 || PACKETVER_ZERO_NUM >= 20210317
#endif // PACKETVER_MAIN_NUM >= 20210317 || PACKETVER_RE_NUM >= 20211103 || PACKETVER_ZERO_NUM >= 20210317
}

static void clif_parse_NpcNextClicked(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
Expand Down Expand Up @@ -21798,9 +21798,9 @@ static void clif_npc_market_open(struct map_session_data *sd, struct npc_data *n
packet->list[c].qty = shop[i].qty;
packet->list[c].type = itemtype(id->type);
packet->list[c].weight = id->weight * 10;
#if PACKETVER_MAIN_NUM >= 20210203
#if PACKETVER_MAIN_NUM >= 20210203 || PACKETVER_RE_NUM >= 20211103
packet->list[c].location = pc->item_equippoint(sd, id);
#endif // PACKETVER_MAIN_NUM >= 20210203
#endif // PACKETVER_MAIN_NUM >= 20210203 || PACKETVER_RE_NUM >= 20211103
c++;
}
}
Expand Down Expand Up @@ -23035,7 +23035,7 @@ static void clif_parse_rodex_checkname1(int fd, struct map_session_data *sd)
static void clif_parse_rodex_checkname2(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
static void clif_parse_rodex_checkname2(int fd, struct map_session_data *sd)
{
#if PACKETVER_MAIN_NUM >= 20201104 || PACKETVER_ZERO_NUM >= 20201118
#if PACKETVER_MAIN_NUM >= 20201104 || PACKETVER_RE_NUM >= 20211103 || PACKETVER_ZERO_NUM >= 20201118
const struct PACKET_CZ_CHECKNAME2 *rPacket = RFIFOP(fd, 0);
int char_id = 0, base_level = 0;
int class = 0;
Expand All @@ -23044,7 +23044,7 @@ static void clif_parse_rodex_checkname2(int fd, struct map_session_data *sd)
safestrncpy(name, rPacket->Name, NAME_LENGTH);

rodex->check_player(sd, name, &base_level, &char_id, &class);
#endif // PACKETVER_MAIN_NUM >= 20201104 || PACKETVER_ZERO_NUM >= 20201118
#endif // PACKETVER_MAIN_NUM >= 20201104 || PACKETVER_RE_NUM >= 20211103 || PACKETVER_ZERO_NUM >= 20201118
}

static void clif_rodex_checkname_result(struct map_session_data *sd, int char_id, int class_, int base_level, const char *name)
Expand Down Expand Up @@ -24176,7 +24176,7 @@ static void clif_npc_barter_open(struct map_session_data *sd, struct npc_data *n
packet->list[c].currencyAmount = shop[i].value2;
packet->list[c].weight = id->weight * 10;
packet->list[c].index = i;
#if PACKETVER_MAIN_NUM >= 20210203
#if PACKETVER_MAIN_NUM >= 20210203 || PACKETVER_RE_NUM >= 20211103
packet->list[c].viewSprite = id->view_sprite;
packet->list[c].location = pc->item_equippoint(sd, id);
#endif // PACKETVER_MAIN_NUM >= 20210203
Expand Down Expand Up @@ -24267,10 +24267,10 @@ static void clif_npc_expanded_barter_open(struct map_session_data *sd, struct np
item->weight = id->weight * 10;
item->index = i;
item->zeny = shop[i].value;
#if PACKETVER_MAIN_NUM >= 20210203
#if PACKETVER_MAIN_NUM >= 20210203 || PACKETVER_RE_NUM >= 20211103
item->viewSprite = id->view_sprite;
item->location = pc->item_equippoint(sd, id);
#endif // PACKETVER_MAIN_NUM >= 20210203
#endif // PACKETVER_MAIN_NUM >= 20210203 || PACKETVER_RE_NUM >= 20211103
item->currency_count = 0;
buf_left -= ptr_size;
items_count ++;
Expand Down
12 changes: 6 additions & 6 deletions src/map/packets.h
Expand Up @@ -2014,16 +2014,16 @@ packet(0x96e,clif->ackmergeitems);
packet(0x0b66,clif->pRepairItem2);
#endif

#if PACKETVER_MAIN_NUM >= 20201104 || PACKETVER_ZERO_NUM >= 20201118
#if PACKETVER_MAIN_NUM >= 20201104 || PACKETVER_RE_NUM >= 20211103 || PACKETVER_ZERO_NUM >= 20201118
packet(0x0b97,clif->pRodexCheckName2);
#endif // PACKETVER_MAIN_NUM >= 20201104 || PACKETVER_ZERO_NUM >= 20201118
#endif // PACKETVER_MAIN_NUM >= 20201104 || PACKETVER_RE_NUM >= 20211103 || PACKETVER_ZERO_NUM >= 20201118

#if PACKETVER_MAIN_NUM >= 20210818 || PACKETVER_ZERO_NUM >= 20210818
#if PACKETVER_MAIN_NUM >= 20210818 || PACKETVER_RE_NUM >= 20211103 || PACKETVER_ZERO_NUM >= 20210818
packet(0x0bad,clif->pUnequipAllItems);
#endif // PACKETVER_MAIN_NUM >= 20210818 || PACKETVER_ZERO_NUM >= 20210818
#endif // PACKETVER_MAIN_NUM >= 20210818 || PACKETVER_RE_NUM >= 20211103 || PACKETVER_ZERO_NUM >= 20210818

#if PACKETVER_MAIN_NUM >= 20210317 || PACKETVER_ZERO_NUM >= 20210317
#if PACKETVER_MAIN_NUM >= 20210317 || PACKETVER_RE_NUM >= 20211103 || PACKETVER_ZERO_NUM >= 20210317
packet(0x0ba8,clif->pNpcSelectMenuZero);
#endif // PACKETVER_MAIN_NUM >= 20210317 || PACKETVER_ZERO_NUM >= 20210317
#endif // PACKETVER_MAIN_NUM >= 20210317 || PACKETVER_RE_NUM >= 20211103 || PACKETVER_ZERO_NUM >= 20210317

#endif /* MAP_PACKETS_H */
24 changes: 12 additions & 12 deletions src/map/packets_struct.h
Expand Up @@ -1466,7 +1466,7 @@ struct packet_npc_market_purchase {
} list[]; // Note: We assume this should be <= MAX_INVENTORY (since you can't hold more than MAX_INVENTORY items thus cant buy that many at once).
} __attribute__((packed));

#if PACKETVER_MAIN_NUM >= 20210203
#if PACKETVER_MAIN_NUM >= 20210203 || PACKETVER_RE_NUM >= 20211103
struct PACKET_ZC_NPC_MARKET_OPEN_sub {
#if PACKETVER_MAIN_NUM >= 20181121 || PACKETVER_RE_NUM >= 20180704 || PACKETVER_ZERO_NUM >= 20181114
uint32 nameid;
Expand Down Expand Up @@ -1783,7 +1783,7 @@ struct PACKET_CZ_CHECKNAME1 {
DEFINE_PACKET_HEADER(CZ_CHECKNAME1, 0x0a13)
#endif // PACKETVER >= 20140423

#if PACKETVER_MAIN_NUM >= 20201104 || PACKETVER_ZERO_NUM >= 20201118
#if PACKETVER_MAIN_NUM >= 20201104 || PACKETVER_RE_NUM >= 20211103 || PACKETVER_ZERO_NUM >= 20201118
struct PACKET_CZ_CHECKNAME2 {
int16 PacketType;
char Name[24];
Expand Down Expand Up @@ -2665,7 +2665,7 @@ struct PACKET_ZC_ACK_WEAPONREFINE {
#endif
} __attribute__((packed));

#if PACKETVER_MAIN_NUM >= 20210303
#if PACKETVER_MAIN_NUM >= 20210303 || PACKETVER_RE_NUM >= 20211103
// PACKET_ZC_PROPERTY_HOMUN4
struct PACKET_ZC_PROPERTY_HOMUN {
int16 packetType;
Expand Down Expand Up @@ -2972,7 +2972,7 @@ struct PACKET_ZC_PC_PURCHASE_MYITEMLIST {
DEFINE_PACKET_HEADER(ZC_PC_PURCHASE_MYITEMLIST, 0x0136);
#endif // PACKETVER_MAIN_NUM >= 20200916 || PACKETVER_RE_NUM >= 20200723

#if PACKETVER_MAIN_NUM >= 20210203
#if PACKETVER_MAIN_NUM >= 20210203 || PACKETVER_RE_NUM >= 20211103
struct PACKET_ZC_PC_PURCHASE_ITEMLIST_sub {
#if PACKETVER_MAIN_NUM >= 20181121 || PACKETVER_RE_NUM >= 20180704 || PACKETVER_ZERO_NUM >= 20181114
uint32 itemId;
Expand Down Expand Up @@ -3694,7 +3694,7 @@ struct PACKET_CZ_PARTY_CONFIG {
} __attribute__((packed));
DEFINE_PACKET_HEADER(CZ_PARTY_CONFIG, 0x02c8);

#if PACKETVER_MAIN_NUM >= 20210203
#if PACKETVER_MAIN_NUM >= 20210203 || PACKETVER_RE_NUM >= 20211103
struct PACKET_ZC_NPC_BARTER_OPEN_sub {
#if PACKETVER_MAIN_NUM >= 20181121 || PACKETVER_RE_NUM >= 20180704 || PACKETVER_ZERO_NUM >= 20181114
uint32 nameid;
Expand Down Expand Up @@ -4370,7 +4370,7 @@ struct PACKET_CZ_NPC_EXPANDED_BARTER_CLOSE {
DEFINE_PACKET_HEADER(CZ_NPC_EXPANDED_BARTER_CLOSE, 0x0b58);
#endif

#if PACKETVER_MAIN_NUM >= 20210203
#if PACKETVER_MAIN_NUM >= 20210203 || PACKETVER_RE_NUM >= 20211103
struct PACKET_ZC_NPC_EXPANDED_BARTER_OPEN_sub2 {
#if PACKETVER_MAIN_NUM >= 20181121 || PACKETVER_RE_NUM >= 20180704 || PACKETVER_ZERO_NUM >= 20181114
uint32 nameid;
Expand Down Expand Up @@ -5092,20 +5092,20 @@ struct PACKET_ZC_DELETE_MEMBER_FROM_GROUP {
} __attribute__((packed));
DEFINE_PACKET_HEADER(ZC_DELETE_MEMBER_FROM_GROUP, 0x0105);

#if PACKETVER_MAIN_NUM >= 20210818 || PACKETVER_ZERO_NUM >= 20210818
#if PACKETVER_MAIN_NUM >= 20210818 || PACKETVER_RE_NUM >= 20211103 || PACKETVER_ZERO_NUM >= 20210818
struct PACKET_CZ_REQ_TAKEOFF_EQUIP_ALL {
int16 PacketType;
} __attribute__((packed));
DEFINE_PACKET_HEADER(CZ_REQ_TAKEOFF_EQUIP_ALL, 0x0bad);
#endif // PACKETVER_MAIN_NUM >= 20210818 || PACKETVER_ZERO_NUM >= 20210818
#endif // PACKETVER_MAIN_NUM >= 20210818 || PACKETVER_RE_NUM >= 20211103 || PACKETVER_ZERO_NUM >= 20210818

#if PACKETVER_MAIN_NUM >= 20210818
#if PACKETVER_MAIN_NUM >= 20210818 || PACKETVER_RE_NUM >= 20211103
struct PACKET_ZC_TAKEOFF_EQUIP_ALL_ACK {
int16 PacketType;
uint8 result;
} __attribute__((packed));
DEFINE_PACKET_HEADER(ZC_TAKEOFF_EQUIP_ALL_ACK, 0x0bae);
#endif // PACKETVER_MAIN_NUM >= 20210818
#endif // PACKETVER_MAIN_NUM >= 20210818 || PACKETVER_RE_NUM >= 20211103

#if PACKETVER_ZERO_NUM >= 20210504
struct PACKET_ZC_BATTLEFIELD_NOTIFY_HP {
Expand Down Expand Up @@ -5166,14 +5166,14 @@ struct PACKET_ZC_MENU_LIST_ZERO {
DEFINE_PACKET_HEADER(ZC_MENU_LIST_ZERO, 0x0ba7);
#endif // PACKETVER_ZERO_NUM >= 20210721

#if PACKETVER_MAIN_NUM >= 20210317 || PACKETVER_ZERO_NUM >= 20210317
#if PACKETVER_MAIN_NUM >= 20210317 || PACKETVER_RE_NUM >= 20211103 || PACKETVER_ZERO_NUM >= 20210317
struct PACKET_CZ_CHOOSE_MENU_ZERO {
int16 PacketType;
uint32 NpcID;
uint8 menuIndex;
} __attribute__((packed));
DEFINE_PACKET_HEADER(CZ_CHOOSE_MENU_ZERO, 0x0ba8);
#endif // PACKETVER_MAIN_NUM >= 20210317 || PACKETVER_ZERO_NUM >= 20210317
#endif // PACKETVER_MAIN_NUM >= 20210317 || PACKETVER_RE_NUM >= 20211103 || PACKETVER_ZERO_NUM >= 20210317

#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
#pragma pack(pop)
Expand Down

0 comments on commit ea1017d

Please sign in to comment.