示例#1
0
//Request leave party
int mapif_parse_PartyLeave(int fd, int party_id, uint32 account_id, uint32 char_id, char *name, enum e_party_member_withdraw type)
{
	struct party_data *p;
	int i,j=-1;

	p = inter_party_fromsql(party_id);
	if( p == NULL )
	{// Party does not exists?
		if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", schema_config.char_db, party_id) )
			Sql_ShowDebug(sql_handle);
		return 0;
	}

	for (i = 0; i < MAX_PARTY; i++) {
		if(p->party.member[i].account_id == account_id &&
			p->party.member[i].char_id == char_id) {
			break;
		}
	}
	if (i >= MAX_PARTY)
		return 0; //Member not found?

	mapif_party_withdraw(party_id, account_id, char_id, name, type);

	if (p->party.member[i].leader){
		// TODO: Official allow 'leaderless' party
		p->party.member[i].account_id = 0;
		for (j = 0; j < MAX_PARTY; j++) {
			if (!p->party.member[j].account_id)
				continue;
			mapif_party_withdraw(party_id, p->party.member[j].account_id, p->party.member[j].char_id, p->party.member[j].name, type);
			p->party.member[j].account_id = 0;
		}
		//Party gets deleted on the check_empty call below.
	} else {
		inter_party_tosql(&p->party,PS_DELMEMBER,i);
		j = p->party.member[i].lv;
		if(p->party.member[i].online) p->party.count--;
		memset(&p->party.member[i], 0, sizeof(struct party_member));
		p->size--;
		if (j == p->min_lv || j == p->max_lv || p->family)
		{
			if(p->family) p->family = 0; //Family state broken.
			int_party_check_lv(p);
		}
	}

	if (party_check_empty(p) == 0)
		mapif_party_info(-1, &p->party, 0);
	return 0;
}
示例#2
0
// パ?ティ?退要求
int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id)
{
	struct party_data *p;
	int i,lv;

	p = (struct party_data*)idb_get(party_db, party_id);
	if (!p) return 0;

	for(i = 0; i < MAX_PARTY; i++) {
		if(p->party.member[i].account_id == account_id &&
			p->party.member[i].char_id == char_id)
		{
			mapif_party_withdraw(party_id, account_id, char_id);
			lv = p->party.member[i].lv;
			if(p->party.member[i].online) p->party.count--;
			memset(&p->party.member[i], 0, sizeof(struct party_member));
			p->size--;
			if (lv == p->min_lv || lv == p->max_lv || p->family)
			{
				if(p->family) p->family = 0; //Family state broken.
				int_party_check_lv(p);
			}
			if (party_check_empty(&p->party) == 0)
				mapif_party_info(-1, &p->party, 0);
			return 0;
		}
	}
	return 0;
}