Skip to content

Commit

Permalink
Some fixes for python 3.4.
Browse files Browse the repository at this point in the history
Python 3.4 didn't like some of my syntax. Win7 Service pack 1 is required for
  Python 3.5 Service Pack 1 won't install in my VM for unknown reasons. Welcome
  to yak shaving 101.
  • Loading branch information
mcgrew committed Feb 29, 2016
1 parent 927150c commit 0e625b5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
31 changes: 15 additions & 16 deletions dwrandomizer.py
Expand Up @@ -465,9 +465,9 @@ def fix_fighters_ring(self):
Adds functionality for the fighter's ring (+2 to attack)
"""
# ring patch
self.add_patch(0xf10c, 1, (0x20, 0x54, 0xff, 0xea))
self.add_patch(0xff64 ,1, (0x85, 0xcd, 0xa5, 0xcf, 0x29, 0x20, 0xf0, 0x07,
0xa5, 0xcc, 0x18, 0x69, 0x02, 0x85, 0xcc, 0xa5, 0xcf, 0x60))
self.add_patch(0xf10c, 1, 0x20, 0x54, 0xff, 0xea)
self.add_patch(0xff64 ,1, 0x85, 0xcd, 0xa5, 0xcf, 0x29, 0x20, 0xf0, 0x07,
0xa5, 0xcc, 0x18, 0x69, 0x02, 0x85, 0xcc, 0xa5, 0xcf, 0x60)

def move_repel(self):
"""
Expand All @@ -480,14 +480,14 @@ def buff_heal(self):
"""
Buffs the heal spell slightly to have a range of 10-25 instead of 10-15
"""
self.add_patch(0xdbce, 1, [15])
self.add_patch(0xdbce, 1, 15)

def patch_northern_shrine(self):
"""
Removes the 2 blocks from around the shrine guardian so you can walk around
him.
"""
self.add_patch(0xd77, 10, [0x66, 0x66])
self.add_patch(0xd77, 10, 0x66, 0x66)

def revert(self):
"""
Expand Down Expand Up @@ -544,15 +544,15 @@ def add_tantegel_exit(self):
Adds a quicker exit for the Tantegel throne room.
"""
# add new stairs to the throne room and 1st floor
self.add_patch(0x43a, 1, [0x47])
self.add_patch(0x2b9, 1, [0x45])
self.add_patch(0x43a, 1, 0x47)
self.add_patch(0x2b9, 1, 0x45)
# add a new exit to the first floor
self.add_patch(0x2d7, 1, [0x66])
self.add_patch(0x2d7, 1, 0x66)
# replace the usless grave warps with some for tantegel
self.add_patch(0xf45f, 1, [5, 1, 8])
self.add_patch(0xf4f8, 1, [4, 1, 7])
self.add_patch(0xf45f, 1, 5, 1, 8)
self.add_patch(0xf4f8, 1, 4, 1, 7)
#remove the top set of stairs associated with the old warp in the grave
self.add_patch(0x1298, 1, [0x22])
self.add_patch(0x1298, 1, 0x22)

def commit(self):
"""
Expand Down Expand Up @@ -586,21 +586,20 @@ def commit(self):
self.rom_data[self.chests_slice] = self.chests
self.apply_patches()

def add_patch(self, addr, step, data):
def add_patch(self, addr, *data):
"""
Adds a new manual rom patch
:Parameters:
addr : int
The address where the new data is to be applied
step : int
The distance between each data byte in the rom
data : array
The data to be patched into the ROM
The first argument should be the distance between each byte to be placed
in the rom. The rest is the data to be patched into the ROM
rtype:
return:
"""
self.patches[addr] = (step, *data)
self.patches[addr] = data

def apply_patches(self):
"""
Expand Down
8 changes: 4 additions & 4 deletions worldmap.py
Expand Up @@ -178,7 +178,7 @@ def place_landmarks(self):
grid = MapGrid(self.grid)

# place Charlock
while (self.closer_than(x-3, y, *tantegel, 5) or
while (self.closer_than(5, x-3, y, *tantegel) or
self.tile_at( x, y) in (TOWN, CASTLE, CAVE, STAIRS)):
x, y = self.accessible_land(grid, tantegel, 6, 118, 3, 116)
charlock = (x-3, y)
Expand All @@ -192,19 +192,19 @@ def place_landmarks(self):

for i in range(6):
x, y = charlock
while (self.closer_than(x, y, *charlock, 5) or
while (self.closer_than(5, x, y, *charlock) or
self.grid[y][x] in (TOWN, CASTLE, CAVE, STAIRS)):
x, y = self.accessible_land(grid, tantegel)
self.add_warp(1, x, y, TOWN)

for i in range(6):
x, y = charlock
while (self.closer_than(x, y, *charlock, 5) or
while (self.closer_than(5, x, y, *charlock) or
self.grid[y][x] in (TOWN, CASTLE, CAVE, STAIRS)):
x, y = self.accessible_land(grid, tantegel)
self.add_warp(1, x, y, CAVE)

def closer_than (self, x1, y1, x2, y2, distance):
def closer_than (self, distance, x1, y1, x2, y2):
"""
Determines whether x1,y1 is closer than distance vertically and
horizontally to x2,y2.
Expand Down

0 comments on commit 0e625b5

Please sign in to comment.