mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
[Bugfix] Load zone variables before encounter_load. (#4846)
This commit is contained in:
parent
b883888a19
commit
4fc0ffd173
@ -1191,6 +1191,11 @@ bool Zone::Init(bool is_static) {
|
||||
|
||||
RespawnTimesRepository::ClearExpiredRespawnTimers(database);
|
||||
|
||||
// Loading zone variables so they're available for things like encounter_load
|
||||
if (RuleB(Zone, StateSavingOnShutdown)) {
|
||||
zone->LoadZoneVariablesState();
|
||||
}
|
||||
|
||||
// make sure that anything that needs to be loaded prior to scripts is loaded before here
|
||||
// this is to ensure that the scripts have access to the data they need
|
||||
parse->ReloadQuests(true);
|
||||
|
||||
@ -476,6 +476,7 @@ public:
|
||||
inline uint32 GetZoneServerId() const { return m_zone_server_id; }
|
||||
|
||||
// zone state
|
||||
bool LoadZoneVariablesState();
|
||||
bool LoadZoneState(
|
||||
std::unordered_map<uint32, uint32> spawn_times,
|
||||
std::vector<Spawn2DisabledRepository::Spawn2Disabled> disabled_spawns
|
||||
|
||||
@ -381,6 +381,31 @@ inline void LoadZoneVariables(Zone *z, const std::string &variables)
|
||||
}
|
||||
}
|
||||
|
||||
bool Zone::LoadZoneVariablesState()
|
||||
{
|
||||
auto spawn_states = ZoneStateSpawnsRepository::GetWhere(
|
||||
database,
|
||||
fmt::format(
|
||||
"zone_id = {} AND instance_id = {} AND is_zone = 1 ORDER BY spawn2_id",
|
||||
zoneid,
|
||||
zone->GetInstanceID()
|
||||
)
|
||||
);
|
||||
|
||||
if (spawn_states.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto &s: spawn_states) {
|
||||
if (s.is_zone) {
|
||||
LoadZoneVariables(zone, s.entity_variables);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Zone::LoadZoneState(
|
||||
std::unordered_map<uint32, uint32> spawn_times,
|
||||
std::vector<Spawn2DisabledRepository::Spawn2Disabled> disabled_spawns
|
||||
@ -389,18 +414,19 @@ bool Zone::LoadZoneState(
|
||||
auto spawn_states = ZoneStateSpawnsRepository::GetWhere(
|
||||
database,
|
||||
fmt::format(
|
||||
"zone_id = {} AND instance_id = {} ORDER BY spawn2_id",
|
||||
"zone_id = {} AND instance_id = {} AND is_zone = 0 ORDER BY spawn2_id",
|
||||
zoneid,
|
||||
zone->GetInstanceID()
|
||||
)
|
||||
);
|
||||
|
||||
LogInfo("Loading zone state spawns for zone [{}] spawns [{}]", GetShortName(), spawn_states.size());
|
||||
|
||||
if (spawn_states.empty()) {
|
||||
LogInfo("No zone state spawns found for zone [{}] instance [{}]", GetShortName(), zone->GetInstanceID());
|
||||
return false;
|
||||
}
|
||||
|
||||
LogInfo("Loading zone state spawns for zone [{}] instance [{}] spawns [{}]", GetShortName(), zone->GetInstanceID(), spawn_states.size());
|
||||
|
||||
if (!IsZoneStateValid(spawn_states)) {
|
||||
LogZoneState("Invalid zone state data for zone [{}]", GetShortName());
|
||||
ClearZoneState(zoneid, zone->GetInstanceID());
|
||||
@ -414,16 +440,8 @@ bool Zone::LoadZoneState(
|
||||
zone->initgrids_timer.Trigger();
|
||||
zone->Process();
|
||||
|
||||
// load zone variables first
|
||||
int count = 0;
|
||||
for (auto &s: spawn_states) {
|
||||
if (s.is_zone) {
|
||||
LoadZoneVariables(zone, s.entity_variables);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// spawn2
|
||||
int count = 0;
|
||||
for (auto &s: spawn_states) {
|
||||
if (s.spawngroup_id == 0 || s.is_corpse || s.is_zone) {
|
||||
continue;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user