Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Contribution Scores
Random page
Help about MediaWiki
External Links
Homepage
Discord
Forum
Funding
DDraceNetwork
Search
Search
English
Create account
Log in
Personal tools
Create account
Log in
Export translations
Translate
English
Language statistics
Message group statistics
Export
Tools
Tools
move to sidebar
hide
Actions
Language statistics
Message group statistics
Export
General
Special pages
Printable version
Settings
Group
Aled
Binds
Block
Catch16
Category:Templates
Collision
Common Terminology
DDNet Mobile Tutorial
DDRace
Death
Deepfly
Demos
Development
Drag Part
Dragger
Dummy
Dummy drag
Edge jump
Extra tools
FAQ
FNG
Foot
Freeze
Getting started
GFX Troubleshooting
Gores
Grenade
Hammer
Hammerfly
Hammerhit
Hook
Hookfly
How to contribute
Infection
Jetpack
Jump
LAN Server
Laser
Main Page
Map
Mapping
Monster
Movement
Ninja
Pistol
Pseudofly
Ranks and Points
Resources
Rocketfly
Settings and Commands
Shotgun
Shotgunfly
Skin Creation
Speedups
Stoppers
Switch layer
Teams
TeeSmash
TeeWare
Telegun
Teleporter
Teleportfly
Template:Infobox mod
Template:Infobox weapon
Template:MigrateTranslationText
Template:Note
Template:Stub
Template:Tip
Template:Todo
Template:Warning
Ticks
Tiles
Timeline
Troubleshooting
Tune zones
Vanilla
World
ZCatch
Language
aa - Afar
aae - Arbëresh
ab - Abkhazian
abs - Ambonese Malay
ace - Achinese
acm - Iraqi Arabic
ady - Adyghe
ady-cyrl - Adyghe (Cyrillic script)
aeb - Tunisian Arabic
aeb-arab - Tunisian Arabic (Arabic script)
aeb-latn - Tunisian Arabic (Latin script)
af - Afrikaans
aln - Gheg Albanian
alt - Southern Altai
am - Amharic
ami - Amis
an - Aragonese
ang - Old English
ann - Obolo
anp - Angika
ar - Arabic
arc - Aramaic
arn - Mapuche
arq - Algerian Arabic
ary - Moroccan Arabic
arz - Egyptian Arabic
as - Assamese
ase - American Sign Language
ast - Asturian
atj - Atikamekw
av - Avaric
avk - Kotava
awa - Awadhi
ay - Aymara
az - Azerbaijani
azb - South Azerbaijani
ba - Bashkir
ban - Balinese
ban-bali - Balinese (Balinese script)
bar - Bavarian
bbc - Batak Toba
bbc-latn - Batak Toba (Latin script)
bcc - Southern Balochi
bci - Baoulé
bcl - Central Bikol
bdr - West Coast Bajau
be - Belarusian
be-tarask - Belarusian (Taraškievica orthography)
bew - Betawi
bg - Bulgarian
bgn - Western Balochi
bh - Bhojpuri
bho - Bhojpuri
bi - Bislama
bjn - Banjar
blk - Pa'O
bm - Bambara
bn - Bangla
bo - Tibetan
bpy - Bishnupriya
bqi - Bakhtiari
br - Breton
brh - Brahui
bs - Bosnian
btm - Batak Mandailing
bto - Iriga Bicolano
bug - Buginese
bxr - Russia Buriat
ca - Catalan
cbk-zam - Chavacano
cdo - Mindong
ce - Chechen
ceb - Cebuano
ch - Chamorro
chn - Chinook Jargon
cho - Choctaw
chr - Cherokee
chy - Cheyenne
ckb - Central Kurdish
co - Corsican
cps - Capiznon
cpx - Pu–Xian Min
cpx-hans - Pu–Xian Min (Simplified Han script)
cpx-hant - Pu–Xian Min (Traditional Han script)
cpx-latn - Pu–Xian Min (Latin script)
cr - Cree
crh - Crimean Tatar
crh-cyrl - Crimean Tatar (Cyrillic script)
crh-latn - Crimean Tatar (Latin script)
crh-ro - Dobrujan Tatar
cs - Czech
csb - Kashubian
cu - Church Slavic
cv - Chuvash
cy - Welsh
da - Danish
dag - Dagbani
de - German
de-at - Austrian German
de-ch - Swiss High German
de-formal - German (formal address)
dga - Dagaare
din - Dinka
diq - Zazaki
dsb - Lower Sorbian
dtp - Central Dusun
dty - Doteli
dv - Divehi
dz - Dzongkha
ee - Ewe
efi - Efik
egl - Emilian
el - Greek
eml - Emiliano-Romagnolo
en - English
en-ca - Canadian English
en-gb - British English
eo - Esperanto
es - Spanish
es-419 - Latin American Spanish
es-formal - Spanish (formal address)
et - Estonian
eu - Basque
ext - Extremaduran
fa - Persian
fat - Fanti
ff - Fula
fi - Finnish
fit - Tornedalen Finnish
fj - Fijian
fo - Faroese
fon - Fon
fr - French
frc - Cajun French
frp - Arpitan
frr - Northern Frisian
fur - Friulian
fy - Western Frisian
ga - Irish
gaa - Ga
gag - Gagauz
gan - Gan
gan-hans - Gan (Simplified Han script)
gan-hant - Gan (Traditional Han script)
gcf - Guadeloupean Creole
gcr - Guianan Creole
gd - Scottish Gaelic
gl - Galician
gld - Nanai
glk - Gilaki
gn - Guarani
gom - Goan Konkani
gom-deva - Goan Konkani (Devanagari script)
gom-latn - Goan Konkani (Latin script)
gor - Gorontalo
got - Gothic
gpe - Ghanaian Pidgin
grc - Ancient Greek
gsw - Alemannic
gu - Gujarati
guc - Wayuu
gur - Frafra
guw - Gun
gv - Manx
ha - Hausa
hak - Hakka Chinese
haw - Hawaiian
he - Hebrew
hi - Hindi
hif - Fiji Hindi
hif-latn - Fiji Hindi (Latin script)
hil - Hiligaynon
hno - Northern Hindko
ho - Hiri Motu
hr - Croatian
hrx - Hunsrik
hsb - Upper Sorbian
hsn - Xiang
ht - Haitian Creole
hu - Hungarian
hu-formal - Hungarian (formal address)
hy - Armenian
hyw - Western Armenian
hz - Herero
ia - Interlingua
ibb - Ibibio
id - Indonesian
ie - Interlingue
ig - Igbo
igl - Igala
ii - Sichuan Yi
ik - Inupiaq
ike-cans - Eastern Canadian (Aboriginal syllabics)
ike-latn - Eastern Canadian (Latin script)
ilo - Iloko
inh - Ingush
io - Ido
is - Icelandic
it - Italian
iu - Inuktitut
ja - Japanese
jam - Jamaican Creole English
jbo - Lojban
jut - Jutish
jv - Javanese
ka - Georgian
kaa - Kara-Kalpak
kab - Kabyle
kai - Karekare
kbd - Kabardian
kbd-cyrl - Kabardian (Cyrillic script)
kbp - Kabiye
kcg - Tyap
kea - Kabuverdianu
kg - Kongo
kge - Komering
khw - Khowar
ki - Kikuyu
kiu - Kirmanjki
kj - Kuanyama
kjh - Khakas
kjp - Eastern Pwo
kk - Kazakh
kk-arab - Kazakh (Arabic script)
kk-cn - Kazakh (China)
kk-cyrl - Kazakh (Cyrillic script)
kk-kz - Kazakh (Kazakhstan)
kk-latn - Kazakh (Latin script)
kk-tr - Kazakh (Turkey)
kl - Kalaallisut
km - Khmer
kn - Kannada
ko - Korean
ko-kp - Korean (North Korea)
koi - Komi-Permyak
kr - Kanuri
krc - Karachay-Balkar
kri - Krio
krj - Kinaray-a
krl - Karelian
ks - Kashmiri
ks-arab - Kashmiri (Arabic script)
ks-deva - Kashmiri (Devanagari script)
ksh - Colognian
ksw - S'gaw Karen
ku - Kurdish
ku-arab - Kurdish (Arabic script)
ku-latn - Kurdish (Latin script)
kum - Kumyk
kus - Kʋsaal
kv - Komi
kw - Cornish
ky - Kyrgyz
la - Latin
lad - Ladino
lb - Luxembourgish
lbe - Lak
lez - Lezghian
lfn - Lingua Franca Nova
lg - Ganda
li - Limburgish
lij - Ligurian
liv - Livonian
lki - Laki
lld - Ladin
lmo - Lombard
ln - Lingala
lo - Lao
loz - Lozi
lrc - Northern Luri
lt - Lithuanian
ltg - Latgalian
lus - Mizo
luz - Southern Luri
lv - Latvian
lzh - Literary Chinese
lzz - Laz
mad - Madurese
mag - Magahi
mai - Maithili
map-bms - Basa Banyumasan
mdf - Moksha
mg - Malagasy
mh - Marshallese
mhr - Eastern Mari
mi - Māori
min - Minangkabau
mk - Macedonian
ml - Malayalam
mn - Mongolian
mnc - Manchu
mnc-latn - Manchu (Latin script)
mnc-mong - Manchu (Mongolian script)
mni - Manipuri
mnw - Mon
mo - Moldovan
mos - Mossi
mr - Marathi
mrh - Mara
mrj - Western Mari
ms - Malay
ms-arab - Malay (Jawi script)
mt - Maltese
mus - Muscogee
mwl - Mirandese
my - Burmese
myv - Erzya
mzn - Mazanderani
na - Nauru
nah - Nāhuatl
nan - Minnan
nap - Neapolitan
nb - Norwegian Bokmål
nds - Low German
nds-nl - Low Saxon
ne - Nepali
new - Newari
ng - Ndonga
nia - Nias
nit - కొలామి
niu - Niuean
nl - Dutch
nl-informal - Dutch (informal address)
nmz - Nawdm
nn - Norwegian Nynorsk
no - Norwegian
nod - Northern Thai
nog - Nogai
nov - Novial
nqo - N’Ko
nrm - Norman
nso - Northern Sotho
nv - Navajo
ny - Nyanja
nyn - Nyankole
nyo - Nyoro
nys - Nyungar
oc - Occitan
ojb - Northwestern Ojibwa
olo - Livvi-Karelian
om - Oromo
or - Odia
os - Ossetic
pa - Punjabi
pag - Pangasinan
pam - Pampanga
pap - Papiamento
pcd - Picard
pcm - Nigerian Pidgin
pdc - Pennsylvania German
pdt - Plautdietsch
pfl - Palatine German
pi - Pali
pih - Norfuk / Pitkern
pl - Polish
pms - Piedmontese
pnb - Western Punjabi
pnt - Pontic
prg - Prussian
ps - Pashto
pt - Portuguese
pt-br - Brazilian Portuguese
pwn - Paiwan
qqq - Message documentation
qu - Quechua
qug - Chimborazo Highland Quichua
rgn - Romagnol
rif - Riffian
rki - Arakanese
rm - Romansh
rmc - Carpathian Romani
rmy - Vlax Romani
rn - Rundi
ro - Romanian
roa-tara - Tarantino
rsk - Pannonian Rusyn
ru - Russian
rue - Rusyn
rup - Aromanian
ruq - Megleno-Romanian
ruq-cyrl - Megleno-Romanian (Cyrillic script)
ruq-latn - Megleno-Romanian (Latin script)
rut - Rutul
rw - Kinyarwanda
ryu - Okinawan
sa - Sanskrit
sah - Yakut
sat - Santali
sc - Sardinian
scn - Sicilian
sco - Scots
sd - Sindhi
sdc - Sassarese Sardinian
sdh - Southern Kurdish
se - Northern Sami
se-fi - Northern Sami (Finland)
se-no - Northern Sami (Norway)
se-se - Northern Sami (Sweden)
sei - Seri
ses - Koyraboro Senni
sg - Sango
sgs - Samogitian
sh - Serbo-Croatian
sh-cyrl - Serbo-Croatian (Cyrillic script)
sh-latn - Serbo-Croatian (Latin script)
shi - Tachelhit
shi-latn - Tachelhit (Latin script)
shi-tfng - Tachelhit (Tifinagh script)
shn - Shan
shy - Shawiya
shy-latn - Shawiya (Latin script)
si - Sinhala
simple - Simple English
sjd - Kildin Sami
sje - Pite Sami
sk - Slovak
skr - Saraiki
skr-arab - Saraiki (Arabic script)
sl - Slovenian
sli - Lower Silesian
sm - Samoan
sma - Southern Sami
smn - Inari Sami
sms - Skolt Sami
sn - Shona
so - Somali
sq - Albanian
sr - Serbian
sr-ec - Serbian (Cyrillic script)
sr-el - Serbian (Latin script)
srn - Sranan Tongo
sro - Campidanese Sardinian
ss - Swati
st - Southern Sotho
stq - Saterland Frisian
sty - Siberian Tatar
su - Sundanese
sv - Swedish
sw - Swahili
syl - Sylheti
szl - Silesian
szy - Sakizaya
ta - Tamil
tay - Tayal
tcy - Tulu
tdd - Tai Nuea
te - Telugu
tet - Tetum
tg - Tajik
tg-cyrl - Tajik (Cyrillic script)
tg-latn - Tajik (Latin script)
th - Thai
ti - Tigrinya
tk - Turkmen
tl - Tagalog
tly - Talysh
tly-cyrl - Talysh (Cyrillic script)
tn - Tswana
to - Tongan
tok - Toki Pona
tpi - Tok Pisin
tr - Turkish
tru - Turoyo
trv - Taroko
ts - Tsonga
tt - Tatar
tt-cyrl - Tatar (Cyrillic script)
tt-latn - Tatar (Latin script)
ttj - Tooro
tum - Tumbuka
tw - Twi
ty - Tahitian
tyv - Tuvinian
tzm - Central Atlas Tamazight
udm - Udmurt
ug - Uyghur
ug-arab - Uyghur (Arabic script)
ug-latn - Uyghur (Latin script)
uk - Ukrainian
ur - Urdu
uz - Uzbek
uz-cyrl - Uzbek (Cyrillic script)
uz-latn - Uzbek (Latin script)
ve - Venda
vec - Venetian
vep - Veps
vi - Vietnamese
vls - West Flemish
vmf - Main-Franconian
vmw - Makhuwa
vo - Volapük
vot - Votic
vro - Võro
wa - Walloon
wal - Wolaytta
war - Waray
wls - Wallisian
wo - Wolof
wuu - Wu
wuu-hans - Wu (Simplified Han script)
wuu-hant - Wu (Traditional Han script)
xal - Kalmyk
xh - Xhosa
xmf - Mingrelian
xsy - Saisiyat
yi - Yiddish
yo - Yoruba
yrl - Nheengatu
yue - Cantonese
yue-hans - Cantonese (Simplified Han script)
yue-hant - Cantonese (Traditional Han script)
za - Zhuang
zea - Zeelandic
zgh - Standard Moroccan Tamazight
zh - Chinese
zh-cn - Chinese (China)
zh-hans - Simplified Chinese
zh-hant - Traditional Chinese
zh-hk - Chinese (Hong Kong)
zh-mo - Chinese (Macau)
zh-my - Chinese (Malaysia)
zh-sg - Chinese (Singapore)
zh-tw - Chinese (Taiwan)
zu - Zulu
Format
Export for off-line translation
Export in native format
Export in CSV format
Fetch
<languages /> <div lang="en" dir="ltr" class="mw-content-ltr"> 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. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ==Your development environment== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> It is extremely recommended to set up a Linux environment to begin programming in DDNet for the following reasons (as of now): *Most DDNet contributors actually use Linux to contribute. *Easier package management, you can easily install all the needed libraries and begin contributing. *This article doesn't have yet a Windows version and is focused on Linux. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> First and 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. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Some useful resources to learn C++: *[https://www.learncpp.com/ learncpp.com] *[https://en.cppreference.com/w/ cppreference.com] *Your search engine of preference </div> <div lang="en" dir="ltr" class="mw-content-ltr"> The source code of DDNet is managed using [https://git-scm.com/ Git], a version control system, an essential tool to collaborate with multiple developers. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> If you don't have git yet in your Linux distribution, make sure to install it, for example in most debian/ubuntu based distributions: <code>sudo apt install git</code>. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ==Getting the source code== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> The source code is located on [https://github.com/ddnet/ddnet 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. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> If you are not familiar with git/github you can learn the basics here: [https://docs.github.com/en/get-started/quickstart/hello-world Hello World - Github] </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ==Installing the dependencies== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> If 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 </div> <div lang="en" dir="ltr" class="mw-content-ltr"> For Arch Linux: </div> <div lang="en" dir="ltr" class="mw-content-ltr"> <syntaxhighlight lang="bash"> 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 </syntaxhighlight> </div> <div lang="en" dir="ltr" class="mw-content-ltr"> For Debian: </div> <div lang="en" dir="ltr" class="mw-content-ltr"> <syntaxhighlight lang="bash"> 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 python3 rustc spirv-tools </syntaxhighlight> </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ==Compiling DDNet== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> We 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): </div> <div lang="en" dir="ltr" class="mw-content-ltr"> <syntaxhighlight lang="bash"> mkdir build cd build cmake .. make -j$(nproc) </syntaxhighlight> </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ==General information== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Here are some general bits of information: *Currently, the source code is compiled with the C++17 standard, but you will see that many parts of the code are more C-like since only mostly new code uses C++17 stuff. *<code>std::string</code> is rarely used, char arrays plus using <code>system.h</code> methods for handling them are the norm. *Most I/O code, formatting and printing is done using <code>system.h</code> provided methods. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ==The source code layout== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Now that you can build DDNet you can begin editing it. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ===The src/base directory=== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Since 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. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ===The src/engine directory=== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Here lies the game engine, it handles most stuff that is not gameplay related, such as graphics, sound, network, etc. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ===The src/game directory=== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> All gameplay related code is here, separated into client and server. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ====Server side==== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> This game uses its own hierarchical object-oriented entity system, the main class to which all other entities derive from is <code>CEntity</code> located in <code>src/game/server/entity.h</code>. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> These entities are managed by the game world located here <code>src/game/server/gameworld.h</code> </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Some important entities are: </div> <div lang="en" dir="ltr" class="mw-content-ltr"> *[https://github.com/ddnet/ddnet/blob/master/src/game/server/entities/character.h CCharacter]: Represents a [[Special:MyLanguage/Common_Terminology#Tee|tee]] that is alive, it is instantiated when a tee spawns and deleted when it dies. * [https://github.com/ddnet/ddnet/blob/master/src/game/server/player.h CPlayer] contains information not related to the [[Common Terminology/fr#Tee|Tee]] (nickname, flag, etc.). </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ====Client side==== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> The client side is made up of components, these are classes that inherit [https://github.com/ddnet/ddnet/blob/master/src/game/client/component.h CComponent] defined in <code>src/game/client/component.h</code>. These components can implement the virtual methods such as <code>OnInit</code>, <code>OnMessage</code>, etc. to provide their functionality. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ====Networking==== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> The network protocol is mostly generated by python scripts that output C++ code, for example, <code>datasrc/network.py</code> defines all network packets. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ==Code conventions== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> The ongoing discussion on code conventions is located here: [https://github.com/ddnet/ddnet/issues/2945 ddnet#2945] </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Currently, the following applies: </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ===Indentation style=== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> [https://en.wikipedia.org/wiki/Indentation_style#Allman_style Allman style] is used. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> <blockquote> This style puts the brace associated with a control statement on the next line, indented to the same level as the control statement. Statements within the braces are indented to the next level. </blockquote> </div> <div lang="en" dir="ltr" class="mw-content-ltr"> <syntaxhighlight lang="cpp"> while(x == y) { Something(); SomethingElse(); } </div> <div lang="en" dir="ltr" class="mw-content-ltr"> FinalThing(); </syntaxhighlight> </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ===Classes and Structs=== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Must be prefixed by <code>C</code> (for legacy reasons this is ignored for structs in some places, such as in graphics code) or <code>I</code> for interfaces. New <code>struct</code>s should be prefixed by <code>S</code>. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Example: </div> <div lang="en" dir="ltr" class="mw-content-ltr"> <syntaxhighlight lang="cpp"> class CCharacter : public CEntity { // ... } </syntaxhighlight> </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ===Enums and constants=== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Should be ''screaming snake case [https://en.wikipedia.org/wiki/Snake_case]'', for example: <code>MAX_PLAYERS</code> </div> <div lang="en" dir="ltr" class="mw-content-ltr"> <syntaxhighlight lang="cpp"> enum { FAKETUNE_FREEZE = 1, FAKETUNE_SOLO = 2, FAKETUNE_NOJUMP = 4, FAKETUNE_NOCOLL = 8, FAKETUNE_NOHOOK = 16, FAKETUNE_JETPACK = 32, FAKETUNE_NOHAMMER = 64, }; </syntaxhighlight> </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ===Variable naming=== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> *The names of variables contain 3 parts: qualifier, prefix and name. *Variable names should start with uppercase unless they are 1 char long without any prefix or qualifier, for example: <code>i</code>, <code>x</code>, <code>y</code>. *Variables can have more than 1 qualifier (or zero) and more than 1 prefix (or zero). </div> <div lang="en" dir="ltr" class="mw-content-ltr"> These are laid out like this: <code>[qualifiers]_[prefixes][Name]</code> </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ====Qualifiers==== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> *<code>m</code> for member variables: <code>m_MyVariable</code>. *<code>s</code> for static variables: <code>s_MyStaticVariable</code>, <code>ms_MyStaticMemberVariable</code>. *<code>g</code> for global variables with external linkage: <code>gs_MyGlobalStaticVar</code>. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ====Prefixes==== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> *<code>p</code> for pointers: <code>pMyPointer</code>, <code>m_pCharacter</code>, <code>ppMyPointerToPointer</code>. *<code>a</code> for arrays: <code>aMyArray</code>, <code>aBuf</code>. *<code>v</code> for <code>std::vector</code>s: <code>vMyVector</code>, <code>vpvMyVectorOfPointersToVectors</code>. *<code>fn</code> for functions: <code>pfnMyCallback</code>, <code>m_papfnMyPointerToArrayOfCallbacks</code>. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ==Common snippets== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Here is a list of code that you may frequently see across the codebase: </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ===Formatting text=== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> <syntaxhighlight lang="cpp"> char aBuf[128]; str_format(aBuf, sizeof(aBuf), "number: %d", 2); </syntaxhighlight> </div> <div lang="en" dir="ltr" class="mw-content-ltr"> See [https://cplusplus.com/reference/cstdio/printf/ printf documentation] for a list of all format specifiers. ===Iterating over all players=== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> <syntaxhighlight lang="cpp"> for(int i = 0; i < MAX_CLIENTS; i++) { // Server-side CPlayer *pPlayer = GameServer()->m_apPlayers[i]; } </syntaxhighlight> </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ===Printing to the game console=== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> <syntaxhighlight lang="cpp"> Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "wikiprint", "Hello from the ddnet wiki!"); </syntaxhighlight> </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ===Debug printing=== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> <syntaxhighlight lang="cpp"> int i = 2; dbg_msg("wikiprint", "Hello from the ddnet wiki: %d", i); </syntaxhighlight> </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ===Translating text in the client=== <code>Localize</code> can be used in the game client to get the translation for a specific string from the language file selected by the user.<syntaxhighlight lang="cpp"> DoButton(..., Localize("Connect"), ...); </syntaxhighlight>The string can also contain format specifiers. The translated string must contain the same format specifiers.<syntaxhighlight lang="cpp"> char aBuf[128]; str_format(aBuf, sizeof(aBuf), Localize("%d of %d servers"), NumServers, TotalServers); </syntaxhighlight>A script is used to scan the code for calls to <code>Localize</code> and collect the strings to update the translation files. For this reason, the call to <code>Localize</code> must not contain any other code, or the script cannot determine the text correctly.<syntaxhighlight lang="cpp"> // Do NOT do this: const char *pStr = Localize(Team == TEAM_RED ? "Red team" : "Blue team"); </div> <div lang="en" dir="ltr" class="mw-content-ltr"> // Do this instead: const char *pStr = Team == TEAM_RED ? Localize("Red team") : Localize("Blue team"); </syntaxhighlight> </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ==External resources== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> *[https://edgarluque.com/blog/ui-code-ddnet/ UI Code in DDraceNetwork] by [[Special:MyLanguage/User:Ryozuki|Ryozuki]] *[https://edgarluque.com/blog/intro-to-ddnet/ An intro to the DDraceNetwork game source code] by [[Special:MyLanguage/User:Ryozuki|Ryozuki]] *[https://edgarluque.com/blog/code-conventions-in-ddnet/ Code conventions in DDraceNetwork] by [[Special:MyLanguage/User:Ryozuki|Ryozuki]] *[https://edgarluque.com/blog/chat-command-ddracenetwork/ Implementing a chat command in DDraceNetwork] by [[Special:MyLanguage/User:Ryozuki|Ryozuki]] *[https://codedoc.ddnet.org/ Auto generated docs] *[https://ddnet.org/libtw2-doc/ Technical documentation of Teeworlds file formats and network protocol] *[https://heinrich5991.github.io/blog/blog/one-tick-unfreeze The Anatomy of a One Tick Unfreeze] *[https://www.youtube.com/playlist?list=PLhJkqAQmOh5LyYOfnMy4PJB6CSZltQyTc Teeworlds programming YouTube tutorial] by [[User:ChillerDragon|ChillerDragon]] *[https://chillerdragon.github.io/teeworlds-protocol/ Teeworlds 0.6/0.7 network protocol documentation] by [[User:ChillerDragon|ChillerDragon]] </div> <div lang="en" dir="ltr" class="mw-content-ltr"> ==About Tee Skin Rendering== </div> <div lang="en" dir="ltr" class="mw-content-ltr"> This section explains how to render a tee skin. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Values put together by Patiga Special Thanks to Jupstar Segment Scaling: body: 100% feet: 150% eyes: 120% eye blink: 45% hand: 93.75% Positioning: 64/64 = 1 = width or height of the body segment body: 4/64 up feet: 10/64 down 7/64 left/right eyes: 0.125 up 0.05 left/right eye movement: dir = angle of eyes (view angle), right = 0 eyes: x: cos(dir) * 0.125 y: sin(dir) * 0.1 each eye (away from the other): x: abs(cos(dir)) * 0.01 </div>
Toggle limited content width