Implement consent for group/raid/guild and add Auto Consent support

Refactors consent to be more live accurate

Message sent to owner and receiver for each zone a corpse is in
Corpses now store consent list instead of clients holding corpse list
Consent throttling added
Message strings and colors updated
Removed reporting invalid consent targets
This commit is contained in:
hg
2020-01-26 20:53:59 -05:00
parent c82d08cf11
commit 63b8df72b2
10 changed files with 222 additions and 176 deletions
+53 -36
View File
@@ -1442,50 +1442,67 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
}
case ServerOP_Consent: {
ServerOP_Consent_Struct* s = (ServerOP_Consent_Struct*)pack->pBuffer;
Client* client = entity_list.GetClientByName(s->grantname);
if (client) {
if (s->permission == 1)
client->consent_list.push_back(s->ownername);
else
client->consent_list.remove(s->ownername);
auto outapp =
new EQApplicationPacket(OP_ConsentResponse, sizeof(ConsentResponse_Struct));
ConsentResponse_Struct* crs = (ConsentResponse_Struct*)outapp->pBuffer;
strcpy(crs->grantname, s->grantname);
strcpy(crs->ownername, s->ownername);
crs->permission = s->permission;
strcpy(crs->zonename, "all zones");
client->QueuePacket(outapp);
safe_delete(outapp);
bool found_corpse = false;
for (auto const& it : entity_list.GetCorpseList()) {
if (it.second->IsPlayerCorpse() && strcmp(it.second->GetOwnerName(), s->ownername) == 0) {
if (s->consent_type == EQEmu::consent::Normal) {
if (s->permission == 1) {
it.second->AddConsentName(s->grantname);
}
else {
it.second->RemoveConsentName(s->grantname);
}
}
else if (s->consent_type == EQEmu::consent::Group) {
it.second->SetConsentGroupID(s->consent_id);
}
else if (s->consent_type == EQEmu::consent::Raid) {
it.second->SetConsentRaidID(s->consent_id);
}
else if (s->consent_type == EQEmu::consent::Guild) {
it.second->SetConsentGuildID(s->consent_id);
}
found_corpse = true;
}
}
else {
// target not found
// Message string id's likely to be used here are:
// CONSENT_YOURSELF = 399
// CONSENT_INVALID_NAME = 397
// TARGET_NOT_FOUND = 101
auto scs_pack =
new ServerPacket(ServerOP_Consent_Response, sizeof(ServerOP_Consent_Struct));
ServerOP_Consent_Struct* scs = (ServerOP_Consent_Struct*)scs_pack->pBuffer;
strcpy(scs->grantname, s->grantname);
strcpy(scs->ownername, s->ownername);
scs->permission = s->permission;
scs->zone_id = s->zone_id;
scs->instance_id = s->instance_id;
scs->message_string_id = TARGET_NOT_FOUND;
worldserver.SendPacket(scs_pack);
safe_delete(scs_pack);
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;
memcpy(outapp->pBuffer, s, sizeof(ServerOP_Consent_Struct));
if (zone) {
strn0cpy(scs->zonename, zone->GetLongName(), sizeof(scs->zonename));
}
scs->message_string_id = s->permission ? GIVE_CONSENT : DENY_CONSENT;
worldserver.SendPacket(outapp);
safe_delete(outapp);
}
break;
}
case ServerOP_Consent_Response: {
ServerOP_Consent_Struct* s = (ServerOP_Consent_Struct*)pack->pBuffer;
Client* client = entity_list.GetClientByName(s->ownername);
if (client) {
client->MessageString(Chat::White, s->message_string_id);
if (s->consent_type == EQEmu::consent::Normal)
{
if (Client* client = entity_list.GetClientByName(s->grantname))
{
// 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;
strcpy(crs->grantname, s->grantname);
strcpy(crs->ownername, s->ownername);
crs->permission = s->permission;
strn0cpy(crs->zonename, s->zonename, sizeof(crs->zonename));
client->QueuePacket(outapp);
safe_delete(outapp);
}
}
if (Client* client = entity_list.GetClientByName(s->ownername))
{
// send owner consent/deny confirmation message
client->MessageString(Chat::White, s->message_string_id, s->grantname, s->zonename);
}
break;
}