This is a project I've been working on for a couple days, and I think it will massively improve the RSPS scene. I was looking around for cache editors, and it seems Tom's cache suite is still what's popular. As I made a quick little archive extractor, it occurred to me I should make all the tools for viewing and editing files plugins, so we can have a giant integrated community-based clean cache editor capable of editing everything - maps, interfaces, configurations, etc..
I wrote this in C#. There are three parts to the project - the shell (what you run), the cache API (what does all the dirty work), and the plugins (the features). The API is very powerful, allowing you to load, rename, edit, and even add new files to archives and sub-archives with just a couple lines of code.Update List1.3
- Several additions to the cache API, including being able to load items, objects, NPCs, and "VarBit"
- A model-viewer control has been added to the API to allow model viewing integration in any plugin with ease
- Some other minor changes to the underlying client-ripped rendering system (still lots of work to do here)
- "ModelViewer" plugin now uses the API's model viewer control. It is recommended you delete the Tao DLLs in the Plugins folder!
- With the addition of the model viewer plugin, the Tao library files are now required to be in the same directory as the API library file. Either download the entire suite or manually place them there if you're just adding your own plugins
- The source is no longer included in the download. Visit the GitHub page down below for it.
How To Use
- Added drag/drop file importing/adding
- Batch file exporting
- Fixed the search feature not working for regular archives
- Added the client's model and rasterizer class
- Added a model viewer (wasd to move, left click to rotate, wheel to zoom)
To start, open your cache. This is a folder with "main_file_cache.dat" and "main_file_cache.idx0-4". Upon doing so, the tree on the left should populate with archives and sub-archives. Sub-archives, commonly known as "Jagex Archives", are archives with a different file format that uses BZip2 compression. Regular archives use GZip compression. You don't have to worry about any of this, as the API deals with compression for you.
To add a file, go to File > New when you have either an archive, file, or sub-archive parent node selected. Adding a file with a sub-archive file or sub-archive parent node will create a sub-archive file. Note that if you create a new file with the archive 0 node selected ("Sub-Archives") or try to add a file to sub-archive 0, the program will work but those archives and files specifically won't.
On the right you see import/export data, which allow importing/exporting a file if any of the loaded plugins support importing/exporting. Note these always take the uncompressed files, so don't compress them before-hand. You can also rename files if they're part of sub-archives, but note you must add your name to files.txt for it to show when you open your cache down the road.
When you modify a regular archive file by importing data or creating a new file, you don't have to save. It's automatic. With sub-archives, however, you must manually save. Do this by saving all archives or when the file/node you have selected is part of a sub-archive, save the current one.
To view the plugins that are installed, go to Plugins > Summary. If a plugin allows configuring, the "Configure" button will be enabled. Here you can also view what criteria has to be met for a plugin to be loaded, and what I/O operations it allows you to do.Plugin Pack 1.3
-ImageViewer - Views and allows the basic importing and exporting of 317-format images.
-HexEditor - A basic hex editor. Note editing with it doesn't work. It's really only there to allow importing/exporting raw data.
-PaletteViewer - Views the palette an image archive uses.
-ModelViewer - Views and allows the basic importing and exporting of 317-format models. Note if OpenGL fails to initialize, software rendering is enabled. To disable it (or enable it), configure it from the plugin summary window.
-ItemViewer - Views 317-format items.
-ObjectViewer - Views 317-format objects.
-NPCViewer - Views 317-format NPCs.
-VarBitViewer - Views 317-format VarBit. (This was just a quick test to see everything VarBit contained)
-MidiPlayer - Allows playing and exporting of midi files. This was made by Bobster from Rune-Server and I included it in the pack.Shell Features
Cache API Features
- Plugins (obviously)
- Naming of archives and individual files (through Files.txt)
- Search files with filtering - Searching allows for named files containing the searched text and/or unnamed files matching the whole text. If a sub-archive file hasn't been manually named, as in we only have its hash code (since file name storing is lossy), the search will bring it up anyways.
- Map files display their coordinates (only works for I believe terrain files at the moment)
- Importing, exporting, creating, and renaming files
- Drag and drop (see below)
- Batch export (file dumping)
The Plugin API
- Reading and writing archives (automatic GZip compressing/decompressing)
- Reading and writing sub-archives (automatic BZip compressing/decompressing)
- Client image loading, bitmap generating, PNG importing (excellent color quantization, thanks to the nQuant library)
- Creating files for both archives and sub-archives
- Contains a copy of the client's model and rasterizer class (mostly undocumented/copy-pasted)
- Contains almost fully-documented Item, Object, and NPC definition files. Also has VarBit...
- An easy-to-use model viewer control that will render any Model supplied and allow basic viewing interaction
Creating and adding plugins is very
simple. Start a new Class Library project in VS, add the API to the references, and create a class that extends IPlugin. Copy the properties and functions, fill them out, and compile the project. Adding the plugin is as easy as copying the DLL file to the "Plugins" folder.
Plugins have specific criteria that have to be met (called Classifications in the IPlugin class) in order for the plugin to show up when you're viewing files, to not only keep things neat but also to prevent you from accidentally breaking stuff. By default, it makes the plugin appear for everything (blank properties), but you can limit it by requiring specific file names, extensions, sub-archives, and/or archives.
The FileExtensions and StaticFileExtensions properties control how data can be imported/exported. StaticFileExtensions is what's used in the plugin's summary, and FileExtensions are used for the actual import/export dialog box. See the ImageViewer for an example on a plugin's I/O features can be enabled and disabled depending on the success of its operations.Drag and Drop
Dragging and dropping files into the file browser and plugin window is supported. When a file is dropped into the plugin window, it will act simply as if the user imported the file; dropping files into the file browser is where things get more complicated. If a single file is dropped into a file node, the node's data is replaced by the plugin that would handle the dropped file. If a single file is dropped into a sub-archive header node, the file is added to the archive, or it replaces the existing file if it exists (node name must match the dropped file name). If a single file is dropped into an archive header node, the file is added to the archive. If multiple files are dragged into a file node, sub-archive header node, or archive header node, the files are added into the archive. Like the single-file drop into the sub-archive header, multiple files will attempt to check if the file exists first.MediaDownload[/url]
The API is undocumented, but you should be able to figure out how to write plugins if you just look at the sample ones. To get plugins loading when debugging, you'll have to change the debug directories in the PluginContainer class in the Cache Editor project. I used Visual Studio 2013 for this.Notes
Visit This Project on GitHub
- The file tree shows the compressed sizes for regular archive files to improve speed. When you import a raw file, it uses the uncompressed size.
- The API image importer requires imported images are 32-bit, so if yours is not, it is made transparent automatically (white becomes transparent). Save your images in a 32-bit ARGB format to avoid this.
- There are some serious time-consuming operations. Saving all the archives isn't fast, as rewriting each archive requires extracting and recompressing all the files in it to optimize the file size (it can be optimized but I'm lazy). Importing large images is extremely costly, primarily because of the color quantization (if you don't know what that means, it's finding the 256-color palette that gives the image the best quality. This is necessary because this is how the client reads images).
- You can't create image groups with my image viewer plugin. If you would like one that could, develop it further or make your own!
- This is still an early program that hasn't been fully tested with every situation, but it has passed every test so far. Use with caution and back up your cache frequently.