From 15b3f414a3b1bdcf783d6e36609506602d3d6e42 Mon Sep 17 00:00:00 2001
From: HAL20000 <hans.liegener@fau.de>
Date: Wed, 8 May 2019 21:57:27 +0000
Subject: [PATCH] Fix disappearing planets in network games (they turned into
 BHs)

---
 src/bin/slingshot         | 5 +++--
 src/slingshot/planet.py   | 5 +++--
 src/slingshot/settings.py | 6 +++++-
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/bin/slingshot b/src/bin/slingshot
index 68185fb..7509f23 100644
--- a/src/bin/slingshot
+++ b/src/bin/slingshot
@@ -371,8 +371,9 @@ class Game:
                     result.add(Planet(result, self.background))
         else:
             for p in planetlist:
-                if p[0] > Settings.MAX_PLANETS:
-                    # Numbers above Settings.MAX_PLANETS are
+                if p[0] > Settings.NUM_PLANET_SPRITES:
+                    # Numbers above
+                    # Settings.NUM_PLANET_SPRITES are
                     # allocated to blackholes.
                     result.add(Blackhole(None, self.background, p[0], p[1], p[2], p[3]))
                 else:
diff --git a/src/slingshot/planet.py b/src/slingshot/planet.py
index a6da9db..af11c2f 100644
--- a/src/slingshot/planet.py
+++ b/src/slingshot/planet.py
@@ -60,7 +60,7 @@ def __init__(self, planets, background, n=None, radius=None, mass=None, pos=None
 			unique = False
 			while not unique:
 				unique = True
-				self.n = randint(1, 8)
+				self.n = randint(1, Settings.NUM_PLANET_SPRITES)
 				for p in planets:
 					if self.n == p.get_n():
 						unique = False
@@ -143,7 +143,8 @@ def __init__(self, planets, background, n=None, radius=None, mass=None, pos=None
 			unique = False
 			while not unique:
 				unique = True
-				self.n = randint(Settings.MAX_PLANETS + 1, Settings.MAX_PLANETS + Settings.MAX_BLACKHOLES + 1)
+				self.n = randint(Settings.NUM_PLANET_SPRITES +
+                                        1, Settings.NUM_PLANET_SPRITES + Settings.MAX_BLACKHOLES + 1)
 				for p in planets:
 					if self.n == p.get_n():
 						unique = False
diff --git a/src/slingshot/settings.py b/src/slingshot/settings.py
index 799fa7b..733605f 100644
--- a/src/slingshot/settings.py
+++ b/src/slingshot/settings.py
@@ -26,7 +26,7 @@
 
 class Settings:
 
-        VERSION = '0.9'
+        VERSION = '0.9r1'
 
 	g = 120 # gravity
 	MAXPOWER = 350
@@ -52,6 +52,10 @@ class Settings:
 	MAX_FLIGHT = 750
 
 	MAX_PLANETS = 4
+        # MAX_PLANTES_SPRITES is the number of planet sprites, hence the maximal
+        # number for any Planet.n and we can identify BHs by haveing an n >
+        # NUM_PLANET_SPRITES
+        NUM_PLANET_SPRITES = 8
         MAX_BLACKHOLES = 0
 
 	HITSCORE = 1500