Browse Source

Minor optimizations

Tomasz Zieliński 1 year ago
parent
commit
8602a14e6f
3 changed files with 6 additions and 5 deletions
  1. 1 1
      lib/rmg/RmgMap.cpp
  2. 1 1
      lib/rmg/RmgMap.h
  3. 4 3
      lib/rmg/RmgPath.cpp

+ 1 - 1
lib/rmg/RmgMap.cpp

@@ -309,7 +309,7 @@ void RmgMap::setZoneID(const int3& tile, TRmgTemplateZoneId zid)
 	zoneColouring[tile.x][tile.y][tile.z] = zid;
 }
 
-void RmgMap::setNearestObjectDistance(int3 &tile, float value)
+void RmgMap::setNearestObjectDistance(const int3 &tile, float value)
 {
 	assertOnMap(tile);
 	

+ 1 - 1
lib/rmg/RmgMap.h

@@ -61,7 +61,7 @@ public:
 	TerrainTile & getTile(const int3 & tile) const;
 		
 	float getNearestObjectDistance(const int3 &tile) const;
-	void setNearestObjectDistance(int3 &tile, float value);
+	void setNearestObjectDistance(const int3 &tile, float value);
 	
 	TRmgTemplateZoneId getZoneID(const int3& tile) const;
 	void setZoneID(const int3& tile, TRmgTemplateZoneId zid);

+ 4 - 3
lib/rmg/RmgPath.cpp

@@ -68,11 +68,12 @@ Path Path::search(const Tileset & dst, bool straight, std::function<float(const
 	if(!dArea)
 		return Path::invalid();
 	
+	if(dst.empty()) // Skip construction of same area
+		return Path(*dArea);
+
 	auto resultArea = *dArea + dst;
 	Path result(resultArea);
-	if(dst.empty())
-		return result;
-	
+
 	int3 src = rmg::Area(dst).nearest(dPath);
 	result.connect(src);