Thread: OSRS Clipping - No errors but not working

Page 1 of 3 123 LastLast
Results 1 to 10 of 21
  1. #1 OSRS Clipping - No errors but not working 
    Registered Member
    Join Date
    Jan 2012
    Posts
    562
    Thanks given
    43
    Thanks received
    53
    Rep Power
    72
    So I've replaced the loc.idx/loc.dat,maps & map_index in the source with the ones in the client's cache - modified ObjectDef to match the client's ObjectDef.
    Problem is, I don't get errors but the clipping doesn't work.

    Client's ObjectDef
    [SPOIL]
    Code:
    public final class ObjectDef {
    
    	public static ObjectDef forID(int i) {
    		if (i > streamIndices.length)
    			i = streamIndices.length - 1;
    		for (int j = 0; j < 20; j++)
    			if (cache[j].type == i)
    				return cache[j];
    		cacheIndex = (cacheIndex + 1) % 20;
    		ObjectDef class46 = cache[cacheIndex];
    		stream.currentOffset = streamIndices[i];
    		class46.type = i;
    		class46.setDefaults();
    		class46.readValues(stream);
    		switch(i) {
    		case 6552:
    			class46.actions = new String[5];
    			class46.actions[0] = "Normals";
    			class46.actions[1] = "Ancients";
    			class46.actions[2] = "Lunars";
    			break;
    		case 11744:
    			class46.actions = new String[5];
    			class46.actions[0] = "Bank";
    			break;
    		}
    		return class46;
    	}
    
    	public void setDefaults() {
    		anIntArray773 = null;
    		anIntArray776 = null;
    		name = null;
    		description = null;
    		modifiedModelColors = null;
    		originalModelColors = null;
    		anInt744 = 1;
    		anInt761 = 1;
    		aBoolean767 = true;
    		aBoolean757 = true;
    		hasActions = false;
    		aBoolean762 = false;
    		aBoolean769 = false;
    		aBoolean764 = false;
    		anInt781 = -1;
    		anInt775 = 16;
    		aByte737 = 0;
    		aByte742 = 0;
    		actions = null;
    		anInt746 = -1;
    		anInt758 = -1;
    		aBoolean751 = false;
    		aBoolean779 = true;
    		anInt748 = 128;
    		anInt772 = 128;
    		anInt740 = 128;
    		anInt768 = 0;
    		anInt738 = 0;
    		anInt745 = 0;
    		anInt783 = 0;
    		aBoolean736 = false;
    		aBoolean766 = false;
    		anInt760 = -1;
    		anInt774 = -1;
    		anInt749 = -1;
    		childrenIDs = null;
    	}
    
    	public void method574(OnDemandFetcher class42_sub1) {
    		if (anIntArray773 == null)
    			return;
    		for (int j = 0; j < anIntArray773.length; j++)
    			class42_sub1.method560(anIntArray773[j] & 0xffff, 0);
    	}
    
    	public static void nullLoader() {
    		mruNodes1 = null;
    		mruNodes2 = null;
    		streamIndices = null;
    		cache = null;
    		stream = null;
    	}
    
    	public static void unpackConfig(StreamLoader streamLoader) {
    		stream = new Stream(streamLoader.getDataForName("loc.dat"));
    		Stream stream = new Stream(streamLoader.getDataForName("loc.idx"));
    		//stream = new Stream(FileOperations.ReadFile(signlink.findcachedir()+ "loc.dat"));
    		//Stream stream = new Stream(FileOperations.ReadFile(signlink.findcachedir()+ "loc.idx"));
    		int totalObjects = stream.readUnsignedWord();
    		streamIndices = new int[totalObjects];
    		int i = 2;
    		for (int j = 0; j < totalObjects; j++) {
    			streamIndices[j] = i;
    			i += stream.readUnsignedWord();
    		}
    		cache = new ObjectDef[20];
    		for (int k = 0; k < 20; k++)
    			cache[k] = new ObjectDef();
    	}
    
    	public boolean method577(int i) {
    		if (anIntArray776 == null) {
    			if (anIntArray773 == null)
    				return true;
    			if (i != 10)
    				return true;
    			boolean flag1 = true;
    			for (int k = 0; k < anIntArray773.length; k++)
    				flag1 &= Model.method463(anIntArray773[k] & 0xffff);
    
    			return flag1;
    		}
    		for (int j = 0; j < anIntArray776.length; j++)
    			if (anIntArray776[j] == i)
    				return Model.method463(anIntArray773[j] & 0xffff);
    
    		return true;
    	}
    
    	public Model method578(int i, int j, int k, int l, int i1, int j1, int k1) {
    		Model model = method581(i, k1, j);
    		if (model == null)
    			return null;
    		if (aBoolean762 || aBoolean769)
    			model = new Model(aBoolean762, aBoolean769, model);
    		if (aBoolean762) {
    			int l1 = (k + l + i1 + j1) / 4;
    			for (int i2 = 0; i2 < model.anInt1626; i2++) {
    				int j2 = model.anIntArray1627[i2];
    				int k2 = model.anIntArray1629[i2];
    				int l2 = k + ((l - k) * (j2 + 64)) / 128;
    				int i3 = j1 + ((i1 - j1) * (j2 + 64)) / 128;
    				int j3 = l2 + ((i3 - l2) * (k2 + 64)) / 128;
    				model.anIntArray1628[i2] += j3 - l1;
    			}
    
    			model.method467();
    		}
    		return model;
    	}
    
    	public boolean method579() {
    		if (anIntArray773 == null)
    			return true;
    		boolean flag1 = true;
    		for (int i = 0; i < anIntArray773.length; i++)
    			flag1 &= Model.method463(anIntArray773[i] & 0xffff);
    		return flag1;
    	}
    
    	public ObjectDef method580() {
    		int i = -1;
    		if (anInt774 != -1) {
    			VarBit varBit = VarBit.cache[anInt774];
    			int j = varBit.anInt648;
    			int k = varBit.anInt649;
    			int l = varBit.anInt650;
    			int i1 = Client.anIntArray1232[l - k];
    			i = clientInstance.variousSettings[j] >> k & i1;
    		} else if (anInt749 != -1)
    			i = clientInstance.variousSettings[anInt749];
    		if (i < 0 || i >= childrenIDs.length || childrenIDs[i] == -1)
    			return null;
    		else
    			return forID(childrenIDs[i]);
    	}
    
    	public Model method581(int j, int k, int l) {
    		Model model = null;
    		long l1;
    		if (anIntArray776 == null) {
    			if (j != 10)
    				return null;
    			l1 = (long) ((type << 8) + l) + ((long) (k + 1) << 32);
    			Model model_1 = (Model) mruNodes2.insertFromCache(l1);
    			if (model_1 != null)
    				return model_1;
    			if (anIntArray773 == null)
    				return null;
    			boolean flag1 = aBoolean751 ^ (l > 3);
    			int k1 = anIntArray773.length;
    			for (int i2 = 0; i2 < k1; i2++) {
    				int l2 = anIntArray773[i2];
    				if (flag1)
    					l2 += 0x10000;
    				model = (Model) mruNodes1.insertFromCache(l2);
    				if (model == null) {
    					model = Model.method462(l2 & 0xffff);
    					if (model == null)
    						return null;
    					if (flag1)
    						model.method477();
    					mruNodes1.removeFromCache(model, l2);
    				}
    				if (k1 > 1)
    					aModelArray741s[i2] = model;
    			}
    
    			if (k1 > 1)
    				model = new Model(k1, aModelArray741s);
    		} else {
    			int i1 = -1;
    			for (int j1 = 0; j1 < anIntArray776.length; j1++) {
    				if (anIntArray776[j1] != j)
    					continue;
    				i1 = j1;
    				break;
    			}
    
    			if (i1 == -1)
    				return null;
    			l1 = (long) ((type << 8) + (i1 << 3) + l) + ((long) (k + 1) << 32);
    			Model model_2 = (Model) mruNodes2.insertFromCache(l1);
    			if (model_2 != null)
    				return model_2;
    			int j2 = anIntArray773[i1];
    			boolean flag3 = aBoolean751 ^ (l > 3);
    			if (flag3)
    				j2 += 0x10000;
    			model = (Model) mruNodes1.insertFromCache(j2);
    			if (model == null) {
    				model = Model.method462(j2 & 0xffff);
    				if (model == null)
    					return null;
    				if (flag3)
    					model.method477();
    				mruNodes1.removeFromCache(model, j2);
    			}
    		}
    		boolean flag;
    		flag = anInt748 != 128 || anInt772 != 128 || anInt740 != 128;
    		boolean flag2;
    		flag2 = anInt738 != 0 || anInt745 != 0 || anInt783 != 0;
    		Model model_3 = new Model(modifiedModelColors == null, Class36
    				.method532(k), l == 0 && k == -1 && !flag && !flag2, model);
    		if (k != -1) {
    			model_3.method469();
    			model_3.method470(k);
    			model_3.anIntArrayArray1658 = null;
    			model_3.anIntArrayArray1657 = null;
    		}
    		while (l-- > 0)
    			model_3.method473();
    		if (modifiedModelColors != null) {
    			for (int k2 = 0; k2 < modifiedModelColors.length; k2++)
    				model_3.method476(modifiedModelColors[k2],
    						originalModelColors[k2]);
    
    		}
    		if (flag)
    			model_3.method478(anInt748, anInt740, anInt772);
    		if (flag2)
    			model_3.method475(anInt738, anInt745, anInt783);
    		//model_3.method479(64, 768, -50, -10, -50, !aBoolean769);
    		//model_3.method479(64 + aByte737, 768 + aByte742 * 5, -50, -10, -50, !aBoolean769);
    
    		//model_3.method479(84, 1500, -90, -280, -70, !aBoolean769);
    		model_3.method479(74, 1000, -90, -580, -90, !aBoolean769);
    		if (anInt760 == 1)
    			model_3.anInt1654 = model_3.modelHeight;
    		mruNodes2.removeFromCache(model_3, l1);
    		return model_3;
    	}
    
    	public void readValues(Stream stream) {
    		int flag = -1;
    		do {
    			int type = stream.readUnsignedByte();
    			if (type == 0)
    				break;
    			if (type == 1) {
    				int len = stream.readUnsignedByte();
    				if (len > 0) {
    					if (anIntArray773 == null || lowMem) {
    						anIntArray776 = new int[len];
    						anIntArray773 = new int[len];
    						for (int k1 = 0; k1 < len; k1++) {
    							anIntArray773[k1] = stream.readUnsignedWord();
    							anIntArray776[k1] = stream.readUnsignedByte();
    						}
    					} else {
    						stream.currentOffset += len * 3;
    					}
    				}
    			} else if (type == 2)
    				name = stream.readString();
    			else if (type == 3)
    				description = stream.readBytes();
    			else if (type == 5) {
    				int len = stream.readUnsignedByte();
    				if (len > 0) {
    					if (anIntArray773 == null || lowMem) {
    						anIntArray776 = null;
    						anIntArray773 = new int[len];
    						for (int l1 = 0; l1 < len; l1++)
    							anIntArray773[l1] = stream.readUnsignedWord();
    					} else {
    						stream.currentOffset += len * 2;
    					}
    				}
    			} else if (type == 14)
    				anInt744 = stream.readUnsignedByte();
    			else if (type == 15)
    				anInt761 = stream.readUnsignedByte();
    			else if (type == 17)
    				aBoolean767 = false;
    			else if (type == 18)
    				aBoolean757 = false;
    			else if (type == 19)
    				hasActions = (stream.readUnsignedByte() == 1);
    			else if (type == 21)
    				aBoolean762 = true;
    			else if (type == 22)
    				aBoolean769 = false;
    			else if (type == 23)
    				aBoolean764 = true;
    			else if (type == 24) {
    				anInt781 = stream.readUnsignedWord();
    				if (anInt781 == 65535)
    					anInt781 = -1;
    			} else if (type == 28)
    				anInt775 = stream.readUnsignedByte();
    			else if (type == 29)
    				aByte737 = stream.readSignedByte();
    			else if (type == 39)
    				aByte742 = stream.readSignedByte();
    			else if (type >= 30 && type < 39) {
    				if (actions == null)
    					actions = new String[5];
    				actions[type - 30] = stream.readString();
    				if (actions[type - 30].equalsIgnoreCase("hidden"))
    					actions[type - 30] = null;
    			} else if (type == 40) {
    				int i1 = stream.readUnsignedByte();
    				modifiedModelColors = new int[i1];
    				originalModelColors = new int[i1];
    				for (int i2 = 0; i2 < i1; i2++) {
    					modifiedModelColors[i2] = stream.readUnsignedWord();
    					originalModelColors[i2] = stream.readUnsignedWord();
    				}
    
    			} else if (type == 60)
    				anInt746 = stream.readUnsignedWord();
    			else if (type == 62)
    				aBoolean751 = true;
    			else if (type == 64)
    				aBoolean779 = false;
    			else if (type == 65)
    				anInt748 = stream.readUnsignedWord();
    			else if (type == 66)
    				anInt772 = stream.readUnsignedWord();
    			else if (type == 67)
    				anInt740 = stream.readUnsignedWord();
    			else if (type == 68)
    				anInt758 = stream.readUnsignedWord();
    			else if (type == 69)
    				anInt768 = stream.readUnsignedByte();
    			else if (type == 70)
    				anInt738 = stream.readSignedWord();
    			else if (type == 71)
    				anInt745 = stream.readSignedWord();
    			else if (type == 72)
    				anInt783 = stream.readSignedWord();
    			else if (type == 73)
    				aBoolean736 = true;
    			else if (type == 74)
    				aBoolean766 = true;
    			else if (type == 75)
    				anInt760 = stream.readUnsignedByte();
    			else if (type == 77) {
    				anInt774 = stream.readUnsignedWord();
    				if (anInt774 == 65535)
    					anInt774 = -1;
    				anInt749 = stream.readUnsignedWord();
    				if (anInt749 == 65535)
    					anInt749 = -1;
    				int j1 = stream.readUnsignedByte();
    				childrenIDs = new int[j1 + 1];
    				for (int j2 = 0; j2 <= j1; j2++) {
    					childrenIDs[j2] = stream.readUnsignedWord();
    					if (childrenIDs[j2] == 65535)
    						childrenIDs[j2] = -1;
    				}
    			}
    		} while (true);
    		if (flag == -1  && name != "null" && name != null) {
    			hasActions = anIntArray773 != null
    			&& (anIntArray776 == null || anIntArray776[0] == 10);
    			if (actions != null)
    				hasActions = true;
    		}
    		if (aBoolean766) {
    			aBoolean767 = false;
    			aBoolean757 = false;
    		}
    		if (anInt760 == -1)
    			anInt760 = aBoolean767 ? 1 : 0;
    	}
    
    	public ObjectDef() {
    		type = -1;
    	}
    
    	public boolean aBoolean736;
    	public byte aByte737;
    	public int anInt738;
    	public String name;
    	public int anInt740;
    	public static final Model[] aModelArray741s = new Model[4];
    	public byte aByte742;
    	public int anInt744;
    	public int anInt745;
    	public int anInt746;
    	public int[] originalModelColors;
    	public int anInt748;
    	public int anInt749;
    	public boolean aBoolean751;
    	public static boolean lowMem;
    	public static Stream stream;
    	public int type;
    	public static int[] streamIndices;
    	public boolean aBoolean757;
    	public int anInt758;
    	public int childrenIDs[];
    	public int anInt760;
    	public int anInt761;
    	public boolean aBoolean762;
    	public boolean aBoolean764;
    	public static Client clientInstance;
    	public boolean aBoolean766;
    	public boolean aBoolean767;
    	public int anInt768;
    	public boolean aBoolean769;
    	public static int cacheIndex;
    	public int anInt772;
    	public int[] anIntArray773;
    	public int anInt774;
    	public int anInt775;
    	public int[] anIntArray776;
    	public byte description[];
    	public boolean hasActions;
    	public boolean aBoolean779;
    	public static MRUNodes mruNodes2 = new MRUNodes(30);
    	public int anInt781;
    	public static ObjectDef[] cache;
    	public int anInt783;
    	public int[] modifiedModelColors;
    	public static MRUNodes mruNodes1 = new MRUNodes(500);
    	public String actions[];
    
    }
    [/SPOIL]

    Server's ObjectDef:
    [SPOIL]
    Code:
    package server.clip.region;
    
    public final class ObjectDef
    {
    
        public static ObjectDef getObjectDef(int i)
        {
            for(int j = 0; j < 20; j++)
                if(cache[j].type == i)
                    return cache[j];
    
            cacheIndex = (cacheIndex + 1) % 20;
            ObjectDef class46 = cache[cacheIndex];
            class46.type = i;
            class46.setDefaults();
            byte[] buffer = archive.get(i);
    	//if(buffer != null && buffer.length > 0)
    		class46.readValues(new ByteStreamExt(buffer));
            return class46;
        }
    
        private void setDefaults()
        {
            anIntArray773 = null;
            anIntArray776 = null;
            name = null;
            description = null;
            modifiedModelColors = null;
            originalModelColors = null;
            anInt744 = 1;
            anInt761 = 1;
            aBoolean767 = true;
            aBoolean757 = true;
            hasActions = false;
            aBoolean762 = false;
            aBoolean764 = false;
            anInt781 = -1;
            anInt775 = 16;
            actions = null;
            anInt746 = -1;
            anInt758 = -1;
            aBoolean779 = true;
    		aBoolean766 = false;
            anInt768 = 0;
            aBoolean736 = false;
            anInt774 = -1;
            anInt749 = -1;
            childrenIDs = null;
        }
    
        public static void loadConfig()
        {
    	    archive = new MemoryArchive(new ByteStream(getBuffer("loc.dat")), new ByteStream(getBuffer("loc.idx")));
            cache = new ObjectDef[20];
            for(int k = 0; k < 20; k++)
                cache[k] = new ObjectDef();	
        }
    
    	public static byte[] getBuffer(String s)
    	{
    		try {
    			java.io.File f = new java.io.File("./Data/world/object/" + s);
    			if(!f.exists())
    				return null;
    			byte[] buffer = new byte[(int) f.length()];
    			java.io.DataInputStream dis = new java.io.DataInputStream(new java.io.FileInputStream(f));
    			dis.readFully(buffer);
    			dis.close();
    			return buffer;
    		} catch(Exception e) {
    		}
    		return null;
    	}
    	
        private void readValues(ByteStreamExt stream)
        {
            int flag = -1;
    	do {
    		int type = stream.readUnsignedByte();
    		if(type == 0)
    			break;
    		if(type == 1)
    		{
    			int len = stream.readUnsignedByte();
    			if(len > 0)
    			{
    				if(anIntArray773 == null || lowMem)
    				{
    					anIntArray776 = new int[len];
                                		anIntArray773 = new int[len];
                                		for(int k1 = 0; k1 < len; k1++)
                                		{
                                    		anIntArray773[k1] = stream.readUnsignedWord();
                                    		anIntArray776[k1] = stream.readUnsignedByte();
                                		}
                            	} else
                            	{
                                		stream.currentOffset += len * 3;
                            	}
           			}
    		} else
    		if(type == 2)
    		{
    			name = stream.readString();
    		} else if (type == 3) {
    			description = stream.readBytes();
    		} else
    		if(type == 5)
    		{
    			int len = stream.readUnsignedByte();
    			if(len > 0)
    			{
    				if(anIntArray773 == null || lowMem)
    				{
    					anIntArray776 = null;
                                		anIntArray773 = new int[len];
                                		for(int l1 = 0; l1 < len; l1++)
                                    		anIntArray773[l1] = stream.readUnsignedWord();
    				} else
                            	{
                                		stream.currentOffset += len * 2;
                            	}
    			}
    		} else
    		if(type == 14)
    			anInt744 = stream.readUnsignedByte();
    		else
    		if(type == 15)
    			anInt761 = stream.readUnsignedByte();
    		else
                    if(type == 17)
                        aBoolean767 = false;
                    else
                    if(type == 18)
                        aBoolean757 = false;
                    else
                    if(type == 19)
                        hasActions = (stream.readUnsignedByte() == 1);
                    else
                    if(type == 21)
                        aBoolean762 = true;
                    else
                    if(type == 22) {
    				} else
                    if(type == 23)
                        aBoolean764 = true;
                    else
                    if(type == 24)
                    {
                        anInt781 = stream.readUnsignedWord();
                        if(anInt781 == 65535)
                            anInt781 = -1;
                    } else
                    if(type == 28)
                        anInt775 = stream.readUnsignedByte();
                    else
                    if(type == 29)
    					stream.readSignedByte();
    				else
                    if(type == 39)
    					stream.readSignedByte();
    				else
                    if(type >= 30 && type < 39)
                    {
                        if(actions == null)
                            actions = new String[5];
                        actions[type - 30] = stream.readNewString();
    					hasActions = true;
                        if(actions[type - 30].equalsIgnoreCase("hidden"))
                            actions[type - 30] = null;
                    } else
    		if(type == 40)
                    {
                        int i1 = stream.readUnsignedByte();
                        modifiedModelColors = new int[i1];
                        originalModelColors = new int[i1];
                        for(int i2 = 0; i2 < i1; i2++)
                        {
                            modifiedModelColors[i2] = stream.readUnsignedWord();
                            originalModelColors[i2] = stream.readUnsignedWord();
                        }
    
                    } else
                    if(type == 60)
                        anInt746 = stream.readUnsignedWord();
                    else
                    if(type == 62) {
    				} else
                    if(type == 64)
                        aBoolean779 = false;
                    else
                    if(type == 65)
    					stream.readUnsignedWord();
    				else
                    if(type == 66)
    					stream.readUnsignedWord();
    				else
                    if(type == 67)
    					stream.readUnsignedWord();
    				else
                    if(type == 68)
                        anInt758 = stream.readUnsignedWord();
                    else
                    if(type == 69)
                        anInt768 = stream.readUnsignedByte();
                    else
                    if(type == 70)
    					stream.readSignedWord();
    				else
                    if(type == 71)
    					stream.readSignedWord();
    				else
                    if(type == 72)
    					stream.readSignedWord();
    				else
    		if(type == 73)
                        aBoolean736 = true;
                    else
                    if(type == 74) {
            			aBoolean766 = true;
    				} else
    		if(type == 75)
    			stream.readUnsignedByte();
    		else
    		/*if(type == 77 || type == 92)
    		{
    			anInt774 = stream.readUnsignedWord();
                		if(anInt774 == 65535)
                    		anInt774 = -1;
                		anInt749 = stream.readUnsignedWord();
                		if(anInt749 == 65535)
                    		anInt749 = -1;
    			int endChild = -1;
    			if(type == 92)
    			{
    				endChild = stream.readUnsignedWord();
    				if(endChild == 65535)
    					endChild = -1;
    			}
                		int j1 = stream.readUnsignedByte();
                		childrenIDs = new int[j1 + 2];
                		for(int j2 = 0; j2 <= j1; j2++)
                		{
                    		childrenIDs[j2] = stream.readUnsignedWord();
                    		if(childrenIDs[j2] == 65535)
                        			childrenIDs[j2] = -1;
                		}
    			childrenIDs[j1 + 1] = endChild;
    		} else*/
    			if (type == 77) {
    				anInt774 = stream.readUnsignedWord();
    			if (anInt774 == 65535)
    				anInt774 = -1;
    			anInt749 = stream.readUnsignedWord();
    			if (anInt749 == 65535)
    				anInt749 = -1;
    			int j1 = stream.readUnsignedByte();
    			childrenIDs = new int[j1 + 1];
    			for (int j2 = 0; j2 <= j1; j2++) {
    				childrenIDs[j2] = stream.readUnsignedWord();
    				if (childrenIDs[j2] == 65535)
    					childrenIDs[j2] = -1;
    			}
    		}
    	} while(true);
    	if (flag == -1  && name != "null" && name != null) {
    		hasActions = anIntArray773 != null
    		&& (anIntArray776 == null || anIntArray776[0] == 10);
                hasActions = anIntArray773 != null && (anIntArray776 == null || anIntArray776[0] == 10);
                if(actions != null)
                    hasActions = true;
            }
    	if (aBoolean766) {
    		aBoolean767 = false;
    		aBoolean757 = false;
    	}
        }
    
        private ObjectDef()
        {
            type = -1;
        }
    
        public boolean hasActions()
        {
    		return hasActions;
        }
    	
    	public boolean hasName()
    	{
    		return name != null && name.length() > 1;
    	}
    
        public boolean solid()
        {
    		return aBoolean779;
        }
    	
        public int xLength()
        {
    	return anInt744;
        }
    	
        public int yLength()
        {
    	return anInt761;
        }
    	
    	public boolean aBoolean767()
    	{
    		return aBoolean767;
    	}
    
        public boolean aBoolean736;
        public String name;
        public int anInt744;
        public int anInt746;
        private int[] originalModelColors;
        public int anInt749;
        public static boolean lowMem;
        public int type;
        public boolean aBoolean757;
        public int anInt758;
        public int childrenIDs[];
        public int anInt761;
        public boolean aBoolean762;
        public boolean aBoolean764;
        public boolean aBoolean766;
        public boolean aBoolean767;
        public int anInt768;
        private static int cacheIndex;
        private int[] anIntArray773;
        public int anInt774;
        public int anInt775;
        private int[] anIntArray776;
        public byte description[];
        public boolean hasActions;
        public boolean aBoolean779;
        public int anInt781;
        private static ObjectDef[] cache;
        private int[] modifiedModelColors;
        public String actions[];
        private static MemoryArchive archive;
    
    }
    [/SPOIL]

    Server's Region:
    [SPOIL]
    Code:
    package server.clip.region;
    
    import java.io.*;
    import java.util.zip.*;
    
    
    public class Region {
    
        private void addClip(int x, int y, int height, int shift) {
            int regionAbsX = (id >> 8) * 64;
            int regionAbsY = (id & 0xff) * 64;
            if (clips[height] == null) {
                clips[height] = new int[64][64];
            }
            clips[height][x - regionAbsX][y - regionAbsY] |= shift;
        }
     
        private int getClip(int x, int y, int height) {
            int regionAbsX = (id >> 8) * 64;
            int regionAbsY = (id & 0xff) * 64;
            if (clips[height] == null) {
                return 0;
            }
            return clips[height][x - regionAbsX][y - regionAbsY];
        }
    	
        public boolean blockedNorth(int x, int y, int z) {
        	return (getClipping(x, y + 1, z) & 0x1280120) != 0;
        }
        public boolean blockedEast(int x, int y, int z) {
        	return (getClipping(x + 1, y, z) & 0x1280180) != 0;
        }
        public boolean blockedSouth(int x, int y, int z) {
        	return (getClipping(x, y - 1, z) & 0x1280102) != 0;
        }
        public boolean blockedWest(int x, int y, int z) {
        	return (getClipping(x - 1, y, z) & 0x1280108) != 0;
        }
        public boolean blockedNorthEast(int x, int y, int z) {
        	return (getClipping(x + 1, y + 1, z) & 0x12801e0) != 0;
        }
        public boolean blockedNorthWest(int x, int y, int z) {
        	return (getClipping(x - 1, y + 1, z) & 0x1280138) != 0;
        }
        public boolean blockedSouthEast(int x, int y, int z) {
        	return (getClipping(x + 1, y - 1, z) & 0x1280183) != 0;
        }
        public boolean blockedSouthWest(int x, int y, int z) {
        	return (getClipping(x - 1, y - 1, z) & 0x128010e) != 0;
        }
    	
        private static void addClipping(int x, int y, int height, int shift) {
            int regionX = x >> 3;
            int regionY = y >> 3;
            int regionId = ((regionX / 8) << 8) + (regionY / 8);
            for (Region r : regions) {
                if (r.id() == regionId) {
                    r.addClip(x, y, height, shift);
                    break;
                }
            }
        }
    
        private static Region[] regions;
        private int id;
        private int[][][] clips = new int[4][][];
    	private boolean members = false;
     
        public Region(int id) {
            this.id = id;
        }
     
        public int id() {
            return id;
        }
    	
    	public boolean members()
    	{
    		return members;
    	}
     
    	public static boolean isMembers(int x, int y, int height)
    	{
    		if(x >= 3272 && x <= 3320 && y >= 2752 && y <= 2809)
    			return false;
    		if(x >= 2640 && x <= 2677 && y >= 2638 && y <= 2679)
    			return false;
    		int regionX = x >> 3;
            int regionY = y >> 3;
            int regionId = ((regionX / 8) << 8) + (regionY / 8);
            for (Region r : regions) {
                if (r.id() == regionId) {
                    return r.members();
                }
            }
    		return false;
    	}
     
        private static void addClippingForVariableObject(int x, int y, int height, int type, int direction, boolean flag) {
            if (type == 0) {
                if (direction == 0) {
                    addClipping(x, y, height, 128);
                    addClipping(x - 1, y, height, 8);
                } else if (direction == 1) {
                    addClipping(x, y, height, 2);
                    addClipping(x, y + 1, height, 32);
                } else if (direction == 2) {
                    addClipping(x, y, height, 8);
                    addClipping(x + 1, y, height, 128);
                } else if (direction == 3) {
                    addClipping(x, y, height, 32);
                    addClipping(x, y - 1, height, 2);
                }
            } else if (type == 1 || type == 3) {
                if (direction == 0) {
                    addClipping(x, y, height, 1);
                    addClipping(x - 1, y, height, 16);
                } else if (direction == 1) {
                    addClipping(x, y, height, 4);
                    addClipping(x + 1, y + 1, height, 64);
                } else if (direction == 2) {
                    addClipping(x, y, height, 16);
                    addClipping(x + 1, y - 1, height, 1);
                } else if (direction == 3) {
                    addClipping(x, y, height, 64);
                    addClipping(x - 1, y - 1, height, 4);
                }
            } else if (type == 2) {
                if (direction == 0) {
                    addClipping(x, y, height, 130);
                    addClipping(x - 1, y, height, 8);
                    addClipping(x, y + 1, height, 32);
                } else if (direction == 1) {
                    addClipping(x, y, height, 10);
                    addClipping(x, y + 1, height, 32);
                    addClipping(x + 1, y, height, 128);
                } else if (direction == 2) {
                    addClipping(x, y, height, 40);
                    addClipping(x + 1, y, height, 128);
                    addClipping(x, y - 1, height, 2);
                } else if (direction == 3) {
                    addClipping(x, y, height, 160);
                    addClipping(x, y - 1, height, 2);
                    addClipping(x - 1, y, height, 8);
                }
            }
            if (flag) {
                if (type == 0) {
                    if (direction == 0) {
                        addClipping(x, y, height, 65536);
                        addClipping(x - 1, y, height, 4096);
                    } else if (direction == 1) {
                        addClipping(x, y, height, 1024);
                        addClipping(x, y + 1, height, 16384);
                    } else if (direction == 2) {
                        addClipping(x, y, height, 4096);
                        addClipping(x + 1, y, height, 65536);
                    } else if (direction == 3) {
                        addClipping(x, y, height, 16384);
                        addClipping(x, y - 1, height, 1024);
                    }
                }
                if (type == 1 || type == 3) {
                    if (direction == 0) {
                        addClipping(x, y, height, 512);
                        addClipping(x - 1, y + 1, height, 8192);
                    } else if (direction == 1) {
                        addClipping(x, y, height, 2048);
                        addClipping(x + 1, y + 1, height, 32768);
                    } else if (direction == 2) {
                        addClipping(x, y, height, 8192);
                        addClipping(x + 1, y + 1, height, 512);
                    } else if (direction == 3) {
                        addClipping(x, y, height, 32768);
                        addClipping(x - 1, y - 1, height, 2048);
                    }
                } else if (type == 2) {
                    if (direction == 0) {
                        addClipping(x, y, height, 66560);
                        addClipping(x - 1, y, height, 4096);
                        addClipping(x, y + 1, height, 16384);
                    } else if (direction == 1) {
                        addClipping(x, y, height, 5120);
                        addClipping(x, y + 1, height, 16384);
                        addClipping(x + 1, y, height, 65536);
                    } else if (direction == 2) {
                        addClipping(x, y, height, 20480);
                        addClipping(x + 1, y, height, 65536);
                        addClipping(x, y - 1, height, 1024);
                    } else if (direction == 3) {
                        addClipping(x, y, height, 81920);
                        addClipping(x, y - 1, height, 1024);
                        addClipping(x - 1, y, height, 4096);
                    }
                }
            }
        }
     
        private static void addClippingForSolidObject(int x, int y, int height, int xLength, int yLength, boolean flag) {
            int clipping = 256;
            if (flag) {
                clipping += 0x20000;
            }
            for (int i = x; i < x + xLength; i++) {
                for (int i2 = y; i2 < y + yLength; i2++) {
                    addClipping(i, i2, height, clipping);
                }
            }
        }
     
        public static void addObject(int objectId, int x, int y, int height, int type, int direction) {
            ObjectDef def = ObjectDef.getObjectDef(objectId);
            if (def == null) {
                return;
            }
            int xLength;
            int yLength;
            if (direction != 1 && direction != 3) {
                xLength = def.xLength();
                yLength = def.yLength();
            } else {
                xLength = def.yLength();
                yLength = def.xLength();
            }
            if (type == 22) {
                if (def.hasActions() && def.aBoolean767()) {
                    addClipping(x, y, height, 0x200000);
                }
            } else if (type >= 9) {
    			if(def.aBoolean767())
    			{
                    addClippingForSolidObject(x, y, height, xLength, yLength, def.solid());
    			}
            } else if (type >= 0 && type <= 3) {
    			if(def.aBoolean767())
    			{
                    addClippingForVariableObject(x, y, height, type, direction, def.solid());
    			}
            }
        }
     
        public static int getClipping(int x, int y, int height) {
    		if(height > 3)
    			height = 0;
            int regionX = x >> 3;
            int regionY = y >> 3;
            int regionId = ((regionX / 8) << 8) + (regionY / 8);
            for (Region r : regions) {
                if (r.id() == regionId) {
                    return r.getClip(x, y, height);
                }
            }
            return 0;
        }
    
        public static boolean getClipping(int x, int y, int height, int moveTypeX, int moveTypeY)
        {
    		try {
    		if(height > 3)
    			height = 0;
    		int checkX = (x + moveTypeX);
    		int checkY = (y + moveTypeY);
    		if(moveTypeX == -1 && moveTypeY == 0)
    			return (getClipping(x, y, height) & 0x1280108) == 0;
    		else	
    		if(moveTypeX == 1 && moveTypeY == 0)
    			return (getClipping(x, y, height) & 0x1280180) == 0;
    		else
    		if(moveTypeX == 0 && moveTypeY == -1)
    			return (getClipping(x, y, height) & 0x1280102) == 0;
    		else
    		if(moveTypeX == 0 && moveTypeY == 1)
    			return (getClipping(x, y, height) & 0x1280120) == 0;
    		else
    		if(moveTypeX == -1 && moveTypeY == -1)
    			return ((getClipping(x, y, height) & 0x128010e) == 0 && (getClipping(checkX - 1, checkY, height) & 0x1280108) == 0 && (getClipping(checkX - 1, checkY, height) & 0x1280102) == 0);
    		else
    		if(moveTypeX == 1 && moveTypeY == -1)
    			return ((getClipping(x, y, height) & 0x1280183) == 0 && (getClipping(checkX + 1, checkY, height) & 0x1280180) == 0 && (getClipping(checkX, checkY - 1, height) & 0x1280102) == 0);
    		else
    		if(moveTypeX == -1 && moveTypeY == 1)
    			return ((getClipping(x, y, height) & 0x1280138) == 0 && (getClipping(checkX - 1, checkY, height) & 0x1280108) == 0 && (getClipping(checkX, checkY + 1, height) & 0x1280120) == 0);
    		else
    		if(moveTypeX == 1 && moveTypeY == 1)
    			return ((getClipping(x, y, height) & 0x12801e0) == 0 && (getClipping(checkX + 1, checkY, height) & 0x1280180) == 0 && (getClipping(checkX, checkY + 1, height) & 0x1280120) == 0);
    		else
    		{
    			System.out.println("[FATAL ERROR]: At getClipping: "+x+", "+y+", "+height+", "+moveTypeX+", "+moveTypeY);
    			return false;
    		}
    		} catch (Exception e) { return true; }
        }
    
        public static void load() {
        	try {
    		File f = new File("./Data/world/map_index");
    		byte[] buffer = new byte[(int) f.length()];
    		DataInputStream dis = new DataInputStream(new FileInputStream(f));
    		dis.readFully(buffer);
    		dis.close();
            ByteStream in = new ByteStream(buffer);
            int size = in.length() / 7;
            regions = new Region[size];
            int[] regionIds = new int[size];
            int[] mapGroundFileIds = new int[size];
            int[] mapObjectsFileIds = new int[size];
            for (int i = 0; i < size; i++) {
                regionIds[i] = in.getUShort();
                mapGroundFileIds[i] = in.getUShort();
                mapObjectsFileIds[i] = in.getUShort();
            }
            for (int i = 0; i < size; i++) {
                regions[i] = new Region(regionIds[i]);
            }
            for (int i = 0; i < size; i++) {
                byte[] file1 = getBuffer(new File("./Data/world/map/" + mapObjectsFileIds[i] + ".gz"));
                byte[] file2 = getBuffer(new File("./Data/world/map/" + mapGroundFileIds[i] + ".gz"));
                if (file1 == null || file2 == null) {
                    continue;
                }
    			try {
    				loadMaps(regionIds[i], new ByteStream(file1), new ByteStream(file2));
    			} catch(Exception e) {
    				System.out.println("Error loading map region: " + regionIds[i]);
    			}
            }
        	} catch (Exception e) {
        		e.printStackTrace();
        	}
        }
     
        private static void loadMaps(int regionId, ByteStream str1, ByteStream str2) {
            int absX = (regionId >> 8) * 64;
            int absY = (regionId & 0xff) * 64;
            int[][][] someArray = new int[4][64][64];
            for (int i = 0; i < 4; i++) {
                for (int i2 = 0; i2 < 64; i2++) {
                    for (int i3 = 0; i3 < 64; i3++) {
                        while (true) {
                            int v = str2.getUByte();
                            if (v == 0) {
                                break;
                            } else if (v == 1) {
                                str2.skip(1);
                                break;
                            } else if (v <= 49) {
                                str2.skip(1);
                            } else if (v <= 81) {
                                someArray[i][i2][i3] = v - 49;
                            }
                        }
                    }
                }
            }
            for (int i = 0; i < 4; i++) {
                for (int i2 = 0; i2 < 64; i2++) {
                    for (int i3 = 0; i3 < 64; i3++) {
                        if ((someArray[i][i2][i3] & 1) == 1) {
                            int height = i;
                            if ((someArray[1][i2][i3] & 2) == 2) {
                                height--;
                            }
                            if (height >= 0 && height <= 3) {
                                addClipping(absX + i2, absY + i3, height, 0x200000);
                            }
                        }
                    }
                }
            }
            int objectId = -1;
            int incr;
            while ((incr = str1.getUSmart()) != 0) {
                objectId += incr;
                int location = 0;
                int incr2;
                while ((incr2 = str1.getUSmart()) != 0) {
                    location += incr2 - 1;
                    int localX = (location >> 6 & 0x3f);
                    int localY = (location & 0x3f);
                    int height = location >> 12;
                    int objectData = str1.getUByte();
                    int type = objectData >> 2;
                    int direction = objectData & 0x3;
                    if (localX < 0 || localX >= 64 || localY < 0 || localY >= 64) {
                        continue;
                    }
                    if ((someArray[1][localX][localY] & 2) == 2) {
                        height--;
                    }
                    if (height >= 0 && height <= 3) {
                        addObject(objectId, absX + localX, absY + localY, height, type, direction);
                    }
                }
            }
        }
    
        public static byte[] getBuffer(File f) throws Exception
        {
    	if(!f.exists())
    		return null;
    	byte[] buffer = new byte[(int) f.length()];
    	DataInputStream dis = new DataInputStream(new FileInputStream(f));
    	dis.readFully(buffer);
    	dis.close();
    	byte[] gzipInputBuffer = new byte[999999];
    	int bufferlength = 0;
    	GZIPInputStream gzip = new GZIPInputStream(new ByteArrayInputStream(buffer));
    	do {
    		if(bufferlength == gzipInputBuffer.length)
    		{
    			System.out.println("Error inflating data.\nGZIP buffer overflow.");
    			break;
    		}
    		int readByte = gzip.read(gzipInputBuffer, bufferlength, gzipInputBuffer.length - bufferlength);
    		if(readByte == -1)
    			break;
    		bufferlength += readByte;
    	} while(true);
    	byte[] inflated = new byte[bufferlength];
    	System.arraycopy(gzipInputBuffer, 0, inflated, 0, bufferlength);
    	buffer = inflated;
    	if(buffer.length < 10)
    		return null;
    	return buffer;
        }
    
    }
    [/SPOIL]

    Followed [Only registered and activated users can see links. ] but changing the size from 6 to 7 and versa doesn't fix the problem.
    Reply With Quote  
     

  2. #2  
    The One And Only

    01053's Avatar
    Join Date
    Apr 2011
    Age
    25
    Posts
    2,888
    Thanks given
    416
    Thanks received
    884
    Rep Power
    856
    Have you loaded the map files server-sided assuming you're using the region clipping everyone currently uses.


    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Jan 2012
    Posts
    562
    Thanks given
    43
    Thanks received
    53
    Rep Power
    72
    Quote Originally Posted by 01053 View Post
    Have you loaded the map files server-sided assuming you're using the region clipping everyone currently uses.
    Yes, used the #78 maps that my client also uses and put them in Data/world/map/
    Reply With Quote  
     

  4. #4  
    The One And Only

    01053's Avatar
    Join Date
    Apr 2011
    Age
    25
    Posts
    2,888
    Thanks given
    416
    Thanks received
    884
    Rep Power
    856
    Quote Originally Posted by V i c t o r View Post
    Yes, used the #78 maps that my client also uses and put them in Data/world/map/
    Did you also add the map_index / loc.idx / loc.dat for #78, including the #78 map models.


    Reply With Quote  
     

  5. #5  
    Banned

    Join Date
    Feb 2014
    Posts
    1,210
    Thanks given
    138
    Thanks received
    450
    Rep Power
    0
    If you've done all of the above, show us your load method in the region class
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Jan 2012
    Posts
    562
    Thanks given
    43
    Thanks received
    53
    Rep Power
    72
    Quote Originally Posted by 01053 View Post
    Did you also add the map_index / loc.idx / loc.dat for #78, including the #78 map models.
    Map models? You mean the .gz files that're supposed to be placed in Data/world/map/? I've replaced the old ones (1389 files) with the new ones (3535 files). The rest I've also replaced yes.

    Quote Originally Posted by kyoto View Post
    If you've done all of the above, show us your load method in the region class
    Code:
    public static void load() {
        	try {
    		File f = new File("./Data/world/map_index");
    		byte[] buffer = new byte[(int) f.length()];
    		DataInputStream dis = new DataInputStream(new FileInputStream(f));
    		dis.readFully(buffer);
    		dis.close();
            ByteStream in = new ByteStream(buffer);
            int size = in.length() / 7;
            regions = new Region[size];
            int[] regionIds = new int[size];
            int[] mapGroundFileIds = new int[size];
            int[] mapObjectsFileIds = new int[size];
            for (int i = 0; i < size; i++) {
                regionIds[i] = in.getUShort();
                mapGroundFileIds[i] = in.getUShort();
                mapObjectsFileIds[i] = in.getUShort();
            }
            for (int i = 0; i < size; i++) {
                regions[i] = new Region(regionIds[i]);
            }
            for (int i = 0; i < size; i++) {
                byte[] file1 = getBuffer(new File("./Data/world/map/" + mapObjectsFileIds[i] + ".gz"));
                byte[] file2 = getBuffer(new File("./Data/world/map/" + mapGroundFileIds[i] + ".gz"));
                if (file1 == null || file2 == null) {
                    continue;
                }
    			try {
    				loadMaps(regionIds[i], new ByteStream(file1), new ByteStream(file2));
    			} catch(Exception e) {
    				System.out.println("Error loading map region: " + regionIds[i]);
    			}
            }
        	} catch (Exception e) {
        		e.printStackTrace();
        	}
        }
    Quote Originally Posted by 01053 View Post
    Did you also add the map_index / loc.idx / loc.dat for #78, including the #78 map models.
    Map models? You mean the .gz files that're supposed to be placed in Data/world/map/? I've replaced the old ones (1389 files) with the new ones (3535 files). The rest I've also replaced yes.

    Quote Originally Posted by kyoto View Post
    If you've done all of the above, show us your load method in the region class
    Code:
    	public static void load() {
    		try {
    			File f = new File("./Data/world/map_index");
    			byte[] buffer = new byte[(int) f.length()];
    			DataInputStream dis = new DataInputStream(new FileInputStream(f));
    			dis.readFully(buffer);
    			dis.close();
    			ByteStream in = new ByteStream(buffer);
    			int size = in.length() / 7;
    			regions = new Region[size];
    			int[] regionIds = new int[size];
    			int[] mapGroundFileIds = new int[size];
    			int[] mapObjectsFileIds = new int[size];
    			for (int i = 0; i < size; i++) {
    				regionIds[i] = in.getUShort();
    				mapGroundFileIds[i] = in.getUShort();
    				mapObjectsFileIds[i] = in.getUShort();
    			}
    			for (int i = 0; i < size; i++) {
    				regions[i] = new Region(regionIds[i]);
    			}
    			for (int i = 0; i < size; i++) {
    				byte[] file1 = getBuffer(new File("./Data/world/map/" + mapObjectsFileIds[i] + ".gz"));
    				byte[] file2 = getBuffer(new File("./Data/world/map/" + mapGroundFileIds[i] + ".gz"));
    				if (file1 == null || file2 == null) {
    					continue;
    				}
    				try {
    					loadMaps(regionIds[i], new ByteStream(file1), new ByteStream(file2));
    				} catch (Exception e) {
    					System.out.println("Error loading map region: " + regionIds[i]);
    				}
    			}
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}
    Reply With Quote  
     

  7. #7  
    Registered Member
    Join Date
    Jan 2012
    Posts
    562
    Thanks given
    43
    Thanks received
    53
    Rep Power
    72
    Bump.
    Reply With Quote  
     

  8. #8  
    Registered Member
    Join Date
    Jan 2012
    Posts
    562
    Thanks given
    43
    Thanks received
    53
    Rep Power
    72
    Still need this.
    Reply With Quote  
     

  9. #9  
    Registered Member

    Join Date
    Dec 2013
    Posts
    858
    Thanks given
    121
    Thanks received
    138
    Rep Power
    107
    Quote Originally Posted by V i c t o r View Post
    Still need this.
    I have this done for os-pvp, although I am not releasing.
    Reply With Quote  
     

  10. #10  
    WHAT DO I PUT HERE!?

    Join Date
    Apr 2015
    Posts
    293
    Thanks given
    3
    Thanks received
    47
    Discord
    View profile
    Rep Power
    19
    Quote Originally Posted by Provider View Post
    I have this done for os-pvp, although I am not releasing.
    Then why comment?
    It's pointless, stop bragging and move on.
    Reply With Quote  
     

  11. Thankful users:


Page 1 of 3 123 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 2
    Last Post: 01-29-2014, 10:44 PM
  2. Replies: 31
    Last Post: 07-19-2011, 07:41 PM
  3. Replies: 1
    Last Post: 08-22-2009, 07:09 AM
  4. Replies: 20
    Last Post: 08-02-2009, 06:31 AM
  5. Replies: 1
    Last Post: 10-09-2008, 11:17 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •