/// Invoked (from char-server) when a new member is added to the party. /// flag: 0-success, 1-failure int party_member_added(int party_id,int account_id,int char_id, int flag) { struct map_session_data *sd = map_id2sd(account_id),*sd2; struct party_data *p = party_search(party_id); int i; if(sd == NULL || sd->status.char_id != char_id || !sd->party_joining ) { if (!flag) //Char logged off before being accepted into party. intif_party_leave(party_id,account_id,char_id); return 0; } sd2 = map_id2sd(sd->party_invite_account); sd->party_joining = false; sd->party_invite = 0; sd->party_invite_account = 0; if (!p) { ShowError("party_member_added: party %d not found.\n",party_id); intif_party_leave(party_id,account_id,char_id); return 0; } if( flag ) {// failed if( sd2 != NULL ) clif_party_inviteack(sd2,sd->status.name,3); return 0; } sd->status.party_id = party_id; ARR_FIND( 0, MAX_PARTY, i, p->party.member[i].account_id == 0 ); if (i < MAX_PARTY) { //TODO: This is a hack to allow the following clif calls to send the data to the new player. //The correct player data is set when party_recv_info arrives soon afterwards. party_fill_member(&p->party.member[i], sd); p->data[i].sd = sd; } clif_party_member_info(p,sd); clif_party_option(p,sd,0x100); clif_party_info(p,sd); if( sd2 != NULL ) clif_party_inviteack(sd2,sd->status.name,2); for( i = 0; i < ARRAYLENGTH(p->data); ++i ) {// hp of the other party members sd2 = p->data[i].sd; if( sd2 && sd2->status.account_id != account_id && sd2->status.char_id != char_id ) clif_hpmeter_single(sd->fd, sd2->bl.id, sd2->battle_status.hp, sd2->battle_status.max_hp); } clif_party_hp(sd); clif_party_xy(sd); clif_charnameupdate(sd); //Update char name's display [Skotlex] return 0; }
void party_send_movemap(struct map_session_data *sd) { int i; struct party_data *p; if( sd->status.party_id==0 ) return; intif_party_changemap(sd,1); p=party_search(sd->status.party_id); if (!p) return; if(sd->state.connect_new) { //Note that this works because this function is invoked before connect_new is cleared. clif_party_option(p,sd,0x100); clif_party_info(p,sd); clif_party_member_info(p,sd); } if (sd->fd) { // synchronize minimap positions with the rest of the party for(i=0; i < MAX_PARTY; i++) { if (p->data[i].sd && p->data[i].sd != sd && p->data[i].sd->bl.m == sd->bl.m) { clif_party_xy_single(sd->fd, p->data[i].sd); clif_party_xy_single(p->data[i].sd->fd, sd); } } } return; }
/// Invoked (from char-server) when a new member is added to the party. /// flag: 0-success, 1-failure int party_member_added (int party_id, int account_id, int char_id, int flag) { struct map_session_data *sd = map_id2sd (account_id), *sd2; struct party_data *p = party_search (party_id); int i; if (sd == NULL || sd->status.char_id != char_id || !sd->party_joining) { if (!flag) //Char logged off before being accepted into party. intif_party_leave (party_id, account_id, char_id); return 0; } sd2 = map_id2sd (sd->party_invite_account); sd->party_joining = false; sd->party_invite = 0; sd->party_invite_account = 0; if (!p) { ShowError ("party_member_added: party %d not found.\n", party_id); intif_party_leave (party_id, account_id, char_id); return 0; } if (flag) { // failed if (sd2 != NULL) clif_party_inviteack (sd2, sd->status.name, 3); return 0; } sd->status.party_id = party_id; clif_party_member_info (p, sd); clif_party_option (p, sd, 0x100); clif_party_info (p, sd); if (sd2 != NULL) clif_party_inviteack (sd2, sd->status.name, 2); for (i = 0; i < ARRAYLENGTH (p->data); ++i) { // hp of the other party members sd2 = p->data[i].sd; if (sd2 && sd2->status.account_id != account_id && sd2->status.char_id != char_id) clif_hpmeter_single (sd->fd, sd2->bl.id, sd2->battle_status.hp, sd2->battle_status.max_hp); } clif_party_hp (sd); clif_party_xy (sd); clif_charnameupdate (sd); //Update char name's display [Skotlex] if (p->instance_id) clif_instance_join (sd->fd, p->instance_id); return 0; }
int party_optionchanged(int party_id,int account_id,int exp,int item,int flag) { struct party_data *p; struct map_session_data *sd=map_id2sd(account_id); if( (p=party_search(party_id))==NULL) return 0; if(!(flag&0x01) && p->party.exp != exp) { p->party.exp=exp; clif_party_option(p,sd,flag); //This packet doesn't updates item info anymore... } if(!(flag&0x10) && p->party.item != item) { p->party.item=item; clif_party_member_info(p,sd); } if(flag&0x01) //Send denied message clif_party_option(p,sd,flag); return 0; }
int party_optionchanged(int party_id,int account_id,int exp,int item,int flag) { struct party_data *p; struct map_session_data *sd=map_id2sd(account_id); if( (p=party_search(party_id))==NULL) return 0; //Flag&1: Exp change denied. Flag&2: Item change denied. if(!(flag&0x01) && p->party.exp != exp) p->party.exp=exp; if(!(flag&0x10) && p->party.item != item) { p->party.item=item; #if PACKETVER<20090603 //item changes aren't updated by clif_party_option for older clients. clif_party_member_info(p,sd); #endif } clif_party_option(p,sd,flag); return 0; }
int party_optionchanged(int party_id,int account_id,int exp,int item,int flag) { struct party_data *p; struct map_session_data *sd=map_id2sd(account_id); if( (p=party_search(party_id))==NULL) return 0; if( !(flag&0x01) || !(flag&0x10) ) { if( p->party.exp != exp ) p->party.exp=exp; if( p->party.item != item ) { p->party.item=item; clif_party_member_info(p,sd); } clif_party_option(p,sd,flag); } if( flag&0x01 ) //Send denied message clif_party_option(p,sd,flag); return 0; }
int party_recv_info(struct party *sp) { struct party_data *p; int i; bool party_new = false; nullpo_retr(0, sp); p = (struct party_data*)idb_ensure(party_db, sp->party_id, create_party); if (!p->party.party_id) //party just received. { party_new = true; party_check_member(sp); } memcpy(&p->party,sp,sizeof(struct party)); memset(&p->state, 0, sizeof(p->state)); memset(&p->data, 0, sizeof(p->data)); for(i=0;i<MAX_PARTY;i++){ if (!p->party.member[i].account_id) continue; p->data[i].sd = party_sd_check(p->party.party_id, p->party.member[i].account_id, p->party.member[i].char_id); } party_check_state(p); if (party_new) { //Send party data to all players. struct map_session_data *sd; for(i=0;i<MAX_PARTY;i++){ sd = p->data[i].sd; if(!sd) continue; clif_charnameupdate(sd); //Update other people's display. [Skotlex] clif_party_member_info(p,sd); clif_party_option(p,sd,0x100); clif_party_info(p,NULL); } } return 0; }
int party_member_added(int party_id,int account_id,int char_id, int flag) { struct map_session_data *sd = map_id2sd(account_id),*sd2; struct party_data *p = party_search(party_id); if(sd == NULL || sd->status.char_id != char_id){ if (flag == 0) { if(battle_config.error_log) ShowError("party: member added error %d is not online\n",account_id); intif_party_leave(party_id,account_id,char_id); } return 0; } sd->party_invite=0; sd->party_invite_account=0; if (!p) { if(battle_config.error_log) ShowError("party_member_added: party %d not found.\n",party_id); intif_party_leave(party_id,account_id,char_id); return 0; } if(!flag) { sd->state.party_sent=0; sd->status.party_id=party_id; party_check_conflict(sd); clif_party_member_info(p,sd); clif_party_hp(sd); clif_party_xy(sd); clif_charnameupdate(sd); //Update char name's display [Skotlex] } sd2=map_id2sd(sd->party_invite_account); if (sd2) clif_party_inviteack(sd2,sd->status.name,flag?2:1); return 0; }
void party_send_movemap(struct map_session_data *sd) { int i; struct party_data *p; if( sd->status.party_id==0 ) return; intif_party_changemap(sd,1); p=party_search(sd->status.party_id); if (!p) return; if(!sd->state.party_sent) { party_check_member(&p->party); if(sd->status.party_id==p->party.party_id){ clif_party_option(p,sd,0x100); clif_party_info(p,sd); clif_party_member_info(p,sd); sd->state.party_sent=1; } } if (sd->fd) { // synchronize minimap positions with the rest of the party for(i=0; i < MAX_PARTY; i++) { if (p->data[i].sd && p->data[i].sd != sd && p->data[i].sd->bl.m == sd->bl.m) { clif_party_xy_single(sd->fd, p->data[i].sd); clif_party_xy_single(p->data[i].sd->fd, sd); } } } return; }
int party_recv_info(struct party *sp) { struct map_session_data *sd; struct party_data *p; int i; nullpo_retr(0, sp); p= idb_ensure(party_db, sp->party_id, create_party); if (!p->party.party_id) //party just received. party_check_member(sp); memcpy(&p->party,sp,sizeof(struct party)); memset(&p->state, 0, sizeof(p->state)); memset(&p->data, 0, sizeof(p->data)); for(i=0;i<MAX_PARTY;i++){ if (!p->party.member[i].account_id) continue; sd = map_id2sd(p->party.member[i].account_id); if (sd && sd->status.party_id==p->party.party_id && sd->status.char_id == p->party.member[i].char_id && !sd->state.waitingdisconnect) p->data[i].sd = sd; } party_check_state(p); for(i=0;i<MAX_PARTY;i++){ sd = p->data[i].sd; if(!sd || sd->state.party_sent) continue; clif_party_member_info(p,sd); clif_party_option(p,sd,0x100); clif_party_info(p,NULL); sd->state.party_sent=1; } return 0; }
int party_recv_info(struct party* sp, uint32 char_id) { struct party_data* p; struct party_member* member; struct map_session_data* sd; int removed[MAX_PARTY];// member_id in old data int removed_count = 0; int added[MAX_PARTY];// member_id in new data int added_count = 0; int member_id; nullpo_ret(sp); p = (struct party_data*)idb_get(party_db, sp->party_id); if( p != NULL ) { // diff members int i; for( member_id = 0; member_id < MAX_PARTY; ++member_id ) { member = &p->party.member[member_id]; if( member->char_id == 0 ) continue; // empty ARR_FIND(0, MAX_PARTY, i, sp->member[i].account_id == member->account_id && sp->member[i].char_id == member->char_id); if( i == MAX_PARTY ) removed[removed_count++] = member_id; } for( member_id = 0; member_id < MAX_PARTY; ++member_id ) { member = &sp->member[member_id]; if( member->char_id == 0 ) continue; // empty ARR_FIND(0, MAX_PARTY, i, p->party.member[i].account_id == member->account_id && p->party.member[i].char_id == member->char_id); if( i == MAX_PARTY ) added[added_count++] = member_id; } } else { for( member_id = 0; member_id < MAX_PARTY; ++member_id ) if( sp->member[member_id].char_id != 0 ) added[added_count++] = member_id; CREATE(p, struct party_data, 1); idb_put(party_db, sp->party_id, p); } while( removed_count > 0 ) { // no longer in party member_id = removed[--removed_count]; sd = p->data[member_id].sd; if( sd == NULL ) continue; // not online party_member_withdraw(sp->party_id, sd->status.account_id, sd->status.char_id); } memcpy(&p->party, sp, sizeof(struct party)); memset(&p->state, 0, sizeof(p->state)); memset(&p->data, 0, sizeof(p->data)); for( member_id = 0; member_id < MAX_PARTY; member_id++ ) { member = &p->party.member[member_id]; if ( member->char_id == 0 ) continue;// empty p->data[member_id].sd = party_sd_check(sp->party_id, member->account_id, member->char_id); } party_check_state(p); while( added_count > 0 ) { // new in party member_id = added[--added_count]; sd = p->data[member_id].sd; if( sd == NULL ) continue;// not online clif_charnameupdate(sd); //Update other people's display. [Skotlex] clif_party_member_info(p,sd); // Only send this on party creation, otherwise it will be sent by party_send_movemap [Lemongrass] if( sd->party_creating ){ clif_party_option(p,sd,0x100); } clif_party_info(p,NULL); if( p->instance_id != 0 ) instance_reqinfo(sd,p->instance_id); } if( char_id != 0 ) { // requester sd = map_charid2sd(char_id); if( sd && sd->status.party_id == sp->party_id && party_getmemberid(p,sd) == -1 ) sd->status.party_id = 0;// was not in the party } return 0; }