Compare commits
No commits in common. "f8887a4bafc3ae1f8d97a001eba1e8c0ed6e594c" and "7277d784720a92dca0150dc3820d2b3ffa1695e1" have entirely different histories.
f8887a4baf
...
7277d78472
@ -10,12 +10,14 @@ class GameABC(ABC):
|
|||||||
def __init__(self, path: PathLike = None):
|
def __init__(self, path: PathLike = None):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
def is_installed(self) -> bool:
|
def is_installed(self) -> bool:
|
||||||
"""
|
"""
|
||||||
Check if the game is installed
|
Check if the game is installed
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
def install_game(self, game_path: PathLike = None):
|
def install_game(self, game_path: PathLike = None):
|
||||||
"""
|
"""
|
||||||
Install the game
|
Install the game
|
||||||
@ -31,6 +33,7 @@ class GameABC(ABC):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
def install_game_from_archive(
|
def install_game_from_archive(
|
||||||
self, archive: PathLike, game_path: PathLike = None
|
self, archive: PathLike, game_path: PathLike = None
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -45,6 +48,7 @@ class GameABC(ABC):
|
|||||||
game_path (PathLike, optional): Path to install the game to.
|
game_path (PathLike, optional): Path to install the game to.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
def install_update_from_archive(
|
def install_update_from_archive(
|
||||||
self, archive: PathLike, game_path: PathLike = None
|
self, archive: PathLike, game_path: PathLike = None
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -57,6 +61,7 @@ class GameABC(ABC):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
def get_version(self) -> tuple[int, int, int]:
|
def get_version(self) -> tuple[int, int, int]:
|
||||||
"""
|
"""
|
||||||
Get the game version
|
Get the game version
|
||||||
@ -65,18 +70,21 @@ class GameABC(ABC):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
def get_update(self):
|
def get_update(self):
|
||||||
"""
|
"""
|
||||||
Get the game update
|
Get the game update
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
def get_voiceover_update(self, language: str):
|
def get_voiceover_update(self, language: str):
|
||||||
"""
|
"""
|
||||||
Get the voiceover update
|
Get the voiceover update
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
def get_channel(self):
|
def get_channel(self):
|
||||||
"""
|
"""
|
||||||
Get the game channel
|
Get the game channel
|
||||||
|
@ -19,9 +19,6 @@ class Game(GameABC):
|
|||||||
def path(self) -> Path | None:
|
def path(self) -> Path | None:
|
||||||
return self._path
|
return self._path
|
||||||
|
|
||||||
def data_folder(self) -> Path:
|
|
||||||
return self._path.joinpath("StarRail_Data")
|
|
||||||
|
|
||||||
def is_installed(self) -> bool:
|
def is_installed(self) -> bool:
|
||||||
if self._path is None:
|
if self._path is None:
|
||||||
return False
|
return False
|
||||||
@ -31,49 +28,6 @@ class Game(GameABC):
|
|||||||
):
|
):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_version(self) -> tuple[int, int, int]:
|
|
||||||
"""
|
|
||||||
Get the current installed game version.
|
|
||||||
|
|
||||||
Credits to An Anime Team for the code that does the magic:
|
|
||||||
https://github.com/an-anime-team/anime-game-core/blob/main/src/games/star_rail/game.rs#L49
|
|
||||||
"""
|
|
||||||
allowed = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57]
|
|
||||||
version_bytes: list[bytes] = [0, 0, 0]
|
|
||||||
version_ptr = 0
|
|
||||||
correct = True
|
|
||||||
with self.data_folder().joinpath("data.unity3d").open("rb") as f:
|
|
||||||
f.seek(0x7D0) # 2000 in decimal
|
|
||||||
for byte in f.read(10000):
|
|
||||||
match byte:
|
|
||||||
case 0:
|
|
||||||
version_bytes = [0, 0, 0]
|
|
||||||
version_ptr = 0
|
|
||||||
correct = True
|
|
||||||
case 46:
|
|
||||||
version_ptr += 1
|
|
||||||
if version_ptr > 2:
|
|
||||||
correct = False
|
|
||||||
case 38:
|
|
||||||
if (
|
|
||||||
correct
|
|
||||||
and version_bytes[0] > 0
|
|
||||||
and version_bytes[1] > 0
|
|
||||||
and version_bytes[2] > 0
|
|
||||||
):
|
|
||||||
# TODO: The below code is not correct.
|
|
||||||
return (
|
|
||||||
int(version_bytes[0]),
|
|
||||||
int(version_bytes[1]),
|
|
||||||
int(version_bytes[2]),
|
|
||||||
)
|
|
||||||
case _:
|
|
||||||
if correct and byte in allowed:
|
|
||||||
version_bytes[version_ptr] += byte
|
|
||||||
else:
|
|
||||||
correct = False
|
|
||||||
return (0, 0, 0)
|
|
||||||
|
|
||||||
def get_channel(self) -> GameChannel:
|
def get_channel(self) -> GameChannel:
|
||||||
if self.get_version() == (1, 0, 5):
|
if self.get_version() == (1, 0, 5):
|
||||||
for channel, v in md5sums["1.0.5"].values():
|
for channel, v in md5sums["1.0.5"].values():
|
||||||
@ -88,5 +42,3 @@ class Game(GameABC):
|
|||||||
return GameChannel.China
|
return GameChannel.China
|
||||||
case "os":
|
case "os":
|
||||||
return GameChannel.Overseas
|
return GameChannel.Overseas
|
||||||
else:
|
|
||||||
return
|
|
||||||
|
Loading…
Reference in New Issue
Block a user