Remove assignments in conditions

This commit is contained in:
hg
2020-01-29 18:34:33 -05:00
parent 371265d143
commit 9689787e56
3 changed files with 52 additions and 36 deletions
+24 -11
View File
@@ -283,10 +283,16 @@ Corpse::Corpse(Client* client, int32 in_rezexp) : Mob (
allowed_looters[i] = 0;
}
Group* grp = nullptr;
Raid* raid = nullptr;
consent_group_id = (client->AutoConsentGroupEnabled() && (grp = client->GetGroup())) ? grp->GetID() : 0;
consent_raid_id = (client->AutoConsentRaidEnabled() && (raid = client->GetRaid())) ? raid->GetID() : 0;
if (client->AutoConsentGroupEnabled()) {
Group* grp = client->GetGroup();
consent_group_id = grp ? grp->GetID() : 0;
}
if (client->AutoConsentRaidEnabled()) {
Raid* raid = client->GetRaid();
consent_raid_id = raid ? raid->GetID() : 0;
}
consent_guild_id = client->AutoConsentGuildEnabled() ? client->GuildID() : 0;
is_corpse_changed = true;
@@ -1474,13 +1480,20 @@ bool Corpse::Summon(Client* client, bool spell, bool CheckDistance) {
}
}
if (!consented) {
Group* grp = nullptr;
Raid* raid = nullptr;
if ((consent_guild_id && consent_guild_id != GUILD_NONE && client->GuildID() == consent_guild_id) ||
(consent_group_id && (grp = client->GetGroup()) && grp->GetID() == consent_group_id) ||
(consent_raid_id && (raid = client->GetRaid()) && raid->GetID() == consent_raid_id))
{
if (!consented && consent_guild_id && consent_guild_id != GUILD_NONE) {
if (client->GuildID() == consent_guild_id) {
consented = true;
}
}
if (!consented && consent_group_id) {
Group* grp = client->GetGroup();
if (grp && grp->GetID() == consent_group_id) {
consented = true;
}
}
if (!consented && consent_raid_id) {
Raid* raid = client->GetRaid();
if (raid && raid->GetID() == consent_raid_id) {
consented = true;
}
}
+7 -9
View File
@@ -1467,8 +1467,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
}
}
if (found_corpse)
{
if (found_corpse) {
// forward the grant/deny message for this zone to both owner and granted
auto outapp = new ServerPacket(ServerOP_Consent_Response, sizeof(ServerOP_Consent_Struct));
ServerOP_Consent_Struct* scs = (ServerOP_Consent_Struct*)outapp->pBuffer;
@@ -1484,10 +1483,9 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
}
case ServerOP_Consent_Response: {
ServerOP_Consent_Struct* s = (ServerOP_Consent_Struct*)pack->pBuffer;
if (s->consent_type == EQEmu::consent::Normal)
{
if (Client* client = entity_list.GetClientByName(s->grantname))
{
if (s->consent_type == EQEmu::consent::Normal) {
Client* grant_client = entity_list.GetClientByName(s->grantname);
if (grant_client) {
// send the message to the client being granted or denied permission
auto outapp = new EQApplicationPacket(OP_ConsentResponse, sizeof(ConsentResponse_Struct));
ConsentResponse_Struct* crs = (ConsentResponse_Struct*)outapp->pBuffer;
@@ -1495,12 +1493,12 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
strcpy(crs->ownername, s->ownername);
crs->permission = s->permission;
strn0cpy(crs->zonename, s->zonename, sizeof(crs->zonename));
client->QueuePacket(outapp);
grant_client->QueuePacket(outapp);
safe_delete(outapp);
}
}
if (Client* client = entity_list.GetClientByName(s->ownername))
{
Client* client = entity_list.GetClientByName(s->ownername);
if (client) {
// send owner consent/deny confirmation message
client->MessageString(Chat::White, s->message_string_id, s->grantname, s->zonename);
}