<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -428,7 +428,7 @@ bool CPathFinder::TestSquare(const MoveData&amp; moveData, const CPathFinderDef&amp; pfD
 	float heatCostMod = 1.0f;
 	if (heatMapping &amp;&amp; moveData.heatMapping
 			&amp;&amp; heatmap[square.x][square.y].ownerId != ownerId) {
-		heatCostMod += moveData.heatMod * heatmap[square.x][square.y].value;
+		heatCostMod += moveData.heatMod * std::max(0, heatmap[square.x][square.y].value - heatMapOffset);
 	}
 
 	float squareCost = heatCostMod * moveCost[enterDirection] / squareSpeedMod;
@@ -520,7 +520,7 @@ void CPathFinder::FinishSearch(const MoveData&amp; moveData, Path&amp; foundPath) {
 			if (false &amp;&amp; heatMapping &amp;&amp; moveData.heatMapping) {
 				for (int i = 0; i &lt; foundPath.squares.size(); ++i) {
 					const int2&amp; tmp = foundPath.squares[i];
-					heatmap[tmp.x][tmp.y].value = std::max(heatmap[tmp.x][tmp.y].value, moveData.heatProduced);
+					heatmap[tmp.x][tmp.y].value = std::max(heatmap[tmp.x][tmp.y].value, moveData.heatProduced + heatMapOffset);
 				}
 			}
 		}
@@ -688,20 +688,13 @@ void CPathFinder::InitHeatMap()
 	for (int i = 0; i&lt;gs-&gt;mapx; ++i) {
 		heatmap[i].resize(gs-&gt;mapy);
 	}
+	heatMapOffset = 0;
 }
 
 
 void CPathFinder::UpdateHeatMap()
 {
-	if (heatmap.empty())
-		return;
-
-	for (int x = 0; x&lt;gs-&gt;mapx; x += 2) {
-		for (int y = 0; y&lt;gs-&gt;mapy; y += 2) {
-			if (heatmap[x][y].value &gt; 0)
-				--heatmap[x][y].value;
-		}
-	}
+	++heatMapOffset;
 }
 
 </diff>
      <filename>rts/Sim/Path/PathFinder.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -81,17 +81,12 @@ public:
 	bool GetHeatMapState() { return heatMapping; }
 	void UpdateHeatMap();
 
-	struct HeatMapValue {
-		int value;
-		int ownerId;
-	};
-
 	void UpdateHeatValue(int x, int y, int value, int ownerId)
 	{
 		assert(!heatmap.empty());
 
-		if (heatmap[x][y].value &lt; value) {
-			heatmap[x][y].value = value;
+		if (heatmap[x][y].value &lt; value + heatMapOffset) {
+			heatmap[x][y].value = value + heatMapOffset;
 			heatmap[x][y].ownerId = ownerId;
 		}
 	}
@@ -121,6 +116,7 @@ private:
 		unsigned int status;
 		float cost;
 	};
+
 	class myVector{
 	public:
 		typedef OpenSquare* value_type;
@@ -177,10 +173,11 @@ private:
 		inline void clear()			{bufPos=-1;}
 	};
 
-  class myPQ : public std::priority_queue&lt;OpenSquare*,myVector,lessCost&gt;{
+	class myPQ : public std::priority_queue&lt;OpenSquare*,myVector,lessCost&gt;{
 	public:
 		void DeleteAll();
-  };
+	};
+
 	void ResetSearch();
 	SearchResult InitSearch(const MoveData&amp; moveData, const CPathFinderDef&amp; pfDef, int ownerId);
 	SearchResult DoSearch(const MoveData&amp; moveData, const CPathFinderDef&amp; pfDef, int ownerId);
@@ -218,8 +215,14 @@ private:
 	OpenSquare openSquareBuffer[MAX_SEARCHED_SQUARES];
 
 	// Heat mapping
+	struct HeatMapValue {
+		int value;
+		int ownerId;
+	};
+
 	bool heatMapping;
 	std::vector&lt;std::vector&lt;HeatMapValue&gt; &gt; heatmap;
+	int heatMapOffset;  // heatmap values are relative to this
 
 public:
 	void Draw(void);</diff>
      <filename>rts/Sim/Path/PathFinder.h</filename>
    </modified>
    <modified>
      <diff>@@ -44,7 +44,7 @@ CPathManager::~CPathManager() {
 void CPathManager::SetHeatMappingEnabled(bool enabled)
 {
 	pf-&gt;SetHeatMapState(enabled);
-};
+}
 
 bool CPathManager::GetHeatMappingEnabled()
 {</diff>
      <filename>rts/Sim/Path/PathManager.cpp</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>bba10b61bcd91eedc4e08fc7bdda6c2680b8d3e6</id>
    </parent>
  </parents>
  <author>
    <name>Tobi Vollebregt</name>
    <email>tobivollebregt@gmail.com</email>
  </author>
  <url>http://github.com/spring/spring/commit/35a923037035addc8d050219d1351afa619ab7f4</url>
  <id>35a923037035addc8d050219d1351afa619ab7f4</id>
  <committed-date>2009-10-07T08:53:06-07:00</committed-date>
  <authored-date>2009-10-07T08:53:06-07:00</authored-date>
  <message>got rid of expensive UpdateHeatMap implementation

(by storing heat+heatMapOffset, and only incrementing heatMapOffset every frame)</message>
  <tree>160dcfc7321da125dd27d66aefa16208c4a72140</tree>
  <committer>
    <name>Tobi Vollebregt</name>
    <email>tobivollebregt@gmail.com</email>
  </committer>
</commit>
