Thread: ObjectDef packing

Results 1 to 3 of 3
  1. #1 ObjectDef packing 
    Derp.
    BenjaR's Avatar
    Join Date
    May 2008
    Age
    26
    Posts
    2,086
    Thanks given
    167
    Thanks received
    125
    Rep Power
    915
    So I wanna re-pack my object def, I had slight success in that I ended up with an idx the right size, but a dat 3 times larger which didn't work :\

    If anyone has a working packer or can fix mine please do so

    Currently:
    Code:
    	public static void pack() {
    		try {
    			Stream dat = new Stream(new byte[9999999]);
    			java.io.DataOutputStream idx = new java.io.DataOutputStream(new java.io.FileOutputStream("loc.idx"));
    			idx.writeShort(streamIndices.length);
    			dat.writeWord(streamIndices.length);
    			for (int i = 0; i < streamIndices.length; i++) {
    				System.out.println("dumping obj " + i);
    				ObjectDef def = forID(i);
    				int offset1 = dat.buffer.toString().length();
    				for (int j = 0; j < 78; j++) {
    					dat.writeWordBigEndian(j);
    					if (j == 1) {
    						if (def.anIntArray773 != null && def.anIntArray773.length > 0
    								&& def.anIntArray776 != null && def.anIntArray776.length > 0) {
    							dat.writeWordBigEndian(def.anIntArray773.length);
    							for (int k1 = 0; k1 < def.anIntArray773.length; k1++) {
    								dat.writeWord(def.anIntArray773[k1] == -1 ? 0 : def.anIntArray773[k1]);
    								dat.writeWordBigEndian(def.anIntArray776[k1] == -1 ? 0 : def.anIntArray776[k1]);
    							}
    						} else
    							dat.writeWordBigEndian(0);
    					} else if (j == 2)
    						dat.writeString(def.name == null ? "" : def.name);
    					else if (j == 3) {
    						if (def.description != null && def.description.length > 0)
    							dat.writeBytes(def.description, def.description.length, 0);
    						else
    							dat.writeBytes("".getBytes(), "".getBytes().length, 0);
    					} else if (j == 5)
    						if (def.anIntArray773 != null && def.anIntArray773.length > 0) {
    							dat.writeWordBigEndian(def.anIntArray773.length);
    							for (int l1 = 0; l1 < def.anIntArray773.length; l1++)
    								dat.writeWord(def.anIntArray773[l1]);
    						} else
    							dat.writeWordBigEndian(0);
    					else if (j == 14)
    						dat.writeWordBigEndian(def.anInt744);
    					else if (j == 15)
    						dat.writeWordBigEndian(def.anInt761);
    					else if (j == 19)
    						dat.writeWordBigEndian(def.hasActions ? 1 : 0);
    					else if (j == 24)
    						dat.writeWord(def.anInt781 == -1 ? 65535 : def.anInt781);
    					else if (j == 28)
    						dat.writeWordBigEndian(def.anInt775);
    					else if (j == 29)
    						dat.writeWordBigEndian(def.aByte737);
    					else if (j == 39)
    						dat.writeWordBigEndian(def.aByte742);
    					else if (j >= 30 && j < 39) {
    						if (def.actions != null && def.actions.length > (j - 30))
    							dat.writeString(def.actions[j - 30] == null ? "hidden" : def.actions[j - 30]);
    						else
    							continue;
    					} else if (j == 40) {
    						if (def.modifiedModelColors != null && def.modifiedModelColors.length > 0) {
    							dat.writeWord(def.modifiedModelColors.length);
    							for (int i2 = 0; i2 < def.modifiedModelColors.length; i2++) {
    								dat.writeWord(def.modifiedModelColors[i2]);
    								dat.writeWord(def.originalModelColors[i2]);
    							}
    						} else
    							dat.writeWord(0);
    
    					} else if (j == 60)
    						dat.writeWord(def.anInt746);
    					else if (j == 65)
    						dat.writeWord(def.anInt748);
    					else if (j == 66)
    						dat.writeWord(def.anInt772);
    					else if (j == 67)
    						dat.writeWord(def.anInt740);
    					else if (j == 68)
    						dat.writeWord(def.anInt758);
    					else if (j == 69)
    						dat.writeWordBigEndian(def.anInt768);
    					else if (j == 70)
    						dat.writeWord(def.anInt738);
    					else if (j == 71)
    						dat.writeWord(def.anInt745);
    					else if (j == 72)
    						dat.writeWord(def.anInt760);
    					else {
    						if (j != 75)
    							continue;
    						dat.writeWordBigEndian(def.anInt760);
    					}
    				}
    
    				dat.writeWord(def.anInt774 == -1 ? 65535 : def.anInt774);
    
    				dat.writeWord(def.anInt749 == -1 ? 65535 : def.anInt749);
    
    				if (def.childrenIDs != null && def.childrenIDs.length > 1) {
    					dat.writeWordBigEndian(def.childrenIDs.length - 1);
    					for (int j2 = 0; j2 <= def.childrenIDs.length - 1; j2++)
    							dat.writeWord(def.childrenIDs[j2] == -1 ? 65535 : def.childrenIDs[j2]);
    				} else
    					dat.writeWordBigEndian(0);
    
    				dat.writeWordBigEndian(0);
    				int offset2 = dat.buffer.toString().length();
    				int writeOffset = offset2 - offset1;
    				idx.writeShort(writeOffset);
    			}
    			java.io.DataOutputStream dos = new java.io.DataOutputStream(new java.io.FileOutputStream("loc.dat"));
    			dos.write(dat.buffer, 0, dat.currentOffset);
    			dos.close();
    			idx.close();
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}
    Reply With Quote  
     

  2. #2  
    Banned

    Join Date
    Oct 2010
    Posts
    1,731
    Thanks given
    56
    Thanks received
    97
    Rep Power
    0
    I might have this but what file is this method located at?
    Reply With Quote  
     

  3. #3  
    Derp.
    BenjaR's Avatar
    Join Date
    May 2008
    Age
    26
    Posts
    2,086
    Thanks given
    167
    Thanks received
    125
    Rep Power
    915
    ObjectDef.. that's what I'm trying to pack so ?
    Reply With Quote  
     


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. ObjectDef Class Refactoring
    By Xaves in forum RS2 Client
    Replies: 27
    Last Post: 10-24-2010, 06:40 PM
  2. 508 Objectdef
    By jordan641 in forum Requests
    Replies: 0
    Last Post: 08-28-2010, 11:03 AM
  3. packing
    By Leanbow in forum Help
    Replies: 0
    Last Post: 05-16-2010, 03:43 PM
  4. Replies: 109
    Last Post: 06-26-2009, 06:22 PM
  5. Objectdef 500+
    By Clienthax in forum Requests
    Replies: 1
    Last Post: 09-25-2008, 10:06 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
  •