From 800d5c2d6927441b67dd38ff81da6401961176bc Mon Sep 17 00:00:00 2001
From: Andreas Monzner <andreas.monzner@multimedia-labs.de>
Date: Thu, 22 Dec 2005 09:56:31 +0000
Subject: [PATCH] fix satellite order in channellist save orbital position in
 lamedb compatible with e1

---
 lib/dvb/db.cpp | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/lib/dvb/db.cpp b/lib/dvb/db.cpp
index 33a422f8..d40b4b10 100644
--- a/lib/dvb/db.cpp
+++ b/lib/dvb/db.cpp
@@ -279,7 +279,8 @@ void eDVBDB::load()
 				sat.symbol_rate = symbol_rate;
 				sat.polarisation = polarisation;
 				sat.fec = fec;
-				sat.orbital_position = orbital_position;
+				sat.orbital_position =
+					orbital_position < 0 ? orbital_position + 3600 : orbital_position;
 				sat.inversion = inversion;
 				feparm->setDVBS(sat);
 			} else if (line[1]=='t')
@@ -418,7 +419,8 @@ void eDVBDB::save()
 		{
 			fprintf(f, "\ts %d:%d:%d:%d:%d:%d\n",
 				sat.frequency, sat.symbol_rate,
-				sat.polarisation, sat.fec, sat.orbital_position,
+				sat.polarisation, sat.fec,
+				sat.orbital_position > 1800 ? sat.orbital_position - 3600 : sat.orbital_position,
 				sat.inversion);
 		}
 		if (!ch.m_frontendParameters->getDVBT(ter))
@@ -829,7 +831,15 @@ RESULT eDVBDBListQuery::getNextResult(eServiceReferenceDVB &ref)
 int eDVBDBListQuery::compareLessEqual(const eServiceReferenceDVB &a, const eServiceReferenceDVB &b)
 {
 	if ( m_query->m_sort == eDVBChannelQuery::tSatellitePosition )
-		return (a.getDVBNamespace().get() >> 16) < (b.getDVBNamespace().get() >> 16);
+	{
+		int x = (a.getDVBNamespace().get() >> 16);
+		int y = (b.getDVBNamespace().get() >> 16);
+		if ( x > 1800 )
+			x -= 3600;
+		if ( y > 1800 )
+			y -= 3600;
+		return x < y;
+	}
 	return a.name < b.name;
 }
 
-- 
2.30.2