home · contact · privacy
Optimize send_gamestate, don't send any invisible state changes.
[plomrogue2] / plomrogue / commands.py
index 1cf051266e81a6c504454004a1f3cfddb7cb3bfd..8b1a1b99d58b54505c1a3c89c5752b11f20481cb 100644 (file)
@@ -46,15 +46,15 @@ def cmd_LOGIN(game, nick, connection_id):
         'thing_id': t.id_,
         'status': 'player'
     }
+    game.io.send('PLAYER_ID %s' % t.id_, connection_id)
     game.io.send('LOGIN_OK', connection_id)
     t.name = nick
     game.io.send('CHAT ' + quote(t.name + ' entered the map.'))
-    game.io.send('PLAYER_ID %s' % t.id_, connection_id)
     for s in [s for s in game.things
               if s.type_ == 'SpawnPoint' and s.name == t.name]:
         t.position = s.position
         break
-    game.changed = True
+    # game.changed = True  # handled by game.add_thing
 cmd_LOGIN.argtypes = 'string'
 
 def cmd_BECOME_ADMIN(game, password, connection_id):
@@ -95,7 +95,9 @@ def cmd_THING_PROTECTION(game, thing_id, protection_char, connection_id):
     if not t:
         raise GameError('thing of ID %s not found' % thing_id)
     t.protection = protection_char
-    #game.changed = True
+    game.changed = True
+    # FIXME: pseudo-FOV-change actually
+    game.record_fov_change(t.position)
 cmd_THING_PROTECTION.argtypes = 'int:pos char'
 
 def cmd_SET_MAP_CONTROL_PASSWORD(game, tile_class, password, connection_id):
@@ -120,6 +122,8 @@ def cmd_NICK(game, nick, connection_id):
     t.name = nick
     game.io.send('CHAT ' + quote(old_nick + ' renamed themselves to ' + nick))
     game.changed = True
+    # FIXME: pseudo-FOV-change actually
+    game.record_fov_change(t.position)
 cmd_NICK.argtypes = 'string'
 
 def cmd_GET_GAMESTATE(game, connection_id):
@@ -166,6 +170,8 @@ def cmd_ANNOTATE(game, yx, msg, pw, connection_id):
         if big_yx not in game.annotations:
             game.annotations[big_yx] = {}
         game.annotations[big_yx][little_yx] = msg
+    # FIXME: pseudo-FOV-change actually
+    game.record_fov_change([big_yx, little_yx])
     game.changed = True
 cmd_ANNOTATE.argtypes = 'yx_tuple:nonneg string string'
 
@@ -184,6 +190,8 @@ def cmd_PORTAL(game, yx, msg, pw, connection_id):
         if big_yx not in game.portals:
             game.portals[big_yx] = {}
         game.portals[big_yx][little_yx] = msg
+    # FIXME: pseudo-FOV-change actually
+    game.record_fov_change([big_yx, little_yx])
     game.changed = True
 cmd_PORTAL.argtypes = 'yx_tuple:nonneg string string'
 
@@ -228,7 +236,7 @@ def cmd_THING(game, big_yx, little_yx, thing_type, thing_id):
         raise GameError('illegal thing type %s' % thing_type)
     _ = game.get_map(big_yx)
     game.add_thing(thing_type, (big_yx, little_yx), id_=thing_id)
-    game.changed = True
+    # game.changed = True  handled by add_thing
 cmd_THING.argtypes = 'yx_tuple yx_tuple:nonneg string:thing_type int:nonneg'
 
 def cmd_THING_NAME(game, thing_id, name, pw, connection_id):
@@ -240,6 +248,8 @@ def cmd_THING_NAME(game, thing_id, name, pw, connection_id):
         raise GameError('wrong password for thing')
     t.name = name
     game.changed = True
+    # FIXME: pseudo-FOV-change actually
+    game.record_fov_change(t.position)
 cmd_THING_NAME.argtypes = 'int:pos string string'
 
 def cmd_GOD_THING_NAME(game, thing_id, name):
@@ -313,6 +323,8 @@ def cmd_PLAYER_FACE(game, face, connection_id):
         raise GameError('wrong face string length')
     game.faces[t.name] = face
     game.changed = True
+    # FIXME: pseudo-FOV-change actually
+    game.record_fov_change(t.position)
 cmd_PLAYER_FACE.argtypes = 'string'
 
 def cmd_GOD_PLAYER_FACE(game, name, face):