summaryrefslogtreecommitdiff
path: root/src/char/int_party.c
diff options
context:
space:
mode:
authorKirieZ <guilherme.menaldo@outlook.com>2016-12-18 18:54:40 -0200
committerKirieZ <guilherme.menaldo@outlook.com>2016-12-18 18:54:40 -0200
commitea449a7a5720335ff1b19ef0f3b97361c606355e (patch)
treefb7f341d8f8f3fbde19bb46175f18a374925a457 /src/char/int_party.c
parent9795505a14327d5d2603a1d756633485e7e2ba94 (diff)
downloadhercules-ea449a7a5720335ff1b19ef0f3b97361c606355e.tar.gz
hercules-ea449a7a5720335ff1b19ef0f3b97361c606355e.tar.bz2
hercules-ea449a7a5720335ff1b19ef0f3b97361c606355e.tar.xz
hercules-ea449a7a5720335ff1b19ef0f3b97361c606355e.zip
Changed behavior when party leader leaves it from party being disbanded to leader being changed to the second user. Closes #1107
Diffstat (limited to 'src/char/int_party.c')
-rw-r--r--src/char/int_party.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/src/char/int_party.c b/src/char/int_party.c
index 2fc39c328..a7adea30d 100644
--- a/src/char/int_party.c
+++ b/src/char/int_party.c
@@ -614,6 +614,7 @@ int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id)
{
struct party_data *p;
int i,j;
+ unsigned int leader;
p = inter_party->fromsql(party_id);
if( p == NULL )
@@ -634,25 +635,30 @@ int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id)
mapif->party_withdraw(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_withdraw(party_id, p->party.member[j].account_id, p->party.member[j].char_id);
- p->party.member[j].account_id = 0;
+ leader = p->party.member[i].leader; // member's leader state
+
+ 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.
+ inter_party->check_lv(p);
+ }
+
+ if( leader ) {
+ // Member was party leader, pick a new leader
+ i = 0;
+ while (i < MAX_PARTY && p->party.member[i].account_id == 0) {
+ i++;
}
- //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.
- inter_party->check_lv(p);
+
+ if( i < MAX_PARTY ) {
+ // Update party's leader
+ p->party.member[i].leader = 1;
+ inter_party->tosql(&p->party, PS_LEADER, i);
}
}