Skip to content

Commit

Permalink
Refactored Party Booking defines (fixes #1018)
Browse files Browse the repository at this point in the history
* Adjusted the name of the defines to better suit their purpose.
Thanks to @Artuvazro!
  • Loading branch information
aleos89 committed Mar 10, 2016
1 parent 0fb78d4 commit ed7157c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
18 changes: 9 additions & 9 deletions src/map/clif.c
Expand Up @@ -12811,10 +12811,10 @@ void clif_parse_PartyBookingRegisterReq(int fd, struct map_session_data* sd){
short level = RFIFOW(fd,info->pos[0]);
short mapid = RFIFOW(fd,info->pos[1]);
int idxpbj = info->pos[2];
short job[PARTY_BOOKING_JOBS];
short job[MAX_PARTY_BOOKING_JOBS];
int i;

for(i=0; i<PARTY_BOOKING_JOBS; i++)
for(i=0; i<MAX_PARTY_BOOKING_JOBS; i++)
job[i] = RFIFOB(fd,idxpbj+i*2);

party_booking_register(sd, level, mapid, job);
Expand Down Expand Up @@ -12874,7 +12874,7 @@ void clif_PartyBookingSearchAck(int fd, struct party_booking_ad_info** results,
WFIFOL(fd,i*size+33) = pb_ad->starttime; // FIXME: This is expire time
WFIFOW(fd,i*size+37) = pb_ad->p_detail.level;
WFIFOW(fd,i*size+39) = pb_ad->p_detail.mapid;
for(j=0; j<PARTY_BOOKING_JOBS; j++)
for(j=0; j<MAX_PARTY_BOOKING_JOBS; j++)
WFIFOW(fd,i*size+41+j*2) = pb_ad->p_detail.job[j];
}
WFIFOSET(fd,WFIFOW(fd,2));
Expand Down Expand Up @@ -12912,11 +12912,11 @@ void clif_PartyBookingDeleteAck(struct map_session_data* sd, int flag)
/// 0808 { <job>.W }*6
void clif_parse_PartyBookingUpdateReq(int fd, struct map_session_data* sd)
{
short job[PARTY_BOOKING_JOBS];
short job[MAX_PARTY_BOOKING_JOBS];
int i;
int idxpbu = packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0];

for(i=0; i<PARTY_BOOKING_JOBS; i++)
for(i=0; i<MAX_PARTY_BOOKING_JOBS; i++)
job[i] = RFIFOW(fd,idxpbu+i*2);

party_booking_update(sd, job);
Expand All @@ -12928,7 +12928,7 @@ void clif_parse_PartyBookingUpdateReq(int fd, struct map_session_data* sd)
void clif_PartyBookingInsertNotify(struct map_session_data* sd, struct party_booking_ad_info* pb_ad)
{
int i;
uint8 buf[38+PARTY_BOOKING_JOBS*2];
uint8 buf[38+MAX_PARTY_BOOKING_JOBS*2];

if(pb_ad == NULL) return;

Expand All @@ -12938,7 +12938,7 @@ void clif_PartyBookingInsertNotify(struct map_session_data* sd, struct party_boo
WBUFL(buf,30) = pb_ad->starttime; // FIXME: This is expire time
WBUFW(buf,34) = pb_ad->p_detail.level;
WBUFW(buf,36) = pb_ad->p_detail.mapid;
for(i=0; i<PARTY_BOOKING_JOBS; i++)
for(i=0; i<MAX_PARTY_BOOKING_JOBS; i++)
WBUFW(buf,38+i*2) = pb_ad->p_detail.job[i];

clif_send(buf, packet_len(0x809), &sd->bl, ALL_CLIENT);
Expand All @@ -12950,13 +12950,13 @@ void clif_PartyBookingInsertNotify(struct map_session_data* sd, struct party_boo
void clif_PartyBookingUpdateNotify(struct map_session_data* sd, struct party_booking_ad_info* pb_ad)
{
int i;
uint8 buf[6+PARTY_BOOKING_JOBS*2];
uint8 buf[6+MAX_PARTY_BOOKING_JOBS*2];

if(pb_ad == NULL) return;

WBUFW(buf,0) = 0x80a;
WBUFL(buf,2) = pb_ad->index;
for(i=0; i<PARTY_BOOKING_JOBS; i++)
for(i=0; i<MAX_PARTY_BOOKING_JOBS; i++)
WBUFW(buf,6+i*2) = pb_ad->p_detail.job[i];
clif_send(buf,packet_len(0x80a),&sd->bl,ALL_CLIENT); // Now UPDATE all client.
}
Expand Down
10 changes: 5 additions & 5 deletions src/map/party.c
Expand Up @@ -1278,7 +1278,7 @@ void party_booking_register(struct map_session_data *sd, short level, short mapi
pb_ad->p_detail.level = level;
pb_ad->p_detail.mapid = mapid;

for(i = 0; i < PARTY_BOOKING_JOBS; i++)
for(i = 0; i < MAX_PARTY_BOOKING_JOBS; i++)
if(job[i] != 0xFF)
pb_ad->p_detail.job[i] = job[i];
else pb_ad->p_detail.job[i] = -1;
Expand All @@ -1299,7 +1299,7 @@ void party_booking_update(struct map_session_data *sd, short* job)

pb_ad->starttime = (int)time(NULL);// Update time.

for(i = 0; i < PARTY_BOOKING_JOBS; i++)
for(i = 0; i < MAX_PARTY_BOOKING_JOBS; i++)
if(job[i] != 0xFF)
pb_ad->p_detail.job[i] = job[i];
else
Expand All @@ -1312,7 +1312,7 @@ void party_booking_search(struct map_session_data *sd, short level, short mapid,
{
struct party_booking_ad_info *pb_ad;
int i, count=0;
struct party_booking_ad_info* result_list[PARTY_BOOKING_RESULTS];
struct party_booking_ad_info* result_list[MAX_PARTY_BOOKING_RESULTS];
bool more_result = false;
DBIterator* iter = db_iterator(party_booking_db);

Expand All @@ -1322,15 +1322,15 @@ void party_booking_search(struct map_session_data *sd, short level, short mapid,
if (pb_ad->index < lastindex || (level && (pb_ad->p_detail.level < level-15 || pb_ad->p_detail.level > level)))
continue;

if (count >= PARTY_BOOKING_RESULTS) {
if (count >= MAX_PARTY_BOOKING_RESULTS) {
more_result = true;
break;
}

if (mapid == 0 && job == -1)
result_list[count] = pb_ad;
else if (mapid == 0) {
for(i=0; i<PARTY_BOOKING_JOBS; i++)
for(i=0; i<MAX_PARTY_BOOKING_JOBS; i++)
if (pb_ad->p_detail.job[i] == job && job != -1)
result_list[count] = pb_ad;
} else if (job == -1) {
Expand Down
6 changes: 3 additions & 3 deletions src/map/party.h
Expand Up @@ -12,8 +12,8 @@ struct item;

#include <stdarg.h>

#define PARTY_BOOKING_JOBS 6
#define PARTY_BOOKING_RESULTS 10
#define MAX_PARTY_BOOKING_JOBS 6
#define MAX_PARTY_BOOKING_RESULTS 10

struct party_member_data {
struct map_session_data *sd;
Expand All @@ -37,7 +37,7 @@ struct party_data {
struct party_booking_detail {
short level;
short mapid;
short job[PARTY_BOOKING_JOBS];
short job[MAX_PARTY_BOOKING_JOBS];
};

struct party_booking_ad_info {
Expand Down

0 comments on commit ed7157c

Please sign in to comment.