Noesis tutorial Zlib
Posted: Mon Dec 05, 2011 7:04 pm
In this tutorial ill go over how to load a file format that uses zlib compression directly in noesis.
The game is a free to play mmo called Rise of Immortals http://www.riseofimmortals.com/
This code also works on other Petroglyph games using the alo format.
Download the client for free for a sample of your own
Ok in this particular format the file contains one zlib chunk that needs to be decompressed to gain access to the model
They only give us the compressed size and a constant offset the data starts at.
So the format of these alo files is
Bytes 01 - 16 #Header Information
Bytes 17 - 20 #Compressed size
Offset 36 #Start of zlib data
So knowing this we can use this code here to get the raw file in memory to work with
So what are we doing here
We create a context with
ctx = rapi.rpgCreateContext()
Then we open our byte stream
bs = NoeBitStream(data)
Then We get the compressed size of the zlib chunk
Now we setup a place to hold our new byte stream pieces "you only need to do this if you want to add multiple streams together but it will also work for one stream "
Now we store our compressed chunk
Then we get the uncompressed size of that chunk with this command
Now we add our uncompressed data to our container we did earlier
We Now go back to the start of the file because we don't need any of the original header and we replace our bs with the new uncompressed model
Now you can handle the model just as if it were uncompressed.
The end result
If anyone has any questions on anything done in this model format just ask.
The game is a free to play mmo called Rise of Immortals http://www.riseofimmortals.com/
This code also works on other Petroglyph games using the alo format.
Download the client for free for a sample of your own
Ok in this particular format the file contains one zlib chunk that needs to be decompressed to gain access to the model
They only give us the compressed size and a constant offset the data starts at.
So the format of these alo files is
Bytes 01 - 16 #Header Information
Bytes 17 - 20 #Compressed size
Offset 36 #Start of zlib data
So knowing this we can use this code here to get the raw file in memory to work with
Code: Select all
#load the model
def noepyLoadModel(data, mdlList):
ctx = rapi.rpgCreateContext()
bs = NoeBitStream(data)
bs.seek(16, NOESEEK_ABS)
compsize = bs.read("i")
bs.seek(36, NOESEEK_ABS)
decompData = bytearray()
cmpData = bs.readBytes(compsize[0])
decompSize = rapi.getInflatedSize(cmpData)
decompData += rapi.decompInflate(cmpData, decompSize)
bs.seek(0, NOESEEK_ABS)
bs = NoeBitStream(decompData, NOE_LITTLEENDIAN)
We create a context with
ctx = rapi.rpgCreateContext()
Then we open our byte stream
bs = NoeBitStream(data)
Then We get the compressed size of the zlib chunk
Code: Select all
bs.seek(16, NOESEEK_ABS)
compsize = bs.read("i")
Code: Select all
decompData = bytearray()
Code: Select all
cmpData = bs.readBytes(compsize[0])
Code: Select all
decompSize = rapi.getInflatedSize(cmpData)
Code: Select all
decompData += rapi.decompInflate(cmpData, decompSize)
Code: Select all
bs.seek(0, NOESEEK_ABS)
bs = NoeBitStream(decompData, NOE_LITTLEENDIAN)
The end result
If anyone has any questions on anything done in this model format just ask.