Game Development Community

Binary File read/write...

by Nic Cusworth · in Torque Game Builder · 01/31/2007 (4:06 am) · 5 replies

I know this has been discussed before but I thought I'd shake the tree a little again.

I do a lot of custom loading of assets using a text file (as well as using text files for the overall game control etc.)

There's a couple of things I'd like to do.

1: be able to protect my text files so they are not in plain text. I know I can write something to encode this data somehow... but I personally would prefer to be able to write out a binary file... like the dso files.

2: I would like to write a custom image reader so that I can grab information from png files.

I don't own the Pro TGB and I got a feeling that this is the answer to my problem. I don't really understand why binary files aren't supported in script to be honest and it seems like yet another thing I'm having to work around in TGB...

I'd also like to do binary reading and writing so I can scramble my image files so they can't be read in photoshop etc.

Nic.

#1
01/31/2007 (7:56 am)
When you use the non-pro version of TGB you will always be "working around" things that are not stock features. As a suggestion for #1, you can write your text file information as a set of key/value pairs into a .cs file, compile it, then delete the .cs file (or just don't ship it). Look into prefs.cs for an example of the key/value pair approach though prefs is not deleted and remains in plain text as well as compiled .dso

#2
01/31/2007 (8:03 am)
I think for the text files I'll probably work out some encryption of my own, but I was wondering if there was any plans for protection of assets like gfx, sound etc??

Nic.
#3
01/31/2007 (8:07 am)
There is a zip encryption resource, but it is only beneficial to pro users right now. Perhaps it will be integrated (or something similar) down the line.
#4
01/31/2007 (8:11 am)
Zip enryption would be VERY VERY VERY useful!!!

Here's a question about the Pro Licence. I want to keep my code as portable as possible so it'll run cross platform. I'm worried if I start poking around in the innards of TGB I'll end up having to recompile the engine for all platforms. Is this correct or am I going crazy?

Nic.
#5
01/31/2007 (8:16 am)
Yes, if you make changes to the core C++ engine, you will have to recompile it for all platforms.