diff options
author | Machiavelli <none@none> | 2010-06-19 17:26:12 +0200 |
---|---|---|
committer | Machiavelli <none@none> | 2010-06-19 17:26:12 +0200 |
commit | 8c8986b2bc7a5dee3c12252486ad68a40a482ee0 (patch) | |
tree | 0ffb64f293b409a10f898830515e3ee6e3dbe0a1 | |
parent | 706c0568a5a7261bbc1839d771bd885a5842a116 (diff) |
Fix usage of uninitialized waypoint array variables in ConfusedMovementGenerator<T>::Initialize and revert 9b1c565510+ad8ce5245e that covered up this problem without fixing it and introduced a faulty LOS calculation.
With thanks to Lynx3d and click, and Aokromes and ritchy for testing.
--HG--
branch : trunk
-rw-r--r-- | src/server/collision/Management/VMapManager2.cpp | 10 | ||||
-rw-r--r-- | src/server/collision/Maps/MapTree.cpp | 23 | ||||
-rw-r--r-- | src/server/collision/Maps/MapTree.h | 1 | ||||
-rw-r--r-- | src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp | 14 |
4 files changed, 17 insertions, 31 deletions
diff --git a/src/server/collision/Management/VMapManager2.cpp b/src/server/collision/Management/VMapManager2.cpp index 1e8a84aee52..032793b1c09 100644 --- a/src/server/collision/Management/VMapManager2.cpp +++ b/src/server/collision/Management/VMapManager2.cpp @@ -109,7 +109,7 @@ namespace VMAP ss2 >> map_num; if (map_num >= 0) { - std::cout << "ingoring Map " << map_num << " for VMaps\n"; + sLog.outDebug("Ignoring Map %i for VMaps", map_num); iIgnoreMapIds[map_num] = true; // unload map in case it is loaded unloadMap(map_num); @@ -299,11 +299,11 @@ namespace VMAP WorldModel *worldmodel = new WorldModel(); if (!worldmodel->readFile(basepath + filename + ".vmo")) { - std::cout << "VMapManager2: could not load '" << basepath << filename << ".vmo'!\n"; + sLog.outError("VMapManager2: could not load '%s%s.vmo'!", basepath, filename); delete worldmodel; return NULL; } - std::cout << "VMapManager2: loading file '" << basepath << filename << "'.\n"; + sLog.outDebug("VMapManager2: loading file '%s%s'.", basepath, filename); model = iLoadedModelFiles.insert(std::pair<std::string, ManagedModel>(filename, ManagedModel())).first; model->second.setModel(worldmodel); } @@ -316,12 +316,12 @@ namespace VMAP ModelFileMap::iterator model = iLoadedModelFiles.find(filename); if (model == iLoadedModelFiles.end()) { - std::cout << "VMapManager2: trying to unload non-loaded file '" << filename << "'!\n"; + sLog.outError("VMapManager2: trying to unload non-loaded file '%s'!", filename); return; } if( model->second.decRefCount() == 0) { - std::cout << "VMapManager2: unloading file '" << filename << "'.\n"; + sLog.outDebug("VMapManager2: unloading file '%s'", filename); delete model->second.getModel(); iLoadedModelFiles.erase(model); } diff --git a/src/server/collision/Maps/MapTree.cpp b/src/server/collision/Maps/MapTree.cpp index c733ed37454..af4073fcc8c 100644 --- a/src/server/collision/Maps/MapTree.cpp +++ b/src/server/collision/Maps/MapTree.cpp @@ -146,32 +146,19 @@ namespace VMAP bool StaticMapTree::isInLineOfSight(const Vector3& pos1, const Vector3& pos2) const { - bool result = false; + bool result = true; float maxDist = (pos2 - pos1).magnitude(); // valid map coords should *never ever* produce float overflow, but this would produce NaNs too - - //ASSERT(maxDist < std::numeric_limits<float>::max()); - + ASSERT(maxDist < std::numeric_limits<float>::max()); // prevent NaN values which can cause BIH intersection to enter infinite loop if (maxDist < 1e-10f) return true; // direction with length of 1 - G3D::Plane checkPlane = G3D::Plane((pos2 - pos1)/maxDist,pos1, pos2); G3D::Ray ray = G3D::Ray::fromOriginAndDirection(pos1, (pos2 - pos1)/maxDist); - - Vector3 checkFinite = ray.intersection(checkPlane); - if (!checkFinite.isFinite()) + float resultDist = getIntersectionTime(ray, maxDist, true); + if (resultDist < maxDist) { - ray = G3D::Ray::fromOriginAndDirection(pos1, -((pos2 - pos1)/maxDist)); - checkFinite = ray.intersection(checkPlane); - } - if (checkFinite.isFinite()) - { - float resultDist = getIntersectionTime(ray, maxDist, true); - if (resultDist >= maxDist) - { - result = true; - } + result = false; } return result; } diff --git a/src/server/collision/Maps/MapTree.h b/src/server/collision/Maps/MapTree.h index 7a7af43e949..f9c51d47b95 100644 --- a/src/server/collision/Maps/MapTree.h +++ b/src/server/collision/Maps/MapTree.h @@ -22,6 +22,7 @@ #include "Define.h" #include "Dynamic/UnorderedMap.h" #include "BoundingIntervalHierarchy.h" +#include "Log.h" namespace VMAP { diff --git a/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp index 43c6052d2d3..c9e39866bf5 100644 --- a/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp @@ -51,15 +51,13 @@ ConfusedMovementGenerator<T>::Initialize(T &unit) for (uint8 idx = 0; idx <= MAX_CONF_WAYPOINTS; ++idx) { + const float wanderX = wander_distance*rand_norm() - wander_distance/2; + const float wanderY = wander_distance*rand_norm() - wander_distance/2; + i_waypoints[idx][0] = x + wanderX; + i_waypoints[idx][1] = y + wanderY; + const bool isInLoS = vMaps->isInLineOfSight(unit.GetMapId(), x, y, z + 2.0f, i_waypoints[idx][0], i_waypoints[idx][1], z + 2.0f); - if (isInLoS) - { - const float wanderX = wander_distance*rand_norm() - wander_distance/2; - const float wanderY = wander_distance*rand_norm() - wander_distance/2; - i_waypoints[idx][0] = x + wanderX; - i_waypoints[idx][1] = y + wanderY; - } - else + if (!isInLoS) { i_waypoints[idx][0] = x; i_waypoints[idx][1] = y; |