[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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 819 additions and 731 deletions

View File

@ -16,6 +16,7 @@
#include "../../strings.h" #include "../../strings.h"
#include <ctime> #include <ctime>
class BaseCharacterCorpseItemsRepository { class BaseCharacterCorpseItemsRepository {
public: public:
struct CharacterCorpseItems { struct CharacterCorpseItems {

View File

@ -16,6 +16,7 @@
#include "../../strings.h" #include "../../strings.h"
#include <ctime> #include <ctime>
class BaseCharacterCorpsesRepository { class BaseCharacterCorpsesRepository {
public: public:
struct CharacterCorpses { struct CharacterCorpses {

View File

@ -1,6 +1,7 @@
#ifndef EQEMU_CHARACTER_CORPSES_REPOSITORY_H #ifndef EQEMU_CHARACTER_CORPSES_REPOSITORY_H
#define EQEMU_CHARACTER_CORPSES_REPOSITORY_H #define EQEMU_CHARACTER_CORPSES_REPOSITORY_H
#include <glm/vec4.hpp>
#include "../database.h" #include "../database.h"
#include "../strings.h" #include "../strings.h"
#include "base/base_character_corpses_repository.h" #include "base/base_character_corpses_repository.h"
@ -44,29 +45,191 @@ public:
*/ */
// Custom extended repository methods here // Custom extended repository methods here
static int BuryInstance(Database& db, uint16 instance_id) { static int BuryCorpse(Database& db, uint32 corpse_id)
{
auto results = db.QueryDatabase( auto results = db.QueryDatabase(
fmt::format( fmt::format(
"UPDATE {} SET is_buried = 1, instance_id = 0 WHERE instance_id = {}", "UPDATE `{}` SET `is_buried` = 1 WHERE `{}` = {}",
TableName(),
PrimaryKey(),
corpse_id
)
);
return results.Success() ? results.RowsAffected() : 0;
}
static int BuryDecayedCorpses(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"UPDATE `{}` SET `is_buried` = 1 WHERE `is_buried` = 0 AND (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(time_of_death)) > {} AND time_of_death != 0",
TableName(),
RuleI(Character, CorpseDecayTimeMS) / 1000
)
);
return results.Success() ? results.RowsAffected() : 0;
}
static int BuryInstance(Database& db, uint16 instance_id)
{
auto results = db.QueryDatabase(
fmt::format(
"UPDATE `{}` SET is_buried = 1, instance_id = 0 WHERE instance_id = {}",
TableName(), TableName(),
instance_id instance_id
) )
); );
return (results.Success() ? results.RowsAffected() : 0); return results.Success() ? results.RowsAffected() : 0;
} }
static int BuryInstances(Database& db, const std::string& joined_instance_ids) static int BuryInstances(Database& db, const std::string& joined_instance_ids)
{ {
auto results = db.QueryDatabase( auto results = db.QueryDatabase(
fmt::format( fmt::format(
"UPDATE {} SET is_buried = 1, instance_id = 0 WHERE instance_id IN ({})", "UPDATE `{}` SET is_buried = 1, instance_id = 0 WHERE instance_id IN ({})",
TableName(), TableName(),
joined_instance_ids joined_instance_ids
) )
); );
return (results.Success() ? results.RowsAffected() : 0); return results.Success() ? results.RowsAffected() : 0;
}
static uint32 GetDecayTimer(Database& db, uint32 corpse_id)
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(time_of_death)) FROM `{}` WHERE `{}` = {} AND `time_of_death` != 0",
TableName(),
PrimaryKey(),
corpse_id
)
);
if (!results.Success() || !results.RowCount()) {
return 0;
}
auto row = results.begin();
return Strings::ToUnsignedInt(row[0]);
}
static uint32 ResurrectCorpse(Database& db, uint32 corpse_id)
{
auto results = db.QueryDatabase(
fmt::format(
"UPDATE `{}` SET `is_rezzed` = 1 WHERE `{}` = {}",
TableName(),
PrimaryKey(),
corpse_id
)
);
return results.Success() ? results.RowsAffected() : 0;
}
static void SendAdventureCorpsesToGraveyard(
Database& db,
uint32 graveyard_zone_id,
uint16 instance_id,
const glm::vec4& position
)
{
db.QueryDatabase(
fmt::format(
"UPDATE `{}` SET `zone_id` = {}, `instance_id` = 0, `x` = {:.2f}, `y` = {:.2f}, `z` = {:.2f}`, `heading` = {:.2f}, `was_at_graveyard` = 1 WHERE `instance_id` = {}",
TableName(),
graveyard_zone_id,
position.x,
position.y,
position.z,
position.w,
instance_id
)
);
}
static int SendToGraveyard(
Database& db,
uint32 corpse_id,
uint32 zone_id,
uint16 instance_id,
const glm::vec4& position
)
{
db.QueryDatabase(
fmt::format(
"UPDATE `{}` SET `zone_id` = {}, `instance_id` = {}, `x` = {:.2f}, `y` = {:.2f}, `z` = {:.2f}`, `heading` = {:.2f}, `was_at_graveyard` = 1 WHERE `{}` = {}",
TableName(),
zone_id,
instance_id,
position.x,
position.y,
position.z,
position.w,
PrimaryKey(),
corpse_id
)
);
return corpse_id;
}
static void SendToNonInstance(Database& db, uint32 corpse_id)
{
db.QueryDatabase(
fmt::format(
"UPDATE `{}` SET `instance_id` = 0 WHERE `{}` = {}",
TableName(),
PrimaryKey(),
corpse_id
)
);
}
static uint32 SetGuildConsentID(Database& db, uint32 character_id, uint32 guild_consent_id)
{
auto results = db.QueryDatabase(
fmt::format(
"UPDATE `{}` SET `guild_consent_id` = {} WHERE `charid` = {}",
TableName(),
guild_consent_id,
character_id
)
);
return results.Success() ? results.RowsAffected() : 0;
}
static int UnburyCorpse(
Database& db,
uint32 corpse_id,
uint32 zone_id,
uint16 instance_id,
const glm::vec4& position
)
{
auto results = db.QueryDatabase(
fmt::format(
"UPDATE `{}` SET `is_buried` = 0, `zone_id` = {}, `instance_id` = {}, `x` = {:.2f}, `y` = {:.2f}, `z` = {:.2f}, `heading` = {:.2f}, `time_of_death` = {}, `was_at_graveyard` = 0 WHERE `{}` = {}",
TableName(),
zone_id,
instance_id,
position.x,
position.y,
position.z,
position.w,
std::time(nullptr),
PrimaryKey(),
corpse_id
)
);
return results.Success() ? results.RowsAffected() : 0;
} }
}; };

View File

@ -45,6 +45,7 @@
#include "path_manager.h" #include "path_manager.h"
#include "repositories/loottable_repository.h" #include "repositories/loottable_repository.h"
#include "repositories/character_item_recast_repository.h" #include "repositories/character_item_recast_repository.h"
#include "repositories/character_corpses_repository.h"
namespace ItemField namespace ItemField
{ {
@ -1667,27 +1668,18 @@ EQ::ItemInstance* SharedDatabase::CreateBaseItem(const EQ::ItemData* item, int16
return inst; return inst;
} }
int32 SharedDatabase::DeleteStalePlayerCorpses() { int SharedDatabase::DeleteStalePlayerCorpses() {
if(RuleB(Zone, EnableShadowrest)) { return (
const std::string query = StringFormat( RuleB(Zone, EnableShadowrest) ?
"UPDATE `character_corpses` SET `is_buried` = 1 WHERE `is_buried` = 0 AND " CharacterCorpsesRepository::BuryDecayedCorpses(*this) :
"(UNIX_TIMESTAMP() - UNIX_TIMESTAMP(time_of_death)) > %d AND NOT time_of_death = 0", CharacterCorpsesRepository::DeleteWhere(
(RuleI(Character, CorpseDecayTimeMS) / 1000)); *this,
const auto results = QueryDatabase(query); fmt::format(
if (!results.Success()) "(UNIX_TIMESTAMP() - UNIX_TIMESTAMP(time_of_death)) > {} AND time_of_death != 0",
return -1; RuleI(Character, CorpseDecayTimeMS) / 1000
)
return results.RowsAffected(); )
} );
const std::string query = StringFormat(
"DELETE FROM `character_corpses` WHERE (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(time_of_death)) > %d "
"AND NOT time_of_death = 0", (RuleI(Character, CorpseDecayTimeMS) / 1000));
const auto results = QueryDatabase(query);
if (!results.Success())
return -1;
return results.RowsAffected();
} }
bool SharedDatabase::GetCommandSettings(std::map<std::string, std::pair<uint8, std::vector<std::string>>> &command_settings) bool SharedDatabase::GetCommandSettings(std::map<std::string, std::pair<uint8, std::vector<std::string>>> &command_settings)

View File

@ -72,7 +72,7 @@ public:
bool SetGMSpeed(uint32 account_id, uint8 gmspeed); bool SetGMSpeed(uint32 account_id, uint8 gmspeed);
uint8 GetGMSpeed(uint32 account_id); uint8 GetGMSpeed(uint32 account_id);
bool SetHideMe(uint32 account_id, uint8 hideme); bool SetHideMe(uint32 account_id, uint8 hideme);
int32 DeleteStalePlayerCorpses(); int DeleteStalePlayerCorpses();
void LoadCharacterInspectMessage(uint32 character_id, InspectMessage_Struct *message); void LoadCharacterInspectMessage(uint32 character_id, InspectMessage_Struct *message);
void SaveCharacterInspectMessage(uint32 character_id, const InspectMessage_Struct *message); void SaveCharacterInspectMessage(uint32 character_id, const InspectMessage_Struct *message);
bool GetCommandSettings(std::map<std::string, std::pair<uint8, std::vector<std::string>>> &command_settings); bool GetCommandSettings(std::map<std::string, std::pair<uint8, std::vector<std::string>>> &command_settings);

View File

@ -1,3 +1,4 @@
#include <glm/vec4.hpp>
#include "../common/global_define.h" #include "../common/global_define.h"
#include "../common/servertalk.h" #include "../common/servertalk.h"
#include "../common/extprofile.h" #include "../common/extprofile.h"
@ -12,6 +13,7 @@
#include "clientlist.h" #include "clientlist.h"
#include "cliententry.h" #include "cliententry.h"
#include "../common/zone_store.h" #include "../common/zone_store.h"
#include "../common/repositories/character_corpses_repository.h"
extern ZSList zoneserver_list; extern ZSList zoneserver_list;
extern ClientList client_list; extern ClientList client_list;
@ -370,54 +372,53 @@ void Adventure::Finished(AdventureWinStatus ws)
void Adventure::MoveCorpsesToGraveyard() void Adventure::MoveCorpsesToGraveyard()
{ {
if(GetTemplate()->graveyard_zone_id == 0) if (GetTemplate()->graveyard_zone_id == 0) {
{
return; return;
} }
std::list<uint32> dbid_list; glm::vec4 position;
std::list<uint32> charid_list;
std::string query = StringFormat("SELECT id, charid FROM character_corpses WHERE instance_id=%d", GetInstanceID()); float x = GetTemplate()->graveyard_x + emu_random.Real(-GetTemplate()->graveyard_radius, GetTemplate()->graveyard_radius);
auto results = database.QueryDatabase(query); float y = GetTemplate()->graveyard_y + emu_random.Real(-GetTemplate()->graveyard_radius, GetTemplate()->graveyard_radius);
if(!results.Success()) float z = GetTemplate()->graveyard_z;
for(auto row = results.begin(); row != results.end(); ++row) { position.x = x;
dbid_list.push_back(Strings::ToInt(row[0])); position.y = y;
charid_list.push_back(Strings::ToInt(row[1])); position.z = z;
} position.w = 0.0f;
for (auto &elem : dbid_list) { CharacterCorpsesRepository::SendAdventureCorpsesToGraveyard(database, GetTemplate()->graveyard_zone_id, GetInstanceID(), position);
float x = GetTemplate()->graveyard_x + emu_random.Real(-GetTemplate()->graveyard_radius, GetTemplate()->graveyard_radius);
float y = GetTemplate()->graveyard_y + emu_random.Real(-GetTemplate()->graveyard_radius, GetTemplate()->graveyard_radius);
float z = GetTemplate()->graveyard_z;
query = StringFormat("UPDATE character_corpses " const auto& l = CharacterCorpsesRepository::GetWhere(
"SET zone_id = %d, instance_id = 0, " database,
"x = %f, y = %f, z = %f WHERE instance_id = %d", fmt::format(
GetTemplate()->graveyard_zone_id, "`instance_id` = {}",
x, y, z, GetInstanceID()); GetInstanceID()
database.QueryDatabase(query); )
} );
for (const auto& e : l) {
auto pack = new ServerPacket(ServerOP_DepopAllPlayersCorpses, sizeof(ServerDepopAllPlayersCorpses_Struct));
auto d = (ServerDepopAllPlayersCorpses_Struct*) pack->pBuffer;
d->CharacterID = e.charid;
d->InstanceID = 0;
d->ZoneID = GetTemplate()->graveyard_zone_id;
auto c_iter = charid_list.begin();
for (auto iter = dbid_list.begin(); iter != dbid_list.end(); ++iter, ++c_iter)
{
auto pack =
new ServerPacket(ServerOP_DepopAllPlayersCorpses, sizeof(ServerDepopAllPlayersCorpses_Struct));
ServerDepopAllPlayersCorpses_Struct *dpc = (ServerDepopAllPlayersCorpses_Struct*)pack->pBuffer;
dpc->CharacterID = (*c_iter);
dpc->InstanceID = 0;
dpc->ZoneID = GetTemplate()->graveyard_zone_id;
zoneserver_list.SendPacket(0, GetInstanceID(), pack); zoneserver_list.SendPacket(0, GetInstanceID(), pack);
delete pack; delete pack;
pack = new ServerPacket(ServerOP_SpawnPlayerCorpse, sizeof(SpawnPlayerCorpse_Struct)); pack = new ServerPacket(ServerOP_SpawnPlayerCorpse, sizeof(SpawnPlayerCorpse_Struct));
SpawnPlayerCorpse_Struct* spc = (SpawnPlayerCorpse_Struct*)pack->pBuffer;
spc->player_corpse_id = (*iter); auto spc = (SpawnPlayerCorpse_Struct*) pack->pBuffer;
spc->zone_id = GetTemplate()->graveyard_zone_id;
spc->player_corpse_id = e.id;
spc->zone_id = GetTemplate()->graveyard_zone_id;
zoneserver_list.SendPacket(spc->zone_id, 0, pack); zoneserver_list.SendPacket(spc->zone_id, 0, pack);
delete pack; delete pack;
} }
} }

View File

@ -1451,7 +1451,7 @@ public:
void DepopAllCorpses(); void DepopAllCorpses();
void DepopPlayerCorpse(uint32 dbid); void DepopPlayerCorpse(uint32 dbid);
void BuryPlayerCorpses(); void BuryPlayerCorpses();
uint32 GetCorpseCount() { return database.GetCharacterCorpseCount(CharacterID()); } int64 GetCorpseCount() { return database.GetCharacterCorpseCount(CharacterID()); }
uint32 GetCorpseID(int corpse) { return database.GetCharacterCorpseID(CharacterID(), corpse); } uint32 GetCorpseID(int corpse) { return database.GetCharacterCorpseID(CharacterID(), corpse); }
uint32 GetCorpseItemAt(int corpse_id, int slot_id) { return database.GetCharacterCorpseItemAt(corpse_id, slot_id); } uint32 GetCorpseItemAt(int corpse_id, int slot_id) { return database.GetCharacterCorpseItemAt(corpse_id, slot_id); }
void SuspendMinion(int value); void SuspendMinion(int value);

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 "gm_commands/object_manipulation.h"
#include "client.h" #include "client.h"
#include "../common/repositories/account_repository.h" #include "../common/repositories/account_repository.h"
#include "../common/repositories/character_corpses_repository.h"
#include "../common/events/player_event_logs.h" #include "../common/events/player_event_logs.h"
#include "../common/repositories/character_stats_record_repository.h" #include "../common/repositories/character_stats_record_repository.h"
#include "dialogue_window.h"
extern QueryServ* QServ; extern QueryServ* QServ;
extern Zone* zone; 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 // 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. // 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)); LogDebug("OP_GMSearchCorpse size lower than expected: got [{}] expected at least [{}]", app->size, sizeof(GMSearchCorpse_Struct));
DumpPacket(app); DumpPacket(app);
return; return;
} }
GMSearchCorpse_Struct *gmscs = (GMSearchCorpse_Struct *)app->pBuffer; auto s = (GMSearchCorpse_Struct *) app->pBuffer;
gmscs->Name[63] = '\0'; s->Name[63] = '\0';
auto escSearchString = new char[129]; const auto& l = CharacterCorpsesRepository::GetWhere(
database.DoEscapeString(escSearchString, gmscs->Name, strlen(gmscs->Name)); 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 " if (l.empty()) {
"FROM character_corpses WheRE charname LIKE '%%%s%%' ORDER BY charname LIMIT %i", Message(
escSearchString, maxResults); Chat::White,
safe_delete_array(escSearchString); fmt::format(
auto results = database.QueryDatabase(query); "No corpses were found matching '{}'.",
if (!results.Success()) { s->Name
).c_str()
);
return; return;
} }
if (results.RowCount() == 0) if (l.size() == max_results) {
return; Message(Chat::White, "Your search found too many results; some are not displayed.");
} else {
if (results.RowCount() == maxResults) Message(
Message(Chat::Red, "Your search found too many results; some are not displayed."); Chat::White,
else fmt::format(
Message(Chat::Yellow, "There are %i corpse(s) that match the search string '%s'.", results.RowCount(), gmscs->Name); "{} Corpse{} were found matching '{}'.",
l.size(),
char charName[64], time_of_death[20]; l.size() != 1 ? "s" : "",
s->Name
std::string popupText = "<table><tr><td>Name</td><td>Zone</td><td>X</td><td>Y</td><td>Z</td><td>Date</td><td>" ).c_str()
"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;
}
} }
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) void Client::Handle_OP_GMServers(const EQApplicationPacket *app)

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 // 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. // 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 [{}]", LogSpells("Player [{}] got a [{}] Rezz spellid [{}] in zone[{}] instance id [{}]",
name, (uint16)spells[SpellID].base_value[0], name, (uint16)spells[SpellID].base_value[0],
SpellID, ZoneID, InstanceID); SpellID, ZoneID, InstanceID);

View File

@ -2058,8 +2058,10 @@ bool Corpse::MovePlayerCorpseToGraveyard()
{ {
Save(); Save();
glm::vec4 graveyard_point = zone->GetGraveyardPoint();
uint16_t instance_id = (zone->GetZoneID() == zone->graveyard_zoneid()) ? zone->GetInstanceID() : 0; 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()); SendWorldSpawnPlayerCorpseInZone(zone->graveyard_zoneid());
corpse_db_id = 0; corpse_db_id = 0;

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); 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); return quest_manager.getplayerburiedcorpsecount(char_id);
} }

View File

@ -8,7 +8,7 @@ void ShowBuriedCorpseCount(Client *c, const Seperator *sep)
t = c->GetTarget()->CastToClient(); t = c->GetTarget()->CastToClient();
} }
const uint32 corpse_count = database.GetCharacterBuriedCorpseCount(t->CharacterID()); const int64 corpse_count = database.GetCharacterBuriedCorpseCount(t->CharacterID());
c->Message( c->Message(
Chat::White, Chat::White,

View File

@ -1436,7 +1436,7 @@ void Lua_Client::EndSharedTask(bool send_fail) {
self->EndSharedTask(send_fail); self->EndSharedTask(send_fail);
} }
int Lua_Client::GetCorpseCount() { int64 Lua_Client::GetCorpseCount() {
Lua_Safe_Call_Int(); Lua_Safe_Call_Int();
return self->GetCorpseCount(); return self->GetCorpseCount();
} }
@ -3427,7 +3427,7 @@ luabind::scope lua_register_client() {
.def("GetClientMaxLevel", (int(Lua_Client::*)(void))&Lua_Client::GetClientMaxLevel) .def("GetClientMaxLevel", (int(Lua_Client::*)(void))&Lua_Client::GetClientMaxLevel)
.def("GetClientVersion", (int(Lua_Client::*)(void))&Lua_Client::GetClientVersion) .def("GetClientVersion", (int(Lua_Client::*)(void))&Lua_Client::GetClientVersion)
.def("GetClientVersionBit", (uint32(Lua_Client::*)(void))&Lua_Client::GetClientVersionBit) .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("GetCorpseID", (int(Lua_Client::*)(int))&Lua_Client::GetCorpseID)
.def("GetCorpseItemAt", (int(Lua_Client::*)(int,int))&Lua_Client::GetCorpseItemAt) .def("GetCorpseItemAt", (int(Lua_Client::*)(int,int))&Lua_Client::GetCorpseItemAt)
.def("GetDiscSlotBySpellID", (int(Lua_Client::*)(int32))&Lua_Client::GetDiscSlotBySpellID) .def("GetDiscSlotBySpellID", (int(Lua_Client::*)(int32))&Lua_Client::GetDiscSlotBySpellID)

View File

@ -361,7 +361,7 @@ public:
void LockSharedTask(bool lock); void LockSharedTask(bool lock);
void EndSharedTask(); void EndSharedTask();
void EndSharedTask(bool send_fail); void EndSharedTask(bool send_fail);
int GetCorpseCount(); int64 GetCorpseCount();
int GetCorpseID(int corpse); int GetCorpseID(int corpse);
int GetCorpseItemAt(int corpse, int slot); int GetCorpseItemAt(int corpse, int slot);
void AssignToInstance(int instance_id); void AssignToInstance(int instance_id);

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)); quest_manager.summonallplayercorpses(char_id, glm::vec4(x, y, z, h));
} }
int lua_get_player_corpse_count(uint32 char_id) { int64 lua_get_player_corpse_count(uint32 character_id) {
return database.CountCharacterCorpses(char_id); return database.CountCharacterCorpses(character_id);
} }
int lua_get_player_corpse_count_by_zone_id(uint32 char_id, uint32 zone_id) { int64 lua_get_player_corpse_count_by_zone_id(uint32 character_id, uint32 zone_id) {
return database.CountCharacterCorpsesByZoneID(char_id, zone_id); return database.CountCharacterCorpsesByZoneID(character_id, zone_id);
} }
int lua_get_player_buried_corpse_count(uint32 char_id) { int64 lua_get_player_buried_corpse_count(uint32 character_id) {
return quest_manager.getplayerburiedcorpsecount(char_id); return quest_manager.getplayerburiedcorpsecount(character_id);
} }
bool lua_bury_player_corpse(uint32 char_id) { bool lua_bury_player_corpse(uint32 char_id) {

View File

@ -1413,7 +1413,7 @@ void Perl_Client_EndSharedTask(Client* self, bool send_fail)
return self->EndSharedTask(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(); return self->GetCorpseCount();
} }

View File

@ -2101,28 +2101,17 @@ bool QuestManager::summonallplayercorpses(uint32 char_id, const glm::vec4& posit
return true; return true;
} }
int QuestManager::getplayercorpsecount(uint32 char_id) { int64 QuestManager::getplayercorpsecount(uint32 character_id) {
if (char_id > 0) { return character_id ? database.CountCharacterCorpses(character_id) : 0;
return database.CountCharacterCorpses(char_id);
}
return 0;
} }
int QuestManager::getplayercorpsecountbyzoneid(uint32 char_id, uint32 zone_id) { int64 QuestManager::getplayercorpsecountbyzoneid(uint32 character_id, uint32 zone_id) {
if (char_id > 0 && zone_id > 0) { return (character_id && zone_id) ? database.CountCharacterCorpsesByZoneID(character_id, zone_id) : 0;
return database.CountCharacterCorpsesByZoneID(char_id, zone_id);
}
return 0;
} }
uint32 QuestManager::getplayerburiedcorpsecount(uint32 char_id) { int64 QuestManager::getplayerburiedcorpsecount(uint32 character_id) {
uint32 Result = 0; return character_id ? database.GetCharacterBuriedCorpseCount(character_id) : 0;
if(char_id > 0) {
Result = database.GetCharacterBuriedCorpseCount(char_id);
}
return Result;
} }
bool QuestManager::buryplayercorpse(uint32 char_id) bool QuestManager::buryplayercorpse(uint32 char_id)

View File

@ -193,9 +193,9 @@ public:
void sethp(int64 hpperc); void sethp(int64 hpperc);
bool summonburiedplayercorpse(uint32 char_id, const glm::vec4& position); bool summonburiedplayercorpse(uint32 char_id, const glm::vec4& position);
bool summonallplayercorpses(uint32 char_id, const glm::vec4& position); bool summonallplayercorpses(uint32 char_id, const glm::vec4& position);
uint32 getplayerburiedcorpsecount(uint32 char_id); int64 getplayerburiedcorpsecount(uint32 char_id);
int getplayercorpsecount(uint32 char_id); int64 getplayercorpsecount(uint32 character_id);
int getplayercorpsecountbyzoneid(uint32 char_id, uint32 zone_id); int64 getplayercorpsecountbyzoneid(uint32 character_id, uint32 zone_id);
bool buryplayercorpse(uint32 char_id); bool buryplayercorpse(uint32 char_id);
void forcedooropen(uint32 doorid, bool altmode); void forcedooropen(uint32 doorid, bool altmode);
void forcedoorclose(uint32 doorid, bool altmode); void forcedoorclose(uint32 doorid, bool altmode);

File diff suppressed because it is too large Load Diff

View File

@ -476,32 +476,31 @@ public:
bool RestoreCharacterInvSnapshot(uint32 character_id, uint32 timestamp); bool RestoreCharacterInvSnapshot(uint32 character_id, uint32 timestamp);
/* Corpses */ /* Corpses */
bool DeleteItemOffCharacterCorpse(uint32 db_id, uint32 equip_slot, uint32 item_id); bool BuryAllCharacterCorpses(uint32 character_id);
bool LoadCharacterCorpseData(uint32 corpse_id, CharacterCorpseEntry &corpse); bool BuryCharacterCorpse(uint32 corpse_id);
Corpse* LoadCharacterCorpse(uint32 player_corpse_id); int64 CountCharacterCorpses(uint32 character_id);
Corpse* SummonBuriedCharacterCorpses(uint32 char_id, uint32 dest_zoneid, uint16 dest_instanceid, const glm::vec4& position); int64 CountCharacterCorpsesByZoneID(uint32 character_id, uint32 zone_id);
void MarkCorpseAsRezzed(uint32 dbid); bool DeleteCharacterCorpse(uint32 corpse_id);
bool GetDecayTimes(npcDecayTimes_Struct* npcCorpseDecayTimes); bool DeleteItemOffCharacterCorpse(uint32 corpse_id, uint32 slot_id, uint32 item_id);
bool BuryCharacterCorpse(uint32 dbid); uint32 GetCharacterBuriedCorpseCount(uint32 character_id);
bool BuryAllCharacterCorpses(uint32 charid); int64 GetCharacterCorpseCount(uint32 character_id);
bool DeleteCharacterCorpse(uint32 dbid); uint32 GetCharacterCorpseDecayTimer(uint32 corpse_id);
bool SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zoneid, uint16 dest_instanceid, const glm::vec4& position); uint32 GetCharacterCorpseID(uint32 character_id, uint8 corpse_limit);
int CountCharacterCorpses(uint32 char_id); uint32 GetCharacterCorpseItemAt(uint32 corpse_id, uint16 slot_id);
int CountCharacterCorpsesByZoneID(uint32 char_id, uint32 zone_id); bool GetDecayTimes(npcDecayTimes_Struct* npc_decay_times);
bool UnburyCharacterCorpse(uint32 dbid, uint32 new_zoneid, uint16 dest_instanceid, const glm::vec4& position); uint32 GetFirstCorpseID(uint32 character_id);
bool LoadCharacterCorpses(uint32 iZoneID, uint16 iInstanceID); Corpse* LoadCharacterCorpse(uint32 corpse_id);
uint32 GetCharacterCorpseDecayTimer(uint32 corpse_db_id); bool LoadCharacterCorpseData(uint32 corpse_id, CharacterCorpseEntry &corpse);
uint32 GetCharacterBuriedCorpseCount(uint32 char_id); bool LoadCharacterCorpses(uint32 zone_id, uint16 instance_id);
uint32 SendCharacterCorpseToGraveyard(uint32 dbid, uint32 zoneid, uint16 instanceid, const glm::vec4& position); void MarkCorpseAsResurrected(uint32 corpse_id);
uint32 SaveCharacterCorpse(uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, const CharacterCorpseEntry& corpse, const glm::vec4& position, uint32 guildid); 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 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 SendCharacterCorpseToGraveyard(uint32 corpse_id, uint32 zone_id, uint16 instance_id, glm::vec4& position);
uint32 UpdateCharacterCorpseConsent(uint32 charid, uint32 guildid); void SendCharacterCorpseToNonInstance(uint32 corpse_id);
uint32 GetFirstCorpseID(uint32 char_id); Corpse* SummonBuriedCharacterCorpses(uint32 character_id, uint32 zone_id, uint16 instance_id, const glm::vec4& position);
uint32 GetCharacterCorpseCount(uint32 char_id); bool SummonAllCharacterCorpses(uint32 character_id, uint32 zone_id, uint16 instance_id, const glm::vec4& position);
uint32 GetCharacterCorpseID(uint32 char_id, uint8 corpse); bool UnburyCharacterCorpse(uint32 corpse_id, uint32 zone_id, uint16 instance_id, const glm::vec4& position);
uint32 GetCharacterCorpseItemAt(uint32 corpse_id, uint16 slot_id); 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 GetPlayerCorpseTimeLeft(uint8 corpse, uint8 type); uint32 UpdateCharacterCorpseConsent(uint32 character_id, uint32 guild_consent_id);
void SendCharacterCorpseToNonInstance(uint32 corpse_db_id);
/* Faction */ /* Faction */
bool GetNPCFactionList(uint32 npcfaction_id, int32* faction_id, int32* value, uint8* temp, int32* primary_faction = 0); bool GetNPCFactionList(uint32 npcfaction_id, int32* faction_id, int32* value, uint8* temp, int32* primary_faction = 0);