Commits

Andrew Peterson  committed 5c2e8ba

The server no longer sends an initial Ship Update right after a player connects. Instead the initial ship update is added to the ClientInit. If this ClientInit starts becoming to large, we may need to think about splitting up the initial updates into seperate ones handled by the LoadingState.

  • Participants
  • Parent commits b094a14

Comments (0)

Files changed (3)

File pyshipcommand/network.py

 
         self.server_step = None
         self.universe = None
+        self.ships = None
 
 #end NetInit
 

File pyshipcommand/players.py

         log.info('Player: "%s" has connected', self.name)
         self.remote = mind
 
-        # send ship update immediately
-        self.sendShips()
         return True
             
     def disconnect(self, mind):
         if scripts:
             cinit.scripts = [NetScript(s.name, s.version, s.lastHash) for s in scripts.itervalues()]
 
+        # Send Universe
         univ = getUtility(IManager, "Universe")
         bodies = univ.getAllStatic()
         cinit.universe = [NetCelestialBody(b) for b in bodies]
+
+        # Send Ships
+        ships = self.getShips()
+        cinit.ships = [NetShip(s) for s in ships]
         
         return cinit
 

File pyshipcommand_gui/viewer.py

         print "View Position: %s" % (str(init_data.start_pos))
 
         self.player_id = init_data.player_id
-        self.mship = init_data.mship_id
         self.setServerStep(init_data.server_step)
+
+        self.updateShips(init_data.ships)
+        self.mship = self.ships[init_data.mship_id]
+        
         
     def updateShips(self, net_ships):