KH2: Async fix and linter cleanup (#1796)

This commit is contained in:
JaredWeakStrike 2023-05-06 22:49:37 -04:00 committed by GitHub
parent c8ebad1dfe
commit a8b76b1310
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 8 deletions

View File

@ -134,10 +134,10 @@ class KH2Context(CommonContext):
self.AbilityQuantityDict = {item: self.item_name_to_data[item].quantity for item in self.all_abilities} self.AbilityQuantityDict = {item: self.item_name_to_data[item].quantity for item in self.all_abilities}
# Growth:[level 1,level 4,slot] # Growth:[level 1,level 4,slot]
self.growth_values_dict = {"High Jump": [0x05E, 0x061, 0x25DA], self.growth_values_dict = {"High Jump": [0x05E, 0x061, 0x25DA],
"Quick Run": [0x62, 0x65, 0x25DC], "Quick Run": [0x62, 0x65, 0x25DC],
"Dodge Roll": [0x234, 0x237, 0x25DE], "Dodge Roll": [0x234, 0x237, 0x25DE],
"Aerial Dodge": [0x066, 0x069, 0x25E0], "Aerial Dodge": [0x066, 0x069, 0x25E0],
"Glide": [0x6A, 0x6D, 0x25E2]} "Glide": [0x6A, 0x6D, 0x25E2]}
self.boost_to_anchor_dict = { self.boost_to_anchor_dict = {
"Power Boost": 0x24F9, "Power Boost": 0x24F9,
"Magic Boost": 0x24FA, "Magic Boost": 0x24FA,
@ -271,6 +271,21 @@ class KH2Context(CommonContext):
if cmd in {"ReceivedItems"}: if cmd in {"ReceivedItems"}:
start_index = args["index"] start_index = args["index"]
if start_index == 0:
self.kh2seedsave["itemIndex"] = - 1
self.kh2seedsave["AmountInvo"]["ServerItems"] = {
"Ability": {},
"Amount": {},
"Growth": {"High Jump": 0, "Quick Run": 0, "Dodge Roll": 0,
"Aerial Dodge": 0,
"Glide": 0},
"Bitmask": [],
"Weapon": {"Sora": [], "Donald": [], "Goofy": []},
"Equipment": [],
"Magic": {},
"StatIncrease": {},
"Boost": {},
}
if start_index > self.kh2seedsave["itemIndex"]: if start_index > self.kh2seedsave["itemIndex"]:
self.kh2seedsave["itemIndex"] = start_index self.kh2seedsave["itemIndex"] = start_index
for item in args['items']: for item in args['items']:
@ -295,7 +310,6 @@ class KH2Context(CommonContext):
and (int.from_bytes( and (int.from_bytes(
self.kh2.read_bytes(self.kh2.base_address + self.Save + data.addrObtained, 1), self.kh2.read_bytes(self.kh2.base_address + self.Save + data.addrObtained, 1),
"big") & 0x1 << data.bitIndex) > 0: "big") & 0x1 << data.bitIndex) > 0:
self.sending = self.sending + [(int(locationId))] self.sending = self.sending + [(int(locationId))]
except Exception as e: except Exception as e:
logger.info("Line 285") logger.info("Line 285")
@ -342,7 +356,6 @@ class KH2Context(CommonContext):
if locationId not in self.locations_checked: if locationId not in self.locations_checked:
if int.from_bytes(self.kh2.read_bytes(self.kh2.base_address + self.Save + data.addrObtained, 1), if int.from_bytes(self.kh2.read_bytes(self.kh2.base_address + self.Save + data.addrObtained, 1),
"big") > 0: "big") > 0:
self.sending = self.sending + [(int(locationId))] self.sending = self.sending + [(int(locationId))]
for location, data in formSlots.items(): for location, data in formSlots.items():
@ -350,7 +363,7 @@ class KH2Context(CommonContext):
if locationId not in self.locations_checked: if locationId not in self.locations_checked:
if int.from_bytes(self.kh2.read_bytes(self.kh2.base_address + self.Save + data.addrObtained, 1), if int.from_bytes(self.kh2.read_bytes(self.kh2.base_address + self.Save + data.addrObtained, 1),
"big") & 0x1 << data.bitIndex > 0: "big") & 0x1 << data.bitIndex > 0:
#self.locations_checked # self.locations_checked
self.sending = self.sending + [(int(locationId))] self.sending = self.sending + [(int(locationId))]
except Exception as e: except Exception as e:
@ -631,8 +644,8 @@ class KH2Context(CommonContext):
self.kh2.write_short(self.kh2.base_address + self.Save + slot, itemData.memaddr) self.kh2.write_short(self.kh2.base_address + self.Save + slot, itemData.memaddr)
# removes the duped ability if client gave faster than the game. # removes the duped ability if client gave faster than the game.
for charInvo in {"SoraInvo", "DonaldInvo", "GoofyInvo"}: for charInvo in {"SoraInvo", "DonaldInvo", "GoofyInvo"}:
if self.kh2.read_short(self.kh2.base_address + self.Save + self.kh2seedsave[charInvo][1]) != 0 and\ if self.kh2.read_short(self.kh2.base_address + self.Save + self.kh2seedsave[charInvo][1]) != 0 and \
self.kh2seedsave[charInvo][1]+2 < self.kh2seedsave[charInvo][0]: self.kh2seedsave[charInvo][1] + 2 < self.kh2seedsave[charInvo][0]:
self.kh2.write_short(self.kh2.base_address + self.Save + self.kh2seedsave[charInvo][1], 0) self.kh2.write_short(self.kh2.base_address + self.Save + self.kh2seedsave[charInvo][1], 0)
# remove the dummy level 1 growths if they are in these invo slots. # remove the dummy level 1 growths if they are in these invo slots.
for inventorySlot in {0x25CE, 0x25D0, 0x25D2, 0x25D4, 0x25D6, 0x25D8}: for inventorySlot in {0x25CE, 0x25D0, 0x25D2, 0x25D4, 0x25D6, 0x25D8}:
@ -738,7 +751,8 @@ class KH2Context(CommonContext):
if itemName == "AP Boost": if itemName == "AP Boost":
amountOfUsedBoosts -= 50 amountOfUsedBoosts -= 50
totalBoosts = (amountOfBoostsInInvo + amountOfUsedBoosts) totalBoosts = (amountOfBoostsInInvo + amountOfUsedBoosts)
if totalBoosts <= amountOfItems - self.kh2seedsave["SoldBoosts"][itemName] and amountOfBoostsInInvo < 255: if totalBoosts <= amountOfItems - self.kh2seedsave["SoldBoosts"][
itemName] and amountOfBoostsInInvo < 255:
self.kh2.write_bytes(self.kh2.base_address + self.Save + itemData.memaddr, self.kh2.write_bytes(self.kh2.base_address + self.Save + itemData.memaddr,
(amountOfBoostsInInvo + 1).to_bytes(1, 'big'), 1) (amountOfBoostsInInvo + 1).to_bytes(1, 'big'), 1)