Skip to content

Commit

Permalink
1 of 2 changes to support bot replays in ggtracker#149 (#1)
Browse files Browse the repository at this point in the history
* 1 of 2 changes to support bot replays in ggtracker#149

One of two fixes

This one corrects for the error we see here:

sc2reader/engine/plugins/context.py", line 66, in handleTargetUnitCommandEvent
    self.last_target_ability_event[event.player.pid] = event
AttributeError: 'NoneType' object has no attribute 'pid'

* Update sc2reader/engine/plugins/context.py

Co-authored-by: Christian Clauss <cclauss@me.com>

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
  • Loading branch information
craigdods and cclauss authored Jul 16, 2023
1 parent d693b08 commit e289f3a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sc2reader/engine/plugins/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ def handleCommandEvent(self, event, replay):
self.logger.error("Other unit {0} not found".format(event.other_unit_id))

def handleTargetUnitCommandEvent(self, event, replay):
self.last_target_ability_event[event.player.pid] = event
if event.player:
self.last_target_ability_event[event.player.pid] = event


if not replay.datapack:
return
Expand Down

3 comments on commit e289f3a

@histmeisah
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this bug still occur,even if i have used this change

Traceback (most recent call last):
File "E:\python_code\starcraft2_data_process\process_replay\process_replay\process_ai_replay\test_01.py", line 2, in
replay = sc2reader.load_replay('Altitude LE_20230903_161615_PROTOSS_VS_BUILD_IN_AI_MediumHard_Zerg_process_-5_checked.SC2Replay')
File "E:\python_code\sc2reader-upstream\sc2reader\factories\sc2factory.py", line 85, in load_replay
return self.load(Replay, source, options, **new_options)
File "E:\python_code\sc2reader-upstream\sc2reader\factories\sc2factory.py", line 163, in load
return self._load(cls, resource, filename=filename, options=options)
File "E:\python_code\sc2reader-upstream\sc2reader\factories\sc2factory.py", line 172, in _load
obj = cls(resource, filename=filename, factory=self, **options)
File "E:\python_code\sc2reader-upstream\sc2reader\resources.py", line 342, in init
engine.run(self)
File "E:\python_code\sc2reader-upstream\sc2reader\engine\engine.py", line 183, in run
for new_event in event_handler(event, replay) or []:
File "E:\python_code\sc2reader-upstream\sc2reader\engine\plugins\context.py", line 129, in handleUpdateTargetUnitCommandEvent
if event.player.pid in self.last_target_ability_event:
AttributeError: 'NoneType' object has no attribute 'pid'

@cclauss
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 66 and 129 are not the same line.

@histmeisah
Copy link

@histmeisah histmeisah commented on e289f3a Jan 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 66 and 129 are not the same line.

Thank you sir, I reinstall the sc2reader from pypi.
Now the new error occurs here:
Traceback (most recent call last):
File "E:\python_code\starcraft2_data_process\process_replay\process_replay\process_ai_replay\test_01.py", line 2, in
replay = sc2reader.load_replay('Altitude LE_20230903_161615_PROTOSS_VS_BUILD_IN_AI_MediumHard_Zerg_process_-5_checked.SC2Replay')
File "F:\ide\anaconda\envs\sc2env\lib\site-packages\sc2reader\factories\sc2factory.py", line 88, in load_replay
return self.load(Replay, source, options, **new_options)
File "F:\ide\anaconda\envs\sc2env\lib\site-packages\sc2reader\factories\sc2factory.py", line 166, in load
return self._load(cls, resource, filename=filename, options=options)
File "F:\ide\anaconda\envs\sc2env\lib\site-packages\sc2reader\factories\sc2factory.py", line 175, in _load
obj = cls(resource, filename=filename, factory=self, **options)
File "F:\ide\anaconda\envs\sc2env\lib\site-packages\sc2reader\resources.py", line 346, in init
engine.run(self)
File "F:\ide\anaconda\envs\sc2env\lib\site-packages\sc2reader\engine\engine.py", line 179, in run
for new_event in event_handler(event, replay) or []:
File "F:\ide\anaconda\envs\sc2env\lib\site-packages\sc2reader\engine\plugins\context.py", line 93, in handleUpdateTargetUnitCommandEvent
if event.player.pid in self.last_target_ability_event:
AttributeError: 'NoneType' object has no attribute 'pid'

Due to my replays generated by python-sc2 botai pacakge, I hope you can help me to solve these bugs.

here is replay :
replays.zip

Please sign in to comment.