mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-11 11:48:37 +00:00
[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:
+77
-52
@@ -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> </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)
|
||||
|
||||
Reference in New Issue
Block a user