Преглед изворни кода

[RMG]Fix gcc build, remove some unused variables

AlexVinS пре 11 година
родитељ
комит
f212c8221d
4 измењених фајлова са 11 додато и 16 уклоњено
  1. 4 8
      lib/rmg/CMapGenerator.cpp
  2. 3 3
      lib/rmg/CMapGenerator.h
  3. 3 4
      lib/rmg/CRmgTemplateZone.cpp
  4. 1 1
      lib/rmg/CRmgTemplateZone.h

+ 4 - 8
lib/rmg/CMapGenerator.cpp

@@ -20,7 +20,7 @@ void CMapGenerator::foreach_neighbour(const int3 &pos, std::function<void(int3&
 	{
 		int3 n = pos + dir;
 		if(map->isInTheMap(n))
-			foo(pos+dir);
+			foo(n);
 	}
 }
 
@@ -191,7 +191,6 @@ void CMapGenerator::genZones()
 	zones = tmpl->getZones(); //copy from template (refactor?)
 
 	int player_per_side = zones.size() > 4 ? 3 : 2;
-	int zones_cnt = zones.size() > 4 ? 9 : 4;
 		
 	logGlobal->infoStream() << boost::format("Map size %d %d, players per side %d") % w % h % player_per_side;
 
@@ -200,9 +199,6 @@ void CMapGenerator::genZones()
 	placer.assignZones(mapGenOptions);
 
 	int i = 0;
-	int part_w = w/player_per_side;
-	int part_h = h/player_per_side;
-
 
 	for(auto const it : zones)
 	{
@@ -276,7 +272,7 @@ bool CMapGenerator::isFree(const int3 &tile) const
 
 	return tiles[tile.x][tile.y][tile.z].isFree();
 }
-void CMapGenerator::setOccupied(int3 &tile, ETileType::ETileType state)
+void CMapGenerator::setOccupied(const int3 &tile, ETileType::ETileType state)
 {
 	if (!map->isInTheMap(tile))
 		throw  rmgException(boost::to_string(boost::format("Tile %s is outside the map") % tile));
@@ -284,7 +280,7 @@ void CMapGenerator::setOccupied(int3 &tile, ETileType::ETileType state)
 	tiles[tile.x][tile.y][tile.z].setOccupied(state);
 }
 
-CTileInfo CMapGenerator::getTile(int3 tile) const
+CTileInfo CMapGenerator::getTile(const int3&  tile) const
 {
 	if (!map->isInTheMap(tile))
 		throw  rmgException(boost::to_string(boost::format("Tile %s is outside the map") % tile));
@@ -306,4 +302,4 @@ int CMapGenerator::getNearestObjectDistance(const int3 &tile) const
 		throw  rmgException(boost::to_string(boost::format("Tile %s is outside the map") % tile));
 
 	return tiles[tile.x][tile.y][tile.z].getNearestObjectDistance();
-}
+}

+ 3 - 3
lib/rmg/CMapGenerator.h

@@ -70,8 +70,8 @@ public:
 	bool shouldBeBlocked(const int3 &tile) const;
 	bool isPossible(const int3 &tile) const;
 	bool isFree(const int3 &tile) const;
-	void setOccupied(int3 &tile, ETileType::ETileType state);
-	CTileInfo getTile(int3 tile) const;
+	void setOccupied(const int3 &tile, ETileType::ETileType state);
+	CTileInfo getTile(const int3 & tile) const;
 
 	int getNearestObjectDistance(const int3 &tile) const; 
 	void setNearestObjectDistance(int3 &tile, int value); 
@@ -89,4 +89,4 @@ private:
 	void genZones();
 	void fillZones();
 
-};
+};

+ 3 - 4
lib/rmg/CRmgTemplateZone.cpp

@@ -367,7 +367,7 @@ void CRmgTemplateZone::createBorder(CMapGenerator* gen)
 	}
 }
 
-bool CRmgTemplateZone::crunchPath (CMapGenerator* gen, int3 &src, int3 &dst, TRmgTemplateZoneId zone)
+bool CRmgTemplateZone::crunchPath (CMapGenerator* gen, const int3 &src, const int3 &dst, TRmgTemplateZoneId zone)
 {
 /*
 make shortest path with free tiles, reachning dst or closest already free tile. Avoid blocks.
@@ -588,12 +588,11 @@ bool CRmgTemplateZone::findPlaceForObject(CMapGenerator* gen, CGObjectInstance*
 	bool result = false;
 	si32 w = gen->map->width;
 	si32 h = gen->map->height; 
-	auto ow = obj->getWidth();
-	auto oh = obj->getHeight();
+
 	//logGlobal->infoStream() << boost::format("Min dist for density %f is %d") % density % min_dist;
 	for(auto tile : tileinfo)
 	{
-		auto &ti = gen->getTile(tile);
+		auto ti = gen->getTile(tile);
 		auto dist = ti.getNearestObjectDistance();
 		//avoid borders
 		if ((tile.x < 3) || (w - tile.x < 3) || (tile.y < 3) || (h - tile.y < 3))

+ 1 - 1
lib/rmg/CRmgTemplateZone.h

@@ -115,7 +115,7 @@ public:
 	bool fill(CMapGenerator* gen);
 	void createConnections(CMapGenerator* gen);
 	void createBorder(CMapGenerator* gen);
-	bool crunchPath (CMapGenerator* gen, int3 &src, int3 &dst, TRmgTemplateZoneId zone);
+	bool crunchPath (CMapGenerator* gen, const int3 &src, const int3 &dst, TRmgTemplateZoneId zone);
 
 	void addConnection(TRmgTemplateZoneId otherZone);
 	std::vector<TRmgTemplateZoneId> getConnections() const;