GraylinKim / sc2reader

A python library that extracts data from various Starcraft II resources to power tools and services for the SC2 community. Who doesn't want to hack on the games they play?
http://sc2reader.readthedocs.org
MIT License
411 stars 85 forks source link

"Rejoin" events not used for players list on resumed replays. #180

Closed OlegSmelov closed 9 years ago

OlegSmelov commented 9 years ago

Parsing this replay fails with the following exception:

<type 'exceptions.AttributeError'>
Traceback (most recent call last):
  File "xxx", line 51, in upload_file
    analysis.perform()
  File "xxx", line 27, in perform
    replay = sc2reader.load_replay(self.filename, load_level=4, do_tracker_events=False)
  File "build/bdist.macosx-10.9-intel/egg/sc2reader/factories/sc2factory.py", line 85, in load_replay
    return self.load(Replay, source, options, **new_options)
  File "build/bdist.macosx-10.9-intel/egg/sc2reader/factories/sc2factory.py", line 137, in load
    return self._load(cls, resource, filename=filename, options=options)
  File "build/bdist.macosx-10.9-intel/egg/sc2reader/factories/sc2factory.py", line 146, in _load
    obj = cls(resource, filename=filename, factory=self, **options)
  File "build/bdist.macosx-10.9-intel/egg/sc2reader/resources.py", line 309, in __init__
    engine.run(self)
  File "build/bdist.macosx-10.9-intel/egg/sc2reader/engine/engine.py", line 174, in run
    for new_event in (event_handler(event, replay) or []):
  File "build/bdist.macosx-10.9-intel/egg/sc2reader/engine/plugins/context.py", line 18, in handleGameEvent
    self.load_message_game_player(event, replay)
  File "build/bdist.macosx-10.9-intel/egg/sc2reader/engine/plugins/context.py", line 257, in load_message_game_player
    self.logger.error("Bad pid ({0}) for event {1} at {2} [{3}].".format(event.pid, event.__class__, Length(seconds=event.second), event.frames))
AttributeError: 'CameraEvent' object has no attribute 'frames'

GGTracker also fails to parse this replay, so I assume this has nothing to do with my OS/Python version/use case. This game was resumed from replay, so it might change some things internally.

This should fail:

import sc2reader
replay = sc2reader.load_replay('replay.SC2Replay', load_level=4, do_tracker_events=False)

sc2parse output (not very helpful, cause tracker events):

dealing with 2013-10-30_acerbly(Z)_dtefel(Z)_whirlwind_[sc2-replays-net].SC2Replay

2013-10-30_acerbly(Z)_dtefel(Z)_whirlwind_[sc2-replays-net].SC2Replay
26825 - 1v1 on Whirlwind LE - Played 2013-10-30 18:52:36
[ERROR] Cannot run engine on resumed games with tracker events. Run again with the do_tracker_events=False option to generate context without tracker events.
16 {u'Lobby Delay': u'10', u'Game Mode': u'Private', u'Rules': u'Default', u'Premade Game': u'Yes', u'Teams': u'1v1', u'Locked Alliances': u'Yes', u'Game Privacy': u'No Build Order', u'Game Speed': u'Faster'}
1 {u'Participant Role': u'Participant', u'Using Custom Observer UI': u'Not Using Custom Observer UI', u'Handicap': u'100%', u'Teams4v4': u'Team 2', u'AI Build (Terran)': u'Any Build', u'Difficulty': u'Medium', u'Color': u'Red', u'Observer Type': u'Spectator', u'Teams2v2': u'Team 2', u'AI Build': u'Any Build', u'Teams1v1': u'Team 1', u'Teams3v3': u'Team 2', u'Controller': u'User', u'Race': u'Zerg', u'Teams6v6': u'Team 2', u'AI Build (Protoss)': u'Any Build', u'AI Build (Zerg)': u'Any Build', u'Team': u'Team 4', u'Teams7v7': u'Team 2', u'Teams5v5': u'Team 2', u'TeamsFFA': u'Team 4'}
2 {u'Participant Role': u'Participant', u'Using Custom Observer UI': u'Not Using Custom Observer UI', u'Handicap': u'100%', u'Teams4v4': u'Team 2', u'AI Build (Terran)': u'Any Build', u'Difficulty': u'Medium', u'Color': u'Green', u'Observer Type': u'Spectator', u'Teams2v2': u'Team 2', u'AI Build': u'Any Build', u'Teams1v1': u'Team 2', u'Teams3v3': u'Team 2', u'Controller': u'User', u'Race': u'Zerg', u'Teams6v6': u'Team 2', u'AI Build (Protoss)': u'Any Build', u'AI Build (Zerg)': u'Any Build', u'Team': u'Team 2', u'Teams7v7': u'Team 2', u'Teams5v5': u'Team 2', u'TeamsFFA': u'Team 2'}
Total failure parsing 2.0.11.26825
[ERROR] Cannot run engine on resumed games with tracker events. Run again with the do_tracker_events=False option to generate context without tracker events.
[ERROR] 'dict' object has no attribute 'players'
Traceback (most recent call last):
  File "build/bdist.macosx-10.9-intel/egg/sc2reader/scripts/sc2parse.py", line 83, in main
    for pid, info in enumerate(replay.raw_data['replay.details'].players):
AttributeError: 'dict' object has no attribute 'players'
GraylinKim commented 9 years ago

Okay, I resolved the various issues that were causing these exceptions. The root issue is now properly written to the log as follows:

Bad pid (13) for event <class 'sc2reader.events.game.CameraEvent'> at 14.07 [13555].

I expect that this is related to the fact that it is a resumed replay. We don't properly use the player "rejoin" events to construct our player listings. Instead we use the initial player details that are never updated on resumed replays. I suppose we could call this a needed enhancement.

GraylinKim commented 9 years ago

Closing this in favor of #91. This sort of enhancement falls under that general set of features.