From e4c1f576bf32e13a640670de3656765bfa966198 Mon Sep 17 00:00:00 2001 From: ai4rei Date: Sun, 28 Nov 2010 13:44:23 +0000 Subject: * Made the party booking search pass results as array of pointers, rather than array of indexes, which require further lookup. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14514 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 1 + src/map/clif.c | 7 +++---- src/map/clif.h | 2 +- src/map/party.c | 23 +++++++---------------- src/map/party.h | 1 - 5 files changed, 12 insertions(+), 22 deletions(-) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 9e12607c3..10220dd42 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -1,6 +1,7 @@ Date Added 2010/11/28 + * Made the party booking search pass results as array of pointers, rather than array of indexes, which require further lookup. [Ai4rei] * Replaced literal constants related to the party booking system with defines. [Ai4rei] * Fixed pets derived from immobile monsters not being able to walk (bugreport:3377, since r13789). [Ai4rei] - This also fixes pets using original monster walk speed, instead of the one defined in pet db. diff --git a/src/map/clif.c b/src/map/clif.c index 7917d5b8b..8f7971b29 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -10832,7 +10832,7 @@ void clif_parse_PartyBookingSearchReq(int fd, struct map_session_data* sd) /*========================================== * more_result: 0 - no more, 1 - more *------------------------------------------*/ -void clif_PartyBookingSearchAck(int fd, unsigned long *index, int count, bool more_result) +void clif_PartyBookingSearchAck(int fd, struct party_booking_ad_info** results, int count, bool more_result) { int i, j; int size = sizeof(struct party_booking_ad_info); // structure size (48) @@ -10840,11 +10840,10 @@ void clif_PartyBookingSearchAck(int fd, unsigned long *index, int count, bool mo WFIFOHEAD(fd,size*count + 5); WFIFOW(fd,0) = 0x805; WFIFOW(fd,2) = size*count + 5; - WFIFOB(fd,4) = (bool)more_result; + WFIFOB(fd,4) = more_result; for(i=0; iindex; memcpy(WFIFOP(fd,i*size+9),pb_ad->charname,NAME_LENGTH); WFIFOL(fd,i*size+33) = pb_ad->starttime; diff --git a/src/map/clif.h b/src/map/clif.h index d3a3679f1..5989fa5c8 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -469,7 +469,7 @@ void clif_progressbar_abort(struct map_session_data * sd); void clif_PartyBookingRegisterAck(struct map_session_data *sd, int flag); void clif_PartyBookingDeleteAck(struct map_session_data* sd, int flag); -void clif_PartyBookingSearchAck(int fd, unsigned long *index, int count, bool more_result); +void clif_PartyBookingSearchAck(int fd, struct party_booking_ad_info** results, int count, bool more_result); void clif_PartyBookingUpdateNotify(struct map_session_data* sd, struct party_booking_ad_info* pb_ad); void clif_PartyBookingDeleteNotify(struct map_session_data* sd, int index); void clif_PartyBookingInsertNotify(struct map_session_data* sd, struct party_booking_ad_info* pb_ad); diff --git a/src/map/party.c b/src/map/party.c index 9e2ee5c7b..b86e52d98 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -1078,13 +1078,6 @@ static struct party_booking_ad_info* create_party_booking_data(int party_id) return pb_ad; } -struct party_booking_ad_info* party_booking_getdata(unsigned long index) -{ - struct party_booking_ad_info *pb_ad; - pb_ad = (struct party_booking_ad_info*)idb_get(party_booking_db, index); - return pb_ad; -} - bool check_party_leader(struct map_session_data *sd, struct party_data *p) { int i; @@ -1130,8 +1123,7 @@ void party_booking_register(struct map_session_data *sd, short level, short mapi clif_PartyBookingRegisterAck(sd, 0); clif_PartyBookingInsertNotify(sd, pb_ad); // Notice - clif_PartyBookingSearchAck(sd->fd, &pb_ad->index, 1, false); // Update Client! - return; + clif_PartyBookingSearchAck(sd->fd, &pb_ad, 1, false); // Update Client! } void party_booking_update(struct map_session_data *sd, short* job) @@ -1157,18 +1149,17 @@ void party_booking_update(struct map_session_data *sd, short* job) else pb_ad->p_detail.job[i] = -1; clif_PartyBookingUpdateNotify(sd, pb_ad); - return; } void party_booking_search(struct map_session_data *sd, short level, short mapid, short job, unsigned long lastindex, short resultcount) { struct party_booking_ad_info *pb_ad; int i, count=0; - unsigned long index_list[PARTY_BOOKING_RESULTS]; + struct party_booking_ad_info* result_list[PARTY_BOOKING_RESULTS]; bool more_result = false; DBIterator* iter = party_booking_db->iterator(party_booking_db); - memset(index_list, 0, sizeof(index_list)); + memset(result_list, 0, sizeof(result_list)); for( pb_ad = (struct party_booking_ad_info*)iter->first(iter,NULL); iter->exists(iter); pb_ad = (struct party_booking_ad_info*)iter->next(iter,NULL) ) { @@ -1179,19 +1170,19 @@ void party_booking_search(struct map_session_data *sd, short level, short mapid, break; } if (mapid == 0 && job == -1) - index_list[count] = pb_ad->index; + result_list[count] = pb_ad; else if (mapid == 0) { for(i=0; ip_detail.job[i] == job && job != -1) - index_list[count] = pb_ad->index; + result_list[count] = pb_ad; } else if (job == -1){ if (pb_ad->p_detail.mapid == mapid) - index_list[count] = pb_ad->index; + result_list[count] = pb_ad; } count++; } iter->destroy(iter); - clif_PartyBookingSearchAck(sd->fd, index_list, count, more_result); + clif_PartyBookingSearchAck(sd->fd, result_list, count, more_result); } bool party_booking_delete(struct map_session_data *sd, bool force_delete) diff --git a/src/map/party.h b/src/map/party.h index db8339bd2..a9df002e7 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -86,7 +86,6 @@ int party_foreachsamemap(int (*func)(struct block_list *,va_list),struct map_ses /*========================================== * Party Booking in KRO [Spiria] *------------------------------------------*/ -struct party_booking_ad_info* party_booking_getdata(unsigned long index); void party_booking_register(struct map_session_data *sd, short level, short mapid, short* job); void party_booking_update(struct map_session_data *sd, short* job); void party_booking_search(struct map_session_data *sd, short level, short mapid, short job, unsigned long lastindex, short resultcount); -- cgit v1.2.3-70-g09d2