[Feature] GM State Change Persistance (#2328)

* [Feature] GM State Change Persistance

- Flymode and Invulnerable will now persist over zoning.

- Appended GMSpeed, Flymode and Invulnerable to the hideme message GMs see when they first login.

- Added #godmode [on/off] command to turn on or off hideme, flymode, gmspeed and invulnerable all in one shot.

- /becomenpc will now disable tells to the target player. It will also automatically disable GM States that interfere with its functionality.

- GM Command /toggle will not properly turn tells on/off

- GMs will now be notified if they are ignoring tells when they first zone-in, provided their GM flag is up.

- Added TellsOff variable to the output to #showstats

* [Bug] Fix tells when gmhideme is turned off.

* [Cleanup] Cleanup function and rename for consistancy.

Remove un-needed this->

* Tweaks

* Tweaks

* Update db_update_manifest.txt

* Move string building logic to a vector and use strings join

* Update client_packet.cpp

* Update 2022_07_28_gm_state_changes.sql

* PR comment tweaks

Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
Michael 2022-07-30 20:29:24 -04:00 committed by GitHub
parent 793d4bc3a4
commit ea878ed27f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 252 additions and 125 deletions

View File

@ -28,6 +28,9 @@ public:
std::string ls_id; std::string ls_id;
int lsaccount_id; int lsaccount_id;
int gmspeed; int gmspeed;
int invulnerable;
int flymode;
int ignore_tells;
int revoked; int revoked;
int karma; int karma;
std::string minilogin_ip; std::string minilogin_ip;
@ -60,6 +63,9 @@ public:
"ls_id", "ls_id",
"lsaccount_id", "lsaccount_id",
"gmspeed", "gmspeed",
"invulnerable",
"flymode",
"ignore_tells",
"revoked", "revoked",
"karma", "karma",
"minilogin_ip", "minilogin_ip",
@ -88,6 +94,9 @@ public:
"ls_id", "ls_id",
"lsaccount_id", "lsaccount_id",
"gmspeed", "gmspeed",
"invulnerable",
"flymode",
"ignore_tells",
"revoked", "revoked",
"karma", "karma",
"minilogin_ip", "minilogin_ip",
@ -150,6 +159,9 @@ public:
entry.ls_id = "eqemu"; entry.ls_id = "eqemu";
entry.lsaccount_id = 0; entry.lsaccount_id = 0;
entry.gmspeed = 0; entry.gmspeed = 0;
entry.invulnerable = 0;
entry.flymode = 0;
entry.ignore_tells = 0;
entry.revoked = 0; entry.revoked = 0;
entry.karma = 0; entry.karma = 0;
entry.minilogin_ip = ""; entry.minilogin_ip = "";
@ -207,19 +219,22 @@ public:
entry.ls_id = row[6] ? row[6] : ""; entry.ls_id = row[6] ? row[6] : "";
entry.lsaccount_id = atoi(row[7]); entry.lsaccount_id = atoi(row[7]);
entry.gmspeed = atoi(row[8]); entry.gmspeed = atoi(row[8]);
entry.revoked = atoi(row[9]); entry.invulnerable = atoi(row[9]);
entry.karma = atoi(row[10]); entry.flymode = atoi(row[10]);
entry.minilogin_ip = row[11] ? row[11] : ""; entry.ignore_tells = atoi(row[11]);
entry.hideme = atoi(row[12]); entry.revoked = atoi(row[12]);
entry.rulesflag = atoi(row[13]); entry.karma = atoi(row[13]);
entry.suspendeduntil = strtoll(row[14] ? row[14] : "-1", nullptr, 10); entry.minilogin_ip = row[14] ? row[14] : "";
entry.time_creation = atoi(row[15]); entry.hideme = atoi(row[15]);
entry.expansion = atoi(row[16]); entry.rulesflag = atoi(row[16]);
entry.ban_reason = row[17] ? row[17] : ""; entry.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10);
entry.suspend_reason = row[18] ? row[18] : ""; entry.time_creation = atoi(row[18]);
entry.crc_eqgame = row[19] ? row[19] : ""; entry.expansion = atoi(row[19]);
entry.crc_skillcaps = row[20] ? row[20] : ""; entry.ban_reason = row[20] ? row[20] : "";
entry.crc_basedata = row[21] ? row[21] : ""; entry.suspend_reason = row[21] ? row[21] : "";
entry.crc_eqgame = row[22] ? row[22] : "";
entry.crc_skillcaps = row[23] ? row[23] : "";
entry.crc_basedata = row[24] ? row[24] : "";
return entry; return entry;
} }
@ -261,19 +276,22 @@ public:
update_values.push_back(columns[6] + " = '" + Strings::Escape(account_entry.ls_id) + "'"); update_values.push_back(columns[6] + " = '" + Strings::Escape(account_entry.ls_id) + "'");
update_values.push_back(columns[7] + " = " + std::to_string(account_entry.lsaccount_id)); update_values.push_back(columns[7] + " = " + std::to_string(account_entry.lsaccount_id));
update_values.push_back(columns[8] + " = " + std::to_string(account_entry.gmspeed)); update_values.push_back(columns[8] + " = " + std::to_string(account_entry.gmspeed));
update_values.push_back(columns[9] + " = " + std::to_string(account_entry.revoked)); update_values.push_back(columns[9] + " = " + std::to_string(account_entry.invulnerable));
update_values.push_back(columns[10] + " = " + std::to_string(account_entry.karma)); update_values.push_back(columns[10] + " = " + std::to_string(account_entry.flymode));
update_values.push_back(columns[11] + " = '" + Strings::Escape(account_entry.minilogin_ip) + "'"); update_values.push_back(columns[11] + " = " + std::to_string(account_entry.ignore_tells));
update_values.push_back(columns[12] + " = " + std::to_string(account_entry.hideme)); update_values.push_back(columns[12] + " = " + std::to_string(account_entry.revoked));
update_values.push_back(columns[13] + " = " + std::to_string(account_entry.rulesflag)); update_values.push_back(columns[13] + " = " + std::to_string(account_entry.karma));
update_values.push_back(columns[14] + " = FROM_UNIXTIME(" + (account_entry.suspendeduntil > 0 ? std::to_string(account_entry.suspendeduntil) : "null") + ")"); update_values.push_back(columns[14] + " = '" + Strings::Escape(account_entry.minilogin_ip) + "'");
update_values.push_back(columns[15] + " = " + std::to_string(account_entry.time_creation)); update_values.push_back(columns[15] + " = " + std::to_string(account_entry.hideme));
update_values.push_back(columns[16] + " = " + std::to_string(account_entry.expansion)); update_values.push_back(columns[16] + " = " + std::to_string(account_entry.rulesflag));
update_values.push_back(columns[17] + " = '" + Strings::Escape(account_entry.ban_reason) + "'"); update_values.push_back(columns[17] + " = FROM_UNIXTIME(" + (account_entry.suspendeduntil > 0 ? std::to_string(account_entry.suspendeduntil) : "null") + ")");
update_values.push_back(columns[18] + " = '" + Strings::Escape(account_entry.suspend_reason) + "'"); update_values.push_back(columns[18] + " = " + std::to_string(account_entry.time_creation));
update_values.push_back(columns[19] + " = '" + Strings::Escape(account_entry.crc_eqgame) + "'"); update_values.push_back(columns[19] + " = " + std::to_string(account_entry.expansion));
update_values.push_back(columns[20] + " = '" + Strings::Escape(account_entry.crc_skillcaps) + "'"); update_values.push_back(columns[20] + " = '" + Strings::Escape(account_entry.ban_reason) + "'");
update_values.push_back(columns[21] + " = '" + Strings::Escape(account_entry.crc_basedata) + "'"); update_values.push_back(columns[21] + " = '" + Strings::Escape(account_entry.suspend_reason) + "'");
update_values.push_back(columns[22] + " = '" + Strings::Escape(account_entry.crc_eqgame) + "'");
update_values.push_back(columns[23] + " = '" + Strings::Escape(account_entry.crc_skillcaps) + "'");
update_values.push_back(columns[24] + " = '" + Strings::Escape(account_entry.crc_basedata) + "'");
auto results = db.QueryDatabase( auto results = db.QueryDatabase(
fmt::format( fmt::format(
@ -304,6 +322,9 @@ public:
insert_values.push_back("'" + Strings::Escape(account_entry.ls_id) + "'"); insert_values.push_back("'" + Strings::Escape(account_entry.ls_id) + "'");
insert_values.push_back(std::to_string(account_entry.lsaccount_id)); insert_values.push_back(std::to_string(account_entry.lsaccount_id));
insert_values.push_back(std::to_string(account_entry.gmspeed)); insert_values.push_back(std::to_string(account_entry.gmspeed));
insert_values.push_back(std::to_string(account_entry.invulnerable));
insert_values.push_back(std::to_string(account_entry.flymode));
insert_values.push_back(std::to_string(account_entry.ignore_tells));
insert_values.push_back(std::to_string(account_entry.revoked)); insert_values.push_back(std::to_string(account_entry.revoked));
insert_values.push_back(std::to_string(account_entry.karma)); insert_values.push_back(std::to_string(account_entry.karma));
insert_values.push_back("'" + Strings::Escape(account_entry.minilogin_ip) + "'"); insert_values.push_back("'" + Strings::Escape(account_entry.minilogin_ip) + "'");
@ -355,6 +376,9 @@ public:
insert_values.push_back("'" + Strings::Escape(account_entry.ls_id) + "'"); insert_values.push_back("'" + Strings::Escape(account_entry.ls_id) + "'");
insert_values.push_back(std::to_string(account_entry.lsaccount_id)); insert_values.push_back(std::to_string(account_entry.lsaccount_id));
insert_values.push_back(std::to_string(account_entry.gmspeed)); insert_values.push_back(std::to_string(account_entry.gmspeed));
insert_values.push_back(std::to_string(account_entry.invulnerable));
insert_values.push_back(std::to_string(account_entry.flymode));
insert_values.push_back(std::to_string(account_entry.ignore_tells));
insert_values.push_back(std::to_string(account_entry.revoked)); insert_values.push_back(std::to_string(account_entry.revoked));
insert_values.push_back(std::to_string(account_entry.karma)); insert_values.push_back(std::to_string(account_entry.karma));
insert_values.push_back("'" + Strings::Escape(account_entry.minilogin_ip) + "'"); insert_values.push_back("'" + Strings::Escape(account_entry.minilogin_ip) + "'");
@ -410,19 +434,22 @@ public:
entry.ls_id = row[6] ? row[6] : ""; entry.ls_id = row[6] ? row[6] : "";
entry.lsaccount_id = atoi(row[7]); entry.lsaccount_id = atoi(row[7]);
entry.gmspeed = atoi(row[8]); entry.gmspeed = atoi(row[8]);
entry.revoked = atoi(row[9]); entry.invulnerable = atoi(row[9]);
entry.karma = atoi(row[10]); entry.flymode = atoi(row[10]);
entry.minilogin_ip = row[11] ? row[11] : ""; entry.ignore_tells = atoi(row[11]);
entry.hideme = atoi(row[12]); entry.revoked = atoi(row[12]);
entry.rulesflag = atoi(row[13]); entry.karma = atoi(row[13]);
entry.suspendeduntil = strtoll(row[14] ? row[14] : "-1", nullptr, 10); entry.minilogin_ip = row[14] ? row[14] : "";
entry.time_creation = atoi(row[15]); entry.hideme = atoi(row[15]);
entry.expansion = atoi(row[16]); entry.rulesflag = atoi(row[16]);
entry.ban_reason = row[17] ? row[17] : ""; entry.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10);
entry.suspend_reason = row[18] ? row[18] : ""; entry.time_creation = atoi(row[18]);
entry.crc_eqgame = row[19] ? row[19] : ""; entry.expansion = atoi(row[19]);
entry.crc_skillcaps = row[20] ? row[20] : ""; entry.ban_reason = row[20] ? row[20] : "";
entry.crc_basedata = row[21] ? row[21] : ""; entry.suspend_reason = row[21] ? row[21] : "";
entry.crc_eqgame = row[22] ? row[22] : "";
entry.crc_skillcaps = row[23] ? row[23] : "";
entry.crc_basedata = row[24] ? row[24] : "";
all_entries.push_back(entry); all_entries.push_back(entry);
} }
@ -456,19 +483,22 @@ public:
entry.ls_id = row[6] ? row[6] : ""; entry.ls_id = row[6] ? row[6] : "";
entry.lsaccount_id = atoi(row[7]); entry.lsaccount_id = atoi(row[7]);
entry.gmspeed = atoi(row[8]); entry.gmspeed = atoi(row[8]);
entry.revoked = atoi(row[9]); entry.invulnerable = atoi(row[9]);
entry.karma = atoi(row[10]); entry.flymode = atoi(row[10]);
entry.minilogin_ip = row[11] ? row[11] : ""; entry.ignore_tells = atoi(row[11]);
entry.hideme = atoi(row[12]); entry.revoked = atoi(row[12]);
entry.rulesflag = atoi(row[13]); entry.karma = atoi(row[13]);
entry.suspendeduntil = strtoll(row[14] ? row[14] : "-1", nullptr, 10); entry.minilogin_ip = row[14] ? row[14] : "";
entry.time_creation = atoi(row[15]); entry.hideme = atoi(row[15]);
entry.expansion = atoi(row[16]); entry.rulesflag = atoi(row[16]);
entry.ban_reason = row[17] ? row[17] : ""; entry.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10);
entry.suspend_reason = row[18] ? row[18] : ""; entry.time_creation = atoi(row[18]);
entry.crc_eqgame = row[19] ? row[19] : ""; entry.expansion = atoi(row[19]);
entry.crc_skillcaps = row[20] ? row[20] : ""; entry.ban_reason = row[20] ? row[20] : "";
entry.crc_basedata = row[21] ? row[21] : ""; entry.suspend_reason = row[21] ? row[21] : "";
entry.crc_eqgame = row[22] ? row[22] : "";
entry.crc_skillcaps = row[23] ? row[23] : "";
entry.crc_basedata = row[24] ? row[24] : "";
all_entries.push_back(entry); all_entries.push_back(entry);
} }

View File

@ -39,6 +39,7 @@
#include "eqemu_config.h" #include "eqemu_config.h"
#include "data_verification.h" #include "data_verification.h"
#include "repositories/criteria/content_filter_criteria.h" #include "repositories/criteria/content_filter_criteria.h"
#include "repositories/account_repository.h"
namespace ItemField namespace ItemField
{ {
@ -65,40 +66,56 @@ SharedDatabase::~SharedDatabase() = default;
bool SharedDatabase::SetHideMe(uint32 account_id, uint8 hideme) bool SharedDatabase::SetHideMe(uint32 account_id, uint8 hideme)
{ {
const std::string query = StringFormat("UPDATE account SET hideme = %i WHERE id = %i", hideme, account_id); auto a = AccountRepository::FindOne(*this, account_id);
const auto results = QueryDatabase(query); if (a.id > 0) {
if (!results.Success()) { a.hideme = hideme ? 1 : 0;
return false; AccountRepository::UpdateOne(*this, a);
} }
return true; return a.id > 0;
} }
uint8 SharedDatabase::GetGMSpeed(uint32 account_id) uint8 SharedDatabase::GetGMSpeed(uint32 account_id)
{ {
const std::string query = StringFormat("SELECT gmspeed FROM account WHERE id = '%i'", account_id); auto a = AccountRepository::FindOne(*this, account_id);
auto results = QueryDatabase(query); if (a.id > 0) {
if (!results.Success()) { return a.gmspeed;
return 0;
} }
if (results.RowCount() != 1) return 0;
return 0;
auto& row = results.begin();
return atoi(row[0]);
} }
bool SharedDatabase::SetGMSpeed(uint32 account_id, uint8 gmspeed) bool SharedDatabase::SetGMSpeed(uint32 account_id, uint8 gmspeed)
{ {
const std::string query = StringFormat("UPDATE account SET gmspeed = %i WHERE id = %i", gmspeed, account_id); auto a = AccountRepository::FindOne(*this, account_id);
const auto results = QueryDatabase(query); if (a.id > 0) {
if (!results.Success()) { a.gmspeed = gmspeed ? 1 : 0;
return false; AccountRepository::UpdateOne(*this, a);
} }
return true; return a.id > 0;
}
bool SharedDatabase::SetGMInvul(uint32 account_id, bool gminvul)
{
auto a = AccountRepository::FindOne(*this, account_id);
if (a.id > 0) {
a.invulnerable = gminvul ? 1 : 0;
AccountRepository::UpdateOne(*this, a);
}
return a.id > 0;
}
bool SharedDatabase::SetGMFlymode(uint32 account_id, uint8 flymode)
{
auto a = AccountRepository::FindOne(*this, account_id);
if (a.id > 0) {
a.flymode = flymode;
AccountRepository::UpdateOne(*this, a);
}
return a.id > 0;
} }
uint32 SharedDatabase::GetTotalTimeEntitledOnAccount(uint32 AccountID) { uint32 SharedDatabase::GetTotalTimeEntitledOnAccount(uint32 AccountID) {

View File

@ -79,6 +79,8 @@ public:
bool UpdateInjectedCommandSettings(const std::vector<std::pair<std::string, uint8>> &injected); bool UpdateInjectedCommandSettings(const std::vector<std::pair<std::string, uint8>> &injected);
bool UpdateOrphanedCommandSettings(const std::vector<std::string> &orphaned); bool UpdateOrphanedCommandSettings(const std::vector<std::string> &orphaned);
uint32 GetTotalTimeEntitledOnAccount(uint32 AccountID); uint32 GetTotalTimeEntitledOnAccount(uint32 AccountID);
bool SetGMInvul(uint32 account_id, bool gminvul);
bool SetGMFlymode(uint32 account_id, uint8 flymode);
void SetMailKey(int CharID, int IPAddress, int MailKey); void SetMailKey(int CharID, int IPAddress, int MailKey);
std::string GetMailKey(int CharID, bool key_only = false); std::string GetMailKey(int CharID, bool key_only = false);
bool SaveCursor( bool SaveCursor(

View File

@ -444,6 +444,7 @@
9188|2022_07_14_zone_expansion_revert.sql|SHOW COLUMNS FROM `zone` LIKE 'expansion'|empty| 9188|2022_07_14_zone_expansion_revert.sql|SHOW COLUMNS FROM `zone` LIKE 'expansion'|empty|
9189|2022_07_10_character_task_rewarded.sql|SHOW COLUMNS FROM `character_tasks` LIKE 'was_rewarded'|empty| 9189|2022_07_10_character_task_rewarded.sql|SHOW COLUMNS FROM `character_tasks` LIKE 'was_rewarded'|empty|
9190|2022_07_13_task_reward_points.sql|SHOW COLUMNS FROM `tasks` LIKE 'reward_points'|empty| 9190|2022_07_13_task_reward_points.sql|SHOW COLUMNS FROM `tasks` LIKE 'reward_points'|empty|
9191|2022_07_28_gm_state_changes.sql|SHOW COLUMNS FROM `account` LIKE 'invulnerable'|empty|
# Upgrade conditions: # Upgrade conditions:
# This won't be needed after this system is implemented, but it is used database that are not # This won't be needed after this system is implemented, but it is used database that are not

View File

@ -0,0 +1,4 @@
ALTER TABLE `account`
ADD COLUMN `invulnerable` TINYINT(4) NULL DEFAULT '0' AFTER `gmspeed`,
ADD COLUMN `flymode` TINYINT(4) NULL DEFAULT '0' AFTER `invulnerable`,
ADD COLUMN `ignore_tells` TINYINT(4) NULL DEFAULT '0' AFTER `flymode`;

View File

@ -457,27 +457,25 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) {
( (
cle->TellsOff() && cle->TellsOff() &&
( (
( scm->fromadmin < cle->Admin()
cle->Anon() == 1 && || scm->fromadmin < AccountStatus::QuestTroupe
scm->fromadmin < cle->Admin()
) ||
scm->fromadmin < AccountStatus::QuestTroupe
) )
) )
) { ) {
if (!scm->noreply) { if (!scm->noreply) {
auto sender = client_list.FindCharacter(scm->from); auto sender = client_list.FindCharacter(scm->from);
if (!sender || !sender->Server()) { if (!sender || !sender->Server()) {
break; break;
} }
scm->noreply = true; scm->noreply = true;
scm->queued = 3; // offline scm->queued = 3; // offline
scm->chan_num = ChatChannel_TellEcho; scm->chan_num = ChatChannel_TellEcho;
strcpy(scm->deliverto, scm->from); strcpy(scm->deliverto, scm->from);
sender->Server()->SendPacket(pack); sender->Server()->SendPacket(pack);
} }
} else if (cle->Online() == CLE_Status::Zoning) { }
else if (cle->Online() == CLE_Status::Zoning) {
if (!scm->noreply) { if (!scm->noreply) {
auto sender = client_list.FindCharacter(scm->from); auto sender = client_list.FindCharacter(scm->from);
if (cle->TellQueueFull()) { if (cle->TellQueueFull()) {

View File

@ -220,6 +220,7 @@ Client::Client(EQStreamInterface* ieqs)
LFGComments[0] = '\0'; LFGComments[0] = '\0';
LFP = false; LFP = false;
gmspeed = 0; gmspeed = 0;
gminvul = false;
playeraction = 0; playeraction = 0;
SetTarget(0); SetTarget(0);
auto_attack = false; auto_attack = false;
@ -3378,27 +3379,26 @@ void Client::SetTint(int16 in_slot, EQ::textures::Tint_Struct& color) {
} }
void Client::SetHideMe(bool flag) void Client::SetHideMe(bool gm_hide_me)
{ {
EQApplicationPacket app; EQApplicationPacket app;
gm_hide_me = flag; if (gm_hide_me) {
database.SetHideMe(AccountID(), true);
if(gm_hide_me)
{
database.SetHideMe(AccountID(),true);
CreateDespawnPacket(&app, false); CreateDespawnPacket(&app, false);
entity_list.RemoveFromTargets(this); entity_list.RemoveFromTargets(this);
trackable = false; trackable = false;
tellsoff = true;
} }
else else {
{ database.SetHideMe(AccountID(), false);
database.SetHideMe(AccountID(),false);
CreateSpawnPacket(&app); CreateSpawnPacket(&app);
trackable = true; trackable = true;
tellsoff = false;
} }
entity_list.QueueClientsStatus(this, &app, true, 0, Admin()-1); entity_list.QueueClientsStatus(this, &app, true, 0, Admin() - 1);
UpdateWho();
} }
void Client::SetLanguageSkill(int langid, int value) void Client::SetLanguageSkill(int langid, int value)
@ -7092,6 +7092,7 @@ void Client::SendStatsWindow(Client* client, bool use_window)
client->Message(Chat::White, " compute_tohit: %i TotalToHit: %i", compute_tohit(skill), GetTotalToHit(skill, 0)); client->Message(Chat::White, " compute_tohit: %i TotalToHit: %i", compute_tohit(skill), GetTotalToHit(skill, 0));
client->Message(Chat::White, " compute_defense: %i TotalDefense: %i", compute_defense(), GetTotalDefense()); client->Message(Chat::White, " compute_defense: %i TotalDefense: %i", compute_defense(), GetTotalDefense());
client->Message(Chat::White, " offense: %i mitigation ac: %i", offense(skill), GetMitigationAC()); client->Message(Chat::White, " offense: %i mitigation ac: %i", offense(skill), GetMitigationAC());
client->Message(Chat::White, " AFK: %i LFG: %i Anon: %i PVP: %i GM: %i Flymode: %i GMSpeed: %i Hideme: %i GMInvul: %d LD: %i ClientVersion: %i TellsOff: %i", AFK, LFG, GetAnon(), GetPVP(), GetGM(), flymode, GetGMSpeed(), GetHideMe(), GetGMInvul(), IsLD(), ClientVersionBit(), tellsoff);
if(CalcMaxMana() > 0) if(CalcMaxMana() > 0)
client->Message(Chat::White, " Mana: %i/%i Mana Regen: %i/%i", GetMana(), GetMaxMana(), CalcManaRegen(), CalcManaRegenCap()); client->Message(Chat::White, " Mana: %i/%i Mana Regen: %i/%i", GetMana(), GetMaxMana(), CalcManaRegen(), CalcManaRegenCap());
client->Message(Chat::White, " End.: %i/%i End. Regen: %i/%i",GetEndurance(), GetMaxEndurance(), CalcEnduranceRegen(), CalcEnduranceRegenCap()); client->Message(Chat::White, " End.: %i/%i End. Regen: %i/%i",GetEndurance(), GetMaxEndurance(), CalcEnduranceRegen(), CalcEnduranceRegenCap());

View File

@ -1040,6 +1040,7 @@ public:
void SendRules(); void SendRules();
const bool GetGMSpeed() const { return (gmspeed > 0); } const bool GetGMSpeed() const { return (gmspeed > 0); }
const bool GetGMInvul() const { return gminvul; }
bool CanUseReport; bool CanUseReport;
//This is used to later set the buff duration of the spell, in slot to duration. //This is used to later set the buff duration of the spell, in slot to duration.
@ -1786,6 +1787,7 @@ private:
bool auto_fire; bool auto_fire;
bool runmode; bool runmode;
uint8 gmspeed; uint8 gmspeed;
bool gminvul;
bool medding; bool medding;
uint16 horseId; uint16 horseId;
bool revoked; bool revoked;

View File

@ -68,6 +68,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "../common/shared_tasks.h" #include "../common/shared_tasks.h"
#include "gm_commands/door_manipulation.h" #include "gm_commands/door_manipulation.h"
#include "client.h" #include "client.h"
#include "../common/repositories/account_repository.h"
#ifdef BOTS #ifdef BOTS
@ -569,7 +570,31 @@ void Client::CompleteConnect()
//SendAATable(); //SendAATable();
if (GetHideMe()) Message(Chat::Red, "[GM] You are currently hidden to all clients"); if (GetGM() && (GetHideMe() || GetGMSpeed() || GetGMInvul() || flymode != 0 || tellsoff)) {
std::vector<std::string> state;
if (GetHideMe()) {
state.emplace_back("hidden to all clients");
}
if (GetGMSpeed()) {
state.emplace_back("running at GM speed");
}
if (GetGMInvul()) {
state.emplace_back("invulnerable to all damage");
}
if (flymode == GravityBehavior::Flying) {
state.emplace_back("flying");
}
else if (flymode == GravityBehavior::Levitating) {
state.emplace_back("levitating");
}
if (tellsoff) {
state.emplace_back("ignoring tells");
}
if (!state.empty()) {
Message(Chat::Red, "[GM] You are currently %s.", Strings::Join(state, ", ").c_str());
}
}
uint32 raidid = database.GetRaidID(GetName()); uint32 raidid = database.GetRaidID(GetName());
Raid *raid = nullptr; Raid *raid = nullptr;
@ -1184,23 +1209,25 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
database.RemoveTempFactions(this); database.RemoveTempFactions(this);
database.LoadCharacterFactionValues(cid, factionvalues); database.LoadCharacterFactionValues(cid, factionvalues);
/* Load Character Account Data: Temp until I move */ auto a = AccountRepository::FindOne(database, AccountID());
query = StringFormat("SELECT `status`, `name`, `ls_id`, `lsaccount_id`, `gmspeed`, `revoked`, `hideme`, `time_creation` FROM `account` WHERE `id` = %u", AccountID()); if (a.id > 0) {
auto results = database.QueryDatabase(query); strn0cpy(account_name, a.name.c_str(), sizeof(account_name));
for (auto row = results.begin(); row != results.end(); ++row) { strn0cpy(loginserver, a.ls_id.c_str(), sizeof(loginserver));
admin = atoi(row[0]);
strn0cpy(account_name, row[1], sizeof(account_name)); admin = a.status;
strn0cpy(loginserver, row[2], sizeof(loginserver)); lsaccountid = a.lsaccount_id;
lsaccountid = atoi(row[3]); gmspeed = a.gmspeed;
gmspeed = atoi(row[4]); revoked = a.revoked;
revoked = atoi(row[5]); gm_hide_me = a.hideme;
gm_hide_me = atoi(row[6]); account_creation = a.time_creation;
account_creation = atoul(row[7]); gminvul = a.invulnerable;
flymode = static_cast<GravityBehavior>(a.flymode);
tellsoff = gm_hide_me;
} }
/* Load Character Data */ /* Load Character Data */
query = StringFormat("SELECT `lfp`, `lfg`, `xtargets`, `firstlogon`, `guild_id`, `rank` FROM `character_data` LEFT JOIN `guild_members` ON `id` = `char_id` WHERE `id` = %i", cid); query = StringFormat("SELECT `lfp`, `lfg`, `xtargets`, `firstlogon`, `guild_id`, `rank` FROM `character_data` LEFT JOIN `guild_members` ON `id` = `char_id` WHERE `id` = %i", cid);
results = database.QueryDatabase(query); auto results = database.QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
if (row[4] && atoi(row[4]) > 0) { if (row[4] && atoi(row[4]) > 0) {
guild_id = atoi(row[4]); guild_id = atoi(row[4]);
@ -1266,6 +1293,8 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
/* If GM, not trackable */ /* If GM, not trackable */
if (gm_hide_me) { trackable = false; } if (gm_hide_me) { trackable = false; }
if (gminvul) { invulnerable = true; }
if (flymode > 0) { SendAppearancePacket(AT_Levitate, flymode); }
/* Set Con State for Reporting */ /* Set Con State for Reporting */
conn_state = PlayerProfileLoaded; conn_state = PlayerProfileLoaded;
@ -6117,17 +6146,26 @@ void Client::Handle_OP_GMBecomeNPC(const EQApplicationPacket *app)
BecomeNPC_Struct* bnpc = (BecomeNPC_Struct*)app->pBuffer; BecomeNPC_Struct* bnpc = (BecomeNPC_Struct*)app->pBuffer;
Mob* cli = (Mob*)entity_list.GetMob(bnpc->id); Mob* cli = (Mob*)entity_list.GetMob(bnpc->id);
if (cli == 0) if (cli == nullptr) {
return; return;
}
if (cli->IsClient()) if (cli->IsClient()) {
cli->CastToClient()->QueuePacket(app); Client* target = cli->CastToClient();
cli->SendAppearancePacket(AT_NPCName, 1, true); target->QueuePacket(app);
cli->CastToClient()->SetBecomeNPC(true); if(target->GetGM()) {
cli->CastToClient()->SetBecomeNPCLevel(bnpc->maxlevel); target->SetInvul(false);
cli->MessageString(Chat::White, TOGGLE_OFF); target->SetHideMe(false);
cli->CastToClient()->tellsoff = true; target->SetGM(false);
//TODO: Make this toggle a BecomeNPC flag so that it gets updated when people zone in as well; Make combat work with this. }
cli->SendAppearancePacket(AT_NPCName, 1, true);
target->SetBecomeNPC(true);
target->SetBecomeNPCLevel(bnpc->maxlevel);
cli->MessageString(Chat::White, TOGGLE_OFF);
target->tellsoff = true;
target->UpdateWho();
}
return; return;
} }
@ -6532,16 +6570,12 @@ void Client::Handle_OP_GMToggle(const EQApplicationPacket *app)
GMToggle_Struct *ts = (GMToggle_Struct *)app->pBuffer; GMToggle_Struct *ts = (GMToggle_Struct *)app->pBuffer;
if (ts->toggle == 0) { if (ts->toggle == 0) {
MessageString(Chat::White, TOGGLE_OFF); MessageString(Chat::White, TOGGLE_OFF);
//Message(0, "Turning tells OFF");
tellsoff = true; tellsoff = true;
} } else if (ts->toggle == 1) {
else if (ts->toggle == 1) {
//Message(0, "Turning tells ON");
MessageString(Chat::White, TOGGLE_ON); MessageString(Chat::White, TOGGLE_ON);
tellsoff = false; tellsoff = false;
} } else {
else { Message(Chat::White, "Unkown value in /toggle packet");
Message(0, "Unkown value in /toggle packet");
} }
UpdateWho(); UpdateWho();
return; return;

View File

@ -166,6 +166,7 @@ int command_init(void)
command_add("gm", "[On|Off] - Modify your or your target's GM Flag", AccountStatus::QuestTroupe, command_gm) || command_add("gm", "[On|Off] - Modify your or your target's GM Flag", AccountStatus::QuestTroupe, command_gm) ||
command_add("gmspeed", "[On|Off] - Turn GM Speed On or Off for you or your player target", AccountStatus::GMAdmin, command_gmspeed) || command_add("gmspeed", "[On|Off] - Turn GM Speed On or Off for you or your player target", AccountStatus::GMAdmin, command_gmspeed) ||
command_add("gmzone", "[Zone ID|Zone Short Name] [Version] [Instance Identifier] - Zones to a private GM instance (Version defaults to 0 and Instance Identifier defaults to 'gmzone' if not used)", AccountStatus::GMAdmin, command_gmzone) || command_add("gmzone", "[Zone ID|Zone Short Name] [Version] [Instance Identifier] - Zones to a private GM instance (Version defaults to 0 and Instance Identifier defaults to 'gmzone' if not used)", AccountStatus::GMAdmin, command_gmzone) ||
command_add("godmode", "[on/off] - Turns on/off hideme, gmspeed, invul, and flymode.", AccountStatus::GMMgmt, command_godmode) ||
command_add("goto", "[playername] or [x y z] [h] - Teleport to the provided coordinates or to your target", AccountStatus::Steward, command_goto) || command_add("goto", "[playername] or [x y z] [h] - Teleport to the provided coordinates or to your target", AccountStatus::Steward, command_goto) ||
command_add("grid", "[add/delete] [grid_num] [wandertype] [pausetype] - Create/delete a wandering grid", AccountStatus::GMAreas, command_grid) || command_add("grid", "[add/delete] [grid_num] [wandertype] [pausetype] - Create/delete a wandering grid", AccountStatus::GMAreas, command_grid) ||
command_add("guild", "Guild manipulation commands. Use argument help for more info.", AccountStatus::Steward, command_guild) || command_add("guild", "Guild manipulation commands. Use argument help for more info.", AccountStatus::Steward, command_guild) ||
@ -1007,6 +1008,7 @@ void command_bot(Client *c, const Seperator *sep)
#include "gm_commands/gm.cpp" #include "gm_commands/gm.cpp"
#include "gm_commands/gmspeed.cpp" #include "gm_commands/gmspeed.cpp"
#include "gm_commands/gmzone.cpp" #include "gm_commands/gmzone.cpp"
#include "gm_commands/godmode.cpp"
#include "gm_commands/goto.cpp" #include "gm_commands/goto.cpp"
#include "gm_commands/grid.cpp" #include "gm_commands/grid.cpp"
#include "gm_commands/guild.cpp" #include "gm_commands/guild.cpp"

View File

@ -105,6 +105,7 @@ void command_globalview(Client *c, const Seperator *sep);
void command_gm(Client *c, const Seperator *sep); void command_gm(Client *c, const Seperator *sep);
void command_gmspeed(Client *c, const Seperator *sep); void command_gmspeed(Client *c, const Seperator *sep);
void command_gmzone(Client *c, const Seperator *sep); void command_gmzone(Client *c, const Seperator *sep);
void command_godmode(Client* c, const Seperator *sep);
void command_goto(Client *c, const Seperator *sep); void command_goto(Client *c, const Seperator *sep);
void command_grid(Client *c, const Seperator *sep); void command_grid(Client *c, const Seperator *sep);
void command_guild(Client *c, const Seperator *sep); void command_guild(Client *c, const Seperator *sep);

View File

@ -24,6 +24,8 @@ void command_flymode(Client *c, const Seperator *sep)
target->SetFlyMode(static_cast<GravityBehavior>(flymode_id)); target->SetFlyMode(static_cast<GravityBehavior>(flymode_id));
target->SendAppearancePacket(AT_Levitate, flymode_id); target->SendAppearancePacket(AT_Levitate, flymode_id);
uint32 account = c->AccountID();
database.SetGMFlymode(account, flymode_id);
c->Message( c->Message(
Chat::White, Chat::White,
fmt::format( fmt::format(

View File

@ -0,0 +1,33 @@
#include "../client.h"
#include "../../common/repositories/account_repository.h"
void command_godmode(Client *c, const Seperator *sep)
{
bool state = atobool(sep->arg[1]);
uint32 account_id = c->AccountID();
if (sep->arg[1][0] != 0) {
auto a = AccountRepository::FindOne(database, c->AccountID());
if (a.id > 0) {
a.flymode = state ? 1 : 0;
a.gmspeed = state ? 1 : 0;
a.invulnerable = state ? 1 : 0;
a.hideme = state ? 1 : 0;
}
c->SetInvul(state);
c->SendAppearancePacket(AT_Levitate, state);
c->SetHideMe(state);
c->Message(
Chat::White,
"Turning GodMode %s for %s (zone for gmspeed to take effect)",
state ? "On" : "Off",
c->GetName()
);
AccountRepository::UpdateOne(database, a);
}
else {
c->Message(Chat::White, "Usage: #godmode [on/off]");
}
}

View File

@ -1,7 +1,6 @@
#include "../client.h" #include "../client.h"
void command_invul(Client *c, const Seperator *sep) void command_invul(Client *c, const Seperator *sep) {
{
int arguments = sep->argnum; int arguments = sep->argnum;
if (!arguments) { if (!arguments) {
c->Message(Chat::White, "Usage: #invul [On|Off]"); c->Message(Chat::White, "Usage: #invul [On|Off]");
@ -15,6 +14,8 @@ void command_invul(Client *c, const Seperator *sep)
} }
target->SetInvul(invul_flag); target->SetInvul(invul_flag);
uint32 account = target->AccountID();
database.SetGMInvul(account, invul_flag);
c->Message( c->Message(
Chat::White, Chat::White,
fmt::format( fmt::format(
@ -25,4 +26,3 @@ void command_invul(Client *c, const Seperator *sep)
).c_str() ).c_str()
); );
} }

View File

@ -1959,7 +1959,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
// Check for No Drop Hacks // Check for No Drop Hacks
Mob* with = trade->With(); Mob* with = trade->With();
if (((with && with->IsClient() && dst_slot_id >= EQ::invslot::TRADE_BEGIN && dst_slot_id <= EQ::invslot::TRADE_END) || if (((with && with->IsClient() && !with->CastToClient()->IsBecomeNPC() && dst_slot_id >= EQ::invslot::TRADE_BEGIN && dst_slot_id <= EQ::invslot::TRADE_END) ||
(dst_slot_id >= EQ::invslot::SHARED_BANK_BEGIN && dst_slot_id <= EQ::invbag::SHARED_BANK_BAGS_END)) (dst_slot_id >= EQ::invslot::SHARED_BANK_BEGIN && dst_slot_id <= EQ::invbag::SHARED_BANK_BAGS_END))
&& GetInv().CheckNoDrop(src_slot_id) && GetInv().CheckNoDrop(src_slot_id)
&& !CanTradeFVNoDropItem()) { && !CanTradeFVNoDropItem()) {