mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 09:06:46 +00:00
[Code Cleanup] Zone Data Loading Refactor (#2388)
* [Code Cleanup] Zone data loading refactor * Update client_packet.cpp * strcpy adjustments * Ensure safe points get reloaded properly * Simplify GetPEQZone and getZoneShutDownDelay * Bring in zone_store where needed * Update client.cpp * Signature * Signature * Convert helpers to using pointers * PR comment * Update worlddb.cpp * Fix loading for instances * Fix zoning with fallback as well * Another place for instance fallback
This commit is contained in:
+21
-24
@@ -11,10 +11,10 @@ void command_gmzone(Client *c, const Seperator *sep)
|
||||
|
||||
std::string zone_short_name = Strings::ToLower(
|
||||
sep->IsNumber(1) ?
|
||||
ZoneName(std::stoul(sep->arg[1]), true) :
|
||||
sep->arg[1]
|
||||
ZoneName(std::stoul(sep->arg[1]), true) :
|
||||
sep->arg[1]
|
||||
);
|
||||
bool is_unknown_zone = zone_short_name.find("unknown") != std::string::npos;
|
||||
bool is_unknown_zone = zone_short_name.find("unknown") != std::string::npos;
|
||||
if (is_unknown_zone) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
@@ -41,14 +41,14 @@ void command_gmzone(Client *c, const Seperator *sep)
|
||||
|
||||
auto zone_version = (
|
||||
sep->IsNumber(2) ?
|
||||
std::stoul(sep->arg[2]) :
|
||||
0
|
||||
std::stoul(sep->arg[2]) :
|
||||
0
|
||||
);
|
||||
|
||||
std::string instance_identifier = (
|
||||
sep->arg[3] ?
|
||||
sep->arg[3] :
|
||||
"gmzone"
|
||||
sep->arg[3] :
|
||||
"gmzone"
|
||||
);
|
||||
|
||||
auto bucket_key = fmt::format(
|
||||
@@ -58,9 +58,9 @@ void command_gmzone(Client *c, const Seperator *sep)
|
||||
zone_version
|
||||
);
|
||||
|
||||
auto existing_zone_instance = DataBucket::GetData(bucket_key);
|
||||
uint16 instance_id = 0;
|
||||
uint32 duration = 100000000;
|
||||
auto existing_zone_instance = DataBucket::GetData(bucket_key);
|
||||
uint16 instance_id = 0;
|
||||
uint32 duration = 100000000;
|
||||
|
||||
if (!existing_zone_instance.empty()) {
|
||||
instance_id = std::stoi(existing_zone_instance);
|
||||
@@ -106,21 +106,12 @@ void command_gmzone(Client *c, const Seperator *sep)
|
||||
|
||||
if (instance_id) {
|
||||
float target_x = -1, target_y = -1, target_z = -1, target_heading = -1;
|
||||
int16 min_status = AccountStatus::Player;
|
||||
uint8 min_level = 0;
|
||||
|
||||
if (
|
||||
!content_db.GetSafePoints(
|
||||
zone_short_name.c_str(),
|
||||
zone_version,
|
||||
&target_x,
|
||||
&target_y,
|
||||
&target_z,
|
||||
&target_heading,
|
||||
&min_status,
|
||||
&min_level
|
||||
)
|
||||
) {
|
||||
auto z = GetZoneVersionWithFallback(
|
||||
ZoneID(zone_short_name.c_str()),
|
||||
zone_version
|
||||
);
|
||||
if (!z) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
@@ -130,8 +121,14 @@ void command_gmzone(Client *c, const Seperator *sep)
|
||||
zone_short_name
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
target_x = z->safe_x;
|
||||
target_y = z->safe_y;
|
||||
target_z = z->safe_z;
|
||||
target_heading = z->safe_heading;
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
|
||||
+14
-12
@@ -68,13 +68,13 @@ void command_reload(Client *c, const Seperator *sep)
|
||||
ServerPacket* pack = nullptr;
|
||||
|
||||
if (is_aa) {
|
||||
c->Message(Chat::White, "Attempting to reload Alternate Advancement Data globally.");
|
||||
c->Message(Chat::White, "Attempting to reload Alternate Advancement Data globally.");
|
||||
pack = new ServerPacket(ServerOP_ReloadAAData, 0);
|
||||
} else if (is_alternate_currencies) {
|
||||
c->Message(Chat::White, "Attempting to reload Alternate Currencies globally.");
|
||||
c->Message(Chat::White, "Attempting to reload Alternate Currencies globally.");
|
||||
pack = new ServerPacket(ServerOP_ReloadAlternateCurrencies, 0);
|
||||
} else if (is_blocked_spells) {
|
||||
c->Message(Chat::White, "Attempting to reload Blocked Spells globally.");
|
||||
c->Message(Chat::White, "Attempting to reload Blocked Spells globally.");
|
||||
pack = new ServerPacket(ServerOP_ReloadBlockedSpells, 0);
|
||||
} else if (is_commands) {
|
||||
c->Message(Chat::White, "Attempting to reload Commands globally.");
|
||||
@@ -83,20 +83,20 @@ void command_reload(Client *c, const Seperator *sep)
|
||||
c->Message(Chat::White, "Attempting to reload Content Flags globally.");
|
||||
pack = new ServerPacket(ServerOP_ReloadContentFlags, 0);
|
||||
} else if (is_doors) {
|
||||
c->Message(Chat::White, "Attempting to reload Doors globally.");
|
||||
c->Message(Chat::White, "Attempting to reload Doors globally.");
|
||||
pack = new ServerPacket(ServerOP_ReloadDoors, 0);
|
||||
} else if (is_dztemplates) {
|
||||
c->Message(Chat::White, "Attempting to reload Dynamic Zone Templates globally.");
|
||||
pack = new ServerPacket(ServerOP_ReloadDzTemplates, 0);
|
||||
} else if (is_ground_spawns) {
|
||||
c->Message(Chat::White, "Attempting to reload Ground Spawns globally.");
|
||||
c->Message(Chat::White, "Attempting to reload Ground Spawns globally.");
|
||||
pack = new ServerPacket(ServerOP_ReloadGroundSpawns, 0);
|
||||
} else if (is_level_mods) {
|
||||
if (!RuleB(Zone, LevelBasedEXPMods)) {
|
||||
c->Message(Chat::White, "Level Based Experience Modifiers are disabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
c->Message(Chat::White, "Attempting to reload Level Based Experience Modifiers globally.");
|
||||
pack = new ServerPacket(ServerOP_ReloadLevelEXPMods, 0);
|
||||
} else if (is_logs) {
|
||||
@@ -137,7 +137,7 @@ void command_reload(Client *c, const Seperator *sep)
|
||||
} else if (is_rules) {
|
||||
c->Message(Chat::White, "Attempting to reload Rules globally.");
|
||||
pack = new ServerPacket(ServerOP_ReloadRules, 0);
|
||||
} else if (is_static) {
|
||||
} else if (is_static) {
|
||||
c->Message(Chat::White, "Attempting to reload Static Zone Data globally.");
|
||||
pack = new ServerPacket(ServerOP_ReloadStaticZoneData, 0);
|
||||
} else if (is_tasks) {
|
||||
@@ -148,11 +148,11 @@ void command_reload(Client *c, const Seperator *sep)
|
||||
} else {
|
||||
task_id = std::stoul(sep->arg[2]);
|
||||
}
|
||||
|
||||
|
||||
auto rts = (ReloadTasks_Struct*) pack->pBuffer;
|
||||
rts->reload_type = RELOADTASKS;
|
||||
rts->task_id = task_id;
|
||||
} else if (is_titles) {
|
||||
} else if (is_titles) {
|
||||
c->Message(Chat::White, "Attempting to reload Titles globally.");
|
||||
pack = new ServerPacket(ServerOP_ReloadTitles, 0);
|
||||
} else if (is_traps) {
|
||||
@@ -221,6 +221,8 @@ void command_reload(Client *c, const Seperator *sep)
|
||||
auto RW = (ReloadWorld_Struct *) pack->pBuffer;
|
||||
RW->global_repop = global_repop;
|
||||
} else if (is_zone) {
|
||||
zone_store.LoadZones(content_db);
|
||||
|
||||
if (arguments < 2) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
@@ -260,7 +262,7 @@ void command_reload(Client *c, const Seperator *sep)
|
||||
std::stoul(sep->arg[3]) :
|
||||
0
|
||||
);
|
||||
|
||||
|
||||
auto outapp = new EQApplicationPacket(OP_NewZone, sizeof(NewZone_Struct));
|
||||
memcpy(outapp->pBuffer, &zone->newzone_data, outapp->size);
|
||||
entity_list.QueueClients(c, outapp);
|
||||
@@ -287,11 +289,11 @@ void command_reload(Client *c, const Seperator *sep)
|
||||
)
|
||||
).c_str()
|
||||
);
|
||||
} else if (is_zone_points) {
|
||||
} else if (is_zone_points) {
|
||||
c->Message(Chat::White, "Attempting to reloading Zone Points globally.");
|
||||
pack = new ServerPacket(ServerOP_ReloadZonePoints, 0);
|
||||
}
|
||||
|
||||
|
||||
if (pack) {
|
||||
worldserver.SendPacket(pack);
|
||||
}
|
||||
|
||||
@@ -31,12 +31,14 @@ void command_zheader(Client *c, const Seperator *sep)
|
||||
std::stoul(sep->arg[3]) :
|
||||
0
|
||||
);
|
||||
|
||||
|
||||
auto outapp = new EQApplicationPacket(OP_NewZone, sizeof(NewZone_Struct));
|
||||
memcpy(outapp->pBuffer, &zone->newzone_data, outapp->size);
|
||||
entity_list.QueueClients(c, outapp);
|
||||
safe_delete(outapp);
|
||||
|
||||
zone_store.LoadZones(content_db);
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
|
||||
@@ -59,12 +59,14 @@ void command_zone(Client *c, const Seperator *sep)
|
||||
auto z = sep->IsNumber(4) ? std::stof(sep->arg[4]) : 0.0f;
|
||||
auto zone_mode = sep->IsNumber(2) ? ZoneSolicited : ZoneToSafeCoords;
|
||||
|
||||
auto zd = GetZone(zone_id);
|
||||
|
||||
c->MovePC(
|
||||
zone_id,
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
0.0f,
|
||||
zd ? zd->safe_heading : 0.0f,
|
||||
0,
|
||||
zone_mode
|
||||
);
|
||||
|
||||
@@ -159,7 +159,7 @@ void command_zstats(Client *c, const Seperator *sep)
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Suspend Buffs: {}",
|
||||
zone->newzone_data.SuspendBuffs
|
||||
zone->newzone_data.suspend_buffs
|
||||
).c_str()
|
||||
);
|
||||
|
||||
@@ -168,9 +168,9 @@ void command_zstats(Client *c, const Seperator *sep)
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Regen | Health: {} Mana: {} Endurance: {}",
|
||||
zone->newzone_data.FastRegenHP,
|
||||
zone->newzone_data.FastRegenMana,
|
||||
zone->newzone_data.FastRegenEndurance
|
||||
zone->newzone_data.fast_regen_hp,
|
||||
zone->newzone_data.fast_regen_mana,
|
||||
zone->newzone_data.fast_regen_endurance
|
||||
).c_str()
|
||||
);
|
||||
|
||||
@@ -179,7 +179,7 @@ void command_zstats(Client *c, const Seperator *sep)
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"NPC Max Aggro Distance: {}",
|
||||
zone->newzone_data.NPCAggroMaxDist
|
||||
zone->newzone_data.npc_aggro_max_dist
|
||||
).c_str()
|
||||
);
|
||||
|
||||
@@ -197,8 +197,8 @@ void command_zstats(Client *c, const Seperator *sep)
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Lava Damage | Min: {} Max: {}",
|
||||
zone->newzone_data.MinLavaDamage,
|
||||
zone->newzone_data.LavaDamage
|
||||
zone->newzone_data.min_lava_damage,
|
||||
zone->newzone_data.lava_damage
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user