[Hotfix] Fix database loading routines (#4030)

This commit is contained in:
Chris Miles 2024-01-29 00:14:33 -06:00 committed by GitHub
parent 2e0ed82986
commit bc59882a65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 26 additions and 62 deletions

View File

@ -37,7 +37,7 @@ public:
uint32_t respawn_time;
uint32_t respawn_var;
int8_t triggered_number;
int8_t group;
int8_t group_;
int8_t despawn_when_triggered;
int8_t undetectable;
int8_t min_expansion;
@ -72,7 +72,7 @@ public:
"respawn_time",
"respawn_var",
"triggered_number",
"group",
"`group`",
"despawn_when_triggered",
"undetectable",
"min_expansion",
@ -103,7 +103,7 @@ public:
"respawn_time",
"respawn_var",
"triggered_number",
"group",
"`group`",
"despawn_when_triggered",
"undetectable",
"min_expansion",
@ -168,7 +168,7 @@ public:
e.respawn_time = 60;
e.respawn_var = 0;
e.triggered_number = 0;
e.group = 0;
e.group_ = 0;
e.despawn_when_triggered = 0;
e.undetectable = 0;
e.min_expansion = -1;
@ -229,7 +229,7 @@ public:
e.respawn_time = row[15] ? static_cast<uint32_t>(strtoul(row[15], nullptr, 10)) : 60;
e.respawn_var = row[16] ? static_cast<uint32_t>(strtoul(row[16], nullptr, 10)) : 0;
e.triggered_number = row[17] ? static_cast<int8_t>(atoi(row[17])) : 0;
e.group = row[18] ? static_cast<int8_t>(atoi(row[18])) : 0;
e.group_ = row[18] ? static_cast<int8_t>(atoi(row[18])) : 0;
e.despawn_when_triggered = row[19] ? static_cast<int8_t>(atoi(row[19])) : 0;
e.undetectable = row[20] ? static_cast<int8_t>(atoi(row[20])) : 0;
e.min_expansion = row[21] ? static_cast<int8_t>(atoi(row[21])) : -1;
@ -286,7 +286,7 @@ public:
v.push_back(columns[15] + " = " + std::to_string(e.respawn_time));
v.push_back(columns[16] + " = " + std::to_string(e.respawn_var));
v.push_back(columns[17] + " = " + std::to_string(e.triggered_number));
v.push_back(columns[18] + " = " + std::to_string(e.group));
v.push_back(columns[18] + " = " + std::to_string(e.group_));
v.push_back(columns[19] + " = " + std::to_string(e.despawn_when_triggered));
v.push_back(columns[20] + " = " + std::to_string(e.undetectable));
v.push_back(columns[21] + " = " + std::to_string(e.min_expansion));
@ -332,7 +332,7 @@ public:
v.push_back(std::to_string(e.respawn_time));
v.push_back(std::to_string(e.respawn_var));
v.push_back(std::to_string(e.triggered_number));
v.push_back(std::to_string(e.group));
v.push_back(std::to_string(e.group_));
v.push_back(std::to_string(e.despawn_when_triggered));
v.push_back(std::to_string(e.undetectable));
v.push_back(std::to_string(e.min_expansion));
@ -386,7 +386,7 @@ public:
v.push_back(std::to_string(e.respawn_time));
v.push_back(std::to_string(e.respawn_var));
v.push_back(std::to_string(e.triggered_number));
v.push_back(std::to_string(e.group));
v.push_back(std::to_string(e.group_));
v.push_back(std::to_string(e.despawn_when_triggered));
v.push_back(std::to_string(e.undetectable));
v.push_back(std::to_string(e.min_expansion));
@ -444,7 +444,7 @@ public:
e.respawn_time = row[15] ? static_cast<uint32_t>(strtoul(row[15], nullptr, 10)) : 60;
e.respawn_var = row[16] ? static_cast<uint32_t>(strtoul(row[16], nullptr, 10)) : 0;
e.triggered_number = row[17] ? static_cast<int8_t>(atoi(row[17])) : 0;
e.group = row[18] ? static_cast<int8_t>(atoi(row[18])) : 0;
e.group_ = row[18] ? static_cast<int8_t>(atoi(row[18])) : 0;
e.despawn_when_triggered = row[19] ? static_cast<int8_t>(atoi(row[19])) : 0;
e.undetectable = row[20] ? static_cast<int8_t>(atoi(row[20])) : 0;
e.min_expansion = row[21] ? static_cast<int8_t>(atoi(row[21])) : -1;
@ -493,7 +493,7 @@ public:
e.respawn_time = row[15] ? static_cast<uint32_t>(strtoul(row[15], nullptr, 10)) : 60;
e.respawn_var = row[16] ? static_cast<uint32_t>(strtoul(row[16], nullptr, 10)) : 0;
e.triggered_number = row[17] ? static_cast<int8_t>(atoi(row[17])) : 0;
e.group = row[18] ? static_cast<int8_t>(atoi(row[18])) : 0;
e.group_ = row[18] ? static_cast<int8_t>(atoi(row[18])) : 0;
e.despawn_when_triggered = row[19] ? static_cast<int8_t>(atoi(row[19])) : 0;
e.undetectable = row[20] ? static_cast<int8_t>(atoi(row[20])) : 0;
e.min_expansion = row[21] ? static_cast<int8_t>(atoi(row[21])) : -1;
@ -592,7 +592,7 @@ public:
v.push_back(std::to_string(e.respawn_time));
v.push_back(std::to_string(e.respawn_var));
v.push_back(std::to_string(e.triggered_number));
v.push_back(std::to_string(e.group));
v.push_back(std::to_string(e.group_));
v.push_back(std::to_string(e.despawn_when_triggered));
v.push_back(std::to_string(e.undetectable));
v.push_back(std::to_string(e.min_expansion));
@ -639,7 +639,7 @@ public:
v.push_back(std::to_string(e.respawn_time));
v.push_back(std::to_string(e.respawn_var));
v.push_back(std::to_string(e.triggered_number));
v.push_back(std::to_string(e.group));
v.push_back(std::to_string(e.group_));
v.push_back(std::to_string(e.despawn_when_triggered));
v.push_back(std::to_string(e.undetectable));
v.push_back(std::to_string(e.min_expansion));

View File

@ -607,7 +607,8 @@ sub get_reserved_cpp_variable_names
"key",
"rank",
"range",
"interval"
"interval",
"group"
);
}

View File

@ -887,10 +887,6 @@ bool SpawnConditionManager::LoadSpawnConditions(const std::string& zone_short_na
)
);
if (conditions.empty()) {
return false;
}
for (const auto& e : conditions) {
SpawnCondition c;
@ -919,10 +915,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const std::string& zone_short_na
)
);
if (condition_values.empty()) {
spawn_conditions.clear();
return false;
}
spawn_conditions.clear();
for (const auto& e : condition_values) {
auto i = spawn_conditions.find(e.id);
@ -939,10 +932,6 @@ bool SpawnConditionManager::LoadSpawnConditions(const std::string& zone_short_na
)
);
if (events.empty()) {
return false;
}
LogInfo("Loaded [{}] spawn_events", Strings::Commify(std::to_string(events.size())));
for (const auto& e : events) {

View File

@ -459,8 +459,8 @@ bool ZoneDatabase::LoadTraps(const std::string& zone_short_name, int16 instance_
}
for (const auto& e : l) {
if (e.group) {
if (entity_list.IsTrapGroupSpawned(e.id, e.group)) {
if (e.group_) {
if (entity_list.IsTrapGroupSpawned(e.id, e.group_)) {
// If a member of our group is already spawned skip loading this trap.
continue;
}
@ -482,7 +482,7 @@ bool ZoneDatabase::LoadTraps(const std::string& zone_short_name, int16 instance_
t->respawn_time = e.respawn_time;
t->respawn_var = e.respawn_var;
t->level = e.level;
t->group = e.group;
t->group = e.group_;
t->triggered_number = e.triggered_number;
t->despawn_when_triggered = e.despawn_when_triggered;
t->undetectable = e.undetectable;

View File

@ -1123,49 +1123,25 @@ bool Zone::Init(bool is_static) {
watermap = WaterMap::LoadWaterMapfile(map_name);
pathing = IPathfinder::Load(map_name);
if(!spawn_conditions.LoadSpawnConditions(short_name, instanceid)) {
LogError("Loading spawn conditions failed, continuing without them");
}
spawn_conditions.LoadSpawnConditions(short_name, instanceid);
if (!content_db.LoadStaticZonePoints(&zone_point_list, short_name, GetInstanceVersion())) {
LogError("Loading static zone points failed");
return false;
}
content_db.LoadStaticZonePoints(&zone_point_list, short_name, GetInstanceVersion());
if (!content_db.LoadSpawnGroups(short_name, GetInstanceVersion(), &spawn_group_list)) {
LogError("Loading spawn groups failed");
return false;
}
if (!content_db.PopulateZoneSpawnList(zoneid, spawn2_list, GetInstanceVersion()))
{
LogError("Loading spawn2 points failed");
return false;
}
content_db.PopulateZoneSpawnList(zoneid, spawn2_list, GetInstanceVersion());
database.LoadCharacterCorpses(zoneid, instanceid);
if (!database.LoadCharacterCorpses(zoneid, instanceid)) {
LogError("Loading player corpses failed");
return false;
}
if (!content_db.LoadTraps(short_name, GetInstanceVersion()))
{
LogError("Loading traps failed");
return false;
}
content_db.LoadTraps(short_name, GetInstanceVersion());
LogInfo("Loading adventure flavor text");
LoadAdventureFlavor();
if (!LoadGroundSpawns())
{
LogError("Loading ground spawns failed. continuing");
}
if (!LoadZoneObjects())
{
LogError("Loading World Objects failed. continuing");
}
LoadGroundSpawns();
LoadZoneObjects();
RespawnTimesRepository::ClearExpiredRespawnTimers(database);
@ -1923,9 +1899,7 @@ void Zone::Repop()
LogError("Loading spawn groups failed");
}
if (!spawn_conditions.LoadSpawnConditions(short_name, instanceid)) {
LogError("Loading spawn conditions failed, continuing without them");
}
spawn_conditions.LoadSpawnConditions(short_name, instanceid);
if (!content_db.PopulateZoneSpawnList(zoneid, spawn2_list, GetInstanceVersion())) {
LogDebug("Error in Zone::Repop: database.PopulateZoneSpawnList failed");