Skip to content

Commit

Permalink
Adds src/config option ''PARTY_LEADER_LEAVE' which disbands party whe…
Browse files Browse the repository at this point in the history
…n the leader leaves.
  • Loading branch information
bWolfie committed Feb 25, 2019
1 parent 4232145 commit c879dd0
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 10 deletions.
45 changes: 35 additions & 10 deletions src/char/int_party.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,40 +449,65 @@ static bool inter_party_change_option(int party_id, int account_id, int exp, int
//Request leave party
static bool inter_party_leave(int party_id, int account_id, int char_id)
{
struct party_data *p;
int i,j;
struct party_data *p = inter_party->fromsql(party_id);

p = inter_party->fromsql(party_id);
if( p == NULL )
{// Party does not exists?
if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id) )
if (p == NULL) { // Party does not exists?
if (SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `party_id` = '0' WHERE `party_id` = '%d'", char_db, party_id))
Sql_ShowDebug(inter->sql_handle);
return false;
}

int i, j;
for (i = 0; i < MAX_PARTY; i++) {
if(p->party.member[i].account_id == account_id &&
p->party.member[i].char_id == char_id) {
if (p->party.member[i].account_id == account_id && p->party.member[i].char_id == char_id)
break;
}
}

if (i >= MAX_PARTY)
return false; //Member not found?

mapif->party_withdraw(party_id, account_id, char_id);

#ifdef PARTY_LEADER_LEAVE
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;
}
//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 > 0)
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);
}
}
#else
j = p->party.member[i].lv;
if (p->party.member[i].online > 0)
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.
if (p->family)
p->family = 0; //Family state broken.
inter_party->check_lv(p);
}
#endif

if (inter_party->check_empty(p) == 0) {
#ifndef PARTY_LEADER_LEAVE
inter_party->tosql(&p->party, PS_DELMEMBER, i);
#endif
mapif->party_info(-1, &p->party, 0);
}
return true;
Expand Down
6 changes: 6 additions & 0 deletions src/config/classes/general.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
**/
//#define DEVOTION_REFLECT_DAMAGE

/**
* when enabled, parties will be disbanded if its leader leaves the party
* uncomment to enable
**/
//#define PARTY_LEADER_LEAVE

/**
* No settings past this point
**/
Expand Down

0 comments on commit c879dd0

Please sign in to comment.