Beispiel #1
0
//Calculates the state of a party.
static void int_party_calc_state(struct party_data *p)
{
	int i;
	unsigned int lv;
	p->min_lv = UINT_MAX;
	p->max_lv = 0;
	p->party.count =
	p->size =
	p->family = 0;

	//Check party size.
	for(i=0;i<MAX_PARTY;i++){
		if (!p->party.member[i].lv) continue;
		p->size++;
		if(p->party.member[i].online)
			p->party.count++;
	}
	if(p->size == 3) {
		//Check Family State.
		p->family = char_family(
			p->party.member[0].char_id,
			p->party.member[1].char_id,
			p->party.member[2].char_id
		);
	}
	//max/min levels.
	for(i=0;i<MAX_PARTY;i++){
		lv=p->party.member[i].lv;
		if (!lv) continue;
		if(p->party.member[i].online &&
			//On families, the kid is not counted towards exp share rules.
			p->party.member[i].char_id != p->family)
		{
			if( lv < p->min_lv ) p->min_lv=lv;
			if( p->max_lv < lv ) p->max_lv=lv;
		}
	}

	if (p->party.exp && !party_check_exp_share(p)) {
		p->party.exp = 0; //Set off even share.
		mapif_party_optionchanged(0, &p->party, 0, 0);
	}
	return;
}
Beispiel #2
0
// パーティー設定変更要求
int mapif_parse_PartyChangeOption(int fd,int party_id,int account_id,int exp,int item)
{
	struct party_data *p;
	int flag = 0;
	p = inter_party_fromsql(party_id);

	if(!p)
		return 0;

	p->party.exp=exp;
	if( exp && !party_check_exp_share(p) ){
		flag|=0x01;
		p->party.exp=0;
	}
	p->party.item = item&0x3; //Filter out invalid values.
	mapif_party_optionchanged(fd,&p->party,account_id,flag);
	inter_party_tosql(&p->party, PS_BASIC, 0);
	return 0;
}
Beispiel #3
0
// パーティ追加要求
int mapif_parse_PartyAddMember(int fd,int party_id,int account_id,char *nick,char *map,int lv)
{
	struct party *p;
	int i;
	
	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){
		mapif_party_memberadded(fd,party_id,account_id,1);
		return 0;
	}
	
	for(i=0;i<MAX_PARTY;i++){
		if(p->member[i].account_id==0){
			int flag=0;
			
			p->member[i].account_id=account_id;
			memcpy(p->member[i].name,nick,24);
			memcpy(p->member[i].map,map,16);
			p->member[i].leader=0;
			p->member[i].online=1;
			p->member[i].lv=lv;
			mapif_party_memberadded(fd,party_id,account_id,0);
			mapif_party_info(-1,p);

			if( p->exp>0 && !party_check_exp_share(p) ){
				p->exp=0;
				flag=0x01;
			}
			if(flag)
				mapif_party_optionchanged(fd,p,0,0);
			return 0;
		}
	}
	mapif_party_memberadded(fd,party_id,account_id,1);
	inter_party_tosql(party_id, p);
	return 0;
}
Beispiel #4
0
// パーティー設定変更要求
static
void mapif_parse_PartyChangeOption(int fd, int party_id, int account_id,
        int exp, int item)
{
    struct party *p = party_db.search(party_id);
    if (p == NULL)
        return;

    p->exp = exp;
    int flag = 0;
    if (exp > 0 && !party_check_exp_share(p))
    {
        flag |= 0x01;
        p->exp = 0;
    }

    p->item = item;

    mapif_party_optionchanged(fd, p, account_id, flag);
}
Beispiel #5
0
//Checks whether the even-share setting of a party is broken when a character logs in. [Skotlex]
int inter_party_logged(int party_id, int account_id)
{
	struct party *p = party_pt;
	if(p==NULL){
		ShowFatalError("int_party: out of memory !\n");
		return 0;
	}
	if (!party_id)
		return 0;
		
	inter_party_fromsql(party_id, p);

	if(p->party_id && p->exp == 1 && !party_check_exp_share(p))
	{
		p->exp=0;
		mapif_party_optionchanged(0,p,0,0);
		return 1;
	}
	return 0;
}
Beispiel #6
0
//---------------------------
// Adding a member in a party
//---------------------------
void mapif_parse_PartyAddMember(int fd, int party_id, int account_id, char *nick, char *map, int lv) {
	int i;

	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) { // party doesn't exist
		mapif_party_memberadded(fd, party_id, account_id, 1);
		return;
	}

	for(i = 0; i < MAX_PARTY; i++) {
		if (party_tmp.member[i].account_id == 0) { // must we check if an other character of same account is in the party?
			party_tmp.member[i].account_id = account_id;
			memset(party_tmp.member[i].name, 0, sizeof(party_tmp.member[i].name));
			strncpy(party_tmp.member[i].name, nick, 24);
			memset(party_tmp.member[i].map, 0, sizeof(party_tmp.member[i].map));
			strncpy(party_tmp.member[i].map, map, 16); // 17 - NULL
			party_tmp.member[i].leader = 0;
			party_tmp.member[i].online = 1;
			party_tmp.member[i].lv = lv;
			mapif_party_memberadded(fd, party_id, account_id, 0);
			mapif_party_info(-1, &party_tmp);
			// Update character in memory
			for(i = 0; i < char_num; i++)
				if (char_dat[i].account_id == account_id && memcmp(char_dat[i].name, nick, 24) == 0) {
					char_dat[i].party_id = party_tmp.party_id;
					break;
				}

			if (party_tmp.exp > 0 && !party_check_exp_share(&party_tmp)) {
				party_tmp.exp = 0;
				mapif_party_optionchanged(fd, &party_tmp, 0, 0);
			}
			inter_party_tosql(party_id, &party_tmp);
			return;
		}
	}
	mapif_party_memberadded(fd, party_id, account_id, 1);

	return;
}
Beispiel #7
0
//Updates party's level range and unsets even share if broken.
static int int_party_check_lv(struct party_data *p) {
	int i;
	unsigned int lv;
	p->min_lv = UINT_MAX;
	p->max_lv = 0;
	for(i=0;i<MAX_PARTY;i++){
		if(!p->party.member[i].online)
			continue;

		lv=p->party.member[i].lv;
		if (lv < p->min_lv) p->min_lv = lv;
		if (lv > p->max_lv) p->max_lv = lv;
	}

	if (p->party.exp && !party_check_exp_share(p)) {
		p->party.exp = 0;
		mapif_party_optionchanged(0, &p->party, 0, 0);
		return 0;
	}
	return 1;
}
Beispiel #8
0
//--------------------------------------
// Request to change a option in a party
//--------------------------------------
void mapif_parse_PartyChangeOption(int fd, int party_id, int account_id, unsigned short exp, unsigned char item) {
	struct party *p;
	int flag;

	p = numdb_search(party_db, (CPU_INT)party_id);
	if (p == NULL)
		return;

	flag = 0;
	p->exp = exp;
	if (exp > 0 && !party_check_exp_share(p)) {
		flag = 1;
		p->exp = 0;
	}

	p->item = item;

	mapif_party_optionchanged(fd, p, account_id, flag);

	return;
}
Beispiel #9
0
// パーティ追加要求
int mapif_parse_PartyAddMember(int fd,int party_id,int account_id,int char_id,const char *nick,const char *map,int lv)
{
	const struct party *p1 = partydb_load_num(party_id);
	struct party p2;
	int i;

	if(p1 == NULL){
		mapif_party_memberadded(fd, party_id, account_id, char_id, nick, 1);
		return 0;
	}
	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)
			break;
		if(p2.member[i].account_id == 0) {
			p2.member[i].account_id = account_id;
			p2.member[i].char_id    = char_id;
			memcpy(p2.member[i].name,nick,24);
			p2.member[i].name[23] = '\0';	// force \0 terminal
			memcpy(p2.member[i].map,map,16);
			p2.member[i].map[15] = '\0';	// force \0 terminal
			p2.member[i].leader  = 0;
			p2.member[i].online  = 1;
			p2.member[i].lv=lv;
			mapif_party_memberadded(fd, party_id, account_id, char_id, nick, 0);
			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 0;
		}
	}
	mapif_party_memberadded(fd, party_id, account_id, char_id, nick, 1);
	partydb_save(&p2);
	return 0;
}
Beispiel #10
0
// パーティー設定変更要求
int mapif_parse_PartyChangeOption(int fd,int party_id,int account_id,int baby_id,unsigned char exp,unsigned char item)
{
	const struct party *p1 = partydb_load_num(party_id);
	struct party p2;
	int flag=0;

	if(p1 == NULL){
		return 0;
	}
	memcpy(&p2,p1,sizeof(struct party));

	p2.exp = exp;
	if( exp>0 && !party_check_exp_share(&p2,baby_id) ){
		flag|=0x01;
		p2.exp=0;
	}
	p2.item = item;

	mapif_party_optionchanged(fd,&p2,account_id,flag);
	partydb_save(&p2);
	return 0;
}
Beispiel #11
0
//--------------------------------------
// Request to change a option in a party
//--------------------------------------
void mapif_parse_PartyChangeOption(int fd, int party_id, int account_id, unsigned short exp, unsigned char item) {
	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) // party doesn't exist
		return;

	flag = 0;
	party_tmp.exp = exp;
	if (exp > 0 && !party_check_exp_share(&party_tmp)) {
		flag = 1;
		party_tmp.exp = 0;
	}

	party_tmp.item = item;

	mapif_party_optionchanged(fd, &party_tmp, account_id, flag);
	inter_party_tosql(party_id, &party_tmp);

	return;
}
Beispiel #12
0
// パーティ追加要求
static
void mapif_parse_PartyAddMember(int fd, int party_id, int account_id,
        CharName nick, MapName map, int lv)
{
    struct party *p = party_db.search(party_id);
    if (p == NULL)
    {
        mapif_party_memberadded(fd, party_id, account_id, 1);
        return;
    }

    for (int i = 0; i < MAX_PARTY; i++)
    {
        if (p->member[i].account_id == 0)
        {
            int flag = 0;

            p->member[i].account_id = account_id;
            p->member[i].name = nick;
            p->member[i].map = map;
            p->member[i].leader = 0;
            p->member[i].online = 1;
            p->member[i].lv = lv;
            mapif_party_memberadded(fd, party_id, account_id, 0);
            mapif_party_info(-1, p);

            if (p->exp > 0 && !party_check_exp_share(p))
            {
                p->exp = 0;
                flag = 0x01;
            }
            if (flag)
                mapif_party_optionchanged(fd, p, 0, 0);
            return;
        }
    }
    mapif_party_memberadded(fd, party_id, account_id, 1);
}
Beispiel #13
0
//Updates party's level range and unsets even share if broken.
static int int_party_check_lv(struct party_data *p) {
	int i;
	unsigned int lv;
	p->min_lv = UINT_MAX;
	p->max_lv = 0;
	for(i=0;i<MAX_PARTY;i++){
		/**
		 * - If not online OR if it's a family party and this is the child (doesn't affect exp range)
		 **/
		if(!p->party.member[i].online || p->party.member[i].char_id == p->family )
			continue;

		lv=p->party.member[i].lv;
		if (lv < p->min_lv) p->min_lv = lv;
		if (lv > p->max_lv) p->max_lv = lv;
	}

	if (p->party.exp && !party_check_exp_share(p)) {
		p->party.exp = 0;
		mapif_party_optionchanged(0, &p->party, 0, 0);
		return 0;
	}
	return 1;
}
Beispiel #14
0
// When member goes to other map
int mapif_parse_PartyChangeMap(int fd,int party_id,int account_id,char *map,int online,int lv)
{
	struct party *p;
	int i;
	
	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){
		return 0;
	}
	for(i=0;i<MAX_PARTY;i++){
		if(p->member[i].account_id==account_id){
			int flag=0;
			
			memcpy(p->member[i].map,map,16);
			p->member[i].online=online;
			p->member[i].lv=lv;
			mapif_party_membermoved(p,i);

			if( p->exp>0 && !party_check_exp_share(p) ){
				p->exp=0;
				flag=1;
			}
			if(flag)
				mapif_party_optionchanged(fd,p,0,0);
			break;
		}
	}
	inter_party_tosql(party_id, p);
	return 0;
}