From 4fa8c89e5cc7471402742e47c5d361167948de26 Mon Sep 17 00:00:00 2001 From: Joshua Packard Date: Wed, 28 Sep 2016 19:24:09 -0700 Subject: [PATCH 1/4] Added Best Z Calculation to Ground Spawn Loc --- zone/object.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/zone/object.cpp b/zone/object.cpp index c00f718b3..b28a886f3 100644 --- a/zone/object.cpp +++ b/zone/object.cpp @@ -451,6 +451,21 @@ void Object::RandomSpawn(bool send_packet) { m_data.x = zone->random.Real(m_min_x, m_max_x); m_data.y = zone->random.Real(m_min_y, m_max_y); + + if(m_data.z == BEST_Z_INVALID) { + glm::vec3 me; + me.x = m_data.x; + me.y = m_data.y; + me.z = 0; + glm::vec3 hit; + float best_z = zone->zonemap->FindClosestZ(me, &hit); + if (best_z != BEST_Z_INVALID) { + m_data.z = best_z; + } + } + + Log.Out(Logs::Detail, Logs::Zone_Server, "Object::RandomSpawn(%s): %d (%.2f, %.2f, %.2f)", m_data.object_name, m_inst->GetID(), m_data.x, m_data.y, m_data.z); + respawn_timer.Disable(); if(send_packet) { From 329c9c8d98535b410880389227e8167130fa9930 Mon Sep 17 00:00:00 2001 From: Joshua Packard Date: Wed, 28 Sep 2016 19:26:44 -0700 Subject: [PATCH 2/4] Reordered zone initialization Needed to reorder zone init so that the zonemap is loaded before ground spawns are made, otherwise the best Z won't calculate. --- zone/zone.cpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index 35b2d52bb..1edf1a268 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -100,9 +100,6 @@ bool Zone::Bootup(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) { worldserver.SetZoneData(0); return false; } - zone->zonemap = Map::LoadMapFile(zone->map_name); - zone->watermap = WaterMap::LoadWaterMapfile(zone->map_name); - zone->pathing = PathManager::LoadPathFile(zone->map_name); std::string tmp; if (database.GetVariable("loglevel", tmp)) { @@ -877,6 +874,23 @@ Zone::~Zone() { //Modified for timezones. bool Zone::Init(bool iStaticZone) { SetStaticZone(iStaticZone); + + //load the zone config file. + if (!LoadZoneCFG(zone->GetShortName(), zone->GetInstanceVersion(), true)) // try loading the zone name... + LoadZoneCFG(zone->GetFileName(), zone->GetInstanceVersion()); // if that fails, try the file name, then load defaults + + if(RuleManager::Instance()->GetActiveRulesetID() != default_ruleset) + { + std::string r_name = RuleManager::Instance()->GetRulesetName(&database, default_ruleset); + if(r_name.size() > 0) + { + RuleManager::Instance()->LoadRules(&database, r_name.c_str()); + } + } + + zone->zonemap = Map::LoadMapFile(zone->map_name); + zone->watermap = WaterMap::LoadWaterMapfile(zone->map_name); + zone->pathing = PathManager::LoadPathFile(zone->map_name); Log.Out(Logs::General, Logs::Status, "Loading spawn conditions..."); if(!spawn_conditions.LoadSpawnConditions(short_name, instanceid)) { @@ -969,19 +983,6 @@ bool Zone::Init(bool iStaticZone) { petition_list.ClearPetitions(); petition_list.ReadDatabase(); - //load the zone config file. - if (!LoadZoneCFG(zone->GetShortName(), zone->GetInstanceVersion(), true)) // try loading the zone name... - LoadZoneCFG(zone->GetFileName(), zone->GetInstanceVersion()); // if that fails, try the file name, then load defaults - - if(RuleManager::Instance()->GetActiveRulesetID() != default_ruleset) - { - std::string r_name = RuleManager::Instance()->GetRulesetName(&database, default_ruleset); - if(r_name.size() > 0) - { - RuleManager::Instance()->LoadRules(&database, r_name.c_str()); - } - } - Log.Out(Logs::General, Logs::Status, "Loading timezone data..."); zone->zone_time.setEQTimeZone(database.GetZoneTZ(zoneid, GetInstanceVersion())); From 379ef7eed314fc887e47b36859dbc69b1c888024 Mon Sep 17 00:00:00 2001 From: Joshua Packard Date: Thu, 29 Sep 2016 16:49:05 -0700 Subject: [PATCH 3/4] Added optional SQL to apply max z updates --- utils/sql/git/optional/2016_09_29_GroundSpawnsMaxZ.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 utils/sql/git/optional/2016_09_29_GroundSpawnsMaxZ.sql diff --git a/utils/sql/git/optional/2016_09_29_GroundSpawnsMaxZ.sql b/utils/sql/git/optional/2016_09_29_GroundSpawnsMaxZ.sql new file mode 100644 index 000000000..1cc98e246 --- /dev/null +++ b/utils/sql/git/optional/2016_09_29_GroundSpawnsMaxZ.sql @@ -0,0 +1 @@ +UPDATE ground_spawns SET max_z = -99999 WHERE max_x != min_x OR max_y != min_y From a5b19d0c0df7dff2b4d648f204aeb7f91da05363 Mon Sep 17 00:00:00 2001 From: Joshua Packard Date: Mon, 10 Oct 2016 09:39:55 -0700 Subject: [PATCH 4/4] Added 0.1 to calculated Z so that objects show better above ground --- zone/object.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/object.cpp b/zone/object.cpp index b28a886f3..ab9637e96 100644 --- a/zone/object.cpp +++ b/zone/object.cpp @@ -460,7 +460,7 @@ void Object::RandomSpawn(bool send_packet) { glm::vec3 hit; float best_z = zone->zonemap->FindClosestZ(me, &hit); if (best_z != BEST_Z_INVALID) { - m_data.z = best_z; + m_data.z = best_z + 0.1f; } }