61 changes: 52 additions & 9 deletions data/languages/portuguese.txt
Expand Up @@ -985,11 +985,6 @@ Editor
== Editor

[Start menu]
%d new mentions
== %d novas menções

9+ new mentions
== 9+ novas menções

Successfully saved the replay!
==
Expand Down Expand Up @@ -1111,6 +1106,9 @@ Skip the main menu
Config directory
==

Toggle to edit your dummy settings
==

Download skins
==

Expand All @@ -1123,6 +1121,9 @@ Fat skins (DDFat)
Skin prefix
==

Choose default eyes when joining a server
==

Skin Database
==

Expand Down Expand Up @@ -1180,16 +1181,25 @@ Windowed fullscreen
may cause delay
==

Use modern OpenGL
Allows maps to render with more detail
==

Preinit VBO (iGPUs only)
Use high DPI
==

Multiple texture units (disable for macOS)
Renderer
==

Use high DPI
default
==

custom
==

Graphics cards
==

auto
==

Enable long pain sound (used when shooting in freeze)
Expand Down Expand Up @@ -1240,18 +1250,33 @@ Enable replays
Default length: %d
==

When you cross the start line, show a ghost tee replicating the movements of your best time
==

Overlay entities
==

Show text entities
==

Opacity
==

Adjust the opacity of entities belonging to other teams, such as tees and nameplates
==

Show others (own team only)
==

Show quads
==

Quads are used for background decoration
==

Tries to predict other entities to give a feel of low latency
==

Show other players' hook collision lines
==

Expand Down Expand Up @@ -1291,6 +1316,12 @@ Emoticons
Assets directory
==

Tutorial
==

Can't find a Tutorial server
==

Run server
==

Expand All @@ -1310,6 +1341,12 @@ Downloading %s:
Update failed! Check log...
==

Super
==

Team %d
==

Manual
==

Expand Down Expand Up @@ -1342,3 +1379,9 @@ Grabs

1 new mention
==

%d new mentions
==

9+ new mentions
==
50 changes: 46 additions & 4 deletions data/languages/romanian.txt
Expand Up @@ -907,6 +907,9 @@ Max CSVs
Dummy settings
==

Toggle to edit your dummy settings
==

Download skins
==

Expand All @@ -919,6 +922,9 @@ Fat skins (DDFat)
Skin prefix
==

Choose default eyes when joining a server
==

Skin Database
==

Expand Down Expand Up @@ -1000,16 +1006,25 @@ may cause delay
Screen
==

Use modern OpenGL
Allows maps to render with more detail
==

Preinit VBO (iGPUs only)
Use high DPI
==

Multiple texture units (disable for macOS)
Renderer
==

Use high DPI
default
==

custom
==

Graphics cards
==

auto
==

Enable game sounds
Expand Down Expand Up @@ -1147,6 +1162,9 @@ Enable replays
Default length: %d
==

When you cross the start line, show a ghost tee replicating the movements of your best time
==

Show ghost
==

Expand All @@ -1162,15 +1180,27 @@ Overlay entities
Show text entities
==

Opacity
==

Adjust the opacity of entities belonging to other teams, such as tees and nameplates
==

Show others (own team only)
==

Show quads
==

Quads are used for background decoration
==

AntiPing
==

Tries to predict other entities to give a feel of low latency
==

AntiPing: predict other players
==

Expand Down Expand Up @@ -1261,6 +1291,12 @@ Learn
https://wiki.ddnet.tw/
==

Tutorial
==

Can't find a Tutorial server
==

Website
==

Expand Down Expand Up @@ -1295,6 +1331,12 @@ Update failed! Check log...
Restart
==

Super
==

Team %d
==

Manual
==

Expand Down
76 changes: 59 additions & 17 deletions data/languages/russian.txt
Expand Up @@ -186,7 +186,7 @@ Friends
== Друзья

Fullscreen
== Полноэкранный режим
== Полноэкранный(настр.)

Game
== Игра
Expand Down Expand Up @@ -960,12 +960,6 @@ may cause delay
Screen
== Экран

Preinit VBO (iGPUs only)
== Преинициал-ть VBO (только iGPU)

Multiple texture units (disable for macOS)
== Улучш. блоки текстур (откл. для macOS)

Use high DPI
== Использовать высокую чувств.

Expand Down Expand Up @@ -1291,9 +1285,6 @@ Windowed borderless
Desktop fullscreen
== Полноэкранный

Use modern OpenGL
== Использовать новый OpenGL

Tee
== Tee

Expand Down Expand Up @@ -1325,25 +1316,76 @@ Show local player's key presses
== Показывать нажатия клавиш игрока

The format of texture %s is not RGBA which will cause visual bugs.
==
== Формат текстуры %s не соотвествует RGBA, что может повлечь артефакты.

Join Tutorial Server
==
== Начать туториал

Skip Tutorial
==
== Пропустить туториал

Settings file
==
== Файл настроек

Config directory
==
== Путь к настройкам

Windowed fullscreen
==
== Оконный на весь экран

Renderer
== Рендерер

default
== станд.

custom
== перс.

Graphics cards
== Видеокарты

auto
== авто

Run on join
==
== Запускать при входе

Chat command (e.g. showall 1)
== Чат-команда (напр. showall 1)

Tutorial
== Туториал

Can't find a Tutorial server
== Обучающий сервер не найден

Toggle to edit your dummy settings
==

Choose default eyes when joining a server
==

Allows maps to render with more detail
==

When you cross the start line, show a ghost tee replicating the movements of your best time
==

Opacity
==

Adjust the opacity of entities belonging to other teams, such as tees and nameplates
==

Quads are used for background decoration
==

Tries to predict other entities to give a feel of low latency
==

Super
==

Team %d
==
50 changes: 46 additions & 4 deletions data/languages/serbian.txt
Expand Up @@ -905,6 +905,9 @@ Max CSVs
Dummy settings
==

Toggle to edit your dummy settings
==

Download skins
==

Expand All @@ -917,6 +920,9 @@ Fat skins (DDFat)
Skin prefix
==

Choose default eyes when joining a server
==

Skin Database
==

Expand Down Expand Up @@ -998,16 +1004,25 @@ may cause delay
Screen
==

Use modern OpenGL
Allows maps to render with more detail
==

Preinit VBO (iGPUs only)
Use high DPI
==

Multiple texture units (disable for macOS)
Renderer
==

Use high DPI
default
==

custom
==

Graphics cards
==

auto
==

Enable game sounds
Expand Down Expand Up @@ -1145,6 +1160,9 @@ Enable replays
Default length: %d
==

When you cross the start line, show a ghost tee replicating the movements of your best time
==

Show ghost
==

Expand All @@ -1160,15 +1178,27 @@ Overlay entities
Show text entities
==

Opacity
==

Adjust the opacity of entities belonging to other teams, such as tees and nameplates
==

Show others (own team only)
==

Show quads
==

Quads are used for background decoration
==

AntiPing
==

Tries to predict other entities to give a feel of low latency
==

AntiPing: predict other players
==

Expand Down Expand Up @@ -1256,6 +1286,12 @@ https://ddnet.tw/discord
https://wiki.ddnet.tw/
==

Tutorial
==

Can't find a Tutorial server
==

Website
==

Expand Down Expand Up @@ -1290,6 +1326,12 @@ Update failed! Check log...
Restart
==

Super
==

Team %d
==

Manual
==

Expand Down
56 changes: 49 additions & 7 deletions data/languages/serbian_cyrillic.txt
Expand Up @@ -913,12 +913,6 @@ UI mouse s.
may cause delay
== може проузроковати кашњење

Preinit VBO (iGPUs only)
== Preinit VBO (само у iGPUs)

Multiple texture units (disable for macOS)
== Вишеструке текстурне јединице (угашено за macOS)

Use high DPI
== Користи високи DPI

Expand Down Expand Up @@ -1247,6 +1241,12 @@ Settings file
Config directory
==

Toggle to edit your dummy settings
==

Choose default eyes when joining a server
==

Chat command
==

Expand All @@ -1265,7 +1265,22 @@ Windowed fullscreen
Desktop fullscreen
==

Use modern OpenGL
Allows maps to render with more detail
==

Renderer
==

default
==

custom
==

Graphics cards
==

auto
==

Game sound volume
Expand Down Expand Up @@ -1313,6 +1328,21 @@ Use old chat style
Preview
==

When you cross the start line, show a ghost tee replicating the movements of your best time
==

Opacity
==

Adjust the opacity of entities belonging to other teams, such as tees and nameplates
==

Quads are used for background decoration
==

Tries to predict other entities to give a feel of low latency
==

Show local player's key presses
==

Expand All @@ -1339,3 +1369,15 @@ Discord

https://ddnet.tw/discord
==

Tutorial
==

Can't find a Tutorial server
==

Super
==

Team %d
==
250 changes: 149 additions & 101 deletions data/languages/simplified_chinese.txt

Large diffs are not rendered by default.

50 changes: 46 additions & 4 deletions data/languages/slovak.txt
Expand Up @@ -901,6 +901,9 @@ Max CSVs
Dummy settings
==

Toggle to edit your dummy settings
==

Download skins
==

Expand All @@ -913,6 +916,9 @@ Fat skins (DDFat)
Skin prefix
==

Choose default eyes when joining a server
==

Skin Database
==

Expand Down Expand Up @@ -994,16 +1000,25 @@ may cause delay
Screen
==

Use modern OpenGL
Allows maps to render with more detail
==

Preinit VBO (iGPUs only)
Use high DPI
==

Multiple texture units (disable for macOS)
Renderer
==

Use high DPI
default
==

custom
==

Graphics cards
==

auto
==

Enable game sounds
Expand Down Expand Up @@ -1141,6 +1156,9 @@ Enable replays
Default length: %d
==

When you cross the start line, show a ghost tee replicating the movements of your best time
==

Show ghost
==

Expand All @@ -1156,15 +1174,27 @@ Overlay entities
Show text entities
==

Opacity
==

Adjust the opacity of entities belonging to other teams, such as tees and nameplates
==

Show others (own team only)
==

Show quads
==

Quads are used for background decoration
==

AntiPing
==

Tries to predict other entities to give a feel of low latency
==

AntiPing: predict other players
==

Expand Down Expand Up @@ -1255,6 +1285,12 @@ Learn
https://wiki.ddnet.tw/
==

Tutorial
==

Can't find a Tutorial server
==

Website
==

Expand Down Expand Up @@ -1289,6 +1325,12 @@ Update failed! Check log...
Restart
==

Super
==

Team %d
==

Manual
==

Expand Down
68 changes: 56 additions & 12 deletions data/languages/spanish.txt
Expand Up @@ -13,6 +13,8 @@
# Headshot 2021-05-30 17:00:00
# Deëivid! 2021-10-27 00:49:00
# Deëivid! 2022-02-05 21:53:00
# Deëivid! 2022-03-27 18:40:00
# Deëivid! 2022-05-13 18:44:00
##### /authors #####

##### translated strings #####
Expand Down Expand Up @@ -887,12 +889,6 @@ may cause delay
Screen
== Pantalla

Preinit VBO (iGPUs only)
== Preinit VBO (solo iGPU)

Multiple texture units (disable for macOS)
== Múltiples unidades de textura (deshabilitar para macOS)

Use high DPI
== Usar DPI alto

Expand Down Expand Up @@ -1266,9 +1262,6 @@ Windowed borderless
Desktop fullscreen
== Pantalla completa de escritorio

Use modern OpenGL
== Usar OpenGL moderno

Show client IDs
== Mostrar IDs de clientes

Expand Down Expand Up @@ -1339,13 +1332,64 @@ Chat command (e.g. showall 1)
== Comando de chat (Ej. showall 1)

The format of texture %s is not RGBA which will cause visual bugs.
==
== El formato de la textura %s no es RGBA, lo que puede causar errores visuales.

Join Tutorial Server
==
== Ir a un servidor Tutorial

Skip Tutorial
==
== Saltar Tutorial

Windowed fullscreen
== Ventana a pantalla completa

Renderer
== Renderizador

default
== por defecto

custom
== personalizado

Graphics cards
== Tarjetas de video

auto
== auto.

Tutorial
== Tutorial

Can't find a Tutorial server
== No se pudo encontrar un servidor Tutorial

Toggle to edit your dummy settings
== Actívalo para editar la configuración de tu dummy

Choose default eyes when joining a server
== Escoge los ojos predeterminados al unirte a un servidor

Allows maps to render with more detail
== Permite que los mapas tengan más detalles

When you cross the start line, show a ghost tee replicating the movements of your best time
== Cuando cruzas la línea de inicio, se muestra un tee fantasma replicando los movimientos de tu mejor tiempo

Opacity
== Opacidad

Adjust the opacity of entities belonging to other teams, such as tees and nameplates
==

Quads are used for background decoration
== Las quads se usan para la decoración del fondo

Tries to predict other entities to give a feel of low latency
== Intenta predecir a otras entidades para dar una sensación de baja latencia

Super
== Súper

Team %d
== Equipo %d
60 changes: 51 additions & 9 deletions data/languages/swedish.txt
Expand Up @@ -864,9 +864,6 @@ Normal message
Show score
== Visa poäng

Multiple texture units (disable for macOS)
== Multiple texture units (avaktivera för macOS)

Refresh Rate
== Uppdateringsfrekvens

Expand Down Expand Up @@ -966,9 +963,6 @@ Best
Updating...
== Updaterar...

Preinit VBO (iGPUs only)
== Preinit VBO (bara iGPUs)

Clan plates size
== Klanskylt storlek

Expand Down Expand Up @@ -1243,9 +1237,6 @@ Windowed fullscreen
Desktop fullscreen
== Desktop fullscreen

Use modern OpenGL
== Använd modern OpenGL

Game sound volume
== Spel ljudvolym

Expand Down Expand Up @@ -1341,3 +1332,54 @@ Join Tutorial Server

Skip Tutorial
==

Toggle to edit your dummy settings
==

Choose default eyes when joining a server
==

Allows maps to render with more detail
==

Renderer
==

default
==

custom
==

Graphics cards
==

auto
==

When you cross the start line, show a ghost tee replicating the movements of your best time
==

Opacity
==

Adjust the opacity of entities belonging to other teams, such as tees and nameplates
==

Quads are used for background decoration
==

Tries to predict other entities to give a feel of low latency
==

Tutorial
==

Can't find a Tutorial server
==

Super
==

Team %d
==
73 changes: 59 additions & 14 deletions data/languages/traditional_chinese.txt
Expand Up @@ -10,6 +10,9 @@
# 2021-12-21 cheeser0613
# 2022-02-07 cheeser0613
# 2022-03-19 cheeser0613
# 2022-03-22 cheeser0613
# 2022-03-24 cheeser0613
# 2022-05-14 cheeser0613
##### /authors #####

##### translated strings #####
Expand Down Expand Up @@ -906,15 +909,9 @@ Deactivate
Welcome to DDNet
== 歡迎來到 DDNet

Preinit VBO (iGPUs only)
== 預初始化頂點緩衝物件 (僅限整合顯示卡)

Activate
== 啟用

Multiple texture units (disable for macOS)
== 多重紋理單元 (macOS不可用)

File already exists, do you want to overwrite it?
== 檔案已存在,是否覆蓋?

Expand Down Expand Up @@ -1051,7 +1048,7 @@ DDraceNetwork is a cooperative online game where the goal is for you and your gr
== DDraceNetwork 是以到達地圖終點為目標,單人或組隊的線上合作遊戲。如果你是新手,你可以從有入門級地圖的 Novice 伺服器開 始。記得選擇 Ping 值低的伺服器。

It's recommended that you check the settings to adjust them to your liking before joining a server.
== 推薦在進入伺服器前,先將設定調整到符合你的習慣。
== 推薦在加入伺服器前,先將設定調整到符合你的習慣。

Please enter your nickname below.
== 請輸入你的暱稱。
Expand All @@ -1063,7 +1060,7 @@ Server best:
== 伺服器最佳

Learn
== 教程
== 教程Wiki

Use high DPI
== 使用高 DPI
Expand Down Expand Up @@ -1267,9 +1264,6 @@ Windowed borderless
Desktop fullscreen
== 無邊框全螢幕

Use modern OpenGL
== 使用現代OpenGL

Show client IDs
== 顯示客戶端ID

Expand Down Expand Up @@ -1343,10 +1337,61 @@ Windowed fullscreen
== 視窗化全螢幕

The format of texture %s is not RGBA which will cause visual bugs.
== %s 材質文件并非RGBA格式因此可能會導致視覺錯誤
== 紋理文件 %s 并非 RGBA 格式,這可能會導致顯示錯誤

Join Tutorial Server
==
== 加入教學伺服器

Skip Tutorial
==
== 跳過教學

Renderer
== 渲染設定

default
== 預設

custom
== 自定義

Graphics cards
== 顯示卡

auto
== 自動

Tutorial
== 教學

Toggle to edit your dummy settings
== 編輯分身設定

Choose default eyes when joining a server
== 加入伺服器時的預設表情

Allows maps to render with more detail
== 允許地圖渲染更多細節

When you cross the start line, show a ghost tee replicating the movements of your best time
== 當越過起跑綫時,游戲裏將有影子回放你的最佳成績

Opacity
== 不透明度

Adjust the opacity of entities belonging to other teams, such as tees and nameplates
== 調整單人區域或其他隊伍中玩家的不透明度

Quads are used for background decoration
== 顯示用於背景裝飾的貼圖

Tries to predict other entities to give a feel of low latency
== 嘗試預測其他實體物以帶來低延遲的游玩體驗

Can't find a Tutorial server
== 無法找到教學伺服器

Super
== 無敵

Team %d
== 隊伍 %d
56 changes: 49 additions & 7 deletions data/languages/turkish.txt
Expand Up @@ -885,12 +885,6 @@ may cause delay
Screen
== Ekran

Preinit VBO (iGPUs only)
== Preinit VBO (sadece iGPUs)

Multiple texture units (disable for macOS)
== Çoklu doku birimleri (macOS'da kullanılmaz)

Use high DPI
== Yüksek DPI kullan

Expand Down Expand Up @@ -1203,9 +1197,15 @@ Config directory
Themes directory
==

Toggle to edit your dummy settings
==

Download skins
==

Choose default eyes when joining a server
==

Skin Database
==

Expand All @@ -1230,7 +1230,22 @@ Windowed fullscreen
Desktop fullscreen
==

Use modern OpenGL
Allows maps to render with more detail
==

Renderer
==

default
==

custom
==

Graphics cards
==

auto
==

Game sound volume
Expand Down Expand Up @@ -1281,6 +1296,21 @@ Use old chat style
Preview
==

When you cross the start line, show a ghost tee replicating the movements of your best time
==

Opacity
==

Adjust the opacity of entities belonging to other teams, such as tees and nameplates
==

Quads are used for background decoration
==

Tries to predict other entities to give a feel of low latency
==

Show local player's key presses
==

Expand Down Expand Up @@ -1323,6 +1353,12 @@ https://ddnet.tw/discord
https://wiki.ddnet.tw/
==

Tutorial
==

Can't find a Tutorial server
==

Website
==

Expand All @@ -1344,3 +1380,9 @@ Editor
[Start menu]
Play
==

Super
==

Team %d
==
60 changes: 51 additions & 9 deletions data/languages/ukrainian.txt
Expand Up @@ -868,12 +868,6 @@ may cause delay
Screen
== Екран

Preinit VBO (iGPUs only)
== Preinit VBO (iGPUs only)

Multiple texture units (disable for macOS)
== Декілька текстурних одиниць (вимкнути для macOS)

Use high DPI
== Використовувати високий DPI

Expand Down Expand Up @@ -1207,9 +1201,6 @@ Windowed borderless
Desktop fullscreen
== Повний робочий стіл

Use modern OpenGL
== Використовувати сучасний OpenGL

Game sound volume
== Гучність звуку гри

Expand Down Expand Up @@ -1331,11 +1322,62 @@ Settings file
Config directory
==

Toggle to edit your dummy settings
==

Choose default eyes when joining a server
==

Windowed fullscreen
==

Allows maps to render with more detail
==

Renderer
==

default
==

custom
==

Graphics cards
==

auto
==

When you cross the start line, show a ghost tee replicating the movements of your best time
==

Opacity
==

Adjust the opacity of entities belonging to other teams, such as tees and nameplates
==

Quads are used for background decoration
==

Tries to predict other entities to give a feel of low latency
==

Run on join
==

Chat command (e.g. showall 1)
==

Tutorial
==

Can't find a Tutorial server
==

Super
==

Team %d
==
8 changes: 8 additions & 0 deletions datasrc/content.py
Expand Up @@ -259,6 +259,10 @@ def FileList(fmt, num):

container.pickups.Add(Pickup("health"))
container.pickups.Add(Pickup("armor"))
container.pickups.Add(Pickup("armor_shotgun"))
container.pickups.Add(Pickup("armor_grenade"))
container.pickups.Add(Pickup("armor_laser"))
container.pickups.Add(Pickup("armor_ninja"))
container.pickups.Add(Pickup("weapon"))
container.pickups.Add(Pickup("ninja", 90, 90))

Expand Down Expand Up @@ -358,6 +362,10 @@ def FileList(fmt, num):

container.sprites.Add(Sprite("pickup_health", set_game, 10,2,2,2))
container.sprites.Add(Sprite("pickup_armor", set_game, 12,2,2,2))
container.sprites.Add(Sprite("pickup_armor_shotgun", set_game, 15,2,2,2))
container.sprites.Add(Sprite("pickup_armor_grenade", set_game, 17,2,2,2))
container.sprites.Add(Sprite("pickup_armor_laser", set_game, 19,2,2,2))
container.sprites.Add(Sprite("pickup_armor_ninja", set_game, 10,10,2,2))
container.sprites.Add(Sprite("pickup_weapon", set_game, 3,0,6,2))
container.sprites.Add(Sprite("pickup_ninja", set_game, 2,10,8,2))

Expand Down
43 changes: 33 additions & 10 deletions datasrc/crosscompile.py
@@ -1,3 +1,4 @@
import sys
import network
import seven.network

Expand All @@ -23,30 +24,52 @@ def generate_map(a, b):

return result

def output_map_header(name, m):
print("extern const int gs_{}[{}];".format(name, len(m)))
print("inline int {0}(int a) {{ if(a < 0 || a >= {1}) return -1; return gs_{0}[a]; }}".format(name, len(m)))

def output_map(name, m):
print("static const int gs_{}[{}] = {{".format(name, len(m)))
def output_map_source(name, m):
print("const int gs_{}[{}] = {{".format(name, len(m)))
print(*m, sep=',')
print("};")
print("inline int {0}(int a) {{ if(a < 0 || a >= {1}) return -1; return gs_{0}[a]; }}".format(name, len(m)))

def main():
map_header = "map_header" in sys.argv
map_source = "map_source" in sys.argv
guard = "GAME_GENERATED_PROTOCOLGLUE"
print("#ifndef " + guard)
print("#define " + guard)
if map_header:
print("#ifndef " + guard)
print("#define " + guard)
elif map_source:
print("#include \"protocolglue.h\"")

msgs = get_msgs()
msgs7 = get_msgs_7()

output_map("Msg_SixToSeven", generate_map(msgs, msgs7))
output_map("Msg_SevenToSix", generate_map(msgs7, msgs))
map6to7 = generate_map(msgs, msgs7)
map7to6 = generate_map(msgs7, msgs)

if map_header:
output_map_header("Msg_SixToSeven", map6to7)
output_map_header("Msg_SevenToSix", map7to6)
elif map_source:
output_map_source("Msg_SixToSeven", map6to7)
output_map_source("Msg_SevenToSix", map7to6)

objs = get_objs()
objs7 = get_objs_7()
output_map("Obj_SixToSeven", generate_map(objs, objs7))
output_map("Obj_SevenToSix", generate_map(objs7, objs))

print("#endif //" + guard)
objs6to7 = generate_map(objs, objs7)
objs7to6 = generate_map(objs7, objs)

if map_header:
output_map_header("Obj_SixToSeven", objs6to7)
output_map_header("Obj_SevenToSix", objs7to6)
print("#endif //" + guard)
elif map_source:
output_map_source("Obj_SixToSeven", objs6to7)
output_map_source("Obj_SevenToSix", objs7to6)


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion datasrc/network.py
Expand Up @@ -34,7 +34,7 @@

Emoticons = ["OOP", "EXCLAMATION", "HEARTS", "DROP", "DOTDOT", "MUSIC", "SORRY", "GHOST", "SUSHI", "SPLATTEE", "DEVILTEE", "ZOMG", "ZZZ", "WTF", "EYES", "QUESTION"]

Powerups = ["HEALTH", "ARMOR", "WEAPON", "NINJA"]
Powerups = ["HEALTH", "ARMOR", "WEAPON", "NINJA", "ARMOR_SHOTGUN", "ARMOR_GRENADE", "ARMOR_NINJA", "ARMOR_LASER"]
Authed = ["NO", "HELPER", "MOD", "ADMIN"]
EntityClasses = ["PROJECTILE", "DOOR", "DRAGGER_WEAK", "DRAGGER_NORMAL", "DRAGGER_STRONG", "GUN_NORMAL", "GUN_EXPLOSIVE", "GUN_FREEZE", "GUN_UNFREEZE", "LIGHT", "PICKUP"]

Expand Down
2 changes: 1 addition & 1 deletion ddnet-libs
6 changes: 5 additions & 1 deletion other/config_directory.bat
@@ -1 +1,5 @@
@start explorer %APPDATA%\Teeworlds
if exist %APPDATA%\DDNet\ (
@start explorer %APPDATA%\DDNet\
) else (
@start explorer %APPDATA%\Teeworlds\
)
22 changes: 22 additions & 0 deletions other/config_directory.sh
@@ -0,0 +1,22 @@
#!/bin/sh
case "$(uname -s)" in
CYGWIN*|MINGW*|MSYS*)
if [ -d "$APPDATA/DDNet/" ]; then
explorer "$APPDATA/DDNet/"
else
explorer "$APPDATA/Teeworlds/"
fi;;
Darwin*)
if [ -d "$HOME/Library/Application Support/DDNet/" ]; then
open "$HOME/Library/Application Support/DDNet/"
else
open "$HOME/Library/Application Support/Teeworlds/"
fi;;
*)
DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
if [ -d "$DATA_HOME/ddnet/" ]; then
xdg-open "$DATA_HOME/ddnet/"
else
xdg-open "$HOME/.teeworlds/"
fi;;
esac
44 changes: 44 additions & 0 deletions other/emscripten/minimal.html
@@ -0,0 +1,44 @@
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
.game {
position: absolute;
top: 0px;
left: 0px;
margin: 0px;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
display: block;
}
</style>
</head>
<body>
<canvas class="game" id="canvas" widht="100%" height="100%" oncontextmenu="event.preventDefault()"></canvas>
<p id="output"></p>
<script>
var Module = {
print: (function() {
var element = document.getElementById('output');
return function(text) {
element.innerHTML += text + "<br>";
};
})(),
printErr: function(text) {
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
if (0) {
dump(text + '\n');
}
},
canvas: (function() {
var canvas = document.getElementById('canvas');
return canvas;
})()
};
</script>
<script src="DDNet.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion scripts/android/README.md
Expand Up @@ -47,7 +47,7 @@ How to build:
How to build the ddnet-libs for Android:
========================================
- There is a script to automatically download and build all repositories, this requires an active internet connection:
`scripts/android/gen_android_libs.sh <directory to build in>`
`scripts/compile_libs/gen_libs.sh <directory to build in> android`
Warning!: DO NOT CHOOSE A DIRECTORY INSIDE THE SOURCE TREE

After the script finished executing it should have created a ddnet-libs directory which created all libs in the right directory format and can be merged with ddnet-libs in the source directory
41 changes: 0 additions & 41 deletions scripts/android/cmake_lib_compile.sh

This file was deleted.

179 changes: 0 additions & 179 deletions scripts/android/gen_android_libs.sh

This file was deleted.

33 changes: 0 additions & 33 deletions scripts/android/make_android_openssl.sh

This file was deleted.

41 changes: 0 additions & 41 deletions scripts/android/make_android_sqlite3.sh

This file was deleted.

81 changes: 81 additions & 0 deletions scripts/compile_libs/cmake_lib_compile.sh
@@ -0,0 +1,81 @@
#!/bin/bash

ANDROID_HOME=~/Android/Sdk
ANDROID_NDK="$(find "$ANDROID_HOME/ndk" -maxdepth 1 | sort -n | tail -1)"
echo "$ANDROID_NDK"

export MAKEFLAGS=-j32

if [[ "${2}" == "webasm" ]]; then
COMPILEFLAGS="-pthread -O3 -g -s USE_PTHREADS=1"
LINKFLAGS="-pthread -O3 -g -s USE_PTHREADS=1 -s ASYNCIFY=1"
fi

COMPILEFLAGS=$3
LINKFLAGS=$4

function compile_source() {
if [[ "${4}" == "android" ]]; then
cmake \
-H. \
-G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Release \
-DANDROID_NATIVE_API_LEVEL="android-$1" \
-DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK/build/cmake/android.toolchain.cmake" \
-DANDROID_ABI="${3}" \
-DANDROID_ARM_NEON=TRUE \
-B"$2" \
-DBUILD_SHARED_LIBS=OFF \
-DHIDAPI_SKIP_LIBUSB=TRUE \
-DCURL_USE_OPENSSL=ON \
-DSDL_HIDAPI=OFF \
-DOP_DISABLE_HTTP=ON \
-DOP_DISABLE_EXAMPLES=ON \
-DOP_DISABLE_DOCS=ON \
-DOPENSSL_ROOT_DIR="$PWD"/../openssl/"$2" \
-DOPENSSL_CRYPTO_LIBRARY="$PWD"/../openssl/"$2"/libcrypto.a \
-DOPENSSL_SSL_LIBRARY="$PWD"/../openssl/"$2"/libssl.a \
-DOPENSSL_INCLUDE_DIR="${PWD}/../openssl/include;${PWD}/../openssl/${2}/include"
(
cd "$2" || exit 1
cmake --build .
)
else
${5} cmake \
-H. \
-DCMAKE_BUILD_TYPE=Release \
-B"$2" \
-DSDL_STATIC=TRUE \
-DFT_DISABLE_HARFBUZZ=ON \
-DFT_DISABLE_BZIP2=ON \
-DFT_DISABLE_BROTLI=ON \
-DFT_REQUIRE_ZLIB=TRUE \
-DCMAKE_C_FLAGS="$COMPILEFLAGS -DGLEW_STATIC" -DCMAKE_CXX_FLAGS="$COMPILEFLAGS" -DCMAKE_CXX_FLAGS_RELEASE="$COMPILEFLAGS" -DCMAKE_C_FLAGS_RELEASE="$COMPILEFLAGS" \
-DCMAKE_SHARED_LINKER_FLAGS="$LINKFLAGS" -DCMAKE_SHARED_LINKER_FLAGS_RELEASE="$LINKFLAGS" \
-DSDL_PTHREADS=ON -DSDL_THREADS=ON \
-DCURL_USE_OPENSSL=ON \
-DOPUS_HARDENING=OFF \
-DOPUS_STACK_PROTECTOR=OFF \
-DOPENSSL_ROOT_DIR="$PWD"/../openssl/"$2" \
-DOPENSSL_CRYPTO_LIBRARY="$PWD"/../openssl/"$2"/libcrypto.a \
-DOPENSSL_SSL_LIBRARY="$PWD"/../openssl/"$2"/libssl.a \
-DOPENSSL_INCLUDE_DIR="${PWD}/../openssl/include;${PWD}/../openssl/${2}/include" \
-DZLIB_LIBRARY="${PWD}/../zlib/${2}/libz.a" -DZLIB_INCLUDE_DIR="${PWD}/../zlib;${PWD}/../zlib/${2}"
(
cd "$2" || exit 1
cmake --build .
)
fi
}

if [[ "${2}" == "android" ]]; then
compile_source "$1" build_"$2"_arm armeabi-v7a "$2" "" &
compile_source "$1" build_"$2"_arm64 arm64-v8a "$2" "" &
compile_source "$1" build_"$2"_x86 x86 "$2" "" &
compile_source "$1" build_"$2"_x86_64 x86_64 "$2" "" &
elif [[ "${2}" == "webasm" ]]; then
sed -i "s/include(CheckSizes)//g" CMakeLists.txt
compile_source "$1" build_"$2"_wasm wasm "$2" emcmake &
fi

wait
253 changes: 253 additions & 0 deletions scripts/compile_libs/gen_libs.sh
@@ -0,0 +1,253 @@
#!/bin/bash

CURDIR="$PWD"
if [ -z ${1+x} ]; then
echo "Give a destination path where to run this script, please choose a path other than in the source directory"
exit 1
fi

if [ -z ${2+x} ]; then
echo "Specify the target system"
exit 1
fi

OS_NAME=$2

COMPILEFLAGS="-fPIC"
LINKFLAGS="-fPIC"
if [[ "${OS_NAME}" == "webasm" ]]; then
COMPILEFLAGS="-pthread -O3 -g -s USE_PTHREADS=1"
LINKFLAGS="-pthread -O3 -g -s USE_PTHREADS=1 -s ASYNCIFY=1 -s WASM=1"
fi

if [[ "${OS_NAME}" == "android" ]]; then
OS_NAME_PATH="android"
elif [[ "${OS_NAME}" == "windows" ]]; then
OS_NAME_PATH="windows"
elif [[ "${OS_NAME}" == "linux" ]]; then
OS_NAME_PATH="linux"
elif [[ "${OS_NAME}" == "webasm" ]]; then
OS_NAME_PATH="webasm"
fi

COMP_HAS_ARM32=0
COMP_HAS_ARM64=0
COMP_HAS_x86=0
COMP_HAS_x64=0
COMP_HAS_WEBASM=0

if [[ "${OS_NAME}" == "android" ]]; then
COMP_HAS_ARM32=1
COMP_HAS_ARM64=1
COMP_HAS_x86=1
COMP_HAS_x64=1
elif [[ "${OS_NAME}" == "linux" ]]; then
COMP_HAS_x64=1
elif [[ "${OS_NAME}" == "windows" ]]; then
COMP_HAS_x86=1
COMP_HAS_x64=1
elif [[ "${OS_NAME}" == "webasm" ]]; then
COMP_HAS_WEBASM=1
fi

mkdir -p "$1"
cd "$1" || exit 1

function build_cmake_lib() {
if [ ! -d "${1}" ]; then
git clone "${2}" "${1}"
fi
(
cd "${1}" || exit 1
cp "${CURDIR}"/scripts/compile_libs/cmake_lib_compile.sh cmake_lib_compile.sh
./cmake_lib_compile.sh "$_ANDROID_ABI_LEVEL" "$OS_NAME" "$COMPILEFLAGS" "$LINKFLAGS"
)
}

_ANDROID_ABI_LEVEL=24

mkdir -p compile_libs
cd compile_libs || exit 1

# start with openssl
(
_WAS_THERE_SSLFILE=1
if [ ! -d "openssl" ]; then
git clone https://github.com/openssl/openssl openssl
_WAS_THERE_SSLFILE=0
fi
(
cd openssl || exit 1
if [[ "$_WAS_THERE_SSLFILE" == 0 ]]; then
./autogen.sh
fi
cp "${CURDIR}"/scripts/compile_libs/make_lib_openssl.sh make_lib_openssl.sh
./make_lib_openssl.sh "$_ANDROID_ABI_LEVEL" "$OS_NAME" "$COMPILEFLAGS" "$LINKFLAGS"
)
)

build_cmake_lib zlib https://github.com/madler/zlib
build_cmake_lib png https://github.com/glennrp/libpng
build_cmake_lib curl https://github.com/curl/curl
build_cmake_lib freetype2 https://gitlab.freedesktop.org/freetype/freetype
build_cmake_lib sdl https://github.com/libsdl-org/SDL
build_cmake_lib ogg https://github.com/xiph/ogg
build_cmake_lib opus https://github.com/xiph/opus

(
_WAS_THERE_OPUSFILE=1
if [ ! -d "opusfile" ]; then
git clone https://github.com/xiph/opusfile opusfile
_WAS_THERE_OPUSFILE=0
fi
cd opusfile || exit 1
if [[ "$_WAS_THERE_OPUSFILE" == 0 ]]; then
./autogen.sh
fi
cp "${CURDIR}"/scripts/compile_libs/make_lib_opusfile.sh make_lib_opusfile.sh
./make_lib_opusfile.sh "$_ANDROID_ABI_LEVEL" "$OS_NAME" "$COMPILEFLAGS" "$LINKFLAGS"
)

# SQLite, just download and built by hand
if [ ! -d "sqlite3" ]; then
wget https://www.sqlite.org/2021/sqlite-amalgamation-3360000.zip
7z e sqlite-amalgamation-3360000.zip -osqlite3
fi

(
cd sqlite3 || exit 1
cp "${CURDIR}"/scripts/compile_libs/make_lib_sqlite3.sh make_lib_sqlite3.sh
./make_lib_sqlite3.sh "$_ANDROID_ABI_LEVEL" "$OS_NAME" "$COMPILEFLAGS" "$LINKFLAGS"
)

cd ..

function copy_arches_for_lib() {
if [[ "$COMP_HAS_ARM32" == "1" ]]; then
${1} arm arm
fi
if [[ "$COMP_HAS_ARM64" == "1" ]]; then
${1} arm64 arm64
fi
if [[ "$COMP_HAS_x86" == "1" ]]; then
${1} x86 32
fi
if [[ "$COMP_HAS_x64" == "1" ]]; then
${1} x86_64 64
fi
if [[ "$COMP_HAS_WEBASM" == "1" ]]; then
${1} wasm wasm
fi
}

mkdir ddnet-libs
function _copy_curl() {
mkdir -p ddnet-libs/curl/"$OS_NAME_PATH"/lib"$2"
cp compile_libs/curl/build_"$OS_NAME"_"$1"/lib/libcurl.a ddnet-libs/curl/"$OS_NAME_PATH"/lib"$2"/libcurl.a
}

copy_arches_for_lib _copy_curl

mkdir ddnet-libs
function _copy_freetype2() {
mkdir -p ddnet-libs/freetype/"$OS_NAME_PATH"/lib"$2"
cp compile_libs/freetype2/build_"$OS_NAME"_"$1"/libfreetype.a ddnet-libs/freetype/"$OS_NAME_PATH"/lib"$2"/libfreetype.a
}

copy_arches_for_lib _copy_freetype2

mkdir ddnet-libs
function _copy_sdl() {
mkdir -p ddnet-libs/sdl/"$OS_NAME_PATH"/lib"$2"
cp compile_libs/sdl/build_"$OS_NAME"_"$1"/libSDL2.a ddnet-libs/sdl/"$OS_NAME_PATH"/lib"$2"/libSDL2.a
cp compile_libs/sdl/build_"$OS_NAME"_"$1"/libSDL2main.a ddnet-libs/sdl/"$OS_NAME_PATH"/lib"$2"/libSDL2main.a
if [ ! -d "ddnet-libs/sdl/include/$OS_NAME_PATH" ]; then
mkdir -p ddnet-libs/sdl/include/"$OS_NAME_PATH"
fi
cp -R compile_libs/sdl/include/* ddnet-libs/sdl/include/"$OS_NAME_PATH"
}

copy_arches_for_lib _copy_sdl

# copy java code from SDL2
if [[ "$OS_NAME" == "android" ]]; then
rm -R ddnet-libs/sdl/java
mkdir -p ddnet-libs/sdl/java
cp -R compile_libs/sdl/android-project/app/src/main/java/org ddnet-libs/sdl/java/
fi

mkdir ddnet-libs
function _copy_ogg() {
mkdir -p ddnet-libs/opus/"$OS_NAME_PATH"/lib"$2"
cp compile_libs/ogg/build_"$OS_NAME"_"$1"/libogg.a ddnet-libs/opus/"$OS_NAME_PATH"/lib"$2"/libogg.a
}

copy_arches_for_lib _copy_ogg

mkdir ddnet-libs
function _copy_opus() {
mkdir -p ddnet-libs/opus/"$OS_NAME_PATH"/lib"$2"
cp compile_libs/opus/build_"$OS_NAME"_"$1"/libopus.a ddnet-libs/opus/"$OS_NAME_PATH"/lib"$2"/libopus.a
}

copy_arches_for_lib _copy_opus

mkdir ddnet-libs
function _copy_opusfile() {
mkdir -p ddnet-libs/opus/"$OS_NAME_PATH"/lib"$2"
cp compile_libs/opusfile/build_"$OS_NAME"_"$1"/libopusfile.a ddnet-libs/opus/"$OS_NAME_PATH"/lib"$2"/libopusfile.a
}

copy_arches_for_lib _copy_opusfile

mkdir ddnet-libs
function _copy_sqlite3() {
mkdir -p ddnet-libs/sqlite3/"$OS_NAME_PATH"/lib"$2"
cp compile_libs/sqlite3/build_"$OS_NAME"_"$1"/sqlite3.a ddnet-libs/sqlite3/"$OS_NAME_PATH"/lib"$2"/libsqlite3.a
}

copy_arches_for_lib _copy_sqlite3

mkdir ddnet-libs
function _copy_openssl() {
mkdir -p ddnet-libs/openssl/"$OS_NAME_PATH"/lib"$2"
mkdir -p ddnet-libs/openssl/include
mkdir -p ddnet-libs/openssl/include/"$OS_NAME_PATH"
cp compile_libs/openssl/build_"$OS_NAME"_"$1"/libcrypto.a ddnet-libs/openssl/"$OS_NAME_PATH"/lib"$2"/libcrypto.a
cp compile_libs/openssl/build_"$OS_NAME"_"$1"/libssl.a ddnet-libs/openssl/"$OS_NAME_PATH"/lib"$2"/libssl.a
cp -R compile_libs/openssl/build_"$OS_NAME"_"$1"/include/* ddnet-libs/openssl/include/"$OS_NAME_PATH"
cp -R compile_libs/openssl/include/* ddnet-libs/openssl/include
}

copy_arches_for_lib _copy_openssl

mkdir ddnet-libs
function _copy_zlib() {
# copy headers
(
cd compile_libs/zlib || exit 1
find . -maxdepth 1 -iname '*.h' -print0 | while IFS= read -r -d $'\0' file; do
mkdir -p ../../ddnet-libs/zlib/include/"$(dirname "$file")"
cp "$file" ../../ddnet-libs/zlib/include/"$(dirname "$file")"
done

cd build_"$OS_NAME"_"$1" || exit 1
find . -maxdepth 1 -iname '*.h' -print0 | while IFS= read -r -d $'\0' file; do
mkdir -p ../../../ddnet-libs/zlib/include/"$OS_NAME_PATH"/"$(dirname "$file")"
cp "$file" ../../../ddnet-libs/zlib/include/"$OS_NAME_PATH"/"$(dirname "$file")"
done
)

mkdir -p ddnet-libs/zlib/"$OS_NAME_PATH"/lib"$2"
cp compile_libs/zlib/build_"$OS_NAME"_"$1"/libz.a ddnet-libs/zlib/"$OS_NAME_PATH"/lib"$2"/libz.a
}

copy_arches_for_lib _copy_zlib

mkdir ddnet-libs
function _copy_png() {
mkdir -p ddnet-libs/png/"$OS_NAME_PATH"/lib"$2"
cp compile_libs/png/build_"$OS_NAME"_"$1"/libpng16.a ddnet-libs/png/"$OS_NAME_PATH"/lib"$2"/libpng16.a
}

copy_arches_for_lib _copy_png
48 changes: 48 additions & 0 deletions scripts/compile_libs/make_lib_openssl.sh
@@ -0,0 +1,48 @@
#!/bin/bash

ANDROID_HOME=~/Android/Sdk
ANDROID_NDK="$(find "$ANDROID_HOME/ndk" -maxdepth 1 | sort -n | tail -1)"

export MAKEFLAGS=-j32

export CXXFLAGS="$3"
export CFLAGS="$3"
export CPPFLAGS="$4"
export LDFLAGS="$4"

export ANDROID_NDK_ROOT=$ANDROID_NDK
PATH=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin:$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin:$PATH

function buid_openssl() {
_EXISTS_PROJECT=0
if [ -d "$1" ]; then
_EXISTS_PROJECT=1
else
mkdir "$1"
fi
(
cd "$1" || exit 1
if [[ "$_EXISTS_PROJECT" == "0" ]]; then
if [[ "${4}" == "webasm" ]]; then
emconfigure ../Configure "$2" -no-tests -no-asm -static -no-afalgeng -DOPENSSL_SYS_NETWARE -DSIG_DFL=0 -DSIG_IGN=0 -DHAVE_FORK=0 -DOPENSSL_NO_AFALGENG=1 --with-rand-seed=getrandom

sed -i 's|^CROSS_COMPILE.*$|CROSS_COMPILE=|g' Makefile
else
../Configure "$2" no-asm no-shared
fi
fi
${5} make $MAKEFLAGS build_generated
${5} make $MAKEFLAGS libcrypto.a
${5} make $MAKEFLAGS libssl.a
cd ..
)
}

if [[ "${2}" == "android" ]]; then
buid_openssl build_"$2"_arm android-arm "$1" "$2" ""
buid_openssl build_"$2"_arm64 android-arm64 "$1" "$2" ""
buid_openssl build_"$2"_x86 android-x86 "$1" "$2" ""
buid_openssl build_"$2"_x86_64 android-x86_64 "$1" "$2" ""
elif [[ "${2}" == "webasm" ]]; then
buid_openssl build_"$2"_wasm linux-generic64 "$1" "$2" emmake
fi
Expand Up @@ -5,6 +5,11 @@ ANDROID_NDK="$(find "$ANDROID_HOME/ndk" -maxdepth 1 | sort -n | tail -1)"

export MAKEFLAGS=-j32

export CXXFLAGS="$3"
export CFLAGS="$3"
export CPPFLAGS="$4"
export LDFLAGS="$4"

export ANDROID_NDK_ROOT="$ANDROID_NDK"

function make_opusfile() {
Expand All @@ -24,24 +29,33 @@ function make_opusfile() {
cp ../../ogg/"$2"/libogg.a libogg.a
cp ../../opus/"$2"/libopus.a libopus.a
fi
"$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/$3$4-clang" \

TMP_COMPILER=""
TMP_AR=""
if [[ "${5}" == "android" ]]; then
TMP_COMPILER="$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/$3$4-clang"
TMP_AR="$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar"
elif [[ "${5}" == "webasm" ]]; then
TMP_COMPILER="emcc"
TMP_AR="emar"
fi

${TMP_COMPILER} \
-c \
-fPIC \
-I"${PWD}"/../include \
-I"${PWD}"/include \
../src/opusfile.c \
../src/info.c \
../src/internal.c
"$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/$3$4-clang" \
${TMP_COMPILER} \
-c \
-fPIC \
-I"${PWD}"/../include \
-I"${PWD}"/include \
-include stdio.h \
-Dftello=ftell \
-Dfseek=fseek \
../src/stream.c
"$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" \
${TMP_AR} \
rvs \
libopusfile.a \
opusfile.o \
Expand All @@ -52,11 +66,15 @@ function make_opusfile() {
}

function compile_all_opusfile() {
make_opusfile build_arm build_android_arm armv7a-linux-androideabi "$1"
make_opusfile build_arm64 build_android_arm64 aarch64-linux-android "$1"
make_opusfile build_x86 build_android_x86 i686-linux-android "$1"
make_opusfile build_x86_64 build_android_x86_64 x86_64-linux-android "$1"
if [[ "${2}" == "android" ]]; then
make_opusfile build_"$2"_arm build_"$2"_arm armv7a-linux-androideabi "$1" "$2"
make_opusfile build_"$2"_arm64 build_"$2"_arm64 aarch64-linux-android "$1" "$2"
make_opusfile build_"$2"_x86 build_"$2"_x86 i686-linux-android "$1" "$2"
make_opusfile build_"$2"_x86_64 build_"$2"_x86_64 x86_64-linux-android "$1" "$2"
elif [[ "${2}" == "webasm" ]]; then
make_opusfile build_"$2"_wasm build_"$2"_wasm "" "$1" "$2"
fi
}

compile_all_opusfile "$1"
compile_all_opusfile "$1" "$2"

65 changes: 65 additions & 0 deletions scripts/compile_libs/make_lib_sqlite3.sh
@@ -0,0 +1,65 @@
#!/bin/bash

ANDROID_HOME=~/Android/Sdk
ANDROID_NDK="$(find "$ANDROID_HOME/ndk" -maxdepth 1 | sort -n | tail -1)"

export MAKEFLAGS=-j32

export CXXFLAGS="$3"
export CFLAGS="$3"
export CPPFLAGS="$4"
LINKER_FLAGS="$4"

export ANDROID_NDK_ROOT="$ANDROID_NDK"
PATH="$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin:$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin:$PATH"
_LD_LIBRARY_PATH=".:$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin:$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin:$LD_LIBRARY_PATH"

function make_sqlite3() {
(
mkdir -p "$1"
cd "$1" || exit 1

TMP_COMPILER=""
TMP_AR=""
if [[ "${5}" == "android" ]]; then
TMP_COMPILER="$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/$3$4-clang"
TMP_AR="$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar"
elif [[ "${5}" == "webasm" ]]; then
TMP_COMPILER="emcc"
TMP_AR="emar"
fi

LDFLAGS="${LINKER_FLAGS} -L./" \
LD_LIBRARY_PATH="$_LD_LIBRARY_PATH" \
${TMP_COMPILER} \
-c \
-fPIC \
-DSQLITE_ENABLE_ATOMIC_WRITE=1 \
-DSQLITE_ENABLE_BATCH_ATOMIC_WRITE=1 \
-DSQLITE_ENABLE_MULTITHREADED_CHECKS=1 \
-DSQLITE_THREADSAFE=1 \
../sqlite3.c \
-o sqlite3.o

LDFLAGS="${LINKER_FLAGS} -L./" \
LD_LIBRARY_PATH="$_LD_LIBRARY_PATH" \
${TMP_AR} \
rvs \
sqlite3.a \
sqlite3.o
)
}

function compile_all_sqlite3() {
if [[ "${2}" == "android" ]]; then
make_sqlite3 build_"$2"_arm build_"$2"_arm armv7a-linux-androideabi "$1" "$2"
make_sqlite3 build_"$2"_arm64 build_"$2"_arm64 aarch64-linux-android "$1" "$2"
make_sqlite3 build_"$2"_x86 build_"$2"_x86 i686-linux-android "$1" "$2"
make_sqlite3 build_"$2"_x86_64 build_"$2"_x86_64 x86_64-linux-android "$1" "$2"
elif [[ "${2}" == "webasm" ]]; then
make_sqlite3 build_"$2"_wasm build_"$2"_wasm "" "$1" "$2"
fi
}

compile_all_sqlite3 "$1" "$2"

2 changes: 1 addition & 1 deletion scripts/move_sqlite.py
Expand Up @@ -36,7 +36,7 @@ def transfer(file_from, file_to):
conn_from = sqlite3.connect(file_from, isolation_level='EXCLUSIVE')
for line in conn_from.iterdump():
cursor_to.execute(line)
print(line)
print(line.encode('utf-8'))
cursor_to.close()
conn_to.commit()
conn_to.close()
Expand Down
4 changes: 2 additions & 2 deletions src/base/color.h
Expand Up @@ -177,8 +177,8 @@ inline ColorRGBA color_cast(const ColorHSLA &hsl)
vec3 rgb = vec3(0, 0, 0);

float h1 = hsl.h * 6;
float c = (1 - absolute(2 * hsl.l - 1)) * hsl.s;
float x = c * (1 - absolute(fmod(h1, 2) - 1));
float c = (1.f - absolute(2 * hsl.l - 1)) * hsl.s;
float x = c * (1.f - absolute(fmodf(h1, 2) - 1.f));

switch(round_truncate(h1))
{
Expand Down
6 changes: 5 additions & 1 deletion src/base/detect.h
Expand Up @@ -46,12 +46,16 @@
#define PLATFORM_STRING "openbsd"
#endif

#if(defined(__LINUX__) || defined(__linux__)) && !defined(__ANDROID__)
#if(defined(__LINUX__) || defined(__linux__) || defined(CONF_WEBASM)) && !defined(__ANDROID__)
#define CONF_FAMILY_UNIX 1
#define CONF_FAMILY_STRING "unix"
#define CONF_PLATFORM_LINUX 1
#define PLATFORM_STRING "linux"
#define CONF_BACKEND_OPENGL_ES3 1
#ifdef CONF_WEBASM
// GLES only
#define CONF_BACKEND_OPENGL_ES 1
#endif
#endif

#if defined(__ANDROID__)
Expand Down
2 changes: 2 additions & 0 deletions src/base/hash.cpp
Expand Up @@ -3,6 +3,8 @@

#include "system.h"

const SHA256_DIGEST SHA256_ZEROED = {{0}};

static void digest_str(const unsigned char *digest, size_t digest_len, char *str, size_t max_len)
{
unsigned i;
Expand Down
3 changes: 1 addition & 2 deletions src/base/hash.h
Expand Up @@ -31,8 +31,7 @@ void md5_str(MD5_DIGEST digest, char *str, size_t max_len);
int md5_from_str(MD5_DIGEST *out, const char *str);
int md5_comp(MD5_DIGEST digest1, MD5_DIGEST digest2);

static const SHA256_DIGEST SHA256_ZEROED = {{0}};
static const MD5_DIGEST MD5_ZEROED = {{0}};
extern const SHA256_DIGEST SHA256_ZEROED;

inline bool operator==(const SHA256_DIGEST &that, const SHA256_DIGEST &other)
{
Expand Down
418 changes: 418 additions & 0 deletions src/base/log.cpp

Large diffs are not rendered by default.

100 changes: 100 additions & 0 deletions src/base/log.h
@@ -0,0 +1,100 @@
#ifndef BASE_LOG_H
#define BASE_LOG_H

#include <stdarg.h>
#include <stdint.h>

#if defined(__cplusplus)
extern "C" {
#endif

#ifdef __GNUC__
#define GNUC_ATTRIBUTE(x) __attribute__(x)
#else
#define GNUC_ATTRIBUTE(x)
#endif

enum LEVEL : char
{
LEVEL_ERROR,
LEVEL_WARN,
LEVEL_INFO,
LEVEL_DEBUG,
LEVEL_TRACE,
};

struct LOG_COLOR
{
uint8_t r;
uint8_t g;
uint8_t b;
};

#define log_error(sys, ...) log_log(LEVEL_ERROR, sys, __VA_ARGS__)
#define log_warn(sys, ...) log_log(LEVEL_WARN, sys, __VA_ARGS__)
#define log_info(sys, ...) log_log(LEVEL_INFO, sys, __VA_ARGS__)
#define log_debug(sys, ...) log_log(LEVEL_DEBUG, sys, __VA_ARGS__)
#define log_trace(sys, ...) log_log(LEVEL_TRACE, sys, __VA_ARGS__)

/**
* @defgroup Log
*
* Methods for outputting log messages and way of handling them.
*/

/**
* @ingroup Log
*
* Prints a log message.
*
* @param level Severity of the log message.
* @param sys A string that describes what system the message belongs to.
* @param fmt A printf styled format string.
*/
void log_log(LEVEL level, const char *sys, const char *fmt, ...)
GNUC_ATTRIBUTE((format(printf, 3, 4)));

/**
* @ingroup Log
*
* Prints a log message with a given color.
*
* @param level Severity of the log message.
* @param color Requested color for the log message output.
* @param sys A string that describes what system the message belongs to.
* @param fmt A printf styled format string.
*/
void log_log_color(LEVEL level, LOG_COLOR color, const char *sys, const char *fmt, ...)
GNUC_ATTRIBUTE((format(printf, 4, 5)));

/**
* @ingroup Log
*
* Same as `log_log`, but takes a `va_list` instead.
*
* @param level Severity of the log message.
* @param sys A string that describes what system the message belongs to.
* @param fmt A printf styled format string.
* @param args The variable argument list.
*/
void log_log_v(LEVEL level, const char *sys, const char *fmt, va_list args)
GNUC_ATTRIBUTE((format(printf, 3, 0)));

/**
* @ingroup Log
*
* Same as `log_log_color`, but takes a `va_list` instead.
*
* @param level Severity of the log message.
* @param color Requested color for the log message output.
* @param sys A string that describes what system the message belongs to.
* @param fmt A printf styled format string.
* @param args The variable argument list.
*/
void log_log_color_v(LEVEL level, LOG_COLOR color, const char *sys, const char *fmt, va_list args)
GNUC_ATTRIBUTE((format(printf, 4, 0)));

#if defined(__cplusplus)
}
#endif
#endif // BASE_LOG_H
237 changes: 237 additions & 0 deletions src/base/logger.h
@@ -0,0 +1,237 @@
#ifndef BASE_LOGGER_H
#define BASE_LOGGER_H

#include "log.h"
#include <atomic>
#include <memory>
#include <mutex>
#include <vector>

extern "C" {

typedef struct IOINTERNAL *IOHANDLE;

/**
* @ingroup Log
*
* Metadata and actual content of a log message.
*/
class CLogMessage
{
public:
/**
* Severity
*/
LEVEL m_Level;
bool m_HaveColor;
/**
* The requested color of the log message. Only useful if `m_HaveColor`
* is set.
*/
LOG_COLOR m_Color;
char m_aTimestamp[80];
char m_aSystem[32];
/**
* The actual log message including the timestamp and the system.
*/
char m_aLine[4096];
int m_TimestampLength;
int m_SystemLength;
/**
* Length of the log message including timestamp and the system.
*/
int m_LineLength;
int m_LineMessageOffset;

/**
* The actual log message excluding timestamp and the system.
*/
const char *Message() const
{
return m_aLine + m_LineMessageOffset;
}
};

class ILogger
{
public:
virtual ~ILogger() {}

/**
* Send the specified message to the logging backend.
*
* @param pMessage Struct describing the log message.
*/
virtual void Log(const CLogMessage *pMessage) = 0;
/**
* Flushes output buffers and shuts down.
* Global loggers cannot be destroyed because they might be accessed
* from multiple threads concurrently.
*
* This function is called on the global logger by
* `log_global_logger_finish` when the program is about to shut down
* and loggers are supposed to finish writing the log messages they
* have received so far.
*
* The destructor of this `ILogger` instance will not be called if this
* function is called.
*
* @see log_global_logger_finish
*/
virtual void GlobalFinish() {}
};

/**
* @ingroup Log
*
* Registers a logger instance as the default logger for all current and future
* threads. It will only be used if no thread-local logger is set via
* `log_set_scope_logger`.
*
* This function can only be called once. The passed logger instance will never
* be freed.
*
* @param logger The global logger default.
*/
void log_set_global_logger(ILogger *logger);

/**
* @ingroup Log
*
* Registers a sane default as the default logger for all current and future
* threads.
*
* This is logging to stdout on most platforms and to the system log on
* Android.
*
* @see log_set_global_logger
*/
void log_set_global_logger_default();

/**
* @ingroup Log
*
* Notify global loggers of impending abnormal exit.
*
* This function is automatically called on normal exit. It notifies the global
* logger of the impending shutdown via `GlobalFinish`, the logger is supposed
* to flush its buffers and shut down.
*
* Don't call this except right before an abnormal exit.
*/
void log_global_logger_finish();

/**
* @ingroup Log
*
* Get the logger active in the current scope. This might be the global default
* logger or some other logger set via `log_set_scope_logger`.
*/
ILogger *log_get_scope_logger();

/**
* @ingroup Log
*
* Set the logger for the current thread. The logger isn't managed by the
* logging system, it still needs to be kept alive or freed by the caller.
*
* Consider using `CLogScope` if you only want to set the logger temporarily.
*
* @see CLogScope
*/
void log_set_scope_logger(ILogger *logger);
}

/**
* @ingroup Log
*
* Logger for sending logs to the Android system log.
*
* Should only be called when targeting the Android platform.
*/
std::unique_ptr<ILogger> log_logger_android();

/**
* @ingroup Log
*
* Logger combining a vector of other loggers.
*/
std::unique_ptr<ILogger> log_logger_collection(std::vector<std::shared_ptr<ILogger>> &&loggers);

/**
* @ingroup Log
*
* Logger for writing logs to the given file.
*
* @param file File to write to, must be opened for writing.
*/
std::unique_ptr<ILogger> log_logger_file(IOHANDLE file);

/**
* @ingroup Log
*
* Logger for writing logs to the standard output (stdout).
*/
std::unique_ptr<ILogger> log_logger_stdout();

/**
* @ingroup Log
*
* Logger for sending logs to the debugger on Windows via `OutputDebugStringW`.
*
* Should only be called when targeting the Windows platform.
*/
std::unique_ptr<ILogger> log_logger_windows_debugger();

/**
* @ingroup Log
*
* Logger that collects log messages in memory until it is replaced by another
* logger.
*
* Useful when you want to set a global logger without all logging targets
* being configured.
*/
class CFutureLogger : public ILogger
{
private:
std::atomic<ILogger *> m_pLogger;
std::vector<CLogMessage> m_aPending;
std::mutex m_PendingLock;

public:
/**
* Replace the `CFutureLogger` instance with the given logger. It'll
* receive all log messages sent to the `CFutureLogger` so far.
*/
void Set(std::unique_ptr<ILogger> &&pLogger);
void Log(const CLogMessage *pMessage) override;
void GlobalFinish() override;
};

/**
* @ingroup Log
*
* RAII guard for temporarily changing the logger via `log_set_scope_logger`.
*
* @see log_set_scope_logger
*/
class CLogScope
{
ILogger *old_scope_logger;
ILogger *new_scope_logger;

public:
CLogScope(ILogger *logger) :
old_scope_logger(log_get_scope_logger()),
new_scope_logger(logger)
{
log_set_scope_logger(new_scope_logger);
}
~CLogScope()
{
//dbg_assert(log_get_scope_logger() == new_scope_logger, "loggers weren't properly scoped");
log_set_scope_logger(old_scope_logger);
}
};
#endif // BASE_LOGGER_H
69 changes: 37 additions & 32 deletions src/base/math.h
Expand Up @@ -3,19 +3,11 @@
#ifndef BASE_MATH_H
#define BASE_MATH_H

#include <algorithm>
#include <math.h>
#include <stdlib.h>

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;
}
using std::clamp;

constexpr inline int round_to_int(float f)
{
Expand All @@ -38,51 +30,64 @@ constexpr inline T mix(const T a, const T b, TB amount)
return a + (b - a) * amount;
}

inline float random_float() { return rand() / (float)(RAND_MAX); }
inline float random_float()
{
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 int fxpscale = 1 << 10;

// int to fixed
inline int i2fx(int v)
// float to fixed
constexpr inline int f2fx(float v)
{
return v << 10;
return (int)(v * fxpscale);
}
inline int fx2i(int v)
constexpr inline float fx2f(int v)
{
return v >> 10;
return v / (float)fxpscale;
}

inline int gcd(int a, int b)
// int to fixed
constexpr inline int i2fx(int v)
{
while(b != 0)
{
int c = a % b;
a = b;
b = c;
}
return a;
return v * fxpscale;
}
constexpr inline int fx2i(int v)
{
return v / fxpscale;
}

class fxp
{
int value;

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

constexpr float pi = 3.1415926535897932384626433f;
Expand Down