59 changes: 43 additions & 16 deletions data/languages/portuguese.txt
Expand Up @@ -464,12 +464,6 @@ Spectator mode
Spectators
== Espectadores

Standard gametype
== Tipo de jogo normal

Standard map
== Mapa normal

Stop record
== Parar de gravar

Expand Down Expand Up @@ -875,15 +869,18 @@ Switch weapon when out of ammo
AntiPing: predict grenade paths
== Antiping: prever os caminhos da granada

AntiPing limit
== Limite do Antiping

Inner color
== Cor interior

Downloading ddnet-info.json failed
==

Successfully saved the replay!
==

Saving ddnet-settings.cfg failed
==

Replay feature is disabled!
==

Expand Down Expand Up @@ -962,13 +959,7 @@ Show DDNet map finishes in server browser
transmits your player name to info2.ddnet.tw
==

Search:
==

Exclude:
==

Search servers:
Theme
==

%d of %d servers
Expand All @@ -992,6 +983,9 @@ Indicate map finish
Unfinished map
==

File
==

Markers:
==

Expand All @@ -1013,6 +1007,9 @@ Date
Fetch Info
==

Demos directory
==

Render
==

Expand Down Expand Up @@ -1043,6 +1040,9 @@ Reset wanted weapon on death
Skip the main menu
==

Themes directory
==

Download skins
==

Expand All @@ -1055,6 +1055,12 @@ Fat skins (DDFat)
Skin prefix
==

Skin Database
==

Skins directory
==

Hook collisions
==

Expand Down Expand Up @@ -1121,6 +1127,12 @@ Enable long pain sound (used when shooting in freeze)
Threaded sound loading
==

Background music volume
==

Assets
==

Friend message
==

Expand Down Expand Up @@ -1160,12 +1172,27 @@ Show other players' hook collision lines
Show other players' key presses
==

Use current map as background
==

Show tiles layers from BG map
==

Try fast HTTP map download first
==

Entities
==

Emoticons
==

Particles
==

Assets directory
==

Learn
==

Expand Down
59 changes: 43 additions & 16 deletions data/languages/romanian.txt
Expand Up @@ -452,12 +452,6 @@ Spectator mode
Spectators
== Spectatori

Standard gametype
== Jocuri standard

Standard map
== Hărți standard

Stop record
== Stop înreg.

Expand Down Expand Up @@ -640,9 +634,15 @@ Name plates size
Type:
== Tip:

Downloading ddnet-info.json failed
==

Successfully saved the replay!
==

Saving ddnet-settings.cfg failed
==

Replay feature is disabled!
==

Expand Down Expand Up @@ -733,13 +733,7 @@ Show DDNet map finishes in server browser
transmits your player name to info2.ddnet.tw
==

Search:
==

Exclude:
==

Search servers:
Theme
==

Search
Expand Down Expand Up @@ -784,6 +778,9 @@ Please use a different name
Remove chat
==

File
==

Markers:
==

Expand All @@ -808,6 +805,9 @@ Date
Fetch Info
==

Demos directory
==

Render
==

Expand Down Expand Up @@ -856,6 +856,9 @@ Refresh Rate
Show console window
==

Themes directory
==

Automatically take statboard screenshot
==

Expand All @@ -880,6 +883,12 @@ Fat skins (DDFat)
Skin prefix
==

Skin Database
==

Skins directory
==

Hook collisions
==

Expand Down Expand Up @@ -979,12 +988,18 @@ Threaded sound loading
Map sound volume
==

Background music volume
==

HUD
==

DDNet
==

Assets
==

DDNet Client needs to be restarted to complete update!
==

Expand Down Expand Up @@ -1099,9 +1114,6 @@ Show others (own team only)
Show quads
==

AntiPing limit
==

AntiPing
==

Expand Down Expand Up @@ -1129,6 +1141,9 @@ Background (regular)
Background (entities)
==

Use current map as background
==

Show tiles layers from BG map
==

Expand Down Expand Up @@ -1156,6 +1171,18 @@ Check now
New random timeout code
==

Entities
==

Emoticons
==

Particles
==

Assets directory
==

Learn
==

Expand Down
72 changes: 45 additions & 27 deletions data/languages/russian.txt
Expand Up @@ -448,12 +448,6 @@ Spectator mode
Spectators
== Наблюдатели

Standard gametype
== Станд. тип игры

Standard map
== Станд. карта

Stop record
== Стоп

Expand Down Expand Up @@ -643,9 +637,6 @@ Join game
FSAA samples
== Сэмплов FSAA

%d of %d servers, %d players
== %d из %d серверов, %d игроков

Sound volume
== Громкость звука

Expand Down Expand Up @@ -703,9 +694,6 @@ Lht.
UI Color
== Цвет интерфейса

Host address
== Адрес сервера

Crc:
== Crc:

Expand Down Expand Up @@ -823,9 +811,6 @@ Friend
Demo
== Демо

AntiPing limit
== AntiPing лимит

Inner color
== Внутренний цвет

Expand Down Expand Up @@ -1186,9 +1171,6 @@ The width or height of texture %s is not divisible by 16, which might cause visu
Warning
== Предупреждение

Menu
== Меню

Use k key to kill (restart), q to pause and watch other players. See settings for other key binds.
== Используйте кнопку k, чтобы возродиться, q для паузы и наблюдением за остальными игроками. Проверьте настройки для остальных кнопок.

Expand Down Expand Up @@ -1228,15 +1210,6 @@ Editor
News
== Новости

Search:
== Искать:

Exclude:
== Исключить:

Search servers:
== Искать сервера:

%d of %d servers
== %d из %d серверов

Expand All @@ -1258,3 +1231,48 @@ Learn
[Start menu]
Play
== Играть

Downloading ddnet-info.json failed
==

Saving ddnet-settings.cfg failed
==

Theme
==

File
==

Demos directory
==

Themes directory
==

Skin Database
==

Skins directory
==

Background music volume
==

Assets
==

Use current map as background
==

Entities
==

Emoticons
==

Particles
==

Assets directory
==
59 changes: 43 additions & 16 deletions data/languages/serbian.txt
Expand Up @@ -443,12 +443,6 @@ Spectator mode
Spectators
== Posmatrači

Standard gametype
== Standardni tip igre

Standard map
== Standardna mapa

Stop record
== Prekini snimanje

Expand Down Expand Up @@ -656,6 +650,12 @@ Video name:
Use k key to kill (restart), q to pause and watch other players. See settings for other key binds.
== Tipka K da se ubijes (restart), tipka q da pauziras i gledas druge igrače.

Downloading ddnet-info.json failed
==

Saving ddnet-settings.cfg failed
==

The width or height of texture %s is not divisible by 16, which might cause visual bugs.
==

Expand Down Expand Up @@ -728,13 +728,7 @@ Show DDNet map finishes in server browser
transmits your player name to info2.ddnet.tw
==

Search:
==

Exclude:
==

Search servers:
Theme
==

Search
Expand Down Expand Up @@ -779,6 +773,9 @@ Please use a different name
Remove chat
==

File
==

Markers:
==

Expand All @@ -803,6 +800,9 @@ Date
Fetch Info
==

Demos directory
==

Render
==

Expand Down Expand Up @@ -854,6 +854,9 @@ Refresh Rate
Show console window
==

Themes directory
==

Automatically take statboard screenshot
==

Expand All @@ -878,6 +881,12 @@ Fat skins (DDFat)
Skin prefix
==

Skin Database
==

Skins directory
==

Hook collisions
==

Expand Down Expand Up @@ -977,12 +986,18 @@ Threaded sound loading
Map sound volume
==

Background music volume
==

HUD
==

DDNet
==

Assets
==

DDNet Client needs to be restarted to complete update!
==

Expand Down Expand Up @@ -1097,9 +1112,6 @@ Show others (own team only)
Show quads
==

AntiPing limit
==

AntiPing
==

Expand Down Expand Up @@ -1127,6 +1139,9 @@ Background (regular)
Background (entities)
==

Use current map as background
==

Show tiles layers from BG map
==

Expand Down Expand Up @@ -1154,6 +1169,18 @@ Check now
New random timeout code
==

Entities
==

Emoticons
==

Particles
==

Assets directory
==

https://wiki.ddnet.tw/
==

Expand Down
1,260 changes: 1,260 additions & 0 deletions data/languages/serbian_cyrillic.txt

Large diffs are not rendered by default.

51 changes: 39 additions & 12 deletions data/languages/simplified_chinese.txt
Expand Up @@ -480,12 +480,6 @@ Spectator mode
Spectators
== 旁观者

Standard gametype
== 原生游戏模式

Standard map
== 原生地图

Stop record
== 停止录制

Expand Down Expand Up @@ -783,9 +777,6 @@ Show quads
Default zoom
== 默认缩放

AntiPing limit
== AntiPing 限制

AntiPing: predict other players
== AntiPing:预测其他玩家

Expand Down Expand Up @@ -1231,13 +1222,13 @@ Server executable not found, can't run server
Editor
== 编辑器

Search:
Downloading ddnet-info.json failed
==

Exclude:
Saving ddnet-settings.cfg failed
==

Search servers:
Theme
==

%d of %d servers
Expand All @@ -1252,5 +1243,41 @@ Search servers:
%d player
==

File
==

Demos directory
==

Themes directory
==

Download skins
==

Skin Database
==

Skins directory
==

Background music volume
==

Assets
==

Use current map as background
==

Entities
==

Emoticons
==

Particles
==

Assets directory
==
59 changes: 43 additions & 16 deletions data/languages/slovak.txt
Expand Up @@ -440,12 +440,6 @@ Spectator mode
Spectators
== Diváci

Standard gametype
== Štandardný herný typ

Standard map
== Štandardná mapa

Stop record
== Nenahrávať

Expand Down Expand Up @@ -628,9 +622,15 @@ Name plates size
Type:
== Typ:

Downloading ddnet-info.json failed
==

Successfully saved the replay!
==

Saving ddnet-settings.cfg failed
==

Replay feature is disabled!
==

Expand Down Expand Up @@ -724,13 +724,7 @@ Show DDNet map finishes in server browser
transmits your player name to info2.ddnet.tw
==

Search:
==

Exclude:
==

Search servers:
Theme
==

Search
Expand Down Expand Up @@ -775,6 +769,9 @@ Please use a different name
Remove chat
==

File
==

Markers:
==

Expand All @@ -799,6 +796,9 @@ Date
Fetch Info
==

Demos directory
==

Render
==

Expand Down Expand Up @@ -850,6 +850,9 @@ Refresh Rate
Show console window
==

Themes directory
==

Automatically take statboard screenshot
==

Expand All @@ -874,6 +877,12 @@ Fat skins (DDFat)
Skin prefix
==

Skin Database
==

Skins directory
==

Hook collisions
==

Expand Down Expand Up @@ -973,12 +982,18 @@ Threaded sound loading
Map sound volume
==

Background music volume
==

HUD
==

DDNet
==

Assets
==

DDNet Client needs to be restarted to complete update!
==

Expand Down Expand Up @@ -1093,9 +1108,6 @@ Show others (own team only)
Show quads
==

AntiPing limit
==

AntiPing
==

Expand Down Expand Up @@ -1123,6 +1135,9 @@ Background (regular)
Background (entities)
==

Use current map as background
==

Show tiles layers from BG map
==

Expand Down Expand Up @@ -1150,6 +1165,18 @@ Check now
New random timeout code
==

Entities
==

Emoticons
==

Particles
==

Assets directory
==

Learn
==

Expand Down
59 changes: 43 additions & 16 deletions data/languages/spanish.txt
Expand Up @@ -452,12 +452,6 @@ Spectator mode
Spectators
== Espectadores

Standard gametype
== Tipo de juego estándar

Standard map
== Mapa estándar

Stop record
== Detener grabación

Expand Down Expand Up @@ -1075,9 +1069,6 @@ Show others (own team only)
Show quads
== Mostrar quads

AntiPing limit
== Límite de AntiPing

AntiPing
== AntiPing

Expand Down Expand Up @@ -1180,6 +1171,12 @@ Grabs
9+ new mentions
== 9+ nuevas menciones

Downloading ddnet-info.json failed
==

Saving ddnet-settings.cfg failed
==

The width or height of texture %s is not divisible by 16, which might cause visual bugs.
==

Expand All @@ -1195,13 +1192,7 @@ Country / Region
Speed
==

Search:
==

Exclude:
==

Search servers:
Theme
==

%d of %d servers
Expand All @@ -1216,15 +1207,51 @@ Search servers:
%d player
==

File
==

Demos directory
==

Skip the main menu
==

Themes directory
==

Download skins
==

Skin Database
==

Skins directory
==

Background music volume
==

Assets
==

Client message
==

Use current map as background
==

Entities
==

Emoticons
==

Particles
==

Assets directory
==

https://wiki.ddnet.tw/
==

Expand Down
100 changes: 64 additions & 36 deletions data/languages/swedish.txt
Expand Up @@ -5,6 +5,7 @@
# Martin Pola 2011-04-02 11:17:09
# Kottizen 2011-07-02 00:34:54
# 3edcxzaq1 2020-06-25 00:00:00
# cur.ie 2020-09-28 00:00:00
##### /authors #####

##### translated strings #####
Expand Down Expand Up @@ -442,12 +443,6 @@ Spectator mode
Spectators
== Åskådare

Standard gametype
== Standard speltyp

Standard map
== Standardkarta

Stop record
== Sluta spela in

Expand Down Expand Up @@ -636,9 +631,6 @@ Show console window
Vanilla skins only
== Bara vanilla skins

AntiPing limit
== AntiPing gräns

New random timeout code
== Ny slumpad timeout kod

Expand Down Expand Up @@ -1177,71 +1169,107 @@ Show others (own team only)
== Visa andra (eget lag endast)

The width or height of texture %s is not divisible by 16, which might cause visual bugs.
==
== Bredden eller höjden av texturen %s är ej delbar med 16, och kan därav skapa visuella buggar.

Warning
==
== Varning

Use k key to kill (restart), q to pause and watch other players. See settings for other key binds.
==
== Använd knappen k för att dö (starta om), q för att pausa och se andra spelare. Se inställnignar för andra knappbindningar.

Country / Region
==
== Land / Region

Speed
==
== Hastighet

Search:
==
%d of %d servers
== %d av %d servrar.

Exclude:
==
%d of %d server
== %d av %d server

Search servers:
==
%d players
== %d spelare

%d of %d servers
%d player
== %d spelare

Skip the main menu
== Skippa till huvudmenyn

Download skins
== Ladda ner skins

Client message
== Klientmeddelande

https://wiki.ddnet.tw/
== https://wiki.ddnet.tw/

Website
== Hemsida

Settings
== Inställningar

Stop server
== Stoppa servern

Run server
== Kör servern

Server executable not found, can't run server
== Server exekveringsfil hittades ej, kan ej starta servern

Editor
== Editor

[Start menu]
Play
== Spela

Downloading ddnet-info.json failed
==

%d of %d server
Saving ddnet-settings.cfg failed
==

%d players
Theme
==

%d player
File
==

Skip the main menu
Demos directory
==

Download skins
Themes directory
==

Client message
Skin Database
==

https://wiki.ddnet.tw/
Skins directory
==

Website
Background music volume
==

Settings
Assets
==

Stop server
Use current map as background
==

Run server
Entities
==

Server executable not found, can't run server
Emoticons
==

Editor
Particles
==

[Start menu]
Play
Assets directory
==
57 changes: 42 additions & 15 deletions data/languages/traditional_chinese.txt
Expand Up @@ -474,12 +474,6 @@ Spectator mode
Spectators
== 旁觀者

Standard gametype
== 原生遊戲模式

Standard map
== 原生地圖

Stop record
== 停止錄製

Expand Down Expand Up @@ -777,9 +771,6 @@ Show quads
Default zoom
== 預設縮放

AntiPing limit
== AntiPing 限制

AntiPing: predict other players
== AntiPing:預測其他玩家

Expand Down Expand Up @@ -1191,22 +1182,22 @@ Replay %3d:%02d
https://wiki.ddnet.tw/
== https://docs.qq.com/doc/DWGFrV0xPRmVWVkla

The width or height of texture %s is not divisible by 16, which might cause visual bugs.
Downloading ddnet-info.json failed
==

Warning
Saving ddnet-settings.cfg failed
==

Speed
The width or height of texture %s is not divisible by 16, which might cause visual bugs.
==

Search:
Warning
==

Exclude:
Speed
==

Search servers:
Theme
==

%d of %d servers
Expand All @@ -1221,12 +1212,48 @@ Search servers:
%d player
==

File
==

Demos directory
==

Skip the main menu
==

Themes directory
==

Download skins
==

Skin Database
==

Skins directory
==

Background music volume
==

Assets
==

Use current map as background
==

Entities
==

Emoticons
==

Particles
==

Assets directory
==

Website
==

Expand Down
59 changes: 43 additions & 16 deletions data/languages/turkish.txt
Expand Up @@ -442,12 +442,6 @@ Spectator mode
Spectators
== İzleyiciler

Standard gametype
== Standart oyun türleri

Standard map
== Standart haritalar

Stop record
== Kaydı durdur

Expand Down Expand Up @@ -1080,9 +1074,6 @@ Show others (own team only)
Show quads
== Dörtgen yapıları göster

AntiPing limit
== AntiPing sınırı

AntiPing
== AntiPing

Expand Down Expand Up @@ -1185,25 +1176,25 @@ Grabs
9+ new mentions
== 9+ yeni bildirim

The width or height of texture %s is not divisible by 16, which might cause visual bugs.
Downloading ddnet-info.json failed
==

Warning
Saving ddnet-settings.cfg failed
==

Country / Region
The width or height of texture %s is not divisible by 16, which might cause visual bugs.
==

Speed
Warning
==

Search:
Country / Region
==

Exclude:
Speed
==

Search servers:
Theme
==

%d of %d servers
Expand All @@ -1218,12 +1209,48 @@ Search servers:
%d player
==

File
==

Demos directory
==

Skip the main menu
==

Themes directory
==

Download skins
==

Skin Database
==

Skins directory
==

Background music volume
==

Assets
==

Use current map as background
==

Entities
==

Emoticons
==

Particles
==

Assets directory
==

https://wiki.ddnet.tw/
==

Expand Down
59 changes: 43 additions & 16 deletions data/languages/ukrainian.txt
Expand Up @@ -326,12 +326,6 @@ Spectate
Spectators
== Спостерігачі

Standard gametype
== Стандартний тип гри

Standard map
== Стандартна карта

Stop record
== Зупинити запис

Expand Down Expand Up @@ -1066,9 +1060,6 @@ Show others (own team only)
Show quads
== Показувати quads

AntiPing limit
== AntiPing ліміт

AntiPing
== AntiPing

Expand Down Expand Up @@ -1174,6 +1165,12 @@ Grabs
9+ new mentions
== 9+ нових згадок

Downloading ddnet-info.json failed
==

Saving ddnet-settings.cfg failed
==

The width or height of texture %s is not divisible by 16, which might cause visual bugs.
==

Expand All @@ -1189,13 +1186,7 @@ Country / Region
Speed
==

Search:
==

Exclude:
==

Search servers:
Theme
==

%d of %d servers
Expand All @@ -1210,15 +1201,51 @@ Search servers:
%d player
==

File
==

Markers
==

Demos directory
==

Skip the main menu
==

Themes directory
==

Download skins
==

Skin Database
==

Skins directory
==

Background music volume
==

Assets
==

Use current map as background
==

Entities
==

Emoticons
==

Particles
==

Assets directory
==

https://wiki.ddnet.tw/
==

Expand Down
Binary file added data/maps/LearnToPlay.map
Binary file not shown.
Binary file added data/maps/Sunny Side Up.map
Binary file not shown.
Binary file added data/maps/Tsunami.map
Binary file not shown.
12 changes: 12 additions & 0 deletions data/maps/license.txt
@@ -1,3 +1,15 @@
Gold Mine:
Copyright <BµmM>
CC-BY-SA license

LearnToPlay:
Copyright Tridemy & Cøke
CC-BY-SA license

Sunny Side Up:
Copyright Ravie
CC-BY-SA license, grass_main is redrawn from original Teeworlds grass_main mapres (Apache 2.0 license)

Tsunami:
Copyright louis
CC-BY-SA license
Binary file modified data/maps7/Gold Mine.map
Binary file not shown.
Binary file added data/maps7/LearnToPlay.map
Binary file not shown.
Binary file added data/maps7/Sunny Side Up.map
Binary file not shown.
Binary file added data/maps7/Tsunami.map
Binary file not shown.
17 changes: 17 additions & 0 deletions data/shader/pipeline.frag
Expand Up @@ -6,13 +6,30 @@ uniform sampler2DArray gTextureSampler;
#endif
#endif

#ifdef TW_MODERN_GL
#ifdef TW_TEXTURED
noperspective in vec3 oTexCoord;
#endif
noperspective in vec4 oVertColor;
out vec4 FragClr;
#endif

void main()
{
#ifdef TW_MODERN_GL
#ifdef TW_TEXTURED
vec4 TexColor = texture(gTextureSampler, oTexCoord.xyz).rgba;
FragClr = TexColor.rgba * oVertColor.rgba;
#else
FragClr = oVertColor.rgba;
#endif
#else
#ifdef TW_TEXTURED
vec4 TexColor = texture(gTextureSampler, gl_TexCoord[0].xyz).rgba;
gl_FragColor = TexColor.rgba * gl_Color.rgba;
#else
gl_FragColor = gl_Color.rgba;
#endif
#endif
}

21 changes: 21 additions & 0 deletions data/shader/pipeline.vert
@@ -1,11 +1,32 @@
#ifdef TW_MODERN_GL
layout (location = 0) in vec2 inVertex;
layout (location = 1) in vec4 inVertexColor;
layout (location = 2) in vec3 inVertexTexCoord;
#endif

uniform mat4x2 gPos;

#ifdef TW_MODERN_GL
#ifdef TW_TEXTURED
noperspective out vec3 oTexCoord;
#endif
noperspective out vec4 oVertColor;
#endif

void main()
{
#ifdef TW_MODERN_GL
gl_Position = vec4(gPos * vec4(inVertex, 0.0, 1.0), 0.0, 1.0);
#ifdef TW_TEXTURED
oTexCoord = inVertexTexCoord;
#endif
oVertColor = inVertexColor;
#else
gl_Position = vec4(gPos * vec4(gl_Vertex.xy, 0.0, 1.0), 0.0, 1.0);
#ifdef TW_TEXTURED
gl_TexCoord[0] = gl_MultiTexCoord0;
#endif
gl_FrontColor = gl_Color.rgba;
gl_BackColor = gl_Color.rgba;
#endif
}
Binary file removed data/skins/Ablush NeoN.png
Binary file not shown.
Binary file removed data/skins/Apish Coke.png
Binary file not shown.
Binary file removed data/skins/Black Phantom heinrich5991.png
Binary file not shown.
Binary file removed data/skins/Evil Puffi.png
Binary file not shown.
Binary file removed data/skins/Flying Silex.png
Binary file not shown.
Binary file removed data/skins/Hidden Assassin.png
Binary file not shown.
Binary file removed data/skins/Irradiated Sunny.png
Binary file not shown.
Binary file removed data/skins/Mobys Skull.png
Binary file not shown.
7 changes: 0 additions & 7 deletions data/skins/license.txt
Expand Up @@ -43,12 +43,5 @@ Aoe4legs:
Copyright Aoe
CC0 license

Ablush NeoN, Apish Coke, Black Phantom heinrich5991, Evil Puffi, Flying Silex,
Hidden Assassin, Irradiated Sunny, Mobys Skull:
Copyright Moby Dog
CC-BY-NC-ND license
Permission to modify the skins to fit other skin systems (split it into parts,
etc.) and publish them under the same license was given.

All other skins:
All content is released under CC-BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0/).
Binary file added data/themes/auto.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/themes/autumn.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/themes/autumn_day.map
Binary file not shown.
Binary file added data/themes/autumn_night.map
Binary file not shown.
Binary file added data/themes/heavens.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/themes/heavens_day.map
Binary file not shown.
Binary file added data/themes/heavens_night.map
Binary file not shown.
Binary file added data/themes/jungle.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/themes/jungle_day.map
Binary file not shown.
Binary file added data/themes/jungle_night.map
Binary file not shown.
Binary file added data/themes/none.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/themes/rand.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/themes/winter.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/themes/winter_day.map
Binary file not shown.
Binary file added data/themes/winter_night.map
Binary file not shown.
4 changes: 3 additions & 1 deletion datasrc/compile.py
Expand Up @@ -98,6 +98,8 @@ def EmitFlags(names, num):

print("#ifndef GAME_GENERATED_PROTOCOL_H")
print("#define GAME_GENERATED_PROTOCOL_H")
print("#include <engine/shared/protocol.h>")
print("#include <engine/message.h>")
print(network.RawHeader)

for e in network.Enums:
Expand Down Expand Up @@ -167,9 +169,9 @@ class CNetObjHandler
# create names
lines = []

lines += ['#include "protocol.h"']
lines += ['#include <engine/shared/protocol.h>']
lines += ['#include <engine/message.h>']
lines += ['#include "protocol.h"']
lines += ['#include <game/mapitems_ex.h>']

lines += ['CNetObjHandler::CNetObjHandler()']
Expand Down
10 changes: 8 additions & 2 deletions datasrc/network.py
Expand Up @@ -17,7 +17,11 @@
"BUG_DDRACE_INPUT", "BUG_FNG_LASER_RANGE", "BUG_VANILLA_BOUNCE",
"PREDICT_FNG", "PREDICT_DDRACE", "PREDICT_DDRACE_TILES", "PREDICT_VANILLA",
"ENTITIES_DDNET", "ENTITIES_DDRACE", "ENTITIES_RACE", "ENTITIES_FNG",
"ENTITIES_VANILLA", "DONT_MASK_ENTITIES", "ENTITIES_BW",
"ENTITIES_VANILLA", "DONT_MASK_ENTITIES", "ENTITIES_BW"
# Full, use GameInfoFlags2 for more flags
]
GameInfoFlags2 = [
"ALLOW_X_SKINS", "GAMETYPE_CITY",
]
ExPlayerFlags = ["AFK", "PAUSED", "SPEC"]

Expand Down Expand Up @@ -52,7 +56,7 @@
enum
{
GAMEINFO_CURVERSION=4,
GAMEINFO_CURVERSION=5,
};
'''

Expand All @@ -74,6 +78,7 @@
Flags("GAMESTATEFLAG", GameStateFlags),
Flags("CHARACTERFLAG", CharacterFlags),
Flags("GAMEINFOFLAG", GameInfoFlags),
Flags("GAMEINFOFLAG2", GameInfoFlags2),
Flags("EXPLAYERFLAG", ExPlayerFlags),
]

Expand Down Expand Up @@ -236,6 +241,7 @@
NetObjectEx("GameInfoEx", "gameinfo@netobj.ddnet.tw", [
NetIntAny("m_Flags"),
NetIntAny("m_Version"),
NetIntAny("m_Flags2"),
], validate_size=False),

## Events
Expand Down
4 changes: 3 additions & 1 deletion datasrc/seven/compile.py
Expand Up @@ -99,6 +99,8 @@ def EmitFlags(names, num):

print("#ifndef GAME_GENERATED_PROTOCOL7_H")
print("#define GAME_GENERATED_PROTOCOL7_H")
print("#include <engine/shared/protocol.h>")
print("#include <engine/message.h>")
print("namespace protocol7 {")
print(network.RawHeader)

Expand Down Expand Up @@ -177,9 +179,9 @@ class CNetObjHandler
# create names
lines = []

lines += ['#include "protocol7.h"']
lines += ['#include <engine/shared/protocol.h>']
lines += ['#include <engine/message.h>']
lines += ['#include "protocol7.h"']

lines += ['namespace protocol7 {']

Expand Down
2 changes: 1 addition & 1 deletion ddnet-libs
11 changes: 11 additions & 0 deletions formatting-revs.txt
@@ -0,0 +1,11 @@
f7b37eaf6a5dcd20c3bf53c842474129197b585f
3a986fbe529a0b34b4ca968cd8d9e12a07ba3e68
a67a8e36aa81f12b2cac8f5e240228e669fdd11e
f42a5a0431b16cfe3ed7f3f8158606e8fd36d0b1
833e3640b469d5fb98bb431ef834759815d94b55
8ef6a0da169d6eba151d6909a96fb52dc0a47384
4e157c64e3d7e36f23b3dfad0555f3095f31f712
a273969bc198d7259f57286c8a19214d48d22de5
cfd32c357b5aca410c7befb8ae4953fec1fa54ed
d4da82f977abb34cd0ed9a77e707b4c42f26673d
3be8a592e52a03e555b6aa29a8dea529797bb645
4 changes: 4 additions & 0 deletions other/ddnet.appdata.xml
Expand Up @@ -37,6 +37,10 @@
<content_attribute id="social-chat">intense</content_attribute>
</content_rating>
<releases>
<release date="2020-10-15" version="15.1.3"/>
<release date="2020-10-12" version="15.1.2"/>
<release date="2020-10-11" version="15.1.1"/>
<release date="2020-10-11" version="15.1"/>
<release date="2020-09-23" version="15.0.5"/>
<release date="2020-09-20" version="15.0.4"/>
<release date="2020-09-18" version="15.0.3"/>
Expand Down
74 changes: 26 additions & 48 deletions scripts/fix_style.py
@@ -1,70 +1,48 @@
#!/usr/bin/env python3

from collections import defaultdict
import os
import re
import subprocess
import sys

RE_POSITION=re.compile(rb"^@@ -[0-9]+,[0-9]+ \+(?P<start>[0-9]+),(?P<len>[0-9]+) @@")
def get_line_ranges(git_diff):
new_filename = None
result = defaultdict(list)
for line in git_diff.splitlines():
if line.startswith(b"+++ "):
new_filename = line[6:].decode()
continue
match = RE_POSITION.match(line)
if match:
start = int(match.group("start").decode())
end = start + int(match.group("len").decode()) - 1
result[new_filename].append((start, end))
continue
return dict(result)
os.chdir(os.path.dirname(__file__) + "/..")

def git_get_changed_lines(margin, base):
return get_line_ranges(subprocess.check_output([
"git",
"diff",
base,
"--unified={}".format(margin),
]))
def recursive_file_list(path):
result = []
for dirpath, dirnames, filenames in os.walk(path):
result += [os.path.join(dirpath, filename) for filename in filenames]
return result

def filter_cpp(changed_lines):
return {filename: changed_lines[filename] for filename in changed_lines
if any(filename.endswith(ext) for ext in ".c .cpp .h".split())}
IGNORE_FILES = [
"src/engine/client/keynames.h",
"src/engine/keys.h",
]
def filter_ignored(filenames):
return [filename for filename in filenames
if filename not in IGNORE_FILES
and not filename.startswith("src/game/generated/")]

def reformat(changed_lines):
for filename in changed_lines:
subprocess.check_call(["clang-format", "-i"] + ["--lines={}:{}".format(start, end) for start, end in changed_lines[filename]] + [filename])
def filter_cpp(filenames):
return [filename for filename in filenames
if any(filename.endswith(ext) for ext in ".c .cpp .h".split())]

def warn(changed_lines):
result = 0
for filename in changed_lines:
result = subprocess.call(["clang-format", "-Werror", "--dry-run"] + ["--lines={}:{}".format(start, end) for start, end in changed_lines[filename]] + [filename]) or result
return result
def reformat(filenames):
subprocess.check_call(["clang-format", "-i"] + filenames)

def get_common_base(base):
return subprocess.check_output(["git", "merge-base", "HEAD", base]).decode().strip()
def warn(filenames):
return subprocess.call(["clang-format", "-Werror", "--dry-run"] + filenames)

def main():
import argparse
p = argparse.ArgumentParser(description="Check and fix style of changed lines")
p.add_argument("--base", default="HEAD", help="Revision to compare to")
p = argparse.ArgumentParser(description="Check and fix style of changed files")
p.add_argument("-n", "--dry-run", action="store_true", help="Don't fix, only warn")
args = p.parse_args()
filenames = filter_ignored(filter_cpp(recursive_file_list("src")))
if not args.dry_run:
last_ranges = None
ranges = filter_cpp(git_get_changed_lines(1, base=args.base))
i = 0
while last_ranges != ranges:
print("Iteration {}".format(i))
reformat(ranges)
last_ranges = ranges
ranges = filter_cpp(git_get_changed_lines(1, base=args.base))
i += 1
print("Done after {} iterations".format(i))
reformat(filenames)
else:
sys.exit(warn(filter_cpp(git_get_changed_lines(1, base=args.base))))
sys.exit(warn(filenames))

if __name__ == "__main__":
main()
33 changes: 17 additions & 16 deletions src/antibot/antibot_data.h
Expand Up @@ -6,12 +6,12 @@

enum
{
ANTIBOT_ABI_VERSION=3,
ANTIBOT_ABI_VERSION = 3,

ANTIBOT_MSGFLAG_NONVITAL=1,
ANTIBOT_MSGFLAG_FLUSH=2,
ANTIBOT_MSGFLAG_NONVITAL = 1,
ANTIBOT_MSGFLAG_FLUSH = 2,

ANTIBOT_MAX_CLIENTS=64,
ANTIBOT_MAX_CLIENTS = 64,
};

struct CAntibotMapData
Expand All @@ -30,9 +30,9 @@ struct CAntibotInputData
// Defined by the network protocol, unlikely to change.
//enum
//{
//TEAM_SPECTATORS=-1,
//TEAM_RED=0,
//TEAM_BLUE=1,
// TEAM_SPECTATORS=-1,
// TEAM_RED=0,
// TEAM_BLUE=1,
//};

struct CAntibotCharacterData
Expand Down Expand Up @@ -64,15 +64,16 @@ struct CAntibotVersion
int m_SizeRoundData;
};

#define ANTIBOT_VERSION { \
ANTIBOT_ABI_VERSION, \
sizeof(CAntibotVersion), \
sizeof(CAntibotData), \
sizeof(CAntibotCharacterData), \
sizeof(CAntibotInputData), \
sizeof(CAntibotMapData), \
sizeof(CAntibotRoundData), \
}
#define ANTIBOT_VERSION \
{ \
ANTIBOT_ABI_VERSION, \
sizeof(CAntibotVersion), \
sizeof(CAntibotData), \
sizeof(CAntibotCharacterData), \
sizeof(CAntibotInputData), \
sizeof(CAntibotMapData), \
sizeof(CAntibotRoundData), \
}

struct CAntibotData
{
Expand Down
4 changes: 1 addition & 3 deletions src/antibot/antibot_interface.h
Expand Up @@ -2,8 +2,7 @@
#define ANTIBOT_ANTIBOT_INTERFACE_H

#include "antibot_data.h"
extern "C"
{
extern "C" {

int AntibotAbiVersion();
void AntibotInit(CAntibotData *pCallbackData);
Expand All @@ -25,7 +24,6 @@ void AntibotOnEngineTick(void);
void AntibotOnEngineClientJoin(int ClientID, bool Sixup);
void AntibotOnEngineClientDrop(int ClientID, const char *pReason);
void AntibotOnEngineClientMessage(int ClientID, const void *pData, int Size, int Flags);

}

#endif // ANTIBOT_ANTIBOT_INTERFACE_H
36 changes: 17 additions & 19 deletions src/antibot/antibot_null.cpp
Expand Up @@ -2,8 +2,7 @@

static CAntibotData *g_pData;

extern "C"
{
extern "C" {

int AntibotAbiVersion()
{
Expand All @@ -14,26 +13,25 @@ void AntibotInit(CAntibotData *pData)
g_pData = pData;
g_pData->m_pfnLog("null antibot initialized", g_pData->m_pUser);
}
void AntibotRoundStart(CAntibotRoundData *pRoundData) { };
void AntibotRoundEnd(void) { };
void AntibotUpdateData(void) { }
void AntibotRoundStart(CAntibotRoundData *pRoundData){};
void AntibotRoundEnd(void){};
void AntibotUpdateData(void) {}
void AntibotDestroy(void) { g_pData = 0; }
void AntibotDump(void)
{
g_pData->m_pfnLog("null antibot", g_pData->m_pUser);
}
void AntibotOnPlayerInit(int ClientID) { (void)ClientID; }
void AntibotOnPlayerDestroy(int ClientID) { (void)ClientID; }
void AntibotOnSpawn(int ClientID) { (void)ClientID; }
void AntibotOnHammerFireReloading(int ClientID) { (void)ClientID; }
void AntibotOnHammerFire(int ClientID) { (void)ClientID; }
void AntibotOnHammerHit(int ClientID) { (void)ClientID; }
void AntibotOnDirectInput(int ClientID) { (void)ClientID; }
void AntibotOnCharacterTick(int ClientID) { (void)ClientID; }
void AntibotOnHookAttach(int ClientID, bool Player) { (void)ClientID; (void)Player; }
void AntibotOnEngineTick(void) { }
void AntibotOnEngineClientJoin(int ClientID, bool Sixup) { (void)ClientID; (void)Sixup; }
void AntibotOnEngineClientDrop(int ClientID, const char *pReason) { (void)ClientID; (void)pReason; }
void AntibotOnEngineClientMessage(int ClientID, const void *pData, int Size, int Flags) { (void)ClientID; (void)pData; (void)Size; (void)Flags; }

void AntibotOnPlayerInit(int /*ClientID*/) {}
void AntibotOnPlayerDestroy(int /*ClientID*/) {}
void AntibotOnSpawn(int /*ClientID*/) {}
void AntibotOnHammerFireReloading(int /*ClientID*/) {}
void AntibotOnHammerFire(int /*ClientID*/) {}
void AntibotOnHammerHit(int /*ClientID*/) {}
void AntibotOnDirectInput(int /*ClientID*/) {}
void AntibotOnCharacterTick(int /*ClientID*/) {}
void AntibotOnHookAttach(int /*ClientID*/, bool /*Player*/) {}
void AntibotOnEngineTick(void) {}
void AntibotOnEngineClientJoin(int /*ClientID*/, bool /*Sixup*/) {}
void AntibotOnEngineClientDrop(int /*ClientID*/, const char * /*pReason*/) {}
void AntibotOnEngineClientMessage(int /*ClientID*/, const void * /*pData*/, int /*Size*/, int /*Flags*/) {}
}
60 changes: 37 additions & 23 deletions src/base/color.h
Expand Up @@ -33,14 +33,26 @@ inline float RgbToHue(float r, float g, float b)
}

// Curiously Recurring Template Pattern for type safety
template <typename DerivedT>
template<typename DerivedT>
class color4_base
{
public:
union { float x, r, h; };
union { float y, g, s; };
union { float z, b, l, v; };
union { float w, a; };
union
{
float x, r, h;
};
union
{
float y, g, s;
};
union
{
float z, b, l, v;
};
union
{
float w, a;
};

color4_base() {}

Expand Down Expand Up @@ -93,7 +105,7 @@ class color4_base

DerivedT WithAlpha(float alpha)
{
DerivedT col(static_cast<DerivedT&>(*this));
DerivedT col(static_cast<DerivedT &>(*this));
col.a = alpha;
return col;
}
Expand All @@ -103,7 +115,7 @@ class ColorHSLA : public color4_base<ColorHSLA>
{
public:
using color4_base::color4_base;
ColorHSLA() {};
ColorHSLA(){};

constexpr static const float DARKEST_LGT = 0.5f;

Expand All @@ -122,7 +134,7 @@ class ColorHSLA : public color4_base<ColorHSLA>
unsigned Pack(float Darkest, bool Alpha = false)
{
ColorHSLA col = *this;
col.l = (l - Darkest)/(1 - Darkest);
col.l = (l - Darkest) / (1 - Darkest);
col.l = clamp(col.l, 0.0f, 1.0f);
return col.Pack(Alpha);
}
Expand All @@ -132,19 +144,20 @@ class ColorHSVA : public color4_base<ColorHSVA>
{
public:
using color4_base::color4_base;
ColorHSVA() {};
ColorHSVA(){};
};

class ColorRGBA : public color4_base<ColorRGBA>
{
public:
using color4_base::color4_base;
ColorRGBA() {};
ColorRGBA(){};
};

template <typename T, typename F> T color_cast(const F &f) = delete;
template<typename T, typename F>
T color_cast(const F &f) = delete;

template <>
template<>
inline ColorHSLA color_cast(const ColorRGBA &rgb)
{
float Min = minimum(rgb.r, rgb.g, rgb.b);
Expand All @@ -153,12 +166,12 @@ inline ColorHSLA color_cast(const ColorRGBA &rgb)
float c = Max - Min;
float h = RgbToHue(rgb.r, rgb.g, rgb.b);
float l = 0.5f * (Max + Min);
float s = (Max != 0.0f && Min != 1.0f) ? (c/(1 - (absolute(2 * l - 1)))) : 0;
float s = (Max != 0.0f && Min != 1.0f) ? (c / (1 - (absolute(2 * l - 1)))) : 0;

return ColorHSLA(h, s, l, rgb.a);
}

template <>
template<>
inline ColorRGBA color_cast(const ColorHSLA &hsl)
{
vec3 rgb = vec3(0, 0, 0);
Expand All @@ -167,7 +180,8 @@ inline ColorRGBA color_cast(const ColorHSLA &hsl)
float c = (1 - absolute(2 * hsl.l - 1)) * hsl.s;
float x = c * (1 - absolute(fmod(h1, 2) - 1));

switch(round_truncate(h1)) {
switch(round_truncate(h1))
{
case 0:
rgb.r = c, rgb.g = x;
break;
Expand All @@ -189,43 +203,43 @@ inline ColorRGBA color_cast(const ColorHSLA &hsl)
break;
}

float m = hsl.l - (c/2);
float m = hsl.l - (c / 2);
return ColorRGBA(rgb.r + m, rgb.g + m, rgb.b + m, hsl.a);
}

template <>
template<>
inline ColorHSLA color_cast(const ColorHSVA &hsv)
{
float l = hsv.v * (1 - hsv.s * 0.5f);
return ColorHSLA(hsv.h, (l == 0.0f || l == 1.0f) ? 0 : (hsv.v - l)/minimum(l, 1 - l), l);
return ColorHSLA(hsv.h, (l == 0.0f || l == 1.0f) ? 0 : (hsv.v - l) / minimum(l, 1 - l), l);
}

template <>
template<>
inline ColorHSVA color_cast(const ColorHSLA &hsl)
{
float v = hsl.l + hsl.s * minimum(hsl.l, 1 - hsl.l);
return ColorHSVA(hsl.h, v == 0.0f ? 0 : 2 - (2 * hsl.l / v), v);
}

template <>
template<>
inline ColorRGBA color_cast(const ColorHSVA &hsv)
{
return color_cast<ColorRGBA>(color_cast<ColorHSLA>(hsv));
}

template <>
template<>
inline ColorHSVA color_cast(const ColorRGBA &rgb)
{
return color_cast<ColorHSVA>(color_cast<ColorHSLA>(rgb));
}

template <typename T>
template<typename T>
T color_scale(const T &col, float s)
{
return T(col.x * s, col.y * s, col.z * s, col.a * s);
}

template <typename T>
template<typename T>
T color_invert(const T &col)
{
return T(1.0f - col.x, 1.0f - col.y, 1.0f - col.z, 1.0f - col.a);
Expand Down
166 changes: 82 additions & 84 deletions src/base/detect.h
Expand Up @@ -12,144 +12,142 @@

/* windows Family */
#if defined(WIN64) || defined(_WIN64)
/* Hmm, is this IA64 or x86-64? */
#define CONF_FAMILY_WINDOWS 1
#define CONF_FAMILY_STRING "windows"
#define CONF_PLATFORM_WIN64 1
#define PLATFORM_STRING "win64"
/* Hmm, is this IA64 or x86-64? */
#define CONF_FAMILY_WINDOWS 1
#define CONF_FAMILY_STRING "windows"
#define CONF_PLATFORM_WIN64 1
#define PLATFORM_STRING "win64"
#elif defined(WIN32) || defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
#define CONF_FAMILY_WINDOWS 1
#define CONF_FAMILY_STRING "windows"
#define CONF_PLATFORM_WIN32 1
#define PLATFORM_STRING "win32"
#define CONF_FAMILY_WINDOWS 1
#define CONF_FAMILY_STRING "windows"
#define CONF_PLATFORM_WIN32 1
#define PLATFORM_STRING "win32"
#endif

/* unix family */
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#define CONF_FAMILY_UNIX 1
#define CONF_FAMILY_STRING "unix"
#define CONF_PLATFORM_FREEBSD 1
#define PLATFORM_STRING "freebsd"
#define CONF_FAMILY_UNIX 1
#define CONF_FAMILY_STRING "unix"
#define CONF_PLATFORM_FREEBSD 1
#define PLATFORM_STRING "freebsd"
#endif

#if defined(__NetBSD__)
#define CONF_FAMILY_UNIX 1
#define CONF_FAMILY_STRING "unix"
#define CONF_PLATFORM_NETBSD 1
#define PLATFORM_STRING "netbsd"
#define CONF_FAMILY_UNIX 1
#define CONF_FAMILY_STRING "unix"
#define CONF_PLATFORM_NETBSD 1
#define PLATFORM_STRING "netbsd"
#endif

#if defined(__OpenBSD__)
#define CONF_FAMILY_UNIX 1
#define CONF_FAMILY_STRING "unix"
#define CONF_PLATFORM_OPENBSD 1
#define PLATFORM_STRING "openbsd"
#define CONF_FAMILY_UNIX 1
#define CONF_FAMILY_STRING "unix"
#define CONF_PLATFORM_OPENBSD 1
#define PLATFORM_STRING "openbsd"
#endif

#if defined(__LINUX__) || defined(__linux__)
#define CONF_FAMILY_UNIX 1
#define CONF_FAMILY_STRING "unix"
#define CONF_PLATFORM_LINUX 1
#define PLATFORM_STRING "linux"
#define CONF_FAMILY_UNIX 1
#define CONF_FAMILY_STRING "unix"
#define CONF_PLATFORM_LINUX 1
#define PLATFORM_STRING "linux"
#endif

#if defined(__GNU__) || defined(__gnu__)
#define CONF_FAMILY_UNIX 1
#define CONF_FAMILY_STRING "unix"
#define CONF_PLATFORM_HURD 1
#define PLATFORM_STRING "gnu"
#define CONF_FAMILY_UNIX 1
#define CONF_FAMILY_STRING "unix"
#define CONF_PLATFORM_HURD 1
#define PLATFORM_STRING "gnu"
#endif

#if defined(MACOSX) || defined(__APPLE__) || defined(__DARWIN__)
#define CONF_FAMILY_UNIX 1
#define CONF_FAMILY_STRING "unix"
#define CONF_PLATFORM_MACOSX 1
#define PLATFORM_STRING "macosx"
#define CONF_FAMILY_UNIX 1
#define CONF_FAMILY_STRING "unix"
#define CONF_PLATFORM_MACOSX 1
#define PLATFORM_STRING "macosx"
#endif

#if defined(__sun)
#define CONF_FAMILY_UNIX 1
#define CONF_FAMILY_STRING "unix"
#define CONF_PLATFORM_SOLARIS 1
#define PLATFORM_STRING "solaris"
#define CONF_FAMILY_UNIX 1
#define CONF_FAMILY_STRING "unix"
#define CONF_PLATFORM_SOLARIS 1
#define PLATFORM_STRING "solaris"
#endif

/* beos family */
#if defined(__BeOS) || defined(__BEOS__)
#define CONF_FAMILY_BEOS 1
#define CONF_FAMILY_STRING "beos"
#define CONF_PLATFORM_BEOS 1
#define PLATFORM_STRING "beos"
#define CONF_FAMILY_BEOS 1
#define CONF_FAMILY_STRING "beos"
#define CONF_PLATFORM_BEOS 1
#define PLATFORM_STRING "beos"
#endif


/* use gcc endianness definitions when available */
#if defined(__GNUC__) && !defined(__APPLE__) && !defined(__MINGW32__) && !defined(__sun)
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
#include <sys/endian.h>
#else
#include <endian.h>
#endif

#if __BYTE_ORDER == __LITTLE_ENDIAN
#define CONF_ARCH_ENDIAN_LITTLE 1
#elif __BYTE_ORDER == __BIG_ENDIAN
#define CONF_ARCH_ENDIAN_BIG 1
#endif
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
#include <sys/endian.h>
#else
#include <endian.h>
#endif

#if __BYTE_ORDER == __LITTLE_ENDIAN
#define CONF_ARCH_ENDIAN_LITTLE 1
#elif __BYTE_ORDER == __BIG_ENDIAN
#define CONF_ARCH_ENDIAN_BIG 1
#endif
#endif

/* architectures */
#if defined(i386) || defined(__i386__) || defined(__x86__) || defined(CONF_PLATFORM_WIN32)
#define CONF_ARCH_IA32 1
#define CONF_ARCH_STRING "ia32"
#if !defined(CONF_ARCH_ENDIAN_LITTLE) && !defined(CONF_ARCH_ENDIAN_BIG)
#define CONF_ARCH_ENDIAN_LITTLE 1
#endif
#define CONF_ARCH_IA32 1
#define CONF_ARCH_STRING "ia32"
#if !defined(CONF_ARCH_ENDIAN_LITTLE) && !defined(CONF_ARCH_ENDIAN_BIG)
#define CONF_ARCH_ENDIAN_LITTLE 1
#endif
#endif

#if defined(__ia64__) || defined(_M_IA64)
#define CONF_ARCH_IA64 1
#define CONF_ARCH_STRING "ia64"
#if !defined(CONF_ARCH_ENDIAN_LITTLE) && !defined(CONF_ARCH_ENDIAN_BIG)
#define CONF_ARCH_ENDIAN_LITTLE 1
#endif
#define CONF_ARCH_IA64 1
#define CONF_ARCH_STRING "ia64"
#if !defined(CONF_ARCH_ENDIAN_LITTLE) && !defined(CONF_ARCH_ENDIAN_BIG)
#define CONF_ARCH_ENDIAN_LITTLE 1
#endif
#endif

#if defined(__amd64__) || defined(__x86_64__) || defined(_M_X64)
#define CONF_ARCH_AMD64 1
#define CONF_ARCH_STRING "amd64"
#if !defined(CONF_ARCH_ENDIAN_LITTLE) && !defined(CONF_ARCH_ENDIAN_BIG)
#define CONF_ARCH_ENDIAN_LITTLE 1
#endif
#define CONF_ARCH_AMD64 1
#define CONF_ARCH_STRING "amd64"
#if !defined(CONF_ARCH_ENDIAN_LITTLE) && !defined(CONF_ARCH_ENDIAN_BIG)
#define CONF_ARCH_ENDIAN_LITTLE 1
#endif
#endif

#if defined(__powerpc__) || defined(__ppc__)
#define CONF_ARCH_PPC 1
#define CONF_ARCH_STRING "ppc"
#if !defined(CONF_ARCH_ENDIAN_LITTLE) && !defined(CONF_ARCH_ENDIAN_BIG)
#define CONF_ARCH_ENDIAN_BIG 1
#endif
#define CONF_ARCH_PPC 1
#define CONF_ARCH_STRING "ppc"
#if !defined(CONF_ARCH_ENDIAN_LITTLE) && !defined(CONF_ARCH_ENDIAN_BIG)
#define CONF_ARCH_ENDIAN_BIG 1
#endif
#endif

#if defined(__sparc__)
#define CONF_ARCH_SPARC 1
#define CONF_ARCH_STRING "sparc"
#if !defined(CONF_ARCH_ENDIAN_LITTLE) && !defined(CONF_ARCH_ENDIAN_BIG)
#define CONF_ARCH_ENDIAN_BIG 1
#endif
#define CONF_ARCH_SPARC 1
#define CONF_ARCH_STRING "sparc"
#if !defined(CONF_ARCH_ENDIAN_LITTLE) && !defined(CONF_ARCH_ENDIAN_BIG)
#define CONF_ARCH_ENDIAN_BIG 1
#endif
#endif

#if defined(__ARMEB__)
#define CONF_ARCH_ARM 1
#define CONF_ARCH_STRING "arm"
#define CONF_ARCH_ENDIAN_BIG 1
#define CONF_ARCH_ARM 1
#define CONF_ARCH_STRING "arm"
#define CONF_ARCH_ENDIAN_BIG 1
#endif

#if defined(__ARMEL__)
#define CONF_ARCH_ARM 1
#define CONF_ARCH_STRING "arm"
#define CONF_ARCH_ENDIAN_LITTLE 1
#define CONF_ARCH_ARM 1
#define CONF_ARCH_STRING "arm"
#define CONF_ARCH_ENDIAN_LITTLE 1
#endif

#ifndef CONF_FAMILY_STRING
Expand Down
1 change: 0 additions & 1 deletion src/base/dynamic.h
Expand Up @@ -11,5 +11,4 @@
#define DYNAMIC_IMPORT
#endif


#endif // BASE_DYNAMIC_H
8 changes: 4 additions & 4 deletions src/base/hash.h
Expand Up @@ -9,10 +9,10 @@ extern "C" {

enum
{
SHA256_DIGEST_LENGTH=256/8,
SHA256_MAXSTRSIZE=2*SHA256_DIGEST_LENGTH+1,
MD5_DIGEST_LENGTH=128/8,
MD5_MAXSTRSIZE=2*MD5_DIGEST_LENGTH+1,
SHA256_DIGEST_LENGTH = 256 / 8,
SHA256_MAXSTRSIZE = 2 * SHA256_DIGEST_LENGTH + 1,
MD5_DIGEST_LENGTH = 128 / 8,
MD5_MAXSTRSIZE = 2 * MD5_DIGEST_LENGTH + 1,
};

typedef struct
Expand Down
8 changes: 4 additions & 4 deletions src/base/hash_bundled.c
Expand Up @@ -6,14 +6,14 @@

void md5_update(MD5_CTX *ctxt, const void *data, size_t data_len)
{
md5_append(ctxt, data, data_len);
md5_append(ctxt, data, data_len);
}

MD5_DIGEST md5_finish(MD5_CTX *ctxt)
{
MD5_DIGEST result;
md5_finish_(ctxt, result.data);
return result;
MD5_DIGEST result;
md5_finish_(ctxt, result.data);
return result;
}

#endif
8 changes: 4 additions & 4 deletions src/base/hash_ctxt.h
Expand Up @@ -21,10 +21,10 @@ extern "C" {
#else
typedef struct
{
uint64 length;
uint32_t state[8];
uint32_t curlen;
unsigned char buf[64];
uint64 length;
uint32_t state[8];
uint32_t curlen;
unsigned char buf[64];
} SHA256_CTX;
typedef md5_state_t MD5_CTX;
#endif
Expand Down
294 changes: 150 additions & 144 deletions src/base/hash_libtomcrypt.c 100755 → 100644
Expand Up @@ -14,189 +14,195 @@ typedef uint64_t u64;
typedef SHA256_CTX sha256_state;

static const u32 K[64] =
{
0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL,
0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL,
0x243185beUL, 0x550c7dc3UL, 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL,
0xc19bf174UL, 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL,
0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, 0x983e5152UL,
0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, 0xc6e00bf3UL, 0xd5a79147UL,
0x06ca6351UL, 0x14292967UL, 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL,
0x53380d13UL, 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL,
0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, 0xd192e819UL,
0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, 0x19a4c116UL, 0x1e376c08UL,
0x2748774cUL, 0x34b0bcb5UL, 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL,
0x682e6ff3UL, 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL
};
{
0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL,
0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL,
0x243185beUL, 0x550c7dc3UL, 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL,
0xc19bf174UL, 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL,
0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, 0x983e5152UL,
0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, 0xc6e00bf3UL, 0xd5a79147UL,
0x06ca6351UL, 0x14292967UL, 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL,
0x53380d13UL, 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL,
0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, 0xd192e819UL,
0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, 0x19a4c116UL, 0x1e376c08UL,
0x2748774cUL, 0x34b0bcb5UL, 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL,
0x682e6ff3UL, 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL};

static u32 minimum(u32 x, u32 y)
{
return x < y ? x : y;
return x < y ? x : y;
}

static u32 load32(const unsigned char* y)
static u32 load32(const unsigned char *y)
{
return ((u32)y[0] << 24) | ((u32)y[1] << 16) | ((u32)y[2] << 8) | ((u32)y[3] << 0);
return ((u32)y[0] << 24) | ((u32)y[1] << 16) | ((u32)y[2] << 8) | ((u32)y[3] << 0);
}

static void store64(u64 x, unsigned char* y)
static void store64(u64 x, unsigned char *y)
{
int i;
for(i = 0; i != 8; ++i)
y[i] = (x >> ((7-i) * 8)) & 255;
int i;
for(i = 0; i != 8; ++i)
y[i] = (x >> ((7 - i) * 8)) & 255;
}

static void store32(u32 x, unsigned char* y)
static void store32(u32 x, unsigned char *y)
{
int i;
for(i = 0; i != 4; ++i)
y[i] = (x >> ((3-i) * 8)) & 255;
int i;
for(i = 0; i != 4; ++i)
y[i] = (x >> ((3 - i) * 8)) & 255;
}

static u32 Ch(u32 x, u32 y, u32 z) { return z ^ (x & (y ^ z)); }
static u32 Ch(u32 x, u32 y, u32 z) { return z ^ (x & (y ^ z)); }
static u32 Maj(u32 x, u32 y, u32 z) { return ((x | y) & z) | (x & y); }
static u32 Rot(u32 x, u32 n) { return (x >> (n & 31)) | (x << (32 - (n & 31))); }
static u32 Sh(u32 x, u32 n) { return x >> n; }
static u32 Sigma0(u32 x) { return Rot(x, 2) ^ Rot(x, 13) ^ Rot(x, 22); }
static u32 Sigma1(u32 x) { return Rot(x, 6) ^ Rot(x, 11) ^ Rot(x, 25); }
static u32 Gamma0(u32 x) { return Rot(x, 7) ^ Rot(x, 18) ^ Sh(x, 3); }
static u32 Gamma1(u32 x) { return Rot(x, 17) ^ Rot(x, 19) ^ Sh(x, 10); }

static void sha_compress(sha256_state* md, const unsigned char* buf)
static u32 Rot(u32 x, u32 n) { return (x >> (n & 31)) | (x << (32 - (n & 31))); }
static u32 Sh(u32 x, u32 n) { return x >> n; }
static u32 Sigma0(u32 x) { return Rot(x, 2) ^ Rot(x, 13) ^ Rot(x, 22); }
static u32 Sigma1(u32 x) { return Rot(x, 6) ^ Rot(x, 11) ^ Rot(x, 25); }
static u32 Gamma0(u32 x) { return Rot(x, 7) ^ Rot(x, 18) ^ Sh(x, 3); }
static u32 Gamma1(u32 x) { return Rot(x, 17) ^ Rot(x, 19) ^ Sh(x, 10); }

static void sha_compress(sha256_state *md, const unsigned char *buf)
{
u32 S[8], W[64], t0, t1, t;
int i;

// Copy state into S
for(i = 0; i < 8; i++)
S[i] = md->state[i];

// Copy the state into 512-bits into W[0..15]
for(i = 0; i < 16; i++)
W[i] = load32(buf + (4*i));

// Fill W[16..63]
for(i = 16; i < 64; i++)
W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16];

// Compress
#define RND(a, b, c, d, e, f, g, h, i) \
{ \
t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \
t1 = Sigma0(a) + Maj(a, b, c); \
d += t0; \
h = t0 + t1; \
}

for(i = 0; i < 64; ++i)
{
RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],i);
t = S[7]; S[7] = S[6]; S[6] = S[5]; S[5] = S[4];
S[4] = S[3]; S[3] = S[2]; S[2] = S[1]; S[1] = S[0]; S[0] = t;
}

// Feedback
for(i = 0; i < 8; i++)
md->state[i] = md->state[i] + S[i];
u32 S[8], W[64], t0, t1, t;
int i;

// Copy state into S
for(i = 0; i < 8; i++)
S[i] = md->state[i];

// Copy the state into 512-bits into W[0..15]
for(i = 0; i < 16; i++)
W[i] = load32(buf + (4 * i));

// Fill W[16..63]
for(i = 16; i < 64; i++)
W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16];

// Compress
#define RND(a, b, c, d, e, f, g, h, i) \
{ \
t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \
t1 = Sigma0(a) + Maj(a, b, c); \
d += t0; \
h = t0 + t1; \
}

for(i = 0; i < 64; ++i)
{
RND(S[0], S[1], S[2], S[3], S[4], S[5], S[6], S[7], i);
t = S[7];
S[7] = S[6];
S[6] = S[5];
S[5] = S[4];
S[4] = S[3];
S[3] = S[2];
S[2] = S[1];
S[1] = S[0];
S[0] = t;
}

// Feedback
for(i = 0; i < 8; i++)
md->state[i] = md->state[i] + S[i];
}

// Public interface

static void sha_init(sha256_state* md)
static void sha_init(sha256_state *md)
{
md->curlen = 0;
md->length = 0;
md->state[0] = 0x6A09E667UL;
md->state[1] = 0xBB67AE85UL;
md->state[2] = 0x3C6EF372UL;
md->state[3] = 0xA54FF53AUL;
md->state[4] = 0x510E527FUL;
md->state[5] = 0x9B05688CUL;
md->state[6] = 0x1F83D9ABUL;
md->state[7] = 0x5BE0CD19UL;
md->curlen = 0;
md->length = 0;
md->state[0] = 0x6A09E667UL;
md->state[1] = 0xBB67AE85UL;
md->state[2] = 0x3C6EF372UL;
md->state[3] = 0xA54FF53AUL;
md->state[4] = 0x510E527FUL;
md->state[5] = 0x9B05688CUL;
md->state[6] = 0x1F83D9ABUL;
md->state[7] = 0x5BE0CD19UL;
}

static void sha_process(sha256_state* md, const void* src, u32 inlen)
static void sha_process(sha256_state *md, const void *src, u32 inlen)
{
const u32 block_size = 64;
const unsigned char* in = src;

while(inlen > 0)
{
if(md->curlen == 0 && inlen >= block_size)
{
sha_compress(md, in);
md->length += block_size * 8;
in += block_size;
inlen -= block_size;
}
else
{
u32 n = minimum(inlen, (block_size - md->curlen));
memcpy(md->buf + md->curlen, in, n);
md->curlen += n;
in += n;
inlen -= n;

if(md->curlen == block_size)
{
sha_compress(md, md->buf);
md->length += 8*block_size;
md->curlen = 0;
}
}
}
const u32 block_size = 64;
const unsigned char *in = src;

while(inlen > 0)
{
if(md->curlen == 0 && inlen >= block_size)
{
sha_compress(md, in);
md->length += block_size * 8;
in += block_size;
inlen -= block_size;
}
else
{
u32 n = minimum(inlen, (block_size - md->curlen));
memcpy(md->buf + md->curlen, in, n);
md->curlen += n;
in += n;
inlen -= n;

if(md->curlen == block_size)
{
sha_compress(md, md->buf);
md->length += 8 * block_size;
md->curlen = 0;
}
}
}
}

static void sha_done(sha256_state* md, void* out)
static void sha_done(sha256_state *md, void *out)
{
int i;

// Increase the length of the message
md->length += md->curlen * 8;

// Append the '1' bit
md->buf[md->curlen++] = (unsigned char)0x80;

// If the length is currently above 56 bytes we append zeros then compress.
// Then we can fall back to padding zeros and length encoding like normal.
if(md->curlen > 56)
{
while(md->curlen < 64)
md->buf[md->curlen++] = 0;
sha_compress(md, md->buf);
md->curlen = 0;
}

// Pad up to 56 bytes of zeroes
while(md->curlen < 56)
md->buf[md->curlen++] = 0;

// Store length
store64(md->length, md->buf+56);
sha_compress(md, md->buf);

// Copy output
for(i = 0; i < 8; i++)
store32(md->state[i], (unsigned char *)out+(4*i));
int i;

// Increase the length of the message
md->length += md->curlen * 8;

// Append the '1' bit
md->buf[md->curlen++] = (unsigned char)0x80;

// If the length is currently above 56 bytes we append zeros then compress.
// Then we can fall back to padding zeros and length encoding like normal.
if(md->curlen > 56)
{
while(md->curlen < 64)
md->buf[md->curlen++] = 0;
sha_compress(md, md->buf);
md->curlen = 0;
}

// Pad up to 56 bytes of zeroes
while(md->curlen < 56)
md->buf[md->curlen++] = 0;

// Store length
store64(md->length, md->buf + 56);
sha_compress(md, md->buf);

// Copy output
for(i = 0; i < 8; i++)
store32(md->state[i], (unsigned char *)out + (4 * i));
}

void sha256_init(SHA256_CTX *ctxt)
{
sha_init(ctxt);
sha_init(ctxt);
}

void sha256_update(SHA256_CTX *ctxt, const void *data, size_t data_len)
{
sha_process(ctxt, data, data_len);
sha_process(ctxt, data, data_len);
}

SHA256_DIGEST sha256_finish(SHA256_CTX *ctxt)
{
SHA256_DIGEST result;
sha_done(ctxt, result.data);
return result;
SHA256_DIGEST result;
sha_done(ctxt, result.data);
return result;
}

#endif
79 changes: 63 additions & 16 deletions src/base/math.h
Expand Up @@ -6,15 +6,15 @@
#include <math.h>
#include <stdlib.h>

template <typename T>
template<typename T>
constexpr inline T clamp(T val, T min, T max)
{
return val < min ? min : (val > max ? max : val);
}

constexpr inline float sign(float f)
{
return f<0.0f?-1.0f:1.0f;
return f < 0.0f ? -1.0f : 1.0f;
}

constexpr inline int round_to_int(float f)
Expand All @@ -35,14 +35,24 @@ inline int round_ceil(float f)
template<typename T, typename TB>
constexpr inline T mix(const T a, const T b, TB amount)
{
return a + (b-a)*amount;
return a + (b - a) * amount;
}

inline float frandom() { return rand()/(float)(RAND_MAX); }
inline float frandom() { return rand() / (float)(RAND_MAX); }

// float to fixed
constexpr inline int f2fx(float v) { return (int)(v*(float)(1<<10)); }
constexpr inline float fx2f(int v) { return v*(1.0f/(1<<10)); }
constexpr inline int f2fx(float v) { return (int)(v * (float)(1 << 10)); }
constexpr inline float fx2f(int v) { return v * (1.0f / (1 << 10)); }

// int to fixed
inline int i2fx(int v)
{
return v << 10;
}
inline int fx2i(int v)
{
return v >> 10;
}

inline int gcd(int a, int b)
{
Expand All @@ -58,23 +68,60 @@ inline int gcd(int a, int b)
class fxp
{
int value;

public:
void set(int v) { value = v; }
int get() const { return value; }
fxp &operator = (int v) { value = v<<10; return *this; }
fxp &operator = (float v) { value = (int)(v*(float)(1<<10)); return *this; }
operator float() const { return value/(float)(1<<10); }
fxp &operator=(int v)
{
value = v << 10;
return *this;
}
fxp &operator=(float v)
{
value = (int)(v * (float)(1 << 10));
return *this;
}
operator float() const { return value / (float)(1 << 10); }
};

constexpr float pi = 3.1415926535897932384626433f;

template <typename T> constexpr inline T minimum(T a, T b) { return a<b?a:b; }
template <typename T> constexpr inline T minimum(T a, T b, T c) { return minimum(minimum(a, b), c); }
template <typename T> constexpr inline T maximum(T a, T b) { return a>b?a:b; }
template <typename T> constexpr inline T maximum(T a, T b, T c) { return maximum(maximum(a, b), c); }
template <typename T> constexpr inline T absolute(T a) { return a<T(0)?-a:a; }
template<typename T>
constexpr inline T minimum(T a, T b)
{
return a < b ? a : b;
}
template<typename T>
constexpr inline T minimum(T a, T b, T c)
{
return minimum(minimum(a, b), c);
}
template<typename T>
constexpr inline T maximum(T a, T b)
{
return a > b ? a : b;
}
template<typename T>
constexpr inline T maximum(T a, T b, T c)
{
return maximum(maximum(a, b), c);
}
template<typename T>
constexpr inline T absolute(T a)
{
return a < T(0) ? -a : a;
}

template <typename T> constexpr inline T in_range(T a, T lower, T upper) { return lower <= a && a <= upper; }
template <typename T> constexpr inline T in_range(T a, T upper) { return in_range(a, 0, upper); }
template<typename T>
constexpr inline T in_range(T a, T lower, T upper)
{
return lower <= a && a <= upper;
}
template<typename T>
constexpr inline T in_range(T a, T upper)
{
return in_range(a, 0, upper);
}

#endif // BASE_MATH_H