[Cleanup] Nuke Make/AppendAnyLenString (#1251)

* Add a std::string overload for Database::SetMQDetectionFlag

* Replace calls to MakeAnyLenString in client_packet.cpp

At least the SetMQDetectionFlag ones

* Replace MakeAnyLenString calls in client_process

At least SetMQDectectionFlag ones

* Replace MakeAnyLenString in embparser

fmtlib actually is gross here, oh well.

* Replace MakeAnyLenString in merc

* Replace MakeAnyLenString in inventory

Also if'd out an unfinished implementation of Client::GetItemLinkHash

* Replace AppendAnyLenString in zonelist

* Replace AppendAnyLenString in zonelist

* Replace MakeAnyLenString in clientlist

* Nuke MakeAnyLenString/AppendAnyLenString

* Fix formatting string in zonelist
This commit is contained in:
Michael Cook (mackal) 2021-02-23 19:32:19 -05:00 committed by GitHub
parent 7a46a6595c
commit 86ce506956
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 128 additions and 212 deletions

View File

@ -1356,6 +1356,20 @@ bool Database::SetMQDetectionFlag(const char* accountname, const char* character
return results.RowsAffected() != 0;
}
bool Database::SetMQDetectionFlag(const char* accountname, const char* charactername, const std::string &hacked, const char* zone) {
//Utilize the "hacker" table, but also give zone information.
auto query = fmt::format("INSERT INTO hackers(account, name, hacked, zone) values('{}', '{}', '{}', '{}')",
accountname, charactername, hacked, zone);
auto results = QueryDatabase(query);
if (!results.Success())
{
return false;
}
return results.RowsAffected() != 0;
}
uint8 Database::GetRaceSkill(uint8 skillid, uint8 in_race)
{
uint16 race_cap = 0;

View File

@ -128,6 +128,7 @@ public:
bool SaveCharacterCreate(uint32 character_id, uint32 account_id, PlayerProfile_Struct *pp);
bool SetHackerFlag(const char *accountname, const char *charactername, const char *hacked);
bool SetMQDetectionFlag(const char *accountname, const char *charactername, const char *hacked, const char *zone);
bool SetMQDetectionFlag(const char *accountname, const char *charactername, const std::string &hacked, const char *zone);
bool UpdateName(const char *oldname, const char *newname);
bool CopyCharacter(
std::string source_character_name,

View File

@ -355,56 +355,6 @@ void MakeLowerString(const char *source, char *target) {
*target = 0;
}
int MakeAnyLenString(char** ret, const char* format, ...) {
int buf_len = 128;
int chars = -1;
va_list argptr, tmpargptr;
va_start(argptr, format);
while (chars == -1 || chars >= buf_len) {
safe_delete_array(*ret);
if (chars == -1)
buf_len *= 2;
else
buf_len = chars + 1;
*ret = new char[buf_len];
va_copy(tmpargptr, argptr);
chars = vsnprintf(*ret, buf_len, format, tmpargptr);
va_end(tmpargptr);
}
va_end(argptr);
return chars;
}
uint32 AppendAnyLenString(char** ret, uint32* bufsize, uint32* strlen, const char* format, ...) {
if (*bufsize == 0)
*bufsize = 256;
if (*ret == 0)
*strlen = 0;
int chars = -1;
char* oldret = 0;
va_list argptr, tmpargptr;
va_start(argptr, format);
while (chars == -1 || chars >= (int32)(*bufsize - *strlen)) {
if (chars == -1)
*bufsize += 256;
else
*bufsize += chars + 25;
oldret = *ret;
*ret = new char[*bufsize];
if (oldret) {
if (*strlen)
memcpy(*ret, oldret, *strlen);
safe_delete_array(oldret);
}
va_copy(tmpargptr, argptr);
chars = vsnprintf(&(*ret)[*strlen], (*bufsize - *strlen), format, tmpargptr);
va_end(tmpargptr);
}
va_end(argptr);
*strlen += chars;
return *strlen;
}
uint32 hextoi(const char* num) {
if (num == nullptr)
return 0;

View File

@ -199,8 +199,6 @@ char* strn0cpy(char* dest, const char* source, uint32 size);
const char *ConvertArray(int input, char *returnchar);
const char *ConvertArrayF(float input, char *returnchar);
const char *MakeLowerString(const char *source);
int MakeAnyLenString(char** ret, const char* format, ...);
uint32 AppendAnyLenString(char** ret, uint32* bufsize, uint32* strlen, const char* format, ...);
uint32 hextoi(const char* num);
uint64 hextoi64(const char* num);
void MakeLowerString(const char *source, char *target);

View File

@ -65,14 +65,10 @@ void Client::SendUptime() {
ms -= m * 60000;
uint32 s = ms / 1000;
char *Buffer = nullptr;
MakeAnyLenString(&Buffer, "UCS has been up for %02id %02ih %02im %02is", d, h, m, s);
GeneralChannelMessage(Buffer);
safe_delete_array(Buffer);
MakeAnyLenString(&Buffer, "Chat Messages Sent: %i, Mail Messages Sent: %i", ChatMessagesSent, MailMessagesSent);
GeneralChannelMessage(Buffer);
safe_delete_array(Buffer);
auto message = fmt::format("UCS has been up for {:02}d {:02}h {:02}m {:02}s", d, h, m, s);
GeneralChannelMessage(message);
message = fmt::format("Chat Messages Sent: {}, Mail Messages Sent: {}", ChatMessagesSent, MailMessagesSent);
GeneralChannelMessage(message);
}
std::vector<std::string> ParseRecipients(std::string RecipientString) {

View File

@ -269,8 +269,6 @@ ClientListEntry* ClientList::FindCLEByLSID(uint32 iLSID) {
void ClientList::SendCLEList(const int16& admin, const char* to, WorldTCPConnection* connection, const char* iName) {
LinkedListIterator<ClientListEntry*> iterator(clientlist);
char* output = 0;
uint32 outsize = 0, outlen = 0;
int x = 0, y = 0;
int namestrlen = iName == 0 ? 0 : strlen(iName);
bool addnewline = false;
@ -279,6 +277,7 @@ void ClientList::SendCLEList(const int16& admin, const char* to, WorldTCPConnect
strcpy(newline, "\r\n");
else
strcpy(newline, "^");
fmt::memory_buffer out;
iterator.Reset();
while(iterator.MoreElements()) {
@ -287,31 +286,30 @@ void ClientList::SendCLEList(const int16& admin, const char* to, WorldTCPConnect
struct in_addr in;
in.s_addr = cle->GetIP();
if (addnewline) {
AppendAnyLenString(&output, &outsize, &outlen, newline);
fmt::format_to(out, newline);
}
AppendAnyLenString(&output, &outsize, &outlen, "ID: %i Acc# %i AccName: %s IP: %s", cle->GetID(), cle->AccountID(), cle->AccountName(), inet_ntoa(in));
AppendAnyLenString(&output, &outsize, &outlen, "%s Stale: %i Online: %i Admin: %i", newline, cle->GetStaleCounter(), cle->Online(), cle->Admin());
fmt::format_to(out, "ID: {} Acc# {} AccName: {} IP: {}", cle->GetID(), cle->AccountID(), cle->AccountName(), inet_ntoa(in));
fmt::format_to(out, "{} Stale: {} Online: {} Admin: {}", newline, cle->GetStaleCounter(), cle->Online(), cle->Admin());
if (cle->LSID())
AppendAnyLenString(&output, &outsize, &outlen, "%s LSID: %i LSName: %s WorldAdmin: %i", newline, cle->LSID(), cle->LSName(), cle->WorldAdmin());
fmt::format_to(out, "{} LSID: {} LSName: {} WorldAdmin: {}", newline, cle->LSID(), cle->LSName(), cle->WorldAdmin());
if (cle->CharID())
AppendAnyLenString(&output, &outsize, &outlen, "%s CharID: %i CharName: %s Zone: %s (%i)", newline, cle->CharID(), cle->name(), ZoneName(cle->zone()), cle->zone());
if (outlen >= 3072) {
connection->SendEmoteMessageRaw(to, 0, 0, 10, output);
safe_delete(output);
outsize = 0;
outlen = 0;
fmt:format_to(out, "{} CharID: {} CharName: {} Zone: {} ({})", newline, cle->CharID(), cle->name(), ZoneName(cle->zone()), cle->zone());
if (out.size() >= 3072) {
auto output = fmt::to_string(out);
connection->SendEmoteMessageRaw(to, 0, 0, 10, output.c_str());
addnewline = false;
}
else
out.clear();
} else {
addnewline = true;
}
y++;
}
iterator.Advance();
x++;
}
AppendAnyLenString(&output, &outsize, &outlen, "%s%i CLEs in memory. %i CLEs listed. numplayers = %i.", newline, x, y, numplayers);
connection->SendEmoteMessageRaw(to, 0, 0, 10, output);
safe_delete(output);
fmt::format_to(out, "{}{} CLEs in memory. {} CLEs listed. numplayers = {}.", newline, x, y, numplayers);
auto output = fmt::to_string(out);
connection->SendEmoteMessageRaw(to, 0, 0, 10, output.c_str());
}
@ -489,15 +487,8 @@ void ClientList::SendWhoAll(uint32 fromid,const char* to, int16 admin, Who_All_S
whom->wrace = FROGLOK; // This is what EQEmu uses for the Froglok Race number.
}
char* output = 0;
uint32 outsize = 0, outlen = 0;
uint32 totalusers=0;
uint32 totallength=0;
AppendAnyLenString(&output, &outsize, &outlen, "Players on server:");
if (connection->IsConsole())
AppendAnyLenString(&output, &outsize, &outlen, "\r\n");
else
AppendAnyLenString(&output, &outsize, &outlen, "\n");
countclients.Reset();
while(countclients.MoreElements()){
countcle = countclients.GetData();
@ -722,7 +713,6 @@ void ClientList::SendWhoAll(uint32 fromid,const char* to, int16 admin, Who_All_S
//zoneserver_list.SendPacket(pack2); // NO NO NO WHY WOULD YOU SEND IT TO EVERY ZONE SERVER?!?
SendPacket(to,pack2);
safe_delete(pack2);
safe_delete_array(output);
}
catch(...){
LogInfo("Unknown error in world's SendWhoAll (probably mem error), ignoring");
@ -956,13 +946,12 @@ void ClientList::ConsoleSendWhoAll(const char* to, int16 admin, Who_All_Struct*
if (whom)
whomlen = strlen(whom->whom);
char* output = 0;
uint32 outsize = 0, outlen = 0;
AppendAnyLenString(&output, &outsize, &outlen, "Players on server:");
fmt::memory_buffer out;
fmt::format_to(out, "Players on server:");
if (connection->IsConsole())
AppendAnyLenString(&output, &outsize, &outlen, "\r\n");
fmt::format_to(out, "\r\n");
else
AppendAnyLenString(&output, &outsize, &outlen, "\n");
fmt::format_to(out, "\n");
iterator.Reset();
while (iterator.MoreElements()) {
cle = iterator.GetData();
@ -1058,18 +1047,17 @@ void ClientList::ConsoleSendWhoAll(const char* to, int16 admin, Who_All_Struct*
else
sprintf(line, " %s[%i %s] %s (%s)%s zone: %s%s%s", tmpgm, cle->level(), GetClassIDName(cle->class_(), cle->level()), cle->name(), GetRaceIDName(cle->race()), tmpguild, tmpZone, LFG, accinfo);
AppendAnyLenString(&output, &outsize, &outlen, line);
if (outlen >= 3584) {
connection->SendEmoteMessageRaw(to, 0, 0, 10, output);
safe_delete(output);
outsize = 0;
outlen = 0;
fmt::format_to(out, line);
if (out.size() >= 3584) {
auto output = fmt::to_string(out);
connection->SendEmoteMessageRaw(to, 0, 0, 10, output.c_str());
out.clear();
}
else {
if (connection->IsConsole())
AppendAnyLenString(&output, &outsize, &outlen, "\r\n");
fmt::format_to(out, "\r\n");
else
AppendAnyLenString(&output, &outsize, &outlen, "\n");
fmt::format_to(out, "\n");
}
x++;
if (x >= 20 && admin < 80)
@ -1079,20 +1067,19 @@ void ClientList::ConsoleSendWhoAll(const char* to, int16 admin, Who_All_Struct*
}
if (x >= 20 && admin < 80)
AppendAnyLenString(&output, &outsize, &outlen, "too many results...20 players shown");
fmt::format_to(out, "too many results...20 players shown");
else
AppendAnyLenString(&output, &outsize, &outlen, "%i players online", x);
fmt::format_to(out, "{} players online", x);
if (admin >= 150 && (whom == 0 || whom->gmlookup != 0xFFFF)) {
if (connection->IsConsole())
AppendAnyLenString(&output, &outsize, &outlen, "\r\n");
fmt::format_to(out, "\r\n");
else
AppendAnyLenString(&output, &outsize, &outlen, "\n");
fmt::format_to(out, "\n");
//console_list.SendConsoleWho(connection, to, admin, &output, &outsize, &outlen);
}
if (output)
connection->SendEmoteMessageRaw(to, 0, 0, 10, output);
safe_delete(output);
auto output = fmt::to_string(out);
connection->SendEmoteMessageRaw(to, 0, 0, 10, output.c_str());
}
void ClientList::Add(Client* client) {

View File

@ -280,20 +280,19 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con
strcpy(locked, "No");
}
char* output = 0;
uint32 outsize = 0, outlen = 0;
fmt::memory_buffer out;
if (connection->IsConsole()) {
AppendAnyLenString(&output, &outsize, &outlen, "World Locked: %s\r\n", locked);
fmt::format_to(out, "World Locked: {}\r\n", locked);
}
else {
AppendAnyLenString(&output, &outsize, &outlen, "World Locked: %s^", locked);
fmt::format_to(out, "World Locked: {}^", locked);
}
if (connection->IsConsole()) {
AppendAnyLenString(&output, &outsize, &outlen, "Zoneservers online:\r\n");
fmt::format_to(out, "Zoneservers online:\r\n");
}
else {
AppendAnyLenString(&output, &outsize, &outlen, "Zoneservers online:^");
fmt::format_to(out, "Zoneservers online:^");
}
int v = 0, w = 0, x = 0, y = 0, z = 0;
@ -333,8 +332,8 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con
zone_data_string[0] = 0;
}
AppendAnyLenString(&output, &outsize, &outlen,
"#%-3i :: %s :: %15s:%-5i :: %2i :: %s:%i :: %s :: (%u)",
fmt::format_to(out,
"#{:<3} :: {} :: {}:{:<5} :: {:2} :: {}:{} :: {} :: ({})",
zone_server_data->GetID(),
is_static_string,
addr.c_str(),
@ -346,17 +345,16 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con
zone_server_data->GetZoneOSProcessID()
);
if (outlen >= 3584) {
connection->SendEmoteMessageRaw(to, 0, 0, 10, output);
safe_delete(output);
outsize = 0;
outlen = 0;
if (out.size() >= 3584) {
auto output = fmt::to_string(out);
connection->SendEmoteMessageRaw(to, 0, 0, 10, output.c_str());
out.clear();
}
else {
if (connection->IsConsole())
AppendAnyLenString(&output, &outsize, &outlen, "\r\n");
fmt::format_to(out, "\r\n");
else
AppendAnyLenString(&output, &outsize, &outlen, "^");
fmt::format_to(out, "^");
}
x++;
}
@ -365,19 +363,18 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con
strcpy(zone_data_string, zone_server_data->GetZoneName());
else
zone_data_string[0] = 0;
AppendAnyLenString(&output, &outsize, &outlen, " #%i %s %s", zone_server_data->GetID(), is_static_string, zone_data_string);
if (outlen >= 3584) {
connection->SendEmoteMessageRaw(to, 0, 0, 10, output);
safe_delete(output);
outsize = 0;
outlen = 0;
fmt::format_to(out, " #{} {} {}", zone_server_data->GetID(), is_static_string, zone_data_string);
if (out.size() >= 3584) {
auto output = fmt::to_string(out);
connection->SendEmoteMessageRaw(to, 0, 0, 10, output.c_str());
out.clear();
}
else {
if (connection->IsConsole()) {
AppendAnyLenString(&output, &outsize, &outlen, "\r\n");
fmt::format_to(out, "\r\n");
}
else {
AppendAnyLenString(&output, &outsize, &outlen, "^");
fmt::format_to(out, "^");
}
}
x++;
@ -387,19 +384,16 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con
}
if (connection->IsConsole()) {
AppendAnyLenString(&output, &outsize, &outlen, "%i servers listed. %i servers online.\r\n", x, y);
fmt::format_to(out, "{} servers listed. {} servers online.\r\n", x, y);
}
else {
AppendAnyLenString(&output, &outsize, &outlen, "%i servers listed. %i servers online.^", x, y);
fmt::format_to(out, "{} servers listed. {} servers online.^", x, y);
}
AppendAnyLenString(&output, &outsize, &outlen, "%i zones are static zones, %i zones are booted zones, %i zones available.", z, w, v);
fmt::format_to(out, "{} zones are static zones, {} zones are booted zones, {} zones available.", z, w, v);
if (output) {
connection->SendEmoteMessageRaw(to, 0, 0, 10, output);
}
safe_delete(output);
auto output = fmt::to_string(out);
connection->SendEmoteMessageRaw(to, 0, 0, 10, output.c_str());
}
void ZSList::SendChannelMessage(const char* from, const char* to, uint8 chan_num, uint8 language, const char* message, ...) {

View File

@ -3383,11 +3383,10 @@ void Client::Handle_OP_BankerChange(const EQApplicationPacket *app)
if (!banker || distance > USE_NPC_RANGE2)
{
char *hacked_string = nullptr;
MakeAnyLenString(&hacked_string, "Player tried to make use of a banker(money) but %s is non-existant or too far away (%u units).",
banker ? banker->GetName() : "UNKNOWN NPC", distance);
auto hacked_string = fmt::format(
"Player tried to make use of a banker(money) but {} is non-existant or too far away ({} units).",
banker ? banker->GetName() : "UNKNOWN NPC", distance);
database.SetMQDetectionFlag(AccountName(), GetName(), hacked_string, zone->GetShortName());
safe_delete_array(hacked_string);
return;
}
@ -5018,10 +5017,8 @@ void Client::Handle_OP_ControlBoat(const EQApplicationPacket *app)
if (!boat->IsNPC() || !boat->IsControllableBoat())
{
char *hacked_string = nullptr;
MakeAnyLenString(&hacked_string, "OP_Control Boat was sent against %s which is of race %u", boat->GetName(), boat->GetRace());
auto hacked_string = fmt::format("OP_Control Boat was sent against {} which is of race {}", boat->GetName(), boat->GetRace());
database.SetMQDetectionFlag(this->AccountName(), this->GetName(), hacked_string, zone->GetShortName());
safe_delete_array(hacked_string);
return;
}
@ -5341,10 +5338,8 @@ void Client::Handle_OP_Disarm(const EQApplicationPacket *app) {
return;
if (pmob->GetID() != GetID()) {
// Client sent a disarm request with an originator ID not matching their own ID.
char *hack_str = NULL;
MakeAnyLenString(&hack_str, "Player %s (%d) sent OP_Disarm with source ID of: %d", GetCleanName(), GetID(), pmob->GetID());
auto hack_str = fmt::format("Player {} ({}) sent OP_Disarm with source ID of: {}", GetCleanName(), GetID(), pmob->GetID());
database.SetMQDetectionFlag(this->account_name, this->name, hack_str, zone->GetShortName());
safe_delete_array(hack_str);
return;
}
// No disarm on corpses
@ -10031,17 +10026,15 @@ void Client::Handle_OP_MoveItem(const EQApplicationPacket *app)
{
if (mi->from_slot != mi->to_slot && (mi->from_slot <= EQ::invslot::GENERAL_END || mi->from_slot > 39) && IsValidSlot(mi->from_slot) && IsValidSlot(mi->to_slot))
{
char *detect = nullptr;
const EQ::ItemInstance *itm_from = GetInv().GetItem(mi->from_slot);
const EQ::ItemInstance *itm_to = GetInv().GetItem(mi->to_slot);
MakeAnyLenString(&detect, "Player issued a move item from %u(item id %u) to %u(item id %u) while casting %u.",
auto detect = fmt::format("Player issued a move item from {}(item id {}) to {}(item id {}) while casting {}.",
mi->from_slot,
itm_from ? itm_from->GetID() : 0,
mi->to_slot,
itm_to ? itm_to->GetID() : 0,
casting_spell_id);
database.SetMQDetectionFlag(AccountName(), GetName(), detect, zone->GetShortName());
safe_delete_array(detect);
Kick("Inventory desync"); // Kick client to prevent client and server from getting out-of-sync inventory slots
return;
}
@ -12983,12 +12976,10 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app)
if (!TakeMoneyFromPP(mpo->price))
{
char *hacker_str = nullptr;
MakeAnyLenString(&hacker_str, "Vendor Cheat: attempted to buy %i of %i: %s that cost %d cp but only has %d pp %d gp %d sp %d cp\n",
auto hacker_str = fmt::format("Vendor Cheat: attempted to buy {} of {}: {} that cost {} cp but only has {} pp {} gp {} sp {} cp",
mpo->quantity, item->ID, item->Name,
mpo->price, m_pp.platinum, m_pp.gold, m_pp.silver, m_pp.copper);
database.SetMQDetectionFlag(AccountName(), GetName(), hacker_str, zone->GetShortName());
safe_delete_array(hacker_str);
safe_delete(outapp);
safe_delete(inst);
return;
@ -13470,10 +13461,8 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app)
{
if (ClientVersion() < EQ::versions::ClientVersion::SoF)
{
char *hack_str = nullptr;
MakeAnyLenString(&hack_str, "Player sent OP_SpawnAppearance with AT_Invis: %i", sa->parameter);
auto hack_str = fmt::format("Player sent OP_SpawnAppearance with AT_Invis: {}", sa->parameter);
database.SetMQDetectionFlag(this->account_name, this->name, hack_str, zone->GetShortName());
safe_delete_array(hack_str);
}
}
return;
@ -13572,10 +13561,8 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app)
{
if (!HasSkill(EQ::skills::SkillSneak))
{
char *hack_str = nullptr;
MakeAnyLenString(&hack_str, "Player sent OP_SpawnAppearance with AT_Sneak: %i", sa->parameter);
auto hack_str = fmt::format("Player sent OP_SpawnAppearance with AT_Sneak: {}", sa->parameter);
database.SetMQDetectionFlag(this->account_name, this->name, hack_str, zone->GetShortName());
safe_delete_array(hack_str);
}
return;
}
@ -13584,10 +13571,8 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app)
}
else if (sa->type == AT_Size)
{
char *hack_str = nullptr;
MakeAnyLenString(&hack_str, "Player sent OP_SpawnAppearance with AT_Size: %i", sa->parameter);
auto hack_str = fmt::format("Player sent OP_SpawnAppearance with AT_Size: {}", sa->parameter);
database.SetMQDetectionFlag(this->account_name, this->name, hack_str, zone->GetShortName());
safe_delete_array(hack_str);
}
else if (sa->type == AT_Light) // client emitting light (lightstone, shiny shield)
{
@ -13927,11 +13912,9 @@ void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app)
else if (GetTarget()->GetBodyType() == BT_NoTarget2 || GetTarget()->GetBodyType() == BT_Special
|| GetTarget()->GetBodyType() == BT_NoTarget)
{
char *hacker_str = nullptr;
MakeAnyLenString(&hacker_str, "%s attempting to target something untargetable, %s bodytype: %i\n",
auto hacker_str = fmt::format("{} attempting to target something untargetable, {} bodytype: {}",
GetName(), GetTarget()->GetName(), (int)GetTarget()->GetBodyType());
database.SetMQDetectionFlag(AccountName(), GetName(), hacker_str, zone->GetShortName());
safe_delete_array(hacker_str);
SetTarget((Mob*)nullptr);
return;
}
@ -13951,13 +13934,15 @@ void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app)
{
if (DistanceSquared(m_Position, GetTarget()->GetPosition()) > (zone->newzone_data.maxclip*zone->newzone_data.maxclip))
{
char *hacker_str = nullptr;
MakeAnyLenString(&hacker_str, "%s attempting to target something beyond the clip plane of %.2f units,"
" from (%.2f, %.2f, %.2f) to %s (%.2f, %.2f, %.2f)", GetName(),
(zone->newzone_data.maxclip*zone->newzone_data.maxclip),
GetX(), GetY(), GetZ(), GetTarget()->GetName(), GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ());
auto hacker_str = fmt::format(
"{} attempting to target something beyond the clip plane of {:.2f} "
"units, from ({:.2f}, {:.2f}, {:.2f}) to {} ({:.2f}, {:.2f}, "
"{:.2f})",
GetName(),
(zone->newzone_data.maxclip * zone->newzone_data.maxclip), GetX(),
GetY(), GetZ(), GetTarget()->GetName(), GetTarget()->GetX(),
GetTarget()->GetY(), GetTarget()->GetZ());
database.SetMQDetectionFlag(AccountName(), GetName(), hacker_str, zone->GetShortName());
safe_delete_array(hacker_str);
SetTarget(nullptr);
return;
}
@ -13965,13 +13950,13 @@ void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app)
}
else if (DistanceSquared(m_Position, GetTarget()->GetPosition()) > (zone->newzone_data.maxclip*zone->newzone_data.maxclip))
{
char *hacker_str = nullptr;
MakeAnyLenString(&hacker_str, "%s attempting to target something beyond the clip plane of %.2f units,"
" from (%.2f, %.2f, %.2f) to %s (%.2f, %.2f, %.2f)", GetName(),
(zone->newzone_data.maxclip*zone->newzone_data.maxclip),
GetX(), GetY(), GetZ(), GetTarget()->GetName(), GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ());
auto hacker_str =
fmt::format("{} attempting to target something beyond the clip plane of {:.2f} "
"units, from ({:.2f}, {:.2f}, {:.2f}) to {} ({:.2f}, {:.2f}, {:.2f})",
GetName(), (zone->newzone_data.maxclip * zone->newzone_data.maxclip),
GetX(), GetY(), GetZ(), GetTarget()->GetName(), GetTarget()->GetX(),
GetTarget()->GetY(), GetTarget()->GetZ());
database.SetMQDetectionFlag(AccountName(), GetName(), hacker_str, zone->GetShortName());
safe_delete_array(hacker_str);
SetTarget(nullptr);
return;
}

View File

@ -1262,11 +1262,10 @@ void Client::OPMoveCoin(const EQApplicationPacket* app)
NPC *banker = entity_list.GetClosestBanker(this, distance);
if(!banker || distance > USE_NPC_RANGE2)
{
char *hacked_string = nullptr;
MakeAnyLenString(&hacked_string, "Player tried to make use of a banker(coin move) but %s is non-existant or too far away (%u units).",
banker ? banker->GetName() : "UNKNOWN NPC", distance);
auto hacked_string = fmt::format("Player tried to make use of a banker(coin move) but "
"{} is non-existant or too far away ({} units).",
banker ? banker->GetName() : "UNKNOWN NPC", distance);
database.SetMQDetectionFlag(AccountName(), GetName(), hacked_string, zone->GetShortName());
safe_delete_array(hacked_string);
return;
}
@ -1294,11 +1293,11 @@ void Client::OPMoveCoin(const EQApplicationPacket* app)
NPC *banker = entity_list.GetClosestBanker(this, distance);
if(!banker || distance > USE_NPC_RANGE2)
{
char *hacked_string = nullptr;
MakeAnyLenString(&hacked_string, "Player tried to make use of a banker(shared coin move) but %s is non-existant or too far away (%u units).",
banker ? banker->GetName() : "UNKNOWN NPC", distance);
auto hacked_string =
fmt::format("Player tried to make use of a banker(shared coin move) but {} is "
"non-existant or too far away ({} units).",
banker ? banker->GetName() : "UNKNOWN NPC", distance);
database.SetMQDetectionFlag(AccountName(), GetName(), hacked_string, zone->GetShortName());
safe_delete_array(hacked_string);
return;
}
if(mc->cointype1 == COINTYPE_PP) // there's only platinum here
@ -1350,11 +1349,10 @@ void Client::OPMoveCoin(const EQApplicationPacket* app)
NPC *banker = entity_list.GetClosestBanker(this, distance);
if(!banker || distance > USE_NPC_RANGE2)
{
char *hacked_string = nullptr;
MakeAnyLenString(&hacked_string, "Player tried to make use of a banker(coin move) but %s is non-existant or too far away (%u units).",
banker ? banker->GetName() : "UNKNOWN NPC", distance);
auto hacked_string = fmt::format("Player tried to make use of a banker(coin move) but "
"{} is non-existant or too far away ({} units).",
banker ? banker->GetName() : "UNKNOWN NPC", distance);
database.SetMQDetectionFlag(AccountName(), GetName(), hacked_string, zone->GetShortName());
safe_delete_array(hacked_string);
return;
}
switch(mc->cointype2)
@ -1394,11 +1392,11 @@ void Client::OPMoveCoin(const EQApplicationPacket* app)
NPC *banker = entity_list.GetClosestBanker(this, distance);
if(!banker || distance > USE_NPC_RANGE2)
{
char *hacked_string = nullptr;
MakeAnyLenString(&hacked_string, "Player tried to make use of a banker(shared coin move) but %s is non-existant or too far away (%u units).",
banker ? banker->GetName() : "UNKNOWN NPC", distance);
auto hacked_string =
fmt::format("Player tried to make use of a banker(shared coin move) but {} is "
"non-existant or too far away ({} units).",
banker ? banker->GetName() : "UNKNOWN NPC", distance);
database.SetMQDetectionFlag(AccountName(), GetName(), hacked_string, zone->GetShortName());
safe_delete_array(hacked_string);
return;
}
if(mc->cointype2 == COINTYPE_PP) // there's only platinum here

View File

@ -1270,12 +1270,11 @@ void PerlembParser::ExportItemVariables(std::string &package_name, Mob *mob)
perl->eval(std::string("%").append(hashname).append(" = ();").c_str());
for (int slot = EQ::invslot::EQUIPMENT_BEGIN; slot <= EQ::invslot::GENERAL_END; slot++) {
char *hi_decl = nullptr;
int itemid = mob->CastToClient()->GetItemIDAt(slot);
if (itemid != -1 && itemid != 0) {
MakeAnyLenString(&hi_decl, "push (@{$%s{%d}},%d);", hashname.c_str(), itemid, slot);
perl->eval(hi_decl);
safe_delete_array(hi_decl);
// this is really ugly with fmtlib, I think I did it right
auto hi_decl = fmt::format("push (@{{${0}{{{1}}}}},{2});", hashname, itemid, slot);
perl->eval(hi_decl.c_str());
}
}
}
@ -1283,12 +1282,11 @@ void PerlembParser::ExportItemVariables(std::string &package_name, Mob *mob)
if (mob && mob->IsClient()) {
std::string hashname = package_name + std::string("::oncursor");
perl->eval(std::string("%").append(hashname).append(" = ();").c_str());
char *hi_decl = nullptr;
int itemid = mob->CastToClient()->GetItemIDAt(EQ::invslot::slotCursor);
if (itemid != -1 && itemid != 0) {
MakeAnyLenString(&hi_decl, "push (@{$%s{%d}},%d);", hashname.c_str(), itemid, EQ::invslot::slotCursor);
perl->eval(hi_decl);
safe_delete_array(hi_decl);
// this is really ugly with fmtlib, I think I did it right
auto hi_decl = fmt::format("push (@{{${0}{{{1}}}}},{2});", hashname, itemid, EQ::invslot::slotCursor);
perl->eval(hi_decl.c_str());
}
}
}

View File

@ -1355,6 +1355,7 @@ bool MakeItemLink(char* &ret_link, const ItemData *item, uint32 aug0, uint32 aug
#endif
int Client::GetItemLinkHash(const EQ::ItemInstance* inst) {
#if 0
//pre-Titanium: http://eqitems.13th-floor.org/phpBB2/viewtopic.php?t=70&postdays=0&postorder=asc
//Titanium: http://eqitems.13th-floor.org/phpBB2/viewtopic.php?t=145
if (!inst) //have to have an item to make the hash
@ -1440,6 +1441,8 @@ int Client::GetItemLinkHash(const EQ::ItemInstance* inst) {
safe_delete_array(hash_str);
return hash;
#endif
return 0;
}
// This appears to still be in use... The core of this should be incorporated into class EQ::SayLinkEngine
@ -1626,11 +1629,10 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
if(!banker || distance > USE_NPC_RANGE2)
{
char *hacked_string = nullptr;
MakeAnyLenString(&hacked_string, "Player tried to make use of a banker(items) but %s is non-existant or too far away (%u units).",
banker ? banker->GetName() : "UNKNOWN NPC", distance);
auto hacked_string = fmt::format("Player tried to make use of a banker(items) but {} is "
"non-existant or too far away ({} units).",
banker ? banker->GetName() : "UNKNOWN NPC", distance);
database.SetMQDetectionFlag(AccountName(), GetName(), hacked_string, zone->GetShortName());
safe_delete_array(hacked_string);
Kick("Inventory desync"); // Kicking player to avoid item loss do to client and server inventories not being sync'd
return false;
}

View File

@ -2154,16 +2154,9 @@ bool Merc::AICastSpell(int8 iChance, uint32 iSpellTypes) {
}
if(castedSpell) {
char* gmsg = nullptr;
if(tar && tar != this) { // [tar] was implicitly valid at this point..this change is to catch any bad logic
//we don't need spam of bots healing themselves
MakeAnyLenString(&gmsg, "Casting %s on %s.", spells[selectedMercSpell.spellid].name, tar->GetCleanName());
if(gmsg)
{
MercGroupSay(this, gmsg);
safe_delete_array(gmsg);
}
MercGroupSay(this, "Casting %s on %s.", spells[selectedMercSpell.spellid].name, tar->GetCleanName());
}
}