summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tilesetfixer.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/tilesetfixer.cpp b/src/tilesetfixer.cpp
index 71bea9d..2fdb99e 100644
--- a/src/tilesetfixer.cpp
+++ b/src/tilesetfixer.cpp
@@ -3,14 +3,20 @@
const char *GetTilesetName(void *cls, int areaNum, int slotNum);
-void DoFixes(int slotNumber);
+void DoFixes(int areaNumber, int slotNumber);
void SwapObjData(u8 *data, int slotNumber);
+extern "C" void *OriginalTilesetLoadingThing(void *, void *, int, int);
+
// Main hook
-void TilesetFixerHack() {
- for (int i = 1; i < 4; i++) {
- DoFixes(i);
+void *TilesetFixerHack(void *cls, void *heap, int areaNum, int layerNum) {
+ if (layerNum == 0) {
+ for (int i = 1; i < 4; i++) {
+ DoFixes(areaNum, i);
+ }
}
+
+ return OriginalTilesetLoadingThing(cls, heap, areaNum, layerNum);
}
@@ -23,9 +29,9 @@ struct ObjLookupEntry {
};
-void DoFixes(int slotNumber) {
+void DoFixes(int areaNumber, int slotNumber) {
// This is where it all starts
- const char *tsName = GetTilesetName(BGDatClass, GetAreaNum(), slotNumber);
+ const char *tsName = GetTilesetName(BGDatClass, areaNumber, slotNumber);
if (tsName == 0 || tsName[0] == 0) {
return;