SM: fix Nothing type crash (#363)

This commit is contained in:
Fabian Dill 2022-03-31 03:29:08 +02:00 committed by GitHub
parent c472d740ec
commit 0263130126
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 6 deletions

View File

@ -1,8 +1,11 @@
from __future__ import annotations
import logging import logging
import copy import copy
import os import os
import threading import threading
from typing import Set import base64
from typing import Set, List
logger = logging.getLogger("Super Metroid") logger = logging.getLogger("Super Metroid")
@ -246,7 +249,6 @@ class SMWorld(World):
multiWorldLocations = {} multiWorldLocations = {}
multiWorldItems = {} multiWorldItems = {}
idx = 0 idx = 0
itemId = 0
self.playerIDMap = {} self.playerIDMap = {}
playerIDCount = 0 # 0 is for "Archipelago" server playerIDCount = 0 # 0 is for "Archipelago" server
for itemLoc in self.world.get_locations(): for itemLoc in self.world.get_locations():
@ -421,7 +423,7 @@ class SMWorld(World):
self.rom_name_available_event.set() # make sure threading continues and errors are collected self.rom_name_available_event.set() # make sure threading continues and errors are collected
def checksum_mirror_sum(self, start, length, mask = 0x800000): def checksum_mirror_sum(self, start, length, mask = 0x800000):
while (not(length & mask) and mask): while not(length & mask) and mask:
mask >>= 1 mask >>= 1
part1 = sum(start[:mask]) & 0xFFFF part1 = sum(start[:mask]) & 0xFFFF
@ -450,7 +452,6 @@ class SMWorld(World):
outfile.write(buffer) outfile.write(buffer)
def modify_multidata(self, multidata: dict): def modify_multidata(self, multidata: dict):
import base64
# wait for self.rom_name to be available. # wait for self.rom_name to be available.
self.rom_name_available_event.wait() self.rom_name_available_event.wait()
rom_name = getattr(self, "rom_name", None) rom_name = getattr(self, "rom_name", None)
@ -542,6 +543,11 @@ class SMWorld(World):
world.state.smbm[player].onlyBossLeft = True world.state.smbm[player].onlyBossLeft = True
break break
# Turn Nothing items into event pairs.
for location in world.get_locations():
if location.game == location.item.game == "Super Metroid" and location.item.type == "Nothing":
location.address = location.item.code = None
def create_locations(self, player: int): def create_locations(self, player: int):
for name, id in locations_lookup_name_to_id.items(): for name, id in locations_lookup_name_to_id.items():
@ -576,7 +582,5 @@ class SMItem(Item):
game = "Super Metroid" game = "Super Metroid"
def __init__(self, name, advancement, type, code, player: int = None): def __init__(self, name, advancement, type, code, player: int = None):
if type == "Nothing":
code = None
super(SMItem, self).__init__(name, advancement, code, player) super(SMItem, self).__init__(name, advancement, code, player)
self.type = type self.type = type