# OpenMFOR # credits manually reinstated due to the comments being lost from the object code decompilation # Original release is Copyright (C) 2022 Kazuto88 # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # Source Generated with Decompyle++ # File: Fusion_Graph.pyc (Python 3.8) import struct import sys class Game: def __init__(self, vanillaGame, randoSettings=None): self.graph = dict() self.areaConnections = dict() self.areaConnectionOffsets = dict() self.doorConnections = dict() self.rooms = dict() self.requirements = dict() self.visited = list() self.queue = list() self.majorItemLocations = list() self.minorItemLocations = list() self.itemLocations = list() self.patcher = dict() self.graph.clear() self.areaConnections.clear() self.areaConnectionOffsets.clear() self.doorConnections.clear() self.rooms.clear() self.requirements.clear() self.visited.clear() self.queue.clear() self.majorItemLocations.clear() self.minorItemLocations.clear() self.itemLocations.clear() self.patcher.clear() # print('DEBUG: Opening ROM to pick stuff') try: with open(vanillaGame, 'rb') as sourceRom: sourceRom.seek(3967888, 0) sourceArea = int.from_bytes(sourceRom.read(1), 'little') sourceDoor = int.from_bytes(sourceRom.read(1), 'little') targetOffset = sourceRom.tell() targetArea = int.from_bytes(sourceRom.read(1), 'little') while sourceArea != 255: self.areaConnections.update({ 'S{}-{:02X}'.format(sourceArea, sourceDoor): targetArea }) self.areaConnectionOffsets.update({ 'S{}-{:02X}'.format(sourceArea, sourceDoor): targetOffset }) sourceArea = int.from_bytes(sourceRom.read(1), 'little') sourceDoor = int.from_bytes(sourceRom.read(1), 'little') 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('= depth: return None for point in self.graph[start]: if point in self.itemLocations: if point not in end: continue if point in path: continue if LimitArea: for area in range(0, 7): if 'S{}'.format(area) in start: if 'S{}'.format(area) not in point: return None edge = (start, point) self.queue.append(edge) while self.queue: edge = self.queue.pop() if edge not in self.visited: self.visited.append(edge) node = edge[1] pathReqs = self.get_requirements(start, node) if pathReqs == None: newpath = self.get_path(node, end, LimitArea, path, depth) if newpath: path = path + [node] return newpath elif pathReqs == True: newpath = self.get_path(node, end, LimitArea, path, depth) if newpath: path = path + [node] return newpath