Protecting Assets vs. Load Speed
by Harry Durnan · in Torque Game Builder · 12/01/2011 (9:35 pm) · 8 replies
I've been trying to make my game look a bit more professional, and I wanted to do some very basic asset protection (or at least bundling them so there's not just a directory with a bunch of .png's and .jpg's).
I tried putting them in a password protected .zip file, and while I got this to work, I noticed a major hit to speed everytime it had to load one of the images in the .zip file. I'm pretty sure I set it to no compression on the .zip... but is there anything else that I might be missing that would cause this?
Or, if anyone has any suggestions for a better method to clean up the image directory without seeing a big performance hit I would love to hear them!
I tried putting them in a password protected .zip file, and while I got this to work, I noticed a major hit to speed everytime it had to load one of the images in the .zip file. I'm pretty sure I set it to no compression on the .zip... but is there anything else that I might be missing that would cause this?
Or, if anyone has any suggestions for a better method to clean up the image directory without seeing a big performance hit I would love to hear them!
About the author
Author of It's A Wipe! (http://www.iawgame.com :)
#2
If you really need to protect assets, encrypt em and bear with slowdowns. If you need faster loading - avoid any unnecessary packaging. Form follows function, don't do things just for looks of it.
12/02/2011 (1:39 am)
Password protection = encryption. Even if assets are not compressed, they're still getting decoded. Apparently, any additional packaging will cause overhead, unless you have custom files and storage scheme specifically designed to be used this way.If you really need to protect assets, encrypt em and bear with slowdowns. If you need faster loading - avoid any unnecessary packaging. Form follows function, don't do things just for looks of it.
#3
I mean what the hell we all make small indie games and if it gets popular to the level of people breaking it and pirating on a major scale that would mean you are already rich. But still want to know if there is a way to protect your game.
12/02/2011 (4:04 am)
Can we actually rename .png .jpg extensions to something else and still use them? Or TGB won't recognize them?I mean what the hell we all make small indie games and if it gets popular to the level of people breaking it and pirating on a major scale that would mean you are already rich. But still want to know if there is a way to protect your game.
#4
In the source code, you can make new extensions. So you can map ".png" to ".q14" and tell Torque to load ".q14" files with the ".png" loader.
But from what I've seen, if you game is popular, all of the assets will be "stolen" and either used in popular culture or for prototyping. And it sounds like a champagne problem... I mean, who wouldn't love to become so popular that people want to steal your assets? *HEHE!*
12/02/2011 (8:04 am)
There are a ton of very easy-to-use tools out there that will take graphics straight from the video card. Even if you encrypt the graphics, they still have to be decrypted and put into the video card memory.In the source code, you can make new extensions. So you can map ".png" to ".q14" and tell Torque to load ".q14" files with the ".png" loader.
But from what I've seen, if you game is popular, all of the assets will be "stolen" and either used in popular culture or for prototyping. And it sounds like a champagne problem... I mean, who wouldn't love to become so popular that people want to steal your assets? *HEHE!*
#5
While protection would be good, I also just wanted to make it look a bit cleaner. I know a renamed zip isn't too hard to crack if someone is really determined, but it does look a bit nicer to have an images.dbx file than just 40ish files in an image folder... at least in my opinion :)
12/02/2011 (6:56 pm)
I figured this out somewhat... I moved everything out of datablocks.cs except for one image, which I bring up as a loading screen. That pops up very quickly, and then it takes a couple minutes to uncompress everything. The other thing I had to change was preloading images. With them in a single file, having them load on use would cause lag everytime they were used, so I changed most of it to just load into memory at start-up. While protection would be good, I also just wanted to make it look a bit cleaner. I know a renamed zip isn't too hard to crack if someone is really determined, but it does look a bit nicer to have an images.dbx file than just 40ish files in an image folder... at least in my opinion :)
#6
04/08/2012 (5:54 pm)
Can you explain in a bit more detail what you did and what was accomplished Harry?
#7
To get it to automatically work with a password, you need to modify ZipArchive.h and put whatever password you want in place of the default: #define DEFAULT_ZIP_PASSWORD "defaltpassword". (or whatever it originally was, just look for the #define DEFAULT_ZIP_PASSWORD part).
To get it to treat another extension like .zip files, you need to modify resManager.cc. In the function ResManager:searchPath look for the line:
"
if (extension && !dStricmp (extension, ".zip") && !ignoreZips )
"
and change zip to whatever made up extension you want to use.
I believe you should make your .zips with no compression, and with it set to not store filepaths.
Then, when you make datablocks, just treat the .zip as a folder. So, if you put a images zip containing all your files into the normal images folder, you'd need to reference it on your datablocks like:
imageName = "~/data/images/images/IMAGEFILE";
As I noted before, the downside of this is that there's a very noticeable increase in load time. To avoid having the game lag every time you call up an image, you pretty much need to pre-load everything, or write code to dynamically load and unload graphics. All you need to do is when you define datablocks, set:
preload = "1";
It really depends on the type of game your trying to make. There's probably a better way to do this, but I haven't really figured one out. I probably should note, that I'm also not really using the TGB GUI game builder. I'm working almost entirely through Torsion/TorqueScript and just using it to compile the executable.
04/08/2012 (8:48 pm)
Well, it depends which part your really interested in. If it's getting things to load from a renamed/password protected .zip, you need to make a couple small edits to the C++ source and recompile TGB.To get it to automatically work with a password, you need to modify ZipArchive.h and put whatever password you want in place of the default: #define DEFAULT_ZIP_PASSWORD "defaltpassword". (or whatever it originally was, just look for the #define DEFAULT_ZIP_PASSWORD part).
To get it to treat another extension like .zip files, you need to modify resManager.cc. In the function ResManager:searchPath look for the line:
"
if (extension && !dStricmp (extension, ".zip") && !ignoreZips )
"
and change zip to whatever made up extension you want to use.
I believe you should make your .zips with no compression, and with it set to not store filepaths.
Then, when you make datablocks, just treat the .zip as a folder. So, if you put a images zip containing all your files into the normal images folder, you'd need to reference it on your datablocks like:
imageName = "~/data/images/images/IMAGEFILE";
As I noted before, the downside of this is that there's a very noticeable increase in load time. To avoid having the game lag every time you call up an image, you pretty much need to pre-load everything, or write code to dynamically load and unload graphics. All you need to do is when you define datablocks, set:
preload = "1";
It really depends on the type of game your trying to make. There's probably a better way to do this, but I haven't really figured one out. I probably should note, that I'm also not really using the TGB GUI game builder. I'm working almost entirely through Torsion/TorqueScript and just using it to compile the executable.
#8
You could also unpack everything to a working folder and clean it up on game close.
Also, naming your image archive "images" isn't helping the original intent. You should name it something less obvious, like keyfile or gamegen or anything but "TheAssetsIDontWantYouToFindAreRightHere.zip"
04/09/2012 (10:03 am)
Not encrypting the zip might speed this up a little.You could also unpack everything to a working folder and clean it up on game close.
Also, naming your image archive "images" isn't helping the original intent. You should name it something less obvious, like keyfile or gamegen or anything but "TheAssetsIDontWantYouToFindAreRightHere.zip"
Vlad I
Default Studio Name