Index: src/water_cmd.cpp
===================================================================
--- src/water_cmd.cpp	(revision 13759)
+++ src/water_cmd.cpp	(working copy)
@@ -1184,6 +1184,121 @@
 }
 
 
+DiagDirection GetAntiSeaDirection(TileIndex tile)
+{	
+	for (DiagDirection d = DIAGDIR_BEGIN; d < DIAGDIR_END; d++) {
+		TileIndex diag_tile = TileAddByDiagDir(tile, d);
+		if (!IsValidTile(diag_tile)) { continue; }
+		if ((IsTileType(diag_tile, MP_WATER)) && (IsSea(diag_tile))) {
+			return ReverseDiagDir(d);
+		}
+	}
+	return INVALID_DIAGDIR;
+}
+
+TileIndex GetRandomWell()
+{
+	TileIndex tile = INVALID_TILE;
+	Slope slopet;
+	for (int i = 0; i < 1000; i++) {
+		tile = RandomTile();
+		if (!IsValidTile(tile)) { continue; }
+		slopet = GetTileSlope(tile,NULL);
+		/// We cannot build a river, if the slope is wrong
+		if (! ( (slopet == SLOPE_NW) || (slopet == SLOPE_NE) ||
+			(slopet == SLOPE_SW) || (slopet == SLOPE_SE) ||
+			(slopet == SLOPE_FLAT))) {
+			continue;
+		}
+		///Don't start river adjacent to sea
+/*		if (GetAntiSeaDirection(tile) != INVALID_DIAGDIR) {
+			continue;
+		}*/
+		return tile;
+	}
+	return INVALID_TILE;
+}
+
+bool WalkRiver(TileIndex tile, DiagDirection dir, uint16 step)
+{
+	if (step > 5000) { return true; }
+	/// randomly change the flow direction with 20% chance
+	if ((Chance16(1,25)) && (dir != DIAGDIR_SE)) { dir = DIAGDIR_NW; }
+	if ((Chance16(1,25)) && (dir != DIAGDIR_SW)) { dir = DIAGDIR_NE; }
+	if ((Chance16(1,25)) && (dir != DIAGDIR_NE)) { dir = DIAGDIR_SW; }
+	if ((Chance16(1,25)) && (dir != DIAGDIR_NW)) { dir = DIAGDIR_SE; } 
+	TileIndex new_tile = TileAddByDiagDir(tile,dir);
+	/// Invalid tile means we're too close to the edge anyway...
+	if (IsValidTile(new_tile)) { 
+		/// stop river building, if we hit any water
+		if (IsTileType(new_tile, MP_WATER)) {
+			if (IsSea(new_tile)) {
+				return true;
+			}
+			if (Chance16(50,100)) { return false; }
+		}			
+		Slope slopet = GetTileSlope(new_tile,NULL);
+		if ((((slopet == SLOPE_NW) && (dir == DIAGDIR_SE)) || 
+			 ((slopet == SLOPE_NE) && (dir == DIAGDIR_SW)) ||
+			 ((slopet == SLOPE_SW) && (dir == DIAGDIR_NE)) || 
+			 ((slopet == SLOPE_SE) && (dir == DIAGDIR_NW)) ||
+			 (slopet == SLOPE_FLAT)) && 
+			 (TileHeight(new_tile) <= TileHeight(tile))) {
+			if (WalkRiver(new_tile,dir,step+1)) {
+				MakeRiver(new_tile,Random());
+				return true;
+			}			
+			/// With a 5% chance end river here and don't return
+			///if (Chance16(96,100)) { return true; }
+		}
+	}	
+	/// If we cannot walk on, we try the usual approach		
+	for (dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) {
+		new_tile = TileAddByDiagDir(tile, dir);
+		if (IsValidTile(new_tile)) { 
+			if (IsTileType(new_tile, MP_WATER)) { continue; }	
+			Slope slopet = GetTileSlope(new_tile,NULL);
+			if ((((slopet == SLOPE_NW) && (dir == DIAGDIR_SE)) || 
+				((slopet == SLOPE_NE) && (dir == DIAGDIR_SW)) ||
+				((slopet == SLOPE_SW) && (dir == DIAGDIR_NE)) || 
+				((slopet == SLOPE_SE) && (dir == DIAGDIR_NW)) ||
+				(slopet == SLOPE_FLAT)) && 
+				(TileHeight(new_tile) <= TileHeight(tile))) {
+				if (WalkRiver(new_tile,dir,step+1)) {
+					MakeRiver(new_tile,Random());
+					return true;
+				}
+			}
+		}
+	}
+	/// 1% chance to end river despite all trouble
+	if (Chance16(1,100)) { return true; }
+	return false;
+}
+
+void GenerateRivers()
+{
+	int number_rivers = ScaleByMapSize(10);
+	DiagDirection d = DIAGDIR_BEGIN;
+	for (int i = 0; i < number_rivers; i++) {
+		/*
+		 * Find a suitable coastal tile and flow the river upwards
+		 */
+		TileIndex tile_riverwell = GetRandomWell();
+		/// Should the search for a suitable tile fail, we skip the loop run
+		if (tile_riverwell == INVALID_TILE) { continue; }
+		MakeRiver(tile_riverwell,Random());
+//		d = GetAntiSeaDirection(tile_riverwell);
+		/// get a random starting direction - it's really randomly
+		/// chosen :-)
+		d = DIAGDIR_SE;
+		/// In order to walk on we have to invert the direction
+		/// Now just walk the river. We may end any time.
+		WalkRiver(tile_riverwell,d,0);
+	}
+}
+
+
 extern const TileTypeProcs _tile_type_water_procs = {
 	DrawTile_Water,           /* draw_tile_proc */
 	GetSlopeZ_Water,          /* get_slope_z_proc */
Index: src/genworld.cpp
===================================================================
--- src/genworld.cpp	(revision 13759)
+++ src/genworld.cpp	(working copy)
@@ -34,6 +34,7 @@
 void GenerateUnmovables();
 bool GenerateTowns();
 void GenerateTrees();
+void GenerateRivers();
 
 void StartupEconomy();
 void StartupPlayers();
@@ -113,8 +114,9 @@
 			GenerateLandscape(_gw.mode);
 			GenerateClearTile();
 
-			/* only generate towns, tree and industries in newgame mode. */
+			/* only generate towns, tree, rivers and industries in newgame mode. */
 			if (_game_mode != GM_EDITOR) {
+				GenerateRivers();
 				GenerateTowns();
 				GenerateIndustries();
 				GenerateUnmovables();
