Archiving and Encrypting Game Assets

Hello, everybody!

I’m not sure how I’d go about simply Googling and researching this, so I thought I’d try and articulate it here to see if you guys could help me out. I basically want to be able to encrypt my data in my game (primarily level files and the like) and then archive them in the way you see a lot of game assets come in commercial digital packages… similar to how Doom’s WAD files were stored, though in Java and perhaps not quite to that extent.

For example, my game levels are a combination of text files and image files (the image files directly affect the level data and are pixel maps, not tiles or visual data to be rendered on the screen, which I understand doesn’t need the encryption and archiving like direct data files would). I would like for these text and pixel files to be able to be combined into one file (with a custom extension, VLF for example) and then to have this one file be representative of an entire level and unable to be edited by the users directly once they play the game. (I’m not at all against modding, I just don’t want it to be quite so accessible for security purposes.)

If anybody could provide me some resources or information on how I could go about doing this, it would be much appreciated! Thank you very much, and sorry for the most likely unnecessarily long post.

Best regards,
Colton

Java Cryptography: javax.crypto.*
java.util.zip

65K, thank you very much! I’ll take a gander at those classes and glean as much as I can.

Colton

But take into account that encryption of your shipped game will be hackable anyway no matter what you do.
So its just a small obstacle to prevent direct asset access for the public.

65K,

Yes, of course. I don’t have an issue with that; merely, I just want to make it so that curious but amateur “hackers” won’t be able to merely open up a text editor and potentially ruin their whole world with a few minor changes to the data. It’s also for the sake of consolidation; having one archive for everything rather than a bunch of files will make it easier for me to keep track of the game data on a higher level once everything has been refined as best it can. I appreciate all the assistance!

Colton

…Why not? It’s their game once it’s on their computer - let 'em do what they want with it and you can spend your efforts making the rest of the game instead of wasting your time on this.

Cas :slight_smile:

Cas,

I can’t think of many commercial games off the top of my head that allowed these kinds of things to be out in the open, within a text or image editor’s reach. For the general public, it seems safer to me to have these things packaged. Those privy to modding and hacking will still access them, without trouble no doubt. Those with casual interest will either download a level editor or learn how to hack the data properly, and all of the data will still be consolidated and easy to manage. There is a lot of content in my game, so having it all within modules that can either be indirectly edited or at the very least more carefully edited will save headaches and potentially save worlds of data. Doom and its sequel were designed from the ground up with modding in mind and yet both games relied on the same engine and external WAD package files that housed all of the data, same with Quake. I’m hard pressed, looking through my Steam library of 150+ games, to find a title offering the kind of access that you’re suggesting. I understand why you would suggest allowing everything to be out in the open, but with the way my game and its data are structured, not to mention the fact that PvP will become an option at some point, I’d rather my players be able to mod the game but not have that easy a way of doing so. Minecraft has a tremendous modding community and is probably my favorite game, yet the data for its levels are encrypted and consolidated. I hope you can at least recognize my point of view.

Regards,
Colton

I do understand your POV, but if I may say, it is naively misguided; here is some food for thought:

I’d suggest you don’t look “up” to AAA titles as being the paragon of excellence in design and implementation that the AAA-marketing aspect would have you believe. AAA games development studios are shrouded in paranoia, dated development practices, jobsworth employees, suits, and deeply entrenched pre-millenium mindsets. Instead, look down on them. You’ve already made a very cunning and sensible decision in using Java to save yourself a lot of the pain that these studios have but simply refuse to fix for themselves. Your decision to use Java has already made your source code practically available for all to see anyway - so don’t fight it, run with it, and use it as an asset.

The data in Minecraft is not necessarily so much encrypted as just stored in whatever format Markus figured out at the time he was coding it for whatever simplistic reasons he had to do it that way. He obfuscated the code (unnecessarily) as well but of course that completely failed to stop a) everyone writing cube voxel engines and b) Minecraft being reverse engineered anyway. If you are clever enough to reverse engineer Minecraft you are already clever enough to have written it all on your own. Even if you have the source code to Minecraft it is worthless to you because… Minecraft. What is your cube voxel game going to do to compete? Does Markus even care you exist? No, he does not.

In my own example the full source code and data files has been available for Revenge of the Titans for two years. I’d like to let you know the effect this has had on sales, piracy, and rip off versions appearing.
Zero
That’s right, we gave away the crown jewels but for some reason they’ve been left completely alone, still in their box. It was not a low profile giveaway either; the event was broadcast directly to nearly half a million people and widely publicised at the time. We even included the source code to our DRM system. Yet still we’ve managed to sell over a third of a million copies. (You can pick it up on Steam).

So, the gist of what I’m saying is, let them tinker. It does no harm to anyone whatsoever. At the very most, you might want to run a checksum on your data files if only to warn the user their data files have been modified and therefore the game might not run as expected. They can always revert them back again by running the installer, yes?

Cas :slight_smile:

One thing I didn’t reply to - I understand your concerns about PvP; but keep the game between “friends” and that’ll not be so much of a problem. Any serious security can be implemented via a server and of course there are a whole load of other things clients can do to cross-check each other’s answers. Until you start getting rich and famous though I wouldn’t consider it a problem you seriously need to waste time on.

Cas :slight_smile:

Wow, Cas, point conveyed excellently!

I can’t say I look up to AAA developers in particular, as I’m very particular to the indie scene and am an aspiring independent developer myself, but that aside, what you’ve explained makes sense.

I was also thinking of something of a checksum system for the server system also, which would most likely disallow players from taking part simply because of how easy it would be to cheat (and that’s just not right ;]). For the client side as well, this would be an effective practice, and you’re right, they could always revert.

However, the reversion would not solve the problem I was specifically referring to, which is the level system, as these levels are dynamically generated. Instead, the players would have to regenerate their entire world from scratch, which would be a hassle, unless these levels were backed up every time they were generated or altered (which would occur usually every time the player loaded that level and did anything within it). Considering the scope of my game and the kind of work someone could put into a world, only to have it broken with relatively little effort without some form of protection, this could mean tears and blood shed by a player out of the sake of curiosity. This isn’t a huge issue by any means, as a small percentage of players would likely engage in this sort of thing to begin with, but neither is this a major stepping stone in the game’s development; this is probably something that would take me a day or two to implement into my game once I tinker with the classes, and the game been in development for quite some time. If my game’s levels were static levels, this whole process wouldn’t matter.

Hopefully this will give you more insight into why I’d be more reluctant to make editing them quite so easy. Revenge of the Titans has static levels, at least judging by its Steam description, so in that scenario, it wouldn’t really matter. Congratulations on that, by the way! It sounds like your game is selling very well, and I hope to do as well myself! :] I plan on trying to get my game on Steam once it has been completed, though it’s a ways away yet.

I feel like we could have some very involved discussions regarding game development, and judging by your post count, it seems you do enjoy discourse! Perhaps we should have some discussions through messaging or whatnot, tangential to this one, if you would like and have the time.

Best regards,
Colton

btw everything in RotT is dynamically generated and unique for every game :slight_smile:

Prefer to keep all discussions out in the open on the forums for all to see - haven’t got time for PMs on all the forums I use! Plenty of other points of view to be had around here too.

Cas :slight_smile:

Cas, I can respect that. I was doing it more for respect the forums (not sure if admins would approve of tangential discourse where unduly expected).

I beg your pardon, as I haven’t played Revenge myself. Are the levels saved for future reuse? Taking a quote from the Steam page…

“50 level campaign mode across Earth, Moon, Mars, Saturn and Titan itself”

…this lead me to believe that these 50 levels were static, or at the very least only created and used once and then never seen again once the player has progressed. The way my game works is that the world is actually a dynamic entity that is initially generated, where the entire thing can always be explored again; there are levels within this world, but these levels are open to come back to later and will actually develop as the player has been out in the world and time has passed. Thus, affecting one of these levels or the entire world at large can have drastic consequences and could potentially destroy the entire thing in regard to its ability to load. A player with resolve could easily put hundreds of hours into one of these worlds (hypothetically, not to give my game any sort of gloating self-proclaimed good press; we’ll have to let sales take care of that).

I would of course enjoy discussion with anybody else on the forums, but your very elaborate post in response to mine spurred me to ask. The forums will suffice :]

Regards,
Colton

We like tangential discourses here on JGO; they’re most welcome.

The levels are procedurally generated based on a seed. The seed is calculated from your name, current research, and current money, and current difficulty; and then the generated level is saved to disk/cloud. This means you can go back and play a level again (and replay indefinitely), but all subsequent levels will have different seeds and be regenerated. A bit fiddly but very neat if I may say so :slight_smile:

Cas :slight_smile:

Ah, I see. So it’s more or less a linear path but with random generation to mix things up. In a situation like this, I can especially see why it would not hurt to have things so easily editable, because after all, you’re not striving to preserve necessarily an entirely holistic gaming “world” experience. I feel I’m attached to this preservation in my case only because of this interdependence, which is simply the result of the game being what it is. However, I appreciate your point of view a whole lot more thanks to your willingness to explain it in detail previously; were I to embark on a game unlike what I am currently working toward, where the preservation of entirety is not so necessary and otherwise game-breaking, I would now most likely relinquish data assets to the players.

Thanks for the advice and the discussion, Cas. I’m sure we’ll meet again in the near future. ;] And good luck to you on any of your near endeavors in the world of game development. If my game gets released on Steam, I’ll make sure to let you know!

Best regards,
Colton

It seems to me that a fair amount of successful studio games actually do allow end-users to muck around with content/scripting. And by doing so have increased their total sales figures.

Roquen,

A lot of games do this, though often through toolsets and kits like Neverwinter Nights and Skyrim did. Is this the kind of thing you’re referring to? Like I’ve said already, I don’t mind allowing the users to mess around with the game’s assets, just not edit raw textual level data without some sort of guidance, tool, or knowledge of what they’re doing, hence why I would find it safer to put a single layer of abstraction over that kind of data before shipping. Say I have a level composed of linked parts and the file to contain the linking information is stored as such:

0 T 3 BR 6
1 B 2 L 8
2 T 5 BL 10

etc. etc. as many as 20, 30, even more lines.

Say those first numbers represent the section of that level and the information to follow is a varargs type of way of representing connections (in this case, each section has 2 links for ease, examples including “T” for top, “BR” for bottom right, etc. and the number to follow indicating the section which is connected through that route of travel). These “sections” are stored as separate files of pixel data. This metafile, if tinkered with, would have the capability of ruining the entire level if something as simple as one character or letter were altered from the originally intended file. This is something that the end user should not have control over directly, not unless they knew how to also create the content they would need to make sure the level would still load and function properly, which would not be easy right out of the box without knowing how the engine works. However, being able to edit the section data mapping out the tangible levels rather than the metadata would actually not hurt in the same way, though it could. However, the severity of such consequences would be far less.

This is but one example of many which could wreak havoc on the game’s structure and ability to function and load, should anything as simple as a character or number be misplaced; with a level editor of some kind or at least knowledge of how the engine works and what can be done with it, this problem would be mitigated or absolved completely and is usually how I’ve seen issues like these addressed with commercial games. I have yet to see a commercial game that allows the user that kind of access to the data in such an easily editable and readable fashion, though from what Cas said, Revenge of the Titans offers very open assets (though I’m unsure if they are the same enough for this example to work in a similar context as my engine).

Once again, I love modding and encourage it, and I encourage those apt enough to edit the data to do so and have a blast with it… it’s fun stuff. However, I feel this is much too risky in certain situations to just have everything out in the open, especially for those who have put a lot of time into the game and are unaware of the risks involved with this type of game in doing so. Media assets, I’m okay with. The users can edit those all they want, because the engine will load them either way and display or play them nonetheless (within certain limitations, of course). However, it won’t be able to properly load something like a level in my engine if that level’s metadata has been tinkered with in even the slightest of ways.

Best regards,
Colton

NWN and various TES are actually a couple of examples I was thinking of. If you just want to prevent joe-average from mucking around with raw data, then just compress the file-set and give the compressed file(s) a non-standard extension “.dat” or whatever. No real need to waste your time coding and the CPU’s time de/en-coding some encrypted format and move on to making your game. With an asset editor of course. :slight_smile:

Roquen,

That’s essentially what I stated in a prior post… the “VLF” format I referred to, as well as having the files in a zip-like archive. The encryption probably would not be necessary as you said, but I just want things consolidated and behind at least one layer of protection; easy enough to break through without a terrible amount of trouble, but not so easy to edit that even a casual browser might be tempted without any forethought.

Thanks! :]

Best regards,
Colton

Just using .jar files will fox 99% of the population.

Cas :slight_smile:

The plan is to have the game engine and core assets packaged as a .jar. For levels and saves, however, can the .jar add these things to itself? Using Minecraft as an example again, all saves are kept in a separate folder from the core .jar. I’m not sure if this was just a design choice or not from Markus.

Regards,
Colton