/// 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; }
int bg_team_join(int bg_id, struct map_session_data *sd) { // Player joins team int i; struct battleground_data *bg = bg_team_search(bg_id); struct map_session_data *pl_sd; if( bg == NULL || sd == NULL || sd->bg_id ) return 0; ARR_FIND(0, MAX_BG_MEMBERS, i, bg->members[i].sd == NULL); if( i == MAX_BG_MEMBERS ) return 0; // No free slots sd->bg_id = bg_id; bg->members[i].sd = sd; bg->members[i].x = sd->bl.x; bg->members[i].y = sd->bl.y; bg->count++; guild_send_dot_remove(sd); for( i = 0; i < MAX_BG_MEMBERS; i++ ) { if( (pl_sd = bg->members[i].sd) != NULL && pl_sd != sd ) clif_hpmeter_single(sd->fd, pl_sd->bl.id, pl_sd->battle_status.hp, pl_sd->battle_status.max_hp); } clif_bg_hp(sd); clif_bg_xy(sd); return 1; }
/** * Inter-serv has sent us the elemental data from sql, fill it in map-serv memory * @param ele : The elemental data received from char-serv * @param flag : 0:not created, 1:was saved/loaded * @return 0:failed, 1:sucess */ int elemental_data_received(struct s_elemental *ele, bool flag) { struct map_session_data *sd; struct elemental_data *ed; struct s_elemental_db *db; int i = elemental_search_index(ele->class_); if( (sd = map_charid2sd(ele->char_id)) == NULL ) return 0; if( !flag || i < 0 ) { // Not created - loaded - DB info sd->status.ele_id = 0; return 0; } db = &elemental_db[i]; if( !sd->ed ) { // Initialize it after first summon. sd->ed = ed = (struct elemental_data*)aCalloc(1,sizeof(struct elemental_data)); ed->bl.type = BL_ELEM; ed->bl.id = npc_get_new_npc_id(); ed->master = sd; ed->db = db; memcpy(&ed->elemental, ele, sizeof(struct s_elemental)); status_set_viewdata(&ed->bl, ed->elemental.class_); ed->vd->head_mid = 10; // Why? status_change_init(&ed->bl); unit_dataset(&ed->bl); ed->ud.dir = sd->ud.dir; ed->bl.m = sd->bl.m; ed->bl.x = sd->bl.x; ed->bl.y = sd->bl.y; unit_calc_pos(&ed->bl, sd->bl.x, sd->bl.y, sd->ud.dir); ed->bl.x = ed->ud.to_x; ed->bl.y = ed->ud.to_y; map_addiddb(&ed->bl); status_calc_elemental(ed,SCO_FIRST); ed->last_spdrain_time = ed->last_thinktime = gettick(); ed->summon_timer = INVALID_TIMER; ed->masterteleport_timer = INVALID_TIMER; elemental_summon_init(ed); } else { memcpy(&sd->ed->elemental, ele, sizeof(struct s_elemental)); ed = sd->ed; } sd->status.ele_id = ele->elemental_id; if( ed->bl.prev == NULL && sd->bl.prev != NULL ) { if(map_addblock(&ed->bl)) return 0; clif_spawn(&ed->bl); clif_elemental_info(sd); clif_elemental_updatestatus(sd,SP_HP); clif_hpmeter_single(sd->fd,ed->bl.id,ed->battle_status.hp,ed->battle_status.max_hp); clif_elemental_updatestatus(sd,SP_SP); } return 1; }
/// 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; }