[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:
Chris Miles
2022-09-01 18:48:28 -05:00
committed by GitHub
parent c613dbb2f7
commit 89fdd842e1
81 changed files with 753 additions and 1130 deletions
-2
View File
@@ -161,7 +161,6 @@ SET(zone_sources
zonedb.cpp
zone_event_scheduler.cpp
zone_reload.cpp
zone_store.cpp
zoning.cpp
)
@@ -284,7 +283,6 @@ SET(zone_headers
zonedb.h
zonedump.h
zone_reload.h
zone_store.h
)
ADD_EXECUTABLE(zone ${zone_sources} ${zone_headers})
+1 -1
View File
@@ -33,7 +33,7 @@ Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
#include "string_ids.h"
#include "titles.h"
#include "zonedb.h"
#include "zone_store.h"
#include "../common/zone_store.h"
extern QueryServ* QServ;
+1 -1
View File
@@ -22,7 +22,7 @@
#include "../common/net/websocket_server.h"
#include "../common/eqemu_logsys.h"
#include "zonedb.h"
#include "zone_store.h"
#include "../common/zone_store.h"
#include "client.h"
#include "entity.h"
#include "corpse.h"
+3 -3
View File
@@ -8184,9 +8184,9 @@ void Bot::CalcRestState() {
}
}
RestRegenHP = 6 * (GetMaxHP() / zone->newzone_data.FastRegenHP);
RestRegenMana = 6 * (GetMaxMana() / zone->newzone_data.FastRegenMana);
RestRegenEndurance = 6 * (GetMaxEndurance() / zone->newzone_data.FastRegenEndurance);
RestRegenHP = 6 * (GetMaxHP() / zone->newzone_data.fast_regen_hp);
RestRegenMana = 6 * (GetMaxMana() / zone->newzone_data.fast_regen_mana);
RestRegenEndurance = 6 * (GetMaxEndurance() / zone->newzone_data.fast_regen_endurance);
}
int32 Bot::LevelRegen() {
+1 -1
View File
@@ -29,7 +29,7 @@
#include "groups.h"
#include "corpse.h"
#include "zonedb.h"
#include "zone_store.h"
#include "../common/zone_store.h"
#include "string_ids.h"
#include "../common/misc_functions.h"
#include "../common/global_define.h"
+1 -1
View File
@@ -61,7 +61,7 @@
#include "bot_command.h"
#include "zonedb.h"
#include "zone_store.h"
#include "../common/zone_store.h"
#include "guild_mgr.h"
#include "map.h"
#include "doors.h"
+1 -1
View File
@@ -24,7 +24,7 @@
#include "../common/eqemu_logsys.h"
#include "zonedb.h"
#include "zone_store.h"
#include "../common/zone_store.h"
#include "bot.h"
#include "client.h"
+9 -10
View File
@@ -46,7 +46,7 @@ extern volatile bool RunLoops;
#include "position.h"
#include "worldserver.h"
#include "zonedb.h"
#include "zone_store.h"
#include "../common/zone_store.h"
#include "petitions.h"
#include "command.h"
#include "water_map.h"
@@ -5371,14 +5371,13 @@ void Client::SetStartZone(uint32 zoneid, float x, float y, float z, float headin
}
if (x == 0 && y == 0 && z == 0) {
content_db.GetSafePoints(
ZoneName(m_pp.binds[4].zone_id),
0,
&m_pp.binds[4].x,
&m_pp.binds[4].y,
&m_pp.binds[4].z,
&m_pp.binds[4].heading
);
auto zd = GetZone(m_pp.binds[4].zone_id);
if (zd) {
m_pp.binds[4].x = zd->safe_x;
m_pp.binds[4].y = zd->safe_y;
m_pp.binds[4].z = zd->safe_z;
m_pp.binds[4].heading = zd->safe_heading;
}
}
else {
m_pp.binds[4].x = x;
@@ -9427,7 +9426,7 @@ bool Client::GotoPlayerRaid(const std::string& player_name)
if (!GetRaid()) {
return GotoPlayer(player_name);
}
for (auto &m: GetRaid()->members) {
if (m.member && m.member->IsClient()) {
auto c = m.member->CastToClient();
+1 -1
View File
@@ -63,7 +63,7 @@ namespace EQ
#include "questmgr.h"
#include "zone.h"
#include "zonedb.h"
#include "zone_store.h"
#include "../common/zone_store.h"
#include "task_manager.h"
#include "task_client_state.h"
#include "cheat_manager.h"
+3 -3
View File
@@ -292,7 +292,7 @@ int64 Client::CalcHPRegen(bool bCombat)
if (!bCombat && CanFastRegen() && (IsSitting() || CanMedOnHorse())) {
auto max_hp = GetMaxHP();
int fast_regen = 6 * (max_hp / zone->newzone_data.FastRegenHP);
int fast_regen = 6 * (max_hp / zone->newzone_data.fast_regen_hp);
if (base < fast_regen) // weird, but what the client is doing
base = fast_regen;
}
@@ -771,7 +771,7 @@ int64 Client::CalcManaRegen(bool bCombat)
if (!bCombat && CanFastRegen() && (IsSitting() || CanMedOnHorse())) {
auto max_mana = GetMaxMana();
int fast_regen = 6 * (max_mana / zone->newzone_data.FastRegenMana);
int fast_regen = 6 * (max_mana / zone->newzone_data.fast_regen_mana);
if (regen < fast_regen) // weird, but what the client is doing
regen = fast_regen;
}
@@ -1801,7 +1801,7 @@ int64 Client::CalcEnduranceRegen(bool bCombat)
int64 regen = base;
if (!bCombat && CanFastRegen() && (IsSitting() || CanMedOnHorse())) {
auto max_end = GetMaxEndurance();
int fast_regen = 6 * (max_end / zone->newzone_data.FastRegenEndurance);
int fast_regen = 6 * (max_end / zone->newzone_data.fast_regen_endurance);
if (aa_regen < fast_regen) // weird, but what the client is doing
aa_regen = fast_regen;
}
+6 -10
View File
@@ -6638,17 +6638,13 @@ void Client::Handle_OP_GMZoneRequest(const EQApplicationPacket *app)
strcpy(target_zone, zone_short_name);
// this both loads the safe points and does a sanity check on zone name
if (!content_db.GetSafePoints(
target_zone,
0,
&target_x,
&target_y,
&target_z,
&target_heading,
&min_status,
&min_level
)) {
auto z = GetZone(target_zone, 0);
if (z) {
target_zone[0] = 0;
target_x = z->safe_x;
target_y = z->safe_y;
target_z = z->safe_z;
target_heading = z->safe_heading;
}
auto outapp = new EQApplicationPacket(OP_GMZoneRequest, sizeof(GMZoneRequest_Struct));
+1 -1
View File
@@ -54,7 +54,7 @@
#include "worldserver.h"
#include "zone.h"
#include "zonedb.h"
#include "zone_store.h"
#include "../common/zone_store.h"
extern QueryServ* QServ;
extern Zone* zone;
+1 -1
View File
@@ -2,7 +2,7 @@
#include <utility>
#include "../common/strings.h"
#include "zonedb.h"
#include "zone_store.h"
#include "../common/zone_store.h"
#include <ctime>
#include <cctype>
#include <algorithm>
+1 -1
View File
@@ -28,7 +28,7 @@
#include "string_ids.h"
#include "worldserver.h"
#include "zonedb.h"
#include "zone_store.h"
#include "../common/zone_store.h"
#include "../common/repositories/criteria/content_filter_criteria.h"
#include <iostream>
+1 -1
View File
@@ -28,7 +28,7 @@
#include "string_ids.h"
#include "worldserver.h"
#include "zonedb.h"
#include "zone_store.h"
#include "../common/zone_store.h"
#include "position.h"
float Mob::GetActSpellRange(uint16 spell_id, float range, bool IsBard)
+1 -1
View File
@@ -30,7 +30,7 @@
#include "titles.h"
#include "water_map.h"
#include "zonedb.h"
#include "zone_store.h"
#include "../common/zone_store.h"
#include "../common/repositories/criteria/content_filter_criteria.h"
#include <iostream>
+21 -24
View File
@@ -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
View File
@@ -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);
}
+3 -1
View File
@@ -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(
+3 -1
View File
@@ -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
);
+7 -7
View File
@@ -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()
);
}
+1 -1
View File
@@ -24,7 +24,7 @@
#include "guild_mgr.h"
#include "worldserver.h"
#include "zonedb.h"
#include "zone_store.h"
#include "../common/zone_store.h"
ZoneGuildManager guild_mgr;
GuildBankManager *GuildBanks;
+1 -1
View File
@@ -23,7 +23,7 @@
#include "quest_parser_collection.h"
#include "worldserver.h"
#include "zonedb.h"
#include "zone_store.h"
#include "../common/zone_store.h"
extern WorldServer worldserver;
+1 -1
View File
@@ -26,7 +26,7 @@
#include "mob.h"
#include "npc.h"
#include "zonedb.h"
#include "zone_store.h"
#include "../common/zone_store.h"
#include "global_loot_manager.h"
#include "../common/repositories/criteria/content_filter_criteria.h"
#include "../common/say_link.h"
+1 -1
View File
@@ -2,7 +2,7 @@
#include "lua_expedition.h"
#include "expedition.h"
#include "zone_store.h"
#include "../common/zone_store.h"
#include "lua.hpp"
#include <luabind/luabind.hpp>
#include <luabind/object.hpp>
+2 -3
View File
@@ -49,7 +49,7 @@
#include "bot_command.h"
#endif
#include "zonedb.h"
#include "zone_store.h"
#include "../common/zone_store.h"
#include "titles.h"
#include "guild_mgr.h"
#include "task_manager.h"
@@ -78,7 +78,6 @@
#else
#include <pthread.h>
#include "../common/unix.h"
#include "zone_store.h"
#include "zone_event_scheduler.h"
#endif
@@ -303,7 +302,7 @@ int main(int argc, char** argv) {
LogInfo("Loading zone names");
zone_store.LoadZones();
zone_store.LoadZones(content_db);
LogInfo("Loading items");
if (!database.LoadItems(hotfix_name)) {
+3 -3
View File
@@ -1168,11 +1168,11 @@ void Merc::CalcRestState() {
}
}
RestRegenHP = 6 * (GetMaxHP() / zone->newzone_data.FastRegenHP);
RestRegenHP = 6 * (GetMaxHP() / zone->newzone_data.fast_regen_hp);
RestRegenMana = 6 * (GetMaxMana() / zone->newzone_data.FastRegenMana);
RestRegenMana = 6 * (GetMaxMana() / zone->newzone_data.fast_regen_mana);
RestRegenEndurance = 6 * (GetMaxEndurance() / zone->newzone_data.FastRegenEndurance);
RestRegenEndurance = 6 * (GetMaxEndurance() / zone->newzone_data.fast_regen_endurance);
}
bool Merc::HasSkill(EQ::skills::SkillType skill_id) const {
+1 -1
View File
@@ -1075,7 +1075,7 @@ void Mob::AI_Process() {
// NPCs will forget people after 10 mins of not interacting with them or out of range
// both of these maybe zone specific, hardcoded for now
if (hate_list_cleanup_timer.Check()) {
hate_list.RemoveStaleEntries(600000, static_cast<float>(zone->newzone_data.NPCAggroMaxDist));
hate_list.RemoveStaleEntries(600000, static_cast<float>(zone->newzone_data.npc_aggro_max_dist));
if (hate_list.IsHateListEmpty()) {
AI_Event_NoLongerEngaged();
zone->DelAggroMob();
+1 -1
View File
@@ -27,7 +27,7 @@
#include "mob.h"
#include "quest_parser_collection.h"
#include "zonedb.h"
#include "zone_store.h"
#include "../common/zone_store.h"
#ifdef BOTS
#include "bot.h"
+1 -1
View File
@@ -8,7 +8,7 @@
#include "zone.h"
#include "spawngroup.h"
#include "zonedb.h"
#include "zone_store.h"
#include "../common/zone_store.h"
#include "npc.h"
#include "mob.h"
#include "client.h"
+1 -1
View File
@@ -23,7 +23,7 @@
#include "mob.h"
#include "qglobals.h"
#include "zonedb.h"
#include "zone_store.h"
#include "../common/zone_store.h"
#include "zonedump.h"
#include "../common/loottable.h"
+1 -1
View File
@@ -26,7 +26,7 @@
#include "quest_parser_collection.h"
#include "zonedb.h"
#include "zone_store.h"
#include "../common/zone_store.h"
#include "../common/repositories/criteria/content_filter_criteria.h"
#include <iostream>
+1 -1
View File
@@ -4,7 +4,7 @@
#include "embperl.h"
#include "expedition.h"
#include "zone_store.h"
#include "../common/zone_store.h"
#include "../common/global_define.h"
void Perl_Expedition_AddLockout(Expedition* self, std::string event_name, uint32_t seconds)
+1 -1
View File
@@ -25,7 +25,7 @@
#include "client.h"
#include "zonedb.h"
#include "zone_store.h"
#include "../common/zone_store.h"
class Client;
+1 -1
View File
@@ -27,7 +27,7 @@
#include "pets.h"
#include "zonedb.h"
#include "zone_store.h"
#include "../common/zone_store.h"
#include <string>
+4 -4
View File
@@ -35,7 +35,7 @@
#include "worldserver.h"
#include "zone.h"
#include "zonedb.h"
#include "zone_store.h"
#include "../common/zone_store.h"
#include "dialogue_window.h"
#include "string_ids.h"
@@ -3364,11 +3364,11 @@ void QuestManager::UpdateZoneHeader(std::string type, std::string value) {
} else if (strcasecmp(type.c_str(), "fog_density") == 0) {
zone->newzone_data.fog_density = atof(value.c_str());
} else if (strcasecmp(type.c_str(), "suspendbuffs") == 0) {
zone->newzone_data.SuspendBuffs = atoi(value.c_str());
zone->newzone_data.suspend_buffs = atoi(value.c_str());
} else if (strcasecmp(type.c_str(), "lavadamage") == 0) {
zone->newzone_data.LavaDamage = atoi(value.c_str());
zone->newzone_data.lava_damage = atoi(value.c_str());
} else if (strcasecmp(type.c_str(), "minlavadamage") == 0) {
zone->newzone_data.MinLavaDamage = atoi(value.c_str());
zone->newzone_data.min_lava_damage = atoi(value.c_str());
}
auto outapp = new EQApplicationPacket(OP_NewZone, sizeof(NewZone_Struct));
+1 -1
View File
@@ -26,7 +26,7 @@
#include "worldserver.h"
#include "zone.h"
#include "zonedb.h"
#include "zone_store.h"
#include "../common/zone_store.h"
extern EntityList entity_list;
extern Zone* zone;
+1 -1
View File
@@ -24,7 +24,7 @@
#include "spawngroup.h"
#include "zone.h"
#include "zonedb.h"
#include "zone_store.h"
#include "../common/zone_store.h"
#include "../common/repositories/criteria/content_filter_criteria.h"
extern EntityList entity_list;
+1 -1
View File
@@ -2410,7 +2410,7 @@ void ClientTaskState::CreateTaskDynamicZone(Client* client, int task_id, Dynamic
// dz should be named the version-based zone name (used in choose zone window and dz window on live)
auto zone_info = zone_store.GetZone(dz_request.GetZoneID(), dz_request.GetZoneVersion());
dz_request.SetName(zone_info.long_name.empty() ? task->title : zone_info.long_name);
dz_request.SetName(zone_info->long_name.empty() ? task->title : zone_info->long_name);
dz_request.SetMinPlayers(task->min_players);
dz_request.SetMaxPlayers(task->max_players);
+1 -1
View File
@@ -33,8 +33,8 @@
#include "string_ids.h"
#include "titles.h"
#include "zonedb.h"
#include "zone_store.h"
#include "../common/repositories/char_recipe_list_repository.h"
#include "../common/zone_store.h"
#include "../common/repositories/tradeskill_recipe_repository.h"
extern QueryServ* QServ;
+7
View File
@@ -2041,6 +2041,13 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
content_db.LoadStaticZonePoints(&zone->zone_point_list, zone->GetShortName(), zone->GetInstanceVersion());
break;
}
case ServerOP_ReloadZoneData:
{
zone_store.LoadZones(content_db);
zone->LoadZoneCFG(zone->GetShortName(), zone->GetInstanceVersion());
zone->SendReloadMessage("Zone Data");
break;
}
case ServerOP_CameraShake:
{
if (zone)
+153 -60
View File
@@ -950,14 +950,14 @@ void Zone::LoadZoneDoors()
}
Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name)
: initgrids_timer(10000),
autoshutdown_timer((RuleI(Zone, AutoShutdownDelay))),
clientauth_timer(AUTHENTICATION_TIMEOUT * 1000),
spawn2_timer(1000),
hot_reload_timer(1000),
qglobal_purge_timer(30000),
m_SafePoint(0.0f,0.0f,0.0f,0.0f),
m_Graveyard(0.0f,0.0f,0.0f,0.0f)
: initgrids_timer(10000),
autoshutdown_timer((RuleI(Zone, AutoShutdownDelay))),
clientauth_timer(AUTHENTICATION_TIMEOUT * 1000),
spawn2_timer(1000),
hot_reload_timer(1000),
qglobal_purge_timer(30000),
m_safe_points(0.0f, 0.0f, 0.0f, 0.0f),
m_graveyard(0.0f, 0.0f, 0.0f, 0.0f)
{
zoneid = in_zoneid;
instanceid = in_instanceid;
@@ -977,7 +977,7 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name)
tradevar = 0;
lootvar = 0;
if(RuleB(TaskSystem, EnableTaskSystem)) {
if (RuleB(TaskSystem, EnableTaskSystem)) {
task_manager->LoadProximities(zoneid);
}
@@ -985,21 +985,41 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name)
strlwr(short_name);
memset(file_name, 0, sizeof(file_name));
long_name = 0;
aggroedmobs =0;
pgraveyard_id = 0;
aggroedmobs =0;
m_graveyard_id = 0;
pgraveyard_zoneid = 0;
pMaxClients = 0;
pvpzone = false;
if(database.GetServerType() == 1)
m_max_clients = 0;
pvpzone = false;
if (database.GetServerType() == 1) {
pvpzone = true;
content_db.GetZoneLongName(short_name, &long_name, file_name, &m_SafePoint.x, &m_SafePoint.y, &m_SafePoint.z, &pgraveyard_id, &pMaxClients);
if(graveyard_id() > 0)
{
}
auto z = GetZoneVersionWithFallback(ZoneID(short_name), instanceversion);
if (z) {
long_name = strcpy(new char[strlen(z->long_name.c_str()) + 1], z->long_name.c_str());
m_safe_points.x = z->safe_x;
m_safe_points.y = z->safe_y;
m_safe_points.z = z->safe_z;
m_safe_points.w = z->safe_heading;
m_graveyard_id = z->graveyard_id;
m_max_clients = z->maxclients;
if (z->file_name.empty()) {
strcpy(file_name, short_name);
}
else {
strcpy(file_name, z->file_name.c_str());
}
}
if (graveyard_id() > 0) {
LogDebug("Graveyard ID is [{}]", graveyard_id());
bool GraveYardLoaded = content_db.GetZoneGraveyard(graveyard_id(), &pgraveyard_zoneid, &m_Graveyard.x, &m_Graveyard.y, &m_Graveyard.z, &m_Graveyard.w);
bool GraveYardLoaded = content_db.GetZoneGraveyard(graveyard_id(), &pgraveyard_zoneid, &m_graveyard.x, &m_graveyard.y, &m_graveyard.z, &m_graveyard.w);
if (GraveYardLoaded) {
LogDebug("Loaded a graveyard for zone [{}]: graveyard zoneid is [{}] at [{}]", short_name, graveyard_zoneid(), to_string(m_Graveyard).c_str());
LogDebug("Loaded a graveyard for zone [{}]: graveyard zoneid is [{}] at [{}]", short_name, graveyard_zoneid(), to_string(m_graveyard).c_str());
}
else {
LogError("Unable to load the graveyard id [{}] for zone [{}]", graveyard_id(), short_name);
@@ -1280,52 +1300,125 @@ void Zone::ReloadStaticData() {
bool Zone::LoadZoneCFG(const char* filename, uint16 instance_version)
{
auto z = zone_store.GetZoneWithFallback(ZoneID(filename), instance_version);
if (!z) {
LogError("[LoadZoneCFG] Failed to load zone data for [{}] instance_version [{}]", filename, instance_version);
return false;
}
memset(&newzone_data, 0, sizeof(NewZone_Struct));
map_name = nullptr;
map_name = new char[100];
newzone_data.zone_id = zoneid;
if (!content_db.GetZoneCFG(
ZoneID(filename),
instance_version,
&newzone_data,
can_bind,
can_combat,
can_levitate,
can_castoutdoor,
is_city,
is_hotzone,
allow_mercs,
max_movement_update_range,
zone_type,
default_ruleset,
&map_name
)) {
// If loading a non-zero instance failed, try loading the default
if (instance_version != 0) {
safe_delete_array(map_name);
if (!content_db.GetZoneCFG(
ZoneID(filename),
0,
&newzone_data,
can_bind,
can_combat,
can_levitate,
can_castoutdoor,
is_city,
is_hotzone,
allow_mercs,
max_movement_update_range,
zone_type,
default_ruleset,
&map_name
)) {
LogError("Error loading the Zone Config");
return false;
}
}
strcpy(map_name, "default");
newzone_data.ztype = z->ztype;
zone_type = newzone_data.ztype;
// fog:red
newzone_data.fog_red[0] = z->fog_red;
newzone_data.fog_red[1] = z->fog_red2;
newzone_data.fog_red[2] = z->fog_red3;
newzone_data.fog_red[3] = z->fog_red4;
// fog:blue
newzone_data.fog_blue[0] = z->fog_blue;
newzone_data.fog_blue[1] = z->fog_blue2;
newzone_data.fog_blue[2] = z->fog_blue3;
newzone_data.fog_blue[3] = z->fog_blue4;
// fog:green
newzone_data.fog_green[0] = z->fog_green;
newzone_data.fog_green[1] = z->fog_green2;
newzone_data.fog_green[2] = z->fog_green3;
newzone_data.fog_green[3] = z->fog_green4;
// fog:minclip
newzone_data.fog_minclip[0] = z->fog_minclip;
newzone_data.fog_minclip[1] = z->fog_minclip2;
newzone_data.fog_minclip[2] = z->fog_minclip3;
newzone_data.fog_minclip[3] = z->fog_minclip4;
// fog:maxclip
newzone_data.fog_maxclip[0] = z->fog_maxclip;
newzone_data.fog_maxclip[1] = z->fog_maxclip2;
newzone_data.fog_maxclip[2] = z->fog_maxclip3;
newzone_data.fog_maxclip[3] = z->fog_maxclip4;
// rain_chance
newzone_data.rain_chance[0] = z->rain_chance1;
newzone_data.rain_chance[1] = z->rain_chance2;
newzone_data.rain_chance[2] = z->rain_chance3;
newzone_data.rain_chance[3] = z->rain_chance4;
// rain_duration
newzone_data.rain_duration[0] = z->rain_duration1;
newzone_data.rain_duration[1] = z->rain_duration2;
newzone_data.rain_duration[2] = z->rain_duration3;
newzone_data.rain_duration[3] = z->rain_duration4;
// snow_chance
newzone_data.snow_chance[0] = z->snow_chance1;
newzone_data.snow_chance[1] = z->snow_chance2;
newzone_data.snow_chance[2] = z->snow_chance3;
newzone_data.snow_chance[3] = z->snow_chance4;
// snow_duration
newzone_data.snow_duration[0] = z->snow_duration1;
newzone_data.snow_duration[1] = z->snow_duration2;
newzone_data.snow_duration[2] = z->snow_duration3;
newzone_data.snow_duration[3] = z->snow_duration4;
// misc
newzone_data.fog_density = z->fog_density;
newzone_data.sky = z->sky;
newzone_data.zone_exp_multiplier = z->zone_exp_multiplier;
newzone_data.safe_x = z->safe_x;
newzone_data.safe_y = z->safe_y;
newzone_data.safe_z = z->safe_z;
newzone_data.underworld = z->underworld;
newzone_data.minclip = z->minclip;
newzone_data.maxclip = z->maxclip;
newzone_data.time_type = z->time_type;
newzone_data.gravity = z->gravity;
newzone_data.fast_regen_hp = z->fast_regen_hp;
newzone_data.fast_regen_mana = z->fast_regen_mana;
newzone_data.fast_regen_endurance = z->fast_regen_endurance;
newzone_data.npc_aggro_max_dist = z->npc_max_aggro_dist;
newzone_data.underworld_teleport_index = z->underworld_teleport_index;
newzone_data.lava_damage = z->lava_damage;
newzone_data.min_lava_damage = z->min_lava_damage;
newzone_data.suspend_buffs = z->suspendbuffs;
// local attributes
can_bind = z->canbind != 0;
is_city = z->canbind == 2;
can_combat = z->cancombat != 0;
can_levitate = z->canlevitate != 0;
can_castoutdoor = z->castoutdoor != 0;
is_hotzone = z->hotzone != 0;
max_movement_update_range = z->max_movement_update_range;
default_ruleset = z->ruleset;
allow_mercs = true;
m_graveyard_id = z->graveyard_id;
m_max_clients = z->maxclients;
// safe coordinates
m_safe_points.x = z->safe_x;
m_safe_points.y = z->safe_y;
m_safe_points.z = z->safe_z;
m_safe_points.w = z->safe_heading;
if (!z->map_file_name.empty()) {
strcpy(map_name, z->map_file_name.c_str());
}
else {
strcpy(map_name, z->short_name.c_str());
}
//overwrite with our internal variables
// overwrite with our internal variables
strcpy(newzone_data.zone_short_name, GetShortName());
strcpy(newzone_data.zone_long_name, GetLongName());
strcpy(newzone_data.zone_short_name2, GetShortName());
@@ -2137,7 +2230,7 @@ bool Zone::HasGraveyard() {
void Zone::SetGraveyard(uint32 zoneid, const glm::vec4& graveyardPosition) {
pgraveyard_zoneid = zoneid;
m_Graveyard = graveyardPosition;
m_graveyard = graveyardPosition;
}
void Zone::LoadZoneBlockedSpells()
+10 -10
View File
@@ -25,7 +25,7 @@
#include "../common/random.h"
#include "../common/strings.h"
#include "zonedb.h"
#include "zone_store.h"
#include "../common/zone_store.h"
#include "../common/repositories/grid_repository.h"
#include "../common/repositories/grid_entries_repository.h"
#include "../common/repositories/zone_points_repository.h"
@@ -155,7 +155,7 @@ public:
ZonePoint *
GetClosestZonePoint(const glm::vec3 &location, const char *to_name, Client *client, float max_distance = 40000.0f);
inline bool BuffTimersSuspended() const { return newzone_data.SuspendBuffs != 0; };
inline bool BuffTimersSuspended() const { return newzone_data.suspend_buffs != 0; };
inline bool HasMap() { return zonemap != nullptr; }
inline bool HasWaterMap() { return watermap != nullptr; }
inline bool InstantGrids() { return (!initgrids_timer.Enabled()); }
@@ -166,13 +166,13 @@ public:
inline const char *GetShortName() { return short_name; }
inline const uint8 GetZoneType() const { return zone_type; }
inline const uint16 GetInstanceVersion() const { return instanceversion; }
inline const uint32 &GetMaxClients() { return pMaxClients; }
inline const uint32 &graveyard_id() { return pgraveyard_id; }
inline const uint32 &GetMaxClients() { return m_max_clients; }
inline const uint32 &graveyard_id() { return m_graveyard_id; }
inline const uint32 &graveyard_zoneid() { return pgraveyard_zoneid; }
inline const uint32 GetInstanceID() const { return instanceid; }
inline const uint32 GetZoneID() const { return zoneid; }
inline glm::vec4 GetSafePoint() { return m_SafePoint; }
inline glm::vec4 GetGraveyardPoint() { return m_Graveyard; }
inline glm::vec4 GetSafePoint() { return m_safe_points; }
inline glm::vec4 GetGraveyardPoint() { return m_graveyard; }
inline std::vector<int> GetGlobalLootTables(NPC *mob) const { return m_global_loot.GetGlobalLootTables(mob); }
inline Timer *GetInstanceTimer() { return Instance_Timer; }
inline void AddGlobalLootEntry(GlobalLootEntry &in) { return m_global_loot.AddEntry(in); }
@@ -409,8 +409,8 @@ private:
char *map_name;
char *short_name;
char file_name[16];
glm::vec4 m_SafePoint;
glm::vec4 m_Graveyard;
glm::vec4 m_safe_points;
glm::vec4 m_graveyard;
int default_ruleset;
int zone_total_blocked_spells;
int npc_position_update_distance;
@@ -419,8 +419,8 @@ private:
uint16 instanceversion;
uint32 instanceid;
uint32 instance_time_remaining;
uint32 pgraveyard_id, pgraveyard_zoneid;
uint32 pMaxClients;
uint32 m_graveyard_id, pgraveyard_zoneid;
uint32 m_max_clients;
uint32 zoneid;
uint32 m_last_ucss_update;
-162
View File
@@ -1,162 +0,0 @@
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY except by those people which sell it, which
* are required to give you total support for your newly bought product;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "zone_store.h"
#include "../common/repositories/content_flags_repository.h"
#include "../common/content/world_content_service.h"
ZoneStore::ZoneStore() = default;
ZoneStore::~ZoneStore() = default;
void ZoneStore::LoadZones()
{
zones = ZoneRepository::All(content_db);
}
/**
* @param in_zone_name
* @return
*/
uint32 ZoneStore::GetZoneID(const char *in_zone_name)
{
if (in_zone_name == nullptr) {
return 0;
}
std::string zone_name = Strings::ToLower(in_zone_name);
return GetZoneID(zone_name);
}
/**
* @param zone_name
* @return
*/
uint32 ZoneStore::GetZoneID(std::string zone_name)
{
for (auto &z: zones) {
if (z.short_name == zone_name) {
return z.zoneidnumber;
}
}
return 0;
}
/**
* @param zone_id
* @param error_unknown
* @return
*/
const char *ZoneStore::GetZoneName(uint32 zone_id, bool error_unknown)
{
for (auto &z: zones) {
if (z.zoneidnumber == zone_id) {
return z.short_name.c_str();
}
}
if (error_unknown) {
return "UNKNOWN";
}
return nullptr;
}
/**
* @param zone_id
* @param error_unknown
* @return
*/
const char *ZoneStore::GetZoneLongName(uint32 zone_id, bool error_unknown)
{
for (auto &z: zones) {
if (z.zoneidnumber == zone_id) {
return z.long_name.c_str();
}
}
if (error_unknown) {
return "UNKNOWN";
}
return nullptr;
}
/**
* @param zone_id
* @return
*/
std::string ZoneStore::GetZoneName(uint32 zone_id)
{
for (auto &z: zones) {
if (z.zoneidnumber == zone_id) {
return z.short_name;
}
}
return std::string();
}
/**
* @param zone_id
* @return
*/
std::string ZoneStore::GetZoneLongName(uint32 zone_id)
{
for (auto &z: zones) {
if (z.zoneidnumber == zone_id) {
return z.long_name;
}
}
return std::string();
}
/**
* @param zone_id
* @param version
* @return
*/
ZoneRepository::Zone ZoneStore::GetZone(uint32 zone_id, int version)
{
for (auto &z: zones) {
if (z.zoneidnumber == zone_id && z.version == version) {
return z;
}
}
return ZoneRepository::Zone();
}
/**
* @param in_zone_name
* @return
*/
ZoneRepository::Zone ZoneStore::GetZone(const char *in_zone_name)
{
for (auto &z: zones) {
if (z.short_name == in_zone_name) {
return z;
}
}
return ZoneRepository::Zone();
}
-71
View File
@@ -1,71 +0,0 @@
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY except by those people which sell it, which
* are required to give you total support for your newly bought product;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef EQEMU_ZONE_STORE_H
#define EQEMU_ZONE_STORE_H
#include "zonedb.h"
#include "../common/repositories/zone_repository.h"
#include "../common/repositories/base/base_content_flags_repository.h"
class ZoneStore {
public:
ZoneStore();
virtual ~ZoneStore();
std::vector<ZoneRepository::Zone> zones;
void LoadZones();
ZoneRepository::Zone GetZone(uint32 zone_id, int version = 0);
ZoneRepository::Zone GetZone(const char *in_zone_name);
uint32 GetZoneID(const char *in_zone_name);
uint32 GetZoneID(std::string zone_name);
std::string GetZoneName(uint32 zone_id);
std::string GetZoneLongName(uint32 zone_id);
const char *GetZoneName(uint32 zone_id, bool error_unknown = false);
const char *GetZoneLongName(uint32 zone_id, bool error_unknown = false);
};
extern ZoneStore zone_store;
/**
* Global helpers
*/
inline uint32 ZoneID(const char *in_zone_name) { return zone_store.GetZoneID(in_zone_name); }
inline uint32 ZoneID(std::string zone_name) { return zone_store.GetZoneID(zone_name); }
inline const char *ZoneName(uint32 zone_id, bool error_unknown = false)
{
return zone_store.GetZoneName(
zone_id,
error_unknown
);
}
inline const char *ZoneLongName(uint32 zone_id, bool error_unknown = false)
{
return zone_store.GetZoneLongName(
zone_id,
error_unknown
);
}
inline ZoneRepository::Zone GetZone(uint32 zone_id, int version = 0) { return zone_store.GetZone(zone_id, version); };
inline ZoneRepository::Zone GetZone(const char *in_zone_name) { return zone_store.GetZone(in_zone_name); };
#endif //EQEMU_ZONE_STORE_H
+2 -192
View File
@@ -11,7 +11,6 @@
#include "merc.h"
#include "zone.h"
#include "zonedb.h"
#include "zone_store.h"
#include "aura.h"
#include "../common/repositories/criteria/content_filter_criteria.h"
#include "../common/repositories/npc_types_repository.h"
@@ -95,182 +94,6 @@ bool ZoneDatabase::SaveZoneCFG(uint32 zoneid, uint16 instance_version, NewZone_S
return true;
}
bool ZoneDatabase::GetZoneCFG(
uint32 zoneid,
uint16 instance_version,
NewZone_Struct *zone_data,
bool &can_bind,
bool &can_combat,
bool &can_levitate,
bool &can_castoutdoor,
bool &is_city,
bool &is_hotzone,
bool &allow_mercs,
double &max_movement_update_range,
uint8 &zone_type,
int &ruleset,
char **map_filename) {
*map_filename = new char[100];
zone_data->zone_id = zoneid;
std::string query = fmt::format(
"SELECT "
"ztype, " // 0
"fog_red, " // 1
"fog_green, " // 2
"fog_blue, " // 3
"fog_minclip, " // 4
"fog_maxclip, " // 5
"fog_red2, " // 6
"fog_green2, " // 7
"fog_blue2, " // 8
"fog_minclip2, " // 9
"fog_maxclip2, " // 10
"fog_red3, " // 11
"fog_green3, " // 12
"fog_blue3, " // 13
"fog_minclip3, " // 14
"fog_maxclip3, " // 15
"fog_red4, " // 16
"fog_green4, " // 17
"fog_blue4, " // 18
"fog_minclip4, " // 19
"fog_maxclip4, " // 20
"fog_density, " // 21
"sky, " // 22
"zone_exp_multiplier, " // 23
"safe_x, " // 24
"safe_y, " // 25
"safe_z, " // 26
"underworld, " // 27
"minclip, " // 28
"maxclip, " // 29
"time_type, " // 30
"canbind, " // 31
"cancombat, " // 32
"canlevitate, " // 33
"castoutdoor, " // 34
"hotzone, " // 35
"ruleset, " // 36
"suspendbuffs, " // 37
"map_file_name, " // 38
"short_name, " // 39
"rain_chance1, " // 40
"rain_chance2, " // 41
"rain_chance3, " // 42
"rain_chance4, " // 43
"rain_duration1, " // 44
"rain_duration2, " // 45
"rain_duration3, " // 46
"rain_duration4, " // 47
"snow_chance1, " // 48
"snow_chance2, " // 49
"snow_chance3, " // 50
"snow_chance4, " // 51
"snow_duration1, " // 52
"snow_duration2, " // 53
"snow_duration3, " // 54
"snow_duration4, " // 55
"gravity, " // 56
"fast_regen_hp, " // 57
"fast_regen_mana, " // 58
"fast_regen_endurance, " // 59
"npc_max_aggro_dist, " // 60
"max_movement_update_range, " // 61
"underworld_teleport_index, " // 62
"lava_damage, " // 63
"min_lava_damage " // 64
"FROM zone WHERE zoneidnumber = {} AND version = {} {}",
zoneid,
instance_version,
ContentFilterCriteria::apply()
);
auto results = QueryDatabase(query);
if (!results.Success()) {
strcpy(*map_filename, "default");
return false;
}
if (results.RowCount() == 0) {
strcpy(*map_filename, "default");
return false;
}
auto& row = results.begin();
memset(zone_data, 0, sizeof(NewZone_Struct));
zone_data->ztype = atoi(row[0]);
zone_type = zone_data->ztype;
int index;
for (index = 0; index < 4; index++) {
zone_data->fog_red[index] = atoi(row[1 + index * 5]);
zone_data->fog_green[index] = atoi(row[2 + index * 5]);
zone_data->fog_blue[index] = atoi(row[3 + index * 5]);
zone_data->fog_minclip[index] = atof(row[4 + index * 5]);
zone_data->fog_maxclip[index] = atof(row[5 + index * 5]);
}
zone_data->fog_density = atof(row[21]);
zone_data->sky = atoi(row[22]);
zone_data->zone_exp_multiplier = atof(row[23]);
zone_data->safe_x = atof(row[24]);
zone_data->safe_y = atof(row[25]);
zone_data->safe_z = atof(row[26]);
zone_data->underworld = atof(row[27]);
zone_data->minclip = atof(row[28]);
zone_data->maxclip = atof(row[29]);
zone_data->time_type = atoi(row[30]);
//not in the DB yet:
zone_data->gravity = atof(row[56]);
LogDebug("Zone Gravity is [{}]", zone_data->gravity);
allow_mercs = true;
zone_data->FastRegenHP = atoi(row[57]);
zone_data->FastRegenMana = atoi(row[58]);
zone_data->FastRegenEndurance = atoi(row[59]);
zone_data->NPCAggroMaxDist = atoi(row[60]);
zone_data->underworld_teleport_index = atoi(row[62]);
zone_data->LavaDamage = atoi(row[63]);
zone_data->MinLavaDamage = atoi(row[64]);
int bindable = 0;
bindable = atoi(row[31]);
can_bind = bindable == 0 ? false : true;
is_city = bindable == 2 ? true : false;
can_combat = atoi(row[32]) == 0 ? false : true;
can_levitate = atoi(row[33]) == 0 ? false : true;
can_castoutdoor = atoi(row[34]) == 0 ? false : true;
is_hotzone = atoi(row[35]) == 0 ? false : true;
max_movement_update_range = atof(row[61]);
ruleset = atoi(row[36]);
zone_data->SuspendBuffs = atoi(row[37]);
char *file = row[38];
if (file)
strcpy(*map_filename, file);
else
strcpy(*map_filename, row[39]);
for (index = 0; index < 4; index++)
zone_data->rain_chance[index] = atoi(row[40 + index]);
for (index = 0; index < 4; index++)
zone_data->rain_duration[index] = atoi(row[44 + index]);
for (index = 0; index < 4; index++)
zone_data->snow_chance[index] = atoi(row[48 + index]);
for (index = 0; index < 4; index++)
zone_data->snow_duration[index] = atof(row[52 + index]);
return true;
}
void ZoneDatabase::UpdateRespawnTime(uint32 spawn2_id, uint16 instance_id, uint32 time_left)
{
@@ -3321,22 +3144,9 @@ bool ZoneDatabase::LoadBlockedSpells(int32 blockedSpellsCount, ZoneSpellsBlocked
int ZoneDatabase::getZoneShutDownDelay(uint32 zoneID, uint32 version)
{
std::string query = StringFormat("SELECT shutdowndelay FROM zone "
"WHERE zoneidnumber = %i AND (version=%i OR version=0) "
"ORDER BY version DESC", zoneID, version);
auto results = QueryDatabase(query);
if (!results.Success()) {
return (RuleI(Zone, AutoShutdownDelay));
}
auto z = GetZoneVersionWithFallback(zoneID, version);
if (results.RowCount() == 0) {
std::cerr << "Error in getZoneShutDownDelay no result '" << query << "' " << std::endl;
return (RuleI(Zone, AutoShutdownDelay));
}
auto& row = results.begin();
return atoi(row[0]);
return z ? z->shutdowndelay : RuleI(Zone, AutoShutdownDelay);
}
uint32 ZoneDatabase::GetKarma(uint32 acct_id)
+3 -18
View File
@@ -246,7 +246,7 @@ struct ClientMercEntry {
uint32 npcid;
};
namespace BeastlordPetData {
namespace BeastlordPetData {
struct PetStruct {
uint16 race_id = WOLF;
uint8 texture = 0;
@@ -369,7 +369,7 @@ public:
bool SaveCharacterSkill(uint32 character_id, uint32 skill_id, uint32 value);
bool SaveCharacterSpell(uint32 character_id, uint32 spell_id, uint32 slot_id);
bool SaveCharacterTribute(uint32 character_id, PlayerProfile_Struct* pp);
double GetAAEXPModifier(uint32 character_id, uint32 zone_id, int16 instance_version = -1) const;
double GetEXPModifier(uint32 character_id, uint32 zone_id, int16 instance_version = -1) const;
void SetAAEXPModifier(uint32 character_id, uint32 zone_id, double aa_modifier, int16 instance_version = -1);
@@ -386,7 +386,7 @@ public:
void DivergeCharacterInvSnapshotFromInventory(uint32 character_id, uint32 timestamp, std::list<std::pair<int16, uint32>> &compare_list);
void DivergeCharacterInventoryFromInvSnapshot(uint32 character_id, uint32 timestamp, std::list<std::pair<int16, uint32>> &compare_list);
bool RestoreCharacterInvSnapshot(uint32 character_id, uint32 timestamp);
/* Corpses */
bool DeleteItemOffCharacterCorpse(uint32 db_id, uint32 equip_slot, uint32 item_id);
uint32 GetCharacterCorpseItemCount(uint32 corpse_id);
@@ -432,21 +432,6 @@ public:
bool LoadAlternateAdvancement(Client *c);
/* Zone related */
bool GetZoneCFG(
uint32 zoneid,
uint16 instance_version,
NewZone_Struct *data,
bool &can_bind,
bool &can_combat,
bool &can_levitate,
bool &can_castoutdoor,
bool &is_city,
bool &is_hotzone,
bool &allow_mercs,
double &max_movement_update_range,
uint8 &zone_type,
int &ruleset,
char **map_filename);
bool SaveZoneCFG(uint32 zoneid, uint16 instance_version, NewZone_Struct* zd);
bool LoadStaticZonePoints(LinkedList<ZonePoint*>* zone_point_list,const char* zonename, uint32 version);
int getZoneShutDownDelay(uint32 zoneID, uint32 version);
+58 -55
View File
@@ -179,29 +179,32 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) {
return;
}
/* Load up the Safe Coordinates, restrictions and verify the zone name*/
float safe_x, safe_y, safe_z, safe_heading;
int16 min_status = AccountStatus::Player;
uint8 min_level = 0;
char flag_needed[128];
if(!content_db.GetSafePoints(
target_zone_name,
database.GetInstanceVersion(target_instance_id),
&safe_x,
&safe_y,
&safe_z,
&safe_heading,
&min_status,
&min_level,
flag_needed
)) {
//invalid zone...
auto zone_data = GetZoneVersionWithFallback(
ZoneID(target_zone_name),
database.GetInstanceVersion(target_instance_id)
);
if (!zone_data) {
Message(Chat::Red, "Invalid target zone while getting safe points.");
LogError("Zoning [{}]: Unable to get safe coordinates for zone [{}]", GetName(), target_zone_name);
SendZoneCancel(zc);
return;
}
float safe_x, safe_y, safe_z, safe_heading;
int16 min_status = AccountStatus::Player;
uint8 min_level = 0;
char flag_needed[128];
if (!zone_data->flag_needed.empty()) {
strcpy(flag_needed, zone_data->flag_needed.c_str());
}
safe_x = zone_data->safe_x;
safe_y = zone_data->safe_y;
safe_z = zone_data->safe_z;
min_status = zone_data->min_status;
min_level = zone_data->min_level;
std::string export_string = fmt::format(
"{} {}",
zone->GetZoneID(),
@@ -318,7 +321,7 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) {
//not sure when we would use ZONE_ERROR_NOTREADY
//enforce min status and level
if (!ignore_restrictions && (Admin() < min_status || GetLevel() < min_level))
if (!ignore_restrictions && (Admin() < min_status || GetLevel() < zone_data->min_level))
{
myerror = ZONE_ERROR_NOEXPERIENCE;
}
@@ -344,7 +347,7 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) {
*/
bool meets_zone_expansion_check = false;
bool found_zone = false;
for (auto &z: zone_store.zones) {
for (auto &z: zone_store.GetZones()) {
if (z.short_name == target_zone_name && z.version == 0) {
found_zone = true;
if (z.expansion <= content_service.GetCurrentExpansion() || z.bypass_expansion_check) {
@@ -664,7 +667,11 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z
char* pZoneName = nullptr;
pShortZoneName = ZoneName(zoneID);
content_db.GetZoneLongName(pShortZoneName, &pZoneName);
auto zd = GetZoneVersionWithFallback(zoneID, zone->GetInstanceVersion());
if (zd) {
pZoneName = strcpy(new char[strlen(zd->long_name.c_str()) + 1], zd->long_name.c_str());
}
cheat_manager.SetExemptStatus(Port, true);
@@ -1047,21 +1054,10 @@ void Client::SendZoneFlagInfo(Client *to) const {
const char* zone_short_name = ZoneName(zone_id, true);
if (strncmp(zone_short_name, "UNKNOWN", strlen(zone_short_name)) != 0) {
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
)) {
auto z = GetZone(zone_id);
if (!z) {
strcpy(flag_name, "ERROR");
}
@@ -1236,43 +1232,50 @@ bool Client::CanBeInZone() {
//only enforce rules here which are serious enough to warrant being kicked from
//the zone
if(Admin() >= RuleI(GM, MinStatusToZoneAnywhere))
return(true);
if (Admin() >= RuleI(GM, MinStatusToZoneAnywhere)) {
return (true);
}
float safe_x, safe_y, safe_z, safe_heading;
int16 min_status = AccountStatus::Player;
uint8 min_level = 0;
char flag_needed[128];
if(!content_db.GetSafePoints(
zone->GetShortName(),
zone->GetInstanceVersion(),
&safe_x,
&safe_y,
&safe_z,
&safe_heading,
&min_status,
&min_level,
flag_needed
)) {
auto z = GetZoneVersionWithFallback(
ZoneID(zone->GetShortName()),
zone->GetInstanceVersion()
);
if (!z) {
//this should not happen...
LogDebug("[CLIENT] Unable to query zone info for ourself [{}]", zone->GetShortName());
return(false);
return false;
}
if(GetLevel() < min_level) {
safe_x = z->safe_x;
safe_y = z->safe_y;
safe_z = z->safe_z;
safe_heading = z->safe_heading;
min_status = z->min_status;
min_level = z->min_level;
if (!z->flag_needed.empty()) {
strcpy(flag_needed, z->flag_needed.c_str());
}
if (GetLevel() < min_level) {
LogDebug("[CLIENT] Character does not meet min level requirement ([{}] < [{}])!", GetLevel(), min_level);
return(false);
return (false);
}
if(Admin() < min_status) {
if (Admin() < min_status) {
LogDebug("[CLIENT] Character does not meet min status requirement ([{}] < [{}])!", Admin(), min_status);
return(false);
return (false);
}
if(flag_needed[0] != '\0') {
if (flag_needed[0] != '\0') {
//the flag needed string is not empty, meaning a flag is required.
if(Admin() < minStatusToIgnoreZoneFlags && !HasZoneFlag(zone->GetZoneID())) {
if (Admin() < minStatusToIgnoreZoneFlags && !HasZoneFlag(zone->GetZoneID())) {
LogDebug("[CLIENT] Character does not have the flag to be in this zone ([{}])!", flag_needed);
return(false);
return (false);
}
}