• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
  • entries
    500
  • comments
    1888
  • views
    333011

Solving over six thousand woes with a custom pak format

Sign in to follow this  
Followers 0
EDI

404 views

Greetings all,

A series of recent technical difficulties has brought about a need for change...


Rooms in Revel Immortal

As some of you may know, Revel is composed of many, many screen-sized rooms; which collectively make up one whole map.
And yet within Revel there are many maps; Garranshall, a map in Revel is composed of 80x80 (or 6400) rooms.

Each room is a file; which seems, and maybe be somewhat absurd but there are some good reasons for it...


Revel, is an HTML5 game

... or 'web-game' if you will; users don't install anything so, we only give them data they request and need.
since you can only see one room at a time, serving single rooms on request makes good sense for everyone.

It was very important per-alpha and post-alpha to focus on content...

This means we only went on technological side-roads when it was deemed critical; and having an 80x80 map in 80 directories of 80 files each, was a simple, fast way to express the data and still have it be workable for the end user.

Also having each room as a single .json file meant we could do sweeping find-replace transformations, in an era when we did not have strong editing tools (we couldn't afford the time to build them yet).



But now this format is killing us softly...

As our number of maps grow, we are getting more and more discrete room files (as if 6400 wasn't enough); this is putting nominal per-file load on things like, cloning directory strcuture, adding, commiting to SVN.

But there have been two final straws that have killed this format...


You just can't load 6400 tiny json files real-time for a sweeping overview of the map

Now that we have powerful tools in the form of the Revel Editor, it has been a goal and neccesity to better grok and visualize the world-at-large in Revel... to do this even just for Garranshall would mean loading up and processing 6400 files, and it seems at least commodity hard disks just can't hack it.

While I might be able to, throwing hardware at this problem is not desireable as I think this use case is just plain wrong; and heck with 16GB of RAM on my development machine I'm not making effective use of it.


The other straw is that soon, hopefully very soon; we will no longer just be serving direct file linkages to resources such as rooms.

Hopefully around April, we will be reaching beta-stage

and with that... players will be able to purchase keys (or a one-time master key) to unlock access to realms that aren't part of the free areas in Revel.

In order to make this semi-secure we need to start validating requests for certain resources against a players' keyring; and while it is a simple matter of validating their key, fetching the file and returning it with proper headers;

All of a sudden the simplicity of direct file linkage is null and void, we get no benefit from it.


So, after talking with other programmers here on GameDev chat, and other programmers on the Revel team; we devised a simple format that should solve all the identified issues.


A custom 'pak' format

I've written plenty of archive-type formats in the past, so I knew all the common pitfalls; the only new elements here were that I planned to frequently update the archive, and a single file request from the archive needed to be fast (due to the stateless nature of the CGI that would fetch room files).

...in addition a fairly flexible format was desireable so it could be tightly integrated into our server code, since it serves all such HTML5 games we might build and release.


The Format

I started from the angle of the end-use, as it was going to get the most 'hammering' and we had the least amount of control at the server level, what I came up with is as such:
fileCount //- 4 bytes - the number of toc lines (and fragments) in the file//a toc line{offset //- 4 bytes - the offset from the end of this toc line to the start of the file datasize //- 4 bytes - the size of the data}//file data//all of the file fragments lined up next to one anotherThis is a fairly common format scenario that many of you may recognize; with one exception being perhaps offset being calculated from the end of the toc line.

With this form, requesting a single file simply becomes a matter of:

  1. Open the file stream
  2. Read 4 bytes to get file count
  3. Validate requested file index is in range (>=0
  4. seek to proper toc line +(fileIndex*8)
  5. read 4 bytes of offset and 4 bytes of size
  6. seek to +offset
  7. read and return 'size' bytes
This is all sequential, no back-tracking, and no reading of unneccesary data.



From the editor side, I've written a class that makes creation/reading of this file format easy.

It is designed to be worked in-memory; which should hopefully save my HDD any undue stress, and use that 16GB of RAM ;)

FragFile f = new FragFile(100);f.Write(0, "zero");f.Write(2, "two");f.Write(1, "one");f.Save("G:\\test.frag");FragFile f2 = new FragFile("G:\\test.frag");string val1 = ASCIIEncoding.ASCII.GetString(f2.Read(2));

1
Sign in to follow this  
Followers 0


3 Comments


@Navyman - it hasn't been stressed yet; due to the nature of this change; I ideally need to integrated it into Engine, Editor, Server software, and of course do a data migration in one shot.

 

Hopefully that will happen this week; last night was spent finishing off previously noted changes to the NPC conversation system (which seems to be playing nicely); and furthering quest content.

0

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now