Coding
From modwiki
All engines in the id Tech 4 family are written in C++, a high-level programming language. Coding, as it applies to id Tech 4 games, is the modification of the engine's public source code to extend upon its capabilities.
Contents |
Engine code
The engine code is not currently available without licensing, however there are plans by id Software for it to be released under an open source license in the future.
Among other systems, the engine contains - the common framework, renderer, sound system, file system, network system.
The compiled engine code is referred to as the engine executable.
Game code
Game code can be downloaded as part of the respective games SDK and is released under the SDK EULA.
Among other systems, the game code contains - the main game logic, map loading, entity spawning, spawn classes, physics, networking.
The compiled game code is referred to as the game binary. People often refer to the game code and the game binary interchangeably, also using such terms as the dll, or the SDK.
The engine/game interface, or API, is described by idGame with local aspects in idGameLocal.
There is version check done by the game engine on loading the game binary in order to enforce the API which halts the game with the error "ERROR: wrong game DLL API version". Therefore each engine update or game patch is likely to 'break' compatibility of mods, necessitating the author to update the mod to the new game code.
For more details on each file and class included in the SDK, and therefore what can and cannot be done, please read The annotated API.
The SDK
This game code project in the SDK, allows modders the ability to compile a new game binary for different platforms - gamex86.dll/gamex86.so/gameppc.dylib file for windows/linux/mac respectively.
- Download the Doom 3 SDK version 1.3.1
- Download the Quake 4 SDK version 1.4.2
- Download the Prey SDK
- Download the ETQW SDK version 1.5
Most of the SDKs support Visual Studio .NET 2003 and 2005 "out of the box".
Where to start
So much code!
As a starting point the idGameLocal::RunFrame() function can be considered the entry point or the systems "main()".
It is the part of the game loop called by the engine at 60Hz (30Hz for ETQW). Each call referred to as a game frame.
The idGameLocal class handles main game aspects, loading map, setting up the main data structures, spawning and tracking entities.
idEntity is the base spawn class that other entities are derived from.
References
- The annotated API
- CVar flags (Description of the flags)
- Server query protocol
Coding tutorials
- Adding a custom keyhandler
- Beginner's Tutorial (Part 1) Filetypes
- Beginner's Tutorial (Part 2) The SDK
- How to build the SDK on Linux
- How to build the SDK on OSX
- How to build the SDK on Windows
- How to add custom console commands
- How to add CVar's
- Rendering with the D3 renderengine
- D3 Networking: Basics
- D3 Networking: Communication
- D3 Networking: Setting up a test session
- D3 Networking: Snapshot synchronisation
- D3 Networking: Server and client side events
- D3 Networking: Server- and UserInfo
- D3 Networking: A birth and death of an entity
- D3 Networking: An overview of the architecture
- D3 Networking: Delta and PVS-based synchronisation
- D3 Networking: Client-side prediction
- Q4 Networking: Encoding messages like snapshots
- Q4 Networking: Deltifying rockets away

