From 6096ce0b42a3eee07dc70ae5ef489aa4c30bf515 Mon Sep 17 00:00:00 2001 From: ai4rei Date: Sun, 26 Dec 2010 22:36:41 +0000 Subject: * Merged changes from trunk [14496:14630/trunk]. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/renewal@14632 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/party.c | 97 ++++++++++++++++++--------------------------------------- 1 file changed, 30 insertions(+), 67 deletions(-) (limited to 'src/map/party.c') diff --git a/src/map/party.c b/src/map/party.c index e6a7ffd8b..407221cde 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -30,8 +30,9 @@ static DBMap* party_db; // int party_id -> struct party_data* static DBMap* party_booking_db; // Party Booking [Spiria] +static unsigned long party_booking_nextid = 1; + int party_send_xy_timer(int tid, unsigned int tick, int id, intptr data); -bool check_party_leader(struct map_session_data *sd, struct party_data *p); // Party Booking [Spiria] /*========================================== * Fills the given party_member structure according to the sd provided. @@ -515,11 +516,6 @@ int party_leave(struct map_session_data *sd) if( i == MAX_PARTY ) return 0; - if( check_party_leader(sd, p) ){ // when party leader leaves party, cancel booking. - party_booking_delete(sd,true); - clif_PartyBookingDeleteAck(sd,0); - } - intif_party_leave(p->party.party_id,sd->status.account_id,sd->status.char_id); return 1; } @@ -665,8 +661,6 @@ bool party_changeleader(struct map_session_data *sd, struct map_session_data *ts //Update info. intif_party_leaderchange(p->party.party_id,p->party.member[tmi].account_id,p->party.member[tmi].char_id); clif_party_info(p,NULL); - party_booking_delete(sd, true); // Party Booking [Spiria] - clif_PartyBookingDeleteAck(sd, 0); // Close small window return true; } @@ -1070,52 +1064,25 @@ int party_foreachsamemap(int (*func)(struct block_list*,va_list),struct map_sess * Party Booking in KRO [Spiria] *------------------------------------------*/ -static struct party_booking_ad_info* create_party_booking_data(int party_id) +static struct party_booking_ad_info* create_party_booking_data(void) { struct party_booking_ad_info *pb_ad; CREATE(pb_ad, struct party_booking_ad_info, 1); - pb_ad->index = party_id; + pb_ad->index = party_booking_nextid++; 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; - - if (!sd || !sd->status.party_id) return false; - - if( p == NULL ) return false; - - ARR_FIND(0, MAX_PARTY, i, p->party.member[i].leader && p->party.member[i].online && p->data[i].sd == sd); - if(i == MAX_PARTY) return false; - - return true; -} - void party_booking_register(struct map_session_data *sd, short level, short mapid, short* job) { struct party_booking_ad_info *pb_ad; - struct party_data *p=party_search(sd->status.party_id); int i; - if (!check_party_leader(sd, p)) { - clif_PartyBookingRegisterAck(sd, 1); - return; - } - - pb_ad = (struct party_booking_ad_info*)idb_get(party_booking_db, p->party.party_id); + pb_ad = (struct party_booking_ad_info*)idb_get(party_booking_db, sd->status.char_id); if( pb_ad == NULL ) { - pb_ad = create_party_booking_data(p->party.party_id); - idb_put(party_booking_db, pb_ad->index, pb_ad); + pb_ad = create_party_booking_data(); + idb_put(party_booking_db, sd->status.char_id, pb_ad); } memcpy(pb_ad->charname,sd->status.name,NAME_LENGTH); @@ -1123,84 +1090,80 @@ 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<6;i++) + for(i=0;ip_detail.job[i] = job[i]; else pb_ad->p_detail.job[i] = -1; clif_PartyBookingRegisterAck(sd, 0); clif_PartyBookingInsertNotify(sd, pb_ad); // Notice - clif_PartyBookingSearchAck(sd->fd, &pb_ad->index, 1, false); // Update Client! - return; } void party_booking_update(struct map_session_data *sd, short* job) { int i; - struct party_data *p=party_search(sd->status.party_id); struct party_booking_ad_info *pb_ad; - if (!check_party_leader(sd, p)) { - return; - } - - pb_ad = (struct party_booking_ad_info*)idb_get(party_booking_db, p->party.party_id); + pb_ad = (struct party_booking_ad_info*)idb_get(party_booking_db, sd->status.char_id); if( pb_ad == NULL ) return; pb_ad->starttime = (int)time(NULL);// Update time. - for(i=0;i<6;i++) + for(i=0;ip_detail.job[i] = job[i]; 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[10]; + 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) ) { - if (pb_ad->index < lastindex || (pb_ad->p_detail.level < level || pb_ad->p_detail.level-15 > level)) + if (pb_ad->index < lastindex || (level && (pb_ad->p_detail.level < level-15 || pb_ad->p_detail.level > level))) continue; - if (count >= 10){ + if (count >= PARTY_BOOKING_RESULTS){ more_result = true; break; } if (mapid == 0 && job == -1) - index_list[count] = pb_ad->index; + result_list[count] = pb_ad; else if (mapid == 0) { - for(i=0; i<6; i++) + 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; + } + if( result_list[count] ) + { + count++; } - 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) +bool party_booking_delete(struct map_session_data *sd) { - struct party_data *p=party_search(sd->status.party_id); - if (!check_party_leader(sd, p) && !force_delete) { - return false; + struct party_booking_ad_info* pb_ad; + + if((pb_ad = (struct party_booking_ad_info*)idb_get(party_booking_db, sd->status.char_id))!=NULL) + { + clif_PartyBookingDeleteNotify(sd, pb_ad->index); + idb_remove(party_booking_db,sd->status.char_id); } - clif_PartyBookingDeleteNotify(sd, sd->status.party_id); - idb_remove(party_booking_db,sd->status.party_id); return true; } -- cgit v1.2.3-70-g09d2