Thread: Dumping Unique Sprite Cache

Results 1 to 8 of 8
  1. #1 Dumping Unique Sprite Cache 
    Jake from State Farm

    FKN Jake's Avatar
    Join Date
    Nov 2013
    Posts
    675
    Thanks given
    45
    Thanks received
    58
    Rep Power
    153
    Usually its sprites.dat + sprites.idx but this is how it is set up:

    Attached image

    I've been looking for hours but no luck so far lol..

    Need to dump and repack.

    When running client the console prints:

    Code:
    Total sprites in firstsprites: 1223
    Total sprites in thirdsprites: 45
    Client loads/works fine.
    Reply With Quote  
     

  2. #2  
    Banned

    Join Date
    Jul 2009
    Posts
    3,999
    Thanks given
    1,003
    Thanks received
    1,028
    Rep Power
    0
    Galkons cache sprite tool, not sure if it works straight off the bat.
    Reply With Quote  
     

  3. #3  
    Rune-Server Affiliate

    Join Date
    Apr 2014
    Posts
    1,761
    Thanks given
    75
    Thanks received
    714
    Rep Power
    1073
    show the class that loads the files
    Reply With Quote  
     

  4. #4  
    Jake from State Farm

    FKN Jake's Avatar
    Join Date
    Nov 2013
    Posts
    675
    Thanks given
    45
    Thanks received
    58
    Rep Power
    153
    Quote Originally Posted by Zion View Post
    show the class that loads the files
    Code:
    public final class CacheSpriteLoader {
    
        private static final List<Integer> cachedSpriteIdList = new ArrayList<>();
        private static final HashMap<Integer, byte[]> cachedSpriteData = new HashMap<>();
    
        private static boolean DUMP_SPRITES = true;
    
        static {
            /**
             * These sprites cache the byte[] containing the sprite data when loaded
             * for the HP bar, for example.
             */
            cachedSpriteIdList.add(348);
            cachedSpriteIdList.add(397);
        }
    
        private static int[] cachedSpritePositions;
        private static int[] cachedSpriteSizes;
        private static Sprite[] cachedSprites;
        private static int dataFileOffset;
        private static RandomAccessFile dataFile;
    
        private static int[] cachedSpritePositions2;
        private static int[] cachedSpriteSizes2;
        private static Sprite[] cachedSprites2;
        private static int dataFile2Offset;
        private static RandomAccessFile dataFile2;
    
        private static int[] cachedSpritePositions3;
        private static int[] cachedSpriteSizes3;
        private static Sprite[] cachedSprites3;
        private static int dataFile3Offset;
        private static RandomAccessFile dataFile3;
    
        public static byte[] getCacheSpriteData(int index) {
            if (!cachedSpriteData.containsKey(index) || cachedSpriteData.get(index) == null) {
                getCacheSprite(index);
            }
            return cachedSpriteData.get(index);
        }
    
        public static Sprite getCacheSprite(int index) {
            if (cachedSprites[index] == null) {
                cachedSprites[index] = decodeSprite(index);
            }
            return cachedSprites[index];
        }
    
        public static Sprite getCacheSprite2(int index) {
            if (cachedSprites2[index] == null) {
                cachedSprites2[index] = decodeSprite2(index);
            }
            return cachedSprites2[index];
        }
    
        public static Sprite getCacheSprite3(int index) {
            if (cachedSprites3[index] == null) {
                cachedSprites3[index] = decodeSprite3(index);
            }
            return cachedSprites3[index];
        }
    
    
        /**
         * Creates a sprite out of the spriteData.
         *
         * @param id
         */
        public static void createSprite(int id) {
            if (DUMP_SPRITES) {
                File directory = new File(Signlink.getIdentifierFile() + "/image_dump");
                if (!directory.exists()) {
                    directory.mkdir();
                }
                FileUtilities.WriteFile(directory.getAbsolutePath() + System.getProperty("file.separator") + id + ".png", getData(id));
            }
        }
    
        private static byte[] getData(int index) {
            int pos = cachedSpritePositions2[index];
            int size = cachedSpriteSizes2[index];
            try {
                dataFile2.seek(dataFile2Offset + pos);
                byte[] data = new byte[size];
                dataFile2.read(data);
                return data;
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
    
        public static void loadCachedSpriteDefinitions(Archive archive) {
            final String fileName = "mainsprites.data";
            byte[] data = archive.get(fileName);
            StringBuilder sb = new StringBuilder();
            for (int index = 0; index < 10; index++) {
                sb.append(data[index] + ", ");
            }
            System.out.println("length: " + data.length + ", bytes: " + sb.toString());
            try {
                dataFile = new RandomAccessFile(Signlink.getCacheDirectory() + fileName, "rw");
    
                dataFile.setLength(0);
                dataFile.seek(0);
                dataFile.write(data);
                dataFile.seek(0);
    
                int spriteCount = dataFile.readShort();
    
                int idxSize = dataFile.readShort();
                byte[] idx = new byte[idxSize];
                dataFile.read(idx);
                dataFileOffset = 4 + idxSize;
    
                ByteBuffer index = new ByteBuffer(idx);
                int totalSprites = index.getShort();
                System.out.println("Total sprites in firstsprites: " + totalSprites);
    
                cachedSprites = new Sprite[totalSprites];
                cachedSpritePositions = new int[totalSprites];
                cachedSpriteSizes = new int[totalSprites];
    
                for (int file = 0; file < totalSprites; file++) {
                    cachedSpritePositions[file] = index.getInt();
                    cachedSpriteSizes[file] = index.getInt();
                }
            } catch (IOException e) {
    
            }
        }
    
        public static void loadCachedSpriteDefinitions2(Archive archive) {
                    final String fileName = "secondarysprites.data";
                    byte[] data = archive.get(fileName);
                    try {
                        dataFile2 = new RandomAccessFile(Signlink.getCacheDirectory() + fileName, "rw");
    
                        dataFile2.setLength(0);
                        dataFile2.seek(0);
                        dataFile2.write(data);
                        dataFile2.seek(0);
    
                        int spriteCount = dataFile2.readShort();
    
                        int idxSize = dataFile2.readShort();
                        dataFile2Offset = 4 + idxSize;
                        byte[] idx = new byte[idxSize];
                        dataFile2.read(idx);
    
                        ByteBuffer index = new ByteBuffer(idx);
                        int totalSprites = index.getShort();
    
                        cachedSprites2 = new Sprite[totalSprites];
                        cachedSpritePositions2 = new int[totalSprites];
                        cachedSpriteSizes2 = new int[totalSprites];
    
                        for (int file = 0; file < totalSprites; file++) {
                            cachedSpritePositions2[file] = index.getInt();
                            cachedSpriteSizes2[file] = index.getInt();
                            //createSprite(file);
                        }
                    } catch (FileNotFoundException e) {
                        e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
    
            public static void loadCachedSpriteDefinitions3(Archive archive) {
                final String fileName = "thirdsprites.data";
                byte[] data = archive.get(fileName);
                try {
                    dataFile3 = new RandomAccessFile(Signlink.getCacheDirectory() + fileName, "rw");
    
                    dataFile3.setLength(0);
                    dataFile3.seek(0);
                    dataFile3.write(data);
                    dataFile3.seek(0);
    
                    int spriteCount = dataFile3.readShort();
    
                    int idxSize = dataFile3.readShort();
                    dataFile3Offset = 4 + idxSize;
                    byte[] idx = new byte[idxSize];
                    dataFile3.read(idx);
    
                    ByteBuffer index = new ByteBuffer(idx);
                    int totalSprites = index.getShort();
                    System.out.println("Total sprites in thirdsprites: "+totalSprites);
                    cachedSprites3 = new Sprite[totalSprites];
                    cachedSpritePositions3 = new int[totalSprites];
                    cachedSpriteSizes3 = new int[totalSprites];
    
                    for (int file = 0; file < totalSprites; file++) {
                        cachedSpritePositions3[file] = index.getInt();
                        cachedSpriteSizes3[file] = index.getInt();
                    }
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
    
            private static Sprite decodeSprite(int index) {
                int pos = cachedSpritePositions[index];
                int size = cachedSpriteSizes[index];
                try {
                    dataFile.seek(dataFileOffset + pos);
                    byte[] data = new byte[size];
                    dataFile.read(data);
                    if (cachedSpriteIdList.contains(index)) {
                        cachedSpriteData.put(index, data);
                    }
                    return new Sprite(data, index, 1);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                return null;
            }
    
            private static Sprite decodeSprite2(int index) {
                int pos = cachedSpritePositions2[index];
                int size = cachedSpriteSizes2[index];
                try {
                    dataFile2.seek(dataFile2Offset + pos);
                    byte[] data = new byte[size];
                    dataFile2.read(data);
                    return new Sprite(data, index, 2);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                return null;
            }
    
            private static Sprite decodeSprite3(int index) {
                int pos = cachedSpritePositions3[index];
                int size = cachedSpriteSizes3[index];
                try {
                    dataFile3.seek(dataFile3Offset + pos);
                byte[] data = new byte[size];
                dataFile3.read(data);
                return new Sprite(data, index, 3);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
    
    }
    Reply With Quote  
     

  5. #5  
    Rune-Server Affiliate

    Join Date
    Apr 2014
    Posts
    1,761
    Thanks given
    75
    Thanks received
    714
    Rep Power
    1073
    Code:
    public static void createSprite(int id) {
            if (DUMP_SPRITES) {
                File directory = new File(Signlink.getIdentifierFile() + "/image_dump");
                if (!directory.exists()) {
                    directory.mkdir();
                }
                FileUtilities.WriteFile(directory.getAbsolutePath() + System.getProperty("file.separator") + id + ".png", getData(id));
            }
        }
    its right there???
    Reply With Quote  
     

  6. #6  
    Jake from State Farm

    FKN Jake's Avatar
    Join Date
    Nov 2013
    Posts
    675
    Thanks given
    45
    Thanks received
    58
    Rep Power
    153
    Quote Originally Posted by Zion View Post
    Code:
    public static void createSprite(int id) {
            if (DUMP_SPRITES) {
                File directory = new File(Signlink.getIdentifierFile() + "/image_dump");
                if (!directory.exists()) {
                    directory.mkdir();
                }
                FileUtilities.WriteFile(directory.getAbsolutePath() + System.getProperty("file.separator") + id + ".png", getData(id));
            }
        }
    its right there???
    1 - the Dump doesn't work lol
    2 - how would i repack those if they were to work


    Signlink:
    Code:
    	public static String getIdentifierFile() {
    		return (!System.getProperty("os.name").toLowerCase().contains("windows") ? System.getProperty("user.home")
    				: System.getenv("APPDATA")) + "/.fallout/";
    	}
    Attached image
    Reply With Quote  
     

  7. #7  
    Respected Member


    Join Date
    Jan 2009
    Posts
    5,743
    Thanks given
    1,162
    Thanks received
    3,603
    Rep Power
    5000
    if you read the code its all there, the file is an idx and the sprites packed into one file.

    Code:
                        for (int file = 0; file < totalSprites; file++) {
                            cachedSpritePositions2[file] = index.getInt();
                            cachedSpriteSizes2[file] = index.getInt();
                            //createSprite(file);
    the size of the file and where it is located, inside the file. you can use the methods "decodeSprite" to dump your sprites

    Code:
    for (int file = 0; file < totalSprites; file++) {
    decodeSprite(file);
    }
    you'll need to write your own image packer for this format.
    Reply With Quote  
     

  8. #8  
    Jake from State Farm

    FKN Jake's Avatar
    Join Date
    Nov 2013
    Posts
    675
    Thanks given
    45
    Thanks received
    58
    Rep Power
    153
    Quote Originally Posted by Stuart View Post
    if you read the code its all there, the file is an idx and the sprites packed into one file.

    Code:
                        for (int file = 0; file < totalSprites; file++) {
                            cachedSpritePositions2[file] = index.getInt();
                            cachedSpriteSizes2[file] = index.getInt();
                            //createSprite(file);
    the size of the file and where it is located, inside the file. you can use the methods "decodeSprite" to dump your sprites

    Code:
    for (int file = 0; file < totalSprites; file++) {
    decodeSprite(file);
    }
    you'll need to write your own image packer for this format.
    Much thanks i cant beileve i overlooked that dumped thirdsprites successfully now onto repacking, thanks again.
    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. Dump Any Sprite From The Cache
    By CrazyPanda in forum Snippets
    Replies: 2
    Last Post: 06-15-2016, 09:16 PM
  2. Replies: 6
    Last Post: 12-01-2009, 10:12 PM
  3. Dumping from 400+ cache.
    By Jon in forum Help
    Replies: 0
    Last Post: 11-15-2009, 03:20 AM
  4. Project Sprite Cache
    By Clienthax in forum RS2 Client
    Replies: 10
    Last Post: 05-20-2008, 03:10 AM
  5. Colour Npc Dump Of 377 Cache
    By Sean in forum Tutorials
    Replies: 4
    Last Post: 11-11-2007, 07:13 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
  •