Skip to content

Commit 68557e3

Browse files
update to use 0.10 as base and fix violet's base 0 on hex values
1 parent 2dd1dca commit 68557e3

File tree

1 file changed

+20
-31
lines changed

1 file changed

+20
-31
lines changed

worlds/kh2/Client.py

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class KH2Context(CommonContext):
2525
def __init__(self, server_address, password):
2626
super(KH2Context, self).__init__(server_address, password)
2727

28-
2928
self.goofy_ability_to_slot = dict()
3029
self.donald_ability_to_slot = dict()
3130
self.all_weapon_location_id = None
@@ -88,7 +87,7 @@ def __init__(self, server_address, password):
8887
}
8988
self.kh2seedname = None
9089
self.kh2_seed_save_path_join = None
91-
90+
9291
self.kh2slotdata = None
9392
self.mem_json = None
9493
self.itemamount = {}
@@ -120,23 +119,13 @@ def __init__(self, server_address, password):
120119
# 255: {}, # starting screen
121120
}
122121
self.last_world_int = -1
123-
# 0x2A09C00+0x40 is the sve anchor. +1 is the last saved room
124-
# self.sveroom = 0x2A09C00 + 0x41
125-
# 0 not in battle 1 in yellow battle 2 red battle #short
126-
# self.inBattle = 0x2A0EAC4 + 0x40
127-
# self.onDeath = 0xAB9078
128122
# PC Address anchors
129-
# self.Now = 0x0714DB8 old address
130-
# epic addresses
123+
# epic .10 addresses
131124
self.Now = 0x0716DF8
132-
self.Save = 0x09A92F0
125+
self.Save = 0x9A9330
133126
self.Journal = 0x743260
134127
self.Shop = 0x743350
135-
self.Slot1 = 0x2A22FD8
136-
# self.Sys3 = 0x2A59DF0
137-
# self.Bt10 = 0x2A74880
138-
# self.BtlEnd = 0x2A0D3E0
139-
# self.Slot1 = 0x2A20C98 old address
128+
self.Slot1 = 0x2A23018
140129

141130
self.kh2_game_version = None # can be egs or steam
142131

@@ -269,7 +258,7 @@ def on_package(self, cmd: str, args: dict):
269258
},
270259
"SoldEquipment": [],
271260
}
272-
with open(self.kh2_seed_save_path_join,'wt') as f:
261+
with open(self.kh2_seed_save_path_join, 'wt') as f:
273262
pass
274263
# self.locations_checked = set()
275264
elif os.path.exists(self.kh2_seed_save_path_join):
@@ -362,8 +351,8 @@ def on_package(self, cmd: str, args: dict):
362351
if cmd == "DataPackage":
363352
if "Kingdom Hearts 2" in args["data"]["games"]:
364353
self.data_package_kh2_cache(
365-
args["data"]["games"]["Kingdom Hearts 2"]["location_name_to_id"],
366-
args["data"]["games"]["Kingdom Hearts 2"]["item_name_to_id"])
354+
args["data"]["games"]["Kingdom Hearts 2"]["location_name_to_id"],
355+
args["data"]["games"]["Kingdom Hearts 2"]["item_name_to_id"])
367356
self.connect_to_game()
368357
asyncio.create_task(self.send_msgs([{'cmd': 'Sync'}]))
369358

@@ -827,14 +816,15 @@ async def verifyItems(self):
827816
def get_addresses(self):
828817
if not self.kh2connected and self.kh2 is not None:
829818
if self.kh2_game_version is None:
830-
if self.kh2_read_string(0x09A9830, 4) == "KH2J":
819+
# current verions is .10 then runs the get from github stuff
820+
if self.kh2_read_string(0x9A98B0, 4) == "KH2J":
831821
self.kh2_game_version = "STEAM"
832822
self.Now = 0x0717008
833-
self.Save = 0x09A9830
834-
self.Slot1 = 0x2A23518
823+
self.Save = 0x09A98B0
824+
self.Slot1 = 0x2A23598
835825
self.Journal = 0x7434E0
836826
self.Shop = 0x7435D0
837-
elif self.kh2_read_string(0x09A92F0, 4) == "KH2J":
827+
elif self.kh2_read_string(0x9A9330, 4) == "KH2J":
838828
self.kh2_game_version = "EGS"
839829
else:
840830
if self.game_communication_path:
@@ -846,21 +836,20 @@ def get_addresses(self):
846836
mem_resp = requests.get("https://raw.githubusercontent.com/JaredWeakStrike/KH2APMemoryValues/master/kh2memaddresses.json")
847837
if mem_resp.status_code == 200:
848838
self.mem_json = json.loads(mem_resp.content)
849-
with open(kh2memaddresses_path,
850-
'w') as f:
839+
with open(kh2memaddresses_path, 'w') as f:
851840
f.write(json.dumps(self.mem_json, indent=4))
852841
else:
853-
with open(kh2memaddresses_path, 'r') as f:
842+
with open(kh2memaddresses_path) as f:
854843
self.mem_json = json.load(f)
855844
if self.mem_json:
856845
for key in self.mem_json.keys():
857846

858-
if self.kh2_read_string(int(self.mem_json[key]["GameVersionCheck"], 0), 4) == "KH2J":
859-
self.Now = int(self.mem_json[key]["Now"], 0)
860-
self.Save = int(self.mem_json[key]["Save"], 0)
861-
self.Slot1 = int(self.mem_json[key]["Slot1"], 0)
862-
self.Journal = int(self.mem_json[key]["Journal"], 0)
863-
self.Shop = int(self.mem_json[key]["Shop"], 0)
847+
if self.kh2_read_string(int(self.mem_json[key]["GameVersionCheck"], 16), 4) == "KH2J":
848+
self.Now = int(self.mem_json[key]["Now"], 16)
849+
self.Save = int(self.mem_json[key]["Save"], 16)
850+
self.Slot1 = int(self.mem_json[key]["Slot1"], 16)
851+
self.Journal = int(self.mem_json[key]["Journal"], 16)
852+
self.Shop = int(self.mem_json[key]["Shop"], 16)
864853
self.kh2_game_version = key
865854

866855
if self.kh2_game_version is not None:

0 commit comments

Comments
 (0)