From 57f226414fed86f5591d27fe029a76edccfbb8ac Mon Sep 17 00:00:00 2001 From: gumi Date: Wed, 3 Jan 2018 19:53:32 -0500 Subject: release v18.1.3 --- src/map/atcommand.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/map/atcommand.cpp') diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index 2e11227..718b6f0 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -3748,6 +3748,45 @@ ATCE atcommand_setpartyleader(Session *s, dumb_ptr sd, return ATCE::OKAY; } +static +ATCE atcommand_setleader(Session *s, dumb_ptr sd, + ZString message) +{ + CharName character; + short mask = 0; + int i = 0; + + if (!asplit(message, &character)) + return ATCE::USAGE; + + dumb_ptr pl_sd = map_nick2sd(character); + + if (pl_sd == nullptr || pl_sd->status.party_id == PartyId()) + return ATCE::EXIST; + + PartyPair p_ = TRY_UNWRAP(party_search(pl_sd->status.party_id), return ATCE::EXIST); + + for (i = 0; i < MAX_PARTY; i++) + { + if (p_->member[i].account_id == sd->status_key.account_id) + mask |= p_->member[i].leader ? 3 : 1; + + if (p_->member[i].account_id == pl_sd->status_key.account_id) + mask |= p_->member[i].leader ? 12 : 4; + + if (mask & 5) + break; + } + + if (!(mask & 2)) + return ATCE::PERM; + + intif_party_changeleader(pl_sd->status.party_id, pl_sd->status_key.account_id, (mask & 8) ? 0 : 1); + clif_displaymessage(s, "Party leader changed."_s); + + return ATCE::OKAY; +} + static ATCE atcommand_enablenpc(Session *s, dumb_ptr, ZString message) @@ -5338,6 +5377,9 @@ Map atcommand_info = {"setpartyleader"_s, {" "_s, 40, atcommand_setpartyleader, "Change the leader of a party"_s}}, + {"setleader"_s, {""_s, + 0, atcommand_setleader, + "Add/remove a leader to the current party"_s}}, {"mapexit"_s, {""_s, 99, atcommand_mapexit, "Try to kill the server kindly"_s}}, -- cgit v1.2.3-70-g09d2