Overview

A large portion of the lessons on this site have focused on examining and modifying a game’s code. This code is commonly stored in the game’s executable, or in DLL’s loaded by the game, and controls the game’s logic, or how the game responds to certain events. However, this code represents a small portion of the overall package that makes up a game. For example, take the following scene from the game Urban Terror:

Urban Terror

In this scene, our player is firing his weapon. To render this scene, the game has to load 3D models for both our player, the enemy, our weapon, and the world map. Then, textures need to be applied to the models, such as the clothes for the players and the asphalt texture for the street. Since we are firing, the game then needs to either load a series of static images or one animated image for muzzle flash. Finally, the firing sound needs to be loaded and played in the game.

Resources

3D models, textures, images, and sounds represent the resources of a game. In certain games, general data can also be a resource. For example, in an RPG, the dialog in a game will be treated as a resource. Unlike code, resources are large in size, especially 3D models. As such, resources will often be compressed, or packed, by a game developer when releasing a game. This is similar to other compression techniques, such as ZIP’ing several files together. Developers will often create custom packers to both prevent easy access to game resources and to optimize file compression. To retrieve packed files, you will need to reverse these packers.

File System

Access to the file system is slow, so games typically will load all resources required for the current scene into RAM. However, RAM is both limited in size and volatile, meaning data stored in RAM will not persist if the computer is turned off. Due to these limitations, resources must be stored on the file system on the computer’s HDD or SSD. The game then must load and unload these resources from RAM as different parts of the game are accessed. This is often done during loading screens.

Access to the computer’s file system is controlled by the OS running on the computer. For games to access the file system, they must use OS-level API’s, such as CreateFile.

Save Data

Many games allow the player to save the current state of the game and load it later. To persist across computer restarts, save data must be stored on the file system like other resources. Each game will implement saving in a unique way. For some games, they may only save the player’s current level in a text format. Other games may save the position of every entity in the world and will have to use some sort of custom encoding to store all this data in a file.

 

results matching ""

    No results matching ""