Thread: Partly refactored 812

Page 1 of 2 12 LastLast
Results 1 to 10 of 19
  1. #1 Partly refactored 812 
    Renown Programmer


    Join Date
    Jul 2009
    Posts
    1,846
    Thanks given
    69
    Thanks received
    1,113
    Rep Power
    3170
    Might be useful to some of you guys that are doing rs3.

    Disclaimer:
    Refactoring was done by multiple people over time, it is very possible that some of it may be incorrect.




    ->download<-



    p.s. 99% of the 'multipliers', dummy methods/arguments, are removed, and code looks really clean.
    also: field reordering was performed based on their initialization order, so that related fields are usually declared near each other.
    example:
    Code:
    /* ItemDefinitions - Decompiled by JODE
     * Visit http://jode.sourceforge.net/
     */
    import java.util.Arrays;
    
    public class ItemDefinition implements Definition {
    	int if_model;
    	ItemDefinitionLoader loader;
    	int id;
    	public int[] quests;
    	short[] recol_s;
    	short[] recol_d;
    	public String[] iop;
    	short[] retex_s;
    	byte[] aByteArray7758;
    	byte[] aByteArray7759;
    	int[] manskeletons;
    	short[] retex_d;
    	int[] countobj;
    	int[] countco;
    	public String[] op;
    	int[] womanskeletons;
    	byte[] recol_d_pallete;
    	IterableNodeMap params;
    	public int anInt7817;
    	public int anInt0001 = -1;
    	public String name = "null";
    	public int zoom2d = 2000;
    	public int xan2d = 0;
    	public int yan2d = 0;
    	public int zan2d = 0;
    	public int xof2d = 0;
    	public int yof2d = 0;
    	public int stackable = 0;
    	public int multistacksize = -1;
    	public int cost = 1;
    	public boolean members = false;
    	public int equip_slot = -1;
    	public int equip_flags = -1;
    	public int anInt7776 = -1;
    	int manmodel1 = -1;
    	int manmodel2 = -1;
    	int womanmodel1 = -1;
    	int womanmodel2 = -1;
    	int equip_color1 = -1;
    	int equip_color2 = -1;
    	int manwearxoff = 0;
    	int womanwearxoff = 0;
    	int manwearyoff = 0;
    	int womanwearyoff = 0;
    	int manwearzoff = 0;
    	int womanwearzoff = 0;
    	int manhead = -1;
    	int manhead2 = -1;
    	int womanhead = -1;
    	int womanhead2 = -1;
    	public int certLink = -1;
    	public int certTemplate = -1;
    	int lentLink = -1;
    	public int lentTemplate = -1;
    	public int unknownLink = -1;
    	public int unknownTemplate = -1;
    	String aString7767 = "null";
    	public int anInt7762 = 0;
    	int resizex = 128;
    	int resizey = 128;
    	int resizez = 128;
    	int ambient = 0;
    	int contrast = 0;
    	public int team = 0;
    	public boolean stockmarket = false;
    	public int dummyitem = 0;
    	public int picksizeshift = 0;
    	int boughtLink = -1;
    	public int boughtTemplate = -1;
    	public boolean aBool7773 = false;
    	public boolean aBool7818 = false;
    	public static short[] aShortArray7747 = new short[256];
    	static String aString7819 = "</col>";
    
    	ItemDefinition() {
    		/* empty */
    	}
    
    	public int manskeleton(int i) {
    		if (manskeletons == null)
    			return -1;
    		return manskeletons[i];
    	}
    
    	public ItemDefinition forAmt(int amt) {
    		if (countobj != null && amt > 1) {
    			int best = -1;
    			for (int i_1_ = 0; i_1_ < 10; i_1_++) {
    				if (amt >= countco[i_1_] && countco[i_1_] != 0)
    					best = countobj[i_1_];
    			}
    			if (best != -1)
    				return loader.get(best);
    		}
    		return this;
    	}
    
    	public int womanskeleton(int i) {
    		if (womanskeletons == null)
    			return -1;
    		return womanskeletons[i];
    	}
    
    	public final Model getModel(boolean female, ItemDefRecolor recolor) {
    		int head1;
    		int head2;
    		if (female) {
    			if (recolor != null && recolor.womanHeads != null) {
    				head1 = recolor.womanHeads[0];
    				head2 = recolor.womanHeads[1];
    			}
    			else {
    				head1 = womanhead;
    				head2 = womanhead2;
    			}
    		}
    		else if (recolor != null && recolor.manHeads != null) {
    			head1 = recolor.manHeads[0];
    			head2 = recolor.manHeads[1];
    		}
    		else {
    			head1 = manhead;
    			head2 = manhead2;
    		}
    		if (head1 == -1)
    			return null;
    		Model mhead1 = Model.load(loader.fs7, head1, 0);
    		if (mhead1.anInt1247 < 13)
    			mhead1.method1899(2);
    		if (head2 != -1) {
    			Model mhead2 = Model.load(loader.fs7, head2, 0);
    			if (mhead2.anInt1247 < 13)
    				mhead2.method1899(2);
    			Model[] mheads = { mhead1, mhead2 };
    			mhead1 = new Model(mheads, 2);
    		}
    		if (recol_s != null) {
    			short[] recolor_;
    			if (recolor != null && recolor.recol_d != null)
    				recolor_ = recolor.recol_d;
    			else
    				recolor_ = recol_d;
    			for (int i = 0; i < recol_s.length; i++)
    				mhead1.method1895(recol_s[i], recolor_[i]);
    		}
    		if (retex_s != null) {
    			short[] retex_;
    			if (recolor != null && recolor.retex_d != null)
    				retex_ = recolor.retex_d;
    			else
    				retex_ = retex_d;
    			for (int i_5_ = 0; i_5_ < retex_s.length; i_5_++)
    				mhead1.method1940(retex_s[i_5_], retex_[i_5_]);
    		}
    		return mhead1;
    	}
    
    	public final boolean method12989(boolean bool, ItemDefRecolor class634) {
    		int i;
    		int i_6_;
    		int i_7_;
    		if (bool) {
    			if (class634 != null && class634.anIntArray7954 != null) {
    				i = class634.anIntArray7954[0];
    				i_6_ = class634.anIntArray7954[1];
    				i_7_ = class634.anIntArray7954[2];
    			}
    			else {
    				i = womanmodel1;
    				i_6_ = womanmodel2;
    				i_7_ = equip_color2;
    			}
    		}
    		else if (class634 != null && class634.anIntArray7958 != null) {
    			i = class634.anIntArray7958[0];
    			i_6_ = class634.anIntArray7958[1];
    			i_7_ = class634.anIntArray7958[2];
    		}
    		else {
    			i = manmodel1;
    			i_6_ = manmodel2;
    			i_7_ = equip_color1;
    		}
    		if (i == -1)
    			return true;
    		boolean bool_8_ = true;
    		if (!loader.fs7.load(i, 0))
    			bool_8_ = false;
    		if (i_6_ != -1 && !loader.fs7.load(i_6_, 0))
    			bool_8_ = false;
    		if (i_7_ != -1 && !loader.fs7.load(i_7_, 0))
    			bool_8_ = false;
    		return bool_8_;
    	}
    
    	public final boolean modelsReady(boolean female, ItemDefRecolor recolor) {
    		int head1;
    		int head2;
    		if (female) {
    			if (recolor != null && recolor.womanHeads != null) {
    				head1 = recolor.womanHeads[0];
    				head2 = recolor.womanHeads[1];
    			}
    			else {
    				head1 = womanhead;
    				head2 = womanhead2;
    			}
    		}
    		else if (recolor != null && recolor.manHeads != null) {
    			head1 = recolor.manHeads[0];
    			head2 = recolor.manHeads[1];
    		}
    		else {
    			head1 = manhead;
    			head2 = manhead2;
    		}
    		if (head1 == -1)
    			return true;
    		boolean has = true;
    		if (!loader.fs7.load(head1, 0))
    			has = false;
    		if (head2 != -1 && !loader.fs7.load(head2, 0))
    			has = false;
    		return has;
    	}
    
    	public int convertAttribute(int i) {
    		if(i == 4084)
    			i = 4329;
    		else if(i == 4085)
    			i = 4330;
    		else if(i == 4086)
    			i = 4332;
    		else if(i == 4087)
    			i = 4333;
    		else if(i == 4088)
    			i = 4334;
    		return i;
    	}
    	
    	public int intAttribute(int id, int default_) {
    		if (params == null)
    			return default_;
    		id = convertAttribute(id);
    		IntNode v = (IntNode) params.get(id);
    		if (v == null)
    			return default_;
    		return v.intval;
    	}
    
    	public String stringAttribute(int id, String default_) {
    		if (params == null)
    			return default_;
    		id = convertAttribute(id);
    		ObjectNode v = (ObjectNode) params.get(id);
    		if (v == null)
    			return default_;
    		return (String) v.objval;
    	}
    
    	public final Model method13008(boolean bool, ItemDefRecolor class634) {
    		int i;
    		int i_12_;
    		int i_13_;
    		if (bool) {
    			if (class634 != null && class634.anIntArray7954 != null) {
    				i = class634.anIntArray7954[0];
    				i_12_ = class634.anIntArray7954[1];
    				i_13_ = class634.anIntArray7954[2];
    			}
    			else {
    				i = womanmodel1;
    				i_12_ = womanmodel2;
    				i_13_ = equip_color2;
    			}
    		}
    		else if (class634 != null && class634.anIntArray7958 != null) {
    			i = class634.anIntArray7958[0];
    			i_12_ = class634.anIntArray7958[1];
    			i_13_ = class634.anIntArray7958[2];
    		}
    		else {
    			i = manmodel1;
    			i_12_ = manmodel2;
    			i_13_ = equip_color1;
    		}
    		if (i == -1)
    			return null;
    		Model class87 = Model.load(loader.fs7, i, 0);
    		if (class87 == null)
    			return null;
    		if (class87.anInt1247 < 13)
    			class87.method1899(2);
    		if (i_12_ != -1) {
    			Model class87_14_ = Model.load(loader.fs7, i_12_, 0);
    			if (class87_14_.anInt1247 < 13)
    				class87_14_.method1899(2);
    			if (i_13_ != -1) {
    				Model class87_15_ = Model.load(loader.fs7, i_13_, 0);
    				if (class87_15_.anInt1247 < 13)
    					class87_15_.method1899(2);
    				Model[] class87s = { class87, class87_14_, class87_15_ };
    				class87 = new Model(class87s, 3);
    			}
    			else {
    				Model[] class87s = { class87, class87_14_ };
    				class87 = new Model(class87s, 2);
    			}
    		}
    		if (!bool && (manwearxoff != 0 || manwearyoff != 0 || manwearzoff != 0))
    			class87.method1916(manwearxoff, manwearyoff, manwearzoff);
    		if (bool && (womanwearxoff != 0 || womanwearyoff != 0 || womanwearzoff != 0))
    			class87.method1916(womanwearxoff, womanwearyoff, womanwearzoff);
    		if (recol_s != null) {
    			short[] is;
    			if (class634 != null && class634.recol_d != null)
    				is = class634.recol_d;
    			else
    				is = recol_d;
    			for (int i_16_ = 0; i_16_ < recol_s.length; i_16_++)
    				class87.method1895(recol_s[i_16_], is[i_16_]);
    		}
    		if (retex_s != null) {
    			short[] is;
    			if (class634 != null && class634.retex_d != null)
    				is = class634.retex_d;
    			else
    				is = retex_d;
    			for (int i_17_ = 0; i_17_ < retex_s.length; i_17_++)
    				class87.method1940(retex_s[i_17_], is[i_17_]);
    		}
    		return class87;
    	}
    
    	public final Class101 method13038(GraphicsToolkit class105, int i, int i_18_, Class459 class459, Class642 class642, int i_19_, int i_20_, int i_21_, int i_22_) {
    		if (countobj != null && i_18_ > 1) {
    			int i_23_ = -1;
    			for (int i_24_ = 0; i_24_ < 10; i_24_++) {
    				if (i_18_ >= countco[i_24_] && countco[i_24_] != 0)
    					i_23_ = countobj[i_24_];
    			}
    			if (i_23_ != -1)
    				return loader.get(i_23_).method13038(class105, i, 1, class459, class642, i_19_, i_20_, i_21_, i_22_);
    		}
    		int i_25_ = i;
    		if (class642 != null)
    			i_25_ |= class642.method13342();
    		Class101 class101;
    		synchronized (loader.aClass134_7827) {
    			class101 = (Class101) loader.aClass134_7827.get_(id | class105.toolkit_id << 29);
    		}
    		if (class101 == null || class105.method2641(class101.method2253(), i_25_) != 0) {
    			if (class101 != null)
    				i_25_ = class105.method2456(i_25_, class101.method2253());
    			int i_26_ = i_25_;
    			if (retex_s != null)
    				i_26_ |= 0x8000;
    			if (recol_s != null || class459 != null)
    				i_26_ |= 0x4000;
    			if (resizex != 128)
    				i_26_ |= 0x1;
    			if (resizey != 128)
    				i_26_ |= 0x2;
    			if (resizez != 128)
    				i_26_ |= 0x4;
    			Model class87 = Model.load(loader.fs7, if_model, 0);
    			if (class87 == null)
    				return null;
    			if (class87.anInt1247 < 13)
    				class87.method1899(2);
    			class101 = class105.method2454(class87, i_26_, loader.anInt7831, ambient + 64, contrast + 850);
    			if (resizex != 128 || resizey != 128 || resizez != 128)
    				class101.method2303(resizex, resizey, resizez);
    			if (recol_s != null) {
    				for (int i_27_ = 0; i_27_ < recol_s.length; i_27_++) {
    					if (recol_d_pallete != null && i_27_ < recol_d_pallete.length)
    						class101.method2305(recol_s[i_27_], aShortArray7747[recol_d_pallete[i_27_] & 0xff]);
    					else
    						class101.method2305(recol_s[i_27_], recol_d[i_27_]);
    				}
    			}
    			if (retex_s != null) {
    				for (int i_28_ = 0; i_28_ < retex_s.length; i_28_++)
    					class101.method2215(retex_s[i_28_], retex_d[i_28_]);
    			}
    			if (class459 != null) {
    				for (int i_29_ = 0; i_29_ < 10; i_29_++) {
    					for (int i_30_ = 0; i_30_ < ParticleSetting.aShortArrayArray8761[i_29_].length; i_30_++) {
    						if (class459.anIntArray4963[i_29_] < Class459.aShortArrayArrayArray4967[i_29_][i_30_].length)
    							class101.method2305(ParticleSetting.aShortArrayArray8761[i_29_][i_30_], Class459.aShortArrayArrayArray4967[i_29_][i_30_][class459.anIntArray4963[i_29_]]);
    					}
    				}
    			}
    			class101.method2317(i_25_);
    			synchronized (loader.aClass134_7827) {
    				loader.aClass134_7827.put_(class101, id | class105.toolkit_id << 29);
    			}
    		}
    		if (class642 != null || i_22_ != 0) {
    			class101 = class101.method2173((byte) 1, i_25_, true);
    			if (class642 != null)
    				class642.method13284(class101, 0);
    			if (i_22_ != 0)
    				class101.method2170(i_19_, i_20_, i_21_, i_22_);
    		}
    		class101.method2317(i);
    		return class101;
    	}
    
    	void postDecode() {
    		/* empty */
    	}
    
    	void decode(RSByteBuffer rsbytebuffer) {
    		for (;;) {
    			int i = rsbytebuffer.readUnsignedByte();
    			if (i == 0)
    				break;
    			decodeOp(rsbytebuffer, i);
    		}
    	}
    
    	void decodeOp(RSByteBuffer buf, int opcode) {
    		if (opcode == 1)
    			if_model = buf.readUnsignedSmart32_ex();
    		else if (opcode == 2)
    			name = buf.readString();
    		else if (opcode == 4)
    			zoom2d = buf.readUnsignedShort();
    		else if (opcode == 5)
    			xan2d = buf.readUnsignedShort();
    		else if (opcode == 6)
    			yan2d = buf.readUnsignedShort();
    		else if (opcode == 7) {
    			xof2d = buf.readUnsignedShort();
    			if (xof2d > 32767)
    				xof2d -= 65536;
    		}
    		else if (opcode == 8) {
    			yof2d = buf.readUnsignedShort();
    			if (yof2d > 32767)
    				yof2d -= 65536;
    		}
    		else if (opcode == 11)
    			stackable = 1;
    		else if (opcode == 12)
    			cost = buf.readInt();
    		else if (opcode == 13)
    			equip_slot = buf.readUnsignedByte();
    		else if (opcode == 14)
    			equip_flags = buf.readUnsignedByte();
    		else if (opcode == 16)
    			members = true;
    		else if (opcode == 18)
    			multistacksize = buf.readUnsignedShort();
    		else if (opcode == 23)
    			manmodel1 = buf.readUnsignedSmart32_ex();
    		else if (opcode == 24)
    			manmodel2 = buf.readUnsignedSmart32_ex();
    		else if (opcode == 25)
    			womanmodel1 = buf.readUnsignedSmart32_ex();
    		else if (opcode == 26)
    			womanmodel2 = buf.readUnsignedSmart32_ex();
    		else if (opcode == 27)
    			anInt7776 = buf.readUnsignedByte();
    		else if (opcode >= 30 && opcode < 35)
    			op[opcode - 30] = buf.readString();
    		else if (opcode >= 35 && opcode < 40)
    			iop[opcode - 35] = buf.readString();
    		else if (opcode == 40) {
    			int i_31_ = buf.readUnsignedByte();
    			recol_s = new short[i_31_];
    			recol_d = new short[i_31_];
    			for (int i_32_ = 0; i_32_ < i_31_; i_32_++) {
    				recol_s[i_32_] = (short) buf.readUnsignedShort();
    				recol_d[i_32_] = (short) buf.readUnsignedShort();
    			}
    		}
    		else if (opcode == 41) {
    			int i_33_ = buf.readUnsignedByte();
    			retex_s = new short[i_33_];
    			retex_d = new short[i_33_];
    			for (int i_34_ = 0; i_34_ < i_33_; i_34_++) {
    				retex_s[i_34_] = (short) buf.readUnsignedShort();
    				retex_d[i_34_] = (short) buf.readUnsignedShort();
    			}
    		}
    		else if (opcode == 42) {
    			int i_35_ = buf.readUnsignedByte();
    			recol_d_pallete = new byte[i_35_];
    			for (int i_36_ = 0; i_36_ < i_35_; i_36_++)
    				recol_d_pallete[i_36_] = buf.readByte();
    		}
    		else if (opcode == 43) {
    			anInt7817 = buf.readInt();
    			aBool7773 = true;
    		}
    		else if (opcode == 44) {
    			int i_37_ = buf.readUnsignedShort();
    			int i_38_ = 0;
    			for (int i_39_ = i_37_; i_39_ > 0; i_39_ >>= 1)
    				i_38_++;
    			aByteArray7758 = new byte[i_38_];
    			byte i_40_ = 0;
    			for (int i_41_ = 0; i_41_ < i_38_; i_41_++) {
    				if ((i_37_ & 1 << i_41_) > 0) {
    					aByteArray7758[i_41_] = i_40_;
    					i_40_++;
    				}
    				else
    					aByteArray7758[i_41_] = (byte) -1;
    			}
    		}
    		else if (opcode == 45) {
    			int i_42_ = buf.readUnsignedShort();
    			int i_43_ = 0;
    			for (int i_44_ = i_42_; i_44_ > 0; i_44_ >>= 1)
    				i_43_++;
    			aByteArray7759 = new byte[i_43_];
    			byte i_45_ = 0;
    			for (int i_46_ = 0; i_46_ < i_43_; i_46_++) {
    				if ((i_42_ & 1 << i_46_) > 0) {
    					aByteArray7759[i_46_] = i_45_;
    					i_45_++;
    				}
    				else
    					aByteArray7759[i_46_] = (byte) -1;
    			}
    		}
    		else if (opcode == 65)
    			stockmarket = true;
    		else if (opcode == 78)
    			equip_color1 = buf.readUnsignedSmart32_ex();
    		else if (opcode == 79)
    			equip_color2 = buf.readUnsignedSmart32_ex();
    		else if (opcode == 90)
    			manhead = buf.readUnsignedSmart32_ex();
    		else if (opcode == 91)
    			womanhead = buf.readUnsignedSmart32_ex();
    		else if (opcode == 92)
    			manhead2 = buf.readUnsignedSmart32_ex();
    		else if (opcode == 93)
    			womanhead2 = buf.readUnsignedSmart32_ex();
    		else if (opcode == 94)
    			anInt0001 = buf.readUnsignedShort();
    		else if (opcode == 95)
    			zan2d = buf.readUnsignedShort();
    		else if (opcode == 96)
    			dummyitem = buf.readUnsignedByte();
    		else if (opcode == 97)
    			certLink = buf.readUnsignedShort();
    		else if (opcode == 98)
    			certTemplate = buf.readUnsignedShort();
    		else if (opcode >= 100 && opcode < 110) {
    			if (countobj == null) {
    				countobj = new int[10];
    				countco = new int[10];
    			}
    			countobj[opcode - 100] = buf.readUnsignedShort();
    			countco[opcode - 100] = buf.readUnsignedShort();
    		}
    		else if (opcode == 110)
    			resizex = buf.readUnsignedShort();
    		else if (opcode == 111)
    			resizey = buf.readUnsignedShort();
    		else if (opcode == 112)
    			resizez = buf.readUnsignedShort();
    		else if (opcode == 113)
    			ambient = buf.readByte();
    		else if (opcode == 114)
    			contrast = buf.readByte() * 5;
    		else if (opcode == 115)
    			team = buf.readUnsignedByte();
    		else if (opcode == 121)
    			lentLink = buf.readUnsignedShort();
    		else if (opcode == 122)
    			lentTemplate = buf.readUnsignedShort();
    		else if (opcode == 125) {
    			manwearxoff = buf.readByte() << 2;
    			manwearyoff = buf.readByte() << 2;
    			manwearzoff = buf.readByte() << 2;
    		}
    		else if (opcode == 126) {
    			womanwearxoff = buf.readByte() << 2;
    			womanwearyoff = buf.readByte() << 2;
    			womanwearzoff = buf.readByte() << 2;
    		}
    		else if (opcode == 127 || opcode == 128 || opcode == 129 || opcode == 130) {
    			buf.readUnsignedByte();
    			buf.readUnsignedShort();
    		}
    		else if (opcode == 132) {
    			int i_47_ = buf.readUnsignedByte();
    			quests = new int[i_47_];
    			for (int i_48_ = 0; i_48_ < i_47_; i_48_++)
    				quests[i_48_] = buf.readUnsignedShort();
    		}
    		else if (opcode == 134)
    			picksizeshift = buf.readUnsignedByte();
    		else if (opcode == 139)
    			boughtLink = buf.readUnsignedShort();
    		else if (opcode == 140)
    			boughtTemplate = buf.readUnsignedShort();
    		else if (opcode >= 142 && opcode < 147) {
    			if (manskeletons == null) {
    				manskeletons = new int[6];
    				Arrays.fill(manskeletons, -1);
    			}
    			manskeletons[opcode - 142] = buf.readUnsignedShort();
    		}
    		else if (opcode >= 150 && opcode < 155) {
    			if (womanskeletons == null) {
    				womanskeletons = new int[5];
    				Arrays.fill(womanskeletons, -1);
    			}
    			womanskeletons[opcode - 150] = buf.readUnsignedShort();
    		}
    		else if (opcode != 156) {
    			if (opcode == 157)
    				aBool7818 = true;
    			else if (opcode == 161)
    				unknownLink = buf.readUnsignedShort();
    			else if (opcode == 162)
    				unknownTemplate = buf.readUnsignedShort();
    			else if (opcode == 163)
    				anInt7762 = buf.readUnsignedShort();
    			else if (opcode == 164)
    				aString7767 = buf.readString();
    			else if (opcode == 165)
    				stackable = 2;
    			else if (opcode == 249) {
    				int i_49_ = buf.readUnsignedByte();
    				if (params == null) {
    					int i_50_ = IterableNodeMap.bestKeyIndexSize(i_49_);
    					params = new IterableNodeMap(i_50_);
    				}
    				for (int i_51_ = 0; i_51_ < i_49_; i_51_++) {
    					boolean bool = buf.readUnsignedByte() == 1;
    					int i_52_ = buf.readUnsignedMedInt();
    					Node node;
    					if (bool)
    						node = new ObjectNode(buf.readString());
    					else
    						node = new IntNode(buf.readInt());
    					params.put(node, i_52_);
    				}
    			}
    		}
    	}
    
    	void method12980(int[] is, int i) {
    		for (int i_53_ = 31; i_53_ > 0; i_53_--) {
    			int i_54_ = i_53_ * 36;
    			for (int i_55_ = 35; i_55_ > 0; i_55_--) {
    				if (is[i_54_ + i_55_] == 0 && is[i_55_ + i_54_ - 1 - 36] != 0)
    					is[i_55_ + i_54_] = i;
    			}
    		}
    	}
    
    	void genCert(ItemDefinition template, ItemDefinition link) {
    		copyFrom(ItemDefCopyType.aClass635_7962, template, link, null);
    	}
    
    	void genBought(ItemDefinition template, ItemDefinition link) {
    		copyFrom(ItemDefCopyType.aClass635_7961, template, link, Message.DISCARD_1);
    	}
    
    	void genUnknown(ItemDefinition template, ItemDefinition link) {
    		copyFrom(ItemDefCopyType.aClass635_7959, template, link, Message.DROP);
    	}
    
    	void genLent(ItemDefinition template, ItemDefinition link) {
    		copyFrom(ItemDefCopyType.aClass635_7960, template, link, Message.DISCARD_2);
    	}
    
    	int[] method13025(int[] is, int i) {
    		int[] is_64_ = new int[1152];
    		int i_65_ = 0;
    		for (int i_66_ = 0; i_66_ < 32; i_66_++) {
    			for (int i_67_ = 0; i_67_ < 36; i_67_++) {
    				int i_68_ = is[i_65_];
    				if (i_68_ == 0) {
    					if (i_67_ > 0 && is[i_65_ - 1] != 0)
    						i_68_ = i;
    					else if (i_66_ > 0 && is[i_65_ - 36] != 0)
    						i_68_ = i;
    					else if (i_67_ < 35 && is[i_65_ + 1] != 0)
    						i_68_ = i;
    					else if (i_66_ < 31 && is[i_65_ + 36] != 0)
    						i_68_ = i;
    				}
    				is_64_[i_65_++] = i_68_;
    			}
    		}
    		return is_64_;
    	}
    
    	void copyFrom(ItemDefCopyType type, ItemDefinition template, ItemDefinition link, Message msg) {
    		if_model = template.if_model;
    		zoom2d = template.zoom2d;
    		xan2d = template.xan2d;
    		yan2d = template.yan2d;
    		zan2d = template.zan2d;
    		xof2d = template.xof2d;
    		yof2d = template.yof2d;
    		ItemDefinition b = type == ItemDefCopyType.aClass635_7962 ? template : link;
    		recol_s = b.recol_s;
    		recol_d = b.recol_d;
    		recol_d_pallete = b.recol_d_pallete;
    		retex_s = b.retex_s;
    		retex_d = b.retex_d;
    		name = link.name;
    		members = link.members;
    		if (ItemDefCopyType.aClass635_7962 == type) {
    			cost = link.cost;
    			stackable = 1;
    		}
    		else if (type == ItemDefCopyType.aClass635_7959) {
    			name = link.aString7767;
    			cost = (int) Math.floor(link.cost / link.anInt7762);
    			stackable = 1;
    			stockmarket = link.stockmarket;
    			anInt0001 = template.anInt0001;
    			manskeletons = template.manskeletons;
    			womanskeletons = template.womanskeletons;
    			iop = new String[5];
    			iop[0] = Message.aClass638_7983.translate(loader.lang);
    			iop[4] = msg.translate(loader.lang);
    		}
    		else {
    			cost = 0;
    			stackable = link.stackable;
    			equip_slot = link.equip_slot;
    			equip_flags = link.equip_flags;
    			anInt7776 = link.anInt7776;
    			manmodel1 = link.manmodel1;
    			manmodel2 = link.manmodel2;
    			equip_color1 = link.equip_color1;
    			womanmodel1 = link.womanmodel1;
    			womanmodel2 = link.womanmodel2;
    			equip_color2 = link.equip_color2;
    			manwearxoff = link.manwearxoff;
    			womanwearxoff = link.womanwearxoff;
    			manwearyoff = link.manwearyoff;
    			womanwearyoff = link.womanwearyoff;
    			manwearzoff = link.manwearzoff;
    			womanwearzoff = link.womanwearzoff;
    			manhead = link.manhead;
    			manhead2 = link.manhead2;
    			womanhead = link.womanhead;
    			womanhead2 = link.womanhead2;
    			anInt0001 = link.anInt0001;
    			team = link.team;
    			op = link.op;
    			params = link.params;
    			iop = new String[5];
    			if (link.iop != null) {
    				for (int i = 0; i < 4; i++)
    					iop[i] = link.iop[i];
    			}
    			iop[4] = msg.translate(loader.lang);
    		}
    	}
    
    	int[] method13039(GraphicsToolkit class105, GraphicsToolkit class105_72_, int i, int i_73_, int i_74_, boolean bool, int i_75_, Class90 class90, Class459 class459, GameDefaults class516) {
    		Model class87 = Model.load(loader.fs7, if_model, 0);
    		if (class87 == null)
    			return null;
    		if (class87.anInt1247 < 13)
    			class87.method1899(2);
    		if (recol_s != null) {
    			for (int i_76_ = 0; i_76_ < recol_s.length; i_76_++) {
    				if (recol_d_pallete != null && i_76_ < recol_d_pallete.length)
    					class87.method1895(recol_s[i_76_], aShortArray7747[recol_d_pallete[i_76_] & 0xff]);
    				else
    					class87.method1895(recol_s[i_76_], recol_d[i_76_]);
    			}
    		}
    		if (retex_s != null) {
    			for (int i_77_ = 0; i_77_ < retex_s.length; i_77_++)
    				class87.method1940(retex_s[i_77_], retex_d[i_77_]);
    		}
    		if (class459 != null) {
    			for (int i_78_ = 0; i_78_ < 10; i_78_++) {
    				for (int i_79_ = 0; i_79_ < ParticleSetting.aShortArrayArray8761[i_78_].length; i_79_++) {
    					if (class459.anIntArray4963[i_78_] < Class459.aShortArrayArrayArray4967[i_78_][i_79_].length)
    						class87.method1895(ParticleSetting.aShortArrayArray8761[i_78_][i_79_], Class459.aShortArrayArrayArray4967[i_78_][i_79_][class459.anIntArray4963[i_78_]]);
    				}
    			}
    		}
    		int i_80_ = 2048;
    		boolean bool_81_ = false;
    		if (resizex != 128 || resizey != 128 || resizez != 128) {
    			bool_81_ = true;
    			i_80_ |= 0x7;
    		}
    		Class101 class101 = class105.method2454(class87, i_80_, 64, ambient + 64, contrast + 768);
    		if (!class101.method2224())
    			return null;
    		if (bool_81_)
    			class101.method2303(resizex, resizey, resizez);
    		AbstractSprite class167 = null;
    		if (certTemplate != -1) {
    			class167 = loader.method13065(class105, class105_72_, certLink, 10, 1, 0, true, true, 0, class90, class459, class516);
    			if (class167 == null)
    				return null;
    		}
    		else if (lentTemplate != -1) {
    			class167 = loader.method13065(class105, class105_72_, lentLink, i, i_73_, i_74_, false, true, 0, class90, class459, class516);
    			if (class167 == null)
    				return null;
    		}
    		else if (boughtTemplate != -1) {
    			class167 = loader.method13065(class105, class105_72_, boughtLink, i, i_73_, i_74_, false, true, 0, class90, class459, class516);
    			if (class167 == null)
    				return null;
    		}
    		else if (unknownTemplate != -1) {
    			class167 = loader.method13065(class105, class105_72_, unknownLink, 10, 1, 0, true, true, 0, class90, class459, class516);
    			if (class167 == null)
    				return null;
    		}
    		int i_82_;
    		if (bool)
    			i_82_ = (int) (zoom2d * 1.5) << 2;
    		else if (i_73_ == 2)
    			i_82_ = (int) (zoom2d * 1.04) << 2;
    		else
    			i_82_ = zoom2d << 2;
    		Class319 class319 = class105.method2464();
    		Class319 class319_83_ = class105.method2451();
    		class319_83_.method5651(16.0F, 16.0F, 512.0F, 512.0F, 50.0F, 2.14748365E9F, class105.method2390().method1872(), class105.method2390().method1873());
    		class105.method2463(class319_83_);
    		class105.method2407(0, 0, class105.method2390().method1872(), class105.method2390().method1873());
    		TransformationMatrix class206 = new TransformationMatrix();
    		class105.method2460(class206);
    		class105.method2592((float) (Math.random() / 10.0) + 0.95F);
    		class105.method2466(16777215, (float) (Math.random() / 10.0) + 0.95F, (float) (Math.random() / 10.0) + 0.95F, -50.0F, -10.0F, -50.0F);
    		TransformationMatrix class206_84_ = class105.method2724();
    		class206_84_.method4107(0.0F, 0.0F, 1.0F, SineTable.method4187(-zan2d << 3));
    		class206_84_.method4111(0.0F, 1.0F, 0.0F, SineTable.method4187(yan2d << 3));
    		class206_84_.translate(xof2d << 2, (SineTable.sine[xan2d << 3] * i_82_ >> 14) - class101.method2202() / 2 + (yof2d << 2), (yof2d << 2) + (SineTable.cosine[xan2d << 3] * i_82_ >> 14));
    		class206_84_.method4111(1.0F, 0.0F, 0.0F, SineTable.method4187(xan2d << 3));
    		class105.method2740(0, 0, 36, 32);
    		class105.method2415(2, 0);
    		class105.method2423(0, 0, 36, 32, 0, 0);
    		class105.method2468(0, -1, 0);
    		class101.method2310(class206_84_, null, 1);
    		class105.method2463(class319);
    		int[] is = class105.method2426(0, 0, 36, 32);
    		if (i_73_ >= 1) {
    			is = method13025(is, -16777214);
    			if (i_73_ >= 2)
    				is = method13025(is, -1);
    		}
    		if (i_74_ != 0)
    			method12980(is, i_74_);
    		if (lentTemplate != -1)
    			class167.method3525(0, 0);
    		else if (boughtTemplate != -1)
    			class167.method3525(0, 0);
    		class105.method2442(is, 0, 36, 36, 32).method3525(0, 0);
    		if (certTemplate != -1)
    			class167.method3525(0, 0);
    		if (unknownTemplate != -1)
    			class167.method3525(0, 0);
    		if (i_75_ == 1 || i_75_ == 2 && (stackable == 1 || i != 1) && i != -1)
    			class90.method1981(Class540.method11551(i, loader.lang, class516), 0, 9, -256, -16777215);
    		is = class105.method2426(0, 0, 36, 32);
    		for (int i_85_ = 0; i_85_ < is.length; i_85_++) {
    			if ((is[i_85_] & 0xffffff) == 0)
    				is[i_85_] = 0;
    			else
    				is[i_85_] |= ~0xffffff;
    		}
    		return is;
    	}
    
    	public static final void method13043() {
    		String string = NodeMapIterator.aString8211 != null ? NodeMapIterator.aString8211 : Class221_Sub4.method15578();
    		Class412.method7041(string, false, client.aBool8418);
    	}
    }
    Code:
    /* RSByteBuffer - Decompiled by JODE
     * Visit http://jode.sourceforge.net/
     */
    import java.math.BigInteger;
    
    public class RSByteBuffer extends Node {
    	public byte[] buffer;
    	public int offset;
    	static Js5FileSystem aClass223_8919;
    	static int[] crctable = new int[256];
    	public static long[] aLongArray8911;
    
    	static {
    		for (int i = 0; i < 256; i++) {
    			int i_0_ = i;
    			for (int i_1_ = 0; i_1_ < 8; i_1_++) {
    				if ((i_0_ & 0x1) == 1)
    					i_0_ = i_0_ >>> 1 ^ ~0x12477cdf;
    				else
    					i_0_ >>>= 1;
    			}
    			crctable[i] = i_0_;
    		}
    		aLongArray8911 = new long[256];
    		for (int i = 0; i < 256; i++) {
    			long l = i;
    			for (int i_2_ = 0; i_2_ < 8; i_2_++) {
    				if (1L == (l & 0x1L))
    					l = l >>> 1 ^ ~0x3693a86a2878f0bdL;
    				else
    					l >>>= 1;
    			}
    			aLongArray8911[i] = l;
    		}
    	}
    
    	public RSByteBuffer(byte[] is) {
    		buffer = is;
    		offset = 0;
    	}
    
    	public RSByteBuffer(int i) {
    		buffer = PooledBuffers.allocPooledBuffer(i);
    		offset = 0;
    	}
    
    	public RSByteBuffer(int i, boolean bool) {
    		buffer = PooledBuffers.allocPooledBuffer(i, bool);
    	}
    
    	public int readUnsignedShort() {
    		offset += 2;
    		return (buffer[offset - 1] & 0xff) + ((buffer[offset - 2] & 0xff) << 8);
    	}
    
    	public int readUnsignedShortLE() {
    		offset += 2;
    		return (buffer[offset - 2] & 0xff) + ((buffer[offset - 1] & 0xff) << 8);
    	}
    
    	public int readInt() {
    		offset += 4;
    		return (buffer[offset - 1] & 0xff) + ((buffer[offset - 2] & 0xff) << 8) + ((buffer[offset - 4] & 0xff) << 24) + ((buffer[offset - 3] & 0xff) << 16);
    	}
    
    	public long read5Byte() {
    		long l = readUnsignedByte() & 0xffffffffL;
    		long l_3_ = readInt() & 0xffffffffL;
    		return l_3_ + (l << 32);
    	}
    
    	public long readLong() {
    		long l = readInt() & 0xffffffffL;
    		long l_4_ = readInt() & 0xffffffffL;
    		return l_4_ + (l << 32);
    	}
    
    	public String readString() {
    		int i = offset;
    		while (buffer[offset++] != 0) {
    			/* empty */
    		}
    		int i_5_ = offset - i - 1;
    		if (i_5_ == 0)
    			return "";
    		return Class519.decodeString(buffer, i, i_5_);
    	}
    
    	public int readUnsignedByte128() {
    		return buffer[offset++] - 128 & 0xff;
    	}
    
    	public int readSignedMedInt() {
    		offset += 3;
    		int i = (buffer[offset - 1] & 0xff) + ((buffer[offset - 2] & 0xff) << 8) + ((buffer[offset - 3] & 0xff) << 16);
    		if (i > 8388607)
    			i -= 16777216;
    		return i;
    	}
    
    	public byte readByte128() {
    		return (byte) (buffer[offset++] - 128);
    	}
    
    	public byte readByteC() {
    		return (byte) (0 - buffer[offset++]);
    	}
    
    	public int readUnsignedShort128() {
    		offset += 2;
    		return (buffer[offset - 1] - 128 & 0xff) + ((buffer[offset - 2] & 0xff) << 8);
    	}
    
    	public int readUnsignedShortLE128() {
    		offset += 2;
    		return ((buffer[offset - 1] & 0xff) << 8) + (buffer[offset - 2] - 128 & 0xff);
    	}
    
    	public int readUnsignedByteC() {
    		return 0 - buffer[offset++] & 0xff;
    	}
    
    	public int readIntLE() {
    		offset += 4;
    		return ((buffer[offset - 2] & 0xff) << 16) + ((buffer[offset - 1] & 0xff) << 24) + ((buffer[offset - 3] & 0xff) << 8) + (buffer[offset - 4] & 0xff);
    	}
    
    	public int readUnsigned128Byte() {
    		return 128 - buffer[offset++] & 0xff;
    	}
    
    	public int readIntV2() {
    		offset += 4;
    		return ((buffer[offset - 4] & 0xff) << 16) + ((buffer[offset - 3] & 0xff) << 24) + ((buffer[offset - 1] & 0xff) << 8) + (buffer[offset - 2] & 0xff);
    	}
    
    	public int readUnsignedByte() {
    		return buffer[offset++] & 0xff;
    	}
    
    	public byte readByte() {
    		return buffer[offset++];
    	}
    
    	public byte read128Byte() {
    		return (byte) (128 - buffer[offset++]);
    	}
    
    	public int readIntV1() {
    		offset += 4;
    		return ((buffer[offset - 2] & 0xff) << 24) + ((buffer[offset - 1] & 0xff) << 16) + ((buffer[offset - 4] & 0xff) << 8) + (buffer[offset - 3] & 0xff);
    	}
    
    	public void deallocPooled() {
    		if (buffer != null)
    			PooledBuffers.deallocPooledBuffer(buffer);
    		buffer = null;
    	}
    
    	public int readSignedShort() {
    		offset += 2;
    		int i = (buffer[offset - 1] & 0xff) + ((buffer[offset - 2] & 0xff) << 8);
    		if (i > 32767)
    			i -= 65536;
    		return i;
    	}
    
    	public int method14501() {
    		offset += 4;
    		return (buffer[offset - 4] & 0xff) + ((buffer[offset - 1] & 0xff) << 24) + ((buffer[offset - 2] & 0xff) << 16) + ((buffer[offset - 3] & 0xff) << 8);
    	}
    
    	public long read6Byte() {
    		long l = readUnsignedShort() & 0xffffffffL;
    		long l_6_ = readInt() & 0xffffffffL;
    		return (l << 32) + l_6_;
    	}
    
    	public float readFloat() {
    		return Float.intBitsToFloat(readInt());
    	}
    
    	public String readNullString() {
    		if (buffer[offset] == 0) {
    			++offset;
    			return null;
    		}
    		return readString();
    	}
    
    	public int readSignedSmart() {
    		int i = buffer[offset] & 0xff;
    		if (i < 128)
    			return readUnsignedByte() - 64;
    		return readUnsignedShort() - 49152;
    	}
    
    	public int readUnsignedSmart_ex() {
    		int i = buffer[offset] & 0xff;
    		if (i < 128)
    			return readUnsignedByte() - 1;
    		return readUnsignedShort() - 32769;
    	}
    
    	public int readSum() {
    		int sum = 0;
    		int x;
    		for (x = readUnsignedSmart(); x == 32767; x = readUnsignedSmart())
    			sum += 32767;
    		sum += x;
    		return sum;
    	}
    
    	public int readUnsignedSmart32() {
    		if (buffer[offset] < 0)
    			return readInt() & 0x7fffffff;
    		return readUnsignedShort();
    	}
    
    	public int readUnsignedSmart32_ex() {
    		if (buffer[offset] < 0)
    			return readInt() & 0x7fffffff;
    		int i = readUnsignedShort();
    		if (i == 32767)
    			return -1;
    		return i;
    	}
    
    	public boolean read_crc_check() {
    		offset -= 4;
    		int crc = RSByteBuffer.crc32(buffer, 0, offset);
    		int expected = readInt();
    		if (expected == crc)
    			return true;
    		return false;
    	}
    
    	public int method14540() {
    		offset += 2;
    		int i = (buffer[offset - 2] & 0xff) + ((buffer[offset - 1] & 0xff) << 8);
    		if (i > 32767)
    			i -= 65536;
    		return i;
    	}
    
    	public int method14542() {
    		offset += 2;
    		int i = ((buffer[offset - 1] & 0xff) << 8) + (buffer[offset - 2] - 128 & 0xff);
    		if (i > 32767)
    			i -= 65536;
    		return i;
    	}
    
    	public int readUnsignedMedInt() {
    		offset += 3;
    		return ((buffer[offset - 2] & 0xff) << 8) + ((buffer[offset - 3] & 0xff) << 16) + (buffer[offset - 1] & 0xff);
    	}
    
    	public int method14583() {
    		offset += 2;
    		int i = ((buffer[offset - 2] & 0xff) << 8) + (buffer[offset - 1] - 128 & 0xff);
    		if (i > 32767)
    			i -= 65536;
    		return i;
    	}
    
    	public int readUnsignedSmart() {
    		int i = buffer[offset] & 0xff;
    		if (i < 128)
    			return readUnsignedByte();
    		return readUnsignedShort() - 32768;
    	}
    
    	public String readVersionedString() {
    		byte i = buffer[offset++];
    		if (i != 0)
    			throw new IllegalStateException("");
    		int i_9_ = offset;
    		while (buffer[offset++] != 0) {
    			/* empty */
    		}
    		int i_10_ = offset - i_9_ - 1;
    		if (i_10_ == 0)
    			return "";
    		return Class519.decodeString(buffer, i_9_, i_10_);
    	}
    
    	public String readXString() {
    		byte versionNumber = buffer[offset++];
    		if (versionNumber != 0)
    			throw new IllegalStateException("");
    		int len = xStringLen();
    		if (len + offset > buffer.length)
    			throw new IllegalStateException("");
    		String str = SeekableFile.decodeXString(buffer, offset, len);
    		offset += len;
    		return str;
    	}
    
    	public void writeByte(int i) {
    		buffer[offset++] = (byte) i;
    	}
    
    	public void writeInt(int i) {
    		buffer[offset++] = (byte) (i >> 24);
    		buffer[offset++] = (byte) (i >> 16);
    		buffer[offset++] = (byte) (i >> 8);
    		buffer[offset++] = (byte) i;
    	}
    
    	public void write6Byte(long l) {
    		buffer[offset++] = (byte) (int) (l >> 40);
    		buffer[offset++] = (byte) (int) (l >> 32);
    		buffer[offset++] = (byte) (int) (l >> 24);
    		buffer[offset++] = (byte) (int) (l >> 16);
    		buffer[offset++] = (byte) (int) (l >> 8);
    		buffer[offset++] = (byte) (int) l;
    	}
    
    	public void writeString(String string) {
    		int i = string.indexOf('\0');
    		if (i >= 0)
    			throw new IllegalArgumentException("");
    		offset += Class641.encodeString(string, 0, string.length(), buffer, offset);
    		buffer[offset++] = (byte) 0;
    	}
    
    	public void writeByteC(int i) {
    		buffer[offset++] = (byte) (0 - i);
    	}
    
    	public void writeLong(long l) {
    		buffer[offset++] = (byte) (int) (l >> 56);
    		buffer[offset++] = (byte) (int) (l >> 48);
    		buffer[offset++] = (byte) (int) (l >> 40);
    		buffer[offset++] = (byte) (int) (l >> 32);
    		buffer[offset++] = (byte) (int) (l >> 24);
    		buffer[offset++] = (byte) (int) (l >> 16);
    		buffer[offset++] = (byte) (int) (l >> 8);
    		buffer[offset++] = (byte) (int) l;
    	}
    
    	public void write5Byte(long l) {
    		buffer[offset++] = (byte) (int) (l >> 32);
    		buffer[offset++] = (byte) (int) (l >> 24);
    		buffer[offset++] = (byte) (int) (l >> 16);
    		buffer[offset++] = (byte) (int) (l >> 8);
    		buffer[offset++] = (byte) (int) l;
    	}
    
    	public void writeIntV1(int i) {
    		buffer[offset++] = (byte) (i >> 8);
    		buffer[offset++] = (byte) i;
    		buffer[offset++] = (byte) (i >> 24);
    		buffer[offset++] = (byte) (i >> 16);
    	}
    
    	public void writeShort(int i) {
    		buffer[offset++] = (byte) (i >> 8);
    		buffer[offset++] = (byte) i;
    	}
    
    	public void writeShortLE128(int i) {
    		buffer[offset++] = (byte) (i + 128);
    		buffer[offset++] = (byte) (i >> 8);
    	}
    
    	public void write128Byte(int i) {
    		buffer[offset++] = (byte) (128 - i);
    	}
    
    	public void method14476(int i) {
    		buffer[offset - i - 2] = (byte) (i >> 8);
    		buffer[offset - i - 1] = (byte) i;
    	}
    
    	public void writeMedInt(int i) {
    		buffer[offset++] = (byte) (i >> 16);
    		buffer[offset++] = (byte) (i >> 8);
    		buffer[offset++] = (byte) i;
    	}
    
    	public void method14480(int i) {
    		buffer[offset++] = (byte) i;
    		buffer[offset++] = (byte) (i >> 8);
    		buffer[offset++] = (byte) (i >> 16);
    		buffer[offset++] = (byte) (i >> 24);
    	}
    
    	public long readDynamic(int nBytes) {
    		if (--nBytes < 0 || nBytes > 7)
    			throw new IllegalArgumentException();
    		int nBits = nBytes * 8;
    		long l = 0L;
    		for (/**/; nBits >= 0; nBits -= 8)
    			l |= (buffer[offset++] & 0xffL) << nBits;
    		return l;
    	}
    
    	public void writeVersionedString(String string) {
    		int i = string.indexOf('\0');
    		if (i >= 0)
    			throw new IllegalArgumentException("");
    		buffer[offset++] = (byte) 0;
    		offset += Class641.encodeString(string, 0, string.length(), buffer, offset);
    		buffer[offset++] = (byte) 0;
    	}
    
    	public void writeXStr(CharSequence charsequence) {
    		int xstrlen = Class469_Sub2.xstrlen(charsequence);
    		buffer[offset++] = (byte) 0;
    		writeVarSized(xstrlen);
    		offset += Class449.encodeXStr(buffer, offset, charsequence);
    	}
    
    	public void method14489(int i) {
    		buffer[offset++] = (byte) i;
    		buffer[offset++] = (byte) (i >> 8);
    	}
    
    	public void method14491(int i) {
    		buffer[offset - i - 1] = (byte) i;
    	}
    
    
    
    	public void writeByte128(int i) {
    		buffer[offset++] = (byte) (i + 128);
    	}
    
    	public void writeShortLE(int i) {
    		buffer[offset++] = (byte) i;
    		buffer[offset++] = (byte) (i >> 8);
    	}
    
    	public void writeShort128(int i) {
    		buffer[offset++] = (byte) (i >> 8);
    		buffer[offset++] = (byte) (i + 128);
    	}
    
    	public void method14543(int i) {
    		buffer[offset++] = (byte) i;
    		buffer[offset++] = (byte) (i >> 8);
    		buffer[offset++] = (byte) (i >> 16);
    	}
    
    	public void writeIntV2(int i) {
    		buffer[offset++] = (byte) (i >> 16);
    		buffer[offset++] = (byte) (i >> 24);
    		buffer[offset++] = (byte) i;
    		buffer[offset++] = (byte) (i >> 8);
    	}
    
    	public void method14558(int i) {
    		buffer[offset++] = (byte) (i >> 16);
    		buffer[offset++] = (byte) i;
    		buffer[offset++] = (byte) (i >> 8);
    	}
    
    	public void method14581(int i) {
    		buffer[offset++] = (byte) i;
    		buffer[offset++] = (byte) (i >> 8);
    		buffer[offset++] = (byte) (i >> 16);
    		buffer[offset++] = (byte) (i >> 24);
    	}
    
    	public int writeCrcCheck(int offset_) {
    		int crc = RSByteBuffer.crc32(buffer, offset_, offset);
    		writeInt(crc);
    		return crc;
    	}
    
    	public void writeSmart(int v) {
    		if (v >= 0 && v < 128)
    			writeByte(v);
    		else if (v >= 0 && v < 32768)
    			writeShort(v + 32768);
    		else
    			throw new IllegalArgumentException();
    	}
    
    
    
    	public void writeBuffer(RSByteBuffer b) {
    		writeBytes(b.buffer, 0, b.offset);
    	}
    
    	public void writeDynamic(long v, int nbytes) {
    		if (--nbytes < 0 || nbytes > 7)
    			throw new IllegalArgumentException();
    		for (int nbits = nbytes * 8; nbits >= 0; nbits -= 8)
    			buffer[offset++] = (byte) (int) (v >> nbits);
    	}
    
    	public void cryptRsa(BigInteger public_exp, BigInteger modulus) {
    		int length = offset;
    		offset = 0;
    		byte[] crypt_in = new byte[length];
    		readBytes(crypt_in, 0, length);
    		byte[] crypt_out = new BigInteger(crypt_in).modPow(public_exp, modulus).toByteArray();
    		offset = 0;
    		writeShort(crypt_out.length);
    		writeBytes(crypt_out, 0, crypt_out.length);
    	}
    
    	public void writeBytes(byte[] buff, int offs, int len) {
    		for (int i = offs; i < len + offs; i++)
    			buffer[offset++] = buff[i];
    	}
    	
    	public void xteaEncrypt(int[] keys) {
    		int cycles = offset / 8;
    		offset = 0;
    		for (int i = 0; i < cycles; i++) {
    			int a = readInt();
    			int b = readInt();
    			int c = 0;
    			int d = -1640531527;
    			int rounds = 32;
    			while (rounds-- > 0) {
    				a += (b << 4 ^ b >>> 5) + b ^ keys[c & 0x3] + c;
    				c += d;
    				b += a + (a << 4 ^ a >>> 5) ^ keys[c >>> 11 & 0x3] + c;
    			}
    			offset -= 8;
    			writeInt(a);
    			writeInt(b);
    		}
    	}
    	
    	public void xteaDecrypt(int[] keys) {
    		int cycles = offset / 8;
    		offset = 0;
    		for (int i = 0; i < cycles; i++) {
    			int a = readInt();
    			int b = readInt();
    			int d = -957401312;
    			int c = -1640531527;
    			int rounds = 32;
    			while (rounds-- > 0) {
    				b -= a + (a << 4 ^ a >>> 5) ^ d + keys[d >>> 11 & 0x3];
    				d -= c;
    				a -= (b << 4 ^ b >>> 5) + b ^ keys[d & 0x3] + d;
    			}
    			offset -= 8;
    			writeInt(a);
    			writeInt(b);
    		}
    	}
    
    	public void xteaEncrypt(int[] keys, int offs, int length) {
    		int prev = offset;
    		offset = offs;
    		int cycles = (length - offs) / 8;
    		for (int i = 0; i < cycles; i++) {
    			int a = readInt();
    			int b = readInt();
    			int c = 0;
    			int d = -1640531527;
    			int rounds = 32;
    			while (rounds-- > 0) {
    				a += b + (b << 4 ^ b >>> 5) ^ c + keys[c & 0x3];
    				c += d;
    				b += (a << 4 ^ a >>> 5) + a ^ c + keys[c >>> 11 & 0x3];
    			}
    			offset -= 8;
    			writeInt(a);
    			writeInt(b);
    		}
    		offset = prev;
    	}
    	
    	public void xteaDecrypt(int[] keys, int offs, int length) {
    		int prev = offset;
    		offset = offs;
    		int cycles = (length - offs) / 8;
    		for (int i = 0; i < cycles; i++) {
    			int a = readInt();
    			int b = readInt();
    			int c = -957401312;
    			int d = -1640531527;
    			int rounds = 32;
    			while (rounds-- > 0) {
    				b -= a + (a << 4 ^ a >>> 5) ^ keys[c >>> 11 & 0x3] + c;
    				c -= d;
    				a -= b + (b << 4 ^ b >>> 5) ^ keys[c & 0x3] + c;
    			}
    			offset -= 8;
    			writeInt(a);
    			writeInt(b);
    		}
    		offset = prev;
    	}
    
    	public void readReverseBytes(byte[] buff, int offs, int length) {
    		for (int i = offs + length - 1; i >= offs; i--)
    			buff[i] = (byte) (buffer[offset++] - 128);
    	}
    
    	public void readBytes(byte[] buff, int offs, int length) {
    		for (int i = offs; i < offs + length; i++)
    			buff[i] = buffer[offset++];
    	}
    
    
    
    	int xStringLen() {
    		int i = buffer[offset++];
    		int i_56_ = 0;
    		for (/**/; i < 0; i = buffer[offset++])
    			i_56_ = (i_56_ | i & 0x7f) << 7;
    		return i_56_ | i;
    	}
    
    	void writeVarSized(int i) {
    		if ((i & ~0x7f) != 0) {
    			if ((i & ~0x3fff) != 0) {
    				if ((i & ~0x1fffff) != 0) {
    					if ((i & ~0xfffffff) != 0)
    						writeByte(i >>> 28 | 0x80);
    					writeByte(i >>> 21 | 0x80);
    				}
    				writeByte(i >>> 14 | 0x80);
    			}
    			writeByte(i >>> 7 | 0x80);
    		}
    		writeByte(i & 0x7f);
    	}
    
    
    	public static int crc32(byte[] data, int length) {
    		return crc32(data, 0, length);
    	}
    	
    	public static int crc32(byte[] data, int offset, int length) {
    		int crc = -1;
    		for (int i = offset; i < length; i++)
    			crc = crc >>> 8 ^ crctable[(crc ^ data[i]) & 0xff];
    		crc ^= 0xffffffff;
    		return crc;
    	}
    
    	static final void method14716(CS2Executor cs2executor) {
    		int i = cs2executor.intStack[--cs2executor.intStackPtr];
    		InterfaceComponent class76 = TextureLoader.method3677(i);
    		Class576_Sub41.method15347(class76, cs2executor);
    	}
    
    	static Class374 method14717(int i) {
    		if (Class374.aClass374_4324.anInt4326 == i)
    			return Class374.aClass374_4324;
    		if (Class374.aClass374_4323.anInt4326 == i)
    			return Class374.aClass374_4323;
    		if (i == Class374.aClass374_4325.anInt4326)
    			return Class374.aClass374_4325;
    		return null;
    	}
    }
    Reply With Quote  
     


  2. #2  
    Registered Member
    Join Date
    Oct 2012
    Posts
    1,279
    Thanks given
    331
    Thanks received
    257
    Rep Power
    69
    Phew, must have taken awhile. Thanks for your dedication and contribution; you don't often see people with both of them. Nice work.
    Reply With Quote  
     

  3. #3  
    Banned

    Join Date
    Jan 2012
    Age
    25
    Posts
    2,703
    Thanks given
    906
    Thanks received
    630
    Rep Power
    0
    Nice release . I hope there will be more RS3 servers soon!
    Reply With Quote  
     

  4. Thankful user:


  5. #4  
    Registered Member
    Join Date
    Sep 2013
    Posts
    105
    Thanks given
    13
    Thanks received
    28
    Rep Power
    10
    You beast. Definitely checking this out.
    Reply With Quote  
     

  6. #5  
    Computer Engineer
    Join Date
    Aug 2014
    Posts
    1,051
    Thanks given
    365
    Thanks received
    215
    Rep Power
    16
    Nice contribution.
    Reply With Quote  
     

  7. #6  
    Chemist

    Advocatus's Avatar
    Join Date
    Dec 2009
    Posts
    2,622
    Thanks given
    201
    Thanks received
    813
    Rep Power
    1462
    Thanks for this. Will be useful.
    Quote Originally Posted by blakeman8192 View Post
    Quitting is the only true failure.
    Reply With Quote  
     

  8. #7  
    Registered Member

    Join Date
    Oct 2012
    Posts
    1,461
    Thanks given
    560
    Thanks received
    323
    Rep Power
    122
    Nice, good release.

    “I have not failed. I've just found 10,000 ways that won't work.”
    ― Thomas A. Edison


    Attached image


    Reply With Quote  
     

  9. #8  
    Registered Member
    Join Date
    May 2011
    Age
    29
    Posts
    2,246
    Thanks given
    2,469
    Thanks received
    1,120
    Rep Power
    943
    Thank you, mirrored.
    Reply With Quote  
     

  10. #9  
    Registered Member Atrium's Avatar
    Join Date
    Apr 2013
    Posts
    295
    Thanks given
    43
    Thanks received
    41
    Rep Power
    0
    Mgi is bae, superb release. Thanks!
    Reply With Quote  
     

  11. #10  
    Registered Member

    Join Date
    Jan 2014
    Posts
    595
    Thanks given
    328
    Thanks received
    231
    Rep Power
    153
    You got the cache?




    Reply With Quote  
     

  12. Thankful user:


Page 1 of 2 12 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: 0
    Last Post: 02-08-2010, 11:36 PM
  2. Recoloring as many parts of an item as you want
    By Scottyz in forum Tutorials
    Replies: 4
    Last Post: 01-08-2008, 01:30 AM
  3. Replies: 10
    Last Post: 09-21-2007, 02:40 AM
  4. ice arrows cast ice barrage (part 1)
    By rukia in forum Tutorials
    Replies: 19
    Last Post: 09-12-2007, 02:00 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •