Skip to content

Commit

Permalink
sparse demo parsing (disabled by default)
Browse files Browse the repository at this point in the history
  • Loading branch information
onethirtyfive committed Sep 1, 2013
1 parent 1b0e712 commit e78082c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions skadi/demo.py
Expand Up @@ -86,13 +86,14 @@ def construct(*args):


class Stream(object):
def __init__(self, prologue, io, world, string_tables, remaining_packets):
def __init__(self, prologue, io, world, string_tables, rem, sparse=False):
self.prologue = prologue
self.demo_io = d_io.construct(io)
self.world = world
self.string_tables = string_tables
self.sparse = sparse

for peek, message in remaining_packets:
for peek, message in rem:
pbmsg = d_io.parse(peek.kind, peek.compressed, message)
self.advance(peek.tick, pbmsg)

Expand Down Expand Up @@ -156,7 +157,7 @@ def advance(self, tick, pbmsg):
elif mode & u_ent.PVS.Deleting:
self.world.delete(index)
elif mode ^ u_ent.PVS.Leaving:
state = dict(self.world.find_index(index))
state = {} if self.sparse else dict(self.world.find_index(index))
state.update(context)

self.world.update(index, state)
Expand Down Expand Up @@ -199,7 +200,7 @@ def __init__(self, abspath):
self.io = infile
self._tell = infile.tell()

def stream(self, tick=0):
def stream(self, tick=0, sparse=False):
self.io.seek(self._tell)
args = fast_forward(self.prologue, d_io.construct(self.io), tick=tick)
return Stream(self.prologue, self.io, *args)
return Stream(self.prologue, self.io, *args, sparse=sparse)

0 comments on commit e78082c

Please sign in to comment.