Beispiel #1
0
int party_member_leaved(int party_id,int account_id,int char_id)
{
	struct map_session_data *sd=map_id2sd(account_id);
	struct party_data *p=party_search(party_id);
	int i;
	if (sd && sd->status.char_id != char_id) //Wrong target
		sd = NULL;
	if(p!=NULL){
		for(i=0;i<MAX_PARTY;i++)
			if(p->party.member[i].account_id==account_id &&
				p->party.member[i].char_id==char_id){
				clif_party_leaved(p,sd,account_id,p->party.member[i].name,0x00);
				memset(&p->party.member[i], 0, sizeof(p->party.member[0]));
				memset(&p->data[i], 0, sizeof(p->data[0]));
				p->party.count--;
				party_check_state(p);
				break;
			}
	}
	if(sd!=NULL && sd->status.party_id==party_id){
		sd->status.party_id=0;
		sd->state.party_sent=0;
		clif_charnameupdate(sd); //Update name display [Skotlex]
		//TODO: hp bars should be cleared too
	}
	return 0;
}
Beispiel #2
0
/// Invoked (from char-server) when a party member leaves the party.
int party_member_withdraw(int party_id, int account_id, int char_id)
{
	struct map_session_data* sd = map_id2sd(account_id);
	struct party_data* p = party_search(party_id);
	int i;

	if( p )
	{
		ARR_FIND( 0, MAX_PARTY, i, p->party.member[i].account_id == account_id && p->party.member[i].char_id == char_id );
		if( i < MAX_PARTY )
		{
			clif_party_withdraw(p,sd,account_id,p->party.member[i].name,0x00);
			memset(&p->party.member[i], 0, sizeof(p->party.member[0]));
			memset(&p->data[i], 0, sizeof(p->data[0]));
			p->party.count--;
			party_check_state(p);
			clif_party_info(p, NULL);
		}
	}

	if( sd && sd->status.party_id == party_id && sd->status.char_id == char_id )
	{
		sd->status.party_id = 0;
		if( sd->state.spb ) {
			sd->state.spb = 0;
			clif_displaymessage(sd->fd, msg_txt(1451));
		}
		clif_charnameupdate(sd); //Update name display [Skotlex]
		//TODO: hp bars should be cleared too
		if( p->instance_id )
			instance_check_kick(sd);
	}

	return 0;
}
Beispiel #3
0
/// Invoked (from char-server) when a party member leaves the party.
int party_member_withdraw(int party_id, int account_id, int char_id)
{
	struct map_session_data* sd = map_id2sd(account_id);
	struct party_data* p = party_search(party_id);

	if( p ) {
		int i;
		ARR_FIND( 0, MAX_PARTY, i, p->party.member[i].account_id == account_id && p->party.member[i].char_id == char_id );
		if( i < MAX_PARTY ) {
			clif_party_withdraw(p,sd,account_id,p->party.member[i].name,0x0);
			memset(&p->party.member[i], 0, sizeof(p->party.member[0]));
			memset(&p->data[i], 0, sizeof(p->data[0]));
			p->party.count--;
			party_check_state(p);
		}
	}

	if( sd && sd->status.party_id == party_id && sd->status.char_id == char_id ) {
		int idxlist[MAX_INVENTORY]; //or malloc to reduce consumtion
		int j,i;
		j = pc_bound_chk(sd,3,idxlist);
		for(i=0;i<j;i++)
			pc_delitem(sd,idxlist[i],sd->status.inventory[idxlist[i]].amount,0,1,LOG_TYPE_OTHER);
		sd->status.party_id = 0;
		clif_charnameupdate(sd); //Update name display [Skotlex]
		//TODO: hp bars should be cleared too
		if( p->instance_id )
			instance_check_kick(sd);
	}

	return 0;
}
Beispiel #4
0
// 作成可否
int 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);

	nullpo_retr(0, sd);
	if (sd->status.char_id != char_id)
		return 0; //unlikely failure...
	
	if(fail==0){
		struct party *p;
		sd->status.party_id=party_id;
		if(idb_get(party_db,party_id)!=NULL){
			ShowFatalError("party: id already exists!\n");
			exit(1);
		}
		p=(struct party *)aCalloc(1,sizeof(struct party));
		p->party_id=party_id;
		memcpy(p->name, name, NAME_LENGTH);
		idb_put(party_db,party_id,p);
		clif_party_created(sd,0); //Success message
		clif_charnameupdate(sd); //Update other people's display. [Skotlex]
	}else{
		clif_party_created(sd,1);
	}
	return 0;
}
Beispiel #5
0
/// Invoked (from char-server) when a party member leaves the party.
int party_member_leaved(int party_id, int account_id, int char_id)
{
	struct map_session_data* sd = map_id2sd(account_id);
	struct party_data* p = party_search(party_id);
	int i;

	if( p )
	{
		ARR_FIND( 0, MAX_PARTY, i, p->party.member[i].account_id == account_id && p->party.member[i].char_id == char_id );
		if( i < MAX_PARTY )
		{
			clif_party_leaved(p,sd,account_id,p->party.member[i].name,0x00);
			memset(&p->party.member[i], 0, sizeof(p->party.member[0]));
			memset(&p->data[i], 0, sizeof(p->data[0]));
			p->party.count--;
			party_check_state(p);
		}
	}

	if( sd && sd->status.party_id == party_id && sd->status.char_id == char_id )
	{
		sd->status.party_id = 0;
		clif_charnameupdate(sd); //Update name display [Skotlex]
		//TODO: hp bars should be cleared too
	}
	return 0;
}
Beispiel #6
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;
	
	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); // キャラ側i登録eきhかaたたぁ脱憎要求も出す
		}
		return 0;
	}
	
	sd->party_invite=0;
	sd->party_invite_account=0;
	
	sd2=map_id2sd(sd->party_invite_account);
	if (sd2)
		clif_party_inviteack(sd2,sd->status.name,flag?2:0);
	if(flag)
		return 0;
	
	sd->state.party_sent=0;
	sd->status.party_id=party_id;

	party_check_conflict(sd);
	clif_charnameupdate(sd); //Update char name's display [Skotlex]
	clif_party_hp(sd);
	clif_party_xy(sd);
	return 0;
}
Beispiel #7
0
/// 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;
}
Beispiel #8
0
// 作成可否
int party_created(int account_id,int fail,int party_id,char *name)
{
	struct map_session_data *sd;
	sd=map_id2sd(account_id);

	nullpo_retr(0, sd);
	
	if(fail==0){
		struct party *p;
		sd->status.party_id=party_id;
		if((p=(struct party *) numdb_search(party_db,party_id))!=NULL){
			ShowFatalError("party: id already exists!\n");
			exit(1);
		}
		p=(struct party *)aCalloc(1,sizeof(struct party));
		p->party_id=party_id;
		memcpy(p->name, name, NAME_LENGTH-1);
		numdb_insert(party_db,party_id,p);
		clif_party_created(sd,0);
		clif_charnameupdate(sd); //Update other people's display. [Skotlex]
	}else{
		clif_party_created(sd,1);
	}
	return 0;
}
Beispiel #9
0
/// 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;
}
Beispiel #10
0
// ギルドメンバの役職変更通知
int guild_memberposition_changed(struct guild *g,int idx,int pos)
{
	nullpo_ret(g);

	g->member[idx].position=pos;
	clif_guild_memberpositionchanged(g,idx);
	
	// Update char position in client [LuzZza]
	if(g->member[idx].sd != NULL)
		clif_charnameupdate(g->member[idx].sd);
	return 0;
}
Beispiel #11
0
// ギルド役職変更通知
int guild_position_changed(int guild_id,int idx,struct guild_position *p)
{
	struct guild *g=guild_search(guild_id);
	int i;
	if(g==NULL)
		return 0;
	memcpy(&g->position[idx],p,sizeof(struct guild_position));
	clif_guild_positionchanged(g,idx);
	
	// Update char name in client [LuzZza]
	for(i=0;i<g->max_member;i++)
		if(g->member[i].position == idx && g->member[i].sd != NULL)
			clif_charnameupdate(g->member[i].sd);
	return 0;
}
Beispiel #12
0
/// Invoked (from char-server) when a party member leaves the party.
int party_member_withdraw(int party_id, uint32 account_id, uint32 char_id)
{
	struct map_session_data* sd = map_id2sd(account_id);
	struct party_data* p = party_search(party_id);

	if( p ) {
		int i;
		ARR_FIND( 0, MAX_PARTY, i, p->party.member[i].account_id == account_id && p->party.member[i].char_id == char_id );
		if( i < MAX_PARTY ) {
			clif_party_withdraw(p,sd,account_id,p->party.member[i].name,0x0);
			memset(&p->party.member[i], 0, sizeof(p->party.member[0]));
			memset(&p->data[i], 0, sizeof(p->data[0]));
			p->party.count--;
			party_check_state(p);
		}
	}

	if( sd && sd->status.party_id == party_id && sd->status.char_id == char_id ) {
#ifdef BOUND_ITEMS
		int idxlist[MAX_INVENTORY]; //or malloc to reduce consumtion
		int j,i;

		party_trade_bound_cancel(sd);
		j = pc_bound_chk(sd,BOUND_PARTY,idxlist);

		for(i = 0; i < j; i++)
			pc_delitem(sd,idxlist[i],sd->status.inventory[idxlist[i]].amount,0,1,LOG_TYPE_BOUND_REMOVAL);
#endif

		sd->status.party_id = 0;
		clif_charnameupdate(sd); //Update name display [Skotlex]
		//TODO: hp bars should be cleared too

		if( p->instance_id ) {
			int16 m = sd->bl.m;

			if( map[m].instance_id ) { // User was on the instance map
				if( map[m].save.map )
					pc_setpos(sd, map[m].save.map, map[m].save.x, map[m].save.y, CLR_TELEPORT);
				else
					pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT);
			}
		}
	}

	return 0;
}
Beispiel #13
0
int guild_member_withdraw(int guild_id, int account_id, int char_id, int flag, const char* name, const char* mes)
{
	int i;
	struct guild* g = guild_search(guild_id);
	struct map_session_data* sd = map_charid2sd(char_id);
	struct map_session_data* online_member_sd;

	if(g == NULL)
		return 0; // no such guild (error!)
	
	i = guild_getindex(g, account_id, char_id);
	if( i == -1 )
		return 0; // not a member (inconsistency!)

	online_member_sd = guild_getavailablesd(g);
	if(online_member_sd == NULL)
		return 0; // noone online to inform

	if(!flag)
		clif_guild_leave(online_member_sd, name, mes);
	else
		clif_guild_expulsion(online_member_sd, name, mes, account_id);

	// remove member from guild
	memset(&g->member[i],0,sizeof(struct guild_member));
	clif_guild_memberlist(online_member_sd);

	// update char, if online
	if(sd != NULL && sd->status.guild_id == guild_id)
	{
		// do stuff that needs the guild_id first, BEFORE we wipe it
		if (sd->state.storage_flag == 2) //Close the guild storage.
			storage_guild_storageclose(sd);
		guild_send_dot_remove(sd);

		sd->status.guild_id = 0;
		sd->guild_emblem_id = 0;
		
		clif_charnameupdate(sd); //Update display name [Skotlex]
		//TODO: send emblem update to self and people around
	}
	return 0;
}
Beispiel #14
0
int guild_member_leaved(int guild_id,int account_id,int char_id,int flag,
	const char *name,const char *mes) // rewrote [LuzZza]
{
	int i;
	struct guild *g = guild_search(guild_id);
	struct map_session_data *sd = map_charid2sd(char_id);
	struct map_session_data *online_member_sd;

	if(g == NULL)
		return 0;
	
	for(i=0;i<g->max_member;i++) {
		if( g->member[i].account_id == account_id &&
			g->member[i].char_id == char_id ){

				if((online_member_sd = guild_getavailablesd(g)) == NULL)
					return 0;

				if(!flag)
					clif_guild_leave(online_member_sd, name, mes);
				else
					clif_guild_expulsion(online_member_sd, name, mes, account_id);

				memset(&g->member[i],0,sizeof(struct guild_member));
				clif_guild_memberlist(online_member_sd);

				if(sd != NULL && sd->status.guild_id == guild_id) {
					if (sd->state.storage_flag == 2) //Close the guild storage.
						storage_guild_storageclose(sd);
					sd->status.guild_id=0;
					sd->guild_emblem_id=0;
					sd->state.guild_sent=0;
					
					guild_send_dot_remove(sd);
					clif_charnameupdate(sd); //Update display name [Skotlex]
				}
				return 0;
		}
					
	}

	return 0;
}
Beispiel #15
0
//Innvoked on /breakguild "Guild name"
int guild_broken(int guild_id,int flag)
{
	struct guild *g=guild_search(guild_id);
//	struct guild_castle *gc=NULL;
	struct map_session_data *sd;
	int i;
//	char *name;;

	if(flag!=0 || g==NULL)
		return 0;

	//we call castle_event::OnGuildBreak of all castlesof the guild
	//you can set all castle_events in the castle_db.txt
/*	name=(char *)aCalloc(50,sizeof(char)); //24 char = event name, + space for  "::OnGuildBreak"
	for(i=0;i<MAX_GUILDCASTLE;i++){
		if( (gc=guild_castle_search(i)) != NULL ){
			if(gc->guild_id == guild_id){
				memcpy(name,gc->castle_event,50);
				npc_event_do(strcat(name,"::OnGuildBreak"));
			}
		}
	}
	free(name);
*/
	for(i=0;i<g->max_member;i++){	// ギルド解散を通知
		if((sd=g->member[i].sd)!=NULL){
			if(sd->state.storage_flag == 2)
				storage_guild_storage_quit(sd,1);
			sd->status.guild_id=0;
			sd->state.guild_sent=0;
			clif_guild_broken(g->member[i].sd,0);
			clif_charnameupdate(sd); // [LuzZza]
		}
	}

	guild_db->foreach(guild_db,guild_broken_sub,guild_id);
	castle_db->foreach(castle_db,castle_guild_broken_sub,guild_id);
	if (guild_cache && guild_cache->guild_id == guild_id)
		guild_cache = NULL;
	guild_storage_delete(guild_id);
	idb_remove(guild_db,guild_id);
	return 0;
}
Beispiel #16
0
// パーティメンバが脱退した
int party_member_leaved(int party_id,int account_id,char *name)
{
	struct map_session_data *sd=map_id2sd(account_id);
	struct party *p=party_search(party_id);
	if(p!=NULL){
		int i;
		for(i=0;i<MAX_PARTY;i++)
			if(p->member[i].account_id==account_id){
				clif_party_leaved(p,sd,account_id,name,0x00);
				p->member[i].account_id=0;
				p->member[i].sd=NULL;
			}
	}
	if(sd!=NULL && sd->status.party_id==party_id){
		sd->status.party_id=0;
		sd->state.party_sent=0;
		clif_charnameupdate(sd); //Update name display [Skotlex]
	}
	return 0;
}
Beispiel #17
0
//Innvoked on /breakguild "Guild name"
int guild_broken(int guild_id,int flag)
{
	struct guild *g=guild_search(guild_id);
	struct guild_castle *gc=NULL;
	struct map_session_data *sd;
	int i;
	char name[EVENT_NAME_LENGTH];

	if(flag!=0 || g==NULL)
		return 0;

	//we call castle_event::OnGuildBreak of all castlesof the guild
	//you can set all castle_events in the castle_db.txt
	for(i=0;i<MAX_GUILDCASTLE;i++){
		if( (gc=guild_castle_search(i)) != NULL ){
			if(gc->guild_id == guild_id){
				safestrncpy(name, gc->castle_event, 50);
				npc_event_do(strcat(name,"::OnGuildBreak"));
			}
		}
	}

	for(i=0;i<g->max_member;i++){	// ギルド解散を通知
		if((sd=g->member[i].sd)!=NULL){
			if(sd->state.storage_flag == 2)
				storage_guild_storage_quit(sd,1);
			sd->status.guild_id=0;
			clif_guild_broken(g->member[i].sd,0);
			clif_charnameupdate(sd); // [LuzZza]
		}
	}

	guild_db->foreach(guild_db,guild_broken_sub,guild_id);
	castle_db->foreach(castle_db,castle_guild_broken_sub,guild_id);
	guild_storage_delete(guild_id);
	idb_remove(guild_db,guild_id);
	return 0;
}
Beispiel #18
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;
}
Beispiel #19
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;
}
Beispiel #20
0
int bg_team_clean(int bg_id, bool remove)
{ // Deletes BG Team from db
	int i;
	struct map_session_data *sd;
	struct battleground_data *bg = bg_team_search(bg_id);
	struct guild *g;

	if( bg == NULL ) return 0;
	for( i = 0; i < MAX_BG_MEMBERS; i++ )
	{
		if( (sd = bg->members[i].sd) == NULL )
			continue;

		bg_send_dot_remove(sd);
		sd->bg_id = 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 )
			continue; // No need to touch Guild stuff

		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);
		}
		else
			clif_bg_leave_single(sd, sd->status.name, "Leaving Battleground...");

		clif_charnameupdate(sd);
		clif_guild_emblem_area(&sd->bl);
	}

	for( i = 0; i < MAX_GUILDSKILL; i++ )
	{
		if( bg->skill_block_timer[i] == INVALID_TIMER )
			continue;
		delete_timer(bg->skill_block_timer[i], bg_block_skill_end);
	}

	if( remove )
		idb_remove(bg_team_db, bg_id);
	else
	{
		bg->count = 0;
		bg->leader_char_id = 0;
		bg->team_score = 0;
		bg->creation_tick = 0;
		memset(&bg->members, 0, sizeof(bg->members));
	}

	return 1;
}
Beispiel #21
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;
}
Beispiel #22
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;
}
Beispiel #23
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;
}
Beispiel #24
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

	pc_update_last_action(sd,0); // Start count from here...
	sd->bg_id = bg_id;
	sd->bg_kills = 0;
	sd->state.bg_afk = 0;
	bg->members[i].sd = sd;
	bg->members[i].x = sd->bl.x;
	bg->members[i].y = sd->bl.y;
	bg->count++;

	if( bg->creation_tick == 0 ) bg->creation_tick = last_tick; // Creation Tick = First member joined.

	if( bg->leader_char_id == 0 )
	{ // First Join = Team Leader
		bg->leader_char_id = sd->status.char_id;
		sd->bmaster_flag = bg;
	}

	if( battle_config.bg_ranked_mode && sd->status.bgstats.rank_games < battle_config.bg_ranked_max_games && DIFF_TICK(last_tick,bg->creation_tick) < 60 )
	{
		char output[128];
		bg->members[i].ranked = true;
		sd->status.bgstats.rank_games++;
		sprintf(output,"-- RANKED BATTLEGROUND MATCH %d OF %d --", sd->status.bgstats.rank_games, battle_config.bg_ranked_max_games);
		clif_displaymessage(sd->fd,output);
	}

	guild_send_dot_remove(sd);
	if( battle_config.bg_eAmod_mode )
	{
		clif_bg_belonginfo(sd);
		clif_charnameupdate(sd);
	}

	for( i = 0; i < MAX_BG_MEMBERS; i++ )
	{
		if( (pl_sd = bg->members[i].sd) == NULL )
			continue;

		if( battle_config.bg_eAmod_mode )
		{ // Simulate Guild Information
			clif_guild_basicinfo(pl_sd);
			clif_bg_emblem(pl_sd, bg->g);
			clif_bg_memberlist(pl_sd);
		}

		if( pl_sd != sd )
			clif_bg_hp_single(sd->fd,pl_sd);
	}

	if( battle_config.bg_eAmod_mode ) clif_guild_emblem_area(&sd->bl);
	clif_bg_hp(sd);
	clif_bg_xy(sd);
	return 1;
}
Beispiel #25
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;
}