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

View File

@ -1064,29 +1064,34 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) {
ServerOP_Consent_Struct* s = (ServerOP_Consent_Struct*)pack->pBuffer; ServerOP_Consent_Struct* s = (ServerOP_Consent_Struct*)pack->pBuffer;
ZoneServer* owner_zs = nullptr; ZoneServer* owner_zs = nullptr;
if ((s->instance_id != 0 && (owner_zs = zoneserver_list.FindByInstanceID(s->instance_id))) || if (s->instance_id == 0) {
(s->instance_id == 0 && (owner_zs = zoneserver_list.FindByZoneID(s->zone_id)))) owner_zs = zoneserver_list.FindByZoneID(s->zone_id);
{ }
else {
owner_zs = zoneserver_list.FindByInstanceID(s->instance_id);
}
if (owner_zs) {
owner_zs->SendPacket(pack); owner_zs->SendPacket(pack);
} }
else else {
{
LogInfo("Unable to locate zone record for zone id [{}] or instance id [{}] in zoneserver list for ServerOP_Consent_Response operation", s->zone_id, s->instance_id); LogInfo("Unable to locate zone record for zone id [{}] or instance id [{}] in zoneserver list for ServerOP_Consent_Response operation", s->zone_id, s->instance_id);
} }
if (s->consent_type == EQEmu::consent::Normal) if (s->consent_type == EQEmu::consent::Normal) {
{
// send the message to the client being granted or denied permission // send the message to the client being granted or denied permission
if (ClientListEntry* cle = client_list.FindCharacter(s->grantname)) ClientListEntry* cle = client_list.FindCharacter(s->grantname);
{ if (cle) {
ZoneServer* granted_zs = nullptr; ZoneServer* granted_zs = nullptr;
if ((cle->instance() != 0 && (granted_zs = zoneserver_list.FindByInstanceID(cle->instance()))) || if (cle->instance() == 0) {
(cle->instance() == 0 && (granted_zs = zoneserver_list.FindByZoneID(cle->zone())))) granted_zs = zoneserver_list.FindByZoneID(cle->zone());
{
// avoid sending twice if owner and granted are in same zone
if (granted_zs != owner_zs) {
granted_zs->SendPacket(pack);
} }
else {
granted_zs = zoneserver_list.FindByInstanceID(cle->instance());
}
// avoid sending twice if owner and granted are in same zone
if (granted_zs && granted_zs != owner_zs) {
granted_zs->SendPacket(pack);
} }
} }
} }

View File

@ -283,10 +283,16 @@ Corpse::Corpse(Client* client, int32 in_rezexp) : Mob (
allowed_looters[i] = 0; allowed_looters[i] = 0;
} }
Group* grp = nullptr; if (client->AutoConsentGroupEnabled()) {
Raid* raid = nullptr; Group* grp = client->GetGroup();
consent_group_id = (client->AutoConsentGroupEnabled() && (grp = client->GetGroup())) ? grp->GetID() : 0; consent_group_id = grp ? grp->GetID() : 0;
consent_raid_id = (client->AutoConsentRaidEnabled() && (raid = client->GetRaid())) ? raid->GetID() : 0; }
if (client->AutoConsentRaidEnabled()) {
Raid* raid = client->GetRaid();
consent_raid_id = raid ? raid->GetID() : 0;
}
consent_guild_id = client->AutoConsentGuildEnabled() ? client->GuildID() : 0; consent_guild_id = client->AutoConsentGuildEnabled() ? client->GuildID() : 0;
is_corpse_changed = true; is_corpse_changed = true;
@ -1474,13 +1480,20 @@ bool Corpse::Summon(Client* client, bool spell, bool CheckDistance) {
} }
} }
if (!consented) { if (!consented && consent_guild_id && consent_guild_id != GUILD_NONE) {
Group* grp = nullptr; if (client->GuildID() == consent_guild_id) {
Raid* raid = nullptr; consented = true;
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_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; consented = true;
} }
} }

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 // forward the grant/deny message for this zone to both owner and granted
auto outapp = new ServerPacket(ServerOP_Consent_Response, sizeof(ServerOP_Consent_Struct)); auto outapp = new ServerPacket(ServerOP_Consent_Response, sizeof(ServerOP_Consent_Struct));
ServerOP_Consent_Struct* scs = (ServerOP_Consent_Struct*)outapp->pBuffer; 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: { case ServerOP_Consent_Response: {
ServerOP_Consent_Struct* s = (ServerOP_Consent_Struct*)pack->pBuffer; ServerOP_Consent_Struct* s = (ServerOP_Consent_Struct*)pack->pBuffer;
if (s->consent_type == EQEmu::consent::Normal) if (s->consent_type == EQEmu::consent::Normal) {
{ Client* grant_client = entity_list.GetClientByName(s->grantname);
if (Client* client = entity_list.GetClientByName(s->grantname)) if (grant_client) {
{
// send the message to the client being granted or denied permission // send the message to the client being granted or denied permission
auto outapp = new EQApplicationPacket(OP_ConsentResponse, sizeof(ConsentResponse_Struct)); auto outapp = new EQApplicationPacket(OP_ConsentResponse, sizeof(ConsentResponse_Struct));
ConsentResponse_Struct* crs = (ConsentResponse_Struct*)outapp->pBuffer; 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); strcpy(crs->ownername, s->ownername);
crs->permission = s->permission; crs->permission = s->permission;
strn0cpy(crs->zonename, s->zonename, sizeof(crs->zonename)); strn0cpy(crs->zonename, s->zonename, sizeof(crs->zonename));
client->QueuePacket(outapp); grant_client->QueuePacket(outapp);
safe_delete(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 // send owner consent/deny confirmation message
client->MessageString(Chat::White, s->message_string_id, s->grantname, s->zonename); client->MessageString(Chat::White, s->message_string_id, s->grantname, s->zonename);
} }