Add support for initial d zero
This commit is contained in:
39
titles/idz/handlers/__init__.py
Normal file
39
titles/idz/handlers/__init__.py
Normal file
@@ -0,0 +1,39 @@
|
||||
from .base import IDZHandlerBase
|
||||
|
||||
from .load_server_info import IDZHandlerLoadServerInfo
|
||||
|
||||
from .load_ghost import IDZHandlerLoadGhost
|
||||
|
||||
from .load_config import IDZHandlerLoadConfigA, IDZHandlerLoadConfigB
|
||||
|
||||
from .load_top_ten import IDZHandlerLoadTopTen
|
||||
|
||||
from .update_story_clear_num import IDZHandlerUpdateStoryClearNum
|
||||
|
||||
from .save_expedition import IDZHandlerSaveExpedition
|
||||
|
||||
from .load_2on2 import IDZHandlerLoad2on2A, IDZHandlerLoad2on2B
|
||||
|
||||
from .load_team_ranking import IDZHandlerLoadTeamRankingA, IDZHandlerLoadTeamRankingB
|
||||
|
||||
from .discover_profile import IDZHandlerDiscoverProfile
|
||||
|
||||
from .lock_profile import IDZHandlerLockProfile
|
||||
|
||||
from .check_team_names import IDZHandlerCheckTeamName
|
||||
|
||||
from .unknown import IDZHandlerUnknown
|
||||
|
||||
from .create_profile import IDZHandlerCreateProfile
|
||||
|
||||
from .create_auto_team import IDZHandlerCreateAutoTeam
|
||||
|
||||
from .load_profile import IDZHandlerLoadProfile
|
||||
|
||||
from .save_profile import IDZHandlerSaveProfile
|
||||
|
||||
from .update_provisional_store_rank import IDZHandlerUpdateProvisionalStoreRank
|
||||
|
||||
from .load_reward_table import IDZHandlerLoadRewardTable
|
||||
|
||||
from .save_topic import IDZHandlerSaveTopic
|
||||
25
titles/idz/handlers/base.py
Normal file
25
titles/idz/handlers/base.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import logging
|
||||
import struct
|
||||
from core.data import Data
|
||||
from core.config import CoreConfig
|
||||
from ..config import IDZConfig
|
||||
from ..const import IDZConstants
|
||||
|
||||
class IDZHandlerBase():
|
||||
name = "generic"
|
||||
cmd_codes = [0x0000] * IDZConstants.NUM_VERS
|
||||
rsp_codes = [0x0001] * IDZConstants.NUM_VERS
|
||||
|
||||
def __init__(self, core_cfg: CoreConfig, game_cfg: IDZConfig, version: int) -> None:
|
||||
self.core_config = core_cfg
|
||||
self.game_cfg = game_cfg
|
||||
self.data = Data(core_cfg)
|
||||
self.logger = logging.getLogger("idz")
|
||||
self.game = IDZConstants.GAME_CODE
|
||||
self.version = version
|
||||
self.size = 0x30
|
||||
|
||||
def handle(self, data: bytes) -> bytearray:
|
||||
ret = bytearray([0] * self.size)
|
||||
struct.pack_into("<H", ret, 0x0, self.rsp_codes[self.version])
|
||||
return ret
|
||||
19
titles/idz/handlers/check_team_names.py
Normal file
19
titles/idz/handlers/check_team_names.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import struct
|
||||
|
||||
from .base import IDZHandlerBase
|
||||
from core.config import CoreConfig
|
||||
from ..config import IDZConfig
|
||||
|
||||
class IDZHandlerCheckTeamName(IDZHandlerBase):
|
||||
cmd_codes = [0x00a2, 0x00a2, 0x0097, 0x0097]
|
||||
rsp_codes = [0x00a3, 0x00a3, 0x0098, 0x0098]
|
||||
name = "check_team_name"
|
||||
|
||||
def __init__(self, core_cfg: CoreConfig, game_cfg: IDZConfig, version: int) -> None:
|
||||
super().__init__(core_cfg, game_cfg, version)
|
||||
self.size = 0x0010
|
||||
|
||||
def handle(self, data: bytes) -> bytearray:
|
||||
ret = super().handle(data)
|
||||
struct.pack_into("<I", ret, 0x4, 0x1)
|
||||
return data
|
||||
49
titles/idz/handlers/create_auto_team.py
Normal file
49
titles/idz/handlers/create_auto_team.py
Normal file
@@ -0,0 +1,49 @@
|
||||
from operator import indexOf
|
||||
import struct
|
||||
import json
|
||||
from random import choice, randrange
|
||||
|
||||
from .base import IDZHandlerBase
|
||||
from core.config import CoreConfig
|
||||
from ..config import IDZConfig
|
||||
|
||||
AUTO_TEAM_NAMES = ["スピードスターズ", "レッドサンズ", "ナイトキッズ"]
|
||||
FULL_WIDTH_NUMS = ["\uff10", "\uff11", "\uff12", "\uff13", "\uff14", "\uff15", "\uff16", "\uff17", "\uff18", "\uff19"]
|
||||
|
||||
class IDZHandlerCreateAutoTeam(IDZHandlerBase):
|
||||
cmd_codes = [0x007b, 0x007b, 0x0077, 0x0077]
|
||||
rsp_codes = [0x007c, 0x007c, 0x0078, 0x0078]
|
||||
name = "create_auto_team"
|
||||
|
||||
def __init__(self, core_cfg: CoreConfig, game_cfg: IDZConfig, version: int) -> None:
|
||||
super().__init__(core_cfg, game_cfg, version)
|
||||
self.size = 0x0ca0
|
||||
|
||||
def handle(self, data: bytes) -> bytearray:
|
||||
ret = super().handle(data)
|
||||
aime_id = struct.unpack_from("<I", data, 0x04)[0]
|
||||
name = choice(AUTO_TEAM_NAMES)
|
||||
bg = indexOf(AUTO_TEAM_NAMES, name)
|
||||
number = choice(FULL_WIDTH_NUMS) + choice(FULL_WIDTH_NUMS) + choice(FULL_WIDTH_NUMS)
|
||||
|
||||
tdata = {
|
||||
"id": aime_id,
|
||||
"bg": bg,
|
||||
"fx": 0,
|
||||
}
|
||||
|
||||
tdata = {
|
||||
"id": aime_id,
|
||||
"name": (name + number),
|
||||
"bg": bg,
|
||||
"fx": 0,
|
||||
}
|
||||
tname = tdata['name'].encode("shift-jis")
|
||||
|
||||
struct.pack_into("<I", ret, 0x0C, tdata["id"])
|
||||
struct.pack_into(f"{len(tname)}s", ret, 0x24, tname)
|
||||
struct.pack_into("<I", ret, 0x80, tdata["id"])
|
||||
struct.pack_into(f"<I", ret, 0xD8, tdata["bg"])
|
||||
struct.pack_into(f"<I", ret, 0xDC, tdata["fx"])
|
||||
|
||||
return ret
|
||||
91
titles/idz/handlers/create_profile.py
Normal file
91
titles/idz/handlers/create_profile.py
Normal file
@@ -0,0 +1,91 @@
|
||||
import json
|
||||
import struct
|
||||
from datetime import datetime
|
||||
|
||||
from .base import IDZHandlerBase
|
||||
from core.config import CoreConfig
|
||||
from ..config import IDZConfig
|
||||
|
||||
class IDZHandlerCreateProfile(IDZHandlerBase):
|
||||
cmd_codes = [0x0066, 0x0066, 0x0064, 0x0064]
|
||||
rsp_codes = [0x0067, 0x0065, 0x0065, 0x0065]
|
||||
name = "create_profile"
|
||||
|
||||
def __init__(self, core_cfg: CoreConfig, game_cfg: IDZConfig, version: int) -> None:
|
||||
super().__init__(core_cfg, game_cfg, version)
|
||||
self.size = 0x0020
|
||||
|
||||
def handle(self, data: bytes) -> bytearray:
|
||||
ret = super().handle(data)
|
||||
|
||||
aime_id = struct.unpack_from("<L", data, 0x04)[0]
|
||||
name = data[0x1E:0x0034].decode("shift-jis").replace("\x00", "")
|
||||
car = data[0x40:0xa0].hex()
|
||||
chara = data[0xa8:0xbc].hex()
|
||||
|
||||
self.logger.info(f"Create profile for {name} (aime id {aime_id})")
|
||||
|
||||
auto_team = None
|
||||
if not auto_team:
|
||||
team = {
|
||||
"bg": 0,
|
||||
"id": 0,
|
||||
"shop": ""
|
||||
}
|
||||
else:
|
||||
tdata = json.loads(auto_team["data"])
|
||||
|
||||
team = {
|
||||
"bg": tdata["bg"],
|
||||
"id": tdata["fx"],
|
||||
"shop": ""
|
||||
}
|
||||
|
||||
profile_data={
|
||||
"profile": {
|
||||
"xp": 0,
|
||||
"lv": 1,
|
||||
"fame": 0,
|
||||
"dpoint": 0,
|
||||
"milage": 0,
|
||||
"playstamps": 0,
|
||||
"last_login": int(datetime.now().timestamp()),
|
||||
"car_str": car, # These should probably be chaged to dicts
|
||||
"chara_str": chara, # But this works for now...
|
||||
},
|
||||
|
||||
"options": {
|
||||
"music": 0,
|
||||
"pack": 13640,
|
||||
"aura": 0,
|
||||
"paper_cup": 0,
|
||||
"gauges": 5,
|
||||
"driving_style": 0
|
||||
},
|
||||
|
||||
"missions": {
|
||||
"team": [],
|
||||
"solo": []
|
||||
},
|
||||
|
||||
"story": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"rows": {}
|
||||
},
|
||||
|
||||
"unlocks": {
|
||||
"auras": 1,
|
||||
"cup": 0,
|
||||
"gauges": 32,
|
||||
"music": 0,
|
||||
"last_mileage_reward": 0,
|
||||
},
|
||||
"team": team
|
||||
}
|
||||
|
||||
if self.version > 2:
|
||||
struct.pack_into("<L", ret, 0x04, aime_id)
|
||||
else:
|
||||
struct.pack_into("<L", ret, 0x08, aime_id)
|
||||
return ret
|
||||
0
titles/idz/handlers/create_team.py
Normal file
0
titles/idz/handlers/create_team.py
Normal file
23
titles/idz/handlers/discover_profile.py
Normal file
23
titles/idz/handlers/discover_profile.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import struct
|
||||
from typing import Tuple, List, Dict
|
||||
|
||||
from .base import IDZHandlerBase
|
||||
from core.config import CoreConfig
|
||||
from ..config import IDZConfig
|
||||
|
||||
class IDZHandlerDiscoverProfile(IDZHandlerBase):
|
||||
cmd_codes = [0x006b, 0x0067]
|
||||
rsp_codes = [0x006c, 0x0068, 0x0068,0x0068]
|
||||
name = "discover_profile"
|
||||
|
||||
def __init__(self, core_cfg: CoreConfig, game_cfg: IDZConfig, version: int) -> None:
|
||||
super().__init__(core_cfg, game_cfg, version)
|
||||
self.size = 0x0010
|
||||
|
||||
def handle(self, data: bytes) -> bytearray:
|
||||
ret = super().handle(data)
|
||||
user_id = struct.unpack_from("<I", data, 0x04)[0]
|
||||
profile = None
|
||||
|
||||
struct.pack_into("<H", ret, 0x04, int(profile is not None))
|
||||
return ret
|
||||
36
titles/idz/handlers/load_2on2.py
Normal file
36
titles/idz/handlers/load_2on2.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import struct
|
||||
|
||||
from .base import IDZHandlerBase
|
||||
from core.config import CoreConfig
|
||||
from ..config import IDZConfig
|
||||
from ..const import IDZConstants
|
||||
|
||||
class IDZHandlerLoad2on2A(IDZHandlerBase):
|
||||
cmd_codes = [0x00b0, 0x00b0, 0x00a3, 0x00a3]
|
||||
rsp_codes = [0x00b1, 0x00b1, 0x00a4, 0x00a4]
|
||||
name = "load_2on2A"
|
||||
|
||||
def __init__(self, core_cfg: CoreConfig, game_cfg: IDZConfig, version: int) -> None:
|
||||
super().__init__(core_cfg, game_cfg, version)
|
||||
self.size = 0x04c0
|
||||
|
||||
if version >= IDZConstants.VER_IDZ_210:
|
||||
self.size = 0x1290
|
||||
|
||||
def handle(self, data: bytes) -> bytearray:
|
||||
return super().handle(data)
|
||||
|
||||
class IDZHandlerLoad2on2B(IDZHandlerBase):
|
||||
cmd_codes = [0x0132] * 4
|
||||
rsp_codes = [0x0133] * 4
|
||||
name = "load_2on2B"
|
||||
|
||||
def __init__(self, core_cfg: CoreConfig, game_cfg: IDZConfig, version: int) -> None:
|
||||
super().__init__(core_cfg, game_cfg, version)
|
||||
self.size = 0x04c0
|
||||
|
||||
if version >= IDZConstants.VER_IDZ_210:
|
||||
self.size = 0x0540
|
||||
|
||||
def handle(self, data: bytes) -> bytearray:
|
||||
return super().handle(data)
|
||||
41
titles/idz/handlers/load_config.py
Normal file
41
titles/idz/handlers/load_config.py
Normal file
@@ -0,0 +1,41 @@
|
||||
import struct
|
||||
|
||||
from .base import IDZHandlerBase
|
||||
from core.config import CoreConfig
|
||||
from ..config import IDZConfig
|
||||
from ..const import IDZConstants
|
||||
|
||||
class IDZHandlerLoadConfigA(IDZHandlerBase):
|
||||
cmd_codes = [0x0004] * IDZConstants.NUM_VERS
|
||||
rsp_codes = [0x0005] * IDZConstants.NUM_VERS
|
||||
name = "load_config_a"
|
||||
|
||||
def __init__(self, core_cfg: CoreConfig, game_cfg: IDZConfig, version: int) -> None:
|
||||
super().__init__(core_cfg, game_cfg, version)
|
||||
self.size = 0x01a0
|
||||
|
||||
if self.version > 1:
|
||||
self.size = 0x05e0
|
||||
|
||||
def handle(self, data: bytes) -> bytearray:
|
||||
ret = super().handle(data)
|
||||
struct.pack_into("<H", ret, 0x02, 1)
|
||||
struct.pack_into("<I", ret, 0x16, 230)
|
||||
return ret
|
||||
|
||||
class IDZHandlerLoadConfigB(IDZHandlerBase):
|
||||
cmd_codes = [0x00a0] * IDZConstants.NUM_VERS
|
||||
rsp_codes = [0x00ac, 0x00ac, 0x00a1, 0x00a1]
|
||||
name = "load_config_b"
|
||||
|
||||
def __init__(self, core_cfg: CoreConfig, game_cfg: IDZConfig, version: int) -> None:
|
||||
super().__init__(core_cfg, game_cfg, version)
|
||||
self.size = 0x0230
|
||||
|
||||
if self.version > 1:
|
||||
self.size = 0x0240
|
||||
|
||||
def handle(self, data: bytes) -> bytearray:
|
||||
ret = super().handle(data)
|
||||
struct.pack_into("<H", ret, 0x02, 1)
|
||||
return ret
|
||||
39
titles/idz/handlers/load_ghost.py
Normal file
39
titles/idz/handlers/load_ghost.py
Normal file
@@ -0,0 +1,39 @@
|
||||
import struct
|
||||
|
||||
from .base import IDZHandlerBase
|
||||
from core.config import CoreConfig
|
||||
from ..config import IDZConfig
|
||||
|
||||
class IDZHandlerLoadGhost(IDZHandlerBase):
|
||||
cmd_codes = [0x00a0, 0x00a0, 0x0095, 0x0095]
|
||||
rsp_codes = [0x00a1, 0x00a1, 0x0096, 0x0096]
|
||||
name = "load_ghost"
|
||||
|
||||
def __init__(self, core_cfg: CoreConfig, game_cfg: IDZConfig, version: int) -> None:
|
||||
super().__init__(core_cfg, game_cfg, version)
|
||||
self.size = 0x0070
|
||||
|
||||
def handle(self, data: bytes) -> bytearray:
|
||||
ret = super().handle(data)
|
||||
struct.pack_into("<I", ret, 0x02, 0x5)
|
||||
|
||||
struct.pack_into("<L", ret, 0x04, 0x0)
|
||||
struct.pack_into("<l", ret, 0x08, -1)
|
||||
struct.pack_into("<L", ret, 0x0C, 0x1D4C0)
|
||||
struct.pack_into("<L", ret, 0x10, 0x1D4C0)
|
||||
struct.pack_into("<L", ret, 0x14, 0x1D4C0)
|
||||
|
||||
struct.pack_into("<L", ret, 0x38, 0x0)
|
||||
struct.pack_into("<l", ret, 0x3C, -1)
|
||||
struct.pack_into("<L", ret, 0x40, 0x1D4C0)
|
||||
struct.pack_into("<L", ret, 0x44, 0x1D4C0)
|
||||
struct.pack_into("<L", ret, 0x48, 0x1D4C0)
|
||||
|
||||
struct.pack_into("<L", ret, 0x4C, 0x1D4C0)
|
||||
struct.pack_into("<i", ret, 0x50, -1)
|
||||
struct.pack_into("<H", ret, 0x52, 0)
|
||||
struct.pack_into("<H", ret, 0x53, 0)
|
||||
struct.pack_into("<H", ret, 0x54, 0)
|
||||
struct.pack_into("<H", ret, 0x55, 0)
|
||||
struct.pack_into("<H", ret, 0x58, 0)
|
||||
return ret
|
||||
28
titles/idz/handlers/load_profile.py
Normal file
28
titles/idz/handlers/load_profile.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import struct
|
||||
|
||||
from .base import IDZHandlerBase
|
||||
from core.config import CoreConfig
|
||||
from ..config import IDZConfig
|
||||
from ..const import IDZConstants
|
||||
|
||||
class IDZHandlerLoadProfile(IDZHandlerBase):
|
||||
cmd_codes = [0x0067, 0x012f, 0x012f, 0x0142]
|
||||
rsp_codes = [0x0065, 0x012e, 0x012e, 0x0141]
|
||||
name = "load_profile"
|
||||
|
||||
def __init__(self, core_cfg: CoreConfig, game_cfg: IDZConfig, version: int) -> None:
|
||||
super().__init__(core_cfg, game_cfg, version)
|
||||
|
||||
if self.version == IDZConstants.VER_IDZ_110:
|
||||
self.size = 0x0d30
|
||||
elif self.version == IDZConstants.VER_IDZ_130:
|
||||
self.size = 0x0ea0
|
||||
elif self.version == IDZConstants.VER_IDZ_210:
|
||||
self.size = 0x1360
|
||||
elif self.version == IDZConstants.VER_IDZ_230:
|
||||
self.size = 0x1640
|
||||
|
||||
def handle(self, data: bytes) -> bytearray:
|
||||
ret = super().handle(data)
|
||||
aime_id = struct.unpack_from("<L", data, 0x04)[0]
|
||||
return ret
|
||||
17
titles/idz/handlers/load_reward_table.py
Normal file
17
titles/idz/handlers/load_reward_table.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import struct
|
||||
|
||||
from .base import IDZHandlerBase
|
||||
from core.config import CoreConfig
|
||||
from ..config import IDZConfig
|
||||
|
||||
class IDZHandlerLoadRewardTable(IDZHandlerBase):
|
||||
cmd_codes = [0x0086, 0x0086, 0x007F, 0x007F]
|
||||
rsp_codes = [0x0087, 0x0087, 0x0080, 0x0080]
|
||||
name = "load_reward_table"
|
||||
|
||||
def __init__(self, core_cfg: CoreConfig, game_cfg: IDZConfig, version: int) -> None:
|
||||
super().__init__(core_cfg, game_cfg, version)
|
||||
self.size = 0x01c0
|
||||
|
||||
def handle(self, data: bytes) -> bytearray:
|
||||
return super().handle(data)
|
||||
60
titles/idz/handlers/load_server_info.py
Normal file
60
titles/idz/handlers/load_server_info.py
Normal file
@@ -0,0 +1,60 @@
|
||||
import struct
|
||||
|
||||
from .base import IDZHandlerBase
|
||||
from core.config import CoreConfig
|
||||
from ..config import IDZConfig
|
||||
from ..const import IDZConstants
|
||||
|
||||
class IDZHandlerLoadServerInfo(IDZHandlerBase):
|
||||
cmd_codes = [0x0006] * IDZConstants.NUM_VERS
|
||||
rsp_codes = [0x0007] * IDZConstants.NUM_VERS
|
||||
name = "load_server_info1"
|
||||
|
||||
def __init__(self, core_cfg: CoreConfig, game_cfg: IDZConfig, version: int) -> None:
|
||||
super().__init__(core_cfg, game_cfg, version)
|
||||
self.size = 0x04b0
|
||||
|
||||
def handle(self, data: bytes) -> bytearray:
|
||||
ret = super().handle(data)
|
||||
offset = 0
|
||||
if self.version >= IDZConstants.VER_IDZ_210:
|
||||
offset = 2
|
||||
|
||||
news_str = f"http://{self.core_config.title.hostname}:{self.core_config.title.port}/SDDF/230/news/news80**.txt"
|
||||
err_str = f"http://{self.core_config.title.hostname}:{self.core_config.title.port}/SDDF/230/error"
|
||||
|
||||
len_hostname = len(self.core_config.title.hostname)
|
||||
len_news = len(news_str)
|
||||
len_error = len(err_str)
|
||||
|
||||
struct.pack_into("<I", ret, 0x2 + offset, 1) # Status
|
||||
struct.pack_into(f"{len_hostname}s", ret, 0x4 + offset, self.core_config.title.hostname.encode())
|
||||
struct.pack_into("<I", ret, 0x84 + offset, self.game_cfg.ports.userdb)
|
||||
struct.pack_into("<I", ret, 0x86 + offset, self.game_cfg.ports.userdb + 1)
|
||||
|
||||
struct.pack_into(f"{len_hostname}s", ret, 0x88 + offset, self.core_config.title.hostname.encode())
|
||||
struct.pack_into("<I", ret, 0x108 + offset, self.game_cfg.ports.match - 1)
|
||||
struct.pack_into("<I", ret, 0x10a + offset, self.game_cfg.ports.match - 3)
|
||||
struct.pack_into("<I", ret, 0x10c + offset, self.game_cfg.ports.match - 2)
|
||||
|
||||
struct.pack_into("<I", ret, 0x10e + offset, self.game_cfg.ports.match + 2)
|
||||
struct.pack_into("<I", ret, 0x110 + offset, self.game_cfg.ports.match + 3)
|
||||
struct.pack_into("<I", ret, 0x112 + offset, self.game_cfg.ports.match + 1)
|
||||
|
||||
struct.pack_into(f"{len_hostname}s", ret, 0x114 + offset, self.core_config.title.hostname.encode())
|
||||
struct.pack_into("<I", ret, 0x194 + offset, self.game_cfg.ports.echo + 2)
|
||||
|
||||
struct.pack_into(f"{len_hostname}s", ret, 0x0199 + offset, self.core_config.title.hostname.encode())
|
||||
struct.pack_into("<I", ret, 0x0219 + offset, self.game_cfg.ports.echo + 3)
|
||||
|
||||
struct.pack_into(f"{len_hostname}s", ret, 0x021c + offset, self.core_config.title.hostname.encode())
|
||||
struct.pack_into(f"{len_hostname}s", ret, 0x029c + offset, self.core_config.title.hostname.encode())
|
||||
struct.pack_into(f"{len_hostname}s", ret, 0x031c + offset, self.core_config.title.hostname.encode())
|
||||
|
||||
struct.pack_into("<I", ret, 0x39c + offset, self.game_cfg.ports.echo)
|
||||
struct.pack_into("<I", ret, 0x39e + offset, self.game_cfg.ports.echo + 1)
|
||||
|
||||
struct.pack_into(f"{len_news}s", ret, 0x03a0 + offset, news_str.encode())
|
||||
struct.pack_into(f"{len_error}s", ret, 0x0424 + offset, err_str.encode())
|
||||
|
||||
return ret
|
||||
29
titles/idz/handlers/load_team_ranking.py
Normal file
29
titles/idz/handlers/load_team_ranking.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import struct
|
||||
|
||||
from .base import IDZHandlerBase
|
||||
from core.config import CoreConfig
|
||||
from ..config import IDZConfig
|
||||
|
||||
class IDZHandlerLoadTeamRankingA(IDZHandlerBase):
|
||||
cmd_codes = [0x00b9, 0x00b9, 0x00a7, 0x00a7]
|
||||
rsp_codes = [0x00b1] * 4
|
||||
name = "load_team_ranking_a"
|
||||
|
||||
def __init__(self, core_cfg: CoreConfig, game_cfg: IDZConfig, version: int) -> None:
|
||||
super().__init__(core_cfg, game_cfg, version)
|
||||
self.size = 0x0ba0
|
||||
|
||||
def handle(self, data: bytes) -> bytearray:
|
||||
return super().handle(data)
|
||||
|
||||
class IDZHandlerLoadTeamRankingB(IDZHandlerBase):
|
||||
cmd_codes = [0x00bb, 0x00bb, 0x00a9, 0x00a9]
|
||||
rsp_codes = [0x00a8] * 4
|
||||
name = "load_team_ranking_b"
|
||||
|
||||
def __init__(self, core_cfg: CoreConfig, game_cfg: IDZConfig, version: int) -> None:
|
||||
super().__init__(core_cfg, game_cfg, version)
|
||||
self.size = 0x0ba0
|
||||
|
||||
def handle(self, data: bytes) -> bytearray:
|
||||
return super().handle(data)
|
||||
30
titles/idz/handlers/load_top_ten.py
Normal file
30
titles/idz/handlers/load_top_ten.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import struct
|
||||
from typing import Tuple, List, Dict
|
||||
|
||||
from .base import IDZHandlerBase
|
||||
from core.config import CoreConfig
|
||||
from ..config import IDZConfig
|
||||
|
||||
class IDZHandlerLoadTopTen(IDZHandlerBase):
|
||||
cmd_codes = [0x012c] * 4
|
||||
rsp_codes = [0x00ce] * 4
|
||||
name = "load_top_ten"
|
||||
|
||||
def __init__(self, core_cfg: CoreConfig, game_cfg: IDZConfig, version: int) -> None:
|
||||
super().__init__(core_cfg, game_cfg, version)
|
||||
self.size = 0x1720
|
||||
|
||||
def handle(self, data: bytes) -> bytearray:
|
||||
ret = super().handle(data)
|
||||
tracks_dates: List[Tuple[int, int]] = []
|
||||
for i in range(32):
|
||||
tracks_dates.append(
|
||||
(struct.unpack_from("<H", data, 0x04 + (2 * i))[0], "little",
|
||||
struct.unpack_from("<I", data, 0x44 + (4 * i))[0], "little")
|
||||
)
|
||||
# TODO: Best scores
|
||||
for i in range (3):
|
||||
offset = 0x16c0 + 0x1c * i
|
||||
struct.pack_into("<B", ret, offset + 0x02, 0xff)
|
||||
|
||||
return ret
|
||||
39
titles/idz/handlers/lock_profile.py
Normal file
39
titles/idz/handlers/lock_profile.py
Normal file
@@ -0,0 +1,39 @@
|
||||
import struct
|
||||
from typing import Dict
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from .base import IDZHandlerBase
|
||||
from core.config import CoreConfig
|
||||
from ..config import IDZConfig
|
||||
from ..const import IDZConstants
|
||||
|
||||
class IDZHandlerLockProfile(IDZHandlerBase):
|
||||
cmd_codes = [0x0069, 0x0069, 0x0065, 0x0065]
|
||||
rsp_codes = [0x006a, 0x006a, 0x0066, 0x0066]
|
||||
name = "lock_profile"
|
||||
|
||||
def __init__(self, core_cfg: CoreConfig, game_cfg: IDZConfig, version: int) -> None:
|
||||
super().__init__(core_cfg, game_cfg, version)
|
||||
self.size = 0x0020
|
||||
|
||||
def handle(self, data: bytes) -> bytearray:
|
||||
ret = super().handle(data)
|
||||
profile_data = {
|
||||
"status": IDZConstants.PROFILE_STATUS.UNLOCKED.value,
|
||||
"expire_time": int((datetime.now() + timedelta(hours=1)).timestamp() / 1000)
|
||||
}
|
||||
user_id = struct.unpack_from("<I", data, 0x04)[0]
|
||||
profile = None
|
||||
|
||||
if profile is None and self.version > 0:
|
||||
old_profile = None
|
||||
if old_profile is not None:
|
||||
profile_data["status"] = IDZConstants.PROFILE_STATUS.OLD.value
|
||||
|
||||
return self.handle_common(profile_data, ret)
|
||||
|
||||
def handle_common(cls, data: Dict, ret: bytearray) -> bytearray:
|
||||
struct.pack_into("<B", ret, 0x18, data["status"])
|
||||
struct.pack_into("<h", ret, 0x1a, -1)
|
||||
struct.pack_into("<I", ret, 0x1c, data["expire_time"])
|
||||
return ret
|
||||
14
titles/idz/handlers/save_expedition.py
Normal file
14
titles/idz/handlers/save_expedition.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from .base import IDZHandlerBase
|
||||
from core.config import CoreConfig
|
||||
from ..config import IDZConfig
|
||||
from ..const import IDZConstants
|
||||
|
||||
class IDZHandlerSaveExpedition(IDZHandlerBase):
|
||||
cmd_codes = [0x008c, 0x013f]
|
||||
name = "save_expedition"
|
||||
|
||||
def __init__(self, core_cfg: CoreConfig, game_cfg: IDZConfig, version: int) -> None:
|
||||
super().__init__(core_cfg, game_cfg, version)
|
||||
|
||||
def handle(self, data: bytes) -> bytearray:
|
||||
return super().handle(data)
|
||||
15
titles/idz/handlers/save_profile.py
Normal file
15
titles/idz/handlers/save_profile.py
Normal file
@@ -0,0 +1,15 @@
|
||||
import struct
|
||||
|
||||
from .base import IDZHandlerBase
|
||||
from core.config import CoreConfig
|
||||
from ..config import IDZConfig
|
||||
|
||||
class IDZHandlerSaveProfile(IDZHandlerBase):
|
||||
cmd_codes = [0x0068, 0x0138, 0x0138, 0x0143]
|
||||
name = "save_profile"
|
||||
|
||||
def __init__(self, core_cfg: CoreConfig, game_cfg: IDZConfig, version: int) -> None:
|
||||
super().__init__(core_cfg, game_cfg, version)
|
||||
|
||||
def handle(self, data: bytes) -> bytearray:
|
||||
return super().handle(data)
|
||||
17
titles/idz/handlers/save_topic.py
Normal file
17
titles/idz/handlers/save_topic.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import struct
|
||||
|
||||
from .base import IDZHandlerBase
|
||||
from core.config import CoreConfig
|
||||
from ..config import IDZConfig
|
||||
|
||||
class IDZHandlerSaveTopic(IDZHandlerBase):
|
||||
cmd_codes = [0x009A, 0x009A, 0x0091, 0x0091]
|
||||
rsp_codes = [0x009B, 0x009B, 0x0092, 0x0092]
|
||||
name = "save_topic"
|
||||
|
||||
def __init__(self, core_cfg: CoreConfig, game_cfg: IDZConfig, version: int) -> None:
|
||||
super().__init__(core_cfg, game_cfg, version)
|
||||
self.size = 0x05d0
|
||||
|
||||
def handle(self, data: bytes) -> bytearray:
|
||||
return super().handle(data)
|
||||
12
titles/idz/handlers/unknown.py
Normal file
12
titles/idz/handlers/unknown.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import struct
|
||||
|
||||
from .base import IDZHandlerBase
|
||||
from core.config import CoreConfig
|
||||
from ..config import IDZConfig
|
||||
|
||||
class IDZHandlerUnknown(IDZHandlerBase):
|
||||
cmd_codes = [0x00ad, 0x00ad, 0x00a2, 0x00a2]
|
||||
name = "unknown"
|
||||
|
||||
def __init__(self, core_cfg: CoreConfig, game_cfg: IDZConfig, version: int) -> None:
|
||||
super().__init__(core_cfg, game_cfg, version)
|
||||
20
titles/idz/handlers/update_provisional_store_rank.py
Normal file
20
titles/idz/handlers/update_provisional_store_rank.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import struct
|
||||
|
||||
from .base import IDZHandlerBase
|
||||
from core.config import CoreConfig
|
||||
from ..config import IDZConfig
|
||||
|
||||
class IDZHandlerUpdateProvisionalStoreRank(IDZHandlerBase):
|
||||
cmd_codes = [0x0082, 0x0082, 0x007C, 0x007C]
|
||||
rsp_codes = [0x0083, 0x0083, 0x007D, 0x007D]
|
||||
name = "update_provisional_store_ranking"
|
||||
|
||||
def __init__(self, core_cfg: CoreConfig, game_cfg: IDZConfig, version: int) -> None:
|
||||
super().__init__(core_cfg, game_cfg, version)
|
||||
self.size = 0x02b0
|
||||
|
||||
def handle(self, data: bytes) -> bytearray:
|
||||
return super().handle(data)
|
||||
|
||||
def handle_common(cls, aime_id: int, ret: bytearray) -> bytearray:
|
||||
pass
|
||||
26
titles/idz/handlers/update_story_clear_num.py
Normal file
26
titles/idz/handlers/update_story_clear_num.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import struct
|
||||
|
||||
from .base import IDZHandlerBase
|
||||
from core.config import CoreConfig
|
||||
from ..config import IDZConfig
|
||||
from ..const import IDZConstants
|
||||
|
||||
class IDZHandlerUpdateStoryClearNum(IDZHandlerBase):
|
||||
cmd_codes = [0x007f, 0x097f, 0x013d, 0x0144]
|
||||
rsp_codes = [0x0080, 0x013e, 0x013e, 0x0145]
|
||||
name = "update_story_clear_num"
|
||||
|
||||
def __init__(self, core_cfg: CoreConfig, game_cfg: IDZConfig, version: int) -> None:
|
||||
super().__init__(core_cfg, game_cfg, version)
|
||||
|
||||
if self.version == IDZConstants.VER_IDZ_110:
|
||||
self.size = 0x0220
|
||||
elif self.version == IDZConstants.VER_IDZ_130:
|
||||
self.size = 0x04f0
|
||||
elif self.version == IDZConstants.VER_IDZ_210:
|
||||
self.size = 0x0510
|
||||
elif self.version == IDZConstants.VER_IDZ_230:
|
||||
self.size = 0x0800
|
||||
|
||||
def handle(self, data: bytes) -> bytearray:
|
||||
return super().handle(data)
|
||||
Reference in New Issue
Block a user