summaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/char/int_party.c42
-rw-r--r--src/map/party.c12
2 files changed, 36 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);
}
}
diff --git a/src/map/party.c b/src/map/party.c
index 3bf9542c7..1a9ac1cbe 100644
--- a/src/map/party.c
+++ b/src/map/party.c
@@ -300,6 +300,18 @@ int party_recv_info(const struct party *sp, int char_id)
if (i == MAX_PARTY)
added[added_count++] = member_id;
}
+
+ ARR_FIND(0, MAX_PARTY, j, p->party.member[j].leader == 1);
+ if( j == MAX_PARTY ) {
+ // Leader has changed
+ int i;
+ ARR_FIND(0, MAX_PARTY, i, sp->member[i].leader == 1);
+ if( i < MAX_PARTY ) {
+ clif->PartyLeaderChanged(map->id2sd(sp->member[i].account_id), 0, sp->member[i].account_id);
+ } else {
+ party->broken(p->party.party_id); // Should not happen, Party is leaderless, disband
+ }
+ }
} else {
for( member_id = 0; member_id < MAX_PARTY; ++member_id )
if( sp->member[member_id].char_id != 0 )