Allow leaderless party (#1980)

* Fixed some misc. stuff

* Allow for leaderless party.
This commit is contained in:
Matheus Macabu 2017-11-02 12:32:33 +03:00 committed by Cydh Ramdh
parent c09929aa16
commit f86bb39df8
2 changed files with 17 additions and 21 deletions

View File

@ -177,6 +177,13 @@ int inter_party_tosql(struct party *p, int flag, int index)
Sql_ShowDebug(sql_handle); Sql_ShowDebug(sql_handle);
} }
if( flag & PS_DELLEADER )
{// Remove leader status
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `leader_id`='0', `leader_char`='0' WHERE `party_id`='%d'",
schema_config.party_db, party_id) )
Sql_ShowDebug(sql_handle);
}
if( charserv_config.save_log ) if( charserv_config.save_log )
ShowInfo("Party Saved (%d - %s)\n", party_id, p->name); ShowInfo("Party Saved (%d - %s)\n", party_id, p->name);
return 1; return 1;
@ -647,27 +654,15 @@ int mapif_parse_PartyLeave(int fd, int party_id, uint32 account_id, uint32 char_
mapif_party_withdraw(party_id, account_id, char_id, name, type); mapif_party_withdraw(party_id, account_id, char_id, name, type);
if (p->party.member[i].leader){ inter_party_tosql(&p->party, PS_DELMEMBER|((p->party.member[i].leader) ? PS_DELLEADER : 0x00), i);
// TODO: Official allow 'leaderless' party j = p->party.member[i].lv;
p->party.member[i].account_id = 0; if(p->party.member[i].online) p->party.count--;
for (j = 0; j < MAX_PARTY; j++) { memset(&p->party.member[i], 0, sizeof(struct party_member));
if (!p->party.member[j].account_id) p->size--;
continue; if (j == p->min_lv || j == p->max_lv || p->family)
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; if(p->family) p->family = 0; //Family state broken.
} int_party_check_lv(p);
//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) if (party_check_empty(p) == 0)

View File

@ -16,6 +16,7 @@ enum {
PS_ADDMEMBER = 0x08, //Specify new party member (index specifies which party member) PS_ADDMEMBER = 0x08, //Specify new party member (index specifies which party member)
PS_DELMEMBER = 0x10, //Specify member that left (index specifies which party member) PS_DELMEMBER = 0x10, //Specify member that left (index specifies which party member)
PS_BREAK = 0x20, //Specify that this party must be deleted. PS_BREAK = 0x20, //Specify that this party must be deleted.
PS_DELLEADER = 0x40, //Specify that member that left is also the leader of the party
}; };
struct party; struct party;