Пример #1
0
    def ipsPatch(self, ipsPatches):
        mergedIPS = IPS_Patch()
        for ips in ipsPatches:
            mergedIPS.append(ips)

        # generate records for ips from self data
        groupedData = {}
        startAddress = -1
        prevAddress = -1
        curData = []
        for address in sorted(self.data):
            if address == prevAddress + 1:
                curData.append(self.data[address])
                prevAddress = address
            else:
                if len(curData) > 0:
                    groupedData[startAddress] = curData
                startAddress = address
                prevAddress = address
                curData = [self.data[startAddress]]
        if startAddress != -1:
            groupedData[startAddress] = curData

        patch = IPS_Patch(groupedData)
        mergedIPS.append(patch)
        patchData = mergedIPS.encode()
        self.data = {}
        self.data["ips"] = base64.b64encode(patchData).decode()
        if mergedIPS.truncate_length is not None:
            self.data["truncate_length"] = mergedIPS.truncate_length
        self.data["max_size"] = mergedIPS.max_size
Пример #2
0
 def close(self):
     mergedIPS = IPS_Patch()
     for ips in self.ipsPatches:
         mergedIPS.append(ips)
     mergedIPS.append(self.ips())
     patchData = mergedIPS.encode()
     self.data = {}
     self.data["ips"] = base64.b64encode(patchData).decode()
     if mergedIPS.truncate_length is not None:
         self.data["truncate_length"] = mergedIPS.truncate_length
     self.data["max_size"] = mergedIPS.max_size
#!/usr/bin/python3

import sys, os, json

# we're in directory 'tools/' we have to update sys.path
sys.path.append(os.path.dirname(sys.path[0]))

from rom.ips import IPS_Patch
elev = IPS_Patch.load("patches/common/ips/elevators_speed.ips")
doors = IPS_Patch.load("patches/common/ips/fast_doors.ips")
merged = IPS_Patch()
merged.append(elev)
merged.append(doors)
merged.save("patches/common/ips/elevators_doors_speed.ips")