Skip to content

Commit

Permalink
Fix some client desyncs
Browse files Browse the repository at this point in the history
  • Loading branch information
matpow2 committed Jul 30, 2017
1 parent 53be235 commit e28015d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions cuwo/server.py
Expand Up @@ -52,7 +52,7 @@

class Entity(world.Entity):
connection = None
first_update = True
full_update = True

def init(self, *args, **kw):
self.close_players = {}
Expand Down Expand Up @@ -321,7 +321,7 @@ def on_name_update(self):
if self.old_entity.name:
print(self.old_entity.name, 'changed name to', self.entity.name)
if self.entity:
self.entity.first_update = True
self.entity.full_update = True
self.scripts.call('on_name_update')

def on_pos_update(self):
Expand Down Expand Up @@ -624,10 +624,11 @@ def send_entity_data(self, entity):
entity_packet.set_entity(entity, entity.entity_id)
full = packets.write_packet(entity_packet)

# reduced rate dummy packet
# reduced rate packet (only send pos)
skip_reduced = self.skip_index != 0
self.skip_index = (self.skip_index + 1) % base.reduce_skip
entity_packet.set_entity(entity, entity.entity_id, 0)
entity_packet.set_entity(entity, entity.entity_id,
entitydata.POS_FLAG)
reduced = packets.write_packet(entity_packet)

max_distance = base.max_distance
Expand All @@ -641,7 +642,7 @@ def send_entity_data(self, entity):
continue
if entity is player_entity:
continue
if entity.first_update:
if entity.full_update:
connection.send_data(full)
new_close_players[connection] = entity.copy()
continue
Expand All @@ -660,12 +661,13 @@ def send_entity_data(self, entity):
new_close_players[connection] = old_ref
continue
new_mask = entitydata.get_mask(old_ref, entity)
new_mask |= entitydata.POS_FLAG
entity_packet.set_entity(entity, entity.entity_id, new_mask)
connection.send_packet(entity_packet)
new_close_players[connection] = entity.copy()

entity.close_players = new_close_players
entity.first_update = False
entity.full_update = False

def update(self):
self.scripts.call('update')
Expand Down

0 comments on commit e28015d

Please sign in to comment.