Skip to content

Commit

Permalink
Fixed version handling for big numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
jwlkns committed Sep 1, 2022
1 parent c17c2ad commit 5f12eb3
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ def patch(self, username: str, password: str, target_version: int):
print("Please enter a password")
return

self.installed_version = utils.get_version_number(self.game_dir / "AoE2DE_s.exe")[2]

if self.installed_version == target_version:
print("The selected version is already installed")
return
Expand Down Expand Up @@ -144,9 +142,10 @@ def set_game_dir(self, dir: pathlib.Path):

if aoe_binary.exists():
self.game_dir = dir
self.installed_version = self._get_game_version()

print(f"Game directory set to: {dir.absolute()}")
print(f"Installed version detected: {utils.get_version_number(aoe_binary)[2]}")
print(f"Installed version detected: {self.installed_version}")
return True

print("Invalid game directory")
Expand Down Expand Up @@ -483,6 +482,14 @@ def _get_filelist(self, username: str, password: str, depot_id: int, current_man
return changes

def _read_manifest(self, file: pathlib.Path):
"""Parse a given manifest file and return a manifest object
Args:
file (pathlib.Path): Path to the manifest file
Returns:
Manifest: The parsed manifest object
"""
result = None

with open(file, "r") as f:
Expand Down Expand Up @@ -537,4 +544,14 @@ def _read_manifest(self, file: pathlib.Path):

result = Manifest(depot, id, date, num_files, num_chunks, size_disk, size_compressed, files)

return result
return result

def _get_game_version(self):
"""Retrieve the game version from the executable file. Requires game directory to be set.
Returns:
int: The detected game version
"""
metadata = utils.get_version_number(self.game_dir / "AoE2DE_s.exe")

return (metadata[1] - 101) * 65536 + metadata[2]

0 comments on commit 5f12eb3

Please sign in to comment.