Jump to content

Map Function Fixes [143+]


Mark
 Share

Recommended Posts

Hey, so since 143 a lot of servers have been using Zions Tutorial for map icons, While this does work. Its not the correct way to do it and is a cheap way to do it also it only supports up to icon 83 so all the new map icons are not showing on the Minimap

The fix: 

The reason this is happening is because OSRS started to use Areas to store information like map icons, World map Information. I have dumped and encoded the icons with the sprite id that they should be loaded from in your cache

What your Adding:

Hd88iZ5.png
O32HxX3.png

Step 1:

Remove Zions Fix

Step 2:

Download these files and pack them into your cache

[Sprites] Map Functions
[Areas.dat and idx] into your configs

Step 3:

Next you will need to add this class
 

package com.runescape.cache.def;

import com.runescape.cache.FileArchive;
import com.runescape.io.Buffer;
import com.runescape.sign.SignLink;
import com.runescape.util.FileUtils;

public final class AreaDefinition {

    public static int totalAreas;
    public static AreaDefinition[] cache;
    private static int cacheIndex;
    private static Buffer area_data;
    private static int[] streamIndices;


    public int id;
    public int spriteId = -1;
    public int field3294 = -1;
    public String name = "";
    public int field3296 = -1;
    public int field3297 = -1;
    public String actions[];
    public int field3310 = -1;


    private AreaDefinition() {
        id = -1;
    }

    public static void clear() {
        streamIndices = null;
        cache = null;
        area_data = null;
    }

    public static void init(FileArchive archive) {
 
        area_data = new Buffer(archive.readFile("areas.dat"));
        Buffer stream = new Buffer(archive.readFile("areas.idx"));

        totalAreas = stream.readUShort();
        streamIndices = new int[totalAreas];
        int offset = 2;

        for (int _ctr = 0; _ctr < totalAreas; _ctr++) {
            streamIndices[_ctr] = offset;
            offset += stream.readUShort();
        }

        cache = new AreaDefinition[10];

        for (int _ctr = 0; _ctr < 10; _ctr++) {
            cache[_ctr] = new AreaDefinition();
        }

        System.out.println("Loaded: " + totalAreas + " Areas");

    }

    public static AreaDefinition lookup(int itemId) {

            for (int count = 0; count < 10; count++)
                if (cache[count].id == itemId)
                    return cache[count];

            cacheIndex = (cacheIndex + 1) % 10;
            AreaDefinition itemDef = cache[cacheIndex];
            if (itemId > 0)
                area_data.currentPosition = streamIndices[itemId];
            itemDef.id = itemId;
            itemDef.readValues(area_data);
            return itemDef;
    }

    public void readValues(Buffer buffer) {
        do {
            int opCode = buffer.readUnsignedByte();
            if (opCode == 0)
                return;
            if (opCode == 1)
                spriteId = buffer.readInt();
            else if (opCode == 2)
                field3294 = buffer.readInt();
            else if (opCode == 3)
                name = buffer.readNewString();
            else if (opCode == 4)
                field3296 = buffer.readInt();
            else if (opCode == 5)
                field3297 = buffer.readInt();
            else if (opCode == 6)
                field3296 = buffer.readInt();
            else if (opCode >= 6 && opCode < 11) {
                if (actions  == null)
                    actions = new String[5];
                   actions[opCode - 6] = buffer.readNewString();
            } else if (opCode == 12)
                field3310 = buffer.readInt();

        } while (true);
    }

}



Step 3:

Under where you load the Objects Configs add 

AreaDefinition.init(configArchive);

Step 4:

Find Something that looks like 

for (int x = 0; x < 104; x++) {                
            for (int y = 0; y < 104; y++) {                      
                int id = scene.getGroundDecorationUid(plane, x, y);
                if (id != 0) {
                    id = id >> 14 & 0x7fff;

            int function = ObjectDefinition.lookup(id).minimapFunction;

            if (function >= 0) {
                int viewportX = x;                                    
                int viewportY = y;                                    
                minimapHint[anInt1071] = mapFunctions[function];
                minimapHintX[anInt1071] = viewportX;
                minimapHintY[anInt1071] = viewportY;
                anInt1071++;
            }
                }
            }

        }


and replace it with this

for (int x = 0; x < 104; x++) {                
            for (int y = 0; y < 104; y++) {                      
                int id = scene.getGroundDecorationUid(plane, x, y);
                if (id != 0) {
                    id = id >> 14 & 0x7fff;

            int function = ObjectDefinition.lookup(id).minimapFunction;

            if (function >= 0) {
                int sprite = AreaDefinition.lookup(j3).spriteId;
                if(sprite != -1) {
                    int viewportX = x;                                    
                    int viewportY = y;                                    
                    minimapHint[anInt1071] = mapFunctions[sprite];
                    minimapHintX[anInt1071] = viewportX;
                    minimapHintY[anInt1071] = viewportY;
                    anInt1071++;
                }
            }
                }
            }

        }


 

Step 5:

Search for 

mapFunctions[l3] = new Sprite

 

and edit the loop to load 118 Icons

if (mapFunctions[i6] != null)

 

in startup and edit the loop to load 118 Icons

mapFunctions = new Sprite

 

and edit the array to 118 Icons

Step 6:

Load up and make sure its working :)

if you need any help comment on the thread or dm me on discord, You may also need 32k object clicking to load some of the very new Icons up.

I will also look into what the other fields do tomorrow and update the thread

  • Positive 1

Cool DEV

Mark
RuneList Jr. Moderator

Link to comment
Share on other sites


Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share