mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-10 15:00:25 +00:00
[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:
+64
-30
@@ -68,6 +68,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#include "../common/shared_tasks.h"
|
||||
#include "gm_commands/door_manipulation.h"
|
||||
#include "client.h"
|
||||
#include "../common/repositories/account_repository.h"
|
||||
|
||||
|
||||
#ifdef BOTS
|
||||
@@ -569,7 +570,31 @@ void Client::CompleteConnect()
|
||||
|
||||
//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());
|
||||
Raid *raid = nullptr;
|
||||
@@ -1184,23 +1209,25 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
|
||||
database.RemoveTempFactions(this);
|
||||
database.LoadCharacterFactionValues(cid, factionvalues);
|
||||
|
||||
/* Load Character Account Data: Temp until I move */
|
||||
query = StringFormat("SELECT `status`, `name`, `ls_id`, `lsaccount_id`, `gmspeed`, `revoked`, `hideme`, `time_creation` FROM `account` WHERE `id` = %u", AccountID());
|
||||
auto results = database.QueryDatabase(query);
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
admin = atoi(row[0]);
|
||||
strn0cpy(account_name, row[1], sizeof(account_name));
|
||||
strn0cpy(loginserver, row[2], sizeof(loginserver));
|
||||
lsaccountid = atoi(row[3]);
|
||||
gmspeed = atoi(row[4]);
|
||||
revoked = atoi(row[5]);
|
||||
gm_hide_me = atoi(row[6]);
|
||||
account_creation = atoul(row[7]);
|
||||
auto a = AccountRepository::FindOne(database, AccountID());
|
||||
if (a.id > 0) {
|
||||
strn0cpy(account_name, a.name.c_str(), sizeof(account_name));
|
||||
strn0cpy(loginserver, a.ls_id.c_str(), sizeof(loginserver));
|
||||
|
||||
admin = a.status;
|
||||
lsaccountid = a.lsaccount_id;
|
||||
gmspeed = a.gmspeed;
|
||||
revoked = a.revoked;
|
||||
gm_hide_me = a.hideme;
|
||||
account_creation = a.time_creation;
|
||||
gminvul = a.invulnerable;
|
||||
flymode = static_cast<GravityBehavior>(a.flymode);
|
||||
tellsoff = gm_hide_me;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
results = database.QueryDatabase(query);
|
||||
auto results = database.QueryDatabase(query);
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
if (row[4] && atoi(row[4]) > 0) {
|
||||
guild_id = atoi(row[4]);
|
||||
@@ -1266,6 +1293,8 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
|
||||
|
||||
/* If GM, not trackable */
|
||||
if (gm_hide_me) { trackable = false; }
|
||||
if (gminvul) { invulnerable = true; }
|
||||
if (flymode > 0) { SendAppearancePacket(AT_Levitate, flymode); }
|
||||
/* Set Con State for Reporting */
|
||||
conn_state = PlayerProfileLoaded;
|
||||
|
||||
@@ -6117,17 +6146,26 @@ void Client::Handle_OP_GMBecomeNPC(const EQApplicationPacket *app)
|
||||
BecomeNPC_Struct* bnpc = (BecomeNPC_Struct*)app->pBuffer;
|
||||
|
||||
Mob* cli = (Mob*)entity_list.GetMob(bnpc->id);
|
||||
if (cli == 0)
|
||||
if (cli == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cli->IsClient())
|
||||
cli->CastToClient()->QueuePacket(app);
|
||||
cli->SendAppearancePacket(AT_NPCName, 1, true);
|
||||
cli->CastToClient()->SetBecomeNPC(true);
|
||||
cli->CastToClient()->SetBecomeNPCLevel(bnpc->maxlevel);
|
||||
cli->MessageString(Chat::White, TOGGLE_OFF);
|
||||
cli->CastToClient()->tellsoff = true;
|
||||
//TODO: Make this toggle a BecomeNPC flag so that it gets updated when people zone in as well; Make combat work with this.
|
||||
if (cli->IsClient()) {
|
||||
Client* target = cli->CastToClient();
|
||||
target->QueuePacket(app);
|
||||
if(target->GetGM()) {
|
||||
target->SetInvul(false);
|
||||
target->SetHideMe(false);
|
||||
target->SetGM(false);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -6532,16 +6570,12 @@ void Client::Handle_OP_GMToggle(const EQApplicationPacket *app)
|
||||
GMToggle_Struct *ts = (GMToggle_Struct *)app->pBuffer;
|
||||
if (ts->toggle == 0) {
|
||||
MessageString(Chat::White, TOGGLE_OFF);
|
||||
//Message(0, "Turning tells OFF");
|
||||
tellsoff = true;
|
||||
}
|
||||
else if (ts->toggle == 1) {
|
||||
//Message(0, "Turning tells ON");
|
||||
} else if (ts->toggle == 1) {
|
||||
MessageString(Chat::White, TOGGLE_ON);
|
||||
tellsoff = false;
|
||||
}
|
||||
else {
|
||||
Message(0, "Unkown value in /toggle packet");
|
||||
} else {
|
||||
Message(Chat::White, "Unkown value in /toggle packet");
|
||||
}
|
||||
UpdateWho();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user