mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 14:41:28 +00:00
Make consent variable names more descriptive and replace char pointer parameters with std::string
Use fmt::format for SQL statement when updating corpse guild id
This commit is contained in:
parent
b8229c8459
commit
d7138e84c0
@ -6255,12 +6255,9 @@ void Client::DragCorpses()
|
||||
}
|
||||
}
|
||||
|
||||
void Client::ConsentCorpses(const char* consent_name, bool deny)
|
||||
void Client::ConsentCorpses(std::string consent_name, bool deny)
|
||||
{
|
||||
if (!consent_name) {
|
||||
return;
|
||||
}
|
||||
else if (strcasecmp(consent_name, GetName()) == 0) {
|
||||
if (strcasecmp(consent_name.c_str(), GetName()) == 0) {
|
||||
MessageString(Chat::Red, CONSENT_YOURSELF);
|
||||
}
|
||||
else if (!consent_throttle_timer.Check()) {
|
||||
@ -6269,7 +6266,7 @@ void Client::ConsentCorpses(const char* consent_name, bool deny)
|
||||
else {
|
||||
auto pack = new ServerPacket(ServerOP_Consent, sizeof(ServerOP_Consent_Struct));
|
||||
ServerOP_Consent_Struct* scs = (ServerOP_Consent_Struct*)pack->pBuffer;
|
||||
strn0cpy(scs->grantname, consent_name, sizeof(scs->grantname));
|
||||
strn0cpy(scs->grantname, consent_name.c_str(), sizeof(scs->grantname));
|
||||
strn0cpy(scs->ownername, GetName(), sizeof(scs->ownername));
|
||||
strn0cpy(scs->zonename, "Unknown", sizeof(scs->zonename));
|
||||
scs->permission = deny ? 0 : 1;
|
||||
|
||||
@ -1139,7 +1139,7 @@ public:
|
||||
inline bool IsDraggingCorpse() { return (DraggedCorpses.size() > 0); }
|
||||
void DragCorpses();
|
||||
inline void ClearDraggedCorpses() { DraggedCorpses.clear(); }
|
||||
void ConsentCorpses(const char* consent_name, bool deny = false);
|
||||
void ConsentCorpses(std::string consent_name, bool deny = false);
|
||||
void SendAltCurrencies();
|
||||
void SetAlternateCurrencyValue(uint32 currency_id, uint32 new_amount);
|
||||
void AddAlternateCurrencyValue(uint32 currency_id, int32 amount, int8 method = 0);
|
||||
|
||||
@ -138,7 +138,7 @@ Corpse* Corpse::LoadCharacterCorpseEntity(uint32 in_dbid, uint32 in_charid, std:
|
||||
pc->drakkin_details = pcs->drakkin_details;
|
||||
pc->IsRezzed(rezzed);
|
||||
pc->become_npc = false;
|
||||
pc->consent_guild_id = guild_consent_id;
|
||||
pc->consented_guild_id = guild_consent_id;
|
||||
|
||||
pc->UpdateEquipmentLight(); // itemlist populated above..need to determine actual values
|
||||
|
||||
@ -285,15 +285,15 @@ Corpse::Corpse(Client* client, int32 in_rezexp) : Mob (
|
||||
|
||||
if (client->AutoConsentGroupEnabled()) {
|
||||
Group* grp = client->GetGroup();
|
||||
consent_group_id = grp ? grp->GetID() : 0;
|
||||
consented_group_id = grp ? grp->GetID() : 0;
|
||||
}
|
||||
|
||||
if (client->AutoConsentRaidEnabled()) {
|
||||
Raid* raid = client->GetRaid();
|
||||
consent_raid_id = raid ? raid->GetID() : 0;
|
||||
consented_raid_id = raid ? raid->GetID() : 0;
|
||||
}
|
||||
|
||||
consent_guild_id = client->AutoConsentGuildEnabled() ? client->GuildID() : 0;
|
||||
consented_guild_id = client->AutoConsentGuildEnabled() ? client->GuildID() : 0;
|
||||
|
||||
is_corpse_changed = true;
|
||||
rez_experience = in_rezexp;
|
||||
@ -624,11 +624,11 @@ bool Corpse::Save() {
|
||||
|
||||
/* Create New Corpse*/
|
||||
if (corpse_db_id == 0) {
|
||||
corpse_db_id = database.SaveCharacterCorpse(char_id, corpse_name, zone->GetZoneID(), zone->GetInstanceID(), dbpc, m_Position, consent_guild_id);
|
||||
corpse_db_id = database.SaveCharacterCorpse(char_id, corpse_name, zone->GetZoneID(), zone->GetInstanceID(), dbpc, m_Position, consented_guild_id);
|
||||
}
|
||||
/* Update Corpse Data */
|
||||
else{
|
||||
corpse_db_id = database.UpdateCharacterCorpse(corpse_db_id, char_id, corpse_name, zone->GetZoneID(), zone->GetInstanceID(), dbpc, m_Position, consent_guild_id, IsRezzed());
|
||||
corpse_db_id = database.UpdateCharacterCorpse(corpse_db_id, char_id, corpse_name, zone->GetZoneID(), zone->GetInstanceID(), dbpc, m_Position, consented_guild_id, IsRezzed());
|
||||
}
|
||||
|
||||
safe_delete_array(dbpc);
|
||||
@ -660,27 +660,23 @@ void Corpse::DepopPlayerCorpse() {
|
||||
player_corpse_depop = true;
|
||||
}
|
||||
|
||||
void Corpse::AddConsentName(const char* add_name)
|
||||
void Corpse::AddConsentName(std::string consent_player_name)
|
||||
{
|
||||
if (add_name) {
|
||||
for (const auto& n : consent_names) {
|
||||
if (strcasecmp(n.c_str(), add_name) == 0) {
|
||||
return;
|
||||
}
|
||||
for (const auto& consented_player_name : consented_player_names) {
|
||||
if (strcasecmp(consented_player_name.c_str(), consent_player_name.c_str()) == 0) {
|
||||
return;
|
||||
}
|
||||
consent_names.emplace_back(add_name);
|
||||
}
|
||||
consented_player_names.emplace_back(consent_player_name);
|
||||
}
|
||||
|
||||
void Corpse::RemoveConsentName(const char* rem_name)
|
||||
void Corpse::RemoveConsentName(std::string consent_player_name)
|
||||
{
|
||||
if (rem_name) {
|
||||
consent_names.erase(std::remove_if(consent_names.begin(), consent_names.end(),
|
||||
[rem_name](const std::string& n) {
|
||||
return strcasecmp(n.c_str(), rem_name) == 0;
|
||||
}
|
||||
), consent_names.end());
|
||||
}
|
||||
consented_player_names.erase(std::remove_if(consented_player_names.begin(), consented_player_names.end(),
|
||||
[consent_player_name](const std::string& consented_player_name) {
|
||||
return strcasecmp(consented_player_name.c_str(), consent_player_name.c_str()) == 0;
|
||||
}
|
||||
), consented_player_names.end());
|
||||
}
|
||||
|
||||
uint32 Corpse::CountItems() {
|
||||
@ -1477,27 +1473,27 @@ bool Corpse::Summon(Client* client, bool spell, bool CheckDistance) {
|
||||
else
|
||||
{
|
||||
bool consented = false;
|
||||
for (const auto& n : consent_names) {
|
||||
if (strcasecmp(client->GetName(), n.c_str()) == 0) {
|
||||
for (const auto& consented_player_name : consented_player_names) {
|
||||
if (strcasecmp(client->GetName(), consented_player_name.c_str()) == 0) {
|
||||
consented = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!consented && consent_guild_id && consent_guild_id != GUILD_NONE) {
|
||||
if (client->GuildID() == consent_guild_id) {
|
||||
if (!consented && consented_guild_id && consented_guild_id != GUILD_NONE) {
|
||||
if (client->GuildID() == consented_guild_id) {
|
||||
consented = true;
|
||||
}
|
||||
}
|
||||
if (!consented && consent_group_id) {
|
||||
if (!consented && consented_group_id) {
|
||||
Group* grp = client->GetGroup();
|
||||
if (grp && grp->GetID() == consent_group_id) {
|
||||
if (grp && grp->GetID() == consented_group_id) {
|
||||
consented = true;
|
||||
}
|
||||
}
|
||||
if (!consented && consent_raid_id) {
|
||||
if (!consented && consented_raid_id) {
|
||||
Raid* raid = client->GetRaid();
|
||||
if (raid && raid->GetID() == consent_raid_id) {
|
||||
if (raid && raid->GetID() == consented_raid_id) {
|
||||
consented = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,11 +74,11 @@ class Corpse : public Mob {
|
||||
uint32 GetDecayTime() { if (!corpse_decay_timer.Enabled()) return 0xFFFFFFFF; else return corpse_decay_timer.GetRemainingTime(); }
|
||||
uint32 GetRezTime() { if (!corpse_rez_timer.Enabled()) return 0; else return corpse_rez_timer.GetRemainingTime(); }
|
||||
void SetDecayTimer(uint32 decay_time);
|
||||
void SetConsentGroupID(uint32 id) { if (IsPlayerCorpse()) { consent_group_id = id; } }
|
||||
void SetConsentRaidID(uint32 id) { if (IsPlayerCorpse()) { consent_raid_id = id; } }
|
||||
void SetConsentGuildID(uint32 id) { if (IsPlayerCorpse()) { consent_guild_id = id; } }
|
||||
void AddConsentName(const char* name);
|
||||
void RemoveConsentName(const char* name);
|
||||
void SetConsentGroupID(uint32 group_id) { if (IsPlayerCorpse()) { consented_group_id = group_id; } }
|
||||
void SetConsentRaidID(uint32 raid_id) { if (IsPlayerCorpse()) { consented_raid_id = raid_id; } }
|
||||
void SetConsentGuildID(uint32 guild_id) { if (IsPlayerCorpse()) { consented_guild_id = guild_id; } }
|
||||
void AddConsentName(std::string consent_player_name);
|
||||
void RemoveConsentName(std::string consent_player_name);
|
||||
|
||||
void Delete();
|
||||
void Bury();
|
||||
@ -147,9 +147,9 @@ private:
|
||||
int32 player_kill_item; /* Determines if Player Kill Item */
|
||||
uint32 corpse_db_id; /* Corpse Database ID (Player Corpse) */
|
||||
uint32 char_id; /* Character ID */
|
||||
uint32 consent_group_id = 0; /* consented group id */
|
||||
uint32 consent_raid_id = 0; /* consented raid id */
|
||||
uint32 consent_guild_id = 0; /* consented guild id */
|
||||
uint32 consented_group_id = 0;
|
||||
uint32 consented_raid_id = 0;
|
||||
uint32 consented_guild_id = 0;
|
||||
ItemList itemlist; /* Internal Item list used for corpses */
|
||||
uint32 copper;
|
||||
uint32 silver;
|
||||
@ -168,7 +168,7 @@ private:
|
||||
Timer corpse_graveyard_timer;
|
||||
Timer loot_cooldown_timer; /* Delay between loot actions on the corpse entity */
|
||||
EQEmu::TintProfile item_tint;
|
||||
std::vector<std::string> consent_names;
|
||||
std::vector<std::string> consented_player_names;
|
||||
|
||||
LootRequestType loot_request_type;
|
||||
};
|
||||
|
||||
@ -4321,7 +4321,7 @@ uint32 ZoneDatabase::UpdateCharacterCorpse(uint32 db_id, uint32 char_id, const c
|
||||
|
||||
uint32 ZoneDatabase::UpdateCharacterCorpseConsent(uint32 charid, uint32 guildid)
|
||||
{
|
||||
std::string query = StringFormat("UPDATE `character_corpses` SET `guild_consent_id` = %u WHERE `charid` = %u", guildid, charid);
|
||||
std::string query = fmt::format("UPDATE `character_corpses` SET `guild_consent_id` = '{}' WHERE charid = '{}'", guildid, charid);
|
||||
auto results = QueryDatabase(query);
|
||||
return results.RowsAffected();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user