summaryrefslogtreecommitdiff
path: root/src/map/party.c
diff options
context:
space:
mode:
authorL0ne_W0lf <L0ne_W0lf@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-10-05 17:17:58 +0000
committerL0ne_W0lf <L0ne_W0lf@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-10-05 17:17:58 +0000
commit1963ef3c77c8c2035da2e7a2310db341c4c421fc (patch)
tree0205d53e9c52b29f2c53e8234e3259247781434e /src/map/party.c
parentcc256e4bdc0c3cb858b993e82f53104113f814c4 (diff)
downloadhercules-1963ef3c77c8c2035da2e7a2310db341c4c421fc.tar.gz
hercules-1963ef3c77c8c2035da2e7a2310db341c4c421fc.tar.bz2
hercules-1963ef3c77c8c2035da2e7a2310db341c4c421fc.tar.xz
hercules-1963ef3c77c8c2035da2e7a2310db341c4c421fc.zip
* Added Spira's Party Booking System implementation
- Added two additional mercenaries and updated data. - Added place holder values to the item database. - Added packets for the party booking system. - Updated the 13.2 monster skills to official. - Updated stats and drop rates on several monsters. - Fixed Lullaby working on allies/party members. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14412 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/party.c')
-rw-r--r--src/map/party.c150
1 files changed, 150 insertions, 0 deletions
diff --git a/src/map/party.c b/src/map/party.c
index 53755b777..33c079fdf 100644
--- a/src/map/party.c
+++ b/src/map/party.c
@@ -29,7 +29,9 @@
static DBMap* party_db; // int party_id -> struct party_data*
+static DBMap* party_booking_db; // Party Booking [Spiria]
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.
@@ -84,11 +86,13 @@ static TBL_PC* party_sd_check(int party_id, int account_id, int char_id)
void do_final_party(void)
{
party_db->destroy(party_db,NULL);
+ party_booking_db->destroy(party_booking_db,NULL); // Party Booking [Spiria]
}
// ‰Šú‰»
void do_init_party(void)
{
party_db = idb_alloc(DB_OPT_RELEASE_DATA);
+ party_booking_db = idb_alloc(DB_OPT_RELEASE_DATA); // Party Booking [Spiria]
add_timer_func_list(party_send_xy_timer, "party_send_xy_timer");
add_timer_interval(gettick()+battle_config.party_update_interval, party_send_xy_timer, 0, 0, battle_config.party_update_interval);
}
@@ -511,6 +515,11 @@ 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;
}
@@ -656,6 +665,8 @@ 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;
}
@@ -1054,3 +1065,142 @@ int party_foreachsamemap(int (*func)(struct block_list*,va_list),struct map_sess
return total;
}
+
+/*==========================================
+ * Party Booking in KRO [Spiria]
+ *------------------------------------------*/
+
+static struct party_booking_ad_info* create_party_booking_data(int party_id)
+{
+ struct party_booking_ad_info *pb_ad;
+ CREATE(pb_ad, struct party_booking_ad_info, 1);
+ pb_ad->index = 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;
+
+ 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);
+
+ if( pb_ad == NULL )
+ {
+ pb_ad = create_party_booking_data(p->party.party_id);
+ idb_put(party_booking_db, pb_ad->index, pb_ad);
+ }
+
+ memcpy(pb_ad->charname,sd->status.name,NAME_LENGTH);
+ pb_ad->starttime = (int)time(NULL);
+ pb_ad->p_detail.level = level;
+ pb_ad->p_detail.mapid = mapid;
+
+ for(i=0;i<6;i++)
+ if(job[i] != 0xFF)
+ pb_ad->p_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);
+
+ if( pb_ad == NULL )
+ return;
+
+ pb_ad->starttime = (int)time(NULL);// Update time.
+
+ for(i=0;i<6;i++)
+ if(job[i] != 0xFF)
+ pb_ad->p_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];
+ bool more_result = false;
+ DBIterator* iter = party_booking_db->iterator(party_booking_db);
+
+ memset(index_list, 0, sizeof(index_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))
+ continue;
+ if (count >= 10){
+ more_result = true;
+ break;
+ }
+ if (mapid == 0 && job == -1)
+ index_list[count] = pb_ad->index;
+ else if (mapid == 0) {
+ for(i=0; i<6; i++)
+ if (pb_ad->p_detail.job[i] == job && job != -1)
+ index_list[count] = pb_ad->index;
+ } else if (job == -1){
+ if (pb_ad->p_detail.mapid == mapid)
+ index_list[count] = pb_ad->index;
+ }
+ count++;
+ }
+ iter->destroy(iter);
+ clif_PartyBookingSearchAck(sd->fd, index_list, count, more_result);
+}
+
+bool party_booking_delete(struct map_session_data *sd, bool force_delete)
+{
+ struct party_data *p=party_search(sd->status.party_id);
+ if (!check_party_leader(sd, p) && !force_delete) {
+ return false;
+ }
+ clif_PartyBookingDeleteNotify(sd, sd->status.party_id);
+ idb_remove(party_booking_db,sd->status.party_id);
+ return true;
+}