Did you look in method422..?
|
Code:Stream stream = new Stream(abyte0); int objectId = -1; do { int objectIdOffset = stream.readUSmart2(); if (objectIdOffset == 0) break; objectId += objectIdOffset; int loc = 0; do { int objectPosOffset = stream.method422(); if (objectPosOffset == 0) break; loc += objectPosOffset - 1; int localX = loc >> 6 & 0x3f; int localY = loc & 0x3f; int height = loc >> 12; int objectData = stream.readUnsignedByte(); int type = objectData >> 2; int direction = objectData & 3;Iirc, the red coloured lines above represent the offset of the object's position. But how is this calculated?Code:objectId = 6968 objectPosOffset = 7339 localX = 50 localY = 42 height = 1 objectData = 40 type = 10 direction = 0
Thanks.
http://www.rune-server.org/runescape...m-packets.html
pretty sure its the same as this
Here quick example of how the selection you have highlighted can be generated.
Code:import java.util.ArrayList; import java.util.List; public class MapCompressTest { //stores the objects private List<GameObject> list = new ArrayList<GameObject>(); public static void main(String[] args) { MapCompressTest test = new MapCompressTest(); int lastValue = 0; //loop for the same object ids for(GameObject obj : test.getList()) { int compressed = obj.getCompressedValue(); //the value is the same so write 1 if(lastValue == compressed) { //TODO write one to the buffer continue; } //otherwise check the dif between the two value int dif = (compressed - lastValue) + 1; //debug to show example System.out.println("Display"); GameObject.displayDecodeValue(compressed); GameObject.displayDecodeValue(dif - 1); //TODO write the dif to the stream //set the last value lastValue = compressed; } } public MapCompressTest() { //same list.add(new GameObject(1, 50, 40)); //same would give a change of 0 //list.add(new GameObject(1, 50, 40)); //new height list.add(new GameObject(3, 50, 40)); } public List<GameObject> getList() { return list; } //containing class public static class GameObject { private int height; private int localX; private int localY; public static void displayDecodeValue(int input) { //uncompress the encoded value System.out.println("Height:" +(input >> 12)); System.out.println("LocalX:" +((input >> 6) & 0x3f)); System.out.println("LocalY:" +((input) & 0x3f)); } public GameObject(int height, int localX, int localY) { this.height = height; this.localX = localX; this.localY = localY; } public int getCompressedValue() { //compress the values into a 32bit int however we only require 14bits //max value of localX and localY is 63 and 3 for height return ((height << 12) | (localX << 6) | localY) ; } } }
the answer is 3 lines under the code
Code:int localX = loc >> 6 & 0x3f; int localY = loc & 0x3f; int height = loc >> 12;
in 377:
then for the delta ("objectPosOffset") it is calculated as (cur.pos.enc - prev.pos.enc) and written as an unsigned smart-sized value:Code:union obj_pos { struct { /* x,y are offsets into this current 64x64 region */ uint y : 6; /* 0...63 */ uint x : 6; /* 0...63 */ uint plane : 2; /* 0...3 */ /* unused 2 bits */ }; ushort enc; }
offsets are used because they will tend to be small numbers (iirc jagex tend to encode objects in ascending y,x,plane order, so the the delta will in most cases only actually require 6-bits [only y variant], followed by the lesser likely cases of 12-bits [x variant as well] and 14-bits [plane variant], in that order) and therefore landscape resource sizes will be reducedCode:public int read_usmart() { int i = data[pointer] & 0xff; if (i < 128) /* size bit == 0 */ return read_u8(); else /* size bit == 1 */ return read_u16() - 32768; /* use only latter 15-bits */ }
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |