From ec09fdfd64399c52ae492ac07dc6f84f9522965e Mon Sep 17 00:00:00 2001 From: Treeki Date: Sat, 20 Oct 2012 22:19:59 +0200 Subject: fixed tileset fixer --- src/tilesetfixer.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src') 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; -- cgit v1.2.3