From: Elias Fleckenstein Date: Mon, 25 Apr 2022 10:43:59 +0000 (+0200) Subject: Rework structure X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=7899e0ebbe3b6c20feeef09fcc3209d4029e25f7;p=dragonblocks_alpha.git Rework structure --- diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index c12d675..232947f 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -11,11 +11,14 @@ jobs: - 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: | diff --git a/.gitignore b/.gitignore index 576b8e6..53912a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,30 +1,4 @@ -# 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* diff --git a/.gitmodules b/.gitmodules index 49df65f..bf29ca1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,7 +3,7 @@ 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 @@ -21,10 +21,28 @@ 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 diff --git a/BUILDING.md b/BUILDING.md index 2decc4b..723d2b7 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -1,50 +1,34 @@ # 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. diff --git a/README.md b/README.md index baa5eec..581cf19 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,30 @@ # 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 for ubuntu snapshot and release builds. +Head to for snapshot and release builds (CURRENTLY DOWN). ## Invocation -```bash -./DragonblocksServer -./Dragonblocks
+```sh +# on posix +./dragonblocks_server "[
]:" +./dragonblocks_client "[
]:" + +# on windows +dragonblocks_server.exe "[
]:" +dragonblocks_client.exe "[
]:" ``` or alternatively: -```bash +```sh +# on posix ./singleplayer.sh + +# on windows +singleplayer.bat ``` ## Controls @@ -35,35 +45,10 @@ or alternatively: | 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 diff --git a/assets/fonts/Minecraftia.ttf b/assets/fonts/Minecraftia.ttf new file mode 100644 index 0000000..2cf2af4 Binary files /dev/null and b/assets/fonts/Minecraftia.ttf differ diff --git a/assets/meshes/axe.gox b/assets/meshes/axe.gox new file mode 100644 index 0000000..08bb09a Binary files /dev/null and b/assets/meshes/axe.gox differ diff --git a/assets/meshes/axe.txt b/assets/meshes/axe.txt new file mode 100644 index 0000000..1e29a2a --- /dev/null +++ b/assets/meshes/axe.txt @@ -0,0 +1,39 @@ +# 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 diff --git a/assets/meshes/pickaxe.gox b/assets/meshes/pickaxe.gox new file mode 100644 index 0000000..95e9c21 Binary files /dev/null and b/assets/meshes/pickaxe.gox differ diff --git a/assets/meshes/pickaxe.txt b/assets/meshes/pickaxe.txt new file mode 100644 index 0000000..c14d78e --- /dev/null +++ b/assets/meshes/pickaxe.txt @@ -0,0 +1,31 @@ +# 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 diff --git a/assets/meshes/shovel.gox b/assets/meshes/shovel.gox new file mode 100644 index 0000000..76d6155 Binary files /dev/null and b/assets/meshes/shovel.gox differ diff --git a/assets/meshes/shovel.txt b/assets/meshes/shovel.txt new file mode 100644 index 0000000..808bc2a --- /dev/null +++ b/assets/meshes/shovel.txt @@ -0,0 +1,22 @@ +# 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 diff --git a/assets/meshes/unknown.gox b/assets/meshes/unknown.gox new file mode 100644 index 0000000..61584af Binary files /dev/null and b/assets/meshes/unknown.gox differ diff --git a/assets/meshes/unknown.txt b/assets/meshes/unknown.txt new file mode 100644 index 0000000..78bbd97 --- /dev/null +++ b/assets/meshes/unknown.txt @@ -0,0 +1,732 @@ +# 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 diff --git a/assets/models/player.txt b/assets/models/player.txt new file mode 100644 index 0000000..ec997b8 --- /dev/null +++ b/assets/models/player.txt @@ -0,0 +1,15 @@ +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 diff --git a/assets/schematics/spawn_hut.gox b/assets/schematics/spawn_hut.gox new file mode 100644 index 0000000..7387575 Binary files /dev/null and b/assets/schematics/spawn_hut.gox differ diff --git a/assets/schematics/spawn_hut.txt b/assets/schematics/spawn_hut.txt new file mode 100644 index 0000000..5e33f2d --- /dev/null +++ b/assets/schematics/spawn_hut.txt @@ -0,0 +1,429 @@ +# 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 diff --git a/assets/shaders/3d/entity/fragment.glsl b/assets/shaders/3d/entity/fragment.glsl new file mode 100755 index 0000000..d74e86a --- /dev/null +++ b/assets/shaders/3d/entity/fragment.glsl @@ -0,0 +1,18 @@ +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; +} diff --git a/assets/shaders/3d/entity/vertex.glsl b/assets/shaders/3d/entity/vertex.glsl new file mode 100755 index 0000000..1490381 --- /dev/null +++ b/assets/shaders/3d/entity/vertex.glsl @@ -0,0 +1,28 @@ +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); +} diff --git a/assets/shaders/3d/item/fragment.glsl b/assets/shaders/3d/item/fragment.glsl new file mode 100755 index 0000000..102b9a5 --- /dev/null +++ b/assets/shaders/3d/item/fragment.glsl @@ -0,0 +1,16 @@ +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; +} diff --git a/assets/shaders/3d/item/vertex.glsl b/assets/shaders/3d/item/vertex.glsl new file mode 100755 index 0000000..897610c --- /dev/null +++ b/assets/shaders/3d/item/vertex.glsl @@ -0,0 +1,28 @@ +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); +} diff --git a/assets/shaders/3d/selection/fragment.glsl b/assets/shaders/3d/selection/fragment.glsl new file mode 100755 index 0000000..b591cd7 --- /dev/null +++ b/assets/shaders/3d/selection/fragment.glsl @@ -0,0 +1,8 @@ +out vec4 outColor; + +uniform vec3 color; + +void main() +{ + outColor = vec4(color, 0.1); +} diff --git a/assets/shaders/3d/selection/vertex.glsl b/assets/shaders/3d/selection/vertex.glsl new file mode 100755 index 0000000..65dc0d2 --- /dev/null +++ b/assets/shaders/3d/selection/vertex.glsl @@ -0,0 +1,8 @@ +layout(location = 0) in vec3 vertexPosition; + +uniform mat4 MVP; + +void main() +{ + gl_Position = MVP * vec4(vertexPosition, 1.0); +} diff --git a/assets/shaders/3d/terrain/fragment.glsl b/assets/shaders/3d/terrain/fragment.glsl new file mode 100755 index 0000000..37bc567 --- /dev/null +++ b/assets/shaders/3d/terrain/fragment.glsl @@ -0,0 +1,19 @@ +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; +} diff --git a/assets/shaders/3d/terrain/vertex.glsl b/assets/shaders/3d/terrain/vertex.glsl new file mode 100755 index 0000000..2068cdc --- /dev/null +++ b/assets/shaders/3d/terrain/vertex.glsl @@ -0,0 +1,29 @@ +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); +} diff --git a/assets/shaders/gui/background/fragment.glsl b/assets/shaders/gui/background/fragment.glsl new file mode 100755 index 0000000..5bd15e3 --- /dev/null +++ b/assets/shaders/gui/background/fragment.glsl @@ -0,0 +1,8 @@ +out vec4 outColor; + +uniform vec4 color; + +void main() +{ + outColor = color; +} diff --git a/assets/shaders/gui/background/vertex.glsl b/assets/shaders/gui/background/vertex.glsl new file mode 100755 index 0000000..5815511 --- /dev/null +++ b/assets/shaders/gui/background/vertex.glsl @@ -0,0 +1,9 @@ +layout(location = 0) in vec2 vertexPosition; + +uniform mat4 model; +uniform mat4 projection; + +void main() +{ + gl_Position = projection * model * vec4(vertexPosition, 0.0, 1.0); +} diff --git a/assets/shaders/gui/font/fragment.glsl b/assets/shaders/gui/font/fragment.glsl new file mode 100755 index 0000000..883a012 --- /dev/null +++ b/assets/shaders/gui/font/fragment.glsl @@ -0,0 +1,11 @@ +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; +} diff --git a/assets/shaders/gui/font/vertex.glsl b/assets/shaders/gui/font/vertex.glsl new file mode 100644 index 0000000..50bcd6e --- /dev/null +++ b/assets/shaders/gui/font/vertex.glsl @@ -0,0 +1,13 @@ +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; +} diff --git a/assets/shaders/gui/image/fragment.glsl b/assets/shaders/gui/image/fragment.glsl new file mode 100755 index 0000000..bc8e428 --- /dev/null +++ b/assets/shaders/gui/image/fragment.glsl @@ -0,0 +1,10 @@ +in vec2 fragmentTextureCoordinates; + +out vec4 outColor; + +uniform sampler2D texture0; + +void main() +{ + outColor = texture(texture0, fragmentTextureCoordinates); +} diff --git a/assets/shaders/gui/image/vertex.glsl b/assets/shaders/gui/image/vertex.glsl new file mode 100755 index 0000000..50bcd6e --- /dev/null +++ b/assets/shaders/gui/image/vertex.glsl @@ -0,0 +1,13 @@ +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; +} diff --git a/assets/shaders/sky/clouds/fragment.glsl b/assets/shaders/sky/clouds/fragment.glsl new file mode 100755 index 0000000..32fc25b --- /dev/null +++ b/assets/shaders/sky/clouds/fragment.glsl @@ -0,0 +1,31 @@ +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)); +} diff --git a/assets/shaders/sky/clouds/vertex.glsl b/assets/shaders/sky/clouds/vertex.glsl new file mode 100755 index 0000000..1b361b7 --- /dev/null +++ b/assets/shaders/sky/clouds/vertex.glsl @@ -0,0 +1,12 @@ +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; +} diff --git a/assets/shaders/sky/skybox/fragment.glsl b/assets/shaders/sky/skybox/fragment.glsl new file mode 100755 index 0000000..e6c61b4 --- /dev/null +++ b/assets/shaders/sky/skybox/fragment.glsl @@ -0,0 +1,17 @@ +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); +} diff --git a/assets/shaders/sky/skybox/vertex.glsl b/assets/shaders/sky/skybox/vertex.glsl new file mode 100755 index 0000000..1b361b7 --- /dev/null +++ b/assets/shaders/sky/skybox/vertex.glsl @@ -0,0 +1,12 @@ +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; +} diff --git a/assets/shaders/sky/sun/fragment.glsl b/assets/shaders/sky/sun/fragment.glsl new file mode 100755 index 0000000..bc8e428 --- /dev/null +++ b/assets/shaders/sky/sun/fragment.glsl @@ -0,0 +1,10 @@ +in vec2 fragmentTextureCoordinates; + +out vec4 outColor; + +uniform sampler2D texture0; + +void main() +{ + outColor = texture(texture0, fragmentTextureCoordinates); +} diff --git a/assets/shaders/sky/sun/vertex.glsl b/assets/shaders/sky/sun/vertex.glsl new file mode 100755 index 0000000..243d17f --- /dev/null +++ b/assets/shaders/sky/sun/vertex.glsl @@ -0,0 +1,13 @@ +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; +} diff --git a/assets/textures/crosshair.png b/assets/textures/crosshair.png new file mode 100644 index 0000000..8f03d32 Binary files /dev/null and b/assets/textures/crosshair.png differ diff --git a/assets/textures/dirt.png b/assets/textures/dirt.png new file mode 100644 index 0000000..9a64b49 Binary files /dev/null and b/assets/textures/dirt.png differ diff --git a/assets/textures/grass.png b/assets/textures/grass.png new file mode 100644 index 0000000..70a3522 Binary files /dev/null and b/assets/textures/grass.png differ diff --git a/assets/textures/lava.png b/assets/textures/lava.png new file mode 100644 index 0000000..48aaccf Binary files /dev/null and b/assets/textures/lava.png differ diff --git a/assets/textures/lava_nt.png b/assets/textures/lava_nt.png new file mode 100644 index 0000000..e44018f Binary files /dev/null and b/assets/textures/lava_nt.png differ diff --git a/assets/textures/models/player/arm/back.png b/assets/textures/models/player/arm/back.png new file mode 100644 index 0000000..69ffff3 Binary files /dev/null and b/assets/textures/models/player/arm/back.png differ diff --git a/assets/textures/models/player/arm/bottom.png b/assets/textures/models/player/arm/bottom.png new file mode 100644 index 0000000..fda334e Binary files /dev/null and b/assets/textures/models/player/arm/bottom.png differ diff --git a/assets/textures/models/player/arm/front.png b/assets/textures/models/player/arm/front.png new file mode 100644 index 0000000..ce19461 Binary files /dev/null and b/assets/textures/models/player/arm/front.png differ diff --git a/assets/textures/models/player/arm/left.png b/assets/textures/models/player/arm/left.png new file mode 100644 index 0000000..c2b2325 Binary files /dev/null and b/assets/textures/models/player/arm/left.png differ diff --git a/assets/textures/models/player/arm/right.png b/assets/textures/models/player/arm/right.png new file mode 100644 index 0000000..9ae2e41 Binary files /dev/null and b/assets/textures/models/player/arm/right.png differ diff --git a/assets/textures/models/player/arm/top.png b/assets/textures/models/player/arm/top.png new file mode 100644 index 0000000..e12765d Binary files /dev/null and b/assets/textures/models/player/arm/top.png differ diff --git a/assets/textures/models/player/chest/back.png b/assets/textures/models/player/chest/back.png new file mode 100644 index 0000000..5eca9ec Binary files /dev/null and b/assets/textures/models/player/chest/back.png differ diff --git a/assets/textures/models/player/chest/bottom.png b/assets/textures/models/player/chest/bottom.png new file mode 100644 index 0000000..131d33d Binary files /dev/null and b/assets/textures/models/player/chest/bottom.png differ diff --git a/assets/textures/models/player/chest/front.png b/assets/textures/models/player/chest/front.png new file mode 100644 index 0000000..d44fd42 Binary files /dev/null and b/assets/textures/models/player/chest/front.png differ diff --git a/assets/textures/models/player/chest/left.png b/assets/textures/models/player/chest/left.png new file mode 100644 index 0000000..995ad5f Binary files /dev/null and b/assets/textures/models/player/chest/left.png differ diff --git a/assets/textures/models/player/chest/right.png b/assets/textures/models/player/chest/right.png new file mode 100644 index 0000000..e48eb66 Binary files /dev/null and b/assets/textures/models/player/chest/right.png differ diff --git a/assets/textures/models/player/chest/top.png b/assets/textures/models/player/chest/top.png new file mode 100644 index 0000000..df84083 Binary files /dev/null and b/assets/textures/models/player/chest/top.png differ diff --git a/assets/textures/models/player/head/back.png b/assets/textures/models/player/head/back.png new file mode 100644 index 0000000..935a2b9 Binary files /dev/null and b/assets/textures/models/player/head/back.png differ diff --git a/assets/textures/models/player/head/bottom.png b/assets/textures/models/player/head/bottom.png new file mode 100644 index 0000000..1fdae43 Binary files /dev/null and b/assets/textures/models/player/head/bottom.png differ diff --git a/assets/textures/models/player/head/front.png b/assets/textures/models/player/head/front.png new file mode 100644 index 0000000..805fec0 Binary files /dev/null and b/assets/textures/models/player/head/front.png differ diff --git a/assets/textures/models/player/head/left.png b/assets/textures/models/player/head/left.png new file mode 100644 index 0000000..7dc2a81 Binary files /dev/null and b/assets/textures/models/player/head/left.png differ diff --git a/assets/textures/models/player/head/right.png b/assets/textures/models/player/head/right.png new file mode 100644 index 0000000..47436ba Binary files /dev/null and b/assets/textures/models/player/head/right.png differ diff --git a/assets/textures/models/player/head/top.png b/assets/textures/models/player/head/top.png new file mode 100644 index 0000000..916ea2b Binary files /dev/null and b/assets/textures/models/player/head/top.png differ diff --git a/assets/textures/models/player/leg/back.png b/assets/textures/models/player/leg/back.png new file mode 100644 index 0000000..48b93ce Binary files /dev/null and b/assets/textures/models/player/leg/back.png differ diff --git a/assets/textures/models/player/leg/bottom.png b/assets/textures/models/player/leg/bottom.png new file mode 100644 index 0000000..0c942fb Binary files /dev/null and b/assets/textures/models/player/leg/bottom.png differ diff --git a/assets/textures/models/player/leg/front.png b/assets/textures/models/player/leg/front.png new file mode 100644 index 0000000..13b1016 Binary files /dev/null and b/assets/textures/models/player/leg/front.png differ diff --git a/assets/textures/models/player/leg/left.png b/assets/textures/models/player/leg/left.png new file mode 100644 index 0000000..104c6e7 Binary files /dev/null and b/assets/textures/models/player/leg/left.png differ diff --git a/assets/textures/models/player/leg/right.png b/assets/textures/models/player/leg/right.png new file mode 100644 index 0000000..a97a13a Binary files /dev/null and b/assets/textures/models/player/leg/right.png differ diff --git a/assets/textures/models/player/leg/top.png b/assets/textures/models/player/leg/top.png new file mode 100644 index 0000000..d575dc7 Binary files /dev/null and b/assets/textures/models/player/leg/top.png differ diff --git a/assets/textures/needles.png b/assets/textures/needles.png new file mode 100644 index 0000000..24e3ed4 Binary files /dev/null and b/assets/textures/needles.png differ diff --git a/assets/textures/oak_leaves.png b/assets/textures/oak_leaves.png new file mode 100644 index 0000000..a29369a Binary files /dev/null and b/assets/textures/oak_leaves.png differ diff --git a/assets/textures/oak_wood.png b/assets/textures/oak_wood.png new file mode 100644 index 0000000..90af189 Binary files /dev/null and b/assets/textures/oak_wood.png differ diff --git a/assets/textures/oak_wood_top.png b/assets/textures/oak_wood_top.png new file mode 100644 index 0000000..cf8ed6f Binary files /dev/null and b/assets/textures/oak_wood_top.png differ diff --git a/assets/textures/palm_leaves.png b/assets/textures/palm_leaves.png new file mode 100644 index 0000000..9d44925 Binary files /dev/null and b/assets/textures/palm_leaves.png differ diff --git a/assets/textures/palm_wood.png b/assets/textures/palm_wood.png new file mode 100644 index 0000000..5f0295d Binary files /dev/null and b/assets/textures/palm_wood.png differ diff --git a/assets/textures/palm_wood_top.png b/assets/textures/palm_wood_top.png new file mode 100644 index 0000000..276ae1e Binary files /dev/null and b/assets/textures/palm_wood_top.png differ diff --git a/assets/textures/pine_leaves.png b/assets/textures/pine_leaves.png new file mode 100644 index 0000000..24e3ed4 Binary files /dev/null and b/assets/textures/pine_leaves.png differ diff --git a/assets/textures/pine_wood.png b/assets/textures/pine_wood.png new file mode 100644 index 0000000..fae7da1 Binary files /dev/null and b/assets/textures/pine_wood.png differ diff --git a/assets/textures/pine_wood_top.png b/assets/textures/pine_wood_top.png new file mode 100644 index 0000000..276ae1e Binary files /dev/null and b/assets/textures/pine_wood_top.png differ diff --git a/assets/textures/player.png b/assets/textures/player.png new file mode 100644 index 0000000..f403dc3 Binary files /dev/null and b/assets/textures/player.png differ diff --git a/assets/textures/sand.png b/assets/textures/sand.png new file mode 100644 index 0000000..3899f4b Binary files /dev/null and b/assets/textures/sand.png differ diff --git a/assets/textures/skybox/day/back.png b/assets/textures/skybox/day/back.png new file mode 100644 index 0000000..6b98546 Binary files /dev/null and b/assets/textures/skybox/day/back.png differ diff --git a/assets/textures/skybox/day/bottom.png b/assets/textures/skybox/day/bottom.png new file mode 100644 index 0000000..ceaa6aa Binary files /dev/null and b/assets/textures/skybox/day/bottom.png differ diff --git a/assets/textures/skybox/day/front.png b/assets/textures/skybox/day/front.png new file mode 100644 index 0000000..f62ee88 Binary files /dev/null and b/assets/textures/skybox/day/front.png differ diff --git a/assets/textures/skybox/day/left.png b/assets/textures/skybox/day/left.png new file mode 100644 index 0000000..558391a Binary files /dev/null and b/assets/textures/skybox/day/left.png differ diff --git a/assets/textures/skybox/day/right.png b/assets/textures/skybox/day/right.png new file mode 100644 index 0000000..b1b7b9f Binary files /dev/null and b/assets/textures/skybox/day/right.png differ diff --git a/assets/textures/skybox/day/top.png b/assets/textures/skybox/day/top.png new file mode 100644 index 0000000..45567ca Binary files /dev/null and b/assets/textures/skybox/day/top.png differ diff --git a/assets/textures/skybox/night/back.png b/assets/textures/skybox/night/back.png new file mode 100644 index 0000000..0a0a862 Binary files /dev/null and b/assets/textures/skybox/night/back.png differ diff --git a/assets/textures/skybox/night/bottom.png b/assets/textures/skybox/night/bottom.png new file mode 100644 index 0000000..e51749a Binary files /dev/null and b/assets/textures/skybox/night/bottom.png differ diff --git a/assets/textures/skybox/night/front.png b/assets/textures/skybox/night/front.png new file mode 100644 index 0000000..6ec46e1 Binary files /dev/null and b/assets/textures/skybox/night/front.png differ diff --git a/assets/textures/skybox/night/left.png b/assets/textures/skybox/night/left.png new file mode 100644 index 0000000..c04fb71 Binary files /dev/null and b/assets/textures/skybox/night/left.png differ diff --git a/assets/textures/skybox/night/right.png b/assets/textures/skybox/night/right.png new file mode 100644 index 0000000..60329f4 Binary files /dev/null and b/assets/textures/skybox/night/right.png differ diff --git a/assets/textures/skybox/night/top.png b/assets/textures/skybox/night/top.png new file mode 100644 index 0000000..2711dd1 Binary files /dev/null and b/assets/textures/skybox/night/top.png differ diff --git a/assets/textures/snow.png b/assets/textures/snow.png new file mode 100644 index 0000000..359335e Binary files /dev/null and b/assets/textures/snow.png differ diff --git a/assets/textures/stone.png b/assets/textures/stone.png new file mode 100644 index 0000000..3af8ac9 Binary files /dev/null and b/assets/textures/stone.png differ diff --git a/assets/textures/sun.png b/assets/textures/sun.png new file mode 100644 index 0000000..fb3b88d Binary files /dev/null and b/assets/textures/sun.png differ diff --git a/assets/textures/unknown.png b/assets/textures/unknown.png new file mode 100644 index 0000000..bbea82c Binary files /dev/null and b/assets/textures/unknown.png differ diff --git a/assets/textures/vulcano_stone.png b/assets/textures/vulcano_stone.png new file mode 100644 index 0000000..c359713 Binary files /dev/null and b/assets/textures/vulcano_stone.png differ diff --git a/assets/textures/water.png b/assets/textures/water.png new file mode 100644 index 0000000..b9a66fd Binary files /dev/null and b/assets/textures/water.png differ diff --git a/assets/textures/water_nt.png b/assets/textures/water_nt.png new file mode 100644 index 0000000..f457566 Binary files /dev/null and b/assets/textures/water_nt.png differ diff --git a/build/debug.sh b/build/debug.sh new file mode 100755 index 0000000..4323a99 --- /dev/null +++ b/build/debug.sh @@ -0,0 +1,44 @@ +#!/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 diff --git a/build/debug_loop.sh b/build/debug_loop.sh new file mode 100755 index 0000000..3c6c460 --- /dev/null +++ b/build/debug_loop.sh @@ -0,0 +1,12 @@ +#!/bin/bash +COMMAND="./debug.sh" + +if [[ $1 == "terrain" ]]; then + COMMAND="./debug_terrain.sh" +fi + +while true; do + if ! $COMMAND; then + read + fi +done diff --git a/deps/asprintf b/deps/asprintf index 84c7e7c..305d3f9 160000 --- a/deps/asprintf +++ b/deps/asprintf @@ -1 +1 @@ -Subproject commit 84c7e7cb1e0a6ea4102ca785cca31a3e66f34a48 +Subproject commit 305d3f995280196f4c88146b03f09b94191e8cca diff --git a/deps/dragonnet b/deps/dragonnet index 9ab2148..72fd472 160000 --- a/deps/dragonnet +++ b/deps/dragonnet @@ -1 +1 @@ -Subproject commit 9ab2148e1b8d03dab816bbba6209794663b31576 +Subproject commit 72fd472f45d9589269d7786877dff8d45586c006 diff --git a/deps/dragonstd b/deps/dragonstd index 7d8cdee..ae5dd6c 160000 --- a/deps/dragonstd +++ b/deps/dragonstd @@ -1 +1 @@ -Subproject commit 7d8cdeeb49fc6fa0b4b7ac9c3bb3e1fb27f4f0bf +Subproject commit ae5dd6c930ccef19ad313aa903f0528aa803ee80 diff --git a/deps/endian.h b/deps/endian.h index 6c7eccf..f24960e 160000 --- a/deps/endian.h +++ b/deps/endian.h @@ -1 +1 @@ -Subproject commit 6c7eccf05405eacbb76281550cd69895089f9773 +Subproject commit f24960eca3bb806fa72d8de2b9a761a889fdeee3 diff --git a/deps/freetype b/deps/freetype new file mode 160000 index 0000000..d59c7ce --- /dev/null +++ b/deps/freetype @@ -0,0 +1 @@ +Subproject commit d59c7ce1b970bfe38b3df161e9dd711b75392709 diff --git a/deps/getline b/deps/getline index 9d102be..305c38b 160000 --- a/deps/getline +++ b/deps/getline @@ -1 +1 @@ -Subproject commit 9d102be3fb622bcd3fab9f7feaafe2b1abf3980a +Subproject commit 305c38b4595254706f103e0043ac2fd6e491d8ed diff --git a/deps/glew-cmake b/deps/glew-cmake new file mode 160000 index 0000000..7c2b751 --- /dev/null +++ b/deps/glew-cmake @@ -0,0 +1 @@ +Subproject commit 7c2b7514f64234756f7df051b9316f1e46f5a6e7 diff --git a/deps/glfw b/deps/glfw new file mode 160000 index 0000000..4cb3687 --- /dev/null +++ b/deps/glfw @@ -0,0 +1 @@ +Subproject commit 4cb36872a5fe448c205d0b46f0e8c8b57530cfe0 diff --git a/deps/linenoise b/deps/linenoise index 9430e6e..2da54ed 160000 --- a/deps/linenoise +++ b/deps/linenoise @@ -1 +1 @@ -Subproject commit 9430e6e4e7fc09e8ca6a2fd5e3fcafa07818542e +Subproject commit 2da54ed285c5da913c9fb11e0b0410becccb8a39 diff --git a/deps/perlin b/deps/perlin index 78efd36..2b58452 160000 --- a/deps/perlin +++ b/deps/perlin @@ -1 +1 @@ -Subproject commit 78efd369ac89a1db0dee71e277bf5e74309ef9fe +Subproject commit 2b584521c2657c8c8e8cb4a49ca80c2ffa0c3f96 diff --git a/deps/protogen b/deps/protogen index 2200835..f506262 160000 --- a/deps/protogen +++ b/deps/protogen @@ -1 +1 @@ -Subproject commit 2200835ac31adfa47f2baaa93f0a79a7c9a9007c +Subproject commit f506262076d602340500786703ac384d92683e26 diff --git a/deps/sqlite3-cmake b/deps/sqlite3-cmake new file mode 160000 index 0000000..a8200e0 --- /dev/null +++ b/deps/sqlite3-cmake @@ -0,0 +1 @@ +Subproject commit a8200e0816fb742617347d3e1a43c35b5b2f424e diff --git a/deps/stpcpy b/deps/stpcpy new file mode 160000 index 0000000..c85c304 --- /dev/null +++ b/deps/stpcpy @@ -0,0 +1 @@ +Subproject commit c85c304ae7cb6867a732c4183c1d260f746bd73d diff --git a/deps/zlib b/deps/zlib new file mode 160000 index 0000000..4b4fbf4 --- /dev/null +++ b/deps/zlib @@ -0,0 +1 @@ +Subproject commit 4b4fbf4ee10310760f763bcb674775f0325b842a diff --git a/fonts/Minecraftia.ttf b/fonts/Minecraftia.ttf deleted file mode 100644 index 2cf2af4..0000000 Binary files a/fonts/Minecraftia.ttf and /dev/null differ diff --git a/meshes/axe.gox b/meshes/axe.gox deleted file mode 100644 index 08bb09a..0000000 Binary files a/meshes/axe.gox and /dev/null differ diff --git a/meshes/axe.txt b/meshes/axe.txt deleted file mode 100644 index 1e29a2a..0000000 --- a/meshes/axe.txt +++ /dev/null @@ -1,39 +0,0 @@ -# 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 diff --git a/meshes/pickaxe.gox b/meshes/pickaxe.gox deleted file mode 100644 index 95e9c21..0000000 Binary files a/meshes/pickaxe.gox and /dev/null differ diff --git a/meshes/pickaxe.txt b/meshes/pickaxe.txt deleted file mode 100644 index c14d78e..0000000 --- a/meshes/pickaxe.txt +++ /dev/null @@ -1,31 +0,0 @@ -# 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 diff --git a/meshes/shovel.gox b/meshes/shovel.gox deleted file mode 100644 index 76d6155..0000000 Binary files a/meshes/shovel.gox and /dev/null differ diff --git a/meshes/shovel.txt b/meshes/shovel.txt deleted file mode 100644 index 808bc2a..0000000 --- a/meshes/shovel.txt +++ /dev/null @@ -1,22 +0,0 @@ -# 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 diff --git a/meshes/unknown.gox b/meshes/unknown.gox deleted file mode 100644 index 61584af..0000000 Binary files a/meshes/unknown.gox and /dev/null differ diff --git a/meshes/unknown.txt b/meshes/unknown.txt deleted file mode 100644 index 78bbd97..0000000 --- a/meshes/unknown.txt +++ /dev/null @@ -1,732 +0,0 @@ -# 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 diff --git a/models/player.txt b/models/player.txt deleted file mode 100644 index ec997b8..0000000 --- a/models/player.txt +++ /dev/null @@ -1,15 +0,0 @@ -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 diff --git a/schematics/spawn_hut.gox b/schematics/spawn_hut.gox deleted file mode 100644 index 7387575..0000000 Binary files a/schematics/spawn_hut.gox and /dev/null differ diff --git a/schematics/spawn_hut.txt b/schematics/spawn_hut.txt deleted file mode 100644 index 5e33f2d..0000000 --- a/schematics/spawn_hut.txt +++ /dev/null @@ -1,429 +0,0 @@ -# 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 diff --git a/shaders/3d/entity/fragment.glsl b/shaders/3d/entity/fragment.glsl deleted file mode 100755 index d74e86a..0000000 --- a/shaders/3d/entity/fragment.glsl +++ /dev/null @@ -1,18 +0,0 @@ -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; -} diff --git a/shaders/3d/entity/vertex.glsl b/shaders/3d/entity/vertex.glsl deleted file mode 100755 index 1490381..0000000 --- a/shaders/3d/entity/vertex.glsl +++ /dev/null @@ -1,28 +0,0 @@ -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); -} diff --git a/shaders/3d/item/fragment.glsl b/shaders/3d/item/fragment.glsl deleted file mode 100755 index 102b9a5..0000000 --- a/shaders/3d/item/fragment.glsl +++ /dev/null @@ -1,16 +0,0 @@ -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; -} diff --git a/shaders/3d/item/vertex.glsl b/shaders/3d/item/vertex.glsl deleted file mode 100755 index 897610c..0000000 --- a/shaders/3d/item/vertex.glsl +++ /dev/null @@ -1,28 +0,0 @@ -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); -} diff --git a/shaders/3d/selection/fragment.glsl b/shaders/3d/selection/fragment.glsl deleted file mode 100755 index b591cd7..0000000 --- a/shaders/3d/selection/fragment.glsl +++ /dev/null @@ -1,8 +0,0 @@ -out vec4 outColor; - -uniform vec3 color; - -void main() -{ - outColor = vec4(color, 0.1); -} diff --git a/shaders/3d/selection/vertex.glsl b/shaders/3d/selection/vertex.glsl deleted file mode 100755 index 65dc0d2..0000000 --- a/shaders/3d/selection/vertex.glsl +++ /dev/null @@ -1,8 +0,0 @@ -layout(location = 0) in vec3 vertexPosition; - -uniform mat4 MVP; - -void main() -{ - gl_Position = MVP * vec4(vertexPosition, 1.0); -} diff --git a/shaders/3d/terrain/fragment.glsl b/shaders/3d/terrain/fragment.glsl deleted file mode 100755 index 37bc567..0000000 --- a/shaders/3d/terrain/fragment.glsl +++ /dev/null @@ -1,19 +0,0 @@ -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; -} diff --git a/shaders/3d/terrain/vertex.glsl b/shaders/3d/terrain/vertex.glsl deleted file mode 100755 index 2068cdc..0000000 --- a/shaders/3d/terrain/vertex.glsl +++ /dev/null @@ -1,29 +0,0 @@ -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); -} diff --git a/shaders/gui/background/fragment.glsl b/shaders/gui/background/fragment.glsl deleted file mode 100755 index 5bd15e3..0000000 --- a/shaders/gui/background/fragment.glsl +++ /dev/null @@ -1,8 +0,0 @@ -out vec4 outColor; - -uniform vec4 color; - -void main() -{ - outColor = color; -} diff --git a/shaders/gui/background/vertex.glsl b/shaders/gui/background/vertex.glsl deleted file mode 100755 index 5815511..0000000 --- a/shaders/gui/background/vertex.glsl +++ /dev/null @@ -1,9 +0,0 @@ -layout(location = 0) in vec2 vertexPosition; - -uniform mat4 model; -uniform mat4 projection; - -void main() -{ - gl_Position = projection * model * vec4(vertexPosition, 0.0, 1.0); -} diff --git a/shaders/gui/font/fragment.glsl b/shaders/gui/font/fragment.glsl deleted file mode 100755 index 883a012..0000000 --- a/shaders/gui/font/fragment.glsl +++ /dev/null @@ -1,11 +0,0 @@ -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; -} diff --git a/shaders/gui/font/vertex.glsl b/shaders/gui/font/vertex.glsl deleted file mode 100644 index 50bcd6e..0000000 --- a/shaders/gui/font/vertex.glsl +++ /dev/null @@ -1,13 +0,0 @@ -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; -} diff --git a/shaders/gui/image/fragment.glsl b/shaders/gui/image/fragment.glsl deleted file mode 100755 index bc8e428..0000000 --- a/shaders/gui/image/fragment.glsl +++ /dev/null @@ -1,10 +0,0 @@ -in vec2 fragmentTextureCoordinates; - -out vec4 outColor; - -uniform sampler2D texture0; - -void main() -{ - outColor = texture(texture0, fragmentTextureCoordinates); -} diff --git a/shaders/gui/image/vertex.glsl b/shaders/gui/image/vertex.glsl deleted file mode 100755 index 50bcd6e..0000000 --- a/shaders/gui/image/vertex.glsl +++ /dev/null @@ -1,13 +0,0 @@ -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; -} diff --git a/shaders/sky/clouds/fragment.glsl b/shaders/sky/clouds/fragment.glsl deleted file mode 100755 index 32fc25b..0000000 --- a/shaders/sky/clouds/fragment.glsl +++ /dev/null @@ -1,31 +0,0 @@ -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)); -} diff --git a/shaders/sky/clouds/vertex.glsl b/shaders/sky/clouds/vertex.glsl deleted file mode 100755 index 1b361b7..0000000 --- a/shaders/sky/clouds/vertex.glsl +++ /dev/null @@ -1,12 +0,0 @@ -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; -} diff --git a/shaders/sky/skybox/fragment.glsl b/shaders/sky/skybox/fragment.glsl deleted file mode 100755 index e6c61b4..0000000 --- a/shaders/sky/skybox/fragment.glsl +++ /dev/null @@ -1,17 +0,0 @@ -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); -} diff --git a/shaders/sky/skybox/vertex.glsl b/shaders/sky/skybox/vertex.glsl deleted file mode 100755 index 1b361b7..0000000 --- a/shaders/sky/skybox/vertex.glsl +++ /dev/null @@ -1,12 +0,0 @@ -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; -} diff --git a/shaders/sky/sun/fragment.glsl b/shaders/sky/sun/fragment.glsl deleted file mode 100755 index bc8e428..0000000 --- a/shaders/sky/sun/fragment.glsl +++ /dev/null @@ -1,10 +0,0 @@ -in vec2 fragmentTextureCoordinates; - -out vec4 outColor; - -uniform sampler2D texture0; - -void main() -{ - outColor = texture(texture0, fragmentTextureCoordinates); -} diff --git a/shaders/sky/sun/vertex.glsl b/shaders/sky/sun/vertex.glsl deleted file mode 100755 index 243d17f..0000000 --- a/shaders/sky/sun/vertex.glsl +++ /dev/null @@ -1,13 +0,0 @@ -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; -} diff --git a/singleplayer.bat b/singleplayer.bat new file mode 100755 index 0000000..0328b33 --- /dev/null +++ b/singleplayer.bat @@ -0,0 +1,5 @@ +@echo off +start "Internal Server" dragonblocks_server.exe "[::1]:4000" +echo "singleplayer" | dragonblocks_client.exe "[::1]:4000" +taskkill /FI "Internal Server" /T /F + diff --git a/singleplayer.sh b/singleplayer.sh index 0daa513..5f084ad 100755 --- a/singleplayer.sh +++ b/singleplayer.sh @@ -1,4 +1,4 @@ #!/bin/bash ./dragonblocks_server "[::1]:4000" & -echo "singleplayer" | ./dragonblocks "[::1]:4000" -pkill -P $$ -9 +echo "singleplayer" | ./dragonblocks_client "[::1]:4000" +pkill -P $$ diff --git a/snapshot.sh b/snapshot.sh index 9c1098f..e99ab63 100755 --- a/snapshot.sh +++ b/snapshot.sh @@ -1,23 +1,44 @@ #!/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/* diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 896d845..6c9838a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,41 +1,44 @@ -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 @@ -44,21 +47,17 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") 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") @@ -73,45 +72,43 @@ endif() # 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 @@ -144,23 +141,18 @@ add_executable(dragonblocks 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 @@ -178,7 +170,8 @@ add_executable(dragonblocks_server ) target_link_libraries(dragonblocks_server - sqlite3 + PUBLIC dragonblocks + PUBLIC sqlite3 ) # Version @@ -189,7 +182,6 @@ add_custom_target(version ) add_dependencies(dragonblocks version) -add_dependencies(dragonblocks_server version) # Types @@ -206,4 +198,3 @@ add_custom_target(types ) add_dependencies(dragonblocks types) -add_dependencies(dragonblocks_server types) diff --git a/src/client/camera.h b/src/client/camera.h index 3e3d517..740ece2 100644 --- a/src/client/camera.h +++ b/src/client/camera.h @@ -1,7 +1,7 @@ #ifndef _CAMERA_H_ #define _CAMERA_H_ -#include +#include #include "types.h" extern struct Camera { diff --git a/src/client/client.c b/src/client/client.c index 55bfc45..2adb649 100644 --- a/src/client/client.c +++ b/src/client/client.c @@ -14,9 +14,9 @@ #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; diff --git a/src/client/client_auth.c b/src/client/client_auth.c index b955cd5..a338aa1 100644 --- a/src/client/client_auth.c +++ b/src/client/client_auth.c @@ -1,10 +1,10 @@ #include #include #include -#include +#include #include "client.h" #include "client_auth.h" -#include "interrupt.h" +#include "common/interrupt.h" #include "types.h" struct ClientAuth client_auth; diff --git a/src/client/client_config.c b/src/client/client_config.c index cc49c97..a1c34ab 100644 --- a/src/client/client_config.c +++ b/src/client/client_config.c @@ -1,5 +1,5 @@ -#include "config.h" #include "client/client_config.h" +#include "common/config.h" struct ClientConfig client_config = { .antialiasing = 4, diff --git a/src/client/client_entity.c b/src/client/client_entity.c index 2174e1b..49f8d61 100644 --- a/src/client/client_entity.c +++ b/src/client/client_entity.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -170,7 +170,7 @@ void client_entity_gfx_init() { 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 diff --git a/src/client/client_entity.h b/src/client/client_entity.h index a0e43df..7d009a9 100644 --- a/src/client/client_entity.h +++ b/src/client/client_entity.h @@ -5,8 +5,8 @@ #include #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 { diff --git a/src/client/client_inventory.c b/src/client/client_inventory.c index 4bc4124..c0f780b 100644 --- a/src/client/client_inventory.c +++ b/src/client/client_inventory.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include "client/client_config.h" @@ -19,7 +19,7 @@ void client_inventory_init() { 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"); diff --git a/src/client/client_item.c b/src/client/client_item.c index 5685cbf..0d16ee7 100644 --- a/src/client/client_item.c +++ b/src/client/client_item.c @@ -1,6 +1,6 @@ #include "client/client_item.h" #include "client/interact.h" -#include "node.h" +#include "common/node.h" static bool use_dig(__attribute__((unused)) ItemStack *stack) { @@ -11,7 +11,7 @@ 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, }, @@ -23,19 +23,19 @@ ClientItemDef client_item_def[COUNT_ITEM] = { }, // 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, }, diff --git a/src/client/client_item.h b/src/client/client_item.h index cbd6334..16552b0 100644 --- a/src/client/client_item.h +++ b/src/client/client_item.h @@ -3,8 +3,8 @@ #include #include "client/mesh.h" -#include "item.h" -#include "node.h" +#include "common/item.h" +#include "common/node.h" typedef struct { const char *mesh_path; diff --git a/src/client/client_node.c b/src/client/client_node.c index 1142a85..76eb738 100644 --- a/src/client/client_node.c +++ b/src/client/client_node.c @@ -1,10 +1,10 @@ #include #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}} @@ -42,7 +42,7 @@ static void render_color(NodeArgsRender *args) 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, @@ -62,7 +62,7 @@ ClientNodeDef client_node_def[COUNT_NODE] = { }, // 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, @@ -72,7 +72,7 @@ ClientNodeDef client_node_def[COUNT_NODE] = { }, // dirt { - .tiles = TILES_SIMPLE(RESSOURCE_PATH "textures/dirt.png"), + .tiles = TILES_SIMPLE(ASSET_PATH "textures/dirt.png"), .visibility = VISIBILITY_SOLID, .mipmap = true, .render = NULL, @@ -82,7 +82,7 @@ ClientNodeDef client_node_def[COUNT_NODE] = { }, // 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, @@ -92,7 +92,7 @@ ClientNodeDef client_node_def[COUNT_NODE] = { }, // snow { - .tiles = TILES_SIMPLE(RESSOURCE_PATH "textures/snow.png"), + .tiles = TILES_SIMPLE(ASSET_PATH "textures/snow.png"), .visibility = VISIBILITY_SOLID, .mipmap = true, .render = NULL, @@ -103,7 +103,7 @@ ClientNodeDef client_node_def[COUNT_NODE] = { // 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}, }, @@ -116,7 +116,7 @@ ClientNodeDef client_node_def[COUNT_NODE] = { }, // 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, @@ -127,7 +127,7 @@ ClientNodeDef client_node_def[COUNT_NODE] = { // 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}, }, @@ -140,7 +140,7 @@ ClientNodeDef client_node_def[COUNT_NODE] = { }, // 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, @@ -151,7 +151,7 @@ ClientNodeDef client_node_def[COUNT_NODE] = { // 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}, }, @@ -164,7 +164,7 @@ ClientNodeDef client_node_def[COUNT_NODE] = { }, // 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, @@ -174,7 +174,7 @@ ClientNodeDef client_node_def[COUNT_NODE] = { }, // sand { - .tiles = TILES_SIMPLE(RESSOURCE_PATH "textures/sand.png"), + .tiles = TILES_SIMPLE(ASSET_PATH "textures/sand.png"), .visibility = VISIBILITY_SOLID, .mipmap = true, .render = NULL, @@ -184,7 +184,7 @@ ClientNodeDef client_node_def[COUNT_NODE] = { }, // water { - .tiles = TILES_SIMPLE(RESSOURCE_PATH "textures/water.png"), + .tiles = TILES_SIMPLE(ASSET_PATH "textures/water.png"), .visibility = VISIBILITY_BLEND, .mipmap = true, .render = NULL, @@ -194,7 +194,7 @@ ClientNodeDef client_node_def[COUNT_NODE] = { }, // lava { - .tiles = TILES_SIMPLE(RESSOURCE_PATH "textures/lava.png"), + .tiles = TILES_SIMPLE(ASSET_PATH "textures/lava.png"), .visibility = VISIBILITY_BLEND, .mipmap = true, .render = NULL, @@ -204,7 +204,7 @@ ClientNodeDef client_node_def[COUNT_NODE] = { }, // 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, diff --git a/src/client/client_node.h b/src/client/client_node.h index 8068eca..a2f88ee 100644 --- a/src/client/client_node.h +++ b/src/client/client_node.h @@ -3,7 +3,7 @@ #include "client/terrain_gfx.h" #include "client/texture.h" -#include "terrain.h" +#include "common/terrain.h" typedef enum { VISIBILITY_NONE, diff --git a/src/client/client_player.c b/src/client/client_player.c index ffdc6b2..d6c9cc0 100644 --- a/src/client/client_player.c +++ b/src/client/client_player.c @@ -8,8 +8,8 @@ #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; @@ -233,7 +233,7 @@ void client_player_deinit() 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; diff --git a/src/client/client_terrain.c b/src/client/client_terrain.c index e8eae36..86f3f21 100644 --- a/src/client/client_terrain.c +++ b/src/client/client_terrain.c @@ -14,7 +14,7 @@ #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 diff --git a/src/client/client_terrain.h b/src/client/client_terrain.h index 262a3d5..a337325 100644 --- a/src/client/client_terrain.h +++ b/src/client/client_terrain.h @@ -4,7 +4,7 @@ #include #include #include "client/model.h" -#include "terrain.h" +#include "common/terrain.h" #include "types.h" #define CHUNK_MODE_NOCREATE 2 diff --git a/src/client/debug_menu.c b/src/client/debug_menu.c index ddf36c4..ef1c457 100644 --- a/src/client/debug_menu.c +++ b/src/client/debug_menu.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -15,9 +15,9 @@ #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}; diff --git a/src/client/font.c b/src/client/font.c index 8014d97..56c6e07 100644 --- a/src/client/font.c +++ b/src/client/font.c @@ -39,7 +39,7 @@ void font_init() 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(); } diff --git a/src/client/frustum.h b/src/client/frustum.h index a747265..59304aa 100644 --- a/src/client/frustum.h +++ b/src/client/frustum.h @@ -2,7 +2,7 @@ #define _FRUSTUM_H_ #include -#include +#include #include "types.h" extern mat4x4 frustum; diff --git a/src/client/game.c b/src/client/game.c index b45499a..859d9cf 100644 --- a/src/client/game.c +++ b/src/client/game.c @@ -21,8 +21,8 @@ #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 diff --git a/src/client/gui.c b/src/client/gui.c index 9cda646..8e5e1f3 100644 --- a/src/client/gui.c +++ b/src/client/gui.c @@ -253,18 +253,18 @@ static void transform_element(GUIElement *element) 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 diff --git a/src/client/gui.h b/src/client/gui.h index b7c3087..a3776ea 100644 --- a/src/client/gui.h +++ b/src/client/gui.h @@ -2,7 +2,7 @@ #define _GUI_H_ #include -#include +#include #include #include "client/font.h" #include "client/texture.h" diff --git a/src/client/input.c b/src/client/input.c index 32c181b..a5927ff 100644 --- a/src/client/input.c +++ b/src/client/input.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -13,7 +13,7 @@ #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); \ diff --git a/src/client/interact.c b/src/client/interact.c index 25401d7..1e2fb6e 100644 --- a/src/client/interact.c +++ b/src/client/interact.c @@ -1,4 +1,4 @@ -#include +#include #include #include "client/camera.h" #include "client/client.h" @@ -42,7 +42,7 @@ static Mesh selection_mesh = { 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 @@ -64,7 +64,7 @@ void interact_init() .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}, }); diff --git a/src/client/interact.h b/src/client/interact.h index 3c9a96d..a80b905 100644 --- a/src/client/interact.h +++ b/src/client/interact.h @@ -2,7 +2,7 @@ #define _INTERACT_H_ #include -#include "node.h" +#include "common/node.h" #include "types.h" extern struct InteractPointed { diff --git a/src/client/light.c b/src/client/light.c index 9ba99d0..a17c2d0 100644 --- a/src/client/light.c +++ b/src/client/light.c @@ -1,8 +1,8 @@ -#include +#include #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) { diff --git a/src/client/mesh.c b/src/client/mesh.c index 1674da0..75b0b10 100644 --- a/src/client/mesh.c +++ b/src/client/mesh.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/src/client/model.c b/src/client/model.c index 1755bd9..93bc773 100644 --- a/src/client/model.c +++ b/src/client/model.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/src/client/model.h b/src/client/model.h index 7254d0d..0d4d3fb 100644 --- a/src/client/model.h +++ b/src/client/model.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include "client/mesh.h" diff --git a/src/client/raycast.h b/src/client/raycast.h index eac7e17..6ba8ed9 100644 --- a/src/client/raycast.h +++ b/src/client/raycast.h @@ -2,7 +2,7 @@ #define _RAYCAST_H_ #include -#include "node.h" +#include "common/node.h" #include "types.h" bool raycast(v3f64 pos, v3f64 dir, f64 len, v3s32 *node_pos, NodeType *node); diff --git a/src/client/screenshot.c b/src/client/screenshot.c index 0a388f2..1569d14 100644 --- a/src/client/screenshot.c +++ b/src/client/screenshot.c @@ -1,7 +1,7 @@ #define STB_IMAGE_WRITE_IMPLEMENTATION #include #include -#include +#include #include #include #include "client/game.h" diff --git a/src/client/sky.c b/src/client/sky.c index 101782d..d20b149 100644 --- a/src/client/sky.c +++ b/src/client/sky.c @@ -10,7 +10,7 @@ #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; @@ -86,24 +86,24 @@ void sky_init() // 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; diff --git a/src/client/terrain_gfx.c b/src/client/terrain_gfx.c index 401b42e..d8ce09f 100644 --- a/src/client/terrain_gfx.c +++ b/src/client/terrain_gfx.c @@ -1,6 +1,6 @@ #include -#include -#include +#include +#include #include #include #include "client/client_config.h" @@ -12,7 +12,7 @@ #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 @@ -225,7 +225,7 @@ void terrain_gfx_init() 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 diff --git a/src/client/terrain_gfx.h b/src/client/terrain_gfx.h index d2a0cc9..f967505 100644 --- a/src/client/terrain_gfx.h +++ b/src/client/terrain_gfx.h @@ -2,7 +2,7 @@ #define _TERRAIN_GFX_H_ #include "client/cube.h" -#include "terrain.h" +#include "common/terrain.h" typedef struct { CubeVertex cube; diff --git a/src/client/texture.c b/src/client/texture.c index 54063fe..fb489ca 100644 --- a/src/client/texture.c +++ b/src/client/texture.c @@ -1,7 +1,7 @@ #define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_RESIZE_IMPLEMENTATION -#include -#include +#include +#include #include #include #include "client/client_config.h" diff --git a/src/client/window.h b/src/client/window.h index aae5ed6..e33fa3e 100644 --- a/src/client/window.h +++ b/src/client/window.h @@ -2,7 +2,7 @@ #define _WINDOW_H_ #include -#include +#include #include #include "types.h" diff --git a/src/color.c b/src/color.c deleted file mode 100644 index 66c5d84..0000000 --- a/src/color.c +++ /dev/null @@ -1,40 +0,0 @@ -#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; -} - diff --git a/src/color.h b/src/color.h deleted file mode 100644 index ebf8d73..0000000 --- a/src/color.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _COLOR_H_ -#define _COLOR_H_ - -#include "types.h" - -v3f32 hsl_to_rgb(v3f32 hsl); - -#endif // _COLOR_H_ diff --git a/src/common/color.c b/src/common/color.c new file mode 100644 index 0000000..e1689c7 --- /dev/null +++ b/src/common/color.c @@ -0,0 +1,40 @@ +#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; +} + diff --git a/src/common/color.h b/src/common/color.h new file mode 100644 index 0000000..ebf8d73 --- /dev/null +++ b/src/common/color.h @@ -0,0 +1,8 @@ +#ifndef _COLOR_H_ +#define _COLOR_H_ + +#include "types.h" + +v3f32 hsl_to_rgb(v3f32 hsl); + +#endif // _COLOR_H_ diff --git a/src/common/config.c b/src/common/config.c new file mode 100644 index 0000000..da9959e --- /dev/null +++ b/src/common/config.c @@ -0,0 +1,109 @@ +#include +#include +#include +#include +#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); + } + } +} diff --git a/src/common/config.h b/src/common/config.h new file mode 100644 index 0000000..c7eeab3 --- /dev/null +++ b/src/common/config.h @@ -0,0 +1,23 @@ +#ifndef _CONFIG_H_ +#define _CONFIG_H_ + +#include + +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_ diff --git a/src/common/day.c b/src/common/day.c new file mode 100644 index 0000000..cbb9623 --- /dev/null +++ b/src/common/day.c @@ -0,0 +1,41 @@ +#include +#include +#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; +} diff --git a/src/common/day.h b/src/common/day.h new file mode 100644 index 0000000..75cf3e9 --- /dev/null +++ b/src/common/day.h @@ -0,0 +1,21 @@ +#ifndef _DAY_H_ +#define _DAY_H_ + +#include +#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_ diff --git a/src/common/dig.h b/src/common/dig.h new file mode 100644 index 0000000..3885ae4 --- /dev/null +++ b/src/common/dig.h @@ -0,0 +1,12 @@ +#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_ diff --git a/src/common/entity.h b/src/common/entity.h new file mode 100644 index 0000000..f564cee --- /dev/null +++ b/src/common/entity.h @@ -0,0 +1,11 @@ +#ifndef _ENTITY_H_ +#define _ENTITY_H_ + +// ET phone home +typedef enum { + ENTITY_LOCALPLAYER, + ENTITY_PLAYER, + COUNT_ENTITY, +} EntityType; + +#endif // _ENTITY_H_ diff --git a/src/common/environment.c b/src/common/environment.c new file mode 100644 index 0000000..862fdef --- /dev/null +++ b/src/common/environment.c @@ -0,0 +1,12 @@ +#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; +} diff --git a/src/common/environment.h b/src/common/environment.h new file mode 100644 index 0000000..f9a3ef7 --- /dev/null +++ b/src/common/environment.h @@ -0,0 +1,9 @@ +#ifndef _ENVIRONMENT_H_ +#define _ENVIRONMENT_H_ + +#include "types.h" + +f64 get_humidity(v3s32 pos); +f64 get_temperature(v3s32 pos); + +#endif // _ENVIRONMENT_H_ diff --git a/src/common/facedir.c b/src/common/facedir.c new file mode 100644 index 0000000..94c14c7 --- /dev/null +++ b/src/common/facedir.c @@ -0,0 +1,10 @@ +#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}, +}; diff --git a/src/common/facedir.h b/src/common/facedir.h new file mode 100644 index 0000000..b676f0e --- /dev/null +++ b/src/common/facedir.h @@ -0,0 +1,8 @@ +#ifndef _FACEDIR_H_ +#define _FACEDIR_H_ + +#include "types.h" + +extern v3s32 facedir[]; + +#endif // _FACEDIR_H_ diff --git a/src/common/interrupt.c b/src/common/interrupt.c new file mode 100644 index 0000000..590b16f --- /dev/null +++ b/src/common/interrupt.c @@ -0,0 +1,51 @@ +#include +#include +#include +#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); +} diff --git a/src/common/interrupt.h b/src/common/interrupt.h new file mode 100644 index 0000000..9cf840b --- /dev/null +++ b/src/common/interrupt.h @@ -0,0 +1,11 @@ +#ifndef _INTERRUPT_H_ +#define _INTERRUPT_H_ + +#include + +void interrupt_init(); +void interrupt_deinit(); + +extern Flag interrupt; + +#endif // _INTERRUPT_H_ diff --git a/src/common/item.c b/src/common/item.c new file mode 100644 index 0000000..f589ce0 --- /dev/null +++ b/src/common/item.c @@ -0,0 +1,97 @@ +#include +#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}, + }, +}; diff --git a/src/common/item.h b/src/common/item.h new file mode 100644 index 0000000..ffefd61 --- /dev/null +++ b/src/common/item.h @@ -0,0 +1,45 @@ +#ifndef _ITEM_H_ +#define _ITEM_H_ + +#include +#include +#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_ diff --git a/src/common/node.c b/src/common/node.c new file mode 100644 index 0000000..b2422b8 --- /dev/null +++ b/src/common/node.c @@ -0,0 +1,87 @@ +#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, + }, +}; diff --git a/src/common/node.h b/src/common/node.h new file mode 100644 index 0000000..ef21713 --- /dev/null +++ b/src/common/node.h @@ -0,0 +1,39 @@ +#ifndef _NODE_H_ +#define _NODE_H_ + +#include +#include +#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 diff --git a/src/common/perlin.c b/src/common/perlin.c new file mode 100644 index 0000000..687e778 --- /dev/null +++ b/src/common/perlin.c @@ -0,0 +1,3 @@ +#include "common/perlin.h" + +s32 seed = 0; diff --git a/src/common/perlin.h b/src/common/perlin.h new file mode 100644 index 0000000..4bc27a7 --- /dev/null +++ b/src/common/perlin.h @@ -0,0 +1,39 @@ +#ifndef _PERLIN_H_ +#define _PERLIN_H_ + +#include_next +#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_ diff --git a/src/common/physics.c b/src/common/physics.c new file mode 100644 index 0000000..9209790 --- /dev/null +++ b/src/common/physics.c @@ -0,0 +1,125 @@ +#include +#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); +} diff --git a/src/common/physics.h b/src/common/physics.h new file mode 100644 index 0000000..66d00dd --- /dev/null +++ b/src/common/physics.h @@ -0,0 +1,11 @@ +#ifndef _PHYSICS_H_ +#define _PHYSICS_H_ + +#include +#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_ diff --git a/src/common/terrain.c b/src/common/terrain.c new file mode 100644 index 0000000..907cc5a --- /dev/null +++ b/src/common/terrain.c @@ -0,0 +1,249 @@ +#include +#include +#include +#include +#include +#include +#include +#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}; +} diff --git a/src/common/terrain.h b/src/common/terrain.h new file mode 100644 index 0000000..46da156 --- /dev/null +++ b/src/common/terrain.h @@ -0,0 +1,61 @@ +#ifndef _TERRAIN_H_ +#define _TERRAIN_H_ + +#include +#include +#include +#include +#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 diff --git a/src/config.c b/src/config.c deleted file mode 100644 index 8f200c8..0000000 --- a/src/config.c +++ /dev/null @@ -1,109 +0,0 @@ -#include -#include -#include -#include -#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); - } - } -} diff --git a/src/config.h b/src/config.h deleted file mode 100644 index c7eeab3..0000000 --- a/src/config.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef _CONFIG_H_ -#define _CONFIG_H_ - -#include - -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_ diff --git a/src/day.c b/src/day.c deleted file mode 100644 index e28e21b..0000000 --- a/src/day.c +++ /dev/null @@ -1,41 +0,0 @@ -#include -#include -#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; -} diff --git a/src/day.h b/src/day.h deleted file mode 100644 index 75cf3e9..0000000 --- a/src/day.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef _DAY_H_ -#define _DAY_H_ - -#include -#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_ diff --git a/src/debug.sh b/src/debug.sh deleted file mode 100755 index cc4cd54..0000000 --- a/src/debug.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/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 diff --git a/src/debug_loop.sh b/src/debug_loop.sh deleted file mode 100755 index 3c6c460..0000000 --- a/src/debug_loop.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -COMMAND="./debug.sh" - -if [[ $1 == "terrain" ]]; then - COMMAND="./debug_terrain.sh" -fi - -while true; do - if ! $COMMAND; then - read - fi -done diff --git a/src/debug_terrain.sh b/src/debug_terrain.sh deleted file mode 100755 index 7da1b80..0000000 --- a/src/debug_terrain.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -rm -f *.sqlite -./debug.sh diff --git a/src/dig.h b/src/dig.h deleted file mode 100644 index 3885ae4..0000000 --- a/src/dig.h +++ /dev/null @@ -1,12 +0,0 @@ -#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_ diff --git a/src/entity.h b/src/entity.h deleted file mode 100644 index f564cee..0000000 --- a/src/entity.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef _ENTITY_H_ -#define _ENTITY_H_ - -// ET phone home -typedef enum { - ENTITY_LOCALPLAYER, - ENTITY_PLAYER, - COUNT_ENTITY, -} EntityType; - -#endif // _ENTITY_H_ diff --git a/src/environment.c b/src/environment.c deleted file mode 100644 index 200eee7..0000000 --- a/src/environment.c +++ /dev/null @@ -1,12 +0,0 @@ -#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; -} diff --git a/src/environment.h b/src/environment.h deleted file mode 100644 index f9a3ef7..0000000 --- a/src/environment.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _ENVIRONMENT_H_ -#define _ENVIRONMENT_H_ - -#include "types.h" - -f64 get_humidity(v3s32 pos); -f64 get_temperature(v3s32 pos); - -#endif // _ENVIRONMENT_H_ diff --git a/src/facedir.c b/src/facedir.c deleted file mode 100644 index e1125a9..0000000 --- a/src/facedir.c +++ /dev/null @@ -1,10 +0,0 @@ -#include "facedir.h" - -v3s32 facedir[6] = { - {+0, +0, -1}, - {+0, +0, +1}, - {-1, +0, +0}, - {+1, +0, +0}, - {+0, -1, +0}, - {+0, +1, +0}, -}; diff --git a/src/facedir.h b/src/facedir.h deleted file mode 100644 index b676f0e..0000000 --- a/src/facedir.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _FACEDIR_H_ -#define _FACEDIR_H_ - -#include "types.h" - -extern v3s32 facedir[]; - -#endif // _FACEDIR_H_ diff --git a/src/interrupt.c b/src/interrupt.c deleted file mode 100644 index 2b9052c..0000000 --- a/src/interrupt.c +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include -#include -#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); -} diff --git a/src/interrupt.h b/src/interrupt.h deleted file mode 100644 index 9cf840b..0000000 --- a/src/interrupt.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef _INTERRUPT_H_ -#define _INTERRUPT_H_ - -#include - -void interrupt_init(); -void interrupt_deinit(); - -extern Flag interrupt; - -#endif // _INTERRUPT_H_ diff --git a/src/item.c b/src/item.c deleted file mode 100644 index b492aa9..0000000 --- a/src/item.c +++ /dev/null @@ -1,97 +0,0 @@ -#include -#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}, - }, -}; diff --git a/src/item.h b/src/item.h deleted file mode 100644 index c794006..0000000 --- a/src/item.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef _ITEM_H_ -#define _ITEM_H_ - -#include -#include -#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_ diff --git a/src/mingw.cmake b/src/mingw.cmake new file mode 100644 index 0000000..2a51e36 --- /dev/null +++ b/src/mingw.cmake @@ -0,0 +1,4 @@ +set(CMAKE_SYSTEM_NAME Windows) + +set(CMAKE_C_COMPILER i686-w64-mingw32-gcc-posix) +set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++-posix) diff --git a/src/node.c b/src/node.c deleted file mode 100644 index e79352b..0000000 --- a/src/node.c +++ /dev/null @@ -1,87 +0,0 @@ -#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, - }, -}; diff --git a/src/node.h b/src/node.h deleted file mode 100644 index ef21713..0000000 --- a/src/node.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef _NODE_H_ -#define _NODE_H_ - -#include -#include -#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 diff --git a/src/perlin.c b/src/perlin.c deleted file mode 100644 index d204e48..0000000 --- a/src/perlin.c +++ /dev/null @@ -1,3 +0,0 @@ -#include "perlin.h" - -s32 seed = 0; diff --git a/src/perlin.h b/src/perlin.h deleted file mode 100644 index 2aab5e1..0000000 --- a/src/perlin.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef _PERLIN_H_ -#define _PERLIN_H_ - -#include -#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_ diff --git a/src/physics.c b/src/physics.c deleted file mode 100644 index 5fab114..0000000 --- a/src/physics.c +++ /dev/null @@ -1,125 +0,0 @@ -#include -#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); -} diff --git a/src/physics.h b/src/physics.h deleted file mode 100644 index 083cc09..0000000 --- a/src/physics.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef _PHYSICS_H_ -#define _PHYSICS_H_ - -#include -#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_ diff --git a/src/server/biomes.h b/src/server/biomes.h index dce835d..ffdfb31 100644 --- a/src/server/biomes.h +++ b/src/server/biomes.h @@ -1,8 +1,8 @@ #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 { diff --git a/src/server/database.c b/src/server/database.c index 79d1e59..d6cdbca 100644 --- a/src/server/database.c +++ b/src/server/database.c @@ -1,14 +1,14 @@ -#include +#include #include #include #include #include #include -#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; diff --git a/src/server/database.h b/src/server/database.h index 754b6b9..98c5c0e 100644 --- a/src/server/database.h +++ b/src/server/database.h @@ -2,7 +2,7 @@ #define _DATABASE_H_ #include -#include "terrain.h" +#include "common/terrain.h" #include "types.h" bool database_init(); // open and initialize SQLite3 databases diff --git a/src/server/schematic.c b/src/server/schematic.c index af92cfa..8e105d2 100644 --- a/src/server/schematic.c +++ b/src/server/schematic.c @@ -1,9 +1,9 @@ -#include +#include #include #include +#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) { diff --git a/src/server/schematic.h b/src/server/schematic.h index 213645e..06631bf 100644 --- a/src/server/schematic.h +++ b/src/server/schematic.h @@ -4,7 +4,7 @@ #include #include #include -#include "node.h" +#include "common/node.h" #include "server/server_terrain.h" #include "types.h" diff --git a/src/server/server.c b/src/server/server.c index d856512..be3605e 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -4,7 +4,7 @@ #include #include #include -#include "interrupt.h" +#include "common/interrupt.h" #include "server/database.h" #include "server/server.h" #include "server/server_item.h" diff --git a/src/server/server_config.c b/src/server/server_config.c index 242a100..2911f7a 100644 --- a/src/server/server_config.c +++ b/src/server/server_config.c @@ -1,4 +1,4 @@ -#include "config.h" +#include "common/config.h" #include "server/server_config.h" struct ServerConfig server_config = { diff --git a/src/server/server_item.c b/src/server/server_item.c index 70c4c67..18fb36c 100644 --- a/src/server/server_item.c +++ b/src/server/server_item.c @@ -1,5 +1,5 @@ #include -#include "node.h" +#include "common/node.h" #include "server/server_item.h" #include "server/server_node.h" #include "server/server_terrain.h" diff --git a/src/server/server_item.h b/src/server/server_item.h index 9fe5f2d..4163078 100644 --- a/src/server/server_item.h +++ b/src/server/server_item.h @@ -2,7 +2,7 @@ #define _SERVER_ITEM_H_ #include -#include "item.h" +#include "common/item.h" #include "server/server_player.h" #include "types.h" diff --git a/src/server/server_node.h b/src/server/server_node.h index 045ffcc..fadb8ee 100644 --- a/src/server/server_node.h +++ b/src/server/server_node.h @@ -1,7 +1,7 @@ #ifndef _SERVER_NODE_H_ #define _SERVER_NODE_H_ -#include "terrain.h" +#include "common/terrain.h" #include "types.h" TerrainNode server_node_create(NodeType type); diff --git a/src/server/server_player.c b/src/server/server_player.c index c024915..5d0eb10 100644 --- a/src/server/server_player.c +++ b/src/server/server_player.c @@ -3,9 +3,9 @@ #include #include #include -#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" diff --git a/src/server/server_player.h b/src/server/server_player.h index afd7119..956258b 100644 --- a/src/server/server_player.h +++ b/src/server/server_player.h @@ -5,7 +5,7 @@ #include #include #include -#include "item.h" +#include "common/item.h" #include "types.h" typedef struct { diff --git a/src/server/server_terrain.c b/src/server/server_terrain.c index 6078216..4f2ede3 100644 --- a/src/server/server_terrain.c +++ b/src/server/server_terrain.c @@ -8,14 +8,14 @@ #include #include #include -#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; @@ -168,7 +168,7 @@ static void generate_spawn_hut() 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, diff --git a/src/server/server_terrain.h b/src/server/server_terrain.h index 4cd2ce3..8c0104e 100644 --- a/src/server/server_terrain.h +++ b/src/server/server_terrain.h @@ -3,8 +3,8 @@ #include #include +#include "common/terrain.h" #include "server/server_player.h" -#include "terrain.h" #include "types.h" typedef enum { diff --git a/src/server/terrain_gen.c b/src/server/terrain_gen.c index b913167..74d1403 100644 --- a/src/server/terrain_gen.c +++ b/src/server/terrain_gen.c @@ -1,8 +1,8 @@ #include #include #include -#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" diff --git a/src/server/terrain_gen.h b/src/server/terrain_gen.h index ce07148..ca7d8ce 100644 --- a/src/server/terrain_gen.h +++ b/src/server/terrain_gen.h @@ -1,8 +1,8 @@ #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) diff --git a/src/server/tree.h b/src/server/tree.h index 2eb08aa..fbce233 100644 --- a/src/server/tree.h +++ b/src/server/tree.h @@ -3,8 +3,8 @@ #include #include -#include "perlin.h" -#include "terrain.h" +#include "common/perlin.h" +#include "common/terrain.h" #include "types.h" #define NUM_TREES 3 diff --git a/src/server/tree_physics.c b/src/server/tree_physics.c index 7db6a10..b1da431 100644 --- a/src/server/tree_physics.c +++ b/src/server/tree_physics.c @@ -7,7 +7,7 @@ #include #include #include -#include "facedir.h" +#include "common/facedir.h" #include "server/server_node.h" #include "server/server_terrain.h" #include "server/tree_physics.h" diff --git a/src/server/voxel_depth_search.c b/src/server/voxel_depth_search.c index edf9fb5..b775025 100644 --- a/src/server/voxel_depth_search.c +++ b/src/server/voxel_depth_search.c @@ -1,5 +1,5 @@ #include -#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 diff --git a/src/server/voxel_procedural.c b/src/server/voxel_procedural.c index 2eb9bf8..4adce68 100644 --- a/src/server/voxel_procedural.c +++ b/src/server/voxel_procedural.c @@ -1,7 +1,7 @@ #include #include -#include "color.h" -#include "perlin.h" +#include "common/color.h" +#include "common/perlin.h" #include "server/terrain_gen.h" #include "server/voxel_procedural.h" diff --git a/src/server/voxel_procedural.h b/src/server/voxel_procedural.h index 6de0f1e..6d753f0 100644 --- a/src/server/voxel_procedural.h +++ b/src/server/voxel_procedural.h @@ -2,7 +2,7 @@ #define _VOXEL_PROCEDURAL_H_ #include -#include +#include #include "server/server_terrain.h" #include "types.h" diff --git a/src/terrain.c b/src/terrain.c deleted file mode 100644 index 5f7b928..0000000 --- a/src/terrain.c +++ /dev/null @@ -1,249 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#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}; -} diff --git a/src/terrain.h b/src/terrain.h deleted file mode 100644 index c6aea4e..0000000 --- a/src/terrain.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef _TERRAIN_H_ -#define _TERRAIN_H_ - -#include -#include -#include -#include -#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 diff --git a/textures/crosshair.png b/textures/crosshair.png deleted file mode 100644 index 8f03d32..0000000 Binary files a/textures/crosshair.png and /dev/null differ diff --git a/textures/dirt.png b/textures/dirt.png deleted file mode 100644 index 9a64b49..0000000 Binary files a/textures/dirt.png and /dev/null differ diff --git a/textures/grass.png b/textures/grass.png deleted file mode 100644 index 70a3522..0000000 Binary files a/textures/grass.png and /dev/null differ diff --git a/textures/lava.png b/textures/lava.png deleted file mode 100644 index 48aaccf..0000000 Binary files a/textures/lava.png and /dev/null differ diff --git a/textures/lava_nt.png b/textures/lava_nt.png deleted file mode 100644 index e44018f..0000000 Binary files a/textures/lava_nt.png and /dev/null differ diff --git a/textures/models/player/arm/back.png b/textures/models/player/arm/back.png deleted file mode 100644 index 69ffff3..0000000 Binary files a/textures/models/player/arm/back.png and /dev/null differ diff --git a/textures/models/player/arm/bottom.png b/textures/models/player/arm/bottom.png deleted file mode 100644 index fda334e..0000000 Binary files a/textures/models/player/arm/bottom.png and /dev/null differ diff --git a/textures/models/player/arm/front.png b/textures/models/player/arm/front.png deleted file mode 100644 index ce19461..0000000 Binary files a/textures/models/player/arm/front.png and /dev/null differ diff --git a/textures/models/player/arm/left.png b/textures/models/player/arm/left.png deleted file mode 100644 index c2b2325..0000000 Binary files a/textures/models/player/arm/left.png and /dev/null differ diff --git a/textures/models/player/arm/right.png b/textures/models/player/arm/right.png deleted file mode 100644 index 9ae2e41..0000000 Binary files a/textures/models/player/arm/right.png and /dev/null differ diff --git a/textures/models/player/arm/top.png b/textures/models/player/arm/top.png deleted file mode 100644 index e12765d..0000000 Binary files a/textures/models/player/arm/top.png and /dev/null differ diff --git a/textures/models/player/chest/back.png b/textures/models/player/chest/back.png deleted file mode 100644 index 5eca9ec..0000000 Binary files a/textures/models/player/chest/back.png and /dev/null differ diff --git a/textures/models/player/chest/bottom.png b/textures/models/player/chest/bottom.png deleted file mode 100644 index 131d33d..0000000 Binary files a/textures/models/player/chest/bottom.png and /dev/null differ diff --git a/textures/models/player/chest/front.png b/textures/models/player/chest/front.png deleted file mode 100644 index d44fd42..0000000 Binary files a/textures/models/player/chest/front.png and /dev/null differ diff --git a/textures/models/player/chest/left.png b/textures/models/player/chest/left.png deleted file mode 100644 index 995ad5f..0000000 Binary files a/textures/models/player/chest/left.png and /dev/null differ diff --git a/textures/models/player/chest/right.png b/textures/models/player/chest/right.png deleted file mode 100644 index e48eb66..0000000 Binary files a/textures/models/player/chest/right.png and /dev/null differ diff --git a/textures/models/player/chest/top.png b/textures/models/player/chest/top.png deleted file mode 100644 index df84083..0000000 Binary files a/textures/models/player/chest/top.png and /dev/null differ diff --git a/textures/models/player/head/back.png b/textures/models/player/head/back.png deleted file mode 100644 index 935a2b9..0000000 Binary files a/textures/models/player/head/back.png and /dev/null differ diff --git a/textures/models/player/head/bottom.png b/textures/models/player/head/bottom.png deleted file mode 100644 index 1fdae43..0000000 Binary files a/textures/models/player/head/bottom.png and /dev/null differ diff --git a/textures/models/player/head/front.png b/textures/models/player/head/front.png deleted file mode 100644 index 805fec0..0000000 Binary files a/textures/models/player/head/front.png and /dev/null differ diff --git a/textures/models/player/head/left.png b/textures/models/player/head/left.png deleted file mode 100644 index 7dc2a81..0000000 Binary files a/textures/models/player/head/left.png and /dev/null differ diff --git a/textures/models/player/head/right.png b/textures/models/player/head/right.png deleted file mode 100644 index 47436ba..0000000 Binary files a/textures/models/player/head/right.png and /dev/null differ diff --git a/textures/models/player/head/top.png b/textures/models/player/head/top.png deleted file mode 100644 index 916ea2b..0000000 Binary files a/textures/models/player/head/top.png and /dev/null differ diff --git a/textures/models/player/leg/back.png b/textures/models/player/leg/back.png deleted file mode 100644 index 48b93ce..0000000 Binary files a/textures/models/player/leg/back.png and /dev/null differ diff --git a/textures/models/player/leg/bottom.png b/textures/models/player/leg/bottom.png deleted file mode 100644 index 0c942fb..0000000 Binary files a/textures/models/player/leg/bottom.png and /dev/null differ diff --git a/textures/models/player/leg/front.png b/textures/models/player/leg/front.png deleted file mode 100644 index 13b1016..0000000 Binary files a/textures/models/player/leg/front.png and /dev/null differ diff --git a/textures/models/player/leg/left.png b/textures/models/player/leg/left.png deleted file mode 100644 index 104c6e7..0000000 Binary files a/textures/models/player/leg/left.png and /dev/null differ diff --git a/textures/models/player/leg/right.png b/textures/models/player/leg/right.png deleted file mode 100644 index a97a13a..0000000 Binary files a/textures/models/player/leg/right.png and /dev/null differ diff --git a/textures/models/player/leg/top.png b/textures/models/player/leg/top.png deleted file mode 100644 index d575dc7..0000000 Binary files a/textures/models/player/leg/top.png and /dev/null differ diff --git a/textures/needles.png b/textures/needles.png deleted file mode 100644 index 24e3ed4..0000000 Binary files a/textures/needles.png and /dev/null differ diff --git a/textures/oak_leaves.png b/textures/oak_leaves.png deleted file mode 100644 index a29369a..0000000 Binary files a/textures/oak_leaves.png and /dev/null differ diff --git a/textures/oak_wood.png b/textures/oak_wood.png deleted file mode 100644 index 90af189..0000000 Binary files a/textures/oak_wood.png and /dev/null differ diff --git a/textures/oak_wood_top.png b/textures/oak_wood_top.png deleted file mode 100644 index cf8ed6f..0000000 Binary files a/textures/oak_wood_top.png and /dev/null differ diff --git a/textures/palm_leaves.png b/textures/palm_leaves.png deleted file mode 100644 index 9d44925..0000000 Binary files a/textures/palm_leaves.png and /dev/null differ diff --git a/textures/palm_wood.png b/textures/palm_wood.png deleted file mode 100644 index 5f0295d..0000000 Binary files a/textures/palm_wood.png and /dev/null differ diff --git a/textures/palm_wood_top.png b/textures/palm_wood_top.png deleted file mode 100644 index 276ae1e..0000000 Binary files a/textures/palm_wood_top.png and /dev/null differ diff --git a/textures/pine_leaves.png b/textures/pine_leaves.png deleted file mode 100644 index 24e3ed4..0000000 Binary files a/textures/pine_leaves.png and /dev/null differ diff --git a/textures/pine_wood.png b/textures/pine_wood.png deleted file mode 100644 index fae7da1..0000000 Binary files a/textures/pine_wood.png and /dev/null differ diff --git a/textures/pine_wood_top.png b/textures/pine_wood_top.png deleted file mode 100644 index 276ae1e..0000000 Binary files a/textures/pine_wood_top.png and /dev/null differ diff --git a/textures/player.png b/textures/player.png deleted file mode 100644 index f403dc3..0000000 Binary files a/textures/player.png and /dev/null differ diff --git a/textures/sand.png b/textures/sand.png deleted file mode 100644 index 3899f4b..0000000 Binary files a/textures/sand.png and /dev/null differ diff --git a/textures/skybox/day/back.png b/textures/skybox/day/back.png deleted file mode 100644 index 6b98546..0000000 Binary files a/textures/skybox/day/back.png and /dev/null differ diff --git a/textures/skybox/day/bottom.png b/textures/skybox/day/bottom.png deleted file mode 100644 index ceaa6aa..0000000 Binary files a/textures/skybox/day/bottom.png and /dev/null differ diff --git a/textures/skybox/day/front.png b/textures/skybox/day/front.png deleted file mode 100644 index f62ee88..0000000 Binary files a/textures/skybox/day/front.png and /dev/null differ diff --git a/textures/skybox/day/left.png b/textures/skybox/day/left.png deleted file mode 100644 index 558391a..0000000 Binary files a/textures/skybox/day/left.png and /dev/null differ diff --git a/textures/skybox/day/right.png b/textures/skybox/day/right.png deleted file mode 100644 index b1b7b9f..0000000 Binary files a/textures/skybox/day/right.png and /dev/null differ diff --git a/textures/skybox/day/top.png b/textures/skybox/day/top.png deleted file mode 100644 index 45567ca..0000000 Binary files a/textures/skybox/day/top.png and /dev/null differ diff --git a/textures/skybox/night/back.png b/textures/skybox/night/back.png deleted file mode 100644 index 0a0a862..0000000 Binary files a/textures/skybox/night/back.png and /dev/null differ diff --git a/textures/skybox/night/bottom.png b/textures/skybox/night/bottom.png deleted file mode 100644 index e51749a..0000000 Binary files a/textures/skybox/night/bottom.png and /dev/null differ diff --git a/textures/skybox/night/front.png b/textures/skybox/night/front.png deleted file mode 100644 index 6ec46e1..0000000 Binary files a/textures/skybox/night/front.png and /dev/null differ diff --git a/textures/skybox/night/left.png b/textures/skybox/night/left.png deleted file mode 100644 index c04fb71..0000000 Binary files a/textures/skybox/night/left.png and /dev/null differ diff --git a/textures/skybox/night/right.png b/textures/skybox/night/right.png deleted file mode 100644 index 60329f4..0000000 Binary files a/textures/skybox/night/right.png and /dev/null differ diff --git a/textures/skybox/night/top.png b/textures/skybox/night/top.png deleted file mode 100644 index 2711dd1..0000000 Binary files a/textures/skybox/night/top.png and /dev/null differ diff --git a/textures/snow.png b/textures/snow.png deleted file mode 100644 index 359335e..0000000 Binary files a/textures/snow.png and /dev/null differ diff --git a/textures/stone.png b/textures/stone.png deleted file mode 100644 index 3af8ac9..0000000 Binary files a/textures/stone.png and /dev/null differ diff --git a/textures/sun.png b/textures/sun.png deleted file mode 100644 index fb3b88d..0000000 Binary files a/textures/sun.png and /dev/null differ diff --git a/textures/unknown.png b/textures/unknown.png deleted file mode 100644 index bbea82c..0000000 Binary files a/textures/unknown.png and /dev/null differ diff --git a/textures/vulcano_stone.png b/textures/vulcano_stone.png deleted file mode 100644 index c359713..0000000 Binary files a/textures/vulcano_stone.png and /dev/null differ diff --git a/textures/water.png b/textures/water.png deleted file mode 100644 index b9a66fd..0000000 Binary files a/textures/water.png and /dev/null differ diff --git a/textures/water_nt.png b/textures/water_nt.png deleted file mode 100644 index f457566..0000000 Binary files a/textures/water_nt.png and /dev/null differ diff --git a/upload.sh b/upload.sh index fa554b9..214981b 100755 --- a/upload.sh +++ b/upload.sh @@ -1,13 +1,18 @@ #!/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