shithub: pokecrystal

Download patch

ref: a53b5ae051d0d1d054da2ff0ee64247ea1663ee2
parent: 34c6b38da6026b3a877c68541d0d7bd0ec1373e9
author: Bryan Bishop <[email protected]>
date: Wed May 16 11:22:39 EDT 2012

handle dragon shrine recursion (but not others?)

--- a/extras/crystal.py
+++ b/extras/crystal.py
@@ -30,6 +30,8 @@
 
 spacing = "\t"
 
+lousy_dragon_shrine_hack = [0x18d079, 0x18d0a9, 0x18d061, 0x18d091]
+
 #table of pointers to map groups
 #each map group contains some number of map headers
 map_group_pointer_table = 0x94000
@@ -5775,12 +5777,19 @@
             # its' probably being injected in some get_dependencies() somewhere
             print "don't know why ScriptPointerLabelParam is getting to this point?"
             return
-        start_address = new_object.address
         
         #first some validation
         if not hasattr(new_object, "address"):
             print "object needs to have an address property: " + str(new_object)
             return
+        
+        start_address = new_object.address
+
+        # skip this dragon shrine script calling itself
+        # what about other scripts that call themselves ?
+        if start_address in lousy_dragon_shrine_hack:
+            print "skipping 0x18d079 in dragon shrine for a lousy hack"
+            return
        
         if not hasattr(new_object, "label") and hasattr(new_object, "is_valid") and not new_object.is_valid():
             return
@@ -5847,6 +5856,10 @@
                 self.parts.remove(object)
                 found = True
                 break
+            elif object.address <= start_address < object.last_address:
+                print "this is probably a script that is looping back on itself?"
+                found = True
+                break
             #insert before the current object
             elif object.address > end_address:
                 #insert_before = index of object
@@ -6103,6 +6116,10 @@
         return None
     if type(address) != int:
         raise Exception, "get_label_for requires an integer address, got: " + str(type(address))
+
+    # lousy hack to get around recursive scripts in dragon shrine
+    if address in lousy_dragon_shrine_hack:
+        return None
 
     #the old way
     for thing in all_labels: