RECENT NEWS
📢 𝟑𝟎% Discount for all ads only this month ❄️

Map Functions Fixes [143+] [The Correct way]

Krim
power_settings_new
Seen 2 years ago
Steel Warrior (10/15)
Steel Warrior
0
0
0
10 Posts
Posts
0
Warning level
1
Likes
0
Dislikes
Joined: 2021-11-08

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

THIS IS BASED OFF ELVARGS CLIENT BUT WILL WORK WITH ANY

What your Adding:


Step 1:

Remove Zions Fix

Step 2:

Download the map icons Images and the data files and pack them into your cache

Spoiler for Downloads

Step 3:

Next you will need to add this class

Spoiler for AreaDefinition
Code:
public final class AreaDefinition {

    public static int size;
    public static int mapFunctionsSize;
    public static AreaDefinition[] cache;
    public static HashMap<Integer, Sprite> sprites = new HashMap<>();
    private static int cacheIndex;
    private static Buffer area_data;
    private static int[] indices;

    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() {
        indices = 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")
        );

        size = stream.readUShort();
        mapFunctionsSize = stream.readUShort();

        indices = new int[size];
        int offset = 2;

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

        cache = new AreaDefinition[10];

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

        System.out.println("Areas read -> " + size);
        
    }

    public static Sprite getImage(int sprite) {
        return sprites.get(sprite);
    }

    public static AreaDefinition lookup(int area) {
        for (int count = 0; count < 10; count++) {
            if (cache[count].id == area) {
                return cache[count];
            }
        }
        cacheIndex = (cacheIndex + 1) % 10;
        AreaDefinition data = cache[cacheIndex];
        if (area >= 0) {
            area_data.currentPosition = indices[area];
            data.readValues(area_data);
            if (!sprites.containsKey(data.spriteId)) {
                try {
                    sprites.put(data.spriteId, new Sprite(Client.instance.mediaStreamLoader, "mapfunction", data.spriteId));
                } catch (Exception e) {
                    System.out.println("Missing Sprite: " + data.spriteId + " Using Shop Icon");
                    sprites.put(data.spriteId, new Sprite(Client.instance.mediaStreamLoader, "mapfunction", 0));
                }
            }
        }
        return data;
    }

    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 4:

Now we need to load the Defs to do this find

Code:
FloorDefinition.init(

Under that add:

Code:
AreaDefinition.init(configArchive);

Step 5:

Next find this or somthing like it

Code:
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 or make the edits to match the following [EDITS ARE IN GREEN]

Code:
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 != -1) {
                    int sprite = AreaDefinition.lookup(function).spriteId;
                    if(sprite != -1) {
                        int viewportX = x;
                        int viewportY = y;
                        minimapHint[anInt1071] = AreaDefinition.getImage(sprite);
                        minimapHintX[anInt1071] = viewportX;
                        minimapHintY[anInt1071] = viewportY;
                        anInt1071++;
                    }
                }
            }
        }

Step 6:

Load up and make sure its working 

You can also remove all other map function refences in your client

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.

00
  • Like
Reactions: