mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 18:52:22 +00:00
[Commands] Add additional #peqzone functionality. (#2085)
* [Commands] Add additional #peqzone functionality. - Add #peqzone flagging capabilities so operators don't have to blanket allow #peqzone access to zones. - Allows you to set a zone's `peqzone` column to `2` and disallow use of `#peqzone` until they have been given the appropriate flag. - Add #peqzone_flags command to list your #peqzone flags similar to #flags command. - Add `character_peqzone_flags` table to database and database_schema.h. - Required SQL update to add the new table. - Add client:ClearPEQZoneFlag(zone_id) to Lua. - Add client:HasPEQZoneFlag(zone_id) to Lua. - Add client:LoadPEQZoneFlags() to Lua. - Add client:LoadZoneFlags() to Lua. - Add client:SendPEQZoneFlagInfo(client) to Lua. - Add client:SetPEQZoneFlag(zone_id) to Lua. - Add $client->ClearPEQZoneFlag(zone_id) to Perl. - Add $client->HasPEQZoneFlag(zone_id) to Perl. - Add $client->LoadPEQZoneFlags() to Perl. - Add $client->SendPEQZoneFlagInfo(client) to Perl. - Add $client->SetPEQZoneFlag(zone_id) to Perl. * Fixes.
This commit is contained in:
+197
-58
@@ -980,53 +980,50 @@ void Client::GoToDeath() {
|
||||
MovePC(m_pp.binds[0].zone_id, m_pp.binds[0].instance_id, 0.0f, 0.0f, 0.0f, 0.0f, 1, ZoneToBindPoint);
|
||||
}
|
||||
|
||||
void Client::SetZoneFlag(uint32 zone_id) {
|
||||
if(HasZoneFlag(zone_id))
|
||||
return;
|
||||
|
||||
zone_flags.insert(zone_id);
|
||||
|
||||
// Retrieve all waypoints for this grid
|
||||
std::string query = StringFormat("INSERT INTO zone_flags (charID,zoneID) VALUES(%d,%d)", CharacterID(), zone_id);
|
||||
auto results = database.QueryDatabase(query);
|
||||
if(!results.Success())
|
||||
LogError("MySQL Error while trying to set zone flag for [{}]: [{}]", GetName(), results.ErrorMessage().c_str());
|
||||
}
|
||||
|
||||
void Client::ClearZoneFlag(uint32 zone_id) {
|
||||
if(!HasZoneFlag(zone_id))
|
||||
if (!HasZoneFlag(zone_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
zone_flags.erase(zone_id);
|
||||
|
||||
// Retrieve all waypoints for this grid
|
||||
std::string query = StringFormat("DELETE FROM zone_flags WHERE charID=%d AND zoneID=%d", CharacterID(), zone_id);
|
||||
std::string query = fmt::format(
|
||||
"DELETE FROM zone_flags WHERE charID = {} AND zoneID = {}",
|
||||
CharacterID(),
|
||||
zone_id
|
||||
);
|
||||
auto results = database.QueryDatabase(query);
|
||||
if(!results.Success())
|
||||
LogError("MySQL Error while trying to clear zone flag for [{}]: [{}]", GetName(), results.ErrorMessage().c_str());
|
||||
|
||||
if (!results.Success()) {
|
||||
LogError("MySQL Error while trying to clear zone flag for [{}]: [{}]", GetName(), results.ErrorMessage().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
bool Client::HasZoneFlag(uint32 zone_id) const {
|
||||
return zone_flags.find(zone_id) != zone_flags.end();
|
||||
}
|
||||
|
||||
void Client::LoadZoneFlags() {
|
||||
|
||||
// Retrieve all waypoints for this grid
|
||||
std::string query = StringFormat("SELECT zoneID from zone_flags WHERE charID=%d", CharacterID());
|
||||
std::string query = fmt::format(
|
||||
"SELECT zoneID from zone_flags WHERE charID = {}",
|
||||
CharacterID()
|
||||
);
|
||||
auto results = database.QueryDatabase(query);
|
||||
|
||||
if (!results.Success()) {
|
||||
LogError("MySQL Error while trying to load zone flags for [{}]: [{}]", GetName(), results.ErrorMessage().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
for(auto row = results.begin(); row != results.end(); ++row)
|
||||
zone_flags.insert(atoi(row[0]));
|
||||
}
|
||||
zone_flags.clear();
|
||||
|
||||
bool Client::HasZoneFlag(uint32 zone_id) const {
|
||||
return(zone_flags.find(zone_id) != zone_flags.end());
|
||||
for (auto row : results) {
|
||||
zone_flags.insert(std::stoul(row[0]));
|
||||
}
|
||||
}
|
||||
|
||||
void Client::SendZoneFlagInfo(Client *to) const {
|
||||
if(zone_flags.empty()) {
|
||||
if (zone_flags.empty()) {
|
||||
to->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
@@ -1041,7 +1038,7 @@ void Client::SendZoneFlagInfo(Client *to) const {
|
||||
to->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} {} the following Flags:",
|
||||
"{} {} the following Zone Flags:",
|
||||
to == this ? "You" : GetName(),
|
||||
to == this ? "have" : "has"
|
||||
).c_str()
|
||||
@@ -1050,38 +1047,47 @@ void Client::SendZoneFlagInfo(Client *to) const {
|
||||
int flag_count = 0;
|
||||
for (const auto& zone_id : zone_flags) {
|
||||
int flag_number = (flag_count + 1);
|
||||
const char* zone_short_name = ZoneName(zone_id);
|
||||
std::string zone_long_name = ZoneLongName(zone_id);
|
||||
float safe_x, safe_y, safe_z, safe_heading;
|
||||
int16 min_status = AccountStatus::Player;
|
||||
uint8 min_level = 0;
|
||||
char flag_name[128];
|
||||
if(!content_db.GetSafePoints(
|
||||
zone_short_name,
|
||||
0,
|
||||
&safe_x,
|
||||
&safe_y,
|
||||
&safe_z,
|
||||
&safe_heading,
|
||||
&min_status,
|
||||
&min_level,
|
||||
flag_name
|
||||
)) {
|
||||
strcpy(flag_name, "ERROR");
|
||||
}
|
||||
|
||||
to->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Zone Flag {} | Zone ID: {} Zone Name: {} ({}) Flag Name: {}",
|
||||
flag_number,
|
||||
zone_id,
|
||||
zone_long_name,
|
||||
const char* zone_short_name = ZoneName(zone_id, true);
|
||||
if (zone_short_name != "UNKNOWN") {
|
||||
std::string zone_long_name = ZoneLongName(zone_id);
|
||||
float safe_x, safe_y, safe_z, safe_heading;
|
||||
int16 min_status = AccountStatus::Player;
|
||||
uint8 min_level = 0;
|
||||
char flag_name[128];
|
||||
if (!content_db.GetSafePoints(
|
||||
zone_short_name,
|
||||
0,
|
||||
&safe_x,
|
||||
&safe_y,
|
||||
&safe_z,
|
||||
&safe_heading,
|
||||
&min_status,
|
||||
&min_level,
|
||||
flag_name
|
||||
).c_str()
|
||||
);
|
||||
flag_count++;
|
||||
)) {
|
||||
strcpy(flag_name, "ERROR");
|
||||
}
|
||||
|
||||
to->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Flag {} | Zone ID: {} Zone Name: {} ({}){}",
|
||||
flag_number,
|
||||
zone_id,
|
||||
zone_long_name,
|
||||
zone_short_name,
|
||||
(
|
||||
flag_name != "" ?
|
||||
fmt::format(
|
||||
" Flag Required: {}",
|
||||
flag_name
|
||||
) :
|
||||
""
|
||||
)
|
||||
).c_str()
|
||||
);
|
||||
flag_count++;
|
||||
}
|
||||
}
|
||||
|
||||
to->Message(
|
||||
@@ -1095,6 +1101,139 @@ void Client::SendZoneFlagInfo(Client *to) const {
|
||||
);
|
||||
}
|
||||
|
||||
void Client::SetZoneFlag(uint32 zone_id) {
|
||||
if (HasZoneFlag(zone_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
zone_flags.insert(zone_id);
|
||||
|
||||
std::string query = fmt::format(
|
||||
"INSERT INTO zone_flags (charID, zoneID) VALUES ({}, {})",
|
||||
CharacterID(),
|
||||
zone_id
|
||||
);
|
||||
auto results = database.QueryDatabase(query);
|
||||
|
||||
if (!results.Success()) {
|
||||
LogError("MySQL Error while trying to set zone flag for [{}]: [{}]", GetName(), results.ErrorMessage().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void Client::ClearPEQZoneFlag(uint32 zone_id) {
|
||||
if (!HasPEQZoneFlag(zone_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
peqzone_flags.erase(zone_id);
|
||||
|
||||
auto query = fmt::format(
|
||||
"DELETE FROM character_peqzone_flags WHERE id = {} AND zone_id = {}",
|
||||
CharacterID(),
|
||||
zone_id
|
||||
);
|
||||
auto results = database.QueryDatabase(query);
|
||||
|
||||
if (!results.Success()) {
|
||||
LogError("MySQL Error while trying to clear zone flag for [{}]: [{}]", GetName(), results.ErrorMessage().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
bool Client::HasPEQZoneFlag(uint32 zone_id) const {
|
||||
return peqzone_flags.find(zone_id) != peqzone_flags.end();
|
||||
}
|
||||
|
||||
void Client::LoadPEQZoneFlags() {
|
||||
std::string query = fmt::format(
|
||||
"SELECT zone_id from character_peqzone_flags WHERE id = {}",
|
||||
CharacterID()
|
||||
);
|
||||
auto results = database.QueryDatabase(query);
|
||||
|
||||
if (!results.Success()) {
|
||||
LogError("MySQL Error while trying to load zone flags for [{}]: [{}]", GetName(), results.ErrorMessage().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
peqzone_flags.clear();
|
||||
|
||||
for (auto row : results) {
|
||||
peqzone_flags.insert(std::stoul(row[0]));
|
||||
}
|
||||
}
|
||||
|
||||
void Client::SendPEQZoneFlagInfo(Client *to) const {
|
||||
if (peqzone_flags.empty()) {
|
||||
to->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} {} no PEQZone Flags.",
|
||||
to == this ? "You" : GetName(),
|
||||
to == this ? "have" : "has"
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
to->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} {} the following PEQZone Flags:",
|
||||
to == this ? "You" : GetName(),
|
||||
to == this ? "have" : "has"
|
||||
).c_str()
|
||||
);
|
||||
|
||||
int flag_count = 0;
|
||||
for (const auto& zone_id : peqzone_flags) {
|
||||
int flag_number = (flag_count + 1);
|
||||
std::string zone_short_name = ZoneName(zone_id, true);
|
||||
if (zone_short_name != "UNKNOWN") {
|
||||
std::string zone_long_name = ZoneLongName(zone_id);
|
||||
to->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Flag {} | Zone ID: {} Zone Name: {} ({})",
|
||||
flag_number,
|
||||
zone_id,
|
||||
zone_long_name,
|
||||
zone_short_name
|
||||
).c_str()
|
||||
);
|
||||
flag_count++;
|
||||
}
|
||||
}
|
||||
|
||||
to->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} {} {} PEQZone Flags.",
|
||||
to == this ? "You" : GetName(),
|
||||
to == this ? "have" : "has",
|
||||
flag_count
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
|
||||
void Client::SetPEQZoneFlag(uint32 zone_id) {
|
||||
if (HasPEQZoneFlag(zone_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
peqzone_flags.insert(zone_id);
|
||||
|
||||
auto query = fmt::format(
|
||||
"INSERT INTO character_peqzone_flags (id, zone_id) VALUES ({}, {})",
|
||||
CharacterID(),
|
||||
zone_id
|
||||
);
|
||||
auto results = database.QueryDatabase(query);
|
||||
|
||||
if (!results.Success()) {
|
||||
LogError("MySQL Error while trying to set zone flag for [{}]: [{}]", GetName(), results.ErrorMessage().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
bool Client::CanBeInZone() {
|
||||
//check some critial rules to see if this char needs to be booted from the zone
|
||||
//only enforce rules here which are serious enough to warrant being kicked from
|
||||
|
||||
Reference in New Issue
Block a user