View Single Post
  #7  
Old 01-22-2015, 11:27 AM
iluvseq
Sarnak
 
Join Date: Aug 2009
Location: Somewhere
Posts: 53
Default

Ok, figured it out. The current codebase has a bug with watermap v1 files. Basically all the calls to InWater() etc were converted to pass an xyz_location struct instead of y,x,z directly, but those function signatures were never added to water_map_v1. So if a user loads v1 watermaps (which are the only kind I can find anywhere anyway) InWater() and related calls always return false due to the virtual signature in water_map.h.

This patch fixes that, by adding xyz_location based versions to water_map_v1. I left in the legacy (y,x,z) signatures as well, even though they are never called, just in case there's some code somewhere that depends on it that I'm missing.

Code:
diff --git a/zone/water_map_v1.cpp b/zone/water_map_v1.cpp
index 4f3797a..2fd63d3 100644
--- a/zone/water_map_v1.cpp
+++ b/zone/water_map_v1.cpp
@@ -14,6 +14,26 @@ WaterRegionType WaterMapV1::ReturnRegionType(float y, float x, float z) const {
        return BSPReturnRegionType(1, y, x, z);
 }
 
+WaterRegionType WaterMapV1::ReturnRegionType(const xyz_location& location) const {
+       return BSPReturnRegionType(1, location.m_X, location.m_Y, location.m_Z);
+}
+
+bool WaterMapV1::InWater(const xyz_location& location) const {
+       return ReturnRegionType(location) == RegionTypeWater;
+}
+
+bool WaterMapV1::InVWater(const xyz_location& location) const {
+       return ReturnRegionType(location) == RegionTypeVWater;
+}
+
+bool WaterMapV1::InLava(const xyz_location& location) const {
+       return ReturnRegionType(location) == RegionTypeLava;
+}
+
+bool WaterMapV1::InLiquid(const xyz_location& location) const {
+       return InWater(location) || InLava(location);
+}
+
 bool WaterMapV1::InWater(float y, float x, float z) const {
        return ReturnRegionType(y, x, z) == RegionTypeWater;
 }
diff --git a/zone/water_map_v1.h b/zone/water_map_v1.h
index dfac5f9..061b475 100644
--- a/zone/water_map_v1.h
+++ b/zone/water_map_v1.h
@@ -24,6 +24,11 @@ public:
        virtual bool InVWater(float y, float x, float z) const;
        virtual bool InLava(float y, float x, float z) const;
        virtual bool InLiquid(float y, float x, float z) const;
+       virtual WaterRegionType ReturnRegionType(const xyz_location& location) const;
+       virtual bool InWater(const xyz_location& location) const;
+       virtual bool InVWater(const xyz_location& location) const;
+       virtual bool InLava(const xyz_location& location) const;
+       virtual bool InLiquid(const xyz_location& location) const;
        
 protected:
        virtual bool Load(FILE *fp);
Trevius: You are correct, if a user finds a spot to 'skill up' swimming that doesn't result in any actual movement, the skillup patch I submitted above will not kick in. They'll have to either use Drajor's trick or go against a zone wall with a slightly upper angle so that they are constantly moving a little. Seems legit and live-like to me

Sorry this patch isn't a git 'pull' request, but I'm still learning git and don't quite know how to do that yet...
Reply With Quote