Skip to content

Commit

Permalink
support ror
Browse files Browse the repository at this point in the history
  • Loading branch information
happyleavesaoc committed May 8, 2023
1 parent c51af6d commit f63acd0
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 7 deletions.
10 changes: 6 additions & 4 deletions mgz/fast/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,9 @@ def parse_de(data, version, save, skip=False):
if save >= 26.16 and not skip:
timestamp = unpack('<I', data) # missing on console (?)
data.read(12)
dlc_count = unpack('<I', data)
data.read(dlc_count * 4)
dlc_ids = []
for i in range(0, unpack('<I', data)):
dlc_ids.append(unpack('<I', data))
data.read(4)
difficulty_id = unpack('<I', data)
data.read(4)
Expand Down Expand Up @@ -428,7 +429,8 @@ def parse_de(data, version, save, skip=False):
visibility_id=visibility,
rms_mod_id=rms_mod_id,
rms_map_id=rms_map_id,
rms_filename=rms_filename
rms_filename=rms_filename,
dlc_ids=dlc_ids
)


Expand Down Expand Up @@ -566,7 +568,7 @@ def parse(data):
map=map_,
de=de,
hd=hd,
mod=mod,
mod=de.get('dlc_ids') if de else mod,
metadata=metadata,
scenario=scenario,
lobby=lobby
Expand Down
1 change: 1 addition & 0 deletions mgz/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ def parse_match(handle):
timedelta(milliseconds=timestamp + data['map']['restore_time']),
diplomacy_type,
bool(resigned),
dataset_id,
data['version'],
data['game_version'],
data['save_version'],
Expand Down
6 changes: 6 additions & 0 deletions mgz/model/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ def get_postgame(self):
return None

def get_dataset(self):
if self.match.dataset_id == 101:
return dict(
id=101,
name='Return of Rome',
version=None
)
return dict(
id=100,
name='Definitive Edition',
Expand Down
1 change: 1 addition & 0 deletions mgz/model/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class Match:
duration: timedelta
diplomacy_type: str
completed: bool
dataset_id: int
version: Version
game_version: str
save_version: float
Expand Down
5 changes: 4 additions & 1 deletion mgz/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
def get_dataset(version, mod):
"""Fetch dataset reference data."""
if version is Version.DE:
dataset_id = 100
if 11 in mod:
dataset_id = 101
else:
dataset_id = 100
elif version is Version.HD:
dataset_id = 300
elif mod:
Expand Down
8 changes: 8 additions & 0 deletions mgz/summary/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,18 @@ def get_dataset_data(header):
"""Get dataset."""
sample = header.initial.players[0].attributes.player_stats
mod = None
if header.de:
mod = header.de.dlc_ids
if 'mod' in sample:
mod = (sample.mod.get('id'), sample.mod.get('version'))
_, ref = get_dataset(header.version, mod)
if header.version == Version.DE:
if 11 in header.de.dlc_ids:
return {
'id': 101,
'name': 'Return of Rome',
'version': None
}, ref
return {
'id': 100,
'name': 'Definitive Edition',
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

setup(
name='mgz',
version='1.8.14',
version='1.8.16',
description='Parse Age of Empires 2 recorded games.',
url='https://github.com/happyleavesaoc/aoc-mgz/',
license='MIT',
author='happyleaves',
author_email='happyleaves.tfr@gmail.com',
packages=find_packages(),
install_requires=[
'aocref>=2.0.8',
'aocref>=2.0.10',
'construct==2.8.16',
'dataclasses==0.8; python_version < "3.7"',
'tabulate>=0.9.0',
Expand Down

0 comments on commit f63acd0

Please sign in to comment.