[Character] Convert Character Corpses to Repositories (#3941)

* asdsa

* Final push

* Update character_corpses_repository.h

* Update character_corpses_repository.h

* Update zonedb.cpp

* Update zonedb.cpp

* Final push

* Update character_corpses_repository.h
This commit is contained in:
Alex King
2024-01-13 01:02:44 -05:00
committed by GitHub
parent 5d1c59c95f
commit 77c0eb3998
20 changed files with 819 additions and 731 deletions
+1 -1
View File
@@ -1451,7 +1451,7 @@ public:
void DepopAllCorpses();
void DepopPlayerCorpse(uint32 dbid);
void BuryPlayerCorpses();
uint32 GetCorpseCount() { return database.GetCharacterCorpseCount(CharacterID()); }
int64 GetCorpseCount() { return database.GetCharacterCorpseCount(CharacterID()); }
uint32 GetCorpseID(int corpse) { return database.GetCharacterCorpseID(CharacterID(), corpse); }
uint32 GetCorpseItemAt(int corpse_id, int slot_id) { return database.GetCharacterCorpseItemAt(corpse_id, slot_id); }
void SuspendMinion(int value);
+77 -52
View File
@@ -63,9 +63,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "gm_commands/object_manipulation.h"
#include "client.h"
#include "../common/repositories/account_repository.h"
#include "../common/repositories/character_corpses_repository.h"
#include "../common/events/player_event_logs.h"
#include "../common/repositories/character_stats_record_repository.h"
#include "dialogue_window.h"
extern QueryServ* QServ;
extern Zone* zone;
@@ -6821,73 +6823,96 @@ void Client::Handle_OP_GMSearchCorpse(const EQApplicationPacket *app)
// Could make this into a rule, although there is a hard limit since we are using a popup, of 4096 bytes that can
// be displayed in the window, including all the HTML formatting tags.
//
const int maxResults = 10;
const int max_results = 10;
if (app->size < sizeof(GMSearchCorpse_Struct))
{
if (app->size < sizeof(GMSearchCorpse_Struct)) {
LogDebug("OP_GMSearchCorpse size lower than expected: got [{}] expected at least [{}]", app->size, sizeof(GMSearchCorpse_Struct));
DumpPacket(app);
return;
}
GMSearchCorpse_Struct *gmscs = (GMSearchCorpse_Struct *)app->pBuffer;
gmscs->Name[63] = '\0';
auto s = (GMSearchCorpse_Struct *) app->pBuffer;
s->Name[63] = '\0';
auto escSearchString = new char[129];
database.DoEscapeString(escSearchString, gmscs->Name, strlen(gmscs->Name));
const auto& l = CharacterCorpsesRepository::GetWhere(
database,
fmt::format(
"`charname` LIKE '%{}%' ORDER BY `charname` LIMIT {}",
Strings::Escape(s->Name),
max_results
)
);
std::string query = StringFormat("SELECT charname, zone_id, x, y, z, time_of_death, is_rezzed, is_buried "
"FROM character_corpses WheRE charname LIKE '%%%s%%' ORDER BY charname LIMIT %i",
escSearchString, maxResults);
safe_delete_array(escSearchString);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
if (l.empty()) {
Message(
Chat::White,
fmt::format(
"No corpses were found matching '{}'.",
s->Name
).c_str()
);
return;
}
if (results.RowCount() == 0)
return;
if (results.RowCount() == maxResults)
Message(Chat::Red, "Your search found too many results; some are not displayed.");
else
Message(Chat::Yellow, "There are %i corpse(s) that match the search string '%s'.", results.RowCount(), gmscs->Name);
char charName[64], time_of_death[20];
std::string popupText = "<table><tr><td>Name</td><td>Zone</td><td>X</td><td>Y</td><td>Z</td><td>Date</td><td>"
"Rezzed</td><td>Buried</td></tr><tr><td>&nbsp</td><td></td><td></td><td></td><td></td><td>"
"</td><td></td><td></td></tr>";
for (auto row = results.begin(); row != results.end(); ++row) {
strn0cpy(charName, row[0], sizeof(charName));
uint32 ZoneID = Strings::ToInt(row[1]);
float CorpseX = Strings::ToFloat(row[2]);
float CorpseY = Strings::ToFloat(row[3]);
float CorpseZ = Strings::ToFloat(row[4]);
strn0cpy(time_of_death, row[5], sizeof(time_of_death));
bool corpseRezzed = Strings::ToInt(row[6]);
bool corpseBuried = Strings::ToInt(row[7]);
popupText += StringFormat("<tr><td>%s</td><td>%s</td><td>%8.0f</td><td>%8.0f</td><td>%8.0f</td><td>%s</td><td>%s</td><td>%s</td></tr>",
charName, zone_store.GetZoneName(ZoneID, true), CorpseX, CorpseY, CorpseZ, time_of_death,
corpseRezzed ? "Yes" : "No", corpseBuried ? "Yes" : "No");
if (popupText.size() > 4000) {
Message(Chat::Red, "Unable to display all the results.");
break;
}
if (l.size() == max_results) {
Message(Chat::White, "Your search found too many results; some are not displayed.");
} else {
Message(
Chat::White,
fmt::format(
"{} Corpse{} were found matching '{}'.",
l.size(),
l.size() != 1 ? "s" : "",
s->Name
).c_str()
);
}
popupText += "</table>";
std::string popup_text = DialogueWindow::TableRow(
DialogueWindow::TableCell("Name") +
DialogueWindow::TableCell("Zone") +
DialogueWindow::TableCell("Position") +
DialogueWindow::TableCell("Date") +
DialogueWindow::TableCell("Resurrected") +
DialogueWindow::TableCell("Buried")
);
SendPopupToClient("Corpses", popupText.c_str());
for (const auto& e : l) {
popup_text += DialogueWindow::TableRow(
DialogueWindow::TableCell(e.charname) +
DialogueWindow::TableCell(
fmt::format(
"{} ({})",
zone_store.GetZoneLongName(e.zone_id, true),
e.zone_id
)
) +
DialogueWindow::TableCell(
fmt::format(
"{:.2f}, {:.2f}, {:.2f}, {:.2f}",
e.x,
e.y,
e.z,
e.heading
)
) +
DialogueWindow::TableCell(std::to_string(e.time_of_death)) +
DialogueWindow::TableCell(
e.is_rezzed ?
DialogueWindow::ColorMessage("forest_green", "Y") :
DialogueWindow::ColorMessage("red_1", "N")
) +
DialogueWindow::TableCell(
e.is_buried ?
DialogueWindow::ColorMessage("forest_green", "Y") :
DialogueWindow::ColorMessage("red_1", "N")
)
);
}
popup_text = DialogueWindow::Table(popup_text);
SendPopupToClient("Corpses", popup_text.c_str());
}
void Client::Handle_OP_GMServers(const EQApplicationPacket *app)
+1 -1
View File
@@ -1024,7 +1024,7 @@ void Client::OPRezzAnswer(uint32 Action, uint32 SpellID, uint16 ZoneID, uint16 I
{
// Mark the corpse as rezzed in the database, just in case the corpse has buried, or the zone the
// corpse is in has shutdown since the rez spell was cast.
database.MarkCorpseAsRezzed(PendingRezzDBID);
database.MarkCorpseAsResurrected(PendingRezzDBID);
LogSpells("Player [{}] got a [{}] Rezz spellid [{}] in zone[{}] instance id [{}]",
name, (uint16)spells[SpellID].base_value[0],
SpellID, ZoneID, InstanceID);
+3 -1
View File
@@ -2058,8 +2058,10 @@ bool Corpse::MovePlayerCorpseToGraveyard()
{
Save();
glm::vec4 graveyard_point = zone->GetGraveyardPoint();
uint16_t instance_id = (zone->GetZoneID() == zone->graveyard_zoneid()) ? zone->GetInstanceID() : 0;
database.SendCharacterCorpseToGraveyard(corpse_db_id, zone->graveyard_zoneid(), instance_id, zone->GetGraveyardPoint());
database.SendCharacterCorpseToGraveyard(corpse_db_id, zone->graveyard_zoneid(), instance_id, graveyard_point);
SendWorldSpawnPlayerCorpseInZone(zone->graveyard_zoneid());
corpse_db_id = 0;
+5 -5
View File
@@ -982,17 +982,17 @@ bool Perl__summonallplayercorpses(uint32 char_id, float dest_x, float dest_y, fl
return quest_manager.summonallplayercorpses(char_id, position);
}
int Perl__getplayercorpsecount(uint32 char_id)
int64 Perl__getplayercorpsecount(uint32 character_id)
{
return quest_manager.getplayercorpsecount(char_id);
return quest_manager.getplayercorpsecount(character_id);
}
int Perl__getplayercorpsecountbyzoneid(uint32 char_id, uint32 zone_id)
int64 Perl__getplayercorpsecountbyzoneid(uint32 character_id, uint32 zone_id)
{
return quest_manager.getplayercorpsecountbyzoneid(char_id, zone_id);
return quest_manager.getplayercorpsecountbyzoneid(character_id, zone_id);
}
int Perl__getplayerburiedcorpsecount(uint32 char_id)
int64 Perl__getplayerburiedcorpsecount(uint32 char_id)
{
return quest_manager.getplayerburiedcorpsecount(char_id);
}
@@ -8,7 +8,7 @@ void ShowBuriedCorpseCount(Client *c, const Seperator *sep)
t = c->GetTarget()->CastToClient();
}
const uint32 corpse_count = database.GetCharacterBuriedCorpseCount(t->CharacterID());
const int64 corpse_count = database.GetCharacterBuriedCorpseCount(t->CharacterID());
c->Message(
Chat::White,
+2 -2
View File
@@ -1436,7 +1436,7 @@ void Lua_Client::EndSharedTask(bool send_fail) {
self->EndSharedTask(send_fail);
}
int Lua_Client::GetCorpseCount() {
int64 Lua_Client::GetCorpseCount() {
Lua_Safe_Call_Int();
return self->GetCorpseCount();
}
@@ -3427,7 +3427,7 @@ luabind::scope lua_register_client() {
.def("GetClientMaxLevel", (int(Lua_Client::*)(void))&Lua_Client::GetClientMaxLevel)
.def("GetClientVersion", (int(Lua_Client::*)(void))&Lua_Client::GetClientVersion)
.def("GetClientVersionBit", (uint32(Lua_Client::*)(void))&Lua_Client::GetClientVersionBit)
.def("GetCorpseCount", (int(Lua_Client::*)(void))&Lua_Client::GetCorpseCount)
.def("GetCorpseCount", (int64(Lua_Client::*)(void))&Lua_Client::GetCorpseCount)
.def("GetCorpseID", (int(Lua_Client::*)(int))&Lua_Client::GetCorpseID)
.def("GetCorpseItemAt", (int(Lua_Client::*)(int,int))&Lua_Client::GetCorpseItemAt)
.def("GetDiscSlotBySpellID", (int(Lua_Client::*)(int32))&Lua_Client::GetDiscSlotBySpellID)
+1 -1
View File
@@ -361,7 +361,7 @@ public:
void LockSharedTask(bool lock);
void EndSharedTask();
void EndSharedTask(bool send_fail);
int GetCorpseCount();
int64 GetCorpseCount();
int GetCorpseID(int corpse);
int GetCorpseItemAt(int corpse, int slot);
void AssignToInstance(int instance_id);
+6 -6
View File
@@ -579,16 +579,16 @@ void lua_summon_all_player_corpses(uint32 char_id, float x, float y, float z, fl
quest_manager.summonallplayercorpses(char_id, glm::vec4(x, y, z, h));
}
int lua_get_player_corpse_count(uint32 char_id) {
return database.CountCharacterCorpses(char_id);
int64 lua_get_player_corpse_count(uint32 character_id) {
return database.CountCharacterCorpses(character_id);
}
int lua_get_player_corpse_count_by_zone_id(uint32 char_id, uint32 zone_id) {
return database.CountCharacterCorpsesByZoneID(char_id, zone_id);
int64 lua_get_player_corpse_count_by_zone_id(uint32 character_id, uint32 zone_id) {
return database.CountCharacterCorpsesByZoneID(character_id, zone_id);
}
int lua_get_player_buried_corpse_count(uint32 char_id) {
return quest_manager.getplayerburiedcorpsecount(char_id);
int64 lua_get_player_buried_corpse_count(uint32 character_id) {
return quest_manager.getplayerburiedcorpsecount(character_id);
}
bool lua_bury_player_corpse(uint32 char_id) {
+1 -1
View File
@@ -1413,7 +1413,7 @@ void Perl_Client_EndSharedTask(Client* self, bool send_fail)
return self->EndSharedTask(send_fail);
}
uint32_t Perl_Client_GetCorpseCount(Client* self) // @categories Account and Character, Corpse
int64_t Perl_Client_GetCorpseCount(Client* self) // @categories Account and Character, Corpse
{
return self->GetCorpseCount();
}
+6 -17
View File
@@ -2101,28 +2101,17 @@ bool QuestManager::summonallplayercorpses(uint32 char_id, const glm::vec4& posit
return true;
}
int QuestManager::getplayercorpsecount(uint32 char_id) {
if (char_id > 0) {
return database.CountCharacterCorpses(char_id);
}
return 0;
int64 QuestManager::getplayercorpsecount(uint32 character_id) {
return character_id ? database.CountCharacterCorpses(character_id) : 0;
}
int QuestManager::getplayercorpsecountbyzoneid(uint32 char_id, uint32 zone_id) {
if (char_id > 0 && zone_id > 0) {
return database.CountCharacterCorpsesByZoneID(char_id, zone_id);
}
return 0;
int64 QuestManager::getplayercorpsecountbyzoneid(uint32 character_id, uint32 zone_id) {
return (character_id && zone_id) ? database.CountCharacterCorpsesByZoneID(character_id, zone_id) : 0;
}
uint32 QuestManager::getplayerburiedcorpsecount(uint32 char_id) {
uint32 Result = 0;
if(char_id > 0) {
Result = database.GetCharacterBuriedCorpseCount(char_id);
}
return Result;
int64 QuestManager::getplayerburiedcorpsecount(uint32 character_id) {
return character_id ? database.GetCharacterBuriedCorpseCount(character_id) : 0;
}
bool QuestManager::buryplayercorpse(uint32 char_id)
+3 -3
View File
@@ -193,9 +193,9 @@ public:
void sethp(int64 hpperc);
bool summonburiedplayercorpse(uint32 char_id, const glm::vec4& position);
bool summonallplayercorpses(uint32 char_id, const glm::vec4& position);
uint32 getplayerburiedcorpsecount(uint32 char_id);
int getplayercorpsecount(uint32 char_id);
int getplayercorpsecountbyzoneid(uint32 char_id, uint32 zone_id);
int64 getplayerburiedcorpsecount(uint32 char_id);
int64 getplayercorpsecount(uint32 character_id);
int64 getplayercorpsecountbyzoneid(uint32 character_id, uint32 zone_id);
bool buryplayercorpse(uint32 char_id);
void forcedooropen(uint32 doorid, bool altmode);
void forcedoorclose(uint32 doorid, bool altmode);
+468 -553
View File
File diff suppressed because it is too large Load Diff
+25 -26
View File
@@ -476,32 +476,31 @@ public:
bool RestoreCharacterInvSnapshot(uint32 character_id, uint32 timestamp);
/* Corpses */
bool DeleteItemOffCharacterCorpse(uint32 db_id, uint32 equip_slot, uint32 item_id);
bool LoadCharacterCorpseData(uint32 corpse_id, CharacterCorpseEntry &corpse);
Corpse* LoadCharacterCorpse(uint32 player_corpse_id);
Corpse* SummonBuriedCharacterCorpses(uint32 char_id, uint32 dest_zoneid, uint16 dest_instanceid, const glm::vec4& position);
void MarkCorpseAsRezzed(uint32 dbid);
bool GetDecayTimes(npcDecayTimes_Struct* npcCorpseDecayTimes);
bool BuryCharacterCorpse(uint32 dbid);
bool BuryAllCharacterCorpses(uint32 charid);
bool DeleteCharacterCorpse(uint32 dbid);
bool SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zoneid, uint16 dest_instanceid, const glm::vec4& position);
int CountCharacterCorpses(uint32 char_id);
int CountCharacterCorpsesByZoneID(uint32 char_id, uint32 zone_id);
bool UnburyCharacterCorpse(uint32 dbid, uint32 new_zoneid, uint16 dest_instanceid, const glm::vec4& position);
bool LoadCharacterCorpses(uint32 iZoneID, uint16 iInstanceID);
uint32 GetCharacterCorpseDecayTimer(uint32 corpse_db_id);
uint32 GetCharacterBuriedCorpseCount(uint32 char_id);
uint32 SendCharacterCorpseToGraveyard(uint32 dbid, uint32 zoneid, uint16 instanceid, const glm::vec4& position);
uint32 SaveCharacterCorpse(uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, const CharacterCorpseEntry& corpse, const glm::vec4& position, uint32 guildid);
uint32 UpdateCharacterCorpse(uint32 dbid, uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, const CharacterCorpseEntry& corpse, const glm::vec4& position, uint32 guildid, bool rezzed = false);
uint32 UpdateCharacterCorpseConsent(uint32 charid, uint32 guildid);
uint32 GetFirstCorpseID(uint32 char_id);
uint32 GetCharacterCorpseCount(uint32 char_id);
uint32 GetCharacterCorpseID(uint32 char_id, uint8 corpse);
uint32 GetCharacterCorpseItemAt(uint32 corpse_id, uint16 slot_id);
uint32 GetPlayerCorpseTimeLeft(uint8 corpse, uint8 type);
void SendCharacterCorpseToNonInstance(uint32 corpse_db_id);
bool BuryAllCharacterCorpses(uint32 character_id);
bool BuryCharacterCorpse(uint32 corpse_id);
int64 CountCharacterCorpses(uint32 character_id);
int64 CountCharacterCorpsesByZoneID(uint32 character_id, uint32 zone_id);
bool DeleteCharacterCorpse(uint32 corpse_id);
bool DeleteItemOffCharacterCorpse(uint32 corpse_id, uint32 slot_id, uint32 item_id);
uint32 GetCharacterBuriedCorpseCount(uint32 character_id);
int64 GetCharacterCorpseCount(uint32 character_id);
uint32 GetCharacterCorpseDecayTimer(uint32 corpse_id);
uint32 GetCharacterCorpseID(uint32 character_id, uint8 corpse_limit);
uint32 GetCharacterCorpseItemAt(uint32 corpse_id, uint16 slot_id);
bool GetDecayTimes(npcDecayTimes_Struct* npc_decay_times);
uint32 GetFirstCorpseID(uint32 character_id);
Corpse* LoadCharacterCorpse(uint32 corpse_id);
bool LoadCharacterCorpseData(uint32 corpse_id, CharacterCorpseEntry &corpse);
bool LoadCharacterCorpses(uint32 zone_id, uint16 instance_id);
void MarkCorpseAsResurrected(uint32 corpse_id);
uint32 SaveCharacterCorpse(uint32 character_id, const std::string& name, uint32 zone_id, uint16 instance_id, const CharacterCorpseEntry& c, const glm::vec4& position, uint32 guild_consent_id);
uint32 SendCharacterCorpseToGraveyard(uint32 corpse_id, uint32 zone_id, uint16 instance_id, glm::vec4& position);
void SendCharacterCorpseToNonInstance(uint32 corpse_id);
Corpse* SummonBuriedCharacterCorpses(uint32 character_id, uint32 zone_id, uint16 instance_id, const glm::vec4& position);
bool SummonAllCharacterCorpses(uint32 character_id, uint32 zone_id, uint16 instance_id, const glm::vec4& position);
bool UnburyCharacterCorpse(uint32 corpse_id, uint32 zone_id, uint16 instance_id, const glm::vec4& position);
uint32 UpdateCharacterCorpse(uint32 corpse_id, uint32 character_id, const std::string& name, uint32 zone_id, uint16 instance_id, const CharacterCorpseEntry& c, const glm::vec4& position, uint32 guild_consent_id, bool is_resurrected = false);
uint32 UpdateCharacterCorpseConsent(uint32 character_id, uint32 guild_consent_id);
/* Faction */
bool GetNPCFactionList(uint32 npcfaction_id, int32* faction_id, int32* value, uint8* temp, int32* primary_faction = 0);