예제 #1
0
// パーティ脱退要求
int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id)
{
	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'", 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_leaved(party_id, account_id, char_id);

	if (p->party.member[i].leader){
		p->party.member[i].account_id = 0;
		for (j = 0; j < MAX_PARTY; j++) {
			if (!p->party.member[j].account_id)
				continue;
			mapif_party_leaved(party_id, p->party.member[j].account_id, p->party.member[j].char_id);
			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);
	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 = 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_leaved(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);
			return 0;
		}
	}
	return 0;
}
예제 #3
0
// パーティ脱退要求
void mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id)
{
	const struct party *p1 = partydb_load_num(party_id);
	struct party p2;
	int i;

	if(p1 == NULL)
		return;

	memcpy(&p2,p1,sizeof(struct party));
	for(i=0;i<MAX_PARTY;i++){
		if(p2.member[i].account_id == account_id && p2.member[i].char_id == char_id)
		{
			mapif_party_leaved(party_id,account_id,p2.member[i].char_id,p2.member[i].name);
			memset(&p2.member[i],0,sizeof(struct party_member));

			if(fd >= 0) {
				// キャラ削除でない場合はパーティIDを0に初期化
				const struct mmo_chardata *cd = chardb_load(char_id);
				if(cd) {
					struct mmo_charstatus st;
					memcpy(&st, &cd->st, sizeof(st));
					st.party_id = 0;
					chardb_save(&st);
				}
			}

			if( party_check_empty(&p2) ) {
				// 空になったので解散
				mapif_party_broken(p2.party_id,0);
				partydb_delete(p2.party_id);
			} else {
				// まだ人がいるのでデータ送信
				mapif_party_info(-1,&p2);

				if( p2.exp>0 && !party_check_exp_share(&p2,0) ){
					p2.exp=0;
					mapif_party_optionchanged(fd,&p2,0,0);
				}
				partydb_save(&p2);
			}
			return;
		}
	}

	return;
}
예제 #4
0
// パーティ脱退要求
void mapif_parse_PartyLeave(int, int party_id, int account_id)
{
    struct party *p = party_db.search(party_id);
    if (!p)
        return;
    for (int i = 0; i < MAX_PARTY; i++)
    {
        if (p->member[i].account_id != account_id)
            continue;
        mapif_party_leaved(party_id, account_id, p->member[i].name);

        p->member[i] = party_member{};
        if (party_check_empty(p) == 0)
            mapif_party_info(-1, p);   // まだ人がいるのでデータ送信
        return;
    }
}
예제 #5
0
파일: int_party.c 프로젝트: OmarAcero/freya
//------------------------
// A member leaves a party
//------------------------
int mapif_parse_PartyLeave(int fd, int party_id, int account_id) {
	struct party *p;
	int i;

	p = numdb_search(party_db, (CPU_INT)party_id);
	if (p != NULL) {
		for(i = 0; i < MAX_PARTY; i++) {
			if (p->member[i].account_id == account_id) {
				mapif_party_leaved(party_id, account_id, p->member[i].name);

				memset(&p->member[i], 0, sizeof(struct party_member));
				if (party_check_empty(p) == 0)
					mapif_party_info(-1, p); // Sending party information to map-server // �܂��l������̂Ńf�[�^���M
				break;
			}
		}
	}

	return 0;
}
예제 #6
0
// パーティ脱退要求
int mapif_parse_PartyLeave(int fd,int party_id,int account_id)
{
	struct party *p=NULL;
	p=numdb_search(party_db,party_id);
	if(p!=NULL){
		int i;
		for(i=0;i<MAX_PARTY;i++){
			if(p->member[i].account_id==account_id){
				mapif_party_leaved(party_id,account_id,p->member[i].name);
				
				memset(&p->member[i],0,sizeof(struct party_member));
				if( party_check_empty(p)==0 )
					mapif_party_info(-1,p);// まだ人がいるのでデータ送信
				else
					inter_party_save();	// 解散したのでセーブ
				return 0;
			}
		}
	}
	return 0;
}
예제 #7
0
//------------------------
// A member leaves a party
//------------------------
int mapif_parse_PartyLeave(int fd, int party_id, int account_id) {
	char t_member[49]; // 24 * 2 + NULL
	int i, j;
	int flag;

	inter_party_fromsql(party_id); // fill party_tmp with informations of the party (or set all values to 0)

	if (party_tmp.party_id > 0) {
		for(i = 0; i < MAX_PARTY; i++) {
			if (party_tmp.member[i].account_id == account_id) {
				//printf("member leave the party #%d: account_id = %d.\n", party_id, account_id);
				mapif_party_leaved(party_id, account_id, party_tmp.member[i].name);

				// Update character information
				db_sql_escape_string(t_member, party_tmp.member[i].name, strlen(party_tmp.member[i].name));
				sql_request("UPDATE `%s` SET `party_id`='0' WHERE `account_id`='%d' AND `name`='%s'", char_db, account_id, t_member);
				// Update character in memory
				for(j = 0; j < char_num; j++)
					if (char_dat[j].account_id == account_id && strncmp(char_dat[j].name, party_tmp.member[i].name, 24) == 0) {
						char_dat[j].party_id = 0;
						break;
					}
				//printf("Delete member %s from party #%d.\n", p->member[i].name, party_id);

				// if it's leader, remove all other members
				if (party_tmp.member[i].leader == 1) {
					flag = 0;
					for(j = 0; j < MAX_PARTY; j++) {
						if (party_tmp.member[j].account_id > 0 && j != i) {
							mapif_party_leaved(party_id, party_tmp.member[j].account_id, party_tmp.member[j].name);
							flag++;
							//printf("Delete member %s from party #%d (Leader breaks party).\n", party_tmp->member[j].name, party_id);
						}
					}
					if (flag > 0) {
						// Update char information in database
						sql_request("UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id);
					}
					// Update characters in memory
					for(j = 0; j < char_num; j++)
						if (char_dat[j].party_id == party_id)
							char_dat[j].party_id = 0;
					// Delete the party.
					sql_request("DELETE FROM `%s` WHERE `party_id`='%d'", party_db, party_id);
					//printf("Leader breaks party #%d.\n", party_id);
					memset(&party_tmp, 0, sizeof(struct party));
					// remove party from memory
					for(j = 0; j < party_num; j++)
						if (partys[j].party_id == party_id) { // if found
							if (j != (party_num - 1))
								memcpy(&partys[j], &partys[party_num - 1], sizeof(struct party));
							party_num--;
							break;
						}
				} else {
					memset(&party_tmp.member[i], 0, sizeof(struct party_member));
					// Update party in memory (party_tmp is not pointer on &partys[j])
					for(j = 0; j < party_num; j++) {
						if (partys[j].party_id == party_id) { // if found
							memcpy(&partys[j], &party_tmp, sizeof(struct party));
							break;
						}
					}
 				}
				// leader is always the last member, but with deletion of char, that can be different
				if (party_check_empty(&party_tmp) == 0)
					mapif_party_info(-1, &party_tmp); // Sending party information to map-server // �܂��l������̂Ńf�[�^���M
				break;
			}
		}

	// party not found, suppress characters with this party
	} else {
		sql_request("UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id);
		// Update character in memory
		for(i = 0; i < char_num; i++)
			if (char_dat[i].party_id == party_id)
				char_dat[i].party_id = 0;
	}

	return 0;
}
예제 #8
0
// パーティ脱退要求
int mapif_parse_PartyLeave(int fd,int party_id,int account_id)
{
	char t_member[2*NAME_LENGTH];
	struct party *p = party_pt;
	if (p == NULL) {
		ShowFatalError("int_party: out of memory !\n");
		return 0;
	}

	inter_party_fromsql(party_id, p);
	if (p->party_id >= 0) {
		int i;
		for (i = 0; i < MAX_PARTY; i++) {
			if (p->member[i].account_id == account_id) {
				mapif_party_leaved(party_id, account_id, p->member[i].name);

				// Update char information, does the name need encoding?
				sprintf (tmp_sql, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d' AND `name`='%s'",
					char_db, party_id, jstrescapecpy(t_member,p->member[i].name));
				if (mysql_query (&mysql_handle, tmp_sql)) {
					ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
					ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
				}

				if (p->member[i].leader == 1){
					int j;
					for (j = 0; j < MAX_PARTY; j++) {
						if (p->member[j].account_id > 0 && j != i) {
							mapif_party_leaved(party_id, p->member[j].account_id, p->member[j].name);
						}
					}
					// we'll skip name-checking and just reset everyone with the same party id [celest]
					// -- if anything goes wrong just uncomment the section above ^^;
					sprintf (tmp_sql, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id);
					if (mysql_query(&mysql_handle, tmp_sql)) {
						ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
						ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
					}
					// Delete the party, if has no member.
					sprintf(tmp_sql, "DELETE FROM `%s` WHERE `party_id`='%d'", party_db, party_id);
					if (mysql_query(&mysql_handle, tmp_sql)) {
						ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
						ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
					}
					memset(p, 0, sizeof(struct party));
				} else
					memset(&p->member[i], 0, sizeof(struct party_member));
				break;
			}
		}

		if (party_check_empty(p) == 0)
			mapif_party_info(-1,p);// まだ人がいるのでデータ送信
		//else
		//	inter_party_tosql(party_id,p);	// Break the party if no member
	} else {
		sprintf(tmp_sql, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d' AND `account_id`='%d' AND `online`='1'",
			char_db, party_id, account_id);
		if (mysql_query(&mysql_handle, tmp_sql)) {
			ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
			ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
		}
	}
	return 0;
}
예제 #9
0
// パーティ脱退要求
int mapif_parse_PartyLeave(int fd,int party_id,int account_id)
{
	struct party *p = party_pt;
	if(p==NULL){
		printf("int_party: out of memory !\n");
		return 0;
	}
	
	inter_party_fromsql(party_id, p);
	
	if(p->party_id >= 0){
		int i,j;
		for(i=0;i<MAX_PARTY;i++){
			
			if(p->member[i].account_id==account_id){
				//printf("p->member[i].account_id = %d , account_id = %d \n",p->member[i].account_id,account_id);
				mapif_party_leaved(party_id,account_id,p->member[i].name);
				
				
				char t_memname[256];
				jstrescapecpy(t_memname, p->member[i].name);
				// Update char information, does the name need encoding?
				sprintf(tmp_sql,"UPDATE `char` SET `party_id`='0', `online`='1' WHERE `party_id`='%d' AND BINARY `name`='%s';", 
					party_id, t_memname);	
				if(mysql_query(&mysql_handle, tmp_sql) ) {
					printf("DB server Error (update `char`)- %s\n", mysql_error(&mysql_handle) );
				}
				printf("Delete member %s from MySQL \n", p->member[i].name);	
						
				if (p->member[i].leader==1){
					for(j=0;j<MAX_PARTY;j++)
					{
						//printf("j = %d , p->member[j].account_id = %d , p->member[j].account_id = %d \n",j,p->member[j].account_id,p->member[j].account_id);
						if(p->member[j].account_id>0&&j!=i){
							mapif_party_leaved(party_id,p->member[j].account_id,p->member[j].name);
							// Update char information, does the name need encoding?
							char t_memname[256];
							jstrescapecpy(t_memname,p->member[j].name);
							sprintf(tmp_sql,"UPDATE `char` SET `party_id`='0', `online`='1' WHERE `party_id`='%d' AND BINARY `name`='%s';", 
								party_id, t_memname);	
							if(mysql_query(&mysql_handle, tmp_sql) ) {
								printf("DB server Error (update `char`)- %s\n", mysql_error(&mysql_handle) );
							}
							printf("Delete member %s from MySQL \n", p->member[j].name);	
						}
					}
					// Delete the party, if has no member.
					sprintf(tmp_sql,"DELETE FROM `party` WHERE `party_id`='%d'",party_id);
					if(mysql_query(&mysql_handle, tmp_sql) ) {
						printf("DB server Error - %s\n", mysql_error(&mysql_handle) );
					}
					printf("Leader breaks party %d \n",party_id);
					memset(p, 0, sizeof(struct party));					
				}else memset(&p->member[i],0,sizeof(struct party_member));
				
				break;

			}
		}
		if( party_check_empty(p)==0 )
			mapif_party_info(-1,p);// まだ人がいるのでデータ送信
		/*
		else
			inter_party_tosql(party_id,p);	// Break the party if no member
		*/
	}
	return 0;
}