Thread: Index Repacking

Page 1 of 22 123 11 ... LastLast
Results 1 to 10 of 211
  1. #1 Index Repacking 
    Community Veteran
    Index RepackingIndex RepackingIndex Repacking

    Galkon's Avatar
    Join Date
    Nov 2007
    Age
    12
    Posts
    7,300
    Thanks given
    1,571
    Thanks received
    2,499
    Rep Power
    5000
    For those of you who want to pack models, animations, and maps into the cache but don't know how, here are some methods I've written to make the client do it for you with one simple calling of a method.

    Add these methods in client.java:
    Spoiler for Methods:
    Code:
    	public String indexLocation(int cacheIndex, int index) {
    		return signlink.findcachedir() + "index" + cacheIndex + "/" + (index != -1 ? index + ".gz" : "");
    	}
    
    	public void repackCacheIndex(int cacheIndex) {
    		System.out.println("Started repacking index " + cacheIndex + ".");
    		int indexLength = new File(indexLocation(cacheIndex, -1)).listFiles().length;
    		File[] file = new File(indexLocation(cacheIndex, -1)).listFiles();
    		try {
    			for (int index = 0; index < indexLength; index++) {
    				int fileIndex = Integer.parseInt(getFileNameWithoutExtension(file[index].toString()));
    				byte[] data = fileToByteArray(cacheIndex, fileIndex);
    				if(data != null && data.length > 0) {
    					decompressors[cacheIndex].method234(data.length, data, fileIndex);
    					System.out.println("Repacked " + fileIndex + ".");
    				} else {
    					System.out.println("Unable to locate index " + fileIndex + ".");
    				}
    			}
    		} catch(Exception e) {
    			System.out.println("Error packing cache index " + cacheIndex + ".");
    		}
    		System.out.println("Finished repacking " + cacheIndex + ".");
    	}
    
    	public byte[] fileToByteArray(int cacheIndex, int index) {
    		try {
    			if (indexLocation(cacheIndex, index).length() <= 0 || indexLocation(cacheIndex, index) == null) {
    				return null;
    			}
    			File file = new File(indexLocation(cacheIndex, index));
    			byte[] fileData = new byte[(int)file.length()];
    			FileInputStream fis = new FileInputStream(file);
    			fis.read(fileData);
    			fis.close();
    			return fileData;
    		} catch(Exception e) {
    			return null;
    		}
    	}

    And if you need getFileNameWithoutExtension, here it is:
    Code:
    	public static String getFileNameWithoutExtension(String fileName) {
    		File tmpFile = new File(fileName);
    		tmpFile.getName();
    		int whereDot = tmpFile.getName().lastIndexOf('.');
    		if (0 < whereDot && whereDot <= tmpFile.getName().length() - 2) {
    			return tmpFile.getName().substring(0, whereDot);
    		}
    		return "";
    	}
    If you want to add models past 40k or so:
    Spoiler for Unlimiting cache size:

    Decompressor.java, replace this method:
    Code:
    	private synchronized void seekTo(RandomAccessFile randomaccessfile, int j) throws IOException {
    		try {
    			/*if (j < 0 || j > 0x3c00000) {
    				System.out.println("Badseek - pos:" + j + " len:" + randomaccessfile.length());
    				j = 0x3c00000;
    				try {
    					Thread.sleep(1000L);
    				} catch (Exception _ex) {
    				}
    			}*/
    			randomaccessfile.seek(j);
    		} catch(Exception e) {
    			e.printStackTrace();
    		}
    	}
    signlink.java, replace the top part of run() with this:
    Code:
        public void run() {
            active = true;
            String s = findcachedir();
            uid = getuid(s);
            try {
                cache_dat = new RandomAccessFile(s + "main_file_cache.dat", "rw");
                for(int j = 0; j < 5; j++) {
                    cache_idx[j] = new RandomAccessFile(s + "main_file_cache.idx" + j, "rw");
    			}
            } catch(Exception exception) {
                exception.printStackTrace();
            }


    Now if you want to repack an index:
    • Place the folder containing all the gzipped files in the cache folder.
    • Make sure the folder is called index#, so for example models would be located at "/cache/index1/#.gz".
    • In the startup method, simply call 'repackCacheIndex(#)'.

    models = index1
    animations = index2
    sounds = index3
    maps = index4

    What this will do is it will find the index directory with the gzipped files, and pack only the files in the directory, so you can also use this to repack a few models at a time.
    Last edited by Galkon; 08-07-2011 at 07:23 PM.
    "I would rather have a mind opened by wonder than one closed by belief." - Gerry Spence

    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    Reply With Quote  
     


  2. #2  
    q.q Index Repacking


    Join Date
    Dec 2010
    Posts
    6,438
    Thanks given
    1,018
    Thanks received
    3,340
    Rep Power
    4129
    Spoiler for Spoiler:
    Quote Originally Posted by Galkon View Post
    For those of you who want to pack models, animations, and maps into the cache but don't know how, here are some methods I've written to make the client do it for you with one simple calling of a method.

    Add these methods in client.java:
    Spoiler for Methods:
    Code:
    	public String indexLocation(int cacheIndex, int index) {
    		return signlink.findcachedir() + "index" + cacheIndex + "/" + (index != -1 ? index + ".gz" : "");
    	}
    
    	public void repackCacheIndex(int cacheIndex) {
    		System.out.println("Started repacking index " + cacheIndex + ".");
    		int indexLength = new File(indexLocation(cacheIndex, -1)).listFiles().length;
    		File[] file = new File(indexLocation(cacheIndex, -1)).listFiles();
    		try {
    			for (int index = 0; index < indexLength; index++) {
    				int fileIndex = Integer.parseInt(getFileNameWithoutExtension(file[index].toString()));
    				byte[] data = fileToByteArray(cacheIndex, fileIndex);
    				if(data != null && data.length > 0) {
    					decompressors[cacheIndex].method234(data.length, data, fileIndex);
    					System.out.println("Repacked " + fileIndex + ".");
    				} else {
    					System.out.println("Unable to locate index " + fileIndex + ".");
    				}
    			}
    		} catch(Exception e) {
    			System.out.println("Error packing cache index " + cacheIndex + ".");
    		}
    		System.out.println("Finished repacking " + cacheIndex + ".");
    	}
    
    	public byte[] fileToByteArray(int cacheIndex, int index) {
    		try {
    			if (indexLocation(cacheIndex, index).length() <= 0 || indexLocation(cacheIndex, index) == null) {
    				return null;
    			}
    			File file = new File(indexLocation(cacheIndex, index));
    			byte[] fileData = new byte[(int)file.length()];
    			FileInputStream fis = new FileInputStream(file);
    			fis.read(fileData);
    			fis.close();
    			return fileData;
    		} catch(Exception e) {
    			return null;
    		}
    	}

    And if you need getFileNameWithoutExtension, here it is:
    Code:
    	public static String getFileNameWithoutExtension(String fileName) {
    		File tmpFile = new File(fileName);
    		tmpFile.getName();
    		int whereDot = tmpFile.getName().lastIndexOf('.');
    		if (0 < whereDot && whereDot <= tmpFile.getName().length() - 2) {
    			return tmpFile.getName().substring(0, whereDot);
    		}
    		return "";
    	}
    If you want to add models past 40k or so:
    Spoiler for Unlimiting cache size:

    Decompressor.java, replace this method:
    Code:
    	private synchronized void seekTo(RandomAccessFile randomaccessfile, int j) throws IOException {
    		try {
    			/*if (j < 0 || j > 0x3c00000) {
    				System.out.println("Badseek - pos:" + j + " len:" + randomaccessfile.length());
    				j = 0x3c00000;
    				try {
    					Thread.sleep(1000L);
    				} catch (Exception _ex) {
    				}
    			}*/
    			randomaccessfile.seek(j);
    		} catch(Exception e) {
    			e.printStackTrace();
    		}
    	}
    signlink.java, replace the top part of run() with this:
    Code:
        public void run() {
            active = true;
            String s = findcachedir();
            uid = getuid(s);
            try {
                cache_dat = new RandomAccessFile(s + "main_file_cache.dat", "rw");
                for(int j = 0; j < 5; j++) {
                    cache_idx[j] = new RandomAccessFile(s + "main_file_cache.idx" + j, "rw");
    			}
            } catch(Exception exception) {
                exception.printStackTrace();
            }


    Now if you want to repack an index:
    • Place the folder containing all the gzipped files in the cache folder.
    • Make sure the folder is called index#, so for example models would be located at "/cache/index1/#.gz".
    • In the startup method, simply call 'repackCacheIndex(#)'.

    models = index1
    animations = index2
    maps = index4

    What this will do is it will find the index directory with the gzipped files, and pack only the files in the directory, so you can also use this to repack a few models at a time.


    Awesome, needed something like this. Thanks.
    Reply With Quote  
     

  3. #3  
    Interface Junkie Index Repacking
    Index Repacking
    Nyan's Avatar
    Join Date
    Apr 2011
    Posts
    645
    Thanks given
    35
    Thanks received
    83
    Rep Power
    56
    easy but good job
    Reply With Quote  
     

  4. #4  
    Helping around :P Index RepackingIndex RepackingIndex Repacking
    Index Repacking

    Join Date
    Feb 2011
    Age
    19
    Posts
    631
    Thanks given
    28
    Thanks received
    47
    Rep Power
    18
    Nice work Galkon once again
    Reply With Quote  
     

  5. #5  
    Community Veteran
    Index RepackingIndex RepackingIndex Repacking

    Galkon's Avatar
    Join Date
    Nov 2007
    Age
    12
    Posts
    7,300
    Thanks given
    1,571
    Thanks received
    2,499
    Rep Power
    5000
    Quote Originally Posted by Harlan View Post

    Awesome, needed something like this. Thanks.
    No need to quote, it'll never be removed .
    "I would rather have a mind opened by wonder than one closed by belief." - Gerry Spence

    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  6. #6  
    Banned Index Repacking

    Join Date
    Sep 2010
    Age
    20
    Posts
    567
    Thanks given
    147
    Thanks received
    197
    Rep Power
    0
    You're a beast, thank you
    Reply With Quote  
     

  7. #7  
    Banned Index Repacking

    Join Date
    Aug 2008
    Posts
    1,889
    Thanks given
    56
    Thanks received
    102
    Rep Power
    0
    Thank's. This is useful
    Reply With Quote  
     

  8. #8  
    If you read this you're gay! Index Repacking
    Infexis's Avatar
    Join Date
    Aug 2009
    Age
    19
    Posts
    4,559
    Thanks given
    1,161
    Thanks received
    1,172
    Rep Power
    2876
    How is it recognizing if it's a map, or if it's an animation?
    [Only registered and activated users can see links. ]
    "If you can't explain it simply, you don't understand it well enough." - Albert Einstein
    Reply With Quote  
     

  9. #9  
    .supersyn Index Repacking
    Index Repacking

    myK-'s Avatar
    Join Date
    Aug 2008
    Posts
    1,779
    Thanks given
    18
    Thanks received
    39
    Rep Power
    399
    Thanks so much needed this for the unlimiting cache.


    Quote Originally Posted by Infexis View Post
    How is it recognizing if it's a map, or if it's an animation?
    Quote Originally Posted by Galkon View Post
    Now if you want to repack an index:
    • Place the folder containing all the gzipped files in the cache folder.
    • Make sure the folder is called index#, so for example models would be located at "/cache/index1/#.gz".
    • In the startup method, simply call 'repackCacheIndex(#)'.

    models = index1
    animations = index2
    maps = index4

    What this will do is it will find the index directory with the gzipped files, and pack only the files in the directory, so you can also use this to repack a few models at a time.
    Reply With Quote  
     

  10. Thankful users:


  11. #10  
    Registered Member Index Repacking
    owner blade's Avatar
    Join Date
    Nov 2009
    Posts
    2,994
    Thanks given
    108
    Thanks received
    763
    Rep Power
    602
    thx, didnt knew how to fix badseek b4

    rofl
    Reply With Quote  
     

Page 1 of 22 12311 ... LastLast

Thread Information
Users Browsing this Thread

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

Similar Threads

  1. 634 map index for 317
    By mige5 in forum Downloads
    Replies: 222
    Last Post: 02-25-2012, 09:03 PM
  2. index?t=something
    By minutes in forum Help
    Replies: 0
    Last Post: 02-20-2011, 12:38 PM
  3. model_index archive repacking
    By Xaves in forum Help
    Replies: 9
    Last Post: 01-07-2011, 11:36 PM
  4. Repacking Data
    By Stewie in forum Help
    Replies: 1
    Last Post: 05-02-2010, 07:45 AM
  5. Index Help
    By Streetwave in forum Help
    Replies: 6
    Last Post: 10-21-2009, 12:38 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
  •