diff options
Diffstat (limited to 'src/map/party.c')
-rw-r--r-- | src/map/party.c | 116 |
1 files changed, 47 insertions, 69 deletions
diff --git a/src/map/party.c b/src/map/party.c index fb738a12b..3a0b6d518 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -4,37 +4,38 @@ #define HERCULES_CORE -#include "../config/core.h" // GP_BOUND_ITEMS, RENEWAL_EXP +#include "config/core.h" // GP_BOUND_ITEMS, RENEWAL_EXP #include "party.h" +#include "map/atcommand.h" //msg_txt() +#include "map/battle.h" +#include "map/clif.h" +#include "map/instance.h" +#include "map/intif.h" +#include "map/itemdb.h" +#include "map/log.h" +#include "map/map.h" +#include "map/mob.h" // struct mob_data +#include "map/pc.h" +#include "map/skill.h" +#include "map/status.h" +#include "common/HPM.h" +#include "common/cbasetypes.h" +#include "common/memmgr.h" +#include "common/nullpo.h" +#include "common/random.h" +#include "common/showmsg.h" +#include "common/socket.h" // last_tick +#include "common/strlib.h" +#include "common/timer.h" +#include "common/utils.h" + #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "atcommand.h" //msg_txt() -#include "battle.h" -#include "clif.h" -#include "instance.h" -#include "intif.h" -#include "itemdb.h" -#include "log.h" -#include "map.h" -#include "mob.h" // struct mob_data -#include "pc.h" -#include "skill.h" -#include "status.h" -#include "../common/HPM.h" -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" // last_tick -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" - struct party_interface party_s; +struct party_interface *party; /*========================================== * Fills the given party_member structure according to the sd provided. @@ -97,23 +98,13 @@ TBL_PC* party_sd_check(int party_id, int account_id, int char_id) { } int party_db_final(DBKey key, DBData *data, va_list ap) { struct party_data *p; - + if ((p = DB->data2ptr(data))) { if (p->instance) aFree(p->instance); - if (p->hdata) { - int i; - for (i = 0; i < p->hdatac; i++) { - if (p->hdata[i]->flag.free) { - aFree(p->hdata[i]->data); - } - aFree(p->hdata[i]); - } - aFree(p->hdata); - } + HPM->data_store_destroy(&p->hdata); } - return 0; } /// Party data lookup using party id. @@ -167,7 +158,6 @@ int party_create(struct map_session_data *sd,char *name,int item,int item2) return 0; } - void party_created(int account_id,int char_id,int fail,int party_id,char *name) { struct map_session_data *sd; sd=map->id2sd(account_id); @@ -499,7 +489,6 @@ int party_member_added(int party_id,int account_id,int char_id, int flag) { break; } } - return 0; } @@ -599,7 +588,7 @@ int party_broken(int party_id) instance->list[p->instance[j]].owner_id = 0; } } - + for( i = 0; i < MAX_PARTY; i++ ) { if( p->data[i].sd!=NULL ) { clif->party_withdraw(p,p->data[i].sd,p->party.member[i].account_id,p->party.member[i].name,0x10); @@ -610,16 +599,8 @@ int party_broken(int party_id) if( p->instance ) aFree(p->instance); - if( p->hdata ) - { - for( j = 0; j < p->hdatac; j++ ) { - if( p->hdata[j]->flag.free ) { - aFree(p->hdata[j]->data); - } - aFree(p->hdata[j]); - } - aFree(p->hdata); - } + HPM->data_store_destroy(&p->hdata); + idb_remove(party->db,party_id); return 0; } @@ -640,7 +621,7 @@ int party_optionchanged(int party_id,int account_id,int exp,int item,int flag) { if( (p=party->search(party_id))==NULL) return 0; - //Flag&1: Exp change denied. Flag&2: Item change denied. + //Flag&0x1: Exp change denied. Flag&0x10: Item change denied. if(!(flag&0x01) && p->party.exp != exp) p->party.exp=exp; if(!(flag&0x10) && p->party.item != item) { @@ -689,7 +670,7 @@ bool party_changeleader(struct map_session_data *sd, struct map_session_data *ts //Change leadership. p->party.member[mi].leader = 0; p->party.member[tmi].leader = 1; - + /** update members **/ clif->PartyLeaderChanged(p->data[mi].sd, p->data[mi].sd->status.account_id, p->data[tmi].sd->status.account_id); @@ -954,13 +935,13 @@ int party_exp_share(struct party_data* p, struct block_list* src, unsigned int b base_exp_bonus = base_exp; job_exp_bonus = job_exp; #endif - + for (i = 0; i < c; i++) { #ifdef RENEWAL_EXP if( !(src && src->type == BL_MOB && ((TBL_MOB*)src)->db->mexp) ){ struct mob_data *md = (TBL_MOB*)src; int rate = pc->level_penalty_mod(md->level - (sd[i])->status.base_level, md->status.race, md->status.mode, 1); - + base_exp = (unsigned int)cap_value(base_exp_bonus * rate / 100, 1, UINT_MAX); job_exp = (unsigned int)cap_value(job_exp_bonus * rate / 100, 1, UINT_MAX); } @@ -1117,7 +1098,7 @@ int party_sub_count_chorus(struct block_list *bl, va_list ap) { if (sd->state.autotrade) return 0; - + if (battle_config.idle_no_share && pc_isidle(sd)) return 0; @@ -1188,9 +1169,8 @@ void party_booking_register(struct map_session_data *sd, short level, short mapi #ifndef PARTY_RECRUIT struct party_booking_ad_info *pb_ad; int i; - + pb_ad = (struct party_booking_ad_info*)idb_get(party->booking_db, sd->status.char_id); - if( pb_ad == NULL ) { pb_ad = party->create_booking_data(); @@ -1201,17 +1181,17 @@ void party_booking_register(struct map_session_data *sd, short level, short mapi clif->PartyBookingRegisterAck(sd, 2); return; } - + memcpy(pb_ad->charname,sd->status.name,NAME_LENGTH); pb_ad->expiretime = (int)time(NULL); pb_ad->p_detail.level = level; pb_ad->p_detail.mapid = mapid; - + for(i=0;i<PARTY_BOOKING_JOBS;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 #else @@ -1243,26 +1223,25 @@ void party_booking_update(struct map_session_data *sd, short* job) { #ifndef PARTY_RECRUIT int i; struct party_booking_ad_info *pb_ad; - + pb_ad = (struct party_booking_ad_info*)idb_get(party->booking_db, sd->status.char_id); - + if( pb_ad == NULL ) return; - + pb_ad->expiretime = (int)time(NULL);// Update time. - + for(i=0;i<PARTY_BOOKING_JOBS;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); #else return; #endif } - void party_recruit_search(struct map_session_data *sd, short level, short mapid, unsigned long lastindex, short resultcount) { #ifdef PARTY_RECRUIT struct party_booking_ad_info *pb_ad; @@ -1301,9 +1280,9 @@ void party_booking_search(struct map_session_data *sd, short level, short mapid, struct party_booking_ad_info* result_list[PARTY_BOOKING_RESULTS]; bool more_result = false; DBIterator* iter = db_iterator(party->booking_db); - + memset(result_list, 0, sizeof(result_list)); - + for( pb_ad = dbi_first(iter); dbi_exists(iter); pb_ad = dbi_next(iter) ) { if (pb_ad->index < lastindex || (level && (pb_ad->p_detail.level < level-15 || pb_ad->p_detail.level > level))) continue; @@ -1333,7 +1312,6 @@ void party_booking_search(struct map_session_data *sd, short level, short mapid, #endif } - bool party_booking_delete(struct map_session_data *sd) { struct party_booking_ad_info* pb_ad; @@ -1383,7 +1361,7 @@ void party_defaults(void) { party->searchname = party_searchname; party->getmemberid = party_getmemberid; party->getavailablesd = party_getavailablesd; - + party->create = party_create; party->created = party_created; party->request_info = party_request_info; |