- name: Install deps
run: |
sudo apt-get update
- sudo apt-get install -y build-essential cmake libgl1-mesa-dev libglfw3-dev libglew-dev libsqlite3-dev zlib1g-dev curl zip lua5.3
- - name: Build
+ sudo apt-get install -y build-essential cmake lua5.3 curl zip
+ - name: Build ubuntu snapshot
run: |
./snapshot.sh
- - name: Upload snapshot
+ - name: Build windows snapshot
+ run: |
+ ./snapshot.sh mingw
+ - name: Upload snapshots
env:
SECRET: ${{ secrets.ELIDRAGON_UPLOAD_TOKEN }}
run: |
-# CMake
-CMakeLists.txt.user
-CMakeCache.txt
-CMakeFiles
-CMakeScripts
-Testing
-Makefile
-cmake_install.cmake
-install_manifest.txt
-compile_commands.json
-CTestTestfile.cmake
-_deps
-
-# Binaries
-dragonblocks
-dragonblocks_server
-dragonblocks_alpha-*.zip
-dragonblocks_alpha
-
-# Data
-client.conf
-server.conf
-*.sqlite
-*.sqlite-journal
-screenshot-*.png
-
-# Generated code
-version.h
-types.c
-types.h
+build*/*
+!build/debug.sh
+!build/debug_loop.sh
+dragonblocks_alpha*
url = https://github.com/datenwolf/linmath.h
[submodule "deps/perlin"]
path = deps/perlin
- url = https://github.com/czinn/perlin
+ url = https://github.com/dragonblocks/perlin
[submodule "deps/stb"]
path = deps/stb
url = https://github.com/nothings/stb
url = https://github.com/dragonblocks/dragonnet
[submodule "deps/linenoise"]
path = deps/linenoise
- url = https://github.com/msteveb/linenoise
+ url = https://github.com/dragonblocks/linenoise
[submodule "deps/protogen"]
path = deps/protogen
url = https://github.com/dragonblocks/protogen
[submodule "deps/getline"]
path = deps/getline
url = https://github.com/dragonblocks/getline
+[submodule "deps/glfw"]
+ path = deps/glfw
+ url = https://github.com/glfw/glfw
+[submodule "deps/glew-cmake"]
+ path = deps/glew-cmake
+ url = https://github.com/Perlmint/glew-cmake
+[submodule "deps/freetype"]
+ path = deps/freetype
+ url = https://gitlab.freedesktop.org/freetype/freetype
+[submodule "deps/sqlite3-cmake"]
+ path = deps/sqlite3-cmake
+ url = https://github.com/dragonblocks/sqlite3-cmake
+[submodule "deps/stpcpy"]
+ path = deps/stpcpy
+ url = https://github.com/dragonblocks/stpcpy
+[submodule "deps/zlib"]
+ path = deps/zlib
+ url = https://github.com/dragonblocks/zlib
# Building instructions
-CMake is used for compiling. Make sure to clone the repository recursively:
-
-```bash
-git clone --recurse-submodules https://github.com/dragonblocks/dragonblocks_alpha.git
-```
-
## Dependencies
-To build anything you need CMake and Lua. The ZLib development library is needed as well.
-The development versions of OpenGL, GLFW3, GLEW and Freetype are required to build the client.
-For building the server the SQLite3 development library is required.
-
-
-Ubuntu / Debian:
+To build anything you need Git, CMake, Lua, Bash and GCC. Make sure these dependencies are installed on your system.
+All other dependencies are included as submodules, compiled automatically and statically linked.
+Make sure to clone the repository recursively:
```bash
-sudo apt install build-essential cmake zlib1g-dev libgl1-mesa-dev libglfw3-dev libglew-dev libfreetype-dev libsqlite3-dev lua5.3
-```
-
-FreeBSD:
-
-```csh
-sudo pkg install cmake gcc lzlib mesa-devel glfw glew freetype sqlite3 lua
-```
-
-OpenBSD:
-
-```sh
-sudo pkg_add cmake lzlib glfw glew freetype sqlite3 lua
+git clone --recurse-submodules https://github.com/dragonblocks/dragonblocks_alpha.git
```
## Building a debug build
-By default CMake will make a Debug build if nothing else is specified. Simply use
+By default CMake will make a debug build if nothing else is specified. Simply use
```bash
-cd src
-cmake .
+cmake -B build -S src
+cd build
make -j$(nproc)
```
to build the dragonblocks client and server.
-If you use a debug build, the singleplayer script should be invoked from the src/ directory, because that's where the binaries are located.
+If you use a debug build, the singleplayer script should be invoked from the build/ directory, because that's where the binaries are located.
-## Building a snapshot
+## Building a release snapshot
```bash
+# Native snapshot
./snapshot.sh
+
+# Crosscompiling for windows (requires i686-w64-mingw32-gcc-posix)
+./snapshot.sh mingw
```
-This script will create a snapshot zipfile.
+
+Creates snapshot zipfiles.
# Dragonblocks Alpha
A multiplayer voxelgame for POSIX systems.
+It has been ported to Linux, Windows, FreeBSD and OpenBSD, but may work on other systems.
-Head to <https://www.elidragon.tk/dragonblocks_alpha/> for ubuntu snapshot and release builds.
+Head to <https://www.elidragon.tk/dragonblocks_alpha/> for snapshot and release builds (CURRENTLY DOWN).
## Invocation
-```bash
-./DragonblocksServer <port>
-./Dragonblocks <address> <port>
+```sh
+# on posix
+./dragonblocks_server "[<address>]:<port>"
+./dragonblocks_client "[<address>]:<port>"
+
+# on windows
+dragonblocks_server.exe "[<address>]:<port>"
+dragonblocks_client.exe "[<address>]:<port>"
```
or alternatively:
-```bash
+```sh
+# on posix
./singleplayer.sh
+
+# on windows
+singleplayer.bat
```
## Controls
| F11 | Toggle fullscreen |
| ESC | Pause / unpause game |
-## Dependencies
-
-Both the client and the server depend on ZLib.
-The client depends on GLFW3, OpenGL, GLEW and Freetype.
-The server depends on SQLite3.
-
-Ubuntu / Debian:
-
-```bash
-sudo apt install zlib1g libgl1-mesa-dri libglfw3 libglew2.1 libfreetype6 libsqlite3-0
-
-```
-
-FreeBSD:
-
-```csh
-sudo pkg install lzlib mesa-dri glfw glew freetype sqlite3
-```
-
-OpenBSD:
-
-```sh
-sudo pkg_add lzlib glfw glew freetype sqlite3
-```
-
-## Setup Requirements
+## System Requirements
Dragonblocks Alpha targets PCs only. Non x86-64 platforms may work, however there is no guarantee whatsoever.
You need a POSIX system conforming to the ISO C and POSIX 2008 standards. However, so far only GNU/Linux systems, in particular Ubuntu and Debian, have been tested.
-The minimum OpenGL version is 4.6.0. Dragonblocks has been tested on Intel Integrated and NVIDIA GPUs, however other graphics cards should work as well.
+The minimum OpenGL version is 4.2.0. Dragonblocks has been tested on Intel Integrated and NVIDIA GPUs, however other graphics cards should work as well.
A PC with at least 4 CPU cores is recommended, but not necessarily required.
## Current Features
--- /dev/null
+# Goxel 0.10.6
+# One line per voxel
+# X Y Z RRGGBB
+0 -1 9 a5a5a5
+0 -1 10 a0a0a0
+0 0 0 503612
+0 0 1 503612
+0 0 2 584120
+0 0 3 43351e
+0 0 4 503612
+0 0 5 503612
+0 0 6 4a3312
+0 0 7 5c421a
+0 3 7 a0a0a0
+0 4 7 9e9e9e
+0 0 8 5a380e
+0 2 8 9e9e9e
+0 3 8 a1a1a1
+0 4 8 a1a1a1
+0 0 9 a1a1a1
+1 0 9 a0a0a0
+0 1 9 9e9e9e
+0 2 9 9e9e9e
+0 3 9 a1a1a1
+0 4 9 9e9e9e
+0 0 10 989898
+1 0 10 a0a0a0
+0 1 10 a0a0a0
+0 2 10 9e9e9e
+0 3 10 9e9e9e
+0 4 10 9e9e9e
+0 0 11 5c421a
+0 2 11 a0a0a0
+0 3 11 9e9e9e
+0 4 11 a1a1a1
+0 3 12 9e9e9e
+0 4 12 9e9e9e
+-1 0 9 a0a0a0
+-1 0 10 a0a0a0
--- /dev/null
+# Goxel 0.10.6
+# One line per voxel
+# X Y Z RRGGBB
+0 -4 7 a0a0a0
+0 -4 8 a0a0a0
+0 -3 8 999999
+0 -3 9 a0a0a0
+0 -2 9 a0a0a0
+0 -1 9 8b8b8b
+0 -2 10 a0a0a0
+0 -1 10 a9a9a9
+0 0 0 503612
+0 0 1 503612
+0 0 2 584120
+0 0 3 43351e
+0 0 4 503612
+0 0 5 503612
+0 0 6 4a3312
+0 0 7 5c421a
+0 4 7 999999
+0 0 8 5a380e
+0 3 8 999999
+0 4 8 a0a0a0
+0 0 9 a0a0a0
+0 1 9 a9a9a9
+0 2 9 a0a0a0
+0 3 9 a0a0a0
+0 0 10 a9a9a9
+0 1 10 8b8b8b
+0 2 10 a0a0a0
+0 0 11 a0a0a0
--- /dev/null
+# Goxel 0.10.6
+# One line per voxel
+# X Y Z RRGGBB
+0 0 0 503612
+0 0 1 503612
+0 0 2 584120
+0 0 3 43351e
+0 0 4 503612
+0 0 5 503612
+0 0 6 4a3312
+0 0 7 5c421a
+0 0 8 5a380e
+0 0 9 959595
+1 0 9 a0a0a0
+0 0 10 959595
+1 0 10 959595
+0 0 11 7e7e7e
+1 0 11 a0a0a0
+0 0 12 a0a0a0
+-1 0 9 7e7e7e
+-1 0 10 959595
+-1 0 11 959595
--- /dev/null
+# Goxel 0.10.6
+# One line per voxel
+# X Y Z RRGGBB
+0 0 0 920088
+1 0 0 920088
+2 0 0 920088
+3 0 0 920088
+4 0 0 920088
+5 0 0 920088
+6 0 0 920088
+7 0 0 920088
+8 0 0 920088
+0 1 0 920088
+1 1 0 c400bc
+2 1 0 c400bc
+3 1 0 c400bc
+4 1 0 c400bc
+5 1 0 c400bc
+6 1 0 c400bc
+7 1 0 c400bc
+8 1 0 920088
+0 2 0 920088
+1 2 0 c400bc
+2 2 0 c400bc
+3 2 0 cdd300
+4 2 0 cdd300
+5 2 0 cdd300
+6 2 0 c400bc
+7 2 0 c400bc
+8 2 0 920088
+0 3 0 920088
+1 3 0 c400bc
+2 3 0 cdd300
+3 3 0 c400bc
+4 3 0 c400bc
+5 3 0 c400bc
+6 3 0 cdd300
+7 3 0 c400bc
+8 3 0 920088
+0 4 0 920088
+1 4 0 c400bc
+2 4 0 c400bc
+3 4 0 c400bc
+4 4 0 cdd300
+5 4 0 cdd300
+6 4 0 c400bc
+7 4 0 c400bc
+8 4 0 920088
+0 5 0 920088
+1 5 0 c400bc
+2 5 0 c400bc
+3 5 0 c400bc
+4 5 0 c400bc
+5 5 0 c400bc
+6 5 0 c400bc
+7 5 0 c400bc
+8 5 0 920088
+0 6 0 920088
+1 6 0 c400bc
+2 6 0 c400bc
+3 6 0 c400bc
+4 6 0 cdd300
+5 6 0 c400bc
+6 6 0 c400bc
+7 6 0 c400bc
+8 6 0 920088
+0 7 0 920088
+1 7 0 c400bc
+2 7 0 c400bc
+3 7 0 c400bc
+4 7 0 c400bc
+5 7 0 c400bc
+6 7 0 c400bc
+7 7 0 c400bc
+8 7 0 920088
+0 8 0 920088
+1 8 0 920088
+2 8 0 920088
+3 8 0 920088
+4 8 0 920088
+5 8 0 920088
+6 8 0 920088
+7 8 0 920088
+8 8 0 920088
+0 0 1 920088
+1 0 1 c400bc
+2 0 1 c400bc
+3 0 1 c400bc
+4 0 1 c400bc
+5 0 1 c400bc
+6 0 1 c400bc
+7 0 1 c400bc
+8 0 1 920088
+0 1 1 c400bc
+1 1 1 ffffff
+2 1 1 ffffff
+3 1 1 ffffff
+4 1 1 ffffff
+5 1 1 ffffff
+6 1 1 ffffff
+7 1 1 ffffff
+8 1 1 c400bc
+0 2 1 c400bc
+1 2 1 ffffff
+2 2 1 ffffff
+3 2 1 ffffff
+4 2 1 ffffff
+5 2 1 ffffff
+6 2 1 ffffff
+7 2 1 ffffff
+8 2 1 c400bc
+0 3 1 c400bc
+1 3 1 ffffff
+2 3 1 ffffff
+3 3 1 ffffff
+4 3 1 ffffff
+5 3 1 ffffff
+6 3 1 ffffff
+7 3 1 ffffff
+8 3 1 c400bc
+0 4 1 c400bc
+1 4 1 ffffff
+2 4 1 ffffff
+3 4 1 ffffff
+4 4 1 ffffff
+5 4 1 ffffff
+6 4 1 ffffff
+7 4 1 ffffff
+8 4 1 c400bc
+0 5 1 c400bc
+1 5 1 ffffff
+2 5 1 ffffff
+3 5 1 ffffff
+4 5 1 ffffff
+5 5 1 ffffff
+6 5 1 ffffff
+7 5 1 ffffff
+8 5 1 c400bc
+0 6 1 c400bc
+1 6 1 ffffff
+2 6 1 ffffff
+3 6 1 ffffff
+4 6 1 ffffff
+5 6 1 ffffff
+6 6 1 ffffff
+7 6 1 ffffff
+8 6 1 c400bc
+0 7 1 c400bc
+1 7 1 ffffff
+2 7 1 ffffff
+3 7 1 ffffff
+4 7 1 ffffff
+5 7 1 ffffff
+6 7 1 ffffff
+7 7 1 ffffff
+8 7 1 c400bc
+0 8 1 920088
+1 8 1 c400bc
+2 8 1 c400bc
+3 8 1 c400bc
+4 8 1 c400bc
+5 8 1 c400bc
+6 8 1 c400bc
+7 8 1 c400bc
+8 8 1 920088
+0 0 2 920088
+1 0 2 c400bc
+2 0 2 c400bc
+3 0 2 c400bc
+4 0 2 cdd300
+5 0 2 c400bc
+6 0 2 c400bc
+7 0 2 c400bc
+8 0 2 920088
+0 1 2 c400bc
+1 1 2 ffffff
+2 1 2 ffffff
+3 1 2 ffffff
+4 1 2 ffffff
+5 1 2 ffffff
+6 1 2 ffffff
+7 1 2 ffffff
+8 1 2 c400bc
+0 2 2 c400bc
+1 2 2 ffffff
+2 2 2 ffffff
+3 2 2 ffffff
+4 2 2 ffffff
+5 2 2 ffffff
+6 2 2 ffffff
+7 2 2 ffffff
+8 2 2 c400bc
+0 3 2 c400bc
+1 3 2 ffffff
+2 3 2 ffffff
+3 3 2 ffffff
+4 3 2 ffffff
+5 3 2 ffffff
+6 3 2 ffffff
+7 3 2 ffffff
+8 3 2 c400bc
+0 4 2 cdd300
+1 4 2 ffffff
+2 4 2 ffffff
+3 4 2 ffffff
+4 4 2 ffffff
+5 4 2 ffffff
+6 4 2 ffffff
+7 4 2 ffffff
+8 4 2 cdd300
+0 5 2 c400bc
+1 5 2 ffffff
+2 5 2 ffffff
+3 5 2 ffffff
+4 5 2 ffffff
+5 5 2 ffffff
+6 5 2 ffffff
+7 5 2 ffffff
+8 5 2 c400bc
+0 6 2 c400bc
+1 6 2 ffffff
+2 6 2 ffffff
+3 6 2 ffffff
+4 6 2 ffffff
+5 6 2 ffffff
+6 6 2 ffffff
+7 6 2 ffffff
+8 6 2 c400bc
+0 7 2 c400bc
+1 7 2 ffffff
+2 7 2 ffffff
+3 7 2 ffffff
+4 7 2 ffffff
+5 7 2 ffffff
+6 7 2 ffffff
+7 7 2 ffffff
+8 7 2 c400bc
+0 8 2 920088
+1 8 2 c400bc
+2 8 2 c400bc
+3 8 2 c400bc
+4 8 2 cdd300
+5 8 2 c400bc
+6 8 2 c400bc
+7 8 2 c400bc
+8 8 2 920088
+0 0 3 920088
+1 0 3 c400bc
+2 0 3 c400bc
+3 0 3 c400bc
+4 0 3 c400bc
+5 0 3 c400bc
+6 0 3 c400bc
+7 0 3 c400bc
+8 0 3 920088
+0 1 3 c400bc
+1 1 3 ffffff
+2 1 3 c400bc
+3 1 3 c400bc
+4 1 3 ffffff
+5 1 3 ffffff
+6 1 3 ffffff
+7 1 3 ffffff
+8 1 3 c400bc
+0 2 3 c400bc
+1 2 3 c400bc
+2 2 3 c400bc
+3 2 3 ffffff
+4 2 3 ffffff
+5 2 3 ffffff
+6 2 3 ffffff
+7 2 3 ffffff
+8 2 3 c400bc
+0 3 3 c400bc
+1 3 3 ffffff
+2 3 3 ffffff
+3 3 3 ffffff
+4 3 3 ffffff
+5 3 3 ffffff
+6 3 3 ffffff
+7 3 3 ffffff
+8 3 3 c400bc
+0 4 3 c400bc
+1 4 3 ffffff
+2 4 3 ffffff
+3 4 3 ffffff
+4 4 3 ffffff
+5 4 3 ffffff
+6 4 3 ffffff
+7 4 3 ffffff
+8 4 3 c400bc
+0 5 3 c400bc
+1 5 3 ffffff
+2 5 3 ffffff
+3 5 3 ffffff
+4 5 3 ffffff
+5 5 3 ffffff
+6 5 3 ffffff
+7 5 3 ffffff
+8 5 3 c400bc
+0 6 3 c400bc
+1 6 3 ffffff
+2 6 3 ffffff
+3 6 3 ffffff
+4 6 3 ffffff
+5 6 3 ffffff
+6 6 3 ffffff
+7 6 3 ffffff
+8 6 3 c400bc
+0 7 3 c400bc
+1 7 3 ffffff
+2 7 3 ffffff
+3 7 3 ffffff
+4 7 3 ffffff
+5 7 3 ffffff
+6 7 3 ffffff
+7 7 3 ffffff
+8 7 3 c400bc
+0 8 3 920088
+1 8 3 c400bc
+2 8 3 c400bc
+3 8 3 c400bc
+4 8 3 c400bc
+5 8 3 c400bc
+6 8 3 c400bc
+7 8 3 c400bc
+8 8 3 920088
+0 0 4 920088
+1 0 4 c400bc
+2 0 4 c400bc
+3 0 4 c400bc
+4 0 4 cdd300
+5 0 4 cdd300
+6 0 4 c400bc
+7 0 4 c400bc
+8 0 4 920088
+0 1 4 c400bc
+1 1 4 c400bc
+2 1 4 c400bc
+3 1 4 ffffff
+4 1 4 ffffff
+5 1 4 ffffff
+6 1 4 ffffff
+7 1 4 ffffff
+8 1 4 c400bc
+0 2 4 c400bc
+1 2 4 c400bc
+2 2 4 ffffff
+3 2 4 ffffff
+4 2 4 ffffff
+5 2 4 ffffff
+6 2 4 ffffff
+7 2 4 ffffff
+8 2 4 c400bc
+0 3 4 cdd300
+1 3 4 ffffff
+2 3 4 ffffff
+3 3 4 ffffff
+4 3 4 ffffff
+5 3 4 ffffff
+6 3 4 ffffff
+7 3 4 ffffff
+8 3 4 c400bc
+0 4 4 cdd300
+1 4 4 ffffff
+2 4 4 ffffff
+3 4 4 ffffff
+4 4 4 ffffff
+5 4 4 ffffff
+6 4 4 ffffff
+7 4 4 ffffff
+8 4 4 cdd300
+0 5 4 c400bc
+1 5 4 ffffff
+2 5 4 ffffff
+3 5 4 ffffff
+4 5 4 ffffff
+5 5 4 ffffff
+6 5 4 ffffff
+7 5 4 ffffff
+8 5 4 cdd300
+0 6 4 c400bc
+1 6 4 ffffff
+2 6 4 ffffff
+3 6 4 ffffff
+4 6 4 ffffff
+5 6 4 ffffff
+6 6 4 ffffff
+7 6 4 ffffff
+8 6 4 c400bc
+0 7 4 c400bc
+1 7 4 ffffff
+2 7 4 ffffff
+3 7 4 ffffff
+4 7 4 ffffff
+5 7 4 ffffff
+6 7 4 ffffff
+7 7 4 ffffff
+8 7 4 c400bc
+0 8 4 920088
+1 8 4 c400bc
+2 8 4 c400bc
+3 8 4 cdd300
+4 8 4 cdd300
+5 8 4 c400bc
+6 8 4 c400bc
+7 8 4 c400bc
+8 8 4 920088
+0 0 5 920088
+1 0 5 c400bc
+2 0 5 cdd300
+3 0 5 c400bc
+4 0 5 c400bc
+5 0 5 c400bc
+6 0 5 cdd300
+7 0 5 c400bc
+8 0 5 920088
+0 1 5 c400bc
+1 1 5 c400bc
+2 1 5 ffffff
+3 1 5 ffffff
+4 1 5 ffffff
+5 1 5 ffffff
+6 1 5 ffffff
+7 1 5 ffffff
+8 1 5 c400bc
+0 2 5 cdd300
+1 2 5 ffffff
+2 2 5 ffffff
+3 2 5 ffffff
+4 2 5 ffffff
+5 2 5 ffffff
+6 2 5 ffffff
+7 2 5 ffffff
+8 2 5 cdd300
+0 3 5 c400bc
+1 3 5 ffffff
+2 3 5 ffffff
+3 3 5 ffffff
+4 3 5 ffffff
+5 3 5 ffffff
+6 3 5 ffffff
+7 3 5 ffffff
+8 3 5 c400bc
+0 4 5 c400bc
+1 4 5 ffffff
+2 4 5 ffffff
+3 4 5 ffffff
+4 4 5 ffffff
+5 4 5 ffffff
+6 4 5 ffffff
+7 4 5 ffffff
+8 4 5 c400bc
+0 5 5 c400bc
+1 5 5 ffffff
+2 5 5 ffffff
+3 5 5 ffffff
+4 5 5 ffffff
+5 5 5 ffffff
+6 5 5 ffffff
+7 5 5 ffffff
+8 5 5 c400bc
+0 6 5 cdd300
+1 6 5 ffffff
+2 6 5 ffffff
+3 6 5 ffffff
+4 6 5 ffffff
+5 6 5 ffffff
+6 6 5 ffffff
+7 6 5 ffffff
+8 6 5 cdd300
+0 7 5 c400bc
+1 7 5 ffffff
+2 7 5 ffffff
+3 7 5 ffffff
+4 7 5 ffffff
+5 7 5 ffffff
+6 7 5 ffffff
+7 7 5 ffffff
+8 7 5 c400bc
+0 8 5 920088
+1 8 5 c400bc
+2 8 5 cdd300
+3 8 5 c400bc
+4 8 5 c400bc
+5 8 5 c400bc
+6 8 5 cdd300
+7 8 5 c400bc
+8 8 5 920088
+0 0 6 920088
+1 0 6 c400bc
+2 0 6 c400bc
+3 0 6 cdd300
+4 0 6 cdd300
+5 0 6 cdd300
+6 0 6 c400bc
+7 0 6 c400bc
+8 0 6 920088
+0 1 6 c400bc
+1 1 6 c400bc
+2 1 6 c400bc
+3 1 6 c400bc
+4 1 6 ffffff
+5 1 6 ffffff
+6 1 6 c400bc
+7 1 6 c400bc
+8 1 6 c400bc
+0 2 6 c400bc
+1 2 6 c400bc
+2 2 6 ffffff
+3 2 6 ffffff
+4 2 6 ffffff
+5 2 6 ffffff
+6 2 6 ffffff
+7 2 6 ffffff
+8 2 6 c400bc
+0 3 6 cdd300
+1 3 6 ffffff
+2 3 6 ffffff
+3 3 6 ffffff
+4 3 6 ffffff
+5 3 6 ffffff
+6 3 6 ffffff
+7 3 6 ffffff
+8 3 6 cdd300
+0 4 6 cdd300
+1 4 6 ffffff
+2 4 6 ffffff
+3 4 6 ffffff
+4 4 6 ffffff
+5 4 6 ffffff
+6 4 6 ffffff
+7 4 6 ffffff
+8 4 6 cdd300
+0 5 6 cdd300
+1 5 6 ffffff
+2 5 6 ffffff
+3 5 6 ffffff
+4 5 6 ffffff
+5 5 6 ffffff
+6 5 6 ffffff
+7 5 6 ffffff
+8 5 6 cdd300
+0 6 6 c400bc
+1 6 6 ffffff
+2 6 6 ffffff
+3 6 6 ffffff
+4 6 6 ffffff
+5 6 6 ffffff
+6 6 6 ffffff
+7 6 6 ffffff
+8 6 6 c400bc
+0 7 6 c400bc
+1 7 6 ffffff
+2 7 6 ffffff
+3 7 6 ffffff
+4 7 6 ffffff
+5 7 6 ffffff
+6 7 6 ffffff
+7 7 6 ffffff
+8 7 6 c400bc
+0 8 6 920088
+1 8 6 c400bc
+2 8 6 c400bc
+3 8 6 cdd300
+4 8 6 cdd300
+5 8 6 cdd300
+6 8 6 c400bc
+7 8 6 c400bc
+8 8 6 920088
+0 0 7 920088
+1 0 7 c400bc
+2 0 7 c400bc
+3 0 7 c400bc
+4 0 7 c400bc
+5 0 7 c400bc
+6 0 7 c400bc
+7 0 7 c400bc
+8 0 7 920088
+0 1 7 c400bc
+1 1 7 ffffff
+2 1 7 c400bc
+3 1 7 ffffff
+4 1 7 ffffff
+5 1 7 ffffff
+6 1 7 ffffff
+7 1 7 c400bc
+8 1 7 c400bc
+0 2 7 c400bc
+1 2 7 c400bc
+2 2 7 c400bc
+3 2 7 c400bc
+4 2 7 ffffff
+5 2 7 c400bc
+6 2 7 c400bc
+7 2 7 c400bc
+8 2 7 c400bc
+0 3 7 c400bc
+1 3 7 c400bc
+2 3 7 ffffff
+3 3 7 ffffff
+4 3 7 c400bc
+5 3 7 c400bc
+6 3 7 c400bc
+7 3 7 ffffff
+8 3 7 c400bc
+0 4 7 c400bc
+1 4 7 ffffff
+2 4 7 ffffff
+3 4 7 ffffff
+4 4 7 ffffff
+5 4 7 ffffff
+6 4 7 ffffff
+7 4 7 ffffff
+8 4 7 c400bc
+0 5 7 c400bc
+1 5 7 ffffff
+2 5 7 ffffff
+3 5 7 ffffff
+4 5 7 ffffff
+5 5 7 ffffff
+6 5 7 ffffff
+7 5 7 ffffff
+8 5 7 c400bc
+0 6 7 c400bc
+1 6 7 ffffff
+2 6 7 ffffff
+3 6 7 ffffff
+4 6 7 ffffff
+5 6 7 ffffff
+6 6 7 ffffff
+7 6 7 ffffff
+8 6 7 c400bc
+0 7 7 c400bc
+1 7 7 ffffff
+2 7 7 ffffff
+3 7 7 ffffff
+4 7 7 ffffff
+5 7 7 ffffff
+6 7 7 ffffff
+7 7 7 ffffff
+8 7 7 c400bc
+0 8 7 920088
+1 8 7 c400bc
+2 8 7 c400bc
+3 8 7 c400bc
+4 8 7 c400bc
+5 8 7 c400bc
+6 8 7 c400bc
+7 8 7 c400bc
+8 8 7 920088
+0 0 8 920088
+1 0 8 920088
+2 0 8 920088
+3 0 8 920088
+4 0 8 920088
+5 0 8 920088
+6 0 8 920088
+7 0 8 920088
+8 0 8 920088
+0 1 8 920088
+1 1 8 c400bc
+2 1 8 c400bc
+3 1 8 c400bc
+4 1 8 c400bc
+5 1 8 c400bc
+6 1 8 c400bc
+7 1 8 c400bc
+8 1 8 920088
+0 2 8 920088
+1 2 8 c400bc
+2 2 8 c400bc
+3 2 8 c400bc
+4 2 8 cdd300
+5 2 8 c400bc
+6 2 8 c400bc
+7 2 8 c400bc
+8 2 8 920088
+0 3 8 920088
+1 3 8 c400bc
+2 3 8 c400bc
+3 3 8 c400bc
+4 3 8 c400bc
+5 3 8 c400bc
+6 3 8 c400bc
+7 3 8 c400bc
+8 3 8 920088
+0 4 8 920088
+1 4 8 c400bc
+2 4 8 c400bc
+3 4 8 c400bc
+4 4 8 cdd300
+5 4 8 cdd300
+6 4 8 c400bc
+7 4 8 c400bc
+8 4 8 920088
+0 5 8 920088
+1 5 8 c400bc
+2 5 8 cdd300
+3 5 8 c400bc
+4 5 8 c400bc
+5 5 8 c400bc
+6 5 8 cdd300
+7 5 8 c400bc
+8 5 8 920088
+0 6 8 920088
+1 6 8 c400bc
+2 6 8 c400bc
+3 6 8 cdd300
+4 6 8 cdd300
+5 6 8 cdd300
+6 6 8 c400bc
+7 6 8 c400bc
+8 6 8 920088
+0 7 8 920088
+1 7 8 c400bc
+2 7 8 c400bc
+3 7 8 c400bc
+4 7 8 c400bc
+5 7 8 c400bc
+6 7 8 c400bc
+7 7 8 c400bc
+8 7 8 920088
+0 8 8 920088
+1 8 8 920088
+2 8 8 920088
+3 8 8 920088
+4 8 8 920088
+5 8 8 920088
+6 8 8 920088
+7 8 8 920088
+8 8 8 920088
--- /dev/null
+name nametag pos 0 2 0
+name neck pos 0 1.35 0
+ name head pos 0 0.225 0 scale 0.45 0.45 0.45 cube head
+ name eyes pos 0 0 +0.5
+name chest pos 0 1.0125 0 scale 0.48 0.675 0.225 cube chest
+name arm_left pos +0.36 1.35 0
+ pos 0 -0.3375 0 scale 0.24 0.675 0.225 cube arm
+ name hand pos 0 -0.585 0 scale 0.0625 0.0625 0.0625 rot 90 0 0
+name arm_right pos -0.36 1.35 0 scale -1 1 1 clockwise
+ pos 0 -0.3375 0 scale 0.24 0.675 0.225 cube arm
+ name hand pos 0 -0.585 0 scale 0.0625 0.0625 0.0625 rot 90 0 0
+name leg_left pos +0.12 0.675 0
+ pos 0 -0.3375 0 scale 0.24 0.675 0.225 cube leg
+name leg_right pos -0.12 0.675 0 scale -1 1 1 clockwise
+ pos 0 -0.3375 0 scale 0.24 0.675 0.225 cube leg
--- /dev/null
+# Goxel 0.10.6
+# One line per voxel
+# X Y Z RRGGBB
+0 -3 0 7d5435
+1 -3 0 7d5435
+2 -3 0 7d5435
+3 -3 0 7d5435
+4 -3 0 7d5435
+0 -2 0 7d5435
+1 -2 0 7d5435
+2 -2 0 7d5435
+3 -2 0 7d5435
+4 -2 0 7d5435
+0 -1 0 7d5435
+1 -1 0 7d5435
+2 -1 0 7d5435
+3 -1 0 7d5435
+4 -1 0 7d5435
+0 -3 1 7d5435
+1 -3 1 7d5435
+2 -3 1 7d5435
+3 -3 1 7d5435
+4 -3 1 7d5435
+4 -2 1 7d5435
+4 -1 1 7d5435
+0 -3 2 7d5435
+3 -3 2 7d5435
+4 -3 2 7d5435
+4 -2 2 7d5435
+4 -1 2 7d5435
+0 -3 3 7d5435
+3 -3 3 7d5435
+4 -3 3 7d5435
+4 -2 3 7d5435
+4 -1 3 7d5435
+0 -3 4 7d5435
+1 -3 4 7d5435
+2 -3 4 7d5435
+3 -3 4 7d5435
+4 -3 4 7d5435
+4 -2 4 7d5435
+4 -1 4 7d5435
+0 -4 5 503728
+1 -4 5 503728
+2 -4 5 503728
+3 -4 5 503728
+4 -4 5 503728
+5 -4 5 503728
+0 -3 5 503728
+1 -3 5 503728
+2 -3 5 503728
+3 -3 5 503728
+4 -3 5 503728
+0 -2 5 503728
+1 -2 5 503728
+2 -2 5 503728
+3 -2 5 503728
+4 -2 5 7d5435
+0 -1 5 503728
+1 -1 5 503728
+2 -1 5 503728
+3 -1 5 503728
+4 -1 5 7d5435
+0 -3 6 503728
+1 -3 6 503728
+2 -3 6 503728
+3 -3 6 503728
+4 -3 6 503728
+5 -3 6 503728
+0 -2 6 503728
+1 -2 6 503728
+2 -2 6 503728
+3 -2 6 503728
+4 -2 6 503728
+4 -1 6 7d5435
+0 -2 7 503728
+1 -2 7 503728
+2 -2 7 503728
+3 -2 7 503728
+4 -2 7 503728
+5 -2 7 503728
+0 -1 7 503728
+1 -1 7 503728
+2 -1 7 503728
+3 -1 7 503728
+4 -1 7 503728
+0 -1 8 503728
+1 -1 8 503728
+2 -1 8 503728
+3 -1 8 503728
+4 -1 8 503728
+5 -1 8 503728
+-5 -3 0 7d5435
+-4 -3 0 7d5435
+-3 -3 0 7d5435
+-2 -3 0 7d5435
+-1 -3 0 7d5435
+-5 -2 0 7d5435
+-4 -2 0 7d5435
+-3 -2 0 7d5435
+-2 -2 0 7d5435
+-1 -2 0 7d5435
+-5 -1 0 7d5435
+-4 -1 0 7d5435
+-3 -1 0 7d5435
+-2 -1 0 7d5435
+-1 -1 0 7d5435
+-5 -3 1 7d5435
+-4 -3 1 7d5435
+-3 -3 1 7d5435
+-2 -3 1 7d5435
+-1 -3 1 7d5435
+-5 -2 1 7d5435
+-5 -1 1 7d5435
+-5 -3 2 7d5435
+-4 -3 2 7d5435
+-1 -3 2 7d5435
+-5 -3 3 7d5435
+-4 -3 3 7d5435
+-1 -3 3 7d5435
+-5 -3 4 7d5435
+-4 -3 4 7d5435
+-3 -3 4 7d5435
+-2 -3 4 7d5435
+-1 -3 4 7d5435
+-5 -2 4 7d5435
+-5 -1 4 7d5435
+-6 -4 5 503728
+-5 -4 5 503728
+-4 -4 5 503728
+-3 -4 5 503728
+-2 -4 5 503728
+-1 -4 5 503728
+-5 -3 5 503728
+-4 -3 5 503728
+-3 -3 5 503728
+-2 -3 5 503728
+-1 -3 5 503728
+-5 -2 5 7d5435
+-4 -2 5 503728
+-3 -2 5 503728
+-2 -2 5 503728
+-1 -2 5 503728
+-5 -1 5 7d5435
+-4 -1 5 503728
+-3 -1 5 503728
+-2 -1 5 503728
+-1 -1 5 503728
+-6 -3 6 503728
+-5 -3 6 503728
+-4 -3 6 503728
+-3 -3 6 503728
+-2 -3 6 503728
+-1 -3 6 503728
+-5 -2 6 503728
+-4 -2 6 503728
+-3 -2 6 503728
+-2 -2 6 503728
+-1 -2 6 503728
+-5 -1 6 7d5435
+-6 -2 7 503728
+-5 -2 7 503728
+-4 -2 7 503728
+-3 -2 7 503728
+-2 -2 7 503728
+-1 -2 7 503728
+-5 -1 7 503728
+-4 -1 7 503728
+-3 -1 7 503728
+-2 -1 7 503728
+-1 -1 7 503728
+-6 -1 8 503728
+-5 -1 8 503728
+-4 -1 8 503728
+-3 -1 8 503728
+-2 -1 8 503728
+-1 -1 8 503728
+0 0 0 7d5435
+1 0 0 7d5435
+2 0 0 7d5435
+3 0 0 7d5435
+4 0 0 7d5435
+0 1 0 7d5435
+1 1 0 7d5435
+2 1 0 7d5435
+3 1 0 7d5435
+4 1 0 7d5435
+0 2 0 7d5435
+1 2 0 7d5435
+2 2 0 7d5435
+3 2 0 7d5435
+4 2 0 7d5435
+0 3 0 7d5435
+1 3 0 7d5435
+2 3 0 7d5435
+3 3 0 7d5435
+4 3 0 7d5435
+0 4 0 7d5435
+1 4 0 7d5435
+2 4 0 7d5435
+3 4 0 7d5435
+4 4 0 7d5435
+4 2 1 7d5435
+4 3 1 7d5435
+0 4 1 7d5435
+1 4 1 7d5435
+2 4 1 7d5435
+3 4 1 7d5435
+4 4 1 7d5435
+4 2 2 7d5435
+4 3 2 7d5435
+1 4 2 7d5435
+4 4 2 7d5435
+4 2 3 7d5435
+4 3 3 7d5435
+1 4 3 7d5435
+4 4 3 7d5435
+4 0 4 7d5435
+4 1 4 7d5435
+4 2 4 7d5435
+4 3 4 7d5435
+0 4 4 7d5435
+1 4 4 7d5435
+2 4 4 7d5435
+3 4 4 7d5435
+4 4 4 7d5435
+0 0 5 503728
+1 0 5 503728
+2 0 5 503728
+3 0 5 503728
+4 0 5 7d5435
+0 1 5 503728
+1 1 5 503728
+2 1 5 503728
+3 1 5 503728
+4 1 5 7d5435
+0 2 5 503728
+1 2 5 503728
+2 2 5 503728
+3 2 5 503728
+4 2 5 7d5435
+0 3 5 503728
+1 3 5 503728
+2 3 5 503728
+3 3 5 503728
+4 3 5 7d5435
+0 4 5 503728
+1 4 5 503728
+2 4 5 503728
+3 4 5 503728
+4 4 5 503728
+0 5 5 503728
+1 5 5 503728
+2 5 5 503728
+3 5 5 503728
+4 5 5 503728
+5 5 5 503728
+4 0 6 7d5435
+4 1 6 7d5435
+4 2 6 7d5435
+0 3 6 503728
+1 3 6 503728
+2 3 6 503728
+3 3 6 503728
+4 3 6 503728
+0 4 6 503728
+1 4 6 503728
+2 4 6 503728
+3 4 6 503728
+4 4 6 503728
+5 4 6 503728
+4 0 7 503728
+4 1 7 503728
+0 2 7 503728
+1 2 7 503728
+2 2 7 503728
+3 2 7 503728
+4 2 7 503728
+0 3 7 503728
+1 3 7 503728
+2 3 7 503728
+3 3 7 503728
+4 3 7 503728
+5 3 7 503728
+0 0 8 503728
+1 0 8 503728
+2 0 8 503728
+3 0 8 503728
+4 0 8 503728
+5 0 8 503728
+0 1 8 503728
+1 1 8 503728
+2 1 8 503728
+3 1 8 503728
+4 1 8 503728
+5 1 8 503728
+0 2 8 503728
+1 2 8 503728
+2 2 8 503728
+3 2 8 503728
+4 2 8 503728
+5 2 8 503728
+-5 0 0 7d5435
+-4 0 0 7d5435
+-3 0 0 7d5435
+-2 0 0 7d5435
+-1 0 0 7d5435
+-5 1 0 7d5435
+-4 1 0 7d5435
+-3 1 0 7d5435
+-2 1 0 7d5435
+-1 1 0 7d5435
+-5 2 0 7d5435
+-4 2 0 7d5435
+-3 2 0 7d5435
+-2 2 0 7d5435
+-1 2 0 7d5435
+-5 3 0 7d5435
+-4 3 0 7d5435
+-3 3 0 7d5435
+-2 3 0 7d5435
+-1 3 0 7d5435
+-5 4 0 7d5435
+-4 4 0 7d5435
+-3 4 0 7d5435
+-2 4 0 7d5435
+-1 4 0 7d5435
+-5 0 1 7d5435
+-5 1 1 7d5435
+-5 2 1 7d5435
+-5 3 1 7d5435
+-5 4 1 7d5435
+-4 4 1 7d5435
+-3 4 1 7d5435
+-2 4 1 7d5435
+-1 4 1 7d5435
+-5 1 2 7d5435
+-5 2 2 7d5435
+-5 4 2 7d5435
+-3 4 2 7d5435
+-5 1 3 7d5435
+-5 2 3 7d5435
+-5 4 3 7d5435
+-3 4 3 7d5435
+-5 0 4 7d5435
+-5 1 4 7d5435
+-5 2 4 7d5435
+-5 3 4 7d5435
+-5 4 4 7d5435
+-4 4 4 7d5435
+-3 4 4 7d5435
+-2 4 4 7d5435
+-1 4 4 7d5435
+-5 0 5 7d5435
+-4 0 5 503728
+-3 0 5 503728
+-2 0 5 503728
+-1 0 5 503728
+-5 1 5 7d5435
+-4 1 5 503728
+-3 1 5 503728
+-2 1 5 503728
+-1 1 5 503728
+-5 2 5 7d5435
+-4 2 5 503728
+-3 2 5 503728
+-2 2 5 503728
+-1 2 5 503728
+-5 3 5 7d5435
+-4 3 5 503728
+-3 3 5 503728
+-2 3 5 503728
+-1 3 5 503728
+-5 4 5 503728
+-4 4 5 503728
+-3 4 5 503728
+-2 4 5 503728
+-1 4 5 503728
+-6 5 5 503728
+-5 5 5 503728
+-4 5 5 503728
+-3 5 5 503728
+-2 5 5 503728
+-1 5 5 503728
+-5 0 6 7d5435
+-5 1 6 7d5435
+-5 2 6 7d5435
+-5 3 6 503728
+-4 3 6 503728
+-3 3 6 503728
+-2 3 6 503728
+-1 3 6 503728
+-6 4 6 503728
+-5 4 6 503728
+-4 4 6 503728
+-3 4 6 503728
+-2 4 6 503728
+-1 4 6 503728
+-5 0 7 503728
+-5 1 7 503728
+-5 2 7 503728
+-4 2 7 503728
+-3 2 7 503728
+-2 2 7 503728
+-1 2 7 503728
+-6 3 7 503728
+-5 3 7 503728
+-4 3 7 503728
+-3 3 7 503728
+-2 3 7 503728
+-1 3 7 503728
+-6 0 8 503728
+-5 0 8 503728
+-4 0 8 503728
+-3 0 8 503728
+-2 0 8 503728
+-1 0 8 503728
+-6 1 8 503728
+-5 1 8 503728
+-4 1 8 503728
+-3 1 8 503728
+-2 1 8 503728
+-1 1 8 503728
+-6 2 8 503728
+-5 2 8 503728
+-4 2 8 503728
+-3 2 8 503728
+-2 2 8 503728
+-1 2 8 503728
--- /dev/null
+in vec3 fragmentPosition;
+in vec3 fragmentTextureCoordinates;
+in float fragmentLight;
+
+out vec4 outColor;
+
+uniform vec3 fogColor;
+uniform vec3 cameraPos;
+uniform samplerCube texture0;
+
+void main()
+{
+ outColor = texture(texture0, fragmentTextureCoordinates) * vec4(vec3(fragmentLight), 1.0);
+ outColor.rgb = mix(outColor.rgb, fogColor, clamp(length(fragmentPosition - cameraPos) / VIEW_DISTANCE, 0.0, 1.0));
+
+ if (outColor.a == 0.0)
+ discard;
+}
--- /dev/null
+layout(location = 0) in vec3 vertexPosition;
+layout(location = 1) in vec3 vertexNormal;
+
+out vec3 fragmentPosition;
+out vec3 fragmentTextureCoordinates;
+out float fragmentLight;
+
+uniform mat4 model;
+uniform mat4 VP;
+uniform float daylight;
+uniform float ambientLight;
+uniform vec3 lightDir;
+uniform float depthOffset;
+
+void main()
+{
+ vec4 worldSpace = model * vec4(vertexPosition, 1.0);
+ gl_Position = VP * worldSpace;
+ if (gl_Position.z > -1.0)
+ gl_Position.z = max(-1.0, gl_Position.z - depthOffset);
+
+ fragmentPosition = worldSpace.xyz;
+ fragmentTextureCoordinates = vertexPosition;
+
+ mat3 normalMatrix = transpose(inverse(mat3(model)));
+ vec3 normal = normalize(normalMatrix * vertexNormal);
+ fragmentLight = ambientLight + 0.3 * daylight * clamp(dot(normal, normalize(lightDir)), 0.0, 1.0);
+}
--- /dev/null
+in vec3 fragmentPosition;
+in vec3 fragmentColor;
+
+out vec4 outColor;
+
+uniform vec3 fogColor;
+uniform vec3 cameraPos;
+
+void main()
+{
+ outColor = vec4(fragmentColor, 1.0);
+ outColor.rgb = mix(outColor.rgb, fogColor, clamp(length(fragmentPosition - cameraPos) / VIEW_DISTANCE, 0.0, 1.0));
+
+ if (outColor.a == 0.0)
+ discard;
+}
--- /dev/null
+layout(location = 0) in vec3 vertexPosition;
+layout(location = 1) in vec3 vertexNormal;
+layout(location = 2) in vec3 vertexColor;
+
+out vec3 fragmentPosition;
+out vec3 fragmentColor;
+
+uniform mat4 model;
+uniform mat4 VP;
+uniform float daylight;
+uniform float ambientLight;
+uniform vec3 lightDir;
+uniform float depthOffset;
+
+void main()
+{
+ vec4 worldSpace = model * vec4(vertexPosition, 1.0);
+ gl_Position = VP * worldSpace;
+ if (gl_Position.z > -1.0)
+ gl_Position.z = max(-1.0, gl_Position.z - depthOffset);
+
+ fragmentPosition = worldSpace.xyz;
+ fragmentColor = vertexColor;
+
+ mat3 normalMatrix = transpose(inverse(mat3(model)));
+ vec3 normal = normalize(normalMatrix * vertexNormal);
+ fragmentColor *= ambientLight + 0.3 * daylight * clamp(dot(normal, normalize(lightDir)), 0.0, 1.0);
+}
--- /dev/null
+out vec4 outColor;
+
+uniform vec3 color;
+
+void main()
+{
+ outColor = vec4(color, 0.1);
+}
--- /dev/null
+layout(location = 0) in vec3 vertexPosition;
+
+uniform mat4 MVP;
+
+void main()
+{
+ gl_Position = MVP * vec4(vertexPosition, 1.0);
+}
--- /dev/null
+in vec3 fragmentPosition;
+in vec2 fragmentTextureCoordinates;
+in float fragmentTextureIndex;
+in vec3 fragmentColor;
+
+out vec4 outColor;
+
+uniform vec3 fogColor;
+uniform vec3 cameraPos;
+uniform sampler2D textures[MAX_TEXTURE_UNITS];
+
+void main()
+{
+ outColor = texture(textures[int(fragmentTextureIndex + 0.5)], fragmentTextureCoordinates) * vec4(fragmentColor, 1.0);
+ outColor.rgb = mix(outColor.rgb, fogColor, clamp(length(fragmentPosition - cameraPos) / VIEW_DISTANCE, 0.0, 1.0));
+
+ if (outColor.a == 0.0)
+ discard;
+}
--- /dev/null
+layout(location = 0) in vec3 vertexPosition;
+layout(location = 1) in vec3 vertexNormal;
+layout(location = 2) in vec2 vertexTextureCoordinates;
+layout(location = 3) in float vertexTextureIndex;
+layout(location = 4) in vec3 vertexColor;
+
+out vec3 fragmentPosition;
+out vec2 fragmentTextureCoordinates;
+out float fragmentTextureIndex;
+out vec3 fragmentColor;
+
+uniform mat4 model;
+uniform mat4 VP;
+uniform float daylight;
+uniform float ambientLight;
+uniform vec3 lightDir;
+
+void main()
+{
+ vec4 worldSpace = model * vec4(vertexPosition, 1.0);
+ gl_Position = VP * worldSpace;
+
+ fragmentPosition = worldSpace.xyz;
+ fragmentTextureCoordinates = vertexTextureCoordinates;
+ fragmentTextureIndex = vertexTextureIndex;
+ fragmentColor = vertexColor;
+
+ fragmentColor *= ambientLight + 0.3 * daylight * clamp(dot(normalize(vertexNormal), normalize(lightDir)), 0.0, 1.0);
+}
--- /dev/null
+out vec4 outColor;
+
+uniform vec4 color;
+
+void main()
+{
+ outColor = color;
+}
--- /dev/null
+layout(location = 0) in vec2 vertexPosition;
+
+uniform mat4 model;
+uniform mat4 projection;
+
+void main()
+{
+ gl_Position = projection * model * vec4(vertexPosition, 0.0, 1.0);
+}
--- /dev/null
+in vec2 fragmentTextureCoordinates;
+
+out vec4 outColor;
+
+uniform sampler2D texture0;
+uniform vec4 color;
+
+void main()
+{
+ outColor = vec4(1.0, 1.0, 1.0, texture(texture0, fragmentTextureCoordinates).r) * color;
+}
--- /dev/null
+layout(location = 0) in vec2 vertexPosition;
+layout(location = 1) in vec2 vertexTextureCoordinates;
+
+out vec2 fragmentTextureCoordinates;
+
+uniform mat4 model;
+uniform mat4 projection;
+
+void main()
+{
+ gl_Position = projection * model * vec4(vertexPosition, 0.0, 1.0);
+ fragmentTextureCoordinates = vertexTextureCoordinates;
+}
--- /dev/null
+in vec2 fragmentTextureCoordinates;
+
+out vec4 outColor;
+
+uniform sampler2D texture0;
+
+void main()
+{
+ outColor = texture(texture0, fragmentTextureCoordinates);
+}
--- /dev/null
+layout(location = 0) in vec2 vertexPosition;
+layout(location = 1) in vec2 vertexTextureCoordinates;
+
+out vec2 fragmentTextureCoordinates;
+
+uniform mat4 model;
+uniform mat4 projection;
+
+void main()
+{
+ gl_Position = projection * model * vec4(vertexPosition, 0.0, 1.0);
+ fragmentTextureCoordinates = vertexTextureCoordinates;
+}
--- /dev/null
+in vec3 fragmentTextureCoordinates;
+
+out vec4 outColor;
+
+uniform float daylight;
+uniform samplerCube texture0;
+
+float reverseMix(float value, float min, float max)
+{
+ return clamp((value - min) / (max - min), 0.0, 1.0);
+}
+
+float strengthen(float value, float exponent, float max)
+{
+ return min((1.0 - pow(1.0 - value, exponent)) / (1.0 - pow(1.0 - max, exponent)), 1.0);
+}
+
+void main()
+{
+ float height = normalize(fragmentTextureCoordinates).y;
+
+ vec4 topColor = texture(texture0, vec3(0.0, 1.0, 0.0));
+ vec4 bottomColor = texture(texture0, vec3(1.0, 0.11, 0.5));
+ vec4 expectedColor = mix(bottomColor, topColor, height);
+
+ vec4 dayColor = texture(texture0, fragmentTextureCoordinates);
+
+ float cloudFactor = reverseMix(length(dayColor.rg - expectedColor.rg), 0.15, length(vec2(1.0)));
+
+ outColor = vec4(dayColor.rgb, mix(cloudFactor, strengthen(cloudFactor, 8.0, 0.1), daylight));
+}
--- /dev/null
+layout(location = 0) in vec3 vertexPosition;
+
+out vec3 fragmentTextureCoordinates;
+
+uniform mat4 VP;
+
+void main()
+{
+ gl_Position = VP * vec4(vertexPosition, 1.0);
+ gl_Position.z = gl_Position.w;
+ fragmentTextureCoordinates = vertexPosition;
+}
--- /dev/null
+in vec3 fragmentTextureCoordinates;
+
+out vec4 outColor;
+
+uniform float daylight;
+uniform samplerCube textures[2];
+
+void main()
+{
+ vec4 topColor = texture(textures[0], vec3(0.0, 1.0, 0.0));
+ vec4 bottomColor = texture(textures[0], vec3(1.0, 0.11, 0.5));
+
+ vec4 dayColor = mix(bottomColor, topColor, normalize(fragmentTextureCoordinates).y);
+ vec4 nightColor = texture(textures[1], fragmentTextureCoordinates);
+
+ outColor = mix(nightColor, dayColor, daylight);
+}
--- /dev/null
+layout(location = 0) in vec3 vertexPosition;
+
+out vec3 fragmentTextureCoordinates;
+
+uniform mat4 VP;
+
+void main()
+{
+ gl_Position = VP * vec4(vertexPosition, 1.0);
+ gl_Position.z = gl_Position.w;
+ fragmentTextureCoordinates = vertexPosition;
+}
--- /dev/null
+in vec2 fragmentTextureCoordinates;
+
+out vec4 outColor;
+
+uniform sampler2D texture0;
+
+void main()
+{
+ outColor = texture(texture0, fragmentTextureCoordinates);
+}
--- /dev/null
+layout(location = 0) in vec3 vertexPosition;
+layout(location = 1) in vec2 vertexTextureCoordinates;
+
+out vec2 fragmentTextureCoordinates;
+
+uniform mat4 MVP;
+
+void main()
+{
+ gl_Position = MVP * vec4(vertexPosition, 1.0);
+ gl_Position.z = gl_Position.w;
+ fragmentTextureCoordinates = vertexTextureCoordinates;
+}
--- /dev/null
+#!/bin/bash
+
+if ! make -j$(nproc); then
+ exit 1
+fi
+
+DEBUG_DIR=/tmp/dragonblocks_alpha_debug_$$/
+mkdir $DEBUG_DIR
+
+echo "singleplayer" > $DEBUG_DIR/name
+
+COMMON="set confirm off
+handle SIGTERM nostop print pass
+handle SIGPIPE nostop noprint pass
+set height 0
+set \$_exitcode=1
+define hook-stop
+ if \$_exitcode == 0
+ quit
+ end
+end
+"
+
+echo "$COMMON
+break gl_error
+run \"[::1]:4000\" < $DEBUG_DIR/name
+" > $DEBUG_DIR/client_script
+
+echo "$COMMON
+set print thread-events off
+run \"[::1]:4000\"
+" > $DEBUG_DIR/server_script
+
+alacritty -e bash -c "
+ echo \$\$ > $DEBUG_DIR/server_pid
+ exec gdb --command $DEBUG_DIR/server_script ./dragonblocks_server
+" &
+sleep 0.5
+
+gdb --command $DEBUG_DIR/client_script ./dragonblocks_client
+
+kill `cat $DEBUG_DIR/server_pid`
+
+rm -rf $DEBUG_DIR
--- /dev/null
+#!/bin/bash
+COMMAND="./debug.sh"
+
+if [[ $1 == "terrain" ]]; then
+ COMMAND="./debug_terrain.sh"
+fi
+
+while true; do
+ if ! $COMMAND; then
+ read
+ fi
+done
-Subproject commit 84c7e7cb1e0a6ea4102ca785cca31a3e66f34a48
+Subproject commit 305d3f995280196f4c88146b03f09b94191e8cca
-Subproject commit 9ab2148e1b8d03dab816bbba6209794663b31576
+Subproject commit 72fd472f45d9589269d7786877dff8d45586c006
-Subproject commit 7d8cdeeb49fc6fa0b4b7ac9c3bb3e1fb27f4f0bf
+Subproject commit ae5dd6c930ccef19ad313aa903f0528aa803ee80
-Subproject commit 6c7eccf05405eacbb76281550cd69895089f9773
+Subproject commit f24960eca3bb806fa72d8de2b9a761a889fdeee3
--- /dev/null
+Subproject commit d59c7ce1b970bfe38b3df161e9dd711b75392709
-Subproject commit 9d102be3fb622bcd3fab9f7feaafe2b1abf3980a
+Subproject commit 305c38b4595254706f103e0043ac2fd6e491d8ed
--- /dev/null
+Subproject commit 7c2b7514f64234756f7df051b9316f1e46f5a6e7
--- /dev/null
+Subproject commit 4cb36872a5fe448c205d0b46f0e8c8b57530cfe0
-Subproject commit 9430e6e4e7fc09e8ca6a2fd5e3fcafa07818542e
+Subproject commit 2da54ed285c5da913c9fb11e0b0410becccb8a39
-Subproject commit 78efd369ac89a1db0dee71e277bf5e74309ef9fe
+Subproject commit 2b584521c2657c8c8e8cb4a49ca80c2ffa0c3f96
-Subproject commit 2200835ac31adfa47f2baaa93f0a79a7c9a9007c
+Subproject commit f506262076d602340500786703ac384d92683e26
--- /dev/null
+Subproject commit a8200e0816fb742617347d3e1a43c35b5b2f424e
--- /dev/null
+Subproject commit c85c304ae7cb6867a732c4183c1d260f746bd73d
--- /dev/null
+Subproject commit 4b4fbf4ee10310760f763bcb674775f0325b842a
+++ /dev/null
-# Goxel 0.10.6
-# One line per voxel
-# X Y Z RRGGBB
-0 -1 9 a5a5a5
-0 -1 10 a0a0a0
-0 0 0 503612
-0 0 1 503612
-0 0 2 584120
-0 0 3 43351e
-0 0 4 503612
-0 0 5 503612
-0 0 6 4a3312
-0 0 7 5c421a
-0 3 7 a0a0a0
-0 4 7 9e9e9e
-0 0 8 5a380e
-0 2 8 9e9e9e
-0 3 8 a1a1a1
-0 4 8 a1a1a1
-0 0 9 a1a1a1
-1 0 9 a0a0a0
-0 1 9 9e9e9e
-0 2 9 9e9e9e
-0 3 9 a1a1a1
-0 4 9 9e9e9e
-0 0 10 989898
-1 0 10 a0a0a0
-0 1 10 a0a0a0
-0 2 10 9e9e9e
-0 3 10 9e9e9e
-0 4 10 9e9e9e
-0 0 11 5c421a
-0 2 11 a0a0a0
-0 3 11 9e9e9e
-0 4 11 a1a1a1
-0 3 12 9e9e9e
-0 4 12 9e9e9e
--1 0 9 a0a0a0
--1 0 10 a0a0a0
+++ /dev/null
-# Goxel 0.10.6
-# One line per voxel
-# X Y Z RRGGBB
-0 -4 7 a0a0a0
-0 -4 8 a0a0a0
-0 -3 8 999999
-0 -3 9 a0a0a0
-0 -2 9 a0a0a0
-0 -1 9 8b8b8b
-0 -2 10 a0a0a0
-0 -1 10 a9a9a9
-0 0 0 503612
-0 0 1 503612
-0 0 2 584120
-0 0 3 43351e
-0 0 4 503612
-0 0 5 503612
-0 0 6 4a3312
-0 0 7 5c421a
-0 4 7 999999
-0 0 8 5a380e
-0 3 8 999999
-0 4 8 a0a0a0
-0 0 9 a0a0a0
-0 1 9 a9a9a9
-0 2 9 a0a0a0
-0 3 9 a0a0a0
-0 0 10 a9a9a9
-0 1 10 8b8b8b
-0 2 10 a0a0a0
-0 0 11 a0a0a0
+++ /dev/null
-# Goxel 0.10.6
-# One line per voxel
-# X Y Z RRGGBB
-0 0 0 503612
-0 0 1 503612
-0 0 2 584120
-0 0 3 43351e
-0 0 4 503612
-0 0 5 503612
-0 0 6 4a3312
-0 0 7 5c421a
-0 0 8 5a380e
-0 0 9 959595
-1 0 9 a0a0a0
-0 0 10 959595
-1 0 10 959595
-0 0 11 7e7e7e
-1 0 11 a0a0a0
-0 0 12 a0a0a0
--1 0 9 7e7e7e
--1 0 10 959595
--1 0 11 959595
+++ /dev/null
-# Goxel 0.10.6
-# One line per voxel
-# X Y Z RRGGBB
-0 0 0 920088
-1 0 0 920088
-2 0 0 920088
-3 0 0 920088
-4 0 0 920088
-5 0 0 920088
-6 0 0 920088
-7 0 0 920088
-8 0 0 920088
-0 1 0 920088
-1 1 0 c400bc
-2 1 0 c400bc
-3 1 0 c400bc
-4 1 0 c400bc
-5 1 0 c400bc
-6 1 0 c400bc
-7 1 0 c400bc
-8 1 0 920088
-0 2 0 920088
-1 2 0 c400bc
-2 2 0 c400bc
-3 2 0 cdd300
-4 2 0 cdd300
-5 2 0 cdd300
-6 2 0 c400bc
-7 2 0 c400bc
-8 2 0 920088
-0 3 0 920088
-1 3 0 c400bc
-2 3 0 cdd300
-3 3 0 c400bc
-4 3 0 c400bc
-5 3 0 c400bc
-6 3 0 cdd300
-7 3 0 c400bc
-8 3 0 920088
-0 4 0 920088
-1 4 0 c400bc
-2 4 0 c400bc
-3 4 0 c400bc
-4 4 0 cdd300
-5 4 0 cdd300
-6 4 0 c400bc
-7 4 0 c400bc
-8 4 0 920088
-0 5 0 920088
-1 5 0 c400bc
-2 5 0 c400bc
-3 5 0 c400bc
-4 5 0 c400bc
-5 5 0 c400bc
-6 5 0 c400bc
-7 5 0 c400bc
-8 5 0 920088
-0 6 0 920088
-1 6 0 c400bc
-2 6 0 c400bc
-3 6 0 c400bc
-4 6 0 cdd300
-5 6 0 c400bc
-6 6 0 c400bc
-7 6 0 c400bc
-8 6 0 920088
-0 7 0 920088
-1 7 0 c400bc
-2 7 0 c400bc
-3 7 0 c400bc
-4 7 0 c400bc
-5 7 0 c400bc
-6 7 0 c400bc
-7 7 0 c400bc
-8 7 0 920088
-0 8 0 920088
-1 8 0 920088
-2 8 0 920088
-3 8 0 920088
-4 8 0 920088
-5 8 0 920088
-6 8 0 920088
-7 8 0 920088
-8 8 0 920088
-0 0 1 920088
-1 0 1 c400bc
-2 0 1 c400bc
-3 0 1 c400bc
-4 0 1 c400bc
-5 0 1 c400bc
-6 0 1 c400bc
-7 0 1 c400bc
-8 0 1 920088
-0 1 1 c400bc
-1 1 1 ffffff
-2 1 1 ffffff
-3 1 1 ffffff
-4 1 1 ffffff
-5 1 1 ffffff
-6 1 1 ffffff
-7 1 1 ffffff
-8 1 1 c400bc
-0 2 1 c400bc
-1 2 1 ffffff
-2 2 1 ffffff
-3 2 1 ffffff
-4 2 1 ffffff
-5 2 1 ffffff
-6 2 1 ffffff
-7 2 1 ffffff
-8 2 1 c400bc
-0 3 1 c400bc
-1 3 1 ffffff
-2 3 1 ffffff
-3 3 1 ffffff
-4 3 1 ffffff
-5 3 1 ffffff
-6 3 1 ffffff
-7 3 1 ffffff
-8 3 1 c400bc
-0 4 1 c400bc
-1 4 1 ffffff
-2 4 1 ffffff
-3 4 1 ffffff
-4 4 1 ffffff
-5 4 1 ffffff
-6 4 1 ffffff
-7 4 1 ffffff
-8 4 1 c400bc
-0 5 1 c400bc
-1 5 1 ffffff
-2 5 1 ffffff
-3 5 1 ffffff
-4 5 1 ffffff
-5 5 1 ffffff
-6 5 1 ffffff
-7 5 1 ffffff
-8 5 1 c400bc
-0 6 1 c400bc
-1 6 1 ffffff
-2 6 1 ffffff
-3 6 1 ffffff
-4 6 1 ffffff
-5 6 1 ffffff
-6 6 1 ffffff
-7 6 1 ffffff
-8 6 1 c400bc
-0 7 1 c400bc
-1 7 1 ffffff
-2 7 1 ffffff
-3 7 1 ffffff
-4 7 1 ffffff
-5 7 1 ffffff
-6 7 1 ffffff
-7 7 1 ffffff
-8 7 1 c400bc
-0 8 1 920088
-1 8 1 c400bc
-2 8 1 c400bc
-3 8 1 c400bc
-4 8 1 c400bc
-5 8 1 c400bc
-6 8 1 c400bc
-7 8 1 c400bc
-8 8 1 920088
-0 0 2 920088
-1 0 2 c400bc
-2 0 2 c400bc
-3 0 2 c400bc
-4 0 2 cdd300
-5 0 2 c400bc
-6 0 2 c400bc
-7 0 2 c400bc
-8 0 2 920088
-0 1 2 c400bc
-1 1 2 ffffff
-2 1 2 ffffff
-3 1 2 ffffff
-4 1 2 ffffff
-5 1 2 ffffff
-6 1 2 ffffff
-7 1 2 ffffff
-8 1 2 c400bc
-0 2 2 c400bc
-1 2 2 ffffff
-2 2 2 ffffff
-3 2 2 ffffff
-4 2 2 ffffff
-5 2 2 ffffff
-6 2 2 ffffff
-7 2 2 ffffff
-8 2 2 c400bc
-0 3 2 c400bc
-1 3 2 ffffff
-2 3 2 ffffff
-3 3 2 ffffff
-4 3 2 ffffff
-5 3 2 ffffff
-6 3 2 ffffff
-7 3 2 ffffff
-8 3 2 c400bc
-0 4 2 cdd300
-1 4 2 ffffff
-2 4 2 ffffff
-3 4 2 ffffff
-4 4 2 ffffff
-5 4 2 ffffff
-6 4 2 ffffff
-7 4 2 ffffff
-8 4 2 cdd300
-0 5 2 c400bc
-1 5 2 ffffff
-2 5 2 ffffff
-3 5 2 ffffff
-4 5 2 ffffff
-5 5 2 ffffff
-6 5 2 ffffff
-7 5 2 ffffff
-8 5 2 c400bc
-0 6 2 c400bc
-1 6 2 ffffff
-2 6 2 ffffff
-3 6 2 ffffff
-4 6 2 ffffff
-5 6 2 ffffff
-6 6 2 ffffff
-7 6 2 ffffff
-8 6 2 c400bc
-0 7 2 c400bc
-1 7 2 ffffff
-2 7 2 ffffff
-3 7 2 ffffff
-4 7 2 ffffff
-5 7 2 ffffff
-6 7 2 ffffff
-7 7 2 ffffff
-8 7 2 c400bc
-0 8 2 920088
-1 8 2 c400bc
-2 8 2 c400bc
-3 8 2 c400bc
-4 8 2 cdd300
-5 8 2 c400bc
-6 8 2 c400bc
-7 8 2 c400bc
-8 8 2 920088
-0 0 3 920088
-1 0 3 c400bc
-2 0 3 c400bc
-3 0 3 c400bc
-4 0 3 c400bc
-5 0 3 c400bc
-6 0 3 c400bc
-7 0 3 c400bc
-8 0 3 920088
-0 1 3 c400bc
-1 1 3 ffffff
-2 1 3 c400bc
-3 1 3 c400bc
-4 1 3 ffffff
-5 1 3 ffffff
-6 1 3 ffffff
-7 1 3 ffffff
-8 1 3 c400bc
-0 2 3 c400bc
-1 2 3 c400bc
-2 2 3 c400bc
-3 2 3 ffffff
-4 2 3 ffffff
-5 2 3 ffffff
-6 2 3 ffffff
-7 2 3 ffffff
-8 2 3 c400bc
-0 3 3 c400bc
-1 3 3 ffffff
-2 3 3 ffffff
-3 3 3 ffffff
-4 3 3 ffffff
-5 3 3 ffffff
-6 3 3 ffffff
-7 3 3 ffffff
-8 3 3 c400bc
-0 4 3 c400bc
-1 4 3 ffffff
-2 4 3 ffffff
-3 4 3 ffffff
-4 4 3 ffffff
-5 4 3 ffffff
-6 4 3 ffffff
-7 4 3 ffffff
-8 4 3 c400bc
-0 5 3 c400bc
-1 5 3 ffffff
-2 5 3 ffffff
-3 5 3 ffffff
-4 5 3 ffffff
-5 5 3 ffffff
-6 5 3 ffffff
-7 5 3 ffffff
-8 5 3 c400bc
-0 6 3 c400bc
-1 6 3 ffffff
-2 6 3 ffffff
-3 6 3 ffffff
-4 6 3 ffffff
-5 6 3 ffffff
-6 6 3 ffffff
-7 6 3 ffffff
-8 6 3 c400bc
-0 7 3 c400bc
-1 7 3 ffffff
-2 7 3 ffffff
-3 7 3 ffffff
-4 7 3 ffffff
-5 7 3 ffffff
-6 7 3 ffffff
-7 7 3 ffffff
-8 7 3 c400bc
-0 8 3 920088
-1 8 3 c400bc
-2 8 3 c400bc
-3 8 3 c400bc
-4 8 3 c400bc
-5 8 3 c400bc
-6 8 3 c400bc
-7 8 3 c400bc
-8 8 3 920088
-0 0 4 920088
-1 0 4 c400bc
-2 0 4 c400bc
-3 0 4 c400bc
-4 0 4 cdd300
-5 0 4 cdd300
-6 0 4 c400bc
-7 0 4 c400bc
-8 0 4 920088
-0 1 4 c400bc
-1 1 4 c400bc
-2 1 4 c400bc
-3 1 4 ffffff
-4 1 4 ffffff
-5 1 4 ffffff
-6 1 4 ffffff
-7 1 4 ffffff
-8 1 4 c400bc
-0 2 4 c400bc
-1 2 4 c400bc
-2 2 4 ffffff
-3 2 4 ffffff
-4 2 4 ffffff
-5 2 4 ffffff
-6 2 4 ffffff
-7 2 4 ffffff
-8 2 4 c400bc
-0 3 4 cdd300
-1 3 4 ffffff
-2 3 4 ffffff
-3 3 4 ffffff
-4 3 4 ffffff
-5 3 4 ffffff
-6 3 4 ffffff
-7 3 4 ffffff
-8 3 4 c400bc
-0 4 4 cdd300
-1 4 4 ffffff
-2 4 4 ffffff
-3 4 4 ffffff
-4 4 4 ffffff
-5 4 4 ffffff
-6 4 4 ffffff
-7 4 4 ffffff
-8 4 4 cdd300
-0 5 4 c400bc
-1 5 4 ffffff
-2 5 4 ffffff
-3 5 4 ffffff
-4 5 4 ffffff
-5 5 4 ffffff
-6 5 4 ffffff
-7 5 4 ffffff
-8 5 4 cdd300
-0 6 4 c400bc
-1 6 4 ffffff
-2 6 4 ffffff
-3 6 4 ffffff
-4 6 4 ffffff
-5 6 4 ffffff
-6 6 4 ffffff
-7 6 4 ffffff
-8 6 4 c400bc
-0 7 4 c400bc
-1 7 4 ffffff
-2 7 4 ffffff
-3 7 4 ffffff
-4 7 4 ffffff
-5 7 4 ffffff
-6 7 4 ffffff
-7 7 4 ffffff
-8 7 4 c400bc
-0 8 4 920088
-1 8 4 c400bc
-2 8 4 c400bc
-3 8 4 cdd300
-4 8 4 cdd300
-5 8 4 c400bc
-6 8 4 c400bc
-7 8 4 c400bc
-8 8 4 920088
-0 0 5 920088
-1 0 5 c400bc
-2 0 5 cdd300
-3 0 5 c400bc
-4 0 5 c400bc
-5 0 5 c400bc
-6 0 5 cdd300
-7 0 5 c400bc
-8 0 5 920088
-0 1 5 c400bc
-1 1 5 c400bc
-2 1 5 ffffff
-3 1 5 ffffff
-4 1 5 ffffff
-5 1 5 ffffff
-6 1 5 ffffff
-7 1 5 ffffff
-8 1 5 c400bc
-0 2 5 cdd300
-1 2 5 ffffff
-2 2 5 ffffff
-3 2 5 ffffff
-4 2 5 ffffff
-5 2 5 ffffff
-6 2 5 ffffff
-7 2 5 ffffff
-8 2 5 cdd300
-0 3 5 c400bc
-1 3 5 ffffff
-2 3 5 ffffff
-3 3 5 ffffff
-4 3 5 ffffff
-5 3 5 ffffff
-6 3 5 ffffff
-7 3 5 ffffff
-8 3 5 c400bc
-0 4 5 c400bc
-1 4 5 ffffff
-2 4 5 ffffff
-3 4 5 ffffff
-4 4 5 ffffff
-5 4 5 ffffff
-6 4 5 ffffff
-7 4 5 ffffff
-8 4 5 c400bc
-0 5 5 c400bc
-1 5 5 ffffff
-2 5 5 ffffff
-3 5 5 ffffff
-4 5 5 ffffff
-5 5 5 ffffff
-6 5 5 ffffff
-7 5 5 ffffff
-8 5 5 c400bc
-0 6 5 cdd300
-1 6 5 ffffff
-2 6 5 ffffff
-3 6 5 ffffff
-4 6 5 ffffff
-5 6 5 ffffff
-6 6 5 ffffff
-7 6 5 ffffff
-8 6 5 cdd300
-0 7 5 c400bc
-1 7 5 ffffff
-2 7 5 ffffff
-3 7 5 ffffff
-4 7 5 ffffff
-5 7 5 ffffff
-6 7 5 ffffff
-7 7 5 ffffff
-8 7 5 c400bc
-0 8 5 920088
-1 8 5 c400bc
-2 8 5 cdd300
-3 8 5 c400bc
-4 8 5 c400bc
-5 8 5 c400bc
-6 8 5 cdd300
-7 8 5 c400bc
-8 8 5 920088
-0 0 6 920088
-1 0 6 c400bc
-2 0 6 c400bc
-3 0 6 cdd300
-4 0 6 cdd300
-5 0 6 cdd300
-6 0 6 c400bc
-7 0 6 c400bc
-8 0 6 920088
-0 1 6 c400bc
-1 1 6 c400bc
-2 1 6 c400bc
-3 1 6 c400bc
-4 1 6 ffffff
-5 1 6 ffffff
-6 1 6 c400bc
-7 1 6 c400bc
-8 1 6 c400bc
-0 2 6 c400bc
-1 2 6 c400bc
-2 2 6 ffffff
-3 2 6 ffffff
-4 2 6 ffffff
-5 2 6 ffffff
-6 2 6 ffffff
-7 2 6 ffffff
-8 2 6 c400bc
-0 3 6 cdd300
-1 3 6 ffffff
-2 3 6 ffffff
-3 3 6 ffffff
-4 3 6 ffffff
-5 3 6 ffffff
-6 3 6 ffffff
-7 3 6 ffffff
-8 3 6 cdd300
-0 4 6 cdd300
-1 4 6 ffffff
-2 4 6 ffffff
-3 4 6 ffffff
-4 4 6 ffffff
-5 4 6 ffffff
-6 4 6 ffffff
-7 4 6 ffffff
-8 4 6 cdd300
-0 5 6 cdd300
-1 5 6 ffffff
-2 5 6 ffffff
-3 5 6 ffffff
-4 5 6 ffffff
-5 5 6 ffffff
-6 5 6 ffffff
-7 5 6 ffffff
-8 5 6 cdd300
-0 6 6 c400bc
-1 6 6 ffffff
-2 6 6 ffffff
-3 6 6 ffffff
-4 6 6 ffffff
-5 6 6 ffffff
-6 6 6 ffffff
-7 6 6 ffffff
-8 6 6 c400bc
-0 7 6 c400bc
-1 7 6 ffffff
-2 7 6 ffffff
-3 7 6 ffffff
-4 7 6 ffffff
-5 7 6 ffffff
-6 7 6 ffffff
-7 7 6 ffffff
-8 7 6 c400bc
-0 8 6 920088
-1 8 6 c400bc
-2 8 6 c400bc
-3 8 6 cdd300
-4 8 6 cdd300
-5 8 6 cdd300
-6 8 6 c400bc
-7 8 6 c400bc
-8 8 6 920088
-0 0 7 920088
-1 0 7 c400bc
-2 0 7 c400bc
-3 0 7 c400bc
-4 0 7 c400bc
-5 0 7 c400bc
-6 0 7 c400bc
-7 0 7 c400bc
-8 0 7 920088
-0 1 7 c400bc
-1 1 7 ffffff
-2 1 7 c400bc
-3 1 7 ffffff
-4 1 7 ffffff
-5 1 7 ffffff
-6 1 7 ffffff
-7 1 7 c400bc
-8 1 7 c400bc
-0 2 7 c400bc
-1 2 7 c400bc
-2 2 7 c400bc
-3 2 7 c400bc
-4 2 7 ffffff
-5 2 7 c400bc
-6 2 7 c400bc
-7 2 7 c400bc
-8 2 7 c400bc
-0 3 7 c400bc
-1 3 7 c400bc
-2 3 7 ffffff
-3 3 7 ffffff
-4 3 7 c400bc
-5 3 7 c400bc
-6 3 7 c400bc
-7 3 7 ffffff
-8 3 7 c400bc
-0 4 7 c400bc
-1 4 7 ffffff
-2 4 7 ffffff
-3 4 7 ffffff
-4 4 7 ffffff
-5 4 7 ffffff
-6 4 7 ffffff
-7 4 7 ffffff
-8 4 7 c400bc
-0 5 7 c400bc
-1 5 7 ffffff
-2 5 7 ffffff
-3 5 7 ffffff
-4 5 7 ffffff
-5 5 7 ffffff
-6 5 7 ffffff
-7 5 7 ffffff
-8 5 7 c400bc
-0 6 7 c400bc
-1 6 7 ffffff
-2 6 7 ffffff
-3 6 7 ffffff
-4 6 7 ffffff
-5 6 7 ffffff
-6 6 7 ffffff
-7 6 7 ffffff
-8 6 7 c400bc
-0 7 7 c400bc
-1 7 7 ffffff
-2 7 7 ffffff
-3 7 7 ffffff
-4 7 7 ffffff
-5 7 7 ffffff
-6 7 7 ffffff
-7 7 7 ffffff
-8 7 7 c400bc
-0 8 7 920088
-1 8 7 c400bc
-2 8 7 c400bc
-3 8 7 c400bc
-4 8 7 c400bc
-5 8 7 c400bc
-6 8 7 c400bc
-7 8 7 c400bc
-8 8 7 920088
-0 0 8 920088
-1 0 8 920088
-2 0 8 920088
-3 0 8 920088
-4 0 8 920088
-5 0 8 920088
-6 0 8 920088
-7 0 8 920088
-8 0 8 920088
-0 1 8 920088
-1 1 8 c400bc
-2 1 8 c400bc
-3 1 8 c400bc
-4 1 8 c400bc
-5 1 8 c400bc
-6 1 8 c400bc
-7 1 8 c400bc
-8 1 8 920088
-0 2 8 920088
-1 2 8 c400bc
-2 2 8 c400bc
-3 2 8 c400bc
-4 2 8 cdd300
-5 2 8 c400bc
-6 2 8 c400bc
-7 2 8 c400bc
-8 2 8 920088
-0 3 8 920088
-1 3 8 c400bc
-2 3 8 c400bc
-3 3 8 c400bc
-4 3 8 c400bc
-5 3 8 c400bc
-6 3 8 c400bc
-7 3 8 c400bc
-8 3 8 920088
-0 4 8 920088
-1 4 8 c400bc
-2 4 8 c400bc
-3 4 8 c400bc
-4 4 8 cdd300
-5 4 8 cdd300
-6 4 8 c400bc
-7 4 8 c400bc
-8 4 8 920088
-0 5 8 920088
-1 5 8 c400bc
-2 5 8 cdd300
-3 5 8 c400bc
-4 5 8 c400bc
-5 5 8 c400bc
-6 5 8 cdd300
-7 5 8 c400bc
-8 5 8 920088
-0 6 8 920088
-1 6 8 c400bc
-2 6 8 c400bc
-3 6 8 cdd300
-4 6 8 cdd300
-5 6 8 cdd300
-6 6 8 c400bc
-7 6 8 c400bc
-8 6 8 920088
-0 7 8 920088
-1 7 8 c400bc
-2 7 8 c400bc
-3 7 8 c400bc
-4 7 8 c400bc
-5 7 8 c400bc
-6 7 8 c400bc
-7 7 8 c400bc
-8 7 8 920088
-0 8 8 920088
-1 8 8 920088
-2 8 8 920088
-3 8 8 920088
-4 8 8 920088
-5 8 8 920088
-6 8 8 920088
-7 8 8 920088
-8 8 8 920088
+++ /dev/null
-name nametag pos 0 2 0
-name neck pos 0 1.35 0
- name head pos 0 0.225 0 scale 0.45 0.45 0.45 cube head
- name eyes pos 0 0 +0.5
-name chest pos 0 1.0125 0 scale 0.48 0.675 0.225 cube chest
-name arm_left pos +0.36 1.35 0
- pos 0 -0.3375 0 scale 0.24 0.675 0.225 cube arm
- name hand pos 0 -0.585 0 scale 0.0625 0.0625 0.0625 rot 90 0 0
-name arm_right pos -0.36 1.35 0 scale -1 1 1 clockwise
- pos 0 -0.3375 0 scale 0.24 0.675 0.225 cube arm
- name hand pos 0 -0.585 0 scale 0.0625 0.0625 0.0625 rot 90 0 0
-name leg_left pos +0.12 0.675 0
- pos 0 -0.3375 0 scale 0.24 0.675 0.225 cube leg
-name leg_right pos -0.12 0.675 0 scale -1 1 1 clockwise
- pos 0 -0.3375 0 scale 0.24 0.675 0.225 cube leg
+++ /dev/null
-# Goxel 0.10.6
-# One line per voxel
-# X Y Z RRGGBB
-0 -3 0 7d5435
-1 -3 0 7d5435
-2 -3 0 7d5435
-3 -3 0 7d5435
-4 -3 0 7d5435
-0 -2 0 7d5435
-1 -2 0 7d5435
-2 -2 0 7d5435
-3 -2 0 7d5435
-4 -2 0 7d5435
-0 -1 0 7d5435
-1 -1 0 7d5435
-2 -1 0 7d5435
-3 -1 0 7d5435
-4 -1 0 7d5435
-0 -3 1 7d5435
-1 -3 1 7d5435
-2 -3 1 7d5435
-3 -3 1 7d5435
-4 -3 1 7d5435
-4 -2 1 7d5435
-4 -1 1 7d5435
-0 -3 2 7d5435
-3 -3 2 7d5435
-4 -3 2 7d5435
-4 -2 2 7d5435
-4 -1 2 7d5435
-0 -3 3 7d5435
-3 -3 3 7d5435
-4 -3 3 7d5435
-4 -2 3 7d5435
-4 -1 3 7d5435
-0 -3 4 7d5435
-1 -3 4 7d5435
-2 -3 4 7d5435
-3 -3 4 7d5435
-4 -3 4 7d5435
-4 -2 4 7d5435
-4 -1 4 7d5435
-0 -4 5 503728
-1 -4 5 503728
-2 -4 5 503728
-3 -4 5 503728
-4 -4 5 503728
-5 -4 5 503728
-0 -3 5 503728
-1 -3 5 503728
-2 -3 5 503728
-3 -3 5 503728
-4 -3 5 503728
-0 -2 5 503728
-1 -2 5 503728
-2 -2 5 503728
-3 -2 5 503728
-4 -2 5 7d5435
-0 -1 5 503728
-1 -1 5 503728
-2 -1 5 503728
-3 -1 5 503728
-4 -1 5 7d5435
-0 -3 6 503728
-1 -3 6 503728
-2 -3 6 503728
-3 -3 6 503728
-4 -3 6 503728
-5 -3 6 503728
-0 -2 6 503728
-1 -2 6 503728
-2 -2 6 503728
-3 -2 6 503728
-4 -2 6 503728
-4 -1 6 7d5435
-0 -2 7 503728
-1 -2 7 503728
-2 -2 7 503728
-3 -2 7 503728
-4 -2 7 503728
-5 -2 7 503728
-0 -1 7 503728
-1 -1 7 503728
-2 -1 7 503728
-3 -1 7 503728
-4 -1 7 503728
-0 -1 8 503728
-1 -1 8 503728
-2 -1 8 503728
-3 -1 8 503728
-4 -1 8 503728
-5 -1 8 503728
--5 -3 0 7d5435
--4 -3 0 7d5435
--3 -3 0 7d5435
--2 -3 0 7d5435
--1 -3 0 7d5435
--5 -2 0 7d5435
--4 -2 0 7d5435
--3 -2 0 7d5435
--2 -2 0 7d5435
--1 -2 0 7d5435
--5 -1 0 7d5435
--4 -1 0 7d5435
--3 -1 0 7d5435
--2 -1 0 7d5435
--1 -1 0 7d5435
--5 -3 1 7d5435
--4 -3 1 7d5435
--3 -3 1 7d5435
--2 -3 1 7d5435
--1 -3 1 7d5435
--5 -2 1 7d5435
--5 -1 1 7d5435
--5 -3 2 7d5435
--4 -3 2 7d5435
--1 -3 2 7d5435
--5 -3 3 7d5435
--4 -3 3 7d5435
--1 -3 3 7d5435
--5 -3 4 7d5435
--4 -3 4 7d5435
--3 -3 4 7d5435
--2 -3 4 7d5435
--1 -3 4 7d5435
--5 -2 4 7d5435
--5 -1 4 7d5435
--6 -4 5 503728
--5 -4 5 503728
--4 -4 5 503728
--3 -4 5 503728
--2 -4 5 503728
--1 -4 5 503728
--5 -3 5 503728
--4 -3 5 503728
--3 -3 5 503728
--2 -3 5 503728
--1 -3 5 503728
--5 -2 5 7d5435
--4 -2 5 503728
--3 -2 5 503728
--2 -2 5 503728
--1 -2 5 503728
--5 -1 5 7d5435
--4 -1 5 503728
--3 -1 5 503728
--2 -1 5 503728
--1 -1 5 503728
--6 -3 6 503728
--5 -3 6 503728
--4 -3 6 503728
--3 -3 6 503728
--2 -3 6 503728
--1 -3 6 503728
--5 -2 6 503728
--4 -2 6 503728
--3 -2 6 503728
--2 -2 6 503728
--1 -2 6 503728
--5 -1 6 7d5435
--6 -2 7 503728
--5 -2 7 503728
--4 -2 7 503728
--3 -2 7 503728
--2 -2 7 503728
--1 -2 7 503728
--5 -1 7 503728
--4 -1 7 503728
--3 -1 7 503728
--2 -1 7 503728
--1 -1 7 503728
--6 -1 8 503728
--5 -1 8 503728
--4 -1 8 503728
--3 -1 8 503728
--2 -1 8 503728
--1 -1 8 503728
-0 0 0 7d5435
-1 0 0 7d5435
-2 0 0 7d5435
-3 0 0 7d5435
-4 0 0 7d5435
-0 1 0 7d5435
-1 1 0 7d5435
-2 1 0 7d5435
-3 1 0 7d5435
-4 1 0 7d5435
-0 2 0 7d5435
-1 2 0 7d5435
-2 2 0 7d5435
-3 2 0 7d5435
-4 2 0 7d5435
-0 3 0 7d5435
-1 3 0 7d5435
-2 3 0 7d5435
-3 3 0 7d5435
-4 3 0 7d5435
-0 4 0 7d5435
-1 4 0 7d5435
-2 4 0 7d5435
-3 4 0 7d5435
-4 4 0 7d5435
-4 2 1 7d5435
-4 3 1 7d5435
-0 4 1 7d5435
-1 4 1 7d5435
-2 4 1 7d5435
-3 4 1 7d5435
-4 4 1 7d5435
-4 2 2 7d5435
-4 3 2 7d5435
-1 4 2 7d5435
-4 4 2 7d5435
-4 2 3 7d5435
-4 3 3 7d5435
-1 4 3 7d5435
-4 4 3 7d5435
-4 0 4 7d5435
-4 1 4 7d5435
-4 2 4 7d5435
-4 3 4 7d5435
-0 4 4 7d5435
-1 4 4 7d5435
-2 4 4 7d5435
-3 4 4 7d5435
-4 4 4 7d5435
-0 0 5 503728
-1 0 5 503728
-2 0 5 503728
-3 0 5 503728
-4 0 5 7d5435
-0 1 5 503728
-1 1 5 503728
-2 1 5 503728
-3 1 5 503728
-4 1 5 7d5435
-0 2 5 503728
-1 2 5 503728
-2 2 5 503728
-3 2 5 503728
-4 2 5 7d5435
-0 3 5 503728
-1 3 5 503728
-2 3 5 503728
-3 3 5 503728
-4 3 5 7d5435
-0 4 5 503728
-1 4 5 503728
-2 4 5 503728
-3 4 5 503728
-4 4 5 503728
-0 5 5 503728
-1 5 5 503728
-2 5 5 503728
-3 5 5 503728
-4 5 5 503728
-5 5 5 503728
-4 0 6 7d5435
-4 1 6 7d5435
-4 2 6 7d5435
-0 3 6 503728
-1 3 6 503728
-2 3 6 503728
-3 3 6 503728
-4 3 6 503728
-0 4 6 503728
-1 4 6 503728
-2 4 6 503728
-3 4 6 503728
-4 4 6 503728
-5 4 6 503728
-4 0 7 503728
-4 1 7 503728
-0 2 7 503728
-1 2 7 503728
-2 2 7 503728
-3 2 7 503728
-4 2 7 503728
-0 3 7 503728
-1 3 7 503728
-2 3 7 503728
-3 3 7 503728
-4 3 7 503728
-5 3 7 503728
-0 0 8 503728
-1 0 8 503728
-2 0 8 503728
-3 0 8 503728
-4 0 8 503728
-5 0 8 503728
-0 1 8 503728
-1 1 8 503728
-2 1 8 503728
-3 1 8 503728
-4 1 8 503728
-5 1 8 503728
-0 2 8 503728
-1 2 8 503728
-2 2 8 503728
-3 2 8 503728
-4 2 8 503728
-5 2 8 503728
--5 0 0 7d5435
--4 0 0 7d5435
--3 0 0 7d5435
--2 0 0 7d5435
--1 0 0 7d5435
--5 1 0 7d5435
--4 1 0 7d5435
--3 1 0 7d5435
--2 1 0 7d5435
--1 1 0 7d5435
--5 2 0 7d5435
--4 2 0 7d5435
--3 2 0 7d5435
--2 2 0 7d5435
--1 2 0 7d5435
--5 3 0 7d5435
--4 3 0 7d5435
--3 3 0 7d5435
--2 3 0 7d5435
--1 3 0 7d5435
--5 4 0 7d5435
--4 4 0 7d5435
--3 4 0 7d5435
--2 4 0 7d5435
--1 4 0 7d5435
--5 0 1 7d5435
--5 1 1 7d5435
--5 2 1 7d5435
--5 3 1 7d5435
--5 4 1 7d5435
--4 4 1 7d5435
--3 4 1 7d5435
--2 4 1 7d5435
--1 4 1 7d5435
--5 1 2 7d5435
--5 2 2 7d5435
--5 4 2 7d5435
--3 4 2 7d5435
--5 1 3 7d5435
--5 2 3 7d5435
--5 4 3 7d5435
--3 4 3 7d5435
--5 0 4 7d5435
--5 1 4 7d5435
--5 2 4 7d5435
--5 3 4 7d5435
--5 4 4 7d5435
--4 4 4 7d5435
--3 4 4 7d5435
--2 4 4 7d5435
--1 4 4 7d5435
--5 0 5 7d5435
--4 0 5 503728
--3 0 5 503728
--2 0 5 503728
--1 0 5 503728
--5 1 5 7d5435
--4 1 5 503728
--3 1 5 503728
--2 1 5 503728
--1 1 5 503728
--5 2 5 7d5435
--4 2 5 503728
--3 2 5 503728
--2 2 5 503728
--1 2 5 503728
--5 3 5 7d5435
--4 3 5 503728
--3 3 5 503728
--2 3 5 503728
--1 3 5 503728
--5 4 5 503728
--4 4 5 503728
--3 4 5 503728
--2 4 5 503728
--1 4 5 503728
--6 5 5 503728
--5 5 5 503728
--4 5 5 503728
--3 5 5 503728
--2 5 5 503728
--1 5 5 503728
--5 0 6 7d5435
--5 1 6 7d5435
--5 2 6 7d5435
--5 3 6 503728
--4 3 6 503728
--3 3 6 503728
--2 3 6 503728
--1 3 6 503728
--6 4 6 503728
--5 4 6 503728
--4 4 6 503728
--3 4 6 503728
--2 4 6 503728
--1 4 6 503728
--5 0 7 503728
--5 1 7 503728
--5 2 7 503728
--4 2 7 503728
--3 2 7 503728
--2 2 7 503728
--1 2 7 503728
--6 3 7 503728
--5 3 7 503728
--4 3 7 503728
--3 3 7 503728
--2 3 7 503728
--1 3 7 503728
--6 0 8 503728
--5 0 8 503728
--4 0 8 503728
--3 0 8 503728
--2 0 8 503728
--1 0 8 503728
--6 1 8 503728
--5 1 8 503728
--4 1 8 503728
--3 1 8 503728
--2 1 8 503728
--1 1 8 503728
--6 2 8 503728
--5 2 8 503728
--4 2 8 503728
--3 2 8 503728
--2 2 8 503728
--1 2 8 503728
+++ /dev/null
-in vec3 fragmentPosition;
-in vec3 fragmentTextureCoordinates;
-in float fragmentLight;
-
-out vec4 outColor;
-
-uniform vec3 fogColor;
-uniform vec3 cameraPos;
-uniform samplerCube texture0;
-
-void main()
-{
- outColor = texture(texture0, fragmentTextureCoordinates) * vec4(vec3(fragmentLight), 1.0);
- outColor.rgb = mix(outColor.rgb, fogColor, clamp(length(fragmentPosition - cameraPos) / VIEW_DISTANCE, 0.0, 1.0));
-
- if (outColor.a == 0.0)
- discard;
-}
+++ /dev/null
-layout(location = 0) in vec3 vertexPosition;
-layout(location = 1) in vec3 vertexNormal;
-
-out vec3 fragmentPosition;
-out vec3 fragmentTextureCoordinates;
-out float fragmentLight;
-
-uniform mat4 model;
-uniform mat4 VP;
-uniform float daylight;
-uniform float ambientLight;
-uniform vec3 lightDir;
-uniform float depthOffset;
-
-void main()
-{
- vec4 worldSpace = model * vec4(vertexPosition, 1.0);
- gl_Position = VP * worldSpace;
- if (gl_Position.z > -1.0)
- gl_Position.z = max(-1.0, gl_Position.z - depthOffset);
-
- fragmentPosition = worldSpace.xyz;
- fragmentTextureCoordinates = vertexPosition;
-
- mat3 normalMatrix = transpose(inverse(mat3(model)));
- vec3 normal = normalize(normalMatrix * vertexNormal);
- fragmentLight = ambientLight + 0.3 * daylight * clamp(dot(normal, normalize(lightDir)), 0.0, 1.0);
-}
+++ /dev/null
-in vec3 fragmentPosition;
-in vec3 fragmentColor;
-
-out vec4 outColor;
-
-uniform vec3 fogColor;
-uniform vec3 cameraPos;
-
-void main()
-{
- outColor = vec4(fragmentColor, 1.0);
- outColor.rgb = mix(outColor.rgb, fogColor, clamp(length(fragmentPosition - cameraPos) / VIEW_DISTANCE, 0.0, 1.0));
-
- if (outColor.a == 0.0)
- discard;
-}
+++ /dev/null
-layout(location = 0) in vec3 vertexPosition;
-layout(location = 1) in vec3 vertexNormal;
-layout(location = 2) in vec3 vertexColor;
-
-out vec3 fragmentPosition;
-out vec3 fragmentColor;
-
-uniform mat4 model;
-uniform mat4 VP;
-uniform float daylight;
-uniform float ambientLight;
-uniform vec3 lightDir;
-uniform float depthOffset;
-
-void main()
-{
- vec4 worldSpace = model * vec4(vertexPosition, 1.0);
- gl_Position = VP * worldSpace;
- if (gl_Position.z > -1.0)
- gl_Position.z = max(-1.0, gl_Position.z - depthOffset);
-
- fragmentPosition = worldSpace.xyz;
- fragmentColor = vertexColor;
-
- mat3 normalMatrix = transpose(inverse(mat3(model)));
- vec3 normal = normalize(normalMatrix * vertexNormal);
- fragmentColor *= ambientLight + 0.3 * daylight * clamp(dot(normal, normalize(lightDir)), 0.0, 1.0);
-}
+++ /dev/null
-out vec4 outColor;
-
-uniform vec3 color;
-
-void main()
-{
- outColor = vec4(color, 0.1);
-}
+++ /dev/null
-layout(location = 0) in vec3 vertexPosition;
-
-uniform mat4 MVP;
-
-void main()
-{
- gl_Position = MVP * vec4(vertexPosition, 1.0);
-}
+++ /dev/null
-in vec3 fragmentPosition;
-in vec2 fragmentTextureCoordinates;
-in float fragmentTextureIndex;
-in vec3 fragmentColor;
-
-out vec4 outColor;
-
-uniform vec3 fogColor;
-uniform vec3 cameraPos;
-uniform sampler2D textures[MAX_TEXTURE_UNITS];
-
-void main()
-{
- outColor = texture(textures[int(fragmentTextureIndex + 0.5)], fragmentTextureCoordinates) * vec4(fragmentColor, 1.0);
- outColor.rgb = mix(outColor.rgb, fogColor, clamp(length(fragmentPosition - cameraPos) / VIEW_DISTANCE, 0.0, 1.0));
-
- if (outColor.a == 0.0)
- discard;
-}
+++ /dev/null
-layout(location = 0) in vec3 vertexPosition;
-layout(location = 1) in vec3 vertexNormal;
-layout(location = 2) in vec2 vertexTextureCoordinates;
-layout(location = 3) in float vertexTextureIndex;
-layout(location = 4) in vec3 vertexColor;
-
-out vec3 fragmentPosition;
-out vec2 fragmentTextureCoordinates;
-out float fragmentTextureIndex;
-out vec3 fragmentColor;
-
-uniform mat4 model;
-uniform mat4 VP;
-uniform float daylight;
-uniform float ambientLight;
-uniform vec3 lightDir;
-
-void main()
-{
- vec4 worldSpace = model * vec4(vertexPosition, 1.0);
- gl_Position = VP * worldSpace;
-
- fragmentPosition = worldSpace.xyz;
- fragmentTextureCoordinates = vertexTextureCoordinates;
- fragmentTextureIndex = vertexTextureIndex;
- fragmentColor = vertexColor;
-
- fragmentColor *= ambientLight + 0.3 * daylight * clamp(dot(normalize(vertexNormal), normalize(lightDir)), 0.0, 1.0);
-}
+++ /dev/null
-out vec4 outColor;
-
-uniform vec4 color;
-
-void main()
-{
- outColor = color;
-}
+++ /dev/null
-layout(location = 0) in vec2 vertexPosition;
-
-uniform mat4 model;
-uniform mat4 projection;
-
-void main()
-{
- gl_Position = projection * model * vec4(vertexPosition, 0.0, 1.0);
-}
+++ /dev/null
-in vec2 fragmentTextureCoordinates;
-
-out vec4 outColor;
-
-uniform sampler2D texture0;
-uniform vec4 color;
-
-void main()
-{
- outColor = vec4(1.0, 1.0, 1.0, texture(texture0, fragmentTextureCoordinates).r) * color;
-}
+++ /dev/null
-layout(location = 0) in vec2 vertexPosition;
-layout(location = 1) in vec2 vertexTextureCoordinates;
-
-out vec2 fragmentTextureCoordinates;
-
-uniform mat4 model;
-uniform mat4 projection;
-
-void main()
-{
- gl_Position = projection * model * vec4(vertexPosition, 0.0, 1.0);
- fragmentTextureCoordinates = vertexTextureCoordinates;
-}
+++ /dev/null
-in vec2 fragmentTextureCoordinates;
-
-out vec4 outColor;
-
-uniform sampler2D texture0;
-
-void main()
-{
- outColor = texture(texture0, fragmentTextureCoordinates);
-}
+++ /dev/null
-layout(location = 0) in vec2 vertexPosition;
-layout(location = 1) in vec2 vertexTextureCoordinates;
-
-out vec2 fragmentTextureCoordinates;
-
-uniform mat4 model;
-uniform mat4 projection;
-
-void main()
-{
- gl_Position = projection * model * vec4(vertexPosition, 0.0, 1.0);
- fragmentTextureCoordinates = vertexTextureCoordinates;
-}
+++ /dev/null
-in vec3 fragmentTextureCoordinates;
-
-out vec4 outColor;
-
-uniform float daylight;
-uniform samplerCube texture0;
-
-float reverseMix(float value, float min, float max)
-{
- return clamp((value - min) / (max - min), 0.0, 1.0);
-}
-
-float strengthen(float value, float exponent, float max)
-{
- return min((1.0 - pow(1.0 - value, exponent)) / (1.0 - pow(1.0 - max, exponent)), 1.0);
-}
-
-void main()
-{
- float height = normalize(fragmentTextureCoordinates).y;
-
- vec4 topColor = texture(texture0, vec3(0.0, 1.0, 0.0));
- vec4 bottomColor = texture(texture0, vec3(1.0, 0.11, 0.5));
- vec4 expectedColor = mix(bottomColor, topColor, height);
-
- vec4 dayColor = texture(texture0, fragmentTextureCoordinates);
-
- float cloudFactor = reverseMix(length(dayColor.rg - expectedColor.rg), 0.15, length(vec2(1.0)));
-
- outColor = vec4(dayColor.rgb, mix(cloudFactor, strengthen(cloudFactor, 8.0, 0.1), daylight));
-}
+++ /dev/null
-layout(location = 0) in vec3 vertexPosition;
-
-out vec3 fragmentTextureCoordinates;
-
-uniform mat4 VP;
-
-void main()
-{
- gl_Position = VP * vec4(vertexPosition, 1.0);
- gl_Position.z = gl_Position.w;
- fragmentTextureCoordinates = vertexPosition;
-}
+++ /dev/null
-in vec3 fragmentTextureCoordinates;
-
-out vec4 outColor;
-
-uniform float daylight;
-uniform samplerCube textures[2];
-
-void main()
-{
- vec4 topColor = texture(textures[0], vec3(0.0, 1.0, 0.0));
- vec4 bottomColor = texture(textures[0], vec3(1.0, 0.11, 0.5));
-
- vec4 dayColor = mix(bottomColor, topColor, normalize(fragmentTextureCoordinates).y);
- vec4 nightColor = texture(textures[1], fragmentTextureCoordinates);
-
- outColor = mix(nightColor, dayColor, daylight);
-}
+++ /dev/null
-layout(location = 0) in vec3 vertexPosition;
-
-out vec3 fragmentTextureCoordinates;
-
-uniform mat4 VP;
-
-void main()
-{
- gl_Position = VP * vec4(vertexPosition, 1.0);
- gl_Position.z = gl_Position.w;
- fragmentTextureCoordinates = vertexPosition;
-}
+++ /dev/null
-in vec2 fragmentTextureCoordinates;
-
-out vec4 outColor;
-
-uniform sampler2D texture0;
-
-void main()
-{
- outColor = texture(texture0, fragmentTextureCoordinates);
-}
+++ /dev/null
-layout(location = 0) in vec3 vertexPosition;
-layout(location = 1) in vec2 vertexTextureCoordinates;
-
-out vec2 fragmentTextureCoordinates;
-
-uniform mat4 MVP;
-
-void main()
-{
- gl_Position = MVP * vec4(vertexPosition, 1.0);
- gl_Position.z = gl_Position.w;
- fragmentTextureCoordinates = vertexTextureCoordinates;
-}
--- /dev/null
+@echo off
+start "Internal Server" dragonblocks_server.exe "[::1]:4000"
+echo "singleplayer" | dragonblocks_client.exe "[::1]:4000"
+taskkill /FI "Internal Server" /T /F
+
#!/bin/bash
./dragonblocks_server "[::1]:4000" &
-echo "singleplayer" | ./dragonblocks "[::1]:4000"
-pkill -P $$ -9
+echo "singleplayer" | ./dragonblocks_client "[::1]:4000"
+pkill -P $$
#!/bin/bash
+set -e
+
VERSION=`git tag --points-at HEAD`
if [[ $VERSION = "" ]]; then
VERSION=`git rev-parse --short HEAD`
fi
-DIR=dragonblocks_alpha-$VERSION
-mkdir .build
-cp -r * .build/
-cd .build/
-mkdir build
-cd build
-if ! (cmake -B . -S ../src -DCMAKE_BUILD_TYPE=Release -DRESSOURCE_PATH="\"\"" -DCMAKE_C_FLAGS="-Ofast" && make clean && make -j$(nproc)); then
- cd ../..
- rm -rf .build
- exit 1
+
+BUILD=build-release
+SNAPSHOT=dragonblocks_alpha-$VERSION
+TOOLCHAIN=
+DOTEXE=
+DOTSH=".sh"
+if [[ "$1" == "mingw" ]]; then
+ BUILD=build-mingw
+ SNAPSHOT=dragonblocks_alpha-win64-$VERSION
+ TOOLCHAIN=mingw.cmake
+ DOTEXE=".exe"
+ DOTSH=".bat"
fi
-cp dragonblocks dragonblocks_server ..
-cd ..
-rm -rf .git* deps src build BUILDING.md snapshot.sh upload.sh dragonblocks_alpha-* screenshot-*.png
-cd ..
-mv .build $DIR
-zip -r $DIR.zip $DIR/*
-rm -rf $DIR
+
+mkdir -p $BUILD
+
+cmake -B $BUILD -S src \
+ -DCMAKE_BUILD_TYPE="Release" \
+ -DASSET_PATH="assets/" \
+ -DCMAKE_C_FLAGS="-Ofast" \
+ -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN"
+
+make --no-print-directory -C $BUILD -j$(nproc)
+
+rm -rf $SNAPSHOT
+mkdir $SNAPSHOT
+
+cp -r \
+ assets \
+ $BUILD/dragonblocks_client$DOTEXE \
+ $BUILD/dragonblocks_server$DOTEXE \
+ singleplayer$DOTSH \
+ LICENSE \
+ README.md \
+ $SNAPSHOT
+
+zip -r $SNAPSHOT.zip $SNAPSHOT/*
-cmake_minimum_required(VERSION 3.12)
+cmake_minimum_required(VERSION 3.14)
project(Dragonblocks)
# Variables
-set(DEPS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../deps/")
+set(DEPS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../deps")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
-if(NOT RESSOURCE_PATH)
- set(RESSOURCE_PATH "../")
+if(NOT ASSET_PATH)
+ set(ASSET_PATH "../assets/")
endif()
# Dependencies
-find_package(OpenGL REQUIRED)
-
-if(NOT GLEW_LIBRARIES OR NOT GLEW_INCLUDE_DIRS)
- find_package(GLEW REQUIRED)
-endif()
-
-if(NOT GLFW_LIBRARIES OR NOT GLFW_INCLUDE_DIRS)
- find_package(glfw3 3.3 REQUIRED)
- set(GLFW_LIBRARIES glfw)
- set(GLFW_INCLUDE_DIRS)
-endif()
-
-if(NOT FREETYPE_LIBRARIES OR NOT FREETYPE_INCLUDE_DIRS)
- find_package(Freetype REQUIRED)
-endif()
-
-if(NOT ZLIB_LIBRARIES OR NOT ZLIB_INCLUDE_DIRS)
- find_package(ZLIB REQUIRED)
- set(ZLIB_LIBRARIES ZLIB::ZLIB)
- set(ZLIB_INCLUDE_DIRS)
-endif()
+cmake_policy(SET CMP0077 NEW)
+
+set(SKIP_INSTALL_ALL ON)
+set(BUILD_SHARED_LIBS OFF)
+set(ZLIB_LIBRARY zlibstatic)
+
+set(FT_DISABLE_ZLIB OFF)
+set(FT_DISABLE_BZIP2 ON)
+set(FT_DISABLE_PNG ON)
+set(FT_DISABLE_HARFBUZZ ON)
+set(FT_DISABLE_BROTLI ON)
+
+add_subdirectory("${DEPS_DIR}/glfw" EXCLUDE_FROM_ALL "${CMAKE_CURRENT_BINARY_DIR}/glfw")
+add_subdirectory("${DEPS_DIR}/glew-cmake" EXCLUDE_FROM_ALL "${CMAKE_CURRENT_BINARY_DIR}/glew")
+add_subdirectory("${DEPS_DIR}/sqlite3-cmake" EXCLUDE_FROM_ALL "${CMAKE_CURRENT_BINARY_DIR}/sqlite3")
+add_subdirectory("${DEPS_DIR}/perlin" EXCLUDE_FROM_ALL "${CMAKE_CURRENT_BINARY_DIR}/perlin")
+add_subdirectory("${DEPS_DIR}/asprintf" EXCLUDE_FROM_ALL "${CMAKE_CURRENT_BINARY_DIR}/asprintf")
+add_subdirectory("${DEPS_DIR}/dragonnet" EXCLUDE_FROM_ALL "${CMAKE_CURRENT_BINARY_DIR}/dragonnet")
+add_subdirectory("${DEPS_DIR}/dragonstd" EXCLUDE_FROM_ALL "${CMAKE_CURRENT_BINARY_DIR}/dragonstd")
+add_subdirectory("${DEPS_DIR}/getline" EXCLUDE_FROM_ALL "${CMAKE_CURRENT_BINARY_DIR}/getline")
+add_subdirectory("${DEPS_DIR}/stpcpy" EXCLUDE_FROM_ALL "${CMAKE_CURRENT_BINARY_DIR}/stpcpy")
+add_subdirectory("${DEPS_DIR}/linenoise" EXCLUDE_FROM_ALL "${CMAKE_CURRENT_BINARY_DIR}/linenoise")
+add_subdirectory("${DEPS_DIR}/zlib" EXCLUDE_FROM_ALL "${CMAKE_CURRENT_BINARY_DIR}/zlib")
+add_subdirectory("${DEPS_DIR}/freetype" EXCLUDE_FROM_ALL "${CMAKE_CURRENT_BINARY_DIR}/freetype")
# Options
endif()
add_compile_definitions("USE_DRAGONNET")
-add_compile_definitions("RESSOURCE_PATH=\"${RESSOURCE_PATH}\"")
-
-add_compile_options(-Wall -Wextra -Werror -Wno-address-of-packed-member -Wno-implicit-fallthrough -Wno-unused-parameter -Wno-maybe-uninitialized -fmax-errors=4)
-
-link_libraries(
- pthread
- m
- ${ZLIB_LIBRARIES}
+add_compile_definitions("GLEW_STATIC")
+add_compile_definitions("ASSET_PATH=\"${ASSET_PATH}\"")
+
+add_compile_options(
+ -Wall
+ -Wextra
+ -Werror
+ -Wno-address-of-packed-member
+ -fmax-errors=4
)
-include_directories(SYSTEM ${DEPS_DIR})
-include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR})
-include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
-include_directories(${ZLIB_INCLUDE_DIRS})
-
# System specific options
if("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD")
# Common sources
-set(COMMON_SOURCES
+add_library(dragonblocks
"${CMAKE_CURRENT_BINARY_DIR}/types.c"
- "${DEPS_DIR}/asprintf/asprintf.c"
- "${DEPS_DIR}/dragonnet/addr.c"
- "${DEPS_DIR}/dragonnet/listen.c"
- "${DEPS_DIR}/dragonnet/peer.c"
- "${DEPS_DIR}/dragonnet/recv.c"
- "${DEPS_DIR}/dragonnet/recv_thread.c"
- "${DEPS_DIR}/dragonnet/send.c"
- "${DEPS_DIR}/dragonstd/array.c"
- "${DEPS_DIR}/dragonstd/flag.c"
- "${DEPS_DIR}/dragonstd/list.c"
- "${DEPS_DIR}/dragonstd/map.c"
- "${DEPS_DIR}/dragonstd/queue.c"
- "${DEPS_DIR}/dragonstd/refcount.c"
- "${DEPS_DIR}/dragonstd/tree.c"
- "${DEPS_DIR}/dragonstd/bits/compare.c"
- "${DEPS_DIR}/getline/getline.c"
- "${DEPS_DIR}/linenoise/linenoise.c"
- "${DEPS_DIR}/linenoise/stringbuf.c"
- "${DEPS_DIR}/linenoise/utf8.c"
- "${DEPS_DIR}/perlin/perlin.c"
- color.c
- config.c
- day.c
- environment.c
- facedir.c
- interrupt.c
- item.c
- node.c
- perlin.c
- physics.c
- terrain.c
+ common/color.c
+ common/config.c
+ common/day.c
+ common/environment.c
+ common/facedir.c
+ common/interrupt.c
+ common/item.c
+ common/node.c
+ common/perlin.c
+ common/physics.c
+ common/terrain.c
+)
+
+target_include_directories(dragonblocks
+ PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
+ PUBLIC ${CMAKE_CURRENT_BINARY_DIR}
+ PUBLIC "${DEPS_DIR}/linmath.h"
+ PUBLIC "${DEPS_DIR}/endian.h"
+ PUBLIC "${DEPS_DIR}/stb"
+)
+
+target_link_libraries(dragonblocks
+ PUBLIC pthread
+ PUBLIC m
+ PUBLIC perlin
+ PUBLIC dragonnet
+ PUBLIC dragonstd
+ PUBLIC getline
+ PUBLIC zlibstatic
+ PUBLIC stpcpy
)
# Client
-add_executable(dragonblocks
- ${COMMON_SOURCES}
+add_executable(dragonblocks_client
client/camera.c
client/client.c
client/client_auth.c
client/window.c
)
-target_link_libraries(dragonblocks
- ${OPENGL_LIBRARIES}
- ${GLEW_LIBRARIES}
- ${GLFW_LIBRARIES}
- ${FREETYPE_LIBRARIES}
-)
-
-target_include_directories(dragonblocks PUBLIC
- ${GLEW_INCLUDE_DIRS}
- ${GLFW_INCLUDE_DIRS}
- ${FREETYPE_INCLUDE_DIRS}
+target_link_libraries(dragonblocks_client
+ PUBLIC dragonblocks
+ PUBLIC libglew_static
+ PUBLIC glfw
+ PUBLIC asprintf
+ PUBLIC linenoise
+ PUBLIC freetype
)
# Server
add_executable(dragonblocks_server
- ${COMMON_SOURCES}
server/biomes.c
server/database.c
server/schematic.c
)
target_link_libraries(dragonblocks_server
- sqlite3
+ PUBLIC dragonblocks
+ PUBLIC sqlite3
)
# Version
)
add_dependencies(dragonblocks version)
-add_dependencies(dragonblocks_server version)
# Types
)
add_dependencies(dragonblocks types)
-add_dependencies(dragonblocks_server types)
#ifndef _CAMERA_H_
#define _CAMERA_H_
-#include <linmath.h/linmath.h>
+#include <linmath.h>
#include "types.h"
extern struct Camera {
#include "client/debug_menu.h"
#include "client/game.h"
#include "client/input.h"
-#include "day.h"
-#include "interrupt.h"
-#include "perlin.h"
+#include "common/day.h"
+#include "common/interrupt.h"
+#include "common/perlin.h"
#include "types.h"
DragonnetPeer *client;
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
-#include <linenoise/linenoise.h>
+#include <linenoise.h>
#include "client.h"
#include "client_auth.h"
-#include "interrupt.h"
+#include "common/interrupt.h"
#include "types.h"
struct ClientAuth client_auth;
-#include "config.h"
#include "client/client_config.h"
+#include "common/config.h"
struct ClientConfig client_config = {
.antialiasing = 4,
-#include <asprintf/asprintf.h>
+#include <asprintf.h>
#include <dragonstd/map.h>
#include <inttypes.h>
#include <stdio.h>
{
char *shader_def;
asprintf(&shader_def, "#define VIEW_DISTANCE %lf\n", client_config.view_distance);
- shader_prog = shader_program_create(RESSOURCE_PATH "shaders/3d/entity", shader_def);
+ shader_prog = shader_program_create(ASSET_PATH "shaders/3d/entity", shader_def);
free(shader_def);
loc_VP = glGetUniformLocation(shader_prog, "VP"); GL_DEBUG
#include <pthread.h>
#include "client/gui.h"
#include "client/model.h"
-#include "entity.h"
-#include "item.h"
+#include "common/entity.h"
+#include "common/item.h"
#include "types.h"
typedef struct {
-#include <asprintf/asprintf.h>
+#include <asprintf.h>
#include <stdio.h>
#include <stdlib.h>
#include "client/client_config.h"
{
char *_3d_shader_def;
asprintf(&_3d_shader_def, "#define VIEW_DISTANCE %lf\n", client_config.view_distance);
- _3d_shader_prog = shader_program_create(RESSOURCE_PATH "shaders/3d/item", _3d_shader_def);
+ _3d_shader_prog = shader_program_create(ASSET_PATH "shaders/3d/item", _3d_shader_def);
free(_3d_shader_def);
_3d_loc_VP = glGetUniformLocation(_3d_shader_prog, "VP");
#include "client/client_item.h"
#include "client/interact.h"
-#include "node.h"
+#include "common/node.h"
static bool use_dig(__attribute__((unused)) ItemStack *stack)
{
ClientItemDef client_item_def[COUNT_ITEM] = {
// unknown
{
- .mesh_path = RESSOURCE_PATH "meshes/unknown.txt",
+ .mesh_path = ASSET_PATH "meshes/unknown.txt",
.mesh = {0},
.use = NULL,
},
},
// pickaxe
{
- .mesh_path = RESSOURCE_PATH "meshes/pickaxe.txt",
+ .mesh_path = ASSET_PATH "meshes/pickaxe.txt",
.mesh = {0},
.use = &use_dig,
},
// axe
{
- .mesh_path = RESSOURCE_PATH "meshes/axe.txt",
+ .mesh_path = ASSET_PATH "meshes/axe.txt",
.mesh = {0},
.use = &use_dig,
},
// shovel
{
- .mesh_path = RESSOURCE_PATH "meshes/shovel.txt",
+ .mesh_path = ASSET_PATH "meshes/shovel.txt",
.mesh = {0},
.use = &use_dig,
},
#include <stdbool.h>
#include "client/mesh.h"
-#include "item.h"
-#include "node.h"
+#include "common/item.h"
+#include "common/node.h"
typedef struct {
const char *mesh_path;
#include <stdlib.h>
#include "client/client.h"
#include "client/client_node.h"
-#include "color.h"
-#include "environment.h"
-#include "node.h"
-#include "perlin.h"
+#include "common/color.h"
+#include "common/environment.h"
+#include "common/node.h"
+#include "common/perlin.h"
#define TILES_SIMPLE(path) {.paths = {path, NULL, NULL, NULL, NULL, NULL}, .indices = {0, 0, 0, 0, 0, 0}, .textures = {NULL}}
#define TILES_NONE {.paths = {NULL}, .indices = {0}, .textures = {NULL}}
ClientNodeDef client_node_def[COUNT_NODE] = {
// unknown
{
- .tiles = TILES_SIMPLE(RESSOURCE_PATH "textures/unknown.png"),
+ .tiles = TILES_SIMPLE(ASSET_PATH "textures/unknown.png"),
.visibility = VISIBILITY_SOLID,
.mipmap = true,
.render = NULL,
},
// grass
{
- .tiles = TILES_SIMPLE(RESSOURCE_PATH "textures/grass.png"),
+ .tiles = TILES_SIMPLE(ASSET_PATH "textures/grass.png"),
.visibility = VISIBILITY_SOLID,
.mipmap = true,
.render = &render_grass,
},
// dirt
{
- .tiles = TILES_SIMPLE(RESSOURCE_PATH "textures/dirt.png"),
+ .tiles = TILES_SIMPLE(ASSET_PATH "textures/dirt.png"),
.visibility = VISIBILITY_SOLID,
.mipmap = true,
.render = NULL,
},
// stone
{
- .tiles = TILES_SIMPLE(RESSOURCE_PATH "textures/stone.png"),
+ .tiles = TILES_SIMPLE(ASSET_PATH "textures/stone.png"),
.visibility = VISIBILITY_SOLID,
.mipmap = true,
.render = &render_stone,
},
// snow
{
- .tiles = TILES_SIMPLE(RESSOURCE_PATH "textures/snow.png"),
+ .tiles = TILES_SIMPLE(ASSET_PATH "textures/snow.png"),
.visibility = VISIBILITY_SOLID,
.mipmap = true,
.render = NULL,
// oak wood
{
.tiles = {
- .paths = {RESSOURCE_PATH "textures/oak_wood.png", RESSOURCE_PATH "textures/oak_wood_top.png", NULL, NULL, NULL, NULL},
+ .paths = {ASSET_PATH "textures/oak_wood.png", ASSET_PATH "textures/oak_wood_top.png", NULL, NULL, NULL, NULL},
.indices = {0, 0, 0, 0, 1, 1},
.textures = {NULL},
},
},
// oak leaves
{
- .tiles = TILES_SIMPLE(RESSOURCE_PATH "textures/oak_leaves.png"),
+ .tiles = TILES_SIMPLE(ASSET_PATH "textures/oak_leaves.png"),
.visibility = VISIBILITY_SOLID,
.mipmap = true,
.render = &render_color,
// pine wood
{
.tiles = {
- .paths = {RESSOURCE_PATH "textures/pine_wood.png", RESSOURCE_PATH "textures/pine_wood_top.png", NULL, NULL, NULL, NULL},
+ .paths = {ASSET_PATH "textures/pine_wood.png", ASSET_PATH "textures/pine_wood_top.png", NULL, NULL, NULL, NULL},
.indices = {0, 0, 0, 0, 1, 1},
.textures = {NULL},
},
},
// pine leaves
{
- .tiles = TILES_SIMPLE(RESSOURCE_PATH "textures/pine_leaves.png"),
+ .tiles = TILES_SIMPLE(ASSET_PATH "textures/pine_leaves.png"),
.visibility = VISIBILITY_CLIP,
.mipmap = true,
.render = &render_color,
// palm wood
{
.tiles = {
- .paths = {RESSOURCE_PATH "textures/palm_wood.png", RESSOURCE_PATH "textures/palm_wood_top.png", NULL, NULL, NULL, NULL},
+ .paths = {ASSET_PATH "textures/palm_wood.png", ASSET_PATH "textures/palm_wood_top.png", NULL, NULL, NULL, NULL},
.indices = {0, 0, 0, 0, 1, 1},
.textures = {NULL},
},
},
// palm leaves
{
- .tiles = TILES_SIMPLE(RESSOURCE_PATH "textures/palm_leaves.png"),
+ .tiles = TILES_SIMPLE(ASSET_PATH "textures/palm_leaves.png"),
.visibility = VISIBILITY_SOLID,
.mipmap = true,
.render = &render_color,
},
// sand
{
- .tiles = TILES_SIMPLE(RESSOURCE_PATH "textures/sand.png"),
+ .tiles = TILES_SIMPLE(ASSET_PATH "textures/sand.png"),
.visibility = VISIBILITY_SOLID,
.mipmap = true,
.render = NULL,
},
// water
{
- .tiles = TILES_SIMPLE(RESSOURCE_PATH "textures/water.png"),
+ .tiles = TILES_SIMPLE(ASSET_PATH "textures/water.png"),
.visibility = VISIBILITY_BLEND,
.mipmap = true,
.render = NULL,
},
// lava
{
- .tiles = TILES_SIMPLE(RESSOURCE_PATH "textures/lava.png"),
+ .tiles = TILES_SIMPLE(ASSET_PATH "textures/lava.png"),
.visibility = VISIBILITY_BLEND,
.mipmap = true,
.render = NULL,
},
// vulcano_stone
{
- .tiles = TILES_SIMPLE(RESSOURCE_PATH "textures/vulcano_stone.png"),
+ .tiles = TILES_SIMPLE(ASSET_PATH "textures/vulcano_stone.png"),
.visibility = VISIBILITY_SOLID,
.mipmap = true,
.render = NULL,
#include "client/terrain_gfx.h"
#include "client/texture.h"
-#include "terrain.h"
+#include "common/terrain.h"
typedef enum {
VISIBILITY_NONE,
#include "client/cube.h"
#include "client/debug_menu.h"
#include "client/texture.h"
-#include "environment.h"
-#include "physics.h"
+#include "common/environment.h"
+#include "common/physics.h"
struct ClientPlayer client_player;
void client_player_gfx_init()
{
player_model = model_load(
- RESSOURCE_PATH "models/player.txt", RESSOURCE_PATH "textures/models/player",
+ ASSET_PATH "models/player.txt", ASSET_PATH "textures/models/player",
&client_entity_cube, &client_entity_shader);
player_model->callbacks.delete = &on_model_delete;
#include "client/client_terrain.h"
#include "client/debug_menu.h"
#include "client/terrain_gfx.h"
-#include "facedir.h"
+#include "common/facedir.h"
#define MAX_REQUESTS 4
#include <stdatomic.h>
#include <stdbool.h>
#include "client/model.h"
-#include "terrain.h"
+#include "common/terrain.h"
#include "types.h"
#define CHUNK_MODE_NOCREATE 2
-#include <asprintf/asprintf.h>
+#include <asprintf.h>
#include <GL/glew.h>
#include <GL/gl.h>
#include <stdbool.h>
#include "client/gui.h"
#include "client/interact.h"
#include "client/window.h"
-#include "day.h"
-#include "environment.h"
-#include "perlin.h"
+#include "common/day.h"
+#include "common/environment.h"
+#include "common/perlin.h"
#include "version.h"
static GUIElement *gui_elements[COUNT_ENTRY] = {NULL};
abort();
}
- if (FT_New_Face(font_library, RESSOURCE_PATH "fonts/Minecraftia.ttf", 0, &font_face)) {
+ if (FT_New_Face(font_library, ASSET_PATH "fonts/Minecraftia.ttf", 0, &font_face)) {
fprintf(stderr, "[error] failed to load Minecraftia.ttf\n");
abort();
}
#define _FRUSTUM_H_
#include <stdbool.h>
-#include <linmath.h/linmath.h>
+#include <linmath.h>
#include "types.h"
extern mat4x4 frustum;
#include "client/interact.h"
#include "client/sky.h"
#include "client/window.h"
-#include "day.h"
-#include "interrupt.h"
+#include "common/day.h"
+#include "common/interrupt.h"
#ifdef _WIN32
#include <pthread_time.h>
void gui_init()
{
// initialize background pipeline
- background_prog = shader_program_create(RESSOURCE_PATH "shaders/gui/background", NULL);
+ background_prog = shader_program_create(ASSET_PATH "shaders/gui/background", NULL);
background_loc_model = glGetUniformLocation(background_prog, "model"); GL_DEBUG
background_loc_projection = glGetUniformLocation(background_prog, "projection"); GL_DEBUG
background_loc_color = glGetUniformLocation(background_prog, "color"); GL_DEBUG
// initialize image pipeline
- image_prog = shader_program_create(RESSOURCE_PATH "shaders/gui/image", NULL);
+ image_prog = shader_program_create(ASSET_PATH "shaders/gui/image", NULL);
image_loc_model = glGetUniformLocation(image_prog, "model"); GL_DEBUG
image_loc_projection = glGetUniformLocation(image_prog, "projection"); GL_DEBUG
// initialize font pipeline
- font_prog = shader_program_create(RESSOURCE_PATH "shaders/gui/font", NULL);
+ font_prog = shader_program_create(ASSET_PATH "shaders/gui/font", NULL);
font_loc_model = glGetUniformLocation(font_prog, "model"); GL_DEBUG
font_loc_projection = glGetUniformLocation(font_prog, "projection"); GL_DEBUG
font_loc_color = glGetUniformLocation(font_prog, "color"); GL_DEBUG
#define _GUI_H_
#include <dragonstd/array.h>
-#include <linmath.h/linmath.h>
+#include <linmath.h>
#include <stdbool.h>
#include "client/font.h"
#include "client/texture.h"
-#include <asprintf/asprintf.h>
+#include <asprintf.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "client/input.h"
#include "client/screenshot.h"
#include "client/window.h"
-#include "day.h"
+#include "common/day.h"
#define SET_STATUS_MESSAGE(args...) { \
char *msg; asprintf(&msg, args); \
-#include <linmath.h/linmath.h>
+#include <linmath.h>
#include <stdio.h>
#include "client/camera.h"
#include "client/client.h"
void interact_init()
{
- shader_prog = shader_program_create(RESSOURCE_PATH "shaders/3d/selection", NULL);
+ shader_prog = shader_program_create(ASSET_PATH "shaders/3d/selection", NULL);
loc_MVP = glGetUniformLocation(shader_prog, "MVP"); GL_DEBUG
loc_color = glGetUniformLocation(shader_prog, "color"); GL_DEBUG
.scale_type = SCALE_IMAGE,
.affect_parent_scale = false,
.text = NULL,
- .image = texture_load(RESSOURCE_PATH "textures/crosshair.png", false),
+ .image = texture_load(ASSET_PATH "textures/crosshair.png", false),
.text_color = {0.0f, 0.0f, 0.0f, 0.0f},
.bg_color = {0.0f, 0.0f, 0.0f, 0.0f},
});
#define _INTERACT_H_
#include <stdbool.h>
-#include "node.h"
+#include "common/node.h"
#include "types.h"
extern struct InteractPointed {
-#include <linmath.h/linmath.h>
+#include <linmath.h>
#include "client/camera.h"
#include "client/gl_debug.h"
#include "client/light.h"
-#include "day.h"
+#include "common/day.h"
void light_shader_locate(LightShader *shader)
{
#include <dragonstd/tree.h>
-#include <getline/getline.h>
+#include <getline.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <dragonstd/tree.h>
-#include <getline/getline.h>
+#include <getline.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <dragonstd/list.h>
#include <GL/glew.h>
#include <GL/gl.h>
-#include <linmath.h/linmath.h>
+#include <linmath.h>
#include <stdbool.h>
#include <stddef.h>
#include "client/mesh.h"
#define _RAYCAST_H_
#include <stdbool.h>
-#include "node.h"
+#include "common/node.h"
#include "types.h"
bool raycast(v3f64 pos, v3f64 dir, f64 len, v3s32 *node_pos, NodeType *node);
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include <GL/glew.h>
#include <GL/gl.h>
-#include <stb/stb_image_write.h>
+#include <stb_image_write.h>
#include <string.h>
#include <time.h>
#include "client/game.h"
#include "client/sky.h"
#include "client/texture.h"
#include "client/window.h"
-#include "day.h"
+#include "common/day.h"
static GLuint sun_prog;
static GLint sun_loc_MVP;
// skybox
- skybox_prog = shader_program_create(RESSOURCE_PATH "shaders/sky/skybox", NULL);
+ skybox_prog = shader_program_create(ASSET_PATH "shaders/sky/skybox", NULL);
glProgramUniform1iv(skybox_prog, glGetUniformLocation(skybox_prog, "textures"), 2, (GLint[]) {0, 1}); GL_DEBUG
skybox_loc_VP = glGetUniformLocation(skybox_prog, "VP"); GL_DEBUG
skybox_loc_daylight = glGetUniformLocation(skybox_prog, "daylight"); GL_DEBUG
- skybox_texture_day = texture_load_cubemap(RESSOURCE_PATH "textures/skybox/day", true)->txo;
- skybox_texture_night = texture_load_cubemap(RESSOURCE_PATH "textures/skybox/night", true)->txo;
+ skybox_texture_day = texture_load_cubemap(ASSET_PATH "textures/skybox/day", true)->txo;
+ skybox_texture_night = texture_load_cubemap(ASSET_PATH "textures/skybox/night", true)->txo;
skybox_mesh.data = skybox_vertices;
mesh_upload(&skybox_mesh);
// sun
- sun_prog = shader_program_create(RESSOURCE_PATH "shaders/sky/sun", NULL);
+ sun_prog = shader_program_create(ASSET_PATH "shaders/sky/sun", NULL);
sun_loc_MVP = glGetUniformLocation(sun_prog, "MVP"); GL_DEBUG
- sun_texture = texture_load(RESSOURCE_PATH "textures/sun.png", false)->txo;
+ sun_texture = texture_load(ASSET_PATH "textures/sun.png", false)->txo;
// clouds
- clouds_prog = shader_program_create(RESSOURCE_PATH "shaders/sky/clouds", NULL);
+ clouds_prog = shader_program_create(ASSET_PATH "shaders/sky/clouds", NULL);
clouds_loc_VP = glGetUniformLocation(clouds_prog, "VP"); GL_DEBUG
clouds_loc_daylight = glGetUniformLocation(clouds_prog, "daylight"); GL_DEBUG
clouds_mesh.data = clouds_vertices;
#include <assert.h>
-#include <asprintf/asprintf.h>
-#include <linmath.h/linmath.h>
+#include <asprintf.h>
+#include <linmath.h>
#include <stdio.h>
#include <stdlib.h>
#include "client/client_config.h"
#include "client/light.h"
#include "client/shader.h"
#include "client/terrain_gfx.h"
-#include "facedir.h"
+#include "common/facedir.h"
typedef struct {
TerrainChunk *chunk; // input: chunk pointer
texture_units,
client_config.view_distance
);
- shader_prog = shader_program_create(RESSOURCE_PATH "shaders/3d/terrain", shader_def);
+ shader_prog = shader_program_create(ASSET_PATH "shaders/3d/terrain", shader_def);
free(shader_def);
loc_VP = glGetUniformLocation(shader_prog, "VP"); GL_DEBUG
#define _TERRAIN_GFX_H_
#include "client/cube.h"
-#include "terrain.h"
+#include "common/terrain.h"
typedef struct {
CubeVertex cube;
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_RESIZE_IMPLEMENTATION
-#include <stb/stb_image.h>
-#include <stb/stb_image_resize.h>
+#include <stb_image.h>
+#include <stb_image_resize.h>
#include <stdbool.h>
#include <dragonstd/tree.h>
#include "client/client_config.h"
#define _WINDOW_H_
#include <GLFW/glfw3.h>
-#include <linmath.h/linmath.h>
+#include <linmath.h>
#include <stdbool.h>
#include "types.h"
+++ /dev/null
-#include "color.h"
-
-static f32 hue_to_rgb(f32 p, f32 q, f32 t)
-{
- if (t < 0.0f)
- t += 1.0f;
-
- if (t > 1.0f)
- t -= 1.0f;
-
- if (t < 1.0f / 6.0f)
- return p + (q - p) * 6.0f * t;
-
- if (t < 1.0f / 2.0f)
- return q;
-
- if (t < 2.0f / 3.0f)
- return p + (q - p) * (2.0f / 3.0f - t) * 6.0f;
-
- return p;
-}
-
-v3f32 hsl_to_rgb(v3f32 hsl)
-{
- v3f32 rgb;
-
- if (hsl.y == 0.0f) {
- rgb = (v3f32) {hsl.z, hsl.z, hsl.z};
- } else {
- f32 q = hsl.z < 0.5f ? hsl.z * (1.0f + hsl.y) : hsl.z + hsl.y - hsl.z * hsl.y;
- f32 p = 2.0f * hsl.z - q;
-
- rgb.x = hue_to_rgb(p, q, hsl.x + 1.0f / 3.0f);
- rgb.y = hue_to_rgb(p, q, hsl.x);
- rgb.z = hue_to_rgb(p, q, hsl.x - 1.0f / 3.0f);
- }
-
- return rgb;
-}
-
+++ /dev/null
-#ifndef _COLOR_H_
-#define _COLOR_H_
-
-#include "types.h"
-
-v3f32 hsl_to_rgb(v3f32 hsl);
-
-#endif // _COLOR_H_
--- /dev/null
+#include "common/color.h"
+
+static f32 hue_to_rgb(f32 p, f32 q, f32 t)
+{
+ if (t < 0.0f)
+ t += 1.0f;
+
+ if (t > 1.0f)
+ t -= 1.0f;
+
+ if (t < 1.0f / 6.0f)
+ return p + (q - p) * 6.0f * t;
+
+ if (t < 1.0f / 2.0f)
+ return q;
+
+ if (t < 2.0f / 3.0f)
+ return p + (q - p) * (2.0f / 3.0f - t) * 6.0f;
+
+ return p;
+}
+
+v3f32 hsl_to_rgb(v3f32 hsl)
+{
+ v3f32 rgb;
+
+ if (hsl.y == 0.0f) {
+ rgb = (v3f32) {hsl.z, hsl.z, hsl.z};
+ } else {
+ f32 q = hsl.z < 0.5f ? hsl.z * (1.0f + hsl.y) : hsl.z + hsl.y - hsl.z * hsl.y;
+ f32 p = 2.0f * hsl.z - q;
+
+ rgb.x = hue_to_rgb(p, q, hsl.x + 1.0f / 3.0f);
+ rgb.y = hue_to_rgb(p, q, hsl.x);
+ rgb.z = hue_to_rgb(p, q, hsl.x - 1.0f / 3.0f);
+ }
+
+ return rgb;
+}
+
--- /dev/null
+#ifndef _COLOR_H_
+#define _COLOR_H_
+
+#include "types.h"
+
+v3f32 hsl_to_rgb(v3f32 hsl);
+
+#endif // _COLOR_H_
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdbool.h>
+#include "common/config.h"
+
+void config_read(char *path, ConfigEntry *entries, size_t num_entries)
+{
+ FILE *f = fopen(path, "r");
+
+ if (!f)
+ return;
+
+ printf("[info] reading config from %s\n", path);
+
+ while (!feof(f)) {
+ char key[BUFSIZ];
+ if (!fscanf(f, "%s", key))
+ break;
+
+ bool found = false;
+ for (size_t i = 0; i < num_entries; i++) {
+ ConfigEntry *entry = &entries[i];
+ if (strcmp(key, entry->key) == 0) {
+ bool valid = false;
+
+ switch (entry->type) {
+ case CONFIG_STRING: {
+ char value[BUFSIZ];
+
+ if (!fscanf(f, "%s", value))
+ break;
+
+ valid = true;
+
+ char **entry_value = entry->value;
+
+ if (*entry_value)
+ free(*entry_value);
+ *entry_value = strdup(value);
+
+ break;
+ }
+
+ case CONFIG_INT:
+ if (fscanf(f, "%d", (int *) entry->value))
+ valid = true;
+
+ break;
+
+ case CONFIG_UINT:
+ if (fscanf(f, "%u", (unsigned int *) entry->value))
+ valid = true;
+
+ break;
+
+ case CONFIG_FLOAT:
+ if (fscanf(f, "%lf", (double *) entry->value))
+ valid = true;
+
+ break;
+
+ case CONFIG_BOOL: {
+ char value[BUFSIZ];
+
+ if (!fscanf(f, "%s", value))
+ break;
+
+ valid = true;
+
+ if (strcmp(value, "on") == 0 || strcmp(value, "yes") == 0 || strcmp(value, "true") == 0)
+ *(bool *) entry->value = true;
+ else if (strcmp(value, "off") == 0 || strcmp(value, "no") == 0 || strcmp(value, "false") == 0)
+ *(bool *) entry->value = false;
+ else
+ valid = false;
+
+ break;
+ }
+ }
+
+ if (!valid)
+ fprintf(stderr, "[warning] invalid value for setting %s in %s\n", key, path);
+
+ found = true;
+ break;
+ }
+ }
+
+ if (!found)
+ fprintf(stderr, "[warning] unknown setting %s in %s\n", key, path);
+ }
+
+ fclose(f);
+}
+
+void config_free(ConfigEntry *entries, size_t num_entries)
+{
+ for (size_t i = 0; i < num_entries; i++) {
+ ConfigEntry *entry = &entries[i];
+
+ if (entry->type == CONFIG_STRING) {
+ char **entry_value = entry->value;
+
+ if (*entry_value)
+ free(*entry_value);
+ }
+ }
+}
--- /dev/null
+#ifndef _CONFIG_H_
+#define _CONFIG_H_
+
+#include <stddef.h>
+
+typedef enum {
+ CONFIG_STRING,
+ CONFIG_INT,
+ CONFIG_UINT,
+ CONFIG_FLOAT,
+ CONFIG_BOOL,
+} ConfigType;
+
+typedef struct {
+ ConfigType type;
+ char *key;
+ void *value;
+} ConfigEntry;
+
+void config_read(char *path, ConfigEntry *entries, size_t num_entries);
+void config_free(ConfigEntry *entries, size_t num_entires);
+
+#endif // _CONFIG_H_
--- /dev/null
+#include <math.h>
+#include <time.h>
+#include "common/day.h"
+
+bool timelapse = false;
+static f64 time_of_day_offset;
+
+f64 get_unix_time()
+{
+ struct timespec ts;
+ clock_gettime(CLOCK_REALTIME, &ts);
+ return ((f64) ts.tv_sec + ts.tv_nsec / 1.0e9) * (timelapse ? 100.0 : 1.0);
+}
+
+f64 get_time_of_day()
+{
+ return fmod(get_unix_time() - time_of_day_offset, MINUTES_PER_DAY);
+}
+
+void set_time_of_day(f64 new_time)
+{
+ time_of_day_offset = get_unix_time() - new_time;
+}
+
+f64 get_sun_angle()
+{
+ return 2.0 * M_PI * (f64) get_time_of_day() / MINUTES_PER_DAY + M_PI;
+}
+
+f64 get_daylight()
+{
+ return f64_clamp(cos(get_sun_angle()) * 2.0 + 0.5, 0.0, 1.0);
+}
+
+void split_time_of_day(int *hours, int *minutes)
+{
+ int time_of_day = get_time_of_day();
+
+ *minutes = time_of_day % MINUTES_PER_HOUR;
+ *hours = time_of_day / MINUTES_PER_HOUR;
+}
--- /dev/null
+#ifndef _DAY_H_
+#define _DAY_H_
+
+#include <stdbool.h>
+#include "types.h"
+
+#define MINUTES_PER_HOUR 60
+#define HOURS_PER_DAY 24
+#define MINUTES_PER_DAY (HOURS_PER_DAY * MINUTES_PER_HOUR)
+
+// 1 second in real life = 1 minute ingame
+
+f64 get_time_of_day();
+void set_time_of_day(f64 new_time);
+f64 get_sun_angle();
+f64 get_daylight();
+void split_time_of_day(int *hours, int *minutes);
+
+extern bool timelapse;
+
+#endif // _DAY_H_
--- /dev/null
+#ifndef _DIG_H_
+#define _DIG_H_
+
+typedef enum {
+ DIG_NONE = 0x0,
+ DIG_STONE = 0x01,
+ DIG_WOOD = 0x02,
+ DIG_DIRT = 0x04,
+ DIG_LEAVES = 0x08,
+} DigClass;
+
+#endif // _DIG_H_
--- /dev/null
+#ifndef _ENTITY_H_
+#define _ENTITY_H_
+
+// ET phone home
+typedef enum {
+ ENTITY_LOCALPLAYER,
+ ENTITY_PLAYER,
+ COUNT_ENTITY,
+} EntityType;
+
+#endif // _ENTITY_H_
--- /dev/null
+#include "common/environment.h"
+#include "common/perlin.h"
+
+f64 get_humidity(v3s32 pos)
+{
+ return smooth2d(U32(pos.x) / 128.0, U32(pos.z) / 128.0, 0, seed + OFFSET_WETNESS) * 0.5 + 0.5;
+}
+
+f64 get_temperature(v3s32 pos)
+{
+ return smooth2d(U32(pos.x) / 128.0, U32(pos.z) / 128.0, 0, seed + OFFSET_TEMPERATURE) * 0.5 + 0.5 - (pos.y - 32.0) / 64.0;
+}
--- /dev/null
+#ifndef _ENVIRONMENT_H_
+#define _ENVIRONMENT_H_
+
+#include "types.h"
+
+f64 get_humidity(v3s32 pos);
+f64 get_temperature(v3s32 pos);
+
+#endif // _ENVIRONMENT_H_
--- /dev/null
+#include "common/facedir.h"
+
+v3s32 facedir[6] = {
+ {+0, +0, -1},
+ {+0, +0, +1},
+ {-1, +0, +0},
+ {+1, +0, +0},
+ {+0, -1, +0},
+ {+0, +1, +0},
+};
--- /dev/null
+#ifndef _FACEDIR_H_
+#define _FACEDIR_H_
+
+#include "types.h"
+
+extern v3s32 facedir[];
+
+#endif // _FACEDIR_H_
--- /dev/null
+#include <signal.h>
+#include <stdio.h>
+#include <string.h>
+#include "common/interrupt.h"
+
+Flag interrupt;
+
+#ifdef _WIN32
+
+// just the signals we need, for Win32
+static const char *strsignal(int sig)
+{
+ switch (sig) {
+ case SIGINT:
+ return "Interrupted";
+
+ case SIGTERM:
+ return "Terminated";
+
+ default:
+ return "Unknown signal";
+ }
+}
+
+#endif // _WIN32
+
+static void interrupt_handler(int sig)
+{
+ fprintf(stderr, "%s\n", strsignal(sig));
+ flag_set(&interrupt);
+}
+
+void interrupt_init()
+{
+ flag_ini(&interrupt);
+
+#ifdef _WIN32
+ signal(SIGINT, interrupt_handler);
+ signal(SIGTERM, interrupt_handler);
+#else // _WIN32
+ struct sigaction sa = {0};
+ sa.sa_handler = &interrupt_handler;
+ sigaction(SIGINT, &sa, NULL);
+ sigaction(SIGTERM, &sa, NULL);
+#endif // _WIN32
+}
+
+void interrupt_deinit()
+{
+ flag_dst(&interrupt);
+}
--- /dev/null
+#ifndef _INTERRUPT_H_
+#define _INTERRUPT_H_
+
+#include <dragonstd/flag.h>
+
+void interrupt_init();
+void interrupt_deinit();
+
+extern Flag interrupt;
+
+#endif // _INTERRUPT_H_
--- /dev/null
+#include <stdlib.h>
+#include "common/item.h"
+
+void item_stack_initialize(ItemStack *stack)
+{
+ stack->type = ITEM_NONE;
+ stack->count = 1;
+ stack->data = NULL;
+
+ if (item_def[stack->type].callbacks.create)
+ item_def[stack->type].callbacks.create(stack);
+}
+
+void item_stack_destroy(ItemStack *stack)
+{
+ if (item_def[stack->type].callbacks.delete)
+ item_def[stack->type].callbacks.delete(stack);
+
+ if (stack->data) {
+ free(stack->data);
+ stack->data = NULL;
+ }
+}
+
+void item_stack_set(ItemStack *stack, ItemType type, u32 count, Blob buffer)
+{
+ item_stack_destroy(stack);
+
+ stack->type = type;
+ stack->count = count;
+ stack->data = item_def[stack->type].data_size > 0 ?
+ malloc(item_def[stack->type].data_size) : NULL;
+
+ if (item_def[stack->type].callbacks.create)
+ item_def[stack->type].callbacks.create(stack);
+
+ if (item_def[stack->type].callbacks.deserialize)
+ item_def[stack->type].callbacks.deserialize(&buffer, stack->data);
+}
+
+void item_stack_serialize(ItemStack *stack, SerializedItemStack *serialized)
+{
+ serialized->type = stack->type;
+ serialized->count = stack->count;
+ serialized->data = (Blob) {0, NULL};
+
+ if (item_def[stack->type].callbacks.serialize)
+ item_def[stack->type].callbacks.serialize(&serialized->data, stack->data);
+}
+
+void item_stack_deserialize(ItemStack *stack, SerializedItemStack *serialized)
+{
+ ItemType type = serialized->type;
+
+ if (type >= COUNT_ITEM)
+ type = ITEM_UNKNOWN;
+
+ item_stack_set(stack, type, serialized->count, serialized->data);
+}
+
+ItemDef item_def[COUNT_ITEM] = {
+ // unknown
+ {
+ .stackable = false,
+ .data_size = 0,
+ .dig_class = DIG_NONE,
+ .callbacks = {NULL},
+ },
+ // none
+ {
+ .stackable = false,
+ .data_size = 0,
+ .dig_class = DIG_NONE,
+ .callbacks = {NULL},
+ },
+ // pickaxe
+ {
+ .stackable = false,
+ .data_size = 0,
+ .dig_class = DIG_STONE,
+ .callbacks = {NULL},
+ },
+ // axe
+ {
+ .stackable = false,
+ .data_size = 0,
+ .dig_class = DIG_WOOD,
+ .callbacks = {NULL},
+ },
+ // shovel
+ {
+ .stackable = false,
+ .data_size = 0,
+ .dig_class = DIG_DIRT,
+ .callbacks = {NULL},
+ },
+};
--- /dev/null
+#ifndef _ITEM_H_
+#define _ITEM_H_
+
+#include <stdbool.h>
+#include <stddef.h>
+#include "common/dig.h"
+#include "types.h"
+
+typedef enum {
+ ITEM_UNKNOWN,
+ ITEM_NONE,
+ ITEM_PICKAXE,
+ ITEM_AXE,
+ ITEM_SHOVEL,
+ COUNT_ITEM,
+} ItemType;
+
+typedef struct {
+ ItemType type;
+ u32 count; // i know future me is going to thank me for making it big
+ void *data;
+} ItemStack;
+
+typedef struct {
+ bool stackable;
+ size_t data_size;
+ DigClass dig_class;
+ struct {
+ void (*create)(ItemStack *stack);
+ void (*delete)(ItemStack *stack);
+ void (*serialize)(Blob *buffer, void *data);
+ void (*deserialize)(Blob *buffer, void *data);
+ } callbacks;
+} ItemDef;
+
+void item_stack_initialize(ItemStack *stack);
+void item_stack_destroy(ItemStack *stack);
+
+void item_stack_set(ItemStack *stack, ItemType type, u32 count, Blob buffer);
+void item_stack_serialize(ItemStack *stack, SerializedItemStack *serialized);
+void item_stack_deserialize(ItemStack *stack, SerializedItemStack *serialized);
+
+extern ItemDef item_def[];
+
+#endif // _ITEM_H_
--- /dev/null
+#include "common/dig.h"
+#include "common/node.h"
+#include "common/terrain.h"
+#include "types.h"
+
+NodeDef node_def[COUNT_NODE] = {
+ // unknown
+ {
+ .solid = true,
+ .dig_class = DIG_NONE,
+ },
+ // air
+ {
+ .solid = false,
+ .dig_class = DIG_NONE,
+ },
+ // grass
+ {
+ .solid = true,
+ .dig_class = DIG_DIRT,
+ },
+ // dirt
+ {
+ .solid = true,
+ .dig_class = DIG_DIRT,
+ },
+ // stone
+ {
+ .solid = true,
+ .dig_class = DIG_STONE,
+ },
+ // snow
+ {
+ .solid = true,
+ .dig_class = DIG_DIRT,
+ },
+ // oak wood
+ {
+ .solid = true,
+ .dig_class = DIG_WOOD,
+ },
+ // oak leaves
+ {
+ .solid = true,
+ .dig_class = DIG_LEAVES,
+ },
+ // pine wood
+ {
+ .solid = true,
+ .dig_class = DIG_WOOD,
+ },
+ // pine leaves
+ {
+ .solid = true,
+ .dig_class = DIG_LEAVES,
+ },
+ // palm wood
+ {
+ .solid = true,
+ .dig_class = DIG_WOOD,
+ },
+ // palm leaves
+ {
+ .solid = true,
+ .dig_class = DIG_LEAVES,
+ },
+ // sand
+ {
+ .solid = true,
+ .dig_class = DIG_DIRT,
+ },
+ // water
+ {
+ .solid = false,
+ .dig_class = DIG_NONE,
+ },
+ // lava
+ {
+ .solid = false,
+ .dig_class = DIG_NONE,
+ },
+ // vulcanostone
+ {
+ .solid = true,
+ .dig_class = DIG_STONE,
+ },
+};
--- /dev/null
+#ifndef _NODE_H_
+#define _NODE_H_
+
+#include <stdbool.h>
+#include <stddef.h>
+#include "types.h"
+
+#define NODES_TREE case NODE_OAK_WOOD: case NODE_OAK_LEAVES: case NODE_PINE_WOOD: case NODE_PINE_LEAVES: case NODE_PALM_WOOD: case NODE_PALM_LEAVES:
+
+typedef enum {
+ NODE_UNKNOWN, // Used for unknown nodes received from server (caused by outdated clients)
+ NODE_AIR,
+ NODE_GRASS,
+ NODE_DIRT,
+ NODE_STONE,
+ NODE_SNOW,
+ NODE_OAK_WOOD,
+ NODE_OAK_LEAVES,
+ NODE_PINE_WOOD,
+ NODE_PINE_LEAVES,
+ NODE_PALM_WOOD,
+ NODE_PALM_LEAVES,
+ NODE_SAND,
+ NODE_WATER,
+ NODE_LAVA,
+ NODE_VULCANO_STONE,
+ COUNT_NODE, // Used for nodes in unloaded chunks
+} NodeType;
+
+struct TerrainNode;
+
+typedef struct {
+ bool solid;
+ unsigned long dig_class;
+} NodeDef;
+
+extern NodeDef node_def[];
+
+#endif
--- /dev/null
+#include "common/perlin.h"
+
+s32 seed = 0;
--- /dev/null
+#ifndef _PERLIN_H_
+#define _PERLIN_H_
+
+#include_next <perlin.h>
+#include "types.h"
+
+#define U32(x) (((u32) 1 << 31) + (x))
+
+typedef enum {
+ OFFSET_NONE,
+ OFFSET_HEIGHT,
+ OFFSET_MOUNTAIN,
+ OFFSET_OCEAN,
+ OFFSET_MOUNTAIN_HEIGHT,
+ OFFSET_BOULDER,
+ OFFSET_WETNESS,
+ OFFSET_TEXTURE_OFFSET_S,
+ OFFSET_TEXTURE_OFFSET_T,
+ OFFSET_TEMPERATURE,
+ OFFSET_VULCANO,
+ OFFSET_VULCANO_HEIGHT,
+ OFFSET_VULCANO_STONE,
+ OFFSET_VULCANO_CRATER_TOP,
+ OFFSET_HILLYNESS,
+ OFFSET_VOXEL_PROCEDURAL,
+ OFFSET_OAKTREE,
+ OFFSET_OAKTREE_AREA,
+ OFFSET_PINETREE,
+ OFFSET_PINETREE_AREA,
+ OFFSET_PINETREE_HEIGHT,
+ OFFSET_PINETREE_BRANCH,
+ OFFSET_PINETREE_BRANCH_DIR,
+ OFFSET_PALMTREE,
+ OFFSET_PALMTREE_AREA,
+} SeedOffset;
+
+extern s32 seed;
+
+#endif // _PERLIN_H_
--- /dev/null
+#include <math.h>
+#include "common/physics.h"
+
+static aabb3f64 move_box(aabb3f32 box, v3f64 pos)
+{
+ return (aabb3f64) {
+ {pos.x + box.min.x, pos.y + box.min.y, pos.z + box.min.z},
+ {pos.x + box.max.x, pos.y + box.max.y, pos.z + box.max.z},
+ };
+}
+
+static aabb3s32 round_box(aabb3f64 box)
+{
+ return (aabb3s32) {
+ {floor(box.min.x + 0.5), floor(box.min.y + 0.5), floor(box.min.z + 0.5)},
+ { ceil(box.max.x - 0.5), ceil(box.max.y - 0.5), ceil(box.max.z - 0.5)},
+ };
+}
+
+static bool is_solid(Terrain *terrain, s32 x, s32 y, s32 z)
+{
+ NodeType node = terrain_get_node(terrain, (v3s32) {x, y, z}).type;
+ return node == COUNT_NODE || node_def[node].solid;
+}
+
+bool physics_ground(Terrain *terrain, bool collide, aabb3f32 box, v3f64 *pos, v3f64 *vel)
+{
+ if (!collide)
+ return false;
+
+ if (vel->y != 0.0)
+ return false;
+
+ aabb3f64 mbox = move_box(box, *pos);
+ mbox.min.y -= 0.5;
+
+ aabb3s32 rbox = round_box(mbox);
+
+ if (mbox.min.y - (f64) rbox.min.y > 0.01)
+ return false;
+
+ for (s32 x = rbox.min.x; x <= rbox.max.x; x++)
+ for (s32 z = rbox.min.z; z <= rbox.max.z; z++)
+ if (is_solid(terrain, x, rbox.min.y, z))
+ return true;
+
+ return false;
+}
+
+bool physics_step(Terrain *terrain, bool collide, aabb3f32 box, v3f64 *pos, v3f64 *vel, v3f64 *acc, f64 t)
+{
+ v3f64 old_pos = *pos;
+
+ f64 *x = &pos->x;
+ f64 *v = &vel->x;
+ f64 *a = &acc->x;
+
+ f32 *min = &box.min.x;
+ f32 *max = &box.max.x;
+
+ static u8 idx[3][3] = {
+ {0, 1, 2},
+ {1, 0, 2},
+ {2, 0, 1},
+ };
+
+ for (u8 i = 0; i < 3; i++) {
+ f64 v_old = v[i];
+ v[i] += a[i] * t;
+ f64 v_cur = (v[i] + v_old) / 2.0;
+ if (v_cur == 0.0)
+ continue;
+
+ f64 x_old = x[i];
+ x[i] += v_cur * t;
+ if (!collide)
+ continue;
+
+ aabb3s32 box_rnd = round_box(move_box(box, *pos));
+
+ s32 dir;
+ f32 off;
+ s32 *min_rnd = &box_rnd.min.x;
+ s32 *max_rnd = &box_rnd.max.x;
+
+ if (v[i] > 0.0) {
+ dir = +1;
+ off = max[i];
+
+ min_rnd[i] = ceil(x_old + off + 0.5);
+ max_rnd[i] = floor(x[i] + off + 0.5);
+ } else {
+ dir = -1;
+ off = min[i];
+
+ min_rnd[i] = floor(x_old + off - 0.5);
+ max_rnd[i] = ceil(x[i] + off - 0.5);
+ }
+
+ max_rnd[i] += dir;
+
+ u8 i_a = idx[i][0]; // = i
+ u8 i_b = idx[i][1];
+ u8 i_c = idx[i][2];
+
+ for (s32 a = min_rnd[i_a]; a != max_rnd[i_a]; a += dir)
+ for (s32 b = min_rnd[i_b]; b <= max_rnd[i_b]; b++)
+ for (s32 c = min_rnd[i_c]; c <= max_rnd[i_c]; c++) {
+ s32 p[3];
+ p[i_a] = a;
+ p[i_b] = b;
+ p[i_c] = c;
+
+ if (is_solid(terrain, p[0], p[1], p[2])) {
+ x[i] = (f64) a - off - 0.5 * (f64) dir;
+ v[i] = 0.0;
+ goto done;
+ }
+ }
+
+ done: continue;
+ }
+
+ return !v3f64_equals(*pos, old_pos);
+}
--- /dev/null
+#ifndef _PHYSICS_H_
+#define _PHYSICS_H_
+
+#include <stdbool.h>
+#include "common/terrain.h"
+#include "types.h"
+
+bool physics_ground(Terrain *terrain, bool collide, aabb3f32 box, v3f64 *pos, v3f64 *vel);
+bool physics_step (Terrain *terrain, bool collide, aabb3f32 box, v3f64 *pos, v3f64 *vel, v3f64 *acc, f64 t);
+
+#endif // _PHYSICS_H_
--- /dev/null
+#include <assert.h>
+#include <math.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include "common/terrain.h"
+
+typedef struct {
+ v2s32 pos;
+ Tree chunks;
+ pthread_rwlock_t lock;
+} TerrainSector;
+
+static TerrainChunk *allocate_chunk(v3s32 pos)
+{
+ TerrainChunk *chunk = malloc(sizeof * chunk);
+ chunk->level = pos.y;
+ chunk->pos = pos;
+ chunk->extra = NULL;
+ pthread_rwlock_init(&chunk->lock, NULL);
+
+ CHUNK_ITERATE
+ chunk->data[x][y][z] = (TerrainNode) {NODE_UNKNOWN, NULL};
+
+ return chunk;
+}
+
+static void free_chunk(Terrain *terrain, TerrainChunk *chunk)
+{
+ if (terrain->callbacks.delete_node) CHUNK_ITERATE
+ terrain->callbacks.delete_node(&chunk->data[x][y][z]);
+
+ pthread_rwlock_destroy(&chunk->lock);
+ free(chunk);
+}
+
+static void delete_chunk(TerrainChunk *chunk, Terrain *terrain)
+{
+ if (terrain->callbacks.delete_chunk)
+ terrain->callbacks.delete_chunk(chunk);
+
+ free_chunk(terrain, chunk);
+}
+
+static void delete_sector(TerrainSector *sector, Terrain *terrain)
+{
+ tree_clr(§or->chunks, &delete_chunk, terrain, NULL, 0);
+ pthread_rwlock_destroy(§or->lock);
+ free(sector);
+}
+
+static TerrainSector *get_sector(Terrain *terrain, v2s32 pos, int mode)
+{
+ if (mode == CHUNK_MODE_CREATE)
+ pthread_rwlock_wrlock(&terrain->lock);
+ else
+ pthread_rwlock_rdlock(&terrain->lock);
+
+ TreeNode **loc = tree_nfd(&terrain->sectors, &pos, &v2s32_cmp);
+ TerrainSector *sector = NULL;
+
+ if (*loc) {
+ sector = (*loc)->dat;
+ } else if (mode == CHUNK_MODE_CREATE) {
+ sector = malloc(sizeof *sector);
+ sector->pos = pos;
+ tree_ini(§or->chunks);
+ pthread_rwlock_init(§or->lock, NULL);
+
+ tree_nmk(&terrain->sectors, loc, sector);
+ }
+
+ pthread_rwlock_unlock(&terrain->lock);
+
+ return sector;
+}
+
+Terrain *terrain_create()
+{
+ Terrain *terrain = malloc(sizeof *terrain);
+ tree_ini(&terrain->sectors);
+ pthread_rwlock_init(&terrain->lock, NULL);
+ terrain->cache = NULL;
+ pthread_rwlock_init(&terrain->cache_lock, NULL);
+ return terrain;
+}
+
+void terrain_delete(Terrain *terrain)
+{
+ tree_clr(&terrain->sectors, &delete_sector, terrain, NULL, 0);
+ pthread_rwlock_destroy(&terrain->lock);
+ pthread_rwlock_destroy(&terrain->cache_lock);
+ free(terrain);
+}
+
+TerrainChunk *terrain_get_chunk(Terrain *terrain, v3s32 pos, int mode)
+{
+ TerrainChunk *cache = NULL;
+
+ pthread_rwlock_rdlock(&terrain->cache_lock);
+ cache = terrain->cache;
+ pthread_rwlock_unlock(&terrain->cache_lock);
+
+ if (cache && v3s32_equals(cache->pos, pos))
+ return cache;
+
+ TerrainSector *sector = get_sector(terrain, (v2s32) {pos.x, pos.z}, mode);
+ if (!sector)
+ return NULL;
+
+ if (mode == CHUNK_MODE_CREATE)
+ pthread_rwlock_wrlock(§or->lock);
+ else
+ pthread_rwlock_rdlock(§or->lock);
+
+ TreeNode **loc = tree_nfd(§or->chunks, &pos.y, &s32_cmp);
+ TerrainChunk *chunk = NULL;
+
+ if (*loc) {
+ chunk = (*loc)->dat;
+
+ if (terrain->callbacks.get_chunk && !terrain->callbacks.get_chunk(chunk, mode)) {
+ chunk = NULL;
+ } else {
+ pthread_rwlock_wrlock(&terrain->cache_lock);
+ terrain->cache = chunk;
+ pthread_rwlock_unlock(&terrain->cache_lock);
+ }
+ } else if (mode == CHUNK_MODE_CREATE) {
+ tree_nmk(§or->chunks, loc, chunk = allocate_chunk(pos));
+
+ if (terrain->callbacks.create_chunk)
+ terrain->callbacks.create_chunk(chunk);
+ }
+
+ pthread_rwlock_unlock(§or->lock);
+
+ return chunk;
+}
+
+TerrainChunk *terrain_get_chunk_nodep(Terrain *terrain, v3s32 nodep, v3s32 *offset, int mode)
+{
+ TerrainChunk *chunk = terrain_get_chunk(terrain, terrain_chunkp(nodep), mode);
+ if (!chunk)
+ return NULL;
+ *offset = terrain_offset(nodep);
+ return chunk;
+}
+
+Blob terrain_serialize_chunk(__attribute__((unused)) Terrain *terrain, TerrainChunk *chunk, void (*callback)(TerrainNode *node, Blob *buffer))
+{
+ bool empty = true;
+
+ CHUNK_ITERATE {
+ if (chunk->data[x][y][z].type != NODE_AIR) {
+ empty = false;
+ break;
+ }
+ }
+
+ if (empty)
+ return (Blob) {0, NULL};
+
+ SerializedTerrainChunk serialized_chunk;
+
+ CHUNK_ITERATE {
+ TerrainNode *node = &chunk->data[x][y][z];
+ SerializedTerrainNode *serialized = &serialized_chunk.raw.nodes[x][y][z];
+
+ serialized->type = node->type;
+ serialized->data = (Blob) {0, NULL};
+
+ if (callback)
+ callback(node, &serialized->data);
+ }
+
+ Blob buffer = {0, NULL};
+ SerializedTerrainChunk_write(&buffer, &serialized_chunk);
+ SerializedTerrainChunk_free(&serialized_chunk);
+ return buffer;
+}
+
+bool terrain_deserialize_chunk(Terrain *terrain, TerrainChunk *chunk, Blob buffer, void (*callback)(TerrainNode *node, Blob buffer))
+{
+ if (buffer.siz == 0) {
+ CHUNK_ITERATE {
+ if (terrain->callbacks.delete_node)
+ terrain->callbacks.delete_node(&chunk->data[x][y][z]);
+
+ chunk->data[x][y][z] = (TerrainNode) {NODE_AIR, NULL};
+ }
+
+ return true;
+ }
+
+ // it's important to copy Blobs that have been malloc'd before reading from them
+ // because reading from a Blob modifies its data and size pointer,
+ // but does not free anything
+ SerializedTerrainChunk serialized_chunk = {0};
+ bool success = SerializedTerrainChunk_read(&buffer, &serialized_chunk);
+
+ if (success) CHUNK_ITERATE {
+ if (terrain->callbacks.delete_node)
+ terrain->callbacks.delete_node(&chunk->data[x][y][z]);
+
+ TerrainNode *node = &chunk->data[x][y][z];
+ SerializedTerrainNode *serialized = &serialized_chunk.raw.nodes[x][y][z];
+
+ node->type = serialized->type;
+
+ if (callback)
+ callback(node, serialized->data);
+ }
+
+ SerializedTerrainChunk_free(&serialized_chunk);
+ return success;
+}
+
+TerrainNode terrain_get_node(Terrain *terrain, v3s32 pos)
+{
+ v3s32 offset;
+ TerrainChunk *chunk = terrain_get_chunk_nodep(terrain, pos, &offset, CHUNK_MODE_PASSIVE);
+ if (!chunk)
+ return (TerrainNode) {COUNT_NODE, NULL};
+
+ assert(pthread_rwlock_rdlock(&chunk->lock) == 0);
+ TerrainNode node = chunk->data[offset.x][offset.y][offset.z];
+ pthread_rwlock_unlock(&chunk->lock);
+
+ return node;
+}
+
+v3s32 terrain_chunkp(v3s32 pos)
+{
+ return (v3s32) {
+ floor((double) pos.x / (double) CHUNK_SIZE),
+ floor((double) pos.y / (double) CHUNK_SIZE),
+ floor((double) pos.z / (double) CHUNK_SIZE)};
+}
+
+v3s32 terrain_offset(v3s32 pos)
+{
+ return (v3s32) {
+ (u32) pos.x % CHUNK_SIZE,
+ (u32) pos.y % CHUNK_SIZE,
+ (u32) pos.z % CHUNK_SIZE};
+}
--- /dev/null
+#ifndef _TERRAIN_H_
+#define _TERRAIN_H_
+
+#include <dragonstd/list.h>
+#include <dragonstd/tree.h>
+#include <stdbool.h>
+#include <pthread.h>
+#include "common/node.h"
+#include "types.h"
+
+#define CHUNK_ITERATE \
+ for (s32 x = 0; x < CHUNK_SIZE; x++) \
+ for (s32 y = 0; y < CHUNK_SIZE; y++) \
+ for (s32 z = 0; z < CHUNK_SIZE; z++)
+
+#define CHUNK_MODE_PASSIVE 0
+#define CHUNK_MODE_CREATE 1
+
+typedef struct TerrainNode {
+ NodeType type;
+ void *data;
+} TerrainNode;
+
+typedef TerrainNode TerrainChunkData[CHUNK_SIZE][CHUNK_SIZE][CHUNK_SIZE];
+
+typedef struct {
+ s32 level;
+ v3s32 pos;
+ TerrainChunkData data;
+ void *extra;
+ pthread_rwlock_t lock;
+} TerrainChunk;
+
+typedef struct {
+ Tree sectors;
+ pthread_rwlock_t lock;
+ TerrainChunk *cache;
+ pthread_rwlock_t cache_lock;
+ struct {
+ void (*create_chunk)(TerrainChunk *chunk);
+ void (*delete_chunk)(TerrainChunk *chunk);
+ bool (*get_chunk)(TerrainChunk *chunk, int mode);
+ void (*delete_node)(TerrainNode *node);
+ } callbacks;
+} Terrain;
+
+Terrain *terrain_create();
+void terrain_delete(Terrain *terrain);
+
+TerrainChunk *terrain_get_chunk(Terrain *terrain, v3s32 pos, int mode);
+TerrainChunk *terrain_get_chunk_nodep(Terrain *terrain, v3s32 node_pos, v3s32 *offset, int mode);
+
+Blob terrain_serialize_chunk(Terrain *terrain, TerrainChunk *chunk, void (*callback)(TerrainNode *node, Blob *buffer));
+bool terrain_deserialize_chunk(Terrain *terrain, TerrainChunk *chunk, Blob buffer, void (*callback)(TerrainNode *node, Blob buffer));
+
+TerrainNode terrain_get_node(Terrain *terrain, v3s32 pos);
+
+v3s32 terrain_chunkp(v3s32 pos);
+v3s32 terrain_offset(v3s32 pos);
+
+#endif
+++ /dev/null
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-#include "config.h"
-
-void config_read(char *path, ConfigEntry *entries, size_t num_entries)
-{
- FILE *f = fopen(path, "r");
-
- if (!f)
- return;
-
- printf("[info] reading config from %s\n", path);
-
- while (!feof(f)) {
- char key[BUFSIZ];
- if (!fscanf(f, "%s", key))
- break;
-
- bool found = false;
- for (size_t i = 0; i < num_entries; i++) {
- ConfigEntry *entry = &entries[i];
- if (strcmp(key, entry->key) == 0) {
- bool valid = false;
-
- switch (entry->type) {
- case CONFIG_STRING: {
- char value[BUFSIZ];
-
- if (!fscanf(f, "%s", value))
- break;
-
- valid = true;
-
- char **entry_value = entry->value;
-
- if (*entry_value)
- free(*entry_value);
- *entry_value = strdup(value);
-
- break;
- }
-
- case CONFIG_INT:
- if (fscanf(f, "%d", (int *) entry->value))
- valid = true;
-
- break;
-
- case CONFIG_UINT:
- if (fscanf(f, "%u", (unsigned int *) entry->value))
- valid = true;
-
- break;
-
- case CONFIG_FLOAT:
- if (fscanf(f, "%lf", (double *) entry->value))
- valid = true;
-
- break;
-
- case CONFIG_BOOL: {
- char value[BUFSIZ];
-
- if (!fscanf(f, "%s", value))
- break;
-
- valid = true;
-
- if (strcmp(value, "on") == 0 || strcmp(value, "yes") == 0 || strcmp(value, "true") == 0)
- *(bool *) entry->value = true;
- else if (strcmp(value, "off") == 0 || strcmp(value, "no") == 0 || strcmp(value, "false") == 0)
- *(bool *) entry->value = false;
- else
- valid = false;
-
- break;
- }
- }
-
- if (!valid)
- fprintf(stderr, "[warning] invalid value for setting %s in %s\n", key, path);
-
- found = true;
- break;
- }
- }
-
- if (!found)
- fprintf(stderr, "[warning] unknown setting %s in %s\n", key, path);
- }
-
- fclose(f);
-}
-
-void config_free(ConfigEntry *entries, size_t num_entries)
-{
- for (size_t i = 0; i < num_entries; i++) {
- ConfigEntry *entry = &entries[i];
-
- if (entry->type == CONFIG_STRING) {
- char **entry_value = entry->value;
-
- if (*entry_value)
- free(*entry_value);
- }
- }
-}
+++ /dev/null
-#ifndef _CONFIG_H_
-#define _CONFIG_H_
-
-#include <stddef.h>
-
-typedef enum {
- CONFIG_STRING,
- CONFIG_INT,
- CONFIG_UINT,
- CONFIG_FLOAT,
- CONFIG_BOOL,
-} ConfigType;
-
-typedef struct {
- ConfigType type;
- char *key;
- void *value;
-} ConfigEntry;
-
-void config_read(char *path, ConfigEntry *entries, size_t num_entries);
-void config_free(ConfigEntry *entries, size_t num_entires);
-
-#endif // _CONFIG_H_
+++ /dev/null
-#include <math.h>
-#include <time.h>
-#include "day.h"
-
-bool timelapse = false;
-static f64 time_of_day_offset;
-
-f64 get_unix_time()
-{
- struct timespec ts;
- clock_gettime(CLOCK_REALTIME, &ts);
- return ((f64) ts.tv_sec + ts.tv_nsec / 1.0e9) * (timelapse ? 100.0 : 1.0);
-}
-
-f64 get_time_of_day()
-{
- return fmod(get_unix_time() - time_of_day_offset, MINUTES_PER_DAY);
-}
-
-void set_time_of_day(f64 new_time)
-{
- time_of_day_offset = get_unix_time() - new_time;
-}
-
-f64 get_sun_angle()
-{
- return 2.0 * M_PI * (f64) get_time_of_day() / MINUTES_PER_DAY + M_PI;
-}
-
-f64 get_daylight()
-{
- return f64_clamp(cos(get_sun_angle()) * 2.0 + 0.5, 0.0, 1.0);
-}
-
-void split_time_of_day(int *hours, int *minutes)
-{
- int time_of_day = get_time_of_day();
-
- *minutes = time_of_day % MINUTES_PER_HOUR;
- *hours = time_of_day / MINUTES_PER_HOUR;
-}
+++ /dev/null
-#ifndef _DAY_H_
-#define _DAY_H_
-
-#include <stdbool.h>
-#include "types.h"
-
-#define MINUTES_PER_HOUR 60
-#define HOURS_PER_DAY 24
-#define MINUTES_PER_DAY (HOURS_PER_DAY * MINUTES_PER_HOUR)
-
-// 1 second in real life = 1 minute ingame
-
-f64 get_time_of_day();
-void set_time_of_day(f64 new_time);
-f64 get_sun_angle();
-f64 get_daylight();
-void split_time_of_day(int *hours, int *minutes);
-
-extern bool timelapse;
-
-#endif // _DAY_H_
+++ /dev/null
-#!/bin/bash
-
-if ! make -j$(nproc); then
- exit 1
-fi
-
-DEBUG_DIR=/tmp/dragonblocks_alpha_debug_$$/
-mkdir $DEBUG_DIR
-
-echo "singleplayer" > $DEBUG_DIR/name
-
-COMMON="set confirm off
-handle SIGTERM nostop print pass
-handle SIGPIPE nostop noprint pass
-set height 0
-set \$_exitcode=1
-define hook-stop
- if \$_exitcode == 0
- quit
- end
-end
-"
-
-echo "$COMMON
-break gl_error
-run \"[::1]:4000\" < $DEBUG_DIR/name
-" > $DEBUG_DIR/client_script
-
-echo "$COMMON
-set print thread-events off
-run \"[::1]:4000\"
-" > $DEBUG_DIR/server_script
-
-alacritty -e bash -c "
- echo \$\$ > $DEBUG_DIR/server_pid
- exec gdb --command $DEBUG_DIR/server_script ./dragonblocks_server
-" &
-sleep 0.5
-
-gdb --command $DEBUG_DIR/client_script ./dragonblocks
-
-kill `cat $DEBUG_DIR/server_pid`
-
-rm -rf $DEBUG_DIR
+++ /dev/null
-#!/bin/bash
-COMMAND="./debug.sh"
-
-if [[ $1 == "terrain" ]]; then
- COMMAND="./debug_terrain.sh"
-fi
-
-while true; do
- if ! $COMMAND; then
- read
- fi
-done
+++ /dev/null
-#!/bin/bash
-rm -f *.sqlite
-./debug.sh
+++ /dev/null
-#ifndef _DIG_H_
-#define _DIG_H_
-
-typedef enum {
- DIG_NONE = 0x0,
- DIG_STONE = 0x01,
- DIG_WOOD = 0x02,
- DIG_DIRT = 0x04,
- DIG_LEAVES = 0x08,
-} DigClass;
-
-#endif // _DIG_H_
+++ /dev/null
-#ifndef _ENTITY_H_
-#define _ENTITY_H_
-
-// ET phone home
-typedef enum {
- ENTITY_LOCALPLAYER,
- ENTITY_PLAYER,
- COUNT_ENTITY,
-} EntityType;
-
-#endif // _ENTITY_H_
+++ /dev/null
-#include "environment.h"
-#include "perlin.h"
-
-f64 get_humidity(v3s32 pos)
-{
- return smooth2d(U32(pos.x) / 128.0, U32(pos.z) / 128.0, 0, seed + OFFSET_WETNESS) * 0.5 + 0.5;
-}
-
-f64 get_temperature(v3s32 pos)
-{
- return smooth2d(U32(pos.x) / 128.0, U32(pos.z) / 128.0, 0, seed + OFFSET_TEMPERATURE) * 0.5 + 0.5 - (pos.y - 32.0) / 64.0;
-}
+++ /dev/null
-#ifndef _ENVIRONMENT_H_
-#define _ENVIRONMENT_H_
-
-#include "types.h"
-
-f64 get_humidity(v3s32 pos);
-f64 get_temperature(v3s32 pos);
-
-#endif // _ENVIRONMENT_H_
+++ /dev/null
-#include "facedir.h"
-
-v3s32 facedir[6] = {
- {+0, +0, -1},
- {+0, +0, +1},
- {-1, +0, +0},
- {+1, +0, +0},
- {+0, -1, +0},
- {+0, +1, +0},
-};
+++ /dev/null
-#ifndef _FACEDIR_H_
-#define _FACEDIR_H_
-
-#include "types.h"
-
-extern v3s32 facedir[];
-
-#endif // _FACEDIR_H_
+++ /dev/null
-#include <signal.h>
-#include <stdio.h>
-#include <string.h>
-#include "interrupt.h"
-
-Flag interrupt;
-
-#ifdef _WIN32
-
-// just the signals we need, for Win32
-static const char *strsignal(int sig)
-{
- switch (sig) {
- case SIGINT:
- return "Interrupted";
-
- case SIGTERM:
- return "Terminated";
-
- default:
- return "Unknown signal";
- }
-}
-
-#endif // _WIN32
-
-static void interrupt_handler(int sig)
-{
- fprintf(stderr, "%s\n", strsignal(sig));
- flag_set(&interrupt);
-}
-
-void interrupt_init()
-{
- flag_ini(&interrupt);
-
-#ifdef _WIN32
- signal(SIGINT, interrupt_handler);
- signal(SIGTERM, interrupt_handler);
-#else // _WIN32
- struct sigaction sa = {0};
- sa.sa_handler = &interrupt_handler;
- sigaction(SIGINT, &sa, NULL);
- sigaction(SIGTERM, &sa, NULL);
-#endif // _WIN32
-}
-
-void interrupt_deinit()
-{
- flag_dst(&interrupt);
-}
+++ /dev/null
-#ifndef _INTERRUPT_H_
-#define _INTERRUPT_H_
-
-#include <dragonstd/flag.h>
-
-void interrupt_init();
-void interrupt_deinit();
-
-extern Flag interrupt;
-
-#endif // _INTERRUPT_H_
+++ /dev/null
-#include <stdlib.h>
-#include "item.h"
-
-void item_stack_initialize(ItemStack *stack)
-{
- stack->type = ITEM_NONE;
- stack->count = 1;
- stack->data = NULL;
-
- if (item_def[stack->type].callbacks.create)
- item_def[stack->type].callbacks.create(stack);
-}
-
-void item_stack_destroy(ItemStack *stack)
-{
- if (item_def[stack->type].callbacks.delete)
- item_def[stack->type].callbacks.delete(stack);
-
- if (stack->data) {
- free(stack->data);
- stack->data = NULL;
- }
-}
-
-void item_stack_set(ItemStack *stack, ItemType type, u32 count, Blob buffer)
-{
- item_stack_destroy(stack);
-
- stack->type = type;
- stack->count = count;
- stack->data = item_def[stack->type].data_size > 0 ?
- malloc(item_def[stack->type].data_size) : NULL;
-
- if (item_def[stack->type].callbacks.create)
- item_def[stack->type].callbacks.create(stack);
-
- if (item_def[stack->type].callbacks.deserialize)
- item_def[stack->type].callbacks.deserialize(&buffer, stack->data);
-}
-
-void item_stack_serialize(ItemStack *stack, SerializedItemStack *serialized)
-{
- serialized->type = stack->type;
- serialized->count = stack->count;
- serialized->data = (Blob) {0, NULL};
-
- if (item_def[stack->type].callbacks.serialize)
- item_def[stack->type].callbacks.serialize(&serialized->data, stack->data);
-}
-
-void item_stack_deserialize(ItemStack *stack, SerializedItemStack *serialized)
-{
- ItemType type = serialized->type;
-
- if (type >= COUNT_ITEM)
- type = ITEM_UNKNOWN;
-
- item_stack_set(stack, type, serialized->count, serialized->data);
-}
-
-ItemDef item_def[COUNT_ITEM] = {
- // unknown
- {
- .stackable = false,
- .data_size = 0,
- .dig_class = DIG_NONE,
- .callbacks = {NULL},
- },
- // none
- {
- .stackable = false,
- .data_size = 0,
- .dig_class = DIG_NONE,
- .callbacks = {NULL},
- },
- // pickaxe
- {
- .stackable = false,
- .data_size = 0,
- .dig_class = DIG_STONE,
- .callbacks = {NULL},
- },
- // axe
- {
- .stackable = false,
- .data_size = 0,
- .dig_class = DIG_WOOD,
- .callbacks = {NULL},
- },
- // shovel
- {
- .stackable = false,
- .data_size = 0,
- .dig_class = DIG_DIRT,
- .callbacks = {NULL},
- },
-};
+++ /dev/null
-#ifndef _ITEM_H_
-#define _ITEM_H_
-
-#include <stdbool.h>
-#include <stddef.h>
-#include "dig.h"
-#include "types.h"
-
-typedef enum {
- ITEM_UNKNOWN,
- ITEM_NONE,
- ITEM_PICKAXE,
- ITEM_AXE,
- ITEM_SHOVEL,
- COUNT_ITEM,
-} ItemType;
-
-typedef struct {
- ItemType type;
- u32 count; // i know future me is going to thank me for making it big
- void *data;
-} ItemStack;
-
-typedef struct {
- bool stackable;
- size_t data_size;
- DigClass dig_class;
- struct {
- void (*create)(ItemStack *stack);
- void (*delete)(ItemStack *stack);
- void (*serialize)(Blob *buffer, void *data);
- void (*deserialize)(Blob *buffer, void *data);
- } callbacks;
-} ItemDef;
-
-void item_stack_initialize(ItemStack *stack);
-void item_stack_destroy(ItemStack *stack);
-
-void item_stack_set(ItemStack *stack, ItemType type, u32 count, Blob buffer);
-void item_stack_serialize(ItemStack *stack, SerializedItemStack *serialized);
-void item_stack_deserialize(ItemStack *stack, SerializedItemStack *serialized);
-
-extern ItemDef item_def[];
-
-#endif // _ITEM_H_
--- /dev/null
+set(CMAKE_SYSTEM_NAME Windows)
+
+set(CMAKE_C_COMPILER i686-w64-mingw32-gcc-posix)
+set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++-posix)
+++ /dev/null
-#include "dig.h"
-#include "node.h"
-#include "terrain.h"
-#include "types.h"
-
-NodeDef node_def[COUNT_NODE] = {
- // unknown
- {
- .solid = true,
- .dig_class = DIG_NONE,
- },
- // air
- {
- .solid = false,
- .dig_class = DIG_NONE,
- },
- // grass
- {
- .solid = true,
- .dig_class = DIG_DIRT,
- },
- // dirt
- {
- .solid = true,
- .dig_class = DIG_DIRT,
- },
- // stone
- {
- .solid = true,
- .dig_class = DIG_STONE,
- },
- // snow
- {
- .solid = true,
- .dig_class = DIG_DIRT,
- },
- // oak wood
- {
- .solid = true,
- .dig_class = DIG_WOOD,
- },
- // oak leaves
- {
- .solid = true,
- .dig_class = DIG_LEAVES,
- },
- // pine wood
- {
- .solid = true,
- .dig_class = DIG_WOOD,
- },
- // pine leaves
- {
- .solid = true,
- .dig_class = DIG_LEAVES,
- },
- // palm wood
- {
- .solid = true,
- .dig_class = DIG_WOOD,
- },
- // palm leaves
- {
- .solid = true,
- .dig_class = DIG_LEAVES,
- },
- // sand
- {
- .solid = true,
- .dig_class = DIG_DIRT,
- },
- // water
- {
- .solid = false,
- .dig_class = DIG_NONE,
- },
- // lava
- {
- .solid = false,
- .dig_class = DIG_NONE,
- },
- // vulcanostone
- {
- .solid = true,
- .dig_class = DIG_STONE,
- },
-};
+++ /dev/null
-#ifndef _NODE_H_
-#define _NODE_H_
-
-#include <stdbool.h>
-#include <stddef.h>
-#include "types.h"
-
-#define NODES_TREE case NODE_OAK_WOOD: case NODE_OAK_LEAVES: case NODE_PINE_WOOD: case NODE_PINE_LEAVES: case NODE_PALM_WOOD: case NODE_PALM_LEAVES:
-
-typedef enum {
- NODE_UNKNOWN, // Used for unknown nodes received from server (caused by outdated clients)
- NODE_AIR,
- NODE_GRASS,
- NODE_DIRT,
- NODE_STONE,
- NODE_SNOW,
- NODE_OAK_WOOD,
- NODE_OAK_LEAVES,
- NODE_PINE_WOOD,
- NODE_PINE_LEAVES,
- NODE_PALM_WOOD,
- NODE_PALM_LEAVES,
- NODE_SAND,
- NODE_WATER,
- NODE_LAVA,
- NODE_VULCANO_STONE,
- COUNT_NODE, // Used for nodes in unloaded chunks
-} NodeType;
-
-struct TerrainNode;
-
-typedef struct {
- bool solid;
- unsigned long dig_class;
-} NodeDef;
-
-extern NodeDef node_def[];
-
-#endif
+++ /dev/null
-#include "perlin.h"
-
-s32 seed = 0;
+++ /dev/null
-#ifndef _PERLIN_H_
-#define _PERLIN_H_
-
-#include <perlin/perlin.h>
-#include "types.h"
-
-#define U32(x) (((u32) 1 << 31) + (x))
-
-typedef enum {
- OFFSET_NONE,
- OFFSET_HEIGHT,
- OFFSET_MOUNTAIN,
- OFFSET_OCEAN,
- OFFSET_MOUNTAIN_HEIGHT,
- OFFSET_BOULDER,
- OFFSET_WETNESS,
- OFFSET_TEXTURE_OFFSET_S,
- OFFSET_TEXTURE_OFFSET_T,
- OFFSET_TEMPERATURE,
- OFFSET_VULCANO,
- OFFSET_VULCANO_HEIGHT,
- OFFSET_VULCANO_STONE,
- OFFSET_VULCANO_CRATER_TOP,
- OFFSET_HILLYNESS,
- OFFSET_VOXEL_PROCEDURAL,
- OFFSET_OAKTREE,
- OFFSET_OAKTREE_AREA,
- OFFSET_PINETREE,
- OFFSET_PINETREE_AREA,
- OFFSET_PINETREE_HEIGHT,
- OFFSET_PINETREE_BRANCH,
- OFFSET_PINETREE_BRANCH_DIR,
- OFFSET_PALMTREE,
- OFFSET_PALMTREE_AREA,
-} SeedOffset;
-
-extern s32 seed;
-
-#endif // _PERLIN_H_
+++ /dev/null
-#include <math.h>
-#include "physics.h"
-
-static aabb3f64 move_box(aabb3f32 box, v3f64 pos)
-{
- return (aabb3f64) {
- {pos.x + box.min.x, pos.y + box.min.y, pos.z + box.min.z},
- {pos.x + box.max.x, pos.y + box.max.y, pos.z + box.max.z},
- };
-}
-
-static aabb3s32 round_box(aabb3f64 box)
-{
- return (aabb3s32) {
- {floor(box.min.x + 0.5), floor(box.min.y + 0.5), floor(box.min.z + 0.5)},
- { ceil(box.max.x - 0.5), ceil(box.max.y - 0.5), ceil(box.max.z - 0.5)},
- };
-}
-
-static bool is_solid(Terrain *terrain, s32 x, s32 y, s32 z)
-{
- NodeType node = terrain_get_node(terrain, (v3s32) {x, y, z}).type;
- return node == COUNT_NODE || node_def[node].solid;
-}
-
-bool physics_ground(Terrain *terrain, bool collide, aabb3f32 box, v3f64 *pos, v3f64 *vel)
-{
- if (!collide)
- return false;
-
- if (vel->y != 0.0)
- return false;
-
- aabb3f64 mbox = move_box(box, *pos);
- mbox.min.y -= 0.5;
-
- aabb3s32 rbox = round_box(mbox);
-
- if (mbox.min.y - (f64) rbox.min.y > 0.01)
- return false;
-
- for (s32 x = rbox.min.x; x <= rbox.max.x; x++)
- for (s32 z = rbox.min.z; z <= rbox.max.z; z++)
- if (is_solid(terrain, x, rbox.min.y, z))
- return true;
-
- return false;
-}
-
-bool physics_step(Terrain *terrain, bool collide, aabb3f32 box, v3f64 *pos, v3f64 *vel, v3f64 *acc, f64 t)
-{
- v3f64 old_pos = *pos;
-
- f64 *x = &pos->x;
- f64 *v = &vel->x;
- f64 *a = &acc->x;
-
- f32 *min = &box.min.x;
- f32 *max = &box.max.x;
-
- static u8 idx[3][3] = {
- {0, 1, 2},
- {1, 0, 2},
- {2, 0, 1},
- };
-
- for (u8 i = 0; i < 3; i++) {
- f64 v_old = v[i];
- v[i] += a[i] * t;
- f64 v_cur = (v[i] + v_old) / 2.0;
- if (v_cur == 0.0)
- continue;
-
- f64 x_old = x[i];
- x[i] += v_cur * t;
- if (!collide)
- continue;
-
- aabb3s32 box_rnd = round_box(move_box(box, *pos));
-
- s32 dir;
- f32 off;
- s32 *min_rnd = &box_rnd.min.x;
- s32 *max_rnd = &box_rnd.max.x;
-
- if (v[i] > 0.0) {
- dir = +1;
- off = max[i];
-
- min_rnd[i] = ceil(x_old + off + 0.5);
- max_rnd[i] = floor(x[i] + off + 0.5);
- } else {
- dir = -1;
- off = min[i];
-
- min_rnd[i] = floor(x_old + off - 0.5);
- max_rnd[i] = ceil(x[i] + off - 0.5);
- }
-
- max_rnd[i] += dir;
-
- u8 i_a = idx[i][0]; // = i
- u8 i_b = idx[i][1];
- u8 i_c = idx[i][2];
-
- for (s32 a = min_rnd[i_a]; a != max_rnd[i_a]; a += dir)
- for (s32 b = min_rnd[i_b]; b <= max_rnd[i_b]; b++)
- for (s32 c = min_rnd[i_c]; c <= max_rnd[i_c]; c++) {
- s32 p[3];
- p[i_a] = a;
- p[i_b] = b;
- p[i_c] = c;
-
- if (is_solid(terrain, p[0], p[1], p[2])) {
- x[i] = (f64) a - off - 0.5 * (f64) dir;
- v[i] = 0.0;
- goto done;
- }
- }
-
- done: continue;
- }
-
- return !v3f64_equals(*pos, old_pos);
-}
+++ /dev/null
-#ifndef _PHYSICS_H_
-#define _PHYSICS_H_
-
-#include <stdbool.h>
-#include "terrain.h"
-#include "types.h"
-
-bool physics_ground(Terrain *terrain, bool collide, aabb3f32 box, v3f64 *pos, v3f64 *vel);
-bool physics_step (Terrain *terrain, bool collide, aabb3f32 box, v3f64 *pos, v3f64 *vel, v3f64 *acc, f64 t);
-
-#endif // _PHYSICS_H_
#ifndef _BIOMES_H_
#define _BIOMES_H_
-#include "perlin.h"
-#include "terrain.h"
+#include "common/perlin.h"
+#include "common/terrain.h"
#include "types.h"
typedef enum {
-#include <endian.h/endian.h>
+#include <endian.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sqlite3.h>
#include <time.h>
-#include "day.h"
+#include "common/day.h"
+#include "common/perlin.h"
#include "server/database.h"
#include "server/server_node.h"
#include "server/server_terrain.h"
-#include "perlin.h"
static sqlite3 *terrain_database;
static sqlite3 *meta_database;
#define _DATABASE_H_
#include <stdbool.h>
-#include "terrain.h"
+#include "common/terrain.h"
#include "types.h"
bool database_init(); // open and initialize SQLite3 databases
-#include <getline/getline.h>
+#include <getline.h>
#include <stdio.h>
#include <stdlib.h>
+#include "common/terrain.h"
#include "server/schematic.h"
#include "server/server_node.h"
-#include "terrain.h"
void schematic_load(List *schematic, const char *path, SchematicMapping *mappings, size_t num_mappings)
{
#include <dragonstd/list.h>
#include <stdbool.h>
#include <stddef.h>
-#include "node.h"
+#include "common/node.h"
#include "server/server_terrain.h"
#include "types.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
-#include "interrupt.h"
+#include "common/interrupt.h"
#include "server/database.h"
#include "server/server.h"
#include "server/server_item.h"
-#include "config.h"
+#include "common/config.h"
#include "server/server_config.h"
struct ServerConfig server_config = {
#include <assert.h>
-#include "node.h"
+#include "common/node.h"
#include "server/server_item.h"
#include "server/server_node.h"
#include "server/server_terrain.h"
#define _SERVER_ITEM_H_
#include <stdbool.h>
-#include "item.h"
+#include "common/item.h"
#include "server/server_player.h"
#include "types.h"
#ifndef _SERVER_NODE_H_
#define _SERVER_NODE_H_
-#include "terrain.h"
+#include "common/terrain.h"
#include "types.h"
TerrainNode server_node_create(NodeType type);
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
-#include "day.h"
-#include "entity.h"
-#include "perlin.h"
+#include "common/day.h"
+#include "common/entity.h"
+#include "common/perlin.h"
#include "server/database.h"
#include "server/server_config.h"
#include "server/server_player.h"
#include <dragonstd/refcount.h>
#include <pthread.h>
#include <stdbool.h>
-#include "item.h"
+#include "common/item.h"
#include "types.h"
typedef struct {
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include "interrupt.h"
+#include "common/interrupt.h"
+#include "common/terrain.h"
#include "server/database.h"
#include "server/schematic.h"
#include "server/server_config.h"
#include "server/server_node.h"
#include "server/server_terrain.h"
#include "server/terrain_gen.h"
-#include "terrain.h"
// this file is too long
Terrain *server_terrain;
list_ini(&changed_chunks);
List spawn_hut;
- schematic_load(&spawn_hut, RESSOURCE_PATH "schematics/spawn_hut.txt", (SchematicMapping[]) {
+ schematic_load(&spawn_hut, ASSET_PATH "schematics/spawn_hut.txt", (SchematicMapping[]) {
{
.color = {0x7d, 0x54, 0x35},
.type = NODE_OAK_WOOD,
#include <dragonstd/list.h>
#include <pthread.h>
+#include "common/terrain.h"
#include "server/server_player.h"
-#include "terrain.h"
#include "types.h"
typedef enum {
#include <assert.h>
#include <math.h>
#include <stdlib.h>
-#include "environment.h"
-#include "perlin.h"
+#include "common/environment.h"
+#include "common/perlin.h"
#include "server/biomes.h"
#include "server/server_node.h"
#include "server/server_terrain.h"
#ifndef _TERRAIN_GEN_H_
#define _TERRAIN_GEN_H_
+#include "common/terrain.h"
#include "server/server_terrain.h"
-#include "terrain.h"
s32 terrain_gen_get_base_height(v2s32 pos);
void terrain_gen_chunk(TerrainChunk *chunk, List *changed_chunks); // generate a chunk (does not manage chunk state or threading)
#include <dragonstd/list.h>
#include <stdbool.h>
-#include "perlin.h"
-#include "terrain.h"
+#include "common/perlin.h"
+#include "common/terrain.h"
#include "types.h"
#define NUM_TREES 3
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
-#include "facedir.h"
+#include "common/facedir.h"
#include "server/server_node.h"
#include "server/server_terrain.h"
#include "server/tree_physics.h"
#include <stdlib.h>
-#include "voxel_depth_search.h"
+#include "server/voxel_depth_search.h"
v3s32 dirs[6] = {
{+0, -1, +0}, // this is commonly used to find ground, search downwards first
#include <stdlib.h>
#include <pthread.h>
-#include "color.h"
-#include "perlin.h"
+#include "common/color.h"
+#include "common/perlin.h"
#include "server/terrain_gen.h"
#include "server/voxel_procedural.h"
#define _VOXEL_PROCEDURAL_H_
#include <dragonstd/list.h>
-#include <linmath.h/linmath.h>
+#include <linmath.h>
#include "server/server_terrain.h"
#include "types.h"
+++ /dev/null
-#include <assert.h>
-#include <math.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include "terrain.h"
-
-typedef struct {
- v2s32 pos;
- Tree chunks;
- pthread_rwlock_t lock;
-} TerrainSector;
-
-static TerrainChunk *allocate_chunk(v3s32 pos)
-{
- TerrainChunk *chunk = malloc(sizeof * chunk);
- chunk->level = pos.y;
- chunk->pos = pos;
- chunk->extra = NULL;
- pthread_rwlock_init(&chunk->lock, NULL);
-
- CHUNK_ITERATE
- chunk->data[x][y][z] = (TerrainNode) {NODE_UNKNOWN, NULL};
-
- return chunk;
-}
-
-static void free_chunk(Terrain *terrain, TerrainChunk *chunk)
-{
- if (terrain->callbacks.delete_node) CHUNK_ITERATE
- terrain->callbacks.delete_node(&chunk->data[x][y][z]);
-
- pthread_rwlock_destroy(&chunk->lock);
- free(chunk);
-}
-
-static void delete_chunk(TerrainChunk *chunk, Terrain *terrain)
-{
- if (terrain->callbacks.delete_chunk)
- terrain->callbacks.delete_chunk(chunk);
-
- free_chunk(terrain, chunk);
-}
-
-static void delete_sector(TerrainSector *sector, Terrain *terrain)
-{
- tree_clr(§or->chunks, &delete_chunk, terrain, NULL, 0);
- pthread_rwlock_destroy(§or->lock);
- free(sector);
-}
-
-static TerrainSector *get_sector(Terrain *terrain, v2s32 pos, int mode)
-{
- if (mode == CHUNK_MODE_CREATE)
- pthread_rwlock_wrlock(&terrain->lock);
- else
- pthread_rwlock_rdlock(&terrain->lock);
-
- TreeNode **loc = tree_nfd(&terrain->sectors, &pos, &v2s32_cmp);
- TerrainSector *sector = NULL;
-
- if (*loc) {
- sector = (*loc)->dat;
- } else if (mode == CHUNK_MODE_CREATE) {
- sector = malloc(sizeof *sector);
- sector->pos = pos;
- tree_ini(§or->chunks);
- pthread_rwlock_init(§or->lock, NULL);
-
- tree_nmk(&terrain->sectors, loc, sector);
- }
-
- pthread_rwlock_unlock(&terrain->lock);
-
- return sector;
-}
-
-Terrain *terrain_create()
-{
- Terrain *terrain = malloc(sizeof *terrain);
- tree_ini(&terrain->sectors);
- pthread_rwlock_init(&terrain->lock, NULL);
- terrain->cache = NULL;
- pthread_rwlock_init(&terrain->cache_lock, NULL);
- return terrain;
-}
-
-void terrain_delete(Terrain *terrain)
-{
- tree_clr(&terrain->sectors, &delete_sector, terrain, NULL, 0);
- pthread_rwlock_destroy(&terrain->lock);
- pthread_rwlock_destroy(&terrain->cache_lock);
- free(terrain);
-}
-
-TerrainChunk *terrain_get_chunk(Terrain *terrain, v3s32 pos, int mode)
-{
- TerrainChunk *cache = NULL;
-
- pthread_rwlock_rdlock(&terrain->cache_lock);
- cache = terrain->cache;
- pthread_rwlock_unlock(&terrain->cache_lock);
-
- if (cache && v3s32_equals(cache->pos, pos))
- return cache;
-
- TerrainSector *sector = get_sector(terrain, (v2s32) {pos.x, pos.z}, mode);
- if (!sector)
- return NULL;
-
- if (mode == CHUNK_MODE_CREATE)
- pthread_rwlock_wrlock(§or->lock);
- else
- pthread_rwlock_rdlock(§or->lock);
-
- TreeNode **loc = tree_nfd(§or->chunks, &pos.y, &s32_cmp);
- TerrainChunk *chunk = NULL;
-
- if (*loc) {
- chunk = (*loc)->dat;
-
- if (terrain->callbacks.get_chunk && !terrain->callbacks.get_chunk(chunk, mode)) {
- chunk = NULL;
- } else {
- pthread_rwlock_wrlock(&terrain->cache_lock);
- terrain->cache = chunk;
- pthread_rwlock_unlock(&terrain->cache_lock);
- }
- } else if (mode == CHUNK_MODE_CREATE) {
- tree_nmk(§or->chunks, loc, chunk = allocate_chunk(pos));
-
- if (terrain->callbacks.create_chunk)
- terrain->callbacks.create_chunk(chunk);
- }
-
- pthread_rwlock_unlock(§or->lock);
-
- return chunk;
-}
-
-TerrainChunk *terrain_get_chunk_nodep(Terrain *terrain, v3s32 nodep, v3s32 *offset, int mode)
-{
- TerrainChunk *chunk = terrain_get_chunk(terrain, terrain_chunkp(nodep), mode);
- if (!chunk)
- return NULL;
- *offset = terrain_offset(nodep);
- return chunk;
-}
-
-Blob terrain_serialize_chunk(__attribute__((unused)) Terrain *terrain, TerrainChunk *chunk, void (*callback)(TerrainNode *node, Blob *buffer))
-{
- bool empty = true;
-
- CHUNK_ITERATE {
- if (chunk->data[x][y][z].type != NODE_AIR) {
- empty = false;
- break;
- }
- }
-
- if (empty)
- return (Blob) {0, NULL};
-
- SerializedTerrainChunk serialized_chunk;
-
- CHUNK_ITERATE {
- TerrainNode *node = &chunk->data[x][y][z];
- SerializedTerrainNode *serialized = &serialized_chunk.raw.nodes[x][y][z];
-
- serialized->type = node->type;
- serialized->data = (Blob) {0, NULL};
-
- if (callback)
- callback(node, &serialized->data);
- }
-
- Blob buffer = {0, NULL};
- SerializedTerrainChunk_write(&buffer, &serialized_chunk);
- SerializedTerrainChunk_free(&serialized_chunk);
- return buffer;
-}
-
-bool terrain_deserialize_chunk(Terrain *terrain, TerrainChunk *chunk, Blob buffer, void (*callback)(TerrainNode *node, Blob buffer))
-{
- if (buffer.siz == 0) {
- CHUNK_ITERATE {
- if (terrain->callbacks.delete_node)
- terrain->callbacks.delete_node(&chunk->data[x][y][z]);
-
- chunk->data[x][y][z] = (TerrainNode) {NODE_AIR, NULL};
- }
-
- return true;
- }
-
- // it's important to copy Blobs that have been malloc'd before reading from them
- // because reading from a Blob modifies its data and size pointer,
- // but does not free anything
- SerializedTerrainChunk serialized_chunk = {0};
- bool success = SerializedTerrainChunk_read(&buffer, &serialized_chunk);
-
- if (success) CHUNK_ITERATE {
- if (terrain->callbacks.delete_node)
- terrain->callbacks.delete_node(&chunk->data[x][y][z]);
-
- TerrainNode *node = &chunk->data[x][y][z];
- SerializedTerrainNode *serialized = &serialized_chunk.raw.nodes[x][y][z];
-
- node->type = serialized->type;
-
- if (callback)
- callback(node, serialized->data);
- }
-
- SerializedTerrainChunk_free(&serialized_chunk);
- return success;
-}
-
-TerrainNode terrain_get_node(Terrain *terrain, v3s32 pos)
-{
- v3s32 offset;
- TerrainChunk *chunk = terrain_get_chunk_nodep(terrain, pos, &offset, CHUNK_MODE_PASSIVE);
- if (!chunk)
- return (TerrainNode) {COUNT_NODE, NULL};
-
- assert(pthread_rwlock_rdlock(&chunk->lock) == 0);
- TerrainNode node = chunk->data[offset.x][offset.y][offset.z];
- pthread_rwlock_unlock(&chunk->lock);
-
- return node;
-}
-
-v3s32 terrain_chunkp(v3s32 pos)
-{
- return (v3s32) {
- floor((double) pos.x / (double) CHUNK_SIZE),
- floor((double) pos.y / (double) CHUNK_SIZE),
- floor((double) pos.z / (double) CHUNK_SIZE)};
-}
-
-v3s32 terrain_offset(v3s32 pos)
-{
- return (v3s32) {
- (u32) pos.x % CHUNK_SIZE,
- (u32) pos.y % CHUNK_SIZE,
- (u32) pos.z % CHUNK_SIZE};
-}
+++ /dev/null
-#ifndef _TERRAIN_H_
-#define _TERRAIN_H_
-
-#include <dragonstd/list.h>
-#include <dragonstd/tree.h>
-#include <stdbool.h>
-#include <pthread.h>
-#include "node.h"
-#include "types.h"
-
-#define CHUNK_ITERATE \
- for (s32 x = 0; x < CHUNK_SIZE; x++) \
- for (s32 y = 0; y < CHUNK_SIZE; y++) \
- for (s32 z = 0; z < CHUNK_SIZE; z++)
-
-#define CHUNK_MODE_PASSIVE 0
-#define CHUNK_MODE_CREATE 1
-
-typedef struct TerrainNode {
- NodeType type;
- void *data;
-} TerrainNode;
-
-typedef TerrainNode TerrainChunkData[CHUNK_SIZE][CHUNK_SIZE][CHUNK_SIZE];
-
-typedef struct {
- s32 level;
- v3s32 pos;
- TerrainChunkData data;
- void *extra;
- pthread_rwlock_t lock;
-} TerrainChunk;
-
-typedef struct {
- Tree sectors;
- pthread_rwlock_t lock;
- TerrainChunk *cache;
- pthread_rwlock_t cache_lock;
- struct {
- void (*create_chunk)(TerrainChunk *chunk);
- void (*delete_chunk)(TerrainChunk *chunk);
- bool (*get_chunk)(TerrainChunk *chunk, int mode);
- void (*delete_node)(TerrainNode *node);
- } callbacks;
-} Terrain;
-
-Terrain *terrain_create();
-void terrain_delete(Terrain *terrain);
-
-TerrainChunk *terrain_get_chunk(Terrain *terrain, v3s32 pos, int mode);
-TerrainChunk *terrain_get_chunk_nodep(Terrain *terrain, v3s32 node_pos, v3s32 *offset, int mode);
-
-Blob terrain_serialize_chunk(Terrain *terrain, TerrainChunk *chunk, void (*callback)(TerrainNode *node, Blob *buffer));
-bool terrain_deserialize_chunk(Terrain *terrain, TerrainChunk *chunk, Blob buffer, void (*callback)(TerrainNode *node, Blob buffer));
-
-TerrainNode terrain_get_node(Terrain *terrain, v3s32 pos);
-
-v3s32 terrain_chunkp(v3s32 pos);
-v3s32 terrain_offset(v3s32 pos);
-
-#endif
#!/bin/bash
+echo "Snapshot uploading temporarily disabled"
+exit
+
VERSION=`git tag --points-at HEAD`
IS_RELEASE="1"
if [[ $VERSION = "" ]]; then
VERSION=`git rev-parse --short HEAD`
IS_RELEASE="0"
fi
+
curl -f -i -X POST -H "Content-Type: multipart/form-data" \
-F "secret=$SECRET" \
-F "name=$VERSION" \
-F "is_release=$IS_RELEASE" \
- -F "build=@dragonblocks_alpha-$VERSION.zip" \
+ -F "ubuntu=@dragonblocks_alpha-$VERSION.zip" \
+ -F "windows=@dragonblocks_alpha-win64-$VERSION.zip" \
https://elidragon.tk/dragonblocks_alpha/upload.php