vanilla ROM parsing fix + stuff
parent
43e16025da
commit
bd7e1bc15d
|
@ -32,7 +32,7 @@ class Game:
|
|||
self.itemLocations.clear()
|
||||
self.patcher.clear()
|
||||
|
||||
print('DEBUG: Opening ROM to pick stuff')
|
||||
# print('DEBUG: Opening ROM to pick stuff')
|
||||
|
||||
try:
|
||||
with open(vanillaGame, 'rb') as sourceRom:
|
||||
|
@ -51,19 +51,21 @@ class Game:
|
|||
targetOffset = sourceRom.tell()
|
||||
targetArea = int.from_bytes(sourceRom.read(1), 'little')
|
||||
for currentArea in range(7):
|
||||
# print('DEBUG: Parsing sector {}'.format(currentArea))
|
||||
sourceRom.seek(7977108 + currentArea * 4, 0)
|
||||
data = sourceRom.read(4)
|
||||
unpacked = struct.unpack('<L', data)
|
||||
doorData = unpacked[0] - 134217728
|
||||
sourceRom.seek(doorData, 0)
|
||||
doorNumber = 0
|
||||
while True:
|
||||
connectionType = int.from_bytes(sourceRom.read(1), 'little')
|
||||
roomNumber = int.from_bytes(sourceRom.read(1), 'little')
|
||||
sourceRom.seek(4, 1)
|
||||
connectedDoor = int.from_bytes(sourceRom.read(1), 'little')
|
||||
sourceRom.seek(5, 1)
|
||||
if connectionType == 0 and connectedDoor == 0:
|
||||
continue
|
||||
break
|
||||
sourceNode = 'S{}-{:02X}'.format(currentArea, doorNumber)
|
||||
connectedArea = self.areaConnections.get(sourceNode, currentArea)
|
||||
targetNode = 'S{}-{:02X}'.format(connectedArea, connectedDoor)
|
||||
|
@ -72,16 +74,17 @@ class Game:
|
|||
roomNumber = format(roomNumber, '02X')
|
||||
roomString = 'Room-S{}-{}'.format(currentArea, roomNumber)
|
||||
doorString = 'S{}-{:02X}'.format(currentArea, doorNumber)
|
||||
print('DEBUG: Adding door {} to S{}-{:02X}'.format(doorNumber, currentArea, roomNumber))
|
||||
# print('DEBUG: Adding door S{}-{:02X} to S{}-{}'.format(currentArea, doorNumber, currentArea, roomNumber))
|
||||
if roomString in self.rooms:
|
||||
self.rooms[roomString].append(doorString)
|
||||
else:
|
||||
self.rooms[roomString] = [
|
||||
doorString]
|
||||
doorNumber += 1
|
||||
print('DEBUG: Parsing seemingly done?')
|
||||
# print('DEBUG: Parsing seemingly done?')
|
||||
except:
|
||||
sys.exit('Error:', vanillaGame, 'could not be opened.')
|
||||
print('Error:', vanillaGame, 'could not be opened.')
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
||||
|
@ -150,17 +153,14 @@ class Game:
|
|||
for targetNode in self.rooms[targetRoom]:
|
||||
if currentNode != targetNode:
|
||||
self.add_edges(currentNode, targetNode)
|
||||
continue
|
||||
continue
|
||||
else:
|
||||
self.rooms[targetRoom] = [
|
||||
currentNode]
|
||||
continue
|
||||
return None
|
||||
|
||||
|
||||
def add_directed_edge(self, start, end):
|
||||
if start != end:
|
||||
if start in self.graph or end not in self.graph[start]:
|
||||
if start in self.graph:
|
||||
if end not in self.graph[start]:
|
||||
self.graph[start].append(end)
|
||||
else:
|
||||
self.graph[start] = [
|
||||
|
|
807
Randomizer.py
807
Randomizer.py
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue