Search in sources :

Example 11 with ArchiveEntry

use of net.runelite.http.service.cache.beans.ArchiveEntry in project runelite by runelite.

the class XteaService method checkKeys.

private boolean checkKeys(CacheEntry cache, int regionId, int[] keys) {
    int x = regionId >>> 8;
    int y = regionId & 0xFF;
    String archiveName = new StringBuilder().append('l').append(x).append('_').append(y).toString();
    int archiveNameHash = Djb2.hash(archiveName);
    ArchiveEntry archiveEntry = cacheService.findArchiveForTypeAndName(cache, IndexType.MAPS, archiveNameHash);
    if (archiveEntry == null) {
        throw new InternalServerErrorException("Unable to find archive for region");
    }
    byte[] data = cacheService.getArchive(archiveEntry);
    if (data == null) {
        throw new InternalServerErrorException("Unable to get archive data");
    }
    try {
        Container.decompress(data, keys);
        return true;
    } catch (IOException ex) {
        return false;
    }
}
Also used : InternalServerErrorException(net.runelite.http.service.util.exception.InternalServerErrorException) ArchiveEntry(net.runelite.http.service.cache.beans.ArchiveEntry) IOException(java.io.IOException)

Aggregations

ArchiveEntry (net.runelite.http.service.cache.beans.ArchiveEntry)11 NotFoundException (net.runelite.http.service.util.exception.NotFoundException)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 ArchiveFiles (net.runelite.cache.fs.ArchiveFiles)6 FSFile (net.runelite.cache.fs.FSFile)6 CacheEntry (net.runelite.http.service.cache.beans.CacheEntry)6 IndexEntry (net.runelite.http.service.cache.beans.IndexEntry)6 IOException (java.io.IOException)3 SpriteDefinition (net.runelite.cache.definitions.SpriteDefinition)3 SpriteLoader (net.runelite.cache.definitions.loaders.SpriteLoader)3 BufferedImage (java.awt.image.BufferedImage)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ItemDefinition (net.runelite.cache.definitions.ItemDefinition)2 NpcDefinition (net.runelite.cache.definitions.NpcDefinition)2 ObjectDefinition (net.runelite.cache.definitions.ObjectDefinition)2 TextureDefinition (net.runelite.cache.definitions.TextureDefinition)2 ItemLoader (net.runelite.cache.definitions.loaders.ItemLoader)2 ModelLoader (net.runelite.cache.definitions.loaders.ModelLoader)2 NpcLoader (net.runelite.cache.definitions.loaders.NpcLoader)2 ObjectLoader (net.runelite.cache.definitions.loaders.ObjectLoader)2