GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing wiki.ddnet.org — Development - DDNet This article aims to introduce you into DDNet development, since it's an open-source game, it relies on random people kind enough to contribute to it on their free time.
Your development environmentIt is extremely recommended to set up a Linux environment to begin programming in DDNet for the following reasons (as of now):
First an foremost, DDNet is coded using the C++ programming language, you will need to be fairly familiar with it, but you can also know the basics and learn more with it. Some useful resources to learn C++:
The source code of DDNet is managed using Git, a version control system, an essential tool to collaborate with multiple developers. If you don't have git yet in your Linux distribution, make sure to install it, for example in most debian/ubuntu based distributions:
Getting the source codeThe source code is located on Github, you can get the source code by cloning without the need of an account, but if you want to ever put your changes to the official source code you will need one. If you are not familiar with git/github you can learn the basics here: Hello World - Github
Installing the dependenciesIf you are on Linux, you can install all the needed dependencies by reading the README on the DDNet github page: https://github.com/ddnet/ddnet#dependencies-on-linux--macos For Arch Linux: sudo pacman -S --needed base-devel cmake curl ffmpeg freetype2 git glew glslang gmock libnotify libpng opusfile python rust sdl2 spirv-tools sqlite vulkan-headers vulkan-icd-loader wavpack x264 For Debian: sudo apt install build-essential cargo cmake git glslang-tools google-mock libavcodec-extra libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev libcurl4-openssl-dev libfreetype6-dev libglew-dev libnotify-dev libogg-dev libopus-dev libopusfile-dev libpng-dev libsdl2-dev libsqlite3-dev libssl-dev libvulkan-dev libwavpack-dev libx264-dev python rustc spirv-tools4 Compiling DDNetWe use CMake to control the compilation process, if you have all the dependencies installed, it's as easy as following these commands (make sure you are on the DDNet folder): mkdir build cd build cmake .. make -j$(nproc)
General informationHere are some general bits of information:
The source code layoutNow that you can build DDNet you can begin editing it.
The src/base directorySince DDNet is a cross-platform game, an abstraction layer over that is needed to make development easier, this directory contains many useful functions to handle that.
The src/engine directoryHere lies the game engine, it handles most stuff that is not gameplay related, such as graphics, sound, network, etc.
The src/game directoryAll gameplay related code is here, separated into client and server.
Server sideThis game uses its own hierarchical object-oriented entity system, the main class to which all other entities derive from is These entities are managed by the game world located here Some important entities are:
Client sideThe client side is made up of components, these are classes that inherit
NetworkingThe network protocol is mostly generated by python scripts that output C++ code, for example,
Code conventionsThe ongoing discussion on code conventions is located here: ddnet#2945 Currently, the following applies:
Indentation styleAllman style is used.
while(x == y) { Something(); SomethingElse(); } FinalThing(); Classes and StructsMust be prefixed by Example: class CCharacter : public CEntity { // ... }
Enums and constantsShould be screaming snake case, for example: enum { FAKETUNE_FREEZE = 1, FAKETUNE_SOLO = 2, FAKETUNE_NOJUMP = 4, FAKETUNE_NOCOLL = 8, FAKETUNE_NOHOOK = 16, FAKETUNE_JETPACK = 32, FAKETUNE_NOHAMMER = 64, };
Variable naming
These are laid out like this:
Qualifiers
Prefixes
Common snippetsHere is a list of code that you may frequently see across the codebase:
Formatting textchar aBuf[128]; str_format(aBuf, sizeof(aBuf), "number: %d", 2); See printf documentation for a list of all format specifiers. Iterating over all playersfor(int i = 0; i < MAX_CLIENTS; i++) { // Server-side CPlayer *pPlayer = GameServer()->m_apPlayers[i]; }
Printing to the game consoleConsole()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "wikiprint", "Hello from the ddnet wiki!");
Debug printingint i = 2; dbg_msg("wikiprint", "Hello from the ddnet wiki: %d", i); Translating text in the client
DoButton(..., Localize("Connect"), ...); The string can also contain format specifiers. The translated string must contain the same format specifiers. char aBuf[128]; str_format(aBuf, sizeof(aBuf), Localize("%d of %d servers"), NumServers, TotalServers); A script is used to scan the code for calls to // Do NOT do this: const char *pStr = Localize(Team == TEAM_RED ? "Red team" : "Blue team"); // Do this instead: const char *pStr = Team == TEAM_RED ? Localize("Red team") : Localize("Blue team"); External resources
Retrieved from "https://wiki.ddnet.org/wiki/Development?oldid=21035" |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |