// ギルドエンブレム変更通知 int guild_emblem_changed(int len,int guild_id,int emblem_id,const char *data) { int i; struct map_session_data *sd; struct guild *g=guild_search(guild_id); if(g==NULL) return 0; memcpy(g->emblem_data,data,len); g->emblem_len=len; g->emblem_id=emblem_id; for(i=0;i<g->max_member;i++){ if((sd=g->member[i].sd)!=NULL){ sd->guild_emblem_id=emblem_id; clif_guild_belonginfo(sd,g); clif_guild_emblem(sd,g); } } return 0; }
// 情報所得 int guild_recv_info(struct guild *sg) { struct guild *g,before; int i,bm,m; struct eventlist *ev,*ev2; struct map_session_data *sd; bool guild_new = false; nullpo_ret(sg); if((g = (struct guild*)idb_get(guild_db,sg->guild_id))==NULL) { guild_new = true; g=(struct guild *)aCalloc(1,sizeof(struct guild)); idb_put(guild_db,sg->guild_id,g); before=*sg; // 最初のロードなのでユーザーのチェックを行う guild_check_member(sg); if ((sd = map_nick2sd(sg->master)) != NULL) { //If the guild master is online the first time the guild_info is received, //that means he was the first to join, so apply guild skill blocking here. if( battle_config.guild_skill_relog_delay ) guild_block_skill(sd, 300000); //Also set the guild master flag. sd->state.gmaster_flag = g; clif_charnameupdate(sd); // [LuzZza] clif_guild_masterormember(sd); } }else before=*g; memcpy(g,sg,sizeof(struct guild)); if(g->max_member > MAX_GUILD) { ShowError("guild_recv_info: Received guild with %d members, but MAX_GUILD is only %d. Extra guild-members have been lost!\n", g->max_member, MAX_GUILD); g->max_member = MAX_GUILD; } for(i=bm=m=0;i<g->max_member;i++){ if(g->member[i].account_id>0){ sd = g->member[i].sd = guild_sd_check(g->guild_id, g->member[i].account_id, g->member[i].char_id); if (sd) clif_charnameupdate(sd); // [LuzZza] m++; }else g->member[i].sd=NULL; if(before.member[i].account_id>0) bm++; } for(i=0;i<g->max_member;i++){ // 情報の送信 sd = g->member[i].sd; if( sd==NULL ) continue; if( before.guild_lv!=g->guild_lv || bm!=m || before.max_member!=g->max_member ){ clif_guild_basicinfo(sd); // 基本情報送信 clif_guild_emblem(sd,g); // エンブレム送信 } if(bm!=m){ // メンバー情報送信 clif_guild_memberlist(g->member[i].sd); } if( before.skill_point!=g->skill_point) clif_guild_skillinfo(sd); // スキル情報送信 if( guild_new ){ // 未送信なら所属情報も送る clif_guild_belonginfo(sd,g); clif_guild_notice(sd,g); sd->guild_emblem_id=g->emblem_id; } } // イベントの発生 if( (ev = (struct eventlist*)idb_remove(guild_infoevent_db,sg->guild_id))!=NULL ) { while(ev){ npc_event_do(ev->name); ev2=ev->next; aFree(ev); ev=ev2; } } return 0; }
// ギルドエンブレム変更通知 int guild_emblem_changed(int len,int guild_id,int emblem_id,const char *data) { int i; struct map_session_data *sd; struct guild *g=guild_search(guild_id); if(g==NULL) return 0; memcpy(g->emblem_data,data,len); g->emblem_len=len; g->emblem_id=emblem_id; for(i=0;i<g->max_member;i++){ if((sd=g->member[i].sd)!=NULL){ sd->guild_emblem_id=emblem_id; clif_guild_belonginfo(sd,g); clif_guild_emblem(sd,g); clif_guild_emblem_area(&sd->bl); } } {// update guardians (mobs) DBIterator* iter = db_iterator(castle_db); struct guild_castle* gc; for( gc = (struct guild_castle*)dbi_first(iter) ; dbi_exists(iter); gc = (struct guild_castle*)dbi_next(iter) ) { if( gc->guild_id != guild_id ) continue; // update permanent guardians for( i = 0; i < ARRAYLENGTH(gc->guardian); ++i ) { TBL_MOB* md = (gc->guardian[i].id ? map_id2md(gc->guardian[i].id) : NULL); if( md == NULL || md->guardian_data == NULL ) continue; md->guardian_data->emblem_id = emblem_id; clif_guild_emblem_area(&md->bl); } // update temporary guardians for( i = 0; i < gc->temp_guardians_max; ++i ) { TBL_MOB* md = (gc->temp_guardians[i] ? map_id2md(gc->temp_guardians[i]) : NULL); if( md == NULL || md->guardian_data == NULL ) continue; md->guardian_data->emblem_id = emblem_id; clif_guild_emblem_area(&md->bl); } } dbi_destroy(iter); } {// update npcs (flags or other npcs that used flagemblem to attach to this guild) // TODO this is not efficient [FlavioJS] struct s_mapiterator* iter = mapit_geteachnpc(); TBL_NPC* nd; for( nd = (TBL_NPC*)mapit_first(iter) ; mapit_exists(iter); nd = (TBL_NPC*)mapit_next(iter) ) { if( nd->subtype != SCRIPT || nd->u.scr.guild_id != guild_id ) continue; clif_guild_emblem_area(&nd->bl); } mapit_free(iter); } return 0; }
// 情報所得 int guild_recv_info(struct guild *sg) { struct guild *g,before; int i,bm,m; struct eventlist *ev,*ev2; nullpo_retr(0, sg); if((g=idb_get(guild_db,sg->guild_id))==NULL){ struct map_session_data *sd; g=(struct guild *)aCalloc(1,sizeof(struct guild)); idb_put(guild_db,sg->guild_id,g); before=*sg; // 最初のロードなのでユーザーのチェックを行う guild_check_member(sg); //If the guild master is online the first time the guild_info is received, that means he was the first to join, //and as such, his guild skills should be blocked to avoid login/logout abuse [Skotlex] if ((sd = map_nick2sd(sg->master)) != NULL) { guild_block_skill(sd, 300000); //Also set the guild master flag. sd->state.gmaster_flag = g; clif_charnameupdate(sd); // [LuzZza] } }else before=*g; memcpy(g,sg,sizeof(struct guild)); for(i=bm=m=0;i<g->max_member;i++){ // sdの設定と人数の確認 if(g->member[i].account_id>0){ struct map_session_data *sd = map_id2sd(g->member[i].account_id); if (sd && sd->status.char_id == g->member[i].char_id && sd->status.guild_id == g->guild_id && !sd->state.waitingdisconnect) { g->member[i].sd = sd; clif_charnameupdate(sd); // [LuzZza] } else g->member[i].sd = NULL; m++; }else g->member[i].sd=NULL; if(before.member[i].account_id>0) bm++; } for(i=0;i<g->max_member;i++){ // 情報の送信 struct map_session_data *sd = g->member[i].sd; if( sd==NULL ) continue; if( before.guild_lv!=g->guild_lv || bm!=m || before.max_member!=g->max_member ){ clif_guild_basicinfo(sd); // 基本情報送信 clif_guild_emblem(sd,g); // エンブレム送信 } if(bm!=m){ // メンバー情報送信 clif_guild_memberlist(g->member[i].sd); } if( before.skill_point!=g->skill_point) clif_guild_skillinfo(sd); // スキル情報送信 if( sd->state.guild_sent==0){ // 未送信なら所属情報も送る clif_guild_belonginfo(sd,g); clif_guild_notice(sd,g); sd->guild_emblem_id=g->emblem_id; sd->state.guild_sent=1; } } // イベントの発生 if( (ev=idb_remove(guild_infoevent_db,sg->guild_id))!=NULL ){ while(ev){ npc_event_do(ev->name); ev2=ev->next; aFree(ev); ev=ev2; } } return 0; }
int bg_team_leave(struct map_session_data *sd, int flag) { // Single Player leaves team int i; struct battleground_data *bg; struct map_session_data *pl_sd; struct guild *g; if( sd == NULL || !sd->bg_id ) return 0; bg = bg_team_search(sd->bg_id); if( bg && bg->logout_event[0] && flag ) npc_event(sd, bg->logout_event, 0); // Packets if( battle_config.bg_eAmod_mode ) clif_bg_leave_single(sd, sd->status.name, "Leaving Battle..."); bg_send_dot_remove(sd); sd->bg_id = 0; sd->bg_kills = 0; sd->state.bg_afk = 0; sd->bmaster_flag = NULL; bg_member_removeskulls(sd); // Remove Guild Skill Buffs status_change_end(&sd->bl,SC_GUILDAURA,INVALID_TIMER); status_change_end(&sd->bl,SC_BATTLEORDERS,INVALID_TIMER); status_change_end(&sd->bl,SC_REGENERATION,INVALID_TIMER); if( battle_config.bg_eAmod_mode ) { // Refresh Guild Information if( sd->status.guild_id && (g = guild_search(sd->status.guild_id)) != NULL ) { clif_guild_belonginfo(sd, g); clif_guild_basicinfo(sd); clif_guild_allianceinfo(sd); clif_guild_memberlist(sd); clif_guild_skillinfo(sd); clif_guild_emblem(sd, g); } clif_charnameupdate(sd); clif_guild_emblem_area(&sd->bl); } if( !bg ) return 0; ARR_FIND(0, MAX_BG_MEMBERS, i, bg->members[i].sd == sd); if( i < MAX_BG_MEMBERS ) // Removes member from BG memset(&bg->members[i], 0, sizeof(bg->members[0])); if( bg->leader_char_id == sd->status.char_id ) bg->leader_char_id = 0; bg->count--; for( i = 0; i < MAX_BG_MEMBERS; i++ ) { // Update other BG members if( (pl_sd = bg->members[i].sd) == NULL ) continue; if( !bg->leader_char_id ) { // Set new Leader first on the list bg->leader_char_id = pl_sd->status.char_id; pl_sd->bmaster_flag = bg; } if( battle_config.bg_eAmod_mode ) { switch( flag ) { case 3: clif_bg_expulsion_single(pl_sd, sd->status.name, "Kicked by AFK Status..."); break; case 2: clif_bg_expulsion_single(pl_sd, sd->status.name, "Kicked by AFK Report..."); break; case 1: clif_bg_expulsion_single(pl_sd, sd->status.name, "User has quit the game..."); break; case 0: clif_bg_leave_single(pl_sd, sd->status.name, "Leaving Battle..."); break; } clif_guild_basicinfo(pl_sd); clif_bg_emblem(pl_sd, bg->g); clif_bg_memberlist(pl_sd); } } if( !battle_config.bg_eAmod_mode ) { char output[128]; switch( flag ) { case 3: sprintf(output, "Server : %s kicked by AFK Status...", sd->status.name); break; case 2: sprintf(output, "Server : %s kicked by AFK Report...", sd->status.name); break; case 1: sprintf(output, "Server : %s has quit the game...", sd->status.name); break; case 0: sprintf(output, "Server : %s is leaving the battlefield...", sd->status.name); break; } clif_bg_message(bg, 0, "Server", output, strlen(output) + 1); } return bg->count; }