From 5ef48b867e21c60b596303441b44cc6e4e8ab315 Mon Sep 17 00:00:00 2001 From: TheBrokenRail <17478432+TheBrokenRail@users.noreply.github.com> Date: Thu, 1 May 2025 17:49:29 -0400 Subject: [PATCH 001/293] MinGW Support + CMake Refactor (#149) * MinGW Support + CMake Refactor * Updated Xcode Project * Update build.yml * Make Requested Changes * Properly Build stb_vorbis * Remove Unused Makefiles * CMake Fix --------- Co-authored-by: BrentDaMage Co-authored-by: Brent <43089001+BrentDaMage@users.noreply.github.com> --- .github/workflows/build.yml | 63 ++++-- .gitignore | 10 +- .gitmodules | 3 - CMakeLists.txt | 64 ++++++ Makefile | 71 ------- MakefileMinGW | 86 -------- README.md | 7 +- build-wasm.sh | 2 +- cmake/mingw-w64-toolchain.cmake | 11 ++ compat/KeyCodes.hpp | 2 +- platforms/CMakeLists.txt | 12 ++ platforms/android/AppPlatform_android.cpp | 4 +- .../app/src/main/cpp => }/CMakeLists.txt | 20 +- platforms/android/project/app/build.gradle | 4 +- .../Minecraft.xcodeproj/project.pbxproj | 184 +++++++++--------- platforms/openal/CMakeLists.txt | 31 --- platforms/sdl/CMakeLists.txt | 82 ++++---- platforms/sdl/android/app/build.gradle | 2 +- .../android/app/src/main/AndroidManifest.xml | 4 +- platforms/sdl/base/AppPlatform_sdl_base.cpp | 34 ++-- platforms/sdl/base/AppPlatform_sdl_base.hpp | 7 +- platforms/sdl/desktop/AppPlatform_sdl.cpp | 16 +- platforms/sdl/desktop/AppPlatform_sdl.hpp | 2 + platforms/sdl/main.cpp | 28 ++- platforms/sound/CMakeLists.txt | 10 + platforms/sound/directsound/CMakeLists.txt | 17 ++ .../directsound/CustomSoundSystem.hpp} | 6 +- .../directsound}/SoundSystemDS.cpp | 2 +- platforms/sound/openal/CMakeLists.txt | 32 +++ .../openal/CustomSoundSystem.hpp} | 21 +- .../{ => sound}/openal/SoundSystemAL.cpp | 5 +- platforms/sound/opensl/CMakeLists.txt | 16 ++ .../opensl/CustomSoundSystem.hpp} | 4 +- .../opensl}/SoundSystemSL.cpp | 2 +- platforms/windows/AppPlatform_win32.cpp | 9 +- platforms/windows/AppPlatform_win32.hpp | 5 +- platforms/windows/CMakeLists.txt | 28 +++ platforms/windows/LoggerWin32.hpp | 2 +- platforms/windows/main.cpp | 7 +- .../MinecraftClient.Win32.vcxproj | 4 +- .../MinecraftClient.Win32.vcxproj.filters | 4 +- source/CMakeLists.txt | 75 ++----- source/client/app/AppPlatform.hpp | 3 +- source/client/app/Minecraft.cpp | 3 - source/client/app/Minecraft.hpp | 1 - source/client/gui/screens/StartMenuScreen.cpp | 2 +- source/client/renderer/GameRenderer.cpp | 2 + source/client/renderer/Lighting.cpp | 2 + source/client/renderer/Tesselator.cpp | 5 +- source/client/renderer/entity/MobRenderer.cpp | 2 + source/common/CThread.cpp | 2 +- source/common/CThread.hpp | 4 +- source/common/Logger.cpp | 9 +- source/common/Logger.hpp | 2 +- source/common/Utils.cpp | 4 +- source/common/Utils.hpp | 6 +- thirdparty/GL/GL.hpp | 9 +- thirdparty/SDL2/SDL2.h | 1 + thirdparty/gles-compatibility-layer | 1 - thirdparty/raknet/CMakeLists.txt | 9 + thirdparty/raknet/WindowsIncludes.h | 4 +- thirdparty/stb_image/CMakeLists.txt | 2 + 62 files changed, 538 insertions(+), 533 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 Makefile delete mode 100644 MakefileMinGW create mode 100644 cmake/mingw-w64-toolchain.cmake create mode 100644 platforms/CMakeLists.txt rename platforms/android/{project/app/src/main/cpp => }/CMakeLists.txt (63%) delete mode 100644 platforms/openal/CMakeLists.txt create mode 100644 platforms/sound/CMakeLists.txt create mode 100644 platforms/sound/directsound/CMakeLists.txt rename platforms/{windows/SoundSystemDS.hpp => sound/directsound/CustomSoundSystem.hpp} (95%) rename platforms/{windows => sound/directsound}/SoundSystemDS.cpp (99%) create mode 100644 platforms/sound/openal/CMakeLists.txt rename platforms/{openal/SoundSystemAL.hpp => sound/openal/CustomSoundSystem.hpp} (87%) rename platforms/{ => sound}/openal/SoundSystemAL.cpp (99%) create mode 100644 platforms/sound/opensl/CMakeLists.txt rename platforms/{android/SoundSystemSL.hpp => sound/opensl/CustomSoundSystem.hpp} (97%) rename platforms/{android => sound/opensl}/SoundSystemSL.cpp (99%) create mode 100644 platforms/windows/CMakeLists.txt delete mode 160000 thirdparty/gles-compatibility-layer diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2ad9186a4..b0bb0a1a0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,38 +6,33 @@ on: jobs: linux: - strategy: - fail-fast: false - matrix: - include: - - name: OpenGL ES - flags: "-DUSE_GLES1_COMPATIBILITY_LAYER=ON" - - name: OpenGL - flags: "-DUSE_GLES1_COMPATIBILITY_LAYER=OFF" - name: Linux (${{ matrix.name }}) + name: Linux runs-on: ubuntu-latest steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true - name: Install Dependencies run: | sudo apt-get update - sudo apt-get install --no-install-recommends -y build-essential cmake ninja-build libopenal-dev libsdl2-dev zlib1g-dev + sudo apt-get install --no-install-recommends -y \ + build-essential \ + cmake ninja-build \ + libopenal-dev \ + libsdl2-dev zlib1g-dev - name: Build run: | - cd platforms/sdl mkdir build cd build - cmake -GNinja ${{ matrix.flags }} .. + cmake -GNinja .. cmake --build . wasm: name: WASM runs-on: ubuntu-latest steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true - name: Install Dependencies @@ -51,15 +46,16 @@ jobs: runs-on: macos-latest steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true - name: Install MacPorts uses: melusina-org/setup-macports@v1 - name: Install Dependencies run: | - sudo port install libsdl2 +universal - sudo port install libpng +universal + port selfupdate + port install libsdl2 +universal + port install libpng +universal - name: Build macOS Archive run: | cd platforms/macos/projects/Minecraft @@ -103,11 +99,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true - name: Setup JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: '17' distribution: 'temurin' @@ -116,3 +112,32 @@ jobs: run: | cd ${{ matrix.directory }} ./gradlew build + mingw: + strategy: + fail-fast: false + matrix: + include: + - name: Win32 + flags: "-DREMCPE_PLATFORM=windows" + - name: SDL + flags: "-DREMCPE_PLATFORM=sdl" + name: MinGW-w64 (${{ matrix.name }}) + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + submodules: true + - name: Install Dependencies + run: | + sudo apt-get update + sudo apt-get install --no-install-recommends -y \ + build-essential \ + cmake ninja-build \ + mingw-w64 + - name: Build + run: | + mkdir build + cd build + cmake -GNinja -DCMAKE_TOOLCHAIN_FILE=../cmake/mingw-w64-toolchain.cmake ${{ matrix.flags }} .. + cmake --build . diff --git a/.gitignore b/.gitignore index 22c107a57..85fe04251 100644 --- a/.gitignore +++ b/.gitignore @@ -123,7 +123,7 @@ xcuserdata/ /sound_data # Ignore linux/mingw build artifacts. -/build +/build* /minecraftcpp /minecraftcpp.exe @@ -242,3 +242,11 @@ xcuserdata/ # Ignore options.txt - where your configuration will be saved /game/options.txt /game/assetsO +/game/assets/gui/feedback_fill.png +/game/assets/gui/feedback_outer.png +/game/assets/snow.png +/game/assets/mob/pig.png + +# CLion +/.idea +/cmake-build-* \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 8838e392c..602032d83 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,6 @@ [submodule "thirdparty/coi-serviceworker"] path = thirdparty/coi-serviceworker url = https://github.com/gzuidhof/coi-serviceworker.git -[submodule "thirdparty/gles-compatibility-layer"] - path = thirdparty/gles-compatibility-layer - url = https://github.com/TheBrokenRail/gles-compatibility-layer.git [submodule "thirdparty/SDL-src"] path = thirdparty/SDL2/src url = https://github.com/libsdl-org/SDL.git diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..0a1bc69b7 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,64 @@ +cmake_minimum_required(VERSION 3.16.0) +project(reminecraftpe) + +# Store Output In Top-Level Build Directory +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") + +# WASM +if(EMSCRIPTEN) + function(add_compile_and_link_options) + add_compile_options(${ARGV}) + add_link_options(${ARGV}) + endfunction() + set(CMAKE_EXECUTABLE_SUFFIX ".js") + add_link_options("$<$:-gsource-map>") + add_link_options(-Wno-pthreads-mem-growth -sALLOW_MEMORY_GROWTH=1) +endif() + +# Clang +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + add_compile_options(-Wno-inconsistent-missing-override -Wno-enum-compare-switch -Wno-register) +endif() + +# Windows Linking +if(WIN32) + add_link_options( + -static-libgcc + -static-libstdc++ + ) +endif() + +# HaikuOS Network Library +if(HAIKU) + link_libraries(network) +endif() + +# Threading +if(EMSCRIPTEN) + add_compile_and_link_options(-pthread) +else() + find_package(Threads) + link_libraries(Threads::Threads) +endif() + +# Android Logging +if(ANDROID) + link_libraries(log) +endif() + +# stb_image And Other Libraries +add_subdirectory(thirdparty/stb_image EXCLUDE_FROM_ALL) + +# Load Common Code +add_subdirectory(source) + +# Load Platform-Specific Code +add_subdirectory(platforms) + +# Assets +if(EMSCRIPTEN) + target_link_options(reminecraftpe PRIVATE --use-preload-plugins --preload-file "${CMAKE_CURRENT_SOURCE_DIR}/game@/") +else() + file(CREATE_LINK "${CMAKE_CURRENT_SOURCE_DIR}/game/assets" "${CMAKE_CURRENT_BINARY_DIR}/assets" SYMBOLIC) +endif() \ No newline at end of file diff --git a/Makefile b/Makefile deleted file mode 100644 index 3b3441833..000000000 --- a/Makefile +++ /dev/null @@ -1,71 +0,0 @@ -# ReMinecraftPE - Makefile for linux - -# Commonly included directories. -SRC_DIR=source -BLD_DIR=build -RKN_DIR=thirdparty/raknet -ZLB_DIR=thirdparty/zlib -PLT_DIR=platforms - -# Target executable's name. -TARGET=minecraftcpp - -# Compilation flags for C++ source files -CXXFLAGS=-Isource -I. -Ithirdparty/raknet -Ithirdparty/zlib -DUSE_SDL -DUSE_OPENAL -DUSE_MATH_DEFINES -DHANDLE_CHARS_SEPARATELY -O3 -MMD - -# Compilation flags for zlib source files -ZLIBFLAGS=-O3 -I. -MMD - -# Link flags -LINKFLAGS=-L/opt/vc/lib/ -lpng -lpthread -lSDL2 -lGL -lopenal -lGLU - -#include everything in source/, plus certain files from platforms -SRC_FILES = $(shell find $(SRC_DIR) -type f -name '*.cpp') -PLT_FILES = $(shell find $(PLT_DIR)/sdl $(PLT_DIR)/openal -type f -name '*.cpp') -RKN_FILES = $(shell find $(RKN_DIR) -type f -name '*.cpp') -ZLB_FILES = $(shell find $(ZLB_DIR) -type f -name '*.c') - -OBJ_FILES = \ - $(patsubst $(SRC_DIR)/%,$(BLD_DIR)/s/%,$(SRC_FILES:.cpp=.o)) \ - $(patsubst $(PLT_DIR)/%,$(BLD_DIR)/p/%,$(PLT_FILES:.cpp=.o)) \ - $(patsubst $(RKN_DIR)/%,$(BLD_DIR)/r/%,$(RKN_FILES:.cpp=.o)) \ - $(patsubst $(ZLB_DIR)/%,$(BLD_DIR)/z/%,$(ZLB_FILES:.c=.o)) - -DEP_FILES = \ - $(patsubst $(SRC_DIR)/%,$(BLD_DIR)/s/%,$(SRC_FILES:.cpp=.d)) \ - $(patsubst $(PLT_DIR)/%,$(BLD_DIR)/p/%,$(PLT_FILES:.cpp=.d)) \ - $(patsubst $(RKN_DIR)/%,$(BLD_DIR)/r/%,$(RKN_FILES:.cpp=.d)) \ - $(patsubst $(ZLB_DIR)/%,$(BLD_DIR)/z/%,$(ZLB_FILES:.c=.d)) - -#default target. -.PHONY = all -all: program - -#link rules for the executable -$(TARGET): $(OBJ_FILES) - $(CXX) -o $@ $^ $(LINKFLAGS) - -#include header dependencies --include $(DEP_FILES) - -$(BLD_DIR)/p/%.o: $(PLT_DIR)/%.cpp - @mkdir -p $(dir $@) - $(CXX) $(CXXFLAGS) -c -o $@ $< - -$(BLD_DIR)/r/%.o: $(RKN_DIR)/%.cpp - @mkdir -p $(dir $@) - $(CXX) $(CXXFLAGS) -c -o $@ $< - -$(BLD_DIR)/z/%.o: $(ZLB_DIR)/%.c - @mkdir -p $(dir $@) - $(CC) $(ZLIBFLAGS) -c -o $@ $< - -$(BLD_DIR)/s/%.o: $(SRC_DIR)/%.cpp - @mkdir -p $(dir $@) - $(CXX) $(CXXFLAGS) -c -o $@ $< - -program: $(TARGET) - -clean: - rm -rf $(BLD_DIR) - rm -rf minecraftcpp diff --git a/MakefileMinGW b/MakefileMinGW deleted file mode 100644 index ab6f58460..000000000 --- a/MakefileMinGW +++ /dev/null @@ -1,86 +0,0 @@ -# ReMinecraftPE - Makefile for MinGW - -# User Settings -EMULATE_VBOS ?= no - -ifeq ($(EMULATE_VBOS), yes) - VBO_EMULATION_FLAG = -DUSE_GL_VBO_EMULATION -endif - -# Commonly included directories. -SRC_DIR=source -BLD_DIR=build -RKN_DIR=thirdparty/raknet -ZLB_DIR=thirdparty/zlib -PLT_DIR=platforms -TGL_DIR=thirdparty/GL - -# Target executable's name. -TARGET=minecraftcpp.exe - -# Compilation flags for C++ source files -CXXFLAGS=-Isource -I. -Ithirdparty/raknet -Ithirdparty/zlib -DUSE_MATH_DEFINES -DSHA1_HAS_TCHAR -DHANDLE_CHARS_SEPARATELY -DUSE_WIN32_THREADS -DLOCKLESS_TYPES_USE_MUTEX -DNDEBUG -O3 -mno-sse -mno-sse2 -mno-mmx -march=i386 -MMD $(VBO_EMULATION_FLAG) - -# Compilation flags for zlib source files -ZLIBFLAGS=-O3 -I. -MMD -Ithirdparty/stb_image/include - -# Link flags -LINKFLAGS=-lopengl32 -lws2_32 -lglu32 -lgdi32 -ldsound -ldxguid -luuid -static-libgcc -mwindows - -#include everything in source/, plus certain files from platforms -SRC_FILES = $(shell find $(SRC_DIR) -name '*.cpp') -PLT_FILES = $(shell find $(PLT_DIR)/windows -name '*.cpp') -RKN_FILES = $(shell find $(RKN_DIR) -name '*.cpp') -TGL_FILES = $(shell find $(TGL_DIR) -name '*.cpp') -ZLB_FILES = $(shell find $(ZLB_DIR) -name '*.c') - -OBJ_FILES = \ - $(patsubst $(SRC_DIR)/%,$(BLD_DIR)/s/%,$(SRC_FILES:.cpp=.o)) \ - $(patsubst $(PLT_DIR)/%,$(BLD_DIR)/p/%,$(PLT_FILES:.cpp=.o)) \ - $(patsubst $(RKN_DIR)/%,$(BLD_DIR)/r/%,$(RKN_FILES:.cpp=.o)) \ - $(patsubst $(TGL_DIR)/%,$(BLD_DIR)/g/%,$(TGL_FILES:.cpp=.o)) \ - $(patsubst $(ZLB_DIR)/%,$(BLD_DIR)/z/%,$(ZLB_FILES:.c=.o)) \ - build/t/stb_image_impl.o - -DEP_FILES = $(OBJ_FILES:.o=.d)) - -#default target. -.PHONY = all -all: program - -#link rules for the executable -$(TARGET): $(OBJ_FILES) - $(CXX) -o $@ $^ $(LINKFLAGS) - -#include header dependencies --include $(DEP_FILES) - -$(BLD_DIR)/p/%.o: $(PLT_DIR)/%.cpp - @mkdir -p $(dir $@) - $(CXX) $(CXXFLAGS) -c -o $@ $< - -$(BLD_DIR)/g/%.o: $(TGL_DIR)/%.cpp - @mkdir -p $(dir $@) - $(CXX) $(CXXFLAGS) -c -o $@ $< - -$(BLD_DIR)/r/%.o: $(RKN_DIR)/%.cpp - @mkdir -p $(dir $@) - $(CXX) $(CXXFLAGS) -c -o $@ $< - -$(BLD_DIR)/z/%.o: $(ZLB_DIR)/%.c - @mkdir -p $(dir $@) - $(CC) $(ZLIBFLAGS) -c -o $@ $< - -$(BLD_DIR)/s/%.o: $(SRC_DIR)/%.cpp - @mkdir -p $(dir $@) - $(CXX) $(CXXFLAGS) -c -o $@ $< - -$(BLD_DIR)/t/%.o: thirdparty/stb_image/src/%.c - @mkdir -p $(dir $@) - $(CC) $(ZLIBFLAGS) -c -o $@ $< - -program: $(TARGET) - -clean: - rm -rf $(BLD_DIR) - rm -rf minecraftcpp diff --git a/README.md b/README.md index ebb4e7b9e..d72711ee5 100644 --- a/README.md +++ b/README.md @@ -11,12 +11,12 @@ based on Minecraft PE v0.1.3. * To keep the source code layout similar to the original Minecraft PE (reconstructed from clues hidden within certain versions of the game, such as the 0.1.0 touch prototype/debug build) * To port the game to more platforms, such as Windows (including older versions), Xbox 360, Wii, and more. - Currently there are ports for: + Currently, there are ports for: * Windows XP-11 * Android (thanks to [Stom](https://github.com/Stommm) for the help) * Linux * WebGL - * Mac OS (port by [BrentDaMage](https://github.com/BrentDaMage)) + * macOS (port by [BrentDaMage](https://github.com/BrentDaMage)) * iOS (3.0 and above; port by [BrentDaMage](https://github.com/BrentDaMage)) * HaikuOS (thanks to [SanyaSho](https://github.com/SanyaSho)) * Xbox 360 (work in progress; port by [BrentDaMage](https://github.com/BrentDaMage)) @@ -36,7 +36,7 @@ Note: While the original Minecraft PE v0.1.3 may not work on newer devices, ReMi ## License information -This project is licensed under the [BSD 1 clause license](LICENSE.md). However, it contains third party +This project is licensed under the [BSD 1 clause license](LICENSE.txt). However, it contains third party software with different but compatible licenses: - [RakNet](https://github.com/facebookarchive/RakNet): [Licensed under the BSD 2 clause license](thirdparty/raknet/LICENSE) @@ -142,7 +142,6 @@ This project uses CMake on Linux. Just like WebAssembly, the game assets must be #### How To Build ```sh -cd platforms/sdl mkdir build && cd build cmake -GNinja .. cmake --build . diff --git a/build-wasm.sh b/build-wasm.sh index bc1265706..033140ec2 100755 --- a/build-wasm.sh +++ b/build-wasm.sh @@ -31,7 +31,7 @@ mkdir -p build cd build # Configure Build -emcmake cmake -GNinja "$@" ../../platforms/sdl +emcmake cmake -GNinja "$@" ../../ # Build cmake --build . diff --git a/cmake/mingw-w64-toolchain.cmake b/cmake/mingw-w64-toolchain.cmake new file mode 100644 index 000000000..9610577a5 --- /dev/null +++ b/cmake/mingw-w64-toolchain.cmake @@ -0,0 +1,11 @@ +# https://gist.github.com/peterspackman/8cf73f7f12ba270aa8192d6911972fe8 +set(CMAKE_SYSTEM_NAME Windows) +set(TOOLCHAIN_PREFIX x86_64-w64-mingw32) +set(CMAKE_C_COMPILER "${TOOLCHAIN_PREFIX}-gcc") +set(CMAKE_CXX_COMPILER "${TOOLCHAIN_PREFIX}-g++") +set(CMAKE_Fortran_COMPILER "${TOOLCHAIN_PREFIX}-gfortran") +set(CMAKE_RC_COMPILER "${TOOLCHAIN_PREFIX}-windres") +set(CMAKE_FIND_ROOT_PATH "/usr/${TOOLCHAIN_PREFIX}") +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) \ No newline at end of file diff --git a/compat/KeyCodes.hpp b/compat/KeyCodes.hpp index 783a04595..f2316c5f1 100644 --- a/compat/KeyCodes.hpp +++ b/compat/KeyCodes.hpp @@ -23,7 +23,7 @@ enum eSDLVirtualKeys #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN - #include + #include #elif __APPLE__ // https://i.stack.imgur.com/LD8pT.png #define AKEYCODE_FORWARD_DEL 0x75 diff --git a/platforms/CMakeLists.txt b/platforms/CMakeLists.txt new file mode 100644 index 000000000..daf641034 --- /dev/null +++ b/platforms/CMakeLists.txt @@ -0,0 +1,12 @@ +project(reminecraftpe-platforms) + +# Select & Build +set(DEFAULT_PLATFORM "sdl") +if(WIN32) + set(DEFAULT_PLATFORM "windows") +endif() +set(REMCPE_PLATFORM "${DEFAULT_PLATFORM}" CACHE STRING "ReMCPE Platform (Check /platforms)") +add_subdirectory("${REMCPE_PLATFORM}") + +# Load Sound +add_subdirectory(sound) \ No newline at end of file diff --git a/platforms/android/AppPlatform_android.cpp b/platforms/android/AppPlatform_android.cpp index 117f68b13..0f6fd4a4e 100644 --- a/platforms/android/AppPlatform_android.cpp +++ b/platforms/android/AppPlatform_android.cpp @@ -9,7 +9,7 @@ #include #include "AppPlatform_android.hpp" -#include "SoundSystemSL.hpp" +#include "CustomSoundSystem.hpp" #include "client/player/input/Mouse.hpp" #include "stb_image.h" @@ -174,7 +174,7 @@ SoundSystem* const AppPlatform_android::getSoundSystem() const void AppPlatform_android::initSoundSystem() { if (!m_pSoundSystem) - m_pSoundSystem = new SoundSystemSL(); + m_pSoundSystem = new SOUND_SYSTEM(); else LOG_E("Trying to initialize SoundSystem more than once!"); } diff --git a/platforms/android/project/app/src/main/cpp/CMakeLists.txt b/platforms/android/CMakeLists.txt similarity index 63% rename from platforms/android/project/app/src/main/cpp/CMakeLists.txt rename to platforms/android/CMakeLists.txt index 6a03a611f..0f69cc8d6 100644 --- a/platforms/android/project/app/src/main/cpp/CMakeLists.txt +++ b/platforms/android/CMakeLists.txt @@ -1,31 +1,27 @@ cmake_minimum_required(VERSION 3.16.0) project(reminecraftpe-android) -# Project Root -set(MC_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../..") - # Native Android Build -add_compile_definitions(USE_NATIVE_ANDROID) -set(USE_NATIVE_ANDROID TRUE) +target_compile_definitions(reminecraftpe-core PUBLIC USE_NATIVE_ANDROID) # Build add_library(reminecraftpe SHARED - "${MC_ROOT}/platforms/android/android_native_app_glue.c" - "${MC_ROOT}/platforms/android/AppPlatform_android.cpp" - "${MC_ROOT}/platforms/android/SoundSystemSL.cpp" - "${MC_ROOT}/platforms/android/main.cpp" + android_native_app_glue.c + AppPlatform_android.cpp + main.cpp ) # Core -add_subdirectory("${MC_ROOT}/source" source) target_link_libraries(reminecraftpe reminecraftpe-core) +# OpenGL +target_link_libraries(reminecraftpe-core PUBLIC EGL GLESv1_CM) + # stb_image -add_subdirectory("${MC_ROOT}/thirdparty/stb_image" stb_image) target_link_libraries(reminecraftpe stb_image) # Extra Dependencies -target_link_libraries(reminecraftpe android OpenSLES) +target_link_libraries(reminecraftpe android) # Check for the presence of some optional asset based features. if(EXISTS "${MC_ROOT}/game/assets/gui/background/panorama_0.png") diff --git a/platforms/android/project/app/build.gradle b/platforms/android/project/app/build.gradle index 84b308c56..7743e2ab1 100644 --- a/platforms/android/project/app/build.gradle +++ b/platforms/android/project/app/build.gradle @@ -29,7 +29,7 @@ android { // testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" externalNativeBuild { cmake { - arguments '-DANDROID_PLATFORM=android-21', '-DANDROID_STL=c++_static' + arguments '-DANDROID_PLATFORM=android-21', '-DANDROID_STL=c++_static', '-DREMCPE_PLATFORM=android', '-DREMCPE_SOUND_PLATFORM=opensl' abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' } } @@ -47,7 +47,7 @@ android { } externalNativeBuild { cmake { - path file('src/main/cpp/CMakeLists.txt') + path '../../../../CMakeLists.txt' version '3.22.1' } } diff --git a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj index fd769b36a..c0dfd30a8 100644 --- a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj +++ b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj @@ -200,6 +200,8 @@ 8426107E2AE989730065905F /* RakNetInstance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD64E2AC810620006A435 /* RakNetInstance.cpp */; }; 8426107F2AE989730065905F /* ServerSideNetworkHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD6502AC810620006A435 /* ServerSideNetworkHandler.cpp */; }; 842610882AE98A4C0065905F /* libRakNet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84FFBD7E2ACA2876005A8CCF /* libRakNet.a */; }; + 8441F98F2DB4E911005977BD /* SoundSystemAL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8441F9862DB4E911005977BD /* SoundSystemAL.cpp */; }; + 8441F9962DB4E911005977BD /* SoundSystemAL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8441F9862DB4E911005977BD /* SoundSystemAL.cpp */; }; 8443B6EA2A98675F0086730C /* libSDL2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8443B6E92A98675F0086730C /* libSDL2.a */; }; 8445E7A02D769329008DC834 /* EntityCategories.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8445E7952D769329008DC834 /* EntityCategories.cpp */; }; 8445E7A12D769329008DC834 /* EntityCategories.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 8445E7962D769329008DC834 /* EntityCategories.hpp */; }; @@ -245,7 +247,6 @@ 84619B212AF1EDA300B0DE81 /* libWorld.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84BF630B2AF1859D008A9995 /* libWorld.a */; }; 84619B222AF1EDA300B0DE81 /* libZLib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84498A832AF18C7A005EF5A5 /* libZLib.a */; }; 84619B392AF1F73900B0DE81 /* GL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD6552AC810620006A435 /* GL.hpp */; }; - 84619B3A2AF1FE1500B0DE81 /* SoundSystemAL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EAE8E62AF1EAFA000894E8 /* SoundSystemAL.cpp */; }; 84619B3C2AF1FE4C00B0DE81 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84619B3B2AF1FE4C00B0DE81 /* OpenAL.framework */; }; 84619B3E2AF1FEB700B0DE81 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84619B3D2AF1FEB700B0DE81 /* QuartzCore.framework */; }; 8470AF2B2BE9B60A00BCA54E /* EntityType.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 8470AF282BE9B60900BCA54E /* EntityType.hpp */; }; @@ -895,7 +896,6 @@ 84EAE8DE2AF1EAA1000894E8 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84EAE8DD2AF1EAA1000894E8 /* UIKit.framework */; }; 84EAE8E02AF1EAA9000894E8 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84EAE8DF2AF1EAA9000894E8 /* CoreGraphics.framework */; }; 84EAE8E42AF1EABE000894E8 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84EAE8E32AF1EABE000894E8 /* OpenGLES.framework */; }; - 84EAE8F32AF1EAFA000894E8 /* SoundSystemAL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EAE8E62AF1EAFA000894E8 /* SoundSystemAL.cpp */; }; 84EAE8F72AF1EAFA000894E8 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EAE8F12AF1EAFA000894E8 /* main.cpp */; }; 84ED99D52AFF12D1003B6AF0 /* minecraftpe.entitlements in Resources */ = {isa = PBXBuildFile; fileRef = 84ED99D42AFF12D1003B6AF0 /* minecraftpe.entitlements */; }; 84FFBE952ACA3415005A8CCF /* _FindFirst.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD73A2AC810620006A435 /* _FindFirst.cpp */; }; @@ -1776,6 +1776,8 @@ 84336BA52B1EB57E00097DB0 /* Settings_iOS_Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Settings_iOS_Debug.xcconfig; path = ../Configuration/Settings_iOS_Debug.xcconfig; sourceTree = ""; }; 84336BA82B1EB88500097DB0 /* Settings_macOS.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Settings_macOS.xcconfig; path = ../Configuration/Settings_macOS.xcconfig; sourceTree = ""; }; 84336BA92B1EB9C200097DB0 /* Settings_macOS_Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Settings_macOS_Debug.xcconfig; path = ../Configuration/Settings_macOS_Debug.xcconfig; sourceTree = ""; }; + 8441F9852DB4E911005977BD /* CustomSoundSystem.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CustomSoundSystem.hpp; sourceTree = ""; }; + 8441F9862DB4E911005977BD /* SoundSystemAL.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SoundSystemAL.cpp; sourceTree = ""; }; 8443B6E92A98675F0086730C /* libSDL2.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libSDL2.a; path = /opt/local/lib/libSDL2.a; sourceTree = ""; }; 8445E7952D769329008DC834 /* EntityCategories.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EntityCategories.cpp; sourceTree = ""; }; 8445E7962D769329008DC834 /* EntityCategories.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = EntityCategories.hpp; sourceTree = ""; }; @@ -1945,7 +1947,6 @@ 84AA8B6D2B32F3B5003F5B82 /* PathfinderMob.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PathfinderMob.hpp; sourceTree = ""; }; 84AA8B6E2B32F3B5003F5B82 /* Pig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Pig.cpp; sourceTree = ""; }; 84AA8B6F2B32F3B5003F5B82 /* Pig.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Pig.hpp; sourceTree = ""; }; - 84AA8B702B32F3B5003F5B82 /* Player.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Player.cpp; sourceTree = ""; }; 84AA8B762B32F3B5003F5B82 /* WaterAnimal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WaterAnimal.cpp; sourceTree = ""; }; 84AA8B772B32F3B5003F5B82 /* WaterAnimal.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = WaterAnimal.hpp; sourceTree = ""; }; 84AA8B992B32F3F3003F5B82 /* Chunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Chunk.cpp; sourceTree = ""; }; @@ -2035,8 +2036,6 @@ 84AA8C3F2B32F535003F5B82 /* CowModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CowModel.hpp; sourceTree = ""; }; 84AA8C402B32F535003F5B82 /* CreeperModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CreeperModel.cpp; sourceTree = ""; }; 84AA8C412B32F535003F5B82 /* CreeperModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CreeperModel.hpp; sourceTree = ""; }; - 84AA8C442B32F535003F5B82 /* HumanoidModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HumanoidModel.cpp; sourceTree = ""; }; - 84AA8C462B32F535003F5B82 /* Model.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Model.cpp; sourceTree = ""; }; 84AA8C482B32F535003F5B82 /* ModelPart.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ModelPart.cpp; sourceTree = ""; }; 84AA8C492B32F535003F5B82 /* ModelPart.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ModelPart.hpp; sourceTree = ""; }; 84AA8C4A2B32F535003F5B82 /* PigModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PigModel.cpp; sourceTree = ""; }; @@ -2164,8 +2163,6 @@ 84EAE8DF2AF1EAA9000894E8 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 84EAE8E12AF1EAB5000894E8 /* GLKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GLKit.framework; path = System/Library/Frameworks/GLKit.framework; sourceTree = SDKROOT; }; 84EAE8E32AF1EABE000894E8 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; - 84EAE8E62AF1EAFA000894E8 /* SoundSystemAL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SoundSystemAL.cpp; sourceTree = ""; }; - 84EAE8E72AF1EAFA000894E8 /* SoundSystemAL.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SoundSystemAL.hpp; sourceTree = ""; }; 84EAE8F02AF1EAFA000894E8 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = ""; }; 84EAE8F12AF1EAFA000894E8 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; 84ED99D42AFF12D1003B6AF0 /* minecraftpe.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = minecraftpe.entitlements; sourceTree = ""; }; @@ -2420,10 +2417,8 @@ 840DD5BF2AC810620006A435 /* Cube.hpp */, 840DD5BE2AC810620006A435 /* Cube.cpp */, 840DD5C12AC810620006A435 /* HumanoidModel.hpp */, - 84AA8C442B32F535003F5B82 /* HumanoidModel.cpp */, 840DD5C02AC810620006A435 /* HumanoidModel.cpp */, 840DD5C32AC810620006A435 /* Model.hpp */, - 84AA8C462B32F535003F5B82 /* Model.cpp */, 840DD5C22AC810620006A435 /* Model.cpp */, 84AA8C492B32F535003F5B82 /* ModelPart.hpp */, 84AA8C482B32F535003F5B82 /* ModelPart.cpp */, @@ -2687,7 +2682,6 @@ 84AA8B6F2B32F3B5003F5B82 /* Pig.hpp */, 84AA8B6E2B32F3B5003F5B82 /* Pig.cpp */, 840DD6632AC810620006A435 /* Player.hpp */, - 84AA8B702B32F3B5003F5B82 /* Player.cpp */, 840DD6622AC810620006A435 /* Player.cpp */, 840DD6652AC810620006A435 /* PrimedTnt.hpp */, 840DD6642AC810620006A435 /* PrimedTnt.cpp */, @@ -2722,22 +2716,22 @@ 840DD66F2AC810620006A435 /* item */ = { isa = PBXGroup; children = ( - 840DD6702AC810620006A435 /* CameraItem.cpp */, 840DD6712AC810620006A435 /* CameraItem.hpp */, - 840DD6722AC810620006A435 /* DoorItem.cpp */, + 840DD6702AC810620006A435 /* CameraItem.cpp */, 840DD6732AC810620006A435 /* DoorItem.hpp */, - 840DD6742AC810620006A435 /* Inventory.cpp */, + 840DD6722AC810620006A435 /* DoorItem.cpp */, 840DD6752AC810620006A435 /* Inventory.hpp */, - 840DD6762AC810620006A435 /* Item.cpp */, + 840DD6742AC810620006A435 /* Inventory.cpp */, 840DD6772AC810620006A435 /* Item.hpp */, - 840DD6782AC810620006A435 /* ItemInstance.cpp */, + 840DD6762AC810620006A435 /* Item.cpp */, 840DD6792AC810620006A435 /* ItemInstance.hpp */, - 84E78C812B58B5FB00D515EF /* RocketItem.cpp */, + 840DD6782AC810620006A435 /* ItemInstance.cpp */, 84E78C822B58B5FB00D515EF /* RocketItem.hpp */, - 840DD67A2AC810620006A435 /* TileItem.cpp */, + 84E78C812B58B5FB00D515EF /* RocketItem.cpp */, 840DD67B2AC810620006A435 /* TileItem.hpp */, - 840DD67C2AC810620006A435 /* TilePlanterItem.cpp */, + 840DD67A2AC810620006A435 /* TileItem.cpp */, 840DD67D2AC810620006A435 /* TilePlanterItem.hpp */, + 840DD67C2AC810620006A435 /* TilePlanterItem.cpp */, ); path = item; sourceTree = ""; @@ -2883,14 +2877,14 @@ children = ( 840DD6CF2AC810620006A435 /* BubbleParticle.cpp */, 840DD6D02AC810620006A435 /* ExplodeParticle.cpp */, - 8470AF3A2BE9B6FA00BCA54E /* FireworkParticle.cpp */, 8470AF3B2BE9B6FA00BCA54E /* FireworkParticle.hpp */, + 8470AF3A2BE9B6FA00BCA54E /* FireworkParticle.cpp */, 840DD6D12AC810620006A435 /* FlameParticle.cpp */, 840DD6D22AC810620006A435 /* LavaParticle.cpp */, - 840DD6D32AC810620006A435 /* Particle.cpp */, 840DD6D42AC810620006A435 /* Particle.hpp */, - 840DD6D52AC810620006A435 /* ParticleEngine.cpp */, + 840DD6D32AC810620006A435 /* Particle.cpp */, 840DD6D62AC810620006A435 /* ParticleEngine.hpp */, + 840DD6D52AC810620006A435 /* ParticleEngine.cpp */, 840DD6D72AC810620006A435 /* RedDustParticle.cpp */, 840DD6D82AC810620006A435 /* SmokeParticle.cpp */, 840DD6D92AC810620006A435 /* TerrainParticle.cpp */, @@ -2916,84 +2910,84 @@ 840DD6E12AC810620006A435 /* tile */ = { isa = PBXGroup; children = ( - 840DD6E22AC810620006A435 /* BookshelfTile.cpp */, 840DD6E32AC810620006A435 /* BookshelfTile.hpp */, - 840DD6E42AC810620006A435 /* Bush.cpp */, + 840DD6E22AC810620006A435 /* BookshelfTile.cpp */, 840DD6E52AC810620006A435 /* Bush.hpp */, - 840DD6E62AC810620006A435 /* ClayTile.cpp */, + 840DD6E42AC810620006A435 /* Bush.cpp */, 840DD6E72AC810620006A435 /* ClayTile.hpp */, - 840DD6E82AC810620006A435 /* ClothTile.cpp */, + 840DD6E62AC810620006A435 /* ClayTile.cpp */, 840DD6E92AC810620006A435 /* ClothTile.hpp */, - 840DD6EA2AC810620006A435 /* DirtTile.cpp */, + 840DD6E82AC810620006A435 /* ClothTile.cpp */, 840DD6EB2AC810620006A435 /* DirtTile.hpp */, - 840DD6EC2AC810620006A435 /* DoorTile.cpp */, + 840DD6EA2AC810620006A435 /* DirtTile.cpp */, 840DD6ED2AC810620006A435 /* DoorTile.hpp */, - 840DD6EE2AC810620006A435 /* FarmTile.cpp */, + 840DD6EC2AC810620006A435 /* DoorTile.cpp */, 840DD6EF2AC810620006A435 /* FarmTile.hpp */, - 840DD6F02AC810620006A435 /* FireTile.cpp */, + 840DD6EE2AC810620006A435 /* FarmTile.cpp */, 840DD6F12AC810620006A435 /* FireTile.hpp */, - 840DD6F22AC810620006A435 /* GlassTile.cpp */, + 840DD6F02AC810620006A435 /* FireTile.cpp */, 840DD6F32AC810620006A435 /* GlassTile.hpp */, - 840DD6F42AC810620006A435 /* GrassTile.cpp */, + 840DD6F22AC810620006A435 /* GlassTile.cpp */, 840DD6F52AC810620006A435 /* GrassTile.hpp */, - 840DD6F62AC810620006A435 /* GravelTile.cpp */, + 840DD6F42AC810620006A435 /* GrassTile.cpp */, 840DD6F72AC810620006A435 /* GravelTile.hpp */, - 840DD6F82AC810620006A435 /* HalfTransparentTile.cpp */, + 840DD6F62AC810620006A435 /* GravelTile.cpp */, 840DD6F92AC810620006A435 /* HalfTransparentTile.hpp */, - 840DD6FA2AC810620006A435 /* IceTile.cpp */, + 840DD6F82AC810620006A435 /* HalfTransparentTile.cpp */, 840DD6FB2AC810620006A435 /* IceTile.hpp */, - 840DD6FC2AC810620006A435 /* InvisibleTile.cpp */, + 840DD6FA2AC810620006A435 /* IceTile.cpp */, 840DD6FD2AC810620006A435 /* InvisibleTile.hpp */, - 840DD6FE2AC810620006A435 /* LadderTile.cpp */, + 840DD6FC2AC810620006A435 /* InvisibleTile.cpp */, 840DD6FF2AC810620006A435 /* LadderTile.hpp */, - 840DD7002AC810620006A435 /* LeafTile.cpp */, + 840DD6FE2AC810620006A435 /* LadderTile.cpp */, 840DD7012AC810620006A435 /* LeafTile.hpp */, - 840DD7022AC810620006A435 /* LiquidTile.cpp */, + 840DD7002AC810620006A435 /* LeafTile.cpp */, 840DD7032AC810620006A435 /* LiquidTile.hpp */, - 840DD7042AC810620006A435 /* LiquidTileDynamic.cpp */, + 840DD7022AC810620006A435 /* LiquidTile.cpp */, 840DD7052AC810620006A435 /* LiquidTileDynamic.hpp */, - 840DD7062AC810620006A435 /* LiquidTileStatic.cpp */, + 840DD7042AC810620006A435 /* LiquidTileDynamic.cpp */, 840DD7072AC810620006A435 /* LiquidTileStatic.hpp */, - 840DD7082AC810620006A435 /* MetalTile.cpp */, + 840DD7062AC810620006A435 /* LiquidTileStatic.cpp */, 840DD7092AC810620006A435 /* MetalTile.hpp */, - 840DD70A2AC810620006A435 /* ObsidianTile.cpp */, + 840DD7082AC810620006A435 /* MetalTile.cpp */, 840DD70B2AC810620006A435 /* ObsidianTile.hpp */, - 840DD70C2AC810620006A435 /* OreTile.cpp */, + 840DD70A2AC810620006A435 /* ObsidianTile.cpp */, 840DD70D2AC810620006A435 /* OreTile.hpp */, - 840DD70E2AC810620006A435 /* RedStoneOreTile.cpp */, + 840DD70C2AC810620006A435 /* OreTile.cpp */, 840DD70F2AC810620006A435 /* RedStoneOreTile.hpp */, - 840DD7102AC810620006A435 /* ReedTile.cpp */, + 840DD70E2AC810620006A435 /* RedStoneOreTile.cpp */, 840DD7112AC810620006A435 /* ReedTile.hpp */, - 84E78C852B58B66B00D515EF /* RocketLauncherTile.cpp */, + 840DD7102AC810620006A435 /* ReedTile.cpp */, 84E78C862B58B66B00D515EF /* RocketLauncherTile.hpp */, - 840DD7122AC810620006A435 /* SandStoneTile.cpp */, + 84E78C852B58B66B00D515EF /* RocketLauncherTile.cpp */, 840DD7132AC810620006A435 /* SandStoneTile.hpp */, - 840DD7142AC810620006A435 /* SandTile.cpp */, + 840DD7122AC810620006A435 /* SandStoneTile.cpp */, 840DD7152AC810620006A435 /* SandTile.hpp */, - 840DD7162AC810620006A435 /* Sapling.cpp */, + 840DD7142AC810620006A435 /* SandTile.cpp */, 840DD7172AC810620006A435 /* Sapling.hpp */, - 840DD7182AC810620006A435 /* SpongeTile.cpp */, + 840DD7162AC810620006A435 /* Sapling.cpp */, 840DD7192AC810620006A435 /* SpongeTile.hpp */, - 840DD71A2AC810620006A435 /* StairTile.cpp */, + 840DD7182AC810620006A435 /* SpongeTile.cpp */, 840DD71B2AC810620006A435 /* StairTile.hpp */, - 840DD71C2AC810620006A435 /* StoneSlabTile.cpp */, + 840DD71A2AC810620006A435 /* StairTile.cpp */, 840DD71D2AC810620006A435 /* StoneSlabTile.hpp */, - 840DD71E2AC810620006A435 /* StoneTile.cpp */, + 840DD71C2AC810620006A435 /* StoneSlabTile.cpp */, 840DD71F2AC810620006A435 /* StoneTile.hpp */, - 840DD7202AC810620006A435 /* Tile.cpp */, + 840DD71E2AC810620006A435 /* StoneTile.cpp */, 840DD7212AC810620006A435 /* Tile.hpp */, - 840DD7222AC810620006A435 /* TntTile.cpp */, + 840DD7202AC810620006A435 /* Tile.cpp */, 840DD7232AC810620006A435 /* TntTile.hpp */, - 840DD7242AC810620006A435 /* TopSnowTile.cpp */, + 840DD7222AC810620006A435 /* TntTile.cpp */, 840DD7252AC810620006A435 /* TopSnowTile.hpp */, - 840DD7262AC810620006A435 /* TorchTile.cpp */, + 840DD7242AC810620006A435 /* TopSnowTile.cpp */, 840DD7272AC810620006A435 /* TorchTile.hpp */, - 840DD7282AC810620006A435 /* TransparentTile.cpp */, + 840DD7262AC810620006A435 /* TorchTile.cpp */, 840DD7292AC810620006A435 /* TransparentTile.hpp */, - 840DD72A2AC810620006A435 /* TreeTile.cpp */, + 840DD7282AC810620006A435 /* TransparentTile.cpp */, 840DD72B2AC810620006A435 /* TreeTile.hpp */, - 840DD72C2AC810620006A435 /* WireTile.cpp */, + 840DD72A2AC810620006A435 /* TreeTile.cpp */, 840DD72D2AC810620006A435 /* WireTile.hpp */, + 840DD72C2AC810620006A435 /* WireTile.cpp */, ); path = tile; sourceTree = ""; @@ -3342,8 +3336,8 @@ isa = PBXGroup; children = ( 84790AEC2AD7DA410076F2A1 /* ios */, - 84EAE8E52AF1EAFA000894E8 /* openal */, 84EAE8E82AF1EAFA000894E8 /* sdl */, + 8441F98D2DB4E911005977BD /* sound */, ); name = platforms; path = ../../..; @@ -3385,6 +3379,23 @@ name = macOS; sourceTree = ""; }; + 8441F9872DB4E911005977BD /* openal */ = { + isa = PBXGroup; + children = ( + 8441F9852DB4E911005977BD /* CustomSoundSystem.hpp */, + 8441F9862DB4E911005977BD /* SoundSystemAL.cpp */, + ); + path = openal; + sourceTree = ""; + }; + 8441F98D2DB4E911005977BD /* sound */ = { + isa = PBXGroup; + children = ( + 8441F9872DB4E911005977BD /* openal */, + ); + path = sound; + sourceTree = ""; + }; 8470AF422BE9B8B600BCA54E /* environment */ = { isa = PBXGroup; children = ( @@ -3707,44 +3718,44 @@ 84AA8B9F2B32F3F3003F5B82 /* entity */ = { isa = PBXGroup; children = ( - 84AA8BA02B32F3F3003F5B82 /* ChickenRenderer.cpp */, 84AA8BA12B32F3F3003F5B82 /* ChickenRenderer.hpp */, - 84AA8BA22B32F3F3003F5B82 /* CowRenderer.cpp */, + 84AA8BA02B32F3F3003F5B82 /* ChickenRenderer.cpp */, 84AA8BA32B32F3F3003F5B82 /* CowRenderer.hpp */, - 84AA8BA42B32F3F3003F5B82 /* CreeperRenderer.cpp */, + 84AA8BA22B32F3F3003F5B82 /* CowRenderer.cpp */, 84AA8BA52B32F3F3003F5B82 /* CreeperRenderer.hpp */, - 84AA8BA62B32F3F3003F5B82 /* EntityRenderDispatcher.cpp */, + 84AA8BA42B32F3F3003F5B82 /* CreeperRenderer.cpp */, 84AA8BA72B32F3F3003F5B82 /* EntityRenderDispatcher.hpp */, - 84AA8BA82B32F3F3003F5B82 /* EntityRenderer.cpp */, + 84AA8BA62B32F3F3003F5B82 /* EntityRenderDispatcher.cpp */, 84AA8BA92B32F3F3003F5B82 /* EntityRenderer.hpp */, - 84AA8BAA2B32F3F3003F5B82 /* FallingTileRenderer.cpp */, + 84AA8BA82B32F3F3003F5B82 /* EntityRenderer.cpp */, 84AA8BAB2B32F3F3003F5B82 /* FallingTileRenderer.hpp */, - 84AA8BAC2B32F3F3003F5B82 /* HumanoidMobRenderer.cpp */, + 84AA8BAA2B32F3F3003F5B82 /* FallingTileRenderer.cpp */, 84AA8BAD2B32F3F3003F5B82 /* HumanoidMobRenderer.hpp */, - 84AA8BAE2B32F3F3003F5B82 /* ItemRenderer.cpp */, + 84AA8BAC2B32F3F3003F5B82 /* HumanoidMobRenderer.cpp */, 84AA8BAF2B32F3F3003F5B82 /* ItemRenderer.hpp */, - 84AA8BB02B32F3F3003F5B82 /* ItemSpriteRenderer.cpp */, + 84AA8BAE2B32F3F3003F5B82 /* ItemRenderer.cpp */, 84AA8BB12B32F3F3003F5B82 /* ItemSpriteRenderer.hpp */, - 84AA8BB22B32F3F3003F5B82 /* MobRenderer.cpp */, + 84AA8BB02B32F3F3003F5B82 /* ItemSpriteRenderer.cpp */, 84AA8BB32B32F3F3003F5B82 /* MobRenderer.hpp */, - 84AA8BB42B32F3F3003F5B82 /* PigRenderer.cpp */, + 84AA8BB22B32F3F3003F5B82 /* MobRenderer.cpp */, 84AA8BB52B32F3F3003F5B82 /* PigRenderer.hpp */, - 84E78C7D2B58B5CC00D515EF /* RocketRenderer.cpp */, + 84AA8BB42B32F3F3003F5B82 /* PigRenderer.cpp */, 84E78C7E2B58B5CC00D515EF /* RocketRenderer.hpp */, - 84AA8BB62B32F3F3003F5B82 /* SheepFurRenderer.cpp */, + 84E78C7D2B58B5CC00D515EF /* RocketRenderer.cpp */, 84AA8BB72B32F3F3003F5B82 /* SheepFurRenderer.hpp */, - 84AA8BB82B32F3F3003F5B82 /* SheepRenderer.cpp */, + 84AA8BB62B32F3F3003F5B82 /* SheepFurRenderer.cpp */, 84AA8BB92B32F3F3003F5B82 /* SheepRenderer.hpp */, - 84AA8BBA2B32F3F3003F5B82 /* SkeletonRenderer.cpp */, + 84AA8BB82B32F3F3003F5B82 /* SheepRenderer.cpp */, 84AA8BBB2B32F3F3003F5B82 /* SkeletonRenderer.hpp */, - 84AA8BBC2B32F3F3003F5B82 /* SpiderRenderer.cpp */, + 84AA8BBA2B32F3F3003F5B82 /* SkeletonRenderer.cpp */, 84AA8BBD2B32F3F3003F5B82 /* SpiderRenderer.hpp */, - 84AA8BBE2B32F3F3003F5B82 /* TntRenderer.cpp */, + 84AA8BBC2B32F3F3003F5B82 /* SpiderRenderer.cpp */, 84AA8BBF2B32F3F3003F5B82 /* TntRenderer.hpp */, - 84AA8BC02B32F3F3003F5B82 /* TripodCameraRenderer.cpp */, + 84AA8BBE2B32F3F3003F5B82 /* TntRenderer.cpp */, 84AA8BC12B32F3F3003F5B82 /* TripodCameraRenderer.hpp */, - 84AA8BC22B32F3F3003F5B82 /* ZombieRenderer.cpp */, + 84AA8BC02B32F3F3003F5B82 /* TripodCameraRenderer.cpp */, 84AA8BC32B32F3F3003F5B82 /* ZombieRenderer.hpp */, + 84AA8BC22B32F3F3003F5B82 /* ZombieRenderer.cpp */, ); path = entity; sourceTree = ""; @@ -3903,15 +3914,6 @@ path = mob; sourceTree = ""; }; - 84EAE8E52AF1EAFA000894E8 /* openal */ = { - isa = PBXGroup; - children = ( - 84EAE8E62AF1EAFA000894E8 /* SoundSystemAL.cpp */, - 84EAE8E72AF1EAFA000894E8 /* SoundSystemAL.hpp */, - ); - path = openal; - sourceTree = ""; - }; 84EAE8E82AF1EAFA000894E8 /* sdl */ = { isa = PBXGroup; children = ( @@ -4854,12 +4856,12 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 84EAE8F32AF1EAFA000894E8 /* SoundSystemAL.cpp in Sources */, 84EAE8F72AF1EAFA000894E8 /* main.cpp in Sources */, 841DD8772AF8AA7A00AA3B66 /* AppPlatform_sdl_base.cpp in Sources */, 841DD8782AF8AA7A00AA3B66 /* AppPlatform_sdl.cpp in Sources */, 84AA8E4D2B32FB33003F5B82 /* stb_vorbis.c in Sources */, 84AA8E802B32FB33003F5B82 /* stb_image_impl.c in Sources */, + 8441F9962DB4E911005977BD /* SoundSystemAL.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4867,12 +4869,12 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 84619B3A2AF1FE1500B0DE81 /* SoundSystemAL.cpp in Sources */, 849259592AD8FD4F0081F5B9 /* minecraftpeAppDelegate.mm in Sources */, 8492595A2AD8FD4F0081F5B9 /* minecraftpeViewController.mm in Sources */, 8492595B2AD8FD4F0081F5B9 /* Shader.fsh in Sources */, 8492595C2AD8FD4F0081F5B9 /* Shader.vsh in Sources */, 849259622AD8FDD10081F5B9 /* main.m in Sources */, + 8441F98F2DB4E911005977BD /* SoundSystemAL.cpp in Sources */, 84CEF0032AE3C97D006C5829 /* EAGLView.m in Sources */, 8495E4892AF0905B00A06901 /* AppPlatform_iOS.mm in Sources */, 8488C08A2B1EDD4F001AEC4F /* ShowKeyboardView.mm in Sources */, diff --git a/platforms/openal/CMakeLists.txt b/platforms/openal/CMakeLists.txt deleted file mode 100644 index 36450e0fe..000000000 --- a/platforms/openal/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -cmake_minimum_required(VERSION 3.16.0) -project(reminecraftpe-openal) - -# Build -add_library(reminecraftpe-openal STATIC - SoundSystemAL.cpp -) - -# Core -target_link_libraries(reminecraftpe-openal PUBLIC reminecraftpe-core) - -# OpenAL -if(ANDROID) - # Use Vendored OpenAL - set(ALSOFT_UTILS FALSE CACHE BOOL "" FORCE) - set(ALSOFT_EXAMPLES FALSE CACHE BOOL "" FORCE) - set(ALSOFT_TESTS FALSE CACHE BOOL "" FORCE) - set(ALSOFT_REQUIRE_OPENSL TRUE CACHE BOOL "" FORCE) - add_subdirectory(../../thirdparty/OpenAL openal EXCLUDE_FROM_ALL) - target_link_libraries(reminecraftpe-openal PUBLIC OpenAL::OpenAL) -elseif(EMSCRIPTEN) - # Use Emscripten's OpenAL - target_link_libraries(reminecraftpe-openal PUBLIC openal) -else() - # Use System ZLib - find_library(OPENAL_LIBRARY NAMES openal REQUIRED) - target_link_libraries(reminecraftpe-openal PUBLIC "${OPENAL_LIBRARY}") -endif() - -# Headers -target_include_directories(reminecraftpe-openal PUBLIC .) diff --git a/platforms/sdl/CMakeLists.txt b/platforms/sdl/CMakeLists.txt index b5cff20c9..1d2e84112 100644 --- a/platforms/sdl/CMakeLists.txt +++ b/platforms/sdl/CMakeLists.txt @@ -2,36 +2,10 @@ cmake_minimum_required(VERSION 3.16.0) project(reminecraftpe-sdl) # SDL Build -add_compile_definitions(USE_SDL USE_OPENAL HANDLE_CHARS_SEPARATELY) -set(USE_SDL TRUE) - -# WASM -if(EMSCRIPTEN) - function(add_compile_and_link_options) - add_compile_options(${ARGV}) - add_link_options(${ARGV}) - endfunction() - set(CMAKE_EXECUTABLE_SUFFIX ".js") - add_link_options("$<$:-gsource-map>") -endif() - -# Clang -if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - add_compile_options(-Wno-inconsistent-missing-override -Wno-enum-compare-switch -Wno-register) -endif() - -# Network library -if(HAIKU) - link_libraries(network) -endif() - -# Threads -if(EMSCRIPTEN) - add_compile_and_link_options(-pthread) -else() - find_package(Threads) - link_libraries(Threads::Threads) -endif() +target_compile_definitions(reminecraftpe-core + PUBLIC USE_SDL + PUBLIC HANDLE_CHARS_SEPARATELY +) # Build set(SOURCES @@ -51,35 +25,53 @@ else() endif() # Core -add_subdirectory(../../source source) target_link_libraries(reminecraftpe reminecraftpe-core) -# OpenAL -add_subdirectory(../openal openal) -target_link_libraries(reminecraftpe reminecraftpe-openal) - # stb_image (If Needed) if(NOT EMSCRIPTEN) - add_subdirectory(../../thirdparty/stb_image stb_image) target_link_libraries(reminecraftpe stb_image) endif() # SDL +add_library(SDL INTERFACE) +if(ANDROID OR WIN32) + # Use Vendored SDL2 (Only For Android) + add_subdirectory(../../thirdparty/SDL2/src SDL EXCLUDE_FROM_ALL) + target_link_libraries(SDL INTERFACE SDL2::SDL2) +elseif(EMSCRIPTEN) + # Use Emscripten's SDL2 + set(SDL_FLAG -sUSE_SDL=2) + target_compile_options(SDL INTERFACE "${SDL_FLAG}") + target_link_options(SDL INTERFACE "${SDL_FLAG}") +else() + # Use System SDL2 + find_package(SDL2 REQUIRED) + target_link_libraries(SDL INTERFACE SDL2::SDL2) +endif() +target_link_libraries(reminecraftpe-core PUBLIC SDL) if(TARGET SDL2::SDL2main) target_link_libraries(reminecraftpe SDL2::SDL2main) endif() +# OpenGL +if(ANDROID) + find_library(GLES_LIB GLESv1_CM REQUIRED) + target_link_libraries(reminecraftpe-core PUBLIC "${GLES_LIB}") + target_compile_definitions(reminecraftpe-core PUBLIC USE_GLES) +else() + find_package(OpenGL REQUIRED) + target_link_libraries(reminecraftpe-core PUBLIC OpenGL::GL) + if(EMSCRIPTEN) + # Use WebGL 2 + target_link_options(reminecraftpe-core PUBLIC + -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 + -sLEGACY_GL_EMULATION -sGL_FFP_ONLY + ) + endif() +endif() + # WASM if(EMSCRIPTEN) - target_link_options(reminecraftpe PRIVATE -Wno-pthreads-mem-growth) - target_link_options(reminecraftpe PRIVATE -sALLOW_MEMORY_GROWTH=1) # Export Resize Function target_link_options(reminecraftpe PRIVATE -sEXPORTED_FUNCTIONS=_main,_resize_from_js -sEXPORTED_RUNTIME_METHODS=ccall) endif() - -# Assets -if(EMSCRIPTEN) - target_link_options(reminecraftpe PRIVATE --use-preload-plugins --preload-file "${CMAKE_CURRENT_SOURCE_DIR}/../../game@/") -elseif(NOT ANDROID) - file(CREATE_LINK "${CMAKE_CURRENT_SOURCE_DIR}/../../game/assets" "${CMAKE_CURRENT_BINARY_DIR}/assets" SYMBOLIC) -endif() diff --git a/platforms/sdl/android/app/build.gradle b/platforms/sdl/android/app/build.gradle index dddb581b7..f08bc84ae 100644 --- a/platforms/sdl/android/app/build.gradle +++ b/platforms/sdl/android/app/build.gradle @@ -33,7 +33,7 @@ android { } externalNativeBuild { cmake { - path '../../CMakeLists.txt' + path '../../../../CMakeLists.txt' version '3.22.1' } } diff --git a/platforms/sdl/android/app/src/main/AndroidManifest.xml b/platforms/sdl/android/app/src/main/AndroidManifest.xml index 99abe3faf..f580f1b9e 100644 --- a/platforms/sdl/android/app/src/main/AndroidManifest.xml +++ b/platforms/sdl/android/app/src/main/AndroidManifest.xml @@ -5,8 +5,8 @@ android:versionName="1.0" android:installLocation="auto"> - - + + /platforms/sound)") +add_subdirectory("${REMCPE_SOUND_PLATFORM}") +target_link_libraries(reminecraftpe reminecraftpe-sound) \ No newline at end of file diff --git a/platforms/sound/directsound/CMakeLists.txt b/platforms/sound/directsound/CMakeLists.txt new file mode 100644 index 000000000..24daf6bbf --- /dev/null +++ b/platforms/sound/directsound/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.16.0) +project(reminecraftpe-directsound) + +# Build +add_library(reminecraftpe-sound STATIC + SoundSystemDS.cpp +) + +# Libraries +target_link_libraries(reminecraftpe-sound + reminecraftpe-core + dsound + dxguid +) + +# Headers +target_include_directories(reminecraftpe-sound PUBLIC .) diff --git a/platforms/windows/SoundSystemDS.hpp b/platforms/sound/directsound/CustomSoundSystem.hpp similarity index 95% rename from platforms/windows/SoundSystemDS.hpp rename to platforms/sound/directsound/CustomSoundSystem.hpp index 7543c4a55..de50e210c 100644 --- a/platforms/windows/SoundSystemDS.hpp +++ b/platforms/sound/directsound/CustomSoundSystem.hpp @@ -8,7 +8,7 @@ #pragma once #include -#include +#include #include #include #include @@ -49,4 +49,6 @@ class SoundSystemDS : public SoundSystem IDirectSound* m_directsound; LPDIRECTSOUND3DLISTENER m_listener; std::vector m_buffers; -}; \ No newline at end of file +}; + +#define SOUND_SYSTEM SoundSystemDS diff --git a/platforms/windows/SoundSystemDS.cpp b/platforms/sound/directsound/SoundSystemDS.cpp similarity index 99% rename from platforms/windows/SoundSystemDS.cpp rename to platforms/sound/directsound/SoundSystemDS.cpp index 34ca8efd3..a13a04241 100644 --- a/platforms/windows/SoundSystemDS.cpp +++ b/platforms/sound/directsound/SoundSystemDS.cpp @@ -7,7 +7,7 @@ ********************************************************************/ #define WIN32_LEAN_AND_MEAN -#include "SoundSystemDS.hpp" +#include "CustomSoundSystem.hpp" #include "common/Utils.hpp" // @TODO: fix crash in playAt when Asan is active diff --git a/platforms/sound/openal/CMakeLists.txt b/platforms/sound/openal/CMakeLists.txt new file mode 100644 index 000000000..101c05f28 --- /dev/null +++ b/platforms/sound/openal/CMakeLists.txt @@ -0,0 +1,32 @@ +cmake_minimum_required(VERSION 3.16.0) +project(reminecraftpe-openal) + +# Build +add_library(reminecraftpe-sound STATIC + SoundSystemAL.cpp +) + +# Core +target_link_libraries(reminecraftpe-sound PUBLIC reminecraftpe-core) + +# OpenAL +if(ANDROID) + # Use Vendored OpenAL + set(ALSOFT_UTILS FALSE CACHE BOOL "" FORCE) + set(ALSOFT_EXAMPLES FALSE CACHE BOOL "" FORCE) + set(ALSOFT_TESTS FALSE CACHE BOOL "" FORCE) + set(ALSOFT_REQUIRE_OPENSL TRUE CACHE BOOL "" FORCE) + add_subdirectory(../../../thirdparty/OpenAL openal EXCLUDE_FROM_ALL) + target_link_libraries(reminecraftpe-sound PUBLIC OpenAL::OpenAL) +elseif(EMSCRIPTEN) + # Use Emscripten's OpenAL + target_link_libraries(reminecraftpe-sound PUBLIC openal) +else() + # Use System OpenAL + find_package(OpenAL REQUIRED) + target_link_libraries(reminecraftpe-sound PUBLIC "${OPENAL_LIBRARY}") + target_include_directories(reminecraftpe-sound PUBLIC "${OPENAL_INCLUDE_DIR}") +endif() + +# Headers +target_include_directories(reminecraftpe-sound PUBLIC .) diff --git a/platforms/openal/SoundSystemAL.hpp b/platforms/sound/openal/CustomSoundSystem.hpp similarity index 87% rename from platforms/openal/SoundSystemAL.hpp rename to platforms/sound/openal/CustomSoundSystem.hpp index bc04737bf..639566914 100644 --- a/platforms/openal/SoundSystemAL.hpp +++ b/platforms/sound/openal/CustomSoundSystem.hpp @@ -1,20 +1,19 @@ #pragma once -#ifdef USE_OPENAL - -#ifdef _WIN32 -#include -#include -#pragma comment( lib, "OpenAl32.lib" ) -#elif defined(__APPLE__) +#ifdef __APPLE__ #include #include -#else +#elif defined(__EMSCRIPTEN__) #include #include +#else +#include "al.h" +#include "alc.h" +#ifdef _WIN32 +#pragma comment( lib, "OpenAL32.lib" ) +#endif #endif -#include #include #include @@ -24,6 +23,8 @@ #define MAX_IDLE_SOURCES 50 #define MAX_DISTANCE 16.0f +#define SOUND_SYSTEM SoundSystemAL + class SoundSystemAL : public SoundSystem { public: @@ -54,5 +55,3 @@ class SoundSystemAL : public SoundSystem Vec3 _lastListenerPos; float _listenerVolume; }; - -#endif diff --git a/platforms/openal/SoundSystemAL.cpp b/platforms/sound/openal/SoundSystemAL.cpp similarity index 99% rename from platforms/openal/SoundSystemAL.cpp rename to platforms/sound/openal/SoundSystemAL.cpp index 2130532c6..21c48688f 100644 --- a/platforms/openal/SoundSystemAL.cpp +++ b/platforms/sound/openal/SoundSystemAL.cpp @@ -1,5 +1,4 @@ -#ifdef USE_OPENAL -#include "SoundSystemAL.hpp" +#include "CustomSoundSystem.hpp" #include "common/Utils.hpp" @@ -344,5 +343,3 @@ void SoundSystemAL::stopEngine() // Mark as unloaded _initialized = false; } - -#endif diff --git a/platforms/sound/opensl/CMakeLists.txt b/platforms/sound/opensl/CMakeLists.txt new file mode 100644 index 000000000..89eeabc98 --- /dev/null +++ b/platforms/sound/opensl/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.16.0) +project(reminecraftpe-opensl) + +# Build +add_library(reminecraftpe-sound STATIC + SoundSystemSL.cpp +) + +# Core +target_link_libraries(reminecraftpe-sound PUBLIC reminecraftpe-core) + +# OpenSL +target_link_libraries(reminecraftpe-sound PUBLIC OpenSLES) + +# Headers +target_include_directories(reminecraftpe-sound PUBLIC .) diff --git a/platforms/android/SoundSystemSL.hpp b/platforms/sound/opensl/CustomSoundSystem.hpp similarity index 97% rename from platforms/android/SoundSystemSL.hpp rename to platforms/sound/opensl/CustomSoundSystem.hpp index 121625bc1..f9e37e3da 100644 --- a/platforms/android/SoundSystemSL.hpp +++ b/platforms/sound/opensl/CustomSoundSystem.hpp @@ -30,6 +30,8 @@ typedef std::list SLSoundList; +#define SOUND_SYSTEM SoundSystemSL + class SoundSystemSL : public SoundSystem { public: @@ -62,4 +64,4 @@ class SoundSystemSL : public SoundSystem static std::vector toRemove; static SLObjectItf objEngine; static pthread_mutex_t toRemoveMutex; -}; \ No newline at end of file +}; diff --git a/platforms/android/SoundSystemSL.cpp b/platforms/sound/opensl/SoundSystemSL.cpp similarity index 99% rename from platforms/android/SoundSystemSL.cpp rename to platforms/sound/opensl/SoundSystemSL.cpp index 65649cd94..fcfca14da 100644 --- a/platforms/android/SoundSystemSL.cpp +++ b/platforms/sound/opensl/SoundSystemSL.cpp @@ -5,7 +5,7 @@ The following code is licensed under the BSD 1 clause license. SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ -#include "SoundSystemSL.hpp" +#include "CustomSoundSystem.hpp" #include "common/Utils.hpp" #define C_MAX_SOUNDS 4 diff --git a/platforms/windows/AppPlatform_win32.cpp b/platforms/windows/AppPlatform_win32.cpp index e5daf9d67..bde51080a 100644 --- a/platforms/windows/AppPlatform_win32.cpp +++ b/platforms/windows/AppPlatform_win32.cpp @@ -14,7 +14,6 @@ #include "GameMods.hpp" #include "AppPlatform_win32.hpp" -#include "LoggerWin32.hpp" #include "thirdparty/GL/GL.hpp" @@ -37,24 +36,18 @@ AppPlatform_win32::AppPlatform_win32() m_MouseDiffX = 0, m_MouseDiffY = 0; - // This initializes the Logger singleton to use the Windows-specific variant - // If we didn't initialize it here, the Minecraft class would have our back - m_pLogger = new LoggerWin32(); m_pSoundSystem = nullptr; } AppPlatform_win32::~AppPlatform_win32() { SAFE_DELETE(m_pSoundSystem); - - // DELETE THIS LAST - SAFE_DELETE(m_pLogger); } void AppPlatform_win32::initSoundSystem() { if (!m_pSoundSystem) - m_pSoundSystem = new SoundSystemDS(); + m_pSoundSystem = new SOUND_SYSTEM(); else LOG_E("Trying to initialize SoundSystem more than once!"); } diff --git a/platforms/windows/AppPlatform_win32.hpp b/platforms/windows/AppPlatform_win32.hpp index 772e4cfc2..76323b8b9 100644 --- a/platforms/windows/AppPlatform_win32.hpp +++ b/platforms/windows/AppPlatform_win32.hpp @@ -15,7 +15,7 @@ #include "client/player/input/Keyboard.hpp" #include "common/Utils.hpp" #include "LoggerWin32.hpp" -#include "SoundSystemDS.hpp" +#include "CustomSoundSystem.hpp" class AppPlatform_win32 : public AppPlatform { @@ -83,7 +83,6 @@ class AppPlatform_win32 : public AppPlatform int m_MouseDiffX, m_MouseDiffY; - LoggerWin32 *m_pLogger; - SoundSystemDS* m_pSoundSystem; + SOUND_SYSTEM* m_pSoundSystem; }; diff --git a/platforms/windows/CMakeLists.txt b/platforms/windows/CMakeLists.txt new file mode 100644 index 000000000..782c0a2a8 --- /dev/null +++ b/platforms/windows/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.16.0) +project(reminecraftpe-windows) + +# Win32 Build +target_compile_definitions(reminecraftpe-core + PUBLIC HANDLE_CHARS_SEPARATELY +) + +# Libraries +target_link_libraries(reminecraftpe-core + PUBLIC opengl32 + PUBLIC glu32 + PUBLIC gdi32 + PUBLIC uuid +) + +# Build +add_executable(reminecraftpe WIN32 + LoggerWin32.cpp + AppPlatform_win32.cpp + main.cpp +) + +# Core +target_link_libraries(reminecraftpe reminecraftpe-core) + +# stb_image (If Needed) +target_link_libraries(reminecraftpe stb_image) \ No newline at end of file diff --git a/platforms/windows/LoggerWin32.hpp b/platforms/windows/LoggerWin32.hpp index 22bd0da1d..ac7f4a55b 100644 --- a/platforms/windows/LoggerWin32.hpp +++ b/platforms/windows/LoggerWin32.hpp @@ -3,7 +3,7 @@ #include #include "common/Logger.hpp" -class LoggerWin32 : Logger +class LoggerWin32 : public Logger { void print(eLogLevel, const char* const str) override; void print(eLogLevel, std::string str) override; diff --git a/platforms/windows/main.cpp b/platforms/windows/main.cpp index 9dd531c98..dc1b5b009 100644 --- a/platforms/windows/main.cpp +++ b/platforms/windows/main.cpp @@ -7,7 +7,7 @@ ********************************************************************/ #include -#include +#include #include "thirdparty/GL/GL.hpp" #include "compat/KeyCodes.hpp" @@ -19,6 +19,7 @@ #include "AppPlatform_win32.hpp" #include "resource.h" +#include "LoggerWin32.hpp" LPCTSTR g_WindowClassName = TEXT("MCPEClass"); @@ -128,6 +129,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine SetInstance(hInstance); + // This initializes the Logger singleton to use the Windows-specific variant + // If we didn't initialize it here, the Minecraft class would have our back + Logger::setSingleton(new LoggerWin32); + // register the window class: WNDCLASS wc; wc.style = CS_OWNDC; diff --git a/platforms/windows/projects/MinecraftClient.Win32/MinecraftClient.Win32.vcxproj b/platforms/windows/projects/MinecraftClient.Win32/MinecraftClient.Win32.vcxproj index 3e71dab03..dab9c33b3 100644 --- a/platforms/windows/projects/MinecraftClient.Win32/MinecraftClient.Win32.vcxproj +++ b/platforms/windows/projects/MinecraftClient.Win32/MinecraftClient.Win32.vcxproj @@ -56,15 +56,15 @@ - + - + diff --git a/platforms/windows/projects/MinecraftClient.Win32/MinecraftClient.Win32.vcxproj.filters b/platforms/windows/projects/MinecraftClient.Win32/MinecraftClient.Win32.vcxproj.filters index c76c4fdab..5991da251 100644 --- a/platforms/windows/projects/MinecraftClient.Win32/MinecraftClient.Win32.vcxproj.filters +++ b/platforms/windows/projects/MinecraftClient.Win32/MinecraftClient.Win32.vcxproj.filters @@ -24,7 +24,7 @@ Header Files - + Header Files @@ -44,7 +44,7 @@ Source Files - + Source Files diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index acf65732e..e08f8101e 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -306,69 +306,22 @@ add_subdirectory(../thirdparty/raknet raknet) target_link_libraries(reminecraftpe-core PUBLIC raknet) # zlib -add_library(zlib INTERFACE) -if(EMSCRIPTEN) +add_library(zlib-interface INTERFACE) +if(WIN32) + # Compile Vendored ZLib + add_subdirectory(../thirdparty/zlib zlib) + target_link_libraries(zlib-interface INTERFACE zlib) +elseif(EMSCRIPTEN) # Use Emscripten's ZLib set(ZLIB_FLAG -sUSE_ZLIB=1) - target_compile_options(zlib INTERFACE "${ZLIB_FLAG}") - target_link_options(zlib INTERFACE "${ZLIB_FLAG}") + target_compile_options(zlib-interface INTERFACE "${ZLIB_FLAG}") + target_link_options(zlib-interface INTERFACE "${ZLIB_FLAG}") else() # Use System ZLib find_package(ZLIB REQUIRED) - target_link_libraries(zlib INTERFACE ZLIB::ZLIB) -endif() -target_link_libraries(reminecraftpe-core PUBLIC zlib) - -# Platform Dependencies -if(USE_SDL) - # SDL - add_library(SDL INTERFACE) - if(ANDROID) - # Use Vendored SDL2 (Only For Android) - add_subdirectory(../thirdparty/SDL2/src SDL EXCLUDE_FROM_ALL) - target_link_libraries(SDL INTERFACE SDL2::SDL2) - elseif(EMSCRIPTEN) - # Use Emscripten's SDL2 - set(SDL_FLAG -sUSE_SDL=2) - target_compile_options(SDL INTERFACE "${SDL_FLAG}") - target_link_options(SDL INTERFACE "${SDL_FLAG}") - else() - # Use System SDL2 - find_package(SDL2 REQUIRED) - target_link_libraries(SDL INTERFACE SDL2::SDL2) - endif() - target_link_libraries(reminecraftpe-core PUBLIC SDL) - - # OpenGL - if(NOT EMSCRIPTEN AND NOT ANDROID) - option(USE_GLES1_COMPATIBILITY_LAYER "Whether To Enable The GLESv1_CM Compatibility Layer" TRUE) - else() - set(USE_GLES1_COMPATIBILITY_LAYER TRUE CACHE BOOL "" FORCE) - endif() - if(USE_GLES1_COMPATIBILITY_LAYER) - set(GLES_COMPATIBILITY_LAYER_USE_SDL TRUE CACHE BOOL "" FORCE) - set(GLES_COMPATIBILITY_LAYER_DEPENDENCY SDL CACHE STRING "" FORCE) - set(GLES_COMPATIBILITY_LAYER_USE_ES3 FALSE CACHE BOOL "" FORCE) - add_subdirectory(../thirdparty/gles-compatibility-layer gles-compatibility-layer) - target_link_libraries(reminecraftpe-core PUBLIC gles-compatibility-layer) - target_compile_definitions(reminecraftpe-core PUBLIC USE_GLES1_COMPATIBILITY_LAYER) - if(EMSCRIPTEN) - # Use WebGL 2 - target_link_options(reminecraftpe-core PUBLIC -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2) - endif() - else() - find_package(OpenGL REQUIRED) - target_link_libraries(reminecraftpe-core PUBLIC OpenGL::GL) - endif() -elseif(USE_NATIVE_ANDROID) - # OpenGL - target_link_libraries(reminecraftpe-core PUBLIC EGL GLESv1_CM) -endif() - -# Android Logging -if(ANDROID) - target_link_libraries(reminecraftpe-core PUBLIC log) + target_link_libraries(zlib-interface INTERFACE ZLIB::ZLIB) endif() +target_link_libraries(reminecraftpe-core PUBLIC zlib-interface) # Sound Data if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../sound_data/sounds.h") @@ -377,3 +330,11 @@ if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../sound_data/sounds.h") endif() target_compile_definitions(reminecraftpe-core PRIVATE MISSING_SOUND_DATA) endif() + +# OpenGL Support Code +if(WIN32) + target_sources(reminecraftpe-core PRIVATE ../thirdparty/GL/GLExt.cpp) +endif() + +# OGG Support +target_link_libraries(reminecraftpe-core PUBLIC stb_vorbis) \ No newline at end of file diff --git a/source/client/app/AppPlatform.hpp b/source/client/app/AppPlatform.hpp index 082552140..51ddc7945 100644 --- a/source/client/app/AppPlatform.hpp +++ b/source/client/app/AppPlatform.hpp @@ -31,7 +31,8 @@ class AppPlatform static AppPlatform* const singleton(); AppPlatform(); - ~AppPlatform(); + + virtual ~AppPlatform(); virtual void buyGame(); virtual int checkLicense(); diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp index 1d38364d9..e0f5817b9 100644 --- a/source/client/app/Minecraft.cpp +++ b/source/client/app/Minecraft.cpp @@ -98,8 +98,6 @@ Minecraft::Minecraft() : m_fLastUpdated = 0; m_fDeltaTime = 0; m_lastInteractTime = 0; - - m_Logger = new Logger(); } int Minecraft::getLicenseId() @@ -885,7 +883,6 @@ Minecraft::~Minecraft() SAFE_DELETE(m_pUser); SAFE_DELETE(m_pLevelStorageSource); SAFE_DELETE(m_pInputHolder); - SAFE_DELETE(m_Logger); //@BUG: potentially leaking a CThread instance if this is destroyed early? } diff --git a/source/client/app/Minecraft.hpp b/source/client/app/Minecraft.hpp index f69d9284c..28e8fc252 100644 --- a/source/client/app/Minecraft.hpp +++ b/source/client/app/Minecraft.hpp @@ -107,7 +107,6 @@ class Minecraft : public App static int customDebugId; private: - Logger *m_Logger; Options *m_options; public: diff --git a/source/client/gui/screens/StartMenuScreen.cpp b/source/client/gui/screens/StartMenuScreen.cpp index 18c196e4f..5156523d0 100644 --- a/source/client/gui/screens/StartMenuScreen.cpp +++ b/source/client/gui/screens/StartMenuScreen.cpp @@ -13,7 +13,7 @@ #include "SelectWorldScreen.hpp" #include "JoinGameScreen.hpp" -#if defined(_WIN32) || (defined(TARGET_OS_MAC) && TARGET_OS_IPHONE == 0) +#if (defined(USE_SDL) || defined(_WIN32) || (defined(TARGET_OS_MAC) && TARGET_OS_IPHONE == 0)) && !defined(ANDROID) #define CAN_QUIT #endif diff --git a/source/client/renderer/GameRenderer.cpp b/source/client/renderer/GameRenderer.cpp index e0a300cca..ff7e3170a 100644 --- a/source/client/renderer/GameRenderer.cpp +++ b/source/client/renderer/GameRenderer.cpp @@ -331,7 +331,9 @@ void GameRenderer::setupFog(int i) fog_color[3] = 1.0f; glFogfv(GL_FOG_COLOR, fog_color); +#ifndef __EMSCRIPTEN__ glNormal3f(0.0f, -1.0f, 0.0f); +#endif glColor4f(1.0f, 1.0f, 1.0f, 1.0f); if (m_pMinecraft->m_pMobPersp->isUnderLiquid(Material::water)) diff --git a/source/client/renderer/Lighting.cpp b/source/client/renderer/Lighting.cpp index ccf769fee..7d162cc54 100644 --- a/source/client/renderer/Lighting.cpp +++ b/source/client/renderer/Lighting.cpp @@ -23,7 +23,9 @@ void Lighting::turnOn() glEnable(GL_LIGHT0); glEnable(GL_LIGHT1); glEnable(GL_COLOR_MATERIAL); +#if !defined(__EMSCRIPTEN__) && !defined(USE_GLES) glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); +#endif constexpr float a = 0.4f, d = 0.6f, s = 0.0f; diff --git a/source/client/renderer/Tesselator.cpp b/source/client/renderer/Tesselator.cpp index a6778c1b0..1a07bc957 100644 --- a/source/client/renderer/Tesselator.cpp +++ b/source/client/renderer/Tesselator.cpp @@ -342,12 +342,13 @@ void Tesselator::vertex(float x, float y, float z) } // Wasn't here in Java cuz I guess it's not needed? -/*#ifdef USE_GL_NORMAL_LIGHTING + // TBR: This is needed with Emscripten's OpenGL implementation. +#ifdef USE_GL_NORMAL_LIGHTING if (m_bHasNormal) { pVert2->m_normal = pVert1->m_normal; } -#endif*/ +#endif pVert2->m_x = pVert1->m_x; pVert2->m_y = pVert1->m_y; diff --git a/source/client/renderer/entity/MobRenderer.cpp b/source/client/renderer/entity/MobRenderer.cpp index 1fbeead8c..d5b3fde6c 100644 --- a/source/client/renderer/entity/MobRenderer.cpp +++ b/source/client/renderer/entity/MobRenderer.cpp @@ -213,7 +213,9 @@ void MobRenderer::renderNameTag(Mob* mob, const std::string& str, float x, float glPushMatrix(); glTranslatef(x + 0.0f, y + 2.3f, z); +#ifndef __EMSCRIPTEN__ glNormal3f(0.0f, 1.0f, 0.0f); +#endif // billboard the name towards the camera glRotatef(-m_pDispatcher->m_rot.x, 0.0f, 1.0f, 0.0f); glRotatef(+m_pDispatcher->m_rot.y, 1.0f, 0.0f, 0.0f); diff --git a/source/common/CThread.cpp b/source/common/CThread.cpp index f2857c8d9..530a40fbc 100644 --- a/source/common/CThread.cpp +++ b/source/common/CThread.cpp @@ -12,7 +12,7 @@ #if defined(_WIN32) #define WIN32_LEAN_AND_MEAN -#include // for Sleep() +#include // for Sleep() #else #include #endif diff --git a/source/common/CThread.hpp b/source/common/CThread.hpp index b2b02b04a..ecc7cd955 100644 --- a/source/common/CThread.hpp +++ b/source/common/CThread.hpp @@ -13,7 +13,7 @@ #if defined(_WIN32) #ifndef USE_WIN32_THREADS -#if defined(_XBOX) || defined(USE_OLD_CPP) +#if defined(_XBOX) || defined(USE_OLD_CPP) || defined(__MINGW32__) // USE_WIN32_THREADS - Use a Win32 implementation of threads instead of using pthread #define USE_WIN32_THREADS #else @@ -41,7 +41,7 @@ #include #else #define WIN32_LEAN_AND_MEAN -#include +#include #endif #else diff --git a/source/common/Logger.cpp b/source/common/Logger.cpp index f629ac4f2..0b75ba832 100644 --- a/source/common/Logger.cpp +++ b/source/common/Logger.cpp @@ -12,11 +12,14 @@ Logger* const Logger::singleton() return m_singleton; } -Logger::Logger() +void Logger::setSingleton(Logger* logger) { // Stick with the first output handle we get - if (!m_singleton) - m_singleton = this; + if (!m_singleton) { + m_singleton = logger; + } else { + m_singleton->print(LOG_ERR, "Logging already setup!"); + } } Logger::~Logger() diff --git a/source/common/Logger.hpp b/source/common/Logger.hpp index 3d1f4a597..7ab2e5863 100644 --- a/source/common/Logger.hpp +++ b/source/common/Logger.hpp @@ -26,8 +26,8 @@ class Logger static Logger* m_singleton; public: static Logger* const singleton(); + static void setSingleton(Logger*); - Logger(); virtual ~Logger(); const char* GetTag(eLogLevel ll); diff --git a/source/common/Utils.cpp b/source/common/Utils.cpp index e187e142a..beb8f1785 100644 --- a/source/common/Utils.cpp +++ b/source/common/Utils.cpp @@ -14,7 +14,7 @@ #if defined(_WIN32) && !defined(_XBOX) #define WIN32_LEAN_AND_MEAN -#include +#include #include #include @@ -276,7 +276,7 @@ time_t getEpochTimeS() return time(0); } -#ifdef _WIN32 +#if defined(_WIN32) && !defined(USE_SDL) HINSTANCE g_hInstance = NULL; HWND g_hWnd = NULL; diff --git a/source/common/Utils.hpp b/source/common/Utils.hpp index 8098fc8f3..f0ae463d1 100644 --- a/source/common/Utils.hpp +++ b/source/common/Utils.hpp @@ -37,9 +37,9 @@ // Do we even need all this WinSock stuff anymore? #ifndef _XBOX // assume we're on a normal Windows device #define WIN32_LEAN_AND_MEAN -#include -#include -#include +#include +#include +#include #include #include diff --git a/thirdparty/GL/GL.hpp b/thirdparty/GL/GL.hpp index bfe1cf645..91157af67 100644 --- a/thirdparty/GL/GL.hpp +++ b/thirdparty/GL/GL.hpp @@ -16,10 +16,8 @@ #include #endif -#ifdef USE_GLES1_COMPATIBILITY_LAYER - #define USE_GLES // GLES or its compatibility layer. -#endif - +// Disable this on OpenGL ES 2+ +#define USE_GL_NORMAL_LIGHTING #ifdef USE_GLES #if MC_PLATFORM_IOS @@ -38,9 +36,6 @@ #define USE_GL_ORTHO_F #else - // Standard OpenGL supports normals and lighting, OpenGL ES doesn't - #define USE_GL_NORMAL_LIGHTING - #ifdef USE_SDL #define USE_OPENGL_2_FEATURES diff --git a/thirdparty/SDL2/SDL2.h b/thirdparty/SDL2/SDL2.h index 04de4d961..3d2518b96 100644 --- a/thirdparty/SDL2/SDL2.h +++ b/thirdparty/SDL2/SDL2.h @@ -3,6 +3,7 @@ #ifdef _WIN32 #pragma comment(lib, "SDL2.lib") #include +#include #else #include #endif \ No newline at end of file diff --git a/thirdparty/gles-compatibility-layer b/thirdparty/gles-compatibility-layer deleted file mode 160000 index 5bf535a68..000000000 --- a/thirdparty/gles-compatibility-layer +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5bf535a68fe1ca0381b4628859e642b40a166017 diff --git a/thirdparty/raknet/CMakeLists.txt b/thirdparty/raknet/CMakeLists.txt index 99465983b..3fac7eb43 100644 --- a/thirdparty/raknet/CMakeLists.txt +++ b/thirdparty/raknet/CMakeLists.txt @@ -115,3 +115,12 @@ add_library(raknet STATIC RakSleep.cpp ) target_include_directories(raknet PUBLIC .) + +# Windows Support +if(WIN32) + target_compile_definitions(raknet + PUBLIC SHA1_HAS_TCHAR + PUBLIC LOCKLESS_TYPES_USE_MUTEX + ) + target_link_libraries(raknet ws2_32) +endif() \ No newline at end of file diff --git a/thirdparty/raknet/WindowsIncludes.h b/thirdparty/raknet/WindowsIncludes.h index 9ec686837..969d9aeb5 100644 --- a/thirdparty/raknet/WindowsIncludes.h +++ b/thirdparty/raknet/WindowsIncludes.h @@ -16,9 +16,9 @@ #include #elif defined (_WIN32) && !defined(WINDOWS_PHONE_8) && !defined(WINDOWS_STORE_RT) #define _WINPC -#include +#include #include -#include +#include // Must always include Winsock2.h before windows.h // or else: diff --git a/thirdparty/stb_image/CMakeLists.txt b/thirdparty/stb_image/CMakeLists.txt index 0e11124b8..475339635 100644 --- a/thirdparty/stb_image/CMakeLists.txt +++ b/thirdparty/stb_image/CMakeLists.txt @@ -4,3 +4,5 @@ project(stb_image) # Build add_library(stb_image STATIC src/stb_image_impl.c) target_include_directories(stb_image PUBLIC include) +add_library(stb_vorbis STATIC include/stb_vorbis.c) +target_include_directories(stb_vorbis PUBLIC include) From 52351f89185d16824a716afcaf7ef4fc5f1e4910 Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Tue, 13 May 2025 00:20:49 -0500 Subject: [PATCH 002/293] Fix MinecraftClient.Win32 VS Building Small oversight --- .../MinecraftClient.Win32/MinecraftClient.Win32.vcxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platforms/windows/projects/MinecraftClient.Win32/MinecraftClient.Win32.vcxproj b/platforms/windows/projects/MinecraftClient.Win32/MinecraftClient.Win32.vcxproj index dab9c33b3..a633e212c 100644 --- a/platforms/windows/projects/MinecraftClient.Win32/MinecraftClient.Win32.vcxproj +++ b/platforms/windows/projects/MinecraftClient.Win32/MinecraftClient.Win32.vcxproj @@ -37,7 +37,7 @@ - $(DXSDK_DIR)\Include;$(MC_ROOT)\thirdparty\stb_image\include;%(AdditionalIncludeDirectories) + $(DXSDK_DIR)\Include;$(MC_ROOT)\platforms\sound\directsound;$(MC_ROOT)\thirdparty\stb_image\include;%(AdditionalIncludeDirectories) Windows @@ -96,4 +96,4 @@ $(MC_ROOT)\game WindowsLocalDebugger - \ No newline at end of file + From cb90625b5d71e4261c7220f2269f3592ef8905e7 Mon Sep 17 00:00:00 2001 From: __andrew <95462744+known81331@users.noreply.github.com> Date: Wed, 4 Jun 2025 02:45:31 -0400 Subject: [PATCH 003/293] Sky Rendering Bugfixes (#156) * cloud culling fix * fix 3d cloud jitter * fix sunset gradient --------- Co-authored-by: Brent <43089001+BrentDaMage@users.noreply.github.com> --- source/client/renderer/LevelRenderer.cpp | 19 +++++++++++++++++-- source/world/level/Dimension.cpp | 20 ++++++++++++++++++++ thirdparty/GL/GL.hpp | 8 ++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/source/client/renderer/LevelRenderer.cpp b/source/client/renderer/LevelRenderer.cpp index 36e103f75..329710117 100644 --- a/source/client/renderer/LevelRenderer.cpp +++ b/source/client/renderer/LevelRenderer.cpp @@ -1288,6 +1288,16 @@ void LevelRenderer::renderClouds(float alpha) t.voidBeginAndEndCalls(false); // why?? t.draw(); + + + + + float yy = ((float)C_MAX_Y - yPos) + 0.33f; // 108.0f on b1.2_02, see below + + if (yy > 1.0f) { + glClear(GL_DEPTH_BUFFER_BIT); + } + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glDisable(GL_BLEND); glEnable(GL_CULL_FACE); @@ -1305,8 +1315,8 @@ void LevelRenderer::renderAdvancedClouds(float alpha) constexpr float h = 4.0f; // @NOTE: Using Mth::Lerp will use incorrect logic - float xo = (m_pMinecraft->m_pMobPersp->m_oPos.x + (m_pMinecraft->m_pMobPersp->m_oPos.x - m_pMinecraft->m_pMobPersp->m_oPos.x) * alpha + ((float(m_ticksSinceStart) + alpha) * 0.03f)) / ss; - float zo = (m_pMinecraft->m_pMobPersp->m_oPos.z + (m_pMinecraft->m_pMobPersp->m_oPos.z - m_pMinecraft->m_pMobPersp->m_oPos.z) * alpha) / ss + 0.33f; + float xo = (m_pMinecraft->m_pMobPersp->m_oPos.x + (m_pMinecraft->m_pMobPersp->m_pos.x - m_pMinecraft->m_pMobPersp->m_oPos.x) * alpha + ((float(m_ticksSinceStart) + alpha) * 0.03f)) / ss; + float zo = (m_pMinecraft->m_pMobPersp->m_oPos.z + (m_pMinecraft->m_pMobPersp->m_pos.z - m_pMinecraft->m_pMobPersp->m_oPos.z) * alpha) / ss + 0.33f; float yy = ((float)C_MAX_Y - yOffs) + 0.33f; // 108.0f on b1.2_02, see below //float yy = 108.0f - yOffs + 0.33F; @@ -1454,6 +1464,11 @@ void LevelRenderer::renderAdvancedClouds(float alpha) } } + if (yy > 1.0f) { + glDepthRange(0.f, 7.f); + glClear(GL_DEPTH_BUFFER_BIT); + } + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glDisable(GL_BLEND); glEnable(GL_CULL_FACE); diff --git a/source/world/level/Dimension.cpp b/source/world/level/Dimension.cpp index a8981a890..6ec2e9772 100644 --- a/source/world/level/Dimension.cpp +++ b/source/world/level/Dimension.cpp @@ -53,6 +53,25 @@ Vec3 Dimension::getFogColor(float a, float b) float* Dimension::getSunriseColor(float a, float b) { + float radial = 0.4f; + float dot = Mth::cos(a * M_PI * 2.0f) - 0.125f; // * 2.0f + 0.5f; + float center = -0.0f; + + if (dot >= center - radial && dot <= center + radial) + { + float norm = (dot - center) / radial * 0.5f + 0.5f; + float alpha = 1.0f - (1.0f - Mth::sin(norm * M_PI)) * 0.99f; + + m_sunriseColor[0] = norm * 0.3f + 0.7f; + m_sunriseColor[1] = norm * norm * 0.7f + 0.2f; + m_sunriseColor[2] = norm * norm * 0.0f + 0.2f; + m_sunriseColor[3] = alpha * alpha; + + return m_sunriseColor; + } + return nullptr; +/* + float x1 = Mth::cos(a * M_PI * 2.0f); //@BUG: Meant to use Mth::cos? if (x1 < -0.4f || x1 > 0.4f) return nullptr; @@ -66,6 +85,7 @@ float* Dimension::getSunriseColor(float a, float b) m_sunriseColor[3] = ((x3 * -0.99f) + 1.0f) * ((x3 * -0.99f) + 1.0f); return m_sunriseColor; + */ } float Dimension::getTimeOfDay(int32_t l, float f) diff --git a/thirdparty/GL/GL.hpp b/thirdparty/GL/GL.hpp index 91157af67..2954eb6c1 100644 --- a/thirdparty/GL/GL.hpp +++ b/thirdparty/GL/GL.hpp @@ -35,6 +35,14 @@ #include #define USE_GL_ORTHO_F + + // https://discourse.libsdl.org/t/opengl-es2-support-on-windows/20177/10 + // float on GLES for performance reasons (mobile hardware) rather than double precision on GL + #if GL_ES_VERSION_2_0 + #define glClearColor glClearColorf + #endif + #define glClearDepth glClearDepthf + #define glDepthRange glDepthRangef #else #ifdef USE_SDL #define USE_OPENGL_2_FEATURES From 918b87c1b6cc092faceb83562ca3471513609759 Mon Sep 17 00:00:00 2001 From: riall <71668864+break-core@users.noreply.github.com> Date: Wed, 4 Jun 2025 02:47:46 -0400 Subject: [PATCH 004/293] Monster.cpp implementation (#155) * work on Monster.cpp * Fix build * Formatting consistency * No need for Mth::floor * Apply requested fixes --- source/world/entity/Animal.cpp | 2 +- source/world/entity/Animal.hpp | 2 +- source/world/entity/Mob.cpp | 6 +- source/world/entity/Mob.hpp | 4 +- source/world/entity/Monster.cpp | 88 +++++++++++++++++++++++++++ source/world/entity/Monster.hpp | 19 ++++++ source/world/entity/PathfinderMob.cpp | 6 +- source/world/entity/PathfinderMob.hpp | 4 +- 8 files changed, 119 insertions(+), 12 deletions(-) diff --git a/source/world/entity/Animal.cpp b/source/world/entity/Animal.cpp index c73bdf878..944b65463 100644 --- a/source/world/entity/Animal.cpp +++ b/source/world/entity/Animal.cpp @@ -30,7 +30,7 @@ bool Animal::isBaby() const return getAge() < 0; } -bool Animal::canSpawn() const +bool Animal::canSpawn() { TilePos pos(m_pos.x, m_hitbox.min.y, m_pos.z); diff --git a/source/world/entity/Animal.hpp b/source/world/entity/Animal.hpp index 927182bcd..755179978 100644 --- a/source/world/entity/Animal.hpp +++ b/source/world/entity/Animal.hpp @@ -17,7 +17,7 @@ class Animal : public PathfinderMob // TODO: void readAdditonalSaveData(CompoundTag*) override; void aiStep() override; bool isBaby() const override; - bool canSpawn() const override; + bool canSpawn() override; Entity* findAttackTarget() override; int getAmbientSoundInterval() const override; float getWalkTargetValue(const TilePos& pos) const override; diff --git a/source/world/entity/Mob.cpp b/source/world/entity/Mob.cpp index 55d791fc2..3b39b78d7 100644 --- a/source/world/entity/Mob.cpp +++ b/source/world/entity/Mob.cpp @@ -24,7 +24,7 @@ Mob::Mob(Level* pLevel) : Entity(pLevel) m_hurtDuration = 0; m_hurtDir = 0.0f; field_110 = 0; - field_114 = 0; + m_attackTime = 0; m_oTilt = 0.0f; m_tilt = 0.0f; field_120 = 0; @@ -259,7 +259,7 @@ void Mob::baseTick() m_oTilt = m_tilt; - if (field_114 > 0) field_114--; + if (m_attackTime > 0) m_attackTime--; if (m_hurtTime > 0) m_hurtTime--; if (field_B8 > 0) field_B8--; @@ -642,7 +642,7 @@ void Mob::lookAt(Entity* pEnt, float a3, float a4) rotlerp(m_rot.x, x1 * 180.0f / float(M_PI) - 90.0f, a3))); } -bool Mob::canSpawn() const +bool Mob::canSpawn() { return m_pLevel->getCubes(this, m_hitbox)->empty(); } diff --git a/source/world/entity/Mob.hpp b/source/world/entity/Mob.hpp index 63568fc1d..74d9abe65 100644 --- a/source/world/entity/Mob.hpp +++ b/source/world/entity/Mob.hpp @@ -56,7 +56,7 @@ class Mob : public Entity virtual bool isLookingAtAnEntity() { return m_pEntLookedAt != nullptr; } virtual Entity* getLookingAt() const { return m_pEntLookedAt; } virtual void beforeRemove() { } - virtual bool canSpawn() const; + virtual bool canSpawn(); virtual float getAttackAnim(float f) const; virtual Vec3 getPos(float f) const; virtual Vec3 getLookAngle(float f) const { return getViewVector(1.0f); } @@ -99,7 +99,7 @@ class Mob : public Entity int m_hurtDuration; float m_hurtDir; int field_110; - int field_114; + int m_attackTime; float m_oTilt; float m_tilt; int field_120; diff --git a/source/world/entity/Monster.cpp b/source/world/entity/Monster.cpp index e69de29bb..25a7a0296 100644 --- a/source/world/entity/Monster.cpp +++ b/source/world/entity/Monster.cpp @@ -0,0 +1,88 @@ +#include "world/entity/Monster.hpp" + +Monster::Monster(Level* pLevel) : PathfinderMob(pLevel) +{ + m_health = 20; + m_attackDamage = 2; +} + +void Monster::aiStep() +{ + float brightness = getBrightness(1.0f); + + if (brightness > 0.5f) + { + m_noActionTime += 2; + } + + PathfinderMob::aiStep(); +} + +void Monster::tick() +{ + PathfinderMob::tick(); + + // Remove any monsters when in peaceful mode + if (m_pLevel->m_difficulty == 0) + { + remove(); + } +} + +Entity* Monster::findAttackTarget() +{ + Player* player = m_pLevel->getNearestPlayer(this, 16.0f); + + if (player && canSee(player)) + { + return player; + } + + return nullptr; +} + +bool Monster::hurt(Entity* pCulprit, int damage) +{ + if (PathfinderMob::hurt(pCulprit, damage)) + { + if (pCulprit != this) + { + m_pAttackTarget = pCulprit; + } + return true; + } + + return false; +} + +void Monster::checkHurtTarget(Entity* pEnt, float f) +{ + if (m_attackTime <= 0 && f < 2.0f && pEnt->m_hitbox.max.y > m_hitbox.min.y && pEnt->m_hitbox.min.y < m_hitbox.max.y) + { + m_attackTime = 20; + pEnt->hurt(this, m_attackDamage); + } +} + +float Monster::getWalkTargetValue(const TilePos& pos) const +{ + float brightness = m_pLevel->getBrightness(pos); + + return 0.5f - brightness; +} + +bool Monster::canSpawn() +{ + TilePos pos(m_pos.x, m_hitbox.min.y, m_pos.z); + + if (m_pLevel->getBrightness(LightLayer::Sky, pos) > m_random.nextInt(30)) + { + return false; + } + else if (m_pLevel->getBrightness(pos) <= m_random.nextInt(8)) + { + return PathfinderMob::canSpawn(); + } + + return false; +} \ No newline at end of file diff --git a/source/world/entity/Monster.hpp b/source/world/entity/Monster.hpp index e69de29bb..daa76b43f 100644 --- a/source/world/entity/Monster.hpp +++ b/source/world/entity/Monster.hpp @@ -0,0 +1,19 @@ +#include "world/entity/PathfinderMob.hpp" +#include "world/level/Level.hpp" + +class Monster : public PathfinderMob +{ +public: + Monster(Level* pLevel); + + void aiStep() override; + void tick() override; + Entity* findAttackTarget() override; + bool hurt(Entity* pCulprit, int damage) override; + virtual void checkHurtTarget(Entity*, float) override; + virtual float getWalkTargetValue(const TilePos& pos) const override; + bool canSpawn() override; + +protected: + int m_attackDamage; +}; \ No newline at end of file diff --git a/source/world/entity/PathfinderMob.cpp b/source/world/entity/PathfinderMob.cpp index 8a3213431..18e2e5473 100644 --- a/source/world/entity/PathfinderMob.cpp +++ b/source/world/entity/PathfinderMob.cpp @@ -32,9 +32,9 @@ Entity* PathfinderMob::findAttackTarget() return nullptr; } -bool PathfinderMob::checkHurtTarget(Entity* pEnt, float f) +void PathfinderMob::checkHurtTarget(Entity* pEnt, float f) { - return false; + // Override this function in your own mob. } void PathfinderMob::checkCantSeeTarget(Entity* pEnt, float f) @@ -91,7 +91,7 @@ float PathfinderMob::getWalkingSpeedModifier() const return mod; } -bool PathfinderMob::canSpawn() const +bool PathfinderMob::canSpawn() { if (!Mob::canSpawn()) return false; diff --git a/source/world/entity/PathfinderMob.hpp b/source/world/entity/PathfinderMob.hpp index d0d00ab1b..9b0059567 100644 --- a/source/world/entity/PathfinderMob.hpp +++ b/source/world/entity/PathfinderMob.hpp @@ -18,14 +18,14 @@ class PathfinderMob : public Mob virtual Entity* getAttackTarget(); virtual void setAttackTarget(Entity*); virtual Entity* findAttackTarget(); - virtual bool checkHurtTarget(Entity*, float); + virtual void checkHurtTarget(Entity*, float); virtual void checkCantSeeTarget(Entity*, float); virtual float getWalkTargetValue(const TilePos& pos) const; virtual bool shouldHoldGround() const; virtual void findRandomStrollLocation(); float getWalkingSpeedModifier() const override; - bool canSpawn() const override; + bool canSpawn() override; void updateAi() override; void setPath(Path& path); From 1f85c6491ac970d8d8534375b635fed322a33256 Mon Sep 17 00:00:00 2001 From: TheBrokenRail <17478432+TheBrokenRail@users.noreply.github.com> Date: Wed, 4 Jun 2025 23:34:33 -0400 Subject: [PATCH 005/293] Load Sound Data From Files (#150) * Generic Asset Loading * Load Sounds From Files * Some Fixes * Added OGG Vorbis Support * Fix Native Android * Fix WASM Build * Fix macOS Build * Salvage unmerged changes from cmake-mingw-things * Bugfixes * Fixed building on Windows + issues that could occur on non-Macs from stb_vorbis defining the "R" macro * Fixed SoundSystemDS * Fixed unmerged SoundEngine::playUI calls * WIP SoundStream * Sound Fixes * SoundSystem cleanup * Added Music * Added support for streaming sounds via SoundStream * Added SoundStream base class and SoundStreamAL * SoundEngine listener position * Fix Android & macOS Build Issues * Fix Android Building (oops) * SoundStream / Music Fixes * Fixed SoundStreamAL buffer re-use * Abstracted private SoundStreamAL functions * Added music to music_list.h * Moved AL_ERROR_CHECK to /thirdparty/OpenAL.h * Added AL_ERROR_SILENCE * Fix unresolved merge conflicts * Add SoundStreamAL.cpp to CMakeLists.txt * Remove leftover "platforms/openal" directory * Fixed building on macOS * Fix VS Project Paths * SoundStream Abstractions * Update SoundSystemSL.cpp * Update SoundSystemDS.cpp * SoundStreamAL C++03 Compatibility * for real this time * More Paulscode Parity * Support for loading from multiple sound/music directories * Update README.md * Update README.md --------- Co-authored-by: BrentDaMage Co-authored-by: Brent <43089001+BrentDaMage@users.noreply.github.com> --- .github/workflows/build.yml | 4 +- .gitignore | 16 +- README.md | 19 +- platforms/android/AppPlatform_android.cpp | 19 + platforms/android/AppPlatform_android.hpp | 2 + .../Minecraft.xcodeproj/project.pbxproj | 44 +- platforms/sdl/base/AppPlatform_sdl_base.cpp | 27 ++ platforms/sdl/base/AppPlatform_sdl_base.hpp | 3 + .../sound/directsound/CustomSoundSystem.hpp | 14 +- platforms/sound/directsound/SoundSystemDS.cpp | 124 +++--- platforms/sound/openal/CMakeLists.txt | 1 + platforms/sound/openal/CustomSoundSystem.hpp | 66 +-- platforms/sound/openal/SoundStreamAL.cpp | 156 +++++++ platforms/sound/openal/SoundStreamAL.hpp | 45 ++ platforms/sound/openal/SoundSystemAL.cpp | 403 +++++++++++------- platforms/sound/opensl/CustomSoundSystem.hpp | 14 +- platforms/sound/opensl/SoundSystemSL.cpp | 45 +- platforms/windows/AppPlatform_win32.cpp | 16 +- platforms/windows/AppPlatform_win32.hpp | 2 +- platforms/windows/minecraftcpp.sln | 21 +- .../windows/projects/Client/Client.vcxproj | 9 + .../projects/Client/Client.vcxproj.filters | 20 +- .../MinecraftClient.SDL2.vcxproj | 8 +- .../MinecraftClient.SDL2.vcxproj.filters | 10 +- platforms/windows/projects/STB/STB.vcxproj | 67 +++ .../windows/projects/STB/STB.vcxproj.filters | 78 ++++ source/CMakeLists.txt | 31 +- source/client/app/AppPlatform.cpp | 10 +- source/client/app/AppPlatform.hpp | 3 + source/client/app/AssetFile.hpp | 19 + source/client/app/Minecraft.cpp | 12 +- source/client/gui/Gui.cpp | 8 +- source/client/gui/Screen.cpp | 6 +- .../screens/IngameBlockSelectionScreen.cpp | 2 +- source/client/options/Options.cpp | 2 +- source/client/options/Options.hpp | 2 +- source/client/renderer/GameRenderer.cpp | 4 +- source/client/renderer/ItemInHandRenderer.cpp | 4 +- .../entity/EntityRenderDispatcher.cpp | 4 +- source/client/renderer/entity/MobRenderer.cpp | 8 +- source/client/sound/SoundData.cpp | 127 +++++- source/client/sound/SoundData.hpp | 63 ++- source/client/sound/SoundDefs.hpp | 34 -- source/client/sound/SoundEngine.cpp | 201 ++++++--- source/client/sound/SoundEngine.hpp | 49 ++- source/client/sound/SoundPathRepository.cpp | 47 ++ source/client/sound/SoundPathRepository.hpp | 20 + source/client/sound/SoundRepository.cpp | 4 +- source/client/sound/SoundRepository.hpp | 1 - source/client/sound/SoundStream.cpp | 111 +++++ source/client/sound/SoundStream.hpp | 57 +++ source/client/sound/SoundSystem.cpp | 52 ++- source/client/sound/SoundSystem.hpp | 41 +- source/client/sound/music_list.h | 12 + source/client/sound/sound_list.h | 67 +++ source/common/Mth.cpp | 8 +- source/network/PacketUtil.cpp | 4 +- source/renderer/GL/GL.cpp | 64 +-- source/world/entity/Entity.cpp | 25 +- source/world/entity/Entity.hpp | 10 +- source/world/entity/ItemEntity.cpp | 2 +- source/world/entity/Mob.cpp | 327 ++++++++------ source/world/entity/Mob.hpp | 12 +- source/world/entity/Player.cpp | 49 ++- source/world/entity/TripodCamera.cpp | 2 +- source/world/gamemode/CreativeMode.cpp | 1 + source/world/gamemode/GameMode.cpp | 2 + source/world/gamemode/SurvivalMode.cpp | 2 + source/world/level/Level.cpp | 4 +- source/world/level/storage/LevelData.cpp | 2 +- thirdparty/GL/GL.hpp | 2 +- thirdparty/OpenAL.h | 24 ++ tools/extract_apk.py | 81 ++++ tools/grabsounds.py | 181 ++------ tools/setup_venv.py | 44 ++ 75 files changed, 2154 insertions(+), 926 deletions(-) create mode 100644 platforms/sound/openal/SoundStreamAL.cpp create mode 100644 platforms/sound/openal/SoundStreamAL.hpp create mode 100644 platforms/windows/projects/STB/STB.vcxproj create mode 100644 platforms/windows/projects/STB/STB.vcxproj.filters create mode 100644 source/client/app/AssetFile.hpp create mode 100644 source/client/sound/SoundPathRepository.cpp create mode 100644 source/client/sound/SoundPathRepository.hpp create mode 100644 source/client/sound/SoundStream.cpp create mode 100644 source/client/sound/SoundStream.hpp create mode 100644 source/client/sound/music_list.h create mode 100644 source/client/sound/sound_list.h create mode 100644 thirdparty/OpenAL.h create mode 100755 tools/extract_apk.py create mode 100644 tools/setup_venv.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b0bb0a1a0..080fcd287 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -64,7 +64,7 @@ jobs: -sdk macosx \ -configuration "Release (Default)" \ -destination generic/platform=macOS \ - GCC_PREPROCESSOR_DEFINITIONS='MISSING_SOUND_DATA $(GCC_PREPROCESSOR_DEFINITIONS)' \ + GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_DEFINITIONS)' \ -quiet \ clean archive # @NOTE: Newer versions of Xcode will complain and refuse to build old XIB files or target old iOS versions @@ -83,7 +83,7 @@ jobs: # -sdk iphoneos \ # -configuration "Release (iOS)" \ # -destination generic/platform=iOS \ - # GCC_PREPROCESSOR_DEFINITIONS='MISSING_SOUND_DATA $(GCC_PREPROCESSOR_DEFINITIONS)' \ + # GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_DEFINITIONS)' \ # -quiet \ # clean archive android: diff --git a/.gitignore b/.gitignore index 85fe04251..20855b3ec 100644 --- a/.gitignore +++ b/.gitignore @@ -211,6 +211,12 @@ xcuserdata/ /game/assets/gui/touchgui2.png /game/assets/item/arrows.png /game/assets/item/sign.png +# Sound +/game/assets/sound +/game/assets/newsound +/game/assets/sound3 +/game/assets/music +/game/assets/newmusic # Java /game/assets/terrain/sun.png /game/assets/terrain/moon.png @@ -242,11 +248,11 @@ xcuserdata/ # Ignore options.txt - where your configuration will be saved /game/options.txt /game/assetsO -/game/assets/gui/feedback_fill.png -/game/assets/gui/feedback_outer.png -/game/assets/snow.png -/game/assets/mob/pig.png # CLion /.idea -/cmake-build-* \ No newline at end of file +/cmake-build-* + +# PCM sound extraction +/tools/__pycache__ +/tools/venv diff --git a/README.md b/README.md index d72711ee5..db51a0e0f 100644 --- a/README.md +++ b/README.md @@ -68,12 +68,19 @@ This fetches the three dependencies we have: - [coi-serviceworker](https://github.com/gzuidhof/coi-serviceworker) - [gles-compatibility-layer](https://github.com/TheBrokenRail/gles-compatibility-layer.git) -2. Load the sound assets into the `sound_data/` folder in the root of the project -by **running the following command**: -* `tools/grabsounds.py /path/to/the/apk/lib/armeabi-v7a/libminecraftpe.so`. - -After that, **prepare the assets folder** from the apk. You will need it for the platform specific -build. +2. Copy the assets (including sounds and textures) into the necessary folders within the project.
+ Do this by performing **one** of the following: + - To extract all assets from _Pocket Edition_: + - **Run the following command**: + - `tools/extract_apk.py /path/to/the/apk` + - You can also run it with an interactive GUI by not providing arguments. + - To extract only the sounds from _Pocket Edition_: + - **Run the following command**: + - `tools/grabsounds.py /path/to/the/apk/lib/armeabi-v7a/libminecraftpe.so` + - You will need to extract textures and other assets manually. + - To retrieve only the sounds from _Java Edition_: + - Locate the `resources` directory in the `.minecraft` folder and copy its contents (e.g. `music`, `sound`, etc.) into the `game/assets/` directory of the project. + - You will need to extract textures and other assets manually from _Pocket Edition_. ## Building diff --git a/platforms/android/AppPlatform_android.cpp b/platforms/android/AppPlatform_android.cpp index 0f6fd4a4e..d8de4b86b 100644 --- a/platforms/android/AppPlatform_android.cpp +++ b/platforms/android/AppPlatform_android.cpp @@ -357,3 +357,22 @@ int AppPlatform_android::getKeyboardUpOffset() // For now we'll just return 1/2 of the screen height. That ought to cover most cases. return m_ScreenHeight / 2; } + +AssetFile AppPlatform_android::readAssetFile(const std::string& str, bool quiet) const +{ + std::string realPath = str; + if (realPath.size() && realPath[0] == '/') + // trim it off + realPath = realPath.substr(1); + + AAsset* asset = AAssetManager_open(m_app->activity->assetManager, str.c_str(), AASSET_MODE_BUFFER); + if (!asset) { + if (!quiet) LOG_E("File %s couldn't be opened", realPath.c_str()); + return AssetFile(); + } + size_t cnt = AAsset_getLength(asset); + unsigned char* buffer = new unsigned char[cnt]; + AAsset_read(asset, (void*)buffer, cnt); + AAsset_close(asset); + return AssetFile(ssize_t(cnt), buffer); +} \ No newline at end of file diff --git a/platforms/android/AppPlatform_android.hpp b/platforms/android/AppPlatform_android.hpp index 3e6de84f6..f7420a7c5 100644 --- a/platforms/android/AppPlatform_android.hpp +++ b/platforms/android/AppPlatform_android.hpp @@ -62,6 +62,8 @@ class AppPlatform_android : public AppPlatform void initAndroidApp(android_app* ptr); void setExternalStoragePath(const std::string& path); + AssetFile readAssetFile(const std::string&, bool) const override; + private: void changeKeyboardVisibility(bool bShown); diff --git a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj index c0dfd30a8..6bfc4cf21 100644 --- a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj +++ b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj @@ -200,6 +200,8 @@ 8426107E2AE989730065905F /* RakNetInstance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD64E2AC810620006A435 /* RakNetInstance.cpp */; }; 8426107F2AE989730065905F /* ServerSideNetworkHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD6502AC810620006A435 /* ServerSideNetworkHandler.cpp */; }; 842610882AE98A4C0065905F /* libRakNet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84FFBD7E2ACA2876005A8CCF /* libRakNet.a */; }; + 8435BB192DCD47F400D38282 /* SoundStreamAL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8435BB182DCD47F400D38282 /* SoundStreamAL.cpp */; }; + 8435BB1A2DCD47F400D38282 /* SoundStreamAL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8435BB182DCD47F400D38282 /* SoundStreamAL.cpp */; }; 8441F98F2DB4E911005977BD /* SoundSystemAL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8441F9862DB4E911005977BD /* SoundSystemAL.cpp */; }; 8441F9962DB4E911005977BD /* SoundSystemAL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8441F9862DB4E911005977BD /* SoundSystemAL.cpp */; }; 8443B6EA2A98675F0086730C /* libSDL2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8443B6E92A98675F0086730C /* libSDL2.a */; }; @@ -393,6 +395,11 @@ 849FF0DC2AF465340013BAE3 /* char.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E0018E2AF3A28B009B9555 /* char.png */; }; 849FF0DD2AF465340013BAE3 /* particles.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E0018F2AF3A28B009B9555 /* particles.png */; }; 849FF0DE2AF465340013BAE3 /* terrain.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E001912AF3A28B009B9555 /* terrain.png */; }; + 84A2FF162DB5B7B70090CE3E /* AssetFile.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84A2FF152DB5B7B70090CE3E /* AssetFile.hpp */; }; + 84A2FF182DB61D440090CE3E /* SoundPathRepository.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84A2FF172DB61D3A0090CE3E /* SoundPathRepository.hpp */; }; + 84A2FF1A2DB61D720090CE3E /* SoundPathRepository.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84A2FF192DB61D6D0090CE3E /* SoundPathRepository.cpp */; }; + 84A2FF1C2DB61F650090CE3E /* SoundStream.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84A2FF1B2DB61F610090CE3E /* SoundStream.hpp */; }; + 84A2FF1E2DB61F6C0090CE3E /* SoundStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84A2FF1D2DB61F690090CE3E /* SoundStream.cpp */; }; 84AA8B502B32F39A003F5B82 /* BinaryHeap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8B482B32F39A003F5B82 /* BinaryHeap.cpp */; }; 84AA8B512B32F39A003F5B82 /* BinaryHeap.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84AA8B492B32F39A003F5B82 /* BinaryHeap.hpp */; }; 84AA8B522B32F39A003F5B82 /* Node.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8B4A2B32F39A003F5B82 /* Node.cpp */; }; @@ -1776,6 +1783,8 @@ 84336BA52B1EB57E00097DB0 /* Settings_iOS_Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Settings_iOS_Debug.xcconfig; path = ../Configuration/Settings_iOS_Debug.xcconfig; sourceTree = ""; }; 84336BA82B1EB88500097DB0 /* Settings_macOS.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Settings_macOS.xcconfig; path = ../Configuration/Settings_macOS.xcconfig; sourceTree = ""; }; 84336BA92B1EB9C200097DB0 /* Settings_macOS_Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Settings_macOS_Debug.xcconfig; path = ../Configuration/Settings_macOS_Debug.xcconfig; sourceTree = ""; }; + 8435BB172DCD47F400D38282 /* SoundStreamAL.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = SoundStreamAL.hpp; sourceTree = ""; }; + 8435BB182DCD47F400D38282 /* SoundStreamAL.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SoundStreamAL.cpp; sourceTree = ""; }; 8441F9852DB4E911005977BD /* CustomSoundSystem.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CustomSoundSystem.hpp; sourceTree = ""; }; 8441F9862DB4E911005977BD /* SoundSystemAL.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SoundSystemAL.cpp; sourceTree = ""; }; 8443B6E92A98675F0086730C /* libSDL2.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libSDL2.a; path = /opt/local/lib/libSDL2.a; sourceTree = ""; }; @@ -1925,6 +1934,11 @@ 849488352C9284DA006DB706 /* Lighting.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Lighting.hpp; sourceTree = ""; }; 8495E4872AF0905B00A06901 /* AppPlatform_iOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppPlatform_iOS.h; sourceTree = ""; }; 8495E4882AF0905B00A06901 /* AppPlatform_iOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppPlatform_iOS.mm; sourceTree = ""; }; + 84A2FF152DB5B7B70090CE3E /* AssetFile.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AssetFile.hpp; sourceTree = ""; }; + 84A2FF172DB61D3A0090CE3E /* SoundPathRepository.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = SoundPathRepository.hpp; sourceTree = ""; }; + 84A2FF192DB61D6D0090CE3E /* SoundPathRepository.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SoundPathRepository.cpp; sourceTree = ""; }; + 84A2FF1B2DB61F610090CE3E /* SoundStream.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = SoundStream.hpp; sourceTree = ""; }; + 84A2FF1D2DB61F690090CE3E /* SoundStream.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SoundStream.cpp; sourceTree = ""; }; 84AA8B482B32F39A003F5B82 /* BinaryHeap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BinaryHeap.cpp; sourceTree = ""; }; 84AA8B492B32F39A003F5B82 /* BinaryHeap.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = BinaryHeap.hpp; sourceTree = ""; }; 84AA8B4A2B32F39A003F5B82 /* Node.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Node.cpp; sourceTree = ""; }; @@ -2314,14 +2328,15 @@ 840DD57D2AC810620006A435 /* app */ = { isa = PBXGroup; children = ( - 840DD57E2AC810620006A435 /* App.cpp */, 840DD57F2AC810620006A435 /* App.hpp */, - 840DD5802AC810620006A435 /* AppPlatform.cpp */, + 840DD57E2AC810620006A435 /* App.cpp */, 840DD5812AC810620006A435 /* AppPlatform.hpp */, - 840DD5822AC810620006A435 /* Minecraft.cpp */, + 840DD5802AC810620006A435 /* AppPlatform.cpp */, + 84A2FF152DB5B7B70090CE3E /* AssetFile.hpp */, 840DD5832AC810620006A435 /* Minecraft.hpp */, - 840DD5842AC810620006A435 /* NinecraftApp.cpp */, + 840DD5822AC810620006A435 /* Minecraft.cpp */, 840DD5852AC810620006A435 /* NinecraftApp.hpp */, + 840DD5842AC810620006A435 /* NinecraftApp.cpp */, ); path = app; sourceTree = ""; @@ -2531,15 +2546,19 @@ 840DD61A2AC810620006A435 /* sound */ = { isa = PBXGroup; children = ( - 840DD61B2AC810620006A435 /* SoundData.cpp */, + 84A2FF172DB61D3A0090CE3E /* SoundPathRepository.hpp */, + 84A2FF192DB61D6D0090CE3E /* SoundPathRepository.cpp */, 840DD61C2AC810620006A435 /* SoundData.hpp */, + 840DD61B2AC810620006A435 /* SoundData.cpp */, 840DD61D2AC810620006A435 /* SoundDefs.hpp */, - 840DD61E2AC810620006A435 /* SoundEngine.cpp */, 840DD61F2AC810620006A435 /* SoundEngine.hpp */, - 840DD6202AC810620006A435 /* SoundRepository.cpp */, + 840DD61E2AC810620006A435 /* SoundEngine.cpp */, 840DD6212AC810620006A435 /* SoundRepository.hpp */, - 840DD6222AC810620006A435 /* SoundSystem.cpp */, + 840DD6202AC810620006A435 /* SoundRepository.cpp */, + 84A2FF1B2DB61F610090CE3E /* SoundStream.hpp */, + 84A2FF1D2DB61F690090CE3E /* SoundStream.cpp */, 840DD6232AC810620006A435 /* SoundSystem.hpp */, + 840DD6222AC810620006A435 /* SoundSystem.cpp */, ); path = sound; sourceTree = ""; @@ -3383,6 +3402,8 @@ isa = PBXGroup; children = ( 8441F9852DB4E911005977BD /* CustomSoundSystem.hpp */, + 8435BB172DCD47F400D38282 /* SoundStreamAL.hpp */, + 8435BB182DCD47F400D38282 /* SoundStreamAL.cpp */, 8441F9862DB4E911005977BD /* SoundSystemAL.cpp */, ); path = openal; @@ -4081,9 +4102,11 @@ 84AA8C232B32F3F3003F5B82 /* ItemInHandRenderer.hpp in Headers */, 84AA8C272B32F3F3003F5B82 /* LevelRenderer.hpp in Headers */, 84AA8C292B32F3F3003F5B82 /* LightLayer.hpp in Headers */, + 84A2FF182DB61D440090CE3E /* SoundPathRepository.hpp in Headers */, 84AA8C2B2B32F3F3003F5B82 /* LightUpdate.hpp in Headers */, 84AA8C2D2B32F3F3003F5B82 /* PatchManager.hpp in Headers */, 84AA8C2F2B32F3F3003F5B82 /* RenderChunk.hpp in Headers */, + 84A2FF162DB5B7B70090CE3E /* AssetFile.hpp in Headers */, 84AA8C312B32F3F3003F5B82 /* RenderList.hpp in Headers */, 84AA8C332B32F3F3003F5B82 /* Tesselator.hpp in Headers */, 84AA8C342B32F3F3003F5B82 /* Texture.hpp in Headers */, @@ -4092,6 +4115,7 @@ 84AA8C392B32F3F3003F5B82 /* VertexPT.hpp in Headers */, 84AA8C5B2B32F535003F5B82 /* ChickenModel.hpp in Headers */, 84AA8C5D2B32F535003F5B82 /* CowModel.hpp in Headers */, + 84A2FF1C2DB61F650090CE3E /* SoundStream.hpp in Headers */, 84AA8C5F2B32F535003F5B82 /* CreeperModel.hpp in Headers */, 84AA8C672B32F535003F5B82 /* ModelPart.hpp in Headers */, 84AA8C692B32F535003F5B82 /* PigModel.hpp in Headers */, @@ -4856,6 +4880,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 8435BB192DCD47F400D38282 /* SoundStreamAL.cpp in Sources */, 84EAE8F72AF1EAFA000894E8 /* main.cpp in Sources */, 841DD8772AF8AA7A00AA3B66 /* AppPlatform_sdl_base.cpp in Sources */, 841DD8782AF8AA7A00AA3B66 /* AppPlatform_sdl.cpp in Sources */, @@ -4877,6 +4902,7 @@ 8441F98F2DB4E911005977BD /* SoundSystemAL.cpp in Sources */, 84CEF0032AE3C97D006C5829 /* EAGLView.m in Sources */, 8495E4892AF0905B00A06901 /* AppPlatform_iOS.mm in Sources */, + 8435BB1A2DCD47F400D38282 /* SoundStreamAL.cpp in Sources */, 8488C08A2B1EDD4F001AEC4F /* ShowKeyboardView.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -4984,6 +5010,7 @@ 84AA8C182B32F3F3003F5B82 /* Font.cpp in Sources */, 84AA8C1A2B32F3F3003F5B82 /* Frustum.cpp in Sources */, 84AA8C1C2B32F3F3003F5B82 /* FrustumCuller.cpp in Sources */, + 84A2FF1A2DB61D720090CE3E /* SoundPathRepository.cpp in Sources */, 84AA8C1E2B32F3F3003F5B82 /* GameRenderer.cpp in Sources */, 84AA8C202B32F3F3003F5B82 /* GrassColor.cpp in Sources */, 84AA8C222B32F3F3003F5B82 /* ItemInHandRenderer.cpp in Sources */, @@ -4998,6 +5025,7 @@ 84AA8C302B32F3F3003F5B82 /* RenderList.cpp in Sources */, 84AA8C322B32F3F3003F5B82 /* Tesselator.cpp in Sources */, 84AA8C352B32F3F3003F5B82 /* Textures.cpp in Sources */, + 84A2FF1E2DB61F6C0090CE3E /* SoundStream.cpp in Sources */, 84AA8C372B32F3F3003F5B82 /* TileRenderer.cpp in Sources */, 84AA8C3A2B32F3F3003F5B82 /* WaterSideTexture.cpp in Sources */, 84AA8C3B2B32F3F3003F5B82 /* WaterTexture.cpp in Sources */, diff --git a/platforms/sdl/base/AppPlatform_sdl_base.cpp b/platforms/sdl/base/AppPlatform_sdl_base.cpp index aeeada144..dcbecc134 100644 --- a/platforms/sdl/base/AppPlatform_sdl_base.cpp +++ b/platforms/sdl/base/AppPlatform_sdl_base.cpp @@ -397,4 +397,31 @@ void AppPlatform_sdl_base::handleControllerAxisEvent(SDL_JoystickID controllerIn Controller::feedTrigger(2, val); break; } +} + +AssetFile AppPlatform_sdl_base::readAssetFile(const std::string& str, bool quiet) const +{ + std::string path = getAssetPath(str); + SDL_RWops *io = SDL_RWFromFile(path.c_str(), "rb"); + // Open File + if (!io) + { + if (!quiet) LOG_W("Couldn't find asset file: %s", path.c_str()); + return AssetFile(); + } + // Get File Size + int64_t size = SDL_RWsize(io); + if (size < 0) + { + if (!quiet) LOG_E("Error determining the size of the asset file!"); + SDL_RWclose(io); + return AssetFile(); + } + // Read Data + unsigned char *buf = new unsigned char[size]; + SDL_RWread(io, buf, size, 1); + // Close File + SDL_RWclose(io); + // Return + return AssetFile(size, buf); } \ No newline at end of file diff --git a/platforms/sdl/base/AppPlatform_sdl_base.hpp b/platforms/sdl/base/AppPlatform_sdl_base.hpp index 4e34e8285..7fe614cef 100644 --- a/platforms/sdl/base/AppPlatform_sdl_base.hpp +++ b/platforms/sdl/base/AppPlatform_sdl_base.hpp @@ -61,6 +61,9 @@ class AppPlatform_sdl_base : public AppPlatform void handleKeyEvent(int key, uint8_t state); void handleButtonEvent(SDL_JoystickID controllerIndex, uint8_t button, uint8_t state); void handleControllerAxisEvent(SDL_JoystickID controllerIndex, uint8_t axis, int16_t value); + + // Read Sounds + AssetFile readAssetFile(const std::string&, bool) const override; protected: SDL_Window *_window; private: diff --git a/platforms/sound/directsound/CustomSoundSystem.hpp b/platforms/sound/directsound/CustomSoundSystem.hpp index de50e210c..bac276636 100644 --- a/platforms/sound/directsound/CustomSoundSystem.hpp +++ b/platforms/sound/directsound/CustomSoundSystem.hpp @@ -29,15 +29,13 @@ class SoundSystemDS : public SoundSystem public: SoundSystemDS(); ~SoundSystemDS(); - virtual bool isAvailable(); - virtual void setListenerPos(float x, float y, float z); - virtual void setListenerAngle(float yaw, float pitch); - virtual void load(const std::string& sound); - virtual void play(const std::string& sound); - virtual void pause(const std::string& sound); - virtual void stop(const std::string& sound); - virtual void playAt(const SoundDesc& sound, float x, float y, float z, float a, float b); + virtual bool isAvailable() override; + virtual void setListenerPos(const Vec3& pos) override; + virtual void setListenerAngle(const Vec2& rot) override; + virtual void playAt(const SoundDesc& sound, const Vec3& pos, float volume, float pitch) override; private: + WAVEFORMATEX _getWaveFormat(const PCMSoundHeader& header, float pitch) const; + void _cleanSources(); struct BufferInfo { diff --git a/platforms/sound/directsound/SoundSystemDS.cpp b/platforms/sound/directsound/SoundSystemDS.cpp index a13a04241..26827c138 100644 --- a/platforms/sound/directsound/SoundSystemDS.cpp +++ b/platforms/sound/directsound/SoundSystemDS.cpp @@ -83,25 +83,25 @@ bool SoundSystemDS::isAvailable() return m_available; } -void SoundSystemDS::setListenerPos(float x, float y, float z) +void SoundSystemDS::setListenerPos(const Vec3& pos) { if (!isAvailable()) { return; } - m_listener->SetPosition(x, y, -z, DS3D_IMMEDIATE); + m_listener->SetPosition(pos.x, pos.y, -pos.z, DS3D_IMMEDIATE); } -void SoundSystemDS::setListenerAngle(float degyaw, float degpitch) +void SoundSystemDS::setListenerAngle(const Vec2& rot) { if (!isAvailable()) { return; } - float yaw = degyaw * M_PI / 180.f; - float pitch = degpitch * M_PI / 180.f; + float yaw = rot.x * M_PI / 180.f; + float pitch = rot.y * M_PI / 180.f; float lx = cosf(pitch) * sinf(yaw); float ly = -sinf(pitch); @@ -114,71 +114,29 @@ void SoundSystemDS::setListenerAngle(float degyaw, float degpitch) m_listener->SetOrientation(-lx,-ly,-lz, ux,uy,uz, DS3D_IMMEDIATE); } -void SoundSystemDS::load(const std::string& sound) +void SoundSystemDS::playAt(const SoundDesc& sound, const Vec3& pos, float volume, float pitch) { -} - -void SoundSystemDS::play(const std::string& sound) -{ -} - -void SoundSystemDS::pause(const std::string& sound) -{ -} - -void SoundSystemDS::stop(const std::string& sound) -{ -} - - -void SoundSystemDS::playAt(const SoundDesc& sound, float x, float y, float z, float volume, float pitch) -{ - //Directsound failed to initialize return to avoid crash. if (!isAvailable()) { + // DirectSound failed to initialize. Return to avoid crash. + assert(!"DirectSound is not initialized!"); return; } - //Release sounds that finished playing - for (size_t i = 0; i < m_buffers.size(); i++) - { - DWORD status; - m_buffers[i].buffer->GetStatus(&status); - if (status != DSBSTATUS_PLAYING) { - m_buffers[i].buffer->Release(); - if (m_buffers[i].object3d != NULL) - { - m_buffers[i].object3d->Release(); - } - m_buffers.erase(m_buffers.begin() + i); - i--; - } - } + // Release sounds that finished playing + _cleanSources(); HRESULT result; IDirectSoundBuffer* tempBuffer; unsigned char* bufferPtr; unsigned long bufferSize; - int length = sound.m_pHeader->m_length * sound.m_pHeader->m_bytes_per_sample; - bool is2D = sqrtf(x * x + y * y + z * z) == 0.f; - - //For some reason mojang made 3D sounds are REALLY quiet, with some of their volumes literally going below 0.1 - if (!is2D) - { - volume *= 5.f; - } + int length = sound.m_header.m_length * sound.m_header.m_bytes_per_sample; + bool is2D = pos.length() == 0.0f; LPDIRECTSOUNDBUFFER soundbuffer; //= (LPDIRECTSOUNDBUFFER*)calloc(1, sizeof(LPDIRECTSOUNDBUFFER)); - WAVEFORMATEX waveFormat; - waveFormat.wFormatTag = WAVE_FORMAT_PCM; - waveFormat.nSamplesPerSec = DWORD(float(sound.m_pHeader->m_sample_rate) * pitch); - waveFormat.wBitsPerSample = 8 * sound.m_pHeader->m_bytes_per_sample; - waveFormat.nChannels = sound.m_pHeader->m_channels; - waveFormat.nBlockAlign = (waveFormat.wBitsPerSample / 8) * waveFormat.nChannels; - waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAlign; - waveFormat.cbSize = 0; + WAVEFORMATEX waveFormat = _getWaveFormat(sound.m_header, pitch); // Set the buffer description of the secondary sound buffer that the wave file will be loaded onto. DSBUFFERDESC bufferDesc; @@ -230,7 +188,7 @@ void SoundSystemDS::playAt(const SoundDesc& sound, float x, float y, float z, fl } //Move the wave data into the buffer. - memcpy(bufferPtr, sound.m_pData, length); + memcpy(bufferPtr, sound.m_buffer.m_pData, length); // Unlock the secondary buffer after the data has been written to it. result = soundbuffer->Unlock((void*)bufferPtr, bufferSize, NULL, 0); @@ -245,12 +203,8 @@ void SoundSystemDS::playAt(const SoundDesc& sound, float x, float y, float z, fl // https://learn.microsoft.com/en-us/previous-versions/windows/desktop/mt708939(v=vs.85) // Conversion from 0-1 linear volume to directsound logarithmic volume.. // This seems to work for the most part, but accuracy testing should be done for actual MCPE, water splashing is pretty quiet. - float attenuation = volume;//Lerp(DSBVOLUME_MIN, DSBVOLUME_MAX, volume); // clamp the attenuation value - if (attenuation < 0.0f) - attenuation = 0.0f; - else if (attenuation > 1.0f) - attenuation = 1.0f; + float attenuation = Mth::clamp(volume, 0.0f, 1.0f);//Lerp(DSBVOLUME_MIN, DSBVOLUME_MAX, volume); if (attenuation == 0) { @@ -267,8 +221,8 @@ void SoundSystemDS::playAt(const SoundDesc& sound, float x, float y, float z, fl info.buffer = soundbuffer; info.object3d = NULL; - //Check if position is not 0,0,0 and for mono to play 3D sound - if (!is2D && sound.m_pHeader->m_channels == 1) + //Check if position is not 0,0,0 to play 3D sound + if (!is2D) { LPDIRECTSOUND3DBUFFER object3d; @@ -279,11 +233,7 @@ void SoundSystemDS::playAt(const SoundDesc& sound, float x, float y, float z, fl return; } - object3d->SetPosition( - x, - y, - -z, - DS3D_IMMEDIATE); + object3d->SetPosition(pos.x, pos.y, -pos.z, DS3D_IMMEDIATE); //Im not really sure what values original MCPE would use. object3d->SetMinDistance(2.f, DS3D_IMMEDIATE); @@ -295,4 +245,40 @@ void SoundSystemDS::playAt(const SoundDesc& sound, float x, float y, float z, fl soundbuffer->Play(0, 0, 0); m_buffers.push_back(info); -} \ No newline at end of file +} + +WAVEFORMATEX SoundSystemDS::_getWaveFormat(const PCMSoundHeader& header, float pitch) const +{ + WAVEFORMATEX wf; + + wf.wFormatTag = WAVE_FORMAT_PCM; + wf.nSamplesPerSec = DWORD(float(header.m_sample_rate) * pitch); + wf.wBitsPerSample = 8 * header.m_bytes_per_sample; + wf.nChannels = header.m_channels; + wf.nBlockAlign = (wf.wBitsPerSample / 8) * wf.nChannels; + wf.nAvgBytesPerSec = wf.nSamplesPerSec * wf.nBlockAlign; + wf.cbSize = 0; + + return wf; +} + +// Release sounds that finished playing +void SoundSystemDS::_cleanSources() +{ + for (size_t i = 0; i < m_buffers.size(); i++) + { + DWORD status; + m_buffers[i].buffer->GetStatus(&status); + if (status != DSBSTATUS_PLAYING) + { + m_buffers[i].buffer->Release(); + if (m_buffers[i].object3d != NULL) + { + m_buffers[i].object3d->Release(); + } + + m_buffers.erase(m_buffers.begin() + i); + i--; + } + } +} diff --git a/platforms/sound/openal/CMakeLists.txt b/platforms/sound/openal/CMakeLists.txt index 101c05f28..881769405 100644 --- a/platforms/sound/openal/CMakeLists.txt +++ b/platforms/sound/openal/CMakeLists.txt @@ -4,6 +4,7 @@ project(reminecraftpe-openal) # Build add_library(reminecraftpe-sound STATIC SoundSystemAL.cpp + SoundStreamAL.cpp ) # Core diff --git a/platforms/sound/openal/CustomSoundSystem.hpp b/platforms/sound/openal/CustomSoundSystem.hpp index 639566914..c00e01d6f 100644 --- a/platforms/sound/openal/CustomSoundSystem.hpp +++ b/platforms/sound/openal/CustomSoundSystem.hpp @@ -1,18 +1,6 @@ #pragma once -#ifdef __APPLE__ -#include -#include -#elif defined(__EMSCRIPTEN__) -#include -#include -#else -#include "al.h" -#include "alc.h" -#ifdef _WIN32 -#pragma comment( lib, "OpenAL32.lib" ) -#endif -#endif +#include "thirdparty/OpenAL.h" #include #include @@ -20,8 +8,9 @@ #include "client/sound/SoundSystem.hpp" #include "world/phys/Vec3.hpp" -#define MAX_IDLE_SOURCES 50 -#define MAX_DISTANCE 16.0f +#include "SoundStreamAL.hpp" + +//#define SS_AL_SOURCES 12 // 0.10.0 #define SOUND_SYSTEM SoundSystemAL @@ -30,28 +19,47 @@ class SoundSystemAL : public SoundSystem public: SoundSystemAL(); ~SoundSystemAL(); - virtual bool isAvailable(); - void update(); - virtual void playAt(const SoundDesc& sound, float x, float y, float z, float volume, float pitch); + virtual bool isAvailable() override; + virtual void setListenerPos(const Vec3& pos) override; + virtual void setListenerAngle(const Vec2& rot) override; + + virtual void setMusicVolume(float vol) override; + + virtual void playAt(const SoundDesc& sound, const Vec3& pos, float volume, float pitch) override; - virtual void setListenerPos(float x, float y, float z); - virtual void setListenerAngle(float yaw, float pitch); + virtual void playMusic(const std::string& soundPath) override; + virtual bool isPlayingMusic() const override; + virtual void stopMusic() override; + virtual void pauseMusic(bool state) override; - virtual void startEngine(); - virtual void stopEngine(); + virtual void update(float elapsedTime) override; + + virtual void startEngine() override; + virtual void stopEngine() override; private: - void delete_sources(); - void delete_buffers(); - ALuint get_buffer(const SoundDesc& sound); + bool _hasMaxSources() const; + ALuint _getIdleSource(); + ALuint _getSource(bool& isNew, bool tryClean = true); + void _deleteSources(); + void _cleanSources(); + ALuint _getBuffer(const SoundDesc& sound); + void _deleteBuffers(); + ALenum _getSoundFormat(const PCMSoundHeader& header) const; ALCdevice *_device; ALCcontext *_context; - bool _initialized; + + //ALuint m_sources[SS_AL_SOURCES]; // 0.10.0 std::vector _sources; std::vector _sources_idle; - std::map _buffers; + std::map _buffers; + SoundStreamAL* _musicStream; + + bool _initialized; + + float _mainVolume; - Vec3 _lastListenerPos; - float _listenerVolume; + Vec3 _listenerPos; + float _listenerYaw; }; diff --git a/platforms/sound/openal/SoundStreamAL.cpp b/platforms/sound/openal/SoundStreamAL.cpp new file mode 100644 index 000000000..b6848e0c5 --- /dev/null +++ b/platforms/sound/openal/SoundStreamAL.cpp @@ -0,0 +1,156 @@ +#include "SoundStreamAL.hpp" +#include +#include "common/Logger.hpp" + +SoundStreamAL::SoundStreamAL() + : SoundStream() +{ + _createSource(); + _createBuffers(); + _alFormat = AL_NONE; + + _setVolume(getVolume()); +} + +SoundStreamAL::~SoundStreamAL() +{ + _deleteSource(); + _deleteBuffers(); +} + +void SoundStreamAL::_deleteSource() +{ + alDeleteSources(1, &_source); + AL_ERROR_CHECK(); +} + +void SoundStreamAL::_createSource() +{ + alGenSources(1, &_source); +} + +void SoundStreamAL::_resetSource() +{ + alSourceStop(_source); + AL_ERROR_CHECK(); + alSourceRewind(_source); + AL_ERROR_CHECK(); + // Detach all of the buffers from the source + alSourcei(_source, AL_BUFFER, AL_NONE); + AL_ERROR_CHECK(); +} + +void SoundStreamAL::_deleteBuffers() +{ + alDeleteBuffers(_buffers.size(), _buffers.data()); + AL_ERROR_CHECK(); + + _buffers.clear(); + _bufferIdMap.clear(); +} + +void SoundStreamAL::_createBuffers() +{ + // Should not be called while buffers are already present + assert(_buffers.size() == 0); + + ALuint buffers[2]; + alGenBuffers(2, buffers); + for (int i = 0; i < sizeof(buffers) / sizeof(ALuint); i++) + { + _buffers.push_back(buffers[i]); + _bufferIdMap.insert(std::make_pair(buffers[i], i )); + } +} + +void SoundStreamAL::_resetBuffers() +{ + _deleteBuffers(); + _createBuffers(); +} + +void SoundStreamAL::_setVolume(float vol) +{ + alSourcef(_source, AL_GAIN, vol); + AL_ERROR_CHECK(); +} + +void SoundStreamAL::_play() +{ + alSourcePlay(_source); + AL_ERROR_CHECK(); +} + +void SoundStreamAL::_pause() +{ + alSourcePause(_source); + AL_ERROR_CHECK(); +} + +bool SoundStreamAL::_open(const std::string& fileName) +{ + if (m_info.channels == 2) _alFormat = AL_FORMAT_STEREO16; + else _alFormat = AL_FORMAT_MONO16; + + size_t size = _buffers.size(); + for (int i = 0; i < size; i++) + { + if (!_stream(i)) return false; + } + alSourceQueueBuffers(_source, size, _buffers.data()); + AL_ERROR_CHECK(); + _play(); + + return true; +} + +void SoundStreamAL::_close() +{ + _resetSource(); + //_resetBuffers(); + _alFormat = AL_NONE; +} + +void SoundStreamAL::_update() +{ + ALint processed = 0; + + alGetSourcei(_source, AL_BUFFERS_PROCESSED, &processed); + AL_ERROR_CHECK(); + + while (processed--) + { + ALuint buffer = 0; + + alSourceUnqueueBuffers(_source, 1, &buffer); + AL_ERROR_CHECK(); + + int bufferId = _bufferIdMap[buffer]; + + if (!_stream(bufferId)) + { + bool shouldExit = true; + + if (shouldLoop()) + { + stb_vorbis_seek_start(m_decoder); + m_totalSamplesLeft = stb_vorbis_stream_length_in_samples(m_decoder) * m_info.channels; + shouldExit = !_stream(bufferId); + } + + if (shouldExit) + { + close(); + return; + } + } + alSourceQueueBuffers(_source, 1, &buffer); + AL_ERROR_CHECK(); + } +} + +void SoundStreamAL::_publishBuffer(unsigned int destBufferId, const SoundBuffer& sourceBuffer) +{ + alBufferData(_buffers[destBufferId], _alFormat, sourceBuffer.m_pData, sourceBuffer.m_dataSize * sizeof(int16_t), m_info.sample_rate); + AL_ERROR_CHECK(); +} \ No newline at end of file diff --git a/platforms/sound/openal/SoundStreamAL.hpp b/platforms/sound/openal/SoundStreamAL.hpp new file mode 100644 index 000000000..287b8b2c6 --- /dev/null +++ b/platforms/sound/openal/SoundStreamAL.hpp @@ -0,0 +1,45 @@ +#pragma once + +#include +#include +#include + +#include "thirdparty/OpenAL.h" + +#include "client/sound/SoundStream.hpp" + +class SoundStreamAL : public SoundStream +{ +private: + typedef std::map BufferIdMap; + +private: + std::vector _buffers; + BufferIdMap _bufferIdMap; + + ALuint _source; + + ALenum _alFormat; + +public: + SoundStreamAL(); + ~SoundStreamAL(); + +private: + void _deleteSource(); + void _createSource(); + void _resetSource(); + + void _deleteBuffers(); + void _createBuffers(); + void _resetBuffers(); + +protected: + void _setVolume(float vol) override; + void _play() override; + void _pause() override; + bool _open(const std::string& fileName) override; + void _close() override; + void _update() override; + void _publishBuffer(unsigned int destBufferId, const SoundBuffer& sourceBuffer); +}; \ No newline at end of file diff --git a/platforms/sound/openal/SoundSystemAL.cpp b/platforms/sound/openal/SoundSystemAL.cpp index 21c48688f..56e134bf6 100644 --- a/platforms/sound/openal/SoundSystemAL.cpp +++ b/platforms/sound/openal/SoundSystemAL.cpp @@ -2,10 +2,17 @@ #include "common/Utils.hpp" +#include "SoundStreamAL.hpp" + SoundSystemAL::SoundSystemAL() { + _device = nullptr; + _context = nullptr; _initialized = false; - _listenerVolume = 1.0; + _musicStream = nullptr; + _mainVolume = 1.0f; + _listenerPos = Vec3::ZERO; + _listenerYaw = 0.0f; startEngine(); } @@ -15,20 +22,72 @@ SoundSystemAL::~SoundSystemAL() stopEngine(); } -// Error Checking -#define AL_ERROR_CHECK() AL_ERROR_CHECK_MANUAL(alGetError()) -#define AL_ERROR_CHECK_MANUAL(val) \ - { \ - ALenum __err = val; \ - if (__err != AL_NO_ERROR) \ - { \ - LOG_E("(%s:%i) OpenAL Error: %s", __FILE__, __LINE__, alGetString(__err)); \ - assert(!"An OpenAL error occurred!"); \ - } \ +bool SoundSystemAL::_hasMaxSources() const +{ + return _sources.size() + _sources_idle.size() >= SOUND_MAX_SOURCES; +} + +ALuint SoundSystemAL::_getIdleSource() +{ + ALuint al_source = AL_NONE; + + if (_sources_idle.size() > 0) + { + // Use Idle Source + al_source = _sources_idle.back(); + _sources_idle.pop_back(); + } + + return al_source; +} + +ALuint SoundSystemAL::_getSource(bool& isNew, bool tryClean) +{ + isNew = false; + ALuint al_source = _getIdleSource(); // Try to fetch pre-existing idle source + if (!al_source) + { + // Could not find pre-existing idle source + + if (_hasMaxSources()) + { + if (tryClean) + { + // Clean finished sources since no idle ones are available + _cleanSources(); + + // Did some cleaning, lets try again... + return _getSource(isNew, false); + } + else + { + // Too many sources already exist and they're all in-use, sucks to suck... + return AL_NONE; + } + } + + // Create Source + alGenSources(1, &al_source); + // Special Out-Of-Memory Handling + { + ALenum err = alGetError(); + if (err == AL_OUT_OF_MEMORY) + { + return AL_NONE; + } + else + { + AL_ERROR_CHECK_MANUAL(err); + } + } + isNew = true; } + return al_source; +} + // Delete Sources -void SoundSystemAL::delete_sources() +void SoundSystemAL::_deleteSources() { if (_initialized) { @@ -47,8 +106,75 @@ void SoundSystemAL::delete_sources() _sources.clear(); } +// Clear Finished Sources +void SoundSystemAL::_cleanSources() +{ + std::vector::iterator it = _sources.begin(); + while (it != _sources.end()) + { + ALuint source = *it; + bool remove = false; + // Check + if (source && alIsSource(source)) + { + // Is Valid Source + ALint source_state; + alGetSourcei(source, AL_SOURCE_STATE, &source_state); + AL_ERROR_CHECK(); + if (source_state != AL_PLAYING) + { + // Finished Playing + remove = true; + _sources_idle.push_back(source); + + // Reset playback state of source to prevent buffer ghosting on legacy Mac OS X and Windows. + // see: https://stackoverflow.com/questions/6960731/openal-problem-changing-gain-of-source + alSourceStop(source); + AL_ERROR_CHECK(); + alSourceRewind(source); + AL_ERROR_CHECK(); + } + } + else + { + // Not A Source + remove = true; + } + // Remove If Needed + if (remove) + { + it = _sources.erase(it); + } + else + { + ++it; + } + } +} + +// Get Buffer +ALuint SoundSystemAL::_getBuffer(const SoundDesc& sound) +{ + // Fetch pre-existing buffer + if (_buffers.count(sound.m_buffer.m_pData) > 0) + { + return _buffers[sound.m_buffer.m_pData]; + } + + // Create Buffer + ALuint buffer; + alGenBuffers(1, &buffer); + AL_ERROR_CHECK(); + alBufferData(buffer, _getSoundFormat(sound.m_header), sound.m_buffer.m_pData, sound.m_buffer.m_dataSize, sound.m_header.m_sample_rate); + AL_ERROR_CHECK(); + + // Store + _buffers[sound.m_buffer.m_pData] = buffer; + return buffer; +} + // Delete Buffers -void SoundSystemAL::delete_buffers() +void SoundSystemAL::_deleteBuffers() { if (_initialized) { @@ -65,39 +191,16 @@ void SoundSystemAL::delete_buffers() _buffers.clear(); } -// Get Buffer -ALuint SoundSystemAL::get_buffer(const SoundDesc& sound) +ALenum SoundSystemAL::_getSoundFormat(const PCMSoundHeader& header) const { - if (_buffers.count(sound.m_pData) > 0) - { - return _buffers[sound.m_pData]; - } - else + switch (header.m_channels) { - // Sound Format - ALenum format = AL_NONE; - if (sound.m_header.m_channels == 1) - { - format = sound.m_header.m_bytes_per_sample == 2 ? AL_FORMAT_MONO16 : AL_FORMAT_MONO8; - } - else if (sound.m_header.m_channels == 2) - { - format = sound.m_header.m_bytes_per_sample == 2 ? AL_FORMAT_STEREO16 : AL_FORMAT_STEREO8; - } - - // Sound Data Size - int size = sound.m_header.m_channels * sound.m_header.m_length * sound.m_header.m_bytes_per_sample; - - // Create Buffer - ALuint buffer; - alGenBuffers(1, &buffer); - AL_ERROR_CHECK(); - alBufferData(buffer, format, sound.m_pData, size, sound.m_header.m_sample_rate); - AL_ERROR_CHECK(); - - // Store - _buffers[sound.m_pData] = buffer; - return buffer; + case 1: + return header.m_bytes_per_sample == 2 ? AL_FORMAT_MONO16 : AL_FORMAT_MONO8; + case 2: + return header.m_bytes_per_sample == 2 ? AL_FORMAT_STEREO16 : AL_FORMAT_STEREO8; + default: + return AL_NONE; } } @@ -106,81 +209,43 @@ bool SoundSystemAL::isAvailable() return _initialized; } -void SoundSystemAL::setListenerPos(float x, float y, float z) +void SoundSystemAL::setListenerPos(const Vec3& pos) { + // Empty on iOS 0.10.0 + if (_listenerPos == pos) + return; // No need to waste time doing math and talking to OpenAL + // Update Listener Position - alListener3f(AL_POSITION, x, y, z); + alListener3f(AL_POSITION, pos.x, pos.y, pos.z); + AL_ERROR_CHECK(); + _listenerPos = pos; + + // Update Listener Volume + alListenerf(AL_GAIN, _mainVolume); AL_ERROR_CHECK(); - _lastListenerPos = Vec3(x, y, z); - update(); } -void SoundSystemAL::setListenerAngle(float yaw, float pitch) +void SoundSystemAL::setListenerAngle(const Vec2& rot) { + if (_listenerYaw == rot.x) + return; // No need to waste time doing math and talking to OpenAL + // Update Listener Orientation - float radian_yaw = yaw * (M_PI / 180); + float radian_yaw = rot.x * (M_PI / 180); ALfloat orientation[] = { -sinf(radian_yaw), 0.0f, cosf(radian_yaw), 0.0f, 1.0f, 0.0f }; alListenerfv(AL_ORIENTATION, orientation); AL_ERROR_CHECK(); + _listenerYaw = rot.x; } -void SoundSystemAL::update() +void SoundSystemAL::setMusicVolume(float vol) { - // Check - if (!_initialized) - { - return; - } - - // Update Listener Volume - alListenerf(AL_GAIN, _listenerVolume); - AL_ERROR_CHECK(); + assert(_musicStream != nullptr); - // Clear Finished Sources - std::vector::iterator it = _sources.begin(); - while (it != _sources.end()) - { - ALuint source = *it; - bool remove = false; - // Check - if (source && alIsSource(source)) - { - // Is Valid Source - ALint source_state; - alGetSourcei(source, AL_SOURCE_STATE, &source_state); - AL_ERROR_CHECK(); - if (source_state != AL_PLAYING) - { - // Finished Playing - remove = true; - if (_sources_idle.size() < MAX_IDLE_SOURCES) - { - _sources_idle.push_back(source); - } - else - { - alDeleteSources(1, &source); - AL_ERROR_CHECK(); - } - } - } - else - { - // Not A Source - remove = true; - } - // Remove If Needed - if (remove) { - it = _sources.erase(it); - } - else - { - ++it; - } - } + _musicStream->setVolume(vol); } -void SoundSystemAL::playAt(const SoundDesc& sound, float x, float y, float z, float volume, float pitch) +void SoundSystemAL::playAt(const SoundDesc& sound, const Vec3& pos, float volume, float pitch) { // Check if (!_initialized) @@ -193,71 +258,57 @@ void SoundSystemAL::playAt(const SoundDesc& sound, float x, float y, float z, fl bool bIsGUI = AL_FALSE; float distance = 0.0f; - if (x == 0 && y == 0 && z == 0) + if (pos == Vec3::ZERO) { bIsGUI = AL_TRUE; } - else - { - distance = Vec3(x, y, z).distanceTo(_lastListenerPos); - if (distance >= MAX_DISTANCE) - return; - } // Load Sound - ALuint buffer = get_buffer(sound); + ALuint buffer = _getBuffer(sound); if (!buffer) return; - + // Get Source - ALuint al_source; - if (_sources_idle.size() > 0) + bool isNew; + ALuint al_source = _getSource(isNew); + if (!al_source) { - // Use Idle Source - al_source = _sources_idle.back(); - _sources_idle.pop_back(); - } - else - { - // Create Source - alGenSources(1, &al_source); - // Special Out-Of-Memory Handling - { - ALenum err = alGetError(); - if (err == AL_OUT_OF_MEMORY) - { - return; - } - else - { - AL_ERROR_CHECK_MANUAL(err); - } - } + // Couldn't get a source, just give up. + return; } // Set Properties alSourcef(al_source, AL_PITCH, pitch); AL_ERROR_CHECK(); - // There is a problem with Apple's OpenAL implementation on older Mac OS X versions - // https://stackoverflow.com/questions/6960731/openal-problem-changing-gain-of-source alSourcef(al_source, AL_GAIN, volume); AL_ERROR_CHECK(); - alSource3f(al_source, AL_POSITION, x, y, z); - AL_ERROR_CHECK(); - alSource3f(al_source, AL_VELOCITY, 0, 0, 0); - AL_ERROR_CHECK(); - alSourcei(al_source, AL_LOOPING, AL_FALSE); + alSource3f(al_source, AL_POSITION, pos.x, pos.y, pos.z); AL_ERROR_CHECK(); alSourcei(al_source, AL_SOURCE_RELATIVE, bIsGUI); AL_ERROR_CHECK(); - // Set Attenuation - alSourcef(al_source, AL_MAX_DISTANCE, MAX_DISTANCE); - AL_ERROR_CHECK(); - alSourcef(al_source, AL_ROLLOFF_FACTOR, 1.0f); - AL_ERROR_CHECK(); - alSourcef(al_source, AL_REFERENCE_DISTANCE, 5.0f); - AL_ERROR_CHECK(); + // Only set constant parameters if source isn't reused + if (isNew) + { + // Set Attenuation + alSourcef(al_source, AL_MAX_DISTANCE, SOUND_MAX_DISTANCE); + AL_ERROR_CHECK(); + alSourcef(al_source, AL_ROLLOFF_FACTOR, 0.9f); // 0.9f is audibly on-par with b1.2_02's rolloff factor. So you probably shouldn't change it. 0.03f is default value for Paulscode. + AL_ERROR_CHECK(); + alSourcef(al_source, AL_REFERENCE_DISTANCE, 5.0f); // Sounds the same regardless of being set. Paulscode doesn't set this. + AL_ERROR_CHECK(); + + alSource3f(al_source, AL_VELOCITY, 0.0f, 0.0f, 0.0f); + AL_ERROR_CHECK(); + alSourcei(al_source, AL_LOOPING, AL_FALSE); + AL_ERROR_CHECK(); + } + else + { + // Detach all of the buffers from the source + alSourcei(al_source, AL_BUFFER, AL_NONE); + AL_ERROR_CHECK(); + } // Set Buffer alSourcei(al_source, AL_BUFFER, buffer); @@ -269,6 +320,31 @@ void SoundSystemAL::playAt(const SoundDesc& sound, float x, float y, float z, fl _sources.push_back(al_source); } +void SoundSystemAL::playMusic(const std::string& soundPath) +{ + _musicStream->open(soundPath); +} + +bool SoundSystemAL::isPlayingMusic() const +{ + return _musicStream->isPlaying(); +} + +void SoundSystemAL::stopMusic() +{ + _musicStream->close(); +} + +void SoundSystemAL::pauseMusic(bool state) +{ + _musicStream->setPausedState(state); +} + +void SoundSystemAL::update(float elapsedTime) +{ + _musicStream->update(); +} + void SoundSystemAL::startEngine() { if (_initialized) return; @@ -285,7 +361,7 @@ void SoundSystemAL::startEngine() ALCenum err = alcGetError(_device); if (err != ALC_NO_ERROR) { - LOG_E("Unable To Open Audio Context: %s", alcGetString(_device, err)); + LOG_E("Unable To Open Audio Context: %ss", alcGetString(_device, err)); return; } @@ -300,6 +376,29 @@ void SoundSystemAL::startEngine() // Set Distance Model alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED); + + // From 0.10.0 + /*alGenSources(SS_AL_SOURCES, m_sources); + for (int i = 0; i < SS_AL_SOURCES; i++) + { + ALuint sid = m_sources[i]; + alSourcef(sid, AL_REFERENCE_DISTANCE, 5.0f); + alSourcef(sid, AL_MAX_DISTANCE, SS_AL_MAX_DISTANCE); + alSourcef(sid, AL_ROLLOFF_FACTOR, 6.0f); + }*/ + + // From 0.10.0 + /*const ALfloat position[12] = {}; + alListenerfv(AL_POSITION, position); + AL_ERROR_CHECK(); + const ALfloat orientation[6] = { 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f }; + alListenerfv(AL_ORIENTATION, orientation); + AL_ERROR_CHECK(); + const ALfloat velocity[3] = { }; + alListenerfv(AL_VELOCITY, velocity); + AL_ERROR_CHECK();*/ + + _musicStream = new SoundStreamAL(); // Mark As loaded _initialized = true; @@ -308,12 +407,14 @@ void SoundSystemAL::startEngine() void SoundSystemAL::stopEngine() { if (!_initialized) return; + + delete _musicStream; // Delete Audio Sources - delete_sources(); + _deleteSources(); // Delete Audio Buffers - delete_buffers(); + _deleteBuffers(); // Deselect Context alcMakeContextCurrent(NULL); diff --git a/platforms/sound/opensl/CustomSoundSystem.hpp b/platforms/sound/opensl/CustomSoundSystem.hpp index f9e37e3da..e37141fa8 100644 --- a/platforms/sound/opensl/CustomSoundSystem.hpp +++ b/platforms/sound/opensl/CustomSoundSystem.hpp @@ -41,22 +41,16 @@ class SoundSystemSL : public SoundSystem void destroy(); bool checkErr(SLresult res); void removeStoppedSounds(); - void setListenerPos(float x, float y, float z) override; - void setListenerAngle(float yaw, float pitch) override; - void load(const std::string& sound) override; - void play(const std::string& sound) override; - void pause(const std::string& sound) override; - void stop(const std::string& sound) override; - void playAt(const SoundDesc& sound, float x, float y, float z, float volume, float pitch) override; + void setListenerPos(const Vec3& pos) override; + void setListenerAngle(const Vec2& rot) override; + void playAt(const SoundDesc& sound, const Vec3& pos, float volume, float pitch) override; static void removePlayer(SLAndroidSimpleBufferQueueItf caller, void* context); private: SLSoundList m_playingSounds; SLEngineItf m_slEngine; SL3DLocationItf m_3dLocationItf; SLObjectItf m_slOutputMix; - float m_listenerX; - float m_listenerY; - float m_listenerZ; + Vec3 m_listenerPos; int m_soundCount; bool m_bAvailable; std::vector m_tempToRemove; diff --git a/platforms/sound/opensl/SoundSystemSL.cpp b/platforms/sound/opensl/SoundSystemSL.cpp index fcfca14da..bc3deaecc 100644 --- a/platforms/sound/opensl/SoundSystemSL.cpp +++ b/platforms/sound/opensl/SoundSystemSL.cpp @@ -17,9 +17,7 @@ pthread_mutex_t SoundSystemSL::toRemoveMutex; SoundSystemSL::SoundSystemSL() { - m_listenerX = 0.0f; - m_listenerY = 0.0f; - m_listenerZ = 0.0f; + m_listenerPos = Vec3::ZERO; m_soundCount = 0; m_3dLocationItf = nullptr; m_bAvailable = true; @@ -113,40 +111,38 @@ void SoundSystemSL::removeStoppedSounds() } -void SoundSystemSL::setListenerPos(float x, float y, float z) +void SoundSystemSL::setListenerPos(const Vec3& pos) { if (!m_3dLocationItf) { - m_listenerX = x; - m_listenerY = y; - m_listenerZ = z; + m_listenerPos = pos; return; } SLVec3D vec; - vec.x = int(1000.0f * x); - vec.y = int(1000.0f * y); - vec.z = int(1000.0f * z); + vec.x = int(1000.0f * pos.x); + vec.y = int(1000.0f * pos.y); + vec.z = int(1000.0f * pos.z); checkErr((*m_3dLocationItf)->SetLocationCartesian( m_3dLocationItf, &vec )); } -void SoundSystemSL::setListenerAngle(float yaw, float pitch) +void SoundSystemSL::setListenerAngle(const Vec2& rot) { if (!m_3dLocationItf) return; checkErr((*m_3dLocationItf)->SetOrientationAngles( m_3dLocationItf, - int(180000.0f * yaw), + int(180000.0f * rot.x), 0, 0 )); } -void SoundSystemSL::playAt(const SoundDesc &sound, float x, float y, float z, float volume, float pitch) +void SoundSystemSL::playAt(const SoundDesc &sound, const Vec3& pos, float volume, float pitch) { removeStoppedSounds(); @@ -206,7 +202,7 @@ void SoundSystemSL::playAt(const SoundDesc &sound, float x, float y, float z, fl checkErr((*pVolumeItf)->SetVolumeLevel(pVolumeItf, remappedVolume)); checkErr((*pAudioPlayer)->GetInterface(pAudioPlayer, SL_IID_BUFFERQUEUE, &pBufferQueueItf)); checkErr((*pBufferQueueItf)->RegisterCallback(pBufferQueueItf, removePlayer, (void*) pAudioPlayer)); - checkErr((*pBufferQueueItf)->Enqueue(pBufferQueueItf, sound.m_pData, sound.field_4)); + checkErr((*pBufferQueueItf)->Enqueue(pBufferQueueItf, sound.m_buffer.m_pData, sound.m_buffer.m_dataSize)); checkErr((*pPlayItf)->SetPlayState(pPlayItf, SL_PLAYSTATE_PLAYING)); m_playingSounds.push_back(pAudioPlayer); @@ -218,24 +214,3 @@ void SoundSystemSL::destroy() { } - -void SoundSystemSL::load(const std::string &sound) -{ - -} - -void SoundSystemSL::play(const std::string &sound) -{ - -} - -void SoundSystemSL::pause(const std::string &sound) -{ - -} - -void SoundSystemSL::stop(const std::string &sound) -{ - -} - diff --git a/platforms/windows/AppPlatform_win32.cpp b/platforms/windows/AppPlatform_win32.cpp index bde51080a..1ce44ea7e 100644 --- a/platforms/windows/AppPlatform_win32.cpp +++ b/platforms/windows/AppPlatform_win32.cpp @@ -207,16 +207,20 @@ bool AppPlatform_win32::hasFileSystemAccess() return true; } -std::string AppPlatform_win32::getPatchData() +AssetFile AppPlatform_win32::readAssetFile(const std::string& str, bool quiet) const { - std::ifstream ifs("assets/patches/patch_data.txt"); + std::string path = getAssetPath(str); + std::ifstream ifs(path, std::ios::binary | std::ios::ate); if (!ifs.is_open()) - return ""; + return AssetFile(); - std::stringstream ss; - ss << ifs.rdbuf(); + std::streamsize size = ifs.tellg(); + ifs.seekg(0, std::ios::beg); - return ss.str(); + unsigned char* buffer = new unsigned char[size]; + ifs.read((char*) buffer, size); + + return AssetFile(size, buffer); } void AppPlatform_win32::setScreenSize(int width, int height) diff --git a/platforms/windows/AppPlatform_win32.hpp b/platforms/windows/AppPlatform_win32.hpp index 76323b8b9..bc681df00 100644 --- a/platforms/windows/AppPlatform_win32.hpp +++ b/platforms/windows/AppPlatform_win32.hpp @@ -55,7 +55,7 @@ class AppPlatform_win32 : public AppPlatform bool hasFileSystemAccess() override; // Also add this to allow dynamic texture patching. - std::string getPatchData() override; + AssetFile readAssetFile(const std::string&, bool) const override; void setScreenSize(int width, int height); const char* const getWindowTitle() const { return m_WindowTitle; } diff --git a/platforms/windows/minecraftcpp.sln b/platforms/windows/minecraftcpp.sln index f66764d3e..2fa8f435f 100644 --- a/platforms/windows/minecraftcpp.sln +++ b/platforms/windows/minecraftcpp.sln @@ -1,6 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio Version 10 +# Visual Studio Version 17 VisualStudioVersion = 17.6.33723.286 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZLib", "projects\ZLib\ZLib.vcxproj", "{5DA292FD-FA40-45D8-900A-6652C9662913}" @@ -27,6 +27,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Renderer", "projects\Render EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenGL", "projects\OpenGL\OpenGL.vcxproj", "{2E1A5B55-A6D4-4743-A63A-4F27DB03C0A1}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "STB", "projects\STB\STB.vcxproj", "{F332CB57-FF16-4D43-BBE0-76F28301DAA8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug_SDL2|x64 = Debug_SDL2|x64 @@ -203,6 +205,22 @@ Global {2E1A5B55-A6D4-4743-A63A-4F27DB03C0A1}.Release|x64.Build.0 = Release|x64 {2E1A5B55-A6D4-4743-A63A-4F27DB03C0A1}.Release|x86.ActiveCfg = Release|Win32 {2E1A5B55-A6D4-4743-A63A-4F27DB03C0A1}.Release|x86.Build.0 = Release|Win32 + {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Debug_SDL2|x64.ActiveCfg = Debug|x64 + {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Debug_SDL2|x64.Build.0 = Debug|x64 + {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Debug_SDL2|x86.ActiveCfg = Debug|Win32 + {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Debug_SDL2|x86.Build.0 = Debug|Win32 + {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Debug|x64.ActiveCfg = Debug|x64 + {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Debug|x64.Build.0 = Debug|x64 + {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Debug|x86.ActiveCfg = Debug|Win32 + {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Debug|x86.Build.0 = Debug|Win32 + {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Release_SDL2|x64.ActiveCfg = Release|x64 + {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Release_SDL2|x64.Build.0 = Release|x64 + {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Release_SDL2|x86.ActiveCfg = Release|Win32 + {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Release_SDL2|x86.Build.0 = Release|Win32 + {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Release|x64.ActiveCfg = Release|x64 + {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Release|x64.Build.0 = Release|x64 + {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Release|x86.ActiveCfg = Release|Win32 + {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -212,6 +230,7 @@ Global {4B7FCC5F-7E38-4934-B272-2F5BBEF51013} = {3274DB20-9315-418F-8634-A4203E0436C2} {A88F87B0-D37B-4385-A870-F349D8001E08} = {3274DB20-9315-418F-8634-A4203E0436C2} {2E1A5B55-A6D4-4743-A63A-4F27DB03C0A1} = {3274DB20-9315-418F-8634-A4203E0436C2} + {F332CB57-FF16-4D43-BBE0-76F28301DAA8} = {3274DB20-9315-418F-8634-A4203E0436C2} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {469E02FA-FBC4-419C-8EA0-3055EE0AD3AC} diff --git a/platforms/windows/projects/Client/Client.vcxproj b/platforms/windows/projects/Client/Client.vcxproj index cdfbbd235..aa82f51dd 100644 --- a/platforms/windows/projects/Client/Client.vcxproj +++ b/platforms/windows/projects/Client/Client.vcxproj @@ -129,11 +129,13 @@ + + @@ -176,6 +178,8 @@ + + @@ -257,10 +261,12 @@ + + @@ -308,6 +314,9 @@ {e43f7c6a-a099-48c9-9d37-b56cd8d6d785} + + {f332cb57-ff16-4d43-bbe0-76f28301daa8} + diff --git a/platforms/windows/projects/Client/Client.vcxproj.filters b/platforms/windows/projects/Client/Client.vcxproj.filters index e234a075c..d83f97e7f 100644 --- a/platforms/windows/projects/Client/Client.vcxproj.filters +++ b/platforms/windows/projects/Client/Client.vcxproj.filters @@ -1,4 +1,4 @@ - + @@ -284,6 +284,9 @@ Header Files\Renderer + + Header Files\Sound + Header Files\Sound @@ -296,6 +299,9 @@ Header Files\Sound + + Header Files\Sound + Header Files\Sound @@ -455,6 +461,12 @@ Header Files\Player\Input + + Header Files\Sound + + + Header Files\Sound + @@ -664,6 +676,9 @@ Source Files\Renderer + + Source Files\Sound + Source Files\Sound @@ -673,6 +688,9 @@ Source Files\Sound + + Source Files\Sound + Source Files\Sound diff --git a/platforms/windows/projects/MinecraftClient.SDL2/MinecraftClient.SDL2.vcxproj b/platforms/windows/projects/MinecraftClient.SDL2/MinecraftClient.SDL2.vcxproj index 46f98edb0..1be42c37d 100644 --- a/platforms/windows/projects/MinecraftClient.SDL2/MinecraftClient.SDL2.vcxproj +++ b/platforms/windows/projects/MinecraftClient.SDL2/MinecraftClient.SDL2.vcxproj @@ -37,7 +37,7 @@ - $(MC_ROOT)\platforms\openal;$(MC_ROOT)\thirdparty\stb_image\include;$(SDL2_PATH)\include;$(LIBPNG_PATH);$(OPENAL_PATH)\include;%(AdditionalIncludeDirectories) + $(MC_ROOT)\platforms\sound\openal;$(MC_ROOT)\thirdparty\stb_image\include;$(SDL2_PATH)\include;$(LIBPNG_PATH);$(OPENAL_PATH)\include;%(AdditionalIncludeDirectories) Console @@ -61,18 +61,20 @@ - + + - + + diff --git a/platforms/windows/projects/MinecraftClient.SDL2/MinecraftClient.SDL2.vcxproj.filters b/platforms/windows/projects/MinecraftClient.SDL2/MinecraftClient.SDL2.vcxproj.filters index 0c2cb9f2a..f60c21af6 100644 --- a/platforms/windows/projects/MinecraftClient.SDL2/MinecraftClient.SDL2.vcxproj.filters +++ b/platforms/windows/projects/MinecraftClient.SDL2/MinecraftClient.SDL2.vcxproj.filters @@ -24,7 +24,7 @@ Source Files - + Source Files @@ -33,6 +33,9 @@ Source Files + + Source Files + @@ -41,7 +44,7 @@ Header Files\Compatibility - + Header Files @@ -50,5 +53,8 @@ Header Files + + Header Files + \ No newline at end of file diff --git a/platforms/windows/projects/STB/STB.vcxproj b/platforms/windows/projects/STB/STB.vcxproj new file mode 100644 index 000000000..a02a47c8e --- /dev/null +++ b/platforms/windows/projects/STB/STB.vcxproj @@ -0,0 +1,67 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {f332cb57-ff16-4d43-bbe0-76f28301daa8} + STB + STB + StaticLibrary + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/platforms/windows/projects/STB/STB.vcxproj.filters b/platforms/windows/projects/STB/STB.vcxproj.filters new file mode 100644 index 000000000..1718ea326 --- /dev/null +++ b/platforms/windows/projects/STB/STB.vcxproj.filters @@ -0,0 +1,78 @@ + + + + + {e505ae8a-bc6d-4cc0-a25d-232a1d2f5fcf} + + + {979d09b3-8d66-4441-ad0b-c9a1759c617f} + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Header Files + + + \ No newline at end of file diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index e08f8101e..f4a6ab7c0 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -63,6 +63,8 @@ add_library(reminecraftpe-core STATIC client/renderer/FoliageColor.cpp client/renderer/GrassColor.cpp client/sound/SoundData.cpp + client/sound/SoundPathRepository.cpp + client/sound/SoundStream.cpp client/sound/SoundSystem.cpp client/sound/SoundRepository.cpp client/sound/SoundEngine.cpp @@ -186,16 +188,16 @@ add_library(reminecraftpe-core STATIC world/entity/Monster.cpp world/entity/Rocket.cpp world/entity/MobFactory.cpp - world/entity/Chicken.cpp - world/entity/Cow.cpp - world/entity/Creeper.cpp - world/entity/Pig.cpp - world/entity/Sheep.cpp - world/entity/SynchedEntityData.cpp - world/entity/EntityCategories.cpp - world/entity/EntityType.cpp - world/entity/EntityTypeDescriptor.cpp - world/entity/MobCategory.cpp + world/entity/Chicken.cpp + world/entity/Cow.cpp + world/entity/Creeper.cpp + world/entity/Pig.cpp + world/entity/Sheep.cpp + world/entity/SynchedEntityData.cpp + world/entity/EntityCategories.cpp + world/entity/EntityType.cpp + world/entity/EntityTypeDescriptor.cpp + world/entity/MobCategory.cpp world/level/Dimension.cpp world/level/Material.cpp world/level/LevelListener.cpp @@ -322,15 +324,6 @@ else() target_link_libraries(zlib-interface INTERFACE ZLIB::ZLIB) endif() target_link_libraries(reminecraftpe-core PUBLIC zlib-interface) - -# Sound Data -if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../sound_data/sounds.h") - if(NOT DEFINED ENV{CI}) - message(WARNING "Missing sound data! Did you run tools/grabsounds.py?") - endif() - target_compile_definitions(reminecraftpe-core PRIVATE MISSING_SOUND_DATA) -endif() - # OpenGL Support Code if(WIN32) target_sources(reminecraftpe-core PRIVATE ../thirdparty/GL/GLExt.cpp) diff --git a/source/client/app/AppPlatform.cpp b/source/client/app/AppPlatform.cpp index b90592c86..08fa245a1 100644 --- a/source/client/app/AppPlatform.cpp +++ b/source/client/app/AppPlatform.cpp @@ -226,7 +226,15 @@ bool AppPlatform::hasFileSystemAccess() std::string AppPlatform::getPatchData() { - return ""; + const AssetFile file = readAssetFile("patches/patch_data.txt", false); + std::string out = std::string(file.data, file.data + file.size); + delete file.data; + return out; +} + +AssetFile AppPlatform::readAssetFile(const std::string& path, bool quiet) const +{ + return AssetFile(); } void AppPlatform::initSoundSystem() diff --git a/source/client/app/AppPlatform.hpp b/source/client/app/AppPlatform.hpp index 51ddc7945..0a03bfea2 100644 --- a/source/client/app/AppPlatform.hpp +++ b/source/client/app/AppPlatform.hpp @@ -13,6 +13,7 @@ #include "client/renderer/Texture.hpp" #include "client/sound/SoundSystem.hpp" +#include "AssetFile.hpp" class AppPlatform { @@ -86,6 +87,8 @@ class AppPlatform virtual std::string getPatchData(); virtual void initSoundSystem(); virtual SoundSystem* const getSoundSystem() const; + // Used For Sounds + virtual AssetFile readAssetFile(const std::string&, bool) const; #endif public: diff --git a/source/client/app/AssetFile.hpp b/source/client/app/AssetFile.hpp new file mode 100644 index 000000000..b0f2c0316 --- /dev/null +++ b/source/client/app/AssetFile.hpp @@ -0,0 +1,19 @@ +/******************************************************************** +Minecraft: Pocket Edition - Decompilation Project + Copyright (C) 2023 iProgramInCpp + + The following code is licensed under the BSD 1 clause license. + SPDX-License-Identifier: BSD-1-Clause + ********************************************************************/ + +#pragma once + +#include + +struct AssetFile { + int64_t size; + unsigned char *data; + + AssetFile(): size(-1), data(nullptr) {} + AssetFile(int64_t size, unsigned char *data): size(size), data(data) {} +}; \ No newline at end of file diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp index e0f5817b9..fbd16a5ef 100644 --- a/source/client/app/Minecraft.cpp +++ b/source/client/app/Minecraft.cpp @@ -734,13 +734,8 @@ void Minecraft::tick() m_pParticleEngine->tick(); #ifndef ORIGINAL_CODE - if (m_pMobPersp) - { - m_pSoundEngine->m_pSoundSystem->setListenerPos(m_pMobPersp->m_pos.x, m_pMobPersp->m_pos.y, m_pMobPersp->m_pos.z); - m_pSoundEngine->m_pSoundSystem->setListenerAngle(m_pMobPersp->m_rot.x, m_pMobPersp->m_rot.y); - } + m_pSoundEngine->update(m_pMobPersp, m_timer.m_renderTicks); #endif - } if (m_pScreen) @@ -837,8 +832,8 @@ void Minecraft::init() GetPatchManager()->PatchTiles(); - m_pSoundEngine = new SoundEngine(platform()->getSoundSystem()); - m_pSoundEngine->init(m_options); + m_pSoundEngine = new SoundEngine(platform()->getSoundSystem(), 20.0f); // 20.0f on 0.7.0 + m_pSoundEngine->init(m_options, platform()); m_pLevelRenderer = new LevelRenderer(this, m_pTextures); m_pGameRenderer = new GameRenderer(this); @@ -866,6 +861,7 @@ Minecraft::~Minecraft() SAFE_DELETE(m_pLevelRenderer); SAFE_DELETE(m_pGameRenderer); SAFE_DELETE(m_pParticleEngine); + m_pSoundEngine->destroy(); SAFE_DELETE(m_pSoundEngine); SAFE_DELETE(m_pGameMode); SAFE_DELETE(m_pFont); diff --git a/source/client/gui/Gui.cpp b/source/client/gui/Gui.cpp index 148a270fa..8f9a7a9fb 100644 --- a/source/client/gui/Gui.cpp +++ b/source/client/gui/Gui.cpp @@ -288,9 +288,9 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY) int emptyHeartX = 16; bool b1 = false; - if (player->field_B8 < 10) + if (player->m_invulnerableTime < 10) { - b1 = player->field_B8 / 3 % 2; + b1 = player->m_invulnerableTime / 3 % 2; emptyHeartX += 9 * b1; } @@ -318,9 +318,9 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY) if (b1) { - if (healthNo < player->field_100) + if (healthNo < player->m_lastHealth) blit(heartX, heartY, 70, 0, 9, 9, 0, 0); - else if (healthNo == player->field_100) + else if (healthNo == player->m_lastHealth) blit(heartX, heartY, 79, 0, 9, 9, 0, 0); } diff --git a/source/client/gui/Screen.cpp b/source/client/gui/Screen.cpp index 99e7cb4b0..aeb233a2e 100644 --- a/source/client/gui/Screen.cpp +++ b/source/client/gui/Screen.cpp @@ -63,7 +63,7 @@ void Screen::keyPressed(int key) { if (m_buttonTabList[m_tabButtonIndex]->m_bEnabled) { - m_pMinecraft->m_pSoundEngine->play("random.click"); + m_pMinecraft->m_pSoundEngine->playUI("random.click"); buttonClicked(m_buttonTabList[m_tabButtonIndex]); } } @@ -210,7 +210,7 @@ void Screen::mouseClicked(int xPos, int yPos, int d) // d = clicked? if (!m_pMinecraft->isTouchscreen()) { - m_pMinecraft->m_pSoundEngine->play("random.click"); + m_pMinecraft->m_pSoundEngine->playUI("random.click"); buttonClicked(button); } } @@ -264,7 +264,7 @@ void Screen::mouseReleased(int xPos, int yPos, int d) { if (m_pMinecraft->isTouchscreen() && m_pClickedButton->clicked(m_pMinecraft, xPos, yPos)) { - m_pMinecraft->m_pSoundEngine->play("random.click"); + m_pMinecraft->m_pSoundEngine->playUI("random.click"); buttonClicked(m_pClickedButton); } m_pClickedButton->released(xPos, yPos); diff --git a/source/client/gui/screens/IngameBlockSelectionScreen.cpp b/source/client/gui/screens/IngameBlockSelectionScreen.cpp index 6fc7d4449..9af461270 100644 --- a/source/client/gui/screens/IngameBlockSelectionScreen.cpp +++ b/source/client/gui/screens/IngameBlockSelectionScreen.cpp @@ -201,6 +201,6 @@ void IngameBlockSelectionScreen::selectSlotAndClose() pInv->selectItem(m_selectedSlot, m_pMinecraft->m_gui.getNumUsableSlots()); - m_pMinecraft->m_pSoundEngine->play("random.click"); + m_pMinecraft->m_pSoundEngine->playUI("random.click"); m_pMinecraft->setScreen(nullptr); } diff --git a/source/client/options/Options.cpp b/source/client/options/Options.cpp index 57a43ca1e..e863d74ef 100644 --- a/source/client/options/Options.cpp +++ b/source/client/options/Options.cpp @@ -38,7 +38,7 @@ void Options::_initDefaultValues() m_bDontRenderGui = false; field_248 = 1.0f; m_bThirdPerson = false; - field_0 = 1.0f; + m_fMusicVolume = 1.0f; field_23E = 0; m_fMasterVolume = 1.0f; m_bFlyCheat = false; diff --git a/source/client/options/Options.hpp b/source/client/options/Options.hpp index 6bb24c7db..7dfe9fbcf 100644 --- a/source/client/options/Options.hpp +++ b/source/client/options/Options.hpp @@ -95,7 +95,7 @@ class Options KeyMapping m_keyMappings[KM_COUNT]; public: - float field_0; + float m_fMusicVolume; float m_fMasterVolume; float m_fSensitivity; bool m_bInvertMouse; diff --git a/source/client/renderer/GameRenderer.cpp b/source/client/renderer/GameRenderer.cpp index ff7e3170a..e6b1afddd 100644 --- a/source/client/renderer/GameRenderer.cpp +++ b/source/client/renderer/GameRenderer.cpp @@ -200,8 +200,8 @@ void GameRenderer::moveCameraToPlayer(float f) if (!m_pMinecraft->getOptions()->field_241) { - glRotatef(pMob->m_rotPrev.y + f * (pMob->m_rot.y - pMob->m_rotPrev.y), 1.0f, 0.0f, 0.0f); - glRotatef(pMob->m_rotPrev.x + f * (pMob->m_rot.x - pMob->m_rotPrev.x) + 180.0f, 0.0f, 1.0f, 0.0f); + glRotatef(pMob->m_oRot.y + f * (pMob->m_rot.y - pMob->m_oRot.y), 1.0f, 0.0f, 0.0f); + glRotatef(pMob->m_oRot.x + f * (pMob->m_rot.x - pMob->m_oRot.x) + 180.0f, 0.0f, 1.0f, 0.0f); } glTranslatef(0.0f, headHeightDiff, 0.0f); diff --git a/source/client/renderer/ItemInHandRenderer.cpp b/source/client/renderer/ItemInHandRenderer.cpp index 0c9c0b0b5..98c77ba81 100644 --- a/source/client/renderer/ItemInHandRenderer.cpp +++ b/source/client/renderer/ItemInHandRenderer.cpp @@ -170,8 +170,8 @@ void ItemInHandRenderer::render(float f) float h = m_oHeight + (m_height - m_oHeight) * f; glPushMatrix(); - glRotatef(pLP->m_rotPrev.y + (pLP->m_rot.y - pLP->m_rotPrev.y) * f, 1.0f, 0.0f, 0.0f); - glRotatef(pLP->m_rotPrev.x + (pLP->m_rot.x - pLP->m_rotPrev.x) * f, 0.0f, 1.0f, 0.0f); + glRotatef(pLP->m_oRot.y + (pLP->m_rot.y - pLP->m_oRot.y) * f, 1.0f, 0.0f, 0.0f); + glRotatef(pLP->m_oRot.x + (pLP->m_rot.x - pLP->m_oRot.x) * f, 0.0f, 1.0f, 0.0f); Lighting::turnOn(); // must be called before glPopMatrix() glPopMatrix(); diff --git a/source/client/renderer/entity/EntityRenderDispatcher.cpp b/source/client/renderer/entity/EntityRenderDispatcher.cpp index ae3ef15c8..d7d18a29d 100644 --- a/source/client/renderer/entity/EntityRenderDispatcher.cpp +++ b/source/client/renderer/entity/EntityRenderDispatcher.cpp @@ -127,14 +127,14 @@ void EntityRenderDispatcher::prepare(Level* level, Textures* textures, Font* fon m_pMob = mob; m_pFont = font; m_pOptions = options; - m_rot = mob->m_rotPrev + (mob->m_rot - mob->m_rotPrev) * f; + m_rot = mob->m_oRot + (mob->m_rot - mob->m_oRot) * f; m_pos = mob->m_posPrev + (mob->m_pos - mob->m_posPrev) * f; } void EntityRenderDispatcher::render(Entity* entity, float a) { Vec3 pos = Vec3(entity->m_posPrev + (entity->m_pos - entity->m_posPrev) * a); - float yaw = entity->m_rotPrev.x + a * (entity->m_rot.x - entity->m_rotPrev.x); + float yaw = entity->m_oRot.x + a * (entity->m_rot.x - entity->m_oRot.x); float bright = entity->getBrightness(1.0f); glColor4f(bright, bright, bright, 1.0f); diff --git a/source/client/renderer/entity/MobRenderer.cpp b/source/client/renderer/entity/MobRenderer.cpp index d5b3fde6c..36cf254b5 100644 --- a/source/client/renderer/entity/MobRenderer.cpp +++ b/source/client/renderer/entity/MobRenderer.cpp @@ -95,8 +95,8 @@ void MobRenderer::render(Entity* entity, float x, float y, float z, float unused m_pArmorModel->m_bIsBaby = m_pModel->m_bIsBaby; } - float aYaw = pMob->m_rotPrev.x + (pMob->m_rot.x - pMob->m_rotPrev.x) * f; - float aPitch = pMob->m_rotPrev.y + (pMob->m_rot.y - pMob->m_rotPrev.y) * f; + float aYaw = pMob->m_oRot.x + (pMob->m_rot.x - pMob->m_oRot.x) * f; + float aPitch = pMob->m_oRot.y + (pMob->m_rot.y - pMob->m_oRot.y) * f; float fBob = getBob(pMob, f); float fSmth = pMob->field_EC + (pMob->field_E8 - pMob->field_EC) * f; @@ -109,10 +109,10 @@ void MobRenderer::render(Entity* entity, float x, float y, float z, float unused //glTranslatef(0.0f, -1.5078f, 0.0f); glTranslatef(0.0f, -24.0f * fScale - (1.0f / 128.0f), 0.0f); - float x1 = pMob->field_128 + (pMob->field_12C - pMob->field_128) * f; + float x1 = pMob->field_128 + (pMob->m_walkAnimSpeed - pMob->field_128) * f; if (x1 > 1.0f) x1 = 1.0f; - float x2 = pMob->field_130 - pMob->field_12C * (1.0f - f); + float x2 = pMob->field_130 - pMob->m_walkAnimSpeed * (1.0f - f); bindTexture(pMob->getTexture()); glEnable(GL_ALPHA_TEST); diff --git a/source/client/sound/SoundData.cpp b/source/client/sound/SoundData.cpp index c1cabd486..823642efd 100644 --- a/source/client/sound/SoundData.cpp +++ b/source/client/sound/SoundData.cpp @@ -6,15 +6,122 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ +#define STB_VORBIS_HEADER_ONLY +#include "thirdparty/stb_image/include/stb_vorbis.c" + #include "SoundData.hpp" -// -------------------------------------------------------------------- -// WARNING! If you have an error here it is most likely because you did -// not grab the sound data from a working Minecraft PE 0.1.3 .apk. -// -// Check the readme for a guide on how to extract game sounds from the -// Minecraft PE 0.1.3 .apk file. -// -------------------------------------------------------------------- -#ifndef MISSING_SOUND_DATA -#include "../../sound_data/sounds.h" -#endif +#include "client/app/AppPlatform.hpp" + +std::string SoundDesc::dirs[] = { + "sound", + "newsound", + "sound3" +}; + +bool SoundDesc::_load(const AppPlatform* platform, const char* category, const char *name) +{ + if (m_isLoaded) + { + // Already Loaded + LOG_W("Sound \"%s\" is already loaded!", name); + return true; + } + + // Load + if (_loadOgg(platform, category, name) || _loadPcm(platform, name)) + { + // Success! + return true; + } + else + { + m_codecType = AudioCodec::NONE; + LOG_W("Failed to load sound \"%s\"!", name); + return false; + } +} + +bool SoundDesc::_loadPcm(const AppPlatform* platform, const char *name) +{ + m_file = platform->readAssetFile(std::string("sound/") + name + ".pcm", true); + m_isLoaded = m_file.size > 0; + + // Error + if (!m_isLoaded) return false; + + m_codecType = AudioCodec::PCM; + m_fileData = m_file.data; + m_header = *(PCMSoundHeader *) m_fileData; + m_buffer.m_pData = (void *) (m_fileData + sizeof(PCMSoundHeader)); + m_buffer.m_dataSize = m_header.m_channels * m_header.m_length * m_header.m_bytes_per_sample; + + // Success! + return true; +} + +bool SoundDesc::_loadOgg(const AppPlatform* platform, const char* category, const char *name) +{ + for (int i = 0; i < SOUND_DIRS_SIZE; i++) + { + m_file = platform->readAssetFile(dirs[i] + '/' + category + '/' + name + ".ogg", true); + m_isLoaded = m_file.size > 0; + if (m_isLoaded) break; + } + + // Error + if (!m_isLoaded) return false; + + m_codecType = AudioCodec::OGG; + m_fileData = m_file.data; + m_header.m_bytes_per_sample = 2; // Always 2 (16-bit) + // Casting to a short** here might cause problems. Let's find out... + // Seems like it doesn't. Cool. + m_header.m_length = stb_vorbis_decode_memory(m_file.data, (int) m_file.size, &m_header.m_channels, &m_header.m_sample_rate, (short **) &m_buffer.m_pData); + if (m_header.m_length == -1) + { + LOG_E("An error occurred while trying to decode a sound!"); + return false; + } + m_buffer.m_dataSize = m_header.m_channels * m_header.m_length * m_header.m_bytes_per_sample; + + // Success! + return true; +} + +void SoundDesc::_unload() +{ + if (!m_isLoaded) + { + // Sound is already unloaded + return; + } + // Free OGG Data + if (m_codecType == AudioCodec::OGG) { + free(m_buffer.m_pData); + } + // Free File Data + delete m_file.data; + m_isLoaded = false; +} + +// Load All Sounds +void SoundDesc::_loadAll(const AppPlatform* platform) +{ +#define SOUND(category, name, number) SA_##name##number._load(platform, #category, #name#number); +#include "sound_list.h" +#undef SOUND +} + +// Un-load All Sounds +void SoundDesc::_unloadAll() +{ +#define SOUND(category, name, number) SA_##name##number._unload(); +#include "sound_list.h" +#undef SOUND +} + +// Declare Variables +#define SOUND(category, name, number) SoundDesc SA_##name##number; +#include "sound_list.h" +#undef SOUND \ No newline at end of file diff --git a/source/client/sound/SoundData.hpp b/source/client/sound/SoundData.hpp index 6769bc73b..34b78e47d 100644 --- a/source/client/sound/SoundData.hpp +++ b/source/client/sound/SoundData.hpp @@ -10,6 +10,20 @@ #include #include "common/Utils.hpp" +#include "client/app/AssetFile.hpp" + +class AppPlatform; + +class AudioCodec +{ +public: + enum Type + { + NONE, + PCM, + OGG + }; +}; struct PCMSoundHeader { @@ -19,24 +33,37 @@ struct PCMSoundHeader int m_length; }; -struct SoundDesc +struct SoundBuffer { - uint16_t* m_pData; - int field_4; - PCMSoundHeader m_header; - PCMSoundHeader* m_pHeader; + void* m_pData; + int m_dataSize; +}; - SoundDesc() - { - m_pData = nullptr; - field_4 = 0; - m_pHeader = nullptr; - } - SoundDesc(PCMSoundHeader& header, uint16_t* data) - { - m_pHeader = &header; - m_header = header; - m_pData = data; - field_4 = header.m_channels * header.m_length * header.m_bytes_per_sample; - } +struct AudioDescriptor +{ + bool m_isLoaded; + AudioCodec::Type m_codecType; + PCMSoundHeader m_header; +}; + +#define SOUND_DIRS_SIZE 3 + +struct SoundDesc : AudioDescriptor +{ + static std::string dirs[SOUND_DIRS_SIZE]; + + AssetFile m_file; + SoundBuffer m_buffer; + unsigned char* m_fileData; + + bool _load(const AppPlatform* platform, const char* category, const char *name); + bool _loadPcm(const AppPlatform* platform, const char *name); + bool _loadOgg(const AppPlatform* platform, const char* category, const char *name); + void _unload(); + static void _loadAll(const AppPlatform*); + static void _unloadAll(); }; + +#define SOUND(category, name, number) extern SoundDesc SA_##name##number; +#include "sound_list.h" +#undef SOUND diff --git a/source/client/sound/SoundDefs.hpp b/source/client/sound/SoundDefs.hpp index e39aaec3c..9a759a06c 100644 --- a/source/client/sound/SoundDefs.hpp +++ b/source/client/sound/SoundDefs.hpp @@ -8,37 +8,3 @@ #pragma once #include "SoundData.hpp" - -// These are defined in SoundData.cpp, if MISSING_SOUND_DATA isn't declared. - -#ifndef MISSING_SOUND_DATA - -extern SoundDesc SA_cloth1; -extern SoundDesc SA_cloth2; -extern SoundDesc SA_cloth3; -extern SoundDesc SA_cloth4; -extern SoundDesc SA_grass1; -extern SoundDesc SA_grass2; -extern SoundDesc SA_grass3; -extern SoundDesc SA_grass4; -extern SoundDesc SA_gravel1; -extern SoundDesc SA_gravel2; -extern SoundDesc SA_gravel3; -extern SoundDesc SA_gravel4; -extern SoundDesc SA_sand1; -extern SoundDesc SA_sand2; -extern SoundDesc SA_sand3; -extern SoundDesc SA_sand4; -extern SoundDesc SA_stone1; -extern SoundDesc SA_stone2; -extern SoundDesc SA_stone3; -extern SoundDesc SA_stone4; -extern SoundDesc SA_wood1; -extern SoundDesc SA_wood2; -extern SoundDesc SA_wood3; -extern SoundDesc SA_wood4; -extern SoundDesc SA_click; -extern SoundDesc SA_explode; -extern SoundDesc SA_splash; - -#endif diff --git a/source/client/sound/SoundEngine.cpp b/source/client/sound/SoundEngine.cpp index d67a9ec32..335ba066c 100644 --- a/source/client/sound/SoundEngine.cpp +++ b/source/client/sound/SoundEngine.cpp @@ -1,70 +1,52 @@ /******************************************************************** - Minecraft: Pocket Edition - Decompilation Project - Copyright (C) 2023 iProgramInCpp - - The following code is licensed under the BSD 1 clause license. - SPDX-License-Identifier: BSD-1-Clause + Minecraft: Pocket Edition - Decompilation Project + Copyright (C) 2023 iProgramInCpp + + The following code is licensed under the BSD 1 clause license. + SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ #include "SoundEngine.hpp" #include "SoundDefs.hpp" #include "common/Mth.hpp" +#include "world/entity/Mob.hpp" +#include "client/app/AppPlatform.hpp" -SoundEngine::SoundEngine(SoundSystem* soundSystem) +SoundEngine::SoundEngine(SoundSystem* soundSystem, float distance) { - m_pSoundSystem = soundSystem; - m_pOptions = nullptr; - field_40 = 0; - field_A1C = 0; - field_A20 = 0; - m_muted = false; + m_pSoundSystem = soundSystem; + m_pOptions = nullptr; + field_40 = 0; + m_listenerPosition = Vec3::ZERO; + m_listenerOrientation = Vec2::ZERO; + m_soundDistance = 1.0f / distance; + m_noMusicDelay = m_random.nextInt(12000); + field_A20 = 0; + m_muted = false; } float SoundEngine::_getVolumeMult(const Vec3& pos) { - return 1.0f; + // Taken from 0.7.0. Very similar to paulscode.sound.libraries.SourceLWJGLOpenAL.calculateGain() + float distance = 1.1f - (pos.distanceTo(m_listenerPosition) * m_soundDistance); + return Mth::clamp(distance, -1.0f, 1.0f); } -void SoundEngine::init(Options* options) +void SoundEngine::init(Options* options, AppPlatform* platform) { - // TODO: Who's the genius who decided it'd be better to check a name string rather than an enum? - m_pOptions = options; - -#ifndef MISSING_SOUND_DATA - m_repository.add("step.cloth", SA_cloth1); - m_repository.add("step.cloth", SA_cloth2); - m_repository.add("step.cloth", SA_cloth3); - m_repository.add("step.cloth", SA_cloth4); - - m_repository.add("step.grass", SA_grass1); - m_repository.add("step.grass", SA_grass2); - m_repository.add("step.grass", SA_grass3); - m_repository.add("step.grass", SA_grass4); - - m_repository.add("step.gravel", SA_gravel1); - m_repository.add("step.gravel", SA_gravel2); - m_repository.add("step.gravel", SA_gravel3); - m_repository.add("step.gravel", SA_gravel4); - - m_repository.add("step.sand", SA_sand1); - m_repository.add("step.sand", SA_sand2); - m_repository.add("step.sand", SA_sand3); - m_repository.add("step.sand", SA_sand4); - - m_repository.add("step.stone", SA_stone1); - m_repository.add("step.stone", SA_stone2); - m_repository.add("step.stone", SA_stone3); - m_repository.add("step.stone", SA_stone4); - - m_repository.add("step.wood", SA_wood1); - m_repository.add("step.wood", SA_wood2); - m_repository.add("step.wood", SA_wood3); - m_repository.add("step.wood", SA_wood4); - - m_repository.add("random.splash", SA_splash); - m_repository.add("random.explode", SA_explode); - m_repository.add("random.click", SA_click); -#endif + // TODO: Who's the genius who decided it'd be better to check a name string rather than an enum? + m_pOptions = options; + // Load Sounds + SoundDesc::_loadAll(platform); + +#define SOUND(category, name, number) m_sounds.add(#category "." #name, SA_##name##number); +#include "sound_list.h" +#undef SOUND + +#define MUSIC(name, number) m_songs.add(#name, platform->getAssetPath("music/" #name #number ".ogg")); +#define NEWMUSIC(name, number) m_songs.add(#name, platform->getAssetPath("newmusic/" #name #number ".ogg")); +#include "music_list.h" +#undef MUSIC } void SoundEngine::enable(bool b) @@ -77,29 +59,122 @@ void SoundEngine::updateOptions() void SoundEngine::mute() { - m_muted = true; + m_muted = true; } void SoundEngine::unMute() { - m_muted = false; + m_muted = false; } void SoundEngine::destroy() { + // Un-load Sounds + SoundDesc::_unloadAll(); +} + +void SoundEngine::playMusicTick() +{ + if (m_pOptions->m_fMusicVolume <= 0.0f) + return; + + if (!m_pSoundSystem->isPlayingMusic()/* && !soundSystem.playing("streaming")*/) + { + if (m_noMusicDelay > 0) + { + --m_noMusicDelay; + return; + } + + std::string songPath; + if (m_songs.any(songPath)) + { + m_noMusicDelay = m_random.nextInt(12000) + 12000; + m_pSoundSystem->setMusicVolume(m_pOptions->m_fMusicVolume); + m_pSoundSystem->playMusic(songPath); + } + } +} + + +void SoundEngine::update(const Mob* player, float elapsedTime) +{ + if (m_pOptions->m_fMasterVolume > 0.0f) + { + if (player != nullptr) + { + Vec3 pos = player->getPos(elapsedTime); + pos.y -= player->m_heightOffset; + m_listenerPosition = pos; + m_pSoundSystem->setListenerPos(pos); + + Vec2 rot = player->getRot(elapsedTime); + m_listenerOrientation = rot; + m_pSoundSystem->setListenerAngle(rot); + } + } + + assert(m_pSoundSystem->isAvailable()); + + m_pSoundSystem->update(elapsedTime); } void SoundEngine::play(const std::string& name, const Vec3& pos, float volume, float pitch) { - float vol = m_pOptions->m_fMasterVolume * volume; - if (vol <= 0.0f) - return; + float vol = m_pOptions->m_fMasterVolume * volume; + if (vol <= 0.0f) + return; + Vec3 nPos; + float distance = pos.distanceTo(m_listenerPosition); + if (distance > SOUND_MAX_DISTANCE) + return; + // @HACK: Annoying hack because DirectSound is making steps in 2D insanely quiet. +#ifdef USE_OPENAL + if (distance < SOUND_ATTENUATION_MIN_DISTANCE) + nPos = Vec3::ZERO; + else + nPos = pos; +#else + nPos = pos; +#endif + + float cVolume = Mth::clamp(_getVolumeMult(pos) * vol, 0.0f, 1.0f); + float cPitch = Mth::clamp(pitch, 0.5f, 2.0f); // Clamp to values specified by Paulscode + SoundDesc sd; + + if (m_sounds.get(name, sd)) + { + m_pSoundSystem->playAt(sd, nPos, cVolume, cPitch); + } +} + +void SoundEngine::playUI(const std::string& name, float volume, float pitch) +{ + volume *= 0.25F; // present on Java b1.2_02, but not Pocket for some reason + float vol = m_pOptions->m_fMasterVolume * volume; + if (vol <= 0.0f) + return; + + float cVolume = Mth::clamp(vol, 0.0f, 1.0f); + SoundDesc sd; + + if (m_sounds.get(name, sd)) + { + m_pSoundSystem->playAt(sd, Vec3::ZERO, cVolume, pitch); + } +} + +void SoundEngine::playMusic(const std::string& name) +{ + float vol = m_pOptions->m_fMusicVolume; + if (vol <= 0.0f) + return; - float cVolume = Mth::clamp(_getVolumeMult(pos) * vol, 0.0f, 1.0f); - float cPitch = Mth::clamp(pitch, -1.0f, 1.0f); - SoundDesc sd; + std::string path; - if (m_repository.get(name, sd)) { - m_pSoundSystem->playAt(sd, pos.x, pos.y, pos.z, cVolume, pitch); - } + if (m_songs.get(name, path)) + { + m_pSoundSystem->setMusicVolume(vol); + m_pSoundSystem->playMusic(path); + } } diff --git a/source/client/sound/SoundEngine.hpp b/source/client/sound/SoundEngine.hpp index 40012fc56..0b91fb023 100644 --- a/source/client/sound/SoundEngine.hpp +++ b/source/client/sound/SoundEngine.hpp @@ -11,31 +11,46 @@ #include "client/options/Options.hpp" #include "common/Random.hpp" #include "world/phys/Vec3.hpp" +#include "world/phys/Vec2.hpp" #include "SoundSystem.hpp" #include "SoundRepository.hpp" +#include "SoundPathRepository.hpp" +#include "SoundStream.hpp" + +class Mob; class SoundEngine { private: - float _getVolumeMult(const Vec3& pos); + float _getVolumeMult(const Vec3& pos); public: - SoundEngine(SoundSystem* soundSystem); - void init(Options*); - void enable(bool b); - void updateOptions(); - void mute(); - void unMute(); - void destroy(); - void play(const std::string& name, const Vec3& pos = Vec3::ZERO, float volume = 1.0f, float pitch = 1.0f); + SoundEngine(SoundSystem* soundSystem, float distance); + void init(Options*, AppPlatform*); + void enable(bool b); + void updateOptions(); + void mute(); + void unMute(); + void destroy(); + void playMusicTick(); + void update(const Mob* player, float elapsedTime); + void play(const std::string& name, const Vec3& pos = Vec3::ZERO, float volume = 1.0f, float pitch = 1.0f); + void playUI(const std::string& name, float volume = 1.0f, float pitch = 1.0f); + void playMusic(const std::string& name); public: - SoundSystem* m_pSoundSystem; - Options* m_pOptions; - int field_40; - //Random m_random; - SoundRepository m_repository; - int field_A1C; - int field_A20; - bool m_muted; + SoundSystem* m_pSoundSystem; +private: + SoundRepository m_sounds; + SoundPathRepository m_songs; + Options* m_pOptions; + int field_40; + Random m_random; + Vec3 m_listenerPosition; + Vec2 m_listenerOrientation; + float m_soundDistance; + int m_noMusicDelay; + int field_A20; + bool m_muted; + //std::vector m_streams; }; diff --git a/source/client/sound/SoundPathRepository.cpp b/source/client/sound/SoundPathRepository.cpp new file mode 100644 index 000000000..c959c4412 --- /dev/null +++ b/source/client/sound/SoundPathRepository.cpp @@ -0,0 +1,47 @@ +#include "SoundPathRepository.hpp" + +#include "common/Utils.hpp" +#include "common/Mth.hpp" + +void SoundPathRepository::add(const std::string& name, const std::string& path) +{ + _all.push_back(path); + + std::map >::iterator iter = m_repo.find(name); + if (iter == m_repo.end()) + { + std::vector paths; + paths.push_back(path); + m_repo.insert(std::make_pair(name, paths)); + } + else + { + iter->second.push_back(path); + } +} + +bool SoundPathRepository::get(const std::string& name, std::string& path) +{ + // TODO: Who's the genius who decided it'd be better to check a name string rather than an enum? + std::map >::iterator iter = m_repo.find(name); + if (iter == m_repo.end()) + { + LOG_E("Couldn't find a sound with id: %s", name.c_str()); + return false; + } + + int index = Mth::random(int(iter->second.size())); + + path = iter->second[index]; + + return true; +} + +bool SoundPathRepository::any(std::string& path) +{ + if (_all.empty()) + return false; + + path = _all.at(Mth::random(_all.size()-1)); + return true; +} \ No newline at end of file diff --git a/source/client/sound/SoundPathRepository.hpp b/source/client/sound/SoundPathRepository.hpp new file mode 100644 index 000000000..76eb388a5 --- /dev/null +++ b/source/client/sound/SoundPathRepository.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include +#include +#include + +class SoundPathRepository +{ +private: + std::vector _all; + +public: + void add(const std::string& name, const std::string& path); + bool get(const std::string& name, std::string& path); + bool any(std::string& path); + +public: + std::map > m_repo; +}; + diff --git a/source/client/sound/SoundRepository.cpp b/source/client/sound/SoundRepository.cpp index b2e54c9e7..1b7d3e32a 100644 --- a/source/client/sound/SoundRepository.cpp +++ b/source/client/sound/SoundRepository.cpp @@ -12,12 +12,14 @@ void SoundRepository::add(const std::string& name, SoundDesc& sd) { + if (!sd.m_isLoaded) + return; std::map >::iterator iter = m_repo.find(name); if (iter == m_repo.end()) { std::vector sdv; sdv.push_back(sd); - m_repo.insert(std::pair >(name, sdv)); + m_repo.insert(std::make_pair(name, sdv)); } else { diff --git a/source/client/sound/SoundRepository.hpp b/source/client/sound/SoundRepository.hpp index 01a801f58..6b33b710a 100644 --- a/source/client/sound/SoundRepository.hpp +++ b/source/client/sound/SoundRepository.hpp @@ -22,4 +22,3 @@ class SoundRepository public: std::map > m_repo; }; - diff --git a/source/client/sound/SoundStream.cpp b/source/client/sound/SoundStream.cpp new file mode 100644 index 000000000..7b1456263 --- /dev/null +++ b/source/client/sound/SoundStream.cpp @@ -0,0 +1,111 @@ +#include "SoundStream.hpp" + +SoundStream::SoundStream() +{ + m_volume = 1.0f; + m_bIsStreaming = false; + m_bIsPaused = false; + m_bShouldLoop = false; + + m_decoder = nullptr; + m_info = stb_vorbis_info(); + m_totalSamplesLeft = 0; + + m_tempPcmBuffer.m_dataSize = 4096 * 8; + m_tempPcmBuffer.m_pData = new int16_t[m_tempPcmBuffer.m_dataSize]; +} + +SoundStream::~SoundStream() +{ + _deleteDecoder(); + + delete[] m_tempPcmBuffer.m_pData; +} + +void SoundStream::_deleteDecoder() +{ + if (m_decoder != nullptr) + stb_vorbis_close(m_decoder); + m_decoder = nullptr; +} + +bool SoundStream::_stream(int bufferId) +{ + int size = 0; + int result = 0; + + while (size < m_tempPcmBuffer.m_dataSize) + { + result = stb_vorbis_get_samples_short_interleaved(m_decoder, m_info.channels, (short*)m_tempPcmBuffer.m_pData + size, m_tempPcmBuffer.m_dataSize - size); + if (result > 0) size += result * m_info.channels; + else break; + } + + if (size == 0) return false; + + _publishBuffer(bufferId, m_tempPcmBuffer); + m_totalSamplesLeft -= size; + + return true; +} + +void SoundStream::setVolume(float vol) +{ + if (m_volume == vol) + return; + + _setVolume(vol); + + m_volume = vol; +} + +void SoundStream::setPausedState(bool isPaused) +{ + if (m_bIsPaused == isPaused) + return; + + if (isPaused == true) + _pause(); + else + _play(); + + m_bIsPaused = isPaused; +} + +bool SoundStream::open(const std::string& fileName) +{ + if (isStreaming()) + { + close(); + } + + m_decoder = stb_vorbis_open_filename(fileName.c_str(), NULL, NULL); + if (!m_decoder) return false; + // Get file info + m_info = stb_vorbis_get_info(m_decoder); + + if (!_open(fileName)) return false; + + setPausedState(false); + + m_totalSamplesLeft = stb_vorbis_stream_length_in_samples(m_decoder) * m_info.channels; + m_bIsStreaming = true; + + return true; +} + +void SoundStream::close() +{ + _close(); + + _deleteDecoder(); + m_totalSamplesLeft = 0; + m_bIsStreaming = false; +} + +void SoundStream::update() +{ + if (!isPlaying()) return; + + _update(); +} diff --git a/source/client/sound/SoundStream.hpp b/source/client/sound/SoundStream.hpp new file mode 100644 index 000000000..ec0a8f68c --- /dev/null +++ b/source/client/sound/SoundStream.hpp @@ -0,0 +1,57 @@ +#pragma once + +#include + +#define STB_VORBIS_HEADER_ONLY +#include "thirdparty/stb_image/include/stb_vorbis.c" + +#include "client/sound/SoundData.hpp" + +class SoundStream +{ +protected: + typedef unsigned int BufferId; + +protected: + float m_volume; + bool m_bIsStreaming; + bool m_bIsPaused; + bool m_bShouldLoop; + + stb_vorbis* m_decoder; + stb_vorbis_info m_info; + size_t m_totalSamplesLeft; + + SoundBuffer m_tempPcmBuffer; + +public: + SoundStream(); + virtual ~SoundStream(); + +private: + void _deleteDecoder(); + +protected: + virtual void _setVolume(float vol) = 0; + virtual void _play() = 0; + virtual void _pause() = 0; + virtual bool _open(const std::string& fileName) = 0; + virtual void _close() = 0; + virtual void _update() = 0; + virtual void _publishBuffer(unsigned int destBufferId, const SoundBuffer& sourceBuffer) = 0; + + bool _stream(int bufferId); + +public: + float getVolume() const { return m_volume; } + void setVolume(float vol); + bool isStreaming() const { return m_bIsStreaming; } + bool isPaused() const { return m_bIsPaused; } + void setPausedState(bool isPaused); + bool isPlaying() const { return isStreaming() && !isPaused(); } + bool shouldLoop() const { return m_bShouldLoop; } + + bool open(const std::string& fileName); + void close(); + void update(); +}; \ No newline at end of file diff --git a/source/client/sound/SoundSystem.cpp b/source/client/sound/SoundSystem.cpp index 9fb023458..81903adfa 100644 --- a/source/client/sound/SoundSystem.cpp +++ b/source/client/sound/SoundSystem.cpp @@ -17,31 +17,69 @@ bool SoundSystem::isAvailable() return false; } -void SoundSystem::setListenerPos(float x, float y, float z) +void SoundSystem::setListenerPos(const Vec3& pos) { } -void SoundSystem::setListenerAngle(float yaw, float pitch) +void SoundSystem::setListenerAngle(const Vec2& rot) { } -void SoundSystem::load(const std::string& sound) +void SoundSystem::setListenerVelocity(const Vec3& vel) { } -void SoundSystem::play(const std::string& sound) +void SoundSystem::setMusicVolume(float vol) { } -void SoundSystem::pause(const std::string& sound) +void SoundSystem::setSoundVolume(float vol) { } -void SoundSystem::stop(const std::string& sound) +void SoundSystem::load(const std::string& soundPath, bool is3D, float minDis) { } -void SoundSystem::playAt(const SoundDesc& sound, float x, float y, float z, float a, float b) +void SoundSystem::play(const std::string& soundPath) +{ +} + +void SoundSystem::pause(const std::string& soundPath) +{ +} + +void SoundSystem::stop(const std::string& soundPath) +{ +} + +void SoundSystem::playAt(const SoundDesc& sound, const Vec3& pos, float volume, float pitch) +{ +} + +void SoundSystem::playMusic(const std::string& soundPath) +{ +} + +bool SoundSystem::isPlayingMusic() const +{ + return false; +} + +bool SoundSystem::isPlayingMusic(const std::string& soundPath) const +{ + return false; +} + +void SoundSystem::stopMusic() +{ +} + +void SoundSystem::pauseMusic(bool state) +{ +} + +void SoundSystem::update(float elapsedTime) { } diff --git a/source/client/sound/SoundSystem.hpp b/source/client/sound/SoundSystem.hpp index 3192fa58d..c458f92b4 100644 --- a/source/client/sound/SoundSystem.hpp +++ b/source/client/sound/SoundSystem.hpp @@ -9,25 +9,48 @@ #pragma once #include +#include "world/phys/Vec2.hpp" +#include "world/phys/Vec3.hpp" #include "SoundData.hpp" +// Platform-agnostic sound settings // +// Just guessing for this one +#define SOUND_ATTENUATION_MIN_DISTANCE 2.0f +#define SOUND_MAX_DISTANCE 16.0f +// 28 non-streaming channels in Paulscode +// @NOTE: Currently only SoundSystemAL adheres to this. +#define SOUND_MAX_SOURCES 28 + class SoundSystem { public: virtual ~SoundSystem(); virtual bool isAvailable(); - virtual void setListenerPos(float x, float y, float z); - virtual void setListenerAngle(float yaw, float pitch); - virtual void load(const std::string& sound); - virtual void play(const std::string& sound); - virtual void pause(const std::string& sound); - virtual void stop(const std::string& sound); - virtual void playAt(const SoundDesc& sound, float x, float y, float z, float a, float b); + virtual void setListenerPos(const Vec3& pos); + virtual void setListenerAngle(const Vec2& rot); + virtual void setListenerVelocity(const Vec3& vel); + + virtual void setMusicVolume(float vol); + virtual void setSoundVolume(float vol); + + virtual void load(const std::string& soundPath, bool is3D, float minDis); + virtual void play(const std::string& soundPath); + virtual void pause(const std::string& soundPath); + virtual void stop(const std::string& soundPath); + virtual void playAt(const SoundDesc& sound, const Vec3& pos, float volume, float pitch); + + virtual void playMusic(const std::string& soundPath); + virtual bool isPlayingMusic() const; + virtual bool isPlayingMusic(const std::string& soundPath) const; + virtual void stopMusic(); + virtual void pauseMusic(bool state); + + virtual void update(float elapsedTime); // Be prepared for these to be called regardless of engine state - virtual void startEngine(); - virtual void stopEngine(); + virtual void startEngine(); // called init in 0.10.0 + virtual void stopEngine(); // called destroy in 0.10.0 virtual void muteAudio(); virtual void unMuteAudio(); diff --git a/source/client/sound/music_list.h b/source/client/sound/music_list.h new file mode 100644 index 000000000..b80142b9c --- /dev/null +++ b/source/client/sound/music_list.h @@ -0,0 +1,12 @@ +MUSIC(calm, 1) +MUSIC(calm, 2) +MUSIC(calm, 3) +NEWMUSIC(piano, 1) +NEWMUSIC(piano, 2) +NEWMUSIC(piano, 3) +NEWMUSIC(hal, 1) +NEWMUSIC(hal, 2) +NEWMUSIC(hal, 3) +NEWMUSIC(hal, 4) +NEWMUSIC(nuance, 1) +NEWMUSIC(nuance, 2) \ No newline at end of file diff --git a/source/client/sound/sound_list.h b/source/client/sound/sound_list.h new file mode 100644 index 000000000..70ae21ec2 --- /dev/null +++ b/source/client/sound/sound_list.h @@ -0,0 +1,67 @@ +SOUND(step, cloth, 1) +SOUND(step, cloth, 2) +SOUND(step, cloth, 3) +SOUND(step, cloth, 4) + +SOUND(step, grass, 1) +SOUND(step, grass, 2) +SOUND(step, grass, 3) +SOUND(step, grass, 4) + +SOUND(step, gravel, 1) +SOUND(step, gravel, 2) +SOUND(step, gravel, 3) +SOUND(step, gravel, 4) + +SOUND(step, sand, 1) +SOUND(step, sand, 2) +SOUND(step, sand, 3) +SOUND(step, sand, 4) + +SOUND(step, stone, 1) +SOUND(step, stone, 2) +SOUND(step, stone, 3) +SOUND(step, stone, 4) + +SOUND(step, wood, 1) +SOUND(step, wood, 2) +SOUND(step, wood, 3) +SOUND(step, wood, 4) + +SOUND(random, splash, ) +SOUND(random, explode, ) +SOUND(random, click, ) +SOUND(random, door_close, ) +SOUND(random, door_open, ) +SOUND(random, hurt, ) +SOUND(random, pop, ) +SOUND(random, fizz, ) + +SOUND(fire, fire, ) + +SOUND(damage, fallbig, 1) +SOUND(damage, fallbig, 2) + +SOUND(damage, fallsmall, ) + +SOUND(mob, pig, 1) +SOUND(mob, pig, 2) +SOUND(mob, pig, 3) +SOUND(mob, pigdeath, ) + +SOUND(mob, sheep, 1) +SOUND(mob, sheep, 2) +SOUND(mob, sheep, 3) + +SOUND(mob, cow, 1) +SOUND(mob, cow, 2) +SOUND(mob, cow, 3) +SOUND(mob, cow, 4) +SOUND(mob, cowhurt, 1) +SOUND(mob, cowhurt, 2) +SOUND(mob, cowhurt, 3) + +SOUND(mob, chicken, 2) +SOUND(mob, chicken, 3) +SOUND(mob, chickenhurt, 1) +SOUND(mob, chickenhurt, 2) \ No newline at end of file diff --git a/source/common/Mth.cpp b/source/common/Mth.cpp index e3fa9cef3..9b1b07242 100644 --- a/source/common/Mth.cpp +++ b/source/common/Mth.cpp @@ -84,12 +84,12 @@ unsigned Mth::fastRandom() return(x4 = x4 ^ (unsigned(x4) >> 19) ^ x0 ^ (x0 << 11) ^ ((x0 ^ unsigned(x0 << 11)) >> 8)); } -float Mth::clamp(float a, float min, float max) +float Mth::clamp(float x, float min, float max) { - if (a > max) + if (x > max) return max; - if (a > min) - return a; + if (x > min) + return x; else return min; return max; diff --git a/source/network/PacketUtil.cpp b/source/network/PacketUtil.cpp index 2ed6af551..268f1f211 100644 --- a/source/network/PacketUtil.cpp +++ b/source/network/PacketUtil.cpp @@ -19,10 +19,10 @@ void PacketUtil::Rot_entityToChar(const Entity* entity, char& yawChar, char& pit void PacketUtil::Rot_charToEntity(Entity* entity, char yawChar, char pitchChar) { float pitch = PacketUtil::Rot_charToDegrees(pitchChar); - entity->m_rotPrev.y = pitch; + entity->m_oRot.y = pitch; entity->m_rot.y = pitch; float yaw = PacketUtil::Rot_charToDegrees(yawChar); - entity->m_rotPrev.x = yaw; + entity->m_oRot.x = yaw; entity->m_rot.x = yaw; } \ No newline at end of file diff --git a/source/renderer/GL/GL.cpp b/source/renderer/GL/GL.cpp index 65c9c6eea..cb3b3d3e5 100644 --- a/source/renderer/GL/GL.cpp +++ b/source/renderer/GL/GL.cpp @@ -65,19 +65,19 @@ int glhProjectf(float objx, float objy, float objz, float* modelview, float* pro fTempo[6] = projection[2] * fTempo[0] + projection[6] * fTempo[1] + projection[10] * fTempo[2] + projection[14] * fTempo[3]; fTempo[7] = -fTempo[2]; // The result normalizes between -1 and 1 - if (fTempo[7] == 0.0) // The w value + if (fTempo[7] == 0.0f) // The w value return 0; - fTempo[7] = 1.0 / fTempo[7]; + fTempo[7] = 1.0f / fTempo[7]; // Perspective division fTempo[4] *= fTempo[7]; fTempo[5] *= fTempo[7]; fTempo[6] *= fTempo[7]; // Window coordinates // Map x, y to range 0-1 - windowCoordinate[0] = (fTempo[4] * 0.5 + 0.5) * viewport[2] + viewport[0]; - windowCoordinate[1] = (fTempo[5] * 0.5 + 0.5) * viewport[3] + viewport[1]; - // This is only correct when glDepthRange(0.0, 1.0) - windowCoordinate[2] = (1.0 + fTempo[6]) * 0.5; // Between 0 and 1 + windowCoordinate[0] = (fTempo[4] * 0.5f + 0.5f) * viewport[2] + viewport[0]; + windowCoordinate[1] = (fTempo[5] * 0.5f + 0.5f) * viewport[3] + viewport[1]; + // This is only correct when glDepthRange(0.0f, 1.0f) + windowCoordinate[2] = (1.0f + fTempo[6]) * 0.5f; // Between 0 and 1 return 1; } @@ -93,15 +93,15 @@ int glhUnProjectf(float winx, float winy, float winz, float* modelview, float* p if (glhInvertMatrixf2(A, m) == 0) return 0; // Transformation of normalized coordinates between -1 and 1 - in[0] = (winx - (float)viewport[0]) / (float)viewport[2] * 2.0 - 1.0; - in[1] = (winy - (float)viewport[1]) / (float)viewport[3] * 2.0 - 1.0; - in[2] = 2.0 * winz - 1.0; - in[3] = 1.0; + in[0] = (winx - (float)viewport[0]) / (float)viewport[2] * 2.0f - 1.0f; + in[1] = (winy - (float)viewport[1]) / (float)viewport[3] * 2.0f - 1.0f; + in[2] = 2.0f * winz - 1.0f; + in[3] = 1.0f; // Objects coordinates MultiplyMatrixByVector4by4OpenGL_FLOAT(out, m, in); - if (out[3] == 0.0) + if (out[3] == 0.0f) return 0; - out[3] = 1.0 / out[3]; + out[3] = 1.0f / out[3]; objectCoordinate[0] = out[0] * out[3]; objectCoordinate[1] = out[1] * out[3]; objectCoordinate[2] = out[2] * out[3]; @@ -197,16 +197,16 @@ int glhInvertMatrixf2(float* m, float* out) r0 = wtmp[0], r1 = wtmp[1], r2 = wtmp[2], r3 = wtmp[3]; r0[0] = MAT(m, 0, 0), r0[1] = MAT(m, 0, 1), r0[2] = MAT(m, 0, 2), r0[3] = MAT(m, 0, 3), - r0[4] = 1.0, r0[5] = r0[6] = r0[7] = 0.0, + r0[4] = 1.0f, r0[5] = r0[6] = r0[7] = 0.0f, r1[0] = MAT(m, 1, 0), r1[1] = MAT(m, 1, 1), r1[2] = MAT(m, 1, 2), r1[3] = MAT(m, 1, 3), - r1[5] = 1.0, r1[4] = r1[6] = r1[7] = 0.0, + r1[5] = 1.0f, r1[4] = r1[6] = r1[7] = 0.0f, r2[0] = MAT(m, 2, 0), r2[1] = MAT(m, 2, 1), r2[2] = MAT(m, 2, 2), r2[3] = MAT(m, 2, 3), - r2[6] = 1.0, r2[4] = r2[5] = r2[7] = 0.0, + r2[6] = 1.0f, r2[4] = r2[5] = r2[7] = 0.0f, r3[0] = MAT(m, 3, 0), r3[1] = MAT(m, 3, 1), r3[2] = MAT(m, 3, 2), r3[3] = MAT(m, 3, 3), - r3[7] = 1.0, r3[4] = r3[5] = r3[6] = 0.0; + r3[7] = 1.0f, r3[4] = r3[5] = r3[6] = 0.0f; /* choose pivot - or die */ if (fabsf(r3[0]) > fabsf(r2[0])) SWAP_ROWS_FLOAT(r3, r2); @@ -214,7 +214,7 @@ int glhInvertMatrixf2(float* m, float* out) SWAP_ROWS_FLOAT(r2, r1); if (fabsf(r1[0]) > fabsf(r0[0])) SWAP_ROWS_FLOAT(r1, r0); - if (0.0 == r0[0]) + if (0.0f == r0[0]) return 0; /* eliminate first variable */ m1 = r1[0] / r0[0]; @@ -233,25 +233,25 @@ int glhInvertMatrixf2(float* m, float* out) r2[3] -= m2 * s; r3[3] -= m3 * s; s = r0[4]; - if (s != 0.0) { + if (s != 0.0f) { r1[4] -= m1 * s; r2[4] -= m2 * s; r3[4] -= m3 * s; } s = r0[5]; - if (s != 0.0) { + if (s != 0.0f) { r1[5] -= m1 * s; r2[5] -= m2 * s; r3[5] -= m3 * s; } s = r0[6]; - if (s != 0.0) { + if (s != 0.0f) { r1[6] -= m1 * s; r2[6] -= m2 * s; r3[6] -= m3 * s; } s = r0[7]; - if (s != 0.0) { + if (s != 0.0f) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; @@ -261,7 +261,7 @@ int glhInvertMatrixf2(float* m, float* out) SWAP_ROWS_FLOAT(r3, r2); if (fabsf(r2[1]) > fabsf(r1[1])) SWAP_ROWS_FLOAT(r2, r1); - if (0.0 == r1[1]) + if (0.0f == r1[1]) return 0; /* eliminate second variable */ m2 = r2[1] / r1[1]; @@ -271,44 +271,44 @@ int glhInvertMatrixf2(float* m, float* out) r2[3] -= m2 * r1[3]; r3[3] -= m3 * r1[3]; s = r1[4]; - if (0.0 != s) { + if (0.0f != s) { r2[4] -= m2 * s; r3[4] -= m3 * s; } s = r1[5]; - if (0.0 != s) { + if (0.0f != s) { r2[5] -= m2 * s; r3[5] -= m3 * s; } s = r1[6]; - if (0.0 != s) { + if (0.0f != s) { r2[6] -= m2 * s; r3[6] -= m3 * s; } s = r1[7]; - if (0.0 != s) { + if (0.0f != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; } /* choose pivot - or die */ if (fabsf(r3[2]) > fabsf(r2[2])) SWAP_ROWS_FLOAT(r3, r2); - if (0.0 == r2[2]) + if (0.0f == r2[2]) return 0; /* eliminate third variable */ m3 = r3[2] / r2[2]; r3[3] -= m3 * r2[3], r3[4] -= m3 * r2[4], r3[5] -= m3 * r2[5], r3[6] -= m3 * r2[6], r3[7] -= m3 * r2[7]; /* last check */ - if (0.0 == r3[3]) + if (0.0f == r3[3]) return 0; - s = 1.0 / r3[3]; /* now back substitute row 3 */ + s = 1.0f / r3[3]; /* now back substitute row 3 */ r3[4] *= s; r3[5] *= s; r3[6] *= s; r3[7] *= s; m2 = r2[3]; /* now back substitute row 2 */ - s = 1.0 / r2[2]; + s = 1.0f / r2[2]; r2[4] = s * (r2[4] - r3[4] * m2), r2[5] = s * (r2[5] - r3[5] * m2), r2[6] = s * (r2[6] - r3[6] * m2), r2[7] = s * (r2[7] - r3[7] * m2); m1 = r1[3]; @@ -318,14 +318,14 @@ int glhInvertMatrixf2(float* m, float* out) r0[4] -= r3[4] * m0, r0[5] -= r3[5] * m0, r0[6] -= r3[6] * m0, r0[7] -= r3[7] * m0; m1 = r1[2]; /* now back substitute row 1 */ - s = 1.0 / r1[1]; + s = 1.0f / r1[1]; r1[4] = s * (r1[4] - r2[4] * m1), r1[5] = s * (r1[5] - r2[5] * m1), r1[6] = s * (r1[6] - r2[6] * m1), r1[7] = s * (r1[7] - r2[7] * m1); m0 = r0[2]; r0[4] -= r2[4] * m0, r0[5] -= r2[5] * m0, r0[6] -= r2[6] * m0, r0[7] -= r2[7] * m0; m0 = r0[1]; /* now back substitute row 0 */ - s = 1.0 / r0[0]; + s = 1.0f / r0[0]; r0[4] = s * (r0[4] - r1[4] * m0), r0[5] = s * (r0[5] - r1[5] * m0), r0[6] = s * (r0[6] - r1[6] * m0), r0[7] = s * (r0[7] - r1[7] * m0); MAT(out, 0, 0) = r0[4]; diff --git a/source/world/entity/Entity.cpp b/source/world/entity/Entity.cpp index 4d08af3e8..1359b7690 100644 --- a/source/world/entity/Entity.cpp +++ b/source/world/entity/Entity.cpp @@ -26,7 +26,7 @@ void Entity::_init() m_bBlocksBuilding = false; m_pLevel = nullptr; m_rot = Vec2::ZERO; - m_rotPrev = Vec2::ZERO; + m_oRot = Vec2::ZERO; m_onGround = false; m_bHorizontalCollision = false; field_7E = false; @@ -45,7 +45,7 @@ void Entity::_init() m_bNoPhysics = false; field_B0 = 0.0f; m_tickCount = 0; - field_B8 = 0; + m_invulnerableTime = 0; m_airCapacity = TOTAL_AIR_SUPPLY; m_fireTicks = 0; m_flameTime = 1; @@ -439,15 +439,14 @@ int Entity::move(const Vec3& pos) bool bPlaySound = true; const Tile::SoundType *sound = Tile::tiles[tileID]->m_pSound; - /*if (!isPlayer()) // no idea why this wasn't already a thing - bPlaySound = false;*/ if (m_pLevel->getTile(tilePos.above()) == Tile::topSnow->m_ID) sound = Tile::topSnow->m_pSound; else if (Tile::tiles[tileID]->m_pMaterial->isLiquid()) bPlaySound = false; + // vol is * 0.15f in Java, is quiet for whatever reason, so bumping to 0.20f if (bPlaySound) - m_pLevel->playSound(this, "step." + sound->m_name, sound->volume * 0.15f, sound->pitch); + m_pLevel->playSound(this, "step." + sound->m_name, sound->volume * 0.20f, sound->pitch); Tile::tiles[tileID]->stepOn(m_pLevel, tilePos, this); } @@ -516,18 +515,18 @@ void Entity::absMoveTo(const Vec3& pos, const Vec2& rot) { m_ySlideOffset = 0.0f; - m_rotPrev = rot; + m_oRot = rot; setRot(rot); setPos(pos); m_oPos = pos; // This looks like a rebounding check for the angle - float dyRot = (m_rotPrev.y - m_rot.y); + float dyRot = (m_oRot.y - m_rot.y); if (dyRot < -180.0f) - m_rotPrev.y += 360.0f; + m_oRot.y += 360.0f; if (dyRot >= 180.0f) - m_rotPrev.y -= 360.0f; + m_oRot.y -= 360.0f; } void Entity::moveRelative(const Vec3& pos) @@ -575,15 +574,15 @@ void Entity::turn(const Vec2& rot) interpolateTurn(rot); - m_rotPrev.x += m_rot.x - rotOld.x; - m_rotPrev.y += m_rot.y - rotOld.y; + m_oRot.x += m_rot.x - rotOld.x; + m_oRot.y += m_rot.y - rotOld.y; } void Entity::reset() { // TODO is this it m_posPrev = m_oPos = m_pos; - m_rotPrev = m_rot; + m_oRot = m_rot; m_bRemoved = false; m_distanceFallen = 0.0f; field_D5 = false; @@ -616,7 +615,7 @@ void Entity::baseTick() field_90 = m_walkDist; m_oPos = m_pos; m_tickCount++; - m_rotPrev = m_rot; + m_oRot = m_rot; if (isInWater()) { if (!field_D4 && !field_D6) diff --git a/source/world/entity/Entity.hpp b/source/world/entity/Entity.hpp index 520eae1af..c64816a2b 100644 --- a/source/world/entity/Entity.hpp +++ b/source/world/entity/Entity.hpp @@ -183,14 +183,10 @@ class Entity float field_30; bool m_bBlocksBuilding; Level* m_pLevel; - Vec3 m_oPos; // "o" in Java or "xo" ""yo" "zo" + Vec3 m_oPos; // "o" in Java or "xo" "yo" "zo" Vec3 m_vel; Vec2 m_rot; - //maybe these are the actual m_yaw and m_pitch, and - //the one I annotated are the destination yaw and pitch. - //interpolateTurn doesn't modify them, so I highly suspect - //this to be the case. - Vec2 m_rotPrev; + Vec2 m_oRot; // "RotO" in Java or "xRotO" "yRotO" AABB m_hitbox; bool m_onGround; bool m_bHorizontalCollision; @@ -210,7 +206,7 @@ class Entity bool m_bNoPhysics; float field_B0; int m_tickCount; - int field_B8; + int m_invulnerableTime; int m_airCapacity; int m_fireTicks; int m_flameTime; diff --git a/source/world/entity/ItemEntity.cpp b/source/world/entity/ItemEntity.cpp index 9dfa8b7cd..3cf2772a0 100644 --- a/source/world/entity/ItemEntity.cpp +++ b/source/world/entity/ItemEntity.cpp @@ -73,7 +73,7 @@ void ItemEntity::playerTouch(Player* player) pInventory->addItem(&m_itemInstance); m_pLevel->playSound(this, "random.pop", 0.3f, - (((sharedRandom.nextFloat() - sharedRandom.nextFloat()) * 0.7f) + 1.0f) + (((sharedRandom.nextFloat() - sharedRandom.nextFloat()) * 0.7f) + 1.0f)); + ((sharedRandom.nextFloat() - sharedRandom.nextFloat()) * 0.7f + 1.0f) * 2.0f); if (m_itemInstance.m_count <= 0) remove(); diff --git a/source/world/entity/Mob.cpp b/source/world/entity/Mob.cpp index 3b39b78d7..7b932cd54 100644 --- a/source/world/entity/Mob.cpp +++ b/source/world/entity/Mob.cpp @@ -12,14 +12,14 @@ Mob::Mob(Level* pLevel) : Entity(pLevel) { - field_DC = 10; + m_invulnerableDuration = 10; field_E8 = 0.0f; field_EC = 0.0f; field_F0 = 0; m_oAttackAnim = 0.0f; m_attackAnim = 0.0f; m_health = 10; - field_100 = 20; + m_lastHealth = 20; m_hurtTime = 0; m_hurtDuration = 0; m_hurtDir = 0.0f; @@ -30,12 +30,12 @@ Mob::Mob(Level* pLevel) : Entity(pLevel) field_120 = 0; field_124 = 0; field_128 = 0.0f; - field_12C = 0.0f; + m_walkAnimSpeed = 0.0f; field_130 = 0.0f; m_noActionTime = 0; field_B00 = Vec2::ZERO; field_B08 = 0.0f; - m_bJumping = 0; + m_bJumping = false; field_B10 = 0; m_runSpeed = 0.7f; field_B48 = 0; @@ -51,10 +51,11 @@ Mob::Mob(Level* pLevel) : Entity(pLevel) m_lSteps = 0; m_lPos = Vec3::ZERO; m_lRot = Vec2::ZERO; - field_B84 = 0; + m_lastHurt = 0; m_pEntLookedAt = nullptr; m_bSwinging = false; m_swingTime = 0; + m_ambientSoundTime = 0; m_texture = "/mob/pig.png"; m_class = ""; @@ -201,11 +202,11 @@ void Mob::tick() // Similar to rotlerp // I'm pretty sure this is super inefficient and its trying to do what I have it doing in setRot already. - while (x4 - m_rotPrev.x < -180.0f) - m_rotPrev.x -= 360.0f; + while (x4 - m_oRot.x < -180.0f) + m_oRot.x -= 360.0f; - while (x4 - m_rotPrev.x >= 180.0f) - m_rotPrev.x += 360.0f; + while (x4 - m_oRot.x >= 180.0f) + m_oRot.x += 360.0f; while (field_E8 - field_EC < -180.0f) field_EC -= 360.0f; @@ -213,84 +214,96 @@ void Mob::tick() while (field_E8 - field_EC >= 180.0f) field_EC += 360.0f; - while (m_rot.y - m_rotPrev.y < -180.0f) - m_rotPrev.y -= 360.0f; + while (m_rot.y - m_oRot.y < -180.0f) + m_oRot.y -= 360.0f; - while (m_rot.y - m_rotPrev.y >= 180.0f) - m_rotPrev.y += 360.0f; + while (m_rot.y - m_oRot.y >= 180.0f) + m_oRot.y += 360.0f; field_B54 += x2; } void Mob::baseTick() { - m_oAttackAnim = m_attackAnim; - Entity::baseTick(); - - if (isAlive() && isInWall()) - hurt(nullptr, 1); - - if (isAlive() && isUnderLiquid(Material::water) && !isWaterMob()) - { - m_airCapacity--; - if (m_airCapacity == -20) - { - m_airCapacity = 0; - - for (int i = 0; i < 8; i++) - { - m_pLevel->addParticle("bubble", - Vec3( - m_pos.x + m_random.nextFloat() - m_random.nextFloat(), - m_pos.y + m_random.nextFloat() - m_random.nextFloat(), - m_pos.z + m_random.nextFloat() - m_random.nextFloat() - ), - m_vel - ); - } - - hurt(nullptr, 2); - } - } - else - { - m_airCapacity = m_airSupply; - } + m_oAttackAnim = m_attackAnim; + Entity::baseTick(); + + if (m_random.nextInt(1000) < m_ambientSoundTime++) + { + playAmbientSound(); + } + + if (isAlive() && isInWall()) + hurt(nullptr, 1); + + // Java + /*if (m_bFireImmune || m_pLevel->m_bIsMultiplayer) + { + m_fireTicks = 0; + }*/ + + + if (isAlive() && isUnderLiquid(Material::water) && !isWaterMob()) + { + m_airCapacity--; + if (m_airCapacity == -20) + { + m_airCapacity = 0; + + for (int i = 0; i < 8; i++) + { + m_pLevel->addParticle("bubble", + Vec3( + m_pos.x + m_random.nextFloat() - m_random.nextFloat(), + m_pos.y + m_random.nextFloat() - m_random.nextFloat(), + m_pos.z + m_random.nextFloat() - m_random.nextFloat() + ), + m_vel + ); + } + + hurt(nullptr, 2); + } + } + else + { + m_airCapacity = m_airSupply; + } m_oTilt = m_tilt; - if (m_attackTime > 0) m_attackTime--; - if (m_hurtTime > 0) m_hurtTime--; - if (field_B8 > 0) field_B8--; - - if (m_health <= 0) - { - field_110++; - if (field_110 > 20) - { - beforeRemove(); - remove(); - for (int i = 0; i < 20; i++) - { - m_pLevel->addParticle("explode", - Vec3( - m_pos.x + 2 * m_bbWidth * m_random.nextFloat() - m_bbWidth, - m_pos.y + m_bbHeight * m_random.nextFloat(), - m_pos.z + 2 * m_bbWidth * m_random.nextFloat() - m_bbWidth - ), - Vec3( - 0.02f * (m_random.nextFloat() * 2 - 1) * (m_random.nextFloat() * 2 - 1), - 0.02f * (m_random.nextFloat() * 2 - 1) * (m_random.nextFloat() * 2 - 1), - 0.02f * (m_random.nextFloat() * 2 - 1) * (m_random.nextFloat() * 2 - 1) - ) - ); - } - } - } - - field_B58 = field_B54; - field_EC = field_E8; - m_rotPrev = m_rot; + if (m_attackTime > 0) m_attackTime--; + if (m_hurtTime > 0) m_hurtTime--; + if (m_invulnerableTime > 0) m_invulnerableTime--; + + if (m_health <= 0) + { + field_110++; + if (field_110 > 20) + { + beforeRemove(); + remove(); + for (int i = 0; i < 20; i++) + { + m_pLevel->addParticle("explode", + Vec3( + m_pos.x + 2 * m_bbWidth * m_random.nextFloat() - m_bbWidth, + m_pos.y + m_bbHeight * m_random.nextFloat(), + m_pos.z + 2 * m_bbWidth * m_random.nextFloat() - m_bbWidth + ), + Vec3( + 0.02f * (m_random.nextFloat() * 2 - 1) * (m_random.nextFloat() * 2 - 1), + 0.02f * (m_random.nextFloat() * 2 - 1) * (m_random.nextFloat() * 2 - 1), + 0.02f * (m_random.nextFloat() * 2 - 1) * (m_random.nextFloat() * 2 - 1) + ) + ); + } + } + } + + field_B58 = field_B54; + field_EC = field_E8; + m_oRot = m_rot; } bool Mob::isAlive() const @@ -303,58 +316,75 @@ bool Mob::isAlive() const bool Mob::hurt(Entity *pAttacker, int damage) { - if (m_pLevel->m_bIsMultiplayer) - return false; - - m_noActionTime = 0; - - if (m_health <= 0) - return false; - - field_12C = 1.5f; - if (float(field_B8) <= float(field_DC) * 0.5f) - { - field_100 = m_health; - field_B8 = field_DC; - field_B84 = damage; - actuallyHurt(damage); - m_hurtDuration = 10; - m_hurtTime = 10; - - // not in 0.1 - markHurt(); - - if (pAttacker) - { - float xd = pAttacker->m_pos.x - m_pos.x; - float zd = pAttacker->m_pos.z - m_pos.z; - - while (zd * zd + xd * xd < 0.0001f) - { - xd = 0.01f * (Mth::random() - Mth::random()); - zd = 0.01f * (Mth::random() - Mth::random()); - } - - float ang = atan2f(zd, xd); - v020_field_104 = ang * (180.0f / float(M_PI)) - m_rot.x; - - knockback(pAttacker, damage, xd, zd); - } - } - else - { - if (field_B84 >= damage) - return 0; - - actuallyHurt(damage - field_B84); - field_B84 = damage; - } - - m_hurtDir = 0; - if (m_health <= 0) - die(pAttacker); - - return true; + if (m_pLevel->m_bIsMultiplayer) + return false; + + m_noActionTime = 0; + + if (m_health <= 0) + return false; + + m_walkAnimSpeed = 1.5f; + bool var3 = true; + if (float(m_invulnerableTime) > float(m_invulnerableDuration) / 2.0f) + { + if (damage <= m_lastHurt) + return false; + + actuallyHurt(damage - m_lastHurt); + m_lastHurt = damage; + var3 = false; + } + else + { + m_lastHurt = damage; + m_lastHealth = m_health; + m_invulnerableTime = m_invulnerableDuration; + actuallyHurt(damage); + m_hurtTime = m_hurtDuration = 10; + } + + m_hurtDir = 0.0f; + // not in 0.1 + if (var3) + { + //m_pLevel->broadcastEntityEvent(this, 2); // Java + markHurt(); + + if (pAttacker) + { + float xd = pAttacker->m_pos.x - m_pos.x; + float zd = pAttacker->m_pos.z - m_pos.z; + + while (zd * zd + xd * xd < 0.0001f) + { + xd = 0.01f * (Mth::random() - Mth::random()); + zd = 0.01f * (Mth::random() - Mth::random()); + } + + float ang = atan2f(zd, xd); + v020_field_104 = ang * (180.0f / float(M_PI)) - m_rot.x; + + knockback(pAttacker, damage, xd, zd); + } + } + + if (m_health <= 0) + { + if (var3) + { + m_pLevel->playSound(this, getDeathSound(), getSoundVolume(), (m_random.nextFloat() - m_random.nextFloat()) * 0.2f + 1.0f); + } + + die(pAttacker); + } + else if (var3) + { + m_pLevel->playSound(this, getHurtSound(), getSoundVolume(), (m_random.nextFloat() - m_random.nextFloat()) * 0.2f + 1.0f); + } + + + return true; } void Mob::animateHurt() @@ -390,9 +420,13 @@ void Mob::causeFallDamage(float level) hurt(nullptr, x); - //@HUH: useless call to getTile? or could this be a return value of some sort - //Entity::causeFallDamage returns nothing though, so.... - m_pLevel->getTile(TilePos(m_pos.x, m_pos.y - 0.2f - m_heightOffset, m_pos.z)); + TileID tileId = m_pLevel->getTile(TilePos(m_pos.x, m_pos.y - 0.2f - m_heightOffset, m_pos.z)); + if (tileId > 0) + { + const Tile::SoundType* pSound = Tile::tiles[tileId]->m_pSound; + + m_pLevel->playSound(this, "step." + pSound->m_name, pSound->volume * 0.5f, pSound->pitch * 0.75f); + } } } @@ -432,7 +466,12 @@ std::string Mob::getTexture() const void Mob::playAmbientSound() { - + m_ambientSoundTime = -getAmbientSoundInterval(); + std::string sound = getAmbientSound(); + if (sound != "") + { + m_pLevel->playSound(this, sound, getSoundVolume(), (m_random.nextFloat() - m_random.nextFloat()) * 0.2f + 1.0f); + } } int Mob::getAmbientSoundInterval() const @@ -449,7 +488,7 @@ void Mob::heal(int health) if (m_health > C_MAX_MOB_HEALTH) m_health = C_MAX_MOB_HEALTH; - field_B8 = field_DC / 2; + m_invulnerableTime = m_invulnerableDuration / 2; } HitResult Mob::pick(float f1, float f2) @@ -575,7 +614,7 @@ bool Mob::canSee(Entity* pEnt) const void Mob::updateWalkAnim() { - field_128 = field_12C; + field_128 = m_walkAnimSpeed; float diffX = m_pos.x - m_oPos.x; float diffZ = m_pos.z - m_oPos.z; @@ -584,8 +623,8 @@ void Mob::updateWalkAnim() if (spd > 1.0f) spd = 1.0f; - field_12C += (spd - field_12C) * 0.4f; - field_130 += field_12C; + m_walkAnimSpeed += (spd - m_walkAnimSpeed) * 0.4f; + field_130 += m_walkAnimSpeed; } void Mob::aiStep() @@ -669,10 +708,18 @@ Vec3 Mob::getPos(float f) const ); } +Vec2 Mob::getRot(float f) const +{ + return Vec2( + Mth::Lerp(m_oRot.x, m_rot.x, f), + Mth::Lerp(m_oRot.y, m_rot.y, f) + ); +} + Vec3 Mob::getViewVector(float f) const { constexpr float C_180_OVER_PI = 0.017453f; - constexpr float C_PI = 3.1416f; + constexpr float C_PI = 3.1416f; // @HUH: Why not just use M_PI here? if (f == 1.0) { @@ -683,8 +730,8 @@ Vec3 Mob::getViewVector(float f) const return Vec3(x.x * x.z, Mth::sin(-(m_rot.y * C_180_OVER_PI)), x.y * x.z); } - float x1 = m_rotPrev.y + (m_rot.y - m_rotPrev.y) * f; - float x2 = -((m_rotPrev.x + (m_rot.x - m_rotPrev.x) * f) * C_180_OVER_PI) - C_PI; + float x1 = m_oRot.y + (m_rot.y - m_oRot.y) * f; + float x2 = -((m_oRot.x + (m_rot.x - m_oRot.x) * f) * C_180_OVER_PI) - C_PI; float x3 = Mth::cos(x2); float x4 = Mth::sin(x2); float x5 = -(x1 * C_180_OVER_PI); diff --git a/source/world/entity/Mob.hpp b/source/world/entity/Mob.hpp index 74d9abe65..cef53ef2e 100644 --- a/source/world/entity/Mob.hpp +++ b/source/world/entity/Mob.hpp @@ -59,6 +59,7 @@ class Mob : public Entity virtual bool canSpawn(); virtual float getAttackAnim(float f) const; virtual Vec3 getPos(float f) const; + virtual Vec2 getRot(float f) const; virtual Vec3 getLookAngle(float f) const { return getViewVector(1.0f); } virtual Vec3 getViewVector(float f) const; virtual int getMaxSpawnClusterSize() const { return 4; } @@ -83,9 +84,12 @@ class Mob : public Entity float rotlerp(float, float, float); void updateAttackAnim(); + +private: + int m_ambientSoundTime; public: - int field_DC; + int m_invulnerableDuration; float field_E0; float field_E4; float field_E8; @@ -94,7 +98,7 @@ class Mob : public Entity float m_oAttackAnim; float m_attackAnim; int m_health; - int field_100; + int m_lastHealth; int m_hurtTime; int m_hurtDuration; float m_hurtDir; @@ -105,7 +109,7 @@ class Mob : public Entity int field_120; int field_124; float field_128; - float field_12C; + float m_walkAnimSpeed; float field_130; Random m_random; int m_noActionTime; @@ -129,7 +133,7 @@ class Mob : public Entity int m_lSteps; Vec3 m_lPos; Vec2 m_lRot; - int field_B84; + int m_lastHurt; Entity* m_pEntLookedAt; float v020_field_104; diff --git a/source/world/entity/Player.cpp b/source/world/entity/Player.cpp index 937b83b53..d995bf56e 100644 --- a/source/world/entity/Player.cpp +++ b/source/world/entity/Player.cpp @@ -66,29 +66,32 @@ bool Player::hurt(Entity* pEnt, int damage) return false; } - EntityTypeDescriptor entDesc = pEnt->getDescriptor(); - - if (entDesc.hasCategory(EntityCategories::MONSTER) || entDesc.hasCategory(EntityCategories::ABSTRACT_ARROW)) - { - switch (m_pLevel->m_difficulty) - { - case 0: - damage = 0; - break; - case 1: - damage = damage / 3 + 1; - break; - case 2: - // Don't modify damage - break; - case 3: - damage = damage * 3 / 2; - break; - default: - assert(!"Unknown difficulty value"); - break; - } - } + if (pEnt != nullptr) + { + EntityTypeDescriptor entDesc = pEnt->getDescriptor(); + + if (entDesc.hasCategory(EntityCategories::MONSTER) || entDesc.hasCategory(EntityCategories::ABSTRACT_ARROW)) + { + switch (m_pLevel->m_difficulty) + { + case 0: + damage = 0; + break; + case 1: + damage = damage / 3 + 1; + break; + case 2: + // Don't modify damage + break; + case 3: + damage = damage * 3 / 2; + break; + default: + assert(!"Unknown difficulty value"); + break; + } + } + } return damage == 0 ? false : Mob::hurt(pEnt, damage); } diff --git a/source/world/entity/TripodCamera.cpp b/source/world/entity/TripodCamera.cpp index df00627d9..eb5fcc171 100644 --- a/source/world/entity/TripodCamera.cpp +++ b/source/world/entity/TripodCamera.cpp @@ -19,7 +19,7 @@ TripodCamera::TripodCamera(Level* level, Player* player, const Vec3& pos) : Mob( m_owner = player; field_C8 = RENDER_CAMERA; - m_rotPrev = m_rot = player->m_rot; + m_oRot = m_rot = player->m_rot; m_bBlocksBuilding = true; diff --git a/source/world/gamemode/CreativeMode.cpp b/source/world/gamemode/CreativeMode.cpp index f5f7a4c32..fbd53dd03 100644 --- a/source/world/gamemode/CreativeMode.cpp +++ b/source/world/gamemode/CreativeMode.cpp @@ -55,6 +55,7 @@ void CreativeMode::stopDestroyBlock() void CreativeMode::tick() { m_lastDestroyProgress = m_destroyProgress; + GameMode::tick(); } void CreativeMode::render(float f) diff --git a/source/world/gamemode/GameMode.cpp b/source/world/gamemode/GameMode.cpp index 410e37fad..e28e5f7e0 100644 --- a/source/world/gamemode/GameMode.cpp +++ b/source/world/gamemode/GameMode.cpp @@ -69,6 +69,8 @@ void GameMode::stopDestroyBlock() void GameMode::tick() { + // @NOTE: should only be in SurvivalMode & MultiPlayerGameMode, but Minecraft music is awesome + m_pMinecraft->m_pSoundEngine->playMusicTick(); } void GameMode::render(float f) diff --git a/source/world/gamemode/SurvivalMode.cpp b/source/world/gamemode/SurvivalMode.cpp index 54c5bf1d6..2f2c42481 100644 --- a/source/world/gamemode/SurvivalMode.cpp +++ b/source/world/gamemode/SurvivalMode.cpp @@ -132,6 +132,8 @@ void SurvivalMode::stopDestroyBlock() void SurvivalMode::tick() { m_lastDestroyProgress = m_destroyProgress; + //m_pMinecraft->m_pSoundEngine->playMusicTick(); // also on MultiPlayerGameMode + GameMode::tick(); } void SurvivalMode::render(float f) diff --git a/source/world/level/Level.cpp b/source/world/level/Level.cpp index 2e21dc644..084d50ffd 100644 --- a/source/world/level/Level.cpp +++ b/source/world/level/Level.cpp @@ -1396,7 +1396,7 @@ void Level::tick(Entity* pEnt, bool b) } pEnt->m_posPrev = pEnt->m_pos; - pEnt->m_rotPrev = pEnt->m_rot; + pEnt->m_oRot = pEnt->m_rot; if (pEnt->m_bInAChunk) pEnt->tick(); @@ -1404,7 +1404,7 @@ void Level::tick(Entity* pEnt, bool b) else { pEnt->m_posPrev = pEnt->m_pos; - pEnt->m_rotPrev = pEnt->m_rot; + pEnt->m_oRot = pEnt->m_rot; } ChunkPos cp(pEnt->m_pos); diff --git a/source/world/level/storage/LevelData.cpp b/source/world/level/storage/LevelData.cpp index 83f431e3b..aa16440e1 100644 --- a/source/world/level/storage/LevelData.cpp +++ b/source/world/level/storage/LevelData.cpp @@ -82,7 +82,7 @@ void PlayerData::loadPlayer(Player* player) // Let the setter do the validation player->setRot( - player->m_rotPrev = m_rot + player->m_oRot = m_rot ); player->m_distanceFallen = m_distanceFallen; player->m_fireTicks = field_24; diff --git a/thirdparty/GL/GL.hpp b/thirdparty/GL/GL.hpp index 2954eb6c1..abbe0c808 100644 --- a/thirdparty/GL/GL.hpp +++ b/thirdparty/GL/GL.hpp @@ -83,7 +83,7 @@ static inline void gluPerspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar) { GLfloat m[4][4]; float sine, cotangent, deltaZ; - float radians = fovy / 2 * M_PI / 180; + float radians = fovy / 2.0f * M_PI / 180.0f; deltaZ = zFar - zNear; sine = sin(radians); diff --git a/thirdparty/OpenAL.h b/thirdparty/OpenAL.h new file mode 100644 index 000000000..b77806f64 --- /dev/null +++ b/thirdparty/OpenAL.h @@ -0,0 +1,24 @@ +#ifdef _WIN32 +#include +#include +#pragma comment( lib, "OpenAl32.lib" ) +#elif defined(__APPLE__) +#include +#include +#else +#include +#include +#endif + +// Error Checking +#define AL_ERROR_CHECK() AL_ERROR_CHECK_MANUAL(alGetError()) +#define AL_ERROR_CHECK_MANUAL(val) \ + { \ + ALenum __err = val; \ + if (__err != AL_NO_ERROR) \ + { \ + LOG_E("(%s:%i) OpenAL Error: %s", __FILE__, __LINE__, alGetString(__err)); \ + assert(!"An OpenAL error occurred!"); \ + } \ + } +#define AL_ERROR_SILENCE() { while ( alGetError() ); } \ No newline at end of file diff --git a/tools/extract_apk.py b/tools/extract_apk.py new file mode 100755 index 000000000..21f8c8764 --- /dev/null +++ b/tools/extract_apk.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python3 +import setup_venv + +import grabsounds +import sys +import zipfile +import os + +# Constants +TITLE = 'APK Extractor' +ASSETS_DIR = 'assets/' +SOUND_DATA_FILE = 'libminecraftpe.so' + +# Determine Mode +use_gui = len(sys.argv) < 2 +if use_gui: + # Setup GUI + import tkinter as tk + from tkinter import filedialog, messagebox + root = tk.Tk() + root.withdraw() + +# Show Information +def info(msg): + print(msg) + if use_gui: + messagebox.showinfo(title=TITLE, message=msg) + +# Extract Sounds +def extract_sounds(apk_zip): + # Search For File + for name in apk_zip.namelist(): + if os.path.basename(name) == SOUND_DATA_FILE: + with apk_zip.open(name) as sound_data: + grabsounds.main(sound_data) + return + raise Exception('Unable to find sound data!') + +# Extract Assets +def extract_assets(apk_zip): + assets = os.path.dirname(os.path.abspath(__file__)) + assets = os.path.join(assets, '..', 'game', 'assets') + # Search For Assets + for name in apk_zip.namelist(): + if name.startswith(ASSETS_DIR): + # Found Asset + short_name = name[len(ASSETS_DIR):] + print(f'Extracting Asset {short_name}...') + out = os.path.join(assets, short_name) + os.makedirs(os.path.dirname(out), exist_ok=True) + # Extract + with open(out, 'wb') as file: + file.write(apk_zip.read(name)) + +# Open APK +def open_apk(): + if use_gui: + out = filedialog.askopenfile('rb', title=TITLE, filetypes=[('APK', '*.apk')]) + if out is None: + sys.exit() + return out + else: + return open(sys.argv[1], 'rb') + +# Main +def main(): + with open_apk() as apk: + # Extract + with zipfile.ZipFile(apk) as apk_zip: + extract_sounds(apk_zip) + extract_assets(apk_zip) + # Done + info('Done!') + +# Handle Errors +try: + main() +except Exception as e: + if use_gui: + info('An error has occurred!') + raise diff --git a/tools/grabsounds.py b/tools/grabsounds.py index 42bacb235..9040bc8fc 100755 --- a/tools/grabsounds.py +++ b/tools/grabsounds.py @@ -1,155 +1,36 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 +import setup_venv -# Minecraft PE Reverse Engineering Project -# Copyright (C) 2023 iProgramInCpp -# ----------------------------------------------- -# This tool grabs the sound data from the .so file from the source Minecraft PE -# Android *.so file. Offsets are hardcoded to that version, nothing else will work. -# -# TODO: Lookup ELF symbols to un-hardcode the offsets? +import lief import sys import os -import hashlib -# use memory efficient range always -merange = range -try: - merange = xrange # python 2 -except NameError: - pass - -# defines -pcm_addresses = [ - ('PCM_cloth1', 0x00112B08), - ('PCM_cloth2', 0x00117134), - ('PCM_cloth3', 0x0011B760), - ('PCM_cloth4', 0x0011FD8C), - ('PCM_grass1', 0x001243B8), - ('PCM_grass2', 0x0012F00C), - ('PCM_grass3', 0x00139C60), - ('PCM_grass4', 0x001448B4), - ('PCM_gravel1', 0x0014F508), - ('PCM_gravel2', 0x0015A15C), - ('PCM_gravel3', 0x00164DB0), - ('PCM_gravel4', 0x0016FA04), - ('PCM_sand1', 0x0017A658), - ('PCM_sand2', 0x00181214), - ('PCM_sand3', 0x00187DD0), - ('PCM_sand4', 0x0018E98C), - ('PCM_stone1', 0x00195548), - ('PCM_stone2', 0x001A019C), - ('PCM_stone3', 0x001AADF0), - ('PCM_stone4', 0x001B5A44), - ('PCM_wood1', 0x001C0698), - ('PCM_wood2', 0x001CB2EC), - ('PCM_wood3', 0x001D5F40), - ('PCM_wood4', 0x001E0B94), - ('PCM_click', 0x001EB7E8), - ('PCM_explode', 0x001F78A8), - ('PCM_splash', 0x00209A38) -] - -so_file_sha256 = '157af341d13a54cc935bbe24c5e1cf3d02d7e40ec20f9859b9853c2e996ebd81' - -header_1 = '// Minecraft Pocket Edition Reverse Engineering Project\n// Copyright (C) 2011 Mojang Specifications.\n' -header_2 = '// Data extracted from libminecraftpe.so (Minecraft PE v0.1.3.apk).\n\n' - -def read_int_from_bytes(arr_bytes, offset): - return arr_bytes[offset] | arr_bytes[offset + 1] << 8 | arr_bytes[offset + 2] << 16 | arr_bytes[offset + 3] << 24 - -def read_short_from_bytes(arr_bytes, offset): - return arr_bytes[offset] | arr_bytes[offset + 1] << 8 - -def format_hex_short(short): - return "{:04x}".format(short) - -def main(): - if len(sys.argv) < 2: - print('Usage:', sys.argv[0], '[libminecraftpe.so] (output dir)') - return - - output_dir = '' - - if len(sys.argv) > 2: - output_dir = sys.argv[2] - - if len(output_dir) == 0: - output_dir = './sound_data/' - - # append a slash to the file name, if it doesn't have one already - if output_dir[len(output_dir) - 1] != '/': - output_dir += '/' - - if not os.path.exists(output_dir): - os.makedirs(output_dir) - - bytes = [] - - # open the file - try: - with open(sys.argv[1],mode='rb') as sofile: - # read all bytes - bytes = sofile.read() - - except FileNotFoundError: - print('ERROR: The file', sys.argv[1], 'was not found.') - return - - # first off, hash the file to ensure it matches - src_sha256 = hashlib.sha256(bytes).hexdigest() - - print('* Source file hash: ', src_sha256) - - if src_sha256 != so_file_sha256: - print('ERROR: Source file does not match the Source APK\'s SO file. Please extract one from the aforementioned APK. See the readme for more details.') - return - - print('* Extracting PCM data...') - - include_all_str = '#pragma once\n\n' + header_1 - include_all_str+= '\n// @NOTE: This is meant to be included in exactly 1 compile object/source file.\n\n' + header_2 - - for item in pcm_addresses: - include_all_str += '#include "' + item[0] + '.h"\n' - ostr = header_1 + header_2 - - channels = read_int_from_bytes(bytes, item[1] + 0) - data_length = read_int_from_bytes(bytes, item[1] + 12) - - # @NOTE: All the PCM sound data is in `.data`. So there's no consts to be found. - - ostr += 'PCMSoundHeader '+item[0]+' =\n{\n' - ostr += '\t' + str(channels) + ',\n' - ostr += '\t' + str(read_int_from_bytes(bytes, item[1] + 4)) + ',\n' - ostr += '\t' + str(read_int_from_bytes(bytes, item[1] + 8)) + ',\n' - ostr += '\t' + str(data_length) - ostr += '\n};\n\n' - - data_length *= channels - - ostr += 'uint16_t '+item[0]+'_data['+str(data_length)+'] =\n{' - - for i in merange(data_length): - if i % 16 == 0: - ostr += '\n\t' - ostr += '0x'+format_hex_short(read_short_from_bytes(bytes, item[1] + 16 + i * 2)) + ',' - - ostr += '\n};\n' - - filename = output_dir + item[0] + '.h' - with open(filename, 'w') as of: - of.write(ostr) - - include_all_str += '\n\n' - - for item in pcm_addresses: - include_all_str += 'SoundDesc SA_' + item[0][4:] + '(' + item[0] + ', ' + item[0] + '_data);\n' - - with open(output_dir + 'sounds.h', 'w') as of: - of.write(include_all_str) - - pass - - +# Main Function +def main(file): + # Output Directory + out = os.path.dirname(os.path.abspath(__file__)) + out = os.path.join(out, '..', 'game', 'assets', 'sound') + os.makedirs(out, exist_ok=True) + # Extract Sound Data + elf = lief.parse(file) + prefix = 'PCM_' + for sym in elf.dynamic_symbols: + if sym.name.startswith('PCM_'): + # Found Sound Symbol, Extract It + name = sym.name[len(prefix):] + print(f'Extracting Sound {name}...') + path = os.path.join(out, name + '.pcm') + data = bytes(elf.get_content_from_virtual_address(sym.value, sym.size)) + with open(path, 'wb') as file: + file.write(data) + +# Entrypoint if __name__ == '__main__': - main() + # Check Arguments + if len(sys.argv) < 2: + print(f'USAGE: {__file__} libminecraftpe.so') + sys.exit() + # Run + main(sys.argv[1]) + # Done + print('Done!') diff --git a/tools/setup_venv.py b/tools/setup_venv.py new file mode 100644 index 000000000..ae6010bfc --- /dev/null +++ b/tools/setup_venv.py @@ -0,0 +1,44 @@ +import os +import venv +import sys +import subprocess +import platform + +# Find Binary Directory +bin_dir = 'bin' +if platform.system() == 'Windows': + bin_dir = 'Scripts' + +# Paths +path = os.path.dirname(os.path.abspath(__file__)) +path = os.path.join(path, 'venv') +valid_file = os.path.join(path, '.valid') + +# Open In Virtualenv +def restart_in_venv(path): + print('Activating Virtualenv...') + py = os.path.basename(sys.executable) + py = os.path.join(path, bin_dir, py) + os.execv(py, [py] + sys.argv) + +# Create Virtualenv +def create_venv(path): + # Check If It Already Exists + if os.path.exists(valid_file): + return + # Build Environment + print('Creating Virtualenv...') + builder = venv.EnvBuilder(clear=True, symlinks=False, with_pip=True) + builder.create(path) + # Install LIEF + pip = 'pip' + if platform.system() == 'Windows': + pip += '.exe' + subprocess.run([os.path.join(path, bin_dir, pip), 'install', 'lief']) + # Mark As Created + open(valid_file, 'wb').close() + +# Run +if not sys.executable.startswith(path): + create_venv(path) + restart_in_venv(path) From c12b261e658882f625e6d7a31c1fcae07af4a89d Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Thu, 5 Jun 2025 21:31:51 -0500 Subject: [PATCH 006/293] Add "fuse" sound --- source/client/sound/sound_list.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source/client/sound/sound_list.h b/source/client/sound/sound_list.h index 70ae21ec2..fb39c1239 100644 --- a/source/client/sound/sound_list.h +++ b/source/client/sound/sound_list.h @@ -28,14 +28,15 @@ SOUND(step, wood, 2) SOUND(step, wood, 3) SOUND(step, wood, 4) -SOUND(random, splash, ) -SOUND(random, explode, ) SOUND(random, click, ) SOUND(random, door_close, ) SOUND(random, door_open, ) +SOUND(random, explode, ) +SOUND(random, fizz, ) +SOUND(random, fuse, ) SOUND(random, hurt, ) SOUND(random, pop, ) -SOUND(random, fizz, ) +SOUND(random, splash, ) SOUND(fire, fire, ) @@ -64,4 +65,4 @@ SOUND(mob, cowhurt, 3) SOUND(mob, chicken, 2) SOUND(mob, chicken, 3) SOUND(mob, chickenhurt, 1) -SOUND(mob, chickenhurt, 2) \ No newline at end of file +SOUND(mob, chickenhurt, 2) From 20d4beeacfb10d46ed69f707d6bbc227a99d8b7f Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Fri, 13 Jun 2025 22:04:10 -0500 Subject: [PATCH 007/293] Added /gamemode command (#159) - Other functional GameType/GameMode related cleanup Co-authored-by: Brent Da Mage --- source/network/ServerSideNetworkHandler.cpp | 72 +++++++++++++++++---- source/network/ServerSideNetworkHandler.hpp | 16 +++-- source/world/entity/LocalPlayer.cpp | 9 +++ source/world/entity/LocalPlayer.hpp | 1 + source/world/entity/Player.hpp | 4 +- source/world/gamemode/GameType.hpp | 3 +- source/world/item/Inventory.cpp | 22 ++++--- source/world/item/Inventory.hpp | 4 +- 8 files changed, 100 insertions(+), 31 deletions(-) diff --git a/source/network/ServerSideNetworkHandler.cpp b/source/network/ServerSideNetworkHandler.cpp index 6a5ea9303..f0633a91f 100644 --- a/source/network/ServerSideNetworkHandler.cpp +++ b/source/network/ServerSideNetworkHandler.cpp @@ -414,16 +414,17 @@ OnlinePlayer* ServerSideNetworkHandler::getPlayerByGUID(const RakNet::RakNetGUID void ServerSideNetworkHandler::setupCommands() { - m_commands["?"] = &ServerSideNetworkHandler::commandHelp; - m_commands["help"] = &ServerSideNetworkHandler::commandHelp; - m_commands["stats"] = &ServerSideNetworkHandler::commandStats; - m_commands["time"] = &ServerSideNetworkHandler::commandTime; - m_commands["seed"] = &ServerSideNetworkHandler::commandSeed; - m_commands["tp"] = &ServerSideNetworkHandler::commandTP; - m_commands["summon"] = &ServerSideNetworkHandler::commandSummon; + m_commands["?"] = &ServerSideNetworkHandler::commandHelp; + m_commands["help"] = &ServerSideNetworkHandler::commandHelp; + m_commands["stats"] = &ServerSideNetworkHandler::commandStats; + m_commands["time"] = &ServerSideNetworkHandler::commandTime; + m_commands["seed"] = &ServerSideNetworkHandler::commandSeed; + m_commands["tp"] = &ServerSideNetworkHandler::commandTP; + m_commands["summon"] = &ServerSideNetworkHandler::commandSummon; + m_commands["gamemode"] = &ServerSideNetworkHandler::commandGamemode; } -bool ServerSideNetworkHandler::checkPermissions(OnlinePlayer* player) +bool ServerSideNetworkHandler::_checkPermissions(OnlinePlayer* player) { if (player->m_pPlayer != m_pMinecraft->m_pLocalPlayer) { @@ -434,6 +435,22 @@ bool ServerSideNetworkHandler::checkPermissions(OnlinePlayer* player) return true; } +bool ServerSideNetworkHandler::_validateNum(OnlinePlayer* player, int value, int min, int max) +{ + if (value < min) + { + sendMessage(player, Util::format("The number you have entered (%d) is too small, it must be at least %d", value, min)); + return false; + } + else if (value > max) + { + sendMessage(player, Util::format("The number you have entered (%d) is too big, it must be at most %d", value, max)); + return false; + } + + return true; +} + void ServerSideNetworkHandler::commandHelp(OnlinePlayer* player, const std::vector& parms) { std::stringstream ss; @@ -479,7 +496,7 @@ void ServerSideNetworkHandler::commandTime(OnlinePlayer* player, const std::vect return; } - if (!checkPermissions(player)) return; + if (!_checkPermissions(player)) return; m_pLevel->setTime(t); @@ -517,7 +534,7 @@ void ServerSideNetworkHandler::commandTP(OnlinePlayer* player, const std::vector return; } - if (!checkPermissions(player)) return; + if (!_checkPermissions(player)) return; Vec3 pos = player->m_pPlayer->getPos(1.0f); @@ -564,7 +581,7 @@ void ServerSideNetworkHandler::commandSummon(OnlinePlayer* player, const std::ve return; } - if (!checkPermissions(player)) return; + if (!_checkPermissions(player)) return; std::string entityName; std::stringstream ss; @@ -643,3 +660,36 @@ void ServerSideNetworkHandler::commandSummon(OnlinePlayer* player, const std::ve sendMessage(player, ss.str()); } + +void ServerSideNetworkHandler::commandGamemode(OnlinePlayer* player, const std::vector& parms) +{ + if (!m_pLevel) + return; + + if (parms.size() != 1) + { + sendMessage(player, "Usage: /gamemode "); + return; + } + /*if (parms.size() < 1 || parms.size() > 2) + { + sendMessage(player, "Usage: /gamemode [player]"); + return; + }*/ + + if (!_checkPermissions(player)) return; + + Vec3 pos = player->m_pPlayer->getPos(1.0f); + + GameType gameMode; + std::stringstream ss; + ss.str(parms[0]); + ss >> (int&)gameMode; + + if (!_validateNum(player, gameMode, GAME_TYPES_MIN, GAME_TYPES_MAX)) + return; + + player->m_pPlayer->setPlayerGameType(gameMode); + + sendMessage(player, "Your game mode has been updated"); +} diff --git a/source/network/ServerSideNetworkHandler.hpp b/source/network/ServerSideNetworkHandler.hpp index ce0571909..ca56db636 100644 --- a/source/network/ServerSideNetworkHandler.hpp +++ b/source/network/ServerSideNetworkHandler.hpp @@ -33,7 +33,8 @@ typedef std::map OnlinePlayerMap; class ServerSideNetworkHandler : public NetEventCallback, public LevelListener { private: - bool checkPermissions(OnlinePlayer* player); + bool _checkPermissions(OnlinePlayer* player); + bool _validateNum(OnlinePlayer* player, int value, int min, int max); public: @@ -70,12 +71,13 @@ class ServerSideNetworkHandler : public NetEventCallback, public LevelListener void setupCommands(); // Commands - void commandHelp (OnlinePlayer*, const std::vector&); - void commandStats (OnlinePlayer*, const std::vector&); - void commandTime (OnlinePlayer*, const std::vector&); - void commandSeed (OnlinePlayer*, const std::vector&); - void commandTP (OnlinePlayer*, const std::vector&); - void commandSummon (OnlinePlayer*, const std::vector&); + void commandHelp (OnlinePlayer*, const std::vector&); + void commandStats (OnlinePlayer*, const std::vector&); + void commandTime (OnlinePlayer*, const std::vector&); + void commandSeed (OnlinePlayer*, const std::vector&); + void commandTP (OnlinePlayer*, const std::vector&); + void commandSummon (OnlinePlayer*, const std::vector&); + void commandGamemode (OnlinePlayer*, const std::vector&); public: Minecraft* m_pMinecraft; diff --git a/source/world/entity/LocalPlayer.cpp b/source/world/entity/LocalPlayer.cpp index 434adff13..db77d7b83 100644 --- a/source/world/entity/LocalPlayer.cpp +++ b/source/world/entity/LocalPlayer.cpp @@ -87,6 +87,15 @@ bool LocalPlayer::isImmobile() const return Player::isImmobile() || (m_pMinecraft->useController() && m_pMinecraft->m_pScreen); //!m_pMinecraft->m_bGrabbedMouse; // this works if we still set this when not using a mouse } +void LocalPlayer::setPlayerGameType(GameType gameType) +{ + // @HACK: This info should be updated / stored in one place, and one place only. + // Don't know what crack Notch was smoking. + m_pMinecraft->setGameMode(gameType); + + Player::setPlayerGameType(gameType); +} + void LocalPlayer::animateRespawn() { diff --git a/source/world/entity/LocalPlayer.hpp b/source/world/entity/LocalPlayer.hpp index e2a59af71..de0be882f 100644 --- a/source/world/entity/LocalPlayer.hpp +++ b/source/world/entity/LocalPlayer.hpp @@ -30,6 +30,7 @@ class LocalPlayer : public Player virtual bool isLocalPlayer() const override { return true; } virtual void drop(const ItemInstance* pItemInstance, bool b = false) override; virtual bool isImmobile() const override; + virtual void setPlayerGameType(GameType gameType) override; void calculateFlight(const Vec3& pos); void closeContainer(); //@HUH: oddly enough not a virtual/override diff --git a/source/world/entity/Player.hpp b/source/world/entity/Player.hpp index eea58dbcc..928994306 100644 --- a/source/world/entity/Player.hpp +++ b/source/world/entity/Player.hpp @@ -56,7 +56,7 @@ class Player : public Mob void drop(); float getDestroySpeed() const { return 1.0f; } int getInventorySlot(int x) const; - TilePos getRespawnPosition() { return m_respawnPos; } + TilePos getRespawnPosition() const { return m_respawnPos; } int getScore() const { return m_score; } void prepareCustomTextures(); void reallyDrop(ItemEntity* pEnt); @@ -68,7 +68,7 @@ class Player : public Mob void take(Entity* pEnt, int x); void touch(Entity* pEnt); GameType getPlayerGameType() const { return _playerGameType; } - void setPlayerGameType(GameType playerGameType) { _playerGameType = playerGameType; } + virtual void setPlayerGameType(GameType playerGameType) { _playerGameType = playerGameType; } bool isSurvival() const { return getPlayerGameType() == GAME_TYPE_SURVIVAL; } bool isCreative() const { return getPlayerGameType() == GAME_TYPE_CREATIVE; } ItemInstance* getSelectedItem() const; diff --git a/source/world/gamemode/GameType.hpp b/source/world/gamemode/GameType.hpp index b1f683368..77becfbeb 100644 --- a/source/world/gamemode/GameType.hpp +++ b/source/world/gamemode/GameType.hpp @@ -6,5 +6,6 @@ enum GameType GAME_TYPE_CREATIVE, GAME_TYPE_ADVENTURE, GAME_TYPE_SPECTATOR, - GAME_TYPES_MAX + GAME_TYPES_MIN = GAME_TYPE_SURVIVAL, + GAME_TYPES_MAX = GAME_TYPE_CREATIVE }; \ No newline at end of file diff --git a/source/world/item/Inventory.cpp b/source/world/item/Inventory.cpp index 606bc88a9..7f3a8cccf 100644 --- a/source/world/item/Inventory.cpp +++ b/source/world/item/Inventory.cpp @@ -5,7 +5,6 @@ Inventory::Inventory(Player* pPlayer) { m_pPlayer = pPlayer; m_selectedHotbarSlot = 0; - m_bIsSurvival = false; for (int i = 0; i < C_MAX_HOTBAR_ITEMS; i++) m_hotbar[i] = -1; @@ -13,8 +12,6 @@ Inventory::Inventory(Player* pPlayer) void Inventory::prepareCreativeInventory() { - m_bIsSurvival = false; - m_items.clear(); // Original list of items. @@ -86,7 +83,6 @@ void Inventory::prepareCreativeInventory() void Inventory::prepareSurvivalInventory() { - m_bIsSurvival = true; m_items.clear(); m_items.resize(C_NUM_SURVIVAL_SLOTS); @@ -105,10 +101,13 @@ void Inventory::prepareSurvivalInventory() int Inventory::getNumSlots() { - if (m_bIsSurvival) + switch (_getGameMode()) + { + case GAME_TYPE_SURVIVAL: return C_NUM_SURVIVAL_SLOTS; - - return getNumItems(); + default: + return getNumItems(); + } } int Inventory::getNumItems() @@ -132,7 +131,7 @@ void Inventory::clear() // but addResource's code is entirely different somehow. Did we write this from scratch? void Inventory::addItem(ItemInstance* pInst) { - if (!m_bIsSurvival) + if (_getGameMode() == GAME_TYPE_CREATIVE) { // Just get rid of the item. pInst->m_count = 0; @@ -293,7 +292,7 @@ void Inventory::setQuickSlotIndexByItemId(int slotNo, int itemID) if (slotNo < 0 || slotNo >= C_MAX_HOTBAR_ITEMS) return; - if (m_bIsSurvival) + if (_getGameMode() == GAME_TYPE_SURVIVAL) return; // TODO for (int i = 0; i < getNumItems(); i++) @@ -344,3 +343,8 @@ void Inventory::dropAll(bool butNotReally) } } } + +GameType Inventory::_getGameMode() const +{ + return m_pPlayer->getPlayerGameType(); +} \ No newline at end of file diff --git a/source/world/item/Inventory.hpp b/source/world/item/Inventory.hpp index acbd0b939..d91d2c100 100644 --- a/source/world/item/Inventory.hpp +++ b/source/world/item/Inventory.hpp @@ -3,6 +3,7 @@ #include #include "world/item/ItemInstance.hpp" #include "world/entity/Player.hpp" +#include "world/gamemode/GameType.hpp" class Entity; class Player; // in case we're included from Player.hpp @@ -52,12 +53,13 @@ class Inventory ItemInstance* getSelected() { return getSelectedItem(); } +private: + GameType _getGameMode() const; public: int m_selectedHotbarSlot; private: Player* m_pPlayer; - bool m_bIsSurvival; int m_hotbar[C_MAX_HOTBAR_ITEMS]; std::vector m_items; From 670f4c7f5b324dbf44a24212beda5b51462e2eca Mon Sep 17 00:00:00 2001 From: riall <71668864+break-core@users.noreply.github.com> Date: Sun, 15 Jun 2025 17:06:18 -0400 Subject: [PATCH 008/293] Creeper and CreeperRenderer implementation (#158) * Creeper and CreeperRenderer * Fix creeper rendering, use entity data, creeper summonable * Added missing Creeper sounds * Added music disc drops for Creepers Minor Mob bugfixes * Fixed Mob Pathfinding * Minor Creeper Optimizations * Make Monsters Not Agro on Creative Players - Fixed floating Creeper - Cleaned up model code for other mobs * Make Creepers Float Again --------- Co-authored-by: Brent Da Mage --- source/client/model/ChickenModel.cpp | 27 ++---- source/client/model/ChickenModel.hpp | 2 +- source/client/model/CowModel.cpp | 7 +- source/client/model/CreeperModel.cpp | 39 +++++--- source/client/model/CreeperModel.hpp | 1 + source/client/model/HumanoidModel.cpp | 19 ++-- source/client/model/ModelPart.cpp | 4 +- source/client/model/ModelPart.hpp | 4 +- source/client/model/QuadrupedModel.cpp | 21 ++--- source/client/model/QuadrupedModel.hpp | 2 +- .../renderer/entity/CreeperRenderer.cpp | 45 +++++++++- .../renderer/entity/CreeperRenderer.hpp | 1 + source/client/sound/sound_list.h | 31 ++++--- source/world/entity/Creeper.cpp | 88 +++++++++++++++++++ source/world/entity/Creeper.hpp | 30 +++++++ source/world/entity/Mob.cpp | 19 ++-- source/world/entity/MobFactory.cpp | 2 +- source/world/entity/Monster.cpp | 2 +- source/world/entity/Monster.hpp | 2 + source/world/entity/PathfinderMob.cpp | 2 +- source/world/level/Level.cpp | 36 ++++++-- source/world/level/Level.hpp | 7 +- 22 files changed, 290 insertions(+), 101 deletions(-) diff --git a/source/client/model/ChickenModel.cpp b/source/client/model/ChickenModel.cpp index 59755b294..655c065b4 100644 --- a/source/client/model/ChickenModel.cpp +++ b/source/client/model/ChickenModel.cpp @@ -10,25 +10,16 @@ ChickenModel::ChickenModel() : Model(64, 32), - m_head(0, 0), - m_unknown(0, 0), - m_body(0, 9), - m_leg1(26, 0), - m_leg2(26, 0), - m_wing1(24, 13), - m_wing2(24, 13), - m_beak(14, 0), - m_wattle(14, 4) // Yes, it's called a wattle. Look it up. + m_head(this, 0, 0), + //m_hair(this, 0, 0), + m_body(this, 0, 9), + m_leg1(this, 26, 0), + m_leg2(this, 26, 0), + m_wing1(this, 24, 13), + m_wing2(this, 24, 13), + m_beak(this, 14, 0), + m_wattle(this, 14, 4) // Yes, it's called a wattle. Look it up. { - m_head.setModel(this); - m_beak.setModel(this); - m_wattle.setModel(this); - m_body.setModel(this); - m_leg1.setModel(this); - m_leg2.setModel(this); - m_wing1.setModel(this); - m_wing2.setModel(this); - m_head.addBox(-2, -6, -2, 4, 6, 3); m_head.setPos(0, 15, -4); m_beak.addBox(-2, -4, -4, 4, 2, 2, 0); diff --git a/source/client/model/ChickenModel.hpp b/source/client/model/ChickenModel.hpp index 0027ed7ae..9d67df255 100644 --- a/source/client/model/ChickenModel.hpp +++ b/source/client/model/ChickenModel.hpp @@ -19,7 +19,7 @@ class ChickenModel : public Model private: ModelPart m_head; - ModelPart m_unknown; + //ModelPart m_hair; ModelPart m_body; ModelPart m_leg1; ModelPart m_leg2; diff --git a/source/client/model/CowModel.cpp b/source/client/model/CowModel.cpp index 25c099440..16434ce19 100644 --- a/source/client/model/CowModel.cpp +++ b/source/client/model/CowModel.cpp @@ -10,9 +10,7 @@ CowModel::CowModel() : QuadrupedModel(12, 0.0f) { - m_head = ModelPart(0, 0); - - m_head.setModel(this); + m_head = ModelPart(this, 0, 0); // head m_head.addBox(-4, -4, -6, 8, 8, 6); @@ -24,8 +22,7 @@ CowModel::CowModel() : m_head.texOffs(22, 0); m_head.addBox(4, -5, -4, 1, 3, 1); - m_body = ModelPart(18, 4); - m_body.setModel(this); + m_body = ModelPart(this, 18, 4); // torso m_body.addBox(-6, -10, -7, 12, 18, 10); diff --git a/source/client/model/CreeperModel.cpp b/source/client/model/CreeperModel.cpp index fceb7451b..a6e92eb6a 100644 --- a/source/client/model/CreeperModel.cpp +++ b/source/client/model/CreeperModel.cpp @@ -10,20 +10,14 @@ CreeperModel::CreeperModel() : Model(64, 32), - m_head(0, 0), - m_body(16, 16), - m_leg1(0, 16), - m_leg2(0, 16), - m_leg3(0, 16), - m_leg4(0, 16) + m_head(this, 0, 0), + //m_hair(this, 32, 0), + m_body(this, 16, 16), + m_leg1(this, 0, 16), + m_leg2(this, 0, 16), + m_leg3(this, 0, 16), + m_leg4(this, 0, 16) { - m_head.setModel(this); - m_body.setModel(this); - m_leg1.setModel(this); - m_leg2.setModel(this); - m_leg3.setModel(this); - m_leg4.setModel(this); - m_head.addBox(-4, -8, -4, 8, 8, 8); m_head.setPos(0, 4, 0); m_body.addBox(-4, 0, -2, 8, 12, 4); @@ -36,6 +30,25 @@ CreeperModel::CreeperModel() : m_leg3.setPos(-2, 16, -4); m_leg4.addBox(-2, 0, -2, 4, 6, 4); m_leg4.setPos(2, 16, -4); + + float g = 0.0f; + // Creepers have just always been floating in Java. + // Setting it to 6 fixes this, but makes the creeper look short. + int yo = 4; + m_head.addBox(-4, -8, -4, 8, 8, 8, g); + m_head.setPos(0, yo, 0); + //m_hair.addBox(-4, -8, -4, 8, 8, 8, g + 0.5f); + //m_hair.setPos(0, yo, 0); + m_body.addBox(-4, 0, -2, 8, 12, 4, g); + m_body.setPos(0, yo, 0); + m_leg1.addBox(-2, 0, -2, 4, 6, 4, g); + m_leg1.setPos(-2, 12 + yo, 4); + m_leg2.addBox(-2, 0, -2, 4, 6, 4, g); + m_leg2.setPos(2, 12 + yo, 4); + m_leg3.addBox(-2, 0, -2, 4, 6, 4, g); + m_leg3.setPos(-2, 12 + yo, -4); + m_leg4.addBox(-2, 0, -2, 4, 6, 4, g); + m_leg4.setPos(2, 12 + yo, -4); } CreeperModel::~CreeperModel() diff --git a/source/client/model/CreeperModel.hpp b/source/client/model/CreeperModel.hpp index d9226063c..230726a02 100644 --- a/source/client/model/CreeperModel.hpp +++ b/source/client/model/CreeperModel.hpp @@ -19,6 +19,7 @@ class CreeperModel : public Model private: ModelPart m_head; + //ModelPart m_hair; // wtf *is* this?? ModelPart m_body; ModelPart m_leg1; ModelPart m_leg2; diff --git a/source/client/model/HumanoidModel.cpp b/source/client/model/HumanoidModel.cpp index 6b255ab02..ae668aca8 100644 --- a/source/client/model/HumanoidModel.cpp +++ b/source/client/model/HumanoidModel.cpp @@ -11,12 +11,12 @@ HumanoidModel::HumanoidModel(float a, float b): Model(64, 32), - m_head(0, 0), - m_body(16, 16), - m_arm1(40, 16), - m_arm2(40, 16), - m_leg1(0, 16), - m_leg2(0, 16) + m_head(this, 0, 0), + m_body(this, 16, 16), + m_arm1(this, 40, 16), + m_arm2(this, 40, 16), + m_leg1(this, 0, 16), + m_leg2(this, 0, 16) { field_20 = false; m_bHoldingLeftHand = false; @@ -24,13 +24,6 @@ HumanoidModel::HumanoidModel(float a, float b): m_bSneaking = false; field_237 = false; - m_head.setModel(this); - m_body.setModel(this); - m_arm1.setModel(this); - m_arm2.setModel(this); - m_leg1.setModel(this); - m_leg2.setModel(this); - m_head.addBox(-4, -8, -4, 8, 8, 8, a); m_head.setPos(0, b, 0); m_body.addBox(-4, 0, -2, 8, 12, 4); diff --git a/source/client/model/ModelPart.cpp b/source/client/model/ModelPart.cpp index 61b2744a0..dfb40a7ac 100644 --- a/source/client/model/ModelPart.cpp +++ b/source/client/model/ModelPart.cpp @@ -10,12 +10,12 @@ #define MUL_DEG_TO_RAD (180.0f / float(M_PI)) // formerly known as Cube::c -ModelPart::ModelPart(int a, int b, float textureWidth, float textureHeight) +ModelPart::ModelPart(int a, int b) { _init(a, b); } -ModelPart::ModelPart(Model* model, int a, int b, float textureWidth, float textureHeight) +ModelPart::ModelPart(Model* model, int a, int b) { _init(a, b); setModel(model); diff --git a/source/client/model/ModelPart.hpp b/source/client/model/ModelPart.hpp index e6d9b1eba..104a2ae6a 100644 --- a/source/client/model/ModelPart.hpp +++ b/source/client/model/ModelPart.hpp @@ -18,8 +18,8 @@ class Model; class ModelPart { public: - ModelPart(int, int, float textureWidth = 64.0f, float textureHeight = 64.0f); - ModelPart(Model*, int, int, float textureWidth = 64.0f, float textureHeight = 64.0f); + ModelPart(int, int); + ModelPart(Model*, int, int); ModelPart(const std::string&); ~ModelPart(); diff --git a/source/client/model/QuadrupedModel.cpp b/source/client/model/QuadrupedModel.cpp index 6df32684c..9dcaf8313 100644 --- a/source/client/model/QuadrupedModel.cpp +++ b/source/client/model/QuadrupedModel.cpp @@ -10,24 +10,17 @@ QuadrupedModel::QuadrupedModel(int i, float f) : Model(64, 32), - m_head(0, 0), - m_unknown(0, 0), - m_body(28, 8), - m_leg1(0, 16), - m_leg2(0, 16), - m_leg3(0, 16), - m_leg4(0, 16) + m_head(this, 0, 0), + m_hair(this, 0, 0), + m_body(this, 28, 8), + m_leg1(this, 0, 16), + m_leg2(this, 0, 16), + m_leg3(this, 0, 16), + m_leg4(this, 0, 16) { field_28C = 8.0f; field_290 = 4.0f; - m_head.setModel(this); - m_body.setModel(this); - m_leg1.setModel(this); - m_leg2.setModel(this); - m_leg3.setModel(this); - m_leg4.setModel(this); - m_head.addBox(-4, -4, -8, 8, 8, 8, f); m_head.setPos(0, 18 - float(i), -6); m_body.addBox(-5, -10, -7, 10, 16, 8, f); diff --git a/source/client/model/QuadrupedModel.hpp b/source/client/model/QuadrupedModel.hpp index ab76446e8..7e110c38b 100644 --- a/source/client/model/QuadrupedModel.hpp +++ b/source/client/model/QuadrupedModel.hpp @@ -21,7 +21,7 @@ class QuadrupedModel : public Model protected: friend class PigModel; ModelPart m_head; - ModelPart m_unknown; + ModelPart m_hair; ModelPart m_body; ModelPart m_leg1; ModelPart m_leg2; diff --git a/source/client/renderer/entity/CreeperRenderer.cpp b/source/client/renderer/entity/CreeperRenderer.cpp index e793a2a16..cf825a448 100644 --- a/source/client/renderer/entity/CreeperRenderer.cpp +++ b/source/client/renderer/entity/CreeperRenderer.cpp @@ -17,11 +17,50 @@ CreeperRenderer::~CreeperRenderer() int CreeperRenderer::getOverlayColor(Mob* pMob, float a, float b) { - // TODO - return 0; + Creeper* pCreeper = (Creeper*)pMob; + + float step = pCreeper->getSwelling(b); + + if (static_cast(step * 10.0f) % 2 == 0) + { + return 0; + } + + int _a = step * 0.2f * 255.0f; + + if (_a < 0) { _a = 0; } + + if (_a > 255) { _a = 255; } + + int red = 255; + int green = 255; + int blue = 255; + + return _a << 24 | red << 16 | green << 8 | blue; } void CreeperRenderer::scale(Mob* pMob, float f) { - // TODO + Creeper* pCreeper = (Creeper*)pMob; + + float g = pCreeper->getSwelling(f); + float wobble = 1.0f + Mth::sin(g * 100.0f) * g * 0.01f; + + if (g < 0.0f) + { + g = 0.0f; + } + + if (g > 1.0f) + { + g = 1.0f; + } + + g *= g; + g *= g; + + float s = (1.0f + g * 0.4f) * wobble; + float hs = (1.0f + g * 0.1f) / wobble; + + glScalef(s, hs, s); } diff --git a/source/client/renderer/entity/CreeperRenderer.hpp b/source/client/renderer/entity/CreeperRenderer.hpp index 5ab6f233d..89923edf3 100644 --- a/source/client/renderer/entity/CreeperRenderer.hpp +++ b/source/client/renderer/entity/CreeperRenderer.hpp @@ -8,6 +8,7 @@ #pragma once #include "MobRenderer.hpp" +#include "world/entity/Creeper.hpp" class CreeperRenderer : public MobRenderer { diff --git a/source/client/sound/sound_list.h b/source/client/sound/sound_list.h index fb39c1239..0c0f38da5 100644 --- a/source/client/sound/sound_list.h +++ b/source/client/sound/sound_list.h @@ -45,14 +45,10 @@ SOUND(damage, fallbig, 2) SOUND(damage, fallsmall, ) -SOUND(mob, pig, 1) -SOUND(mob, pig, 2) -SOUND(mob, pig, 3) -SOUND(mob, pigdeath, ) - -SOUND(mob, sheep, 1) -SOUND(mob, sheep, 2) -SOUND(mob, sheep, 3) +SOUND(mob, chicken, 2) +SOUND(mob, chicken, 3) +SOUND(mob, chickenhurt, 1) +SOUND(mob, chickenhurt, 2) SOUND(mob, cow, 1) SOUND(mob, cow, 2) @@ -62,7 +58,18 @@ SOUND(mob, cowhurt, 1) SOUND(mob, cowhurt, 2) SOUND(mob, cowhurt, 3) -SOUND(mob, chicken, 2) -SOUND(mob, chicken, 3) -SOUND(mob, chickenhurt, 1) -SOUND(mob, chickenhurt, 2) +SOUND(mob, creeper, 1) +SOUND(mob, creeper, 2) +SOUND(mob, creeper, 3) +SOUND(mob, creeper, 4) +SOUND(mob, creeperdeath, ) + +SOUND(mob, pig, 1) +SOUND(mob, pig, 2) +SOUND(mob, pig, 3) +SOUND(mob, pigdeath, ) + +SOUND(mob, sheep, 1) +SOUND(mob, sheep, 2) +SOUND(mob, sheep, 3) + diff --git a/source/world/entity/Creeper.cpp b/source/world/entity/Creeper.cpp index e69de29bb..a63e33e91 100644 --- a/source/world/entity/Creeper.cpp +++ b/source/world/entity/Creeper.cpp @@ -0,0 +1,88 @@ +#include "world/entity/Creeper.hpp" + +Creeper::Creeper(Level* pLevel) : Monster(pLevel) +{ + m_pDescriptor = &EntityTypeDescriptor::creeper; + field_C8 = RENDER_CREEPER; + m_texture = "mob/creeper.png"; + m_swell = 0; + m_oldSwell = 0; + + _defineEntityData(); +} + +void Creeper::_defineEntityData() +{ + m_entityData.define(DATA_SWELL_DIR, -1); +} + +void Creeper::tick() +{ + m_oldSwell = m_swell; + if (m_pLevel->m_bIsMultiplayer) + { + int swellDir = getSwellDir(); + if (swellDir > 0 && m_swell == 0) + { + m_pLevel->playSound(this, "random.fuse", 1.0f, 0.5f); + } + + m_swell += swellDir; + + if (m_swell < 0) + { + m_swell = 0; + } + else if (m_swell > MAX_SWELL) + { + m_swell = MAX_SWELL; + } + } + + Monster::tick(); +} + +void Creeper::die(Entity* pCulprit) +{ + Monster::die(pCulprit); + + if (pCulprit->getDescriptor().isType(EntityType::SKELETON)) + { + spawnAtLocation(Item::record_01->m_itemID + m_random.nextInt(2), 1); + } +} + +void Creeper::checkHurtTarget(Entity* pEnt, float f) +{ + int swellDir = getSwellDir(); + if (swellDir <= 0 && f < 3.0f || swellDir > 0 && f < 7.0f) + { + if (m_swell == 0) + { + m_pLevel->playSound(this, "random.fuse", 1.0f, 0.5f); + } + + setSwellDir(1); + m_swell++; + if (m_swell >= MAX_SWELL) + { + m_pLevel->explode(this, m_pos, 3.0f); + remove(); + } + + m_bHoldGround = true; + } + else + { + setSwellDir(-1); + m_swell--; + if (m_swell < 0) { + m_swell = 0; + } + } +} + +float Creeper::getSwelling(float f) const +{ + return (m_oldSwell + (m_swell - m_oldSwell) * f) / 28.0f; +} \ No newline at end of file diff --git a/source/world/entity/Creeper.hpp b/source/world/entity/Creeper.hpp index e69de29bb..c24d6ad46 100644 --- a/source/world/entity/Creeper.hpp +++ b/source/world/entity/Creeper.hpp @@ -0,0 +1,30 @@ +#pragma once + +#include "world/entity/Monster.hpp" + +#define DATA_SWELL_DIR (16) +#define MAX_SWELL (30) + +class Creeper : public Monster +{ +public: + Creeper(Level* pLevel); + + void tick() override; + std::string getHurtSound() const override { return "mob.creeper"; } + std::string getDeathSound() const override { return "mob.creeperdeath"; } + float getSwelling(float f) const; + int getSwellDir() const { return m_entityData.get(DATA_SWELL_DIR); } + void setSwellDir(int value) { m_entityData.set(DATA_SWELL_DIR, value); } + int getDeathLoot() const override { return ITEM_SULPHUR; } + + virtual void die(Entity* pCulprit) override; + virtual void checkHurtTarget(Entity*, float) override; + +private: + void _defineEntityData(); + +public: + int m_swell; + int m_oldSwell; +}; \ No newline at end of file diff --git a/source/world/entity/Mob.cpp b/source/world/entity/Mob.cpp index 7b932cd54..37ffab763 100644 --- a/source/world/entity/Mob.cpp +++ b/source/world/entity/Mob.cpp @@ -671,14 +671,23 @@ void Mob::lookAt(Entity* pEnt, float a3, float a4) float diffX = pEnt->m_pos.x - m_pos.x; float diffZ = pEnt->m_pos.z - m_pos.z; - float q1 = (pEnt->m_hitbox.min.y + pEnt->m_hitbox.max.y) / 2 - (m_pos.y + getHeadHeight()); + float q1; + if (pEnt->getDescriptor().hasCategory(EntityCategories::MOB)) + { + Mob* pMob = (Mob*)pEnt; + q1 = pMob->m_pos.y + pMob->getHeadHeight() - (m_pos.y + getHeadHeight()); + } + else + { + q1 = (pEnt->m_hitbox.min.y + pEnt->m_hitbox.max.y) / 2 - (m_pos.y + getHeadHeight()); + } float p1 = Mth::sqrt(diffX * diffX + diffZ * diffZ); float x1 = atan2f(diffZ, diffX); float x2 = atan2f(q1, p1); - setRot(Vec2(-rotlerp(m_rot.y, x2 * 180.0f / float(M_PI), a4), - rotlerp(m_rot.x, x1 * 180.0f / float(M_PI) - 90.0f, a3))); + setRot(Vec2(rotlerp(m_rot.x, x1 * 180.0f / float(M_PI) - 90.0f, a4), + -rotlerp(m_rot.y, x2 * 180.0f / float(M_PI), a3))); } bool Mob::canSpawn() @@ -773,7 +782,7 @@ void Mob::updateAi() if (m_random.nextFloat() < 0.02f) { - Entity* nearestPlayer = m_pLevel->getNearestPlayer(this, 8.0f); + Entity* nearestPlayer = m_pLevel->getNearestPlayer(*this, 8.0f); if (nearestPlayer) { m_pEntLookedAt = nearestPlayer; @@ -835,7 +844,7 @@ void Mob::checkDespawn(Mob* nearestMob) void Mob::checkDespawn() { - Mob* nearestPlayer = m_pLevel->getNearestPlayer(this, -1.0f); + Mob* nearestPlayer = m_pLevel->getNearestPlayer(*this, -1.0f); checkDespawn(nearestPlayer); } diff --git a/source/world/entity/MobFactory.cpp b/source/world/entity/MobFactory.cpp index 01b232ddf..9e8ede63d 100644 --- a/source/world/entity/MobFactory.cpp +++ b/source/world/entity/MobFactory.cpp @@ -13,8 +13,8 @@ ENT(COW, Cow) \ ENT(PIG, Pig) \ ENT(SHEEP, Sheep) \ + ENT(CREEPER, Creeper) \ //ENT(ZOMBIE, Zombie) \ - //ENT(CREEPER, Creeper) \ //ENT(SKELETON, Skeleton) \ //ENT(SPIDER, Spider) \ //ENT(PIG_ZOMBIE, PigZombie) diff --git a/source/world/entity/Monster.cpp b/source/world/entity/Monster.cpp index 25a7a0296..3e9048ea7 100644 --- a/source/world/entity/Monster.cpp +++ b/source/world/entity/Monster.cpp @@ -31,7 +31,7 @@ void Monster::tick() Entity* Monster::findAttackTarget() { - Player* player = m_pLevel->getNearestPlayer(this, 16.0f); + Player* player = m_pLevel->getNearestAttackablePlayer(*this, 16.0f); if (player && canSee(player)) { diff --git a/source/world/entity/Monster.hpp b/source/world/entity/Monster.hpp index daa76b43f..51c68bc33 100644 --- a/source/world/entity/Monster.hpp +++ b/source/world/entity/Monster.hpp @@ -1,3 +1,5 @@ +#pragma once + #include "world/entity/PathfinderMob.hpp" #include "world/level/Level.hpp" diff --git a/source/world/entity/PathfinderMob.cpp b/source/world/entity/PathfinderMob.cpp index 18e2e5473..270503852 100644 --- a/source/world/entity/PathfinderMob.cpp +++ b/source/world/entity/PathfinderMob.cpp @@ -212,7 +212,7 @@ void PathfinderMob::updateAi() lookAt(m_pAttackTarget, MAX_TURN, MAX_TURN); // if we hit a wall while moving - if (m_bHorizontalCollision && !isPathFinding()) + if (m_bHorizontalCollision && isPathFinding()) m_bJumping = true; // if we're in water, try to swim up diff --git a/source/world/level/Level.cpp b/source/world/level/Level.cpp index 084d50ffd..46842a3a5 100644 --- a/source/world/level/Level.cpp +++ b/source/world/level/Level.cpp @@ -750,12 +750,7 @@ std::vector* Level::getLightsToUpdate() return &m_lightUpdates; } -Player* Level::getNearestPlayer(const Entity* entity, float f) const -{ - return getNearestPlayer(entity->m_pos, f); -} - -Player* Level::getNearestPlayer(const Vec3& pos, float maxDist) const +Player* Level::_getNearestPlayer(const Vec3& source, float maxDist, bool onlyFindAttackable) const { float dist = -1.0f; Player* pPlayer = nullptr; @@ -763,7 +758,14 @@ Player* Level::getNearestPlayer(const Vec3& pos, float maxDist) const for (std::vector::const_iterator it = m_players.begin(); it != m_players.end(); it++) { Player* player = *it; - float ldist = player->distanceToSqr(pos); + + if (onlyFindAttackable) + { + if (player->isCreative()) + continue; + } + + float ldist = player->distanceToSqr(source); if ((maxDist < 0.0f || ldist < maxDist * maxDist) && (dist == -1.0f || dist > ldist)) { pPlayer = player; @@ -774,6 +776,26 @@ Player* Level::getNearestPlayer(const Vec3& pos, float maxDist) const return pPlayer; } +Player* Level::getNearestPlayer(const Entity& source, float maxDist) const +{ + return getNearestPlayer(source.m_pos, maxDist, false); +} + +Player* Level::getNearestPlayer(const Vec3& source, float maxDist, bool findAnyNearPlayer = false) const +{ + return _getNearestPlayer(source, maxDist, false); // don't know what findAnyNearPlayer is actually supposed to do +} + +Player* Level::getNearestAttackablePlayer(const Entity& source, float maxDist) const +{ + return getNearestAttackablePlayer(source.m_pos, maxDist, &source); +} + +Player* Level::getNearestAttackablePlayer(const Vec3& source, float maxDist, const Entity* sourceEntity = nullptr) const +{ + return _getNearestPlayer(source, maxDist, true); +} + bool Level::containsFireTile(const AABB& aabb) { TilePos min(aabb.min), diff --git a/source/world/level/Level.hpp b/source/world/level/Level.hpp index 53c0babb1..416ba5c4c 100644 --- a/source/world/level/Level.hpp +++ b/source/world/level/Level.hpp @@ -43,6 +43,7 @@ class Level : public LevelSource private: // @NOTE: LevelListeners do NOT get updated here void _setTime(int32_t time) { m_levelData.setTime(time); } + Player* _getNearestPlayer(const Vec3&, float, bool) const; public: Level(LevelStorage* pStor, const std::string& str, int32_t seed, int version, Dimension* pDimension = nullptr); @@ -164,8 +165,10 @@ class Level : public LevelSource const LevelData* getLevelData() const { return &m_levelData; } AABBVector* getCubes(const Entity* pEnt, const AABB& aabb); std::vector* getLightsToUpdate(); - Player* getNearestPlayer(const Entity*, float) const; - Player* getNearestPlayer(const Vec3& pos, float) const; + Player* getNearestPlayer(const Entity&, float) const; + Player* getNearestPlayer(const Vec3& pos, float, bool) const; + Player* getNearestAttackablePlayer(const Entity&, float) const; + Player* getNearestAttackablePlayer(const Vec3& pos, float, const Entity*) const; // unused redstone stuff int getSignal(const TilePos& pos, Facing::Name face) const; From 1981a3c2804b99ec35005808e11648035e37ce7b Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Tue, 17 Jun 2025 22:40:38 -0500 Subject: [PATCH 009/293] Fixed bug preventing interaction with no item in-hand (#164) * Fixed bug preventing interaction with no item in-hand * Cleaned up ItemInstance null handling * Fixed Player::isUsingItem() logic --------- Co-authored-by: Brent Da Mage --- source/client/app/Minecraft.cpp | 38 ++++------ source/client/gui/Gui.cpp | 7 +- .../screens/IngameBlockSelectionScreen.cpp | 5 +- .../client/player/input/MouseBuildInput.cpp | 12 ++-- .../client/player/input/MouseBuildInput.hpp | 4 ++ .../client/player/input/UnifiedTurnBuild.cpp | 3 +- source/client/renderer/ItemInHandRenderer.cpp | 4 +- source/world/entity/Player.cpp | 2 +- source/world/entity/Player.hpp | 2 +- source/world/item/Inventory.cpp | 11 +-- source/world/item/ItemInstance.cpp | 69 +++++++++++-------- source/world/item/ItemInstance.hpp | 10 ++- 12 files changed, 87 insertions(+), 80 deletions(-) diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp index fbd16a5ef..0bb5029ed 100644 --- a/source/client/app/Minecraft.cpp +++ b/source/client/app/Minecraft.cpp @@ -270,7 +270,8 @@ void Minecraft::handleBuildAction(const BuildActionIntention& action) { LocalPlayer* player = m_pLocalPlayer; bool canInteract = getTimeMs() - m_lastInteractTime >= 200; - if (player->isUsingItem()) return; + // This logic is present in 0.9.0, but just does not make any sense being here. + //if (player->isUsingItem()) return; if (action.isDestroyStart() || action.isAttack()) { @@ -350,13 +351,7 @@ void Minecraft::handleBuildAction(const BuildActionIntention& action) else if (action.isPlace() && canInteract) { ItemInstance* pItem = getSelectedItem(); - if (pItem && - m_pGameMode->useItemOn( - player, - m_pLevel, - pItem->m_itemID <= 0 ? nullptr : pItem, - m_hitResult.m_tilePos, - m_hitResult.m_hitSide)) + if (m_pGameMode->useItemOn(player, m_pLevel, pItem, m_hitResult.m_tilePos, m_hitResult.m_hitSide)) { bInteract = false; @@ -366,7 +361,7 @@ void Minecraft::handleBuildAction(const BuildActionIntention& action) if (isOnline()) { - if (pItem->m_itemID > C_MAX_TILES || pItem->m_itemID < 0) + if (ItemInstance::isNull(pItem) || pItem->m_itemID > C_MAX_TILES) return; TilePos tp(m_hitResult.m_tilePos); @@ -480,7 +475,7 @@ void Minecraft::tickInput() else if (getOptions()->isKey(KM_DROP, keyCode)) { ItemInstance *item = m_pLocalPlayer->m_pInventory->getSelected(); - if (item != nullptr) + if (!ItemInstance::isNull(item)) { ItemInstance itemDrop = m_pLocalPlayer->isSurvival() ? item->remove(1) : ItemInstance(*item); itemDrop.m_count = 1; @@ -1181,22 +1176,19 @@ ItemInstance* Minecraft::getSelectedItem() { ItemInstance* pInst = m_pLocalPlayer->getSelectedItem(); - if (!pInst) + if (ItemInstance::isNull(pInst)) return nullptr; - if (m_pGameMode->isSurvivalType()) - return pInst; - - // Create new "unlimited" ItemInstance for Creative mode - - if (pInst->isNull()) - return nullptr; - - m_CurrItemInstance.m_itemID = pInst->m_itemID; - m_CurrItemInstance.m_count = 999; - m_CurrItemInstance.setAuxValue(pInst->getAuxValue()); + if (m_pGameMode->isCreativeType()) + { + // Create new "unlimited" ItemInstance for Creative mode + m_CurrItemInstance.m_itemID = pInst->m_itemID; + m_CurrItemInstance.m_count = 999; + m_CurrItemInstance.setAuxValue(pInst->getAuxValue()); + return &m_CurrItemInstance; + } - return &m_CurrItemInstance; + return pInst; } int Minecraft::getFpsIntlCounter() diff --git a/source/client/gui/Gui.cpp b/source/client/gui/Gui.cpp index 8f9a7a9fb..d8e8f31e9 100644 --- a/source/client/gui/Gui.cpp +++ b/source/client/gui/Gui.cpp @@ -417,7 +417,7 @@ void Gui::renderSlot(int slot, int x, int y, float f) Inventory* pInv = m_pMinecraft->m_pLocalPlayer->m_pInventory; ItemInstance* pInst = pInv->getQuickSlotItem(slot); - if (pInst == nullptr || pInst->m_itemID <= 0) + if (ItemInstance::isNull(pInst)) return; float var6 = ((float)pInst->m_popTime) - f; @@ -442,10 +442,7 @@ void Gui::renderSlotOverlay(int slot, int x, int y, float f) Inventory* pInv = m_pMinecraft->m_pLocalPlayer->m_pInventory; ItemInstance* pInst = pInv->getQuickSlotItem(slot); - if (!pInst) - return; - - if (!pInst->m_itemID) + if (ItemInstance::isNull(pInst)) return; ItemRenderer::renderGuiItemOverlay(m_pMinecraft->m_pFont, m_pMinecraft->m_pTextures, pInst, x, y); diff --git a/source/client/gui/screens/IngameBlockSelectionScreen.cpp b/source/client/gui/screens/IngameBlockSelectionScreen.cpp index 9af461270..1d22a4ef2 100644 --- a/source/client/gui/screens/IngameBlockSelectionScreen.cpp +++ b/source/client/gui/screens/IngameBlockSelectionScreen.cpp @@ -99,10 +99,7 @@ void IngameBlockSelectionScreen::init() void IngameBlockSelectionScreen::renderSlot(int index, int x, int y, float f) { ItemInstance* pItem = getInventory()->getItem(index); - if (!pItem) - return; - - if (!pItem->m_itemID) + if (ItemInstance::isNull(pItem)) return; ItemRenderer::renderGuiItem(m_pMinecraft->m_pFont, m_pMinecraft->m_pTextures, pItem, x, y, true); diff --git a/source/client/player/input/MouseBuildInput.cpp b/source/client/player/input/MouseBuildInput.cpp index d65707ed2..41cf477fe 100644 --- a/source/client/player/input/MouseBuildInput.cpp +++ b/source/client/player/input/MouseBuildInput.cpp @@ -9,6 +9,13 @@ MouseBuildInput::MouseBuildInput() m_lastButtonStates[i] = false; } +void MouseBuildInput::_updateLastButtonStates() +{ + m_lastButtonStates[BUTTON_LEFT] = Mouse::isButtonDown(BUTTON_LEFT); + m_lastButtonStates[BUTTON_RIGHT] = Mouse::isButtonDown(BUTTON_RIGHT); + m_lastButtonStates[BUTTON_MIDDLE] = Mouse::isButtonDown(BUTTON_MIDDLE); +} + bool MouseBuildInput::tickBuild(Player* player, BuildActionIntention* buildActionIntention) { bool wroteIntention = false; @@ -61,10 +68,7 @@ bool MouseBuildInput::tickBuild(Player* player, BuildActionIntention* buildActio *buildActionIntention = BuildActionIntention(intent); } - // Log last button states - m_lastButtonStates[BUTTON_LEFT] = Mouse::isButtonDown(BUTTON_LEFT); - m_lastButtonStates[BUTTON_RIGHT] = Mouse::isButtonDown(BUTTON_RIGHT); - m_lastButtonStates[BUTTON_MIDDLE] = Mouse::isButtonDown(BUTTON_MIDDLE); + _updateLastButtonStates(); return wroteIntention; } \ No newline at end of file diff --git a/source/client/player/input/MouseBuildInput.hpp b/source/client/player/input/MouseBuildInput.hpp index 6d47f8998..90e909422 100644 --- a/source/client/player/input/MouseBuildInput.hpp +++ b/source/client/player/input/MouseBuildInput.hpp @@ -12,6 +12,10 @@ class MouseBuildInput : public IBuildInput public: MouseBuildInput(); +private: + void _updateLastButtonStates(); + +public: virtual bool tickBuild(Player* player, BuildActionIntention* buildActionIntention) override; }; diff --git a/source/client/player/input/UnifiedTurnBuild.cpp b/source/client/player/input/UnifiedTurnBuild.cpp index be3bee3b4..e3c64d287 100644 --- a/source/client/player/input/UnifiedTurnBuild.cpp +++ b/source/client/player/input/UnifiedTurnBuild.cpp @@ -182,7 +182,8 @@ bool UnifiedTurnBuild::tickBuild(Player* pPlayer, BuildActionIntention* pIntenti intent = BuildActionIntention::INTERACT; wroteIntention = true; } - else */if (field_24 /* && pPlayer->isUsingItem()*/) // Holds off on acknowledging interact intent until the user is absolutely sure a tick later + // Holds off on acknowledging interact intent until the user is absolutely sure a tick later + else */if (field_24 /*&& pPlayer->isUsingItem()*/) // Adding pPlayer->isUsingItem() makes player break blocks way too fast when not holding items { intent = BuildActionIntention::TOUCH_HOLD_CONTINUE; wroteIntention = true; diff --git a/source/client/renderer/ItemInHandRenderer.cpp b/source/client/renderer/ItemInHandRenderer.cpp index 98c77ba81..921f36367 100644 --- a/source/client/renderer/ItemInHandRenderer.cpp +++ b/source/client/renderer/ItemInHandRenderer.cpp @@ -41,7 +41,7 @@ void ItemInHandRenderer::itemUsed() void ItemInHandRenderer::renderItem(ItemInstance* inst) { #ifndef ORIGINAL_CODE - if (inst->isNull()) + if (ItemInstance::isNull(inst)) return; #endif @@ -197,7 +197,7 @@ void ItemInHandRenderer::render(float f) float fAnim = pLP->getAttackAnim(f); constexpr float d = 0.8f; - if (!pItem->isNull()) + if (!ItemInstance::isNull(pItem)) { glTranslatef(-0.4f * Mth::sin(float(M_PI) * Mth::sqrt(fAnim)), 0.2f * Mth::sin(2.0f * float(M_PI) * Mth::sqrt(fAnim)), -0.2f * Mth::sin(float(M_PI) * fAnim)); glTranslatef(0.7f * d, -0.65f * d - (1.0f - h) * 0.6f, -0.9f * d); diff --git a/source/world/entity/Player.cpp b/source/world/entity/Player.cpp index d995bf56e..22a0c13e7 100644 --- a/source/world/entity/Player.cpp +++ b/source/world/entity/Player.cpp @@ -250,7 +250,7 @@ void Player::displayClientMessage(const std::string& msg) void Player::drop(const ItemInstance* pItemInstance, bool b) { - if (pItemInstance->isNull()) + if (ItemInstance::isNull(pItemInstance)) return; ItemEntity* pItemEntity = new ItemEntity(m_pLevel, Vec3(m_pos.x, m_pos.y - 0.3f + getHeadHeight(), m_pos.z), pItemInstance); diff --git a/source/world/entity/Player.hpp b/source/world/entity/Player.hpp index 928994306..03ebe0091 100644 --- a/source/world/entity/Player.hpp +++ b/source/world/entity/Player.hpp @@ -72,7 +72,7 @@ class Player : public Mob bool isSurvival() const { return getPlayerGameType() == GAME_TYPE_SURVIVAL; } bool isCreative() const { return getPlayerGameType() == GAME_TYPE_CREATIVE; } ItemInstance* getSelectedItem() const; - bool isUsingItem() const { return false && !getSelectedItem()->isNull(); } + bool isUsingItem() const { return !ItemInstance::isNull(getSelectedItem()); } // QUIRK: Yes, I did mean it like that, as did Mojang. #pragma GCC diagnostic push diff --git a/source/world/item/Inventory.cpp b/source/world/item/Inventory.cpp index 7f3a8cccf..cf69f7264 100644 --- a/source/world/item/Inventory.cpp +++ b/source/world/item/Inventory.cpp @@ -226,7 +226,7 @@ int Inventory::getQuickSlotItemId(int slotNo) int idx = m_hotbar[slotNo]; ItemInstance* pInst = getItem(idx); - if (!pInst) + if (ItemInstance::isNull(pInst)) return -1; return pInst->m_itemID; @@ -238,13 +238,8 @@ ItemInstance* Inventory::getQuickSlotItem(int slotNo) return nullptr; ItemInstance* pInst = getItem(m_hotbar[slotNo]); - if (!pInst) - return nullptr; - - if (pInst->m_itemID == 0) - return nullptr; - return pInst; + return !ItemInstance::isNull(pInst) ? pInst : nullptr; } ItemInstance* Inventory::getSelectedItem() @@ -324,7 +319,7 @@ void Inventory::selectItemById(int itemID, int maxHotBarSlot) int Inventory::getAttackDamage(Entity* pEnt) { ItemInstance* pInst = getSelected(); - if (!pInst) + if (ItemInstance::isNull(pInst)) return 1; return pInst->getAttackDamage(pEnt); diff --git a/source/world/item/ItemInstance.cpp b/source/world/item/ItemInstance.cpp index 388369260..762f0a193 100644 --- a/source/world/item/ItemInstance.cpp +++ b/source/world/item/ItemInstance.cpp @@ -151,29 +151,6 @@ bool ItemInstance::isStackedByData() return getItem()->isStackedByData(); } -bool ItemInstance::matches(ItemInstance* other) const -{ - return this->getAuxValue() == other->getAuxValue() && - this->m_count == other->m_count && - this->m_itemID == other->m_itemID; -} - -bool ItemInstance::matches(ItemInstance* a1, ItemInstance* a2) -{ - if (a1 == a2 && a1 == nullptr) - return true; - - if (a1 == nullptr || a2 == nullptr) - return false; - - return a1->matches(a2); -} - -int ItemInstance::getAttackDamage(Entity *pEnt) -{ - return getItem()->getAttackDamage(pEnt); -} - void ItemInstance::mineBlock(const TilePos& pos, Facing::Name face) { return getItem()->mineBlock(this, pos, face); @@ -212,18 +189,54 @@ bool ItemInstance::useOn(Player* player, Level* level, const TilePos& pos, Facin return getItem()->useOn(this, player, level, pos, face); } +int ItemInstance::getAttackDamage(Entity* pEnt) +{ + return getItem()->getAttackDamage(pEnt); +} + bool ItemInstance::isNull() const { // 0.9.2 if (m_itemID <= 0) // m_field_10, assuming this is m_itemID return true; - if (m_auxValue != 0) - return false; - if (m_count != 0) - return false; - if (m_popTime != 0) + if (m_auxValue != 0 || + m_count != 0 || + m_popTime != 0) + { return false; + } return true; // isNull } + +bool ItemInstance::isNull(const ItemInstance* item) +{ + return item == nullptr || item->isNull(); +} + +bool ItemInstance::matches(const ItemInstance* a1, const ItemInstance* a2) +{ + if (a1 == a2 && a1 == nullptr) + return true; + + if (a1 == nullptr || a2 == nullptr) + return false; + + return a1 == a2; +} + +bool ItemInstance::operator==(const ItemInstance& other) const +{ + return this->getAuxValue() == other.getAuxValue() && + this->m_count == other.m_count && + this->m_itemID == other.m_itemID; +} + +bool ItemInstance::operator!=(const ItemInstance& other) const +{ + // doing this is likely more efficient than inverting the result of == after the fact + return this->getAuxValue() != other.getAuxValue() || + this->m_count != other.m_count || + this->m_itemID != other.m_itemID; +} \ No newline at end of file diff --git a/source/world/item/ItemInstance.hpp b/source/world/item/ItemInstance.hpp index 5dab7e8b5..9c27175b7 100644 --- a/source/world/item/ItemInstance.hpp +++ b/source/world/item/ItemInstance.hpp @@ -52,7 +52,6 @@ class ItemInstance bool isDamaged(); bool isStackable(); bool isStackedByData(); - bool matches(ItemInstance*) const; void mineBlock(const TilePos& pos, Facing::Name face); ItemInstance remove(int amt); void setDescriptionId(const std::string&); @@ -64,12 +63,17 @@ class ItemInstance Item* getItem() const; ItemInstance* copy(); - static bool matches(ItemInstance*, ItemInstance*); - // v0.2.0 int getAttackDamage(Entity *pEnt); bool isNull() const; + // @NOTE: Won't this be ambiguous with the non-static method? + static bool isNull(const ItemInstance*); + static bool matches(const ItemInstance*, const ItemInstance*); + + bool operator==(const ItemInstance&) const; + bool operator!=(const ItemInstance&) const; + public: int m_count; int m_popTime; From 19258155b6a4c1960ab045ad56968db4d1e4b90c Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Wed, 18 Jun 2025 22:55:36 -0500 Subject: [PATCH 010/293] Player Reach Bugfixes (#165) * Fixed a bug causing players in Creative mode to be able to punch entities through blocks * Cleaned up block and entity reach for GameModes * Fixed null pointer dereference in Creeper::die() Co-authored-by: Brent Da Mage --- source/client/renderer/GameRenderer.cpp | 29 ++++++++++++------------ source/client/renderer/GameRenderer.hpp | 2 +- source/world/entity/Creeper.cpp | 2 +- source/world/gamemode/CreativeMode.hpp | 2 +- source/world/gamemode/GameMode.cpp | 30 +++++++++++++++---------- source/world/gamemode/GameMode.hpp | 4 +++- source/world/gamemode/SurvivalMode.hpp | 3 ++- 7 files changed, 41 insertions(+), 31 deletions(-) diff --git a/source/client/renderer/GameRenderer.cpp b/source/client/renderer/GameRenderer.cpp index e6b1afddd..9cbfffd81 100644 --- a/source/client/renderer/GameRenderer.cpp +++ b/source/client/renderer/GameRenderer.cpp @@ -30,7 +30,7 @@ void GameRenderer::_init() field_8 = 0.0f; field_C = 0; - field_10 = nullptr; + m_pHovered = nullptr; field_14 = 0.0f; field_18 = 0.0f; field_1C = 0.0f; @@ -980,7 +980,7 @@ void GameRenderer::pick(float f) Mob* pMob = m_pMinecraft->m_pMobPersp; HitResult& mchr = m_pMinecraft->m_hitResult; - float dist = m_pMinecraft->m_pGameMode->getPickRange(); + float dist = m_pMinecraft->m_pGameMode->getBlockReachDistance(); bool isFirstPerson = !m_pMinecraft->getOptions()->m_bThirdPerson; if (!m_pMinecraft->useSplitControls()) @@ -1065,19 +1065,20 @@ void GameRenderer::pick(float f) Vec3 mobPos = pMob->getPos(f); - if (m_pMinecraft->m_hitResult.m_hitType != HitResult::NONE) + if (mchr.m_hitType != HitResult::NONE) dist = mchr.m_hitPos.distanceTo(mobPos); - if (m_pMinecraft->m_pGameMode->isCreativeType()) + float maxEntityDist = m_pMinecraft->m_pGameMode->getEntityReachDistance(); + /*if (m_pMinecraft->m_pGameMode->isCreativeType()) dist = 7.0f; - else if (dist > 3.0f) - dist = 3.0f; + else */if (dist > maxEntityDist) + dist = maxEntityDist; Vec3 view = pMob->getViewVector(f); Vec3 exp = view * dist; Vec3 limit = mobPos + view * dist; - field_10 = nullptr; + m_pHovered = nullptr; AABB scanAABB = pMob->m_hitbox; @@ -1109,7 +1110,7 @@ void GameRenderer::pick(float f) if (fDist >= 0.0f) { //this is it brother - field_10 = pEnt; + m_pHovered = pEnt; fDist = 0.0f; } continue; @@ -1124,20 +1125,20 @@ void GameRenderer::pick(float f) if (fDist > fNewDist || fDist == 0.0f) { - field_10 = pEnt; + m_pHovered = pEnt; fDist = fNewDist; } } } // picked entities take priority over tiles (?!) - if (field_10) + if (m_pHovered) { - m_pMinecraft->m_hitResult = HitResult(field_10); + mchr = HitResult(m_pHovered); return; } - if (m_pMinecraft->m_hitResult.m_hitType != HitResult::NONE || view.y >= -0.7f) + if (mchr.m_hitType != HitResult::NONE || view.y >= -0.7f) return; mobPos = pMob->getPos(f); @@ -1154,11 +1155,11 @@ void GameRenderer::pick(float f) if (fabsf(view.x) <= fabsf(view.z)) { - m_pMinecraft->m_hitResult.m_hitSide = view.z >= 0.0f ? Facing::SOUTH : Facing::NORTH; + mchr.m_hitSide = view.z >= 0.0f ? Facing::SOUTH : Facing::NORTH; } else { - m_pMinecraft->m_hitResult.m_hitSide = view.x >= 0.0f ? Facing::EAST : Facing::WEST; + mchr.m_hitSide = view.x >= 0.0f ? Facing::EAST : Facing::WEST; } } diff --git a/source/client/renderer/GameRenderer.hpp b/source/client/renderer/GameRenderer.hpp index 00d11d91a..19c2b8641 100644 --- a/source/client/renderer/GameRenderer.hpp +++ b/source/client/renderer/GameRenderer.hpp @@ -54,7 +54,7 @@ class GameRenderer float field_8; int field_C; - Entity* field_10; + Entity* m_pHovered; float field_14; float field_18; float field_1C; diff --git a/source/world/entity/Creeper.cpp b/source/world/entity/Creeper.cpp index a63e33e91..3ea37c0cc 100644 --- a/source/world/entity/Creeper.cpp +++ b/source/world/entity/Creeper.cpp @@ -46,7 +46,7 @@ void Creeper::die(Entity* pCulprit) { Monster::die(pCulprit); - if (pCulprit->getDescriptor().isType(EntityType::SKELETON)) + if (pCulprit && pCulprit->getDescriptor().isType(EntityType::SKELETON)) { spawnAtLocation(Item::record_01->m_itemID + m_random.nextInt(2), 1); } diff --git a/source/world/gamemode/CreativeMode.hpp b/source/world/gamemode/CreativeMode.hpp index 2f69a32e8..7a222396f 100644 --- a/source/world/gamemode/CreativeMode.hpp +++ b/source/world/gamemode/CreativeMode.hpp @@ -15,7 +15,7 @@ class CreativeMode : public GameMode public: CreativeMode(Minecraft*, Level&); - float getPickRange() const override { return 5.0f; } + //float getBlockReachDistance() const override { return 5.0f; } // 5.0f on Java bool isCreativeType() const override { return true; } void initPlayer(Player*) override; diff --git a/source/world/gamemode/GameMode.cpp b/source/world/gamemode/GameMode.cpp index e28e5f7e0..5d637e18f 100644 --- a/source/world/gamemode/GameMode.cpp +++ b/source/world/gamemode/GameMode.cpp @@ -77,18 +77,24 @@ void GameMode::render(float f) { } -float GameMode::getPickRange() const -{ -/* - if ( *inputMode == 1 ) - return 5.7; - if ( *inputMode == 3 ) - return 5.6; - if ( !player || player->isCreative() ) - return 12.0; - return 5.0; -*/ - return 7.5f; +float GameMode::getBlockReachDistance() const +{ + /* Logic from Pocket Edition 0.12.1 + if ( *inputMode == 1 ) + return 5.7f; + if ( *inputMode == 3 ) + return 5.6f; + if ( !player || player->isCreative() ) + return 12.0f; + */ + + // Fallback on Java and Pocket. All GameModes on PE are 5.0f until 0.10.0-0.12.1 + return 5.0f; +} + +float GameMode::getEntityReachDistance() const +{ + return 5.0f; } LocalPlayer* GameMode::createPlayer(Level* pLevel) diff --git a/source/world/gamemode/GameMode.hpp b/source/world/gamemode/GameMode.hpp index 7bafc56a0..873540589 100644 --- a/source/world/gamemode/GameMode.hpp +++ b/source/world/gamemode/GameMode.hpp @@ -30,7 +30,9 @@ class GameMode virtual void stopDestroyBlock(); virtual void tick(); virtual void render(float f); - virtual float getPickRange() const; + // Used to be called getPickRange + virtual float getBlockReachDistance() const; + virtual float getEntityReachDistance() const; virtual bool useItem(Player*, Level*, ItemInstance*); virtual bool useItemOn(Player*, Level*, ItemInstance*, const TilePos& pos, Facing::Name face); virtual LocalPlayer* createPlayer(Level*); diff --git a/source/world/gamemode/SurvivalMode.hpp b/source/world/gamemode/SurvivalMode.hpp index 273ecfcbc..b03b41788 100644 --- a/source/world/gamemode/SurvivalMode.hpp +++ b/source/world/gamemode/SurvivalMode.hpp @@ -21,7 +21,8 @@ class SurvivalMode : public GameMode void stopDestroyBlock() override; void tick() override; void render(float f) override; - float getPickRange() const override { return 5.0f; } + float getBlockReachDistance() const override { return 4.0f; } // 4.0f on Java, 5.0f until 0.10.0-0.12.1 + float getEntityReachDistance() const override { return 3.0f; } bool isCreativeType() const override { return false; } bool isSurvivalType() const override { return true; } void initPlayer(Player*) override; From 2616562cd2e86d00c7e5a93f4025420402fa28af Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Wed, 18 Jun 2025 23:42:11 -0500 Subject: [PATCH 011/293] Change TilePos::y from uint8_t to int (#166) * Fixes integer overflow issues Co-authored-by: Brent Da Mage --- source/world/level/TilePos.cpp | 2 +- source/world/level/TilePos.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/world/level/TilePos.cpp b/source/world/level/TilePos.cpp index a0a3cc1d6..e7c286888 100644 --- a/source/world/level/TilePos.cpp +++ b/source/world/level/TilePos.cpp @@ -21,7 +21,7 @@ TilePos::TilePos(int _x, int _y, int _z) TilePos::TilePos(float _x, float _y, float _z) { - _init((int)floorf(_x), (uint8_t)floorf(_y), (int)floorf(_z)); + _init((int)floorf(_x), (int)floorf(_y), (int)floorf(_z)); } TilePos::TilePos(const Vec3& pos) diff --git a/source/world/level/TilePos.hpp b/source/world/level/TilePos.hpp index fc39776cf..f9673e70f 100644 --- a/source/world/level/TilePos.hpp +++ b/source/world/level/TilePos.hpp @@ -15,7 +15,7 @@ struct ChunkPos; struct TilePos { int x; - uint8_t y; // 255 height limit + int y; // We had this on uint8_t due to the 255 height limit, but this can overflow too easily int z; private: From a04bcb91664bc9e00d7b475bec2ae0eb22265660 Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Mon, 23 Jun 2025 23:18:01 -0500 Subject: [PATCH 012/293] Fixed broken leaf decay (#171) Co-authored-by: Brent Da Mage --- source/world/tile/LeafTile.cpp | 244 ++++++++++++++++++++++----------- source/world/tile/LeafTile.hpp | 7 +- 2 files changed, 169 insertions(+), 82 deletions(-) diff --git a/source/world/tile/LeafTile.cpp b/source/world/tile/LeafTile.cpp index fe5e39065..8d243e5f2 100644 --- a/source/world/tile/LeafTile.cpp +++ b/source/world/tile/LeafTile.cpp @@ -10,9 +10,16 @@ #include "world/level/Level.hpp" #include "client/renderer/PatchManager.hpp" +#define C_REQUIRED_WOOD_RANGE 4 +#define C_UPDATE_LEAF_BIT 8 // 4 on b1.2_02 & 0.1.0 +#define C_NORMAL_LEAF 0 +#define C_EVERGREEN_LEAF 1 +#define C_BIRCH_LEAF 2 +#define C_LEAF_TYPE_MASK 3 + LeafTile::LeafTile(int id) : TransparentTile(id, TEXTURE_LEAVES_TRANSPARENT, Material::leaves, false) { - field_70 = nullptr; + m_checkBuffer = nullptr; m_TextureFrame = TEXTURE_LEAVES_TRANSPARENT; field_74 = TEXTURE_LEAVES_TRANSPARENT; @@ -22,8 +29,158 @@ LeafTile::LeafTile(int id) : TransparentTile(id, TEXTURE_LEAVES_TRANSPARENT, Mat LeafTile::~LeafTile() { - if (field_70) - delete[] field_70; + if (m_checkBuffer) + delete[] m_checkBuffer; +} + +void LeafTile::_tickDecayOld(Level* level, const TilePos& pos) +{ + int data = level->getData(pos); + if ((data & C_UPDATE_LEAF_BIT) == 0) + return; + + constexpr int C_RANGE = 32; + + if (!m_checkBuffer) + m_checkBuffer = new int[C_RANGE * C_RANGE * C_RANGE]; + + if (level->hasChunksAt(pos - (C_REQUIRED_WOOD_RANGE + 1), pos + (C_REQUIRED_WOOD_RANGE + 1))) + { + TilePos curr(pos); + // @TODO: get rid of magic values + for (int i = 3 << 10; i != (5 << 12) + (1 << 10); i += 1 << 10, curr.x++) + { + curr.x = pos.x - C_REQUIRED_WOOD_RANGE; + for (int j = 0; j != 9 << 5; j += C_RANGE, curr.y++) + { + curr.y = pos.y - C_REQUIRED_WOOD_RANGE; + for (int k = 0; k != 9; k++, curr.z++) + { + curr.z = pos.z - C_REQUIRED_WOOD_RANGE; + + TileID tile = level->getTile(curr); + if (tile == Tile::treeTrunk->m_ID) + m_checkBuffer[0x18C + i + j + k] = 0; + else if (tile == Tile::leaves->m_ID) + m_checkBuffer[0x18C + i + j + k] = -2; // ~1 + else + m_checkBuffer[0x18C + i + j + k] = -1; // ~0 + } + } + } + + constexpr int k1 = C_RANGE / 2; + constexpr int j1 = C_RANGE * C_RANGE; + + for (int i2 = 1; i2 <= C_REQUIRED_WOOD_RANGE; i2++) + { + for (int l2 = -C_REQUIRED_WOOD_RANGE; l2 <= C_REQUIRED_WOOD_RANGE; l2++) + { + for (int j3 = -C_REQUIRED_WOOD_RANGE; j3 <= C_REQUIRED_WOOD_RANGE; j3++) + { + for (int l3 = -C_REQUIRED_WOOD_RANGE; l3 <= C_REQUIRED_WOOD_RANGE; l3++) + { + if (m_checkBuffer[(l2 + k1) * j1 + (j3 + k1) * C_RANGE + (l3 + k1)] != i2 - 1) + continue; + + if (m_checkBuffer[((l2 + k1) - 1) * j1 + (j3 + k1) * C_RANGE + (l3 + k1)] == -2) + m_checkBuffer[((l2 + k1) - 1) * j1 + (j3 + k1) * C_RANGE + (l3 + k1)] = i2; + + if (m_checkBuffer[(l2 + k1 + 1) * j1 + (j3 + k1) * C_RANGE + (l3 + k1)] == -2) + m_checkBuffer[(l2 + k1 + 1) * j1 + (j3 + k1) * C_RANGE + (l3 + k1)] = i2; + + if (m_checkBuffer[(l2 + k1) * j1 + ((j3 + k1) - 1) * C_RANGE + (l3 + k1)] == -2) + m_checkBuffer[(l2 + k1) * j1 + ((j3 + k1) - 1) * C_RANGE + (l3 + k1)] = i2; + + if (m_checkBuffer[(l2 + k1) * j1 + (j3 + k1 + 1) * C_RANGE + (l3 + k1)] == -2) + m_checkBuffer[(l2 + k1) * j1 + (j3 + k1 + 1) * C_RANGE + (l3 + k1)] = i2; + + if (m_checkBuffer[(l2 + k1) * j1 + (j3 + k1) * C_RANGE + ((l3 + k1) - 1)] == -2) + m_checkBuffer[(l2 + k1) * j1 + (j3 + k1) * C_RANGE + ((l3 + k1) - 1)] = i2; + + if (m_checkBuffer[(l2 + k1) * j1 + (j3 + k1) * C_RANGE + (l3 + k1 + 1)] == -2) + m_checkBuffer[(l2 + k1) * j1 + (j3 + k1) * C_RANGE + (l3 + k1 + 1)] = i2; + } + } + } + } + + if (m_checkBuffer[0x4210] < 0) + die(level, pos); + else + level->setDataNoUpdate(pos, data & ~C_UPDATE_LEAF_BIT); // equates to -5 + } +} + +void LeafTile::_tickDecay(Level* level, const TilePos& pos) +{ + int data = level->getData(pos); + if ((data & C_UPDATE_LEAF_BIT) == 0) + return; + + constexpr int C_RANGE = 32; + constexpr int k1 = C_RANGE / 2; + constexpr int j1 = C_RANGE * C_RANGE; + + if (!m_checkBuffer) + m_checkBuffer = new int[C_RANGE * C_RANGE * C_RANGE]; + + if (level->hasChunksAt(pos - (C_REQUIRED_WOOD_RANGE + 1), pos + (C_REQUIRED_WOOD_RANGE + 1))) + { + TilePos curr(pos); + for (int i2 = -C_REQUIRED_WOOD_RANGE; i2 <= C_REQUIRED_WOOD_RANGE; i2++) + { + curr.x = pos.x + i2; + for (int j = -C_REQUIRED_WOOD_RANGE; j <= C_REQUIRED_WOOD_RANGE; j++) + { + curr.y = pos.y + j; + for (int k = -C_REQUIRED_WOOD_RANGE; k <= C_REQUIRED_WOOD_RANGE; k++) + { + curr.z = pos.z + k; + TileID tile = level->getTile(curr); + m_checkBuffer[(i2 + k1) * j1 + (j + k1) * C_RANGE + k + k1] = tile == Tile::treeTrunk->m_ID ? 0 : tile == Tile::leaves->m_ID ? -2 : -1; + } + } + } + + for (int i2 = 1; i2 <= C_REQUIRED_WOOD_RANGE; i2++) + { + for (int l2 = -C_REQUIRED_WOOD_RANGE; l2 <= C_REQUIRED_WOOD_RANGE; l2++) + { + for (int j3 = -C_REQUIRED_WOOD_RANGE; j3 <= C_REQUIRED_WOOD_RANGE; j3++) + { + for (int l3 = -C_REQUIRED_WOOD_RANGE; l3 <= C_REQUIRED_WOOD_RANGE; l3++) + { + if (m_checkBuffer[(l2 + k1) * j1 + (j3 + k1) * C_RANGE + (l3 + k1)] != i2 - 1) + continue; + + if (m_checkBuffer[((l2 + k1) - 1) * j1 + (j3 + k1) * C_RANGE + (l3 + k1)] == -2) + m_checkBuffer[((l2 + k1) - 1) * j1 + (j3 + k1) * C_RANGE + (l3 + k1)] = i2; + + if (m_checkBuffer[(l2 + k1 + 1) * j1 + (j3 + k1) * C_RANGE + (l3 + k1)] == -2) + m_checkBuffer[(l2 + k1 + 1) * j1 + (j3 + k1) * C_RANGE + (l3 + k1)] = i2; + + if (m_checkBuffer[(l2 + k1) * j1 + ((j3 + k1) - 1) * C_RANGE + (l3 + k1)] == -2) + m_checkBuffer[(l2 + k1) * j1 + ((j3 + k1) - 1) * C_RANGE + (l3 + k1)] = i2; + + if (m_checkBuffer[(l2 + k1) * j1 + (j3 + k1 + 1) * C_RANGE + (l3 + k1)] == -2) + m_checkBuffer[(l2 + k1) * j1 + (j3 + k1 + 1) * C_RANGE + (l3 + k1)] = i2; + + if (m_checkBuffer[(l2 + k1) * j1 + (j3 + k1) * C_RANGE + ((l3 + k1) - 1)] == -2) + m_checkBuffer[(l2 + k1) * j1 + (j3 + k1) * C_RANGE + ((l3 + k1) - 1)] = i2; + + if (m_checkBuffer[(l2 + k1) * j1 + (j3 + k1) * C_RANGE + (l3 + k1 + 1)] == -2) + m_checkBuffer[(l2 + k1) * j1 + (j3 + k1) * C_RANGE + (l3 + k1 + 1)] = i2; + } + } + } + } + } + + if (m_checkBuffer[k1 * j1 + k1 * C_RANGE + k1] < 0) + die(level, pos); + else + level->setDataNoUpdate(pos, data & ~C_UPDATE_LEAF_BIT); } void LeafTile::die(Level* level, const TilePos& pos) @@ -44,7 +201,7 @@ int LeafTile::getColor(const LevelSource* level, const TilePos& pos) const int LeafTile::getTexture(Facing::Name face, int data) const { - if ((data & 3) == 1) + if ((data & C_LEAF_TYPE_MASK) == 1) return m_TextureFrame + 80; return m_TextureFrame; @@ -74,7 +231,7 @@ void LeafTile::onRemove(Level* level, const TilePos& pos) TileID tile = level->getTile(pos + o); if (tile != Tile::leaves->m_ID) continue; - level->setDataNoUpdate(pos + o, level->getData(pos + o) | 4); + level->setDataNoUpdate(pos + o, level->getData(pos + o) | C_UPDATE_LEAF_BIT); } } } @@ -85,80 +242,5 @@ void LeafTile::tick(Level* level, const TilePos& pos, Random* random) if (level->m_bIsMultiplayer) return; - int data = level->getData(pos); - if ((data & 4) == 0) - return; - - constexpr int C_RANGE = 32; - constexpr int C_RANGE_SMALL = 4; - - if (!field_70) - field_70 = new int[C_RANGE * C_RANGE * C_RANGE]; - - if (level->hasChunksAt(pos - 5, pos + 5)) - { - TilePos curr(pos); - // @TODO: get rid of magic values - for (int i = 0x3000; i != 0x5400; i += 0x400, curr.x++) - { - curr.x = pos.x - C_RANGE_SMALL; - for (int j = 0; j != 0x120; j += 0x20, curr.y++) - { - curr.y = pos.y - C_RANGE_SMALL; - for (int k = 0; k != 9; k++, curr.z++) - { - curr.z = pos.z - C_RANGE_SMALL; - - TileID tile = level->getTile(curr); - if (tile == Tile::treeTrunk->m_ID) - field_70[0x18C + i + j + k] = 0; - else if (tile == Tile::leaves->m_ID) - field_70[0x18C + i + j + k] = -2; - else - field_70[0x18C + i + j + k] = -1; - } - } - } - - constexpr int k1 = C_RANGE / 2; - constexpr int j1 = C_RANGE * C_RANGE; - - for (int i2 = 1; i2 <= 4; i2++) - { - for (int l2 = -C_RANGE_SMALL; l2 <= C_RANGE_SMALL; l2++) - { - for (int j3 = -C_RANGE_SMALL; j3 <= C_RANGE_SMALL; j3++) - { - for (int l3 = -C_RANGE_SMALL; l3 <= C_RANGE_SMALL; l3++) - { - if (field_70[(l2 + k1) * j1 + (j3 + k1) * C_RANGE + (l3 + k1)] != i2 - 1) - continue; - - if (field_70[((l2 + k1) - 1) * j1 + (j3 + k1) * C_RANGE + (l3 + k1)] == -2) - field_70[((l2 + k1) - 1) * j1 + (j3 + k1) * C_RANGE + (l3 + k1)] = i2; - - if (field_70[(l2 + k1 + 1) * j1 + (j3 + k1) * C_RANGE + (l3 + k1)] == -2) - field_70[(l2 + k1 + 1) * j1 + (j3 + k1) * C_RANGE + (l3 + k1)] = i2; - - if (field_70[(l2 + k1) * j1 + ((j3 + k1) - 1) * C_RANGE + (l3 + k1)] == -2) - field_70[(l2 + k1) * j1 + ((j3 + k1) - 1) * C_RANGE + (l3 + k1)] = i2; - - if (field_70[(l2 + k1) * j1 + (j3 + k1 + 1) * C_RANGE + (l3 + k1)] == -2) - field_70[(l2 + k1) * j1 + (j3 + k1 + 1) * C_RANGE + (l3 + k1)] = i2; - - if (field_70[(l2 + k1) * j1 + (j3 + k1) * C_RANGE + ((l3 + k1) - 1)] == -2) - field_70[(l2 + k1) * j1 + (j3 + k1) * C_RANGE + ((l3 + k1) - 1)] = i2; - - if (field_70[(l2 + k1) * j1 + (j3 + k1) * C_RANGE + (l3 + k1 + 1)] == -2) - field_70[(l2 + k1) * j1 + (j3 + k1) * C_RANGE + (l3 + k1 + 1)] = i2; - } - } - } - } - - if (field_70[0x4210] < 0) - die(level, pos); - else - level->setDataNoUpdate(pos, data & ~0x4); - } + _tickDecay(level, pos); } diff --git a/source/world/tile/LeafTile.hpp b/source/world/tile/LeafTile.hpp index 1a15374d6..651bfbecc 100644 --- a/source/world/tile/LeafTile.hpp +++ b/source/world/tile/LeafTile.hpp @@ -16,6 +16,11 @@ class LeafTile : public TransparentTile LeafTile(int id); ~LeafTile(); +private: + void _tickDecayOld(Level* level, const TilePos& pos); // circa 0.1.0 + void _tickDecay(Level* level, const TilePos& pos); /// circa b1.7.3 + +public: int getColor(const LevelSource*, const TilePos& pos) const override; int getTexture(Facing::Name face, int data) const override; bool isSolidRender() const override; @@ -25,6 +30,6 @@ class LeafTile : public TransparentTile void die(Level*, const TilePos& pos); - int* field_70; + int* m_checkBuffer; int field_74; }; From ab513d111c75fcc968407088587fa68fe57b7187 Mon Sep 17 00:00:00 2001 From: Lucanero <45377498+lucanero@users.noreply.github.com> Date: Mon, 30 Jun 2025 21:53:57 -0400 Subject: [PATCH 013/293] Monsters (#170) * adding Spider, Zombie * Monster Commit * finish Spider and add to EntityRenderDispatcher * finish Skeleton, Arrow, ArrowRenderer class and add to EntityRenderDispatcher * instantiate Bow in item init fn * adjusted HumanoidMobRenderer to support carried items * fix vcxproj files * fix vcxproj.filter files * add back Creeper Renderer; disabled by accident * fix cmakelist * Fix macOS Building * Bugfixes * Fixed iOS Building * Added platform-agnostic AppPlatform::readAssetFile() * Textures::loadTexture() I/O Optimization * Cleanup * More cleanup * Inline Vec3 functions * Fixed arrow landing --------- Co-authored-by: Brent --- .gitignore | 13 + game/assets/app/launch/Default-568h@2x.png | Bin .../app/launch/Default-Landscape~ipad.png | Bin game/assets/app/launch/Default.png | Bin game/assets/app/launch/Default@2x.png | Bin game/assets/icon.ico | Bin platforms/ios/AppPlatform_iOS.h | 2 +- platforms/ios/AppPlatform_iOS.mm | 2 +- platforms/ios/minecraftpeViewController.mm | 3 + .../Minecraft.xcodeproj/project.pbxproj | 1648 ++++++++++++++++- .../windows/projects/Client/Client.vcxproj | 8 +- .../projects/Client/Client.vcxproj.filters | 24 +- .../windows/projects/World/World.vcxproj | 8 + .../projects/World/World.vcxproj.filters | 24 + source/CMakeLists.txt | 8 +- source/client/app/AppPlatform.cpp | 34 +- source/client/model/HumanoidModel.cpp | 5 + source/client/model/SkeletonModel.cpp | 27 + source/client/model/SkeletonModel.hpp | 10 + source/client/model/SpiderModel.cpp | 127 ++ source/client/model/SpiderModel.hpp | 26 + source/client/model/ZombieModel.cpp | 35 + source/client/model/ZombieModel.hpp | 11 + source/client/renderer/DynamicTexture.cpp | 4 +- source/client/renderer/DynamicTexture.hpp | 2 +- source/client/renderer/Textures.cpp | 45 +- source/client/renderer/Textures.hpp | 2 +- .../client/renderer/entity/ArrowRenderer.cpp | 73 + .../client/renderer/entity/ArrowRenderer.hpp | 12 + .../entity/EntityRenderDispatcher.cpp | 22 +- .../entity/EntityRenderDispatcher.hpp | 9 +- .../client/renderer/entity/EntityRenderer.cpp | 4 +- .../client/renderer/entity/EntityRenderer.hpp | 2 +- .../renderer/entity/HumanoidMobRenderer.cpp | 15 +- .../renderer/entity/SkeletonRenderer.cpp | 0 .../renderer/entity/SkeletonRenderer.hpp | 0 .../client/renderer/entity/SpiderRenderer.cpp | 29 + .../client/renderer/entity/SpiderRenderer.hpp | 13 + .../client/renderer/entity/ZombieRenderer.cpp | 0 .../client/renderer/entity/ZombieRenderer.hpp | 0 source/client/sound/sound_list.h | 23 + source/world/entity/Arrow.cpp | 243 +++ source/world/entity/Arrow.hpp | 39 + source/world/entity/Entity.hpp | 1 + source/world/entity/Mob.hpp | 3 +- source/world/entity/MobFactory.cpp | 12 +- source/world/entity/Player.cpp | 9 + source/world/entity/Player.hpp | 1 + source/world/entity/Skeleton.cpp | 66 + source/world/entity/Skeleton.hpp | 27 + source/world/entity/Spider.cpp | 48 + source/world/entity/Spider.hpp | 20 + source/world/entity/Zombie.cpp | 26 + source/world/entity/Zombie.hpp | 18 + source/world/item/Inventory.cpp | 12 +- source/world/item/Inventory.hpp | 2 +- source/world/item/Item.cpp | 4 + source/world/phys/AABB.cpp | 28 +- source/world/phys/AABB.hpp | 14 +- source/world/phys/Vec3.cpp | 34 +- source/world/phys/Vec3.hpp | 77 +- 61 files changed, 2759 insertions(+), 195 deletions(-) mode change 100644 => 100755 game/assets/app/launch/Default-568h@2x.png mode change 100644 => 100755 game/assets/app/launch/Default-Landscape~ipad.png mode change 100644 => 100755 game/assets/app/launch/Default.png mode change 100644 => 100755 game/assets/app/launch/Default@2x.png mode change 100644 => 100755 game/assets/icon.ico create mode 100644 source/client/renderer/entity/ArrowRenderer.cpp create mode 100644 source/client/renderer/entity/ArrowRenderer.hpp delete mode 100644 source/client/renderer/entity/SkeletonRenderer.cpp delete mode 100644 source/client/renderer/entity/SkeletonRenderer.hpp delete mode 100644 source/client/renderer/entity/ZombieRenderer.cpp delete mode 100644 source/client/renderer/entity/ZombieRenderer.hpp create mode 100644 source/world/entity/Arrow.cpp create mode 100644 source/world/entity/Arrow.hpp create mode 100644 source/world/entity/Skeleton.cpp create mode 100644 source/world/entity/Skeleton.hpp create mode 100644 source/world/entity/Spider.cpp create mode 100644 source/world/entity/Spider.hpp create mode 100644 source/world/entity/Zombie.cpp create mode 100644 source/world/entity/Zombie.hpp diff --git a/.gitignore b/.gitignore index 20855b3ec..bde9bdcb8 100644 --- a/.gitignore +++ b/.gitignore @@ -223,6 +223,18 @@ xcuserdata/ /game/assets/misc/vignette.png /game/assets/misc/shadow.png /game/assets/misc/pumpkinblur.png +/game/assets/environment/rain.png +/game/assets/environment/snow.png +/game/assets/item/boat.png +/game/assets/item/cart.png +/game/assets/item/door.png +/game/assets/mob/ghast.png +/game/assets/mob/ghast_fire.png +/game/assets/mob/pigman.png +/game/assets/mob/saddle.png +/game/assets/mob/slime.png +/game/assets/mob/spider_eyes.png +/game/assets/mob/squid.png # Ignore the panorama textures. Adding them yourself will make the title screen use them. /game/assets/gui/background/panorama_0.png @@ -256,3 +268,4 @@ xcuserdata/ # PCM sound extraction /tools/__pycache__ /tools/venv +/game/assets diff --git a/game/assets/app/launch/Default-568h@2x.png b/game/assets/app/launch/Default-568h@2x.png old mode 100644 new mode 100755 diff --git a/game/assets/app/launch/Default-Landscape~ipad.png b/game/assets/app/launch/Default-Landscape~ipad.png old mode 100644 new mode 100755 diff --git a/game/assets/app/launch/Default.png b/game/assets/app/launch/Default.png old mode 100644 new mode 100755 diff --git a/game/assets/app/launch/Default@2x.png b/game/assets/app/launch/Default@2x.png old mode 100644 new mode 100755 diff --git a/game/assets/icon.ico b/game/assets/icon.ico old mode 100644 new mode 100755 diff --git a/platforms/ios/AppPlatform_iOS.h b/platforms/ios/AppPlatform_iOS.h index 0609b86bc..742924b9e 100644 --- a/platforms/ios/AppPlatform_iOS.h +++ b/platforms/ios/AppPlatform_iOS.h @@ -36,7 +36,7 @@ class AppPlatform_iOS : public AppPlatform bool doesTextureExist(const std::string& path) const override; int getUserInputStatus() override; bool isTouchscreen() const override; - std::string getAssetPath(const std::string &path) const override; + std::string getAssetPath(const std::string& path) const override; std::string getPatchData() override; SoundSystem* const getSoundSystem() const override { return m_pSoundSystem; } diff --git a/platforms/ios/AppPlatform_iOS.mm b/platforms/ios/AppPlatform_iOS.mm index eadaa2073..6e929b500 100644 --- a/platforms/ios/AppPlatform_iOS.mm +++ b/platforms/ios/AppPlatform_iOS.mm @@ -12,7 +12,7 @@ #include "common/Utils.hpp" -#include "platforms/openal/SoundSystemAL.hpp" +#include "platforms/sound/openal/CustomSoundSystem.hpp" AppPlatform_iOS::AppPlatform_iOS(minecraftpeViewController *viewController) { diff --git a/platforms/ios/minecraftpeViewController.mm b/platforms/ios/minecraftpeViewController.mm index c33c901b3..e34e212b0 100644 --- a/platforms/ios/minecraftpeViewController.mm +++ b/platforms/ios/minecraftpeViewController.mm @@ -155,6 +155,9 @@ - (void)viewDidLoad //_keyboardView = [[ShowKeyboardView alloc] init]; [super viewDidLoad]; + // Setup logging + Logger::setSingleton(new Logger); + //EAGLContext *aContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; // //if (!aContext) diff --git a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj index 6bfc4cf21..f265a842d 100644 --- a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj +++ b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj @@ -456,16 +456,12 @@ 84AA8C082B32F3F3003F5B82 /* SheepFurRenderer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84AA8BB72B32F3F3003F5B82 /* SheepFurRenderer.hpp */; }; 84AA8C092B32F3F3003F5B82 /* SheepRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8BB82B32F3F3003F5B82 /* SheepRenderer.cpp */; }; 84AA8C0A2B32F3F3003F5B82 /* SheepRenderer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84AA8BB92B32F3F3003F5B82 /* SheepRenderer.hpp */; }; - 84AA8C0B2B32F3F3003F5B82 /* SkeletonRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8BBA2B32F3F3003F5B82 /* SkeletonRenderer.cpp */; }; - 84AA8C0C2B32F3F3003F5B82 /* SkeletonRenderer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84AA8BBB2B32F3F3003F5B82 /* SkeletonRenderer.hpp */; }; 84AA8C0D2B32F3F3003F5B82 /* SpiderRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8BBC2B32F3F3003F5B82 /* SpiderRenderer.cpp */; }; 84AA8C0E2B32F3F3003F5B82 /* SpiderRenderer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84AA8BBD2B32F3F3003F5B82 /* SpiderRenderer.hpp */; }; 84AA8C0F2B32F3F3003F5B82 /* TntRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8BBE2B32F3F3003F5B82 /* TntRenderer.cpp */; }; 84AA8C102B32F3F3003F5B82 /* TntRenderer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84AA8BBF2B32F3F3003F5B82 /* TntRenderer.hpp */; }; 84AA8C112B32F3F3003F5B82 /* TripodCameraRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8BC02B32F3F3003F5B82 /* TripodCameraRenderer.cpp */; }; 84AA8C122B32F3F3003F5B82 /* TripodCameraRenderer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84AA8BC12B32F3F3003F5B82 /* TripodCameraRenderer.hpp */; }; - 84AA8C132B32F3F3003F5B82 /* ZombieRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8BC22B32F3F3003F5B82 /* ZombieRenderer.cpp */; }; - 84AA8C142B32F3F3003F5B82 /* ZombieRenderer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84AA8BC32B32F3F3003F5B82 /* ZombieRenderer.hpp */; }; 84AA8C152B32F3F3003F5B82 /* FireTexture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8BC42B32F3F3003F5B82 /* FireTexture.cpp */; }; 84AA8C162B32F3F3003F5B82 /* FoliageColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8BC52B32F3F3003F5B82 /* FoliageColor.cpp */; }; 84AA8C172B32F3F3003F5B82 /* FoliageColor.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84AA8BC62B32F3F3003F5B82 /* FoliageColor.hpp */; }; @@ -528,12 +524,351 @@ 84AA8C762B32F536003F5B82 /* ZombieModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8C582B32F535003F5B82 /* ZombieModel.cpp */; }; 84AA8C772B32F536003F5B82 /* ZombieModel.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84AA8C592B32F535003F5B82 /* ZombieModel.hpp */; }; 84AA8C792B32F578003F5B82 /* gui_custom.png in Resources */ = {isa = PBXBuildFile; fileRef = 84AA8C782B32F578003F5B82 /* gui_custom.png */; }; - 84AA8E4D2B32FB33003F5B82 /* stb_vorbis.c in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8CD02B32FB32003F5B82 /* stb_vorbis.c */; }; 84AA8E802B32FB33003F5B82 /* stb_image_impl.c in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8E462B32FB33003F5B82 /* stb_image_impl.c */; }; 84AAF6432AF18BD000BD67F4 /* GLExt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD7332AC810620006A435 /* GLExt.cpp */; }; 84AAF6442AF18BE700BD67F4 /* GL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD7322AC810620006A435 /* GL.hpp */; }; 84AAF6452AF18BE700BD67F4 /* glext.h in Headers */ = {isa = PBXBuildFile; fileRef = 840DD7342AC810620006A435 /* glext.h */; }; 84AAF6482AF18C0C00BD67F4 /* libOpenGL.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84AAF6422AF18B9500BD67F4 /* libOpenGL.a */; }; + 84B1E02F2E04FD4500ED000A /* ArrowRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84B1E02D2E04FD4500ED000A /* ArrowRenderer.cpp */; }; + 84B1E0302E04FD4500ED000A /* ArrowRenderer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84B1E02E2E04FD4500ED000A /* ArrowRenderer.hpp */; }; + 84B1E0392E04FD7900ED000A /* Arrow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84B1E0312E04FD7900ED000A /* Arrow.cpp */; }; + 84B1E03A2E04FD7900ED000A /* Arrow.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84B1E0322E04FD7900ED000A /* Arrow.hpp */; }; + 84B1E03B2E04FD7900ED000A /* Skeleton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84B1E0332E04FD7900ED000A /* Skeleton.cpp */; }; + 84B1E03C2E04FD7900ED000A /* Skeleton.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84B1E0342E04FD7900ED000A /* Skeleton.hpp */; }; + 84B1E03D2E04FD7900ED000A /* Spider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84B1E0352E04FD7900ED000A /* Spider.cpp */; }; + 84B1E03E2E04FD7900ED000A /* Spider.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84B1E0362E04FD7900ED000A /* Spider.hpp */; }; + 84B1E03F2E04FD7900ED000A /* Zombie.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84B1E0372E04FD7900ED000A /* Zombie.cpp */; }; + 84B1E0402E04FD7900ED000A /* Zombie.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84B1E0382E04FD7900ED000A /* Zombie.hpp */; }; + 84B1E0552E050D2500ED000A /* ghast_fire.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0442E050D2500ED000A /* ghast_fire.png */; }; + 84B1E0562E050D2500ED000A /* ghast.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0452E050D2500ED000A /* ghast.png */; }; + 84B1E0582E050D2500ED000A /* pigman.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0472E050D2500ED000A /* pigman.png */; }; + 84B1E0592E050D2500ED000A /* pigzombie.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0482E050D2500ED000A /* pigzombie.png */; }; + 84B1E05A2E050D2500ED000A /* saddle.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0492E050D2500ED000A /* saddle.png */; }; + 84B1E05E2E050D2500ED000A /* slime.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E04D2E050D2500ED000A /* slime.png */; }; + 84B1E0612E050D2500ED000A /* squid.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0502E050D2500ED000A /* squid.png */; }; + 84B1E0632E05194A00ED000A /* stb_vorbis.c in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8CD02B32FB32003F5B82 /* stb_vorbis.c */; }; + 84B1E0642E051B6400ED000A /* chicken.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0412E050D2500ED000A /* chicken.png */; }; + 84B1E0652E051B6400ED000A /* cow.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0422E050D2500ED000A /* cow.png */; }; + 84B1E0662E051B6400ED000A /* creeper.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0432E050D2500ED000A /* creeper.png */; }; + 84B1E0672E051B6400ED000A /* pig.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0462E050D2500ED000A /* pig.png */; }; + 84B1E0682E051B6400ED000A /* sheep.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E04B2E050D2500ED000A /* sheep.png */; }; + 84B1E0692E051B6400ED000A /* sheep_fur.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E04A2E050D2500ED000A /* sheep_fur.png */; }; + 84B1E06A2E051B6400ED000A /* skeleton.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E04C2E050D2500ED000A /* skeleton.png */; }; + 84B1E06B2E051B6400ED000A /* spider.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E04F2E050D2500ED000A /* spider.png */; }; + 84B1E06C2E051B6400ED000A /* spider_eyes.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E04E2E050D2500ED000A /* spider_eyes.png */; }; + 84B1E06D2E051B6400ED000A /* zombie.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0512E050D2500ED000A /* zombie.png */; }; + 84B1E1C22E051B7D00ED000A /* calm1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E06F2E051B7C00ED000A /* calm1.ogg */; }; + 84B1E1C32E051B7D00ED000A /* calm2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0702E051B7C00ED000A /* calm2.ogg */; }; + 84B1E1C42E051B7D00ED000A /* calm3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0712E051B7C00ED000A /* calm3.ogg */; }; + 84B1E1C52E051B7D00ED000A /* hal1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0732E051B7C00ED000A /* hal1.ogg */; }; + 84B1E1C62E051B7D00ED000A /* hal2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0742E051B7C00ED000A /* hal2.ogg */; }; + 84B1E1C72E051B7D00ED000A /* hal3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0752E051B7C00ED000A /* hal3.ogg */; }; + 84B1E1C82E051B7D00ED000A /* hal4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0762E051B7C00ED000A /* hal4.ogg */; }; + 84B1E1C92E051B7D00ED000A /* nuance1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0772E051B7C00ED000A /* nuance1.ogg */; }; + 84B1E1CA2E051B7D00ED000A /* nuance2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0782E051B7C00ED000A /* nuance2.ogg */; }; + 84B1E1CB2E051B7D00ED000A /* piano1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0792E051B7C00ED000A /* piano1.ogg */; }; + 84B1E1CC2E051B7D00ED000A /* piano2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E07A2E051B7C00ED000A /* piano2.ogg */; }; + 84B1E1CD2E051B7D00ED000A /* piano3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E07B2E051B7C00ED000A /* piano3.ogg */; }; + 84B1E1CE2E051B7D00ED000A /* cave1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E07F2E051B7C00ED000A /* cave1.ogg */; }; + 84B1E1CF2E051B7D00ED000A /* cave10.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0802E051B7C00ED000A /* cave10.ogg */; }; + 84B1E1D02E051B7D00ED000A /* cave11.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0812E051B7C00ED000A /* cave11.ogg */; }; + 84B1E1D12E051B7D00ED000A /* cave12.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0822E051B7C00ED000A /* cave12.ogg */; }; + 84B1E1D22E051B7D00ED000A /* cave13.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0832E051B7C00ED000A /* cave13.ogg */; }; + 84B1E1D32E051B7D00ED000A /* cave2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0842E051B7C00ED000A /* cave2.ogg */; }; + 84B1E1D42E051B7D00ED000A /* cave3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0852E051B7C00ED000A /* cave3.ogg */; }; + 84B1E1D52E051B7D00ED000A /* cave4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0862E051B7C00ED000A /* cave4.ogg */; }; + 84B1E1D62E051B7D00ED000A /* cave5.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0872E051B7C00ED000A /* cave5.ogg */; }; + 84B1E1D72E051B7D00ED000A /* cave6.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0882E051B7C00ED000A /* cave6.ogg */; }; + 84B1E1D82E051B7D00ED000A /* cave7.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0892E051B7C00ED000A /* cave7.ogg */; }; + 84B1E1D92E051B7D00ED000A /* cave8.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E08A2E051B7C00ED000A /* cave8.ogg */; }; + 84B1E1DA2E051B7D00ED000A /* cave9.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E08B2E051B7C00ED000A /* cave9.ogg */; }; + 84B1E1DB2E051B7D00ED000A /* rain1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E08D2E051B7C00ED000A /* rain1.ogg */; }; + 84B1E1DC2E051B7D00ED000A /* rain2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E08E2E051B7C00ED000A /* rain2.ogg */; }; + 84B1E1DD2E051B7D00ED000A /* rain3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E08F2E051B7C00ED000A /* rain3.ogg */; }; + 84B1E1DE2E051B7D00ED000A /* rain4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0902E051B7C00ED000A /* rain4.ogg */; }; + 84B1E1DF2E051B7D00ED000A /* thunder1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0912E051B7C00ED000A /* thunder1.ogg */; }; + 84B1E1E02E051B7D00ED000A /* thunder2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0922E051B7C00ED000A /* thunder2.ogg */; }; + 84B1E1E12E051B7D00ED000A /* thunder3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0932E051B7C00ED000A /* thunder3.ogg */; }; + 84B1E1E22E051B7D00ED000A /* fallbig1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0952E051B7C00ED000A /* fallbig1.ogg */; }; + 84B1E1E32E051B7D00ED000A /* fallbig2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0962E051B7C00ED000A /* fallbig2.ogg */; }; + 84B1E1E42E051B7D00ED000A /* fallsmall.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0972E051B7C00ED000A /* fallsmall.ogg */; }; + 84B1E1E52E051B7D00ED000A /* hurtflesh1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0982E051B7C00ED000A /* hurtflesh1.ogg */; }; + 84B1E1E62E051B7D00ED000A /* hurtflesh2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0992E051B7C00ED000A /* hurtflesh2.ogg */; }; + 84B1E1E72E051B7D00ED000A /* hurtflesh3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E09A2E051B7C00ED000A /* hurtflesh3.ogg */; }; + 84B1E1E82E051B7D00ED000A /* fire.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E09C2E051B7C00ED000A /* fire.ogg */; }; + 84B1E1E92E051B7D00ED000A /* ignite.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E09D2E051B7C00ED000A /* ignite.ogg */; }; + 84B1E1EA2E051B7D00ED000A /* lava.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E09F2E051B7C00ED000A /* lava.ogg */; }; + 84B1E1EB2E051B7D00ED000A /* lavapop.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0A02E051B7C00ED000A /* lavapop.ogg */; }; + 84B1E1EC2E051B7D00ED000A /* splash.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0A12E051B7C00ED000A /* splash.ogg */; }; + 84B1E1ED2E051B7D00ED000A /* water.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0A22E051B7C00ED000A /* water.ogg */; }; + 84B1E1EE2E051B7D00ED000A /* breathe1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0A52E051B7C00ED000A /* breathe1.ogg */; }; + 84B1E1EF2E051B7D00ED000A /* breathe2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0A62E051B7C00ED000A /* breathe2.ogg */; }; + 84B1E1F02E051B7D00ED000A /* breathe3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0A72E051B7C00ED000A /* breathe3.ogg */; }; + 84B1E1F12E051B7D00ED000A /* breathe4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0A82E051B7C00ED000A /* breathe4.ogg */; }; + 84B1E1F22E051B7D00ED000A /* death.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0A92E051B7C00ED000A /* death.ogg */; }; + 84B1E1F32E051B7D00ED000A /* hit1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0AA2E051B7C00ED000A /* hit1.ogg */; }; + 84B1E1F42E051B7D00ED000A /* hit2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0AB2E051B7C00ED000A /* hit2.ogg */; }; + 84B1E1F52E051B7D00ED000A /* hit3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0AC2E051B7C00ED000A /* hit3.ogg */; }; + 84B1E1F62E051B7D00ED000A /* hit4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0AD2E051B7C00ED000A /* hit4.ogg */; }; + 84B1E1F72E051B7D00ED000A /* hiss1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0AF2E051B7C00ED000A /* hiss1.ogg */; }; + 84B1E1F82E051B7D00ED000A /* hiss2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0B02E051B7C00ED000A /* hiss2.ogg */; }; + 84B1E1F92E051B7D00ED000A /* hiss3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0B12E051B7C00ED000A /* hiss3.ogg */; }; + 84B1E1FA2E051B7D00ED000A /* hitt1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0B22E051B7C00ED000A /* hitt1.ogg */; }; + 84B1E1FB2E051B7D00ED000A /* hitt2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0B32E051B7C00ED000A /* hitt2.ogg */; }; + 84B1E1FC2E051B7D00ED000A /* hitt3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0B42E051B7C00ED000A /* hitt3.ogg */; }; + 84B1E1FD2E051B7D00ED000A /* meow1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0B52E051B7C00ED000A /* meow1.ogg */; }; + 84B1E1FE2E051B7D00ED000A /* meow2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0B62E051B7C00ED000A /* meow2.ogg */; }; + 84B1E1FF2E051B7D00ED000A /* meow3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0B72E051B7C00ED000A /* meow3.ogg */; }; + 84B1E2002E051B7D00ED000A /* meow4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0B82E051B7C00ED000A /* meow4.ogg */; }; + 84B1E2012E051B7D00ED000A /* purr1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0B92E051B7C00ED000A /* purr1.ogg */; }; + 84B1E2022E051B7D00ED000A /* purr2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0BA2E051B7C00ED000A /* purr2.ogg */; }; + 84B1E2032E051B7D00ED000A /* purr3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0BB2E051B7C00ED000A /* purr3.ogg */; }; + 84B1E2042E051B7D00ED000A /* purreow1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0BC2E051B7C00ED000A /* purreow1.ogg */; }; + 84B1E2052E051B7D00ED000A /* purreow2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0BD2E051B7C00ED000A /* purreow2.ogg */; }; + 84B1E2062E051B7D00ED000A /* chicken1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0BE2E051B7C00ED000A /* chicken1.ogg */; }; + 84B1E2072E051B7D00ED000A /* chicken2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0BF2E051B7C00ED000A /* chicken2.ogg */; }; + 84B1E2082E051B7D00ED000A /* chicken3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0C02E051B7C00ED000A /* chicken3.ogg */; }; + 84B1E2092E051B7D00ED000A /* chickenhurt1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0C12E051B7C00ED000A /* chickenhurt1.ogg */; }; + 84B1E20A2E051B7D00ED000A /* chickenhurt2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0C22E051B7C00ED000A /* chickenhurt2.ogg */; }; + 84B1E20B2E051B7D00ED000A /* chickenplop.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0C32E051B7C00ED000A /* chickenplop.ogg */; }; + 84B1E20C2E051B7D00ED000A /* cow1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0C42E051B7C00ED000A /* cow1.ogg */; }; + 84B1E20D2E051B7D00ED000A /* cow2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0C52E051B7C00ED000A /* cow2.ogg */; }; + 84B1E20E2E051B7D00ED000A /* cow3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0C62E051B7C00ED000A /* cow3.ogg */; }; + 84B1E20F2E051B7D00ED000A /* cow4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0C72E051B7C00ED000A /* cow4.ogg */; }; + 84B1E2102E051B7D00ED000A /* cowhurt1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0C82E051B7C00ED000A /* cowhurt1.ogg */; }; + 84B1E2112E051B7D00ED000A /* cowhurt2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0C92E051B7C00ED000A /* cowhurt2.ogg */; }; + 84B1E2122E051B7D00ED000A /* cowhurt3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0CA2E051B7C00ED000A /* cowhurt3.ogg */; }; + 84B1E2132E051B7D00ED000A /* creeper1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0CB2E051B7C00ED000A /* creeper1.ogg */; }; + 84B1E2142E051B7D00ED000A /* creeper2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0CC2E051B7C00ED000A /* creeper2.ogg */; }; + 84B1E2152E051B7D00ED000A /* creeper3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0CD2E051B7C00ED000A /* creeper3.ogg */; }; + 84B1E2162E051B7D00ED000A /* creeper4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0CE2E051B7C00ED000A /* creeper4.ogg */; }; + 84B1E2172E051B7D00ED000A /* creeperdeath.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0CF2E051B7C00ED000A /* creeperdeath.ogg */; }; + 84B1E2182E051B7D00ED000A /* death.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0D12E051B7C00ED000A /* death.ogg */; }; + 84B1E2192E051B7D00ED000A /* hit1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0D22E051B7C00ED000A /* hit1.ogg */; }; + 84B1E21A2E051B7D00ED000A /* hit2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0D32E051B7C00ED000A /* hit2.ogg */; }; + 84B1E21B2E051B7D00ED000A /* hit3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0D42E051B7C00ED000A /* hit3.ogg */; }; + 84B1E21C2E051B7D00ED000A /* hit4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0D52E051B7C00ED000A /* hit4.ogg */; }; + 84B1E21D2E051B7D00ED000A /* idle1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0D62E051B7C00ED000A /* idle1.ogg */; }; + 84B1E21E2E051B7D00ED000A /* idle2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0D72E051B7C00ED000A /* idle2.ogg */; }; + 84B1E21F2E051B7D00ED000A /* idle3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0D82E051B7C00ED000A /* idle3.ogg */; }; + 84B1E2202E051B7D00ED000A /* idle4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0D92E051B7C00ED000A /* idle4.ogg */; }; + 84B1E2212E051B7D00ED000A /* idle5.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0DA2E051B7C00ED000A /* idle5.ogg */; }; + 84B1E2222E051B7D00ED000A /* portal.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0DB2E051B7C00ED000A /* portal.ogg */; }; + 84B1E2232E051B7D00ED000A /* portal2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0DC2E051B7C00ED000A /* portal2.ogg */; }; + 84B1E2242E051B7D00ED000A /* scream1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0DD2E051B7C00ED000A /* scream1.ogg */; }; + 84B1E2252E051B7D00ED000A /* scream2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0DE2E051B7C00ED000A /* scream2.ogg */; }; + 84B1E2262E051B7D00ED000A /* scream3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0DF2E051B7C00ED000A /* scream3.ogg */; }; + 84B1E2272E051B7D00ED000A /* scream4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0E02E051B7C00ED000A /* scream4.ogg */; }; + 84B1E2282E051B7D00ED000A /* stare.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0E12E051B7C00ED000A /* stare.ogg */; }; + 84B1E2292E051B7D00ED000A /* affectionate scream.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0E32E051B7C00ED000A /* affectionate scream.ogg */; }; + 84B1E22A2E051B7D00ED000A /* charge.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0E42E051B7C00ED000A /* charge.ogg */; }; + 84B1E22B2E051B7D00ED000A /* death.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0E52E051B7C00ED000A /* death.ogg */; }; + 84B1E22C2E051B7D00ED000A /* fireball4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0E62E051B7C00ED000A /* fireball4.ogg */; }; + 84B1E22D2E051B7D00ED000A /* moan1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0E72E051B7C00ED000A /* moan1.ogg */; }; + 84B1E22E2E051B7D00ED000A /* moan2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0E82E051B7C00ED000A /* moan2.ogg */; }; + 84B1E22F2E051B7D00ED000A /* moan3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0E92E051B7C00ED000A /* moan3.ogg */; }; + 84B1E2302E051B7D00ED000A /* moan4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0EA2E051B7C00ED000A /* moan4.ogg */; }; + 84B1E2312E051B7D00ED000A /* moan5.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0EB2E051B7C00ED000A /* moan5.ogg */; }; + 84B1E2322E051B7D00ED000A /* moan6.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0EC2E051B7C00ED000A /* moan6.ogg */; }; + 84B1E2332E051B7D00ED000A /* moan7.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0ED2E051B7C00ED000A /* moan7.ogg */; }; + 84B1E2342E051B7D00ED000A /* scream1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0EE2E051B7C00ED000A /* scream1.ogg */; }; + 84B1E2352E051B7D00ED000A /* scream2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0EF2E051B7C00ED000A /* scream2.ogg */; }; + 84B1E2362E051B7D00ED000A /* scream3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0F02E051B7C00ED000A /* scream3.ogg */; }; + 84B1E2372E051B7D00ED000A /* scream4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0F12E051B7C00ED000A /* scream4.ogg */; }; + 84B1E2382E051B7D00ED000A /* scream5.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0F22E051B7C00ED000A /* scream5.ogg */; }; + 84B1E2392E051B7D00ED000A /* death.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0F42E051B7C00ED000A /* death.ogg */; }; + 84B1E23A2E051B7D00ED000A /* hit1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0F52E051B7C00ED000A /* hit1.ogg */; }; + 84B1E23B2E051B7D00ED000A /* hit2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0F62E051B7C00ED000A /* hit2.ogg */; }; + 84B1E23C2E051B7D00ED000A /* hit3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0F72E051B7C00ED000A /* hit3.ogg */; }; + 84B1E23D2E051B7D00ED000A /* hit4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0F82E051B7C00ED000A /* hit4.ogg */; }; + 84B1E23E2E051B7D00ED000A /* throw.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0F92E051B7C00ED000A /* throw.ogg */; }; + 84B1E23F2E051B7D00ED000A /* walk1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0FA2E051B7C00ED000A /* walk1.ogg */; }; + 84B1E2402E051B7D00ED000A /* walk2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0FB2E051B7C00ED000A /* walk2.ogg */; }; + 84B1E2412E051B7D00ED000A /* walk3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0FC2E051B7C00ED000A /* walk3.ogg */; }; + 84B1E2422E051B7D00ED000A /* walk4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0FD2E051B7C00ED000A /* walk4.ogg */; }; + 84B1E2432E051B7D00ED000A /* big1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0FF2E051B7C00ED000A /* big1.ogg */; }; + 84B1E2442E051B7D00ED000A /* big2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1002E051B7C00ED000A /* big2.ogg */; }; + 84B1E2452E051B7D00ED000A /* big3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1012E051B7C00ED000A /* big3.ogg */; }; + 84B1E2462E051B7D00ED000A /* big4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1022E051B7C00ED000A /* big4.ogg */; }; + 84B1E2472E051B7D00ED000A /* jump1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1032E051B7C00ED000A /* jump1.ogg */; }; + 84B1E2482E051B7D00ED000A /* jump2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1042E051B7C00ED000A /* jump2.ogg */; }; + 84B1E2492E051B7D00ED000A /* jump3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1052E051B7C00ED000A /* jump3.ogg */; }; + 84B1E24A2E051B7D00ED000A /* jump4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1062E051B7C00ED000A /* jump4.ogg */; }; + 84B1E24B2E051B7D00ED000A /* small1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1072E051B7C00ED000A /* small1.ogg */; }; + 84B1E24C2E051B7D00ED000A /* small2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1082E051B7C00ED000A /* small2.ogg */; }; + 84B1E24D2E051B7D00ED000A /* small3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1092E051B7C00ED000A /* small3.ogg */; }; + 84B1E24E2E051B7D00ED000A /* small4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E10A2E051B7C00ED000A /* small4.ogg */; }; + 84B1E24F2E051B7D00ED000A /* small5.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E10B2E051B7C00ED000A /* small5.ogg */; }; + 84B1E2502E051B7D00ED000A /* pig1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E10C2E051B7C00ED000A /* pig1.ogg */; }; + 84B1E2512E051B7D00ED000A /* pig2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E10D2E051B7C00ED000A /* pig2.ogg */; }; + 84B1E2522E051B7D00ED000A /* pig3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E10E2E051B7C00ED000A /* pig3.ogg */; }; + 84B1E2532E051B7D00ED000A /* pigdeath.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E10F2E051B7C00ED000A /* pigdeath.ogg */; }; + 84B1E2542E051B7D00ED000A /* sheep1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1102E051B7C00ED000A /* sheep1.ogg */; }; + 84B1E2552E051B7D00ED000A /* sheep2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1112E051B7C00ED000A /* sheep2.ogg */; }; + 84B1E2562E051B7D00ED000A /* sheep3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1122E051B7C00ED000A /* sheep3.ogg */; }; + 84B1E2572E051B7D00ED000A /* hit1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1142E051B7C00ED000A /* hit1.ogg */; }; + 84B1E2582E051B7D00ED000A /* hit2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1152E051B7C00ED000A /* hit2.ogg */; }; + 84B1E2592E051B7D00ED000A /* hit3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1162E051B7C00ED000A /* hit3.ogg */; }; + 84B1E25A2E051B7D00ED000A /* kill.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1172E051B7C00ED000A /* kill.ogg */; }; + 84B1E25B2E051B7D00ED000A /* say1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1182E051B7C00ED000A /* say1.ogg */; }; + 84B1E25C2E051B7D00ED000A /* say2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1192E051B7C00ED000A /* say2.ogg */; }; + 84B1E25D2E051B7D00ED000A /* say3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E11A2E051B7C00ED000A /* say3.ogg */; }; + 84B1E25E2E051B7D00ED000A /* say4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E11B2E051B7C00ED000A /* say4.ogg */; }; + 84B1E25F2E051B7D00ED000A /* step1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E11C2E051B7C00ED000A /* step1.ogg */; }; + 84B1E2602E051B7D00ED000A /* step2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E11D2E051B7C00ED000A /* step2.ogg */; }; + 84B1E2612E051B7D00ED000A /* step3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E11E2E051B7C00ED000A /* step3.ogg */; }; + 84B1E2622E051B7D00ED000A /* step4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E11F2E051B7C00ED000A /* step4.ogg */; }; + 84B1E2632E051B7D00ED000A /* skeleton1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1202E051B7C00ED000A /* skeleton1.ogg */; }; + 84B1E2642E051B7D00ED000A /* skeleton2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1212E051B7C00ED000A /* skeleton2.ogg */; }; + 84B1E2652E051B7D00ED000A /* skeleton3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1222E051B7C00ED000A /* skeleton3.ogg */; }; + 84B1E2662E051B7D00ED000A /* skeletondeath.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1232E051B7D00ED000A /* skeletondeath.ogg */; }; + 84B1E2672E051B7D00ED000A /* skeletonhurt1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1242E051B7D00ED000A /* skeletonhurt1.ogg */; }; + 84B1E2682E051B7D00ED000A /* skeletonhurt2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1252E051B7D00ED000A /* skeletonhurt2.ogg */; }; + 84B1E2692E051B7D00ED000A /* skeletonhurt3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1262E051B7D00ED000A /* skeletonhurt3.ogg */; }; + 84B1E26A2E051B7D00ED000A /* skeletonhurt4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1272E051B7D00ED000A /* skeletonhurt4.ogg */; }; + 84B1E26B2E051B7D00ED000A /* slime1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1282E051B7D00ED000A /* slime1.ogg */; }; + 84B1E26C2E051B7D00ED000A /* slime2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1292E051B7D00ED000A /* slime2.ogg */; }; + 84B1E26D2E051B7D00ED000A /* slime3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E12A2E051B7D00ED000A /* slime3.ogg */; }; + 84B1E26E2E051B7D00ED000A /* slime4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E12B2E051B7D00ED000A /* slime4.ogg */; }; + 84B1E26F2E051B7D00ED000A /* slime5.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E12C2E051B7D00ED000A /* slime5.ogg */; }; + 84B1E2702E051B7D00ED000A /* slimeattack1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E12D2E051B7D00ED000A /* slimeattack1.ogg */; }; + 84B1E2712E051B7D00ED000A /* slimeattack2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E12E2E051B7D00ED000A /* slimeattack2.ogg */; }; + 84B1E2722E051B7D00ED000A /* spider1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E12F2E051B7D00ED000A /* spider1.ogg */; }; + 84B1E2732E051B7D00ED000A /* spider2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1302E051B7D00ED000A /* spider2.ogg */; }; + 84B1E2742E051B7D00ED000A /* spider3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1312E051B7D00ED000A /* spider3.ogg */; }; + 84B1E2752E051B7D00ED000A /* spider4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1322E051B7D00ED000A /* spider4.ogg */; }; + 84B1E2762E051B7D00ED000A /* spiderdeath.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1332E051B7D00ED000A /* spiderdeath.ogg */; }; + 84B1E2772E051B7D00ED000A /* bark1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1352E051B7D00ED000A /* bark1.ogg */; }; + 84B1E2782E051B7D00ED000A /* bark2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1362E051B7D00ED000A /* bark2.ogg */; }; + 84B1E2792E051B7D00ED000A /* bark3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1372E051B7D00ED000A /* bark3.ogg */; }; + 84B1E27A2E051B7D00ED000A /* death.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1382E051B7D00ED000A /* death.ogg */; }; + 84B1E27B2E051B7D00ED000A /* growl1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1392E051B7D00ED000A /* growl1.ogg */; }; + 84B1E27C2E051B7D00ED000A /* growl2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E13A2E051B7D00ED000A /* growl2.ogg */; }; + 84B1E27D2E051B7D00ED000A /* growl3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E13B2E051B7D00ED000A /* growl3.ogg */; }; + 84B1E27E2E051B7D00ED000A /* howl1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E13C2E051B7D00ED000A /* howl1.ogg */; }; + 84B1E27F2E051B7D00ED000A /* howl2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E13D2E051B7D00ED000A /* howl2.ogg */; }; + 84B1E2802E051B7D00ED000A /* hurt1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E13E2E051B7D00ED000A /* hurt1.ogg */; }; + 84B1E2812E051B7D00ED000A /* hurt2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E13F2E051B7D00ED000A /* hurt2.ogg */; }; + 84B1E2822E051B7D00ED000A /* hurt3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1402E051B7D00ED000A /* hurt3.ogg */; }; + 84B1E2832E051B7D00ED000A /* panting.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1412E051B7D00ED000A /* panting.ogg */; }; + 84B1E2842E051B7D00ED000A /* shake.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1422E051B7D00ED000A /* shake.ogg */; }; + 84B1E2852E051B7D00ED000A /* whine.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1432E051B7D00ED000A /* whine.ogg */; }; + 84B1E2862E051B7D00ED000A /* metal1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1452E051B7D00ED000A /* metal1.ogg */; }; + 84B1E2872E051B7D00ED000A /* metal2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1462E051B7D00ED000A /* metal2.ogg */; }; + 84B1E2882E051B7D00ED000A /* metal3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1472E051B7D00ED000A /* metal3.ogg */; }; + 84B1E2892E051B7D00ED000A /* wood1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1482E051B7D00ED000A /* wood1.ogg */; }; + 84B1E28A2E051B7D00ED000A /* wood2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1492E051B7D00ED000A /* wood2.ogg */; }; + 84B1E28B2E051B7D00ED000A /* wood3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E14A2E051B7D00ED000A /* wood3.ogg */; }; + 84B1E28C2E051B7D00ED000A /* wood4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E14B2E051B7D00ED000A /* wood4.ogg */; }; + 84B1E28D2E051B7D00ED000A /* woodbreak.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E14C2E051B7D00ED000A /* woodbreak.ogg */; }; + 84B1E28E2E051B7D00ED000A /* zombie1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E14D2E051B7D00ED000A /* zombie1.ogg */; }; + 84B1E28F2E051B7D00ED000A /* zombie2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E14E2E051B7D00ED000A /* zombie2.ogg */; }; + 84B1E2902E051B7D00ED000A /* zombie3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E14F2E051B7D00ED000A /* zombie3.ogg */; }; + 84B1E2912E051B7D00ED000A /* zombiedeath.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1502E051B7D00ED000A /* zombiedeath.ogg */; }; + 84B1E2922E051B7D00ED000A /* zombiehurt1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1512E051B7D00ED000A /* zombiehurt1.ogg */; }; + 84B1E2932E051B7D00ED000A /* zombiehurt2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1522E051B7D00ED000A /* zombiehurt2.ogg */; }; + 84B1E2942E051B7D00ED000A /* zpig1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1542E051B7D00ED000A /* zpig1.ogg */; }; + 84B1E2952E051B7D00ED000A /* zpig2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1552E051B7D00ED000A /* zpig2.ogg */; }; + 84B1E2962E051B7D00ED000A /* zpig3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1562E051B7D00ED000A /* zpig3.ogg */; }; + 84B1E2972E051B7D00ED000A /* zpig4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1572E051B7D00ED000A /* zpig4.ogg */; }; + 84B1E2982E051B7D00ED000A /* zpigangry1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1582E051B7D00ED000A /* zpigangry1.ogg */; }; + 84B1E2992E051B7D00ED000A /* zpigangry2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1592E051B7D00ED000A /* zpigangry2.ogg */; }; + 84B1E29A2E051B7D00ED000A /* zpigangry3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E15A2E051B7D00ED000A /* zpigangry3.ogg */; }; + 84B1E29B2E051B7D00ED000A /* zpigangry4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E15B2E051B7D00ED000A /* zpigangry4.ogg */; }; + 84B1E29C2E051B7D00ED000A /* zpigdeath.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E15C2E051B7D00ED000A /* zpigdeath.ogg */; }; + 84B1E29D2E051B7D00ED000A /* zpighurt1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E15D2E051B7D00ED000A /* zpighurt1.ogg */; }; + 84B1E29E2E051B7D00ED000A /* zpighurt2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E15E2E051B7D00ED000A /* zpighurt2.ogg */; }; + 84B1E29F2E051B7D00ED000A /* bass.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1602E051B7D00ED000A /* bass.ogg */; }; + 84B1E2A02E051B7D00ED000A /* bassattack.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1612E051B7D00ED000A /* bassattack.ogg */; }; + 84B1E2A12E051B7D00ED000A /* bd.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1622E051B7D00ED000A /* bd.ogg */; }; + 84B1E2A22E051B7D00ED000A /* harp.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1632E051B7D00ED000A /* harp.ogg */; }; + 84B1E2A32E051B7D00ED000A /* hat.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1642E051B7D00ED000A /* hat.ogg */; }; + 84B1E2A42E051B7D00ED000A /* pling.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1652E051B7D00ED000A /* pling.ogg */; }; + 84B1E2A52E051B7D00ED000A /* snare.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1662E051B7D00ED000A /* snare.ogg */; }; + 84B1E2A62E051B7D00ED000A /* portal.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1682E051B7D00ED000A /* portal.ogg */; }; + 84B1E2A72E051B7D00ED000A /* travel.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1692E051B7D00ED000A /* travel.ogg */; }; + 84B1E2A82E051B7D00ED000A /* trigger.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E16A2E051B7D00ED000A /* trigger.ogg */; }; + 84B1E2A92E051B7D00ED000A /* bow.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E16C2E051B7D00ED000A /* bow.ogg */; }; + 84B1E2AA2E051B7D00ED000A /* bowhit1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E16D2E051B7D00ED000A /* bowhit1.ogg */; }; + 84B1E2AB2E051B7D00ED000A /* bowhit2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E16E2E051B7D00ED000A /* bowhit2.ogg */; }; + 84B1E2AC2E051B7D00ED000A /* bowhit3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E16F2E051B7D00ED000A /* bowhit3.ogg */; }; + 84B1E2AD2E051B7D00ED000A /* bowhit4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1702E051B7D00ED000A /* bowhit4.ogg */; }; + 84B1E2AE2E051B7D00ED000A /* break.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1712E051B7D00ED000A /* break.ogg */; }; + 84B1E2AF2E051B7D00ED000A /* breath.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1722E051B7D00ED000A /* breath.ogg */; }; + 84B1E2B02E051B7D00ED000A /* burp.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1732E051B7D00ED000A /* burp.ogg */; }; + 84B1E2B12E051B7D00ED000A /* chestclosed.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1742E051B7D00ED000A /* chestclosed.ogg */; }; + 84B1E2B22E051B7D00ED000A /* chestopen.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1752E051B7D00ED000A /* chestopen.ogg */; }; + 84B1E2B32E051B7D00ED000A /* click.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1762E051B7D00ED000A /* click.ogg */; }; + 84B1E2B42E051B7D00ED000A /* door_close.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1772E051B7D00ED000A /* door_close.ogg */; }; + 84B1E2B52E051B7D00ED000A /* door_open.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1782E051B7D00ED000A /* door_open.ogg */; }; + 84B1E2B62E051B7D00ED000A /* drink.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1792E051B7D00ED000A /* drink.ogg */; }; + 84B1E2B72E051B7D00ED000A /* drr.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E17A2E051B7D00ED000A /* drr.ogg */; }; + 84B1E2B82E051B7D00ED000A /* eat1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E17B2E051B7D00ED000A /* eat1.ogg */; }; + 84B1E2B92E051B7D00ED000A /* eat2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E17C2E051B7D00ED000A /* eat2.ogg */; }; + 84B1E2BA2E051B7D00ED000A /* eat3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E17D2E051B7D00ED000A /* eat3.ogg */; }; + 84B1E2BB2E051B7D00ED000A /* explode.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E17E2E051B7D00ED000A /* explode.ogg */; }; + 84B1E2BC2E051B7D00ED000A /* explode1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E17F2E051B7D00ED000A /* explode1.ogg */; }; + 84B1E2BD2E051B7D00ED000A /* explode2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1802E051B7D00ED000A /* explode2.ogg */; }; + 84B1E2BE2E051B7D00ED000A /* explode3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1812E051B7D00ED000A /* explode3.ogg */; }; + 84B1E2BF2E051B7D00ED000A /* explode4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1822E051B7D00ED000A /* explode4.ogg */; }; + 84B1E2C02E051B7D00ED000A /* fizz.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1832E051B7D00ED000A /* fizz.ogg */; }; + 84B1E2C12E051B7D00ED000A /* fuse.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1842E051B7D00ED000A /* fuse.ogg */; }; + 84B1E2C22E051B7D00ED000A /* glass1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1852E051B7D00ED000A /* glass1.ogg */; }; + 84B1E2C32E051B7D00ED000A /* glass2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1862E051B7D00ED000A /* glass2.ogg */; }; + 84B1E2C42E051B7D00ED000A /* glass3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1872E051B7D00ED000A /* glass3.ogg */; }; + 84B1E2C52E051B7D00ED000A /* hurt.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1882E051B7D00ED000A /* hurt.ogg */; }; + 84B1E2C62E051B7D00ED000A /* levelup.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1892E051B7D00ED000A /* levelup.ogg */; }; + 84B1E2C72E051B7D00ED000A /* old_explode.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E18A2E051B7D00ED000A /* old_explode.ogg */; }; + 84B1E2C82E051B7D00ED000A /* orb.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E18B2E051B7D00ED000A /* orb.ogg */; }; + 84B1E2C92E051B7D00ED000A /* pop.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E18C2E051B7D00ED000A /* pop.ogg */; }; + 84B1E2CA2E051B7D00ED000A /* splash.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E18D2E051B7D00ED000A /* splash.ogg */; }; + 84B1E2CB2E051B7D00ED000A /* wood click.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E18E2E051B7D00ED000A /* wood click.ogg */; }; + 84B1E2CC2E051B7D00ED000A /* cloth1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1902E051B7D00ED000A /* cloth1.ogg */; }; + 84B1E2CD2E051B7D00ED000A /* cloth2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1912E051B7D00ED000A /* cloth2.ogg */; }; + 84B1E2CE2E051B7D00ED000A /* cloth3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1922E051B7D00ED000A /* cloth3.ogg */; }; + 84B1E2CF2E051B7D00ED000A /* cloth4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1932E051B7D00ED000A /* cloth4.ogg */; }; + 84B1E2D02E051B7D00ED000A /* grass1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1942E051B7D00ED000A /* grass1.ogg */; }; + 84B1E2D12E051B7D00ED000A /* grass2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1952E051B7D00ED000A /* grass2.ogg */; }; + 84B1E2D22E051B7D00ED000A /* grass3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1962E051B7D00ED000A /* grass3.ogg */; }; + 84B1E2D32E051B7D00ED000A /* grass4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1972E051B7D00ED000A /* grass4.ogg */; }; + 84B1E2D42E051B7D00ED000A /* gravel1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1982E051B7D00ED000A /* gravel1.ogg */; }; + 84B1E2D52E051B7D00ED000A /* gravel2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1992E051B7D00ED000A /* gravel2.ogg */; }; + 84B1E2D62E051B7D00ED000A /* gravel3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E19A2E051B7D00ED000A /* gravel3.ogg */; }; + 84B1E2D72E051B7D00ED000A /* gravel4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E19B2E051B7D00ED000A /* gravel4.ogg */; }; + 84B1E2D82E051B7D00ED000A /* sand1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E19C2E051B7D00ED000A /* sand1.ogg */; }; + 84B1E2D92E051B7D00ED000A /* sand2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E19D2E051B7D00ED000A /* sand2.ogg */; }; + 84B1E2DA2E051B7D00ED000A /* sand3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E19E2E051B7D00ED000A /* sand3.ogg */; }; + 84B1E2DB2E051B7D00ED000A /* sand4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E19F2E051B7D00ED000A /* sand4.ogg */; }; + 84B1E2DC2E051B7D00ED000A /* snow1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1A02E051B7D00ED000A /* snow1.ogg */; }; + 84B1E2DD2E051B7D00ED000A /* snow2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1A12E051B7D00ED000A /* snow2.ogg */; }; + 84B1E2DE2E051B7D00ED000A /* snow3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1A22E051B7D00ED000A /* snow3.ogg */; }; + 84B1E2DF2E051B7D00ED000A /* snow4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1A32E051B7D00ED000A /* snow4.ogg */; }; + 84B1E2E02E051B7D00ED000A /* stone1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1A42E051B7D00ED000A /* stone1.ogg */; }; + 84B1E2E12E051B7D00ED000A /* stone2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1A52E051B7D00ED000A /* stone2.ogg */; }; + 84B1E2E22E051B7D00ED000A /* stone3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1A62E051B7D00ED000A /* stone3.ogg */; }; + 84B1E2E32E051B7D00ED000A /* stone4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1A72E051B7D00ED000A /* stone4.ogg */; }; + 84B1E2E42E051B7D00ED000A /* wood1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1A82E051B7D00ED000A /* wood1.ogg */; }; + 84B1E2E52E051B7D00ED000A /* wood2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1A92E051B7D00ED000A /* wood2.ogg */; }; + 84B1E2E62E051B7D00ED000A /* wood3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1AA2E051B7D00ED000A /* wood3.ogg */; }; + 84B1E2E72E051B7D00ED000A /* wood4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1AB2E051B7D00ED000A /* wood4.ogg */; }; + 84B1E2E82E051B7D00ED000A /* in.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1AE2E051B7D00ED000A /* in.ogg */; }; + 84B1E2E92E051B7D00ED000A /* out.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1AF2E051B7D00ED000A /* out.ogg */; }; + 84B1E2EA2E051B7D00ED000A /* grass1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1B22E051B7D00ED000A /* grass1.ogg */; }; + 84B1E2EB2E051B7D00ED000A /* grass2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1B32E051B7D00ED000A /* grass2.ogg */; }; + 84B1E2EC2E051B7D00ED000A /* grass3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1B42E051B7D00ED000A /* grass3.ogg */; }; + 84B1E2ED2E051B7D00ED000A /* grass4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1B52E051B7D00ED000A /* grass4.ogg */; }; + 84B1E2EE2E051B7D00ED000A /* gravel1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1B62E051B7D00ED000A /* gravel1.ogg */; }; + 84B1E2EF2E051B7D00ED000A /* gravel2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1B72E051B7D00ED000A /* gravel2.ogg */; }; + 84B1E2F02E051B7D00ED000A /* gravel3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1B82E051B7D00ED000A /* gravel3.ogg */; }; + 84B1E2F12E051B7D00ED000A /* gravel4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1B92E051B7D00ED000A /* gravel4.ogg */; }; + 84B1E2F22E051B7D00ED000A /* stone1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1BA2E051B7D00ED000A /* stone1.ogg */; }; + 84B1E2F32E051B7D00ED000A /* stone2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1BB2E051B7D00ED000A /* stone2.ogg */; }; + 84B1E2F42E051B7D00ED000A /* stone3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1BC2E051B7D00ED000A /* stone3.ogg */; }; + 84B1E2F52E051B7D00ED000A /* stone4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1BD2E051B7D00ED000A /* stone4.ogg */; }; + 84B1E2F62E051B7D00ED000A /* wood1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1BE2E051B7D00ED000A /* wood1.ogg */; }; + 84B1E2F72E051B7D00ED000A /* wood2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1BF2E051B7D00ED000A /* wood2.ogg */; }; + 84B1E2F82E051B7D00ED000A /* wood3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1C02E051B7D00ED000A /* wood3.ogg */; }; + 84B1E2F92E051B7D00ED000A /* wood4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1C12E051B7D00ED000A /* wood4.ogg */; }; 84B8AEE82AF1890A008DE93D /* App.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD57E2AC810620006A435 /* App.cpp */; }; 84B8AEE92AF1890A008DE93D /* AppPlatform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD5802AC810620006A435 /* AppPlatform.cpp */; }; 84B8AEEA2AF1890A008DE93D /* Minecraft.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD5822AC810620006A435 /* Minecraft.cpp */; }; @@ -1995,16 +2330,12 @@ 84AA8BB72B32F3F3003F5B82 /* SheepFurRenderer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SheepFurRenderer.hpp; sourceTree = ""; }; 84AA8BB82B32F3F3003F5B82 /* SheepRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SheepRenderer.cpp; sourceTree = ""; }; 84AA8BB92B32F3F3003F5B82 /* SheepRenderer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SheepRenderer.hpp; sourceTree = ""; }; - 84AA8BBA2B32F3F3003F5B82 /* SkeletonRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SkeletonRenderer.cpp; sourceTree = ""; }; - 84AA8BBB2B32F3F3003F5B82 /* SkeletonRenderer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SkeletonRenderer.hpp; sourceTree = ""; }; 84AA8BBC2B32F3F3003F5B82 /* SpiderRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpiderRenderer.cpp; sourceTree = ""; }; 84AA8BBD2B32F3F3003F5B82 /* SpiderRenderer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SpiderRenderer.hpp; sourceTree = ""; }; 84AA8BBE2B32F3F3003F5B82 /* TntRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TntRenderer.cpp; sourceTree = ""; }; 84AA8BBF2B32F3F3003F5B82 /* TntRenderer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TntRenderer.hpp; sourceTree = ""; }; 84AA8BC02B32F3F3003F5B82 /* TripodCameraRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TripodCameraRenderer.cpp; sourceTree = ""; }; 84AA8BC12B32F3F3003F5B82 /* TripodCameraRenderer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TripodCameraRenderer.hpp; sourceTree = ""; }; - 84AA8BC22B32F3F3003F5B82 /* ZombieRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ZombieRenderer.cpp; sourceTree = ""; }; - 84AA8BC32B32F3F3003F5B82 /* ZombieRenderer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ZombieRenderer.hpp; sourceTree = ""; }; 84AA8BC42B32F3F3003F5B82 /* FireTexture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FireTexture.cpp; sourceTree = ""; }; 84AA8BC52B32F3F3003F5B82 /* FoliageColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FoliageColor.cpp; sourceTree = ""; }; 84AA8BC62B32F3F3003F5B82 /* FoliageColor.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FoliageColor.hpp; sourceTree = ""; }; @@ -2091,6 +2422,345 @@ 84AA8E462B32FB33003F5B82 /* stb_image_impl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = stb_image_impl.c; sourceTree = ""; }; 84AAF6422AF18B9500BD67F4 /* libOpenGL.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libOpenGL.a; sourceTree = BUILT_PRODUCTS_DIR; }; 84AD710C2AF20B6A00DA73F9 /* readme.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = readme.txt; sourceTree = ""; }; + 84B1E02D2E04FD4500ED000A /* ArrowRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ArrowRenderer.cpp; sourceTree = ""; }; + 84B1E02E2E04FD4500ED000A /* ArrowRenderer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ArrowRenderer.hpp; sourceTree = ""; }; + 84B1E0312E04FD7900ED000A /* Arrow.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Arrow.cpp; sourceTree = ""; }; + 84B1E0322E04FD7900ED000A /* Arrow.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Arrow.hpp; sourceTree = ""; }; + 84B1E0332E04FD7900ED000A /* Skeleton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Skeleton.cpp; sourceTree = ""; }; + 84B1E0342E04FD7900ED000A /* Skeleton.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Skeleton.hpp; sourceTree = ""; }; + 84B1E0352E04FD7900ED000A /* Spider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Spider.cpp; sourceTree = ""; }; + 84B1E0362E04FD7900ED000A /* Spider.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Spider.hpp; sourceTree = ""; }; + 84B1E0372E04FD7900ED000A /* Zombie.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Zombie.cpp; sourceTree = ""; }; + 84B1E0382E04FD7900ED000A /* Zombie.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Zombie.hpp; sourceTree = ""; }; + 84B1E0412E050D2500ED000A /* chicken.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = chicken.png; sourceTree = ""; }; + 84B1E0422E050D2500ED000A /* cow.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = cow.png; sourceTree = ""; }; + 84B1E0432E050D2500ED000A /* creeper.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = creeper.png; sourceTree = ""; }; + 84B1E0442E050D2500ED000A /* ghast_fire.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ghast_fire.png; sourceTree = ""; }; + 84B1E0452E050D2500ED000A /* ghast.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ghast.png; sourceTree = ""; }; + 84B1E0462E050D2500ED000A /* pig.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pig.png; sourceTree = ""; }; + 84B1E0472E050D2500ED000A /* pigman.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pigman.png; sourceTree = ""; }; + 84B1E0482E050D2500ED000A /* pigzombie.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pigzombie.png; sourceTree = ""; }; + 84B1E0492E050D2500ED000A /* saddle.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = saddle.png; sourceTree = ""; }; + 84B1E04A2E050D2500ED000A /* sheep_fur.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = sheep_fur.png; sourceTree = ""; }; + 84B1E04B2E050D2500ED000A /* sheep.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = sheep.png; sourceTree = ""; }; + 84B1E04C2E050D2500ED000A /* skeleton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = skeleton.png; sourceTree = ""; }; + 84B1E04D2E050D2500ED000A /* slime.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = slime.png; sourceTree = ""; }; + 84B1E04E2E050D2500ED000A /* spider_eyes.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = spider_eyes.png; sourceTree = ""; }; + 84B1E04F2E050D2500ED000A /* spider.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = spider.png; sourceTree = ""; }; + 84B1E0502E050D2500ED000A /* squid.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = squid.png; sourceTree = ""; }; + 84B1E0512E050D2500ED000A /* zombie.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = zombie.png; sourceTree = ""; }; + 84B1E06F2E051B7C00ED000A /* calm1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = calm1.ogg; sourceTree = ""; }; + 84B1E0702E051B7C00ED000A /* calm2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = calm2.ogg; sourceTree = ""; }; + 84B1E0712E051B7C00ED000A /* calm3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = calm3.ogg; sourceTree = ""; }; + 84B1E0732E051B7C00ED000A /* hal1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hal1.ogg; sourceTree = ""; }; + 84B1E0742E051B7C00ED000A /* hal2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hal2.ogg; sourceTree = ""; }; + 84B1E0752E051B7C00ED000A /* hal3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hal3.ogg; sourceTree = ""; }; + 84B1E0762E051B7C00ED000A /* hal4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hal4.ogg; sourceTree = ""; }; + 84B1E0772E051B7C00ED000A /* nuance1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = nuance1.ogg; sourceTree = ""; }; + 84B1E0782E051B7C00ED000A /* nuance2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = nuance2.ogg; sourceTree = ""; }; + 84B1E0792E051B7C00ED000A /* piano1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = piano1.ogg; sourceTree = ""; }; + 84B1E07A2E051B7C00ED000A /* piano2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = piano2.ogg; sourceTree = ""; }; + 84B1E07B2E051B7C00ED000A /* piano3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = piano3.ogg; sourceTree = ""; }; + 84B1E07F2E051B7C00ED000A /* cave1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cave1.ogg; sourceTree = ""; }; + 84B1E0802E051B7C00ED000A /* cave10.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cave10.ogg; sourceTree = ""; }; + 84B1E0812E051B7C00ED000A /* cave11.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cave11.ogg; sourceTree = ""; }; + 84B1E0822E051B7C00ED000A /* cave12.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cave12.ogg; sourceTree = ""; }; + 84B1E0832E051B7C00ED000A /* cave13.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cave13.ogg; sourceTree = ""; }; + 84B1E0842E051B7C00ED000A /* cave2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cave2.ogg; sourceTree = ""; }; + 84B1E0852E051B7C00ED000A /* cave3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cave3.ogg; sourceTree = ""; }; + 84B1E0862E051B7C00ED000A /* cave4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cave4.ogg; sourceTree = ""; }; + 84B1E0872E051B7C00ED000A /* cave5.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cave5.ogg; sourceTree = ""; }; + 84B1E0882E051B7C00ED000A /* cave6.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cave6.ogg; sourceTree = ""; }; + 84B1E0892E051B7C00ED000A /* cave7.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cave7.ogg; sourceTree = ""; }; + 84B1E08A2E051B7C00ED000A /* cave8.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cave8.ogg; sourceTree = ""; }; + 84B1E08B2E051B7C00ED000A /* cave9.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cave9.ogg; sourceTree = ""; }; + 84B1E08D2E051B7C00ED000A /* rain1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = rain1.ogg; sourceTree = ""; }; + 84B1E08E2E051B7C00ED000A /* rain2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = rain2.ogg; sourceTree = ""; }; + 84B1E08F2E051B7C00ED000A /* rain3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = rain3.ogg; sourceTree = ""; }; + 84B1E0902E051B7C00ED000A /* rain4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = rain4.ogg; sourceTree = ""; }; + 84B1E0912E051B7C00ED000A /* thunder1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = thunder1.ogg; sourceTree = ""; }; + 84B1E0922E051B7C00ED000A /* thunder2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = thunder2.ogg; sourceTree = ""; }; + 84B1E0932E051B7C00ED000A /* thunder3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = thunder3.ogg; sourceTree = ""; }; + 84B1E0952E051B7C00ED000A /* fallbig1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = fallbig1.ogg; sourceTree = ""; }; + 84B1E0962E051B7C00ED000A /* fallbig2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = fallbig2.ogg; sourceTree = ""; }; + 84B1E0972E051B7C00ED000A /* fallsmall.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = fallsmall.ogg; sourceTree = ""; }; + 84B1E0982E051B7C00ED000A /* hurtflesh1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hurtflesh1.ogg; sourceTree = ""; }; + 84B1E0992E051B7C00ED000A /* hurtflesh2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hurtflesh2.ogg; sourceTree = ""; }; + 84B1E09A2E051B7C00ED000A /* hurtflesh3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hurtflesh3.ogg; sourceTree = ""; }; + 84B1E09C2E051B7C00ED000A /* fire.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = fire.ogg; sourceTree = ""; }; + 84B1E09D2E051B7C00ED000A /* ignite.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = ignite.ogg; sourceTree = ""; }; + 84B1E09F2E051B7C00ED000A /* lava.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = lava.ogg; sourceTree = ""; }; + 84B1E0A02E051B7C00ED000A /* lavapop.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = lavapop.ogg; sourceTree = ""; }; + 84B1E0A12E051B7C00ED000A /* splash.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = splash.ogg; sourceTree = ""; }; + 84B1E0A22E051B7C00ED000A /* water.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = water.ogg; sourceTree = ""; }; + 84B1E0A52E051B7C00ED000A /* breathe1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = breathe1.ogg; sourceTree = ""; }; + 84B1E0A62E051B7C00ED000A /* breathe2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = breathe2.ogg; sourceTree = ""; }; + 84B1E0A72E051B7C00ED000A /* breathe3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = breathe3.ogg; sourceTree = ""; }; + 84B1E0A82E051B7C00ED000A /* breathe4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = breathe4.ogg; sourceTree = ""; }; + 84B1E0A92E051B7C00ED000A /* death.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = death.ogg; sourceTree = ""; }; + 84B1E0AA2E051B7C00ED000A /* hit1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit1.ogg; sourceTree = ""; }; + 84B1E0AB2E051B7C00ED000A /* hit2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit2.ogg; sourceTree = ""; }; + 84B1E0AC2E051B7C00ED000A /* hit3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit3.ogg; sourceTree = ""; }; + 84B1E0AD2E051B7C00ED000A /* hit4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit4.ogg; sourceTree = ""; }; + 84B1E0AF2E051B7C00ED000A /* hiss1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hiss1.ogg; sourceTree = ""; }; + 84B1E0B02E051B7C00ED000A /* hiss2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hiss2.ogg; sourceTree = ""; }; + 84B1E0B12E051B7C00ED000A /* hiss3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hiss3.ogg; sourceTree = ""; }; + 84B1E0B22E051B7C00ED000A /* hitt1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hitt1.ogg; sourceTree = ""; }; + 84B1E0B32E051B7C00ED000A /* hitt2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hitt2.ogg; sourceTree = ""; }; + 84B1E0B42E051B7C00ED000A /* hitt3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hitt3.ogg; sourceTree = ""; }; + 84B1E0B52E051B7C00ED000A /* meow1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = meow1.ogg; sourceTree = ""; }; + 84B1E0B62E051B7C00ED000A /* meow2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = meow2.ogg; sourceTree = ""; }; + 84B1E0B72E051B7C00ED000A /* meow3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = meow3.ogg; sourceTree = ""; }; + 84B1E0B82E051B7C00ED000A /* meow4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = meow4.ogg; sourceTree = ""; }; + 84B1E0B92E051B7C00ED000A /* purr1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = purr1.ogg; sourceTree = ""; }; + 84B1E0BA2E051B7C00ED000A /* purr2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = purr2.ogg; sourceTree = ""; }; + 84B1E0BB2E051B7C00ED000A /* purr3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = purr3.ogg; sourceTree = ""; }; + 84B1E0BC2E051B7C00ED000A /* purreow1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = purreow1.ogg; sourceTree = ""; }; + 84B1E0BD2E051B7C00ED000A /* purreow2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = purreow2.ogg; sourceTree = ""; }; + 84B1E0BE2E051B7C00ED000A /* chicken1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = chicken1.ogg; sourceTree = ""; }; + 84B1E0BF2E051B7C00ED000A /* chicken2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = chicken2.ogg; sourceTree = ""; }; + 84B1E0C02E051B7C00ED000A /* chicken3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = chicken3.ogg; sourceTree = ""; }; + 84B1E0C12E051B7C00ED000A /* chickenhurt1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = chickenhurt1.ogg; sourceTree = ""; }; + 84B1E0C22E051B7C00ED000A /* chickenhurt2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = chickenhurt2.ogg; sourceTree = ""; }; + 84B1E0C32E051B7C00ED000A /* chickenplop.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = chickenplop.ogg; sourceTree = ""; }; + 84B1E0C42E051B7C00ED000A /* cow1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cow1.ogg; sourceTree = ""; }; + 84B1E0C52E051B7C00ED000A /* cow2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cow2.ogg; sourceTree = ""; }; + 84B1E0C62E051B7C00ED000A /* cow3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cow3.ogg; sourceTree = ""; }; + 84B1E0C72E051B7C00ED000A /* cow4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cow4.ogg; sourceTree = ""; }; + 84B1E0C82E051B7C00ED000A /* cowhurt1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cowhurt1.ogg; sourceTree = ""; }; + 84B1E0C92E051B7C00ED000A /* cowhurt2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cowhurt2.ogg; sourceTree = ""; }; + 84B1E0CA2E051B7C00ED000A /* cowhurt3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cowhurt3.ogg; sourceTree = ""; }; + 84B1E0CB2E051B7C00ED000A /* creeper1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = creeper1.ogg; sourceTree = ""; }; + 84B1E0CC2E051B7C00ED000A /* creeper2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = creeper2.ogg; sourceTree = ""; }; + 84B1E0CD2E051B7C00ED000A /* creeper3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = creeper3.ogg; sourceTree = ""; }; + 84B1E0CE2E051B7C00ED000A /* creeper4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = creeper4.ogg; sourceTree = ""; }; + 84B1E0CF2E051B7C00ED000A /* creeperdeath.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = creeperdeath.ogg; sourceTree = ""; }; + 84B1E0D12E051B7C00ED000A /* death.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = death.ogg; sourceTree = ""; }; + 84B1E0D22E051B7C00ED000A /* hit1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit1.ogg; sourceTree = ""; }; + 84B1E0D32E051B7C00ED000A /* hit2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit2.ogg; sourceTree = ""; }; + 84B1E0D42E051B7C00ED000A /* hit3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit3.ogg; sourceTree = ""; }; + 84B1E0D52E051B7C00ED000A /* hit4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit4.ogg; sourceTree = ""; }; + 84B1E0D62E051B7C00ED000A /* idle1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = idle1.ogg; sourceTree = ""; }; + 84B1E0D72E051B7C00ED000A /* idle2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = idle2.ogg; sourceTree = ""; }; + 84B1E0D82E051B7C00ED000A /* idle3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = idle3.ogg; sourceTree = ""; }; + 84B1E0D92E051B7C00ED000A /* idle4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = idle4.ogg; sourceTree = ""; }; + 84B1E0DA2E051B7C00ED000A /* idle5.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = idle5.ogg; sourceTree = ""; }; + 84B1E0DB2E051B7C00ED000A /* portal.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = portal.ogg; sourceTree = ""; }; + 84B1E0DC2E051B7C00ED000A /* portal2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = portal2.ogg; sourceTree = ""; }; + 84B1E0DD2E051B7C00ED000A /* scream1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = scream1.ogg; sourceTree = ""; }; + 84B1E0DE2E051B7C00ED000A /* scream2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = scream2.ogg; sourceTree = ""; }; + 84B1E0DF2E051B7C00ED000A /* scream3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = scream3.ogg; sourceTree = ""; }; + 84B1E0E02E051B7C00ED000A /* scream4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = scream4.ogg; sourceTree = ""; }; + 84B1E0E12E051B7C00ED000A /* stare.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = stare.ogg; sourceTree = ""; }; + 84B1E0E32E051B7C00ED000A /* affectionate scream.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = "affectionate scream.ogg"; sourceTree = ""; }; + 84B1E0E42E051B7C00ED000A /* charge.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = charge.ogg; sourceTree = ""; }; + 84B1E0E52E051B7C00ED000A /* death.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = death.ogg; sourceTree = ""; }; + 84B1E0E62E051B7C00ED000A /* fireball4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = fireball4.ogg; sourceTree = ""; }; + 84B1E0E72E051B7C00ED000A /* moan1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = moan1.ogg; sourceTree = ""; }; + 84B1E0E82E051B7C00ED000A /* moan2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = moan2.ogg; sourceTree = ""; }; + 84B1E0E92E051B7C00ED000A /* moan3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = moan3.ogg; sourceTree = ""; }; + 84B1E0EA2E051B7C00ED000A /* moan4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = moan4.ogg; sourceTree = ""; }; + 84B1E0EB2E051B7C00ED000A /* moan5.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = moan5.ogg; sourceTree = ""; }; + 84B1E0EC2E051B7C00ED000A /* moan6.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = moan6.ogg; sourceTree = ""; }; + 84B1E0ED2E051B7C00ED000A /* moan7.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = moan7.ogg; sourceTree = ""; }; + 84B1E0EE2E051B7C00ED000A /* scream1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = scream1.ogg; sourceTree = ""; }; + 84B1E0EF2E051B7C00ED000A /* scream2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = scream2.ogg; sourceTree = ""; }; + 84B1E0F02E051B7C00ED000A /* scream3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = scream3.ogg; sourceTree = ""; }; + 84B1E0F12E051B7C00ED000A /* scream4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = scream4.ogg; sourceTree = ""; }; + 84B1E0F22E051B7C00ED000A /* scream5.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = scream5.ogg; sourceTree = ""; }; + 84B1E0F42E051B7C00ED000A /* death.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = death.ogg; sourceTree = ""; }; + 84B1E0F52E051B7C00ED000A /* hit1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit1.ogg; sourceTree = ""; }; + 84B1E0F62E051B7C00ED000A /* hit2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit2.ogg; sourceTree = ""; }; + 84B1E0F72E051B7C00ED000A /* hit3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit3.ogg; sourceTree = ""; }; + 84B1E0F82E051B7C00ED000A /* hit4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit4.ogg; sourceTree = ""; }; + 84B1E0F92E051B7C00ED000A /* throw.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = throw.ogg; sourceTree = ""; }; + 84B1E0FA2E051B7C00ED000A /* walk1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = walk1.ogg; sourceTree = ""; }; + 84B1E0FB2E051B7C00ED000A /* walk2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = walk2.ogg; sourceTree = ""; }; + 84B1E0FC2E051B7C00ED000A /* walk3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = walk3.ogg; sourceTree = ""; }; + 84B1E0FD2E051B7C00ED000A /* walk4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = walk4.ogg; sourceTree = ""; }; + 84B1E0FF2E051B7C00ED000A /* big1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = big1.ogg; sourceTree = ""; }; + 84B1E1002E051B7C00ED000A /* big2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = big2.ogg; sourceTree = ""; }; + 84B1E1012E051B7C00ED000A /* big3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = big3.ogg; sourceTree = ""; }; + 84B1E1022E051B7C00ED000A /* big4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = big4.ogg; sourceTree = ""; }; + 84B1E1032E051B7C00ED000A /* jump1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = jump1.ogg; sourceTree = ""; }; + 84B1E1042E051B7C00ED000A /* jump2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = jump2.ogg; sourceTree = ""; }; + 84B1E1052E051B7C00ED000A /* jump3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = jump3.ogg; sourceTree = ""; }; + 84B1E1062E051B7C00ED000A /* jump4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = jump4.ogg; sourceTree = ""; }; + 84B1E1072E051B7C00ED000A /* small1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = small1.ogg; sourceTree = ""; }; + 84B1E1082E051B7C00ED000A /* small2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = small2.ogg; sourceTree = ""; }; + 84B1E1092E051B7C00ED000A /* small3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = small3.ogg; sourceTree = ""; }; + 84B1E10A2E051B7C00ED000A /* small4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = small4.ogg; sourceTree = ""; }; + 84B1E10B2E051B7C00ED000A /* small5.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = small5.ogg; sourceTree = ""; }; + 84B1E10C2E051B7C00ED000A /* pig1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = pig1.ogg; sourceTree = ""; }; + 84B1E10D2E051B7C00ED000A /* pig2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = pig2.ogg; sourceTree = ""; }; + 84B1E10E2E051B7C00ED000A /* pig3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = pig3.ogg; sourceTree = ""; }; + 84B1E10F2E051B7C00ED000A /* pigdeath.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = pigdeath.ogg; sourceTree = ""; }; + 84B1E1102E051B7C00ED000A /* sheep1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = sheep1.ogg; sourceTree = ""; }; + 84B1E1112E051B7C00ED000A /* sheep2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = sheep2.ogg; sourceTree = ""; }; + 84B1E1122E051B7C00ED000A /* sheep3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = sheep3.ogg; sourceTree = ""; }; + 84B1E1142E051B7C00ED000A /* hit1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit1.ogg; sourceTree = ""; }; + 84B1E1152E051B7C00ED000A /* hit2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit2.ogg; sourceTree = ""; }; + 84B1E1162E051B7C00ED000A /* hit3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit3.ogg; sourceTree = ""; }; + 84B1E1172E051B7C00ED000A /* kill.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = kill.ogg; sourceTree = ""; }; + 84B1E1182E051B7C00ED000A /* say1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = say1.ogg; sourceTree = ""; }; + 84B1E1192E051B7C00ED000A /* say2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = say2.ogg; sourceTree = ""; }; + 84B1E11A2E051B7C00ED000A /* say3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = say3.ogg; sourceTree = ""; }; + 84B1E11B2E051B7C00ED000A /* say4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = say4.ogg; sourceTree = ""; }; + 84B1E11C2E051B7C00ED000A /* step1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = step1.ogg; sourceTree = ""; }; + 84B1E11D2E051B7C00ED000A /* step2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = step2.ogg; sourceTree = ""; }; + 84B1E11E2E051B7C00ED000A /* step3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = step3.ogg; sourceTree = ""; }; + 84B1E11F2E051B7C00ED000A /* step4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = step4.ogg; sourceTree = ""; }; + 84B1E1202E051B7C00ED000A /* skeleton1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = skeleton1.ogg; sourceTree = ""; }; + 84B1E1212E051B7C00ED000A /* skeleton2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = skeleton2.ogg; sourceTree = ""; }; + 84B1E1222E051B7C00ED000A /* skeleton3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = skeleton3.ogg; sourceTree = ""; }; + 84B1E1232E051B7D00ED000A /* skeletondeath.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = skeletondeath.ogg; sourceTree = ""; }; + 84B1E1242E051B7D00ED000A /* skeletonhurt1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = skeletonhurt1.ogg; sourceTree = ""; }; + 84B1E1252E051B7D00ED000A /* skeletonhurt2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = skeletonhurt2.ogg; sourceTree = ""; }; + 84B1E1262E051B7D00ED000A /* skeletonhurt3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = skeletonhurt3.ogg; sourceTree = ""; }; + 84B1E1272E051B7D00ED000A /* skeletonhurt4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = skeletonhurt4.ogg; sourceTree = ""; }; + 84B1E1282E051B7D00ED000A /* slime1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = slime1.ogg; sourceTree = ""; }; + 84B1E1292E051B7D00ED000A /* slime2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = slime2.ogg; sourceTree = ""; }; + 84B1E12A2E051B7D00ED000A /* slime3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = slime3.ogg; sourceTree = ""; }; + 84B1E12B2E051B7D00ED000A /* slime4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = slime4.ogg; sourceTree = ""; }; + 84B1E12C2E051B7D00ED000A /* slime5.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = slime5.ogg; sourceTree = ""; }; + 84B1E12D2E051B7D00ED000A /* slimeattack1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = slimeattack1.ogg; sourceTree = ""; }; + 84B1E12E2E051B7D00ED000A /* slimeattack2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = slimeattack2.ogg; sourceTree = ""; }; + 84B1E12F2E051B7D00ED000A /* spider1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = spider1.ogg; sourceTree = ""; }; + 84B1E1302E051B7D00ED000A /* spider2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = spider2.ogg; sourceTree = ""; }; + 84B1E1312E051B7D00ED000A /* spider3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = spider3.ogg; sourceTree = ""; }; + 84B1E1322E051B7D00ED000A /* spider4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = spider4.ogg; sourceTree = ""; }; + 84B1E1332E051B7D00ED000A /* spiderdeath.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = spiderdeath.ogg; sourceTree = ""; }; + 84B1E1352E051B7D00ED000A /* bark1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = bark1.ogg; sourceTree = ""; }; + 84B1E1362E051B7D00ED000A /* bark2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = bark2.ogg; sourceTree = ""; }; + 84B1E1372E051B7D00ED000A /* bark3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = bark3.ogg; sourceTree = ""; }; + 84B1E1382E051B7D00ED000A /* death.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = death.ogg; sourceTree = ""; }; + 84B1E1392E051B7D00ED000A /* growl1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = growl1.ogg; sourceTree = ""; }; + 84B1E13A2E051B7D00ED000A /* growl2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = growl2.ogg; sourceTree = ""; }; + 84B1E13B2E051B7D00ED000A /* growl3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = growl3.ogg; sourceTree = ""; }; + 84B1E13C2E051B7D00ED000A /* howl1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = howl1.ogg; sourceTree = ""; }; + 84B1E13D2E051B7D00ED000A /* howl2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = howl2.ogg; sourceTree = ""; }; + 84B1E13E2E051B7D00ED000A /* hurt1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hurt1.ogg; sourceTree = ""; }; + 84B1E13F2E051B7D00ED000A /* hurt2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hurt2.ogg; sourceTree = ""; }; + 84B1E1402E051B7D00ED000A /* hurt3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hurt3.ogg; sourceTree = ""; }; + 84B1E1412E051B7D00ED000A /* panting.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = panting.ogg; sourceTree = ""; }; + 84B1E1422E051B7D00ED000A /* shake.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = shake.ogg; sourceTree = ""; }; + 84B1E1432E051B7D00ED000A /* whine.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = whine.ogg; sourceTree = ""; }; + 84B1E1452E051B7D00ED000A /* metal1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = metal1.ogg; sourceTree = ""; }; + 84B1E1462E051B7D00ED000A /* metal2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = metal2.ogg; sourceTree = ""; }; + 84B1E1472E051B7D00ED000A /* metal3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = metal3.ogg; sourceTree = ""; }; + 84B1E1482E051B7D00ED000A /* wood1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = wood1.ogg; sourceTree = ""; }; + 84B1E1492E051B7D00ED000A /* wood2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = wood2.ogg; sourceTree = ""; }; + 84B1E14A2E051B7D00ED000A /* wood3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = wood3.ogg; sourceTree = ""; }; + 84B1E14B2E051B7D00ED000A /* wood4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = wood4.ogg; sourceTree = ""; }; + 84B1E14C2E051B7D00ED000A /* woodbreak.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = woodbreak.ogg; sourceTree = ""; }; + 84B1E14D2E051B7D00ED000A /* zombie1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zombie1.ogg; sourceTree = ""; }; + 84B1E14E2E051B7D00ED000A /* zombie2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zombie2.ogg; sourceTree = ""; }; + 84B1E14F2E051B7D00ED000A /* zombie3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zombie3.ogg; sourceTree = ""; }; + 84B1E1502E051B7D00ED000A /* zombiedeath.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zombiedeath.ogg; sourceTree = ""; }; + 84B1E1512E051B7D00ED000A /* zombiehurt1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zombiehurt1.ogg; sourceTree = ""; }; + 84B1E1522E051B7D00ED000A /* zombiehurt2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zombiehurt2.ogg; sourceTree = ""; }; + 84B1E1542E051B7D00ED000A /* zpig1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zpig1.ogg; sourceTree = ""; }; + 84B1E1552E051B7D00ED000A /* zpig2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zpig2.ogg; sourceTree = ""; }; + 84B1E1562E051B7D00ED000A /* zpig3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zpig3.ogg; sourceTree = ""; }; + 84B1E1572E051B7D00ED000A /* zpig4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zpig4.ogg; sourceTree = ""; }; + 84B1E1582E051B7D00ED000A /* zpigangry1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zpigangry1.ogg; sourceTree = ""; }; + 84B1E1592E051B7D00ED000A /* zpigangry2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zpigangry2.ogg; sourceTree = ""; }; + 84B1E15A2E051B7D00ED000A /* zpigangry3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zpigangry3.ogg; sourceTree = ""; }; + 84B1E15B2E051B7D00ED000A /* zpigangry4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zpigangry4.ogg; sourceTree = ""; }; + 84B1E15C2E051B7D00ED000A /* zpigdeath.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zpigdeath.ogg; sourceTree = ""; }; + 84B1E15D2E051B7D00ED000A /* zpighurt1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zpighurt1.ogg; sourceTree = ""; }; + 84B1E15E2E051B7D00ED000A /* zpighurt2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zpighurt2.ogg; sourceTree = ""; }; + 84B1E1602E051B7D00ED000A /* bass.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = bass.ogg; sourceTree = ""; }; + 84B1E1612E051B7D00ED000A /* bassattack.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = bassattack.ogg; sourceTree = ""; }; + 84B1E1622E051B7D00ED000A /* bd.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = bd.ogg; sourceTree = ""; }; + 84B1E1632E051B7D00ED000A /* harp.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = harp.ogg; sourceTree = ""; }; + 84B1E1642E051B7D00ED000A /* hat.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hat.ogg; sourceTree = ""; }; + 84B1E1652E051B7D00ED000A /* pling.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = pling.ogg; sourceTree = ""; }; + 84B1E1662E051B7D00ED000A /* snare.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = snare.ogg; sourceTree = ""; }; + 84B1E1682E051B7D00ED000A /* portal.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = portal.ogg; sourceTree = ""; }; + 84B1E1692E051B7D00ED000A /* travel.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = travel.ogg; sourceTree = ""; }; + 84B1E16A2E051B7D00ED000A /* trigger.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = trigger.ogg; sourceTree = ""; }; + 84B1E16C2E051B7D00ED000A /* bow.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = bow.ogg; sourceTree = ""; }; + 84B1E16D2E051B7D00ED000A /* bowhit1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = bowhit1.ogg; sourceTree = ""; }; + 84B1E16E2E051B7D00ED000A /* bowhit2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = bowhit2.ogg; sourceTree = ""; }; + 84B1E16F2E051B7D00ED000A /* bowhit3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = bowhit3.ogg; sourceTree = ""; }; + 84B1E1702E051B7D00ED000A /* bowhit4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = bowhit4.ogg; sourceTree = ""; }; + 84B1E1712E051B7D00ED000A /* break.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = break.ogg; sourceTree = ""; }; + 84B1E1722E051B7D00ED000A /* breath.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = breath.ogg; sourceTree = ""; }; + 84B1E1732E051B7D00ED000A /* burp.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = burp.ogg; sourceTree = ""; }; + 84B1E1742E051B7D00ED000A /* chestclosed.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = chestclosed.ogg; sourceTree = ""; }; + 84B1E1752E051B7D00ED000A /* chestopen.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = chestopen.ogg; sourceTree = ""; }; + 84B1E1762E051B7D00ED000A /* click.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = click.ogg; sourceTree = ""; }; + 84B1E1772E051B7D00ED000A /* door_close.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = door_close.ogg; sourceTree = ""; }; + 84B1E1782E051B7D00ED000A /* door_open.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = door_open.ogg; sourceTree = ""; }; + 84B1E1792E051B7D00ED000A /* drink.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = drink.ogg; sourceTree = ""; }; + 84B1E17A2E051B7D00ED000A /* drr.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = drr.ogg; sourceTree = ""; }; + 84B1E17B2E051B7D00ED000A /* eat1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = eat1.ogg; sourceTree = ""; }; + 84B1E17C2E051B7D00ED000A /* eat2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = eat2.ogg; sourceTree = ""; }; + 84B1E17D2E051B7D00ED000A /* eat3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = eat3.ogg; sourceTree = ""; }; + 84B1E17E2E051B7D00ED000A /* explode.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = explode.ogg; sourceTree = ""; }; + 84B1E17F2E051B7D00ED000A /* explode1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = explode1.ogg; sourceTree = ""; }; + 84B1E1802E051B7D00ED000A /* explode2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = explode2.ogg; sourceTree = ""; }; + 84B1E1812E051B7D00ED000A /* explode3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = explode3.ogg; sourceTree = ""; }; + 84B1E1822E051B7D00ED000A /* explode4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = explode4.ogg; sourceTree = ""; }; + 84B1E1832E051B7D00ED000A /* fizz.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = fizz.ogg; sourceTree = ""; }; + 84B1E1842E051B7D00ED000A /* fuse.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = fuse.ogg; sourceTree = ""; }; + 84B1E1852E051B7D00ED000A /* glass1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = glass1.ogg; sourceTree = ""; }; + 84B1E1862E051B7D00ED000A /* glass2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = glass2.ogg; sourceTree = ""; }; + 84B1E1872E051B7D00ED000A /* glass3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = glass3.ogg; sourceTree = ""; }; + 84B1E1882E051B7D00ED000A /* hurt.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hurt.ogg; sourceTree = ""; }; + 84B1E1892E051B7D00ED000A /* levelup.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = levelup.ogg; sourceTree = ""; }; + 84B1E18A2E051B7D00ED000A /* old_explode.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = old_explode.ogg; sourceTree = ""; }; + 84B1E18B2E051B7D00ED000A /* orb.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = orb.ogg; sourceTree = ""; }; + 84B1E18C2E051B7D00ED000A /* pop.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = pop.ogg; sourceTree = ""; }; + 84B1E18D2E051B7D00ED000A /* splash.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = splash.ogg; sourceTree = ""; }; + 84B1E18E2E051B7D00ED000A /* wood click.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = "wood click.ogg"; sourceTree = ""; }; + 84B1E1902E051B7D00ED000A /* cloth1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cloth1.ogg; sourceTree = ""; }; + 84B1E1912E051B7D00ED000A /* cloth2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cloth2.ogg; sourceTree = ""; }; + 84B1E1922E051B7D00ED000A /* cloth3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cloth3.ogg; sourceTree = ""; }; + 84B1E1932E051B7D00ED000A /* cloth4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cloth4.ogg; sourceTree = ""; }; + 84B1E1942E051B7D00ED000A /* grass1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = grass1.ogg; sourceTree = ""; }; + 84B1E1952E051B7D00ED000A /* grass2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = grass2.ogg; sourceTree = ""; }; + 84B1E1962E051B7D00ED000A /* grass3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = grass3.ogg; sourceTree = ""; }; + 84B1E1972E051B7D00ED000A /* grass4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = grass4.ogg; sourceTree = ""; }; + 84B1E1982E051B7D00ED000A /* gravel1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = gravel1.ogg; sourceTree = ""; }; + 84B1E1992E051B7D00ED000A /* gravel2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = gravel2.ogg; sourceTree = ""; }; + 84B1E19A2E051B7D00ED000A /* gravel3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = gravel3.ogg; sourceTree = ""; }; + 84B1E19B2E051B7D00ED000A /* gravel4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = gravel4.ogg; sourceTree = ""; }; + 84B1E19C2E051B7D00ED000A /* sand1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = sand1.ogg; sourceTree = ""; }; + 84B1E19D2E051B7D00ED000A /* sand2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = sand2.ogg; sourceTree = ""; }; + 84B1E19E2E051B7D00ED000A /* sand3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = sand3.ogg; sourceTree = ""; }; + 84B1E19F2E051B7D00ED000A /* sand4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = sand4.ogg; sourceTree = ""; }; + 84B1E1A02E051B7D00ED000A /* snow1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = snow1.ogg; sourceTree = ""; }; + 84B1E1A12E051B7D00ED000A /* snow2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = snow2.ogg; sourceTree = ""; }; + 84B1E1A22E051B7D00ED000A /* snow3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = snow3.ogg; sourceTree = ""; }; + 84B1E1A32E051B7D00ED000A /* snow4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = snow4.ogg; sourceTree = ""; }; + 84B1E1A42E051B7D00ED000A /* stone1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = stone1.ogg; sourceTree = ""; }; + 84B1E1A52E051B7D00ED000A /* stone2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = stone2.ogg; sourceTree = ""; }; + 84B1E1A62E051B7D00ED000A /* stone3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = stone3.ogg; sourceTree = ""; }; + 84B1E1A72E051B7D00ED000A /* stone4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = stone4.ogg; sourceTree = ""; }; + 84B1E1A82E051B7D00ED000A /* wood1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = wood1.ogg; sourceTree = ""; }; + 84B1E1A92E051B7D00ED000A /* wood2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = wood2.ogg; sourceTree = ""; }; + 84B1E1AA2E051B7D00ED000A /* wood3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = wood3.ogg; sourceTree = ""; }; + 84B1E1AB2E051B7D00ED000A /* wood4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = wood4.ogg; sourceTree = ""; }; + 84B1E1AE2E051B7D00ED000A /* in.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = in.ogg; sourceTree = ""; }; + 84B1E1AF2E051B7D00ED000A /* out.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = out.ogg; sourceTree = ""; }; + 84B1E1B22E051B7D00ED000A /* grass1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = grass1.ogg; sourceTree = ""; }; + 84B1E1B32E051B7D00ED000A /* grass2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = grass2.ogg; sourceTree = ""; }; + 84B1E1B42E051B7D00ED000A /* grass3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = grass3.ogg; sourceTree = ""; }; + 84B1E1B52E051B7D00ED000A /* grass4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = grass4.ogg; sourceTree = ""; }; + 84B1E1B62E051B7D00ED000A /* gravel1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = gravel1.ogg; sourceTree = ""; }; + 84B1E1B72E051B7D00ED000A /* gravel2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = gravel2.ogg; sourceTree = ""; }; + 84B1E1B82E051B7D00ED000A /* gravel3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = gravel3.ogg; sourceTree = ""; }; + 84B1E1B92E051B7D00ED000A /* gravel4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = gravel4.ogg; sourceTree = ""; }; + 84B1E1BA2E051B7D00ED000A /* stone1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = stone1.ogg; sourceTree = ""; }; + 84B1E1BB2E051B7D00ED000A /* stone2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = stone2.ogg; sourceTree = ""; }; + 84B1E1BC2E051B7D00ED000A /* stone3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = stone3.ogg; sourceTree = ""; }; + 84B1E1BD2E051B7D00ED000A /* stone4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = stone4.ogg; sourceTree = ""; }; + 84B1E1BE2E051B7D00ED000A /* wood1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = wood1.ogg; sourceTree = ""; }; + 84B1E1BF2E051B7D00ED000A /* wood2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = wood2.ogg; sourceTree = ""; }; + 84B1E1C02E051B7D00ED000A /* wood3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = wood3.ogg; sourceTree = ""; }; + 84B1E1C12E051B7D00ED000A /* wood4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = wood4.ogg; sourceTree = ""; }; 84B8AEE72AF188D8008DE93D /* libClient.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libClient.a; sourceTree = BUILT_PRODUCTS_DIR; }; 84BF630B2AF1859D008A9995 /* libWorld.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libWorld.a; sourceTree = BUILT_PRODUCTS_DIR; }; 84C0D8002B159A0E007E1E76 /* GlobalSettings.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = GlobalSettings.xcconfig; path = ../Configuration/GlobalSettings.xcconfig; sourceTree = ""; }; @@ -2666,54 +3336,62 @@ 840DD6572AC810620006A435 /* entity */ = { isa = PBXGroup; children = ( - 84AA8B592B32F3B5003F5B82 /* Animal.hpp */, 84AA8B582B32F3B5003F5B82 /* Animal.cpp */, - 84AA8B5B2B32F3B5003F5B82 /* Chicken.hpp */, + 84AA8B592B32F3B5003F5B82 /* Animal.hpp */, + 84B1E0312E04FD7900ED000A /* Arrow.cpp */, + 84B1E0322E04FD7900ED000A /* Arrow.hpp */, 84AA8B5A2B32F3B5003F5B82 /* Chicken.cpp */, - 84AA8B5D2B32F3B5003F5B82 /* Cow.hpp */, + 84AA8B5B2B32F3B5003F5B82 /* Chicken.hpp */, 84AA8B5C2B32F3B5003F5B82 /* Cow.cpp */, - 84AA8B5F2B32F3B5003F5B82 /* Creeper.hpp */, + 84AA8B5D2B32F3B5003F5B82 /* Cow.hpp */, 84AA8B5E2B32F3B5003F5B82 /* Creeper.cpp */, - 840DD6592AC810620006A435 /* Entity.hpp */, + 84AA8B5F2B32F3B5003F5B82 /* Creeper.hpp */, 840DD6582AC810620006A435 /* Entity.cpp */, - 8445E7962D769329008DC834 /* EntityCategories.hpp */, + 840DD6592AC810620006A435 /* Entity.hpp */, 8445E7952D769329008DC834 /* EntityCategories.cpp */, - 8470AF282BE9B60900BCA54E /* EntityType.hpp */, + 8445E7962D769329008DC834 /* EntityCategories.hpp */, 8445E7972D769329008DC834 /* EntityType.cpp */, - 8445E7992D769329008DC834 /* EntityTypeDescriptor.hpp */, + 8470AF282BE9B60900BCA54E /* EntityType.hpp */, 8445E7982D769329008DC834 /* EntityTypeDescriptor.cpp */, - 840DD65B2AC810620006A435 /* FallingTile.hpp */, + 8445E7992D769329008DC834 /* EntityTypeDescriptor.hpp */, 840DD65A2AC810620006A435 /* FallingTile.cpp */, - 840DD65D2AC810620006A435 /* ItemEntity.hpp */, + 840DD65B2AC810620006A435 /* FallingTile.hpp */, 840DD65C2AC810620006A435 /* ItemEntity.cpp */, - 840DD65F2AC810620006A435 /* LocalPlayer.hpp */, + 840DD65D2AC810620006A435 /* ItemEntity.hpp */, 840DD65E2AC810620006A435 /* LocalPlayer.cpp */, - 840DD6612AC810620006A435 /* Mob.hpp */, + 840DD65F2AC810620006A435 /* LocalPlayer.hpp */, 840DD6602AC810620006A435 /* Mob.cpp */, - 8445E79B2D769329008DC834 /* MobCategory.hpp */, + 840DD6612AC810620006A435 /* Mob.hpp */, 8445E79A2D769329008DC834 /* MobCategory.cpp */, - 8470AF2A2BE9B60A00BCA54E /* MobFactory.hpp */, + 8445E79B2D769329008DC834 /* MobCategory.hpp */, 8470AF292BE9B60A00BCA54E /* MobFactory.cpp */, - 84AA8B6B2B32F3B5003F5B82 /* Monster.hpp */, + 8470AF2A2BE9B60A00BCA54E /* MobFactory.hpp */, 84AA8B6A2B32F3B5003F5B82 /* Monster.cpp */, - 84AA8B6D2B32F3B5003F5B82 /* PathfinderMob.hpp */, + 84AA8B6B2B32F3B5003F5B82 /* Monster.hpp */, 84AA8B6C2B32F3B5003F5B82 /* PathfinderMob.cpp */, - 84AA8B6F2B32F3B5003F5B82 /* Pig.hpp */, + 84AA8B6D2B32F3B5003F5B82 /* PathfinderMob.hpp */, 84AA8B6E2B32F3B5003F5B82 /* Pig.cpp */, - 840DD6632AC810620006A435 /* Player.hpp */, + 84AA8B6F2B32F3B5003F5B82 /* Pig.hpp */, 840DD6622AC810620006A435 /* Player.cpp */, - 840DD6652AC810620006A435 /* PrimedTnt.hpp */, + 840DD6632AC810620006A435 /* Player.hpp */, 840DD6642AC810620006A435 /* PrimedTnt.cpp */, - 84E78C7A2B58B3E000D515EF /* Rocket.hpp */, + 840DD6652AC810620006A435 /* PrimedTnt.hpp */, 84E78C792B58B3E000D515EF /* Rocket.cpp */, - 8445E79D2D769329008DC834 /* Sheep.hpp */, + 84E78C7A2B58B3E000D515EF /* Rocket.hpp */, 8445E79C2D769329008DC834 /* Sheep.cpp */, - 8445E79F2D769329008DC834 /* SynchedEntityData.hpp */, + 8445E79D2D769329008DC834 /* Sheep.hpp */, + 84B1E0332E04FD7900ED000A /* Skeleton.cpp */, + 84B1E0342E04FD7900ED000A /* Skeleton.hpp */, + 84B1E0352E04FD7900ED000A /* Spider.cpp */, + 84B1E0362E04FD7900ED000A /* Spider.hpp */, 8445E79E2D769329008DC834 /* SynchedEntityData.cpp */, - 840DD6672AC810620006A435 /* TripodCamera.hpp */, + 8445E79F2D769329008DC834 /* SynchedEntityData.hpp */, 840DD6662AC810620006A435 /* TripodCamera.cpp */, - 84AA8B772B32F3B5003F5B82 /* WaterAnimal.hpp */, + 840DD6672AC810620006A435 /* TripodCamera.hpp */, 84AA8B762B32F3B5003F5B82 /* WaterAnimal.cpp */, + 84AA8B772B32F3B5003F5B82 /* WaterAnimal.hpp */, + 84B1E0372E04FD7900ED000A /* Zombie.cpp */, + 84B1E0382E04FD7900ED000A /* Zombie.hpp */, ); path = entity; sourceTree = ""; @@ -3739,6 +4417,8 @@ 84AA8B9F2B32F3F3003F5B82 /* entity */ = { isa = PBXGroup; children = ( + 84B1E02D2E04FD4500ED000A /* ArrowRenderer.cpp */, + 84B1E02E2E04FD4500ED000A /* ArrowRenderer.hpp */, 84AA8BA12B32F3F3003F5B82 /* ChickenRenderer.hpp */, 84AA8BA02B32F3F3003F5B82 /* ChickenRenderer.cpp */, 84AA8BA32B32F3F3003F5B82 /* CowRenderer.hpp */, @@ -3767,16 +4447,12 @@ 84AA8BB62B32F3F3003F5B82 /* SheepFurRenderer.cpp */, 84AA8BB92B32F3F3003F5B82 /* SheepRenderer.hpp */, 84AA8BB82B32F3F3003F5B82 /* SheepRenderer.cpp */, - 84AA8BBB2B32F3F3003F5B82 /* SkeletonRenderer.hpp */, - 84AA8BBA2B32F3F3003F5B82 /* SkeletonRenderer.cpp */, 84AA8BBD2B32F3F3003F5B82 /* SpiderRenderer.hpp */, 84AA8BBC2B32F3F3003F5B82 /* SpiderRenderer.cpp */, 84AA8BBF2B32F3F3003F5B82 /* TntRenderer.hpp */, 84AA8BBE2B32F3F3003F5B82 /* TntRenderer.cpp */, 84AA8BC12B32F3F3003F5B82 /* TripodCameraRenderer.hpp */, 84AA8BC02B32F3F3003F5B82 /* TripodCameraRenderer.cpp */, - 84AA8BC32B32F3F3003F5B82 /* ZombieRenderer.hpp */, - 84AA8BC22B32F3F3003F5B82 /* ZombieRenderer.cpp */, ); path = entity; sourceTree = ""; @@ -3836,6 +4512,538 @@ path = ../../../../game; sourceTree = ""; }; + 84B1E06E2E051B7C00ED000A /* music */ = { + isa = PBXGroup; + children = ( + 84B1E06F2E051B7C00ED000A /* calm1.ogg */, + 84B1E0702E051B7C00ED000A /* calm2.ogg */, + 84B1E0712E051B7C00ED000A /* calm3.ogg */, + ); + path = music; + sourceTree = ""; + }; + 84B1E0722E051B7C00ED000A /* newmusic */ = { + isa = PBXGroup; + children = ( + 84B1E0732E051B7C00ED000A /* hal1.ogg */, + 84B1E0742E051B7C00ED000A /* hal2.ogg */, + 84B1E0752E051B7C00ED000A /* hal3.ogg */, + 84B1E0762E051B7C00ED000A /* hal4.ogg */, + 84B1E0772E051B7C00ED000A /* nuance1.ogg */, + 84B1E0782E051B7C00ED000A /* nuance2.ogg */, + 84B1E0792E051B7C00ED000A /* piano1.ogg */, + 84B1E07A2E051B7C00ED000A /* piano2.ogg */, + 84B1E07B2E051B7C00ED000A /* piano3.ogg */, + ); + path = newmusic; + sourceTree = ""; + }; + 84B1E07C2E051B7C00ED000A /* newsound */ = { + isa = PBXGroup; + children = ( + 84B1E07D2E051B7C00ED000A /* ambient */, + 84B1E0942E051B7C00ED000A /* damage */, + 84B1E09B2E051B7C00ED000A /* fire */, + 84B1E09E2E051B7C00ED000A /* liquid */, + 84B1E0A32E051B7C00ED000A /* mob */, + 84B1E15F2E051B7D00ED000A /* note */, + 84B1E1672E051B7D00ED000A /* portal */, + 84B1E16B2E051B7D00ED000A /* random */, + 84B1E18F2E051B7D00ED000A /* step */, + 84B1E1AC2E051B7D00ED000A /* tile */, + ); + path = newsound; + sourceTree = ""; + }; + 84B1E07D2E051B7C00ED000A /* ambient */ = { + isa = PBXGroup; + children = ( + 84B1E07E2E051B7C00ED000A /* cave */, + 84B1E08C2E051B7C00ED000A /* weather */, + ); + path = ambient; + sourceTree = ""; + }; + 84B1E07E2E051B7C00ED000A /* cave */ = { + isa = PBXGroup; + children = ( + 84B1E07F2E051B7C00ED000A /* cave1.ogg */, + 84B1E0802E051B7C00ED000A /* cave10.ogg */, + 84B1E0812E051B7C00ED000A /* cave11.ogg */, + 84B1E0822E051B7C00ED000A /* cave12.ogg */, + 84B1E0832E051B7C00ED000A /* cave13.ogg */, + 84B1E0842E051B7C00ED000A /* cave2.ogg */, + 84B1E0852E051B7C00ED000A /* cave3.ogg */, + 84B1E0862E051B7C00ED000A /* cave4.ogg */, + 84B1E0872E051B7C00ED000A /* cave5.ogg */, + 84B1E0882E051B7C00ED000A /* cave6.ogg */, + 84B1E0892E051B7C00ED000A /* cave7.ogg */, + 84B1E08A2E051B7C00ED000A /* cave8.ogg */, + 84B1E08B2E051B7C00ED000A /* cave9.ogg */, + ); + path = cave; + sourceTree = ""; + }; + 84B1E08C2E051B7C00ED000A /* weather */ = { + isa = PBXGroup; + children = ( + 84B1E08D2E051B7C00ED000A /* rain1.ogg */, + 84B1E08E2E051B7C00ED000A /* rain2.ogg */, + 84B1E08F2E051B7C00ED000A /* rain3.ogg */, + 84B1E0902E051B7C00ED000A /* rain4.ogg */, + 84B1E0912E051B7C00ED000A /* thunder1.ogg */, + 84B1E0922E051B7C00ED000A /* thunder2.ogg */, + 84B1E0932E051B7C00ED000A /* thunder3.ogg */, + ); + path = weather; + sourceTree = ""; + }; + 84B1E0942E051B7C00ED000A /* damage */ = { + isa = PBXGroup; + children = ( + 84B1E0952E051B7C00ED000A /* fallbig1.ogg */, + 84B1E0962E051B7C00ED000A /* fallbig2.ogg */, + 84B1E0972E051B7C00ED000A /* fallsmall.ogg */, + 84B1E0982E051B7C00ED000A /* hurtflesh1.ogg */, + 84B1E0992E051B7C00ED000A /* hurtflesh2.ogg */, + 84B1E09A2E051B7C00ED000A /* hurtflesh3.ogg */, + ); + path = damage; + sourceTree = ""; + }; + 84B1E09B2E051B7C00ED000A /* fire */ = { + isa = PBXGroup; + children = ( + 84B1E09C2E051B7C00ED000A /* fire.ogg */, + 84B1E09D2E051B7C00ED000A /* ignite.ogg */, + ); + path = fire; + sourceTree = ""; + }; + 84B1E09E2E051B7C00ED000A /* liquid */ = { + isa = PBXGroup; + children = ( + 84B1E09F2E051B7C00ED000A /* lava.ogg */, + 84B1E0A02E051B7C00ED000A /* lavapop.ogg */, + 84B1E0A12E051B7C00ED000A /* splash.ogg */, + 84B1E0A22E051B7C00ED000A /* water.ogg */, + ); + path = liquid; + sourceTree = ""; + }; + 84B1E0A32E051B7C00ED000A /* mob */ = { + isa = PBXGroup; + children = ( + 84B1E0A42E051B7C00ED000A /* blaze */, + 84B1E0AE2E051B7C00ED000A /* cat */, + 84B1E0BE2E051B7C00ED000A /* chicken1.ogg */, + 84B1E0BF2E051B7C00ED000A /* chicken2.ogg */, + 84B1E0C02E051B7C00ED000A /* chicken3.ogg */, + 84B1E0C12E051B7C00ED000A /* chickenhurt1.ogg */, + 84B1E0C22E051B7C00ED000A /* chickenhurt2.ogg */, + 84B1E0C32E051B7C00ED000A /* chickenplop.ogg */, + 84B1E0C42E051B7C00ED000A /* cow1.ogg */, + 84B1E0C52E051B7C00ED000A /* cow2.ogg */, + 84B1E0C62E051B7C00ED000A /* cow3.ogg */, + 84B1E0C72E051B7C00ED000A /* cow4.ogg */, + 84B1E0C82E051B7C00ED000A /* cowhurt1.ogg */, + 84B1E0C92E051B7C00ED000A /* cowhurt2.ogg */, + 84B1E0CA2E051B7C00ED000A /* cowhurt3.ogg */, + 84B1E0CB2E051B7C00ED000A /* creeper1.ogg */, + 84B1E0CC2E051B7C00ED000A /* creeper2.ogg */, + 84B1E0CD2E051B7C00ED000A /* creeper3.ogg */, + 84B1E0CE2E051B7C00ED000A /* creeper4.ogg */, + 84B1E0CF2E051B7C00ED000A /* creeperdeath.ogg */, + 84B1E0D02E051B7C00ED000A /* endermen */, + 84B1E0E22E051B7C00ED000A /* ghast */, + 84B1E0F32E051B7C00ED000A /* irongolem */, + 84B1E0FE2E051B7C00ED000A /* magmacube */, + 84B1E10C2E051B7C00ED000A /* pig1.ogg */, + 84B1E10D2E051B7C00ED000A /* pig2.ogg */, + 84B1E10E2E051B7C00ED000A /* pig3.ogg */, + 84B1E10F2E051B7C00ED000A /* pigdeath.ogg */, + 84B1E1102E051B7C00ED000A /* sheep1.ogg */, + 84B1E1112E051B7C00ED000A /* sheep2.ogg */, + 84B1E1122E051B7C00ED000A /* sheep3.ogg */, + 84B1E1132E051B7C00ED000A /* silverfish */, + 84B1E1202E051B7C00ED000A /* skeleton1.ogg */, + 84B1E1212E051B7C00ED000A /* skeleton2.ogg */, + 84B1E1222E051B7C00ED000A /* skeleton3.ogg */, + 84B1E1232E051B7D00ED000A /* skeletondeath.ogg */, + 84B1E1242E051B7D00ED000A /* skeletonhurt1.ogg */, + 84B1E1252E051B7D00ED000A /* skeletonhurt2.ogg */, + 84B1E1262E051B7D00ED000A /* skeletonhurt3.ogg */, + 84B1E1272E051B7D00ED000A /* skeletonhurt4.ogg */, + 84B1E1282E051B7D00ED000A /* slime1.ogg */, + 84B1E1292E051B7D00ED000A /* slime2.ogg */, + 84B1E12A2E051B7D00ED000A /* slime3.ogg */, + 84B1E12B2E051B7D00ED000A /* slime4.ogg */, + 84B1E12C2E051B7D00ED000A /* slime5.ogg */, + 84B1E12D2E051B7D00ED000A /* slimeattack1.ogg */, + 84B1E12E2E051B7D00ED000A /* slimeattack2.ogg */, + 84B1E12F2E051B7D00ED000A /* spider1.ogg */, + 84B1E1302E051B7D00ED000A /* spider2.ogg */, + 84B1E1312E051B7D00ED000A /* spider3.ogg */, + 84B1E1322E051B7D00ED000A /* spider4.ogg */, + 84B1E1332E051B7D00ED000A /* spiderdeath.ogg */, + 84B1E1342E051B7D00ED000A /* wolf */, + 84B1E1442E051B7D00ED000A /* zombie */, + 84B1E14D2E051B7D00ED000A /* zombie1.ogg */, + 84B1E14E2E051B7D00ED000A /* zombie2.ogg */, + 84B1E14F2E051B7D00ED000A /* zombie3.ogg */, + 84B1E1502E051B7D00ED000A /* zombiedeath.ogg */, + 84B1E1512E051B7D00ED000A /* zombiehurt1.ogg */, + 84B1E1522E051B7D00ED000A /* zombiehurt2.ogg */, + 84B1E1532E051B7D00ED000A /* zombiepig */, + ); + path = mob; + sourceTree = ""; + }; + 84B1E0A42E051B7C00ED000A /* blaze */ = { + isa = PBXGroup; + children = ( + 84B1E0A52E051B7C00ED000A /* breathe1.ogg */, + 84B1E0A62E051B7C00ED000A /* breathe2.ogg */, + 84B1E0A72E051B7C00ED000A /* breathe3.ogg */, + 84B1E0A82E051B7C00ED000A /* breathe4.ogg */, + 84B1E0A92E051B7C00ED000A /* death.ogg */, + 84B1E0AA2E051B7C00ED000A /* hit1.ogg */, + 84B1E0AB2E051B7C00ED000A /* hit2.ogg */, + 84B1E0AC2E051B7C00ED000A /* hit3.ogg */, + 84B1E0AD2E051B7C00ED000A /* hit4.ogg */, + ); + path = blaze; + sourceTree = ""; + }; + 84B1E0AE2E051B7C00ED000A /* cat */ = { + isa = PBXGroup; + children = ( + 84B1E0AF2E051B7C00ED000A /* hiss1.ogg */, + 84B1E0B02E051B7C00ED000A /* hiss2.ogg */, + 84B1E0B12E051B7C00ED000A /* hiss3.ogg */, + 84B1E0B22E051B7C00ED000A /* hitt1.ogg */, + 84B1E0B32E051B7C00ED000A /* hitt2.ogg */, + 84B1E0B42E051B7C00ED000A /* hitt3.ogg */, + 84B1E0B52E051B7C00ED000A /* meow1.ogg */, + 84B1E0B62E051B7C00ED000A /* meow2.ogg */, + 84B1E0B72E051B7C00ED000A /* meow3.ogg */, + 84B1E0B82E051B7C00ED000A /* meow4.ogg */, + 84B1E0B92E051B7C00ED000A /* purr1.ogg */, + 84B1E0BA2E051B7C00ED000A /* purr2.ogg */, + 84B1E0BB2E051B7C00ED000A /* purr3.ogg */, + 84B1E0BC2E051B7C00ED000A /* purreow1.ogg */, + 84B1E0BD2E051B7C00ED000A /* purreow2.ogg */, + ); + path = cat; + sourceTree = ""; + }; + 84B1E0D02E051B7C00ED000A /* endermen */ = { + isa = PBXGroup; + children = ( + 84B1E0D12E051B7C00ED000A /* death.ogg */, + 84B1E0D22E051B7C00ED000A /* hit1.ogg */, + 84B1E0D32E051B7C00ED000A /* hit2.ogg */, + 84B1E0D42E051B7C00ED000A /* hit3.ogg */, + 84B1E0D52E051B7C00ED000A /* hit4.ogg */, + 84B1E0D62E051B7C00ED000A /* idle1.ogg */, + 84B1E0D72E051B7C00ED000A /* idle2.ogg */, + 84B1E0D82E051B7C00ED000A /* idle3.ogg */, + 84B1E0D92E051B7C00ED000A /* idle4.ogg */, + 84B1E0DA2E051B7C00ED000A /* idle5.ogg */, + 84B1E0DB2E051B7C00ED000A /* portal.ogg */, + 84B1E0DC2E051B7C00ED000A /* portal2.ogg */, + 84B1E0DD2E051B7C00ED000A /* scream1.ogg */, + 84B1E0DE2E051B7C00ED000A /* scream2.ogg */, + 84B1E0DF2E051B7C00ED000A /* scream3.ogg */, + 84B1E0E02E051B7C00ED000A /* scream4.ogg */, + 84B1E0E12E051B7C00ED000A /* stare.ogg */, + ); + path = endermen; + sourceTree = ""; + }; + 84B1E0E22E051B7C00ED000A /* ghast */ = { + isa = PBXGroup; + children = ( + 84B1E0E32E051B7C00ED000A /* affectionate scream.ogg */, + 84B1E0E42E051B7C00ED000A /* charge.ogg */, + 84B1E0E52E051B7C00ED000A /* death.ogg */, + 84B1E0E62E051B7C00ED000A /* fireball4.ogg */, + 84B1E0E72E051B7C00ED000A /* moan1.ogg */, + 84B1E0E82E051B7C00ED000A /* moan2.ogg */, + 84B1E0E92E051B7C00ED000A /* moan3.ogg */, + 84B1E0EA2E051B7C00ED000A /* moan4.ogg */, + 84B1E0EB2E051B7C00ED000A /* moan5.ogg */, + 84B1E0EC2E051B7C00ED000A /* moan6.ogg */, + 84B1E0ED2E051B7C00ED000A /* moan7.ogg */, + 84B1E0EE2E051B7C00ED000A /* scream1.ogg */, + 84B1E0EF2E051B7C00ED000A /* scream2.ogg */, + 84B1E0F02E051B7C00ED000A /* scream3.ogg */, + 84B1E0F12E051B7C00ED000A /* scream4.ogg */, + 84B1E0F22E051B7C00ED000A /* scream5.ogg */, + ); + path = ghast; + sourceTree = ""; + }; + 84B1E0F32E051B7C00ED000A /* irongolem */ = { + isa = PBXGroup; + children = ( + 84B1E0F42E051B7C00ED000A /* death.ogg */, + 84B1E0F52E051B7C00ED000A /* hit1.ogg */, + 84B1E0F62E051B7C00ED000A /* hit2.ogg */, + 84B1E0F72E051B7C00ED000A /* hit3.ogg */, + 84B1E0F82E051B7C00ED000A /* hit4.ogg */, + 84B1E0F92E051B7C00ED000A /* throw.ogg */, + 84B1E0FA2E051B7C00ED000A /* walk1.ogg */, + 84B1E0FB2E051B7C00ED000A /* walk2.ogg */, + 84B1E0FC2E051B7C00ED000A /* walk3.ogg */, + 84B1E0FD2E051B7C00ED000A /* walk4.ogg */, + ); + path = irongolem; + sourceTree = ""; + }; + 84B1E0FE2E051B7C00ED000A /* magmacube */ = { + isa = PBXGroup; + children = ( + 84B1E0FF2E051B7C00ED000A /* big1.ogg */, + 84B1E1002E051B7C00ED000A /* big2.ogg */, + 84B1E1012E051B7C00ED000A /* big3.ogg */, + 84B1E1022E051B7C00ED000A /* big4.ogg */, + 84B1E1032E051B7C00ED000A /* jump1.ogg */, + 84B1E1042E051B7C00ED000A /* jump2.ogg */, + 84B1E1052E051B7C00ED000A /* jump3.ogg */, + 84B1E1062E051B7C00ED000A /* jump4.ogg */, + 84B1E1072E051B7C00ED000A /* small1.ogg */, + 84B1E1082E051B7C00ED000A /* small2.ogg */, + 84B1E1092E051B7C00ED000A /* small3.ogg */, + 84B1E10A2E051B7C00ED000A /* small4.ogg */, + 84B1E10B2E051B7C00ED000A /* small5.ogg */, + ); + path = magmacube; + sourceTree = ""; + }; + 84B1E1132E051B7C00ED000A /* silverfish */ = { + isa = PBXGroup; + children = ( + 84B1E1142E051B7C00ED000A /* hit1.ogg */, + 84B1E1152E051B7C00ED000A /* hit2.ogg */, + 84B1E1162E051B7C00ED000A /* hit3.ogg */, + 84B1E1172E051B7C00ED000A /* kill.ogg */, + 84B1E1182E051B7C00ED000A /* say1.ogg */, + 84B1E1192E051B7C00ED000A /* say2.ogg */, + 84B1E11A2E051B7C00ED000A /* say3.ogg */, + 84B1E11B2E051B7C00ED000A /* say4.ogg */, + 84B1E11C2E051B7C00ED000A /* step1.ogg */, + 84B1E11D2E051B7C00ED000A /* step2.ogg */, + 84B1E11E2E051B7C00ED000A /* step3.ogg */, + 84B1E11F2E051B7C00ED000A /* step4.ogg */, + ); + path = silverfish; + sourceTree = ""; + }; + 84B1E1342E051B7D00ED000A /* wolf */ = { + isa = PBXGroup; + children = ( + 84B1E1352E051B7D00ED000A /* bark1.ogg */, + 84B1E1362E051B7D00ED000A /* bark2.ogg */, + 84B1E1372E051B7D00ED000A /* bark3.ogg */, + 84B1E1382E051B7D00ED000A /* death.ogg */, + 84B1E1392E051B7D00ED000A /* growl1.ogg */, + 84B1E13A2E051B7D00ED000A /* growl2.ogg */, + 84B1E13B2E051B7D00ED000A /* growl3.ogg */, + 84B1E13C2E051B7D00ED000A /* howl1.ogg */, + 84B1E13D2E051B7D00ED000A /* howl2.ogg */, + 84B1E13E2E051B7D00ED000A /* hurt1.ogg */, + 84B1E13F2E051B7D00ED000A /* hurt2.ogg */, + 84B1E1402E051B7D00ED000A /* hurt3.ogg */, + 84B1E1412E051B7D00ED000A /* panting.ogg */, + 84B1E1422E051B7D00ED000A /* shake.ogg */, + 84B1E1432E051B7D00ED000A /* whine.ogg */, + ); + path = wolf; + sourceTree = ""; + }; + 84B1E1442E051B7D00ED000A /* zombie */ = { + isa = PBXGroup; + children = ( + 84B1E1452E051B7D00ED000A /* metal1.ogg */, + 84B1E1462E051B7D00ED000A /* metal2.ogg */, + 84B1E1472E051B7D00ED000A /* metal3.ogg */, + 84B1E1482E051B7D00ED000A /* wood1.ogg */, + 84B1E1492E051B7D00ED000A /* wood2.ogg */, + 84B1E14A2E051B7D00ED000A /* wood3.ogg */, + 84B1E14B2E051B7D00ED000A /* wood4.ogg */, + 84B1E14C2E051B7D00ED000A /* woodbreak.ogg */, + ); + path = zombie; + sourceTree = ""; + }; + 84B1E1532E051B7D00ED000A /* zombiepig */ = { + isa = PBXGroup; + children = ( + 84B1E1542E051B7D00ED000A /* zpig1.ogg */, + 84B1E1552E051B7D00ED000A /* zpig2.ogg */, + 84B1E1562E051B7D00ED000A /* zpig3.ogg */, + 84B1E1572E051B7D00ED000A /* zpig4.ogg */, + 84B1E1582E051B7D00ED000A /* zpigangry1.ogg */, + 84B1E1592E051B7D00ED000A /* zpigangry2.ogg */, + 84B1E15A2E051B7D00ED000A /* zpigangry3.ogg */, + 84B1E15B2E051B7D00ED000A /* zpigangry4.ogg */, + 84B1E15C2E051B7D00ED000A /* zpigdeath.ogg */, + 84B1E15D2E051B7D00ED000A /* zpighurt1.ogg */, + 84B1E15E2E051B7D00ED000A /* zpighurt2.ogg */, + ); + path = zombiepig; + sourceTree = ""; + }; + 84B1E15F2E051B7D00ED000A /* note */ = { + isa = PBXGroup; + children = ( + 84B1E1602E051B7D00ED000A /* bass.ogg */, + 84B1E1612E051B7D00ED000A /* bassattack.ogg */, + 84B1E1622E051B7D00ED000A /* bd.ogg */, + 84B1E1632E051B7D00ED000A /* harp.ogg */, + 84B1E1642E051B7D00ED000A /* hat.ogg */, + 84B1E1652E051B7D00ED000A /* pling.ogg */, + 84B1E1662E051B7D00ED000A /* snare.ogg */, + ); + path = note; + sourceTree = ""; + }; + 84B1E1672E051B7D00ED000A /* portal */ = { + isa = PBXGroup; + children = ( + 84B1E1682E051B7D00ED000A /* portal.ogg */, + 84B1E1692E051B7D00ED000A /* travel.ogg */, + 84B1E16A2E051B7D00ED000A /* trigger.ogg */, + ); + path = portal; + sourceTree = ""; + }; + 84B1E16B2E051B7D00ED000A /* random */ = { + isa = PBXGroup; + children = ( + 84B1E16C2E051B7D00ED000A /* bow.ogg */, + 84B1E16D2E051B7D00ED000A /* bowhit1.ogg */, + 84B1E16E2E051B7D00ED000A /* bowhit2.ogg */, + 84B1E16F2E051B7D00ED000A /* bowhit3.ogg */, + 84B1E1702E051B7D00ED000A /* bowhit4.ogg */, + 84B1E1712E051B7D00ED000A /* break.ogg */, + 84B1E1722E051B7D00ED000A /* breath.ogg */, + 84B1E1732E051B7D00ED000A /* burp.ogg */, + 84B1E1742E051B7D00ED000A /* chestclosed.ogg */, + 84B1E1752E051B7D00ED000A /* chestopen.ogg */, + 84B1E1762E051B7D00ED000A /* click.ogg */, + 84B1E1772E051B7D00ED000A /* door_close.ogg */, + 84B1E1782E051B7D00ED000A /* door_open.ogg */, + 84B1E1792E051B7D00ED000A /* drink.ogg */, + 84B1E17A2E051B7D00ED000A /* drr.ogg */, + 84B1E17B2E051B7D00ED000A /* eat1.ogg */, + 84B1E17C2E051B7D00ED000A /* eat2.ogg */, + 84B1E17D2E051B7D00ED000A /* eat3.ogg */, + 84B1E17E2E051B7D00ED000A /* explode.ogg */, + 84B1E17F2E051B7D00ED000A /* explode1.ogg */, + 84B1E1802E051B7D00ED000A /* explode2.ogg */, + 84B1E1812E051B7D00ED000A /* explode3.ogg */, + 84B1E1822E051B7D00ED000A /* explode4.ogg */, + 84B1E1832E051B7D00ED000A /* fizz.ogg */, + 84B1E1842E051B7D00ED000A /* fuse.ogg */, + 84B1E1852E051B7D00ED000A /* glass1.ogg */, + 84B1E1862E051B7D00ED000A /* glass2.ogg */, + 84B1E1872E051B7D00ED000A /* glass3.ogg */, + 84B1E1882E051B7D00ED000A /* hurt.ogg */, + 84B1E1892E051B7D00ED000A /* levelup.ogg */, + 84B1E18A2E051B7D00ED000A /* old_explode.ogg */, + 84B1E18B2E051B7D00ED000A /* orb.ogg */, + 84B1E18C2E051B7D00ED000A /* pop.ogg */, + 84B1E18D2E051B7D00ED000A /* splash.ogg */, + 84B1E18E2E051B7D00ED000A /* wood click.ogg */, + ); + path = random; + sourceTree = ""; + }; + 84B1E18F2E051B7D00ED000A /* step */ = { + isa = PBXGroup; + children = ( + 84B1E1902E051B7D00ED000A /* cloth1.ogg */, + 84B1E1912E051B7D00ED000A /* cloth2.ogg */, + 84B1E1922E051B7D00ED000A /* cloth3.ogg */, + 84B1E1932E051B7D00ED000A /* cloth4.ogg */, + 84B1E1942E051B7D00ED000A /* grass1.ogg */, + 84B1E1952E051B7D00ED000A /* grass2.ogg */, + 84B1E1962E051B7D00ED000A /* grass3.ogg */, + 84B1E1972E051B7D00ED000A /* grass4.ogg */, + 84B1E1982E051B7D00ED000A /* gravel1.ogg */, + 84B1E1992E051B7D00ED000A /* gravel2.ogg */, + 84B1E19A2E051B7D00ED000A /* gravel3.ogg */, + 84B1E19B2E051B7D00ED000A /* gravel4.ogg */, + 84B1E19C2E051B7D00ED000A /* sand1.ogg */, + 84B1E19D2E051B7D00ED000A /* sand2.ogg */, + 84B1E19E2E051B7D00ED000A /* sand3.ogg */, + 84B1E19F2E051B7D00ED000A /* sand4.ogg */, + 84B1E1A02E051B7D00ED000A /* snow1.ogg */, + 84B1E1A12E051B7D00ED000A /* snow2.ogg */, + 84B1E1A22E051B7D00ED000A /* snow3.ogg */, + 84B1E1A32E051B7D00ED000A /* snow4.ogg */, + 84B1E1A42E051B7D00ED000A /* stone1.ogg */, + 84B1E1A52E051B7D00ED000A /* stone2.ogg */, + 84B1E1A62E051B7D00ED000A /* stone3.ogg */, + 84B1E1A72E051B7D00ED000A /* stone4.ogg */, + 84B1E1A82E051B7D00ED000A /* wood1.ogg */, + 84B1E1A92E051B7D00ED000A /* wood2.ogg */, + 84B1E1AA2E051B7D00ED000A /* wood3.ogg */, + 84B1E1AB2E051B7D00ED000A /* wood4.ogg */, + ); + path = step; + sourceTree = ""; + }; + 84B1E1AC2E051B7D00ED000A /* tile */ = { + isa = PBXGroup; + children = ( + 84B1E1AD2E051B7D00ED000A /* piston */, + ); + path = tile; + sourceTree = ""; + }; + 84B1E1AD2E051B7D00ED000A /* piston */ = { + isa = PBXGroup; + children = ( + 84B1E1AE2E051B7D00ED000A /* in.ogg */, + 84B1E1AF2E051B7D00ED000A /* out.ogg */, + ); + path = piston; + sourceTree = ""; + }; + 84B1E1B02E051B7D00ED000A /* sound */ = { + isa = PBXGroup; + children = ( + 84B1E1B12E051B7D00ED000A /* step */, + ); + path = sound; + sourceTree = ""; + }; + 84B1E1B12E051B7D00ED000A /* step */ = { + isa = PBXGroup; + children = ( + 84B1E1B22E051B7D00ED000A /* grass1.ogg */, + 84B1E1B32E051B7D00ED000A /* grass2.ogg */, + 84B1E1B42E051B7D00ED000A /* grass3.ogg */, + 84B1E1B52E051B7D00ED000A /* grass4.ogg */, + 84B1E1B62E051B7D00ED000A /* gravel1.ogg */, + 84B1E1B72E051B7D00ED000A /* gravel2.ogg */, + 84B1E1B82E051B7D00ED000A /* gravel3.ogg */, + 84B1E1B92E051B7D00ED000A /* gravel4.ogg */, + 84B1E1BA2E051B7D00ED000A /* stone1.ogg */, + 84B1E1BB2E051B7D00ED000A /* stone2.ogg */, + 84B1E1BC2E051B7D00ED000A /* stone3.ogg */, + 84B1E1BD2E051B7D00ED000A /* stone4.ogg */, + 84B1E1BE2E051B7D00ED000A /* wood1.ogg */, + 84B1E1BF2E051B7D00ED000A /* wood2.ogg */, + 84B1E1C02E051B7D00ED000A /* wood3.ogg */, + 84B1E1C12E051B7D00ED000A /* wood4.ogg */, + ); + path = step; + sourceTree = ""; + }; 84C208502AF88A5000BAE438 /* patches */ = { isa = PBXGroup; children = ( @@ -3870,9 +5078,13 @@ 84E0018B2AF3A28B009B9555 /* item */, 849488242C92844C006DB706 /* misc */, 84E0018D2AF3A28B009B9555 /* mob */, + 84B1E06E2E051B7C00ED000A /* music */, + 84B1E0722E051B7C00ED000A /* newmusic */, + 84B1E07C2E051B7C00ED000A /* newsound */, 84E0018F2AF3A28B009B9555 /* particles.png */, 84C208502AF88A5000BAE438 /* patches */, 84E001902AF3A28B009B9555 /* readme.txt */, + 84B1E1B02E051B7D00ED000A /* sound */, 8494882F2C928459006DB706 /* terrain */, 84E001912AF3A28B009B9555 /* terrain.png */, ); @@ -3931,6 +5143,23 @@ isa = PBXGroup; children = ( 84E0018E2AF3A28B009B9555 /* char.png */, + 84B1E0412E050D2500ED000A /* chicken.png */, + 84B1E0422E050D2500ED000A /* cow.png */, + 84B1E0432E050D2500ED000A /* creeper.png */, + 84B1E0452E050D2500ED000A /* ghast.png */, + 84B1E0442E050D2500ED000A /* ghast_fire.png */, + 84B1E0462E050D2500ED000A /* pig.png */, + 84B1E0472E050D2500ED000A /* pigman.png */, + 84B1E0482E050D2500ED000A /* pigzombie.png */, + 84B1E0492E050D2500ED000A /* saddle.png */, + 84B1E04B2E050D2500ED000A /* sheep.png */, + 84B1E04A2E050D2500ED000A /* sheep_fur.png */, + 84B1E04C2E050D2500ED000A /* skeleton.png */, + 84B1E04D2E050D2500ED000A /* slime.png */, + 84B1E04F2E050D2500ED000A /* spider.png */, + 84B1E04E2E050D2500ED000A /* spider_eyes.png */, + 84B1E0502E050D2500ED000A /* squid.png */, + 84B1E0512E050D2500ED000A /* zombie.png */, ); path = mob; sourceTree = ""; @@ -4088,11 +5317,9 @@ 84AA8C062B32F3F3003F5B82 /* PigRenderer.hpp in Headers */, 84AA8C082B32F3F3003F5B82 /* SheepFurRenderer.hpp in Headers */, 84AA8C0A2B32F3F3003F5B82 /* SheepRenderer.hpp in Headers */, - 84AA8C0C2B32F3F3003F5B82 /* SkeletonRenderer.hpp in Headers */, 84AA8C0E2B32F3F3003F5B82 /* SpiderRenderer.hpp in Headers */, 84AA8C102B32F3F3003F5B82 /* TntRenderer.hpp in Headers */, 84AA8C122B32F3F3003F5B82 /* TripodCameraRenderer.hpp in Headers */, - 84AA8C142B32F3F3003F5B82 /* ZombieRenderer.hpp in Headers */, 84AA8C172B32F3F3003F5B82 /* FoliageColor.hpp in Headers */, 84AA8C192B32F3F3003F5B82 /* Font.hpp in Headers */, 84AA8C1B2B32F3F3003F5B82 /* Frustum.hpp in Headers */, @@ -4103,6 +5330,7 @@ 84AA8C272B32F3F3003F5B82 /* LevelRenderer.hpp in Headers */, 84AA8C292B32F3F3003F5B82 /* LightLayer.hpp in Headers */, 84A2FF182DB61D440090CE3E /* SoundPathRepository.hpp in Headers */, + 84B1E0302E04FD4500ED000A /* ArrowRenderer.hpp in Headers */, 84AA8C2B2B32F3F3003F5B82 /* LightUpdate.hpp in Headers */, 84AA8C2D2B32F3F3003F5B82 /* PatchManager.hpp in Headers */, 84AA8C2F2B32F3F3003F5B82 /* RenderChunk.hpp in Headers */, @@ -4136,6 +5364,7 @@ buildActionMask = 2147483647; files = ( 84BF63792AF186C8008A9995 /* Entity.hpp in Headers */, + 84B1E03C2E04FD7900ED000A /* Skeleton.hpp in Headers */, 84BF637A2AF186C8008A9995 /* FallingTile.hpp in Headers */, 84BF637B2AF186C8008A9995 /* ItemEntity.hpp in Headers */, 84BF637C2AF186C8008A9995 /* LocalPlayer.hpp in Headers */, @@ -4165,6 +5394,7 @@ 84BF63912AF186C8008A9995 /* ChunkSource.hpp in Headers */, 84BF63922AF186C8008A9995 /* LevelChunk.hpp in Headers */, 84BF63932AF186C8008A9995 /* PerformanceTestChunkSource.hpp in Headers */, + 84B1E03A2E04FD7900ED000A /* Arrow.hpp in Headers */, 84BF63942AF186C8008A9995 /* RandomLevelSource.hpp in Headers */, 84BF63952AF186C8008A9995 /* TestChunkSource.hpp in Headers */, 84BF63962AF186C8008A9995 /* Feature.hpp in Headers */, @@ -4191,6 +5421,7 @@ 84BF63A92AF186C8008A9995 /* RegionFile.hpp in Headers */, 84BF63AA2AF186C8008A9995 /* TickNextTickData.hpp in Headers */, 84BF63AB2AF186C8008A9995 /* Particle.hpp in Headers */, + 84B1E0402E04FD7900ED000A /* Zombie.hpp in Headers */, 84BF63AC2AF186C8008A9995 /* ParticleEngine.hpp in Headers */, 84BF63AD2AF186C8008A9995 /* AABB.hpp in Headers */, 84BF63AE2AF186C9008A9995 /* HitResult.hpp in Headers */, @@ -4244,6 +5475,7 @@ 84AA8B7D2B32F3B5003F5B82 /* Cow.hpp in Headers */, 84AA8B7F2B32F3B5003F5B82 /* Creeper.hpp in Headers */, 84AA8B8B2B32F3B5003F5B82 /* Monster.hpp in Headers */, + 84B1E03E2E04FD7900ED000A /* Spider.hpp in Headers */, 84AA8B8D2B32F3B5003F5B82 /* PathfinderMob.hpp in Headers */, 84AA8B8F2B32F3B5003F5B82 /* Pig.hpp in Headers */, 8477B3BB2C4DC42E004E1AC5 /* Vec2.hpp in Headers */, @@ -4684,116 +5916,445 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 84B1E29F2E051B7D00ED000A /* bass.ogg in Resources */, 8470AF442BE9B98000BCA54E /* clouds.png in Resources */, + 84B1E2C52E051B7D00ED000A /* hurt.ogg in Resources */, + 84B1E1F82E051B7D00ED000A /* hiss2.ogg in Resources */, + 84B1E26F2E051B7D00ED000A /* slime5.ogg in Resources */, 8477B41C2C4DE77F004E1AC5 /* creative_1_4.png in Resources */, + 84B1E2B52E051B7D00ED000A /* door_open.ogg in Resources */, 849259562AD8FD4F0081F5B9 /* minecraftpeViewController.xib in Resources */, + 84B1E1E72E051B7D00ED000A /* hurtflesh3.ogg in Resources */, + 84B1E2842E051B7D00ED000A /* shake.ogg in Resources */, + 84B1E1D22E051B7D00ED000A /* cave13.ogg in Resources */, + 84B1E1F92E051B7D00ED000A /* hiss3.ogg in Resources */, + 84B1E21B2E051B7D00ED000A /* hit3.ogg in Resources */, + 84B1E2CA2E051B7D00ED000A /* splash.ogg in Resources */, + 84B1E1C62E051B7D00ED000A /* hal2.ogg in Resources */, + 84B1E24D2E051B7D00ED000A /* small3.ogg in Resources */, + 84B1E27D2E051B7D00ED000A /* growl3.ogg in Resources */, + 84B1E06D2E051B6400ED000A /* zombie.png in Resources */, 8477B4312C4DE77F004E1AC5 /* create_1_3.png in Resources */, 8477B4482C4DE77F004E1AC5 /* Icon_lite.png in Resources */, 8477B44D2C4DE77F004E1AC5 /* Default.png in Resources */, + 84B1E2ED2E051B7D00ED000A /* grass4.ogg in Resources */, 849488332C928459006DB706 /* sun.png in Resources */, + 84B1E2432E051B7D00ED000A /* big1.ogg in Resources */, + 84B1E1FD2E051B7D00ED000A /* meow1.ogg in Resources */, + 84B1E2672E051B7D00ED000A /* skeletonhurt1.ogg in Resources */, 8477B40A2C4DE77F004E1AC5 /* bg64.png in Resources */, + 84B1E2922E051B7D00ED000A /* zombiehurt1.ogg in Resources */, + 84B1E2892E051B7D00ED000A /* wood1.ogg in Resources */, + 84B1E2AC2E051B7D00ED000A /* bowhit3.ogg in Resources */, 8477B4382C4DE77F004E1AC5 /* worldname_ipad.png in Resources */, + 84B1E2152E051B7D00ED000A /* creeper3.ogg in Resources */, + 84B1E2C32E051B7D00ED000A /* glass2.ogg in Resources */, + 84B1E29D2E051B7D00ED000A /* zpighurt1.ogg in Resources */, + 84B1E2232E051B7D00ED000A /* portal2.ogg in Resources */, + 84B1E2AB2E051B7D00ED000A /* bowhit2.ogg in Resources */, + 84B1E2352E051B7D00ED000A /* scream2.ogg in Resources */, + 84B1E23B2E051B7D00ED000A /* hit2.ogg in Resources */, + 84B1E2192E051B7D00ED000A /* hit1.ogg in Resources */, 849259602AD8FDCB0081F5B9 /* InfoPlist.strings in Resources */, + 84B1E2CE2E051B7D00ED000A /* cloth3.ogg in Resources */, 849259642AD8FDD90081F5B9 /* minecraftpe-Info.plist in Resources */, + 84B1E2EB2E051B7D00ED000A /* grass2.ogg in Resources */, + 84B1E22C2E051B7D00ED000A /* fireball4.ogg in Resources */, + 84B1E2C12E051B7D00ED000A /* fuse.ogg in Resources */, 8477B4292C4DE77F004E1AC5 /* worldname_iphone_3.png in Resources */, 8477B4102C4DE77F004E1AC5 /* cancel_1_3.png in Resources */, + 84B1E2342E051B7D00ED000A /* scream1.ogg in Resources */, 8477B4152C4DE77F004E1AC5 /* create_1_1.png in Resources */, 8477B40F2C4DE77F004E1AC5 /* cancel_1_1.png in Resources */, 84E001BB2AF3AF9B009B9555 /* MainWindow.xib in Resources */, + 84B1E2EC2E051B7D00ED000A /* grass3.ogg in Resources */, + 84B1E2F32E051B7D00ED000A /* stone2.ogg in Resources */, + 84B1E2B42E051B7D00ED000A /* door_close.ogg in Resources */, + 84B1E0682E051B6400ED000A /* sheep.png in Resources */, + 84B1E20F2E051B7D00ED000A /* cow4.ogg in Resources */, 8477B4422C4DE77F004E1AC5 /* Icon-Small@2x.png in Resources */, 8494882B2C92844C006DB706 /* grasscolor.png in Resources */, + 84B1E2392E051B7D00ED000A /* death.ogg in Resources */, + 84B1E2D12E051B7D00ED000A /* grass2.ogg in Resources */, + 84B1E2272E051B7D00ED000A /* scream4.ogg in Resources */, + 84B1E27E2E051B7D00ED000A /* howl1.ogg in Resources */, 849FF0B72AF465340013BAE3 /* default8.png in Resources */, + 84B1E2A22E051B7D00ED000A /* harp.ogg in Resources */, + 84B1E24B2E051B7D00ED000A /* small1.ogg in Resources */, + 84B1E2E62E051B7D00ED000A /* wood3.ogg in Resources */, + 84B1E06A2E051B6400ED000A /* skeleton.png in Resources */, + 84B1E29C2E051B7D00ED000A /* zpigdeath.ogg in Resources */, + 84B1E1C72E051B7D00ED000A /* hal3.ogg in Resources */, 8477B4262C4DE77F004E1AC5 /* worldname_ipad.png in Resources */, + 84B1E2E92E051B7D00ED000A /* out.ogg in Resources */, 8477B4212C4DE77F004E1AC5 /* worldname_ipad_4.png in Resources */, + 84B1E2C62E051B7D00ED000A /* levelup.ogg in Resources */, + 84B1E2D72E051B7D00ED000A /* gravel4.ogg in Resources */, + 84B1E25C2E051B7D00ED000A /* say2.ogg in Resources */, + 84B1E1D92E051B7D00ED000A /* cave8.ogg in Resources */, 849FF0B82AF465340013BAE3 /* panorama_0.png in Resources */, + 84B1E2062E051B7D00ED000A /* chicken1.ogg in Resources */, 8477B43B2C4DE77F004E1AC5 /* worldname_iphone5_3.png in Resources */, 8477B4192C4DE77F004E1AC5 /* create_0_4.png in Resources */, + 84B1E2162E051B7D00ED000A /* creeper4.ogg in Resources */, + 84B1E2962E051B7D00ED000A /* zpig3.ogg in Resources */, + 84B1E2652E051B7D00ED000A /* skeleton3.ogg in Resources */, 8477B4372C4DE77F004E1AC5 /* worldname_3.png in Resources */, + 84B1E2EA2E051B7D00ED000A /* grass1.ogg in Resources */, 849FF0B92AF465340013BAE3 /* panorama_1.png in Resources */, + 84B1E26A2E051B7D00ED000A /* skeletonhurt4.ogg in Resources */, 8477B4432C4DE77F004E1AC5 /* Icon-Small@2x_lite.png in Resources */, + 84B1E2732E051B7D00ED000A /* spider2.ogg in Resources */, + 84B1E1F52E051B7D00ED000A /* hit3.ogg in Resources */, + 84B1E1DC2E051B7D00ED000A /* rain2.ogg in Resources */, + 84B1E2402E051B7D00ED000A /* walk2.ogg in Resources */, + 84B1E2BB2E051B7D00ED000A /* explode.ogg in Resources */, + 84B1E24A2E051B7D00ED000A /* jump4.ogg in Resources */, + 84B1E27A2E051B7D00ED000A /* death.ogg in Resources */, 849FF0BA2AF465340013BAE3 /* panorama_2.png in Resources */, + 84B1E29B2E051B7D00ED000A /* zpigangry4.ogg in Resources */, + 84B1E29A2E051B7D00ED000A /* zpigangry3.ogg in Resources */, + 84B1E2912E051B7D00ED000A /* zombiedeath.ogg in Resources */, + 84B1E0612E050D2500ED000A /* squid.png in Resources */, 8477B4272C4DE77F004E1AC5 /* worldname_ipad_3.png in Resources */, + 84B1E2AD2E051B7D00ED000A /* bowhit4.ogg in Resources */, + 84B1E25A2E051B7D00ED000A /* kill.ogg in Resources */, + 84B1E2CC2E051B7D00ED000A /* cloth1.ogg in Resources */, + 84B1E27B2E051B7D00ED000A /* growl1.ogg in Resources */, + 84B1E1CD2E051B7D00ED000A /* piano3.ogg in Resources */, + 84B1E2582E051B7D00ED000A /* hit2.ogg in Resources */, + 84B1E2E82E051B7D00ED000A /* in.ogg in Resources */, 8477B4342C4DE77F004E1AC5 /* survival_0_3.png in Resources */, 849FF0BB2AF465340013BAE3 /* panorama_3.png in Resources */, + 84B1E2AE2E051B7D00ED000A /* break.ogg in Resources */, + 84B1E2012E051B7D00ED000A /* purr1.ogg in Resources */, 8477B44B2C4DE77F004E1AC5 /* Default-568h@2x.png in Resources */, + 84B1E26B2E051B7D00ED000A /* slime1.ogg in Resources */, + 84B1E2BA2E051B7D00ED000A /* eat3.ogg in Resources */, + 84B1E2BC2E051B7D00ED000A /* explode1.ogg in Resources */, + 84B1E2692E051B7D00ED000A /* skeletonhurt3.ogg in Resources */, + 84B1E2132E051B7D00ED000A /* creeper1.ogg in Resources */, + 84B1E2D02E051B7D00ED000A /* grass1.ogg in Resources */, + 84B1E2772E051B7D00ED000A /* bark1.ogg in Resources */, + 84B1E2852E051B7D00ED000A /* whine.ogg in Resources */, + 84B1E2752E051B7D00ED000A /* spider4.ogg in Resources */, 8477B42E2C4DE77F004E1AC5 /* create_0_1.png in Resources */, + 84B1E20D2E051B7D00ED000A /* cow2.ogg in Resources */, + 84B1E2F12E051B7D00ED000A /* gravel4.ogg in Resources */, + 84B1E2F82E051B7D00ED000A /* wood3.ogg in Resources */, 8477B4142C4DE77F004E1AC5 /* create_1.png in Resources */, + 84B1E2712E051B7D00ED000A /* slimeattack2.ogg in Resources */, + 84B1E2F72E051B7D00ED000A /* wood2.ogg in Resources */, + 84B1E1CA2E051B7D00ED000A /* nuance2.ogg in Resources */, + 84B1E1D02E051B7D00ED000A /* cave11.ogg in Resources */, + 84B1E0562E050D2500ED000A /* ghast.png in Resources */, 849FF0BC2AF465340013BAE3 /* panorama_4.png in Resources */, + 84B1E1F42E051B7D00ED000A /* hit2.ogg in Resources */, + 84B1E2532E051B7D00ED000A /* pigdeath.ogg in Resources */, + 84B1E2982E051B7D00ED000A /* zpigangry1.ogg in Resources */, 8477B4362C4DE77F004E1AC5 /* worldname.png in Resources */, 8477B4412C4DE77F004E1AC5 /* Icon-Small.png in Resources */, + 84B1E2E52E051B7D00ED000A /* wood2.ogg in Resources */, + 84B1E2312E051B7D00ED000A /* moan5.ogg in Resources */, + 84B1E1FB2E051B7D00ED000A /* hitt2.ogg in Resources */, + 84B1E2332E051B7D00ED000A /* moan7.ogg in Resources */, + 84B1E2622E051B7D00ED000A /* step4.ogg in Resources */, + 84B1E2102E051B7D00ED000A /* cowhurt1.ogg in Resources */, + 84B1E0552E050D2500ED000A /* ghast_fire.png in Resources */, + 84B1E1D72E051B7D00ED000A /* cave6.ogg in Resources */, 849FF0BD2AF465340013BAE3 /* panorama_5.png in Resources */, 849FF0BE2AF465340013BAE3 /* background.png in Resources */, 849FF0C32AF465340013BAE3 /* default_world.png in Resources */, + 84B1E2812E051B7D00ED000A /* hurt2.ogg in Resources */, + 84B1E1FC2E051B7D00ED000A /* hitt3.ogg in Resources */, + 84B1E2EF2E051B7D00ED000A /* gravel2.ogg in Resources */, + 84B1E1EE2E051B7D00ED000A /* breathe1.ogg in Resources */, + 84B1E20B2E051B7D00ED000A /* chickenplop.ogg in Resources */, 8477B4352C4DE77F004E1AC5 /* survival_1_3.png in Resources */, + 84B1E2412E051B7D00ED000A /* walk3.ogg in Resources */, + 84B1E0582E050D2500ED000A /* pigman.png in Resources */, + 84B1E2B62E051B7D00ED000A /* drink.ogg in Resources */, 849FF0C52AF465340013BAE3 /* feedback_fill.png in Resources */, + 84B1E2382E051B7D00ED000A /* scream5.ogg in Resources */, 849FF0C62AF465340013BAE3 /* feedback_outer.png in Resources */, + 84B1E2302E051B7D00ED000A /* moan4.ogg in Resources */, + 84B1E2792E051B7D00ED000A /* bark3.ogg in Resources */, 8477B4112C4DE77F004E1AC5 /* create_0.png in Resources */, + 84B1E21C2E051B7D00ED000A /* hit4.ogg in Resources */, + 84B1E2CF2E051B7D00ED000A /* cloth4.ogg in Resources */, + 84B1E2BE2E051B7D00ED000A /* explode3.ogg in Resources */, + 84B1E1E92E051B7D00ED000A /* ignite.ogg in Resources */, + 84B1E1D32E051B7D00ED000A /* cave2.ogg in Resources */, + 84B1E1F72E051B7D00ED000A /* hiss1.ogg in Resources */, + 84B1E1CE2E051B7D00ED000A /* cave1.ogg in Resources */, + 84B1E1DA2E051B7D00ED000A /* cave9.ogg in Resources */, + 84B1E1C42E051B7D00ED000A /* calm3.ogg in Resources */, + 84B1E2002E051B7D00ED000A /* meow4.ogg in Resources */, + 84B1E20A2E051B7D00ED000A /* chickenhurt2.ogg in Resources */, + 84B1E2D52E051B7D00ED000A /* gravel2.ogg in Resources */, 8477B42F2C4DE77F004E1AC5 /* create_0_3.png in Resources */, + 84B1E2872E051B7D00ED000A /* metal2.ogg in Resources */, + 84B1E2CB2E051B7D00ED000A /* wood click.ogg in Resources */, + 84B1E2552E051B7D00ED000A /* sheep2.ogg in Resources */, + 84B1E26E2E051B7D00ED000A /* slime4.ogg in Resources */, 8477B44C2C4DE77F004E1AC5 /* Default-Landscape~ipad.png in Resources */, + 84B1E2902E051B7D00ED000A /* zombie3.ogg in Resources */, + 84B1E1F62E051B7D00ED000A /* hit4.ogg in Resources */, + 84B1E2B72E051B7D00ED000A /* drr.ogg in Resources */, + 84B1E06C2E051B6400ED000A /* spider_eyes.png in Resources */, + 84B1E1F22E051B7D00ED000A /* death.ogg in Resources */, + 84B1E1FA2E051B7D00ED000A /* hitt1.ogg in Resources */, + 84B1E1E52E051B7D00ED000A /* hurtflesh1.ogg in Resources */, 8477B44A2C4DE77F004E1AC5 /* mcpe_lite_ios_icon.png in Resources */, + 84B1E2AA2E051B7D00ED000A /* bowhit1.ogg in Resources */, + 84B1E2E02E051B7D00ED000A /* stone1.ogg in Resources */, + 84B1E2DC2E051B7D00ED000A /* snow1.ogg in Resources */, + 84B1E2C92E051B7D00ED000A /* pop.ogg in Resources */, + 84B1E2262E051B7D00ED000A /* scream3.ogg in Resources */, 8477B41D2C4DE77F004E1AC5 /* creative_3_4.png in Resources */, + 84B1E0692E051B6400ED000A /* sheep_fur.png in Resources */, 8477B40D2C4DE77F004E1AC5 /* cancel_0_3.png in Resources */, + 84B1E2602E051B7D00ED000A /* step2.ogg in Resources */, + 84B1E28F2E051B7D00ED000A /* zombie2.ogg in Resources */, 849FF0C72AF465340013BAE3 /* gui.png in Resources */, 8477B43F2C4DE77F004E1AC5 /* Icon-Small-50.png in Resources */, + 84B1E1DD2E051B7D00ED000A /* rain3.ogg in Resources */, + 84B1E2D42E051B7D00ED000A /* gravel1.ogg in Resources */, + 84B1E2282E051B7D00ED000A /* stare.ogg in Resources */, + 84B1E0662E051B6400ED000A /* creeper.png in Resources */, + 84B1E2452E051B7D00ED000A /* big3.ogg in Resources */, + 84B1E2F62E051B7D00ED000A /* wood1.ogg in Resources */, 849FF0C82AF465340013BAE3 /* gui_blocks.png in Resources */, + 84B1E23E2E051B7D00ED000A /* throw.ogg in Resources */, + 84B1E2B12E051B7D00ED000A /* chestclosed.ogg in Resources */, + 84B1E2782E051B7D00ED000A /* bark2.ogg in Resources */, + 84B1E2492E051B7D00ED000A /* jump3.ogg in Resources */, 849FF0C92AF465340013BAE3 /* icons.png in Resources */, + 84B1E1E42E051B7D00ED000A /* fallsmall.ogg in Resources */, + 84B1E2D22E051B7D00ED000A /* grass3.ogg in Resources */, 8477B4492C4DE77F004E1AC5 /* mcpe_ios_icon.png in Resources */, 8477B4122C4DE77F004E1AC5 /* create_0_1.png in Resources */, 8477B4232C4DE77F004E1AC5 /* save_0_3.png in Resources */, + 84B1E1D82E051B7D00ED000A /* cave7.ogg in Resources */, + 84B1E2E42E051B7D00ED000A /* wood1.ogg in Resources */, 8477B4442C4DE77F004E1AC5 /* Icon-Small_lite.png in Resources */, + 84B1E1C32E051B7D00ED000A /* calm2.ogg in Resources */, 8494882C2C92844C006DB706 /* pumpkinblur.png in Resources */, + 84B1E2A32E051B7D00ED000A /* hat.ogg in Resources */, + 84B1E22E2E051B7D00ED000A /* moan2.ogg in Resources */, + 84B1E1F02E051B7D00ED000A /* breathe3.ogg in Resources */, 8477B4462C4DE77F004E1AC5 /* Icon@2x.png in Resources */, + 84B1E2662E051B7D00ED000A /* skeletondeath.ogg in Resources */, + 84B1E1C92E051B7D00ED000A /* nuance1.ogg in Resources */, 8477B44E2C4DE77F004E1AC5 /* Default@2x.png in Resources */, 8477B4202C4DE77F004E1AC5 /* survival_3_4.png in Resources */, + 84B1E2A12E051B7D00ED000A /* bd.ogg in Resources */, + 84B1E2F92E051B7D00ED000A /* wood4.ogg in Resources */, + 84B1E25D2E051B7D00ED000A /* say3.ogg in Resources */, + 84B1E2D62E051B7D00ED000A /* gravel3.ogg in Resources */, + 84B1E2092E051B7D00ED000A /* chickenhurt1.ogg in Resources */, 8477B41A2C4DE77F004E1AC5 /* create_1_4.png in Resources */, + 84B1E2442E051B7D00ED000A /* big2.ogg in Resources */, + 84B1E28A2E051B7D00ED000A /* wood2.ogg in Resources */, + 84B1E28C2E051B7D00ED000A /* wood4.ogg in Resources */, + 84B1E1DB2E051B7D00ED000A /* rain1.ogg in Resources */, 8477B4392C4DE77F004E1AC5 /* worldname_ipad_3.png in Resources */, + 84B1E2472E051B7D00ED000A /* jump1.ogg in Resources */, + 84B1E1EF2E051B7D00ED000A /* breathe2.ogg in Resources */, + 84B1E25E2E051B7D00ED000A /* say4.ogg in Resources */, + 84B1E24F2E051B7D00ED000A /* small5.ogg in Resources */, 8477B40E2C4DE77F004E1AC5 /* cancel_1.png in Resources */, 8477B4472C4DE77F004E1AC5 /* Icon@2x_lite.png in Resources */, + 84B1E2592E051B7D00ED000A /* hit3.ogg in Resources */, + 84B1E2742E051B7D00ED000A /* spider3.ogg in Resources */, + 84B1E1C52E051B7D00ED000A /* hal1.ogg in Resources */, 849FF0CB2AF465340013BAE3 /* items.png in Resources */, + 84B1E2762E051B7D00ED000A /* spiderdeath.ogg in Resources */, + 84B1E2F52E051B7D00ED000A /* stone4.ogg in Resources */, + 84B1E2972E051B7D00ED000A /* zpig4.ogg in Resources */, + 84B1E2992E051B7D00ED000A /* zpigangry2.ogg in Resources */, + 84B1E28B2E051B7D00ED000A /* wood3.ogg in Resources */, + 84B1E2612E051B7D00ED000A /* step3.ogg in Resources */, + 84B1E20E2E051B7D00ED000A /* cow3.ogg in Resources */, + 84B1E1CF2E051B7D00ED000A /* cave10.ogg in Resources */, + 84B1E1D12E051B7D00ED000A /* cave12.ogg in Resources */, + 84B1E1DE2E051B7D00ED000A /* rain4.ogg in Resources */, + 84B1E2C82E051B7D00ED000A /* orb.ogg in Resources */, + 84B1E0642E051B6400ED000A /* chicken.png in Resources */, + 84B1E1D52E051B7D00ED000A /* cave4.ogg in Resources */, + 84B1E22A2E051B7D00ED000A /* charge.ogg in Resources */, + 84B1E1E12E051B7D00ED000A /* thunder3.ogg in Resources */, + 84B1E1CC2E051B7D00ED000A /* piano2.ogg in Resources */, + 84B1E2122E051B7D00ED000A /* cowhurt3.ogg in Resources */, + 84B1E23D2E051B7D00ED000A /* hit4.ogg in Resources */, + 84B1E22B2E051B7D00ED000A /* death.ogg in Resources */, 8477B41E2C4DE77F004E1AC5 /* survival_0_4.png in Resources */, + 84B1E2252E051B7D00ED000A /* scream2.ogg in Resources */, + 84B1E25B2E051B7D00ED000A /* say1.ogg in Resources */, + 84B1E1F32E051B7D00ED000A /* hit1.ogg in Resources */, + 84B1E2822E051B7D00ED000A /* hurt3.ogg in Resources */, + 84B1E06B2E051B6400ED000A /* spider.png in Resources */, + 84B1E2112E051B7D00ED000A /* cowhurt2.ogg in Resources */, + 84B1E2DD2E051B7D00ED000A /* snow2.ogg in Resources */, + 84B1E2AF2E051B7D00ED000A /* breath.ogg in Resources */, 849FF0D32AF465340013BAE3 /* title.png in Resources */, + 84B1E26D2E051B7D00ED000A /* slime3.ogg in Resources */, + 84B1E28D2E051B7D00ED000A /* woodbreak.ogg in Resources */, + 84B1E1CB2E051B7D00ED000A /* piano1.ogg in Resources */, 8477B43A2C4DE77F004E1AC5 /* worldname_iphone.png in Resources */, + 84B1E2A02E051B7D00ED000A /* bassattack.ogg in Resources */, + 84B1E2832E051B7D00ED000A /* panting.ogg in Resources */, + 84B1E2C02E051B7D00ED000A /* fizz.ogg in Resources */, + 84B1E1ED2E051B7D00ED000A /* water.ogg in Resources */, + 84B1E2B22E051B7D00ED000A /* chestopen.ogg in Resources */, + 84B1E2E32E051B7D00ED000A /* stone4.ogg in Resources */, + 84B1E2322E051B7D00ED000A /* moan6.ogg in Resources */, + 84B1E2DB2E051B7D00ED000A /* sand4.ogg in Resources */, + 84B1E22F2E051B7D00ED000A /* moan3.ogg in Resources */, + 84B1E1D42E051B7D00ED000A /* cave3.ogg in Resources */, + 84B1E24C2E051B7D00ED000A /* small2.ogg in Resources */, + 84B1E2422E051B7D00ED000A /* walk4.ogg in Resources */, + 84B1E2952E051B7D00ED000A /* zpig2.ogg in Resources */, + 84B1E2632E051B7D00ED000A /* skeleton1.ogg in Resources */, + 84B1E2B92E051B7D00ED000A /* eat2.ogg in Resources */, + 84B1E2F22E051B7D00ED000A /* stone1.ogg in Resources */, 8477B42C2C4DE77F004E1AC5 /* cancel_1_1.png in Resources */, + 84B1E26C2E051B7D00ED000A /* slime2.ogg in Resources */, + 84B1E2512E051B7D00ED000A /* pig2.ogg in Resources */, 849FF0D52AF465340013BAE3 /* icon.png in Resources */, 8477B4092C4DE77F004E1AC5 /* bg128.png in Resources */, 8494882D2C92844C006DB706 /* shadow.png in Resources */, + 84B1E2172E051B7D00ED000A /* creeperdeath.ogg in Resources */, + 84B1E27C2E051B7D00ED000A /* growl2.ogg in Resources */, 8477B43E2C4DE77F004E1AC5 /* Icon-72_lite.png in Resources */, 8477B4222C4DE77F004E1AC5 /* save_0.png in Resources */, + 84B1E2292E051B7D00ED000A /* affectionate scream.ogg in Resources */, + 84B1E2A62E051B7D00ED000A /* portal.ogg in Resources */, 849FF0DB2AF465340013BAE3 /* camera.png in Resources */, + 84B1E29E2E051B7D00ED000A /* zpighurt2.ogg in Resources */, + 84B1E1FE2E051B7D00ED000A /* meow2.ogg in Resources */, + 84B1E22D2E051B7D00ED000A /* moan1.ogg in Resources */, 8477B4242C4DE77F004E1AC5 /* save_1.png in Resources */, + 84B1E1E32E051B7D00ED000A /* fallbig2.ogg in Resources */, 8477B42A2C4DE77F004E1AC5 /* cancel_0_1.png in Resources */, + 84B1E2C42E051B7D00ED000A /* glass3.ogg in Resources */, 8477B41F2C4DE77F004E1AC5 /* survival_1_4.png in Resources */, + 84B1E21D2E051B7D00ED000A /* idle1.ogg in Resources */, + 84B1E2082E051B7D00ED000A /* chicken3.ogg in Resources */, + 84B1E2022E051B7D00ED000A /* purr2.ogg in Resources */, + 84B1E1E62E051B7D00ED000A /* hurtflesh2.ogg in Resources */, 849FF0DC2AF465340013BAE3 /* char.png in Resources */, + 84B1E21E2E051B7D00ED000A /* idle2.ogg in Resources */, + 84B1E2942E051B7D00ED000A /* zpig1.ogg in Resources */, 8477B4452C4DE77F004E1AC5 /* Icon.png in Resources */, + 84B1E2B02E051B7D00ED000A /* burp.ogg in Resources */, 849FF0DD2AF465340013BAE3 /* particles.png in Resources */, + 84B1E2CD2E051B7D00ED000A /* cloth2.ogg in Resources */, 8477B41B2C4DE77F004E1AC5 /* creative_0_4.png in Resources */, + 84B1E2B32E051B7D00ED000A /* click.ogg in Resources */, + 84B1E2A72E051B7D00ED000A /* travel.ogg in Resources */, 8477B4132C4DE77F004E1AC5 /* create_0_3.png in Resources */, + 84B1E2522E051B7D00ED000A /* pig3.ogg in Resources */, + 84B1E1E22E051B7D00ED000A /* fallbig1.ogg in Resources */, + 84B1E20C2E051B7D00ED000A /* cow1.ogg in Resources */, + 84B1E2D82E051B7D00ED000A /* sand1.ogg in Resources */, + 84B1E1EC2E051B7D00ED000A /* splash.ogg in Resources */, + 84B1E2D32E051B7D00ED000A /* grass4.ogg in Resources */, 8477B4182C4DE77F004E1AC5 /* cancel_1_4.png in Resources */, + 84B1E05A2E050D2500ED000A /* saddle.png in Resources */, + 84B1E2702E051B7D00ED000A /* slimeattack1.ogg in Resources */, + 84B1E2DA2E051B7D00ED000A /* sand3.ogg in Resources */, + 84B1E2F42E051B7D00ED000A /* stone3.ogg in Resources */, 849FF0DE2AF465340013BAE3 /* terrain.png in Resources */, + 84B1E2042E051B7D00ED000A /* purreow1.ogg in Resources */, + 84B1E1D62E051B7D00ED000A /* cave5.ogg in Resources */, + 84B1E2EE2E051B7D00ED000A /* gravel1.ogg in Resources */, + 84B1E1E82E051B7D00ED000A /* fire.ogg in Resources */, + 84B1E1FF2E051B7D00ED000A /* meow3.ogg in Resources */, + 84B1E2362E051B7D00ED000A /* scream3.ogg in Resources */, + 84B1E2862E051B7D00ED000A /* metal1.ogg in Resources */, + 84B1E2E12E051B7D00ED000A /* stone2.ogg in Resources */, + 84B1E2DE2E051B7D00ED000A /* snow3.ogg in Resources */, 8477B40C2C4DE77F004E1AC5 /* cancel_0_1.png in Resources */, + 84B1E27F2E051B7D00ED000A /* howl2.ogg in Resources */, + 84B1E23F2E051B7D00ED000A /* walk1.ogg in Resources */, + 84B1E2C22E051B7D00ED000A /* glass1.ogg in Resources */, + 84B1E2372E051B7D00ED000A /* scream4.ogg in Resources */, + 84B1E2C72E051B7D00ED000A /* old_explode.ogg in Resources */, 84C208532AF88A5000BAE438 /* grass_side_transparent.png in Resources */, + 84B1E23A2E051B7D00ED000A /* hit1.ogg in Resources */, + 84B1E2A52E051B7D00ED000A /* snare.ogg in Resources */, 8477B43C2C4DE77F004E1AC5 /* worldname_iphone_3.png in Resources */, + 84B1E2072E051B7D00ED000A /* chicken2.ogg in Resources */, 8477B4302C4DE77F004E1AC5 /* create_1_1.png in Resources */, + 84B1E2562E051B7D00ED000A /* sheep3.ogg in Resources */, 8477B4252C4DE77F004E1AC5 /* save_1_3.png in Resources */, 8494882E2C92844C006DB706 /* vignette.png in Resources */, 8477B4162C4DE77F004E1AC5 /* create_1_3.png in Resources */, + 84B1E25F2E051B7D00ED000A /* step1.ogg in Resources */, + 84B1E2BD2E051B7D00ED000A /* explode2.ogg in Resources */, + 84B1E2542E051B7D00ED000A /* sheep1.ogg in Resources */, + 84B1E0652E051B6400ED000A /* cow.png in Resources */, + 84B1E2E22E051B7D00ED000A /* stone3.ogg in Resources */, + 84B1E2A92E051B7D00ED000A /* bow.ogg in Resources */, 8494882A2C92844C006DB706 /* foliagecolor.png in Resources */, + 84B1E2242E051B7D00ED000A /* scream1.ogg in Resources */, + 84B1E1EA2E051B7D00ED000A /* lava.ogg in Resources */, + 84B1E2A82E051B7D00ED000A /* trigger.ogg in Resources */, + 84B1E2462E051B7D00ED000A /* big4.ogg in Resources */, + 84B1E21A2E051B7D00ED000A /* hit2.ogg in Resources */, + 84B1E1F12E051B7D00ED000A /* breathe4.ogg in Resources */, + 84B1E2682E051B7D00ED000A /* skeletonhurt2.ogg in Resources */, + 84B1E0592E050D2500ED000A /* pigzombie.png in Resources */, 84C208542AF88A5000BAE438 /* patch_data.txt in Resources */, 8477B40B2C4DE77F004E1AC5 /* cancel_0.png in Resources */, 8477B43D2C4DE77F004E1AC5 /* Icon-72.png in Resources */, + 84B1E2182E051B7D00ED000A /* death.ogg in Resources */, + 84B1E2052E051B7D00ED000A /* purreow2.ogg in Resources */, + 84B1E0672E051B6400ED000A /* pig.png in Resources */, + 84B1E2212E051B7D00ED000A /* idle5.ogg in Resources */, + 84B1E1E02E051B7D00ED000A /* thunder2.ogg in Resources */, + 84B1E2BF2E051B7D00ED000A /* explode4.ogg in Resources */, + 84B1E2032E051B7D00ED000A /* purr3.ogg in Resources */, + 84B1E2F02E051B7D00ED000A /* gravel3.ogg in Resources */, 84ED99D52AFF12D1003B6AF0 /* minecraftpe.entitlements in Resources */, + 84B1E2502E051B7D00ED000A /* pig1.ogg in Resources */, 84AA8C792B32F578003F5B82 /* gui_custom.png in Resources */, + 84B1E21F2E051B7D00ED000A /* idle3.ogg in Resources */, + 84B1E2A42E051B7D00ED000A /* pling.ogg in Resources */, + 84B1E2722E051B7D00ED000A /* spider1.ogg in Resources */, + 84B1E05E2E050D2500ED000A /* slime.png in Resources */, 8477B4402C4DE77F004E1AC5 /* Icon-Small-50_lite.png in Resources */, + 84B1E28E2E051B7D00ED000A /* zombie1.ogg in Resources */, + 84B1E23C2E051B7D00ED000A /* hit3.ogg in Resources */, + 84B1E24E2E051B7D00ED000A /* small4.ogg in Resources */, + 84B1E2B82E051B7D00ED000A /* eat1.ogg in Resources */, + 84B1E2482E051B7D00ED000A /* jump2.ogg in Resources */, 84E78C8C2B58BB7400D515EF /* n_rocket_launched.png in Resources */, 8477B4332C4DE77F004E1AC5 /* creative_1_3.png in Resources */, 8477B42D2C4DE77F004E1AC5 /* cancel_1_3.png in Resources */, + 84B1E1C82E051B7D00ED000A /* hal4.ogg in Resources */, + 84B1E2642E051B7D00ED000A /* skeleton2.ogg in Resources */, + 84B1E2572E051B7D00ED000A /* hit1.ogg in Resources */, + 84B1E2932E051B7D00ED000A /* zombiehurt2.ogg in Resources */, 84E78C8D2B58BB7400D515EF /* n_rocket_launcher.png in Resources */, + 84B1E2DF2E051B7D00ED000A /* snow4.ogg in Resources */, + 84B1E2882E051B7D00ED000A /* metal3.ogg in Resources */, + 84B1E1C22E051B7D00ED000A /* calm1.ogg in Resources */, 8477B4282C4DE77F004E1AC5 /* worldname_iphone.png in Resources */, 8477B4322C4DE77F004E1AC5 /* creative_0_3.png in Resources */, + 84B1E2142E051B7D00ED000A /* creeper2.ogg in Resources */, 84E78C8E2B58BB7400D515EF /* n_rocket.png in Resources */, 849488322C928459006DB706 /* moon.png in Resources */, + 84B1E1DF2E051B7D00ED000A /* thunder1.ogg in Resources */, + 84B1E2E72E051B7D00ED000A /* wood4.ogg in Resources */, + 84B1E2802E051B7D00ED000A /* hurt1.ogg in Resources */, 84E78C902B58C18C00D515EF /* black.png in Resources */, + 84B1E1EB2E051B7D00ED000A /* lavapop.ogg in Resources */, + 84B1E2222E051B7D00ED000A /* portal.ogg in Resources */, + 84B1E2D92E051B7D00ED000A /* sand2.ogg in Resources */, 8477B4172C4DE77F004E1AC5 /* cancel_0_4.png in Resources */, + 84B1E2202E051B7D00ED000A /* idle4.ogg in Resources */, 8477B42B2C4DE77F004E1AC5 /* cancel_0_3.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -4884,7 +6445,6 @@ 84EAE8F72AF1EAFA000894E8 /* main.cpp in Sources */, 841DD8772AF8AA7A00AA3B66 /* AppPlatform_sdl_base.cpp in Sources */, 841DD8782AF8AA7A00AA3B66 /* AppPlatform_sdl.cpp in Sources */, - 84AA8E4D2B32FB33003F5B82 /* stb_vorbis.c in Sources */, 84AA8E802B32FB33003F5B82 /* stb_image_impl.c in Sources */, 8441F9962DB4E911005977BD /* SoundSystemAL.cpp in Sources */, ); @@ -4921,6 +6481,7 @@ files = ( 84B8AEFB2AF1896F008DE93D /* DirectConnectScreen.cpp in Sources */, 84B8AEFC2AF1896F008DE93D /* IngameBlockSelectionScreen.cpp in Sources */, + 84B1E0632E05194A00ED000A /* stb_vorbis.c in Sources */, 84B8AEFD2AF1896F008DE93D /* InvalidLicenseScreen.cpp in Sources */, 84B8AEFE2AF1896F008DE93D /* JoinGameScreen.cpp in Sources */, 84B8AEFF2AF1896F008DE93D /* OptionsScreen.cpp in Sources */, @@ -4948,6 +6509,7 @@ 84B8AF332AF1896F008DE93D /* SoundEngine.cpp in Sources */, 84B8AF342AF1896F008DE93D /* SoundRepository.cpp in Sources */, 84B8AF352AF1896F008DE93D /* SoundSystem.cpp in Sources */, + 84B1E02F2E04FD4500ED000A /* ArrowRenderer.cpp in Sources */, 84B8AEE82AF1890A008DE93D /* App.cpp in Sources */, 84B8AEE92AF1890A008DE93D /* AppPlatform.cpp in Sources */, 84B8AEEA2AF1890A008DE93D /* Minecraft.cpp in Sources */, @@ -5000,11 +6562,9 @@ 84AA8C052B32F3F3003F5B82 /* PigRenderer.cpp in Sources */, 84AA8C072B32F3F3003F5B82 /* SheepFurRenderer.cpp in Sources */, 84AA8C092B32F3F3003F5B82 /* SheepRenderer.cpp in Sources */, - 84AA8C0B2B32F3F3003F5B82 /* SkeletonRenderer.cpp in Sources */, 84AA8C0D2B32F3F3003F5B82 /* SpiderRenderer.cpp in Sources */, 84AA8C0F2B32F3F3003F5B82 /* TntRenderer.cpp in Sources */, 84AA8C112B32F3F3003F5B82 /* TripodCameraRenderer.cpp in Sources */, - 84AA8C132B32F3F3003F5B82 /* ZombieRenderer.cpp in Sources */, 84AA8C152B32F3F3003F5B82 /* FireTexture.cpp in Sources */, 84AA8C162B32F3F3003F5B82 /* FoliageColor.cpp in Sources */, 84AA8C182B32F3F3003F5B82 /* Font.cpp in Sources */, @@ -5087,6 +6647,7 @@ 84BF632C2AF18631008A9995 /* FlowerFeature.cpp in Sources */, 8445E7A72D769329008DC834 /* Sheep.cpp in Sources */, 84BF632D2AF18631008A9995 /* LargeCaveFeature.cpp in Sources */, + 84B1E03F2E04FD7900ED000A /* Zombie.cpp in Sources */, 84BF632E2AF18631008A9995 /* LargeFeature.cpp in Sources */, 84BF632F2AF18631008A9995 /* OreFeature.cpp in Sources */, 84BF63302AF18631008A9995 /* PineFeature.cpp in Sources */, @@ -5120,6 +6681,7 @@ 8445E7A92D769329008DC834 /* SynchedEntityData.cpp in Sources */, 84BF63492AF18631008A9995 /* FlameParticle.cpp in Sources */, 84BF634A2AF18631008A9995 /* LavaParticle.cpp in Sources */, + 84B1E03D2E04FD7900ED000A /* Spider.cpp in Sources */, 84BF634B2AF18631008A9995 /* Particle.cpp in Sources */, 84BF634C2AF18631008A9995 /* ParticleEngine.cpp in Sources */, 84BF634D2AF18631008A9995 /* RedDustParticle.cpp in Sources */, @@ -5150,6 +6712,7 @@ 84BF63662AF18631008A9995 /* MetalTile.cpp in Sources */, 84BF63672AF18631008A9995 /* ObsidianTile.cpp in Sources */, 84BF63682AF18631008A9995 /* OreTile.cpp in Sources */, + 84B1E0392E04FD7900ED000A /* Arrow.cpp in Sources */, 84BF63692AF18631008A9995 /* RedStoneOreTile.cpp in Sources */, 84BF636A2AF18631008A9995 /* ReedTile.cpp in Sources */, 84BF636B2AF18631008A9995 /* SandStoneTile.cpp in Sources */, @@ -5175,6 +6738,7 @@ 8477B3B32C4DC414004E1AC5 /* ChunkPos.cpp in Sources */, 84AA8B782B32F3B5003F5B82 /* Animal.cpp in Sources */, 84AA8B7A2B32F3B5003F5B82 /* Chicken.cpp in Sources */, + 84B1E03B2E04FD7900ED000A /* Skeleton.cpp in Sources */, 84AA8B7C2B32F3B5003F5B82 /* Cow.cpp in Sources */, 84AA8B7E2B32F3B5003F5B82 /* Creeper.cpp in Sources */, 84AA8B8A2B32F3B5003F5B82 /* Monster.cpp in Sources */, diff --git a/platforms/windows/projects/Client/Client.vcxproj b/platforms/windows/projects/Client/Client.vcxproj index aa82f51dd..0b90b99a9 100644 --- a/platforms/windows/projects/Client/Client.vcxproj +++ b/platforms/windows/projects/Client/Client.vcxproj @@ -170,10 +170,9 @@ - - + @@ -293,19 +292,18 @@ - - - + + diff --git a/platforms/windows/projects/Client/Client.vcxproj.filters b/platforms/windows/projects/Client/Client.vcxproj.filters index d83f97e7f..1f1b8b092 100644 --- a/platforms/windows/projects/Client/Client.vcxproj.filters +++ b/platforms/windows/projects/Client/Client.vcxproj.filters @@ -386,15 +386,9 @@ Header Files\GUI\Components - - Header Files\Renderer\Entity - Header Files\Renderer\Entity - - Header Files\Renderer\Entity - Header Files\Renderer\Entity @@ -467,6 +461,9 @@ Header Files\Sound + + Header Files\Renderer\Entity + @@ -796,12 +793,6 @@ Source Files\Model - - Source Files\Model - - - Source Files\Renderer\Entity - Source Files\Renderer\Entity @@ -820,9 +811,6 @@ Source Files\Renderer\Entity - - Source Files\Renderer\Entity - Source Files\Renderer\Entity @@ -841,5 +829,11 @@ Source Files\Renderer + + Source Files\Model + + + Source Files\Renderer\Entity + \ No newline at end of file diff --git a/platforms/windows/projects/World/World.vcxproj b/platforms/windows/projects/World/World.vcxproj index fb8ca71b3..008dc0943 100644 --- a/platforms/windows/projects/World/World.vcxproj +++ b/platforms/windows/projects/World/World.vcxproj @@ -172,6 +172,10 @@ + + + + @@ -296,6 +300,10 @@ + + + + diff --git a/platforms/windows/projects/World/World.vcxproj.filters b/platforms/windows/projects/World/World.vcxproj.filters index 2349d1288..a4ac35b23 100644 --- a/platforms/windows/projects/World/World.vcxproj.filters +++ b/platforms/windows/projects/World/World.vcxproj.filters @@ -503,6 +503,18 @@ Source Files\Entity + + Source Files\Entity + + + Source Files\Entity + + + Source Files\Entity + + + Source Files\Entity + @@ -871,5 +883,17 @@ Header Files\Entity + + Header Files\Entity + + + Header Files\Entity + + + Header Files\Entity + + + Header Files\Entity + \ No newline at end of file diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index f4a6ab7c0..dc4ab10cc 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -29,14 +29,12 @@ add_library(reminecraftpe-core STATIC client/renderer/entity/EntityRenderDispatcher.cpp client/renderer/entity/HumanoidMobRenderer.cpp client/renderer/entity/SpiderRenderer.cpp - client/renderer/entity/ZombieRenderer.cpp - client/renderer/entity/SkeletonRenderer.cpp + client/renderer/entity/ArrowRenderer.cpp client/renderer/entity/SheepRenderer.cpp client/renderer/entity/SheepFurRenderer.cpp client/renderer/entity/CreeperRenderer.cpp client/renderer/entity/CowRenderer.cpp client/renderer/entity/PigRenderer.cpp - client/renderer/entity/SheepRenderer.cpp client/renderer/entity/ChickenRenderer.cpp client/renderer/entity/RocketRenderer.cpp client/renderer/RenderList.cpp @@ -184,6 +182,10 @@ add_library(reminecraftpe-core STATIC world/entity/ItemEntity.cpp world/entity/PathfinderMob.cpp world/entity/Animal.cpp + world/entity/Skeleton.cpp + world/entity/Spider.cpp + world/entity/Zombie.cpp + world/entity/Arrow.cpp world/entity/WaterAnimal.cpp world/entity/Monster.cpp world/entity/Rocket.cpp diff --git a/source/client/app/AppPlatform.cpp b/source/client/app/AppPlatform.cpp index 08fa245a1..0613cff5a 100644 --- a/source/client/app/AppPlatform.cpp +++ b/source/client/app/AppPlatform.cpp @@ -6,6 +6,8 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ +#include + #include "AppPlatform.hpp" #include "common/Utils.hpp" @@ -234,7 +236,37 @@ std::string AppPlatform::getPatchData() AssetFile AppPlatform::readAssetFile(const std::string& path, bool quiet) const { - return AssetFile(); + std::string realPath = getAssetPath(path); + std::ifstream ifs(realPath.c_str()); + + // Open File + if (!ifs.is_open()) + { + if (!quiet) LOG_W("Couldn't find asset file: %s", realPath.c_str()); + return AssetFile(); + } + + std::filebuf* pbuf = ifs.rdbuf(); + + // Get File Size + std::streamoff size = pbuf->pubseekoff(0, ifs.end, ifs.in); + pbuf->pubseekpos(0, ifs.in); + if (size < 0) + { + if (!quiet) LOG_E("Error determining the size of the asset file!"); + ifs.close(); + return AssetFile(); + } + + // Read Data + char *buf = new char[size]; + pbuf->sgetn(buf, (std::streamsize)size); + + // Close File + ifs.close(); + + // Return + return AssetFile((int64_t)size, (unsigned char*)buf); } void AppPlatform::initSoundSystem() diff --git a/source/client/model/HumanoidModel.cpp b/source/client/model/HumanoidModel.cpp index ae668aca8..500a775c5 100644 --- a/source/client/model/HumanoidModel.cpp +++ b/source/client/model/HumanoidModel.cpp @@ -26,15 +26,20 @@ HumanoidModel::HumanoidModel(float a, float b): m_head.addBox(-4, -8, -4, 8, 8, 8, a); m_head.setPos(0, b, 0); + m_body.addBox(-4, 0, -2, 8, 12, 4); m_body.setPos(0, b, 0); + m_arm1.addBox(-3, -2, -2, 4, 12, 4, a); m_arm1.setPos(-5, b + 2, 0); + m_arm2.m_bMirror = true; m_arm2.addBox(-1, -2, -2, 4, 12, 4, a); m_arm2.setPos(5, b + 2, 0); + m_leg1.addBox(-2, 0, -2, 4, 12, 4, a); m_leg1.setPos(-2, b + 12, 0); + m_leg2.m_bMirror = true; m_leg2.addBox(-2, 0, -2, 4, 12, 4, a); m_leg2.setPos(2, b + 12, 0); diff --git a/source/client/model/SkeletonModel.cpp b/source/client/model/SkeletonModel.cpp index e69de29bb..61af699af 100644 --- a/source/client/model/SkeletonModel.cpp +++ b/source/client/model/SkeletonModel.cpp @@ -0,0 +1,27 @@ +#include "SkeletonModel.hpp" + +SkeletonModel::SkeletonModel() : ZombieModel() +{ + m_arm1.clear(); + m_arm2.clear(); + m_leg1.clear(); + m_leg2.clear(); + + m_arm1.addBox(-1.0f, -2.0f, -1.0f, 2, 12, 2, 0.0f); + m_arm1.setPos(-5.0f, 2.0f, 0.0f); + + m_arm2.m_bMirror = true; + m_arm2.addBox(-1.0f, -2.0f, -1.0f, 2, 12, 2, 0.0f); + m_arm2.setPos(5.0f, 2.0f, 0.0f); + + m_leg1.addBox(-1.0f, 0.0f, -1.0f, 2, 12, 2, 0.0f); + m_leg1.setPos(-2.0f, 12.0f, 0.0f); + + m_leg2.m_bMirror = true; + m_leg2.addBox(-1.0f, 0.0f, -1.0f, 2, 12, 2, 0.0f); + m_leg2.setPos(2.0f, 12.0f, 0.0f); +} + +SkeletonModel::~SkeletonModel() +{ +} \ No newline at end of file diff --git a/source/client/model/SkeletonModel.hpp b/source/client/model/SkeletonModel.hpp index e69de29bb..6c894c682 100644 --- a/source/client/model/SkeletonModel.hpp +++ b/source/client/model/SkeletonModel.hpp @@ -0,0 +1,10 @@ +#pragma once + +#include "ZombieModel.hpp" + +class SkeletonModel : public ZombieModel +{ +public: + SkeletonModel(); + ~SkeletonModel(); +}; diff --git a/source/client/model/SpiderModel.cpp b/source/client/model/SpiderModel.cpp index e69de29bb..22bb9a9a2 100644 --- a/source/client/model/SpiderModel.cpp +++ b/source/client/model/SpiderModel.cpp @@ -0,0 +1,127 @@ +#include "SpiderModel.hpp" + +SpiderModel::SpiderModel() : + Model(64, 64), + m_head(32, 4), + m_body0(0, 0), + m_body1(0, 12), + m_leg0(18, 0), + m_leg1(18, 0), + m_leg2(18, 0), + m_leg3(18, 0), + m_leg4(18, 0), + m_leg5(18, 0), + m_leg6(18, 0), + m_leg7(18, 0) +{ + static float g = 0.0f; + static int yo = 15; + + m_head.addBox(-4.0f, -4.0f, -8.0f, 8, 8, 8, g); + m_head.addBox(-4.0F, -4.0F, -8.0F, 8, 8, 8, g); + m_head.setPos(0.0F, (float)(0 + yo), -3.0F); + + m_body0.addBox(-3.0F, -3.0F, -3.0F, 6, 6, 6, g); + m_body0.setPos(0.0F, (float)yo, 0.0F); + + m_body1.addBox(-5.0F, -4.0F, -6.0F, 10, 8, 12, g); + m_body1.setPos(0.0F, (float)(0 + yo), 9.0F); + + m_leg0.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, g); + m_leg0.setPos(-4.0F, (float)(0 + yo), 2.0F); + + m_leg1.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, g); + m_leg1.setPos(4.0F, (float)(0 + yo), 2.0F); + + m_leg2.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, g); + m_leg2.setPos(-4.0F, (float)(0 + yo), 1.0F); + + m_leg3.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, g); + m_leg3.setPos(4.0F, (float)(0 + yo), 1.0F); + + m_leg4.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, g); + m_leg4.setPos(-4.0F, (float)(0 + yo), 0.0F); + + m_leg5.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, g); + m_leg5.setPos(4.0F, (float)(0 + yo), 0.0F); + + m_leg6.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, g); + m_leg6.setPos(-4.0F, (float)(0 + yo), -1.0F); + + m_leg7.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, g); + m_leg7.setPos(4.0F, (float)(0 + yo), -1.0F); +} + +SpiderModel::~SpiderModel() +{ +} + +void SpiderModel::render(float time, float r, float bob, float yRot, float xRot, float scale) { + setupAnim(time, r, bob, yRot, xRot, scale); + m_head.render(scale); + + m_body0.render(scale); + m_body1.render(scale); + + m_leg0.render(scale); + m_leg1.render(scale); + m_leg2.render(scale); + m_leg3.render(scale); + m_leg4.render(scale); + m_leg5.render(scale); + m_leg6.render(scale); + m_leg7.render(scale); +} + +void SpiderModel::setupAnim(float time, float r, float bob, float yRot, float xRot, float scale) { + m_head.m_rot.y = yRot / 57.295776F; + m_head.m_rot.x = xRot / 57.295776F; + + static float sr = 0.7853982F; + m_leg0.m_rot.z = -sr; + m_leg1.m_rot.z = sr; + m_leg2.m_rot.z = -sr * 0.74F; + m_leg3.m_rot.z = sr * 0.74F; + m_leg4.m_rot.z = -sr * 0.74F; + m_leg5.m_rot.z = sr * 0.74F; + m_leg6.m_rot.z = -sr; + m_leg7.m_rot.z = sr; + + static float ro = -0.0F; + static float ur = 0.3926991F; + m_leg0.m_rot.y = ur * 2.0F + ro; + m_leg1.m_rot.y = -ur * 2.0F - ro; + m_leg2.m_rot.y = ur * 1.0F + ro; + m_leg3.m_rot.y = -ur * 1.0F - ro; + m_leg4.m_rot.y = -ur * 1.0F + ro; + m_leg5.m_rot.y = ur * 1.0F - ro; + m_leg6.m_rot.y = -ur * 2.0F + ro; + m_leg7.m_rot.y = ur * 2.0F - ro; + + float c0 = -(Mth::cos(time * 0.6662F * 2.0F + 0.0F) * 0.4F) * r; + float c1 = -(Mth::cos(time * 0.6662F * 2.0F + M_PI) * 0.4F) * r; + float c2 = -(Mth::cos(time * 0.6662F * 2.0F + 1.5707964F) * 0.4F) * r; + float c3 = -(Mth::cos(time * 0.6662F * 2.0F + 4.712389F) * 0.4F) * r; + float s0 = Mth::abs(Mth::sin(time * 0.6662F + 0.0F) * 0.4F) * r; + float s1 = Mth::abs(Mth::sin(time * 0.6662F + M_PI) * 0.4F) * r; + float s2 = Mth::abs(Mth::sin(time * 0.6662F + 1.5707964F) * 0.4F) * r; + float s3 = Mth::abs(Mth::sin(time * 0.6662F + 4.712389F) * 0.4F) * r; + + m_leg0.m_rot.y += c0; + m_leg1.m_rot.y += -c0; + m_leg2.m_rot.y += c1; + m_leg3.m_rot.y += -c1; + m_leg4.m_rot.y += c2; + m_leg5.m_rot.y += -c2; + m_leg6.m_rot.y += c3; + m_leg7.m_rot.y += -c3; + + m_leg0.m_rot.z += s0; + m_leg1.m_rot.z += -s0; + m_leg2.m_rot.z += s1; + m_leg3.m_rot.z += -s1; + m_leg4.m_rot.z += s2; + m_leg5.m_rot.z += -s2; + m_leg6.m_rot.z += s3; + m_leg7.m_rot.z += -s3; +} diff --git a/source/client/model/SpiderModel.hpp b/source/client/model/SpiderModel.hpp index e69de29bb..e4b650174 100644 --- a/source/client/model/SpiderModel.hpp +++ b/source/client/model/SpiderModel.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include "Model.hpp" + +class SpiderModel : public Model +{ +public: + SpiderModel(); + ~SpiderModel(); + + void render(float time, float r, float bob, float y_rot, float x_rot, float scale) override; + void setupAnim(float time, float r, float bob, float y_rot, float x_rot, float scale) override; + +private: + ModelPart m_head; + ModelPart m_body0; + ModelPart m_body1; + ModelPart m_leg0; + ModelPart m_leg1; + ModelPart m_leg2; + ModelPart m_leg3; + ModelPart m_leg4; + ModelPart m_leg5; + ModelPart m_leg6; + ModelPart m_leg7; +}; \ No newline at end of file diff --git a/source/client/model/ZombieModel.cpp b/source/client/model/ZombieModel.cpp index e69de29bb..ae604df3e 100644 --- a/source/client/model/ZombieModel.cpp +++ b/source/client/model/ZombieModel.cpp @@ -0,0 +1,35 @@ +#include "ZombieModel.hpp" +#include "common/Mth.hpp" + +ZombieModel::ZombieModel() : + HumanoidModel(0.0f, 0.0f) +{ +} + +ZombieModel::~ZombieModel() +{ +} + +void ZombieModel::setupAnim(float time, float r, float bob, float y_rot, float x_rot, float scale) +{ + float attackTime = 1.f; + HumanoidModel::setupAnim(time, r, bob, y_rot, x_rot, scale); + float attack2 = Mth::sin(attackTime * M_PI); + float attack = Mth::sin((1.0f - (1.0f - attackTime) * (1.0f - attackTime)) * M_PI); + + m_arm1.m_rot.z = .0f; + m_arm2.m_rot.z = .0f; + m_arm1.m_rot.y = -(0.1f - attack2 * 0.6f); + m_arm2.m_rot.y = 0.1f - attack2 * 0.6f; + m_arm1.m_rot.x = -1.5707964f; + m_arm2.m_rot.x = -1.5707964f; + + m_arm1.m_rot.x -= attack2 * 1.2f - attack * 0.4f; + m_arm2.m_rot.x -= attack2 * 1.2f - attack * 0.4f; + + m_arm1.m_rot.z += Mth::cos(bob * 0.09f) * 0.05f + 0.05f; + m_arm2.m_rot.z -= Mth::cos(bob * 0.09f) * 0.05f + 0.05f; + + m_arm1.m_rot.x += Mth::sin(bob * 0.067f) * 0.05f; + m_arm2.m_rot.x -= Mth::sin(bob * 0.067f) * 0.05f; +} \ No newline at end of file diff --git a/source/client/model/ZombieModel.hpp b/source/client/model/ZombieModel.hpp index e69de29bb..76145615b 100644 --- a/source/client/model/ZombieModel.hpp +++ b/source/client/model/ZombieModel.hpp @@ -0,0 +1,11 @@ +#pragma once + +#include "HumanoidModel.hpp" + +class ZombieModel : public HumanoidModel +{ +public: + ZombieModel(); + ~ZombieModel(); + void setupAnim(float, float, float, float, float, float) override; +}; diff --git a/source/client/renderer/DynamicTexture.cpp b/source/client/renderer/DynamicTexture.cpp index f1afda969..b544cfdce 100644 --- a/source/client/renderer/DynamicTexture.cpp +++ b/source/client/renderer/DynamicTexture.cpp @@ -16,9 +16,9 @@ DynamicTexture::DynamicTexture(int a2) : m_textureIndex(a2) memset(m_pixels, 0, sizeof m_pixels); } -void DynamicTexture::bindTexture(Textures* pTextures) +bool DynamicTexture::bindTexture(Textures* pTextures) { - pTextures->loadAndBindTexture(C_TERRAIN_NAME); + return pTextures->loadAndBindTexture(C_TERRAIN_NAME) != -1; } DynamicTexture::~DynamicTexture() diff --git a/source/client/renderer/DynamicTexture.hpp b/source/client/renderer/DynamicTexture.hpp index 4f6d70fdd..a0f690d08 100644 --- a/source/client/renderer/DynamicTexture.hpp +++ b/source/client/renderer/DynamicTexture.hpp @@ -19,7 +19,7 @@ class DynamicTexture { public: virtual void tick() = 0; - virtual void bindTexture(Textures*); + virtual bool bindTexture(Textures*); DynamicTexture(int a2); virtual ~DynamicTexture(); diff --git a/source/client/renderer/Textures.cpp b/source/client/renderer/Textures.cpp index 2da437fb5..2300c3f26 100644 --- a/source/client/renderer/Textures.cpp +++ b/source/client/renderer/Textures.cpp @@ -15,27 +15,36 @@ int Textures::loadTexture(const std::string& name, bool bIsRequired) { std::map::iterator i = m_textures.find(name); if (i != m_textures.end()) - return i->second; + { + return i->second != 0 ? i->second : -1; + } Texture t = m_pPlatform->loadTexture(name, bIsRequired); - if (!t.m_pixels && bIsRequired) { - t.m_hasAlpha = 1; - t.field_D = 0; - t.m_width = 2; - t.m_height = 2; - t.m_pixels = new uint32_t[4]; - t.m_pixels[0] = 0xfff800f8; - t.m_pixels[1] = 0xff000000; - t.m_pixels[3] = 0xfff800f8; - t.m_pixels[2] = 0xff000000; + if (!t.m_pixels) + { + if (bIsRequired) + { + t.m_hasAlpha = true; + t.field_D = 0; + t.m_width = 2; + t.m_height = 2; + t.m_pixels = new uint32_t[4]; + t.m_pixels[0] = 0xfff800f8; + t.m_pixels[1] = 0xff000000; + t.m_pixels[3] = 0xfff800f8; + t.m_pixels[2] = 0xff000000; + } + else + { + // Record the fact that the texture file couldn't be loaded + // This means we can stop checking the filesystem every frame to see if the texture can be found + m_textures[name] = 0; + return -1; + } } - if (t.m_pixels) { - return assignTexture(name, t); - } else { - return -1; - } + return assignTexture(name, t); } int Textures::assignTexture(const std::string& name, Texture& texture) @@ -159,9 +168,9 @@ void Textures::tick() } } -int Textures::loadAndBindTexture(const std::string& name) +int Textures::loadAndBindTexture(const std::string& name, bool isRequired) { - int id = loadTexture(name, true); + int id = loadTexture(name, isRequired); if (m_currBoundTex != id) { diff --git a/source/client/renderer/Textures.hpp b/source/client/renderer/Textures.hpp index 52bd59dcc..5a7825dfd 100644 --- a/source/client/renderer/Textures.hpp +++ b/source/client/renderer/Textures.hpp @@ -36,7 +36,7 @@ class Textures { public: int loadTexture(const std::string& name, bool bRequired); - int loadAndBindTexture(const std::string& name); + int loadAndBindTexture(const std::string& name, bool isRequired = true); void clear(); void tick(); void addDynamicTexture(DynamicTexture* pTexture); diff --git a/source/client/renderer/entity/ArrowRenderer.cpp b/source/client/renderer/entity/ArrowRenderer.cpp new file mode 100644 index 000000000..b9430b1f2 --- /dev/null +++ b/source/client/renderer/entity/ArrowRenderer.cpp @@ -0,0 +1,73 @@ +#include "ArrowRenderer.hpp" +#include + +ArrowRenderer::ArrowRenderer() +{ +} + +ArrowRenderer::~ArrowRenderer() +{ +} + +void ArrowRenderer::render(Entity* ent, float x, float y, float z, float rot, float a) +{ + Arrow* arrow = reinterpret_cast(ent); + + glPushMatrix(); + bindTexture("item/arrows.png"); + + glTranslatef(x, y, z); + glRotatef(arrow->m_oRot.y + (arrow->m_rot.y - arrow->m_oRot.y) * a - 90.0f, 0.0f, 1.0f, 0.0f); + glRotatef(arrow->m_oRot.x + (arrow->m_rot.x - arrow->m_oRot.x) * a, 0.0f, 0.0f, 1.0f); + + Tesselator& t = Tesselator::instance; + int type = 0; + float u0 = 0.0f; + float u1 = 0.5f; + float v0 = (0 + type * 10) / 32.0f; + float v1 = (5 + type * 10) / 32.0f; + float u02 = 0.0f; + float u12 = 0.15625f; + float v02 = (5 + type * 10) / 32.0f; + float v12 = (10 + type * 10) / 32.0f; + float ss = 0.05625f; + glEnable(32826); + float shake = arrow->m_shakeTime - a; + if (shake > 0.0f) { + float pow = -Mth::sin(shake * 3.0f) * shake; + glRotatef(pow, 0.0f, 0.0f, 1.0f); + } + + glRotatef(45.0f, 1.0f, 0.0f, 0.0f); + glScalef(ss, ss, ss); + glTranslatef(-4.0f, 0.0f, 0.0f); + glNormal3f(ss, 0.0f, 0.0f); + t.begin(); + t.vertexUV(-7.0, -2.0, -2.0, u02, v02); + t.vertexUV(-7.0, -2.0, 2.0, u12, v02); + t.vertexUV(-7.0, 2.0, 2.0, u12, v12); + t.vertexUV(-7.0, 2.0, -2.0, u02, v12); + t.draw(); + + glNormal3f(-ss, 0.0f, 0.0f); + t.begin(); + t.vertexUV(-7.0, 2.0, -2.0, u02, v02); + t.vertexUV(-7.0, 2.0, 2.0, u12, v02); + t.vertexUV(-7.0, -2.0, 2.0, u12, v12); + t.vertexUV(-7.0, -2.0, -2.0, u02, v12); + t.draw(); + + for (int i = 0; i < 4; ++i) { + glRotatef(90.0f, 1.0f, 0.0f, 0.0f); + glNormal3f(0.0f, 0.0f, ss); + t.begin(); + t.vertexUV(-8.0, -2.0, 0.0, u0, v0); + t.vertexUV(8.0, -2.0, 0.0, u1, v0); + t.vertexUV(8.0, 2.0, 0.0, u1, v1); + t.vertexUV(-8.0, 2.0, 0.0, u0, v1); + t.draw(); + } + + glDisable(32826); + glPopMatrix(); +} \ No newline at end of file diff --git a/source/client/renderer/entity/ArrowRenderer.hpp b/source/client/renderer/entity/ArrowRenderer.hpp new file mode 100644 index 000000000..bd3471141 --- /dev/null +++ b/source/client/renderer/entity/ArrowRenderer.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include "EntityRenderer.hpp" + +class ArrowRenderer : public EntityRenderer +{ +public: + ArrowRenderer(); + ~ArrowRenderer(); + + void render(Entity* ent, float x, float y, float z, float rot, float a) override; +}; diff --git a/source/client/renderer/entity/EntityRenderDispatcher.cpp b/source/client/renderer/entity/EntityRenderDispatcher.cpp index d7d18a29d..740319d52 100644 --- a/source/client/renderer/entity/EntityRenderDispatcher.cpp +++ b/source/client/renderer/entity/EntityRenderDispatcher.cpp @@ -15,6 +15,9 @@ #include "client/model/CowModel.hpp" #include "client/model/ChickenModel.hpp" #include "client/model/CreeperModel.hpp" +#include "client/model/SpiderModel.hpp" +#include "client/model/SkeletonModel.hpp" +#include "client/model/ZombieModel.hpp" EntityRenderDispatcher* EntityRenderDispatcher::instance; Vec3 EntityRenderDispatcher::off; @@ -25,7 +28,11 @@ EntityRenderDispatcher::EntityRenderDispatcher() : m_SheepRenderer(new SheepModel(false), new SheepModel(true), 0.7f), m_CowRenderer(new CowModel, 0.7f), m_ChickenRenderer(new ChickenModel, 0.3f), - m_CreeperRenderer(new CreeperModel, 0.5f) + m_CreeperRenderer(new CreeperModel, 0.5f), + m_SpiderRenderer(), + m_SkeletonRenderer(new SkeletonModel, 0.5f), + m_ZombieRenderer(new ZombieModel, 0.5f), + m_ArrowRenderer() { m_pItemInHandRenderer = nullptr; m_pTextures = nullptr; @@ -39,9 +46,13 @@ EntityRenderDispatcher::EntityRenderDispatcher() : m_HumanoidMobRenderer.init(this); m_PigRenderer.init(this); m_SheepRenderer.init(this); + m_SpiderRenderer.init(this); + m_SkeletonRenderer.init(this); m_CowRenderer.init(this); m_ChickenRenderer.init(this); m_CreeperRenderer.init(this); + m_ZombieRenderer.init(this); + m_ArrowRenderer.init(this); // TODO @@ -92,8 +103,16 @@ EntityRenderer* EntityRenderDispatcher::getRenderer(int renderType) return &m_PigRenderer; case RENDER_SHEEP: return &m_SheepRenderer; + case RENDER_SPIDER: + return &m_SpiderRenderer; + case RENDER_SKELETON: + return &m_SkeletonRenderer; case RENDER_CREEPER: return &m_CreeperRenderer; + case RENDER_ZOMBIE: + return &m_ZombieRenderer; + case RENDER_ARROW: + return &m_ArrowRenderer; case RENDER_ROCKET: return &m_RocketRenderer; #ifdef ENH_ALLOW_SAND_GRAVITY @@ -145,6 +164,7 @@ void EntityRenderDispatcher::render(Entity* entity, float a) void EntityRenderDispatcher::render(Entity* entity, const Vec3& pos, float rot, float a) { EntityRenderer* pRenderer = getRenderer(entity); + if (pRenderer) { #ifndef ORIGINAL_CODE diff --git a/source/client/renderer/entity/EntityRenderDispatcher.hpp b/source/client/renderer/entity/EntityRenderDispatcher.hpp index 32766ddeb..8b1655ab6 100644 --- a/source/client/renderer/entity/EntityRenderDispatcher.hpp +++ b/source/client/renderer/entity/EntityRenderDispatcher.hpp @@ -19,6 +19,8 @@ #include "CowRenderer.hpp" #include "ChickenRenderer.hpp" #include "CreeperRenderer.hpp" +#include "SpiderRenderer.hpp" +#include "ArrowRenderer.hpp" #include "RocketRenderer.hpp" class Minecraft; @@ -56,12 +58,13 @@ class EntityRenderDispatcher //padding?? ItemRenderer m_ItemRenderer; CreeperRenderer m_CreeperRenderer; - //SpiderRenderer m_SpiderRenderer; - //SkeletonRenderer m_SkeletonRenderer; - //ZombieRenderer m_ZombieRenderer; + SpiderRenderer m_SpiderRenderer; + HumanoidMobRenderer m_SkeletonRenderer; + HumanoidMobRenderer m_ZombieRenderer; //SheepRenderer m_SheepRenderer; //SheepFurRenderer m_SheepFurRenderer; TripodCameraRenderer m_CameraRenderer; + ArrowRenderer m_ArrowRenderer; RocketRenderer m_RocketRenderer; Textures* m_pTextures; Level* m_pLevel; diff --git a/source/client/renderer/entity/EntityRenderer.cpp b/source/client/renderer/entity/EntityRenderer.cpp index 8a3e96047..27dd53d43 100644 --- a/source/client/renderer/entity/EntityRenderer.cpp +++ b/source/client/renderer/entity/EntityRenderer.cpp @@ -18,9 +18,9 @@ EntityRenderer::EntityRenderer() : m_model(0.0f, 0.0f) m_pDispatcher = nullptr; } -void EntityRenderer::bindTexture(const std::string& file) +bool EntityRenderer::bindTexture(const std::string& file, bool isRequired) { - m_pDispatcher->m_pTextures->loadAndBindTexture(file); + return m_pDispatcher->m_pTextures->loadAndBindTexture(file, isRequired) != -1; } Font* EntityRenderer::getFont() diff --git a/source/client/renderer/entity/EntityRenderer.hpp b/source/client/renderer/entity/EntityRenderer.hpp index 65bb9141e..6fa7553a9 100644 --- a/source/client/renderer/entity/EntityRenderer.hpp +++ b/source/client/renderer/entity/EntityRenderer.hpp @@ -33,7 +33,7 @@ class EntityRenderer public: EntityRenderer(); - void bindTexture(const std::string& file); + bool bindTexture(const std::string& file, bool isRequired = true); Font* getFont(); void init(EntityRenderDispatcher* d); static void render(const AABB&, float, float, float); diff --git a/source/client/renderer/entity/HumanoidMobRenderer.cpp b/source/client/renderer/entity/HumanoidMobRenderer.cpp index ebf4f282b..f740901c4 100644 --- a/source/client/renderer/entity/HumanoidMobRenderer.cpp +++ b/source/client/renderer/entity/HumanoidMobRenderer.cpp @@ -21,25 +21,20 @@ HumanoidMobRenderer::HumanoidMobRenderer(HumanoidModel* pModel, float f) : MobRe void HumanoidMobRenderer::additionalRendering(Mob* mob, float f) { - if (!mob->isPlayer()) return; - Player* player = (Player*)mob; + ItemInstance* inst = mob->getCarriedItem(); - int itemID = player->m_pInventory->getSelectedItemId(); - if (itemID <= 0) - return; - - ItemInstance inst(itemID, 1, 0); glPushMatrix(); m_pHumanoidModel->m_arm1.translateTo(0.0625f); glTranslatef(-0.0625f, 0.4375f, 0.0625f); - if (itemID <= C_MAX_TILES && TileRenderer::canRender(Tile::tiles[itemID]->getRenderShape())) +#pragma warning(disable : 6385) // this warning is just wrong; intellisense cant handle it being a pointer->index + if (inst && inst->m_itemID <= C_MAX_TILES && TileRenderer::canRender(Tile::tiles[inst->m_itemID]->getRenderShape())) { glTranslatef(0.0f, 0.1875f, -0.3125f); glRotatef(20.0f, 1.0f, 0.0f, 0.0f); glRotatef(45.0f, 0.0f, 1.0f, 0.0f); glScalef(0.375f, -0.375f, 0.375f); } - else if (Item::items[itemID]->isHandEquipped()) + else if (inst && Item::items[inst->m_itemID]->isHandEquipped()) { glTranslatef(0.0f, 0.1875f, 0.0f); glScalef(0.625f, -0.625f, 0.625f); @@ -55,7 +50,7 @@ void HumanoidMobRenderer::additionalRendering(Mob* mob, float f) glRotatef(20.0f, 0.0f, 0.0f, 1.0f); } - m_pDispatcher->m_pItemInHandRenderer->renderItem(&inst); + m_pDispatcher->m_pItemInHandRenderer->renderItem(inst); glPopMatrix(); } diff --git a/source/client/renderer/entity/SkeletonRenderer.cpp b/source/client/renderer/entity/SkeletonRenderer.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/source/client/renderer/entity/SkeletonRenderer.hpp b/source/client/renderer/entity/SkeletonRenderer.hpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/source/client/renderer/entity/SpiderRenderer.cpp b/source/client/renderer/entity/SpiderRenderer.cpp index e69de29bb..09be5dd2e 100644 --- a/source/client/renderer/entity/SpiderRenderer.cpp +++ b/source/client/renderer/entity/SpiderRenderer.cpp @@ -0,0 +1,29 @@ +#include "SpiderRenderer.hpp" +#include "world/entity/Mob.hpp" +#include "client/model/SpiderModel.hpp" + +SpiderRenderer::SpiderRenderer() : MobRenderer(new SpiderModel, 1.0f) +{ + setArmor(new SpiderModel); +} + +SpiderRenderer::~SpiderRenderer() +{ +} + +int SpiderRenderer::prepareArmor(Mob* spider, int layer, float a) +{ + if (layer != 0) + return 0; + + if (!bindTexture("mob/spider_eyes.png", false)) + return 0; + + float br = (1.0f - spider->getBrightness(1.0f)) * 0.5f; + glEnable(GL_BLEND); + glDisable(GL_ALPHA_TEST); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glColor4f(1.0f, 1.0f, 1.0f, br); + + return 1; +} \ No newline at end of file diff --git a/source/client/renderer/entity/SpiderRenderer.hpp b/source/client/renderer/entity/SpiderRenderer.hpp index e69de29bb..1ddbbca02 100644 --- a/source/client/renderer/entity/SpiderRenderer.hpp +++ b/source/client/renderer/entity/SpiderRenderer.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include "MobRenderer.hpp" + +class SpiderRenderer : public MobRenderer +{ +public: + SpiderRenderer(); + ~SpiderRenderer(); + + float getFlipDegrees(Mob*) override { return 180.0f; } + int prepareArmor(Mob* spider, int layer, float a) override; +}; diff --git a/source/client/renderer/entity/ZombieRenderer.cpp b/source/client/renderer/entity/ZombieRenderer.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/source/client/renderer/entity/ZombieRenderer.hpp b/source/client/renderer/entity/ZombieRenderer.hpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/source/client/sound/sound_list.h b/source/client/sound/sound_list.h index 0c0f38da5..df43af453 100644 --- a/source/client/sound/sound_list.h +++ b/source/client/sound/sound_list.h @@ -28,9 +28,11 @@ SOUND(step, wood, 2) SOUND(step, wood, 3) SOUND(step, wood, 4) +SOUND(random, bow, ) SOUND(random, click, ) SOUND(random, door_close, ) SOUND(random, door_open, ) +SOUND(random, drr, ) SOUND(random, explode, ) SOUND(random, fizz, ) SOUND(random, fuse, ) @@ -73,3 +75,24 @@ SOUND(mob, sheep, 1) SOUND(mob, sheep, 2) SOUND(mob, sheep, 3) +SOUND(mob, skeleton, 1) +SOUND(mob, skeleton, 2) +SOUND(mob, skeleton, 3) +SOUND(mob, skeletonhurt, 1) +SOUND(mob, skeletonhurt, 2) +SOUND(mob, skeletonhurt, 3) +SOUND(mob, skeletonhurt, 4) +SOUND(mob, skeletondeath, ) + +SOUND(mob, spider, 1) +SOUND(mob, spider, 2) +SOUND(mob, spider, 3) +SOUND(mob, spider, 4) +SOUND(mob, spiderdeath, ) + +SOUND(mob, zombie, 1) +SOUND(mob, zombie, 2) +SOUND(mob, zombie, 3) +SOUND(mob, zombiehurt, 1) +SOUND(mob, zombiehurt, 2) +SOUND(mob, zombiedeath, ) diff --git a/source/world/entity/Arrow.cpp b/source/world/entity/Arrow.cpp new file mode 100644 index 000000000..c417bc721 --- /dev/null +++ b/source/world/entity/Arrow.cpp @@ -0,0 +1,243 @@ +#include "Arrow.hpp" +#include "Mob.hpp" +#include "world/level/Level.hpp" + +Arrow::Arrow(Level* pLevel) : Entity(pLevel) +{ + _init(); +} + +Arrow::Arrow(Level* pLevel, const Vec3& pos) : Entity(pLevel) +{ + _init(); + + setPos(pos); +} + +Arrow::Arrow(Level* pLevel, Mob* pMob) : Entity(pLevel) +{ + _init(); + + m_owner = pMob; + moveTo(Vec3(pMob->m_pos.x, pMob->m_pos.y + pMob->getHeadHeight(), pMob->m_pos.z), Vec2(pMob->m_rot.y, pMob->m_rot.x)); + + m_pos.x -= Mth::cos(m_rot.y / 180.0f * M_PI) * 0.16f; + m_pos.y -= 0.1f; + m_pos.z -= Mth::sin(m_rot.y / 180.0f * M_PI) * 0.16f; + setPos(m_pos); + + m_vel.x = -Mth::sin(m_rot.y / 180.0f * M_PI) * Mth::cos(m_rot.x / 180.0f * M_PI); + m_vel.z = Mth::cos(m_rot.y / 180.0f * M_PI) * Mth::cos(m_rot.x / 180.0f * M_PI); + m_vel.y = -Mth::sin(m_rot.x / 180.0f * M_PI); + shoot(m_vel, 1.5f, 1.0f); +} + +void Arrow::_init() +{ + m_pDescriptor = &EntityTypeDescriptor::arrow; + field_C8 = RENDER_ARROW; + setSize(0.5f, 0.5f); + + m_tilePos = Vec3(-1, -1, -1); + m_lastTile = 0; + m_inGround = false; + m_life = 0; + m_flightTime = 0; + m_shakeTime = 0; + m_owner = nullptr; +} + +void Arrow::shoot(Vec3 vel, float speed, float r) +{ + float len = vel.length(); + vel /= len; + vel.x += sharedRandom.nextGaussian() * 0.0075f * r; + vel.y += sharedRandom.nextGaussian() * 0.0075f * r; + vel.z += sharedRandom.nextGaussian() * 0.0075f * r; + vel *= speed; + + m_vel = vel; + _lerpMotion(vel); + + m_life = 0; +} + +void Arrow::_lerpMotion(const Vec3& vel) +{ + float len = vel.length(); + m_oRot.y = m_rot.y = Mth::atan2(vel.x, vel.z) * 180.0f / M_PI; + m_oRot.x = m_rot.x = Mth::atan2(vel.y, len) * 180.0f / M_PI; +} + +void Arrow::_lerpMotion2(const Vec3& vel) +{ + if (m_oRot.x == 0.0f && m_oRot.y == 0.0f) + { + return _lerpMotion(vel); + } +} + +void Arrow::lerpMotion(const Vec3& vel) +{ + m_vel = vel; + + _lerpMotion2(vel); +} + +void Arrow::tick() +{ + Entity::tick(); + + _lerpMotion2(m_vel); + + if (m_shakeTime > 0) + --m_shakeTime; + + if (m_inGround) + { + if (m_pLevel->getTile(m_tilePos) == m_lastTile) + { + ++m_life; + if (m_life == 1200) + { + remove(); + } + + return; + } + + m_inGround = false; + m_vel.x *= sharedRandom.nextFloat() * 0.2f; + m_vel.y *= sharedRandom.nextFloat() * 0.2f; + m_vel.z *= sharedRandom.nextFloat() * 0.2f; + m_life = 0; + m_flightTime = 0; + } + else + { + ++m_flightTime; + } + + Vec3 future_pos = m_pos + m_vel; + HitResult hit_result = m_pLevel->clip(m_pos, future_pos); + if (hit_result.isHit()) + { + future_pos = hit_result.m_hitPos; + } + + Entity* hit_ent = nullptr; + AABB hitbox = m_hitbox; + hitbox.expand(m_vel.x, m_vel.y, m_vel.z).grow(1.0f); + EntityVector entities = m_pLevel->getEntities(this, hitbox); + + float max_dist = 0.0f; + constexpr float var10 = 0.3f; + for (EntityVector::iterator it = entities.begin(); it != entities.end(); it++) + { + Entity* ent = *it; + if (ent->isPickable() && (ent != m_owner || m_flightTime >= 5)) + { + AABB aabb = ent->m_hitbox; + aabb.grow(var10); + // these Vec3's are copied in the TilePos::clip fn, so no need to create them over and over like in b1.2 + HitResult hit = aabb.clip(m_pos, future_pos); + if (hit.isHit()) + { + float distance = m_pos.distanceTo(hit.m_hitPos); + if (distance < max_dist || max_dist == 0.0f) + { + hit_ent = ent; + max_dist = distance; + } + } + } + } + + if (hit_ent != nullptr) + { + hit_result = HitResult(hit_ent); + } + + if (hit_result.isHit()) + { + if (hit_result.m_pEnt != nullptr) + { + if (hit_result.m_pEnt->hurt(m_owner, 4)) + { + m_pLevel->playSound(this, "random.drr", 1.0f, 1.2f / (sharedRandom.nextFloat() * 0.2f + 0.9f)); + remove(); + } + else + { + m_vel *= -0.1f; + m_rot.y += 180.0f; + m_oRot.y += 180.0f; + m_flightTime = 0; + } + } + else + { + m_tilePos = hit_result.m_tilePos; + m_lastTile = m_pLevel->getTile(m_tilePos); + m_vel = hit_result.m_hitPos - m_pos; + m_pos -= (m_vel / m_pos.length() * 0.05f); + m_pLevel->playSound(this, "random.drr", 1.0f, 1.2f / (sharedRandom.nextFloat() * 0.2f + 0.9f)); + m_inGround = true; + m_shakeTime = 7; + } + } + + m_pos += m_vel; + float var17 = m_vel.length(); + m_rot.y = Mth::atan2(m_vel.x, m_vel.z) * 180.0f / M_PI; + + for (m_rot.x = Mth::atan2(m_vel.y, var17) * 180.0f / M_PI; m_rot.x - m_oRot.x < -180.0f; m_oRot.x -= 360.0f); + + while (m_rot.x - m_oRot.x >= 180.0f) + { + m_oRot.x += 360.0f; + } + + while (m_rot.y - m_oRot.y < -180.0f) + { + m_oRot.y -= 360.0f; + } + + while (m_rot.y - m_oRot.y >= 180.0f) + { + m_oRot.y += 360.0f; + } + + m_rot.x = m_oRot.x + (m_rot.x - m_oRot.x) * 0.2f; + m_rot.y = m_oRot.y + (m_rot.y - m_oRot.y) * 0.2f; + float dampening = 0.99f; + if (isInWater()) + { + for (int var19 = 0; var19 < 4; ++var19) + { + constexpr float var20 = 0.25f; + m_pLevel->addParticle("bubble", m_pos - m_vel * var20, m_pos * 1); // passed as reference so *1; although addParticle doesn't exist yet + } + + dampening = 0.8f; + } + + m_vel *= dampening; + m_vel.y -= 0.03f; + setPos(m_pos); +} + +void Arrow::playerTouch(Player* pPlayer) +{ + // IsMultiplayer should just be called IsOnline + if (!m_pLevel->m_bIsMultiplayer) + { + // they use ->add here in b1.2_02 + if (m_inGround && m_owner == pPlayer && m_shakeTime <= 0 && pPlayer->m_pInventory->addItem(new ItemInstance(ITEM_ARROW, 1, 0))) + { + m_pLevel->playSound(this, "random.pop", 0.2f, ((sharedRandom.nextFloat() - sharedRandom.nextFloat()) * 0.7f + 1.0f) * 2.0f); + pPlayer->take(this, 1); + remove(); + } + } +} diff --git a/source/world/entity/Arrow.hpp b/source/world/entity/Arrow.hpp new file mode 100644 index 000000000..f814cf0f7 --- /dev/null +++ b/source/world/entity/Arrow.hpp @@ -0,0 +1,39 @@ +#pragma once + +#include "Entity.hpp" + +class Arrow : public Entity +{ +private: + TilePos m_tilePos; + TileID m_lastTile; + bool m_inGround; + int m_life; + int m_flightTime; + +public: + int m_shakeTime; + Mob* m_owner; + + Arrow(Level* pLevel); + Arrow(Level* pLevel, const Vec3& pos); + Arrow(Level* pLevel, Mob* pMob); + +private: + void _init(); + void _lerpMotion(const Vec3& vel); + void _lerpMotion2(const Vec3& vel); + +public: + void shoot(float x, float y, float z, float speed, float r) { shoot(Vec3(x, y, z), speed, r); }; + void shoot(Vec3 pos, float speed, float r); + + void lerpMotion(float x, float y, float z) { lerpMotion(Vec3(x, y, z)); }; + void lerpMotion(const Vec3& vel); + + void tick() override; + + void playerTouch(Player* pPlayer) override; + + float getShadowHeightOffs() const override { return 0.0f; } +}; \ No newline at end of file diff --git a/source/world/entity/Entity.hpp b/source/world/entity/Entity.hpp index c64816a2b..a04724acc 100644 --- a/source/world/entity/Entity.hpp +++ b/source/world/entity/Entity.hpp @@ -42,6 +42,7 @@ enum eEntityRenderType RENDER_SPIDER, RENDER_CREEPER, RENDER_ROCKET, + RENDER_ARROW, // custom RENDER_FALLING_TILE = 50, diff --git a/source/world/entity/Mob.hpp b/source/world/entity/Mob.hpp index cef53ef2e..3a6b3c920 100644 --- a/source/world/entity/Mob.hpp +++ b/source/world/entity/Mob.hpp @@ -55,7 +55,7 @@ class Mob : public Entity virtual void lookAt(Entity* pEnt, float, float); virtual bool isLookingAtAnEntity() { return m_pEntLookedAt != nullptr; } virtual Entity* getLookingAt() const { return m_pEntLookedAt; } - virtual void beforeRemove() { } + virtual void beforeRemove() {} virtual bool canSpawn(); virtual float getAttackAnim(float f) const; virtual Vec3 getPos(float f) const; @@ -63,6 +63,7 @@ class Mob : public Entity virtual Vec3 getLookAngle(float f) const { return getViewVector(1.0f); } virtual Vec3 getViewVector(float f) const; virtual int getMaxSpawnClusterSize() const { return 4; } + virtual ItemInstance* getCarriedItem() { return nullptr; } virtual bool isBaby() const { return false; } virtual void actuallyHurt(int damage); virtual bool removeWhenFarAway() const { return true; } diff --git a/source/world/entity/MobFactory.cpp b/source/world/entity/MobFactory.cpp index 9e8ede63d..12b10a1f9 100644 --- a/source/world/entity/MobFactory.cpp +++ b/source/world/entity/MobFactory.cpp @@ -3,10 +3,10 @@ #include "Cow.hpp" #include "Pig.hpp" #include "Sheep.hpp" -//#include "Zombie.hpp" +#include "Zombie.hpp" #include "Creeper.hpp" -//#include "Skeleton.hpp" -//#include "Spider.hpp" +#include "Skeleton.hpp" +#include "Spider.hpp" //#include "PigZombie.hpp" #define ENTS ENT(CHICKEN, Chicken) \ @@ -14,9 +14,9 @@ ENT(PIG, Pig) \ ENT(SHEEP, Sheep) \ ENT(CREEPER, Creeper) \ - //ENT(ZOMBIE, Zombie) \ - //ENT(SKELETON, Skeleton) \ - //ENT(SPIDER, Spider) \ + ENT(ZOMBIE, Zombie) \ + ENT(SPIDER, Spider) \ + ENT(SKELETON, Skeleton) \ //ENT(PIG_ZOMBIE, PigZombie) #define ENT(enumType, classType) case EntityType::enumType: return new classType(level); diff --git a/source/world/entity/Player.cpp b/source/world/entity/Player.cpp index 22a0c13e7..9c356d44b 100644 --- a/source/world/entity/Player.cpp +++ b/source/world/entity/Player.cpp @@ -192,6 +192,15 @@ void Player::aiStep() } } +ItemInstance* Player::getCarriedItem() +{ + ItemInstance* inst = m_pInventory->getItem(m_pInventory->m_selectedHotbarSlot); + if (inst->m_itemID <= 0) + return nullptr; + + return inst; +} + void Player::updateAi() { if (m_bSwinging) diff --git a/source/world/entity/Player.hpp b/source/world/entity/Player.hpp index 03ebe0091..980001e8e 100644 --- a/source/world/entity/Player.hpp +++ b/source/world/entity/Player.hpp @@ -36,6 +36,7 @@ class Player : public Mob virtual void resetPos() override; virtual void die(Entity* pCulprit) override; virtual void aiStep() override; + ItemInstance* getCarriedItem() override; virtual bool isImmobile() const override { return m_health <= 0; } virtual void updateAi() override; diff --git a/source/world/entity/Skeleton.cpp b/source/world/entity/Skeleton.cpp new file mode 100644 index 000000000..212b405fb --- /dev/null +++ b/source/world/entity/Skeleton.cpp @@ -0,0 +1,66 @@ +#include "Skeleton.hpp" + +Skeleton::Skeleton(Level* pLevel) : Monster(pLevel) +{ + m_pDescriptor = &EntityTypeDescriptor::skeleton; + field_C8 = RENDER_SKELETON; + m_texture = "mob/skeleton.png"; +} + +void Skeleton::aiStep() +{ + if (m_pLevel->isDay()) + { + float brightness = getBrightness(1.0f); + if (brightness > 0.5f + && m_pLevel->canSeeSky(this->m_pos) + && m_random.nextFloat() * 30.0f < (brightness - 0.4f) * 2.0f) + { + this->m_fireTicks = 300; + } + } + + Monster::aiStep(); +} + +void Skeleton::checkHurtTarget(Entity* ent, float f) +{ + if (f < 10.0f) + { + float delta_x = ent->m_pos.x - m_pos.x; + float delta_z = ent->m_pos.z - m_pos.z; + if (m_attackTime == 0) + { + Arrow* arrow = new Arrow(m_pLevel, this); + arrow->m_pos.y += 1; + float var8 = ent->m_pos.y - 0.2f - arrow->m_pos.y; + float var10 = Mth::sqrt(delta_x * delta_x + delta_z * delta_z) * 0.2f; + m_pLevel->playSound(this, "random.bow", 1.0f, 1.0f / (m_random.nextFloat() * 0.4f + 0.8f)); + m_pLevel->addEntity(arrow); + arrow->shoot(delta_x, var8 + var10, delta_z, 0.6f, 12.0f); + m_attackTime = 30; + } + + m_rot.y = (Mth::atan2(delta_z, delta_x) * 180.0f / M_PI) - 90.0f; + m_bHoldGround = true; + } + +} + +void Skeleton::dropDeathLoot() +{ + for (int i = 0; i < m_random.nextInt(3); ++i) + spawnAtLocation(Item::arrow->m_itemID, 1); + + for (int i = 0; i < m_random.nextInt(3); ++i) + spawnAtLocation(Item::bone->m_itemID, 1); +} + +ItemInstance* Skeleton::bow = nullptr; +ItemInstance* Skeleton::getCarriedItem() +{ + if (!bow) + bow = new ItemInstance(Item::bow, 1); + + return bow; +} diff --git a/source/world/entity/Skeleton.hpp b/source/world/entity/Skeleton.hpp new file mode 100644 index 000000000..e1653f9b4 --- /dev/null +++ b/source/world/entity/Skeleton.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include "world/entity/Monster.hpp" +#include "world/entity/Arrow.hpp" + +class Skeleton : public Monster +{ +private: + static ItemInstance* bow; + +public: + Skeleton(Level* pLevel); + + std::string getAmbientSound() const override { return "mob.skeleton"; } + std::string getDeathSound() const override { return "mob.skeletonhurt"; } + std::string getHurtSound() const override { return "mob.skeletonhurt"; } + + void aiStep() override; + + void checkHurtTarget(Entity* ent, float f) override; + + int getDeathLoot() const override { return ITEM_ARROW; } + + void dropDeathLoot() override; + + ItemInstance* getCarriedItem() override; +}; \ No newline at end of file diff --git a/source/world/entity/Spider.cpp b/source/world/entity/Spider.cpp new file mode 100644 index 000000000..eac95c4e3 --- /dev/null +++ b/source/world/entity/Spider.cpp @@ -0,0 +1,48 @@ +#include "Spider.hpp" + +Spider::Spider(Level* pLevel) : Monster(pLevel) +{ + m_pDescriptor = &EntityTypeDescriptor::spider; + field_C8 = RENDER_SPIDER; + + m_texture = "mob/spider.png"; + setSize(1.4f, 0.9f); + m_runSpeed = 0.8f; +} + +Entity* Spider::findAttackTarget() +{ + if (getBrightness(1.0f) < 0.5f) + return m_pLevel->getNearestAttackablePlayer(*this, 16.0f); + + return nullptr; +} + +void Spider::checkHurtTarget(Entity* ent, float var2) +{ + float brightness = getBrightness(1.0f); + + if (brightness > 0.5f && m_random.nextInt(100) == 0) + { + m_pAttackTarget = nullptr; + } + else + { + if (var2 > 2.0f && var2 < 6.0f && m_random.nextInt(10) == 0) + { + if (m_onGround) + { + float var4 = ent->m_pos.x - m_pos.x; + float var6 = ent->m_pos.z - m_pos.z; + float var8 = Mth::sqrt(var4 * var4 + var6 * var6); + m_vel.x = var4 / var8 * 0.5f * 0.8f + m_vel.x * 0.2f; + m_vel.z = var6 / var8 * 0.5f * 0.8f + m_vel.z * 0.2f; + m_vel.y = 0.4f; + } + } + else + { + Monster::checkHurtTarget(ent, var2); + } + } +} \ No newline at end of file diff --git a/source/world/entity/Spider.hpp b/source/world/entity/Spider.hpp new file mode 100644 index 000000000..44151857f --- /dev/null +++ b/source/world/entity/Spider.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include "world/entity/Monster.hpp" + +class Spider : public Monster +{ +public: + Spider(Level* pLevel); + + std::string getAmbientSound() const override { return "mob.spider"; } + std::string getDeathSound() const override { return "mob.spiderdeath"; } + std::string getHurtSound() const override { return "mob.spider"; } + int getDeathLoot() const override { return ITEM_STRING; } + float getRideHeight() const { return m_bbHeight * 0.75f - 0.5f; } + + Entity* findAttackTarget() override; + void checkHurtTarget(Entity* ent, float var2) override; + + bool onLadder() const override { return m_bHorizontalCollision; } +}; \ No newline at end of file diff --git a/source/world/entity/Zombie.cpp b/source/world/entity/Zombie.cpp new file mode 100644 index 000000000..1b431ea47 --- /dev/null +++ b/source/world/entity/Zombie.cpp @@ -0,0 +1,26 @@ +#include "Zombie.hpp" + +Zombie::Zombie(Level* pLevel) : Monster(pLevel) +{ + m_pDescriptor = &EntityTypeDescriptor::zombie; + field_C8 = RENDER_ZOMBIE; + m_texture = "mob/zombie.png"; + m_runSpeed = 0.5f; + m_attackDamage = 5; +} + +void Zombie::aiStep() +{ + if (m_pLevel->isDay()) + { + float var1 = getBrightness(1.0f); + if (var1 > 0.5f + && m_pLevel->canSeeSky(this->m_pos) + && m_random.nextFloat() * 30.0f < (var1 - 0.4f) * 2.0f) + { + this->m_fireTicks = 300; + } + } + + Monster::aiStep(); +} \ No newline at end of file diff --git a/source/world/entity/Zombie.hpp b/source/world/entity/Zombie.hpp new file mode 100644 index 000000000..cf12c0563 --- /dev/null +++ b/source/world/entity/Zombie.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include "world/entity/Monster.hpp" + +class Zombie : public Monster +{ +public: + Zombie(Level* pLevel); + + std::string getAmbientSound() const override { return "mob.zombie"; } + std::string getDeathSound() const override { return "mob.zombiedeath"; } + std::string getHurtSound() const override { return "mob.zombiehurt"; } + int getDeathLoot() const override { return ITEM_FEATHER; } + int getMaxHealth() const override { return 10; } + float getSoundVolume() const override { return 0.4f; } + + void aiStep() override; +}; \ No newline at end of file diff --git a/source/world/item/Inventory.cpp b/source/world/item/Inventory.cpp index cf69f7264..dbc12a6a9 100644 --- a/source/world/item/Inventory.cpp +++ b/source/world/item/Inventory.cpp @@ -129,15 +129,15 @@ void Inventory::clear() // This code, and this function, don't exist in b1.2_02 // "add" exists with these same arguments, which calls "addResource", // but addResource's code is entirely different somehow. Did we write this from scratch? -void Inventory::addItem(ItemInstance* pInst) +bool Inventory::addItem(ItemInstance* pInst) { if (_getGameMode() == GAME_TYPE_CREATIVE) { // Just get rid of the item. pInst->m_count = 0; - return; + return true; } - + // look for an item with the same ID for (int i = 0; i < getNumItems(); i++) { @@ -169,7 +169,7 @@ void Inventory::addItem(ItemInstance* pInst) // If there's nothing leftover: if (pInst->m_count <= 0) - return; + return true; // try to add it to an empty slot for (int i = 0; i < getNumItems(); i++) @@ -180,8 +180,10 @@ void Inventory::addItem(ItemInstance* pInst) m_items[i] = *pInst; m_items[i].m_popTime = 5; pInst->m_count = 0; - return; + return true; } + + return false; } // Doesn't exist in PE diff --git a/source/world/item/Inventory.hpp b/source/world/item/Inventory.hpp index d91d2c100..8645ce284 100644 --- a/source/world/item/Inventory.hpp +++ b/source/world/item/Inventory.hpp @@ -26,7 +26,7 @@ class Inventory void addTestItem(int itemID, int amount, int auxValue = 0); void clear(); - void addItem(ItemInstance* pInst); + bool addItem(ItemInstance* pInst); void tick(); ItemInstance* getItem(int slotNo); diff --git a/source/world/item/Item.cpp b/source/world/item/Item.cpp index 29ddda15c..81454d27a 100644 --- a/source/world/item/Item.cpp +++ b/source/world/item/Item.cpp @@ -97,6 +97,10 @@ void Item::initItems() g_bInittedItems = true; + Item::bow = NEW_ITEM(ITEM_BOW) + ->setIcon(5, 1) + ->setDescriptionId("bow"); + Item::arrow = NEW_ITEM(ITEM_ARROW) ->setIcon(5, 2) ->setDescriptionId("arrow"); diff --git a/source/world/phys/AABB.cpp b/source/world/phys/AABB.cpp index b5e69eeb3..3c24e6970 100644 --- a/source/world/phys/AABB.cpp +++ b/source/world/phys/AABB.cpp @@ -170,37 +170,45 @@ bool AABB::intersect(const AABB& other) const && min.z < other.max.z; } -void AABB::move(const Vec3& vec) +AABB& AABB::move(const Vec3& vec) { min += vec; max += vec; + + return *this; } -void AABB::move(float x, float y, float z) +AABB& AABB::move(float x, float y, float z) { - move(Vec3(x, y, z)); + return move(Vec3(x, y, z)); } // same thing -void AABB::grow(const Vec3& vec) +AABB& AABB::grow(const Vec3& vec) { min -= vec; max += vec; + + return *this; } -void AABB::grow(float x, float y, float z) +AABB& AABB::grow(float x, float y, float z) { grow(Vec3(x, y, z)); + + return *this; } // same thing -void AABB::grow(float x) +AABB& AABB::grow(float x) { min -= Vec3(x, x, x); max += Vec3(x, x, x); + + return *this; } -void AABB::expand(float x, float y, float z) +AABB& AABB::expand(float x, float y, float z) { if (x < 0) min.x += x; if (x > 0) max.x += x; @@ -208,11 +216,13 @@ void AABB::expand(float x, float y, float z) if (y > 0) max.y += y; if (z < 0) min.z += z; if (z > 0) max.z += z; + + return *this; } -void AABB::expand(const Vec3& vec) +AABB& AABB::expand(const Vec3& vec) { - expand(vec.x, vec.y, vec.z); + return expand(vec.x, vec.y, vec.z); } bool AABB::contains(const Vec3& v) const diff --git a/source/world/phys/AABB.hpp b/source/world/phys/AABB.hpp index c44432327..b0dc12a58 100644 --- a/source/world/phys/AABB.hpp +++ b/source/world/phys/AABB.hpp @@ -33,15 +33,15 @@ class AABB bool intersect(const AABB& other) const; // @NOTE: Names for `move`, `grow` and `expand` were taken from really early minecraft (rd-132211 to be exact). - void move(const Vec3& vec); - void move(float x, float y, float z); + AABB& move(const Vec3& vec); + AABB& move(float x, float y, float z); // same thing - void grow(const Vec3& vec); - void grow(float x, float y, float z); + AABB& grow(const Vec3& vec); + AABB& grow(float x, float y, float z); // same thing - void grow(float x); - void expand(float x, float y, float z); - void expand(const Vec3& vec); + AABB& grow(float x); + AABB& expand(float x, float y, float z); + AABB& expand(const Vec3& vec); bool contains(const Vec3& v) const; }; diff --git a/source/world/phys/Vec3.cpp b/source/world/phys/Vec3.cpp index f0529c52b..55d899763 100644 --- a/source/world/phys/Vec3.cpp +++ b/source/world/phys/Vec3.cpp @@ -41,47 +41,15 @@ Vec3 Vec3::interpolateTo(const Vec3& to, float t) const return Vec3(nx, ny, nz); } -Vec3 Vec3::vectorTo(const Vec3& to) const -{ - return Vec3(to.x - x, to.y - y, to.z - z); -} - Vec3 Vec3::normalize() const { - float dist = Mth::sqrt(x * x + y * y + z * z); + float dist = length(); if (dist < 0.0001f) return ZERO; return Vec3(x / dist, y / dist, z / dist); } -float Vec3::dot(const Vec3& other) const -{ - return x * other.x + y * other.y + z * other.z; -} - -Vec3 Vec3::cross(const Vec3& other) const -{ - return Vec3(y * other.z - z * other.y, z * other.x - x * other.z, x * other.y - y * other.x); -} - -Vec3 Vec3::add(float x, float y, float z) const -{ - return Vec3(this->x + x, this->y + y, this->z + z); -} - -float Vec3::distanceTo(const Vec3& b) const -{ - return Mth::sqrt(distanceToSqr(b)); -} - -float Vec3::distanceToSqr(const Vec3& b) const -{ - Vec3 d = *this - b; - - return d.x * d.x + d.y * d.y + d.z * d.z; -} - bool Vec3::clipX(const Vec3& a2, float a3, Vec3& a4) const { float crap = a2.x - this->x; diff --git a/source/world/phys/Vec3.hpp b/source/world/phys/Vec3.hpp index 74b2926f8..6e093bcc2 100644 --- a/source/world/phys/Vec3.hpp +++ b/source/world/phys/Vec3.hpp @@ -38,20 +38,58 @@ class Vec3 Vec3(const TilePos& tilePos); Vec3 interpolateTo(const Vec3& to, float t) const; - Vec3 vectorTo(const Vec3& to) const; + Vec3 vectorTo(const Vec3& to) const + { + return Vec3(to.x - x, to.y - y, to.z - z); + } Vec3 normalize() const; - float dot(const Vec3& other) const; - Vec3 cross(const Vec3& other) const; - Vec3 add(float x, float y, float z) const; + float dot(const Vec3& other) const + { + return x * other.x + y * other.y + z * other.z; + } + Vec3 cross(const Vec3& other) const + { + return Vec3(y * other.z - z * other.y, z * other.x - x * other.z, x * other.y - y * other.x); + } + Vec3 add(float x, float y, float z) const + { + return Vec3(this->x + x, this->y + y, this->z + z); + } // these are likely inlined - float distanceTo(const Vec3& b) const; - float distanceToSqr(const Vec3& b) const; + float distanceTo(const Vec3& b) const + { + return Mth::sqrt(distanceToSqr(b)); + } + float distanceToSqr(const Vec3& b) const + { + return (*this - b).lengthSqr(); + } bool clipX(const Vec3& a2, float a3, Vec3& a4) const; bool clipY(const Vec3& a2, float a3, Vec3& a4) const; bool clipZ(const Vec3& a2, float a3, Vec3& a4) const; + Vec3 translate(float tx, float ty, float tz) const + { + return Vec3(x + tx, y + ty, z + tz); + } + + float lengthSqr() const + { + return x * x + y * y + z * z; + } + + float length() const + { + return Mth::sqrt(lengthSqr()); + } + + Vec3 scale(float scale) const + { + return Vec3(x * scale, y * scale, z * scale); + } + // these are also likely inlined, but I'll declare them in the header Vec3 operator+(const Vec3& b) const { @@ -101,6 +139,13 @@ class Vec3 z *= f; } + void operator/=(float f) + { + x /= f; + y /= f; + z /= f; + } + Vec3 operator-() const { return Vec3(-x, -y, -z); @@ -127,25 +172,5 @@ class Vec3 y == b.y && z == b.z; } - - Vec3 translate(float tx, float ty, float tz) const - { - return Vec3(x + tx, y + ty, z + tz); - } - - float lengthSqr() const - { - return x * x + y * y + z * z; - } - - float length() const - { - return Mth::sqrt(lengthSqr()); - } - - Vec3 scale(float scale) const - { - return Vec3(x * scale, y * scale, z * scale); - } }; From 25302a0e51502381fa042423d8fc8bec64f9d90e Mon Sep 17 00:00:00 2001 From: Er2 Date: Tue, 1 Jul 2025 23:05:15 +0300 Subject: [PATCH 014/293] GUI: Add scrolling (#118) * GUI: Add scrolling Fixes #107 * Fix bad merge * Remove GLES Compatibility Layer --------- Co-authored-by: Brent <43089001+BrentDaMage@users.noreply.github.com> Co-authored-by: BrentDaMage --- source/client/app/Minecraft.cpp | 12 ++++++++--- source/client/gui/Gui.cpp | 20 +++++++++++++++++++ source/client/gui/Gui.hpp | 1 + source/client/gui/Screen.cpp | 6 ++++++ source/client/gui/Screen.hpp | 1 + .../gui/components/RolledSelectionList.cpp | 7 +++++++ .../gui/components/RolledSelectionList.hpp | 1 + .../gui/components/ScrolledSelectionList.cpp | 8 +++++++- .../gui/components/ScrolledSelectionList.hpp | 1 + source/client/gui/screens/OptionsScreen.cpp | 4 ++++ source/client/gui/screens/OptionsScreen.hpp | 1 + .../client/gui/screens/SelectWorldScreen.cpp | 5 +++++ .../client/gui/screens/SelectWorldScreen.hpp | 1 + 13 files changed, 64 insertions(+), 4 deletions(-) diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp index 0bb5029ed..d0cada9c5 100644 --- a/source/client/app/Minecraft.cpp +++ b/source/client/app/Minecraft.cpp @@ -425,14 +425,20 @@ void Minecraft::tickInput() if (Mouse::isButtonDown(BUTTON_LEFT)) m_gui.handleClick(1, Mouse::getX(), Mouse::getY()); + MouseButtonType buttonType = Mouse::getEventButton(); + bool bPressed = Mouse::getEventButtonState() == true; + +#ifdef ENH_ALLOW_SCROLL_WHEEL + if (buttonType == BUTTON_SCROLLWHEEL) + m_gui.handleScroll(bPressed); +#endif + if (!bIsInGUI && getOptions()->field_19) { - MouseButtonType buttonType = Mouse::getEventButton(); - #ifdef ENH_ALLOW_SCROLL_WHEEL if (buttonType == BUTTON_SCROLLWHEEL) { - if (Mouse::getEventButtonState() == 0) + if (!bPressed) { // @NOTE: Scroll up m_gui.handleKeyPressed(getOptions()->getKey(KM_SLOT_L)); diff --git a/source/client/gui/Gui.cpp b/source/client/gui/Gui.cpp index d8e8f31e9..dcb6648b0 100644 --- a/source/client/gui/Gui.cpp +++ b/source/client/gui/Gui.cpp @@ -491,6 +491,26 @@ void Gui::handleClick(int clickID, int mouseX, int mouseY) m_pMinecraft->m_pLocalPlayer->m_pInventory->selectSlot(slot); } +void Gui::handleScroll(bool down) +{ + int slot = m_pMinecraft->m_pLocalPlayer->m_pInventory->m_selectedHotbarSlot; + + int maxItems = getNumUsableSlots() - 1; + + if (down) + { + if (slot++ == maxItems) + slot = 0; + } + else + { + if (slot-- == 0) + slot = maxItems; + } + + m_pMinecraft->m_pLocalPlayer->m_pInventory->selectSlot(slot); +} + void Gui::handleKeyPressed(int keyCode) { Options* options = m_pMinecraft->getOptions(); diff --git a/source/client/gui/Gui.hpp b/source/client/gui/Gui.hpp index 169a3b14f..98e1cf925 100644 --- a/source/client/gui/Gui.hpp +++ b/source/client/gui/Gui.hpp @@ -49,6 +49,7 @@ class Gui : public GuiComponent int getSlotIdAt(int mx, int my); bool isInside(int mx, int my); void handleClick(int id, int mx, int my); + void handleScroll(bool down); void handleKeyPressed(int keyCode); void renderMessages(bool bShowAll); int getNumSlots(); // Gets the number of slots in the inventory. Includes the '...' if in touch mode. diff --git a/source/client/gui/Screen.cpp b/source/client/gui/Screen.cpp index aeb233a2e..4156b659d 100644 --- a/source/client/gui/Screen.cpp +++ b/source/client/gui/Screen.cpp @@ -87,6 +87,10 @@ void Screen::keyboardNewChar(char chr) } } +void Screen::handleScroll(bool down) +{ +} + static const char* g_panoramaList[] = { "gui/background/panorama_0.png", @@ -391,6 +395,8 @@ void Screen::mouseEvent() else mouseReleased(m_width * pAction->_posX / Minecraft::width, m_height * pAction->_posY / Minecraft::height - 1 + getYOffset(), Mouse::getEventButton()); } + if (pAction->_buttonType == BUTTON_SCROLLWHEEL) + handleScroll(Mouse::getEventButtonState()); } void Screen::renderBackground(int unk) diff --git a/source/client/gui/Screen.hpp b/source/client/gui/Screen.hpp index e1e12c382..688cc9458 100644 --- a/source/client/gui/Screen.hpp +++ b/source/client/gui/Screen.hpp @@ -62,6 +62,7 @@ class Screen : public GuiComponent virtual void mouseReleased(int, int, int); virtual void keyPressed(int); virtual void keyboardNewChar(char); + virtual void handleScroll(bool down); // ported from 0.8 virtual void renderMenuBackground(float f); diff --git a/source/client/gui/components/RolledSelectionList.cpp b/source/client/gui/components/RolledSelectionList.cpp index 80ac50425..96bc3e3d6 100644 --- a/source/client/gui/components/RolledSelectionList.cpp +++ b/source/client/gui/components/RolledSelectionList.cpp @@ -335,3 +335,10 @@ void RolledSelectionList::clickedHeader(int x, int y) { } + +void RolledSelectionList::handleScroll(bool down) +{ + float diff = 5.0f * (down ? -1.0f : 1.0f); + field_34 = field_30 = field_30 + diff; + field_28 = 0; +} diff --git a/source/client/gui/components/RolledSelectionList.hpp b/source/client/gui/components/RolledSelectionList.hpp index 6d02f78ab..e830f9483 100644 --- a/source/client/gui/components/RolledSelectionList.hpp +++ b/source/client/gui/components/RolledSelectionList.hpp @@ -33,6 +33,7 @@ class RolledSelectionList : public GuiComponent virtual void renderBackground() = 0; virtual void renderDecorations(int x, int y); virtual void clickedHeader(int, int); + virtual void handleScroll(bool down); int getItemAtXPositionRaw(int x); diff --git a/source/client/gui/components/ScrolledSelectionList.cpp b/source/client/gui/components/ScrolledSelectionList.cpp index 12676237b..e0ffcc145 100644 --- a/source/client/gui/components/ScrolledSelectionList.cpp +++ b/source/client/gui/components/ScrolledSelectionList.cpp @@ -97,7 +97,6 @@ void ScrolledSelectionList::renderScrollBackground() void ScrolledSelectionList::checkInput(int mouseX, int mouseY) { - int nItems = getNumberOfItems(); if (Mouse::isButtonDown(BUTTON_LEFT)) { if (float(mouseY) >= field_C && float(mouseY) <= field_10 && abs(mouseY - field_28) > 5) @@ -276,3 +275,10 @@ void ScrolledSelectionList::setRenderHeader(bool b, int i) i = 0; field_48 = i; } + +void ScrolledSelectionList::handleScroll(bool down) +{ + float diff = 5.0f * (down ? -1.0f : 1.0f); + field_34 -= diff; + field_38 += diff; +} diff --git a/source/client/gui/components/ScrolledSelectionList.hpp b/source/client/gui/components/ScrolledSelectionList.hpp index 3c9798600..a0b6c19b8 100644 --- a/source/client/gui/components/ScrolledSelectionList.hpp +++ b/source/client/gui/components/ScrolledSelectionList.hpp @@ -36,6 +36,7 @@ class ScrolledSelectionList : public GuiComponent virtual void checkInput(int mouseX, int mouseY); virtual void onClickItem(int index, int mouseX, int mouseY); virtual void renderScrollBackground(); + virtual void handleScroll(bool down); void setRenderHeader(bool, int); diff --git a/source/client/gui/screens/OptionsScreen.cpp b/source/client/gui/screens/OptionsScreen.cpp index 91d6975b9..31a731781 100644 --- a/source/client/gui/screens/OptionsScreen.cpp +++ b/source/client/gui/screens/OptionsScreen.cpp @@ -79,6 +79,10 @@ bool OptionsScreen::handleBackEvent(bool b) return true; } +void OptionsScreen::handleScroll(bool down) +{ + m_pList->handleScroll(down); +} #else diff --git a/source/client/gui/screens/OptionsScreen.hpp b/source/client/gui/screens/OptionsScreen.hpp index e2cf013b1..b74a7b568 100644 --- a/source/client/gui/screens/OptionsScreen.hpp +++ b/source/client/gui/screens/OptionsScreen.hpp @@ -24,6 +24,7 @@ class OptionsScreen : public Screen void removed() override; void buttonClicked(Button* pButton) override; bool handleBackEvent(bool b) override; + void handleScroll(bool down) override; private: OptionList* m_pList; diff --git a/source/client/gui/screens/SelectWorldScreen.cpp b/source/client/gui/screens/SelectWorldScreen.cpp index f9f2f13de..d27229686 100644 --- a/source/client/gui/screens/SelectWorldScreen.cpp +++ b/source/client/gui/screens/SelectWorldScreen.cpp @@ -222,6 +222,11 @@ void SelectWorldScreen::buttonClicked(Button* pButton) } } +void SelectWorldScreen::handleScroll(bool down) +{ + m_pWorldSelectionList->handleScroll(down); +} + bool SelectWorldScreen::isIndexValid(int idx) { if (!m_pWorldSelectionList) diff --git a/source/client/gui/screens/SelectWorldScreen.hpp b/source/client/gui/screens/SelectWorldScreen.hpp index b4daaea43..85fb64630 100644 --- a/source/client/gui/screens/SelectWorldScreen.hpp +++ b/source/client/gui/screens/SelectWorldScreen.hpp @@ -23,6 +23,7 @@ class SelectWorldScreen : public Screen void render(int mouseX, int mouseY, float f) override; bool handleBackEvent(bool b) override; void buttonClicked(Button* pButton) override; + void handleScroll(bool down) override; bool isIndexValid(int); std::string getUniqueLevelName(const std::string& in); From 17c3daef4a27018c34b4b1f14e865d1da52dbeed Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Fri, 4 Jul 2025 02:34:44 -0500 Subject: [PATCH 015/293] Update README.md --- README.md | 70 ++++++++++++++++++++++++------------------------------- 1 file changed, 30 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index db51a0e0f..6bc43735a 100644 --- a/README.md +++ b/README.md @@ -1,38 +1,40 @@ # ReMinecraftPE -This project aims to create a custom Minecraft experience based on Minecraft: Pocket Edition as of 2011. It's -based on Minecraft PE v0.1.3. +This project aims to provide a customizable, cross-platform, legacy Minecraft experience. +The code is based on a decompilation of Minecraft: Pocket Edition (v0.1.3) as of 2011, which itself is a port of Minecraft: Java Edition (Beta 1.3-1.7.3). **Its goals are:** -* To add Quality-of-Life features to Minecraft: Pocket Edition, such as a brighter color gamut, an in-game - options menu, etc. -* To add features that were in Minecraft Alpha and the early Betas in 2011. (before and during Minecraft PE's - development - this excludes hunger, for example, as it was added in Beta 1.8) +* To add features from Minecraft Beta 1.7.3 and below. +* To add togglable edition-specific aesthetic features. + Some examples include: + * Legacy Console Edition gamma and mipmaps + * Pocket Edition sky colors + * Normal lighting (something Pocket Edition lacked) + * Alpha title logo +* To (in the future) provide a cross-platform modding API in a language like [Luau](https://luau.org/), giving more creative control to the community. * To keep the source code layout similar to the original Minecraft PE (reconstructed from clues hidden within certain versions of the game, such as the 0.1.0 touch prototype/debug build) -* To port the game to more platforms, such as Windows (including older versions), Xbox 360, Wii, and more. - Currently, there are ports for: - * Windows XP-11 +* To add support for as many platforms as possible, such as the Xbox 360, PlayStation 3, Wii, and more. + Currently, the following platforms are supported: + * Windows (2000 and above; thanks to [iProgramInCpp](https://github.com/iProgramMC)) * Android (thanks to [Stom](https://github.com/Stommm) for the help) * Linux * WebGL - * macOS (port by [BrentDaMage](https://github.com/BrentDaMage)) - * iOS (3.0 and above; port by [BrentDaMage](https://github.com/BrentDaMage)) + * macOS (10.6 and above; thanks to [BrentDaMage](https://github.com/BrentDaMage)) + * iOS (3.0 and above; thanks to [BrentDaMage](https://github.com/BrentDaMage)) * HaikuOS (thanks to [SanyaSho](https://github.com/SanyaSho)) - * Xbox 360 (work in progress; port by [BrentDaMage](https://github.com/BrentDaMage)) **We will not do the following:** * Add features added in or after Java Edition Beta 1.8 -* Backport features from versions newer than 0.9.0 -* Add The Nether or The End (probably) +* Change the default aesthetic the game is shipped with. We're currently targeting Java Edition Beta 1.7.3. + Players can use the options menu to change the game's aesthetic to match the version/edition of their liking. * Add Herobrine * Add support for Minecraft Java or Minecraft Bedrock servers. (although LAN play with original MCPE clients will be supported for as long as possible) -* Modify the project structure -Note: While the original Minecraft PE v0.1.3 may not work on newer devices, ReMinecraftPE works on all Android devices. +Note: While the original Minecraft PE v0.1.3 may not work on newer devices, ReMinecraftPE works on any of the platforms listed above. -### This is the main modded version. For the original decompilation, see [ReMinecraftPE/mcped](https://github.com/ReMinecraftPE/mcped) +### This a modified version of [the original Minecraft PE v0.1.3 decompilation](https://github.com/ReMinecraftPE/mcped). ## License information @@ -41,19 +43,15 @@ software with different but compatible licenses: - [RakNet](https://github.com/facebookarchive/RakNet): [Licensed under the BSD 2 clause license](thirdparty/raknet/LICENSE) - [zlib](https://github.com/madler/zlib): [View license](thirdparty/zlib/LICENSE) -- [GLES compatibility layer](https://github.com/TheBrokenRail/gles-compatibility-layer): [View license](https://github.com/TheBrokenRail/gles-compatibility-layer/blob/master/LICENSE). Embedded as a submodule. - [coi-serviceworker](https://github.com/gzuidhof/coi-serviceworker): [View license](https://github.com/gzuidhof/coi-serviceworker/blob/master/LICENSE). Embedded as a submodule. +- [stb](https://github.com/nothings/stb): [View license]([https://github.com/gzuidhof/coi-serviceworker/blob/master/LICENSE](https://github.com/nothings/stb/blob/master/LICENSE)). Embedded as a submodule. ## WANT TO HELP? -Want to help this project? [Here's a list of things left to do.](TODO.md) +Want to help this project? Here's [a list of things to do.](https://github.com/ReMinecraftPE/mcpe/issues) +Once your code is tested and ready, [submit a pull request](https://github.com/ReMinecraftPE/mcpe/pulls). -## DISCLAIMER - -This project **requires** you to have a copy of the Minecraft PE v0.1.3 apk (sha256 of the `libminecraftpe.so` -inside: `157af341d13a54cc935bbe24c5e1cf3d02d7e40ec20f9859b9853c2e996ebd81`), before you can build. - -## Setup +## Prep for Building Before trying to build: @@ -62,13 +60,12 @@ Before trying to build: git submodule init git submodule update ``` +This fetches the project's necessary dependencies. -This fetches the three dependencies we have: -- [zlib](https://github.com/madler/zlib) -- [coi-serviceworker](https://github.com/gzuidhof/coi-serviceworker) -- [gles-compatibility-layer](https://github.com/TheBrokenRail/gles-compatibility-layer.git) +2. It is recommended that you have a copy of the Minecraft PE v0.1.3 APK (SHA256 of the `libminecraftpe.so` +inside: `157af341d13a54cc935bbe24c5e1cf3d02d7e40ec20f9859b9853c2e996ebd81`), to extract assets from. Otherwise, the minecraft.jar file from Java Edition Beta 1.7.3 should work _more or less_. -2. Copy the assets (including sounds and textures) into the necessary folders within the project.
+3. Copy the assets (including sounds and textures) into the necessary folders within the project.
Do this by performing **one** of the following: - To extract all assets from _Pocket Edition_: - **Run the following command**: @@ -82,7 +79,7 @@ This fetches the three dependencies we have: - Locate the `resources` directory in the `.minecraft` folder and copy its contents (e.g. `music`, `sound`, etc.) into the `game/assets/` directory of the project. - You will need to extract textures and other assets manually from _Pocket Edition_. -## Building +## How to Build ### Windows @@ -171,14 +168,7 @@ To build, perform the same steps as on Linux. I've had texture seams when playing Minecraft Classic, ClassiCube and this recreation of Minecraft PE, on a fresh new laptop. If seams bother you, and you are using an NVIDIA graphics card, go to the NVIDIA Control Panel, then in "Manage 3D Settings", change "Antialiasing - Mode" to "Application Controlled". - -## Notes on assets - -The terrain.png and related textures appear to have stayed the same between the E3 demo and the final release -for Xperia PLAY. It appears to have been fetched before Java Edition Beta 1.4's release. This can be seen -because the cookie's texture is missing. (it was added in Java Edition Beta 1.4) - -There are plans to create a custom script which downloads and sets up all assets needed for the game. +a custom script which downloads and sets up all assets needed for the game. ## Screenshots (from the decomp) @@ -190,6 +180,6 @@ There are plans to create a custom script which downloads and sets up all assets ## Enhancements -ReMinecraftPE is an enhanced version of the original. To see the original, (mostly) as it was back in the day, +ReMinecraftPE is an enhanced version of the original decompilation. To see the original, (mostly) unmodified code, [see the mcped repository](https://github.com/ReMinecraftPE/mcped). From 24c4f9244881353f094a8ce3cbd5fdecd6be3061 Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Sat, 12 Jul 2025 17:47:19 -0500 Subject: [PATCH 016/293] Fixed lack of top-snow in world gen (#175) * Fixed faulty logic in Level::getTopSolidBlock Co-authored-by: Brent Da Mage --- source/world/level/Level.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/world/level/Level.cpp b/source/world/level/Level.cpp index 46842a3a5..20313c54b 100644 --- a/source/world/level/Level.cpp +++ b/source/world/level/Level.cpp @@ -960,15 +960,15 @@ int Level::getTopTileY(const TilePos& pos) const int Level::getTopSolidBlock(const TilePos& tilePos) const { - //int y = C_MAX_Y - 1; LevelChunk* pChunk = getChunkAt(tilePos); if (!pChunk) return C_MAX_Y; TilePos pos(tilePos); + pos.y = C_MAX_Y - 1; while (true) { - if (!getMaterial(tilePos)->blocksMotion()) + if (!getMaterial(pos)->blocksMotion()) break; if (!pos.y) return -1; From ef35b4b718cf4aaa75877a85805304158515e389 Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Tue, 15 Jul 2025 18:58:05 -0500 Subject: [PATCH 017/293] Fixed hotbar double-scroll (#176) * Fixed duplicate logic in Minecraft::tickInput() calling Gui::handleScroll() twice. * PineFeature logic fix Co-authored-by: Brent Da Mage --- source/client/app/Minecraft.cpp | 19 ------------------- .../level/levelgen/feature/PineFeature.cpp | 4 ++-- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp index d0cada9c5..d8be0fcf8 100644 --- a/source/client/app/Minecraft.cpp +++ b/source/client/app/Minecraft.cpp @@ -432,25 +432,6 @@ void Minecraft::tickInput() if (buttonType == BUTTON_SCROLLWHEEL) m_gui.handleScroll(bPressed); #endif - - if (!bIsInGUI && getOptions()->field_19) - { -#ifdef ENH_ALLOW_SCROLL_WHEEL - if (buttonType == BUTTON_SCROLLWHEEL) - { - if (!bPressed) - { - // @NOTE: Scroll up - m_gui.handleKeyPressed(getOptions()->getKey(KM_SLOT_L)); - } - else - { - // @NOTE: Scroll down - m_gui.handleKeyPressed(getOptions()->getKey(KM_SLOT_R)); - } - } -#endif - } } while (Keyboard::next()) diff --git a/source/world/level/levelgen/feature/PineFeature.cpp b/source/world/level/levelgen/feature/PineFeature.cpp index 6dbfd0bd8..48e8db3f7 100644 --- a/source/world/level/levelgen/feature/PineFeature.cpp +++ b/source/world/level/levelgen/feature/PineFeature.cpp @@ -33,9 +33,9 @@ bool PineFeature::place(Level* level, Random* random, const TilePos& pos) else range = x2; - for (int cx = pos.x - range; cx <= pos.x + range && bCanPlace; cx++) + for (tp.x = pos.x - range; tp.x <= pos.x + range && bCanPlace; tp.x++) { - for (int cz = pos.z - range; cz <= pos.z + range && bCanPlace; cz++) + for (tp.z = pos.z - range; tp.z <= pos.z + range && bCanPlace; tp.z++) { if (tp.y >= C_MAX_Y || tp.y < C_MIN_Y) { From 770f9f6d47312097de6f42c9651e034ef096b094 Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Sat, 30 Aug 2025 18:57:54 -0500 Subject: [PATCH 018/293] NBT-Based Level Saving/Loading (Level Storage Version 2) (#179) * Added NBT Project * Added DataIO & RakIO * Added entity saving and loading via NBT (including player) * NBT-Based Inventory Saving & Bug Fixes * Fixed a number of ItemInstance-related memory leaks * Added NBT-based Inventory saving and loading * Added BigEndianStringByteInput * Added EntityFactory * Added saving/loading for additional entities * Other bugfixes * Fixed CMake Building * Fixed WASM building on Windows * Fixed StringByteInput memcpy build failure * Renamed and abstracted some LegacyCPP headers * Tag memset Build Fix * Fixed building via Xcode & for C++03 * Changed iOS bundle identifier from com.mojang.minecraftpe to io.github.reminecraftpe.minecraftpe * Fixed iOS status bar hiding on iOS 7+ * Fixed bugs + new save format opt-out * Added GameType display to SelectWorldScreen --------- Co-authored-by: Brent Da Mage --- GameMods.hpp | 33 +- build-wasm.bat | 2 +- compat/LegacyCPP.hpp | 3 + ...Compatibility.hpp => LegacyCPP_Compat.hpp} | 10 +- compat/LegacyCPP_Info.hpp | 8 + platforms/ios/minecraftpe-Info.plist | 6 +- .../Minecraft.xcodeproj/project.pbxproj | 331 +++++++++++++++++- platforms/sdl/CMakeLists.txt | 2 +- platforms/windows/minecraftcpp.sln | 20 +- .../windows/projects/Common/Common.vcxproj | 8 +- .../projects/Common/Common.vcxproj.filters | 16 +- platforms/windows/projects/NBT/NBT.vcxproj | 75 ++++ .../windows/projects/NBT/NBT.vcxproj.filters | 107 ++++++ .../windows/projects/Network/Network.vcxproj | 6 +- .../projects/Network/Network.vcxproj.filters | 6 + .../windows/projects/World/World.vcxproj | 7 + .../projects/World/World.vcxproj.filters | 6 + source/CMakeLists.txt | 28 +- source/client/app/Minecraft.cpp | 29 +- .../gui/components/RolledSelectionList.cpp | 2 +- .../gui/components/RolledSelectionList.hpp | 1 + .../gui/components/WorldSelectionList.cpp | 13 +- .../client/gui/screens/CreateWorldScreen.cpp | 17 +- .../screens/IngameBlockSelectionScreen.cpp | 3 +- .../client/gui/screens/SelectWorldScreen.cpp | 4 +- .../network/ClientSideNetworkHandler.cpp | 4 +- source/client/player/input/IArea.hpp | 2 +- source/client/player/input/IMoveInput.hpp | 2 +- source/client/player/input/ITurnInput.hpp | 2 +- source/client/player/input/MouseHandler.cpp | 2 +- source/client/renderer/GameRenderer.cpp | 4 +- .../entity/EntityRenderDispatcher.cpp | 20 +- .../client/renderer/entity/ItemRenderer.cpp | 11 +- source/client/renderer/entity/MobRenderer.cpp | 8 +- source/common/DataIO.cpp | 270 ++++++++++++++ source/common/DataIO.hpp | 119 +++++++ source/common/Utils.hpp | 2 +- source/nbt/CompoundTag.cpp | 328 +++++++++++++++++ source/nbt/CompoundTag.hpp | 78 +++++ source/nbt/DoubleTag.cpp | 34 ++ source/nbt/DoubleTag.hpp | 26 ++ source/nbt/EndTag.cpp | 21 ++ source/nbt/EndTag.hpp | 20 ++ source/nbt/FloatTag.cpp | 34 ++ source/nbt/FloatTag.hpp | 24 ++ source/nbt/Int16Tag.cpp | 34 ++ source/nbt/Int16Tag.hpp | 26 ++ source/nbt/Int32ArrayTag.cpp | 81 +++++ source/nbt/Int32ArrayTag.hpp | 24 ++ source/nbt/Int32Tag.cpp | 34 ++ source/nbt/Int32Tag.hpp | 26 ++ source/nbt/Int64ArrayTag.cpp | 81 +++++ source/nbt/Int64ArrayTag.hpp | 24 ++ source/nbt/Int64Tag.cpp | 34 ++ source/nbt/Int64Tag.hpp | 26 ++ source/nbt/Int8ArrayTag.cpp | 56 +++ source/nbt/Int8ArrayTag.hpp | 24 ++ source/nbt/Int8Tag.cpp | 34 ++ source/nbt/Int8Tag.hpp | 26 ++ source/nbt/ListTag.cpp | 207 +++++++++++ source/nbt/ListTag.hpp | 75 ++++ source/nbt/NbtIo.cpp | 15 + source/nbt/NbtIo.hpp | 11 + source/nbt/StringTag.cpp | 32 ++ source/nbt/StringTag.hpp | 27 ++ source/nbt/Tag.cpp | 115 ++++++ source/nbt/Tag.hpp | 86 +++++ source/network/RakIO.cpp | 23 ++ source/network/RakIO.hpp | 33 ++ source/world/entity/Animal.cpp | 15 + source/world/entity/Animal.hpp | 4 +- source/world/entity/Arrow.cpp | 86 +++-- source/world/entity/Arrow.hpp | 29 +- source/world/entity/Chicken.cpp | 12 +- source/world/entity/Chicken.hpp | 4 +- source/world/entity/Cow.cpp | 10 + source/world/entity/Cow.hpp | 2 + source/world/entity/Creeper.cpp | 4 +- source/world/entity/Entity.cpp | 114 +++++- source/world/entity/Entity.hpp | 15 +- source/world/entity/EntityFactory.cpp | 79 +++++ source/world/entity/EntityFactory.hpp | 11 + source/world/entity/EntityTypeDescriptor.cpp | 2 +- source/world/entity/FallingTile.cpp | 13 +- source/world/entity/FallingTile.hpp | 4 +- source/world/entity/ItemEntity.cpp | 68 ++-- source/world/entity/ItemEntity.hpp | 25 +- source/world/entity/LocalPlayer.cpp | 36 +- source/world/entity/LocalPlayer.hpp | 5 +- source/world/entity/Mob.cpp | 34 +- source/world/entity/Mob.hpp | 4 +- source/world/entity/MobFactory.cpp | 6 +- source/world/entity/Monster.cpp | 10 + source/world/entity/Monster.hpp | 2 + source/world/entity/Player.cpp | 77 +++- source/world/entity/Player.hpp | 9 +- source/world/entity/PrimedTnt.cpp | 11 + source/world/entity/PrimedTnt.hpp | 2 + source/world/entity/Sheep.cpp | 24 +- source/world/entity/Sheep.hpp | 5 +- source/world/gamemode/GameType.hpp | 21 ++ source/world/item/CameraItem.cpp | 2 +- source/world/item/Inventory.cpp | 156 +++++++-- source/world/item/Inventory.hpp | 21 +- source/world/item/Item.cpp | 5 + source/world/item/Item.hpp | 3 + source/world/item/ItemInstance.cpp | 133 ++++++- source/world/item/ItemInstance.hpp | 28 +- source/world/level/Level.cpp | 82 +++-- source/world/level/Level.hpp | 26 +- .../world/level/levelgen/chunk/LevelChunk.cpp | 4 +- .../levelgen/chunk/RandomLevelSource.cpp | 2 +- source/world/level/path/Node.hpp | 2 +- source/world/level/storage/ChunkStorage.cpp | 4 +- source/world/level/storage/ChunkStorage.hpp | 4 +- .../storage/ExternalFileLevelStorage.cpp | 209 +++++++++-- .../storage/ExternalFileLevelStorage.hpp | 21 +- .../ExternalFileLevelStorageSource.cpp | 10 +- .../ExternalFileLevelStorageSource.hpp | 2 +- source/world/level/storage/LevelData.cpp | 220 ++++++++++-- source/world/level/storage/LevelData.hpp | 82 +++-- source/world/level/storage/LevelStorage.cpp | 13 +- source/world/level/storage/LevelStorage.hpp | 8 +- .../level/storage/LevelStorageSource.cpp | 10 +- .../level/storage/LevelStorageSource.hpp | 15 +- .../level/storage/MemoryLevelStorage.cpp | 2 +- .../level/storage/MemoryLevelStorage.hpp | 2 +- source/world/particle/Particle.hpp | 5 +- source/world/phys/Vec2.hpp | 2 +- source/world/phys/Vec3.hpp | 2 +- source/world/tile/GrassTile.cpp | 2 +- source/world/tile/LeafTile.cpp | 2 +- source/world/tile/SandTile.cpp | 2 +- source/world/tile/Tile.cpp | 8 +- source/world/tile/TntTile.cpp | 2 +- thirdparty/raknet/RakNetDefinesOverrides.h | 2 +- 136 files changed, 4284 insertions(+), 460 deletions(-) create mode 100644 compat/LegacyCPP.hpp rename compat/{LegacyCPPCompatibility.hpp => LegacyCPP_Compat.hpp} (60%) create mode 100644 compat/LegacyCPP_Info.hpp create mode 100644 platforms/windows/projects/NBT/NBT.vcxproj create mode 100644 platforms/windows/projects/NBT/NBT.vcxproj.filters create mode 100644 source/common/DataIO.cpp create mode 100644 source/common/DataIO.hpp create mode 100644 source/nbt/CompoundTag.cpp create mode 100644 source/nbt/CompoundTag.hpp create mode 100644 source/nbt/DoubleTag.cpp create mode 100644 source/nbt/DoubleTag.hpp create mode 100644 source/nbt/EndTag.cpp create mode 100644 source/nbt/EndTag.hpp create mode 100644 source/nbt/FloatTag.cpp create mode 100644 source/nbt/FloatTag.hpp create mode 100644 source/nbt/Int16Tag.cpp create mode 100644 source/nbt/Int16Tag.hpp create mode 100644 source/nbt/Int32ArrayTag.cpp create mode 100644 source/nbt/Int32ArrayTag.hpp create mode 100644 source/nbt/Int32Tag.cpp create mode 100644 source/nbt/Int32Tag.hpp create mode 100644 source/nbt/Int64ArrayTag.cpp create mode 100644 source/nbt/Int64ArrayTag.hpp create mode 100644 source/nbt/Int64Tag.cpp create mode 100644 source/nbt/Int64Tag.hpp create mode 100644 source/nbt/Int8ArrayTag.cpp create mode 100644 source/nbt/Int8ArrayTag.hpp create mode 100644 source/nbt/Int8Tag.cpp create mode 100644 source/nbt/Int8Tag.hpp create mode 100644 source/nbt/ListTag.cpp create mode 100644 source/nbt/ListTag.hpp create mode 100644 source/nbt/NbtIo.cpp create mode 100644 source/nbt/NbtIo.hpp create mode 100644 source/nbt/StringTag.cpp create mode 100644 source/nbt/StringTag.hpp create mode 100644 source/nbt/Tag.cpp create mode 100644 source/nbt/Tag.hpp create mode 100644 source/network/RakIO.cpp create mode 100644 source/network/RakIO.hpp create mode 100644 source/world/entity/EntityFactory.cpp create mode 100644 source/world/entity/EntityFactory.hpp diff --git a/GameMods.hpp b/GameMods.hpp index 54d588e18..685f85935 100644 --- a/GameMods.hpp +++ b/GameMods.hpp @@ -20,22 +20,23 @@ // Features (major changes) // Enhancements (minor changes) -//#define ENH_ENTITY_SHADING // Allows shading of entities -- Currently we are abandoning this. Want to add normal support -#define ENH_SHADE_HELD_TILES // Allows shading of the item in hand -#define ENH_FIX_INVIS_STAIRS // Fixes a bug wherein a 16x16x16 chunk in the world that contains only stairs is invisible -#define ENH_ALLOW_AO_TOGGLE // Allows using the F4 key to toggle ambient occlusion (buggy) -#define ENH_TRANSPARENT_HOTBAR // Allows the hotbar to be transparent. Due to a bug in the code, it is not. -#define ENH_CAMERA_NO_PARTICLES // Hide particles from the view of a camera, such as smoke, that would otherwise render the resulting image useless. -#define ENH_USE_JAVA_LIGHT_RAMP // Use Java Beta 1.3 light ramp instead of flawed PE one -#define ENH_RUN_DAY_NIGHT_CYCLE // Allow the day/night cycle to run. -#define ENH_USE_OWN_AO // Use own ambient occlusion engine - looks pretty much the same except it fixes the corners -#define ENH_ADD_OPTIONS_PAUSE // Add an 'options' button in the pause menu -#define ENH_ALLOW_SAND_GRAVITY // Allow sand to fall. -#define ENH_USE_GUI_SCALE_2 // Use a 2x GUI scale instead of 3x. Looks better on PC -#define ENH_ALLOW_SCROLL_WHEEL // Allow use of the scroll wheel to change selected inventory slots -#define ENH_3D_INVENTORY_TILES // Uses 3D rendered inventory tiles, use with ENH_SHADE_HELD_TILES to render correctly. -#define ENH_MENU_BACKGROUND // Renders a spinning panorama (if it's available) in the background of the main menu -#define ENH_GUI_ITEM_POP // Calls Inventory::tick() to create the "pop" animation for items that enter the hotbar. This function was not present on Pocket Edition. +//#define ENH_ENTITY_SHADING // Allows shading of entities -- Currently we are abandoning this. Want to add normal support +#define ENH_SHADE_HELD_TILES // Allows shading of the item in hand +#define ENH_FIX_INVIS_STAIRS // Fixes a bug wherein a 16x16x16 chunk in the world that contains only stairs is invisible +#define ENH_ALLOW_AO_TOGGLE // Allows using the F4 key to toggle ambient occlusion (buggy) +#define ENH_TRANSPARENT_HOTBAR // Allows the hotbar to be transparent. Due to a bug in the code, it is not. +#define ENH_CAMERA_NO_PARTICLES // Hide particles from the view of a camera, such as smoke, that would otherwise render the resulting image useless. +#define ENH_USE_JAVA_LIGHT_RAMP // Use Java Beta 1.3 light ramp instead of flawed PE one +#define ENH_RUN_DAY_NIGHT_CYCLE // Allow the day/night cycle to run. +#define ENH_USE_OWN_AO // Use own ambient occlusion engine - looks pretty much the same except it fixes the corners +#define ENH_ADD_OPTIONS_PAUSE // Add an 'options' button in the pause menu +#define ENH_ALLOW_SAND_GRAVITY // Allow sand to fall. +#define ENH_USE_GUI_SCALE_2 // Use a 2x GUI scale instead of 3x. Looks better on PC +#define ENH_ALLOW_SCROLL_WHEEL // Allow use of the scroll wheel to change selected inventory slots +#define ENH_3D_INVENTORY_TILES // Uses 3D rendered inventory tiles, use with ENH_SHADE_HELD_TILES to render correctly. +#define ENH_MENU_BACKGROUND // Renders a spinning panorama (if it's available) in the background of the main menu +#define ENH_GUI_ITEM_POP // Calls Inventory::tick() to create the "pop" animation for items that enter the hotbar. This function was not present on Pocket Edition. +//#define ENH_DISABLE_FORCED_SAVE_UPGRADES // Prevents the forced format-version upgrade of world/level saves, effectively opting-out of new save formats. See LEVEL_STORAGE_VERSION_DEFAULT in LevelData.hpp. // TODO: Implement this permanently? #define ENH_IMPROVED_SAVING // Improve world saving. The original Minecraft doesn't always really save for some reason diff --git a/build-wasm.bat b/build-wasm.bat index b88d488fe..0a721f811 100644 --- a/build-wasm.bat +++ b/build-wasm.bat @@ -31,7 +31,7 @@ cd build ::configure build echo * Configuring build. -start emcmake cmake -GNinja "$@" ..\..\platforms/sdl +start emcmake cmake -GNinja "$@" ..\..\ echo * PRESS ANY KEY when emcmake is done. pause > nul diff --git a/compat/LegacyCPP.hpp b/compat/LegacyCPP.hpp new file mode 100644 index 000000000..0debd554d --- /dev/null +++ b/compat/LegacyCPP.hpp @@ -0,0 +1,3 @@ +#pragma once + +#include "LegacyCPP_Compat.hpp" \ No newline at end of file diff --git a/compat/LegacyCPPCompatibility.hpp b/compat/LegacyCPP_Compat.hpp similarity index 60% rename from compat/LegacyCPPCompatibility.hpp rename to compat/LegacyCPP_Compat.hpp index a808a1851..2d37ff0dd 100644 --- a/compat/LegacyCPPCompatibility.hpp +++ b/compat/LegacyCPP_Compat.hpp @@ -1,11 +1,6 @@ #pragma once -// On MSVC, pass "/Zc:__cplusplus" to make this actually work correctly -#ifndef USE_OLD_CPP -#if __cplusplus < 201103L -#define USE_OLD_CPP -#endif -#endif +#include "LegacyCPP_Info.hpp" #ifdef USE_OLD_CPP #ifndef constexpr @@ -20,4 +15,7 @@ #ifndef override #define override #endif +#ifndef noexcept +#define noexcept +#endif #endif \ No newline at end of file diff --git a/compat/LegacyCPP_Info.hpp b/compat/LegacyCPP_Info.hpp new file mode 100644 index 000000000..4a1279a50 --- /dev/null +++ b/compat/LegacyCPP_Info.hpp @@ -0,0 +1,8 @@ +#pragma once + +// On MSVC, pass "/Zc:__cplusplus" to make this actually work correctly +#ifndef USE_OLD_CPP +#if __cplusplus < 201103L +#define USE_OLD_CPP +#endif +#endif \ No newline at end of file diff --git a/platforms/ios/minecraftpe-Info.plist b/platforms/ios/minecraftpe-Info.plist index a46711abb..f257e8cdc 100644 --- a/platforms/ios/minecraftpe-Info.plist +++ b/platforms/ios/minecraftpe-Info.plist @@ -5,13 +5,13 @@ CFBundleDevelopmentRegion en CFBundleDisplayName - Minecraft PE + ReMinecraftPE CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIconFiles CFBundleIdentifier - com.mojang.${PRODUCT_NAME:rfc1034identifier} + io.github.reminecraftpe.${PRODUCT_NAME:rfc1034identifier} CFBundleInfoDictionaryVersion 6.0 CFBundleName @@ -36,6 +36,8 @@ UIStatusBarHidden + UIViewControllerBasedStatusBarAppearance + UISupportedInterfaceOrientations UIInterfaceOrientationLandscapeLeft diff --git a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj index f265a842d..b01f8f7e6 100644 --- a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj +++ b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj @@ -243,10 +243,8 @@ 84498A9C2AF18CDA005EF5A5 /* uncompr.c in Sources */ = {isa = PBXBuildFile; fileRef = 840DD8652AC810630006A435 /* uncompr.c */; }; 84498A9D2AF18CDA005EF5A5 /* zutil.c in Sources */ = {isa = PBXBuildFile; fileRef = 840DD8682AC810630006A435 /* zutil.c */; }; 84498AA02AF18D08005EF5A5 /* libZLib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84498A832AF18C7A005EF5A5 /* libZLib.a */; }; - 84619B1E2AF1EDA300B0DE81 /* libClient.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84B8AEE72AF188D8008DE93D /* libClient.a */; }; 84619B1F2AF1EDA300B0DE81 /* libCommon.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84E4BFAE2AE9854B0023E16A /* libCommon.a */; }; 84619B202AF1EDA300B0DE81 /* libRenderer.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8406FD292AF1814500B09C1D /* libRenderer.a */; }; - 84619B212AF1EDA300B0DE81 /* libWorld.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84BF630B2AF1859D008A9995 /* libWorld.a */; }; 84619B222AF1EDA300B0DE81 /* libZLib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84498A832AF18C7A005EF5A5 /* libZLib.a */; }; 84619B392AF1F73900B0DE81 /* GL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD6552AC810620006A435 /* GL.hpp */; }; 84619B3C2AF1FE4C00B0DE81 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84619B3B2AF1FE4C00B0DE81 /* OpenAL.framework */; }; @@ -1176,6 +1174,48 @@ 84C208542AF88A5000BAE438 /* patch_data.txt in Resources */ = {isa = PBXBuildFile; fileRef = 84C208522AF88A5000BAE438 /* patch_data.txt */; }; 84C90EA52AF8861A008973F9 /* OptionList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84C90EA32AF8861A008973F9 /* OptionList.cpp */; }; 84C90EA62AF8861A008973F9 /* OptionList.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84C90EA42AF8861A008973F9 /* OptionList.hpp */; }; + 84CCBC3F2E6183F300E251AF /* DataIO.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84CCBC3D2E6183F300E251AF /* DataIO.cpp */; }; + 84CCBC402E6183F300E251AF /* DataIO.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84CCBC3E2E6183F300E251AF /* DataIO.hpp */; }; + 84CCBC6D2E61857800E251AF /* CompoundTag.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84CCBC4F2E61857800E251AF /* CompoundTag.cpp */; }; + 84CCBC6E2E61857800E251AF /* CompoundTag.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84CCBC502E61857800E251AF /* CompoundTag.hpp */; }; + 84CCBC6F2E61857800E251AF /* DoubleTag.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84CCBC512E61857800E251AF /* DoubleTag.cpp */; }; + 84CCBC702E61857800E251AF /* DoubleTag.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84CCBC522E61857800E251AF /* DoubleTag.hpp */; }; + 84CCBC712E61857800E251AF /* EndTag.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84CCBC532E61857800E251AF /* EndTag.cpp */; }; + 84CCBC722E61857800E251AF /* EndTag.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84CCBC542E61857800E251AF /* EndTag.hpp */; }; + 84CCBC732E61857800E251AF /* FloatTag.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84CCBC552E61857800E251AF /* FloatTag.cpp */; }; + 84CCBC742E61857800E251AF /* FloatTag.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84CCBC562E61857800E251AF /* FloatTag.hpp */; }; + 84CCBC752E61857800E251AF /* Int16Tag.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84CCBC572E61857800E251AF /* Int16Tag.cpp */; }; + 84CCBC762E61857800E251AF /* Int16Tag.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84CCBC582E61857800E251AF /* Int16Tag.hpp */; }; + 84CCBC772E61857800E251AF /* Int32ArrayTag.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84CCBC592E61857800E251AF /* Int32ArrayTag.cpp */; }; + 84CCBC782E61857800E251AF /* Int32ArrayTag.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84CCBC5A2E61857800E251AF /* Int32ArrayTag.hpp */; }; + 84CCBC792E61857800E251AF /* Int32Tag.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84CCBC5B2E61857800E251AF /* Int32Tag.cpp */; }; + 84CCBC7A2E61857800E251AF /* Int32Tag.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84CCBC5C2E61857800E251AF /* Int32Tag.hpp */; }; + 84CCBC7B2E61857800E251AF /* Int64ArrayTag.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84CCBC5D2E61857800E251AF /* Int64ArrayTag.cpp */; }; + 84CCBC7C2E61857800E251AF /* Int64ArrayTag.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84CCBC5E2E61857800E251AF /* Int64ArrayTag.hpp */; }; + 84CCBC7D2E61857800E251AF /* Int64Tag.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84CCBC5F2E61857800E251AF /* Int64Tag.cpp */; }; + 84CCBC7E2E61857800E251AF /* Int64Tag.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84CCBC602E61857800E251AF /* Int64Tag.hpp */; }; + 84CCBC7F2E61857800E251AF /* Int8ArrayTag.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84CCBC612E61857800E251AF /* Int8ArrayTag.cpp */; }; + 84CCBC802E61857800E251AF /* Int8ArrayTag.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84CCBC622E61857800E251AF /* Int8ArrayTag.hpp */; }; + 84CCBC812E61857800E251AF /* Int8Tag.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84CCBC632E61857800E251AF /* Int8Tag.cpp */; }; + 84CCBC822E61857800E251AF /* Int8Tag.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84CCBC642E61857800E251AF /* Int8Tag.hpp */; }; + 84CCBC832E61857800E251AF /* ListTag.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84CCBC652E61857800E251AF /* ListTag.cpp */; }; + 84CCBC842E61857800E251AF /* ListTag.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84CCBC662E61857800E251AF /* ListTag.hpp */; }; + 84CCBC852E61857800E251AF /* NbtIo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84CCBC672E61857800E251AF /* NbtIo.cpp */; }; + 84CCBC862E61857800E251AF /* NbtIo.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84CCBC682E61857800E251AF /* NbtIo.hpp */; }; + 84CCBC872E61857800E251AF /* StringTag.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84CCBC692E61857800E251AF /* StringTag.cpp */; }; + 84CCBC882E61857800E251AF /* StringTag.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84CCBC6A2E61857800E251AF /* StringTag.hpp */; }; + 84CCBC892E61857800E251AF /* Tag.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84CCBC6B2E61857800E251AF /* Tag.cpp */; }; + 84CCBC8A2E61857800E251AF /* Tag.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84CCBC6C2E61857800E251AF /* Tag.hpp */; }; + 84CCBC932E61880600E251AF /* EntityFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84CCBC912E61880600E251AF /* EntityFactory.cpp */; }; + 84CCBC942E61880600E251AF /* EntityFactory.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84CCBC922E61880600E251AF /* EntityFactory.hpp */; }; + 84CCBC972E61886800E251AF /* RakIO.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84CCBC952E61886800E251AF /* RakIO.cpp */; }; + 84CCBC982E61886800E251AF /* RakIO.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84CCBC962E61886800E251AF /* RakIO.hpp */; }; + 84CCBC992E618BD400E251AF /* libCommon.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84E4BFAE2AE9854B0023E16A /* libCommon.a */; }; + 84CCBC9A2E618BD400E251AF /* libWorld.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84BF630B2AF1859D008A9995 /* libWorld.a */; }; + 84CCBC9D2E618BF000E251AF /* libCommon.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84E4BFAE2AE9854B0023E16A /* libCommon.a */; }; + 84CCBC9E2E618C1D00E251AF /* libNBT.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84CCBC452E61849800E251AF /* libNBT.a */; }; + 84CCBC9F2E61910500E251AF /* libClient.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84B8AEE72AF188D8008DE93D /* libClient.a */; }; + 84CCBCA02E61910500E251AF /* libWorld.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84BF630B2AF1859D008A9995 /* libWorld.a */; }; 84CEF0032AE3C97D006C5829 /* EAGLView.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CEF0022AE3C97D006C5829 /* EAGLView.m */; }; 84D9A30E2AF18EC000B00AD3 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8489B3252A86E4B0004CA8EC /* OpenGL.framework */; }; 84D9A30F2AF18EE700B00AD3 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8489B3252A86E4B0004CA8EC /* OpenGL.framework */; settings = {ATTRIBUTES = (Required, ); }; }; @@ -1451,6 +1491,34 @@ remoteGlobalIDString = 84BF62FE2AF1859D008A9995; remoteInfo = World; }; + 84CCBC8B2E61861900E251AF /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 8489B08F2A86D4B2004CA8EC /* Project object */; + proxyType = 1; + remoteGlobalIDString = 84CCBC442E61849800E251AF; + remoteInfo = NBT; + }; + 84CCBC8D2E6186CD00E251AF /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 8489B08F2A86D4B2004CA8EC /* Project object */; + proxyType = 1; + remoteGlobalIDString = 84E4BFAD2AE9854B0023E16A; + remoteInfo = Common; + }; + 84CCBC8F2E6186D000E251AF /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 8489B08F2A86D4B2004CA8EC /* Project object */; + proxyType = 1; + remoteGlobalIDString = 84BF62FE2AF1859D008A9995; + remoteInfo = World; + }; + 84CCBC9B2E618BEB00E251AF /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 8489B08F2A86D4B2004CA8EC /* Project object */; + proxyType = 1; + remoteGlobalIDString = 84E4BFAD2AE9854B0023E16A; + remoteInfo = Common; + }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -2770,6 +2838,43 @@ 84C4D86E2A872C0100323E33 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; 84C90EA32AF8861A008973F9 /* OptionList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OptionList.cpp; sourceTree = ""; }; 84C90EA42AF8861A008973F9 /* OptionList.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = OptionList.hpp; sourceTree = ""; }; + 84CCBC3D2E6183F300E251AF /* DataIO.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DataIO.cpp; sourceTree = ""; }; + 84CCBC3E2E6183F300E251AF /* DataIO.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DataIO.hpp; sourceTree = ""; }; + 84CCBC452E61849800E251AF /* libNBT.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libNBT.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 84CCBC4F2E61857800E251AF /* CompoundTag.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CompoundTag.cpp; sourceTree = ""; }; + 84CCBC502E61857800E251AF /* CompoundTag.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CompoundTag.hpp; sourceTree = ""; }; + 84CCBC512E61857800E251AF /* DoubleTag.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DoubleTag.cpp; sourceTree = ""; }; + 84CCBC522E61857800E251AF /* DoubleTag.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DoubleTag.hpp; sourceTree = ""; }; + 84CCBC532E61857800E251AF /* EndTag.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EndTag.cpp; sourceTree = ""; }; + 84CCBC542E61857800E251AF /* EndTag.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = EndTag.hpp; sourceTree = ""; }; + 84CCBC552E61857800E251AF /* FloatTag.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FloatTag.cpp; sourceTree = ""; }; + 84CCBC562E61857800E251AF /* FloatTag.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FloatTag.hpp; sourceTree = ""; }; + 84CCBC572E61857800E251AF /* Int16Tag.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Int16Tag.cpp; sourceTree = ""; }; + 84CCBC582E61857800E251AF /* Int16Tag.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Int16Tag.hpp; sourceTree = ""; }; + 84CCBC592E61857800E251AF /* Int32ArrayTag.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Int32ArrayTag.cpp; sourceTree = ""; }; + 84CCBC5A2E61857800E251AF /* Int32ArrayTag.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Int32ArrayTag.hpp; sourceTree = ""; }; + 84CCBC5B2E61857800E251AF /* Int32Tag.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Int32Tag.cpp; sourceTree = ""; }; + 84CCBC5C2E61857800E251AF /* Int32Tag.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Int32Tag.hpp; sourceTree = ""; }; + 84CCBC5D2E61857800E251AF /* Int64ArrayTag.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Int64ArrayTag.cpp; sourceTree = ""; }; + 84CCBC5E2E61857800E251AF /* Int64ArrayTag.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Int64ArrayTag.hpp; sourceTree = ""; }; + 84CCBC5F2E61857800E251AF /* Int64Tag.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Int64Tag.cpp; sourceTree = ""; }; + 84CCBC602E61857800E251AF /* Int64Tag.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Int64Tag.hpp; sourceTree = ""; }; + 84CCBC612E61857800E251AF /* Int8ArrayTag.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Int8ArrayTag.cpp; sourceTree = ""; }; + 84CCBC622E61857800E251AF /* Int8ArrayTag.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Int8ArrayTag.hpp; sourceTree = ""; }; + 84CCBC632E61857800E251AF /* Int8Tag.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Int8Tag.cpp; sourceTree = ""; }; + 84CCBC642E61857800E251AF /* Int8Tag.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Int8Tag.hpp; sourceTree = ""; }; + 84CCBC652E61857800E251AF /* ListTag.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ListTag.cpp; sourceTree = ""; }; + 84CCBC662E61857800E251AF /* ListTag.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ListTag.hpp; sourceTree = ""; }; + 84CCBC672E61857800E251AF /* NbtIo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NbtIo.cpp; sourceTree = ""; }; + 84CCBC682E61857800E251AF /* NbtIo.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = NbtIo.hpp; sourceTree = ""; }; + 84CCBC692E61857800E251AF /* StringTag.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringTag.cpp; sourceTree = ""; }; + 84CCBC6A2E61857800E251AF /* StringTag.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StringTag.hpp; sourceTree = ""; }; + 84CCBC6B2E61857800E251AF /* Tag.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Tag.cpp; sourceTree = ""; }; + 84CCBC6C2E61857800E251AF /* Tag.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Tag.hpp; sourceTree = ""; }; + 84CCBC912E61880600E251AF /* EntityFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EntityFactory.cpp; sourceTree = ""; }; + 84CCBC922E61880600E251AF /* EntityFactory.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = EntityFactory.hpp; sourceTree = ""; }; + 84CCBC952E61886800E251AF /* RakIO.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RakIO.cpp; sourceTree = ""; }; + 84CCBC962E61886800E251AF /* RakIO.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RakIO.hpp; sourceTree = ""; }; 84CEF0012AE3C97D006C5829 /* EAGLView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EAGLView.h; sourceTree = ""; }; 84CEF0022AE3C97D006C5829 /* EAGLView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EAGLView.m; sourceTree = ""; }; 84D6694F2B1EAEBF00B34FC1 /* GlobalDebugSettings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = GlobalDebugSettings.xcconfig; path = ../Configuration/GlobalDebugSettings.xcconfig; sourceTree = ""; }; @@ -2866,6 +2971,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 84CCBC992E618BD400E251AF /* libCommon.a in Frameworks */, + 84CCBC9A2E618BD400E251AF /* libWorld.a in Frameworks */, 842610882AE98A4C0065905F /* libRakNet.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -2898,11 +3005,11 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 84CCBC9F2E61910500E251AF /* libClient.a in Frameworks */, + 84CCBCA02E61910500E251AF /* libWorld.a in Frameworks */, 8420EF302B32B4EE0051910E /* libSystem.dylib in Frameworks */, - 84619B1E2AF1EDA300B0DE81 /* libClient.a in Frameworks */, 84619B1F2AF1EDA300B0DE81 /* libCommon.a in Frameworks */, 84619B202AF1EDA300B0DE81 /* libRenderer.a in Frameworks */, - 84619B212AF1EDA300B0DE81 /* libWorld.a in Frameworks */, 84619B222AF1EDA300B0DE81 /* libZLib.a in Frameworks */, 84EAE8DE2AF1EAA1000894E8 /* UIKit.framework in Frameworks */, 849259202AD8FCFC0081F5B9 /* Foundation.framework in Frameworks */, @@ -2935,6 +3042,15 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 84CCBC9E2E618C1D00E251AF /* libNBT.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 84CCBC422E61849800E251AF /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 84CCBC9D2E618BF000E251AF /* libCommon.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2972,6 +3088,7 @@ children = ( 840DD57C2AC810620006A435 /* client */, 840DD6252AC810620006A435 /* common */, + 84CCBC4E2E61857800E251AF /* nbt */, 840DD6392AC810620006A435 /* network */, 840DD6522AC810620006A435 /* renderer */, 840DD6562AC810620006A435 /* world */, @@ -3238,6 +3355,8 @@ children = ( 840DD6262AC810620006A435 /* CThread.cpp */, 840DD6272AC810620006A435 /* CThread.hpp */, + 84CCBC3D2E6183F300E251AF /* DataIO.cpp */, + 84CCBC3E2E6183F300E251AF /* DataIO.hpp */, 840DD6282AC810620006A435 /* Logger.cpp */, 840DD6292AC810620006A435 /* Logger.hpp */, 840DD62B2AC810620006A435 /* Matrix.cpp */, @@ -3270,6 +3389,8 @@ 8470AF2E2BE9B62600BCA54E /* PacketUtil.cpp */, 8470AF2F2BE9B62600BCA54E /* PacketUtil.hpp */, 840DD64D2AC810620006A435 /* PingedCompatibleServer.hpp */, + 84CCBC952E61886800E251AF /* RakIO.cpp */, + 84CCBC962E61886800E251AF /* RakIO.hpp */, 840DD64E2AC810620006A435 /* RakNetInstance.cpp */, 840DD64F2AC810620006A435 /* RakNetInstance.hpp */, 840DD6502AC810620006A435 /* ServerSideNetworkHandler.cpp */, @@ -3350,6 +3471,8 @@ 840DD6592AC810620006A435 /* Entity.hpp */, 8445E7952D769329008DC834 /* EntityCategories.cpp */, 8445E7962D769329008DC834 /* EntityCategories.hpp */, + 84CCBC912E61880600E251AF /* EntityFactory.cpp */, + 84CCBC922E61880600E251AF /* EntityFactory.hpp */, 8445E7972D769329008DC834 /* EntityType.cpp */, 8470AF282BE9B60900BCA54E /* EntityType.hpp */, 8445E7982D769329008DC834 /* EntityTypeDescriptor.cpp */, @@ -4296,6 +4419,7 @@ 84B8AEE72AF188D8008DE93D /* libClient.a */, 84AAF6422AF18B9500BD67F4 /* libOpenGL.a */, 84498A832AF18C7A005EF5A5 /* libZLib.a */, + 84CCBC452E61849800E251AF /* libNBT.a */, ); name = Products; sourceTree = ""; @@ -5056,6 +5180,43 @@ path = patches; sourceTree = ""; }; + 84CCBC4E2E61857800E251AF /* nbt */ = { + isa = PBXGroup; + children = ( + 84CCBC4F2E61857800E251AF /* CompoundTag.cpp */, + 84CCBC502E61857800E251AF /* CompoundTag.hpp */, + 84CCBC512E61857800E251AF /* DoubleTag.cpp */, + 84CCBC522E61857800E251AF /* DoubleTag.hpp */, + 84CCBC532E61857800E251AF /* EndTag.cpp */, + 84CCBC542E61857800E251AF /* EndTag.hpp */, + 84CCBC552E61857800E251AF /* FloatTag.cpp */, + 84CCBC562E61857800E251AF /* FloatTag.hpp */, + 84CCBC572E61857800E251AF /* Int16Tag.cpp */, + 84CCBC582E61857800E251AF /* Int16Tag.hpp */, + 84CCBC592E61857800E251AF /* Int32ArrayTag.cpp */, + 84CCBC5A2E61857800E251AF /* Int32ArrayTag.hpp */, + 84CCBC5B2E61857800E251AF /* Int32Tag.cpp */, + 84CCBC5C2E61857800E251AF /* Int32Tag.hpp */, + 84CCBC5D2E61857800E251AF /* Int64ArrayTag.cpp */, + 84CCBC5E2E61857800E251AF /* Int64ArrayTag.hpp */, + 84CCBC5F2E61857800E251AF /* Int64Tag.cpp */, + 84CCBC602E61857800E251AF /* Int64Tag.hpp */, + 84CCBC612E61857800E251AF /* Int8ArrayTag.cpp */, + 84CCBC622E61857800E251AF /* Int8ArrayTag.hpp */, + 84CCBC632E61857800E251AF /* Int8Tag.cpp */, + 84CCBC642E61857800E251AF /* Int8Tag.hpp */, + 84CCBC652E61857800E251AF /* ListTag.cpp */, + 84CCBC662E61857800E251AF /* ListTag.hpp */, + 84CCBC672E61857800E251AF /* NbtIo.cpp */, + 84CCBC682E61857800E251AF /* NbtIo.hpp */, + 84CCBC692E61857800E251AF /* StringTag.cpp */, + 84CCBC6A2E61857800E251AF /* StringTag.hpp */, + 84CCBC6B2E61857800E251AF /* Tag.cpp */, + 84CCBC6C2E61857800E251AF /* Tag.hpp */, + ); + path = nbt; + sourceTree = ""; + }; 84D6694E2B1EAE3C00B34FC1 /* Configuration */ = { isa = PBXGroup; children = ( @@ -5195,6 +5356,7 @@ 8406FD2E2AF1820700B09C1D /* Packet.hpp in Headers */, 8406FD2F2AF1820700B09C1D /* PingedCompatibleServer.hpp in Headers */, 8406FD302AF1820700B09C1D /* RakNetInstance.hpp in Headers */, + 84CCBC982E61886800E251AF /* RakIO.hpp in Headers */, 8406FD312AF1820700B09C1D /* ServerSideNetworkHandler.hpp in Headers */, 8470AF312BE9B62600BCA54E /* PacketUtil.hpp in Headers */, ); @@ -5455,6 +5617,7 @@ 84BF63C82AF186C9008A9995 /* SandStoneTile.hpp in Headers */, 84BF63C92AF186C9008A9995 /* SandTile.hpp in Headers */, 84BF63CA2AF186C9008A9995 /* Sapling.hpp in Headers */, + 84CCBC942E61880600E251AF /* EntityFactory.hpp in Headers */, 84BF63CB2AF186C9008A9995 /* SpongeTile.hpp in Headers */, 84BF63CC2AF186C9008A9995 /* StairTile.hpp in Headers */, 84BF63CD2AF186C9008A9995 /* StoneSlabTile.hpp in Headers */, @@ -5493,6 +5656,28 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 84CCBC432E61849800E251AF /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 84CCBC802E61857800E251AF /* Int8ArrayTag.hpp in Headers */, + 84CCBC7A2E61857800E251AF /* Int32Tag.hpp in Headers */, + 84CCBC782E61857800E251AF /* Int32ArrayTag.hpp in Headers */, + 84CCBC742E61857800E251AF /* FloatTag.hpp in Headers */, + 84CCBC882E61857800E251AF /* StringTag.hpp in Headers */, + 84CCBC702E61857800E251AF /* DoubleTag.hpp in Headers */, + 84CCBC6E2E61857800E251AF /* CompoundTag.hpp in Headers */, + 84CCBC862E61857800E251AF /* NbtIo.hpp in Headers */, + 84CCBC722E61857800E251AF /* EndTag.hpp in Headers */, + 84CCBC762E61857800E251AF /* Int16Tag.hpp in Headers */, + 84CCBC822E61857800E251AF /* Int8Tag.hpp in Headers */, + 84CCBC842E61857800E251AF /* ListTag.hpp in Headers */, + 84CCBC8A2E61857800E251AF /* Tag.hpp in Headers */, + 84CCBC7E2E61857800E251AF /* Int64Tag.hpp in Headers */, + 84CCBC7C2E61857800E251AF /* Int64ArrayTag.hpp in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 84E4BFAA2AE9854B0023E16A /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; @@ -5503,6 +5688,7 @@ 8406FD362AF1823600B09C1D /* Mth.hpp in Headers */, 8406FD372AF1823600B09C1D /* Random.hpp in Headers */, 8406FD392AF1823700B09C1D /* Timer.hpp in Headers */, + 84CCBC402E6183F300E251AF /* DataIO.hpp in Headers */, 8406FD3A2AF1823700B09C1D /* Util.hpp in Headers */, 8406FD3B2AF1823700B09C1D /* Utils.hpp in Headers */, 84E001B92AF3A3CB009B9555 /* SmoothFloat.hpp in Headers */, @@ -5704,6 +5890,8 @@ buildRules = ( ); dependencies = ( + 84CCBC902E6186D000E251AF /* PBXTargetDependency */, + 84CCBC8E2E6186CD00E251AF /* PBXTargetDependency */, 842610812AE9898E0065905F /* PBXTargetDependency */, ); name = Network; @@ -5820,12 +6008,31 @@ buildRules = ( ); dependencies = ( + 84CCBC8C2E61861900E251AF /* PBXTargetDependency */, ); name = World; productName = World; productReference = 84BF630B2AF1859D008A9995 /* libWorld.a */; productType = "com.apple.product-type.library.static"; }; + 84CCBC442E61849800E251AF /* NBT */ = { + isa = PBXNativeTarget; + buildConfigurationList = 84CCBC462E61849800E251AF /* Build configuration list for PBXNativeTarget "NBT" */; + buildPhases = ( + 84CCBC412E61849800E251AF /* Sources */, + 84CCBC422E61849800E251AF /* Frameworks */, + 84CCBC432E61849800E251AF /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + 84CCBC9C2E618BEB00E251AF /* PBXTargetDependency */, + ); + name = NBT; + productName = NBT; + productReference = 84CCBC452E61849800E251AF /* libNBT.a */; + productType = "com.apple.product-type.library.static"; + }; 84E4BFAD2AE9854B0023E16A /* Common */ = { isa = PBXNativeTarget; buildConfigurationList = 84E4BFB42AE9854B0023E16A /* Build configuration list for PBXNativeTarget "Common" */; @@ -5907,6 +6114,7 @@ 84B8AE132AF188D8008DE93D /* Client */, 84AAF5972AF18B9500BD67F4 /* OpenGL */, 84498A762AF18C7A005EF5A5 /* ZLib */, + 84CCBC442E61849800E251AF /* NBT */, ); }; /* End PBXProject section */ @@ -6409,6 +6617,7 @@ 8426107E2AE989730065905F /* RakNetInstance.cpp in Sources */, 8426107F2AE989730065905F /* ServerSideNetworkHandler.cpp in Sources */, 8470AF302BE9B62600BCA54E /* PacketUtil.cpp in Sources */, + 84CCBC972E61886800E251AF /* RakIO.cpp in Sources */, 8470AF352BE9B63900BCA54E /* LoginStatusPacket.cpp in Sources */, 8470AF362BE9B63900BCA54E /* ReadyPacket.cpp in Sources */, 8470AF372BE9B63900BCA54E /* SetTimePacket.cpp in Sources */, @@ -6711,6 +6920,7 @@ 84BF63652AF18631008A9995 /* LiquidTileStatic.cpp in Sources */, 84BF63662AF18631008A9995 /* MetalTile.cpp in Sources */, 84BF63672AF18631008A9995 /* ObsidianTile.cpp in Sources */, + 84CCBC932E61880600E251AF /* EntityFactory.cpp in Sources */, 84BF63682AF18631008A9995 /* OreTile.cpp in Sources */, 84B1E0392E04FD7900ED000A /* Arrow.cpp in Sources */, 84BF63692AF18631008A9995 /* RedStoneOreTile.cpp in Sources */, @@ -6753,11 +6963,34 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 84CCBC412E61849800E251AF /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 84CCBC832E61857800E251AF /* ListTag.cpp in Sources */, + 84CCBC7D2E61857800E251AF /* Int64Tag.cpp in Sources */, + 84CCBC6D2E61857800E251AF /* CompoundTag.cpp in Sources */, + 84CCBC712E61857800E251AF /* EndTag.cpp in Sources */, + 84CCBC7B2E61857800E251AF /* Int64ArrayTag.cpp in Sources */, + 84CCBC792E61857800E251AF /* Int32Tag.cpp in Sources */, + 84CCBC7F2E61857800E251AF /* Int8ArrayTag.cpp in Sources */, + 84CCBC872E61857800E251AF /* StringTag.cpp in Sources */, + 84CCBC6F2E61857800E251AF /* DoubleTag.cpp in Sources */, + 84CCBC772E61857800E251AF /* Int32ArrayTag.cpp in Sources */, + 84CCBC852E61857800E251AF /* NbtIo.cpp in Sources */, + 84CCBC732E61857800E251AF /* FloatTag.cpp in Sources */, + 84CCBC892E61857800E251AF /* Tag.cpp in Sources */, + 84CCBC752E61857800E251AF /* Int16Tag.cpp in Sources */, + 84CCBC812E61857800E251AF /* Int8Tag.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 84E4BFAB2AE9854B0023E16A /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 84E4BFB52AE9869A0023E16A /* CThread.cpp in Sources */, + 84CCBC3F2E6183F300E251AF /* DataIO.cpp in Sources */, 84E4BFB62AE9869A0023E16A /* Logger.cpp in Sources */, 84E4BFB72AE9869A0023E16A /* Matrix.cpp in Sources */, 84E4BFB82AE9869A0023E16A /* Mth.cpp in Sources */, @@ -6959,6 +7192,26 @@ target = 84BF62FE2AF1859D008A9995 /* World */; targetProxy = 84BF63D62AF1876C008A9995 /* PBXContainerItemProxy */; }; + 84CCBC8C2E61861900E251AF /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 84CCBC442E61849800E251AF /* NBT */; + targetProxy = 84CCBC8B2E61861900E251AF /* PBXContainerItemProxy */; + }; + 84CCBC8E2E6186CD00E251AF /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 84E4BFAD2AE9854B0023E16A /* Common */; + targetProxy = 84CCBC8D2E6186CD00E251AF /* PBXContainerItemProxy */; + }; + 84CCBC902E6186D000E251AF /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 84BF62FE2AF1859D008A9995 /* World */; + targetProxy = 84CCBC8F2E6186D000E251AF /* PBXContainerItemProxy */; + }; + 84CCBC9C2E618BEB00E251AF /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 84E4BFAD2AE9854B0023E16A /* Common */; + targetProxy = 84CCBC9B2E618BEB00E251AF /* PBXContainerItemProxy */; + }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ @@ -8009,6 +8262,62 @@ }; name = "Release (x86-PPC)"; }; + 84CCBC472E61849800E251AF /* Debug (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Debug (Default)"; + }; + 84CCBC482E61849800E251AF /* Debug (iOS) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Debug (iOS)"; + }; + 84CCBC492E61849800E251AF /* Release (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Release (Default)"; + }; + 84CCBC4A2E61849800E251AF /* Release (iOS) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Release (iOS)"; + }; + 84CCBC4B2E61849800E251AF /* Release (x86) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Release (x86)"; + }; + 84CCBC4C2E61849800E251AF /* Release (PPC) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Release (PPC)"; + }; + 84CCBC4D2E61849800E251AF /* Release (x86-PPC) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Release (x86-PPC)"; + }; 84E4BFAF2AE9854B0023E16A /* Debug (Default) */ = { isa = XCBuildConfiguration; buildSettings = { @@ -8218,6 +8527,20 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = "Release (Default)"; }; + 84CCBC462E61849800E251AF /* Build configuration list for PBXNativeTarget "NBT" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 84CCBC472E61849800E251AF /* Debug (Default) */, + 84CCBC482E61849800E251AF /* Debug (iOS) */, + 84CCBC492E61849800E251AF /* Release (Default) */, + 84CCBC4A2E61849800E251AF /* Release (iOS) */, + 84CCBC4B2E61849800E251AF /* Release (x86) */, + 84CCBC4C2E61849800E251AF /* Release (PPC) */, + 84CCBC4D2E61849800E251AF /* Release (x86-PPC) */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = "Release (Default)"; + }; 84E4BFB42AE9854B0023E16A /* Build configuration list for PBXNativeTarget "Common" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/platforms/sdl/CMakeLists.txt b/platforms/sdl/CMakeLists.txt index 1d2e84112..14cd3bf4a 100644 --- a/platforms/sdl/CMakeLists.txt +++ b/platforms/sdl/CMakeLists.txt @@ -60,7 +60,7 @@ if(ANDROID) target_compile_definitions(reminecraftpe-core PUBLIC USE_GLES) else() find_package(OpenGL REQUIRED) - target_link_libraries(reminecraftpe-core PUBLIC OpenGL::GL) + target_link_libraries(reminecraftpe-core PUBLIC ${OPENGL_gl_LIBRARY}) if(EMSCRIPTEN) # Use WebGL 2 target_link_options(reminecraftpe-core PUBLIC diff --git a/platforms/windows/minecraftcpp.sln b/platforms/windows/minecraftcpp.sln index 2fa8f435f..5f8744339 100644 --- a/platforms/windows/minecraftcpp.sln +++ b/platforms/windows/minecraftcpp.sln @@ -1,6 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio Version 17 +# Visual Studio Version 10 VisualStudioVersion = 17.6.33723.286 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZLib", "projects\ZLib\ZLib.vcxproj", "{5DA292FD-FA40-45D8-900A-6652C9662913}" @@ -29,6 +29,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenGL", "projects\OpenGL\O EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "STB", "projects\STB\STB.vcxproj", "{F332CB57-FF16-4D43-BBE0-76F28301DAA8}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NBT", "projects\NBT\NBT.vcxproj", "{B01E1536-505B-4357-B5B6-083EFBF786B0}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug_SDL2|x64 = Debug_SDL2|x64 @@ -221,6 +223,22 @@ Global {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Release|x64.Build.0 = Release|x64 {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Release|x86.ActiveCfg = Release|Win32 {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Release|x86.Build.0 = Release|Win32 + {B01E1536-505B-4357-B5B6-083EFBF786B0}.Debug_SDL2|x64.ActiveCfg = Debug|x64 + {B01E1536-505B-4357-B5B6-083EFBF786B0}.Debug_SDL2|x64.Build.0 = Debug|x64 + {B01E1536-505B-4357-B5B6-083EFBF786B0}.Debug_SDL2|x86.ActiveCfg = Debug|Win32 + {B01E1536-505B-4357-B5B6-083EFBF786B0}.Debug_SDL2|x86.Build.0 = Debug|Win32 + {B01E1536-505B-4357-B5B6-083EFBF786B0}.Debug|x64.ActiveCfg = Debug|x64 + {B01E1536-505B-4357-B5B6-083EFBF786B0}.Debug|x64.Build.0 = Debug|x64 + {B01E1536-505B-4357-B5B6-083EFBF786B0}.Debug|x86.ActiveCfg = Debug|Win32 + {B01E1536-505B-4357-B5B6-083EFBF786B0}.Debug|x86.Build.0 = Debug|Win32 + {B01E1536-505B-4357-B5B6-083EFBF786B0}.Release_SDL2|x64.ActiveCfg = Release|x64 + {B01E1536-505B-4357-B5B6-083EFBF786B0}.Release_SDL2|x64.Build.0 = Release|x64 + {B01E1536-505B-4357-B5B6-083EFBF786B0}.Release_SDL2|x86.ActiveCfg = Release|Win32 + {B01E1536-505B-4357-B5B6-083EFBF786B0}.Release_SDL2|x86.Build.0 = Release|Win32 + {B01E1536-505B-4357-B5B6-083EFBF786B0}.Release|x64.ActiveCfg = Release|x64 + {B01E1536-505B-4357-B5B6-083EFBF786B0}.Release|x64.Build.0 = Release|x64 + {B01E1536-505B-4357-B5B6-083EFBF786B0}.Release|x86.ActiveCfg = Release|Win32 + {B01E1536-505B-4357-B5B6-083EFBF786B0}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/platforms/windows/projects/Common/Common.vcxproj b/platforms/windows/projects/Common/Common.vcxproj index fc5f56315..c28c88616 100644 --- a/platforms/windows/projects/Common/Common.vcxproj +++ b/platforms/windows/projects/Common/Common.vcxproj @@ -1,4 +1,4 @@ - + @@ -66,7 +66,7 @@ - + @@ -78,6 +78,10 @@ + + + + diff --git a/platforms/windows/projects/Common/Common.vcxproj.filters b/platforms/windows/projects/Common/Common.vcxproj.filters index d3b9f577c..3ce5c7017 100644 --- a/platforms/windows/projects/Common/Common.vcxproj.filters +++ b/platforms/windows/projects/Common/Common.vcxproj.filters @@ -38,8 +38,8 @@ Source Files - - Header Files + + Source Files @@ -70,5 +70,17 @@ Header Files + + Header Files + + + Header Files + + + Header Files + + + Header Files + \ No newline at end of file diff --git a/platforms/windows/projects/NBT/NBT.vcxproj b/platforms/windows/projects/NBT/NBT.vcxproj new file mode 100644 index 000000000..1baa9e3ed --- /dev/null +++ b/platforms/windows/projects/NBT/NBT.vcxproj @@ -0,0 +1,75 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {b01e1536-505b-4357-b5b6-083efbf786b0} + NBT + StaticLibrary + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/platforms/windows/projects/NBT/NBT.vcxproj.filters b/platforms/windows/projects/NBT/NBT.vcxproj.filters new file mode 100644 index 000000000..5e79926ff --- /dev/null +++ b/platforms/windows/projects/NBT/NBT.vcxproj.filters @@ -0,0 +1,107 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/platforms/windows/projects/Network/Network.vcxproj b/platforms/windows/projects/Network/Network.vcxproj index e08985252..6b8f22a50 100644 --- a/platforms/windows/projects/Network/Network.vcxproj +++ b/platforms/windows/projects/Network/Network.vcxproj @@ -1,4 +1,4 @@ - + @@ -23,7 +23,7 @@ Win32Proj {e43f7c6a-a099-48c9-9d37-b56cd8d6d785} Network - StaticLibrary + StaticLibrary @@ -57,6 +57,7 @@ + @@ -66,6 +67,7 @@ + diff --git a/platforms/windows/projects/Network/Network.vcxproj.filters b/platforms/windows/projects/Network/Network.vcxproj.filters index 6fe053fe9..ec17cfc0a 100644 --- a/platforms/windows/projects/Network/Network.vcxproj.filters +++ b/platforms/windows/projects/Network/Network.vcxproj.filters @@ -35,6 +35,9 @@ Header Files + + Header Files + @@ -100,5 +103,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/platforms/windows/projects/World/World.vcxproj b/platforms/windows/projects/World/World.vcxproj index 008dc0943..1266c8fc8 100644 --- a/platforms/windows/projects/World/World.vcxproj +++ b/platforms/windows/projects/World/World.vcxproj @@ -176,6 +176,7 @@ + @@ -304,6 +305,12 @@ + + + + + {b01e1536-505b-4357-b5b6-083efbf786b0} + diff --git a/platforms/windows/projects/World/World.vcxproj.filters b/platforms/windows/projects/World/World.vcxproj.filters index a4ac35b23..e32476167 100644 --- a/platforms/windows/projects/World/World.vcxproj.filters +++ b/platforms/windows/projects/World/World.vcxproj.filters @@ -515,6 +515,9 @@ Source Files\Entity + + Source Files\Entity + @@ -895,5 +898,8 @@ Header Files\Entity + + Header Files\Entity + \ No newline at end of file diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index dc4ab10cc..d8c9ad044 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -3,15 +3,16 @@ project(reminecraftpe-core) # Build add_library(reminecraftpe-core STATIC - common/Random.cpp - common/Utils.cpp + common/CThread.cpp + common/DataIO.cpp + common/Logger.cpp common/Matrix.cpp common/Mth.cpp + common/Random.cpp + common/SmoothFloat.cpp common/Timer.cpp - common/CThread.cpp common/Util.cpp - common/Logger.cpp - common/SmoothFloat.cpp + common/Utils.cpp client/app/App.cpp client/app/AppPlatform.cpp client/app/Minecraft.cpp @@ -137,6 +138,21 @@ add_library(reminecraftpe-core STATIC client/player/input/TouchscreenInput_TestFps.cpp client/player/input/UnifiedTurnBuild.cpp client/network/ClientSideNetworkHandler.cpp + nbt/CompoundTag.cpp + nbt/DoubleTag.cpp + nbt/EndTag.cpp + nbt/FloatTag.cpp + nbt/Int8ArrayTag.cpp + nbt/Int8Tag.cpp + nbt/Int16Tag.cpp + nbt/Int32ArrayTag.cpp + nbt/Int32Tag.cpp + nbt/Int64ArrayTag.cpp + nbt/Int64Tag.cpp + nbt/ListTag.cpp + nbt/NbtIo.cpp + nbt/StringTag.cpp + nbt/Tag.cpp network/packets/UpdateBlockPacket.cpp network/packets/RequestChunkPacket.cpp network/packets/PlayerEquipmentPacket.cpp @@ -154,6 +170,7 @@ add_library(reminecraftpe-core STATIC network/packets/MovePlayerPacket.cpp network/packets/MessagePacket.cpp network/ServerSideNetworkHandler.cpp + network/RakIO.cpp network/RakNetInstance.cpp network/MinecraftPackets.cpp network/NetEventCallback.cpp @@ -189,6 +206,7 @@ add_library(reminecraftpe-core STATIC world/entity/WaterAnimal.cpp world/entity/Monster.cpp world/entity/Rocket.cpp + world/entity/EntityFactory.cpp world/entity/MobFactory.cpp world/entity/Chicken.cpp world/entity/Cow.cpp diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp index d8be0fcf8..05706f409 100644 --- a/source/client/app/Minecraft.cpp +++ b/source/client/app/Minecraft.cpp @@ -184,6 +184,12 @@ void Minecraft::setScreen(Screen* pScreen) releaseMouse(); // the ceil prevents under-drawing pScreen->init(this, ceil(width * Gui::InvGuiScale), ceil(height * Gui::InvGuiScale)); + + if (pScreen->isPauseScreen()) + { + if (m_pLevel && isLevelGenerated()) + return m_pLevel->saveGame(); + } } else { @@ -226,7 +232,7 @@ bool Minecraft::isOnlineClient() const if (!m_pLevel) return false; - return m_pLevel->m_bIsMultiplayer; + return m_pLevel->m_bIsOnline; } bool Minecraft::isTouchscreen() const @@ -466,7 +472,7 @@ void Minecraft::tickInput() { ItemInstance itemDrop = m_pLocalPlayer->isSurvival() ? item->remove(1) : ItemInstance(*item); itemDrop.m_count = 1; - m_pLocalPlayer->drop(&itemDrop); + m_pLocalPlayer->drop(itemDrop); } } else if (getOptions()->isKey(KM_TOGGLEGUI, keyCode)) @@ -691,7 +697,7 @@ void Minecraft::tick() if (m_pLevel && !isGamePaused()) { m_pLevel->m_difficulty = m_options->m_difficulty; - if (m_pLevel->m_bIsMultiplayer) + if (m_pLevel->m_bIsOnline) { m_pLevel->m_difficulty = 3; } @@ -937,10 +943,12 @@ void Minecraft::prepareLevel(const std::string& unused) m_pLevel->setInitialSpawn(); m_pLevel->saveLevelData(); m_pLevel->getChunkSource()->saveAll(); + m_pLevel->saveGame(); } else { m_pLevel->saveLevelData(); + m_pLevel->loadEntities(); } m_progressPercent = -1; @@ -1054,13 +1062,12 @@ void Minecraft::generateLevel(const std::string& unused, Level* pLevel) m_pGameMode->adjustPlayer(m_pLocalPlayer); - pLevel->validateSpawn(); - pLevel->loadPlayer(m_pLocalPlayer); - + // was after loadPlayer for some reason if (m_pLocalPlayer) - { m_pLocalPlayer->resetPos(); - } + + pLevel->validateSpawn(); + pLevel->loadPlayer(*m_pLocalPlayer); m_pMobPersp = m_pLocalPlayer; m_pLevel = pLevel; @@ -1138,12 +1145,12 @@ void Minecraft::setLevel(Level* pLevel, const std::string& text, LocalPlayer* pL } } -void Minecraft::selectLevel(const std::string& a, const std::string& b, int c) +void Minecraft::selectLevel(const std::string& levelDir, const std::string& levelName, int c) { - LevelStorage* pStor = m_pLevelStorageSource->selectLevel(a, false); + LevelStorage* pStor = m_pLevelStorageSource->selectLevel(levelDir, false); Dimension* pDim = Dimension::getNew(0); - m_pLevel = new Level(pStor, b, c, 1, pDim); + m_pLevel = new Level(pStor, levelName, c, LEVEL_STORAGE_VERSION_DEFAULT, pDim); setLevel(m_pLevel, "Generating level", nullptr); field_D9C = 1; diff --git a/source/client/gui/components/RolledSelectionList.cpp b/source/client/gui/components/RolledSelectionList.cpp index 96bc3e3d6..729111c54 100644 --- a/source/client/gui/components/RolledSelectionList.cpp +++ b/source/client/gui/components/RolledSelectionList.cpp @@ -202,7 +202,7 @@ void RolledSelectionList::render(int mouseX, int mouseY, float f) float right = itemX + width; float up = float(field_1C) / 2.0f - 48.0f - 4.0f; - float dn = float(field_1C) / 2.0f + 48.0f - 4.0f; + float dn = float(field_1C) / 2.0f + 56.0f - 4.0f; t.vertexUV(itemX - 2, up, 0.0f, 0.0f, 0.0f); t.vertexUV(itemX - 2, dn, 0.0f, 1.0f, 0.0f); diff --git a/source/client/gui/components/RolledSelectionList.hpp b/source/client/gui/components/RolledSelectionList.hpp index e830f9483..031eb860a 100644 --- a/source/client/gui/components/RolledSelectionList.hpp +++ b/source/client/gui/components/RolledSelectionList.hpp @@ -11,6 +11,7 @@ #include "../GuiComponent.hpp" #include "client/app/Minecraft.hpp" +// @TODO: Renamed to RolledSelectionListH in 0.2.1 class RolledSelectionList : public GuiComponent { public: diff --git a/source/client/gui/components/WorldSelectionList.cpp b/source/client/gui/components/WorldSelectionList.cpp index ad2b445ce..307c5f350 100644 --- a/source/client/gui/components/WorldSelectionList.cpp +++ b/source/client/gui/components/WorldSelectionList.cpp @@ -145,9 +145,13 @@ void WorldSelectionList::renderItem(int index, int xPos, int yPos, int width, Te std::vector details = m_vvs[index]; + // Draw name drawString(m_pMinecraft->m_pFont, details[0], xCenter + 5 - m_itemWidth / 2, yPos + 50, color1); - drawString(m_pMinecraft->m_pFont, details[1], xCenter + 5 - m_itemWidth / 2, yPos + 60, color2); - drawString(m_pMinecraft->m_pFont, details[2], xCenter + 5 - m_itemWidth / 2, yPos + 70, color2); + // Draw other details + for (unsigned int i = 1; i < details.size(); i++) + { + drawString(m_pMinecraft->m_pFont, details[i], xCenter + 5 - m_itemWidth / 2, yPos + (50 + (10 * i)), color2); + } m_pMinecraft->m_pTextures->loadAndBindTexture(m_previewImages[index]); @@ -176,8 +180,8 @@ void WorldSelectionList::commit() // @NOTE: this string stream crap is unused. // Weirdly Java Edition Beta 1.3 did not have world previews, so its interesting to see PE try - std::stringstream ss; - ss << item.m_levelName << "/preview.png"; + /*std::stringstream ss; + ss << item.m_levelName << "/preview.png";*/ m_previewImages.push_back("gui/default_world.png"); @@ -185,6 +189,7 @@ void WorldSelectionList::commit() vs.push_back(item.m_levelName); vs.push_back(m_pMinecraft->platform()->getDateString(item.m_lastPlayed)); vs.push_back(item.m_fileName); + vs.push_back(GameTypeConv::GameTypeToNonLocString(item.m_gameType)); m_vvs.push_back(vs); } } diff --git a/source/client/gui/screens/CreateWorldScreen.cpp b/source/client/gui/screens/CreateWorldScreen.cpp index adf20c9a8..79c4a2c00 100644 --- a/source/client/gui/screens/CreateWorldScreen.cpp +++ b/source/client/gui/screens/CreateWorldScreen.cpp @@ -66,18 +66,25 @@ static std::string GetUniqueLevelName(LevelStorageSource* pSource, const std::st { std::set maps; - std::vector vls; - pSource->getLevelList(vls); + std::vector summaries; + pSource->getLevelList(summaries); - for (int i = 0; i < int(vls.size()); i++) + for (std::vector::const_iterator it = summaries.begin(); it != summaries.end(); it++) { - const LevelSummary& ls = vls[i]; - maps.insert(ls.m_fileName); + maps.insert(it->m_fileName); } std::string out = in; + //unsigned int generationId = 0; while (maps.find(out) != maps.end()) + { + // Custom duplicate naming scheme, so the world name matches the folder name + /*generationId++; + out = in + "" + Util::format("(%d)", generationId);*/ + + // Java/PE default out += "-"; + } return out; } diff --git a/source/client/gui/screens/IngameBlockSelectionScreen.cpp b/source/client/gui/screens/IngameBlockSelectionScreen.cpp index 1d22a4ef2..65881fafb 100644 --- a/source/client/gui/screens/IngameBlockSelectionScreen.cpp +++ b/source/client/gui/screens/IngameBlockSelectionScreen.cpp @@ -85,7 +85,8 @@ void IngameBlockSelectionScreen::init() for (int i = 0; i < nItems; i++) { - if (pInv->getItem(i)->m_itemID == pInv->getSelectedItemId()) + ItemInstance* item = pInv->getItem(i); + if (item && item->m_itemID == pInv->getSelectedItemId()) { m_selectedSlot = i; break; diff --git a/source/client/gui/screens/SelectWorldScreen.cpp b/source/client/gui/screens/SelectWorldScreen.cpp index d27229686..2be55b6d5 100644 --- a/source/client/gui/screens/SelectWorldScreen.cpp +++ b/source/client/gui/screens/SelectWorldScreen.cpp @@ -152,9 +152,9 @@ void SelectWorldScreen::tick() } // the level summary stuff is unused. - LevelSummary ls; + /*LevelSummary ls; if (isIndexValid(m_pWorldSelectionList->m_selectedIndex)) - ls = m_pWorldSelectionList->m_items[m_pWorldSelectionList->m_selectedIndex]; + ls = m_pWorldSelectionList->m_items[m_pWorldSelectionList->m_selectedIndex];*/ m_btnDelete.m_bEnabled = isIndexValid(m_pWorldSelectionList->m_selectedIndex); } diff --git a/source/client/network/ClientSideNetworkHandler.cpp b/source/client/network/ClientSideNetworkHandler.cpp index 3dedf6378..d6c64b76e 100644 --- a/source/client/network/ClientSideNetworkHandler.cpp +++ b/source/client/network/ClientSideNetworkHandler.cpp @@ -83,7 +83,7 @@ void ClientSideNetworkHandler::onDisconnect(const RakNet::RakNetGUID& rakGuid) puts_ignorable("onDisconnect"); if (m_pLevel) - m_pLevel->m_bIsMultiplayer = false; + m_pLevel->m_bIsOnline = false; m_pMinecraft->m_gui.addMessage("Disconnected from server"); } @@ -130,7 +130,7 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, StartGa pStartGamePkt->m_seed, pStartGamePkt->m_levelVersion); - m_pLevel->m_bIsMultiplayer = true; + m_pLevel->m_bIsOnline = true; GameType gameType = pStartGamePkt->m_gameType != GAME_TYPES_MAX ? pStartGamePkt->m_gameType : m_pLevel->getDefaultGameType(); LocalPlayer *pLocalPlayer = new LocalPlayer(m_pMinecraft, m_pLevel, m_pMinecraft->m_pUser, gameType, m_pLevel->m_pDimension->field_50); diff --git a/source/client/player/input/IArea.hpp b/source/client/player/input/IArea.hpp index 58d94af8e..ec2dc9b9b 100644 --- a/source/client/player/input/IArea.hpp +++ b/source/client/player/input/IArea.hpp @@ -8,7 +8,7 @@ #pragma once -#include "compat/LegacyCPPCompatibility.hpp" +#include "compat/LegacyCPP.hpp" class IArea { diff --git a/source/client/player/input/IMoveInput.hpp b/source/client/player/input/IMoveInput.hpp index 8ec7ebff1..9efeea9e2 100644 --- a/source/client/player/input/IMoveInput.hpp +++ b/source/client/player/input/IMoveInput.hpp @@ -8,7 +8,7 @@ #pragma once -#include "compat/LegacyCPPCompatibility.hpp" +#include "compat/LegacyCPP.hpp" class Player; diff --git a/source/client/player/input/ITurnInput.hpp b/source/client/player/input/ITurnInput.hpp index 0ac4a0d70..529c0c0d1 100644 --- a/source/client/player/input/ITurnInput.hpp +++ b/source/client/player/input/ITurnInput.hpp @@ -8,7 +8,7 @@ #pragma once -#include "compat/LegacyCPPCompatibility.hpp" +#include "compat/LegacyCPP.hpp" struct TurnDelta { diff --git a/source/client/player/input/MouseHandler.cpp b/source/client/player/input/MouseHandler.cpp index 511221a29..6caed8acc 100644 --- a/source/client/player/input/MouseHandler.cpp +++ b/source/client/player/input/MouseHandler.cpp @@ -1,6 +1,6 @@ #include "MouseHandler.hpp" -#include "compat/LegacyCPPCompatibility.hpp" +#include "compat/LegacyCPP.hpp" MouseHandler::MouseHandler() : m_pTurnInput(nullptr) diff --git a/source/client/renderer/GameRenderer.cpp b/source/client/renderer/GameRenderer.cpp index 9cbfffd81..b83481e28 100644 --- a/source/client/renderer/GameRenderer.cpp +++ b/source/client/renderer/GameRenderer.cpp @@ -231,7 +231,7 @@ void GameRenderer::bobHurt(float f) Mob* pMob = m_pMinecraft->m_pMobPersp; if (pMob->m_health <= 0) - glRotatef(-8000.0f / (float(pMob->field_110) + f + 200.0f) + 40.0f, 0.0f, 0.0f, 1.0f); + glRotatef(-8000.0f / (float(pMob->m_deathTime) + f + 200.0f) + 40.0f, 0.0f, 0.0f, 1.0f); if (pMob->m_hurtTime > 0) { @@ -393,7 +393,7 @@ float GameRenderer::getFov(float f) if (pMob->m_health <= 0) { - float x2 = 1.0f + (-500.0f / ((pMob->field_110 + f) + 500.0f)); + float x2 = 1.0f + (-500.0f / ((pMob->m_deathTime + f) + 500.0f)); x1 /= (1.0f + 2.0f * x2); } diff --git a/source/client/renderer/entity/EntityRenderDispatcher.cpp b/source/client/renderer/entity/EntityRenderDispatcher.cpp index 740319d52..e2b83f0f5 100644 --- a/source/client/renderer/entity/EntityRenderDispatcher.cpp +++ b/source/client/renderer/entity/EntityRenderDispatcher.cpp @@ -165,18 +165,22 @@ void EntityRenderDispatcher::render(Entity* entity, const Vec3& pos, float rot, { EntityRenderer* pRenderer = getRenderer(entity); - if (pRenderer) + if (!pRenderer) { + //LOG_E("Failed to fetch renderer for entity: %s", entity->getDescriptor().getEntityType().getName()); + assert(!"Failed to fetch renderer for an entity"); + return; + } + #ifndef ORIGINAL_CODE - if (pRenderer == &m_HumanoidMobRenderer) - m_HumanoidMobRenderer.m_pHumanoidModel->m_bSneaking = entity->isSneaking(); - else - m_HumanoidMobRenderer.m_pHumanoidModel->m_bSneaking = false; + if (pRenderer == &m_HumanoidMobRenderer) + m_HumanoidMobRenderer.m_pHumanoidModel->m_bSneaking = entity->isSneaking(); + else + m_HumanoidMobRenderer.m_pHumanoidModel->m_bSneaking = false; #endif - pRenderer->render(entity, pos.x, pos.y, pos.z, rot, a); - pRenderer->postRender(entity, pos, rot, a); - } + pRenderer->render(entity, pos.x, pos.y, pos.z, rot, a); + pRenderer->postRender(entity, pos, rot, a); } void EntityRenderDispatcher::setLevel(Level* level) diff --git a/source/client/renderer/entity/ItemRenderer.cpp b/source/client/renderer/entity/ItemRenderer.cpp index 67ebd9c12..ff4c1efbd 100644 --- a/source/client/renderer/entity/ItemRenderer.cpp +++ b/source/client/renderer/entity/ItemRenderer.cpp @@ -40,8 +40,13 @@ void ItemRenderer::render(Entity* pEntity, float x, float y, float z, float a, f ItemEntity* pItemEntity = (ItemEntity*)pEntity; glPushMatrix(); - float yOffset = Mth::sin((float(pItemEntity->field_E0) + b) / 10.0f + pItemEntity->field_E8); - const ItemInstance* pItemInstance = &(pItemEntity->m_itemInstance); + float yOffset = Mth::sin((float(pItemEntity->m_age) + b) / 10.0f + pItemEntity->m_bobOffs); + const ItemInstance* pItemInstance = pItemEntity->m_pItemInstance; + if (!pItemInstance) + { + assert(pItemInstance != nullptr); + return; + } int itemsToRender = 1; if (pItemInstance->m_count > 1) @@ -57,7 +62,7 @@ void ItemRenderer::render(Entity* pEntity, float x, float y, float z, float a, f int itemID = pItemInstance->m_itemID; if (itemID < C_MAX_TILES && TileRenderer::canRender(Tile::tiles[itemID]->getRenderShape())) { - glRotatef(((float(pItemEntity->field_E0) + b) / 20.0f + pItemEntity->field_E8) * 57.296f, 0.0f, 1.0f, 0.0f); + glRotatef(((float(pItemEntity->m_age) + b) / 20.0f + pItemEntity->m_bobOffs) * 57.296f, 0.0f, 1.0f, 0.0f); bindTexture(C_TERRAIN_NAME); float scale = 0.5f; diff --git a/source/client/renderer/entity/MobRenderer.cpp b/source/client/renderer/entity/MobRenderer.cpp index 36cf254b5..4a14c6dae 100644 --- a/source/client/renderer/entity/MobRenderer.cpp +++ b/source/client/renderer/entity/MobRenderer.cpp @@ -68,9 +68,9 @@ void MobRenderer::setupRotations(Entity* entity, float x, float y, float z) glRotatef(180.0f - y, 0.0f, 1.0f, 0.0f); Mob* mob = (Mob*)entity; - if (mob->field_110 > 0) + if (mob->m_deathTime > 0) { - float t = Mth::sqrt((float(mob->field_110) + z - 1.0f) / 20.0f * 1.6f); + float t = Mth::sqrt((float(mob->m_deathTime) + z - 1.0f) / 20.0f * 1.6f); if (t > 1.0f) t = 1.0f; @@ -136,7 +136,7 @@ void MobRenderer::render(Entity* entity, float x, float y, float z, float unused float fBright = pMob->getBrightness(f); int iOverlayColor = getOverlayColor(pMob, fBright, f); - if (GET_ALPHA(iOverlayColor) || pMob->m_hurtTime > 0 || pMob->field_110 > 0) + if (GET_ALPHA(iOverlayColor) || pMob->m_hurtTime > 0 || pMob->m_deathTime > 0) { glDisable(GL_TEXTURE_2D); glDisable(GL_ALPHA_TEST); @@ -144,7 +144,7 @@ void MobRenderer::render(Entity* entity, float x, float y, float z, float unused glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDepthFunc(GL_EQUAL); - if (pMob->m_hurtTime > 0 || pMob->field_110 > 0) + if (pMob->m_hurtTime > 0 || pMob->m_deathTime > 0) { glColor4f(fBright, 0.0f, 0.0f, 0.4f); m_pModel->render(x2, x1, fBob, aYaw - fSmth, aPitch, fScale); // was 0.059375f. Why? diff --git a/source/common/DataIO.cpp b/source/common/DataIO.cpp new file mode 100644 index 000000000..bbc156519 --- /dev/null +++ b/source/common/DataIO.cpp @@ -0,0 +1,270 @@ +#include +#include + +#include "DataIO.hpp" + +#define STR16_MAX_LEN 32767 +#define STR32_MAX_LEN 2147483647 + +std::string IDataInput::_readString() +{ + int16_t size = readInt16(); + + if (size <= 0) + { + return "\0\0\0\0"; + } + + int16_t csize, cend; + if (size == STR16_MAX_LEN) + { + csize = STR16_MAX_LEN; + cend = STR16_MAX_LEN - 1; + size = cend; + } + else + { + csize = size + 1; + cend = size; + } + + char* cstr = new char[csize]; + readBytes(cstr, size); + + cstr[cend] = '\0'; + + std::string str = std::string(cstr); + + if (cstr) + delete[] cstr; + + return str; +} + +std::string IDataInput::_readLongString() +{ + // @NOTE: ugly copy-paste of _readString(), just with 32-bit ints instead of 16-bit + + int32_t size = readInt32(); + + if (size <= 0) + { + return "\0\0\0\0"; + } + + int32_t csize, cend; + if (size == STR32_MAX_LEN) + { + csize = STR32_MAX_LEN; + cend = STR32_MAX_LEN - 1; + size = cend; + } + else + { + csize = size + 1; + cend = size; + } + + char* cstr = new char[csize]; + readBytes(cstr, size); + + cstr[cend] = '\0'; + + std::string str = std::string(cstr); + + if (cstr) + delete[] cstr; + + return str; +} + +inline void IDataOutput::_writeString(const std::string& v) +{ + // Writing strings longer than this wont work. Hopefully we're not relying on it. + assert(v.length() <= STR16_MAX_LEN); + + int16_t len = v.length() & STR16_MAX_LEN; + writeInt16(len); + writeBytes((const void *)v.c_str(), len); +} + +inline void IDataOutput::_writeLongString(const std::string& v) +{ + // originally no assertion existed here, I guess Mojang assumed no string could possibly be larger than the 32-bit signed integer limit + assert(v.length() <= STR32_MAX_LEN); + + int32_t len = v.length(); + writeInt32(len); + writeBytes((const void *)v.c_str(), len); +} + +std::string BytesDataInput::readString() +{ + return _readString(); +} + +std::string BytesDataInput::readLongString() +{ + return _readLongString(); +} + +float BytesDataInput::readFloat() +{ + float v = 0.0f; + readBytes(&v, 4); + return v; +} + +double BytesDataInput::readDouble() +{ + double v = 0.0; + readBytes(&v, 8); + return v; +} + +int8_t BytesDataInput::readInt8() +{ + int8_t v = 0; + readBytes(&v, 1); + return v; +} + +int16_t BytesDataInput::readInt16() +{ + int16_t v = 0; + readBytes(&v, 2); + return v; +} + +int32_t BytesDataInput::readInt32() +{ + int32_t v = 0; + readBytes(&v, 4); + return v; +} + +int64_t BytesDataInput::readInt64() +{ + int64_t v = 0; + readBytes(&v, 8); + return v; +} + +void BytesDataOutput::writeString(const std::string& v) +{ + _writeString(v); +} + +void BytesDataOutput::writeLongString(const std::string& v) +{ + _writeLongString(v); +} + +void BytesDataOutput::writeFloat(float v) +{ + writeBytes(&v, 4); +} + +void BytesDataOutput::writeDouble(double v) +{ + writeBytes(&v, 8); +} + +void BytesDataOutput::writeInt8(int8_t v) +{ + writeBytes(&v, 1); +} + +void BytesDataOutput::writeInt16(int16_t v) +{ + writeBytes(&v, 2); +} + +void BytesDataOutput::writeInt32(int32_t v) +{ + writeBytes(&v, 4); +} + +void BytesDataOutput::writeInt64(int64_t v) +{ + writeBytes(&v, 8); +} + +unsigned int StringByteInput::numBytesLeft() const +{ + return m_buffer.length() - m_idx; +} + +bool StringByteInput::readBytes(void* data, unsigned int count) +{ + if (m_idx == m_buffer.length()) + return false; + unsigned int v7 = numBytesLeft(); + if (count < v7) + v7 = count; + memcpy(data, &m_buffer.c_str()[m_idx], v7); + m_idx += v7; + return true; +} + +void StringByteOutput::writeBytes(const void* data, unsigned int count) +{ + m_buffer->append((const char*)data, count); +} + +float BigEndianStringByteInput::readFloat() +{ + float v = 0.0f; + readBigEndianBytes(&v, 4); + return v; +} + +double BigEndianStringByteInput::readDouble() +{ + double v = 0.0; + readBigEndianBytes(&v, 8); + return v; +} + +int16_t BigEndianStringByteInput::readInt16() +{ + int16_t v = 0; + readBigEndianBytes(&v, 2); + return v; +} + +int32_t BigEndianStringByteInput::readInt32() +{ + int32_t v = 0; + readBigEndianBytes(&v, 4); + return v; +} + +int64_t BigEndianStringByteInput::readInt64() +{ + int64_t v = 0; + readBigEndianBytes(&v, 8); + return v; +} + +bool BigEndianStringByteInput::readBigEndianBytes(void* data, unsigned int count) +{ + if (!readBytes(data, count)) + return false; + + int8_t* buffer = (int8_t*)data; + + int8_t* v7 = &buffer[count - 1]; + if (!buffer || !v7) + return false; + + int8_t v8; + for (; buffer <= v7; v7--) + { + v8 = *buffer; + *buffer++ = *v7; + *v7 = v8; + } + + return true; +} \ No newline at end of file diff --git a/source/common/DataIO.hpp b/source/common/DataIO.hpp new file mode 100644 index 000000000..63261fba4 --- /dev/null +++ b/source/common/DataIO.hpp @@ -0,0 +1,119 @@ +#pragma once + +#include +#include + +#include "compat/LegacyCPP.hpp" + +class IDataInput +{ +protected: + std::string _readString(); + std::string _readLongString(); + +public: + bool hasBytesLeft(unsigned int bytes) const { return numBytesLeft() >= bytes; } + +public: + virtual std::string readString() = 0; + virtual std::string readLongString() = 0; + virtual float readFloat() = 0; + virtual double readDouble() = 0; + virtual int8_t readInt8() = 0; + virtual int16_t readInt16() = 0; + virtual int32_t readInt32() = 0; + virtual int64_t readInt64() = 0; + virtual bool readBytes(void* data, unsigned int count) = 0; + virtual unsigned int numBytesLeft() const = 0; + //virtual bool isOk() const = 0; + //virtual bool seek(uint64_t pos) = 0; +}; + +class IDataOutput +{ +protected: + void _writeString(const std::string& v); + void _writeLongString(const std::string& v); + +public: + virtual void writeString(const std::string& v) = 0; + virtual void writeLongString(const std::string& v) = 0; + virtual void writeFloat(float v) = 0; + virtual void writeDouble(double v) = 0; + virtual void writeInt8(int8_t v) = 0; + virtual void writeInt16(int16_t v) = 0; + virtual void writeInt32(int32_t v) = 0; + virtual void writeInt64(int64_t v) = 0; + virtual void writeBytes(const void* data, unsigned int count) = 0; + //virtual bool isOk() = 0; +}; + +class BytesDataInput : public IDataInput +{ +public: + std::string readString() override; + std::string readLongString() override; + float readFloat() override; + double readDouble() override; + int8_t readInt8() override; + int16_t readInt16() override; + int32_t readInt32() override; + int64_t readInt64() override; +}; + +class BytesDataOutput : public IDataOutput +{ +public: + void writeString(const std::string& v) override; + void writeLongString(const std::string& v) override; + void writeFloat(float v) override; + void writeDouble(double v) override; + void writeInt8(int8_t v) override; + void writeInt16(int16_t v) override; + void writeInt32(int32_t v) override; + void writeInt64(int64_t v) override; +}; + +class StringByteInput : public BytesDataInput +{ +public: + StringByteInput(const std::string& buffer) + : m_idx(0), m_buffer(buffer) + { }; + +public: + unsigned int numBytesLeft() const override; + bool readBytes(void* data, unsigned int count) override; + +public: + uint64_t m_idx; + std::string m_buffer; +}; + +class StringByteOutput : public BytesDataOutput +{ +public: + StringByteOutput(std::string* buffer) + : m_buffer(buffer) + { }; + +public: + void writeBytes(const void* data, unsigned int count) override; + +public: + std::string* m_buffer; +}; + +class BigEndianStringByteInput : public StringByteInput +{ +public: + BigEndianStringByteInput(const std::string& buffer) : StringByteInput(buffer) {} + +public: + float readFloat() override; + double readDouble() override; + int16_t readInt16() override; + int32_t readInt32() override; + int64_t readInt64() override; + virtual bool readBigEndianBytes(void* data, unsigned int count); +}; \ No newline at end of file diff --git a/source/common/Utils.hpp b/source/common/Utils.hpp index f0ae463d1..d6d4a96c4 100644 --- a/source/common/Utils.hpp +++ b/source/common/Utils.hpp @@ -26,7 +26,7 @@ #include #include -#include "compat/LegacyCPPCompatibility.hpp" +#include "compat/LegacyCPP.hpp" #ifdef _MSC_VER #pragma warning (disable : 4068) diff --git a/source/nbt/CompoundTag.cpp b/source/nbt/CompoundTag.cpp new file mode 100644 index 000000000..6b95857cd --- /dev/null +++ b/source/nbt/CompoundTag.cpp @@ -0,0 +1,328 @@ +#include +#include + +#include "CompoundTag.hpp" +#include "common/Util.hpp" + +CompoundTag::CompoundTag() +{ +} + +void CompoundTag::write(IDataOutput& dos) const +{ + for (std::map::const_iterator it = m_tags.begin(); it != m_tags.end(); it++) + { + writeNamedTag(it->first, *it->second, dos); + } + + dos.writeInt8(TAG_TYPE_END); +} + +void CompoundTag::load(IDataInput& dis) +{ + std::string name; + + while (true) + { + if (dis.numBytesLeft() == 0) + break; + + Tag* tag = readNamedTag(dis, name); + + if (!tag) + { + // We want this to shit itself when in debug mode so we know something's fucked + assert(!"Null tag returned in CompoundTag::read"); + break; + } + + if (tag->getId() == TAG_TYPE_END) + break; + + m_tags[name] = tag; + } +} + +void CompoundTag::put(const std::string& name, Tag* tag) +{ + // @TODO: is tag managed by something already? is it our job to deallocate it? no clue. + // for now, let's manage the memory, and just see what happens + if (!tag) + { + assert(!"Cannot store null tags"); + return; + } + + m_tags[name] = tag; +} + +void CompoundTag::putInt8(const std::string& name, int8_t value) +{ + put(name, new Int8Tag(value)); +} + +void CompoundTag::putInt16(const std::string& name, int16_t value) +{ + put(name, new Int16Tag(value)); +} + +void CompoundTag::putInt32(const std::string& name, int32_t value) +{ + put(name, new Int32Tag(value)); +} + +void CompoundTag::putInt64(const std::string& name, int64_t value) +{ + put(name, new Int64Tag(value)); +} + +void CompoundTag::putFloat(const std::string& name, float value) +{ + put(name, new FloatTag(value)); +} + +void CompoundTag::putDouble(const std::string& name, double value) +{ + put(name, new DoubleTag(value)); +} + +void CompoundTag::putString(const std::string& name, const std::string& value) +{ + put(name, new StringTag(value)); +} + +void CompoundTag::putInt8Array(const std::string& name, const TagMemoryChunk& mem) +{ + put(name, new Int8ArrayTag(mem)); +} + +void CompoundTag::putInt32Array(const std::string& name, const TagMemoryChunk& mem) +{ + put(name, new Int32ArrayTag(mem)); +} + +void CompoundTag::putInt64Array(const std::string& name, const TagMemoryChunk& mem) +{ + put(name, new Int64ArrayTag(mem)); +} + +void CompoundTag::putCompound(const std::string& name, CompoundTag* value) +{ + put(name, (Tag*)value); +} + +void CompoundTag::putBoolean(const std::string& name, bool value) +{ + putInt8(name, value); +} + +bool CompoundTag::contains(const std::string& name) const +{ + return m_tags.find(name) != m_tags.end(); +} + +bool CompoundTag::contains(const std::string& name, Tag::Type type) const +{ + // @TODO: inefficient, all get functions check this, then get the Tag for the second time + const Tag* tag = get(name); + return tag && tag->getId() == type; +} + +const Tag* CompoundTag::get(const std::string& name) const +{ + std::map::const_iterator it = m_tags.find(name); + if (it != m_tags.end()) return it->second; + return nullptr; +} + +Tag* CompoundTag::get(const std::string& name) +{ + std::map::iterator it = m_tags.find(name); + if (it != m_tags.end()) return it->second; + return nullptr; +} + +int8_t CompoundTag::getInt8(const std::string& name) const +{ + if (contains(name, TAG_TYPE_INT8)) + return ((const Int8Tag*)get(name))->m_data; + + return 0; +} + +int16_t CompoundTag::getInt16(const std::string& name) const +{ + if (contains(name, TAG_TYPE_INT16)) + return ((const Int16Tag*)get(name))->m_data; + + return 0; +} + +int32_t CompoundTag::getInt32(const std::string& name) const +{ + if (contains(name, TAG_TYPE_INT32)) + return ((const Int32Tag*)get(name))->m_data; + + return 0; +} + +int64_t CompoundTag::getInt64(const std::string& name) const +{ + if (contains(name, TAG_TYPE_INT64)) + return ((const Int64Tag*)get(name))->m_data; + + return 0; +} + +float CompoundTag::getFloat(const std::string& name) const +{ + if (contains(name, TAG_TYPE_FLOAT)) + return ((const FloatTag*)get(name))->m_data; + + return 0.0f; +} + +double CompoundTag::getDouble(const std::string& name) const +{ + if (contains(name, TAG_TYPE_DOUBLE)) + return ((const DoubleTag*)get(name))->m_data; + + return 0.0; +} + +const std::string& CompoundTag::getString(const std::string& name) const +{ + if (contains(name, TAG_TYPE_STRING)) + return ((const StringTag*)get(name))->m_data; + + return Util::EMPTY_STRING; +} + +const TagMemoryChunk* CompoundTag::getInt8Array(const std::string& name) const +{ + if (contains(name, TAG_TYPE_INT8_ARRAY)) + { + return &((const Int8ArrayTag*)get(name))->m_data; + } + + return nullptr; +} + +const TagMemoryChunk* CompoundTag::getInt32Array(const std::string& name) const +{ + if (contains(name, TAG_TYPE_INT32_ARRAY)) + { + return &((const Int32ArrayTag*)get(name))->m_data; + } + + return nullptr; +} + +const TagMemoryChunk* CompoundTag::getInt64Array(const std::string& name) const +{ + if (contains(name, TAG_TYPE_INT64_ARRAY)) + { + return &((const Int64ArrayTag*)get(name))->m_data; + } + + return nullptr; +} + +const CompoundTag* CompoundTag::getCompound(const std::string& name) const +{ + if (contains(name, TAG_TYPE_COMPOUND)) + { + return (const CompoundTag*)get(name); + } + + return nullptr; +} + +CompoundTag* CompoundTag::getCompound(const std::string& name) +{ + if (contains(name, TAG_TYPE_COMPOUND)) + { + return (CompoundTag*)get(name); + } + + return nullptr; +} + +const ListTag* CompoundTag::getList(const std::string& name) const +{ + if (contains(name, TAG_TYPE_LIST)) + { + return (const ListTag*)get(name); + } + + return nullptr; +} + +bool CompoundTag::getBoolean(const std::string& name) const +{ + return getInt8(name) != 0; +} + +std::string CompoundTag::toString() const +{ + std::ostringstream sstream; + sstream << m_tags.size() << " entries"; + return sstream.str(); +} + +CompoundTag* CompoundTag::copy() const +{ + return new CompoundTag(*this); +} + +CompoundTag CompoundTag::clone() +{ + return CompoundTag(*this); +} + +bool CompoundTag::remove(const std::string& name) +{ + std::map::iterator it = m_tags.find(name); + if (it == m_tags.end()) + return false; + + delete it->second; + m_tags.erase(it); + + return true; +} + +void CompoundTag::deleteChildren() +{ + for (std::map::iterator it = m_tags.begin(); it != m_tags.end(); it++) + { + delete it->second; + } + + m_tags.clear(); +} + +bool CompoundTag::operator==(const Tag& other) const +{ + const CompoundTag& other2 = (const CompoundTag&)(other); + if (getId() == other2.getId() && m_tags.size() == other2.m_tags.size()) + { + for (std::map::const_iterator it = m_tags.begin(); it != m_tags.end(); it++) + { + std::pair pair = *it, pair2; + std::map::const_iterator it2 = other2.m_tags.find(pair.first); + if (it2 == other2.m_tags.end()) + return false; // Failed to find tag in other by name + + pair2 = *it2; + Tag *tag = pair.second, *tag2 = pair2.second; + + if (tag != tag2) + return false; + } + + return true; + } + + return false; +} \ No newline at end of file diff --git a/source/nbt/CompoundTag.hpp b/source/nbt/CompoundTag.hpp new file mode 100644 index 000000000..7479a2a46 --- /dev/null +++ b/source/nbt/CompoundTag.hpp @@ -0,0 +1,78 @@ +#pragma once + +#include + +#include "Tag.hpp" +#include "Int8ArrayTag.hpp" +#include "Int32ArrayTag.hpp" +#include "Int64ArrayTag.hpp" +#include "ListTag.hpp" +#include "Int8Tag.hpp" +#include "Int32Tag.hpp" +#include "Int64Tag.hpp" +#include "Int16Tag.hpp" +#include "StringTag.hpp" +#include "FloatTag.hpp" +#include "DoubleTag.hpp" + +class CompoundTag : public Tag +{ +public: + CompoundTag(); + + Tag::Type getId() const override { return TAG_TYPE_COMPOUND; } + + void write(IDataOutput& dos) const override; + void load(IDataInput& dis) override; + + void put(const std::string& name, Tag* tag); + void putInt8(const std::string& name, int8_t value); + void putInt16(const std::string& name, int16_t value); + void putInt32(const std::string& name, int32_t value); + void putInt64(const std::string& name, int64_t value); + void putFloat(const std::string& name, float value); + void putDouble(const std::string& name, double value); + void putString(const std::string& name, const std::string& value); + void putInt8Array(const std::string& name, const TagMemoryChunk& mem); + void putInt32Array(const std::string& name, const TagMemoryChunk& mem); + void putInt64Array(const std::string& name, const TagMemoryChunk& mem); + void putCompound(const std::string& name, CompoundTag* value); + void putBoolean(const std::string& name, bool value); + + //void append(const CompoundTag& tag); // not in 0.12.1 + bool contains(const std::string& name) const; + bool contains(const std::string& name, Tag::Type type) const; + + const Tag* get(const std::string& name) const; + Tag* get(const std::string& name); + int8_t getInt8(const std::string& name) const; + int16_t getInt16(const std::string& name) const; + int32_t getInt32(const std::string& name) const; + int64_t getInt64(const std::string& name) const; + float getFloat(const std::string& name) const; + double getDouble(const std::string& name) const; + const std::string& getString(const std::string& name) const; + const TagMemoryChunk* getInt8Array(const std::string& name) const; + const TagMemoryChunk* getInt32Array(const std::string& name) const; + const TagMemoryChunk* getInt64Array(const std::string& name) const; + CompoundTag* getCompound(const std::string& name); + const CompoundTag* getCompound(const std::string& name) const; + const ListTag* getList(const std::string& name) const; + bool getBoolean(const std::string& name) const; + + std::string toString() const override; + CompoundTag* copy() const override; + CompoundTag clone(); + bool remove(const std::string& name); + void deleteChildren() override; + + bool isEmpty() const { return m_tags.empty(); } + std::map& rawView() { return m_tags; } + const std::map& rawView() const { return m_tags; } + + bool operator==(const Tag& other) const override; + bool operator!=(const Tag& other) const { return !(*this == other); } + +private: + std::map m_tags; +}; \ No newline at end of file diff --git a/source/nbt/DoubleTag.cpp b/source/nbt/DoubleTag.cpp new file mode 100644 index 000000000..784b625f4 --- /dev/null +++ b/source/nbt/DoubleTag.cpp @@ -0,0 +1,34 @@ +#include + +#include "DoubleTag.hpp" + +DoubleTag::DoubleTag() : m_data(0.0) {} +DoubleTag::DoubleTag(double val) : m_data(val) {} + +void DoubleTag::write(IDataOutput& dos) const +{ + dos.writeDouble(m_data); +} + +void DoubleTag::load(IDataInput& dis) +{ + m_data = dis.readDouble(); +} + +std::string DoubleTag::toString() const +{ + std::ostringstream sstream; + sstream << m_data; + return sstream.str(); +} + +Tag* DoubleTag::copy() const +{ + return new DoubleTag(m_data); +} + +bool DoubleTag::operator==(const Tag& other) const +{ + const DoubleTag& other2 = (const DoubleTag&)(other); + return getId() == other2.getId() && m_data == other2.m_data; +} \ No newline at end of file diff --git a/source/nbt/DoubleTag.hpp b/source/nbt/DoubleTag.hpp new file mode 100644 index 000000000..89d0e046d --- /dev/null +++ b/source/nbt/DoubleTag.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include + +#include "Tag.hpp" + +class DoubleTag : public Tag +{ +public: + DoubleTag(); + DoubleTag(double val); + +public: + Tag::Type getId() const override { return TAG_TYPE_DOUBLE; } + + void write(IDataOutput& dos) const override; + void load(IDataInput& dis) override; + + std::string toString() const override; + Tag* copy() const override; + + bool operator==(const Tag& other) const override; + +public: + double m_data; +}; diff --git a/source/nbt/EndTag.cpp b/source/nbt/EndTag.cpp new file mode 100644 index 000000000..235291b9e --- /dev/null +++ b/source/nbt/EndTag.cpp @@ -0,0 +1,21 @@ +#include "Tag.hpp" +#include "EndTag.hpp" + +EndTag::EndTag() +{ +} + +std::string EndTag::toString() const +{ + return "END"; +} + +Tag* EndTag::copy() const +{ + return new EndTag(); +} + +bool EndTag::operator==(const Tag& other) const +{ + return getId() == other.getId(); +} \ No newline at end of file diff --git a/source/nbt/EndTag.hpp b/source/nbt/EndTag.hpp new file mode 100644 index 000000000..2d7eb152f --- /dev/null +++ b/source/nbt/EndTag.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include "Tag.hpp" + +class EndTag : public Tag +{ +public: + EndTag(); + +public: + Tag::Type getId() const override { return TAG_TYPE_END; } + + void write(IDataOutput& dos) const override {}; + void load(IDataInput& dis) override {}; + + std::string toString() const override; + Tag* copy() const override; + + bool operator==(const Tag& other) const override; +}; \ No newline at end of file diff --git a/source/nbt/FloatTag.cpp b/source/nbt/FloatTag.cpp new file mode 100644 index 000000000..733e586a7 --- /dev/null +++ b/source/nbt/FloatTag.cpp @@ -0,0 +1,34 @@ +#include + +#include "FloatTag.hpp" + +FloatTag::FloatTag() : m_data(0.0f) {} +FloatTag::FloatTag(float val) : m_data(val) {} + +void FloatTag::write(IDataOutput& dos) const +{ + dos.writeFloat(m_data); +} + +void FloatTag::load(IDataInput& dis) +{ + m_data = dis.readFloat(); +} + +std::string FloatTag::toString() const +{ + std::ostringstream sstream; + sstream << m_data; + return sstream.str(); +} + +Tag* FloatTag::copy() const +{ + return new FloatTag(m_data); +} + +bool FloatTag::operator==(const Tag& other) const +{ + const FloatTag& other2 = (const FloatTag&)(other); + return getId() == other2.getId() && m_data == other2.m_data; +} \ No newline at end of file diff --git a/source/nbt/FloatTag.hpp b/source/nbt/FloatTag.hpp new file mode 100644 index 000000000..200acfba5 --- /dev/null +++ b/source/nbt/FloatTag.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include "Tag.hpp" + +class FloatTag : public Tag +{ +public: + FloatTag(); + FloatTag(float val); + +public: + Tag::Type getId() const override { return TAG_TYPE_FLOAT; } + + void write(IDataOutput& dos) const override; + void load(IDataInput& dis) override; + + std::string toString() const override; + Tag* copy() const override; + + bool operator==(const Tag& other) const override; + +public: + float m_data; +}; diff --git a/source/nbt/Int16Tag.cpp b/source/nbt/Int16Tag.cpp new file mode 100644 index 000000000..79f60752f --- /dev/null +++ b/source/nbt/Int16Tag.cpp @@ -0,0 +1,34 @@ +#include + +#include "Int16Tag.hpp" + +Int16Tag::Int16Tag() : m_data(0) {} +Int16Tag::Int16Tag(int16_t val) : m_data(val) {} + +void Int16Tag::write(IDataOutput& dos) const +{ + dos.writeInt16(m_data); +} + +void Int16Tag::load(IDataInput& dis) +{ + m_data = dis.readInt16(); +} + +std::string Int16Tag::toString() const +{ + std::ostringstream sstream; + sstream << m_data; + return sstream.str(); +} + +Tag* Int16Tag::copy() const +{ + return new Int16Tag(m_data); +} + +bool Int16Tag::operator==(const Tag& other) const +{ + const Int16Tag& other2 = (const Int16Tag&)(other); + return getId() == other2.getId() && m_data == other2.m_data; +} \ No newline at end of file diff --git a/source/nbt/Int16Tag.hpp b/source/nbt/Int16Tag.hpp new file mode 100644 index 000000000..8ddf74623 --- /dev/null +++ b/source/nbt/Int16Tag.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include + +#include "Tag.hpp" + +class Int16Tag : public Tag +{ +public: + Int16Tag(); + Int16Tag(int16_t val); + +public: + Tag::Type getId() const override { return TAG_TYPE_INT16; } + + void write(IDataOutput& dos) const override; + void load(IDataInput& dis) override; + + std::string toString() const override; + Tag* copy() const override; + + bool operator==(const Tag& other) const override; + +public: + int16_t m_data; +}; diff --git a/source/nbt/Int32ArrayTag.cpp b/source/nbt/Int32ArrayTag.cpp new file mode 100644 index 000000000..5a50c2a8b --- /dev/null +++ b/source/nbt/Int32ArrayTag.cpp @@ -0,0 +1,81 @@ +#include +#include +#include + +#include "Int32ArrayTag.hpp" + +#define MAX_SIZE 4096 +#define ELEMENT_SIZE sizeof(int32_t) + +Int32ArrayTag::Int32ArrayTag() : m_data() {} +Int32ArrayTag::Int32ArrayTag(const TagMemoryChunk& data) + : m_data(data.copy()) +{ +} + +void Int32ArrayTag::write(IDataOutput& dos) const +{ + dos.writeInt32(m_data.m_elements); + for (uint32_t i = 0; i < m_data.m_elements; i++) + { + dos.writeInt32(m_data.m_buffer[ELEMENT_SIZE * i]); + } +} + +void Int32ArrayTag::load(IDataInput& dis) +{ + int32_t elements = dis.readInt32(); + if (elements <= 0 ) + return; + + uint32_t size = MAX_SIZE; + if (elements < MAX_SIZE) + size = elements; + uint8_t* buf = m_data.alloc(size); + if (buf) + { + for (uint32_t i = 0; i < elements; i++) + { + if (dis.numBytesLeft() == 0) + break; + if (i >= m_data.m_elements) + { + size = m_data.m_elements + MAX_SIZE; + if (elements < size) + size = elements; + m_data.alloc(size); + } + // @HACK + ((int32_t*)buf)[i] = dis.readInt32(); + } + } + else + { + assert(!"Memory allocation failed"); + } +} + +std::string Int32ArrayTag::toString() const +{ + std::ostringstream sstream("["); + sstream << m_data.m_elements << " 32-bit ints]"; + return sstream.str(); +} + +Tag* Int32ArrayTag::copy() const +{ + return new Int32ArrayTag(m_data); +} + +bool Int32ArrayTag::operator==(const Tag& other) const +{ + const Int32ArrayTag& other2 = (const Int32ArrayTag&)(other); + + if (getId() != other2.getId()) + return false; + + if (other2.m_data != m_data) + return false; + + return true; +} \ No newline at end of file diff --git a/source/nbt/Int32ArrayTag.hpp b/source/nbt/Int32ArrayTag.hpp new file mode 100644 index 000000000..15e923349 --- /dev/null +++ b/source/nbt/Int32ArrayTag.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include "Tag.hpp" + +class Int32ArrayTag : public Tag +{ +public: + Int32ArrayTag(); + Int32ArrayTag(const TagMemoryChunk& data); + +public: + Tag::Type getId() const override { return TAG_TYPE_INT32_ARRAY; } + + void write(IDataOutput& dos) const override; + void load(IDataInput& dis) override; + + std::string toString() const override; + Tag* copy() const override; + + bool operator==(const Tag& other) const override; + +public: + TagMemoryChunk m_data; +}; diff --git a/source/nbt/Int32Tag.cpp b/source/nbt/Int32Tag.cpp new file mode 100644 index 000000000..c02d84a2f --- /dev/null +++ b/source/nbt/Int32Tag.cpp @@ -0,0 +1,34 @@ +#include + +#include "Int32Tag.hpp" + +Int32Tag::Int32Tag() : m_data(0) {} +Int32Tag::Int32Tag(int32_t val) : m_data(val) {} + +void Int32Tag::write(IDataOutput& dos) const +{ + dos.writeInt32(m_data); +} + +void Int32Tag::load(IDataInput& dis) +{ + m_data = dis.readInt32(); +} + +std::string Int32Tag::toString() const +{ + std::ostringstream sstream; + sstream << m_data; + return sstream.str(); +} + +Tag* Int32Tag::copy() const +{ + return new Int32Tag(m_data); +} + +bool Int32Tag::operator==(const Tag& other) const +{ + const Int32Tag& other2 = (const Int32Tag&)(other); + return getId() == other2.getId() && m_data == other2.m_data; +} \ No newline at end of file diff --git a/source/nbt/Int32Tag.hpp b/source/nbt/Int32Tag.hpp new file mode 100644 index 000000000..bc0c443b3 --- /dev/null +++ b/source/nbt/Int32Tag.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include + +#include "Tag.hpp" + +class Int32Tag : public Tag +{ +public: + Int32Tag(); + Int32Tag(int32_t val); + +public: + Tag::Type getId() const override { return TAG_TYPE_INT32; } + + void write(IDataOutput& dos) const override; + void load(IDataInput& dis) override; + + std::string toString() const override; + Tag* copy() const override; + + bool operator==(const Tag& other) const override; + +public: + int32_t m_data; +}; diff --git a/source/nbt/Int64ArrayTag.cpp b/source/nbt/Int64ArrayTag.cpp new file mode 100644 index 000000000..1ff1a3ce0 --- /dev/null +++ b/source/nbt/Int64ArrayTag.cpp @@ -0,0 +1,81 @@ +#include +#include +#include + +#include "Int64ArrayTag.hpp" + +#define MAX_SIZE 4096 / 2 +#define ELEMENT_SIZE sizeof(int64_t) + +Int64ArrayTag::Int64ArrayTag() : m_data() {} +Int64ArrayTag::Int64ArrayTag(const TagMemoryChunk& data) + : m_data(data.copy()) +{ +} + +void Int64ArrayTag::write(IDataOutput& dos) const +{ + dos.writeInt32(m_data.m_elements); + for (uint32_t i = 0; i < m_data.m_elements; i++) + { + dos.writeInt64(m_data.m_buffer[ELEMENT_SIZE * i]); + } +} + +void Int64ArrayTag::load(IDataInput& dis) +{ + int32_t elements = dis.readInt32(); + if (elements <= 0 ) + return; + + uint32_t size = MAX_SIZE; + if (elements < MAX_SIZE) + size = elements; + uint8_t* buf = m_data.alloc(size); + if (buf) + { + for (uint32_t i = 0; i < elements; i++) + { + if (dis.numBytesLeft() == 0) + break; + if (i >= m_data.m_elements) + { + size = m_data.m_elements + MAX_SIZE; + if (elements < size) + size = elements; + m_data.alloc(size); + } + // @HACK + ((int64_t*)buf)[i] = dis.readInt64(); + } + } + else + { + assert(!"Memory allocation failed"); + } +} + +std::string Int64ArrayTag::toString() const +{ + std::ostringstream sstream("["); + sstream << m_data.m_elements << " 64-bit ints]"; + return sstream.str(); +} + +Tag* Int64ArrayTag::copy() const +{ + return new Int64ArrayTag(m_data); +} + +bool Int64ArrayTag::operator==(const Tag& other) const +{ + const Int64ArrayTag& other2 = (const Int64ArrayTag&)(other); + + if (getId() != other2.getId()) + return false; + + if (other2.m_data != m_data) + return false; + + return true; +} \ No newline at end of file diff --git a/source/nbt/Int64ArrayTag.hpp b/source/nbt/Int64ArrayTag.hpp new file mode 100644 index 000000000..66b9c8fa9 --- /dev/null +++ b/source/nbt/Int64ArrayTag.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include "Tag.hpp" + +class Int64ArrayTag : public Tag +{ +public: + Int64ArrayTag(); + Int64ArrayTag(const TagMemoryChunk& data); + +public: + Tag::Type getId() const override { return TAG_TYPE_INT64_ARRAY; } + + void write(IDataOutput& dos) const override; + void load(IDataInput& dis) override; + + std::string toString() const override; + Tag* copy() const override; + + bool operator==(const Tag& other) const override; + +public: + TagMemoryChunk m_data; +}; diff --git a/source/nbt/Int64Tag.cpp b/source/nbt/Int64Tag.cpp new file mode 100644 index 000000000..a2145c203 --- /dev/null +++ b/source/nbt/Int64Tag.cpp @@ -0,0 +1,34 @@ +#include + +#include "Int64Tag.hpp" + +Int64Tag::Int64Tag() : m_data(0) {} +Int64Tag::Int64Tag(int64_t val) : m_data(val) {} + +void Int64Tag::write(IDataOutput& dos) const +{ + dos.writeInt64(m_data); +} + +void Int64Tag::load(IDataInput& dis) +{ + m_data = dis.readInt64(); +} + +std::string Int64Tag::toString() const +{ + std::ostringstream sstream; + sstream << m_data; + return sstream.str(); +} + +Tag* Int64Tag::copy() const +{ + return new Int64Tag(m_data); +} + +bool Int64Tag::operator==(const Tag& other) const +{ + const Int64Tag& other2 = (const Int64Tag&)(other); + return getId() == other2.getId() && m_data == other2.m_data; +} \ No newline at end of file diff --git a/source/nbt/Int64Tag.hpp b/source/nbt/Int64Tag.hpp new file mode 100644 index 000000000..b4342d8bc --- /dev/null +++ b/source/nbt/Int64Tag.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include + +#include "Tag.hpp" + +class Int64Tag : public Tag +{ +public: + Int64Tag(); + Int64Tag(int64_t val); + +public: + Tag::Type getId() const override { return TAG_TYPE_INT64; } + + void write(IDataOutput& dos) const override; + void load(IDataInput& dis) override; + + std::string toString() const override; + Tag* copy() const override; + + bool operator==(const Tag& other) const override; + +public: + int64_t m_data; +}; diff --git a/source/nbt/Int8ArrayTag.cpp b/source/nbt/Int8ArrayTag.cpp new file mode 100644 index 000000000..441dc28d6 --- /dev/null +++ b/source/nbt/Int8ArrayTag.cpp @@ -0,0 +1,56 @@ +#include + +#include "Int8ArrayTag.hpp" + +Int8ArrayTag::Int8ArrayTag() {} +Int8ArrayTag::Int8ArrayTag(const TagMemoryChunk& data) + : m_data(data.copy()) +{ +} + +void Int8ArrayTag::write(IDataOutput& dos) const +{ + dos.writeInt32(m_data.m_elements); + dos.writeBytes(m_data.m_buffer, m_data.m_elements); +} + +void Int8ArrayTag::load(IDataInput& dis) +{ + int32_t elements = dis.readInt32(); + m_data.m_elements = elements; + + if (elements <= 0) + return; + + unsigned int bytesLeft = dis.numBytesLeft(); + int32_t count = elements; + if (bytesLeft < elements) + count = bytesLeft; + void* buf = m_data.alloc(count); + dis.readBytes(buf, m_data.m_elements); +} + +std::string Int8ArrayTag::toString() const +{ + std::ostringstream sstream("["); + sstream << m_data.m_elements << " 8-bit ints]"; + return sstream.str(); +} + +Tag* Int8ArrayTag::copy() const +{ + return new Int8ArrayTag(m_data); +} + +bool Int8ArrayTag::operator==(const Tag& other) const +{ + const Int8ArrayTag& other2 = (const Int8ArrayTag&)(other); + + if (getId() != other2.getId()) + return false; + + if (other2.m_data != m_data) + return false; + + return true; +} \ No newline at end of file diff --git a/source/nbt/Int8ArrayTag.hpp b/source/nbt/Int8ArrayTag.hpp new file mode 100644 index 000000000..88d2ae8ef --- /dev/null +++ b/source/nbt/Int8ArrayTag.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include "Tag.hpp" + +class Int8ArrayTag : public Tag +{ +public: + Int8ArrayTag(); + Int8ArrayTag(const TagMemoryChunk& data); + +public: + Tag::Type getId() const override { return TAG_TYPE_INT8_ARRAY; } + + void write(IDataOutput& dos) const override; + void load(IDataInput& dis) override; + + std::string toString() const override; + Tag* copy() const override; + + bool operator==(const Tag& other) const override; + +public: + TagMemoryChunk m_data; +}; diff --git a/source/nbt/Int8Tag.cpp b/source/nbt/Int8Tag.cpp new file mode 100644 index 000000000..aea5894d4 --- /dev/null +++ b/source/nbt/Int8Tag.cpp @@ -0,0 +1,34 @@ +#include + +#include "Int8Tag.hpp" + +Int8Tag::Int8Tag() : m_data(0) {} +Int8Tag::Int8Tag(int8_t val) : m_data(val) {} + +void Int8Tag::write(IDataOutput& dos) const +{ + dos.writeInt8(m_data); +} + +void Int8Tag::load(IDataInput& dis) +{ + m_data = dis.readInt8(); +} + +std::string Int8Tag::toString() const +{ + std::ostringstream sstream; + sstream << m_data; + return sstream.str(); +} + +Tag* Int8Tag::copy() const +{ + return new Int8Tag(m_data); +} + +bool Int8Tag::operator==(const Tag& other) const +{ + const Int8Tag& other2 = (const Int8Tag&)(other); + return getId() == other2.getId() && m_data == other2.m_data; +} \ No newline at end of file diff --git a/source/nbt/Int8Tag.hpp b/source/nbt/Int8Tag.hpp new file mode 100644 index 000000000..893ba7057 --- /dev/null +++ b/source/nbt/Int8Tag.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include + +#include "Tag.hpp" + +class Int8Tag : public Tag +{ +public: + Int8Tag(); + Int8Tag(int8_t val); + +public: + Tag::Type getId() const override { return TAG_TYPE_INT8; } + + void write(IDataOutput& dos) const override; + void load(IDataInput& dis) override; + + std::string toString() const override; + Tag* copy() const override; + + bool operator==(const Tag& other) const override; + +public: + int8_t m_data; +}; diff --git a/source/nbt/ListTag.cpp b/source/nbt/ListTag.cpp new file mode 100644 index 000000000..3836cf651 --- /dev/null +++ b/source/nbt/ListTag.cpp @@ -0,0 +1,207 @@ +#include + +#include "ListTag.hpp" +#include "common/Util.hpp" +#include "FloatTag.hpp" +#include "StringTag.hpp" +#include "Int32Tag.hpp" + +ListTag::ListTag() : m_type(TAG_TYPE_END) {} +ListTag::ListTag(Tag::Type type) : m_type(type) {} + +ListTag::~ListTag() +{ + deleteChildren(); +} + +void ListTag::write(IDataOutput& dos) const +{ + dos.writeInt8(m_type); + dos.writeInt32(m_list.size()); + + for (std::vector::const_iterator it = m_list.begin(); it != m_list.end(); it++) + { + (*it)->write(dos); + } +} + +void ListTag::load(IDataInput& dis) +{ + m_type = (Tag::Type)dis.readInt8(); + uint32_t length = dis.readInt32(); + + m_list.clear(); + + if (length <= 0 || m_type == TAG_TYPE_END ) + return; + + for (uint32_t i = 0; i < length; ++i ) + { + if (dis.numBytesLeft() == 0) break; + + Tag* tag = Tag::newTag(m_type); + if (!tag) break; + + tag->load(dis); + m_list.push_back(tag); + } +} + +std::string ListTag::toString() const +{ + std::ostringstream sstream; + sstream << m_list.size() << " entries of type " << Tag::getTagName(m_type); + return sstream.str(); +} + +void ListTag::add(Tag* tag) +{ + m_type = tag->getId(); + m_list.push_back(tag); +} + +float ListTag::getFloat(unsigned int index) const +{ + if (index < m_list.size() + && index >= 0 + && m_list[index] != nullptr + && m_list[index]->getId() == TAG_TYPE_FLOAT) + { + return ((FloatTag*)m_list[index])->m_data; + } + else + { + return 0.0f; + } +} + +int32_t ListTag::getInt32(unsigned int index) const +{ + if (index < m_list.size() + && index >= 0 + && m_list[index] != nullptr + && m_list[index]->getId() == TAG_TYPE_INT32) + { + return ((FloatTag*)m_list[index])->m_data; + } + else + { + return 0.0f; + } +} + +const std::string& ListTag::getString(unsigned int index) const +{ + if (index >= m_list.size()) + return Util::EMPTY_STRING; + if (index < 0) + return Util::EMPTY_STRING; + if (!m_list[index]) + return Util::EMPTY_STRING; + if (m_list[index]->getId() == TAG_TYPE_STRING) + return Util::EMPTY_STRING; + + return ((StringTag*)m_list[index])->m_data; +} + +const CompoundTag* ListTag::getCompound(unsigned int index) const +{ + if (index < m_list.size() + && index >= 0 + && m_list[index]->getId() == TAG_TYPE_COMPOUND) + { + return (const CompoundTag *)m_list[index]; + } + else + { + return nullptr; + } +} + +Tag* ListTag::copy() const +{ + return copyList(); +} + +ListTag* ListTag::copyList() const +{ + ListTag* result = new ListTag(); + result->m_type = m_type; + + for (std::vector::const_iterator it = m_list.begin(); it != m_list.end(); it++) + { + Tag* tag = *it; + Tag* copiedTag = tag->copy(); + result->m_list.push_back(copiedTag); + } + + return result; +} + +void ListTag::deleteChildren() +{ + for (std::vector::iterator it = m_list.begin(); it != m_list.end(); it++) + { + Tag* tag = *it; + delete tag; + } + + m_list.clear(); +} + +bool ListTag::operator==(const Tag& other) const +{ + const ListTag& other2 = (const ListTag&)(other); + if (getId() == other2.getId() && m_type == other2.m_type) + { + if (m_list.size() == other2.m_list.size()) + { + if (m_list.empty()) + return true; + + for (size_t i = 0; i < m_list.size(); i++) + { + if (m_list[i] != other2.m_list[i]) + return false; + } + } + } + + return false; +} + +ListTagFloatAdder::ListTagFloatAdder(float f) +{ + m_tag = nullptr; + this->operator()(f); +} + +ListTagFloatAdder& ListTagFloatAdder::operator()(float f) +{ + if (!m_tag) + m_tag = new ListTag(); + + Tag* newTag = new FloatTag(f); + + m_tag->add(newTag); + + return *this; +} + +ListTagInt32Adder::ListTagInt32Adder(int32_t i) +{ + m_tag = nullptr; + this->operator()(i); +} + +ListTagInt32Adder& ListTagInt32Adder::operator()(int32_t i) +{ + if (!m_tag) + m_tag = new ListTag(); + + Tag* newTag = new Int32Tag(i); + + m_tag->add(newTag); + + return *this; +} \ No newline at end of file diff --git a/source/nbt/ListTag.hpp b/source/nbt/ListTag.hpp new file mode 100644 index 000000000..68dc4f273 --- /dev/null +++ b/source/nbt/ListTag.hpp @@ -0,0 +1,75 @@ +#pragma once + +#include +#include + +#include "Tag.hpp" + +class CompoundTag; +class ListTag; + +class ListTagFloatAdder +{ +public: + ListTagFloatAdder() : m_tag(nullptr) {} + ListTagFloatAdder(ListTag* tag) : m_tag(tag) {} + ListTagFloatAdder(float f); + +public: + ListTagFloatAdder& operator()(float f); + operator ListTag* () { return m_tag; } + operator const ListTag* () const { return m_tag; } + +private: + ListTag* m_tag; +}; + +class ListTagInt32Adder +{ +public: + ListTagInt32Adder() : m_tag(nullptr) {} + ListTagInt32Adder(ListTag* tag) : m_tag(tag) {} + ListTagInt32Adder(int32_t i); + +public: + ListTagInt32Adder& operator()(int32_t i); + operator ListTag* () { return m_tag; } + operator const ListTag* () const { return m_tag; } + +private: + ListTag* m_tag; +}; + +class ListTag : public Tag +{ +public: + ListTag(); + ListTag(Tag::Type elementType); + ~ListTag(); + +public: + Tag::Type getId() const override { return TAG_TYPE_LIST; } + + void write(IDataOutput& dos) const override; + void load(IDataInput& dis) override; + + std::string toString() const override; + void add(Tag* tag); + float getFloat(unsigned int index) const; + int32_t getInt32(unsigned int index) const; + const std::string& getString(unsigned int index) const; + const CompoundTag* getCompound(unsigned int index) const; + Tag* copy() const override; + ListTag* copyList() const; + void deleteChildren(); + + const std::vector& rawView() const { return m_list; } + + bool operator==(const Tag& other) const override; + operator ListTagFloatAdder() { return ListTagFloatAdder(this); } + operator ListTagInt32Adder() { return ListTagInt32Adder(this); } + +private: + std::vector m_list; + Tag::Type m_type; +}; \ No newline at end of file diff --git a/source/nbt/NbtIo.cpp b/source/nbt/NbtIo.cpp new file mode 100644 index 000000000..d72a8f36a --- /dev/null +++ b/source/nbt/NbtIo.cpp @@ -0,0 +1,15 @@ +#include "NbtIo.hpp" + +CompoundTag* NbtIo::read(IDataInput& dis) +{ + std::string tagName = std::string(); + + return (CompoundTag*)Tag::readNamedTag(dis, tagName); +} + +void NbtIo::write(const CompoundTag& tag, IDataOutput& dos) +{ + // I have no idea how they intend for this to work without writing the Tag name, + // considering the name of the format is fucking Named Binary Tag + Tag::writeNamedTag("", tag, dos); +} \ No newline at end of file diff --git a/source/nbt/NbtIo.hpp b/source/nbt/NbtIo.hpp new file mode 100644 index 000000000..0d7e96336 --- /dev/null +++ b/source/nbt/NbtIo.hpp @@ -0,0 +1,11 @@ +#pragma once + +#include "CompoundTag.hpp" +#include "common/DataIO.hpp" + +class NbtIo +{ +public: + static CompoundTag* read(IDataInput& dis); + static void write(const CompoundTag& tag, IDataOutput& dos); +}; \ No newline at end of file diff --git a/source/nbt/StringTag.cpp b/source/nbt/StringTag.cpp new file mode 100644 index 000000000..9aa5a3a48 --- /dev/null +++ b/source/nbt/StringTag.cpp @@ -0,0 +1,32 @@ +#include + +#include "StringTag.hpp" + +StringTag::StringTag() {} +StringTag::StringTag(const std::string& data) : m_data(data) {} + +void StringTag::write(IDataOutput& dos) const +{ + dos.writeString(m_data); +} + +void StringTag::load(IDataInput& dis) +{ + m_data = dis.readString(); +} + +std::string StringTag::toString() const +{ + return m_data; +} + +Tag* StringTag::copy() const +{ + return new StringTag(m_data); +} + +bool StringTag::operator==(const Tag& other) const +{ + const StringTag& other2 = (const StringTag&)(other); + return getId() == other2.getId() && m_data == other2.m_data; +} \ No newline at end of file diff --git a/source/nbt/StringTag.hpp b/source/nbt/StringTag.hpp new file mode 100644 index 000000000..1e914a6c9 --- /dev/null +++ b/source/nbt/StringTag.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include + +#include "Tag.hpp" + +class StringTag : public Tag +{ +public: + StringTag(); + StringTag(const std::string& value); + +public: + Tag::Type getId() const override { return TAG_TYPE_STRING; } + +public: + void write(IDataOutput& dos) const override; + void load(IDataInput& dis) override; + + std::string toString() const override; + Tag* copy() const override; + + bool operator==(const Tag& other) const override; + +public: + std::string m_data; +}; diff --git a/source/nbt/Tag.cpp b/source/nbt/Tag.cpp new file mode 100644 index 000000000..dd57ce4f0 --- /dev/null +++ b/source/nbt/Tag.cpp @@ -0,0 +1,115 @@ +#include "Tag.hpp" +#include "Int8Tag.hpp" +#include "Int16Tag.hpp" +#include "Int32Tag.hpp" +#include "Int64Tag.hpp" +#include "FloatTag.hpp" +#include "DoubleTag.hpp" +#include "Int8ArrayTag.hpp" +#include "StringTag.hpp" +#include "ListTag.hpp" +#include "CompoundTag.hpp" +#include "Int32ArrayTag.hpp" +#include "Int64ArrayTag.hpp" +#include "EndTag.hpp" + +std::string Tag::getTagName(Tag::Type type) +{ + switch (type) + { + case TAG_TYPE_END: return "TAG_End"; + case TAG_TYPE_INT8: return "TAG_Byte"; + case TAG_TYPE_INT16: return "TAG_Short"; + case TAG_TYPE_INT32: return "TAG_Int"; + case TAG_TYPE_INT64: return "TAG_Long"; + case TAG_TYPE_FLOAT: return "TAG_Float"; + case TAG_TYPE_DOUBLE: return "TAG_Double"; + case TAG_TYPE_INT8_ARRAY: return "TAG_Byte_Array"; + case TAG_TYPE_STRING: return "TAG_String"; + case TAG_TYPE_LIST: return "TAG_List"; + case TAG_TYPE_COMPOUND: return "TAG_Compound"; + case TAG_TYPE_INT32_ARRAY: return "TAG_Int_Array"; + default: return "UNKNOWN"; + } +} + +Tag* Tag::newTag(Tag::Type type) +{ + switch (type) + { + case TAG_TYPE_END: return new EndTag(); + case TAG_TYPE_INT8: return new Int8Tag(); + case TAG_TYPE_INT16: return new Int16Tag(); + case TAG_TYPE_INT32: return new Int32Tag(); + case TAG_TYPE_INT64: return new Int64Tag(); + case TAG_TYPE_FLOAT: return new FloatTag(); + case TAG_TYPE_DOUBLE: return new DoubleTag(); + case TAG_TYPE_INT8_ARRAY: return new Int8ArrayTag(); + case TAG_TYPE_STRING: return new StringTag(); + case TAG_TYPE_LIST: return new ListTag(); + case TAG_TYPE_COMPOUND: return new CompoundTag(); + case TAG_TYPE_INT32_ARRAY: return new Int32ArrayTag(); + case TAG_TYPE_INT64_ARRAY: return new Int64ArrayTag(); + default: return nullptr; + } +} + +Tag* Tag::readNamedTag(IDataInput& dis, std::string& name) +{ + Tag::Type type = (Tag::Type)dis.readInt8(); + if (type == TAG_TYPE_END) + return new EndTag(); + + name = dis.readString(); + + Tag* tag = Tag::newTag(type); + if (tag) + tag->load(dis); + + return tag; +} + +void Tag::writeNamedTag(const std::string& name, const Tag& tag, IDataOutput& dos) +{ + dos.writeInt8(tag.getId()); + + if (tag.getId() != TAG_TYPE_END) + { + dos.writeString(name); + tag.write(dos); + } +} + +TagMemoryChunk::TagMemoryChunk() +{ + m_elements = 0; + m_size = 0; + m_buffer = nullptr; +} + +TagMemoryChunk::~TagMemoryChunk() +{ + if (m_buffer) + delete m_buffer; +} + +TagMemoryChunk TagMemoryChunk::copy() const +{ + TagMemoryChunk result = TagMemoryChunk(); + result.m_elements = m_elements; + result.m_size = m_size; + result.alloc(m_size); + memcpy(result.m_buffer, m_buffer, m_size); + return result; +} + +bool TagMemoryChunk::operator!=(const TagMemoryChunk& other) const +{ + if (m_size != other.m_size ) + return true; + + if (m_size > 0) + return memcmp(m_buffer, other.m_buffer, m_size) != 0; + + return false; +} \ No newline at end of file diff --git a/source/nbt/Tag.hpp b/source/nbt/Tag.hpp new file mode 100644 index 000000000..dea1ce99c --- /dev/null +++ b/source/nbt/Tag.hpp @@ -0,0 +1,86 @@ +#pragma once + +#include +#include +#include + +#include "common/DataIO.hpp" + +class Tag +{ +public: + enum Type + { + TAG_TYPE_END, + TAG_TYPE_INT8, + TAG_TYPE_INT16, + TAG_TYPE_INT32, + TAG_TYPE_INT64, + TAG_TYPE_FLOAT, + TAG_TYPE_DOUBLE, + TAG_TYPE_INT8_ARRAY, + TAG_TYPE_STRING, + TAG_TYPE_LIST, + TAG_TYPE_COMPOUND, + TAG_TYPE_INT32_ARRAY, + TAG_TYPE_INT64_ARRAY + }; + +public: + virtual ~Tag() {} + +public: + virtual void deleteChildren() {}; + virtual void write(IDataOutput& dos) const = 0; + virtual void load(IDataInput& dis) = 0; + virtual std::string toString() const = 0; + virtual Tag::Type getId() const = 0; + //virtual bool equals(const Tag& other) = 0; + virtual Tag* copy() const = 0; + //virtual uint64_t hash() = 0; + +public: + virtual bool operator==(const Tag& other) const = 0; + +public: + static std::string getTagName(Tag::Type type); + static Tag* newTag(Tag::Type type); + static Tag* readNamedTag(IDataInput& dis, std::string& name); + static void writeNamedTag(const std::string& name, const Tag& tag, IDataOutput& dos); +}; + +class TagMemoryChunk +{ +private: + template + uint8_t* _alloc(unsigned int count, unsigned int size) + { + m_elements = count; + m_size = size; + if (size > 0) + { + m_buffer = new uint8_t(size); + if (m_buffer) + memset(m_buffer, 0, size); + } + + return m_buffer; + } +public: + TagMemoryChunk(); + ~TagMemoryChunk(); + + template + uint8_t* alloc(unsigned int count) + { + return _alloc(count, sizeof(T) * count); + } + + TagMemoryChunk copy() const; + + bool operator!=(const TagMemoryChunk& other) const; +public: + unsigned int m_elements; + unsigned int m_size; + uint8_t* m_buffer; +}; \ No newline at end of file diff --git a/source/network/RakIO.cpp b/source/network/RakIO.cpp new file mode 100644 index 000000000..e234f6d8f --- /dev/null +++ b/source/network/RakIO.cpp @@ -0,0 +1,23 @@ +#include "RakIO.hpp" + +unsigned int RakDataInput::numBytesLeft() const +{ + return (m_bitStream.GetWriteOffset() - m_bitStream.GetReadOffset()) / 8; +} + +bool RakDataInput::readBytes(void* data, unsigned int count) +{ + if (!hasBytesLeft(count)) + return false; + + RakNet::BitSize_t bitsToRead = 8 * count; + if (bitsToRead > 0) + m_bitStream.ReadBits((unsigned char*)data, bitsToRead); + + return true; +} + +void RakDataOutput::writeBytes(const void* data, unsigned int count) +{ + m_bitStream.WriteBits((const unsigned char*)data, 8 * count); +} \ No newline at end of file diff --git a/source/network/RakIO.hpp b/source/network/RakIO.hpp new file mode 100644 index 000000000..c6c8807f2 --- /dev/null +++ b/source/network/RakIO.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include "common/DataIO.hpp" +#include "BitStream.h" + +class RakDataInput : public BytesDataInput +{ +public: + RakDataInput(RakNet::BitStream& bitStream) + : m_bitStream(bitStream) + { }; + +public: + virtual unsigned int numBytesLeft() const override; + virtual bool readBytes(void* data, unsigned int count) override; + +public: + RakNet::BitStream& m_bitStream; +}; + +class RakDataOutput : public BytesDataOutput +{ +public: + RakDataOutput(RakNet::BitStream& bitStream) + : m_bitStream(bitStream) + { }; + +public: + virtual void writeBytes(const void* data, unsigned int count) override; + +public: + RakNet::BitStream& m_bitStream; +}; \ No newline at end of file diff --git a/source/world/entity/Animal.cpp b/source/world/entity/Animal.cpp index 944b65463..1c30c0614 100644 --- a/source/world/entity/Animal.cpp +++ b/source/world/entity/Animal.cpp @@ -7,6 +7,7 @@ ********************************************************************/ #include "Animal.hpp" #include "world/level/Level.hpp" +#include "nbt/CompoundTag.hpp" Animal::Animal(Level* pLevel) : PathfinderMob(pLevel) { @@ -14,6 +15,20 @@ Animal::Animal(Level* pLevel) : PathfinderMob(pLevel) m_age = 0; } +void Animal::addAdditionalSaveData(CompoundTag& tag) const +{ + Mob::addAdditionalSaveData(tag); + + tag.putInt32("Age", getAge()); +} + +void Animal::readAdditionalSaveData(const CompoundTag& tag) +{ + Mob::readAdditionalSaveData(tag); + + setAge(tag.getInt32("Age")); +} + void Animal::aiStep() { int age = getAge(); diff --git a/source/world/entity/Animal.hpp b/source/world/entity/Animal.hpp index 755179978..7a2830e6a 100644 --- a/source/world/entity/Animal.hpp +++ b/source/world/entity/Animal.hpp @@ -13,8 +13,8 @@ class Animal : public PathfinderMob { public: Animal(Level* pLevel); - // TODO: void addAdditonalSaveData(CompoundTag*) override; - // TODO: void readAdditonalSaveData(CompoundTag*) override; + void addAdditionalSaveData(CompoundTag& tag) const override; + void readAdditionalSaveData(const CompoundTag& tag) override; void aiStep() override; bool isBaby() const override; bool canSpawn() override; diff --git a/source/world/entity/Arrow.cpp b/source/world/entity/Arrow.cpp index c417bc721..eb89eafd6 100644 --- a/source/world/entity/Arrow.cpp +++ b/source/world/entity/Arrow.cpp @@ -1,6 +1,26 @@ #include "Arrow.hpp" #include "Mob.hpp" #include "world/level/Level.hpp" +#include "nbt/CompoundTag.hpp" + +const unsigned int Arrow::ARROW_BASE_DAMAGE = 4; + +void Arrow::_init() +{ + m_pDescriptor = &EntityTypeDescriptor::arrow; + field_C8 = RENDER_ARROW; + setSize(0.5f, 0.5f); + + m_tilePos = Vec3(-1, -1, -1); + m_lastTile = 0; + m_lastTileData = 0; + m_bInGround = false; + m_bIsPlayerOwned = false; + m_life = 0; + m_flightTime = 0; + m_shakeTime = 0; + m_owner = nullptr; +} Arrow::Arrow(Level* pLevel) : Entity(pLevel) { @@ -19,6 +39,7 @@ Arrow::Arrow(Level* pLevel, Mob* pMob) : Entity(pLevel) _init(); m_owner = pMob; + m_bIsPlayerOwned = m_owner->isPlayer(); moveTo(Vec3(pMob->m_pos.x, pMob->m_pos.y + pMob->getHeadHeight(), pMob->m_pos.z), Vec2(pMob->m_rot.y, pMob->m_rot.x)); m_pos.x -= Mth::cos(m_rot.y / 180.0f * M_PI) * 0.16f; @@ -32,21 +53,6 @@ Arrow::Arrow(Level* pLevel, Mob* pMob) : Entity(pLevel) shoot(m_vel, 1.5f, 1.0f); } -void Arrow::_init() -{ - m_pDescriptor = &EntityTypeDescriptor::arrow; - field_C8 = RENDER_ARROW; - setSize(0.5f, 0.5f); - - m_tilePos = Vec3(-1, -1, -1); - m_lastTile = 0; - m_inGround = false; - m_life = 0; - m_flightTime = 0; - m_shakeTime = 0; - m_owner = nullptr; -} - void Arrow::shoot(Vec3 vel, float speed, float r) { float len = vel.length(); @@ -93,7 +99,7 @@ void Arrow::tick() if (m_shakeTime > 0) --m_shakeTime; - if (m_inGround) + if (m_bInGround) { if (m_pLevel->getTile(m_tilePos) == m_lastTile) { @@ -106,7 +112,7 @@ void Arrow::tick() return; } - m_inGround = false; + m_bInGround = false; m_vel.x *= sharedRandom.nextFloat() * 0.2f; m_vel.y *= sharedRandom.nextFloat() * 0.2f; m_vel.z *= sharedRandom.nextFloat() * 0.2f; @@ -162,7 +168,7 @@ void Arrow::tick() { if (hit_result.m_pEnt != nullptr) { - if (hit_result.m_pEnt->hurt(m_owner, 4)) + if (hit_result.m_pEnt->hurt(m_owner, ARROW_BASE_DAMAGE)) { m_pLevel->playSound(this, "random.drr", 1.0f, 1.2f / (sharedRandom.nextFloat() * 0.2f + 0.9f)); remove(); @@ -182,7 +188,7 @@ void Arrow::tick() m_vel = hit_result.m_hitPos - m_pos; m_pos -= (m_vel / m_pos.length() * 0.05f); m_pLevel->playSound(this, "random.drr", 1.0f, 1.2f / (sharedRandom.nextFloat() * 0.2f + 0.9f)); - m_inGround = true; + m_bInGround = true; m_shakeTime = 7; } } @@ -229,15 +235,43 @@ void Arrow::tick() void Arrow::playerTouch(Player* pPlayer) { - // IsMultiplayer should just be called IsOnline - if (!m_pLevel->m_bIsMultiplayer) + if (!m_pLevel->m_bIsOnline) { - // they use ->add here in b1.2_02 - if (m_inGround && m_owner == pPlayer && m_shakeTime <= 0 && pPlayer->m_pInventory->addItem(new ItemInstance(ITEM_ARROW, 1, 0))) + // had m_owner == pPlayer, but this logic breaks when loaded from a save, and m_owner is null + if (m_bInGround && m_bIsPlayerOwned && m_shakeTime <= 0) { - m_pLevel->playSound(this, "random.pop", 0.2f, ((sharedRandom.nextFloat() - sharedRandom.nextFloat()) * 0.7f + 1.0f) * 2.0f); - pPlayer->take(this, 1); - remove(); + ItemInstance arrow(Item::arrow, 1); + // they use ->add here in b1.2_02 + if (pPlayer->m_pInventory->addItem(arrow)) + { + m_pLevel->playSound(this, "random.pop", 0.2f, ((sharedRandom.nextFloat() - sharedRandom.nextFloat()) * 0.7f + 1.0f) * 2.0f); + pPlayer->take(this, 1); + remove(); + } } } } + +void Arrow::addAdditionalSaveData(CompoundTag& tag) const +{ + tag.putInt16("xTile", m_tilePos.x); + tag.putInt16("yTile", m_tilePos.y); + tag.putInt16("zTile", m_tilePos.z); + tag.putInt8("inTile", m_lastTile); + tag.putInt8("inData", m_lastTileData); + tag.putInt8("shake", m_shakeTime); + tag.putBoolean("inGround", m_bInGround); + tag.putBoolean("player", m_bIsPlayerOwned); +} + +void Arrow::readAdditionalSaveData(const CompoundTag& tag) +{ + m_tilePos.x = tag.getInt16("xTile"); + m_tilePos.y = tag.getInt16("yTile"); + m_tilePos.z = tag.getInt16("zTile"); + m_lastTile = tag.getInt8("inTile") & 255; + m_lastTileData = tag.getInt8("inData") & 255; + m_shakeTime = tag.getInt8("shake") & 255; + m_bInGround = tag.getBoolean("inGround"); + m_bIsPlayerOwned = tag.getBoolean("player"); +} diff --git a/source/world/entity/Arrow.hpp b/source/world/entity/Arrow.hpp index f814cf0f7..806479a1a 100644 --- a/source/world/entity/Arrow.hpp +++ b/source/world/entity/Arrow.hpp @@ -4,23 +4,18 @@ class Arrow : public Entity { +public: + static const unsigned int ARROW_BASE_DAMAGE; + private: - TilePos m_tilePos; - TileID m_lastTile; - bool m_inGround; - int m_life; - int m_flightTime; + void _init(); public: - int m_shakeTime; - Mob* m_owner; - Arrow(Level* pLevel); Arrow(Level* pLevel, const Vec3& pos); Arrow(Level* pLevel, Mob* pMob); private: - void _init(); void _lerpMotion(const Vec3& vel); void _lerpMotion2(const Vec3& vel); @@ -32,8 +27,22 @@ class Arrow : public Entity void lerpMotion(const Vec3& vel); void tick() override; - void playerTouch(Player* pPlayer) override; + void addAdditionalSaveData(CompoundTag& tag) const override; + void readAdditionalSaveData(const CompoundTag& tag) override; float getShadowHeightOffs() const override { return 0.0f; } + +private: + TilePos m_tilePos; + TileID m_lastTile; + int8_t m_lastTileData; + bool m_bInGround; + bool m_bIsPlayerOwned; + int m_life; + int m_flightTime; + +public: + int m_shakeTime; + Mob* m_owner; }; \ No newline at end of file diff --git a/source/world/entity/Chicken.cpp b/source/world/entity/Chicken.cpp index 5c27ded03..8eba37bc5 100644 --- a/source/world/entity/Chicken.cpp +++ b/source/world/entity/Chicken.cpp @@ -43,7 +43,7 @@ void Chicken::aiStep() m_vel.y *= 0.6f; m_flap += m_flapping * 2.0f; - if (!m_pLevel->m_bIsMultiplayer && isAlive() && !isBaby() /* && !isChickenJockey()*/ && --m_eggTime <= 0) + if (!m_pLevel->m_bIsOnline && isAlive() && !isBaby() /* && !isChickenJockey()*/ && --m_eggTime <= 0) { m_pLevel->playSound(this, "mob.chickenplop", 1.0f, (m_random.nextFloat() - m_random.nextFloat()) * 0.2f + 1.0f); spawnAtLocation(Item::egg->m_itemID, 1); @@ -65,3 +65,13 @@ void Chicken::dropDeathLoot() else spawnAtLocation(Item::chicken_raw->m_itemID, 1);*/ } + +void Chicken::addAdditionalSaveData(CompoundTag& tag) const +{ + Animal::addAdditionalSaveData(tag); +} + +void Chicken::readAdditionalSaveData(const CompoundTag& tag) +{ + Animal::readAdditionalSaveData(tag); +} \ No newline at end of file diff --git a/source/world/entity/Chicken.hpp b/source/world/entity/Chicken.hpp index 8b3b89706..ecdb15bde 100644 --- a/source/world/entity/Chicken.hpp +++ b/source/world/entity/Chicken.hpp @@ -25,10 +25,12 @@ class Chicken : public Animal std::string getAmbientSound() const override { return "mob.chicken"; } std::string getDeathSound() const override { return "mob.chickenhurt"; } std::string getHurtSound() const override { return "mob.chickenhurt"; } - void dropDeathLoot() override; int getMaxHealth() const override { return 4; } void aiStep() override; + void dropDeathLoot() override; void causeFallDamage(float) override { return; } + void addAdditionalSaveData(CompoundTag& tag) const override; + void readAdditionalSaveData(const CompoundTag& tag) override; Entity* getBreedOffspring(Animal* pOther) { return new Chicken(m_pLevel); } }; diff --git a/source/world/entity/Cow.cpp b/source/world/entity/Cow.cpp index 968250106..4e248b63d 100644 --- a/source/world/entity/Cow.cpp +++ b/source/world/entity/Cow.cpp @@ -14,4 +14,14 @@ Cow::Cow(Level* pLevel) : Animal(pLevel) field_C8 = RENDER_COW; m_texture = "mob/cow.png"; setSize(0.9f, 1.3f); +} + +void Cow::addAdditionalSaveData(CompoundTag& tag) const +{ + Animal::addAdditionalSaveData(tag); +} + +void Cow::readAdditionalSaveData(const CompoundTag& tag) +{ + Animal::readAdditionalSaveData(tag); } \ No newline at end of file diff --git a/source/world/entity/Cow.hpp b/source/world/entity/Cow.hpp index 14b2481e8..4f8b2b9b1 100644 --- a/source/world/entity/Cow.hpp +++ b/source/world/entity/Cow.hpp @@ -20,6 +20,8 @@ class Cow : public Animal int getDeathLoot() const override { return ITEM_LEATHER; } int getMaxHealth() const override { return 10; } float getSoundVolume() const override { return 0.4f; } + void addAdditionalSaveData(CompoundTag& tag) const override; + void readAdditionalSaveData(const CompoundTag& tag) override; Entity* getBreedOffspring(Animal* pOther) { return new Cow(m_pLevel); } }; diff --git a/source/world/entity/Creeper.cpp b/source/world/entity/Creeper.cpp index 3ea37c0cc..c8f7f74ca 100644 --- a/source/world/entity/Creeper.cpp +++ b/source/world/entity/Creeper.cpp @@ -19,7 +19,7 @@ void Creeper::_defineEntityData() void Creeper::tick() { m_oldSwell = m_swell; - if (m_pLevel->m_bIsMultiplayer) + if (m_pLevel->m_bIsOnline) { int swellDir = getSwellDir(); if (swellDir > 0 && m_swell == 0) @@ -55,7 +55,7 @@ void Creeper::die(Entity* pCulprit) void Creeper::checkHurtTarget(Entity* pEnt, float f) { int swellDir = getSwellDir(); - if (swellDir <= 0 && f < 3.0f || swellDir > 0 && f < 7.0f) + if ((swellDir <= 0 && f < 3.0f) || (swellDir > 0 && f < 7.0f)) { if (m_swell == 0) { diff --git a/source/world/entity/Entity.cpp b/source/world/entity/Entity.cpp index 1359b7690..792a63f03 100644 --- a/source/world/entity/Entity.cpp +++ b/source/world/entity/Entity.cpp @@ -9,6 +9,7 @@ #include "Entity.hpp" #include "Player.hpp" #include "world/level/Level.hpp" +#include "nbt/CompoundTag.hpp" #define TOTAL_AIR_SUPPLY (300) @@ -667,14 +668,14 @@ void Entity::baseTick() m_fireTicks = 0; m_distanceFallen = 0; - if (m_pLevel->m_bIsMultiplayer) + if (m_pLevel->m_bIsOnline) goto label_4; } else { field_D4 = false; - if (m_pLevel->m_bIsMultiplayer) + if (m_pLevel->m_bIsOnline) { label_4: m_fireTicks = 0; @@ -881,7 +882,6 @@ void Entity::animateHurt() ItemEntity* Entity::spawnAtLocation(ItemInstance* itemInstance, float y) { ItemEntity *itemEntity = new ItemEntity(m_pLevel, Vec3(m_pos.x, m_pos.y + y, m_pos.z), itemInstance); - delete(itemInstance); // @TODO: not sure what this does, or is for itemEntity->m_oPos.x = 10; m_pLevel->addEntity(itemEntity); @@ -1016,6 +1016,114 @@ int Entity::queryEntityRenderer() return 0; } +const AABB* Entity::getCollideBox() const +{ + return nullptr; +} + +AABB* Entity::getCollideAgainstBox(Entity* ent) const +{ + return nullptr; +} + +void Entity::handleInsidePortal() +{ +} + +void Entity::handleEntityEvent(int event) +{ +} + +/*void Entity::thunderHit(LightningBolt* bolt) +{ + burn(5); + ++m_fireTicks; + if (m_fireTicks == 0) + m_fireTicks = 300; + +}*/ + +void Entity::load(const CompoundTag& tag) +{ + const ListTag* posTag = tag.getList("Pos"); + const ListTag* motionTag = tag.getList("Motion"); + const ListTag* rotTag = tag.getList("Rotation"); + m_vel.x = motionTag->getFloat(0); + m_vel.y = motionTag->getFloat(1); + m_vel.z = motionTag->getFloat(2); + if (Mth::abs(m_vel.x) > 10.0f) + { + m_vel.x = 0.0f; + } + if (Mth::abs(m_vel.y) > 10.0f) + { + m_vel.y = 0.0f; + } + if (Mth::abs(m_vel.z) > 10.0f) + { + m_vel.z = 0.0f; + } + m_posPrev.x = m_oPos.x = m_pos.x = posTag->getFloat(0); + m_posPrev.y = m_oPos.y = m_pos.y = posTag->getFloat(1); + m_posPrev.z = m_oPos.z = m_pos.z = posTag->getFloat(2); + m_oRot.y = m_rot.y = rotTag->getFloat(0); + m_oRot.x = m_rot.x = rotTag->getFloat(1); + m_distanceFallen = tag.getFloat("FallDistance"); + m_fireTicks = tag.getInt16("Fire"); + m_airSupply = tag.getInt16("Air"); + m_onGround = tag.getBoolean("OnGround"); + setPos(m_pos); + setRot(m_rot); + readAdditionalSaveData(tag); +} + +bool Entity::save(CompoundTag& tag) const +{ + EntityType::ID id = getEncodeId(); + if (m_bRemoved) + return false; + if (id == EntityType::UNKNOWN) + { + LOG_W("Failed to save unknown entity!"); + return false; + } + + tag.putInt32("id", id); + saveWithoutId(tag); + return true; +} + +void Entity::saveWithoutId(CompoundTag& tag) const +{ + tag.put("Pos", ListTagFloatAdder(m_pos.x)(m_pos.y + m_ySlideOffset)(m_pos.z)); + tag.put("Motion", ListTagFloatAdder(m_vel.x)(m_vel.y)(m_vel.z)); + tag.put("Rotation", ListTagFloatAdder(m_rot.y)(m_rot.x)); + tag.putFloat("FallDistance", m_distanceFallen); + tag.putInt16("Fire", m_fireTicks); + tag.putInt16("Air", m_airSupply); + tag.putBoolean("OnGround", m_onGround); + //tag.putInt32("PortalCooldown", m_portalCooldown); + //tag.putBoolean("IsGlobal", m_bIsGlobal); + + /*if (isRide()) + tag.put("LinksTag", saveLinks());*/ + + addAdditionalSaveData(tag); +} + +void Entity::addAdditionalSaveData(CompoundTag& tag) const +{ +} + +void Entity::readAdditionalSaveData(const CompoundTag& tag) +{ +} + +EntityType::ID Entity::getEncodeId() const +{ + return getDescriptor().getEntityType().getId(); +} + bool Entity::operator==(const Entity& other) const { return m_EntityID == other.m_EntityID; diff --git a/source/world/entity/Entity.hpp b/source/world/entity/Entity.hpp index a04724acc..b668fbc1b 100644 --- a/source/world/entity/Entity.hpp +++ b/source/world/entity/Entity.hpp @@ -151,8 +151,19 @@ class Entity virtual void burn(int); virtual void lavaHurt(); virtual int queryEntityRenderer(); + virtual const AABB* getCollideBox() const; + virtual AABB* getCollideAgainstBox(Entity* ent) const; + virtual void handleInsidePortal(); + virtual void handleEntityEvent(int event); + //virtual void thunderHit(LightningBolt*); + void load(const CompoundTag& tag); + bool save(CompoundTag& tag) const; + void saveWithoutId(CompoundTag& tag) const; + virtual void addAdditionalSaveData(CompoundTag& tag) const; + virtual void readAdditionalSaveData(const CompoundTag& tag); // Removed by Mojang. See https://stackoverflow.com/questions/962132/why-is-a-call-to-a-virtual-member-function-in-the-constructor-a-non-virtual-call //virtual void defineSynchedData(); + EntityType::ID getEncodeId() const; const EntityTypeDescriptor& getDescriptor() const { return *m_pDescriptor; } const SynchedEntityData& getEntityData() const { return m_entityData; } @@ -209,11 +220,11 @@ class Entity int m_tickCount; int m_invulnerableTime; int m_airCapacity; - int m_fireTicks; + int16_t m_fireTicks; int m_flameTime; int field_C8; // @NOTE: Render type? (eEntityRenderType) float m_distanceFallen; // Supposed to be protected - int m_airSupply; + int16_t m_airSupply; uint8_t field_D4; bool field_D5; bool field_D6; diff --git a/source/world/entity/EntityFactory.cpp b/source/world/entity/EntityFactory.cpp new file mode 100644 index 000000000..02348707d --- /dev/null +++ b/source/world/entity/EntityFactory.cpp @@ -0,0 +1,79 @@ +#include "EntityFactory.hpp" +#include "MobFactory.hpp" +#include "nbt/CompoundTag.hpp" + +#include "ItemEntity.hpp" +#include "PrimedTnt.hpp" +#include "FallingTile.hpp" +#include "Arrow.hpp" +//#include "Snowball.hpp" +//#include "ThrownEgg.hpp" +//#include "Painting.hpp" + +#define ENTS ENT(ITEM, ItemEntity) \ + ENT(PRIMED_TNT, PrimedTnt) \ + ENT(FALLING_TILE, FallingTile) \ + ENT(ARROW, Arrow) + //ENT(SNOWBALL, Snowball) + //ENT(THROWN_EGG, ThrownEgg) + //ENT(PAINTING, Painting) + +#define ENT(enumType, classType) case EntityType::enumType: return new classType(level); + +Entity* EntityFactory::CreateEntity(EntityType::ID entityType, Level* level) +{ + switch (entityType) + { + ENTS; + default: + LOG_W("Unknown entity type requested: %d", entityType); + return nullptr; + } +} + +Entity* EntityFactory::LoadEntity(const CompoundTag& tag, Level* level) +{ + EntityType::ID entityTypeId = (EntityType::ID)tag.getInt32("id"); + if (entityTypeId < 0) + { + LOG_E("Negative ItemId: %d at EntityFactory::LoadEntity", entityTypeId); + return nullptr; + } + + const EntityTypeDescriptor* entityTypeDescriptor = EntityTypeDescriptor::GetByEntityTypeID(entityTypeId); + if (!entityTypeDescriptor) + { + LOG_E("No EntityTypeDescriptor found for Entity ID: %d in EntityFactory::LoadEntity", entityTypeId); + return nullptr; + } + + Entity* entity = nullptr; + + if (entityTypeDescriptor->hasCategory(EntityCategories::MOB)) + { + entity = MobFactory::CreateMob(entityTypeId, level); + } + else + { + entity = EntityFactory::CreateEntity(entityTypeId, level); + } + + if (entity) + { + entity->load(tag); + + if (entityTypeDescriptor->isType(EntityType::ITEM)) + { + ItemInstance* itemInstance = ((ItemEntity*)entity)->m_pItemInstance; + if (ItemInstance::isNull(itemInstance) || !Item::items[itemInstance->m_itemID]) + { + delete entity; + entity = nullptr; + } + } + } + + return entity; +} + +#undef ENT \ No newline at end of file diff --git a/source/world/entity/EntityFactory.hpp b/source/world/entity/EntityFactory.hpp new file mode 100644 index 000000000..67253ff62 --- /dev/null +++ b/source/world/entity/EntityFactory.hpp @@ -0,0 +1,11 @@ +#pragma once + +#include "EntityType.hpp" +#include "Entity.hpp" + +class EntityFactory +{ +public: + static Entity* CreateEntity(EntityType::ID entityType, Level* level); + static Entity* LoadEntity(const CompoundTag& tag, Level* level); +}; \ No newline at end of file diff --git a/source/world/entity/EntityTypeDescriptor.cpp b/source/world/entity/EntityTypeDescriptor.cpp index 4a107b03d..1416c5e15 100644 --- a/source/world/entity/EntityTypeDescriptor.cpp +++ b/source/world/entity/EntityTypeDescriptor.cpp @@ -1,6 +1,6 @@ #include #include "EntityTypeDescriptor.hpp" -#include "compat/LegacyCPPCompatibility.hpp" +#include "compat/LegacyCPP.hpp" std::map EntityTypeDescriptor::entityTypeIdMap = std::map(); std::map EntityTypeDescriptor::entityTypeNameMap = std::map(); diff --git a/source/world/entity/FallingTile.cpp b/source/world/entity/FallingTile.cpp index 3718c5e91..f72522b8d 100644 --- a/source/world/entity/FallingTile.cpp +++ b/source/world/entity/FallingTile.cpp @@ -8,8 +8,10 @@ #include "FallingTile.hpp" #include "world/level/Level.hpp" +#include "nbt/CompoundTag.hpp" FallingTile::FallingTile(Level* level) : Entity(level), + m_id(TILE_AIR), // Uninitialized by Mojang field_E0(0) { } @@ -63,7 +65,7 @@ void FallingTile::tick() if (!m_onGround) { - if (field_E0 > 100 && !m_pLevel->m_bIsMultiplayer) + if (field_E0 > 100 && !m_pLevel->m_bIsOnline) remove(); return; @@ -83,7 +85,12 @@ void FallingTile::tick() } } -Level* FallingTile::getLevel() +void FallingTile::addAdditionalSaveData(CompoundTag& tag) const { - return m_pLevel; + tag.putInt8("Tile", m_id); } + +void FallingTile::readAdditionalSaveData(const CompoundTag& tag) +{ + m_id = tag.getInt8("Tile"); +} \ No newline at end of file diff --git a/source/world/entity/FallingTile.hpp b/source/world/entity/FallingTile.hpp index 5ba75e41a..0eb11b523 100644 --- a/source/world/entity/FallingTile.hpp +++ b/source/world/entity/FallingTile.hpp @@ -19,8 +19,10 @@ class FallingTile : public Entity float getShadowHeightOffs() const override; bool isPickable() const override; void tick() override; + void addAdditionalSaveData(CompoundTag& tag) const override; + void readAdditionalSaveData(const CompoundTag& tag) override; - Level* getLevel(); + Level* getLevel() { return m_pLevel; } public: int m_id; diff --git a/source/world/entity/ItemEntity.cpp b/source/world/entity/ItemEntity.cpp index 3cf2772a0..61987aad2 100644 --- a/source/world/entity/ItemEntity.cpp +++ b/source/world/entity/ItemEntity.cpp @@ -8,31 +8,28 @@ #include "ItemEntity.hpp" #include "world/level/Level.hpp" +#include "nbt/CompoundTag.hpp" -void ItemEntity::_init(const ItemInstance* itemInstance) +void ItemEntity::_init(ItemInstance* itemInstance) { - field_E0 = 0; - field_E4 = 0; - field_EC = 0; + m_pDescriptor = &EntityTypeDescriptor::item; + field_C8 = RENDER_ITEM; + m_age = 0; + m_throwTime = 0; + m_tickCount = 0; m_health = 5; m_bMakeStepSound = false; // @NOTE: not setting render type - field_E8 = 2 * float(M_PI) * Mth::random(); + m_bobOffs = 2 * float(M_PI) * Mth::random(); setSize(0.25f, 0.25f); m_heightOffset = m_bbHeight * 0.5f; -#ifdef ORIGINAL_CODE - m_pItemInstance = itemInstance != nullptr ? itemInstance : new ItemInstance(); -#else - m_itemInstance = itemInstance != nullptr ? ItemInstance(*itemInstance) : ItemInstance(); -#endif + m_pItemInstance = itemInstance; } -void ItemEntity::_init(const ItemInstance* itemInstance, const Vec3& pos) +void ItemEntity::_init(ItemInstance* itemInstance, const Vec3& pos) { _init(itemInstance); - - field_C8 = RENDER_ITEM; setPos(pos); m_rot.x = 360.0f * Mth::random(); @@ -42,6 +39,11 @@ void ItemEntity::_init(const ItemInstance* itemInstance, const Vec3& pos) m_vel.z = Mth::random() * 0.2f - 0.1f; } +ItemEntity::~ItemEntity() +{ + SAFE_DELETE(m_pItemInstance); +} + void ItemEntity::burn(int damage) { hurt(nullptr, damage); @@ -65,17 +67,17 @@ bool ItemEntity::isInWater() void ItemEntity::playerTouch(Player* player) { // Here, this would give the item to the player, and remove the item entity. - if (field_E4 != 0) + if (m_throwTime != 0) return; Inventory* pInventory = player->m_pInventory; - pInventory->addItem(&m_itemInstance); + pInventory->addItem(*m_pItemInstance); m_pLevel->playSound(this, "random.pop", 0.3f, ((sharedRandom.nextFloat() - sharedRandom.nextFloat()) * 0.7f + 1.0f) * 2.0f); - if (m_itemInstance.m_count <= 0) + if (m_pItemInstance->m_count <= 0) remove(); } @@ -83,8 +85,8 @@ void ItemEntity::tick() { Entity::tick(); - if (field_E4 > 0) - field_E4--; + if (m_throwTime > 0) + m_throwTime--; m_oPos = m_pos; m_vel.y -= 0.04f; @@ -118,14 +120,38 @@ void ItemEntity::tick() if (m_onGround) m_vel.y *= -0.5f; - field_EC++; - field_E0++; + m_tickCount++; + m_age++; // despawn after 5 minutes - if (field_E0 >= 6000) + if (m_age >= 6000) remove(); } +void ItemEntity::addAdditionalSaveData(CompoundTag& tag) const +{ + tag.putInt16("Health", m_health); + tag.putInt16("Age", m_age); + CompoundTag* itemTag = new CompoundTag(); + m_pItemInstance->save(*itemTag); + tag.putCompound("Item", itemTag); +} + +void ItemEntity::readAdditionalSaveData(const CompoundTag& tag) +{ + m_health = tag.getInt16("Health") & 255; + m_age = tag.getInt16("Age"); + + const CompoundTag* itemTag = tag.getCompound("Item"); + if (!itemTag) + { + remove(); + return; + } + m_pItemInstance = new ItemInstance(); + m_pItemInstance->load(*itemTag); +} + void ItemEntity::checkInTile(const Vec3& pos) { TilePos flPos = pos; diff --git a/source/world/entity/ItemEntity.hpp b/source/world/entity/ItemEntity.hpp index e05d91fb2..f77684064 100644 --- a/source/world/entity/ItemEntity.hpp +++ b/source/world/entity/ItemEntity.hpp @@ -13,33 +13,30 @@ class ItemEntity : public Entity { private: - void _init(const ItemInstance* itemInstance = nullptr); - void _init(const ItemInstance* itemInstance, const Vec3& pos); + void _init(ItemInstance* itemInstance = nullptr); + void _init(ItemInstance* itemInstance, const Vec3& pos); public: ItemEntity(Level* level) : Entity(level) { _init(); } - ItemEntity(Level* level, const Vec3& pos, const ItemInstance* itemInstance) : Entity(level) { _init(itemInstance, pos); } + ItemEntity(Level* level, const Vec3& pos, ItemInstance* itemInstance) : Entity(level) { _init(itemInstance, pos); } + ~ItemEntity(); void burn(int damage) override; bool hurt(Entity* pCulprit, int damage) override; bool isInWater() override; void playerTouch(Player*) override; void tick() override; + void addAdditionalSaveData(CompoundTag& tag) const override; + void readAdditionalSaveData(const CompoundTag& tag) override; void checkInTile(const Vec3& pos); public: - // @NOTE: The original code keeps a pointer to something which is not duplicated with a new(), nor does it delete() the instance. - // So either it's leaked, or the code will use invalid memory. -#ifdef ORIGINAL_CODE ItemInstance* m_pItemInstance; -#else - ItemInstance m_itemInstance; -#endif - - int field_E0; - int field_E4; - float field_E8; - int field_EC; + + int m_age; + int m_throwTime; + float m_bobOffs; + int m_tickCount; int m_health; }; diff --git a/source/world/entity/LocalPlayer.cpp b/source/world/entity/LocalPlayer.cpp index db77d7b83..86ad452aa 100644 --- a/source/world/entity/LocalPlayer.cpp +++ b/source/world/entity/LocalPlayer.cpp @@ -8,10 +8,11 @@ #include "LocalPlayer.hpp" #include "client/app/Minecraft.hpp" +#include "nbt/CompoundTag.hpp" int dword_250ADC, dword_250AE0; -LocalPlayer::LocalPlayer(Minecraft* pMinecraft, Level* pLevel, User* pUser, GameType playerGameType, int i) : Player(pLevel, playerGameType) +LocalPlayer::LocalPlayer(Minecraft* pMinecraft, Level* pLevel, User* pUser, GameType playerGameType, int dimensionId) : Player(pLevel, playerGameType) { field_BEC = 0; field_BF0 = Vec3::ZERO; @@ -38,7 +39,7 @@ LocalPlayer::LocalPlayer(Minecraft* pMinecraft, Level* pLevel, User* pUser, Game m_pMinecraft = pMinecraft; m_name = pUser->field_0; - field_BC4 = i; + m_dimension = dimensionId; field_C38 = m_pInventory->getSelectedItemId(); } @@ -60,18 +61,15 @@ void LocalPlayer::aiStep() Player::aiStep(); } -void LocalPlayer::drop(const ItemInstance* pItemInstance, bool b) +void LocalPlayer::drop(const ItemInstance& item, bool randomly) { - if (pItemInstance) + if (m_pMinecraft->isOnlineClient()) { - if (m_pMinecraft->isOnlineClient()) - { - // @TODO: Replicate DropItemPacket to server - } - else - { - Player::drop(pItemInstance, b); - } + // @TODO: Replicate DropItemPacket to server + } + else + { + Player::drop(item, randomly); } } @@ -272,3 +270,17 @@ void LocalPlayer::updateAi() m_bJumping = m_pMoveInput->m_bJumping || m_nAutoJumpFrames > 0; } + +void LocalPlayer::addAdditionalSaveData(CompoundTag& tag) const +{ + Player::addAdditionalSaveData(tag); + + tag.putInt32("Score", getScore()); +} + +void LocalPlayer::readAdditionalSaveData(const CompoundTag& tag) +{ + Player::readAdditionalSaveData(tag); + + m_score = tag.getInt32("Score"); +} \ No newline at end of file diff --git a/source/world/entity/LocalPlayer.hpp b/source/world/entity/LocalPlayer.hpp index de0be882f..38537dc90 100644 --- a/source/world/entity/LocalPlayer.hpp +++ b/source/world/entity/LocalPlayer.hpp @@ -20,15 +20,16 @@ class LocalPlayer : public Player LocalPlayer(Minecraft*, Level*, User*, GameType, int); virtual ~LocalPlayer(); - // TODO: void addAdditonalSaveData(); virtual void animateRespawn() override; virtual void aiStep() override; virtual bool isSneaking() const override; virtual int move(const Vec3& pos) override; virtual void tick() override; virtual void updateAi() override; + virtual void addAdditionalSaveData(CompoundTag& tag) const override; + virtual void readAdditionalSaveData(const CompoundTag& tag) override; virtual bool isLocalPlayer() const override { return true; } - virtual void drop(const ItemInstance* pItemInstance, bool b = false) override; + virtual void drop(const ItemInstance& item, bool randomly = false) override; virtual bool isImmobile() const override; virtual void setPlayerGameType(GameType gameType) override; diff --git a/source/world/entity/Mob.cpp b/source/world/entity/Mob.cpp index 37ffab763..eb24286a1 100644 --- a/source/world/entity/Mob.cpp +++ b/source/world/entity/Mob.cpp @@ -1,4 +1,3 @@ -#include "Mob.hpp" /******************************************************************** Minecraft: Pocket Edition - Decompilation Project Copyright (C) 2023 iProgramInCpp @@ -9,6 +8,7 @@ #include "Mob.hpp" #include "world/level/Level.hpp" +#include "nbt/CompoundTag.hpp" Mob::Mob(Level* pLevel) : Entity(pLevel) { @@ -23,7 +23,7 @@ Mob::Mob(Level* pLevel) : Entity(pLevel) m_hurtTime = 0; m_hurtDuration = 0; m_hurtDir = 0.0f; - field_110 = 0; + m_deathTime = 0; m_attackTime = 0; m_oTilt = 0.0f; m_tilt = 0.0f; @@ -237,7 +237,7 @@ void Mob::baseTick() hurt(nullptr, 1); // Java - /*if (m_bFireImmune || m_pLevel->m_bIsMultiplayer) + /*if (m_bFireImmune || m_pLevel->m_bIsOnline) { m_fireTicks = 0; }*/ @@ -278,8 +278,8 @@ void Mob::baseTick() if (m_health <= 0) { - field_110++; - if (field_110 > 20) + m_deathTime++; + if (m_deathTime > 20) { beforeRemove(); remove(); @@ -316,7 +316,7 @@ bool Mob::isAlive() const bool Mob::hurt(Entity *pAttacker, int damage) { - if (m_pLevel->m_bIsMultiplayer) + if (m_pLevel->m_bIsOnline) return false; m_noActionTime = 0; @@ -430,6 +430,26 @@ void Mob::causeFallDamage(float level) } } +void Mob::addAdditionalSaveData(CompoundTag& tag) const +{ + tag.putInt16("Health", m_health); + tag.putInt16("HurtTime", m_hurtTime); + tag.putInt16("DeathTime", m_deathTime); + tag.putInt16("AttackTime", m_attackTime); +} + +void Mob::readAdditionalSaveData(const CompoundTag& tag) +{ + if (tag.contains("Health")) + m_health = tag.getInt16("Health"); + else + m_health = 10; // Only present in Java, not PE. We don't want peoples' pets dying somehow. + + m_hurtTime = tag.getInt16("HurtTime"); + m_deathTime = tag.getInt16("DeathTime"); + m_attackTime = tag.getInt16("AttackTime"); +} + void Mob::knockback(Entity* pEnt, int a, float x, float z) { float power = Mth::invSqrt(x * x + z * z); @@ -598,7 +618,7 @@ void Mob::die(Entity* pCulprit) field_B69 = true; - if (!m_pLevel->m_bIsMultiplayer) + if (!m_pLevel->m_bIsOnline) dropDeathLoot(); } diff --git a/source/world/entity/Mob.hpp b/source/world/entity/Mob.hpp index 3a6b3c920..c3cd6f097 100644 --- a/source/world/entity/Mob.hpp +++ b/source/world/entity/Mob.hpp @@ -33,6 +33,8 @@ class Mob : public Entity virtual void setSize(float rad, float height) override; virtual void outOfWorld() override; virtual void causeFallDamage(float level) override; + virtual void addAdditionalSaveData(CompoundTag& tag) const override; + virtual void readAdditionalSaveData(const CompoundTag& tag) override; //virtuals virtual void knockback(Entity* pEnt, int a, float x, float z); @@ -103,7 +105,7 @@ class Mob : public Entity int m_hurtTime; int m_hurtDuration; float m_hurtDir; - int field_110; + int m_deathTime; int m_attackTime; float m_oTilt; float m_tilt; diff --git a/source/world/entity/MobFactory.cpp b/source/world/entity/MobFactory.cpp index 12b10a1f9..9d4cdbdd5 100644 --- a/source/world/entity/MobFactory.cpp +++ b/source/world/entity/MobFactory.cpp @@ -1,4 +1,6 @@ #include "MobFactory.hpp" +#include "nbt/CompoundTag.hpp" + #include "Chicken.hpp" #include "Cow.hpp" #include "Pig.hpp" @@ -13,10 +15,10 @@ ENT(COW, Cow) \ ENT(PIG, Pig) \ ENT(SHEEP, Sheep) \ - ENT(CREEPER, Creeper) \ ENT(ZOMBIE, Zombie) \ - ENT(SPIDER, Spider) \ + ENT(CREEPER, Creeper) \ ENT(SKELETON, Skeleton) \ + ENT(SPIDER, Spider) \ //ENT(PIG_ZOMBIE, PigZombie) #define ENT(enumType, classType) case EntityType::enumType: return new classType(level); diff --git a/source/world/entity/Monster.cpp b/source/world/entity/Monster.cpp index 3e9048ea7..039609c42 100644 --- a/source/world/entity/Monster.cpp +++ b/source/world/entity/Monster.cpp @@ -85,4 +85,14 @@ bool Monster::canSpawn() } return false; +} + +void Monster::addAdditionalSaveData(CompoundTag& tag) const +{ + Mob::addAdditionalSaveData(tag); +} + +void Monster::readAdditionalSaveData(const CompoundTag& tag) +{ + Mob::readAdditionalSaveData(tag); } \ No newline at end of file diff --git a/source/world/entity/Monster.hpp b/source/world/entity/Monster.hpp index 51c68bc33..560a79a32 100644 --- a/source/world/entity/Monster.hpp +++ b/source/world/entity/Monster.hpp @@ -15,6 +15,8 @@ class Monster : public PathfinderMob virtual void checkHurtTarget(Entity*, float) override; virtual float getWalkTargetValue(const TilePos& pos) const override; bool canSpawn() override; + void addAdditionalSaveData(CompoundTag& tag) const override; + void readAdditionalSaveData(const CompoundTag& tag) override; protected: int m_attackDamage; diff --git a/source/world/entity/Player.cpp b/source/world/entity/Player.cpp index 9c356d44b..ca50c7a58 100644 --- a/source/world/entity/Player.cpp +++ b/source/world/entity/Player.cpp @@ -8,6 +8,7 @@ #include "Player.hpp" #include "world/level/Level.hpp" +#include "nbt/CompoundTag.hpp" Player::Player(Level* pLevel, GameType playerGameType) : Mob(pLevel) { @@ -18,8 +19,8 @@ Player::Player(Level* pLevel, GameType playerGameType) : Mob(pLevel) m_oBob = 0.0f; m_bob = 0.0f; m_name = ""; - field_BC4 = 0; - m_bHaveRespawnPos = false; + m_dimension = 0; + m_bHasRespawnPos = false; m_destroyingBlock = false; field_C8 = RENDER_HUMANOID; @@ -109,7 +110,7 @@ void Player::resetPos() Entity::resetPos(); m_health = 20; - field_110 = 0; + m_deathTime = 0; } void Player::die(Entity* pCulprit) @@ -120,7 +121,7 @@ void Player::die(Entity* pCulprit) m_vel.y = 0.1f; if (m_name == "Notch") - drop(new ItemInstance(Item::apple), true); + drop(ItemInstance(Item::apple), true); m_pInventory->dropAll(); if (pCulprit) @@ -194,11 +195,11 @@ void Player::aiStep() ItemInstance* Player::getCarriedItem() { - ItemInstance* inst = m_pInventory->getItem(m_pInventory->m_selectedHotbarSlot); - if (inst->m_itemID <= 0) + ItemInstance* item = m_pInventory->getItem(m_pInventory->m_selectedHotbarSlot); + if (ItemInstance::isNull(item)) return nullptr; - return inst; + return item; } void Player::updateAi() @@ -220,6 +221,54 @@ void Player::updateAi() m_attackAnim = m_swingTime / 8.0f; } +void Player::addAdditionalSaveData(CompoundTag& tag) const +{ + Mob::addAdditionalSaveData(tag); + + ListTag* inventoryTag = new ListTag(); + m_pInventory->save(*inventoryTag); + tag.put("Inventory", inventoryTag); + + tag.putInt32("playerGameType", getPlayerGameType()); + tag.putInt32("Dimension", m_dimension); + + // Why would we save the player's sleep state? If they leave the game, just wake them up. + /*tag.putBoolean("Sleeping", m_bSleeping); + tag.putShort("SleepTimer", m_sleepTimer); + if (m_bSleeping) + { + setBedSleepPos(m_pos); + wake(true, true, false); + }*/ + + if (m_bHasRespawnPos) + { + tag.putInt32("SpawnX", m_respawnPos.x); + tag.putInt32("SpawnY", m_respawnPos.y); + tag.putInt32("SpawnZ", m_respawnPos.z); + } +} + +void Player::readAdditionalSaveData(const CompoundTag& tag) +{ + Mob::readAdditionalSaveData(tag); + + // Needs to load before Inventory, since Inventory won't load if Player is in creative mode + if (tag.contains("playerGameType")) + { + setPlayerGameType((GameType)tag.getInt32("playerGameType")); + } + + if (tag.contains("Inventory")) + m_pInventory->load(*tag.getList("Inventory")); + + m_dimension = tag.getInt32("Dimension"); + //m_sleepTimer = tag.getInt32("SleepTimer"); + + if (tag.contains("SpawnX") && tag.contains("SpawnY") && tag.contains("SpawnZ")) + setRespawnPos(TilePos(tag.getInt32("SpawnX"), tag.getInt32("SpawnY"), tag.getInt32("SpawnZ"))); +} + void Player::animateRespawn() { @@ -257,15 +306,15 @@ void Player::displayClientMessage(const std::string& msg) } -void Player::drop(const ItemInstance* pItemInstance, bool b) +void Player::drop(const ItemInstance& item, bool randomly) { - if (ItemInstance::isNull(pItemInstance)) + if (item.isNull()) return; - ItemEntity* pItemEntity = new ItemEntity(m_pLevel, Vec3(m_pos.x, m_pos.y - 0.3f + getHeadHeight(), m_pos.z), pItemInstance); - pItemEntity->field_E4 = 40; + ItemEntity* pItemEntity = new ItemEntity(m_pLevel, Vec3(m_pos.x, m_pos.y - 0.3f + getHeadHeight(), m_pos.z), item.copy()); + pItemEntity->m_throwTime = 40; - if (b) + if (randomly) { float throwPower = 0.5f * m_random.nextFloat(); float throwAngle = m_random.nextFloat(); @@ -330,11 +379,11 @@ void Player::setRespawnPos(const TilePos& pos) { /*if (!pos) { - m_bHaveRespawnPos = false; + m_bHasRespawnPos = false; return; }*/ - m_bHaveRespawnPos = true; + m_bHasRespawnPos = true; m_respawnPos = pos; } diff --git a/source/world/entity/Player.hpp b/source/world/entity/Player.hpp index 980001e8e..45ef9d1de 100644 --- a/source/world/entity/Player.hpp +++ b/source/world/entity/Player.hpp @@ -39,9 +39,10 @@ class Player : public Mob ItemInstance* getCarriedItem() override; virtual bool isImmobile() const override { return m_health <= 0; } virtual void updateAi() override; - + virtual void addAdditionalSaveData(CompoundTag& tag) const override; + virtual void readAdditionalSaveData(const CompoundTag& tag) override; virtual void animateRespawn(); - virtual void drop(const ItemInstance* pItemInstance, bool b = false); + virtual void drop(const ItemInstance& item, bool randomly = false); virtual void startCrafting(const TilePos& pos); virtual void startStonecutting(const TilePos& pos); virtual void startDestroying(); @@ -89,12 +90,12 @@ class Player : public Mob float m_oBob; // field_B9C float m_bob; std::string m_name; - int field_BC4; + int m_dimension; RakNet::RakNetGUID m_guid; //TODO TilePos m_respawnPos; //TODO - bool m_bHaveRespawnPos; + bool m_bHasRespawnPos; //TODO bool m_destroyingBlock; }; diff --git a/source/world/entity/PrimedTnt.cpp b/source/world/entity/PrimedTnt.cpp index fc2321cab..092bd26dd 100644 --- a/source/world/entity/PrimedTnt.cpp +++ b/source/world/entity/PrimedTnt.cpp @@ -8,6 +8,7 @@ #include "PrimedTnt.hpp" #include "world/level/Level.hpp" +#include "nbt/CompoundTag.hpp" void PrimedTnt::_init() { @@ -77,3 +78,13 @@ void PrimedTnt::tick() m_pLevel->addParticle("smoke", Vec3(m_pos.x, m_pos.y + 0.5f, m_pos.z)); } } + +void PrimedTnt::addAdditionalSaveData(CompoundTag& tag) const +{ + tag.putInt8("Fuse", m_fuseTimer); +} + +void PrimedTnt::readAdditionalSaveData(const CompoundTag& tag) +{ + m_fuseTimer = tag.getInt8("Fuse"); +} \ No newline at end of file diff --git a/source/world/entity/PrimedTnt.hpp b/source/world/entity/PrimedTnt.hpp index d7d5e9f96..eb621d094 100644 --- a/source/world/entity/PrimedTnt.hpp +++ b/source/world/entity/PrimedTnt.hpp @@ -21,6 +21,8 @@ class PrimedTnt : public Entity float getShadowHeightOffs() const override; bool isPickable() const override; void tick() override; + void addAdditionalSaveData(CompoundTag& tag) const override; + void readAdditionalSaveData(const CompoundTag& tag) override; void explode(); diff --git a/source/world/entity/Sheep.cpp b/source/world/entity/Sheep.cpp index 624a2d6f2..41528488f 100644 --- a/source/world/entity/Sheep.cpp +++ b/source/world/entity/Sheep.cpp @@ -1,6 +1,6 @@ #include "Sheep.hpp" -//#include "common/Utils.hpp" #include "world/level/Level.hpp" +#include "nbt/CompoundTag.hpp" #define DATA_WOOL_ID (16) @@ -23,6 +23,8 @@ const float Sheep::COLOR[][3] = { {0.10f, 0.10f, 0.10f} }; +const unsigned int Sheep::COLOR_COUNT = sizeof(Sheep::COLOR) / (sizeof(float) * 3); + Sheep::Sheep(Level* pLevel) : Animal(pLevel) { m_pDescriptor = &EntityTypeDescriptor::sheep; @@ -40,7 +42,7 @@ void Sheep::_defineEntityData() bool Sheep::hurt(Entity* pEnt, int damage) { - if (!m_pLevel->m_bIsMultiplayer && !isSheared() && (pEnt != nullptr && pEnt->getDescriptor().hasCategory(EntityCategories::MOB))) + if (!m_pLevel->m_bIsOnline && !isSheared() && (pEnt != nullptr && pEnt->getDescriptor().hasCategory(EntityCategories::MOB))) { setSheared(true); int var3 = 1 + m_random.nextInt(3); @@ -57,6 +59,22 @@ bool Sheep::hurt(Entity* pEnt, int damage) return Mob::hurt(pEnt, damage); } +void Sheep::addAdditionalSaveData(CompoundTag& tag) const +{ + Animal::addAdditionalSaveData(tag); + + tag.putInt8("Sheared", isSheared()); + tag.putInt8("Color", getColor()); +} + +void Sheep::readAdditionalSaveData(const CompoundTag& tag) +{ + Animal::readAdditionalSaveData(tag); + + setSheared(tag.getInt8("Sheared")); + setColor(tag.getInt8("Color")); +} + int Sheep::getColor() const { return m_entityData.get(DATA_WOOL_ID) & 15; @@ -65,7 +83,7 @@ int Sheep::getColor() const void Sheep::setColor(int var1) { int8_t var2 = m_entityData.get(DATA_WOOL_ID); - m_entityData.set(DATA_WOOL_ID, (var2 & 240 | var1 & 15)); + m_entityData.set(DATA_WOOL_ID, ((var2 & 240) | (var1 & 15))); } bool Sheep::isSheared() const diff --git a/source/world/entity/Sheep.hpp b/source/world/entity/Sheep.hpp index b59219ddb..340f49bb4 100644 --- a/source/world/entity/Sheep.hpp +++ b/source/world/entity/Sheep.hpp @@ -6,6 +6,7 @@ class Sheep : public Animal { public: static const float COLOR[][3]; + static const unsigned int COLOR_COUNT; // NumColors on PE, stupid name public: Sheep(Level* pLevel); @@ -18,8 +19,8 @@ class Sheep : public Animal std::string getDeathSound() const override { return "mob.sheep"; } std::string getHurtSound() const override { return "mob.sheep"; } virtual bool hurt(Entity*, int) override; - //TODO: addAdditonalSaveData - //TODO: readAdditionalSaveData + void addAdditionalSaveData(CompoundTag& tag) const override; + void readAdditionalSaveData(const CompoundTag& tag) override; Entity* getBreedOffspring(Animal* pOther) { return new Sheep(m_pLevel); } diff --git a/source/world/gamemode/GameType.hpp b/source/world/gamemode/GameType.hpp index 77becfbeb..f72480981 100644 --- a/source/world/gamemode/GameType.hpp +++ b/source/world/gamemode/GameType.hpp @@ -8,4 +8,25 @@ enum GameType GAME_TYPE_SPECTATOR, GAME_TYPES_MIN = GAME_TYPE_SURVIVAL, GAME_TYPES_MAX = GAME_TYPE_CREATIVE +}; + +class GameTypeConv +{ +public: + static std::string GameTypeToNonLocString(GameType type) + { + switch (type) + { + case GAME_TYPE_SURVIVAL: + return "Survival"; + case GAME_TYPE_CREATIVE: + return "Creative"; + case GAME_TYPE_ADVENTURE: + return "Adventure"; + case GAME_TYPE_SPECTATOR: + return "Spectator"; + default: + return "Undefined"; + } + } }; \ No newline at end of file diff --git a/source/world/item/CameraItem.cpp b/source/world/item/CameraItem.cpp index 3c65eece5..345ec5ff8 100644 --- a/source/world/item/CameraItem.cpp +++ b/source/world/item/CameraItem.cpp @@ -22,7 +22,7 @@ ItemInstance* CameraItem::use(ItemInstance* inst, Level* level, Player* player) { #ifndef ORIGINAL_CODE // prevent players from using this in multiplayer, to prevent a desync of entity IDs - if (level->m_bIsMultiplayer) + if (level->m_bIsOnline) return inst; #endif diff --git a/source/world/item/Inventory.cpp b/source/world/item/Inventory.cpp index dbc12a6a9..be4f9ba9a 100644 --- a/source/world/item/Inventory.cpp +++ b/source/world/item/Inventory.cpp @@ -1,5 +1,6 @@ #include "Inventory.hpp" #include "Item.hpp" +#include "nbt/CompoundTag.hpp" Inventory::Inventory(Player* pPlayer) { @@ -10,9 +11,18 @@ Inventory::Inventory(Player* pPlayer) m_hotbar[i] = -1; } +Inventory::~Inventory() +{ + for (std::vector::iterator it = m_items.begin(); it != m_items.end(); it++) + { + ItemInstance* item = *it; + delete item; + } +} + void Inventory::prepareCreativeInventory() { - m_items.clear(); + clear(); // Original list of items. addCreativeItem(Tile::rock->m_ID); @@ -83,7 +93,7 @@ void Inventory::prepareCreativeInventory() void Inventory::prepareSurvivalInventory() { - m_items.clear(); + clear(); m_items.resize(C_NUM_SURVIVAL_SLOTS); // Add some items for testing @@ -117,40 +127,45 @@ int Inventory::getNumItems() void Inventory::addCreativeItem(int itemID, int auxValue) { - m_items.push_back(ItemInstance(itemID, 1, auxValue)); + m_items.push_back(new ItemInstance(itemID, 1, auxValue)); } void Inventory::clear() { + for (std::vector::iterator it = m_items.begin(); it != m_items.end(); it++) + { + ItemInstance* item = *it; + delete item; + } m_items.clear(); - m_items.resize(C_NUM_SURVIVAL_SLOTS); } // This code, and this function, don't exist in b1.2_02 // "add" exists with these same arguments, which calls "addResource", // but addResource's code is entirely different somehow. Did we write this from scratch? -bool Inventory::addItem(ItemInstance* pInst) +bool Inventory::addItem(ItemInstance& instance) { if (_getGameMode() == GAME_TYPE_CREATIVE) { // Just get rid of the item. - pInst->m_count = 0; + instance.m_count = 0; return true; } // look for an item with the same ID for (int i = 0; i < getNumItems(); i++) { - if (m_items[i].m_itemID != pInst->m_itemID) + ItemInstance* item = m_items[i]; + if (!item || item->m_itemID != instance.m_itemID) continue; - int maxStackSize = m_items[i].getMaxStackSize(); - bool bIsStackedByData = Item::items[pInst->m_itemID]->isStackedByData(); - if (bIsStackedByData && m_items[i].getAuxValue() != pInst->getAuxValue()) + int maxStackSize = item->getMaxStackSize(); + bool bIsStackedByData = instance.getItem()->isStackedByData(); + if (bIsStackedByData && item->getAuxValue() != instance.getAuxValue()) continue; // try to collate. - int combinedItemAmount = pInst->m_count + m_items[i].m_count; + int combinedItemAmount = instance.m_count + item->m_count; int leftover = combinedItemAmount - maxStackSize; if (leftover < 0) @@ -158,28 +173,34 @@ bool Inventory::addItem(ItemInstance* pInst) else combinedItemAmount = C_MAX_AMOUNT; - m_items[i].m_count = combinedItemAmount; - m_items[i].m_popTime = 5; + item->m_count = combinedItemAmount; + item->m_popTime = 5; - pInst->m_count = leftover; + instance.m_count = leftover; if (!bIsStackedByData) - m_items[i].setAuxValue(0); + item->setAuxValue(0); } // If there's nothing leftover: - if (pInst->m_count <= 0) + if (instance.m_count <= 0) return true; // try to add it to an empty slot for (int i = 0; i < getNumItems(); i++) { - if (m_items[i].m_itemID != 0) - continue; + ItemInstance* item = m_items[i]; - m_items[i] = *pInst; - m_items[i].m_popTime = 5; - pInst->m_count = 0; + if (item) + { + if (item->m_itemID != 0) + continue; + delete item; + } + + item = m_items[i] = new ItemInstance(instance); + item->m_popTime = 5; + instance.m_count = 0; return true; } @@ -191,9 +212,11 @@ void Inventory::tick() { for (int i = 0; i < m_items.size(); i++) { - if (!m_items[i].isNull() && m_items[i].m_popTime > 0) + ItemInstance* item = m_items[i]; + + if (!ItemInstance::isNull(item) && item->m_popTime > 0) { - m_items[i].m_popTime--; + item->m_popTime--; } } } @@ -201,7 +224,7 @@ void Inventory::tick() void Inventory::addTestItem(int itemID, int amount, int auxValue) { ItemInstance inst(itemID, amount, auxValue); - addItem(&inst); + addItem(inst); if (inst.m_count != 0) { @@ -215,10 +238,14 @@ ItemInstance* Inventory::getItem(int slotNo) if (slotNo < 0 || slotNo >= int(m_items.size())) return nullptr; - if (m_items[slotNo].m_count <= 0) - m_items[slotNo].m_itemID = 0; + ItemInstance* item = m_items[slotNo]; + if (!item) + return nullptr; + + if (item->m_count <= 0) + item->m_itemID = 0; - return &m_items[slotNo]; + return item; } int Inventory::getQuickSlotItemId(int slotNo) @@ -294,7 +321,8 @@ void Inventory::setQuickSlotIndexByItemId(int slotNo, int itemID) for (int i = 0; i < getNumItems(); i++) { - if (m_items[i].m_itemID == itemID) + ItemInstance* item = m_items[i]; + if (item && item->m_itemID == itemID) { m_hotbar[slotNo] = i; return; @@ -308,7 +336,8 @@ void Inventory::selectItemById(int itemID, int maxHotBarSlot) { for (int i = 0; i < getNumItems(); i++) { - if (m_items[i].m_itemID != itemID) + ItemInstance* item = m_items[i]; + if (!item || item->m_itemID != itemID) continue; selectItem(i, maxHotBarSlot); @@ -327,20 +356,79 @@ int Inventory::getAttackDamage(Entity* pEnt) return pInst->getAttackDamage(pEnt); } -void Inventory::dropAll(bool butNotReally) +void Inventory::dropAll(bool onlyClearContainer) { for (int i = 0; i < getNumItems(); i++) { - ItemInstance* item = &m_items[i]; - if (item->m_count > 0) + ItemInstance* item = m_items[i]; + if (item && item->m_count > 0) { - if (!butNotReally) - m_pPlayer->drop(item->copy(), true); + if (!onlyClearContainer) + m_pPlayer->drop(*item, true); item->m_count = 0; } } } +void Inventory::save(ListTag& tag) const +{ + if (_getGameMode() == GAME_TYPE_CREATIVE) + return; + + for (int i = 0; i < m_items.size(); i++) + { + const ItemInstance* item = m_items[i]; + + if (ItemInstance::isNull(item)) + continue; + + CompoundTag* itemTag = new CompoundTag(); + itemTag->putInt8("Slot", i); + /* On PE, Mojang for some reason limited something saved as a 16-bit signed integer to a 0-255 range. + if (item.getAuxValue() < 0) + { + item.setAuxValue(0); + } + else if (item.getAuxValue > 255) + { + item.setAuxValue(255); + } + */ + item->save(*itemTag); + tag.add(itemTag); + } +} + +void Inventory::load(const ListTag& tag) +{ + if (_getGameMode() == GAME_TYPE_CREATIVE) + return; + + clear(); + m_items.resize(C_NUM_SURVIVAL_SLOTS); + + const std::vector& itemTags = tag.rawView(); + + for (std::vector::const_iterator it = itemTags.begin(); it != itemTags.end(); it++) + { + const CompoundTag* itemTag = (const CompoundTag*)*it; + int slot = itemTag->getInt8("Slot") & 255; + ItemInstance* item = ItemInstance::fromTag(*itemTag); + if (item) + { + if (slot >= 0 && slot < m_items.size()) + { + m_items[slot] = item; + } + + /*if (slot >= 100 && slot < m_armor.size() + 100) + { + m_armor[slot - 100] = item; + }*/ + } + } +} + GameType Inventory::_getGameMode() const { return m_pPlayer->getPlayerGameType(); diff --git a/source/world/item/Inventory.hpp b/source/world/item/Inventory.hpp index 8645ce284..e5e923100 100644 --- a/source/world/item/Inventory.hpp +++ b/source/world/item/Inventory.hpp @@ -4,6 +4,7 @@ #include "world/item/ItemInstance.hpp" #include "world/entity/Player.hpp" #include "world/gamemode/GameType.hpp" +#include "nbt/ListTag.hpp" class Entity; class Player; // in case we're included from Player.hpp @@ -16,6 +17,7 @@ class Inventory { public: Inventory(Player*); + ~Inventory(); void prepareCreativeInventory(); void prepareSurvivalInventory(); @@ -26,7 +28,7 @@ class Inventory void addTestItem(int itemID, int amount, int auxValue = 0); void clear(); - bool addItem(ItemInstance* pInst); + bool addItem(ItemInstance& instance); void tick(); ItemInstance* getItem(int slotNo); @@ -42,17 +44,16 @@ class Inventory int getAttackDamage(Entity*); - void dropAll(bool butNotReally = false); + void dropAll(bool onlyClearContainer = false); - int getSelectedSlotNo() const - { - return m_selectedHotbarSlot; - } + void save(ListTag& tag) const; + void load(const ListTag&); + + int getSelectedSlotNo() const { return m_selectedHotbarSlot; } // v0.2.0 name alias - ItemInstance* getSelected() { - return getSelectedItem(); - } + ItemInstance* getSelected() { return getSelectedItem(); } + private: GameType _getGameMode() const; @@ -62,5 +63,5 @@ class Inventory Player* m_pPlayer; int m_hotbar[C_MAX_HOTBAR_ITEMS]; - std::vector m_items; + std::vector m_items; }; diff --git a/source/world/item/Item.cpp b/source/world/item/Item.cpp index 81454d27a..a69571235 100644 --- a/source/world/item/Item.cpp +++ b/source/world/item/Item.cpp @@ -336,6 +336,11 @@ std::string Item::getName() return getDescriptionId() + ".name"; } +int Item::buildIdAux(int16_t auxValue, const CompoundTag* userData) +{ + return auxValue | (unsigned int)(m_itemID << 16); +} + Item *Item::shovel_iron, *Item::pickAxe_iron, diff --git a/source/world/item/Item.hpp b/source/world/item/Item.hpp index b78bc3b02..a8871c8d3 100644 --- a/source/world/item/Item.hpp +++ b/source/world/item/Item.hpp @@ -9,6 +9,7 @@ #pragma once #include +#include #include "common/Utils.hpp" #include "world/level/Material.hpp" #include "ItemInstance.hpp" @@ -24,6 +25,7 @@ class Entity; class Mob; class Player; class Tile; +class CompoundTag; class Item { @@ -80,6 +82,7 @@ class Item virtual Item* getCraftingRemainingItem(); virtual bool hasCraftingRemainingItem(); virtual std::string getName(); + virtual int buildIdAux(int16_t auxValue, const CompoundTag* userData = nullptr); static void initItems(); diff --git a/source/world/item/ItemInstance.cpp b/source/world/item/ItemInstance.cpp index 762f0a193..14f51c857 100644 --- a/source/world/item/ItemInstance.cpp +++ b/source/world/item/ItemInstance.cpp @@ -9,15 +9,15 @@ #include #include "ItemInstance.hpp" #include "world/tile/Tile.hpp" +#include "nbt/CompoundTag.hpp" void ItemInstance::_init(int itemID, int count, int auxValue) { m_itemID = itemID; m_count = count; m_auxValue = auxValue; + m_userData = nullptr; m_popTime = 0; - - //@BUG? Not using the auxValue. This is problematic in the case of wool and dyes. } ItemInstance::ItemInstance() @@ -60,16 +60,66 @@ ItemInstance::ItemInstance(int itemID, int amount, int auxValue) _init(itemID, amount, auxValue); } +int ItemInstance::getId() const +{ + return m_itemID; + + /* + if (!m_valid) + return -1; + + Item* item = getItem(); + if (item) + return item->m_itemID; + + return 0; + */ +} + +int ItemInstance::getIdAux() const +{ + //if (!m_item) + if (m_itemID <= 0) + return 0; + + return getItem()->buildIdAux(m_auxValue, m_userData); +} + Item* ItemInstance::getItem() const { return Item::items[m_itemID]; } -ItemInstance* ItemInstance::copy() +void ItemInstance::setUserData(CompoundTag* tag) +{ + if (m_userData != tag) + { + if (m_userData) + { + delete m_userData; + } + + m_userData = tag; + } +} + +ItemInstance* ItemInstance::copy() const { return new ItemInstance(m_itemID, m_count, m_auxValue); } +void ItemInstance::set(int inCount) +{ + assert(inCount >= 0); + if (inCount <= getMaxStackSize()) + assert(!"stack too big!"); + + m_count = inCount; + + if (inCount == 0) + setNull(); +} + bool ItemInstance::canDestroySpecial(Tile* tile) { return getItem()->canDestroySpecial(tile); @@ -201,8 +251,7 @@ bool ItemInstance::isNull() const return true; if (m_auxValue != 0 || - m_count != 0 || - m_popTime != 0) + m_count != 0) { return false; } @@ -215,6 +264,46 @@ bool ItemInstance::isNull(const ItemInstance* item) return item == nullptr || item->isNull(); } +void ItemInstance::setNull() +{ + m_count = 0; + m_auxValue = 0; + //m_item = nullptr; + m_itemID = 0; + m_popTime = 0; + if (m_userData) + delete m_userData; + m_userData = nullptr; +} + +void ItemInstance::load(const CompoundTag& tag) +{ + m_itemID = tag.getInt16("id"); + m_count = tag.getInt8("Count"); + m_auxValue = tag.getInt16("Damage"); + + CompoundTag* newTag = nullptr; + + if (tag.contains("tag")) + { + newTag = tag.getCompound("tag")->copy(); + } + + m_userData = newTag; +} + +CompoundTag& ItemInstance::save(CompoundTag& tag) const +{ + tag.putInt16("id", m_itemID); + tag.putInt8("Count", m_count); + tag.putInt16("Damage", getDamageValue()); + + if (hasUserData()) + tag.putCompound("tag", m_userData->copy()); + + return tag; +} + bool ItemInstance::matches(const ItemInstance* a1, const ItemInstance* a2) { if (a1 == a2 && a1 == nullptr) @@ -226,6 +315,20 @@ bool ItemInstance::matches(const ItemInstance* a1, const ItemInstance* a2) return a1 == a2; } +ItemInstance* ItemInstance::fromTag(const CompoundTag& tag) +{ + ItemInstance* item = new ItemInstance(); + item->load(tag); + + if (!Item::items[item->m_itemID]) + { + delete item; + item = nullptr; + } + + return item; +} + bool ItemInstance::operator==(const ItemInstance& other) const { return this->getAuxValue() == other.getAuxValue() && @@ -239,4 +342,22 @@ bool ItemInstance::operator!=(const ItemInstance& other) const return this->getAuxValue() != other.getAuxValue() || this->m_count != other.m_count || this->m_itemID != other.m_itemID; -} \ No newline at end of file +} + +/*ItemInstance::operator bool() const +{ + bool result = false; + if (m_valid) + { + Item* item = getItem(); + if (item) + { + if (!isNull()) + { + return true; + } + } + } + + return result; +}*/ \ No newline at end of file diff --git a/source/world/item/ItemInstance.hpp b/source/world/item/ItemInstance.hpp index 9c27175b7..d3710ba40 100644 --- a/source/world/item/ItemInstance.hpp +++ b/source/world/item/ItemInstance.hpp @@ -19,6 +19,7 @@ class Level; class Entity; class Mob; class Player; +class CompoundTag; class ItemInstance { @@ -35,10 +36,18 @@ class ItemInstance ItemInstance(Tile*, int amount, int auxValue); ItemInstance(int itemID, int amount, int auxValue); + int getId() const; + int getIdAux() const; + int getAuxValue() const { return m_auxValue; } - void setAuxValue(int auxValue) { m_auxValue = auxValue; } // Technically doesn't exist in b1.2_02 + void setAuxValue(int16_t auxValue) { m_auxValue = auxValue; } // Technically doesn't exist in b1.2_02 int getDamageValue() const { return m_auxValue; } + bool hasUserData() const { return m_userData != nullptr; } + const CompoundTag* getUserData() const { return m_userData; } + void setUserData(CompoundTag* tag); + + void set(int inCount); bool canDestroySpecial(Tile*); std::string getDescriptionId(); float getDestroySpeed(Tile*); @@ -61,24 +70,33 @@ class ItemInstance bool useOn(Player*, Level*, const TilePos& pos, Facing::Name face); Item* getItem() const; - ItemInstance* copy(); + ItemInstance* copy() const; // v0.2.0 int getAttackDamage(Entity *pEnt); bool isNull() const; + void setNull(); + + void load(const CompoundTag& tag); + CompoundTag& save(CompoundTag& tag) const; // @NOTE: Won't this be ambiguous with the non-static method? static bool isNull(const ItemInstance*); static bool matches(const ItemInstance*, const ItemInstance*); + static ItemInstance* fromTag(const CompoundTag& tag); bool operator==(const ItemInstance&) const; bool operator!=(const ItemInstance&) const; + //operator bool() const; public: - int m_count; + int16_t m_count; int m_popTime; - int m_itemID; + int16_t m_itemID; private: - int m_auxValue; + int16_t m_auxValue; + CompoundTag* m_userData; + //Item* m_item; // @TODO: replace m_itemID with Item pointer + //bool m_valid; }; diff --git a/source/world/level/Level.cpp b/source/world/level/Level.cpp index 20313c54b..70c2eea3d 100644 --- a/source/world/level/Level.cpp +++ b/source/world/level/Level.cpp @@ -14,10 +14,10 @@ #include "Explosion.hpp" #include "Region.hpp" -Level::Level(LevelStorage* pStor, const std::string& str, int32_t seed, int storageVersion, Dimension *pDimension) +Level::Level(LevelStorage* pStor, const std::string& name, int32_t seed, int storageVersion, Dimension *pDimension) { m_bInstantTicking = false; - m_bIsMultiplayer = false; + m_bIsOnline = false; m_bPostProcessing = false; m_skyDarken = 0; field_30 = 0; @@ -45,9 +45,9 @@ Level::Level(LevelStorage* pStor, const std::string& str, int32_t seed, int stor m_pDimension = new Dimension; if (!pData) - m_levelData = LevelData(seed, str, storageVersion); + m_pLevelData = new LevelData(seed, name, storageVersion); else - m_levelData = *pData; + m_pLevelData = pData; m_pDimension->init(this); @@ -633,7 +633,7 @@ void Level::sendTileUpdated(const TilePos& pos) void Level::neighborChanged(const TilePos& pos, TileID tile) { - if (field_30 || m_bIsMultiplayer) return; + if (field_30 || m_bIsOnline) return; Tile* pTile = Tile::tiles[getTile(pos)]; if (pTile) @@ -941,7 +941,7 @@ bool Level::checkAndHandleWater(const AABB& aabb, const Material* pMtl, Entity* TilePos Level::getSharedSpawnPos() const { - return m_levelData.getSpawn(); + return m_pLevelData->getSpawn(); } TileID Level::getTopTile(const TilePos& pos) const @@ -999,10 +999,10 @@ int Level::getTopSolidBlock(const TilePos& tilePos) const void Level::validateSpawn() { - if (m_levelData.getYSpawn() <= 0) - m_levelData.setYSpawn(C_MAX_Y / 2); + if (m_pLevelData->getYSpawn() <= 0) + m_pLevelData->setYSpawn(C_MAX_Y / 2); - TilePos spawn(m_levelData.getSpawn()); + TilePos spawn(m_pLevelData->getSpawn()); #ifndef ORIGINAL_CODE int nAttempts = 0; #endif @@ -1040,8 +1040,8 @@ void Level::validateSpawn() } while (tile == Tile::invisible_bedrock->m_ID); - m_levelData.setXSpawn(spawn.x); - m_levelData.setZSpawn(spawn.z); + m_pLevelData->setXSpawn(spawn.x); + m_pLevelData->setZSpawn(spawn.z); #ifndef ORIGINAL_CODE return; @@ -1049,14 +1049,14 @@ void Level::validateSpawn() _failure: /* - m_levelData.m_spawnPos.x = C_MAX_CHUNKS_X * 16 / 2; - m_levelData.m_spawnPos.z = C_MAX_CHUNKS_X * 16 / 2; - m_levelData.m_spawnPos.y = C_MAX_Y; + m_pLevelData->m_spawnPos.x = C_MAX_CHUNKS_X * 16 / 2; + m_pLevelData->m_spawnPos.z = C_MAX_CHUNKS_X * 16 / 2; + m_pLevelData->m_spawnPos.y = C_MAX_Y; */ - m_levelData.setSpawn(TilePos(0, 32, 0)); + m_pLevelData->setSpawn(TilePos(0, 32, 0)); - LOG_W("Failed to validate spawn point, using (%d, %d, %d)", m_levelData.getXSpawn(), m_levelData.getYSpawn(), m_levelData.getZSpawn()); + LOG_W("Failed to validate spawn point, using (%d, %d, %d)", m_pLevelData->getXSpawn(), m_pLevelData->getYSpawn(), m_pLevelData->getZSpawn()); return; #endif @@ -1106,7 +1106,7 @@ bool Level::addEntity(Entity* pEnt) //removeEntity(pOldEnt); } - if (!pEnt->isPlayer() && m_bIsMultiplayer) + if (!pEnt->isPlayer() && m_bIsOnline) { LOG_W("Hey, why are you trying to add an non-player entity in a multiplayer world?"); } @@ -1135,13 +1135,20 @@ bool Level::addEntity(Entity* pEnt) return true; } -void Level::loadPlayer(Player* player) +void Level::loadPlayer(Player& player) { - if (!player) return; - - m_levelData.setLoadedPlayerTo(player); + const CompoundTag* tag = m_pLevelData->getLoadedPlayerTag(); + if (tag) + { + player.load(*tag); + m_pLevelData->setLoadedPlayerTag(nullptr); + //addEntity(&player); + } + m_pLevelData->setLoadedPlayerTo(player); - addEntity(player); + // 0.2.1 had us only adding the player if LevelData had a CompoundTag + // who cares if it doesn't? + addEntity(&player); } void Level::prepare() @@ -1151,12 +1158,12 @@ void Level::prepare() void Level::saveLevelData() { - m_pLevelStorage->saveLevelData(&m_levelData); + m_pLevelStorage->saveLevelData(m_pLevelData, &m_players); } void Level::savePlayerData() { - m_pLevelStorage->savePlayerData(&m_levelData, m_players); + m_pLevelStorage->savePlayerData(*m_pLevelData, m_players); } void Level::saveAllChunks() @@ -1164,6 +1171,23 @@ void Level::saveAllChunks() m_pChunkSource->saveAll(); } +void Level::saveGame() +{ + if (m_pLevelStorage) + { + m_pLevelStorage->saveGame(this); + saveLevelData(); + } +} + +void Level::loadEntities() +{ + if (m_pLevelStorage) + { + m_pLevelStorage->loadEntities(this); + } +} + #ifdef ENH_IMPROVED_SAVING void Level::saveUnsavedChunks() { @@ -1199,7 +1223,7 @@ void Level::setInitialSpawn() #endif } - m_levelData.setSpawn(TilePos(spawnX, 64, spawnZ)); + m_pLevelData->setSpawn(TilePos(spawnX, 64, spawnZ)); m_bCalculatingInitialSpawn = false; @@ -1208,11 +1232,11 @@ void Level::setInitialSpawn() _failure: - // m_levelData.setSpawn(C_MAX_CHUNKS_X * 16 / 2, C_MAX_Y, C_MAX_CHUNKS_X * 16 / 2); + // m_pLevelData->setSpawn(C_MAX_CHUNKS_X * 16 / 2, C_MAX_Y, C_MAX_CHUNKS_X * 16 / 2); - m_levelData.setSpawn(TilePos(0, 32, 0)); + m_pLevelData->setSpawn(TilePos(0, 32, 0)); - LOG_W("Failed to validate spawn point, using (%d, %d, %d)", m_levelData.getXSpawn(), m_levelData.getYSpawn(), m_levelData.getZSpawn()); + LOG_W("Failed to validate spawn point, using (%d, %d, %d)", m_pLevelData->getXSpawn(), m_pLevelData->getYSpawn(), m_pLevelData->getZSpawn()); return; #endif @@ -1349,7 +1373,7 @@ void Level::tickPendingTicks(bool b) for (int i = 0; i < size; i++) { const TickNextTickData& t = *m_pendingTicks.begin(); - if (!b && t.m_delay > m_levelData.getTime()) + if (!b && t.m_delay > m_pLevelData->getTime()) break; if (hasChunksAt(t.field_4 - 8, t.field_4 + 8)) diff --git a/source/world/level/Level.hpp b/source/world/level/Level.hpp index 416ba5c4c..26e186c37 100644 --- a/source/world/level/Level.hpp +++ b/source/world/level/Level.hpp @@ -37,16 +37,13 @@ typedef std::vector AABBVector; class Level : public LevelSource { -private: - LevelData m_levelData; - private: // @NOTE: LevelListeners do NOT get updated here - void _setTime(int32_t time) { m_levelData.setTime(time); } + void _setTime(int32_t time) { m_pLevelData->setTime(time); } Player* _getNearestPlayer(const Vec3&, float, bool) const; public: - Level(LevelStorage* pStor, const std::string& str, int32_t seed, int version, Dimension* pDimension = nullptr); + Level(LevelStorage* pStor, const std::string& name, int32_t seed, int storageVersion, Dimension* pDimension = nullptr); ~Level(); // TODO @@ -65,10 +62,10 @@ class Level : public LevelSource int getBrightness(const LightLayer&, const TilePos& pos) const; void setBrightness(const LightLayer&, const TilePos& pos, int brightness); int getSeaLevel() const { return 63; } - int getSeed() const { return m_levelData.getSeed(); } - int32_t getTime() const { return m_levelData.getTime(); } + int getSeed() const { return m_pLevelData->getSeed(); } + int32_t getTime() const { return m_pLevelData->getTime(); } void setTime(int32_t time); - GameType getDefaultGameType() { return m_levelData.getGameType(); } + GameType getDefaultGameType() { return m_pLevelData->getGameType(); } int getHeightmap(const TilePos& pos); bool isDay() const; bool isSkyLit(const TilePos& pos) const; @@ -109,7 +106,7 @@ class Level : public LevelSource TileID getTopTile(const TilePos& pos) const; int getTopTileY(const TilePos& pos) const; int getTopSolidBlock(const TilePos& tilePos) const; - void loadPlayer(Player*); + void loadPlayer(Player&); bool addEntity(Entity*); bool removeEntity(Entity*); void removeEntities(const EntityVector&); @@ -118,8 +115,10 @@ class Level : public LevelSource void saveLevelData(); void savePlayerData(); void saveAllChunks(); + void saveGame(); + void loadEntities(); void setInitialSpawn(); - void setSpawnPos(const TilePos& pos) { m_levelData.setSpawn(pos); } + void setSpawnPos(const TilePos& pos) { m_pLevelData->setSpawn(pos); } void setSpawnSettings(bool a, bool b) { } bool canSeeSky(const TilePos& pos) const; Vec3 getSkyColor(Entity* pEnt, float f) const; @@ -162,7 +161,7 @@ class Level : public LevelSource EntityVector getEntities(Entity* pAvoid, const AABB&) const; BiomeSource* getBiomeSource() const override; LevelStorage* getLevelStorage() const { return m_pLevelStorage; } - const LevelData* getLevelData() const { return &m_levelData; } + const LevelData* getLevelData() const { return m_pLevelData; } AABBVector* getCubes(const Entity* pEnt, const AABB& aabb); std::vector* getLightsToUpdate(); Player* getNearestPlayer(const Entity&, float) const; @@ -180,6 +179,9 @@ class Level : public LevelSource void saveUnsavedChunks(); #endif +private: + LevelData* m_pLevelData; + protected: int m_randValue; int m_addend; @@ -187,7 +189,7 @@ class Level : public LevelSource public: AABBVector m_aabbs; bool m_bInstantTicking; - bool m_bIsMultiplayer; // if the level is controlled externally by a server. NOTE: this might just be called "isOnline" + bool m_bIsOnline; // if the level is controlled externally by a server. bool m_bPostProcessing; EntityVector m_entities; std::vector m_players; diff --git a/source/world/level/levelgen/chunk/LevelChunk.cpp b/source/world/level/levelgen/chunk/LevelChunk.cpp index ac3b8eb32..c3f29fc1e 100644 --- a/source/world/level/levelgen/chunk/LevelChunk.cpp +++ b/source/world/level/levelgen/chunk/LevelChunk.cpp @@ -642,7 +642,7 @@ bool LevelChunk::setTile(const ChunkTilePos& pos, TileID tile) lightGaps(pos); if (tile) { - if (!m_pLevel->m_bIsMultiplayer) + if (!m_pLevel->m_bIsOnline) Tile::tiles[tile]->onPlace(m_pLevel, tilePos); } @@ -709,7 +709,7 @@ bool LevelChunk::setTileAndData(const ChunkTilePos& pos, TileID tile, int data) lightGaps(pos); if (tile) { - if (!m_pLevel->m_bIsMultiplayer) + if (!m_pLevel->m_bIsOnline) Tile::tiles[tile]->onPlace(m_pLevel, tilePos); } diff --git a/source/world/level/levelgen/chunk/RandomLevelSource.cpp b/source/world/level/levelgen/chunk/RandomLevelSource.cpp index 6f2c1beb6..9ced2812c 100644 --- a/source/world/level/levelgen/chunk/RandomLevelSource.cpp +++ b/source/world/level/levelgen/chunk/RandomLevelSource.cpp @@ -17,7 +17,7 @@ const float RandomLevelSource::SNOW_SCALE = 0.3f; float g_timeSpentInPostProcessing = 0; -RandomLevelSource::RandomLevelSource(Level* level, int32_t seed, int x) : +RandomLevelSource::RandomLevelSource(Level* level, int32_t seed, int version) : m_random(seed), m_perlinNoise1(&m_random, 16), m_perlinNoise2(&m_random, 16), diff --git a/source/world/level/path/Node.hpp b/source/world/level/path/Node.hpp index 358c4f9b0..8225360d9 100644 --- a/source/world/level/path/Node.hpp +++ b/source/world/level/path/Node.hpp @@ -8,7 +8,7 @@ #pragma once #include -#include "compat/LegacyCPPCompatibility.hpp" +#include "compat/LegacyCPP.hpp" #include "world/level/TilePos.hpp" struct Node diff --git a/source/world/level/storage/ChunkStorage.cpp b/source/world/level/storage/ChunkStorage.cpp index 559d1cf7e..e82dd9c72 100644 --- a/source/world/level/storage/ChunkStorage.cpp +++ b/source/world/level/storage/ChunkStorage.cpp @@ -17,11 +17,11 @@ LevelChunk* ChunkStorage::load(Level* level, const ChunkPos& pos) return 0; } -void ChunkStorage::save(Level* a, LevelChunk* b) +void ChunkStorage::save(Level* level, LevelChunk* chunk) { } -void ChunkStorage::saveEntities(Level* a, LevelChunk* b) +void ChunkStorage::saveEntities(Level* level, LevelChunk* chunk) { } diff --git a/source/world/level/storage/ChunkStorage.hpp b/source/world/level/storage/ChunkStorage.hpp index 25ce45bf1..ccb42935e 100644 --- a/source/world/level/storage/ChunkStorage.hpp +++ b/source/world/level/storage/ChunkStorage.hpp @@ -10,6 +10,7 @@ #include #include +#include "compat/LegacyCPP.hpp" #include "world/level/levelgen/chunk/ChunkPos.hpp" class Level; @@ -21,7 +22,8 @@ class ChunkStorage virtual ~ChunkStorage(); virtual LevelChunk* load(Level*, const ChunkPos& pos); virtual void save(Level*, LevelChunk*); - virtual void saveEntities(Level*, LevelChunk*); + void saveEntities(Level* level) { saveEntities(level, nullptr); } + virtual void saveEntities(Level* level, LevelChunk* chunk); virtual void saveAll(Level*, std::vector&); virtual void tick(); virtual void flush(); diff --git a/source/world/level/storage/ExternalFileLevelStorage.cpp b/source/world/level/storage/ExternalFileLevelStorage.cpp index 8a57fa59e..ca0aa132e 100644 --- a/source/world/level/storage/ExternalFileLevelStorage.cpp +++ b/source/world/level/storage/ExternalFileLevelStorage.cpp @@ -6,9 +6,15 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ +#include + #include "ExternalFileLevelStorage.hpp" #include "world/level/Level.hpp" #include "GetTime.h" +#include "nbt/CompoundTag.hpp" +#include "nbt/NbtIo.hpp" +#include "network/RakIO.hpp" +#include "world/entity/EntityFactory.hpp" #ifndef DEMO @@ -17,7 +23,9 @@ ExternalFileLevelStorage::ExternalFileLevelStorage(const std::string& a, const std::string& path) : field_8(a), m_levelDirPath(path), - m_timer(0) + m_timer(0), + m_storageVersion(LEVEL_STORAGE_VERSION_DEFAULT), + m_lastEntitySave(-999999) { m_pRegionFile = nullptr; m_pLevel = nullptr; @@ -28,22 +36,32 @@ ExternalFileLevelStorage::ExternalFileLevelStorage(const std::string& a, const s std::string datPlayer = m_levelDirPath + "/" + "player.dat"; m_pLevelData = new LevelData; - if (!readLevelData(datLevel, m_pLevelData)) + if (!readLevelData(datLevel, *m_pLevelData)) { delete m_pLevelData; m_pLevelData = nullptr; return; } - readPlayerData(datPlayer, m_pLevelData); + m_storageVersion = m_pLevelData->getStorageVersion(); + + readPlayerData(datPlayer, *m_pLevelData); } ExternalFileLevelStorage::~ExternalFileLevelStorage() { - if (m_pRegionFile) - delete m_pRegionFile; - if (m_pLevelData) - delete m_pLevelData; + SAFE_DELETE(m_pRegionFile); + SAFE_DELETE(m_pLevelData); +} + +void ExternalFileLevelStorage::_setLevelData(LevelData* levelData) +{ + if (m_pLevelData == levelData) + return; + + SAFE_DELETE(m_pLevelData); + + m_pLevelData = levelData; } LevelData* ExternalFileLevelStorage::prepareLevel(Level* level) @@ -57,20 +75,39 @@ ChunkStorage* ExternalFileLevelStorage::createChunkStorage(Dimension* pDim) return this; } -void ExternalFileLevelStorage::saveLevelData(LevelData* levelData, std::vector& players) +void ExternalFileLevelStorage::saveLevelData(const std::string& levelPath, LevelData* levelData, const std::vector* players) { - // Uncomment this when using level v2 - //levelData->setStorageVersion(2); - writeLevelData(m_levelDirPath + "/" + "level.dat", levelData); - savePlayerData(levelData, players); + std::string pathBase = levelPath + "/"; + std::string pathNew = pathBase + "level.dat_new"; + std::string path = pathBase + "level.dat"; + std::string pathOld = pathBase + "level.dat_old"; + +#ifndef ENH_DISABLE_FORCED_SAVE_UPGRADES + // Forces world to upgrade to new default storage version. + levelData->setStorageVersion(LEVEL_STORAGE_VERSION_DEFAULT); +#endif - SAFE_DELETE(m_pLevelData); + writeLevelData(path, *levelData, players); - m_pLevelData = new LevelData(*levelData); + if (levelData->getStorageVersion() == 1) + { + if (players != nullptr) + savePlayerData(*levelData, *players); + } + + _setLevelData(levelData); } -void ExternalFileLevelStorage::savePlayerData(LevelData* levelData, std::vector& players) +void ExternalFileLevelStorage::saveLevelData(LevelData* levelData, const std::vector* players) { + saveLevelData(m_levelDirPath, levelData, players); +} + +void ExternalFileLevelStorage::savePlayerData(LevelData& levelData, const std::vector& players) +{ + if (levelData.getStorageVersion() > 1) + return; // we shouldn't be saving player.dat files for V2 and greater + if (players.empty()) return; @@ -81,7 +118,7 @@ void ExternalFileLevelStorage::savePlayerData(LevelData* levelData, std::vector< return; } - levelData->m_LocalPlayerData.savePlayer(players[0]); + levelData.m_LocalPlayerData.savePlayer(*players[0]); int nPlayers = 1; fwrite(&nPlayers, sizeof nPlayers, 1, pFile); @@ -92,11 +129,17 @@ void ExternalFileLevelStorage::savePlayerData(LevelData* levelData, std::vector< // @NOTE: No reason to swap elementCount and elementSize here. I understood it the // last time - to check whether the data loaded all the way. However, no checks are // done here. - fwrite(&levelData->m_LocalPlayerData, 1, nSizePD, pFile); + fwrite(&levelData.m_LocalPlayerData, 1, nSizePD, pFile); fclose(pFile); } +void ExternalFileLevelStorage::saveGame(Level* level) +{ + // I don't know why it makes me specify this manually + ChunkStorage::saveEntities(level); +} + void ExternalFileLevelStorage::closeAll() { } @@ -155,6 +198,9 @@ void ExternalFileLevelStorage::tick() save(m_pLevel, pChunk); } + + if (m_timer - m_lastEntitySave > 1200) + saveEntities(m_pLevel, nullptr); } void ExternalFileLevelStorage::flush() @@ -207,6 +253,68 @@ LevelChunk* ExternalFileLevelStorage::load(Level* level, const ChunkPos& pos) return pChunk; } +void ExternalFileLevelStorage::loadEntities(Level* level, LevelChunk* chunk) +{ + m_lastEntitySave = m_timer; + + FILE* pFile = fopen((m_levelDirPath + "/entities.dat").c_str(), "rb"); + if (!pFile) + return; + + char formatId[4]; + fread(formatId, 1, 4, pFile); + int formatVersion; + fread(&formatVersion, 4, 1, pFile); + unsigned int size; + fread(&size, 4, 1, pFile); + + long v6 = ftell(pFile); + fseek(pFile, 0, 2); + long v7 = ftell(pFile); + fseek(pFile, v6, 0); + + if (size <= v7 - v6 && size > 0) + { + uint8_t* data = new uint8_t[size]; + fread(data, 1, size, pFile); + + RakNet::BitStream bs(data, size, false); + RakDataInput dis = RakDataInput(bs); + + CompoundTag* tag = NbtIo::read(dis); + if (tag) + { + if (tag->getId() == Tag::TAG_TYPE_COMPOUND) + { + const ListTag* entitiesTag = tag->getList("Entities"); + if (entitiesTag) + { + const std::vector& entities = entitiesTag->rawView(); + for (std::vector::const_iterator it = entities.begin(); it != entities.end(); it++) + { + const Tag* betterTag = *it; + if (!betterTag || betterTag->getId() != Tag::TAG_TYPE_COMPOUND) + continue; + + Entity* entity = EntityFactory::LoadEntity(*(CompoundTag*)betterTag, level); + if (entity) + level->addEntity(entity); + } + } + } + else + { + delete tag; // not what we want, banish it to the shadow realm + } + } + + if (data) + delete[] data; + } + + fclose(pFile); +} + void ExternalFileLevelStorage::save(Level* level, LevelChunk* chunk) { if (!m_pRegionFile) @@ -238,10 +346,45 @@ void ExternalFileLevelStorage::save(Level* level, LevelChunk* chunk) void ExternalFileLevelStorage::saveEntities(Level* level, LevelChunk* chunk) { - // no op + m_lastEntitySave = m_timer; + //getTimeS(); + ListTag* entitiesTag = new ListTag(); + + const EntityVector* entities = level->getAllEntities(); + for (EntityVector::const_iterator it = entities->begin(); it != entities->end(); it++) + { + const Entity* entity = *it; + CompoundTag* tag = new CompoundTag(); + + if (!entity->save(*tag)) + continue; + + entitiesTag->add(tag); + } + + CompoundTag tag = CompoundTag(); + tag.put("Entities", entitiesTag); + RakNet::BitStream bs; + RakDataOutput dos = RakDataOutput(bs); + NbtIo::write(tag, dos); + + unsigned int size = bs.GetNumberOfBytesUsed(); + + FILE* pFile = fopen((m_levelDirPath + "/entities.dat").c_str(), "wb"); + if (pFile) + { + int formatVersion = 1; // I'm assuming it's a version number + fwrite("ENT", 1, 4, pFile); + fwrite(&formatVersion, 4, 1, pFile); + fwrite(&size, 4, 1, pFile); + fwrite(bs.GetData(), 1, size, pFile); + fclose(pFile); + } + + //getTimeS(); } -bool ExternalFileLevelStorage::readLevelData(const std::string& path, LevelData* pLevelData) +bool ExternalFileLevelStorage::readLevelData(const std::string& path, LevelData& levelData) { FILE* pFile = fopen(path.c_str(), "rb"); if (!pFile) @@ -267,7 +410,14 @@ bool ExternalFileLevelStorage::readLevelData(const std::string& path, LevelData* } RakNet::BitStream bs(data, length, false); - pLevelData->read(bs, version); + if (version == 1) + { + levelData.v1_read(bs, version); + } + else if (version == 2) + { + levelData.read(bs, version); + } SAFE_DELETE_ARRAY(data); fclose(pFile); @@ -275,7 +425,7 @@ bool ExternalFileLevelStorage::readLevelData(const std::string& path, LevelData* return true; } -bool ExternalFileLevelStorage::readPlayerData(const std::string& path, LevelData* pLevelData) +bool ExternalFileLevelStorage::readPlayerData(const std::string& path, LevelData& levelData) { FILE* pFile = fopen(path.c_str(), "rb"); if (!pFile) @@ -292,8 +442,8 @@ bool ExternalFileLevelStorage::readPlayerData(const std::string& path, LevelData if (nPlayers != 1) goto _cleanup; - if (fread(&pLevelData->m_LocalPlayerData, 1, sizeof pLevelData->m_LocalPlayerData, pFile) == size) - pLevelData->m_nPlayers = nPlayers; + if (fread(&levelData.m_LocalPlayerData, 1, sizeof levelData.m_LocalPlayerData, pFile) == size) + levelData.m_nPlayers = nPlayers; fclose(pFile); return true; @@ -303,16 +453,23 @@ bool ExternalFileLevelStorage::readPlayerData(const std::string& path, LevelData return false; } -bool ExternalFileLevelStorage::writeLevelData(const std::string& path, LevelData* pLevelData) +bool ExternalFileLevelStorage::writeLevelData(const std::string& path, const LevelData& levelData, const std::vector* players) { FILE* pFile = fopen(path.c_str(), "wb"); if (!pFile) return false; RakNet::BitStream bs; - pLevelData->write(bs); + if (levelData.getStorageVersion() == 1) + { + levelData.v1_write(bs); + } + else + { + levelData.write(bs, players); + } - int storageVersion = pLevelData->getStorageVersion(); + int storageVersion = levelData.getStorageVersion(); fwrite(&storageVersion, sizeof(int), 1, pFile); int length = bs.GetNumberOfBytesUsed(); diff --git a/source/world/level/storage/ExternalFileLevelStorage.hpp b/source/world/level/storage/ExternalFileLevelStorage.hpp index 8cdc4d2f2..cb3916a77 100644 --- a/source/world/level/storage/ExternalFileLevelStorage.hpp +++ b/source/world/level/storage/ExternalFileLevelStorage.hpp @@ -22,29 +22,36 @@ struct UnsavedLevelChunk LevelChunk* m_pChunk; }; -class ExternalFileLevelStorage : public LevelStorage, ChunkStorage +class ExternalFileLevelStorage : public LevelStorage, public ChunkStorage { public: ExternalFileLevelStorage(const std::string& a, const std::string& path); ~ExternalFileLevelStorage(); +private: + void _setLevelData(LevelData* levelData); + +public: // LevelStorage LevelData* prepareLevel(Level* level) override; ChunkStorage* createChunkStorage(Dimension*) override; - void saveLevelData(LevelData* levelData, std::vector& players) override; - void savePlayerData(LevelData* levelData, std::vector& players) override; + void saveLevelData(const std::string& levelPath, LevelData* levelData, const std::vector* players) override; + void saveLevelData(LevelData* levelData, const std::vector* players) override; + void savePlayerData(LevelData& levelData, const std::vector& players) override; + void saveGame(Level* level) override; void closeAll() override; void tick() override; void flush() override; // ChunkStorage LevelChunk* load(Level* level, const ChunkPos& pos) override; + void loadEntities(Level* level, LevelChunk* chunk) override; void save(Level* level, LevelChunk* chunk) override; void saveEntities(Level* level, LevelChunk* chunk) override; - static bool readLevelData(const std::string& path, LevelData* pLevelData); - static bool readPlayerData(const std::string& path, LevelData* pLevelData); - static bool writeLevelData(const std::string& path, LevelData* pLevelData); + static bool readLevelData(const std::string& path, LevelData& levelData); + static bool readPlayerData(const std::string& path, LevelData& levelData); + static bool writeLevelData(const std::string& path, const LevelData& levelData, const std::vector* players = nullptr); public: std::string field_8; @@ -53,7 +60,9 @@ class ExternalFileLevelStorage : public LevelStorage, ChunkStorage RegionFile* m_pRegionFile; Level* m_pLevel; int m_timer; + unsigned int m_storageVersion; std::list m_unsavedLevelChunks; + int m_lastEntitySave; }; #endif diff --git a/source/world/level/storage/ExternalFileLevelStorageSource.cpp b/source/world/level/storage/ExternalFileLevelStorageSource.cpp index dd761e9a2..dd13acc16 100644 --- a/source/world/level/storage/ExternalFileLevelStorageSource.cpp +++ b/source/world/level/storage/ExternalFileLevelStorageSource.cpp @@ -34,7 +34,7 @@ ExternalFileLevelStorageSource::ExternalFileLevelStorageSource(const std::string m_worldsPath = path + "/games" + "/com.mojang" + "/minecraftWorlds"; } -std::string ExternalFileLevelStorageSource::getName() +std::string ExternalFileLevelStorageSource::getName() const { return "External File Level Storage"; } @@ -136,9 +136,9 @@ void ExternalFileLevelStorageSource::renameLevel(const std::string& oldName, con levelUniqueName = oldName; LevelData ld; - ExternalFileLevelStorage::readLevelData(m_worldsPath + "/" + levelUniqueName + "/" + "level.dat", &ld); + ExternalFileLevelStorage::readLevelData(m_worldsPath + "/" + levelUniqueName + "/" + "level.dat", ld); ld.setLevelName(levelName); - ExternalFileLevelStorage::writeLevelData(m_worldsPath + "/" + levelUniqueName + "/" + "level.dat", &ld); + ExternalFileLevelStorage::writeLevelData(m_worldsPath + "/" + levelUniqueName + "/" + "level.dat", ld); } bool ExternalFileLevelStorageSource::isConvertible(const std::string&) @@ -162,10 +162,10 @@ void ExternalFileLevelStorageSource::addLevelSummaryIfExists(std::vector&) override; void clearAll() override; diff --git a/source/world/level/storage/LevelData.cpp b/source/world/level/storage/LevelData.cpp index aa16440e1..00b78633c 100644 --- a/source/world/level/storage/LevelData.cpp +++ b/source/world/level/storage/LevelData.cpp @@ -7,18 +7,25 @@ ********************************************************************/ #include "LevelData.hpp" +#include "network/RakIO.hpp" +#include "nbt/NbtIo.hpp" #define FORCE_SURVIVAL_MODE (TEST_SURVIVAL_MODE || 0) void LevelData::_init(int32_t seed, int storageVersion) { + m_levelName = std::string(); m_seed = seed; + m_spawnPos = TilePos(128, 64, 128); m_time = 0; m_lastPlayed = 0; m_sizeOnDisk = 0; - field_1C = 0; + m_playerTag = nullptr; + m_dimensionId = 0; + m_gameType = GAME_TYPE_CREATIVE; m_storageVersion = storageVersion; - m_generatorVersion = 1; // pre-0.2.1 versions used storageVersion instead + m_generatorVersion = 0; // pre-0.2.1 versions used storageVersion instead + m_bSpawnMobs = false; m_nPlayers = -1; } @@ -28,9 +35,14 @@ void LevelData::_init(int32_t seed, int storageVersion, const std::string& name) m_levelName = name; } -void LevelData::read(RakNet::BitStream& bs, int storageVersion) +LevelData::~LevelData() { - m_storageVersion = storageVersion; + setPlayerTag(nullptr); +} + +void LevelData::v1_read(RakNet::BitStream& bs, int storageVersion) +{ + setStorageVersion(storageVersion); bs.Read(m_seed); bs.Read(m_spawnPos); bs.Read(m_time); @@ -42,7 +54,7 @@ void LevelData::read(RakNet::BitStream& bs, int storageVersion) m_levelName = std::string(rs.C_String()); } -void LevelData::write(RakNet::BitStream& bs) +void LevelData::v1_write(RakNet::BitStream& bs) const { bs.Write(m_seed); bs.Write(m_spawnPos); @@ -54,60 +66,204 @@ void LevelData::write(RakNet::BitStream& bs) bs.Write(rs); } +void LevelData::read(RakNet::BitStream& bs, int storageVersion) +{ + // Actual PE doesn't call setStorageVersion() at all. + // It did not respect the storageVersion of the Level after LevelData::read() had been called. + // Instead, it relied on LevelData's default storageVersion. This was yet another way of forcing world save upgrades. + setStorageVersion(storageVersion); + + RakDataInput dis = RakDataInput(bs); + CompoundTag* tag = NbtIo::read(dis); + + if (tag) + { + if (tag->getId() == Tag::TAG_TYPE_COMPOUND) + { + loadTagData(*tag); + } + + tag->deleteChildren(); + delete tag; + } +} + +void LevelData::write(RakNet::BitStream& bs, const std::vector* players) const +{ + RakDataOutput dos(bs); + CompoundTag tag; + + if (!players || players->empty()) + tag = createTag(); + else + tag = createTag(*players); + + NbtIo::write(tag, dos); + + tag.deleteChildren(); +} + +CompoundTag LevelData::createTag() const +{ + CompoundTag levelTag; + CompoundTag* playerTag = nullptr; + + if (m_playerTag) + playerTag = m_playerTag->copy(); + + writeTagData(levelTag, playerTag); + + return levelTag; +} + +CompoundTag LevelData::createTag(const std::vector& players) const +{ + CompoundTag levelTag; + CompoundTag* playerTag = nullptr; + + if (!players.empty()) + { + playerTag = new CompoundTag(); + players[0]->saveWithoutId(*playerTag); + } + + writeTagData(levelTag, playerTag); + + return levelTag; +} + +void LevelData::loadTagData(CompoundTag& tag) +{ + setSeed(tag.getInt64("RandomSeed")); + setGameType((GameType)tag.getInt32("GameType")); + + setXSpawn(tag.getInt32("SpawnX")); + setYSpawn(tag.getInt32("SpawnY")); + setZSpawn(tag.getInt32("SpawnZ")); + + setTime(tag.getInt64("Time")); + _setLastPlayed(tag.getInt64("LastPlayed")); + setSizeOnDisk(tag.getInt64("SizeOnDisk")); + setLevelName(tag.getString("LevelName")); + setStorageVersion(tag.getInt32("StorageVersion")); + + setSpawnMobs(getGameType() == GAME_TYPE_SURVIVAL); + + CompoundTag* playerTag = tag.getCompound("Player"); + if (playerTag) + { + setPlayerTag(playerTag); + } +} + +void LevelData::writeTagData(CompoundTag& levelTag, CompoundTag* playerTag) const +{ + CompoundTag& tag = levelTag; + + tag.putInt64("RandomSeed", getSeed()); + tag.putInt32("GameType", getGameType()); + + tag.putInt32("SpawnX", getXSpawn()); + tag.putInt32("SpawnY", getYSpawn()); + tag.putInt32("SpawnZ", getZSpawn()); + + tag.putInt64("Time", getTime()); + tag.putInt64("SizeOnDisk", getSizeOnDisk()); + tag.putInt64("LastPlayed", getEpochTimeS()); + tag.putString("LevelName", getLevelName()); + tag.putInt32("StorageVersion", getStorageVersion()); + tag.putInt32("Platform", 2); // what's 2? why is it only written and not read? not sure... + + if (playerTag) + { + tag.putCompound("Player", playerTag); + } +} + +void LevelData::setLoadedPlayerTag(CompoundTag* playerTag) +{ + if (m_playerTag == playerTag) + return; + + if (m_playerTag) + { + m_playerTag->deleteChildren(); + delete m_playerTag; + } + + m_playerTag = playerTag; +} + +void LevelData::setPlayerTag(const CompoundTag* playerTag) +{ + if (m_playerTag == playerTag) + return; + + if (m_playerTag) + { + m_playerTag->deleteChildren(); + delete m_playerTag; + m_playerTag = nullptr; + } + + if (playerTag) + m_playerTag = playerTag->copy(); +} + GameType LevelData::getGameType() const { #if FORCE_SURVIVAL_MODE return GAME_TYPE_SURVIVAL; #else - return GAME_TYPE_CREATIVE; + return m_gameType; #endif } -void LevelData::setLoadedPlayerTo(Player* player) +void LevelData::setLoadedPlayerTo(Player& player) const { if (m_nPlayers == 1) m_LocalPlayerData.loadPlayer(player); } -void PlayerData::loadPlayer(Player* player) +void PlayerData::loadPlayer(Player& player) const { - player->setPos(Vec3::ZERO); + player.setPos(Vec3::ZERO); - player->m_pos = m_pos; - player->m_oPos = m_pos; - player->m_posPrev = m_pos; - player->m_vel.x = Mth::abs(m_vel.x) > 10.0f ? 0.0f : m_vel.x; - player->m_vel.y = Mth::abs(m_vel.y) > 10.0f ? 0.0f : m_vel.y; - player->m_vel.z = Mth::abs(m_vel.z) > 10.0f ? 0.0f : m_vel.z; + player.m_pos = m_pos; + player.m_oPos = m_pos; + player.m_posPrev = m_pos; + player.m_vel.x = Mth::abs(m_vel.x) > 10.0f ? 0.0f : m_vel.x; + player.m_vel.y = Mth::abs(m_vel.y) > 10.0f ? 0.0f : m_vel.y; + player.m_vel.z = Mth::abs(m_vel.z) > 10.0f ? 0.0f : m_vel.z; // Let the setter do the validation - player->setRot( - player->m_oRot = m_rot + player.setRot( + player.m_oRot = m_rot ); - player->m_distanceFallen = m_distanceFallen; - player->m_fireTicks = field_24; - player->m_airCapacity = field_26; - player->m_onGround = field_28; + player.m_distanceFallen = m_distanceFallen; + player.m_fireTicks = field_24; + player.m_airCapacity = field_26; + player.m_onGround = field_28; // @NOTE: Why are we updating m_pos, m_oPos and m_posPrev above if we do this? - player->setPos(m_pos); + player.setPos(m_pos); // TODO: survival mode stuff for (int i = 0; i < C_MAX_HOTBAR_ITEMS; i++) - player->m_pInventory->setQuickSlotIndexByItemId(i, m_hotbar[i]); + player.m_pInventory->setQuickSlotIndexByItemId(i, m_hotbar[i]); } -void PlayerData::savePlayer(Player* player) +void PlayerData::savePlayer(const Player& player) { - m_pos = player->m_pos; - m_vel = player->m_vel; - m_rot = player->m_rot; - m_distanceFallen = player->m_distanceFallen; - field_24 = player->m_fireTicks; - field_26 = player->m_airCapacity; - field_28 = player->m_onGround; + m_pos = player.m_pos; + m_vel = player.m_vel; + m_rot = player.m_rot; + m_distanceFallen = player.m_distanceFallen; + field_24 = player.m_fireTicks; + field_26 = player.m_airCapacity; + field_28 = player.m_onGround; // TODO: survival mode stuff for (int i = 0; i < C_MAX_HOTBAR_ITEMS; i++) - m_hotbar[i] = player->m_pInventory->getQuickSlotItemId(i); + m_hotbar[i] = player.m_pInventory->getQuickSlotItemId(i); } diff --git a/source/world/level/storage/LevelData.hpp b/source/world/level/storage/LevelData.hpp index 2aebf1707..ade1cfac6 100644 --- a/source/world/level/storage/LevelData.hpp +++ b/source/world/level/storage/LevelData.hpp @@ -14,6 +14,8 @@ #include "world/phys/Vec3.hpp" #include "world/item/Inventory.hpp" +#define LEVEL_STORAGE_VERSION_DEFAULT 2 + struct PlayerData { Vec3 m_pos; @@ -25,27 +27,18 @@ struct PlayerData bool field_28; int m_hotbar[C_MAX_HOTBAR_ITEMS]; - void loadPlayer(Player* player); - void savePlayer(Player* player); + void loadPlayer(Player& player) const; + void savePlayer(const Player& player); }; struct LevelData { private: - int32_t m_seed; - TilePos m_spawnPos; - int32_t m_time; - int m_lastPlayed; - int32_t m_sizeOnDisk; - int field_1C; - int m_storageVersion; - int m_generatorVersion; - std::string m_levelName; - -private: - void _init(int32_t seed = 0, int x = 0); + void _init(int32_t seed = 0, int storageVersion = 0); void _init(int32_t seed, int storageVersion, const std::string& name); + void _setLastPlayed(int lastPlayed) { m_lastPlayed = lastPlayed; } + public: // @TODO: Make private when level v2 is done PlayerData m_LocalPlayerData; @@ -53,50 +46,79 @@ struct LevelData LevelData() { _init(); } LevelData(int32_t seed, const std::string& name, int storageVersion) { _init(seed, storageVersion, name); } + ~LevelData(); + + void v1_read(RakNet::BitStream& bs, int storageVersion); + void v1_write(RakNet::BitStream& bs) const; + void read(RakNet::BitStream& bs, int storageVersion); + void write(RakNet::BitStream& bs, const std::vector* players) const; + CompoundTag createTag() const; + CompoundTag createTag(const std::vector& players) const; - void read(RakNet::BitStream& bs, int d); - void write(RakNet::BitStream& bs); + void loadTagData(CompoundTag& tag); + void writeTagData(CompoundTag& levelTag, CompoundTag* playerTag) const; /* Getters & Setters */ int32_t getSeed() const { return m_seed; } + void setSeed(int32_t seed) { m_seed = seed; } + int getXSpawn() const { return m_spawnPos.x; } + void setXSpawn(int xSpawn) { m_spawnPos.x = xSpawn; } int getYSpawn() const { return m_spawnPos.y; } + void setYSpawn(int ySpawn) { m_spawnPos.y = ySpawn; } int getZSpawn() const { return m_spawnPos.z; } + void setZSpawn(int zSpawn) { m_spawnPos.z = zSpawn; } + const TilePos& getSpawn() const { return m_spawnPos; } - int32_t getTime() const { return m_time; } - int32_t getSizeOnDisk() const { return m_sizeOnDisk; } - //CompoundTag getLoadedPlayerTag(); // Return type may actually be a pointer, not sure + void setSpawn(const TilePos& pos) { m_spawnPos = pos; } - void setSeed(int32_t seed) { m_seed = seed; } - void setXSpawn(int xSpawn) { m_spawnPos.x = xSpawn; } - void setYSpawn(int ySpawn) { m_spawnPos.y = ySpawn; } - void setZSpawn(int zSpawn) { m_spawnPos.z = zSpawn; } + int32_t getTime() const { return m_time; } void setTime(int32_t time) { m_time = time; } + + int32_t getSizeOnDisk() const { return m_sizeOnDisk; } void setSizeOnDisk(int32_t sizeOnDisk) { m_sizeOnDisk = sizeOnDisk; } - void setSpawn(const TilePos& pos) { m_spawnPos = pos; } + const CompoundTag* getLoadedPlayerTag() const { return m_playerTag; } + void setLoadedPlayerTag(CompoundTag* playerTag); + void setPlayerTag(const CompoundTag* playerTag); + + int getDimension() const { return m_dimensionId; } + void setDimension(int dimensionId) { m_dimensionId = dimensionId; } int getGeneratorVersion() const { return m_generatorVersion; } void setGeneratorVersion(int generatorVersion) { m_generatorVersion = generatorVersion; } - int getLastPlayed() const { return m_lastPlayed; } + int32_t getLastPlayed() const { return m_lastPlayed; } // inlined in 0.1.0 demo int getStorageVersion() const { return m_storageVersion; } void setStorageVersion(int storageVersion) { m_storageVersion = storageVersion; } GameType getGameType() const; - void setGameType(GameType gameType) { /* Empty in 0.2.1 */ } + void setGameType(GameType gameType) { m_gameType = gameType; } // Empty and uncalled in 0.2.1 - // @TODO: Not Implemented - bool getSpawnMobs() { return false; } - void setSpawnMobs(bool spawnMobs) { } + bool getSpawnMobs() const { return m_bSpawnMobs; } + void setSpawnMobs(bool spawnMobs) { m_bSpawnMobs = spawnMobs; } std::string getLevelName() const { return m_levelName; } void setLevelName(const std::string& name) { m_levelName = name; } - void setLoadedPlayerTo(Player* player); + void setLoadedPlayerTo(Player& player) const; + +private: + std::string m_levelName; + int32_t m_seed; + TilePos m_spawnPos; + int32_t m_time; + int32_t m_lastPlayed; + int32_t m_sizeOnDisk; + CompoundTag* m_playerTag; + int m_dimensionId; + GameType m_gameType; + int m_storageVersion; + bool m_bSpawnMobs; + int m_generatorVersion; }; diff --git a/source/world/level/storage/LevelStorage.cpp b/source/world/level/storage/LevelStorage.cpp index d3dc3b1c1..882f580df 100644 --- a/source/world/level/storage/LevelStorage.cpp +++ b/source/world/level/storage/LevelStorage.cpp @@ -14,10 +14,17 @@ LevelStorage::~LevelStorage() void LevelStorage::saveLevelData(LevelData* levelData) { - std::vector nothing; - saveLevelData(levelData, nothing); + saveLevelData(levelData, nullptr); } -void LevelStorage::savePlayerData(LevelData* levelData, std::vector& players) +void LevelStorage::savePlayerData(LevelData& levelData, const std::vector& players) { } + +void LevelStorage::saveGame(Level* level) +{ +} + +void LevelStorage::loadEntities(Level* level, LevelChunk* chunk) +{ +} \ No newline at end of file diff --git a/source/world/level/storage/LevelStorage.hpp b/source/world/level/storage/LevelStorage.hpp index ba5d2ec49..3388b6931 100644 --- a/source/world/level/storage/LevelStorage.hpp +++ b/source/world/level/storage/LevelStorage.hpp @@ -22,9 +22,13 @@ class LevelStorage virtual ~LevelStorage(); virtual LevelData* prepareLevel(Level*) = 0; virtual ChunkStorage* createChunkStorage(Dimension*) = 0; - virtual void saveLevelData(LevelData* levelData, std::vector& players) = 0; + virtual void saveLevelData(const std::string& levelPath, LevelData* levelData, const std::vector* players) = 0; + virtual void saveLevelData(LevelData* levelData, const std::vector* players) = 0; virtual void saveLevelData(LevelData* levelData); - virtual void savePlayerData(LevelData* levelData, std::vector& players); + virtual void savePlayerData(LevelData& levelData, const std::vector& players); + virtual void saveGame(Level* level); + void loadEntities(Level* level) { loadEntities(level, nullptr); } + virtual void loadEntities(Level* level, LevelChunk* chunk); virtual void closeAll() = 0; }; diff --git a/source/world/level/storage/LevelStorageSource.cpp b/source/world/level/storage/LevelStorageSource.cpp index 0fe53e8a7..22f5654d5 100644 --- a/source/world/level/storage/LevelStorageSource.cpp +++ b/source/world/level/storage/LevelStorageSource.cpp @@ -16,10 +16,10 @@ void LevelStorageSource::getLevelList(std::vector& vec) { // @TODO: complete mock #ifndef ORIGINAL_CODE - vec.push_back(LevelSummary("Level1", "Level-1", 12345, 1234567)); - vec.push_back(LevelSummary("Level2", "Level-2", 23456, 2345678)); - vec.push_back(LevelSummary("Level3", "Level-3", 34567, 3456789)); - vec.push_back(LevelSummary("Level4", "Level-4", 45678, 4567890)); - vec.push_back(LevelSummary("Level5", "Level-5", 56789, 5678901)); + vec.push_back(LevelSummary("Level1", "Level-1", 12345, 1234567, GAME_TYPE_CREATIVE)); + vec.push_back(LevelSummary("Level2", "Level-2", 23456, 2345678, GAME_TYPE_CREATIVE)); + vec.push_back(LevelSummary("Level3", "Level-3", 34567, 3456789, GAME_TYPE_CREATIVE)); + vec.push_back(LevelSummary("Level4", "Level-4", 45678, 4567890, GAME_TYPE_CREATIVE)); + vec.push_back(LevelSummary("Level5", "Level-5", 56789, 5678901, GAME_TYPE_CREATIVE)); #endif } diff --git a/source/world/level/storage/LevelStorageSource.hpp b/source/world/level/storage/LevelStorageSource.hpp index f6a47d5fc..de2c5841e 100644 --- a/source/world/level/storage/LevelStorageSource.hpp +++ b/source/world/level/storage/LevelStorageSource.hpp @@ -16,19 +16,22 @@ struct LevelSummary std::string m_levelName; int m_lastPlayed; int m_sizeOnDisk; + GameType m_gameType; LevelSummary() { m_lastPlayed = 0; m_sizeOnDisk = 0; + m_gameType = GAME_TYPE_CREATIVE; } - LevelSummary(const std::string& a, const std::string& b, int c, int d) + LevelSummary(const std::string& fileName, const std::string& levelName, int lastPlayed, int sizeOnDisk, GameType gameType) { - m_fileName = a; - m_levelName = b; - m_lastPlayed = c; - m_sizeOnDisk = d; + m_fileName = fileName; + m_levelName = levelName; + m_lastPlayed = lastPlayed; + m_sizeOnDisk = sizeOnDisk; + m_gameType = gameType; } bool operator<(const LevelSummary& b) const @@ -41,7 +44,7 @@ class LevelStorageSource { public: virtual ~LevelStorageSource(); - virtual std::string getName() = 0; + virtual std::string getName() const = 0; virtual LevelStorage* selectLevel(const std::string&, bool) = 0; virtual void getLevelList(std::vector&); virtual void clearAll() = 0; diff --git a/source/world/level/storage/MemoryLevelStorage.cpp b/source/world/level/storage/MemoryLevelStorage.cpp index fd5dfcf75..2aeb39ad3 100644 --- a/source/world/level/storage/MemoryLevelStorage.cpp +++ b/source/world/level/storage/MemoryLevelStorage.cpp @@ -20,7 +20,7 @@ ChunkStorage* MemoryLevelStorage::createChunkStorage(Dimension* pDim) return new MemoryChunkStorage; } -void MemoryLevelStorage::saveLevelData(LevelData* levelData, std::vector& players) +void MemoryLevelStorage::saveLevelData(LevelData* levelData, const std::vector* players) { } diff --git a/source/world/level/storage/MemoryLevelStorage.hpp b/source/world/level/storage/MemoryLevelStorage.hpp index 9bb7a0f61..9242babbc 100644 --- a/source/world/level/storage/MemoryLevelStorage.hpp +++ b/source/world/level/storage/MemoryLevelStorage.hpp @@ -15,7 +15,7 @@ class MemoryLevelStorage : public LevelStorage public: LevelData* prepareLevel(Level*) override; ChunkStorage* createChunkStorage(Dimension*) override; - void saveLevelData(LevelData* levelData, std::vector& players) override; + void saveLevelData(LevelData* levelData, const std::vector* players) override; void saveLevelData(LevelData* levelData) override; void closeAll() override; }; diff --git a/source/world/particle/Particle.hpp b/source/world/particle/Particle.hpp index b8668e9a0..c7f729bdc 100644 --- a/source/world/particle/Particle.hpp +++ b/source/world/particle/Particle.hpp @@ -36,11 +36,10 @@ class Particle : public Entity virtual void render(Tesselator&, float, float, float, float, float, float); virtual int getParticleTexture(); - //TODO: addAdditonalSaveData - //TODO: readAdditionalSaveData - //TODO: _defineEntityData void tick() override; + void addAdditionalSaveData(CompoundTag& tag) const override {} + void readAdditionalSaveData(const CompoundTag& tag) override {} Particle* scale(float); Particle* setPower(float); diff --git a/source/world/phys/Vec2.hpp b/source/world/phys/Vec2.hpp index 4b34d2788..360279792 100644 --- a/source/world/phys/Vec2.hpp +++ b/source/world/phys/Vec2.hpp @@ -10,7 +10,7 @@ #include "common/Mth.hpp" // Needed for when we're missing nullptr in multiple files -#include "compat/LegacyCPPCompatibility.hpp" +#include "compat/LegacyCPP.hpp" class Vec2 { diff --git a/source/world/phys/Vec3.hpp b/source/world/phys/Vec3.hpp index 6e093bcc2..d64c07c55 100644 --- a/source/world/phys/Vec3.hpp +++ b/source/world/phys/Vec3.hpp @@ -10,7 +10,7 @@ #include "common/Mth.hpp" // Needed for when we're missing nullptr in multiple files -#include "compat/LegacyCPPCompatibility.hpp" +#include "compat/LegacyCPP.hpp" struct TilePos; diff --git a/source/world/tile/GrassTile.cpp b/source/world/tile/GrassTile.cpp index 0528549c8..1abbf0a09 100644 --- a/source/world/tile/GrassTile.cpp +++ b/source/world/tile/GrassTile.cpp @@ -65,7 +65,7 @@ void GrassTile::tick(Level* level, const TilePos& pos, Random* random) { // Controls the spread/death of grass. // It's like a full on automata of sorts. :) - if (level->m_bIsMultiplayer) + if (level->m_bIsOnline) return; if (level->getRawBrightness(pos.above()) <= 3 && diff --git a/source/world/tile/LeafTile.cpp b/source/world/tile/LeafTile.cpp index 8d243e5f2..37ada9ee5 100644 --- a/source/world/tile/LeafTile.cpp +++ b/source/world/tile/LeafTile.cpp @@ -239,7 +239,7 @@ void LeafTile::onRemove(Level* level, const TilePos& pos) void LeafTile::tick(Level* level, const TilePos& pos, Random* random) { - if (level->m_bIsMultiplayer) + if (level->m_bIsOnline) return; _tickDecay(level, pos); diff --git a/source/world/tile/SandTile.cpp b/source/world/tile/SandTile.cpp index ad43e4f74..77deb2666 100644 --- a/source/world/tile/SandTile.cpp +++ b/source/world/tile/SandTile.cpp @@ -81,7 +81,7 @@ bool SandTile::isFree(Level* level, const TilePos& pos) void SandTile::tick(Level* level, const TilePos& pos, Random* random) { - if (level->m_bIsMultiplayer) + if (level->m_bIsOnline) return; checkSlide(level, pos); diff --git a/source/world/tile/Tile.cpp b/source/world/tile/Tile.cpp index ba590e2fd..61b78cf9a 100644 --- a/source/world/tile/Tile.cpp +++ b/source/world/tile/Tile.cpp @@ -1040,7 +1040,7 @@ void Tile::spawnResources(Level* pLevel, const TilePos& pos, int data) void Tile::spawnResources(Level* pLevel, const TilePos& pos, int data, float fChance) { - if (pLevel->m_bIsMultiplayer) + if (pLevel->m_bIsOnline) return; int count = getResourceCount(&pLevel->m_random); @@ -1057,9 +1057,9 @@ void Tile::spawnResources(Level* pLevel, const TilePos& pos, int data, float fCh (pLevel->m_random.nextFloat() * 0.7f) + (1.0f - 0.7f) * 0.5f, (pLevel->m_random.nextFloat() * 0.7f) + (1.0f - 0.7f) * 0.5f); - ItemInstance inst(id, 1, getSpawnResourcesAuxValue(data)); - ItemEntity* pEntity = new ItemEntity(pLevel, Vec3(pos) + o, &inst); - pEntity->field_E4 = 10; + ItemInstance* inst = new ItemInstance(id, 1, getSpawnResourcesAuxValue(data)); + ItemEntity* pEntity = new ItemEntity(pLevel, Vec3(pos) + o, inst); + pEntity->m_throwTime = 10; pLevel->addEntity(pEntity); } diff --git a/source/world/tile/TntTile.cpp b/source/world/tile/TntTile.cpp index 48016e5c0..6be58b60a 100644 --- a/source/world/tile/TntTile.cpp +++ b/source/world/tile/TntTile.cpp @@ -36,7 +36,7 @@ int TntTile::getTexture(Facing::Name face) const void TntTile::destroy(Level* level, const TilePos& pos, int data) { // prevent players from using this in multiplayer, to prevent a desync of player IDs - if (level->m_bIsMultiplayer) return; + if (level->m_bIsOnline) return; level->addEntity(new PrimedTnt(level, Vec3(pos) + 0.5f)); } diff --git a/thirdparty/raknet/RakNetDefinesOverrides.h b/thirdparty/raknet/RakNetDefinesOverrides.h index a15fb4f84..892ae3bae 100644 --- a/thirdparty/raknet/RakNetDefinesOverrides.h +++ b/thirdparty/raknet/RakNetDefinesOverrides.h @@ -11,4 +11,4 @@ // USER EDITABLE FILE // Needed for C++03 backwards compatibility -#include "../../compat/LegacyCPPCompatibility.hpp" \ No newline at end of file +#include "../../compat/LegacyCPP.hpp" \ No newline at end of file From 332a83bc3d73a71b0993bfeed69ae2ec5a3bc3d5 Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Sat, 6 Sep 2025 17:28:37 -0700 Subject: [PATCH 019/293] Level Storage Format UI (#181) * Added display for level storage format to bottom-right of world select screen * Added automatic world conversion confirmation screen * Fixed backspace and delete handling for on-screen keyboard Co-authored-by: Brent --- platforms/ios/minecraftpe-Info.plist | 6 +- platforms/ios/minecraftpeViewController.mm | 4 +- .../Configuration/Settings_iOS.xcconfig | 2 +- .../Minecraft.xcodeproj/project.pbxproj | 8 ++ platforms/sdl/base/AppPlatform_sdl_base.cpp | 18 --- platforms/sdl/base/AppPlatform_sdl_base.hpp | 1 - source/CMakeLists.txt | 35 +++--- source/client/app/AppPlatform.cpp | 15 ++- source/client/app/Minecraft.cpp | 22 +++- source/client/app/Minecraft.hpp | 3 +- .../gui/components/RolledSelectionList.cpp | 2 +- source/client/gui/components/TextInputBox.cpp | 106 ++++++++++-------- .../gui/components/WorldSelectionList.cpp | 15 ++- .../client/gui/screens/ConvertWorldScreen.cpp | 24 ++++ .../client/gui/screens/ConvertWorldScreen.hpp | 16 +++ .../client/gui/screens/CreateWorldScreen.cpp | 2 - .../client/gui/screens/SelectWorldScreen.cpp | 9 +- source/client/gui/screens/StartMenuScreen.cpp | 2 - source/common/Util.cpp | 2 +- .../storage/ExternalFileLevelStorage.cpp | 14 ++- .../storage/ExternalFileLevelStorage.hpp | 5 +- .../ExternalFileLevelStorageSource.cpp | 6 +- .../ExternalFileLevelStorageSource.hpp | 2 +- source/world/level/storage/LevelData.hpp | 2 +- .../level/storage/LevelStorageSource.cpp | 10 +- .../level/storage/LevelStorageSource.hpp | 7 +- 26 files changed, 209 insertions(+), 129 deletions(-) create mode 100644 source/client/gui/screens/ConvertWorldScreen.cpp create mode 100644 source/client/gui/screens/ConvertWorldScreen.hpp diff --git a/platforms/ios/minecraftpe-Info.plist b/platforms/ios/minecraftpe-Info.plist index f257e8cdc..ef8fd2e60 100644 --- a/platforms/ios/minecraftpe-Info.plist +++ b/platforms/ios/minecraftpe-Info.plist @@ -5,7 +5,7 @@ CFBundleDevelopmentRegion en CFBundleDisplayName - ReMinecraftPE + ReMCPE CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIconFiles @@ -36,8 +36,6 @@ UIStatusBarHidden - UIViewControllerBasedStatusBarAppearance - UISupportedInterfaceOrientations UIInterfaceOrientationLandscapeLeft @@ -48,5 +46,7 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + UIViewControllerBasedStatusBarAppearance + diff --git a/platforms/ios/minecraftpeViewController.mm b/platforms/ios/minecraftpeViewController.mm index e34e212b0..132bd9732 100644 --- a/platforms/ios/minecraftpeViewController.mm +++ b/platforms/ios/minecraftpeViewController.mm @@ -285,9 +285,7 @@ - (void)initView //[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateDrawSize) name:UIDeviceOrientationDidChangeNotification object:nil]; /*Minecraft *mc = (Minecraft *)app; - mc->selectLevel("TestWorld", "Test", (int)"iOS"); - mc->hostMultiplayer(); - mc->setScreen(new ProgressScreen);*/ + mc->selectLevel("TestWorld", "Test", (int)"iOS");*/ } - (NSInteger)animationFrameInterval diff --git a/platforms/macos/projects/Configuration/Settings_iOS.xcconfig b/platforms/macos/projects/Configuration/Settings_iOS.xcconfig index 42a1a844f..4cf8f6948 100644 --- a/platforms/macos/projects/Configuration/Settings_iOS.xcconfig +++ b/platforms/macos/projects/Configuration/Settings_iOS.xcconfig @@ -18,5 +18,5 @@ SDKROOT = $(SDKROOT_IOS) ARCHS_IOS = armv6 armv7 armv7s arm64 ARCHS = $(ARCHS_IOS) -IPHONEOS_DEPLOYMENT_TARGET = 3.0 // iOS 3.0 +IPHONEOS_DEPLOYMENT_TARGET = 5.0 // iOS 3.0 TARGETED_DEVICE_FAMILY = 1,2 // iPhone/iPad diff --git a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj index b01f8f7e6..3e68c6c60 100644 --- a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj +++ b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj @@ -1216,6 +1216,8 @@ 84CCBC9E2E618C1D00E251AF /* libNBT.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84CCBC452E61849800E251AF /* libNBT.a */; }; 84CCBC9F2E61910500E251AF /* libClient.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84B8AEE72AF188D8008DE93D /* libClient.a */; }; 84CCBCA02E61910500E251AF /* libWorld.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84BF630B2AF1859D008A9995 /* libWorld.a */; }; + 84CED51F2E672826006BC585 /* ConvertWorldScreen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84CED51D2E672826006BC585 /* ConvertWorldScreen.cpp */; }; + 84CED5202E672826006BC585 /* ConvertWorldScreen.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84CED51E2E672826006BC585 /* ConvertWorldScreen.hpp */; }; 84CEF0032AE3C97D006C5829 /* EAGLView.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CEF0022AE3C97D006C5829 /* EAGLView.m */; }; 84D9A30E2AF18EC000B00AD3 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8489B3252A86E4B0004CA8EC /* OpenGL.framework */; }; 84D9A30F2AF18EE700B00AD3 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8489B3252A86E4B0004CA8EC /* OpenGL.framework */; settings = {ATTRIBUTES = (Required, ); }; }; @@ -2875,6 +2877,8 @@ 84CCBC922E61880600E251AF /* EntityFactory.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = EntityFactory.hpp; sourceTree = ""; }; 84CCBC952E61886800E251AF /* RakIO.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RakIO.cpp; sourceTree = ""; }; 84CCBC962E61886800E251AF /* RakIO.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RakIO.hpp; sourceTree = ""; }; + 84CED51D2E672826006BC585 /* ConvertWorldScreen.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConvertWorldScreen.cpp; sourceTree = ""; }; + 84CED51E2E672826006BC585 /* ConvertWorldScreen.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ConvertWorldScreen.hpp; sourceTree = ""; }; 84CEF0012AE3C97D006C5829 /* EAGLView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EAGLView.h; sourceTree = ""; }; 84CEF0022AE3C97D006C5829 /* EAGLView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EAGLView.m; sourceTree = ""; }; 84D6694F2B1EAEBF00B34FC1 /* GlobalDebugSettings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = GlobalDebugSettings.xcconfig; path = ../Configuration/GlobalDebugSettings.xcconfig; sourceTree = ""; }; @@ -3173,6 +3177,8 @@ 840DD59E2AC810620006A435 /* ChatScreen.hpp */, 840DD59F2AC810620006A435 /* ConfirmScreen.cpp */, 840DD5A02AC810620006A435 /* ConfirmScreen.hpp */, + 84CED51D2E672826006BC585 /* ConvertWorldScreen.cpp */, + 84CED51E2E672826006BC585 /* ConvertWorldScreen.hpp */, 840DD5A12AC810620006A435 /* CreateWorldScreen.cpp */, 840DD5A22AC810620006A435 /* CreateWorldScreen.hpp */, 840DD5A32AC810620006A435 /* DeathScreen.cpp */, @@ -5496,6 +5502,7 @@ 84AA8C2B2B32F3F3003F5B82 /* LightUpdate.hpp in Headers */, 84AA8C2D2B32F3F3003F5B82 /* PatchManager.hpp in Headers */, 84AA8C2F2B32F3F3003F5B82 /* RenderChunk.hpp in Headers */, + 84CED5202E672826006BC585 /* ConvertWorldScreen.hpp in Headers */, 84A2FF162DB5B7B70090CE3E /* AssetFile.hpp in Headers */, 84AA8C312B32F3F3003F5B82 /* RenderList.hpp in Headers */, 84AA8C332B32F3F3003F5B82 /* Tesselator.hpp in Headers */, @@ -6729,6 +6736,7 @@ 84B8AEEF2AF1890A008DE93D /* ScrolledSelectionList.cpp in Sources */, 84B8AEF02AF1890A008DE93D /* SmallButton.cpp in Sources */, 84B8AEF12AF1890A008DE93D /* TextInputBox.cpp in Sources */, + 84CED51F2E672826006BC585 /* ConvertWorldScreen.cpp in Sources */, 84B8AEF22AF1890A008DE93D /* WorldSelectionList.cpp in Sources */, 84B8AEF32AF1890A008DE93D /* Gui.cpp in Sources */, 84B8AEF42AF1890A008DE93D /* GuiComponent.cpp in Sources */, diff --git a/platforms/sdl/base/AppPlatform_sdl_base.cpp b/platforms/sdl/base/AppPlatform_sdl_base.cpp index dcbecc134..cb28389c1 100644 --- a/platforms/sdl/base/AppPlatform_sdl_base.cpp +++ b/platforms/sdl/base/AppPlatform_sdl_base.cpp @@ -74,24 +74,6 @@ void AppPlatform_sdl_base::initSoundSystem() } } -std::string AppPlatform_sdl_base::getDateString(int time) -{ - time_t tt = time; - struct tm t; -#ifdef _WIN32 - gmtime_s(&t, &tt); -#else - gmtime_r(&tt, &t); -#endif - - // Format String - char buf[2048]; - strftime(buf, sizeof buf, "%b %d %Y %H:%M:%S", &t); - - // Return - return std::string(buf); -} - void AppPlatform_sdl_base::setIcon(const Texture& icon) { if (!icon.m_pixels) diff --git a/platforms/sdl/base/AppPlatform_sdl_base.hpp b/platforms/sdl/base/AppPlatform_sdl_base.hpp index 7fe614cef..4904edae6 100644 --- a/platforms/sdl/base/AppPlatform_sdl_base.hpp +++ b/platforms/sdl/base/AppPlatform_sdl_base.hpp @@ -28,7 +28,6 @@ class AppPlatform_sdl_base : public AppPlatform Texture loadTexture(const std::string& path, bool bIsRequired = false) override = 0; int getUserInputStatus() override; SoundSystem* const getSoundSystem() const override { return m_pSoundSystem; } - std::string getDateString(int time) override; // Also add these to allow proper turning within the game. void setMouseGrabbed(bool b) override; diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index d8c9ad044..e6b5eff09 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -4,7 +4,7 @@ project(reminecraftpe-core) # Build add_library(reminecraftpe-core STATIC common/CThread.cpp - common/DataIO.cpp + common/DataIO.cpp common/Logger.cpp common/Matrix.cpp common/Mth.cpp @@ -70,6 +70,7 @@ add_library(reminecraftpe-core STATIC client/gui/Screen.cpp client/gui/screens/OptionsScreen.cpp client/gui/screens/StartMenuScreen.cpp + client/gui/screens/ConvertWorldScreen.cpp client/gui/screens/CreateWorldScreen.cpp client/gui/screens/DirectConnectScreen.cpp client/gui/screens/DisconnectionScreen.cpp @@ -138,21 +139,21 @@ add_library(reminecraftpe-core STATIC client/player/input/TouchscreenInput_TestFps.cpp client/player/input/UnifiedTurnBuild.cpp client/network/ClientSideNetworkHandler.cpp - nbt/CompoundTag.cpp - nbt/DoubleTag.cpp - nbt/EndTag.cpp - nbt/FloatTag.cpp - nbt/Int8ArrayTag.cpp - nbt/Int8Tag.cpp - nbt/Int16Tag.cpp - nbt/Int32ArrayTag.cpp - nbt/Int32Tag.cpp - nbt/Int64ArrayTag.cpp - nbt/Int64Tag.cpp - nbt/ListTag.cpp - nbt/NbtIo.cpp - nbt/StringTag.cpp - nbt/Tag.cpp + nbt/CompoundTag.cpp + nbt/DoubleTag.cpp + nbt/EndTag.cpp + nbt/FloatTag.cpp + nbt/Int8ArrayTag.cpp + nbt/Int8Tag.cpp + nbt/Int16Tag.cpp + nbt/Int32ArrayTag.cpp + nbt/Int32Tag.cpp + nbt/Int64ArrayTag.cpp + nbt/Int64Tag.cpp + nbt/ListTag.cpp + nbt/NbtIo.cpp + nbt/StringTag.cpp + nbt/Tag.cpp network/packets/UpdateBlockPacket.cpp network/packets/RequestChunkPacket.cpp network/packets/PlayerEquipmentPacket.cpp @@ -206,7 +207,7 @@ add_library(reminecraftpe-core STATIC world/entity/WaterAnimal.cpp world/entity/Monster.cpp world/entity/Rocket.cpp - world/entity/EntityFactory.cpp + world/entity/EntityFactory.cpp world/entity/MobFactory.cpp world/entity/Chicken.cpp world/entity/Cow.cpp diff --git a/source/client/app/AppPlatform.cpp b/source/client/app/AppPlatform.cpp index 0613cff5a..b102a6b73 100644 --- a/source/client/app/AppPlatform.cpp +++ b/source/client/app/AppPlatform.cpp @@ -55,7 +55,20 @@ void AppPlatform::finish() std::string AppPlatform::getDateString(int time) { - return ""; + time_t tt = time; + struct tm t; +#ifdef _WIN32 + gmtime_s(&t, &tt); +#else + gmtime_r(&tt, &t); +#endif + + // Format String + char buf[2048]; + strftime(buf, sizeof buf, "%b %d %Y %H:%M:%S", &t); + + // Return + return std::string(buf); } // ??? AppPlatform::getOptionStrings() diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp index 05706f409..ffd0b2d5f 100644 --- a/source/client/app/Minecraft.cpp +++ b/source/client/app/Minecraft.cpp @@ -12,6 +12,8 @@ #include "client/gui/screens/RenameMPLevelScreen.hpp" #include "client/gui/screens/SavingWorldScreen.hpp" #include "client/gui/screens/DeathScreen.hpp" +#include "client/gui/screens/ProgressScreen.hpp" +#include "client/gui/screens/ConvertWorldScreen.hpp" #include "network/ServerSideNetworkHandler.hpp" #include "client/network/ClientSideNetworkHandler.hpp" @@ -1145,15 +1147,29 @@ void Minecraft::setLevel(Level* pLevel, const std::string& text, LocalPlayer* pL } } -void Minecraft::selectLevel(const std::string& levelDir, const std::string& levelName, int c) +void Minecraft::selectLevel(const LevelSummary& ls, bool forceConversion) { - LevelStorage* pStor = m_pLevelStorageSource->selectLevel(levelDir, false); + if (ls.m_storageVersion != LEVEL_STORAGE_VERSION_DEFAULT && !forceConversion) + { + setScreen(new ConvertWorldScreen(ls)); + return; + } + + selectLevel(ls.m_fileName, ls.m_levelName, 0, forceConversion); +} + +void Minecraft::selectLevel(const std::string& levelDir, const std::string& levelName, int32_t seed, bool forceConversion) +{ + LevelStorage* pStor = m_pLevelStorageSource->selectLevel(levelDir, false, forceConversion); Dimension* pDim = Dimension::getNew(0); - m_pLevel = new Level(pStor, levelName, c, LEVEL_STORAGE_VERSION_DEFAULT, pDim); + m_pLevel = new Level(pStor, levelName, seed, LEVEL_STORAGE_VERSION_DEFAULT, pDim); setLevel(m_pLevel, "Generating level", nullptr); field_D9C = 1; + + hostMultiplayer(); + setScreen(new ProgressScreen); } const char* Minecraft::getProgressMessage() diff --git a/source/client/app/Minecraft.hpp b/source/client/app/Minecraft.hpp index 28e8fc252..7857d752c 100644 --- a/source/client/app/Minecraft.hpp +++ b/source/client/app/Minecraft.hpp @@ -46,7 +46,8 @@ class Minecraft : public App void saveOptions(); void handleBuildAction(const BuildActionIntention& action); bool isLevelGenerated() const; - void selectLevel(const std::string&, const std::string&, int); + void selectLevel(const LevelSummary& ls, bool forceConversion = false); + void selectLevel(const std::string&, const std::string&, int, bool forceConversion = false); void setLevel(Level*, const std::string&, LocalPlayer*); bool pauseGame(); bool resumeGame(); diff --git a/source/client/gui/components/RolledSelectionList.cpp b/source/client/gui/components/RolledSelectionList.cpp index 729111c54..96bc3e3d6 100644 --- a/source/client/gui/components/RolledSelectionList.cpp +++ b/source/client/gui/components/RolledSelectionList.cpp @@ -202,7 +202,7 @@ void RolledSelectionList::render(int mouseX, int mouseY, float f) float right = itemX + width; float up = float(field_1C) / 2.0f - 48.0f - 4.0f; - float dn = float(field_1C) / 2.0f + 56.0f - 4.0f; + float dn = float(field_1C) / 2.0f + 48.0f - 4.0f; t.vertexUV(itemX - 2, up, 0.0f, 0.0f, 0.0f); t.vertexUV(itemX - 2, dn, 0.0f, 1.0f, 0.0f); diff --git a/source/client/gui/components/TextInputBox.cpp b/source/client/gui/components/TextInputBox.cpp index 260e36dff..47b35e99d 100644 --- a/source/client/gui/components/TextInputBox.cpp +++ b/source/client/gui/components/TextInputBox.cpp @@ -173,41 +173,11 @@ void TextInputBox::keyPressed(int key) switch (key) { case AKEYCODE_DEL: { - // Backspace - if (m_text.empty()) - { - return; - } - if (m_insertHead <= 0) - { - return; - } - if (m_insertHead > int(m_text.size())) - { - m_insertHead = int(m_text.size()); - } - m_text.erase(m_text.begin() + m_insertHead - 1, m_text.begin() + m_insertHead); - m_insertHead--; - recalculateScroll(); - break; + charPressed('\b'); } case AKEYCODE_FORWARD_DEL: { - // Delete - if (m_text.empty()) - { - return; - } - if (m_insertHead < 0) - { - return; - } - if (m_insertHead >= int(m_text.size())) - { - return; - } - m_text.erase(m_text.begin() + m_insertHead, m_text.begin() + m_insertHead + 1); - break; + charPressed(AKEYCODE_FORWARD_DEL); } case AKEYCODE_ARROW_LEFT: { @@ -307,20 +277,64 @@ void TextInputBox::charPressed(int k) if (!m_bFocused) return; - // Ignore Unprintable Characters - if (k == '\n' || k < ' ' || k > '~') - return; - - // Check Max Length - if (m_maxLength != -1 && int(m_text.length()) >= m_maxLength) - { - return; - } - - // Insert - m_text.insert(m_text.begin() + m_insertHead, k); - m_insertHead++; - recalculateScroll(); + switch (k) { + case '\b': + { + // Backspace + if (m_text.empty()) + { + return; + } + if (m_insertHead <= 0) + { + return; + } + if (m_insertHead > int(m_text.size())) + { + m_insertHead = int(m_text.size()); + } + m_text.erase(m_text.begin() + m_insertHead - 1, m_text.begin() + m_insertHead); + m_insertHead--; + recalculateScroll(); + break; + } + case AKEYCODE_FORWARD_DEL: + { + // Delete + if (m_text.empty()) + { + return; + } + if (m_insertHead < 0) + { + return; + } + if (m_insertHead >= int(m_text.size())) + { + return; + } + m_text.erase(m_text.begin() + m_insertHead, m_text.begin() + m_insertHead + 1); + break; + } + default: + { + // Ignore Unprintable Characters + if (k == '\n' || k < ' ' || k > '~') + return; + + // Check Max Length + if (m_maxLength != -1 && int(m_text.length()) >= m_maxLength) + { + return; + } + + // Insert + m_text.insert(m_text.begin() + m_insertHead, k); + m_insertHead++; + recalculateScroll(); + break; + } + } } constexpr int PADDING = 5; diff --git a/source/client/gui/components/WorldSelectionList.cpp b/source/client/gui/components/WorldSelectionList.cpp index 307c5f350..4c13dff90 100644 --- a/source/client/gui/components/WorldSelectionList.cpp +++ b/source/client/gui/components/WorldSelectionList.cpp @@ -135,6 +135,9 @@ void WorldSelectionList::touched() void WorldSelectionList::renderItem(int index, int xPos, int yPos, int width, Tesselator& t) { + int yPadding = -4; + yPos += yPadding; // Move up + int xCenter = xPos + m_itemWidth / 2; float mult = Mth::Max(1.1f - 0.0055f * float(abs(field_18 / 2 - xCenter)), 0.2f); if (mult > 1.0f) @@ -145,13 +148,16 @@ void WorldSelectionList::renderItem(int index, int xPos, int yPos, int width, Te std::vector details = m_vvs[index]; + int x = xCenter + 5 - m_itemWidth / 2; // Draw name - drawString(m_pMinecraft->m_pFont, details[0], xCenter + 5 - m_itemWidth / 2, yPos + 50, color1); + drawString(m_pMinecraft->m_pFont, details[0], x, yPos + 50 + yPadding, color1); // Draw other details - for (unsigned int i = 1; i < details.size(); i++) + for (unsigned int i = 1; i < details.size()-1; i++) { - drawString(m_pMinecraft->m_pFont, details[i], xCenter + 5 - m_itemWidth / 2, yPos + (50 + (10 * i)), color2); + drawString(m_pMinecraft->m_pFont, details[i], x, yPos + (50 + yPadding + (10 * i)), color2); } + // Draw storage version + drawString(m_pMinecraft->m_pFont, details[details.size()-1], xCenter + 42, yPos + (50 + yPadding + (10 * 3)), color2); m_pMinecraft->m_pTextures->loadAndBindTexture(m_previewImages[index]); @@ -190,6 +196,9 @@ void WorldSelectionList::commit() vs.push_back(m_pMinecraft->platform()->getDateString(item.m_lastPlayed)); vs.push_back(item.m_fileName); vs.push_back(GameTypeConv::GameTypeToNonLocString(item.m_gameType)); + std::stringstream ss; + ss << "V" << item.m_storageVersion; + vs.push_back(ss.str()); m_vvs.push_back(vs); } } diff --git a/source/client/gui/screens/ConvertWorldScreen.cpp b/source/client/gui/screens/ConvertWorldScreen.cpp new file mode 100644 index 000000000..0ef6b47ed --- /dev/null +++ b/source/client/gui/screens/ConvertWorldScreen.cpp @@ -0,0 +1,24 @@ +#include "ConvertWorldScreen.hpp" + +ConvertWorldScreen::ConvertWorldScreen(const LevelSummary& level) : +ConfirmScreen(nullptr, + "A new world storage format is available!", + "Would you like to convert '" + level.m_levelName + "'?", + "Convert", "Don't Convert", 0) +{ + m_level = level; +} + +void ConvertWorldScreen::postResult(bool b) +{ + if (b) + { + // Convert + m_pMinecraft->selectLevel(m_level, true); + } + else + { + // Don't Convert + m_pMinecraft->selectLevel(m_level.m_fileName, m_level.m_levelName, 0, false); + } +} diff --git a/source/client/gui/screens/ConvertWorldScreen.hpp b/source/client/gui/screens/ConvertWorldScreen.hpp new file mode 100644 index 000000000..32cb54980 --- /dev/null +++ b/source/client/gui/screens/ConvertWorldScreen.hpp @@ -0,0 +1,16 @@ +#pragma once + +#include "ConfirmScreen.hpp" +#include "world/level/storage/LevelStorageSource.hpp" + +class ConvertWorldScreen : public ConfirmScreen +{ +public: + ConvertWorldScreen(const LevelSummary& level); + + void postResult(bool b) override; + +private: + LevelSummary m_level; +}; + diff --git a/source/client/gui/screens/CreateWorldScreen.cpp b/source/client/gui/screens/CreateWorldScreen.cpp index 79c4a2c00..029a21ad6 100644 --- a/source/client/gui/screens/CreateWorldScreen.cpp +++ b/source/client/gui/screens/CreateWorldScreen.cpp @@ -126,8 +126,6 @@ void CreateWorldScreen::buttonClicked(Button* pButton) } m_pMinecraft->selectLevel(levelUniqueName, levelNickname, seed); - m_pMinecraft->hostMultiplayer(); - m_pMinecraft->setScreen(new ProgressScreen); } } diff --git a/source/client/gui/screens/SelectWorldScreen.cpp b/source/client/gui/screens/SelectWorldScreen.cpp index 2be55b6d5..6b1f5dc89 100644 --- a/source/client/gui/screens/SelectWorldScreen.cpp +++ b/source/client/gui/screens/SelectWorldScreen.cpp @@ -9,8 +9,8 @@ #include "SelectWorldScreen.hpp" #include "DeleteWorldScreen.hpp" #include "CreateWorldScreen.hpp" -#include "ProgressScreen.hpp" #include "StartMenuScreen.hpp" +#include "ProgressScreen.hpp" #include "common/Util.hpp" SelectWorldScreen::SelectWorldScreen() : @@ -130,8 +130,6 @@ void SelectWorldScreen::tick() } m_pMinecraft->selectLevel(levelUniqueName, levelNickname, seed); - m_pMinecraft->hostMultiplayer(); - m_pMinecraft->setScreen(new ProgressScreen); // @BUG: Use of deallocated memory. SetScreen frees us #ifdef ORIGINAL_CODE @@ -144,10 +142,7 @@ void SelectWorldScreen::tick() m_pWorldSelectionList->tick(); if (m_pWorldSelectionList->field_90) { - LevelSummary& ls = m_pWorldSelectionList->m_levelSummary; - m_pMinecraft->selectLevel(ls.m_fileName, ls.m_levelName, 0); - m_pMinecraft->hostMultiplayer(); - m_pMinecraft->setScreen(new ProgressScreen); + m_pMinecraft->selectLevel(m_pWorldSelectionList->m_levelSummary); return; } diff --git a/source/client/gui/screens/StartMenuScreen.cpp b/source/client/gui/screens/StartMenuScreen.cpp index 5156523d0..66da953a2 100644 --- a/source/client/gui/screens/StartMenuScreen.cpp +++ b/source/client/gui/screens/StartMenuScreen.cpp @@ -405,8 +405,6 @@ void StartMenuScreen::buttonClicked(Button* pButton) { #if defined(DEMO) m_pMinecraft->selectLevel("_DemoLevel", "_DemoLevel", int(getEpochTimeS())); - m_pMinecraft->hostMultiplayer(); - m_pMinecraft->setScreen(new ProgressScreen); #else m_pMinecraft->setScreen(new SelectWorldScreen); #endif diff --git a/source/common/Util.cpp b/source/common/Util.cpp index 38fafba74..fcc4cb861 100644 --- a/source/common/Util.cpp +++ b/source/common/Util.cpp @@ -52,7 +52,7 @@ std::string Util::vformat(const char *fmt, va_list argPtr) vsnprintf(str, sizeof(str), fmt, argPtr); - return std::string(str); + return std::string(str, sizeof(str)); } std::string Util::format(const char *fmt, ...) diff --git a/source/world/level/storage/ExternalFileLevelStorage.cpp b/source/world/level/storage/ExternalFileLevelStorage.cpp index ca0aa132e..2136daec9 100644 --- a/source/world/level/storage/ExternalFileLevelStorage.cpp +++ b/source/world/level/storage/ExternalFileLevelStorage.cpp @@ -20,12 +20,13 @@ #define C_CHUNKS_TO_SAVE_PER_TICK (2) -ExternalFileLevelStorage::ExternalFileLevelStorage(const std::string& a, const std::string& path) : - field_8(a), +ExternalFileLevelStorage::ExternalFileLevelStorage(const std::string& name, const std::string& path, bool forceConversion) : + m_levelName(name), m_levelDirPath(path), m_timer(0), m_storageVersion(LEVEL_STORAGE_VERSION_DEFAULT), - m_lastEntitySave(-999999) + m_lastEntitySave(-999999), + m_bForceConversion(forceConversion) { m_pRegionFile = nullptr; m_pLevel = nullptr; @@ -83,8 +84,11 @@ void ExternalFileLevelStorage::saveLevelData(const std::string& levelPath, Level std::string pathOld = pathBase + "level.dat_old"; #ifndef ENH_DISABLE_FORCED_SAVE_UPGRADES - // Forces world to upgrade to new default storage version. - levelData->setStorageVersion(LEVEL_STORAGE_VERSION_DEFAULT); + if (m_bForceConversion) + { + // Forces world to upgrade to new default storage version. + levelData->setStorageVersion(LEVEL_STORAGE_VERSION_DEFAULT); + } #endif writeLevelData(path, *levelData, players); diff --git a/source/world/level/storage/ExternalFileLevelStorage.hpp b/source/world/level/storage/ExternalFileLevelStorage.hpp index cb3916a77..5c5007421 100644 --- a/source/world/level/storage/ExternalFileLevelStorage.hpp +++ b/source/world/level/storage/ExternalFileLevelStorage.hpp @@ -25,7 +25,7 @@ struct UnsavedLevelChunk class ExternalFileLevelStorage : public LevelStorage, public ChunkStorage { public: - ExternalFileLevelStorage(const std::string& a, const std::string& path); + ExternalFileLevelStorage(const std::string& name, const std::string& path, bool forceConversion = false); ~ExternalFileLevelStorage(); private: @@ -54,7 +54,7 @@ class ExternalFileLevelStorage : public LevelStorage, public ChunkStorage static bool writeLevelData(const std::string& path, const LevelData& levelData, const std::vector* players = nullptr); public: - std::string field_8; + std::string m_levelName; std::string m_levelDirPath; LevelData* m_pLevelData; RegionFile* m_pRegionFile; @@ -63,6 +63,7 @@ class ExternalFileLevelStorage : public LevelStorage, public ChunkStorage unsigned int m_storageVersion; std::list m_unsavedLevelChunks; int m_lastEntitySave; + bool m_bForceConversion; }; #endif diff --git a/source/world/level/storage/ExternalFileLevelStorageSource.cpp b/source/world/level/storage/ExternalFileLevelStorageSource.cpp index dd13acc16..8e3f7399e 100644 --- a/source/world/level/storage/ExternalFileLevelStorageSource.cpp +++ b/source/world/level/storage/ExternalFileLevelStorageSource.cpp @@ -39,9 +39,9 @@ std::string ExternalFileLevelStorageSource::getName() const return "External File Level Storage"; } -LevelStorage* ExternalFileLevelStorageSource::selectLevel(const std::string& name, bool b) +LevelStorage* ExternalFileLevelStorageSource::selectLevel(const std::string& name, bool b, bool forceConversion) { - return new ExternalFileLevelStorage(name, m_worldsPath + "/" + name); + return new ExternalFileLevelStorage(name, m_worldsPath + "/" + name, forceConversion); } void ExternalFileLevelStorageSource::getLevelList(std::vector& vls) @@ -165,7 +165,7 @@ void ExternalFileLevelStorageSource::addLevelSummaryIfExists(std::vector&) override; void clearAll() override; int getDataTagFor(const std::string&) override; diff --git a/source/world/level/storage/LevelData.hpp b/source/world/level/storage/LevelData.hpp index ade1cfac6..982fb293f 100644 --- a/source/world/level/storage/LevelData.hpp +++ b/source/world/level/storage/LevelData.hpp @@ -14,7 +14,7 @@ #include "world/phys/Vec3.hpp" #include "world/item/Inventory.hpp" -#define LEVEL_STORAGE_VERSION_DEFAULT 2 +#define LEVEL_STORAGE_VERSION_DEFAULT 2 struct PlayerData { diff --git a/source/world/level/storage/LevelStorageSource.cpp b/source/world/level/storage/LevelStorageSource.cpp index 22f5654d5..7922a8a57 100644 --- a/source/world/level/storage/LevelStorageSource.cpp +++ b/source/world/level/storage/LevelStorageSource.cpp @@ -16,10 +16,10 @@ void LevelStorageSource::getLevelList(std::vector& vec) { // @TODO: complete mock #ifndef ORIGINAL_CODE - vec.push_back(LevelSummary("Level1", "Level-1", 12345, 1234567, GAME_TYPE_CREATIVE)); - vec.push_back(LevelSummary("Level2", "Level-2", 23456, 2345678, GAME_TYPE_CREATIVE)); - vec.push_back(LevelSummary("Level3", "Level-3", 34567, 3456789, GAME_TYPE_CREATIVE)); - vec.push_back(LevelSummary("Level4", "Level-4", 45678, 4567890, GAME_TYPE_CREATIVE)); - vec.push_back(LevelSummary("Level5", "Level-5", 56789, 5678901, GAME_TYPE_CREATIVE)); + vec.push_back(LevelSummary("Level1", "Level-1", 12345, 1234567, GAME_TYPE_CREATIVE, LEVEL_STORAGE_VERSION_DEFAULT)); + vec.push_back(LevelSummary("Level2", "Level-2", 23456, 2345678, GAME_TYPE_CREATIVE, LEVEL_STORAGE_VERSION_DEFAULT)); + vec.push_back(LevelSummary("Level3", "Level-3", 34567, 3456789, GAME_TYPE_CREATIVE, LEVEL_STORAGE_VERSION_DEFAULT)); + vec.push_back(LevelSummary("Level4", "Level-4", 45678, 4567890, GAME_TYPE_CREATIVE, LEVEL_STORAGE_VERSION_DEFAULT)); + vec.push_back(LevelSummary("Level5", "Level-5", 56789, 5678901, GAME_TYPE_CREATIVE, LEVEL_STORAGE_VERSION_DEFAULT)); #endif } diff --git a/source/world/level/storage/LevelStorageSource.hpp b/source/world/level/storage/LevelStorageSource.hpp index de2c5841e..1609e317d 100644 --- a/source/world/level/storage/LevelStorageSource.hpp +++ b/source/world/level/storage/LevelStorageSource.hpp @@ -17,21 +17,24 @@ struct LevelSummary int m_lastPlayed; int m_sizeOnDisk; GameType m_gameType; + unsigned int m_storageVersion; LevelSummary() { m_lastPlayed = 0; m_sizeOnDisk = 0; m_gameType = GAME_TYPE_CREATIVE; + m_storageVersion = LEVEL_STORAGE_VERSION_DEFAULT; } - LevelSummary(const std::string& fileName, const std::string& levelName, int lastPlayed, int sizeOnDisk, GameType gameType) + LevelSummary(const std::string& fileName, const std::string& levelName, int lastPlayed, int sizeOnDisk, GameType gameType = GAME_TYPE_CREATIVE, unsigned int storageVersion = LEVEL_STORAGE_VERSION_DEFAULT) { m_fileName = fileName; m_levelName = levelName; m_lastPlayed = lastPlayed; m_sizeOnDisk = sizeOnDisk; m_gameType = gameType; + m_storageVersion = storageVersion; } bool operator<(const LevelSummary& b) const @@ -45,7 +48,7 @@ class LevelStorageSource public: virtual ~LevelStorageSource(); virtual std::string getName() const = 0; - virtual LevelStorage* selectLevel(const std::string&, bool) = 0; + virtual LevelStorage* selectLevel(const std::string& name, bool b, bool forceConversion = false) = 0; virtual void getLevelList(std::vector&); virtual void clearAll() = 0; virtual int getDataTagFor(const std::string&) = 0; From 9092a44914fdfd163475a01dc4a356adab432b5f Mon Sep 17 00:00:00 2001 From: Longhorn <65045160+minguinmyoui@users.noreply.github.com> Date: Sun, 7 Sep 2025 19:55:46 -0500 Subject: [PATCH 020/293] Fix typo in README.md (#180) Thanks for the catch. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6bc43735a..b57061084 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ The code is based on a decompilation of Minecraft: Pocket Edition (v0.1.3) as of Note: While the original Minecraft PE v0.1.3 may not work on newer devices, ReMinecraftPE works on any of the platforms listed above. -### This a modified version of [the original Minecraft PE v0.1.3 decompilation](https://github.com/ReMinecraftPE/mcped). +### This is a modified version of [the original Minecraft PE v0.1.3 decompilation](https://github.com/ReMinecraftPE/mcped). ## License information From 5ea150f6d228af7b45ba98874bd9699d06e3928b Mon Sep 17 00:00:00 2001 From: TheBrokenRail <17478432+TheBrokenRail@users.noreply.github.com> Date: Sun, 7 Sep 2025 21:01:08 -0400 Subject: [PATCH 021/293] Fix Bugs When Rendering A Text Input In A `[0, 0]` Window (#183) --- source/client/gui/components/TextInputBox.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/client/gui/components/TextInputBox.cpp b/source/client/gui/components/TextInputBox.cpp index 47b35e99d..f21704c44 100644 --- a/source/client/gui/components/TextInputBox.cpp +++ b/source/client/gui/components/TextInputBox.cpp @@ -345,10 +345,10 @@ std::string TextInputBox::getRenderedText(int scroll_pos, std::string text) // But it does not run often enough to matter. std::string rendered_text = text.substr(scroll_pos); int max_width = m_width - (PADDING * 2); - while (m_pFont->width(rendered_text) > max_width) + while (m_pFont->width(rendered_text) > max_width && !rendered_text.empty()) { //rendered_text.pop_back(); // breaks C++03 compatibility - rendered_text.erase(rendered_text.length()-2, 1); + rendered_text.erase(rendered_text.end() - 1); } return rendered_text; } From c677467f01385df25a08d03000b2368fc29b2aa1 Mon Sep 17 00:00:00 2001 From: __andrew <95462744+known81331@users.noreply.github.com> Date: Sun, 7 Sep 2025 21:11:51 -0400 Subject: [PATCH 022/293] Fix Text Input (#184) --- .gitignore | 1 + source/client/gui/components/TextInputBox.cpp | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index bde9bdcb8..57fb80297 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ bld/ # Visual Studio 2015/2017 cache/options directory .vs/ +.vscode/ # Visual Studio 2017 auto generated files Generated\ Files/ diff --git a/source/client/gui/components/TextInputBox.cpp b/source/client/gui/components/TextInputBox.cpp index f21704c44..0237a0ffa 100644 --- a/source/client/gui/components/TextInputBox.cpp +++ b/source/client/gui/components/TextInputBox.cpp @@ -54,7 +54,7 @@ void TextInputBox::setEnabled(bool bEnabled) #define AKEYCODE_FORWARD_DEL SDLVK_DELETE #define AKEYCODE_ARROW_LEFT SDLVK_LEFT #define AKEYCODE_ARROW_RIGHT SDLVK_RIGHT -#define AKEYCODE_DEL SDLVK_BACKSPACE +#define AKEYCODE_DEL SDLVK_BACKSPACE #define AKEYCODE_ENTER SDLVK_RETURN #define AKEYCODE_A SDLVK_a #define AKEYCODE_Z SDLVK_z @@ -173,11 +173,14 @@ void TextInputBox::keyPressed(int key) switch (key) { case AKEYCODE_DEL: { - charPressed('\b'); + // handled elsewhere, do not dupe + // charPressed('\b'); + break; } case AKEYCODE_FORWARD_DEL: { - charPressed(AKEYCODE_FORWARD_DEL); + charPressed('\x7f'); // DELETE + break; } case AKEYCODE_ARROW_LEFT: { @@ -298,7 +301,7 @@ void TextInputBox::charPressed(int k) recalculateScroll(); break; } - case AKEYCODE_FORWARD_DEL: + case '\x7f': // DELETE { // Delete if (m_text.empty()) From c22a32df3dad307da470ef6e3f5815bd5e014b62 Mon Sep 17 00:00:00 2001 From: Brent Date: Sun, 7 Sep 2025 18:20:19 -0700 Subject: [PATCH 023/293] Fix Building on Visual Studio --- platforms/windows/projects/Client/Client.vcxproj | 2 ++ platforms/windows/projects/Client/Client.vcxproj.filters | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/platforms/windows/projects/Client/Client.vcxproj b/platforms/windows/projects/Client/Client.vcxproj index 0b90b99a9..63a7a26f5 100644 --- a/platforms/windows/projects/Client/Client.vcxproj +++ b/platforms/windows/projects/Client/Client.vcxproj @@ -69,6 +69,7 @@ + @@ -197,6 +198,7 @@ + diff --git a/platforms/windows/projects/Client/Client.vcxproj.filters b/platforms/windows/projects/Client/Client.vcxproj.filters index 1f1b8b092..8bbc9c5c1 100644 --- a/platforms/windows/projects/Client/Client.vcxproj.filters +++ b/platforms/windows/projects/Client/Client.vcxproj.filters @@ -110,6 +110,9 @@ Header Files\GUI\Screens + + Header Files\GUI\Screens + Header Files\GUI\Screens @@ -493,6 +496,9 @@ Source Files\GUI\Screens + + Source Files\GUI\Screens + Source Files\GUI\Screens From 01a0921e3343d7546a36dd07d0857db146fb0dc6 Mon Sep 17 00:00:00 2001 From: TheBrokenRail <17478432+TheBrokenRail@users.noreply.github.com> Date: Sun, 7 Sep 2025 21:27:05 -0400 Subject: [PATCH 024/293] Better Way To Detect When Compiling For Windows (#185) --- CMakeLists.txt | 8 ++++++-- platforms/CMakeLists.txt | 5 +++-- platforms/sdl/CMakeLists.txt | 2 +- platforms/sound/CMakeLists.txt | 5 +++-- source/CMakeLists.txt | 6 +++--- thirdparty/raknet/CMakeLists.txt | 4 ++-- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a1bc69b7..283055c5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,13 +16,17 @@ if(EMSCRIPTEN) add_link_options(-Wno-pthreads-mem-growth -sALLOW_MEMORY_GROWTH=1) endif() +# Detect Windows +include(CheckSymbolExists) +check_symbol_exists("_WIN32" "" MCPE_WIN32) + # Clang if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") add_compile_options(-Wno-inconsistent-missing-override -Wno-enum-compare-switch -Wno-register) endif() # Windows Linking -if(WIN32) +if(MCPE_WIN32) add_link_options( -static-libgcc -static-libstdc++ @@ -61,4 +65,4 @@ if(EMSCRIPTEN) target_link_options(reminecraftpe PRIVATE --use-preload-plugins --preload-file "${CMAKE_CURRENT_SOURCE_DIR}/game@/") else() file(CREATE_LINK "${CMAKE_CURRENT_SOURCE_DIR}/game/assets" "${CMAKE_CURRENT_BINARY_DIR}/assets" SYMBOLIC) -endif() \ No newline at end of file +endif() diff --git a/platforms/CMakeLists.txt b/platforms/CMakeLists.txt index daf641034..6e32b4f15 100644 --- a/platforms/CMakeLists.txt +++ b/platforms/CMakeLists.txt @@ -2,11 +2,12 @@ project(reminecraftpe-platforms) # Select & Build set(DEFAULT_PLATFORM "sdl") -if(WIN32) +if(MCPE_WIN32) set(DEFAULT_PLATFORM "windows") endif() set(REMCPE_PLATFORM "${DEFAULT_PLATFORM}" CACHE STRING "ReMCPE Platform (Check /platforms)") +message(STATUS "Selected Platform: ${REMCPE_PLATFORM}") add_subdirectory("${REMCPE_PLATFORM}") # Load Sound -add_subdirectory(sound) \ No newline at end of file +add_subdirectory(sound) diff --git a/platforms/sdl/CMakeLists.txt b/platforms/sdl/CMakeLists.txt index 14cd3bf4a..736c2cf93 100644 --- a/platforms/sdl/CMakeLists.txt +++ b/platforms/sdl/CMakeLists.txt @@ -34,7 +34,7 @@ endif() # SDL add_library(SDL INTERFACE) -if(ANDROID OR WIN32) +if(ANDROID OR MCPE_WIN32) # Use Vendored SDL2 (Only For Android) add_subdirectory(../../thirdparty/SDL2/src SDL EXCLUDE_FROM_ALL) target_link_libraries(SDL INTERFACE SDL2::SDL2) diff --git a/platforms/sound/CMakeLists.txt b/platforms/sound/CMakeLists.txt index 886b3f6b4..1d2a9d1b8 100644 --- a/platforms/sound/CMakeLists.txt +++ b/platforms/sound/CMakeLists.txt @@ -2,9 +2,10 @@ project(reminecraftpe-sound) # Select & Build set(DEFAULT_SOUND_PLATFORM "openal") -if(WIN32) +if(MCPE_WIN32) set(DEFAULT_SOUND_PLATFORM "directsound") endif() set(REMCPE_SOUND_PLATFORM "${DEFAULT_SOUND_PLATFORM}" CACHE STRING "ReMCPE Sound Platform (Check /platforms/sound)") +message(STATUS "Selected Sound Platform: ${REMCPE_SOUND_PLATFORM}") add_subdirectory("${REMCPE_SOUND_PLATFORM}") -target_link_libraries(reminecraftpe reminecraftpe-sound) \ No newline at end of file +target_link_libraries(reminecraftpe reminecraftpe-sound) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index e6b5eff09..9eba92786 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -330,7 +330,7 @@ target_link_libraries(reminecraftpe-core PUBLIC raknet) # zlib add_library(zlib-interface INTERFACE) -if(WIN32) +if(MCPE_WIN32) # Compile Vendored ZLib add_subdirectory(../thirdparty/zlib zlib) target_link_libraries(zlib-interface INTERFACE zlib) @@ -346,9 +346,9 @@ else() endif() target_link_libraries(reminecraftpe-core PUBLIC zlib-interface) # OpenGL Support Code -if(WIN32) +if(MCPE_WIN32) target_sources(reminecraftpe-core PRIVATE ../thirdparty/GL/GLExt.cpp) endif() # OGG Support -target_link_libraries(reminecraftpe-core PUBLIC stb_vorbis) \ No newline at end of file +target_link_libraries(reminecraftpe-core PUBLIC stb_vorbis) diff --git a/thirdparty/raknet/CMakeLists.txt b/thirdparty/raknet/CMakeLists.txt index 3fac7eb43..7de4efaf2 100644 --- a/thirdparty/raknet/CMakeLists.txt +++ b/thirdparty/raknet/CMakeLists.txt @@ -117,10 +117,10 @@ add_library(raknet STATIC target_include_directories(raknet PUBLIC .) # Windows Support -if(WIN32) +if(MCPE_WIN32) target_compile_definitions(raknet PUBLIC SHA1_HAS_TCHAR PUBLIC LOCKLESS_TYPES_USE_MUTEX ) target_link_libraries(raknet ws2_32) -endif() \ No newline at end of file +endif() From 8b7322e8ab6e71b85f6e00b1d81833c1041f7339 Mon Sep 17 00:00:00 2001 From: TheBrokenRail <17478432+TheBrokenRail@users.noreply.github.com> Date: Sun, 7 Sep 2025 21:39:18 -0400 Subject: [PATCH 025/293] Fix OpenGL Linking With CMake (#182) --- platforms/sdl/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platforms/sdl/CMakeLists.txt b/platforms/sdl/CMakeLists.txt index 736c2cf93..abc4a1029 100644 --- a/platforms/sdl/CMakeLists.txt +++ b/platforms/sdl/CMakeLists.txt @@ -60,7 +60,7 @@ if(ANDROID) target_compile_definitions(reminecraftpe-core PUBLIC USE_GLES) else() find_package(OpenGL REQUIRED) - target_link_libraries(reminecraftpe-core PUBLIC ${OPENGL_gl_LIBRARY}) + target_link_libraries(reminecraftpe-core PUBLIC OpenGL::GL) if(EMSCRIPTEN) # Use WebGL 2 target_link_options(reminecraftpe-core PUBLIC From d4d8c4611a71ef5995ddfd2450c20457a5afb095 Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Mon, 8 Sep 2025 11:24:34 -0700 Subject: [PATCH 026/293] Fixed player data load on levels upgraded to V2 (#186) * Fixed player data load on levels upgraded to V2 * Minor cleanup --------- Co-authored-by: Brent --- source/client/app/Minecraft.cpp | 26 +++++++++---------- .../storage/ExternalFileLevelStorage.cpp | 5 +++- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp index ffd0b2d5f..83fdc51d4 100644 --- a/source/client/app/Minecraft.cpp +++ b/source/client/app/Minecraft.cpp @@ -895,15 +895,15 @@ void Minecraft::prepareLevel(const std::string& unused) float time1 = getTimeS(); // generating all the chunks at once - (void)m_pLevel->getTile(TilePos(i, (C_MAX_Y + C_MIN_Y) / 2, j)); + (void)pLevel->getTile(TilePos(i, (C_MAX_Y + C_MIN_Y) / 2, j)); if (time1 != -1.0f) getTimeS(); float time2 = getTimeS(); - if (m_pLevel->field_B0C) + if (pLevel->field_B0C) { - while (m_pLevel->updateLights()); + while (pLevel->updateLights()); } if (time2 != -1.0f) @@ -914,7 +914,7 @@ void Minecraft::prepareLevel(const std::string& unused) if (startTime != -1.0f) getTimeS(); - m_pLevel->setUpdateLights(1); + pLevel->setUpdateLights(1); startTime = getTimeS(); @@ -923,7 +923,7 @@ void Minecraft::prepareLevel(const std::string& unused) { for (cp.z = 0; cp.z < C_MAX_CHUNKS_Z; cp.z++) { - LevelChunk* pChunk = m_pLevel->getChunk(cp); + LevelChunk* pChunk = pLevel->getChunk(cp); if (!pChunk) continue; @@ -940,17 +940,17 @@ void Minecraft::prepareLevel(const std::string& unused) field_DA0 = 3; - if (m_pLevel->field_B0C) + if (pLevel->field_B0C) { - m_pLevel->setInitialSpawn(); - m_pLevel->saveLevelData(); - m_pLevel->getChunkSource()->saveAll(); - m_pLevel->saveGame(); + pLevel->setInitialSpawn(); + pLevel->saveLevelData(); + pLevel->getChunkSource()->saveAll(); + pLevel->saveGame(); } else { - m_pLevel->saveLevelData(); - m_pLevel->loadEntities(); + pLevel->saveLevelData(); + pLevel->loadEntities(); } m_progressPercent = -1; @@ -958,7 +958,7 @@ void Minecraft::prepareLevel(const std::string& unused) startTime = getTimeS(); - m_pLevel->prepare(); + pLevel->prepare(); if (startTime != -1.0f) getTimeS(); diff --git a/source/world/level/storage/ExternalFileLevelStorage.cpp b/source/world/level/storage/ExternalFileLevelStorage.cpp index 2136daec9..82de59bc4 100644 --- a/source/world/level/storage/ExternalFileLevelStorage.cpp +++ b/source/world/level/storage/ExternalFileLevelStorage.cpp @@ -46,7 +46,10 @@ ExternalFileLevelStorage::ExternalFileLevelStorage(const std::string& name, cons m_storageVersion = m_pLevelData->getStorageVersion(); - readPlayerData(datPlayer, *m_pLevelData); + if (m_storageVersion <= 1) + { + readPlayerData(datPlayer, *m_pLevelData); + } } ExternalFileLevelStorage::~ExternalFileLevelStorage() From 31989c575deb9f4607d05518aff0857b7ef20807 Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Wed, 10 Sep 2025 23:05:33 -0700 Subject: [PATCH 027/293] Fixed memory leaks (#188) --------- Co-authored-by: Brent --- .../Minecraft.xcodeproj/project.pbxproj | 34 +++++------ source/client/app/Minecraft.cpp | 60 +++++++++---------- .../client/gui/screens/SelectWorldScreen.cpp | 5 ++ .../client/gui/screens/SelectWorldScreen.hpp | 1 + source/client/model/CowModel.cpp | 6 +- source/client/model/Model.cpp | 4 -- source/client/model/Model.hpp | 1 - source/client/model/ModelPart.cpp | 6 +- source/client/model/SheepModel.cpp | 30 ++++++---- source/client/renderer/entity/MobRenderer.cpp | 6 ++ source/client/renderer/entity/MobRenderer.hpp | 1 + source/nbt/CompoundTag.cpp | 17 ++++-- source/nbt/CompoundTag.hpp | 2 + source/nbt/ListTag.cpp | 1 + source/world/item/ItemInstance.cpp | 5 ++ source/world/item/ItemInstance.hpp | 1 + .../storage/ExternalFileLevelStorage.cpp | 9 ++- .../ExternalFileLevelStorageSource.cpp | 1 + source/world/level/storage/LevelData.cpp | 6 ++ 19 files changed, 121 insertions(+), 75 deletions(-) diff --git a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj index 3e68c6c60..03352861d 100644 --- a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj +++ b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj @@ -4549,40 +4549,40 @@ children = ( 84B1E02D2E04FD4500ED000A /* ArrowRenderer.cpp */, 84B1E02E2E04FD4500ED000A /* ArrowRenderer.hpp */, - 84AA8BA12B32F3F3003F5B82 /* ChickenRenderer.hpp */, 84AA8BA02B32F3F3003F5B82 /* ChickenRenderer.cpp */, - 84AA8BA32B32F3F3003F5B82 /* CowRenderer.hpp */, + 84AA8BA12B32F3F3003F5B82 /* ChickenRenderer.hpp */, 84AA8BA22B32F3F3003F5B82 /* CowRenderer.cpp */, - 84AA8BA52B32F3F3003F5B82 /* CreeperRenderer.hpp */, + 84AA8BA32B32F3F3003F5B82 /* CowRenderer.hpp */, 84AA8BA42B32F3F3003F5B82 /* CreeperRenderer.cpp */, - 84AA8BA72B32F3F3003F5B82 /* EntityRenderDispatcher.hpp */, + 84AA8BA52B32F3F3003F5B82 /* CreeperRenderer.hpp */, 84AA8BA62B32F3F3003F5B82 /* EntityRenderDispatcher.cpp */, - 84AA8BA92B32F3F3003F5B82 /* EntityRenderer.hpp */, + 84AA8BA72B32F3F3003F5B82 /* EntityRenderDispatcher.hpp */, 84AA8BA82B32F3F3003F5B82 /* EntityRenderer.cpp */, - 84AA8BAB2B32F3F3003F5B82 /* FallingTileRenderer.hpp */, + 84AA8BA92B32F3F3003F5B82 /* EntityRenderer.hpp */, 84AA8BAA2B32F3F3003F5B82 /* FallingTileRenderer.cpp */, - 84AA8BAD2B32F3F3003F5B82 /* HumanoidMobRenderer.hpp */, + 84AA8BAB2B32F3F3003F5B82 /* FallingTileRenderer.hpp */, 84AA8BAC2B32F3F3003F5B82 /* HumanoidMobRenderer.cpp */, - 84AA8BAF2B32F3F3003F5B82 /* ItemRenderer.hpp */, + 84AA8BAD2B32F3F3003F5B82 /* HumanoidMobRenderer.hpp */, 84AA8BAE2B32F3F3003F5B82 /* ItemRenderer.cpp */, - 84AA8BB12B32F3F3003F5B82 /* ItemSpriteRenderer.hpp */, + 84AA8BAF2B32F3F3003F5B82 /* ItemRenderer.hpp */, 84AA8BB02B32F3F3003F5B82 /* ItemSpriteRenderer.cpp */, - 84AA8BB32B32F3F3003F5B82 /* MobRenderer.hpp */, + 84AA8BB12B32F3F3003F5B82 /* ItemSpriteRenderer.hpp */, 84AA8BB22B32F3F3003F5B82 /* MobRenderer.cpp */, - 84AA8BB52B32F3F3003F5B82 /* PigRenderer.hpp */, + 84AA8BB32B32F3F3003F5B82 /* MobRenderer.hpp */, 84AA8BB42B32F3F3003F5B82 /* PigRenderer.cpp */, - 84E78C7E2B58B5CC00D515EF /* RocketRenderer.hpp */, + 84AA8BB52B32F3F3003F5B82 /* PigRenderer.hpp */, 84E78C7D2B58B5CC00D515EF /* RocketRenderer.cpp */, - 84AA8BB72B32F3F3003F5B82 /* SheepFurRenderer.hpp */, + 84E78C7E2B58B5CC00D515EF /* RocketRenderer.hpp */, 84AA8BB62B32F3F3003F5B82 /* SheepFurRenderer.cpp */, - 84AA8BB92B32F3F3003F5B82 /* SheepRenderer.hpp */, + 84AA8BB72B32F3F3003F5B82 /* SheepFurRenderer.hpp */, 84AA8BB82B32F3F3003F5B82 /* SheepRenderer.cpp */, - 84AA8BBD2B32F3F3003F5B82 /* SpiderRenderer.hpp */, + 84AA8BB92B32F3F3003F5B82 /* SheepRenderer.hpp */, 84AA8BBC2B32F3F3003F5B82 /* SpiderRenderer.cpp */, - 84AA8BBF2B32F3F3003F5B82 /* TntRenderer.hpp */, + 84AA8BBD2B32F3F3003F5B82 /* SpiderRenderer.hpp */, 84AA8BBE2B32F3F3003F5B82 /* TntRenderer.cpp */, - 84AA8BC12B32F3F3003F5B82 /* TripodCameraRenderer.hpp */, + 84AA8BBF2B32F3F3003F5B82 /* TntRenderer.hpp */, 84AA8BC02B32F3F3003F5B82 /* TripodCameraRenderer.cpp */, + 84AA8BC12B32F3F3003F5B82 /* TripodCameraRenderer.hpp */, ); path = entity; sourceTree = ""; diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp index 83fdc51d4..63ac0f94b 100644 --- a/source/client/app/Minecraft.cpp +++ b/source/client/app/Minecraft.cpp @@ -102,6 +102,35 @@ Minecraft::Minecraft() : m_lastInteractTime = 0; } +Minecraft::~Minecraft() +{ + SAFE_DELETE(m_options); + SAFE_DELETE(m_pNetEventCallback); + SAFE_DELETE(m_pRakNetInstance); + SAFE_DELETE(m_pLevelRenderer); + SAFE_DELETE(m_pGameRenderer); + SAFE_DELETE(m_pParticleEngine); + SAFE_DELETE(EntityRenderDispatcher::instance); + m_pSoundEngine->destroy(); + SAFE_DELETE(m_pSoundEngine); + SAFE_DELETE(m_pGameMode); + SAFE_DELETE(m_pFont); + SAFE_DELETE(m_pTextures); + + if (m_pLevel) + { + LevelStorage* pStor = m_pLevel->getLevelStorage(); + SAFE_DELETE(pStor); + delete m_pLevel; + } + + SAFE_DELETE(m_pUser); + SAFE_DELETE(m_pLevelStorageSource); + SAFE_DELETE(m_pInputHolder); + + //@BUG: potentially leaking a CThread instance if this is destroyed early? +} + int Minecraft::getLicenseId() { if (m_licenseID < 0) @@ -269,6 +298,7 @@ void Minecraft::setGameMode(GameType gameType) { if (m_pLevel) { + SAFE_DELETE(m_pGameMode); m_pGameMode = createGameMode(gameType, *m_pLevel); m_pGameMode->initLevel(m_pLevel); } @@ -843,36 +873,6 @@ void Minecraft::init() } } -Minecraft::~Minecraft() -{ - SAFE_DELETE(m_options); - SAFE_DELETE(m_pNetEventCallback); - SAFE_DELETE(m_pRakNetInstance); - SAFE_DELETE(m_pLevelRenderer); - SAFE_DELETE(m_pGameRenderer); - SAFE_DELETE(m_pParticleEngine); - m_pSoundEngine->destroy(); - SAFE_DELETE(m_pSoundEngine); - SAFE_DELETE(m_pGameMode); - SAFE_DELETE(m_pFont); - SAFE_DELETE(m_pTextures); - - if (m_pLevel) - { - LevelStorage* pStor = m_pLevel->getLevelStorage(); - if (pStor) - delete pStor; - if (m_pLevel) - delete m_pLevel; - } - - SAFE_DELETE(m_pUser); - SAFE_DELETE(m_pLevelStorageSource); - SAFE_DELETE(m_pInputHolder); - - //@BUG: potentially leaking a CThread instance if this is destroyed early? -} - void Minecraft::prepareLevel(const std::string& unused) { field_DA0 = 1; diff --git a/source/client/gui/screens/SelectWorldScreen.cpp b/source/client/gui/screens/SelectWorldScreen.cpp index 6b1f5dc89..70b728247 100644 --- a/source/client/gui/screens/SelectWorldScreen.cpp +++ b/source/client/gui/screens/SelectWorldScreen.cpp @@ -25,6 +25,11 @@ SelectWorldScreen::SelectWorldScreen() : field_130 = 0; } +SelectWorldScreen::~SelectWorldScreen() +{ + SAFE_DELETE(m_pWorldSelectionList); +} + void SelectWorldScreen::init() { SAFE_DELETE(m_pWorldSelectionList); diff --git a/source/client/gui/screens/SelectWorldScreen.hpp b/source/client/gui/screens/SelectWorldScreen.hpp index 85fb64630..b966d125e 100644 --- a/source/client/gui/screens/SelectWorldScreen.hpp +++ b/source/client/gui/screens/SelectWorldScreen.hpp @@ -15,6 +15,7 @@ class SelectWorldScreen : public Screen { public: SelectWorldScreen(); + ~SelectWorldScreen(); void init() override; bool isInGameScreen() override; diff --git a/source/client/model/CowModel.cpp b/source/client/model/CowModel.cpp index 16434ce19..4dd1763d5 100644 --- a/source/client/model/CowModel.cpp +++ b/source/client/model/CowModel.cpp @@ -10,7 +10,8 @@ CowModel::CowModel() : QuadrupedModel(12, 0.0f) { - m_head = ModelPart(this, 0, 0); + m_head.clear(); + m_head.texOffs(0, 0); // head m_head.addBox(-4, -4, -6, 8, 8, 6); @@ -22,7 +23,8 @@ CowModel::CowModel() : m_head.texOffs(22, 0); m_head.addBox(4, -5, -4, 1, 3, 1); - m_body = ModelPart(this, 18, 4); + m_body.clear(); + m_body.texOffs(18, 4); // torso m_body.addBox(-6, -10, -7, 12, 18, 10); diff --git a/source/client/model/Model.cpp b/source/client/model/Model.cpp index 36417f414..7816804c9 100644 --- a/source/client/model/Model.cpp +++ b/source/client/model/Model.cpp @@ -17,10 +17,6 @@ Model::Model(int width, int height) m_textureHeight = height; } -Model::~Model() -{ -} - void Model::onGraphicsReset() { diff --git a/source/client/model/Model.hpp b/source/client/model/Model.hpp index 1f3bfb7bf..111bdcd07 100644 --- a/source/client/model/Model.hpp +++ b/source/client/model/Model.hpp @@ -17,7 +17,6 @@ class Model { public: Model(int width, int height); - virtual ~Model(); virtual void onGraphicsReset(); virtual void prepareMobModel(Mob*, float, float, float); virtual void render(float, float, float, float, float, float); diff --git a/source/client/model/ModelPart.cpp b/source/client/model/ModelPart.cpp index dfb40a7ac..43a19ad02 100644 --- a/source/client/model/ModelPart.cpp +++ b/source/client/model/ModelPart.cpp @@ -79,9 +79,11 @@ void ModelPart::clear() { for (size_t i = 0; i < m_pCubes.size(); i++) delete m_pCubes[i]; - - // N.B. does not clear children m_pCubes.clear(); + + for (size_t i = 0; i < m_pChildren.size(); i++) + delete m_pChildren[i]; + m_pChildren.clear(); } void ModelPart::compile(float scale) diff --git a/source/client/model/SheepModel.cpp b/source/client/model/SheepModel.cpp index df74c9398..cb7b10edd 100644 --- a/source/client/model/SheepModel.cpp +++ b/source/client/model/SheepModel.cpp @@ -6,10 +6,12 @@ SheepModel::SheepModel(bool hasFur) : if (hasFur) { // For the fully-clothed sheep that inhabit the TGA textures - /*m_body = ModelPart(28, 40); + /*m_body.clear(); + m_body.texOffs(28, 40); m_body.addBox(-4.0f, -10.0f, -7.0f, 8, 16, 6, 1.75f); m_body.setPos(0.0f, 5.0f, 2.0f); - m_head = ModelPart(0, 0); + m_head.clear(); + m_head.texOffs(0, 0); m_head.addBox(-3.0f, -4.0f, -6.0f, 6, 6, 8); m_head.setPos(0.0f, 6.0f, -8.0f); m_head.texOffs(0, 32); @@ -23,34 +25,42 @@ SheepModel::SheepModel(bool hasFur) : m_leg4.texOffs(0, 48); m_leg4.addBox(-2.0f, 0.0f, -2.0f, 4, 6, 4, 0.5f);*/ - m_body = ModelPart(28, 8); + m_body.clear(); + m_body.texOffs(28, 8); m_body.addBox(-4.0f, -10.0f, -7.0f, 8, 16, 6, 1.75f); m_body.setPos(0.0f, 5.0f, 2.0f); - m_head = ModelPart(0, 0); + m_head.clear(); + m_head.texOffs(0, 0); m_head.addBox(-3.0f, -4.0f, -4.0f, 6, 6, 6, 0.6f); m_head.setPos(0.0f, 6.0f, -8.0f); float g = 0.5f; - m_leg1 = ModelPart(0, 16); + m_leg1.clear(); + m_leg1.texOffs(0, 16); m_leg1.addBox(-2.0f, 0.0f, -2.0f, 4, 6, 4, g); m_leg1.setPos(-3.0f, 12.0f, 7.0f); - m_leg2 = ModelPart(0, 16); + m_leg2.clear(); + m_leg2.texOffs(0, 16); m_leg2.addBox(-2.0f, 0.0f, -2.0f, 4, 6, 4, g); m_leg2.setPos(3.0f, 12.0f, 7.0f); - m_leg3 = ModelPart(0, 16); + m_leg3.clear(); + m_leg3.texOffs(0, 16); m_leg3.addBox(-2.0f, 0.0f, -2.0f, 4, 6, 4, g); m_leg3.setPos(-3.0f, 12.0f, -5.0f); - m_leg4 = ModelPart(0, 16); + m_leg4.clear(); + m_leg4.texOffs(0, 16); m_leg4.addBox(-2.0f, 0.0f, -2.0f, 4, 6, 4, g); m_leg4.setPos(3.0f, 12.0f, -5.0f); } else { - m_body = ModelPart(28, 8); + m_body.clear(); + m_body.texOffs(28, 8); m_body.addBox(-4.0f, -10.0f, -7.0f, 8, 16, 6); m_body.setPos(0.0f, 5.0f, 2.0f); - m_head = ModelPart(0, 0); + m_head.clear(); + m_head.texOffs(0, 0); m_head.addBox(-3.0f, -4.0f, -6.0f, 6, 6, 8); m_head.setPos(0.0f, 6.0f, -8.0f); } diff --git a/source/client/renderer/entity/MobRenderer.cpp b/source/client/renderer/entity/MobRenderer.cpp index 4a14c6dae..ea49aa720 100644 --- a/source/client/renderer/entity/MobRenderer.cpp +++ b/source/client/renderer/entity/MobRenderer.cpp @@ -17,6 +17,12 @@ MobRenderer::MobRenderer(Model* pModel, float f) m_shadowRadius = f; } +MobRenderer::~MobRenderer() +{ + SAFE_DELETE(m_pModel); + SAFE_DELETE(m_pArmorModel); +} + void MobRenderer::setArmor(Model* model) { m_pArmorModel = model; diff --git a/source/client/renderer/entity/MobRenderer.hpp b/source/client/renderer/entity/MobRenderer.hpp index dffaa90a4..c21675ab2 100644 --- a/source/client/renderer/entity/MobRenderer.hpp +++ b/source/client/renderer/entity/MobRenderer.hpp @@ -14,6 +14,7 @@ class MobRenderer : public EntityRenderer { public: MobRenderer(Model*, float); + virtual ~MobRenderer(); void setArmor(Model*); virtual void render(Entity*, float, float, float, float, float) override; diff --git a/source/nbt/CompoundTag.cpp b/source/nbt/CompoundTag.cpp index 6b95857cd..9fb8bc9b0 100644 --- a/source/nbt/CompoundTag.cpp +++ b/source/nbt/CompoundTag.cpp @@ -6,6 +6,7 @@ CompoundTag::CompoundTag() { + m_bLeak = false; } void CompoundTag::write(IDataOutput& dos) const @@ -37,7 +38,10 @@ void CompoundTag::load(IDataInput& dis) } if (tag->getId() == TAG_TYPE_END) + { + delete tag; break; + } m_tags[name] = tag; } @@ -294,10 +298,15 @@ bool CompoundTag::remove(const std::string& name) void CompoundTag::deleteChildren() { - for (std::map::iterator it = m_tags.begin(); it != m_tags.end(); it++) - { - delete it->second; - } + if (!m_bLeak) + { + for (std::map::iterator it = m_tags.begin(); it != m_tags.end(); it++) + { + Tag* tag = it->second; + tag->deleteChildren(); + delete tag; + } + } m_tags.clear(); } diff --git a/source/nbt/CompoundTag.hpp b/source/nbt/CompoundTag.hpp index 7479a2a46..475a26feb 100644 --- a/source/nbt/CompoundTag.hpp +++ b/source/nbt/CompoundTag.hpp @@ -65,6 +65,7 @@ class CompoundTag : public Tag CompoundTag clone(); bool remove(const std::string& name); void deleteChildren() override; + void leak() { m_bLeak = true; } bool isEmpty() const { return m_tags.empty(); } std::map& rawView() { return m_tags; } @@ -75,4 +76,5 @@ class CompoundTag : public Tag private: std::map m_tags; + bool m_bLeak; }; \ No newline at end of file diff --git a/source/nbt/ListTag.cpp b/source/nbt/ListTag.cpp index 3836cf651..811dfc56e 100644 --- a/source/nbt/ListTag.cpp +++ b/source/nbt/ListTag.cpp @@ -143,6 +143,7 @@ void ListTag::deleteChildren() for (std::vector::iterator it = m_list.begin(); it != m_list.end(); it++) { Tag* tag = *it; + tag->deleteChildren(); delete tag; } diff --git a/source/world/item/ItemInstance.cpp b/source/world/item/ItemInstance.cpp index 14f51c857..fc5929a09 100644 --- a/source/world/item/ItemInstance.cpp +++ b/source/world/item/ItemInstance.cpp @@ -60,6 +60,11 @@ ItemInstance::ItemInstance(int itemID, int amount, int auxValue) _init(itemID, amount, auxValue); } +ItemInstance::~ItemInstance() +{ + SAFE_DELETE(m_userData); +} + int ItemInstance::getId() const { return m_itemID; diff --git a/source/world/item/ItemInstance.hpp b/source/world/item/ItemInstance.hpp index d3710ba40..e6d690753 100644 --- a/source/world/item/ItemInstance.hpp +++ b/source/world/item/ItemInstance.hpp @@ -35,6 +35,7 @@ class ItemInstance ItemInstance(Tile*, int amount); ItemInstance(Tile*, int amount, int auxValue); ItemInstance(int itemID, int amount, int auxValue); + ~ItemInstance(); int getId() const; int getIdAux() const; diff --git a/source/world/level/storage/ExternalFileLevelStorage.cpp b/source/world/level/storage/ExternalFileLevelStorage.cpp index 82de59bc4..d995f1d6f 100644 --- a/source/world/level/storage/ExternalFileLevelStorage.cpp +++ b/source/world/level/storage/ExternalFileLevelStorage.cpp @@ -241,7 +241,7 @@ LevelChunk* ExternalFileLevelStorage::load(Level* level, const ChunkPos& pos) LevelChunk* pChunk = new LevelChunk(level, pData, pos); pBitStream->Read((char*)pChunk->m_tileData, 16 * 16 * 128 / 2); - if (m_pLevelData->getStorageVersion() >= 1) + if (m_storageVersion >= 1) { pBitStream->Read((char*)pChunk->m_lightSky, 16 * 16 * 128 / 2); pBitStream->Read((char*)pChunk->m_lightBlk, 16 * 16 * 128 / 2); @@ -309,10 +309,9 @@ void ExternalFileLevelStorage::loadEntities(Level* level, LevelChunk* chunk) } } } - else - { - delete tag; // not what we want, banish it to the shadow realm - } + + tag->deleteChildren(); + delete tag; } if (data) diff --git a/source/world/level/storage/ExternalFileLevelStorageSource.cpp b/source/world/level/storage/ExternalFileLevelStorageSource.cpp index 8e3f7399e..8c0610777 100644 --- a/source/world/level/storage/ExternalFileLevelStorageSource.cpp +++ b/source/world/level/storage/ExternalFileLevelStorageSource.cpp @@ -25,6 +25,7 @@ ExternalFileLevelStorageSource::ExternalFileLevelStorageSource(const std::string m_worldsPath += "/minecraftWorlds"; if (createFolderIfNotExists(m_worldsPath.c_str())) { + // @WTF: why? std::vector vls; getLevelList(vls); } diff --git a/source/world/level/storage/LevelData.cpp b/source/world/level/storage/LevelData.cpp index 00b78633c..915bdd745 100644 --- a/source/world/level/storage/LevelData.cpp +++ b/source/world/level/storage/LevelData.cpp @@ -109,7 +109,11 @@ CompoundTag LevelData::createTag() const CompoundTag* playerTag = nullptr; if (m_playerTag) + { playerTag = m_playerTag->copy(); + // Don't want to accidentally de-allocate the current playerTag + playerTag->leak(); + } writeTagData(levelTag, playerTag); @@ -153,6 +157,8 @@ void LevelData::loadTagData(CompoundTag& tag) if (playerTag) { setPlayerTag(playerTag); + // "Transfer ownership" of tag contents to playerTag copy + playerTag->leak(); } } From 56b8073d355ebc6ddf1212ca078af78247fadf84 Mon Sep 17 00:00:00 2001 From: Brent Da Mage Date: Thu, 11 Sep 2025 22:54:11 -0500 Subject: [PATCH 028/293] LevelChunk::getTile skip loading unknown Tiles --- source/world/level/levelgen/chunk/LevelChunk.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/world/level/levelgen/chunk/LevelChunk.cpp b/source/world/level/levelgen/chunk/LevelChunk.cpp index c3f29fc1e..57196ef85 100644 --- a/source/world/level/levelgen/chunk/LevelChunk.cpp +++ b/source/world/level/levelgen/chunk/LevelChunk.cpp @@ -565,7 +565,11 @@ TileID LevelChunk::getTile(const ChunkTilePos& pos) { CheckPosition(pos); - return m_pBlockData[MakeBlockDataIndex(pos)]; + TileID tileId = m_pBlockData[MakeBlockDataIndex(pos)]; + if (Tile::tiles[tileId]) + return tileId; + else + return TILE_AIR; } int LevelChunk::countEntities() From 6e1c0add9a8d28ef685f9866e56b037004ae0cdd Mon Sep 17 00:00:00 2001 From: Brent Da Mage Date: Thu, 11 Sep 2025 23:01:25 -0500 Subject: [PATCH 029/293] Fix item use logic --- source/client/app/Minecraft.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp index 63ac0f94b..3aa3b4424 100644 --- a/source/client/app/Minecraft.cpp +++ b/source/client/app/Minecraft.cpp @@ -421,7 +421,7 @@ void Minecraft::handleBuildAction(const BuildActionIntention& action) if (bInteract && action.isInteract() && canInteract) { ItemInstance* pItem = getSelectedItem(); - if (pItem && !player->isUsingItem()) + if (pItem && player->isUsingItem()) { m_lastInteractTime = getTimeMs(); if (m_pGameMode->useItem(player, m_pLevel, pItem)) From 7b09c8310932a7d6c8357c938a41d36927b3594a Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Fri, 12 Sep 2025 20:42:24 -0700 Subject: [PATCH 030/293] TerrainParticle Enhancements (#190) * TerrainParticle is now colored correctly * TerrainParticle texture is loaded based on tile aux value * Added enhancement for loading TerrainParticle texture based on tile face. (off by default) Co-authored-by: Brent Da Mage --- GameMods.hpp | 1 + source/world/particle/Particle.hpp | 2 +- source/world/particle/ParticleEngine.cpp | 2 +- source/world/particle/TerrainParticle.cpp | 10 ++++++++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/GameMods.hpp b/GameMods.hpp index 685f85935..29c75484f 100644 --- a/GameMods.hpp +++ b/GameMods.hpp @@ -37,6 +37,7 @@ #define ENH_MENU_BACKGROUND // Renders a spinning panorama (if it's available) in the background of the main menu #define ENH_GUI_ITEM_POP // Calls Inventory::tick() to create the "pop" animation for items that enter the hotbar. This function was not present on Pocket Edition. //#define ENH_DISABLE_FORCED_SAVE_UPGRADES // Prevents the forced format-version upgrade of world/level saves, effectively opting-out of new save formats. See LEVEL_STORAGE_VERSION_DEFAULT in LevelData.hpp. +//#define ENH_FACED_TERRAIN_PARTICLES // Sets the TerrainParticle's texture depending on the face the block is being hit from. This is something Notch never did for whatever reason. // TODO: Implement this permanently? #define ENH_IMPROVED_SAVING // Improve world saving. The original Minecraft doesn't always really save for some reason diff --git a/source/world/particle/Particle.hpp b/source/world/particle/Particle.hpp index c7f729bdc..cc3ccbd25 100644 --- a/source/world/particle/Particle.hpp +++ b/source/world/particle/Particle.hpp @@ -70,7 +70,7 @@ class TerrainParticle : public Particle void render(Tesselator&, float, float, float, float, float, float) override; int getParticleTexture() override; - TerrainParticle* init(const TilePos& tilePos); + TerrainParticle* init(const TilePos& tilePos, Facing::Name face = Facing::DOWN); public: Tile* m_pTile; diff --git a/source/world/particle/ParticleEngine.cpp b/source/world/particle/ParticleEngine.cpp index 41e944933..cafd62851 100644 --- a/source/world/particle/ParticleEngine.cpp +++ b/source/world/particle/ParticleEngine.cpp @@ -99,7 +99,7 @@ void ParticleEngine::crack(const TilePos& tilePos, Facing::Name face) break; } - add((new TerrainParticle(m_pLevel, pos, pTile))->setPower(0.2f)->scale(0.6f)); + add((new TerrainParticle(m_pLevel, pos, pTile))->init(tilePos, face)->setPower(0.2f)->scale(0.6f)); } void ParticleEngine::destroyEffect(const TilePos& pos) diff --git a/source/world/particle/TerrainParticle.cpp b/source/world/particle/TerrainParticle.cpp index f14f3def7..dd8d2f72d 100644 --- a/source/world/particle/TerrainParticle.cpp +++ b/source/world/particle/TerrainParticle.cpp @@ -30,9 +30,15 @@ TerrainParticle::TerrainParticle(Level* level, const Vec3& pos, const Vec3& dir, _init(tile); } -TerrainParticle* TerrainParticle::init(const TilePos& tilePos) +TerrainParticle* TerrainParticle::init(const TilePos& tilePos, Facing::Name face) { - if (m_pTile == Tile::grass) +#ifndef ENH_FACED_TERRAIN_PARTICLES + face = Facing::DOWN; +#endif + + field_DC = m_pTile->getTexture(m_pLevel, tilePos, face); + + if (m_pTile == Tile::grass && face != Facing::UP) return this; int color = m_pTile->getColor(m_pLevel, tilePos); From b14409214df31bbe04278a994f2dbe52aba3a9f6 Mon Sep 17 00:00:00 2001 From: Brent Da Mage Date: Sat, 13 Sep 2025 01:15:31 -0500 Subject: [PATCH 031/293] Fixed third-person in-hand item lighting --- source/client/renderer/GameRenderer.cpp | 2 +- source/client/renderer/entity/HumanoidMobRenderer.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/source/client/renderer/GameRenderer.cpp b/source/client/renderer/GameRenderer.cpp index b83481e28..4d89a0291 100644 --- a/source/client/renderer/GameRenderer.cpp +++ b/source/client/renderer/GameRenderer.cpp @@ -504,7 +504,7 @@ void GameRenderer::renderLevel(float f) glShadeModel(GL_SMOOTH); #endif - glEnable(GL_BLEND); + //glEnable(GL_BLEND); glDisable(GL_CULL_FACE); // glDepthMask(false); -- added in 0.1.1j. Introduces more issues than fixes diff --git a/source/client/renderer/entity/HumanoidMobRenderer.cpp b/source/client/renderer/entity/HumanoidMobRenderer.cpp index f740901c4..4e9da0fe5 100644 --- a/source/client/renderer/entity/HumanoidMobRenderer.cpp +++ b/source/client/renderer/entity/HumanoidMobRenderer.cpp @@ -50,8 +50,10 @@ void HumanoidMobRenderer::additionalRendering(Mob* mob, float f) glRotatef(20.0f, 0.0f, 0.0f, 1.0f); } + glEnable(GL_RESCALE_NORMAL); m_pDispatcher->m_pItemInHandRenderer->renderItem(inst); glPopMatrix(); + glDisable(GL_RESCALE_NORMAL); } void HumanoidMobRenderer::onGraphicsReset() From c2e87612bbe9f443917564d43c2892a502fb0bdc Mon Sep 17 00:00:00 2001 From: Brent Da Mage Date: Sat, 13 Sep 2025 02:37:28 -0500 Subject: [PATCH 032/293] Vec3 usage cleanup --- source/client/app/Minecraft.cpp | 10 +- source/client/model/SpiderModel.cpp | 96 +++++++++---------- source/client/renderer/Tesselator.hpp | 6 ++ .../client/renderer/entity/ArrowRenderer.cpp | 4 +- .../client/renderer/entity/ArrowRenderer.hpp | 2 +- .../entity/EntityRenderDispatcher.cpp | 2 +- .../client/renderer/entity/EntityRenderer.cpp | 8 +- .../client/renderer/entity/EntityRenderer.hpp | 4 +- .../renderer/entity/FallingTileRenderer.cpp | 8 +- .../renderer/entity/FallingTileRenderer.hpp | 2 +- .../client/renderer/entity/ItemRenderer.cpp | 8 +- .../client/renderer/entity/ItemRenderer.hpp | 2 +- .../renderer/entity/ItemSpriteRenderer.cpp | 4 +- .../renderer/entity/ItemSpriteRenderer.hpp | 2 +- source/client/renderer/entity/MobRenderer.cpp | 49 ++++++---- source/client/renderer/entity/MobRenderer.hpp | 10 +- .../client/renderer/entity/RocketRenderer.cpp | 4 +- .../client/renderer/entity/RocketRenderer.hpp | 2 +- source/client/renderer/entity/TntRenderer.cpp | 8 +- source/client/renderer/entity/TntRenderer.hpp | 2 +- .../renderer/entity/TripodCameraRenderer.cpp | 6 +- .../renderer/entity/TripodCameraRenderer.hpp | 2 +- thirdparty/GL/GL.hpp | 2 +- 23 files changed, 130 insertions(+), 113 deletions(-) diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp index 3aa3b4424..da57971a6 100644 --- a/source/client/app/Minecraft.cpp +++ b/source/client/app/Minecraft.cpp @@ -877,7 +877,7 @@ void Minecraft::prepareLevel(const std::string& unused) { field_DA0 = 1; - float startTime = getTimeS(); + float startTime = float(getTimeS()); Level* pLevel = m_pLevel; if (!pLevel->field_B0C) @@ -892,7 +892,7 @@ void Minecraft::prepareLevel(const std::string& unused) // this looks like some kind of progress tracking m_progressPercent = i2 / (C_MAX_CHUNKS_X * C_MAX_CHUNKS_Z); - float time1 = getTimeS(); + float time1 = float(getTimeS()); // generating all the chunks at once (void)pLevel->getTile(TilePos(i, (C_MAX_Y + C_MIN_Y) / 2, j)); @@ -916,7 +916,7 @@ void Minecraft::prepareLevel(const std::string& unused) pLevel->setUpdateLights(1); - startTime = getTimeS(); + startTime = float(getTimeS()); ChunkPos cp(0, 0); for (cp.x = 0; cp.x < C_MAX_CHUNKS_X; cp.x++) @@ -956,7 +956,7 @@ void Minecraft::prepareLevel(const std::string& unused) m_progressPercent = -1; field_DA0 = 2; - startTime = getTimeS(); + startTime = float(getTimeS()); pLevel->prepare(); @@ -1036,7 +1036,7 @@ float Minecraft::getBestScaleForThisScreenSize(int width, int height) void Minecraft::generateLevel(const std::string& unused, Level* pLevel) { - float time = getTimeS(); //@UNUSED + float time = float(getTimeS()); //@UNUSED prepareLevel(unused); diff --git a/source/client/model/SpiderModel.cpp b/source/client/model/SpiderModel.cpp index 22bb9a9a2..732043e29 100644 --- a/source/client/model/SpiderModel.cpp +++ b/source/client/model/SpiderModel.cpp @@ -18,38 +18,38 @@ SpiderModel::SpiderModel() : static int yo = 15; m_head.addBox(-4.0f, -4.0f, -8.0f, 8, 8, 8, g); - m_head.addBox(-4.0F, -4.0F, -8.0F, 8, 8, 8, g); - m_head.setPos(0.0F, (float)(0 + yo), -3.0F); + m_head.addBox(-4.0f, -4.0f, -8.0f, 8, 8, 8, g); + m_head.setPos(0.0f, (float)(0 + yo), -3.0f); - m_body0.addBox(-3.0F, -3.0F, -3.0F, 6, 6, 6, g); - m_body0.setPos(0.0F, (float)yo, 0.0F); + m_body0.addBox(-3.0f, -3.0f, -3.0f, 6, 6, 6, g); + m_body0.setPos(0.0f, (float)yo, 0.0f); - m_body1.addBox(-5.0F, -4.0F, -6.0F, 10, 8, 12, g); - m_body1.setPos(0.0F, (float)(0 + yo), 9.0F); + m_body1.addBox(-5.0f, -4.0f, -6.0f, 10, 8, 12, g); + m_body1.setPos(0.0f, (float)(0 + yo), 9.0f); - m_leg0.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, g); - m_leg0.setPos(-4.0F, (float)(0 + yo), 2.0F); + m_leg0.addBox(-15.0f, -1.0f, -1.0f, 16, 2, 2, g); + m_leg0.setPos(-4.0f, (float)(0 + yo), 2.0f); - m_leg1.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, g); - m_leg1.setPos(4.0F, (float)(0 + yo), 2.0F); + m_leg1.addBox(-1.0f, -1.0f, -1.0f, 16, 2, 2, g); + m_leg1.setPos(4.0f, (float)(0 + yo), 2.0f); - m_leg2.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, g); - m_leg2.setPos(-4.0F, (float)(0 + yo), 1.0F); + m_leg2.addBox(-15.0f, -1.0f, -1.0f, 16, 2, 2, g); + m_leg2.setPos(-4.0f, (float)(0 + yo), 1.0f); - m_leg3.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, g); - m_leg3.setPos(4.0F, (float)(0 + yo), 1.0F); + m_leg3.addBox(-1.0f, -1.0f, -1.0f, 16, 2, 2, g); + m_leg3.setPos(4.0f, (float)(0 + yo), 1.0f); - m_leg4.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, g); - m_leg4.setPos(-4.0F, (float)(0 + yo), 0.0F); + m_leg4.addBox(-15.0f, -1.0f, -1.0f, 16, 2, 2, g); + m_leg4.setPos(-4.0f, (float)(0 + yo), 0.0f); - m_leg5.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, g); - m_leg5.setPos(4.0F, (float)(0 + yo), 0.0F); + m_leg5.addBox(-1.0f, -1.0f, -1.0f, 16, 2, 2, g); + m_leg5.setPos(4.0f, (float)(0 + yo), 0.0f); - m_leg6.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, g); - m_leg6.setPos(-4.0F, (float)(0 + yo), -1.0F); + m_leg6.addBox(-15.0f, -1.0f, -1.0f, 16, 2, 2, g); + m_leg6.setPos(-4.0f, (float)(0 + yo), -1.0f); - m_leg7.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, g); - m_leg7.setPos(4.0F, (float)(0 + yo), -1.0F); + m_leg7.addBox(-1.0f, -1.0f, -1.0f, 16, 2, 2, g); + m_leg7.setPos(4.0f, (float)(0 + yo), -1.0f); } SpiderModel::~SpiderModel() @@ -74,38 +74,38 @@ void SpiderModel::render(float time, float r, float bob, float yRot, float xRot, } void SpiderModel::setupAnim(float time, float r, float bob, float yRot, float xRot, float scale) { - m_head.m_rot.y = yRot / 57.295776F; - m_head.m_rot.x = xRot / 57.295776F; + m_head.m_rot.y = yRot / 57.295776f; + m_head.m_rot.x = xRot / 57.295776f; - static float sr = 0.7853982F; + static float sr = 0.7853982f; m_leg0.m_rot.z = -sr; m_leg1.m_rot.z = sr; - m_leg2.m_rot.z = -sr * 0.74F; - m_leg3.m_rot.z = sr * 0.74F; - m_leg4.m_rot.z = -sr * 0.74F; - m_leg5.m_rot.z = sr * 0.74F; + m_leg2.m_rot.z = -sr * 0.74f; + m_leg3.m_rot.z = sr * 0.74f; + m_leg4.m_rot.z = -sr * 0.74f; + m_leg5.m_rot.z = sr * 0.74f; m_leg6.m_rot.z = -sr; m_leg7.m_rot.z = sr; - static float ro = -0.0F; - static float ur = 0.3926991F; - m_leg0.m_rot.y = ur * 2.0F + ro; - m_leg1.m_rot.y = -ur * 2.0F - ro; - m_leg2.m_rot.y = ur * 1.0F + ro; - m_leg3.m_rot.y = -ur * 1.0F - ro; - m_leg4.m_rot.y = -ur * 1.0F + ro; - m_leg5.m_rot.y = ur * 1.0F - ro; - m_leg6.m_rot.y = -ur * 2.0F + ro; - m_leg7.m_rot.y = ur * 2.0F - ro; - - float c0 = -(Mth::cos(time * 0.6662F * 2.0F + 0.0F) * 0.4F) * r; - float c1 = -(Mth::cos(time * 0.6662F * 2.0F + M_PI) * 0.4F) * r; - float c2 = -(Mth::cos(time * 0.6662F * 2.0F + 1.5707964F) * 0.4F) * r; - float c3 = -(Mth::cos(time * 0.6662F * 2.0F + 4.712389F) * 0.4F) * r; - float s0 = Mth::abs(Mth::sin(time * 0.6662F + 0.0F) * 0.4F) * r; - float s1 = Mth::abs(Mth::sin(time * 0.6662F + M_PI) * 0.4F) * r; - float s2 = Mth::abs(Mth::sin(time * 0.6662F + 1.5707964F) * 0.4F) * r; - float s3 = Mth::abs(Mth::sin(time * 0.6662F + 4.712389F) * 0.4F) * r; + static float ro = -0.0f; + static float ur = 0.3926991f; + m_leg0.m_rot.y = ur * 2.0f + ro; + m_leg1.m_rot.y = -ur * 2.0f - ro; + m_leg2.m_rot.y = ur * 1.0f + ro; + m_leg3.m_rot.y = -ur * 1.0f - ro; + m_leg4.m_rot.y = -ur * 1.0f + ro; + m_leg5.m_rot.y = ur * 1.0f - ro; + m_leg6.m_rot.y = -ur * 2.0f + ro; + m_leg7.m_rot.y = ur * 2.0f - ro; + + float c0 = -(Mth::cos(time * 0.6662f * 2.0f + 0.0f) * 0.4f) * r; + float c1 = -(Mth::cos(time * 0.6662f * 2.0f + float(M_PI)) * 0.4f) * r; + float c2 = -(Mth::cos(time * 0.6662f * 2.0f + 1.5707964f) * 0.4f) * r; + float c3 = -(Mth::cos(time * 0.6662f * 2.0f + 4.712389f) * 0.4f) * r; + float s0 = Mth::abs(Mth::sin(time * 0.6662f + 0.0f) * 0.4f) * r; + float s1 = Mth::abs(Mth::sin(time * 0.6662f + float(M_PI)) * 0.4f) * r; + float s2 = Mth::abs(Mth::sin(time * 0.6662f + 1.5707964f) * 0.4f) * r; + float s3 = Mth::abs(Mth::sin(time * 0.6662f + 4.712389f) * 0.4f) * r; m_leg0.m_rot.y += c0; m_leg1.m_rot.y += -c0; diff --git a/source/client/renderer/Tesselator.hpp b/source/client/renderer/Tesselator.hpp index 2a82c78a2..9d9d2cd72 100644 --- a/source/client/renderer/Tesselator.hpp +++ b/source/client/renderer/Tesselator.hpp @@ -12,6 +12,7 @@ #include #include "thirdparty/GL/GL.hpp" #include "RenderChunk.hpp" +#include "world/phys/Vec3.hpp" #define GET_RED(c) (uint8_t(((c) >> 0) & 0xFF)) #define GET_GREEN(c) (uint8_t(((c) >> 8) & 0xFF)) @@ -53,6 +54,7 @@ class Tesselator ~Tesselator(); void addOffset(float x, float y, float z); + void addOffset(const Vec3& pos) { addOffset(pos.x, pos.y, pos.z); } void begin(); void begin(GLenum mode); void clear(); @@ -68,11 +70,15 @@ class Tesselator void init(); void noColor(); void normal(float, float, float); + void normal(const Vec3& pos) { normal(pos.x, pos.y, pos.z); } void offset(float, float, float); + void offset(const Vec3& pos) { offset(pos.x, pos.y, pos.z); } void setAccessMode(int mode); // sets m_DrawArraysMode void tex(float u, float v); void vertex(float x, float y, float z); + void vertex(const Vec3& pos) { vertex(pos.x, pos.y, pos.z); } void vertexUV(float x, float y, float z, float u, float v); + void vertexUV(const Vec3& pos, float u, float v) { vertexUV(pos.x, pos.y, pos.z, u, v); } void voidBeginAndEndCalls(bool b); RenderChunk end(int); diff --git a/source/client/renderer/entity/ArrowRenderer.cpp b/source/client/renderer/entity/ArrowRenderer.cpp index b9430b1f2..f471ba76d 100644 --- a/source/client/renderer/entity/ArrowRenderer.cpp +++ b/source/client/renderer/entity/ArrowRenderer.cpp @@ -9,14 +9,14 @@ ArrowRenderer::~ArrowRenderer() { } -void ArrowRenderer::render(Entity* ent, float x, float y, float z, float rot, float a) +void ArrowRenderer::render(Entity* ent, const Vec3& pos, float rot, float a) { Arrow* arrow = reinterpret_cast(ent); glPushMatrix(); bindTexture("item/arrows.png"); - glTranslatef(x, y, z); + glTranslatef(pos.x, pos.y, pos.z); glRotatef(arrow->m_oRot.y + (arrow->m_rot.y - arrow->m_oRot.y) * a - 90.0f, 0.0f, 1.0f, 0.0f); glRotatef(arrow->m_oRot.x + (arrow->m_rot.x - arrow->m_oRot.x) * a, 0.0f, 0.0f, 1.0f); diff --git a/source/client/renderer/entity/ArrowRenderer.hpp b/source/client/renderer/entity/ArrowRenderer.hpp index bd3471141..15a8f2209 100644 --- a/source/client/renderer/entity/ArrowRenderer.hpp +++ b/source/client/renderer/entity/ArrowRenderer.hpp @@ -8,5 +8,5 @@ class ArrowRenderer : public EntityRenderer ArrowRenderer(); ~ArrowRenderer(); - void render(Entity* ent, float x, float y, float z, float rot, float a) override; + void render(Entity* ent, const Vec3& pos, float rot, float a) override; }; diff --git a/source/client/renderer/entity/EntityRenderDispatcher.cpp b/source/client/renderer/entity/EntityRenderDispatcher.cpp index e2b83f0f5..2dd519652 100644 --- a/source/client/renderer/entity/EntityRenderDispatcher.cpp +++ b/source/client/renderer/entity/EntityRenderDispatcher.cpp @@ -179,7 +179,7 @@ void EntityRenderDispatcher::render(Entity* entity, const Vec3& pos, float rot, m_HumanoidMobRenderer.m_pHumanoidModel->m_bSneaking = false; #endif - pRenderer->render(entity, pos.x, pos.y, pos.z, rot, a); + pRenderer->render(entity, pos, rot, a); pRenderer->postRender(entity, pos, rot, a); } diff --git a/source/client/renderer/entity/EntityRenderer.cpp b/source/client/renderer/entity/EntityRenderer.cpp index 27dd53d43..2bc0726b3 100644 --- a/source/client/renderer/entity/EntityRenderer.cpp +++ b/source/client/renderer/entity/EntityRenderer.cpp @@ -165,14 +165,14 @@ void EntityRenderer::renderTileShadow(Tile* tt, const Vec3& pos, TilePos& tilePo } -void EntityRenderer::render(const AABB& aabb, float offX, float offY, float offZ) +void EntityRenderer::render(const AABB& aabb, const Vec3& pos) { glDisable(GL_TEXTURE_2D); Tesselator& t = Tesselator::instance; glColor4f(1.0f, 1.0f, 1.0f, 1.0f); t.begin(); - //t.vertex(offX, offY, offZ); // Why were we doing this? - t.offset(offX, offY, offZ); + //t.vertex(pos); // Why were we doing this? + t.offset(pos); t.normal(0.0f, 0.0f, -1.0f); t.vertex(aabb.min.x, aabb.max.y, aabb.min.z); t.vertex(aabb.max.x, aabb.max.y, aabb.min.z); @@ -209,7 +209,7 @@ void EntityRenderer::render(const AABB& aabb, float offX, float offY, float offZ t.vertex(aabb.max.x, aabb.max.y, aabb.max.z); t.vertex(aabb.max.x, aabb.min.y, aabb.max.z); - t.offset(0.0f, 0.0f, 0.0f); + t.offset(Vec3::ZERO); t.draw(); // t.end() on Java glEnable(GL_TEXTURE_2D); } diff --git a/source/client/renderer/entity/EntityRenderer.hpp b/source/client/renderer/entity/EntityRenderer.hpp index 6fa7553a9..463b487ba 100644 --- a/source/client/renderer/entity/EntityRenderer.hpp +++ b/source/client/renderer/entity/EntityRenderer.hpp @@ -36,11 +36,11 @@ class EntityRenderer bool bindTexture(const std::string& file, bool isRequired = true); Font* getFont(); void init(EntityRenderDispatcher* d); - static void render(const AABB&, float, float, float); + static void render(const AABB&, const Vec3& pos); static void renderFlat(const AABB&); void postRender(Entity* entity, const Vec3& pos, float rot, float a); - virtual void render(Entity*, float, float, float, float, float) = 0; + virtual void render(Entity* entity, const Vec3& pos, float rot, float a) = 0; virtual void onGraphicsReset(); public: diff --git a/source/client/renderer/entity/FallingTileRenderer.cpp b/source/client/renderer/entity/FallingTileRenderer.cpp index a72e9c3d9..4a3792163 100644 --- a/source/client/renderer/entity/FallingTileRenderer.cpp +++ b/source/client/renderer/entity/FallingTileRenderer.cpp @@ -16,12 +16,12 @@ FallingTileRenderer::FallingTileRenderer() m_shadowRadius = 0.5f; } -void FallingTileRenderer::render(Entity* entity, float x, float y, float z, float a6, float a7) +void FallingTileRenderer::render(Entity* entity, const Vec3& pos, float rot, float a) { - FallingTile* fallingTile = (FallingTile*)entity; + FallingTile* tile = (FallingTile*)entity; glPushMatrix(); - glTranslatef(x, y, z); + glTranslatef(pos.x, pos.y, pos.z); bindTexture(C_TERRAIN_NAME); @@ -35,7 +35,7 @@ void FallingTileRenderer::render(Entity* entity, float x, float y, float z, floa #define ARGPATCH #endif - m_tileRenderer.renderTile(Tile::tiles[fallingTile->m_id], 0 ARGPATCH); + m_tileRenderer.renderTile(Tile::tiles[tile->m_id], 0 ARGPATCH); glPopMatrix(); diff --git a/source/client/renderer/entity/FallingTileRenderer.hpp b/source/client/renderer/entity/FallingTileRenderer.hpp index ed6d77f46..15f1c9c4d 100644 --- a/source/client/renderer/entity/FallingTileRenderer.hpp +++ b/source/client/renderer/entity/FallingTileRenderer.hpp @@ -20,7 +20,7 @@ class FallingTileRenderer : public EntityRenderer public: FallingTileRenderer(); - void render(Entity*, float, float, float, float, float) override; + void render(Entity* entity, const Vec3& pos, float rot, float a) override; public: TileRenderer m_tileRenderer; diff --git a/source/client/renderer/entity/ItemRenderer.cpp b/source/client/renderer/entity/ItemRenderer.cpp index ff4c1efbd..aa0bc2101 100644 --- a/source/client/renderer/entity/ItemRenderer.cpp +++ b/source/client/renderer/entity/ItemRenderer.cpp @@ -34,13 +34,13 @@ ItemRenderer::ItemRenderer() m_shadowStrength = 0.75f; } -void ItemRenderer::render(Entity* pEntity, float x, float y, float z, float a, float b) +void ItemRenderer::render(Entity* pEntity, const Vec3& pos, float rot, float a) { m_random.init_genrand(187); ItemEntity* pItemEntity = (ItemEntity*)pEntity; glPushMatrix(); - float yOffset = Mth::sin((float(pItemEntity->m_age) + b) / 10.0f + pItemEntity->m_bobOffs); + float yOffset = Mth::sin((float(pItemEntity->m_age) + a) / 10.0f + pItemEntity->m_bobOffs); const ItemInstance* pItemInstance = pItemEntity->m_pItemInstance; if (!pItemInstance) { @@ -56,13 +56,13 @@ void ItemRenderer::render(Entity* pEntity, float x, float y, float z, float a, f if (pItemInstance->m_count > 20) itemsToRender = 4; - glTranslatef(x, y + 0.1f + yOffset * 0.1f, z); + glTranslatef(pos.x, pos.y + 0.1f + yOffset * 0.1f, pos.z); glEnable(GL_RESCALE_NORMAL); int itemID = pItemInstance->m_itemID; if (itemID < C_MAX_TILES && TileRenderer::canRender(Tile::tiles[itemID]->getRenderShape())) { - glRotatef(((float(pItemEntity->m_age) + b) / 20.0f + pItemEntity->m_bobOffs) * 57.296f, 0.0f, 1.0f, 0.0f); + glRotatef(((float(pItemEntity->m_age) + a) / 20.0f + pItemEntity->m_bobOffs) * 57.296f, 0.0f, 1.0f, 0.0f); bindTexture(C_TERRAIN_NAME); float scale = 0.5f; diff --git a/source/client/renderer/entity/ItemRenderer.hpp b/source/client/renderer/entity/ItemRenderer.hpp index f1a215e75..2be7babd9 100644 --- a/source/client/renderer/entity/ItemRenderer.hpp +++ b/source/client/renderer/entity/ItemRenderer.hpp @@ -17,7 +17,7 @@ class ItemRenderer : public EntityRenderer public: ItemRenderer(); - void render(Entity*, float, float, float, float, float) override; + void render(Entity* entity, const Vec3& pos, float rot, float a) override; void blitRect(Tesselator&, int, int, int, int, int); static void blit(int, int, int, int, int, int); diff --git a/source/client/renderer/entity/ItemSpriteRenderer.cpp b/source/client/renderer/entity/ItemSpriteRenderer.cpp index df6847126..aab2b1e99 100644 --- a/source/client/renderer/entity/ItemSpriteRenderer.cpp +++ b/source/client/renderer/entity/ItemSpriteRenderer.cpp @@ -6,10 +6,10 @@ ItemSpriteRenderer::ItemSpriteRenderer(int sprite) m_sprite = sprite; } -void ItemSpriteRenderer::render(Entity* pEntity, float x, float y, float z, float a, float b) +void ItemSpriteRenderer::render(Entity* pEntity, const Vec3& pos, float rot, float a) { glPushMatrix(); - glTranslatef(x, y, z); + glTranslatef(pos.x, pos.y, pos.z); glEnable(GL_RESCALE_NORMAL); glScalef(0.5f, 0.5f, 0.5f); bindTexture(C_ITEMS_NAME); diff --git a/source/client/renderer/entity/ItemSpriteRenderer.hpp b/source/client/renderer/entity/ItemSpriteRenderer.hpp index e5686f883..0adda1cb6 100644 --- a/source/client/renderer/entity/ItemSpriteRenderer.hpp +++ b/source/client/renderer/entity/ItemSpriteRenderer.hpp @@ -6,7 +6,7 @@ class ItemSpriteRenderer : public EntityRenderer { public: ItemSpriteRenderer(int sprite); - void render(Entity*, float x, float y, float z, float a, float b) override; + void render(Entity* entity, const Vec3& pos, float rot, float a) override; public: int m_sprite; diff --git a/source/client/renderer/entity/MobRenderer.cpp b/source/client/renderer/entity/MobRenderer.cpp index ea49aa720..94a92f538 100644 --- a/source/client/renderer/entity/MobRenderer.cpp +++ b/source/client/renderer/entity/MobRenderer.cpp @@ -6,6 +6,8 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ +#include + #include "MobRenderer.hpp" #include "EntityRenderDispatcher.hpp" #include "client/app/Minecraft.hpp" @@ -62,21 +64,21 @@ void MobRenderer::scale(Mob*, float) } -void MobRenderer::setupPosition(Entity* entity, float x, float y, float z) +void MobRenderer::setupPosition(Entity* entity, const Vec3& pos) { // @HACK: I eye-balled a corrective offset of 1/13, since I still can't figure out why all mobs are floating - Brent // This was due to "0.059375f" being used for scale instead of "0.0625f" - glTranslatef(x, y, z); + glTranslatef(pos.x, pos.y, pos.z); } -void MobRenderer::setupRotations(Entity* entity, float x, float y, float z) +void MobRenderer::setupRotations(Entity* entity, float bob, float bodyRot, float a) { - glRotatef(180.0f - y, 0.0f, 1.0f, 0.0f); + glRotatef(180.0f - bodyRot, 0.0f, 1.0f, 0.0f); Mob* mob = (Mob*)entity; if (mob->m_deathTime > 0) { - float t = Mth::sqrt((float(mob->m_deathTime) + z - 1.0f) / 20.0f * 1.6f); + float t = Mth::sqrt((float(mob->m_deathTime) + a - 1.0f) / 20.0f * 1.6f); if (t > 1.0f) t = 1.0f; @@ -84,7 +86,7 @@ void MobRenderer::setupRotations(Entity* entity, float x, float y, float z) } } -void MobRenderer::render(Entity* entity, float x, float y, float z, float unused, float f) +void MobRenderer::render(Entity* entity, const Vec3& pos, float unused, float f) { Mob* pMob = (Mob*)entity; @@ -106,7 +108,7 @@ void MobRenderer::render(Entity* entity, float x, float y, float z, float unused float fBob = getBob(pMob, f); float fSmth = pMob->field_EC + (pMob->field_E8 - pMob->field_EC) * f; - setupPosition(pMob, x, y - pMob->m_heightOffset, z); + setupPosition(pMob, Vec3(pos.x, pos.y - pMob->m_heightOffset, pos.z)); setupRotations(pMob, fBob, fSmth, f); float fScale = 0.0625f; // the scale variable according to b1.2_02 @@ -194,23 +196,32 @@ void MobRenderer::render(Entity* entity, float x, float y, float z, float unused glEnable(GL_CULL_FACE); glPopMatrix(); - renderName(pMob, x, y, z); + renderName(pMob, pos); } -void MobRenderer::renderName(Mob* mob, float x, float y, float z) +void MobRenderer::renderName(Mob* mob, const Vec3& pos) { - if (!mob->isPlayer()) - return; - - Player* player = (Player*)mob; - if (player == m_pDispatcher->m_pMinecraft->m_pLocalPlayer) - return; + if (mob->isPlayer()) + { + Player* player = (Player*)mob; + if (player == m_pDispatcher->m_pMinecraft->m_pLocalPlayer) + return; - // @TODO: don't know why but I have to add this correction. look into it and fix it! - renderNameTag(mob, player->m_name, x, y - 1.5f, z, mob->isSneaking() ? 32 : 64); + // @TODO: don't know why but I have to add this correction. look into it and fix it! + renderNameTag(mob, player->m_name, Vec3(pos.x, pos.y - 1.5f, pos.z), mob->isSneaking() ? 32 : 64); + } + else + { + if (m_pDispatcher->m_pOptions->m_bDebugText) + { + std::stringstream ss; + ss << mob->m_EntityID; + renderNameTag(mob, ss.str(), pos, 64); + } + } } -void MobRenderer::renderNameTag(Mob* mob, const std::string& str, float x, float y, float z, int a) +void MobRenderer::renderNameTag(Mob* mob, const std::string& str, const Vec3& pos, int a) { if (mob->distanceToSqr(m_pDispatcher->m_pMob) > float(a * a)) return; @@ -218,7 +229,7 @@ void MobRenderer::renderNameTag(Mob* mob, const std::string& str, float x, float Font* font = getFont(); glPushMatrix(); - glTranslatef(x + 0.0f, y + 2.3f, z); + glTranslatef(pos.x + 0.0f, pos.y + 2.3f, pos.z); #ifndef __EMSCRIPTEN__ glNormal3f(0.0f, 1.0f, 0.0f); #endif diff --git a/source/client/renderer/entity/MobRenderer.hpp b/source/client/renderer/entity/MobRenderer.hpp index c21675ab2..10f7774bd 100644 --- a/source/client/renderer/entity/MobRenderer.hpp +++ b/source/client/renderer/entity/MobRenderer.hpp @@ -17,17 +17,17 @@ class MobRenderer : public EntityRenderer virtual ~MobRenderer(); void setArmor(Model*); - virtual void render(Entity*, float, float, float, float, float) override; + virtual void render(Entity*, const Vec3& pos, float, float) override; virtual int prepareArmor(Mob*, int, float); - virtual void setupPosition(Entity*, float, float, float); - virtual void setupRotations(Entity*, float, float, float); + virtual void setupPosition(Entity*, const Vec3& pos); + virtual void setupRotations(Entity*, float bob, float bodyRot, float a); virtual float getAttackAnim(Mob*, float); virtual float getBob(Mob*, float); virtual float getFlipDegrees(Mob*); virtual int getOverlayColor(Mob*, float, float); virtual void scale(Mob*, float); - virtual void renderName(Mob*, float, float, float); - virtual void renderNameTag(Mob*, const std::string&, float, float, float, int); + virtual void renderName(Mob*, const Vec3& pos); + virtual void renderNameTag(Mob*, const std::string&, const Vec3& pos, int); virtual void additionalRendering(Mob*, float); public: diff --git a/source/client/renderer/entity/RocketRenderer.cpp b/source/client/renderer/entity/RocketRenderer.cpp index dfa5a7b49..2fa0e00a2 100644 --- a/source/client/renderer/entity/RocketRenderer.cpp +++ b/source/client/renderer/entity/RocketRenderer.cpp @@ -15,10 +15,10 @@ RocketRenderer::RocketRenderer() : m_shadowRadius = 0.5f; } -void RocketRenderer::render(Entity* entity, float x, float y, float z, float a, float b) +void RocketRenderer::render(Entity* entity, const Vec3& pos, float rot, float a) { glPushMatrix(); - glTranslatef(x, y, z); + glTranslatef(pos.x, pos.y, pos.z); float brightness = entity->getBrightness(1.0f); diff --git a/source/client/renderer/entity/RocketRenderer.hpp b/source/client/renderer/entity/RocketRenderer.hpp index 5400d05ed..4280e5377 100644 --- a/source/client/renderer/entity/RocketRenderer.hpp +++ b/source/client/renderer/entity/RocketRenderer.hpp @@ -24,7 +24,7 @@ class RocketRenderer : public EntityRenderer { public: RocketRenderer(); - void render(Entity*, float, float, float, float, float) override; + void render(Entity* entity, const Vec3& pos, float rot, float a) override; public: TileRenderer m_renderer; diff --git a/source/client/renderer/entity/TntRenderer.cpp b/source/client/renderer/entity/TntRenderer.cpp index efaffe1e9..318d6a02f 100644 --- a/source/client/renderer/entity/TntRenderer.cpp +++ b/source/client/renderer/entity/TntRenderer.cpp @@ -14,14 +14,14 @@ TntRenderer::TntRenderer() m_shadowRadius = 0.5f; } -void TntRenderer::render(Entity* entity, float x, float y, float z, float a6, float a7) +void TntRenderer::render(Entity* entity, const Vec3& pos, float rot, float a) { PrimedTnt* tnt = (PrimedTnt*)entity; glPushMatrix(); - glTranslatef(x, y, z); + glTranslatef(pos.x, pos.y, pos.z); - float m = 1.0f + float(tnt->m_fuseTimer) - a7; + float m = 1.0f + float(tnt->m_fuseTimer) - a; if (m < 10.0f) { float n = (m / -10.0f) + 1.0f; @@ -54,7 +54,7 @@ void TntRenderer::render(Entity* entity, float x, float y, float z, float a6, fl glDisable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA); - glColor4f(1.0f, 1.0f, 1.0f, (((float(tnt->m_fuseTimer) - a7) + 1.0f) / -100.0f + 1.0f) * 0.8f); + glColor4f(1.0f, 1.0f, 1.0f, (((float(tnt->m_fuseTimer) - a) + 1.0f) / -100.0f + 1.0f) * 0.8f); m_tileRenderer.renderTile(Tile::tnt, 0 ARGPATCH); glColor4f(1.0f, 1.0, 1.0f, 1.0f); glDisable(GL_BLEND); diff --git a/source/client/renderer/entity/TntRenderer.hpp b/source/client/renderer/entity/TntRenderer.hpp index aad39f56b..81f3be2ad 100644 --- a/source/client/renderer/entity/TntRenderer.hpp +++ b/source/client/renderer/entity/TntRenderer.hpp @@ -16,7 +16,7 @@ class TntRenderer : public EntityRenderer public: TntRenderer(); - void render(Entity*, float, float, float, float, float) override; + void render(Entity*entity, const Vec3& pos, float rot, float a) override; public: TileRenderer m_tileRenderer; diff --git a/source/client/renderer/entity/TripodCameraRenderer.cpp b/source/client/renderer/entity/TripodCameraRenderer.cpp index 302c845bb..0d86f11dc 100644 --- a/source/client/renderer/entity/TripodCameraRenderer.cpp +++ b/source/client/renderer/entity/TripodCameraRenderer.cpp @@ -26,10 +26,10 @@ float TripodCameraRenderer::getFlashTime(TripodCamera* camera, float f) return 0.125f * (float(camera->field_B90) - f); } -void TripodCameraRenderer::render(Entity* entity, float x, float y, float z, float a, float b) +void TripodCameraRenderer::render(Entity* entity, const Vec3& pos, float rot, float a) { glPushMatrix(); - glTranslatef(x, y, z); + glTranslatef(pos.x, pos.y, pos.z); m_modelPart.m_rot.x = 0.017453f * (180.0f + 0.5f * entity->m_rot.y); m_modelPart.m_rot.y = -0.017453f * entity->m_rot.x; @@ -50,7 +50,7 @@ void TripodCameraRenderer::render(Entity* entity, float x, float y, float z, flo Entity* pHREntity = m_pDispatcher->m_pMinecraft->m_hitResult.m_pEnt; - float time = getFlashTime((TripodCamera*)entity, b); + float time = getFlashTime((TripodCamera*)entity, a); if (time >= 0.0f) { glColor4f(1.0f, 1.0f, 1.0f, sinf(float(M_PI) * 2.0f * time)); diff --git a/source/client/renderer/entity/TripodCameraRenderer.hpp b/source/client/renderer/entity/TripodCameraRenderer.hpp index 84ac0cb96..9d7cfd2fa 100644 --- a/source/client/renderer/entity/TripodCameraRenderer.hpp +++ b/source/client/renderer/entity/TripodCameraRenderer.hpp @@ -25,7 +25,7 @@ class TripodCameraRenderer : public EntityRenderer public: TripodCameraRenderer(); - void render(Entity*, float, float, float, float, float) override; + void render(Entity*, const Vec3& pos, float rot, float a) override; static float getFlashTime(TripodCamera*, float f); diff --git a/thirdparty/GL/GL.hpp b/thirdparty/GL/GL.hpp index abbe0c808..422ca171d 100644 --- a/thirdparty/GL/GL.hpp +++ b/thirdparty/GL/GL.hpp @@ -83,7 +83,7 @@ static inline void gluPerspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar) { GLfloat m[4][4]; float sine, cotangent, deltaZ; - float radians = fovy / 2.0f * M_PI / 180.0f; + float radians = fovy / 2.0f * float(M_PI) / 180.0f; deltaZ = zFar - zNear; sine = sin(radians); From d45157cdaeac2a38e417a87f55d13eee079e92a4 Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Sat, 13 Sep 2025 19:57:26 -0700 Subject: [PATCH 033/293] Cleanup Xcode Project (#191) Co-authored-by: Brent --- .../Minecraft.xcodeproj/project.pbxproj | 117 +++--------------- 1 file changed, 19 insertions(+), 98 deletions(-) diff --git a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj index 03352861d..98f0c61ba 100644 --- a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj +++ b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj @@ -7,6 +7,9 @@ objects = { /* Begin PBXBuildFile section */ + 84043C432E76627900B988F0 /* libRenderer.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8406FD292AF1814500B09C1D /* libRenderer.a */; }; + 84043C442E7663A000B988F0 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8489B3252A86E4B0004CA8EC /* OpenGL.framework */; }; + 84043C452E7663DB00B988F0 /* libZLib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84498A832AF18C7A005EF5A5 /* libZLib.a */; }; 8406FD2A2AF181B800B09C1D /* GL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD6542AC810620006A435 /* GL.cpp */; }; 8406FD2C2AF1820700B09C1D /* MinecraftPackets.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD63B2AC810620006A435 /* MinecraftPackets.hpp */; }; 8406FD2D2AF1820700B09C1D /* NetEventCallback.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD63D2AC810620006A435 /* NetEventCallback.hpp */; }; @@ -176,7 +179,6 @@ 8406FDD32AF182E700B09C1D /* WindowsIncludes.h in Headers */ = {isa = PBXBuildFile; fileRef = 840DD8432AC810630006A435 /* WindowsIncludes.h */; }; 8406FDD42AF182E700B09C1D /* WSAStartupSingleton.h in Headers */ = {isa = PBXBuildFile; fileRef = 840DD8452AC810630006A435 /* WSAStartupSingleton.h */; }; 8406FDD52AF182E700B09C1D /* XBox360Includes.h in Headers */ = {isa = PBXBuildFile; fileRef = 840DD8462AC810630006A435 /* XBox360Includes.h */; }; - 8406FDD92AF184B600B09C1D /* libRenderer.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8406FD292AF1814500B09C1D /* libRenderer.a */; }; 84171E812B1A6227008B82E6 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84C4D86E2A872C0100323E33 /* OpenAL.framework */; }; 841DD86A2AF8A99000AA3B66 /* LegacyCPPCompatibility.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 841DD8692AF8A99000AA3B66 /* LegacyCPPCompatibility.hpp */; }; 841DD8772AF8AA7A00AA3B66 /* AppPlatform_sdl_base.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 841DD8722AF8AA7A00AA3B66 /* AppPlatform_sdl_base.cpp */; }; @@ -242,9 +244,6 @@ 84498A9B2AF18CDA005EF5A5 /* trees.c in Sources */ = {isa = PBXBuildFile; fileRef = 840DD8632AC810630006A435 /* trees.c */; }; 84498A9C2AF18CDA005EF5A5 /* uncompr.c in Sources */ = {isa = PBXBuildFile; fileRef = 840DD8652AC810630006A435 /* uncompr.c */; }; 84498A9D2AF18CDA005EF5A5 /* zutil.c in Sources */ = {isa = PBXBuildFile; fileRef = 840DD8682AC810630006A435 /* zutil.c */; }; - 84498AA02AF18D08005EF5A5 /* libZLib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84498A832AF18C7A005EF5A5 /* libZLib.a */; }; - 84619B1F2AF1EDA300B0DE81 /* libCommon.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84E4BFAE2AE9854B0023E16A /* libCommon.a */; }; - 84619B202AF1EDA300B0DE81 /* libRenderer.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8406FD292AF1814500B09C1D /* libRenderer.a */; }; 84619B222AF1EDA300B0DE81 /* libZLib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84498A832AF18C7A005EF5A5 /* libZLib.a */; }; 84619B392AF1F73900B0DE81 /* GL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD6552AC810620006A435 /* GL.hpp */; }; 84619B3C2AF1FE4C00B0DE81 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84619B3B2AF1FE4C00B0DE81 /* OpenAL.framework */; }; @@ -350,8 +349,6 @@ 8477B44D2C4DE77F004E1AC5 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B4072C4DE77F004E1AC5 /* Default.png */; }; 8477B44E2C4DE77F004E1AC5 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B4082C4DE77F004E1AC5 /* Default@2x.png */; }; 8488C08A2B1EDD4F001AEC4F /* ShowKeyboardView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8488C0892B1EDD4F001AEC4F /* ShowKeyboardView.mm */; }; - 8489B3222A86E464004CA8EC /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8489B3212A86E464004CA8EC /* Foundation.framework */; }; - 8489B3242A86E46A004CA8EC /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8489B3232A86E46A004CA8EC /* AppKit.framework */; }; 848CBD102AFD847C007634F6 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 848CBD0F2AFD847C007634F6 /* AVFoundation.framework */; }; 849259202AD8FCFC0081F5B9 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8489B3212A86E464004CA8EC /* Foundation.framework */; }; 849259562AD8FD4F0081F5B9 /* minecraftpeViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 849259482AD8FD4F0081F5B9 /* minecraftpeViewController.xib */; }; @@ -1168,7 +1165,6 @@ 84BF63D32AF186C9008A9995 /* TransparentTile.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD7292AC810620006A435 /* TransparentTile.hpp */; }; 84BF63D42AF186C9008A9995 /* TreeTile.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD72B2AC810620006A435 /* TreeTile.hpp */; }; 84BF63D52AF186C9008A9995 /* WireTile.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD72D2AC810620006A435 /* WireTile.hpp */; }; - 84BF63D82AF18771008A9995 /* libWorld.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84BF630B2AF1859D008A9995 /* libWorld.a */; }; 84C0D8032B15A1D0007E1E76 /* PlatformDefinitions.h in Headers */ = {isa = PBXBuildFile; fileRef = 84C0D8022B15A1D0007E1E76 /* PlatformDefinitions.h */; }; 84C208532AF88A5000BAE438 /* grass_side_transparent.png in Resources */ = {isa = PBXBuildFile; fileRef = 84C208512AF88A5000BAE438 /* grass_side_transparent.png */; }; 84C208542AF88A5000BAE438 /* patch_data.txt in Resources */ = {isa = PBXBuildFile; fileRef = 84C208522AF88A5000BAE438 /* patch_data.txt */; }; @@ -1215,12 +1211,10 @@ 84CCBC9D2E618BF000E251AF /* libCommon.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84E4BFAE2AE9854B0023E16A /* libCommon.a */; }; 84CCBC9E2E618C1D00E251AF /* libNBT.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84CCBC452E61849800E251AF /* libNBT.a */; }; 84CCBC9F2E61910500E251AF /* libClient.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84B8AEE72AF188D8008DE93D /* libClient.a */; }; - 84CCBCA02E61910500E251AF /* libWorld.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84BF630B2AF1859D008A9995 /* libWorld.a */; }; 84CED51F2E672826006BC585 /* ConvertWorldScreen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84CED51D2E672826006BC585 /* ConvertWorldScreen.cpp */; }; 84CED5202E672826006BC585 /* ConvertWorldScreen.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84CED51E2E672826006BC585 /* ConvertWorldScreen.hpp */; }; 84CEF0032AE3C97D006C5829 /* EAGLView.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CEF0022AE3C97D006C5829 /* EAGLView.m */; }; 84D9A30E2AF18EC000B00AD3 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8489B3252A86E4B0004CA8EC /* OpenGL.framework */; }; - 84D9A30F2AF18EE700B00AD3 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8489B3252A86E4B0004CA8EC /* OpenGL.framework */; settings = {ATTRIBUTES = (Required, ); }; }; 84E0011B2AF39E84009B9555 /* BuildActionIntention.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E000FB2AF39E84009B9555 /* BuildActionIntention.hpp */; }; 84E0011C2AF39E84009B9555 /* CustomInputHolder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E000FC2AF39E84009B9555 /* CustomInputHolder.cpp */; }; 84E0011D2AF39E84009B9555 /* CustomInputHolder.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E000FD2AF39E84009B9555 /* CustomInputHolder.hpp */; }; @@ -1264,7 +1258,6 @@ 84E4BFBB2AE9869A0023E16A /* Timer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD6332AC810620006A435 /* Timer.cpp */; }; 84E4BFBC2AE9869A0023E16A /* Util.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD6352AC810620006A435 /* Util.cpp */; }; 84E4BFBD2AE9869A0023E16A /* Utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD6372AC810620006A435 /* Utils.cpp */; }; - 84E4BFC02AE987130023E16A /* libCommon.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84E4BFAE2AE9854B0023E16A /* libCommon.a */; }; 84E78C7B2B58B3E000D515EF /* Rocket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E78C792B58B3E000D515EF /* Rocket.cpp */; }; 84E78C7C2B58B3E000D515EF /* Rocket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E78C7A2B58B3E000D515EF /* Rocket.hpp */; }; 84E78C7F2B58B5CC00D515EF /* RocketRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E78C7D2B58B5CC00D515EF /* RocketRenderer.cpp */; }; @@ -1395,7 +1388,7 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - 8406FDD72AF1838A00B09C1D /* PBXContainerItemProxy */ = { + 84043C412E76626D00B988F0 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 8489B08F2A86D4B2004CA8EC /* Project object */; proxyType = 1; @@ -1409,13 +1402,6 @@ remoteGlobalIDString = 84FFBD7D2ACA2876005A8CCF; remoteInfo = RakNet; }; - 842610892AE98A640065905F /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 8489B08F2A86D4B2004CA8EC /* Project object */; - proxyType = 1; - remoteGlobalIDString = 84E4BFAD2AE9854B0023E16A; - remoteInfo = Common; - }; 84498A9E2AF18D01005EF5A5 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 8489B08F2A86D4B2004CA8EC /* Project object */; @@ -1423,27 +1409,6 @@ remoteGlobalIDString = 84498A762AF18C7A005EF5A5; remoteInfo = ZLib; }; - 84619B142AF1EC3500B0DE81 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 8489B08F2A86D4B2004CA8EC /* Project object */; - proxyType = 1; - remoteGlobalIDString = 84E4BFAD2AE9854B0023E16A; - remoteInfo = Common; - }; - 84619B162AF1EC3500B0DE81 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 8489B08F2A86D4B2004CA8EC /* Project object */; - proxyType = 1; - remoteGlobalIDString = 8406FD162AF1814500B09C1D; - remoteInfo = Renderer; - }; - 84619B182AF1EC3500B0DE81 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 8489B08F2A86D4B2004CA8EC /* Project object */; - proxyType = 1; - remoteGlobalIDString = 84BF62FE2AF1859D008A9995; - remoteInfo = World; - }; 84619B1A2AF1EC3500B0DE81 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 8489B08F2A86D4B2004CA8EC /* Project object */; @@ -1486,13 +1451,6 @@ remoteGlobalIDString = 84B8AE132AF188D8008DE93D; remoteInfo = Client; }; - 84BF63D62AF1876C008A9995 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 8489B08F2A86D4B2004CA8EC /* Project object */; - proxyType = 1; - remoteGlobalIDString = 84BF62FE2AF1859D008A9995; - remoteInfo = World; - }; 84CCBC8B2E61861900E251AF /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 8489B08F2A86D4B2004CA8EC /* Project object */; @@ -2992,15 +2950,10 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 84498AA02AF18D08005EF5A5 /* libZLib.a in Frameworks */, 84B8AF8B2AF18ACF008DE93D /* libClient.a in Frameworks */, - 84BF63D82AF18771008A9995 /* libWorld.a in Frameworks */, - 8406FDD92AF184B600B09C1D /* libRenderer.a in Frameworks */, - 84E4BFC02AE987130023E16A /* libCommon.a in Frameworks */, + 84043C452E7663DB00B988F0 /* libZLib.a in Frameworks */, 84171E812B1A6227008B82E6 /* OpenAL.framework in Frameworks */, - 84D9A30F2AF18EE700B00AD3 /* OpenGL.framework in Frameworks */, - 8489B3242A86E46A004CA8EC /* AppKit.framework in Frameworks */, - 8489B3222A86E464004CA8EC /* Foundation.framework in Frameworks */, + 84043C442E7663A000B988F0 /* OpenGL.framework in Frameworks */, 8443B6EA2A98675F0086730C /* libSDL2.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -3010,16 +2963,13 @@ buildActionMask = 2147483647; files = ( 84CCBC9F2E61910500E251AF /* libClient.a in Frameworks */, - 84CCBCA02E61910500E251AF /* libWorld.a in Frameworks */, - 8420EF302B32B4EE0051910E /* libSystem.dylib in Frameworks */, - 84619B1F2AF1EDA300B0DE81 /* libCommon.a in Frameworks */, - 84619B202AF1EDA300B0DE81 /* libRenderer.a in Frameworks */, 84619B222AF1EDA300B0DE81 /* libZLib.a in Frameworks */, + 8420EF302B32B4EE0051910E /* libSystem.dylib in Frameworks */, 84EAE8DE2AF1EAA1000894E8 /* UIKit.framework in Frameworks */, 849259202AD8FCFC0081F5B9 /* Foundation.framework in Frameworks */, 84EAE8E02AF1EAA9000894E8 /* CoreGraphics.framework in Frameworks */, - 84EAE8E42AF1EABE000894E8 /* OpenGLES.framework in Frameworks */, 84619B3C2AF1FE4C00B0DE81 /* OpenAL.framework in Frameworks */, + 84EAE8E42AF1EABE000894E8 /* OpenGLES.framework in Frameworks */, 848CBD102AFD847C007634F6 /* AVFoundation.framework in Frameworks */, 84619B3E2AF1FEB700B0DE81 /* QuartzCore.framework in Frameworks */, ); @@ -3039,6 +2989,7 @@ files = ( 84B8AF872AF18A2C008DE93D /* libCommon.a in Frameworks */, 84B8AF882AF18A2C008DE93D /* libNetwork.a in Frameworks */, + 84043C432E76627900B988F0 /* libRenderer.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -5897,8 +5848,8 @@ buildRules = ( ); dependencies = ( - 84CCBC902E6186D000E251AF /* PBXTargetDependency */, 84CCBC8E2E6186CD00E251AF /* PBXTargetDependency */, + 84CCBC902E6186D000E251AF /* PBXTargetDependency */, 842610812AE9898E0065905F /* PBXTargetDependency */, ); name = Network; @@ -5934,11 +5885,8 @@ buildRules = ( ); dependencies = ( - 84498A9F2AF18D01005EF5A5 /* PBXTargetDependency */, 84B8AF8A2AF18A84008DE93D /* PBXTargetDependency */, - 84BF63D72AF1876C008A9995 /* PBXTargetDependency */, - 8406FDD82AF1838A00B09C1D /* PBXTargetDependency */, - 8426108A2AE98A640065905F /* PBXTargetDependency */, + 84498A9F2AF18D01005EF5A5 /* PBXTargetDependency */, ); name = MinecraftClient.SDL2; productName = Minecraft; @@ -5957,9 +5905,6 @@ buildRules = ( ); dependencies = ( - 84619B152AF1EC3500B0DE81 /* PBXTargetDependency */, - 84619B172AF1EC3500B0DE81 /* PBXTargetDependency */, - 84619B192AF1EC3500B0DE81 /* PBXTargetDependency */, 84619B1B2AF1EC3500B0DE81 /* PBXTargetDependency */, 84619B1D2AF1EC3500B0DE81 /* PBXTargetDependency */, ); @@ -5998,6 +5943,7 @@ dependencies = ( 84B8AF842AF18A25008DE93D /* PBXTargetDependency */, 84B8AF862AF18A25008DE93D /* PBXTargetDependency */, + 84043C422E76626D00B988F0 /* PBXTargetDependency */, ); name = Client; productName = Client; @@ -6112,16 +6058,16 @@ ); targets = ( 8489B0962A86D4B2004CA8EC /* MinecraftClient.SDL2 */, - 84FFBD7D2ACA2876005A8CCF /* RakNet */, 8492591C2AD8FCFC0081F5B9 /* minecraftpe */, + 84B8AE132AF188D8008DE93D /* Client */, 84E4BFAD2AE9854B0023E16A /* Common */, + 84CCBC442E61849800E251AF /* NBT */, 842610672AE988D30065905F /* Network */, 8406FD162AF1814500B09C1D /* Renderer */, 84BF62FE2AF1859D008A9995 /* World */, - 84B8AE132AF188D8008DE93D /* Client */, 84AAF5972AF18B9500BD67F4 /* OpenGL */, + 84FFBD7D2ACA2876005A8CCF /* RakNet */, 84498A762AF18C7A005EF5A5 /* ZLib */, - 84CCBC442E61849800E251AF /* NBT */, ); }; /* End PBXProject section */ @@ -6657,12 +6603,12 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 8435BB192DCD47F400D38282 /* SoundStreamAL.cpp in Sources */, 84EAE8F72AF1EAFA000894E8 /* main.cpp in Sources */, 841DD8772AF8AA7A00AA3B66 /* AppPlatform_sdl_base.cpp in Sources */, 841DD8782AF8AA7A00AA3B66 /* AppPlatform_sdl.cpp in Sources */, - 84AA8E802B32FB33003F5B82 /* stb_image_impl.c in Sources */, + 8435BB192DCD47F400D38282 /* SoundStreamAL.cpp in Sources */, 8441F9962DB4E911005977BD /* SoundSystemAL.cpp in Sources */, + 84AA8E802B32FB33003F5B82 /* stb_image_impl.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -7130,41 +7076,21 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ - 8406FDD82AF1838A00B09C1D /* PBXTargetDependency */ = { + 84043C422E76626D00B988F0 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 8406FD162AF1814500B09C1D /* Renderer */; - targetProxy = 8406FDD72AF1838A00B09C1D /* PBXContainerItemProxy */; + targetProxy = 84043C412E76626D00B988F0 /* PBXContainerItemProxy */; }; 842610812AE9898E0065905F /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 84FFBD7D2ACA2876005A8CCF /* RakNet */; targetProxy = 842610802AE9898E0065905F /* PBXContainerItemProxy */; }; - 8426108A2AE98A640065905F /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 84E4BFAD2AE9854B0023E16A /* Common */; - targetProxy = 842610892AE98A640065905F /* PBXContainerItemProxy */; - }; 84498A9F2AF18D01005EF5A5 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 84498A762AF18C7A005EF5A5 /* ZLib */; targetProxy = 84498A9E2AF18D01005EF5A5 /* PBXContainerItemProxy */; }; - 84619B152AF1EC3500B0DE81 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 84E4BFAD2AE9854B0023E16A /* Common */; - targetProxy = 84619B142AF1EC3500B0DE81 /* PBXContainerItemProxy */; - }; - 84619B172AF1EC3500B0DE81 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 8406FD162AF1814500B09C1D /* Renderer */; - targetProxy = 84619B162AF1EC3500B0DE81 /* PBXContainerItemProxy */; - }; - 84619B192AF1EC3500B0DE81 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 84BF62FE2AF1859D008A9995 /* World */; - targetProxy = 84619B182AF1EC3500B0DE81 /* PBXContainerItemProxy */; - }; 84619B1B2AF1EC3500B0DE81 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 84B8AE132AF188D8008DE93D /* Client */; @@ -7195,11 +7121,6 @@ target = 84B8AE132AF188D8008DE93D /* Client */; targetProxy = 84B8AF892AF18A84008DE93D /* PBXContainerItemProxy */; }; - 84BF63D72AF1876C008A9995 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 84BF62FE2AF1859D008A9995 /* World */; - targetProxy = 84BF63D62AF1876C008A9995 /* PBXContainerItemProxy */; - }; 84CCBC8C2E61861900E251AF /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 84CCBC442E61849800E251AF /* NBT */; From bef0c089adb29c75aee9071d44a1547a46b7d5d4 Mon Sep 17 00:00:00 2001 From: Vimdo <156633328+Vimd0@users.noreply.github.com> Date: Wed, 24 Sep 2025 02:10:50 -0400 Subject: [PATCH 034/293] More blocks, items, and improvements (#189) * Added new tiles & items Blocks: - Cactus - Tall Grass - Dead Bush - Pumpkin - Jack-O'-Lantern (Lit Pumpkin) - Netherrack (Hellstone) - Soul Sand - Glowstone - Web - Fence Auxiliary: - Wool - Wood - Leaves - Slabs Features: - CactusFeature - PumpkinFeature * Added a `FEATURE_PLANT_VEGGIE` macro in GameMods.hpp for pumpkins, tall grass, and more to generate Note: put tall_grass.png and dead_bush.png in patches * Added more items to the creative Inventory * Added every b1.7.3 item (of course most of them aren't functional yet) * Added /give & /clear commands (based off Morgana's implementation) * Added 0.6.0 d-pad & GUI tweaks, requires new textures, locked behind macro * Added a Third Person View option * Added Chat button to inventory, which is only visible on touchscreen * Added pick block to get aux values * Added `ENH_NEW_LADDER_BEHAVIOR` macro, enabled by default * Added missing fire dynamic texture, fixing the placeholder being rendered * Fixed a bug where items were only held from the first row of the inventory * Fixed the player holding animation to work when items are held * Fixed crash caused by item 256 rendering * Fixed block friction and entity movement being inaccurate * Fixed `SHAPE_RANDOM_CROSS` rendering height * Renamed some fields for better understanding * Removed goto in Mob::travel * Fixed swapped axes in Mob::travel fluid movement * Renamed `Entity::m_onGround` to `Entity::m_bOnGround` * Formatted code in `Entity::move` and removed remaining use of auto * Removed uses of float specification in uppercase * Renamed `Entity::field_D4` to `Entity::m_bWasInWater`, and changed its type to `bool` * Renamed `Entity::field_D5` to `Entity::m_bFireImmune` * Renamed `Entity::field_D6` to `Entity::m_bFirstTick` --------- Co-authored-by: Brent <43089001+BrentDaMage@users.noreply.github.com> Co-authored-by: Wilyicaro --- GameMods.hpp | 9 +- game/assets/patches/patch_data.txt | 7 + .../Minecraft.xcodeproj/project.pbxproj | 214 +++++-- .../windows/projects/World/World.vcxproj | 25 + .../projects/World/World.vcxproj.filters | 77 ++- platforms/xenon/projects/Minecraft.vcxproj | 25 + .../xenon/projects/Minecraft.vcxproj.filters | 75 +++ source/CMakeLists.txt | 14 + source/client/app/Minecraft.cpp | 4 +- source/client/gui/Gui.cpp | 27 +- source/client/gui/components/OptionList.cpp | 3 +- .../screens/IngameBlockSelectionScreen.cpp | 15 +- .../screens/IngameBlockSelectionScreen.hpp | 1 + source/client/gui/screens/StartMenuScreen.cpp | 9 +- source/client/player/input/IMoveInput.hpp | 2 + .../player/input/TouchscreenInput_TestFps.cpp | 122 +++- .../player/input/TouchscreenInput_TestFps.hpp | 2 + source/client/renderer/ItemInHandRenderer.cpp | 29 +- source/client/renderer/LavaSideTexture.cpp | 2 +- source/client/renderer/LavaTexture.cpp | 2 +- source/client/renderer/LevelRenderer.cpp | 7 +- source/client/renderer/TileRenderer.cpp | 199 ++++++- source/client/renderer/TileRenderer.hpp | 2 +- .../renderer/entity/HumanoidMobRenderer.cpp | 22 +- .../renderer/entity/HumanoidMobRenderer.hpp | 2 +- source/common/Util.cpp | 3 +- source/common/Util.hpp | 1 + source/common/Utils.hpp | 12 +- source/network/ServerSideNetworkHandler.cpp | 73 ++- source/network/ServerSideNetworkHandler.hpp | 2 + source/world/entity/Chicken.cpp | 6 +- source/world/entity/Entity.cpp | 545 ++++++------------ source/world/entity/Entity.hpp | 19 +- source/world/entity/FallingTile.cpp | 2 +- source/world/entity/ItemEntity.cpp | 6 +- source/world/entity/LocalPlayer.cpp | 2 +- source/world/entity/Mob.cpp | 67 ++- source/world/entity/Player.cpp | 9 +- source/world/entity/PrimedTnt.cpp | 2 +- source/world/entity/Sheep.cpp | 2 +- source/world/entity/Spider.cpp | 2 +- source/world/entity/TripodCamera.cpp | 2 +- source/world/item/AuxTileItem.cpp | 18 + source/world/item/AuxTileItem.hpp | 11 + source/world/item/ClothItem.cpp | 27 + source/world/item/ClothItem.hpp | 12 + source/world/item/Inventory.cpp | 85 ++- source/world/item/Inventory.hpp | 2 + source/world/item/Item.cpp | 335 ++++++++++- source/world/item/Item.hpp | 4 +- source/world/item/SlabItem.cpp | 34 ++ source/world/item/SlabItem.hpp | 10 + source/world/level/Level.cpp | 3 +- source/world/level/Material.cpp | 5 +- source/world/level/Material.hpp | 3 +- source/world/level/TilePos.cpp | 3 +- .../levelgen/chunk/RandomLevelSource.cpp | 67 ++- .../level/levelgen/feature/CactusFeature.cpp | 27 + .../world/level/levelgen/feature/Feature.hpp | 25 + .../level/levelgen/feature/PumpkinFeature.cpp | 19 + .../levelgen/feature/VegetationFeature.cpp | 36 ++ source/world/level/path/PathFinder.cpp | 27 +- source/world/level/path/PathFinder.hpp | 1 + source/world/level/storage/LevelData.cpp | 4 +- source/world/particle/ExplodeParticle.cpp | 2 +- source/world/particle/FlameParticle.cpp | 2 +- source/world/particle/LavaParticle.cpp | 2 +- source/world/particle/Particle.cpp | 2 +- source/world/particle/RedDustParticle.cpp | 2 +- source/world/particle/SmokeParticle.cpp | 2 +- source/world/tile/CactusTile.cpp | 99 ++++ source/world/tile/CactusTile.hpp | 20 + source/world/tile/ClothTile.cpp | 21 +- source/world/tile/ClothTile.hpp | 9 +- source/world/tile/DeadBush.cpp | 18 + source/world/tile/DeadBush.hpp | 11 + source/world/tile/DoorTile.cpp | 4 +- source/world/tile/FenceTile.cpp | 42 ++ source/world/tile/FenceTile.hpp | 14 + source/world/tile/FireTile.cpp | 6 + source/world/tile/GlowstoneTile.cpp | 16 + source/world/tile/GlowstoneTile.hpp | 12 + source/world/tile/GravelTile.cpp | 4 +- source/world/tile/GravelTile.hpp | 2 +- source/world/tile/IceTile.cpp | 1 + source/world/tile/LeafTile.cpp | 10 + source/world/tile/LeafTile.hpp | 2 + source/world/tile/PumpkinTile.cpp | 41 ++ source/world/tile/PumpkinTile.hpp | 13 + source/world/tile/ReedTile.cpp | 2 +- source/world/tile/Sapling.cpp | 34 +- source/world/tile/Sapling.hpp | 2 +- source/world/tile/SoulSandTile.cpp | 19 + source/world/tile/SoulSandTile.hpp | 11 + source/world/tile/StoneSlabTile.cpp | 17 +- source/world/tile/StoneSlabTile.hpp | 8 + source/world/tile/TallGrass.cpp | 40 ++ source/world/tile/TallGrass.hpp | 14 + source/world/tile/Tile.cpp | 243 ++++---- source/world/tile/Tile.hpp | 29 +- source/world/tile/Web.cpp | 36 ++ source/world/tile/Web.hpp | 16 + 102 files changed, 2456 insertions(+), 781 deletions(-) create mode 100644 source/world/item/AuxTileItem.cpp create mode 100644 source/world/item/AuxTileItem.hpp create mode 100644 source/world/item/ClothItem.cpp create mode 100644 source/world/item/ClothItem.hpp create mode 100644 source/world/item/SlabItem.cpp create mode 100644 source/world/item/SlabItem.hpp create mode 100644 source/world/level/levelgen/feature/CactusFeature.cpp create mode 100644 source/world/level/levelgen/feature/PumpkinFeature.cpp create mode 100644 source/world/level/levelgen/feature/VegetationFeature.cpp create mode 100644 source/world/tile/CactusTile.cpp create mode 100644 source/world/tile/CactusTile.hpp create mode 100644 source/world/tile/DeadBush.cpp create mode 100644 source/world/tile/DeadBush.hpp create mode 100644 source/world/tile/FenceTile.cpp create mode 100644 source/world/tile/FenceTile.hpp create mode 100644 source/world/tile/GlowstoneTile.cpp create mode 100644 source/world/tile/GlowstoneTile.hpp create mode 100644 source/world/tile/PumpkinTile.cpp create mode 100644 source/world/tile/PumpkinTile.hpp create mode 100644 source/world/tile/SoulSandTile.cpp create mode 100644 source/world/tile/SoulSandTile.hpp create mode 100644 source/world/tile/TallGrass.cpp create mode 100644 source/world/tile/TallGrass.hpp create mode 100644 source/world/tile/Web.cpp create mode 100644 source/world/tile/Web.hpp diff --git a/GameMods.hpp b/GameMods.hpp index 29c75484f..f447ce60b 100644 --- a/GameMods.hpp +++ b/GameMods.hpp @@ -16,8 +16,10 @@ // Tests //#define TEST_SURVIVAL_MODE // Test survival mode. +//#define TEST_CAVES // Generates caves around the world. // Features (major changes) +//#define FEATURE_PLANT_VEGGIES // Generates tall grass, and dead bushes around the world. // Enhancements (minor changes) //#define ENH_ENTITY_SHADING // Allows shading of entities -- Currently we are abandoning this. Want to add normal support @@ -35,12 +37,15 @@ #define ENH_ALLOW_SCROLL_WHEEL // Allow use of the scroll wheel to change selected inventory slots #define ENH_3D_INVENTORY_TILES // Uses 3D rendered inventory tiles, use with ENH_SHADE_HELD_TILES to render correctly. #define ENH_MENU_BACKGROUND // Renders a spinning panorama (if it's available) in the background of the main menu -#define ENH_GUI_ITEM_POP // Calls Inventory::tick() to create the "pop" animation for items that enter the hotbar. This function was not present on Pocket Edition. +#define ENH_GUI_ITEM_POP // Calls Inventory::tick() to create the "pop" animation for items that enter the hotbar. This function was not present on Pocket Edition. //#define ENH_DISABLE_FORCED_SAVE_UPGRADES // Prevents the forced format-version upgrade of world/level saves, effectively opting-out of new save formats. See LEVEL_STORAGE_VERSION_DEFAULT in LevelData.hpp. -//#define ENH_FACED_TERRAIN_PARTICLES // Sets the TerrainParticle's texture depending on the face the block is being hit from. This is something Notch never did for whatever reason. +//#define ENH_FACED_TERRAIN_PARTICLES // Sets the TerrainParticle's texture depending on the face the block is being hit from. This is something Notch never did for whatever reason. +#define ENH_NEW_LADDER_BEHAVIOR // Use Java Beta 1.5 ladder behavior // TODO: Implement this permanently? #define ENH_IMPROVED_SAVING // Improve world saving. The original Minecraft doesn't always really save for some reason +// TODO: Toggle in the options menu +//#define ENH_NEW_TOUCH_CONTROLS // Uses the newer touch controls found in MCPE 0.6.0 // Toggle Demo Mode //#define DEMO diff --git a/game/assets/patches/patch_data.txt b/game/assets/patches/patch_data.txt index 61d77a490..399be306d 100755 --- a/game/assets/patches/patch_data.txt +++ b/game/assets/patches/patch_data.txt @@ -20,6 +20,13 @@ terrain|2|14|n_rocket_launcher.png terrain|3|14|n_rocket_launched.png items|14|2|n_rocket.png +# Add plant veggie patches +terrain|7|2|tall_grass.png +terrain|7|3|dead_bush.png +# terrain|8|3|fern.png +terrain|15|3|spruce_sapling.png +terrain|15|4|birch_sapling.png + # Stop now to ignore the below commands. They're for a patch I'm working on that I don't want to release yet. stop_now diff --git a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj index 98f0c61ba..e04541310 100644 --- a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj +++ b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj @@ -1250,6 +1250,36 @@ 84E001B82AF3A3CB009B9555 /* SmoothFloat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E001B62AF3A3CB009B9555 /* SmoothFloat.cpp */; }; 84E001B92AF3A3CB009B9555 /* SmoothFloat.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E001B72AF3A3CB009B9555 /* SmoothFloat.hpp */; }; 84E001BB2AF3AF9B009B9555 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 84E001BA2AF3AF9B009B9555 /* MainWindow.xib */; }; + 84E1C9BA2E7FDAE3007D2F5D /* birch_sapling.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E1C9B52E7FDAE3007D2F5D /* birch_sapling.png */; }; + 84E1C9BB2E7FDAE3007D2F5D /* dead_bush.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E1C9B62E7FDAE3007D2F5D /* dead_bush.png */; }; + 84E1C9BC2E7FDAE3007D2F5D /* fern.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E1C9B72E7FDAE3007D2F5D /* fern.png */; }; + 84E1C9BD2E7FDAE3007D2F5D /* spruce_sapling.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E1C9B82E7FDAE3007D2F5D /* spruce_sapling.png */; }; + 84E1C9BE2E7FDAE3007D2F5D /* tall_grass.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E1C9B92E7FDAE3007D2F5D /* tall_grass.png */; }; + 84E1C9CF2E7FDC26007D2F5D /* CactusTile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E1C9BF2E7FDC26007D2F5D /* CactusTile.cpp */; }; + 84E1C9D02E7FDC26007D2F5D /* CactusTile.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E1C9C02E7FDC26007D2F5D /* CactusTile.hpp */; }; + 84E1C9D12E7FDC26007D2F5D /* DeadBush.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E1C9C12E7FDC26007D2F5D /* DeadBush.cpp */; }; + 84E1C9D22E7FDC26007D2F5D /* DeadBush.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E1C9C22E7FDC26007D2F5D /* DeadBush.hpp */; }; + 84E1C9D32E7FDC26007D2F5D /* FenceTile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E1C9C32E7FDC26007D2F5D /* FenceTile.cpp */; }; + 84E1C9D42E7FDC26007D2F5D /* FenceTile.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E1C9C42E7FDC26007D2F5D /* FenceTile.hpp */; }; + 84E1C9D52E7FDC26007D2F5D /* GlowstoneTile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E1C9C52E7FDC26007D2F5D /* GlowstoneTile.cpp */; }; + 84E1C9D62E7FDC26007D2F5D /* GlowstoneTile.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E1C9C62E7FDC26007D2F5D /* GlowstoneTile.hpp */; }; + 84E1C9D72E7FDC26007D2F5D /* PumpkinTile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E1C9C72E7FDC26007D2F5D /* PumpkinTile.cpp */; }; + 84E1C9D82E7FDC26007D2F5D /* PumpkinTile.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E1C9C82E7FDC26007D2F5D /* PumpkinTile.hpp */; }; + 84E1C9D92E7FDC26007D2F5D /* SoulSandTile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E1C9C92E7FDC26007D2F5D /* SoulSandTile.cpp */; }; + 84E1C9DA2E7FDC26007D2F5D /* SoulSandTile.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E1C9CA2E7FDC26007D2F5D /* SoulSandTile.hpp */; }; + 84E1C9DB2E7FDC26007D2F5D /* TallGrass.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E1C9CB2E7FDC26007D2F5D /* TallGrass.cpp */; }; + 84E1C9DC2E7FDC26007D2F5D /* TallGrass.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E1C9CC2E7FDC26007D2F5D /* TallGrass.hpp */; }; + 84E1C9DD2E7FDC26007D2F5D /* Web.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E1C9CD2E7FDC26007D2F5D /* Web.cpp */; }; + 84E1C9DE2E7FDC26007D2F5D /* Web.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E1C9CE2E7FDC26007D2F5D /* Web.hpp */; }; + 84E1C9E52E7FDC72007D2F5D /* AuxTileItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E1C9DF2E7FDC72007D2F5D /* AuxTileItem.cpp */; }; + 84E1C9E62E7FDC72007D2F5D /* AuxTileItem.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E1C9E02E7FDC72007D2F5D /* AuxTileItem.hpp */; }; + 84E1C9E72E7FDC72007D2F5D /* ClothItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E1C9E12E7FDC72007D2F5D /* ClothItem.cpp */; }; + 84E1C9E82E7FDC72007D2F5D /* ClothItem.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E1C9E22E7FDC72007D2F5D /* ClothItem.hpp */; }; + 84E1C9E92E7FDC72007D2F5D /* SlabItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E1C9E32E7FDC72007D2F5D /* SlabItem.cpp */; }; + 84E1C9EA2E7FDC72007D2F5D /* SlabItem.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E1C9E42E7FDC72007D2F5D /* SlabItem.hpp */; }; + 84E1C9EE2E7FDC89007D2F5D /* CactusFeature.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E1C9EB2E7FDC89007D2F5D /* CactusFeature.cpp */; }; + 84E1C9EF2E7FDC89007D2F5D /* PumpkinFeature.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E1C9EC2E7FDC89007D2F5D /* PumpkinFeature.cpp */; }; + 84E1C9F02E7FDC89007D2F5D /* VegetationFeature.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E1C9ED2E7FDC89007D2F5D /* VegetationFeature.cpp */; }; 84E4BFB52AE9869A0023E16A /* CThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD6262AC810620006A435 /* CThread.cpp */; }; 84E4BFB62AE9869A0023E16A /* Logger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD6282AC810620006A435 /* Logger.cpp */; }; 84E4BFB72AE9869A0023E16A /* Matrix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD62B2AC810620006A435 /* Matrix.cpp */; }; @@ -2897,6 +2927,36 @@ 84E001B62AF3A3CB009B9555 /* SmoothFloat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SmoothFloat.cpp; sourceTree = ""; }; 84E001B72AF3A3CB009B9555 /* SmoothFloat.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SmoothFloat.hpp; sourceTree = ""; }; 84E001BA2AF3AF9B009B9555 /* MainWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = ""; }; + 84E1C9B52E7FDAE3007D2F5D /* birch_sapling.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = birch_sapling.png; sourceTree = ""; }; + 84E1C9B62E7FDAE3007D2F5D /* dead_bush.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = dead_bush.png; sourceTree = ""; }; + 84E1C9B72E7FDAE3007D2F5D /* fern.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = fern.png; sourceTree = ""; }; + 84E1C9B82E7FDAE3007D2F5D /* spruce_sapling.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = spruce_sapling.png; sourceTree = ""; }; + 84E1C9B92E7FDAE3007D2F5D /* tall_grass.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = tall_grass.png; sourceTree = ""; }; + 84E1C9BF2E7FDC26007D2F5D /* CactusTile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CactusTile.cpp; sourceTree = ""; }; + 84E1C9C02E7FDC26007D2F5D /* CactusTile.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CactusTile.hpp; sourceTree = ""; }; + 84E1C9C12E7FDC26007D2F5D /* DeadBush.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeadBush.cpp; sourceTree = ""; }; + 84E1C9C22E7FDC26007D2F5D /* DeadBush.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DeadBush.hpp; sourceTree = ""; }; + 84E1C9C32E7FDC26007D2F5D /* FenceTile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FenceTile.cpp; sourceTree = ""; }; + 84E1C9C42E7FDC26007D2F5D /* FenceTile.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FenceTile.hpp; sourceTree = ""; }; + 84E1C9C52E7FDC26007D2F5D /* GlowstoneTile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GlowstoneTile.cpp; sourceTree = ""; }; + 84E1C9C62E7FDC26007D2F5D /* GlowstoneTile.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = GlowstoneTile.hpp; sourceTree = ""; }; + 84E1C9C72E7FDC26007D2F5D /* PumpkinTile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PumpkinTile.cpp; sourceTree = ""; }; + 84E1C9C82E7FDC26007D2F5D /* PumpkinTile.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PumpkinTile.hpp; sourceTree = ""; }; + 84E1C9C92E7FDC26007D2F5D /* SoulSandTile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SoulSandTile.cpp; sourceTree = ""; }; + 84E1C9CA2E7FDC26007D2F5D /* SoulSandTile.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SoulSandTile.hpp; sourceTree = ""; }; + 84E1C9CB2E7FDC26007D2F5D /* TallGrass.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TallGrass.cpp; sourceTree = ""; }; + 84E1C9CC2E7FDC26007D2F5D /* TallGrass.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TallGrass.hpp; sourceTree = ""; }; + 84E1C9CD2E7FDC26007D2F5D /* Web.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Web.cpp; sourceTree = ""; }; + 84E1C9CE2E7FDC26007D2F5D /* Web.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Web.hpp; sourceTree = ""; }; + 84E1C9DF2E7FDC72007D2F5D /* AuxTileItem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AuxTileItem.cpp; sourceTree = ""; }; + 84E1C9E02E7FDC72007D2F5D /* AuxTileItem.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AuxTileItem.hpp; sourceTree = ""; }; + 84E1C9E12E7FDC72007D2F5D /* ClothItem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClothItem.cpp; sourceTree = ""; }; + 84E1C9E22E7FDC72007D2F5D /* ClothItem.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ClothItem.hpp; sourceTree = ""; }; + 84E1C9E32E7FDC72007D2F5D /* SlabItem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SlabItem.cpp; sourceTree = ""; }; + 84E1C9E42E7FDC72007D2F5D /* SlabItem.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SlabItem.hpp; sourceTree = ""; }; + 84E1C9EB2E7FDC89007D2F5D /* CactusFeature.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CactusFeature.cpp; sourceTree = ""; }; + 84E1C9EC2E7FDC89007D2F5D /* PumpkinFeature.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PumpkinFeature.cpp; sourceTree = ""; }; + 84E1C9ED2E7FDC89007D2F5D /* VegetationFeature.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VegetationFeature.cpp; sourceTree = ""; }; 84E4BFAE2AE9854B0023E16A /* libCommon.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCommon.a; sourceTree = BUILT_PRODUCTS_DIR; }; 84E78C792B58B3E000D515EF /* Rocket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Rocket.cpp; sourceTree = ""; }; 84E78C7A2B58B3E000D515EF /* Rocket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Rocket.hpp; sourceTree = ""; }; @@ -3493,22 +3553,28 @@ 840DD66F2AC810620006A435 /* item */ = { isa = PBXGroup; children = ( - 840DD6712AC810620006A435 /* CameraItem.hpp */, + 84E1C9DF2E7FDC72007D2F5D /* AuxTileItem.cpp */, + 84E1C9E02E7FDC72007D2F5D /* AuxTileItem.hpp */, 840DD6702AC810620006A435 /* CameraItem.cpp */, - 840DD6732AC810620006A435 /* DoorItem.hpp */, + 840DD6712AC810620006A435 /* CameraItem.hpp */, + 84E1C9E12E7FDC72007D2F5D /* ClothItem.cpp */, + 84E1C9E22E7FDC72007D2F5D /* ClothItem.hpp */, 840DD6722AC810620006A435 /* DoorItem.cpp */, - 840DD6752AC810620006A435 /* Inventory.hpp */, + 840DD6732AC810620006A435 /* DoorItem.hpp */, 840DD6742AC810620006A435 /* Inventory.cpp */, - 840DD6772AC810620006A435 /* Item.hpp */, + 840DD6752AC810620006A435 /* Inventory.hpp */, 840DD6762AC810620006A435 /* Item.cpp */, - 840DD6792AC810620006A435 /* ItemInstance.hpp */, + 840DD6772AC810620006A435 /* Item.hpp */, 840DD6782AC810620006A435 /* ItemInstance.cpp */, - 84E78C822B58B5FB00D515EF /* RocketItem.hpp */, + 840DD6792AC810620006A435 /* ItemInstance.hpp */, 84E78C812B58B5FB00D515EF /* RocketItem.cpp */, - 840DD67B2AC810620006A435 /* TileItem.hpp */, + 84E78C822B58B5FB00D515EF /* RocketItem.hpp */, + 84E1C9E32E7FDC72007D2F5D /* SlabItem.cpp */, + 84E1C9E42E7FDC72007D2F5D /* SlabItem.hpp */, 840DD67A2AC810620006A435 /* TileItem.cpp */, - 840DD67D2AC810620006A435 /* TilePlanterItem.hpp */, + 840DD67B2AC810620006A435 /* TileItem.hpp */, 840DD67C2AC810620006A435 /* TilePlanterItem.cpp */, + 840DD67D2AC810620006A435 /* TilePlanterItem.hpp */, ); path = item; sourceTree = ""; @@ -3589,6 +3655,7 @@ isa = PBXGroup; children = ( 840DD6992AC810620006A435 /* BirchFeature.cpp */, + 84E1C9EB2E7FDC89007D2F5D /* CactusFeature.cpp */, 840DD69A2AC810620006A435 /* ClayFeature.cpp */, 840DD69B2AC810620006A435 /* Feature.cpp */, 840DD69C2AC810620006A435 /* Feature.hpp */, @@ -3599,10 +3666,12 @@ 840DD6A12AC810620006A435 /* LargeFeature.hpp */, 840DD6A22AC810620006A435 /* OreFeature.cpp */, 840DD6A32AC810620006A435 /* PineFeature.cpp */, + 84E1C9EC2E7FDC89007D2F5D /* PumpkinFeature.cpp */, 840DD6A42AC810620006A435 /* ReedsFeature.cpp */, 840DD6A52AC810620006A435 /* SpringFeature.cpp */, 840DD6A62AC810620006A435 /* SpruceFeature.cpp */, 840DD6A72AC810620006A435 /* TreeFeature.cpp */, + 84E1C9ED2E7FDC89007D2F5D /* VegetationFeature.cpp */, ); path = feature; sourceTree = ""; @@ -3687,84 +3756,100 @@ 840DD6E12AC810620006A435 /* tile */ = { isa = PBXGroup; children = ( - 840DD6E32AC810620006A435 /* BookshelfTile.hpp */, 840DD6E22AC810620006A435 /* BookshelfTile.cpp */, - 840DD6E52AC810620006A435 /* Bush.hpp */, + 840DD6E32AC810620006A435 /* BookshelfTile.hpp */, 840DD6E42AC810620006A435 /* Bush.cpp */, - 840DD6E72AC810620006A435 /* ClayTile.hpp */, + 840DD6E52AC810620006A435 /* Bush.hpp */, + 84E1C9BF2E7FDC26007D2F5D /* CactusTile.cpp */, + 84E1C9C02E7FDC26007D2F5D /* CactusTile.hpp */, 840DD6E62AC810620006A435 /* ClayTile.cpp */, - 840DD6E92AC810620006A435 /* ClothTile.hpp */, + 840DD6E72AC810620006A435 /* ClayTile.hpp */, 840DD6E82AC810620006A435 /* ClothTile.cpp */, - 840DD6EB2AC810620006A435 /* DirtTile.hpp */, + 840DD6E92AC810620006A435 /* ClothTile.hpp */, + 84E1C9C12E7FDC26007D2F5D /* DeadBush.cpp */, + 84E1C9C22E7FDC26007D2F5D /* DeadBush.hpp */, 840DD6EA2AC810620006A435 /* DirtTile.cpp */, - 840DD6ED2AC810620006A435 /* DoorTile.hpp */, + 840DD6EB2AC810620006A435 /* DirtTile.hpp */, 840DD6EC2AC810620006A435 /* DoorTile.cpp */, - 840DD6EF2AC810620006A435 /* FarmTile.hpp */, + 840DD6ED2AC810620006A435 /* DoorTile.hpp */, 840DD6EE2AC810620006A435 /* FarmTile.cpp */, - 840DD6F12AC810620006A435 /* FireTile.hpp */, + 840DD6EF2AC810620006A435 /* FarmTile.hpp */, + 84E1C9C32E7FDC26007D2F5D /* FenceTile.cpp */, + 84E1C9C42E7FDC26007D2F5D /* FenceTile.hpp */, 840DD6F02AC810620006A435 /* FireTile.cpp */, - 840DD6F32AC810620006A435 /* GlassTile.hpp */, + 840DD6F12AC810620006A435 /* FireTile.hpp */, 840DD6F22AC810620006A435 /* GlassTile.cpp */, - 840DD6F52AC810620006A435 /* GrassTile.hpp */, + 840DD6F32AC810620006A435 /* GlassTile.hpp */, + 84E1C9C52E7FDC26007D2F5D /* GlowstoneTile.cpp */, + 84E1C9C62E7FDC26007D2F5D /* GlowstoneTile.hpp */, 840DD6F42AC810620006A435 /* GrassTile.cpp */, - 840DD6F72AC810620006A435 /* GravelTile.hpp */, + 840DD6F52AC810620006A435 /* GrassTile.hpp */, 840DD6F62AC810620006A435 /* GravelTile.cpp */, - 840DD6F92AC810620006A435 /* HalfTransparentTile.hpp */, + 840DD6F72AC810620006A435 /* GravelTile.hpp */, 840DD6F82AC810620006A435 /* HalfTransparentTile.cpp */, - 840DD6FB2AC810620006A435 /* IceTile.hpp */, + 840DD6F92AC810620006A435 /* HalfTransparentTile.hpp */, 840DD6FA2AC810620006A435 /* IceTile.cpp */, - 840DD6FD2AC810620006A435 /* InvisibleTile.hpp */, + 840DD6FB2AC810620006A435 /* IceTile.hpp */, 840DD6FC2AC810620006A435 /* InvisibleTile.cpp */, - 840DD6FF2AC810620006A435 /* LadderTile.hpp */, + 840DD6FD2AC810620006A435 /* InvisibleTile.hpp */, 840DD6FE2AC810620006A435 /* LadderTile.cpp */, - 840DD7012AC810620006A435 /* LeafTile.hpp */, + 840DD6FF2AC810620006A435 /* LadderTile.hpp */, 840DD7002AC810620006A435 /* LeafTile.cpp */, - 840DD7032AC810620006A435 /* LiquidTile.hpp */, + 840DD7012AC810620006A435 /* LeafTile.hpp */, 840DD7022AC810620006A435 /* LiquidTile.cpp */, - 840DD7052AC810620006A435 /* LiquidTileDynamic.hpp */, + 840DD7032AC810620006A435 /* LiquidTile.hpp */, 840DD7042AC810620006A435 /* LiquidTileDynamic.cpp */, - 840DD7072AC810620006A435 /* LiquidTileStatic.hpp */, + 840DD7052AC810620006A435 /* LiquidTileDynamic.hpp */, 840DD7062AC810620006A435 /* LiquidTileStatic.cpp */, - 840DD7092AC810620006A435 /* MetalTile.hpp */, + 840DD7072AC810620006A435 /* LiquidTileStatic.hpp */, 840DD7082AC810620006A435 /* MetalTile.cpp */, - 840DD70B2AC810620006A435 /* ObsidianTile.hpp */, + 840DD7092AC810620006A435 /* MetalTile.hpp */, 840DD70A2AC810620006A435 /* ObsidianTile.cpp */, - 840DD70D2AC810620006A435 /* OreTile.hpp */, + 840DD70B2AC810620006A435 /* ObsidianTile.hpp */, 840DD70C2AC810620006A435 /* OreTile.cpp */, - 840DD70F2AC810620006A435 /* RedStoneOreTile.hpp */, + 840DD70D2AC810620006A435 /* OreTile.hpp */, + 84E1C9C72E7FDC26007D2F5D /* PumpkinTile.cpp */, + 84E1C9C82E7FDC26007D2F5D /* PumpkinTile.hpp */, 840DD70E2AC810620006A435 /* RedStoneOreTile.cpp */, - 840DD7112AC810620006A435 /* ReedTile.hpp */, + 840DD70F2AC810620006A435 /* RedStoneOreTile.hpp */, 840DD7102AC810620006A435 /* ReedTile.cpp */, - 84E78C862B58B66B00D515EF /* RocketLauncherTile.hpp */, + 840DD7112AC810620006A435 /* ReedTile.hpp */, 84E78C852B58B66B00D515EF /* RocketLauncherTile.cpp */, - 840DD7132AC810620006A435 /* SandStoneTile.hpp */, + 84E78C862B58B66B00D515EF /* RocketLauncherTile.hpp */, 840DD7122AC810620006A435 /* SandStoneTile.cpp */, - 840DD7152AC810620006A435 /* SandTile.hpp */, + 840DD7132AC810620006A435 /* SandStoneTile.hpp */, 840DD7142AC810620006A435 /* SandTile.cpp */, - 840DD7172AC810620006A435 /* Sapling.hpp */, + 840DD7152AC810620006A435 /* SandTile.hpp */, 840DD7162AC810620006A435 /* Sapling.cpp */, - 840DD7192AC810620006A435 /* SpongeTile.hpp */, + 840DD7172AC810620006A435 /* Sapling.hpp */, + 84E1C9C92E7FDC26007D2F5D /* SoulSandTile.cpp */, + 84E1C9CA2E7FDC26007D2F5D /* SoulSandTile.hpp */, 840DD7182AC810620006A435 /* SpongeTile.cpp */, - 840DD71B2AC810620006A435 /* StairTile.hpp */, + 840DD7192AC810620006A435 /* SpongeTile.hpp */, 840DD71A2AC810620006A435 /* StairTile.cpp */, - 840DD71D2AC810620006A435 /* StoneSlabTile.hpp */, + 840DD71B2AC810620006A435 /* StairTile.hpp */, 840DD71C2AC810620006A435 /* StoneSlabTile.cpp */, - 840DD71F2AC810620006A435 /* StoneTile.hpp */, + 840DD71D2AC810620006A435 /* StoneSlabTile.hpp */, 840DD71E2AC810620006A435 /* StoneTile.cpp */, - 840DD7212AC810620006A435 /* Tile.hpp */, + 840DD71F2AC810620006A435 /* StoneTile.hpp */, + 84E1C9CB2E7FDC26007D2F5D /* TallGrass.cpp */, + 84E1C9CC2E7FDC26007D2F5D /* TallGrass.hpp */, 840DD7202AC810620006A435 /* Tile.cpp */, - 840DD7232AC810620006A435 /* TntTile.hpp */, + 840DD7212AC810620006A435 /* Tile.hpp */, 840DD7222AC810620006A435 /* TntTile.cpp */, - 840DD7252AC810620006A435 /* TopSnowTile.hpp */, + 840DD7232AC810620006A435 /* TntTile.hpp */, 840DD7242AC810620006A435 /* TopSnowTile.cpp */, - 840DD7272AC810620006A435 /* TorchTile.hpp */, + 840DD7252AC810620006A435 /* TopSnowTile.hpp */, 840DD7262AC810620006A435 /* TorchTile.cpp */, - 840DD7292AC810620006A435 /* TransparentTile.hpp */, + 840DD7272AC810620006A435 /* TorchTile.hpp */, 840DD7282AC810620006A435 /* TransparentTile.cpp */, - 840DD72B2AC810620006A435 /* TreeTile.hpp */, + 840DD7292AC810620006A435 /* TransparentTile.hpp */, 840DD72A2AC810620006A435 /* TreeTile.cpp */, - 840DD72D2AC810620006A435 /* WireTile.hpp */, + 840DD72B2AC810620006A435 /* TreeTile.hpp */, + 84E1C9CD2E7FDC26007D2F5D /* Web.cpp */, + 84E1C9CE2E7FDC26007D2F5D /* Web.hpp */, 840DD72C2AC810620006A435 /* WireTile.cpp */, + 840DD72D2AC810620006A435 /* WireTile.hpp */, ); path = tile; sourceTree = ""; @@ -5128,6 +5213,11 @@ 84C208502AF88A5000BAE438 /* patches */ = { isa = PBXGroup; children = ( + 84E1C9B52E7FDAE3007D2F5D /* birch_sapling.png */, + 84E1C9B62E7FDAE3007D2F5D /* dead_bush.png */, + 84E1C9B72E7FDAE3007D2F5D /* fern.png */, + 84E1C9B82E7FDAE3007D2F5D /* spruce_sapling.png */, + 84E1C9B92E7FDAE3007D2F5D /* tall_grass.png */, 84C208512AF88A5000BAE438 /* grass_side_transparent.png */, 84E78C8B2B58BB7400D515EF /* n_rocket.png */, 84E78C892B58BB7400D515EF /* n_rocket_launched.png */, @@ -5486,6 +5576,7 @@ 84BF63792AF186C8008A9995 /* Entity.hpp in Headers */, 84B1E03C2E04FD7900ED000A /* Skeleton.hpp in Headers */, 84BF637A2AF186C8008A9995 /* FallingTile.hpp in Headers */, + 84E1C9D42E7FDC26007D2F5D /* FenceTile.hpp in Headers */, 84BF637B2AF186C8008A9995 /* ItemEntity.hpp in Headers */, 84BF637C2AF186C8008A9995 /* LocalPlayer.hpp in Headers */, 84BF637D2AF186C8008A9995 /* Mob.hpp in Headers */, @@ -5505,6 +5596,7 @@ 84BF63882AF186C8008A9995 /* ItemInstance.hpp in Headers */, 84BF63892AF186C8008A9995 /* TileItem.hpp in Headers */, 84BF638A2AF186C8008A9995 /* TilePlanterItem.hpp in Headers */, + 84E1C9DC2E7FDC26007D2F5D /* TallGrass.hpp in Headers */, 84BF638B2AF186C8008A9995 /* Dimension.hpp in Headers */, 84BF638C2AF186C8008A9995 /* Explosion.hpp in Headers */, 84BF638D2AF186C8008A9995 /* Level.hpp in Headers */, @@ -5525,7 +5617,9 @@ 84BF639A2AF186C8008A9995 /* PerlinNoise.hpp in Headers */, 84BF639B2AF186C8008A9995 /* Synth.hpp in Headers */, 84BF639C2AF186C8008A9995 /* LevelListener.hpp in Headers */, + 84E1C9D62E7FDC26007D2F5D /* GlowstoneTile.hpp in Headers */, 84BF639D2AF186C8008A9995 /* Material.hpp in Headers */, + 84E1C9D02E7FDC26007D2F5D /* CactusTile.hpp in Headers */, 84BF639E2AF186C8008A9995 /* Region.hpp in Headers */, 84BF639F2AF186C8008A9995 /* ChunkStorage.hpp in Headers */, 84BF63A02AF186C8008A9995 /* ExternalFileLevelStorage.hpp in Headers */, @@ -5533,14 +5627,17 @@ 84BF63A22AF186C8008A9995 /* LevelData.hpp in Headers */, 84BF63A32AF186C8008A9995 /* LevelSource.hpp in Headers */, 84BF63A42AF186C8008A9995 /* LevelStorage.hpp in Headers */, + 84E1C9DA2E7FDC26007D2F5D /* SoulSandTile.hpp in Headers */, 8445E7A82D769329008DC834 /* Sheep.hpp in Headers */, 84BF63A52AF186C8008A9995 /* LevelStorageSource.hpp in Headers */, 84BF63A62AF186C8008A9995 /* MemoryChunkStorage.hpp in Headers */, 84BF63A72AF186C8008A9995 /* MemoryLevelStorage.hpp in Headers */, 84BF63A82AF186C8008A9995 /* MemoryLevelStorageSource.hpp in Headers */, + 84E1C9EA2E7FDC72007D2F5D /* SlabItem.hpp in Headers */, 84BF63A92AF186C8008A9995 /* RegionFile.hpp in Headers */, 84BF63AA2AF186C8008A9995 /* TickNextTickData.hpp in Headers */, 84BF63AB2AF186C8008A9995 /* Particle.hpp in Headers */, + 84E1C9E62E7FDC72007D2F5D /* AuxTileItem.hpp in Headers */, 84B1E0402E04FD7900ED000A /* Zombie.hpp in Headers */, 84BF63AC2AF186C8008A9995 /* ParticleEngine.hpp in Headers */, 84BF63AD2AF186C8008A9995 /* AABB.hpp in Headers */, @@ -5574,10 +5671,12 @@ 84BF63C72AF186C9008A9995 /* ReedTile.hpp in Headers */, 84BF63C82AF186C9008A9995 /* SandStoneTile.hpp in Headers */, 84BF63C92AF186C9008A9995 /* SandTile.hpp in Headers */, + 84E1C9D82E7FDC26007D2F5D /* PumpkinTile.hpp in Headers */, 84BF63CA2AF186C9008A9995 /* Sapling.hpp in Headers */, 84CCBC942E61880600E251AF /* EntityFactory.hpp in Headers */, 84BF63CB2AF186C9008A9995 /* SpongeTile.hpp in Headers */, 84BF63CC2AF186C9008A9995 /* StairTile.hpp in Headers */, + 84E1C9D22E7FDC26007D2F5D /* DeadBush.hpp in Headers */, 84BF63CD2AF186C9008A9995 /* StoneSlabTile.hpp in Headers */, 84BF63CE2AF186C9008A9995 /* StoneTile.hpp in Headers */, 84BF63CF2AF186C9008A9995 /* Tile.hpp in Headers */, @@ -5591,6 +5690,7 @@ 84AA8B532B32F39A003F5B82 /* Node.hpp in Headers */, 84AA8B552B32F39A003F5B82 /* Path.hpp in Headers */, 84AA8B572B32F39A003F5B82 /* PathFinder.hpp in Headers */, + 84E1C9DE2E7FDC26007D2F5D /* Web.hpp in Headers */, 84AA8B792B32F3B5003F5B82 /* Animal.hpp in Headers */, 84AA8B7B2B32F3B5003F5B82 /* Chicken.hpp in Headers */, 84AA8B7D2B32F3B5003F5B82 /* Cow.hpp in Headers */, @@ -5606,6 +5706,7 @@ 84E78C842B58B5FB00D515EF /* RocketItem.hpp in Headers */, 84E78C882B58B66B00D515EF /* RocketLauncherTile.hpp in Headers */, 8477B3B72C4DC414004E1AC5 /* EmptyLevelChunk.hpp in Headers */, + 84E1C9E82E7FDC72007D2F5D /* ClothItem.hpp in Headers */, 8470AF2B2BE9B60A00BCA54E /* EntityType.hpp in Headers */, 8445E7A42D769329008DC834 /* EntityTypeDescriptor.hpp in Headers */, 8470AF2D2BE9B60A00BCA54E /* MobFactory.hpp in Headers */, @@ -6173,6 +6274,7 @@ 84B1E24A2E051B7D00ED000A /* jump4.ogg in Resources */, 84B1E27A2E051B7D00ED000A /* death.ogg in Resources */, 849FF0BA2AF465340013BAE3 /* panorama_2.png in Resources */, + 84E1C9BC2E7FDAE3007D2F5D /* fern.png in Resources */, 84B1E29B2E051B7D00ED000A /* zpigangry4.ogg in Resources */, 84B1E29A2E051B7D00ED000A /* zpigangry3.ogg in Resources */, 84B1E2912E051B7D00ED000A /* zombiedeath.ogg in Resources */, @@ -6239,6 +6341,7 @@ 84B1E2382E051B7D00ED000A /* scream5.ogg in Resources */, 849FF0C62AF465340013BAE3 /* feedback_outer.png in Resources */, 84B1E2302E051B7D00ED000A /* moan4.ogg in Resources */, + 84E1C9BA2E7FDAE3007D2F5D /* birch_sapling.png in Resources */, 84B1E2792E051B7D00ED000A /* bark3.ogg in Resources */, 8477B4112C4DE77F004E1AC5 /* create_0.png in Resources */, 84B1E21C2E051B7D00ED000A /* hit4.ogg in Resources */, @@ -6255,6 +6358,7 @@ 84B1E2D52E051B7D00ED000A /* gravel2.ogg in Resources */, 8477B42F2C4DE77F004E1AC5 /* create_0_3.png in Resources */, 84B1E2872E051B7D00ED000A /* metal2.ogg in Resources */, + 84E1C9BD2E7FDAE3007D2F5D /* spruce_sapling.png in Resources */, 84B1E2CB2E051B7D00ED000A /* wood click.ogg in Resources */, 84B1E2552E051B7D00ED000A /* sheep2.ogg in Resources */, 84B1E26E2E051B7D00ED000A /* slime4.ogg in Resources */, @@ -6281,6 +6385,7 @@ 8477B43F2C4DE77F004E1AC5 /* Icon-Small-50.png in Resources */, 84B1E1DD2E051B7D00ED000A /* rain3.ogg in Resources */, 84B1E2D42E051B7D00ED000A /* gravel1.ogg in Resources */, + 84E1C9BB2E7FDAE3007D2F5D /* dead_bush.png in Resources */, 84B1E2282E051B7D00ED000A /* stare.ogg in Resources */, 84B1E0662E051B6400ED000A /* creeper.png in Resources */, 84B1E2452E051B7D00ED000A /* big3.ogg in Resources */, @@ -6496,6 +6601,7 @@ 8477B42D2C4DE77F004E1AC5 /* cancel_1_3.png in Resources */, 84B1E1C82E051B7D00ED000A /* hal4.ogg in Resources */, 84B1E2642E051B7D00ED000A /* skeleton2.ogg in Resources */, + 84E1C9BE2E7FDAE3007D2F5D /* tall_grass.png in Resources */, 84B1E2572E051B7D00ED000A /* hit1.ogg in Resources */, 84B1E2932E051B7D00ED000A /* zombiehurt2.ogg in Resources */, 84E78C8D2B58BB7400D515EF /* n_rocket_launcher.png in Resources */, @@ -6786,12 +6892,15 @@ 84BF63152AF18631008A9995 /* GameMode.cpp in Sources */, 84BF63162AF18631008A9995 /* SurvivalMode.cpp in Sources */, 84BF63172AF18631008A9995 /* CameraItem.cpp in Sources */, + 84E1C9E52E7FDC72007D2F5D /* AuxTileItem.cpp in Sources */, + 84E1C9D52E7FDC26007D2F5D /* GlowstoneTile.cpp in Sources */, 84BF63182AF18631008A9995 /* DoorItem.cpp in Sources */, 84BF63192AF18631008A9995 /* Inventory.cpp in Sources */, 8445E7A22D769329008DC834 /* EntityType.cpp in Sources */, 84BF631A2AF18631008A9995 /* Item.cpp in Sources */, 84BF631B2AF18631008A9995 /* ItemInstance.cpp in Sources */, 84BF631C2AF18631008A9995 /* TileItem.cpp in Sources */, + 84E1C9F02E7FDC89007D2F5D /* VegetationFeature.cpp in Sources */, 84BF631D2AF18631008A9995 /* TilePlanterItem.cpp in Sources */, 84BF631E2AF18631008A9995 /* Dimension.cpp in Sources */, 84BF631F2AF18631008A9995 /* Explosion.cpp in Sources */, @@ -6799,11 +6908,14 @@ 84BF63212AF18631008A9995 /* Biome.cpp in Sources */, 84BF63222AF18631008A9995 /* BiomeSource.cpp in Sources */, 84BF63232AF18631008A9995 /* ChunkCache.cpp in Sources */, + 84E1C9CF2E7FDC26007D2F5D /* CactusTile.cpp in Sources */, 84BF63242AF18631008A9995 /* ChunkSource.cpp in Sources */, 84BF63252AF18631008A9995 /* LevelChunk.cpp in Sources */, 84BF63262AF18631008A9995 /* PerformanceTestChunkSource.cpp in Sources */, 84BF63272AF18631008A9995 /* RandomLevelSource.cpp in Sources */, + 84E1C9E72E7FDC72007D2F5D /* ClothItem.cpp in Sources */, 84BF63282AF18631008A9995 /* TestChunkSource.cpp in Sources */, + 84E1C9D12E7FDC26007D2F5D /* DeadBush.cpp in Sources */, 84BF63292AF18631008A9995 /* BirchFeature.cpp in Sources */, 84BF632A2AF18631008A9995 /* ClayFeature.cpp in Sources */, 84BF632B2AF18631008A9995 /* Feature.cpp in Sources */, @@ -6825,13 +6937,17 @@ 84BF63392AF18631008A9995 /* Material.cpp in Sources */, 84BF633A2AF18631008A9995 /* Region.cpp in Sources */, 84BF633B2AF18631008A9995 /* ChunkStorage.cpp in Sources */, + 84E1C9EE2E7FDC89007D2F5D /* CactusFeature.cpp in Sources */, 8445E7A02D769329008DC834 /* EntityCategories.cpp in Sources */, 84BF633C2AF18631008A9995 /* ExternalFileLevelStorage.cpp in Sources */, 84BF633D2AF18631008A9995 /* ExternalFileLevelStorageSource.cpp in Sources */, + 84E1C9D72E7FDC26007D2F5D /* PumpkinTile.cpp in Sources */, 84BF633E2AF18631008A9995 /* LevelData.cpp in Sources */, + 84E1C9EF2E7FDC89007D2F5D /* PumpkinFeature.cpp in Sources */, 84BF633F2AF18631008A9995 /* LevelSource.cpp in Sources */, 84BF63402AF18631008A9995 /* LevelStorage.cpp in Sources */, 84BF63412AF18631008A9995 /* LevelStorageSource.cpp in Sources */, + 84E1C9D32E7FDC26007D2F5D /* FenceTile.cpp in Sources */, 8477B3BA2C4DC42E004E1AC5 /* Vec2.cpp in Sources */, 84BF63422AF18631008A9995 /* MemoryChunkStorage.cpp in Sources */, 84BF63432AF18631008A9995 /* MemoryLevelStorage.cpp in Sources */, @@ -6858,6 +6974,7 @@ 84BF63552AF18631008A9995 /* ClayTile.cpp in Sources */, 84BF63562AF18631008A9995 /* ClothTile.cpp in Sources */, 84BF63572AF18631008A9995 /* DirtTile.cpp in Sources */, + 84E1C9DD2E7FDC26007D2F5D /* Web.cpp in Sources */, 84BF63582AF18631008A9995 /* DoorTile.cpp in Sources */, 84BF63592AF18631008A9995 /* FarmTile.cpp in Sources */, 84BF635A2AF18631008A9995 /* FireTile.cpp in Sources */, @@ -6865,6 +6982,7 @@ 84BF635C2AF18631008A9995 /* GrassTile.cpp in Sources */, 84BF635D2AF18631008A9995 /* GravelTile.cpp in Sources */, 84BF635E2AF18631008A9995 /* HalfTransparentTile.cpp in Sources */, + 84E1C9D92E7FDC26007D2F5D /* SoulSandTile.cpp in Sources */, 84BF635F2AF18631008A9995 /* IceTile.cpp in Sources */, 84BF63602AF18631008A9995 /* InvisibleTile.cpp in Sources */, 84BF63612AF18631008A9995 /* LadderTile.cpp in Sources */, @@ -6894,6 +7012,7 @@ 84BF63762AF18631008A9995 /* TransparentTile.cpp in Sources */, 84BF63772AF18631008A9995 /* TreeTile.cpp in Sources */, 84BF63782AF18631008A9995 /* WireTile.cpp in Sources */, + 84E1C9DB2E7FDC26007D2F5D /* TallGrass.cpp in Sources */, 84AA8B502B32F39A003F5B82 /* BinaryHeap.cpp in Sources */, 84AA8B522B32F39A003F5B82 /* Node.cpp in Sources */, 84AA8B542B32F39A003F5B82 /* Path.cpp in Sources */, @@ -6913,6 +7032,7 @@ 84E78C832B58B5FB00D515EF /* RocketItem.cpp in Sources */, 84E78C872B58B66B00D515EF /* RocketLauncherTile.cpp in Sources */, 8470AF2C2BE9B60A00BCA54E /* MobFactory.cpp in Sources */, + 84E1C9E92E7FDC72007D2F5D /* SlabItem.cpp in Sources */, 8470AF3C2BE9B6FA00BCA54E /* FireworkParticle.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/platforms/windows/projects/World/World.vcxproj b/platforms/windows/projects/World/World.vcxproj index 1266c8fc8..80323413b 100644 --- a/platforms/windows/projects/World/World.vcxproj +++ b/platforms/windows/projects/World/World.vcxproj @@ -48,7 +48,9 @@ + + @@ -56,6 +58,7 @@ + @@ -68,6 +71,7 @@ + @@ -75,10 +79,12 @@ + + @@ -113,13 +119,17 @@ + + + + @@ -133,21 +143,25 @@ + + + + @@ -191,7 +205,9 @@ + + @@ -199,6 +215,7 @@ + @@ -239,13 +256,17 @@ + + + + @@ -259,21 +280,25 @@ + + + + diff --git a/platforms/windows/projects/World/World.vcxproj.filters b/platforms/windows/projects/World/World.vcxproj.filters index e32476167..570fe2306 100644 --- a/platforms/windows/projects/World/World.vcxproj.filters +++ b/platforms/windows/projects/World/World.vcxproj.filters @@ -128,9 +128,15 @@ Source Files\GameMode + + Source Files\Item + Source Files\Item + + Source Files\Item + Source Files\Item @@ -143,6 +149,9 @@ Source Files\Item + + Source Files\Item + Source Files\Item @@ -197,6 +206,9 @@ Source Files\Level\LevelGen\Feature + + Source Files\Level\LevelGen\Feature + Source Files\Level\LevelGen\Feature @@ -218,6 +230,9 @@ Source Files\Level\LevelGen\Feature + + Source Files\Level\LevelGen\Feature + Source Files\Level\LevelGen\Feature @@ -230,6 +245,9 @@ Source Files\Level\LevelGen\Feature + + Source Files\Level\LevelGen\Feature + Source Files\Level\LevelGen\Synth @@ -314,12 +332,18 @@ Source Files\Tile + + Source Files\Tile + Source Files\Tile Source Files\Tile + + Source Files\Tile + Source Files\Tile @@ -329,12 +353,18 @@ Source Files\Tile + + Source Files\Tile + Source Files\Tile Source Files\Tile + + Source Files\Tile + Source Files\Tile @@ -374,6 +404,9 @@ Source Files\Tile + + Source Files\Tile + Source Files\Tile @@ -389,6 +422,9 @@ Source Files\Tile + + Source Files\Tile + Source Files\Tile @@ -401,6 +437,9 @@ Source Files\Tile + + Source Files\Tile + Source Files\Tile @@ -419,6 +458,9 @@ Source Files\Tile + + Source Files\Tile + Source Files\Tile @@ -553,9 +595,15 @@ Header Files\GameMode + + Header Files\Item + Header Files\Item + + Header Files\Item + Header Files\Item @@ -568,6 +616,9 @@ Header Files\Item + + Header Files\Item + Header Files\Item @@ -691,12 +742,18 @@ Header Files\Tile + + Header Files\Tile + Header Files\Tile Header Files\Tile + + Header Files\Tile + Header Files\Tile @@ -706,12 +763,18 @@ Header Files\Tile + + Header Files\Tile + Header Files\Tile Header Files\Tile + + Header Files\Tile + Header Files\Tile @@ -751,6 +814,9 @@ Header Files\Tile + + Header Files\Tile + Header Files\Tile @@ -766,6 +832,9 @@ Header Files\Tile + + Header Files\Tile + Header Files\Tile @@ -778,6 +847,9 @@ Header Files\Tile + + Header Files\Tile + Header Files\Tile @@ -901,5 +973,8 @@ Header Files\Entity + + Header Files\Tile + - \ No newline at end of file + diff --git a/platforms/xenon/projects/Minecraft.vcxproj b/platforms/xenon/projects/Minecraft.vcxproj index a18657416..ecb489ca5 100644 --- a/platforms/xenon/projects/Minecraft.vcxproj +++ b/platforms/xenon/projects/Minecraft.vcxproj @@ -420,11 +420,14 @@ + + + @@ -466,13 +469,17 @@ + + + + @@ -486,21 +493,25 @@ + + + + @@ -788,11 +799,14 @@ + + + @@ -807,6 +821,7 @@ + @@ -814,10 +829,12 @@ + + @@ -850,13 +867,17 @@ + + + + @@ -870,21 +891,25 @@ + + + + diff --git a/platforms/xenon/projects/Minecraft.vcxproj.filters b/platforms/xenon/projects/Minecraft.vcxproj.filters index c47d74592..eb467ea21 100644 --- a/platforms/xenon/projects/Minecraft.vcxproj.filters +++ b/platforms/xenon/projects/Minecraft.vcxproj.filters @@ -948,6 +948,9 @@ source\world\tile + + source\world\tile + source\world\tile @@ -987,6 +990,9 @@ source\world\tile + + source\world\tile + source\world\tile @@ -999,6 +1005,9 @@ source\world\tile + + source\world\tile + source\world\tile @@ -1008,6 +1017,9 @@ source\world\tile + + source\world\tile + source\world\tile @@ -1017,6 +1029,12 @@ source\world\tile + + source\world\tile + + + source\world\tile + source\world\tile @@ -1026,6 +1044,9 @@ source\world\tile + + source\world\tile + source\world\tile @@ -1041,6 +1062,9 @@ source\world\tile + + source\world\tile + source\world\tile @@ -1080,12 +1104,21 @@ thirdparty\zlib + + source\world\item + source\world\item + + source\world\item + source\world\item + + source\world\item + source\world\item @@ -1751,6 +1784,9 @@ source\world\entity + + source\world\tile + source\world\tile @@ -1760,12 +1796,18 @@ source\world\tile + + source\world\tile + source\world\tile source\world\tile + + source\world\tile + source\world\tile @@ -1805,6 +1847,9 @@ source\world\tile + + source\world\tile + source\world\tile @@ -1820,6 +1865,9 @@ source\world\tile + + source\world\tile + source\world\tile @@ -1832,6 +1880,9 @@ source\world\tile + + source\world\tile + source\world\tile @@ -1850,12 +1901,18 @@ source\world\tile + + source\world\tile + source\world\tile source\world\tile + + source\world\tile + source\world\tile @@ -1901,9 +1958,18 @@ source\world\item + + source\world\item + source\world\item + + source\world\item + + + source\world\item + source\world\item @@ -1979,6 +2045,9 @@ source\world\level\levelgen\feature + + source\world\level\levelgen\feature + source\world\level\levelgen\feature @@ -2000,6 +2069,12 @@ source\world\level\levelgen\feature + + source\world\level\levelgen\feature + + + source\world\level\levelgen\feature + source\world\level\levelgen\chunk diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 9eba92786..d583b29d3 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -252,6 +252,9 @@ add_library(reminecraftpe-core STATIC world/level/levelgen/feature/ClayFeature.cpp world/level/levelgen/feature/FlowerFeature.cpp world/level/levelgen/feature/SpruceFeature.cpp + world/level/levelgen/feature/PumpkinFeature.cpp + world/level/levelgen/feature/CactusFeature.cpp + world/level/levelgen/feature/VegetationFeature.cpp world/level/levelgen/biome/Biome.cpp world/level/levelgen/biome/BiomeSource.cpp world/level/levelgen/chunk/RandomLevelSource.cpp @@ -272,6 +275,9 @@ add_library(reminecraftpe-core STATIC world/item/ItemInstance.cpp world/item/RocketItem.cpp world/item/Item.cpp + world/item/AuxTileItem.cpp + world/item/ClothItem.cpp + world/item/SlabItem.cpp world/particle/RedDustParticle.cpp world/particle/TerrainParticle.cpp world/particle/BubbleParticle.cpp @@ -320,6 +326,14 @@ add_library(reminecraftpe-core STATIC world/tile/FarmTile.cpp world/tile/DoorTile.cpp world/tile/RocketLauncherTile.cpp + world/tile/CactusTile.cpp + world/tile/TallGrass.cpp + world/tile/DeadBush.cpp + world/tile/PumpkinTile.cpp + world/tile/SoulSandTile.cpp + world/tile/GlowstoneTile.cpp + world/tile/Web.cpp + world/tile/FenceTile.cpp renderer/GL/GL.cpp ) target_include_directories(reminecraftpe-core PUBLIC . ..) diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp index da57971a6..71a9d3c78 100644 --- a/source/client/app/Minecraft.cpp +++ b/source/client/app/Minecraft.cpp @@ -384,7 +384,8 @@ void Minecraft::handleBuildAction(const BuildActionIntention& action) else if (action.isPick()) { // Try to pick the tile. - player->m_pInventory->selectItemById(pTile->m_ID, C_MAX_HOTBAR_ITEMS); + int auxValue = m_pLevel->getData(m_hitResult.m_tilePos); + player->m_pInventory->selectItemByIdAux(pTile->m_ID, auxValue, C_MAX_HOTBAR_ITEMS); } else if (action.isPlace() && canInteract) { @@ -834,6 +835,7 @@ void Minecraft::init() m_pTextures->addDynamicTexture(new LavaTexture); m_pTextures->addDynamicTexture(new LavaSideTexture); m_pTextures->addDynamicTexture(new FireTexture(0)); + m_pTextures->addDynamicTexture(new FireTexture(1)); if (platform()->hasFileSystemAccess()) m_options = new Options(m_externalStorageDir); diff --git a/source/client/gui/Gui.cpp b/source/client/gui/Gui.cpp index dcb6648b0..b345ec907 100644 --- a/source/client/gui/Gui.cpp +++ b/source/client/gui/Gui.cpp @@ -196,12 +196,16 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); #endif + // chat + //blit(width - 18, 0, 200, 82, 18, 18, 18, 18); + int nSlots = getNumSlots(); int hotbarWidth = 2 + nSlots * 20; // hotbar int cenX = width / 2; - blit(cenX - hotbarWidth / 2, height - 22, 0, 0, hotbarWidth, 22, 0, 0); + blit(cenX - hotbarWidth / 2, height - 22, 0, 0, hotbarWidth-2, 22, 0, 0); + blit(cenX + hotbarWidth / 2 -2, height - 22, 180, 0, 2, 22, 0, 0); Inventory* inventory = player->m_pInventory; @@ -293,18 +297,19 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY) b1 = player->m_invulnerableTime / 3 % 2; emptyHeartX += 9 * b1; } - +#ifdef ANDROID || TARGET_OS_IPHONE + //@NOTE: Pocket-style health UI. + int heartX = 2; + int heartYStart = 2; +#else // @NOTE: At the default scale, this would go off screen. - int heartX = cenX - 191; // why? int heartYStart = height - 10; //@NOTE: Alpha-style health UI. I'll probably remove this on release. -#ifndef ORIGINAL_CODE heartX = cenX - 91; heartYStart = height - 32; #endif - int playerHealth = player->m_health; for (int healthNo = 1; healthNo <= C_MAX_MOB_HEALTH; healthNo += 2) @@ -337,15 +342,17 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY) int breathRaw = player->m_airCapacity; int breathFull = int(ceilf((float(breathRaw - 2) * 10.0f) / 300.0f)); int breathMeter = int(ceilf((float(breathRaw) * 10.0f) / 300.0f)) - breathFull; - +#ifdef ANDROID || TARGET_OS_IPHONE + // pe + int bubbleX = 2; + int bubbleY = 12; +#else int bubbleX = cenX - 191; int bubbleY = height - 19; -#ifndef ORIGINAL_CODE bubbleX = cenX - 91; bubbleY = height - 41; #endif - //@NOTE: Not sure this works as it should for (int bubbleNo = 0; bubbleNo < breathFull + breathMeter; bubbleNo++) @@ -560,6 +567,8 @@ void Gui::renderMessages(bool bShowAll) int height = int(ceilf(Minecraft::height * InvGuiScale)); int topEdge = height - 49; + if (m_pMinecraft->isTouchscreen()) + topEdge = 49; for (int i = 0; i < int(m_guiMessages.size()); i++) { @@ -601,7 +610,7 @@ void Gui::renderMessages(bool bShowAll) int Gui::getNumSlots() { if (m_pMinecraft->isTouchscreen()) - return 4; + return 8; return 9; } diff --git a/source/client/gui/components/OptionList.cpp b/source/client/gui/components/OptionList.cpp index 407f778ee..d2e283ba7 100644 --- a/source/client/gui/components/OptionList.cpp +++ b/source/client/gui/components/OptionList.cpp @@ -293,6 +293,7 @@ void OptionList::initDefaultMenu() HEADER("Video"); { OPTION(Distance, m_iViewDistance, "Render Distance"); + OPTION(Boolean, m_bThirdPerson, "Third Person View"); OPTION(AORender, m_bAmbientOcclusion, "Smooth Lighting"); OPTION(Render, m_bFancyGraphics, "Fancy Graphics"); OPTION(Boolean, m_bViewBobbing, "View Bobbing"); @@ -330,7 +331,7 @@ void OptionList::initDefaultMenu() #ifdef __EMSCRIPTEN m_items[idxLM]->setDisabled(true); #endif - + if (!GetPatchManager()->IsGrassSidesTinted()) m_items[idxGrass]->setDisabled(true); diff --git a/source/client/gui/screens/IngameBlockSelectionScreen.cpp b/source/client/gui/screens/IngameBlockSelectionScreen.cpp index 65881fafb..f47efe6a4 100644 --- a/source/client/gui/screens/IngameBlockSelectionScreen.cpp +++ b/source/client/gui/screens/IngameBlockSelectionScreen.cpp @@ -8,13 +8,15 @@ #include "IngameBlockSelectionScreen.hpp" #include "PauseScreen.hpp" +#include "ChatScreen.hpp" #include "client/app/Minecraft.hpp" #include "client/renderer/entity/ItemRenderer.hpp" std::string g_sNotAvailableInDemoVersion = "Not available in the demo version"; IngameBlockSelectionScreen::IngameBlockSelectionScreen() : - m_btnPause(0, "Pause") + m_btnPause(0, "Pause"), + m_btnChat(1, "Chat") // Temp chat button { m_selectedSlot = 0; } @@ -74,11 +76,17 @@ void IngameBlockSelectionScreen::init() m_btnPause.m_width = 40; m_btnPause.m_xPos = 0; m_btnPause.m_yPos = 0; -#if TARGET_OS_IPHONE != 0 +#if MC_PLATFORM_IOS if (m_pMinecraft->isTouchscreen()) m_buttons.push_back(&m_btnPause); #endif + m_btnChat.m_width = 40; + m_btnChat.m_xPos = m_width - m_btnChat.m_width; // Right edge + m_btnChat.m_yPos = 0; + if (m_pMinecraft->isTouchscreen()) + m_buttons.push_back(&m_btnChat); + Inventory* pInv = getInventory(); int nItems = pInv->getNumItems(); @@ -160,6 +168,9 @@ void IngameBlockSelectionScreen::buttonClicked(Button* pButton) { if (pButton->m_buttonId == m_btnPause.m_buttonId) m_pMinecraft->setScreen(new PauseScreen); + + if (pButton->m_buttonId == m_btnChat.m_buttonId) + m_pMinecraft->setScreen(new ChatScreen(true)); } void IngameBlockSelectionScreen::mouseClicked(int x, int y, int type) diff --git a/source/client/gui/screens/IngameBlockSelectionScreen.hpp b/source/client/gui/screens/IngameBlockSelectionScreen.hpp index 72a19af8f..0cddab072 100644 --- a/source/client/gui/screens/IngameBlockSelectionScreen.hpp +++ b/source/client/gui/screens/IngameBlockSelectionScreen.hpp @@ -39,5 +39,6 @@ class IngameBlockSelectionScreen : public Screen private: int m_selectedSlot; Button m_btnPause; + Button m_btnChat; }; diff --git a/source/client/gui/screens/StartMenuScreen.cpp b/source/client/gui/screens/StartMenuScreen.cpp index 66da953a2..a303c8e7b 100644 --- a/source/client/gui/screens/StartMenuScreen.cpp +++ b/source/client/gui/screens/StartMenuScreen.cpp @@ -13,9 +13,7 @@ #include "SelectWorldScreen.hpp" #include "JoinGameScreen.hpp" -#if (defined(USE_SDL) || defined(_WIN32) || (defined(TARGET_OS_MAC) && TARGET_OS_IPHONE == 0)) && !defined(ANDROID) #define CAN_QUIT -#endif // special mode so that we can crop out the title: //#define TITLE_CROP_MODE @@ -781,11 +779,6 @@ Tile* TitleTile::getTileFromChar(char c) // NOTE: Using the tile enum instead of Tile::tileName->id, may want to.. not? static const int _tileBlockList[] = { TILE_BOOKSHELF, - TILE_CLOTH, // TODO: fix these? There's way too many black wool tiles - TILE_CLOTH_00, - TILE_CLOTH_01, - TILE_CLOTH_10, - TILE_CLOTH_41, TILE_STAIRS_WOOD, TILE_STAIRS_STONE, TILE_TOPSNOW, @@ -793,6 +786,8 @@ static const int _tileBlockList[] = { TILE_INFO_UPDATEGAME1, TILE_INFO_UPDATEGAME2, TILE_STONESLAB_HALF, + TILE_CACTUS, + TILE_FENCE, }; static const int _tileBlockListSize = sizeof _tileBlockList / sizeof(int); diff --git a/source/client/player/input/IMoveInput.hpp b/source/client/player/input/IMoveInput.hpp index 9efeea9e2..c5d63584e 100644 --- a/source/client/player/input/IMoveInput.hpp +++ b/source/client/player/input/IMoveInput.hpp @@ -20,6 +20,8 @@ enum INPUT_RIGHT, INPUT_JUMP, INPUT_SNEAK, + INPUT_FORWARDLEFT, + INPUT_FORWARDRIGHT, }; class IMoveInput diff --git a/source/client/player/input/TouchscreenInput_TestFps.cpp b/source/client/player/input/TouchscreenInput_TestFps.cpp index a719fda18..d20f07e46 100644 --- a/source/client/player/input/TouchscreenInput_TestFps.cpp +++ b/source/client/player/input/TouchscreenInput_TestFps.cpp @@ -38,7 +38,7 @@ void TouchscreenInput_TestFps::releaseAllKeys() { m_horzInput = 0.0f; m_vertInput = 0.0f; - for (int i = 0; i < 5; i++) + for (int i = 0; i < 8; i++) field_6C[i] = false; } @@ -84,8 +84,8 @@ void TouchscreenInput_TestFps::setScreenSize(int width, int height) { m_touchAreaModel.clear(); - float widthM = float(width) * 0.11f; - float heightM = float(height) * 0.18f; + float heightM = height / 5.0f; + float widthM = heightM; float x1[4], y1[4], x2[4], y2[4]; @@ -129,15 +129,27 @@ void TouchscreenInput_TestFps::setScreenSize(int width, int height) // NOTE: We are not leaking memory! Since by default IArea's constructor sets // m_vertices to true, TouchAreaModel owns the pointers, so when it's destroyed, // so are these areas we allocated. +#ifdef ENH_NEW_TOUCH_CONTROLS + TransformArray(4, x1, y1, x2, y2, middleX - widthM, middleY - heightM, 1.0f, 1.0f); + m_pAreaForwardLeft = new PolygonArea(4, x2, y2); + m_touchAreaModel.addArea(100 + INPUT_FORWARDLEFT, m_pAreaForwardLeft); + + TransformArray(4, x1, y1, x2, y2, middleX + widthM, middleY - heightM, 1.0f, 1.0f); + m_pAreaForwardRight = new PolygonArea(4, x2, y2); + m_touchAreaModel.addArea(100 + INPUT_FORWARDRIGHT, m_pAreaForwardRight); +#endif } void TouchscreenInput_TestFps::tick(Player* pPlayer) { + if (m_pMinecraft->m_pScreen) return; // If we're in another screen, disable d-pad + m_horzInput = 0.0f; m_vertInput = 0.0f; m_bJumping = false; + //field_40 = false; - for (int i = 0; i < 5; i++) + for (int i = 0; i < 8; i++) field_6C[i] = false; const int* activePointers; @@ -174,26 +186,54 @@ void TouchscreenInput_TestFps::tick(Player* pPlayer) else if (field_40) { pointerId = 100; // forward - bJumpPressed = true; m_vertInput += 1.0f; } + bJumpPressed = true; } switch (pointerId) { case 100 + INPUT_FORWARD: - if (pPlayer->isInWater()) - m_bJumping = true; - else - bForwardPressed = true; - + if (m_bJumpBeingHeld && m_pMinecraft->getOptions()->m_bFlyCheat) { + m_bJumpBeingHeld = true; + m_bWasJumping = false; + bJumpPressed = true; + } + else { + if (pPlayer->isInWater()) + m_bJumping = true; + else + bForwardPressed = true; + + } m_vertInput += 1.0f; break; case 100 + INPUT_BACKWARD: + if (m_bJumpBeingHeld && m_pMinecraft->getOptions()->m_bFlyCheat) { + m_bJumpBeingHeld = true; + m_bWasJumping = false; + bJumpPressed = true; + } m_vertInput -= 1.0f; break; + case 100 + INPUT_FORWARDLEFT: + if (field_40) { + bForwardPressed = true; + m_vertInput += 1.0f; + m_horzInput += 1.0f; + } + break; + case 100 + INPUT_FORWARDRIGHT: + if (field_40) { + bForwardPressed = true; + m_vertInput += 1.0f; + m_horzInput -= 1.0f; + } + break; + + case 100 + INPUT_LEFT: m_horzInput += 1.0f; break; @@ -212,11 +252,22 @@ void TouchscreenInput_TestFps::tick(Player* pPlayer) // Only let them jump once - have them jump again if (!m_bJumpBeingHeld) m_bJumping = true; - m_bJumpBeingHeld = true; + + if (m_bWasJumping && m_pMinecraft->m_pGameMode->isCreativeType()) { + m_pMinecraft->getOptions()->m_bFlyCheat = !m_pMinecraft->getOptions()->m_bFlyCheat; + m_bWasJumping = false; + m_bJumpBeingHeld = false; + } + } else { + if (m_bJumpBeingHeld) + m_bWasJumping = true; + else + m_bWasJumping = false; + m_bJumpBeingHeld = false; } } @@ -227,10 +278,18 @@ static void RenderTouchButton(Tesselator* t, PolygonArea* pArea, int srcX, int s tc[0] = float(srcX) / 256.0f; tc[1] = float(srcY) / 256.0f; +#ifdef ENH_NEW_TOUCH_CONTROLS + tc[2] = tc[0] + 26.0f / 256.0f; +#else tc[2] = tc[0] + 64.0f / 256.0f; +#endif tc[3] = tc[1]; tc[4] = tc[2]; +#ifdef ENH_NEW_TOUCH_CONTROLS + tc[5] = tc[1] + 26.0f / 256.0f; +#else tc[5] = tc[1] + 64.0f / 256.0f; +#endif tc[6] = tc[0]; tc[7] = tc[5]; @@ -256,7 +315,44 @@ void TouchscreenInput_TestFps::render(float f) Tesselator& t = Tesselator::instance; t.begin(); +#ifdef ENH_NEW_TOUCH_CONTROLS + if (field_40 && !isButtonDown(100 + INPUT_JUMP)) + { + t.color(isButtonDown(100 + INPUT_FORWARDLEFT) ? 0xC0C0C0 : 0xFFFFFF, 0x80); + RenderTouchButton(&t, m_pAreaForwardLeft, 0, 132); + + t.color(isButtonDown(100 + INPUT_FORWARDRIGHT) ? 0xC0C0C0 : 0xFFFFFF, 0x80); + RenderTouchButton(&t, m_pAreaForwardRight, 26, 132); + } + + t.color(isButtonDown(100 + INPUT_LEFT) ? 0xC0C0C0 : 0xFFFFFF, 0x80); + RenderTouchButton(&t, m_pAreaLeft, 26, 106); + + t.color(isButtonDown(100 + INPUT_RIGHT) ? 0xC0C0C0 : 0xFFFFFF, 0x80); + RenderTouchButton(&t, m_pAreaRight, 78, 106); + + t.color(isButtonDown(100 + INPUT_JUMP) ? 0xC0C0C0 : 0xFFFFFF, 0x80); + (m_pMinecraft->getOptions()->m_bFlyCheat) ? + RenderTouchButton(&t, m_pAreaJump, 104, 132) : RenderTouchButton(&t, m_pAreaJump, 104, 106); + + if (m_pMinecraft->getOptions()->m_bFlyCheat && m_bJumpBeingHeld ) + { + t.color(isButtonDown(100 + INPUT_FORWARD) ? 0xC0C0C0 : 0xFFFFFF, 0x80); + RenderTouchButton(&t, m_pAreaForward, 52, 132); + + t.color(isButtonDown(100 + INPUT_BACKWARD) ? 0xC0C0C0 : 0xFFFFFF, 0x80); + RenderTouchButton(&t, m_pAreaBackward, 78, 132); + } + else + { + t.color(isButtonDown(100 + INPUT_FORWARD) ? 0xC0C0C0 : 0xFFFFFF, 0x80); + RenderTouchButton(&t, m_pAreaForward, 0, 106); + t.color(isButtonDown(100 + INPUT_BACKWARD) ? 0xC0C0C0 : 0xFFFFFF, 0x80); + RenderTouchButton(&t, m_pAreaBackward, 52, 106); + } +#else + // orginal touch controls t.color(isButtonDown(100 + INPUT_LEFT) ? 0xC0C0C0 : 0xFFFFFF, 0x80); RenderTouchButton(&t, m_pAreaLeft, 64, 112); @@ -271,7 +367,7 @@ void TouchscreenInput_TestFps::render(float f) t.color(isButtonDown(100 + INPUT_JUMP) ? 0xC0C0C0 : 0xFFFFFF, 0x80); RenderTouchButton(&t, m_pAreaJump, 0, 176); - +#endif t.draw(); glDisable(GL_BLEND); @@ -285,5 +381,7 @@ RectangleArea TouchscreenInput_TestFps::getRectangleArea() bool TouchscreenInput_TestFps::isButtonDown(int key) { + if (key == 7) // mp + return m_bJumpBeingHeld; return field_6C[key - 100]; } diff --git a/source/client/player/input/TouchscreenInput_TestFps.hpp b/source/client/player/input/TouchscreenInput_TestFps.hpp index d878b7917..bfbc15a6a 100644 --- a/source/client/player/input/TouchscreenInput_TestFps.hpp +++ b/source/client/player/input/TouchscreenInput_TestFps.hpp @@ -45,6 +45,8 @@ class TouchscreenInput_TestFps : public IMoveInput, public GuiComponent PolygonArea* m_pAreaForward; PolygonArea* m_pAreaBackward; PolygonArea* m_pAreaJump; + PolygonArea* m_pAreaForwardLeft; + PolygonArea* m_pAreaForwardRight; bool field_6C[8]; }; diff --git a/source/client/renderer/ItemInHandRenderer.cpp b/source/client/renderer/ItemInHandRenderer.cpp index 921f36367..795f60bf3 100644 --- a/source/client/renderer/ItemInHandRenderer.cpp +++ b/source/client/renderer/ItemInHandRenderer.cpp @@ -50,7 +50,7 @@ void ItemInHandRenderer::renderItem(ItemInstance* inst) float bright = m_pMinecraft->m_pLocalPlayer->getBrightness(0.0f); #endif - if (inst->m_itemID <= C_MAX_TILES && TileRenderer::canRender(Tile::tiles[inst->m_itemID]->getRenderShape())) + if (inst->m_itemID < C_MAX_TILES && TileRenderer::canRender(Tile::tiles[inst->m_itemID]->getRenderShape())) { float red, grn, blu, alp = 1.0f; @@ -85,7 +85,7 @@ void ItemInHandRenderer::renderItem(ItemInstance* inst) else { std::string toBind; - if (inst->m_itemID <= C_MAX_TILES) + if (inst->m_itemID < C_MAX_TILES) toBind = C_TERRAIN_NAME; else toBind = "gui/items.png"; @@ -314,9 +314,19 @@ void ItemInHandRenderer::tick() { m_oHeight = m_height; - int itemID = m_pMinecraft->m_pLocalPlayer->m_pInventory->getSelectedItemId(); + ItemInstance* item = m_pMinecraft->m_pLocalPlayer->m_pInventory->getSelectedItem(); - bool bSameItem = itemID == m_selectedItem.m_itemID; + bool bSameItem = m_pMinecraft->m_pLocalPlayer->m_pInventory->m_selectedHotbarSlot == m_lastSlot && ItemInstance::matches(&m_selectedItem, item); + + if (ItemInstance::isNull(item) && ItemInstance::isNull(&m_selectedItem)) + bSameItem = true; + + // without this, the player hand remains hidden + if (!ItemInstance::isNull(item) && !ItemInstance::isNull(&m_selectedItem) && item != &m_selectedItem && item->m_itemID == m_selectedItem.m_itemID && item->getAuxValue() == m_selectedItem.getAuxValue()) + { + bSameItem = true; + m_selectedItem = *item; + } float b = bSameItem ? 1.0f : 0.0f; @@ -324,12 +334,19 @@ void ItemInHandRenderer::tick() if (a < -0.4f) a = -0.4f; if (a >= 0.4f) - a = 0.4f; + a = 0.4f; m_height += a; if (m_height < 0.1f) - m_selectedItem.m_itemID = itemID; + { + if (ItemInstance::isNull(item)) + m_selectedItem.m_itemID = 0; + else + m_selectedItem = *item; + + m_lastSlot = m_pMinecraft->m_pLocalPlayer->m_pInventory->m_selectedHotbarSlot; + } } void ItemInHandRenderer::turn(const Vec2& rot) diff --git a/source/client/renderer/LavaSideTexture.cpp b/source/client/renderer/LavaSideTexture.cpp index 55866b372..b8492508b 100644 --- a/source/client/renderer/LavaSideTexture.cpp +++ b/source/client/renderer/LavaSideTexture.cpp @@ -46,7 +46,7 @@ void LavaSideTexture::tick() { for (int y = 0; y < 16; y++) { - float f = 0.0F; + float f = 0.0f; int ax = int(Mth::sin((float(x) * float(M_PI) * 2) / 16.0f) * 1.2f); int ay = int(Mth::sin((float(y) * float(M_PI) * 2) / 16.0f) * 1.2f); diff --git a/source/client/renderer/LavaTexture.cpp b/source/client/renderer/LavaTexture.cpp index 3ab1d66be..e53acd416 100644 --- a/source/client/renderer/LavaTexture.cpp +++ b/source/client/renderer/LavaTexture.cpp @@ -44,7 +44,7 @@ void LavaTexture::tick() { for (int y = 0; y < 16; y++) { - float f = 0.0F; + float f = 0.0f; int ax = int(Mth::sin((float(x) * float(M_PI) * 2) / 16.0f) * 1.2f); int ay = int(Mth::sin((float(y) * float(M_PI) * 2) / 16.0f) * 1.2f); diff --git a/source/client/renderer/LevelRenderer.cpp b/source/client/renderer/LevelRenderer.cpp index 329710117..3459e487f 100644 --- a/source/client/renderer/LevelRenderer.cpp +++ b/source/client/renderer/LevelRenderer.cpp @@ -821,6 +821,7 @@ void LevelRenderer::renderHit(Player* pPlayer, const HitResult& hr, int i, void* float pz = pPlayer->m_posPrev.z + (pPlayer->m_pos.z - pPlayer->m_posPrev.z) * f; Tesselator& t = Tesselator::instance; + glEnable(GL_ALPHA_TEST); // Fixes for b1.7.3 terrain t.begin(); t.offset(-px, -py, -pz); t.noColor(); @@ -1341,9 +1342,9 @@ void LevelRenderer::renderAdvancedClouds(float alpha) if (m_pMinecraft->getOptions()->m_bAnaglyphs) { - uo = (cr * 30.0F + cg * 59.0F + cb * 11.0F) / 100.0F; - vo = (cr * 30.0F + cg * 70.0F) / 100.0F; - scale = (cr * 30.0F + cb * 70.0F) / 100.0F; + uo = (cr * 30.0f + cg * 59.0f + cb * 11.0f) / 100.0f; + vo = (cr * 30.0f + cg * 70.0f) / 100.0f; + scale = (cr * 30.0f + cb * 70.0f) / 100.0f; cr = uo; cg = vo; cb = scale; diff --git a/source/client/renderer/TileRenderer.cpp b/source/client/renderer/TileRenderer.cpp index b1f370f55..1921aabc2 100644 --- a/source/client/renderer/TileRenderer.cpp +++ b/source/client/renderer/TileRenderer.cpp @@ -120,12 +120,15 @@ float TileRenderer::getWaterHeight(const TilePos& pos, const Material* pCheckMtl bool TileRenderer::canRender(int renderShape) { - return renderShape == SHAPE_SOLID || renderShape == SHAPE_STAIRS; + return renderShape == SHAPE_SOLID || renderShape == SHAPE_STAIRS || renderShape == SHAPE_FENCE || renderShape == SHAPE_CACTUS; } // @NOTE: This sucks! Very badly! But it's how they did it. void TileRenderer::renderEast(Tile* tile, const Vec3& pos, int texture) { + if (tile->getRenderShape() == SHAPE_CACTUS) + tile->setShape(0.0625, 0, 0, 0.9375, 1, 1); + static constexpr float C_RATIO = 1.0f / 256.0f; if (m_textureOverride >= 0) @@ -185,10 +188,16 @@ void TileRenderer::renderEast(Tile* tile, const Vec3& pos, int texture) t.vertexUV(aabb.max.x + pos.x, aabb.min.y + pos.y, aabb.min.z + pos.z, texU_r, texV_d); t.vertexUV(aabb.max.x + pos.x, aabb.max.y + pos.y, aabb.min.z + pos.z, texU_r, texV_u); t.vertexUV(aabb.max.x + pos.x, aabb.max.y + pos.y, aabb.max.z + pos.z, texU_l, texV_u); + + if (tile->getRenderShape() == SHAPE_CACTUS) + tile->updateShape(m_pLevelSource, pos); } void TileRenderer::renderWest(Tile* tile, const Vec3& pos, int texture) { + if (tile->getRenderShape() == SHAPE_CACTUS) + tile->setShape(0.0625, 0, 0, 0.9375, 1, 1); + static constexpr float C_RATIO = 1.0f / 256.0f; if (m_textureOverride >= 0) @@ -248,10 +257,16 @@ void TileRenderer::renderWest(Tile* tile, const Vec3& pos, int texture) t.vertexUV(aabb.min.x + pos.x, aabb.max.y + pos.y, aabb.min.z + pos.z, texU_l, texV_u); t.vertexUV(aabb.min.x + pos.x, aabb.min.y + pos.y, aabb.min.z + pos.z, texU_l, texV_d); t.vertexUV(aabb.min.x + pos.x, aabb.min.y + pos.y, aabb.max.z + pos.z, texU_r, texV_d); + + if (tile->getRenderShape() == SHAPE_CACTUS) + tile->updateShape(m_pLevelSource, pos); } void TileRenderer::renderSouth(Tile* tile, const Vec3& pos, int texture) { + if (tile->getRenderShape() == SHAPE_CACTUS) + tile->setShape(0, 0, 0.0625, 1, 1, 0.9375); + static constexpr float C_RATIO = 1.0f / 256.0f; if (m_textureOverride >= 0) @@ -311,10 +326,16 @@ void TileRenderer::renderSouth(Tile* tile, const Vec3& pos, int texture) t.vertexUV(aabb.min.x + pos.x, aabb.min.y + pos.y, aabb.max.z + pos.z, texU_l, texV_d); t.vertexUV(aabb.max.x + pos.x, aabb.min.y + pos.y, aabb.max.z + pos.z, texU_r, texV_d); t.vertexUV(aabb.max.x + pos.x, aabb.max.y + pos.y, aabb.max.z + pos.z, texU_r, texV_u); + + if (tile->getRenderShape() == SHAPE_CACTUS) + tile->updateShape(m_pLevelSource, pos); } void TileRenderer::renderNorth(Tile* tile, const Vec3& pos, int texture) { + if (tile->getRenderShape() == SHAPE_CACTUS) + tile->setShape(0, 0, 0.0625, 1, 1, 0.9375); + static constexpr float C_RATIO = 1.0f / 256.0f; if (m_textureOverride >= 0) @@ -374,10 +395,16 @@ void TileRenderer::renderNorth(Tile* tile, const Vec3& pos, int texture) t.vertexUV(aabb.max.x + pos.x, aabb.max.y + pos.y, aabb.min.z + pos.z, texU_l, texV_u); t.vertexUV(aabb.max.x + pos.x, aabb.min.y + pos.y, aabb.min.z + pos.z, texU_l, texV_d); t.vertexUV(aabb.min.x + pos.x, aabb.min.y + pos.y, aabb.min.z + pos.z, texU_r, texV_d); + + if (tile->getRenderShape() == SHAPE_CACTUS) + tile->updateShape(m_pLevelSource, pos); } void TileRenderer::renderFaceDown(Tile* tile, const Vec3& pos, int texture) { + if (tile->getRenderShape() == SHAPE_CACTUS) + tile->setShape(0, 0, 0, 1, 1, 1); + static constexpr float C_RATIO = 1.0f / 256.0f; if (m_textureOverride >= 0) @@ -431,10 +458,16 @@ void TileRenderer::renderFaceDown(Tile* tile, const Vec3& pos, int texture) t.vertexUV(aabb.max.x + pos.x, aabb.max.y + pos.y, aabb.min.z + pos.z, texU_2, texV_1); t.vertexUV(aabb.min.x + pos.x, aabb.max.y + pos.y, aabb.min.z + pos.z, texU_1, texV_1); t.vertexUV(aabb.min.x + pos.x, aabb.max.y + pos.y, aabb.max.z + pos.z, texU_1, texV_2); + + if (tile->getRenderShape() == SHAPE_CACTUS) + tile->updateShape(m_pLevelSource, pos); } void TileRenderer::renderFaceUp(Tile* tile, const Vec3& pos, int texture) { + if (tile->getRenderShape() == SHAPE_CACTUS) + tile->setShape(0, 0, 0, 1, 1, 1); + static constexpr float C_RATIO = 1.0f / 256.0f; if (m_textureOverride >= 0) @@ -488,6 +521,9 @@ void TileRenderer::renderFaceUp(Tile* tile, const Vec3& pos, int texture) t.vertexUV(aabb.min.x + pos.x, aabb.min.y + pos.y, aabb.min.z + pos.z, texU_1, texV_1); t.vertexUV(aabb.max.x + pos.x, aabb.min.y + pos.y, aabb.min.z + pos.z, texU_2, texV_1); t.vertexUV(aabb.max.x + pos.x, aabb.min.y + pos.y, aabb.max.z + pos.z, texU_2, texV_2); + + if (tile->getRenderShape() == SHAPE_CACTUS) + tile->updateShape(m_pLevelSource, pos); } void TileRenderer::tesselateCrossTexture(Tile* tile, int data, const Vec3& pos) @@ -506,34 +542,44 @@ void TileRenderer::tesselateCrossTexture(Tile* tile, int data, const Vec3& pos) float texV_u = texY * C_RATIO, texV_d = (texY + 15.99f) * C_RATIO; float cenX = pos.x + 0.5f, cenZ = pos.z + 0.5f; + float newY = pos.y; + + if (tile->getRenderShape() == SHAPE_RANDOM_CROSS) + { + int64_t var17 = int64_t(pos.x * 3129871) ^ (int64_t)pos.z * 116129781L ^ (int64_t)pos.y; + var17 = var17 * var17 * 42317861L + var17 * 11L; + cenX += (((var17 >> 16 & 15L) / 15.0f) - 0.5f) * 0.5f; + newY += (((var17 >> 20 & 15L) / 15.0f) - 1.0f) * 0.2f; + cenZ += (((var17 >> 24 & 15L) / 15.0f) - 0.5f) * 0.5f; + } float x1 = cenX - 0.45f, x2 = cenX + 0.45f; float z1 = cenZ - 0.45f, z2 = cenZ + 0.45f; Tesselator& t = Tesselator::instance; // face 1 - t.vertexUV(x1, pos.y + 1, z1, texU_l, texV_u); - t.vertexUV(x1, pos.y + 0, z1, texU_l, texV_d); - t.vertexUV(x2, pos.y + 0, z2, texU_r, texV_d); - t.vertexUV(x2, pos.y + 1, z2, texU_r, texV_u); + t.vertexUV(x1, newY + 1, z1, texU_l, texV_u); + t.vertexUV(x1, newY + 0, z1, texU_l, texV_d); + t.vertexUV(x2, newY + 0, z2, texU_r, texV_d); + t.vertexUV(x2, newY + 1, z2, texU_r, texV_u); // face 2 - t.vertexUV(x2, pos.y + 1, z2, texU_l, texV_u); - t.vertexUV(x2, pos.y + 0, z2, texU_l, texV_d); - t.vertexUV(x1, pos.y + 0, z1, texU_r, texV_d); - t.vertexUV(x1, pos.y + 1, z1, texU_r, texV_u); + t.vertexUV(x2, newY + 1, z2, texU_l, texV_u); + t.vertexUV(x2, newY + 0, z2, texU_l, texV_d); + t.vertexUV(x1, newY + 0, z1, texU_r, texV_d); + t.vertexUV(x1, newY + 1, z1, texU_r, texV_u); // face 3 - t.vertexUV(x1, pos.y + 1, z2, texU_l, texV_u); - t.vertexUV(x1, pos.y + 0, z2, texU_l, texV_d); - t.vertexUV(x2, pos.y + 0, z1, texU_r, texV_d); - t.vertexUV(x2, pos.y + 1, z1, texU_r, texV_u); + t.vertexUV(x1, newY + 1, z2, texU_l, texV_u); + t.vertexUV(x1, newY + 0, z2, texU_l, texV_d); + t.vertexUV(x2, newY + 0, z1, texU_r, texV_d); + t.vertexUV(x2, newY + 1, z1, texU_r, texV_u); // face 4 - t.vertexUV(x2, pos.y + 1, z1, texU_l, texV_u); - t.vertexUV(x2, pos.y + 0, z1, texU_l, texV_d); - t.vertexUV(x1, pos.y + 0, z2, texU_r, texV_d); - t.vertexUV(x1, pos.y + 1, z2, texU_r, texV_u); + t.vertexUV(x2, newY + 1, z1, texU_l, texV_u); + t.vertexUV(x2, newY + 0, z1, texU_l, texV_d); + t.vertexUV(x1, newY + 0, z2, texU_r, texV_d); + t.vertexUV(x1, newY + 1, z2, texU_r, texV_u); } bool TileRenderer::tesselateBlockInWorld(Tile* tile, const TilePos& pos, float r, float g, float b) @@ -675,8 +721,12 @@ bool TileRenderer::tesselateCrossInWorld(Tile* tile, const TilePos& pos) Tesselator& t = Tesselator::instance; float bright = tile->getBrightness(m_pLevelSource, pos); + int color = getTileColor(tile, pos); + float r = bright * (float(GET_RED(color)) / 255.0f); + float g = bright * (float(GET_GREEN(color)) / 255.0f); + float b = bright * (float(GET_BLUE(color)) / 255.0f); - t.color(bright, bright, bright); + t.color(r, g, b); tesselateCrossTexture(tile, m_pLevelSource->getData(pos), pos); @@ -938,6 +988,66 @@ bool TileRenderer::tesselateStairsInWorld(Tile* tile, const TilePos& pos) return bRenderedAnything; } +bool TileRenderer::tesselateFenceInWorld(Tile* tile, const TilePos& pos) +{ + tile->setShape(0.375f, 0.0f, 0.375f, 0.625f, 1.0f, 0.625f); + bool bRenderedAnything = tesselateBlockInWorld(tile, pos); + + + bool tileWest = m_pLevelSource->getTile(pos.west()) == tile->m_ID; + bool tileEast = m_pLevelSource->getTile(pos.east()) == tile->m_ID; + bool tileNorth = m_pLevelSource->getTile(pos.north()) == tile->m_ID; + bool tileSouth = m_pLevelSource->getTile(pos.south()) == tile->m_ID; + + bool connectsHorizontally = tileWest || tileEast; + bool connectsVertically = tileNorth || tileSouth; + + if (!connectsHorizontally && !connectsVertically) { + connectsHorizontally = true; + } + + float var6 = 7.0f / 16.0f; + float var7 = 9.0f / 16.0f; + float var14 = 12.0f / 16.0f; + float var15 = 15.0f / 16.0f; + float var16 = tileWest ? 0.0f : var6; + float var17 = tileEast ? 1.0f : var7; + float var18 = tileNorth ? 0.0f : var6; + float var19 = tileSouth ? 1.0f : var7; + + if (connectsHorizontally) + { + tile->setShape(var16, var14, var6, var17, var15, var7); + if (tesselateBlockInWorld(tile, pos)) bRenderedAnything = true; + + } + + if (connectsVertically) + { + tile->setShape(var6, var14, var18, var7, var15, var19); + if (tesselateBlockInWorld(tile, pos)) bRenderedAnything = true; + } + + var14 = 6.0f / 16.0f; + var15 = 9.0f / 16.0f; + + if (connectsHorizontally) + { + tile->setShape(var16, var14, var6, var17, var15, var7); + if (tesselateBlockInWorld(tile, pos)) bRenderedAnything = true; + } + + if (connectsVertically) + { + tile->setShape(var6, var14, var18, var7, var15, var19); + if (tesselateBlockInWorld(tile, pos)) bRenderedAnything = true; + } + + tile->setShape(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); + + return bRenderedAnything; +} + bool TileRenderer::tesselateDoorInWorld(Tile* tile, const TilePos& pos) { Tesselator& t = Tesselator::instance; @@ -1344,6 +1454,7 @@ bool TileRenderer::tesselateInWorld(Tile* tile, const TilePos& pos) case SHAPE_WATER: return tesselateWaterInWorld(tile, pos); case SHAPE_CROSS: + case SHAPE_RANDOM_CROSS: return tesselateCrossInWorld(tile, pos); case SHAPE_TORCH: return tesselateTorchInWorld(tile, pos); @@ -1353,6 +1464,10 @@ bool TileRenderer::tesselateInWorld(Tile* tile, const TilePos& pos) return tesselateDoorInWorld(tile, pos); case SHAPE_STAIRS: return tesselateStairsInWorld(tile, pos); + case SHAPE_FENCE: + return tesselateFenceInWorld(tile, pos); + case SHAPE_CACTUS: + return tesselateBlockInWorld(tile, pos); } return false; @@ -2500,6 +2615,46 @@ void TileRenderer::renderTile(Tile* tile, int data, float bright, bool preshade) t.addOffset(0.5f, 0.5f, 0.5f); break; } + case SHAPE_FENCE: + { + t.addOffset(-0.5f, -0.5f, -0.5f); + float v5 = 1.0f / 16.0f; + float v6 = v5 * 2.0f; + for (int i = 0; i < 4; i++) + { + switch (i) { + case 0: tile->setShape(0.5f - v6, 0.0f, 0.0f, 0.5f + v6, 1.0f, v6 * 2.0f); break; + case 1: tile->setShape(0.5f - v6, 0.0f, 1.0f - (v6 * 2.0f), 0.5f + v6, 1.0f, 1.0f); break; + case 2: tile->setShape(0.5f - v5, 1.0f - v5 * 3.0f, -v5 * 2.0f, 0.5f + v5, 1.0f - v5, 1.0f + v5 * 2.0f); break; + case 3: tile->setShape(0.5f - v5, 0.5f - v5 * 3.0f, -v5 * 2.0f, 0.5f + v5, 0.5f - v5, 1.0f + v5 * 2.0f); break; + } + + t.begin(); + SHADE_DEFINE; + SHADE_PREPARE; + SHADE_IF_NEEDED(1.0f); + t.normal(0.0f, 1.0f, 0.0f); + renderFaceDown(tile, Vec3::ZERO, tile->getTexture(Facing::UP, data)); + SHADE_IF_NEEDED(0.5f); + t.normal(0.0f, -1.0f, 0.0f); + renderFaceUp(tile, Vec3::ZERO, tile->getTexture(Facing::DOWN, data)); + SHADE_IF_NEEDED(0.8f); + t.normal(0.0f, 0.0f, -1.0f); + renderNorth(tile, Vec3::ZERO, tile->getTexture(Facing::NORTH, data)); + t.normal(0.0f, 0.0f, 1.0f); + renderSouth(tile, Vec3::ZERO, tile->getTexture(Facing::SOUTH, data)); + SHADE_IF_NEEDED(0.6f); + t.normal(-1.0f, 0.0f, 0.0f); + renderWest(tile, Vec3::ZERO, tile->getTexture(Facing::WEST, data)); + t.normal(1.0f, 0.0f, 0.0f); + renderEast(tile, Vec3::ZERO, tile->getTexture(Facing::EAST, data)); + SHADE_IF_NEEDED(1.0f); + t.draw(); + } + t.addOffset(0.5f, 0.5f, 0.5f); + tile->setShape(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); + break; + } } } @@ -2658,7 +2813,8 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusionV2(Tile* tile, cons m_bAmbientOcclusion = true; - switch (dir) { + switch (dir) + { case Facing::DOWN: renderFaceUp (tile, pos, tile->getTexture(m_pLevelSource, pos, Facing::DOWN)); break; @@ -2706,7 +2862,8 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusionV2(Tile* tile, cons m_vtxBlue[i] *= topB * lightingMult[dir]; } - switch (dir) { + switch (dir) + { case Facing::DOWN: renderFaceUp(tile, pos, TEXTURE_NONE84); break; @@ -2742,7 +2899,7 @@ int TileRenderer::getTileColor(Tile* tile, const TilePos& pos) return 0xffffff; } - if (tile == Tile::grass && GrassColor::isAvailable() && m_bBiomeColors) + if ((tile == Tile::grass || tile == Tile::tallGrass) && GrassColor::isAvailable() && m_bBiomeColors) { m_pLevelSource->getBiomeSource()->getBiomeBlock(pos, 1, 1); return GrassColor::get(m_pLevelSource->getBiomeSource()->field_4[0], m_pLevelSource->getBiomeSource()->field_8[0]); diff --git a/source/client/renderer/TileRenderer.hpp b/source/client/renderer/TileRenderer.hpp index 8523cd024..e9699a611 100644 --- a/source/client/renderer/TileRenderer.hpp +++ b/source/client/renderer/TileRenderer.hpp @@ -43,6 +43,7 @@ class TileRenderer bool tesselateCrossInWorld(Tile*, const TilePos& pos); bool tesselateWaterInWorld(Tile*, const TilePos& pos); bool tesselateStairsInWorld(Tile*, const TilePos& pos); + bool tesselateFenceInWorld(Tile*, const TilePos& pos); bool tesselateLadderInWorld(Tile*, const TilePos& pos); bool tesselateTorchInWorld(Tile*, const TilePos& pos); bool tesselateDoorInWorld(Tile*, const TilePos& pos); @@ -117,4 +118,3 @@ class TileRenderer bool field_B6; bool field_B7; }; - diff --git a/source/client/renderer/entity/HumanoidMobRenderer.cpp b/source/client/renderer/entity/HumanoidMobRenderer.cpp index 4e9da0fe5..2f4a29562 100644 --- a/source/client/renderer/entity/HumanoidMobRenderer.cpp +++ b/source/client/renderer/entity/HumanoidMobRenderer.cpp @@ -27,7 +27,7 @@ void HumanoidMobRenderer::additionalRendering(Mob* mob, float f) m_pHumanoidModel->m_arm1.translateTo(0.0625f); glTranslatef(-0.0625f, 0.4375f, 0.0625f); #pragma warning(disable : 6385) // this warning is just wrong; intellisense cant handle it being a pointer->index - if (inst && inst->m_itemID <= C_MAX_TILES && TileRenderer::canRender(Tile::tiles[inst->m_itemID]->getRenderShape())) + if (inst && inst->m_itemID < C_MAX_TILES && TileRenderer::canRender(Tile::tiles[inst->m_itemID]->getRenderShape())) { glTranslatef(0.0f, 0.1875f, -0.3125f); glRotatef(20.0f, 1.0f, 0.0f, 0.0f); @@ -56,6 +56,26 @@ void HumanoidMobRenderer::additionalRendering(Mob* mob, float f) glDisable(GL_RESCALE_NORMAL); } +void HumanoidMobRenderer::render(Entity* pEntity, const Vec3& pos, float f1, float f2) +{ + if (pEntity->isPlayer()) + { + Player* player = (Player*)pEntity; + ItemInstance* item = player->getSelectedItem(); + m_pHumanoidModel->m_bHoldingRightHand = item != nullptr; + } + if (pEntity->isSneaking()) + { + Vec3 pos2 = pos; + pos2.y -= 0.125f; + MobRenderer::render(pEntity, pos2, f1, f2); + } + else + { + MobRenderer::render(pEntity, pos, f1, f2); + } +} + void HumanoidMobRenderer::onGraphicsReset() { m_pHumanoidModel->onGraphicsReset(); diff --git a/source/client/renderer/entity/HumanoidMobRenderer.hpp b/source/client/renderer/entity/HumanoidMobRenderer.hpp index 9d68f2a04..231f5189c 100644 --- a/source/client/renderer/entity/HumanoidMobRenderer.hpp +++ b/source/client/renderer/entity/HumanoidMobRenderer.hpp @@ -15,6 +15,7 @@ class HumanoidMobRenderer : public MobRenderer public: HumanoidMobRenderer(HumanoidModel*, float); virtual void additionalRendering(Mob*, float) override; + virtual void render(Entity*, const Vec3&, float, float) override; virtual void onGraphicsReset() override; void renderHand(); @@ -22,4 +23,3 @@ class HumanoidMobRenderer : public MobRenderer public: HumanoidModel* m_pHumanoidModel; }; - diff --git a/source/common/Util.cpp b/source/common/Util.cpp index fcc4cb861..0229e8c75 100644 --- a/source/common/Util.cpp +++ b/source/common/Util.cpp @@ -6,7 +6,6 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ -#include #include "Util.hpp" const std::string Util::EMPTY_STRING = ""; @@ -52,7 +51,7 @@ std::string Util::vformat(const char *fmt, va_list argPtr) vsnprintf(str, sizeof(str), fmt, argPtr); - return std::string(str, sizeof(str)); + return std::string(str); } std::string Util::format(const char *fmt, ...) diff --git a/source/common/Util.hpp b/source/common/Util.hpp index 25dc10db8..a2625ba02 100644 --- a/source/common/Util.hpp +++ b/source/common/Util.hpp @@ -13,6 +13,7 @@ #include #include #include +#include class Util { diff --git a/source/common/Utils.hpp b/source/common/Utils.hpp index d6d4a96c4..67f940954 100644 --- a/source/common/Utils.hpp +++ b/source/common/Utils.hpp @@ -250,7 +250,7 @@ enum eTileID TILE_STONE_BRICKS, TILE_MUSHROOM1_BLOCK, TILE_MUSHROOM2_BLOCK, - TILE_CLOTH_00 = 101, + TILE_CLOTH_00 = 101, // @TODO: make these save on newer worlds TILE_CLOTH_10, TILE_CLOTH_20, TILE_CLOTH_30, @@ -381,6 +381,7 @@ enum eTileID // Custom items ITEM_ROCKET = 470, + ITEM_QUIVER = 484, }; enum // Textures @@ -423,8 +424,8 @@ enum // Textures TEXTURE_BOOKSHELF, TEXTURE_MOSSY_STONE, TEXTURE_OBSIDIAN, - TEXTURE_OBSIDIAN_CRYING, - TEXTURE_NONE39, + TEXTURE_OBSIDIAN_CRYING, // would become grass side overaly after removel + TEXTURE_NONE39, // tall grass TEXTURE_NONE40, TEXTURE_CHEST_TWO_FRONT_LEFT, TEXTURE_CHEST_TWO_FRONT_RIGHT, @@ -440,7 +441,7 @@ enum // Textures TEXTURE_LEAVES_TRANSPARENT, TEXTURE_LEAVES_OPAQUE, TEXTURE_NONE54, - TEXTURE_NONE55, + TEXTURE_NONE55, // dead bush TEXTURE_NONE56, TEXTURE_CHEST_TWO_BACK_LEFT, TEXTURE_CHEST_TWO_BACK_RIGHT, @@ -544,6 +545,9 @@ enum eRenderShape SHAPE_LADDER, SHAPE_UNK9, SHAPE_STAIRS, + SHAPE_FENCE, + SHAPE_CACTUS, + SHAPE_RANDOM_CROSS }; enum eRenderLayer diff --git a/source/network/ServerSideNetworkHandler.cpp b/source/network/ServerSideNetworkHandler.cpp index f0633a91f..07a7f2ee8 100644 --- a/source/network/ServerSideNetworkHandler.cpp +++ b/source/network/ServerSideNetworkHandler.cpp @@ -422,6 +422,8 @@ void ServerSideNetworkHandler::setupCommands() m_commands["tp"] = &ServerSideNetworkHandler::commandTP; m_commands["summon"] = &ServerSideNetworkHandler::commandSummon; m_commands["gamemode"] = &ServerSideNetworkHandler::commandGamemode; + m_commands["give"] = &ServerSideNetworkHandler::commandGive; + m_commands["clear"] = &ServerSideNetworkHandler::commandClear; } bool ServerSideNetworkHandler::_checkPermissions(OnlinePlayer* player) @@ -492,7 +494,7 @@ void ServerSideNetworkHandler::commandTime(OnlinePlayer* player, const std::vect int t = 0; if (!sscanf(parms[0].c_str(), "%d", &t)) { - sendMessage(player, "Usage: /time [new time value]"); + sendMessage(player, "Usage: /time "); return; } @@ -577,7 +579,7 @@ void ServerSideNetworkHandler::commandSummon(OnlinePlayer* player, const std::ve if (parmsSize != 1 && parmsSize != 4 && parmsSize != 5) { - sendMessage(player, "Usage: /summon "); + sendMessage(player, "Usage: /summon [x] [y] [z] [amount]"); return; } @@ -693,3 +695,70 @@ void ServerSideNetworkHandler::commandGamemode(OnlinePlayer* player, const std:: sendMessage(player, "Your game mode has been updated"); } + +void ServerSideNetworkHandler::commandGive(OnlinePlayer * player, const std::vector&parms) +{ + const std::string usage = "Usage: /give [amount] [data]"; + + if (!m_pLevel) + return; + if (parms.size() < 1 || parms.size() > 3) + { + sendMessage(player, usage); + return; + } + + if (!_checkPermissions(player)) return; + + int id = 0; + int amount = 1; + int auxValue = 0; + if (sscanf(parms[0].c_str(), "%d", &id)) + { + if (!_validateNum(player, id, 1, C_MAX_ITEMS-1)) + return; + } + else + { + sendMessage(player, usage); + return; + } + if (parms.size() >= 2 && sscanf(parms[1].c_str(), "%d", &amount)) + { + if (!_validateNum(player, amount, 1, 64)) + return; + } + if (parms.size() >= 3 && sscanf(parms[2].c_str(), "%d", &auxValue)) + { + if (!_validateNum(player, auxValue, 0, 255)) + return; + } + Item* item = Item::items[id]; + if (!item || id >= 512 || id < 0) + { + sendMessage(player, "There is no such item with ID " + parms[0]); + return; + } + + Inventory* pInventory = player->m_pPlayer->m_pInventory; + + pInventory->addTestItem(item->m_itemID, amount, auxValue); + + sendMessage(player, Util::format("Given %s (ID %d) * %d to %s", item->getName().c_str(), item->m_itemID, amount, player->m_pPlayer->m_name.c_str())); + return; +} + +void ServerSideNetworkHandler::commandClear(OnlinePlayer* player, const std::vector& parms) +{ + if (!m_pLevel) + return; + + if (!_checkPermissions(player)) return; + + Inventory* pInventory = player->m_pPlayer->m_pInventory; + + pInventory->empty(); // calling "clear" will delete all of our slots + + sendMessage(player, "Your inventory has been cleared."); + return; +} diff --git a/source/network/ServerSideNetworkHandler.hpp b/source/network/ServerSideNetworkHandler.hpp index ca56db636..e298cb8a3 100644 --- a/source/network/ServerSideNetworkHandler.hpp +++ b/source/network/ServerSideNetworkHandler.hpp @@ -78,6 +78,8 @@ class ServerSideNetworkHandler : public NetEventCallback, public LevelListener void commandTP (OnlinePlayer*, const std::vector&); void commandSummon (OnlinePlayer*, const std::vector&); void commandGamemode (OnlinePlayer*, const std::vector&); + void commandGive (OnlinePlayer*, const std::vector&); + void commandClear (OnlinePlayer*, const std::vector&); public: Minecraft* m_pMinecraft; diff --git a/source/world/entity/Chicken.cpp b/source/world/entity/Chicken.cpp index 8eba37bc5..9d35ddd07 100644 --- a/source/world/entity/Chicken.cpp +++ b/source/world/entity/Chicken.cpp @@ -25,7 +25,7 @@ void Chicken::aiStep() m_oFlap = m_flap; m_oFlapSpeed = m_flapSpeed; - m_flapSpeed += (m_onGround ? -1.0f : 4.0f) * 0.3f; + m_flapSpeed += (m_bOnGround ? -1.0f : 4.0f) * 0.3f; if (m_flapSpeed >= 0.0f) { if (m_flapSpeed > 1.0f) @@ -35,11 +35,11 @@ void Chicken::aiStep() { m_flapSpeed = 0.0f; } - if (!m_onGround && m_flapping < 1.0f) + if (!m_bOnGround && m_flapping < 1.0f) m_flapping = 1.0f; m_flapping *= 0.9f; - if (!m_onGround && m_vel.y < 0.0f) + if (!m_bOnGround && m_vel.y < 0.0f) m_vel.y *= 0.6f; m_flap += m_flapping * 2.0f; diff --git a/source/world/entity/Entity.cpp b/source/world/entity/Entity.cpp index 792a63f03..1bfd7b4d6 100644 --- a/source/world/entity/Entity.cpp +++ b/source/world/entity/Entity.cpp @@ -28,12 +28,13 @@ void Entity::_init() m_pLevel = nullptr; m_rot = Vec2::ZERO; m_oRot = Vec2::ZERO; - m_onGround = false; + m_bOnGround = false; m_bHorizontalCollision = false; - field_7E = false; - field_7F = false; + m_bCollision = false; + m_bVerticalCollision = false; m_bHurt = false; - field_81 = 1; + m_bIsInWeb = false; + m_bSlide = 1; m_bRemoved = false; m_heightOffset = 0.0f; m_bbWidth = 0.6f; @@ -42,7 +43,7 @@ void Entity::_init() m_walkDist = 0.0f; m_bMakeStepSound = true; m_ySlideOffset = 0.0f; - field_A8 = 0.0f; + m_footSize = 0.0f; m_bNoPhysics = false; field_B0 = 0.0f; m_tickCount = 0; @@ -54,9 +55,9 @@ void Entity::_init() field_C8 = 0; // @NOTE: Render type? (eEntityRenderType) m_distanceFallen = 0.0f; m_airSupply = TOTAL_AIR_SUPPLY; - field_D4 = 0; - field_D5 = false; - field_D6 = true; + m_bWasInWater = false; + m_bFireImmune = false; + m_bFirstTick = true; m_nextStep = 1; m_entityData = SynchedEntityData(); m_pDescriptor = &EntityTypeDescriptor::unknown; @@ -110,391 +111,215 @@ void Entity::remove() int Entity::move(const Vec3& pos) { - float x_1 = pos.x, z_1 = pos.z; - if (m_bNoPhysics) { - // just move it. Don't perform any kind of collision - m_hitbox.min += pos; - m_hitbox.max += pos; - - m_pos.x = (m_hitbox.max.x + m_hitbox.min.x) / 2; - m_pos.z = (m_hitbox.max.z + m_hitbox.min.z) / 2; + m_hitbox.move(pos); + m_pos.x = (m_hitbox.min.x + m_hitbox.max.x) / 2.0f; m_pos.y = m_hitbox.min.y + m_heightOffset - m_ySlideOffset; - - return 1300; - } - - //@TODO: untangle the control flow - - float x1, x2, x3, x4, x5, x6; - float x7, x8, x9, x10, x11, x12, x20; - float x_2, z_2, x_3, z_3; - float oldX, oldZ; - bool b1, b2, b3, b4, b5, b6; - AABB hitold; - - oldX = m_pos.x; oldZ = m_pos.z; - - x7 = m_hitbox.max.z; - x8 = m_hitbox.max.y; - x9 = m_hitbox.max.x; - x10 = m_hitbox.min.z; - x11 = m_hitbox.min.y; - x12 = m_hitbox.min.x; - - x1 = m_hitbox.max.z; - x2 = m_hitbox.max.y; - x3 = m_hitbox.max.x; - x4 = m_hitbox.min.z; - x5 = m_hitbox.min.y; - x6 = m_hitbox.min.x; - - if (!m_onGround) - { - label_4: - - z_2 = z_1; - b1 = x_1 < 0.0f; - b2 = x_1 > 0.0f; - x_2 = x_1; - b3 = z_1 < 0.0f; - b4 = z_1 > 0.0f; - b5 = false; - goto label_5; - } - - if (!isSneaking()) - goto label_4; - - if (x_1 == 0.0f) - { - x_2 = x_1; - b1 = x_1 < 0.0f; - b2 = x_1 > 0.0f; + m_pos.z = (m_hitbox.min.z + m_hitbox.max.z) / 2.0f; } else { - x_2 = x_1; - do + m_ySlideOffset *= 0.4f; + Vec3 newPos(pos); + if (m_bIsInWeb) { - AABB aabb = m_hitbox; - aabb.move(x_1, -1.0f, 0); - - AABBVector* cubes = m_pLevel->getCubes(this, aabb); - - if (cubes->size()) - break; - - if (x_1 < 0.05f && x_1 >= -0.05f) + m_bIsInWeb = false; + newPos.x *= 0.25f; + newPos.y *= 0.05f; + newPos.z *= 0.25f; + m_vel = Vec3::ZERO; + m_distanceFallen = 0.0f; + } + float aPosX = m_pos.x; + float aPosZ = m_pos.z; + float cPosX = newPos.x; + float cPosY = newPos.y; + float cPosZ = newPos.z; + AABB lastHit = m_hitbox; + bool validSneaking = m_bOnGround && isSneaking(); + if (validSneaking) + { + for (float dx = 0.05f; pos.x != 0.0f && m_pLevel->getCubes(this, AABB(m_hitbox).move(newPos.x, -1.0f, 0.0f))->size() == 0; cPosX = newPos.x) { - x_2 = 0.0f; - x_1 = 0.0f; - break; + if (newPos.x < dx && newPos.x >= -dx) + newPos.x = 0.0; + else if (newPos.x > 0.0f) + newPos.x -= dx; + else + newPos.x += dx; } - // @BUG: See the z_1 part - if (x_1 <= 0.0f) - x_1 = x_1 + 0.05f; - else - x_1 = x_1 - 0.05f; - - x_2 = x_1; - } while (x_1 != 0.0f); - - b1 = x_1 < 0.0f; - b2 = x_1 > 0.0f; - } - - if (z_1 == 0.0f) - { - z_2 = z_1; - b3 = z_1 < 0.0f; - b4 = z_1 > 0.0f; - } - else - { - z_2 = z_1; - do - { - AABB aabb = m_hitbox; - aabb.move(0, -1.0f, z_1); - - AABBVector* cubes = m_pLevel->getCubes(this, aabb); - - if (cubes->size()) - break; - - if (z_1 < 0.05f && z_1 >= -0.05f) + for (float dz = 0.05f; newPos.z != 0.0f && m_pLevel->getCubes(this, AABB(m_hitbox).move(0.0f, -1.0f, newPos.z))->size() == 0; cPosZ = newPos.z) { - z_2 = 0.0f; - z_1 = 0.0f; - break; + if (newPos.z < dz && newPos.z >= -dz) + newPos.z = 0.0f; + else if (newPos.z > 0.0f) + newPos.z -= dz; + else + newPos.z += dz; } + } - //@BUG: wouldn't this loop forever? Since if z_1 == 0.025f, it'd oscillate between -0.025f and +0.025f... - if (z_1 <= 0.0f) - z_1 = z_1 + 0.05f; - else - z_1 = z_1 - 0.05f; - } while (z_1 != 0.0f); - b3 = z_1 < 0.0f; - b4 = z_1 > 0.0f; - } - - b5 = true; - -label_5: - if (b1) x6 += x_1; - if (b2) x3 += x_1; - if (pos.y < 0.0f) x5 += pos.y; - if (pos.y > 0.0f) x2 += pos.y; - if (b3) x4 += pos.z; - if (b4) x1 += pos.z; - - AABB scanAABB(x6, x5, x4, x3, x2, x1); - AABBVector* pCubes = m_pLevel->getCubes(this, scanAABB); - - float newY = pos.y; - for (int i = 0; i < pCubes->size(); i++) - { - const AABB& aabb = pCubes->at(i); - newY = aabb.clipYCollide(m_hitbox, newY); - } - - m_hitbox.move(0, newY, 0); - - if (!field_81 && newY != pos.y) - { - z_1 = 0.0f; - x_1 = 0.0f; - newY = 0.0f; - } - - if (m_onGround) - { - b6 = true; - } - else - { - b6 = pos.y < 0.0f; - if (newY == pos.y) - b6 = 0; - } - - for (int i = 0; i < pCubes->size(); i++) - { - const AABB& aabb = pCubes->at(i); - x_1 = aabb.clipXCollide(m_hitbox, x_1); - } - - m_hitbox.move(x_1, 0, 0); - - if (!field_81 && x_1 != x_2) - { - z_1 = 0.0f; - x_1 = 0.0f; - newY = 0.0f; - } - - for (int i = 0; i < pCubes->size(); i++) - { - const AABB& aabb = pCubes->at(i); - z_1 = aabb.clipZCollide(m_hitbox, z_1); - } - - m_hitbox.move(0, 0, z_1); - - if (!field_81 && z_1 != z_2) - { - z_1 = 0.0f; - x_1 = 0.0f; - newY = 0.0f; - } - - x20 = field_A8; - if (x20 <= 0.0f || !b6) - { - label_44: - z_3 = z_1; - x_3 = x_1; - goto label_45; - } - - if (m_ySlideOffset >= 0.05f || (x_2 == x_1 && z_2 == z_1)) - goto label_44; + AABBVector* cubes = m_pLevel->getCubes(this, AABB(m_hitbox).expand(newPos.x, newPos.y, newPos.z)); - // oh come on, undoing all our work?? - hitold = m_hitbox; - m_hitbox = AABB(x12, x11, x10, x9, x8, x7); + for (int i = 0; i < int(cubes->size()); ++i) + newPos.y = cubes->at(i).clipYCollide(m_hitbox, newPos.y); - if (b1) x12 += x_2; - if (b2) x9 += x_2; - x8 += x20; //@BUG: missing if (x20 > 0) check? - if (x20 < 0.0f) x11 += x20; - if (b3) x10 += z_2; - if (b4) x7 += z_2; + m_hitbox.move(0.0f, newPos.y, 0.0f); + if (!m_bSlide && cPosY != newPos.y) + newPos = Vec3::ZERO; - { - AABB scanAABB2(x12, x11, x10, x9, x8, x7); + bool lastsOnGround = m_bOnGround || cPosY != newPos.y && cPosY < 0.0; - //@BUG: useless copy - //@BUG: this doesn't actually copy anything - *pCubes = *m_pLevel->getCubes(this, scanAABB2); - } + for (int i = 0; i < int(cubes->size()); ++i) + newPos.x = cubes->at(i).clipXCollide(m_hitbox, newPos.x); + + m_hitbox.move(newPos.x, 0.0f, 0.0f); + if (!m_bSlide && cPosX != newPos.x) + newPos = Vec3::ZERO; - for (int i = 0; i < pCubes->size(); i++) - { - const AABB& aabb = pCubes->at(i); - x20 = aabb.clipYCollide(m_hitbox, x20); - } + for (int i = 0; i < int(cubes->size()); ++i) + newPos.z = cubes->at(i).clipZCollide(m_hitbox, newPos.z); - m_hitbox.move(0, x20, 0); + m_hitbox.move(0.0f, 0.0f, newPos.z); + if (!m_bSlide && cPosZ != newPos.z) + newPos = Vec3::ZERO; - if (field_81 || x20 == pos.y) - { - z_3 = z_2; - x_3 = x_2; - } - else - { - x20 = 0.0f; - z_3 = 0.0f; - x_3 = 0.0f; - } + if (m_footSize > 0.0f && lastsOnGround && m_ySlideOffset < 0.05F && (cPosX != newPos.x || cPosZ != newPos.z)) + { + Vec3 oldPos = newPos; + newPos.x = cPosX; + newPos.y = m_footSize; + newPos.z = cPosZ; + AABB oldHit = m_hitbox; + m_hitbox = lastHit; + cubes = m_pLevel->getCubes(this, AABB(m_hitbox).expand(cPosX, newPos.y, cPosZ)); - for (int i = 0; i < pCubes->size(); i++) - { - const AABB& aabb = pCubes->at(i); - x_3 = aabb.clipXCollide(m_hitbox, x_3); - } + for (int i = 0; i < int(cubes->size()); ++i) + newPos.y = cubes->at(i).clipYCollide(m_hitbox, newPos.y); - m_hitbox.move(x_3, 0, 0); + m_hitbox.move(0.0f, newPos.y, 0.0f); + if (!m_bSlide && cPosY != newPos.y) + newPos = Vec3::ZERO; - if (!field_81 && x_2 != x_3) - { - x20 = 0.0f; - z_3 = 0.0f; - x_3 = 0.0f; - } + for (int i = 0; i < int(cubes->size()); ++i) + newPos.x = cubes->at(i).clipXCollide(m_hitbox, newPos.x); - for (int i = 0; i < pCubes->size(); i++) - { - const AABB& aabb = pCubes->at(i); - z_3 = aabb.clipZCollide(m_hitbox, z_3); - } + m_hitbox.move(newPos.x, 0.0f, 0.0f); + if (!m_bSlide && cPosX != newPos.x) + newPos = Vec3::ZERO; - m_hitbox.move(0, 0, z_3); + for (int i = 0; i < int(cubes->size()); ++i) + newPos.z = cubes->at(i).clipZCollide(m_hitbox, newPos.z); - if (!field_81 && z_2 != z_3) - { - x20 = 0.0f; - z_3 = 0.0f; - x_3 = 0.0f; - } + m_hitbox.move(0.0f, 0.0f, newPos.z); + if (!m_bSlide && cPosZ != newPos.z) + newPos = Vec3::ZERO; - // if we moved more this time than before?? no clue wtf this is about... - if (z_1 * z_1 + x_1 * x_1 < z_3 * z_3 + x_3 * x_3) - { - m_ySlideOffset += 0.5f; - newY = x20; - } - else - { - // don't get the rationale behind this at all... - m_hitbox = hitold; - z_3 = z_1; - x_3 = x_1; - } + if (oldPos.x * oldPos.x + oldPos.z * oldPos.z >= newPos.x * newPos.x + newPos.z * newPos.z) + { + newPos = oldPos; + m_hitbox = oldHit; + } + else + { + float hitYOff = m_hitbox.min.y - int(m_hitbox.min.y); + if (hitYOff > 0.0f) + m_ySlideOffset = m_ySlideOffset + hitYOff + 0.01f; + } + } -label_45: - m_pos.x = (m_hitbox.min.x + m_hitbox.max.x) / 2; - m_pos.z = (m_hitbox.min.z + m_hitbox.max.z) / 2; - m_pos.y = m_hitbox.min.y - m_ySlideOffset + m_heightOffset; + m_pos.x = (m_hitbox.min.x + m_hitbox.max.x) / 2.0f; + m_pos.y = m_hitbox.min.y + m_heightOffset - m_ySlideOffset; + m_pos.z = (m_hitbox.min.z + m_hitbox.max.z) / 2.0f; + m_bHorizontalCollision = cPosX != newPos.x || cPosZ != newPos.z; + m_bVerticalCollision = cPosY != newPos.y; + m_bOnGround = cPosY != newPos.y && cPosY < 0.0f; + m_bCollision = m_bHorizontalCollision || m_bVerticalCollision; + checkFallDamage(newPos.y, m_bOnGround); + if (cPosX != newPos.x) + m_vel.x = 0.0f; + + if (cPosY != newPos.y) + m_vel.y = 0.0f; + + if (cPosZ != newPos.z) + m_vel.z = 0.0f; + + float diffX = m_pos.x - aPosX; + float diffZ = m_pos.z - aPosZ; + if (m_bMakeStepSound && !validSneaking) + { + m_walkDist = float(m_walkDist + Mth::sqrt(diffX * diffX + diffZ * diffZ) * 0.6f); + TilePos tp(m_pos.x, m_pos.y - 0.2f - m_heightOffset, m_pos.z); + TileID i = m_pLevel->getTile(tp); - m_bHorizontalCollision = x_2 != x_3 || z_2 != z_3; - field_7F = m_bHorizontalCollision || newY != pos.y; - m_onGround = pos.y < 0.0f && newY != pos.y; - field_7E = newY != pos.y; + if (m_pLevel->getTile(tp.below()) == Tile::fence->m_ID) + i = Tile::fence->m_ID; - checkFallDamage(newY, m_onGround); + if (m_walkDist > m_nextStep && i > 0) + { + m_nextStep = m_walkDist + 1; - if (x_2 != x_3) m_vel.x = 0.0; - if (newY != pos.y) m_vel.y = 0.0; - if (z_2 != z_3) m_vel.z = 0.0; + const Tile::SoundType* sound = nullptr; + // vol is * 0.15f in Java, is quiet for whatever reason, so bumping to 0.20f + if (m_pLevel->getTile(tp.above()) == Tile::topSnow->m_ID) + { + sound = Tile::topSnow->m_pSound; + } + else if (!Tile::tiles[i]->m_pMaterial->isLiquid()) + { + sound = Tile::tiles[i]->m_pSound; + } - if (m_bMakeStepSound && !b5) // !(m_onGround && isSneaking()) - { - float diffX = (m_pos.x - oldX), diffZ = (m_pos.z - oldZ); - m_walkDist += Mth::sqrt(diffZ * diffZ + diffX * diffX) * 0.6f; + if (sound != nullptr) + m_pLevel->playSound(this, "step." + sound->m_name, sound->volume * 0.20f, sound->pitch); - TilePos tilePos(Mth::floor(m_pos.x), - Mth::floor(m_pos.y - 0.2f - m_heightOffset), - Mth::floor(m_pos.z)); + Tile::tiles[i]->stepOn(m_pLevel, tp, this); + } + } - TileID tileID = m_pLevel->getTile(tilePos); + TilePos minPos(m_hitbox.min + 0.001f); + TilePos maxPos(m_hitbox.max - 0.001f); + TilePos tilePos; - if (tileID > 0 && m_walkDist > float(m_nextStep)) + if (m_pLevel->hasChunksAt(minPos, TilePos(maxPos))) { - ++m_nextStep; - bool bPlaySound = true; - - const Tile::SoundType *sound = Tile::tiles[tileID]->m_pSound; - if (m_pLevel->getTile(tilePos.above()) == Tile::topSnow->m_ID) - sound = Tile::topSnow->m_pSound; - else if (Tile::tiles[tileID]->m_pMaterial->isLiquid()) - bPlaySound = false; - - // vol is * 0.15f in Java, is quiet for whatever reason, so bumping to 0.20f - if (bPlaySound) - m_pLevel->playSound(this, "step." + sound->m_name, sound->volume * 0.20f, sound->pitch); - - Tile::tiles[tileID]->stepOn(m_pLevel, tilePos, this); + for (tilePos.x = minPos.x; tilePos.x <= maxPos.x; tilePos.x++) + for (tilePos.y = minPos.y; tilePos.y <= maxPos.y; tilePos.y++) + for (tilePos.z = minPos.z; tilePos.z <= maxPos.z; tilePos.z++) + { + TileID tileID = m_pLevel->getTile(tilePos); + if (tileID > 0) + Tile::tiles[tileID]->entityInside(m_pLevel, tilePos, this); + } } - } - - // Check whether the entity is inside of any tiles. - - TilePos minPos(m_hitbox.min); - TilePos maxPos(m_hitbox.max); - TilePos tilePos = TilePos(); - - if (m_pLevel->hasChunksAt(TilePos(m_hitbox.min), TilePos(m_hitbox.max))) - { - for (tilePos.x = minPos.x; tilePos.x <= maxPos.x; tilePos.x++) - for (tilePos.y = minPos.y; tilePos.y <= maxPos.y; tilePos.y++) - for (tilePos.z = minPos.z; tilePos.z <= maxPos.z; tilePos.z++) - { - TileID tileID = m_pLevel->getTile(tilePos); - if (tileID > 0) - Tile::tiles[tileID]->entityInside(m_pLevel, tilePos, this); - } - } - - m_ySlideOffset *= 0.4f; - bool bIsInWater = isInWater(); + bool bIsInWater = isInWater(); - if (m_pLevel->containsFireTile(m_hitbox)) - { - burn(1); + if (m_pLevel->containsFireTile(AABB(minPos, maxPos))) + { + burn(1); - if (!bIsInWater) { - if (m_fireTicks == 0) - m_fireTicks = 300; - else + if (!bIsInWater) + { m_fireTicks++; + if (m_fireTicks == 0) + m_fireTicks = 300; + } + } + else if (m_fireTicks <= 0) + { + m_fireTicks = -m_flameTime; + } + + if (bIsInWater && m_fireTicks > 0) + { + m_pLevel->playSound(this, "random.fizz", 0.7f, 1.6f + (sharedRandom.nextFloat() - sharedRandom.nextFloat()) * 0.4f); + m_fireTicks = -m_flameTime; } - } - else if (m_fireTicks <= 0) - { - m_fireTicks = -m_flameTime; - } - if (bIsInWater && m_fireTicks > 0) - { - m_pLevel->playSound(this, "random.fizz", 0.7f, 1.6f + (sharedRandom.nextFloat() - sharedRandom.nextFloat()) * 0.4f); - m_fireTicks = -m_flameTime; } return 1300; @@ -586,7 +411,7 @@ void Entity::reset() m_oRot = m_rot; m_bRemoved = false; m_distanceFallen = 0.0f; - field_D5 = false; + m_bFireImmune = false; m_fireTicks = 0; } @@ -619,7 +444,7 @@ void Entity::baseTick() m_oRot = m_rot; if (isInWater()) { - if (!field_D4 && !field_D6) + if (!m_bWasInWater && !m_bFirstTick) { float dist = Mth::sqrt(m_vel.y * m_vel.y + m_vel.x * m_vel.x * 0.2f + m_vel.z * m_vel.z * 0.2f) * 0.2f; if (dist > 1.0f) @@ -664,7 +489,7 @@ void Entity::baseTick() } } - field_D4 = true; + m_bWasInWater = true; m_fireTicks = 0; m_distanceFallen = 0; @@ -673,7 +498,7 @@ void Entity::baseTick() } else { - field_D4 = false; + m_bWasInWater = false; if (m_pLevel->m_bIsOnline) { @@ -691,7 +516,7 @@ void Entity::baseTick() goto label_15; } - if (field_D5) + if (m_bFireImmune) { m_fireTicks -= 4; if (m_fireTicks < 0) @@ -716,7 +541,7 @@ void Entity::baseTick() if (m_pos.y < -64.0f) outOfWorld(); - field_D6 = false; + m_bFirstTick = false; } bool Entity::intersects(const Vec3& min, const Vec3& max) const @@ -996,13 +821,13 @@ void Entity::markHurt() void Entity::burn(int x) { - if (!field_D5) + if (!m_bFireImmune) hurt(nullptr, 4); } void Entity::lavaHurt() { - if (!field_D5) + if (!m_bFireImmune) { hurt(nullptr, 4); m_fireTicks = 600; @@ -1071,7 +896,7 @@ void Entity::load(const CompoundTag& tag) m_distanceFallen = tag.getFloat("FallDistance"); m_fireTicks = tag.getInt16("Fire"); m_airSupply = tag.getInt16("Air"); - m_onGround = tag.getBoolean("OnGround"); + m_bOnGround = tag.getBoolean("OnGround"); setPos(m_pos); setRot(m_rot); readAdditionalSaveData(tag); @@ -1101,7 +926,7 @@ void Entity::saveWithoutId(CompoundTag& tag) const tag.putFloat("FallDistance", m_distanceFallen); tag.putInt16("Fire", m_fireTicks); tag.putInt16("Air", m_airSupply); - tag.putBoolean("OnGround", m_onGround); + tag.putBoolean("OnGround", m_bOnGround); //tag.putInt32("PortalCooldown", m_portalCooldown); //tag.putBoolean("IsGlobal", m_bIsGlobal); diff --git a/source/world/entity/Entity.hpp b/source/world/entity/Entity.hpp index b668fbc1b..d3330f340 100644 --- a/source/world/entity/Entity.hpp +++ b/source/world/entity/Entity.hpp @@ -92,7 +92,7 @@ class Entity virtual void removed(); virtual void setPos(const Vec3& pos); virtual void remove(); - virtual int move(const Vec3& pos); + virtual int move(const Vec3& posIn); virtual void moveTo(const Vec3& pos, const Vec2& rot = Vec2::ZERO); virtual void absMoveTo(const Vec3& pos, const Vec2& rot = Vec2::ZERO); virtual void moveRelative(const Vec3& pos); @@ -200,12 +200,13 @@ class Entity Vec2 m_rot; Vec2 m_oRot; // "RotO" in Java or "xRotO" "yRotO" AABB m_hitbox; - bool m_onGround; + bool m_bOnGround; bool m_bHorizontalCollision; - bool field_7E; - bool field_7F; + bool m_bCollision; + bool m_bVerticalCollision; bool m_bHurt; - uint8_t field_81; + bool m_bIsInWeb; + uint8_t m_bSlide; bool m_bRemoved; float m_heightOffset; float m_bbWidth; @@ -214,7 +215,7 @@ class Entity float m_walkDist; Vec3 m_posPrev; float m_ySlideOffset; - float field_A8; + float m_footSize; bool m_bNoPhysics; float field_B0; int m_tickCount; @@ -225,9 +226,9 @@ class Entity int field_C8; // @NOTE: Render type? (eEntityRenderType) float m_distanceFallen; // Supposed to be protected int16_t m_airSupply; - uint8_t field_D4; - bool field_D5; - bool field_D6; + bool m_bWasInWater; + bool m_bFireImmune; + bool m_bFirstTick; int m_nextStep; protected: diff --git a/source/world/entity/FallingTile.cpp b/source/world/entity/FallingTile.cpp index f72522b8d..632a9bc33 100644 --- a/source/world/entity/FallingTile.cpp +++ b/source/world/entity/FallingTile.cpp @@ -63,7 +63,7 @@ void FallingTile::tick() if (m_pLevel->getTile(tilePos) == m_id) m_pLevel->setTile(tilePos, TILE_AIR); - if (!m_onGround) + if (!m_bOnGround) { if (field_E0 > 100 && !m_pLevel->m_bIsOnline) remove(); diff --git a/source/world/entity/ItemEntity.cpp b/source/world/entity/ItemEntity.cpp index 61987aad2..ae16705dc 100644 --- a/source/world/entity/ItemEntity.cpp +++ b/source/world/entity/ItemEntity.cpp @@ -105,19 +105,19 @@ void ItemEntity::tick() float dragFactor = 0.98f; - if (m_onGround) + if (m_bOnGround) { dragFactor = 0.588f; TileID tile = m_pLevel->getTile(TilePos(Mth::floor(m_pos.x), Mth::floor(m_hitbox.min.y) - 1, Mth::floor(m_pos.z))); if (tile > 0) - dragFactor = Tile::tiles[tile]->field_30 * 0.98f; + dragFactor = Tile::tiles[tile]->m_friction * 0.98f; } m_vel.x *= dragFactor; m_vel.z *= dragFactor; m_vel.y *= 0.98f; - if (m_onGround) + if (m_bOnGround) m_vel.y *= -0.5f; m_tickCount++; diff --git a/source/world/entity/LocalPlayer.cpp b/source/world/entity/LocalPlayer.cpp index 86ad452aa..834b234ef 100644 --- a/source/world/entity/LocalPlayer.cpp +++ b/source/world/entity/LocalPlayer.cpp @@ -175,7 +175,7 @@ int LocalPlayer::move(const Vec3& pos) // This looks very funny. result = pLP->Entity::move(field_BF0); - pLP->m_onGround = true; + pLP->m_bOnGround = true; m_walkDist = m_walkDist_old; } diff --git a/source/world/entity/Mob.cpp b/source/world/entity/Mob.cpp index eb24286a1..635e53bcc 100644 --- a/source/world/entity/Mob.cpp +++ b/source/world/entity/Mob.cpp @@ -66,7 +66,7 @@ Mob::Mob(Level* pLevel) : Entity(pLevel) setPos(m_pos); field_E0 = Mth::random() * 12398.0f; m_rot.x = float(Mth::random() * M_PI); - field_A8 = 0.5f; + m_footSize = 0.5f; } Mob::~Mob() @@ -144,7 +144,7 @@ void Mob::tick() else x4 = x1 = m_rot.x; - if (!m_onGround) + if (!m_bOnGround) x3 = 0.0f; field_B50 += (x3 - field_B50) * 0.3f; @@ -466,12 +466,16 @@ void Mob::knockback(Entity* pEnt, int a, float x, float z) bool Mob::onLadder() const { +#ifdef ENH_NEW_LADDER_BEHAVIOR + return m_pLevel->getTile(TilePos(m_pos.x, m_hitbox.min.y, m_pos.z)) == Tile::ladder->m_ID; +#else TilePos tilePos = TilePos(m_pos.x, m_hitbox.min.y, m_pos.z); //@INFO: Pre Beta 1.5 stair behaviour return - m_pLevel->getTile(tilePos) == Tile::ladder->m_ID || + m_pLevel->getTile(tilePos) == Tile::ladder->m_ID || m_pLevel->getTile(tilePos.above()) == Tile::ladder->m_ID; +#endif } void Mob::spawnAnim() @@ -522,48 +526,35 @@ HitResult Mob::pick(float f1, float f2) void Mob::travel(const Vec2& pos) { - float x1, x2, dragFactor, oldYPos = m_pos.y; - if (isInWater()) - { - moveRelative(Vec3(pos.x, 0.02f, pos.y)); - move(m_vel); - x1 = 0.8f; - goto label_3; - } - if (isInLava()) + float x2, dragFactor; + float oldYPos = m_pos.y; + if (isInWater() || isInLava()) { moveRelative(Vec3(pos.x, 0.02f, pos.y)); move(m_vel); - x1 = 0.5f; - label_3: - + const float x1 = (isInWater() ? 0.8f : 0.5f); m_vel.y = m_vel.y * x1 - 0.02f; m_vel.x *= x1; m_vel.z *= x1; - if (m_bHorizontalCollision) - { - if (isFree(Vec3(m_vel.x, m_vel.y + 0.6f - m_pos.y + oldYPos, m_vel.z))) - m_vel.y = 0.3f; - } + if (m_bHorizontalCollision && isFree(Vec3(m_vel.x, m_vel.y + 0.6f - m_pos.y + oldYPos, m_vel.z))) + m_vel.y = 0.3f; return; } - if (!m_onGround) + if (!m_bOnGround) { x2 = 0.02f; } else { float _x1; - TilePos tilePos(m_pos.x, m_hitbox.min.y, m_pos.z);; - tilePos.y -= 1; - TileID tile = m_pLevel->getTile(tilePos); + TileID tile = m_pLevel->getTile(TilePos(m_pos.x, m_hitbox.min.y - 1, m_pos.z)); if (tile <= 0) _x1 = 0.546f; else - _x1 = Tile::tiles[tile]->field_30 * 0.91f; + _x1 = Tile::tiles[tile]->m_friction * 0.91f; assert(_x1 != 0.0f); @@ -572,24 +563,36 @@ void Mob::travel(const Vec2& pos) moveRelative(Vec3(pos.x, x2, pos.y)); - if (!m_onGround) + if (!m_bOnGround) { dragFactor = 0.91f; } else { - //@HUH: repeated code. Could be an inlined function? - TilePos tilePos = TilePos(m_pos); - tilePos.y -= 1; - TileID tile = m_pLevel->getTile(tilePos); + + TileID tile = m_pLevel->getTile(TilePos(m_pos.x, m_hitbox.min.y - 1, m_pos.z)); if (tile <= 0) dragFactor = 0.546f; else - dragFactor = Tile::tiles[tile]->field_30 * 0.91f; + dragFactor = Tile::tiles[tile]->m_friction * 0.91f; } if (onLadder()) { +#ifdef ENH_NEW_LADDER_BEHAVIOR + if (m_vel.x < -0.15f) + m_vel.x = -0.15f; + + if (m_vel.x > 0.15f) + m_vel.x = 0.15f; + + if (m_vel.z < -0.15f) + m_vel.z = -0.15f; + + if (m_vel.z > 0.15f) + m_vel.z = 0.15f; +#endif + m_distanceFallen = 0.0f; if (m_vel.y < -0.15f) @@ -664,7 +667,7 @@ void Mob::aiStep() { if (bIsInWater || bIsInLava) m_vel.y += 0.04f; - else if (m_onGround) + else if (m_bOnGround) jumpFromGround(); } diff --git a/source/world/entity/Player.cpp b/source/world/entity/Player.cpp index ca50c7a58..f8453d04a 100644 --- a/source/world/entity/Player.cpp +++ b/source/world/entity/Player.cpp @@ -156,7 +156,7 @@ void Player::aiStep() if (velLen > 0.1f) velLen = 0.1f; - if (!m_onGround) + if (!m_bOnGround) { if (m_health > 0) { @@ -195,11 +195,14 @@ void Player::aiStep() ItemInstance* Player::getCarriedItem() { - ItemInstance* item = m_pInventory->getItem(m_pInventory->m_selectedHotbarSlot); + // This only gets the first row slot + /*ItemInstance* item = m_pInventory->getItem(m_pInventory->m_selectedHotbarSlot); if (ItemInstance::isNull(item)) return nullptr; - return item; + return item;*/ + + return m_pInventory->getSelected(); } void Player::updateAi() diff --git a/source/world/entity/PrimedTnt.cpp b/source/world/entity/PrimedTnt.cpp index 092bd26dd..084c625d0 100644 --- a/source/world/entity/PrimedTnt.cpp +++ b/source/world/entity/PrimedTnt.cpp @@ -60,7 +60,7 @@ void PrimedTnt::tick() move(m_vel); m_vel *= 0.98f; - if (m_onGround) + if (m_bOnGround) { m_vel.x *= 0.7f; m_vel.z *= 0.7f; diff --git a/source/world/entity/Sheep.cpp b/source/world/entity/Sheep.cpp index 41528488f..5906c9d75 100644 --- a/source/world/entity/Sheep.cpp +++ b/source/world/entity/Sheep.cpp @@ -49,7 +49,7 @@ bool Sheep::hurt(Entity* pEnt, int damage) for (int i = 0; i < var3; i++) { - ItemEntity* item = spawnAtLocation(new ItemInstance(TILE_CLOTH_00, 1, getColor()), 1.0f); + ItemEntity* item = spawnAtLocation(new ItemInstance(TILE_CLOTH, 1, getColor()), 1.0f); item->m_vel.y += m_random.nextFloat() * 0.05f; item->m_vel.x += (m_random.nextFloat() - m_random.nextFloat()) * 0.1f; item->m_vel.z += (m_random.nextFloat() - m_random.nextFloat()) * 0.1f; diff --git a/source/world/entity/Spider.cpp b/source/world/entity/Spider.cpp index eac95c4e3..47c39e095 100644 --- a/source/world/entity/Spider.cpp +++ b/source/world/entity/Spider.cpp @@ -30,7 +30,7 @@ void Spider::checkHurtTarget(Entity* ent, float var2) { if (var2 > 2.0f && var2 < 6.0f && m_random.nextInt(10) == 0) { - if (m_onGround) + if (m_bOnGround) { float var4 = ent->m_pos.x - m_pos.x; float var6 = ent->m_pos.z - m_pos.z; diff --git a/source/world/entity/TripodCamera.cpp b/source/world/entity/TripodCamera.cpp index eb5fcc171..db487bd37 100644 --- a/source/world/entity/TripodCamera.cpp +++ b/source/world/entity/TripodCamera.cpp @@ -51,7 +51,7 @@ void TripodCamera::tick() move(m_vel); m_vel *= 0.98f; - if (m_onGround) + if (m_bOnGround) { m_vel.x *= 0.7f; m_vel.z *= 0.7f; diff --git a/source/world/item/AuxTileItem.cpp b/source/world/item/AuxTileItem.cpp new file mode 100644 index 000000000..61f1ce511 --- /dev/null +++ b/source/world/item/AuxTileItem.cpp @@ -0,0 +1,18 @@ +#include "AuxTileItem.hpp" +#include "world/tile/Tile.hpp" + +AuxTileItem::AuxTileItem(int id) : TileItem(id) +{ + m_maxDamage = 0; + m_bStackedByData = true; +} + +int AuxTileItem::getIcon(const ItemInstance* item) const +{ + return Tile::tiles[m_itemID]->getTexture(Facing::NORTH, item->getAuxValue()); +} + +int AuxTileItem::getLevelDataForAuxValue(int x) +{ + return x; +} diff --git a/source/world/item/AuxTileItem.hpp b/source/world/item/AuxTileItem.hpp new file mode 100644 index 000000000..e05f74e23 --- /dev/null +++ b/source/world/item/AuxTileItem.hpp @@ -0,0 +1,11 @@ +#pragma once + +#include "TileItem.hpp" + +class AuxTileItem : public TileItem +{ +public: + AuxTileItem(int id); + int getIcon(const ItemInstance*) const override; + int getLevelDataForAuxValue(int x) override; +}; diff --git a/source/world/item/ClothItem.cpp b/source/world/item/ClothItem.cpp new file mode 100644 index 000000000..522d29281 --- /dev/null +++ b/source/world/item/ClothItem.cpp @@ -0,0 +1,27 @@ +#include "ClothItem.hpp" +#include "world/level/Level.hpp" +#include "world/entity/Player.hpp" +#include "world/tile/Tile.hpp" +#include "world/tile/ClothTile.hpp" +//#include "DyeColor.hpp" + +ClothItem::ClothItem(int id) : TileItem(id) +{ + m_maxDamage = 0; + m_bStackedByData = true; +} + +std::string ClothItem::getDescriptionId(ItemInstance* item) +{ + return TileItem::getDescriptionId(item) + "."/* + DyeColor::IDS[ClothTile::getColorFromData(item->getAuxValue())];*/; +} + +int ClothItem::getIcon(const ItemInstance* item) const +{ + return Tile::cloth->getTexture(Facing::NORTH, ClothTile::getColorFromData(item->getAuxValue())); +} + +int ClothItem::getLevelDataForAuxValue(int x) +{ + return x; +} diff --git a/source/world/item/ClothItem.hpp b/source/world/item/ClothItem.hpp new file mode 100644 index 000000000..8c91d9b09 --- /dev/null +++ b/source/world/item/ClothItem.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include "TileItem.hpp" + +class ClothItem : public TileItem +{ +public: + ClothItem(int id); + std::string getDescriptionId(ItemInstance* item) override; + int getIcon(const ItemInstance*) const override; + int getLevelDataForAuxValue(int x) override; +}; diff --git a/source/world/item/Inventory.cpp b/source/world/item/Inventory.cpp index be4f9ba9a..e152e4cad 100644 --- a/source/world/item/Inventory.cpp +++ b/source/world/item/Inventory.cpp @@ -24,33 +24,36 @@ void Inventory::prepareCreativeInventory() { clear(); + // When we've got a proper creative inventory, use this method for aux tiles/items + //for (int i = 0; i < 16; i++) // <-- This is an example for all wool colors in order + // Original list of items. addCreativeItem(Tile::rock->m_ID); addCreativeItem(Tile::stoneBrick->m_ID); addCreativeItem(Tile::sandStone->m_ID); addCreativeItem(Tile::wood->m_ID); - addCreativeItem(Tile::treeTrunk->m_ID); + addCreativeItem(Tile::treeTrunk->m_ID, 0); addCreativeItem(Tile::goldBlock->m_ID); addCreativeItem(Tile::ironBlock->m_ID); addCreativeItem(Tile::emeraldBlock->m_ID); addCreativeItem(Tile::redBrick->m_ID); - addCreativeItem(Tile::leaves->m_ID); - addCreativeItem(Tile::cloth_10->m_ID); - addCreativeItem(Tile::cloth_20->m_ID); - addCreativeItem(Tile::cloth_30->m_ID); - addCreativeItem(Tile::cloth_40->m_ID); - addCreativeItem(Tile::cloth_50->m_ID); - addCreativeItem(Tile::cloth_60->m_ID); - addCreativeItem(Tile::cloth_70->m_ID); + addCreativeItem(Tile::leaves->m_ID, 0); + addCreativeItem(Tile::cloth->m_ID, 14); + addCreativeItem(Tile::cloth->m_ID, 13); + addCreativeItem(Tile::cloth->m_ID, 12); + addCreativeItem(Tile::cloth->m_ID, 11); + addCreativeItem(Tile::cloth->m_ID, 10); + addCreativeItem(Tile::cloth->m_ID, 9); + addCreativeItem(Tile::cloth->m_ID, 8); addCreativeItem(Tile::glass->m_ID); - addCreativeItem(Tile::cloth_01->m_ID); - addCreativeItem(Tile::cloth_11->m_ID); - addCreativeItem(Tile::cloth_21->m_ID); - addCreativeItem(Tile::cloth_31->m_ID); - addCreativeItem(Tile::cloth_41->m_ID); + addCreativeItem(Tile::cloth->m_ID, 7); + addCreativeItem(Tile::cloth->m_ID, 6); + addCreativeItem(Tile::cloth->m_ID, 5); + addCreativeItem(Tile::cloth->m_ID, 4); + addCreativeItem(Tile::cloth->m_ID, 3); addCreativeItem(Tile::stairs_wood->m_ID); addCreativeItem(Tile::stairs_stone->m_ID); - addCreativeItem(Tile::stoneSlabHalf->m_ID); + addCreativeItem(Tile::stoneSlabHalf->m_ID, 0); addCreativeItem(Tile::sand->m_ID); addCreativeItem(Tile::ladder->m_ID); addCreativeItem(Tile::torch->m_ID); @@ -66,7 +69,7 @@ void Inventory::prepareCreativeInventory() addCreativeItem(Tile::grass->m_ID); addCreativeItem(Tile::tnt->m_ID); addCreativeItem(Tile::gravel->m_ID); - addCreativeItem(Tile::cloth->m_ID); + addCreativeItem(Tile::cloth->m_ID, 15); addCreativeItem(Tile::mossStone->m_ID); addCreativeItem(Tile::bookshelf->m_ID); addCreativeItem(Tile::lapisBlock->m_ID); @@ -87,6 +90,25 @@ void Inventory::prepareCreativeInventory() addCreativeItem(Item::door_iron->m_itemID); addCreativeItem(Item::rocket->m_itemID); + // more stuff + addCreativeItem(Tile::cloth->m_ID, 0); + addCreativeItem(Tile::cloth->m_ID, 1); + addCreativeItem(Tile::cloth->m_ID, 2); + addCreativeItem(Tile::stoneSlabHalf->m_ID, 1); + addCreativeItem(Tile::stoneSlabHalf->m_ID, 2); + addCreativeItem(Tile::stoneSlabHalf->m_ID, 3); + addCreativeItem(Tile::treeTrunk->m_ID, 1); + addCreativeItem(Tile::treeTrunk->m_ID, 2); + addCreativeItem(Tile::cactus->m_ID); + addCreativeItem(Tile::deadBush->m_ID); + addCreativeItem(Tile::pumpkin->m_ID); + addCreativeItem(Tile::pumpkinLantern->m_ID); + addCreativeItem(Tile::netherrack->m_ID); + addCreativeItem(Tile::soulSand->m_ID); + addCreativeItem(Tile::glowstone->m_ID); + addCreativeItem(Tile::web->m_ID); + addCreativeItem(Tile::fence->m_ID); + for (int i = 0; i < C_MAX_HOTBAR_ITEMS; i++) m_hotbar[i] = i; } @@ -130,12 +152,20 @@ void Inventory::addCreativeItem(int itemID, int auxValue) m_items.push_back(new ItemInstance(itemID, 1, auxValue)); } +void Inventory::empty() +{ + for (int i = 0; i < m_items.size(); i++) + { + delete m_items[i]; + m_items[i] = nullptr; + } +} + void Inventory::clear() { - for (std::vector::iterator it = m_items.begin(); it != m_items.end(); it++) + for (int i = 0; i < m_items.size(); i++) { - ItemInstance* item = *it; - delete item; + delete m_items[i]; } m_items.clear(); } @@ -347,6 +377,21 @@ void Inventory::selectItemById(int itemID, int maxHotBarSlot) LOG_W("selectItemById: %d doesn't exist", itemID); } +void Inventory::selectItemByIdAux(int itemID, int auxValue, int maxHotBarSlot) +{ + for (int i = 0; i < getNumItems(); i++) + { + ItemInstance* item = m_items[i]; + if (!item || item->m_itemID != itemID || item->getAuxValue() != auxValue) + continue; + + selectItem(i, maxHotBarSlot); + return; + } + + LOG_W("selectItemByIdAux: %d:%d doesn't exist", itemID, auxValue); +} + int Inventory::getAttackDamage(Entity* pEnt) { ItemInstance* pInst = getSelected(); @@ -432,4 +477,4 @@ void Inventory::load(const ListTag& tag) GameType Inventory::_getGameMode() const { return m_pPlayer->getPlayerGameType(); -} \ No newline at end of file +} diff --git a/source/world/item/Inventory.hpp b/source/world/item/Inventory.hpp index e5e923100..a2cb5483b 100644 --- a/source/world/item/Inventory.hpp +++ b/source/world/item/Inventory.hpp @@ -27,6 +27,7 @@ class Inventory void addCreativeItem(int itemID, int auxValue = 0); void addTestItem(int itemID, int amount, int auxValue = 0); + void empty(); void clear(); bool addItem(ItemInstance& instance); void tick(); @@ -41,6 +42,7 @@ class Inventory void setQuickSlotIndexByItemId(int slotNo, int itemID); void selectItemById(int itemID, int maxHotBarSlot); + void selectItemByIdAux(int itemID, int auxValue, int maxHotBarSlot); int getAttackDamage(Entity*); diff --git a/source/world/item/Item.cpp b/source/world/item/Item.cpp index a69571235..be34b081a 100644 --- a/source/world/item/Item.cpp +++ b/source/world/item/Item.cpp @@ -97,14 +97,212 @@ void Item::initItems() g_bInittedItems = true; + // @TODO: Add missing items Item::bow = NEW_ITEM(ITEM_BOW) ->setIcon(5, 1) ->setDescriptionId("bow"); + Item::sword_wood = NEW_ITEM(ITEM_SWORD_WOOD) + ->setIcon(0, 4) + ->setDescriptionId("swordWood") + ->handEquipped(); + + Item::pickAxe_wood = NEW_ITEM(ITEM_PICKAXE_WOOD) + ->setIcon(0, 6) + ->setDescriptionId("pickaxeWood") + ->handEquipped(); + + Item::hatchet_wood = NEW_ITEM(ITEM_HATCHET_WOOD) + ->setIcon(0, 7) + ->setDescriptionId("hatchetWood") + ->handEquipped(); + + Item::shovel_wood = NEW_ITEM(ITEM_SHOVEL_WOOD) + ->setIcon(0, 5) + ->setDescriptionId("shovelWood") + ->handEquipped(); + + Item::hoe_wood = NEW_ITEM(ITEM_HOE_WOOD) + ->setIcon(0, 8) + ->setDescriptionId("hoeWood") + ->handEquipped(); + + Item::sword_stone = NEW_ITEM(ITEM_SWORD_STONE) + ->setIcon(1, 4) + ->setDescriptionId("swordStone") + ->handEquipped(); + + Item::pickAxe_stone = NEW_ITEM(ITEM_PICKAXE_STONE) + ->setIcon(1, 6) + ->setDescriptionId("pickaxeStone") + ->handEquipped(); + + Item::hatchet_stone = NEW_ITEM(ITEM_HATCHET_STONE) + ->setIcon(1, 7) + ->setDescriptionId("hatchetStone") + ->handEquipped(); + + Item::shovel_stone = NEW_ITEM(ITEM_SHOVEL_STONE) + ->setIcon(1, 5) + ->setDescriptionId("shovelStone") + ->handEquipped(); + + Item::hoe_stone = NEW_ITEM(ITEM_HOE_STONE) + ->setIcon(1, 8) + ->setDescriptionId("hoeStone") + ->handEquipped(); + + Item::sword_iron = NEW_ITEM(ITEM_SWORD_IRON) + ->setIcon(2, 4) + ->setDescriptionId("swordIron") + ->handEquipped(); + + Item::pickAxe_iron = NEW_ITEM(ITEM_PICKAXE_IRON) + ->setIcon(2, 6) + ->setDescriptionId("pickaxeIron") + ->handEquipped(); + + Item::hatchet_iron = NEW_ITEM(ITEM_HATCHET_IRON) + ->setIcon(2, 7) + ->setDescriptionId("hatchetIron") + ->handEquipped(); + + Item::shovel_iron= NEW_ITEM(ITEM_SHOVEL_IRON) + ->setIcon(2, 5) + ->setDescriptionId("shovelIron") + ->handEquipped(); + + Item::hoe_iron= NEW_ITEM(ITEM_HOE_IRON) + ->setIcon(2, 8) + ->setDescriptionId("hoeIron") + ->handEquipped(); + + Item::sword_gold = NEW_ITEM(ITEM_SWORD_GOLD) + ->setIcon(4, 4) + ->setDescriptionId("swordGold") + ->handEquipped(); + + Item::pickAxe_gold = NEW_ITEM(ITEM_PICKAXE_GOLD) + ->setIcon(4, 6) + ->setDescriptionId("pickaxeGold") + ->handEquipped(); + + Item::hatchet_gold = NEW_ITEM(ITEM_HATCHET_GOLD) + ->setIcon(4, 7) + ->setDescriptionId("hatchetGold") + ->handEquipped(); + + Item::shovel_gold = NEW_ITEM(ITEM_SHOVEL_GOLD) + ->setIcon(4, 5) + ->setDescriptionId("shovelGold") + ->handEquipped(); + + Item::hoe_gold = NEW_ITEM(ITEM_HOE_GOLD) + ->setIcon(4, 8) + ->setDescriptionId("hoeGold") + ->handEquipped(); + + Item::sword_emerald = NEW_ITEM(ITEM_SWORD_EMERALD) + ->setIcon(3, 4) + ->setDescriptionId("swordEmerald") + ->handEquipped(); + + Item::pickAxe_emerald = NEW_ITEM(ITEM_PICKAXE_EMERALD) + ->setIcon(3, 6) + ->setDescriptionId("pickaxeEmerald") + ->handEquipped(); + + Item::hatchet_emerald = NEW_ITEM(ITEM_HATCHET_EMERALD) + ->setIcon(3, 7) + ->setDescriptionId("hatchetEmerald") + ->handEquipped(); + + Item::shovel_emerald = NEW_ITEM(ITEM_SHOVEL_EMERALD) + ->setIcon(3, 5) + ->setDescriptionId("shovelEmerald") + ->handEquipped(); + + Item::hoe_emerald = NEW_ITEM(ITEM_HOE_EMERALD) + ->setIcon(3, 8) + ->setDescriptionId("hoeEmerald") + ->handEquipped(); + + Item::helmet_cloth = NEW_ITEM(ITEM_HELMET_CLOTH) + ->setIcon(0, 0) + ->setDescriptionId("helmetCloth"); + + Item::chestplate_cloth = NEW_ITEM(ITEM_CHESTPLATE_CLOTH) + ->setIcon(0, 1) + ->setDescriptionId("chestplateCloth"); + + Item::leggings_cloth = NEW_ITEM(ITEM_LEGGINGS_CLOTH) + ->setIcon(0, 2) + ->setDescriptionId("leggingsCloth"); + + Item::boots_cloth = NEW_ITEM(ITEM_BOOTS_CLOTH) + ->setIcon(0, 3) + ->setDescriptionId("bootsCloth"); + + Item::helmet_iron = NEW_ITEM(ITEM_HELMET_IRON) + ->setIcon(2, 0) + ->setDescriptionId("helmetIron"); + + Item::chestplate_iron = NEW_ITEM(ITEM_CHESTPLATE_IRON) + ->setIcon(2, 1) + ->setDescriptionId("chestplateIron"); + + Item::leggings_iron = NEW_ITEM(ITEM_LEGGINGS_IRON) + ->setIcon(2, 2) + ->setDescriptionId("leggingsIron"); + + Item::boots_iron = NEW_ITEM(ITEM_BOOTS_IRON) + ->setIcon(2, 3) + ->setDescriptionId("bootsIron"); + + Item::helmet_gold = NEW_ITEM(ITEM_HELMET_GOLD) + ->setIcon(4, 0) + ->setDescriptionId("helmetGold"); + + Item::chestplate_gold = NEW_ITEM(ITEM_CHESTPLATE_GOLD) + ->setIcon(4, 1) + ->setDescriptionId("chestplateGold"); + + Item::leggings_gold = NEW_ITEM(ITEM_LEGGINGS_GOLD) + ->setIcon(4, 2) + ->setDescriptionId("leggingsGold"); + + Item::boots_gold = NEW_ITEM(ITEM_BOOTS_GOLD) + ->setIcon(4, 3) + ->setDescriptionId("bootsGold"); + + Item::helmet_diamond = NEW_ITEM(ITEM_HELMET_EMERALD) + ->setIcon(3, 0) + ->setDescriptionId("helmetEmerald"); + + Item::chestplate_diamond = NEW_ITEM(ITEM_CHESTPLATE_EMERALD) + ->setIcon(3, 1) + ->setDescriptionId("chestplateEmerald"); + + Item::leggings_diamond = NEW_ITEM(ITEM_LEGGINGS_EMERALD) + ->setIcon(3, 2) + ->setDescriptionId("leggingsEmerald"); + + Item::boots_diamond = NEW_ITEM(ITEM_BOOTS_EMERALD) + ->setIcon(3, 3) + ->setDescriptionId("bootsEmerald"); + + Item::flintAndSteel = NEW_ITEM(ITEM_FLINT_AND_STEEL) + ->setIcon(5, 0) + ->setDescriptionId("flintAndSteel"); + Item::arrow = NEW_ITEM(ITEM_ARROW) ->setIcon(5, 2) ->setDescriptionId("arrow"); + Item::coal = NEW_ITEM(ITEM_COAL) + ->setIcon(7, 0) + ->setDescriptionId("coal"); + Item::emerald = NEW_ITEM(ITEM_EMERALD) ->setIcon(7, 3) ->setDescriptionId("emerald"); @@ -126,6 +324,10 @@ void Item::initItems() ->setIcon(7, 4) ->setDescriptionId("bowl"); + Item::mushroomStew = NEW_ITEM(ITEM_STEW_MUSHROOM) + ->setIcon(8, 4) + ->setDescriptionId("mushroomStew"); + Item::string = NEW_ITEM(ITEM_STRING) ->setIcon(8, 0) ->setDescriptionId("string"); @@ -138,10 +340,22 @@ void Item::initItems() ->setIcon(8, 2) ->setDescriptionId("sulphur"); + Item::seeds = NEW_ITEM(ITEM_SEEDS) + ->setIcon(9, 0) + ->setDescriptionId("seeds"); + + Item::reeds = NEW_X_ITEM(TilePlanterItem, ITEM_REEDS, TILE_REEDS) + ->setIcon(11, 1) + ->setDescriptionId("reeds"); + Item::wheat = NEW_ITEM(ITEM_WHEAT) ->setIcon(9, 1) ->setDescriptionId("wheat"); + Item::bread = NEW_ITEM(ITEM_BREAD) + ->setIcon(9, 2) + ->setDescriptionId("bread"); + Item::flint = NEW_ITEM(ITEM_FLINT) ->setIcon(6, 0) ->setDescriptionId("flint"); @@ -154,18 +368,73 @@ void Item::initItems() ->setIcon(8, 5) ->setDescriptionId("porkchopCooked"); + Item::apple = NEW_ITEM(ITEM_APPLE) + ->setIcon(10, 0) + ->setDescriptionId("appleGold"); + + Item::apple_gold = NEW_ITEM(ITEM_APPLE_GOLD) + ->setIcon(11, 0) + ->setDescriptionId("appleGold"); + Item::door_wood = NEW_X_ITEM(DoorItem, ITEM_DOOR_WOOD, Material::wood) ->setIcon(11, 2) ->setDescriptionId("doorWood"); + Item::bucket_empty = NEW_ITEM(ITEM_BUCKET) + ->setIcon(10, 4) + ->setDescriptionId("bucket"); + + Item::bucket_water = NEW_ITEM(ITEM_BUCKET_WATER) + ->setIcon(11, 4) + ->setDescriptionId("bucketWater"); + //->setCraftingRemainingItem(emptyBucket); + + Item::bucket_lava = NEW_ITEM(ITEM_BUCKET_LAVA) + ->setIcon(12, 4) + ->setDescriptionId("bucketLava"); + //>setCraftingRemainingItem(emptyBucket); + + Item::minecart = NEW_ITEM(ITEM_MINECART) + ->setIcon(7, 8) + ->setDescriptionId("minecart"); + + Item::minecart_chest = NEW_ITEM(ITEM_MINECART_CHEST) + ->setIcon(7, 9) + ->setDescriptionId("minecartChest"); + + Item::minecart_furnace = NEW_ITEM(ITEM_MINECART_FURNACE) + ->setIcon(7, 10) + ->setDescriptionId("minecartFurnace"); + + Item::boat = NEW_ITEM(ITEM_BOAT) + ->setIcon(8, 8) + ->setDescriptionId("boat"); + Item::door_iron = NEW_X_ITEM(DoorItem, ITEM_DOOR_IRON, Material::metal) ->setIcon(12, 2) ->setDescriptionId("doorIron"); + + Item::redStone = NEW_ITEM(ITEM_REDSTONE) + ->setIcon(8, 3) + ->setDescriptionId("redstone"); + + Item::snowBall = NEW_ITEM(ITEM_SNOWBALL) + ->setIcon(14, 0) + ->setDescriptionId("snowball"); + + Item::saddle = NEW_ITEM(ITEM_SADDLE) + ->setIcon(8, 6) + ->setDescriptionId("saddle"); Item::leather = NEW_ITEM(ITEM_LEATHER) ->setIcon(7, 6) ->setDescriptionId("leather"); + Item::milk = NEW_ITEM(ITEM_BUCKET_MILK) + ->setIcon(13, 4) + ->setDescriptionId("milk"); + //->setCraftingRemainingItem(emptyBucket); + Item::brick = NEW_ITEM(ITEM_BRICK) ->setIcon(6, 1) ->setDescriptionId("brick"); @@ -174,10 +443,6 @@ void Item::initItems() ->setIcon(9, 3) ->setDescriptionId("clay"); - Item::reeds = NEW_X_ITEM(TilePlanterItem, ITEM_REEDS, TILE_REEDS) - ->setIcon(11, 1) - ->setDescriptionId("reeds"); - Item::paper = NEW_ITEM(ITEM_PAPER) ->setIcon(10, 3) ->setDescriptionId("paper"); @@ -198,10 +463,30 @@ void Item::initItems() ->setIcon(6, 3) ->setDescriptionId("compass"); + Item::fishingRod = NEW_ITEM(ITEM_FISHING_ROD) + ->setIcon(5, 4) + ->setDescriptionId("fishingRod"); + + Item::dye_powder = NEW_ITEM(ITEM_DYE_POWDER) + ->setIcon(14, 4) + ->setDescriptionId("dyePowder"); + Item::clock = NEW_ITEM(ITEM_CLOCK) ->setIcon(6, 4) ->setDescriptionId("clock"); + Item::yellowDust = NEW_ITEM(ITEM_YELLOW_DUST) + ->setIcon(9, 4) + ->setDescriptionId("yellowDust"); + + Item::fish_raw = NEW_ITEM(ITEM_FISH_RAW) + ->setIcon(9, 5) + ->setDescriptionId("fishRaw"); + + Item::fish_cooked = NEW_ITEM(ITEM_FISH_COOKED) + ->setIcon(10, 5) + ->setDescriptionId("fishCooked"); + Item::bone = NEW_ITEM(ITEM_BONE) ->setIcon(12, 1) ->setDescriptionId("bone") @@ -212,6 +497,40 @@ void Item::initItems() ->setDescriptionId("sugar") ->handEquipped(); // weirdly also in JE + Item::cake = NEW_ITEM(ITEM_CAKE) + ->setIcon(13, 1) + ->setMaxStackSize(1) + ->setDescriptionId("cake"); + + Item::bed = NEW_ITEM(ITEM_BED) + ->setIcon(13, 2) + ->setDescriptionId("bed"); + + Item::diode = NEW_ITEM(ITEM_DIODE) + ->setIcon(6, 5) + ->setDescriptionId("diode"); + + Item::cookie = NEW_ITEM(ITEM_COOKIE) + ->setMaxStackSize(8) + ->setIcon(12, 5) + ->setDescriptionId("cookie"); + + Item::sign = NEW_ITEM(ITEM_SIGN) + ->setIcon(10, 2) + ->setDescriptionId("sign"); + + Item::painting = NEW_ITEM(ITEM_PAINTING) + ->setIcon(10, 1) + ->setDescriptionId("painting"); + + Item::record_01 = NEW_ITEM(ITEM_RECORD_01) + ->setIcon(0, 15) + ->setDescriptionId("record"); + + Item::record_02 = NEW_ITEM(ITEM_RECORD_02) + ->setIcon(1, 15) + ->setDescriptionId("record"); + Item::camera = NEW_X_ITEMN(CameraItem, ITEM_CAMERA) ->setIcon(2, 15) ->setDescriptionId("camera"); @@ -219,6 +538,10 @@ void Item::initItems() Item::rocket = NEW_X_ITEMN(RocketItem, ITEM_ROCKET) ->setIcon(14, 2) ->setDescriptionId("rocket"); + + Item::quiver = NEW_ITEM(ITEM_QUIVER) + ->setIcon(6, 2) + ->setDescriptionId("quiver"); } int Item::getIcon(const ItemInstance* pInstance) const @@ -439,10 +762,12 @@ Item *Item::cake, *Item::bed, *Item::diode, + *Item::cookie, *Item::record_01, *Item::record_02, *Item::camera, - *Item::rocket; + *Item::rocket, + *Item::quiver; Item::Tier Item::Tier::WOOD (0, 59, 2.0f, 0), diff --git a/source/world/item/Item.hpp b/source/world/item/Item.hpp index a8871c8d3..d2a2af455 100644 --- a/source/world/item/Item.hpp +++ b/source/world/item/Item.hpp @@ -201,8 +201,10 @@ class Item *cake, *bed, *diode, + *cookie, *record_01, *record_02, *camera, - *rocket; + *rocket, + *quiver; }; diff --git a/source/world/item/SlabItem.cpp b/source/world/item/SlabItem.cpp new file mode 100644 index 000000000..9452ad8b4 --- /dev/null +++ b/source/world/item/SlabItem.cpp @@ -0,0 +1,34 @@ +#include "SlabItem.hpp" +#include "world/tile/StoneSlabTile.hpp" + +SlabItem::SlabItem(int id) : AuxTileItem(id) +{ +} + +std::string SlabItem::getDescriptionId(ItemInstance* item) +{ + int var2 = item->getAuxValue(); + if (var2 < 0 || var2 >= 4) + { + var2 = 0; + } + + std::string name; + switch (var2) + { + case StoneSlabTile::STONE: + name = "stone"; + break; + case StoneSlabTile::SAND: + name = "sand"; + break; + case StoneSlabTile::WOOD: + name = "wood"; + break; + case StoneSlabTile::COBBLE: + name = "cobble"; + break; + } + + return AuxTileItem::getDescriptionId(item) + "." + name; +} diff --git a/source/world/item/SlabItem.hpp b/source/world/item/SlabItem.hpp new file mode 100644 index 000000000..ff9d4b443 --- /dev/null +++ b/source/world/item/SlabItem.hpp @@ -0,0 +1,10 @@ +#pragma once + +#include "AuxTileItem.hpp" + +class SlabItem : public AuxTileItem +{ +public: + SlabItem(int id); + std::string getDescriptionId(ItemInstance* item) override; +}; diff --git a/source/world/level/Level.cpp b/source/world/level/Level.cpp index 70c2eea3d..b44a34a6b 100644 --- a/source/world/level/Level.cpp +++ b/source/world/level/Level.cpp @@ -730,7 +730,8 @@ AABBVector* Level::getCubes(const Entity* pEntUnused, const AABB& aabb) { if (!hasChunkAt(TilePos(x, 64, z))) continue; - for (long y = lowerY; y <= upperY; y++) + // - 1 fixes tiles like the fence + for (long y = lowerY - 1; y <= upperY; y++) { // Obviously this is problematic, but using longs in our for loops rather than // ints helps prevents crashes at extreme distances from 0,0 diff --git a/source/world/level/Material.cpp b/source/world/level/Material.cpp index 0e93fdead..4b57d7af4 100644 --- a/source/world/level/Material.cpp +++ b/source/world/level/Material.cpp @@ -47,7 +47,8 @@ Material * Material::clay, * Material::vegetable, * Material::portal, -* Material::cake; +* Material::cake, +* Material::web; void Material::initMaterials() { @@ -76,6 +77,7 @@ void Material::initMaterials() vegetable = new Material(); portal = new Material(); cake = new Material(); + web = new Material(); } void Material::teardownMaterials() @@ -105,6 +107,7 @@ void Material::teardownMaterials() if (vegetable) delete vegetable; if (portal) delete portal; if (cake) delete cake; + if (web) delete web; } bool Material::isLiquid() const diff --git a/source/world/level/Material.hpp b/source/world/level/Material.hpp index fd7c5c851..b1691e86a 100644 --- a/source/world/level/Material.hpp +++ b/source/world/level/Material.hpp @@ -53,7 +53,8 @@ class Material *clay, *vegetable, *portal, - *cake; + *cake, + *web; public: bool m_bFlammable; diff --git a/source/world/level/TilePos.cpp b/source/world/level/TilePos.cpp index e7c286888..6ce30dc9e 100644 --- a/source/world/level/TilePos.cpp +++ b/source/world/level/TilePos.cpp @@ -26,7 +26,8 @@ TilePos::TilePos(float _x, float _y, float _z) TilePos::TilePos(const Vec3& pos) { - _init(pos.x, pos.y, pos.z); + //@NOTE: Using floor fixes TilePos instantiation in negative coords + _init((int)floorf(pos.x), (int)floorf(pos.y), (int)floorf(pos.z)); } TilePos::TilePos(const ChunkPos& pos, int y) diff --git a/source/world/level/levelgen/chunk/RandomLevelSource.cpp b/source/world/level/levelgen/chunk/RandomLevelSource.cpp index 9ced2812c..283e5789d 100644 --- a/source/world/level/levelgen/chunk/RandomLevelSource.cpp +++ b/source/world/level/levelgen/chunk/RandomLevelSource.cpp @@ -10,7 +10,6 @@ #include "world/level/Level.hpp" #include "world/tile/SandTile.hpp" -//#define TEST_CAVES const float RandomLevelSource::SNOW_CUTOFF = 0.5f; const float RandomLevelSource::SNOW_SCALE = 0.3f; @@ -88,7 +87,7 @@ LevelChunk* RandomLevelSource::getChunk(const ChunkPos& pos) // @NOTE: Java Edition Beta 1.6 uses the m_largeCaveFeature. #ifdef TEST_CAVES - m_largeCaveFeature.apply(this, m_pLevel, x, z, pLevelData, 0); + m_largeCaveFeature.apply(this, m_pLevel, pos.x, pos.z, pLevelData, 0); #endif return pChunk; @@ -547,6 +546,70 @@ void RandomLevelSource::postProcess(ChunkSource* src, const ChunkPos& pos) SpringFeature(Tile::lava->m_ID).place(m_pLevel, &m_random, TilePos(tp.x + 8 + xo, yo, tp.z + 8 + zo)); } + int vegetationCount = 0; + + if (pBiome == Biome::desert) + vegetationCount += 10; + + for (int i = 0; i < vegetationCount; i++) + { + int xo = m_random.nextInt(16); + int yo = m_random.nextInt(128); + int zo = m_random.nextInt(16); + CactusFeature().place(m_pLevel, &m_random, TilePos(tp.x + 8 + xo, yo, tp.z + 8 + zo)); + } + + if (m_random.nextInt(32) == 0) + { + int xo = m_random.nextInt(16); + int yo = m_random.nextInt(128); + int zo = m_random.nextInt(16); + PumpkinFeature().place(m_pLevel, &m_random, TilePos(tp.x + 8 + xo, yo, tp.z + 8 + zo)); + } +#ifdef FEATURE_PLANT_VEGGIES + vegetationCount = 0; + + if (pBiome == Biome::forest) + vegetationCount = 2; + + else if (pBiome == Biome::rainForest) + vegetationCount = 10; + + else if (pBiome == Biome::seasonalForest) + vegetationCount = 2; + + else if (pBiome == Biome::taiga) + vegetationCount = 1; + + else if (pBiome == Biome::plains) + vegetationCount = 10; + + for (int i = 0; i < vegetationCount; i++) + { + int data = 1; + + if (pBiome == Biome::rainForest && m_random.nextInt(3) != 0) { + data = 2; + } + TilePos o(m_random.nextInt(16), + m_random.nextInt(128), + m_random.nextInt(16)); + VegetationFeature(Tile::tallGrass->m_ID, data).place(m_pLevel, &m_random, TilePos(tp.x + 8 + o.x, o.y, tp.z + 8 + o.z)); + } + + vegetationCount = 0; + + if (pBiome == Biome::desert) + vegetationCount = 2; + + for (int i = 0; i < vegetationCount; i++) + { + int xo = m_random.nextInt(16); + int yo = m_random.nextInt(128); + int zo = m_random.nextInt(16); + VegetationFeature(Tile::deadBush->m_ID, 0, 4).place(m_pLevel, &m_random, TilePos(tp.x + 8 + xo, yo, tp.z + 8 + zo)); + } +#endif float* tempBlock = m_pLevel->getBiomeSource()->getTemperatureBlock(tp.x + 8, tp.z + 8, 16, 16); for (int j19 = tp.x + 8; j19 < tp.x + 8 + 16; j19++) { diff --git a/source/world/level/levelgen/feature/CactusFeature.cpp b/source/world/level/levelgen/feature/CactusFeature.cpp new file mode 100644 index 000000000..dc2681d69 --- /dev/null +++ b/source/world/level/levelgen/feature/CactusFeature.cpp @@ -0,0 +1,27 @@ +#include "Feature.hpp" +#include "world/level/Level.hpp" + +bool CactusFeature::place(Level* level, Random* random, const TilePos& pos) +{ + TilePos tp; + for (int var6 = 0; var6 < 10; ++var6) + { + tp.x = pos.x + random->nextInt(8) - random->nextInt(8); + tp.y = pos.y + random->nextInt(4) - random->nextInt(4); + tp.z = pos.z + random->nextInt(8) - random->nextInt(8); + if (level->isEmptyTile(tp)) + { + int var10 = 1 + random->nextInt(random->nextInt(3) + 1); + for (int var11 = 0; var11 < var10; ++var11) + { + TilePos above = tp.above(var11); + if (Tile::cactus->canSurvive(level, above)) + { + level->setTileNoUpdate(above, Tile::cactus->m_ID); + } + } + } + } + + return true; +} diff --git a/source/world/level/levelgen/feature/Feature.hpp b/source/world/level/levelgen/feature/Feature.hpp index b60fd06f8..8372e8a8d 100644 --- a/source/world/level/levelgen/feature/Feature.hpp +++ b/source/world/level/levelgen/feature/Feature.hpp @@ -93,3 +93,28 @@ class ReedsFeature : public Feature bool place(Level*, Random*, const TilePos& pos) override; }; +class VegetationFeature : public Feature +{ +public: + VegetationFeature(int id, int data, int count = 128); + bool place(Level*, Random*, const TilePos& pos) override; + +private: + int m_ID; + int m_data; + int m_count; +}; + +class CactusFeature : public Feature +{ +public: + bool place(Level*, Random*, const TilePos& pos) override; +}; + +class PumpkinFeature : public Feature +{ +public: + bool place(Level*, Random*, const TilePos& pos) override; +}; + + diff --git a/source/world/level/levelgen/feature/PumpkinFeature.cpp b/source/world/level/levelgen/feature/PumpkinFeature.cpp new file mode 100644 index 000000000..7e39bd3fb --- /dev/null +++ b/source/world/level/levelgen/feature/PumpkinFeature.cpp @@ -0,0 +1,19 @@ +#include "Feature.hpp" +#include "world/level/Level.hpp" + +bool PumpkinFeature::place(Level* level, Random* random, const TilePos& pos) +{ + TilePos actual; + for (int var6 = 0; var6 < 64; ++var6) + { + actual.x = pos.x + random->nextInt(8) - random->nextInt(8); + actual.y = pos.y + random->nextInt(4) - random->nextInt(4); + actual.z = pos.z + random->nextInt(8) - random->nextInt(8); + if (level->isEmptyTile(actual) && level->getTile(actual.below()) == Tile::grass->m_ID && Tile::pumpkin->canSurvive(level, actual)) + { + level->setTileAndDataNoUpdate(actual, Tile::pumpkin->m_ID, random->nextInt(4)); + } + } + + return true; +} diff --git a/source/world/level/levelgen/feature/VegetationFeature.cpp b/source/world/level/levelgen/feature/VegetationFeature.cpp new file mode 100644 index 000000000..8316d4f7e --- /dev/null +++ b/source/world/level/levelgen/feature/VegetationFeature.cpp @@ -0,0 +1,36 @@ +#include "Feature.hpp" +#include "world/level/Level.hpp" + +VegetationFeature::VegetationFeature(int id, int data, int count) +{ + m_ID = id; + m_data = data; + m_count = count; +} + +bool VegetationFeature::place(Level* level, Random* random, const TilePos& pos) +{ + TilePos bPos(pos); + TilePos tp; + while (true) + { + int var11 = level->getTile(bPos); + if (var11 != 0 && var11 != Tile::leaves->m_ID || bPos.y <= 0) + { + for (int var7 = 0; var7 < m_count; ++var7) + { + tp.x = bPos.x + random->nextInt(8) - random->nextInt(8); + tp.y = bPos.y + random->nextInt(4) - random->nextInt(4); + tp.z = bPos.z + random->nextInt(8) - random->nextInt(8); + if (level->isEmptyTile(tp) && Tile::tiles[m_ID]->canSurvive(level, tp)) + { + if (m_data) level->setTileAndDataNoUpdate(tp, m_ID, m_data); + else level->setTileNoUpdate(tp, m_ID); + } + } + + return true; + } + --bPos.y; + } +} diff --git a/source/world/level/path/PathFinder.cpp b/source/world/level/path/PathFinder.cpp index 760d19578..516632111 100644 --- a/source/world/level/path/PathFinder.cpp +++ b/source/world/level/path/PathFinder.cpp @@ -28,6 +28,7 @@ PathFinder::PathFinder() { m_pLevel = nullptr; m_nodeCount = 0; + m_bEntityIsDoorBreaker = false; } PathFinder::~PathFinder() @@ -55,25 +56,39 @@ int PathFinder::isFree(Entity* pEntity, const TilePos& pos, const Node* node) if (id == Tile::door_iron->m_ID || id == Tile::door_wood->m_ID) { - if (!DoorTile::isOpen(m_pLevel->getData(tp))) - return 0; + if (id != Tile::door_wood->m_ID || !m_bEntityIsDoorBreaker) + { + if (!DoorTile::isOpen(m_pLevel->getData(tp))) + return 0; // 4 on 0.2.1 + } continue; } + // 0.2.1 + /*if (id == Tile::water->m_ID || id == Tile::calmWater->m_ID) + { + if (field_100B9) // offset from 0.7.0 + return 3; + } + else */if (id == Tile::fence->m_ID/* || id == Tile::fenceGate->m_ID*/) + { + return 0; // 1 on 0.2.1 + } + Material* pMtl = Tile::tiles[id]->m_pMaterial; if (pMtl->blocksMotion()) - return 0; + return 0; // 4 on 0.2.1 if (pMtl == Material::water) return -1; if (pMtl == Material::lava) - return -2; + return -2; // 2 on 0.2.1 } } } - return 1; // Totally free! + return 1; // Totally free! (5 on 0.2.1) } Node* PathFinder::getNode(Entity* pEntity, const TilePos& pos, const Node* node, int a) @@ -83,7 +98,7 @@ Node* PathFinder::getNode(Entity* pEntity, const TilePos& pos, const Node* node, if (isFree(pEntity, tp, node) == 1) pNode = getNode(tp); - if (a > 0 && !pNode && isFree(pEntity, TilePos(tp.x, tp.y + a, tp.z), node) == 1) + if (!pNode && a > 0 && isFree(pEntity, TilePos(tp.x, tp.y + a, tp.z), node) == 1) { tp.y += a; pNode = getNode(tp); diff --git a/source/world/level/path/PathFinder.hpp b/source/world/level/path/PathFinder.hpp index 203cf392a..c058fe69c 100644 --- a/source/world/level/path/PathFinder.hpp +++ b/source/world/level/path/PathFinder.hpp @@ -53,4 +53,5 @@ class PathFinder std::vector m_nodeSpillover; int m_nodeCount; Node* m_neighbors[NEIGHBORS_SIZE]; + bool m_bEntityIsDoorBreaker; }; diff --git a/source/world/level/storage/LevelData.cpp b/source/world/level/storage/LevelData.cpp index 915bdd745..343717073 100644 --- a/source/world/level/storage/LevelData.cpp +++ b/source/world/level/storage/LevelData.cpp @@ -249,7 +249,7 @@ void PlayerData::loadPlayer(Player& player) const player.m_distanceFallen = m_distanceFallen; player.m_fireTicks = field_24; player.m_airCapacity = field_26; - player.m_onGround = field_28; + player.m_bOnGround = field_28; // @NOTE: Why are we updating m_pos, m_oPos and m_posPrev above if we do this? player.setPos(m_pos); @@ -267,7 +267,7 @@ void PlayerData::savePlayer(const Player& player) m_distanceFallen = player.m_distanceFallen; field_24 = player.m_fireTicks; field_26 = player.m_airCapacity; - field_28 = player.m_onGround; + field_28 = player.m_bOnGround; // TODO: survival mode stuff for (int i = 0; i < C_MAX_HOTBAR_ITEMS; i++) diff --git a/source/world/particle/ExplodeParticle.cpp b/source/world/particle/ExplodeParticle.cpp index 02b26d376..e5149e29a 100644 --- a/source/world/particle/ExplodeParticle.cpp +++ b/source/world/particle/ExplodeParticle.cpp @@ -37,7 +37,7 @@ void ExplodeParticle::tick() m_vel *= 0.9f; - if (m_onGround) + if (m_bOnGround) { m_vel.x *= 0.7f; m_vel.z *= 0.7f; diff --git a/source/world/particle/FlameParticle.cpp b/source/world/particle/FlameParticle.cpp index ce929330d..39a63d158 100644 --- a/source/world/particle/FlameParticle.cpp +++ b/source/world/particle/FlameParticle.cpp @@ -46,7 +46,7 @@ void FlameParticle::tick() m_vel *= 0.96f; - if (m_onGround) + if (m_bOnGround) { m_vel.x *= 0.7f; m_vel.z *= 0.7f; diff --git a/source/world/particle/LavaParticle.cpp b/source/world/particle/LavaParticle.cpp index 6d989b29c..d76ad60bd 100644 --- a/source/world/particle/LavaParticle.cpp +++ b/source/world/particle/LavaParticle.cpp @@ -46,7 +46,7 @@ void LavaParticle::tick() move(m_vel); m_vel *= 0.999f; - if (m_onGround) + if (m_bOnGround) { m_vel.x *= 0.7f; m_vel.z *= 0.7f; diff --git a/source/world/particle/Particle.cpp b/source/world/particle/Particle.cpp index 908cc0caa..8b276c1db 100644 --- a/source/world/particle/Particle.cpp +++ b/source/world/particle/Particle.cpp @@ -111,7 +111,7 @@ void Particle::tick() m_vel *= 0.98f; - if (m_onGround) + if (m_bOnGround) { m_vel.x *= 0.7f; m_vel.z *= 0.7f; diff --git a/source/world/particle/RedDustParticle.cpp b/source/world/particle/RedDustParticle.cpp index 59b4f046c..bae587260 100644 --- a/source/world/particle/RedDustParticle.cpp +++ b/source/world/particle/RedDustParticle.cpp @@ -59,7 +59,7 @@ void RedDustParticle::tick() m_vel *= 0.96f; - if (m_onGround) + if (m_bOnGround) { m_vel.x *= 0.7f; m_vel.z *= 0.7f; diff --git a/source/world/particle/SmokeParticle.cpp b/source/world/particle/SmokeParticle.cpp index f8584baf0..2c781a660 100644 --- a/source/world/particle/SmokeParticle.cpp +++ b/source/world/particle/SmokeParticle.cpp @@ -56,7 +56,7 @@ void SmokeParticle::tick() m_vel *= 0.96f; - if (m_onGround) + if (m_bOnGround) { m_vel.x *= 0.7f; m_vel.z *= 0.7f; diff --git a/source/world/tile/CactusTile.cpp b/source/world/tile/CactusTile.cpp new file mode 100644 index 000000000..60ace30cc --- /dev/null +++ b/source/world/tile/CactusTile.cpp @@ -0,0 +1,99 @@ +#include "CactusTile.hpp" +#include "world/level/Level.hpp" + +CactusTile::CactusTile(int id, int texture) : Tile(id, texture, Material::cactus) +{ + setTicking(true); +} + +AABB* CactusTile::getAABB(const Level* pLevel, const TilePos& pos) +{ + AABB* aabb = Tile::getAABB(pLevel, pos); + aabb->max.y -= 1.0f / 16.0f; + return aabb; +} + +bool CactusTile::mayPlace(const Level* level, const TilePos& pos) const +{ + return Tile::mayPlace(level, pos) && canSurvive(level, pos); +} + +bool CactusTile::canSurvive(const Level* level, const TilePos& pos) const +{ + for (int i = Facing::NORTH; i <= Facing::EAST; ++i) + { + if (level->getMaterial(pos.relative((Facing::Name)i))->isSolid()) + { + return false; + } + } + + TileID tile = level->getTile(pos.below()); + + return tile == Tile::sand->m_ID || tile == m_ID; +} + + +void CactusTile::neighborChanged(Level* level, const TilePos& pos, TileID tile) +{ + if (!canSurvive(level, pos)) + { + spawnResources(level, pos, level->getData(pos)); + level->setTile(pos, TILE_AIR); + } +} + +bool CactusTile::isSolidRender() const +{ + return false; +} + +bool CactusTile::isCubeShaped() const +{ + return false; +} + +int CactusTile::getRenderShape() const +{ + return SHAPE_CACTUS; +} + +void CactusTile::tick(Level* level, const TilePos& pos, Random* random) +{ + TilePos above = pos.above(); + if (level->isEmptyTile(pos.above())) + { + int height; + for (height = 1; level->getTile(pos.below(height)) == m_ID; ++height) + { + } + if (height < 3) + { + int data = level->getData(pos); + if (data == 15) + { + level->setTile(above, m_ID); + level->setData(pos, 0); + } + else + { + level->setData(pos, data + 1); + } + } + } +} + +void CactusTile::updateShape(const LevelSource* level, const TilePos& pos) +{ + setShape(0.0625, 0, 0.0625, 0.9375, 1, 0.9375); +} + +void CactusTile::entityInside(Level* level, const TilePos& pos, Entity* entity) const +{ + entity->hurt(nullptr, 1); +} + +int CactusTile::getTexture(Facing::Name face) const +{ + return face == 1 ? m_TextureFrame - 1 : (face == 0 ? m_TextureFrame + 1 : m_TextureFrame); +} diff --git a/source/world/tile/CactusTile.hpp b/source/world/tile/CactusTile.hpp new file mode 100644 index 000000000..6d7275d2a --- /dev/null +++ b/source/world/tile/CactusTile.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include "Tile.hpp" + +class CactusTile : public Tile +{ +public: + CactusTile(int id, int texture); + AABB* getAABB(const Level* pLevel, const TilePos& pos) override; + bool mayPlace(const Level*, const TilePos& pos) const override; + bool canSurvive(const Level* level, const TilePos& pos) const override; + void neighborChanged(Level* level, const TilePos& pos, TileID tile) override; + bool isSolidRender() const override; + bool isCubeShaped() const override; + int getRenderShape() const override; + void tick(Level*, const TilePos& pos, Random*) override; + void entityInside(Level*, const TilePos& pos, Entity*) const override; + int getTexture(Facing::Name face) const override; + void updateShape(const LevelSource* level, const TilePos& pos) override; +}; diff --git a/source/world/tile/ClothTile.cpp b/source/world/tile/ClothTile.cpp index 7bcbeaa89..e5e58c711 100644 --- a/source/world/tile/ClothTile.cpp +++ b/source/world/tile/ClothTile.cpp @@ -9,22 +9,21 @@ #include "ClothTile.hpp" #include "world/level/Level.hpp" -ClothTile::ClothTile(int id, int type) : Tile(id, TEXTURE_CLOTH_64, Material::cloth) +ClothTile::ClothTile(int id) : Tile(id, TEXTURE_CLOTH_64, Material::cloth) { - field_6C = type; - - m_TextureFrame = getTexture(Facing::DOWN, type); -} - -int ClothTile::getTexture(Facing::Name face) const -{ - return getTexture(face, field_6C); } int ClothTile::getTexture(Facing::Name face, int data) const { - //@HUH: what? - return ((~(this->field_6C & 0xFu) >> 3) & 1) + 16 * (~(this->field_6C & 0xF) & 7) + 113; + if (!data) + { + return m_TextureFrame; + } + else + { + data = getColorFromData(data); + return 113 + ((data & 8) >> 3) + (data & 7) * 16; + } } int ClothTile::getSpawnResourcesAuxValue(int val) const diff --git a/source/world/tile/ClothTile.hpp b/source/world/tile/ClothTile.hpp index 727ee57d0..c72841fcd 100644 --- a/source/world/tile/ClothTile.hpp +++ b/source/world/tile/ClothTile.hpp @@ -13,10 +13,11 @@ class ClothTile : public Tile { public: - ClothTile(int id, int type); - int getTexture(Facing::Name face) const override; + ClothTile(int id); int getTexture(Facing::Name face, int data) const override; int getSpawnResourcesAuxValue(int val) const override; - - uint8_t field_6C; + static int getColorFromData(int var0) + { + return ~var0 & 15; + } }; diff --git a/source/world/tile/DeadBush.cpp b/source/world/tile/DeadBush.cpp new file mode 100644 index 000000000..2fb47d006 --- /dev/null +++ b/source/world/tile/DeadBush.cpp @@ -0,0 +1,18 @@ +#include "DeadBush.hpp" +#include "world/level/Level.hpp" + +DeadBush::DeadBush(int id, int texture) : Bush(id, texture) +{ +} + +bool DeadBush::mayPlace(const Level* level, const TilePos& pos) const +{ + TileID tile = level->getTile(pos.below()); + + return tile == Tile::sand->m_ID; +} + +int DeadBush::getResource(int x, Random* random) const +{ + return -1; +} diff --git a/source/world/tile/DeadBush.hpp b/source/world/tile/DeadBush.hpp new file mode 100644 index 000000000..f2073f527 --- /dev/null +++ b/source/world/tile/DeadBush.hpp @@ -0,0 +1,11 @@ +#pragma once + +#include "Bush.hpp" + +class DeadBush : public Bush +{ +public: + DeadBush(int id, int texture); + int getResource(int, Random*) const; + bool mayPlace(const Level*, const TilePos& pos) const; +}; diff --git a/source/world/tile/DoorTile.cpp b/source/world/tile/DoorTile.cpp index bbe4fc446..c28a63cdb 100644 --- a/source/world/tile/DoorTile.cpp +++ b/source/world/tile/DoorTile.cpp @@ -104,9 +104,9 @@ int DoorTile::getResource(int data, Random* random) const return 0; if (m_pMaterial == Material::metal) - return Item::door_iron->m_itemID; + return Item::door_wood->m_itemID; - return Item::door_wood->m_itemID; + return Item::door_iron->m_itemID; } int DoorTile::getTexture(Facing::Name face, int data) const diff --git a/source/world/tile/FenceTile.cpp b/source/world/tile/FenceTile.cpp new file mode 100644 index 000000000..e5697cec7 --- /dev/null +++ b/source/world/tile/FenceTile.cpp @@ -0,0 +1,42 @@ +/******************************************************************** + Minecraft: Pocket Edition - Decompilation Project + Copyright (C) 2023 iProgramInCpp + + The following code is licensed under the BSD 1 clause license. + SPDX-License-Identifier: BSD-1-Clause + ********************************************************************/ + +#include "FenceTile.hpp" +#include "world/level/Level.hpp" + +FenceTile::FenceTile(int a, int b) : Tile(a, b, Material::wood) +{ +} + +bool FenceTile::mayPlace(const Level* level, const TilePos& pos, Facing::Name face) const +{ + TilePos below = pos.below(); + return level->getTile(below) == m_ID || (Tile::mayPlace(level, pos) && level->getMaterial(below)->isSolid()); +} + +AABB* FenceTile::getAABB(const Level* pLevel, const TilePos& pos) +{ + AABB* rAABB = Tile::getAABB(pLevel, pos); + rAABB->max.y += 0.5f; + return rAABB; +} + +bool FenceTile::isSolidRender() const +{ + return false; +} + +bool FenceTile::isCubeShaped() const +{ + return false; +} + +int FenceTile::getRenderShape() const +{ + return SHAPE_FENCE; +} \ No newline at end of file diff --git a/source/world/tile/FenceTile.hpp b/source/world/tile/FenceTile.hpp new file mode 100644 index 000000000..a5cbbdf31 --- /dev/null +++ b/source/world/tile/FenceTile.hpp @@ -0,0 +1,14 @@ +#pragma once + +#include "Tile.hpp" + +class FenceTile : public Tile +{ +public: + FenceTile(int id, int texture); + bool mayPlace(const Level*, const TilePos& pos, Facing::Name face) const; + AABB* getAABB(const Level* pLevel, const TilePos& pos) override; + bool isSolidRender() const override; + bool isCubeShaped() const override; + int getRenderShape() const override; +}; diff --git a/source/world/tile/FireTile.cpp b/source/world/tile/FireTile.cpp index e94f5b8a4..54aaeed5f 100644 --- a/source/world/tile/FireTile.cpp +++ b/source/world/tile/FireTile.cpp @@ -178,6 +178,12 @@ void FireTile::onPlace(Level* level, const TilePos& pos) void FireTile::tick(Level* level, const TilePos& pos, Random* random) { + if (level->getTile(pos.below()) == Tile::netherrack->m_ID) + { + level->addToTickNextTick(pos, m_ID, getTickDelay()); + return; + } + int data = level->getData(pos); if (data <= 14) { diff --git a/source/world/tile/GlowstoneTile.cpp b/source/world/tile/GlowstoneTile.cpp new file mode 100644 index 000000000..1f45f346f --- /dev/null +++ b/source/world/tile/GlowstoneTile.cpp @@ -0,0 +1,16 @@ +#include "GlowstoneTile.hpp" +#include "world/level/Level.hpp" + +GlowstoneTile::GlowstoneTile(int id, int texture, Material* material) : Tile(id, texture, material) +{ +} + +int GlowstoneTile::getResource(int data, Random*) const +{ + return Item::yellowDust->m_itemID; +} + +int GlowstoneTile::getResourceCount(Random* random) const +{ + return 2 + random->nextInt(3); +} \ No newline at end of file diff --git a/source/world/tile/GlowstoneTile.hpp b/source/world/tile/GlowstoneTile.hpp new file mode 100644 index 000000000..31b71107f --- /dev/null +++ b/source/world/tile/GlowstoneTile.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include "Tile.hpp" + +class GlowstoneTile : public Tile +{ +public: + GlowstoneTile(int id, int texture, Material* material); + + int getResource(int, Random*) const override; + int getResourceCount(Random*) const override; +}; \ No newline at end of file diff --git a/source/world/tile/GravelTile.cpp b/source/world/tile/GravelTile.cpp index b2123e939..e22b9419b 100644 --- a/source/world/tile/GravelTile.cpp +++ b/source/world/tile/GravelTile.cpp @@ -13,7 +13,7 @@ GravelTile::GravelTile(int a, int b, Material* c) : SandTile(a, b, c) { } -int GravelTile::getResource(int a, Random* b) const +int GravelTile::getResource(int data, Random* random) const { - return m_ID; + return random->nextInt(10) == 0 ? Item::flint->m_itemID : SandTile::getResource(data, random); } diff --git a/source/world/tile/GravelTile.hpp b/source/world/tile/GravelTile.hpp index be380ef60..675ac2e27 100644 --- a/source/world/tile/GravelTile.hpp +++ b/source/world/tile/GravelTile.hpp @@ -15,5 +15,5 @@ class GravelTile : public SandTile public: GravelTile(int ID, int texture, Material*); - int getResource(int, Random*) const override; + int getResource(int data, Random* random) const override; }; diff --git a/source/world/tile/IceTile.cpp b/source/world/tile/IceTile.cpp index e3e9589b0..c6bb5f47e 100644 --- a/source/world/tile/IceTile.cpp +++ b/source/world/tile/IceTile.cpp @@ -11,6 +11,7 @@ IceTile::IceTile(int a, int b, Material* c) : HalfTransparentTile(a, b, c) { + m_friction = 0.98f; setTicking(true); } diff --git a/source/world/tile/LeafTile.cpp b/source/world/tile/LeafTile.cpp index 37ada9ee5..a198ec5e1 100644 --- a/source/world/tile/LeafTile.cpp +++ b/source/world/tile/LeafTile.cpp @@ -244,3 +244,13 @@ void LeafTile::tick(Level* level, const TilePos& pos, Random* random) _tickDecay(level, pos); } + +int LeafTile::getResource(int x, Random* random) const +{ + return random->nextInt(20) == 0 ? Tile::sapling->m_ID : 0; +} + +int LeafTile::getSpawnResourcesAuxValue(int x) const +{ + return x & 3; +} diff --git a/source/world/tile/LeafTile.hpp b/source/world/tile/LeafTile.hpp index 651bfbecc..a053faedf 100644 --- a/source/world/tile/LeafTile.hpp +++ b/source/world/tile/LeafTile.hpp @@ -27,6 +27,8 @@ class LeafTile : public TransparentTile void onRemove(Level*, const TilePos& pos) override; void stepOn(Level*, const TilePos& pos, Entity*) override; void tick(Level*, const TilePos& pos, Random*) override; + int getResource(int x, Random* random) const override; + int getSpawnResourcesAuxValue(int x) const override; void die(Level*, const TilePos& pos); diff --git a/source/world/tile/PumpkinTile.cpp b/source/world/tile/PumpkinTile.cpp new file mode 100644 index 000000000..aa5fee49e --- /dev/null +++ b/source/world/tile/PumpkinTile.cpp @@ -0,0 +1,41 @@ +#include "PumpkinTile.hpp" +#include "world/level/Level.hpp" + +PumpkinTile::PumpkinTile(int id, bool lantern) : Tile(id, TEXTURE_PUMPKIN_TOP, Material::vegetable), m_bLantern(lantern) +{ +} + +int PumpkinTile::getTexture(Facing::Name face, int data) const +{ + switch (face) { + case Facing::UP: case Facing::DOWN: return m_TextureFrame; + default: + return face == 2 && data == 2 || face == 5 && data == 3 || face == 3 && data == 0 || face == 4 && data == 1 ? m_TextureFrame + (m_bLantern ? 18 : 17) : m_TextureFrame + 16; + } +} + +int PumpkinTile::getTexture(Facing::Name face) const +{ + switch (face) { + case Facing::UP: case Facing::DOWN: return m_TextureFrame; + case Facing::SOUTH: return m_TextureFrame + 17; + default: return m_TextureFrame + 16; + } +} + +void PumpkinTile::setPlacedBy(Level* level, const TilePos& pos, Mob* mob) +{ + int rot = Mth::floor(0.5f + (mob->m_rot.x * 4.0f / 360.0f)) & 3; + + int data = 0; + + switch (rot) + { + case 0: data = 2; break; + case 1: data = 3; break; + case 2: data = 0; break; + case 3: data = 1; break; + } + + level->setData(pos, data); +} diff --git a/source/world/tile/PumpkinTile.hpp b/source/world/tile/PumpkinTile.hpp new file mode 100644 index 000000000..119aade59 --- /dev/null +++ b/source/world/tile/PumpkinTile.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include "Tile.hpp" + +class PumpkinTile : public Tile +{ + public: + PumpkinTile(int id, bool lantern); + int getTexture(Facing::Name face, int data) const override; + int getTexture(Facing::Name face) const override; + void setPlacedBy(Level*, const TilePos& pos, Mob*) override; + bool m_bLantern; +}; diff --git a/source/world/tile/ReedTile.cpp b/source/world/tile/ReedTile.cpp index d7edb524f..2ebe1185e 100644 --- a/source/world/tile/ReedTile.cpp +++ b/source/world/tile/ReedTile.cpp @@ -99,5 +99,5 @@ AABB* ReedTile::getAABB(const Level* level, const TilePos& pos) int ReedTile::getResource(int x, Random* random) const { - return 0; + return Item::reeds->m_itemID; } diff --git a/source/world/tile/Sapling.cpp b/source/world/tile/Sapling.cpp index 5f3001d50..e60886746 100644 --- a/source/world/tile/Sapling.cpp +++ b/source/world/tile/Sapling.cpp @@ -15,7 +15,8 @@ Sapling::Sapling(int id, int texture) : Bush(id, texture) int Sapling::getTexture(Facing::Name face, int data) const { - return TEXTURE_SAPLING; // we don't have the other saplings' textures... + data &= 3; + return data == 1 ? 63 : (data == 2 ? 79 : Bush::getTexture(face, data)); } void Sapling::tick(Level* level, const TilePos& pos, Random* random) @@ -33,33 +34,30 @@ void Sapling::tick(Level* level, const TilePos& pos, Random* random) } } -bool Sapling::maybeGrowTree(Level* level, const TilePos& pos, Random* random) +void Sapling::growTree(Level* level, const TilePos& pos, Random* random) { - // this is fine... these are not heavy at all + int data = level->getData(pos) & 3; + level->setTileNoUpdate(pos, TILE_AIR); + TreeFeature treeFeature; - BirchFeature birchFeature; - SpruceFeature spruceFeature; Feature* pFeature = &treeFeature; - int data = level->getData(pos); switch (data) { - case 1: - pFeature = &birchFeature; - break; - case 2: - pFeature = &spruceFeature; - break; + case 1: + pFeature = new SpruceFeature; + break; + case 2: + pFeature = new BirchFeature; + break; } - return treeFeature.place(level, random, pos); + if (!pFeature->place(level, random, pos)) + level->setTileNoUpdate(pos, m_ID); } -void Sapling::growTree(Level* level, const TilePos& pos, Random* random) +int Sapling::getSpawnResourcesAuxValue(int x) const { - level->setTileNoUpdate(pos, TILE_AIR); - - if (!maybeGrowTree(level, pos, random)) - level->setTileNoUpdate(pos, m_ID); + return x & 3; } diff --git a/source/world/tile/Sapling.hpp b/source/world/tile/Sapling.hpp index d0bf079d8..dca057a27 100644 --- a/source/world/tile/Sapling.hpp +++ b/source/world/tile/Sapling.hpp @@ -17,7 +17,7 @@ class Sapling : public Bush int getTexture(Facing::Name face, int data) const override; void tick(Level*, const TilePos& pos, Random*) override; + int getSpawnResourcesAuxValue(int x) const override; void growTree(Level*, const TilePos& pos, Random*); - bool maybeGrowTree(Level*, const TilePos& pos, Random*); }; diff --git a/source/world/tile/SoulSandTile.cpp b/source/world/tile/SoulSandTile.cpp new file mode 100644 index 000000000..91cc8f72f --- /dev/null +++ b/source/world/tile/SoulSandTile.cpp @@ -0,0 +1,19 @@ +#include "SoulSandTile.hpp" +#include "world/level/Level.hpp" + +SoulSandTile::SoulSandTile(int id, int texture) : Tile(id, texture, Material::sand) +{ +} + +void SoulSandTile::entityInside(Level* level, const TilePos& pos, Entity* entity) const +{ + entity->m_vel.x *= 0.4; + entity->m_vel.z *= 0.4; +} + +AABB* SoulSandTile::getAABB(const Level* pLevel, const TilePos& pos) +{ + AABB* rAABB = Tile::getAABB(pLevel, pos); + rAABB->max.y -= 2 / 16.0; + return rAABB; +} diff --git a/source/world/tile/SoulSandTile.hpp b/source/world/tile/SoulSandTile.hpp new file mode 100644 index 000000000..50c1cde66 --- /dev/null +++ b/source/world/tile/SoulSandTile.hpp @@ -0,0 +1,11 @@ +#pragma once + +#include "Tile.hpp" + +class SoulSandTile : public Tile +{ +public: + SoulSandTile(int id, int texture); + void entityInside(Level* level, const TilePos& pos, Entity* entity) const override; + AABB* getAABB(const Level* pLevel, const TilePos& pos) override; +}; diff --git a/source/world/tile/StoneSlabTile.cpp b/source/world/tile/StoneSlabTile.cpp index 9e2bfb0b6..83a2763f6 100644 --- a/source/world/tile/StoneSlabTile.cpp +++ b/source/world/tile/StoneSlabTile.cpp @@ -54,31 +54,22 @@ int StoneSlabTile::getTexture(Facing::Name face, int data) const { switch (data) { - // regular stone slab - case 0: + case STONE: if (face > Facing::UP) return TEXTURE_STONE_SLAB_SIDE; return TEXTURE_STONE_SLAB_TOP; - - // sandstone slab - case 1: + case SAND: if (face == Facing::DOWN) return TEXTURE_SANDSTONE_BOTTOM; if (face == Facing::UP) return TEXTURE_SANDSTONE_TOP; return TEXTURE_SANDSTONE_SIDE; - - // wood slab - case 2: + case WOOD: return TEXTURE_PLANKS; - - // stone brick slab - case 3: + case COBBLE: return TEXTURE_STONEBRICK; - - // unknown slab type default: return TEXTURE_STONE_SLAB_TOP; } diff --git a/source/world/tile/StoneSlabTile.hpp b/source/world/tile/StoneSlabTile.hpp index 3c94c73eb..839c6a834 100644 --- a/source/world/tile/StoneSlabTile.hpp +++ b/source/world/tile/StoneSlabTile.hpp @@ -13,6 +13,14 @@ class StoneSlabTile : public Tile { public: + enum StoneSlabType + { + STONE, + SAND, + WOOD, + COBBLE + }; + StoneSlabTile(int ID, bool bFull); bool isSolidRender() const override; diff --git a/source/world/tile/TallGrass.cpp b/source/world/tile/TallGrass.cpp new file mode 100644 index 000000000..2335f0188 --- /dev/null +++ b/source/world/tile/TallGrass.cpp @@ -0,0 +1,40 @@ +#include "TallGrass.hpp" +#include "world/level/Level.hpp" +#include "client/renderer/PatchManager.hpp" +#include +#include + +TallGrass::TallGrass(int id, int texture) : Bush(id, texture) +{ + setShape(0.1f, 0.0f, 0.1f, 0.9f, 0.8f, 0.9f); +} + +bool TallGrass::isValidGrowTile(const TileID tile) const +{ + return tile == Tile::grass->m_ID; +} + +int TallGrass::getResource(int x, Random* random) const +{ + return random->nextInt(8) == 0 ? Item::seeds->m_itemID : 0; +} + +int TallGrass::getColor(const LevelSource* levelSource, const TilePos& pos) const +{ + if (GetPatchManager()->IsGrassTinted()) + { + return 0x339933; + } + return 0xFFFFFF; +} + +int TallGrass::getTexture(const LevelSource* level, const TilePos& pos, Facing::Name face) const +{ + auto data = level->getData(pos); + return data == 1 ? m_TextureFrame : (data == 2 ? m_TextureFrame + 16 + 1 : (data == 0 ? m_TextureFrame + 16 : m_TextureFrame)); +} + +int TallGrass::getRenderShape() const +{ + return SHAPE_RANDOM_CROSS; +} diff --git a/source/world/tile/TallGrass.hpp b/source/world/tile/TallGrass.hpp new file mode 100644 index 000000000..aaecdbff6 --- /dev/null +++ b/source/world/tile/TallGrass.hpp @@ -0,0 +1,14 @@ +#pragma once + +#include "Bush.hpp" + +class TallGrass : public Bush +{ +public: + TallGrass(int id, int texture); + int getResource(int, Random*) const override; + bool isValidGrowTile(const TileID tile) const; + int getColor(const LevelSource*, const TilePos& pos) const override; + int getTexture(const LevelSource* level, const TilePos& pos, Facing::Name face) const override; + int getRenderShape() const override; +}; diff --git a/source/world/tile/Tile.cpp b/source/world/tile/Tile.cpp index 61b78cf9a..88a3a0c43 100644 --- a/source/world/tile/Tile.cpp +++ b/source/world/tile/Tile.cpp @@ -9,11 +9,13 @@ #include "world/level/Level.hpp" #include "world/item/TileItem.hpp" #include "world/entity/ItemEntity.hpp" +#include "world/item/AuxTileItem.hpp" +#include "world/item/ClothItem.hpp" +#include "world/item/SlabItem.hpp" // Include tile definitions here #include "SandStoneTile.hpp" #include "SandTile.hpp" -#include "SandStoneTile.hpp" #include "HalfTransparentTile.hpp" #include "GlassTile.hpp" #include "GravelTile.hpp" @@ -49,6 +51,38 @@ #include "BookshelfTile.hpp" #include "WireTile.hpp" #include "RocketLauncherTile.hpp" +//#include "RedStoneDustTile.hpp" +//#include "CraftingTableTile.hpp" +//#include "FurnaceTile.hpp" +#include "TallGrass.hpp" +#include "DeadBush.hpp" +//#include "Fern.hpp" +#include "CactusTile.hpp" +//#include "ChestTile.hpp" +#include "PumpkinTile.hpp" +#include "SoulSandTile.hpp" +#include "GlowstoneTile.hpp" +#include "FenceTile.hpp" +//#include "BedTile.hpp" +//#include "CropsTile.hpp" +#include "Web.hpp" +//#include "SnowTile.hpp" +//#include "SignTile.hpp" +//#include "LeverTile.hpp" +//#include "PressurePlateTile.hpp" +//#include "RailTile.hpp" +//#include "DetectorRailTile.hpp" +//#include "ButtonTile.hpp" +//#include "MobSpawnerTile.hpp" +//#include "RedstoneTorchTile.hpp" +//#include "CakeTile.hpp" +//#include "DispenserTile.hpp" +//#include "MusicTile.hpp" +//#include "RecordPlayerTile.hpp" +//#include "TrapDoorTile.hpp" +//#include "PortalTile.hpp" +//#include "RepeaterTile.hpp" +//#include "Mushroom.hpp" std::string Tile::TILE_DESCRIPTION_PREFIX = "tile."; @@ -66,7 +100,7 @@ void Tile::_init() m_TextureFrame = 1; m_pSound = nullptr; field_28 = 1.0f; - field_30 = 0.6f; + m_friction = 0.6f; m_hardness = 0.0f; m_blastResistance = 0.0f; m_descriptionID = ""; @@ -235,7 +269,7 @@ int Tile::getResourceCount(Random* pRandom) const int Tile::getSpawnResourcesAuxValue(int x) const { - return 1; + return 0; } void Tile::initTiles() @@ -378,7 +412,7 @@ void Tile::initTiles() ->setDestroyTime(0.8f) ->setDescriptionId("sandStone"); - Tile::cloth = (new ClothTile(TILE_CLOTH, 0xCF)) + Tile::cloth = (new ClothTile(TILE_CLOTH)) ->init() ->setDestroyTime(0.8f) ->setSoundType(Tile::SOUND_CLOTH) @@ -558,13 +592,12 @@ void Tile::initTiles() ->setSoundType(Tile::SOUND_CLOTH) ->setDescriptionId("snow"); - // @TODO: CactusTile class - /*Tile::cactus = (new CactusTile(TILE_CACTUS, TEXTURE_CACTUS, Material::cactus)) + Tile::cactus = (new CactusTile(TILE_CACTUS, TEXTURE_CACTUS_SIDE)) ->init() ->setDestroyTime(0.4f) - ->setLightBlock(3) + //->setLightBlock(3) ->setSoundType(Tile::SOUND_CLOTH) - ->setDescriptionId("cactus");*/ + ->setDescriptionId("cactus"); Tile::clay = (new ClayTile(TILE_CLAY, TEXTURE_CLAY, Material::clay)) ->init() @@ -578,13 +611,12 @@ void Tile::initTiles() ->setSoundType(Tile::SOUND_GRASS) ->setDescriptionId("reeds"); - // @TODO: FenceTile class - /*Tile::fence = (new FenceTile(TILE_WOOD, TEXTURE_PLANKS, Material::wood)) + Tile::fence = (new FenceTile(TILE_FENCE, TEXTURE_PLANKS)) ->init() ->setDestroyTime(2.0f) ->setExplodeable(5.0f) ->setSoundType(Tile::SOUND_WOOD) - ->setDescriptionId("fence");*/ + ->setDescriptionId("fence"); Tile::invisible_bedrock = (new InvisibleTile(TILE_INVISIBLE, TEXTURE_STONE, Material::stone)) ->init() @@ -627,134 +659,101 @@ void Tile::initTiles() ->setLightEmission(1.0f) ->setSoundType(Tile::SOUND_WOOD) // @NOTE: Setting fire's sound to Wood ->setDescriptionId("fire"); - - // @TODO: Remove these in favor of what can be found below in 0.2.1 + // custom additions here - Tile::cloth_00 = (new ClothTile(TILE_CLOTH_00, 15)) + Tile::sapling = (new Sapling(TILE_SAPLING, TEXTURE_SAPLING)) ->init() - ->setDestroyTime(0.8f) - ->setSoundType(Tile::SOUND_CLOTH) - ->setDescriptionId("cloth"); + ->setDestroyTime(0.0f) + ->setSoundType(Tile::SOUND_GRASS) + ->setDescriptionId("sapling"); - Tile::cloth_10 = (new ClothTile(TILE_CLOTH_10, 14)) + Tile::sponge = (new SpongeTile(TILE_SPONGE, TEXTURE_SPONGE)) ->init() - ->setDestroyTime(0.8f) + ->setDestroyTime(0.5f) ->setSoundType(Tile::SOUND_CLOTH) - ->setDescriptionId("cloth"); + ->setDescriptionId("sponge"); - Tile::cloth_20 = (new ClothTile(TILE_CLOTH_20, 13)) + Tile::cryingObsidian = (new Tile(TILE_OBSIDIAN_CRYING, TEXTURE_OBSIDIAN_CRYING, Material::stone)) ->init() - ->setDestroyTime(0.8f) - ->setSoundType(Tile::SOUND_CLOTH) - ->setDescriptionId("cloth"); + ->setDestroyTime(10.0f) + ->setExplodeable(2000.0f) + ->setSoundType(Tile::SOUND_STONE) + ->setDescriptionId("cryingObsidian"); - Tile::cloth_30 = (new ClothTile(TILE_CLOTH_30, 12)) + // Jolly + Tile::rocketLauncher = (new RocketLauncherTile(TILE_ROCKET_LAUNCHER)) ->init() - ->setDestroyTime(0.8f) - ->setSoundType(Tile::SOUND_CLOTH) - ->setDescriptionId("cloth"); + ->setSoundType(Tile::SOUND_STONE) + ->setDescriptionId("rocketLauncher"); - Tile::cloth_40 = (new ClothTile(TILE_CLOTH_40, 11)) + Tile::tallGrass = (new TallGrass(TILE_TALLGRASS, TEXTURE_NONE39)) ->init() - ->setDestroyTime(0.8f) - ->setSoundType(Tile::SOUND_CLOTH) - ->setDescriptionId("cloth"); + ->setSoundType(Tile::SOUND_GRASS) + ->setDestroyTime(0.0f) + ->setDescriptionId("tallGrass"); - Tile::cloth_50 = (new ClothTile(TILE_CLOTH_50, 10)) + Tile::deadBush = (new DeadBush(TILE_DEAD_BUSH, TEXTURE_NONE55)) ->init() - ->setDestroyTime(0.8f) - ->setSoundType(Tile::SOUND_CLOTH) - ->setDescriptionId("cloth"); + ->setSoundType(Tile::SOUND_GRASS) + ->setDestroyTime(0.0f) + ->setDescriptionId("deadBush"); - Tile::cloth_60 = (new ClothTile(TILE_CLOTH_60, 9)) + Tile::pumpkin = (new PumpkinTile(TILE_PUMPKIN, false)) ->init() - ->setDestroyTime(0.8f) - ->setSoundType(Tile::SOUND_CLOTH) - ->setDescriptionId("cloth"); - - Tile::cloth_70 = (new ClothTile(TILE_CLOTH_70, 8)) + ->setDestroyTime(1.0f) + ->setSoundType(Tile::SOUND_WOOD) + ->setDescriptionId("pumpkin"); + + Tile::pumpkinLantern = (new PumpkinTile(TILE_PUMPKIN_LIT, true)) ->init() - ->setDestroyTime(0.8f) - ->setSoundType(Tile::SOUND_CLOTH) - ->setDescriptionId("cloth"); - - Tile::cloth_01 = (new ClothTile(TILE_CLOTH_01, 7)) + ->setDestroyTime(1.0f) + ->setLightEmission(1.0f) + ->setSoundType(Tile::SOUND_WOOD) + ->setDescriptionId("litPumpkin"); + + Tile::netherrack = (new Tile(TILE_NETHERRACK, TEXTURE_BLOODSTONE, Material::stone)) ->init() - ->setDestroyTime(0.8f) - ->setSoundType(Tile::SOUND_CLOTH) - ->setDescriptionId("cloth"); + ->setDestroyTime(0.4f) + ->setSoundType(Tile::SOUND_STONE) + ->setDescriptionId("hellRock"); - Tile::cloth_11 = (new ClothTile(TILE_CLOTH_11, 6)) + Tile::soulSand = (new SoulSandTile(TILE_SOUL_SAND, TEXTURE_SOULSAND)) ->init() - ->setDestroyTime(0.8f) - ->setSoundType(Tile::SOUND_CLOTH) - ->setDescriptionId("cloth"); + ->setDestroyTime(0.5f) + ->setSoundType(Tile::SOUND_SAND) + ->setDescriptionId("hellSand"); - Tile::cloth_21 = (new ClothTile(TILE_CLOTH_21, 5)) + Tile::glowstone = (new GlowstoneTile(TILE_GLOWSTONE, TEXTURE_GLOWSTONE, Material::stone)) ->init() - ->setDestroyTime(0.8f) - ->setSoundType(Tile::SOUND_CLOTH) - ->setDescriptionId("cloth"); + ->setDestroyTime(0.3f) + ->setLightEmission(1.0f) + ->setSoundType(Tile::SOUND_GLASS) + ->setDescriptionId("lightGem"); - Tile::cloth_31 = (new ClothTile(TILE_CLOTH_31, 4)) + Tile::web = (new Web(TILE_COBWEB, TEXTURE_COBWEB)) ->init() - ->setDestroyTime(0.8f) + ->setDestroyTime(4.0f) + //->setLightBlock(1) ->setSoundType(Tile::SOUND_CLOTH) - ->setDescriptionId("cloth"); + ->setDescriptionId("web"); - Tile::cloth_41 = (new ClothTile(TILE_CLOTH_41, 3)) - ->init() - ->setDestroyTime(0.8f) - ->setSoundType(Tile::SOUND_CLOTH) + // Great + Item::items[Tile::cloth->m_ID] = (new ClothItem(Tile::cloth->m_ID - C_MAX_TILES)) ->setDescriptionId("cloth"); - Tile::cloth_51 = (new ClothTile(TILE_CLOTH_51, 2)) - ->init() - ->setDestroyTime(0.8f) - ->setSoundType(Tile::SOUND_CLOTH) - ->setDescriptionId("cloth"); + Item::items[Tile::treeTrunk->m_ID] = (new AuxTileItem(Tile::treeTrunk->m_ID - C_MAX_TILES)) + ->setDescriptionId("log"); - Tile::cloth_61 = (new ClothTile(TILE_CLOTH_61, 1)) - ->init() - ->setDestroyTime(0.8f) - ->setSoundType(Tile::SOUND_CLOTH) - ->setDescriptionId("cloth"); + Item::items[Tile::stoneSlabHalf->m_ID] = (new SlabItem(Tile::stoneSlabHalf->m_ID - C_MAX_TILES)) + ->setDescriptionId("stoneSlab"); - // custom additions here + Item::items[Tile::leaves->m_ID] = (new AuxTileItem(Tile::leaves->m_ID - C_MAX_TILES)) + ->setDescriptionId("leaves"); - Tile::sapling = (new Sapling(TILE_SAPLING, TEXTURE_SAPLING)) - ->init() - ->setDestroyTime(0.0f) - ->setSoundType(Tile::SOUND_GRASS) + Item::items[Tile::sapling->m_ID] = (new AuxTileItem(Tile::sapling->m_ID - C_MAX_TILES)) ->setDescriptionId("sapling"); - Tile::sponge = (new SpongeTile(TILE_SPONGE, TEXTURE_SPONGE)) - ->init() - ->setDestroyTime(0.5f) - ->setSoundType(Tile::SOUND_CLOTH) - ->setDescriptionId("sponge"); - - Tile::cryingObsidian = (new Tile(TILE_OBSIDIAN_CRYING, TEXTURE_OBSIDIAN_CRYING, Material::stone)) - ->init() - ->setDestroyTime(10.0f) - ->setExplodeable(2000.0f) - ->setSoundType(Tile::SOUND_STONE) - ->setDescriptionId("cryingObsidian"); - - // Jolly - Tile::rocketLauncher = (new RocketLauncherTile(TILE_ROCKET_LAUNCHER)) - ->init() - ->setSoundType(Tile::SOUND_STONE) - ->setDescriptionId("rocketLauncher"); - - // @TODO: This is from 0.2.1, add this and get rid of the numbered cloth entries. - /*Item::items[Tile::cloth->m_ID] = (new ClothTileItem(Tile::cloth->m_ID - C_MAX_TILES)) - ->setDescriptionId("cloth"); - - Item::items[Tile::treeTrunk->m_ID] = (new AuxDataTileItem(Tile::treeTrunk->m_ID - C_MAX_TILES)) - ->setDescriptionId("log");*/ - for (int i = 0; i < C_MAX_TILES; i++) { if (Tile::tiles[i] && !Item::items[i]) @@ -1127,9 +1126,9 @@ const Tile::SoundType Tile::SOUND_GRASS ("grass", 0.5f, 1.0f), Tile::SOUND_STONE ("stone", 1.0f, 1.0f), Tile::SOUND_METAL ("stone", 1.0f, 1.5f), - Tile::SOUND_GLASS ("stone", 1.0f, 1.0f), + Tile::SOUND_GLASS ("stone", /*"glass",*/1.0f, 1.0f), Tile::SOUND_CLOTH ("cloth", 1.0f, 1.0f), - Tile::SOUND_SAND ("sand", 1.0f, 1.0f), + Tile::SOUND_SAND ("sand", /*"gravel",*/ 1.0f, 1.0f), Tile::SOUND_SILENT("", 1.0f, 1.0f); // @TODO: Refactor this so that Tile::fire is already a FireTile* etc @@ -1154,21 +1153,6 @@ Tile *Tile::stoneSlab, *Tile::stoneSlabHalf, *Tile::cloth, - *Tile::cloth_00, - *Tile::cloth_10, - *Tile::cloth_20, - *Tile::cloth_30, - *Tile::cloth_40, - *Tile::cloth_50, - *Tile::cloth_60, - *Tile::cloth_70, - *Tile::cloth_01, - *Tile::cloth_11, - *Tile::cloth_21, - *Tile::cloth_31, - *Tile::cloth_41, - *Tile::cloth_51, - *Tile::cloth_61, *Tile::flower, *Tile::rose, *Tile::mushroom1, @@ -1203,10 +1187,21 @@ Tile *Tile::door_iron, *Tile::info_updateGame1, *Tile::info_updateGame2, + // custom additions here *Tile::sapling, *Tile::sponge, *Tile::lapisBlock, *Tile::bookshelf, *Tile::mossStone, *Tile::cryingObsidian, - *Tile::rocketLauncher; + *Tile::rocketLauncher, + *Tile::cactus, + *Tile::tallGrass, + *Tile::deadBush, + *Tile::pumpkin, + *Tile::pumpkinLantern, + *Tile::netherrack, + *Tile::soulSand, + *Tile::glowstone, + *Tile::web, + *Tile::fence; diff --git a/source/world/tile/Tile.hpp b/source/world/tile/Tile.hpp index e3954a828..1b8993d23 100644 --- a/source/world/tile/Tile.hpp +++ b/source/world/tile/Tile.hpp @@ -165,21 +165,6 @@ class Tile * stoneSlab, * stoneSlabHalf, * cloth, - * cloth_00, - * cloth_10, - * cloth_20, - * cloth_30, - * cloth_40, - * cloth_50, - * cloth_60, - * cloth_70, - * cloth_01, - * cloth_11, - * cloth_21, - * cloth_31, - * cloth_41, - * cloth_51, - * cloth_61, * flower, * rose, * mushroom1, @@ -221,7 +206,17 @@ class Tile * bookshelf, * mossStone, * cryingObsidian, - * rocketLauncher; + * rocketLauncher, + * cactus, + * tallGrass, + * deadBush, + * pumpkin, + * pumpkinLantern, + * netherrack, + * soulSand, + * glowstone, + * web, + * fence; public: int m_TextureFrame; @@ -230,7 +225,7 @@ class Tile const SoundType* m_pSound; float field_28; Material* m_pMaterial; - float field_30; + float m_friction; float m_hardness; float m_blastResistance; AABB m_aabbReturned; diff --git a/source/world/tile/Web.cpp b/source/world/tile/Web.cpp new file mode 100644 index 000000000..a76834810 --- /dev/null +++ b/source/world/tile/Web.cpp @@ -0,0 +1,36 @@ +#include "Web.hpp" +#include "world/level/Level.hpp" + +Web::Web(int id, int texture) : Tile(id, texture, Material::web) +{ +} + +int Web::getRenderShape() const +{ + return SHAPE_CROSS; +} + +bool Web::isCubeShaped() const +{ + return false; +} + +bool Web::isSolidRender() const +{ + return false; +} + +void Web::entityInside(Level*, const TilePos& pos, Entity* entity) const +{ + entity->m_bIsInWeb = true; +} + +int Web::getResource(int x, Random* random) const +{ + return Item::string->m_itemID; +} + +AABB* Web::getAABB(const Level* level, const TilePos& pos) +{ + return nullptr; +} diff --git a/source/world/tile/Web.hpp b/source/world/tile/Web.hpp new file mode 100644 index 000000000..b0fc514b3 --- /dev/null +++ b/source/world/tile/Web.hpp @@ -0,0 +1,16 @@ +#pragma once + +#include "Tile.hpp" + +class Web : public Tile +{ +public: + Web(int id, int texture); + + AABB* getAABB(const Level*, const TilePos& pos) override; + virtual int getRenderShape() const override; + virtual bool isCubeShaped() const override; + virtual bool isSolidRender() const override; + void entityInside(Level*, const TilePos& pos, Entity*) const override; + int getResource(int x, Random* random) const override; +}; From 80fe2ca3c7b24d60c68ed1eeb8b44a746caf5362 Mon Sep 17 00:00:00 2001 From: EGAMatsu <58616438+EGAMatsu@users.noreply.github.com> Date: Sun, 28 Sep 2025 19:24:45 -0500 Subject: [PATCH 035/293] SDL 1.2 + PowerPC Support (#187) * Added Big Endian / PowerPC Support (Works on Power Mac G5!) * Overhauled SDL File Hierarchy * Overhauled and cleaned up SDL AppPlatform * Added Dummy SoundSystem * Partial Dreamcast support thanks to EGAMatsu --------- Co-authored-by: Brent <43089001+BrentDaMage@users.noreply.github.com> --- .github/workflows/build.yml | 105 +- .gitignore | 1 + CMakeLists.txt | 5 + build-wasm.bat | 2 +- build-wasm.sh | 2 +- compat/EndianDefinitions.h | 33 + compat/KeyCodes.hpp | 21 +- compat/PlatformDefinitions.h | 2 + compat/SDLKeyCodes.h | 46 +- platforms/CMakeLists.txt | 12 +- .../Configuration/Settings_macOS.xcconfig | 3 + .../Minecraft.xcodeproj/project.pbxproj | 1365 ++++++++++++----- .../xcschemes/MinecraftClient.SDL1.xcscheme | 90 ++ .../xcschemes/MinecraftClient.SDL2.xcscheme | 20 +- .../xcschemes/minecraftpe.xcscheme | 10 +- platforms/sdl/base/AppPlatform_sdl.cpp | 550 +++++++ platforms/sdl/base/AppPlatform_sdl.hpp | 87 ++ platforms/sdl/base/AppPlatform_sdl_base.cpp | 409 ----- platforms/sdl/base/AppPlatform_sdl_base.hpp | 92 -- platforms/sdl/desktop/AppPlatform_sdl.cpp | 238 --- platforms/sdl/desktop/AppPlatform_sdl.hpp | 27 - platforms/sdl/sdl1/.gitignore | 2 + platforms/sdl/sdl1/CMakeLists.txt | 36 + platforms/sdl/sdl1/base/AppPlatform_sdl1.cpp | 80 + platforms/sdl/sdl1/base/AppPlatform_sdl1.hpp | 51 + .../sdl1/desktop/AppPlatform_sdl1_desktop.cpp | 22 + .../sdl1/desktop/AppPlatform_sdl1_desktop.hpp | 17 + platforms/sdl/sdl1/main.cpp | 218 +++ platforms/sdl/{ => sdl2}/CMakeLists.txt | 17 +- platforms/sdl/{ => sdl2}/android/.gitignore | 0 .../sdl/{ => sdl2}/android/app/.gitignore | 0 .../sdl/{ => sdl2}/android/app/build.gradle | 6 +- .../{ => sdl2}/android/app/proguard-rules.pro | 0 .../android/app/src/main/AndroidManifest.xml | 0 .../app/src/main/ic_launcher-playstore.png | Bin .../reminecraftpe/ImmersiveModeStrategy.java | 0 .../io/github/reminecraftpe/MainActivity.java | 0 .../org/libsdl/app/LimitedSDLActivity.java | 0 .../drawable-v24/ic_launcher_foreground.xml | 0 .../res/drawable/ic_launcher_background.xml | 0 .../res/mipmap-anydpi-v26/ic_launcher.xml | 0 .../mipmap-anydpi-v26/ic_launcher_round.xml | 0 .../src/main/res/mipmap-hdpi/ic_launcher.webp | Bin .../res/mipmap-hdpi/ic_launcher_round.webp | Bin .../src/main/res/mipmap-mdpi/ic_launcher.webp | Bin .../res/mipmap-mdpi/ic_launcher_round.webp | Bin .../main/res/mipmap-xhdpi/ic_launcher.webp | Bin .../res/mipmap-xhdpi/ic_launcher_round.webp | Bin .../main/res/mipmap-xxhdpi/ic_launcher.webp | Bin .../res/mipmap-xxhdpi/ic_launcher_round.webp | Bin .../main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin .../res/mipmap-xxxhdpi/ic_launcher_round.webp | Bin .../app/src/main/res/values/strings.xml | 0 platforms/sdl/{ => sdl2}/android/build.gradle | 0 .../sdl/{ => sdl2}/android/gradle.properties | 0 .../android/gradle/wrapper/gradle-wrapper.jar | Bin .../gradle/wrapper/gradle-wrapper.properties | 0 platforms/sdl/{ => sdl2}/android/gradlew | 0 platforms/sdl/{ => sdl2}/android/gradlew.bat | 0 .../sdl/{ => sdl2}/android/settings.gradle | 0 platforms/sdl/sdl2/base/AppPlatform_sdl2.cpp | 175 +++ platforms/sdl/sdl2/base/AppPlatform_sdl2.hpp | 51 + .../sdl2/desktop/AppPlatform_sdl2_desktop.cpp | 28 + .../sdl2/desktop/AppPlatform_sdl2_desktop.hpp | 19 + .../AppPlatform_sdl2_emscripten.cpp} | 10 +- .../AppPlatform_sdl2_emscripten.hpp} | 6 +- .../sdl/{ => sdl2}/emscripten/wasm_shell.html | 0 platforms/sdl/{ => sdl2}/main.cpp | 50 +- platforms/sound/dummy/CMakeLists.txt | 12 + platforms/sound/dummy/CustomSoundSystem.hpp | 45 + platforms/sound/dummy/SoundSystemNull.cpp | 94 ++ platforms/sound/openal/SoundStreamAL.cpp | 18 +- platforms/sound/openal/SoundStreamAL.hpp | 2 + platforms/windows/minecraftcpp.sln | 121 +- .../windows/projects/Client/Client.vcxproj | 20 +- .../windows/projects/Common/Common.vcxproj | 16 + .../windows/projects/Directory.Build.props | 9 +- .../MinecraftClient.SDL1.vcxproj | 105 ++ .../MinecraftClient.SDL1.vcxproj.filters | 66 + .../MinecraftClient.SDL2.vcxproj | 12 +- .../MinecraftClient.SDL2.vcxproj.filters | 16 +- .../windows/projects/Network/Network.vcxproj | 1 + .../windows/projects/OpenGL/OpenGL.vcxproj | 16 + .../projects/Renderer/Renderer.vcxproj | 3 +- platforms/windows/projects/SDL/SDL.vcxproj | 102 ++ .../SDL.vcxproj.filters} | 9 +- platforms/windows/projects/SDL2/SDL2.vcxproj | 65 - .../windows/projects/World/World.vcxproj | 3 +- source/client/app/AppPlatform.cpp | 36 +- source/client/app/AppPlatform.hpp | 17 +- source/client/app/Minecraft.cpp | 30 +- source/client/app/Minecraft.hpp | 3 +- source/client/gui/components/TextInputBox.cpp | 52 +- source/client/model/Model.cpp | 5 +- source/client/options/Options.cpp | 3 + .../player/input/BuildActionIntention.hpp | 2 + source/client/renderer/FoliageColor.cpp | 11 +- source/client/renderer/GrassColor.cpp | 10 +- source/client/renderer/Tesselator.cpp | 11 +- .../entity/EntityRenderDispatcher.cpp | 18 + source/client/renderer/entity/MobRenderer.cpp | 5 + source/client/renderer/entity/MobRenderer.hpp | 1 + source/common/Utils.hpp | 3 + source/world/entity/Player.cpp | 8 +- source/world/item/Inventory.cpp | 8 +- thirdparty/GL/GL.hpp | 10 +- thirdparty/GL/GLExt.cpp | 8 +- thirdparty/SDL/SDL.h | 19 + thirdparty/SDL/SDL_gamecontroller.h | 71 + thirdparty/SDL/SDL_opengl.h | 18 + thirdparty/SDL2/SDL2.h | 9 - thirdparty/SDL2/SDL_opengl.h | 8 - thirdparty/raknet/Getche.cpp | 7 +- thirdparty/raknet/Getche.h | 6 +- thirdparty/raknet/RakNetSocket2.cpp | 6 +- thirdparty/raknet/SocketLayer.cpp | 11 +- thirdparty/stb_image/include | 2 +- tools/buildDC.sh | 5 + 118 files changed, 3600 insertions(+), 1446 deletions(-) create mode 100644 compat/EndianDefinitions.h create mode 100644 platforms/macos/projects/Minecraft/Minecraft.xcodeproj/xcshareddata/xcschemes/MinecraftClient.SDL1.xcscheme create mode 100644 platforms/sdl/base/AppPlatform_sdl.cpp create mode 100644 platforms/sdl/base/AppPlatform_sdl.hpp delete mode 100644 platforms/sdl/base/AppPlatform_sdl_base.cpp delete mode 100644 platforms/sdl/base/AppPlatform_sdl_base.hpp delete mode 100644 platforms/sdl/desktop/AppPlatform_sdl.cpp delete mode 100644 platforms/sdl/desktop/AppPlatform_sdl.hpp create mode 100644 platforms/sdl/sdl1/.gitignore create mode 100644 platforms/sdl/sdl1/CMakeLists.txt create mode 100644 platforms/sdl/sdl1/base/AppPlatform_sdl1.cpp create mode 100644 platforms/sdl/sdl1/base/AppPlatform_sdl1.hpp create mode 100644 platforms/sdl/sdl1/desktop/AppPlatform_sdl1_desktop.cpp create mode 100644 platforms/sdl/sdl1/desktop/AppPlatform_sdl1_desktop.hpp create mode 100644 platforms/sdl/sdl1/main.cpp rename platforms/sdl/{ => sdl2}/CMakeLists.txt (83%) rename platforms/sdl/{ => sdl2}/android/.gitignore (100%) rename platforms/sdl/{ => sdl2}/android/app/.gitignore (100%) rename platforms/sdl/{ => sdl2}/android/app/build.gradle (86%) rename platforms/sdl/{ => sdl2}/android/app/proguard-rules.pro (100%) rename platforms/sdl/{ => sdl2}/android/app/src/main/AndroidManifest.xml (100%) rename platforms/sdl/{ => sdl2}/android/app/src/main/ic_launcher-playstore.png (100%) rename platforms/sdl/{ => sdl2}/android/app/src/main/java/io/github/reminecraftpe/ImmersiveModeStrategy.java (100%) rename platforms/sdl/{ => sdl2}/android/app/src/main/java/io/github/reminecraftpe/MainActivity.java (100%) rename platforms/sdl/{ => sdl2}/android/app/src/main/java/org/libsdl/app/LimitedSDLActivity.java (100%) rename platforms/sdl/{ => sdl2}/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml (100%) rename platforms/sdl/{ => sdl2}/android/app/src/main/res/drawable/ic_launcher_background.xml (100%) rename platforms/sdl/{ => sdl2}/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml (100%) rename platforms/sdl/{ => sdl2}/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml (100%) rename platforms/sdl/{ => sdl2}/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp (100%) rename platforms/sdl/{ => sdl2}/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp (100%) rename platforms/sdl/{ => sdl2}/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp (100%) rename platforms/sdl/{ => sdl2}/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp (100%) rename platforms/sdl/{ => sdl2}/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp (100%) rename platforms/sdl/{ => sdl2}/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp (100%) rename platforms/sdl/{ => sdl2}/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp (100%) rename platforms/sdl/{ => sdl2}/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp (100%) rename platforms/sdl/{ => sdl2}/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp (100%) rename platforms/sdl/{ => sdl2}/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp (100%) rename platforms/sdl/{ => sdl2}/android/app/src/main/res/values/strings.xml (100%) rename platforms/sdl/{ => sdl2}/android/build.gradle (100%) rename platforms/sdl/{ => sdl2}/android/gradle.properties (100%) rename platforms/sdl/{ => sdl2}/android/gradle/wrapper/gradle-wrapper.jar (100%) rename platforms/sdl/{ => sdl2}/android/gradle/wrapper/gradle-wrapper.properties (100%) rename platforms/sdl/{ => sdl2}/android/gradlew (100%) rename platforms/sdl/{ => sdl2}/android/gradlew.bat (100%) rename platforms/sdl/{ => sdl2}/android/settings.gradle (100%) create mode 100644 platforms/sdl/sdl2/base/AppPlatform_sdl2.cpp create mode 100644 platforms/sdl/sdl2/base/AppPlatform_sdl2.hpp create mode 100644 platforms/sdl/sdl2/desktop/AppPlatform_sdl2_desktop.cpp create mode 100644 platforms/sdl/sdl2/desktop/AppPlatform_sdl2_desktop.hpp rename platforms/sdl/{emscripten/AppPlatform_sdl.cpp => sdl2/emscripten/AppPlatform_sdl2_emscripten.cpp} (69%) rename platforms/sdl/{emscripten/AppPlatform_sdl.hpp => sdl2/emscripten/AppPlatform_sdl2_emscripten.hpp} (57%) rename platforms/sdl/{ => sdl2}/emscripten/wasm_shell.html (100%) rename platforms/sdl/{ => sdl2}/main.cpp (89%) create mode 100644 platforms/sound/dummy/CMakeLists.txt create mode 100644 platforms/sound/dummy/CustomSoundSystem.hpp create mode 100644 platforms/sound/dummy/SoundSystemNull.cpp create mode 100644 platforms/windows/projects/MinecraftClient.SDL1/MinecraftClient.SDL1.vcxproj create mode 100644 platforms/windows/projects/MinecraftClient.SDL1/MinecraftClient.SDL1.vcxproj.filters create mode 100644 platforms/windows/projects/SDL/SDL.vcxproj rename platforms/windows/projects/{SDL2/SDL2.vcxproj.filters => SDL/SDL.vcxproj.filters} (70%) delete mode 100644 platforms/windows/projects/SDL2/SDL2.vcxproj create mode 100644 thirdparty/SDL/SDL.h create mode 100644 thirdparty/SDL/SDL_gamecontroller.h create mode 100644 thirdparty/SDL/SDL_opengl.h delete mode 100644 thirdparty/SDL2/SDL2.h delete mode 100644 thirdparty/SDL2/SDL_opengl.h create mode 100755 tools/buildDC.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 080fcd287..d3294e3cb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,7 +6,17 @@ on: jobs: linux: - name: Linux + strategy: + fail-fast: false + matrix: + include: + - name: SDL 2 + flags: '-DREMCPE_PLATFORM=sdl2' + packages: 'libsdl2-dev' + - name: SDL 1.2 + flags: '-DREMCPE_PLATFORM=sdl1' + packages: 'libsdl1.2-dev' + name: Linux (${{ matrix.name }}) runs-on: ubuntu-latest steps: - name: Checkout Repository @@ -20,12 +30,13 @@ jobs: build-essential \ cmake ninja-build \ libopenal-dev \ - libsdl2-dev zlib1g-dev + zlib1g-dev \ + ${{ matrix.packages }} - name: Build run: | mkdir build cd build - cmake -GNinja .. + cmake -GNinja ${{ matrix.flags }} .. cmake --build . wasm: name: WASM @@ -42,7 +53,19 @@ jobs: - name: Build run: ./build-wasm.sh macos: - name: macOS + strategy: + fail-fast: false + matrix: + include: + - name: SDL 2 + backend_name: 'SDL2' + packages: 'libsdl2' + # @NOTE: Uses SDL 1.2 compatibility layer in newer macOS versions, resulting in 30+ minutes spent building + # and installing said layer each time the action is run. We're not doing that. + #- name: SDL 1.2 + # backend_name: 'SDL1' + # packages: 'libsdl' + name: macOS (${{ matrix.name }}) runs-on: macos-latest steps: - name: Checkout Repository @@ -54,15 +77,14 @@ jobs: - name: Install Dependencies run: | port selfupdate - port install libsdl2 +universal - port install libpng +universal + port install ${{ matrix.packages }} +universal - name: Build macOS Archive run: | cd platforms/macos/projects/Minecraft - xcodebuild -scheme "MinecraftClient.SDL2" \ - -archivePath $RUNNER_TEMP/GitHubActions_MacOS_SDL2.xcarchive \ + xcodebuild -scheme "MinecraftClient.${{ matrix.backend_name }}" \ + -archivePath $RUNNER_TEMP/GitHubActions_MacOS_${{ matrix.backend_name }}.xcarchive \ -sdk macosx \ - -configuration "Release (Default)" \ + -configuration "Release [${{ matrix.backend_name }}] (Default)" \ -destination generic/platform=macOS \ GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_DEFINITIONS)' \ -quiet \ @@ -81,7 +103,7 @@ jobs: # xcodebuild -scheme "minecraftpe" \ # -archivePath $RUNNER_TEMP/GitHubActions_iOS.xcarchive \ # -sdk iphoneos \ - # -configuration "Release (iOS)" \ + # -configuration "Release [iOS] (Default)" \ # -destination generic/platform=iOS \ # GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_DEFINITIONS)' \ # -quiet \ @@ -91,8 +113,8 @@ jobs: fail-fast: false matrix: include: - - name: SDL - directory: platforms/sdl/android + - name: SDL 2 + directory: platforms/sdl/sdl2/android - name: Native directory: platforms/android/project name: Android (${{ matrix.name }}) @@ -113,31 +135,34 @@ jobs: cd ${{ matrix.directory }} ./gradlew build mingw: - strategy: - fail-fast: false - matrix: - include: - - name: Win32 - flags: "-DREMCPE_PLATFORM=windows" - - name: SDL - flags: "-DREMCPE_PLATFORM=sdl" - name: MinGW-w64 (${{ matrix.name }}) - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - with: - submodules: true - - name: Install Dependencies - run: | - sudo apt-get update - sudo apt-get install --no-install-recommends -y \ - build-essential \ - cmake ninja-build \ - mingw-w64 - - name: Build - run: | - mkdir build - cd build - cmake -GNinja -DCMAKE_TOOLCHAIN_FILE=../cmake/mingw-w64-toolchain.cmake ${{ matrix.flags }} .. - cmake --build . + strategy: + fail-fast: false + matrix: + include: + - name: Win32 + flags: '-DREMCPE_PLATFORM=windows' + - name: SDL2 + flags: "-DREMCPE_PLATFORM=sdl2" + # CMake can't find it + #- name: SDL 1.2 + # flags: "-DREMCPE_PLATFORM=sdl1" + name: MinGW-w64 (${{ matrix.name }}) + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + submodules: true + - name: Install Dependencies + run: | + sudo apt-get update + sudo apt-get install --no-install-recommends -y \ + build-essential \ + cmake ninja-build \ + mingw-w64 + - name: Build + run: | + mkdir build + cd build + cmake -GNinja -DCMAKE_TOOLCHAIN_FILE=../cmake/mingw-w64-toolchain.cmake ${{ matrix.flags }} .. + cmake --build . diff --git a/.gitignore b/.gitignore index 57fb80297..363d52ed8 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ bld/ [Oo]ut/ [Ll]og/ [Ll]ogs/ +.ignore/ # Visual Studio 2015/2017 cache/options directory .vs/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 283055c5f..1c4d132a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,3 +66,8 @@ if(EMSCRIPTEN) else() file(CREATE_LINK "${CMAKE_CURRENT_SOURCE_DIR}/game/assets" "${CMAKE_CURRENT_BINARY_DIR}/assets" SYMBOLIC) endif() + +#VBO Emulation +if(USE_GL_VBO_EMULATION) + add_compile_options(-DUSE_GL_VBO_EMULATION) +endif() \ No newline at end of file diff --git a/build-wasm.bat b/build-wasm.bat index 0a721f811..886149a6e 100644 --- a/build-wasm.bat +++ b/build-wasm.bat @@ -44,7 +44,7 @@ cmake --build . ::bundle echo * Copying bundle data over. copy reminecraftpe.* ..\dist -copy ..\..\platforms\sdl\emscripten\wasm_shell.html ..\dist\reminecraftpe.html +copy ..\..\platforms\sdl\sdl2\emscripten\wasm_shell.html ..\dist\reminecraftpe.html copy ..\..\thirdparty\coi-serviceworker\coi-serviceworker.min.js ..\dist ::for me only diff --git a/build-wasm.sh b/build-wasm.sh index 033140ec2..638906693 100755 --- a/build-wasm.sh +++ b/build-wasm.sh @@ -38,5 +38,5 @@ cmake --build . # Bundle cp reminecraftpe.* ../dist -cp ../../platforms/sdl/emscripten/wasm_shell.html ../dist/reminecraftpe.html +cp ../../platforms/sdl/sdl2/emscripten/wasm_shell.html ../dist/reminecraftpe.html cp ../../thirdparty/coi-serviceworker/coi-serviceworker.min.js ../dist diff --git a/compat/EndianDefinitions.h b/compat/EndianDefinitions.h new file mode 100644 index 000000000..5d54018fc --- /dev/null +++ b/compat/EndianDefinitions.h @@ -0,0 +1,33 @@ +// +// EndianDefinitions.h +// Minecraft +// +// Created by Brent on 9/14/25. +// +// + +#pragma once + +// @TODO: __BIG_ENDIAN__ might be Apple-specific + +#ifndef MC_ENDIANNESS_BIG +#if (defined(__BIG_ENDIAN__) && __BIG_ENDIAN__) || (defined(__powerpc__) && __powerpc__) +#define MC_ENDIANNESS_BIG 1 +#else +#define MC_ENDIANNESS_BIG 0 +#endif +#endif + +#ifndef MC_ENDIANNESS_LITTLE +#if defined(__LITTLE_ENDIAN__) && __LITTLE_ENDIAN__ +#define MC_ENDIANNESS_LITTLE 1 +#else +#define MC_ENDIANNESS_LITTLE 0 +#endif +#endif + +#if !MC_ENDIANNESS_BIG && !MC_ENDIANNESS_LITTLE +#undef MC_ENDIANNESS_LITTLE +// If we don't know what we are, default to little endian +#define MC_ENDIANNESS_LITTLE 1 +#endif \ No newline at end of file diff --git a/compat/KeyCodes.hpp b/compat/KeyCodes.hpp index f2316c5f1..125e38b4f 100644 --- a/compat/KeyCodes.hpp +++ b/compat/KeyCodes.hpp @@ -9,16 +9,15 @@ #pragma once #ifdef USE_SDL -#include "../thirdparty/SDL2/SDL2.h" - -// because SDL sucks and makes no sense and sets bit 1<<30 for some keycodes for some godamn reason -enum eSDLVirtualKeys -{ - #define CODE(x) SDLVK_ ## x, - #include "SDLKeyCodes.h" - #undef CODE -}; - + #include "thirdparty/SDL/SDL.h" + + // because SDL sucks and makes no sense and sets bit 1<<30 for some keycodes for some godamn reason + enum eSDLVirtualKeys + { + #define CODE(x) SDLVK_ ## x, + #include "SDLKeyCodes.h" + #undef CODE + }; #endif #ifdef _WIN32 @@ -38,4 +37,4 @@ enum eSDLVirtualKeys #define AKEYCODE_ARROW_LEFT AKEYCODE_DPAD_LEFT #define AKEYCODE_ARROW_RIGHT AKEYCODE_DPAD_RIGHT -#endif +#endif \ No newline at end of file diff --git a/compat/PlatformDefinitions.h b/compat/PlatformDefinitions.h index eecd4246b..d0aac412a 100644 --- a/compat/PlatformDefinitions.h +++ b/compat/PlatformDefinitions.h @@ -12,6 +12,8 @@ #include #endif +#include "EndianDefinitions.h" + /* Apple - Mac OS X / macOS */ #if (TARGET_OS_MAC && (TARGET_OS_OSX || !defined(TARGET_OS_OSX))) #define MC_PLATFORM_MAC 1 diff --git a/compat/SDLKeyCodes.h b/compat/SDLKeyCodes.h index 05edcb6a8..c8aef200b 100644 --- a/compat/SDLKeyCodes.h +++ b/compat/SDLKeyCodes.h @@ -7,7 +7,6 @@ CODE(SPACE) CODE(EXCLAIM) CODE(QUOTEDBL) CODE(HASH) -CODE(PERCENT) CODE(DOLLAR) CODE(AMPERSAND) CODE(QUOTE) @@ -81,8 +80,6 @@ CODE(F9) CODE(F10) CODE(F11) CODE(F12) -CODE(PRINTSCREEN) -CODE(SCROLLLOCK) CODE(PAUSE) CODE(INSERT) CODE(HOME) @@ -94,12 +91,34 @@ CODE(RIGHT) CODE(LEFT) CODE(DOWN) CODE(UP) -CODE(NUMLOCKCLEAR) CODE(KP_DIVIDE) CODE(KP_MULTIPLY) CODE(KP_MINUS) CODE(KP_PLUS) CODE(KP_ENTER) +CODE(KP_PERIOD) +CODE(POWER) +CODE(KP_EQUALS) +CODE(F13) +CODE(F14) +CODE(F15) +CODE(HELP) +CODE(MENU) +CODE(UNDO) +CODE(SYSREQ) +CODE(CLEAR) +CODE(LCTRL) +CODE(LSHIFT) +CODE(LALT) +CODE(RCTRL) +CODE(RSHIFT) +CODE(RALT) +CODE(MODE) +#if SDL_MAJOR_VERSION == 2 +CODE(PERCENT) +CODE(PRINTSCREEN) +CODE(SCROLLLOCK) +CODE(NUMLOCKCLEAR) CODE(KP_1) CODE(KP_2) CODE(KP_3) @@ -110,13 +129,7 @@ CODE(KP_7) CODE(KP_8) CODE(KP_9) CODE(KP_0) -CODE(KP_PERIOD) CODE(APPLICATION) -CODE(POWER) -CODE(KP_EQUALS) -CODE(F13) -CODE(F14) -CODE(F15) CODE(F16) CODE(F17) CODE(F18) @@ -127,12 +140,9 @@ CODE(F22) CODE(F23) CODE(F24) CODE(EXECUTE) -CODE(HELP) -CODE(MENU) CODE(SELECT) CODE(STOP) CODE(AGAIN) -CODE(UNDO) CODE(CUT) CODE(COPY) CODE(PASTE) @@ -143,9 +153,7 @@ CODE(VOLUMEDOWN) CODE(KP_COMMA) CODE(KP_EQUALSAS400) CODE(ALTERASE) -CODE(SYSREQ) CODE(CANCEL) -CODE(CLEAR) CODE(PRIOR) CODE(RETURN2) CODE(SEPARATOR) @@ -200,15 +208,8 @@ CODE(KP_BINARY) CODE(KP_OCTAL) CODE(KP_DECIMAL) CODE(KP_HEXADECIMAL) -CODE(LCTRL) -CODE(LSHIFT) -CODE(LALT) CODE(LGUI) -CODE(RCTRL) -CODE(RSHIFT) -CODE(RALT) CODE(RGUI) -CODE(MODE) CODE(AUDIONEXT) CODE(AUDIOPREV) CODE(AUDIOSTOP) @@ -234,6 +235,7 @@ CODE(KBDILLUMDOWN) CODE(KBDILLUMUP) CODE(EJECT) CODE(SLEEP) +#endif #ifdef SDLK_APP1 CODE(APP1) #endif diff --git a/platforms/CMakeLists.txt b/platforms/CMakeLists.txt index 6e32b4f15..99c82a5dc 100644 --- a/platforms/CMakeLists.txt +++ b/platforms/CMakeLists.txt @@ -1,13 +1,21 @@ project(reminecraftpe-platforms) # Select & Build -set(DEFAULT_PLATFORM "sdl") +set(DEFAULT_PLATFORM "sdl2") if(MCPE_WIN32) set(DEFAULT_PLATFORM "windows") endif() set(REMCPE_PLATFORM "${DEFAULT_PLATFORM}" CACHE STRING "ReMCPE Platform (Check /platforms)") message(STATUS "Selected Platform: ${REMCPE_PLATFORM}") -add_subdirectory("${REMCPE_PLATFORM}") + +# Add platform-specific subdirectory +if(REMCPE_PLATFORM STREQUAL "sdl1") + add_subdirectory("sdl/sdl1") +elseif(REMCPE_PLATFORM STREQUAL "sdl2") + add_subdirectory("sdl/sdl2") +else() + add_subdirectory("${REMCPE_PLATFORM}") +endif() # Load Sound add_subdirectory(sound) diff --git a/platforms/macos/projects/Configuration/Settings_macOS.xcconfig b/platforms/macos/projects/Configuration/Settings_macOS.xcconfig index cdf0363af..64132a190 100644 --- a/platforms/macos/projects/Configuration/Settings_macOS.xcconfig +++ b/platforms/macos/projects/Configuration/Settings_macOS.xcconfig @@ -24,3 +24,6 @@ VALID_ARCHS = $(VALID_ARCHS_MACOS) //ARCHS = $(ARCHS_MACOS) // Just use whatever Xcode is trying to use... ARCHS = $(ARCHS) + +BACKEND_SDL1 = USE_SDL1 STBI_NO_THREAD_LOCALS +BACKEND_SDL2 = USE_SDL2 \ No newline at end of file diff --git a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj index e04541310..b69d1b9f3 100644 --- a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj +++ b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj @@ -3,13 +3,10 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 45; objects = { /* Begin PBXBuildFile section */ - 84043C432E76627900B988F0 /* libRenderer.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8406FD292AF1814500B09C1D /* libRenderer.a */; }; - 84043C442E7663A000B988F0 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8489B3252A86E4B0004CA8EC /* OpenGL.framework */; }; - 84043C452E7663DB00B988F0 /* libZLib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84498A832AF18C7A005EF5A5 /* libZLib.a */; }; 8406FD2A2AF181B800B09C1D /* GL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD6542AC810620006A435 /* GL.cpp */; }; 8406FD2C2AF1820700B09C1D /* MinecraftPackets.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD63B2AC810620006A435 /* MinecraftPackets.hpp */; }; 8406FD2D2AF1820700B09C1D /* NetEventCallback.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD63D2AC810620006A435 /* NetEventCallback.hpp */; }; @@ -180,9 +177,8 @@ 8406FDD42AF182E700B09C1D /* WSAStartupSingleton.h in Headers */ = {isa = PBXBuildFile; fileRef = 840DD8452AC810630006A435 /* WSAStartupSingleton.h */; }; 8406FDD52AF182E700B09C1D /* XBox360Includes.h in Headers */ = {isa = PBXBuildFile; fileRef = 840DD8462AC810630006A435 /* XBox360Includes.h */; }; 84171E812B1A6227008B82E6 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84C4D86E2A872C0100323E33 /* OpenAL.framework */; }; - 841DD86A2AF8A99000AA3B66 /* LegacyCPPCompatibility.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 841DD8692AF8A99000AA3B66 /* LegacyCPPCompatibility.hpp */; }; - 841DD8772AF8AA7A00AA3B66 /* AppPlatform_sdl_base.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 841DD8722AF8AA7A00AA3B66 /* AppPlatform_sdl_base.cpp */; }; - 841DD8782AF8AA7A00AA3B66 /* AppPlatform_sdl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 841DD8752AF8AA7A00AA3B66 /* AppPlatform_sdl.cpp */; }; + 841DD8772AF8AA7A00AA3B66 /* AppPlatform_sdl2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 841DD8722AF8AA7A00AA3B66 /* AppPlatform_sdl2.cpp */; }; + 841DD8782AF8AA7A00AA3B66 /* AppPlatform_sdl2_desktop.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 841DD8752AF8AA7A00AA3B66 /* AppPlatform_sdl2_desktop.cpp */; }; 8420EF302B32B4EE0051910E /* libSystem.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 8420EF2F2B32B4EE0051910E /* libSystem.dylib */; settings = {ATTRIBUTES = (Weak, ); }; }; 8426106F2AE989720065905F /* MinecraftPackets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD63A2AC810620006A435 /* MinecraftPackets.cpp */; }; 842610702AE989720065905F /* NetEventCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD63C2AC810620006A435 /* NetEventCallback.cpp */; }; @@ -207,6 +203,19 @@ 8441F98F2DB4E911005977BD /* SoundSystemAL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8441F9862DB4E911005977BD /* SoundSystemAL.cpp */; }; 8441F9962DB4E911005977BD /* SoundSystemAL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8441F9862DB4E911005977BD /* SoundSystemAL.cpp */; }; 8443B6EA2A98675F0086730C /* libSDL2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8443B6E92A98675F0086730C /* libSDL2.a */; }; + 844496882E7668B0008CF2E0 /* libClient.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84B8AEE72AF188D8008DE93D /* libClient.a */; }; + 844496892E7668B0008CF2E0 /* libZLib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84498A832AF18C7A005EF5A5 /* libZLib.a */; }; + 8444968A2E7668B6008CF2E0 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84C4D86E2A872C0100323E33 /* OpenAL.framework */; }; + 8444968B2E7668BB008CF2E0 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8489B3252A86E4B0004CA8EC /* OpenGL.framework */; }; + 844496982E766960008CF2E0 /* AppPlatform_sdl1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 844496912E766960008CF2E0 /* AppPlatform_sdl1.cpp */; }; + 844496992E766960008CF2E0 /* AppPlatform_sdl1_desktop.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 844496952E766960008CF2E0 /* AppPlatform_sdl1_desktop.cpp */; }; + 8444969A2E766960008CF2E0 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 844496972E766960008CF2E0 /* main.cpp */; }; + 8444969C2E766C38008CF2E0 /* SoundStreamAL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8435BB182DCD47F400D38282 /* SoundStreamAL.cpp */; }; + 8444969D2E766C49008CF2E0 /* SoundSystemAL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8441F9862DB4E911005977BD /* SoundSystemAL.cpp */; }; + 8444969E2E766C59008CF2E0 /* stb_image_impl.c in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8E462B32FB33003F5B82 /* stb_image_impl.c */; }; + 844496A72E76792A008CF2E0 /* libSDLmain.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 844496A62E76792A008CF2E0 /* libSDLmain.a */; }; + 844496A82E767956008CF2E0 /* libSDL.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8444968C2E7668E5008CF2E0 /* libSDL.a */; }; + 844496AA2E767971008CF2E0 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 844496A92E767971008CF2E0 /* Cocoa.framework */; }; 8445E7A02D769329008DC834 /* EntityCategories.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8445E7952D769329008DC834 /* EntityCategories.cpp */; }; 8445E7A12D769329008DC834 /* EntityCategories.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 8445E7962D769329008DC834 /* EntityCategories.hpp */; }; 8445E7A22D769329008DC834 /* EntityType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8445E7972D769329008DC834 /* EntityType.cpp */; }; @@ -244,6 +253,7 @@ 84498A9B2AF18CDA005EF5A5 /* trees.c in Sources */ = {isa = PBXBuildFile; fileRef = 840DD8632AC810630006A435 /* trees.c */; }; 84498A9C2AF18CDA005EF5A5 /* uncompr.c in Sources */ = {isa = PBXBuildFile; fileRef = 840DD8652AC810630006A435 /* uncompr.c */; }; 84498A9D2AF18CDA005EF5A5 /* zutil.c in Sources */ = {isa = PBXBuildFile; fileRef = 840DD8682AC810630006A435 /* zutil.c */; }; + 84498AA02AF18D08005EF5A5 /* libZLib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84498A832AF18C7A005EF5A5 /* libZLib.a */; }; 84619B222AF1EDA300B0DE81 /* libZLib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84498A832AF18C7A005EF5A5 /* libZLib.a */; }; 84619B392AF1F73900B0DE81 /* GL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD6552AC810620006A435 /* GL.hpp */; }; 84619B3C2AF1FE4C00B0DE81 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84619B3B2AF1FE4C00B0DE81 /* OpenAL.framework */; }; @@ -1215,6 +1225,7 @@ 84CED5202E672826006BC585 /* ConvertWorldScreen.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84CED51E2E672826006BC585 /* ConvertWorldScreen.hpp */; }; 84CEF0032AE3C97D006C5829 /* EAGLView.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CEF0022AE3C97D006C5829 /* EAGLView.m */; }; 84D9A30E2AF18EC000B00AD3 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8489B3252A86E4B0004CA8EC /* OpenGL.framework */; }; + 84D9A30F2AF18EE700B00AD3 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8489B3252A86E4B0004CA8EC /* OpenGL.framework */; settings = {ATTRIBUTES = (Required, ); }; }; 84E0011B2AF39E84009B9555 /* BuildActionIntention.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E000FB2AF39E84009B9555 /* BuildActionIntention.hpp */; }; 84E0011C2AF39E84009B9555 /* CustomInputHolder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E000FC2AF39E84009B9555 /* CustomInputHolder.cpp */; }; 84E0011D2AF39E84009B9555 /* CustomInputHolder.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E000FD2AF39E84009B9555 /* CustomInputHolder.hpp */; }; @@ -1250,6 +1261,8 @@ 84E001B82AF3A3CB009B9555 /* SmoothFloat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E001B62AF3A3CB009B9555 /* SmoothFloat.cpp */; }; 84E001B92AF3A3CB009B9555 /* SmoothFloat.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E001B72AF3A3CB009B9555 /* SmoothFloat.hpp */; }; 84E001BB2AF3AF9B009B9555 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 84E001BA2AF3AF9B009B9555 /* MainWindow.xib */; }; + 84E105F82E85157F00FAB6C5 /* AppPlatform_sdl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E105F62E85157F00FAB6C5 /* AppPlatform_sdl.cpp */; }; + 84E105F92E85157F00FAB6C5 /* AppPlatform_sdl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E105F62E85157F00FAB6C5 /* AppPlatform_sdl.cpp */; }; 84E1C9BA2E7FDAE3007D2F5D /* birch_sapling.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E1C9B52E7FDAE3007D2F5D /* birch_sapling.png */; }; 84E1C9BB2E7FDAE3007D2F5D /* dead_bush.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E1C9B62E7FDAE3007D2F5D /* dead_bush.png */; }; 84E1C9BC2E7FDAE3007D2F5D /* fern.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E1C9B72E7FDAE3007D2F5D /* fern.png */; }; @@ -1300,6 +1313,7 @@ 84E78C8D2B58BB7400D515EF /* n_rocket_launcher.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E78C8A2B58BB7400D515EF /* n_rocket_launcher.png */; }; 84E78C8E2B58BB7400D515EF /* n_rocket.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E78C8B2B58BB7400D515EF /* n_rocket.png */; }; 84E78C902B58C18C00D515EF /* black.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E78C8F2B58C18C00D515EF /* black.png */; }; + 84E8DCE52E84ACBC00B30789 /* libRenderer.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8406FD292AF1814500B09C1D /* libRenderer.a */; }; 84EAE8DE2AF1EAA1000894E8 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84EAE8DD2AF1EAA1000894E8 /* UIKit.framework */; }; 84EAE8E02AF1EAA9000894E8 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84EAE8DF2AF1EAA9000894E8 /* CoreGraphics.framework */; }; 84EAE8E42AF1EABE000894E8 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84EAE8E32AF1EABE000894E8 /* OpenGLES.framework */; }; @@ -1418,19 +1432,26 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - 84043C412E76626D00B988F0 /* PBXContainerItemProxy */ = { + 842610802AE9898E0065905F /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 8489B08F2A86D4B2004CA8EC /* Project object */; proxyType = 1; - remoteGlobalIDString = 8406FD162AF1814500B09C1D; - remoteInfo = Renderer; + remoteGlobalIDString = 84FFBD7D2ACA2876005A8CCF; + remoteInfo = RakNet; }; - 842610802AE9898E0065905F /* PBXContainerItemProxy */ = { + 844496842E7668A1008CF2E0 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 8489B08F2A86D4B2004CA8EC /* Project object */; proxyType = 1; - remoteGlobalIDString = 84FFBD7D2ACA2876005A8CCF; - remoteInfo = RakNet; + remoteGlobalIDString = 84B8AE132AF188D8008DE93D; + remoteInfo = Client; + }; + 844496862E7668A1008CF2E0 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 8489B08F2A86D4B2004CA8EC /* Project object */; + proxyType = 1; + remoteGlobalIDString = 84498A762AF18C7A005EF5A5; + remoteInfo = ZLib; }; 84498A9E2AF18D01005EF5A5 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; @@ -1509,9 +1530,25 @@ remoteGlobalIDString = 84E4BFAD2AE9854B0023E16A; remoteInfo = Common; }; + 84E8DCE32E84ACB000B30789 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 8489B08F2A86D4B2004CA8EC /* Project object */; + proxyType = 1; + remoteGlobalIDString = 8406FD162AF1814500B09C1D; + remoteInfo = Renderer; + }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ + 844496742E76685C008CF2E0 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; 8489B0952A86D4B2004CA8EC /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -1524,6 +1561,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 8400360F2E89DADB00C14213 /* SDL_gamecontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_gamecontroller.h; sourceTree = ""; }; 8406FD292AF1814500B09C1D /* libRenderer.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRenderer.a; sourceTree = BUILT_PRODUCTS_DIR; }; 840DD5792AC810620006A435 /* KeyCodes.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = KeyCodes.hpp; sourceTree = ""; }; 840DD57A2AC810620006A435 /* SDLKeyCodes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLKeyCodes.h; sourceTree = ""; }; @@ -2135,7 +2173,7 @@ 840DD8442AC810630006A435 /* WSAStartupSingleton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WSAStartupSingleton.cpp; sourceTree = ""; }; 840DD8452AC810630006A435 /* WSAStartupSingleton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WSAStartupSingleton.h; sourceTree = ""; }; 840DD8462AC810630006A435 /* XBox360Includes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XBox360Includes.h; sourceTree = ""; }; - 840DD8482AC810630006A435 /* SDL2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL2.h; sourceTree = ""; }; + 840DD8482AC810630006A435 /* SDL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL.h; sourceTree = ""; }; 840DD8492AC810630006A435 /* SDL_opengl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_opengl.h; sourceTree = ""; }; 840DD84E2AC810630006A435 /* adler32.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = adler32.c; sourceTree = ""; }; 840DD84F2AC810630006A435 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = ""; }; @@ -2165,11 +2203,10 @@ 840DD8672AC810630006A435 /* zlib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zlib.h; sourceTree = ""; }; 840DD8682AC810630006A435 /* zutil.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zutil.c; sourceTree = ""; }; 840DD8692AC810630006A435 /* zutil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zutil.h; sourceTree = ""; }; - 841DD8692AF8A99000AA3B66 /* LegacyCPPCompatibility.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = LegacyCPPCompatibility.hpp; sourceTree = ""; }; - 841DD8722AF8AA7A00AA3B66 /* AppPlatform_sdl_base.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppPlatform_sdl_base.cpp; sourceTree = ""; }; - 841DD8732AF8AA7A00AA3B66 /* AppPlatform_sdl_base.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AppPlatform_sdl_base.hpp; sourceTree = ""; }; - 841DD8752AF8AA7A00AA3B66 /* AppPlatform_sdl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppPlatform_sdl.cpp; sourceTree = ""; }; - 841DD8762AF8AA7A00AA3B66 /* AppPlatform_sdl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AppPlatform_sdl.hpp; sourceTree = ""; }; + 841DD8722AF8AA7A00AA3B66 /* AppPlatform_sdl2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppPlatform_sdl2.cpp; sourceTree = ""; }; + 841DD8732AF8AA7A00AA3B66 /* AppPlatform_sdl2.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AppPlatform_sdl2.hpp; sourceTree = ""; }; + 841DD8752AF8AA7A00AA3B66 /* AppPlatform_sdl2_desktop.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppPlatform_sdl2_desktop.cpp; sourceTree = ""; }; + 841DD8762AF8AA7A00AA3B66 /* AppPlatform_sdl2_desktop.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AppPlatform_sdl2_desktop.hpp; sourceTree = ""; }; 8420EF2F2B32B4EE0051910E /* libSystem.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libSystem.dylib; path = usr/lib/libSystem.dylib; sourceTree = SDKROOT; }; 842610682AE988D30065905F /* libNetwork.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libNetwork.a; sourceTree = BUILT_PRODUCTS_DIR; }; 84336BA42B1EB50E00097DB0 /* Settings_iOS.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Settings_iOS.xcconfig; path = ../Configuration/Settings_iOS.xcconfig; sourceTree = ""; }; @@ -2181,6 +2218,16 @@ 8441F9852DB4E911005977BD /* CustomSoundSystem.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CustomSoundSystem.hpp; sourceTree = ""; }; 8441F9862DB4E911005977BD /* SoundSystemAL.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SoundSystemAL.cpp; sourceTree = ""; }; 8443B6E92A98675F0086730C /* libSDL2.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libSDL2.a; path = /opt/local/lib/libSDL2.a; sourceTree = ""; }; + 844496762E76685C008CF2E0 /* MinecraftClient.SDL1 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = MinecraftClient.SDL1; sourceTree = BUILT_PRODUCTS_DIR; }; + 8444968C2E7668E5008CF2E0 /* libSDL.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libSDL.a; path = ../../../../../../../../../opt/local/libexec/libsdl12/lib/libSDL.a; sourceTree = ""; }; + 844496912E766960008CF2E0 /* AppPlatform_sdl1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppPlatform_sdl1.cpp; sourceTree = ""; }; + 844496922E766960008CF2E0 /* AppPlatform_sdl1.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AppPlatform_sdl1.hpp; sourceTree = ""; }; + 844496952E766960008CF2E0 /* AppPlatform_sdl1_desktop.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppPlatform_sdl1_desktop.cpp; sourceTree = ""; }; + 844496962E766960008CF2E0 /* AppPlatform_sdl1_desktop.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AppPlatform_sdl1_desktop.hpp; sourceTree = ""; }; + 844496972E766960008CF2E0 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; + 8444969B2E766977008CF2E0 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = ""; }; + 844496A62E76792A008CF2E0 /* libSDLmain.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libSDLmain.a; path = ../../../../../../../../../opt/local/libexec/libsdl12/lib/libSDLmain.a; sourceTree = ""; }; + 844496A92E767971008CF2E0 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; 8445E7952D769329008DC834 /* EntityCategories.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EntityCategories.cpp; sourceTree = ""; }; 8445E7962D769329008DC834 /* EntityCategories.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = EntityCategories.hpp; sourceTree = ""; }; 8445E7972D769329008DC834 /* EntityType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EntityType.cpp; sourceTree = ""; }; @@ -2195,6 +2242,7 @@ 84498A832AF18C7A005EF5A5 /* libZLib.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libZLib.a; sourceTree = BUILT_PRODUCTS_DIR; }; 84619B3B2AF1FE4C00B0DE81 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; 84619B3D2AF1FEB700B0DE81 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; + 8466BD092E774DCD00DDDFC4 /* EndianDefinitions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EndianDefinitions.h; sourceTree = ""; }; 8470AF282BE9B60900BCA54E /* EntityType.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = EntityType.hpp; sourceTree = ""; }; 8470AF292BE9B60A00BCA54E /* MobFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MobFactory.cpp; sourceTree = ""; }; 8470AF2A2BE9B60A00BCA54E /* MobFactory.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MobFactory.hpp; sourceTree = ""; }; @@ -2301,7 +2349,6 @@ 8488C0892B1EDD4F001AEC4F /* ShowKeyboardView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ShowKeyboardView.mm; sourceTree = ""; }; 8489B0972A86D4B2004CA8EC /* MinecraftClient.SDL2 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = MinecraftClient.SDL2; sourceTree = BUILT_PRODUCTS_DIR; }; 8489B3212A86E464004CA8EC /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - 8489B3232A86E46A004CA8EC /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; 8489B3252A86E4B0004CA8EC /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; }; 848CBD0F2AFD847C007634F6 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; 8492591D2AD8FCFC0081F5B9 /* minecraftpe.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = minecraftpe.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -2310,8 +2357,8 @@ 8492594E2AD8FD4F0081F5B9 /* minecraftpeAppDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = minecraftpeAppDelegate.mm; sourceTree = ""; }; 8492594F2AD8FD4F0081F5B9 /* minecraftpeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = minecraftpeViewController.h; sourceTree = ""; }; 849259502AD8FD4F0081F5B9 /* minecraftpeViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = minecraftpeViewController.mm; sourceTree = ""; }; - 849259522AD8FD4F0081F5B9 /* Shader.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = Shader.fsh; path = Shaders/Shader.fsh; sourceTree = ""; }; - 849259532AD8FD4F0081F5B9 /* Shader.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = Shader.vsh; path = Shaders/Shader.vsh; sourceTree = ""; }; + 849259522AD8FD4F0081F5B9 /* Shader.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Shader.fsh; path = Shaders/Shader.fsh; sourceTree = ""; }; + 849259532AD8FD4F0081F5B9 /* Shader.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Shader.vsh; path = Shaders/Shader.vsh; sourceTree = ""; }; 8492595F2AD8FDCB0081F5B9 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 849259612AD8FDD10081F5B9 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 849259632AD8FDD90081F5B9 /* minecraftpe-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "minecraftpe-Info.plist"; sourceTree = ""; }; @@ -2927,6 +2974,8 @@ 84E001B62AF3A3CB009B9555 /* SmoothFloat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SmoothFloat.cpp; sourceTree = ""; }; 84E001B72AF3A3CB009B9555 /* SmoothFloat.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SmoothFloat.hpp; sourceTree = ""; }; 84E001BA2AF3AF9B009B9555 /* MainWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = ""; }; + 84E105F62E85157F00FAB6C5 /* AppPlatform_sdl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppPlatform_sdl.cpp; sourceTree = ""; }; + 84E105F72E85157F00FAB6C5 /* AppPlatform_sdl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AppPlatform_sdl.hpp; sourceTree = ""; }; 84E1C9B52E7FDAE3007D2F5D /* birch_sapling.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = birch_sapling.png; sourceTree = ""; }; 84E1C9B62E7FDAE3007D2F5D /* dead_bush.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = dead_bush.png; sourceTree = ""; }; 84E1C9B72E7FDAE3007D2F5D /* fern.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = fern.png; sourceTree = ""; }; @@ -2977,6 +3026,9 @@ 84EAE8F02AF1EAFA000894E8 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = ""; }; 84EAE8F12AF1EAFA000894E8 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; 84ED99D42AFF12D1003B6AF0 /* minecraftpe.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = minecraftpe.entitlements; sourceTree = ""; }; + 84EDD07A2E76E2B600375AEF /* LegacyCPP.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = LegacyCPP.hpp; sourceTree = ""; }; + 84EDD07B2E76E2B600375AEF /* LegacyCPP_Compat.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = LegacyCPP_Compat.hpp; sourceTree = ""; }; + 84EDD07C2E76E2B600375AEF /* LegacyCPP_Info.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = LegacyCPP_Info.hpp; sourceTree = ""; }; 84FFBD7E2ACA2876005A8CCF /* libRakNet.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRakNet.a; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -2994,8 +3046,22 @@ buildActionMask = 2147483647; files = ( 84CCBC992E618BD400E251AF /* libCommon.a in Frameworks */, - 84CCBC9A2E618BD400E251AF /* libWorld.a in Frameworks */, 842610882AE98A4C0065905F /* libRakNet.a in Frameworks */, + 84CCBC9A2E618BD400E251AF /* libWorld.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 844496732E76685C008CF2E0 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 844496882E7668B0008CF2E0 /* libClient.a in Frameworks */, + 844496892E7668B0008CF2E0 /* libZLib.a in Frameworks */, + 8444968A2E7668B6008CF2E0 /* OpenAL.framework in Frameworks */, + 8444968B2E7668BB008CF2E0 /* OpenGL.framework in Frameworks */, + 844496AA2E767971008CF2E0 /* Cocoa.framework in Frameworks */, + 844496A82E767956008CF2E0 /* libSDL.a in Frameworks */, + 844496A72E76792A008CF2E0 /* libSDLmain.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3011,9 +3077,9 @@ buildActionMask = 2147483647; files = ( 84B8AF8B2AF18ACF008DE93D /* libClient.a in Frameworks */, - 84043C452E7663DB00B988F0 /* libZLib.a in Frameworks */, + 84498AA02AF18D08005EF5A5 /* libZLib.a in Frameworks */, 84171E812B1A6227008B82E6 /* OpenAL.framework in Frameworks */, - 84043C442E7663A000B988F0 /* OpenGL.framework in Frameworks */, + 84D9A30F2AF18EE700B00AD3 /* OpenGL.framework in Frameworks */, 8443B6EA2A98675F0086730C /* libSDL2.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -3028,8 +3094,8 @@ 84EAE8DE2AF1EAA1000894E8 /* UIKit.framework in Frameworks */, 849259202AD8FCFC0081F5B9 /* Foundation.framework in Frameworks */, 84EAE8E02AF1EAA9000894E8 /* CoreGraphics.framework in Frameworks */, - 84619B3C2AF1FE4C00B0DE81 /* OpenAL.framework in Frameworks */, 84EAE8E42AF1EABE000894E8 /* OpenGLES.framework in Frameworks */, + 84619B3C2AF1FE4C00B0DE81 /* OpenAL.framework in Frameworks */, 848CBD102AFD847C007634F6 /* AVFoundation.framework in Frameworks */, 84619B3E2AF1FEB700B0DE81 /* QuartzCore.framework in Frameworks */, ); @@ -3049,7 +3115,7 @@ files = ( 84B8AF872AF18A2C008DE93D /* libCommon.a in Frameworks */, 84B8AF882AF18A2C008DE93D /* libNetwork.a in Frameworks */, - 84043C432E76627900B988F0 /* libRenderer.a in Frameworks */, + 84E8DCE52E84ACBC00B30789 /* libRenderer.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3089,10 +3155,13 @@ 840DD5782AC810620006A435 /* compat */ = { isa = PBXGroup; children = ( + 84EDD07A2E76E2B600375AEF /* LegacyCPP.hpp */, + 84EDD07B2E76E2B600375AEF /* LegacyCPP_Compat.hpp */, + 84EDD07C2E76E2B600375AEF /* LegacyCPP_Info.hpp */, 840DD5792AC810620006A435 /* KeyCodes.hpp */, - 841DD8692AF8A99000AA3B66 /* LegacyCPPCompatibility.hpp */, 84C0D8022B15A1D0007E1E76 /* PlatformDefinitions.h */, 840DD57A2AC810620006A435 /* SDLKeyCodes.h */, + 8466BD092E774DCD00DDDFC4 /* EndianDefinitions.h */, ); name = compat; path = ../../../../compat; @@ -3859,7 +3928,7 @@ children = ( 840DD7312AC810620006A435 /* GL */, 840DD7392AC810620006A435 /* raknet */, - 840DD8472AC810630006A435 /* SDL2 */, + 840DD8472AC810630006A435 /* SDL */, 84AA8C802B32FB32003F5B82 /* stb_image */, 840DD84D2AC810630006A435 /* zlib */, ); @@ -4150,13 +4219,14 @@ path = raknet; sourceTree = ""; }; - 840DD8472AC810630006A435 /* SDL2 */ = { + 840DD8472AC810630006A435 /* SDL */ = { isa = PBXGroup; children = ( - 840DD8482AC810630006A435 /* SDL2.h */, + 840DD8482AC810630006A435 /* SDL.h */, + 8400360F2E89DADB00C14213 /* SDL_gamecontroller.h */, 840DD8492AC810630006A435 /* SDL_opengl.h */, ); - path = SDL2; + path = SDL; sourceTree = ""; }; 840DD84D2AC810630006A435 /* zlib */ = { @@ -4208,8 +4278,8 @@ 841DD8712AF8AA7A00AA3B66 /* base */ = { isa = PBXGroup; children = ( - 841DD8722AF8AA7A00AA3B66 /* AppPlatform_sdl_base.cpp */, - 841DD8732AF8AA7A00AA3B66 /* AppPlatform_sdl_base.hpp */, + 841DD8722AF8AA7A00AA3B66 /* AppPlatform_sdl2.cpp */, + 841DD8732AF8AA7A00AA3B66 /* AppPlatform_sdl2.hpp */, ); path = base; sourceTree = ""; @@ -4217,8 +4287,8 @@ 841DD8742AF8AA7A00AA3B66 /* desktop */ = { isa = PBXGroup; children = ( - 841DD8752AF8AA7A00AA3B66 /* AppPlatform_sdl.cpp */, - 841DD8762AF8AA7A00AA3B66 /* AppPlatform_sdl.hpp */, + 841DD8752AF8AA7A00AA3B66 /* AppPlatform_sdl2_desktop.cpp */, + 841DD8762AF8AA7A00AA3B66 /* AppPlatform_sdl2_desktop.hpp */, ); path = desktop; sourceTree = ""; @@ -4260,6 +4330,35 @@ path = sound; sourceTree = ""; }; + 8444968E2E766960008CF2E0 /* sdl1 */ = { + isa = PBXGroup; + children = ( + 844496902E766960008CF2E0 /* base */, + 8444969B2E766977008CF2E0 /* CMakeLists.txt */, + 844496942E766960008CF2E0 /* desktop */, + 844496972E766960008CF2E0 /* main.cpp */, + ); + path = sdl1; + sourceTree = ""; + }; + 844496902E766960008CF2E0 /* base */ = { + isa = PBXGroup; + children = ( + 844496912E766960008CF2E0 /* AppPlatform_sdl1.cpp */, + 844496922E766960008CF2E0 /* AppPlatform_sdl1.hpp */, + ); + path = base; + sourceTree = ""; + }; + 844496942E766960008CF2E0 /* desktop */ = { + isa = PBXGroup; + children = ( + 844496952E766960008CF2E0 /* AppPlatform_sdl1_desktop.cpp */, + 844496962E766960008CF2E0 /* AppPlatform_sdl1_desktop.hpp */, + ); + path = desktop; + sourceTree = ""; + }; 8470AF422BE9B8B600BCA54E /* environment */ = { isa = PBXGroup; children = ( @@ -4462,6 +4561,7 @@ 84AAF6422AF18B9500BD67F4 /* libOpenGL.a */, 84498A832AF18C7A005EF5A5 /* libZLib.a */, 84CCBC452E61849800E251AF /* libNBT.a */, + 844496762E76685C008CF2E0 /* MinecraftClient.SDL1 */, ); name = Products; sourceTree = ""; @@ -4469,10 +4569,12 @@ 8489B31E2A86E428004CA8EC /* Frameworks */ = { isa = PBXGroup; children = ( - 84899AF72B32B7F50046B6D1 /* iOS */, - 8489B3232A86E46A004CA8EC /* AppKit.framework */, + 844496A92E767971008CF2E0 /* Cocoa.framework */, 8489B3212A86E464004CA8EC /* Foundation.framework */, + 84899AF72B32B7F50046B6D1 /* iOS */, + 8444968C2E7668E5008CF2E0 /* libSDL.a */, 8443B6E92A98675F0086730C /* libSDL2.a */, + 844496A62E76792A008CF2E0 /* libSDLmain.a */, 84C4D86E2A872C0100323E33 /* OpenAL.framework */, 8489B3252A86E4B0004CA8EC /* OpenGL.framework */, ); @@ -4585,40 +4687,40 @@ children = ( 84B1E02D2E04FD4500ED000A /* ArrowRenderer.cpp */, 84B1E02E2E04FD4500ED000A /* ArrowRenderer.hpp */, - 84AA8BA02B32F3F3003F5B82 /* ChickenRenderer.cpp */, 84AA8BA12B32F3F3003F5B82 /* ChickenRenderer.hpp */, - 84AA8BA22B32F3F3003F5B82 /* CowRenderer.cpp */, + 84AA8BA02B32F3F3003F5B82 /* ChickenRenderer.cpp */, 84AA8BA32B32F3F3003F5B82 /* CowRenderer.hpp */, - 84AA8BA42B32F3F3003F5B82 /* CreeperRenderer.cpp */, + 84AA8BA22B32F3F3003F5B82 /* CowRenderer.cpp */, 84AA8BA52B32F3F3003F5B82 /* CreeperRenderer.hpp */, - 84AA8BA62B32F3F3003F5B82 /* EntityRenderDispatcher.cpp */, + 84AA8BA42B32F3F3003F5B82 /* CreeperRenderer.cpp */, 84AA8BA72B32F3F3003F5B82 /* EntityRenderDispatcher.hpp */, - 84AA8BA82B32F3F3003F5B82 /* EntityRenderer.cpp */, + 84AA8BA62B32F3F3003F5B82 /* EntityRenderDispatcher.cpp */, 84AA8BA92B32F3F3003F5B82 /* EntityRenderer.hpp */, - 84AA8BAA2B32F3F3003F5B82 /* FallingTileRenderer.cpp */, + 84AA8BA82B32F3F3003F5B82 /* EntityRenderer.cpp */, 84AA8BAB2B32F3F3003F5B82 /* FallingTileRenderer.hpp */, - 84AA8BAC2B32F3F3003F5B82 /* HumanoidMobRenderer.cpp */, + 84AA8BAA2B32F3F3003F5B82 /* FallingTileRenderer.cpp */, 84AA8BAD2B32F3F3003F5B82 /* HumanoidMobRenderer.hpp */, - 84AA8BAE2B32F3F3003F5B82 /* ItemRenderer.cpp */, + 84AA8BAC2B32F3F3003F5B82 /* HumanoidMobRenderer.cpp */, 84AA8BAF2B32F3F3003F5B82 /* ItemRenderer.hpp */, - 84AA8BB02B32F3F3003F5B82 /* ItemSpriteRenderer.cpp */, + 84AA8BAE2B32F3F3003F5B82 /* ItemRenderer.cpp */, 84AA8BB12B32F3F3003F5B82 /* ItemSpriteRenderer.hpp */, - 84AA8BB22B32F3F3003F5B82 /* MobRenderer.cpp */, + 84AA8BB02B32F3F3003F5B82 /* ItemSpriteRenderer.cpp */, 84AA8BB32B32F3F3003F5B82 /* MobRenderer.hpp */, - 84AA8BB42B32F3F3003F5B82 /* PigRenderer.cpp */, + 84AA8BB22B32F3F3003F5B82 /* MobRenderer.cpp */, 84AA8BB52B32F3F3003F5B82 /* PigRenderer.hpp */, - 84E78C7D2B58B5CC00D515EF /* RocketRenderer.cpp */, + 84AA8BB42B32F3F3003F5B82 /* PigRenderer.cpp */, 84E78C7E2B58B5CC00D515EF /* RocketRenderer.hpp */, - 84AA8BB62B32F3F3003F5B82 /* SheepFurRenderer.cpp */, + 84E78C7D2B58B5CC00D515EF /* RocketRenderer.cpp */, 84AA8BB72B32F3F3003F5B82 /* SheepFurRenderer.hpp */, - 84AA8BB82B32F3F3003F5B82 /* SheepRenderer.cpp */, + 84AA8BB62B32F3F3003F5B82 /* SheepFurRenderer.cpp */, 84AA8BB92B32F3F3003F5B82 /* SheepRenderer.hpp */, - 84AA8BBC2B32F3F3003F5B82 /* SpiderRenderer.cpp */, + 84AA8BB82B32F3F3003F5B82 /* SheepRenderer.cpp */, 84AA8BBD2B32F3F3003F5B82 /* SpiderRenderer.hpp */, - 84AA8BBE2B32F3F3003F5B82 /* TntRenderer.cpp */, + 84AA8BBC2B32F3F3003F5B82 /* SpiderRenderer.cpp */, 84AA8BBF2B32F3F3003F5B82 /* TntRenderer.hpp */, - 84AA8BC02B32F3F3003F5B82 /* TripodCameraRenderer.cpp */, + 84AA8BBE2B32F3F3003F5B82 /* TntRenderer.cpp */, 84AA8BC12B32F3F3003F5B82 /* TripodCameraRenderer.hpp */, + 84AA8BC02B32F3F3003F5B82 /* TripodCameraRenderer.cpp */, ); path = entity; sourceTree = ""; @@ -5372,7 +5474,16 @@ path = mob; sourceTree = ""; }; - 84EAE8E82AF1EAFA000894E8 /* sdl */ = { + 84E105F52E85155F00FAB6C5 /* base */ = { + isa = PBXGroup; + children = ( + 84E105F62E85157F00FAB6C5 /* AppPlatform_sdl.cpp */, + 84E105F72E85157F00FAB6C5 /* AppPlatform_sdl.hpp */, + ); + path = base; + sourceTree = ""; + }; + 84E8DCE22E849A1600B30789 /* sdl2 */ = { isa = PBXGroup; children = ( 841DD8712AF8AA7A00AA3B66 /* base */, @@ -5380,6 +5491,16 @@ 841DD8742AF8AA7A00AA3B66 /* desktop */, 84EAE8F12AF1EAFA000894E8 /* main.cpp */, ); + path = sdl2; + sourceTree = ""; + }; + 84EAE8E82AF1EAFA000894E8 /* sdl */ = { + isa = PBXGroup; + children = ( + 84E105F52E85155F00FAB6C5 /* base */, + 8444968E2E766960008CF2E0 /* sdl1 */, + 84E8DCE22E849A1600B30789 /* sdl2 */, + ); path = sdl; sourceTree = ""; }; @@ -5751,7 +5872,6 @@ 8406FD3A2AF1823700B09C1D /* Util.hpp in Headers */, 8406FD3B2AF1823700B09C1D /* Utils.hpp in Headers */, 84E001B92AF3A3CB009B9555 /* SmoothFloat.hpp in Headers */, - 841DD86A2AF8A99000AA3B66 /* LegacyCPPCompatibility.hpp in Headers */, 84C0D8032B15A1D0007E1E76 /* PlatformDefinitions.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -5950,14 +6070,33 @@ ); dependencies = ( 84CCBC8E2E6186CD00E251AF /* PBXTargetDependency */, - 84CCBC902E6186D000E251AF /* PBXTargetDependency */, 842610812AE9898E0065905F /* PBXTargetDependency */, + 84CCBC902E6186D000E251AF /* PBXTargetDependency */, ); name = Network; productName = Network; productReference = 842610682AE988D30065905F /* libNetwork.a */; productType = "com.apple.product-type.library.static"; }; + 844496752E76685C008CF2E0 /* MinecraftClient.SDL1 */ = { + isa = PBXNativeTarget; + buildConfigurationList = 844496832E76685C008CF2E0 /* Build configuration list for PBXNativeTarget "MinecraftClient.SDL1" */; + buildPhases = ( + 844496722E76685C008CF2E0 /* Sources */, + 844496732E76685C008CF2E0 /* Frameworks */, + 844496742E76685C008CF2E0 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + 844496852E7668A1008CF2E0 /* PBXTargetDependency */, + 844496872E7668A1008CF2E0 /* PBXTargetDependency */, + ); + name = MinecraftClient.SDL1; + productName = MinecraftClient.SDL1; + productReference = 844496762E76685C008CF2E0 /* MinecraftClient.SDL1 */; + productType = "com.apple.product-type.tool"; + }; 84498A762AF18C7A005EF5A5 /* ZLib */ = { isa = PBXNativeTarget; buildConfigurationList = 84498A7D2AF18C7A005EF5A5 /* Build configuration list for PBXNativeTarget "ZLib" */; @@ -6044,7 +6183,7 @@ dependencies = ( 84B8AF842AF18A25008DE93D /* PBXTargetDependency */, 84B8AF862AF18A25008DE93D /* PBXTargetDependency */, - 84043C422E76626D00B988F0 /* PBXTargetDependency */, + 84E8DCE42E84ACB000B30789 /* PBXTargetDependency */, ); name = Client; productName = Client; @@ -6142,7 +6281,7 @@ }; }; buildConfigurationList = 8489B0922A86D4B2004CA8EC /* Build configuration list for PBXProject "Minecraft" */; - compatibilityVersion = "Xcode 3.2"; + compatibilityVersion = "Xcode 3.1"; developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( @@ -6152,22 +6291,19 @@ mainGroup = 8489B08E2A86D4B2004CA8EC; productRefGroup = 8489B0982A86D4B2004CA8EC /* Products */; projectDirPath = ""; - projectRoots = ( - "", - ../../../.., - ../../../../source, - ); + projectRoot = ""; targets = ( 8489B0962A86D4B2004CA8EC /* MinecraftClient.SDL2 */, + 844496752E76685C008CF2E0 /* MinecraftClient.SDL1 */, 8492591C2AD8FCFC0081F5B9 /* minecraftpe */, 84B8AE132AF188D8008DE93D /* Client */, 84E4BFAD2AE9854B0023E16A /* Common */, 84CCBC442E61849800E251AF /* NBT */, 842610672AE988D30065905F /* Network */, + 84FFBD7D2ACA2876005A8CCF /* RakNet */, 8406FD162AF1814500B09C1D /* Renderer */, 84BF62FE2AF1859D008A9995 /* World */, 84AAF5972AF18B9500BD67F4 /* OpenGL */, - 84FFBD7D2ACA2876005A8CCF /* RakNet */, 84498A762AF18C7A005EF5A5 /* ZLib */, ); }; @@ -6683,6 +6819,20 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 844496722E76685C008CF2E0 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8444969A2E766960008CF2E0 /* main.cpp in Sources */, + 844496982E766960008CF2E0 /* AppPlatform_sdl1.cpp in Sources */, + 844496992E766960008CF2E0 /* AppPlatform_sdl1_desktop.cpp in Sources */, + 84E105F92E85157F00FAB6C5 /* AppPlatform_sdl.cpp in Sources */, + 8444969C2E766C38008CF2E0 /* SoundStreamAL.cpp in Sources */, + 8444969D2E766C49008CF2E0 /* SoundSystemAL.cpp in Sources */, + 8444969E2E766C59008CF2E0 /* stb_image_impl.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 84498A7A2AF18C7A005EF5A5 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -6709,12 +6859,13 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 84EAE8F72AF1EAFA000894E8 /* main.cpp in Sources */, - 841DD8772AF8AA7A00AA3B66 /* AppPlatform_sdl_base.cpp in Sources */, - 841DD8782AF8AA7A00AA3B66 /* AppPlatform_sdl.cpp in Sources */, 8435BB192DCD47F400D38282 /* SoundStreamAL.cpp in Sources */, - 8441F9962DB4E911005977BD /* SoundSystemAL.cpp in Sources */, + 84EAE8F72AF1EAFA000894E8 /* main.cpp in Sources */, + 841DD8772AF8AA7A00AA3B66 /* AppPlatform_sdl2.cpp in Sources */, + 84E105F82E85157F00FAB6C5 /* AppPlatform_sdl.cpp in Sources */, + 841DD8782AF8AA7A00AA3B66 /* AppPlatform_sdl2_desktop.cpp in Sources */, 84AA8E802B32FB33003F5B82 /* stb_image_impl.c in Sources */, + 8441F9962DB4E911005977BD /* SoundSystemAL.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -7196,16 +7347,21 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ - 84043C422E76626D00B988F0 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 8406FD162AF1814500B09C1D /* Renderer */; - targetProxy = 84043C412E76626D00B988F0 /* PBXContainerItemProxy */; - }; 842610812AE9898E0065905F /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 84FFBD7D2ACA2876005A8CCF /* RakNet */; targetProxy = 842610802AE9898E0065905F /* PBXContainerItemProxy */; }; + 844496852E7668A1008CF2E0 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 84B8AE132AF188D8008DE93D /* Client */; + targetProxy = 844496842E7668A1008CF2E0 /* PBXContainerItemProxy */; + }; + 844496872E7668A1008CF2E0 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 84498A762AF18C7A005EF5A5 /* ZLib */; + targetProxy = 844496862E7668A1008CF2E0 /* PBXContainerItemProxy */; + }; 84498A9F2AF18D01005EF5A5 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 84498A762AF18C7A005EF5A5 /* ZLib */; @@ -7261,6 +7417,11 @@ target = 84E4BFAD2AE9854B0023E16A /* Common */; targetProxy = 84CCBC9B2E618BEB00E251AF /* PBXContainerItemProxy */; }; + 84E8DCE42E84ACB000B30789 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 8406FD162AF1814500B09C1D /* Renderer */; + targetProxy = 84E8DCE32E84ACB000B30789 /* PBXContainerItemProxy */; + }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ @@ -7284,47 +7445,47 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ - 8406FD242AF1814500B09C1D /* Debug (Default) */ = { + 8406FD242AF1814500B09C1D /* Debug [SDL2] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = Renderer; }; - name = "Debug (Default)"; + name = "Debug [SDL2] (Default)"; }; - 8406FD252AF1814500B09C1D /* Release (Default) */ = { + 8406FD252AF1814500B09C1D /* Release [SDL2] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = Renderer; }; - name = "Release (Default)"; + name = "Release [SDL2] (Default)"; }; - 8406FD262AF1814500B09C1D /* Release (x86) */ = { + 8406FD262AF1814500B09C1D /* Release [SDL2] (x86) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = Renderer; }; - name = "Release (x86)"; + name = "Release [SDL2] (x86)"; }; - 8406FD272AF1814500B09C1D /* Release (PPC) */ = { + 8406FD272AF1814500B09C1D /* Release [SDL1] (PPC) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = Renderer; }; - name = "Release (PPC)"; + name = "Release [SDL1] (PPC)"; }; - 8406FD282AF1814500B09C1D /* Release (x86-PPC) */ = { + 8406FD282AF1814500B09C1D /* Release [SDL1] (x86-PPC) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = Renderer; }; - name = "Release (x86-PPC)"; + name = "Release [SDL1] (x86-PPC)"; }; - 840FD8C92AA565FB009EB349 /* Release (x86) */ = { + 840FD8C92AA565FB009EB349 /* Release [SDL2] (x86) */ = { isa = XCBuildConfiguration; baseConfigurationReference = 84336BA82B1EB88500097DB0 /* Settings_macOS.xcconfig */; buildSettings = { @@ -7360,7 +7521,7 @@ ENABLE_STRICT_OBJC_MSGSEND = YES; FRAMEWORK_SEARCH_PATHS = ( "$(LOCAL_LIBRARY_DIR)/Frameworks", - "\"$(DEVELOPER_FRAMEWORKS_DIR)\"", + "\\\"$(DEVELOPER_FRAMEWORKS_DIR)\\\"", ); GCC_FAST_MATH = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; @@ -7387,11 +7548,11 @@ MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; RAKNET_PATH = "$(MC_ROOT)/thirdparty/raknet/"; - VALID_ARCHS = "i386 x86_64"; + VALID_ARCHS = "$(ARCHS_MACOS_X86)"; }; - name = "Release (x86)"; + name = "Release [SDL2] (x86)"; }; - 840FD8CA2AA565FB009EB349 /* Release (x86) */ = { + 840FD8CA2AA565FB009EB349 /* Release [SDL2] (x86) */ = { isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; @@ -7401,9 +7562,9 @@ ); PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Release (x86)"; + name = "Release [SDL2] (x86)"; }; - 840FD8CB2AA56676009EB349 /* Release (PPC) */ = { + 840FD8CB2AA56676009EB349 /* Release [SDL1] (PPC) */ = { isa = XCBuildConfiguration; baseConfigurationReference = 84336BA82B1EB88500097DB0 /* Settings_macOS.xcconfig */; buildSettings = { @@ -7439,9 +7600,13 @@ ENABLE_STRICT_OBJC_MSGSEND = YES; FRAMEWORK_SEARCH_PATHS = ( "$(LOCAL_LIBRARY_DIR)/Frameworks", - "\"$(DEVELOPER_FRAMEWORKS_DIR)\"", + "\\\"$(DEVELOPER_FRAMEWORKS_DIR)\\\"", ); GCC_FAST_MATH = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(BACKEND_SDL1)", + "$(inherited)", + ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; @@ -7466,11 +7631,11 @@ MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; RAKNET_PATH = "$(MC_ROOT)/thirdparty/raknet/"; - VALID_ARCHS = "ppc ppc64 ppc7400 ppc970"; + VALID_ARCHS = "$(ARCHS_MACOS_PPC)"; }; - name = "Release (PPC)"; + name = "Release [SDL1] (PPC)"; }; - 840FD8CC2AA56676009EB349 /* Release (PPC) */ = { + 840FD8CC2AA56676009EB349 /* Release [SDL1] (PPC) */ = { isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; @@ -7480,9 +7645,9 @@ ); PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Release (PPC)"; + name = "Release [SDL1] (PPC)"; }; - 840FD8CD2AA566AB009EB349 /* Release (x86-PPC) */ = { + 840FD8CD2AA566AB009EB349 /* Release [SDL1] (x86-PPC) */ = { isa = XCBuildConfiguration; baseConfigurationReference = 84336BA82B1EB88500097DB0 /* Settings_macOS.xcconfig */; buildSettings = { @@ -7518,9 +7683,13 @@ ENABLE_STRICT_OBJC_MSGSEND = YES; FRAMEWORK_SEARCH_PATHS = ( "$(LOCAL_LIBRARY_DIR)/Frameworks", - "\"$(DEVELOPER_FRAMEWORKS_DIR)\"", + "\\\"$(DEVELOPER_FRAMEWORKS_DIR)\\\"", ); GCC_FAST_MATH = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(BACKEND_SDL1)", + "$(inherited)", + ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; @@ -7545,11 +7714,11 @@ MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; RAKNET_PATH = "$(MC_ROOT)/thirdparty/raknet/"; - VALID_ARCHS = "i386 ppc ppc64 ppc7400 ppc970 x86_64"; + VALID_ARCHS = "$(ARCHS_MACOS_X86) $(ARCHS_MACOS_PPC)"; }; - name = "Release (x86-PPC)"; + name = "Release [SDL1] (x86-PPC)"; }; - 840FD8CE2AA566AB009EB349 /* Release (x86-PPC) */ = { + 840FD8CE2AA566AB009EB349 /* Release [SDL1] (x86-PPC) */ = { isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; @@ -7559,89 +7728,166 @@ ); PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Release (x86-PPC)"; + name = "Release [SDL1] (x86-PPC)"; }; - 842610692AE988D30065905F /* Debug (Default) */ = { + 842610692AE988D30065905F /* Debug [SDL2] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Debug (Default)"; + name = "Debug [SDL2] (Default)"; }; - 8426106A2AE988D30065905F /* Release (Default) */ = { + 8426106A2AE988D30065905F /* Release [SDL2] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Release (Default)"; + name = "Release [SDL2] (Default)"; }; - 8426106B2AE988D30065905F /* Release (x86) */ = { + 8426106B2AE988D30065905F /* Release [SDL2] (x86) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Release (x86)"; + name = "Release [SDL2] (x86)"; }; - 8426106C2AE988D30065905F /* Release (PPC) */ = { + 8426106C2AE988D30065905F /* Release [SDL1] (PPC) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Release (PPC)"; + name = "Release [SDL1] (PPC)"; }; - 8426106D2AE988D30065905F /* Release (x86-PPC) */ = { + 8426106D2AE988D30065905F /* Release [SDL1] (x86-PPC) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Release (x86-PPC)"; + name = "Release [SDL1] (x86-PPC)"; + }; + 8444967C2E76685C008CF2E0 /* Debug [SDL2] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + /opt/local/libexec/libsdl12/lib, + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Debug [SDL2] (Default)"; + }; + 8444967D2E76685C008CF2E0 /* Debug [iOS] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + /opt/local/libexec/libsdl12/lib, + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Debug [iOS] (Default)"; + }; + 8444967E2E76685C008CF2E0 /* Release [SDL2] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + /opt/local/libexec/libsdl12/lib, + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Release [SDL2] (Default)"; + }; + 8444967F2E76685C008CF2E0 /* Release [iOS] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + /opt/local/libexec/libsdl12/lib, + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Release [iOS] (Default)"; + }; + 844496802E76685C008CF2E0 /* Release [SDL2] (x86) */ = { + isa = XCBuildConfiguration; + buildSettings = { + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + /opt/local/libexec/libsdl12/lib, + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Release [SDL2] (x86)"; }; - 84498A7E2AF18C7A005EF5A5 /* Debug (Default) */ = { + 844496812E76685C008CF2E0 /* Release [SDL1] (PPC) */ = { + isa = XCBuildConfiguration; + buildSettings = { + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + /opt/local/libexec/libsdl12/lib, + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Release [SDL1] (PPC)"; + }; + 844496822E76685C008CF2E0 /* Release [SDL1] (x86-PPC) */ = { + isa = XCBuildConfiguration; + buildSettings = { + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + /opt/local/libexec/libsdl12/lib, + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Release [SDL1] (x86-PPC)"; + }; + 84498A7E2AF18C7A005EF5A5 /* Debug [SDL2] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = ZLib; }; - name = "Debug (Default)"; + name = "Debug [SDL2] (Default)"; }; - 84498A7F2AF18C7A005EF5A5 /* Release (Default) */ = { + 84498A7F2AF18C7A005EF5A5 /* Release [SDL2] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = ZLib; }; - name = "Release (Default)"; + name = "Release [SDL2] (Default)"; }; - 84498A802AF18C7A005EF5A5 /* Release (x86) */ = { + 84498A802AF18C7A005EF5A5 /* Release [SDL2] (x86) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = ZLib; }; - name = "Release (x86)"; + name = "Release [SDL2] (x86)"; }; - 84498A812AF18C7A005EF5A5 /* Release (PPC) */ = { + 84498A812AF18C7A005EF5A5 /* Release [SDL1] (PPC) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = ZLib; }; - name = "Release (PPC)"; + name = "Release [SDL1] (PPC)"; }; - 84498A822AF18C7A005EF5A5 /* Release (x86-PPC) */ = { + 84498A822AF18C7A005EF5A5 /* Release [SDL1] (x86-PPC) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = ZLib; }; - name = "Release (x86-PPC)"; + name = "Release [SDL1] (x86-PPC)"; }; - 84619B232AF1F32500B0DE81 /* Debug (iOS) */ = { + 84619B232AF1F32500B0DE81 /* Debug [iOS] (Default) */ = { isa = XCBuildConfiguration; baseConfigurationReference = 84336BA52B1EB57E00097DB0 /* Settings_iOS_Debug.xcconfig */; buildSettings = { @@ -7677,7 +7923,7 @@ ENABLE_TESTABILITY = YES; FRAMEWORK_SEARCH_PATHS = ( "$(LOCAL_LIBRARY_DIR)/Frameworks", - "\"$(DEVELOPER_FRAMEWORKS_DIR)\"", + "\\\"$(DEVELOPER_FRAMEWORKS_DIR)\\\"", ); GCC_FAST_MATH = YES; GCC_OPTIMIZATION_LEVEL = 0; @@ -7706,11 +7952,11 @@ MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; RAKNET_PATH = "$(MC_ROOT)/thirdparty/raknet/"; - VALID_ARCHS = "armv6 armv7 armv7s arm64"; + VALID_ARCHS = "$(ARCHS_IOS)"; }; - name = "Debug (iOS)"; + name = "Debug [iOS] (Default)"; }; - 84619B242AF1F32500B0DE81 /* Debug (iOS) */ = { + 84619B242AF1F32500B0DE81 /* Debug [iOS] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; @@ -7720,87 +7966,87 @@ ); PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Debug (iOS)"; + name = "Debug [iOS] (Default)"; }; - 84619B252AF1F32500B0DE81 /* Debug (iOS) */ = { + 84619B252AF1F32500B0DE81 /* Debug [iOS] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Debug (iOS)"; + name = "Debug [iOS] (Default)"; }; - 84619B262AF1F32500B0DE81 /* Debug (iOS) */ = { + 84619B262AF1F32500B0DE81 /* Debug [iOS] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_ENTITLEMENTS = $MC_ROOT/platforms/ios/minecraftpe.entitlements; INFOPLIST_FILE = "$(MC_ROOT)platforms/ios/minecraftpe-Info.plist"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", - "\"$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/usr/lib/arc\"", + "\\\"$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/usr/lib/arc\\\"", ); PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; - name = "Debug (iOS)"; + name = "Debug [iOS] (Default)"; }; - 84619B272AF1F32500B0DE81 /* Debug (iOS) */ = { + 84619B272AF1F32500B0DE81 /* Debug [iOS] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Debug (iOS)"; + name = "Debug [iOS] (Default)"; }; - 84619B282AF1F32500B0DE81 /* Debug (iOS) */ = { + 84619B282AF1F32500B0DE81 /* Debug [iOS] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Debug (iOS)"; + name = "Debug [iOS] (Default)"; }; - 84619B292AF1F32500B0DE81 /* Debug (iOS) */ = { + 84619B292AF1F32500B0DE81 /* Debug [iOS] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = Renderer; }; - name = "Debug (iOS)"; + name = "Debug [iOS] (Default)"; }; - 84619B2A2AF1F32500B0DE81 /* Debug (iOS) */ = { + 84619B2A2AF1F32500B0DE81 /* Debug [iOS] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = World; }; - name = "Debug (iOS)"; + name = "Debug [iOS] (Default)"; }; - 84619B2B2AF1F32500B0DE81 /* Debug (iOS) */ = { + 84619B2B2AF1F32500B0DE81 /* Debug [iOS] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = Client; }; - name = "Debug (iOS)"; + name = "Debug [iOS] (Default)"; }; - 84619B2C2AF1F32500B0DE81 /* Debug (iOS) */ = { + 84619B2C2AF1F32500B0DE81 /* Debug [iOS] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = OpenGL; }; - name = "Debug (iOS)"; + name = "Debug [iOS] (Default)"; }; - 84619B2D2AF1F32500B0DE81 /* Debug (iOS) */ = { + 84619B2D2AF1F32500B0DE81 /* Debug [iOS] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = ZLib; }; - name = "Debug (iOS)"; + name = "Debug [iOS] (Default)"; }; - 84619B2E2AF1F33A00B0DE81 /* Release (iOS) */ = { + 84619B2E2AF1F33A00B0DE81 /* Release [iOS] (Default) */ = { isa = XCBuildConfiguration; baseConfigurationReference = 84336BA42B1EB50E00097DB0 /* Settings_iOS.xcconfig */; buildSettings = { @@ -7834,7 +8080,7 @@ ENABLE_STRICT_OBJC_MSGSEND = YES; FRAMEWORK_SEARCH_PATHS = ( "$(LOCAL_LIBRARY_DIR)/Frameworks", - "\"$(DEVELOPER_FRAMEWORKS_DIR)\"", + "\\\"$(DEVELOPER_FRAMEWORKS_DIR)\\\"", ); GCC_FAST_MATH = YES; "GCC_THUMB_SUPPORT[arch=armv6]" = ""; @@ -7861,11 +8107,11 @@ MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; RAKNET_PATH = "$(MC_ROOT)/thirdparty/raknet/"; - VALID_ARCHS = "armv6 armv7 armv7s arm64"; + VALID_ARCHS = "$(ARCHS_IOS)"; }; - name = "Release (iOS)"; + name = "Release [iOS] (Default)"; }; - 84619B2F2AF1F33A00B0DE81 /* Release (iOS) */ = { + 84619B2F2AF1F33A00B0DE81 /* Release [iOS] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; @@ -7875,89 +8121,89 @@ ); PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Release (iOS)"; + name = "Release [iOS] (Default)"; }; - 84619B302AF1F33A00B0DE81 /* Release (iOS) */ = { + 84619B302AF1F33A00B0DE81 /* Release [iOS] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Release (iOS)"; + name = "Release [iOS] (Default)"; }; - 84619B312AF1F33A00B0DE81 /* Release (iOS) */ = { + 84619B312AF1F33A00B0DE81 /* Release [iOS] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_ENTITLEMENTS = $MC_ROOT/platforms/ios/minecraftpe.entitlements; INFOPLIST_FILE = "$(MC_ROOT)platforms/ios/minecraftpe-Info.plist"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", - "\"$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/usr/lib/arc\"", + "\\\"$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/usr/lib/arc\\\"", ); OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; PRODUCT_NAME = "$(TARGET_NAME)"; VALIDATE_PRODUCT = YES; WRAPPER_EXTENSION = app; }; - name = "Release (iOS)"; + name = "Release [iOS] (Default)"; }; - 84619B322AF1F33A00B0DE81 /* Release (iOS) */ = { + 84619B322AF1F33A00B0DE81 /* Release [iOS] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Release (iOS)"; + name = "Release [iOS] (Default)"; }; - 84619B332AF1F33A00B0DE81 /* Release (iOS) */ = { + 84619B332AF1F33A00B0DE81 /* Release [iOS] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Release (iOS)"; + name = "Release [iOS] (Default)"; }; - 84619B342AF1F33A00B0DE81 /* Release (iOS) */ = { + 84619B342AF1F33A00B0DE81 /* Release [iOS] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = Renderer; }; - name = "Release (iOS)"; + name = "Release [iOS] (Default)"; }; - 84619B352AF1F33A00B0DE81 /* Release (iOS) */ = { + 84619B352AF1F33A00B0DE81 /* Release [iOS] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = World; }; - name = "Release (iOS)"; + name = "Release [iOS] (Default)"; }; - 84619B362AF1F33A00B0DE81 /* Release (iOS) */ = { + 84619B362AF1F33A00B0DE81 /* Release [iOS] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = Client; }; - name = "Release (iOS)"; + name = "Release [iOS] (Default)"; }; - 84619B372AF1F33A00B0DE81 /* Release (iOS) */ = { + 84619B372AF1F33A00B0DE81 /* Release [iOS] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = OpenGL; }; - name = "Release (iOS)"; + name = "Release [iOS] (Default)"; }; - 84619B382AF1F33A00B0DE81 /* Release (iOS) */ = { + 84619B382AF1F33A00B0DE81 /* Release [iOS] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = ZLib; }; - name = "Release (iOS)"; + name = "Release [iOS] (Default)"; }; - 8489B09C2A86D4B2004CA8EC /* Debug (Default) */ = { + 8489B09C2A86D4B2004CA8EC /* Debug [SDL2] (Default) */ = { isa = XCBuildConfiguration; baseConfigurationReference = 84336BA92B1EB9C200097DB0 /* Settings_macOS_Debug.xcconfig */; buildSettings = { @@ -7994,7 +8240,7 @@ ENABLE_TESTABILITY = YES; FRAMEWORK_SEARCH_PATHS = ( "$(LOCAL_LIBRARY_DIR)/Frameworks", - "\"$(DEVELOPER_FRAMEWORKS_DIR)\"", + "\\\"$(DEVELOPER_FRAMEWORKS_DIR)\\\"", ); GCC_FAST_MATH = YES; GCC_OPTIMIZATION_LEVEL = 0; @@ -8024,9 +8270,9 @@ MTL_FAST_MATH = YES; RAKNET_PATH = "$(MC_ROOT)/thirdparty/raknet/"; }; - name = "Debug (Default)"; + name = "Debug [SDL2] (Default)"; }; - 8489B09D2A86D4B2004CA8EC /* Release (Default) */ = { + 8489B09D2A86D4B2004CA8EC /* Release [SDL2] (Default) */ = { isa = XCBuildConfiguration; baseConfigurationReference = 84336BA82B1EB88500097DB0 /* Settings_macOS.xcconfig */; buildSettings = { @@ -8061,7 +8307,7 @@ ENABLE_STRICT_OBJC_MSGSEND = YES; FRAMEWORK_SEARCH_PATHS = ( "$(LOCAL_LIBRARY_DIR)/Frameworks", - "\"$(DEVELOPER_FRAMEWORKS_DIR)\"", + "\\\"$(DEVELOPER_FRAMEWORKS_DIR)\\\"", ); GCC_FAST_MATH = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; @@ -8089,9 +8335,9 @@ MTL_FAST_MATH = YES; RAKNET_PATH = "$(MC_ROOT)/thirdparty/raknet/"; }; - name = "Release (Default)"; + name = "Release [SDL2] (Default)"; }; - 8489B09F2A86D4B2004CA8EC /* Debug (Default) */ = { + 8489B09F2A86D4B2004CA8EC /* Debug [SDL2] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; @@ -8101,9 +8347,9 @@ ); PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Debug (Default)"; + name = "Debug [SDL2] (Default)"; }; - 8489B0A02A86D4B2004CA8EC /* Release (Default) */ = { + 8489B0A02A86D4B2004CA8EC /* Release [SDL2] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; @@ -8113,9 +8359,9 @@ ); PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Release (Default)"; + name = "Release [SDL2] (Default)"; }; - 8492593E2AD8FCFD0081F5B9 /* Debug (Default) */ = { + 8492593E2AD8FCFD0081F5B9 /* Debug [SDL2] (Default) */ = { isa = XCBuildConfiguration; baseConfigurationReference = 84336BA52B1EB57E00097DB0 /* Settings_iOS_Debug.xcconfig */; buildSettings = { @@ -8123,14 +8369,14 @@ INFOPLIST_FILE = "$(MC_ROOT)platforms/ios/minecraftpe-Info.plist"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", - "\"$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/usr/lib/arc\"", + "\\\"$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/usr/lib/arc\\\"", ); PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; - name = "Debug (Default)"; + name = "Debug [SDL2] (Default)"; }; - 8492593F2AD8FCFD0081F5B9 /* Release (Default) */ = { + 8492593F2AD8FCFD0081F5B9 /* Release [SDL2] (Default) */ = { isa = XCBuildConfiguration; baseConfigurationReference = 84336BA42B1EB50E00097DB0 /* Settings_iOS.xcconfig */; buildSettings = { @@ -8138,15 +8384,15 @@ INFOPLIST_FILE = "$(MC_ROOT)platforms/ios/minecraftpe-Info.plist"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", - "\"$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/usr/lib/arc\"", + "\\\"$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/usr/lib/arc\\\"", ); PRODUCT_NAME = "$(TARGET_NAME)"; VALIDATE_PRODUCT = YES; WRAPPER_EXTENSION = app; }; - name = "Release (Default)"; + name = "Release [SDL2] (Default)"; }; - 849259402AD8FCFD0081F5B9 /* Release (x86) */ = { + 849259402AD8FCFD0081F5B9 /* Release [SDL2] (x86) */ = { isa = XCBuildConfiguration; baseConfigurationReference = 84336BA42B1EB50E00097DB0 /* Settings_iOS.xcconfig */; buildSettings = { @@ -8154,14 +8400,14 @@ INFOPLIST_FILE = "$(MC_ROOT)platforms/ios/minecraftpe-Info.plist"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", - "\"$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/usr/lib/arc\"", + "\\\"$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/usr/lib/arc\\\"", ); PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; - name = "Release (x86)"; + name = "Release [SDL2] (x86)"; }; - 849259412AD8FCFD0081F5B9 /* Release (PPC) */ = { + 849259412AD8FCFD0081F5B9 /* Release [SDL1] (PPC) */ = { isa = XCBuildConfiguration; baseConfigurationReference = 84336BA42B1EB50E00097DB0 /* Settings_iOS.xcconfig */; buildSettings = { @@ -8169,14 +8415,14 @@ INFOPLIST_FILE = "$(MC_ROOT)platforms/ios/minecraftpe-Info.plist"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", - "\"$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/usr/lib/arc\"", + "\\\"$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/usr/lib/arc\\\"", ); PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; - name = "Release (PPC)"; + name = "Release [SDL1] (PPC)"; }; - 849259422AD8FCFD0081F5B9 /* Release (x86-PPC) */ = { + 849259422AD8FCFD0081F5B9 /* Release [SDL1] (x86-PPC) */ = { isa = XCBuildConfiguration; baseConfigurationReference = 84336BA42B1EB50E00097DB0 /* Settings_iOS.xcconfig */; buildSettings = { @@ -8184,268 +8430,631 @@ INFOPLIST_FILE = "$(MC_ROOT)platforms/ios/minecraftpe-Info.plist"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", - "\"$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/usr/lib/arc\"", + "\\\"$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/usr/lib/arc\\\"", ); PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; - name = "Release (x86-PPC)"; + name = "Release [SDL1] (x86-PPC)"; }; - 84AAF63D2AF18B9500BD67F4 /* Debug (Default) */ = { + 84AAF63D2AF18B9500BD67F4 /* Debug [SDL2] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = OpenGL; }; - name = "Debug (Default)"; + name = "Debug [SDL2] (Default)"; }; - 84AAF63E2AF18B9500BD67F4 /* Release (Default) */ = { + 84AAF63E2AF18B9500BD67F4 /* Release [SDL2] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = OpenGL; }; - name = "Release (Default)"; + name = "Release [SDL2] (Default)"; }; - 84AAF63F2AF18B9500BD67F4 /* Release (x86) */ = { + 84AAF63F2AF18B9500BD67F4 /* Release [SDL2] (x86) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = OpenGL; }; - name = "Release (x86)"; + name = "Release [SDL2] (x86)"; }; - 84AAF6402AF18B9500BD67F4 /* Release (PPC) */ = { + 84AAF6402AF18B9500BD67F4 /* Release [SDL1] (PPC) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = OpenGL; }; - name = "Release (PPC)"; + name = "Release [SDL1] (PPC)"; }; - 84AAF6412AF18B9500BD67F4 /* Release (x86-PPC) */ = { + 84AAF6412AF18B9500BD67F4 /* Release [SDL1] (x86-PPC) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = OpenGL; }; - name = "Release (x86-PPC)"; + name = "Release [SDL1] (x86-PPC)"; }; - 84B8AEE22AF188D8008DE93D /* Debug (Default) */ = { + 84B8AEE22AF188D8008DE93D /* Debug [SDL2] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = Client; }; - name = "Debug (Default)"; + name = "Debug [SDL2] (Default)"; }; - 84B8AEE32AF188D8008DE93D /* Release (Default) */ = { + 84B8AEE32AF188D8008DE93D /* Release [SDL2] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = Client; }; - name = "Release (Default)"; + name = "Release [SDL2] (Default)"; }; - 84B8AEE42AF188D8008DE93D /* Release (x86) */ = { + 84B8AEE42AF188D8008DE93D /* Release [SDL2] (x86) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = Client; }; - name = "Release (x86)"; + name = "Release [SDL2] (x86)"; }; - 84B8AEE52AF188D8008DE93D /* Release (PPC) */ = { + 84B8AEE52AF188D8008DE93D /* Release [SDL1] (PPC) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = Client; }; - name = "Release (PPC)"; + name = "Release [SDL1] (PPC)"; }; - 84B8AEE62AF188D8008DE93D /* Release (x86-PPC) */ = { + 84B8AEE62AF188D8008DE93D /* Release [SDL1] (x86-PPC) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = Client; }; - name = "Release (x86-PPC)"; + name = "Release [SDL1] (x86-PPC)"; }; - 84BF63062AF1859D008A9995 /* Debug (Default) */ = { + 84BF63062AF1859D008A9995 /* Debug [SDL2] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = World; }; - name = "Debug (Default)"; + name = "Debug [SDL2] (Default)"; }; - 84BF63072AF1859D008A9995 /* Release (Default) */ = { + 84BF63072AF1859D008A9995 /* Release [SDL2] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = World; }; - name = "Release (Default)"; + name = "Release [SDL2] (Default)"; }; - 84BF63082AF1859D008A9995 /* Release (x86) */ = { + 84BF63082AF1859D008A9995 /* Release [SDL2] (x86) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = World; }; - name = "Release (x86)"; + name = "Release [SDL2] (x86)"; }; - 84BF63092AF1859D008A9995 /* Release (PPC) */ = { + 84BF63092AF1859D008A9995 /* Release [SDL1] (PPC) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = World; }; - name = "Release (PPC)"; + name = "Release [SDL1] (PPC)"; }; - 84BF630A2AF1859D008A9995 /* Release (x86-PPC) */ = { + 84BF630A2AF1859D008A9995 /* Release [SDL1] (x86-PPC) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = World; }; - name = "Release (x86-PPC)"; + name = "Release [SDL1] (x86-PPC)"; + }; + 84CCBC472E61849800E251AF /* Debug [SDL2] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Debug [SDL2] (Default)"; + }; + 84CCBC482E61849800E251AF /* Debug [iOS] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Debug [iOS] (Default)"; + }; + 84CCBC492E61849800E251AF /* Release [SDL2] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Release [SDL2] (Default)"; }; - 84CCBC472E61849800E251AF /* Debug (Default) */ = { + 84CCBC4A2E61849800E251AF /* Release [iOS] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Debug (Default)"; + name = "Release [iOS] (Default)"; }; - 84CCBC482E61849800E251AF /* Debug (iOS) */ = { + 84CCBC4B2E61849800E251AF /* Release [SDL2] (x86) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Debug (iOS)"; + name = "Release [SDL2] (x86)"; }; - 84CCBC492E61849800E251AF /* Release (Default) */ = { + 84CCBC4C2E61849800E251AF /* Release [SDL1] (PPC) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Release (Default)"; + name = "Release [SDL1] (PPC)"; }; - 84CCBC4A2E61849800E251AF /* Release (iOS) */ = { + 84CCBC4D2E61849800E251AF /* Release [SDL1] (x86-PPC) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Release (iOS)"; + name = "Release [SDL1] (x86-PPC)"; + }; + 84E4BFAF2AE9854B0023E16A /* Debug [SDL2] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Debug [SDL2] (Default)"; + }; + 84E4BFB02AE9854B0023E16A /* Release [SDL2] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Release [SDL2] (Default)"; + }; + 84E4BFB12AE9854B0023E16A /* Release [SDL2] (x86) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Release [SDL2] (x86)"; + }; + 84E4BFB22AE9854B0023E16A /* Release [SDL1] (PPC) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Release [SDL1] (PPC)"; + }; + 84E4BFB32AE9854B0023E16A /* Release [SDL1] (x86-PPC) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Release [SDL1] (x86-PPC)"; + }; + 84EDCFD62E76D7BD00375AEF /* Debug [SDL1] (Default) */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 84336BA92B1EB9C200097DB0 /* Settings_macOS_Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGNING_ALLOWED = NO; + CODE_SIGN_IDENTITY = ""; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(LOCAL_LIBRARY_DIR)/Frameworks", + "\\\"$(DEVELOPER_FRAMEWORKS_DIR)\\\"", + ); + GCC_FAST_MATH = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(BACKEND_SDL1)", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + /opt/local/include, + /opt/homebrew/include, + /usr/local/include, + "$(MC_ROOT)", + "$(MC_ROOT)/source", + "$(RAKNET_PATH)", + ); + LIBRARY_SEARCH_PATHS = ( + /opt/local/lib, + /opt/homebrew/lib, + /usr/local/lib, + ); + MACOSX_DEPLOYMENT_TARGET = ""; + MC_ROOT = "$(PROJECT_DIR)/../../../../"; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + RAKNET_PATH = "$(MC_ROOT)/thirdparty/raknet/"; + }; + name = "Debug [SDL1] (Default)"; + }; + 84EDCFD72E76D7BD00375AEF /* Debug [SDL1] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + /opt/local/lib, + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Debug [SDL1] (Default)"; + }; + 84EDCFD82E76D7BD00375AEF /* Debug [SDL1] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + /opt/local/libexec/libsdl12/lib, + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Debug [SDL1] (Default)"; }; - 84CCBC4B2E61849800E251AF /* Release (x86) */ = { + 84EDCFD92E76D7BD00375AEF /* Debug [SDL1] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Release (x86)"; + name = "Debug [SDL1] (Default)"; + }; + 84EDCFDA2E76D7BD00375AEF /* Debug [SDL1] (Default) */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 84336BA52B1EB57E00097DB0 /* Settings_iOS_Debug.xcconfig */; + buildSettings = { + CODE_SIGN_ENTITLEMENTS = $MC_ROOT/platforms/ios/minecraftpe.entitlements; + INFOPLIST_FILE = "$(MC_ROOT)platforms/ios/minecraftpe-Info.plist"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\\\"$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/usr/lib/arc\\\"", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = "Debug [SDL1] (Default)"; }; - 84CCBC4C2E61849800E251AF /* Release (PPC) */ = { + 84EDCFDB2E76D7BD00375AEF /* Debug [SDL1] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Release (PPC)"; + name = "Debug [SDL1] (Default)"; }; - 84CCBC4D2E61849800E251AF /* Release (x86-PPC) */ = { + 84EDCFDC2E76D7BD00375AEF /* Debug [SDL1] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Release (x86-PPC)"; + name = "Debug [SDL1] (Default)"; }; - 84E4BFAF2AE9854B0023E16A /* Debug (Default) */ = { + 84EDCFDD2E76D7BD00375AEF /* Debug [SDL1] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = Renderer; + }; + name = "Debug [SDL1] (Default)"; + }; + 84EDCFDE2E76D7BD00375AEF /* Debug [SDL1] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = World; + }; + name = "Debug [SDL1] (Default)"; + }; + 84EDCFDF2E76D7BD00375AEF /* Debug [SDL1] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = Client; + }; + name = "Debug [SDL1] (Default)"; + }; + 84EDCFE02E76D7BD00375AEF /* Debug [SDL1] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = OpenGL; + }; + name = "Debug [SDL1] (Default)"; + }; + 84EDCFE12E76D7BD00375AEF /* Debug [SDL1] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = ZLib; + }; + name = "Debug [SDL1] (Default)"; + }; + 84EDCFE22E76D7BD00375AEF /* Debug [SDL1] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Debug [SDL1] (Default)"; + }; + 84EDCFE32E76D7ED00375AEF /* Release [SDL1] (Default) */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 84336BA82B1EB88500097DB0 /* Settings_macOS.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGNING_ALLOWED = NO; + CODE_SIGN_IDENTITY = ""; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(LOCAL_LIBRARY_DIR)/Frameworks", + "\\\"$(DEVELOPER_FRAMEWORKS_DIR)\\\"", + ); + GCC_FAST_MATH = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(BACKEND_SDL1)", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + /opt/local/include, + /opt/homebrew/include, + /usr/local/include, + "$(MC_ROOT)", + "$(MC_ROOT)/source", + "$(RAKNET_PATH)", + ); + LIBRARY_SEARCH_PATHS = ( + /opt/local/lib, + /opt/homebrew/lib, + /usr/local/lib, + ); + MACOSX_DEPLOYMENT_TARGET = ""; + MC_ROOT = "$(PROJECT_DIR)/../../../../"; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + RAKNET_PATH = "$(MC_ROOT)/thirdparty/raknet/"; + }; + name = "Release [SDL1] (Default)"; + }; + 84EDCFE42E76D7ED00375AEF /* Release [SDL1] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + /opt/local/lib, + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = "Release [SDL1] (Default)"; + }; + 84EDCFE52E76D7ED00375AEF /* Release [SDL1] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + /opt/local/libexec/libsdl12/lib, + ); PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Debug (Default)"; + name = "Release [SDL1] (Default)"; }; - 84E4BFB02AE9854B0023E16A /* Release (Default) */ = { + 84EDCFE62E76D7ED00375AEF /* Release [SDL1] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Release (Default)"; + name = "Release [SDL1] (Default)"; + }; + 84EDCFE72E76D7ED00375AEF /* Release [SDL1] (Default) */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 84336BA42B1EB50E00097DB0 /* Settings_iOS.xcconfig */; + buildSettings = { + CODE_SIGN_ENTITLEMENTS = $MC_ROOT/platforms/ios/minecraftpe.entitlements; + INFOPLIST_FILE = "$(MC_ROOT)platforms/ios/minecraftpe-Info.plist"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\\\"$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/usr/lib/arc\\\"", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + VALIDATE_PRODUCT = YES; + WRAPPER_EXTENSION = app; + }; + name = "Release [SDL1] (Default)"; }; - 84E4BFB12AE9854B0023E16A /* Release (x86) */ = { + 84EDCFE82E76D7ED00375AEF /* Release [SDL1] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Release (x86)"; + name = "Release [SDL1] (Default)"; }; - 84E4BFB22AE9854B0023E16A /* Release (PPC) */ = { + 84EDCFE92E76D7ED00375AEF /* Release [SDL1] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Release (PPC)"; + name = "Release [SDL1] (Default)"; }; - 84E4BFB32AE9854B0023E16A /* Release (x86-PPC) */ = { + 84EDCFEA2E76D7ED00375AEF /* Release [SDL1] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = Renderer; + }; + name = "Release [SDL1] (Default)"; + }; + 84EDCFEB2E76D7ED00375AEF /* Release [SDL1] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = World; + }; + name = "Release [SDL1] (Default)"; + }; + 84EDCFEC2E76D7ED00375AEF /* Release [SDL1] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = Client; + }; + name = "Release [SDL1] (Default)"; + }; + 84EDCFED2E76D7ED00375AEF /* Release [SDL1] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = OpenGL; + }; + name = "Release [SDL1] (Default)"; + }; + 84EDCFEE2E76D7ED00375AEF /* Release [SDL1] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = ZLib; + }; + name = "Release [SDL1] (Default)"; + }; + 84EDCFEF2E76D7ED00375AEF /* Release [SDL1] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Release (x86-PPC)"; + name = "Release [SDL1] (Default)"; }; - 84FFBD7F2ACA2876005A8CCF /* Debug (Default) */ = { + 84FFBD7F2ACA2876005A8CCF /* Debug [SDL2] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Debug (Default)"; + name = "Debug [SDL2] (Default)"; }; - 84FFBD802ACA2876005A8CCF /* Release (Default) */ = { + 84FFBD802ACA2876005A8CCF /* Release [SDL2] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Release (Default)"; + name = "Release [SDL2] (Default)"; }; - 84FFBD812ACA2876005A8CCF /* Release (x86) */ = { + 84FFBD812ACA2876005A8CCF /* Release [SDL2] (x86) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Release (x86)"; + name = "Release [SDL2] (x86)"; }; - 84FFBD822ACA2876005A8CCF /* Release (PPC) */ = { + 84FFBD822ACA2876005A8CCF /* Release [SDL1] (PPC) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Release (PPC)"; + name = "Release [SDL1] (PPC)"; }; - 84FFBD832ACA2876005A8CCF /* Release (x86-PPC) */ = { + 84FFBD832ACA2876005A8CCF /* Release [SDL1] (x86-PPC) */ = { isa = XCBuildConfiguration; buildSettings = { EXECUTABLE_PREFIX = lib; PRODUCT_NAME = "$(TARGET_NAME)"; }; - name = "Release (x86-PPC)"; + name = "Release [SDL1] (x86-PPC)"; }; /* End XCBuildConfiguration section */ @@ -8453,170 +9062,210 @@ 8406FD232AF1814500B09C1D /* Build configuration list for PBXNativeTarget "Renderer" */ = { isa = XCConfigurationList; buildConfigurations = ( - 8406FD242AF1814500B09C1D /* Debug (Default) */, - 84619B292AF1F32500B0DE81 /* Debug (iOS) */, - 8406FD252AF1814500B09C1D /* Release (Default) */, - 84619B342AF1F33A00B0DE81 /* Release (iOS) */, - 8406FD262AF1814500B09C1D /* Release (x86) */, - 8406FD272AF1814500B09C1D /* Release (PPC) */, - 8406FD282AF1814500B09C1D /* Release (x86-PPC) */, + 8406FD242AF1814500B09C1D /* Debug [SDL2] (Default) */, + 84EDCFDD2E76D7BD00375AEF /* Debug [SDL1] (Default) */, + 84619B292AF1F32500B0DE81 /* Debug [iOS] (Default) */, + 8406FD252AF1814500B09C1D /* Release [SDL2] (Default) */, + 84EDCFEA2E76D7ED00375AEF /* Release [SDL1] (Default) */, + 84619B342AF1F33A00B0DE81 /* Release [iOS] (Default) */, + 8406FD262AF1814500B09C1D /* Release [SDL2] (x86) */, + 8406FD272AF1814500B09C1D /* Release [SDL1] (PPC) */, + 8406FD282AF1814500B09C1D /* Release [SDL1] (x86-PPC) */, ); defaultConfigurationIsVisible = 0; - defaultConfigurationName = "Release (Default)"; + defaultConfigurationName = "Release [SDL2] (Default)"; }; 8426106E2AE988D30065905F /* Build configuration list for PBXNativeTarget "Network" */ = { isa = XCConfigurationList; buildConfigurations = ( - 842610692AE988D30065905F /* Debug (Default) */, - 84619B282AF1F32500B0DE81 /* Debug (iOS) */, - 8426106A2AE988D30065905F /* Release (Default) */, - 84619B332AF1F33A00B0DE81 /* Release (iOS) */, - 8426106B2AE988D30065905F /* Release (x86) */, - 8426106C2AE988D30065905F /* Release (PPC) */, - 8426106D2AE988D30065905F /* Release (x86-PPC) */, + 842610692AE988D30065905F /* Debug [SDL2] (Default) */, + 84EDCFDC2E76D7BD00375AEF /* Debug [SDL1] (Default) */, + 84619B282AF1F32500B0DE81 /* Debug [iOS] (Default) */, + 8426106A2AE988D30065905F /* Release [SDL2] (Default) */, + 84EDCFE92E76D7ED00375AEF /* Release [SDL1] (Default) */, + 84619B332AF1F33A00B0DE81 /* Release [iOS] (Default) */, + 8426106B2AE988D30065905F /* Release [SDL2] (x86) */, + 8426106C2AE988D30065905F /* Release [SDL1] (PPC) */, + 8426106D2AE988D30065905F /* Release [SDL1] (x86-PPC) */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = "Release [SDL2] (Default)"; + }; + 844496832E76685C008CF2E0 /* Build configuration list for PBXNativeTarget "MinecraftClient.SDL1" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8444967C2E76685C008CF2E0 /* Debug [SDL2] (Default) */, + 84EDCFD82E76D7BD00375AEF /* Debug [SDL1] (Default) */, + 8444967D2E76685C008CF2E0 /* Debug [iOS] (Default) */, + 8444967E2E76685C008CF2E0 /* Release [SDL2] (Default) */, + 84EDCFE52E76D7ED00375AEF /* Release [SDL1] (Default) */, + 8444967F2E76685C008CF2E0 /* Release [iOS] (Default) */, + 844496802E76685C008CF2E0 /* Release [SDL2] (x86) */, + 844496812E76685C008CF2E0 /* Release [SDL1] (PPC) */, + 844496822E76685C008CF2E0 /* Release [SDL1] (x86-PPC) */, ); defaultConfigurationIsVisible = 0; - defaultConfigurationName = "Release (Default)"; + defaultConfigurationName = "Release [SDL2] (Default)"; }; 84498A7D2AF18C7A005EF5A5 /* Build configuration list for PBXNativeTarget "ZLib" */ = { isa = XCConfigurationList; buildConfigurations = ( - 84498A7E2AF18C7A005EF5A5 /* Debug (Default) */, - 84619B2D2AF1F32500B0DE81 /* Debug (iOS) */, - 84498A7F2AF18C7A005EF5A5 /* Release (Default) */, - 84619B382AF1F33A00B0DE81 /* Release (iOS) */, - 84498A802AF18C7A005EF5A5 /* Release (x86) */, - 84498A812AF18C7A005EF5A5 /* Release (PPC) */, - 84498A822AF18C7A005EF5A5 /* Release (x86-PPC) */, + 84498A7E2AF18C7A005EF5A5 /* Debug [SDL2] (Default) */, + 84EDCFE12E76D7BD00375AEF /* Debug [SDL1] (Default) */, + 84619B2D2AF1F32500B0DE81 /* Debug [iOS] (Default) */, + 84498A7F2AF18C7A005EF5A5 /* Release [SDL2] (Default) */, + 84EDCFEE2E76D7ED00375AEF /* Release [SDL1] (Default) */, + 84619B382AF1F33A00B0DE81 /* Release [iOS] (Default) */, + 84498A802AF18C7A005EF5A5 /* Release [SDL2] (x86) */, + 84498A812AF18C7A005EF5A5 /* Release [SDL1] (PPC) */, + 84498A822AF18C7A005EF5A5 /* Release [SDL1] (x86-PPC) */, ); defaultConfigurationIsVisible = 0; - defaultConfigurationName = "Release (Default)"; + defaultConfigurationName = "Release [SDL2] (Default)"; }; 8489B0922A86D4B2004CA8EC /* Build configuration list for PBXProject "Minecraft" */ = { isa = XCConfigurationList; buildConfigurations = ( - 8489B09C2A86D4B2004CA8EC /* Debug (Default) */, - 84619B232AF1F32500B0DE81 /* Debug (iOS) */, - 8489B09D2A86D4B2004CA8EC /* Release (Default) */, - 84619B2E2AF1F33A00B0DE81 /* Release (iOS) */, - 840FD8C92AA565FB009EB349 /* Release (x86) */, - 840FD8CB2AA56676009EB349 /* Release (PPC) */, - 840FD8CD2AA566AB009EB349 /* Release (x86-PPC) */, + 8489B09C2A86D4B2004CA8EC /* Debug [SDL2] (Default) */, + 84EDCFD62E76D7BD00375AEF /* Debug [SDL1] (Default) */, + 84619B232AF1F32500B0DE81 /* Debug [iOS] (Default) */, + 8489B09D2A86D4B2004CA8EC /* Release [SDL2] (Default) */, + 84EDCFE32E76D7ED00375AEF /* Release [SDL1] (Default) */, + 84619B2E2AF1F33A00B0DE81 /* Release [iOS] (Default) */, + 840FD8C92AA565FB009EB349 /* Release [SDL2] (x86) */, + 840FD8CB2AA56676009EB349 /* Release [SDL1] (PPC) */, + 840FD8CD2AA566AB009EB349 /* Release [SDL1] (x86-PPC) */, ); defaultConfigurationIsVisible = 0; - defaultConfigurationName = "Release (Default)"; + defaultConfigurationName = "Release [SDL2] (Default)"; }; 8489B09E2A86D4B2004CA8EC /* Build configuration list for PBXNativeTarget "MinecraftClient.SDL2" */ = { isa = XCConfigurationList; buildConfigurations = ( - 8489B09F2A86D4B2004CA8EC /* Debug (Default) */, - 84619B242AF1F32500B0DE81 /* Debug (iOS) */, - 8489B0A02A86D4B2004CA8EC /* Release (Default) */, - 84619B2F2AF1F33A00B0DE81 /* Release (iOS) */, - 840FD8CA2AA565FB009EB349 /* Release (x86) */, - 840FD8CC2AA56676009EB349 /* Release (PPC) */, - 840FD8CE2AA566AB009EB349 /* Release (x86-PPC) */, + 8489B09F2A86D4B2004CA8EC /* Debug [SDL2] (Default) */, + 84EDCFD72E76D7BD00375AEF /* Debug [SDL1] (Default) */, + 84619B242AF1F32500B0DE81 /* Debug [iOS] (Default) */, + 8489B0A02A86D4B2004CA8EC /* Release [SDL2] (Default) */, + 84EDCFE42E76D7ED00375AEF /* Release [SDL1] (Default) */, + 84619B2F2AF1F33A00B0DE81 /* Release [iOS] (Default) */, + 840FD8CA2AA565FB009EB349 /* Release [SDL2] (x86) */, + 840FD8CC2AA56676009EB349 /* Release [SDL1] (PPC) */, + 840FD8CE2AA566AB009EB349 /* Release [SDL1] (x86-PPC) */, ); defaultConfigurationIsVisible = 0; - defaultConfigurationName = "Release (Default)"; + defaultConfigurationName = "Release [SDL2] (Default)"; }; 8492593D2AD8FCFD0081F5B9 /* Build configuration list for PBXNativeTarget "minecraftpe" */ = { isa = XCConfigurationList; buildConfigurations = ( - 8492593E2AD8FCFD0081F5B9 /* Debug (Default) */, - 84619B262AF1F32500B0DE81 /* Debug (iOS) */, - 8492593F2AD8FCFD0081F5B9 /* Release (Default) */, - 84619B312AF1F33A00B0DE81 /* Release (iOS) */, - 849259402AD8FCFD0081F5B9 /* Release (x86) */, - 849259412AD8FCFD0081F5B9 /* Release (PPC) */, - 849259422AD8FCFD0081F5B9 /* Release (x86-PPC) */, + 8492593E2AD8FCFD0081F5B9 /* Debug [SDL2] (Default) */, + 84EDCFDA2E76D7BD00375AEF /* Debug [SDL1] (Default) */, + 84619B262AF1F32500B0DE81 /* Debug [iOS] (Default) */, + 8492593F2AD8FCFD0081F5B9 /* Release [SDL2] (Default) */, + 84EDCFE72E76D7ED00375AEF /* Release [SDL1] (Default) */, + 84619B312AF1F33A00B0DE81 /* Release [iOS] (Default) */, + 849259402AD8FCFD0081F5B9 /* Release [SDL2] (x86) */, + 849259412AD8FCFD0081F5B9 /* Release [SDL1] (PPC) */, + 849259422AD8FCFD0081F5B9 /* Release [SDL1] (x86-PPC) */, ); defaultConfigurationIsVisible = 0; - defaultConfigurationName = "Release (Default)"; + defaultConfigurationName = "Release [SDL2] (Default)"; }; 84AAF63C2AF18B9500BD67F4 /* Build configuration list for PBXNativeTarget "OpenGL" */ = { isa = XCConfigurationList; buildConfigurations = ( - 84AAF63D2AF18B9500BD67F4 /* Debug (Default) */, - 84619B2C2AF1F32500B0DE81 /* Debug (iOS) */, - 84AAF63E2AF18B9500BD67F4 /* Release (Default) */, - 84619B372AF1F33A00B0DE81 /* Release (iOS) */, - 84AAF63F2AF18B9500BD67F4 /* Release (x86) */, - 84AAF6402AF18B9500BD67F4 /* Release (PPC) */, - 84AAF6412AF18B9500BD67F4 /* Release (x86-PPC) */, + 84AAF63D2AF18B9500BD67F4 /* Debug [SDL2] (Default) */, + 84EDCFE02E76D7BD00375AEF /* Debug [SDL1] (Default) */, + 84619B2C2AF1F32500B0DE81 /* Debug [iOS] (Default) */, + 84AAF63E2AF18B9500BD67F4 /* Release [SDL2] (Default) */, + 84EDCFED2E76D7ED00375AEF /* Release [SDL1] (Default) */, + 84619B372AF1F33A00B0DE81 /* Release [iOS] (Default) */, + 84AAF63F2AF18B9500BD67F4 /* Release [SDL2] (x86) */, + 84AAF6402AF18B9500BD67F4 /* Release [SDL1] (PPC) */, + 84AAF6412AF18B9500BD67F4 /* Release [SDL1] (x86-PPC) */, ); defaultConfigurationIsVisible = 0; - defaultConfigurationName = "Release (Default)"; + defaultConfigurationName = "Release [SDL2] (Default)"; }; 84B8AEE12AF188D8008DE93D /* Build configuration list for PBXNativeTarget "Client" */ = { isa = XCConfigurationList; buildConfigurations = ( - 84B8AEE22AF188D8008DE93D /* Debug (Default) */, - 84619B2B2AF1F32500B0DE81 /* Debug (iOS) */, - 84B8AEE32AF188D8008DE93D /* Release (Default) */, - 84619B362AF1F33A00B0DE81 /* Release (iOS) */, - 84B8AEE42AF188D8008DE93D /* Release (x86) */, - 84B8AEE52AF188D8008DE93D /* Release (PPC) */, - 84B8AEE62AF188D8008DE93D /* Release (x86-PPC) */, + 84B8AEE22AF188D8008DE93D /* Debug [SDL2] (Default) */, + 84EDCFDF2E76D7BD00375AEF /* Debug [SDL1] (Default) */, + 84619B2B2AF1F32500B0DE81 /* Debug [iOS] (Default) */, + 84B8AEE32AF188D8008DE93D /* Release [SDL2] (Default) */, + 84EDCFEC2E76D7ED00375AEF /* Release [SDL1] (Default) */, + 84619B362AF1F33A00B0DE81 /* Release [iOS] (Default) */, + 84B8AEE42AF188D8008DE93D /* Release [SDL2] (x86) */, + 84B8AEE52AF188D8008DE93D /* Release [SDL1] (PPC) */, + 84B8AEE62AF188D8008DE93D /* Release [SDL1] (x86-PPC) */, ); defaultConfigurationIsVisible = 0; - defaultConfigurationName = "Release (Default)"; + defaultConfigurationName = "Release [SDL2] (Default)"; }; 84BF63052AF1859D008A9995 /* Build configuration list for PBXNativeTarget "World" */ = { isa = XCConfigurationList; buildConfigurations = ( - 84BF63062AF1859D008A9995 /* Debug (Default) */, - 84619B2A2AF1F32500B0DE81 /* Debug (iOS) */, - 84BF63072AF1859D008A9995 /* Release (Default) */, - 84619B352AF1F33A00B0DE81 /* Release (iOS) */, - 84BF63082AF1859D008A9995 /* Release (x86) */, - 84BF63092AF1859D008A9995 /* Release (PPC) */, - 84BF630A2AF1859D008A9995 /* Release (x86-PPC) */, + 84BF63062AF1859D008A9995 /* Debug [SDL2] (Default) */, + 84EDCFDE2E76D7BD00375AEF /* Debug [SDL1] (Default) */, + 84619B2A2AF1F32500B0DE81 /* Debug [iOS] (Default) */, + 84BF63072AF1859D008A9995 /* Release [SDL2] (Default) */, + 84EDCFEB2E76D7ED00375AEF /* Release [SDL1] (Default) */, + 84619B352AF1F33A00B0DE81 /* Release [iOS] (Default) */, + 84BF63082AF1859D008A9995 /* Release [SDL2] (x86) */, + 84BF63092AF1859D008A9995 /* Release [SDL1] (PPC) */, + 84BF630A2AF1859D008A9995 /* Release [SDL1] (x86-PPC) */, ); defaultConfigurationIsVisible = 0; - defaultConfigurationName = "Release (Default)"; + defaultConfigurationName = "Release [SDL2] (Default)"; }; 84CCBC462E61849800E251AF /* Build configuration list for PBXNativeTarget "NBT" */ = { isa = XCConfigurationList; buildConfigurations = ( - 84CCBC472E61849800E251AF /* Debug (Default) */, - 84CCBC482E61849800E251AF /* Debug (iOS) */, - 84CCBC492E61849800E251AF /* Release (Default) */, - 84CCBC4A2E61849800E251AF /* Release (iOS) */, - 84CCBC4B2E61849800E251AF /* Release (x86) */, - 84CCBC4C2E61849800E251AF /* Release (PPC) */, - 84CCBC4D2E61849800E251AF /* Release (x86-PPC) */, + 84CCBC472E61849800E251AF /* Debug [SDL2] (Default) */, + 84EDCFE22E76D7BD00375AEF /* Debug [SDL1] (Default) */, + 84CCBC482E61849800E251AF /* Debug [iOS] (Default) */, + 84CCBC492E61849800E251AF /* Release [SDL2] (Default) */, + 84EDCFEF2E76D7ED00375AEF /* Release [SDL1] (Default) */, + 84CCBC4A2E61849800E251AF /* Release [iOS] (Default) */, + 84CCBC4B2E61849800E251AF /* Release [SDL2] (x86) */, + 84CCBC4C2E61849800E251AF /* Release [SDL1] (PPC) */, + 84CCBC4D2E61849800E251AF /* Release [SDL1] (x86-PPC) */, ); defaultConfigurationIsVisible = 0; - defaultConfigurationName = "Release (Default)"; + defaultConfigurationName = "Release [SDL2] (Default)"; }; 84E4BFB42AE9854B0023E16A /* Build configuration list for PBXNativeTarget "Common" */ = { isa = XCConfigurationList; buildConfigurations = ( - 84E4BFAF2AE9854B0023E16A /* Debug (Default) */, - 84619B272AF1F32500B0DE81 /* Debug (iOS) */, - 84E4BFB02AE9854B0023E16A /* Release (Default) */, - 84619B322AF1F33A00B0DE81 /* Release (iOS) */, - 84E4BFB12AE9854B0023E16A /* Release (x86) */, - 84E4BFB22AE9854B0023E16A /* Release (PPC) */, - 84E4BFB32AE9854B0023E16A /* Release (x86-PPC) */, + 84E4BFAF2AE9854B0023E16A /* Debug [SDL2] (Default) */, + 84EDCFDB2E76D7BD00375AEF /* Debug [SDL1] (Default) */, + 84619B272AF1F32500B0DE81 /* Debug [iOS] (Default) */, + 84E4BFB02AE9854B0023E16A /* Release [SDL2] (Default) */, + 84EDCFE82E76D7ED00375AEF /* Release [SDL1] (Default) */, + 84619B322AF1F33A00B0DE81 /* Release [iOS] (Default) */, + 84E4BFB12AE9854B0023E16A /* Release [SDL2] (x86) */, + 84E4BFB22AE9854B0023E16A /* Release [SDL1] (PPC) */, + 84E4BFB32AE9854B0023E16A /* Release [SDL1] (x86-PPC) */, ); defaultConfigurationIsVisible = 0; - defaultConfigurationName = "Release (Default)"; + defaultConfigurationName = "Release [SDL2] (Default)"; }; 84FFBD842ACA2876005A8CCF /* Build configuration list for PBXNativeTarget "RakNet" */ = { isa = XCConfigurationList; buildConfigurations = ( - 84FFBD7F2ACA2876005A8CCF /* Debug (Default) */, - 84619B252AF1F32500B0DE81 /* Debug (iOS) */, - 84FFBD802ACA2876005A8CCF /* Release (Default) */, - 84619B302AF1F33A00B0DE81 /* Release (iOS) */, - 84FFBD812ACA2876005A8CCF /* Release (x86) */, - 84FFBD822ACA2876005A8CCF /* Release (PPC) */, - 84FFBD832ACA2876005A8CCF /* Release (x86-PPC) */, + 84FFBD7F2ACA2876005A8CCF /* Debug [SDL2] (Default) */, + 84EDCFD92E76D7BD00375AEF /* Debug [SDL1] (Default) */, + 84619B252AF1F32500B0DE81 /* Debug [iOS] (Default) */, + 84FFBD802ACA2876005A8CCF /* Release [SDL2] (Default) */, + 84EDCFE62E76D7ED00375AEF /* Release [SDL1] (Default) */, + 84619B302AF1F33A00B0DE81 /* Release [iOS] (Default) */, + 84FFBD812ACA2876005A8CCF /* Release [SDL2] (x86) */, + 84FFBD822ACA2876005A8CCF /* Release [SDL1] (PPC) */, + 84FFBD832ACA2876005A8CCF /* Release [SDL1] (x86-PPC) */, ); defaultConfigurationIsVisible = 0; - defaultConfigurationName = "Release (Default)"; + defaultConfigurationName = "Release [SDL2] (Default)"; }; /* End XCConfigurationList section */ }; diff --git a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/xcshareddata/xcschemes/MinecraftClient.SDL1.xcscheme b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/xcshareddata/xcschemes/MinecraftClient.SDL1.xcscheme new file mode 100644 index 000000000..0962eb0e3 --- /dev/null +++ b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/xcshareddata/xcschemes/MinecraftClient.SDL1.xcscheme @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/xcshareddata/xcschemes/MinecraftClient.SDL2.xcscheme b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/xcshareddata/xcschemes/MinecraftClient.SDL2.xcscheme index 0285c415f..4755eb1b5 100644 --- a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/xcshareddata/xcschemes/MinecraftClient.SDL2.xcscheme +++ b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/xcshareddata/xcschemes/MinecraftClient.SDL2.xcscheme @@ -1,7 +1,7 @@ + version = "1.8"> @@ -23,10 +23,12 @@ + shouldUseLaunchSchemeArgsEnv = "YES" + buildConfiguration = "Debug [SDL2] (Default)"> + + - - + + @@ -81,10 +83,10 @@ + buildConfiguration = "Debug [SDL2] (Default)"> diff --git a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/xcshareddata/xcschemes/minecraftpe.xcscheme b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/xcshareddata/xcschemes/minecraftpe.xcscheme index 6da3ae5a3..82d15b63a 100644 --- a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/xcshareddata/xcschemes/minecraftpe.xcscheme +++ b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/xcshareddata/xcschemes/minecraftpe.xcscheme @@ -10,7 +10,7 @@ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES" - buildConfiguration = "Debug (iOS)"> + buildConfiguration = "Debug [iOS] (Default)"> @@ -28,7 +28,7 @@ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0" useCustomWorkingDirectory = "NO" - buildConfiguration = "Debug (iOS)" + buildConfiguration = "Debug [iOS] (Default)" ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" enablesOpenGLESFrameCapture = "YES" @@ -49,7 +49,7 @@ shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" - buildConfiguration = "Release (iOS)" + buildConfiguration = "Release [iOS] (Default)" debugDocumentVersioning = "YES"> + buildConfiguration = "Debug [iOS] (Default)"> diff --git a/platforms/sdl/base/AppPlatform_sdl.cpp b/platforms/sdl/base/AppPlatform_sdl.cpp new file mode 100644 index 000000000..bbcb0d4c7 --- /dev/null +++ b/platforms/sdl/base/AppPlatform_sdl.cpp @@ -0,0 +1,550 @@ +#include +#include +#include +#include +#include + +#ifdef __EMSCRIPTEN__ +#include +#endif + +#include "stb_image.h" +#include "stb_image_write.h" + +#include "thirdparty/GL/GL.hpp" + +#include "AppPlatform_sdl.hpp" + +#include "common/Utils.hpp" + +#include "CustomSoundSystem.hpp" +// Macros are cursed +#define _STR(x) #x +#define STR(x) _STR(x) + +#include "client/player/input/Controller.hpp" + +void AppPlatform_sdl::_init(std::string storageDir) +{ + m_storageDir = storageDir; + + m_pIconTexture = nullptr; + m_pIcon = nullptr; + + m_bShiftPressed[0] = false; + m_bShiftPressed[1] = false; + + _ensureDirectoryExists(m_storageDir.c_str()); + + m_pSoundSystem = nullptr; + + // Default Touchscreen Mode +#ifdef ANDROID + m_bIsTouchscreen = true; +#else + m_bIsTouchscreen = false; +#endif + // Custom Touchscreen Mode + const char *mode = getenv("MCPE_INPUT_MODE"); + if (mode) + { + if (strcmp(mode, "touch") == 0) + { + m_bIsTouchscreen = true; + } + else if (strcmp(mode, "mouse") == 0) + { + m_bIsTouchscreen = false; + } + } + + clearDiff(); +} + +AppPlatform_sdl::~AppPlatform_sdl() +{ + if (m_pIcon) SDL_FreeSurface(m_pIcon); + SAFE_DELETE(m_pIconTexture); + + SAFE_DELETE(m_pSoundSystem); +} + +void AppPlatform_sdl::_handleKeyEvent(int key, uint8_t state) +{ + // This really should be handled somewhere else. + // Unforunately, there is no global keyboard handler. + // Keyboard events are either handled in Screen::keyboardEvent + // when a Screen is visible, or in Minecraft::tickInput + // when LocalPlayer exists. + switch (key) + { + case SDLVK_F2: + if (state == SDL_PRESSED) + saveScreenshot("", -1, -1); + return; + case SDLVK_BACKSPACE: + // Text Editing (This is currently handled in handle_events() in platforms/sdl/main.cpp) + /*if (state == SDL_PRESSED) + g_pApp->handleCharInput('\b');*/ + break; + case SDLVK_LSHIFT: + case SDLVK_RSHIFT: + setShiftPressed(state == SDL_PRESSED, key == SDLVK_LSHIFT); + break; + } + + // Normal Key Press + Keyboard::feed(AppPlatform_sdl::GetKeyState(state), key); +} + +// Ensure Screenshots Folder Exists +void AppPlatform_sdl::_ensureDirectoryExists(const char* path) +{ + // Check Screenshots Folder + struct stat obj; + if (stat(path, &obj) != 0 || !S_ISDIR(obj.st_mode)) + { + // Create Screenshots Folder +#if defined(_WIN32) && !defined(__MINGW32__) + int ret = XPL_MKDIR(path); +#else + int ret = XPL_MKDIR(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); +#endif + if (ret != 0) + { + // Unable To Create Folder + LOG_E("Error Creating Directory: %s: %s", path, strerror(errno)); + exit(EXIT_FAILURE); + } + } +} + +void AppPlatform_sdl::_setIcon(const Texture& icon) +{ + if (!icon.m_pixels) + return; + + SAFE_DELETE(m_pIconTexture); + if (m_pIcon) SDL_FreeSurface(m_pIcon); + + m_pIconTexture = new Texture(icon); + m_pIcon = _GetSurfaceForTexture(*m_pIconTexture); + + _updateWindowIcon(); +} + +void AppPlatform_sdl::_setDefaultIcon() +{ + _setIcon(loadTexture("icon.png", false)); +} + +void AppPlatform_sdl::initSoundSystem() +{ + if (!m_pSoundSystem) + { + LOG_I("Initializing " STR(SOUND_SYSTEM) "..."); + m_pSoundSystem = new SOUND_SYSTEM(); + } + else + { + LOG_E("Trying to initialize SoundSystem more than once!"); + } +} + +int AppPlatform_sdl::checkLicense() +{ + // we own the game!! + return 1; +} + +void AppPlatform_sdl::setMouseGrabbed(bool b) +{ + _setMouseGrabbed(b); + clearDiff(); +} + +void AppPlatform_sdl::setMouseDiff(int x, int y) +{ + m_xrel += x; + m_yrel += y; +} + +void AppPlatform_sdl::getMouseDiff(int& x, int& y) +{ + x = m_xrel; + y = m_yrel; +} + +void AppPlatform_sdl::clearDiff() +{ + m_xrel = 0; + m_yrel = 0; +} + +bool AppPlatform_sdl::shiftPressed() +{ + return m_bShiftPressed[0] || m_bShiftPressed[1]; +} + +void AppPlatform_sdl::setShiftPressed(bool b, bool isLeft) +{ + m_bShiftPressed[isLeft ? 0 : 1] = b; +} + +int AppPlatform_sdl::getUserInputStatus() +{ + return -1; +} + +void AppPlatform_sdl::saveScreenshot(const std::string& filename, int glWidth, int glHeight) +{ + // Get Directory + std::string screenshots = m_storageDir + "/screenshots"; + + // Get Timestamp + time_t rawtime; + struct tm* timeinfo; + time(&rawtime); + timeinfo = localtime(&rawtime); + char time[256]; + strftime(time, sizeof(time), "%Y-%m-%d_%H.%M.%S", timeinfo); + + // Ensure Screenshots Folder Exists + _ensureDirectoryExists(screenshots.c_str()); + + // Prevent Overwriting Screenshots + int num = 1; + const std::string path = screenshots + "/"; + std::string file = path + time + ".png"; + while (XPL_ACCESS(file.c_str(), F_OK) != -1) + { + file = path + SSTR(time << "-" << num << ".png"); + num++; + } + + // Get Image Size + GLint viewport[4]; + glGetIntegerv(GL_VIEWPORT, viewport); + int x = viewport[0]; + int y = viewport[1]; + int width = viewport[2]; + int height = viewport[3]; + + // Get Line Size + int line_size = width * 4; + { + // Handle Alignment + int alignment; + glGetIntegerv(GL_PACK_ALIGNMENT, &alignment); + // Round + int diff = line_size % alignment; + if (diff > 0) + { + line_size = line_size + (alignment - diff); + } + } + int size = height * line_size; + + // Read Pixels + bool fail = false; + unsigned char* pixels = new unsigned char[size]; + if (!pixels) + { + fail = true; + } + else + { + glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); + } + + // Save Image + if (fail || !_SavePng(file.c_str(), pixels, line_size, width, height)) + { + LOG_E("Screenshot Failed: %s", file.c_str()); + } + else + { + LOG_I("Screenshot Saved: %s", file.c_str()); + } + + // Free + if (!pixels) + { + delete[] pixels; + } +} + +Texture AppPlatform_sdl::loadTexture(const std::string& path, bool bIsRequired) +{ + Texture out; + out.m_hasAlpha = true; + out.field_D = 0; + + // Get Full Path + std::string realPath = getAssetPath(path); + + // Read File + SDL_RWops* io = SDL_RWFromFile(realPath.c_str(), "rb"); + if (!io) + { + LOG_E("Couldn't find file: %s", path.c_str()); + return out; + } + Sint64 size; +#if SDL_MAJOR_VERSION >= 2 + size = SDL_RWsize(io); +#else + size = SDL_RWseek(io, 0, SEEK_END); + SDL_RWseek(io, 0, SEEK_SET); +#endif + unsigned char* file = new unsigned char[size]; + SDL_RWread(io, file, size, 1); + SDL_RWclose(io); + + // Parse Image + int width = 0, height = 0, channels = 0; + stbi_uc* img = stbi_load_from_memory(file, size, &width, &height, &channels, STBI_rgb_alpha); + delete[] file; + if (!img) + { + // Failed To Parse Image + LOG_E("The image could not be loaded properly: %s", path.c_str()); + return out; + } + + // Copy Image + uint32_t* img2 = new uint32_t[width * height]; + memcpy(img2, img, width * height * sizeof(uint32_t)); + stbi_image_free(img); + + // Create Texture + out.m_width = width; + out.m_height = height; + out.m_pixels = img2; + + // Return + return out; +} + +bool AppPlatform_sdl::doesTextureExist(const std::string& path) const +{ + // Get Full Path + std::string realPath = getAssetPath(path); + + // Open File + SDL_RWops* io = SDL_RWFromFile(realPath.c_str(), "rb"); + if (!io) + { + // Does Not Exist + return false; + } + else + { + // File Exists + SDL_RWclose(io); + return true; + } +} + +bool AppPlatform_sdl::isTouchscreen() const +{ + return m_bIsTouchscreen; +} + +void AppPlatform_sdl::handleKeyEvent(const SDL_Event& event) +{ + int key = _TranslateSDLKeyCodeToVirtual(event.key.keysym.sym); + uint8_t state = event.key.state; + + return _handleKeyEvent(key, state); +} + +void AppPlatform_sdl::handleControllerButtonEvent(SDL_JoystickID controllerIndex, uint8_t button, uint8_t state) +{ + // Normal Key Press + Keyboard::feed(GetKeyState(state), button); +} + +void AppPlatform_sdl::handleControllerAxisEvent(SDL_JoystickID controllerIndex, uint8_t axis, int16_t value) +{ + float val = value / 32767.0f; // -32768 to 32767 + + switch (axis) + { + case SDL_CONTROLLER_AXIS_LEFTX: + Controller::feedStickX(1, true, val); + break; + case SDL_CONTROLLER_AXIS_LEFTY: + Controller::feedStickY(1, true, val); + break; + case SDL_CONTROLLER_AXIS_RIGHTX: + Controller::feedStickX(2, true, val); + break; + case SDL_CONTROLLER_AXIS_RIGHTY: + Controller::feedStickY(2, true, val); + break; + case SDL_CONTROLLER_AXIS_TRIGGERLEFT: + Controller::feedTrigger(1, val); + break; + case SDL_CONTROLLER_AXIS_TRIGGERRIGHT: + Controller::feedTrigger(2, val); + break; + } +} + +AssetFile AppPlatform_sdl::readAssetFile(const std::string& str, bool quiet) const +{ + std::string path = getAssetPath(str); + SDL_RWops* io = SDL_RWFromFile(path.c_str(), "rb"); + + // Open File + if (!io) + { + if (!quiet) LOG_W("Couldn't find asset file: %s", path.c_str()); + return AssetFile(); + } + + // Get File Size + Sint64 size; +#if SDL_MAJOR_VERSION >= 2 + size = SDL_RWsize(io); +#else + size = SDL_RWseek(io, 0, SEEK_END); + SDL_RWseek(io, 0, SEEK_SET); +#endif + if (size < 0) + { + if (!quiet) LOG_E("Error determining the size of the asset file!"); + SDL_RWclose(io); + return AssetFile(); + } + + // Read Data + unsigned char* buf = new unsigned char[size]; + SDL_RWread(io, buf, size, 1); + + // Close File + SDL_RWclose(io); + + // Return + return AssetFile(size, buf); +} + +std::string AppPlatform_sdl::getPatchData() +{ + std::string path = getAssetPath(_getPatchDataPath()); + SDL_RWops* io = SDL_RWFromFile(path.c_str(), "rb"); + + if (!io) + { + LOG_W("Couldn't find patch data file!"); + return ""; + } + Sint64 size; +#if SDL_MAJOR_VERSION >= 2 + size = SDL_RWsize(io); +#else + size = SDL_RWseek(io, 0, SEEK_END); + SDL_RWseek(io, 0, SEEK_SET); +#endif + if (size == -1) + { + LOG_E("Error determining the size of the patch data file!"); + } + + char* buf = new char[size]; + SDL_RWread(io, buf, size, 1); + + SDL_RWclose(io); + + return std::string(buf); +} + +SDL_Surface* AppPlatform_sdl::_GetSurfaceForTexture(const Texture& texture) +{ + void* pixels = texture.m_pixels; + int width = texture.m_width; + int height = texture.m_height; + int depth = 32; // Color depth (32-bit by default) + + SDL_Surface* surface = SDL_CreateRGBSurfaceFrom( + pixels, width, height, depth, + width * 4, // Pitch +#if MC_ENDIANNESS_LITTLE + 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 +#else // MC_ENDIANNESS_BIG + 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF +#endif + ); + if (!surface) + LOG_E("Failed loading SDL_Surface from Texture: %s", SDL_GetError()); + + return surface; +} + +// Take Screenshot +int AppPlatform_sdl::_SavePng(const char* filename, unsigned char* pixels, int line_size, int width, int height) +{ + // Setup + stbi_flip_vertically_on_write(true); + + // Write Image + return stbi_write_png(filename, width, height, 4, pixels, line_size); +} + +int AppPlatform_sdl::_TranslateSDLKeyCodeToVirtual(int sdlCode) +{ + switch (sdlCode) { +#define CODE(x) case SDLK_ ## x: return SDLVK_ ## x; +#include "compat/SDLKeyCodes.h" +#undef CODE + } + return SDLVK_UNKNOWN; +} + +MouseButtonType AppPlatform_sdl::GetMouseButtonType(uint8_t button) +{ + switch (button) + { + case SDL_BUTTON_LEFT: + return BUTTON_LEFT; + case SDL_BUTTON_RIGHT: + return BUTTON_RIGHT; + case SDL_BUTTON_MIDDLE: + return BUTTON_MIDDLE; + default: + return BUTTON_NONE; + } +} + +bool AppPlatform_sdl::GetMouseButtonState(const SDL_Event& event) +{ + bool result; + + switch (event.type) + { + case SDL_MOUSEBUTTONDOWN: + result = true; + break; + case SDL_MOUSEBUTTONUP: + result = false; + break; + default: + result = false; + break; + } + + return result; +} + +Keyboard::KeyState AppPlatform_sdl::GetKeyState(uint8_t state) +{ + switch (state) + { + case SDL_RELEASED: + return Keyboard::UP; + case SDL_PRESSED: + default: + return Keyboard::DOWN; + } +} diff --git a/platforms/sdl/base/AppPlatform_sdl.hpp b/platforms/sdl/base/AppPlatform_sdl.hpp new file mode 100644 index 000000000..3802636c2 --- /dev/null +++ b/platforms/sdl/base/AppPlatform_sdl.hpp @@ -0,0 +1,87 @@ +#pragma once + +#include +#include "thirdparty/SDL/SDL.h" +#include "thirdparty/SDL/SDL_gamecontroller.h" + +#include "client/app/AppPlatform.hpp" + +#include "client/player/input/Mouse.hpp" +#include "client/player/input/Keyboard.hpp" +#include "common/Logger.hpp" + +class AppPlatform_sdl : public AppPlatform +{ +private: + void _init(std::string storageDir); + +public: + AppPlatform_sdl(std::string storageDir) { _init(storageDir); } + ~AppPlatform_sdl() override; + +protected: + virtual void _updateWindowIcon() {} + virtual void _setMouseGrabbed(bool b) {} + virtual void _handleKeyEvent(int key, uint8_t state); + virtual void _ensureDirectoryExists(const char* path); // desktop only + + void _setIcon(const Texture& icon); // note: this takes ownership of the texture, so no memory leaks! + void _setDefaultIcon(); + +public: + virtual const char* getWindowTitle() const = 0; + + void initSoundSystem() override; + + int checkLicense() override; + int getUserInputStatus() override; + void saveScreenshot(const std::string& fileName, int width, int height) override; + Texture loadTexture(const std::string& path, bool bIsRequired = false) override; + bool doesTextureExist(const std::string& path) const override; + SoundSystem* const getSoundSystem() const override { return m_pSoundSystem; } + + // Also add these to allow proper turning within the game. + void setMouseGrabbed(bool b) override; + void setMouseDiff(int x, int y); + void getMouseDiff(int& x, int& y) override; + void clearDiff() override; + + // Also add these to allow proper text input within the game. + bool shiftPressed() override; + void setShiftPressed(bool b, bool isLeft); + + // Configure Touchscreen + bool isTouchscreen() const override; + + // Input events + virtual void handleKeyEvent(const SDL_Event& event); + void handleControllerButtonEvent(SDL_JoystickID controllerIndex, uint8_t button, uint8_t state); + void handleControllerAxisEvent(SDL_JoystickID controllerIndex, uint8_t axis, int16_t value); + + // Read Sounds + AssetFile readAssetFile(const std::string&, bool) const override; + + std::string getPatchData() override; + +protected: + static SDL_Surface* _GetSurfaceForTexture(const Texture& texture); + static int _SavePng(const char* filename, unsigned char* pixels, int line_size, int width, int height); + static int _TranslateSDLKeyCodeToVirtual(int sdlCode); + +public: + static MouseButtonType GetMouseButtonType(uint8_t button); + static bool GetMouseButtonState(const SDL_Event& event); + static Keyboard::KeyState GetKeyState(uint8_t state); + +protected: + const Texture* m_pIconTexture; + SDL_Surface* m_pIcon; + bool m_bShiftPressed[2]; + + int m_xrel; + int m_yrel; + + SoundSystem* m_pSoundSystem; + bool m_bIsTouchscreen; + std::string m_storageDir; +}; diff --git a/platforms/sdl/base/AppPlatform_sdl_base.cpp b/platforms/sdl/base/AppPlatform_sdl_base.cpp deleted file mode 100644 index cb28389c1..000000000 --- a/platforms/sdl/base/AppPlatform_sdl_base.cpp +++ /dev/null @@ -1,409 +0,0 @@ -#include -#include -#include -#include - -#include "AppPlatform_sdl_base.hpp" - -#ifdef __EMSCRIPTEN__ -#include -#else -#include "thirdparty/GL/GL.hpp" -#endif - -#include "common/Utils.hpp" - -#include "CustomSoundSystem.hpp" -// Macros are cursed -#define _STR(x) #x -#define STR(x) _STR(x) - -#include "client/player/input/Controller.hpp" - -void AppPlatform_sdl_base::_init(std::string storageDir, SDL_Window *window) -{ - _storageDir = storageDir; - _window = window; - - _iconTexture = nullptr; - _icon = nullptr; - - m_bShiftPressed[0] = false; - m_bShiftPressed[1] = false; - - ensureDirectoryExists(_storageDir.c_str()); - - m_pSoundSystem = nullptr; - - // Default Touchscreen Mode -#ifdef ANDROID - m_bIsTouchscreen = true; -#else - m_bIsTouchscreen = false; -#endif - // Custom Touchscreen Mode - const char *mode = getenv("MCPE_INPUT_MODE"); - if (mode) - { - if (strcmp(mode, "touch") == 0) - { - m_bIsTouchscreen = true; - } - else if (strcmp(mode, "mouse") == 0) - { - m_bIsTouchscreen = false; - } - } - - // Look for a pre-existing controller - _controller = findGameController(); - - clearDiff(); -} - -void AppPlatform_sdl_base::initSoundSystem() -{ - if (!m_pSoundSystem) - { - LOG_I("Initializing " STR(SOUND_SYSTEM) "..."); - m_pSoundSystem = new SOUND_SYSTEM(); - } - else - { - LOG_E("Trying to initialize SoundSystem more than once!"); - } -} - -void AppPlatform_sdl_base::setIcon(const Texture& icon) -{ - if (!icon.m_pixels) - return; - - SAFE_DELETE(_iconTexture); - if (_icon) SDL_FreeSurface(_icon); - - _iconTexture = new Texture(icon); - _icon = getSurfaceForTexture(_iconTexture); - - if (_icon) - SDL_SetWindowIcon(_window, _icon); -} - -AppPlatform_sdl_base::~AppPlatform_sdl_base() -{ - if (_icon) SDL_FreeSurface(_icon); - SAFE_DELETE(_iconTexture); - - SAFE_DELETE(m_pSoundSystem); -} - -SDL_GameController* AppPlatform_sdl_base::findGameController() -{ - for (int i = 0; i < SDL_NumJoysticks(); i++) { - if (SDL_IsGameController(i)) { - return SDL_GameControllerOpen(i); - } - } - - return nullptr; -} - -SDL_Surface* AppPlatform_sdl_base::getSurfaceForTexture(const Texture* const texture) -{ - if (!texture) return nullptr; - - void * const pixels = texture->m_pixels; - const int width = texture->m_width; - const int height = texture->m_height; - const int depth = 32; // Color depth (32-bit by default) - SDL_Surface* surface = SDL_CreateRGBSurfaceFrom( - pixels, width, height, depth, - width * 4, // Pitch - 0x000000FF, 0x0000FF00, 0x00FF0000, - 0xFF000000 - ); - if (!surface) - LOG_E("Failed loading SDL_Surface from Texture: %s", SDL_GetError()); - - return surface; -} - -int AppPlatform_sdl_base::checkLicense() -{ - // we own the game!! - return 1; -} - -const char* const AppPlatform_sdl_base::getWindowTitle() const -{ - return SDL_GetWindowTitle(_window); -} - -int AppPlatform_sdl_base::getScreenWidth() const -{ - int width; - SDL_GL_GetDrawableSize(_window, &width, nullptr); - return width; -} - -int AppPlatform_sdl_base::getScreenHeight() const -{ - int height; - SDL_GL_GetDrawableSize(_window, nullptr, &height); - return height; -} - -void AppPlatform_sdl_base::setMouseGrabbed(bool b) -{ - SDL_SetWindowGrab(_window, b ? SDL_TRUE : SDL_FALSE); - /** - * @NOTE: There is a bug with older versions of SDL2 (ex: 2.0.4) where disabling RelativeMouseMode will cause a mouse event to be fired - * that just moves the cursor to where it would've been if the mode had never been enabled in the first place, effectively uncentering it. - * https://github.com/libsdl-org/SDL/issues/6002 (I'm not sure if this is the right issue, I just updated SDL after seeing this and it fixed the above problem.) - **/ - SDL_SetRelativeMouseMode(b ? SDL_TRUE : SDL_FALSE); - clearDiff(); -} - -void AppPlatform_sdl_base::setMouseDiff(int x, int y) -{ - xrel += x; - yrel += y; -} - -void AppPlatform_sdl_base::getMouseDiff(int& x, int& y) -{ - x = xrel; - y = yrel; -} - -void AppPlatform_sdl_base::clearDiff() -{ - xrel = 0; - yrel = 0; -} - -bool AppPlatform_sdl_base::shiftPressed() -{ - return m_bShiftPressed[0] || m_bShiftPressed[1]; -} - -void AppPlatform_sdl_base::setShiftPressed(bool b, bool isLeft) -{ - m_bShiftPressed[isLeft ? 0 : 1] = b; -} - -int AppPlatform_sdl_base::getUserInputStatus() -{ - return -1; -} - -MouseButtonType AppPlatform_sdl_base::GetMouseButtonType(SDL_MouseButtonEvent event) -{ - switch (event.button) - { - case SDL_BUTTON_LEFT: - return BUTTON_LEFT; - case SDL_BUTTON_RIGHT: - return BUTTON_RIGHT; - case SDL_BUTTON_MIDDLE: - return BUTTON_MIDDLE; - default: - return BUTTON_NONE; - } -} - -bool AppPlatform_sdl_base::GetMouseButtonState(SDL_Event event) -{ - bool result; - - switch (event.type) - { - case SDL_MOUSEBUTTONDOWN: - result = true; - break; - case SDL_MOUSEBUTTONUP: - result = false; - break; - case SDL_MOUSEWHEEL: - { - short wheelDelta = event.wheel.y; - if (wheelDelta > 0) - { - // "A positive value indicates that the wheel was rotated forward, away from the user." - result = false; - } - else - { - // "A negative value indicates that the wheel was rotated backward, toward the user." - result = true; - } - break; - } - default: - result = false; - break; - } - - return result; -} - -Keyboard::KeyState AppPlatform_sdl_base::GetKeyState(uint8_t state) -{ - switch (state) - { - case SDL_RELEASED: - return Keyboard::UP; - case SDL_PRESSED: - default: - return Keyboard::DOWN; - } -} - -void AppPlatform_sdl_base::showKeyboard(int x, int y, int w, int h) -{ - if (SDL_IsTextInputActive()) - { - hideKeyboard(); - } - SDL_Rect rect; - rect.x = x; - rect.y = y; - rect.w = w; - rect.h = h; - SDL_SetTextInputRect(&rect); - SDL_StartTextInput(); -} - -void AppPlatform_sdl_base::hideKeyboard() -{ - if (SDL_IsTextInputActive()) - { - SDL_StopTextInput(); - } -} - -bool AppPlatform_sdl_base::isTouchscreen() const -{ - return m_bIsTouchscreen; -} - -bool AppPlatform_sdl_base::hasGamepad() const -{ - return _controller != nullptr; -} - -void AppPlatform_sdl_base::gameControllerAdded(int32_t index) -{ - if (!getPrimaryGameController()) - { - setPrimaryGameController(SDL_GameControllerOpen(index)); - Controller::reset(); - } -} - -void AppPlatform_sdl_base::gameControllerRemoved(int32_t index) -{ - SDL_GameController* controller = getPrimaryGameController(); - SDL_JoystickID joystickId = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(controller)); - // Check if current controller has been removed - if (controller && index == joystickId) - { - SDL_GameControllerClose(controller); - // Hunt for a new primary controller - setPrimaryGameController(findGameController()); - } -} - -void AppPlatform_sdl_base::handleKeyEvent(int key, uint8_t state) -{ - // This really should be handled somewhere else. - // Unforunately, there is no global keyboard handler. - // Keyboard events are either handled in Screen::keyboardEvent - // when a Screen is visible, or in Minecraft::tickInput - // when LocalPlayer exists. - switch (key) - { - case SDLVK_F2: - if (state == SDL_PRESSED) - saveScreenshot("", -1, -1); - return; - case SDLVK_AC_BACK: - // Android Back Button (This is currently handled in handle_events() in platforms/sdl/main.cpp) - // @TODO: handleBack function in AppPlatform that calls back to App via function pointer - //g_pApp->handleBack(event.key.state == SDL_PRESSED); - return; - case SDLVK_BACKSPACE: - // Text Editing (This is currently handled in handle_events() in platforms/sdl/main.cpp) - /*if (state == SDL_PRESSED) - g_pApp->handleCharInput('\b');*/ - break; - case SDLVK_LSHIFT: - case SDLVK_RSHIFT: - setShiftPressed(state == SDL_PRESSED, key == SDLVK_LSHIFT); - break; - } - - // Normal Key Press - Keyboard::feed(AppPlatform_sdl_base::GetKeyState(state), key); -} - -void AppPlatform_sdl_base::handleButtonEvent(SDL_JoystickID controllerIndex, uint8_t button, uint8_t state) -{ - // Normal Key Press - Keyboard::feed(AppPlatform_sdl_base::GetKeyState(state), button); -} - -void AppPlatform_sdl_base::handleControllerAxisEvent(SDL_JoystickID controllerIndex, uint8_t axis, int16_t value) -{ - float val = value / 32767.0f; // -32768 to 32767 - - switch (axis) - { - case SDL_CONTROLLER_AXIS_LEFTX: - Controller::feedStickX(1, true, val); - break; - case SDL_CONTROLLER_AXIS_LEFTY: - Controller::feedStickY(1, true, val); - break; - case SDL_CONTROLLER_AXIS_RIGHTX: - Controller::feedStickX(2, true, val); - break; - case SDL_CONTROLLER_AXIS_RIGHTY: - Controller::feedStickY(2, true, val); - break; - case SDL_CONTROLLER_AXIS_TRIGGERLEFT: - Controller::feedTrigger(1, val); - break; - case SDL_CONTROLLER_AXIS_TRIGGERRIGHT: - Controller::feedTrigger(2, val); - break; - } -} - -AssetFile AppPlatform_sdl_base::readAssetFile(const std::string& str, bool quiet) const -{ - std::string path = getAssetPath(str); - SDL_RWops *io = SDL_RWFromFile(path.c_str(), "rb"); - // Open File - if (!io) - { - if (!quiet) LOG_W("Couldn't find asset file: %s", path.c_str()); - return AssetFile(); - } - // Get File Size - int64_t size = SDL_RWsize(io); - if (size < 0) - { - if (!quiet) LOG_E("Error determining the size of the asset file!"); - SDL_RWclose(io); - return AssetFile(); - } - // Read Data - unsigned char *buf = new unsigned char[size]; - SDL_RWread(io, buf, size, 1); - // Close File - SDL_RWclose(io); - // Return - return AssetFile(size, buf); -} \ No newline at end of file diff --git a/platforms/sdl/base/AppPlatform_sdl_base.hpp b/platforms/sdl/base/AppPlatform_sdl_base.hpp deleted file mode 100644 index 4904edae6..000000000 --- a/platforms/sdl/base/AppPlatform_sdl_base.hpp +++ /dev/null @@ -1,92 +0,0 @@ -#pragma once - -#include -#include "thirdparty/SDL2/SDL2.h" - -#include "client/app/AppPlatform.hpp" - -#include "client/player/input/Mouse.hpp" -#include "client/player/input/Keyboard.hpp" -#include "common/Logger.hpp" - -class AppPlatform_sdl_base : public AppPlatform -{ -public: - void _init(std::string storageDir, SDL_Window *window); - AppPlatform_sdl_base(std::string storageDir, SDL_Window *window) - { - _init(storageDir, window); - } - ~AppPlatform_sdl_base() override; - - void initSoundSystem() override; - - int checkLicense() override; - const char* const getWindowTitle() const; - int getScreenWidth() const override; - int getScreenHeight() const override; - Texture loadTexture(const std::string& path, bool bIsRequired = false) override = 0; - int getUserInputStatus() override; - SoundSystem* const getSoundSystem() const override { return m_pSoundSystem; } - - // Also add these to allow proper turning within the game. - void setMouseGrabbed(bool b) override; - void setMouseDiff(int x, int y); - void getMouseDiff(int& x, int& y) override; - void clearDiff() override; - - // Also add these to allow proper text input within the game. - bool shiftPressed() override; - void setShiftPressed(bool b, bool isLeft); - - static MouseButtonType GetMouseButtonType(SDL_MouseButtonEvent event); - static bool GetMouseButtonState(SDL_Event event); - static Keyboard::KeyState GetKeyState(uint8_t state); - - // On-screen keyboard - void showKeyboard(int x, int y, int w, int h) override; - void hideKeyboard() override; - - // Configure Touchscreen - bool isTouchscreen() const override; - - // Game controller - bool hasGamepad() const override; - SDL_GameController* getPrimaryGameController() const { return _controller; } - void setPrimaryGameController(SDL_GameController* controller) { _controller = controller; } - void gameControllerAdded(int32_t index); - void gameControllerRemoved(int32_t index); - - void handleKeyEvent(int key, uint8_t state); - void handleButtonEvent(SDL_JoystickID controllerIndex, uint8_t button, uint8_t state); - void handleControllerAxisEvent(SDL_JoystickID controllerIndex, uint8_t axis, int16_t value); - - // Read Sounds - AssetFile readAssetFile(const std::string&, bool) const override; -protected: - SDL_Window *_window; -private: - SDL_GameController* _controller; - - const Texture *_iconTexture; - SDL_Surface *_icon; - - bool m_bShiftPressed[2]; - - int xrel; - int yrel; - - SoundSystem* m_pSoundSystem; - - bool m_bIsTouchscreen; - - SDL_GameController* findGameController(); - - static SDL_Surface* getSurfaceForTexture(const Texture* const texture); -protected: - std::string _storageDir; - - virtual void ensureDirectoryExists(const char* path) { } - - void setIcon(const Texture& icon); // note: this takes ownership of the texture, so no memory leaks! -}; diff --git a/platforms/sdl/desktop/AppPlatform_sdl.cpp b/platforms/sdl/desktop/AppPlatform_sdl.cpp deleted file mode 100644 index f102b2d05..000000000 --- a/platforms/sdl/desktop/AppPlatform_sdl.cpp +++ /dev/null @@ -1,238 +0,0 @@ -#include -#include -#include -#include - -#include "stb_image.h" -#include "stb_image_write.h" - -#include "AppPlatform_sdl.hpp" - -#include "thirdparty/GL/GL.hpp" - -#include "common/Utils.hpp" - -AppPlatform_sdl::AppPlatform_sdl(std::string storageDir, SDL_Window *window) - : AppPlatform_sdl_base(storageDir, window) -{ - setIcon(loadTexture("icon.png", false)); -} - -// Take Screenshot -static int save_png(const char *filename, unsigned char *pixels, int line_size, int width, int height) -{ - // Setup - stbi_flip_vertically_on_write(true); - - // Write Image - return stbi_write_png(filename, width, height, 4, pixels, line_size); -} - -// Ensure Screenshots Folder Exists -void AppPlatform_sdl::ensureDirectoryExists(const char* path) -{ - // Check Screenshots Folder - struct stat obj; - if (stat(path, &obj) != 0 || !S_ISDIR(obj.st_mode)) - { - // Create Screenshots Folder -#if defined(_WIN32) && !defined(__MINGW32__) - int ret = XPL_MKDIR(path); -#else - int ret = XPL_MKDIR(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); -#endif - if (ret != 0) - { - // Unable To Create Folder - LOG_E("Error Creating Directory: %s: %s", path, strerror(errno)); - exit(EXIT_FAILURE); - } - } -} - -void AppPlatform_sdl::saveScreenshot(const std::string& filename, int glWidth, int glHeight) -{ - // Get Directory - std::string screenshots = _storageDir + "/screenshots"; - - // Get Timestamp - time_t rawtime; - struct tm *timeinfo; - time(&rawtime); - timeinfo = localtime(&rawtime); - char time[256]; - strftime(time, sizeof (time), "%Y-%m-%d_%H.%M.%S", timeinfo); - - // Ensure Screenshots Folder Exists - ensureDirectoryExists(screenshots.c_str()); - - // Prevent Overwriting Screenshots - int num = 1; - const std::string path = screenshots + "/"; - std::string file = path + time + ".png"; - while (XPL_ACCESS(file.c_str(), F_OK) != -1) - { - file = path + SSTR(time << "-" << num << ".png"); - num++; - } - - // Get Image Size - GLint viewport[4]; - glGetIntegerv(GL_VIEWPORT, viewport); - int x = viewport[0]; - int y = viewport[1]; - int width = viewport[2]; - int height = viewport[3]; - - // Get Line Size - int line_size = width * 4; - { - // Handle Alignment - int alignment; - glGetIntegerv(GL_PACK_ALIGNMENT, &alignment); - // Round - int diff = line_size % alignment; - if (diff > 0) - { - line_size = line_size + (alignment - diff); - } - } - int size = height * line_size; - - // Read Pixels - bool fail = false; - unsigned char *pixels = new unsigned char[size]; - if (!pixels) - { - fail = true; - } - else - { - glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); - } - - // Save Image - if (fail || !save_png(file.c_str(), pixels, line_size, width, height)) - { - LOG_E("Screenshot Failed: %s", file.c_str()); - } - else - { - LOG_I("Screenshot Saved: %s", file.c_str()); - } - - // Free - if (!pixels) - { - delete[] pixels; - } -} - -Texture AppPlatform_sdl::loadTexture(const std::string& path, bool bIsRequired) -{ - Texture out; - out.m_hasAlpha = true; - out.field_D = 0; - - // Get Full Path - std::string realPath = getAssetPath(path); - - // Read File - SDL_RWops *io = SDL_RWFromFile(realPath.c_str(), "rb"); - if (!io) - { - LOG_E("Couldn't find file: %s", path.c_str()); - return out; - } - Sint64 size = SDL_RWsize(io); - unsigned char *file = new unsigned char[size]; - SDL_RWread(io, file, size, 1); - SDL_RWclose(io); - - // Parse Image - int width = 0, height = 0, channels = 0; - stbi_uc *img = stbi_load_from_memory(file, size, &width, &height, &channels, STBI_rgb_alpha); - delete[] file; - if (!img) - { - // Failed To Parse Image - LOG_E("The image could not be loaded properly: %s", path.c_str()); - return out; - } - - // Copy Image - uint32_t *img2 = new uint32_t[width * height]; - memcpy(img2, img, width * height * sizeof (uint32_t)); - stbi_image_free(img); - - // Create Texture - out.m_width = width; - out.m_height = height; - out.m_pixels = img2; - - // Return - return out; -} - -bool AppPlatform_sdl::doesTextureExist(const std::string& path) const -{ - // Get Full Path - std::string realPath = getAssetPath(path); - - // Open File - SDL_RWops *io = SDL_RWFromFile(realPath.c_str(), "rb"); - if (!io) - { - // Does Not Exist - return false; - } - else - { - // File Exists - SDL_RWclose(io); - return true; - } -} - -bool AppPlatform_sdl::hasFileSystemAccess() -{ - return true; -} - -std::string AppPlatform_sdl::getPatchData() -{ - std::string path = getAssetPath("patches/patch_data.txt"); - SDL_RWops *io = SDL_RWFromFile(path.c_str(), "rb"); - - if (!io) - { - LOG_W("Couldn't find patch data file!"); - return ""; - } - size_t size = io->size(io); - if (size == -1) - { - LOG_E("Error determining the size of the patch data file!"); - } - - char *buf = new char[size]; - SDL_RWread(io, buf, size, 1); - - SDL_RWclose(io); - - return std::string(buf); -} - -void AppPlatform_sdl::recenterMouse() -{ - // Note. The only reason we do it this way instead of - // using the Mouse class is because, after SDL_WarpMouseInWindow, - // we'll get an event on our window telling us "hey, the - // user has moved their cursor back to the center! Move - // the camera back as well", causing a camera that just - // refuses to move - int w = 0, h = 0; - SDL_GetWindowSize(_window, &w, &h); - SDL_WarpMouseInWindow(_window, w / 2, h / 2); - //Mouse::feed(BUTTON_NONE, false, w / 2, h / 2); -} \ No newline at end of file diff --git a/platforms/sdl/desktop/AppPlatform_sdl.hpp b/platforms/sdl/desktop/AppPlatform_sdl.hpp deleted file mode 100644 index ca4b1d5f5..000000000 --- a/platforms/sdl/desktop/AppPlatform_sdl.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#include - -#include "../base/AppPlatform_sdl_base.hpp" - -#define EM_BOOL bool -#define EM_TRUE true -#define EM_FALSE false - -class AppPlatform_sdl : public AppPlatform_sdl_base -{ -public: - AppPlatform_sdl(std::string storageDir, SDL_Window *window); - - void saveScreenshot(const std::string& fileName, int width, int height) override; - Texture loadTexture(const std::string& path, bool b = false) override; - bool doesTextureExist(const std::string& path) const override; - - bool hasFileSystemAccess() override; - std::string getPatchData() override; - - void recenterMouse() override; - -protected: - void ensureDirectoryExists(const char* path) override; -}; diff --git a/platforms/sdl/sdl1/.gitignore b/platforms/sdl/sdl1/.gitignore new file mode 100644 index 000000000..d01858b20 --- /dev/null +++ b/platforms/sdl/sdl1/.gitignore @@ -0,0 +1,2 @@ +/build +/assets diff --git a/platforms/sdl/sdl1/CMakeLists.txt b/platforms/sdl/sdl1/CMakeLists.txt new file mode 100644 index 000000000..5d5945837 --- /dev/null +++ b/platforms/sdl/sdl1/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.16.0) +project(reminecraftpe-sdl1) + +# SDL Build +target_compile_definitions(reminecraftpe-core + PUBLIC USE_SDL + PUBLIC USE_SDL1 + PUBLIC HANDLE_CHARS_SEPARATELY +) + +# Build +set(SOURCES + main.cpp + base/AppPlatform_sdl1.cpp + ../base/AppPlatform_sdl.cpp +) +list(APPEND SOURCES desktop/AppPlatform_sdl1_desktop.cpp) +add_executable(reminecraftpe ${SOURCES}) + +# Core +target_link_libraries(reminecraftpe reminecraftpe-core) + +# stb_image (If Needed) +target_link_libraries(reminecraftpe stb_image) + +# SDL (From system) +find_package(SDL REQUIRED) +target_include_directories(reminecraftpe-core PUBLIC "${SDL_INCLUDE_DIR}") +target_link_libraries(reminecraftpe-core PUBLIC "${SDL_LIBRARY}") +if(SDLMAIN_LIBRARY) + target_link_libraries(reminecraftpe "${SDLMAIN_LIBRARY}") +endif() + +# OpenGL +find_package(OpenGL REQUIRED) +target_link_libraries(reminecraftpe-core PUBLIC OpenGL::GL) diff --git a/platforms/sdl/sdl1/base/AppPlatform_sdl1.cpp b/platforms/sdl/sdl1/base/AppPlatform_sdl1.cpp new file mode 100644 index 000000000..27eea2fcb --- /dev/null +++ b/platforms/sdl/sdl1/base/AppPlatform_sdl1.cpp @@ -0,0 +1,80 @@ +#include "AppPlatform_sdl1.hpp" + +#include "thirdparty/SDL/SDL_gamecontroller.h" +#include "thirdparty/GL/GL.hpp" + +#include "common/Utils.hpp" +#include "CustomSoundSystem.hpp" +#include "client/player/input/Controller.hpp" + +// Macros are cursed +#define _STR(x) #x +#define STR(x) _STR(x) + +void AppPlatform_sdl1::_init(std::string storageDir, SDL_Surface* screen) +{ + m_pScreen = screen; + + // Look for a pre-existing joystick + m_pJoystick = _findJoystick(); +} + +AppPlatform_sdl1::~AppPlatform_sdl1() +{ +} + +SDL_Joystick* AppPlatform_sdl1::_findJoystick() +{ + if (SDL_NumJoysticks() > 0) + return SDL_JoystickOpen(0); + return nullptr; +} + +void AppPlatform_sdl1::_updateWindowIcon() +{ + if (m_pIcon) + SDL_WM_SetIcon(m_pIcon, nullptr); +} + +void AppPlatform_sdl1::_setMouseGrabbed(bool b) +{ + SDL_WM_GrabInput(b ? SDL_GRAB_ON : SDL_GRAB_OFF); + SDL_ShowCursor(b ? SDL_FALSE : SDL_TRUE); +} + +const char* AppPlatform_sdl1::getWindowTitle() const +{ + char* title; + SDL_WM_GetCaption(&title, nullptr); + return title; +} + +int AppPlatform_sdl1::getScreenWidth() const +{ + return m_pScreen ? m_pScreen->w : 0; +} + +int AppPlatform_sdl1::getScreenHeight() const +{ + return m_pScreen ? m_pScreen->h : 0; +} + +bool AppPlatform_sdl1::hasGamepad() const +{ + return m_pJoystick != nullptr; +} + +void AppPlatform_sdl1::joystickAdded(int index) +{ + if (!m_pJoystick) + m_pJoystick = SDL_JoystickOpen(index); +} + +void AppPlatform_sdl1::joystickRemoved(int index) +{ + if (m_pJoystick && SDL_JoystickIndex(m_pJoystick) == index) + { + SDL_JoystickClose(m_pJoystick); + m_pJoystick = _findJoystick(); + } +} \ No newline at end of file diff --git a/platforms/sdl/sdl1/base/AppPlatform_sdl1.hpp b/platforms/sdl/sdl1/base/AppPlatform_sdl1.hpp new file mode 100644 index 000000000..4302fc332 --- /dev/null +++ b/platforms/sdl/sdl1/base/AppPlatform_sdl1.hpp @@ -0,0 +1,51 @@ +#pragma once + +#include +#include "thirdparty/SDL/SDL.h" + +#include "common/Logger.hpp" + +#include "client/player/input/Mouse.hpp" +#include "client/player/input/Keyboard.hpp" + +#include "platforms/sdl/base/AppPlatform_sdl.hpp" + +class AppPlatform_sdl1 : public AppPlatform_sdl +{ +private: + void _init(std::string storageDir, SDL_Surface* screen); + +public: + AppPlatform_sdl1(std::string storageDir, SDL_Surface* screen) + : AppPlatform_sdl(storageDir) + { + _init(storageDir, screen); + } + ~AppPlatform_sdl1() override; + +private: + SDL_Joystick* _findJoystick(); + +protected: + void _updateWindowIcon() override; + void _setMouseGrabbed(bool b) override; + +public: + const char* getWindowTitle() const override; + + int getScreenWidth() const override; + int getScreenHeight() const override; + + // Game controller + bool hasGamepad() const override; + SDL_Joystick* getPrimaryJoystick() const { return m_pJoystick; } + void setPrimaryJoystick(SDL_Joystick* joystick) { m_pJoystick = joystick; } + void joystickAdded(int index); + void joystickRemoved(int index); + +private: + SDL_Joystick* m_pJoystick; + +protected: + SDL_Surface* m_pScreen; +}; diff --git a/platforms/sdl/sdl1/desktop/AppPlatform_sdl1_desktop.cpp b/platforms/sdl/sdl1/desktop/AppPlatform_sdl1_desktop.cpp new file mode 100644 index 000000000..594269885 --- /dev/null +++ b/platforms/sdl/sdl1/desktop/AppPlatform_sdl1_desktop.cpp @@ -0,0 +1,22 @@ +#include "AppPlatform_sdl1_desktop.hpp" + +AppPlatform_sdl1_desktop::AppPlatform_sdl1_desktop(std::string storageDir, SDL_Surface* screen) + : AppPlatform_sdl1(storageDir, screen) +{ + _setDefaultIcon(); +} + +bool AppPlatform_sdl1_desktop::hasFileSystemAccess() +{ + return true; +} + +void AppPlatform_sdl1_desktop::recenterMouse() +{ + SDL_WarpMouse(m_pScreen->w / 2, m_pScreen->h / 2); +} + +bool AppPlatform_sdl1_desktop::getRecenterMouseEveryTick() +{ + return false; +} diff --git a/platforms/sdl/sdl1/desktop/AppPlatform_sdl1_desktop.hpp b/platforms/sdl/sdl1/desktop/AppPlatform_sdl1_desktop.hpp new file mode 100644 index 000000000..2ac7a7889 --- /dev/null +++ b/platforms/sdl/sdl1/desktop/AppPlatform_sdl1_desktop.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include +#include "thirdparty/SDL/SDL.h" + +#include "../base/AppPlatform_sdl1.hpp" + +class AppPlatform_sdl1_desktop : public AppPlatform_sdl1 +{ +public: + AppPlatform_sdl1_desktop(std::string storageDir, SDL_Surface *screen); + + bool hasFileSystemAccess() override; + + void recenterMouse() override; + bool getRecenterMouseEveryTick() override; +}; diff --git a/platforms/sdl/sdl1/main.cpp b/platforms/sdl/sdl1/main.cpp new file mode 100644 index 000000000..d171b23eb --- /dev/null +++ b/platforms/sdl/sdl1/main.cpp @@ -0,0 +1,218 @@ +#include +#include "thirdparty/SDL/SDL.h" +#include "thirdparty/SDL/SDL_gamecontroller.h" +#include "thirdparty/GL/GL.hpp" + +#include "client/app/App.hpp" +#include "desktop/AppPlatform_sdl1_desktop.hpp" +typedef AppPlatform_sdl1_desktop UsedAppPlatform; + +#include "client/app/NinecraftApp.hpp" +#include "client/player/input/Multitouch.hpp" + +// Video Mode Flags +#define VIDEO_FLAGS (SDL_OPENGL | SDL_RESIZABLE) + +static float g_fPointToPixelScale = 1.0f; + +UsedAppPlatform* g_pAppPlatform; +NinecraftApp* g_pApp; + +SDL_Surface* screen = NULL; + +static void teardown() +{ + if (screen != NULL) + { + SDL_Quit(); + screen = NULL; + } +} + +// DirectSound Support +#ifdef _WIN32 +HWND GetHWND() +{ + SDL_SysWMinfo wmInfo; + SDL_VERSION(&wmInfo.version); + SDL_GetWMInfo(&wmInfo); + return wmInfo.window; +} +#endif + +// Handle Events +static bool window_resized = false; +static void handle_events() +{ + SDL_Event event; + while (SDL_PollEvent(&event)) + { + switch (event.type) + { + case SDL_KEYDOWN: + case SDL_KEYUP: + { + if (event.type == SDL_KEYDOWN && event.key.keysym.unicode > 0) + { + if ((event.key.keysym.unicode & 0xFF80) == 0) + { + char ch = event.key.keysym.unicode & 0x7F; + g_pApp->handleCharInput(ch); + } + else + { + // An international character.. + } + } + + g_pAppPlatform->handleKeyEvent(event); + break; + } + case SDL_JOYBUTTONDOWN: + case SDL_JOYBUTTONUP: + { + // Hate this hack + if (event.jbutton.button == SDL_CONTROLLER_BUTTON_START && event.jbutton.state == SDL_PRESSED) + { + g_pApp->pauseGame() || g_pApp->resumeGame(); + } + g_pAppPlatform->handleControllerButtonEvent(event.jbutton.which, event.jbutton.button, event.jbutton.state); + break; + } + case SDL_MOUSEBUTTONDOWN: + case SDL_MOUSEBUTTONUP: + { + const float scale = g_fPointToPixelScale; + MouseButtonType type = UsedAppPlatform::GetMouseButtonType(event.button.button); + bool state = UsedAppPlatform::GetMouseButtonState(event); + float x = event.button.x * scale; + float y = event.button.y * scale; + Mouse::feed(type, state, x, y); + break; + } + case SDL_MOUSEMOTION: + { + float scale = g_fPointToPixelScale; + float x = event.motion.x * scale; + float y = event.motion.y * scale; + Mouse::feed(BUTTON_NONE, false, x, y); + g_pAppPlatform->setMouseDiff(event.motion.xrel * scale, event.motion.yrel * scale); + break; + } + case SDL_JOYAXISMOTION: + g_pAppPlatform->handleControllerAxisEvent(event.jaxis.which, event.jaxis.axis, event.jaxis.value); + break; + case SDL_VIDEORESIZE: + { + screen = SDL_SetVideoMode(event.resize.w, event.resize.h, 0, VIDEO_FLAGS); + g_pApp->onGraphicsReset(); + window_resized = true; + break; + } + case SDL_QUIT: + { + g_pApp->quit(); + break; + } + } + } +} + +// Resizing +static void resize() +{ + Minecraft::width = screen->w; + Minecraft::height = screen->h; + + g_fPointToPixelScale = float(screen->w) / float(screen->w); + + Minecraft::setRenderScaleMultiplier(g_fPointToPixelScale); + + if (g_pApp) + g_pApp->sizeUpdate(screen->w, screen->h); +} + +// Main Loop +static void main_loop() +{ + handle_events(); + + if (window_resized) + { + window_resized = false; + resize(); + } + + g_pApp->update(); + + SDL_GL_SwapBuffers(); + + if (g_pApp->wantToQuit()) + { + g_pApp->saveOptions(); + delete g_pApp; + delete g_pAppPlatform; + teardown(); + exit(0); + } +} + +// Main +int main(int argc, char* argv[]) +{ + Logger::setSingleton(new Logger); + + if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) + { + exit(EXIT_FAILURE); + } + + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + + SDL_EnableUNICODE(SDL_TRUE); + + SDL_WM_SetCaption("ReMinecraftPE", nullptr); + screen = SDL_SetVideoMode(Minecraft::width, Minecraft::height, 0, VIDEO_FLAGS); + if (!screen) + { + exit(EXIT_FAILURE); + } + +#ifdef _WIN32 + xglInit(); + if (!xglInitted()) + { + const char* const GL_ERROR_MSG = "Error initializing GL extensions. OpenGL 2.0 or later is required."; + exit(EXIT_FAILURE); + } +#endif + + atexit(teardown); + + std::string storagePath; +#ifdef _WIN32 + storagePath = getenv("APPDATA"); +#else + storagePath = getenv("HOME"); +#endif + storagePath += "/.reminecraftpe"; + + if (!storagePath.empty()) + createFolderIfNotExists(storagePath.c_str()); + + g_pApp = new NinecraftApp; + g_pApp->m_externalStorageDir = storagePath; + g_pAppPlatform = new UsedAppPlatform(g_pApp->m_externalStorageDir, screen); + g_pApp->m_pPlatform = g_pAppPlatform; + g_pApp->init(); + + resize(); + + while (true) + { + main_loop(); + } + + return 0; +} diff --git a/platforms/sdl/CMakeLists.txt b/platforms/sdl/sdl2/CMakeLists.txt similarity index 83% rename from platforms/sdl/CMakeLists.txt rename to platforms/sdl/sdl2/CMakeLists.txt index abc4a1029..456831043 100644 --- a/platforms/sdl/CMakeLists.txt +++ b/platforms/sdl/sdl2/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.16.0) -project(reminecraftpe-sdl) +project(reminecraftpe-sdl2) # SDL Build target_compile_definitions(reminecraftpe-core @@ -10,12 +10,13 @@ target_compile_definitions(reminecraftpe-core # Build set(SOURCES main.cpp - base/AppPlatform_sdl_base.cpp + base/AppPlatform_sdl2.cpp + ../base/AppPlatform_sdl.cpp ) if(EMSCRIPTEN) - list(APPEND SOURCES emscripten/AppPlatform_sdl.cpp) + list(APPEND SOURCES emscripten/AppPlatform_sdl2_emscripten.cpp) else() - list(APPEND SOURCES desktop/AppPlatform_sdl.cpp) + list(APPEND SOURCES desktop/AppPlatform_sdl2_desktop.cpp) endif() if(ANDROID) add_library(reminecraftpe SHARED ${SOURCES}) @@ -27,16 +28,14 @@ endif() # Core target_link_libraries(reminecraftpe reminecraftpe-core) -# stb_image (If Needed) -if(NOT EMSCRIPTEN) - target_link_libraries(reminecraftpe stb_image) -endif() +# stb_image +target_link_libraries(reminecraftpe stb_image) # SDL add_library(SDL INTERFACE) if(ANDROID OR MCPE_WIN32) # Use Vendored SDL2 (Only For Android) - add_subdirectory(../../thirdparty/SDL2/src SDL EXCLUDE_FROM_ALL) + add_subdirectory(../../../thirdparty/SDL2/src SDL EXCLUDE_FROM_ALL) target_link_libraries(SDL INTERFACE SDL2::SDL2) elseif(EMSCRIPTEN) # Use Emscripten's SDL2 diff --git a/platforms/sdl/android/.gitignore b/platforms/sdl/sdl2/android/.gitignore similarity index 100% rename from platforms/sdl/android/.gitignore rename to platforms/sdl/sdl2/android/.gitignore diff --git a/platforms/sdl/android/app/.gitignore b/platforms/sdl/sdl2/android/app/.gitignore similarity index 100% rename from platforms/sdl/android/app/.gitignore rename to platforms/sdl/sdl2/android/app/.gitignore diff --git a/platforms/sdl/android/app/build.gradle b/platforms/sdl/sdl2/android/app/build.gradle similarity index 86% rename from platforms/sdl/android/app/build.gradle rename to platforms/sdl/sdl2/android/app/build.gradle index f08bc84ae..b16082fc3 100644 --- a/platforms/sdl/android/app/build.gradle +++ b/platforms/sdl/sdl2/android/app/build.gradle @@ -28,12 +28,12 @@ android { .dependsOn("externalNativeBuild${variant.name.capitalize()}") } sourceSets.main { - java.srcDir '../../../../thirdparty/SDL2/src/android-project/app/src/main/java' - assets.srcDir '../../../../game' + java.srcDir '../../../../../thirdparty/SDL2/src/android-project/app/src/main/java' + assets.srcDir '../../../../../game' } externalNativeBuild { cmake { - path '../../../../CMakeLists.txt' + path '../../../../../CMakeLists.txt' version '3.22.1' } } diff --git a/platforms/sdl/android/app/proguard-rules.pro b/platforms/sdl/sdl2/android/app/proguard-rules.pro similarity index 100% rename from platforms/sdl/android/app/proguard-rules.pro rename to platforms/sdl/sdl2/android/app/proguard-rules.pro diff --git a/platforms/sdl/android/app/src/main/AndroidManifest.xml b/platforms/sdl/sdl2/android/app/src/main/AndroidManifest.xml similarity index 100% rename from platforms/sdl/android/app/src/main/AndroidManifest.xml rename to platforms/sdl/sdl2/android/app/src/main/AndroidManifest.xml diff --git a/platforms/sdl/android/app/src/main/ic_launcher-playstore.png b/platforms/sdl/sdl2/android/app/src/main/ic_launcher-playstore.png similarity index 100% rename from platforms/sdl/android/app/src/main/ic_launcher-playstore.png rename to platforms/sdl/sdl2/android/app/src/main/ic_launcher-playstore.png diff --git a/platforms/sdl/android/app/src/main/java/io/github/reminecraftpe/ImmersiveModeStrategy.java b/platforms/sdl/sdl2/android/app/src/main/java/io/github/reminecraftpe/ImmersiveModeStrategy.java similarity index 100% rename from platforms/sdl/android/app/src/main/java/io/github/reminecraftpe/ImmersiveModeStrategy.java rename to platforms/sdl/sdl2/android/app/src/main/java/io/github/reminecraftpe/ImmersiveModeStrategy.java diff --git a/platforms/sdl/android/app/src/main/java/io/github/reminecraftpe/MainActivity.java b/platforms/sdl/sdl2/android/app/src/main/java/io/github/reminecraftpe/MainActivity.java similarity index 100% rename from platforms/sdl/android/app/src/main/java/io/github/reminecraftpe/MainActivity.java rename to platforms/sdl/sdl2/android/app/src/main/java/io/github/reminecraftpe/MainActivity.java diff --git a/platforms/sdl/android/app/src/main/java/org/libsdl/app/LimitedSDLActivity.java b/platforms/sdl/sdl2/android/app/src/main/java/org/libsdl/app/LimitedSDLActivity.java similarity index 100% rename from platforms/sdl/android/app/src/main/java/org/libsdl/app/LimitedSDLActivity.java rename to platforms/sdl/sdl2/android/app/src/main/java/org/libsdl/app/LimitedSDLActivity.java diff --git a/platforms/sdl/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/platforms/sdl/sdl2/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml similarity index 100% rename from platforms/sdl/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml rename to platforms/sdl/sdl2/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml diff --git a/platforms/sdl/android/app/src/main/res/drawable/ic_launcher_background.xml b/platforms/sdl/sdl2/android/app/src/main/res/drawable/ic_launcher_background.xml similarity index 100% rename from platforms/sdl/android/app/src/main/res/drawable/ic_launcher_background.xml rename to platforms/sdl/sdl2/android/app/src/main/res/drawable/ic_launcher_background.xml diff --git a/platforms/sdl/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/platforms/sdl/sdl2/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml similarity index 100% rename from platforms/sdl/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml rename to platforms/sdl/sdl2/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml diff --git a/platforms/sdl/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/platforms/sdl/sdl2/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml similarity index 100% rename from platforms/sdl/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml rename to platforms/sdl/sdl2/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml diff --git a/platforms/sdl/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/platforms/sdl/sdl2/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp similarity index 100% rename from platforms/sdl/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp rename to platforms/sdl/sdl2/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp diff --git a/platforms/sdl/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/platforms/sdl/sdl2/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp similarity index 100% rename from platforms/sdl/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp rename to platforms/sdl/sdl2/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp diff --git a/platforms/sdl/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/platforms/sdl/sdl2/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp similarity index 100% rename from platforms/sdl/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp rename to platforms/sdl/sdl2/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp diff --git a/platforms/sdl/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/platforms/sdl/sdl2/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp similarity index 100% rename from platforms/sdl/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp rename to platforms/sdl/sdl2/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp diff --git a/platforms/sdl/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/platforms/sdl/sdl2/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp similarity index 100% rename from platforms/sdl/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp rename to platforms/sdl/sdl2/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp diff --git a/platforms/sdl/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/platforms/sdl/sdl2/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp similarity index 100% rename from platforms/sdl/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp rename to platforms/sdl/sdl2/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp diff --git a/platforms/sdl/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/platforms/sdl/sdl2/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp similarity index 100% rename from platforms/sdl/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp rename to platforms/sdl/sdl2/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp diff --git a/platforms/sdl/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/platforms/sdl/sdl2/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp similarity index 100% rename from platforms/sdl/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp rename to platforms/sdl/sdl2/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp diff --git a/platforms/sdl/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/platforms/sdl/sdl2/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp similarity index 100% rename from platforms/sdl/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp rename to platforms/sdl/sdl2/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp diff --git a/platforms/sdl/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/platforms/sdl/sdl2/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp similarity index 100% rename from platforms/sdl/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp rename to platforms/sdl/sdl2/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp diff --git a/platforms/sdl/android/app/src/main/res/values/strings.xml b/platforms/sdl/sdl2/android/app/src/main/res/values/strings.xml similarity index 100% rename from platforms/sdl/android/app/src/main/res/values/strings.xml rename to platforms/sdl/sdl2/android/app/src/main/res/values/strings.xml diff --git a/platforms/sdl/android/build.gradle b/platforms/sdl/sdl2/android/build.gradle similarity index 100% rename from platforms/sdl/android/build.gradle rename to platforms/sdl/sdl2/android/build.gradle diff --git a/platforms/sdl/android/gradle.properties b/platforms/sdl/sdl2/android/gradle.properties similarity index 100% rename from platforms/sdl/android/gradle.properties rename to platforms/sdl/sdl2/android/gradle.properties diff --git a/platforms/sdl/android/gradle/wrapper/gradle-wrapper.jar b/platforms/sdl/sdl2/android/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from platforms/sdl/android/gradle/wrapper/gradle-wrapper.jar rename to platforms/sdl/sdl2/android/gradle/wrapper/gradle-wrapper.jar diff --git a/platforms/sdl/android/gradle/wrapper/gradle-wrapper.properties b/platforms/sdl/sdl2/android/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from platforms/sdl/android/gradle/wrapper/gradle-wrapper.properties rename to platforms/sdl/sdl2/android/gradle/wrapper/gradle-wrapper.properties diff --git a/platforms/sdl/android/gradlew b/platforms/sdl/sdl2/android/gradlew similarity index 100% rename from platforms/sdl/android/gradlew rename to platforms/sdl/sdl2/android/gradlew diff --git a/platforms/sdl/android/gradlew.bat b/platforms/sdl/sdl2/android/gradlew.bat similarity index 100% rename from platforms/sdl/android/gradlew.bat rename to platforms/sdl/sdl2/android/gradlew.bat diff --git a/platforms/sdl/android/settings.gradle b/platforms/sdl/sdl2/android/settings.gradle similarity index 100% rename from platforms/sdl/android/settings.gradle rename to platforms/sdl/sdl2/android/settings.gradle diff --git a/platforms/sdl/sdl2/base/AppPlatform_sdl2.cpp b/platforms/sdl/sdl2/base/AppPlatform_sdl2.cpp new file mode 100644 index 000000000..9697ce2a2 --- /dev/null +++ b/platforms/sdl/sdl2/base/AppPlatform_sdl2.cpp @@ -0,0 +1,175 @@ +#include +#include +#include +#include + +#include "AppPlatform_sdl2.hpp" + +#ifdef __EMSCRIPTEN__ +#include +#else +#include "thirdparty/GL/GL.hpp" +#endif + +#include "common/Utils.hpp" + +#include "CustomSoundSystem.hpp" +// Macros are cursed +#define _STR(x) #x +#define STR(x) _STR(x) + +#include "client/player/input/Controller.hpp" + +void AppPlatform_sdl2::_init(SDL_Window *window) +{ + m_pWindow = window; + + // Look for a pre-existing controller + m_pController = _findGameController(); +} + +AppPlatform_sdl2::~AppPlatform_sdl2() +{ +} + +SDL_GameController* AppPlatform_sdl2::_findGameController() +{ + for (int i = 0; i < SDL_NumJoysticks(); i++) + { + if (SDL_IsGameController(i)) + { + return SDL_GameControllerOpen(i); + } + } + + return nullptr; +} + +void AppPlatform_sdl2::_updateWindowIcon() +{ + if (m_pWindow && m_pIcon) + SDL_SetWindowIcon(m_pWindow, m_pIcon); +} + +void AppPlatform_sdl2::_setMouseGrabbed(bool b) +{ + SDL_SetWindowGrab(m_pWindow, b ? SDL_TRUE : SDL_FALSE); + /** + * @NOTE: There is a bug with older versions of SDL2 (ex: 2.0.4) where disabling RelativeMouseMode will cause a mouse event to be fired + * that just moves the cursor to where it would've been if the mode had never been enabled in the first place, effectively uncentering it. + * https://github.com/libsdl-org/SDL/issues/6002 (I'm not sure if this is the right issue, I just updated SDL after seeing this and it fixed the above problem.) + **/ + SDL_SetRelativeMouseMode(b ? SDL_TRUE : SDL_FALSE); +} + +void AppPlatform_sdl2::_handleKeyEvent(int key, uint8_t state) +{ + switch (key) + { + case SDLVK_AC_BACK: + // Android Back Button (This is currently handled in handle_events() in platforms/sdl/main.cpp) + // @TODO: handleBack function in AppPlatform that calls back to App via function pointer + //g_pApp->handleBack(event.key.state == SDL_PRESSED); + return; + } + + return AppPlatform_sdl::_handleKeyEvent(key, state); +} + +const char* AppPlatform_sdl2::getWindowTitle() const +{ + return SDL_GetWindowTitle(m_pWindow); +} + +int AppPlatform_sdl2::getScreenWidth() const +{ + int width; + SDL_GL_GetDrawableSize(m_pWindow, &width, nullptr); + return width; +} + +int AppPlatform_sdl2::getScreenHeight() const +{ + int height; + SDL_GL_GetDrawableSize(m_pWindow, nullptr, &height); + return height; +} + +void AppPlatform_sdl2::showKeyboard(int x, int y, int w, int h) +{ + if (SDL_IsTextInputActive()) + { + hideKeyboard(); + } + SDL_Rect rect; + rect.x = x; + rect.y = y; + rect.w = w; + rect.h = h; + SDL_SetTextInputRect(&rect); + SDL_StartTextInput(); +} + +void AppPlatform_sdl2::hideKeyboard() +{ + if (SDL_IsTextInputActive()) + { + SDL_StopTextInput(); + } +} + +bool AppPlatform_sdl2::hasGamepad() const +{ + return m_pController != nullptr; +} + +void AppPlatform_sdl2::gameControllerAdded(int32_t index) +{ + if (!getPrimaryGameController()) + { + setPrimaryGameController(SDL_GameControllerOpen(index)); + Controller::reset(); + } +} + +void AppPlatform_sdl2::gameControllerRemoved(int32_t index) +{ + SDL_GameController* controller = getPrimaryGameController(); + SDL_JoystickID joystickId = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(controller)); + // Check if current controller has been removed + if (controller && index == joystickId) + { + SDL_GameControllerClose(controller); + // Hunt for a new primary controller + setPrimaryGameController(_findGameController()); + } +} + +bool AppPlatform_sdl2::GetMouseButtonState(const SDL_Event& event) +{ + bool result; + + switch (event.type) + { + case SDL_MOUSEWHEEL: + { + short wheelDelta = event.wheel.y; + if (wheelDelta > 0) + { + // "A positive value indicates that the wheel was rotated forward, away from the user." + result = false; + } + else + { + // "A negative value indicates that the wheel was rotated backward, toward the user." + result = true; + } + break; + } + default: + result = AppPlatform_sdl::GetMouseButtonState(event); + break; + } + + return result; +} \ No newline at end of file diff --git a/platforms/sdl/sdl2/base/AppPlatform_sdl2.hpp b/platforms/sdl/sdl2/base/AppPlatform_sdl2.hpp new file mode 100644 index 000000000..6e97f3c28 --- /dev/null +++ b/platforms/sdl/sdl2/base/AppPlatform_sdl2.hpp @@ -0,0 +1,51 @@ +#pragma once + +#include "platforms/sdl/base/AppPlatform_sdl.hpp" + +class AppPlatform_sdl2 : public AppPlatform_sdl +{ +private: + void _init(SDL_Window* window); + +public: + AppPlatform_sdl2(std::string storageDir, SDL_Window* window) + : AppPlatform_sdl(storageDir) + { + _init(window); + } + ~AppPlatform_sdl2() override; + +private: + SDL_GameController* _findGameController(); + +protected: + void _updateWindowIcon() override; + void _setMouseGrabbed(bool b) override; + void _handleKeyEvent(int key, uint8_t state) override; + +public: + const char* getWindowTitle() const override; + + int getScreenWidth() const override; + int getScreenHeight() const override; + + // On-screen keyboard + void showKeyboard(int x, int y, int w, int h) override; + void hideKeyboard() override; + + // Game controller + bool hasGamepad() const override; + SDL_GameController* getPrimaryGameController() const { return m_pController; } + void setPrimaryGameController(SDL_GameController* controller) { m_pController = controller; } + void gameControllerAdded(int32_t index); + void gameControllerRemoved(int32_t index); + +public: + static bool GetMouseButtonState(const SDL_Event& event); + +private: + SDL_GameController* m_pController; + +protected: + SDL_Window* m_pWindow; +}; diff --git a/platforms/sdl/sdl2/desktop/AppPlatform_sdl2_desktop.cpp b/platforms/sdl/sdl2/desktop/AppPlatform_sdl2_desktop.cpp new file mode 100644 index 000000000..350cbe4eb --- /dev/null +++ b/platforms/sdl/sdl2/desktop/AppPlatform_sdl2_desktop.cpp @@ -0,0 +1,28 @@ +#include "AppPlatform_sdl2_desktop.hpp" + +#include "common/Utils.hpp" + +AppPlatform_sdl2_desktop::AppPlatform_sdl2_desktop(std::string storageDir, SDL_Window *window) + : AppPlatform_sdl2(storageDir, window) +{ + _setDefaultIcon(); +} + +bool AppPlatform_sdl2_desktop::hasFileSystemAccess() +{ + return true; +} + +void AppPlatform_sdl2_desktop::recenterMouse() +{ + // Note. The only reason we do it this way instead of + // using the Mouse class is because, after SDL_WarpMouseInWindow, + // we'll get an event on our window telling us "hey, the + // user has moved their cursor back to the center! Move + // the camera back as well", causing a camera that just + // refuses to move + int w = 0, h = 0; + SDL_GetWindowSize(m_pWindow, &w, &h); + SDL_WarpMouseInWindow(m_pWindow, w / 2, h / 2); + //Mouse::feed(BUTTON_NONE, false, w / 2, h / 2); +} \ No newline at end of file diff --git a/platforms/sdl/sdl2/desktop/AppPlatform_sdl2_desktop.hpp b/platforms/sdl/sdl2/desktop/AppPlatform_sdl2_desktop.hpp new file mode 100644 index 000000000..ace1e53d3 --- /dev/null +++ b/platforms/sdl/sdl2/desktop/AppPlatform_sdl2_desktop.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include + +#include "../base/AppPlatform_sdl2.hpp" + +#define EM_BOOL bool +#define EM_TRUE true +#define EM_FALSE false + +class AppPlatform_sdl2_desktop : public AppPlatform_sdl2 +{ +public: + AppPlatform_sdl2_desktop(std::string storageDir, SDL_Window *window); + + bool hasFileSystemAccess() override; + + void recenterMouse() override; +}; diff --git a/platforms/sdl/emscripten/AppPlatform_sdl.cpp b/platforms/sdl/sdl2/emscripten/AppPlatform_sdl2_emscripten.cpp similarity index 69% rename from platforms/sdl/emscripten/AppPlatform_sdl.cpp rename to platforms/sdl/sdl2/emscripten/AppPlatform_sdl2_emscripten.cpp index 3bf769fca..6110a71b8 100644 --- a/platforms/sdl/emscripten/AppPlatform_sdl.cpp +++ b/platforms/sdl/sdl2/emscripten/AppPlatform_sdl2_emscripten.cpp @@ -1,13 +1,13 @@ -#include "AppPlatform_sdl.hpp" +#include "AppPlatform_sdl2_emscripten.hpp" #include "common/Utils.hpp" -AppPlatform_sdl::AppPlatform_sdl(std::string storageDir, SDL_Window *window) - : AppPlatform_sdl_base(storageDir, window) +AppPlatform_sdl2_emscripten::AppPlatform_sdl2_emscripten(std::string storageDir, SDL_Window *window) + : AppPlatform_sdl2(storageDir, window) { } -Texture AppPlatform_sdl::loadTexture(const std::string& path, bool bIsRequired) +Texture AppPlatform_sdl2_emscripten::loadTexture(const std::string& path, bool bIsRequired) { Texture out; out.m_hasAlpha = true; @@ -29,7 +29,7 @@ Texture AppPlatform_sdl::loadTexture(const std::string& path, bool bIsRequired) return out; } -bool AppPlatform_sdl::doesTextureExist(const std::string& path) const +bool AppPlatform_sdl2_emscripten::doesTextureExist(const std::string& path) const { // Get Full Path std::string realPath = getAssetPath(path); diff --git a/platforms/sdl/emscripten/AppPlatform_sdl.hpp b/platforms/sdl/sdl2/emscripten/AppPlatform_sdl2_emscripten.hpp similarity index 57% rename from platforms/sdl/emscripten/AppPlatform_sdl.hpp rename to platforms/sdl/sdl2/emscripten/AppPlatform_sdl2_emscripten.hpp index 411c7eac6..3a5fb454c 100644 --- a/platforms/sdl/emscripten/AppPlatform_sdl.hpp +++ b/platforms/sdl/sdl2/emscripten/AppPlatform_sdl2_emscripten.hpp @@ -5,12 +5,12 @@ #include #include -#include "../base/AppPlatform_sdl_base.hpp" +#include "../base/AppPlatform_sdl2.hpp" -class AppPlatform_sdl : public AppPlatform_sdl_base +class AppPlatform_sdl2_emscripten : public AppPlatform_sdl2 { public: - AppPlatform_sdl(std::string storageDir, SDL_Window *window); + AppPlatform_sdl2_emscripten(std::string storageDir, SDL_Window *window); Texture loadTexture(const std::string& path, bool b = false) override; bool doesTextureExist(const std::string& path) const override; diff --git a/platforms/sdl/emscripten/wasm_shell.html b/platforms/sdl/sdl2/emscripten/wasm_shell.html similarity index 100% rename from platforms/sdl/emscripten/wasm_shell.html rename to platforms/sdl/sdl2/emscripten/wasm_shell.html diff --git a/platforms/sdl/main.cpp b/platforms/sdl/sdl2/main.cpp similarity index 89% rename from platforms/sdl/main.cpp rename to platforms/sdl/sdl2/main.cpp index 90f78731a..6107b1636 100644 --- a/platforms/sdl/main.cpp +++ b/platforms/sdl/sdl2/main.cpp @@ -1,20 +1,24 @@ #include -#include "thirdparty/SDL2/SDL2.h" +#include "thirdparty/SDL/SDL.h" #include "thirdparty/GL/GL.hpp" #include "client/app/App.hpp" #ifdef __EMSCRIPTEN__ -#include "emscripten/AppPlatform_sdl.hpp" +#include "emscripten/AppPlatform_sdl2_emscripten.hpp" +typedef AppPlatform_sdl2_emscripten UsedAppPlatform; #else -#include "desktop/AppPlatform_sdl.hpp" +#include "desktop/AppPlatform_sdl2_desktop.hpp" +typedef AppPlatform_sdl2_desktop UsedAppPlatform; #endif -typedef AppPlatform_sdl UsedAppPlatform; #include "client/app/NinecraftApp.hpp" #include "client/player/input/Multitouch.hpp" +// Video Mode Flags +#define VIDEO_FLAGS (SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI) + static float g_fPointToPixelScale = 1.0f; UsedAppPlatform *g_pAppPlatform; @@ -33,16 +37,6 @@ static void teardown() } } -static int TranslateSDLKeyCodeToVirtual(int sdlCode) -{ - switch (sdlCode) { - #define CODE(x) case SDLK_ ## x: return SDLVK_ ## x; - #include "compat/SDLKeyCodes.h" - #undef CODE - } - return SDLVK_UNKNOWN; -} - // Touch #define TOUCH_IDS_SIZE (MAX_TOUCHES - 1) // ID 0 Is Reserved For The Mouse struct touch_id_data { @@ -147,26 +141,28 @@ static void handle_events() g_pApp->handleCharInput('\b'); } - g_pAppPlatform->handleKeyEvent(TranslateSDLKeyCodeToVirtual(event.key.keysym.sym), event.key.state); + g_pAppPlatform->handleKeyEvent(event); break; } case SDL_CONTROLLERBUTTONDOWN: case SDL_CONTROLLERBUTTONUP: + { // Hate this hack if (event.cbutton.button == SDL_CONTROLLER_BUTTON_START && event.cbutton.state == SDL_PRESSED) { g_pApp->pauseGame() || g_pApp->resumeGame(); } - g_pAppPlatform->handleButtonEvent(event.cbutton.which, event.cbutton.button, event.cbutton.state); + g_pAppPlatform->handleControllerButtonEvent(event.cbutton.which, event.cbutton.button, event.cbutton.state); break; - + } case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: { - if (event.button.which != SDL_TOUCH_MOUSEID) { + if (event.button.which != SDL_TOUCH_MOUSEID) + { const float scale = g_fPointToPixelScale; - MouseButtonType type = AppPlatform_sdl_base::GetMouseButtonType(event.button); - bool state = AppPlatform_sdl_base::GetMouseButtonState(event); + MouseButtonType type = UsedAppPlatform::GetMouseButtonType(event.button.button); + bool state = UsedAppPlatform::GetMouseButtonState(event); float x = event.button.x * scale; float y = event.button.y * scale; Mouse::feed(type, state, x, y); @@ -176,7 +172,8 @@ static void handle_events() } case SDL_MOUSEMOTION: { - if (event.button.which != SDL_TOUCH_MOUSEID) { + if (event.button.which != SDL_TOUCH_MOUSEID) + { float scale = g_fPointToPixelScale; float x = event.motion.x * scale; float y = event.motion.y * scale; @@ -188,8 +185,9 @@ static void handle_events() } case SDL_MOUSEWHEEL: { - if (event.button.which != SDL_TOUCH_MOUSEID) { - Mouse::feed(BUTTON_SCROLLWHEEL, AppPlatform_sdl_base::GetMouseButtonState(event), Mouse::getX(), Mouse::getY()); + if (event.button.which != SDL_TOUCH_MOUSEID) + { + Mouse::feed(BUTTON_SCROLLWHEEL, UsedAppPlatform::GetMouseButtonState(event), Mouse::getX(), Mouse::getY()); } break; } @@ -198,7 +196,8 @@ static void handle_events() break; case SDL_FINGERDOWN: case SDL_FINGERUP: - case SDL_FINGERMOTION: { + case SDL_FINGERMOTION: + { float x = event.tfinger.x * Minecraft::width; float y = event.tfinger.y * Minecraft::height; handle_touch(x, y, event.type, get_touch_id(event.tfinger.touchId, event.tfinger.fingerId)); @@ -342,8 +341,7 @@ int main(int argc, char *argv[]) SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeLeft LandscapeRight"); // Create Window - int flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI; - window = SDL_CreateWindow("ReMinecraftPE", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, Minecraft::width, Minecraft::height, flags); + window = SDL_CreateWindow("ReMinecraftPE", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, Minecraft::width, Minecraft::height, VIDEO_FLAGS); if (!window) { LOG_E("Unable to create SDL window: %s", SDL_GetError()); diff --git a/platforms/sound/dummy/CMakeLists.txt b/platforms/sound/dummy/CMakeLists.txt new file mode 100644 index 000000000..d2324e4c6 --- /dev/null +++ b/platforms/sound/dummy/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.16.0) +project(reminecraftpe-dummysound) + +# Build +add_library(reminecraftpe-sound STATIC + SoundSystemNull.cpp +) + +target_link_libraries(reminecraftpe-sound PUBLIC reminecraftpe-core) + +# Headers +target_include_directories(reminecraftpe-sound PUBLIC .) diff --git a/platforms/sound/dummy/CustomSoundSystem.hpp b/platforms/sound/dummy/CustomSoundSystem.hpp new file mode 100644 index 000000000..01f9fa5a1 --- /dev/null +++ b/platforms/sound/dummy/CustomSoundSystem.hpp @@ -0,0 +1,45 @@ +#pragma once + +#include +#include "world/phys/Vec2.hpp" +#include "world/phys/Vec3.hpp" + +#include "client/sound/SoundSystem.hpp" +#include "client/sound/SoundData.hpp" + +#define SOUND_SYSTEM SoundSystemNull + +class SoundSystemNull : public SoundSystem +{ +public: + ~SoundSystemNull(); + + bool isAvailable() override; + void setListenerPos(const Vec3& pos) override; + void setListenerAngle(const Vec2& rot) override; + void setListenerVelocity(const Vec3& vel) override; + + void setMusicVolume(float vol) override; + void setSoundVolume(float vol) override; + + void load(const std::string& soundPath, bool is3D, float minDis) override; + void play(const std::string& soundPath) override; + void pause(const std::string& soundPath) override; + void stop(const std::string& soundPath) override; + void playAt(const SoundDesc& sound, const Vec3& pos, float volume, float pitch) override; + + void playMusic(const std::string& soundPath) override; + bool isPlayingMusic() const override; + bool isPlayingMusic(const std::string& soundPath) const override; + void stopMusic() override; + void pauseMusic(bool state) override; + + void update(float elapsedTime) override; + + void startEngine() override; + void stopEngine() override; + + void muteAudio() override; + void unMuteAudio() override; +} override; + diff --git a/platforms/sound/dummy/SoundSystemNull.cpp b/platforms/sound/dummy/SoundSystemNull.cpp new file mode 100644 index 000000000..7c37821b1 --- /dev/null +++ b/platforms/sound/dummy/SoundSystemNull.cpp @@ -0,0 +1,94 @@ +#include "CustomSoundSystem.hpp" + +SoundSystemNull::~SoundSystemNull() +{ +} + +bool SoundSystemNull::isAvailable() +{ + return true; +} + +void SoundSystemNull::setListenerPos(const Vec3& pos) +{ +} + +void SoundSystemNull::setListenerAngle(const Vec2& rot) +{ + /* STUB */ +} + +void SoundSystemNull::setListenerVelocity(const Vec3& vel) +{ + /* STUB */ +} + +void SoundSystemNull::setMusicVolume(float vol) +{ +} + +void SoundSystemNull::setSoundVolume(float vol) +{ +} + +void SoundSystemNull::load(const std::string& soundPath, bool is3D, float minDis) +{ +} + +void SoundSystemNull::play(const std::string& soundPath) +{ +} + +void SoundSystemNull::pause(const std::string& soundPath) +{ +} + +void SoundSystemNull::stop(const std::string& soundPath) +{ +} + +void SoundSystemNull::playAt(const SoundDesc& sound, const Vec3& pos, float volume, float pitch) +{ +} + +void SoundSystemNull::playMusic(const std::string& soundPath) +{ +} + +bool SoundSystemNull::isPlayingMusic() const +{ + return false; +} + +bool SoundSystemNull::isPlayingMusic(const std::string& soundPath) const +{ + return false; +} + +void SoundSystemNull::stopMusic() +{ +} + +void SoundSystemNull::pauseMusic(bool state) +{ +} + +void SoundSystemNull::update(float elapsedTime) +{ +} + +void SoundSystemNull::startEngine() +{ +} + +void SoundSystemNull::stopEngine() +{ +} + +void SoundSystemNull::muteAudio() +{ +} + +void SoundSystemNull::unMuteAudio() +{ +} \ No newline at end of file diff --git a/platforms/sound/openal/SoundStreamAL.cpp b/platforms/sound/openal/SoundStreamAL.cpp index b6848e0c5..d0a35d84a 100644 --- a/platforms/sound/openal/SoundStreamAL.cpp +++ b/platforms/sound/openal/SoundStreamAL.cpp @@ -42,7 +42,7 @@ void SoundStreamAL::_resetSource() void SoundStreamAL::_deleteBuffers() { - alDeleteBuffers(_buffers.size(), _buffers.data()); + alDeleteBuffers(_buffers.size(), _getBuffersArray()); AL_ERROR_CHECK(); _buffers.clear(); @@ -69,6 +69,20 @@ void SoundStreamAL::_resetBuffers() _createBuffers(); } +ALuint* SoundStreamAL::_getBuffersArray() +{ + ALuint* data; +#ifdef USE_OLD_CPP + // @NOTE: This has a chance of crashing and burning on older C++ versions, since vectors + // were not always guaranteed to store their data in a contiguous manner. + data = &_buffers[0]; +#else + data = _buffers.data(); +#endif + + return data; +} + void SoundStreamAL::_setVolume(float vol) { alSourcef(_source, AL_GAIN, vol); @@ -97,7 +111,7 @@ bool SoundStreamAL::_open(const std::string& fileName) { if (!_stream(i)) return false; } - alSourceQueueBuffers(_source, size, _buffers.data()); + alSourceQueueBuffers(_source, size, _getBuffersArray()); AL_ERROR_CHECK(); _play(); diff --git a/platforms/sound/openal/SoundStreamAL.hpp b/platforms/sound/openal/SoundStreamAL.hpp index 287b8b2c6..826c5e7e7 100644 --- a/platforms/sound/openal/SoundStreamAL.hpp +++ b/platforms/sound/openal/SoundStreamAL.hpp @@ -33,6 +33,8 @@ class SoundStreamAL : public SoundStream void _deleteBuffers(); void _createBuffers(); void _resetBuffers(); + + ALuint* _getBuffersArray(); protected: void _setVolume(float vol) override; diff --git a/platforms/windows/minecraftcpp.sln b/platforms/windows/minecraftcpp.sln index 5f8744339..5dbd273ce 100644 --- a/platforms/windows/minecraftcpp.sln +++ b/platforms/windows/minecraftcpp.sln @@ -1,4 +1,3 @@ - Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio Version 10 VisualStudioVersion = 17.6.33723.286 @@ -21,7 +20,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MinecraftClient.Win32", "pr EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MinecraftClient.SDL2", "projects\MinecraftClient.SDL2\MinecraftClient.SDL2.vcxproj", "{5C1CE194-2DC6-441D-96F5-9780D0A10AAB}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2", "projects\SDL2\SDL2.vcxproj", "{A88F87B0-D37B-4385-A870-F349D8001E08}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL", "projects\SDL\SDL.vcxproj", "{A88F87B0-D37B-4385-A870-F349D8001E08}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Renderer", "projects\Renderer\Renderer.vcxproj", "{BD8B8369-D75D-4D12-A85F-C521349B9125}" EndProject @@ -31,18 +30,28 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "STB", "projects\STB\STB.vcx EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NBT", "projects\NBT\NBT.vcxproj", "{B01E1536-505B-4357-B5B6-083EFBF786B0}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MinecraftClient.SDL1", "projects\MinecraftClient.SDL1\MinecraftClient.SDL1.vcxproj", "{06CF6B2F-D39B-4EEB-A582-A4A264C7B682}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug_SDL1|x64 = Debug_SDL1|x64 + Debug_SDL1|x86 = Debug_SDL1|x86 Debug_SDL2|x64 = Debug_SDL2|x64 Debug_SDL2|x86 = Debug_SDL2|x86 Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 + Release_SDL1|x64 = Release_SDL1|x64 + Release_SDL1|x86 = Release_SDL1|x86 Release_SDL2|x64 = Release_SDL2|x64 Release_SDL2|x86 = Release_SDL2|x86 Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5DA292FD-FA40-45D8-900A-6652C9662913}.Debug_SDL1|x64.ActiveCfg = Debug|x64 + {5DA292FD-FA40-45D8-900A-6652C9662913}.Debug_SDL1|x64.Build.0 = Debug|x64 + {5DA292FD-FA40-45D8-900A-6652C9662913}.Debug_SDL1|x86.ActiveCfg = Debug|Win32 + {5DA292FD-FA40-45D8-900A-6652C9662913}.Debug_SDL1|x86.Build.0 = Debug|Win32 {5DA292FD-FA40-45D8-900A-6652C9662913}.Debug_SDL2|x64.ActiveCfg = Debug|x64 {5DA292FD-FA40-45D8-900A-6652C9662913}.Debug_SDL2|x64.Build.0 = Debug|x64 {5DA292FD-FA40-45D8-900A-6652C9662913}.Debug_SDL2|x86.ActiveCfg = Debug|Win32 @@ -51,6 +60,10 @@ Global {5DA292FD-FA40-45D8-900A-6652C9662913}.Debug|x64.Build.0 = Debug|x64 {5DA292FD-FA40-45D8-900A-6652C9662913}.Debug|x86.ActiveCfg = Debug|Win32 {5DA292FD-FA40-45D8-900A-6652C9662913}.Debug|x86.Build.0 = Debug|Win32 + {5DA292FD-FA40-45D8-900A-6652C9662913}.Release_SDL1|x64.ActiveCfg = Release|x64 + {5DA292FD-FA40-45D8-900A-6652C9662913}.Release_SDL1|x64.Build.0 = Release|x64 + {5DA292FD-FA40-45D8-900A-6652C9662913}.Release_SDL1|x86.ActiveCfg = Release|Win32 + {5DA292FD-FA40-45D8-900A-6652C9662913}.Release_SDL1|x86.Build.0 = Release|Win32 {5DA292FD-FA40-45D8-900A-6652C9662913}.Release_SDL2|x64.ActiveCfg = Release|x64 {5DA292FD-FA40-45D8-900A-6652C9662913}.Release_SDL2|x64.Build.0 = Release|x64 {5DA292FD-FA40-45D8-900A-6652C9662913}.Release_SDL2|x86.ActiveCfg = Release|Win32 @@ -59,6 +72,10 @@ Global {5DA292FD-FA40-45D8-900A-6652C9662913}.Release|x64.Build.0 = Release|x64 {5DA292FD-FA40-45D8-900A-6652C9662913}.Release|x86.ActiveCfg = Release|Win32 {5DA292FD-FA40-45D8-900A-6652C9662913}.Release|x86.Build.0 = Release|Win32 + {4B7FCC5F-7E38-4934-B272-2F5BBEF51013}.Debug_SDL1|x64.ActiveCfg = Debug|x64 + {4B7FCC5F-7E38-4934-B272-2F5BBEF51013}.Debug_SDL1|x64.Build.0 = Debug|x64 + {4B7FCC5F-7E38-4934-B272-2F5BBEF51013}.Debug_SDL1|x86.ActiveCfg = Debug|Win32 + {4B7FCC5F-7E38-4934-B272-2F5BBEF51013}.Debug_SDL1|x86.Build.0 = Debug|Win32 {4B7FCC5F-7E38-4934-B272-2F5BBEF51013}.Debug_SDL2|x64.ActiveCfg = Debug|x64 {4B7FCC5F-7E38-4934-B272-2F5BBEF51013}.Debug_SDL2|x64.Build.0 = Debug|x64 {4B7FCC5F-7E38-4934-B272-2F5BBEF51013}.Debug_SDL2|x86.ActiveCfg = Debug|Win32 @@ -67,6 +84,10 @@ Global {4B7FCC5F-7E38-4934-B272-2F5BBEF51013}.Debug|x64.Build.0 = Debug|x64 {4B7FCC5F-7E38-4934-B272-2F5BBEF51013}.Debug|x86.ActiveCfg = Debug|Win32 {4B7FCC5F-7E38-4934-B272-2F5BBEF51013}.Debug|x86.Build.0 = Debug|Win32 + {4B7FCC5F-7E38-4934-B272-2F5BBEF51013}.Release_SDL1|x64.ActiveCfg = Release|x64 + {4B7FCC5F-7E38-4934-B272-2F5BBEF51013}.Release_SDL1|x64.Build.0 = Release|x64 + {4B7FCC5F-7E38-4934-B272-2F5BBEF51013}.Release_SDL1|x86.ActiveCfg = Release|Win32 + {4B7FCC5F-7E38-4934-B272-2F5BBEF51013}.Release_SDL1|x86.Build.0 = Release|Win32 {4B7FCC5F-7E38-4934-B272-2F5BBEF51013}.Release_SDL2|x64.ActiveCfg = Release|x64 {4B7FCC5F-7E38-4934-B272-2F5BBEF51013}.Release_SDL2|x64.Build.0 = Release|x64 {4B7FCC5F-7E38-4934-B272-2F5BBEF51013}.Release_SDL2|x86.ActiveCfg = Release|Win32 @@ -75,6 +96,10 @@ Global {4B7FCC5F-7E38-4934-B272-2F5BBEF51013}.Release|x64.Build.0 = Release|x64 {4B7FCC5F-7E38-4934-B272-2F5BBEF51013}.Release|x86.ActiveCfg = Release|Win32 {4B7FCC5F-7E38-4934-B272-2F5BBEF51013}.Release|x86.Build.0 = Release|Win32 + {71774270-FD1B-4269-BD8F-F75A52D43EB6}.Debug_SDL1|x64.ActiveCfg = Debug_SDL1|x64 + {71774270-FD1B-4269-BD8F-F75A52D43EB6}.Debug_SDL1|x64.Build.0 = Debug_SDL1|x64 + {71774270-FD1B-4269-BD8F-F75A52D43EB6}.Debug_SDL1|x86.ActiveCfg = Debug_SDL1|Win32 + {71774270-FD1B-4269-BD8F-F75A52D43EB6}.Debug_SDL1|x86.Build.0 = Debug_SDL1|Win32 {71774270-FD1B-4269-BD8F-F75A52D43EB6}.Debug_SDL2|x64.ActiveCfg = Debug_SDL2|x64 {71774270-FD1B-4269-BD8F-F75A52D43EB6}.Debug_SDL2|x64.Build.0 = Debug_SDL2|x64 {71774270-FD1B-4269-BD8F-F75A52D43EB6}.Debug_SDL2|x86.ActiveCfg = Debug_SDL2|Win32 @@ -83,6 +108,10 @@ Global {71774270-FD1B-4269-BD8F-F75A52D43EB6}.Debug|x64.Build.0 = Debug|x64 {71774270-FD1B-4269-BD8F-F75A52D43EB6}.Debug|x86.ActiveCfg = Debug|Win32 {71774270-FD1B-4269-BD8F-F75A52D43EB6}.Debug|x86.Build.0 = Debug|Win32 + {71774270-FD1B-4269-BD8F-F75A52D43EB6}.Release_SDL1|x64.ActiveCfg = Release_SDL1|x64 + {71774270-FD1B-4269-BD8F-F75A52D43EB6}.Release_SDL1|x64.Build.0 = Release_SDL1|x64 + {71774270-FD1B-4269-BD8F-F75A52D43EB6}.Release_SDL1|x86.ActiveCfg = Release_SDL1|Win32 + {71774270-FD1B-4269-BD8F-F75A52D43EB6}.Release_SDL1|x86.Build.0 = Release_SDL1|Win32 {71774270-FD1B-4269-BD8F-F75A52D43EB6}.Release_SDL2|x64.ActiveCfg = Release_SDL2|x64 {71774270-FD1B-4269-BD8F-F75A52D43EB6}.Release_SDL2|x64.Build.0 = Release_SDL2|x64 {71774270-FD1B-4269-BD8F-F75A52D43EB6}.Release_SDL2|x86.ActiveCfg = Release_SDL2|Win32 @@ -91,6 +120,10 @@ Global {71774270-FD1B-4269-BD8F-F75A52D43EB6}.Release|x64.Build.0 = Release|x64 {71774270-FD1B-4269-BD8F-F75A52D43EB6}.Release|x86.ActiveCfg = Release|Win32 {71774270-FD1B-4269-BD8F-F75A52D43EB6}.Release|x86.Build.0 = Release|Win32 + {E43F7C6A-A099-48C9-9D37-B56CD8D6D785}.Debug_SDL1|x64.ActiveCfg = Debug|x64 + {E43F7C6A-A099-48C9-9D37-B56CD8D6D785}.Debug_SDL1|x64.Build.0 = Debug|x64 + {E43F7C6A-A099-48C9-9D37-B56CD8D6D785}.Debug_SDL1|x86.ActiveCfg = Debug|Win32 + {E43F7C6A-A099-48C9-9D37-B56CD8D6D785}.Debug_SDL1|x86.Build.0 = Debug|Win32 {E43F7C6A-A099-48C9-9D37-B56CD8D6D785}.Debug_SDL2|x64.ActiveCfg = Debug|x64 {E43F7C6A-A099-48C9-9D37-B56CD8D6D785}.Debug_SDL2|x64.Build.0 = Debug|x64 {E43F7C6A-A099-48C9-9D37-B56CD8D6D785}.Debug_SDL2|x86.ActiveCfg = Debug|Win32 @@ -99,6 +132,10 @@ Global {E43F7C6A-A099-48C9-9D37-B56CD8D6D785}.Debug|x64.Build.0 = Debug|x64 {E43F7C6A-A099-48C9-9D37-B56CD8D6D785}.Debug|x86.ActiveCfg = Debug|Win32 {E43F7C6A-A099-48C9-9D37-B56CD8D6D785}.Debug|x86.Build.0 = Debug|Win32 + {E43F7C6A-A099-48C9-9D37-B56CD8D6D785}.Release_SDL1|x64.ActiveCfg = Release|x64 + {E43F7C6A-A099-48C9-9D37-B56CD8D6D785}.Release_SDL1|x64.Build.0 = Release|x64 + {E43F7C6A-A099-48C9-9D37-B56CD8D6D785}.Release_SDL1|x86.ActiveCfg = Release|Win32 + {E43F7C6A-A099-48C9-9D37-B56CD8D6D785}.Release_SDL1|x86.Build.0 = Release|Win32 {E43F7C6A-A099-48C9-9D37-B56CD8D6D785}.Release_SDL2|x64.ActiveCfg = Release|x64 {E43F7C6A-A099-48C9-9D37-B56CD8D6D785}.Release_SDL2|x64.Build.0 = Release|x64 {E43F7C6A-A099-48C9-9D37-B56CD8D6D785}.Release_SDL2|x86.ActiveCfg = Release|Win32 @@ -107,6 +144,10 @@ Global {E43F7C6A-A099-48C9-9D37-B56CD8D6D785}.Release|x64.Build.0 = Release|x64 {E43F7C6A-A099-48C9-9D37-B56CD8D6D785}.Release|x86.ActiveCfg = Release|Win32 {E43F7C6A-A099-48C9-9D37-B56CD8D6D785}.Release|x86.Build.0 = Release|Win32 + {5F7CD8C1-413C-4855-A450-2C765F16C5A4}.Debug_SDL1|x64.ActiveCfg = Debug|x64 + {5F7CD8C1-413C-4855-A450-2C765F16C5A4}.Debug_SDL1|x64.Build.0 = Debug|x64 + {5F7CD8C1-413C-4855-A450-2C765F16C5A4}.Debug_SDL1|x86.ActiveCfg = Debug|Win32 + {5F7CD8C1-413C-4855-A450-2C765F16C5A4}.Debug_SDL1|x86.Build.0 = Debug|Win32 {5F7CD8C1-413C-4855-A450-2C765F16C5A4}.Debug_SDL2|x64.ActiveCfg = Debug|x64 {5F7CD8C1-413C-4855-A450-2C765F16C5A4}.Debug_SDL2|x64.Build.0 = Debug|x64 {5F7CD8C1-413C-4855-A450-2C765F16C5A4}.Debug_SDL2|x86.ActiveCfg = Debug|Win32 @@ -115,6 +156,10 @@ Global {5F7CD8C1-413C-4855-A450-2C765F16C5A4}.Debug|x64.Build.0 = Debug|x64 {5F7CD8C1-413C-4855-A450-2C765F16C5A4}.Debug|x86.ActiveCfg = Debug|Win32 {5F7CD8C1-413C-4855-A450-2C765F16C5A4}.Debug|x86.Build.0 = Debug|Win32 + {5F7CD8C1-413C-4855-A450-2C765F16C5A4}.Release_SDL1|x64.ActiveCfg = Release|x64 + {5F7CD8C1-413C-4855-A450-2C765F16C5A4}.Release_SDL1|x64.Build.0 = Release|x64 + {5F7CD8C1-413C-4855-A450-2C765F16C5A4}.Release_SDL1|x86.ActiveCfg = Release|Win32 + {5F7CD8C1-413C-4855-A450-2C765F16C5A4}.Release_SDL1|x86.Build.0 = Release|Win32 {5F7CD8C1-413C-4855-A450-2C765F16C5A4}.Release_SDL2|x64.ActiveCfg = Release|x64 {5F7CD8C1-413C-4855-A450-2C765F16C5A4}.Release_SDL2|x64.Build.0 = Release|x64 {5F7CD8C1-413C-4855-A450-2C765F16C5A4}.Release_SDL2|x86.ActiveCfg = Release|Win32 @@ -123,6 +168,10 @@ Global {5F7CD8C1-413C-4855-A450-2C765F16C5A4}.Release|x64.Build.0 = Release|x64 {5F7CD8C1-413C-4855-A450-2C765F16C5A4}.Release|x86.ActiveCfg = Release|Win32 {5F7CD8C1-413C-4855-A450-2C765F16C5A4}.Release|x86.Build.0 = Release|Win32 + {A6E03DCA-99F6-45B8-800D-73060AE407FC}.Debug_SDL1|x64.ActiveCfg = Debug_SDL1|x64 + {A6E03DCA-99F6-45B8-800D-73060AE407FC}.Debug_SDL1|x64.Build.0 = Debug_SDL1|x64 + {A6E03DCA-99F6-45B8-800D-73060AE407FC}.Debug_SDL1|x86.ActiveCfg = Debug_SDL1|Win32 + {A6E03DCA-99F6-45B8-800D-73060AE407FC}.Debug_SDL1|x86.Build.0 = Debug_SDL1|Win32 {A6E03DCA-99F6-45B8-800D-73060AE407FC}.Debug_SDL2|x64.ActiveCfg = Debug_SDL2|x64 {A6E03DCA-99F6-45B8-800D-73060AE407FC}.Debug_SDL2|x64.Build.0 = Debug_SDL2|x64 {A6E03DCA-99F6-45B8-800D-73060AE407FC}.Debug_SDL2|x86.ActiveCfg = Debug_SDL2|Win32 @@ -131,6 +180,10 @@ Global {A6E03DCA-99F6-45B8-800D-73060AE407FC}.Debug|x64.Build.0 = Debug|x64 {A6E03DCA-99F6-45B8-800D-73060AE407FC}.Debug|x86.ActiveCfg = Debug|Win32 {A6E03DCA-99F6-45B8-800D-73060AE407FC}.Debug|x86.Build.0 = Debug|Win32 + {A6E03DCA-99F6-45B8-800D-73060AE407FC}.Release_SDL1|x64.ActiveCfg = Release_SDL1|x64 + {A6E03DCA-99F6-45B8-800D-73060AE407FC}.Release_SDL1|x64.Build.0 = Release_SDL1|x64 + {A6E03DCA-99F6-45B8-800D-73060AE407FC}.Release_SDL1|x86.ActiveCfg = Release_SDL1|Win32 + {A6E03DCA-99F6-45B8-800D-73060AE407FC}.Release_SDL1|x86.Build.0 = Release_SDL1|Win32 {A6E03DCA-99F6-45B8-800D-73060AE407FC}.Release_SDL2|x64.ActiveCfg = Release_SDL2|x64 {A6E03DCA-99F6-45B8-800D-73060AE407FC}.Release_SDL2|x64.Build.0 = Release_SDL2|x64 {A6E03DCA-99F6-45B8-800D-73060AE407FC}.Release_SDL2|x86.ActiveCfg = Release_SDL2|Win32 @@ -139,42 +192,62 @@ Global {A6E03DCA-99F6-45B8-800D-73060AE407FC}.Release|x64.Build.0 = Release|x64 {A6E03DCA-99F6-45B8-800D-73060AE407FC}.Release|x86.ActiveCfg = Release|Win32 {A6E03DCA-99F6-45B8-800D-73060AE407FC}.Release|x86.Build.0 = Release|Win32 + {FF5A623D-03C2-4967-8E78-CB021114A501}.Debug_SDL1|x64.ActiveCfg = Debug|x64 + {FF5A623D-03C2-4967-8E78-CB021114A501}.Debug_SDL1|x86.ActiveCfg = Debug|Win32 {FF5A623D-03C2-4967-8E78-CB021114A501}.Debug_SDL2|x64.ActiveCfg = Debug|x64 {FF5A623D-03C2-4967-8E78-CB021114A501}.Debug_SDL2|x86.ActiveCfg = Debug|Win32 {FF5A623D-03C2-4967-8E78-CB021114A501}.Debug|x64.ActiveCfg = Debug|x64 {FF5A623D-03C2-4967-8E78-CB021114A501}.Debug|x64.Build.0 = Debug|x64 {FF5A623D-03C2-4967-8E78-CB021114A501}.Debug|x86.ActiveCfg = Debug|Win32 {FF5A623D-03C2-4967-8E78-CB021114A501}.Debug|x86.Build.0 = Debug|Win32 + {FF5A623D-03C2-4967-8E78-CB021114A501}.Release_SDL1|x64.ActiveCfg = Release|x64 + {FF5A623D-03C2-4967-8E78-CB021114A501}.Release_SDL1|x86.ActiveCfg = Release|Win32 {FF5A623D-03C2-4967-8E78-CB021114A501}.Release_SDL2|x64.ActiveCfg = Release|x64 {FF5A623D-03C2-4967-8E78-CB021114A501}.Release_SDL2|x86.ActiveCfg = Release|Win32 {FF5A623D-03C2-4967-8E78-CB021114A501}.Release|x64.ActiveCfg = Release|x64 {FF5A623D-03C2-4967-8E78-CB021114A501}.Release|x64.Build.0 = Release|x64 {FF5A623D-03C2-4967-8E78-CB021114A501}.Release|x86.ActiveCfg = Release|Win32 {FF5A623D-03C2-4967-8E78-CB021114A501}.Release|x86.Build.0 = Release|Win32 + {5C1CE194-2DC6-441D-96F5-9780D0A10AAB}.Debug_SDL1|x64.ActiveCfg = Debug_SDL2|x64 + {5C1CE194-2DC6-441D-96F5-9780D0A10AAB}.Debug_SDL1|x86.ActiveCfg = Debug_SDL2|Win32 {5C1CE194-2DC6-441D-96F5-9780D0A10AAB}.Debug_SDL2|x64.ActiveCfg = Debug_SDL2|x64 {5C1CE194-2DC6-441D-96F5-9780D0A10AAB}.Debug_SDL2|x64.Build.0 = Debug_SDL2|x64 {5C1CE194-2DC6-441D-96F5-9780D0A10AAB}.Debug_SDL2|x86.ActiveCfg = Debug_SDL2|Win32 {5C1CE194-2DC6-441D-96F5-9780D0A10AAB}.Debug_SDL2|x86.Build.0 = Debug_SDL2|Win32 {5C1CE194-2DC6-441D-96F5-9780D0A10AAB}.Debug|x64.ActiveCfg = Debug_SDL2|x64 {5C1CE194-2DC6-441D-96F5-9780D0A10AAB}.Debug|x86.ActiveCfg = Debug_SDL2|Win32 + {5C1CE194-2DC6-441D-96F5-9780D0A10AAB}.Release_SDL1|x64.ActiveCfg = Release_SDL2|x64 + {5C1CE194-2DC6-441D-96F5-9780D0A10AAB}.Release_SDL1|x86.ActiveCfg = Release_SDL2|Win32 {5C1CE194-2DC6-441D-96F5-9780D0A10AAB}.Release_SDL2|x64.ActiveCfg = Release_SDL2|x64 {5C1CE194-2DC6-441D-96F5-9780D0A10AAB}.Release_SDL2|x64.Build.0 = Release_SDL2|x64 {5C1CE194-2DC6-441D-96F5-9780D0A10AAB}.Release_SDL2|x86.ActiveCfg = Release_SDL2|Win32 {5C1CE194-2DC6-441D-96F5-9780D0A10AAB}.Release_SDL2|x86.Build.0 = Release_SDL2|Win32 {5C1CE194-2DC6-441D-96F5-9780D0A10AAB}.Release|x64.ActiveCfg = Release_SDL2|x64 {5C1CE194-2DC6-441D-96F5-9780D0A10AAB}.Release|x86.ActiveCfg = Release_SDL2|Win32 + {A88F87B0-D37B-4385-A870-F349D8001E08}.Debug_SDL1|x64.ActiveCfg = Debug_SDL1|x64 + {A88F87B0-D37B-4385-A870-F349D8001E08}.Debug_SDL1|x64.Build.0 = Debug_SDL1|x64 + {A88F87B0-D37B-4385-A870-F349D8001E08}.Debug_SDL1|x86.ActiveCfg = Debug_SDL1|Win32 + {A88F87B0-D37B-4385-A870-F349D8001E08}.Debug_SDL1|x86.Build.0 = Debug_SDL1|Win32 {A88F87B0-D37B-4385-A870-F349D8001E08}.Debug_SDL2|x64.ActiveCfg = Debug_SDL2|x64 {A88F87B0-D37B-4385-A870-F349D8001E08}.Debug_SDL2|x64.Build.0 = Debug_SDL2|x64 {A88F87B0-D37B-4385-A870-F349D8001E08}.Debug_SDL2|x86.ActiveCfg = Debug_SDL2|Win32 {A88F87B0-D37B-4385-A870-F349D8001E08}.Debug_SDL2|x86.Build.0 = Debug_SDL2|Win32 {A88F87B0-D37B-4385-A870-F349D8001E08}.Debug|x64.ActiveCfg = Debug_SDL2|x64 {A88F87B0-D37B-4385-A870-F349D8001E08}.Debug|x86.ActiveCfg = Debug_SDL2|Win32 + {A88F87B0-D37B-4385-A870-F349D8001E08}.Release_SDL1|x64.ActiveCfg = Release_SDL1|x64 + {A88F87B0-D37B-4385-A870-F349D8001E08}.Release_SDL1|x64.Build.0 = Release_SDL1|x64 + {A88F87B0-D37B-4385-A870-F349D8001E08}.Release_SDL1|x86.ActiveCfg = Release_SDL1|Win32 + {A88F87B0-D37B-4385-A870-F349D8001E08}.Release_SDL1|x86.Build.0 = Release_SDL1|Win32 {A88F87B0-D37B-4385-A870-F349D8001E08}.Release_SDL2|x64.ActiveCfg = Release_SDL2|x64 {A88F87B0-D37B-4385-A870-F349D8001E08}.Release_SDL2|x64.Build.0 = Release_SDL2|x64 {A88F87B0-D37B-4385-A870-F349D8001E08}.Release_SDL2|x86.ActiveCfg = Release_SDL2|Win32 {A88F87B0-D37B-4385-A870-F349D8001E08}.Release_SDL2|x86.Build.0 = Release_SDL2|Win32 {A88F87B0-D37B-4385-A870-F349D8001E08}.Release|x64.ActiveCfg = Release_SDL2|x64 {A88F87B0-D37B-4385-A870-F349D8001E08}.Release|x86.ActiveCfg = Release_SDL2|Win32 + {BD8B8369-D75D-4D12-A85F-C521349B9125}.Debug_SDL1|x64.ActiveCfg = Debug|x64 + {BD8B8369-D75D-4D12-A85F-C521349B9125}.Debug_SDL1|x64.Build.0 = Debug|x64 + {BD8B8369-D75D-4D12-A85F-C521349B9125}.Debug_SDL1|x86.ActiveCfg = Debug|Win32 + {BD8B8369-D75D-4D12-A85F-C521349B9125}.Debug_SDL1|x86.Build.0 = Debug|Win32 {BD8B8369-D75D-4D12-A85F-C521349B9125}.Debug_SDL2|x64.ActiveCfg = Debug|x64 {BD8B8369-D75D-4D12-A85F-C521349B9125}.Debug_SDL2|x64.Build.0 = Debug|x64 {BD8B8369-D75D-4D12-A85F-C521349B9125}.Debug_SDL2|x86.ActiveCfg = Debug|Win32 @@ -183,6 +256,10 @@ Global {BD8B8369-D75D-4D12-A85F-C521349B9125}.Debug|x64.Build.0 = Debug|x64 {BD8B8369-D75D-4D12-A85F-C521349B9125}.Debug|x86.ActiveCfg = Debug|Win32 {BD8B8369-D75D-4D12-A85F-C521349B9125}.Debug|x86.Build.0 = Debug|Win32 + {BD8B8369-D75D-4D12-A85F-C521349B9125}.Release_SDL1|x64.ActiveCfg = Release|x64 + {BD8B8369-D75D-4D12-A85F-C521349B9125}.Release_SDL1|x64.Build.0 = Release|x64 + {BD8B8369-D75D-4D12-A85F-C521349B9125}.Release_SDL1|x86.ActiveCfg = Release|Win32 + {BD8B8369-D75D-4D12-A85F-C521349B9125}.Release_SDL1|x86.Build.0 = Release|Win32 {BD8B8369-D75D-4D12-A85F-C521349B9125}.Release_SDL2|x64.ActiveCfg = Release|x64 {BD8B8369-D75D-4D12-A85F-C521349B9125}.Release_SDL2|x64.Build.0 = Release|x64 {BD8B8369-D75D-4D12-A85F-C521349B9125}.Release_SDL2|x86.ActiveCfg = Release|Win32 @@ -191,6 +268,10 @@ Global {BD8B8369-D75D-4D12-A85F-C521349B9125}.Release|x64.Build.0 = Release|x64 {BD8B8369-D75D-4D12-A85F-C521349B9125}.Release|x86.ActiveCfg = Release|Win32 {BD8B8369-D75D-4D12-A85F-C521349B9125}.Release|x86.Build.0 = Release|Win32 + {2E1A5B55-A6D4-4743-A63A-4F27DB03C0A1}.Debug_SDL1|x64.ActiveCfg = Debug_SDL1|x64 + {2E1A5B55-A6D4-4743-A63A-4F27DB03C0A1}.Debug_SDL1|x64.Build.0 = Debug_SDL1|x64 + {2E1A5B55-A6D4-4743-A63A-4F27DB03C0A1}.Debug_SDL1|x86.ActiveCfg = Debug_SDL1|Win32 + {2E1A5B55-A6D4-4743-A63A-4F27DB03C0A1}.Debug_SDL1|x86.Build.0 = Debug_SDL1|Win32 {2E1A5B55-A6D4-4743-A63A-4F27DB03C0A1}.Debug_SDL2|x64.ActiveCfg = Debug_SDL2|x64 {2E1A5B55-A6D4-4743-A63A-4F27DB03C0A1}.Debug_SDL2|x64.Build.0 = Debug_SDL2|x64 {2E1A5B55-A6D4-4743-A63A-4F27DB03C0A1}.Debug_SDL2|x86.ActiveCfg = Debug_SDL2|Win32 @@ -199,6 +280,10 @@ Global {2E1A5B55-A6D4-4743-A63A-4F27DB03C0A1}.Debug|x64.Build.0 = Debug|x64 {2E1A5B55-A6D4-4743-A63A-4F27DB03C0A1}.Debug|x86.ActiveCfg = Debug|Win32 {2E1A5B55-A6D4-4743-A63A-4F27DB03C0A1}.Debug|x86.Build.0 = Debug|Win32 + {2E1A5B55-A6D4-4743-A63A-4F27DB03C0A1}.Release_SDL1|x64.ActiveCfg = Release_SDL1|x64 + {2E1A5B55-A6D4-4743-A63A-4F27DB03C0A1}.Release_SDL1|x64.Build.0 = Release_SDL1|x64 + {2E1A5B55-A6D4-4743-A63A-4F27DB03C0A1}.Release_SDL1|x86.ActiveCfg = Release_SDL1|Win32 + {2E1A5B55-A6D4-4743-A63A-4F27DB03C0A1}.Release_SDL1|x86.Build.0 = Release_SDL1|Win32 {2E1A5B55-A6D4-4743-A63A-4F27DB03C0A1}.Release_SDL2|x64.ActiveCfg = Release_SDL2|x64 {2E1A5B55-A6D4-4743-A63A-4F27DB03C0A1}.Release_SDL2|x64.Build.0 = Release_SDL2|x64 {2E1A5B55-A6D4-4743-A63A-4F27DB03C0A1}.Release_SDL2|x86.ActiveCfg = Release_SDL2|Win32 @@ -207,6 +292,10 @@ Global {2E1A5B55-A6D4-4743-A63A-4F27DB03C0A1}.Release|x64.Build.0 = Release|x64 {2E1A5B55-A6D4-4743-A63A-4F27DB03C0A1}.Release|x86.ActiveCfg = Release|Win32 {2E1A5B55-A6D4-4743-A63A-4F27DB03C0A1}.Release|x86.Build.0 = Release|Win32 + {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Debug_SDL1|x64.ActiveCfg = Debug|x64 + {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Debug_SDL1|x64.Build.0 = Debug|x64 + {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Debug_SDL1|x86.ActiveCfg = Debug|Win32 + {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Debug_SDL1|x86.Build.0 = Debug|Win32 {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Debug_SDL2|x64.ActiveCfg = Debug|x64 {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Debug_SDL2|x64.Build.0 = Debug|x64 {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Debug_SDL2|x86.ActiveCfg = Debug|Win32 @@ -215,6 +304,10 @@ Global {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Debug|x64.Build.0 = Debug|x64 {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Debug|x86.ActiveCfg = Debug|Win32 {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Debug|x86.Build.0 = Debug|Win32 + {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Release_SDL1|x64.ActiveCfg = Release|x64 + {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Release_SDL1|x64.Build.0 = Release|x64 + {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Release_SDL1|x86.ActiveCfg = Release|Win32 + {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Release_SDL1|x86.Build.0 = Release|Win32 {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Release_SDL2|x64.ActiveCfg = Release|x64 {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Release_SDL2|x64.Build.0 = Release|x64 {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Release_SDL2|x86.ActiveCfg = Release|Win32 @@ -223,6 +316,10 @@ Global {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Release|x64.Build.0 = Release|x64 {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Release|x86.ActiveCfg = Release|Win32 {F332CB57-FF16-4D43-BBE0-76F28301DAA8}.Release|x86.Build.0 = Release|Win32 + {B01E1536-505B-4357-B5B6-083EFBF786B0}.Debug_SDL1|x64.ActiveCfg = Debug|x64 + {B01E1536-505B-4357-B5B6-083EFBF786B0}.Debug_SDL1|x64.Build.0 = Debug|x64 + {B01E1536-505B-4357-B5B6-083EFBF786B0}.Debug_SDL1|x86.ActiveCfg = Debug|Win32 + {B01E1536-505B-4357-B5B6-083EFBF786B0}.Debug_SDL1|x86.Build.0 = Debug|Win32 {B01E1536-505B-4357-B5B6-083EFBF786B0}.Debug_SDL2|x64.ActiveCfg = Debug|x64 {B01E1536-505B-4357-B5B6-083EFBF786B0}.Debug_SDL2|x64.Build.0 = Debug|x64 {B01E1536-505B-4357-B5B6-083EFBF786B0}.Debug_SDL2|x86.ActiveCfg = Debug|Win32 @@ -231,6 +328,10 @@ Global {B01E1536-505B-4357-B5B6-083EFBF786B0}.Debug|x64.Build.0 = Debug|x64 {B01E1536-505B-4357-B5B6-083EFBF786B0}.Debug|x86.ActiveCfg = Debug|Win32 {B01E1536-505B-4357-B5B6-083EFBF786B0}.Debug|x86.Build.0 = Debug|Win32 + {B01E1536-505B-4357-B5B6-083EFBF786B0}.Release_SDL1|x64.ActiveCfg = Release|x64 + {B01E1536-505B-4357-B5B6-083EFBF786B0}.Release_SDL1|x64.Build.0 = Release|x64 + {B01E1536-505B-4357-B5B6-083EFBF786B0}.Release_SDL1|x86.ActiveCfg = Release|Win32 + {B01E1536-505B-4357-B5B6-083EFBF786B0}.Release_SDL1|x86.Build.0 = Release|Win32 {B01E1536-505B-4357-B5B6-083EFBF786B0}.Release_SDL2|x64.ActiveCfg = Release|x64 {B01E1536-505B-4357-B5B6-083EFBF786B0}.Release_SDL2|x64.Build.0 = Release|x64 {B01E1536-505B-4357-B5B6-083EFBF786B0}.Release_SDL2|x86.ActiveCfg = Release|Win32 @@ -239,6 +340,22 @@ Global {B01E1536-505B-4357-B5B6-083EFBF786B0}.Release|x64.Build.0 = Release|x64 {B01E1536-505B-4357-B5B6-083EFBF786B0}.Release|x86.ActiveCfg = Release|Win32 {B01E1536-505B-4357-B5B6-083EFBF786B0}.Release|x86.Build.0 = Release|Win32 + {06CF6B2F-D39B-4EEB-A582-A4A264C7B682}.Debug_SDL1|x64.ActiveCfg = Debug_SDL1|x64 + {06CF6B2F-D39B-4EEB-A582-A4A264C7B682}.Debug_SDL1|x64.Build.0 = Debug_SDL1|x64 + {06CF6B2F-D39B-4EEB-A582-A4A264C7B682}.Debug_SDL1|x86.ActiveCfg = Debug_SDL1|Win32 + {06CF6B2F-D39B-4EEB-A582-A4A264C7B682}.Debug_SDL1|x86.Build.0 = Debug_SDL1|Win32 + {06CF6B2F-D39B-4EEB-A582-A4A264C7B682}.Debug_SDL2|x64.ActiveCfg = Debug_SDL1|x64 + {06CF6B2F-D39B-4EEB-A582-A4A264C7B682}.Debug_SDL2|x86.ActiveCfg = Debug_SDL1|Win32 + {06CF6B2F-D39B-4EEB-A582-A4A264C7B682}.Debug|x64.ActiveCfg = Debug_SDL1|x64 + {06CF6B2F-D39B-4EEB-A582-A4A264C7B682}.Debug|x86.ActiveCfg = Debug_SDL1|Win32 + {06CF6B2F-D39B-4EEB-A582-A4A264C7B682}.Release_SDL1|x64.ActiveCfg = Release_SDL1|x64 + {06CF6B2F-D39B-4EEB-A582-A4A264C7B682}.Release_SDL1|x64.Build.0 = Release_SDL1|x64 + {06CF6B2F-D39B-4EEB-A582-A4A264C7B682}.Release_SDL1|x86.ActiveCfg = Release_SDL1|Win32 + {06CF6B2F-D39B-4EEB-A582-A4A264C7B682}.Release_SDL1|x86.Build.0 = Release_SDL1|Win32 + {06CF6B2F-D39B-4EEB-A582-A4A264C7B682}.Release_SDL2|x64.ActiveCfg = Release_SDL1|x64 + {06CF6B2F-D39B-4EEB-A582-A4A264C7B682}.Release_SDL2|x86.ActiveCfg = Release_SDL1|Win32 + {06CF6B2F-D39B-4EEB-A582-A4A264C7B682}.Release|x64.ActiveCfg = Release_SDL1|x64 + {06CF6B2F-D39B-4EEB-A582-A4A264C7B682}.Release|x86.ActiveCfg = Release_SDL1|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/platforms/windows/projects/Client/Client.vcxproj b/platforms/windows/projects/Client/Client.vcxproj index 63a7a26f5..a6eb3f94f 100644 --- a/platforms/windows/projects/Client/Client.vcxproj +++ b/platforms/windows/projects/Client/Client.vcxproj @@ -1,6 +1,14 @@ - + + + Debug_SDL1 + Win32 + + + Debug_SDL1 + x64 + Debug_SDL2 Win32 @@ -13,6 +21,14 @@ Debug Win32 + + Release_SDL1 + Win32 + + + Release_SDL1 + x64 + Release_SDL2 Win32 @@ -313,9 +329,11 @@ {e43f7c6a-a099-48c9-9d37-b56cd8d6d785} + true {f332cb57-ff16-4d43-bbe0-76f28301daa8} + true diff --git a/platforms/windows/projects/Common/Common.vcxproj b/platforms/windows/projects/Common/Common.vcxproj index c28c88616..eef20b4ef 100644 --- a/platforms/windows/projects/Common/Common.vcxproj +++ b/platforms/windows/projects/Common/Common.vcxproj @@ -1,6 +1,14 @@  + + Debug_SDL1 + Win32 + + + Debug_SDL1 + x64 + Debug_SDL2 Win32 @@ -13,6 +21,14 @@ Debug Win32 + + Release_SDL1 + Win32 + + + Release_SDL1 + x64 + Release_SDL2 Win32 diff --git a/platforms/windows/projects/Directory.Build.props b/platforms/windows/projects/Directory.Build.props index 743e41149..c52e06603 100644 --- a/platforms/windows/projects/Directory.Build.props +++ b/platforms/windows/projects/Directory.Build.props @@ -56,10 +56,17 @@ true + + + + $(SDL1_PATH)\include;$(OPENAL_PATH)\include;%(AdditionalIncludeDirectories) + USE_SDL;USE_SDL1;USE_OPENAL;NOMINMAX;%(PreprocessorDefinitions) + + - $(SDL2_PATH)\include;$(LIBPNG_PATH);$(OPENAL_PATH)\include;%(AdditionalIncludeDirectories) + $(SDL2_PATH)\include;$(OPENAL_PATH)\include;%(AdditionalIncludeDirectories) USE_SDL;USE_OPENAL;NOMINMAX;%(PreprocessorDefinitions) diff --git a/platforms/windows/projects/MinecraftClient.SDL1/MinecraftClient.SDL1.vcxproj b/platforms/windows/projects/MinecraftClient.SDL1/MinecraftClient.SDL1.vcxproj new file mode 100644 index 000000000..889280bc6 --- /dev/null +++ b/platforms/windows/projects/MinecraftClient.SDL1/MinecraftClient.SDL1.vcxproj @@ -0,0 +1,105 @@ + + + + + Debug_SDL1 + Win32 + + + Debug_SDL1 + x64 + + + Release_SDL1 + Win32 + + + Release_SDL1 + x64 + + + + 17.0 + Win32Proj + {06cf6b2f-d39b-4eeb-a582-a4a264c7b682} + MinecraftClientSDL1 + Application + + + + + + + + + + + + + + $(MC_ROOT)\platforms\sound\openal;$(MC_ROOT)\thirdparty\stb_image\include;$(SDL1_PATH)\include;$(OPENAL_PATH)\include;%(AdditionalIncludeDirectories) + + + Console + SDLmain.lib;%(AdditionalDependencies) + + + + + $(SDL1_PATH)\VisualC\SDL\Win32\Release;$(SDL1_PATH)\VisualC\SDLmain\Win32\Release;$(OPENAL_PATH)\libs\Win32\;%(AdditionalLibraryDirectories) + + + copy $(SDL1_PATH)\VisualC\SDL\Win32\Release\SDL.dll $(TargetDir) /y + + + + + $(SDL1_PATH)\VisualC\SDL\x64\Release;$(SDL1_PATH)\VisualC\SDLmain\x64\Release;$(OPENAL_PATH)\libs\Win64\;%(AdditionalLibraryDirectories) + + + copy $(SDL1_PATH)\VisualC\SDL\x64\Release\SDL.dll $(TargetDir) /y + + + + + + + + + + + + + + + + + + + + + + + {a6e03dca-99f6-45b8-800d-73060ae407fc} + + + {71774270-fd1b-4269-bd8f-f75a52d43eb6} + + + {bd8b8369-d75d-4d12-a85f-c521349b9125} + + + {5f7cd8c1-413c-4855-a450-2c765f16c5a4} + + + {5da292fd-fa40-45d8-900a-6652c9662913} + + + + + + + $(MC_ROOT)\game + WindowsLocalDebugger + + \ No newline at end of file diff --git a/platforms/windows/projects/MinecraftClient.SDL1/MinecraftClient.SDL1.vcxproj.filters b/platforms/windows/projects/MinecraftClient.SDL1/MinecraftClient.SDL1.vcxproj.filters new file mode 100644 index 000000000..e47b53061 --- /dev/null +++ b/platforms/windows/projects/MinecraftClient.SDL1/MinecraftClient.SDL1.vcxproj.filters @@ -0,0 +1,66 @@ + + + + + {0B511B13-516D-4AFD-AFAD-8E4C4E898B69} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {0F735622-7CEE-4DB5-8EB4-916BD80E9A60} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {CBAD8E76-B68F-43FF-A4E2-0F5C772AE2FE} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {c0b80e15-0cee-4757-84e3-72ad7892b09c} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files\Compatibility + + + Header Files + + + Header Files\Compatibility + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/platforms/windows/projects/MinecraftClient.SDL2/MinecraftClient.SDL2.vcxproj b/platforms/windows/projects/MinecraftClient.SDL2/MinecraftClient.SDL2.vcxproj index 1be42c37d..0ac64178c 100644 --- a/platforms/windows/projects/MinecraftClient.SDL2/MinecraftClient.SDL2.vcxproj +++ b/platforms/windows/projects/MinecraftClient.SDL2/MinecraftClient.SDL2.vcxproj @@ -62,19 +62,21 @@ - - - + + + + - - + + + diff --git a/platforms/windows/projects/MinecraftClient.SDL2/MinecraftClient.SDL2.vcxproj.filters b/platforms/windows/projects/MinecraftClient.SDL2/MinecraftClient.SDL2.vcxproj.filters index f60c21af6..500d7002f 100644 --- a/platforms/windows/projects/MinecraftClient.SDL2/MinecraftClient.SDL2.vcxproj.filters +++ b/platforms/windows/projects/MinecraftClient.SDL2/MinecraftClient.SDL2.vcxproj.filters @@ -18,16 +18,16 @@ - + Source Files - + Source Files Source Files - + Source Files @@ -36,9 +36,12 @@ Source Files + + Source Files + - + Header Files @@ -50,11 +53,14 @@ Header Files\Compatibility - + Header Files Header Files + + Header Files + \ No newline at end of file diff --git a/platforms/windows/projects/Network/Network.vcxproj b/platforms/windows/projects/Network/Network.vcxproj index 6b8f22a50..a97aa52f3 100644 --- a/platforms/windows/projects/Network/Network.vcxproj +++ b/platforms/windows/projects/Network/Network.vcxproj @@ -75,6 +75,7 @@ {4b7fcc5f-7e38-4934-b272-2f5bbef51013} + true {5f7cd8c1-413c-4855-a450-2c765f16c5a4} diff --git a/platforms/windows/projects/OpenGL/OpenGL.vcxproj b/platforms/windows/projects/OpenGL/OpenGL.vcxproj index ca3fc3233..465ee1047 100644 --- a/platforms/windows/projects/OpenGL/OpenGL.vcxproj +++ b/platforms/windows/projects/OpenGL/OpenGL.vcxproj @@ -1,6 +1,14 @@ + + Debug_SDL1 + Win32 + + + Debug_SDL1 + x64 + Debug_SDL2 Win32 @@ -13,6 +21,14 @@ Debug Win32 + + Release_SDL1 + Win32 + + + Release_SDL1 + x64 + Release_SDL2 Win32 diff --git a/platforms/windows/projects/Renderer/Renderer.vcxproj b/platforms/windows/projects/Renderer/Renderer.vcxproj index fc7bef30b..2165c38d1 100644 --- a/platforms/windows/projects/Renderer/Renderer.vcxproj +++ b/platforms/windows/projects/Renderer/Renderer.vcxproj @@ -1,4 +1,4 @@ - + @@ -27,6 +27,7 @@ {2e1a5b55-a6d4-4743-a63a-4f27db03c0a1} + true diff --git a/platforms/windows/projects/SDL/SDL.vcxproj b/platforms/windows/projects/SDL/SDL.vcxproj new file mode 100644 index 000000000..a8afb90bd --- /dev/null +++ b/platforms/windows/projects/SDL/SDL.vcxproj @@ -0,0 +1,102 @@ + + + + + Debug_SDL1 + Win32 + + + Debug_SDL1 + x64 + + + Debug_SDL2 + Win32 + + + Debug_SDL2 + x64 + + + Release_SDL1 + Win32 + + + Release_SDL1 + x64 + + + Release_SDL2 + Win32 + + + Release_SDL2 + x64 + + + + + + + + + 17.0 + Win32Proj + {a88f87b0-d37b-4385-a870-f349d8001e08} + SDL + StaticLibrary + + + + + + + + + + + + + + $(SDL1_PATH)\include;%(AdditionalIncludeDirectories) + + + + + $(SDL2_PATH)\include;%(AdditionalIncludeDirectories) + + + + + SDL.lib + + + + + SDL2.lib + + + + + $(SDL1_PATH)\VisualC\SDL\Win32\Release;%(AdditionalLibraryDirectories) + + + + + $(SDL2_PATH)\VisualC\Win32\Release;%(AdditionalLibraryDirectories) + + + + + $(SDL1_PATH)\VisualC\SDL\x64\Release;%(AdditionalLibraryDirectories) + + + + + $(SDL2_PATH)\VisualC\x64\Release;%(AdditionalLibraryDirectories) + + + + + + \ No newline at end of file diff --git a/platforms/windows/projects/SDL2/SDL2.vcxproj.filters b/platforms/windows/projects/SDL/SDL.vcxproj.filters similarity index 70% rename from platforms/windows/projects/SDL2/SDL2.vcxproj.filters rename to platforms/windows/projects/SDL/SDL.vcxproj.filters index d958a9e68..60b81081a 100644 --- a/platforms/windows/projects/SDL2/SDL2.vcxproj.filters +++ b/platforms/windows/projects/SDL/SDL.vcxproj.filters @@ -1,4 +1,4 @@ - + @@ -11,10 +11,13 @@ - + Header Files - + + Header Files + + Header Files diff --git a/platforms/windows/projects/SDL2/SDL2.vcxproj b/platforms/windows/projects/SDL2/SDL2.vcxproj deleted file mode 100644 index 085c5385c..000000000 --- a/platforms/windows/projects/SDL2/SDL2.vcxproj +++ /dev/null @@ -1,65 +0,0 @@ - - - - - Debug_SDL2 - Win32 - - - Debug_SDL2 - x64 - - - Release_SDL2 - Win32 - - - Release_SDL2 - x64 - - - - - - - - 17.0 - Win32Proj - {a88f87b0-d37b-4385-a870-f349d8001e08} - SDL2 - StaticLibrary - - - - - - - - - - - - - - $(SDL2_PATH)\include;%(AdditionalIncludeDirectories) - - - - - SDL2.lib - - - - - $(SDL2_PATH)\VisualC\Win32\Release;%(AdditionalLibraryDirectories) - - - - - $(SDL2_PATH)\VisualC\x64\Release;%(AdditionalLibraryDirectories) - - - - - - \ No newline at end of file diff --git a/platforms/windows/projects/World/World.vcxproj b/platforms/windows/projects/World/World.vcxproj index 80323413b..b9c3a4287 100644 --- a/platforms/windows/projects/World/World.vcxproj +++ b/platforms/windows/projects/World/World.vcxproj @@ -1,4 +1,4 @@ - + @@ -335,6 +335,7 @@ {b01e1536-505b-4357-b5b6-083efbf786b0} + true diff --git a/source/client/app/AppPlatform.cpp b/source/client/app/AppPlatform.cpp index b102a6b73..b91cdbb3c 100644 --- a/source/client/app/AppPlatform.cpp +++ b/source/client/app/AppPlatform.cpp @@ -204,6 +204,11 @@ void AppPlatform::vibrate(int milliSeconds) { } +bool AppPlatform::getRecenterMouseEveryTick() +{ + return true; +} + void AppPlatform::_fireLowMemory() { @@ -241,12 +246,28 @@ bool AppPlatform::hasFileSystemAccess() std::string AppPlatform::getPatchData() { - const AssetFile file = readAssetFile("patches/patch_data.txt", false); + AssetFile file = readAssetFile(_getPatchDataPath(), false); + if (!file.data) + return ""; + std::string out = std::string(file.data, file.data + file.size); delete file.data; return out; } +std::string AppPlatform::getAssetPath(const std::string& path) const +{ + std::string realPath = path; + if (realPath.size() && realPath[0] == '/') + { + // trim it off + realPath = realPath.substr(1); + } + realPath = "assets/" + realPath; + + return realPath; +} + AssetFile AppPlatform::readAssetFile(const std::string& path, bool quiet) const { std::string realPath = getAssetPath(path); @@ -292,16 +313,3 @@ SoundSystem* const AppPlatform::getSoundSystem() const } #endif - -std::string AppPlatform::getAssetPath(const std::string &path) const -{ - std::string realPath = path; - if (realPath.size() && realPath[0] == '/') - { - // trim it off - realPath = realPath.substr(1); - } - realPath = "assets/" + realPath; - - return realPath; -} diff --git a/source/client/app/AppPlatform.hpp b/source/client/app/AppPlatform.hpp index 0a03bfea2..a7f1be254 100644 --- a/source/client/app/AppPlatform.hpp +++ b/source/client/app/AppPlatform.hpp @@ -31,10 +31,17 @@ class AppPlatform public: static AppPlatform* const singleton(); +public: AppPlatform(); - virtual ~AppPlatform(); +private: + virtual void _tick(); + +protected: + virtual std::string _getPatchDataPath() const { return "patches/patch_data.txt"; } + +public: virtual void buyGame(); virtual int checkLicense(); virtual void createUserInput(); @@ -74,6 +81,7 @@ class AppPlatform virtual int getKeyboardUpOffset(); #endif virtual void vibrate(int milliSeconds); + virtual bool getRecenterMouseEveryTick(); void _fireLowMemory(); void _fireAppSuspended(); @@ -88,13 +96,8 @@ class AppPlatform virtual void initSoundSystem(); virtual SoundSystem* const getSoundSystem() const; // Used For Sounds + virtual std::string getAssetPath(const std::string& path) const; virtual AssetFile readAssetFile(const std::string&, bool) const; #endif - -public: - virtual std::string getAssetPath(const std::string& path) const; - -private: - virtual void _tick(); }; diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp index 71a9d3c78..202c4e903 100644 --- a/source/client/app/Minecraft.cpp +++ b/source/client/app/Minecraft.cpp @@ -224,6 +224,7 @@ void Minecraft::setScreen(Screen* pScreen) } else { + platform()->recenterMouse(); grabMouse(); } } @@ -231,6 +232,7 @@ void Minecraft::setScreen(Screen* pScreen) void Minecraft::onGraphicsReset() { m_pTextures->clear(); + _initTextures(); m_pFont->onGraphicsReset(); if (m_pLevelRenderer) @@ -462,7 +464,12 @@ void Minecraft::tickInput() continue; if (Mouse::isButtonDown(BUTTON_LEFT)) - m_gui.handleClick(1, Mouse::getX(), Mouse::getY()); + { + // @HACK: on SDL1, we don't recenter the mouse every tick, meaning the user can + // unintentionally click the hotbar while swinging their fist + if (!platform()->getRecenterMouseEveryTick() && m_pScreen) + m_gui.handleClick(1, Mouse::getX(), Mouse::getY()); + } MouseButtonType buttonType = Mouse::getEventButton(); bool bPressed = Mouse::getEventButtonState() == true; @@ -577,7 +584,8 @@ void Minecraft::tickMouse() if (useController() || isTouchscreen()) return; // don't actually try to recenter the mouse - platform()->recenterMouse(); + if (platform()->getRecenterMouseEveryTick()) // just for SDL1 + platform()->recenterMouse(); } void Minecraft::handleCharInput(char chr) @@ -701,6 +709,16 @@ void Minecraft::_levelGenerated() m_pNetEventCallback->levelGenerated(m_pLevel); } +void Minecraft::_initTextures() +{ + m_pTextures->loadAndBindTexture(C_TERRAIN_NAME); + GetPatchManager()->PatchTextures(platform(), TYPE_TERRAIN); + m_pTextures->loadAndBindTexture(C_ITEMS_NAME); + GetPatchManager()->PatchTextures(platform(), TYPE_ITEMS); + + GetPatchManager()->PatchTiles(); +} + void Minecraft::tick() { if (!m_pScreen) @@ -846,13 +864,7 @@ void Minecraft::init() m_options->loadControls(); _reloadInput(); - - m_pTextures->loadAndBindTexture(C_TERRAIN_NAME); - GetPatchManager()->PatchTextures(platform(), TYPE_TERRAIN); - m_pTextures->loadAndBindTexture(C_ITEMS_NAME); - GetPatchManager()->PatchTextures(platform(), TYPE_ITEMS); - - GetPatchManager()->PatchTiles(); + _initTextures(); m_pSoundEngine = new SoundEngine(platform()->getSoundSystem(), 20.0f); // 20.0f on 0.7.0 m_pSoundEngine->init(m_options, platform()); diff --git a/source/client/app/Minecraft.hpp b/source/client/app/Minecraft.hpp index 7857d752c..daf115fa0 100644 --- a/source/client/app/Minecraft.hpp +++ b/source/client/app/Minecraft.hpp @@ -47,7 +47,7 @@ class Minecraft : public App void handleBuildAction(const BuildActionIntention& action); bool isLevelGenerated() const; void selectLevel(const LevelSummary& ls, bool forceConversion = false); - void selectLevel(const std::string&, const std::string&, int, bool forceConversion = false); + void selectLevel(const std::string& levelDir, const std::string& levelName, int32_t seed = 0, bool forceConversion = false); void setLevel(Level*, const std::string&, LocalPlayer*); bool pauseGame(); bool resumeGame(); @@ -91,6 +91,7 @@ class Minecraft : public App private: void _reloadInput(); void _levelGenerated(); + void _initTextures(); GameMode* createGameMode(GameType gameType, Level& level); private: diff --git a/source/client/gui/components/TextInputBox.cpp b/source/client/gui/components/TextInputBox.cpp index 0237a0ffa..fefe25815 100644 --- a/source/client/gui/components/TextInputBox.cpp +++ b/source/client/gui/components/TextInputBox.cpp @@ -50,34 +50,33 @@ void TextInputBox::setEnabled(bool bEnabled) } #ifdef USE_SDL -// See https://www.libsdl.org/release/SDL-1.2.15/docs/html/sdlkey.html -#define AKEYCODE_FORWARD_DEL SDLVK_DELETE -#define AKEYCODE_ARROW_LEFT SDLVK_LEFT -#define AKEYCODE_ARROW_RIGHT SDLVK_RIGHT -#define AKEYCODE_DEL SDLVK_BACKSPACE -#define AKEYCODE_ENTER SDLVK_RETURN -#define AKEYCODE_A SDLVK_a -#define AKEYCODE_Z SDLVK_z -#define AKEYCODE_0 SDLVK_0 -#define AKEYCODE_9 SDLVK_9 -#define AKEYCODE_SPACE SDLVK_SPACE -#define AKEYCODE_COMMA SDLVK_COMMA -#define AKEYCODE_PERIOD SDLVK_PERIOD -#define AKEYCODE_PLUS SDLVK_PLUS -#define AKEYCODE_MINUS SDLVK_MINUS -#define AKEYCODE_SEMICOLON SDLVK_SEMICOLON -#define AKEYCODE_SLASH SDLVK_SLASH -#define AKEYCODE_GRAVE SDLVK_BACKQUOTE -#define AKEYCODE_BACKSLASH SDLVK_BACKSLASH -#define AKEYCODE_APOSTROPHE SDLVK_QUOTE -#define AKEYCODE_LEFT_BRACKET SDLVK_LEFTBRACKET -#define AKEYCODE_RIGHT_BRACKET SDLVK_RIGHTBRACKET +#define AKEYCODE_FORWARD_DEL SDLK_DELETE +#define AKEYCODE_ARROW_LEFT SDLK_LEFT +#define AKEYCODE_ARROW_RIGHT SDLK_RIGHT +#define AKEYCODE_DEL SDLK_BACKSPACE +#define AKEYCODE_ENTER SDLK_RETURN +#define AKEYCODE_A SDLK_a +#define AKEYCODE_Z SDLK_z +#define AKEYCODE_0 SDLK_0 +#define AKEYCODE_9 SDLK_9 +#define AKEYCODE_SPACE SDLK_SPACE +#define AKEYCODE_COMMA SDLK_COMMA +#define AKEYCODE_PERIOD SDLK_PERIOD +#define AKEYCODE_PLUS SDLK_PLUS +#define AKEYCODE_MINUS SDLK_MINUS +#define AKEYCODE_SEMICOLON SDLK_SEMICOLON +#define AKEYCODE_SLASH SDLK_SLASH +#define AKEYCODE_GRAVE SDLK_BACKQUOTE +#define AKEYCODE_BACKSLASH SDLK_BACKSLASH +#define AKEYCODE_APOSTROPHE SDLK_QUOTE +#define AKEYCODE_LEFT_BRACKET SDLK_LEFTBRACKET +#define AKEYCODE_RIGHT_BRACKET SDLK_RIGHTBRACKET #elif defined(_WIN32) // See https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes #define AKEYCODE_FORWARD_DEL VK_DELETE #define AKEYCODE_ARROW_LEFT VK_LEFT #define AKEYCODE_ARROW_RIGHT VK_RIGHT -#define AKEYCODE_DEL VK_BACK +#define AKEYCODE_DEL VK_BACK #define AKEYCODE_ENTER VK_RETURN #define AKEYCODE_A 'A' #define AKEYCODE_Z 'Z' @@ -281,7 +280,8 @@ void TextInputBox::charPressed(int k) return; switch (k) { - case '\b': + case '\b': // BACKSPACE + case '\x7f': // DELETE { // Backspace if (m_text.empty()) @@ -301,6 +301,8 @@ void TextInputBox::charPressed(int k) recalculateScroll(); break; } + /* There's not much of a point in handling deletes differently, + * especially since old Mac OS versions send delete instead of backspace. case '\x7f': // DELETE { // Delete @@ -318,7 +320,7 @@ void TextInputBox::charPressed(int k) } m_text.erase(m_text.begin() + m_insertHead, m_text.begin() + m_insertHead + 1); break; - } + }*/ default: { // Ignore Unprintable Characters diff --git a/source/client/model/Model.cpp b/source/client/model/Model.cpp index 7816804c9..6c1df5550 100644 --- a/source/client/model/Model.cpp +++ b/source/client/model/Model.cpp @@ -19,7 +19,10 @@ Model::Model(int width, int height) void Model::onGraphicsReset() { - + for (size_t i = 0; i < m_parts.size(); i++) + { + m_parts[i]->m_bCompiled = false; + } } void Model::prepareMobModel(Mob*, float, float, float) diff --git a/source/client/options/Options.cpp b/source/client/options/Options.cpp index e863d74ef..d80a5deea 100644 --- a/source/client/options/Options.cpp +++ b/source/client/options/Options.cpp @@ -8,6 +8,9 @@ #include +// for SDL 1.2 controller buttons +#include "thirdparty/SDL/SDL_gamecontroller.h" + #include "Options.hpp" #include "common/Util.hpp" #include "compat/KeyCodes.hpp" diff --git a/source/client/player/input/BuildActionIntention.hpp b/source/client/player/input/BuildActionIntention.hpp index 68193f2fe..c9da585fe 100644 --- a/source/client/player/input/BuildActionIntention.hpp +++ b/source/client/player/input/BuildActionIntention.hpp @@ -8,6 +8,8 @@ #pragma once +#include "compat/LegacyCPP.hpp" + class BuildActionIntention { public: diff --git a/source/client/renderer/FoliageColor.cpp b/source/client/renderer/FoliageColor.cpp index 68671ebae..ec2570e49 100644 --- a/source/client/renderer/FoliageColor.cpp +++ b/source/client/renderer/FoliageColor.cpp @@ -1,4 +1,5 @@ #include "FoliageColor.hpp" +#include "compat/EndianDefinitions.h" bool FoliageColor::_isAvailable = false; @@ -12,7 +13,15 @@ void FoliageColor::init(Texture texture) uint32_t FoliageColor::get(double x, double y) { y *= x; - return FoliageColor::texture.m_pixels[(int)((1.0 - y) * 255.0) << 8 | (int)((1.0 - x) * 255.0)]; + uint32_t c = FoliageColor::texture.m_pixels[(int)((1.0 - y) * 255.0) << 8 | (int)((1.0 - x) * 255.0)]; + + // @TODO: same as in GrassColor::get, should be abstracted +#if MC_ENDIANNESS_BIG + uint8_t r = c & 0xFF, g = (c >> 8) & 0xFF, b = (c >> 16) & 0xFF, a = (c >> 24) & 0xFF; + c = a | (b << 8) | (g << 16) | (r << 24); +#endif + + return c; } uint32_t FoliageColor::getEvergreenColor() diff --git a/source/client/renderer/GrassColor.cpp b/source/client/renderer/GrassColor.cpp index b8906fd99..9e934b05e 100644 --- a/source/client/renderer/GrassColor.cpp +++ b/source/client/renderer/GrassColor.cpp @@ -1,4 +1,5 @@ #include "GrassColor.hpp" +#include "compat/EndianDefinitions.h" bool GrassColor::_isAvailable = false; @@ -12,5 +13,12 @@ void GrassColor::init(Texture texture) uint32_t GrassColor::get(double x, double y) { y *= x; - return GrassColor::texture.m_pixels[(int)((1.0 - y) * 255.0) << 8 | (int)((1.0 - x) * 255.0)]; + uint32_t c = GrassColor::texture.m_pixels[(int)((1.0 - y) * 255.0) << 8 | (int)((1.0 - x) * 255.0)]; + +#if MC_ENDIANNESS_BIG + uint8_t r = c & 0xFF, g = (c >> 8) & 0xFF, b = (c >> 16) & 0xFF, a = (c >> 24) & 0xFF; + c = a | (b << 8) | (g << 16) | (r << 24); +#endif + + return c; } \ No newline at end of file diff --git a/source/client/renderer/Tesselator.cpp b/source/client/renderer/Tesselator.cpp index 1a07bc957..0dca97340 100644 --- a/source/client/renderer/Tesselator.cpp +++ b/source/client/renderer/Tesselator.cpp @@ -9,6 +9,7 @@ #include "Tesselator.hpp" #include "thirdparty/GL/GL.hpp" #include "common/Utils.hpp" +#include "compat/EndianDefinitions.h" #include @@ -109,7 +110,11 @@ void Tesselator::color(int r, int g, int b, int a) if (a < 0) a = 0; m_bHasColor = true; - m_nextVtxColor = a << 24 | b << 16 | g << 8 | r; +#if MC_ENDIANNESS_BIG + m_nextVtxColor = a | (b << 8) | (g << 16) | (r << 24); +#else // MC_ENDIANNESS_LITTLE + m_nextVtxColor = (a << 24) | (b << 16) | (g << 8) | r; +#endif } void Tesselator::color(int r, int g, int b) @@ -287,8 +292,12 @@ void Tesselator::normal(float x, float y, float z) int8_t bx = static_cast(x * 128); int8_t by = static_cast(y * 127); int8_t bz = static_cast(z * 127); +#if MC_ENDIANNESS_BIG + m_nextVtxNormal = (bx << 24) | (by << 16) | (bz << 8); +#else // MC_ENDIANNESS_LITTLE m_nextVtxNormal = (bx << 0) | (by << 8) | (bz << 16); #endif +#endif } void Tesselator::offset(float x, float y, float z) diff --git a/source/client/renderer/entity/EntityRenderDispatcher.cpp b/source/client/renderer/entity/EntityRenderDispatcher.cpp index 2dd519652..4487547c8 100644 --- a/source/client/renderer/entity/EntityRenderDispatcher.cpp +++ b/source/client/renderer/entity/EntityRenderDispatcher.cpp @@ -43,6 +43,7 @@ EntityRenderDispatcher::EntityRenderDispatcher() : m_pOptions = nullptr; m_pFont = nullptr; + // @TODO: Put these in an array or something m_HumanoidMobRenderer.init(this); m_PigRenderer.init(this); m_SheepRenderer.init(this); @@ -137,6 +138,23 @@ EntityRenderer* EntityRenderDispatcher::getRenderer(Entity* pEnt) void EntityRenderDispatcher::onGraphicsReset() { m_HumanoidMobRenderer.onGraphicsReset(); + m_PigRenderer.onGraphicsReset(); + m_SheepRenderer.onGraphicsReset(); + m_SpiderRenderer.onGraphicsReset(); + m_SkeletonRenderer.onGraphicsReset(); + m_CowRenderer.onGraphicsReset(); + m_ChickenRenderer.onGraphicsReset(); + m_CreeperRenderer.onGraphicsReset(); + m_ZombieRenderer.onGraphicsReset(); + m_ArrowRenderer.onGraphicsReset(); + + m_TntRenderer.onGraphicsReset(); + m_CameraRenderer.onGraphicsReset(); + m_ItemRenderer.onGraphicsReset(); + m_RocketRenderer.onGraphicsReset(); +#ifdef ENH_ALLOW_SAND_GRAVITY + m_FallingTileRenderer.onGraphicsReset(); +#endif } void EntityRenderDispatcher::prepare(Level* level, Textures* textures, Font* font, Mob* mob, Options* options, float f) diff --git a/source/client/renderer/entity/MobRenderer.cpp b/source/client/renderer/entity/MobRenderer.cpp index 94a92f538..0d19a1e48 100644 --- a/source/client/renderer/entity/MobRenderer.cpp +++ b/source/client/renderer/entity/MobRenderer.cpp @@ -199,6 +199,11 @@ void MobRenderer::render(Entity* entity, const Vec3& pos, float unused, float f) renderName(pMob, pos); } +void MobRenderer::onGraphicsReset() +{ + m_pModel->onGraphicsReset(); +} + void MobRenderer::renderName(Mob* mob, const Vec3& pos) { if (mob->isPlayer()) diff --git a/source/client/renderer/entity/MobRenderer.hpp b/source/client/renderer/entity/MobRenderer.hpp index 10f7774bd..115ad81ec 100644 --- a/source/client/renderer/entity/MobRenderer.hpp +++ b/source/client/renderer/entity/MobRenderer.hpp @@ -18,6 +18,7 @@ class MobRenderer : public EntityRenderer void setArmor(Model*); virtual void render(Entity*, const Vec3& pos, float, float) override; + virtual void onGraphicsReset() override; virtual int prepareArmor(Mob*, int, float); virtual void setupPosition(Entity*, const Vec3& pos); virtual void setupRotations(Entity*, float bob, float bodyRot, float a); diff --git a/source/common/Utils.hpp b/source/common/Utils.hpp index 67f940954..5b399ecfc 100644 --- a/source/common/Utils.hpp +++ b/source/common/Utils.hpp @@ -112,6 +112,9 @@ void closedir(DIR* dir); #ifndef MOD_USE_BIGGER_SCREEN_SIZE #define C_DEFAULT_SCREEN_WIDTH (854) #define C_DEFAULT_SCREEN_HEIGHT (480) +#elif defined(__DREAMCAST__) +#define C_DEFAULT_SCREEN_WIDTH (800) +#define C_DEFAULT_SCREEN_HEIGHT (600) #else #define C_DEFAULT_SCREEN_WIDTH (1280) #define C_DEFAULT_SCREEN_HEIGHT (720) diff --git a/source/world/entity/Player.cpp b/source/world/entity/Player.cpp index f8453d04a..594f5b197 100644 --- a/source/world/entity/Player.cpp +++ b/source/world/entity/Player.cpp @@ -197,6 +197,7 @@ ItemInstance* Player::getCarriedItem() { // This only gets the first row slot /*ItemInstance* item = m_pInventory->getItem(m_pInventory->m_selectedHotbarSlot); + if (ItemInstance::isNull(item)) return nullptr; @@ -268,8 +269,11 @@ void Player::readAdditionalSaveData(const CompoundTag& tag) m_dimension = tag.getInt32("Dimension"); //m_sleepTimer = tag.getInt32("SleepTimer"); - if (tag.contains("SpawnX") && tag.contains("SpawnY") && tag.contains("SpawnZ")) - setRespawnPos(TilePos(tag.getInt32("SpawnX"), tag.getInt32("SpawnY"), tag.getInt32("SpawnZ"))); + if (tag.contains("SpawnX") && tag.contains("SpawnY") && tag.contains("SpawnZ")) { + setRespawnPos(TilePos( static_cast(tag.getInt32("SpawnX")), + static_cast(tag.getInt32("SpawnY")), + static_cast(tag.getInt32("SpawnZ")))); + } } void Player::animateRespawn() diff --git a/source/world/item/Inventory.cpp b/source/world/item/Inventory.cpp index e152e4cad..81137fe21 100644 --- a/source/world/item/Inventory.cpp +++ b/source/world/item/Inventory.cpp @@ -280,12 +280,8 @@ ItemInstance* Inventory::getItem(int slotNo) int Inventory::getQuickSlotItemId(int slotNo) { - if (slotNo < 0 || slotNo >= C_MAX_HOTBAR_ITEMS) - return -1; - - int idx = m_hotbar[slotNo]; - ItemInstance* pInst = getItem(idx); - if (ItemInstance::isNull(pInst)) + ItemInstance* pInst = getQuickSlotItem(slotNo); + if (!pInst) return -1; return pInst->m_itemID; diff --git a/thirdparty/GL/GL.hpp b/thirdparty/GL/GL.hpp index 422ca171d..3c11eabc6 100644 --- a/thirdparty/GL/GL.hpp +++ b/thirdparty/GL/GL.hpp @@ -48,9 +48,9 @@ #define USE_OPENGL_2_FEATURES #define GL_GLEXT_PROTOTYPES - #include "thirdparty/SDL2/SDL_opengl.h" + #include "thirdparty/SDL/SDL_opengl.h" - #ifndef _WIN32 + #if !defined(_WIN32) && SDL_MAJOR_VERSION == 2 #include #endif #else @@ -74,13 +74,13 @@ #if defined(USE_GLES) || defined(USE_SDL) // https://cgit.freedesktop.org/mesa/glu/tree/src/libutil/project.c - static inline void __gluMakeIdentityf(GLfloat m[16]) { + inline void __gluMakeIdentityf(GLfloat m[16]) { m[0 + 4 * 0] = 1; m[0 + 4 * 1] = 0; m[0 + 4 * 2] = 0; m[0 + 4 * 3] = 0; m[1 + 4 * 0] = 0; m[1 + 4 * 1] = 1; m[1 + 4 * 2] = 0; m[1 + 4 * 3] = 0; m[2 + 4 * 0] = 0; m[2 + 4 * 1] = 0; m[2 + 4 * 2] = 1; m[2 + 4 * 3] = 0; m[3 + 4 * 0] = 0; m[3 + 4 * 1] = 0; m[3 + 4 * 2] = 0; m[3 + 4 * 3] = 1; } - static inline void gluPerspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar) { + inline void gluPerspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar) { GLfloat m[4][4]; float sine, cotangent, deltaZ; float radians = fovy / 2.0f * float(M_PI) / 180.0f; @@ -108,7 +108,7 @@ void xglInit(); bool xglInitted(); #endif -#if defined(USE_OPENGL_2_FEATURES) && !defined(_WIN32) +#if defined(USE_OPENGL_2_FEATURES) && !defined(_WIN32) && !defined(__DREAMCAST__) #define xglBindBuffer glBindBuffer #define xglBufferData glBufferData diff --git a/thirdparty/GL/GLExt.cpp b/thirdparty/GL/GLExt.cpp index 590d06846..ad3e6477f 100644 --- a/thirdparty/GL/GLExt.cpp +++ b/thirdparty/GL/GLExt.cpp @@ -6,7 +6,13 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ -#ifdef _WIN32 +#if defined(_WIN32) || defined(__DREAMCAST__) + +#ifdef __DREAMCAST__ + +#define USE_GL_VBO_EMULATION + +#endif #include "GL.hpp" #include diff --git a/thirdparty/SDL/SDL.h b/thirdparty/SDL/SDL.h new file mode 100644 index 000000000..4efb51aeb --- /dev/null +++ b/thirdparty/SDL/SDL.h @@ -0,0 +1,19 @@ +#pragma once + +#if (defined(_WIN32) || defined(USE_SDL1)) + +#ifdef _WIN32 +#ifdef USE_SDL1 +#pragma comment(lib, "SDL.lib") +#else +#pragma comment(lib, "SDL2.lib") +#endif +#include +#include +#else +#include +#endif + +#else +#include +#endif \ No newline at end of file diff --git a/thirdparty/SDL/SDL_gamecontroller.h b/thirdparty/SDL/SDL_gamecontroller.h new file mode 100644 index 000000000..5b474a374 --- /dev/null +++ b/thirdparty/SDL/SDL_gamecontroller.h @@ -0,0 +1,71 @@ +#pragma once + +#ifdef USE_SDL1 + +#include "SDL.h" + +// Controller values ripped from SDL2, modified for SDL 1.2, since SDL 1.2 has jack-shit + +/** + * The list of buttons available from a controller. + */ +typedef enum +{ + SDL_CONTROLLER_BUTTON_INVALID = -1, + SDL_CONTROLLER_BUTTON_A, + SDL_CONTROLLER_BUTTON_B, + SDL_CONTROLLER_BUTTON_X, + SDL_CONTROLLER_BUTTON_Y, + SDL_CONTROLLER_BUTTON_LEFTSHOULDER, + SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, + SDL_CONTROLLER_BUTTON_BACK, + SDL_CONTROLLER_BUTTON_START, + SDL_CONTROLLER_BUTTON_LEFTSTICK, + SDL_CONTROLLER_BUTTON_RIGHTSTICK, + SDL_CONTROLLER_BUTTON_DPAD_UP, + SDL_CONTROLLER_BUTTON_DPAD_DOWN, + SDL_CONTROLLER_BUTTON_DPAD_LEFT, + SDL_CONTROLLER_BUTTON_DPAD_RIGHT, + SDL_CONTROLLER_BUTTON_GUIDE, + SDL_CONTROLLER_BUTTON_MISC1, /* Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button */ + SDL_CONTROLLER_BUTTON_PADDLE1, /* Xbox Elite paddle P1 (upper left, facing the back) */ + SDL_CONTROLLER_BUTTON_PADDLE2, /* Xbox Elite paddle P3 (upper right, facing the back) */ + SDL_CONTROLLER_BUTTON_PADDLE3, /* Xbox Elite paddle P2 (lower left, facing the back) */ + SDL_CONTROLLER_BUTTON_PADDLE4, /* Xbox Elite paddle P4 (lower right, facing the back) */ + SDL_CONTROLLER_BUTTON_TOUCHPAD, /* PS4/PS5 touchpad button */ + SDL_CONTROLLER_BUTTON_MAX +} SDL_GameControllerButton; + +/** + * The list of axes available from a controller + * + * Thumbstick axis values range from SDL_JOYSTICK_AXIS_MIN to SDL_JOYSTICK_AXIS_MAX, + * and are centered within ~8000 of zero, though advanced UI will allow users to set + * or autodetect the dead zone, which varies between controllers. + * + * Trigger axis values range from 0 (released) to SDL_JOYSTICK_AXIS_MAX + * (fully pressed) when reported by SDL_GameControllerGetAxis(). Note that this is not the + * same range that will be reported by the lower-level SDL_GetJoystickAxis(). + */ +typedef enum +{ + SDL_CONTROLLER_AXIS_INVALID = -1, + SDL_CONTROLLER_AXIS_LEFTX, + SDL_CONTROLLER_AXIS_LEFTY, + SDL_CONTROLLER_AXIS_TRIGGERLEFT, + SDL_CONTROLLER_AXIS_RIGHTY, + SDL_CONTROLLER_AXIS_RIGHTX, + SDL_CONTROLLER_AXIS_TRIGGERRIGHT, + SDL_CONTROLLER_AXIS_MAX +} SDL_GameControllerAxis; + +/** + * This is a unique ID for a joystick for the time it is connected to the system, + * and is never reused for the lifetime of the application. If the joystick is + * disconnected and reconnected, it will get a new ID. + * + * The ID value starts at 0 and increments from there. The value -1 is an invalid ID. + */ +typedef Sint8 SDL_JoystickID; // int8 on SDL1, int32 on SDL2 + +#endif diff --git a/thirdparty/SDL/SDL_opengl.h b/thirdparty/SDL/SDL_opengl.h new file mode 100644 index 000000000..c3b4afcc0 --- /dev/null +++ b/thirdparty/SDL/SDL_opengl.h @@ -0,0 +1,18 @@ +#pragma once + +#if (defined(_WIN32) || defined(USE_SDL1)) + +#ifdef _WIN32 +#ifdef USE_SDL1 +#pragma comment(lib, "SDL.lib") +#else +#pragma comment(lib, "SDL2.lib") +#endif +#include +#else +#include +#endif + +#else +#include +#endif \ No newline at end of file diff --git a/thirdparty/SDL2/SDL2.h b/thirdparty/SDL2/SDL2.h deleted file mode 100644 index 3d2518b96..000000000 --- a/thirdparty/SDL2/SDL2.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#ifdef _WIN32 -#pragma comment(lib, "SDL2.lib") -#include -#include -#else -#include -#endif \ No newline at end of file diff --git a/thirdparty/SDL2/SDL_opengl.h b/thirdparty/SDL2/SDL_opengl.h deleted file mode 100644 index 70da5b7ae..000000000 --- a/thirdparty/SDL2/SDL_opengl.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#ifdef _WIN32 -#pragma comment(lib, "SDL2.lib") -#include -#else -#include -#endif \ No newline at end of file diff --git a/thirdparty/raknet/Getche.cpp b/thirdparty/raknet/Getche.cpp index 5add5668e..07ae9ccf3 100644 --- a/thirdparty/raknet/Getche.cpp +++ b/thirdparty/raknet/Getche.cpp @@ -18,8 +18,7 @@ char getche() { - - +#ifdef ICANON struct termios oldt, newt; char ch; @@ -30,6 +29,8 @@ char getche() ch = getchar(); tcsetattr( STDIN_FILENO, TCSANOW, &oldt ); return ch; - +#else + return 1; +#endif } #endif diff --git a/thirdparty/raknet/Getche.h b/thirdparty/raknet/Getche.h index d0048d3ec..de63d60f7 100644 --- a/thirdparty/raknet/Getche.h +++ b/thirdparty/raknet/Getche.h @@ -8,12 +8,16 @@ * */ -#if defined(_WIN32) +#if (defined(_WIN32)) #include /* getche() */ #else +#if (!defined(__DREAMCAST__)) #include #include #include +#else +#define NO_ONLINE +#endif char getche(); #endif diff --git a/thirdparty/raknet/RakNetSocket2.cpp b/thirdparty/raknet/RakNetSocket2.cpp index f477562ff..c962158a8 100644 --- a/thirdparty/raknet/RakNetSocket2.cpp +++ b/thirdparty/raknet/RakNetSocket2.cpp @@ -25,11 +25,15 @@ using namespace RakNet; #include #include #include // error numbers -#if !defined(ANDROID) +#if (!defined(ANDROID) && !defined(__DREAMCAST__)) #include #endif #include +#if !defined(__DREAMCAST__) #include +#else +#define IP_HDRINCL 3 +#endif #include #include #include diff --git a/thirdparty/raknet/SocketLayer.cpp b/thirdparty/raknet/SocketLayer.cpp index 2b8026284..fb15a5949 100644 --- a/thirdparty/raknet/SocketLayer.cpp +++ b/thirdparty/raknet/SocketLayer.cpp @@ -52,11 +52,13 @@ using namespace pp; #include #include // error numbers #include // RAKNET_DEBUG_PRINTF -#if !defined(ANDROID) +#if (!defined(ANDROID) && !defined(__DREAMCAST__)) #include #endif #include +#if !defined(__DREAMCAST__) #include +#endif #include #include #include @@ -117,6 +119,7 @@ void PrepareAddrInfoHints(addrinfo *hints) void SocketLayer::SetSocketOptions( __UDPSOCKET__ listenSocket, bool blockingSocket, bool setBroadcast) { +#if (!defined(__DREAMCAST__) && !defined(_NO_NETWORKING_)) #ifdef __native_client__ (void) listenSocket; #else @@ -179,12 +182,14 @@ void SocketLayer::SetSocketOptions( __UDPSOCKET__ listenSocket, bool blockingSoc } +#endif #endif } RakNet::RakString SocketLayer::GetSubNetForSocketAndIp(__UDPSOCKET__ inSock, RakNet::RakString inIpString) { + #if (!defined(__DREAMCAST__) && !defined(_NO_NETWORKING_)) RakNet::RakString netMaskString; RakNet::RakString ipString; @@ -271,7 +276,9 @@ RakNet::RakString SocketLayer::GetSubNetForSocketAndIp(__UDPSOCKET__ inSock, Rak return ""; #endif - +#else +return ""; +#endif } diff --git a/thirdparty/stb_image/include b/thirdparty/stb_image/include index beebb24b9..f7f20f39f 160000 --- a/thirdparty/stb_image/include +++ b/thirdparty/stb_image/include @@ -1 +1 @@ -Subproject commit beebb24b945efdea3b9bba23affb8eb3ba8982e7 +Subproject commit f7f20f39fe4f206c6f19e26ebfef7b261ee59ee4 diff --git a/tools/buildDC.sh b/tools/buildDC.sh new file mode 100755 index 000000000..5062d5cac --- /dev/null +++ b/tools/buildDC.sh @@ -0,0 +1,5 @@ +# Helps compile for DC, just streamlines the lengthy commands. +cd ../ +mkdir build +cd build +clear && kos-cmake .. -DREMCPE_PLATFORM=sdl1 -DREMCPE_SOUND_PLATFORM=dummy -DUSE_GL_VBO_EMULATION=1 -DOPENAL_LIBRARY=/opt/toolchains/dc/kos-ports/libAL/inst/lib/libAL.a -DZLIB_INCLUDE_DIR=/opt/toolchains/dc/kos-ports/zlib/inst/include && make clean -j12 && make -j12 From 57dbd63cf99d40699fd8b892e653bdefb85c08f2 Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Sun, 28 Sep 2025 20:40:33 -0500 Subject: [PATCH 036/293] Legacy Compat Fixes --- README.md | 2 +- .../macos/projects/Configuration/Settings_iOS.xcconfig | 3 ++- .../macos/projects/Configuration/Settings_macOS.xcconfig | 8 ++++++++ platforms/sdl/base/AppPlatform_sdl.cpp | 2 +- source/world/tile/TallGrass.cpp | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b57061084..63fb3eae7 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ The code is based on a decompilation of Minecraft: Pocket Edition (v0.1.3) as of * Android (thanks to [Stom](https://github.com/Stommm) for the help) * Linux * WebGL - * macOS (10.6 and above; thanks to [BrentDaMage](https://github.com/BrentDaMage)) + * macOS (10.4 and above; thanks to [BrentDaMage](https://github.com/BrentDaMage)) * iOS (3.0 and above; thanks to [BrentDaMage](https://github.com/BrentDaMage)) * HaikuOS (thanks to [SanyaSho](https://github.com/SanyaSho)) diff --git a/platforms/macos/projects/Configuration/Settings_iOS.xcconfig b/platforms/macos/projects/Configuration/Settings_iOS.xcconfig index 4cf8f6948..d79311b84 100644 --- a/platforms/macos/projects/Configuration/Settings_iOS.xcconfig +++ b/platforms/macos/projects/Configuration/Settings_iOS.xcconfig @@ -18,5 +18,6 @@ SDKROOT = $(SDKROOT_IOS) ARCHS_IOS = armv6 armv7 armv7s arm64 ARCHS = $(ARCHS_IOS) -IPHONEOS_DEPLOYMENT_TARGET = 5.0 // iOS 3.0 +// Should be raised if Xcode gives ambiguous error +IPHONEOS_DEPLOYMENT_TARGET = 3.0 // iOS 3.0 TARGETED_DEVICE_FAMILY = 1,2 // iPhone/iPad diff --git a/platforms/macos/projects/Configuration/Settings_macOS.xcconfig b/platforms/macos/projects/Configuration/Settings_macOS.xcconfig index 64132a190..4939da06c 100644 --- a/platforms/macos/projects/Configuration/Settings_macOS.xcconfig +++ b/platforms/macos/projects/Configuration/Settings_macOS.xcconfig @@ -11,6 +11,14 @@ GCC_PREPROCESSOR_DEFINITIONS_MACOS = USE_SDL SDL_DISABLE_IMMINTRIN_H $(GCC_PREPROCESSOR_DEFINITIONS_GLOBAL) GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_MACOS) +SDKROOT_MACOS = // Current Mac OS +//SDKROOT_MACOS = macosx10.4 +SDKROOT = $(SDKROOT_MACOS) + +MACOSX_DEPLOYMENT_TARGET_MACOS = // Compiler Default +//MACOSX_DEPLOYMENT_TARGET_MACOS = 10.4 +MACOSX_DEPLOYMENT_TARGET = $(MACOSX_DEPLOYMENT_TARGET_MACOS) + ARCHS_MACOS_PPC = ppc ppc64 ppc7400 ppc970 ARCHS_MACOS_X86 = i386 x86_64 ARCHS_MACOS_ARM = arm64 diff --git a/platforms/sdl/base/AppPlatform_sdl.cpp b/platforms/sdl/base/AppPlatform_sdl.cpp index bbcb0d4c7..074106d21 100644 --- a/platforms/sdl/base/AppPlatform_sdl.cpp +++ b/platforms/sdl/base/AppPlatform_sdl.cpp @@ -235,7 +235,7 @@ void AppPlatform_sdl::saveScreenshot(const std::string& filename, int glWidth, i { // Handle Alignment int alignment; - glGetIntegerv(GL_PACK_ALIGNMENT, &alignment); + glGetIntegerv(GL_PACK_ALIGNMENT, (GLint*)&alignment); // Round int diff = line_size % alignment; if (diff > 0) diff --git a/source/world/tile/TallGrass.cpp b/source/world/tile/TallGrass.cpp index 2335f0188..cae000cc4 100644 --- a/source/world/tile/TallGrass.cpp +++ b/source/world/tile/TallGrass.cpp @@ -30,7 +30,7 @@ int TallGrass::getColor(const LevelSource* levelSource, const TilePos& pos) cons int TallGrass::getTexture(const LevelSource* level, const TilePos& pos, Facing::Name face) const { - auto data = level->getData(pos); + int data = level->getData(pos); return data == 1 ? m_TextureFrame : (data == 2 ? m_TextureFrame + 16 + 1 : (data == 0 ? m_TextureFrame + 16 : m_TextureFrame)); } From 094a060f38b959ea7a448f3da5fc1fdc5f8aa2fd Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Mon, 29 Sep 2025 02:04:21 -0500 Subject: [PATCH 037/293] Fix Screen::onTextBoxUpdated() never being called --- source/client/gui/components/TextInputBox.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/client/gui/components/TextInputBox.cpp b/source/client/gui/components/TextInputBox.cpp index fefe25815..d078de7de 100644 --- a/source/client/gui/components/TextInputBox.cpp +++ b/source/client/gui/components/TextInputBox.cpp @@ -340,6 +340,7 @@ void TextInputBox::charPressed(int k) break; } } + m_pParent->onTextBoxUpdated(m_ID); } constexpr int PADDING = 5; From e2bcc7b9958dfa8b4c5f67d55024e6576ee7d0fd Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Mon, 29 Sep 2025 18:08:49 -0700 Subject: [PATCH 038/293] Fixed Networking (#193) * Fixed RakNet Endian-Swapping * Fixed incorrect types for packets. --------- Co-authored-by: Brent Da Mage --- platforms/sdl/base/AppPlatform_sdl.cpp | 30 -------- platforms/sdl/base/AppPlatform_sdl.hpp | 4 +- source/client/app/AppPlatform.cpp | 2 +- source/client/app/Minecraft.cpp | 2 +- .../network/ClientSideNetworkHandler.cpp | 16 ++-- source/network/Packet.hpp | 77 ++++++++++++++----- source/network/RakNetInstance.cpp | 1 + source/network/ServerSideNetworkHandler.cpp | 58 ++++++++++---- source/network/packets/MovePlayerPacket.cpp | 14 +++- source/network/packets/PlaceBlockPacket.cpp | 24 ++++-- source/network/packets/RemoveBlockPacket.cpp | 12 ++- source/network/packets/StartGamePacket.cpp | 6 +- source/network/packets/UpdateBlockPacket.cpp | 6 +- source/world/entity/Mob.cpp | 4 +- source/world/entity/Player.cpp | 18 +---- source/world/gamemode/GameMode.cpp | 2 +- source/world/level/TilePos.cpp | 7 ++ source/world/level/TilePos.hpp | 4 + source/world/tile/Tile.cpp | 18 +++++ source/world/tile/Tile.hpp | 2 + thirdparty/stb_image/include | 2 +- 21 files changed, 198 insertions(+), 111 deletions(-) diff --git a/platforms/sdl/base/AppPlatform_sdl.cpp b/platforms/sdl/base/AppPlatform_sdl.cpp index 074106d21..e075709da 100644 --- a/platforms/sdl/base/AppPlatform_sdl.cpp +++ b/platforms/sdl/base/AppPlatform_sdl.cpp @@ -430,36 +430,6 @@ AssetFile AppPlatform_sdl::readAssetFile(const std::string& str, bool quiet) con return AssetFile(size, buf); } -std::string AppPlatform_sdl::getPatchData() -{ - std::string path = getAssetPath(_getPatchDataPath()); - SDL_RWops* io = SDL_RWFromFile(path.c_str(), "rb"); - - if (!io) - { - LOG_W("Couldn't find patch data file!"); - return ""; - } - Sint64 size; -#if SDL_MAJOR_VERSION >= 2 - size = SDL_RWsize(io); -#else - size = SDL_RWseek(io, 0, SEEK_END); - SDL_RWseek(io, 0, SEEK_SET); -#endif - if (size == -1) - { - LOG_E("Error determining the size of the patch data file!"); - } - - char* buf = new char[size]; - SDL_RWread(io, buf, size, 1); - - SDL_RWclose(io); - - return std::string(buf); -} - SDL_Surface* AppPlatform_sdl::_GetSurfaceForTexture(const Texture& texture) { void* pixels = texture.m_pixels; diff --git a/platforms/sdl/base/AppPlatform_sdl.hpp b/platforms/sdl/base/AppPlatform_sdl.hpp index 3802636c2..032aced10 100644 --- a/platforms/sdl/base/AppPlatform_sdl.hpp +++ b/platforms/sdl/base/AppPlatform_sdl.hpp @@ -58,11 +58,9 @@ class AppPlatform_sdl : public AppPlatform void handleControllerButtonEvent(SDL_JoystickID controllerIndex, uint8_t button, uint8_t state); void handleControllerAxisEvent(SDL_JoystickID controllerIndex, uint8_t axis, int16_t value); - // Read Sounds + // Needed for Android AssetFile readAssetFile(const std::string&, bool) const override; - std::string getPatchData() override; - protected: static SDL_Surface* _GetSurfaceForTexture(const Texture& texture); static int _SavePng(const char* filename, unsigned char* pixels, int line_size, int width, int height); diff --git a/source/client/app/AppPlatform.cpp b/source/client/app/AppPlatform.cpp index b91cdbb3c..468ae6942 100644 --- a/source/client/app/AppPlatform.cpp +++ b/source/client/app/AppPlatform.cpp @@ -271,7 +271,7 @@ std::string AppPlatform::getAssetPath(const std::string& path) const AssetFile AppPlatform::readAssetFile(const std::string& path, bool quiet) const { std::string realPath = getAssetPath(path); - std::ifstream ifs(realPath.c_str()); + std::ifstream ifs(realPath.c_str(), std::ios::binary); // Open File if (!ifs.is_open()) diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp index 202c4e903..727937d09 100644 --- a/source/client/app/Minecraft.cpp +++ b/source/client/app/Minecraft.cpp @@ -414,7 +414,7 @@ void Minecraft::handleBuildAction(const BuildActionIntention& action) hitSide = Facing::DOWN; } - m_pRakNetInstance->send(new PlaceBlockPacket(player->m_EntityID, tp.relative(hitSide, 1), TileID(pItem->m_itemID), hitSide)); + m_pRakNetInstance->send(new PlaceBlockPacket(player->m_EntityID, tp.relative(hitSide, 1), TileID(pItem->m_itemID), hitSide, pItem->getAuxValue())); } } } diff --git a/source/client/network/ClientSideNetworkHandler.cpp b/source/client/network/ClientSideNetworkHandler.cpp index d6c64b76e..9abf0e08d 100644 --- a/source/client/network/ClientSideNetworkHandler.cpp +++ b/source/client/network/ClientSideNetworkHandler.cpp @@ -206,10 +206,10 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, PlaceBl { puts_ignorable("PlaceBlockPacket"); - Player* pPlayer = (Player*)m_pLevel->getEntity(pPlaceBlockPkt->m_playerID); + Player* pPlayer = (Player*)m_pLevel->getEntity(pPlaceBlockPkt->m_entityId); if (!pPlayer) { - LOG_E("No player with id %d", pPlaceBlockPkt->m_playerID); + LOG_E("No player with id %d", pPlaceBlockPkt->m_entityId); return; } @@ -220,7 +220,7 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, PlaceBl return; const TilePos& pos = pPlaceBlockPkt->m_pos; - TileID tile = pPlaceBlockPkt->m_tile; + TileID tile = pPlaceBlockPkt->m_tileId; Facing::Name face = (Facing::Name)pPlaceBlockPkt->m_face; if (!m_pLevel->mayPlace(tile, pos, true)) @@ -241,10 +241,10 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, RemoveB { puts_ignorable("RemoveBlockPacket"); - Player* pPlayer = (Player*)m_pLevel->getEntity(pRemoveBlockPkt->m_playerID); + Player* pPlayer = (Player*)m_pLevel->getEntity(pRemoveBlockPkt->m_entityId); if (!pPlayer) { - LOG_E("No player with id %d", pRemoveBlockPkt->m_playerID); + LOG_E("No player with id %d", pRemoveBlockPkt->m_entityId); return; } @@ -255,13 +255,17 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, RemoveB return; const TilePos& pos = pRemoveBlockPkt->m_pos; - Tile* pTile = Tile::tiles[m_pLevel->getTile(pos)]; int data = m_pLevel->getData(pos); + + m_pMinecraft->m_pParticleEngine->destroyEffect(pos); + bool setTileResult = m_pLevel->setTile(pos, TILE_AIR); if (pTile && setTileResult) { + m_pMinecraft->m_pParticleEngine->destroyEffect(pos); + const Tile::SoundType* pSound = pTile->m_pSound; m_pLevel->playSound(pos + 0.5f, "step." + pSound->m_name, 0.5f * (1.0f + pSound->volume), 0.8f * pSound->pitch); diff --git a/source/network/Packet.hpp b/source/network/Packet.hpp index 21d39bee6..eb1e3fbe0 100644 --- a/source/network/Packet.hpp +++ b/source/network/Packet.hpp @@ -115,12 +115,16 @@ class Packet class LoginPacket : public Packet { public: - LoginPacket() {} + LoginPacket() + { + m_clientNetworkVersion = 0; + m_clientNetworkVersion2 = 0; + } LoginPacket(const std::string& uname) { m_str = RakNet::RakString(uname.c_str()); - m_clientNetworkVersion = 2; - m_clientNetworkVersion2 = 2; + m_clientNetworkVersion = NETWORK_PROTOCOL_VERSION; + m_clientNetworkVersion2 = NETWORK_PROTOCOL_VERSION; } void handle(const RakNet::RakNetGUID&, NetEventCallback* pCallback) override; @@ -158,7 +162,7 @@ class LoginStatusPacket : public Packet class ReadyPacket : public Packet { public: - ReadyPacket(int ready = 0) + ReadyPacket(uint8_t ready = 0) { m_ready = ready; } @@ -206,7 +210,10 @@ class StartGamePacket : public Packet public: StartGamePacket() { + m_seed = 0; + m_levelVersion = 0; m_gameType = GAME_TYPES_MAX; + m_entityId = 0; m_serverVersion = 0; m_time = 0; } @@ -226,7 +233,12 @@ class StartGamePacket : public Packet class AddPlayerPacket : public Packet { public: - AddPlayerPacket() {} + AddPlayerPacket() + { + field_4 = 0; + field_14 = 0; + m_id = 0; + } AddPlayerPacket(const Player *player); void handle(const RakNet::RakNetGUID&, NetEventCallback* pCallback) override; void write(RakNet::BitStream*) override; @@ -243,7 +255,10 @@ class AddPlayerPacket : public Packet class RemoveEntityPacket : public Packet { public: - RemoveEntityPacket() {} + RemoveEntityPacket() + { + m_id = 0; + } RemoveEntityPacket(int id) { m_id = id; } void handle(const RakNet::RakNetGUID&, NetEventCallback* pCallback) override; @@ -256,7 +271,10 @@ class RemoveEntityPacket : public Packet class MovePlayerPacket : public Packet { public: - MovePlayerPacket() {} + MovePlayerPacket() + { + m_id = 0; + } MovePlayerPacket(int id, const Vec3& pos, const Vec2& rot): m_id(id), m_pos(pos), m_rot(rot) {} void handle(const RakNet::RakNetGUID&, NetEventCallback* pCallback) override; void write(RakNet::BitStream*) override; @@ -270,36 +288,47 @@ class MovePlayerPacket : public Packet class PlaceBlockPacket : public Packet { public: - PlaceBlockPacket() {} - PlaceBlockPacket(int playerID, const TilePos& pos, TileID tile, Facing::Name face) + PlaceBlockPacket() + { + m_entityId = 0; + m_tileId = TILE_AIR; + m_face = 0; + m_auxValue = 0; + } + PlaceBlockPacket(int entityId, const TilePos& pos, TileID tileId, Facing::Name face, uint8_t auxValue) { - m_playerID = playerID; + m_entityId = entityId; m_pos = pos; - m_tile = tile; + m_tileId = tileId; m_face = face; + m_auxValue = auxValue; } void handle(const RakNet::RakNetGUID&, NetEventCallback* pCallback) override; void write(RakNet::BitStream*) override; void read(RakNet::BitStream*) override; public: - int m_playerID; + int m_entityId; TilePos m_pos; - TileID m_tile; + TileID m_tileId; uint8_t m_face; + uint8_t m_auxValue; }; class RemoveBlockPacket : public Packet { public: - RemoveBlockPacket() {} - RemoveBlockPacket(int id, const TilePos& pos) :m_playerID(id), m_pos(pos) {} + RemoveBlockPacket() + { + m_entityId = 0; + } + RemoveBlockPacket(int id, const TilePos& pos) :m_entityId(id), m_pos(pos) {} void handle(const RakNet::RakNetGUID&, NetEventCallback* pCallback) override; void write(RakNet::BitStream*) override; void read(RakNet::BitStream*) override; public: - int m_playerID; + int m_entityId; TilePos m_pos; }; @@ -330,7 +359,10 @@ class RequestChunkPacket : public Packet class ChunkDataPacket : public Packet { public: - ChunkDataPacket() {} + ChunkDataPacket() + { + m_pChunk = nullptr; + } ChunkDataPacket(const ChunkPos& pos, LevelChunk* c) :m_chunkPos(pos), m_pChunk(c) {} void handle(const RakNet::RakNetGUID&, NetEventCallback* pCallback) override; void write(RakNet::BitStream*) override; @@ -344,7 +376,10 @@ class ChunkDataPacket : public Packet class LevelDataPacket : public Packet { public: - LevelDataPacket() {} + LevelDataPacket() + { + m_pLevel = nullptr; + } LevelDataPacket(Level* level) : m_pLevel(level) {} void handle(const RakNet::RakNetGUID&, NetEventCallback* pCallback) override; void write(RakNet::BitStream*) override; @@ -357,7 +392,11 @@ class LevelDataPacket : public Packet class PlayerEquipmentPacket : public Packet { public: - PlayerEquipmentPacket() {} + PlayerEquipmentPacket() + { + m_playerID = 0; + m_itemID = 0; + } PlayerEquipmentPacket(int playerID, int itemID): m_playerID(playerID), m_itemID(itemID) {} void handle(const RakNet::RakNetGUID&, NetEventCallback* pCallback) override; void write(RakNet::BitStream*) override; diff --git a/source/network/RakNetInstance.cpp b/source/network/RakNetInstance.cpp index 47cb00aab..aa0c86fa7 100644 --- a/source/network/RakNetInstance.cpp +++ b/source/network/RakNetInstance.cpp @@ -150,6 +150,7 @@ void RakNetInstance::runEvents(NetEventCallback* callback) if (pUserPacket) { pUserPacket->read(pBitStream); + LOG_I("Packet: %d", packetType); pUserPacket->handle(pPacket->guid, callback); delete pUserPacket; } diff --git a/source/network/ServerSideNetworkHandler.cpp b/source/network/ServerSideNetworkHandler.cpp index 07a7f2ee8..bfb8f00c3 100644 --- a/source/network/ServerSideNetworkHandler.cpp +++ b/source/network/ServerSideNetworkHandler.cpp @@ -230,33 +230,42 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, MovePlayer puts_ignorable("MovePlayerPacket"); Entity* pEntity = m_pLevel->getEntity(packet->m_id); - if (pEntity) - pEntity->lerpTo(packet->m_pos, packet->m_rot, 3); + if (!pEntity) + return; + + pEntity->lerpTo(packet->m_pos, packet->m_rot, 3); redistributePacket(packet, guid); } void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, PlaceBlockPacket* packet) { - Mob* pMob = (Mob*)m_pLevel->getEntity(packet->m_playerID); - if (!pMob) + if (!m_pLevel) + return; + + Mob* pMob = (Mob*)m_pLevel->getEntity(packet->m_entityId); + if (!pMob || !pMob->isPlayer()) return; - TileID tile = packet->m_tile; + pMob->swing(); + + TileID tileId = packet->m_tileId; Facing::Name face = (Facing::Name)packet->m_face; TilePos pos = packet->m_pos; + uint8_t auxValue = packet->m_auxValue; - printf_ignorable("PlaceBlockPacket: %d", tile); + printf_ignorable("PlaceBlockPacket: %d", tileId); - if (!m_pLevel->mayPlace(tile, pos, true)) + if (!m_pLevel->mayPlace(tileId, pos, true)) return; - if (m_pLevel->setTile(pos, tile)) + if (m_pLevel->setTileAndData(pos, tileId, auxValue)) { - Tile::tiles[tile]->setPlacedOnFace(m_pLevel, pos, face); - Tile::tiles[tile]->setPlacedBy(m_pLevel, pos, pMob); + Tile* pTile = Tile::tiles[tileId]; + pTile->setPlacedOnFace(m_pLevel, pos, face); + pTile->setPlacedBy(m_pLevel, pos, pMob); - const Tile::SoundType* pSound = Tile::tiles[tile]->m_pSound; + const Tile::SoundType* pSound = pTile->m_pSound; m_pLevel->playSound(pos + 0.5f, "step." + pSound->m_name, 0.5f * (pSound->volume + 1.0f), pSound->pitch * 0.8f); } @@ -267,19 +276,40 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, RemoveBloc { puts_ignorable("RemoveBlockPacket"); - Player* pPlayer = (Player*)m_pLevel->getEntity(packet->m_playerID); - if (!pPlayer) + Entity* pEntity = m_pLevel->getEntity(packet->m_entityId); + if (!pEntity || !pEntity->isPlayer()) return; + Player* pPlayer = (Player*)pEntity; + + pPlayer->swing(); + TilePos pos = packet->m_pos; Tile* pTile = Tile::tiles[m_pLevel->getTile(pos)]; - //int data = m_pLevel->getData(pos); + int auxValue = m_pLevel->getData(pos); + + m_pMinecraft->m_pParticleEngine->destroyEffect(pos); + bool setTileResult = m_pLevel->setTile(pos, TILE_AIR); if (pTile && setTileResult) { const Tile::SoundType* pSound = pTile->m_pSound; m_pLevel->playSound(pos + 0.5f, "step." + pSound->m_name, 0.5f * (pSound->volume + 1.0f), pSound->pitch * 0.8f); + /* 0.2.1 + ItemInstance item(pTile, 1, auxValue); + if (m_pMinecraft->m_pGameMode->isSurvivalType() && pTile->m_ID == Tile::grass->m_ID || !m_pMinecraft->m_pLocalPlayer->m_pInventory->hasUnlimitedResource(item)) + { + pTile->spawnResources(m_pLevel, pos, auxValue); + }*/ + + if (pPlayer->isSurvival()) + { + pTile->spawnResources(m_pLevel, pos, auxValue); + } + + pTile->destroy(m_pLevel, pos, auxValue); + // redistribute the packet only if needed redistributePacket(packet, guid); } diff --git a/source/network/packets/MovePlayerPacket.cpp b/source/network/packets/MovePlayerPacket.cpp index dab195698..e29333431 100644 --- a/source/network/packets/MovePlayerPacket.cpp +++ b/source/network/packets/MovePlayerPacket.cpp @@ -17,12 +17,15 @@ void MovePlayerPacket::write(RakNet::BitStream* bs) { bs->Write((unsigned char)PACKET_MOVE_PLAYER); bs->Write(m_id); - bs->Write(m_pos); + bs->Write(m_pos.x); + bs->Write(m_pos.y); + bs->Write(m_pos.z); #if NETWORK_PROTOCOL_VERSION <= 2 bs->Write(m_rot.y); bs->Write(m_rot.x); #else - bs->Write(m_rot); + bs->Write(m_rot.x); + bs->Write(m_rot.y); #endif } @@ -30,11 +33,14 @@ void MovePlayerPacket::write(RakNet::BitStream* bs) void MovePlayerPacket::read(RakNet::BitStream* bs) { bs->Read(m_id); - bs->Read(m_pos); + bs->Read(m_pos.x); + bs->Read(m_pos.y); + bs->Read(m_pos.z); #if NETWORK_PROTOCOL_VERSION <= 2 bs->Read(m_rot.y); bs->Read(m_rot.x); #else - bs->Read(m_rot); + bs->Read(m_rot.x); + bs->Read(m_rot.y); #endif } diff --git a/source/network/packets/PlaceBlockPacket.cpp b/source/network/packets/PlaceBlockPacket.cpp index 66262df7a..dfda22d45 100644 --- a/source/network/packets/PlaceBlockPacket.cpp +++ b/source/network/packets/PlaceBlockPacket.cpp @@ -16,22 +16,34 @@ void PlaceBlockPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* void PlaceBlockPacket::write(RakNet::BitStream* bs) { bs->Write((unsigned char)PACKET_PLACE_BLOCK); - bs->Write(m_playerID); + bs->Write(m_entityId); + // The order of the TilePos matters here bs->Write(m_pos.x); bs->Write(m_pos.z); - bs->Write(m_pos.y); + bs->Write(m_pos.y); + bs->Write(m_face); - bs->Write(m_tile); + bs->Write(m_tileId); +#if NETWORK_PROTOCOL_VERSION >= 3 + bs->Write(m_auxValue); +#endif } void PlaceBlockPacket::read(RakNet::BitStream* bs) { - bs->Read(m_playerID); + bs->Read(m_entityId); + // The order of the TilePos matters here bs->Read(m_pos.x); bs->Read(m_pos.z); - bs->Read(m_pos.y); + uint8_t y; + bs->Read(y); + m_pos.y = y; + bs->Read(m_face); - bs->Read(m_tile); + bs->Read(m_tileId); +#if NETWORK_PROTOCOL_VERSION >= 3 + bs->Read(m_auxValue); +#endif } diff --git a/source/network/packets/RemoveBlockPacket.cpp b/source/network/packets/RemoveBlockPacket.cpp index cc259f0c2..a02192a69 100644 --- a/source/network/packets/RemoveBlockPacket.cpp +++ b/source/network/packets/RemoveBlockPacket.cpp @@ -16,18 +16,22 @@ void RemoveBlockPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* void RemoveBlockPacket::write(RakNet::BitStream* bs) { bs->Write((unsigned char)PACKET_REMOVE_BLOCK); - bs->Write(m_playerID); + bs->Write(m_entityId); + // The order of the TilePos matters here bs->Write(m_pos.x); bs->Write(m_pos.z); - bs->Write(m_pos.y); + bs->Write(m_pos.y); } void RemoveBlockPacket::read(RakNet::BitStream* bs) { - bs->Read(m_playerID); + bs->Read(m_entityId); + // The order of the TilePos matters here bs->Read(m_pos.x); bs->Read(m_pos.z); - bs->Read(m_pos.y); + uint8_t y; + bs->Read(y); + m_pos.y = y; } diff --git a/source/network/packets/StartGamePacket.cpp b/source/network/packets/StartGamePacket.cpp index 3b3034917..9b844ce88 100644 --- a/source/network/packets/StartGamePacket.cpp +++ b/source/network/packets/StartGamePacket.cpp @@ -19,7 +19,7 @@ void StartGamePacket::write(RakNet::BitStream* bs) bs->Write(m_seed); bs->Write(m_levelVersion); #if NETWORK_PROTOCOL_VERSION >= 3 - bs->Write(m_gameType); + bs->Write(m_gameType); #endif bs->Write(m_entityId); bs->Write(m_pos.x); @@ -38,7 +38,9 @@ void StartGamePacket::read(RakNet::BitStream* bs) bs->Read(m_seed); bs->Read(m_levelVersion); #if NETWORK_PROTOCOL_VERSION >= 3 - bs->Read(m_gameType); + int32_t gameType; + bs->Read(gameType); + m_gameType = (GameType)gameType; #endif bs->Read(m_entityId); bs->Read(m_pos.x); diff --git a/source/network/packets/UpdateBlockPacket.cpp b/source/network/packets/UpdateBlockPacket.cpp index 02906a736..69358493d 100644 --- a/source/network/packets/UpdateBlockPacket.cpp +++ b/source/network/packets/UpdateBlockPacket.cpp @@ -18,7 +18,7 @@ void UpdateBlockPacket::write(RakNet::BitStream* bs) bs->Write((unsigned char)PACKET_UPDATE_BLOCK); bs->Write(m_pos.x); bs->Write(m_pos.z); - bs->Write(m_pos.y); + bs->Write(m_pos.y); bs->Write(m_tile); bs->Write(m_data); } @@ -27,7 +27,9 @@ void UpdateBlockPacket::read(RakNet::BitStream* bs) { bs->Read(m_pos.x); bs->Read(m_pos.z); - bs->Read(m_pos.y); + uint8_t y; + bs->Read(y); + m_pos.y = y; bs->Read(m_tile); bs->Read(m_data); } diff --git a/source/world/entity/Mob.cpp b/source/world/entity/Mob.cpp index 635e53bcc..4115bc666 100644 --- a/source/world/entity/Mob.cpp +++ b/source/world/entity/Mob.cpp @@ -898,7 +898,7 @@ void Mob::updateAttackAnim() if (m_bSwinging) { m_swingTime++; - if (m_swingTime > 7) + if (m_swingTime >= 8) { m_swingTime = 0; m_bSwinging = false; @@ -909,5 +909,5 @@ void Mob::updateAttackAnim() m_swingTime = 0; } - m_attackAnim = m_swingTime * 0.125f; + m_attackAnim = m_swingTime / 8.0f; } diff --git a/source/world/entity/Player.cpp b/source/world/entity/Player.cpp index 594f5b197..fb00a96a0 100644 --- a/source/world/entity/Player.cpp +++ b/source/world/entity/Player.cpp @@ -191,6 +191,9 @@ void Player::aiStep() touch(pEnt); } + + // only needed for non-local players for some reason + updateAttackAnim(); } ItemInstance* Player::getCarriedItem() @@ -208,21 +211,6 @@ ItemInstance* Player::getCarriedItem() void Player::updateAi() { - if (m_bSwinging) - { - m_swingTime++; - if (m_swingTime >= 8) - { - m_swingTime = 0; - m_bSwinging = false; - } - } - else - { - m_swingTime = 0; - } - - m_attackAnim = m_swingTime / 8.0f; } void Player::addAdditionalSaveData(CompoundTag& tag) const diff --git a/source/world/gamemode/GameMode.cpp b/source/world/gamemode/GameMode.cpp index 5d637e18f..448a16410 100644 --- a/source/world/gamemode/GameMode.cpp +++ b/source/world/gamemode/GameMode.cpp @@ -40,7 +40,7 @@ bool GameMode::destroyBlock(Player* player, const TilePos& pos, Facing::Name fac int tileData = _level.getData(pos); pTile->playerWillDestroy(player, pos, face); - bool bChanged = _level.setTile(pos, 0); + bool bChanged = _level.setTile(pos, TILE_AIR); if (!bChanged) return false; diff --git a/source/world/level/TilePos.cpp b/source/world/level/TilePos.cpp index 6ce30dc9e..12310c482 100644 --- a/source/world/level/TilePos.cpp +++ b/source/world/level/TilePos.cpp @@ -1,7 +1,14 @@ +#include + #include "TilePos.hpp" #include "world/phys/Vec3.hpp" #include "world/level/levelgen/chunk/ChunkPos.hpp" +const TilePos TilePos::ZERO = TilePos(0, 0, 0); +const TilePos TilePos::ONE = TilePos(1, 1, 1); +const TilePos TilePos::MIN = TilePos(INT_MIN, INT_MIN, INT_MIN); +const TilePos TilePos::MAX = TilePos(INT_MAX, INT_MAX, INT_MAX); + void TilePos::_init(int _x, int _y, int _z) { x = _x; diff --git a/source/world/level/TilePos.hpp b/source/world/level/TilePos.hpp index f9673e70f..5273b625c 100644 --- a/source/world/level/TilePos.hpp +++ b/source/world/level/TilePos.hpp @@ -14,6 +14,10 @@ struct ChunkPos; struct TilePos { +public: + static const TilePos ZERO, ONE, MIN, MAX; + +public: int x; int y; // We had this on uint8_t due to the 255 height limit, but this can overflow too easily int z; diff --git a/source/world/tile/Tile.cpp b/source/world/tile/Tile.cpp index 88a3a0c43..361ca3532 100644 --- a/source/world/tile/Tile.cpp +++ b/source/world/tile/Tile.cpp @@ -767,6 +767,24 @@ void Tile::teardownTiles() delete tiles[i]; } +TileID Tile::TransformToValidBlockId(TileID tileId, TilePos pos) +{ + if (tileId != TILE_AIR && !Tile::tiles[tileId]) + { + // Lifted from 0.2.1. Don't ask me what this is doing, or why it's doing it + if ((((int8_t)pos.y + (int8_t)pos.x + (int8_t)pos.z) & 1) != 0) + return Tile::info_updateGame1->m_ID; + else + return Tile::info_updateGame2->m_ID; + } + return tileId; +} + +TileID Tile::TransformToValidBlockId(TileID tileId) +{ + return TransformToValidBlockId(tileId, TilePos::ZERO); +} + void Tile::updateShape(const LevelSource* a, const TilePos& pos) { } diff --git a/source/world/tile/Tile.hpp b/source/world/tile/Tile.hpp index 1b8993d23..1c26fea60 100644 --- a/source/world/tile/Tile.hpp +++ b/source/world/tile/Tile.hpp @@ -121,6 +121,8 @@ class Tile public: // static functions static void initTiles(); static void teardownTiles(); + static TileID TransformToValidBlockId(TileID tileId, TilePos pos); + static TileID TransformToValidBlockId(TileID tileId); public: // static variables static std::string TILE_DESCRIPTION_PREFIX; diff --git a/thirdparty/stb_image/include b/thirdparty/stb_image/include index f7f20f39f..beebb24b9 160000 --- a/thirdparty/stb_image/include +++ b/thirdparty/stb_image/include @@ -1 +1 @@ -Subproject commit f7f20f39fe4f206c6f19e26ebfef7b261ee59ee4 +Subproject commit beebb24b945efdea3b9bba23affb8eb3ba8982e7 From 20f71497dd336f7352e8496d246c386f1d38b0c9 Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Mon, 29 Sep 2025 21:58:21 -0500 Subject: [PATCH 039/293] Disable packet logging in RakNetInstance --- source/network/RakNetInstance.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/network/RakNetInstance.cpp b/source/network/RakNetInstance.cpp index aa0c86fa7..91bd19750 100644 --- a/source/network/RakNetInstance.cpp +++ b/source/network/RakNetInstance.cpp @@ -150,7 +150,7 @@ void RakNetInstance::runEvents(NetEventCallback* callback) if (pUserPacket) { pUserPacket->read(pBitStream); - LOG_I("Packet: %d", packetType); + //LOG_PACKET("Packet: %d", packetType); pUserPacket->handle(pPacket->guid, callback); delete pUserPacket; } From 1dfef2d6a513ad83d37abec20e2b48a024361c5d Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Mon, 29 Sep 2025 21:58:57 -0500 Subject: [PATCH 040/293] Disable VERBOSE_SERVER --- source/network/ServerSideNetworkHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/network/ServerSideNetworkHandler.cpp b/source/network/ServerSideNetworkHandler.cpp index bfb8f00c3..d5dd7d20f 100644 --- a/source/network/ServerSideNetworkHandler.cpp +++ b/source/network/ServerSideNetworkHandler.cpp @@ -11,7 +11,7 @@ #include "world/entity/MobFactory.hpp" // This lets you make the server shut up and not log events in the debug console. -#define VERBOSE_SERVER +//#define VERBOSE_SERVER #if defined(ORIGINAL_CODE) || defined(VERBOSE_SERVER) #define puts_ignorable(str) LOG_I(str) From c89e0a11825d9f81445aa7930a85b003fd638b4f Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Mon, 29 Sep 2025 21:59:22 -0500 Subject: [PATCH 041/293] Disable VERBOSE_CLIENT --- source/client/network/ClientSideNetworkHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/client/network/ClientSideNetworkHandler.cpp b/source/client/network/ClientSideNetworkHandler.cpp index 9abf0e08d..a2af25313 100644 --- a/source/client/network/ClientSideNetworkHandler.cpp +++ b/source/client/network/ClientSideNetworkHandler.cpp @@ -13,7 +13,7 @@ #include "client/gui/screens/DisconnectionScreen.hpp" // This lets you make the client shut up and not log events in the debug console. -#define VERBOSE_CLIENT +//#define VERBOSE_CLIENT #if defined(ORIGINAL_CODE) || defined(VERBOSE_CLIENT) #define puts_ignorable(str) LOG_I(str) From 501ce70a2bac84e4adf43df7710343734240db6d Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Mon, 29 Sep 2025 23:33:16 -0500 Subject: [PATCH 042/293] Fix Incorrect Positioning in AddPlayerPacket --- source/network/packets/AddPlayerPacket.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/network/packets/AddPlayerPacket.cpp b/source/network/packets/AddPlayerPacket.cpp index d46a057cc..8110222dc 100644 --- a/source/network/packets/AddPlayerPacket.cpp +++ b/source/network/packets/AddPlayerPacket.cpp @@ -14,7 +14,7 @@ AddPlayerPacket::AddPlayerPacket(const Player *player) m_name = RakNet::RakString(player->m_name.c_str()); m_id = player->m_EntityID; m_pos = player->m_pos; - m_pos -= player->m_heightOffset; + m_pos.y -= player->m_heightOffset; } void AddPlayerPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback) @@ -41,4 +41,4 @@ void AddPlayerPacket::read(RakNet::BitStream* bs) bs->Read(m_pos.x); bs->Read(m_pos.y); bs->Read(m_pos.z); -} \ No newline at end of file +} From 439c4ee48f984f2902bfe1700302718f81197623 Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Tue, 30 Sep 2025 01:13:11 -0500 Subject: [PATCH 043/293] Fix Typo in SoundSystemNull --- platforms/sound/dummy/CustomSoundSystem.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platforms/sound/dummy/CustomSoundSystem.hpp b/platforms/sound/dummy/CustomSoundSystem.hpp index 01f9fa5a1..13d02d669 100644 --- a/platforms/sound/dummy/CustomSoundSystem.hpp +++ b/platforms/sound/dummy/CustomSoundSystem.hpp @@ -41,5 +41,5 @@ class SoundSystemNull : public SoundSystem void muteAudio() override; void unMuteAudio() override; -} override; +}; From 0d4b39e36b3659bd28ab4b752b8faf0c4c4801f6 Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Tue, 30 Sep 2025 02:01:39 -0700 Subject: [PATCH 044/293] Multiplayer F3 Heap Corruption Bugfix (#194) Fixed a bug which would cause a heap corruption when the F3 menu was open while connecting to a server, and would typically result in a crash. Co-authored-by: Brent Da Mage --- source/client/app/Minecraft.cpp | 11 +++++++++-- source/client/renderer/GameRenderer.cpp | 14 +++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp index 727937d09..b6d9a8b65 100644 --- a/source/client/app/Minecraft.cpp +++ b/source/client/app/Minecraft.cpp @@ -1137,15 +1137,16 @@ void Minecraft::setLevel(Level* pLevel, const std::string& text, LocalPlayer* pL { // We're getting a LocalPlayer from a server m_pLocalPlayer = pLocalPlayer; - pLocalPlayer->resetPos(); } else if (m_pLocalPlayer) { // We're not on any server - m_pLocalPlayer->resetPos(); pLevel->addEntity(m_pLocalPlayer); } + if (m_pLocalPlayer) + m_pLocalPlayer->resetPos(); + m_pLevel = pLevel; m_bPreparingLevel = true; m_pPrepThread = new CThread(&Minecraft::prepareLevel_tspawn, this); @@ -1159,6 +1160,12 @@ void Minecraft::setLevel(Level* pLevel, const std::string& text, LocalPlayer* pL { m_pLocalPlayer = nullptr; } + + if (!m_pLocalPlayer) + { + // pLocalPlayer went unused, and *someone* needs to clean it up + SAFE_DELETE(pLocalPlayer); + } } void Minecraft::selectLevel(const LevelSummary& ls, bool forceConversion) diff --git a/source/client/renderer/GameRenderer.cpp b/source/client/renderer/GameRenderer.cpp index 4d89a0291..e3b7028b3 100644 --- a/source/client/renderer/GameRenderer.cpp +++ b/source/client/renderer/GameRenderer.cpp @@ -689,7 +689,19 @@ void GameRenderer::render(float f) if (m_pMinecraft->getOptions()->m_bDebugText) { - if (m_pMinecraft->m_pLocalPlayer) + /* + * The "!m_pMinecraft->m_bPreparingLevel" check *needs* to be here. + * If said check is not here, when getBiome() is called for the biome display, + * it would allocate an array with a size of 1 before the level was even generated. + * Then, during level generation, said array would be written to as if it had a size + * of 256, leading to a heap corruption that took ASan to debug successfully. + * Unfortunately, ASan and DirectSound don't mix, and Microsoft's ASan team has stated that they don't even know why: + * https://developercommunity.visualstudio.com/t/ASAN-x64-causes-unhandled-exception-at-0/1365655#T-N10460750 + * Since all SoundSystems are backed with DirectSound, SoundSystemNull is needed to use ASan. + * This heap corruption bug, which (only if the F3 menu was open) would cause multiplayer functionality to be entirely + * based on luck, had been around since Commit 53200be, on March 5th of 2025, and was fixed on September 30th of 2025. + */ + if (m_pMinecraft->m_pLocalPlayer && !m_pMinecraft->m_bPreparingLevel) { char posStr[96]; Vec3 pos = m_pMinecraft->m_pLocalPlayer->getPos(f); From 861fc9d6e45d6c4c2b1a8525a4a1a9cbcd63f1ba Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Wed, 1 Oct 2025 14:44:03 -0700 Subject: [PATCH 045/293] Tile Cleanup (#195) * Added TileData typedef * Added DataLayer for LevelChunk * Added tile update flags --------- Co-authored-by: Brent Da Mage --- .../Minecraft.xcodeproj/project.pbxproj | 28 ++- .../windows/projects/World/World.vcxproj | 3 + .../projects/World/World.vcxproj.filters | 11 +- source/CMakeLists.txt | 1 + source/client/app/Minecraft.cpp | 4 +- source/client/gui/screens/StartMenuScreen.cpp | 2 +- .../network/ClientSideNetworkHandler.cpp | 35 ++-- .../network/ClientSideNetworkHandler.hpp | 2 +- source/client/renderer/TileRenderer.cpp | 14 +- source/client/renderer/TileRenderer.hpp | 4 +- source/common/Utils.hpp | 5 +- source/network/Packet.hpp | 18 +- source/network/ServerSideNetworkHandler.cpp | 14 +- source/network/packets/ChunkDataPacket.cpp | 4 +- source/network/packets/PlaceBlockPacket.cpp | 8 +- source/network/packets/UpdateBlockPacket.cpp | 4 +- source/world/entity/Arrow.cpp | 2 +- source/world/entity/Chicken.cpp | 2 +- source/world/entity/Creeper.cpp | 2 +- source/world/entity/Entity.cpp | 6 +- source/world/entity/FallingTile.cpp | 2 +- source/world/entity/Mob.cpp | 6 +- source/world/entity/Sheep.cpp | 2 +- source/world/item/CameraItem.cpp | 2 +- source/world/level/Level.cpp | 130 ++++++++----- source/world/level/Level.hpp | 15 +- source/world/level/Region.cpp | 2 +- source/world/level/Region.hpp | 2 +- source/world/level/TileChange.hpp | 38 ++++ .../world/level/levelgen/chunk/DataLayer.cpp | 68 +++++++ .../world/level/levelgen/chunk/DataLayer.hpp | 20 ++ .../level/levelgen/chunk/EmptyLevelChunk.cpp | 8 +- .../level/levelgen/chunk/EmptyLevelChunk.hpp | 6 +- .../world/level/levelgen/chunk/LevelChunk.cpp | 176 +++++------------- .../world/level/levelgen/chunk/LevelChunk.hpp | 18 +- .../levelgen/chunk/RandomLevelSource.cpp | 5 +- .../level/levelgen/feature/ClayFeature.cpp | 2 +- .../world/level/levelgen/feature/Feature.hpp | 22 +-- .../level/levelgen/feature/FlowerFeature.cpp | 2 +- .../level/levelgen/feature/OreFeature.cpp | 2 +- .../level/levelgen/feature/SpringFeature.cpp | 2 +- .../levelgen/feature/VegetationFeature.cpp | 2 +- .../storage/ExternalFileLevelStorage.cpp | 14 +- source/world/level/storage/LevelSource.hpp | 2 +- source/world/tile/BookshelfTile.cpp | 2 +- source/world/tile/BookshelfTile.hpp | 2 +- source/world/tile/Bush.cpp | 2 +- source/world/tile/Bush.hpp | 2 +- source/world/tile/CactusTile.cpp | 2 +- source/world/tile/ClayTile.cpp | 4 +- source/world/tile/ClayTile.hpp | 4 +- source/world/tile/ClothTile.cpp | 2 +- source/world/tile/ClothTile.hpp | 2 +- source/world/tile/DoorTile.cpp | 10 +- source/world/tile/DoorTile.hpp | 10 +- source/world/tile/FarmTile.cpp | 10 +- source/world/tile/FarmTile.hpp | 6 +- source/world/tile/FireTile.cpp | 2 +- source/world/tile/GlowstoneTile.cpp | 4 +- source/world/tile/GlowstoneTile.hpp | 4 +- source/world/tile/GrassTile.cpp | 8 +- source/world/tile/GrassTile.hpp | 4 +- source/world/tile/GravelTile.cpp | 2 +- source/world/tile/GravelTile.hpp | 2 +- source/world/tile/InvisibleTile.cpp | 2 +- source/world/tile/InvisibleTile.hpp | 2 +- source/world/tile/LadderTile.cpp | 8 +- source/world/tile/LeafTile.cpp | 12 +- source/world/tile/LeafTile.hpp | 6 +- source/world/tile/LiquidTile.cpp | 8 +- source/world/tile/LiquidTile.hpp | 8 +- source/world/tile/LiquidTileDynamic.cpp | 6 +- source/world/tile/LiquidTileDynamic.hpp | 2 +- source/world/tile/ObsidianTile.cpp | 2 +- source/world/tile/ObsidianTile.hpp | 2 +- source/world/tile/OreTile.cpp | 4 +- source/world/tile/OreTile.hpp | 4 +- source/world/tile/PumpkinTile.cpp | 6 +- source/world/tile/PumpkinTile.hpp | 4 +- source/world/tile/RedStoneOreTile.cpp | 4 +- source/world/tile/RedStoneOreTile.hpp | 4 +- source/world/tile/ReedTile.cpp | 6 +- source/world/tile/ReedTile.hpp | 4 +- source/world/tile/RocketLauncherTile.cpp | 4 +- source/world/tile/RocketLauncherTile.hpp | 4 +- source/world/tile/SandTile.cpp | 2 +- source/world/tile/Sapling.cpp | 8 +- source/world/tile/Sapling.hpp | 4 +- source/world/tile/SpongeTile.cpp | 4 +- source/world/tile/SpongeTile.hpp | 4 +- source/world/tile/StairTile.cpp | 24 +-- source/world/tile/StairTile.hpp | 12 +- source/world/tile/StoneSlabTile.cpp | 4 +- source/world/tile/StoneSlabTile.hpp | 4 +- source/world/tile/StoneTile.cpp | 4 +- source/world/tile/StoneTile.hpp | 4 +- source/world/tile/TallGrass.cpp | 6 +- source/world/tile/TallGrass.hpp | 4 +- source/world/tile/Tile.cpp | 20 +- source/world/tile/Tile.hpp | 24 +-- source/world/tile/TntTile.cpp | 4 +- source/world/tile/TntTile.hpp | 2 +- source/world/tile/TopSnowTile.cpp | 4 +- source/world/tile/TopSnowTile.hpp | 4 +- source/world/tile/TorchTile.cpp | 4 +- source/world/tile/TreeTile.cpp | 6 +- source/world/tile/TreeTile.hpp | 4 +- source/world/tile/Web.cpp | 4 +- source/world/tile/Web.hpp | 4 +- thirdparty/stb_image/include | 2 +- 110 files changed, 583 insertions(+), 486 deletions(-) create mode 100644 source/world/level/TileChange.hpp create mode 100644 source/world/level/levelgen/chunk/DataLayer.cpp create mode 100644 source/world/level/levelgen/chunk/DataLayer.hpp diff --git a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj index b69d1b9f3..5b619ebb5 100644 --- a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj +++ b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj @@ -1319,6 +1319,9 @@ 84EAE8E42AF1EABE000894E8 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84EAE8E32AF1EABE000894E8 /* OpenGLES.framework */; }; 84EAE8F72AF1EAFA000894E8 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EAE8F12AF1EAFA000894E8 /* main.cpp */; }; 84ED99D52AFF12D1003B6AF0 /* minecraftpe.entitlements in Resources */ = {isa = PBXBuildFile; fileRef = 84ED99D42AFF12D1003B6AF0 /* minecraftpe.entitlements */; }; + 84EE51312E8DCC9000D3DCA2 /* DataLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EE512F2E8DCC9000D3DCA2 /* DataLayer.cpp */; }; + 84EE51322E8DCC9000D3DCA2 /* DataLayer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EE51302E8DCC9000D3DCA2 /* DataLayer.hpp */; }; + 84EE51342E8DCD4900D3DCA2 /* TileChange.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EE51332E8DCD4900D3DCA2 /* TileChange.hpp */; }; 84FFBE952ACA3415005A8CCF /* _FindFirst.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD73A2AC810620006A435 /* _FindFirst.cpp */; }; 84FFBE962ACA3415005A8CCF /* Base64Encoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD73E2AC810620006A435 /* Base64Encoder.cpp */; }; 84FFBE972ACA3415005A8CCF /* BitStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD7402AC810620006A435 /* BitStream.cpp */; }; @@ -3029,6 +3032,9 @@ 84EDD07A2E76E2B600375AEF /* LegacyCPP.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = LegacyCPP.hpp; sourceTree = ""; }; 84EDD07B2E76E2B600375AEF /* LegacyCPP_Compat.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = LegacyCPP_Compat.hpp; sourceTree = ""; }; 84EDD07C2E76E2B600375AEF /* LegacyCPP_Info.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = LegacyCPP_Info.hpp; sourceTree = ""; }; + 84EE512F2E8DCC9000D3DCA2 /* DataLayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DataLayer.cpp; sourceTree = ""; }; + 84EE51302E8DCC9000D3DCA2 /* DataLayer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DataLayer.hpp; sourceTree = ""; }; + 84EE51332E8DCD4900D3DCA2 /* TileChange.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TileChange.hpp; sourceTree = ""; }; 84FFBD7E2ACA2876005A8CCF /* libRakNet.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRakNet.a; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -3651,25 +3657,26 @@ 840DD67E2AC810620006A435 /* level */ = { isa = PBXGroup; children = ( - 840DD6802AC810620006A435 /* Dimension.hpp */, 840DD67F2AC810620006A435 /* Dimension.cpp */, - 840DD6822AC810620006A435 /* Explosion.hpp */, + 840DD6802AC810620006A435 /* Dimension.hpp */, 840DD6812AC810620006A435 /* Explosion.cpp */, - 840DD6842AC810620006A435 /* Level.hpp */, + 840DD6822AC810620006A435 /* Explosion.hpp */, 840DD6832AC810620006A435 /* Level.cpp */, + 840DD6842AC810620006A435 /* Level.hpp */, 840DD6852AC810620006A435 /* levelgen */, - 840DD6B02AC810620006A435 /* LevelListener.hpp */, 840DD6AF2AC810620006A435 /* LevelListener.cpp */, - 840DD6B22AC810620006A435 /* Material.hpp */, + 840DD6B02AC810620006A435 /* LevelListener.hpp */, 840DD6B12AC810620006A435 /* Material.cpp */, + 840DD6B22AC810620006A435 /* Material.hpp */, 84AA8B472B32F39A003F5B82 /* path */, - 840DD6B42AC810620006A435 /* Region.hpp */, 840DD6B32AC810620006A435 /* Region.cpp */, + 840DD6B42AC810620006A435 /* Region.hpp */, 840DD6B52AC810620006A435 /* storage */, - 840DD6CD2AC810620006A435 /* TickNextTickData.hpp */, 840DD6CC2AC810620006A435 /* TickNextTickData.cpp */, - 8477B3AB2C4DC3F6004E1AC5 /* TilePos.hpp */, + 840DD6CD2AC810620006A435 /* TickNextTickData.hpp */, + 84EE51332E8DCD4900D3DCA2 /* TileChange.hpp */, 8477B3AA2C4DC3F6004E1AC5 /* TilePos.cpp */, + 8477B3AB2C4DC3F6004E1AC5 /* TilePos.hpp */, ); path = level; sourceTree = ""; @@ -3706,6 +3713,8 @@ 840DD68E2AC810620006A435 /* ChunkSource.cpp */, 840DD68F2AC810620006A435 /* ChunkSource.hpp */, 8477B3B02C4DC414004E1AC5 /* ChunkTilePos.hpp */, + 84EE512F2E8DCC9000D3DCA2 /* DataLayer.cpp */, + 84EE51302E8DCC9000D3DCA2 /* DataLayer.hpp */, 8477B3B12C4DC414004E1AC5 /* EmptyLevelChunk.cpp */, 8477B3B22C4DC414004E1AC5 /* EmptyLevelChunk.hpp */, 840DD6902AC810620006A435 /* LevelChunk.cpp */, @@ -5744,6 +5753,7 @@ 84BF639E2AF186C8008A9995 /* Region.hpp in Headers */, 84BF639F2AF186C8008A9995 /* ChunkStorage.hpp in Headers */, 84BF63A02AF186C8008A9995 /* ExternalFileLevelStorage.hpp in Headers */, + 84EE51322E8DCC9000D3DCA2 /* DataLayer.hpp in Headers */, 84BF63A12AF186C8008A9995 /* ExternalFileLevelStorageSource.hpp in Headers */, 84BF63A22AF186C8008A9995 /* LevelData.hpp in Headers */, 84BF63A32AF186C8008A9995 /* LevelSource.hpp in Headers */, @@ -5820,6 +5830,7 @@ 84B1E03E2E04FD7900ED000A /* Spider.hpp in Headers */, 84AA8B8D2B32F3B5003F5B82 /* PathfinderMob.hpp in Headers */, 84AA8B8F2B32F3B5003F5B82 /* Pig.hpp in Headers */, + 84EE51342E8DCD4900D3DCA2 /* TileChange.hpp in Headers */, 8477B3BB2C4DC42E004E1AC5 /* Vec2.hpp in Headers */, 8477B3B42C4DC414004E1AC5 /* ChunkPos.hpp in Headers */, 84AA8B972B32F3B5003F5B82 /* WaterAnimal.hpp in Headers */, @@ -7063,6 +7074,7 @@ 84BF63242AF18631008A9995 /* ChunkSource.cpp in Sources */, 84BF63252AF18631008A9995 /* LevelChunk.cpp in Sources */, 84BF63262AF18631008A9995 /* PerformanceTestChunkSource.cpp in Sources */, + 84EE51312E8DCC9000D3DCA2 /* DataLayer.cpp in Sources */, 84BF63272AF18631008A9995 /* RandomLevelSource.cpp in Sources */, 84E1C9E72E7FDC72007D2F5D /* ClothItem.cpp in Sources */, 84BF63282AF18631008A9995 /* TestChunkSource.cpp in Sources */, diff --git a/platforms/windows/projects/World/World.vcxproj b/platforms/windows/projects/World/World.vcxproj index b9c3a4287..3d4fcea2a 100644 --- a/platforms/windows/projects/World/World.vcxproj +++ b/platforms/windows/projects/World/World.vcxproj @@ -191,6 +191,7 @@ + @@ -331,6 +332,8 @@ + + diff --git a/platforms/windows/projects/World/World.vcxproj.filters b/platforms/windows/projects/World/World.vcxproj.filters index 570fe2306..12ecf7b56 100644 --- a/platforms/windows/projects/World/World.vcxproj.filters +++ b/platforms/windows/projects/World/World.vcxproj.filters @@ -560,6 +560,9 @@ Source Files\Entity + + Source Files\Level\LevelGen\Chunk + @@ -976,5 +979,11 @@ Header Files\Tile + + Header Files\Level + + + Header Files\Level\LevelGen\Chunk + - + \ No newline at end of file diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index d583b29d3..8424e0c00 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -262,6 +262,7 @@ add_library(reminecraftpe-core STATIC world/level/levelgen/chunk/ChunkCache.cpp world/level/levelgen/chunk/ChunkPos.cpp world/level/levelgen/chunk/ChunkSource.cpp + world/level/levelgen/chunk/DataLayer.cpp world/level/levelgen/chunk/EmptyLevelChunk.cpp world/level/levelgen/chunk/PerformanceTestChunkSource.cpp world/level/levelgen/chunk/TestChunkSource.cpp diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp index b6d9a8b65..374934f81 100644 --- a/source/client/app/Minecraft.cpp +++ b/source/client/app/Minecraft.cpp @@ -265,7 +265,7 @@ bool Minecraft::isOnlineClient() const if (!m_pLevel) return false; - return m_pLevel->m_bIsOnline; + return m_pLevel->m_bIsClientSide; } bool Minecraft::isTouchscreen() const @@ -748,7 +748,7 @@ void Minecraft::tick() if (m_pLevel && !isGamePaused()) { m_pLevel->m_difficulty = m_options->m_difficulty; - if (m_pLevel->m_bIsOnline) + if (m_pLevel->m_bIsClientSide) { m_pLevel->m_difficulty = 3; } diff --git a/source/client/gui/screens/StartMenuScreen.cpp b/source/client/gui/screens/StartMenuScreen.cpp index a303c8e7b..a3bf7f248 100644 --- a/source/client/gui/screens/StartMenuScreen.cpp +++ b/source/client/gui/screens/StartMenuScreen.cpp @@ -679,7 +679,7 @@ void StartMenuScreen::draw3dTitle(float f) // rotate 90 deg on the X axis to correct lighting glRotatef(90.0f, 1.0f, 0.0f, 0.0f); - m_tileRenderer.renderTile(pTile, i == 0 ? 999 : 0, bright, true); + m_tileRenderer.renderTile(pTile, i == 0 ? 255 : 0, bright, true); glPopMatrix(); } diff --git a/source/client/network/ClientSideNetworkHandler.cpp b/source/client/network/ClientSideNetworkHandler.cpp index a2af25313..49bd009a0 100644 --- a/source/client/network/ClientSideNetworkHandler.cpp +++ b/source/client/network/ClientSideNetworkHandler.cpp @@ -83,7 +83,7 @@ void ClientSideNetworkHandler::onDisconnect(const RakNet::RakNetGUID& rakGuid) puts_ignorable("onDisconnect"); if (m_pLevel) - m_pLevel->m_bIsOnline = false; + m_pLevel->m_bIsClientSide = false; m_pMinecraft->m_gui.addMessage("Disconnected from server"); } @@ -130,7 +130,7 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, StartGa pStartGamePkt->m_seed, pStartGamePkt->m_levelVersion); - m_pLevel->m_bIsOnline = true; + m_pLevel->m_bIsClientSide = true; GameType gameType = pStartGamePkt->m_gameType != GAME_TYPES_MAX ? pStartGamePkt->m_gameType : m_pLevel->getDefaultGameType(); LocalPlayer *pLocalPlayer = new LocalPlayer(m_pMinecraft, m_pLevel, m_pMinecraft->m_pUser, gameType, m_pLevel->m_pDimension->field_50); @@ -220,18 +220,18 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, PlaceBl return; const TilePos& pos = pPlaceBlockPkt->m_pos; - TileID tile = pPlaceBlockPkt->m_tileId; + TileID tileTypeId = pPlaceBlockPkt->m_tileTypeId; Facing::Name face = (Facing::Name)pPlaceBlockPkt->m_face; - if (!m_pLevel->mayPlace(tile, pos, true)) + if (!m_pLevel->mayPlace(tileTypeId, pos, true)) return; - Tile* pTile = Tile::tiles[tile]; - if (!m_pLevel->setTile(pos, tile)) + Tile* pTile = Tile::tiles[tileTypeId]; + if (!m_pLevel->setTile(pos, tileTypeId)) return; - Tile::tiles[tile]->setPlacedOnFace(m_pLevel, pos, face); - Tile::tiles[tile]->setPlacedBy(m_pLevel, pos, pPlayer); + pTile->setPlacedOnFace(m_pLevel, pos, face); + pTile->setPlacedBy(m_pLevel, pos, pPlayer); const Tile::SoundType* pSound = pTile->m_pSound; m_pLevel->playSound(pos + 0.5f, "step." + pSound->m_name, 0.5f * (1.0f + pSound->volume), 0.8f * pSound->pitch); @@ -241,13 +241,15 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, RemoveB { puts_ignorable("RemoveBlockPacket"); - Player* pPlayer = (Player*)m_pLevel->getEntity(pRemoveBlockPkt->m_entityId); - if (!pPlayer) + Entity* pEntity = m_pLevel->getEntity(pRemoveBlockPkt->m_entityId); + if (!pEntity || !pEntity->isPlayer()) { LOG_E("No player with id %d", pRemoveBlockPkt->m_entityId); return; } + Player* pPlayer = (Player*)pEntity; + pPlayer->swing(); // @BUG: Not buffering the update. @@ -256,20 +258,17 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, RemoveB const TilePos& pos = pRemoveBlockPkt->m_pos; Tile* pTile = Tile::tiles[m_pLevel->getTile(pos)]; - int data = m_pLevel->getData(pos); + int auxValue = m_pLevel->getData(pos); m_pMinecraft->m_pParticleEngine->destroyEffect(pos); bool setTileResult = m_pLevel->setTile(pos, TILE_AIR); - if (pTile && setTileResult) { - m_pMinecraft->m_pParticleEngine->destroyEffect(pos); - const Tile::SoundType* pSound = pTile->m_pSound; m_pLevel->playSound(pos + 0.5f, "step." + pSound->m_name, 0.5f * (1.0f + pSound->volume), 0.8f * pSound->pitch); - pTile->destroy(m_pLevel, pos, data); + pTile->destroy(m_pLevel, pos, auxValue); } } @@ -277,11 +276,11 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, UpdateB { if (!areAllChunksLoaded()) { - m_bufferedBlockUpdates.push_back(SBufferedBlockUpdate(pkt->m_pos, pkt->m_tile, pkt->m_data)); + m_bufferedBlockUpdates.push_back(SBufferedBlockUpdate(pkt->m_pos, pkt->m_tileTypeId, pkt->m_data)); return; } - m_pLevel->setTileAndData(pkt->m_pos, pkt->m_tile, pkt->m_data); + m_pLevel->setTileAndData(pkt->m_pos, pkt->m_tileTypeId, pkt->m_data); } void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, ChunkDataPacket* pChunkDataPkt) @@ -334,7 +333,7 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, ChunkDa } int idx = ((k & 0xF) << 11) | ((k >> 4) << 7) + yPos; - memcpy(&pChunk->m_tileData[idx >> 1], datas, sizeof datas); + memcpy(&pChunk->m_tileData.m_data[idx >> 1], datas, sizeof datas); } int ymin = 16 * (1 << j); diff --git a/source/client/network/ClientSideNetworkHandler.hpp b/source/client/network/ClientSideNetworkHandler.hpp index c5ccfeee4..a86332068 100644 --- a/source/client/network/ClientSideNetworkHandler.hpp +++ b/source/client/network/ClientSideNetworkHandler.hpp @@ -17,7 +17,7 @@ struct SBufferedBlockUpdate TilePos pos; uint8_t tile, data; - SBufferedBlockUpdate(const TilePos& pos, TileID tile, int data) : + SBufferedBlockUpdate(const TilePos& pos, TileID tile, TileData data) : pos(pos), tile(uint8_t(tile)), data(uint8_t(data)) {} }; diff --git a/source/client/renderer/TileRenderer.cpp b/source/client/renderer/TileRenderer.cpp index 1921aabc2..76c471d6a 100644 --- a/source/client/renderer/TileRenderer.cpp +++ b/source/client/renderer/TileRenderer.cpp @@ -96,7 +96,7 @@ float TileRenderer::getWaterHeight(const TilePos& pos, const Material* pCheckMtl Material* pMtl = m_pLevelSource->getMaterial(checkPos); if (pMtl == pCheckMtl) { - int data = m_pLevelSource->getData(checkPos); + TileData data = m_pLevelSource->getData(checkPos); if (data >= 8 || data == 0) { fHeight += LiquidTile::getWaterVolume(data) * 10.0f; @@ -526,7 +526,7 @@ void TileRenderer::renderFaceUp(Tile* tile, const Vec3& pos, int texture) tile->updateShape(m_pLevelSource, pos); } -void TileRenderer::tesselateCrossTexture(Tile* tile, int data, const Vec3& pos) +void TileRenderer::tesselateCrossTexture(Tile* tile, TileData data, const Vec3& pos) { static constexpr float C_RATIO = 1.0f / 256.0f; @@ -1198,7 +1198,7 @@ void TileRenderer::tesselateTorch(Tile* tile, const Vec3& pos, float a, float b) bool TileRenderer::tesselateTorchInWorld(Tile* tile, const TilePos& pos) { - int data = m_pLevelSource->getData(pos); + TileData data = m_pLevelSource->getData(pos); float bright = tile->getBrightness(m_pLevelSource, pos); if (Tile::lightEmission[tile->m_ID] > 0) @@ -2518,7 +2518,7 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti #endif -void TileRenderer::renderTile(Tile* tile, int data, float bright, bool preshade) +void TileRenderer::renderTile(Tile* tile, TileData data, float bright, bool preshade) { Tesselator& t = Tesselator::instance; @@ -2535,9 +2535,9 @@ void TileRenderer::renderTile(Tile* tile, int data, float bright, bool preshade) case SHAPE_SOLID: default: { - // N.B. If caller passes 999, they only want the face-down face. + // N.B. If caller passes 255, they only want the face-down face. // This is a hack to accomodate the start menu screen procedurally generated title logo. -#define IF_NEEDED(x) do { if (data != 999) { (x); } } while (0) +#define IF_NEEDED(x) do { if (data != 255) { (x); } } while (0) glTranslatef(-0.5f, -0.5f, -0.5f); t.begin(); @@ -2906,7 +2906,7 @@ int TileRenderer::getTileColor(Tile* tile, const TilePos& pos) } if (tile == Tile::leaves && FoliageColor::isAvailable() && m_bBiomeColors) { - int data = m_pLevelSource->getData(pos); + TileData data = m_pLevelSource->getData(pos); if ((data & 1) == 1) { diff --git a/source/client/renderer/TileRenderer.hpp b/source/client/renderer/TileRenderer.hpp index e9699a611..f76dcc33f 100644 --- a/source/client/renderer/TileRenderer.hpp +++ b/source/client/renderer/TileRenderer.hpp @@ -20,7 +20,7 @@ class TileRenderer TileRenderer(); TileRenderer(LevelSource*); float getWaterHeight(const TilePos& pos, const Material*); - void renderTile(Tile*, int data, float bright = 1.0f, bool preshade = false); + void renderTile(Tile*, TileData data, float bright = 1.0f, bool preshade = false); // TODO @@ -34,7 +34,7 @@ class TileRenderer void renderNorth(Tile*, const Vec3& pos, int texture); void renderFaceDown(Tile*, const Vec3& pos, int texture); void renderFaceUp(Tile*, const Vec3& pos, int texture); - void tesselateCrossTexture(Tile* tile, int data, const Vec3& pos); + void tesselateCrossTexture(Tile* tile, TileData data, const Vec3& pos); void tesselateTorch(Tile*, const Vec3& pos, float a, float b); bool tesselateBlockInWorldWithAmbienceOcclusion(Tile*, const TilePos& pos, float r, float g, float b); diff --git a/source/common/Utils.hpp b/source/common/Utils.hpp index 5b399ecfc..f5a45e7a5 100644 --- a/source/common/Utils.hpp +++ b/source/common/Utils.hpp @@ -560,7 +560,10 @@ enum eRenderLayer }; typedef uint8_t TileID; -// TODO: "FullTile" struct with TileID and auxvalue? +// @TODO: Rename this to "TileTypeId" +// Rename "Tile" to "TileType" +// Create "Tile" class containing TileTypeId, and TileData +typedef uint8_t TileData; /*struct Pos { diff --git a/source/network/Packet.hpp b/source/network/Packet.hpp index eb1e3fbe0..2169b8ec5 100644 --- a/source/network/Packet.hpp +++ b/source/network/Packet.hpp @@ -291,17 +291,17 @@ class PlaceBlockPacket : public Packet PlaceBlockPacket() { m_entityId = 0; - m_tileId = TILE_AIR; + m_tileTypeId = TILE_AIR; m_face = 0; - m_auxValue = 0; + m_data = 0; } - PlaceBlockPacket(int entityId, const TilePos& pos, TileID tileId, Facing::Name face, uint8_t auxValue) + PlaceBlockPacket(int entityId, const TilePos& pos, TileID tileTypeId, Facing::Name face, TileData data) { m_entityId = entityId; m_pos = pos; - m_tileId = tileId; + m_tileTypeId = tileTypeId; m_face = face; - m_auxValue = auxValue; + m_data = data; } void handle(const RakNet::RakNetGUID&, NetEventCallback* pCallback) override; @@ -310,9 +310,9 @@ class PlaceBlockPacket : public Packet public: int m_entityId; TilePos m_pos; - TileID m_tileId; + TileID m_tileTypeId; uint8_t m_face; - uint8_t m_auxValue; + TileData m_data; }; class RemoveBlockPacket : public Packet @@ -340,8 +340,8 @@ class UpdateBlockPacket : public Packet void read(RakNet::BitStream*) override; public: TilePos m_pos; - TileID m_tile; - uint8_t m_data; + TileID m_tileTypeId; + TileData m_data; }; class RequestChunkPacket : public Packet diff --git a/source/network/ServerSideNetworkHandler.cpp b/source/network/ServerSideNetworkHandler.cpp index d5dd7d20f..705291d63 100644 --- a/source/network/ServerSideNetworkHandler.cpp +++ b/source/network/ServerSideNetworkHandler.cpp @@ -249,17 +249,17 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, PlaceBlock pMob->swing(); - TileID tileId = packet->m_tileId; + TileID tileId = packet->m_tileTypeId; Facing::Name face = (Facing::Name)packet->m_face; TilePos pos = packet->m_pos; - uint8_t auxValue = packet->m_auxValue; + TileData data = packet->m_data; printf_ignorable("PlaceBlockPacket: %d", tileId); if (!m_pLevel->mayPlace(tileId, pos, true)) return; - if (m_pLevel->setTileAndData(pos, tileId, auxValue)) + if (m_pLevel->setTileAndData(pos, tileId, data)) { Tile* pTile = Tile::tiles[tileId]; pTile->setPlacedOnFace(m_pLevel, pos, face); @@ -368,13 +368,9 @@ void ServerSideNetworkHandler::tileBrightnessChanged(const TilePos& pos) void ServerSideNetworkHandler::tileChanged(const TilePos& pos) { UpdateBlockPacket ubp; - - int tile = m_pLevel->getTile(pos); - int data = m_pLevel->getData(pos); - ubp.m_pos = pos; - ubp.m_tile = uint8_t(tile); - ubp.m_data = uint8_t(data); + ubp.m_tileTypeId = m_pLevel->getTile(pos); + ubp.m_data = m_pLevel->getData(pos); RakNet::BitStream bs; ubp.write(&bs); diff --git a/source/network/packets/ChunkDataPacket.cpp b/source/network/packets/ChunkDataPacket.cpp index 0c0834cde..9decfc371 100644 --- a/source/network/packets/ChunkDataPacket.cpp +++ b/source/network/packets/ChunkDataPacket.cpp @@ -38,8 +38,8 @@ void ChunkDataPacket::write(RakNet::BitStream* bs) int idx = ((i & 0xF) << 11) | ((i >> 4) << 7) + (y * 16); //write the tile data - m_data.Write((const char*) &m_pChunk->m_pBlockData[idx], 16 * sizeof(TileID)); - m_data.Write((const char*) &m_pChunk->m_tileData [idx >> 1], 8); + m_data.Write((const char*) &m_pChunk->m_pBlockData[idx], 16 * sizeof(TileID)); + m_data.Write((const char*) &m_pChunk->m_tileData.m_data[idx >> 1], 8); } } } diff --git a/source/network/packets/PlaceBlockPacket.cpp b/source/network/packets/PlaceBlockPacket.cpp index dfda22d45..136516ade 100644 --- a/source/network/packets/PlaceBlockPacket.cpp +++ b/source/network/packets/PlaceBlockPacket.cpp @@ -24,9 +24,9 @@ void PlaceBlockPacket::write(RakNet::BitStream* bs) bs->Write(m_pos.y); bs->Write(m_face); - bs->Write(m_tileId); + bs->Write(m_tileTypeId); #if NETWORK_PROTOCOL_VERSION >= 3 - bs->Write(m_auxValue); + bs->Write(m_data); #endif } @@ -42,8 +42,8 @@ void PlaceBlockPacket::read(RakNet::BitStream* bs) m_pos.y = y; bs->Read(m_face); - bs->Read(m_tileId); + bs->Read(m_tileTypeId); #if NETWORK_PROTOCOL_VERSION >= 3 - bs->Read(m_auxValue); + bs->Read(m_data); #endif } diff --git a/source/network/packets/UpdateBlockPacket.cpp b/source/network/packets/UpdateBlockPacket.cpp index 69358493d..8b815e3b0 100644 --- a/source/network/packets/UpdateBlockPacket.cpp +++ b/source/network/packets/UpdateBlockPacket.cpp @@ -19,7 +19,7 @@ void UpdateBlockPacket::write(RakNet::BitStream* bs) bs->Write(m_pos.x); bs->Write(m_pos.z); bs->Write(m_pos.y); - bs->Write(m_tile); + bs->Write(m_tileTypeId); bs->Write(m_data); } @@ -30,6 +30,6 @@ void UpdateBlockPacket::read(RakNet::BitStream* bs) uint8_t y; bs->Read(y); m_pos.y = y; - bs->Read(m_tile); + bs->Read(m_tileTypeId); bs->Read(m_data); } diff --git a/source/world/entity/Arrow.cpp b/source/world/entity/Arrow.cpp index eb89eafd6..73bba0311 100644 --- a/source/world/entity/Arrow.cpp +++ b/source/world/entity/Arrow.cpp @@ -235,7 +235,7 @@ void Arrow::tick() void Arrow::playerTouch(Player* pPlayer) { - if (!m_pLevel->m_bIsOnline) + if (!m_pLevel->m_bIsClientSide) { // had m_owner == pPlayer, but this logic breaks when loaded from a save, and m_owner is null if (m_bInGround && m_bIsPlayerOwned && m_shakeTime <= 0) diff --git a/source/world/entity/Chicken.cpp b/source/world/entity/Chicken.cpp index 9d35ddd07..d81a4b586 100644 --- a/source/world/entity/Chicken.cpp +++ b/source/world/entity/Chicken.cpp @@ -43,7 +43,7 @@ void Chicken::aiStep() m_vel.y *= 0.6f; m_flap += m_flapping * 2.0f; - if (!m_pLevel->m_bIsOnline && isAlive() && !isBaby() /* && !isChickenJockey()*/ && --m_eggTime <= 0) + if (!m_pLevel->m_bIsClientSide && isAlive() && !isBaby() /* && !isChickenJockey()*/ && --m_eggTime <= 0) { m_pLevel->playSound(this, "mob.chickenplop", 1.0f, (m_random.nextFloat() - m_random.nextFloat()) * 0.2f + 1.0f); spawnAtLocation(Item::egg->m_itemID, 1); diff --git a/source/world/entity/Creeper.cpp b/source/world/entity/Creeper.cpp index c8f7f74ca..53d3f47b2 100644 --- a/source/world/entity/Creeper.cpp +++ b/source/world/entity/Creeper.cpp @@ -19,7 +19,7 @@ void Creeper::_defineEntityData() void Creeper::tick() { m_oldSwell = m_swell; - if (m_pLevel->m_bIsOnline) + if (m_pLevel->m_bIsClientSide) { int swellDir = getSwellDir(); if (swellDir > 0 && m_swell == 0) diff --git a/source/world/entity/Entity.cpp b/source/world/entity/Entity.cpp index 1bfd7b4d6..09f67e494 100644 --- a/source/world/entity/Entity.cpp +++ b/source/world/entity/Entity.cpp @@ -493,14 +493,14 @@ void Entity::baseTick() m_fireTicks = 0; m_distanceFallen = 0; - if (m_pLevel->m_bIsOnline) + if (m_pLevel->m_bIsClientSide) goto label_4; } else { m_bWasInWater = false; - if (m_pLevel->m_bIsOnline) + if (m_pLevel->m_bIsClientSide) { label_4: m_fireTicks = 0; @@ -602,7 +602,7 @@ bool Entity::isUnderLiquid(Material* pMtl) const if (!pTile || pTile->m_pMaterial != pMtl) return false; - int data = m_pLevel->getData(tilePos); + TileData data = m_pLevel->getData(tilePos); int level = data <= 7 ? data + 1 : 1; return float(tilePos.y) < float(tilePos.y + 1) - (float(level) / 9.0f - 0.11111f); diff --git a/source/world/entity/FallingTile.cpp b/source/world/entity/FallingTile.cpp index 632a9bc33..86c5cc98b 100644 --- a/source/world/entity/FallingTile.cpp +++ b/source/world/entity/FallingTile.cpp @@ -65,7 +65,7 @@ void FallingTile::tick() if (!m_bOnGround) { - if (field_E0 > 100 && !m_pLevel->m_bIsOnline) + if (field_E0 > 100 && !m_pLevel->m_bIsClientSide) remove(); return; diff --git a/source/world/entity/Mob.cpp b/source/world/entity/Mob.cpp index 4115bc666..63eb8da1e 100644 --- a/source/world/entity/Mob.cpp +++ b/source/world/entity/Mob.cpp @@ -237,7 +237,7 @@ void Mob::baseTick() hurt(nullptr, 1); // Java - /*if (m_bFireImmune || m_pLevel->m_bIsOnline) + /*if (m_bFireImmune || m_pLevel->m_bIsClientSide) { m_fireTicks = 0; }*/ @@ -316,7 +316,7 @@ bool Mob::isAlive() const bool Mob::hurt(Entity *pAttacker, int damage) { - if (m_pLevel->m_bIsOnline) + if (m_pLevel->m_bIsClientSide) return false; m_noActionTime = 0; @@ -621,7 +621,7 @@ void Mob::die(Entity* pCulprit) field_B69 = true; - if (!m_pLevel->m_bIsOnline) + if (!m_pLevel->m_bIsClientSide) dropDeathLoot(); } diff --git a/source/world/entity/Sheep.cpp b/source/world/entity/Sheep.cpp index 5906c9d75..4f933e705 100644 --- a/source/world/entity/Sheep.cpp +++ b/source/world/entity/Sheep.cpp @@ -42,7 +42,7 @@ void Sheep::_defineEntityData() bool Sheep::hurt(Entity* pEnt, int damage) { - if (!m_pLevel->m_bIsOnline && !isSheared() && (pEnt != nullptr && pEnt->getDescriptor().hasCategory(EntityCategories::MOB))) + if (!m_pLevel->m_bIsClientSide && !isSheared() && (pEnt != nullptr && pEnt->getDescriptor().hasCategory(EntityCategories::MOB))) { setSheared(true); int var3 = 1 + m_random.nextInt(3); diff --git a/source/world/item/CameraItem.cpp b/source/world/item/CameraItem.cpp index 345ec5ff8..157e4c400 100644 --- a/source/world/item/CameraItem.cpp +++ b/source/world/item/CameraItem.cpp @@ -22,7 +22,7 @@ ItemInstance* CameraItem::use(ItemInstance* inst, Level* level, Player* player) { #ifndef ORIGINAL_CODE // prevent players from using this in multiplayer, to prevent a desync of entity IDs - if (level->m_bIsOnline) + if (level->m_bIsClientSide) return inst; #endif diff --git a/source/world/level/Level.cpp b/source/world/level/Level.cpp index b44a34a6b..6c8fdb5c5 100644 --- a/source/world/level/Level.cpp +++ b/source/world/level/Level.cpp @@ -17,7 +17,7 @@ Level::Level(LevelStorage* pStor, const std::string& name, int32_t seed, int storageVersion, Dimension *pDimension) { m_bInstantTicking = false; - m_bIsOnline = false; + m_bIsClientSide = false; m_bPostProcessing = false; m_skyDarken = 0; field_30 = 0; @@ -151,7 +151,7 @@ TileID Level::getTile(const TilePos& pos) const return pChunk->getTile(pos); } -int Level::getData(const TilePos& pos) const +TileData Level::getData(const TilePos& pos) const { //@BUG: checking x >= C_MAX_X, but not z >= C_MAX_Z. if (pos.x < C_MIN_X || pos.z < C_MIN_Z || pos.x >= C_MAX_X || pos.z > C_MAX_Z || pos.y < C_MIN_Y || pos.y >= C_MAX_Y) @@ -227,10 +227,10 @@ int Level::getRawBrightness(const TilePos& pos, bool b) const void Level::swap(const TilePos& pos1, const TilePos& pos2) { - int tile1 = getTile(pos1); - int data1 = getData(pos1); - int tile2 = getTile(pos2); - int data2 = getData(pos2); + TileID tile1 = getTile(pos1); + TileData data1 = getData(pos1); + TileID tile2 = getTile(pos2); + TileData data2 = getData(pos2); setTileAndDataNoUpdate(pos1, tile2, data2); setTileAndDataNoUpdate(pos2, tile1, data1); @@ -553,17 +553,9 @@ bool Level::isSkyLit(const TilePos& pos) const return getChunk(pos)->isSkyLit(pos); } -bool Level::setTileAndDataNoUpdate(const TilePos& pos, TileID tile, int data) +bool Level::setTileAndDataNoUpdate(const TilePos& pos, TileID tile, TileData data) { - //@BUG: checking x >= C_MAX_X, but not z >= C_MAX_Z. - if (pos.x < C_MIN_X || pos.z < C_MIN_Z || pos.x >= C_MAX_X || pos.z > C_MAX_Z || pos.y < C_MIN_Y || pos.y >= C_MAX_Y) - // there's nothing out there! - return false; - - if (!hasChunk(pos)) - return false; - - return getChunk(pos)->setTileAndData(pos, tile, data); + return setTileAndData(pos, tile, data, TileChange::UPDATE_SILENT); } int Level::getHeightmap(const TilePos& pos) @@ -591,7 +583,7 @@ void Level::lightColumnChanged(int x, int z, int y1, int y2) setTilesDirty(TilePos(x, y1, z), TilePos(x, y2, z)); } -bool Level::setDataNoUpdate(const TilePos& pos, int data) +bool Level::setDataNoUpdate(const TilePos& pos, TileData data) { //@BUG: checking x >= C_MAX_X, but not z >= C_MAX_Z. if (pos.x < C_MIN_X || pos.z < C_MIN_Z || pos.x >= C_MAX_X || pos.z > C_MAX_Z || pos.y < C_MIN_Y || pos.y >= C_MAX_Y) @@ -611,15 +603,7 @@ bool Level::setDataNoUpdate(const TilePos& pos, int data) bool Level::setTileNoUpdate(const TilePos& pos, TileID tile) { - //@BUG: checking x >= C_MAX_X, but not z >= C_MAX_Z. - if (pos.x < C_MIN_X || pos.z < C_MIN_Z || pos.x >= C_MAX_X || pos.z > C_MAX_Z || pos.y < C_MIN_Y || pos.y >= C_MAX_Y) - // there's nothing out there! - return false; - - if (!hasChunk(pos)) - return false; - - return getChunk(pos)->setTile(pos, tile); + return setTileAndDataNoUpdate(pos, tile, 0); } void Level::sendTileUpdated(const TilePos& pos) @@ -633,7 +617,7 @@ void Level::sendTileUpdated(const TilePos& pos) void Level::neighborChanged(const TilePos& pos, TileID tile) { - if (field_30 || m_bIsOnline) return; + if (field_30 || m_bIsClientSide) return; Tile* pTile = Tile::tiles[getTile(pos)]; if (pTile) @@ -652,38 +636,96 @@ void Level::updateNeighborsAt(const TilePos& pos, TileID tile) void Level::tileUpdated(const TilePos& pos, TileID tile) { - sendTileUpdated(pos); + //sendTileUpdated(pos); // not in 0.7.0 updateNeighborsAt(pos, tile); } -bool Level::setTileAndData(const TilePos& pos, TileID tile, int data) +bool Level::setTileAndData(const TilePos& pos, TileID tile, TileData data, TileChange::UpdateFlags updateFlags) { - if (setTileAndDataNoUpdate(pos, tile, data)) + //@BUG: checking x >= C_MAX_X, but not z >= C_MAX_Z. + if (pos.x < C_MIN_X || pos.z < C_MIN_Z || pos.x >= C_MAX_X || pos.z > C_MAX_Z || pos.y < C_MIN_Y || pos.y >= C_MAX_Y) + // there's nothing out there! + return false; + + if (!hasChunk(pos)) + return false; + + LevelChunk* pChunk = getChunk(pos); + + TileChange change(updateFlags); + + TileID oldTile = TILE_AIR; + if (change.isUpdateNeighbors()) + oldTile = pChunk->getTile(pos); + + bool result = pChunk->setTileAndData(pos, tile, data); + if (result) + { + if (change.isUpdateListeners() && (!m_bIsClientSide || !change.isUpdateSilent())) + { + // Send update to level listeners + sendTileUpdated(pos); + } + if (!m_bIsClientSide && change.isUpdateNeighbors()) + { + // Update neighbors + tileUpdated(pos, oldTile); + } + } + + return result; + + /*if (setTileAndDataNoUpdate(pos, tile, data)) { tileUpdated(pos, tile); return true; } - return false; + return false;*/ } -bool Level::setData(const TilePos& pos, int data) +bool Level::setData(const TilePos& pos, TileData data, TileChange::UpdateFlags updateFlags) { - if (setDataNoUpdate(pos, data)) + //@BUG: checking x >= C_MAX_X, but not z >= C_MAX_Z. + if (pos.x < C_MIN_X || pos.z < C_MIN_Z || pos.x >= C_MAX_X || pos.z > C_MAX_Z || pos.y < C_MIN_Y || pos.y >= C_MAX_Y) + // there's nothing out there! + return false; + + LevelChunk* pChunk = getChunk(pos); + if (!pChunk) + return false; + + TileChange change(updateFlags); + + bool result = pChunk->setData(pos, data); + if (result) + { + TileID tileId = pChunk->getTile(pos); + + if (change.isUpdateListeners() && (!m_bIsClientSide || !change.isUpdateSilent())) + { + // Send update to level listeners + sendTileUpdated(pos); + } + if (!m_bIsClientSide && change.isUpdateNeighbors()) + { + // Update neighbors + tileUpdated(pos, tileId); + } + } + + return result; + + /*if (setDataNoUpdate(pos, data)) { tileUpdated(pos, getTile(pos)); return true; } - return false; + return false;*/ } -bool Level::setTile(const TilePos& pos, TileID tile) +bool Level::setTile(const TilePos& pos, TileID tile, TileChange::UpdateFlags updateFlags) { - if (setTileNoUpdate(pos, tile)) - { - tileUpdated(pos, tile); - return true; - } - return false; + return setTileAndData(pos, tile, 0, updateFlags); } void Level::setTilesDirty(const TilePos& min, const TilePos& max) @@ -862,7 +904,7 @@ bool Level::containsLiquid(const AABB& aabb, const Material* pMtl) if (!Tile::tiles[tileID] || Tile::tiles[tileID]->m_pMaterial != pMtl) continue; - int data = getData(pos); + TileData data = getData(pos); float height; if (data <= 7) @@ -921,7 +963,7 @@ bool Level::checkAndHandleWater(const AABB& aabb, const Material* pMtl, Entity* if (!pTile || pTile->m_pMaterial != pMtl) continue; - int data = getData(pos); + TileData data = getData(pos); int level = data <= 7 ? data + 1 : 1; if (float(max.y) >= float(pos.y + 1) - float(level) / 9.0f) { @@ -1107,7 +1149,7 @@ bool Level::addEntity(Entity* pEnt) //removeEntity(pOldEnt); } - if (!pEnt->isPlayer() && m_bIsOnline) + if (!pEnt->isPlayer() && m_bIsClientSide) { LOG_W("Hey, why are you trying to add an non-player entity in a multiplayer world?"); } diff --git a/source/world/level/Level.hpp b/source/world/level/Level.hpp index 26e186c37..176e6f12d 100644 --- a/source/world/level/Level.hpp +++ b/source/world/level/Level.hpp @@ -17,6 +17,7 @@ #include "world/tile/Tile.hpp" #include "world/entity/Entity.hpp" #include "world/entity/LocalPlayer.hpp" +#include "world/level/TileChange.hpp" #include "world/level/levelgen/chunk/LevelChunk.hpp" #include "world/level/levelgen/chunk/ChunkSource.hpp" #include "world/level/storage/LevelStorageSource.hpp" @@ -49,7 +50,7 @@ class Level : public LevelSource // TODO TileID getTile(const TilePos& pos) const override; float getBrightness(const TilePos& pos) const override; - int getData(const TilePos& pos) const override; + TileData getData(const TilePos& pos) const override; Material* getMaterial(const TilePos& pos) const override; bool isSolidTile(const TilePos& pos) const override; @@ -82,12 +83,12 @@ class Level : public LevelSource void updateLight(const LightLayer&, const TilePos& tilePos1, const TilePos& tilePos2); void updateLight(const LightLayer&, const TilePos& tilePos1, const TilePos& tilePos2, bool); void updateLightIfOtherThan(const LightLayer&, const TilePos& pos, int); - bool setTileAndDataNoUpdate(const TilePos& pos, TileID tile, int data); + bool setTileAndDataNoUpdate(const TilePos& pos, TileID tile, TileData data); bool setTileNoUpdate(const TilePos& pos, TileID tile); - bool setDataNoUpdate(const TilePos& pos, int data); - bool setTileAndData(const TilePos& pos, TileID tile, int data); - bool setTile(const TilePos& pos, TileID tile); - bool setData(const TilePos& pos, int data); + bool setDataNoUpdate(const TilePos& pos, TileData data); + bool setTileAndData(const TilePos& pos, TileID tile, TileData data, TileChange::UpdateFlags updateFlags = TileChange::UPDATE_ALL); + bool setTile(const TilePos& pos, TileID tile, TileChange::UpdateFlags updateFlags = TileChange::UPDATE_ALL); + bool setData(const TilePos& pos, TileData data, TileChange::UpdateFlags updateFlags = TileChange::UPDATE_ALL); void sendTileUpdated(const TilePos& pos); void tileUpdated(const TilePos& pos, TileID tile); void updateNeighborsAt(const TilePos& pos, TileID tile); @@ -189,7 +190,7 @@ class Level : public LevelSource public: AABBVector m_aabbs; bool m_bInstantTicking; - bool m_bIsOnline; // if the level is controlled externally by a server. + bool m_bIsClientSide; // if the level is controlled externally by a server. bool m_bPostProcessing; EntityVector m_entities; std::vector m_players; diff --git a/source/world/level/Region.cpp b/source/world/level/Region.cpp index 83c0ff3bc..e38196cb7 100644 --- a/source/world/level/Region.cpp +++ b/source/world/level/Region.cpp @@ -76,7 +76,7 @@ float Region::getBrightness(const TilePos& pos) const return m_pLevel->m_pDimension->field_10[getRawBrightness(pos)]; } -int Region::getData(const TilePos& pos) const +TileData Region::getData(const TilePos& pos) const { if (pos.y < C_MIN_Y || pos.y >= C_MAX_Y) return 0; diff --git a/source/world/level/Region.hpp b/source/world/level/Region.hpp index 03ea085fc..592a42536 100644 --- a/source/world/level/Region.hpp +++ b/source/world/level/Region.hpp @@ -17,7 +17,7 @@ class Region : public LevelSource int getRawBrightness(const TilePos& pos, bool b) const; int getRawBrightness(const TilePos& pos) const; float getBrightness(const TilePos& pos) const override; - int getData(const TilePos& pos) const override; + TileData getData(const TilePos& pos) const override; Material* getMaterial(const TilePos& pos) const override; bool isSolidTile(const TilePos& pos) const override; BiomeSource* getBiomeSource() const override; diff --git a/source/world/level/TileChange.hpp b/source/world/level/TileChange.hpp new file mode 100644 index 000000000..5fe61f41a --- /dev/null +++ b/source/world/level/TileChange.hpp @@ -0,0 +1,38 @@ +#pragma once + +class TileChange +{ +public: + enum UpdateFlags + { + UPDATE_NONE = 0 << 0, // 0 0 0 // + + UPDATE_NEIGHBORS = 1 << 0, // 0 0 1 // + UPDATE_LISTENERS = 1 << 1, // 0 1 0 // + UPDATE_SILENT = 1 << 2, // 1 0 0 // + + UPDATE_ALL = UPDATE_NEIGHBORS | UPDATE_LISTENERS, // the default behavior + }; + +public: + TileChange(UpdateFlags updateFlags = UPDATE_NONE) : m_updateFlags(updateFlags) {} + + bool isUpdateNeighbors() const { + return (m_updateFlags & UPDATE_NEIGHBORS) != UPDATE_NONE; + } + + bool isUpdateListeners() const { + return (m_updateFlags & UPDATE_LISTENERS) != UPDATE_NONE; + } + + bool isUpdateSilent() const { + return (m_updateFlags & UPDATE_SILENT) != UPDATE_NONE; + } + + bool isUpdateAll() const { + return (m_updateFlags & UPDATE_ALL) != UPDATE_NONE; + } + +private: + UpdateFlags m_updateFlags; +}; \ No newline at end of file diff --git a/source/world/level/levelgen/chunk/DataLayer.cpp b/source/world/level/levelgen/chunk/DataLayer.cpp new file mode 100644 index 000000000..49b0de14b --- /dev/null +++ b/source/world/level/levelgen/chunk/DataLayer.cpp @@ -0,0 +1,68 @@ +#include +#include + +#include "DataLayer.hpp" + +#include "compat/LegacyCPP.hpp" + +DataLayer::DataLayer() +{ + m_size = 0; + m_data = nullptr; +} + +DataLayer::DataLayer(unsigned int size) +{ + m_size = size; + m_data = new uint8_t[m_size]; + memset(m_data, 0, m_size); +} + +uint8_t DataLayer::get(const ChunkTilePos& pos) +{ + int index = pos.y | (pos.x << 11); + uint8_t data = m_data[(index | (pos.z << 7)) >> 1]; + + if ((index & 1) != 0) + return data >> 4; + return data & 0xF; +} + +void DataLayer::set(const ChunkTilePos& pos, uint8_t data) +{ + int index1 = pos.y | (pos.x << 11) | (pos.z << 7); + unsigned int index2 = index1 >> 1; + uint8_t v7 = data; + bool v8 = (index1 & 1) == 0; + uint8_t v9 = m_data[index2]; + uint8_t v10; + if (v8) + { + v7 = data & 0xF; + v10 = v9 & 0xF0; + } + else + { + v10 = v9 & 0xF; + } + uint8_t v11; + if (v8) + v11 = v7 | v10; + else + v11 = v10 | (16 * v7); + m_data[index2] = v11; + + /* + + data &= 0xF; + + int index = pos.y | (pos.x << 11) | (pos.z << 7); + + uint8_t& xdata = m_data[index >> 1]; + if (index & 1) + xdata = (xdata & 0x0F) | (data << 4); + else + xdata = (xdata & 0xF0) | (data); + + */ +} \ No newline at end of file diff --git a/source/world/level/levelgen/chunk/DataLayer.hpp b/source/world/level/levelgen/chunk/DataLayer.hpp new file mode 100644 index 000000000..ba2ecb5fd --- /dev/null +++ b/source/world/level/levelgen/chunk/DataLayer.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include + +#include "world/level/levelgen/chunk/ChunkTilePos.hpp" + +class DataLayer +{ +public: + DataLayer(); + DataLayer(unsigned int size); + +public: + uint8_t get(const ChunkTilePos& pos); + void set(const ChunkTilePos& pos, uint8_t data); + +public: + uint8_t* m_data; + unsigned int m_size; +}; \ No newline at end of file diff --git a/source/world/level/levelgen/chunk/EmptyLevelChunk.cpp b/source/world/level/levelgen/chunk/EmptyLevelChunk.cpp index 150da5c09..b597b1065 100644 --- a/source/world/level/levelgen/chunk/EmptyLevelChunk.cpp +++ b/source/world/level/levelgen/chunk/EmptyLevelChunk.cpp @@ -86,19 +86,19 @@ bool EmptyLevelChunk::setTile(const ChunkTilePos& pos, TileID tile) return true; } -bool EmptyLevelChunk::setTileAndData(const ChunkTilePos& pos, TileID tile, int data) +bool EmptyLevelChunk::setTileAndData(const ChunkTilePos& pos, TileID tile, TileData data) { return true; } -int EmptyLevelChunk::getData(const ChunkTilePos& pos) +TileData EmptyLevelChunk::getData(const ChunkTilePos& pos) { return 0; } -void EmptyLevelChunk::setData(const ChunkTilePos& pos, int data) +bool EmptyLevelChunk::setData(const ChunkTilePos& pos, TileData data) { - + return false; } void EmptyLevelChunk::recalcHeight(const ChunkTilePos& pos) diff --git a/source/world/level/levelgen/chunk/EmptyLevelChunk.hpp b/source/world/level/levelgen/chunk/EmptyLevelChunk.hpp index b282844ff..1eb03d97d 100644 --- a/source/world/level/levelgen/chunk/EmptyLevelChunk.hpp +++ b/source/world/level/levelgen/chunk/EmptyLevelChunk.hpp @@ -24,9 +24,9 @@ class EmptyLevelChunk : public LevelChunk void markUnsaved() override; TileID getTile(const ChunkTilePos& pos) override; bool setTile(const ChunkTilePos& pos, TileID tile) override; - bool setTileAndData(const ChunkTilePos& pos, TileID tile, int data) override; - int getData(const ChunkTilePos& pos) override; - void setData(const ChunkTilePos& pos, int data) override; + bool setTileAndData(const ChunkTilePos& pos, TileID tile, TileData data) override; + TileData getData(const ChunkTilePos& pos) override; + bool setData(const ChunkTilePos& pos, TileData data) override; void recalcHeight(const ChunkTilePos& pos) override; bool isEmpty() override; }; \ No newline at end of file diff --git a/source/world/level/levelgen/chunk/LevelChunk.cpp b/source/world/level/levelgen/chunk/LevelChunk.cpp index 57196ef85..31e6d854d 100644 --- a/source/world/level/levelgen/chunk/LevelChunk.cpp +++ b/source/world/level/levelgen/chunk/LevelChunk.cpp @@ -1,7 +1,7 @@ /******************************************************************** Minecraft: Pocket Edition - Decompilation Project Copyright (C) 2023 iProgramInCpp - + The following code is licensed under the BSD 1 clause license. SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ @@ -13,12 +13,12 @@ bool LevelChunk::touchedSky = false; LevelChunk::~LevelChunk() { - SAFE_DELETE(m_lightBlk); - SAFE_DELETE(m_lightSky); - SAFE_DELETE(m_tileData); + SAFE_DELETE_ARRAY(m_lightBlk.m_data); + SAFE_DELETE_ARRAY(m_lightSky.m_data); + SAFE_DELETE_ARRAY(m_tileData.m_data); } -constexpr int MakeBlockDataIndex (const ChunkTilePos& pos) +constexpr int MakeBlockDataIndex(const ChunkTilePos& pos) { return (pos.x << 11) | (pos.z << 7) | pos.y; } @@ -38,12 +38,6 @@ void LevelChunk::_init() { field_4 = 0; m_bLoaded = false; - m_tileData = nullptr; - m_tileDataCnt = 0; - m_lightSky = nullptr; - m_lightSkyCnt = 0; - m_lightBlk = nullptr; - m_lightBlkCnt = 0; m_chunkPos = TilePos(0, 0, 0); field_234 = 0; m_bUnsaved = false; @@ -74,19 +68,11 @@ LevelChunk::LevelChunk(Level* pLevel, TileID* pData, const ChunkPos& pos) // I have not the slightest idea as to why... /*if (pData) {*/ - m_tileDataCnt = 0x4000; - field_4 = 0x8000; - m_tileData = new uint8_t[m_tileDataCnt]; - memset(m_tileData, 0, m_tileDataCnt); - + field_4 = 16 * 16 * 128; + m_tileData = DataLayer(16 * 16 * 128 / 2); //Space saving measure: Store 2 blocks' light field instead of only one block's, per byte. - m_lightSkyCnt = 16 * 16 * 128 / 2; - m_lightSky = new uint8_t[m_lightSkyCnt]; - memset(m_lightSky, 0, m_lightSkyCnt); - - m_lightBlkCnt = 16 * 16 * 128 / 2; - m_lightBlk = new uint8_t[m_lightBlkCnt]; - memset(m_lightBlk, 0, m_lightBlkCnt); + m_lightSky = DataLayer(16 * 16 * 128 / 2); + m_lightBlk = DataLayer(16 * 16 * 128 / 2); m_pBlockData = pData; //} @@ -161,13 +147,7 @@ void LevelChunk::recalcHeightmap() if (x4 <= 0) break; - int x = x3 + index1; - int index = x >> 1, offs = x & 1; - - if (offs) - m_lightSky[index] = (m_lightSky[index] & 0x0F) | (x4 << 4); // set the upper 4 bits to x4 - else - m_lightSky[index] = (m_lightSky[index] & 0xF0) | x4; // set the lower 4 bits to x4 + m_lightSky.set(ChunkTilePos(pos.x, x3, pos.z), x4); } } } @@ -256,22 +236,12 @@ int LevelChunk::getBrightness(const LightLayer& ll, const ChunkTilePos& pos) // why the hell is it doing it like that. if (&ll == &LightLayer::Sky) { - int bitIdx = MakeBlockDataIndex(pos); - int index = bitIdx >> 1, offs = bitIdx & 1; - if (offs) - return m_lightSky[index] >> 4; - else - return m_lightSky[index] & 0xF; + return m_lightSky.get(pos); } if (&ll == &LightLayer::Block) { - int bitIdx = MakeBlockDataIndex(pos); - int index = bitIdx >> 1, offs = bitIdx & 1; - if (offs) - return m_lightBlk[index] >> 4; - else - return m_lightBlk[index] & 0xF; + return m_lightBlk.get(pos); } return 0; @@ -283,24 +253,14 @@ void LevelChunk::setBrightness(const LightLayer& ll, const ChunkTilePos& pos, in // why the hell is it doing it like that. if (&ll == &LightLayer::Sky) { - int bitIdx = MakeBlockDataIndex(pos); - int index = bitIdx >> 1, offs = bitIdx & 1; - if (offs) - m_lightSky[index] = (m_lightSky[index] & 0x0F) | (brightness << 4); - else - m_lightSky[index] = (m_lightSky[index] & 0xF0) | (brightness & 0xF); + m_lightSky.set(pos, brightness); return; } if (&ll == &LightLayer::Block) { - int bitIdx = MakeBlockDataIndex(pos); - int index = bitIdx >> 1, offs = bitIdx & 1; - if (offs) - m_lightBlk[index] = (m_lightBlk[index] & 0x0F) | (brightness << 4); - else - m_lightBlk[index] = (m_lightBlk[index] & 0xF0) | (brightness & 0xF); + m_lightBlk.set(pos, brightness); return; } @@ -312,26 +272,17 @@ int LevelChunk::getRawBrightness(const ChunkTilePos& pos, int skySubtract) int bitIdx = MakeBlockDataIndex(pos); int index = bitIdx >> 1, offs = bitIdx & 1; - uint8_t bSky, bBlk; - if (offs) - bSky = m_lightSky[index] >> 4; - else - bSky = m_lightSky[index] & 0xF; - - if (m_lightSky) + uint8_t bSky = m_lightSky.get(pos); + if (bSky > 0) touchedSky = true; int br = bSky - skySubtract; - if (offs) - bBlk = m_lightBlk[index] >> 4; - else - bBlk = m_lightBlk[index] & 0xF; - + uint8_t bBlk = m_lightBlk.get(pos); // if it's smaller than 0 it'll probably sort itself out if (br < bBlk) br = bBlk; - + return br; } @@ -454,14 +405,7 @@ void LevelChunk::recalcHeight(const ChunkTilePos& pos) { for (int i = 0; i < x1 - hmap; i++) { - int bitIdx = index | (i + hmap); - int _idx = bitIdx >> 1; - int _off = bitIdx & 1; - - if (_off) - m_lightSky[_idx] &= 0xF0; - else - m_lightSky[_idx] &= 0x0F; + m_lightSky.set(ChunkTilePos(pos.x, i, pos.z), 0); } } } @@ -469,43 +413,27 @@ void LevelChunk::recalcHeight(const ChunkTilePos& pos) { for (int i = 0; i < hmap; i++) { - int v15 = (i | index) >> 1; - //int v16 = (i | index) <<31; - - if ((i | index) & 1) - { - m_lightSky[v15] = (m_lightSky[v15] & 0xF0) | 0x0F; + m_lightSky.set(ChunkTilePos(pos.x, i, pos.z), 15); } - else - { - m_lightSky[v15] = (m_lightSky[v15] & 0x0F) | 0xF0; } - } - } int x2 = x1; int x3 = 15; while (x3 > 0 && x2 > 0) { TileID tile = getTile(ChunkTilePos(pos.x, --x2, pos.z)); - int bitIdx = x2 | index; int x4 = Tile::lightBlock[tile]; if (!x4) x4 = 1; //@HUH: what is this? int x5 = x3 - x4; - int _idx = bitIdx >> 1; - int _off = (bitIdx & 1); x3 = x5; if (x3 < 0) x3 = 0; - if (_off) - m_lightSky[_idx] = (m_lightSky[_idx] & 0x0F) | ((x3) << 4); - else - m_lightSky[_idx] = (m_lightSky[_idx] & 0xF0) | x3; + m_lightSky.set(ChunkTilePos(pos.x, x2, pos.z), x3); } if (x2 > 0) @@ -564,7 +492,7 @@ void LevelChunk::markUnsaved() TileID LevelChunk::getTile(const ChunkTilePos& pos) { CheckPosition(pos); - + TileID tileId = m_pBlockData[MakeBlockDataIndex(pos)]; if (Tile::tiles[tileId]) return tileId; @@ -594,7 +522,7 @@ void LevelChunk::getEntities(Entity* pEntExclude, const AABB& aabb, std::vector< { Entity* ent = *it; if (ent == pEntExclude) continue; - + if (!aabb.intersect(ent->m_hitbox)) continue; out.push_back(ent); @@ -625,10 +553,7 @@ bool LevelChunk::setTile(const ChunkTilePos& pos, TileID tile) } // clear the data value of the block - if (index & 1) - m_tileData[index >> 1] &= 0xF; - else - m_tileData[index >> 1] &= 0xF0; + m_tileData.set(pos, 0); if (Tile::lightBlock[tile]) { @@ -646,7 +571,7 @@ bool LevelChunk::setTile(const ChunkTilePos& pos, TileID tile) lightGaps(pos); if (tile) { - if (!m_pLevel->m_bIsOnline) + if (!m_pLevel->m_bIsClientSide) Tile::tiles[tile]->onPlace(m_pLevel, tilePos); } @@ -656,13 +581,10 @@ bool LevelChunk::setTile(const ChunkTilePos& pos, TileID tile) return true; } -bool LevelChunk::setTileAndData(const ChunkTilePos& pos, TileID tile, int data) +bool LevelChunk::setTileAndData(const ChunkTilePos& pos, TileID tile, TileData data) { CheckPosition(pos); - assert((data & ~0xF) == 0); - data &= 0xF; - int index = MakeBlockDataIndex(pos); TileID oldTile = m_pBlockData[index]; @@ -686,10 +608,7 @@ bool LevelChunk::setTileAndData(const ChunkTilePos& pos, TileID tile, int data) } // update the data value of the block - if (index & 1) - m_tileData[index >> 1] = (m_tileData[index >> 1] & 0x0F) | (data << 4); - else - m_tileData[index >> 1] = (m_tileData[index >> 1] & 0xF0) | (data); + m_tileData.set(pos, data); if (m_pLevel->m_pDimension->field_E) { @@ -713,7 +632,7 @@ bool LevelChunk::setTileAndData(const ChunkTilePos& pos, TileID tile, int data) lightGaps(pos); if (tile) { - if (!m_pLevel->m_bIsOnline) + if (!m_pLevel->m_bIsClientSide) Tile::tiles[tile]->onPlace(m_pLevel, tilePos); } @@ -723,32 +642,21 @@ bool LevelChunk::setTileAndData(const ChunkTilePos& pos, TileID tile, int data) return true; } -int LevelChunk::getData(const ChunkTilePos& pos) +TileData LevelChunk::getData(const ChunkTilePos& pos) { CheckPosition(pos); - int index = MakeBlockDataIndex(pos); - - uint8_t data = m_tileData[index >> 1]; - if (index & 1) - return data >> 4; - return data & 0xF; + return m_tileData.get(pos); } -void LevelChunk::setData(const ChunkTilePos& pos, int data) +bool LevelChunk::setData(const ChunkTilePos& pos, TileData data) { CheckPosition(pos); - assert((data & ~0xF) == 0); - data &= 0xF; - - int index = MakeBlockDataIndex(pos); + if (m_tileData.get(pos) == data) + return false; - uint8_t& xdata = m_tileData[index >> 1]; - if (index & 1) - xdata = (xdata & 0x0F) | (data << 4); - else - xdata = (xdata & 0xF0) | (data); + m_tileData.set(pos, data); } // seems to set block data in 8192 block (4*16*128) chunks for some reason ? @@ -781,7 +689,7 @@ void LevelChunk::setBlocks(uint8_t* pData, int y) tilePos.y = 128; tilePos.x += 16; - m_pLevel->updateLight(LightLayer::Sky, tilePos, tilePos2); + m_pLevel->updateLight(LightLayer::Sky, tilePos, tilePos2); m_pLevel->updateLight(LightLayer::Block, tilePos, tilePos2); m_pLevel->setTilesDirty(tilePos, tilePos2); } @@ -827,7 +735,7 @@ int LevelChunk::setBlocksAndData(uint8_t* pData, int a3, int a4, int a5, int a6, for (int x3 = a5; x3 < a8; x3++) { - uint8_t* dst = &m_tileData[MakeBlockDataIndex(ChunkTilePos(x1, a4, x3)) >> 1]; + uint8_t* dst = &m_tileData.m_data[MakeBlockDataIndex(ChunkTilePos(x1, a4, x3)) >> 1]; memcpy(dst, src, x5); src += x5; a9 += x5; @@ -843,7 +751,7 @@ int LevelChunk::setBlocksAndData(uint8_t* pData, int a3, int a4, int a5, int a6, for (int x3 = a5; x3 < a8; x3++) { - uint8_t* dst = &m_lightBlk[MakeBlockDataIndex(ChunkTilePos(x1, a4, x3)) >> 1]; + uint8_t* dst = &m_lightBlk.m_data[MakeBlockDataIndex(ChunkTilePos(x1, a4, x3)) >> 1]; memcpy(dst, src, x5); src += x5; a9 += x5; @@ -859,7 +767,7 @@ int LevelChunk::setBlocksAndData(uint8_t* pData, int a3, int a4, int a5, int a6, for (int x3 = a5; x3 < a8; x3++) { - uint8_t* dst = &m_lightSky[MakeBlockDataIndex(ChunkTilePos(x1, a4, x3)) >> 1]; + uint8_t* dst = &m_lightSky.m_data[MakeBlockDataIndex(ChunkTilePos(x1, a4, x3)) >> 1]; memcpy(dst, src, x5); src += x5; a9 += x5; @@ -908,7 +816,7 @@ int LevelChunk::getBlocksAndData(uint8_t* pData, int a3, int a4, int a5, int a6, for (int x3 = a5; x3 < a8; x3++) { - uint8_t* src = &m_tileData[MakeBlockDataIndex(ChunkTilePos(x1, a4, x3)) >> 1]; + uint8_t* src = &m_tileData.m_data[MakeBlockDataIndex(ChunkTilePos(x1, a4, x3)) >> 1]; memcpy(dst, src, x5); dst += x5; a9 += x5; @@ -924,7 +832,7 @@ int LevelChunk::getBlocksAndData(uint8_t* pData, int a3, int a4, int a5, int a6, for (int x3 = a5; x3 < a8; x3++) { - uint8_t* src = &m_lightBlk[MakeBlockDataIndex(ChunkTilePos(x1, a4, x3)) >> 1]; + uint8_t* src = &m_lightBlk.m_data[MakeBlockDataIndex(ChunkTilePos(x1, a4, x3)) >> 1]; memcpy(dst, src, x5); dst += x5; a9 += x5; @@ -940,7 +848,7 @@ int LevelChunk::getBlocksAndData(uint8_t* pData, int a3, int a4, int a5, int a6, for (int x3 = a5; x3 < a8; x3++) { - uint8_t* src = &m_lightSky[MakeBlockDataIndex(ChunkTilePos(x1, a4, x3)) >> 1]; + uint8_t* src = &m_lightSky.m_data[MakeBlockDataIndex(ChunkTilePos(x1, a4, x3)) >> 1]; memcpy(dst, src, x5); dst += x5; a9 += x5; @@ -966,4 +874,4 @@ Random LevelChunk::getRandom(int32_t l) bool LevelChunk::isEmpty() { return false; -} +} \ No newline at end of file diff --git a/source/world/level/levelgen/chunk/LevelChunk.hpp b/source/world/level/levelgen/chunk/LevelChunk.hpp index a40622abd..1e4b9e8ed 100644 --- a/source/world/level/levelgen/chunk/LevelChunk.hpp +++ b/source/world/level/levelgen/chunk/LevelChunk.hpp @@ -11,11 +11,11 @@ #include #include #include -#include "common/Utils.hpp" #include "common/Random.hpp" #include "client/renderer/LightLayer.hpp" #include "world/level/levelgen/chunk/ChunkPos.hpp" #include "world/level/levelgen/chunk/ChunkTilePos.hpp" +#include "world/level/levelgen/chunk/DataLayer.hpp" class Level; class AABB; @@ -61,9 +61,9 @@ class LevelChunk virtual void getEntities(Entity* pEntExclude, const AABB&, std::vector& out); virtual TileID getTile(const ChunkTilePos& pos); virtual bool setTile(const ChunkTilePos& pos, TileID tile); - virtual bool setTileAndData(const ChunkTilePos& pos, TileID tile, int data); - virtual int getData(const ChunkTilePos& pos); - virtual void setData(const ChunkTilePos& pos, int data); + virtual bool setTileAndData(const ChunkTilePos& pos, TileID tile, TileData data); + virtual TileData getData(const ChunkTilePos& pos); + virtual bool setData(const ChunkTilePos& pos, TileData data); virtual void setBlocks(uint8_t* pData, int y); virtual int getBlocksAndData(uint8_t* pData, int, int, int, int, int, int, int); virtual int setBlocksAndData(uint8_t* pData, int, int, int, int, int, int, int); @@ -76,16 +76,12 @@ class LevelChunk static bool touchedSky; public: - int field_4; bool m_bLoaded; Level* m_pLevel; - uint8_t* m_tileData; - int m_tileDataCnt; - uint8_t* m_lightSky; - int m_lightSkyCnt; - uint8_t* m_lightBlk; - int m_lightBlkCnt; + DataLayer m_tileData; + DataLayer m_lightSky; + DataLayer m_lightBlk; uint8_t m_heightMap[256]; uint8_t m_updateMap[256]; int field_228; diff --git a/source/world/level/levelgen/chunk/RandomLevelSource.cpp b/source/world/level/levelgen/chunk/RandomLevelSource.cpp index 283e5789d..9bf7a832b 100644 --- a/source/world/level/levelgen/chunk/RandomLevelSource.cpp +++ b/source/world/level/levelgen/chunk/RandomLevelSource.cpp @@ -586,9 +586,10 @@ void RandomLevelSource::postProcess(ChunkSource* src, const ChunkPos& pos) for (int i = 0; i < vegetationCount; i++) { - int data = 1; + TileData data = 1; - if (pBiome == Biome::rainForest && m_random.nextInt(3) != 0) { + if (pBiome == Biome::rainForest && m_random.nextInt(3) != 0) + { data = 2; } TilePos o(m_random.nextInt(16), diff --git a/source/world/level/levelgen/feature/ClayFeature.cpp b/source/world/level/levelgen/feature/ClayFeature.cpp index c92f4766f..4b1faea33 100644 --- a/source/world/level/levelgen/feature/ClayFeature.cpp +++ b/source/world/level/levelgen/feature/ClayFeature.cpp @@ -9,7 +9,7 @@ #include "Feature.hpp" #include "world/level/Level.hpp" -ClayFeature::ClayFeature(int id, int count) +ClayFeature::ClayFeature(TileID id, int count) { m_ID = id; m_count = count; diff --git a/source/world/level/levelgen/feature/Feature.hpp b/source/world/level/levelgen/feature/Feature.hpp index 8372e8a8d..a4346d58e 100644 --- a/source/world/level/levelgen/feature/Feature.hpp +++ b/source/world/level/levelgen/feature/Feature.hpp @@ -48,42 +48,42 @@ class PineFeature : public Feature class FlowerFeature : public Feature { public: - FlowerFeature(int id); + FlowerFeature(TileID id); bool place(Level*, Random*, const TilePos& pos) override; private: - int m_ID; + TileID m_ID; }; class SpringFeature : public Feature { public: - SpringFeature(int id); + SpringFeature(TileID id); bool place(Level*, Random*, const TilePos& pos) override; private: - int m_ID; + TileID m_ID; }; class ClayFeature : public Feature { public: - ClayFeature(int id, int count); + ClayFeature(TileID id, int count); bool place(Level*, Random*, const TilePos& pos) override; private: - int m_ID; + TileID m_ID; int m_count; }; class OreFeature : public Feature { public: - OreFeature(int id, int count); + OreFeature(TileID id, int count); bool place(Level*, Random*, const TilePos& pos) override; private: - int m_ID; + TileID m_ID; int m_count; }; @@ -96,12 +96,12 @@ class ReedsFeature : public Feature class VegetationFeature : public Feature { public: - VegetationFeature(int id, int data, int count = 128); + VegetationFeature(TileID id, TileData data, int count = 128); bool place(Level*, Random*, const TilePos& pos) override; private: - int m_ID; - int m_data; + TileID m_ID; + TileData m_data; int m_count; }; diff --git a/source/world/level/levelgen/feature/FlowerFeature.cpp b/source/world/level/levelgen/feature/FlowerFeature.cpp index 4c7ea4977..9fa2cf1e3 100644 --- a/source/world/level/levelgen/feature/FlowerFeature.cpp +++ b/source/world/level/levelgen/feature/FlowerFeature.cpp @@ -9,7 +9,7 @@ #include "Feature.hpp" #include "world/level/Level.hpp" -FlowerFeature::FlowerFeature(int id) +FlowerFeature::FlowerFeature(TileID id) { m_ID = id; } diff --git a/source/world/level/levelgen/feature/OreFeature.cpp b/source/world/level/levelgen/feature/OreFeature.cpp index 8181de8b1..1b7ca2596 100644 --- a/source/world/level/levelgen/feature/OreFeature.cpp +++ b/source/world/level/levelgen/feature/OreFeature.cpp @@ -9,7 +9,7 @@ #include "Feature.hpp" #include "world/level/Level.hpp" -OreFeature::OreFeature(int id, int count) +OreFeature::OreFeature(TileID id, int count) { m_ID = id; m_count = count; diff --git a/source/world/level/levelgen/feature/SpringFeature.cpp b/source/world/level/levelgen/feature/SpringFeature.cpp index 5298181b0..40090e0d0 100644 --- a/source/world/level/levelgen/feature/SpringFeature.cpp +++ b/source/world/level/levelgen/feature/SpringFeature.cpp @@ -9,7 +9,7 @@ #include "Feature.hpp" #include "world/level/Level.hpp" -SpringFeature::SpringFeature(int id) +SpringFeature::SpringFeature(TileID id) { m_ID = id; } diff --git a/source/world/level/levelgen/feature/VegetationFeature.cpp b/source/world/level/levelgen/feature/VegetationFeature.cpp index 8316d4f7e..ee7480839 100644 --- a/source/world/level/levelgen/feature/VegetationFeature.cpp +++ b/source/world/level/levelgen/feature/VegetationFeature.cpp @@ -1,7 +1,7 @@ #include "Feature.hpp" #include "world/level/Level.hpp" -VegetationFeature::VegetationFeature(int id, int data, int count) +VegetationFeature::VegetationFeature(TileID id, TileData data, int count) { m_ID = id; m_data = data; diff --git a/source/world/level/storage/ExternalFileLevelStorage.cpp b/source/world/level/storage/ExternalFileLevelStorage.cpp index d995f1d6f..c8bf11df5 100644 --- a/source/world/level/storage/ExternalFileLevelStorage.cpp +++ b/source/world/level/storage/ExternalFileLevelStorage.cpp @@ -239,12 +239,12 @@ LevelChunk* ExternalFileLevelStorage::load(Level* level, const ChunkPos& pos) pBitStream->Read((char*)pData, 16 * 16 * 128 * sizeof(TileID)); LevelChunk* pChunk = new LevelChunk(level, pData, pos); - pBitStream->Read((char*)pChunk->m_tileData, 16 * 16 * 128 / 2); + pBitStream->Read((char*)pChunk->m_tileData.m_data, 16 * 16 * 128 / 2); if (m_storageVersion >= 1) { - pBitStream->Read((char*)pChunk->m_lightSky, 16 * 16 * 128 / 2); - pBitStream->Read((char*)pChunk->m_lightBlk, 16 * 16 * 128 / 2); + pBitStream->Read((char*)pChunk->m_lightSky.m_data, 16 * 16 * 128 / 2); + pBitStream->Read((char*)pChunk->m_lightBlk.m_data, 16 * 16 * 128 / 2); } pBitStream->Read((char*)pChunk->m_updateMap, sizeof pChunk->m_updateMap); @@ -336,13 +336,13 @@ void ExternalFileLevelStorage::save(Level* level, LevelChunk* chunk) } RakNet::BitStream bs; - bs.Write((const char*)chunk->m_pBlockData, 16 * 16 * 128 * sizeof(TileID)); - bs.Write((const char*)chunk->m_tileData, 16 * 16 * 128 / 2); + bs.Write((const char*)chunk->m_pBlockData, 16 * 16 * 128 * sizeof(TileID)); + bs.Write((const char*)chunk->m_tileData.m_data, chunk->m_tileData.m_size); if (m_pLevelData->getStorageVersion() >= 1) { - bs.Write((const char*)chunk->m_lightSky, 16 * 16 * 128 / 2); - bs.Write((const char*)chunk->m_lightBlk, 16 * 16 * 128 / 2); + bs.Write((const char*)chunk->m_lightSky.m_data, chunk->m_lightSky.m_size); + bs.Write((const char*)chunk->m_lightBlk.m_data, chunk->m_lightBlk.m_size); } bs.Write((const char*)chunk->m_updateMap, sizeof chunk->m_updateMap); diff --git a/source/world/level/storage/LevelSource.hpp b/source/world/level/storage/LevelSource.hpp index 7cab12c19..97cc026b2 100644 --- a/source/world/level/storage/LevelSource.hpp +++ b/source/world/level/storage/LevelSource.hpp @@ -18,7 +18,7 @@ class LevelSource virtual ~LevelSource(); virtual TileID getTile(const TilePos& pos) const = 0; virtual float getBrightness(const TilePos& pos) const = 0; - virtual int getData(const TilePos& pos) const = 0; + virtual TileData getData(const TilePos& pos) const = 0; virtual Material* getMaterial(const TilePos& pos) const = 0; virtual bool isSolidTile(const TilePos& pos) const = 0; virtual BiomeSource* getBiomeSource() const = 0; diff --git a/source/world/tile/BookshelfTile.cpp b/source/world/tile/BookshelfTile.cpp index 0742dc9a5..0f3b7a350 100644 --- a/source/world/tile/BookshelfTile.cpp +++ b/source/world/tile/BookshelfTile.cpp @@ -21,7 +21,7 @@ int BookshelfTile::getTexture(Facing::Name face) const return m_TextureFrame; } -int BookshelfTile::getResource(int data, Random* random) const +int BookshelfTile::getResource(TileData data, Random* random) const { return 0; // would be Book } diff --git a/source/world/tile/BookshelfTile.hpp b/source/world/tile/BookshelfTile.hpp index 4e3ca14fc..d3259340c 100644 --- a/source/world/tile/BookshelfTile.hpp +++ b/source/world/tile/BookshelfTile.hpp @@ -16,6 +16,6 @@ class BookshelfTile : public Tile BookshelfTile(int ID, int texture, Material*); int getTexture(Facing::Name face) const override; - int getResource(int data, Random* random) const override; + int getResource(TileData data, Random* random) const override; int getResourceCount(Random* random) const override; }; diff --git a/source/world/tile/Bush.cpp b/source/world/tile/Bush.cpp index 39b0a5be1..9c9a6e2f6 100644 --- a/source/world/tile/Bush.cpp +++ b/source/world/tile/Bush.cpp @@ -9,7 +9,7 @@ #include "Bush.hpp" #include "world/level/Level.hpp" -Bush::Bush(int id, int texture) : Tile(id, Material::plant) +Bush::Bush(TileID id, int texture) : Tile(id, Material::plant) { m_TextureFrame = texture; setTicking(true); diff --git a/source/world/tile/Bush.hpp b/source/world/tile/Bush.hpp index 36e687d2c..8515edc1d 100644 --- a/source/world/tile/Bush.hpp +++ b/source/world/tile/Bush.hpp @@ -13,7 +13,7 @@ class Bush : public Tile { public: - Bush(int id, int texture); + Bush(TileID id, int texture); virtual bool canSurvive(const Level*, const TilePos& pos) const override; virtual AABB* getAABB(const Level*, const TilePos& pos) override; diff --git a/source/world/tile/CactusTile.cpp b/source/world/tile/CactusTile.cpp index 60ace30cc..37315f303 100644 --- a/source/world/tile/CactusTile.cpp +++ b/source/world/tile/CactusTile.cpp @@ -69,7 +69,7 @@ void CactusTile::tick(Level* level, const TilePos& pos, Random* random) } if (height < 3) { - int data = level->getData(pos); + TileData data = level->getData(pos); if (data == 15) { level->setTile(above, m_ID); diff --git a/source/world/tile/ClayTile.cpp b/source/world/tile/ClayTile.cpp index 2ff13d035..e76ddf457 100644 --- a/source/world/tile/ClayTile.cpp +++ b/source/world/tile/ClayTile.cpp @@ -9,11 +9,11 @@ #include "ClayTile.hpp" #include "world/level/Level.hpp" -ClayTile::ClayTile(int a, int b, Material* c) : Tile(a, b, c) +ClayTile::ClayTile(TileID id, int texture, Material* c) : Tile(id, texture, c) { } -int ClayTile::getResource(int, Random* random) const +int ClayTile::getResource(TileData data, Random* random) const { return 0; //@NOTE: Would be clay's item ID } diff --git a/source/world/tile/ClayTile.hpp b/source/world/tile/ClayTile.hpp index 7d07d7526..30830e3cf 100644 --- a/source/world/tile/ClayTile.hpp +++ b/source/world/tile/ClayTile.hpp @@ -13,8 +13,8 @@ class ClayTile : public Tile { public: - ClayTile(int ID, int texture, Material*); + ClayTile(TileID ID, int texture, Material*); - int getResource(int, Random*) const override; + int getResource(TileData, Random*) const override; int getResourceCount(Random*) const override; }; diff --git a/source/world/tile/ClothTile.cpp b/source/world/tile/ClothTile.cpp index e5e58c711..ac331f36a 100644 --- a/source/world/tile/ClothTile.cpp +++ b/source/world/tile/ClothTile.cpp @@ -13,7 +13,7 @@ ClothTile::ClothTile(int id) : Tile(id, TEXTURE_CLOTH_64, Material::cloth) { } -int ClothTile::getTexture(Facing::Name face, int data) const +int ClothTile::getTexture(Facing::Name face, TileData data) const { if (!data) { diff --git a/source/world/tile/ClothTile.hpp b/source/world/tile/ClothTile.hpp index c72841fcd..e2dfc94fe 100644 --- a/source/world/tile/ClothTile.hpp +++ b/source/world/tile/ClothTile.hpp @@ -14,7 +14,7 @@ class ClothTile : public Tile { public: ClothTile(int id); - int getTexture(Facing::Name face, int data) const override; + int getTexture(Facing::Name face, TileData data) const override; int getSpawnResourcesAuxValue(int val) const override; static int getColorFromData(int var0) { diff --git a/source/world/tile/DoorTile.cpp b/source/world/tile/DoorTile.cpp index c28a63cdb..50b4f40fb 100644 --- a/source/world/tile/DoorTile.cpp +++ b/source/world/tile/DoorTile.cpp @@ -26,7 +26,7 @@ int DoorTile::use(Level* level, const TilePos& pos, Player* player) if (m_pMaterial == Material::metal) return 1; - int data = level->getData(pos); + TileData data = level->getData(pos); // if we're the top tile if (data & 8) @@ -83,7 +83,7 @@ AABB* DoorTile::getAABB(const Level* level, const TilePos& pos) return Tile::getAABB(level, pos); } -int DoorTile::getDir(int data) const +int DoorTile::getDir(TileData data) const { if (!isOpen(data)) return (data - 1) & 3; @@ -96,7 +96,7 @@ int DoorTile::getRenderShape() const return SHAPE_DOOR; } -int DoorTile::getResource(int data, Random* random) const +int DoorTile::getResource(TileData data, Random* random) const { // breaking the top of the tile doesn't drop anything. // In JE, it probably fixed a certain dupe glitch with doors @@ -109,7 +109,7 @@ int DoorTile::getResource(int data, Random* random) const return Item::door_iron->m_itemID; } -int DoorTile::getTexture(Facing::Name face, int data) const +int DoorTile::getTexture(Facing::Name face, TileData data) const { if (face == Facing::DOWN || face == Facing::UP) return m_TextureFrame; @@ -178,7 +178,7 @@ void DoorTile::updateShape(const LevelSource* level, const TilePos& pos) void DoorTile::setOpen(Level* level, const TilePos& pos, bool bOpen) { - int data = level->getData(pos); + TileData data = level->getData(pos); if (isTop(data)) { if (level->getTile(pos.below()) == m_ID) diff --git a/source/world/tile/DoorTile.hpp b/source/world/tile/DoorTile.hpp index 5e6d48936..e9ba18f1d 100644 --- a/source/world/tile/DoorTile.hpp +++ b/source/world/tile/DoorTile.hpp @@ -20,8 +20,8 @@ class DoorTile : public Tile HitResult clip(const Level*, const TilePos& pos, Vec3, Vec3) override; AABB* getAABB(const Level*, const TilePos& pos) override; int getRenderShape() const override; - int getResource(int data, Random*) const override; - int getTexture(Facing::Name face, int data) const override; + int getResource(TileData data, Random*) const override; + int getTexture(Facing::Name face, TileData data) const override; AABB getTileAABB(const Level*, const TilePos& pos) override; bool isCubeShaped() const override; bool isSolidRender() const override; @@ -30,7 +30,7 @@ class DoorTile : public Tile void neighborChanged(Level*, const TilePos& pos, TileID newTile) override; bool blocksLight() const; - int getDir(int data) const; + int getDir(TileData data) const; void setOpen(Level*, const TilePos& pos, bool bOpen); #pragma GCC diagnostic push @@ -39,11 +39,11 @@ class DoorTile : public Tile #pragma GCC diagnostic pop // @NOTE: These are inlined. - inline static bool isOpen(int data) + inline static bool isOpen(TileData data) { return (data & 4) != 0; } - inline static bool isTop(int data) + inline static bool isTop(TileData data) { return (data & 8) != 0; } diff --git a/source/world/tile/FarmTile.cpp b/source/world/tile/FarmTile.cpp index 6959f9c92..793f80cb9 100644 --- a/source/world/tile/FarmTile.cpp +++ b/source/world/tile/FarmTile.cpp @@ -9,7 +9,7 @@ #include "FarmTile.hpp" #include "world/level/Level.hpp" -FarmTile::FarmTile(int a, Material* c) : Tile(a, c) +FarmTile::FarmTile(TileID id, Material* c) : Tile(id, c) { m_TextureFrame = TEXTURE_FARMLAND_DRY; @@ -33,12 +33,12 @@ AABB* FarmTile::getAABB(const Level*, const TilePos& pos) return &m_aabbReturned; } -int FarmTile::getResource(int x, Random* random) const +int FarmTile::getResource(TileData data, Random* random) const { - return Tile::dirt->getResource(x, random); + return Tile::dirt->getResource(data, random); } -int FarmTile::getTexture(Facing::Name face, int data) const +int FarmTile::getTexture(Facing::Name face, TileData data) const { if (face == Facing::UP) { @@ -106,7 +106,7 @@ void FarmTile::tick(Level* level, const TilePos& pos, Random* random) } else { - int data = level->getData(pos); + TileData data = level->getData(pos); if (data <= 0) level->setTile(pos, Tile::dirt->m_ID); diff --git a/source/world/tile/FarmTile.hpp b/source/world/tile/FarmTile.hpp index 524ae3b03..6c8d3c4a7 100644 --- a/source/world/tile/FarmTile.hpp +++ b/source/world/tile/FarmTile.hpp @@ -13,11 +13,11 @@ class FarmTile : public Tile { public: - FarmTile(int ID, Material*); + FarmTile(TileID ID, Material*); AABB* getAABB(const Level*, const TilePos& pos) override; - int getResource(int, Random*) const override; - int getTexture(Facing::Name face, int data) const override; + int getResource(TileData, Random*) const override; + int getTexture(Facing::Name face, TileData data) const override; bool isCubeShaped() const override; bool isSolidRender() const override; void neighborChanged(Level*, const TilePos& pos, TileID tile) override; diff --git a/source/world/tile/FireTile.cpp b/source/world/tile/FireTile.cpp index 54aaeed5f..87944a5e0 100644 --- a/source/world/tile/FireTile.cpp +++ b/source/world/tile/FireTile.cpp @@ -184,7 +184,7 @@ void FireTile::tick(Level* level, const TilePos& pos, Random* random) return; } - int data = level->getData(pos); + TileData data = level->getData(pos); if (data <= 14) { level->setData(pos, data + 1); diff --git a/source/world/tile/GlowstoneTile.cpp b/source/world/tile/GlowstoneTile.cpp index 1f45f346f..84adca053 100644 --- a/source/world/tile/GlowstoneTile.cpp +++ b/source/world/tile/GlowstoneTile.cpp @@ -1,11 +1,11 @@ #include "GlowstoneTile.hpp" #include "world/level/Level.hpp" -GlowstoneTile::GlowstoneTile(int id, int texture, Material* material) : Tile(id, texture, material) +GlowstoneTile::GlowstoneTile(TileID id, int texture, Material* material) : Tile(id, texture, material) { } -int GlowstoneTile::getResource(int data, Random*) const +int GlowstoneTile::getResource(TileData data, Random*) const { return Item::yellowDust->m_itemID; } diff --git a/source/world/tile/GlowstoneTile.hpp b/source/world/tile/GlowstoneTile.hpp index 31b71107f..13649b66c 100644 --- a/source/world/tile/GlowstoneTile.hpp +++ b/source/world/tile/GlowstoneTile.hpp @@ -5,8 +5,8 @@ class GlowstoneTile : public Tile { public: - GlowstoneTile(int id, int texture, Material* material); + GlowstoneTile(TileID id, int texture, Material* material); - int getResource(int, Random*) const override; + int getResource(TileData, Random*) const override; int getResourceCount(Random*) const override; }; \ No newline at end of file diff --git a/source/world/tile/GrassTile.cpp b/source/world/tile/GrassTile.cpp index 1abbf0a09..216270cd1 100644 --- a/source/world/tile/GrassTile.cpp +++ b/source/world/tile/GrassTile.cpp @@ -10,7 +10,7 @@ #include "world/level/Level.hpp" #include "client/renderer/PatchManager.hpp" -GrassTile::GrassTile(int id, Material* c) : Tile(id, c) +GrassTile::GrassTile(TileID id, Material* c) : Tile(id, c) { m_TextureFrame = TEXTURE_GRASS_SIDE; setTicking(true); @@ -26,9 +26,9 @@ int GrassTile::getColor(const LevelSource* levelSource, const TilePos& pos) cons return 0xffffff; } -int GrassTile::getResource(int i, Random* random) const +int GrassTile::getResource(TileData data, Random* random) const { - return Tile::dirt->getResource(i, random); + return Tile::dirt->getResource(data, random); } int GrassTile::getTexture(Facing::Name face) const @@ -65,7 +65,7 @@ void GrassTile::tick(Level* level, const TilePos& pos, Random* random) { // Controls the spread/death of grass. // It's like a full on automata of sorts. :) - if (level->m_bIsOnline) + if (level->m_bIsClientSide) return; if (level->getRawBrightness(pos.above()) <= 3 && diff --git a/source/world/tile/GrassTile.hpp b/source/world/tile/GrassTile.hpp index a9c9d56b5..f1b2cbc04 100644 --- a/source/world/tile/GrassTile.hpp +++ b/source/world/tile/GrassTile.hpp @@ -13,9 +13,9 @@ class GrassTile : public Tile { public: - GrassTile(int ID, Material*); + GrassTile(TileID ID, Material*); - int getResource(int, Random*) const override; + int getResource(TileData, Random*) const override; int getColor(const LevelSource*, const TilePos& pos) const override; int getTexture(Facing::Name face) const override; int getTexture(const LevelSource*, const TilePos& pos, Facing::Name face) const override; diff --git a/source/world/tile/GravelTile.cpp b/source/world/tile/GravelTile.cpp index e22b9419b..3da69fcd0 100644 --- a/source/world/tile/GravelTile.cpp +++ b/source/world/tile/GravelTile.cpp @@ -13,7 +13,7 @@ GravelTile::GravelTile(int a, int b, Material* c) : SandTile(a, b, c) { } -int GravelTile::getResource(int data, Random* random) const +int GravelTile::getResource(TileData data, Random* random) const { return random->nextInt(10) == 0 ? Item::flint->m_itemID : SandTile::getResource(data, random); } diff --git a/source/world/tile/GravelTile.hpp b/source/world/tile/GravelTile.hpp index 675ac2e27..4f7fb2c13 100644 --- a/source/world/tile/GravelTile.hpp +++ b/source/world/tile/GravelTile.hpp @@ -15,5 +15,5 @@ class GravelTile : public SandTile public: GravelTile(int ID, int texture, Material*); - int getResource(int data, Random* random) const override; + int getResource(TileData data, Random* random) const override; }; diff --git a/source/world/tile/InvisibleTile.cpp b/source/world/tile/InvisibleTile.cpp index 11d895498..a829f0d63 100644 --- a/source/world/tile/InvisibleTile.cpp +++ b/source/world/tile/InvisibleTile.cpp @@ -9,7 +9,7 @@ #include "InvisibleTile.hpp" #include "world/level/Level.hpp" -InvisibleTile::InvisibleTile(int ID, int texture, Material* pMtl) : +InvisibleTile::InvisibleTile(TileID ID, int texture, Material* pMtl) : Tile(ID, texture, pMtl) { diff --git a/source/world/tile/InvisibleTile.hpp b/source/world/tile/InvisibleTile.hpp index 93ced9fcc..a1ef517d4 100644 --- a/source/world/tile/InvisibleTile.hpp +++ b/source/world/tile/InvisibleTile.hpp @@ -13,7 +13,7 @@ class InvisibleTile : public Tile { public: - InvisibleTile(int ID, int texture, Material*); + InvisibleTile(TileID ID, int texture, Material*); int getRenderShape() const override; bool mayPick() const override; }; diff --git a/source/world/tile/LadderTile.cpp b/source/world/tile/LadderTile.cpp index fb07eb511..59ea66d46 100644 --- a/source/world/tile/LadderTile.cpp +++ b/source/world/tile/LadderTile.cpp @@ -35,7 +35,7 @@ bool LadderTile::isSolidRender() const AABB* LadderTile::getAABB(const Level* level, const TilePos& pos) { - int data = level->getData(pos); + TileData data = level->getData(pos); switch (data) { case 2: @@ -57,7 +57,7 @@ AABB* LadderTile::getAABB(const Level* level, const TilePos& pos) AABB LadderTile::getTileAABB(const Level* level, const TilePos& pos) { - int data = level->getData(pos); + TileData data = level->getData(pos); switch (data) { case 2: @@ -79,7 +79,7 @@ AABB LadderTile::getTileAABB(const Level* level, const TilePos& pos) void LadderTile::setPlacedOnFace(Level* level, const TilePos& pos, Facing::Name face) { - int data = level->getData(pos); + TileData data = level->getData(pos); if ((data == 0 || face == Facing::NORTH) && level->isSolidTile(pos.south())) data = 2; if ((data == 0 || face == Facing::SOUTH) && level->isSolidTile(pos.north())) data = 3; @@ -92,7 +92,7 @@ void LadderTile::setPlacedOnFace(Level* level, const TilePos& pos, Facing::Name void LadderTile::neighborChanged(Level* level, const TilePos& pos, TileID tile) { - int data = level->getData(pos); + TileData data = level->getData(pos); switch (data) { case 2: diff --git a/source/world/tile/LeafTile.cpp b/source/world/tile/LeafTile.cpp index a198ec5e1..abc4e5128 100644 --- a/source/world/tile/LeafTile.cpp +++ b/source/world/tile/LeafTile.cpp @@ -17,7 +17,7 @@ #define C_BIRCH_LEAF 2 #define C_LEAF_TYPE_MASK 3 -LeafTile::LeafTile(int id) : TransparentTile(id, TEXTURE_LEAVES_TRANSPARENT, Material::leaves, false) +LeafTile::LeafTile(TileID id) : TransparentTile(id, TEXTURE_LEAVES_TRANSPARENT, Material::leaves, false) { m_checkBuffer = nullptr; @@ -35,7 +35,7 @@ LeafTile::~LeafTile() void LeafTile::_tickDecayOld(Level* level, const TilePos& pos) { - int data = level->getData(pos); + TileData data = level->getData(pos); if ((data & C_UPDATE_LEAF_BIT) == 0) return; @@ -114,7 +114,7 @@ void LeafTile::_tickDecayOld(Level* level, const TilePos& pos) void LeafTile::_tickDecay(Level* level, const TilePos& pos) { - int data = level->getData(pos); + TileData data = level->getData(pos); if ((data & C_UPDATE_LEAF_BIT) == 0) return; @@ -199,7 +199,7 @@ int LeafTile::getColor(const LevelSource* level, const TilePos& pos) const return 0xffffff; } -int LeafTile::getTexture(Facing::Name face, int data) const +int LeafTile::getTexture(Facing::Name face, TileData data) const { if ((data & C_LEAF_TYPE_MASK) == 1) return m_TextureFrame + 80; @@ -239,13 +239,13 @@ void LeafTile::onRemove(Level* level, const TilePos& pos) void LeafTile::tick(Level* level, const TilePos& pos, Random* random) { - if (level->m_bIsOnline) + if (level->m_bIsClientSide) return; _tickDecay(level, pos); } -int LeafTile::getResource(int x, Random* random) const +int LeafTile::getResource(TileData data, Random* random) const { return random->nextInt(20) == 0 ? Tile::sapling->m_ID : 0; } diff --git a/source/world/tile/LeafTile.hpp b/source/world/tile/LeafTile.hpp index a053faedf..f08e05222 100644 --- a/source/world/tile/LeafTile.hpp +++ b/source/world/tile/LeafTile.hpp @@ -13,7 +13,7 @@ class LeafTile : public TransparentTile { public: - LeafTile(int id); + LeafTile(TileID id); ~LeafTile(); private: @@ -22,12 +22,12 @@ class LeafTile : public TransparentTile public: int getColor(const LevelSource*, const TilePos& pos) const override; - int getTexture(Facing::Name face, int data) const override; + int getTexture(Facing::Name face, TileData data) const override; bool isSolidRender() const override; void onRemove(Level*, const TilePos& pos) override; void stepOn(Level*, const TilePos& pos, Entity*) override; void tick(Level*, const TilePos& pos, Random*) override; - int getResource(int x, Random* random) const override; + int getResource(TileData data, Random* random) const override; int getSpawnResourcesAuxValue(int x) const override; void die(Level*, const TilePos& pos); diff --git a/source/world/tile/LiquidTile.cpp b/source/world/tile/LiquidTile.cpp index 78cf2a68d..265dcf032 100644 --- a/source/world/tile/LiquidTile.cpp +++ b/source/world/tile/LiquidTile.cpp @@ -148,7 +148,7 @@ int LiquidTile::getRenderShape() const return SHAPE_WATER; } -int LiquidTile::getResource(int x, Random* random) const +int LiquidTile::getResource(TileData data, Random* random) const { return 0; } @@ -180,7 +180,7 @@ int LiquidTile::getTexture(Facing::Name face) const return m_TextureFrame; } -int LiquidTile::getTexture(Facing::Name face, int data) const +int LiquidTile::getTexture(Facing::Name face, TileData data) const { // @TODO: revert to using Tile::getTexture return Tile::getTexture(face, data); @@ -211,7 +211,7 @@ bool LiquidTile::isSolidRender() const return false; } -bool LiquidTile::mayPick(int data, bool b) const +bool LiquidTile::mayPick(TileData data, bool b) const { if (!b) return false; @@ -261,7 +261,7 @@ void LiquidTile::updateLiquid(Level* level, const TilePos& pos) level->getMaterial(pos.above()) == Material::water) { Tile* newTile; - int data = level->getData(pos); + TileData data = level->getData(pos); if (data == 0) { diff --git a/source/world/tile/LiquidTile.hpp b/source/world/tile/LiquidTile.hpp index 29117e468..0f0a4ec8c 100644 --- a/source/world/tile/LiquidTile.hpp +++ b/source/world/tile/LiquidTile.hpp @@ -23,15 +23,15 @@ class LiquidTile : public Tile float getBrightness(const LevelSource*, const TilePos& pos) const override; int getRenderLayer() const override; int getRenderShape() const override; - int getResource(int, Random*) const override; + int getResource(TileData, Random*) const override; int getResourceCount(Random*) const override; int getTexture(Facing::Name face) const override; - int getTexture(Facing::Name face, int data) const override; + int getTexture(Facing::Name face, TileData data) const override; int getTickDelay() const override; void handleEntityInside(Level*, const TilePos& pos, const Entity*, Vec3&) override; bool isCubeShaped() const override; bool isSolidRender() const override; - bool mayPick(int data, bool b) const override; + bool mayPick(TileData data, bool b) const override; bool shouldRenderFace(const LevelSource*, const TilePos& pos, Facing::Name face) const override; void updateLiquid(Level*, const TilePos& pos); @@ -44,7 +44,7 @@ class LiquidTile : public Tile static float getSlopeAngle(const LevelSource*, const TilePos& pos, const Material* pMtl); // @NOTE: This is inlined in minecraftcpp - static float getWaterVolume(int data) + static float getWaterVolume(TileData data) { if (data >= 8) data = 0; diff --git a/source/world/tile/LiquidTileDynamic.cpp b/source/world/tile/LiquidTileDynamic.cpp index 1b426433c..1beb8efc9 100644 --- a/source/world/tile/LiquidTileDynamic.cpp +++ b/source/world/tile/LiquidTileDynamic.cpp @@ -166,13 +166,13 @@ void LiquidTileDynamic::onPlace(Level* level, const TilePos& pos) void LiquidTileDynamic::setStatic(Level* level, const TilePos& pos) { - int data = level->getData(pos); + TileData data = level->getData(pos); level->setTileAndDataNoUpdate(pos, m_ID + 1, data); level->setTilesDirty(pos, pos); level->sendTileUpdated(pos); } -void LiquidTileDynamic::trySpreadTo(Level* level, const TilePos& pos, int data) +void LiquidTileDynamic::trySpreadTo(Level* level, const TilePos& pos, TileData data) { if (!canSpreadTo(level, pos)) return; @@ -299,7 +299,7 @@ void LiquidTileDynamic::tick(Level* level, const TilePos& pos, Random* random) { bool* bSpread = getSpread(level, pos); - int data = depth + speed; + TileData data = depth + speed; if (depth >= 8) data = 1; diff --git a/source/world/tile/LiquidTileDynamic.hpp b/source/world/tile/LiquidTileDynamic.hpp index 46d23d476..71eba9642 100644 --- a/source/world/tile/LiquidTileDynamic.hpp +++ b/source/world/tile/LiquidTileDynamic.hpp @@ -24,6 +24,6 @@ class LiquidTileDynamic : public LiquidTile int getSlopeDistance(Level*, const TilePos& pos, int depth, int); bool* getSpread(Level*, const TilePos& pos); void setStatic(Level*, const TilePos& pos); - void trySpreadTo(Level*, const TilePos& pos, int a); + void trySpreadTo(Level*, const TilePos& pos, TileData data); int getSmallestDepth(Level*, const TilePos& pos, int oldDepth); }; diff --git a/source/world/tile/ObsidianTile.cpp b/source/world/tile/ObsidianTile.cpp index b730604a2..3c2d1e41e 100644 --- a/source/world/tile/ObsidianTile.cpp +++ b/source/world/tile/ObsidianTile.cpp @@ -13,7 +13,7 @@ ObsidianTile::ObsidianTile(int a, int b, Material* c) : Tile(a, b, c) { } -int ObsidianTile::getResource(int data, Random* random) const +int ObsidianTile::getResource(TileData data, Random* random) const { return Tile::obsidian->m_ID; } diff --git a/source/world/tile/ObsidianTile.hpp b/source/world/tile/ObsidianTile.hpp index eff217391..33a933cc4 100644 --- a/source/world/tile/ObsidianTile.hpp +++ b/source/world/tile/ObsidianTile.hpp @@ -15,6 +15,6 @@ class ObsidianTile : public Tile public: ObsidianTile(int ID, int texture, Material*); - int getResource(int data, Random*) const override; + int getResource(TileData data, Random*) const override; int getResourceCount(Random*) const override; }; diff --git a/source/world/tile/OreTile.cpp b/source/world/tile/OreTile.cpp index 9816e9338..c1ae2bf94 100644 --- a/source/world/tile/OreTile.cpp +++ b/source/world/tile/OreTile.cpp @@ -9,12 +9,12 @@ #include "OreTile.hpp" #include "world/level/Level.hpp" -OreTile::OreTile(int id, int texture) : Tile(id, texture, Material::stone) +OreTile::OreTile(TileID id, int texture) : Tile(id, texture, Material::stone) { } -int OreTile::getResource(int x, Random* random) const +int OreTile::getResource(TileData data, Random* random) const { return m_ID; } diff --git a/source/world/tile/OreTile.hpp b/source/world/tile/OreTile.hpp index f18350e2b..a92d5b769 100644 --- a/source/world/tile/OreTile.hpp +++ b/source/world/tile/OreTile.hpp @@ -13,9 +13,9 @@ class OreTile : public Tile { public: - OreTile(int id, int texture); + OreTile(TileID id, int texture); - int getResource(int, Random*) const override; + int getResource(TileData data, Random*) const override; int getResourceCount(Random*) const override; int getSpawnResourcesAuxValue(int) const override; }; diff --git a/source/world/tile/PumpkinTile.cpp b/source/world/tile/PumpkinTile.cpp index aa5fee49e..524263afc 100644 --- a/source/world/tile/PumpkinTile.cpp +++ b/source/world/tile/PumpkinTile.cpp @@ -1,11 +1,11 @@ #include "PumpkinTile.hpp" #include "world/level/Level.hpp" -PumpkinTile::PumpkinTile(int id, bool lantern) : Tile(id, TEXTURE_PUMPKIN_TOP, Material::vegetable), m_bLantern(lantern) +PumpkinTile::PumpkinTile(TileID id, bool lantern) : Tile(id, TEXTURE_PUMPKIN_TOP, Material::vegetable), m_bLantern(lantern) { } -int PumpkinTile::getTexture(Facing::Name face, int data) const +int PumpkinTile::getTexture(Facing::Name face, TileData data) const { switch (face) { case Facing::UP: case Facing::DOWN: return m_TextureFrame; @@ -27,7 +27,7 @@ void PumpkinTile::setPlacedBy(Level* level, const TilePos& pos, Mob* mob) { int rot = Mth::floor(0.5f + (mob->m_rot.x * 4.0f / 360.0f)) & 3; - int data = 0; + TileData data = 0; switch (rot) { diff --git a/source/world/tile/PumpkinTile.hpp b/source/world/tile/PumpkinTile.hpp index 119aade59..cd58daa50 100644 --- a/source/world/tile/PumpkinTile.hpp +++ b/source/world/tile/PumpkinTile.hpp @@ -5,8 +5,8 @@ class PumpkinTile : public Tile { public: - PumpkinTile(int id, bool lantern); - int getTexture(Facing::Name face, int data) const override; + PumpkinTile(TileID id, bool lantern); + int getTexture(Facing::Name face, TileData data) const override; int getTexture(Facing::Name face) const override; void setPlacedBy(Level*, const TilePos& pos, Mob*) override; bool m_bLantern; diff --git a/source/world/tile/RedStoneOreTile.cpp b/source/world/tile/RedStoneOreTile.cpp index 66c43495d..c11aff91c 100644 --- a/source/world/tile/RedStoneOreTile.cpp +++ b/source/world/tile/RedStoneOreTile.cpp @@ -9,14 +9,14 @@ #include "RedStoneOreTile.hpp" #include "world/level/Level.hpp" -RedStoneOreTile::RedStoneOreTile(int id, int texture, bool bLit) : Tile(id, texture, Material::stone) +RedStoneOreTile::RedStoneOreTile(TileID id, int texture, bool bLit) : Tile(id, texture, Material::stone) { m_bLit = bLit; if (bLit) setTicking(true); } -int RedStoneOreTile::getResource(int x, Random* random) const +int RedStoneOreTile::getResource(TileData data, Random* random) const { return 0; } diff --git a/source/world/tile/RedStoneOreTile.hpp b/source/world/tile/RedStoneOreTile.hpp index 031c91bb1..0c1f83767 100644 --- a/source/world/tile/RedStoneOreTile.hpp +++ b/source/world/tile/RedStoneOreTile.hpp @@ -13,9 +13,9 @@ class RedStoneOreTile : public Tile { public: - RedStoneOreTile(int id, int texture, bool bLit); + RedStoneOreTile(TileID id, int texture, bool bLit); - int getResource(int, Random*) const override; + int getResource(TileData, Random*) const override; int getResourceCount(Random*) const override; int getSpawnResourcesAuxValue(int) const override; int getTickDelay() const override; diff --git a/source/world/tile/ReedTile.cpp b/source/world/tile/ReedTile.cpp index 2ebe1185e..5f7d64c14 100644 --- a/source/world/tile/ReedTile.cpp +++ b/source/world/tile/ReedTile.cpp @@ -9,7 +9,7 @@ #include "ReedTile.hpp" #include "world/level/Level.hpp" -ReedTile::ReedTile(int id) : Tile(id, Material::plant) +ReedTile::ReedTile(TileID id) : Tile(id, Material::plant) { m_TextureFrame = TEXTURE_REEDS; setShape(0.125f, 0.0f, 0.125f, 0.875f, 1.0f, 0.875f); @@ -78,7 +78,7 @@ void ReedTile::tick(Level* level, const TilePos& pos, Random* random) if (height <= 2) { - int data = level->getData(pos); + TileData data = level->getData(pos); if (data == 15) { @@ -97,7 +97,7 @@ AABB* ReedTile::getAABB(const Level* level, const TilePos& pos) return nullptr; } -int ReedTile::getResource(int x, Random* random) const +int ReedTile::getResource(TileData data, Random* random) const { return Item::reeds->m_itemID; } diff --git a/source/world/tile/ReedTile.hpp b/source/world/tile/ReedTile.hpp index 340f4b72d..023f5da22 100644 --- a/source/world/tile/ReedTile.hpp +++ b/source/world/tile/ReedTile.hpp @@ -13,7 +13,7 @@ class ReedTile : public Tile { public: - ReedTile(int id); + ReedTile(TileID id); bool canSurvive(const Level*, const TilePos& pos) const override; AABB* getAABB(const Level*, const TilePos& pos) override; @@ -23,7 +23,7 @@ class ReedTile : public Tile bool mayPlace(const Level*, const TilePos& pos) const override; void tick(Level*, const TilePos& pos, Random*) override; void neighborChanged(Level*, const TilePos& pos, TileID tile) override; - int getResource(int, Random*) const override; + int getResource(TileData data, Random*) const override; void checkAlive(Level*, const TilePos& pos); }; diff --git a/source/world/tile/RocketLauncherTile.cpp b/source/world/tile/RocketLauncherTile.cpp index f68549918..32ad8f1ad 100644 --- a/source/world/tile/RocketLauncherTile.cpp +++ b/source/world/tile/RocketLauncherTile.cpp @@ -9,12 +9,12 @@ #include "world/level/Level.hpp" #include "world/entity/Rocket.hpp" -RocketLauncherTile::RocketLauncherTile(int id) : Tile(id, 16*14+2, Material::wood) +RocketLauncherTile::RocketLauncherTile(TileID id) : Tile(id, 16*14+2, Material::wood) { setTicking(true); } -int RocketLauncherTile::getTexture(Facing::Name face, int data) const +int RocketLauncherTile::getTexture(Facing::Name face, TileData data) const { return data == 1 ? 16*14+3 : 16*14+2; } diff --git a/source/world/tile/RocketLauncherTile.hpp b/source/world/tile/RocketLauncherTile.hpp index f5a492191..c0efd5de2 100644 --- a/source/world/tile/RocketLauncherTile.hpp +++ b/source/world/tile/RocketLauncherTile.hpp @@ -13,9 +13,9 @@ class RocketLauncherTile : public Tile { public: - RocketLauncherTile(int id); + RocketLauncherTile(TileID id); - int getTexture(Facing::Name face, int data) const override; + int getTexture(Facing::Name face, TileData data) const override; AABB* getAABB(const Level*, const TilePos& pos) override; int getRenderShape() const override; bool isCubeShaped() const override; diff --git a/source/world/tile/SandTile.cpp b/source/world/tile/SandTile.cpp index 77deb2666..b5c2db192 100644 --- a/source/world/tile/SandTile.cpp +++ b/source/world/tile/SandTile.cpp @@ -81,7 +81,7 @@ bool SandTile::isFree(Level* level, const TilePos& pos) void SandTile::tick(Level* level, const TilePos& pos, Random* random) { - if (level->m_bIsOnline) + if (level->m_bIsClientSide) return; checkSlide(level, pos); diff --git a/source/world/tile/Sapling.cpp b/source/world/tile/Sapling.cpp index e60886746..4ce78bf9f 100644 --- a/source/world/tile/Sapling.cpp +++ b/source/world/tile/Sapling.cpp @@ -9,11 +9,11 @@ #include "Sapling.hpp" #include "world/level/Level.hpp" -Sapling::Sapling(int id, int texture) : Bush(id, texture) +Sapling::Sapling(TileID id, int texture) : Bush(id, texture) { } -int Sapling::getTexture(Facing::Name face, int data) const +int Sapling::getTexture(Facing::Name face, TileData data) const { data &= 3; return data == 1 ? 63 : (data == 2 ? 79 : Bush::getTexture(face, data)); @@ -25,7 +25,7 @@ void Sapling::tick(Level* level, const TilePos& pos, Random* random) if (level->getRawBrightness(pos) > 8 && random->nextInt(7) == 0) { - int data = level->getData(pos); + TileData data = level->getData(pos); if (data & 8) growTree(level, pos, random); @@ -36,7 +36,7 @@ void Sapling::tick(Level* level, const TilePos& pos, Random* random) void Sapling::growTree(Level* level, const TilePos& pos, Random* random) { - int data = level->getData(pos) & 3; + TileData data = level->getData(pos) & 3; level->setTileNoUpdate(pos, TILE_AIR); TreeFeature treeFeature; diff --git a/source/world/tile/Sapling.hpp b/source/world/tile/Sapling.hpp index dca057a27..1066da73a 100644 --- a/source/world/tile/Sapling.hpp +++ b/source/world/tile/Sapling.hpp @@ -13,9 +13,9 @@ class Sapling : public Bush { public: - Sapling(int id, int texture); + Sapling(TileID id, int texture); - int getTexture(Facing::Name face, int data) const override; + int getTexture(Facing::Name face, TileData data) const override; void tick(Level*, const TilePos& pos, Random*) override; int getSpawnResourcesAuxValue(int x) const override; diff --git a/source/world/tile/SpongeTile.cpp b/source/world/tile/SpongeTile.cpp index b8218820d..d3802f46c 100644 --- a/source/world/tile/SpongeTile.cpp +++ b/source/world/tile/SpongeTile.cpp @@ -9,7 +9,7 @@ #include "SpongeTile.hpp" #include "world/level/Level.hpp" -SpongeTile::SpongeTile(int id, int texture) : Tile(id, texture, Material::sponge) +SpongeTile::SpongeTile(TileID id, int texture) : Tile(id, texture, Material::sponge) { } @@ -33,7 +33,7 @@ void SpongeTile::onPlace(Level* level, const TilePos& pos) } } -void SpongeTile::destroy(Level* level, const TilePos& pos, int data) +void SpongeTile::destroy(Level* level, const TilePos& pos, TileData data) { // give an update to all water around us TilePos o; diff --git a/source/world/tile/SpongeTile.hpp b/source/world/tile/SpongeTile.hpp index 1f14119a0..0729be563 100644 --- a/source/world/tile/SpongeTile.hpp +++ b/source/world/tile/SpongeTile.hpp @@ -13,8 +13,8 @@ class SpongeTile : public Tile { public: - SpongeTile(int ID, int texture); + SpongeTile(TileID ID, int texture); void onPlace(Level*, const TilePos& pos) override; - void destroy(Level*, const TilePos& pos, int data) override; + void destroy(Level*, const TilePos& pos, TileData data) override; }; \ No newline at end of file diff --git a/source/world/tile/StairTile.cpp b/source/world/tile/StairTile.cpp index d95f50bec..8e4b06078 100644 --- a/source/world/tile/StairTile.cpp +++ b/source/world/tile/StairTile.cpp @@ -106,9 +106,9 @@ int StairTile::getTexture(Facing::Name face) const return m_pParent->getTexture(face); } -int StairTile::getTexture(Facing::Name face, int b) const +int StairTile::getTexture(Facing::Name face, TileData data) const { - return m_pParent->getTexture(face, b); + return m_pParent->getTexture(face, data); } int StairTile::getTexture(const LevelSource* level, const TilePos& pos, Facing::Name face) const @@ -126,9 +126,9 @@ bool StairTile::mayPick() const return m_pParent->mayPick(); } -bool StairTile::mayPick(int a, bool b) const +bool StairTile::mayPick(TileData data, bool b) const { - return m_pParent->mayPick(a, b); + return m_pParent->mayPick(data, b); } bool StairTile::mayPlace(const Level* level, const TilePos& pos) const @@ -146,7 +146,7 @@ void StairTile::tick(Level* level, const TilePos& pos, Random* random) m_pParent->tick(level, pos, random); } -void StairTile::destroy(Level* level, const TilePos& pos, int data) +void StairTile::destroy(Level* level, const TilePos& pos, TileData data) { m_pParent->destroy(level, pos, data); } @@ -162,9 +162,9 @@ void StairTile::onRemove(Level* level, const TilePos& pos) m_pParent->onRemove(level, pos); } -int StairTile::getResource(int a, Random* random) const +int StairTile::getResource(TileData data, Random* random) const { - return m_pParent->getResource(a, random); + return m_pParent->getResource(data, random); } int StairTile::getResourceCount(Random* random) const @@ -172,14 +172,14 @@ int StairTile::getResourceCount(Random* random) const return m_pParent->getResourceCount(random); } -void StairTile::spawnResources(Level* level, const TilePos& pos, int d) +void StairTile::spawnResources(Level* level, const TilePos& pos, TileData data) { - m_pParent->spawnResources(level, pos, d); + m_pParent->spawnResources(level, pos, data); } -void StairTile::spawnResources(Level* level, const TilePos& pos, int d, float f) +void StairTile::spawnResources(Level* level, const TilePos& pos, TileData data, float f) { - m_pParent->spawnResources(level, pos, d, f); + m_pParent->spawnResources(level, pos, data, f); } float StairTile::getExplosionResistance(Entity* entity) const @@ -211,7 +211,7 @@ void StairTile::setPlacedBy(Level* level, const TilePos& pos, Mob* mob) { int rot = Mth::floor(0.5f + (mob->m_rot.x * 4.0f / 360.0f)) & 3; - int data = 0; + TileData data = 0; switch (rot) { diff --git a/source/world/tile/StairTile.hpp b/source/world/tile/StairTile.hpp index 7574f77ca..4560839f1 100644 --- a/source/world/tile/StairTile.hpp +++ b/source/world/tile/StairTile.hpp @@ -26,21 +26,21 @@ class StairTile : public Tile virtual void updateShape(const LevelSource*, const TilePos& pos) override; virtual float getBrightness(const LevelSource*, const TilePos& pos) const override; virtual int getTexture(Facing::Name face) const override; - virtual int getTexture(Facing::Name face, int) const override; + virtual int getTexture(Facing::Name face, TileData data) const override; virtual int getTexture(const LevelSource*, const TilePos& pos, Facing::Name face) const override; virtual AABB getTileAABB(const Level*, const TilePos& pos) override; virtual bool mayPick() const override; - virtual bool mayPick(int, bool) const override; + virtual bool mayPick(TileData data, bool) const override; virtual bool mayPlace(const Level*, const TilePos& pos) const override; virtual int getTickDelay() const override; virtual void tick(Level*, const TilePos& pos, Random*) override; - virtual void destroy(Level*, const TilePos& pos, int data) override; + virtual void destroy(Level*, const TilePos& pos, TileData data) override; virtual void onPlace(Level*, const TilePos& pos) override; virtual void onRemove(Level*, const TilePos& pos) override; - virtual int getResource(int, Random*) const override; + virtual int getResource(TileData, Random*) const override; virtual int getResourceCount(Random*) const override; - virtual void spawnResources(Level*, const TilePos& pos, int) override; - virtual void spawnResources(Level*, const TilePos& pos, int, float) override; + virtual void spawnResources(Level*, const TilePos& pos, TileData data) override; + virtual void spawnResources(Level*, const TilePos& pos, TileData data, float) override; virtual float getExplosionResistance(Entity*) const override; virtual void wasExploded(Level*, const TilePos& pos) override; virtual int getRenderLayer() const override; diff --git a/source/world/tile/StoneSlabTile.cpp b/source/world/tile/StoneSlabTile.cpp index 83a2763f6..ced2f2332 100644 --- a/source/world/tile/StoneSlabTile.cpp +++ b/source/world/tile/StoneSlabTile.cpp @@ -29,7 +29,7 @@ bool StoneSlabTile::isCubeShaped() const return m_bFull; } -int StoneSlabTile::getResource(int data, Random* random) const +int StoneSlabTile::getResource(TileData data, Random* random) const { return Tile::stoneSlabHalf->m_ID; } @@ -50,7 +50,7 @@ int StoneSlabTile::getTexture(Facing::Name face) const return getTexture(face, 0); } -int StoneSlabTile::getTexture(Facing::Name face, int data) const +int StoneSlabTile::getTexture(Facing::Name face, TileData data) const { switch (data) { diff --git a/source/world/tile/StoneSlabTile.hpp b/source/world/tile/StoneSlabTile.hpp index 839c6a834..c3f145979 100644 --- a/source/world/tile/StoneSlabTile.hpp +++ b/source/world/tile/StoneSlabTile.hpp @@ -25,11 +25,11 @@ class StoneSlabTile : public Tile bool isSolidRender() const override; bool isCubeShaped() const override; - int getResource(int, Random*) const override; + int getResource(TileData, Random*) const override; int getResourceCount(Random*) const override; int getSpawnResourcesAuxValue(int) const override; int getTexture(Facing::Name face) const override; - int getTexture(Facing::Name face, int data) const override; + int getTexture(Facing::Name face, TileData data) const override; void onPlace(Level*, const TilePos& pos) override; bool shouldRenderFace(const LevelSource*, const TilePos& pos, Facing::Name face) const override; diff --git a/source/world/tile/StoneTile.cpp b/source/world/tile/StoneTile.cpp index 783bf9669..4bd191290 100644 --- a/source/world/tile/StoneTile.cpp +++ b/source/world/tile/StoneTile.cpp @@ -9,11 +9,11 @@ #include "StoneTile.hpp" #include "world/level/Level.hpp" -StoneTile::StoneTile(int a, int b, Material* c) : Tile(a, b, c) +StoneTile::StoneTile(TileID id, int b, Material* c) : Tile(id, b, c) { } -int StoneTile::getResource(int a, Random* b) const +int StoneTile::getResource(TileData data, Random* b) const { return Tile::stoneBrick->m_ID; } diff --git a/source/world/tile/StoneTile.hpp b/source/world/tile/StoneTile.hpp index 15a448058..b80679c2f 100644 --- a/source/world/tile/StoneTile.hpp +++ b/source/world/tile/StoneTile.hpp @@ -13,7 +13,7 @@ class StoneTile : public Tile { public: - StoneTile(int ID, int texture, Material*); + StoneTile(TileID ID, int texture, Material*); - int getResource(int, Random*) const override; + int getResource(TileData data, Random*) const override; }; diff --git a/source/world/tile/TallGrass.cpp b/source/world/tile/TallGrass.cpp index cae000cc4..ec1fcddd1 100644 --- a/source/world/tile/TallGrass.cpp +++ b/source/world/tile/TallGrass.cpp @@ -4,7 +4,7 @@ #include #include -TallGrass::TallGrass(int id, int texture) : Bush(id, texture) +TallGrass::TallGrass(TileID id, int texture) : Bush(id, texture) { setShape(0.1f, 0.0f, 0.1f, 0.9f, 0.8f, 0.9f); } @@ -14,7 +14,7 @@ bool TallGrass::isValidGrowTile(const TileID tile) const return tile == Tile::grass->m_ID; } -int TallGrass::getResource(int x, Random* random) const +int TallGrass::getResource(TileData data, Random* random) const { return random->nextInt(8) == 0 ? Item::seeds->m_itemID : 0; } @@ -30,7 +30,7 @@ int TallGrass::getColor(const LevelSource* levelSource, const TilePos& pos) cons int TallGrass::getTexture(const LevelSource* level, const TilePos& pos, Facing::Name face) const { - int data = level->getData(pos); + TileData data = level->getData(pos); return data == 1 ? m_TextureFrame : (data == 2 ? m_TextureFrame + 16 + 1 : (data == 0 ? m_TextureFrame + 16 : m_TextureFrame)); } diff --git a/source/world/tile/TallGrass.hpp b/source/world/tile/TallGrass.hpp index aaecdbff6..6cf480a43 100644 --- a/source/world/tile/TallGrass.hpp +++ b/source/world/tile/TallGrass.hpp @@ -5,8 +5,8 @@ class TallGrass : public Bush { public: - TallGrass(int id, int texture); - int getResource(int, Random*) const override; + TallGrass(TileID id, int texture); + int getResource(TileData, Random*) const override; bool isValidGrowTile(const TileID tile) const; int getColor(const LevelSource*, const TilePos& pos) const override; int getTexture(const LevelSource* level, const TilePos& pos, Facing::Name face) const override; diff --git a/source/world/tile/Tile.cpp b/source/world/tile/Tile.cpp index 361ca3532..7bd1e5249 100644 --- a/source/world/tile/Tile.cpp +++ b/source/world/tile/Tile.cpp @@ -106,7 +106,7 @@ void Tile::_init() m_descriptionID = ""; } -void Tile::_init(int ID, Material* pMaterial, int texture) +void Tile::_init(TileID ID, Material* pMaterial, int texture) { _init(); @@ -222,7 +222,7 @@ int Tile::getTexture(Facing::Name face) const return m_TextureFrame; } -int Tile::getTexture(Facing::Name face, int data) const +int Tile::getTexture(Facing::Name face, TileData data) const { return getTexture(face); } @@ -252,12 +252,12 @@ bool Tile::mayPick() const return true; } -bool Tile::mayPick(int x, bool y) const +bool Tile::mayPick(TileData data, bool y) const { return mayPick(); } -int Tile::getResource(int x, Random* pRandom) const +int Tile::getResource(TileData data, Random* pRandom) const { return m_ID; } @@ -899,7 +899,7 @@ void Tile::animateTick(Level* pLevel, const TilePos& pos, Random* pRandom) } -void Tile::destroy(Level* pLevel, const TilePos& pos, int data) +void Tile::destroy(Level* pLevel, const TilePos& pos, TileData data) { } @@ -1050,14 +1050,14 @@ float Tile::getDestroyProgress(Player* player) const return player->getDestroySpeed() / m_hardness / 30.0f; } -void Tile::spawnResources(Level* pLevel, const TilePos& pos, int data) +void Tile::spawnResources(Level* pLevel, const TilePos& pos, TileData data) { return spawnResources(pLevel, pos, data, 1.0f); } -void Tile::spawnResources(Level* pLevel, const TilePos& pos, int data, float fChance) +void Tile::spawnResources(Level* pLevel, const TilePos& pos, TileData data, float fChance) { - if (pLevel->m_bIsOnline) + if (pLevel->m_bIsClientSide) return; int count = getResourceCount(&pLevel->m_random); @@ -1127,12 +1127,12 @@ void Tile::attack(Level* pLevel, const TilePos& pos, Player* player) } -void Tile::playerDestroy(Level* level, Player* player, const TilePos& pos, int data) +void Tile::playerDestroy(Level* level, Player* player, const TilePos& pos, TileData data) { spawnResources(level, pos, data); } -void Tile::playerWillDestroy(Player* player, const TilePos& pos, int data) +void Tile::playerWillDestroy(Player* player, const TilePos& pos, TileData data) { } diff --git a/source/world/tile/Tile.hpp b/source/world/tile/Tile.hpp index 1c26fea60..d45ee30a9 100644 --- a/source/world/tile/Tile.hpp +++ b/source/world/tile/Tile.hpp @@ -50,27 +50,27 @@ class Tile virtual float getBrightness(const LevelSource*, const TilePos& pos) const; virtual bool shouldRenderFace(const LevelSource*, const TilePos& pos, Facing::Name face) const; virtual int getTexture(Facing::Name face) const; - virtual int getTexture(Facing::Name face, int data) const; + virtual int getTexture(Facing::Name face, TileData data) const; virtual int getTexture(const LevelSource*, const TilePos& pos, Facing::Name face) const; virtual AABB* getAABB(const Level*, const TilePos& pos); virtual void addAABBs(const Level*, const TilePos& pos, const AABB*, std::vector&); virtual AABB getTileAABB(const Level*, const TilePos& pos); virtual bool isSolidRender() const; virtual bool mayPick() const; - virtual bool mayPick(int, bool) const; + virtual bool mayPick(TileData, bool) const; virtual bool mayPlace(const Level*, const TilePos& pos) const; virtual int getTickDelay() const; virtual void tick(Level*, const TilePos& pos, Random*); virtual void animateTick(Level*, const TilePos& pos, Random*); - virtual void destroy(Level*, const TilePos& pos, int data); + virtual void destroy(Level*, const TilePos& pos, TileData data); virtual void neighborChanged(Level*, const TilePos& pos, TileID tile); virtual void onPlace(Level*, const TilePos& pos); virtual void onRemove(Level*, const TilePos& pos); - virtual int getResource(int, Random*) const; + virtual int getResource(TileData, Random*) const; virtual int getResourceCount(Random*) const; virtual float getDestroyProgress(Player*) const; - virtual void spawnResources(Level*, const TilePos& pos, int); - virtual void spawnResources(Level*, const TilePos& pos, int, float); + virtual void spawnResources(Level*, const TilePos& pos, TileData data); + virtual void spawnResources(Level*, const TilePos& pos, TileData data, float); virtual int spawnBurnResources(Level*, float, float, float); virtual float getExplosionResistance(Entity*) const; virtual HitResult clip(const Level*, const TilePos& pos, Vec3, Vec3); @@ -89,8 +89,8 @@ class Tile virtual int getSignal(const LevelSource*, const TilePos& pos, Facing::Name face) const; virtual int getDirectSignal(const Level*, const TilePos& pos, Facing::Name face) const; virtual void entityInside(Level*, const TilePos& pos, Entity*) const; - virtual void playerDestroy(Level*, Player*, const TilePos& pos, int); - virtual void playerWillDestroy(Player*, const TilePos& pos, int); + virtual void playerDestroy(Level*, Player*, const TilePos& pos, TileData data); + virtual void playerWillDestroy(Player*, const TilePos& pos, TileData data); virtual bool canSurvive(const Level*, const TilePos& pos) const; virtual std::string getName() const; virtual std::string getDescriptionId() const; @@ -106,11 +106,11 @@ class Tile private: void _init(); - void _init(int ID, Material* pMaterial, int texture = 1); + void _init(TileID ID, Material* pMaterial, int texture = 1); Tile() { _init(); } // consider making public? public: // functions - Tile(int ID, Material* pMaterial) { _init(ID, pMaterial); } - Tile(int ID, int texture, Material* pMaterial) { _init(ID, pMaterial, texture); } + Tile(TileID ID, Material* pMaterial) { _init(ID, pMaterial); } + Tile(TileID ID, int texture, Material* pMaterial) { _init(ID, pMaterial, texture); } Tile* init(); @@ -222,7 +222,7 @@ class Tile public: int m_TextureFrame; - int m_ID; + TileID m_ID; AABB m_aabb; const SoundType* m_pSound; float field_28; diff --git a/source/world/tile/TntTile.cpp b/source/world/tile/TntTile.cpp index 6be58b60a..0955bd748 100644 --- a/source/world/tile/TntTile.cpp +++ b/source/world/tile/TntTile.cpp @@ -33,10 +33,10 @@ int TntTile::getTexture(Facing::Name face) const return m_TextureFrame; } -void TntTile::destroy(Level* level, const TilePos& pos, int data) +void TntTile::destroy(Level* level, const TilePos& pos, TileData data) { // prevent players from using this in multiplayer, to prevent a desync of player IDs - if (level->m_bIsOnline) return; + if (level->m_bIsClientSide) return; level->addEntity(new PrimedTnt(level, Vec3(pos) + 0.5f)); } diff --git a/source/world/tile/TntTile.hpp b/source/world/tile/TntTile.hpp index 2c2daef93..e8ff4a5de 100644 --- a/source/world/tile/TntTile.hpp +++ b/source/world/tile/TntTile.hpp @@ -18,6 +18,6 @@ class TntTile : public Tile int getResourceCount(Random*) const override; int getTexture(Facing::Name face) const override; void neighborChanged(Level*, const TilePos& pos, TileID tile) override; - void destroy(Level*, const TilePos& pos, int data) override; + void destroy(Level*, const TilePos& pos, TileData data) override; void wasExploded(Level*, const TilePos& pos) override; }; diff --git a/source/world/tile/TopSnowTile.cpp b/source/world/tile/TopSnowTile.cpp index b756f3272..b974b308b 100644 --- a/source/world/tile/TopSnowTile.cpp +++ b/source/world/tile/TopSnowTile.cpp @@ -9,7 +9,7 @@ #include "TopSnowTile.hpp" #include "world/level/Level.hpp" -TopSnowTile::TopSnowTile(int a, int b, Material* c) : Tile(a, b, c) +TopSnowTile::TopSnowTile(TileID id, int b, Material* c) : Tile(id, b, c) { setShape(0, 0, 0, 1, 0.125f, 1); setTicking(true); @@ -30,7 +30,7 @@ bool TopSnowTile::isSolidRender() const return false; } -int TopSnowTile::getResource(int x, Random* random) const +int TopSnowTile::getResource(TileData data, Random* random) const { return 0; } diff --git a/source/world/tile/TopSnowTile.hpp b/source/world/tile/TopSnowTile.hpp index 2bb814d8c..82af8e659 100644 --- a/source/world/tile/TopSnowTile.hpp +++ b/source/world/tile/TopSnowTile.hpp @@ -13,12 +13,12 @@ class TopSnowTile : public Tile { public: - TopSnowTile(int id, int texture, Material* pMtl); + TopSnowTile(TileID id, int texture, Material* pMtl); AABB* getAABB(const Level*, const TilePos& pos) override; bool isCubeShaped() const override; bool isSolidRender() const override; - int getResource(int, Random*) const override; + int getResource(TileData data, Random*) const override; int getResourceCount(Random*) const override; bool mayPlace(const Level*, const TilePos& pos) const override; void neighborChanged(Level*, const TilePos& pos, TileID tile) override; diff --git a/source/world/tile/TorchTile.cpp b/source/world/tile/TorchTile.cpp index 216259390..64fc7669e 100644 --- a/source/world/tile/TorchTile.cpp +++ b/source/world/tile/TorchTile.cpp @@ -122,7 +122,7 @@ void TorchTile::neighborChanged(Level* level, const TilePos& pos, TileID tile) if (!checkCanSurvive(level, pos)) return; - int data = level->getData(pos); + TileData data = level->getData(pos); bool flag = false; if (!level->isSolidTile(pos.west()) && data == 1) flag = true; @@ -156,7 +156,7 @@ void TorchTile::onPlace(Level* level, const TilePos& pos) void TorchTile::setPlacedOnFace(Level* level, const TilePos& pos, Facing::Name face) { - int data = level->getData(pos); + TileData data = level->getData(pos); switch (face) { diff --git a/source/world/tile/TreeTile.cpp b/source/world/tile/TreeTile.cpp index 774f7b9a9..8ce88a700 100644 --- a/source/world/tile/TreeTile.cpp +++ b/source/world/tile/TreeTile.cpp @@ -14,7 +14,7 @@ TreeTile::TreeTile(int id) : Tile(id, Material::wood) m_TextureFrame = TEXTURE_LOG_SIDE; } -int TreeTile::getResource(int x, Random* random) const +int TreeTile::getResource(TileData data, Random* random) const { return Tile::treeTrunk->m_ID; } @@ -29,7 +29,7 @@ int TreeTile::getSpawnResourcesAuxValue(int x) const return x; } -int TreeTile::getTexture(Facing::Name face, int data) const +int TreeTile::getTexture(Facing::Name face, TileData data) const { if (face == Facing::UP || face == Facing::DOWN) return TEXTURE_LOG_TOP; @@ -61,7 +61,7 @@ void TreeTile::onRemove(Level* level, const TilePos& pos) TileID tid = level->getTile(pos + tp); if (tid != Tile::leaves->m_ID) continue; - int data = level->getData(pos + tp); + TileData data = level->getData(pos + tp); if (data & 4) continue; diff --git a/source/world/tile/TreeTile.hpp b/source/world/tile/TreeTile.hpp index 355dfc26f..4f0a3c2f0 100644 --- a/source/world/tile/TreeTile.hpp +++ b/source/world/tile/TreeTile.hpp @@ -15,9 +15,9 @@ class TreeTile : public Tile public: TreeTile(int ID); - int getResource(int, Random*) const override; + int getResource(TileData, Random*) const override; int getResourceCount(Random*) const override; int getSpawnResourcesAuxValue(int) const override; - int getTexture(Facing::Name face, int data) const override; + int getTexture(Facing::Name face, TileData data) const override; void onRemove(Level*, const TilePos& pos) override; }; diff --git a/source/world/tile/Web.cpp b/source/world/tile/Web.cpp index a76834810..64eb30d2f 100644 --- a/source/world/tile/Web.cpp +++ b/source/world/tile/Web.cpp @@ -1,7 +1,7 @@ #include "Web.hpp" #include "world/level/Level.hpp" -Web::Web(int id, int texture) : Tile(id, texture, Material::web) +Web::Web(TileID id, int texture) : Tile(id, texture, Material::web) { } @@ -25,7 +25,7 @@ void Web::entityInside(Level*, const TilePos& pos, Entity* entity) const entity->m_bIsInWeb = true; } -int Web::getResource(int x, Random* random) const +int Web::getResource(TileData data, Random* random) const { return Item::string->m_itemID; } diff --git a/source/world/tile/Web.hpp b/source/world/tile/Web.hpp index b0fc514b3..16caa4904 100644 --- a/source/world/tile/Web.hpp +++ b/source/world/tile/Web.hpp @@ -5,12 +5,12 @@ class Web : public Tile { public: - Web(int id, int texture); + Web(TileID id, int texture); AABB* getAABB(const Level*, const TilePos& pos) override; virtual int getRenderShape() const override; virtual bool isCubeShaped() const override; virtual bool isSolidRender() const override; void entityInside(Level*, const TilePos& pos, Entity*) const override; - int getResource(int x, Random* random) const override; + int getResource(TileData data, Random* random) const override; }; diff --git a/thirdparty/stb_image/include b/thirdparty/stb_image/include index beebb24b9..f7f20f39f 160000 --- a/thirdparty/stb_image/include +++ b/thirdparty/stb_image/include @@ -1 +1 @@ -Subproject commit beebb24b945efdea3b9bba23affb8eb3ba8982e7 +Subproject commit f7f20f39fe4f206c6f19e26ebfef7b261ee59ee4 From d909f766cee36edfd515238c9a456a7c29df4fb5 Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Thu, 2 Oct 2025 20:03:29 -0500 Subject: [PATCH 046/293] Fix LevelChunk::setData() not returning a value --- source/world/level/levelgen/chunk/LevelChunk.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/world/level/levelgen/chunk/LevelChunk.cpp b/source/world/level/levelgen/chunk/LevelChunk.cpp index 31e6d854d..0822109de 100644 --- a/source/world/level/levelgen/chunk/LevelChunk.cpp +++ b/source/world/level/levelgen/chunk/LevelChunk.cpp @@ -657,6 +657,8 @@ bool LevelChunk::setData(const ChunkTilePos& pos, TileData data) return false; m_tileData.set(pos, data); + + return true; } // seems to set block data in 8192 block (4*16*128) chunks for some reason ? @@ -874,4 +876,4 @@ Random LevelChunk::getRandom(int32_t l) bool LevelChunk::isEmpty() { return false; -} \ No newline at end of file +} From f874d717ad5ad1bd7966d6e03e24a264ef547dd5 Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Sun, 12 Oct 2025 14:25:03 -0700 Subject: [PATCH 047/293] Fixed in-game GUI buttons not working for touch (#196) Co-authored-by: Brent --- platforms/macos/projects/Configuration/Settings_iOS.xcconfig | 2 +- source/client/app/Minecraft.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platforms/macos/projects/Configuration/Settings_iOS.xcconfig b/platforms/macos/projects/Configuration/Settings_iOS.xcconfig index d79311b84..37027b277 100644 --- a/platforms/macos/projects/Configuration/Settings_iOS.xcconfig +++ b/platforms/macos/projects/Configuration/Settings_iOS.xcconfig @@ -19,5 +19,5 @@ ARCHS_IOS = armv6 armv7 armv7s arm64 ARCHS = $(ARCHS_IOS) // Should be raised if Xcode gives ambiguous error -IPHONEOS_DEPLOYMENT_TARGET = 3.0 // iOS 3.0 +//IPHONEOS_DEPLOYMENT_TARGET = 3.0 // iOS 3.0 TARGETED_DEVICE_FAMILY = 1,2 // iPhone/iPad diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp index 374934f81..067406638 100644 --- a/source/client/app/Minecraft.cpp +++ b/source/client/app/Minecraft.cpp @@ -467,7 +467,7 @@ void Minecraft::tickInput() { // @HACK: on SDL1, we don't recenter the mouse every tick, meaning the user can // unintentionally click the hotbar while swinging their fist - if (!platform()->getRecenterMouseEveryTick() && m_pScreen) + if (platform()->getRecenterMouseEveryTick() || m_pScreen) m_gui.handleClick(1, Mouse::getX(), Mouse::getY()); } From 034ca1c523442a790bf14e3cd1679a30b4411262 Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Wed, 29 Oct 2025 01:43:17 -0700 Subject: [PATCH 048/293] Network Protocol V3 Support (#197) * Increased version number from 0.1.0 to 0.2.0 to reflect networking support for 0.2.* * Mobs and items replicate now! * Added MOD_POCKET_SURVIVAL * Enabled by default to give players something to do, and to improve experience with actual PE clients. * Fixed vertical mob jitter on multiplayer worlds * Added ordered client chunk requests * Overhauled ItemInstance to handle unknown items better (particularly in multiplayer) * Added Item and Tile pointer to ItemInstance to replace the ID integer * Fixed CompoundTag memory leak in ExternalFileLevelStorage::saveEntities() * Implemented packets! * AddMobPacket * MoveEntityPacket * SetEntityDataPacket * EntityEventPacket * SetHealthPacket * AnimatePacket * RespawnPacket * InteractPacket * LevelEventPacket * UseItemPacket * AddItemEntityPacket * TakeItemEntityPacket --------- Co-authored-by: Brent Da Mage --- GameMods.hpp | 1 + platforms/ios/minecraftpe-Info.plist | 4 +- .../Minecraft.xcodeproj/project.pbxproj | 403 +++++++++++++++++- platforms/windows/minecraftcpp.sln | 26 ++ .../windows/projects/Client/Client.vcxproj | 9 + .../projects/Client/Client.vcxproj.filters | 24 ++ .../windows/projects/Network/Network.vcxproj | 44 +- .../projects/Network/Network.vcxproj.filters | 141 +++++- .../windows/projects/Server/Server.vcxproj | 54 +++ .../projects/Server/Server.vcxproj.filters | 29 ++ .../windows/projects/World/World.vcxproj | 3 +- .../projects/World/World.vcxproj.filters | 9 +- source/CMakeLists.txt | 20 +- source/client/app/Minecraft.cpp | 233 +++++----- source/client/app/Minecraft.hpp | 11 +- source/client/gui/Gui.cpp | 4 +- .../client/gui/screens/ConvertWorldScreen.cpp | 2 +- .../client/gui/screens/CreateWorldScreen.cpp | 3 +- .../screens/IngameBlockSelectionScreen.cpp | 2 +- source/client/gui/screens/JoinGameScreen.cpp | 3 +- source/client/gui/screens/PauseScreen.cpp | 2 +- .../client/gui/screens/SelectWorldScreen.cpp | 7 +- source/client/gui/screens/StartMenuScreen.cpp | 10 +- .../client/multiplayer/MultiPlayerLevel.cpp | 54 +++ .../client/multiplayer/MultiPlayerLevel.hpp | 37 ++ .../multiplayer/MultiplayerLocalPlayer.cpp | 86 ++++ .../multiplayer/MultiplayerLocalPlayer.hpp | 22 + .../network/ClientSideNetworkHandler.cpp | 375 ++++++++++++++-- .../network/ClientSideNetworkHandler.hpp | 26 +- .../entity => client/player}/LocalPlayer.cpp | 105 +++-- .../entity => client/player}/LocalPlayer.hpp | 38 +- source/client/renderer/ItemInHandRenderer.cpp | 20 +- source/client/renderer/LevelRenderer.cpp | 16 + source/client/renderer/LevelRenderer.hpp | 3 + .../entity/EntityRenderDispatcher.cpp | 7 - .../renderer/entity/HumanoidMobRenderer.cpp | 10 +- .../client/renderer/entity/ItemRenderer.cpp | 38 +- source/common/Utils.hpp | 1 + source/nbt/CompoundTag.cpp | 24 +- source/nbt/CompoundTag.hpp | 13 +- source/network/MinecraftPackets.cpp | 26 ++ source/network/MinecraftPackets.hpp | 29 ++ source/network/NetEventCallback.cpp | 134 ++---- source/network/NetEventCallback.hpp | 83 ++-- source/network/Packet.hpp | 315 +------------- source/network/PacketUtil.cpp | 153 +++++++ source/network/PacketUtil.hpp | 7 + source/network/RakNetInstance.cpp | 18 +- source/network/RakNetInstance.hpp | 2 +- .../network/packets/AddItemEntityPacket.cpp | 55 +++ .../network/packets/AddItemEntityPacket.hpp | 34 ++ source/network/packets/AddMobPacket.cpp | 53 +++ source/network/packets/AddMobPacket.hpp | 28 ++ source/network/packets/AddPlayerPacket.cpp | 67 ++- source/network/packets/AddPlayerPacket.hpp | 27 ++ source/network/packets/AnimatePacket.cpp | 27 ++ source/network/packets/AnimatePacket.hpp | 29 ++ source/network/packets/ChunkDataPacket.cpp | 25 +- source/network/packets/ChunkDataPacket.hpp | 21 + source/network/packets/EntityEventPacket.cpp | 26 ++ source/network/packets/EntityEventPacket.hpp | 21 + source/network/packets/InteractPacket.cpp | 30 ++ source/network/packets/InteractPacket.hpp | 31 ++ source/network/packets/LevelDataPacket.cpp | 53 +-- source/network/packets/LevelDataPacket.hpp | 19 + source/network/packets/LevelEventPacket.cpp | 35 ++ source/network/packets/LevelEventPacket.hpp | 23 + source/network/packets/LoginPacket.cpp | 25 +- source/network/packets/LoginPacket.hpp | 28 ++ source/network/packets/LoginStatusPacket.cpp | 17 +- source/network/packets/LoginStatusPacket.hpp | 26 ++ source/network/packets/MessagePacket.cpp | 17 +- source/network/packets/MessagePacket.hpp | 20 + source/network/packets/MoveEntityPacket.cpp | 16 + source/network/packets/MoveEntityPacket.hpp | 23 + .../packets/MoveEntityPacket_PosRot.cpp | 47 ++ .../packets/MoveEntityPacket_PosRot.hpp | 19 + source/network/packets/MovePlayerPacket.cpp | 45 +- source/network/packets/MovePlayerPacket.hpp | 22 + source/network/packets/PlaceBlockPacket.cpp | 41 +- source/network/packets/PlaceBlockPacket.hpp | 35 ++ .../network/packets/PlayerEquipmentPacket.cpp | 21 +- .../network/packets/PlayerEquipmentPacket.hpp | 20 + source/network/packets/ReadyPacket.cpp | 17 +- source/network/packets/ReadyPacket.hpp | 18 + source/network/packets/RemoveBlockPacket.cpp | 29 +- source/network/packets/RemoveBlockPacket.hpp | 21 + source/network/packets/RemoveEntityPacket.cpp | 17 +- source/network/packets/RemoveEntityPacket.hpp | 19 + source/network/packets/RequestChunkPacket.cpp | 21 +- source/network/packets/RequestChunkPacket.hpp | 16 + source/network/packets/RespawnPacket.cpp | 30 ++ source/network/packets/RespawnPacket.hpp | 22 + .../network/packets/SetEntityDataPacket.cpp | 34 ++ .../network/packets/SetEntityDataPacket.hpp | 25 ++ source/network/packets/SetHealthPacket.cpp | 18 + source/network/packets/SetHealthPacket.hpp | 18 + source/network/packets/SetTimePacket.cpp | 17 +- source/network/packets/SetTimePacket.hpp | 18 + source/network/packets/StartGamePacket.cpp | 62 ++- source/network/packets/StartGamePacket.hpp | 28 ++ .../network/packets/TakeItemEntityPacket.cpp | 26 ++ .../network/packets/TakeItemEntityPacket.hpp | 25 ++ source/network/packets/UpdateBlockPacket.cpp | 33 +- source/network/packets/UpdateBlockPacket.hpp | 17 + source/network/packets/UseItemPacket.cpp | 49 +++ source/network/packets/UseItemPacket.hpp | 29 ++ source/server/ServerPlayer.cpp | 29 ++ source/server/ServerPlayer.hpp | 14 + .../ServerSideNetworkHandler.cpp | 366 +++++++++++++--- .../ServerSideNetworkHandler.hpp | 19 +- source/world/entity/Entity.cpp | 77 +++- source/world/entity/Entity.hpp | 79 +++- source/world/entity/EntityFactory.cpp | 2 +- source/world/entity/ItemEntity.cpp | 11 +- source/world/entity/Mob.cpp | 96 ++++- source/world/entity/Mob.hpp | 52 ++- source/world/entity/Player.cpp | 155 ++++--- source/world/entity/Player.hpp | 47 +- source/world/entity/SynchedEntityData.cpp | 227 +++++++++- source/world/entity/SynchedEntityData.hpp | 31 +- source/world/gamemode/GameMode.cpp | 38 +- source/world/gamemode/GameMode.hpp | 2 +- source/world/gamemode/GameType.hpp | 2 + source/world/gamemode/SurvivalMode.cpp | 51 ++- source/world/gamemode/SurvivalMode.hpp | 1 + source/world/item/AuxTileItem.cpp | 2 +- source/world/item/AuxTileItem.hpp | 2 +- source/world/item/CameraItem.cpp | 2 +- source/world/item/CameraItem.hpp | 2 +- source/world/item/ClothItem.cpp | 4 +- source/world/item/ClothItem.hpp | 4 +- source/world/item/DoorItem.cpp | 2 +- source/world/item/DoorItem.hpp | 2 +- source/world/item/Inventory.cpp | 200 +++++++-- source/world/item/Inventory.hpp | 27 +- source/world/item/Item.cpp | 51 ++- source/world/item/Item.hpp | 49 +-- source/world/item/ItemInstance.cpp | 313 +++++++++++--- source/world/item/ItemInstance.hpp | 63 ++- source/world/item/RocketItem.cpp | 2 +- source/world/item/RocketItem.hpp | 2 +- source/world/item/SlabItem.cpp | 2 +- source/world/item/SlabItem.hpp | 2 +- source/world/item/TileItem.cpp | 10 +- source/world/item/TileItem.hpp | 6 +- source/world/item/TilePlanterItem.cpp | 2 +- source/world/item/TilePlanterItem.hpp | 2 +- source/world/level/Dimension.cpp | 14 +- source/world/level/Level.cpp | 102 +++-- source/world/level/Level.hpp | 35 +- source/world/level/LevelEvent.hpp | 75 ++++ source/world/level/LevelListener.cpp | 60 --- source/world/level/LevelListener.hpp | 26 +- .../world/level/levelgen/chunk/ChunkPos.hpp | 5 + .../storage/ExternalFileLevelStorage.cpp | 1 + source/world/level/storage/LevelData.cpp | 15 +- source/world/level/storage/LevelData.hpp | 19 +- source/world/tile/DoorTile.cpp | 14 +- source/world/tile/DoorTile.hpp | 2 +- source/world/tile/RedStoneOreTile.cpp | 2 +- source/world/tile/RedStoneOreTile.hpp | 2 +- source/world/tile/RocketLauncherTile.cpp | 6 +- source/world/tile/RocketLauncherTile.hpp | 2 +- source/world/tile/StairTile.cpp | 2 +- source/world/tile/StairTile.hpp | 66 +-- source/world/tile/Tile.cpp | 4 +- source/world/tile/Tile.hpp | 2 +- thirdparty/stb_image/include | 2 +- 169 files changed, 5214 insertions(+), 1613 deletions(-) create mode 100644 platforms/windows/projects/Server/Server.vcxproj create mode 100644 platforms/windows/projects/Server/Server.vcxproj.filters create mode 100644 source/client/multiplayer/MultiPlayerLevel.cpp create mode 100644 source/client/multiplayer/MultiPlayerLevel.hpp create mode 100644 source/client/multiplayer/MultiplayerLocalPlayer.cpp create mode 100644 source/client/multiplayer/MultiplayerLocalPlayer.hpp rename source/{world/entity => client/player}/LocalPlayer.cpp (82%) rename source/{world/entity => client/player}/LocalPlayer.hpp (61%) create mode 100644 source/network/packets/AddItemEntityPacket.cpp create mode 100644 source/network/packets/AddItemEntityPacket.hpp create mode 100644 source/network/packets/AddMobPacket.cpp create mode 100644 source/network/packets/AddMobPacket.hpp create mode 100644 source/network/packets/AddPlayerPacket.hpp create mode 100644 source/network/packets/AnimatePacket.cpp create mode 100644 source/network/packets/AnimatePacket.hpp create mode 100644 source/network/packets/ChunkDataPacket.hpp create mode 100644 source/network/packets/EntityEventPacket.cpp create mode 100644 source/network/packets/EntityEventPacket.hpp create mode 100644 source/network/packets/InteractPacket.cpp create mode 100644 source/network/packets/InteractPacket.hpp create mode 100644 source/network/packets/LevelDataPacket.hpp create mode 100644 source/network/packets/LevelEventPacket.cpp create mode 100644 source/network/packets/LevelEventPacket.hpp create mode 100644 source/network/packets/LoginPacket.hpp create mode 100644 source/network/packets/LoginStatusPacket.hpp create mode 100644 source/network/packets/MessagePacket.hpp create mode 100644 source/network/packets/MoveEntityPacket.cpp create mode 100644 source/network/packets/MoveEntityPacket.hpp create mode 100644 source/network/packets/MoveEntityPacket_PosRot.cpp create mode 100644 source/network/packets/MoveEntityPacket_PosRot.hpp create mode 100644 source/network/packets/MovePlayerPacket.hpp create mode 100644 source/network/packets/PlaceBlockPacket.hpp create mode 100644 source/network/packets/PlayerEquipmentPacket.hpp create mode 100644 source/network/packets/ReadyPacket.hpp create mode 100644 source/network/packets/RemoveBlockPacket.hpp create mode 100644 source/network/packets/RemoveEntityPacket.hpp create mode 100644 source/network/packets/RequestChunkPacket.hpp create mode 100644 source/network/packets/RespawnPacket.cpp create mode 100644 source/network/packets/RespawnPacket.hpp create mode 100644 source/network/packets/SetEntityDataPacket.cpp create mode 100644 source/network/packets/SetEntityDataPacket.hpp create mode 100644 source/network/packets/SetHealthPacket.cpp create mode 100644 source/network/packets/SetHealthPacket.hpp create mode 100644 source/network/packets/SetTimePacket.hpp create mode 100644 source/network/packets/StartGamePacket.hpp create mode 100644 source/network/packets/TakeItemEntityPacket.cpp create mode 100644 source/network/packets/TakeItemEntityPacket.hpp create mode 100644 source/network/packets/UpdateBlockPacket.hpp create mode 100644 source/network/packets/UseItemPacket.cpp create mode 100644 source/network/packets/UseItemPacket.hpp create mode 100644 source/server/ServerPlayer.cpp create mode 100644 source/server/ServerPlayer.hpp rename source/{network => server}/ServerSideNetworkHandler.cpp (68%) rename source/{network => server}/ServerSideNetworkHandler.hpp (79%) create mode 100644 source/world/level/LevelEvent.hpp diff --git a/GameMods.hpp b/GameMods.hpp index f447ce60b..b102bd5a2 100644 --- a/GameMods.hpp +++ b/GameMods.hpp @@ -13,6 +13,7 @@ //#define MOD_USE_BIGGER_SCREEN_SIZE // Use a bigger screen size instead of 854x480 //#define MOD_DONT_COLOR_GRASS // Don't give the top of grass tiles a different color. (like Classic) @TODO: This does not do shit anymore //#define MOD_POPOUT_CONSOLE // Open a separate console aside from the game window. By default only the debugger can see our logs. Win32 Debug only. +#define MOD_POCKET_SURVIVAL // Has the survival inventory behave identically to that of legacy Pocket Edition, with some items being limited, and some unlimited. // Tests //#define TEST_SURVIVAL_MODE // Test survival mode. diff --git a/platforms/ios/minecraftpe-Info.plist b/platforms/ios/minecraftpe-Info.plist index ef8fd2e60..33b5f3d24 100644 --- a/platforms/ios/minecraftpe-Info.plist +++ b/platforms/ios/minecraftpe-Info.plist @@ -19,11 +19,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0 + 0.2.0 CFBundleSignature ???? CFBundleVersion - 1.0 + 0.2.0.0 LSApplicationCategoryType public.app-category.games LSRequiresIPhoneOS diff --git a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj index 5b619ebb5..783d060b7 100644 --- a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj +++ b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj @@ -13,7 +13,6 @@ 8406FD2E2AF1820700B09C1D /* Packet.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD63E2AC810620006A435 /* Packet.hpp */; }; 8406FD2F2AF1820700B09C1D /* PingedCompatibleServer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD64D2AC810620006A435 /* PingedCompatibleServer.hpp */; }; 8406FD302AF1820700B09C1D /* RakNetInstance.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD64F2AC810620006A435 /* RakNetInstance.hpp */; }; - 8406FD312AF1820700B09C1D /* ServerSideNetworkHandler.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD6512AC810620006A435 /* ServerSideNetworkHandler.hpp */; }; 8406FD322AF1823600B09C1D /* CThread.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD6272AC810620006A435 /* CThread.hpp */; }; 8406FD332AF1823600B09C1D /* Logger.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD6292AC810620006A435 /* Logger.hpp */; }; 8406FD352AF1823600B09C1D /* Matrix.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD62C2AC810620006A435 /* Matrix.hpp */; }; @@ -196,7 +195,6 @@ 8426107C2AE989730065905F /* StartGamePacket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD64B2AC810620006A435 /* StartGamePacket.cpp */; }; 8426107D2AE989730065905F /* UpdateBlockPacket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD64C2AC810620006A435 /* UpdateBlockPacket.cpp */; }; 8426107E2AE989730065905F /* RakNetInstance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD64E2AC810620006A435 /* RakNetInstance.cpp */; }; - 8426107F2AE989730065905F /* ServerSideNetworkHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD6502AC810620006A435 /* ServerSideNetworkHandler.cpp */; }; 842610882AE98A4C0065905F /* libRakNet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84FFBD7E2ACA2876005A8CCF /* libRakNet.a */; }; 8435BB192DCD47F400D38282 /* SoundStreamAL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8435BB182DCD47F400D38282 /* SoundStreamAL.cpp */; }; 8435BB1A2DCD47F400D38282 /* SoundStreamAL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8435BB182DCD47F400D38282 /* SoundStreamAL.cpp */; }; @@ -976,7 +974,6 @@ 84BF630C2AF18631008A9995 /* Entity.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD6582AC810620006A435 /* Entity.cpp */; }; 84BF630D2AF18631008A9995 /* FallingTile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD65A2AC810620006A435 /* FallingTile.cpp */; }; 84BF630E2AF18631008A9995 /* ItemEntity.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD65C2AC810620006A435 /* ItemEntity.cpp */; }; - 84BF630F2AF18631008A9995 /* LocalPlayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD65E2AC810620006A435 /* LocalPlayer.cpp */; }; 84BF63102AF18631008A9995 /* Mob.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD6602AC810620006A435 /* Mob.cpp */; }; 84BF63112AF18631008A9995 /* Player.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD6622AC810620006A435 /* Player.cpp */; }; 84BF63122AF18631008A9995 /* PrimedTnt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD6642AC810620006A435 /* PrimedTnt.cpp */; }; @@ -1085,7 +1082,6 @@ 84BF63792AF186C8008A9995 /* Entity.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD6592AC810620006A435 /* Entity.hpp */; }; 84BF637A2AF186C8008A9995 /* FallingTile.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD65B2AC810620006A435 /* FallingTile.hpp */; }; 84BF637B2AF186C8008A9995 /* ItemEntity.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD65D2AC810620006A435 /* ItemEntity.hpp */; }; - 84BF637C2AF186C8008A9995 /* LocalPlayer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD65F2AC810620006A435 /* LocalPlayer.hpp */; }; 84BF637D2AF186C8008A9995 /* Mob.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD6612AC810620006A435 /* Mob.hpp */; }; 84BF637E2AF186C8008A9995 /* Player.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD6632AC810620006A435 /* Player.hpp */; }; 84BF637F2AF186C8008A9995 /* PrimedTnt.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD6652AC810620006A435 /* PrimedTnt.hpp */; }; @@ -1322,6 +1318,61 @@ 84EE51312E8DCC9000D3DCA2 /* DataLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EE512F2E8DCC9000D3DCA2 /* DataLayer.cpp */; }; 84EE51322E8DCC9000D3DCA2 /* DataLayer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EE51302E8DCC9000D3DCA2 /* DataLayer.hpp */; }; 84EE51342E8DCD4900D3DCA2 /* TileChange.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EE51332E8DCD4900D3DCA2 /* TileChange.hpp */; }; + 84F77A002EA1BFB40045C907 /* libNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 842610682AE988D30065905F /* libNetwork.a */; }; + 84F77A032EA1BFF30045C907 /* libServer.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84F779FD2EA1BF8E0045C907 /* libServer.a */; }; + 84F77A092EA1C0050045C907 /* ServerPlayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F77A052EA1C0050045C907 /* ServerPlayer.cpp */; }; + 84F77A0A2EA1C0050045C907 /* ServerPlayer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A062EA1C0050045C907 /* ServerPlayer.hpp */; }; + 84F77A0B2EA1C0050045C907 /* ServerSideNetworkHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F77A072EA1C0050045C907 /* ServerSideNetworkHandler.cpp */; }; + 84F77A0C2EA1C0050045C907 /* ServerSideNetworkHandler.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A082EA1C0050045C907 /* ServerSideNetworkHandler.hpp */; }; + 84F77A372EA1C01C0045C907 /* AddItemEntityPacket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F77A0D2EA1C01B0045C907 /* AddItemEntityPacket.cpp */; }; + 84F77A382EA1C01C0045C907 /* AddItemEntityPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A0E2EA1C01B0045C907 /* AddItemEntityPacket.hpp */; }; + 84F77A392EA1C01C0045C907 /* AddMobPacket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F77A0F2EA1C01B0045C907 /* AddMobPacket.cpp */; }; + 84F77A3A2EA1C01C0045C907 /* AddMobPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A102EA1C01B0045C907 /* AddMobPacket.hpp */; }; + 84F77A3B2EA1C01C0045C907 /* AddPlayerPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A112EA1C01B0045C907 /* AddPlayerPacket.hpp */; }; + 84F77A3C2EA1C01C0045C907 /* AnimatePacket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F77A122EA1C01B0045C907 /* AnimatePacket.cpp */; }; + 84F77A3D2EA1C01C0045C907 /* AnimatePacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A132EA1C01B0045C907 /* AnimatePacket.hpp */; }; + 84F77A3E2EA1C01C0045C907 /* ChunkDataPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A142EA1C01B0045C907 /* ChunkDataPacket.hpp */; }; + 84F77A3F2EA1C01C0045C907 /* EntityEventPacket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F77A152EA1C01B0045C907 /* EntityEventPacket.cpp */; }; + 84F77A402EA1C01C0045C907 /* EntityEventPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A162EA1C01B0045C907 /* EntityEventPacket.hpp */; }; + 84F77A412EA1C01C0045C907 /* InteractPacket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F77A172EA1C01C0045C907 /* InteractPacket.cpp */; }; + 84F77A422EA1C01C0045C907 /* InteractPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A182EA1C01C0045C907 /* InteractPacket.hpp */; }; + 84F77A432EA1C01C0045C907 /* LevelDataPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A192EA1C01C0045C907 /* LevelDataPacket.hpp */; }; + 84F77A442EA1C01C0045C907 /* LevelEventPacket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F77A1A2EA1C01C0045C907 /* LevelEventPacket.cpp */; }; + 84F77A452EA1C01C0045C907 /* LevelEventPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A1B2EA1C01C0045C907 /* LevelEventPacket.hpp */; }; + 84F77A462EA1C01C0045C907 /* LoginPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A1C2EA1C01C0045C907 /* LoginPacket.hpp */; }; + 84F77A472EA1C01C0045C907 /* LoginStatusPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A1D2EA1C01C0045C907 /* LoginStatusPacket.hpp */; }; + 84F77A482EA1C01C0045C907 /* MessagePacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A1E2EA1C01C0045C907 /* MessagePacket.hpp */; }; + 84F77A492EA1C01C0045C907 /* MoveEntityPacket_PosRot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F77A1F2EA1C01C0045C907 /* MoveEntityPacket_PosRot.cpp */; }; + 84F77A4A2EA1C01C0045C907 /* MoveEntityPacket_PosRot.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A202EA1C01C0045C907 /* MoveEntityPacket_PosRot.hpp */; }; + 84F77A4B2EA1C01C0045C907 /* MoveEntityPacket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F77A212EA1C01C0045C907 /* MoveEntityPacket.cpp */; }; + 84F77A4C2EA1C01C0045C907 /* MoveEntityPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A222EA1C01C0045C907 /* MoveEntityPacket.hpp */; }; + 84F77A4D2EA1C01C0045C907 /* MovePlayerPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A232EA1C01C0045C907 /* MovePlayerPacket.hpp */; }; + 84F77A4E2EA1C01C0045C907 /* PlaceBlockPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A242EA1C01C0045C907 /* PlaceBlockPacket.hpp */; }; + 84F77A4F2EA1C01C0045C907 /* PlayerEquipmentPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A252EA1C01C0045C907 /* PlayerEquipmentPacket.hpp */; }; + 84F77A502EA1C01C0045C907 /* ReadyPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A262EA1C01C0045C907 /* ReadyPacket.hpp */; }; + 84F77A512EA1C01C0045C907 /* RemoveBlockPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A272EA1C01C0045C907 /* RemoveBlockPacket.hpp */; }; + 84F77A522EA1C01C0045C907 /* RemoveEntityPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A282EA1C01C0045C907 /* RemoveEntityPacket.hpp */; }; + 84F77A532EA1C01C0045C907 /* RequestChunkPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A292EA1C01C0045C907 /* RequestChunkPacket.hpp */; }; + 84F77A542EA1C01C0045C907 /* RespawnPacket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F77A2A2EA1C01C0045C907 /* RespawnPacket.cpp */; }; + 84F77A552EA1C01C0045C907 /* RespawnPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A2B2EA1C01C0045C907 /* RespawnPacket.hpp */; }; + 84F77A562EA1C01C0045C907 /* SetEntityDataPacket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F77A2C2EA1C01C0045C907 /* SetEntityDataPacket.cpp */; }; + 84F77A572EA1C01C0045C907 /* SetEntityDataPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A2D2EA1C01C0045C907 /* SetEntityDataPacket.hpp */; }; + 84F77A582EA1C01C0045C907 /* SetHealthPacket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F77A2E2EA1C01C0045C907 /* SetHealthPacket.cpp */; }; + 84F77A592EA1C01C0045C907 /* SetHealthPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A2F2EA1C01C0045C907 /* SetHealthPacket.hpp */; }; + 84F77A5A2EA1C01C0045C907 /* SetTimePacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A302EA1C01C0045C907 /* SetTimePacket.hpp */; }; + 84F77A5B2EA1C01C0045C907 /* StartGamePacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A312EA1C01C0045C907 /* StartGamePacket.hpp */; }; + 84F77A5C2EA1C01C0045C907 /* TakeItemEntityPacket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F77A322EA1C01C0045C907 /* TakeItemEntityPacket.cpp */; }; + 84F77A5D2EA1C01C0045C907 /* TakeItemEntityPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A332EA1C01C0045C907 /* TakeItemEntityPacket.hpp */; }; + 84F77A5E2EA1C01C0045C907 /* UpdateBlockPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A342EA1C01C0045C907 /* UpdateBlockPacket.hpp */; }; + 84F77A5F2EA1C01C0045C907 /* UseItemPacket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F77A352EA1C01C0045C907 /* UseItemPacket.cpp */; }; + 84F77A602EA1C01C0045C907 /* UseItemPacket.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A362EA1C01C0045C907 /* UseItemPacket.hpp */; }; + 84F77A622EA1C0610045C907 /* LevelEvent.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A612EA1C0610045C907 /* LevelEvent.hpp */; }; + 84F77A682EA1C0A10045C907 /* MultiPlayerLevel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F77A642EA1C0A10045C907 /* MultiPlayerLevel.cpp */; }; + 84F77A692EA1C0A10045C907 /* MultiPlayerLevel.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A652EA1C0A10045C907 /* MultiPlayerLevel.hpp */; }; + 84F77A6A2EA1C0A10045C907 /* MultiplayerLocalPlayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F77A662EA1C0A10045C907 /* MultiplayerLocalPlayer.cpp */; }; + 84F77A6B2EA1C0A10045C907 /* MultiplayerLocalPlayer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A672EA1C0A10045C907 /* MultiplayerLocalPlayer.hpp */; }; + 84F77A6E2EA1C27B0045C907 /* LocalPlayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F77A6C2EA1C27B0045C907 /* LocalPlayer.cpp */; }; + 84F77A6F2EA1C27B0045C907 /* LocalPlayer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84F77A6D2EA1C27B0045C907 /* LocalPlayer.hpp */; }; 84FFBE952ACA3415005A8CCF /* _FindFirst.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD73A2AC810620006A435 /* _FindFirst.cpp */; }; 84FFBE962ACA3415005A8CCF /* Base64Encoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD73E2AC810620006A435 /* Base64Encoder.cpp */; }; 84FFBE972ACA3415005A8CCF /* BitStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD7402AC810620006A435 /* BitStream.cpp */; }; @@ -1540,6 +1591,20 @@ remoteGlobalIDString = 8406FD162AF1814500B09C1D; remoteInfo = Renderer; }; + 84F779FE2EA1BFA40045C907 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 8489B08F2A86D4B2004CA8EC /* Project object */; + proxyType = 1; + remoteGlobalIDString = 842610672AE988D30065905F; + remoteInfo = Network; + }; + 84F77A012EA1BFC90045C907 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 8489B08F2A86D4B2004CA8EC /* Project object */; + proxyType = 1; + remoteGlobalIDString = 84F779CE2EA1BF8E0045C907; + remoteInfo = Server; + }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -1701,8 +1766,6 @@ 840DD64D2AC810620006A435 /* PingedCompatibleServer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PingedCompatibleServer.hpp; sourceTree = ""; }; 840DD64E2AC810620006A435 /* RakNetInstance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RakNetInstance.cpp; sourceTree = ""; }; 840DD64F2AC810620006A435 /* RakNetInstance.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RakNetInstance.hpp; sourceTree = ""; }; - 840DD6502AC810620006A435 /* ServerSideNetworkHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServerSideNetworkHandler.cpp; sourceTree = ""; }; - 840DD6512AC810620006A435 /* ServerSideNetworkHandler.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ServerSideNetworkHandler.hpp; sourceTree = ""; }; 840DD6542AC810620006A435 /* GL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GL.cpp; sourceTree = ""; }; 840DD6552AC810620006A435 /* GL.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = GL.hpp; sourceTree = ""; }; 840DD6582AC810620006A435 /* Entity.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Entity.cpp; sourceTree = ""; }; @@ -1711,8 +1774,6 @@ 840DD65B2AC810620006A435 /* FallingTile.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FallingTile.hpp; sourceTree = ""; }; 840DD65C2AC810620006A435 /* ItemEntity.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ItemEntity.cpp; sourceTree = ""; }; 840DD65D2AC810620006A435 /* ItemEntity.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ItemEntity.hpp; sourceTree = ""; }; - 840DD65E2AC810620006A435 /* LocalPlayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LocalPlayer.cpp; sourceTree = ""; }; - 840DD65F2AC810620006A435 /* LocalPlayer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = LocalPlayer.hpp; sourceTree = ""; }; 840DD6602AC810620006A435 /* Mob.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Mob.cpp; sourceTree = ""; }; 840DD6612AC810620006A435 /* Mob.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Mob.hpp; sourceTree = ""; }; 840DD6622AC810620006A435 /* Player.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Player.cpp; sourceTree = ""; }; @@ -3035,6 +3096,60 @@ 84EE512F2E8DCC9000D3DCA2 /* DataLayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DataLayer.cpp; sourceTree = ""; }; 84EE51302E8DCC9000D3DCA2 /* DataLayer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DataLayer.hpp; sourceTree = ""; }; 84EE51332E8DCD4900D3DCA2 /* TileChange.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TileChange.hpp; sourceTree = ""; }; + 84F779FD2EA1BF8E0045C907 /* libServer.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libServer.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 84F77A052EA1C0050045C907 /* ServerPlayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServerPlayer.cpp; sourceTree = ""; }; + 84F77A062EA1C0050045C907 /* ServerPlayer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ServerPlayer.hpp; sourceTree = ""; }; + 84F77A072EA1C0050045C907 /* ServerSideNetworkHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServerSideNetworkHandler.cpp; sourceTree = ""; }; + 84F77A082EA1C0050045C907 /* ServerSideNetworkHandler.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ServerSideNetworkHandler.hpp; sourceTree = ""; }; + 84F77A0D2EA1C01B0045C907 /* AddItemEntityPacket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AddItemEntityPacket.cpp; sourceTree = ""; }; + 84F77A0E2EA1C01B0045C907 /* AddItemEntityPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AddItemEntityPacket.hpp; sourceTree = ""; }; + 84F77A0F2EA1C01B0045C907 /* AddMobPacket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AddMobPacket.cpp; sourceTree = ""; }; + 84F77A102EA1C01B0045C907 /* AddMobPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AddMobPacket.hpp; sourceTree = ""; }; + 84F77A112EA1C01B0045C907 /* AddPlayerPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AddPlayerPacket.hpp; sourceTree = ""; }; + 84F77A122EA1C01B0045C907 /* AnimatePacket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AnimatePacket.cpp; sourceTree = ""; }; + 84F77A132EA1C01B0045C907 /* AnimatePacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AnimatePacket.hpp; sourceTree = ""; }; + 84F77A142EA1C01B0045C907 /* ChunkDataPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ChunkDataPacket.hpp; sourceTree = ""; }; + 84F77A152EA1C01B0045C907 /* EntityEventPacket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EntityEventPacket.cpp; sourceTree = ""; }; + 84F77A162EA1C01B0045C907 /* EntityEventPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = EntityEventPacket.hpp; sourceTree = ""; }; + 84F77A172EA1C01C0045C907 /* InteractPacket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InteractPacket.cpp; sourceTree = ""; }; + 84F77A182EA1C01C0045C907 /* InteractPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = InteractPacket.hpp; sourceTree = ""; }; + 84F77A192EA1C01C0045C907 /* LevelDataPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = LevelDataPacket.hpp; sourceTree = ""; }; + 84F77A1A2EA1C01C0045C907 /* LevelEventPacket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LevelEventPacket.cpp; sourceTree = ""; }; + 84F77A1B2EA1C01C0045C907 /* LevelEventPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = LevelEventPacket.hpp; sourceTree = ""; }; + 84F77A1C2EA1C01C0045C907 /* LoginPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = LoginPacket.hpp; sourceTree = ""; }; + 84F77A1D2EA1C01C0045C907 /* LoginStatusPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = LoginStatusPacket.hpp; sourceTree = ""; }; + 84F77A1E2EA1C01C0045C907 /* MessagePacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MessagePacket.hpp; sourceTree = ""; }; + 84F77A1F2EA1C01C0045C907 /* MoveEntityPacket_PosRot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MoveEntityPacket_PosRot.cpp; sourceTree = ""; }; + 84F77A202EA1C01C0045C907 /* MoveEntityPacket_PosRot.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MoveEntityPacket_PosRot.hpp; sourceTree = ""; }; + 84F77A212EA1C01C0045C907 /* MoveEntityPacket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MoveEntityPacket.cpp; sourceTree = ""; }; + 84F77A222EA1C01C0045C907 /* MoveEntityPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MoveEntityPacket.hpp; sourceTree = ""; }; + 84F77A232EA1C01C0045C907 /* MovePlayerPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MovePlayerPacket.hpp; sourceTree = ""; }; + 84F77A242EA1C01C0045C907 /* PlaceBlockPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PlaceBlockPacket.hpp; sourceTree = ""; }; + 84F77A252EA1C01C0045C907 /* PlayerEquipmentPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PlayerEquipmentPacket.hpp; sourceTree = ""; }; + 84F77A262EA1C01C0045C907 /* ReadyPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ReadyPacket.hpp; sourceTree = ""; }; + 84F77A272EA1C01C0045C907 /* RemoveBlockPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RemoveBlockPacket.hpp; sourceTree = ""; }; + 84F77A282EA1C01C0045C907 /* RemoveEntityPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RemoveEntityPacket.hpp; sourceTree = ""; }; + 84F77A292EA1C01C0045C907 /* RequestChunkPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RequestChunkPacket.hpp; sourceTree = ""; }; + 84F77A2A2EA1C01C0045C907 /* RespawnPacket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RespawnPacket.cpp; sourceTree = ""; }; + 84F77A2B2EA1C01C0045C907 /* RespawnPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RespawnPacket.hpp; sourceTree = ""; }; + 84F77A2C2EA1C01C0045C907 /* SetEntityDataPacket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SetEntityDataPacket.cpp; sourceTree = ""; }; + 84F77A2D2EA1C01C0045C907 /* SetEntityDataPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SetEntityDataPacket.hpp; sourceTree = ""; }; + 84F77A2E2EA1C01C0045C907 /* SetHealthPacket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SetHealthPacket.cpp; sourceTree = ""; }; + 84F77A2F2EA1C01C0045C907 /* SetHealthPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SetHealthPacket.hpp; sourceTree = ""; }; + 84F77A302EA1C01C0045C907 /* SetTimePacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SetTimePacket.hpp; sourceTree = ""; }; + 84F77A312EA1C01C0045C907 /* StartGamePacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StartGamePacket.hpp; sourceTree = ""; }; + 84F77A322EA1C01C0045C907 /* TakeItemEntityPacket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TakeItemEntityPacket.cpp; sourceTree = ""; }; + 84F77A332EA1C01C0045C907 /* TakeItemEntityPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TakeItemEntityPacket.hpp; sourceTree = ""; }; + 84F77A342EA1C01C0045C907 /* UpdateBlockPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UpdateBlockPacket.hpp; sourceTree = ""; }; + 84F77A352EA1C01C0045C907 /* UseItemPacket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UseItemPacket.cpp; sourceTree = ""; }; + 84F77A362EA1C01C0045C907 /* UseItemPacket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UseItemPacket.hpp; sourceTree = ""; }; + 84F77A612EA1C0610045C907 /* LevelEvent.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = LevelEvent.hpp; sourceTree = ""; }; + 84F77A642EA1C0A10045C907 /* MultiPlayerLevel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MultiPlayerLevel.cpp; sourceTree = ""; }; + 84F77A652EA1C0A10045C907 /* MultiPlayerLevel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MultiPlayerLevel.hpp; sourceTree = ""; }; + 84F77A662EA1C0A10045C907 /* MultiplayerLocalPlayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MultiplayerLocalPlayer.cpp; sourceTree = ""; }; + 84F77A672EA1C0A10045C907 /* MultiplayerLocalPlayer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MultiplayerLocalPlayer.hpp; sourceTree = ""; }; + 84F77A6C2EA1C27B0045C907 /* LocalPlayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LocalPlayer.cpp; sourceTree = ""; }; + 84F77A6D2EA1C27B0045C907 /* LocalPlayer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = LocalPlayer.hpp; sourceTree = ""; }; 84FFBD7E2ACA2876005A8CCF /* libRakNet.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRakNet.a; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -3122,6 +3237,7 @@ 84B8AF872AF18A2C008DE93D /* libCommon.a in Frameworks */, 84B8AF882AF18A2C008DE93D /* libNetwork.a in Frameworks */, 84E8DCE52E84ACBC00B30789 /* libRenderer.a in Frameworks */, + 84F77A032EA1BFF30045C907 /* libServer.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3148,6 +3264,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 84F779E12EA1BF8E0045C907 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 84F77A002EA1BFB40045C907 /* libNetwork.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 84FFBD7B2ACA2876005A8CCF /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -3181,6 +3305,7 @@ 84CCBC4E2E61857800E251AF /* nbt */, 840DD6392AC810620006A435 /* network */, 840DD6522AC810620006A435 /* renderer */, + 84F77A042EA1C0050045C907 /* server */, 840DD6562AC810620006A435 /* world */, ); name = source; @@ -3193,6 +3318,7 @@ 840DD57D2AC810620006A435 /* app */, 840DD5862AC810620006A435 /* gui */, 840DD5BD2AC810620006A435 /* model */, + 84F77A632EA1C0A10045C907 /* multiplayer */, 840DD5C62AC810620006A435 /* network */, 840DD5C92AC810620006A435 /* options */, 840DD5CC2AC810620006A435 /* player */, @@ -3358,6 +3484,8 @@ isa = PBXGroup; children = ( 840DD5CD2AC810620006A435 /* input */, + 84F77A6C2EA1C27B0045C907 /* LocalPlayer.cpp */, + 84F77A6D2EA1C27B0045C907 /* LocalPlayer.hpp */, ); path = player; sourceTree = ""; @@ -3485,8 +3613,6 @@ 84CCBC962E61886800E251AF /* RakIO.hpp */, 840DD64E2AC810620006A435 /* RakNetInstance.cpp */, 840DD64F2AC810620006A435 /* RakNetInstance.hpp */, - 840DD6502AC810620006A435 /* ServerSideNetworkHandler.cpp */, - 840DD6512AC810620006A435 /* ServerSideNetworkHandler.hpp */, ); path = network; sourceTree = ""; @@ -3494,22 +3620,64 @@ 840DD63F2AC810620006A435 /* packets */ = { isa = PBXGroup; children = ( + 84F77A0D2EA1C01B0045C907 /* AddItemEntityPacket.cpp */, + 84F77A0E2EA1C01B0045C907 /* AddItemEntityPacket.hpp */, + 84F77A0F2EA1C01B0045C907 /* AddMobPacket.cpp */, + 84F77A102EA1C01B0045C907 /* AddMobPacket.hpp */, 840DD6402AC810620006A435 /* AddPlayerPacket.cpp */, + 84F77A112EA1C01B0045C907 /* AddPlayerPacket.hpp */, + 84F77A122EA1C01B0045C907 /* AnimatePacket.cpp */, + 84F77A132EA1C01B0045C907 /* AnimatePacket.hpp */, 840DD6412AC810620006A435 /* ChunkDataPacket.cpp */, + 84F77A142EA1C01B0045C907 /* ChunkDataPacket.hpp */, + 84F77A152EA1C01B0045C907 /* EntityEventPacket.cpp */, + 84F77A162EA1C01B0045C907 /* EntityEventPacket.hpp */, + 84F77A172EA1C01C0045C907 /* InteractPacket.cpp */, + 84F77A182EA1C01C0045C907 /* InteractPacket.hpp */, 840DD6422AC810620006A435 /* LevelDataPacket.cpp */, + 84F77A192EA1C01C0045C907 /* LevelDataPacket.hpp */, + 84F77A1A2EA1C01C0045C907 /* LevelEventPacket.cpp */, + 84F77A1B2EA1C01C0045C907 /* LevelEventPacket.hpp */, 840DD6432AC810620006A435 /* LoginPacket.cpp */, + 84F77A1C2EA1C01C0045C907 /* LoginPacket.hpp */, 8470AF322BE9B63900BCA54E /* LoginStatusPacket.cpp */, + 84F77A1D2EA1C01C0045C907 /* LoginStatusPacket.hpp */, 840DD6442AC810620006A435 /* MessagePacket.cpp */, + 84F77A1E2EA1C01C0045C907 /* MessagePacket.hpp */, + 84F77A212EA1C01C0045C907 /* MoveEntityPacket.cpp */, + 84F77A222EA1C01C0045C907 /* MoveEntityPacket.hpp */, + 84F77A1F2EA1C01C0045C907 /* MoveEntityPacket_PosRot.cpp */, + 84F77A202EA1C01C0045C907 /* MoveEntityPacket_PosRot.hpp */, 840DD6452AC810620006A435 /* MovePlayerPacket.cpp */, + 84F77A232EA1C01C0045C907 /* MovePlayerPacket.hpp */, 840DD6462AC810620006A435 /* PlaceBlockPacket.cpp */, + 84F77A242EA1C01C0045C907 /* PlaceBlockPacket.hpp */, 840DD6472AC810620006A435 /* PlayerEquipmentPacket.cpp */, + 84F77A252EA1C01C0045C907 /* PlayerEquipmentPacket.hpp */, 8470AF332BE9B63900BCA54E /* ReadyPacket.cpp */, + 84F77A262EA1C01C0045C907 /* ReadyPacket.hpp */, 840DD6482AC810620006A435 /* RemoveBlockPacket.cpp */, + 84F77A272EA1C01C0045C907 /* RemoveBlockPacket.hpp */, 840DD6492AC810620006A435 /* RemoveEntityPacket.cpp */, + 84F77A282EA1C01C0045C907 /* RemoveEntityPacket.hpp */, 840DD64A2AC810620006A435 /* RequestChunkPacket.cpp */, + 84F77A292EA1C01C0045C907 /* RequestChunkPacket.hpp */, + 84F77A2A2EA1C01C0045C907 /* RespawnPacket.cpp */, + 84F77A2B2EA1C01C0045C907 /* RespawnPacket.hpp */, + 84F77A2C2EA1C01C0045C907 /* SetEntityDataPacket.cpp */, + 84F77A2D2EA1C01C0045C907 /* SetEntityDataPacket.hpp */, + 84F77A2E2EA1C01C0045C907 /* SetHealthPacket.cpp */, + 84F77A2F2EA1C01C0045C907 /* SetHealthPacket.hpp */, 8470AF342BE9B63900BCA54E /* SetTimePacket.cpp */, + 84F77A302EA1C01C0045C907 /* SetTimePacket.hpp */, 840DD64B2AC810620006A435 /* StartGamePacket.cpp */, + 84F77A312EA1C01C0045C907 /* StartGamePacket.hpp */, + 84F77A322EA1C01C0045C907 /* TakeItemEntityPacket.cpp */, + 84F77A332EA1C01C0045C907 /* TakeItemEntityPacket.hpp */, 840DD64C2AC810620006A435 /* UpdateBlockPacket.cpp */, + 84F77A342EA1C01C0045C907 /* UpdateBlockPacket.hpp */, + 84F77A352EA1C01C0045C907 /* UseItemPacket.cpp */, + 84F77A362EA1C01C0045C907 /* UseItemPacket.hpp */, ); path = packets; sourceTree = ""; @@ -3573,8 +3741,6 @@ 840DD65B2AC810620006A435 /* FallingTile.hpp */, 840DD65C2AC810620006A435 /* ItemEntity.cpp */, 840DD65D2AC810620006A435 /* ItemEntity.hpp */, - 840DD65E2AC810620006A435 /* LocalPlayer.cpp */, - 840DD65F2AC810620006A435 /* LocalPlayer.hpp */, 840DD6602AC810620006A435 /* Mob.cpp */, 840DD6612AC810620006A435 /* Mob.hpp */, 8445E79A2D769329008DC834 /* MobCategory.cpp */, @@ -3663,6 +3829,7 @@ 840DD6822AC810620006A435 /* Explosion.hpp */, 840DD6832AC810620006A435 /* Level.cpp */, 840DD6842AC810620006A435 /* Level.hpp */, + 84F77A612EA1C0610045C907 /* LevelEvent.hpp */, 840DD6852AC810620006A435 /* levelgen */, 840DD6AF2AC810620006A435 /* LevelListener.cpp */, 840DD6B02AC810620006A435 /* LevelListener.hpp */, @@ -4571,6 +4738,7 @@ 84498A832AF18C7A005EF5A5 /* libZLib.a */, 84CCBC452E61849800E251AF /* libNBT.a */, 844496762E76685C008CF2E0 /* MinecraftClient.SDL1 */, + 84F779FD2EA1BF8E0045C907 /* libServer.a */, ); name = Products; sourceTree = ""; @@ -5513,6 +5681,28 @@ path = sdl; sourceTree = ""; }; + 84F77A042EA1C0050045C907 /* server */ = { + isa = PBXGroup; + children = ( + 84F77A052EA1C0050045C907 /* ServerPlayer.cpp */, + 84F77A062EA1C0050045C907 /* ServerPlayer.hpp */, + 84F77A072EA1C0050045C907 /* ServerSideNetworkHandler.cpp */, + 84F77A082EA1C0050045C907 /* ServerSideNetworkHandler.hpp */, + ); + path = server; + sourceTree = ""; + }; + 84F77A632EA1C0A10045C907 /* multiplayer */ = { + isa = PBXGroup; + children = ( + 84F77A642EA1C0A10045C907 /* MultiPlayerLevel.cpp */, + 84F77A652EA1C0A10045C907 /* MultiPlayerLevel.hpp */, + 84F77A662EA1C0A10045C907 /* MultiplayerLocalPlayer.cpp */, + 84F77A672EA1C0A10045C907 /* MultiplayerLocalPlayer.hpp */, + ); + path = multiplayer; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -5528,13 +5718,41 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 84F77A462EA1C01C0045C907 /* LoginPacket.hpp in Headers */, + 84F77A3E2EA1C01C0045C907 /* ChunkDataPacket.hpp in Headers */, 8406FD2C2AF1820700B09C1D /* MinecraftPackets.hpp in Headers */, + 84F77A5B2EA1C01C0045C907 /* StartGamePacket.hpp in Headers */, + 84F77A4E2EA1C01C0045C907 /* PlaceBlockPacket.hpp in Headers */, + 84F77A3A2EA1C01C0045C907 /* AddMobPacket.hpp in Headers */, + 84F77A3D2EA1C01C0045C907 /* AnimatePacket.hpp in Headers */, + 84F77A532EA1C01C0045C907 /* RequestChunkPacket.hpp in Headers */, 8406FD2D2AF1820700B09C1D /* NetEventCallback.hpp in Headers */, + 84F77A382EA1C01C0045C907 /* AddItemEntityPacket.hpp in Headers */, + 84F77A432EA1C01C0045C907 /* LevelDataPacket.hpp in Headers */, + 84F77A5D2EA1C01C0045C907 /* TakeItemEntityPacket.hpp in Headers */, + 84F77A482EA1C01C0045C907 /* MessagePacket.hpp in Headers */, + 84F77A552EA1C01C0045C907 /* RespawnPacket.hpp in Headers */, + 84F77A402EA1C01C0045C907 /* EntityEventPacket.hpp in Headers */, 8406FD2E2AF1820700B09C1D /* Packet.hpp in Headers */, 8406FD2F2AF1820700B09C1D /* PingedCompatibleServer.hpp in Headers */, 8406FD302AF1820700B09C1D /* RakNetInstance.hpp in Headers */, + 84F77A4C2EA1C01C0045C907 /* MoveEntityPacket.hpp in Headers */, + 84F77A3B2EA1C01C0045C907 /* AddPlayerPacket.hpp in Headers */, + 84F77A592EA1C01C0045C907 /* SetHealthPacket.hpp in Headers */, + 84F77A572EA1C01C0045C907 /* SetEntityDataPacket.hpp in Headers */, + 84F77A5E2EA1C01C0045C907 /* UpdateBlockPacket.hpp in Headers */, + 84F77A602EA1C01C0045C907 /* UseItemPacket.hpp in Headers */, + 84F77A452EA1C01C0045C907 /* LevelEventPacket.hpp in Headers */, + 84F77A4A2EA1C01C0045C907 /* MoveEntityPacket_PosRot.hpp in Headers */, 84CCBC982E61886800E251AF /* RakIO.hpp in Headers */, - 8406FD312AF1820700B09C1D /* ServerSideNetworkHandler.hpp in Headers */, + 84F77A4D2EA1C01C0045C907 /* MovePlayerPacket.hpp in Headers */, + 84F77A4F2EA1C01C0045C907 /* PlayerEquipmentPacket.hpp in Headers */, + 84F77A522EA1C01C0045C907 /* RemoveEntityPacket.hpp in Headers */, + 84F77A5A2EA1C01C0045C907 /* SetTimePacket.hpp in Headers */, + 84F77A422EA1C01C0045C907 /* InteractPacket.hpp in Headers */, + 84F77A472EA1C01C0045C907 /* LoginStatusPacket.hpp in Headers */, + 84F77A502EA1C01C0045C907 /* ReadyPacket.hpp in Headers */, + 84F77A512EA1C01C0045C907 /* RemoveBlockPacket.hpp in Headers */, 8470AF312BE9B62600BCA54E /* PacketUtil.hpp in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -5570,7 +5788,9 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 84F77A6B2EA1C0A10045C907 /* MultiplayerLocalPlayer.hpp in Headers */, 84B8AF362AF189D8008DE93D /* App.hpp in Headers */, + 84F77A692EA1C0A10045C907 /* MultiPlayerLevel.hpp in Headers */, 84B8AF372AF189D8008DE93D /* AppPlatform.hpp in Headers */, 84B8AF382AF189D8008DE93D /* Minecraft.hpp in Headers */, 84B8AF392AF189D8008DE93D /* NinecraftApp.hpp in Headers */, @@ -5608,6 +5828,7 @@ 84B8AF572AF189D8008DE93D /* PolygonQuad.hpp in Headers */, 84B8AF582AF189D8008DE93D /* ClientSideNetworkHandler.hpp in Headers */, 84B8AF592AF189D8008DE93D /* Options.hpp in Headers */, + 84F77A6F2EA1C27B0045C907 /* LocalPlayer.hpp in Headers */, 84B8AF5A2AF189D8008DE93D /* Controller.hpp in Headers */, 84B8AF5B2AF189D8008DE93D /* ControllerTurnInput.hpp in Headers */, 84B8AF5C2AF189D8008DE93D /* ITurnInput.hpp in Headers */, @@ -5708,7 +5929,6 @@ 84BF637A2AF186C8008A9995 /* FallingTile.hpp in Headers */, 84E1C9D42E7FDC26007D2F5D /* FenceTile.hpp in Headers */, 84BF637B2AF186C8008A9995 /* ItemEntity.hpp in Headers */, - 84BF637C2AF186C8008A9995 /* LocalPlayer.hpp in Headers */, 84BF637D2AF186C8008A9995 /* Mob.hpp in Headers */, 84BF637E2AF186C8008A9995 /* Player.hpp in Headers */, 8477B3A92C4DC3B3004E1AC5 /* Facing.hpp in Headers */, @@ -5793,6 +6013,7 @@ 8445E7AA2D769329008DC834 /* SynchedEntityData.hpp in Headers */, 84BF63BF2AF186C9008A9995 /* LeafTile.hpp in Headers */, 84BF63C02AF186C9008A9995 /* LiquidTile.hpp in Headers */, + 84F77A622EA1C0610045C907 /* LevelEvent.hpp in Headers */, 84BF63C12AF186C9008A9995 /* LiquidTileDynamic.hpp in Headers */, 84BF63C22AF186C9008A9995 /* LiquidTileStatic.hpp in Headers */, 84BF63C32AF186C9008A9995 /* MetalTile.hpp in Headers */, @@ -5887,6 +6108,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 84F779E32EA1BF8E0045C907 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 84F77A0C2EA1C0050045C907 /* ServerSideNetworkHandler.hpp in Headers */, + 84F77A0A2EA1C0050045C907 /* ServerPlayer.hpp in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 84FFBD7C2ACA2876005A8CCF /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; @@ -6195,6 +6425,7 @@ 84B8AF842AF18A25008DE93D /* PBXTargetDependency */, 84B8AF862AF18A25008DE93D /* PBXTargetDependency */, 84E8DCE42E84ACB000B30789 /* PBXTargetDependency */, + 84F77A022EA1BFC90045C907 /* PBXTargetDependency */, ); name = Client; productName = Client; @@ -6254,6 +6485,24 @@ productReference = 84E4BFAE2AE9854B0023E16A /* libCommon.a */; productType = "com.apple.product-type.library.static"; }; + 84F779CE2EA1BF8E0045C907 /* Server */ = { + isa = PBXNativeTarget; + buildConfigurationList = 84F779F32EA1BF8E0045C907 /* Build configuration list for PBXNativeTarget "Server" */; + buildPhases = ( + 84F779D12EA1BF8E0045C907 /* Sources */, + 84F779E12EA1BF8E0045C907 /* Frameworks */, + 84F779E32EA1BF8E0045C907 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + 84F779FF2EA1BFA40045C907 /* PBXTargetDependency */, + ); + name = Server; + productName = NBT; + productReference = 84F779FD2EA1BF8E0045C907 /* libServer.a */; + productType = "com.apple.product-type.library.static"; + }; 84FFBD7D2ACA2876005A8CCF /* RakNet */ = { isa = PBXNativeTarget; buildConfigurationList = 84FFBD842ACA2876005A8CCF /* Build configuration list for PBXNativeTarget "RakNet" */; @@ -6313,6 +6562,7 @@ 842610672AE988D30065905F /* Network */, 84FFBD7D2ACA2876005A8CCF /* RakNet */, 8406FD162AF1814500B09C1D /* Renderer */, + 84F779CE2EA1BF8E0045C907 /* Server */, 84BF62FE2AF1859D008A9995 /* World */, 84AAF5972AF18B9500BD67F4 /* OpenGL */, 84498A762AF18C7A005EF5A5 /* ZLib */, @@ -6805,27 +7055,39 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 84F77A5F2EA1C01C0045C907 /* UseItemPacket.cpp in Sources */, + 84F77A442EA1C01C0045C907 /* LevelEventPacket.cpp in Sources */, 8426106F2AE989720065905F /* MinecraftPackets.cpp in Sources */, + 84F77A3C2EA1C01C0045C907 /* AnimatePacket.cpp in Sources */, + 84F77A392EA1C01C0045C907 /* AddMobPacket.cpp in Sources */, + 84F77A412EA1C01C0045C907 /* InteractPacket.cpp in Sources */, 842610702AE989720065905F /* NetEventCallback.cpp in Sources */, + 84F77A562EA1C01C0045C907 /* SetEntityDataPacket.cpp in Sources */, 842610712AE989720065905F /* AddPlayerPacket.cpp in Sources */, + 84F77A372EA1C01C0045C907 /* AddItemEntityPacket.cpp in Sources */, 842610722AE989720065905F /* ChunkDataPacket.cpp in Sources */, 842610732AE989730065905F /* LevelDataPacket.cpp in Sources */, 842610742AE989730065905F /* LoginPacket.cpp in Sources */, 842610752AE989730065905F /* MessagePacket.cpp in Sources */, 842610762AE989730065905F /* MovePlayerPacket.cpp in Sources */, + 84F77A3F2EA1C01C0045C907 /* EntityEventPacket.cpp in Sources */, 842610772AE989730065905F /* PlaceBlockPacket.cpp in Sources */, 842610782AE989730065905F /* PlayerEquipmentPacket.cpp in Sources */, 842610792AE989730065905F /* RemoveBlockPacket.cpp in Sources */, 8426107A2AE989730065905F /* RemoveEntityPacket.cpp in Sources */, + 84F77A4B2EA1C01C0045C907 /* MoveEntityPacket.cpp in Sources */, 8426107B2AE989730065905F /* RequestChunkPacket.cpp in Sources */, 8426107C2AE989730065905F /* StartGamePacket.cpp in Sources */, 8426107D2AE989730065905F /* UpdateBlockPacket.cpp in Sources */, 8426107E2AE989730065905F /* RakNetInstance.cpp in Sources */, - 8426107F2AE989730065905F /* ServerSideNetworkHandler.cpp in Sources */, + 84F77A492EA1C01C0045C907 /* MoveEntityPacket_PosRot.cpp in Sources */, 8470AF302BE9B62600BCA54E /* PacketUtil.cpp in Sources */, 84CCBC972E61886800E251AF /* RakIO.cpp in Sources */, 8470AF352BE9B63900BCA54E /* LoginStatusPacket.cpp in Sources */, 8470AF362BE9B63900BCA54E /* ReadyPacket.cpp in Sources */, + 84F77A542EA1C01C0045C907 /* RespawnPacket.cpp in Sources */, + 84F77A582EA1C01C0045C907 /* SetHealthPacket.cpp in Sources */, + 84F77A5C2EA1C01C0045C907 /* TakeItemEntityPacket.cpp in Sources */, 8470AF372BE9B63900BCA54E /* SetTimePacket.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -6926,6 +7188,7 @@ 8477B3A22C4DC374004E1AC5 /* ControllerBuildInput.cpp in Sources */, 84B8AF082AF1896F008DE93D /* Model.cpp in Sources */, 84B8AF092AF1896F008DE93D /* PolygonQuad.cpp in Sources */, + 84F77A682EA1C0A10045C907 /* MultiPlayerLevel.cpp in Sources */, 84B8AF0A2AF1896F008DE93D /* ClientSideNetworkHandler.cpp in Sources */, 84B8AF0B2AF1896F008DE93D /* Options.cpp in Sources */, 84B8AF0C2AF1896F008DE93D /* Controller.cpp in Sources */, @@ -6996,6 +7259,8 @@ 84AA8C0D2B32F3F3003F5B82 /* SpiderRenderer.cpp in Sources */, 84AA8C0F2B32F3F3003F5B82 /* TntRenderer.cpp in Sources */, 84AA8C112B32F3F3003F5B82 /* TripodCameraRenderer.cpp in Sources */, + 84F77A6E2EA1C27B0045C907 /* LocalPlayer.cpp in Sources */, + 84F77A6A2EA1C0A10045C907 /* MultiplayerLocalPlayer.cpp in Sources */, 84AA8C152B32F3F3003F5B82 /* FireTexture.cpp in Sources */, 84AA8C162B32F3F3003F5B82 /* FoliageColor.cpp in Sources */, 84AA8C182B32F3F3003F5B82 /* Font.cpp in Sources */, @@ -7044,7 +7309,6 @@ 84BF630C2AF18631008A9995 /* Entity.cpp in Sources */, 84BF630D2AF18631008A9995 /* FallingTile.cpp in Sources */, 84BF630E2AF18631008A9995 /* ItemEntity.cpp in Sources */, - 84BF630F2AF18631008A9995 /* LocalPlayer.cpp in Sources */, 84BF63102AF18631008A9995 /* Mob.cpp in Sources */, 84BF63112AF18631008A9995 /* Player.cpp in Sources */, 8445E7A52D769329008DC834 /* MobCategory.cpp in Sources */, @@ -7239,6 +7503,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 84F779D12EA1BF8E0045C907 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 84F77A092EA1C0050045C907 /* ServerPlayer.cpp in Sources */, + 84F77A0B2EA1C0050045C907 /* ServerSideNetworkHandler.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 84FFBD7A2ACA2876005A8CCF /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -7434,6 +7707,16 @@ target = 8406FD162AF1814500B09C1D /* Renderer */; targetProxy = 84E8DCE32E84ACB000B30789 /* PBXContainerItemProxy */; }; + 84F779FF2EA1BFA40045C907 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 842610672AE988D30065905F /* Network */; + targetProxy = 84F779FE2EA1BFA40045C907 /* PBXContainerItemProxy */; + }; + 84F77A022EA1BFC90045C907 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 84F779CE2EA1BF8E0045C907 /* Server */; + targetProxy = 84F77A012EA1BFC90045C907 /* PBXContainerItemProxy */; + }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ @@ -9028,6 +9311,78 @@ }; name = "Release [SDL1] (Default)"; }; + 84F779F42EA1BF8E0045C907 /* Debug [SDL2] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = Server; + }; + name = "Debug [SDL2] (Default)"; + }; + 84F779F52EA1BF8E0045C907 /* Debug [SDL1] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = Server; + }; + name = "Debug [SDL1] (Default)"; + }; + 84F779F62EA1BF8E0045C907 /* Debug [iOS] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = Server; + }; + name = "Debug [iOS] (Default)"; + }; + 84F779F72EA1BF8E0045C907 /* Release [SDL2] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = Server; + }; + name = "Release [SDL2] (Default)"; + }; + 84F779F82EA1BF8E0045C907 /* Release [SDL1] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = Server; + }; + name = "Release [SDL1] (Default)"; + }; + 84F779F92EA1BF8E0045C907 /* Release [iOS] (Default) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = Server; + }; + name = "Release [iOS] (Default)"; + }; + 84F779FA2EA1BF8E0045C907 /* Release [SDL2] (x86) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = Server; + }; + name = "Release [SDL2] (x86)"; + }; + 84F779FB2EA1BF8E0045C907 /* Release [SDL1] (PPC) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = Server; + }; + name = "Release [SDL1] (PPC)"; + }; + 84F779FC2EA1BF8E0045C907 /* Release [SDL1] (x86-PPC) */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = lib; + PRODUCT_NAME = Server; + }; + name = "Release [SDL1] (x86-PPC)"; + }; 84FFBD7F2ACA2876005A8CCF /* Debug [SDL2] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { @@ -9263,6 +9618,22 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = "Release [SDL2] (Default)"; }; + 84F779F32EA1BF8E0045C907 /* Build configuration list for PBXNativeTarget "Server" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 84F779F42EA1BF8E0045C907 /* Debug [SDL2] (Default) */, + 84F779F52EA1BF8E0045C907 /* Debug [SDL1] (Default) */, + 84F779F62EA1BF8E0045C907 /* Debug [iOS] (Default) */, + 84F779F72EA1BF8E0045C907 /* Release [SDL2] (Default) */, + 84F779F82EA1BF8E0045C907 /* Release [SDL1] (Default) */, + 84F779F92EA1BF8E0045C907 /* Release [iOS] (Default) */, + 84F779FA2EA1BF8E0045C907 /* Release [SDL2] (x86) */, + 84F779FB2EA1BF8E0045C907 /* Release [SDL1] (PPC) */, + 84F779FC2EA1BF8E0045C907 /* Release [SDL1] (x86-PPC) */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = "Release [SDL2] (Default)"; + }; 84FFBD842ACA2876005A8CCF /* Build configuration list for PBXNativeTarget "RakNet" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/platforms/windows/minecraftcpp.sln b/platforms/windows/minecraftcpp.sln index 5dbd273ce..2f649dd29 100644 --- a/platforms/windows/minecraftcpp.sln +++ b/platforms/windows/minecraftcpp.sln @@ -32,6 +32,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NBT", "projects\NBT\NBT.vcx EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MinecraftClient.SDL1", "projects\MinecraftClient.SDL1\MinecraftClient.SDL1.vcxproj", "{06CF6B2F-D39B-4EEB-A582-A4A264C7B682}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Server", "projects\Server\Server.vcxproj", "{38723BE5-0310-4941-B11F-EA7FF21394D9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug_SDL1|x64 = Debug_SDL1|x64 @@ -356,6 +358,30 @@ Global {06CF6B2F-D39B-4EEB-A582-A4A264C7B682}.Release_SDL2|x86.ActiveCfg = Release_SDL1|Win32 {06CF6B2F-D39B-4EEB-A582-A4A264C7B682}.Release|x64.ActiveCfg = Release_SDL1|x64 {06CF6B2F-D39B-4EEB-A582-A4A264C7B682}.Release|x86.ActiveCfg = Release_SDL1|Win32 + {38723BE5-0310-4941-B11F-EA7FF21394D9}.Debug_SDL1|x64.ActiveCfg = Debug|x64 + {38723BE5-0310-4941-B11F-EA7FF21394D9}.Debug_SDL1|x64.Build.0 = Debug|x64 + {38723BE5-0310-4941-B11F-EA7FF21394D9}.Debug_SDL1|x86.ActiveCfg = Debug|Win32 + {38723BE5-0310-4941-B11F-EA7FF21394D9}.Debug_SDL1|x86.Build.0 = Debug|Win32 + {38723BE5-0310-4941-B11F-EA7FF21394D9}.Debug_SDL2|x64.ActiveCfg = Debug|x64 + {38723BE5-0310-4941-B11F-EA7FF21394D9}.Debug_SDL2|x64.Build.0 = Debug|x64 + {38723BE5-0310-4941-B11F-EA7FF21394D9}.Debug_SDL2|x86.ActiveCfg = Debug|Win32 + {38723BE5-0310-4941-B11F-EA7FF21394D9}.Debug_SDL2|x86.Build.0 = Debug|Win32 + {38723BE5-0310-4941-B11F-EA7FF21394D9}.Debug|x64.ActiveCfg = Debug|x64 + {38723BE5-0310-4941-B11F-EA7FF21394D9}.Debug|x64.Build.0 = Debug|x64 + {38723BE5-0310-4941-B11F-EA7FF21394D9}.Debug|x86.ActiveCfg = Debug|Win32 + {38723BE5-0310-4941-B11F-EA7FF21394D9}.Debug|x86.Build.0 = Debug|Win32 + {38723BE5-0310-4941-B11F-EA7FF21394D9}.Release_SDL1|x64.ActiveCfg = Release|x64 + {38723BE5-0310-4941-B11F-EA7FF21394D9}.Release_SDL1|x64.Build.0 = Release|x64 + {38723BE5-0310-4941-B11F-EA7FF21394D9}.Release_SDL1|x86.ActiveCfg = Release|Win32 + {38723BE5-0310-4941-B11F-EA7FF21394D9}.Release_SDL1|x86.Build.0 = Release|Win32 + {38723BE5-0310-4941-B11F-EA7FF21394D9}.Release_SDL2|x64.ActiveCfg = Release|x64 + {38723BE5-0310-4941-B11F-EA7FF21394D9}.Release_SDL2|x64.Build.0 = Release|x64 + {38723BE5-0310-4941-B11F-EA7FF21394D9}.Release_SDL2|x86.ActiveCfg = Release|Win32 + {38723BE5-0310-4941-B11F-EA7FF21394D9}.Release_SDL2|x86.Build.0 = Release|Win32 + {38723BE5-0310-4941-B11F-EA7FF21394D9}.Release|x64.ActiveCfg = Release|x64 + {38723BE5-0310-4941-B11F-EA7FF21394D9}.Release|x64.Build.0 = Release|x64 + {38723BE5-0310-4941-B11F-EA7FF21394D9}.Release|x86.ActiveCfg = Release|Win32 + {38723BE5-0310-4941-B11F-EA7FF21394D9}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/platforms/windows/projects/Client/Client.vcxproj b/platforms/windows/projects/Client/Client.vcxproj index a6eb3f94f..1223943c8 100644 --- a/platforms/windows/projects/Client/Client.vcxproj +++ b/platforms/windows/projects/Client/Client.vcxproj @@ -196,6 +196,9 @@ + + + @@ -322,6 +325,9 @@ + + + @@ -331,6 +337,9 @@ {e43f7c6a-a099-48c9-9d37-b56cd8d6d785} true + + {38723be5-0310-4941-b11f-ea7ff21394d9} + {f332cb57-ff16-4d43-bbe0-76f28301daa8} true diff --git a/platforms/windows/projects/Client/Client.vcxproj.filters b/platforms/windows/projects/Client/Client.vcxproj.filters index 8bbc9c5c1..c21c2a652 100644 --- a/platforms/windows/projects/Client/Client.vcxproj.filters +++ b/platforms/windows/projects/Client/Client.vcxproj.filters @@ -81,6 +81,12 @@ {14572243-8875-4ea9-aae1-7f52b1953754} + + {0b8efc29-fe37-4a05-ab72-4de5c8a0d22b} + + + {05de3cac-cea2-493b-a8c5-84601a5cd26a} + @@ -467,6 +473,15 @@ Header Files\Renderer\Entity + + Header Files\Multiplayer + + + Header Files\Player + + + Header Files\Multiplayer + @@ -841,5 +856,14 @@ Source Files\Renderer\Entity + + Source Files\Multiplayer + + + Source Files\Player + + + Source Files\Multiplayer + \ No newline at end of file diff --git a/platforms/windows/projects/Network/Network.vcxproj b/platforms/windows/projects/Network/Network.vcxproj index a97aa52f3..a20a48452 100644 --- a/platforms/windows/projects/Network/Network.vcxproj +++ b/platforms/windows/projects/Network/Network.vcxproj @@ -55,9 +55,21 @@ - + + + + + + + + + + + + + @@ -65,9 +77,37 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/platforms/windows/projects/Network/Network.vcxproj.filters b/platforms/windows/projects/Network/Network.vcxproj.filters index ec17cfc0a..ae7e8ef15 100644 --- a/platforms/windows/projects/Network/Network.vcxproj.filters +++ b/platforms/windows/projects/Network/Network.vcxproj.filters @@ -12,6 +12,9 @@ {17fcdc40-f9d5-4520-80db-750f4a2db48a} + + {218775b3-53f0-43a2-8535-4fb0ba7b50b4} + @@ -20,24 +23,108 @@ Header Files - - Header Files - Header Files Header Files - - Header Files - Header Files Header Files + + Header Files\Packets + + + Header Files + + + Header Files\Packets + + + Header Files\Packets + + + Header Files\Packets + + + Header Files\Packets + + + Header Files\Packets + + + Header Files\Packets + + + Header Files\Packets + + + Header Files\Packets + + + Header Files\Packets + + + Header Files\Packets + + + Header Files\Packets + + + Header Files\Packets + + + Header Files\Packets + + + Header Files\Packets + + + Header Files\Packets + + + Header Files\Packets + + + Header Files\Packets + + + Header Files\Packets + + + Header Files\Packets + + + Header Files\Packets + + + Header Files\Packets + + + Header Files\Packets + + + Header Files\Packets + + + Header Files\Packets + + + Header Files\Packets + + + Header Files\Packets + + + Header Files\Packets + + + Header Files\Packets + @@ -97,14 +184,50 @@ Source Files - - Source Files - Source Files Source Files + + Source Files\Packets + + + Source Files\Packets + + + Source Files\Packets + + + Source Files\Packets + + + Source Files\Packets + + + Source Files\Packets + + + Source Files\Packets + + + Source Files\Packets + + + Source Files\Packets + + + Source Files\Packets + + + Source Files\Packets + + + Source Files\Packets + + + Source Files\Packets + \ No newline at end of file diff --git a/platforms/windows/projects/Server/Server.vcxproj b/platforms/windows/projects/Server/Server.vcxproj new file mode 100644 index 000000000..ca9664779 --- /dev/null +++ b/platforms/windows/projects/Server/Server.vcxproj @@ -0,0 +1,54 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {38723be5-0310-4941-b11f-ea7ff21394d9} + Network + StaticLibrary + + + + + + + + + + + + + + + + + + + + + + {e43f7c6a-a099-48c9-9d37-b56cd8d6d785} + + + + + + \ No newline at end of file diff --git a/platforms/windows/projects/Server/Server.vcxproj.filters b/platforms/windows/projects/Server/Server.vcxproj.filters new file mode 100644 index 000000000..3304f3b5e --- /dev/null +++ b/platforms/windows/projects/Server/Server.vcxproj.filters @@ -0,0 +1,29 @@ + + + + + {4BA2CD1F-8508-40F0-8742-B5645156B25B} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {288DA959-0EF4-4E6F-A56D-2568AA71E25E} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/platforms/windows/projects/World/World.vcxproj b/platforms/windows/projects/World/World.vcxproj index 3d4fcea2a..71a32d54f 100644 --- a/platforms/windows/projects/World/World.vcxproj +++ b/platforms/windows/projects/World/World.vcxproj @@ -39,7 +39,6 @@ - @@ -197,7 +196,6 @@ - @@ -334,6 +332,7 @@ + diff --git a/platforms/windows/projects/World/World.vcxproj.filters b/platforms/windows/projects/World/World.vcxproj.filters index 12ecf7b56..54805eb8e 100644 --- a/platforms/windows/projects/World/World.vcxproj.filters +++ b/platforms/windows/projects/World/World.vcxproj.filters @@ -104,9 +104,6 @@ Source Files\Entity - - Source Files\Entity - Source Files\Entity @@ -574,9 +571,6 @@ Header Files\Entity - - Header Files\Entity - Header Files\Entity @@ -985,5 +979,8 @@ Header Files\Level\LevelGen\Chunk + + Header Files\Level + \ No newline at end of file diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 8424e0c00..8a56ef786 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -113,6 +113,8 @@ add_library(reminecraftpe-core STATIC client/model/CreeperModel.cpp client/model/CowModel.cpp client/model/ChickenModel.cpp + client/multiplayer/MultiPlayerLevel.cpp + client/multiplayer/MultiplayerLocalPlayer.cpp client/player/input/Controller.cpp client/player/input/ControllerBuildInput.cpp client/player/input/ControllerMoveInput.cpp @@ -138,6 +140,7 @@ add_library(reminecraftpe-core STATIC client/player/input/TouchInputHolder.cpp client/player/input/TouchscreenInput_TestFps.cpp client/player/input/UnifiedTurnBuild.cpp + client/player/LocalPlayer.cpp client/network/ClientSideNetworkHandler.cpp nbt/CompoundTag.cpp nbt/DoubleTag.cpp @@ -157,6 +160,10 @@ add_library(reminecraftpe-core STATIC network/packets/UpdateBlockPacket.cpp network/packets/RequestChunkPacket.cpp network/packets/PlayerEquipmentPacket.cpp + network/packets/InteractPacket.cpp + network/packets/UseItemPacket.cpp + network/packets/SetEntityDataPacket.cpp + network/packets/SetHealthPacket.cpp network/packets/ChunkDataPacket.cpp network/packets/LevelDataPacket.cpp network/packets/PlaceBlockPacket.cpp @@ -166,16 +173,26 @@ add_library(reminecraftpe-core STATIC network/packets/SetTimePacket.cpp network/packets/StartGamePacket.cpp network/packets/RemoveEntityPacket.cpp + network/packets/AddItemEntityPacket.cpp + network/packets/TakeItemEntityPacket.cpp network/packets/AddPlayerPacket.cpp + network/packets/AddMobPacket.cpp network/packets/RemoveBlockPacket.cpp network/packets/MovePlayerPacket.cpp + network/packets/MoveEntityPacket.cpp + network/packets/MoveEntityPacket_PosRot.cpp + network/packets/LevelEventPacket.cpp + network/packets/EntityEventPacket.cpp network/packets/MessagePacket.cpp - network/ServerSideNetworkHandler.cpp + network/packets/AnimatePacket.cpp + network/packets/RespawnPacket.cpp network/RakIO.cpp network/RakNetInstance.cpp network/MinecraftPackets.cpp network/NetEventCallback.cpp network/PacketUtil.cpp + server/ServerPlayer.cpp + server/ServerSideNetworkHandler.cpp world/level/levelgen/synth/Synth.cpp world/level/levelgen/synth/ImprovedNoise.cpp world/level/levelgen/synth/PerlinNoise.cpp @@ -191,7 +208,6 @@ add_library(reminecraftpe-core STATIC world/gamemode/GameMode.cpp world/gamemode/CreativeMode.cpp world/entity/Mob.cpp - world/entity/LocalPlayer.cpp world/entity/Player.cpp world/entity/PrimedTnt.cpp world/entity/Entity.cpp diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp index 067406638..073331dc2 100644 --- a/source/client/app/Minecraft.cpp +++ b/source/client/app/Minecraft.cpp @@ -14,8 +14,11 @@ #include "client/gui/screens/DeathScreen.hpp" #include "client/gui/screens/ProgressScreen.hpp" #include "client/gui/screens/ConvertWorldScreen.hpp" -#include "network/ServerSideNetworkHandler.hpp" + #include "client/network/ClientSideNetworkHandler.hpp" +#include "server/ServerSideNetworkHandler.hpp" +#include "network/packets/PlaceBlockPacket.hpp" +#include "network/packets/MessagePacket.hpp" #include "world/gamemode/SurvivalMode.hpp" #include "world/gamemode/CreativeMode.hpp" @@ -328,97 +331,104 @@ void Minecraft::handleBuildAction(const BuildActionIntention& action) bool bInteract = true; switch (m_hitResult.m_hitType) { - case HitResult::ENTITY: - if (action.isAttack()) - { - m_pGameMode->attack(player, m_hitResult.m_pEnt); - m_lastBlockBreakTime = getTimeMs(); - } - else if (action.isInteract() && canInteract) + case HitResult::ENTITY: { - if (m_hitResult.m_pEnt->interactPreventDefault()) - bInteract = false; + Entity* pTarget = m_hitResult.m_pEnt; + if (action.isAttack()) + { + m_pRakNetInstance->send(new InteractPacket(player->m_EntityID, pTarget->m_EntityID, InteractPacket::ATTACK)); + m_pGameMode->attack(player, pTarget); + m_lastBlockBreakTime = getTimeMs(); + } + else if (action.isInteract() && canInteract) + { + if (pTarget->interactPreventDefault()) + bInteract = false; - m_pGameMode->interact(player, m_hitResult.m_pEnt); - m_lastInteractTime = getTimeMs(); + m_pRakNetInstance->send(new InteractPacket(player->m_EntityID, pTarget->m_EntityID, InteractPacket::INTERACT)); + m_pGameMode->interact(player, pTarget); + m_lastInteractTime = getTimeMs(); + } + break; } - break; - case HitResult::TILE: - Tile* pTile = Tile::tiles[m_pLevel->getTile(m_hitResult.m_tilePos)]; - - if (action.isDestroy()) + case HitResult::TILE: { - if (!pTile) return; - //if (pTile->isLiquidTile()) return; + Tile* pTile = Tile::tiles[m_pLevel->getTile(m_hitResult.m_tilePos)]; - player->swing(); + if (action.isDestroy()) + { + if (!pTile) return; + //if (pTile->isLiquidTile()) return; - // @BUG: This is only done on the client side. - //bool extinguished = m_pLevel->extinguishFire(player, m_hitResult.m_tilePos, m_hitResult.m_hitSide); + player->swing(); - // Allows fire to be extinguished *without* destroying blocks - // @BUG: Hits sometimes pass through fire when done from above - //if (extinguished) break; + // @BUG: This is only done on the client side. + //bool extinguished = m_pLevel->extinguishFire(player, m_hitResult.m_tilePos, m_hitResult.m_hitSide); - if (pTile != Tile::unbreakable || (player->field_B94 >= 100 && !m_hitResult.m_bUnk24)) - { - bool destroyed = false; - if (action.isDestroyStart()) + // Allows fire to be extinguished *without* destroying blocks + // @BUG: Hits sometimes pass through fire when done from above + //if (extinguished) break; + + if (pTile != Tile::unbreakable || (player->field_B94 >= 100 && !m_hitResult.m_bUnk24)) { - destroyed = m_pGameMode->startDestroyBlock(player, m_hitResult.m_tilePos, m_hitResult.m_hitSide); - player->startDestroying(); - } + bool destroyed = false; + if (action.isDestroyStart()) + { + destroyed = m_pGameMode->startDestroyBlock(player, m_hitResult.m_tilePos, m_hitResult.m_hitSide); + player->startDestroying(); + } - bool contDestory = m_pGameMode->continueDestroyBlock(player, m_hitResult.m_tilePos, m_hitResult.m_hitSide); + bool contDestory = m_pGameMode->continueDestroyBlock(player, m_hitResult.m_tilePos, m_hitResult.m_hitSide); - destroyed = destroyed || contDestory; - m_pParticleEngine->crack(m_hitResult.m_tilePos, m_hitResult.m_hitSide); + destroyed = destroyed || contDestory; + m_pParticleEngine->crack(m_hitResult.m_tilePos, m_hitResult.m_hitSide); - m_lastBlockBreakTime = getTimeMs(); + m_lastBlockBreakTime = getTimeMs(); - if (destroyed) - { - /*if (isVibrateOnBlockBreakOptionEnabledOrWhatever) - platform()->vibrate(24);*/ + if (destroyed) + { + /*if (isVibrateOnBlockBreakOptionEnabledOrWhatever) + platform()->vibrate(24);*/ + } } } - } - else if (action.isPick()) - { - // Try to pick the tile. - int auxValue = m_pLevel->getData(m_hitResult.m_tilePos); - player->m_pInventory->selectItemByIdAux(pTile->m_ID, auxValue, C_MAX_HOTBAR_ITEMS); - } - else if (action.isPlace() && canInteract) - { - ItemInstance* pItem = getSelectedItem(); - if (m_pGameMode->useItemOn(player, m_pLevel, pItem, m_hitResult.m_tilePos, m_hitResult.m_hitSide)) + else if (action.isPick()) { - bInteract = false; + // Try to pick the tile. + int auxValue = m_pLevel->getData(m_hitResult.m_tilePos); + player->m_pInventory->selectItemByIdAux(pTile->m_ID, auxValue, C_MAX_HOTBAR_ITEMS); + } + else if (action.isPlace() && canInteract) + { + ItemInstance* pItem = getSelectedItem(); + if (m_pGameMode->useItemOn(player, m_pLevel, pItem, m_hitResult.m_tilePos, m_hitResult.m_hitSide)) + { + bInteract = false; - player->swing(); + player->swing(); - m_lastInteractTime = getTimeMs(); + m_lastInteractTime = getTimeMs(); - if (isOnline()) - { - if (ItemInstance::isNull(pItem) || pItem->m_itemID > C_MAX_TILES) - return; + if (isOnline()) + { + if (ItemInstance::isNull(pItem) || !pItem->getTile()) + return; - TilePos tp(m_hitResult.m_tilePos); + TilePos tp(m_hitResult.m_tilePos); - Facing::Name hitSide = m_hitResult.m_hitSide; + Facing::Name hitSide = m_hitResult.m_hitSide; - if (m_pLevel->getTile(m_hitResult.m_tilePos) == Tile::topSnow->m_ID) - { - hitSide = Facing::DOWN; - } + if (m_pLevel->getTile(m_hitResult.m_tilePos) == Tile::topSnow->m_ID) + { + hitSide = Facing::DOWN; + } - m_pRakNetInstance->send(new PlaceBlockPacket(player->m_EntityID, tp.relative(hitSide, 1), TileID(pItem->m_itemID), hitSide, pItem->getAuxValue())); + m_pRakNetInstance->send(new PlaceBlockPacket(player->m_EntityID, tp.relative(hitSide, 1), (TileID)pItem->getId(), hitSide, pItem->getAuxValue())); + } } } + break; } - break; } if (bInteract && action.isInteract() && canInteract) @@ -508,10 +518,14 @@ void Minecraft::tickInput() else if (getOptions()->isKey(KM_DROP, keyCode)) { ItemInstance *item = m_pLocalPlayer->m_pInventory->getSelected(); - if (!ItemInstance::isNull(item)) + if (!ItemInstance::isNull(item) && item->m_count > 0) { - ItemInstance itemDrop = m_pLocalPlayer->isSurvival() ? item->remove(1) : ItemInstance(*item); + ItemInstance itemDrop(*item); itemDrop.m_count = 1; + + if (m_pLocalPlayer->isSurvival()) + item->remove(1); + m_pLocalPlayer->drop(itemDrop); } } @@ -623,48 +637,17 @@ void Minecraft::sendMessage(const std::string& message) } } -void Minecraft::resetPlayer(Player* player) +void Minecraft::respawnPlayer() { - m_pLevel->validateSpawn(); - player->reset(); - - TilePos pos = m_pLevel->getSharedSpawnPos(); - player->setPos(pos); - player->resetPos(); - - // Of course we have to add him back into the game, if he isn't already. - EntityVector& vec = m_pLevel->m_entities; - for (int i = 0; i < int(vec.size()); i++) - { - if (vec[i] == player) - return; - } - - std::vector& vec2 = m_pLevel->m_players; - for (int i = 0; i < int(vec2.size()); i++) - { - // remove the player if he is already in the player list - if (vec2[i] == player) - { - vec2.erase(vec2.begin() + i); - i--; - } - } - - // add him in!! - m_pLevel->addEntity(player); -} - -void Minecraft::respawnPlayer(Player* player) -{ - resetPlayer(player); + _resetPlayer(m_pLocalPlayer); - // TODO: send a RespawnPacket + // Allows client to dictate respawn position. Why? + m_pRakNetInstance->send(new RespawnPacket(m_pLocalPlayer->m_EntityID, m_pLocalPlayer->m_pos)); } -std::string Minecraft::getVersionString() const +std::string Minecraft::getVersionString(const std::string& str) const { - return "v0.1.0 alpha"; + return "v0.2.0" + str + " alpha"; } void Minecraft::_reloadInput() @@ -719,6 +702,16 @@ void Minecraft::_initTextures() GetPatchManager()->PatchTiles(); } +void Minecraft::_resetPlayer(Player* player) +{ + m_pLevel->validateSpawn(); + player->reset(); + + TilePos pos = m_pLevel->getSharedSpawnPos(); + player->setPos(pos); + player->resetPos(); +} + void Minecraft::tick() { if (!m_pScreen) @@ -800,7 +793,7 @@ void Minecraft::update() if (m_pRakNetInstance) { - m_pRakNetInstance->runEvents(m_pNetEventCallback); + m_pRakNetInstance->runEvents(*m_pNetEventCallback); } for (int i = 0; i < m_timer.m_ticks; i++) @@ -1090,7 +1083,7 @@ void Minecraft::generateLevel(const std::string& unused, Level* pLevel) m_bPreparingLevel = false; - if (m_pRakNetInstance->m_bIsHost) + if (m_pRakNetInstance && m_pRakNetInstance->m_bIsHost) m_pRakNetInstance->announceServer(m_pUser->field_0); } @@ -1133,6 +1126,7 @@ void Minecraft::setLevel(Level* pLevel, const std::string& text, LocalPlayer* pL if (pLevel) { + pLevel->m_pRakNetInstance = m_pRakNetInstance; if (pLocalPlayer && m_pLocalPlayer == nullptr) { // We're getting a LocalPlayer from a server @@ -1176,15 +1170,15 @@ void Minecraft::selectLevel(const LevelSummary& ls, bool forceConversion) return; } - selectLevel(ls.m_fileName, ls.m_levelName, 0, forceConversion); + selectLevel(ls.m_fileName, ls.m_levelName, LevelSettings(), forceConversion); } -void Minecraft::selectLevel(const std::string& levelDir, const std::string& levelName, int32_t seed, bool forceConversion) +void Minecraft::selectLevel(const std::string& levelDir, const std::string& levelName, const LevelSettings& levelSettings, bool forceConversion) { LevelStorage* pStor = m_pLevelStorageSource->selectLevel(levelDir, false, forceConversion); Dimension* pDim = Dimension::getNew(0); - m_pLevel = new Level(pStor, levelName, seed, LEVEL_STORAGE_VERSION_DEFAULT, pDim); + m_pLevel = new Level(pStor, levelName, levelSettings, LEVEL_STORAGE_VERSION_DEFAULT, pDim); setLevel(m_pLevel, "Generating level", nullptr); field_D9C = 1; @@ -1213,9 +1207,7 @@ ItemInstance* Minecraft::getSelectedItem() if (m_pGameMode->isCreativeType()) { // Create new "unlimited" ItemInstance for Creative mode - m_CurrItemInstance.m_itemID = pInst->m_itemID; - m_CurrItemInstance.m_count = 999; - m_CurrItemInstance.setAuxValue(pInst->getAuxValue()); + m_CurrItemInstance = ItemInstance(pInst->getId(), 999, pInst->getAuxValue()); return &m_CurrItemInstance; } @@ -1230,7 +1222,8 @@ int Minecraft::getFpsIntlCounter() void Minecraft::leaveGame(bool bCopyMap) { m_bPreparingLevel = false; - m_pRakNetInstance->disconnect(); + if (m_pRakNetInstance) + m_pRakNetInstance->disconnect(); m_pMobPersp = nullptr; m_pLevelRenderer->setLevel(nullptr); m_pParticleEngine->setLevel(nullptr); @@ -1276,6 +1269,9 @@ void Minecraft::leaveGame(bool bCopyMap) void Minecraft::hostMultiplayer() { + if (!m_pRakNetInstance) + return; + #ifndef __EMSCRIPTEN__ m_pRakNetInstance->host(m_pUser->field_0, C_DEFAULT_PORT, C_MAX_CONNECTIONS); m_pNetEventCallback = new ServerSideNetworkHandler(this, m_pRakNetInstance); @@ -1284,6 +1280,9 @@ void Minecraft::hostMultiplayer() void Minecraft::joinMultiplayer(const PingedCompatibleServer& serverInfo) { + if (!m_pRakNetInstance) + return; + #ifndef __EMSCRIPTEN__ if (field_18 && m_pNetEventCallback) { @@ -1295,6 +1294,9 @@ void Minecraft::joinMultiplayer(const PingedCompatibleServer& serverInfo) void Minecraft::cancelLocateMultiplayer() { + if (!m_pRakNetInstance) + return; + #ifndef __EMSCRIPTEN__ field_18 = false; m_pRakNetInstance->stopPingForHosts(); @@ -1305,6 +1307,9 @@ void Minecraft::cancelLocateMultiplayer() void Minecraft::locateMultiplayer() { + if (!m_pRakNetInstance) + return; + #ifndef __EMSCRIPTEN__ field_18 = true; m_pRakNetInstance->pingForHosts(C_DEFAULT_PORT); diff --git a/source/client/app/Minecraft.hpp b/source/client/app/Minecraft.hpp index daf115fa0..4991d7963 100644 --- a/source/client/app/Minecraft.hpp +++ b/source/client/app/Minecraft.hpp @@ -19,12 +19,12 @@ #include "client/player/input/IInputHolder.hpp" #include "client/player/input/MouseHandler.hpp" #include "client/player/input/BuildActionIntention.hpp" +#include "client/player/LocalPlayer.hpp" #include "client/renderer/GameRenderer.hpp" #include "client/renderer/LevelRenderer.hpp" #include "client/renderer/entity/EntityRenderDispatcher.hpp" #include "client/sound/SoundEngine.hpp" #include "world/level/Level.hpp" -#include "world/entity/LocalPlayer.hpp" #include "world/gamemode/GameMode.hpp" #include "world/gamemode/GameType.hpp" #include "world/particle/ParticleEngine.hpp" @@ -37,6 +37,7 @@ class Minecraft : public App Minecraft(); virtual ~Minecraft(); +public: int getLicenseId(); void setScreen(Screen * pScreen); void releaseMouse(); @@ -47,7 +48,7 @@ class Minecraft : public App void handleBuildAction(const BuildActionIntention& action); bool isLevelGenerated() const; void selectLevel(const LevelSummary& ls, bool forceConversion = false); - void selectLevel(const std::string& levelDir, const std::string& levelName, int32_t seed = 0, bool forceConversion = false); + void selectLevel(const std::string& levelDir, const std::string& levelName, const LevelSettings& levelSettings, bool forceConversion = false); void setLevel(Level*, const std::string&, LocalPlayer*); bool pauseGame(); bool resumeGame(); @@ -60,9 +61,8 @@ class Minecraft : public App void handleCharInput(char chr); void resetInput(); void sendMessage(const std::string& message); - void resetPlayer(Player* player); - void respawnPlayer(Player* player); - std::string getVersionString() const; + void respawnPlayer(); + std::string getVersionString(const std::string& str = Util::EMPTY_STRING) const; bool isTouchscreen() const; bool useSplitControls() const; bool useController() const; @@ -92,6 +92,7 @@ class Minecraft : public App void _reloadInput(); void _levelGenerated(); void _initTextures(); + void _resetPlayer(Player* player); GameMode* createGameMode(GameType gameType, Level& level); private: diff --git a/source/client/gui/Gui.cpp b/source/client/gui/Gui.cpp index b345ec907..9225a9781 100644 --- a/source/client/gui/Gui.cpp +++ b/source/client/gui/Gui.cpp @@ -297,7 +297,7 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY) b1 = player->m_invulnerableTime / 3 % 2; emptyHeartX += 9 * b1; } -#ifdef ANDROID || TARGET_OS_IPHONE +#if defined(ANDROID) || defined(TARGET_OS_IPHONE) //@NOTE: Pocket-style health UI. int heartX = 2; int heartYStart = 2; @@ -342,7 +342,7 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY) int breathRaw = player->m_airCapacity; int breathFull = int(ceilf((float(breathRaw - 2) * 10.0f) / 300.0f)); int breathMeter = int(ceilf((float(breathRaw) * 10.0f) / 300.0f)) - breathFull; -#ifdef ANDROID || TARGET_OS_IPHONE +#if defined(ANDROID) || defined(TARGET_OS_IPHONE) // pe int bubbleX = 2; int bubbleY = 12; diff --git a/source/client/gui/screens/ConvertWorldScreen.cpp b/source/client/gui/screens/ConvertWorldScreen.cpp index 0ef6b47ed..972d073aa 100644 --- a/source/client/gui/screens/ConvertWorldScreen.cpp +++ b/source/client/gui/screens/ConvertWorldScreen.cpp @@ -19,6 +19,6 @@ void ConvertWorldScreen::postResult(bool b) else { // Don't Convert - m_pMinecraft->selectLevel(m_level.m_fileName, m_level.m_levelName, 0, false); + m_pMinecraft->selectLevel(m_level.m_fileName, m_level.m_levelName, LevelSettings(), false); } } diff --git a/source/client/gui/screens/CreateWorldScreen.cpp b/source/client/gui/screens/CreateWorldScreen.cpp index 029a21ad6..42f548e71 100644 --- a/source/client/gui/screens/CreateWorldScreen.cpp +++ b/source/client/gui/screens/CreateWorldScreen.cpp @@ -125,7 +125,8 @@ void CreateWorldScreen::buttonClicked(Button* pButton) seed = Util::hashCode(seedThing); } - m_pMinecraft->selectLevel(levelUniqueName, levelNickname, seed); + LevelSettings levelSettings(seed); + m_pMinecraft->selectLevel(levelUniqueName, levelNickname, levelSettings); } } diff --git a/source/client/gui/screens/IngameBlockSelectionScreen.cpp b/source/client/gui/screens/IngameBlockSelectionScreen.cpp index f47efe6a4..27008040f 100644 --- a/source/client/gui/screens/IngameBlockSelectionScreen.cpp +++ b/source/client/gui/screens/IngameBlockSelectionScreen.cpp @@ -94,7 +94,7 @@ void IngameBlockSelectionScreen::init() for (int i = 0; i < nItems; i++) { ItemInstance* item = pInv->getItem(i); - if (item && item->m_itemID == pInv->getSelectedItemId()) + if (item && item->getId() == pInv->getSelectedItemId()) { m_selectedSlot = i; break; diff --git a/source/client/gui/screens/JoinGameScreen.cpp b/source/client/gui/screens/JoinGameScreen.cpp index b5c68e713..e083e3418 100644 --- a/source/client/gui/screens/JoinGameScreen.cpp +++ b/source/client/gui/screens/JoinGameScreen.cpp @@ -78,7 +78,8 @@ void JoinGameScreen::init() m_buttons.push_back(&m_btnDirectConnect); m_buttons.push_back(&m_btnBack); - m_pMinecraft->m_pRakNetInstance->clearServerList(); + if (m_pMinecraft->m_pRakNetInstance) + m_pMinecraft->m_pRakNetInstance->clearServerList(); m_pAvailableGamesList = new AvailableGamesList(m_pMinecraft, m_width, m_height, 24, m_height - 30, 28); diff --git a/source/client/gui/screens/PauseScreen.cpp b/source/client/gui/screens/PauseScreen.cpp index 03596bd98..35d702ba0 100644 --- a/source/client/gui/screens/PauseScreen.cpp +++ b/source/client/gui/screens/PauseScreen.cpp @@ -8,7 +8,7 @@ #include "PauseScreen.hpp" #include "OptionsScreen.hpp" -#include "network/ServerSideNetworkHandler.hpp" +#include "server/ServerSideNetworkHandler.hpp" PauseScreen::PauseScreen() : //m_oPos(0), diff --git a/source/client/gui/screens/SelectWorldScreen.cpp b/source/client/gui/screens/SelectWorldScreen.cpp index 70b728247..f7ef36c3a 100644 --- a/source/client/gui/screens/SelectWorldScreen.cpp +++ b/source/client/gui/screens/SelectWorldScreen.cpp @@ -134,7 +134,12 @@ void SelectWorldScreen::tick() } } - m_pMinecraft->selectLevel(levelUniqueName, levelNickname, seed); + GameType gameType = GAME_TYPE_CREATIVE; + if (userInput.size() > 2 && userInput[2].compare("survival") == 0) + gameType = GAME_TYPE_SURVIVAL; + + LevelSettings settings(seed, gameType); + m_pMinecraft->selectLevel(levelUniqueName, levelNickname, settings); // @BUG: Use of deallocated memory. SetScreen frees us #ifdef ORIGINAL_CODE diff --git a/source/client/gui/screens/StartMenuScreen.cpp b/source/client/gui/screens/StartMenuScreen.cpp index a3bf7f248..23d347246 100644 --- a/source/client/gui/screens/StartMenuScreen.cpp +++ b/source/client/gui/screens/StartMenuScreen.cpp @@ -349,7 +349,13 @@ const char* gSplashes[] = // custom: "https://github.com/ReMinecraftPE/mcpe", "Also try Minecraft!", - "Also try Noita!" + "Also try Noita!", + "Also try Castle Crashers!", + "Also try Unturned!", + "Controller support!", + "Check out our GitHub!", + "Woo, newgrounds!", + "Woo, curseforge!" }; StartMenuScreen::StartMenuScreen() : @@ -467,7 +473,7 @@ void StartMenuScreen::init() field_154 = "\xFFMojang AB"; field_16C = m_width - 1 - m_pFont->width(field_154); - field_170 = "v0.1.0 alpha" + field_170 = m_pMinecraft->getVersionString(); #ifdef DEMO " (Demo)" #endif diff --git a/source/client/multiplayer/MultiPlayerLevel.cpp b/source/client/multiplayer/MultiPlayerLevel.cpp new file mode 100644 index 000000000..58a787006 --- /dev/null +++ b/source/client/multiplayer/MultiPlayerLevel.cpp @@ -0,0 +1,54 @@ +#include "MultiPlayerLevel.hpp" + +MultiPlayerLevel::MultiPlayerLevel(LevelStorage* pStor, const std::string& name, const LevelSettings& settings, int storageVersion, Dimension* pDimension) + : Level(pStor, name, settings, storageVersion, pDimension) +{ +} + +void MultiPlayerLevel::tick() +{ + _setTime(getTime() + 1); // Bypasses the normally-required update to LevelListeners + updateSkyDarken(); + + for (int i = 0; i < 10 && i < m_reEntries.size(); i++) + { + Entity* pEntity = m_reEntries[i]; + if (std::find(m_entities.begin(), m_entities.end(), pEntity) != m_entities.end()) + { + addEntity(pEntity); + } + } + + for (std::vector::iterator it = m_updatesToReset.begin(); it != m_updatesToReset.end(); it++) + { + if (--it->ticks == 0) + { + setTileAndDataNoUpdate(it->pos, it->tile, it->data); + sendTileUpdated(it->pos); + m_updatesToReset.erase(it); + } + } +} + +ChunkSource* MultiPlayerLevel::createChunkSource() +{ + return nullptr; +} + +void MultiPlayerLevel::putEntity(int id, Entity* e) +{ + Entity* old = getEntity(id); + if (old != nullptr) + { + removeEntity(old); + } + + m_forced.push_back(e); + e->m_EntityID = id; + if (!addEntity(e)) + { + m_reEntries.push_back(e); + } + + m_entitiesById[id] = e; +} \ No newline at end of file diff --git a/source/client/multiplayer/MultiPlayerLevel.hpp b/source/client/multiplayer/MultiPlayerLevel.hpp new file mode 100644 index 000000000..4546e8039 --- /dev/null +++ b/source/client/multiplayer/MultiPlayerLevel.hpp @@ -0,0 +1,37 @@ +#pragma once + +#include "world/level/Level.hpp" + +class MultiPlayerLevel : public Level +{ +private: + struct ResetInfo + { + TilePos pos; + int ticks; + TileID tile; + TileData data; + + ResetInfo(const TilePos& pos, TileID tile, TileData data) + { + this->pos = pos; + this->ticks = 80; + this->tile = tile; + this->data = data; + } + }; + +public: + MultiPlayerLevel(LevelStorage* pStor, const std::string& name, const LevelSettings& settings, int storageVersion = LEVEL_STORAGE_VERSION_DEFAULT, Dimension* pDimension = nullptr); + +public: + void tick() override; + ChunkSource* createChunkSource() override; + void putEntity(int id, Entity* e); + +private: + std::vector m_updatesToReset; + std::map m_entitiesById; + EntityVector m_forced; + EntityVector m_reEntries; +}; \ No newline at end of file diff --git a/source/client/multiplayer/MultiplayerLocalPlayer.cpp b/source/client/multiplayer/MultiplayerLocalPlayer.cpp new file mode 100644 index 000000000..5b1922c9b --- /dev/null +++ b/source/client/multiplayer/MultiplayerLocalPlayer.cpp @@ -0,0 +1,86 @@ +#include "MultiplayerLocalPlayer.hpp" +#include "network/RakNetInstance.hpp" +#include "world/level/Level.hpp" + +MultiplayerLocalPlayer::MultiplayerLocalPlayer(Minecraft* pMinecraft, Level* pLevel, User* pUser, GameType gameType, int dimensionId) + : LocalPlayer(pMinecraft, pLevel, pUser, gameType, dimensionId) +{ + m_flashOnSetHealth = false; +} + +void MultiplayerLocalPlayer::reallyDrop(ItemEntity* itemEntity) +{ +} + +bool MultiplayerLocalPlayer::hurt(Entity* pAttacker, int damage) +{ + // Java returns false + return false; + + // Pulled from Mob::hurt(), modified to remove impact on health. + // @BUG: Will never work, because EntityEventPacket sets m_invulnerableTime + // before InteractPacket is received and calls this. + // If we remove the m_invulnerableTime check, the player can then be + // knocked back despite being invulnerable + + /*if (isCreative()) + return false; + + bool var3 = true; + if (float(m_invulnerableTime) > float(m_invulnerableDuration) / 2.0f) + { + var3 = false; + } + else + { + m_invulnerableTime = m_invulnerableDuration; + m_hurtTime = m_hurtDuration = 10; + } + + m_hurtDir = 0.0f; + if (var3) + { + markHurt(); + + if (pAttacker) + { + float xd = pAttacker->m_pos.x - m_pos.x; + float zd = pAttacker->m_pos.z - m_pos.z; + + while (zd * zd + xd * xd < 0.0001f) + { + xd = 0.01f * (Mth::random() - Mth::random()); + zd = 0.01f * (Mth::random() - Mth::random()); + } + + float ang = atan2f(zd, xd); + v020_field_104 = ang * (180.0f / float(M_PI)) - m_rot.x; + + knockback(pAttacker, damage, xd, zd); + } + } + + return true;*/ +} + +void MultiplayerLocalPlayer::heal(int health) +{ +} + +void MultiplayerLocalPlayer::drop() +{ + //m_pLevel->m_pRakNetInstance->send(new PlayerActionPacket(PlayerActionPacket::DROP_ITEM)) +} + +void MultiplayerLocalPlayer::hurtTo(int newHealth) +{ + if (m_flashOnSetHealth) + { + LocalPlayer::hurtTo(newHealth); + } + else + { + m_health = newHealth; + m_flashOnSetHealth = true; + } +} \ No newline at end of file diff --git a/source/client/multiplayer/MultiplayerLocalPlayer.hpp b/source/client/multiplayer/MultiplayerLocalPlayer.hpp new file mode 100644 index 000000000..9d71bc83d --- /dev/null +++ b/source/client/multiplayer/MultiplayerLocalPlayer.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include "client/player/LocalPlayer.hpp" + +class MultiplayerLocalPlayer : public LocalPlayer +{ +public: + MultiplayerLocalPlayer(Minecraft* pMinecraft, Level* pLevel, User* pUser, GameType gameType, int dimensionId); + +protected: + void reallyDrop(ItemEntity* itemEntity) override; + +public: + bool hurt(Entity*, int) override; + void heal(int health) override; + void drop() override; + void hurtTo(int newHealth) override; + +private: + bool m_flashOnSetHealth; +}; + diff --git a/source/client/network/ClientSideNetworkHandler.cpp b/source/client/network/ClientSideNetworkHandler.cpp index 49bd009a0..d036a1725 100644 --- a/source/client/network/ClientSideNetworkHandler.cpp +++ b/source/client/network/ClientSideNetworkHandler.cpp @@ -11,6 +11,10 @@ #include "common/Utils.hpp" #include "client/gui/screens/StartMenuScreen.hpp" #include "client/gui/screens/DisconnectionScreen.hpp" +#include "client/multiplayer/MultiPlayerLevel.hpp" +#include "client/multiplayer/MultiplayerLocalPlayer.hpp" +#include "network/MinecraftPackets.hpp" +#include "world/entity/MobFactory.hpp" // This lets you make the client shut up and not log events in the debug console. //#define VERBOSE_CLIENT @@ -29,20 +33,24 @@ ClientSideNetworkHandler::ClientSideNetworkHandler(Minecraft* pMinecraft, RakNet m_pRakNetInstance = pRakNetInstance; m_pServerPeer = m_pRakNetInstance->getPeer(); m_chunksRequested = 0; + m_chunkCount = 0; m_serverProtocolVersion = 0; + m_bUseLevelDataPkt = false; m_pLevel = nullptr; m_field_14 = 0; m_field_24 = 0; + clearChunksLoaded(); } void ClientSideNetworkHandler::levelGenerated(Level* level) { - m_pLevel = level; + m_pLevel = (MultiPlayerLevel*)level; -#if NETWORK_PROTOCOL_VERSION >= 3 - ReadyPacket* pReadyPkt = new ReadyPacket(1); - m_pRakNetInstance->send(pReadyPkt); -#endif + if (m_serverProtocolVersion >= 3) + { + ReadyPacket* pReadyPkt = new ReadyPacket(1); + m_pRakNetInstance->send(pReadyPkt); + } arrangeRequestChunkOrder(); requestNextChunk(); @@ -50,16 +58,13 @@ void ClientSideNetworkHandler::levelGenerated(Level* level) void ClientSideNetworkHandler::onConnect(const RakNet::RakNetGUID& rakGuid) // server guid { - RakNet::RakNetGUID localGuid = ((RakNet::RakPeer*)m_pServerPeer)->GetMyGUID(); + RakNet::RakNetGUID localGuid = ((RakNet::RakPeer*)m_pServerPeer)->GetMyGUID(); // iOS 0.2.1 crashes right here after loading chunks printf_ignorable("onConnect, server guid: %s, local guid: %s", rakGuid.ToString(), localGuid.ToString()); m_serverGUID = rakGuid; - LoginPacket* pLoginPkt = new LoginPacket; - pLoginPkt->m_str = RakNet::RakString(m_pMinecraft->m_pUser->field_0.c_str()); - pLoginPkt->m_clientNetworkVersion = NETWORK_PROTOCOL_VERSION; - pLoginPkt->m_clientNetworkVersion2 = NETWORK_PROTOCOL_VERSION; - + clearChunksLoaded(); + LoginPacket* pLoginPkt = new LoginPacket(m_pMinecraft->m_pUser->field_0, NETWORK_PROTOCOL_VERSION); m_pRakNetInstance->send(pLoginPkt); } @@ -112,7 +117,7 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, Message void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, SetTimePacket* pPacket) { - puts_ignorable("SetTimePacket"); + //puts_ignorable("SetTimePacket"); if (m_pLevel) m_pLevel->setTime(pPacket->m_time); @@ -122,18 +127,19 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, StartGa { puts_ignorable("StartGamePacket"); - m_pMinecraft->getLevelSource()->deleteLevel("_LastJoinedServer"); + std::string levelName = "_LastJoinedServer"; + m_pMinecraft->getLevelSource()->deleteLevel(levelName); - m_pLevel = new Level( - m_pMinecraft->getLevelSource()->selectLevel("_LastJoinedServer", true), + LevelSettings settings(pStartGamePkt->m_seed, pStartGamePkt->m_gameType); + m_pLevel = new MultiPlayerLevel( + m_pMinecraft->getLevelSource()->selectLevel(levelName, true), "temp", - pStartGamePkt->m_seed, + settings, pStartGamePkt->m_levelVersion); m_pLevel->m_bIsClientSide = true; - GameType gameType = pStartGamePkt->m_gameType != GAME_TYPES_MAX ? pStartGamePkt->m_gameType : m_pLevel->getDefaultGameType(); - LocalPlayer *pLocalPlayer = new LocalPlayer(m_pMinecraft, m_pLevel, m_pMinecraft->m_pUser, gameType, m_pLevel->m_pDimension->field_50); + MultiplayerLocalPlayer *pLocalPlayer = new MultiplayerLocalPlayer(m_pMinecraft, m_pLevel, m_pMinecraft->m_pUser, settings.m_gameType, m_pLevel->m_pDimension->field_50); pLocalPlayer->m_guid = ((RakNet::RakPeer*)m_pServerPeer)->GetMyGUID(); pLocalPlayer->m_EntityID = pStartGamePkt->m_entityId; @@ -141,14 +147,15 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, StartGa pStartGamePkt->m_pos, pLocalPlayer->m_rot); - if (gameType == GAME_TYPE_CREATIVE) + if (settings.m_gameType == GAME_TYPE_CREATIVE) pLocalPlayer->m_pInventory->prepareCreativeInventory(); else pLocalPlayer->m_pInventory->prepareSurvivalInventory(); m_pLevel->setTime(pStartGamePkt->m_time); - m_serverProtocolVersion = pStartGamePkt->m_serverVersion; + // Not replicated even by 0.12.1, not sure where we even got this from... + m_serverProtocolVersion = NETWORK_PROTOCOL_VERSION; m_pMinecraft->setLevel(m_pLevel, "ClientSideNetworkHandler -> setLevel", pLocalPlayer); } @@ -163,9 +170,13 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, AddPlay pPlayer->m_EntityID = pAddPlayerPkt->m_id; m_pLevel->addEntity(pPlayer); + // If we haven't received a rot, use default player rot + if (pAddPlayerPkt->m_rot == Vec2::ZERO) + pAddPlayerPkt->m_rot = pPlayer->m_rot; + pPlayer->moveTo( pAddPlayerPkt->m_pos, - pPlayer->m_rot); + pAddPlayerPkt->m_rot); pPlayer->m_name = pAddPlayerPkt->m_name; pPlayer->m_guid = pAddPlayerPkt->m_guid; @@ -175,9 +186,47 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, AddPlay else pPlayer->m_pInventory->prepareSurvivalInventory(); + ItemInstance* pItem = pPlayer->getSelectedItem(); + if (pItem) + { + *pItem = ItemInstance(pAddPlayerPkt->m_itemId, pAddPlayerPkt->m_itemAuxValue, 63); + } + m_pMinecraft->m_gui.addMessage(pPlayer->m_name + " joined the game"); } +void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, AddMobPacket* pAddMobPkt) +{ + //puts_ignorable("AddMobPacket"); + + if (!m_pLevel) + { + LOG_W("Trying to add a mob with no level!"); + return; + } + + EntityType::ID entityTypeId = (EntityType::ID)pAddMobPkt->m_entityTypeId; + if (entityTypeId == EntityType::UNKNOWN) + { + LOG_E("Trying to add a mob without a type id"); + return; + } + + Entity* entity = MobFactory::CreateMob(entityTypeId, m_pLevel); + // Mojang, in all of their infinite wisdon, does not have this check here in 0.2.1, + // so the game will just crash if you replicate a mob it can't create. + if (!entity) + { + LOG_E("Server tried to add an unknown mob type! :%d", entityTypeId); + return; + } + + entity->m_EntityID = pAddMobPkt->m_entityId; + entity->moveTo(pAddMobPkt->m_pos, pAddMobPkt->m_rot); + entity->getEntityData().assignValues(pAddMobPkt->getUnpackedData()); + m_pLevel->addEntity(entity); +} + void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, RemoveEntityPacket* pRemoveEntityPkt) { if (!m_pLevel) return; @@ -188,6 +237,79 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, RemoveE m_pLevel->removeEntity(pEnt); } +void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, AddItemEntityPacket* packet) +{ + puts_ignorable("AddItemEntityPacket"); + + if (!m_pLevel) return; + + ItemInstance* pItemInstance = new ItemInstance(packet->m_itemId, packet->m_itemCount, packet->m_auxValue); + if (pItemInstance->isNull()) + { + delete pItemInstance; + LOG_E("Received invalid or null ItemInstance from server!"); + return; + } + + ItemEntity* pItemEntity = new ItemEntity(m_pLevel, packet->m_pos, pItemInstance); + + pItemEntity->m_vel.x = packet->m_velX * (1.f / 128.f); + pItemEntity->m_vel.y = packet->m_velY * (1.f / 128.f); + pItemEntity->m_vel.z = packet->m_velZ * (1.f / 128.f); + + m_pLevel->putEntity(packet->m_entityId, pItemEntity); +} + +void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, TakeItemEntityPacket* pkt) +{ + puts_ignorable("TakeItemEntityPacket"); + + if (!m_pLevel) return; + + Entity* pEntity = m_pLevel->getEntity(pkt->m_targetId); + if (!pEntity) + { + LOG_E("Failed to handle TakeItemEntityPacket: Unknown ItemEntity: %d", pkt->m_targetId); + return; + } + + if (!pEntity->getDescriptor().isType(EntityType::ITEM)) + return; + ItemEntity* pItemEntity = (ItemEntity*)pEntity; + + if (m_pMinecraft->m_pLocalPlayer->m_EntityID == pkt->m_sourceId) + { + if (pItemEntity->m_pItemInstance) + { + if (m_pMinecraft->m_pLocalPlayer->m_pInventory->addItem(*pItemEntity->m_pItemInstance)) + { + m_pLevel->playSound(pItemEntity, "random.pop", 0.3f, + ((Entity::sharedRandom.nextFloat() - Entity::sharedRandom.nextFloat()) * 0.7f + 1.0f) * 2.0f); + } + } + } +} + +void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, MoveEntityPacket* packet) +{ + if (!m_pLevel) return; + + Entity* pEntity = m_pLevel->getEntity(packet->m_entityId); + if (!pEntity) return; + + Vec2 rot; + if (packet->m_bHasRot) + { + rot = packet->m_rot; + } + else + { + rot = pEntity->m_rot; + } + + pEntity->lerpTo(packet->m_pos, rot); +} + void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, MovePlayerPacket* packet) { if (!m_pLevel) return; @@ -195,11 +317,11 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, MovePla Entity* pEntity = m_pLevel->getEntity(packet->m_id); if (!pEntity) { - LOG_E("No player with id %d", packet->m_id); + LOG_E("MovePlayerPacket: No player with id %d", packet->m_id); return; } - - pEntity->lerpTo(packet->m_pos, packet->m_rot, 3); + + pEntity->lerpTo(packet->m_pos, packet->m_rot); } void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, PlaceBlockPacket* pPlaceBlockPkt) @@ -209,7 +331,7 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, PlaceBl Player* pPlayer = (Player*)m_pLevel->getEntity(pPlaceBlockPkt->m_entityId); if (!pPlayer) { - LOG_E("No player with id %d", pPlaceBlockPkt->m_entityId); + LOG_E("PlaceBlockPacket: No player with id %d", pPlaceBlockPkt->m_entityId); return; } @@ -244,7 +366,7 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, RemoveB Entity* pEntity = m_pLevel->getEntity(pRemoveBlockPkt->m_entityId); if (!pEntity || !pEntity->isPlayer()) { - LOG_E("No player with id %d", pRemoveBlockPkt->m_entityId); + LOG_E("RemoveBlockPacket: No player with id %d", pRemoveBlockPkt->m_entityId); return; } @@ -274,13 +396,33 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, RemoveB void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, UpdateBlockPacket* pkt) { + BlockUpdate update(pkt->m_pos, pkt->m_tileTypeId, pkt->m_data); + if (!areAllChunksLoaded()) { - m_bufferedBlockUpdates.push_back(SBufferedBlockUpdate(pkt->m_pos, pkt->m_tileTypeId, pkt->m_data)); + m_bufferedBlockUpdates.push_back(update); return; } - m_pLevel->setTileAndData(pkt->m_pos, pkt->m_tileTypeId, pkt->m_data); + handleBlockUpdate(update); +} + +void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, LevelEventPacket* pkt) +{ + //puts_ignorable("LevelEventPacket"); + if (!m_pLevel) return; + + m_pLevel->levelEvent(nullptr, pkt->m_eventId, pkt->m_pos, pkt->m_data); +} + +void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, EntityEventPacket* pkt) +{ + //puts_ignorable("EntityEventPacket"); + if (!m_pLevel) return; + + Entity* pEntity = m_pLevel->getEntity(pkt->m_entityId); + if (pEntity) + pEntity->handleEntityEvent(pkt->m_eventId); } void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, ChunkDataPacket* pChunkDataPkt) @@ -308,7 +450,7 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, ChunkDa int minX = 16, minZ = 16; int maxX = 0, maxZ = 0; - for (int k = 0; k < 256; k++) + for (int k = 0; k < C_MAX_CHUNKS; k++) { uint8_t updMap; pChunkDataPkt->m_data.Read(updMap); @@ -359,8 +501,8 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, ChunkDa m_pLevel->setTilesDirty(TilePos(minX + x16, minY, minZ), TilePos(maxX + x16, maxY, maxZ + z16)); pChunk->m_bUnsaved = true; - - if (m_serverProtocolVersion < 2) + m_chunkStates[pChunkDataPkt->m_chunkPos.x][pChunkDataPkt->m_chunkPos.z] = true; + if (!m_bUseLevelDataPkt) { if (areAllChunksLoaded()) flushAllBufferedUpdates(); @@ -387,6 +529,107 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, PlayerE pPlayer->m_pInventory->selectItemById(pPlayerEquipmentPkt->m_itemID, C_MAX_HOTBAR_ITEMS); } +void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, InteractPacket* pkt) +{ + //puts_ignorable("InteractPacket"); + if (!m_pLevel) return; + + Entity* pSource = m_pLevel->getEntity(pkt->m_sourceId); + Entity* pTarget = m_pLevel->getEntity(pkt->m_targetId); + if (!pSource || !pTarget) + return; + + if (!pSource->isPlayer()) + return; + + Player* pPlayer = (Player*)pSource; + switch (pkt->m_actionType) + { + case InteractPacket::INTERACT: + pPlayer->swing(); + m_pMinecraft->m_pGameMode->interact(pPlayer, pTarget); + break; + case InteractPacket::ATTACK: + pPlayer->swing(); + m_pMinecraft->m_pGameMode->attack(pPlayer, pTarget); + break; + default: + LOG_W("Received unkown action in InteractPacket: %d", pkt->m_actionType); + break; + } +} + +void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, SetEntityDataPacket* pkt) +{ + puts_ignorable("SetEntityDataPacket"); + + if (!m_pLevel) + return; + + Entity* pEntity = m_pLevel->getEntity(pkt->m_entityId); + if (!pEntity) + return; + + pEntity->getEntityData().assignValues(pkt->getUnpackedData()); +} + +void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, SetHealthPacket* pkt) +{ + puts_ignorable("SetHealthPacket"); + + if (!m_pLevel) + return; + + LocalPlayer* pLocalPlayer = m_pMinecraft->m_pLocalPlayer; + if (pLocalPlayer) + pLocalPlayer->hurtTo(pkt->m_health); +} + +void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, AnimatePacket* pkt) +{ + //puts_ignorable("AnimatePacket"); + + if (!m_pLevel) + return; + + Entity* pEntity = m_pLevel->getEntity(pkt->m_entityId); + if (!pEntity) + return; + + switch (pkt->m_actionId) + { + case AnimatePacket::SWING: + { + if (!pEntity->isMob()) + break; + Mob* pMob = (Mob*)pEntity; + + pMob->swing(); + break; + } + case AnimatePacket::HURT: + { + pEntity->animateHurt(); + break; + } + default: + { + LOG_W("Received unkown action in AnimatePacket: %d, EntityType: %s", pkt->m_actionId, pEntity->getDescriptor().getEntityType().getName().c_str()); + break; + } + } +} + +void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, RespawnPacket* packet) +{ + puts_ignorable("RespawnPacket"); + + if (!m_pLevel) + return; + + NetEventCallback::handle(*m_pLevel, guid, packet); +} + void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, LevelDataPacket* packet) { const int uncompMagic = 12847812, compMagic = 58712758, chunkSepMagic = 284787658; @@ -484,7 +727,7 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, LevelDataP // Read the chunk data packet itself, and handle it. ChunkDataPacket cdp(cp, pChunk); - cdp.read(&bs2); + cdp.read(bs2); if (pChunk) handle(guid, &cdp); @@ -495,24 +738,65 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, LevelDataP } // All chunks are loaded. Also flush all the updates we've buffered. - m_chunksRequested = 256; + m_chunksRequested = C_MAX_CHUNKS; flushAllBufferedUpdates(); } bool ClientSideNetworkHandler::areAllChunksLoaded() { - return m_chunksRequested > 255; + return m_chunksRequested > C_MAX_CHUNKS; +} + +bool ClientSideNetworkHandler::isChunkLoaded(const ChunkPos& cp) +{ + if ((cp.x < 0 || cp.x >= C_MAX_CHUNKS_X) || (cp.z < 0 || cp.z >= C_MAX_CHUNKS_Z)) + return true; + + return m_chunkStates[cp.x][cp.z]; } +struct _ChunkSorter +{ + ChunkPos m_pos; + + _ChunkSorter(const ChunkPos& pos) + { + m_pos = pos; + } + + bool operator()(const ChunkPos& a, const ChunkPos& b) const + { + return (a - m_pos).lengthSqr() < (b - m_pos).lengthSqr(); + } +}; + void ClientSideNetworkHandler::arrangeRequestChunkOrder() { clearChunksLoaded(); - // @TODO: Implement arrangeRequestChunkOrder() + + ChunkPos cp(C_MAX_CHUNKS_X / 2, C_MAX_CHUNKS_Z / 2); + + if (m_pMinecraft) + { + LocalPlayer* pLocalPlayer = m_pMinecraft->m_pLocalPlayer; + if (pLocalPlayer) + { + cp = pLocalPlayer->m_pos; + } + } + + std::sort(&m_orderedChunks[0], &m_orderedChunks[C_MAX_CHUNKS-1], _ChunkSorter(cp)); } void ClientSideNetworkHandler::clearChunksLoaded() { - // @TODO: Implement clearChunksLoaded() + for (int i = 0; i < C_MAX_CHUNKS; i++) + { + ChunkPos cp(i >> 4, i & 0xF); + + m_orderedChunks[i] = cp; + m_chunkStates[cp.x][cp.z] = false; + } } void ClientSideNetworkHandler::requestNextChunk() @@ -520,25 +804,32 @@ void ClientSideNetworkHandler::requestNextChunk() if (areAllChunksLoaded()) return; - // @BUG: The return value of areAllChunksLoaded() is actually true even before the - // 256th chunk is loaded. - if (m_serverProtocolVersion < 2) { m_pRakNetInstance->send(new RequestChunkPacket(ChunkPos(m_chunksRequested % 16, m_chunksRequested / 16))); m_chunksRequested++; } - else + else if (m_bUseLevelDataPkt) { m_pRakNetInstance->send(new RequestChunkPacket(ChunkPos(-9999, -9999))); } + else + { + m_pRakNetInstance->send(new RequestChunkPacket(m_orderedChunks[m_chunkCount])); + m_chunkCount++; + m_chunksRequested++; + } } void ClientSideNetworkHandler::flushAllBufferedUpdates() { for (int i = 0; i < int(m_bufferedBlockUpdates.size()); i++) { - SBufferedBlockUpdate& u = m_bufferedBlockUpdates[i]; - m_pLevel->setTileAndData(u.pos, u.tile, u.data); + handleBlockUpdate(m_bufferedBlockUpdates[i]); } } + +void ClientSideNetworkHandler::handleBlockUpdate(const BlockUpdate& u) +{ + m_pLevel->setTileAndData(u.pos, Tile::TransformToValidBlockId(u.tile), u.data); +} \ No newline at end of file diff --git a/source/client/network/ClientSideNetworkHandler.hpp b/source/client/network/ClientSideNetworkHandler.hpp index a86332068..81230686c 100644 --- a/source/client/network/ClientSideNetworkHandler.hpp +++ b/source/client/network/ClientSideNetworkHandler.hpp @@ -10,14 +10,15 @@ #include "network/NetEventCallback.hpp" #include "client/app/Minecraft.hpp" +#include "client/multiplayer/MultiPlayerLevel.hpp" #include "network/RakNetInstance.hpp" -struct SBufferedBlockUpdate +struct BlockUpdate { TilePos pos; uint8_t tile, data; - SBufferedBlockUpdate(const TilePos& pos, TileID tile, TileData data) : + BlockUpdate(const TilePos& pos, TileID tile, TileData data) : pos(pos), tile(uint8_t(tile)), data(uint8_t(data)) {} }; @@ -37,31 +38,48 @@ class ClientSideNetworkHandler : public NetEventCallback void handle(const RakNet::RakNetGUID&, SetTimePacket*) override; void handle(const RakNet::RakNetGUID&, StartGamePacket*) override; void handle(const RakNet::RakNetGUID&, AddPlayerPacket*) override; + void handle(const RakNet::RakNetGUID&, AddMobPacket*) override; void handle(const RakNet::RakNetGUID&, RemoveEntityPacket*) override; + void handle(const RakNet::RakNetGUID&, AddItemEntityPacket*) override; + void handle(const RakNet::RakNetGUID&, TakeItemEntityPacket*) override; + void handle(const RakNet::RakNetGUID&, MoveEntityPacket*) override; void handle(const RakNet::RakNetGUID&, MovePlayerPacket*) override; void handle(const RakNet::RakNetGUID&, PlaceBlockPacket*) override; void handle(const RakNet::RakNetGUID&, RemoveBlockPacket*) override; void handle(const RakNet::RakNetGUID&, UpdateBlockPacket*) override; + void handle(const RakNet::RakNetGUID&, LevelEventPacket*) override; + void handle(const RakNet::RakNetGUID&, EntityEventPacket*) override; void handle(const RakNet::RakNetGUID&, ChunkDataPacket*) override; void handle(const RakNet::RakNetGUID&, PlayerEquipmentPacket*) override; + void handle(const RakNet::RakNetGUID&, InteractPacket*) override; + void handle(const RakNet::RakNetGUID&, SetEntityDataPacket*) override; + void handle(const RakNet::RakNetGUID&, SetHealthPacket*) override; + void handle(const RakNet::RakNetGUID&, AnimatePacket*) override; + void handle(const RakNet::RakNetGUID&, RespawnPacket*) override; void handle(const RakNet::RakNetGUID&, LevelDataPacket*) override; bool areAllChunksLoaded(); + bool isChunkLoaded(const ChunkPos& cp); void arrangeRequestChunkOrder(); void clearChunksLoaded(); void requestNextChunk(); void flushAllBufferedUpdates(); // inlined + void handleBlockUpdate(const BlockUpdate& u); private: Minecraft* m_pMinecraft; - Level* m_pLevel; + MultiPlayerLevel* m_pLevel; RakNetInstance* m_pRakNetInstance; RakNet::RakPeerInterface* m_pServerPeer; int m_field_14; RakNet::RakNetGUID m_serverGUID; int m_field_24; - std::vector m_bufferedBlockUpdates; + std::vector m_bufferedBlockUpdates; int m_chunksRequested; + int m_chunkCount; + ChunkPos m_orderedChunks[C_MAX_CHUNKS]; + bool m_chunkStates[C_MAX_CHUNKS_X][C_MAX_CHUNKS_Z]; int m_serverProtocolVersion; + bool m_bUseLevelDataPkt; }; diff --git a/source/world/entity/LocalPlayer.cpp b/source/client/player/LocalPlayer.cpp similarity index 82% rename from source/world/entity/LocalPlayer.cpp rename to source/client/player/LocalPlayer.cpp index 834b234ef..c75f40010 100644 --- a/source/world/entity/LocalPlayer.cpp +++ b/source/client/player/LocalPlayer.cpp @@ -9,9 +9,24 @@ #include "LocalPlayer.hpp" #include "client/app/Minecraft.hpp" #include "nbt/CompoundTag.hpp" +#include "network/packets/MovePlayerPacket.hpp" +#include "network/packets/PlayerEquipmentPacket.hpp" int dword_250ADC, dword_250AE0; +void LocalPlayer::_init() +{ + m_nAutoJumpFrames = 0; + // multiplayer related + m_lastSentPos = Vec3::ZERO; + m_lastSentRot = Vec2::ZERO; + // multiplayer related -- end + + m_renderArmRot = Vec2::ZERO; + m_lastRenderArmRot = Vec2::ZERO; + field_C38 = m_pInventory->getSelectedItemId(); +} + LocalPlayer::LocalPlayer(Minecraft* pMinecraft, Level* pLevel, User* pUser, GameType playerGameType, int dimensionId) : Player(pLevel, playerGameType) { field_BEC = 0; @@ -25,22 +40,14 @@ LocalPlayer::LocalPlayer(Minecraft* pMinecraft, Level* pLevel, User* pUser, Game field_C14 = 0.0f; field_C18 = 0.0f; field_C1C = 0.0f; - m_nAutoJumpFrames = 0; - // multiplayer related - field_C24 = Vec3::ZERO; - field_C30 = Vec2::ZERO; - // multiplayer related -- end field_C38 = 0; m_pMoveInput = nullptr; - m_renderArmRot = Vec2::ZERO; - m_lastRenderArmRot = Vec2::ZERO; - m_pMinecraft = pMinecraft; m_name = pUser->field_0; m_dimension = dimensionId; - field_C38 = m_pInventory->getSelectedItemId(); + _init(); } LocalPlayer::~LocalPlayer() @@ -59,6 +66,9 @@ void LocalPlayer::aiStep() Mob::aiStep(); Player::aiStep(); + + if (interpolateOnly()) + updateAi(); } void LocalPlayer::drop(const ItemInstance& item, bool randomly) @@ -94,11 +104,43 @@ void LocalPlayer::setPlayerGameType(GameType gameType) Player::setPlayerGameType(gameType); } +void LocalPlayer::swing() +{ + Player::swing(); + + m_pMinecraft->m_pRakNetInstance->send(new AnimatePacket(m_EntityID, AnimatePacket::SWING)); +} + +void LocalPlayer::reset() +{ + Player::reset(); + _init(); +} + void LocalPlayer::animateRespawn() { } +void LocalPlayer::hurtTo(int newHealth) +{ + // only called by client network handler + int dmg = m_health - newHealth; + if (dmg <= 0) + { + m_health = newHealth; + } + else + { + m_lastHurt = dmg; + m_lastHealth = m_health; + // makes EntityEventPacket the authority for client-side invulnerability + //m_invulnerableTime = m_invulnerableDuration; + actuallyHurt(dmg); + m_hurtTime = m_hurtDuration = 10; + } +} + void LocalPlayer::calculateFlight(const Vec3& pos) { float f1 = m_pMinecraft->getOptions()->field_244; @@ -148,7 +190,7 @@ void LocalPlayer::closeContainer() void LocalPlayer::respawn() { - m_pMinecraft->respawnPlayer(this); + m_pMinecraft->respawnPlayer(); } bool LocalPlayer::isSneaking() const @@ -156,10 +198,8 @@ bool LocalPlayer::isSneaking() const return m_pMoveInput->m_bSneaking; } -int LocalPlayer::move(const Vec3& pos) +void LocalPlayer::move(const Vec3& pos) { - int result = 0; - LocalPlayer* pLP = m_pMinecraft->m_pLocalPlayer; if (Minecraft::DEADMAU5_CAMERA_CHEATS && pLP == this && m_pMinecraft->getOptions()->m_bFlyCheat) { @@ -173,7 +213,7 @@ int LocalPlayer::move(const Vec3& pos) pLP->m_vel.y = 0.0f; // This looks very funny. - result = pLP->Entity::move(field_BF0); + pLP->Entity::move(field_BF0); pLP->m_bOnGround = true; @@ -196,7 +236,7 @@ int LocalPlayer::move(const Vec3& pos) float posX = m_pos.x; float posY = m_pos.y; - result = Entity::move(pos); + Entity::move(pos); //@BUG: backing up posZ too late float posZ = m_pos.z; @@ -206,7 +246,7 @@ int LocalPlayer::move(const Vec3& pos) if (Mth::floor(posX * 2) == Mth::floor(m_pos.x * 2) && Mth::floor(posY * 2) == Mth::floor(m_pos.y * 2) && Mth::floor(posZ * 2) == Mth::floor(m_pos.z * 2)) - return result; + return; float dist = Mth::sqrt(pos.x * pos.x + pos.z * pos.z); int x1 = Mth::floor(pos.x / dist + m_pos.x); @@ -216,15 +256,15 @@ int LocalPlayer::move(const Vec3& pos) // not standing on top of a tile? if (!m_pLevel->isSolidTile(TilePos(x1, int(m_pos.y - 1.0f), z1))) - return 0; + return; // aren't inside of a tile right now if (m_pLevel->isSolidTile(TilePos(x1, int(m_pos.y), z1))) - return 0; + return; // don't have anything on top of us if (m_pLevel->isSolidTile(TilePos(x1, int(m_pos.y + 1.0f), z1))) - return 1; + return; // are we trying to walk into stairs or a slab? if (tileOnTop != Tile::stairs_stone->m_ID && tileOnTop != Tile::stairs_wood->m_ID && tileOnTop != Tile::stoneSlabHalf->m_ID && m_pMinecraft->getOptions()->m_bAutoJump) @@ -232,8 +272,6 @@ int LocalPlayer::move(const Vec3& pos) m_nAutoJumpFrames = 1; } } - - return result; } void LocalPlayer::tick() @@ -242,16 +280,7 @@ void LocalPlayer::tick() if (m_pMinecraft->isOnline()) { - if (fabsf(m_pos.x - field_C24.x) > 0.1f || - fabsf(m_pos.y - field_C24.y) > 0.01f || - fabsf(m_pos.z - field_C24.z) > 0.1f || - fabsf(field_C30.y - m_rot.y) > 1.0f || - fabsf(field_C30.x - m_rot.x) > 1.0f) - { - m_pMinecraft->m_pRakNetInstance->send(new MovePlayerPacket(m_EntityID, Vec3(m_pos.x, m_pos.y - m_heightOffset, m_pos.z), m_rot)); - field_C24 = m_pos; - field_C30 = m_rot; - } + sendPosition(); if (field_C38 != m_pInventory->getSelectedItemId()) { @@ -283,4 +312,18 @@ void LocalPlayer::readAdditionalSaveData(const CompoundTag& tag) Player::readAdditionalSaveData(tag); m_score = tag.getInt32("Score"); +} + +void LocalPlayer::sendPosition() +{ + if (fabsf(m_pos.x - m_lastSentPos.x) > 0.1f || + fabsf(m_pos.y - m_lastSentPos.y) > 0.01f || + fabsf(m_pos.z - m_lastSentPos.z) > 0.1f || + fabsf(m_lastSentRot.y - m_rot.y) > 1.0f || + fabsf(m_lastSentRot.x - m_rot.x) > 1.0f) + { + m_pMinecraft->m_pRakNetInstance->send(new MovePlayerPacket(m_EntityID, Vec3(m_pos.x, m_pos.y - m_heightOffset, m_pos.z), m_rot)); + m_lastSentPos = m_pos; + m_lastSentRot = m_rot; + } } \ No newline at end of file diff --git a/source/world/entity/LocalPlayer.hpp b/source/client/player/LocalPlayer.hpp similarity index 61% rename from source/world/entity/LocalPlayer.hpp rename to source/client/player/LocalPlayer.hpp index 38537dc90..1742da082 100644 --- a/source/world/entity/LocalPlayer.hpp +++ b/source/client/player/LocalPlayer.hpp @@ -16,32 +16,42 @@ class Minecraft; class LocalPlayer : public Player { +private: + void _init(); + public: LocalPlayer(Minecraft*, Level*, User*, GameType, int); virtual ~LocalPlayer(); - virtual void animateRespawn() override; - virtual void aiStep() override; - virtual bool isSneaking() const override; - virtual int move(const Vec3& pos) override; - virtual void tick() override; - virtual void updateAi() override; - virtual void addAdditionalSaveData(CompoundTag& tag) const override; - virtual void readAdditionalSaveData(const CompoundTag& tag) override; - virtual bool isLocalPlayer() const override { return true; } - virtual void drop(const ItemInstance& item, bool randomly = false) override; - virtual bool isImmobile() const override; - virtual void setPlayerGameType(GameType gameType) override; +public: + void reset() override; + void animateRespawn() override; + void aiStep() override; + bool isSneaking() const override; + void move(const Vec3& pos) override; + void tick() override; + void updateAi() override; + void addAdditionalSaveData(CompoundTag& tag) const override; + void readAdditionalSaveData(const CompoundTag& tag) override; + bool isLocalPlayer() const override { return true; } + void drop(const ItemInstance& item, bool randomly = false) override; + bool isImmobile() const override; + bool interpolateOnly() const override { return false; } + void setPlayerGameType(GameType gameType) override; + void swing() override; + + virtual void hurtTo(int newHealth); void calculateFlight(const Vec3& pos); void closeContainer(); //@HUH: oddly enough not a virtual/override void respawn(); + void sendPosition(); private: // Made these private since they're only accessed by LocalPlayer // multiplayer related - Vec3 field_C24; - Vec2 field_C30; + Vec3 m_lastSentPos; + Vec2 m_lastSentRot; // multiplayer related -- end public: diff --git a/source/client/renderer/ItemInHandRenderer.cpp b/source/client/renderer/ItemInHandRenderer.cpp index 795f60bf3..7341703f8 100644 --- a/source/client/renderer/ItemInHandRenderer.cpp +++ b/source/client/renderer/ItemInHandRenderer.cpp @@ -50,11 +50,12 @@ void ItemInHandRenderer::renderItem(ItemInstance* inst) float bright = m_pMinecraft->m_pLocalPlayer->getBrightness(0.0f); #endif - if (inst->m_itemID < C_MAX_TILES && TileRenderer::canRender(Tile::tiles[inst->m_itemID]->getRenderShape())) + Tile* pTile = inst->getTile(); + if (pTile && TileRenderer::canRender(pTile->getRenderShape())) { float red, grn, blu, alp = 1.0f; - if (inst->m_itemID == Tile::leaves->m_ID) + if (pTile == Tile::leaves) { red = 0.35f; grn = 0.65f; @@ -75,7 +76,7 @@ void ItemInHandRenderer::renderItem(ItemInstance* inst) # define ARGPATCH #endif - m_tileRenderer.renderTile(Tile::tiles[inst->m_itemID], inst->getAuxValue() ARGPATCH); + m_tileRenderer.renderTile(pTile, inst->getAuxValue() ARGPATCH); #ifdef ARGPATCH # undef ARGPATCH @@ -85,7 +86,7 @@ void ItemInHandRenderer::renderItem(ItemInstance* inst) else { std::string toBind; - if (inst->m_itemID < C_MAX_TILES) + if (pTile) toBind = C_TERRAIN_NAME; else toBind = "gui/items.png"; @@ -322,10 +323,13 @@ void ItemInHandRenderer::tick() bSameItem = true; // without this, the player hand remains hidden - if (!ItemInstance::isNull(item) && !ItemInstance::isNull(&m_selectedItem) && item != &m_selectedItem && item->m_itemID == m_selectedItem.m_itemID && item->getAuxValue() == m_selectedItem.getAuxValue()) + if (!ItemInstance::isNull(item) && !ItemInstance::isNull(&m_selectedItem)) { - bSameItem = true; - m_selectedItem = *item; + if (item != &m_selectedItem && *item == m_selectedItem) + { + bSameItem = true; + m_selectedItem = *item; + } } float b = bSameItem ? 1.0f : 0.0f; @@ -341,7 +345,7 @@ void ItemInHandRenderer::tick() if (m_height < 0.1f) { if (ItemInstance::isNull(item)) - m_selectedItem.m_itemID = 0; + m_selectedItem.setNull(); else m_selectedItem = *item; diff --git a/source/client/renderer/LevelRenderer.cpp b/source/client/renderer/LevelRenderer.cpp index 3459e487f..3e6351b4d 100644 --- a/source/client/renderer/LevelRenderer.cpp +++ b/source/client/renderer/LevelRenderer.cpp @@ -1490,3 +1490,19 @@ void LevelRenderer::skyColorChanged() pChunk->setDirty(); } } + +void LevelRenderer::levelEvent(Player* pPlayer, LevelEvent::ID eventId, const TilePos& pos, LevelEvent::Data data) +{ + switch (eventId) + { + case LevelEvent::SOUND_DOOR: + std::string snd; + if (Mth::random() < 0.5f) + snd = "random.door_open"; + else + snd = "random.door_close"; + + m_pLevel->playSound(Vec3(pos) + 0.5f, snd, 1.0f, 0.9f + 0.1f * m_pLevel->m_random.nextFloat()); + break; + } +} diff --git a/source/client/renderer/LevelRenderer.hpp b/source/client/renderer/LevelRenderer.hpp index 0b2960978..e674f6f61 100644 --- a/source/client/renderer/LevelRenderer.hpp +++ b/source/client/renderer/LevelRenderer.hpp @@ -81,6 +81,7 @@ class LevelRenderer : public LevelListener public: LevelRenderer(Minecraft*, Textures*); + // LevelListener overrides void allChanged() override; void entityAdded(Entity*) override; void tileChanged(const TilePos& pos) override; @@ -89,6 +90,8 @@ class LevelRenderer : public LevelListener void addParticle(const std::string&, const Vec3& pos, const Vec3& dir) override; void playSound(const std::string& name, const Vec3& pos, float volume, float pitch) override; void skyColorChanged() override; + void levelEvent(Player* pPlayer, LevelEvent::ID eventId, const TilePos& pos, LevelEvent::Data data) override; + void generateSky(); void generateStars(); void cull(Culler*, float); diff --git a/source/client/renderer/entity/EntityRenderDispatcher.cpp b/source/client/renderer/entity/EntityRenderDispatcher.cpp index 4487547c8..7a9e72bd5 100644 --- a/source/client/renderer/entity/EntityRenderDispatcher.cpp +++ b/source/client/renderer/entity/EntityRenderDispatcher.cpp @@ -190,13 +190,6 @@ void EntityRenderDispatcher::render(Entity* entity, const Vec3& pos, float rot, return; } -#ifndef ORIGINAL_CODE - if (pRenderer == &m_HumanoidMobRenderer) - m_HumanoidMobRenderer.m_pHumanoidModel->m_bSneaking = entity->isSneaking(); - else - m_HumanoidMobRenderer.m_pHumanoidModel->m_bSneaking = false; -#endif - pRenderer->render(entity, pos, rot, a); pRenderer->postRender(entity, pos, rot, a); } diff --git a/source/client/renderer/entity/HumanoidMobRenderer.cpp b/source/client/renderer/entity/HumanoidMobRenderer.cpp index 2f4a29562..4d408c270 100644 --- a/source/client/renderer/entity/HumanoidMobRenderer.cpp +++ b/source/client/renderer/entity/HumanoidMobRenderer.cpp @@ -26,15 +26,15 @@ void HumanoidMobRenderer::additionalRendering(Mob* mob, float f) glPushMatrix(); m_pHumanoidModel->m_arm1.translateTo(0.0625f); glTranslatef(-0.0625f, 0.4375f, 0.0625f); -#pragma warning(disable : 6385) // this warning is just wrong; intellisense cant handle it being a pointer->index - if (inst && inst->m_itemID < C_MAX_TILES && TileRenderer::canRender(Tile::tiles[inst->m_itemID]->getRenderShape())) + + if (inst && inst->getTile() && TileRenderer::canRender(inst->getTile()->getRenderShape())) { glTranslatef(0.0f, 0.1875f, -0.3125f); glRotatef(20.0f, 1.0f, 0.0f, 0.0f); glRotatef(45.0f, 0.0f, 1.0f, 0.0f); glScalef(0.375f, -0.375f, 0.375f); } - else if (inst && Item::items[inst->m_itemID]->isHandEquipped()) + else if (inst && inst->getItem() && inst->getItem()->isHandEquipped()) { glTranslatef(0.0f, 0.1875f, 0.0f); glScalef(0.625f, -0.625f, 0.625f); @@ -64,11 +64,15 @@ void HumanoidMobRenderer::render(Entity* pEntity, const Vec3& pos, float f1, flo ItemInstance* item = player->getSelectedItem(); m_pHumanoidModel->m_bHoldingRightHand = item != nullptr; } + if (pEntity->isSneaking()) { + m_pHumanoidModel->m_bSneaking = true; Vec3 pos2 = pos; pos2.y -= 0.125f; MobRenderer::render(pEntity, pos2, f1, f2); + // https://github.com/ReMinecraftPE/mcpe/pull/197/#discussion_r2437985914 + m_pHumanoidModel->m_bSneaking = false; } else { diff --git a/source/client/renderer/entity/ItemRenderer.cpp b/source/client/renderer/entity/ItemRenderer.cpp index aa0bc2101..f52026bc5 100644 --- a/source/client/renderer/entity/ItemRenderer.cpp +++ b/source/client/renderer/entity/ItemRenderer.cpp @@ -42,9 +42,9 @@ void ItemRenderer::render(Entity* pEntity, const Vec3& pos, float rot, float a) glPushMatrix(); float yOffset = Mth::sin((float(pItemEntity->m_age) + a) / 10.0f + pItemEntity->m_bobOffs); const ItemInstance* pItemInstance = pItemEntity->m_pItemInstance; - if (!pItemInstance) + if (ItemInstance::isNull(pItemInstance)) { - assert(pItemInstance != nullptr); + assert(!"Tried to render invalid ItemInstance for ItemEntity"); return; } @@ -59,8 +59,8 @@ void ItemRenderer::render(Entity* pEntity, const Vec3& pos, float rot, float a) glTranslatef(pos.x, pos.y + 0.1f + yOffset * 0.1f, pos.z); glEnable(GL_RESCALE_NORMAL); - int itemID = pItemInstance->m_itemID; - if (itemID < C_MAX_TILES && TileRenderer::canRender(Tile::tiles[itemID]->getRenderShape())) + Tile* pTile = pItemInstance->getTile(); + if (pTile && TileRenderer::canRender(pTile->getRenderShape())) { glRotatef(((float(pItemEntity->m_age) + a) / 20.0f + pItemEntity->m_bobOffs) * 57.296f, 0.0f, 1.0f, 0.0f); bindTexture(C_TERRAIN_NAME); @@ -69,7 +69,7 @@ void ItemRenderer::render(Entity* pEntity, const Vec3& pos, float rot, float a) // @BUG: If cacti existed and were able to be dropped, they would be 2x the size of a regular tile. // This bug has been in the main game until Java Edition Beta 1.8. - if (Tile::tiles[itemID]->isCubeShaped() || pItemInstance->m_itemID == Tile::stoneSlabHalf->m_ID) + if (pTile->isCubeShaped() || pTile == Tile::stoneSlabHalf) scale = 0.25f; glScalef(scale, scale, scale); @@ -85,7 +85,7 @@ void ItemRenderer::render(Entity* pEntity, const Vec3& pos, float rot, float a) 0.2f * (m_random.nextFloat() * 2.0f - 1.0f) / scale); } - tileRenderer->renderTile(Tile::tiles[itemID], pItemInstance->getAuxValue(), pItemEntity->getBrightness(1.0f)); + tileRenderer->renderTile(pTile, pItemInstance->getAuxValue(), pItemEntity->getBrightness(1.0f)); glPopMatrix(); } } @@ -94,7 +94,7 @@ void ItemRenderer::render(Entity* pEntity, const Vec3& pos, float rot, float a) glScalef(0.5f, 0.5f, 0.5f); int icon = pItemInstance->getIcon(); - bindTexture(pItemInstance->m_itemID < C_MAX_TILES ? C_TERRAIN_NAME : C_ITEMS_NAME); + bindTexture(pItemInstance->getTile() ? C_TERRAIN_NAME : C_ITEMS_NAME); for (int i = 0; i < itemsToRender; i++) { @@ -180,44 +180,46 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures, ItemInstance* i { // @NOTE: Font unused but would presumably be used to draw the item amount. // As if that actually works due to us blocking t.begin() and t.draw() calls... - if (!instance) + if (!instance || !instance->isValid()) return; - int itemID = instance->m_itemID; if (!b) return; + Item* pItem = instance->getItem(); + Tile* pTile = instance->getTile(); + // @BUG: This is one of the reasons you can't actually hold items in early Minecraft. // There's an attempt to index `Tile::tiles` out of bounds, which of course fails, and likely crashes the game. :( // If only they'd placed the g_ItemFrames[itemID] check before the TileRenderer::canRender check... #ifdef ORIGINAL_CODE #define COND_PRE #else -#define COND_PRE (0 <= itemID && itemID < C_MAX_TILES) && +#define COND_PRE pTile && #endif bool bCanRenderAsIs = false; #ifdef ENH_3D_INVENTORY_TILES // We don't need to care about g_ItemFrames at all since blocks will get 3D rendered and 2D props will use the terrain.png as the texture. - if (COND_PRE(TileRenderer::canRender(Tile::tiles[itemID]->getRenderShape()))) + if (COND_PRE(TileRenderer::canRender(pTile->getRenderShape()))) { bCanRenderAsIs = true; } #else - if (COND_PRE(TileRenderer::canRender(Tile::tiles[itemID]->getRenderShape()) || g_ItemFrames[itemID] != 0)) + if (COND_PRE(TileRenderer::canRender(pTile->getRenderShape()) || g_ItemFrames[itemID] != 0)) { bCanRenderAsIs = true; } #endif - if (itemID < C_MAX_TILES && bCanRenderAsIs) + if (pTile && bCanRenderAsIs) { #ifndef ENH_3D_INVENTORY_TILES textures->loadAndBindTexture(C_BLOCKS_NAME); - float texU = float(g_ItemFrames[instance->m_itemID] % 10) * 48.0f; - float texV = float(g_ItemFrames[instance->m_itemID] / 10) * 48.0f; + float texU = float(g_ItemFrames[instance->getId()] % 10) * 48.0f; + float texV = float(g_ItemFrames[instance->getId()] / 10) * 48.0f; Tesselator& t = Tesselator::instance; // @NOTE: These do nothing, due to a previous t.voidBeginAndEndCalls call. @@ -242,10 +244,10 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures, ItemInstance* i glRotatef(45.0f, 0.0f, 1.0f, 0.0f); // TODO: Why can't we rotate stairs 90deg also? What's rotating them!? - if (Tile::tiles[itemID]->getRenderShape() != SHAPE_STAIRS) + if (pTile->getRenderShape() != SHAPE_STAIRS) glRotatef(-90.0f, 0.0f, 1.0f, 0.0f); - tileRenderer->renderTile(Tile::tiles[itemID], instance->getAuxValue(), 1.0f, true); + tileRenderer->renderTile(pTile, instance->getAuxValue(), 1.0f, true); #undef PARM_HACK glPopMatrix(); @@ -258,7 +260,7 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures, ItemInstance* i { // @BUG: The last bound texture will be the texture that ALL items will take. This is because begin and end calls // have been void'ed by a t.voidBeginAndEndCalls call in Gui::render. - if (instance->m_itemID <= 255) + if (instance->getTile()) textures->loadAndBindTexture(C_TERRAIN_NAME); else textures->loadAndBindTexture(C_ITEMS_NAME); diff --git a/source/common/Utils.hpp b/source/common/Utils.hpp index f5a45e7a5..ecd2a70a0 100644 --- a/source/common/Utils.hpp +++ b/source/common/Utils.hpp @@ -145,6 +145,7 @@ const char* GetGUIBlocksName(); #define C_MAX_CHUNKS_X (16) #define C_MAX_CHUNKS_Z (16) +#define C_MAX_CHUNKS (C_MAX_CHUNKS_X * C_MAX_CHUNKS_Z) // 9 chunks around a player things will tick #define C_TICK_DISTANCE_CHKS (9) diff --git a/source/nbt/CompoundTag.cpp b/source/nbt/CompoundTag.cpp index 9fb8bc9b0..4ddeaa6fa 100644 --- a/source/nbt/CompoundTag.cpp +++ b/source/nbt/CompoundTag.cpp @@ -57,6 +57,16 @@ void CompoundTag::put(const std::string& name, Tag* tag) return; } + if (!m_bLeak) + { + Tag* oldTag = m_tags[name]; + if (oldTag) + { + oldTag->deleteChildren(); + delete oldTag; + } + } + m_tags[name] = tag; } @@ -279,11 +289,23 @@ CompoundTag* CompoundTag::copy() const return new CompoundTag(*this); } -CompoundTag CompoundTag::clone() +CompoundTag CompoundTag::clone() const { return CompoundTag(*this); } +CompoundTag* CompoundTag::uniqueClone() const +{ + CompoundTag* newTag = new CompoundTag(); + + for (NamedTagMap::const_iterator it = m_tags.begin(); it != m_tags.end(); it++) + { + newTag->put(it->first, it->second->copy()); + } + + return newTag; +} + bool CompoundTag::remove(const std::string& name) { std::map::iterator it = m_tags.find(name); diff --git a/source/nbt/CompoundTag.hpp b/source/nbt/CompoundTag.hpp index 475a26feb..e2bf27fd2 100644 --- a/source/nbt/CompoundTag.hpp +++ b/source/nbt/CompoundTag.hpp @@ -17,9 +17,13 @@ class CompoundTag : public Tag { +public: + typedef std::map NamedTagMap; + public: CompoundTag(); +public: Tag::Type getId() const override { return TAG_TYPE_COMPOUND; } void write(IDataOutput& dos) const override; @@ -62,19 +66,20 @@ class CompoundTag : public Tag std::string toString() const override; CompoundTag* copy() const override; - CompoundTag clone(); + CompoundTag clone() const; + CompoundTag* uniqueClone() const; bool remove(const std::string& name); void deleteChildren() override; void leak() { m_bLeak = true; } bool isEmpty() const { return m_tags.empty(); } - std::map& rawView() { return m_tags; } - const std::map& rawView() const { return m_tags; } + NamedTagMap& rawView() { return m_tags; } + const NamedTagMap& rawView() const { return m_tags; } bool operator==(const Tag& other) const override; bool operator!=(const Tag& other) const { return !(*this == other); } private: - std::map m_tags; + NamedTagMap m_tags; bool m_bLeak; }; \ No newline at end of file diff --git a/source/network/MinecraftPackets.cpp b/source/network/MinecraftPackets.cpp index ebc0198a6..411dcce72 100644 --- a/source/network/MinecraftPackets.cpp +++ b/source/network/MinecraftPackets.cpp @@ -24,10 +24,20 @@ Packet* MinecraftPackets::createPacket(int type) return new SetTimePacket; case PACKET_START_GAME: return new StartGamePacket; + case PACKET_ADD_MOB: + return new AddMobPacket; case PACKET_ADD_PLAYER: return new AddPlayerPacket; case PACKET_REMOVE_ENTITY: return new RemoveEntityPacket; + case PACKET_ADD_ITEM_ENTITY: + return new AddItemEntityPacket; + case PACKET_TAKE_ITEM_ENTITY: + return new TakeItemEntityPacket; + case PACKET_MOVE_ENTITY: + return new MoveEntityPacket; + case PACKET_MOVE_ENTITY_POS_ROT: + return new MoveEntityPacket_PosRot; case PACKET_MOVE_PLAYER: return new MovePlayerPacket; case PACKET_PLACE_BLOCK: @@ -36,12 +46,28 @@ Packet* MinecraftPackets::createPacket(int type) return new RemoveBlockPacket; case PACKET_UPDATE_BLOCK: return new UpdateBlockPacket; + case PACKET_LEVEL_EVENT: + return new LevelEventPacket; + case PACKET_ENTITY_EVENT: + return new EntityEventPacket; case PACKET_REQUEST_CHUNK: return new RequestChunkPacket; case PACKET_CHUNK_DATA: return new ChunkDataPacket; case PACKET_PLAYER_EQUIPMENT: return new PlayerEquipmentPacket; + case PACKET_INTERACT: + return new InteractPacket; + case PACKET_USE_ITEM: + return new UseItemPacket; + case PACKET_SET_ENTITY_DATA: + return new SetEntityDataPacket; + case PACKET_SET_HEALTH: + return new SetHealthPacket; + case PACKET_ANIMATE: + return new AnimatePacket; + case PACKET_RESPAWN: + return new RespawnPacket; case PACKET_LEVEL_DATA: return new LevelDataPacket; diff --git a/source/network/MinecraftPackets.hpp b/source/network/MinecraftPackets.hpp index 0b4c93f58..600b8d187 100644 --- a/source/network/MinecraftPackets.hpp +++ b/source/network/MinecraftPackets.hpp @@ -9,6 +9,35 @@ #pragma once #include "Packet.hpp" +#include "packets/LoginPacket.hpp" +#include "packets/LoginStatusPacket.hpp" +#include "packets/ReadyPacket.hpp" +#include "packets/MessagePacket.hpp" +#include "packets/SetTimePacket.hpp" +#include "packets/StartGamePacket.hpp" +#include "packets/AddMobPacket.hpp" +#include "packets/AddPlayerPacket.hpp" +#include "packets/RemoveEntityPacket.hpp" +#include "packets/AddItemEntityPacket.hpp" +#include "packets/TakeItemEntityPacket.hpp" +#include "packets/MoveEntityPacket.hpp" +#include "packets/MoveEntityPacket_PosRot.hpp" +#include "packets/MovePlayerPacket.hpp" +#include "packets/PlaceBlockPacket.hpp" +#include "packets/RemoveBlockPacket.hpp" +#include "packets/UpdateBlockPacket.hpp" +#include "packets/LevelEventPacket.hpp" +#include "packets/EntityEventPacket.hpp" +#include "packets/RequestChunkPacket.hpp" +#include "packets/ChunkDataPacket.hpp" +#include "packets/PlayerEquipmentPacket.hpp" +#include "packets/InteractPacket.hpp" +#include "packets/UseItemPacket.hpp" +#include "packets/SetEntityDataPacket.hpp" +#include "packets/SetHealthPacket.hpp" +#include "packets/AnimatePacket.hpp" +#include "packets/RespawnPacket.hpp" +#include "packets/LevelDataPacket.hpp" class MinecraftPackets { diff --git a/source/network/NetEventCallback.cpp b/source/network/NetEventCallback.cpp index a688c2759..5de0db21b 100644 --- a/source/network/NetEventCallback.cpp +++ b/source/network/NetEventCallback.cpp @@ -1,94 +1,42 @@ -/******************************************************************** - Minecraft: Pocket Edition - Decompilation Project - Copyright (C) 2023 iProgramInCpp - - The following code is licensed under the BSD 1 clause license. - SPDX-License-Identifier: BSD-1-Clause - ********************************************************************/ - #include "NetEventCallback.hpp" - -void NetEventCallback::levelGenerated(Level* level) -{ -} - -void NetEventCallback::onConnect(const RakNet::RakNetGUID& guid) -{ -} - -void NetEventCallback::onUnableToConnect() -{ -} - -void NetEventCallback::onNewClient(const RakNet::RakNetGUID& guid) -{ -} - -void NetEventCallback::onDisconnect(const RakNet::RakNetGUID& guid) -{ -} - -void NetEventCallback::handle(const RakNet::RakNetGUID& guid, LoginPacket* packet) -{ -} - -void NetEventCallback::handle(const RakNet::RakNetGUID& guid, LoginStatusPacket* packet) -{ -} - -void NetEventCallback::handle(const RakNet::RakNetGUID& guid, ReadyPacket* packet) -{ -} - -void NetEventCallback::handle(const RakNet::RakNetGUID& guid, MessagePacket* packet) -{ -} - -void NetEventCallback::handle(const RakNet::RakNetGUID& guid, SetTimePacket* packet) -{ -} - -void NetEventCallback::handle(const RakNet::RakNetGUID& guid, StartGamePacket* packet) -{ -} - -void NetEventCallback::handle(const RakNet::RakNetGUID& guid, AddPlayerPacket* packet) -{ -} - -void NetEventCallback::handle(const RakNet::RakNetGUID& guid, RemoveEntityPacket* packet) -{ -} - -void NetEventCallback::handle(const RakNet::RakNetGUID& guid, MovePlayerPacket* packet) -{ -} - -void NetEventCallback::handle(const RakNet::RakNetGUID& guid, PlaceBlockPacket* packet) -{ -} - -void NetEventCallback::handle(const RakNet::RakNetGUID& guid, RemoveBlockPacket* packet) -{ -} - -void NetEventCallback::handle(const RakNet::RakNetGUID& guid, UpdateBlockPacket* packet) -{ -} - -void NetEventCallback::handle(const RakNet::RakNetGUID& guid, RequestChunkPacket* packet) -{ -} - -void NetEventCallback::handle(const RakNet::RakNetGUID& guid, ChunkDataPacket* packet) -{ - -} - -void NetEventCallback::handle(const RakNet::RakNetGUID& guid, PlayerEquipmentPacket* packet) -{ -} - -void NetEventCallback::handle(const RakNet::RakNetGUID& guid, LevelDataPacket* packet) -{ -} +#include "world/level/Level.hpp" + +Player* NetEventCallback::_findPlayer(Level& level, Entity::ID entityId, const RakNet::RakNetGUID* guid) +{ + if (entityId != -1) + { + Entity* pEntity = level.getEntity(entityId); + if (pEntity) + { + if (pEntity->isPlayer()) + return (Player*)pEntity; + } + } + + if (!guid || level.m_players.empty()) + return nullptr; + + for (int i = 0; i < level.m_players.size(); i++) + { + Player* pPlayer = level.m_players[i]; + if (pPlayer && pPlayer->m_guid == *guid) + return pPlayer; + } + + return nullptr; +} + +void NetEventCallback::handle(Level& level, const RakNet::RakNetGUID& guid, RespawnPacket* pkt) +{ + Player* pPlayer = _findPlayer(level, pkt->m_entityId); + if (!pPlayer) + { + LOG_W("NetEventCallback failed to find player to respawn with ID: %d", pkt->m_entityId); + return; + } + + // @TODO: on server, ignore client's requested coords, and teleport them to their server-determined spawn + pPlayer->moveTo(pkt->m_pos); + pPlayer->reset(); + pPlayer->resetPos(true); +} \ No newline at end of file diff --git a/source/network/NetEventCallback.hpp b/source/network/NetEventCallback.hpp index c2afee337..b3af86a68 100644 --- a/source/network/NetEventCallback.hpp +++ b/source/network/NetEventCallback.hpp @@ -9,53 +9,54 @@ #pragma once #include "RakNetTypes.h" -#include "Packet.hpp" -class Packet; -class LoginPacket; -class LoginStatusPacket; -class ReadyPacket; -class MessagePacket; -class SetTimePacket; -class StartGamePacket; -class AddPlayerPacket; -class RemoveEntityPacket; -class MovePlayerPacket; -class PlaceBlockPacket; -class RemoveBlockPacket; -class UpdateBlockPacket; -class RequestChunkPacket; -class ChunkDataPacket; -class PlayerEquipmentPacket; -class LevelDataPacket; -#include "world/level/Level.hpp" +#include "MinecraftPackets.hpp" class Level; -class LevelChunk; class NetEventCallback { public: virtual ~NetEventCallback() {} - virtual void levelGenerated(Level*); - virtual void onConnect(const RakNet::RakNetGUID&); - virtual void onUnableToConnect(); - virtual void onNewClient(const RakNet::RakNetGUID&); - virtual void onDisconnect(const RakNet::RakNetGUID&); + +protected: + Player* _findPlayer(Level& level, Entity::ID entityId = -1, const RakNet::RakNetGUID* guid = nullptr); + +public: + virtual void levelGenerated(Level*) {} + virtual void onConnect(const RakNet::RakNetGUID&) {} + virtual void onUnableToConnect() {} + virtual void onNewClient(const RakNet::RakNetGUID&) {} + virtual void onDisconnect(const RakNet::RakNetGUID&) {} + // TODO: macro this with a global PacketType list or something - virtual void handle(const RakNet::RakNetGUID&, LoginPacket*); - virtual void handle(const RakNet::RakNetGUID&, LoginStatusPacket*); - virtual void handle(const RakNet::RakNetGUID&, ReadyPacket*); - virtual void handle(const RakNet::RakNetGUID&, MessagePacket*); - virtual void handle(const RakNet::RakNetGUID&, SetTimePacket*); - virtual void handle(const RakNet::RakNetGUID&, StartGamePacket*); - virtual void handle(const RakNet::RakNetGUID&, AddPlayerPacket*); - virtual void handle(const RakNet::RakNetGUID&, RemoveEntityPacket*); - virtual void handle(const RakNet::RakNetGUID&, MovePlayerPacket*); - virtual void handle(const RakNet::RakNetGUID&, PlaceBlockPacket*); - virtual void handle(const RakNet::RakNetGUID&, RemoveBlockPacket*); - virtual void handle(const RakNet::RakNetGUID&, UpdateBlockPacket*); - virtual void handle(const RakNet::RakNetGUID&, RequestChunkPacket*); - virtual void handle(const RakNet::RakNetGUID&, ChunkDataPacket*); - virtual void handle(const RakNet::RakNetGUID&, PlayerEquipmentPacket*); - virtual void handle(const RakNet::RakNetGUID&, LevelDataPacket*); + virtual void handle(const RakNet::RakNetGUID&, LoginPacket*) {} + virtual void handle(const RakNet::RakNetGUID&, LoginStatusPacket*) {} + virtual void handle(const RakNet::RakNetGUID&, ReadyPacket*) {} + virtual void handle(const RakNet::RakNetGUID&, MessagePacket*) {} + virtual void handle(const RakNet::RakNetGUID&, SetTimePacket*) {} + virtual void handle(const RakNet::RakNetGUID&, StartGamePacket*) {} + virtual void handle(const RakNet::RakNetGUID&, AddMobPacket*) {} + virtual void handle(const RakNet::RakNetGUID&, AddPlayerPacket*) {} + virtual void handle(const RakNet::RakNetGUID&, RemoveEntityPacket*) {} + virtual void handle(const RakNet::RakNetGUID&, AddItemEntityPacket*) {} + virtual void handle(const RakNet::RakNetGUID&, TakeItemEntityPacket*) {} + virtual void handle(const RakNet::RakNetGUID&, MoveEntityPacket*) {} + virtual void handle(const RakNet::RakNetGUID&, MovePlayerPacket*) {} + virtual void handle(const RakNet::RakNetGUID&, PlaceBlockPacket*) {} + virtual void handle(const RakNet::RakNetGUID&, RemoveBlockPacket*) {} + virtual void handle(const RakNet::RakNetGUID&, UpdateBlockPacket*) {} + virtual void handle(const RakNet::RakNetGUID&, LevelEventPacket*) {} + virtual void handle(const RakNet::RakNetGUID&, EntityEventPacket*) {} + virtual void handle(const RakNet::RakNetGUID&, RequestChunkPacket*) {} + virtual void handle(const RakNet::RakNetGUID&, ChunkDataPacket*) {} + virtual void handle(const RakNet::RakNetGUID&, PlayerEquipmentPacket*) {} + virtual void handle(const RakNet::RakNetGUID&, InteractPacket*) {} + virtual void handle(const RakNet::RakNetGUID&, UseItemPacket*) {} + virtual void handle(const RakNet::RakNetGUID&, SetEntityDataPacket*) {} + virtual void handle(const RakNet::RakNetGUID&, SetHealthPacket*) {} + virtual void handle(const RakNet::RakNetGUID&, AnimatePacket*) {} + virtual void handle(const RakNet::RakNetGUID&, RespawnPacket*) {} + virtual void handle(const RakNet::RakNetGUID&, LevelDataPacket*) {} + + virtual void handle(Level&, const RakNet::RakNetGUID&, RespawnPacket*); }; diff --git a/source/network/Packet.hpp b/source/network/Packet.hpp index 2169b8ec5..ec7321280 100644 --- a/source/network/Packet.hpp +++ b/source/network/Packet.hpp @@ -8,18 +8,13 @@ #pragma once -#include -#include "world/phys/Vec3.hpp" -#include "world/gamemode/GameType.hpp" -#include "world/entity/Player.hpp" #include "RakNetTypes.h" #include "BitStream.h" #include "MessageIdentifiers.h" -#include "NetEventCallback.hpp" -#define NETWORK_PROTOCOL_VERSION_MIN 1 // ? -#define NETWORK_PROTOCOL_VERSION 2 // 0.1.1 -//#define NETWORK_PROTOCOL_VERSION 3 // 0.2.1 +#define NETWORK_PROTOCOL_VERSION_MIN 3 // 3 because the packet IDs changed completely between 2 and 3 +//#define NETWORK_PROTOCOL_VERSION 2 // 0.1.0 (actual client crashes with unrecognized tiles) +#define NETWORK_PROTOCOL_VERSION 3 // 0.2.0 class NetEventCallback; class Level; @@ -86,7 +81,7 @@ enum ePacketType PACKET_PLACE_BLOCK, PACKET_REMOVE_BLOCK, PACKET_UPDATE_BLOCK, - PACKET_EXPLODE, + PACKET_EXPLODE, // @TODO PACKET_LEVEL_EVENT, PACKET_ENTITY_EVENT, PACKET_REQUEST_CHUNK, @@ -107,301 +102,7 @@ class Packet { public: virtual ~Packet() {} - virtual void write(RakNet::BitStream*) = 0; - virtual void read(RakNet::BitStream*) = 0; - virtual void handle(const RakNet::RakNetGUID&, NetEventCallback*) = 0; -}; - -class LoginPacket : public Packet -{ -public: - LoginPacket() - { - m_clientNetworkVersion = 0; - m_clientNetworkVersion2 = 0; - } - LoginPacket(const std::string& uname) - { - m_str = RakNet::RakString(uname.c_str()); - m_clientNetworkVersion = NETWORK_PROTOCOL_VERSION; - m_clientNetworkVersion2 = NETWORK_PROTOCOL_VERSION; - } - - void handle(const RakNet::RakNetGUID&, NetEventCallback* pCallback) override; - void write(RakNet::BitStream*) override; - void read(RakNet::BitStream*) override; -public: - RakNet::RakString m_str; - int m_clientNetworkVersion; - int m_clientNetworkVersion2; -}; - -class LoginStatusPacket : public Packet -{ -public: - enum LoginStatus - { - STATUS_SUCCESS, - STATUS_CLIENT_OUTDATED, - STATUS_SERVER_OUTDATED - }; - -public: - LoginStatusPacket(LoginStatus loginStatus = STATUS_SUCCESS) - { - m_loginStatus = loginStatus; - } - - void handle(const RakNet::RakNetGUID&, NetEventCallback* pCallback) override; - void write(RakNet::BitStream*) override; - void read(RakNet::BitStream*) override; -public: - LoginStatus m_loginStatus; -}; - -class ReadyPacket : public Packet -{ -public: - ReadyPacket(uint8_t ready = 0) - { - m_ready = ready; - } - - void handle(const RakNet::RakNetGUID&, NetEventCallback* pCallback) override; - void write(RakNet::BitStream*) override; - void read(RakNet::BitStream*) override; -public: - uint8_t m_ready; -}; - -class MessagePacket : public Packet -{ -public: - MessagePacket() {} - MessagePacket(const std::string& msg) - { - m_str = msg.c_str(); - } - - void handle(const RakNet::RakNetGUID&, NetEventCallback* pCallback) override; - void write(RakNet::BitStream*) override; - void read(RakNet::BitStream*) override; -public: - RakNet::RakString m_str; -}; - -class SetTimePacket : public Packet -{ -public: - SetTimePacket(int32_t time = 0) - { - m_time = time; - } - - void handle(const RakNet::RakNetGUID&, NetEventCallback* pCallback) override; - void write(RakNet::BitStream*) override; - void read(RakNet::BitStream*) override; -public: - int32_t m_time; -}; - -class StartGamePacket : public Packet -{ -public: - StartGamePacket() - { - m_seed = 0; - m_levelVersion = 0; - m_gameType = GAME_TYPES_MAX; - m_entityId = 0; - m_serverVersion = 0; - m_time = 0; - } - void handle(const RakNet::RakNetGUID&, NetEventCallback* pCallback) override; - void write(RakNet::BitStream*) override; - void read(RakNet::BitStream*) override; -public: - int32_t m_seed; - int m_levelVersion; - GameType m_gameType; - int m_entityId; - Vec3 m_pos; - int m_serverVersion; - int m_time; -}; - -class AddPlayerPacket : public Packet -{ -public: - AddPlayerPacket() - { - field_4 = 0; - field_14 = 0; - m_id = 0; - } - AddPlayerPacket(const Player *player); - void handle(const RakNet::RakNetGUID&, NetEventCallback* pCallback) override; - void write(RakNet::BitStream*) override; - void read(RakNet::BitStream*) override; -public: - int field_4; - RakNet::RakNetGUID m_guid; - int field_14; - RakNet::RakString m_name; - int m_id; - Vec3 m_pos; -}; - -class RemoveEntityPacket : public Packet -{ -public: - RemoveEntityPacket() - { - m_id = 0; - } - RemoveEntityPacket(int id) { m_id = id; } - - void handle(const RakNet::RakNetGUID&, NetEventCallback* pCallback) override; - void write(RakNet::BitStream*) override; - void read(RakNet::BitStream*) override; -public: - int m_id; -}; - -class MovePlayerPacket : public Packet -{ -public: - MovePlayerPacket() - { - m_id = 0; - } - MovePlayerPacket(int id, const Vec3& pos, const Vec2& rot): m_id(id), m_pos(pos), m_rot(rot) {} - void handle(const RakNet::RakNetGUID&, NetEventCallback* pCallback) override; - void write(RakNet::BitStream*) override; - void read(RakNet::BitStream*) override; -public: - int m_id; - Vec3 m_pos; - Vec2 m_rot; -}; - -class PlaceBlockPacket : public Packet -{ -public: - PlaceBlockPacket() - { - m_entityId = 0; - m_tileTypeId = TILE_AIR; - m_face = 0; - m_data = 0; - } - PlaceBlockPacket(int entityId, const TilePos& pos, TileID tileTypeId, Facing::Name face, TileData data) - { - m_entityId = entityId; - m_pos = pos; - m_tileTypeId = tileTypeId; - m_face = face; - m_data = data; - } - - void handle(const RakNet::RakNetGUID&, NetEventCallback* pCallback) override; - void write(RakNet::BitStream*) override; - void read(RakNet::BitStream*) override; -public: - int m_entityId; - TilePos m_pos; - TileID m_tileTypeId; - uint8_t m_face; - TileData m_data; -}; - -class RemoveBlockPacket : public Packet -{ -public: - RemoveBlockPacket() - { - m_entityId = 0; - } - RemoveBlockPacket(int id, const TilePos& pos) :m_entityId(id), m_pos(pos) {} - - void handle(const RakNet::RakNetGUID&, NetEventCallback* pCallback) override; - void write(RakNet::BitStream*) override; - void read(RakNet::BitStream*) override; -public: - int m_entityId; - TilePos m_pos; -}; - -class UpdateBlockPacket : public Packet -{ -public: - void handle(const RakNet::RakNetGUID&, NetEventCallback* pCallback) override; - void write(RakNet::BitStream*) override; - void read(RakNet::BitStream*) override; -public: - TilePos m_pos; - TileID m_tileTypeId; - TileData m_data; -}; - -class RequestChunkPacket : public Packet -{ -public: - RequestChunkPacket() {} - RequestChunkPacket(const ChunkPos& pos) { m_chunkPos = pos; } - void handle(const RakNet::RakNetGUID&, NetEventCallback* pCallback) override; - void write(RakNet::BitStream*) override; - void read(RakNet::BitStream*) override; -public: - ChunkPos m_chunkPos; -}; - -class ChunkDataPacket : public Packet -{ -public: - ChunkDataPacket() - { - m_pChunk = nullptr; - } - ChunkDataPacket(const ChunkPos& pos, LevelChunk* c) :m_chunkPos(pos), m_pChunk(c) {} - void handle(const RakNet::RakNetGUID&, NetEventCallback* pCallback) override; - void write(RakNet::BitStream*) override; - void read(RakNet::BitStream*) override; -public: - ChunkPos m_chunkPos; - RakNet::BitStream m_data; - LevelChunk* m_pChunk; -}; - -class LevelDataPacket : public Packet -{ -public: - LevelDataPacket() - { - m_pLevel = nullptr; - } - LevelDataPacket(Level* level) : m_pLevel(level) {} - void handle(const RakNet::RakNetGUID&, NetEventCallback* pCallback) override; - void write(RakNet::BitStream*) override; - void read(RakNet::BitStream*) override; -public: - RakNet::BitStream m_data; - Level* m_pLevel; -}; - -class PlayerEquipmentPacket : public Packet -{ -public: - PlayerEquipmentPacket() - { - m_playerID = 0; - m_itemID = 0; - } - PlayerEquipmentPacket(int playerID, int itemID): m_playerID(playerID), m_itemID(itemID) {} - void handle(const RakNet::RakNetGUID&, NetEventCallback* pCallback) override; - void write(RakNet::BitStream*) override; - void read(RakNet::BitStream*) override; -public: - int m_playerID; - uint16_t m_itemID; -}; + virtual void write(RakNet::BitStream&) = 0; + virtual void read(RakNet::BitStream&) = 0; + virtual void handle(const RakNet::RakNetGUID&, NetEventCallback&) = 0; +}; \ No newline at end of file diff --git a/source/network/PacketUtil.cpp b/source/network/PacketUtil.cpp index 268f1f211..f7b6fe311 100644 --- a/source/network/PacketUtil.cpp +++ b/source/network/PacketUtil.cpp @@ -1,4 +1,5 @@ #include "PacketUtil.hpp" +#include "nbt/NbtIo.hpp" char PacketUtil::Rot_degreesToChar(float degrees) { @@ -25,4 +26,156 @@ void PacketUtil::Rot_charToEntity(Entity* entity, char yawChar, char pitchChar) float yaw = PacketUtil::Rot_charToDegrees(yawChar); entity->m_oRot.x = yaw; entity->m_rot.x = yaw; +} + +void PacketUtil::WriteUserData(const ItemInstance& item, RakNet::BitStream* bs, bool minData) +{ + if (item.getItem()) + { + // Item::writeUserData (0.12.1) + if (!item.getUserData()) + { + int16_t size = 0; + bs->Write(size); + return; + } + + std::string rawUserData; + StringByteOutput dos(&rawUserData); + const CompoundTag* userData; + if (minData) + userData = item.getNetworkUserData(); + else + userData = item.getUserData(); + + if (userData) + { + Tag::writeNamedTag("tag", *userData, dos); + + if (minData) + delete userData; + } + + bs->Write(rawUserData.size()); + bs->Write(rawUserData); + } + else if (item.getTile()) + { + // Tile::writeUserData (0.12.1) + if (item.getBaseRepairCost() == 0) + { + bs->Write(false); + return; + } + + bs->Write(item.getBaseRepairCost()); + + if (item.hasCustomHoverName()) + { + bs->Write(true); + RakNet::RakString hoverName(item.getHoverName().c_str()); + bs->Write(hoverName); + } + } +} + +void PacketUtil::ReadUserData(ItemInstance& item, RakNet::BitStream* bs) +{ + if (item.getItem()) + { + // Item::readUserData (0.12.1) + int16_t size; + bs->Read(size); + if (size == 0) + return; + + // Don't ask me why we're writing this as an std::string, this is from 0.12.1 + std::string rawUserData; + bs->Read(rawUserData); + + StringByteInput dis(rawUserData); + CompoundTag* userData = NbtIo::read(dis); + if (userData) + item.setUserData(userData); + return; + } + else if (item.getTile()) + { + // Tile::readUserData (0.12.1) (never called or called virtually) + bool hasData; + bs->Read(hasData); + if (!hasData) + return; + + int32_t repairCost; + bs->Read(repairCost); + + bool hasHoverName; + bs->Read(hasHoverName); + + item.setRepairCost(repairCost); + if (hasHoverName) + { + RakNet::RakString hoverName; + bs->Read(hoverName); + item.setHoverName(hoverName.C_String()); + } + } + + assert(!"Attempted PacketUtil::ReadUserData() for invalid ItemInstance!"); +} + +void PacketUtil::WriteItemInstance(const ItemInstance& item, RakNet::BitStream* bs, bool doUserData, bool minUserData) +{ + int16_t itemId = item.getId(); + int8_t count = item.m_count; + int16_t auxValue = item.getAuxValue(); + if (itemId <= 0) + { + itemId = -1; + bs->Write(itemId); + return; + } + + bs->Write(itemId); + bs->Write(count); + bs->Write(auxValue); + if (doUserData) + WriteUserData(item, bs, minUserData); +} + +ItemInstance PacketUtil::ReadItemInstance(RakNet::BitStream* bs, bool doUserData) +{ + int16_t itemId; + if (!bs->Read(itemId)) + return ItemInstance(); + + if (itemId == -1) + return ItemInstance(); + + uint8_t count; + int16_t auxValue; + if (!bs->Read(count) || !bs->Read(auxValue)) + { + return ItemInstance(); // Return empty if stream fails + } + + ItemInstance itemInstance(itemId, count, auxValue); + if (!itemInstance.isValid()) + { + return ItemInstance(); + } + + if (!itemInstance.getItem()) + { + /*Item air(TILE_AIR); + // Reading user data for fun + air.readUserData(itemInstance, bs);*/ + return ItemInstance(false); + } + + if (doUserData) + ReadUserData(itemInstance, bs); + + return itemInstance; } \ No newline at end of file diff --git a/source/network/PacketUtil.hpp b/source/network/PacketUtil.hpp index ef6f81c95..253a5de85 100644 --- a/source/network/PacketUtil.hpp +++ b/source/network/PacketUtil.hpp @@ -1,12 +1,19 @@ #pragma once +#include "thirdparty/raknet/BitStream.h" #include "world/entity/Entity.hpp" class PacketUtil { +public: static char Rot_degreesToChar(float degrees); static float Rot_charToDegrees(char charValue); static void Rot_entityToChar(const Entity* entity, char& yawChar, char& pitchChar); static void Rot_charToEntity(Entity* entity, char yawChar, char pitchChar); + + static void WriteUserData(const ItemInstance& item, RakNet::BitStream* bs, bool minData); + static void ReadUserData(ItemInstance& item, RakNet::BitStream* bs); + static void WriteItemInstance(const ItemInstance& item, RakNet::BitStream* bs, bool doUserData, bool minUserData = false); + static ItemInstance ReadItemInstance(RakNet::BitStream* bs, bool doUserData); }; diff --git a/source/network/RakNetInstance.cpp b/source/network/RakNetInstance.cpp index 91bd19750..6302378f0 100644 --- a/source/network/RakNetInstance.cpp +++ b/source/network/RakNetInstance.cpp @@ -9,6 +9,7 @@ #include "RakNetInstance.hpp" #include "MinecraftPackets.hpp" #include "GetTime.h" +#include "NetEventCallback.hpp" //#define LOG_PACKETS @@ -128,7 +129,7 @@ void RakNetInstance::pingForHosts(int port) m_pRakPeerInterface->Ping("255.255.255.255", port, true, 0); } -void RakNetInstance::runEvents(NetEventCallback* callback) +void RakNetInstance::runEvents(NetEventCallback& callback) { while (true) { @@ -149,7 +150,7 @@ void RakNetInstance::runEvents(NetEventCallback* callback) Packet* pUserPacket = MinecraftPackets::createPacket(packetType); if (pUserPacket) { - pUserPacket->read(pBitStream); + pUserPacket->read(*pBitStream); //LOG_PACKET("Packet: %d", packetType); pUserPacket->handle(pPacket->guid, callback); delete pUserPacket; @@ -166,23 +167,23 @@ void RakNetInstance::runEvents(NetEventCallback* callback) { // @BUG: Two players sending connection requests at the same time could cause one of them to fail to connect m_guid = pPacket->guid; - callback->onConnect(pPacket->guid); + callback.onConnect(pPacket->guid); break; } case ID_CONNECTION_ATTEMPT_FAILED: { - callback->onUnableToConnect(); + callback.onUnableToConnect(); break; } case ID_NEW_INCOMING_CONNECTION: { - callback->onNewClient(pPacket->guid); + callback.onNewClient(pPacket->guid); break; } case ID_DISCONNECTION_NOTIFICATION: case ID_CONNECTION_LOST: { - callback->onDisconnect(pPacket->guid); + callback.onDisconnect(pPacket->guid); break; } case ID_UNCONNECTED_PONG: @@ -260,7 +261,7 @@ void RakNetInstance::runEvents(NetEventCallback* callback) void RakNetInstance::send(Packet* packet) { RakNet::BitStream bs; - packet->write(&bs); + packet->write(bs); uint32_t result; if (m_bIsHost) @@ -287,14 +288,13 @@ void RakNetInstance::send(Packet* packet) } delete packet; - // return 1300; --- ida tells me this returns 1300. Huh } // this sends a specific peer a message void RakNetInstance::send(const RakNet::RakNetGUID& guid, Packet* packet) { RakNet::BitStream bs; - packet->write(&bs); + packet->write(bs); m_pRakPeerInterface->Send(&bs, HIGH_PRIORITY, RELIABLE, 0, guid, false); diff --git a/source/network/RakNetInstance.hpp b/source/network/RakNetInstance.hpp index 63623ddce..f3633ca6c 100644 --- a/source/network/RakNetInstance.hpp +++ b/source/network/RakNetInstance.hpp @@ -31,7 +31,7 @@ class RakNetInstance bool host(const std::string& name, int port, int maxConnections); bool isMyLocalGuid(const RakNet::RakNetGUID& guid); void pingForHosts(int port); - void runEvents(NetEventCallback*); + void runEvents(NetEventCallback&); void send(Packet* packet); void send(const RakNet::RakNetGUID& guid, Packet* packet); void stopPingForHosts(); diff --git a/source/network/packets/AddItemEntityPacket.cpp b/source/network/packets/AddItemEntityPacket.cpp new file mode 100644 index 000000000..591a87390 --- /dev/null +++ b/source/network/packets/AddItemEntityPacket.cpp @@ -0,0 +1,55 @@ +#include "AddItemEntityPacket.hpp" +#include "network/NetEventCallback.hpp" + +AddItemEntityPacket::AddItemEntityPacket(ItemEntity& itemEntity) +{ + m_entityId = itemEntity.m_EntityID; + m_pos = itemEntity.m_pos; + + ItemInstance& itemInstance = *itemEntity.m_pItemInstance; + m_itemId = itemInstance.getId(); + m_auxValue = itemInstance.getAuxValue(); + m_itemCount = itemInstance.m_count; + + m_velX = (itemEntity.m_vel.x * 128.0f); + m_velY = (itemEntity.m_vel.y * 128.0f); + m_velZ = (itemEntity.m_vel.z * 128.0f); + + itemEntity.m_vel.x = m_velX * (1.f / 128.f); + itemEntity.m_vel.y = m_velY * (1.f / 128.f); + itemEntity.m_vel.z = m_velZ * (1.f / 128.f); +} + +void AddItemEntityPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) +{ + callback.handle(guid, this); +} + +void AddItemEntityPacket::write(RakNet::BitStream& bs) +{ + bs.Write((unsigned char)PACKET_ADD_ITEM_ENTITY); + bs.Write(m_entityId); + bs.Write(m_itemId); + bs.Write(m_itemCount); + bs.Write(m_auxValue); + bs.Write(m_pos.x); + bs.Write(m_pos.y); + bs.Write(m_pos.z); + bs.Write(m_velX); + bs.Write(m_velY); + bs.Write(m_velZ); +} + +void AddItemEntityPacket::read(RakNet::BitStream& bs) +{ + bs.Read(m_entityId); + bs.Read(m_itemId); + bs.Read(m_itemCount); + bs.Read(m_auxValue); + bs.Read(m_pos.x); + bs.Read(m_pos.y); + bs.Read(m_pos.z); + bs.Read(m_velX); + bs.Read(m_velY); + bs.Read(m_velZ); +} diff --git a/source/network/packets/AddItemEntityPacket.hpp b/source/network/packets/AddItemEntityPacket.hpp new file mode 100644 index 000000000..fca207d78 --- /dev/null +++ b/source/network/packets/AddItemEntityPacket.hpp @@ -0,0 +1,34 @@ +#pragma once + +#include "../Packet.hpp" +#include "world/phys/Vec3.hpp" +#include "world/entity/ItemEntity.hpp" + +class AddItemEntityPacket : public Packet +{ +public: + AddItemEntityPacket() + { + m_entityId = 0; + m_itemId = TILE_AIR; + m_auxValue = 0; + m_itemCount = 0; + m_velX = m_velY = m_velZ = 0; + } + AddItemEntityPacket(ItemEntity& itemEntity); + +public: + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; + +public: + int32_t m_entityId; + Vec3 m_pos; + int16_t m_itemId; + int16_t m_auxValue; + int8_t m_itemCount; + int8_t m_velX; + int8_t m_velY; + int8_t m_velZ; +}; \ No newline at end of file diff --git a/source/network/packets/AddMobPacket.cpp b/source/network/packets/AddMobPacket.cpp new file mode 100644 index 000000000..f51403f39 --- /dev/null +++ b/source/network/packets/AddMobPacket.cpp @@ -0,0 +1,53 @@ +#include "AddMobPacket.hpp" +#include "network/NetEventCallback.hpp" +#include "network/RakIO.hpp" +#include "network/PacketUtil.hpp" +#include "world/entity/Mob.hpp" + +AddMobPacket::AddMobPacket(const Mob& mob) +{ + m_entityId = mob.m_EntityID; + m_entityTypeId = mob.getDescriptor().getEntityType().getId(); + m_pos = mob.m_pos; + m_rot = mob.m_rot; + m_entityData = mob.getEntityData(); +} + +void AddMobPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) +{ + callback.handle(guid, this); +} + +void AddMobPacket::write(RakNet::BitStream& bs) +{ + bs.Write((unsigned char)PACKET_ADD_MOB); + bs.Write(m_entityId); + bs.Write(m_entityTypeId); + bs.Write(m_pos.x); + bs.Write(m_pos.y); + bs.Write(m_pos.z); + bs.Write(PacketUtil::Rot_degreesToChar(m_rot.x)); + bs.Write(PacketUtil::Rot_degreesToChar(m_rot.y)); + + RakDataOutput dos(bs); + m_entityData.packAll(dos); +} + +void AddMobPacket::read(RakNet::BitStream& bs) +{ + bs.Read(m_entityId); + bs.Read(m_entityTypeId); + bs.Read(m_pos.x); + bs.Read(m_pos.y); + bs.Read(m_pos.z); + + char pitch, yaw; + bs.Read(pitch); + bs.Read(yaw); + + RakDataInput dis(bs); + m_unpack = SynchedEntityData::Unpack(dis); + + m_rot.x = PacketUtil::Rot_charToDegrees(pitch); + m_rot.y = PacketUtil::Rot_charToDegrees(yaw); +} diff --git a/source/network/packets/AddMobPacket.hpp b/source/network/packets/AddMobPacket.hpp new file mode 100644 index 000000000..d4c0fc2d7 --- /dev/null +++ b/source/network/packets/AddMobPacket.hpp @@ -0,0 +1,28 @@ +#pragma once + +#include "../Packet.hpp" +#include "world/phys/Vec2.hpp" +#include "world/entity/SynchedEntityData.hpp" + +class AddMobPacket : public Packet +{ +public: + AddMobPacket() + { + m_entityId = 0; + m_entityTypeId = 0; + } + AddMobPacket(const Mob& mob); + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; + const SynchedEntityData::ItemsArray& getUnpackedData() const { return m_unpack; } +public: + int32_t m_entityId; + int32_t m_entityTypeId; + Vec3 m_pos; + Vec2 m_rot; +private: + SynchedEntityData m_entityData; + SynchedEntityData::ItemsArray m_unpack; +}; \ No newline at end of file diff --git a/source/network/packets/AddPlayerPacket.cpp b/source/network/packets/AddPlayerPacket.cpp index 8110222dc..03142cfcc 100644 --- a/source/network/packets/AddPlayerPacket.cpp +++ b/source/network/packets/AddPlayerPacket.cpp @@ -6,7 +6,10 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ -#include "../Packet.hpp" +#include "AddPlayerPacket.hpp" +#include "network/NetEventCallback.hpp" +#include "network/PacketUtil.hpp" +#include "world/entity/Player.hpp" AddPlayerPacket::AddPlayerPacket(const Player *player) { @@ -15,30 +18,58 @@ AddPlayerPacket::AddPlayerPacket(const Player *player) m_id = player->m_EntityID; m_pos = player->m_pos; m_pos.y -= player->m_heightOffset; + m_rot = player->m_rot; + // apparently TILE_AIR isn't valid and causes a crash on 0.2.1 + // even though Mojang initializes this to TILE_AIR + m_itemId = TILE_STONE; + m_itemAuxValue = 0; + ItemInstance* pItem = player->getSelectedItem(); + if (pItem) + { + m_itemId = pItem->getId(); + m_itemAuxValue = pItem->getAuxValue(); + } } -void AddPlayerPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback) +void AddPlayerPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) { - pCallback->handle(guid, this); + callback.handle(guid, this); } -void AddPlayerPacket::write(RakNet::BitStream* bs) +void AddPlayerPacket::write(RakNet::BitStream& bs) { - bs->Write((unsigned char)PACKET_ADD_PLAYER); - bs->Write(m_guid); - bs->Write(m_name); - bs->Write(m_id); - bs->Write(m_pos.x); - bs->Write(m_pos.y); - bs->Write(m_pos.z); + bs.Write((unsigned char)PACKET_ADD_PLAYER); + bs.Write(m_guid); + bs.Write(m_name); + bs.Write(m_id); + bs.Write(m_pos.x); + bs.Write(m_pos.y); + bs.Write(m_pos.z); + +#if NETWORK_PROTOCOL_VERSION >= 3 + bs.Write(PacketUtil::Rot_degreesToChar(m_rot.x)); + bs.Write(PacketUtil::Rot_degreesToChar(m_rot.y)); + bs.Write(m_itemId); + bs.Write(m_itemAuxValue); +#endif } -void AddPlayerPacket::read(RakNet::BitStream* bs) +void AddPlayerPacket::read(RakNet::BitStream& bs) { - bs->Read(m_guid); - bs->Read(m_name); - bs->Read(m_id); - bs->Read(m_pos.x); - bs->Read(m_pos.y); - bs->Read(m_pos.z); + bs.Read(m_guid); + bs.Read(m_name); + bs.Read(m_id); + bs.Read(m_pos.x); + bs.Read(m_pos.y); + bs.Read(m_pos.z); + +#if NETWORK_PROTOCOL_VERSION >= 3 + char pitch, yaw; + bs.Read(pitch); + bs.Read(yaw); + bs.Read(m_itemId); + bs.Read(m_itemAuxValue); + m_rot.x = PacketUtil::Rot_charToDegrees(pitch); + m_rot.y = PacketUtil::Rot_charToDegrees(yaw); +#endif } diff --git a/source/network/packets/AddPlayerPacket.hpp b/source/network/packets/AddPlayerPacket.hpp new file mode 100644 index 000000000..9179eac39 --- /dev/null +++ b/source/network/packets/AddPlayerPacket.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include "../Packet.hpp" +#include "world/entity/Player.hpp" + +class AddPlayerPacket : public Packet +{ +public: + AddPlayerPacket() + { + m_id = 0; + m_itemId = 0; + m_itemAuxValue = 0; + } + AddPlayerPacket(const Player* player); + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; +public: + RakNet::RakNetGUID m_guid; + RakNet::RakString m_name; + int m_id; + Vec3 m_pos; + Vec2 m_rot; + int16_t m_itemId; + int16_t m_itemAuxValue; +}; \ No newline at end of file diff --git a/source/network/packets/AnimatePacket.cpp b/source/network/packets/AnimatePacket.cpp new file mode 100644 index 000000000..de54223d6 --- /dev/null +++ b/source/network/packets/AnimatePacket.cpp @@ -0,0 +1,27 @@ +#include "AnimatePacket.hpp" +#include "network/NetEventCallback.hpp" + +AnimatePacket::AnimatePacket(int32_t entityId, int8_t actionId) +{ + m_entityId = entityId; + m_actionId = actionId; +} + +void AnimatePacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) +{ + callback.handle(guid, this); +} + +void AnimatePacket::write(RakNet::BitStream& bs) +{ + bs.Write((unsigned char)PACKET_ANIMATE); + // Mojang swapped the order on PE for fun + bs.Write(m_actionId); + bs.Write(m_entityId); +} + +void AnimatePacket::read(RakNet::BitStream& bs) +{ + bs.Read(m_actionId); + bs.Read(m_entityId); +} diff --git a/source/network/packets/AnimatePacket.hpp b/source/network/packets/AnimatePacket.hpp new file mode 100644 index 000000000..284fd50e8 --- /dev/null +++ b/source/network/packets/AnimatePacket.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include "../Packet.hpp" + +class AnimatePacket : public Packet +{ +public: + enum Action + { + NONE, + SWING, + HURT + }; + +public: + AnimatePacket() + { + m_entityId = 0; + m_actionId = 0; + } + AnimatePacket(int32_t entityId, int8_t actionId); + + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; +public: + int32_t m_entityId; + int8_t m_actionId; +}; \ No newline at end of file diff --git a/source/network/packets/ChunkDataPacket.cpp b/source/network/packets/ChunkDataPacket.cpp index 9decfc371..7d598fcc0 100644 --- a/source/network/packets/ChunkDataPacket.cpp +++ b/source/network/packets/ChunkDataPacket.cpp @@ -6,19 +6,20 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ -#include "../Packet.hpp" +#include "ChunkDataPacket.hpp" +#include "network/NetEventCallback.hpp" #include "world/level/levelgen/chunk/LevelChunk.hpp" -void ChunkDataPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback) +void ChunkDataPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) { - pCallback->handle(guid, this); + callback.handle(guid, this); } -void ChunkDataPacket::write(RakNet::BitStream* bs) +void ChunkDataPacket::write(RakNet::BitStream& bs) { - bs->Write((unsigned char)PACKET_CHUNK_DATA); - bs->Write(m_chunkPos.x); - bs->Write(m_chunkPos.z); + bs.Write((unsigned char)PACKET_CHUNK_DATA); + bs.Write(m_chunkPos.x); + bs.Write(m_chunkPos.z); // Well, we first have to prepare the data. m_data.Reset(); @@ -45,13 +46,13 @@ void ChunkDataPacket::write(RakNet::BitStream* bs) } m_data.ResetReadPointer(); - bs->Write(m_data); + bs.Write(m_data); } -void ChunkDataPacket::read(RakNet::BitStream* bs) +void ChunkDataPacket::read(RakNet::BitStream& bs) { - bs->Read(m_chunkPos.x); - bs->Read(m_chunkPos.z); - bs->Read(m_data); + bs.Read(m_chunkPos.x); + bs.Read(m_chunkPos.z); + bs.Read(m_data); m_data.ResetReadPointer(); } diff --git a/source/network/packets/ChunkDataPacket.hpp b/source/network/packets/ChunkDataPacket.hpp new file mode 100644 index 000000000..daa494a5f --- /dev/null +++ b/source/network/packets/ChunkDataPacket.hpp @@ -0,0 +1,21 @@ +#pragma once + +#include "../Packet.hpp" +#include "world/level/levelgen/chunk/ChunkPos.hpp" + +class ChunkDataPacket : public Packet +{ +public: + ChunkDataPacket() + { + m_pChunk = nullptr; + } + ChunkDataPacket(const ChunkPos& pos, LevelChunk* c) :m_chunkPos(pos), m_pChunk(c) {} + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; +public: + ChunkPos m_chunkPos; + RakNet::BitStream m_data; + LevelChunk* m_pChunk; +}; \ No newline at end of file diff --git a/source/network/packets/EntityEventPacket.cpp b/source/network/packets/EntityEventPacket.cpp new file mode 100644 index 000000000..4192c6855 --- /dev/null +++ b/source/network/packets/EntityEventPacket.cpp @@ -0,0 +1,26 @@ +#include "EntityEventPacket.hpp" +#include "network/NetEventCallback.hpp" + +EntityEventPacket::EntityEventPacket(int32_t entityId, int8_t eventId) +{ + m_entityId = entityId; + m_eventId = eventId; +} + +void EntityEventPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) +{ + callback.handle(guid, this); +} + +void EntityEventPacket::write(RakNet::BitStream& bs) +{ + bs.Write((unsigned char)PACKET_ENTITY_EVENT); + bs.Write(m_entityId); + bs.Write(m_eventId); +} + +void EntityEventPacket::read(RakNet::BitStream& bs) +{ + bs.Read(m_entityId); + bs.Read(m_eventId); +} diff --git a/source/network/packets/EntityEventPacket.hpp b/source/network/packets/EntityEventPacket.hpp new file mode 100644 index 000000000..03ea5f8a0 --- /dev/null +++ b/source/network/packets/EntityEventPacket.hpp @@ -0,0 +1,21 @@ +#pragma once + +#include "../Packet.hpp" + +class EntityEventPacket : public Packet +{ +public: + EntityEventPacket() + { + m_entityId = 0; + m_eventId = 0; + } + EntityEventPacket(int32_t entityId, int8_t eventId); + + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; +public: + int32_t m_entityId; + int8_t m_eventId; +}; \ No newline at end of file diff --git a/source/network/packets/InteractPacket.cpp b/source/network/packets/InteractPacket.cpp new file mode 100644 index 000000000..f66b4b9fb --- /dev/null +++ b/source/network/packets/InteractPacket.cpp @@ -0,0 +1,30 @@ +#include "InteractPacket.hpp" +#include "network/NetEventCallback.hpp" + +InteractPacket::InteractPacket(int32_t sourceId, int32_t targetId, int8_t actionType) +{ + m_sourceId = sourceId; + m_targetId = targetId; + m_actionType = actionType; +} + +void InteractPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) +{ + callback.handle(guid, this); +} + +void InteractPacket::write(RakNet::BitStream& bs) +{ + bs.Write((unsigned char)PACKET_INTERACT); + bs.Write(m_actionType); + bs.Write(m_sourceId); + bs.Write(m_targetId); +} + +void InteractPacket::read(RakNet::BitStream& bs) +{ + // m_actionType is sent last on Java + bs.Read(m_actionType); + bs.Read(m_sourceId); + bs.Read(m_targetId); +} diff --git a/source/network/packets/InteractPacket.hpp b/source/network/packets/InteractPacket.hpp new file mode 100644 index 000000000..4740e454f --- /dev/null +++ b/source/network/packets/InteractPacket.hpp @@ -0,0 +1,31 @@ +#pragma once + +#include "../Packet.hpp" + +class InteractPacket : public Packet +{ +public: + enum ActionType + { + NONE, + INTERACT, + ATTACK + }; + +public: + InteractPacket() + { + m_sourceId = 0; + m_targetId = 0; + m_actionType = INTERACT; + } + InteractPacket(int32_t sourceId, int32_t targetId, int8_t actionType); + + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; +public: + int32_t m_sourceId; + int32_t m_targetId; + int8_t m_actionType; +}; \ No newline at end of file diff --git a/source/network/packets/LevelDataPacket.cpp b/source/network/packets/LevelDataPacket.cpp index 68c7dce06..859ac0e4a 100644 --- a/source/network/packets/LevelDataPacket.cpp +++ b/source/network/packets/LevelDataPacket.cpp @@ -6,15 +6,18 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ -#include "../Packet.hpp" +#include "LevelDataPacket.hpp" +#include "network/NetEventCallback.hpp" +#include "world/level/Level.hpp" #include "world/level/levelgen/chunk/LevelChunk.hpp" +#include "ChunkDataPacket.hpp" -void LevelDataPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback) +void LevelDataPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) { - pCallback->handle(guid, this); + callback.handle(guid, this); } -void LevelDataPacket::write(RakNet::BitStream* pbs) +void LevelDataPacket::write(RakNet::BitStream& bs) { // @TODO: Maybe offload this to a different 'worker thread'? Or maybe just the compression job? @@ -22,41 +25,41 @@ void LevelDataPacket::write(RakNet::BitStream* pbs) int chunksX = C_MAX_CHUNKS_X; int chunksZ = C_MAX_CHUNKS_Z; int minus9999 = -9999; - RakNet::BitStream bs; - pbs->Write((unsigned char)PACKET_LEVEL_DATA); + RakNet::BitStream bs2; + bs.Write((unsigned char)PACKET_LEVEL_DATA); int uncompMagic = 12847812, compMagic = 58712758, chunkSepMagic = 284787658; - bs.Write(uncompMagic); - bs.Write(chunksX); - bs.Write(chunksZ); + bs2.Write(uncompMagic); + bs2.Write(chunksX); + bs2.Write(chunksZ); ChunkPos chunkPos(0, 0); for (chunkPos.x = 0; chunkPos.x < chunksX; chunkPos.x++) { for (chunkPos.z = 0; chunkPos.z < chunksZ; chunkPos.z++) { - bs.Write(chunkSepMagic); + bs2.Write(chunkSepMagic); - RakNet::BitStream bs2; + RakNet::BitStream bs3; LevelChunk* pChunk = m_pLevel->getChunk(chunkPos); ChunkDataPacket cdp(chunkPos, pChunk); - cdp.write(&bs2); + cdp.write(bs3); - int dataSize = int(bs2.GetNumberOfBytesUsed()); - bs.Write(dataSize); - bs.Write((const char*)bs2.GetData(), dataSize); + int dataSize = int(bs3.GetNumberOfBytesUsed()); + bs2.Write(dataSize); + bs2.Write((const char*)bs3.GetData(), dataSize); } } // compress it size_t compSize = 0; - size_t uncompSize = bs.GetNumberOfBytesUsed(); + size_t uncompSize = bs2.GetNumberOfBytesUsed(); uint8_t* pCompressedData = nullptr; if (uncompSize > 1024) { // takes about 5ms on release to compress everything on L4, compression ratio is around 14-15%. // Increase or decrease this depending on your server's load. - pCompressedData = ZlibDeflateToMemoryLvl(bs.GetData(), uncompSize, &compSize, 4); + pCompressedData = ZlibDeflateToMemoryLvl(bs2.GetData(), uncompSize, &compSize, 4); } if (pCompressedData) @@ -65,11 +68,11 @@ void LevelDataPacket::write(RakNet::BitStream* pbs) //LOG_I("Compression ratio: %.2f (%d comp, %d uncomp)", ratio, int(compSize), int(uncompSize)); int cs2 = int(compSize), us2 = int(uncompSize); - bs.Reset(); - bs.Write(compMagic); - bs.Write(us2); - bs.Write(cs2); - bs.Write((const char*)pCompressedData, compSize); + bs2.Reset(); + bs2.Write(compMagic); + bs2.Write(us2); + bs2.Write(cs2); + bs2.Write((const char*)pCompressedData, compSize); SAFE_DELETE_ARRAY(pCompressedData); } else @@ -77,11 +80,11 @@ void LevelDataPacket::write(RakNet::BitStream* pbs) //LOG_I("Level not compressed."); } - pbs->Write(bs); + bs.Write(bs2); return; } -void LevelDataPacket::read(RakNet::BitStream* bs) +void LevelDataPacket::read(RakNet::BitStream& bs) { - bs->Read(m_data); + bs.Read(m_data); } diff --git a/source/network/packets/LevelDataPacket.hpp b/source/network/packets/LevelDataPacket.hpp new file mode 100644 index 000000000..7055dee4b --- /dev/null +++ b/source/network/packets/LevelDataPacket.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include "../Packet.hpp" + +class LevelDataPacket : public Packet +{ +public: + LevelDataPacket() + { + m_pLevel = nullptr; + } + LevelDataPacket(Level* level) : m_pLevel(level) {} + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; +public: + RakNet::BitStream m_data; + Level* m_pLevel; +}; \ No newline at end of file diff --git a/source/network/packets/LevelEventPacket.cpp b/source/network/packets/LevelEventPacket.cpp new file mode 100644 index 000000000..220e039db --- /dev/null +++ b/source/network/packets/LevelEventPacket.cpp @@ -0,0 +1,35 @@ +#include "LevelEventPacket.hpp" +#include "network/NetEventCallback.hpp" + +LevelEventPacket::LevelEventPacket(int16_t eventId, const TilePos& pos, int32_t data) +{ + m_eventId = eventId; + m_pos = pos; + m_data = data; +} + +void LevelEventPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) +{ + callback.handle(guid, this); +} + +void LevelEventPacket::write(RakNet::BitStream& bs) +{ + bs.Write((unsigned char)PACKET_LEVEL_EVENT); + bs.Write(m_eventId); + bs.Write((int16_t)m_pos.x); + bs.Write((int16_t)m_pos.y); + bs.Write((int16_t)m_pos.z); + bs.Write(m_data); +} + +void LevelEventPacket::read(RakNet::BitStream& bs) +{ + bs.Read(m_eventId); + int16_t x, y, z; + bs.Read(x); + bs.Read(y); + bs.Read(z); + m_pos = TilePos(x, y, z); + bs.Read(m_data); +} diff --git a/source/network/packets/LevelEventPacket.hpp b/source/network/packets/LevelEventPacket.hpp new file mode 100644 index 000000000..4edbfa840 --- /dev/null +++ b/source/network/packets/LevelEventPacket.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include "../Packet.hpp" +#include "world/level/TilePos.hpp" + +class LevelEventPacket : public Packet +{ +public: + LevelEventPacket() + { + m_eventId = 0; + m_data = 0; + } + LevelEventPacket(int16_t eventId, const TilePos& pos, int32_t data); + + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; +public: + int16_t m_eventId; + TilePos m_pos; + int32_t m_data; +}; \ No newline at end of file diff --git a/source/network/packets/LoginPacket.cpp b/source/network/packets/LoginPacket.cpp index b3444a15d..6dff24c1f 100644 --- a/source/network/packets/LoginPacket.cpp +++ b/source/network/packets/LoginPacket.cpp @@ -6,26 +6,27 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ -#include "../Packet.hpp" +#include "LoginPacket.hpp" +#include "network/NetEventCallback.hpp" -void LoginPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback) +void LoginPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) { - pCallback->handle(guid, this); + callback.handle(guid, this); } -void LoginPacket::write(RakNet::BitStream* bs) +void LoginPacket::write(RakNet::BitStream& bs) { - bs->Write((unsigned char)PACKET_LOGIN); - bs->Write(m_str); - bs->Write(m_clientNetworkVersion); - bs->Write(m_clientNetworkVersion2); + bs.Write((unsigned char)PACKET_LOGIN); + bs.Write(m_userName); + bs.Write(m_clientNetworkVersion); + bs.Write(m_clientNetworkVersionMin); } -void LoginPacket::read(RakNet::BitStream* bs) +void LoginPacket::read(RakNet::BitStream& bs) { - bs->Read(m_str); + bs.Read(m_userName); - if (!bs->Read(m_clientNetworkVersion)) + if (!bs.Read(m_clientNetworkVersion)) return; - bs->Read(m_clientNetworkVersion2); + bs.Read(m_clientNetworkVersionMin); } diff --git a/source/network/packets/LoginPacket.hpp b/source/network/packets/LoginPacket.hpp new file mode 100644 index 000000000..f2dd6dc89 --- /dev/null +++ b/source/network/packets/LoginPacket.hpp @@ -0,0 +1,28 @@ +#pragma once + +#include +#include "../Packet.hpp" + +class LoginPacket : public Packet +{ +public: + LoginPacket() + { + m_clientNetworkVersion = 0; + m_clientNetworkVersionMin = 0; + } + LoginPacket(const std::string& uname, int protocolVersion) + { + m_userName = RakNet::RakString(uname.c_str()); + m_clientNetworkVersion = protocolVersion; + m_clientNetworkVersionMin = protocolVersion; + } + + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; +public: + RakNet::RakString m_userName; + int m_clientNetworkVersion; + int m_clientNetworkVersionMin; +}; \ No newline at end of file diff --git a/source/network/packets/LoginStatusPacket.cpp b/source/network/packets/LoginStatusPacket.cpp index da3f25294..5c218bfd6 100644 --- a/source/network/packets/LoginStatusPacket.cpp +++ b/source/network/packets/LoginStatusPacket.cpp @@ -6,20 +6,21 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ -#include "../Packet.hpp" +#include "LoginStatusPacket.hpp" +#include "network/NetEventCallback.hpp" -void LoginStatusPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback) +void LoginStatusPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) { - pCallback->handle(guid, this); + callback.handle(guid, this); } -void LoginStatusPacket::write(RakNet::BitStream* bs) +void LoginStatusPacket::write(RakNet::BitStream& bs) { - bs->Write((unsigned char)PACKET_LOGIN_STATUS); - bs->Write(m_loginStatus); + bs.Write((unsigned char)PACKET_LOGIN_STATUS); + bs.Write(m_loginStatus); } -void LoginStatusPacket::read(RakNet::BitStream* bs) +void LoginStatusPacket::read(RakNet::BitStream& bs) { - bs->Read(m_loginStatus); + bs.Read(m_loginStatus); } diff --git a/source/network/packets/LoginStatusPacket.hpp b/source/network/packets/LoginStatusPacket.hpp new file mode 100644 index 000000000..4d629b667 --- /dev/null +++ b/source/network/packets/LoginStatusPacket.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include "../Packet.hpp" + +class LoginStatusPacket : public Packet +{ +public: + enum LoginStatus + { + STATUS_SUCCESS, + STATUS_CLIENT_OUTDATED, + STATUS_SERVER_OUTDATED + }; + +public: + LoginStatusPacket(LoginStatus loginStatus = STATUS_SUCCESS) + { + m_loginStatus = loginStatus; + } + + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; +public: + LoginStatus m_loginStatus; +}; \ No newline at end of file diff --git a/source/network/packets/MessagePacket.cpp b/source/network/packets/MessagePacket.cpp index a4bc4579c..df1d65379 100644 --- a/source/network/packets/MessagePacket.cpp +++ b/source/network/packets/MessagePacket.cpp @@ -6,20 +6,21 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ -#include "../Packet.hpp" +#include "MessagePacket.hpp" +#include "network/NetEventCallback.hpp" -void MessagePacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback) +void MessagePacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) { - pCallback->handle(guid, this); + callback.handle(guid, this); } -void MessagePacket::write(RakNet::BitStream* bs) +void MessagePacket::write(RakNet::BitStream& bs) { - bs->Write((unsigned char)PACKET_MESSAGE); - bs->Write(m_str); + bs.Write((unsigned char)PACKET_MESSAGE); + bs.Write(m_str); } -void MessagePacket::read(RakNet::BitStream* bs) +void MessagePacket::read(RakNet::BitStream& bs) { - bs->Read(m_str); + bs.Read(m_str); } \ No newline at end of file diff --git a/source/network/packets/MessagePacket.hpp b/source/network/packets/MessagePacket.hpp new file mode 100644 index 000000000..ab23d6e3d --- /dev/null +++ b/source/network/packets/MessagePacket.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include +#include "../Packet.hpp" + +class MessagePacket : public Packet +{ +public: + MessagePacket() {} + MessagePacket(const std::string& msg) + { + m_str = msg.c_str(); + } + + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; +public: + RakNet::RakString m_str; +}; \ No newline at end of file diff --git a/source/network/packets/MoveEntityPacket.cpp b/source/network/packets/MoveEntityPacket.cpp new file mode 100644 index 000000000..0af3d1aa9 --- /dev/null +++ b/source/network/packets/MoveEntityPacket.cpp @@ -0,0 +1,16 @@ +#include "MoveEntityPacket.hpp" +#include "network/NetEventCallback.hpp" + +void MoveEntityPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) +{ + callback.handle(guid, this); +} + +void MoveEntityPacket::write(RakNet::BitStream& bs) +{ + bs.Write((unsigned char)PACKET_MOVE_ENTITY); +} + +void MoveEntityPacket::read(RakNet::BitStream& bs) +{ +} diff --git a/source/network/packets/MoveEntityPacket.hpp b/source/network/packets/MoveEntityPacket.hpp new file mode 100644 index 000000000..519e592ea --- /dev/null +++ b/source/network/packets/MoveEntityPacket.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include "../Packet.hpp" +#include "world/phys/Vec2.hpp" +#include "world/phys/Vec3.hpp" + +class MoveEntityPacket : public Packet +{ +public: + MoveEntityPacket() + { + m_entityId = 0; + m_bHasRot = false; + } + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; +public: + int32_t m_entityId; + Vec3 m_pos; + Vec2 m_rot; + bool m_bHasRot; +}; \ No newline at end of file diff --git a/source/network/packets/MoveEntityPacket_PosRot.cpp b/source/network/packets/MoveEntityPacket_PosRot.cpp new file mode 100644 index 000000000..8f09ea5fc --- /dev/null +++ b/source/network/packets/MoveEntityPacket_PosRot.cpp @@ -0,0 +1,47 @@ +#include "MoveEntityPacket_PosRot.hpp" +#include "network/NetEventCallback.hpp" + +void MoveEntityPacket_PosRot::_init() +{ + m_bHasRot = true; +} + +MoveEntityPacket_PosRot::MoveEntityPacket_PosRot() + : MoveEntityPacket() +{ + _init(); +} + +MoveEntityPacket_PosRot::MoveEntityPacket_PosRot(int32_t entityId, const Vec3& pos, const Vec2& rot) +{ + _init(); + m_entityId = entityId; + m_pos = pos; + m_rot = rot; +} + +void MoveEntityPacket_PosRot::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) +{ + callback.handle(guid, this); +} + +void MoveEntityPacket_PosRot::write(RakNet::BitStream& bs) +{ + bs.Write((unsigned char)PACKET_MOVE_ENTITY_POS_ROT); + bs.Write(m_entityId); + bs.Write(m_pos.x); + bs.Write(m_pos.y); + bs.Write(m_pos.z); + bs.Write(m_rot.x); + bs.Write(m_rot.y); +} + +void MoveEntityPacket_PosRot::read(RakNet::BitStream& bs) +{ + bs.Read(m_entityId); + bs.Read(m_pos.x); + bs.Read(m_pos.y); + bs.Read(m_pos.z); + bs.Read(m_rot.x); + bs.Read(m_rot.y); +} \ No newline at end of file diff --git a/source/network/packets/MoveEntityPacket_PosRot.hpp b/source/network/packets/MoveEntityPacket_PosRot.hpp new file mode 100644 index 000000000..8d85a8aa3 --- /dev/null +++ b/source/network/packets/MoveEntityPacket_PosRot.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include "../Packet.hpp" +#include "MoveEntityPacket.hpp" +#include "world/phys/Vec2.hpp" +#include "world/phys/Vec3.hpp" + +class MoveEntityPacket_PosRot : public MoveEntityPacket +{ +private: + void _init(); +public: + MoveEntityPacket_PosRot(); + MoveEntityPacket_PosRot(int32_t entityId, const Vec3& pos, const Vec2& rot); +public: + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; +}; \ No newline at end of file diff --git a/source/network/packets/MovePlayerPacket.cpp b/source/network/packets/MovePlayerPacket.cpp index e29333431..ca1471d19 100644 --- a/source/network/packets/MovePlayerPacket.cpp +++ b/source/network/packets/MovePlayerPacket.cpp @@ -6,41 +6,42 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ -#include "../Packet.hpp" +#include "MovePlayerPacket.hpp" +#include "network/NetEventCallback.hpp" -void MovePlayerPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback) +void MovePlayerPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) { - pCallback->handle(guid, this); + callback.handle(guid, this); } -void MovePlayerPacket::write(RakNet::BitStream* bs) +void MovePlayerPacket::write(RakNet::BitStream& bs) { - bs->Write((unsigned char)PACKET_MOVE_PLAYER); - bs->Write(m_id); - bs->Write(m_pos.x); - bs->Write(m_pos.y); - bs->Write(m_pos.z); + bs.Write((unsigned char)PACKET_MOVE_PLAYER); + bs.Write(m_id); + bs.Write(m_pos.x); + bs.Write(m_pos.y); + bs.Write(m_pos.z); #if NETWORK_PROTOCOL_VERSION <= 2 - bs->Write(m_rot.y); - bs->Write(m_rot.x); + bs.Write(m_rot.y); + bs.Write(m_rot.x); #else - bs->Write(m_rot.x); - bs->Write(m_rot.y); + bs.Write(m_rot.x); + bs.Write(m_rot.y); #endif } -void MovePlayerPacket::read(RakNet::BitStream* bs) +void MovePlayerPacket::read(RakNet::BitStream& bs) { - bs->Read(m_id); - bs->Read(m_pos.x); - bs->Read(m_pos.y); - bs->Read(m_pos.z); + bs.Read(m_id); + bs.Read(m_pos.x); + bs.Read(m_pos.y); + bs.Read(m_pos.z); #if NETWORK_PROTOCOL_VERSION <= 2 - bs->Read(m_rot.y); - bs->Read(m_rot.x); + bs.Read(m_rot.y); + bs.Read(m_rot.x); #else - bs->Read(m_rot.x); - bs->Read(m_rot.y); + bs.Read(m_rot.x); + bs.Read(m_rot.y); #endif } diff --git a/source/network/packets/MovePlayerPacket.hpp b/source/network/packets/MovePlayerPacket.hpp new file mode 100644 index 000000000..1066d7b15 --- /dev/null +++ b/source/network/packets/MovePlayerPacket.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include "../Packet.hpp" +#include "world/phys/Vec2.hpp" +#include "world/phys/Vec3.hpp" + +class MovePlayerPacket : public Packet +{ +public: + MovePlayerPacket() + { + m_id = 0; + } + MovePlayerPacket(int id, const Vec3& pos, const Vec2& rot) : m_id(id), m_pos(pos), m_rot(rot) {} + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; +public: + int m_id; + Vec3 m_pos; + Vec2 m_rot; +}; \ No newline at end of file diff --git a/source/network/packets/PlaceBlockPacket.cpp b/source/network/packets/PlaceBlockPacket.cpp index 136516ade..a67a789a6 100644 --- a/source/network/packets/PlaceBlockPacket.cpp +++ b/source/network/packets/PlaceBlockPacket.cpp @@ -6,44 +6,45 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ -#include "../Packet.hpp" +#include "PlaceBlockPacket.hpp" +#include "network/NetEventCallback.hpp" -void PlaceBlockPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback) +void PlaceBlockPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) { - pCallback->handle(guid, this); + callback.handle(guid, this); } -void PlaceBlockPacket::write(RakNet::BitStream* bs) +void PlaceBlockPacket::write(RakNet::BitStream& bs) { - bs->Write((unsigned char)PACKET_PLACE_BLOCK); - bs->Write(m_entityId); + bs.Write((unsigned char)PACKET_PLACE_BLOCK); + bs.Write(m_entityId); // The order of the TilePos matters here - bs->Write(m_pos.x); - bs->Write(m_pos.z); - bs->Write(m_pos.y); + bs.Write(m_pos.x); + bs.Write(m_pos.z); + bs.Write(m_pos.y); - bs->Write(m_face); - bs->Write(m_tileTypeId); + bs.Write(m_face); + bs.Write(m_tileTypeId); #if NETWORK_PROTOCOL_VERSION >= 3 - bs->Write(m_data); + bs.Write(m_data); #endif } -void PlaceBlockPacket::read(RakNet::BitStream* bs) +void PlaceBlockPacket::read(RakNet::BitStream& bs) { - bs->Read(m_entityId); + bs.Read(m_entityId); // The order of the TilePos matters here - bs->Read(m_pos.x); - bs->Read(m_pos.z); + bs.Read(m_pos.x); + bs.Read(m_pos.z); uint8_t y; - bs->Read(y); + bs.Read(y); m_pos.y = y; - bs->Read(m_face); - bs->Read(m_tileTypeId); + bs.Read(m_face); + bs.Read(m_tileTypeId); #if NETWORK_PROTOCOL_VERSION >= 3 - bs->Read(m_data); + bs.Read(m_data); #endif } diff --git a/source/network/packets/PlaceBlockPacket.hpp b/source/network/packets/PlaceBlockPacket.hpp new file mode 100644 index 000000000..28930f86c --- /dev/null +++ b/source/network/packets/PlaceBlockPacket.hpp @@ -0,0 +1,35 @@ +#pragma once + +#include "../Packet.hpp" +#include "common/Utils.hpp" +#include "world/level/TilePos.hpp" + +class PlaceBlockPacket : public Packet +{ +public: + PlaceBlockPacket() + { + m_entityId = 0; + m_tileTypeId = TILE_AIR; + m_face = 0; + m_data = 0; + } + PlaceBlockPacket(int entityId, const TilePos& pos, TileID tileTypeId, Facing::Name face, TileData data) + { + m_entityId = entityId; + m_pos = pos; + m_tileTypeId = tileTypeId; + m_face = face; + m_data = data; + } + + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; +public: + int m_entityId; + TilePos m_pos; + TileID m_tileTypeId; + uint8_t m_face; + TileData m_data; +}; \ No newline at end of file diff --git a/source/network/packets/PlayerEquipmentPacket.cpp b/source/network/packets/PlayerEquipmentPacket.cpp index 8da924f89..274c64b44 100644 --- a/source/network/packets/PlayerEquipmentPacket.cpp +++ b/source/network/packets/PlayerEquipmentPacket.cpp @@ -6,22 +6,23 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ -#include "../Packet.hpp" +#include "PlayerEquipmentPacket.hpp" +#include "network/NetEventCallback.hpp" -void PlayerEquipmentPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback) +void PlayerEquipmentPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) { - pCallback->handle(guid, this); + callback.handle(guid, this); } -void PlayerEquipmentPacket::write(RakNet::BitStream* bs) +void PlayerEquipmentPacket::write(RakNet::BitStream& bs) { - bs->Write((unsigned char)PACKET_PLAYER_EQUIPMENT); - bs->Write(m_playerID); - bs->Write(m_itemID); + bs.Write((unsigned char)PACKET_PLAYER_EQUIPMENT); + bs.Write(m_playerID); + bs.Write(m_itemID); } -void PlayerEquipmentPacket::read(RakNet::BitStream* bs) +void PlayerEquipmentPacket::read(RakNet::BitStream& bs) { - bs->Read(m_playerID); - bs->Read(m_itemID); + bs.Read(m_playerID); + bs.Read(m_itemID); } diff --git a/source/network/packets/PlayerEquipmentPacket.hpp b/source/network/packets/PlayerEquipmentPacket.hpp new file mode 100644 index 000000000..b43e67892 --- /dev/null +++ b/source/network/packets/PlayerEquipmentPacket.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include "../Packet.hpp" + +class PlayerEquipmentPacket : public Packet +{ +public: + PlayerEquipmentPacket() + { + m_playerID = 0; + m_itemID = 0; + } + PlayerEquipmentPacket(int playerID, int itemID) : m_playerID(playerID), m_itemID(itemID) {} + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; +public: + int m_playerID; + uint16_t m_itemID; +}; diff --git a/source/network/packets/ReadyPacket.cpp b/source/network/packets/ReadyPacket.cpp index 2f6ae3efd..0063bd2bf 100644 --- a/source/network/packets/ReadyPacket.cpp +++ b/source/network/packets/ReadyPacket.cpp @@ -6,20 +6,21 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ -#include "../Packet.hpp" +#include "ReadyPacket.hpp" +#include "network/NetEventCallback.hpp" -void ReadyPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback) +void ReadyPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) { - pCallback->handle(guid, this); + callback.handle(guid, this); } -void ReadyPacket::write(RakNet::BitStream* bs) +void ReadyPacket::write(RakNet::BitStream& bs) { - bs->Write((unsigned char)PACKET_READY); - bs->Write(m_ready); + bs.Write((unsigned char)PACKET_READY); + bs.Write(m_ready); } -void ReadyPacket::read(RakNet::BitStream* bs) +void ReadyPacket::read(RakNet::BitStream& bs) { - bs->Read(m_ready); + bs.Read(m_ready); } diff --git a/source/network/packets/ReadyPacket.hpp b/source/network/packets/ReadyPacket.hpp new file mode 100644 index 000000000..e835c4108 --- /dev/null +++ b/source/network/packets/ReadyPacket.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include "../Packet.hpp" + +class ReadyPacket : public Packet +{ +public: + ReadyPacket(uint8_t ready = 0) + { + m_ready = ready; + } + + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; +public: + uint8_t m_ready; +}; \ No newline at end of file diff --git a/source/network/packets/RemoveBlockPacket.cpp b/source/network/packets/RemoveBlockPacket.cpp index a02192a69..25d7533ca 100644 --- a/source/network/packets/RemoveBlockPacket.cpp +++ b/source/network/packets/RemoveBlockPacket.cpp @@ -6,32 +6,33 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ -#include "../Packet.hpp" +#include "RemoveBlockPacket.hpp" +#include "network/NetEventCallback.hpp" -void RemoveBlockPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback) +void RemoveBlockPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) { - pCallback->handle(guid, this); + callback.handle(guid, this); } -void RemoveBlockPacket::write(RakNet::BitStream* bs) +void RemoveBlockPacket::write(RakNet::BitStream& bs) { - bs->Write((unsigned char)PACKET_REMOVE_BLOCK); - bs->Write(m_entityId); + bs.Write((unsigned char)PACKET_REMOVE_BLOCK); + bs.Write(m_entityId); // The order of the TilePos matters here - bs->Write(m_pos.x); - bs->Write(m_pos.z); - bs->Write(m_pos.y); + bs.Write(m_pos.x); + bs.Write(m_pos.z); + bs.Write(m_pos.y); } -void RemoveBlockPacket::read(RakNet::BitStream* bs) +void RemoveBlockPacket::read(RakNet::BitStream& bs) { - bs->Read(m_entityId); + bs.Read(m_entityId); // The order of the TilePos matters here - bs->Read(m_pos.x); - bs->Read(m_pos.z); + bs.Read(m_pos.x); + bs.Read(m_pos.z); uint8_t y; - bs->Read(y); + bs.Read(y); m_pos.y = y; } diff --git a/source/network/packets/RemoveBlockPacket.hpp b/source/network/packets/RemoveBlockPacket.hpp new file mode 100644 index 000000000..5f113eaff --- /dev/null +++ b/source/network/packets/RemoveBlockPacket.hpp @@ -0,0 +1,21 @@ +#pragma once + +#include "../Packet.hpp" +#include "world/level/TilePos.hpp" + +class RemoveBlockPacket : public Packet +{ +public: + RemoveBlockPacket() + { + m_entityId = 0; + } + RemoveBlockPacket(int id, const TilePos& pos) :m_entityId(id), m_pos(pos) {} + + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; +public: + int m_entityId; + TilePos m_pos; +}; \ No newline at end of file diff --git a/source/network/packets/RemoveEntityPacket.cpp b/source/network/packets/RemoveEntityPacket.cpp index 16ee9eb2b..ccf44f41f 100644 --- a/source/network/packets/RemoveEntityPacket.cpp +++ b/source/network/packets/RemoveEntityPacket.cpp @@ -6,20 +6,21 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ -#include "../Packet.hpp" +#include "RemoveEntityPacket.hpp" +#include "network/NetEventCallback.hpp" -void RemoveEntityPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback) +void RemoveEntityPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) { - pCallback->handle(guid, this); + callback.handle(guid, this); } -void RemoveEntityPacket::write(RakNet::BitStream* bs) +void RemoveEntityPacket::write(RakNet::BitStream& bs) { - bs->Write((unsigned char)PACKET_REMOVE_ENTITY); - bs->Write(m_id); + bs.Write((unsigned char)PACKET_REMOVE_ENTITY); + bs.Write(m_id); } -void RemoveEntityPacket::read(RakNet::BitStream* bs) +void RemoveEntityPacket::read(RakNet::BitStream& bs) { - bs->Read(m_id); + bs.Read(m_id); } diff --git a/source/network/packets/RemoveEntityPacket.hpp b/source/network/packets/RemoveEntityPacket.hpp new file mode 100644 index 000000000..748738c75 --- /dev/null +++ b/source/network/packets/RemoveEntityPacket.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include "../Packet.hpp" + +class RemoveEntityPacket : public Packet +{ +public: + RemoveEntityPacket() + { + m_id = 0; + } + RemoveEntityPacket(int id) { m_id = id; } + + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; +public: + int m_id; +}; \ No newline at end of file diff --git a/source/network/packets/RequestChunkPacket.cpp b/source/network/packets/RequestChunkPacket.cpp index a5f995681..dc9daeb27 100644 --- a/source/network/packets/RequestChunkPacket.cpp +++ b/source/network/packets/RequestChunkPacket.cpp @@ -6,22 +6,23 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ -#include "../Packet.hpp" +#include "RequestChunkPacket.hpp" +#include "network/NetEventCallback.hpp" -void RequestChunkPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback) +void RequestChunkPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) { - pCallback->handle(guid, this); + callback.handle(guid, this); } -void RequestChunkPacket::write(RakNet::BitStream* bs) +void RequestChunkPacket::write(RakNet::BitStream& bs) { - bs->Write((unsigned char)PACKET_REQUEST_CHUNK); - bs->Write(m_chunkPos.x); - bs->Write(m_chunkPos.z); + bs.Write((unsigned char)PACKET_REQUEST_CHUNK); + bs.Write(m_chunkPos.x); + bs.Write(m_chunkPos.z); } -void RequestChunkPacket::read(RakNet::BitStream* bs) +void RequestChunkPacket::read(RakNet::BitStream& bs) { - bs->Read(m_chunkPos.x); - bs->Read(m_chunkPos.z); + bs.Read(m_chunkPos.x); + bs.Read(m_chunkPos.z); } diff --git a/source/network/packets/RequestChunkPacket.hpp b/source/network/packets/RequestChunkPacket.hpp new file mode 100644 index 000000000..f49d62ad8 --- /dev/null +++ b/source/network/packets/RequestChunkPacket.hpp @@ -0,0 +1,16 @@ +#pragma once + +#include "../Packet.hpp" +#include "world/level/levelgen/chunk/ChunkPos.hpp" + +class RequestChunkPacket : public Packet +{ +public: + RequestChunkPacket() {} + RequestChunkPacket(const ChunkPos& pos) { m_chunkPos = pos; } + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; +public: + ChunkPos m_chunkPos; +}; \ No newline at end of file diff --git a/source/network/packets/RespawnPacket.cpp b/source/network/packets/RespawnPacket.cpp new file mode 100644 index 000000000..5a94fc67e --- /dev/null +++ b/source/network/packets/RespawnPacket.cpp @@ -0,0 +1,30 @@ +#include "RespawnPacket.hpp" +#include "network/NetEventCallback.hpp" + +RespawnPacket::RespawnPacket(int32_t entityId, const Vec3& pos) +{ + m_entityId = entityId; + m_pos = pos; +} + +void RespawnPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) +{ + callback.handle(guid, this); +} + +void RespawnPacket::write(RakNet::BitStream& bs) +{ + bs.Write((unsigned char)PACKET_RESPAWN); + bs.Write(m_entityId); + bs.Write(m_pos.x); + bs.Write(m_pos.y); + bs.Write(m_pos.z); +} + +void RespawnPacket::read(RakNet::BitStream& bs) +{ + bs.Read(m_entityId); + bs.Read(m_pos.x); + bs.Read(m_pos.y); + bs.Read(m_pos.z); +} diff --git a/source/network/packets/RespawnPacket.hpp b/source/network/packets/RespawnPacket.hpp new file mode 100644 index 000000000..0d10a6373 --- /dev/null +++ b/source/network/packets/RespawnPacket.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include "../Packet.hpp" +#include "world/phys/Vec3.hpp" + +class RespawnPacket : public Packet +{ +public: + RespawnPacket() + { + m_entityId = 0; + m_pos = Vec3::ZERO; + } + RespawnPacket(int32_t entityId, const Vec3& pos); + + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; +public: + int32_t m_entityId; + Vec3 m_pos; +}; \ No newline at end of file diff --git a/source/network/packets/SetEntityDataPacket.cpp b/source/network/packets/SetEntityDataPacket.cpp new file mode 100644 index 000000000..33f75fdf0 --- /dev/null +++ b/source/network/packets/SetEntityDataPacket.cpp @@ -0,0 +1,34 @@ +#include "SetEntityDataPacket.hpp" +#include "network/NetEventCallback.hpp" +#include "network/RakIO.hpp" +#include "network/PacketUtil.hpp" + +SetEntityDataPacket::SetEntityDataPacket(int32_t id, SynchedEntityData& data) +{ + m_entityId = id; + m_bIsIncoming = false; + m_packedItems = data.packDirty(); +} + +void SetEntityDataPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) +{ + callback.handle(guid, this); +} + +void SetEntityDataPacket::write(RakNet::BitStream& bs) +{ + bs.Write((unsigned char)PACKET_SET_ENTITY_DATA); + bs.Write(m_entityId); + + RakDataOutput dos(bs); + SynchedEntityData::Pack(m_packedItems, dos); +} + +void SetEntityDataPacket::read(RakNet::BitStream& bs) +{ + bs.Read(m_entityId); + + RakDataInput dis(bs); + m_packedItems = SynchedEntityData::Unpack(dis); + m_bIsIncoming = true; +} diff --git a/source/network/packets/SetEntityDataPacket.hpp b/source/network/packets/SetEntityDataPacket.hpp new file mode 100644 index 000000000..3c7d5621d --- /dev/null +++ b/source/network/packets/SetEntityDataPacket.hpp @@ -0,0 +1,25 @@ +#pragma once + +#include "../Packet.hpp" +#include "world/phys/Vec2.hpp" +#include "world/entity/SynchedEntityData.hpp" + +class SetEntityDataPacket : public Packet +{ +public: + SetEntityDataPacket() + { + m_entityId = 0; + m_bIsIncoming = false; + } + SetEntityDataPacket(int32_t id, SynchedEntityData& data); + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; + const SynchedEntityData::ItemsArray& getUnpackedData() const { return m_packedItems; } +public: + int32_t m_entityId; + bool m_bIsIncoming; +private: + SynchedEntityData::ItemsArray m_packedItems; +}; \ No newline at end of file diff --git a/source/network/packets/SetHealthPacket.cpp b/source/network/packets/SetHealthPacket.cpp new file mode 100644 index 000000000..6cf11edf6 --- /dev/null +++ b/source/network/packets/SetHealthPacket.cpp @@ -0,0 +1,18 @@ +#include "SetHealthPacket.hpp" +#include "network/NetEventCallback.hpp" + +void SetHealthPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) +{ + callback.handle(guid, this); +} + +void SetHealthPacket::write(RakNet::BitStream& bs) +{ + bs.Write((unsigned char)PACKET_SET_HEALTH); + bs.Write(m_health); +} + +void SetHealthPacket::read(RakNet::BitStream& bs) +{ + bs.Read(m_health); +} diff --git a/source/network/packets/SetHealthPacket.hpp b/source/network/packets/SetHealthPacket.hpp new file mode 100644 index 000000000..7d75d2cb3 --- /dev/null +++ b/source/network/packets/SetHealthPacket.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include "../Packet.hpp" + +class SetHealthPacket : public Packet +{ +public: + SetHealthPacket(int8_t health = 0) + { + m_health = health; + } + + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; +public: + int8_t m_health; // int16_t in Java +}; \ No newline at end of file diff --git a/source/network/packets/SetTimePacket.cpp b/source/network/packets/SetTimePacket.cpp index f8fe0743a..2d5a64430 100644 --- a/source/network/packets/SetTimePacket.cpp +++ b/source/network/packets/SetTimePacket.cpp @@ -6,20 +6,21 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ -#include "../Packet.hpp" +#include "SetTimePacket.hpp" +#include "network/NetEventCallback.hpp" -void SetTimePacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback) +void SetTimePacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) { - pCallback->handle(guid, this); + callback.handle(guid, this); } -void SetTimePacket::write(RakNet::BitStream* bs) +void SetTimePacket::write(RakNet::BitStream& bs) { - bs->Write((unsigned char)PACKET_SET_TIME); - bs->Write(m_time); + bs.Write((unsigned char)PACKET_SET_TIME); + bs.Write(m_time); } -void SetTimePacket::read(RakNet::BitStream* bs) +void SetTimePacket::read(RakNet::BitStream& bs) { - bs->Read(m_time); + bs.Read(m_time); } diff --git a/source/network/packets/SetTimePacket.hpp b/source/network/packets/SetTimePacket.hpp new file mode 100644 index 000000000..0c0b443f1 --- /dev/null +++ b/source/network/packets/SetTimePacket.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include "../Packet.hpp" + +class SetTimePacket : public Packet +{ +public: + SetTimePacket(int32_t time = 0) + { + m_time = time; + } + + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; +public: + int32_t m_time; +}; \ No newline at end of file diff --git a/source/network/packets/StartGamePacket.cpp b/source/network/packets/StartGamePacket.cpp index 9b844ce88..8834521d4 100644 --- a/source/network/packets/StartGamePacket.cpp +++ b/source/network/packets/StartGamePacket.cpp @@ -6,52 +6,46 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ -#include "../Packet.hpp" +#include "StartGamePacket.hpp" +#include "network/NetEventCallback.hpp" -void StartGamePacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback) +void StartGamePacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) { - pCallback->handle(guid, this); + callback.handle(guid, this); } -void StartGamePacket::write(RakNet::BitStream* bs) +void StartGamePacket::write(RakNet::BitStream& bs) { - bs->Write((unsigned char)PACKET_START_GAME); - bs->Write(m_seed); - bs->Write(m_levelVersion); + bs.Write((unsigned char)PACKET_START_GAME); + bs.Write(m_seed); + bs.Write(m_levelVersion); #if NETWORK_PROTOCOL_VERSION >= 3 - bs->Write(m_gameType); + bs.Write(m_gameType); #endif - bs->Write(m_entityId); - bs->Write(m_pos.x); - bs->Write(m_pos.y); - bs->Write(m_pos.z); - - bs->Write(m_serverVersion); - if (m_serverVersion >= 1) - { - bs->Write(m_time); - } + bs.Write(m_entityId); + // probably older, you figure it out +#if NETWORK_PROTOCOL_VERSION >= 29 + bs.Write(m_time); +#endif + bs.Write(m_pos.x); + bs.Write(m_pos.y); + bs.Write(m_pos.z); } -void StartGamePacket::read(RakNet::BitStream* bs) +void StartGamePacket::read(RakNet::BitStream& bs) { - bs->Read(m_seed); - bs->Read(m_levelVersion); + bs.Read(m_seed); + bs.Read(m_levelVersion); #if NETWORK_PROTOCOL_VERSION >= 3 int32_t gameType; - bs->Read(gameType); + bs.Read(gameType); m_gameType = (GameType)gameType; #endif - bs->Read(m_entityId); - bs->Read(m_pos.x); - bs->Read(m_pos.y); - bs->Read(m_pos.z); - - if (!bs->Read(m_serverVersion)) - return; - - if (m_serverVersion < 1) - return; - - bs->Read(m_time); + bs.Read(m_entityId); +#if NETWORK_PROTOCOL_VERSION >= 29 + bs.Read(m_time); +#endif + bs.Read(m_pos.x); + bs.Read(m_pos.y); + bs.Read(m_pos.z); } \ No newline at end of file diff --git a/source/network/packets/StartGamePacket.hpp b/source/network/packets/StartGamePacket.hpp new file mode 100644 index 000000000..a2137157c --- /dev/null +++ b/source/network/packets/StartGamePacket.hpp @@ -0,0 +1,28 @@ +#pragma once + +#include "../Packet.hpp" +#include "world/gamemode/GameType.hpp" +#include "world/phys/Vec3.hpp" + +class StartGamePacket : public Packet +{ +public: + StartGamePacket() + { + m_seed = 0; + m_levelVersion = 0; + m_gameType = GAME_TYPES_MAX; + m_entityId = 0; + m_time = 0; + } + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; +public: + int32_t m_seed; + int m_levelVersion; + GameType m_gameType; + int m_entityId; + int m_time; + Vec3 m_pos; +}; \ No newline at end of file diff --git a/source/network/packets/TakeItemEntityPacket.cpp b/source/network/packets/TakeItemEntityPacket.cpp new file mode 100644 index 000000000..d5e0e22c8 --- /dev/null +++ b/source/network/packets/TakeItemEntityPacket.cpp @@ -0,0 +1,26 @@ +#include "TakeItemEntityPacket.hpp" +#include "network/NetEventCallback.hpp" + +TakeItemEntityPacket::TakeItemEntityPacket(int32_t targetId, int32_t sourceId) +{ + m_targetId = targetId; + m_sourceId = sourceId; +} + +void TakeItemEntityPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) +{ + callback.handle(guid, this); +} + +void TakeItemEntityPacket::write(RakNet::BitStream& bs) +{ + bs.Write((unsigned char)PACKET_TAKE_ITEM_ENTITY); + bs.Write(m_targetId); + bs.Write(m_sourceId); +} + +void TakeItemEntityPacket::read(RakNet::BitStream& bs) +{ + bs.Read(m_targetId); + bs.Read(m_sourceId); +} diff --git a/source/network/packets/TakeItemEntityPacket.hpp b/source/network/packets/TakeItemEntityPacket.hpp new file mode 100644 index 000000000..1c6c8d0c1 --- /dev/null +++ b/source/network/packets/TakeItemEntityPacket.hpp @@ -0,0 +1,25 @@ +#pragma once + +#include "../Packet.hpp" +#include "world/phys/Vec3.hpp" +#include "world/entity/ItemEntity.hpp" + +class TakeItemEntityPacket : public Packet +{ +public: + TakeItemEntityPacket() + { + m_targetId = 0; + m_sourceId = 0; + } + TakeItemEntityPacket(int32_t targetId, int32_t sourceId); + +public: + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; + +public: + int32_t m_targetId; + int32_t m_sourceId; +}; \ No newline at end of file diff --git a/source/network/packets/UpdateBlockPacket.cpp b/source/network/packets/UpdateBlockPacket.cpp index 8b815e3b0..a2d2bfd65 100644 --- a/source/network/packets/UpdateBlockPacket.cpp +++ b/source/network/packets/UpdateBlockPacket.cpp @@ -6,30 +6,31 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ -#include "../Packet.hpp" +#include "UpdateBlockPacket.hpp" +#include "network/NetEventCallback.hpp" -void UpdateBlockPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback* pCallback) +void UpdateBlockPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) { - pCallback->handle(guid, this); + callback.handle(guid, this); } -void UpdateBlockPacket::write(RakNet::BitStream* bs) +void UpdateBlockPacket::write(RakNet::BitStream& bs) { - bs->Write((unsigned char)PACKET_UPDATE_BLOCK); - bs->Write(m_pos.x); - bs->Write(m_pos.z); - bs->Write(m_pos.y); - bs->Write(m_tileTypeId); - bs->Write(m_data); + bs.Write((unsigned char)PACKET_UPDATE_BLOCK); + bs.Write(m_pos.x); + bs.Write(m_pos.z); + bs.Write(m_pos.y); + bs.Write(m_tileTypeId); + bs.Write(m_data); } -void UpdateBlockPacket::read(RakNet::BitStream* bs) +void UpdateBlockPacket::read(RakNet::BitStream& bs) { - bs->Read(m_pos.x); - bs->Read(m_pos.z); + bs.Read(m_pos.x); + bs.Read(m_pos.z); uint8_t y; - bs->Read(y); + bs.Read(y); m_pos.y = y; - bs->Read(m_tileTypeId); - bs->Read(m_data); + bs.Read(m_tileTypeId); + bs.Read(m_data); } diff --git a/source/network/packets/UpdateBlockPacket.hpp b/source/network/packets/UpdateBlockPacket.hpp new file mode 100644 index 000000000..9002d53d8 --- /dev/null +++ b/source/network/packets/UpdateBlockPacket.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include "../Packet.hpp" +#include "common/Utils.hpp" +#include "world/level/TilePos.hpp" + +class UpdateBlockPacket : public Packet +{ +public: + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; +public: + TilePos m_pos; + TileID m_tileTypeId; + TileData m_data; +}; \ No newline at end of file diff --git a/source/network/packets/UseItemPacket.cpp b/source/network/packets/UseItemPacket.cpp new file mode 100644 index 000000000..62a0e7eab --- /dev/null +++ b/source/network/packets/UseItemPacket.cpp @@ -0,0 +1,49 @@ +#include "UseItemPacket.hpp" +#include "network/NetEventCallback.hpp" + +UseItemPacket::UseItemPacket(const TilePos& tilePos, int32_t tileFace, int32_t entityId, const ItemInstance* pItem) +{ + m_tilePos = tilePos; + m_tileFace = tileFace; + m_entityId = entityId; + if (pItem) + { + m_itemId = pItem->getId(); + m_itemAuxValue = pItem->getAuxValue(); + } + else + { + m_itemId = TILE_AIR; + m_itemAuxValue = 0; + } +} + +void UseItemPacket::handle(const RakNet::RakNetGUID& guid, NetEventCallback& callback) +{ + callback.handle(guid, this); +} + +void UseItemPacket::write(RakNet::BitStream& bs) +{ + bs.Write((unsigned char)PACKET_USE_ITEM); + bs.Write(m_tilePos.x); + bs.Write(m_tilePos.y); + bs.Write(m_tilePos.z); + bs.Write(m_tileFace); + bs.Write(m_itemId); + bs.Write(m_itemAuxValue); + bs.Write(m_entityId); +} + +void UseItemPacket::read(RakNet::BitStream& bs) +{ + bs.Read(m_tilePos.x); + bs.Read(m_tilePos.y); + bs.Read(m_tilePos.z); + bs.Read(m_tileFace); + bs.Read(m_itemId); + bs.Read(m_itemAuxValue); + bs.Read(m_entityId); + + m_item = ItemInstance(m_itemId, m_itemId > 0 ? 1 : 0, m_itemAuxValue); +} diff --git a/source/network/packets/UseItemPacket.hpp b/source/network/packets/UseItemPacket.hpp new file mode 100644 index 000000000..37a2203c7 --- /dev/null +++ b/source/network/packets/UseItemPacket.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include "../Packet.hpp" +#include "world/item/ItemInstance.hpp" +#include "world/level/TilePos.hpp" + +class UseItemPacket : public Packet +{ +public: + UseItemPacket() + { + m_tileFace = 0; + m_entityId = 0; + m_itemId = TILE_AIR; + m_itemAuxValue = 0; + } + UseItemPacket(const TilePos& tilePos, int32_t tileFace, int32_t entityId, const ItemInstance* pItem = nullptr); + + void handle(const RakNet::RakNetGUID&, NetEventCallback& callback) override; + void write(RakNet::BitStream&) override; + void read(RakNet::BitStream&) override; +public: + TilePos m_tilePos; + int32_t m_tileFace; + int32_t m_entityId; + int16_t m_itemId; + int8_t m_itemAuxValue; + ItemInstance m_item; +}; \ No newline at end of file diff --git a/source/server/ServerPlayer.cpp b/source/server/ServerPlayer.cpp new file mode 100644 index 000000000..c827d2595 --- /dev/null +++ b/source/server/ServerPlayer.cpp @@ -0,0 +1,29 @@ +#include "ServerPlayer.hpp" +#include "network/packets/SetHealthPacket.hpp" +#include "network/packets/TakeItemEntityPacket.hpp" +#include "network/RakNetInstance.hpp" +#include "world/level/Level.hpp" + +ServerPlayer::ServerPlayer(Level* pLevel, GameType playerGameType) + : Player(pLevel, playerGameType) +{ + m_lastHealth = -999; // -99999999 on Java +} + +void ServerPlayer::tick() +{ + Player::tick(); + + if (m_health != m_lastHealth) + { + m_pLevel->m_pRakNetInstance->send(m_guid, new SetHealthPacket(m_health)); + m_lastHealth = m_health; + } +} + +void ServerPlayer::take(Entity* pEnt, int count) +{ + m_pLevel->m_pRakNetInstance->send(new TakeItemEntityPacket(pEnt->m_EntityID, m_EntityID)); + + Player::take(pEnt, count); +} \ No newline at end of file diff --git a/source/server/ServerPlayer.hpp b/source/server/ServerPlayer.hpp new file mode 100644 index 000000000..6b2fcafbb --- /dev/null +++ b/source/server/ServerPlayer.hpp @@ -0,0 +1,14 @@ +#include "world/entity/Player.hpp" + +class ServerPlayer : public Player +{ +public: + ServerPlayer(Level* pLevel, GameType playerGameType); + +public: + void tick() override; + void take(Entity* pEnt, int count) override; + +private: + int m_lastHealth; +}; \ No newline at end of file diff --git a/source/network/ServerSideNetworkHandler.cpp b/source/server/ServerSideNetworkHandler.cpp similarity index 68% rename from source/network/ServerSideNetworkHandler.cpp rename to source/server/ServerSideNetworkHandler.cpp index 705291d63..fbcaf2c60 100644 --- a/source/network/ServerSideNetworkHandler.cpp +++ b/source/server/ServerSideNetworkHandler.cpp @@ -8,7 +8,13 @@ #include "ServerSideNetworkHandler.hpp" #include "common/Utils.hpp" +#include "network/MinecraftPackets.hpp" #include "world/entity/MobFactory.hpp" +#include "ServerPlayer.hpp" + +// How frequently SetTimePackets are sent, in seconds. +// b1.3 sends every second. 0.2.1 seems to send every 12. +#define NETWORK_TIME_SEND_FREQUENCY 12 // This lets you make the server shut up and not log events in the debug console. //#define VERBOSE_SERVER @@ -69,48 +75,62 @@ void ServerSideNetworkHandler::onDisconnect(const RakNet::RakNetGUID& guid) { puts_ignorable("onDisconnect"); - OnlinePlayer* pOnlinePlayer = getPlayerByGUID(guid); + Player* pPlayer = nullptr; - if (!pOnlinePlayer) - return; + OnlinePlayer* pOnlinePlayer = getOnlinePlayerByGUID(guid); + if (pOnlinePlayer) + { + // Player was in-game + pPlayer = pOnlinePlayer->m_pPlayer; - Player* pPlayer = pOnlinePlayer->m_pPlayer; + m_onlinePlayers.erase(guid); - // erase it from the map - m_onlinePlayers.erase(m_onlinePlayers.find(guid)); // it better be in our map + // delete the online player's entry. + delete pOnlinePlayer; + // pPlayer is managed by Level - // tell everyone that they left the game - displayGameMessage(pPlayer->m_name + " disconnected from the game"); - m_pRakNetInstance->send(new RemoveEntityPacket(pPlayer->m_EntityID)); + // tell everyone that they left the game + displayGameMessage(pPlayer->m_name + " disconnected from the game"); - // remove it from our world - m_pLevel->removeEntity(pPlayer); + m_pRakNetInstance->send(new RemoveEntityPacket(pPlayer->m_EntityID)); + + pPlayer->m_bForceRemove = true; + // remove it from our world + m_pLevel->removeEntity(pPlayer); + } + else if (pPlayer = getPendingPlayerByGUID(guid)) + { + // Player was still loading + m_pendingPlayers.erase(guid); - // delete the online player's entry. - delete pOnlinePlayer; + // remove "it" from our heap + delete pPlayer; + } } void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, LoginPacket* packet) { - if (!m_bAllowIncoming) + if (!m_pLevel || !m_bAllowIncoming) return; puts_ignorable("LoginPacket"); // if they're already online, fail - if (getPlayerByGUID(guid)) + if (getOnlinePlayerByGUID(guid)) { LOG_E("That player is already in the world!"); return; } + RakNet::BitStream bs; + #if NETWORK_PROTOCOL_VERSION >= 3 LoginStatusPacket::LoginStatus loginStatus = LoginStatusPacket::STATUS_SUCCESS; if (packet->m_clientNetworkVersion < NETWORK_PROTOCOL_VERSION_MIN) { loginStatus = LoginStatusPacket::STATUS_CLIENT_OUTDATED; } - else if (packet->m_clientNetworkVersion2 > NETWORK_PROTOCOL_VERSION) + else if (packet->m_clientNetworkVersionMin > NETWORK_PROTOCOL_VERSION) { loginStatus = LoginStatusPacket::STATUS_SERVER_OUTDATED; } @@ -119,44 +139,70 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, LoginPacke { LoginStatusPacket lsp = LoginStatusPacket(loginStatus); - RakNet::BitStream lspbs; - lsp.write(&lspbs); - m_pRakNetPeer->Send(&lspbs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, guid, false); + lsp.write(bs); + m_pRakNetPeer->Send(&bs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, guid, false); return; } #endif - Player* pPlayer = new Player(m_pLevel, m_pLevel->getLevelData()->getGameType()); + ServerPlayer* pPlayer = new ServerPlayer(m_pLevel, m_pLevel->getLevelData()->getGameType()); pPlayer->m_guid = guid; - pPlayer->m_name = std::string(packet->m_str.C_String()); + pPlayer->m_name = std::string(packet->m_userName.C_String()); - m_onlinePlayers[guid] = new OnlinePlayer(pPlayer, guid); + m_pendingPlayers[guid] = pPlayer; StartGamePacket sgp; sgp.m_seed = m_pLevel->getSeed(); sgp.m_levelVersion = m_pLevel->getLevelData()->getStorageVersion(); sgp.m_gameType = pPlayer->getPlayerGameType(); sgp.m_entityId = pPlayer->m_EntityID; + sgp.m_time = m_pLevel->getTime(); sgp.m_pos = pPlayer->m_pos; sgp.m_pos.y -= pPlayer->m_heightOffset; - sgp.m_serverVersion = NETWORK_PROTOCOL_VERSION; - sgp.m_time = m_pLevel->getTime(); - RakNet::BitStream sgpbs; - sgp.write(&sgpbs); - m_pRakNetPeer->Send(&sgpbs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, guid, false); + sgp.write(bs); + m_pRakNetPeer->Send(&bs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, guid, false); + +#if NETWORK_PROTOCOL_VERSION <= 2 + // emulate a ReadyPacket being received + handle(guid, (ReadyPacket*)nullptr); +#endif +} + +void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, ReadyPacket* packet) +{ + if (!m_pLevel) + return; + + if (packet) + { + // nullptr is emulated + puts_ignorable("ReadyPacket"); + } + + Player* pPlayer = popPendingPlayer(guid); + if (!pPlayer) + return; - // @TODO: Move everything below into response to ReadyPacket + RakNet::BitStream bs; + +#if NETWORK_PROTOCOL_VERSION >= 3 + { + SetTimePacket packet(m_pLevel->getTime()); + packet.write(bs); + m_pRakNetPeer->Send(&bs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, guid, false); + } +#endif // send the connecting player info about all other players in the world for (int i = 0; i < int(m_pLevel->m_players.size()); i++) { Player* player = m_pLevel->m_players[i]; AddPlayerPacket app(player); - RakNet::BitStream appbs; - app.write(&appbs); - m_pRakNetPeer->Send(&appbs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, guid, false); + bs.Reset(); + app.write(bs); + m_pRakNetPeer->Send(&bs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, guid, false); } m_pLevel->addEntity(pPlayer); @@ -168,15 +214,30 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, LoginPacke m_pMinecraft->m_gui.addMessage(pPlayer->m_name + " joined the game"); +#if NETWORK_PROTOCOL_VERSION >= 3 + // send the connecting player info about all entities in the world + for (int i = 0; i < int(m_pLevel->m_entities.size()); i++) + { + Entity* entity = m_pLevel->m_entities[i]; + if (canReplicateEntity(entity)) + { + AddMobPacket packet(*((Mob*)entity)); + bs.Reset(); + packet.write(bs); + m_pRakNetPeer->Send(&bs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, guid, false); + } + } +#endif + AddPlayerPacket app(pPlayer); - RakNet::BitStream appbs; - app.write(&appbs); - m_pRakNetPeer->Send(&appbs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, guid, true); + bs.Reset(); + app.write(bs); + m_pRakNetPeer->Send(&bs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, guid, true); } void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, MessagePacket* packet) { - OnlinePlayer* pOP = getPlayerByGUID(guid); + OnlinePlayer* pOP = getOnlinePlayerByGUID(guid); if (!pOP) { LOG_W("MessagePacket: That jerk %s doesn't actually exist", guid.ToString()); @@ -227,13 +288,13 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, MessagePac void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, MovePlayerPacket* packet) { //not in the original - puts_ignorable("MovePlayerPacket"); + //puts_ignorable("MovePlayerPacket"); Entity* pEntity = m_pLevel->getEntity(packet->m_id); if (!pEntity) return; - pEntity->lerpTo(packet->m_pos, packet->m_rot, 3); + pEntity->lerpTo(packet->m_pos, packet->m_rot); redistributePacket(packet, guid); } @@ -296,16 +357,18 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, RemoveBloc const Tile::SoundType* pSound = pTile->m_pSound; m_pLevel->playSound(pos + 0.5f, "step." + pSound->m_name, 0.5f * (pSound->volume + 1.0f), pSound->pitch * 0.8f); - /* 0.2.1 - ItemInstance item(pTile, 1, auxValue); - if (m_pMinecraft->m_pGameMode->isSurvivalType() && pTile->m_ID == Tile::grass->m_ID || !m_pMinecraft->m_pLocalPlayer->m_pInventory->hasUnlimitedResource(item)) - { - pTile->spawnResources(m_pLevel, pos, auxValue); - }*/ - if (pPlayer->isSurvival()) { +#ifdef MOD_POCKET_SURVIVAL + // 0.2.1 + ItemInstance tileItem(pTile, 1, auxValue); + if (pTile == Tile::grass || !pPlayer->m_pInventory->hasUnlimitedResource(&tileItem)) + { + pTile->spawnResources(m_pLevel, pos, auxValue); + } +#else pTile->spawnResources(m_pLevel, pos, auxValue); +#endif } pTile->destroy(m_pLevel, pos, auxValue); @@ -320,7 +383,7 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, PlayerEqui Player* pPlayer = (Player*)m_pLevel->getEntity(packet->m_playerID); if (!pPlayer) { - LOG_W("No player with id %d", packet->m_playerID); + LOG_W("PlayerEquipmentPacket: No player with id %d", packet->m_playerID); return; } @@ -335,9 +398,74 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, PlayerEqui redistributePacket(packet, guid); } +void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, InteractPacket* packet) +{ + //puts_ignorable("InteractPacket"); + if (!m_pLevel) return; + + Entity* pSource = m_pLevel->getEntity(packet->m_sourceId); + Entity* pTarget = m_pLevel->getEntity(packet->m_targetId); + if (!pSource || !pTarget) + return; + + if (!pSource->isPlayer()) + return; + + Player* pPlayer = (Player*)pSource; + switch (packet->m_actionType) + { + case InteractPacket::INTERACT: + pPlayer->swing(); + m_pMinecraft->m_pGameMode->interact(pPlayer, pTarget); + break; + case InteractPacket::ATTACK: + pPlayer->swing(); + m_pMinecraft->m_pGameMode->attack(pPlayer, pTarget); + break; + default: + LOG_W("Received unkown action in InteractPacket: %d", packet->m_actionType); + break; + } + + redistributePacket(packet, guid); +} + +void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, UseItemPacket* packet) +{ + //puts_ignorable("UseItemPacket"); + if (!m_pLevel) return; + + Entity* pEntity = m_pLevel->getEntity(packet->m_entityId); + if (!pEntity) return; + Player* pPlayer = (Player*)pEntity; + + if (!pEntity->isPlayer()) + return; + + Tile* pTile = Tile::tiles[m_pLevel->getTile(packet->m_tilePos)]; + if (pTile) + { + if (pTile == Tile::invisible_bedrock) + return; + + // Interface with tile instead of using item + if (pTile->use(m_pLevel, packet->m_tilePos, pPlayer)) + { + pPlayer->swing(); + return; + } + } + + if (packet->m_item.isNull()) + return; + + packet->m_item.useOn(pPlayer, m_pLevel, packet->m_tilePos, (Facing::Name)packet->m_tileFace); + pPlayer->swing(); +} + void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, RequestChunkPacket* packet) { - puts_ignorable("RequestChunkPacket"); + //puts_ignorable("RequestChunkPacket"); if (packet->m_chunkPos.x == -9999) { @@ -356,11 +484,60 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, RequestChu ChunkDataPacket cdp(pChunk->m_chunkPos, pChunk); RakNet::BitStream bs; - cdp.write(&bs); + cdp.write(bs); m_pRakNetPeer->Send(&bs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, guid, false); } +void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, AnimatePacket* packet) +{ + //puts_ignorable("AnimatePacket"); + + if (!m_pLevel) + return; + + Entity* pEntity = m_pLevel->getEntity(packet->m_entityId); + if (!pEntity) + return; + + if (!pEntity->isPlayer()) + return; + Player* pPlayer = (Player*)pEntity; + + switch (packet->m_actionId) + { + case AnimatePacket::SWING: + { + pPlayer->swing(); + break; + } + case AnimatePacket::HURT: + { + pPlayer->animateHurt(); + break; + } + default: + { + LOG_W("Received unkown action in AnimatePacket: %d, EntityType: %s", packet->m_actionId, pEntity->getDescriptor().getEntityType().getName().c_str()); + break; + } + } + + redistributePacket(packet, guid); +} + +void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, RespawnPacket* packet) +{ + puts_ignorable("RespawnPacket"); + + if (!m_pLevel) + return; + + NetEventCallback::handle(*m_pLevel, guid, packet); + + redistributePacket(packet, guid); +} + void ServerSideNetworkHandler::tileBrightnessChanged(const TilePos& pos) { } @@ -373,14 +550,53 @@ void ServerSideNetworkHandler::tileChanged(const TilePos& pos) ubp.m_data = m_pLevel->getData(pos); RakNet::BitStream bs; - ubp.write(&bs); + ubp.write(bs); m_pRakNetPeer->Send(&bs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, RakNet::AddressOrGUID(), true); } void ServerSideNetworkHandler::timeChanged(uint32_t time) { - m_pRakNetInstance->send(new SetTimePacket(time)); + if ((time % (20 * NETWORK_TIME_SEND_FREQUENCY)) == 0) + { + m_pRakNetInstance->send(new SetTimePacket(time)); + } +} + +void ServerSideNetworkHandler::entityAdded(Entity* entity) +{ + if (entity->getDescriptor().isType(EntityType::ITEM)) + { + m_pRakNetInstance->send(new AddItemEntityPacket(*(ItemEntity*)entity)); + } + else + { + if (!canReplicateEntity(entity)) + return; + + AddMobPacket packet(*((Mob*)entity)); + redistributePacket(&packet, m_pRakNetInstance->m_guid); + } +} + +void ServerSideNetworkHandler::entityRemoved(Entity* entity) +{ + RemoveEntityPacket packet(entity->m_EntityID); + redistributePacket(&packet, m_pRakNetInstance->m_guid); +} + +void ServerSideNetworkHandler::levelEvent(Player* pPlayer, LevelEvent::ID eventId, const TilePos& pos, LevelEvent::Data data) +{ + LevelEventPacket pkt(eventId, pos, data); + + if (pPlayer) + { + redistributePacket(&pkt, pPlayer->m_guid); + } + else + { + redistributePacket(&pkt, m_pMinecraft->m_pLocalPlayer->m_guid); + } } void ServerSideNetworkHandler::allowIncomingConnections(bool b) @@ -397,6 +613,21 @@ void ServerSideNetworkHandler::allowIncomingConnections(bool b) m_bAllowIncoming = b; } +Player* ServerSideNetworkHandler::popPendingPlayer(const RakNet::RakNetGUID& guid) +{ + if (!m_pLevel) + return nullptr; + + Player* pPlayer = getPendingPlayerByGUID(guid); + if (pPlayer) + { + m_pendingPlayers.erase(guid); + m_onlinePlayers[guid] = new OnlinePlayer(pPlayer, guid); + } + + return pPlayer; +} + void ServerSideNetworkHandler::displayGameMessage(const std::string& msg) { m_pMinecraft->m_gui.addMessage(msg); @@ -422,12 +653,12 @@ void ServerSideNetworkHandler::sendMessage(OnlinePlayer* player, const std::stri void ServerSideNetworkHandler::redistributePacket(Packet* packet, const RakNet::RakNetGUID& source) { RakNet::BitStream bs; - packet->write(&bs); + packet->write(bs); m_pRakNetPeer->Send(&bs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, source, true); } -OnlinePlayer* ServerSideNetworkHandler::getPlayerByGUID(const RakNet::RakNetGUID& guid) +OnlinePlayer* ServerSideNetworkHandler::getOnlinePlayerByGUID(const RakNet::RakNetGUID& guid) { OnlinePlayerMap::iterator iter = m_onlinePlayers.find(guid); if (iter == m_onlinePlayers.end()) @@ -436,6 +667,39 @@ OnlinePlayer* ServerSideNetworkHandler::getPlayerByGUID(const RakNet::RakNetGUID return iter->second; } +Player* ServerSideNetworkHandler::getPendingPlayerByGUID(const RakNet::RakNetGUID& guid) +{ + PlayerMap::iterator iter = m_pendingPlayers.find(guid); + if (iter == m_pendingPlayers.end()) + return nullptr; + + return iter->second; +} + +bool ServerSideNetworkHandler::canReplicateEntity(const Entity* pEntity) const +{ + if (!pEntity || !pEntity->isMob() || pEntity->isPlayer()) + return false; + + // All clients on V3 will just crash if an unknown + // EntityType ID is replicated in an AddMobPacket. + // V4 and above has the neccessary nullptr check to not need this. +#if NETWORK_PROTOCOL_VERSION <= 3 + EntityType::ID entityTypeId = pEntity->getDescriptor().getEntityType().getId(); + switch (entityTypeId) + { + case EntityType::SHEEP: + case EntityType::ZOMBIE: + case EntityType::PIG: + return true; + default: + return false; + } +#endif + + return true; +} + ///////////////// In-Game Commands ///////////////// void ServerSideNetworkHandler::setupCommands() diff --git a/source/network/ServerSideNetworkHandler.hpp b/source/server/ServerSideNetworkHandler.hpp similarity index 79% rename from source/network/ServerSideNetworkHandler.hpp rename to source/server/ServerSideNetworkHandler.hpp index e298cb8a3..09319b6c1 100644 --- a/source/network/ServerSideNetworkHandler.hpp +++ b/source/server/ServerSideNetworkHandler.hpp @@ -9,9 +9,9 @@ #pragma once #include -#include "NetEventCallback.hpp" #include "client/app/Minecraft.hpp" -#include "RakNetInstance.hpp" +#include "network/NetEventCallback.hpp" +#include "network/RakNetInstance.hpp" #include "world/level/LevelListener.hpp" class Minecraft; @@ -28,6 +28,7 @@ struct OnlinePlayer typedef void(ServerSideNetworkHandler::* CommandFunction)(OnlinePlayer* player, const std::vector& parms); typedef std::map CommandMap; typedef std::map OnlinePlayerMap; +typedef std::map PlayerMap; // @TODO: Rename to ServerNetworkHandler? class ServerSideNetworkHandler : public NetEventCallback, public LevelListener @@ -48,26 +49,37 @@ class ServerSideNetworkHandler : public NetEventCallback, public LevelListener void onNewClient(const RakNet::RakNetGUID&) override; void onDisconnect(const RakNet::RakNetGUID&) override; void handle(const RakNet::RakNetGUID&, LoginPacket*) override; + void handle(const RakNet::RakNetGUID&, ReadyPacket*) override; void handle(const RakNet::RakNetGUID&, MessagePacket*) override; void handle(const RakNet::RakNetGUID&, MovePlayerPacket*) override; void handle(const RakNet::RakNetGUID&, PlaceBlockPacket*) override; void handle(const RakNet::RakNetGUID&, RemoveBlockPacket*) override; void handle(const RakNet::RakNetGUID&, PlayerEquipmentPacket*) override; + void handle(const RakNet::RakNetGUID&, InteractPacket*) override; + void handle(const RakNet::RakNetGUID&, UseItemPacket*) override; void handle(const RakNet::RakNetGUID&, RequestChunkPacket*) override; + void handle(const RakNet::RakNetGUID&, AnimatePacket*) override; + void handle(const RakNet::RakNetGUID&, RespawnPacket*) override; // Overridden from LevelListener void tileBrightnessChanged(const TilePos& pos) override; void tileChanged(const TilePos& pos) override; void timeChanged(uint32_t time) override; + void entityAdded(Entity* entity) override; + void entityRemoved(Entity* entity) override; + void levelEvent(Player* pPlayer, LevelEvent::ID eventId, const TilePos& pos, LevelEvent::Data data) override; void allowIncomingConnections(bool b); + Player* popPendingPlayer(const RakNet::RakNetGUID& guid); void displayGameMessage(const std::string&); void sendMessage(const RakNet::RakNetGUID& guid, const std::string&); void sendMessage(OnlinePlayer*, const std::string&); void redistributePacket(Packet* packet, const RakNet::RakNetGUID& source); // Custom - OnlinePlayer* getPlayerByGUID(const RakNet::RakNetGUID& guid); + OnlinePlayer* getOnlinePlayerByGUID(const RakNet::RakNetGUID& guid); + Player* getPendingPlayerByGUID(const RakNet::RakNetGUID& guid); + bool canReplicateEntity(const Entity* pEntity) const; void setupCommands(); // Commands @@ -86,6 +98,7 @@ class ServerSideNetworkHandler : public NetEventCallback, public LevelListener Level* m_pLevel; RakNetInstance* m_pRakNetInstance; RakNet::RakPeerInterface* m_pRakNetPeer; + PlayerMap m_pendingPlayers; bool m_bAllowIncoming; OnlinePlayerMap m_onlinePlayers; diff --git a/source/world/entity/Entity.cpp b/source/world/entity/Entity.cpp index 09f67e494..8c0c1006e 100644 --- a/source/world/entity/Entity.cpp +++ b/source/world/entity/Entity.cpp @@ -12,6 +12,7 @@ #include "nbt/CompoundTag.hpp" #define TOTAL_AIR_SUPPLY (300) +#define DATA_SHARED_FLAGS_ID (0) int Entity::entityCounter; Random Entity::sharedRandom; @@ -19,15 +20,12 @@ Random Entity::sharedRandom; void Entity::_init() { m_bInAChunk = false; - m_chunkPos = ChunkPos(0, 0); field_20 = 0; field_24 = 0; field_28 = 0; field_30 = 1.0f; m_bBlocksBuilding = false; m_pLevel = nullptr; - m_rot = Vec2::ZERO; - m_oRot = Vec2::ZERO; m_bOnGround = false; m_bHorizontalCollision = false; m_bCollision = false; @@ -36,6 +34,8 @@ void Entity::_init() m_bIsInWeb = false; m_bSlide = 1; m_bRemoved = false; + m_bIsInvisible = false; + m_bForceRemove = false; m_heightOffset = 0.0f; m_bbWidth = 0.6f; m_bbHeight = 1.8f; @@ -45,7 +45,7 @@ void Entity::_init() m_ySlideOffset = 0.0f; m_footSize = 0.0f; m_bNoPhysics = false; - field_B0 = 0.0f; + m_pushthrough = 0.0f; m_tickCount = 0; m_invulnerableTime = 0; m_airCapacity = TOTAL_AIR_SUPPLY; @@ -59,7 +59,6 @@ void Entity::_init() m_bFireImmune = false; m_bFirstTick = true; m_nextStep = 1; - m_entityData = SynchedEntityData(); m_pDescriptor = &EntityTypeDescriptor::unknown; } @@ -71,11 +70,31 @@ Entity::Entity(Level* pLevel) m_EntityID = ++entityCounter; setPos(Vec3::ZERO); - m_entityData.define(0, 0); + m_entityData.define(DATA_SHARED_FLAGS_ID, 0); } Entity::~Entity() { + m_entityData.clear(); +} + +bool Entity::getSharedFlag(SharedFlag flag) const +{ + return (getEntityData().get(DATA_SHARED_FLAGS_ID) & 1 << flag) != 0; +} + +void Entity::setSharedFlag(SharedFlag flag, bool value) +{ + SynchedEntityData& entityData = getEntityData(); + int8_t var3 = entityData.get(DATA_SHARED_FLAGS_ID); + if (value) + { + entityData.set(DATA_SHARED_FLAGS_ID, (int8_t)(var3 | 1 << flag)); + } + else + { + entityData.set(DATA_SHARED_FLAGS_ID, (int8_t)(var3 & ~(1 << flag))); + } } void Entity::setLevel(Level* pLvl) @@ -109,7 +128,7 @@ void Entity::remove() m_bRemoved = true; } -int Entity::move(const Vec3& pos) +void Entity::move(const Vec3& pos) { if (m_bNoPhysics) { @@ -321,11 +340,9 @@ int Entity::move(const Vec3& pos) } } - - return 1300; } -void Entity::moveTo(const Vec3& pos, const Vec2& rot) +void Entity::moveTo(const Vec3& pos) { Vec3 newPos(pos); newPos.y += m_heightOffset; @@ -333,19 +350,28 @@ void Entity::moveTo(const Vec3& pos, const Vec2& rot) setPos(newPos); m_oPos = newPos; m_posPrev = newPos; +} +void Entity::moveTo(const Vec3& pos, const Vec2& rot) +{ + moveTo(pos); m_rot = rot; } -void Entity::absMoveTo(const Vec3& pos, const Vec2& rot) +void Entity::absMoveTo(const Vec3& pos) { m_ySlideOffset = 0.0f; - m_oRot = rot; - setRot(rot); - setPos(pos); m_oPos = pos; +} + +void Entity::absMoveTo(const Vec3& pos, const Vec2& rot) +{ + absMoveTo(pos); + + m_oRot = rot; + setRot(rot); // This looks like a rebounding check for the angle float dyRot = (m_oRot.y - m_rot.y); @@ -668,7 +694,7 @@ void Entity::push(Entity* bud) float x2 = 1.0f / x1; if (x2 > 1.0f) x2 = 1.0f; - float x3 = 1.0f - this->field_B0; + float x3 = 1.0f - m_pushthrough; float x4 = x3 * diffX / x1 * x2 * 0.05f; float x5 = x3 * diffZ / x1 * x2 * 0.05f; @@ -683,6 +709,9 @@ void Entity::push(const Vec3& pos) bool Entity::shouldRender(Vec3& camPos) const { + if (m_bIsInvisible) + return false; + return shouldRenderAtSqrDistance(distanceToSqr(camPos)); } @@ -735,10 +764,17 @@ void Entity::setEquippedSlot(int a, int b, int c) } -void Entity::setRot(const Vec2& rot) +void Entity::setRot(const Vec2& rot, bool rebound) { - m_rot.x = /*Mth::abs(rot.x) > 360.0f ? fmod(rot.x, 360.0f) :*/ rot.x; - m_rot.y = /*Mth::abs(rot.y) > 360.0f ? fmod(rot.y, 360.0f) :*/ rot.y; + if (rebound) + { + m_rot.x = Mth::abs(rot.x) > 360.0f ? fmod(rot.x, 360.0f) : rot.x; + m_rot.y = Mth::abs(rot.y) > 360.0f ? fmod(rot.y, 360.0f) : rot.y; + } + else + { + m_rot = rot; + } } void Entity::setSize(float rad, float height) @@ -760,7 +796,7 @@ void Entity::setPos(EntityPos* pPos) setRot(m_rot); } -void Entity::resetPos() +void Entity::resetPos(bool respawn) { if (!m_pLevel) // No level? Fine @@ -855,8 +891,9 @@ void Entity::handleInsidePortal() { } -void Entity::handleEntityEvent(int event) +void Entity::handleEntityEvent(EventType::ID eventId) { + LOG_W("Unknown EntityEvent ID: %d, EntityType: %s", eventId, getDescriptor().getEntityType().getName().c_str()); } /*void Entity::thunderHit(LightningBolt* bolt) diff --git a/source/world/entity/Entity.hpp b/source/world/entity/Entity.hpp index d3330f340..c61a1dc8d 100644 --- a/source/world/entity/Entity.hpp +++ b/source/world/entity/Entity.hpp @@ -19,6 +19,10 @@ #include "EntityTypeDescriptor.hpp" #include "common/Utils.hpp" +#define C_ENTITY_FLAG_ONFIRE (0) +#define C_ENTITY_FLAG_SNEAKING (1) +#define C_ENTITY_FLAG_RIDING (2) + class Level; class Player; class ItemInstance; @@ -81,23 +85,51 @@ struct EntityPos class Entity { +protected: + typedef int8_t SharedFlag; +public: + typedef int32_t ID; +public: + class EventType + { + public: + typedef int8_t ID; + enum + { + NONE, + JUMP, + HURT, + DEATH, + START_ATTACKING, + STOP_ATTACKING + }; + }; + private: void _init(); public: Entity() { _init(); } Entity(Level*); virtual ~Entity(); + +protected: + virtual bool getSharedFlag(SharedFlag flag) const; + virtual void setSharedFlag(SharedFlag flag, bool value); + +public: virtual void reset(); virtual void setLevel(Level*); virtual void removed(); virtual void setPos(const Vec3& pos); virtual void remove(); - virtual int move(const Vec3& posIn); - virtual void moveTo(const Vec3& pos, const Vec2& rot = Vec2::ZERO); - virtual void absMoveTo(const Vec3& pos, const Vec2& rot = Vec2::ZERO); + virtual void move(const Vec3& posIn); + virtual void moveTo(const Vec3& pos); + virtual void moveTo(const Vec3& pos, const Vec2& rot); + virtual void absMoveTo(const Vec3& pos); + virtual void absMoveTo(const Vec3& pos, const Vec2& rot); virtual void moveRelative(const Vec3& pos); virtual void lerpTo(const Vec3& pos); - virtual void lerpTo(const Vec3& pos, const Vec2& rot, int i); + virtual void lerpTo(const Vec3& pos, const Vec2& rot, int p = 3); virtual void lerpMotion(const Vec3& pos); virtual void turn(const Vec2& rot); virtual void interpolateTurn(const Vec2& rot); @@ -125,10 +157,14 @@ class Entity virtual bool isPickable() const { return false; } virtual bool isPushable() const { return false; } virtual bool isShootable() const { return false; } - virtual bool isSneaking() const { return false; } + virtual bool isOnFire() const { return m_fireTicks > 0 || getSharedFlag(C_ENTITY_FLAG_ONFIRE); } + virtual bool isRiding() const { return /*m_pRiding != nullptr ||*/ getSharedFlag(C_ENTITY_FLAG_RIDING); } + virtual bool isSneaking() const { return getSharedFlag(C_ENTITY_FLAG_SNEAKING); } + virtual void setSneaking(bool value) { setSharedFlag(C_ENTITY_FLAG_SNEAKING, value); } virtual bool isAlive() const { return m_bRemoved; } - virtual bool isOnFire() const { return m_fireTicks > 0; } virtual bool isPlayer() const { return false; } + virtual bool isMob() const { return false; } + virtual bool interpolateOnly() const { return false; } virtual bool isCreativeModeAllowed() const { return false; } virtual bool shouldRender(Vec3& camPos) const; virtual bool shouldRenderAtSqrDistance(float distSqr) const; @@ -140,10 +176,10 @@ class Entity virtual ItemEntity* spawnAtLocation(int, int, float); virtual void awardKillScore(Entity* pKilled, int score); virtual void setEquippedSlot(int, int, int); - virtual void setRot(const Vec2& rot); + virtual void setRot(const Vec2& rot, bool rebound = false); virtual void setSize(float rad, float height); virtual void setPos(EntityPos*); - virtual void resetPos(); + virtual void resetPos(bool respawn = false); virtual void outOfWorld(); virtual void checkFallDamage(float f, bool b); virtual void causeFallDamage(float f); @@ -154,7 +190,7 @@ class Entity virtual const AABB* getCollideBox() const; virtual AABB* getCollideAgainstBox(Entity* ent) const; virtual void handleInsidePortal(); - virtual void handleEntityEvent(int event); + virtual void handleEntityEvent(EventType::ID eventId); //virtual void thunderHit(LightningBolt*); void load(const CompoundTag& tag); bool save(CompoundTag& tag) const; @@ -164,12 +200,12 @@ class Entity // Removed by Mojang. See https://stackoverflow.com/questions/962132/why-is-a-call-to-a-virtual-member-function-in-the-constructor-a-non-virtual-call //virtual void defineSynchedData(); EntityType::ID getEncodeId() const; + Entity::ID hashCode() const { return m_EntityID; } const EntityTypeDescriptor& getDescriptor() const { return *m_pDescriptor; } + SynchedEntityData& getEntityData() { return m_entityData; } const SynchedEntityData& getEntityData() const { return m_entityData; } - int hashCode() const { return m_EntityID; } - bool operator==(const Entity& other) const; float distanceToSqr_inline(const Vec3& pos) const @@ -180,10 +216,12 @@ class Entity (m_pos.z - pos.z) * (m_pos.z - pos.z); } -public: - static int entityCounter; - static Random sharedRandom; +protected: + SynchedEntityData m_entityData; + bool m_bMakeStepSound; + const EntityTypeDescriptor* m_pDescriptor; +public: Vec3 m_pos; bool m_bInAChunk; ChunkPos m_chunkPos; @@ -191,7 +229,7 @@ class Entity int field_20; // unused Vec3? int field_24; int field_28; - int m_EntityID; + Entity::ID m_EntityID; float field_30; bool m_bBlocksBuilding; Level* m_pLevel; @@ -208,6 +246,8 @@ class Entity bool m_bIsInWeb; uint8_t m_bSlide; bool m_bRemoved; + bool m_bIsInvisible; + bool m_bForceRemove; float m_heightOffset; float m_bbWidth; float m_bbHeight; @@ -217,7 +257,7 @@ class Entity float m_ySlideOffset; float m_footSize; bool m_bNoPhysics; - float field_B0; + float m_pushthrough; int m_tickCount; int m_invulnerableTime; int m_airCapacity; @@ -231,8 +271,7 @@ class Entity bool m_bFirstTick; int m_nextStep; - protected: - SynchedEntityData m_entityData; - bool m_bMakeStepSound; - const EntityTypeDescriptor* m_pDescriptor; +public: + static Entity::ID entityCounter; + static Random sharedRandom; }; diff --git a/source/world/entity/EntityFactory.cpp b/source/world/entity/EntityFactory.cpp index 02348707d..0c3d60627 100644 --- a/source/world/entity/EntityFactory.cpp +++ b/source/world/entity/EntityFactory.cpp @@ -65,7 +65,7 @@ Entity* EntityFactory::LoadEntity(const CompoundTag& tag, Level* level) if (entityTypeDescriptor->isType(EntityType::ITEM)) { ItemInstance* itemInstance = ((ItemEntity*)entity)->m_pItemInstance; - if (ItemInstance::isNull(itemInstance) || !Item::items[itemInstance->m_itemID]) + if (ItemInstance::isNull(itemInstance)) { delete entity; entity = nullptr; diff --git a/source/world/entity/ItemEntity.cpp b/source/world/entity/ItemEntity.cpp index ae16705dc..0afae862c 100644 --- a/source/world/entity/ItemEntity.cpp +++ b/source/world/entity/ItemEntity.cpp @@ -66,17 +66,24 @@ bool ItemEntity::isInWater() void ItemEntity::playerTouch(Player* player) { + if (m_pLevel->m_bIsClientSide) + return; + // Here, this would give the item to the player, and remove the item entity. - if (m_throwTime != 0) + if (m_throwTime != 0 || !player->isAlive()) return; Inventory* pInventory = player->m_pInventory; - pInventory->addItem(*m_pItemInstance); + if (!pInventory->addItem(*m_pItemInstance)) + return; m_pLevel->playSound(this, "random.pop", 0.3f, ((sharedRandom.nextFloat() - sharedRandom.nextFloat()) * 0.7f + 1.0f) * 2.0f); + player->take(this, m_pItemInstance->m_count); + + // On 0.2.1, this gets removed regardless. What about stacks?? if (m_pItemInstance->m_count <= 0) remove(); } diff --git a/source/world/entity/Mob.cpp b/source/world/entity/Mob.cpp index 63eb8da1e..044245c86 100644 --- a/source/world/entity/Mob.cpp +++ b/source/world/entity/Mob.cpp @@ -9,24 +9,26 @@ #include "Mob.hpp" #include "world/level/Level.hpp" #include "nbt/CompoundTag.hpp" +#include "network/RakNetInstance.hpp" +#include "network/packets/MoveEntityPacket_PosRot.hpp" -Mob::Mob(Level* pLevel) : Entity(pLevel) +void Mob::_init() { + // only sets 19 fields on 0.2.1 m_invulnerableDuration = 10; field_E8 = 0.0f; field_EC = 0.0f; - field_F0 = 0; m_oAttackAnim = 0.0f; m_attackAnim = 0.0f; - m_health = 10; - m_lastHealth = 20; + m_health = getMaxHealth(); + m_lastHealth = m_health; m_hurtTime = 0; m_hurtDuration = 0; m_hurtDir = 0.0f; m_deathTime = 0; m_attackTime = 0; - m_oTilt = 0.0f; - m_tilt = 0.0f; + m_oTilt = 0.0f; + m_tilt = 0.0f; field_120 = 0; field_124 = 0; field_128 = 0.0f; @@ -55,7 +57,12 @@ Mob::Mob(Level* pLevel) : Entity(pLevel) m_pEntLookedAt = nullptr; m_bSwinging = false; m_swingTime = 0; - m_ambientSoundTime = 0; + m_ambientSoundTime = 0; +} + +Mob::Mob(Level* pLevel) : Entity(pLevel) +{ + _init(); m_texture = "/mob/pig.png"; m_class = ""; @@ -73,11 +80,15 @@ Mob::~Mob() { } +void Mob::actuallyHurt(int damage) +{ + m_health -= damage; +} + void Mob::reset() { Entity::reset(); - // TODO what fields to reset? - m_health = 10; + _init(); } void Mob::lerpTo(const Vec3& pos, const Vec2& rot, int steps) @@ -272,7 +283,7 @@ void Mob::baseTick() m_oTilt = m_tilt; - if (m_attackTime > 0) m_attackTime--; + if (m_attackTime > 0) m_attackTime--; if (m_hurtTime > 0) m_hurtTime--; if (m_invulnerableTime > 0) m_invulnerableTime--; @@ -304,6 +315,21 @@ void Mob::baseTick() field_B58 = field_B54; field_EC = field_E8; m_oRot = m_rot; + + // @TODO: check ServerSideNetworkHandler::canReplicateEntity() + if (m_pLevel->m_pRakNetInstance && !m_pLevel->m_bIsClientSide && !isPlayer()) + { + if (fabsf(m_pos.x - m_lastSentPos.x) > 0.1f || + fabsf(m_pos.y - m_lastSentPos.y) > 0.01f || + fabsf(m_pos.z - m_lastSentPos.z) > 0.1f || + fabsf(m_lastSentRot.y - m_rot.y) > 1.0f || + fabsf(m_lastSentRot.x - m_rot.x) > 1.0f) + { + m_pLevel->m_pRakNetInstance->send(new MoveEntityPacket_PosRot(m_EntityID, Vec3(m_pos.x, m_pos.y - m_heightOffset, m_pos.z), m_rot)); + m_lastSentPos = m_pos; + m_lastSentRot = m_rot; + } + } } bool Mob::isAlive() const @@ -314,6 +340,11 @@ bool Mob::isAlive() const return m_health >= 0; } +bool Mob::interpolateOnly() const +{ + return m_pLevel->m_bIsClientSide; +} + bool Mob::hurt(Entity *pAttacker, int damage) { if (m_pLevel->m_bIsClientSide) @@ -348,7 +379,7 @@ bool Mob::hurt(Entity *pAttacker, int damage) // not in 0.1 if (var3) { - //m_pLevel->broadcastEntityEvent(this, 2); // Java + m_pLevel->broadcastEntityEvent(*this, EventType::HURT); markHurt(); if (pAttacker) @@ -430,6 +461,29 @@ void Mob::causeFallDamage(float level) } } +void Mob::handleEntityEvent(EventType::ID eventId) +{ + switch (eventId) + { + case EventType::HURT: + m_walkAnimSpeed = 1.5f; + m_invulnerableTime = m_invulnerableDuration; + m_hurtTime = m_hurtDuration = 10; + m_hurtDir = 0.0f; + m_pLevel->playSound(this, getHurtSound(), getSoundVolume(), (m_random.nextFloat() - m_random.nextFloat()) * 0.2f + 1.0f); + hurt(nullptr, 0); + break; + case EventType::DEATH: + m_pLevel->playSound(this, getDeathSound(), getSoundVolume(), (m_random.nextFloat() - m_random.nextFloat()) * 0.2f + 1.0f); + m_health = 0; + die(nullptr); + break; + default: + Entity::handleEntityEvent(eventId); + break; + } +} + void Mob::addAdditionalSaveData(CompoundTag& tag) const { tag.putInt16("Health", m_health); @@ -526,6 +580,9 @@ HitResult Mob::pick(float f1, float f2) void Mob::travel(const Vec2& pos) { + if (isImmobile()) + return; + float x2, dragFactor; float oldYPos = m_pos.y; if (isInWater() || isInLava()) @@ -607,7 +664,10 @@ void Mob::travel(const Vec2& pos) if (m_bHorizontalCollision && onLadder()) m_vel.y = 0.2f; - m_vel.y = (m_vel.y - 0.08f) * 0.98f; // gravity? + // quick, dirty workaround to fix mob jump jitter on multiplayer worlds + // could be removed if Entity::EventType::JUMP was replicated and handled, but no... + if (!interpolateOnly()) + m_vel.y = (m_vel.y - 0.08f) * 0.98f; // gravity // drag m_vel.x *= dragFactor; @@ -622,7 +682,10 @@ void Mob::die(Entity* pCulprit) field_B69 = true; if (!m_pLevel->m_bIsClientSide) + { dropDeathLoot(); + m_pLevel->broadcastEntityEvent(*this, EventType::DEATH); + } } bool Mob::canSee(Entity* pEnt) const @@ -657,7 +720,7 @@ void Mob::aiStep() m_bJumping = 0; field_B00 = Vec2::ZERO; } - else if (!field_F0) + else if (!interpolateOnly()) { updateAi(); } @@ -685,7 +748,7 @@ void Mob::aiStep() { Entity* pEnt = *it; if (pEnt->isPushable()) - pEnt->push(this); + pEnt->push(this); } } @@ -772,11 +835,6 @@ Vec3 Mob::getViewVector(float f) const return Vec3(x4 * x6, Mth::sin(x5), x3 * x6); } -void Mob::actuallyHurt(int damage) -{ - m_health -= damage; -} - void Mob::dropDeathLoot() { int itemId = getDeathLoot(); diff --git a/source/world/entity/Mob.hpp b/source/world/entity/Mob.hpp index c3cd6f097..797806f13 100644 --- a/source/world/entity/Mob.hpp +++ b/source/world/entity/Mob.hpp @@ -14,29 +14,39 @@ class Mob : public Entity { +private: + void _init(); + public: Mob(Level* pLevel); virtual ~Mob(); - //overrides - virtual void reset() override; - virtual void lerpTo(const Vec3& pos, const Vec2& rot, int steps) override; - virtual void tick() override; - virtual void baseTick() override; - virtual float getHeadHeight() const override { return 0.85f * m_bbHeight; } - virtual bool isPickable() const override { return !m_bRemoved; } - virtual bool isPushable() const override { return !m_bRemoved; } - virtual bool isShootable() const override { return true; } - virtual bool isAlive() const override; - virtual bool hurt(Entity*, int) override; - virtual void animateHurt() override; - virtual void setSize(float rad, float height) override; - virtual void outOfWorld() override; - virtual void causeFallDamage(float level) override; - virtual void addAdditionalSaveData(CompoundTag& tag) const override; - virtual void readAdditionalSaveData(const CompoundTag& tag) override; +protected: + virtual void actuallyHurt(int damage); + +public: + // overrides + void reset() override; + void lerpTo(const Vec3& pos, const Vec2& rot, int steps) override; + void tick() override; + void baseTick() override; + float getHeadHeight() const override { return 0.85f * m_bbHeight; } + bool isPickable() const override { return !m_bRemoved; } + bool isPushable() const override { return !m_bRemoved; } + bool isShootable() const override { return true; } + bool isAlive() const override; + bool isMob() const override { return true; } + bool interpolateOnly() const override; + bool hurt(Entity*, int) override; + void animateHurt() override; + void setSize(float rad, float height) override; + void outOfWorld() override; + void causeFallDamage(float level) override; + void handleEntityEvent(EventType::ID eventId) override; + void addAdditionalSaveData(CompoundTag& tag) const override; + void readAdditionalSaveData(const CompoundTag& tag) override; - //virtuals + // virtuals virtual void knockback(Entity* pEnt, int a, float x, float z); virtual void die(Entity* pCulprit); virtual bool canSee(Entity* pEnt) const; @@ -52,8 +62,6 @@ class Mob : public Entity virtual void travel(const Vec2& pos); virtual void updateWalkAnim(); virtual void aiStep(); - //AddAdditonalSaveData TODO - //ReadAdditionalSaveData TODO virtual void lookAt(Entity* pEnt, float, float); virtual bool isLookingAtAnEntity() { return m_pEntLookedAt != nullptr; } virtual Entity* getLookingAt() const { return m_pEntLookedAt; } @@ -67,7 +75,6 @@ class Mob : public Entity virtual int getMaxSpawnClusterSize() const { return 4; } virtual ItemInstance* getCarriedItem() { return nullptr; } virtual bool isBaby() const { return false; } - virtual void actuallyHurt(int damage); virtual bool removeWhenFarAway() const { return true; } virtual int getDeathLoot() const { return 0; } virtual void dropDeathLoot(); @@ -90,6 +97,8 @@ class Mob : public Entity private: int m_ambientSoundTime; + Vec3 m_lastSentPos; + Vec2 m_lastSentRot; public: int m_invulnerableDuration; @@ -97,7 +106,6 @@ class Mob : public Entity float field_E4; float field_E8; float field_EC; - char field_F0; float m_oAttackAnim; float m_attackAnim; int m_health; diff --git a/source/world/entity/Player.cpp b/source/world/entity/Player.cpp index fb00a96a0..19abc7958 100644 --- a/source/world/entity/Player.cpp +++ b/source/world/entity/Player.cpp @@ -10,18 +10,24 @@ #include "world/level/Level.hpp" #include "nbt/CompoundTag.hpp" +void Player::_init() +{ + // I just guessed, it's 5/5 fields + m_score = 0; + m_oBob = 0.0f; + m_bob = 0.0f; + m_dimension = 0; + m_destroyingBlock = false; +} + Player::Player(Level* pLevel, GameType playerGameType) : Mob(pLevel) { + _init(); m_pDescriptor = &EntityTypeDescriptor::player; m_pInventory = nullptr; field_B94 = 0; - m_score = 0; - m_oBob = 0.0f; - m_bob = 0.0f; m_name = ""; - m_dimension = 0; m_bHasRespawnPos = false; - m_destroyingBlock = false; field_C8 = RENDER_HUMANOID; @@ -35,7 +41,7 @@ Player::Player(Level* pLevel, GameType playerGameType) : Mob(pLevel) moveTo(Vec3(pos.x + 0.5f, pos.y + 1.0f, pos.z + 0.5f)); - m_health = 20; + m_health = getMaxHealth(); m_class = "humanoid"; m_texture = "mob/char.png"; @@ -49,11 +55,21 @@ Player::~Player() delete m_pInventory; } +void Player::reallyDrop(ItemEntity* pEnt) +{ + m_pLevel->addEntity(pEnt); +} + void Player::reset() { Mob::reset(); + _init(); +} - // TODO what fields to reset??? +void Player::remove() +{ + m_bIsInvisible = true; + Mob::remove(); } bool Player::hurt(Entity* pEnt, int damage) @@ -102,15 +118,18 @@ void Player::awardKillScore(Entity* pKilled, int score) m_score += score; } -void Player::resetPos() +void Player::resetPos(bool respawn) { setDefaultHeadHeight(); setSize(0.6f, 1.8f); Entity::resetPos(); - - m_health = 20; - m_deathTime = 0; + m_bIsInvisible = false; + if (respawn) + { + m_deathTime = 0; + m_health = getMaxHealth(); + } } void Player::die(Entity* pCulprit) @@ -120,9 +139,12 @@ void Player::die(Entity* pCulprit) setPos(m_pos); // update hitbox m_vel.y = 0.1f; - if (m_name == "Notch") - drop(ItemInstance(Item::apple), true); - m_pInventory->dropAll(); + if (!m_pLevel->m_bIsClientSide) + { + if (m_name == "Notch") + drop(ItemInstance(Item::apple), true); + } + m_pInventory->dropAll(m_pLevel->m_bIsClientSide); if (pCulprit) { @@ -286,6 +308,12 @@ void Player::attack(Entity* pEnt) pEnt->hurt(this, atkDmg); } +void Player::useItem(ItemInstance& item) const +{ + if (!isCreative()) + item.remove(1); +} + bool Player::canDestroy(const Tile* pTile) const { return true; @@ -301,45 +329,6 @@ void Player::displayClientMessage(const std::string& msg) } -void Player::drop(const ItemInstance& item, bool randomly) -{ - if (item.isNull()) - return; - - ItemEntity* pItemEntity = new ItemEntity(m_pLevel, Vec3(m_pos.x, m_pos.y - 0.3f + getHeadHeight(), m_pos.z), item.copy()); - pItemEntity->m_throwTime = 40; - - if (randomly) - { - float throwPower = 0.5f * m_random.nextFloat(); - float throwAngle = m_random.nextFloat(); - - pItemEntity->m_vel.x = -(throwPower * Mth::sin(2 * float(M_PI) * throwAngle)); - pItemEntity->m_vel.z = (throwPower * Mth::cos(2 * float(M_PI) * throwAngle)); - pItemEntity->m_vel.y = 0.2f; - } - else - { - pItemEntity->m_vel.x = -(Mth::sin(m_rot.x / 180.0f * float(M_PI)) * Mth::cos(m_rot.y / 180.0f * float(M_PI))) * 0.3f; - pItemEntity->m_vel.z = (Mth::cos(m_rot.x / 180.0f * float(M_PI)) * Mth::cos(m_rot.y / 180.0f * float(M_PI))) * 0.3f; - pItemEntity->m_vel.y = 0.1f - Mth::sin(m_rot.y / 180.0f * float(M_PI)) * 0.3f; - - float f1 = m_random.nextFloat(); - float f2 = m_random.nextFloat(); - - pItemEntity->m_vel.x += 0.02f * f2 * Mth::cos(2 * float(M_PI) * f1); - pItemEntity->m_vel.y += 0.1f * (m_random.nextFloat() - m_random.nextFloat()); - pItemEntity->m_vel.z += 0.02f * f2 * Mth::sin(2 * float(M_PI) * f1); - } - - reallyDrop(pItemEntity); -} - -void Player::drop() -{ - -} - int Player::getInventorySlot(int x) const { return 0; @@ -350,11 +339,6 @@ void Player::prepareCustomTextures() } -void Player::reallyDrop(ItemEntity* pEnt) -{ - m_pLevel->addEntity(pEnt); -} - void Player::respawn() { @@ -382,6 +366,51 @@ void Player::setRespawnPos(const TilePos& pos) m_respawnPos = pos; } +void Player::drop() +{ + // From b1.2_02, doesn't exist in PE + // Isn't called anywhere, but is overriden in MultiplayerLocalPlayer with a PlayerActionPacket + /*ItemInstance* item = getSelectedItem(); + if (!item) + return; + + drop(m_pInventory->removeItem(*item, 1));*/ +} + +void Player::drop(const ItemInstance& item, bool randomly) +{ + if (item.isNull()) + return; + + ItemEntity* pItemEntity = new ItemEntity(m_pLevel, Vec3(m_pos.x, m_pos.y - 0.3f + getHeadHeight(), m_pos.z), item.copy()); + pItemEntity->m_throwTime = 40; + + if (randomly) + { + float throwPower = 0.5f * m_random.nextFloat(); + float throwAngle = m_random.nextFloat(); + + pItemEntity->m_vel.x = -(throwPower * Mth::sin(2 * float(M_PI) * throwAngle)); + pItemEntity->m_vel.z = (throwPower * Mth::cos(2 * float(M_PI) * throwAngle)); + pItemEntity->m_vel.y = 0.2f; + } + else + { + pItemEntity->m_vel.x = -(Mth::sin(m_rot.x / 180.0f * float(M_PI)) * Mth::cos(m_rot.y / 180.0f * float(M_PI))) * 0.3f; + pItemEntity->m_vel.z = (Mth::cos(m_rot.x / 180.0f * float(M_PI)) * Mth::cos(m_rot.y / 180.0f * float(M_PI))) * 0.3f; + pItemEntity->m_vel.y = 0.1f - Mth::sin(m_rot.y / 180.0f * float(M_PI)) * 0.3f; + + float f1 = m_random.nextFloat(); + float f2 = m_random.nextFloat(); + + pItemEntity->m_vel.x += 0.02f * f2 * Mth::cos(2 * float(M_PI) * f1); + pItemEntity->m_vel.y += 0.1f * (m_random.nextFloat() - m_random.nextFloat()); + pItemEntity->m_vel.z += 0.02f * f2 * Mth::sin(2 * float(M_PI) * f1); + } + + reallyDrop(pItemEntity); +} + void Player::startCrafting(const TilePos& pos) { @@ -402,11 +431,6 @@ void Player::stopDestroying() m_destroyingBlock = false; } -void Player::take(Entity* pEnt, int x) -{ - -} - void Player::touch(Entity* pEnt) { pEnt->playerTouch(this); @@ -421,3 +445,8 @@ ItemInstance* Player::getSelectedItem() const { return m_pInventory->getSelected(); } + +void Player::removeSelectedItem() +{ + m_pInventory->setSelectedItem(nullptr); +} diff --git a/source/world/entity/Player.hpp b/source/world/entity/Player.hpp index 45ef9d1de..34f2f90c1 100644 --- a/source/world/entity/Player.hpp +++ b/source/world/entity/Player.hpp @@ -22,58 +22,71 @@ class Player : public Mob private: GameType _playerGameType; +private: + void _init(); + public: Player(Level* pLevel, GameType gameType); virtual ~Player(); - virtual void reset() override; - virtual float getHeadHeight() const override { return 0.12f; /*@HUH: what ?*/ } - virtual bool isShootable() const override { return true; } - virtual bool isPlayer() const override { return true; } - virtual bool isCreativeModeAllowed() const override { return true; } - virtual bool hurt(Entity*, int) override; - virtual void awardKillScore(Entity* pKilled, int score) override; - virtual void resetPos() override; - virtual void die(Entity* pCulprit) override; - virtual void aiStep() override; +protected: + virtual void reallyDrop(ItemEntity* pEnt); + bool getSharedFlag(SharedFlag flag) const override { return false; } + void setSharedFlag(SharedFlag flag, bool value) override {} + +public: + void reset() override; + void remove() override; + float getHeadHeight() const override { return 0.12f; /*@HUH: what ?*/ } + int getMaxHealth() const override { return 20; } + bool isShootable() const override { return true; } + bool isPlayer() const override { return true; } + bool isCreativeModeAllowed() const override { return true; } + bool hurt(Entity*, int) override; + void awardKillScore(Entity* pKilled, int score) override; + void resetPos(bool respawn = false) override; + void die(Entity* pCulprit) override; + void aiStep() override; ItemInstance* getCarriedItem() override; - virtual bool isImmobile() const override { return m_health <= 0; } - virtual void updateAi() override; - virtual void addAdditionalSaveData(CompoundTag& tag) const override; - virtual void readAdditionalSaveData(const CompoundTag& tag) override; + bool isImmobile() const override { return m_health <= 0; } + void updateAi() override; + void addAdditionalSaveData(CompoundTag& tag) const override; + void readAdditionalSaveData(const CompoundTag& tag) override; + virtual void animateRespawn(); + virtual void drop(); virtual void drop(const ItemInstance& item, bool randomly = false); virtual void startCrafting(const TilePos& pos); virtual void startStonecutting(const TilePos& pos); virtual void startDestroying(); virtual void stopDestroying(); virtual bool isLocalPlayer() const { return false; } + virtual void take(Entity* pEnt, int count) {} int addResource(int); void animateRespawn(Player*, Level*); void attack(Entity* pEnt); + void useItem(ItemInstance& item) const; bool canDestroy(const Tile*) const; void closeContainer(); void displayClientMessage(const std::string& msg); - void drop(); float getDestroySpeed() const { return 1.0f; } int getInventorySlot(int x) const; TilePos getRespawnPosition() const { return m_respawnPos; } int getScore() const { return m_score; } void prepareCustomTextures(); - void reallyDrop(ItemEntity* pEnt); void respawn(); void rideTick(); void setDefaultHeadHeight(); void setRespawnPos(const TilePos& pos); - void take(Entity* pEnt, int x); void touch(Entity* pEnt); GameType getPlayerGameType() const { return _playerGameType; } virtual void setPlayerGameType(GameType playerGameType) { _playerGameType = playerGameType; } bool isSurvival() const { return getPlayerGameType() == GAME_TYPE_SURVIVAL; } bool isCreative() const { return getPlayerGameType() == GAME_TYPE_CREATIVE; } ItemInstance* getSelectedItem() const; + void removeSelectedItem(); bool isUsingItem() const { return !ItemInstance::isNull(getSelectedItem()); } // QUIRK: Yes, I did mean it like that, as did Mojang. diff --git a/source/world/entity/SynchedEntityData.cpp b/source/world/entity/SynchedEntityData.cpp index d1a583074..cec5ba8d9 100644 --- a/source/world/entity/SynchedEntityData.cpp +++ b/source/world/entity/SynchedEntityData.cpp @@ -1,3 +1,5 @@ +#include + #include "SynchedEntityData.hpp" #define MAP(cType, typeEnum, value) template<> SynchedEntityData::DataType SynchedEntityData::DataTypeMap::typeFor() { return SynchedEntityData::typeEnum; } \ @@ -18,10 +20,14 @@ MAP(Vec3, TYPE_VEC3, Vec3()) SynchedEntityData::SynchedEntityData() { m_itemsArray = ItemsArray(); - m_minIdxDirty = -1; + m_minIdxDirty = INT_MAX; m_maxIdxDirty = 0; } +SynchedEntityData::~SynchedEntityData() +{ +} + void SynchedEntityData::_updateMinMaxIdxDirty(DataID id) { if (id < m_minIdxDirty) @@ -50,3 +56,222 @@ bool SynchedEntityData::hasData(DataID id) const { return id <= m_itemsArray.size() && m_itemsArray[id] != nullptr; } + +bool SynchedEntityData::isDirty() const +{ + return m_minIdxDirty != (DataID)INT_MAX; +} + +void SynchedEntityData::clear() +{ + for (int i = 0; i < m_itemsArray.size(); i++) + { + DataItem* item = m_itemsArray[i]; + SAFE_DELETE(item); + } + + m_itemsArray.clear(); + // Mark as clean + m_minIdxDirty = INT_MAX; + m_maxIdxDirty = 0; +} + +SynchedEntityData::ItemsArray SynchedEntityData::packDirty() +{ + ItemsArray result; + + for (int i = m_minIdxDirty; i <= m_maxIdxDirty; i++) + { + DataItem* item = m_itemsArray[i]; + if (item && item->isDirty()) + { + item->setDirty(false); + result.push_back(item); + } + } + + // Mark as clean + m_minIdxDirty = INT_MAX; + return result; +} + +void SynchedEntityData::packAll(IDataOutput& dos) const +{ + Pack(m_itemsArray, dos); +} + +void SynchedEntityData::assignValues(const ItemsArray& items) +{ + for (int i = 0; i < items.size(); i++) + { + DataItem* newItem = items[i]; + DataID itemId = newItem->getId(); + if (itemId >= m_itemsArray.size()) + continue; + + DataItem* oldItem = m_itemsArray[itemId]; + if (!oldItem) + continue; + + bool result = false; + + // ugly + switch (newItem->getType()) + { + case TYPE_INT8: + result = set(itemId, newItem->getData()); + break; + case TYPE_INT16: + result = set(itemId, newItem->getData()); + break; + case TYPE_INT32: + result = set(itemId, newItem->getData()); + break; + case TYPE_FLOAT: + result = set(itemId, newItem->getData()); + break; + case TYPE_STRING: + result = set(itemId, newItem->getData()); + break; + case TYPE_ITEMINSTANCE: + result = set(itemId, newItem->getData()); + break; + case TYPE_TILEPOS: + result = set(itemId, newItem->getData()); + break; + case TYPE_INT64: + result = set(itemId, newItem->getData()); + break; + case TYPE_VEC3: + result = set(itemId, newItem->getData()); + break; + default: + continue; + } + } +} + +void SynchedEntityData::_WriteDataItem(IDataOutput& dos, const DataItem& dataItem) +{ + int8_t var2 = dataItem.getType() << C_ENTITYDATA_TYPE_SHIFT | dataItem.getId() & C_ENTITYDATA_MAX_ID_VALUE; + dos.writeInt8(var2); + switch (dataItem.getType()) + { + case TYPE_INT8: + dos.writeInt8(dataItem.getData()); + break; + case TYPE_INT16: + dos.writeInt16(dataItem.getData()); + break; + case TYPE_INT32: + dos.writeInt32(dataItem.getData()); + break; + case TYPE_FLOAT: + dos.writeFloat(dataItem.getData()); + break; + case TYPE_STRING: + dos.writeString(dataItem.getData()); + break; + case TYPE_ITEMINSTANCE: + { + ItemInstance item = dataItem.getData(); + dos.writeInt16(item.getItem()->m_itemID); + dos.writeInt8(item.m_count); + dos.writeInt16(item.getAuxValue()); + break; + } + case TYPE_TILEPOS: + { + TilePos tilePos = dataItem.getData(); + dos.writeInt32(tilePos.x); + dos.writeInt32(tilePos.y); + dos.writeInt32(tilePos.z); + break; + } + case TYPE_INT64: + dos.writeInt64(dataItem.getData()); + break; + case TYPE_VEC3: + { + Vec3 pos = dataItem.getData(); + dos.writeFloat(pos.x); + dos.writeFloat(pos.y); + dos.writeFloat(pos.z); + break; + } + } +} + +void SynchedEntityData::Pack(const ItemsArray& items, IDataOutput& dos) +{ + for (int i = 0; i < items.size(); i++) + { + const DataItem* item = items[i]; + if (item) + _WriteDataItem(dos, *item); + } + + dos.writeInt8(C_ENTITYDATA_EOF_MARKER); +} + +SynchedEntityData::ItemsArray SynchedEntityData::Unpack(IDataInput& dis) +{ + ItemsArray result; + + for (int8_t var2 = dis.readInt8(); var2 != C_ENTITYDATA_EOF_MARKER; var2 = dis.readInt8()) + { + DataType dataType = (DataType)(var2 >> 5); + DataID dataId = var2 & C_ENTITYDATA_MAX_ID_VALUE; + DataItem* dataItem = nullptr; + + switch (dataType) + { + case TYPE_INT8: + dataItem = new DataItem2(dataType, dataId, dis.readInt8()); + break; + case TYPE_INT16: + dataItem = new DataItem2(dataType, dataId, dis.readInt16()); + break; + case TYPE_INT32: + dataItem = new DataItem2(dataType, dataId, dis.readInt32()); + break; + case TYPE_FLOAT: + dataItem = new DataItem2(dataType, dataId, dis.readFloat()); + break; + case TYPE_STRING: + dataItem = new DataItem2(dataType, dataId, dis.readString()); + break; + case TYPE_ITEMINSTANCE: + { + int16_t itemId = dis.readInt16(); + int8_t amount = dis.readInt8(); + int16_t auxValue = dis.readInt16(); + dataItem = new DataItem2(dataType, dataId, ItemInstance(itemId, amount, auxValue)); + break; + } + case TYPE_TILEPOS: + { + int32_t x = dis.readInt32(); + int32_t y = dis.readInt32(); + int32_t z = dis.readInt32(); + dataItem = new DataItem2(dataType, dataId, TilePos(x, y, z)); + break; + } + case TYPE_INT64: + dataItem = new DataItem2(dataType, dataId, dis.readInt64()); + break; + case TYPE_VEC3: + { + float x = dis.readFloat(); + float y = dis.readFloat(); + float z = dis.readFloat(); + dataItem = new DataItem2(dataType, dataId, Vec3(x, y, z)); + break; + } + } + + result.push_back(dataItem); + } + + return result; +} \ No newline at end of file diff --git a/source/world/entity/SynchedEntityData.hpp b/source/world/entity/SynchedEntityData.hpp index 1d3906cdc..87a6f9528 100644 --- a/source/world/entity/SynchedEntityData.hpp +++ b/source/world/entity/SynchedEntityData.hpp @@ -4,6 +4,7 @@ #include #include "common/Util.hpp" +#include "common/DataIO.hpp" #include "world/item/ItemInstance.hpp" #include "world/phys/Vec3.hpp" @@ -14,6 +15,7 @@ class SynchedEntityData { +public: typedef uint16_t DataID; // Order here matters! @@ -60,6 +62,10 @@ class SynchedEntityData DataType getType() const { return m_type; } bool isDirty() const { return m_bDirty; } void setDirty(bool dirty) { m_bDirty = dirty; } + + // beautiful + template + T getData() const { return ((DataItem2*)this)->getData(); } }; template @@ -79,14 +85,11 @@ class SynchedEntityData T getData() const { return m_data; } }; -public: typedef std::vector ItemsArray; - ItemsArray m_itemsArray; - DataID m_minIdxDirty; - DataID m_maxIdxDirty; public: SynchedEntityData(); + ~SynchedEntityData(); private: void _updateMinMaxIdxDirty(DataID id); @@ -95,6 +98,11 @@ class SynchedEntityData public: bool hasData(DataID id) const; + bool isDirty() const; + void clear(); + ItemsArray packDirty(); + void packAll(IDataOutput& dos) const; + void assignValues(const ItemsArray& items); // These all need to be defined in the header file per https://stackoverflow.com/questions/456713/why-do-i-get-unresolved-external-symbol-errors-when-using-templates template void define(DataID id, const T& value) @@ -117,8 +125,7 @@ class SynchedEntityData { if (hasData(id) && m_itemsArray[id]->getType() == DataTypeMap::typeFor()) { - const DataItem2* dataItem = (const DataItem2*)m_itemsArray[id]; - return dataItem->getData(); + return m_itemsArray[id]->getData(); } else { @@ -159,4 +166,16 @@ class SynchedEntityData DataItem2* dataItem = (DataItem2*)_get(id); return set(dataItem, value); } + +private: + static void _WriteDataItem(IDataOutput& dos, const DataItem& dataItem); + +public: + static void Pack(const ItemsArray& items, IDataOutput& dos); + static ItemsArray Unpack(IDataInput& dis); + +private: + ItemsArray m_itemsArray; + DataID m_minIdxDirty; + DataID m_maxIdxDirty; }; diff --git a/source/world/gamemode/GameMode.cpp b/source/world/gamemode/GameMode.cpp index 448a16410..8f43749b4 100644 --- a/source/world/gamemode/GameMode.cpp +++ b/source/world/gamemode/GameMode.cpp @@ -8,6 +8,7 @@ #include "GameMode.hpp" #include "client/app/Minecraft.hpp" +#include "network/packets/RemoveBlockPacket.hpp" GameMode::GameMode(Minecraft* pMinecraft, Level& level) : m_pMinecraft(pMinecraft), @@ -32,23 +33,23 @@ bool GameMode::startDestroyBlock(Player* player, const TilePos& pos, Facing::Nam bool GameMode::destroyBlock(Player* player, const TilePos& pos, Facing::Name face) { - Tile* pTile = Tile::tiles[_level.getTile(pos)]; - if (!pTile) + Tile* oldTile = Tile::tiles[_level.getTile(pos)]; + if (!oldTile) return false; m_pMinecraft->m_pParticleEngine->destroyEffect(pos); int tileData = _level.getData(pos); - pTile->playerWillDestroy(player, pos, face); - bool bChanged = _level.setTile(pos, TILE_AIR); - if (!bChanged) + oldTile->playerWillDestroy(player, pos, face); + bool changed = _level.setTile(pos, TILE_AIR); + if (!changed) return false; - _level.playSound(pos + 0.5f, "step." + pTile->m_pSound->m_name, - (pTile->m_pSound->volume * 0.5f) + 0.5f, pTile->m_pSound->pitch * 0.8f); + _level.playSound(pos + 0.5f, "step." + oldTile->m_pSound->m_name, + (oldTile->m_pSound->volume * 0.5f) + 0.5f, oldTile->m_pSound->pitch * 0.8f); - pTile->destroy(&_level, pos, tileData); + oldTile->destroy(&_level, pos, tileData); if (m_pMinecraft->isOnline()) { @@ -147,12 +148,25 @@ bool GameMode::useItem(Player* player, Level* level, ItemInstance* instance) bool GameMode::useItemOn(Player* player, Level* level, ItemInstance* instance, const TilePos& pos, Facing::Name face) { TileID tile = level->getTile(pos); + if (tile == Tile::invisible_bedrock->m_ID) + return false; + + bool success = false; + if (tile > 0 && Tile::tiles[tile]->use(level, pos, player)) - return true; + { + success = true; + } + else if (instance) + { + success = instance->useOn(player, level, pos, face); + } - if (instance) - return instance->useOn(player, level, pos, face); + if (success) + { + _level.m_pRakNetInstance->send(new UseItemPacket(pos, face, player->m_EntityID, instance)); + } - return false; + return success; } diff --git a/source/world/gamemode/GameMode.hpp b/source/world/gamemode/GameMode.hpp index 873540589..d5c28dcc3 100644 --- a/source/world/gamemode/GameMode.hpp +++ b/source/world/gamemode/GameMode.hpp @@ -8,9 +8,9 @@ #pragma once +#include "client/player/LocalPlayer.hpp" #include "world/level/Level.hpp" #include "world/item/ItemInstance.hpp" -#include "world/entity/LocalPlayer.hpp" class Minecraft; diff --git a/source/world/gamemode/GameType.hpp b/source/world/gamemode/GameType.hpp index f72480981..827982990 100644 --- a/source/world/gamemode/GameType.hpp +++ b/source/world/gamemode/GameType.hpp @@ -1,5 +1,7 @@ #pragma once +#include + enum GameType { GAME_TYPE_SURVIVAL, diff --git a/source/world/gamemode/SurvivalMode.cpp b/source/world/gamemode/SurvivalMode.cpp index 2f2c42481..80bc7f00e 100644 --- a/source/world/gamemode/SurvivalMode.cpp +++ b/source/world/gamemode/SurvivalMode.cpp @@ -8,6 +8,7 @@ #include "SurvivalMode.hpp" #include "client/app/Minecraft.hpp" +#include "network/packets/RemoveBlockPacket.hpp" SurvivalMode::SurvivalMode(Minecraft* pMC, Level& level) : GameMode(pMC, level), m_destroyingPos(-1, -1, -1), @@ -55,28 +56,37 @@ bool SurvivalMode::startDestroyBlock(Player* player, const TilePos& pos, Facing: bool SurvivalMode::destroyBlock(Player* player, const TilePos& pos, Facing::Name face) { - m_pMinecraft->m_pParticleEngine->destroyEffect(pos); - TileID tile = _level.getTile(pos); int data = _level.getData(pos); - if (!GameMode::destroyBlock(player, pos, face)) - return false; - - //@HUH: check too late? - bool bCanDestroy = m_pMinecraft->m_pLocalPlayer->canDestroy(Tile::tiles[tile]); + bool changed = GameMode::destroyBlock(player, pos, face); - if (bCanDestroy) + bool couldDestroy = player->canDestroy(Tile::tiles[tile]); + ItemInstance* item = player->getSelectedItem(); + if (item) { - Tile::tiles[tile]->playerDestroy(&_level, m_pMinecraft->m_pLocalPlayer, pos, data); + item->mineBlock(pos, face); + if (item->m_count == 0) + { + item->snap(player); + player->removeSelectedItem(); + } + } - if (m_pMinecraft->isOnline()) + if (changed && couldDestroy) + { +#ifdef MOD_POCKET_SURVIVAL + ItemInstance tileItem(tile, 1, data); + if (tile == TILE_GRASS || !player->m_pInventory->hasUnlimitedResource(&tileItem)) { - m_pMinecraft->m_pRakNetInstance->send(new RemoveBlockPacket(m_pMinecraft->m_pLocalPlayer->m_EntityID, pos)); + Tile::tiles[tile]->playerDestroy(&_level, player, pos, data); } +#else + Tile::tiles[tile]->playerDestroy(&_level, player, pos, data); +#endif } - return true; + return changed; } bool SurvivalMode::continueDestroyBlock(Player* player, const TilePos& pos, Facing::Name face) @@ -150,3 +160,20 @@ void SurvivalMode::render(float f) m_pMinecraft->m_pLevelRenderer->field_10 = x; } } + +bool SurvivalMode::useItemOn(Player* player, Level* level, ItemInstance* instance, const TilePos& pos, Facing::Name face) +{ +#ifdef MOD_POCKET_SURVIVAL + if (!instance) + return GameMode::useItemOn(player, level, instance, pos, face); + + int oldCount = instance->m_count; + bool result = GameMode::useItemOn(player, level, instance, pos, face); + if (player->m_pInventory->hasUnlimitedResource(instance)) + instance->m_count = oldCount; + + return result; +#else + return GameMode::useItemOn(player, level, instance, pos, face); +#endif +} \ No newline at end of file diff --git a/source/world/gamemode/SurvivalMode.hpp b/source/world/gamemode/SurvivalMode.hpp index b03b41788..5869a567c 100644 --- a/source/world/gamemode/SurvivalMode.hpp +++ b/source/world/gamemode/SurvivalMode.hpp @@ -23,6 +23,7 @@ class SurvivalMode : public GameMode void render(float f) override; float getBlockReachDistance() const override { return 4.0f; } // 4.0f on Java, 5.0f until 0.10.0-0.12.1 float getEntityReachDistance() const override { return 3.0f; } + bool useItemOn(Player*, Level*, ItemInstance*, const TilePos& pos, Facing::Name face) override; bool isCreativeType() const override { return false; } bool isSurvivalType() const override { return true; } void initPlayer(Player*) override; diff --git a/source/world/item/AuxTileItem.cpp b/source/world/item/AuxTileItem.cpp index 61f1ce511..63307fc56 100644 --- a/source/world/item/AuxTileItem.cpp +++ b/source/world/item/AuxTileItem.cpp @@ -12,7 +12,7 @@ int AuxTileItem::getIcon(const ItemInstance* item) const return Tile::tiles[m_itemID]->getTexture(Facing::NORTH, item->getAuxValue()); } -int AuxTileItem::getLevelDataForAuxValue(int x) +TileData AuxTileItem::getLevelDataForAuxValue(int x) const { return x; } diff --git a/source/world/item/AuxTileItem.hpp b/source/world/item/AuxTileItem.hpp index e05f74e23..e34b0aad1 100644 --- a/source/world/item/AuxTileItem.hpp +++ b/source/world/item/AuxTileItem.hpp @@ -7,5 +7,5 @@ class AuxTileItem : public TileItem public: AuxTileItem(int id); int getIcon(const ItemInstance*) const override; - int getLevelDataForAuxValue(int x) override; + TileData getLevelDataForAuxValue(int x) const override; }; diff --git a/source/world/item/CameraItem.cpp b/source/world/item/CameraItem.cpp index 157e4c400..ae538f62e 100644 --- a/source/world/item/CameraItem.cpp +++ b/source/world/item/CameraItem.cpp @@ -18,7 +18,7 @@ CameraItem::CameraItem(int id) : Item(id) { } -ItemInstance* CameraItem::use(ItemInstance* inst, Level* level, Player* player) +ItemInstance* CameraItem::use(ItemInstance* inst, Level* level, Player* player) const { #ifndef ORIGINAL_CODE // prevent players from using this in multiplayer, to prevent a desync of entity IDs diff --git a/source/world/item/CameraItem.hpp b/source/world/item/CameraItem.hpp index 7f332cb99..6f0b9df02 100644 --- a/source/world/item/CameraItem.hpp +++ b/source/world/item/CameraItem.hpp @@ -14,5 +14,5 @@ class CameraItem : public Item public: CameraItem(int id); - ItemInstance* use(ItemInstance* inst, Level* level, Player* player) override; + ItemInstance* use(ItemInstance* inst, Level* level, Player* player) const override; }; diff --git a/source/world/item/ClothItem.cpp b/source/world/item/ClothItem.cpp index 522d29281..a0477b34f 100644 --- a/source/world/item/ClothItem.cpp +++ b/source/world/item/ClothItem.cpp @@ -11,7 +11,7 @@ ClothItem::ClothItem(int id) : TileItem(id) m_bStackedByData = true; } -std::string ClothItem::getDescriptionId(ItemInstance* item) +std::string ClothItem::getDescriptionId(ItemInstance* item) const { return TileItem::getDescriptionId(item) + "."/* + DyeColor::IDS[ClothTile::getColorFromData(item->getAuxValue())];*/; } @@ -21,7 +21,7 @@ int ClothItem::getIcon(const ItemInstance* item) const return Tile::cloth->getTexture(Facing::NORTH, ClothTile::getColorFromData(item->getAuxValue())); } -int ClothItem::getLevelDataForAuxValue(int x) +TileData ClothItem::getLevelDataForAuxValue(int x) const { return x; } diff --git a/source/world/item/ClothItem.hpp b/source/world/item/ClothItem.hpp index 8c91d9b09..23d55d89f 100644 --- a/source/world/item/ClothItem.hpp +++ b/source/world/item/ClothItem.hpp @@ -6,7 +6,7 @@ class ClothItem : public TileItem { public: ClothItem(int id); - std::string getDescriptionId(ItemInstance* item) override; + std::string getDescriptionId(ItemInstance* item) const override; int getIcon(const ItemInstance*) const override; - int getLevelDataForAuxValue(int x) override; + TileData getLevelDataForAuxValue(int x) const override; }; diff --git a/source/world/item/DoorItem.cpp b/source/world/item/DoorItem.cpp index 8ae01f733..5ce7e3dc2 100644 --- a/source/world/item/DoorItem.cpp +++ b/source/world/item/DoorItem.cpp @@ -18,7 +18,7 @@ DoorItem::DoorItem(int id, Material* pMtl) : Item(id) m_pMaterial = pMtl; } -bool DoorItem::useOn(ItemInstance* inst, Player* player, Level* level, const TilePos& pos, Facing::Name face) +bool DoorItem::useOn(ItemInstance* inst, Player* player, Level* level, const TilePos& pos, Facing::Name face) const { if (face != Facing::UP) return false; diff --git a/source/world/item/DoorItem.hpp b/source/world/item/DoorItem.hpp index a9f346292..3a7e4bc23 100644 --- a/source/world/item/DoorItem.hpp +++ b/source/world/item/DoorItem.hpp @@ -14,7 +14,7 @@ class DoorItem : public Item public: DoorItem(int id, Material* pMtl); - virtual bool useOn(ItemInstance*, Player*, Level*, const TilePos& pos, Facing::Name face); + bool useOn(ItemInstance*, Player*, Level*, const TilePos& pos, Facing::Name face) const override; public: Material* m_pMaterial; diff --git a/source/world/item/Inventory.cpp b/source/world/item/Inventory.cpp index 81137fe21..24ef66002 100644 --- a/source/world/item/Inventory.cpp +++ b/source/world/item/Inventory.cpp @@ -116,16 +116,87 @@ void Inventory::prepareCreativeInventory() void Inventory::prepareSurvivalInventory() { clear(); - m_items.resize(C_NUM_SURVIVAL_SLOTS); +#ifndef MOD_POCKET_SURVIVAL + m_items.resize(C_SURVIVAL_INVENTORY_SIZE); +#endif // Add some items for testing - addTestItem(Item::stick->m_itemID, 64); + /*addTestItem(Item::stick->m_itemID, 64); addTestItem(Item::wheat->m_itemID, 64); addTestItem(Item::sugar->m_itemID, 64); addTestItem(Item::camera->m_itemID, 64); addTestItem(Tile::ladder->m_ID, 64); addTestItem(Tile::obsidian->m_ID, 64); - addTestItem(Tile::fire->m_ID, 64); + addTestItem(Tile::fire->m_ID, 64);*/ + + addCreativeItem(ITEM_SHOVEL_STONE); + addCreativeItem(ITEM_PICKAXE_STONE); + addCreativeItem(ITEM_HATCHET_STONE); + //addCreativeItem(ITEM_SHEARS); + addCreativeItem(ITEM_SWORD_STONE); + addCreativeItem(TILE_LADDER); + addCreativeItem(TILE_TORCH); + addCreativeItem(ITEM_DOOR_WOOD); + addCreativeItem(TILE_FENCE); + //addCreativeItem(TILE_FENCEGATE); + addCreativeItem(TILE_STONEBRICK); + addCreativeItem(TILE_TREE_TRUNK, 1); + addCreativeItem(TILE_TREE_TRUNK, 2); + addCreativeItem(TILE_WOOD); + addCreativeItem(TILE_DIRT); + addCreativeItem(TILE_SANDSTONE); + addCreativeItem(TILE_GRAVEL); + addCreativeItem(TILE_STONE); + addCreativeItem(TILE_STAIRS_WOOD); + addCreativeItem(TILE_STAIRS_STONE); + addCreativeItem(TILE_STONESLAB_HALF); + addCreativeItem(TILE_SAND); + addCreativeItem(TILE_CLOTH, 7); + addCreativeItem(TILE_CLOTH, 6); + addCreativeItem(TILE_CLOTH, 5); + addCreativeItem(TILE_CLOTH, 4); + addCreativeItem(TILE_CLOTH, 3); + addCreativeItem(TILE_CLOTH, 15); + addCreativeItem(TILE_CLOTH, 14); + addCreativeItem(TILE_CLOTH, 13); + addCreativeItem(TILE_CLOTH, 12); + addCreativeItem(TILE_CLOTH, 11); + addCreativeItem(TILE_CLOTH, 10); + addCreativeItem(TILE_CLOTH, 9); + addCreativeItem(TILE_CLOTH, 8); + addCreativeItem(TILE_GLASS); + addCreativeItem(TILE_LEAVES); + + if (_getGameMode() == GAME_TYPE_CREATIVE) + { + addCreativeItem(TILE_BLOCK_GOLD); + addCreativeItem(TILE_BLOCK_IRON); + addCreativeItem(TILE_BLOCK_EMERALD); + addCreativeItem(TILE_OBSIDIAN); + addCreativeItem(TILE_BOOKSHELF); + } + else + { + addCreativeItem(TILE_OBSIDIAN); // count of 0 + } + + addCreativeItem(TILE_FLOWER); + addCreativeItem(TILE_ROSE); + addCreativeItem(TILE_MUSHROOM_1); + addCreativeItem(TILE_MUSHROOM_2); + addCreativeItem(TILE_CACTUS); + addCreativeItem(ITEM_REEDS); + +#ifdef MOD_POCKET_SURVIVAL + for (int i = 0; i < getNumSlots(); i++) + { + ItemInstance* item = m_items[i]; + if (_getGameMode() == GAME_TYPE_SURVIVAL && !hasUnlimitedResource(item)) + { + item->m_count = 0; + } + } +#endif for (int i = 0; i < C_MAX_HOTBAR_ITEMS; i++) m_hotbar[i] = i; @@ -136,7 +207,7 @@ int Inventory::getNumSlots() switch (_getGameMode()) { case GAME_TYPE_SURVIVAL: - return C_NUM_SURVIVAL_SLOTS; + return C_SURVIVAL_INVENTORY_SIZE; default: return getNumItems(); } @@ -152,11 +223,16 @@ void Inventory::addCreativeItem(int itemID, int auxValue) m_items.push_back(new ItemInstance(itemID, 1, auxValue)); } +void Inventory::release(int slotNo) +{ + SAFE_DELETE(m_items[slotNo]); +} + void Inventory::empty() { for (int i = 0; i < m_items.size(); i++) { - delete m_items[i]; + release(i); m_items[i] = nullptr; } } @@ -165,7 +241,7 @@ void Inventory::clear() { for (int i = 0; i < m_items.size(); i++) { - delete m_items[i]; + release(i); } m_items.clear(); } @@ -178,7 +254,7 @@ bool Inventory::addItem(ItemInstance& instance) if (_getGameMode() == GAME_TYPE_CREATIVE) { // Just get rid of the item. - instance.m_count = 0; + instance.setNull(); return true; } @@ -186,7 +262,7 @@ bool Inventory::addItem(ItemInstance& instance) for (int i = 0; i < getNumItems(); i++) { ItemInstance* item = m_items[i]; - if (!item || item->m_itemID != instance.m_itemID) + if (!item || item->getItem() != instance.getItem()) continue; int maxStackSize = item->getMaxStackSize(); @@ -201,10 +277,10 @@ bool Inventory::addItem(ItemInstance& instance) if (leftover < 0) leftover = 0; else - combinedItemAmount = C_MAX_AMOUNT; + combinedItemAmount = C_MAX_INVENTORY_STACK_SIZE; item->m_count = combinedItemAmount; - item->m_popTime = 5; + item->m_popTime = C_POP_TIME_DURATION; instance.m_count = leftover; @@ -223,13 +299,13 @@ bool Inventory::addItem(ItemInstance& instance) if (item) { - if (item->m_itemID != 0) + if (item->getId() != 0) continue; delete item; } - item = m_items[i] = new ItemInstance(instance); - item->m_popTime = 5; + item = m_items[i] = instance.copy(); + item->m_popTime = C_POP_TIME_DURATION; instance.m_count = 0; return true; } @@ -263,7 +339,51 @@ void Inventory::addTestItem(int itemID, int amount, int auxValue) } } -ItemInstance* Inventory::getItem(int slotNo) +bool Inventory::hasUnlimitedResource(const ItemInstance* pInstance) const +{ + if (ItemInstance::isNull(pInstance)) + return true; + + int itemId = pInstance->getId(); + + switch (itemId) + { + case ITEM_DOOR_WOOD: + return true; + } + + // strictly an item, not a tile + if (!pInstance->getTile()) + return true; + + // big ol' if statement in 0.2.1 + switch (itemId) + { + case TILE_DIRT: + case TILE_GRAVEL: + case TILE_STONE: + case TILE_SAND: + case TILE_SANDSTONE: + case TILE_CACTUS: + case TILE_TREE_TRUNK: + + case TILE_MUSHROOM_1: + case TILE_MUSHROOM_2: + case TILE_FLOWER: + case TILE_ROSE: + case TILE_STONEBRICK: + + case TILE_OBSIDIAN: + return false; + + case TILE_LEAVES: + return true; + } + + return true; +} + +ItemInstance* Inventory::getItem(int slotNo) const { if (slotNo < 0 || slotNo >= int(m_items.size())) return nullptr; @@ -271,23 +391,20 @@ ItemInstance* Inventory::getItem(int slotNo) ItemInstance* item = m_items[slotNo]; if (!item) return nullptr; - - if (item->m_count <= 0) - item->m_itemID = 0; - + return item; } -int Inventory::getQuickSlotItemId(int slotNo) +int Inventory::getQuickSlotItemId(int slotNo) const { ItemInstance* pInst = getQuickSlotItem(slotNo); if (!pInst) return -1; - return pInst->m_itemID; + return pInst->getId(); } -ItemInstance* Inventory::getQuickSlotItem(int slotNo) +ItemInstance* Inventory::getQuickSlotItem(int slotNo) const { if (slotNo < 0 || slotNo >= C_MAX_HOTBAR_ITEMS) return nullptr; @@ -297,16 +414,33 @@ ItemInstance* Inventory::getQuickSlotItem(int slotNo) return !ItemInstance::isNull(pInst) ? pInst : nullptr; } -ItemInstance* Inventory::getSelectedItem() +ItemInstance* Inventory::getSelectedItem() const { return getQuickSlotItem(m_selectedHotbarSlot); } -int Inventory::getSelectedItemId() +int Inventory::getSelectedItemId() const { return getQuickSlotItemId(m_selectedHotbarSlot); } +void Inventory::setItem(int index, ItemInstance* item) +{ + if (index >= m_items.size()) + { + //m_armor[index - m_items.size()] = item; + } + else + { + m_items[index] = item; + } +} + +void Inventory::setSelectedItem(ItemInstance* item) +{ + setItem(m_selectedHotbarSlot, item); +} + void Inventory::selectItem(int slotNo, int maxHotBarSlot) { if (slotNo < 0 || slotNo >= getNumItems()) @@ -348,7 +482,7 @@ void Inventory::setQuickSlotIndexByItemId(int slotNo, int itemID) for (int i = 0; i < getNumItems(); i++) { ItemInstance* item = m_items[i]; - if (item && item->m_itemID == itemID) + if (item && item->getId() == itemID) { m_hotbar[slotNo] = i; return; @@ -363,7 +497,7 @@ void Inventory::selectItemById(int itemID, int maxHotBarSlot) for (int i = 0; i < getNumItems(); i++) { ItemInstance* item = m_items[i]; - if (!item || item->m_itemID != itemID) + if (!item || item->getId() != itemID) continue; selectItem(i, maxHotBarSlot); @@ -378,7 +512,7 @@ void Inventory::selectItemByIdAux(int itemID, int auxValue, int maxHotBarSlot) for (int i = 0; i < getNumItems(); i++) { ItemInstance* item = m_items[i]; - if (!item || item->m_itemID != itemID || item->getAuxValue() != auxValue) + if (!item || item->getId() != itemID || item->getAuxValue() != auxValue) continue; selectItem(i, maxHotBarSlot); @@ -402,11 +536,11 @@ void Inventory::dropAll(bool onlyClearContainer) for (int i = 0; i < getNumItems(); i++) { ItemInstance* item = m_items[i]; - if (item && item->m_count > 0) + if (!ItemInstance::isNull(item)) { if (!onlyClearContainer) m_pPlayer->drop(*item, true); - item->m_count = 0; + item->setNull(); } } } @@ -446,7 +580,7 @@ void Inventory::load(const ListTag& tag) return; clear(); - m_items.resize(C_NUM_SURVIVAL_SLOTS); + m_items.resize(C_SURVIVAL_INVENTORY_SIZE); const std::vector& itemTags = tag.rawView(); @@ -460,6 +594,14 @@ void Inventory::load(const ListTag& tag) if (slot >= 0 && slot < m_items.size()) { m_items[slot] = item; + +#ifdef MOD_POCKET_SURVIVAL + // 0.2.1 + if (item->m_count == 0 && hasUnlimitedResource(item)) + { + item->m_count = 1; + } +#endif } /*if (slot >= 100 && slot < m_armor.size() + 100) diff --git a/source/world/item/Inventory.hpp b/source/world/item/Inventory.hpp index a2cb5483b..14c26a926 100644 --- a/source/world/item/Inventory.hpp +++ b/source/world/item/Inventory.hpp @@ -9,9 +9,14 @@ class Entity; class Player; // in case we're included from Player.hpp +#define C_POP_TIME_DURATION (5) #define C_MAX_HOTBAR_ITEMS (9) -#define C_NUM_SURVIVAL_SLOTS (36) -#define C_MAX_AMOUNT (64) +#ifdef MOD_POCKET_SURVIVAL +#define C_SURVIVAL_INVENTORY_SIZE (42) +#else +#define C_SURVIVAL_INVENTORY_SIZE (36) +#endif +#define C_MAX_INVENTORY_STACK_SIZE (64) class Inventory { @@ -27,19 +32,25 @@ class Inventory void addCreativeItem(int itemID, int auxValue = 0); void addTestItem(int itemID, int amount, int auxValue = 0); + bool hasUnlimitedResource(const ItemInstance* pInstance) const; + + void release(int slotNo); void empty(); void clear(); bool addItem(ItemInstance& instance); void tick(); - ItemInstance* getItem(int slotNo); - ItemInstance* getQuickSlotItem(int slotNo); - ItemInstance* getSelectedItem(); - int getQuickSlotItemId(int slotNo); - int getSelectedItemId(); + ItemInstance* getItem(int slotNo) const; + ItemInstance* getQuickSlotItem(int slotNo) const; + ItemInstance* getSelectedItem() const; + int getQuickSlotItemId(int slotNo) const; + int getSelectedItemId() const; + + void setItem(int index, ItemInstance* item); + void setSelectedItem(ItemInstance* item); + void selectItem(int slotNo, int maxHotBarSlot); // selects an item by slot number and puts it in the quick slots if needed void selectSlot(int slotNo); - void setQuickSlotIndexByItemId(int slotNo, int itemID); void selectItemById(int itemID, int maxHotBarSlot); void selectItemByIdAux(int itemID, int auxValue, int maxHotBarSlot); diff --git a/source/world/item/Item.cpp b/source/world/item/Item.cpp index be34b081a..18c38d4c4 100644 --- a/source/world/item/Item.cpp +++ b/source/world/item/Item.cpp @@ -549,117 +549,122 @@ int Item::getIcon(const ItemInstance* pInstance) const return m_icon; } -bool Item::useOn(ItemInstance* instance, Level* level, const TilePos& pos, Facing::Name face) +bool Item::useOn(ItemInstance* instance, Level* level, const TilePos& pos, Facing::Name face) const { return false; } -bool Item::useOn(ItemInstance* instance, Player* player, Level* level, const TilePos& pos, Facing::Name face) +bool Item::useOn(ItemInstance* instance, Player* player, Level* level, const TilePos& pos, Facing::Name face) const { return false; } -float Item::getDestroySpeed(ItemInstance* instance, Tile* tile) +float Item::getDestroySpeed(ItemInstance* instance, Tile* tile) const { return 1.0f; } -ItemInstance* Item::use(ItemInstance* instance, Level* level, Player* player) +ItemInstance* Item::use(ItemInstance* instance, Level* level, Player* player) const { return instance; } -int Item::getMaxStackSize() +int Item::getMaxStackSize() const { return m_maxStackSize; } -int Item::getLevelDataForAuxValue(int x) +TileData Item::getLevelDataForAuxValue(int x) const { return 0; } -bool Item::isStackedByData() +bool Item::isStackedByData() const { return m_bStackedByData; } -int Item::getMaxDamage() +int Item::getMaxDamage() const { return m_maxDamage; } -void Item::hurtEnemy(ItemInstance* instance, Mob* mob) +void Item::hurtEnemy(ItemInstance* instance, Mob* mob) const { } -void Item::mineBlock(ItemInstance* instance, const TilePos& pos, Facing::Name face) +void Item::mineBlock(ItemInstance* instance, const TilePos& pos, Facing::Name face) const { } -int Item::getAttackDamage(Entity* ent) +int Item::getAttackDamage(Entity* ent) const { return 1; } -bool Item::canDestroySpecial(Tile* tile) +bool Item::canDestroySpecial(Tile* tile) const { return false; } -void Item::interactEnemy(ItemInstance* instance, Mob* mob) +void Item::interactEnemy(ItemInstance* instance, Mob* mob) const { } -bool Item::isHandEquipped() +bool Item::isHandEquipped() const { return m_bHandEquipped; } -bool Item::isMirroredArt() +bool Item::isMirroredArt() const { return false; } -std::string Item::getDescription() +std::string Item::getDescription() const { return m_DescriptionID; } -std::string Item::getDescription(ItemInstance* inst) +std::string Item::getDescription(ItemInstance* inst) const { return m_DescriptionID; } -std::string Item::getDescriptionId() +std::string Item::getDescriptionId() const { return m_DescriptionID; } -std::string Item::getDescriptionId(ItemInstance* inst) +std::string Item::getDescriptionId(ItemInstance* inst) const { return m_DescriptionID; } -Item* Item::getCraftingRemainingItem() +Item* Item::getCraftingRemainingItem() const { return m_pCraftingRemainingItem; } -bool Item::hasCraftingRemainingItem() +bool Item::hasCraftingRemainingItem() const { return m_pCraftingRemainingItem != 0; } -std::string Item::getName() +std::string Item::getName() const { return getDescriptionId() + ".name"; } -int Item::buildIdAux(int16_t auxValue, const CompoundTag* userData) +std::string Item::getHovertextName() const +{ + return getName(); +} + +int Item::buildIdAux(int16_t auxValue, const CompoundTag* userData) const { return auxValue | (unsigned int)(m_itemID << 16); } diff --git a/source/world/item/Item.hpp b/source/world/item/Item.hpp index d2a2af455..321b39b7a 100644 --- a/source/world/item/Item.hpp +++ b/source/world/item/Item.hpp @@ -49,7 +49,7 @@ class Item }; public: // Methods - Item(int ID); + Item(int ID = TILE_AIR); //@NOTE: The setters are virtual for whatever reason @@ -57,32 +57,33 @@ class Item virtual Item* setMaxStackSize(int mss); virtual Item* setIcon(int ix, int iy); virtual int getIcon(const ItemInstance*) const; - virtual bool useOn(ItemInstance*, Level*, const TilePos& pos, Facing::Name face); - virtual bool useOn(ItemInstance*, Player*, Level*, const TilePos& pos, Facing::Name face); - virtual float getDestroySpeed(ItemInstance*, Tile*); - virtual ItemInstance* use(ItemInstance*, Level*, Player*); - virtual int getMaxStackSize(); - virtual int getLevelDataForAuxValue(int x); - virtual bool isStackedByData(); - virtual int getMaxDamage(); - virtual void hurtEnemy(ItemInstance*, Mob*); - virtual void mineBlock(ItemInstance*, const TilePos& pos, Facing::Name face); - virtual int getAttackDamage(Entity*); - virtual bool canDestroySpecial(Tile*); - virtual void interactEnemy(ItemInstance*, Mob*); + virtual bool useOn(ItemInstance*, Level*, const TilePos& pos, Facing::Name face) const; + virtual bool useOn(ItemInstance*, Player*, Level*, const TilePos& pos, Facing::Name face) const; + virtual float getDestroySpeed(ItemInstance*, Tile*) const; + virtual ItemInstance* use(ItemInstance*, Level*, Player*) const; + virtual int getMaxStackSize() const; + virtual TileData getLevelDataForAuxValue(int x) const; + virtual bool isStackedByData() const; + virtual int getMaxDamage() const; + virtual void hurtEnemy(ItemInstance*, Mob*) const; + virtual void mineBlock(ItemInstance*, const TilePos& pos, Facing::Name face) const; + virtual int getAttackDamage(Entity*) const; + virtual bool canDestroySpecial(Tile*) const; + virtual void interactEnemy(ItemInstance*, Mob*) const; virtual Item* handEquipped(); - virtual bool isHandEquipped(); - virtual bool isMirroredArt(); + virtual bool isHandEquipped() const; + virtual bool isMirroredArt() const; virtual Item* setDescriptionId(const std::string& desc); - virtual std::string getDescription(); - virtual std::string getDescription(ItemInstance*); - virtual std::string getDescriptionId(); - virtual std::string getDescriptionId(ItemInstance*); + virtual std::string getDescription() const; + virtual std::string getDescription(ItemInstance*) const; + virtual std::string getDescriptionId() const; + virtual std::string getDescriptionId(ItemInstance*) const; virtual Item* setCraftingRemainingItem(Item*); - virtual Item* getCraftingRemainingItem(); - virtual bool hasCraftingRemainingItem(); - virtual std::string getName(); - virtual int buildIdAux(int16_t auxValue, const CompoundTag* userData = nullptr); + virtual Item* getCraftingRemainingItem() const; + virtual bool hasCraftingRemainingItem() const; + virtual std::string getName() const; + virtual std::string getHovertextName() const; + virtual int buildIdAux(int16_t auxValue, const CompoundTag* userData = nullptr) const; static void initItems(); diff --git a/source/world/item/ItemInstance.cpp b/source/world/item/ItemInstance.cpp index fc5929a09..02353332c 100644 --- a/source/world/item/ItemInstance.cpp +++ b/source/world/item/ItemInstance.cpp @@ -11,43 +11,66 @@ #include "world/tile/Tile.hpp" #include "nbt/CompoundTag.hpp" -void ItemInstance::_init(int itemID, int count, int auxValue) +const std::string +ItemInstance::TAG_DISPLAY = "display", +ItemInstance::TAG_DISPLAY_NAME = "Name", +ItemInstance::TAG_REPAIR_COST = "RepairCost", +ItemInstance::TAG_ENCHANTS = "ench"; + +void ItemInstance::_init(int id, int count, int auxValue) { - m_itemID = itemID; m_count = count; m_auxValue = auxValue; m_userData = nullptr; m_popTime = 0; + _setItem(id); } ItemInstance::ItemInstance() { - _init(0, 0, 0); + _init(); +} + +ItemInstance::ItemInstance(const ItemInstance& other) +{ + _init(other.getId(), other.m_count, other.getAuxValue()); + + bool v6 = false; + if (other.hasUserData()) + { + setUserData(other.getUserData()->uniqueClone()); + } +} + +ItemInstance::ItemInstance(bool isValid) +{ + _init(); + m_bValid = isValid; } ItemInstance::ItemInstance(Item* pItem) { - _init(pItem->m_itemID, 1, 0); + _init(pItem->m_itemID, 1); } -ItemInstance::ItemInstance(Item* pItem, int amount) +ItemInstance::ItemInstance(Item* pItem, int count) { - _init(pItem->m_itemID, amount, 0); + _init(pItem->m_itemID, count); } -ItemInstance::ItemInstance(Item* pItem, int amount, int auxValue) +ItemInstance::ItemInstance(Item* pItem, int count, int auxValue) { - _init(pItem->m_itemID, amount, auxValue); + _init(pItem->m_itemID, count, auxValue); } ItemInstance::ItemInstance(Tile* pTile) { - _init(pTile->m_ID, 1, 0); + _init(pTile->m_ID, 1); } -ItemInstance::ItemInstance(Tile* pTile, int amount) +ItemInstance::ItemInstance(Tile* pTile, int count) { - _init(pTile->m_ID, amount, 0); + _init(pTile->m_ID, count); } ItemInstance::ItemInstance(Tile* pTile, int amount, int auxValue) @@ -65,34 +88,93 @@ ItemInstance::~ItemInstance() SAFE_DELETE(m_userData); } -int ItemInstance::getId() const +bool ItemInstance::_setItem(int id) { - return m_itemID; + if (id == -1) + { + m_count = -1; + m_bValid = false; + m_pItem = nullptr; + m_pTile = nullptr; + m_auxValue = -1; + return false; + } + + if (id >= C_MAX_ITEMS) + { + return _setItem(-1); + } + + m_pItem = Item::items[id]; + if (m_pItem) + m_bValid = true; + + if (id < C_MAX_TILES) + { + m_pTile = Tile::tiles[id]; + if (m_pTile) + m_bValid = true; + } + else + { + m_pTile = nullptr; + } + + if (m_bValid) + return true; + else + return _setItem(-1); +} - /* - if (!m_valid) +int ItemInstance::getId() const +{ + if (!m_bValid) return -1; - Item* item = getItem(); + const Item* item = getItem(); if (item) return item->m_itemID; + const Tile* tile = getTile(); + if (tile) + return tile->m_ID; + return 0; - */ } int ItemInstance::getIdAux() const { - //if (!m_item) - if (m_itemID <= 0) + if (!m_pItem) return 0; return getItem()->buildIdAux(m_auxValue, m_userData); } -Item* ItemInstance::getItem() const +CompoundTag* ItemInstance::getNetworkUserData() const { - return Item::items[m_itemID]; + CompoundTag* userData = new CompoundTag(); + CompoundTag::NamedTagMap& tags = m_userData->rawView(); + for (CompoundTag::NamedTagMap::iterator it = tags.begin(); it != tags.end(); it++) + { + const std::string& name = it->first; + const Tag* tag = it->second; + if (!tag) continue; + + if (name == TAG_REPAIR_COST) + { + continue; + } + else if (name == TAG_ENCHANTS) + { + ListTag* enchants = new ListTag(); + userData->put(name, enchants); + } + else + { + userData->put(name, tag->copy()); + } + } + return userData; } void ItemInstance::setUserData(CompoundTag* tag) @@ -108,21 +190,38 @@ void ItemInstance::setUserData(CompoundTag* tag) } } +bool ItemInstance::hasSameUserData(const ItemInstance& other) const +{ + if (this->isNull() && other.isNull()) + return true; + else if (this->isNull() || other.isNull()) + return false; + + if (!this->hasUserData() && !other.hasUserData()) + return true; + else if (!this->hasUserData() || !other.hasUserData()) + return false; + + return this->getUserData() == other.getUserData(); +} + ItemInstance* ItemInstance::copy() const { - return new ItemInstance(m_itemID, m_count, m_auxValue); + return new ItemInstance(*this); } void ItemInstance::set(int inCount) { assert(inCount >= 0); - if (inCount <= getMaxStackSize()) + if (inCount > getMaxStackSize()) assert(!"stack too big!"); m_count = inCount; +#ifndef MOD_POCKET_SURVIVAL if (inCount == 0) setNull(); +#endif } bool ItemInstance::canDestroySpecial(Tile* tile) @@ -135,6 +234,14 @@ std::string ItemInstance::getDescriptionId() return getItem()->getDescriptionId(this); } +std::string ItemInstance::getHovertextName() const +{ + if (hasCustomHoverName()) + return getHoverName(); + else + return getItem()->getHovertextName(); +} + float ItemInstance::getDestroySpeed(Tile* tile) { return getItem()->getDestroySpeed(this, tile); @@ -180,17 +287,17 @@ void ItemInstance::interactEnemy(Mob* mob) getItem()->interactEnemy(this, mob); } -bool ItemInstance::isDamageableItem() +bool ItemInstance::isDamageableItem() const { return getItem()->getMaxDamage() > 0; } -bool ItemInstance::isDamaged() +bool ItemInstance::isDamaged() const { return m_auxValue > 0; } -bool ItemInstance::isStackable() +bool ItemInstance::isStackable() const { if (getMaxStackSize() <= 1) return false; @@ -201,7 +308,7 @@ bool ItemInstance::isStackable() return true; } -bool ItemInstance::isStackedByData() +bool ItemInstance::isStackedByData() const { return getItem()->isStackedByData(); } @@ -211,10 +318,9 @@ void ItemInstance::mineBlock(const TilePos& pos, Facing::Name face) return getItem()->mineBlock(this, pos, face); } -ItemInstance ItemInstance::remove(int count) +void ItemInstance::remove(int count) { - m_count -= count; - return ItemInstance(m_itemID, count, m_auxValue); + set(m_count - count); } void ItemInstance::setDescriptionId(const std::string& str) @@ -226,7 +332,7 @@ void ItemInstance::snap(Player*) } -std::string ItemInstance::toString() +std::string ItemInstance::toString() const { std::stringstream ss; ss << m_count << "x" << getItem()->getDescriptionId() << "@" << m_auxValue; @@ -244,24 +350,24 @@ bool ItemInstance::useOn(Player* player, Level* level, const TilePos& pos, Facin return getItem()->useOn(this, player, level, pos, face); } -int ItemInstance::getAttackDamage(Entity* pEnt) +int ItemInstance::getAttackDamage(Entity* pEnt) const { return getItem()->getAttackDamage(pEnt); } bool ItemInstance::isNull() const { - // 0.9.2 - if (m_itemID <= 0) // m_field_10, assuming this is m_itemID + if (!m_bValid) return true; - if (m_auxValue != 0 || - m_count != 0) + if (m_count != 0 || + m_pItem || m_pTile || + hasUserData()) { return false; } - return true; // isNull + return true; } bool ItemInstance::isNull(const ItemInstance* item) @@ -273,33 +379,97 @@ void ItemInstance::setNull() { m_count = 0; m_auxValue = 0; - //m_item = nullptr; - m_itemID = 0; + m_pItem = nullptr; + m_pTile = nullptr; m_popTime = 0; if (m_userData) delete m_userData; m_userData = nullptr; } +int ItemInstance::getBaseRepairCost() const +{ + if (hasUserData() && m_userData->contains(TAG_REPAIR_COST)) + return m_userData->getInt32(TAG_REPAIR_COST); + else + return 0; +} + +void ItemInstance::setRepairCost(int repairCost) +{ + if (!hasUserData()) + m_userData = new CompoundTag(); + + m_userData->putInt32(ItemInstance::TAG_REPAIR_COST, repairCost); +} + +bool ItemInstance::hasCustomHoverName() const +{ + if (!hasUserData() || !m_userData->contains(TAG_DISPLAY)) + return false; + + const CompoundTag* displayTag = m_userData->getCompound(TAG_DISPLAY); + return displayTag->contains(TAG_DISPLAY_NAME); +} + +std::string ItemInstance::getHoverName() const +{ + std::string hoverName; + if (hasUserData()) + { + if (m_userData->contains(TAG_DISPLAY)) + { + const CompoundTag* displayTag = m_userData->getCompound(TAG_DISPLAY); + if (displayTag->contains(TAG_DISPLAY_NAME)) + { + hoverName = displayTag->getString(TAG_DISPLAY_NAME); + } + } + } + return hoverName; +} + +void ItemInstance::setHoverName(const std::string& hoverName) +{ + if (!hasUserData()) + m_userData = new CompoundTag(); + + CompoundTag* displayTag; + if (m_userData->contains(TAG_DISPLAY)) + { + displayTag = m_userData->getCompound(TAG_DISPLAY); + } + else + { + displayTag = new CompoundTag(); + m_userData->putCompound(TAG_DISPLAY, displayTag); + } + + CompoundTag* newDisplayTag = displayTag->uniqueClone(); + newDisplayTag->putString(TAG_DISPLAY_NAME, hoverName); + + m_userData->putCompound(TAG_DISPLAY, newDisplayTag); +} + void ItemInstance::load(const CompoundTag& tag) { - m_itemID = tag.getInt16("id"); + _setItem(tag.getInt16("id")); m_count = tag.getInt8("Count"); - m_auxValue = tag.getInt16("Damage"); + setAuxValue(tag.getInt16("Damage")); - CompoundTag* newTag = nullptr; + CompoundTag* userData = nullptr; if (tag.contains("tag")) { - newTag = tag.getCompound("tag")->copy(); + userData = tag.getCompound("tag")->copy(); } - m_userData = newTag; + m_userData = userData; } CompoundTag& ItemInstance::save(CompoundTag& tag) const { - tag.putInt16("id", m_itemID); + tag.putInt16("id", getId()); tag.putInt8("Count", m_count); tag.putInt16("Damage", getDamageValue()); @@ -325,7 +495,7 @@ ItemInstance* ItemInstance::fromTag(const CompoundTag& tag) ItemInstance* item = new ItemInstance(); item->load(tag); - if (!Item::items[item->m_itemID]) + if (!item->getItem()) { delete item; item = nullptr; @@ -334,35 +504,46 @@ ItemInstance* ItemInstance::fromTag(const CompoundTag& tag) return item; } +ItemInstance* ItemInstance::operator=(const ItemInstance& other) +{ + this->m_count = other.m_count; + this->m_pItem = other.m_pItem; + this->m_pTile = other.m_pTile; + this->m_auxValue = other.m_auxValue; + this->m_bValid = other.m_bValid; + + if (other.hasUserData()) + { + this->m_userData = other.m_userData->uniqueClone(); + } + else + { + this->m_userData = nullptr; + } + + return this; +} + bool ItemInstance::operator==(const ItemInstance& other) const { - return this->getAuxValue() == other.getAuxValue() && + // 0.12.1 seems to intentionally leave out the auxValue comparison, not sure why + // but I have a feeling that doing the same will break things + return this->getItem() == other.getItem() && + this->getAuxValue() == other.getAuxValue() && this->m_count == other.m_count && - this->m_itemID == other.m_itemID; + this->hasSameUserData(other); } bool ItemInstance::operator!=(const ItemInstance& other) const { // doing this is likely more efficient than inverting the result of == after the fact - return this->getAuxValue() != other.getAuxValue() || + return this->getItem() != other.getItem() || + this->getAuxValue() != other.getAuxValue() || this->m_count != other.m_count || - this->m_itemID != other.m_itemID; + !this->hasSameUserData(other); } -/*ItemInstance::operator bool() const +ItemInstance::operator bool() const { - bool result = false; - if (m_valid) - { - Item* item = getItem(); - if (item) - { - if (!isNull()) - { - return true; - } - } - } - - return result; -}*/ \ No newline at end of file + return m_bValid && getItem() && !isNull(); +} \ No newline at end of file diff --git a/source/world/item/ItemInstance.hpp b/source/world/item/ItemInstance.hpp index e6d690753..e31b99393 100644 --- a/source/world/item/ItemInstance.hpp +++ b/source/world/item/ItemInstance.hpp @@ -23,20 +23,32 @@ class CompoundTag; class ItemInstance { +public: + static const std::string TAG_DISPLAY; + static const std::string TAG_DISPLAY_NAME; + static const std::string TAG_REPAIR_COST; + static const std::string TAG_ENCHANTS; + private: - void _init(int itemID, int amount, int auxValue); + void _init(int id = 0, int count = 0, int auxValue = 0); public: ItemInstance(); + ItemInstance(const ItemInstance& other); + ItemInstance(bool isValid); ItemInstance(Item*); - ItemInstance(Item*, int amount); - ItemInstance(Item*, int amount, int auxValue); + ItemInstance(Item*, int count); + ItemInstance(Item*, int count, int auxValue); ItemInstance(Tile*); - ItemInstance(Tile*, int amount); - ItemInstance(Tile*, int amount, int auxValue); - ItemInstance(int itemID, int amount, int auxValue); + ItemInstance(Tile*, int count); + ItemInstance(Tile*, int count, int auxValue); + ItemInstance(int id, int count, int auxValue); ~ItemInstance(); +private: + bool _setItem(int id); + +public: int getId() const; int getIdAux() const; @@ -46,11 +58,14 @@ class ItemInstance bool hasUserData() const { return m_userData != nullptr; } const CompoundTag* getUserData() const { return m_userData; } + CompoundTag* getNetworkUserData() const; void setUserData(CompoundTag* tag); + bool hasSameUserData(const ItemInstance& other) const; void set(int inCount); bool canDestroySpecial(Tile*); std::string getDescriptionId(); + std::string getHovertextName() const; float getDestroySpeed(Tile*); int getIcon() const; int getMaxDamage() const; @@ -58,46 +73,56 @@ class ItemInstance void hurt(int by); void hurtEnemy(Mob*); void interactEnemy(Mob*); - bool isDamageableItem(); - bool isDamaged(); - bool isStackable(); - bool isStackedByData(); + bool isDamageableItem() const; + bool isDamaged() const; + bool isStackable() const; + bool isStackedByData() const; void mineBlock(const TilePos& pos, Facing::Name face); - ItemInstance remove(int amt); + void remove(int count); void setDescriptionId(const std::string&); void snap(Player*); - std::string toString(); + std::string toString() const; ItemInstance* use(Level*, Player*); bool useOn(Player*, Level*, const TilePos& pos, Facing::Name face); - Item* getItem() const; + // Both need to return non-const pointers since TileRenderer calls setShape on render + Item* getItem() const { return m_pItem; } + Tile* getTile() const { return m_pTile; } + bool isValid() const { return m_bValid; } ItemInstance* copy() const; // v0.2.0 - int getAttackDamage(Entity *pEnt); + int getAttackDamage(Entity *pEnt) const; bool isNull() const; void setNull(); + // 0.12.1 + int getBaseRepairCost() const; + void setRepairCost(int repairCost); + bool hasCustomHoverName() const; + std::string getHoverName() const; + void setHoverName(const std::string& hoverName); + void load(const CompoundTag& tag); CompoundTag& save(CompoundTag& tag) const; - // @NOTE: Won't this be ambiguous with the non-static method? static bool isNull(const ItemInstance*); static bool matches(const ItemInstance*, const ItemInstance*); static ItemInstance* fromTag(const CompoundTag& tag); + ItemInstance* operator=(const ItemInstance&); bool operator==(const ItemInstance&) const; bool operator!=(const ItemInstance&) const; - //operator bool() const; + operator bool() const; public: int16_t m_count; int m_popTime; - int16_t m_itemID; private: int16_t m_auxValue; CompoundTag* m_userData; - //Item* m_item; // @TODO: replace m_itemID with Item pointer - //bool m_valid; + Item* m_pItem; // @TODO: replace m_itemID with Item pointer + Tile* m_pTile; + bool m_bValid; }; diff --git a/source/world/item/RocketItem.cpp b/source/world/item/RocketItem.cpp index 488bef601..d0e247c1e 100644 --- a/source/world/item/RocketItem.cpp +++ b/source/world/item/RocketItem.cpp @@ -15,7 +15,7 @@ RocketItem::RocketItem(int id) : Item(id) { } -bool RocketItem::useOn(ItemInstance* inst, Player* player, Level* level, const TilePos& pos, Facing::Name face) +bool RocketItem::useOn(ItemInstance* inst, Player* player, Level* level, const TilePos& pos, Facing::Name face) const { TilePos tp(pos); diff --git a/source/world/item/RocketItem.hpp b/source/world/item/RocketItem.hpp index 877caaf97..6b407a4d7 100644 --- a/source/world/item/RocketItem.hpp +++ b/source/world/item/RocketItem.hpp @@ -14,5 +14,5 @@ class RocketItem : public Item public: RocketItem(int id); - bool useOn(ItemInstance*, Player*, Level*, const TilePos& pos, Facing::Name face) override; + bool useOn(ItemInstance*, Player*, Level*, const TilePos& pos, Facing::Name face) const override; }; diff --git a/source/world/item/SlabItem.cpp b/source/world/item/SlabItem.cpp index 9452ad8b4..66c950668 100644 --- a/source/world/item/SlabItem.cpp +++ b/source/world/item/SlabItem.cpp @@ -5,7 +5,7 @@ SlabItem::SlabItem(int id) : AuxTileItem(id) { } -std::string SlabItem::getDescriptionId(ItemInstance* item) +std::string SlabItem::getDescriptionId(ItemInstance* item) const { int var2 = item->getAuxValue(); if (var2 < 0 || var2 >= 4) diff --git a/source/world/item/SlabItem.hpp b/source/world/item/SlabItem.hpp index ff9d4b443..15889f2b9 100644 --- a/source/world/item/SlabItem.hpp +++ b/source/world/item/SlabItem.hpp @@ -6,5 +6,5 @@ class SlabItem : public AuxTileItem { public: SlabItem(int id); - std::string getDescriptionId(ItemInstance* item) override; + std::string getDescriptionId(ItemInstance* item) const override; }; diff --git a/source/world/item/TileItem.cpp b/source/world/item/TileItem.cpp index 5d16c7981..412b70e1c 100644 --- a/source/world/item/TileItem.cpp +++ b/source/world/item/TileItem.cpp @@ -17,17 +17,17 @@ TileItem::TileItem(int id) : Item(id) m_icon = Tile::tiles[id]->getTexture(Facing::NORTH); } -std::string TileItem::getDescriptionId() +std::string TileItem::getDescriptionId() const { return Tile::tiles[m_tile]->getDescriptionId(); } -std::string TileItem::getDescriptionId(ItemInstance* instance) +std::string TileItem::getDescriptionId(ItemInstance* instance) const { return Tile::tiles[m_tile]->getDescriptionId(); } -bool TileItem::useOn(ItemInstance* instance, Player* player, Level* level, const TilePos& pos, Facing::Name face) +bool TileItem::useOn(ItemInstance* instance, Player* player, Level* level, const TilePos& pos, Facing::Name face) const { TilePos tp(pos); @@ -45,7 +45,7 @@ bool TileItem::useOn(ItemInstance* instance, Player* player, Level* level, const case Facing::EAST: tp.x++; break; } - if (!instance->m_count) + if (instance->m_count == 0) return false; if (!level->mayPlace(m_tile, tp, false)) @@ -66,6 +66,6 @@ bool TileItem::useOn(ItemInstance* instance, Player* player, Level* level, const pTile->m_pSound->pitch * 0.8f ); - instance->m_count--; + player->useItem(*instance); return true; } diff --git a/source/world/item/TileItem.hpp b/source/world/item/TileItem.hpp index 54097be3f..58f1762d6 100644 --- a/source/world/item/TileItem.hpp +++ b/source/world/item/TileItem.hpp @@ -14,9 +14,9 @@ class TileItem : public Item public: TileItem(int id); - virtual std::string getDescriptionId(); - virtual std::string getDescriptionId(ItemInstance*); - virtual bool useOn(ItemInstance*, Player*, Level*, const TilePos& pos, Facing::Name face); + std::string getDescriptionId() const override; + std::string getDescriptionId(ItemInstance*) const override; + bool useOn(ItemInstance*, Player*, Level*, const TilePos& pos, Facing::Name face) const override; public: int m_tile; diff --git a/source/world/item/TilePlanterItem.cpp b/source/world/item/TilePlanterItem.cpp index 71e4bfe37..2e56e1d32 100644 --- a/source/world/item/TilePlanterItem.cpp +++ b/source/world/item/TilePlanterItem.cpp @@ -15,7 +15,7 @@ TilePlanterItem::TilePlanterItem(int id, int place) : Item(id) m_tile = Tile::tiles[place]->m_ID; } -bool TilePlanterItem::useOn(ItemInstance* instance, Player* player, Level* level, const TilePos& pos, Facing::Name face) +bool TilePlanterItem::useOn(ItemInstance* instance, Player* player, Level* level, const TilePos& pos, Facing::Name face) const { TilePos tp(pos); diff --git a/source/world/item/TilePlanterItem.hpp b/source/world/item/TilePlanterItem.hpp index 041e7d9ed..14425170b 100644 --- a/source/world/item/TilePlanterItem.hpp +++ b/source/world/item/TilePlanterItem.hpp @@ -14,7 +14,7 @@ class TilePlanterItem : public Item public: TilePlanterItem(int id, int place); - virtual bool useOn(ItemInstance*, Player*, Level*, const TilePos& pos, Facing::Name face); + bool useOn(ItemInstance*, Player*, Level*, const TilePos& pos, Facing::Name face) const override; public: int m_tile; diff --git a/source/world/level/Dimension.cpp b/source/world/level/Dimension.cpp index 6ec2e9772..0b6ac9a5b 100644 --- a/source/world/level/Dimension.cpp +++ b/source/world/level/Dimension.cpp @@ -11,6 +11,10 @@ #include "world/level/levelgen/chunk/RandomLevelSource.hpp" #include "world/level/levelgen/chunk/ChunkCache.hpp" +#define C_TIMEOFDAY_SCALE_JAVA 24000 +#define C_TIMEOFDAY_SCALE_POCKET 14400 +#define C_TIMEOFDAY_SCALE C_TIMEOFDAY_SCALE_JAVA + Dimension* Dimension::getNew(int type) { switch (type) @@ -96,19 +100,19 @@ float Dimension::getTimeOfDay(int32_t l, float f) f = 0; #endif - int i = int(l % 24000); - float f1 = (float(i) + f) / 24000.0f - 0.25f; + int i = int(l % C_TIMEOFDAY_SCALE); + float f1 = (float(i) + f) / float(C_TIMEOFDAY_SCALE) - 0.25f; if (f1 < 0.0f) - f1 += 1.0f; + f1++; if (f1 > 1.0f) - f1 -= 1.0f; + f1--; // @NOTE: At this point, if the day/night cycle isn't running, // f1's value should be -0.25 float f2 = f1; //@NOTE: Meant to use Mth::cos? - f1 = 1.0f - (cosf(float(M_PI) * f1) + 1.0f) * 0.5f; + f1 = 1.0f - (cosf(float(M_PI) * f1) + 1.0f) / 2.f; f1 = f2 + (f1 - f2) / 3.0f; return f1; } diff --git a/source/world/level/Level.cpp b/source/world/level/Level.cpp index 6c8fdb5c5..f0c924082 100644 --- a/source/world/level/Level.cpp +++ b/source/world/level/Level.cpp @@ -9,12 +9,16 @@ #include "Level.hpp" #include + #include "common/Util.hpp" +#include "network/RakNetInstance.hpp" +#include "network/packets/EntityEventPacket.hpp" +#include "network/packets/SetEntityDataPacket.hpp" #include "world/level/levelgen/chunk/ChunkCache.hpp" #include "Explosion.hpp" #include "Region.hpp" -Level::Level(LevelStorage* pStor, const std::string& name, int32_t seed, int storageVersion, Dimension *pDimension) +Level::Level(LevelStorage* pStor, const std::string& name, const LevelSettings& settings, int storageVersion, Dimension *pDimension) { m_bInstantTicking = false; m_bIsClientSide = false; @@ -23,6 +27,7 @@ Level::Level(LevelStorage* pStor, const std::string& name, int32_t seed, int sto field_30 = 0; m_pDimension = nullptr; m_difficulty = 2; // Java has no actual default, it just always pulls from Options. Putting 2 here just so there's no chance of mobs getting despawned accidentally. + m_pRakNetInstance = nullptr; m_bCalculatingInitialSpawn = false; m_pChunkSource = nullptr; m_pLevelStorage = pStor; @@ -36,7 +41,7 @@ Level::Level(LevelStorage* pStor, const std::string& name, int32_t seed, int sto LevelData* pData = m_pLevelStorage->prepareLevel(this); - field_B0C = pData == 0; + field_B0C = pData == nullptr; // @BUG: leaking a Dimension*? if (pDimension) @@ -45,7 +50,7 @@ Level::Level(LevelStorage* pStor, const std::string& name, int32_t seed, int sto m_pDimension = new Dimension; if (!pData) - m_pLevelData = new LevelData(seed, name, storageVersion); + m_pLevelData = new LevelData(settings, name, storageVersion); else m_pLevelData = pData; @@ -113,6 +118,20 @@ int Level::getSkyDarken(float f) const return int(y * 11.0f); } +void Level::updateSkyDarken() +{ + bool skyColorChanged = updateSkyBrightness(); + + if (skyColorChanged) + { + for (std::vector::iterator it = m_levelListeners.begin(); it != m_levelListeners.end(); it++) + { + LevelListener* pListener = *it; + pListener->skyColorChanged(); + } + } +} + bool Level::updateSkyBrightness() { int skyDarken = getSkyDarken(1.0f); @@ -265,8 +284,10 @@ Material* Level::getMaterial(const TilePos& pos) const return pTile->m_pMaterial; } -Entity* Level::getEntity(int id) const +Entity* Level::getEntity(Entity::ID id) const { + // @TODO: wtf? no map?? + // prioritize players first. for (std::vector::const_iterator it = m_players.begin(); it != m_players.end(); it++) { @@ -755,6 +776,15 @@ void Level::entityRemoved(Entity* pEnt) } } +void Level::levelEvent(Player* pPlayer, LevelEvent::ID eventId, const TilePos& pos, LevelEvent::Data data) +{ + for (std::vector::iterator it = m_levelListeners.begin(); it != m_levelListeners.end(); it++) + { + LevelListener* pListener = *it; + pListener->levelEvent(pPlayer, eventId, pos, data); + } +} + AABBVector* Level::getCubes(const Entity* pEntUnused, const AABB& aabb) { m_aabbs.clear(); @@ -804,7 +834,7 @@ Player* Level::_getNearestPlayer(const Vec3& source, float maxDist, bool onlyFin if (onlyFindAttackable) { - if (player->isCreative()) + if (player->isCreative() || !player->isAlive()) continue; } @@ -982,7 +1012,7 @@ bool Level::checkAndHandleWater(const AABB& aabb, const Material* pMtl, Entity* return bInWater; } -TilePos Level::getSharedSpawnPos() const +const TilePos& Level::getSharedSpawnPos() const { return m_pLevelData->getSpawn(); } @@ -1145,13 +1175,8 @@ bool Level::addEntity(Entity* pEnt) Entity* pOldEnt = getEntity(pEnt->hashCode()); if (pOldEnt) { - LOG_W("Entity %d already exists.", pEnt->hashCode()); - //removeEntity(pOldEnt); - } - - if (!pEnt->isPlayer() && m_bIsClientSide) - { - LOG_W("Hey, why are you trying to add an non-player entity in a multiplayer world?"); + LOG_W("Entity %d already exists. Replacing...", pEnt->hashCode()); + removeEntity(pOldEnt); } //@NOTE: useless Mth::floor() calls @@ -1231,6 +1256,21 @@ void Level::loadEntities() } } +void Level::sendEntityData() +{ + if (!m_pRakNetInstance) + return; + + // Inlined on 0.2.1, god bless PerfTimer + for (EntityVector::iterator it = m_entities.begin(); it != m_entities.end(); it++) + { + Entity* ent = *it; + SynchedEntityData& data = ent->getEntityData(); + if (data.isDirty()) + m_pRakNetInstance->send(new SetEntityDataPacket(ent->m_EntityID, data)); + } +} + #ifdef ENH_IMPROVED_SAVING void Level::saveUnsavedChunks() { @@ -1395,6 +1435,14 @@ bool Level::mayPlace(TileID tile, const TilePos& pos, bool b) const return pTile->mayPlace(this, pos); } +void Level::broadcastEntityEvent(const Entity& entity, Entity::EventType::ID eventId) +{ + if (m_bIsClientSide) + return; + + m_pRakNetInstance->send(new EntityEventPacket(entity.m_EntityID, eventId)); +} + void Level::removeListener(LevelListener* listener) { std::vector::iterator iter = std::find(m_levelListeners.begin(), m_levelListeners.end(), listener); @@ -1532,24 +1580,15 @@ void Level::tick() m_pChunkSource->tick(); #ifdef ENH_RUN_DAY_NIGHT_CYCLE - bool skyColorChanged = updateSkyBrightness(); - - int time = getTime() + 1; - _setTime(time); // Bypasses the normally-required update to LevelListeners + updateSkyDarken(); - for (std::vector::iterator it = m_levelListeners.begin(); it != m_levelListeners.end(); it++) - { - LevelListener* pListener = *it; - - if (skyColorChanged) - pListener->skyColorChanged(); - - pListener->timeChanged(time); - } + setTime(getTime() + 1); #endif tickPendingTicks(false); tickTiles(); + + sendEntityData(); } void Level::tickEntities() @@ -1565,7 +1604,7 @@ void Level::tickEntities() { tick(pEnt); } - else + else if (!pEnt->isPlayer() || pEnt->m_bForceRemove) { if (pEnt->m_bInAChunk && hasChunk(pEnt->m_chunkPos)) getChunk(pEnt->m_chunkPos)->removeEntity(pEnt); @@ -1574,10 +1613,7 @@ void Level::tickEntities() i--; entityRemoved(pEnt); - - // If the entity isn't a player (managed by Minecraft* or through OnlinePlayer), then delete it. - if (!pEnt->isPlayer()) - delete pEnt; + delete pEnt; } } } @@ -1806,11 +1842,11 @@ void Level::explode(Entity* entity, const Vec3& pos, float power, bool bIsFiery) expl.addParticles(); } -void Level::addEntities(const std::vector& entities) +void Level::addEntities(const EntityVector& entities) { m_entities.insert(m_entities.end(), entities.begin(), entities.end()); - for (std::vector::iterator it = m_entities.begin(); it != m_entities.end(); it++) + for (EntityVector::iterator it = m_entities.begin(); it != m_entities.end(); it++) { Entity* pEnt = *it; entityAdded(pEnt); diff --git a/source/world/level/Level.hpp b/source/world/level/Level.hpp index 176e6f12d..900b9005d 100644 --- a/source/world/level/Level.hpp +++ b/source/world/level/Level.hpp @@ -14,9 +14,9 @@ #endif #include +#include "client/renderer/LightUpdate.hpp" #include "world/tile/Tile.hpp" #include "world/entity/Entity.hpp" -#include "world/entity/LocalPlayer.hpp" #include "world/level/TileChange.hpp" #include "world/level/levelgen/chunk/LevelChunk.hpp" #include "world/level/levelgen/chunk/ChunkSource.hpp" @@ -27,26 +27,30 @@ #include "Dimension.hpp" #include "LevelListener.hpp" #include "TickNextTickData.hpp" -#include "client/renderer/LightUpdate.hpp" +#include "LevelEvent.hpp" class Dimension; class Level; class LevelListener; +class RakNetInstance; typedef std::vector EntityVector; typedef std::vector AABBVector; class Level : public LevelSource { +public: + Level(LevelStorage* pStor, const std::string& name, const LevelSettings& settings, int storageVersion = LEVEL_STORAGE_VERSION_DEFAULT, Dimension* pDimension = nullptr); + ~Level(); + private: + Player* _getNearestPlayer(const Vec3&, float, bool) const; + +protected: // @NOTE: LevelListeners do NOT get updated here void _setTime(int32_t time) { m_pLevelData->setTime(time); } - Player* _getNearestPlayer(const Vec3&, float, bool) const; public: - Level(LevelStorage* pStor, const std::string& name, int32_t seed, int storageVersion, Dimension* pDimension = nullptr); - ~Level(); - // TODO TileID getTile(const TilePos& pos) const override; float getBrightness(const TilePos& pos) const override; @@ -55,7 +59,7 @@ class Level : public LevelSource bool isSolidTile(const TilePos& pos) const override; ChunkSource* getChunkSource() const; - ChunkSource* createChunkSource(); + virtual ChunkSource* createChunkSource(); LevelChunk* getChunk(const ChunkPos& pos) const; LevelChunk* getChunkAt(const TilePos& pos) const; int getRawBrightness(const TilePos& pos) const; @@ -66,7 +70,7 @@ class Level : public LevelSource int getSeed() const { return m_pLevelData->getSeed(); } int32_t getTime() const { return m_pLevelData->getTime(); } void setTime(int32_t time); - GameType getDefaultGameType() { return m_pLevelData->getGameType(); } + GameType getDefaultGameType() const { return m_pLevelData->getGameType(); } int getHeightmap(const TilePos& pos); bool isDay() const; bool isSkyLit(const TilePos& pos) const; @@ -75,9 +79,10 @@ class Level : public LevelSource bool hasChunk(const ChunkPos& pos) const; bool hasChunksAt(const TilePos& min, const TilePos& max) const; bool hasChunksAt(const TilePos& pos, int rad) const; - bool updateSkyBrightness(); float getTimeOfDay(float f) const; int getSkyDarken(float f) const; + void updateSkyDarken(); + bool updateSkyBrightness(); void setUpdateLights(bool b); bool updateLights(); void updateLight(const LightLayer&, const TilePos& tilePos1, const TilePos& tilePos2); @@ -96,13 +101,14 @@ class Level : public LevelSource void setTilesDirty(const TilePos& min, const TilePos& max); void entityAdded(Entity* pEnt); void entityRemoved(Entity* pEnt); + void levelEvent(Player* pPlayer, LevelEvent::ID eventId, const TilePos& pos, LevelEvent::Data data = 0); void lightColumnChanged(int x, int z, int y1, int y2); bool containsFireTile(const AABB&); bool containsAnyLiquid(const AABB&); bool containsLiquid(const AABB&, const Material *pMtl); bool containsMaterial(const AABB&, const Material *pMtl); bool checkAndHandleWater(const AABB&, const Material* pMtl, Entity* pEnt); - TilePos getSharedSpawnPos() const; + const TilePos& getSharedSpawnPos() const; void validateSpawn(); TileID getTopTile(const TilePos& pos) const; int getTopTileY(const TilePos& pos) const; @@ -118,6 +124,7 @@ class Level : public LevelSource void saveAllChunks(); void saveGame(); void loadEntities(); + void sendEntityData(); void setInitialSpawn(); void setSpawnPos(const TilePos& pos) { m_pLevelData->setSpawn(pos); } void setSpawnSettings(bool a, bool b) { } @@ -128,11 +135,12 @@ class Level : public LevelSource bool isUnobstructed(AABB*) const; bool mayInteract(Player* player, const TilePos& pos) const; bool mayPlace(TileID tid, const TilePos& pos, bool b) const; + void broadcastEntityEvent(const Entity& entity, Entity::EventType::ID eventId); void removeListener(LevelListener*); void addListener(LevelListener*); void tick(Entity*, bool); void tick(Entity*); - void tick(); + virtual void tick(); void tickPendingTicks(bool b); void tickTiles(); void tickEntities(); @@ -145,7 +153,7 @@ class Level : public LevelSource float getSeenPercent(Vec3, AABB) const; void explode(Entity*, const Vec3& pos, float power); void explode(Entity*, const Vec3& pos, float power, bool bIsFiery); - void addEntities(const std::vector& entities); + void addEntities(const EntityVector& entities); void ensureAdded(Entity* entity); bool extinguishFire(Player* player, const TilePos& pos, Facing::Name face); int findPath(Path* path, Entity* ent1, Entity* ent2, float f) const; @@ -157,7 +165,7 @@ class Level : public LevelSource HitResult clip(const Vec3& a, const Vec3& b) const; HitResult clip(Vec3 a, Vec3 b, bool c) const; - Entity* getEntity(int id) const; + Entity* getEntity(Entity::ID id) const; const EntityVector* getAllEntities() const; EntityVector getEntities(Entity* pAvoid, const AABB&) const; BiomeSource* getBiomeSource() const override; @@ -199,6 +207,7 @@ class Level : public LevelSource Dimension* m_pDimension; int m_difficulty; // @TODO: Difficulty enum Random m_random; + RakNetInstance* m_pRakNetInstance; bool m_bCalculatingInitialSpawn; std::vector m_levelListeners; ChunkSource* m_pChunkSource; diff --git a/source/world/level/LevelEvent.hpp b/source/world/level/LevelEvent.hpp new file mode 100644 index 000000000..735a96ce4 --- /dev/null +++ b/source/world/level/LevelEvent.hpp @@ -0,0 +1,75 @@ +#pragma once + +#include + +class LevelEvent +{ +public: + typedef int16_t ID; + typedef int32_t Data; + // https://minecraft.wiki/w/Bedrock_Edition_protocol/Level_Events + enum Type + { + SOUND_CLICK = 1000, + SOUND_CLICK_FAIL = 1001, + SOUND_SHOOT = 1002, + SOUND_DOOR = 1003, + SOUND_FIZZ = 1004, + SOUND_IGNITE = 1005, + SOUND_GHAST = 1007, + SOUND_GHAST_SHOOT = 1008, + SOUND_BLAZE_SHOOT = 1009, + SOUND_DOOR_BUMP = 1010, + SOUND_DOOR_CRASH = 1012, + SOUND_ENDERMAN_TELEPORT = 1018, + SOUND_ANVIL_BREAK = 1020, + SOUND_ANVIL_USE = 1021, + SOUND_ANVIL_FALL = 1022, + SOUND_POP = 1030, + SOUND_PORTAL = 1032, + SOUND_ITEMFRAME_ADD_ITEM = 1040, + SOUND_ITEMFRAME_REMOVE = 1041, + SOUND_ITEMFRAME_PLACE = 1042, + SOUND_ITEMFRAME_REMOVE_ITEM = 1043, + SOUND_ITEMFRAME_ROTATE_ITEM = 1044, + SOUND_CAMERA = 1050, + SOUND_ORB = 1051, + SOUND_TOTEM = 1052, + SOUND_ARMOR_STAND_BREAK = 1060, + SOUND_ARMOR_STAND_HIT = 1061, + SOUND_ARMOR_STAND_FALL = 1062, + SOUND_ARMOR_STAND_PLACE = 1063, + PARTICLE_SHOOT = 2000, + PARTICLE_DESTROY = 2001, + PARTICLE_SPLASH = 2002, + PARTICLE_EYE_DESPAWN = 2003, + PARTICLE_SPAWN = 2004, + ELDER_GUARDIAN_CURSE = 2006, + PARTICLE_BLOCK_FORCE_FIELD = 2008, + PARTICLE_PROJECTILE_HIT = 2009, + PARTICLE_DRAGON_EGG_TELEPORT = 2010, + PARTICLE_ENDERMAN_TELEPORT = 2013, + PARTICLE_PUNCH_BLOCK = 2014, + START_RAIN = 3001, + START_THUNDER = 3002, + STOP_RAIN = 3003, + STOP_THUNDER = 3004, + PAUSE_GAME = 3005, // Data: 1 to pause, 0 to resume + PAUSE_GAME_NO_SCREEN = 3006, // Data: 1 to pause, 0 to resume - same effect as normal pause but without screen + SET_GAME_SPEED = 3007, // X coordinate of pos = scale factor (default 1.0) + REDSTONE_TRIGGER = 3500, + CAULDRON_EXPLODE = 3501, + CAULDRON_DYE_ARMOR = 3502, + CAULDRON_CLEAN_ARMOR = 3503, + CAULDRON_FILL_POTION = 3504, + CAULDRON_TAKE_POTION = 3505, + CAULDRON_FILL_WATER = 3506, + CAULDRON_TAKE_WATER = 3507, + CAULDRON_ADD_DYE = 3508, + CAULDRON_CLEAN_BANNER = 3509, + BLOCK_START_BREAK = 3600, + BLOCK_STOP_BREAK = 3601, + SET_DATA = 4000, + PLAYERS_SLEEPING = 9800 + }; +}; \ No newline at end of file diff --git a/source/world/level/LevelListener.cpp b/source/world/level/LevelListener.cpp index 0328c67a2..ab5d21f75 100644 --- a/source/world/level/LevelListener.cpp +++ b/source/world/level/LevelListener.cpp @@ -8,67 +8,7 @@ #include "LevelListener.hpp" -void LevelListener::tileChanged(const TilePos& pos) -{ - -} - void LevelListener::tileBrightnessChanged(const TilePos& pos) { tileChanged(pos); } - -void LevelListener::setTilesDirty(const TilePos& min, const TilePos& max) -{ - -} - -void LevelListener::allChanged() -{ - -} - -void LevelListener::playSound(const std::string& name, const Vec3& pos, float volume, float pitch) -{ - -} - -void LevelListener::takePicture(TripodCamera*, Entity*) -{ - -} - -void LevelListener::addParticle(const std::string& a, const Vec3& pos, const Vec3& dir) -{ - -} - -void LevelListener::playMusic(const std::string& a, float b, float c, float d, float e) -{ - -} - -void LevelListener::entityAdded(Entity* a) -{ - -} - -void LevelListener::entityRemoved(Entity* a) -{ - -} - -void LevelListener::skyColorChanged() -{ - -} - -void LevelListener::timeChanged(uint32_t time) -{ - -} - -void LevelListener::playStreamingMusic(const std::string& a, int b, int c, int d) -{ - -} diff --git a/source/world/level/LevelListener.hpp b/source/world/level/LevelListener.hpp index fa15a20e0..b414b0186 100644 --- a/source/world/level/LevelListener.hpp +++ b/source/world/level/LevelListener.hpp @@ -10,23 +10,25 @@ #include #include "world/entity/TripodCamera.hpp" +#include "world/level/LevelEvent.hpp" class LevelListener { public: virtual ~LevelListener() {} - virtual void tileChanged(const TilePos& pos); + virtual void setTilesDirty(const TilePos& min, const TilePos& max) {} + virtual void tileChanged(const TilePos& pos) {} virtual void tileBrightnessChanged(const TilePos& pos); - virtual void setTilesDirty(const TilePos& min, const TilePos& max); - virtual void allChanged(); - virtual void playSound(const std::string&, const Vec3& pos, float, float); - virtual void takePicture(TripodCamera*, Entity*); - virtual void addParticle(const std::string&, const Vec3& pos, const Vec3& dir); - virtual void playMusic(const std::string&, float, float, float, float); - virtual void entityAdded(Entity*); - virtual void entityRemoved(Entity*); - virtual void skyColorChanged(); - virtual void timeChanged(uint32_t time); - virtual void playStreamingMusic(const std::string&, int, int, int); + virtual void skyColorChanged() {} + virtual void allChanged() {} + virtual void takePicture(TripodCamera*, Entity*) {} + virtual void addParticle(const std::string&, const Vec3& pos, const Vec3& dir) {} + virtual void playSound(const std::string&, const Vec3& pos, float, float) {} + virtual void playMusic(const std::string&, float, float, float, float) {} + virtual void playStreamingMusic(const std::string&, int, int, int) {} + virtual void entityAdded(Entity*) {} + virtual void entityRemoved(Entity*) {} + virtual void levelEvent(Player* pPlayer, LevelEvent::ID eventId, const TilePos& pos, LevelEvent::Data data) {} + virtual void timeChanged(uint32_t time) {} }; diff --git a/source/world/level/levelgen/chunk/ChunkPos.hpp b/source/world/level/levelgen/chunk/ChunkPos.hpp index ad7885503..43bc772b8 100644 --- a/source/world/level/levelgen/chunk/ChunkPos.hpp +++ b/source/world/level/levelgen/chunk/ChunkPos.hpp @@ -26,6 +26,11 @@ struct ChunkPos ChunkPos(const Vec3& pos) { _init(pos); } ChunkPos(const TilePos& pos) { _init(pos); } + int lengthSqr() const + { + return x * x + z * z; + } + bool operator<(const ChunkPos& b) const; bool operator>(const ChunkPos& b) const; bool operator<=(const ChunkPos& b) const; diff --git a/source/world/level/storage/ExternalFileLevelStorage.cpp b/source/world/level/storage/ExternalFileLevelStorage.cpp index c8bf11df5..8fa1fb904 100644 --- a/source/world/level/storage/ExternalFileLevelStorage.cpp +++ b/source/world/level/storage/ExternalFileLevelStorage.cpp @@ -373,6 +373,7 @@ void ExternalFileLevelStorage::saveEntities(Level* level, LevelChunk* chunk) RakNet::BitStream bs; RakDataOutput dos = RakDataOutput(bs); NbtIo::write(tag, dos); + tag.deleteChildren(); unsigned int size = bs.GetNumberOfBytesUsed(); diff --git a/source/world/level/storage/LevelData.cpp b/source/world/level/storage/LevelData.cpp index 343717073..60c40e460 100644 --- a/source/world/level/storage/LevelData.cpp +++ b/source/world/level/storage/LevelData.cpp @@ -12,26 +12,31 @@ #define FORCE_SURVIVAL_MODE (TEST_SURVIVAL_MODE || 0) -void LevelData::_init(int32_t seed, int storageVersion) +void LevelData::_init() +{ + _init(LevelSettings()); +} + +void LevelData::_init(const LevelSettings& settings, int storageVersion) { m_levelName = std::string(); - m_seed = seed; + m_seed = settings.m_seed; m_spawnPos = TilePos(128, 64, 128); m_time = 0; m_lastPlayed = 0; m_sizeOnDisk = 0; m_playerTag = nullptr; m_dimensionId = 0; - m_gameType = GAME_TYPE_CREATIVE; + m_gameType = settings.m_gameType; m_storageVersion = storageVersion; m_generatorVersion = 0; // pre-0.2.1 versions used storageVersion instead m_bSpawnMobs = false; m_nPlayers = -1; } -void LevelData::_init(int32_t seed, int storageVersion, const std::string& name) +void LevelData::_init(const LevelSettings& settings, int storageVersion, const std::string& name) { - _init(seed, storageVersion); + _init(settings, storageVersion); m_levelName = name; } diff --git a/source/world/level/storage/LevelData.hpp b/source/world/level/storage/LevelData.hpp index 982fb293f..03ae753b8 100644 --- a/source/world/level/storage/LevelData.hpp +++ b/source/world/level/storage/LevelData.hpp @@ -31,11 +31,24 @@ struct PlayerData void savePlayer(const Player& player); }; +struct LevelSettings +{ + int32_t m_seed; + GameType m_gameType; + + LevelSettings(int32_t seed = 0, GameType gameType = GAME_TYPE_CREATIVE) + { + m_seed = seed; + m_gameType = gameType; + } +}; + struct LevelData { private: - void _init(int32_t seed = 0, int storageVersion = 0); - void _init(int32_t seed, int storageVersion, const std::string& name); + void _init(); + void _init(const LevelSettings& settings, int storageVersion = 0); + void _init(const LevelSettings& settings, int storageVersion, const std::string& name); void _setLastPlayed(int lastPlayed) { m_lastPlayed = lastPlayed; } @@ -45,7 +58,7 @@ struct LevelData int m_nPlayers; LevelData() { _init(); } - LevelData(int32_t seed, const std::string& name, int storageVersion) { _init(seed, storageVersion, name); } + LevelData(const LevelSettings& settings, const std::string& name, int storageVersion) { _init(settings, storageVersion, name); } ~LevelData(); void v1_read(RakNet::BitStream& bs, int storageVersion); diff --git a/source/world/tile/DoorTile.cpp b/source/world/tile/DoorTile.cpp index 50b4f40fb..7d3261042 100644 --- a/source/world/tile/DoorTile.cpp +++ b/source/world/tile/DoorTile.cpp @@ -20,11 +20,11 @@ DoorTile::DoorTile(int ID, Material* pMtl) : Tile(ID, pMtl) Tile::setShape(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); } -int DoorTile::use(Level* level, const TilePos& pos, Player* player) +bool DoorTile::use(Level* level, const TilePos& pos, Player* player) { // well, you know, iron doors can't be opened by right clicking if (m_pMaterial == Material::metal) - return 1; + return true; TileData data = level->getData(pos); @@ -45,16 +45,10 @@ int DoorTile::use(Level* level, const TilePos& pos, Player* player) // @BUG: marking the wrong tiles as dirty? No problem because setData sends an update immediately anyways level->setTilesDirty(pos.below(), pos); - std::string snd; - if (Mth::random() < 0.5f) - snd = "random.door_open"; - else - snd = "random.door_close"; - - level->playSound(Vec3(pos) + 0.5f, snd, 1.0f, 0.9f + 0.1f * level->m_random.nextFloat()); + level->levelEvent(player, LevelEvent::SOUND_DOOR, pos); } - return 1; + return true; } void DoorTile::attack(Level* level, const TilePos& pos, Player* player) diff --git a/source/world/tile/DoorTile.hpp b/source/world/tile/DoorTile.hpp index e9ba18f1d..59aeb9971 100644 --- a/source/world/tile/DoorTile.hpp +++ b/source/world/tile/DoorTile.hpp @@ -16,7 +16,7 @@ class DoorTile : public Tile DoorTile(int ID, Material*); void attack(Level*, const TilePos& pos, Player*) override; - int use(Level*, const TilePos& pos, Player*) override; + bool use(Level*, const TilePos& pos, Player*) override; HitResult clip(const Level*, const TilePos& pos, Vec3, Vec3) override; AABB* getAABB(const Level*, const TilePos& pos) override; int getRenderShape() const override; diff --git a/source/world/tile/RedStoneOreTile.cpp b/source/world/tile/RedStoneOreTile.cpp index c11aff91c..40f12c04e 100644 --- a/source/world/tile/RedStoneOreTile.cpp +++ b/source/world/tile/RedStoneOreTile.cpp @@ -102,7 +102,7 @@ void RedStoneOreTile::attack(Level* level, const TilePos& pos, Player* player) interact(level, pos); } -int RedStoneOreTile::use(Level* level, const TilePos& pos, Player* player) +bool RedStoneOreTile::use(Level* level, const TilePos& pos, Player* player) { interact(level, pos); return Tile::use(level, pos, player); diff --git a/source/world/tile/RedStoneOreTile.hpp b/source/world/tile/RedStoneOreTile.hpp index 0c1f83767..4e7497dff 100644 --- a/source/world/tile/RedStoneOreTile.hpp +++ b/source/world/tile/RedStoneOreTile.hpp @@ -22,7 +22,7 @@ class RedStoneOreTile : public Tile void animateTick(Level*, const TilePos& pos, Random*) override; void tick(Level*, const TilePos& pos, Random*) override; void attack(Level*, const TilePos& pos, Player*) override; - int use(Level*, const TilePos& pos, Player*) override; + bool use(Level*, const TilePos& pos, Player*) override; void stepOn(Level*, const TilePos& pos, Entity*) override; int poofParticles(Level*, const TilePos& pos); diff --git a/source/world/tile/RocketLauncherTile.cpp b/source/world/tile/RocketLauncherTile.cpp index 32ad8f1ad..1cda4b703 100644 --- a/source/world/tile/RocketLauncherTile.cpp +++ b/source/world/tile/RocketLauncherTile.cpp @@ -39,10 +39,10 @@ bool RocketLauncherTile::isSolidRender() const return false; } -int RocketLauncherTile::use(Level* level, const TilePos& pos, Player* player) +bool RocketLauncherTile::use(Level* level, const TilePos& pos, Player* player) { if (level->getData(pos) == 1) - return 1; + return true; level->setData(pos, 1); @@ -52,7 +52,7 @@ int RocketLauncherTile::use(Level* level, const TilePos& pos, Player* player) // add a tick so that the rocket launcher will reset level->addToTickNextTick(pos, m_ID, 10); - return 1; + return true; } void RocketLauncherTile::tick(Level* level, const TilePos& pos, Random* random) diff --git a/source/world/tile/RocketLauncherTile.hpp b/source/world/tile/RocketLauncherTile.hpp index c0efd5de2..1d6232123 100644 --- a/source/world/tile/RocketLauncherTile.hpp +++ b/source/world/tile/RocketLauncherTile.hpp @@ -20,6 +20,6 @@ class RocketLauncherTile : public Tile int getRenderShape() const override; bool isCubeShaped() const override; bool isSolidRender() const override; - int use(Level* pLevel, const TilePos& pos, Player* player) override; + bool use(Level* pLevel, const TilePos& pos, Player* player) override; void tick(Level*, const TilePos& pos, Random*) override; }; diff --git a/source/world/tile/StairTile.cpp b/source/world/tile/StairTile.cpp index 8e4b06078..6fea274e7 100644 --- a/source/world/tile/StairTile.cpp +++ b/source/world/tile/StairTile.cpp @@ -197,7 +197,7 @@ int StairTile::getRenderLayer() const return m_pParent->getRenderLayer(); } -int StairTile::use(Level* level, const TilePos& pos, Player* player) +bool StairTile::use(Level* level, const TilePos& pos, Player* player) { return m_pParent->use(level, pos, player); } diff --git a/source/world/tile/StairTile.hpp b/source/world/tile/StairTile.hpp index 4560839f1..029b265fb 100644 --- a/source/world/tile/StairTile.hpp +++ b/source/world/tile/StairTile.hpp @@ -15,41 +15,41 @@ class StairTile : public Tile public: StairTile(int ID, Tile* pParent); - virtual void addAABBs(const Level*, const TilePos& pos, const AABB*, std::vector&) override; - virtual bool isSolidRender() const override; - virtual bool isCubeShaped() const override; - virtual int getRenderShape() const override; + void addAABBs(const Level*, const TilePos& pos, const AABB*, std::vector&) override; + bool isSolidRender() const override; + bool isCubeShaped() const override; + int getRenderShape() const override; // Just overloads to forward to parent tile. - virtual void addLights(Level*, const TilePos& pos) override; - virtual void animateTick(Level*, const TilePos& pos, Random*) override; - virtual void updateShape(const LevelSource*, const TilePos& pos) override; - virtual float getBrightness(const LevelSource*, const TilePos& pos) const override; - virtual int getTexture(Facing::Name face) const override; - virtual int getTexture(Facing::Name face, TileData data) const override; - virtual int getTexture(const LevelSource*, const TilePos& pos, Facing::Name face) const override; - virtual AABB getTileAABB(const Level*, const TilePos& pos) override; - virtual bool mayPick() const override; - virtual bool mayPick(TileData data, bool) const override; - virtual bool mayPlace(const Level*, const TilePos& pos) const override; - virtual int getTickDelay() const override; - virtual void tick(Level*, const TilePos& pos, Random*) override; - virtual void destroy(Level*, const TilePos& pos, TileData data) override; - virtual void onPlace(Level*, const TilePos& pos) override; - virtual void onRemove(Level*, const TilePos& pos) override; - virtual int getResource(TileData, Random*) const override; - virtual int getResourceCount(Random*) const override; - virtual void spawnResources(Level*, const TilePos& pos, TileData data) override; - virtual void spawnResources(Level*, const TilePos& pos, TileData data, float) override; - virtual float getExplosionResistance(Entity*) const override; - virtual void wasExploded(Level*, const TilePos& pos) override; - virtual int getRenderLayer() const override; - virtual int use(Level*, const TilePos& pos, Player*) override; - virtual void stepOn(Level*, const TilePos& pos, Entity*) override; - virtual void setPlacedBy(Level*, const TilePos& pos, Mob*) override; - virtual void prepareRender(Level*, const TilePos& pos) override; - virtual void attack(Level*, const TilePos& pos, Player*) override; - virtual void handleEntityInside(Level*, const TilePos& pos, const Entity*, Vec3&) override; + void addLights(Level*, const TilePos& pos) override; + void animateTick(Level*, const TilePos& pos, Random*) override; + void updateShape(const LevelSource*, const TilePos& pos) override; + float getBrightness(const LevelSource*, const TilePos& pos) const override; + int getTexture(Facing::Name face) const override; + int getTexture(Facing::Name face, TileData data) const override; + int getTexture(const LevelSource*, const TilePos& pos, Facing::Name face) const override; + AABB getTileAABB(const Level*, const TilePos& pos) override; + bool mayPick() const override; + bool mayPick(TileData data, bool) const override; + bool mayPlace(const Level*, const TilePos& pos) const override; + int getTickDelay() const override; + void tick(Level*, const TilePos& pos, Random*) override; + void destroy(Level*, const TilePos& pos, TileData data) override; + void onPlace(Level*, const TilePos& pos) override; + void onRemove(Level*, const TilePos& pos) override; + int getResource(TileData, Random*) const override; + int getResourceCount(Random*) const override; + void spawnResources(Level*, const TilePos& pos, TileData data) override; + void spawnResources(Level*, const TilePos& pos, TileData data, float) override; + float getExplosionResistance(Entity*) const override; + void wasExploded(Level*, const TilePos& pos) override; + int getRenderLayer() const override; + bool use(Level*, const TilePos& pos, Player*) override; + void stepOn(Level*, const TilePos& pos, Entity*) override; + void setPlacedBy(Level*, const TilePos& pos, Mob*) override; + void prepareRender(Level*, const TilePos& pos) override; + void attack(Level*, const TilePos& pos, Player*) override; + void handleEntityInside(Level*, const TilePos& pos, const Entity*, Vec3&) override; public: Tile* m_pParent; diff --git a/source/world/tile/Tile.cpp b/source/world/tile/Tile.cpp index 7bd1e5249..b88aef8aa 100644 --- a/source/world/tile/Tile.cpp +++ b/source/world/tile/Tile.cpp @@ -1097,9 +1097,9 @@ void Tile::wasExploded(Level* pLevel, const TilePos& pos) } -int Tile::use(Level* pLevel, const TilePos& pos, Player* player) +bool Tile::use(Level* pLevel, const TilePos& pos, Player* player) { - return 0; + return false; } void Tile::stepOn(Level* pLevel, const TilePos& pos, Entity* entity) diff --git a/source/world/tile/Tile.hpp b/source/world/tile/Tile.hpp index d45ee30a9..303e29b3c 100644 --- a/source/world/tile/Tile.hpp +++ b/source/world/tile/Tile.hpp @@ -76,7 +76,7 @@ class Tile virtual HitResult clip(const Level*, const TilePos& pos, Vec3, Vec3); virtual void wasExploded(Level*, const TilePos& pos); virtual int getRenderLayer() const; - virtual int use(Level*, const TilePos& pos, Player*); + virtual bool use(Level*, const TilePos& pos, Player*); virtual void stepOn(Level*, const TilePos& pos, Entity*); virtual void setPlacedOnFace(Level*, const TilePos& pos, Facing::Name face); virtual void setPlacedBy(Level*, const TilePos& pos, Mob*); diff --git a/thirdparty/stb_image/include b/thirdparty/stb_image/include index f7f20f39f..beebb24b9 160000 --- a/thirdparty/stb_image/include +++ b/thirdparty/stb_image/include @@ -1 +1 @@ -Subproject commit f7f20f39fe4f206c6f19e26ebfef7b261ee59ee4 +Subproject commit beebb24b945efdea3b9bba23affb8eb3ba8982e7 From be4dec38c365fc7f2bfc4491fadc14cff264a60b Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Wed, 29 Oct 2025 23:36:05 -0700 Subject: [PATCH 049/293] General Cleanup (#199) * Cleaned up Utils.hpp usage * Cleaned up AppPlatform_win32 --------- Co-authored-by: Brent Da Mage --- platforms/android/AppPlatform_android.cpp | 1 + platforms/android/main.cpp | 1 + platforms/sdl/base/AppPlatform_sdl.cpp | 14 ++- platforms/sdl/base/AppPlatform_sdl.hpp | 1 + platforms/sdl/sdl1/base/AppPlatform_sdl1.cpp | 13 +- platforms/sdl/sdl1/base/AppPlatform_sdl1.hpp | 1 + platforms/sdl/sdl1/main.cpp | 11 -- platforms/sdl/sdl2/base/AppPlatform_sdl2.cpp | 14 ++- platforms/sdl/sdl2/base/AppPlatform_sdl2.hpp | 1 + .../sdl2/desktop/AppPlatform_sdl2_desktop.cpp | 2 - platforms/sdl/sdl2/main.cpp | 21 +--- .../sound/directsound/CustomSoundSystem.hpp | 1 + platforms/sound/directsound/SoundSystemDS.cpp | 12 +- platforms/sound/openal/SoundStreamAL.cpp | 3 +- platforms/sound/openal/SoundStreamAL.hpp | 2 + platforms/sound/openal/SoundSystemAL.cpp | 3 +- platforms/sound/opensl/SoundSystemSL.cpp | 2 +- platforms/windows/AppPlatform_win32.cpp | 113 ++++++++++++++++-- platforms/windows/AppPlatform_win32.hpp | 23 +++- platforms/windows/main.cpp | 22 +--- source/client/app/AppPlatform.cpp | 4 +- source/client/app/AppPlatform.hpp | 20 +++- source/client/app/AssetFile.hpp | 1 + source/client/gui/Gui.cpp | 2 +- source/client/gui/Gui.hpp | 1 - source/client/gui/components/TextInputBox.cpp | 2 + source/client/gui/components/TextInputBox.hpp | 1 - .../gui/components/WorldSelectionList.cpp | 1 - source/client/gui/screens/StartMenuScreen.cpp | 2 +- source/client/model/PolygonQuad.hpp | 1 - .../network/ClientSideNetworkHandler.cpp | 2 +- source/client/options/Options.cpp | 2 +- source/client/player/input/ITurnInput.cpp | 2 +- source/client/player/input/Mouse.cpp | 1 - .../player/input/TouchscreenInput_TestFps.cpp | 1 + .../client/player/input/UnifiedTurnBuild.cpp | 1 - source/client/renderer/Chunk.hpp | 1 - source/client/renderer/DynamicTexture.cpp | 3 +- source/client/renderer/ItemInHandRenderer.cpp | 2 +- source/client/renderer/LevelRenderer.cpp | 4 +- source/client/renderer/PatchManager.cpp | 3 +- source/client/renderer/RenderList.cpp | 1 - source/client/renderer/Tesselator.cpp | 2 +- source/client/renderer/Texture.hpp | 2 +- source/client/renderer/Textures.cpp | 1 - source/client/renderer/Textures.hpp | 4 + source/client/renderer/TileRenderer.cpp | 5 +- .../renderer/entity/FallingTileRenderer.cpp | 2 +- .../renderer/entity/FallingTileRenderer.hpp | 2 +- .../client/renderer/entity/RocketRenderer.cpp | 2 +- .../renderer/entity/TripodCameraRenderer.cpp | 2 +- source/client/sound/SoundData.cpp | 1 + source/client/sound/SoundData.hpp | 2 +- source/client/sound/SoundPathRepository.cpp | 2 +- source/client/sound/SoundRepository.cpp | 2 +- source/client/sound/SoundStream.hpp | 1 + source/common/CThread.cpp | 1 - source/common/Utils.cpp | 112 ++--------------- source/common/Utils.hpp | 70 +---------- source/network/NetEventCallback.cpp | 1 + source/network/RakNetInstance.cpp | 5 +- source/server/ServerSideNetworkHandler.cpp | 3 +- source/world/entity/Cow.cpp | 1 - source/world/entity/Entity.cpp | 7 +- source/world/entity/Entity.hpp | 1 - source/world/entity/EntityFactory.cpp | 1 + source/world/entity/MobCategory.cpp | 1 + source/world/entity/MobFactory.cpp | 1 + source/world/entity/Pig.cpp | 1 - source/world/entity/Player.hpp | 1 - source/world/gamemode/SurvivalMode.cpp | 1 + source/world/item/Inventory.cpp | 6 +- source/world/item/Inventory.hpp | 1 + source/world/item/Item.cpp | 2 + source/world/item/Item.hpp | 6 +- source/world/item/ItemInstance.cpp | 1 + source/world/item/ItemInstance.hpp | 1 - source/world/level/Dimension.cpp | 1 + source/world/level/Level.cpp | 4 +- source/world/level/Material.hpp | 4 +- source/world/level/levelgen/biome/Biome.hpp | 1 - .../level/levelgen/chunk/ChunkSource.hpp | 1 - .../world/level/levelgen/chunk/LevelChunk.cpp | 1 + .../levelgen/chunk/RandomLevelSource.cpp | 3 +- .../levelgen/chunk/RandomLevelSource.hpp | 1 - .../level/levelgen/chunk/TestChunkSource.hpp | 1 - .../level/levelgen/synth/PerlinNoise.cpp | 2 +- .../storage/ExternalFileLevelStorage.cpp | 6 +- .../ExternalFileLevelStorageSource.cpp | 2 +- source/world/level/storage/LevelData.hpp | 1 - source/world/level/storage/LevelSource.hpp | 1 - source/world/tile/Tile.cpp | 1 + thirdparty/GL/GLExt.cpp | 13 +- thirdparty/stb_image/include | 2 +- 94 files changed, 302 insertions(+), 316 deletions(-) diff --git a/platforms/android/AppPlatform_android.cpp b/platforms/android/AppPlatform_android.cpp index d8de4b86b..2d0ce402f 100644 --- a/platforms/android/AppPlatform_android.cpp +++ b/platforms/android/AppPlatform_android.cpp @@ -10,6 +10,7 @@ #include "AppPlatform_android.hpp" #include "CustomSoundSystem.hpp" +#include "common/Logger.hpp" #include "client/player/input/Mouse.hpp" #include "stb_image.h" diff --git a/platforms/android/main.cpp b/platforms/android/main.cpp index 5088a22f4..031fcea81 100644 --- a/platforms/android/main.cpp +++ b/platforms/android/main.cpp @@ -16,6 +16,7 @@ #include #include +#include "common/Logger.hpp" #include "compat/KeyCodes.hpp" #include "thirdparty/GL/GL.hpp" #include "platforms/android/AppPlatform_android.hpp" diff --git a/platforms/sdl/base/AppPlatform_sdl.cpp b/platforms/sdl/base/AppPlatform_sdl.cpp index e075709da..6167e2436 100644 --- a/platforms/sdl/base/AppPlatform_sdl.cpp +++ b/platforms/sdl/base/AppPlatform_sdl.cpp @@ -16,6 +16,7 @@ #include "AppPlatform_sdl.hpp" #include "common/Utils.hpp" +#include "compat/KeyCodes.hpp" #include "CustomSoundSystem.hpp" // Macros are cursed @@ -28,6 +29,8 @@ void AppPlatform_sdl::_init(std::string storageDir) { m_storageDir = storageDir; + m_hWND = _getHWND(); + m_pIconTexture = nullptr; m_pIcon = nullptr; @@ -140,15 +143,14 @@ void AppPlatform_sdl::_setDefaultIcon() void AppPlatform_sdl::initSoundSystem() { - if (!m_pSoundSystem) - { - LOG_I("Initializing " STR(SOUND_SYSTEM) "..."); - m_pSoundSystem = new SOUND_SYSTEM(); - } - else + if (m_pSoundSystem) { LOG_E("Trying to initialize SoundSystem more than once!"); + return; } + + LOG_I("Initializing " STR(SOUND_SYSTEM) "..."); + m_pSoundSystem = new SOUND_SYSTEM(); } int AppPlatform_sdl::checkLicense() diff --git a/platforms/sdl/base/AppPlatform_sdl.hpp b/platforms/sdl/base/AppPlatform_sdl.hpp index 032aced10..88a606894 100644 --- a/platforms/sdl/base/AppPlatform_sdl.hpp +++ b/platforms/sdl/base/AppPlatform_sdl.hpp @@ -24,6 +24,7 @@ class AppPlatform_sdl : public AppPlatform virtual void _setMouseGrabbed(bool b) {} virtual void _handleKeyEvent(int key, uint8_t state); virtual void _ensureDirectoryExists(const char* path); // desktop only + virtual void* _getHWND() const { return nullptr; } void _setIcon(const Texture& icon); // note: this takes ownership of the texture, so no memory leaks! void _setDefaultIcon(); diff --git a/platforms/sdl/sdl1/base/AppPlatform_sdl1.cpp b/platforms/sdl/sdl1/base/AppPlatform_sdl1.cpp index 27eea2fcb..226d33b9c 100644 --- a/platforms/sdl/sdl1/base/AppPlatform_sdl1.cpp +++ b/platforms/sdl/sdl1/base/AppPlatform_sdl1.cpp @@ -3,7 +3,6 @@ #include "thirdparty/SDL/SDL_gamecontroller.h" #include "thirdparty/GL/GL.hpp" -#include "common/Utils.hpp" #include "CustomSoundSystem.hpp" #include "client/player/input/Controller.hpp" @@ -42,6 +41,18 @@ void AppPlatform_sdl1::_setMouseGrabbed(bool b) SDL_ShowCursor(b ? SDL_FALSE : SDL_TRUE); } +void* AppPlatform_sdl1::_getHWND() const +{ +#ifdef _WIN32 + SDL_SysWMinfo wmInfo; + SDL_VERSION(&wmInfo.version); + SDL_GetWMInfo(&wmInfo); + return wmInfo.window; +#else + return AppPlatform_sdl::_getHWND(); +#endif +} + const char* AppPlatform_sdl1::getWindowTitle() const { char* title; diff --git a/platforms/sdl/sdl1/base/AppPlatform_sdl1.hpp b/platforms/sdl/sdl1/base/AppPlatform_sdl1.hpp index 4302fc332..68ccbe547 100644 --- a/platforms/sdl/sdl1/base/AppPlatform_sdl1.hpp +++ b/platforms/sdl/sdl1/base/AppPlatform_sdl1.hpp @@ -29,6 +29,7 @@ class AppPlatform_sdl1 : public AppPlatform_sdl protected: void _updateWindowIcon() override; void _setMouseGrabbed(bool b) override; + void* _getHWND() const override; public: const char* getWindowTitle() const override; diff --git a/platforms/sdl/sdl1/main.cpp b/platforms/sdl/sdl1/main.cpp index d171b23eb..5946c179e 100644 --- a/platforms/sdl/sdl1/main.cpp +++ b/platforms/sdl/sdl1/main.cpp @@ -29,17 +29,6 @@ static void teardown() } } -// DirectSound Support -#ifdef _WIN32 -HWND GetHWND() -{ - SDL_SysWMinfo wmInfo; - SDL_VERSION(&wmInfo.version); - SDL_GetWMInfo(&wmInfo); - return wmInfo.window; -} -#endif - // Handle Events static bool window_resized = false; static void handle_events() diff --git a/platforms/sdl/sdl2/base/AppPlatform_sdl2.cpp b/platforms/sdl/sdl2/base/AppPlatform_sdl2.cpp index 9697ce2a2..57597a3d3 100644 --- a/platforms/sdl/sdl2/base/AppPlatform_sdl2.cpp +++ b/platforms/sdl/sdl2/base/AppPlatform_sdl2.cpp @@ -11,7 +11,7 @@ #include "thirdparty/GL/GL.hpp" #endif -#include "common/Utils.hpp" +#include "compat/KeyCodes.hpp" #include "CustomSoundSystem.hpp" // Macros are cursed @@ -76,6 +76,18 @@ void AppPlatform_sdl2::_handleKeyEvent(int key, uint8_t state) return AppPlatform_sdl::_handleKeyEvent(key, state); } +void* AppPlatform_sdl2::_getHWND() const +{ +#ifdef _WIN32 + SDL_SysWMinfo wmInfo; + SDL_VERSION(&wmInfo.version); + SDL_GetWindowWMInfo(m_pWindow, &wmInfo); + return wmInfo.info.win.window; +#else + return AppPlatform_sdl::_getHWND(); +#endif +} + const char* AppPlatform_sdl2::getWindowTitle() const { return SDL_GetWindowTitle(m_pWindow); diff --git a/platforms/sdl/sdl2/base/AppPlatform_sdl2.hpp b/platforms/sdl/sdl2/base/AppPlatform_sdl2.hpp index 6e97f3c28..92ca56559 100644 --- a/platforms/sdl/sdl2/base/AppPlatform_sdl2.hpp +++ b/platforms/sdl/sdl2/base/AppPlatform_sdl2.hpp @@ -22,6 +22,7 @@ class AppPlatform_sdl2 : public AppPlatform_sdl void _updateWindowIcon() override; void _setMouseGrabbed(bool b) override; void _handleKeyEvent(int key, uint8_t state) override; + void* _getHWND() const override; public: const char* getWindowTitle() const override; diff --git a/platforms/sdl/sdl2/desktop/AppPlatform_sdl2_desktop.cpp b/platforms/sdl/sdl2/desktop/AppPlatform_sdl2_desktop.cpp index 350cbe4eb..661d89abd 100644 --- a/platforms/sdl/sdl2/desktop/AppPlatform_sdl2_desktop.cpp +++ b/platforms/sdl/sdl2/desktop/AppPlatform_sdl2_desktop.cpp @@ -1,7 +1,5 @@ #include "AppPlatform_sdl2_desktop.hpp" -#include "common/Utils.hpp" - AppPlatform_sdl2_desktop::AppPlatform_sdl2_desktop(std::string storageDir, SDL_Window *window) : AppPlatform_sdl2(storageDir, window) { diff --git a/platforms/sdl/sdl2/main.cpp b/platforms/sdl/sdl2/main.cpp index 6107b1636..05c6b89c0 100644 --- a/platforms/sdl/sdl2/main.cpp +++ b/platforms/sdl/sdl2/main.cpp @@ -105,17 +105,6 @@ extern "C" void resize_from_js(int new_width, int new_height) } #endif -// DirectSound Support -#ifdef _WIN32 -HWND GetHWND() -{ - SDL_SysWMinfo wmInfo; - SDL_VERSION(&wmInfo.version); - SDL_GetWindowWMInfo(window, &wmInfo); - return wmInfo.info.win.window; -} -#endif - // Handle Events static bool window_resized = false; static void handle_events() @@ -314,7 +303,7 @@ int main(int argc, char *argv[]) // Setup SDL if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER) < 0) { - //LOG_E("Unable To Initialize SDL: %s", SDL_GetError()); + LOG_E("Unable To Initialize SDL: %s", SDL_GetError()); exit(EXIT_FAILURE); } @@ -353,7 +342,7 @@ int main(int argc, char *argv[]) if (!context) { const char* const GL_ERROR_MSG = "Unable to create OpenGL context"; - //LOG_E(GL_ERROR_MSG); + LOG_E(GL_ERROR_MSG); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "OpenGL Error", GL_ERROR_MSG, window); exit(EXIT_FAILURE); } @@ -362,11 +351,11 @@ int main(int argc, char *argv[]) // Not setting this explicitly results in undefined behavior if (SDL_GL_SetSwapInterval(-1) == -1) // Try adaptive { - //LOG_W("Adaptive V-Sync is not supported on this platform. Falling back to standard V-Sync..."); + LOG_W("Adaptive V-Sync is not supported on this platform. Falling back to standard V-Sync..."); // fallback to standard if (SDL_GL_SetSwapInterval(1) == -1) { - //LOG_W("Setting the swap interval for V-Sync is not supported on this platform!"); + LOG_W("Setting the swap interval for V-Sync is not supported on this platform!"); } } @@ -376,7 +365,7 @@ int main(int argc, char *argv[]) if (!xglInitted()) { const char* const GL_ERROR_MSG = "Error initializing GL extensions. OpenGL 2.0 or later is required. Update your graphics drivers!"; - //LOG_E(GL_ERROR_MSG); + LOG_E(GL_ERROR_MSG); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "OpenGL Error", GL_ERROR_MSG, window); exit(EXIT_FAILURE); } diff --git a/platforms/sound/directsound/CustomSoundSystem.hpp b/platforms/sound/directsound/CustomSoundSystem.hpp index bac276636..5efc39859 100644 --- a/platforms/sound/directsound/CustomSoundSystem.hpp +++ b/platforms/sound/directsound/CustomSoundSystem.hpp @@ -44,6 +44,7 @@ class SoundSystemDS : public SoundSystem }; bool m_available; + HWND m_hWnd; IDirectSound* m_directsound; LPDIRECTSOUND3DLISTENER m_listener; std::vector m_buffers; diff --git a/platforms/sound/directsound/SoundSystemDS.cpp b/platforms/sound/directsound/SoundSystemDS.cpp index 26827c138..ed8215d13 100644 --- a/platforms/sound/directsound/SoundSystemDS.cpp +++ b/platforms/sound/directsound/SoundSystemDS.cpp @@ -8,18 +8,18 @@ #define WIN32_LEAN_AND_MEAN #include "CustomSoundSystem.hpp" -#include "common/Utils.hpp" +#include "common/Logger.hpp" +#include "client/app/AppPlatform.hpp" // @TODO: fix crash in playAt when Asan is active SoundSystemDS::SoundSystemDS() { - LOG_I("Init SoundSystemDS"); + m_available = false; + m_hWnd = (HWND)AppPlatform::singleton()->m_hWND; HRESULT result; DSBUFFERDESC bufferDesc; - m_available = false; - result = DirectSoundCreate(NULL, &m_directsound, NULL); if (FAILED(result)) @@ -28,7 +28,7 @@ SoundSystemDS::SoundSystemDS() return; } - result = m_directsound->SetCooperativeLevel(GetHWND(), DSSCL_NORMAL); + result = m_directsound->SetCooperativeLevel(m_hWnd, DSSCL_NORMAL); if (FAILED(result)) { LOG_E("SoundSystemDS failed set cooperation level"); @@ -63,8 +63,6 @@ SoundSystemDS::SoundSystemDS() m_available = true; } - - SoundSystemDS::~SoundSystemDS() { LOG_I("Destroying SoundSystemDS"); diff --git a/platforms/sound/openal/SoundStreamAL.cpp b/platforms/sound/openal/SoundStreamAL.cpp index d0a35d84a..778f8085c 100644 --- a/platforms/sound/openal/SoundStreamAL.cpp +++ b/platforms/sound/openal/SoundStreamAL.cpp @@ -1,5 +1,6 @@ -#include "SoundStreamAL.hpp" #include + +#include "SoundStreamAL.hpp" #include "common/Logger.hpp" SoundStreamAL::SoundStreamAL() diff --git a/platforms/sound/openal/SoundStreamAL.hpp b/platforms/sound/openal/SoundStreamAL.hpp index 826c5e7e7..d407cded2 100644 --- a/platforms/sound/openal/SoundStreamAL.hpp +++ b/platforms/sound/openal/SoundStreamAL.hpp @@ -6,6 +6,8 @@ #include "thirdparty/OpenAL.h" +#include "compat/LegacyCPP.hpp" + #include "client/sound/SoundStream.hpp" class SoundStreamAL : public SoundStream diff --git a/platforms/sound/openal/SoundSystemAL.cpp b/platforms/sound/openal/SoundSystemAL.cpp index 56e134bf6..c9cdb5ec2 100644 --- a/platforms/sound/openal/SoundSystemAL.cpp +++ b/platforms/sound/openal/SoundSystemAL.cpp @@ -1,6 +1,7 @@ #include "CustomSoundSystem.hpp" -#include "common/Utils.hpp" +#include "thirdparty/OpenAL.h" +#include "common/Logger.hpp" #include "SoundStreamAL.hpp" diff --git a/platforms/sound/opensl/SoundSystemSL.cpp b/platforms/sound/opensl/SoundSystemSL.cpp index bc3deaecc..ac0451b1d 100644 --- a/platforms/sound/opensl/SoundSystemSL.cpp +++ b/platforms/sound/opensl/SoundSystemSL.cpp @@ -6,7 +6,7 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ #include "CustomSoundSystem.hpp" -#include "common/Utils.hpp" +#include "common/Logger.hpp" #define C_MAX_SOUNDS 4 diff --git a/platforms/windows/AppPlatform_win32.cpp b/platforms/windows/AppPlatform_win32.cpp index 1ce44ea7e..fe45c92a5 100644 --- a/platforms/windows/AppPlatform_win32.cpp +++ b/platforms/windows/AppPlatform_win32.cpp @@ -11,22 +11,33 @@ #include #include -#include "GameMods.hpp" - #include "AppPlatform_win32.hpp" +#include "GameMods.hpp" +#include "common/Logger.hpp" + #include "thirdparty/GL/GL.hpp" #include "thirdparty/stb_image/include/stb_image.h" #include "thirdparty/stb_image/include/stb_image_write.h" +// Macros are cursed +#define _STR(x) #x +#define STR(x) _STR(x) + AppPlatform_win32::AppPlatform_win32() { + m_cursor = NULL; + + m_hDC = NULL; + m_hRC = NULL; + m_WindowTitle = "ReMinecraftPE"; // just assume an 854x480 window for now: m_ScreenWidth = C_DEFAULT_SCREEN_WIDTH; m_ScreenHeight = C_DEFAULT_SCREEN_HEIGHT; m_UserInputStatus = -1; + m_DialogType = DLG_NONE; m_bIsFocused = false; m_bGrabbedMouse = false; @@ -46,10 +57,14 @@ AppPlatform_win32::~AppPlatform_win32() void AppPlatform_win32::initSoundSystem() { - if (!m_pSoundSystem) - m_pSoundSystem = new SOUND_SYSTEM(); - else + if (m_pSoundSystem) + { LOG_E("Trying to initialize SoundSystem more than once!"); + return; + } + + LOG_I("Initializing " STR(SOUND_SYSTEM) "..."); + m_pSoundSystem = new SOUND_SYSTEM(); } int AppPlatform_win32::checkLicense() @@ -60,7 +75,7 @@ int AppPlatform_win32::checkLicense() void AppPlatform_win32::buyGame() { - MessageBoxA(GetHWND(), "Buying the game!", getWindowTitle(), MB_OK | MB_ICONINFORMATION); + MessageBoxA(_getHWND(), "Buying the game!", getWindowTitle(), MB_OK | MB_ICONINFORMATION); } void AppPlatform_win32::saveScreenshot(const std::string& fileName, int width, int height) @@ -163,7 +178,7 @@ Texture AppPlatform_win32::loadTexture(const std::string& str, bool bIsRequired) return Texture(0, 0, nullptr, 1, 0); const std::string msg = "Error loading " + realPath + ". Did you unzip the Minecraft assets?\n\nNote, you will be warned for every missing texture."; - MessageBoxA(GetHWND(), msg.c_str(), getWindowTitle(), MB_OK | MB_ICONERROR); + MessageBoxA(_getHWND(), msg.c_str(), getWindowTitle(), MB_OK | MB_ICONERROR); if (f) fclose(f); @@ -236,7 +251,7 @@ void AppPlatform_win32::recenterMouse() return; // If we aren't the foreground window, return - if (GetForegroundWindow() != GetHWND()) + if (GetForegroundWindow() != _getHWND()) { m_bWasUnfocused = true; return; @@ -247,10 +262,10 @@ void AppPlatform_win32::recenterMouse() /* We're doing this for FUN??? RECT rect; - GetClientRect(GetHWND(), &rect);*/ + GetClientRect(_getHWND(), &rect);*/ POINT offs = { getScreenWidth() / 2, getScreenHeight() / 2 }; - ClientToScreen(GetHWND(), &offs); + ClientToScreen(_getHWND(), &offs); SetCursorPos(offs.x, offs.y); @@ -299,10 +314,10 @@ void AppPlatform_win32::setMouseGrabbed(bool b) //confine it to our client area RECT rect; - GetClientRect(GetHWND(), &rect); + GetClientRect(_getHWND(), &rect); POINT offs = { 0, 0 }; - ClientToScreen(GetHWND(), &offs); + ClientToScreen(_getHWND(), &offs); rect.left += offs.x; rect.top += offs.y; rect.right += offs.x; @@ -334,6 +349,80 @@ void AppPlatform_win32::updateFocused(bool focused) setMouseGrabbed(m_bGrabbedMouse); } +void AppPlatform_win32::initializeWindow(HWND hWnd, int nCmdShow) +{ + m_hWND = hWnd; + + centerWindow(); + ShowWindow(hWnd, nCmdShow); + + // enable OpenGL for the window + enableOpenGL(hWnd); +} + +void AppPlatform_win32::destroyWindow(HWND hWnd) +{ + DestroyWindow(hWnd); +} + +void AppPlatform_win32::centerWindow(HWND hWnd) +{ + RECT r, desk; + GetWindowRect(hWnd, &r); + GetWindowRect(GetDesktopWindow(), &desk); + + int wa, ha, wb, hb; + + wa = (r.right - r.left) / 2; + ha = (r.bottom - r.top) / 2; + + wb = (desk.right - desk.left) / 2; + hb = (desk.bottom - desk.top) / 2; + + SetWindowPos(hWnd, NULL, wb - wa, hb - ha, r.right - r.left, r.bottom - r.top, 0); +} + +void AppPlatform_win32::enableOpenGL(HWND hWnd) +{ + PIXELFORMATDESCRIPTOR pfd; + int iFormat; + + /* get the device context (DC) */ + m_hDC = GetDC(hWnd); + + /* set the pixel format for the DC */ + ZeroMemory(&pfd, sizeof(pfd)); + + pfd.nSize = sizeof(pfd); + pfd.nVersion = 1; + pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; + pfd.iPixelType = PFD_TYPE_RGBA; + pfd.cColorBits = 24; + pfd.cDepthBits = 8; + pfd.iLayerType = PFD_MAIN_PLANE; + + iFormat = ChoosePixelFormat(m_hDC, &pfd); + + SetPixelFormat(m_hDC, iFormat, &pfd); + + /* create and enable the render context (RC) */ + m_hRC = wglCreateContext(m_hDC); + + wglMakeCurrent(m_hDC, m_hRC); +} + +void AppPlatform_win32::disableOpenGL(HWND hWnd) +{ + wglMakeCurrent(NULL, NULL); + wglDeleteContext(m_hRC); + ReleaseDC(hWnd, m_hDC); +} + +void AppPlatform_win32::swapBuffers() +{ + SwapBuffers(m_hDC); +} + MouseButtonType AppPlatform_win32::GetMouseButtonType(UINT iMsg) { switch (iMsg) diff --git a/platforms/windows/AppPlatform_win32.hpp b/platforms/windows/AppPlatform_win32.hpp index bc681df00..45a976607 100644 --- a/platforms/windows/AppPlatform_win32.hpp +++ b/platforms/windows/AppPlatform_win32.hpp @@ -13,7 +13,6 @@ #include "client/player/input/Mouse.hpp" #include "client/player/input/Keyboard.hpp" -#include "common/Utils.hpp" #include "LoggerWin32.hpp" #include "CustomSoundSystem.hpp" @@ -23,6 +22,10 @@ class AppPlatform_win32 : public AppPlatform AppPlatform_win32(); ~AppPlatform_win32(); +protected: + HWND _getHWND() const { return (HWND)m_hWND; } + +public: void initSoundSystem() override; void buyGame() override; @@ -61,18 +64,34 @@ class AppPlatform_win32 : public AppPlatform const char* const getWindowTitle() const { return m_WindowTitle; } SoundSystem* const getSoundSystem() const override { return m_pSoundSystem; } + void initializeWindow(HWND hWnd, int nCmdShow); + void destroyWindow(HWND hWnd); + void centerWindow(HWND hWnd); + void enableOpenGL(HWND hWnd); + void disableOpenGL(HWND hWnd); + void destroyWindow() { destroyWindow(_getHWND()); } + void centerWindow() { centerWindow(_getHWND()); } + void enableOpenGL() { enableOpenGL(_getHWND()); } + void disableOpenGL() { disableOpenGL(_getHWND()); } + void swapBuffers(); + static MouseButtonType GetMouseButtonType(UINT iMsg); static bool GetMouseButtonState(UINT iMsg, WPARAM wParam); static Keyboard::KeyState GetKeyState(UINT iMsg); private: + HICON m_cursor; + + // OpenGL + HDC m_hDC; // device context + HGLRC m_hRC; // render context + const char* m_WindowTitle; int m_ScreenWidth; int m_ScreenHeight; std::vector m_UserInput; int m_UserInputStatus; - eDialogType m_DialogType; bool m_bIsFocused; diff --git a/platforms/windows/main.cpp b/platforms/windows/main.cpp index dc1b5b009..cb888d322 100644 --- a/platforms/windows/main.cpp +++ b/platforms/windows/main.cpp @@ -11,6 +11,7 @@ #include "thirdparty/GL/GL.hpp" #include "compat/KeyCodes.hpp" +#include "GameMods.hpp" #include "client/app/App.hpp" #include "client/app/NinecraftApp.hpp" @@ -127,8 +128,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine SetConsoleTitle("ReMinecraftPE Debug Console"); #endif - SetInstance(hInstance); - // This initializes the Logger singleton to use the Windows-specific variant // If we didn't initialize it here, the Minecraft class would have our back Logger::setSingleton(new LoggerWin32); @@ -164,13 +163,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine HWND hWnd = CreateWindowEx(0, g_WindowClassName, windowTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, w, h, NULL, NULL, hInstance, g_pApp); - CenterWindow(hWnd); - ShowWindow(hWnd, nCmdShow); - SetHWND(hWnd); - - HDC hDC; HGLRC hRC; - // enable OpenGL for the window - EnableOpenGL(hWnd, &hDC, &hRC); + g_AppPlatform.initializeWindow(hWnd, nCmdShow); xglInit(); @@ -178,7 +171,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine { const char* const GL_ERROR_MSG = "Error initializing GL extensions. OpenGL 2.0 or later is required. Update your graphics drivers!"; LOG_E(GL_ERROR_MSG); - MessageBoxA(GetHWND(), GL_ERROR_MSG, "OpenGL Error", MB_OK); + MessageBoxA(hWnd, GL_ERROR_MSG, "OpenGL Error", MB_OK); goto _cleanup; } @@ -214,7 +207,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine g_pApp->update(); // note: NinecraftApp would have done this with eglSwapBuffers, but I'd rather do it here: - SwapBuffers(hDC); + g_AppPlatform.swapBuffers(); } } @@ -222,13 +215,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine g_pApp->saveOptions(); // disable OpenGL for the window - DisableOpenGL(hWnd, hDC, hRC); + g_AppPlatform.disableOpenGL(); // destroy the window explicitly, since we ignored the WM_QUIT message - DestroyWindow(hWnd); - - hWnd = NULL; - SetHWND(NULL); + g_AppPlatform.destroyWindow(); delete g_pApp; diff --git a/source/client/app/AppPlatform.cpp b/source/client/app/AppPlatform.cpp index 468ae6942..9931b3020 100644 --- a/source/client/app/AppPlatform.cpp +++ b/source/client/app/AppPlatform.cpp @@ -9,7 +9,8 @@ #include #include "AppPlatform.hpp" -#include "common/Utils.hpp" +#include "common/Logger.hpp" +#include "compat/LegacyCPP.hpp" AppPlatform* AppPlatform::m_singleton = nullptr; @@ -21,6 +22,7 @@ AppPlatform* const AppPlatform::singleton() AppPlatform::AppPlatform() { m_singleton = this; + m_hWND = nullptr; } AppPlatform::~AppPlatform() diff --git a/source/client/app/AppPlatform.hpp b/source/client/app/AppPlatform.hpp index a7f1be254..78fc702dc 100644 --- a/source/client/app/AppPlatform.hpp +++ b/source/client/app/AppPlatform.hpp @@ -15,12 +15,26 @@ #include "client/sound/SoundSystem.hpp" #include "AssetFile.hpp" +#include "GameMods.hpp" + +#ifndef MOD_USE_BIGGER_SCREEN_SIZE +#define C_DEFAULT_SCREEN_WIDTH (854) +#define C_DEFAULT_SCREEN_HEIGHT (480) +#elif defined(__DREAMCAST__) +#define C_DEFAULT_SCREEN_WIDTH (800) +#define C_DEFAULT_SCREEN_HEIGHT (600) +#else +#define C_DEFAULT_SCREEN_WIDTH (1280) +#define C_DEFAULT_SCREEN_HEIGHT (720) +#endif + class AppPlatform { public: enum eDialogType { - DLG_CREATE_WORLD = 1, + DLG_NONE, + DLG_CREATE_WORLD, DLG_CHAT, DLG_OPTIONS, DLG_RENAME_MP_WORLD, @@ -99,5 +113,9 @@ class AppPlatform virtual std::string getAssetPath(const std::string& path) const; virtual AssetFile readAssetFile(const std::string&, bool) const; #endif + +public: + //std::multimap m_listeners; + void* m_hWND; // the Mojang solution }; diff --git a/source/client/app/AssetFile.hpp b/source/client/app/AssetFile.hpp index b0f2c0316..cb5a078c1 100644 --- a/source/client/app/AssetFile.hpp +++ b/source/client/app/AssetFile.hpp @@ -9,6 +9,7 @@ Minecraft: Pocket Edition - Decompilation Project #pragma once #include +#include "compat/LegacyCPP.hpp" struct AssetFile { int64_t size; diff --git a/source/client/gui/Gui.cpp b/source/client/gui/Gui.cpp index 9225a9781..4adce15a3 100644 --- a/source/client/gui/Gui.cpp +++ b/source/client/gui/Gui.cpp @@ -367,7 +367,7 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY) } } - textures->loadAndBindTexture("gui/gui_blocks.png"); + textures->loadAndBindTexture(C_BLOCKS_NAME); int diff = mc->isTouchscreen(); diff --git a/source/client/gui/Gui.hpp b/source/client/gui/Gui.hpp index 98e1cf925..76ebfdb73 100644 --- a/source/client/gui/Gui.hpp +++ b/source/client/gui/Gui.hpp @@ -12,7 +12,6 @@ #include "client/player/input/RectangleArea.hpp" #include "client/app/Minecraft.hpp" #include "common/Random.hpp" -#include "common/Utils.hpp" class Minecraft; // in case we're included from Minecraft.hpp diff --git a/source/client/gui/components/TextInputBox.cpp b/source/client/gui/components/TextInputBox.cpp index d078de7de..a6d83ee71 100644 --- a/source/client/gui/components/TextInputBox.cpp +++ b/source/client/gui/components/TextInputBox.cpp @@ -7,6 +7,8 @@ ********************************************************************/ #include "TextInputBox.hpp" +#include "common/Logger.hpp" +#include "compat/KeyCodes.hpp" #include "client/app/Minecraft.hpp" #ifndef ORIGINAL_CODE diff --git a/source/client/gui/components/TextInputBox.hpp b/source/client/gui/components/TextInputBox.hpp index 0732fcaa5..7c184bec4 100644 --- a/source/client/gui/components/TextInputBox.hpp +++ b/source/client/gui/components/TextInputBox.hpp @@ -10,7 +10,6 @@ #include "../GuiComponent.hpp" #include "../Screen.hpp" -#include "common/Utils.hpp" class Screen; class Minecraft; diff --git a/source/client/gui/components/WorldSelectionList.cpp b/source/client/gui/components/WorldSelectionList.cpp index 4c13dff90..b83783c6e 100644 --- a/source/client/gui/components/WorldSelectionList.cpp +++ b/source/client/gui/components/WorldSelectionList.cpp @@ -7,7 +7,6 @@ ********************************************************************/ #include "WorldSelectionList.hpp" -#include "common/Utils.hpp" static float WorldSelectionList_Static1(float a, float b, float c, float d) { diff --git a/source/client/gui/screens/StartMenuScreen.cpp b/source/client/gui/screens/StartMenuScreen.cpp index 23d347246..56f3bc627 100644 --- a/source/client/gui/screens/StartMenuScreen.cpp +++ b/source/client/gui/screens/StartMenuScreen.cpp @@ -649,7 +649,7 @@ void StartMenuScreen::draw3dTitle(float f) glScalef(0.89f, 1.0f, 0.4f); glTranslatef(-Width * 0.5f, -Height * 0.5f, 0.0f); - m_pMinecraft->m_pTextures->loadAndBindTexture("terrain.png"); + m_pMinecraft->m_pTextures->loadAndBindTexture(C_TERRAIN_NAME); if (i == 0) { m_pMinecraft->m_pTextures->loadAndBindTexture("gui/black.png"); } diff --git a/source/client/model/PolygonQuad.hpp b/source/client/model/PolygonQuad.hpp index 6a23dd309..e6ef4e88f 100644 --- a/source/client/model/PolygonQuad.hpp +++ b/source/client/model/PolygonQuad.hpp @@ -9,7 +9,6 @@ #pragma once #include -#include "common/Utils.hpp" #include "client/renderer/VertexPT.hpp" #include "client/renderer/Tesselator.hpp" #include "GameMods.hpp" diff --git a/source/client/network/ClientSideNetworkHandler.cpp b/source/client/network/ClientSideNetworkHandler.cpp index d036a1725..96d056301 100644 --- a/source/client/network/ClientSideNetworkHandler.cpp +++ b/source/client/network/ClientSideNetworkHandler.cpp @@ -8,7 +8,7 @@ #include #include "ClientSideNetworkHandler.hpp" -#include "common/Utils.hpp" +#include "common/Logger.hpp" #include "client/gui/screens/StartMenuScreen.hpp" #include "client/gui/screens/DisconnectionScreen.hpp" #include "client/multiplayer/MultiPlayerLevel.hpp" diff --git a/source/client/options/Options.cpp b/source/client/options/Options.cpp index d80a5deea..764e02f39 100644 --- a/source/client/options/Options.cpp +++ b/source/client/options/Options.cpp @@ -12,7 +12,7 @@ #include "thirdparty/SDL/SDL_gamecontroller.h" #include "Options.hpp" -#include "common/Util.hpp" +#include "common/Logger.hpp" #include "compat/KeyCodes.hpp" #include "client/app/Minecraft.hpp" diff --git a/source/client/player/input/ITurnInput.cpp b/source/client/player/input/ITurnInput.cpp index dbe0d1c6b..5ffeb4baa 100644 --- a/source/client/player/input/ITurnInput.cpp +++ b/source/client/player/input/ITurnInput.cpp @@ -6,8 +6,8 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ -#include "common/Utils.hpp" #include "ITurnInput.hpp" +#include "common/Utils.hpp" ITurnInput::~ITurnInput() { diff --git a/source/client/player/input/Mouse.cpp b/source/client/player/input/Mouse.cpp index 0146cd16e..b063608ff 100644 --- a/source/client/player/input/Mouse.cpp +++ b/source/client/player/input/Mouse.cpp @@ -7,7 +7,6 @@ ********************************************************************/ #include "Mouse.hpp" -#include "common/Utils.hpp" MouseDevice Mouse::_instance; diff --git a/source/client/player/input/TouchscreenInput_TestFps.cpp b/source/client/player/input/TouchscreenInput_TestFps.cpp index d20f07e46..5021c92a3 100644 --- a/source/client/player/input/TouchscreenInput_TestFps.cpp +++ b/source/client/player/input/TouchscreenInput_TestFps.cpp @@ -8,6 +8,7 @@ #include "TouchscreenInput_TestFps.hpp" #include "Multitouch.hpp" +#include "GameMods.hpp" #include "client/app/Minecraft.hpp" #include "client/options/Options.hpp" #include "world/entity/Player.hpp" diff --git a/source/client/player/input/UnifiedTurnBuild.cpp b/source/client/player/input/UnifiedTurnBuild.cpp index e3c64d287..afb8a7e57 100644 --- a/source/client/player/input/UnifiedTurnBuild.cpp +++ b/source/client/player/input/UnifiedTurnBuild.cpp @@ -9,7 +9,6 @@ #include "UnifiedTurnBuild.hpp" #include "Multitouch.hpp" -#include "common/Utils.hpp" #include "world/entity/Player.hpp" UnifiedTurnBuild::UnifiedTurnBuild(int a, int width, int height, float d, float e, IInputHolder* pHolder) : diff --git a/source/client/renderer/Chunk.hpp b/source/client/renderer/Chunk.hpp index 3e401fe8d..3bf2f88fc 100644 --- a/source/client/renderer/Chunk.hpp +++ b/source/client/renderer/Chunk.hpp @@ -8,7 +8,6 @@ #pragma once -#include "common/Utils.hpp" #include "FrustumCuller.hpp" #include "RenderList.hpp" #include "Tesselator.hpp" diff --git a/source/client/renderer/DynamicTexture.cpp b/source/client/renderer/DynamicTexture.cpp index b544cfdce..e05e6f1a9 100644 --- a/source/client/renderer/DynamicTexture.cpp +++ b/source/client/renderer/DynamicTexture.cpp @@ -6,8 +6,9 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ +#include + #include "DynamicTexture.hpp" -#include "common/Utils.hpp" DynamicTexture::DynamicTexture(int a2) : m_textureIndex(a2) { diff --git a/source/client/renderer/ItemInHandRenderer.cpp b/source/client/renderer/ItemInHandRenderer.cpp index 7341703f8..074583839 100644 --- a/source/client/renderer/ItemInHandRenderer.cpp +++ b/source/client/renderer/ItemInHandRenderer.cpp @@ -89,7 +89,7 @@ void ItemInHandRenderer::renderItem(ItemInstance* inst) if (pTile) toBind = C_TERRAIN_NAME; else - toBind = "gui/items.png"; + toBind = C_ITEMS_NAME; m_pMinecraft->m_pTextures->loadAndBindTexture(toBind); constexpr float C_RATIO = 1.0f / 256.0f; diff --git a/source/client/renderer/LevelRenderer.cpp b/source/client/renderer/LevelRenderer.cpp index 3e6351b4d..2128c4c26 100644 --- a/source/client/renderer/LevelRenderer.cpp +++ b/source/client/renderer/LevelRenderer.cpp @@ -7,9 +7,11 @@ ********************************************************************/ #include "LevelRenderer.hpp" + +#include "common/Logger.hpp" +#include "common/Mth.hpp" #include "client/app/Minecraft.hpp" #include "renderer/GL/GL.hpp" -#include "common/Mth.hpp" #include "world/tile/LeafTile.hpp" #include "world/tile/GrassTile.hpp" diff --git a/source/client/renderer/PatchManager.cpp b/source/client/renderer/PatchManager.cpp index fc726c053..96fb15d57 100644 --- a/source/client/renderer/PatchManager.cpp +++ b/source/client/renderer/PatchManager.cpp @@ -1,6 +1,7 @@ #include "PatchManager.hpp" + +#include "common/Logger.hpp" #include "client/app/AppPlatform.hpp" -#include "common/Utils.hpp" #include "world/tile/Tile.hpp" #include "world/item/Item.hpp" #include "thirdparty/GL/GL.hpp" diff --git a/source/client/renderer/RenderList.cpp b/source/client/renderer/RenderList.cpp index 0a38d103e..1de0d0189 100644 --- a/source/client/renderer/RenderList.cpp +++ b/source/client/renderer/RenderList.cpp @@ -7,7 +7,6 @@ ********************************************************************/ #include "RenderList.hpp" -#include "common/Utils.hpp" #include "Tesselator.hpp" #include diff --git a/source/client/renderer/Tesselator.cpp b/source/client/renderer/Tesselator.cpp index 0dca97340..514c9d10a 100644 --- a/source/client/renderer/Tesselator.cpp +++ b/source/client/renderer/Tesselator.cpp @@ -8,7 +8,7 @@ #include "Tesselator.hpp" #include "thirdparty/GL/GL.hpp" -#include "common/Utils.hpp" +#include "common/Logger.hpp" #include "compat/EndianDefinitions.h" #include diff --git a/source/client/renderer/Texture.hpp b/source/client/renderer/Texture.hpp index 7db8a47ce..49e8a639c 100644 --- a/source/client/renderer/Texture.hpp +++ b/source/client/renderer/Texture.hpp @@ -9,7 +9,7 @@ #pragma once #include -#include "common/Utils.hpp" +#include "compat/LegacyCPP.hpp" struct Texture { diff --git a/source/client/renderer/Textures.cpp b/source/client/renderer/Textures.cpp index 2300c3f26..c77b6c33c 100644 --- a/source/client/renderer/Textures.cpp +++ b/source/client/renderer/Textures.cpp @@ -7,7 +7,6 @@ ********************************************************************/ #include "Textures.hpp" -#include "common/Utils.hpp" bool Textures::MIPMAP = false; diff --git a/source/client/renderer/Textures.hpp b/source/client/renderer/Textures.hpp index 5a7825dfd..18ac6480e 100644 --- a/source/client/renderer/Textures.hpp +++ b/source/client/renderer/Textures.hpp @@ -14,6 +14,10 @@ #include "client/app/AppPlatform.hpp" #include "DynamicTexture.hpp" +#define C_TERRAIN_NAME "terrain.png" +#define C_ITEMS_NAME "gui/items.png" +#define C_BLOCKS_NAME "gui/gui_blocks.png" + class DynamicTexture; // in case we are being included from DynamicTexture. We don't store complete references to that struct TextureData diff --git a/source/client/renderer/TileRenderer.cpp b/source/client/renderer/TileRenderer.cpp index 76c471d6a..c9345334b 100644 --- a/source/client/renderer/TileRenderer.cpp +++ b/source/client/renderer/TileRenderer.cpp @@ -9,10 +9,11 @@ #include "TileRenderer.hpp" #include "client/app/Minecraft.hpp" #include "client/renderer/PatchManager.hpp" -#include "world/tile/FireTile.hpp" -#include "world/tile/LiquidTile.hpp" #include "client/renderer/GrassColor.hpp" #include "client/renderer/FoliageColor.hpp" +#include "world/tile/FireTile.hpp" +#include "world/tile/LiquidTile.hpp" +#include "GameMods.hpp" bool TileRenderer::m_bFancyGrass = false; bool TileRenderer::m_bBiomeColors = false; diff --git a/source/client/renderer/entity/FallingTileRenderer.cpp b/source/client/renderer/entity/FallingTileRenderer.cpp index 4a3792163..fc71b6342 100644 --- a/source/client/renderer/entity/FallingTileRenderer.cpp +++ b/source/client/renderer/entity/FallingTileRenderer.cpp @@ -7,7 +7,7 @@ ********************************************************************/ #include "GameMods.hpp" -#if defined(ENH_ALLOW_SAND_GRAVITY) +#ifdef ENH_ALLOW_SAND_GRAVITY #include "FallingTileRenderer.hpp" #include "world/entity/FallingTile.hpp" diff --git a/source/client/renderer/entity/FallingTileRenderer.hpp b/source/client/renderer/entity/FallingTileRenderer.hpp index 15f1c9c4d..74a98df28 100644 --- a/source/client/renderer/entity/FallingTileRenderer.hpp +++ b/source/client/renderer/entity/FallingTileRenderer.hpp @@ -10,7 +10,7 @@ #include "GameMods.hpp" -#if defined(ENH_ALLOW_SAND_GRAVITY) +#ifdef ENH_ALLOW_SAND_GRAVITY #include "EntityRenderer.hpp" #include "../TileRenderer.hpp" diff --git a/source/client/renderer/entity/RocketRenderer.cpp b/source/client/renderer/entity/RocketRenderer.cpp index 2fa0e00a2..3cd089a08 100644 --- a/source/client/renderer/entity/RocketRenderer.cpp +++ b/source/client/renderer/entity/RocketRenderer.cpp @@ -22,7 +22,7 @@ void RocketRenderer::render(Entity* entity, const Vec3& pos, float rot, float a) float brightness = entity->getBrightness(1.0f); - bindTexture("gui/items.png"); + bindTexture(C_ITEMS_NAME); m_renderer.renderTile(&m_tile, 0, brightness); glPopMatrix(); diff --git a/source/client/renderer/entity/TripodCameraRenderer.cpp b/source/client/renderer/entity/TripodCameraRenderer.cpp index 0d86f11dc..aa29a683a 100644 --- a/source/client/renderer/entity/TripodCameraRenderer.cpp +++ b/source/client/renderer/entity/TripodCameraRenderer.cpp @@ -38,7 +38,7 @@ void TripodCameraRenderer::render(Entity* entity, const Vec3& pos, float rot, fl float brightness = entity->getBrightness(1.0f); - bindTexture("gui/items.png"); + bindTexture(C_ITEMS_NAME); //t.begin(); //m_renderer.tesselateCrossTexture(&m_tile, 0, -0.5f, -0.5f, -0.5f); m_renderer.renderTile(&m_tile, 0, brightness); diff --git a/source/client/sound/SoundData.cpp b/source/client/sound/SoundData.cpp index 823642efd..991391d66 100644 --- a/source/client/sound/SoundData.cpp +++ b/source/client/sound/SoundData.cpp @@ -11,6 +11,7 @@ #include "SoundData.hpp" +#include "common/Logger.hpp" #include "client/app/AppPlatform.hpp" std::string SoundDesc::dirs[] = { diff --git a/source/client/sound/SoundData.hpp b/source/client/sound/SoundData.hpp index 34b78e47d..b2bc5cd49 100644 --- a/source/client/sound/SoundData.hpp +++ b/source/client/sound/SoundData.hpp @@ -8,8 +8,8 @@ #pragma once +#include #include -#include "common/Utils.hpp" #include "client/app/AssetFile.hpp" class AppPlatform; diff --git a/source/client/sound/SoundPathRepository.cpp b/source/client/sound/SoundPathRepository.cpp index c959c4412..52dba228f 100644 --- a/source/client/sound/SoundPathRepository.cpp +++ b/source/client/sound/SoundPathRepository.cpp @@ -1,6 +1,6 @@ #include "SoundPathRepository.hpp" -#include "common/Utils.hpp" +#include "common/Logger.hpp" #include "common/Mth.hpp" void SoundPathRepository::add(const std::string& name, const std::string& path) diff --git a/source/client/sound/SoundRepository.cpp b/source/client/sound/SoundRepository.cpp index 1b7d3e32a..32a24a2dd 100644 --- a/source/client/sound/SoundRepository.cpp +++ b/source/client/sound/SoundRepository.cpp @@ -7,7 +7,7 @@ ********************************************************************/ #include "SoundRepository.hpp" -#include "common/Utils.hpp" +#include "common/Logger.hpp" #include "common/Mth.hpp" void SoundRepository::add(const std::string& name, SoundDesc& sd) diff --git a/source/client/sound/SoundStream.hpp b/source/client/sound/SoundStream.hpp index ec0a8f68c..75f8df959 100644 --- a/source/client/sound/SoundStream.hpp +++ b/source/client/sound/SoundStream.hpp @@ -5,6 +5,7 @@ #define STB_VORBIS_HEADER_ONLY #include "thirdparty/stb_image/include/stb_vorbis.c" +#include "compat/LegacyCPP.hpp" #include "client/sound/SoundData.hpp" class SoundStream diff --git a/source/common/CThread.cpp b/source/common/CThread.cpp index 530a40fbc..19bba2c74 100644 --- a/source/common/CThread.cpp +++ b/source/common/CThread.cpp @@ -8,7 +8,6 @@ #include #include "CThread.hpp" -#include "common/Utils.hpp" #if defined(_WIN32) #define WIN32_LEAN_AND_MEAN diff --git a/source/common/Utils.cpp b/source/common/Utils.cpp index beb8f1785..12a730577 100644 --- a/source/common/Utils.cpp +++ b/source/common/Utils.cpp @@ -8,20 +8,18 @@ // note: not an official file name -#include "common/Utils.hpp" -#include "compat/PlatformDefinitions.h" +#include "Utils.hpp" -#if defined(_WIN32) && !defined(_XBOX) +#include -#define WIN32_LEAN_AND_MEAN -#include -#include -#include +#if MC_PLATFORM_WINPC + +#include // Why are we not using GetTickCount64()? It's simple -- getTimeMs has the exact same problem as using regular old GetTickCount. #pragma warning(disable : 28159) -#elif defined(_XBOX) +#elif MC_PLATFORM_XBOX360 #else @@ -37,7 +35,7 @@ int g_TimeSecondsOnInit = 0; -#if (!defined(USE_SDL) || defined(_WIN32)) && !defined(ANDROID) && !MC_PLATFORM_MAC +#ifdef _WIN32 DIR* opendir(const char* name) { @@ -163,21 +161,6 @@ bool DeleteDirectory(const std::string& name2, bool unused) #endif } -const char* GetTerrainName() -{ - return "terrain.png"; -} - -const char* GetItemsName() -{ - return "gui/items.png"; -} - -const char* GetGUIBlocksName() -{ - return "gui/gui_blocks.png"; -} - #ifdef _WIN32 int gettimeofday(struct timeval* tp, struct timezone* tzp) { @@ -276,87 +259,6 @@ time_t getEpochTimeS() return time(0); } -#if defined(_WIN32) && !defined(USE_SDL) - -HINSTANCE g_hInstance = NULL; -HWND g_hWnd = NULL; - -void SetInstance(HINSTANCE hinst) -{ - g_hInstance = hinst; -} - -HINSTANCE GetInstance() -{ - return g_hInstance; -} - -void SetHWND(HWND hwnd) -{ - g_hWnd = hwnd; -} - -HWND GetHWND() -{ - return g_hWnd; -} - -void CenterWindow(HWND hWnd) -{ - RECT r, desk; - GetWindowRect(hWnd, &r); - GetWindowRect(GetDesktopWindow(), &desk); - - int wa, ha, wb, hb; - - wa = (r.right - r.left) / 2; - ha = (r.bottom - r.top) / 2; - - wb = (desk.right - desk.left) / 2; - hb = (desk.bottom - desk.top) / 2; - - SetWindowPos(hWnd, NULL, wb - wa, hb - ha, r.right - r.left, r.bottom - r.top, 0); -} - -void EnableOpenGL(HWND hwnd, HDC* hDC, HGLRC* hRC) -{ - PIXELFORMATDESCRIPTOR pfd; - - int iFormat; - - /* get the device context (DC) */ - *hDC = GetDC(hwnd); - - /* set the pixel format for the DC */ - ZeroMemory(&pfd, sizeof(pfd)); - - pfd.nSize = sizeof(pfd); - pfd.nVersion = 1; - pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; - pfd.iPixelType = PFD_TYPE_RGBA; - pfd.cColorBits = 24; - pfd.cDepthBits = 8; - pfd.iLayerType = PFD_MAIN_PLANE; - - iFormat = ChoosePixelFormat(*hDC, &pfd); - - SetPixelFormat(*hDC, iFormat, &pfd); - - /* create and enable the render context (RC) */ - *hRC = wglCreateContext(*hDC); - - wglMakeCurrent(*hDC, *hRC); -} - -void DisableOpenGL(HWND hwnd, HDC hDC, HGLRC hRC) -{ - wglMakeCurrent(NULL, NULL); - wglDeleteContext(hRC); - ReleaseDC(hwnd, hDC); -} - -#endif - void sleepMs(int ms) { #ifdef _WIN32 diff --git a/source/common/Utils.hpp b/source/common/Utils.hpp index ecd2a70a0..5c50dd81c 100644 --- a/source/common/Utils.hpp +++ b/source/common/Utils.hpp @@ -27,23 +27,23 @@ #include #include "compat/LegacyCPP.hpp" +#include "compat/PlatformDefinitions.h" #ifdef _MSC_VER #pragma warning (disable : 4068) #endif -#if defined(_WIN32) +#ifdef _WIN32 // Do we even need all this WinSock stuff anymore? -#ifndef _XBOX // assume we're on a normal Windows device +#if MC_PLATFORM_WINPC + #define WIN32_LEAN_AND_MEAN -#include #include -#include #include #include -#elif defined(_XBOX) +#elif MC_PLATFORM_XBOX360 #include #include @@ -101,25 +101,8 @@ void closedir(DIR* dir); #endif -#include "../../compat/KeyCodes.hpp" -#include "Logger.hpp" - -// options: -#include "../../GameMods.hpp" - // don't know where to declare these: -#ifndef MOD_USE_BIGGER_SCREEN_SIZE -#define C_DEFAULT_SCREEN_WIDTH (854) -#define C_DEFAULT_SCREEN_HEIGHT (480) -#elif defined(__DREAMCAST__) -#define C_DEFAULT_SCREEN_WIDTH (800) -#define C_DEFAULT_SCREEN_HEIGHT (600) -#else -#define C_DEFAULT_SCREEN_WIDTH (1280) -#define C_DEFAULT_SCREEN_HEIGHT (720) -#endif - #define C_MAX_TILES (256) #define C_DEFAULT_PORT (19132) @@ -129,20 +112,6 @@ constexpr int C_MIN_X = -32000000, C_MAX_X = 32000000; constexpr int C_MIN_Z = -32000000, C_MAX_Z = 32000000; constexpr int C_MIN_Y = 0, C_MAX_Y = 128; -const char* GetTerrainName(); -const char* GetItemsName(); -const char* GetGUIBlocksName(); - -#ifdef ORIGINAL_CODE -#define C_TERRAIN_NAME "terrain.png" -#define C_ITEMS_NAME "gui/items.png" -#define C_BLOCKS_NAME "gui/gui_blocks.png" -#else -#define C_TERRAIN_NAME GetTerrainName() -#define C_ITEMS_NAME "gui/items.png" -#define C_BLOCKS_NAME "gui/gui_blocks.png" -#endif - #define C_MAX_CHUNKS_X (16) #define C_MAX_CHUNKS_Z (16) #define C_MAX_CHUNKS (C_MAX_CHUNKS_X * C_MAX_CHUNKS_Z) @@ -428,7 +397,7 @@ enum // Textures TEXTURE_BOOKSHELF, TEXTURE_MOSSY_STONE, TEXTURE_OBSIDIAN, - TEXTURE_OBSIDIAN_CRYING, // would become grass side overaly after removel + TEXTURE_OBSIDIAN_CRYING, // would become grass side overlay after removel TEXTURE_NONE39, // tall grass TEXTURE_NONE40, TEXTURE_CHEST_TWO_FRONT_LEFT, @@ -566,18 +535,6 @@ typedef uint8_t TileID; // Create "Tile" class containing TileTypeId, and TileData typedef uint8_t TileData; -/*struct Pos -{ - int x, y, z; - Pos() - { - x = 0; - y = 0; - z = 0; - } - Pos(int _x, int _y, int _z) : x(_x), y(_y), z(_z) {} -};*/ - #define SAFE_DELETE(ptr) do { if (ptr) delete ptr; } while (0) #define SAFE_DELETE_ARRAY(ptr) do { if (ptr) delete[] ptr; } while (0) @@ -599,18 +556,3 @@ bool DeleteDirectory(const std::string& name, bool unused); uint8_t* ZlibInflateToMemory(uint8_t* pInput, size_t compressedSize, size_t decompressedSize); uint8_t* ZlibDeflateToMemory(uint8_t* pInput, size_t sizeBytes, size_t *compressedSizeOut); uint8_t* ZlibDeflateToMemoryLvl(uint8_t* pInput, size_t sizeBytes, size_t* compressedSizeOut, int level); - -// things that we added: - -#ifdef _WIN32 - -HINSTANCE GetInstance(); -HWND GetHWND(); -void CenterWindow(HWND hWnd); -void EnableOpenGL(HWND hwnd, HDC*, HGLRC*); -void DisableOpenGL(HWND, HDC, HGLRC); - -void SetInstance(HINSTANCE hinst); -void SetHWND(HWND hwnd); - -#endif diff --git a/source/network/NetEventCallback.cpp b/source/network/NetEventCallback.cpp index 5de0db21b..2fd32b04d 100644 --- a/source/network/NetEventCallback.cpp +++ b/source/network/NetEventCallback.cpp @@ -1,4 +1,5 @@ #include "NetEventCallback.hpp" +#include "common/Logger.hpp" #include "world/level/Level.hpp" Player* NetEventCallback::_findPlayer(Level& level, Entity::ID entityId, const RakNet::RakNetGUID* guid) diff --git a/source/network/RakNetInstance.cpp b/source/network/RakNetInstance.cpp index 6302378f0..7e7151043 100644 --- a/source/network/RakNetInstance.cpp +++ b/source/network/RakNetInstance.cpp @@ -7,8 +7,11 @@ ********************************************************************/ #include "RakNetInstance.hpp" + +#include "common/Logger.hpp" +#include "thirdparty/raknet/GetTime.h" + #include "MinecraftPackets.hpp" -#include "GetTime.h" #include "NetEventCallback.hpp" //#define LOG_PACKETS diff --git a/source/server/ServerSideNetworkHandler.cpp b/source/server/ServerSideNetworkHandler.cpp index fbcaf2c60..6548f23c6 100644 --- a/source/server/ServerSideNetworkHandler.cpp +++ b/source/server/ServerSideNetworkHandler.cpp @@ -7,7 +7,8 @@ ********************************************************************/ #include "ServerSideNetworkHandler.hpp" -#include "common/Utils.hpp" +#include "common/Logger.hpp" +#include "GameMods.hpp" #include "network/MinecraftPackets.hpp" #include "world/entity/MobFactory.hpp" #include "ServerPlayer.hpp" diff --git a/source/world/entity/Cow.cpp b/source/world/entity/Cow.cpp index 4e248b63d..dce04c8c2 100644 --- a/source/world/entity/Cow.cpp +++ b/source/world/entity/Cow.cpp @@ -6,7 +6,6 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ #include "Cow.hpp" -#include "common/Utils.hpp" Cow::Cow(Level* pLevel) : Animal(pLevel) { diff --git a/source/world/entity/Entity.cpp b/source/world/entity/Entity.cpp index 8c0c1006e..155780683 100644 --- a/source/world/entity/Entity.cpp +++ b/source/world/entity/Entity.cpp @@ -7,9 +7,12 @@ ********************************************************************/ #include "Entity.hpp" -#include "Player.hpp" -#include "world/level/Level.hpp" + +#include "common/Logger.hpp" #include "nbt/CompoundTag.hpp" +#include "world/level/Level.hpp" + +#include "Player.hpp" #define TOTAL_AIR_SUPPLY (300) #define DATA_SHARED_FLAGS_ID (0) diff --git a/source/world/entity/Entity.hpp b/source/world/entity/Entity.hpp index c61a1dc8d..266459d18 100644 --- a/source/world/entity/Entity.hpp +++ b/source/world/entity/Entity.hpp @@ -17,7 +17,6 @@ #include "world/item/ItemInstance.hpp" #include "SynchedEntityData.hpp" #include "EntityTypeDescriptor.hpp" -#include "common/Utils.hpp" #define C_ENTITY_FLAG_ONFIRE (0) #define C_ENTITY_FLAG_SNEAKING (1) diff --git a/source/world/entity/EntityFactory.cpp b/source/world/entity/EntityFactory.cpp index 0c3d60627..b7df0744e 100644 --- a/source/world/entity/EntityFactory.cpp +++ b/source/world/entity/EntityFactory.cpp @@ -1,5 +1,6 @@ #include "EntityFactory.hpp" #include "MobFactory.hpp" +#include "common/Logger.hpp" #include "nbt/CompoundTag.hpp" #include "ItemEntity.hpp" diff --git a/source/world/entity/MobCategory.cpp b/source/world/entity/MobCategory.cpp index 568d19091..96f8d8779 100644 --- a/source/world/entity/MobCategory.cpp +++ b/source/world/entity/MobCategory.cpp @@ -1,4 +1,5 @@ #include "MobCategory.hpp" +#include "compat/LegacyCPP.hpp" #include "world/level/Material.hpp" MobCategory MobCategory::monster = MobCategory(EntityCategories(EntityCategories::MONSTER), 10, 20, nullptr, false); diff --git a/source/world/entity/MobFactory.cpp b/source/world/entity/MobFactory.cpp index 9d4cdbdd5..afa536d7d 100644 --- a/source/world/entity/MobFactory.cpp +++ b/source/world/entity/MobFactory.cpp @@ -1,4 +1,5 @@ #include "MobFactory.hpp" +#include "common/Logger.hpp" #include "nbt/CompoundTag.hpp" #include "Chicken.hpp" diff --git a/source/world/entity/Pig.cpp b/source/world/entity/Pig.cpp index 19b871031..cf2deba79 100644 --- a/source/world/entity/Pig.cpp +++ b/source/world/entity/Pig.cpp @@ -6,7 +6,6 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ #include "Pig.hpp" -#include "common/Utils.hpp" Pig::Pig(Level* pLevel) : Animal(pLevel) { diff --git a/source/world/entity/Player.hpp b/source/world/entity/Player.hpp index 34f2f90c1..884f099a0 100644 --- a/source/world/entity/Player.hpp +++ b/source/world/entity/Player.hpp @@ -8,7 +8,6 @@ #pragma once -#include "common/Utils.hpp" #include "thirdparty/raknet/RakNetTypes.h" #include "world/item/Inventory.hpp" #include "world/entity/Mob.hpp" diff --git a/source/world/gamemode/SurvivalMode.cpp b/source/world/gamemode/SurvivalMode.cpp index 80bc7f00e..90e45f4a5 100644 --- a/source/world/gamemode/SurvivalMode.cpp +++ b/source/world/gamemode/SurvivalMode.cpp @@ -7,6 +7,7 @@ ********************************************************************/ #include "SurvivalMode.hpp" +#include "GameMods.hpp" #include "client/app/Minecraft.hpp" #include "network/packets/RemoveBlockPacket.hpp" diff --git a/source/world/item/Inventory.cpp b/source/world/item/Inventory.cpp index 24ef66002..334d2e989 100644 --- a/source/world/item/Inventory.cpp +++ b/source/world/item/Inventory.cpp @@ -1,7 +1,11 @@ #include "Inventory.hpp" -#include "Item.hpp" + +#include "GameMods.hpp" +#include "common/Logger.hpp" #include "nbt/CompoundTag.hpp" +#include "Item.hpp" + Inventory::Inventory(Player* pPlayer) { m_pPlayer = pPlayer; diff --git a/source/world/item/Inventory.hpp b/source/world/item/Inventory.hpp index 14c26a926..30f2d7cf8 100644 --- a/source/world/item/Inventory.hpp +++ b/source/world/item/Inventory.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include "GameMods.hpp" #include "world/item/ItemInstance.hpp" #include "world/entity/Player.hpp" #include "world/gamemode/GameType.hpp" diff --git a/source/world/item/Item.cpp b/source/world/item/Item.cpp index 18c38d4c4..d43c77f98 100644 --- a/source/world/item/Item.cpp +++ b/source/world/item/Item.cpp @@ -8,6 +8,8 @@ #include "Item.hpp" +#include "common/Logger.hpp" + #include "CameraItem.hpp" #include "DoorItem.hpp" #include "TileItem.hpp" diff --git a/source/world/item/Item.hpp b/source/world/item/Item.hpp index 321b39b7a..e9834c125 100644 --- a/source/world/item/Item.hpp +++ b/source/world/item/Item.hpp @@ -10,12 +10,16 @@ #include #include + +// needed for TileData and Tile IDs #include "common/Utils.hpp" + #include "world/level/Material.hpp" -#include "ItemInstance.hpp" #include "world/level/TilePos.hpp" #include "world/Facing.hpp" +#include "ItemInstance.hpp" + #define C_MAX_ITEMS (C_MAX_TILES * 2) class ItemInstance; // in case we're included from ItemInstance.hpp diff --git a/source/world/item/ItemInstance.cpp b/source/world/item/ItemInstance.cpp index 02353332c..334cc54ca 100644 --- a/source/world/item/ItemInstance.cpp +++ b/source/world/item/ItemInstance.cpp @@ -8,6 +8,7 @@ #include #include "ItemInstance.hpp" +#include "GameMods.hpp" #include "world/tile/Tile.hpp" #include "nbt/CompoundTag.hpp" diff --git a/source/world/item/ItemInstance.hpp b/source/world/item/ItemInstance.hpp index e31b99393..08c1723e1 100644 --- a/source/world/item/ItemInstance.hpp +++ b/source/world/item/ItemInstance.hpp @@ -8,7 +8,6 @@ #pragma once -#include "common/Utils.hpp" #include "Item.hpp" #include "world/level/TilePos.hpp" #include "world/Facing.hpp" diff --git a/source/world/level/Dimension.cpp b/source/world/level/Dimension.cpp index 0b6ac9a5b..96689fdf2 100644 --- a/source/world/level/Dimension.cpp +++ b/source/world/level/Dimension.cpp @@ -7,6 +7,7 @@ ********************************************************************/ #include "Dimension.hpp" +#include "GameMods.hpp" #include "world/level/levelgen/chunk/TestChunkSource.hpp" #include "world/level/levelgen/chunk/RandomLevelSource.hpp" #include "world/level/levelgen/chunk/ChunkCache.hpp" diff --git a/source/world/level/Level.cpp b/source/world/level/Level.cpp index f0c924082..7098bc722 100644 --- a/source/world/level/Level.cpp +++ b/source/world/level/Level.cpp @@ -10,11 +10,13 @@ #include -#include "common/Util.hpp" +#include "GameMods.hpp" +#include "common/Logger.hpp" #include "network/RakNetInstance.hpp" #include "network/packets/EntityEventPacket.hpp" #include "network/packets/SetEntityDataPacket.hpp" #include "world/level/levelgen/chunk/ChunkCache.hpp" + #include "Explosion.hpp" #include "Region.hpp" diff --git a/source/world/level/Material.hpp b/source/world/level/Material.hpp index b1691e86a..50960a2e6 100644 --- a/source/world/level/Material.hpp +++ b/source/world/level/Material.hpp @@ -6,10 +6,10 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ -#include "common/Utils.hpp" - #pragma once +#include "compat/LegacyCPP.hpp" + class Material { public: diff --git a/source/world/level/levelgen/biome/Biome.hpp b/source/world/level/levelgen/biome/Biome.hpp index a42544bd7..dbeadc4c9 100644 --- a/source/world/level/levelgen/biome/Biome.hpp +++ b/source/world/level/levelgen/biome/Biome.hpp @@ -9,7 +9,6 @@ #pragma once #include -#include "common/Utils.hpp" #include "world/level/levelgen/synth/PerlinNoise.hpp" #include "world/level/levelgen/feature/Feature.hpp" diff --git a/source/world/level/levelgen/chunk/ChunkSource.hpp b/source/world/level/levelgen/chunk/ChunkSource.hpp index 6b3b6b2fd..7647e7253 100644 --- a/source/world/level/levelgen/chunk/ChunkSource.hpp +++ b/source/world/level/levelgen/chunk/ChunkSource.hpp @@ -9,7 +9,6 @@ #pragma once #include #include "world/level/levelgen/chunk/LevelChunk.hpp" -#include "common/Utils.hpp" #include "GameMods.hpp" class Level; class LevelChunk; diff --git a/source/world/level/levelgen/chunk/LevelChunk.cpp b/source/world/level/levelgen/chunk/LevelChunk.cpp index 0822109de..fb949208e 100644 --- a/source/world/level/levelgen/chunk/LevelChunk.cpp +++ b/source/world/level/levelgen/chunk/LevelChunk.cpp @@ -6,6 +6,7 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ +#include "common/Logger.hpp" #include "world/level/Level.hpp" #include "world/phys/AABB.hpp" diff --git a/source/world/level/levelgen/chunk/RandomLevelSource.cpp b/source/world/level/levelgen/chunk/RandomLevelSource.cpp index 9bf7a832b..5bb234166 100644 --- a/source/world/level/levelgen/chunk/RandomLevelSource.cpp +++ b/source/world/level/levelgen/chunk/RandomLevelSource.cpp @@ -7,10 +7,11 @@ ********************************************************************/ #include "RandomLevelSource.hpp" + +#include "common/Logger.hpp" #include "world/level/Level.hpp" #include "world/tile/SandTile.hpp" - const float RandomLevelSource::SNOW_CUTOFF = 0.5f; const float RandomLevelSource::SNOW_SCALE = 0.3f; diff --git a/source/world/level/levelgen/chunk/RandomLevelSource.hpp b/source/world/level/levelgen/chunk/RandomLevelSource.hpp index 3bbcd311f..94047a18d 100644 --- a/source/world/level/levelgen/chunk/RandomLevelSource.hpp +++ b/source/world/level/levelgen/chunk/RandomLevelSource.hpp @@ -14,7 +14,6 @@ #include #include "ChunkSource.hpp" -#include "common/Utils.hpp" #include "world/level/levelgen/synth/PerlinNoise.hpp" #include "world/level/levelgen/biome/BiomeSource.hpp" #include "world/level/levelgen/feature/Feature.hpp" diff --git a/source/world/level/levelgen/chunk/TestChunkSource.hpp b/source/world/level/levelgen/chunk/TestChunkSource.hpp index 2b98df72f..d58d9897c 100644 --- a/source/world/level/levelgen/chunk/TestChunkSource.hpp +++ b/source/world/level/levelgen/chunk/TestChunkSource.hpp @@ -9,7 +9,6 @@ #pragma once #include -#include "common/Utils.hpp" #include "ChunkSource.hpp" class Level; diff --git a/source/world/level/levelgen/synth/PerlinNoise.cpp b/source/world/level/levelgen/synth/PerlinNoise.cpp index 323b17c20..bcedc6081 100644 --- a/source/world/level/levelgen/synth/PerlinNoise.cpp +++ b/source/world/level/levelgen/synth/PerlinNoise.cpp @@ -7,7 +7,7 @@ ********************************************************************/ #include "PerlinNoise.hpp" -#include "common/Utils.hpp" +#include "common/Logger.hpp" PerlinNoise::PerlinNoise(int nOctaves) { diff --git a/source/world/level/storage/ExternalFileLevelStorage.cpp b/source/world/level/storage/ExternalFileLevelStorage.cpp index 8fa1fb904..e354c296a 100644 --- a/source/world/level/storage/ExternalFileLevelStorage.cpp +++ b/source/world/level/storage/ExternalFileLevelStorage.cpp @@ -9,12 +9,14 @@ #include #include "ExternalFileLevelStorage.hpp" -#include "world/level/Level.hpp" -#include "GetTime.h" + +#include "common/Logger.hpp" #include "nbt/CompoundTag.hpp" #include "nbt/NbtIo.hpp" #include "network/RakIO.hpp" #include "world/entity/EntityFactory.hpp" +#include "world/level/Level.hpp" +#include "thirdparty/raknet/GetTime.h" #ifndef DEMO diff --git a/source/world/level/storage/ExternalFileLevelStorageSource.cpp b/source/world/level/storage/ExternalFileLevelStorageSource.cpp index 8c0610777..283726b5d 100644 --- a/source/world/level/storage/ExternalFileLevelStorageSource.cpp +++ b/source/world/level/storage/ExternalFileLevelStorageSource.cpp @@ -8,7 +8,7 @@ #include "ExternalFileLevelStorageSource.hpp" #include "ExternalFileLevelStorage.hpp" -#include "common/Util.hpp" +#include "common/Logger.hpp" #ifndef DEMO diff --git a/source/world/level/storage/LevelData.hpp b/source/world/level/storage/LevelData.hpp index 03ae753b8..b2fe53456 100644 --- a/source/world/level/storage/LevelData.hpp +++ b/source/world/level/storage/LevelData.hpp @@ -10,7 +10,6 @@ #include #include "BitStream.h" -#include "common/Utils.hpp" #include "world/phys/Vec3.hpp" #include "world/item/Inventory.hpp" diff --git a/source/world/level/storage/LevelSource.hpp b/source/world/level/storage/LevelSource.hpp index 97cc026b2..01bcf04ec 100644 --- a/source/world/level/storage/LevelSource.hpp +++ b/source/world/level/storage/LevelSource.hpp @@ -8,7 +8,6 @@ #pragma once -#include "common/Utils.hpp" #include "world/level/Material.hpp" #include "world/level/levelgen/biome/BiomeSource.hpp" diff --git a/source/world/tile/Tile.cpp b/source/world/tile/Tile.cpp index b88aef8aa..619da0ca2 100644 --- a/source/world/tile/Tile.cpp +++ b/source/world/tile/Tile.cpp @@ -6,6 +6,7 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ +#include "common/Logger.hpp" #include "world/level/Level.hpp" #include "world/item/TileItem.hpp" #include "world/entity/ItemEntity.hpp" diff --git a/thirdparty/GL/GLExt.cpp b/thirdparty/GL/GLExt.cpp index ad3e6477f..f48f2d501 100644 --- a/thirdparty/GL/GLExt.cpp +++ b/thirdparty/GL/GLExt.cpp @@ -18,7 +18,6 @@ #include #ifdef _WIN32 -HWND GetHWND(); #ifndef USE_OPENGL_2_FEATURES // this is stupidly hacky typedef BOOL(WINAPI* PFNWGLSWAPINTERVALEXTPROC) (int interval); @@ -52,6 +51,7 @@ bool xglInitted() #endif } +// Only called on Win32 and SDL+Win32 void xglInit() { #ifdef USE_HARDWARE_GL_BUFFERS @@ -71,17 +71,6 @@ void xglInit() #ifndef USE_OPENGL_2_FEATURES p_wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); #endif - -#ifdef USE_HARDWARE_GL_BUFFERS - if (!xglInitted()) - { - const char* const GL_ERROR_MSG = "Error initializing GL extensions. OpenGL 2.0 or later is required. Update your graphics drivers!"; - LOG_E(GL_ERROR_MSG); -#ifdef _WIN32 - MessageBoxA(GetHWND(), GL_ERROR_MSG, "OpenGL Error", MB_OK); -#endif - } -#endif } #ifdef USE_HARDWARE_GL_BUFFERS diff --git a/thirdparty/stb_image/include b/thirdparty/stb_image/include index beebb24b9..f7f20f39f 160000 --- a/thirdparty/stb_image/include +++ b/thirdparty/stb_image/include @@ -1 +1 @@ -Subproject commit beebb24b945efdea3b9bba23affb8eb3ba8982e7 +Subproject commit f7f20f39fe4f206c6f19e26ebfef7b261ee59ee4 From 06a468e561714225580496df42d33359f02b1600 Mon Sep 17 00:00:00 2001 From: Matt <97983689+bluepilledgreat@users.noreply.github.com> Date: Wed, 26 Nov 2025 21:35:53 +0000 Subject: [PATCH 050/293] Add missing level checks to ClientSideNetworkHandler (#201) --- source/client/network/ClientSideNetworkHandler.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/client/network/ClientSideNetworkHandler.cpp b/source/client/network/ClientSideNetworkHandler.cpp index 96d056301..ceb8f4bd3 100644 --- a/source/client/network/ClientSideNetworkHandler.cpp +++ b/source/client/network/ClientSideNetworkHandler.cpp @@ -328,6 +328,8 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, PlaceBl { puts_ignorable("PlaceBlockPacket"); + if (!m_pLevel) return; + Player* pPlayer = (Player*)m_pLevel->getEntity(pPlaceBlockPkt->m_entityId); if (!pPlayer) { @@ -363,6 +365,8 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, RemoveB { puts_ignorable("RemoveBlockPacket"); + if (!m_pLevel) return; + Entity* pEntity = m_pLevel->getEntity(pRemoveBlockPkt->m_entityId); if (!pEntity || !pEntity->isPlayer()) { @@ -396,6 +400,8 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, RemoveB void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, UpdateBlockPacket* pkt) { + if (!m_pLevel) return; + BlockUpdate update(pkt->m_pos, pkt->m_tileTypeId, pkt->m_data); if (!areAllChunksLoaded()) @@ -632,6 +638,8 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, RespawnPac void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, LevelDataPacket* packet) { + if (!m_pLevel) return; + const int uncompMagic = 12847812, compMagic = 58712758, chunkSepMagic = 284787658; RakNet::BitStream* bs = &packet->m_data, bs2; From 4564cbdce52b3f3a4407aec61b96ddbc233f908c Mon Sep 17 00:00:00 2001 From: Matt <97983689+bluepilledgreat@users.noreply.github.com> Date: Wed, 26 Nov 2025 21:52:53 +0000 Subject: [PATCH 051/293] Fix crash when removing the oldest chat message (#202) --- source/client/gui/Gui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/client/gui/Gui.cpp b/source/client/gui/Gui.cpp index 4adce15a3..f42ad242f 100644 --- a/source/client/gui/Gui.cpp +++ b/source/client/gui/Gui.cpp @@ -77,7 +77,7 @@ void Gui::addMessage(const std::string& s) if (m_guiMessages.size() > 50) { - m_guiMessages.erase(m_guiMessages.end()); + m_guiMessages.erase(m_guiMessages.end() - 1); } m_guiMessages.insert(m_guiMessages.begin(), GuiMessage(str, 0)); From bc5e9e2b0e64de9dcb894870db39e39c4c5d2c2c Mon Sep 17 00:00:00 2001 From: Matt <97983689+bluepilledgreat@users.noreply.github.com> Date: Sun, 30 Nov 2025 00:21:52 +0000 Subject: [PATCH 052/293] Fix entity's chunk Y-coordinate not updating (#205) --- source/world/level/Level.cpp | 13 ++++-- .../world/level/levelgen/chunk/ChunkPos.cpp | 2 +- .../world/level/levelgen/chunk/ChunkPos.hpp | 11 +++++ .../level/levelgen/chunk/EmptyLevelChunk.cpp | 5 +++ .../level/levelgen/chunk/EmptyLevelChunk.hpp | 1 + .../world/level/levelgen/chunk/LevelChunk.cpp | 42 ++++++++++++++++++- .../world/level/levelgen/chunk/LevelChunk.hpp | 1 + 7 files changed, 69 insertions(+), 6 deletions(-) diff --git a/source/world/level/Level.cpp b/source/world/level/Level.cpp index 7098bc722..f547e2e72 100644 --- a/source/world/level/Level.cpp +++ b/source/world/level/Level.cpp @@ -1522,11 +1522,11 @@ void Level::tickTiles() } } -void Level::tick(Entity* pEnt, bool b) +void Level::tick(Entity* pEnt, bool shouldTick) { TilePos tilePos(pEnt->m_pos); - if (b) + if (shouldTick) { if (!hasChunksAt(TilePos(tilePos.x - 32, 0, tilePos.z - 32), TilePos(tilePos.x + 32, 128, tilePos.z + 32))) { @@ -1558,7 +1558,6 @@ void Level::tick(Entity* pEnt, bool b) if (hasChunk(cp)) { - pEnt->m_bInAChunk = true; getChunk(cp)->addEntity(pEnt); } else @@ -1566,7 +1565,13 @@ void Level::tick(Entity* pEnt, bool b) pEnt->m_bInAChunk = false; } } - + else if (pEnt->m_bInAChunk) + { + if (pEnt->m_chunkPosY != ChunkPos::ToChunkCoordinate(pEnt->m_pos.y)) + { + getChunk(cp)->updateEntity(pEnt); + } + } } void Level::tick(Entity* pEnt) diff --git a/source/world/level/levelgen/chunk/ChunkPos.cpp b/source/world/level/levelgen/chunk/ChunkPos.cpp index ae48b7c58..8bcd4aca3 100644 --- a/source/world/level/levelgen/chunk/ChunkPos.cpp +++ b/source/world/level/levelgen/chunk/ChunkPos.cpp @@ -15,7 +15,7 @@ void ChunkPos::_init(const Vec3& pos) void ChunkPos::_init(const TilePos& pos) { - _init(pos.x >> 4, pos.z >> 4); + _init(ToChunkCoordinate(pos.x), ToChunkCoordinate(pos.z)); } ChunkPos::ChunkPos() diff --git a/source/world/level/levelgen/chunk/ChunkPos.hpp b/source/world/level/levelgen/chunk/ChunkPos.hpp index 43bc772b8..eec5aed06 100644 --- a/source/world/level/levelgen/chunk/ChunkPos.hpp +++ b/source/world/level/levelgen/chunk/ChunkPos.hpp @@ -1,4 +1,5 @@ #pragma once +#include #ifndef __VEC3_HPP class Vec3; @@ -49,4 +50,14 @@ struct ChunkPos bool operator!=(const ChunkPos& other) const; operator TilePos() const; + + static int ToChunkCoordinate(int value) + { + return value / 16; + } + + static int ToChunkCoordinate(float value) + { + return int(floorf(value / 16)); + } }; diff --git a/source/world/level/levelgen/chunk/EmptyLevelChunk.cpp b/source/world/level/levelgen/chunk/EmptyLevelChunk.cpp index b597b1065..749baa4af 100644 --- a/source/world/level/levelgen/chunk/EmptyLevelChunk.cpp +++ b/source/world/level/levelgen/chunk/EmptyLevelChunk.cpp @@ -41,6 +41,11 @@ void EmptyLevelChunk::removeEntity(Entity*, int vec) } +void EmptyLevelChunk::updateEntity(Entity* pEnt) +{ + +} + bool EmptyLevelChunk::isSkyLit(const ChunkTilePos& pos) { return false; diff --git a/source/world/level/levelgen/chunk/EmptyLevelChunk.hpp b/source/world/level/levelgen/chunk/EmptyLevelChunk.hpp index 1eb03d97d..c2230d388 100644 --- a/source/world/level/levelgen/chunk/EmptyLevelChunk.hpp +++ b/source/world/level/levelgen/chunk/EmptyLevelChunk.hpp @@ -15,6 +15,7 @@ class EmptyLevelChunk : public LevelChunk void addEntity(Entity*) override; void removeEntity(Entity*) override; void removeEntity(Entity*, int vec) override; + void updateEntity(Entity* pEnt) override; bool isSkyLit(const ChunkTilePos& pos) override; void lightLava() override; void recalcBlockLights() override; diff --git a/source/world/level/levelgen/chunk/LevelChunk.cpp b/source/world/level/levelgen/chunk/LevelChunk.cpp index fb949208e..aacc726c7 100644 --- a/source/world/level/levelgen/chunk/LevelChunk.cpp +++ b/source/world/level/levelgen/chunk/LevelChunk.cpp @@ -292,7 +292,7 @@ void LevelChunk::addEntity(Entity* pEnt) assert(pEnt != nullptr); // Cannot add a null entity field_238 = 1; - int yCoord = int(floorf(pEnt->m_pos.y / 16)); + int yCoord = ChunkPos::ToChunkCoordinate(pEnt->m_pos.y); if (yCoord < 0) yCoord = 0; if (yCoord > 7) yCoord = 7; pEnt->m_bInAChunk = true; @@ -302,6 +302,46 @@ void LevelChunk::addEntity(Entity* pEnt) m_entities[yCoord].push_back(pEnt); } +void LevelChunk::updateEntity(Entity* pEnt) +{ + assert(pEnt != nullptr); + assert(pEnt->m_bInAChunk); + assert(pEnt->m_chunkPos == m_chunkPos); + + int newYCoord = ChunkPos::ToChunkCoordinate(pEnt->m_pos.y); + if (newYCoord < 0) newYCoord = 0; + if (newYCoord > 7) newYCoord = 7; + + int oldYCoord = pEnt->m_chunkPosY; + if (oldYCoord == newYCoord) + { + return; + } + + if (oldYCoord < 0 || oldYCoord > 7) + { + assert(false); + return; + } + + std::vector& oldTerrainLayer = m_entities[oldYCoord]; + std::vector& newTerrainLayer = m_entities[newYCoord]; + + std::vector::iterator it = std::find(oldTerrainLayer.begin(), oldTerrainLayer.end(), pEnt); + if (it != oldTerrainLayer.end()) + { + oldTerrainLayer.erase(it); + } + else + { + assert(false); + } + + assert(std::find(newTerrainLayer.begin(), newTerrainLayer.end(), pEnt) == newTerrainLayer.end()); + newTerrainLayer.push_back(pEnt); + pEnt->m_chunkPosY = newYCoord; +} + void LevelChunk::clearUpdateMap() { memset(m_updateMap, 0, sizeof m_updateMap); diff --git a/source/world/level/levelgen/chunk/LevelChunk.hpp b/source/world/level/levelgen/chunk/LevelChunk.hpp index 1e4b9e8ed..00c2f891d 100644 --- a/source/world/level/levelgen/chunk/LevelChunk.hpp +++ b/source/world/level/levelgen/chunk/LevelChunk.hpp @@ -49,6 +49,7 @@ class LevelChunk virtual void addEntity(Entity*); virtual void removeEntity(Entity*); virtual void removeEntity(Entity*, int vec); + virtual void updateEntity(Entity* pEnt); virtual bool isSkyLit(const ChunkTilePos& pos); virtual void lightLava(); virtual void recalcBlockLights(); From 8999327477e6d18fa460c0f236af6b65914f2ad8 Mon Sep 17 00:00:00 2001 From: Matt <97983689+bluepilledgreat@users.noreply.github.com> Date: Sun, 30 Nov 2025 01:20:46 +0000 Subject: [PATCH 053/293] Add text pasting support (#204) --- platforms/sdl/base/AppPlatform_sdl.cpp | 14 ++++++ platforms/sdl/base/AppPlatform_sdl.hpp | 3 ++ platforms/sdl/sdl2/base/AppPlatform_sdl2.cpp | 9 ++++ platforms/sdl/sdl2/base/AppPlatform_sdl2.hpp | 2 + platforms/sdl/sdl2/main.cpp | 15 ++++-- platforms/windows/AppPlatform_win32.cpp | 18 +++++++ platforms/windows/AppPlatform_win32.hpp | 5 ++ platforms/windows/main.cpp | 15 ++++-- source/client/app/AppPlatform.cpp | 10 ++++ source/client/app/AppPlatform.hpp | 2 + source/client/app/Minecraft.cpp | 13 +++++ source/client/app/Minecraft.hpp | 2 + source/client/gui/Screen.cpp | 9 ++++ source/client/gui/Screen.hpp | 1 + source/client/gui/components/TextInputBox.cpp | 48 ++++++++++++++++++- source/client/gui/components/TextInputBox.hpp | 4 ++ 16 files changed, 162 insertions(+), 8 deletions(-) diff --git a/platforms/sdl/base/AppPlatform_sdl.cpp b/platforms/sdl/base/AppPlatform_sdl.cpp index 6167e2436..c3228ca09 100644 --- a/platforms/sdl/base/AppPlatform_sdl.cpp +++ b/platforms/sdl/base/AppPlatform_sdl.cpp @@ -90,6 +90,10 @@ void AppPlatform_sdl::_handleKeyEvent(int key, uint8_t state) /*if (state == SDL_PRESSED) g_pApp->handleCharInput('\b');*/ break; + case SDLVK_LCTRL: + case SDLVK_RCTRL: + setControlPressed(state == SDL_PRESSED, key == SDLVK_LCTRL); + break; case SDLVK_LSHIFT: case SDLVK_RSHIFT: setShiftPressed(state == SDL_PRESSED, key == SDLVK_LSHIFT); @@ -183,6 +187,16 @@ void AppPlatform_sdl::clearDiff() m_yrel = 0; } +bool AppPlatform_sdl::controlPressed() +{ + return m_bControlPressed[0] || m_bControlPressed[1]; +} + +void AppPlatform_sdl::setControlPressed(bool b, bool isLeft) +{ + m_bControlPressed[isLeft ? 0 : 1] = b; +} + bool AppPlatform_sdl::shiftPressed() { return m_bShiftPressed[0] || m_bShiftPressed[1]; diff --git a/platforms/sdl/base/AppPlatform_sdl.hpp b/platforms/sdl/base/AppPlatform_sdl.hpp index 88a606894..f0de08ac1 100644 --- a/platforms/sdl/base/AppPlatform_sdl.hpp +++ b/platforms/sdl/base/AppPlatform_sdl.hpp @@ -48,6 +48,8 @@ class AppPlatform_sdl : public AppPlatform void clearDiff() override; // Also add these to allow proper text input within the game. + bool controlPressed() override; + void setControlPressed(bool b, bool isLeft); bool shiftPressed() override; void setShiftPressed(bool b, bool isLeft); @@ -75,6 +77,7 @@ class AppPlatform_sdl : public AppPlatform protected: const Texture* m_pIconTexture; SDL_Surface* m_pIcon; + bool m_bControlPressed[2]; bool m_bShiftPressed[2]; int m_xrel; diff --git a/platforms/sdl/sdl2/base/AppPlatform_sdl2.cpp b/platforms/sdl/sdl2/base/AppPlatform_sdl2.cpp index 57597a3d3..4e969d8ad 100644 --- a/platforms/sdl/sdl2/base/AppPlatform_sdl2.cpp +++ b/platforms/sdl/sdl2/base/AppPlatform_sdl2.cpp @@ -19,6 +19,7 @@ #define STR(x) _STR(x) #include "client/player/input/Controller.hpp" +#include "client/app/NinecraftApp.hpp" void AppPlatform_sdl2::_init(SDL_Window *window) { @@ -130,6 +131,14 @@ void AppPlatform_sdl2::hideKeyboard() } } +std::string AppPlatform_sdl2::getClipboardText() +{ + char* temp = SDL_GetClipboardText(); + std::string str = temp; + SDL_free(temp); + return str; +} + bool AppPlatform_sdl2::hasGamepad() const { return m_pController != nullptr; diff --git a/platforms/sdl/sdl2/base/AppPlatform_sdl2.hpp b/platforms/sdl/sdl2/base/AppPlatform_sdl2.hpp index 92ca56559..7463f0198 100644 --- a/platforms/sdl/sdl2/base/AppPlatform_sdl2.hpp +++ b/platforms/sdl/sdl2/base/AppPlatform_sdl2.hpp @@ -34,6 +34,8 @@ class AppPlatform_sdl2 : public AppPlatform_sdl void showKeyboard(int x, int y, int w, int h) override; void hideKeyboard() override; + std::string getClipboardText() override; + // Game controller bool hasGamepad() const override; SDL_GameController* getPrimaryGameController() const { return m_pController; } diff --git a/platforms/sdl/sdl2/main.cpp b/platforms/sdl/sdl2/main.cpp index 05c6b89c0..a8e443881 100644 --- a/platforms/sdl/sdl2/main.cpp +++ b/platforms/sdl/sdl2/main.cpp @@ -130,6 +130,16 @@ static void handle_events() g_pApp->handleCharInput('\b'); } + if (g_pAppPlatform->controlPressed()) + { + // Copy and pasting + if (event.key.keysym.sym == SDLK_v && event.key.state == SDL_PRESSED) + { + g_pApp->handleTextPaste(); + break; + } + } + g_pAppPlatform->handleKeyEvent(event); break; } @@ -200,10 +210,7 @@ static void handle_events() for (size_t i = 0; i < length; i++) { char x = event.text.text[i]; - if (x >= ' ' && x <= '~') - { - g_pApp->handleCharInput(x); - } + g_pApp->handleCharInput(x); } } break; diff --git a/platforms/windows/AppPlatform_win32.cpp b/platforms/windows/AppPlatform_win32.cpp index fe45c92a5..5c072aa6d 100644 --- a/platforms/windows/AppPlatform_win32.cpp +++ b/platforms/windows/AppPlatform_win32.cpp @@ -349,6 +349,24 @@ void AppPlatform_win32::updateFocused(bool focused) setMouseGrabbed(m_bGrabbedMouse); } +std::string AppPlatform_win32::getClipboardText() +{ + if (!OpenClipboard(nullptr)) + return ""; + + HANDLE h = GetClipboardData(CF_TEXT); + if (!h) + return ""; + + GlobalLock(h); + std::string text((char*)h); + GlobalUnlock(h); + + CloseClipboard(); + + return text; +} + void AppPlatform_win32::initializeWindow(HWND hWnd, int nCmdShow) { m_hWND = hWnd; diff --git a/platforms/windows/AppPlatform_win32.hpp b/platforms/windows/AppPlatform_win32.hpp index 45a976607..65042ae5d 100644 --- a/platforms/windows/AppPlatform_win32.hpp +++ b/platforms/windows/AppPlatform_win32.hpp @@ -51,7 +51,11 @@ class AppPlatform_win32 : public AppPlatform void clearDiff() override; void updateFocused(bool focused) override; + std::string getClipboardText() override; + // Also add these to allow proper text input within the game. + bool controlPressed() override { return m_bControlPressed; } + void setControlPressed(bool b) { m_bControlPressed = b; } bool shiftPressed() override { return m_bShiftPressed; } void setShiftPressed(bool b) { m_bShiftPressed = b; } @@ -98,6 +102,7 @@ class AppPlatform_win32 : public AppPlatform bool m_bGrabbedMouse; bool m_bActuallyGrabbedMouse; bool m_bWasUnfocused; + bool m_bControlPressed; bool m_bShiftPressed; int m_MouseDiffX, m_MouseDiffY; diff --git a/platforms/windows/main.cpp b/platforms/windows/main.cpp index cb888d322..48083237b 100644 --- a/platforms/windows/main.cpp +++ b/platforms/windows/main.cpp @@ -94,6 +94,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam) if (wParam == VK_SHIFT) g_AppPlatform.setShiftPressed(state == Keyboard::KeyState::DOWN); + else if (wParam == VK_CONTROL) + g_AppPlatform.setControlPressed(state == Keyboard::KeyState::DOWN); break; } @@ -103,10 +105,17 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam) if (lParam & (1 << 31)) break; - if (wParam >= '~' && wParam < ' ') - break; + // CTRL+V corresponds to character 0x16 + if (wParam == '\x16') + { + // we are pasting text + g_pApp->handleTextPaste(); + } + else + { + g_pApp->handleCharInput(char(wParam)); + } - g_pApp->handleCharInput(char(wParam)); break; } diff --git a/source/client/app/AppPlatform.cpp b/source/client/app/AppPlatform.cpp index 9931b3020..39696635f 100644 --- a/source/client/app/AppPlatform.cpp +++ b/source/client/app/AppPlatform.cpp @@ -165,6 +165,11 @@ void AppPlatform::updateFocused(bool focused) { } +bool AppPlatform::controlPressed() +{ + return false; +} + bool AppPlatform::shiftPressed() { return false; @@ -211,6 +216,11 @@ bool AppPlatform::getRecenterMouseEveryTick() return true; } +std::string AppPlatform::getClipboardText() +{ + return ""; +} + void AppPlatform::_fireLowMemory() { diff --git a/source/client/app/AppPlatform.hpp b/source/client/app/AppPlatform.hpp index 78fc702dc..f26d7395a 100644 --- a/source/client/app/AppPlatform.hpp +++ b/source/client/app/AppPlatform.hpp @@ -83,6 +83,7 @@ class AppPlatform virtual void clearDiff(); virtual void updateFocused(bool focused); // Also add this to allow proper text input within the game. + virtual bool controlPressed(); virtual bool shiftPressed(); // On-screen keyboard virtual void showKeyboard(int x, int y, int w, int h); @@ -96,6 +97,7 @@ class AppPlatform #endif virtual void vibrate(int milliSeconds); virtual bool getRecenterMouseEveryTick(); + virtual std::string getClipboardText(); void _fireLowMemory(); void _fireAppSuspended(); diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp index 073331dc2..91bbb620e 100644 --- a/source/client/app/Minecraft.cpp +++ b/source/client/app/Minecraft.cpp @@ -608,6 +608,19 @@ void Minecraft::handleCharInput(char chr) m_pScreen->keyboardNewChar(chr); } +void Minecraft::handleTextPaste(const std::string& text) +{ + if (m_pScreen) + m_pScreen->keyboardTextPaste(text); +} + +void Minecraft::handleTextPaste() +{ + std::string text = AppPlatform::singleton()->getClipboardText(); + if (!text.empty()) + handleTextPaste(text); +} + void Minecraft::resetInput() { Keyboard::reset(); diff --git a/source/client/app/Minecraft.hpp b/source/client/app/Minecraft.hpp index 4991d7963..87fd0677f 100644 --- a/source/client/app/Minecraft.hpp +++ b/source/client/app/Minecraft.hpp @@ -59,6 +59,8 @@ class Minecraft : public App void locateMultiplayer(); void tickMouse(); void handleCharInput(char chr); + void handleTextPaste(const std::string& text); + void handleTextPaste(); void resetInput(); void sendMessage(const std::string& message); void respawnPlayer(); diff --git a/source/client/gui/Screen.cpp b/source/client/gui/Screen.cpp index 4156b659d..09b7a6e21 100644 --- a/source/client/gui/Screen.cpp +++ b/source/client/gui/Screen.cpp @@ -87,6 +87,15 @@ void Screen::keyboardNewChar(char chr) } } +void Screen::keyboardTextPaste(const std::string& text) +{ + for (int i = 0; i < int(m_textInputs.size()); i++) + { + TextInputBox* textInput = m_textInputs[i]; + textInput->pasteText(text); + } +} + void Screen::handleScroll(bool down) { } diff --git a/source/client/gui/Screen.hpp b/source/client/gui/Screen.hpp index 688cc9458..eff282454 100644 --- a/source/client/gui/Screen.hpp +++ b/source/client/gui/Screen.hpp @@ -62,6 +62,7 @@ class Screen : public GuiComponent virtual void mouseReleased(int, int, int); virtual void keyPressed(int); virtual void keyboardNewChar(char); + virtual void keyboardTextPaste(const std::string& text); virtual void handleScroll(bool down); // ported from 0.8 diff --git a/source/client/gui/components/TextInputBox.cpp b/source/client/gui/components/TextInputBox.cpp index a6d83ee71..8a2f731a4 100644 --- a/source/client/gui/components/TextInputBox.cpp +++ b/source/client/gui/components/TextInputBox.cpp @@ -16,6 +16,11 @@ #define HANDLE_CHARS_SEPARATELY // faked though, see platforms/android/minecraftcpp/minecraftcpp.NativeActivity/main.cpp #endif +static bool IsInvalidCharacter(char c) +{ + return c == '\n' || c < ' ' || c > '~'; +} + TextInputBox::TextInputBox(Screen* parent, int id, int x, int y, int width, int height, const std::string& placeholder, const std::string& text) { m_ID = id; @@ -326,7 +331,7 @@ void TextInputBox::charPressed(int k) default: { // Ignore Unprintable Characters - if (k == '\n' || k < ' ' || k > '~') + if (IsInvalidCharacter(k)) return; // Check Max Length @@ -345,6 +350,47 @@ void TextInputBox::charPressed(int k) m_pParent->onTextBoxUpdated(m_ID); } +void TextInputBox::pasteText(const std::string& text) +{ + if (!m_bFocused) + return; + + const std::string sanitizedText = _sanitizePasteText(text); + + if (!sanitizedText.empty()) + { + m_text.insert(m_insertHead, sanitizedText); + m_insertHead += int(sanitizedText.length()); + recalculateScroll(); + } +} + +std::string TextInputBox::_sanitizePasteText(const std::string& text) const +{ + // check max size, can we add any further text? + if (m_maxLength != -1 && int(m_text.length()) >= m_maxLength) + return ""; + + // sanitize the text + std::string sanitized; + sanitized.reserve(text.length()); + + for (int i = 0; i < text.length(); ++i) + { + char c = text[i]; + if (!IsInvalidCharacter(c)) + { + sanitized += c; + + // check if we can add any further text + if (m_maxLength != -1 && int(m_text.length() + sanitized.length()) >= m_maxLength) + break; + } + } + + return sanitized; +} + constexpr int PADDING = 5; std::string TextInputBox::getRenderedText(int scroll_pos, std::string text) diff --git a/source/client/gui/components/TextInputBox.hpp b/source/client/gui/components/TextInputBox.hpp index 7c184bec4..557cfdd46 100644 --- a/source/client/gui/components/TextInputBox.hpp +++ b/source/client/gui/components/TextInputBox.hpp @@ -34,6 +34,7 @@ class TextInputBox : public GuiComponent void setEnabled(bool bEnabled); void keyPressed(int key); void charPressed(int chr); + void pasteText(const std::string& text); void render(); void tick(); void setFocused(bool b); @@ -48,6 +49,9 @@ class TextInputBox : public GuiComponent int getKey() const { return m_ID; } std::string getText() const { return m_text; } +private: + std::string _sanitizePasteText(const std::string& text) const; + public: #ifndef HANDLE_CHARS_SEPARATELY char guessCharFromKey(int key); From 6fcfb44caf4c9ea660d5d320a5d7848c6487855e Mon Sep 17 00:00:00 2001 From: Matt <97983689+bluepilledgreat@users.noreply.github.com> Date: Sun, 30 Nov 2025 20:30:13 +0000 Subject: [PATCH 054/293] Fix missing onTextBoxUpdated call in pasteText (#206) --- source/client/gui/components/TextInputBox.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/client/gui/components/TextInputBox.cpp b/source/client/gui/components/TextInputBox.cpp index 8a2f731a4..c868e69b7 100644 --- a/source/client/gui/components/TextInputBox.cpp +++ b/source/client/gui/components/TextInputBox.cpp @@ -362,6 +362,8 @@ void TextInputBox::pasteText(const std::string& text) m_text.insert(m_insertHead, sanitizedText); m_insertHead += int(sanitizedText.length()); recalculateScroll(); + + m_pParent->onTextBoxUpdated(m_ID); } } From 528f9265a92b4989e753beb9d9000f73c630ed02 Mon Sep 17 00:00:00 2001 From: Matt <97983689+bluepilledgreat@users.noreply.github.com> Date: Sun, 30 Nov 2025 20:37:11 +0000 Subject: [PATCH 055/293] Fix bad ToChunkCoordinate (#207) --- source/world/level/levelgen/chunk/ChunkPos.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/world/level/levelgen/chunk/ChunkPos.hpp b/source/world/level/levelgen/chunk/ChunkPos.hpp index eec5aed06..01135b194 100644 --- a/source/world/level/levelgen/chunk/ChunkPos.hpp +++ b/source/world/level/levelgen/chunk/ChunkPos.hpp @@ -53,7 +53,7 @@ struct ChunkPos static int ToChunkCoordinate(int value) { - return value / 16; + return value >> 4; } static int ToChunkCoordinate(float value) From d81ac0f289e14fcecb3c1de7e8ce1ccef3195fa8 Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Thu, 4 Dec 2025 20:29:50 -0500 Subject: [PATCH 056/293] Add CMake build for iOS (#208) --- .github/workflows/build.yml | 42 +++--- platforms/ios/.gitignore | 1 + platforms/ios/CMakeLists.txt | 48 +++++++ platforms/ios/build-ipa.sh | 60 ++++++++ platforms/ios/build.sh | 135 ++++++++++++++++++ platforms/ios/ios-cc.sh | 23 +++ platforms/ios/precompiled/MainWindow.nib | Bin 0 -> 1187 bytes platforms/ios/precompiled/PkgInfo | 1 + .../precompiled/en.lproj/InfoPlist.strings | Bin 0 -> 42 bytes .../en.lproj/minecraftpeViewController.nib | Bin 0 -> 1677 bytes platforms/sound/openal/CMakeLists.txt | 3 + 11 files changed, 294 insertions(+), 19 deletions(-) create mode 100644 platforms/ios/.gitignore create mode 100644 platforms/ios/CMakeLists.txt create mode 100755 platforms/ios/build-ipa.sh create mode 100755 platforms/ios/build.sh create mode 100755 platforms/ios/ios-cc.sh create mode 100644 platforms/ios/precompiled/MainWindow.nib create mode 100644 platforms/ios/precompiled/PkgInfo create mode 100644 platforms/ios/precompiled/en.lproj/InfoPlist.strings create mode 100644 platforms/ios/precompiled/en.lproj/minecraftpeViewController.nib diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d3294e3cb..bdcff9bca 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -89,25 +89,29 @@ jobs: GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_DEFINITIONS)' \ -quiet \ clean archive - # @NOTE: Newer versions of Xcode will complain and refuse to build old XIB files or target old iOS versions - #ios: - # runs-on: macos-latest - # steps: - # - name: Checkout Repository - # uses: actions/checkout@v3 - # with: - # submodules: true - # - name: Build iOS Archive - # run: | - # cd platforms/macos/projects/Minecraft - # xcodebuild -scheme "minecraftpe" \ - # -archivePath $RUNNER_TEMP/GitHubActions_iOS.xcarchive \ - # -sdk iphoneos \ - # -configuration "Release [iOS] (Default)" \ - # -destination generic/platform=iOS \ - # GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_DEFINITIONS)' \ - # -quiet \ - # clean archive + ios: + name: iOS + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + with: + submodules: true + - name: Install Dependencies + run: | + wget https://apt.llvm.org/llvm.sh + sudo bash llvm.sh 21 + sudo apt-get update + sudo apt-get install --no-install-recommends -y clang-21 libplist-dev libplist-utils libssl-dev + + - name: Build iOS binary + run: ./platforms/ios/build.sh + env: + CLANG: clang-21 + AR: llvm-ar-21 + RANLIB: llvm-ranlib-21 + LIPO: llvm-lipo-21 + REMCPE_NO_IPA: 1 android: strategy: fail-fast: false diff --git a/platforms/ios/.gitignore b/platforms/ios/.gitignore new file mode 100644 index 000000000..796b96d1c --- /dev/null +++ b/platforms/ios/.gitignore @@ -0,0 +1 @@ +/build diff --git a/platforms/ios/CMakeLists.txt b/platforms/ios/CMakeLists.txt new file mode 100644 index 000000000..edcacd2a2 --- /dev/null +++ b/platforms/ios/CMakeLists.txt @@ -0,0 +1,48 @@ +cmake_minimum_required(VERSION 3.16.0) +project(reminecraftpe-ios) + +target_compile_definitions(reminecraftpe-core PUBLIC HANDLE_CHARS_SEPARATELY USE_GLES) + +set(CMAKE_CXX_STANDARD 98) + +# Build +add_executable(reminecraftpe + AppPlatform_iOS.mm + EAGLView.m + main.m + minecraftpeAppDelegate.mm + minecraftpeViewController.mm + ShowKeyboardView.mm +) + +# Core +target_link_libraries(reminecraftpe reminecraftpe-core) + +# libobjc +target_link_libraries(reminecraftpe objc) + +# frameworks +target_link_libraries(reminecraftpe + "-framework CoreGraphics" + "-framework QuartzCore" + "-framework Foundation" + "-framework AVFoundation" + "-framework UIKit" + "-framework OpenGLES" +) + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../source/client/app) + +# Check for the presence of some optional asset based features. +if(EXISTS "${MC_ROOT}/game/assets/gui/background/panorama_0.png") + target_compile_definitions(reminecraftpe PUBLIC FEATURE_MENU_BACKGROUND) +endif() +if(EXISTS "${MC_ROOT}/game/assets/environment/clouds.png") + target_compile_definitions(reminecraftpe PUBLIC FEATURE_CLOUDS) +endif() +if(EXISTS "${MC_ROOT}/game/assets/misc/grasscolor.png") + target_compile_definitions(reminecraftpe PUBLIC FEATURE_GRASS_COLOR) +endif() +if(EXISTS "${MC_ROOT}/game/assets/misc/foliagecolor.png") + target_compile_definitions(reminecraftpe PUBLIC FEATURE_FOLIAGE_COLOR) +endif() diff --git a/platforms/ios/build-ipa.sh b/platforms/ios/build-ipa.sh new file mode 100755 index 000000000..dd0db6544 --- /dev/null +++ b/platforms/ios/build-ipa.sh @@ -0,0 +1,60 @@ +#!/bin/sh +# shellcheck disable=2016 +set -e + +ipaname='ReMCPE.ipa' +# must be kept in sync with the cmake executable name +bin='reminecraftpe' +# must be kept in sync with the info.plist +execname='minecraftpe' + +platformdir='platforms/ios' +builddir="$platformdir/build" +assetdir='game/assets' +ipadir="$builddir/ipa" +apppath="$builddir/$ipadir/Payload/ReMCPE.app" + +[ "${0%/*}" = "$0" ] && scriptroot="." || scriptroot="${0%/*}" +cd "$scriptroot/../.." + +if ! [ -f "build/$bin" ]; then + printf 'Expected working binary at build/%s.\n' "$bin" + printf 'Please do a cmake build before running this script.\n' + exit 1 +fi + +if ! command -v plistutil >/dev/null; then + printf 'plistutil not found!\n' + exit 1 +fi + +rm -rf "$ipadir" +mkdir -p "$apppath" +cp "build/$bin" "$apppath/$execname" +sed -E -e "s|\$\{EXECUTABLE_NAME\}|$execname|" -e "s|\$\{PRODUCT_NAME(:rfc1034identifier)?\}|$execname|g" "$platformdir/minecraftpe-Info.plist" | + plistutil -o "$apppath/Info.plist" -f bin +cd "$assetdir" +apppath="../../$apppath" +if [ -f font/default.png ]; then + cp font/default.png "$apppath/default8.png" +elif [ -f font/default8.png ]; then + cp font/default8.png "$apppath/default8.png" +fi +cp icon.png "$apppath/Icon.png" || true +cp -a \ + "../../$platformdir/precompiled"/* \ + gui/*.png \ + mob/* \ + item/* \ + sound/* \ + sounds/random/* \ + app/launch/* \ + patches/* \ + terrain.png \ + particles.png \ + "$apppath" || true +cd "../../$ipadir" +rm -f "../$ipaname" +zip -r "../$ipaname" Payload + +printf '\nDone! Your IPA is at %s/%s\n' "$builddir" "$ipaname" diff --git a/platforms/ios/build.sh b/platforms/ios/build.sh new file mode 100755 index 000000000..83c823a9e --- /dev/null +++ b/platforms/ios/build.sh @@ -0,0 +1,135 @@ +#!/bin/sh +set -e + +[ "${0%/*}" = "$0" ] && scriptroot="." || scriptroot="${0%/*}" +cd "$scriptroot" + +# We could build for armv6, but we don't due to unplayable performance. +targets='armv7-apple-ios3 arm64-apple-ios7' +# Must be kept in sync with the cmake executable name +bin='reminecraftpe' + +platformdir='platforms/ios' +entitlements="$platformdir/minecraftpe.entitlements" + +printf '\nDownloading iOS SDK...\n\n' + +rm -rf build +mkdir -p build/work +cd build/work +workdir="$PWD" + +# The iOS 8 SDK supports arm64, armv7s, and armv7 and is small. +# It also doesn't use tbd stubs so we don't need to link ld64 with libtapi. +sdk="$workdir/ios-sdk" # must be kept in sync with the -isysroot arguement in ios-cc.sh +wget https://invoxiplaygames.uk/sdks/iPhoneOS8.0.sdk.tar.lzma +tar xf iPhoneOS8.0.sdk.tar.lzma +mv iPhoneOS8.0.sdk "$sdk" +rm iPhoneOS8.0.sdk.tar.lzma + +# Make nproc work on macOS and BSDs +nproc() { + cmd="$(command -v nproc)" + if [ -f "$cmd" ]; then + command nproc + else + sysctl -n hw.ncpu + fi +} + +if [ "$(uname -s)" = "Darwin" ]; then + ar="${AR:-ar}" + lipo="${LIPO:-lipo}" + ranlib="${RANLIB:-ranlib}" + strip='strip' +else + ar="${AR:-"llvm-ar"}" + lipo="${LIPO:-"llvm-lipo"}" + ranlib="${RANLIB:-"llvm-ranlib"}" + strip='cctools-strip' +fi + +for var in ar lipo ranlib; do + dep="$(eval "echo \$$var")" + if ! command -v "$dep" >/dev/null; then + printf '%s not found!\n' "$dep" + exit 1 + fi +done + +for dep in "${CLANG:-clang}" make cmake; do + if ! command -v "$dep" >/dev/null; then + printf '%s not found!\n' "$dep" + exit 1 + fi +done + +export REMCPE_IOS_BUILD=1 + +mkdir bin +export PATH="$PWD/bin:$PATH" + +[ -n "$CLANG" ] && ln -s "$(command -v "$CLANG")" bin/clang && ln -s clang bin/clang++ + +printf '\nBuilding ld64 and strip...\n\n' + +# this step is needed even on macOS since newer versions of Xcode will straight up not let you link for old iOS versions anymore + +cctools_commit=35dcdf0285e0a07a32799be3dc08980b6f05313c +wget -O- "https://github.com/tpoechtrager/cctools-port/archive/$cctools_commit.tar.gz" | tar -xz + +cd "cctools-port-$cctools_commit/cctools" +./configure --enable-silent-rules +make -C ld64 -j"$(nproc)" +mv ld64/src/ld/ld ../../bin/ld64.ld64 +make -C libmacho -j"$(nproc)" +make -C libstuff -j"$(nproc)" +make -C misc strip +cp misc/strip ../../bin/cctools-strip +cd ../.. +for target in $targets; do + ln -s ../../../ios-cc.sh "bin/$target-cc" + ln -s ../../../ios-cc.sh "bin/$target-c++" +done + +printf '\nBuilding ldid...\n\n' + +ldid_commit=ef330422ef001ef2aa5792f4c6970d69f3c1f478 +wget -O- "https://github.com/ProcursusTeam/ldid/archive/$ldid_commit.tar.gz" | tar -xz + +cd "ldid-$ldid_commit" +make CXX=clang++ +mv ldid ../bin + +# go to the root of the project +cd ../../../../.. + +for target in $targets; do + printf '\nBuilding for %s\n\n' "$target" + + rm -rf build + mkdir build + cd build + + cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_SYSTEM_NAME=Darwin \ + -DREMCPE_PLATFORM=ios \ + -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \ + -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \ + -DCMAKE_AR="$(command -v "$ar")" \ + -DCMAKE_RANLIB="$(command -v "$ranlib")" \ + -DCMAKE_C_COMPILER="$target-cc" \ + -DCMAKE_CXX_COMPILER="$target-c++" \ + -DCMAKE_FIND_ROOT_PATH="$sdk/usr" + make -j"$(nproc)" + mv "$bin" "$workdir/$bin-$target" + + cd .. +done + +"$lipo" -create "$workdir/$bin"-* -output "build/$bin" +"$strip" "build/$bin" +ldid -S"$entitlements" "build/$bin" + +[ -n "$REMCPE_NO_IPA" ] || "$workdir/../../build-ipa.sh" diff --git a/platforms/ios/ios-cc.sh b/platforms/ios/ios-cc.sh new file mode 100755 index 000000000..12469ce0d --- /dev/null +++ b/platforms/ios/ios-cc.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +if [ -z "$REMCPE_IOS_BUILD" ]; then + printf 'Do not run this script directly!\n' + exit 1 +fi + +case $0 in + *++) cc="clang++" ;; + *) cc="clang" ;; +esac + +target="${0##*/}" +target="${target%-*}" + +exec "$cc" \ + -mlinker-version=762 \ + -stdlib=libstdc++ \ + "$@" \ + -isysroot "${0%/*}/../ios-sdk" \ + -target "$target" \ + -fuse-ld=ld64 \ + -Wno-unused-command-line-argument diff --git a/platforms/ios/precompiled/MainWindow.nib b/platforms/ios/precompiled/MainWindow.nib new file mode 100644 index 0000000000000000000000000000000000000000..d29183c8cfb97ae8bfd26f1075449db6f21f9869 GIT binary patch literal 1187 zcmY*Y&2JM&6rXt$z$OHiBzAzN!6b&FHl)r+1Fc$8+X?9cae_B%J5K1bwkOHN%dWe# zPDo9pZ6#1u!J&dfK^$l}RXyZi;Kqqd`k@G+eyOdho_eWzX{C;LO$sy8zBljp-f!Q> zOrc^h?!;o>U?5F9T9?YxQOBy}qE=yv79F08E>oK`%bbboc5#u3(|0>}1%kVq_q6O4 zOOrZOImHUoR^>chrpBZnc8;!U(moG)-qPk-l9p)-Zb8aDzp!V`FwP1F%`&rOt@uEX z2gHj-$_2&@=B$d?dA3ls_5Z^|o|jCCQ2yV%|9?(_GCB(=47MvfeRt@rJB zPNy<+`hprYtA?=|3U?gHM2m*bc|N7|HHvmy9vnRMk_+w*ch_d<<*vh;bWoM2Z0ic6 zCBGiIL`{dyGitj{E}4@PXP80xq8X4NOjr4(Oz z(Om!KtAci?CP{T-n>%UBE0$TJ_ST8M*JGjnfx)3ShEJY)^Q|E-HI-9aHXUl~URy^Q z*F`H!IaN+rRkOr3sZ*7c2GwmY8tBj~PJ+%`HXXI~6=p7I(thEo7t0HF-92d;maR#x zsvNI6!i%#Hh0}!2%YrZ|>ZSs1e-5QewXn?S3JBelB0pzx{HV!e^rT5qH_ zbV_K01F^NWd~IMz=>5a7wXKnN#}Hx$R;UrcGQ%T9#4qCahp=Jd&EV^`$*skw^?c$>yL=-9l!3L z?3q&3S${T*%yjtrg|vwFn77CB#dNlj!81tAHaq(uHPp8bBjx z29?oA=q`GQw$Kyw6n&3=L_ecn(BJ4^3^<6}aTp)Mowy4}@KGGcNj!$rIEydgGB)v5 zd=1~ipX0mu9^SwY@l*UOG{FHl0mCo>DVTx_pnwWln1MWe09WBA+=hGbC2YVWcnsgd z6Zipsg5ThG_yhigzu+GdAkCzWbdoM|jP#K~a*~`TXNf}cL?Z>VL^!DtmwZgFlTXN} Yo%HBm;@@?u!q`Clg=%_q1%x2Vo&Dy#I41~S==-t?n$N_vZfBWB|SbS!@v7^`2~eV%a*TL z=@gw&u_Ejb$gy56*~uoE63m9}VN+4jXU18DNtY*_?vd5qZ?orNwZU?FC4El47xLN!Byb9C48sa~Ch?uAAcO(z2@R z^_!k#{rYU!ty+pQ=PIvQ)#r{Yl3@%6LR)g_bLWl9)oVEB z4xT^fdTQ;us8|{Hck9|AnI*EB`4dbvR8Mbffz#Gz&&~{HI-qYC?2zI~H6Y7JkU;z5z0wp;n z4F^JYYN4bQXW_8FCzCnMimmi%2cU|;*asyr!+}swM=Jz&=!~f~JGmg(KO(jTUnbJF zrfT@wfA7|WYx@RkjB%21W zuiL@dtv7>*EQI|Hr*VKqs%kRttn+y|9Egw+@8@p;#yv z)(M-0W?`o=AWR5Hg|~!Hgn8ki@JRSh_+I!?_!%LTkCvlSv=&t(H`;(Up?cJa_Mk2l zM8ilzfE_x5$LU+&u^e4{4b+`$);~-{O#V7D7d>Ws{=kR$vi!b0y z_%gnN-^3r{TlhBq8b83l;@=4+MWlpOkSem4)RH=~k!&W-WCv*@yGb`0AVVZhCWuL< z2`9(MMe;UzpWGxLk&nrzmO5tiw I=7huh55t@rv;Y7A literal 0 HcmV?d00001 diff --git a/platforms/sound/openal/CMakeLists.txt b/platforms/sound/openal/CMakeLists.txt index 881769405..f5e69e16e 100644 --- a/platforms/sound/openal/CMakeLists.txt +++ b/platforms/sound/openal/CMakeLists.txt @@ -22,6 +22,9 @@ if(ANDROID) elseif(EMSCRIPTEN) # Use Emscripten's OpenAL target_link_libraries(reminecraftpe-sound PUBLIC openal) +elseif(APPLE) + # Use System OpenAL Framework + target_link_libraries(reminecraftpe-sound PUBLIC "-framework OpenAL") else() # Use System OpenAL find_package(OpenAL REQUIRED) From 4fdf77e52a145fc2b9706a8240ef9a575193ef50 Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Fri, 5 Dec 2025 22:52:17 -0500 Subject: [PATCH 057/293] fix (#210) --- platforms/ios/build-ipa.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platforms/ios/build-ipa.sh b/platforms/ios/build-ipa.sh index dd0db6544..056011227 100755 --- a/platforms/ios/build-ipa.sh +++ b/platforms/ios/build-ipa.sh @@ -12,7 +12,7 @@ platformdir='platforms/ios' builddir="$platformdir/build" assetdir='game/assets' ipadir="$builddir/ipa" -apppath="$builddir/$ipadir/Payload/ReMCPE.app" +apppath="$ipadir/Payload/ReMCPE.app" [ "${0%/*}" = "$0" ] && scriptroot="." || scriptroot="${0%/*}" cd "$scriptroot/../.." From 4fbc54e04a8630e26e8d7dcc235b1e6574e5127f Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Fri, 5 Dec 2025 23:19:18 -0500 Subject: [PATCH 058/293] Fix typo (#211) --- platforms/ios/build-ipa.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platforms/ios/build-ipa.sh b/platforms/ios/build-ipa.sh index 056011227..92d707b4b 100755 --- a/platforms/ios/build-ipa.sh +++ b/platforms/ios/build-ipa.sh @@ -31,7 +31,7 @@ fi rm -rf "$ipadir" mkdir -p "$apppath" cp "build/$bin" "$apppath/$execname" -sed -E -e "s|\$\{EXECUTABLE_NAME\}|$execname|" -e "s|\$\{PRODUCT_NAME(:rfc1034identifier)?\}|$execname|g" "$platformdir/minecraftpe-Info.plist" | +sed -E -e "s|\\\$\{EXECUTABLE_NAME\}|$execname|" -e "s|\\\$\{PRODUCT_NAME(:rfc1034identifier)?\}|$execname|g" "$platformdir/minecraftpe-Info.plist" | plistutil -o "$apppath/Info.plist" -f bin cd "$assetdir" apppath="../../$apppath" From d47346d583e801c7c85a0b19c0311baff02d2921 Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Sat, 6 Dec 2025 01:52:18 -0500 Subject: [PATCH 059/293] CMake always use C++98 (#212) --- CMakeLists.txt | 8 +++++++- platforms/ios/CMakeLists.txt | 2 -- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c4d132a0..93580a9cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,12 @@ project(reminecraftpe) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") +if (WIN32 OR LINUX) +set(CMAKE_CXX_STANDARD 11) +else() +set(CMAKE_CXX_STANDARD 98) +endif() + # WASM if(EMSCRIPTEN) function(add_compile_and_link_options) @@ -70,4 +76,4 @@ endif() #VBO Emulation if(USE_GL_VBO_EMULATION) add_compile_options(-DUSE_GL_VBO_EMULATION) -endif() \ No newline at end of file +endif() diff --git a/platforms/ios/CMakeLists.txt b/platforms/ios/CMakeLists.txt index edcacd2a2..9f84deeb0 100644 --- a/platforms/ios/CMakeLists.txt +++ b/platforms/ios/CMakeLists.txt @@ -3,8 +3,6 @@ project(reminecraftpe-ios) target_compile_definitions(reminecraftpe-core PUBLIC HANDLE_CHARS_SEPARATELY USE_GLES) -set(CMAKE_CXX_STANDARD 98) - # Build add_executable(reminecraftpe AppPlatform_iOS.mm From d722c845f52e8645c01d04d7aa0b34acb486aee3 Mon Sep 17 00:00:00 2001 From: Brent <43089001+BrentDaMage@users.noreply.github.com> Date: Sun, 7 Dec 2025 00:15:00 -0800 Subject: [PATCH 060/293] Rendering Abstraction Layer (HAL) (#209) This took two years. It will allow us to add support for more platforms. :) Original functional decomp: https://github.com/BrentDaMage/mcpe-engine --- .github/workflows/build.yml | 10 +- .gitignore | 129 - CMakeLists.txt | 3 + GameMods.hpp | 1 + compat/LegacyCPP_Compat.hpp | 45 +- compat/PlatformDefinitions.h | 7 + game/.gitignore | 6 + game/assets/.gitignore | 123 + game/assets/materials/common.json | 7 + game/assets/materials/entity.material | 121 + game/assets/materials/fancy.json | 6 + game/assets/materials/fancy.material | 15 + game/assets/materials/particles.material | 15 + game/assets/materials/sad.json | 6 + game/assets/materials/sad.material | 13 + game/assets/materials/shadows.material | 108 + game/assets/materials/sky.material | 47 + game/assets/materials/terrain.material | 116 + game/assets/materials/ui.material | 228 + game/assets/materials/ui3D.material | 151 + platforms/android/AppPlatform_android.cpp | 79 - platforms/android/AppPlatform_android.hpp | 7 - platforms/ios/AppPlatform_iOS.h | 2 +- platforms/ios/AppPlatform_iOS.mm | 26 +- .../Configuration/GlobalSettings.xcconfig | 4 +- .../Configuration/Settings_iOS.xcconfig | 4 +- .../Configuration/Settings_macOS.xcconfig | 4 +- .../Minecraft.xcodeproj/project.pbxproj | 3717 ++++++----------- platforms/sdl/base/AppPlatform_sdl.cpp | 94 +- platforms/sdl/base/AppPlatform_sdl.hpp | 7 +- platforms/sdl/sdl1/base/AppPlatform_sdl1.cpp | 1 - platforms/sdl/sdl1/main.cpp | 39 +- platforms/sdl/sdl2/base/AppPlatform_sdl2.cpp | 2 - .../AppPlatform_sdl2_emscripten.cpp | 23 +- .../AppPlatform_sdl2_emscripten.hpp | 2 +- platforms/sdl/sdl2/main.cpp | 132 +- platforms/windows/AppPlatform_win32.cpp | 46 +- platforms/windows/AppPlatform_win32.hpp | 2 - platforms/windows/main.cpp | 12 +- .../windows/projects/Client/Client.vcxproj | 84 +- .../projects/Client/Client.vcxproj.filters | 267 +- .../windows/projects/Common/Common.vcxproj | 11 +- .../projects/Common/Common.vcxproj.filters | 45 +- .../windows/projects/Directory.Build.props | 4 +- .../windows/projects/OpenGL/OpenGL.vcxproj | 3 - .../projects/OpenGL/OpenGL.vcxproj.filters | 5 - .../projects/Renderer/Renderer.vcxproj | 261 +- .../Renderer/Renderer.vcxproj.filters | 727 +++- source/CMakeLists.txt | 194 +- source/client/app/AppPlatform.cpp | 89 +- source/client/app/AppPlatform.hpp | 20 +- source/client/app/AppPlatformListener.cpp | 20 + source/client/app/AppPlatformListener.hpp | 22 + source/client/app/AssetFile.hpp | 7 +- source/client/app/Minecraft.cpp | 356 +- source/client/app/Minecraft.hpp | 38 +- source/client/app/NinecraftApp.cpp | 239 +- source/client/app/NinecraftApp.hpp | 22 +- source/client/gui/Gui.cpp | 598 +-- source/client/gui/Gui.hpp | 35 +- source/client/gui/GuiComponent.cpp | 91 - source/client/gui/GuiComponent.hpp | 16 +- source/client/gui/GuiElement.cpp | 9 + source/client/gui/GuiElement.hpp | 13 + source/client/gui/IntRectangle.hpp | 17 + source/client/gui/Screen.cpp | 154 +- source/client/gui/Screen.hpp | 18 +- .../gui/components/AvailableGamesList.cpp | 4 +- source/client/gui/components/Button.cpp | 27 +- source/client/gui/components/Button.hpp | 2 +- source/client/gui/components/OptionList.cpp | 48 +- source/client/gui/components/OptionList.hpp | 8 + .../gui/components/RolledSelectionList.cpp | 210 +- .../gui/components/RolledSelectionList.hpp | 2 + .../gui/components/ScrolledSelectionList.cpp | 96 +- source/client/gui/components/TextInputBox.cpp | 4 +- .../gui/components/WorldSelectionList.cpp | 20 +- source/client/gui/screens/ChatScreen.cpp | 6 +- source/client/gui/screens/ConfirmScreen.cpp | 4 +- .../client/gui/screens/CreateWorldScreen.cpp | 8 +- source/client/gui/screens/DeathScreen.cpp | 9 +- .../gui/screens/DirectConnectScreen.cpp | 4 +- .../gui/screens/DisconnectionScreen.cpp | 2 +- .../screens/IngameBlockSelectionScreen.cpp | 21 +- .../gui/screens/InvalidLicenseScreen.cpp | 4 +- source/client/gui/screens/JoinGameScreen.cpp | 2 +- source/client/gui/screens/OptionsScreen.cpp | 4 +- source/client/gui/screens/PauseScreen.cpp | 2 +- source/client/gui/screens/ProgressScreen.cpp | 15 +- .../client/gui/screens/SavingWorldScreen.cpp | 2 +- .../client/gui/screens/SelectWorldScreen.cpp | 12 +- source/client/gui/screens/StartMenuScreen.cpp | 294 +- source/client/gui/screens/StartMenuScreen.hpp | 16 +- source/client/model/Model.cpp | 45 - source/client/model/Model.hpp | 33 - source/client/model/ModelPart.cpp | 285 -- source/client/model/{ => geom}/Cube.cpp | 5 +- source/client/model/{ => geom}/Cube.hpp | 2 +- source/client/model/geom/ModelPart.cpp | 200 + source/client/model/{ => geom}/ModelPart.hpp | 32 +- .../client/model/{ => geom}/PolygonQuad.cpp | 0 .../client/model/{ => geom}/PolygonQuad.hpp | 0 source/client/model/geom/TextureOffset.hpp | 19 + .../model/{ => models}/ChickenModel.cpp | 37 +- .../model/{ => models}/ChickenModel.hpp | 0 source/client/model/{ => models}/CowModel.cpp | 0 source/client/model/{ => models}/CowModel.hpp | 0 .../model/{ => models}/CreeperModel.cpp | 0 .../model/{ => models}/CreeperModel.hpp | 0 .../model/{ => models}/HumanoidModel.cpp | 0 .../model/{ => models}/HumanoidModel.hpp | 0 source/client/model/models/Model.cpp | 76 + source/client/model/models/Model.hpp | 59 + source/client/model/{ => models}/PigModel.cpp | 2 + source/client/model/{ => models}/PigModel.hpp | 0 .../model/{ => models}/QuadrupedModel.cpp | 19 +- .../model/{ => models}/QuadrupedModel.hpp | 0 .../model/{ => models}/SheepFurModel.cpp | 0 .../model/{ => models}/SheepFurModel.hpp | 0 .../client/model/{ => models}/SheepModel.cpp | 0 .../client/model/{ => models}/SheepModel.hpp | 0 .../model/{ => models}/SkeletonModel.cpp | 2 + .../model/{ => models}/SkeletonModel.hpp | 0 .../client/model/{ => models}/SpiderModel.cpp | 32 +- .../client/model/{ => models}/SpiderModel.hpp | 0 .../client/model/{ => models}/ZombieModel.cpp | 0 .../client/model/{ => models}/ZombieModel.hpp | 0 .../network/ClientSideNetworkHandler.cpp | 6 +- .../client/player/input/TouchInputHolder.cpp | 2 +- .../player/input/TouchscreenInput_TestFps.cpp | 15 +- source/client/renderer/Chunk.cpp | 136 +- source/client/renderer/Chunk.hpp | 38 +- source/client/renderer/Culler.cpp | 2 +- source/client/renderer/Culler.hpp | 7 +- source/client/renderer/DynamicTexture.cpp | 4 +- source/client/renderer/DynamicTexture.hpp | 2 +- source/client/renderer/Fog.cpp | 41 + source/client/renderer/Fog.hpp | 20 + source/client/renderer/FoliageColor.cpp | 6 +- source/client/renderer/FoliageColor.hpp | 6 +- source/client/renderer/Font.cpp | 59 +- source/client/renderer/Font.hpp | 19 +- source/client/renderer/Frustum.cpp | 104 +- source/client/renderer/Frustum.hpp | 15 +- source/client/renderer/FrustumCuller.cpp | 29 +- source/client/renderer/FrustumCuller.hpp | 7 +- source/client/renderer/GameRenderer.cpp | 808 ++-- source/client/renderer/GameRenderer.hpp | 44 +- source/client/renderer/GrassColor.cpp | 6 +- source/client/renderer/GrassColor.hpp | 6 +- source/client/renderer/ItemInHandRenderer.cpp | 346 +- source/client/renderer/ItemInHandRenderer.hpp | 25 +- source/client/renderer/LevelRenderer.cpp | 1293 +++--- source/client/renderer/LevelRenderer.hpp | 152 +- source/client/renderer/Lighting.cpp | 60 +- source/client/renderer/Lighting.hpp | 13 +- source/client/renderer/PatchManager.cpp | 31 +- source/client/renderer/PatchManager.hpp | 3 +- source/client/renderer/RenderChunk.cpp | 113 +- source/client/renderer/RenderChunk.hpp | 86 +- source/client/renderer/RenderList.cpp | 96 +- source/client/renderer/RenderList.hpp | 24 +- source/client/renderer/ScreenRenderer.cpp | 132 + source/client/renderer/ScreenRenderer.hpp | 50 + source/client/renderer/Tesselator.cpp | 531 +-- source/client/renderer/Tesselator.hpp | 148 +- source/client/renderer/Textures.cpp | 210 +- source/client/renderer/Textures.hpp | 32 +- source/client/renderer/TileRenderer.cpp | 587 +-- source/client/renderer/TileRenderer.hpp | 27 +- .../client/renderer/entity/ArrowRenderer.cpp | 129 +- .../client/renderer/entity/ArrowRenderer.hpp | 14 +- .../renderer/entity/ChickenRenderer.cpp | 8 +- .../renderer/entity/ChickenRenderer.hpp | 2 +- .../renderer/entity/CreeperRenderer.cpp | 22 +- .../renderer/entity/CreeperRenderer.hpp | 4 +- .../entity/EntityRenderDispatcher.cpp | 116 +- .../entity/EntityRenderDispatcher.hpp | 26 +- .../client/renderer/entity/EntityRenderer.cpp | 154 +- .../client/renderer/entity/EntityRenderer.hpp | 38 +- .../renderer/entity/FallingTileRenderer.cpp | 24 +- .../renderer/entity/FallingTileRenderer.hpp | 15 +- .../renderer/entity/HumanoidMobRenderer.cpp | 67 +- .../renderer/entity/HumanoidMobRenderer.hpp | 5 +- .../client/renderer/entity/ItemRenderer.cpp | 113 +- .../client/renderer/entity/ItemRenderer.hpp | 30 +- .../renderer/entity/ItemSpriteRenderer.cpp | 29 +- .../renderer/entity/ItemSpriteRenderer.hpp | 2 +- source/client/renderer/entity/MobRenderer.cpp | 227 +- source/client/renderer/entity/MobRenderer.hpp | 24 +- .../client/renderer/entity/RocketRenderer.cpp | 14 +- .../client/renderer/entity/RocketRenderer.hpp | 4 +- .../client/renderer/entity/SheepRenderer.cpp | 14 +- .../client/renderer/entity/SheepRenderer.hpp | 2 +- .../client/renderer/entity/SpiderRenderer.cpp | 13 +- .../client/renderer/entity/SpiderRenderer.hpp | 4 +- source/client/renderer/entity/TntRenderer.cpp | 37 +- source/client/renderer/entity/TntRenderer.hpp | 11 +- .../renderer/entity/TripodCameraRenderer.cpp | 47 +- .../renderer/entity/TripodCameraRenderer.hpp | 7 +- .../renderer/renderer/EntityShaderManager.cpp | 38 + .../renderer/renderer/EntityShaderManager.hpp | 26 + .../renderer/renderer/RenderMaterialGroup.cpp | 244 ++ .../renderer/renderer/RenderMaterialGroup.hpp | 52 + source/client/renderer/texture/ColorSpace.hpp | 7 + source/client/renderer/texture/ImageData.cpp | 91 + source/client/renderer/texture/ImageData.hpp | 27 + .../client/renderer/texture/TextureData.cpp | 175 + .../client/renderer/texture/TextureData.hpp | 54 + source/common/Matrix.cpp | 62 - source/common/Matrix.hpp | 31 - source/common/Util.cpp | 42 + source/common/Util.hpp | 5 + source/common/Utils.hpp | 8 +- source/common/math/Color.cpp | 80 + source/common/math/Color.hpp | 119 + source/common/utility/AlignmentHelper.cpp | 17 + source/common/utility/AlignmentHelper.hpp | 10 + source/common/utility/InheritanceTree.hpp | 75 + source/common/utility/JsonParser.cpp | 2 + source/common/utility/JsonParser.hpp | 28 + source/common/utility/Singleton.cpp | 3 + source/common/utility/Singleton.hpp | 70 + source/renderer/Attribute.cpp | 24 + source/renderer/Attribute.hpp | 23 + source/renderer/ConstantBufferMetaData.cpp | 53 + source/renderer/ConstantBufferMetaData.hpp | 26 + .../ConstantBufferMetaDataManager.cpp | 119 + .../ConstantBufferMetaDataManager.hpp | 24 + source/renderer/EnableScissorTest.cpp | 32 + source/renderer/EnableScissorTest.hpp | 22 + source/renderer/EntityConstants.cpp | 110 + source/renderer/EntityConstants.hpp | 24 + source/renderer/GL/GL.cpp | 53 +- source/renderer/GL/GL.hpp | 12 +- .../renderer/GlobalConstantBufferManager.cpp | 38 + .../renderer/GlobalConstantBufferManager.hpp | 23 + source/renderer/GlobalConstantBuffers.cpp | 13 + source/renderer/GlobalConstantBuffers.hpp | 26 + source/renderer/MaterialPtr.cpp | 84 + source/renderer/MaterialPtr.hpp | 38 + source/renderer/MatrixStack.cpp | 196 + source/renderer/MatrixStack.hpp | 100 + source/renderer/Mesh.cpp | 182 + source/renderer/Mesh.hpp | 45 + source/renderer/PerFrameConstants.cpp | 112 + source/renderer/PerFrameConstants.hpp | 24 + source/renderer/PlatformDefinitions.h | 58 + source/renderer/QuadIndexBuffer.cpp | 108 + source/renderer/QuadIndexBuffer.hpp | 30 + source/renderer/RenderChunkConstants.cpp | 28 + source/renderer/RenderChunkConstants.hpp | 18 + source/renderer/RenderContextImmediate.cpp | 14 + source/renderer/RenderContextImmediate.hpp | 13 + source/renderer/RenderMaterial.cpp | 305 ++ source/renderer/RenderMaterial.hpp | 72 + source/renderer/ShaderConstants.cpp | 78 + source/renderer/ShaderConstants.hpp | 26 + source/renderer/ShaderGroup.cpp | 119 + source/renderer/ShaderGroup.hpp | 29 + source/renderer/ShaderGroupBase.cpp | 7 + source/renderer/ShaderGroupBase.hpp | 20 + source/renderer/StencilRefObject.cpp | 18 + source/renderer/StencilRefObject.hpp | 25 + source/renderer/TextureGroup.cpp | 0 source/renderer/TextureGroup.hpp | 0 source/renderer/TexturePtr.cpp | 0 source/renderer/TexturePtr.hpp | 0 source/renderer/UniformMetaData.cpp | 17 + source/renderer/UniformMetaData.hpp | 24 + source/renderer/VertexFormat.cpp | 77 + source/renderer/VertexFormat.hpp | 49 + source/renderer/WeatherConstants.cpp | 126 + source/renderer/WeatherConstants.hpp | 25 + source/renderer/WorldConstants.cpp | 104 + source/renderer/WorldConstants.hpp | 21 + source/renderer/hal/BlendStateDescription.cpp | 24 + source/renderer/hal/BlendStateDescription.hpp | 20 + .../hal/DepthStencilStateDescription.cpp | 35 + .../hal/DepthStencilStateDescription.hpp | 28 + .../hal/FixedPipelineStateDescription.cpp | 25 + .../hal/FixedPipelineStateDescription.hpp | 19 + source/renderer/hal/FogStateDescription.cpp | 27 + source/renderer/hal/FogStateDescription.hpp | 22 + source/renderer/hal/ImageDescription.cpp | 19 + source/renderer/hal/ImageDescription.hpp | 19 + .../hal/RasterizerStateDescription.cpp | 21 + .../hal/RasterizerStateDescription.hpp | 18 + source/renderer/hal/ShaderStage.hpp | 13 + .../renderer/hal/StencilFaceDescription.cpp | 24 + .../renderer/hal/StencilFaceDescription.hpp | 20 + source/renderer/hal/TextureDescription.cpp | 12 + source/renderer/hal/TextureDescription.hpp | 19 + source/renderer/hal/base/BlendStateBase.cpp | 18 + source/renderer/hal/base/BlendStateBase.hpp | 18 + source/renderer/hal/base/BufferBase.cpp | 77 + source/renderer/hal/base/BufferBase.hpp | 39 + .../renderer/hal/base/ConstantBufferBase.cpp | 13 + .../renderer/hal/base/ConstantBufferBase.hpp | 18 + .../hal/base/ConstantBufferConstantsBase.cpp | 14 + .../hal/base/ConstantBufferConstantsBase.hpp | 19 + .../hal/base/ConstantBufferContainerBase.cpp | 114 + .../hal/base/ConstantBufferContainerBase.hpp | 53 + .../hal/base/DepthStencilStateBase.cpp | 17 + .../hal/base/DepthStencilStateBase.hpp | 20 + .../hal/base/FixedPipelineStateBase.cpp | 17 + .../hal/base/FixedPipelineStateBase.hpp | 23 + source/renderer/hal/base/FogStateBase.cpp | 18 + source/renderer/hal/base/FogStateBase.hpp | 18 + .../hal/base/FrameBufferObjectBase.cpp | 0 .../hal/base/FrameBufferObjectBase.hpp | 0 .../renderer/hal/base/ImmediateBufferBase.cpp | 20 + .../renderer/hal/base/ImmediateBufferBase.hpp | 19 + .../renderer/hal/base/RasterizerStateBase.cpp | 17 + .../renderer/hal/base/RasterizerStateBase.hpp | 19 + .../renderer/hal/base/RenderContextBase.cpp | 129 + .../renderer/hal/base/RenderContextBase.hpp | 62 + .../hal/base/RenderContextStateBase.cpp | 17 + .../hal/base/RenderContextStateBase.hpp | 31 + source/renderer/hal/base/RenderDeviceBase.cpp | 28 + source/renderer/hal/base/RenderDeviceBase.hpp | 27 + source/renderer/hal/base/ShaderBase.cpp | 76 + source/renderer/hal/base/ShaderBase.hpp | 37 + .../renderer/hal/base/ShaderConstantBase.cpp | 35 + .../renderer/hal/base/ShaderConstantBase.hpp | 35 + .../hal/base/ShaderConstantWithDataBase.cpp | 1 + .../hal/base/ShaderConstantWithDataBase.hpp | 25 + .../renderer/hal/base/ShaderContextBase.cpp | 0 .../renderer/hal/base/ShaderContextBase.hpp | 0 .../renderer/hal/base/ShaderProgramBase.cpp | 9 + .../renderer/hal/base/ShaderProgramBase.hpp | 21 + source/renderer/hal/base/TextureBase.cpp | 96 + source/renderer/hal/base/TextureBase.hpp | 47 + source/renderer/hal/enums/BlendTarget.hpp | 17 + .../hal/enums/BlendTarget_JsonParser.cpp | 27 + source/renderer/hal/enums/BufferType.hpp | 14 + source/renderer/hal/enums/ColorWriteMask.hpp | 14 + source/renderer/hal/enums/ComparisonFunc.hpp | 16 + .../hal/enums/ComparisonFunc_JsonParser.cpp | 27 + source/renderer/hal/enums/CullMode.hpp | 11 + source/renderer/hal/enums/DepthWriteMask.hpp | 10 + source/renderer/hal/enums/FogMode.hpp | 11 + source/renderer/hal/enums/PrimitiveMode.hpp | 18 + .../hal/enums/PrimitiveMode_JsonParser.cpp | 27 + source/renderer/hal/enums/RenderState.hpp | 21 + .../hal/enums/RenderState_JsonParser.cpp | 13 + .../hal/enums/RenderState_JsonParser.hpp | 26 + source/renderer/hal/enums/ShadeMode.hpp | 10 + .../hal/enums/ShaderPrimitiveTypes.cpp | 32 + .../hal/enums/ShaderPrimitiveTypes.hpp | 47 + .../renderer/hal/enums/ShaderStagesBits.hpp | 14 + .../hal/enums/ShaderStagesBits_JsonParser.cpp | 23 + source/renderer/hal/enums/ShaderType.hpp | 15 + source/renderer/hal/enums/StencilMask.hpp | 10 + source/renderer/hal/enums/StencilOp.hpp | 13 + .../hal/enums/StencilOp_JsonParser.cpp | 22 + .../renderer/hal/enums/TextureFiltering.hpp | 14 + .../hal/enums/TextureFiltering_JsonParser.cpp | 26 + source/renderer/hal/enums/TextureFormat.hpp | 44 + source/renderer/hal/enums/VertexField.hpp | 26 + source/renderer/hal/enums/VertexFieldType.hpp | 12 + .../hal/enums/VertexField_JsonParser.cpp | 30 + source/renderer/hal/helpers/ErrorHandler.cpp | 23 + source/renderer/hal/helpers/ErrorHandler.hpp | 10 + source/renderer/hal/helpers/TextureHelper.cpp | 17 + source/renderer/hal/helpers/TextureHelper.hpp | 12 + source/renderer/hal/interface/BlendState.cpp | 10 + source/renderer/hal/interface/BlendState.hpp | 13 + source/renderer/hal/interface/Buffer.cpp | 25 + source/renderer/hal/interface/Buffer.hpp | 19 + .../renderer/hal/interface/ConstantBuffer.cpp | 1 + .../renderer/hal/interface/ConstantBuffer.hpp | 11 + .../hal/interface/ConstantBufferConstants.hpp | 11 + .../hal/interface/ConstantBufferContainer.cpp | 8 + .../hal/interface/ConstantBufferContainer.hpp | 13 + .../hal/interface/DepthStencilState.cpp | 8 + .../hal/interface/DepthStencilState.hpp | 13 + .../hal/interface/FixedPipelineState.cpp | 8 + .../hal/interface/FixedPipelineState.hpp | 13 + source/renderer/hal/interface/FogState.cpp | 8 + source/renderer/hal/interface/FogState.hpp | 13 + .../hal/interface/ImmediateBuffer.cpp | 8 + .../hal/interface/ImmediateBuffer.hpp | 13 + .../hal/interface/RasterizerState.cpp | 8 + .../hal/interface/RasterizerState.hpp | 13 + .../renderer/hal/interface/RenderContext.cpp | 14 + .../renderer/hal/interface/RenderContext.hpp | 16 + .../renderer/hal/interface/RenderDevice.cpp | 38 + .../renderer/hal/interface/RenderDevice.hpp | 22 + source/renderer/hal/interface/Shader.cpp | 8 + source/renderer/hal/interface/Shader.hpp | 14 + .../renderer/hal/interface/ShaderConstant.hpp | 12 + .../hal/interface/ShaderConstantWithData.cpp | 0 .../hal/interface/ShaderConstantWithData.hpp | 34 + .../renderer/hal/interface/ShaderProgram.cpp | 8 + .../renderer/hal/interface/ShaderProgram.hpp | 16 + source/renderer/hal/interface/Texture.cpp | 20 + source/renderer/hal/interface/Texture.hpp | 17 + source/renderer/hal/null/BlendStateNull.cpp | 10 + source/renderer/hal/null/BlendStateNull.hpp | 15 + source/renderer/hal/null/BufferNull.cpp | 8 + source/renderer/hal/null/BufferNull.hpp | 17 + .../hal/null/ConstantBufferContainerNull.cpp | 8 + .../hal/null/ConstantBufferContainerNull.hpp | 12 + .../hal/null/DepthStencilStateNull.cpp | 8 + .../hal/null/DepthStencilStateNull.hpp | 12 + .../hal/null/FixedPipelineStateNull.cpp | 8 + .../hal/null/FixedPipelineStateNull.hpp | 12 + source/renderer/hal/null/FogStateNull.cpp | 8 + source/renderer/hal/null/FogStateNull.hpp | 12 + .../renderer/hal/null/ImmediateBufferNull.cpp | 8 + .../renderer/hal/null/ImmediateBufferNull.hpp | 12 + .../renderer/hal/null/RasterizerStateNull.cpp | 8 + .../renderer/hal/null/RasterizerStateNull.hpp | 12 + .../renderer/hal/null/RenderContextNull.cpp | 8 + .../renderer/hal/null/RenderContextNull.hpp | 12 + source/renderer/hal/null/RenderDeviceNull.cpp | 1 + source/renderer/hal/null/RenderDeviceNull.hpp | 10 + .../renderer/hal/null/ShaderConstantNull.cpp | 3 + .../renderer/hal/null/ShaderConstantNull.hpp | 12 + .../hal/null/ShaderConstantWithDataNull.cpp | 3 + .../hal/null/ShaderConstantWithDataNull.hpp | 18 + source/renderer/hal/null/ShaderNull.cpp | 8 + source/renderer/hal/null/ShaderNull.hpp | 13 + .../renderer/hal/null/ShaderProgramNull.cpp | 8 + .../renderer/hal/null/ShaderProgramNull.hpp | 12 + source/renderer/hal/null/TextureNull.cpp | 8 + source/renderer/hal/null/TextureNull.hpp | 12 + source/renderer/hal/ogl/API_OGL.cpp | 185 + source/renderer/hal/ogl/API_OGL.hpp | 52 + source/renderer/hal/ogl/BlendStateOGL.cpp | 81 + source/renderer/hal/ogl/BlendStateOGL.hpp | 28 + source/renderer/hal/ogl/BufferOGL.cpp | 143 + source/renderer/hal/ogl/BufferOGL.hpp | 37 + .../hal/ogl/ConstantBufferContainerOGL.cpp | 13 + .../hal/ogl/ConstantBufferContainerOGL.hpp | 14 + .../renderer/hal/ogl/DepthStencilStateOGL.cpp | 165 + .../renderer/hal/ogl/DepthStencilStateOGL.hpp | 42 + .../hal/ogl/FixedPipelineStateOGL.cpp | 55 + .../hal/ogl/FixedPipelineStateOGL.hpp | 23 + source/renderer/hal/ogl/FogStateOGL.cpp | 103 + source/renderer/hal/ogl/FogStateOGL.hpp | 27 + source/renderer/hal/ogl/GPUEventsOGL.cpp | 13 + source/renderer/hal/ogl/GPUEventsOGL.hpp | 11 + .../renderer/hal/ogl/ImmediateBufferOGL.cpp | 62 + .../renderer/hal/ogl/ImmediateBufferOGL.hpp | 19 + source/renderer/hal/ogl/ProfileSectionOGL.cpp | 0 source/renderer/hal/ogl/ProfileSectionOGL.hpp | 0 .../renderer/hal/ogl/RasterizerStateOGL.cpp | 96 + .../renderer/hal/ogl/RasterizerStateOGL.hpp | 25 + source/renderer/hal/ogl/RenderContextOGL.cpp | 310 ++ source/renderer/hal/ogl/RenderContextOGL.hpp | 93 + source/renderer/hal/ogl/RenderDeviceOGL.cpp | 1 + source/renderer/hal/ogl/RenderDeviceOGL.hpp | 10 + source/renderer/hal/ogl/ResourceOGL.cpp | 0 source/renderer/hal/ogl/ResourceOGL.hpp | 0 source/renderer/hal/ogl/ShaderConstantOGL.cpp | 8 + source/renderer/hal/ogl/ShaderConstantOGL.hpp | 12 + .../hal/ogl/ShaderConstantWithDataOGL.cpp | 30 + .../hal/ogl/ShaderConstantWithDataOGL.hpp | 25 + source/renderer/hal/ogl/ShaderOGL.cpp | 285 ++ source/renderer/hal/ogl/ShaderOGL.hpp | 55 + source/renderer/hal/ogl/ShaderProgramOGL.cpp | 59 + source/renderer/hal/ogl/ShaderProgramOGL.hpp | 25 + source/renderer/hal/ogl/ShaderResourceOGL.cpp | 12 + source/renderer/hal/ogl/ShaderResourceOGL.hpp | 20 + source/renderer/hal/ogl/ShaderUniformOGL.cpp | 18 + source/renderer/hal/ogl/ShaderUniformOGL.hpp | 19 + source/renderer/hal/ogl/TextureOGL.cpp | 210 + source/renderer/hal/ogl/TextureOGL.hpp | 52 + source/renderer/platform/ogl/Extensions.cpp | 1000 +++++ source/renderer/platform/ogl/Extensions.hpp | 18 + .../renderer/platform/ogl/ShaderPrecision.cpp | 92 + .../renderer/platform/ogl/ShaderPrecision.hpp | 39 + source/server/ServerSideNetworkHandler.cpp | 6 +- source/world/entity/Arrow.cpp | 2 +- source/world/entity/Chicken.cpp | 2 +- source/world/entity/Cow.cpp | 2 +- source/world/entity/Creeper.cpp | 2 +- source/world/entity/Entity.cpp | 34 +- source/world/entity/Entity.hpp | 61 +- source/world/entity/FallingTile.cpp | 2 +- source/world/entity/ItemEntity.cpp | 2 +- source/world/entity/Mob.cpp | 20 - source/world/entity/Mob.hpp | 4 +- source/world/entity/Pig.cpp | 2 +- source/world/entity/Player.cpp | 9 +- source/world/entity/Player.hpp | 3 +- source/world/entity/PrimedTnt.cpp | 2 +- source/world/entity/Rocket.cpp | 2 +- source/world/entity/Sheep.cpp | 36 +- source/world/entity/Sheep.hpp | 3 +- source/world/entity/Skeleton.cpp | 4 +- source/world/entity/Skeleton.hpp | 2 +- source/world/entity/Spider.cpp | 2 +- source/world/entity/TripodCamera.cpp | 2 +- source/world/entity/Zombie.cpp | 2 +- source/world/gamemode/CreativeMode.cpp | 8 +- source/world/gamemode/SurvivalMode.cpp | 10 +- source/world/level/Dimension.cpp | 26 +- source/world/level/Dimension.hpp | 15 +- source/world/level/Explosion.hpp | 2 +- source/world/level/Level.cpp | 18 +- source/world/level/Level.hpp | 8 +- source/world/level/Region.cpp | 2 +- source/world/level/TilePos.cpp | 2 +- source/world/particle/ParticleEngine.cpp | 31 +- source/world/particle/ParticleEngine.hpp | 15 +- source/world/phys/HitResult.cpp | 6 +- source/world/phys/HitResult.hpp | 14 +- source/world/phys/Vec2.cpp | 12 +- source/world/phys/Vec2.hpp | 12 +- source/world/phys/Vec3.cpp | 13 +- source/world/phys/Vec3.hpp | 14 +- source/world/tile/Bush.cpp | 3 +- source/world/tile/Bush.hpp | 16 +- source/world/tile/CactusTile.cpp | 3 +- source/world/tile/CactusTile.hpp | 2 +- source/world/tile/DoorTile.cpp | 3 +- source/world/tile/DoorTile.hpp | 2 +- source/world/tile/FenceTile.cpp | 2 +- source/world/tile/FenceTile.hpp | 2 +- source/world/tile/FireTile.cpp | 4 +- source/world/tile/FireTile.hpp | 2 +- source/world/tile/GlassTile.cpp | 9 +- source/world/tile/GlassTile.hpp | 1 - source/world/tile/GrassTile.cpp | 1 + source/world/tile/IceTile.cpp | 6 +- source/world/tile/IceTile.hpp | 1 - source/world/tile/InvisibleTile.cpp | 2 +- source/world/tile/InvisibleTile.hpp | 2 +- source/world/tile/LadderTile.cpp | 3 +- source/world/tile/LadderTile.hpp | 2 +- source/world/tile/LeafTile.cpp | 1 + source/world/tile/LiquidTile.cpp | 8 +- source/world/tile/LiquidTile.hpp | 3 +- source/world/tile/ReedTile.cpp | 5 +- source/world/tile/ReedTile.hpp | 2 +- source/world/tile/RocketLauncherTile.cpp | 3 +- source/world/tile/RocketLauncherTile.hpp | 2 +- source/world/tile/StairTile.cpp | 4 +- source/world/tile/StairTile.hpp | 4 +- source/world/tile/TallGrass.cpp | 2 +- source/world/tile/TallGrass.hpp | 2 +- source/world/tile/Tile.cpp | 9 +- source/world/tile/Tile.hpp | 52 +- source/world/tile/TorchTile.cpp | 3 +- source/world/tile/TorchTile.hpp | 2 +- source/world/tile/Web.cpp | 3 +- source/world/tile/Web.hpp | 2 +- thirdparty/GL/GL.hpp | 139 +- thirdparty/GL/GLExt.cpp | 540 --- thirdparty/glm/CMakeLists.txt | 42 + thirdparty/glm/common.hpp | 34 + thirdparty/glm/detail/_features.hpp | 427 ++ thirdparty/glm/detail/_fixes.hpp | 55 + thirdparty/glm/detail/_literals.hpp | 51 + thirdparty/glm/detail/_noise.hpp | 130 + thirdparty/glm/detail/_swizzle.hpp | 840 ++++ thirdparty/glm/detail/_swizzle_func.hpp | 724 ++++ thirdparty/glm/detail/_vectorize.hpp | 217 + thirdparty/glm/detail/dummy.cpp | 190 + thirdparty/glm/detail/func_common.hpp | 472 +++ thirdparty/glm/detail/func_common.inl | 1036 +++++ thirdparty/glm/detail/func_exponential.hpp | 132 + thirdparty/glm/detail/func_exponential.inl | 247 ++ thirdparty/glm/detail/func_geometric.hpp | 151 + thirdparty/glm/detail/func_geometric.inl | 339 ++ thirdparty/glm/detail/func_integer.hpp | 203 + thirdparty/glm/detail/func_integer.inl | 654 +++ thirdparty/glm/detail/func_matrix.hpp | 179 + thirdparty/glm/detail/func_matrix.inl | 460 ++ thirdparty/glm/detail/func_noise.hpp | 92 + thirdparty/glm/detail/func_noise.inl | 384 ++ thirdparty/glm/detail/func_packing.hpp | 195 + thirdparty/glm/detail/func_packing.inl | 120 + thirdparty/glm/detail/func_trigonometric.hpp | 203 + thirdparty/glm/detail/func_trigonometric.inl | 246 ++ .../glm/detail/func_vector_relational.hpp | 145 + .../glm/detail/func_vector_relational.inl | 159 + thirdparty/glm/detail/glm.cpp | 288 ++ thirdparty/glm/detail/hint.hpp | 40 + thirdparty/glm/detail/intrinsic_common.hpp | 89 + thirdparty/glm/detail/intrinsic_common.inl | 313 ++ .../glm/detail/intrinsic_exponential.hpp | 79 + .../glm/detail/intrinsic_exponential.inl | 27 + thirdparty/glm/detail/intrinsic_geometric.hpp | 76 + thirdparty/glm/detail/intrinsic_geometric.inl | 146 + thirdparty/glm/detail/intrinsic_integer.hpp | 50 + thirdparty/glm/detail/intrinsic_integer.inl | 139 + thirdparty/glm/detail/intrinsic_matrix.hpp | 69 + thirdparty/glm/detail/intrinsic_matrix.inl | 1070 +++++ .../glm/detail/intrinsic_trigonometric.hpp | 48 + .../glm/detail/intrinsic_trigonometric.inl | 27 + .../detail/intrinsic_vector_relational.hpp | 48 + .../detail/intrinsic_vector_relational.inl | 366 ++ thirdparty/glm/detail/precision.hpp | 43 + thirdparty/glm/detail/precision.inl | 0 thirdparty/glm/detail/setup.hpp | 778 ++++ thirdparty/glm/detail/type_float.hpp | 95 + thirdparty/glm/detail/type_gentype.hpp | 223 + thirdparty/glm/detail/type_gentype.inl | 366 ++ thirdparty/glm/detail/type_half.hpp | 51 + thirdparty/glm/detail/type_half.inl | 273 ++ thirdparty/glm/detail/type_int.hpp | 191 + thirdparty/glm/detail/type_mat.hpp | 795 ++++ thirdparty/glm/detail/type_mat.inl | 27 + thirdparty/glm/detail/type_mat2x2.hpp | 249 ++ thirdparty/glm/detail/type_mat2x2.inl | 654 +++ thirdparty/glm/detail/type_mat2x3.hpp | 211 + thirdparty/glm/detail/type_mat2x3.inl | 588 +++ thirdparty/glm/detail/type_mat2x4.hpp | 213 + thirdparty/glm/detail/type_mat2x4.inl | 607 +++ thirdparty/glm/detail/type_mat3x2.hpp | 216 + thirdparty/glm/detail/type_mat3x2.inl | 621 +++ thirdparty/glm/detail/type_mat3x3.hpp | 253 ++ thirdparty/glm/detail/type_mat3x3.inl | 784 ++++ thirdparty/glm/detail/type_mat3x4.hpp | 216 + thirdparty/glm/detail/type_mat3x4.inl | 653 +++ thirdparty/glm/detail/type_mat4x2.hpp | 222 + thirdparty/glm/detail/type_mat4x2.inl | 672 +++ thirdparty/glm/detail/type_mat4x3.hpp | 222 + thirdparty/glm/detail/type_mat4x3.inl | 704 ++++ thirdparty/glm/detail/type_mat4x4.hpp | 260 ++ thirdparty/glm/detail/type_mat4x4.inl | 902 ++++ thirdparty/glm/detail/type_vec.hpp | 516 +++ thirdparty/glm/detail/type_vec.inl | 27 + thirdparty/glm/detail/type_vec1.hpp | 277 ++ thirdparty/glm/detail/type_vec1.inl | 811 ++++ thirdparty/glm/detail/type_vec2.hpp | 315 ++ thirdparty/glm/detail/type_vec2.inl | 831 ++++ thirdparty/glm/detail/type_vec3.hpp | 333 ++ thirdparty/glm/detail/type_vec3.inl | 881 ++++ thirdparty/glm/detail/type_vec4.hpp | 376 ++ thirdparty/glm/detail/type_vec4.inl | 992 +++++ thirdparty/glm/exponential.hpp | 34 + thirdparty/glm/ext.hpp | 138 + thirdparty/glm/fwd.hpp | 2598 ++++++++++++ thirdparty/glm/geometric.hpp | 34 + thirdparty/glm/glm.hpp | 117 + thirdparty/glm/gtc/constants.hpp | 185 + thirdparty/glm/gtc/constants.inl | 182 + thirdparty/glm/gtc/epsilon.hpp | 101 + thirdparty/glm/gtc/epsilon.inl | 150 + thirdparty/glm/gtc/matrix_access.hpp | 87 + thirdparty/glm/gtc/matrix_access.inl | 88 + thirdparty/glm/gtc/matrix_integer.hpp | 514 +++ thirdparty/glm/gtc/matrix_inverse.hpp | 74 + thirdparty/glm/gtc/matrix_inverse.inl | 163 + thirdparty/glm/gtc/matrix_transform.hpp | 306 ++ thirdparty/glm/gtc/matrix_transform.inl | 442 ++ thirdparty/glm/gtc/noise.hpp | 81 + thirdparty/glm/gtc/noise.inl | 838 ++++ thirdparty/glm/gtc/packing.hpp | 478 +++ thirdparty/glm/gtc/packing.inl | 496 +++ thirdparty/glm/gtc/quaternion.hpp | 404 ++ thirdparty/glm/gtc/quaternion.inl | 925 ++++ thirdparty/glm/gtc/random.hpp | 114 + thirdparty/glm/gtc/random.inl | 171 + thirdparty/glm/gtc/reciprocal.hpp | 133 + thirdparty/glm/gtc/reciprocal.inl | 202 + thirdparty/glm/gtc/type_precision.hpp | 874 ++++ thirdparty/glm/gtc/type_precision.inl | 32 + thirdparty/glm/gtc/type_ptr.hpp | 179 + thirdparty/glm/gtc/type_ptr.inl | 475 +++ thirdparty/glm/gtc/ulp.hpp | 92 + thirdparty/glm/gtc/ulp.inl | 338 ++ thirdparty/glm/gtx/associated_min_max.hpp | 106 + thirdparty/glm/gtx/associated_min_max.inl | 912 ++++ thirdparty/glm/gtx/bit.hpp | 234 ++ thirdparty/glm/gtx/bit.inl | 782 ++++ thirdparty/glm/gtx/closest_point.hpp | 66 + thirdparty/glm/gtx/closest_point.inl | 36 + thirdparty/glm/gtx/color_space.hpp | 96 + thirdparty/glm/gtx/color_space.inl | 149 + thirdparty/glm/gtx/color_space_YCoCg.hpp | 84 + thirdparty/glm/gtx/color_space_YCoCg.inl | 64 + thirdparty/glm/gtx/compatibility.hpp | 160 + thirdparty/glm/gtx/compatibility.inl | 58 + thirdparty/glm/gtx/component_wise.hpp | 82 + thirdparty/glm/gtx/component_wise.inl | 47 + thirdparty/glm/gtx/constants.hpp | 33 + thirdparty/glm/gtx/dual_quaternion.hpp | 295 ++ thirdparty/glm/gtx/dual_quaternion.inl | 421 ++ thirdparty/glm/gtx/epsilon.hpp | 29 + thirdparty/glm/gtx/euler_angles.hpp | 155 + thirdparty/glm/gtx/euler_angles.inl | 264 ++ thirdparty/glm/gtx/extend.hpp | 66 + thirdparty/glm/gtx/extend.inl | 55 + thirdparty/glm/gtx/extented_min_max.hpp | 161 + thirdparty/glm/gtx/extented_min_max.inl | 146 + thirdparty/glm/gtx/fast_exponential.hpp | 98 + thirdparty/glm/gtx/fast_exponential.inl | 148 + thirdparty/glm/gtx/fast_square_root.hpp | 90 + thirdparty/glm/gtx/fast_square_root.inl | 180 + thirdparty/glm/gtx/fast_trigonometry.hpp | 100 + thirdparty/glm/gtx/fast_trigonometry.inl | 75 + thirdparty/glm/gtx/gradient_paint.hpp | 76 + thirdparty/glm/gtx/gradient_paint.inl | 43 + .../glm/gtx/handed_coordinate_space.hpp | 74 + .../glm/gtx/handed_coordinate_space.inl | 33 + thirdparty/glm/gtx/inertia.hpp | 116 + thirdparty/glm/gtx/inertia.inl | 116 + thirdparty/glm/gtx/int_10_10_10_2.hpp | 44 + thirdparty/glm/gtx/int_10_10_10_2.inl | 33 + thirdparty/glm/gtx/integer.hpp | 104 + thirdparty/glm/gtx/integer.inl | 202 + thirdparty/glm/gtx/intersect.hpp | 111 + thirdparty/glm/gtx/intersect.inl | 217 + thirdparty/glm/gtx/io.hpp | 226 + thirdparty/glm/gtx/io.inl | 598 +++ thirdparty/glm/gtx/log_base.hpp | 65 + thirdparty/glm/gtx/log_base.inl | 24 + thirdparty/glm/gtx/matrix_cross_product.hpp | 71 + thirdparty/glm/gtx/matrix_cross_product.inl | 44 + thirdparty/glm/gtx/matrix_interpolation.hpp | 88 + thirdparty/glm/gtx/matrix_interpolation.inl | 140 + thirdparty/glm/gtx/matrix_major_storage.hpp | 143 + thirdparty/glm/gtx/matrix_major_storage.inl | 173 + thirdparty/glm/gtx/matrix_operation.hpp | 112 + thirdparty/glm/gtx/matrix_operation.inl | 124 + thirdparty/glm/gtx/matrix_query.hpp | 101 + thirdparty/glm/gtx/matrix_query.inl | 123 + thirdparty/glm/gtx/matrix_transform_2d.hpp | 105 + thirdparty/glm/gtx/matrix_transform_2d.inl | 97 + thirdparty/glm/gtx/mixed_product.hpp | 65 + thirdparty/glm/gtx/mixed_product.inl | 22 + thirdparty/glm/gtx/multiple.hpp | 83 + thirdparty/glm/gtx/multiple.inl | 152 + thirdparty/glm/gtx/noise.hpp | 29 + thirdparty/glm/gtx/norm.hpp | 127 + thirdparty/glm/gtx/norm.inl | 147 + thirdparty/glm/gtx/normal.hpp | 67 + thirdparty/glm/gtx/normal.inl | 22 + thirdparty/glm/gtx/normalize_dot.hpp | 76 + thirdparty/glm/gtx/normalize_dot.inl | 115 + thirdparty/glm/gtx/number_precision.hpp | 85 + thirdparty/glm/gtx/number_precision.inl | 13 + thirdparty/glm/gtx/optimum_pow.hpp | 94 + thirdparty/glm/gtx/optimum_pow.inl | 61 + thirdparty/glm/gtx/orthonormalize.hpp | 72 + thirdparty/glm/gtx/orthonormalize.inl | 43 + thirdparty/glm/gtx/perpendicular.hpp | 67 + thirdparty/glm/gtx/perpendicular.inl | 21 + thirdparty/glm/gtx/polar_coordinates.hpp | 72 + thirdparty/glm/gtx/polar_coordinates.inl | 57 + thirdparty/glm/gtx/projection.hpp | 65 + thirdparty/glm/gtx/projection.inl | 21 + thirdparty/glm/gtx/quaternion.hpp | 213 + thirdparty/glm/gtx/quaternion.inl | 262 ++ thirdparty/glm/gtx/random.hpp | 29 + thirdparty/glm/gtx/raw_data.hpp | 75 + thirdparty/glm/gtx/raw_data.inl | 11 + thirdparty/glm/gtx/reciprocal.hpp | 26 + thirdparty/glm/gtx/rotate_normalized_axis.hpp | 92 + thirdparty/glm/gtx/rotate_normalized_axis.inl | 94 + thirdparty/glm/gtx/rotate_vector.hpp | 132 + thirdparty/glm/gtx/rotate_vector.inl | 223 + thirdparty/glm/gtx/scalar_relational.hpp | 60 + thirdparty/glm/gtx/scalar_relational.inl | 95 + thirdparty/glm/gtx/simd_mat4.hpp | 205 + thirdparty/glm/gtx/simd_mat4.inl | 579 +++ thirdparty/glm/gtx/simd_quat.hpp | 341 ++ thirdparty/glm/gtx/simd_quat.inl | 629 +++ thirdparty/glm/gtx/simd_vec4.hpp | 574 +++ thirdparty/glm/gtx/simd_vec4.inl | 727 ++++ thirdparty/glm/gtx/spline.hpp | 90 + thirdparty/glm/gtx/spline.inl | 70 + thirdparty/glm/gtx/std_based_type.hpp | 83 + thirdparty/glm/gtx/std_based_type.inl | 13 + thirdparty/glm/gtx/string_cast.hpp | 74 + thirdparty/glm/gtx/string_cast.inl | 444 ++ thirdparty/glm/gtx/transform.hpp | 84 + thirdparty/glm/gtx/transform.inl | 37 + thirdparty/glm/gtx/transform2.hpp | 135 + thirdparty/glm/gtx/transform2.inl | 154 + thirdparty/glm/gtx/ulp.hpp | 29 + thirdparty/glm/gtx/unsigned_int.hpp | 26 + thirdparty/glm/gtx/unsigned_int.inl | 13 + thirdparty/glm/gtx/vec1.hpp | 166 + thirdparty/glm/gtx/vec1.inl | 27 + thirdparty/glm/gtx/vector_angle.hpp | 88 + thirdparty/glm/gtx/vector_angle.inl | 99 + thirdparty/glm/gtx/vector_query.hpp | 90 + thirdparty/glm/gtx/vector_query.inl | 202 + thirdparty/glm/gtx/wrap.hpp | 73 + thirdparty/glm/gtx/wrap.inl | 165 + thirdparty/glm/integer.hpp | 34 + thirdparty/glm/mat2x2.hpp | 80 + thirdparty/glm/mat2x3.hpp | 59 + thirdparty/glm/mat2x4.hpp | 59 + thirdparty/glm/mat3x2.hpp | 59 + thirdparty/glm/mat3x3.hpp | 80 + thirdparty/glm/mat3x4.hpp | 59 + thirdparty/glm/mat4x2.hpp | 59 + thirdparty/glm/mat4x3.hpp | 59 + thirdparty/glm/mat4x4.hpp | 80 + thirdparty/glm/matrix.hpp | 34 + thirdparty/glm/packing.hpp | 34 + thirdparty/glm/trigonometric.hpp | 34 + thirdparty/glm/vec2.hpp | 34 + thirdparty/glm/vec3.hpp | 34 + thirdparty/glm/vec4.hpp | 34 + thirdparty/glm/vector_relational.hpp | 34 + thirdparty/rapidjson/allocators.h | 693 +++ thirdparty/rapidjson/cursorstreamwrapper.h | 78 + thirdparty/rapidjson/document.h | 3045 ++++++++++++++ thirdparty/rapidjson/encodedstream.h | 299 ++ thirdparty/rapidjson/encodings.h | 716 ++++ thirdparty/rapidjson/error/en.h | 176 + thirdparty/rapidjson/error/error.h | 285 ++ thirdparty/rapidjson/filereadstream.h | 99 + thirdparty/rapidjson/filewritestream.h | 104 + thirdparty/rapidjson/fwd.h | 151 + thirdparty/rapidjson/internal/biginteger.h | 297 ++ thirdparty/rapidjson/internal/clzll.h | 71 + thirdparty/rapidjson/internal/diyfp.h | 261 ++ thirdparty/rapidjson/internal/dtoa.h | 249 ++ thirdparty/rapidjson/internal/ieee754.h | 78 + thirdparty/rapidjson/internal/itoa.h | 308 ++ thirdparty/rapidjson/internal/meta.h | 186 + thirdparty/rapidjson/internal/pow10.h | 55 + thirdparty/rapidjson/internal/regex.h | 739 ++++ thirdparty/rapidjson/internal/stack.h | 232 + thirdparty/rapidjson/internal/strfunc.h | 83 + thirdparty/rapidjson/internal/strtod.h | 293 ++ thirdparty/rapidjson/internal/swap.h | 46 + thirdparty/rapidjson/istreamwrapper.h | 128 + thirdparty/rapidjson/memorybuffer.h | 70 + thirdparty/rapidjson/memorystream.h | 71 + thirdparty/rapidjson/msinttypes/inttypes.h | 316 ++ thirdparty/rapidjson/msinttypes/stdint.h | 300 ++ thirdparty/rapidjson/ostreamwrapper.h | 81 + thirdparty/rapidjson/pointer.h | 1482 +++++++ thirdparty/rapidjson/prettywriter.h | 277 ++ thirdparty/rapidjson/rapidjson.h | 741 ++++ thirdparty/rapidjson/reader.h | 2246 ++++++++++ thirdparty/rapidjson/schema.h | 3261 +++++++++++++++ thirdparty/rapidjson/stream.h | 223 + thirdparty/rapidjson/stringbuffer.h | 121 + thirdparty/rapidjson/uri.h | 481 +++ thirdparty/rapidjson/writer.h | 721 ++++ thirdparty/stb_image/include | 2 +- 843 files changed, 95486 insertions(+), 8512 deletions(-) create mode 100644 game/.gitignore create mode 100644 game/assets/.gitignore create mode 100644 game/assets/materials/common.json create mode 100644 game/assets/materials/entity.material create mode 100644 game/assets/materials/fancy.json create mode 100644 game/assets/materials/fancy.material create mode 100644 game/assets/materials/particles.material create mode 100644 game/assets/materials/sad.json create mode 100644 game/assets/materials/sad.material create mode 100644 game/assets/materials/shadows.material create mode 100644 game/assets/materials/sky.material create mode 100644 game/assets/materials/terrain.material create mode 100644 game/assets/materials/ui.material create mode 100644 game/assets/materials/ui3D.material create mode 100644 source/client/app/AppPlatformListener.cpp create mode 100644 source/client/app/AppPlatformListener.hpp create mode 100644 source/client/gui/GuiElement.cpp create mode 100644 source/client/gui/GuiElement.hpp create mode 100644 source/client/gui/IntRectangle.hpp delete mode 100644 source/client/model/Model.cpp delete mode 100644 source/client/model/Model.hpp delete mode 100644 source/client/model/ModelPart.cpp rename source/client/model/{ => geom}/Cube.cpp (94%) rename source/client/model/{ => geom}/Cube.hpp (88%) create mode 100644 source/client/model/geom/ModelPart.cpp rename source/client/model/{ => geom}/ModelPart.hpp (73%) rename source/client/model/{ => geom}/PolygonQuad.cpp (100%) rename source/client/model/{ => geom}/PolygonQuad.hpp (100%) create mode 100644 source/client/model/geom/TextureOffset.hpp rename source/client/model/{ => models}/ChickenModel.cpp (81%) rename source/client/model/{ => models}/ChickenModel.hpp (100%) rename source/client/model/{ => models}/CowModel.cpp (100%) rename source/client/model/{ => models}/CowModel.hpp (100%) rename source/client/model/{ => models}/CreeperModel.cpp (100%) rename source/client/model/{ => models}/CreeperModel.hpp (100%) rename source/client/model/{ => models}/HumanoidModel.cpp (100%) rename source/client/model/{ => models}/HumanoidModel.hpp (100%) create mode 100644 source/client/model/models/Model.cpp create mode 100644 source/client/model/models/Model.hpp rename source/client/model/{ => models}/PigModel.cpp (79%) rename source/client/model/{ => models}/PigModel.hpp (100%) rename source/client/model/{ => models}/QuadrupedModel.cpp (87%) rename source/client/model/{ => models}/QuadrupedModel.hpp (100%) rename source/client/model/{ => models}/SheepFurModel.cpp (100%) rename source/client/model/{ => models}/SheepFurModel.hpp (100%) rename source/client/model/{ => models}/SheepModel.cpp (100%) rename source/client/model/{ => models}/SheepModel.hpp (100%) rename source/client/model/{ => models}/SkeletonModel.cpp (92%) rename source/client/model/{ => models}/SkeletonModel.hpp (100%) rename source/client/model/{ => models}/SpiderModel.cpp (89%) rename source/client/model/{ => models}/SpiderModel.hpp (100%) rename source/client/model/{ => models}/ZombieModel.cpp (100%) rename source/client/model/{ => models}/ZombieModel.hpp (100%) create mode 100644 source/client/renderer/Fog.cpp create mode 100644 source/client/renderer/Fog.hpp create mode 100644 source/client/renderer/ScreenRenderer.cpp create mode 100644 source/client/renderer/ScreenRenderer.hpp create mode 100644 source/client/renderer/renderer/EntityShaderManager.cpp create mode 100644 source/client/renderer/renderer/EntityShaderManager.hpp create mode 100644 source/client/renderer/renderer/RenderMaterialGroup.cpp create mode 100644 source/client/renderer/renderer/RenderMaterialGroup.hpp create mode 100644 source/client/renderer/texture/ColorSpace.hpp create mode 100644 source/client/renderer/texture/ImageData.cpp create mode 100644 source/client/renderer/texture/ImageData.hpp create mode 100644 source/client/renderer/texture/TextureData.cpp create mode 100644 source/client/renderer/texture/TextureData.hpp delete mode 100644 source/common/Matrix.cpp delete mode 100644 source/common/Matrix.hpp create mode 100644 source/common/math/Color.cpp create mode 100644 source/common/math/Color.hpp create mode 100644 source/common/utility/AlignmentHelper.cpp create mode 100644 source/common/utility/AlignmentHelper.hpp create mode 100644 source/common/utility/InheritanceTree.hpp create mode 100644 source/common/utility/JsonParser.cpp create mode 100644 source/common/utility/JsonParser.hpp create mode 100644 source/common/utility/Singleton.cpp create mode 100644 source/common/utility/Singleton.hpp create mode 100644 source/renderer/Attribute.cpp create mode 100644 source/renderer/Attribute.hpp create mode 100644 source/renderer/ConstantBufferMetaData.cpp create mode 100644 source/renderer/ConstantBufferMetaData.hpp create mode 100644 source/renderer/ConstantBufferMetaDataManager.cpp create mode 100644 source/renderer/ConstantBufferMetaDataManager.hpp create mode 100644 source/renderer/EnableScissorTest.cpp create mode 100644 source/renderer/EnableScissorTest.hpp create mode 100644 source/renderer/EntityConstants.cpp create mode 100644 source/renderer/EntityConstants.hpp create mode 100644 source/renderer/GlobalConstantBufferManager.cpp create mode 100644 source/renderer/GlobalConstantBufferManager.hpp create mode 100644 source/renderer/GlobalConstantBuffers.cpp create mode 100644 source/renderer/GlobalConstantBuffers.hpp create mode 100644 source/renderer/MaterialPtr.cpp create mode 100644 source/renderer/MaterialPtr.hpp create mode 100644 source/renderer/MatrixStack.cpp create mode 100644 source/renderer/MatrixStack.hpp create mode 100644 source/renderer/Mesh.cpp create mode 100644 source/renderer/Mesh.hpp create mode 100644 source/renderer/PerFrameConstants.cpp create mode 100644 source/renderer/PerFrameConstants.hpp create mode 100644 source/renderer/PlatformDefinitions.h create mode 100644 source/renderer/QuadIndexBuffer.cpp create mode 100644 source/renderer/QuadIndexBuffer.hpp create mode 100644 source/renderer/RenderChunkConstants.cpp create mode 100644 source/renderer/RenderChunkConstants.hpp create mode 100644 source/renderer/RenderContextImmediate.cpp create mode 100644 source/renderer/RenderContextImmediate.hpp create mode 100644 source/renderer/RenderMaterial.cpp create mode 100644 source/renderer/RenderMaterial.hpp create mode 100644 source/renderer/ShaderConstants.cpp create mode 100644 source/renderer/ShaderConstants.hpp create mode 100644 source/renderer/ShaderGroup.cpp create mode 100644 source/renderer/ShaderGroup.hpp create mode 100644 source/renderer/ShaderGroupBase.cpp create mode 100644 source/renderer/ShaderGroupBase.hpp create mode 100644 source/renderer/StencilRefObject.cpp create mode 100644 source/renderer/StencilRefObject.hpp create mode 100644 source/renderer/TextureGroup.cpp create mode 100644 source/renderer/TextureGroup.hpp create mode 100644 source/renderer/TexturePtr.cpp create mode 100644 source/renderer/TexturePtr.hpp create mode 100644 source/renderer/UniformMetaData.cpp create mode 100644 source/renderer/UniformMetaData.hpp create mode 100644 source/renderer/VertexFormat.cpp create mode 100644 source/renderer/VertexFormat.hpp create mode 100644 source/renderer/WeatherConstants.cpp create mode 100644 source/renderer/WeatherConstants.hpp create mode 100644 source/renderer/WorldConstants.cpp create mode 100644 source/renderer/WorldConstants.hpp create mode 100644 source/renderer/hal/BlendStateDescription.cpp create mode 100644 source/renderer/hal/BlendStateDescription.hpp create mode 100644 source/renderer/hal/DepthStencilStateDescription.cpp create mode 100644 source/renderer/hal/DepthStencilStateDescription.hpp create mode 100644 source/renderer/hal/FixedPipelineStateDescription.cpp create mode 100644 source/renderer/hal/FixedPipelineStateDescription.hpp create mode 100644 source/renderer/hal/FogStateDescription.cpp create mode 100644 source/renderer/hal/FogStateDescription.hpp create mode 100644 source/renderer/hal/ImageDescription.cpp create mode 100644 source/renderer/hal/ImageDescription.hpp create mode 100644 source/renderer/hal/RasterizerStateDescription.cpp create mode 100644 source/renderer/hal/RasterizerStateDescription.hpp create mode 100644 source/renderer/hal/ShaderStage.hpp create mode 100644 source/renderer/hal/StencilFaceDescription.cpp create mode 100644 source/renderer/hal/StencilFaceDescription.hpp create mode 100644 source/renderer/hal/TextureDescription.cpp create mode 100644 source/renderer/hal/TextureDescription.hpp create mode 100644 source/renderer/hal/base/BlendStateBase.cpp create mode 100644 source/renderer/hal/base/BlendStateBase.hpp create mode 100644 source/renderer/hal/base/BufferBase.cpp create mode 100644 source/renderer/hal/base/BufferBase.hpp create mode 100644 source/renderer/hal/base/ConstantBufferBase.cpp create mode 100644 source/renderer/hal/base/ConstantBufferBase.hpp create mode 100644 source/renderer/hal/base/ConstantBufferConstantsBase.cpp create mode 100644 source/renderer/hal/base/ConstantBufferConstantsBase.hpp create mode 100644 source/renderer/hal/base/ConstantBufferContainerBase.cpp create mode 100644 source/renderer/hal/base/ConstantBufferContainerBase.hpp create mode 100644 source/renderer/hal/base/DepthStencilStateBase.cpp create mode 100644 source/renderer/hal/base/DepthStencilStateBase.hpp create mode 100644 source/renderer/hal/base/FixedPipelineStateBase.cpp create mode 100644 source/renderer/hal/base/FixedPipelineStateBase.hpp create mode 100644 source/renderer/hal/base/FogStateBase.cpp create mode 100644 source/renderer/hal/base/FogStateBase.hpp create mode 100644 source/renderer/hal/base/FrameBufferObjectBase.cpp create mode 100644 source/renderer/hal/base/FrameBufferObjectBase.hpp create mode 100644 source/renderer/hal/base/ImmediateBufferBase.cpp create mode 100644 source/renderer/hal/base/ImmediateBufferBase.hpp create mode 100644 source/renderer/hal/base/RasterizerStateBase.cpp create mode 100644 source/renderer/hal/base/RasterizerStateBase.hpp create mode 100644 source/renderer/hal/base/RenderContextBase.cpp create mode 100644 source/renderer/hal/base/RenderContextBase.hpp create mode 100644 source/renderer/hal/base/RenderContextStateBase.cpp create mode 100644 source/renderer/hal/base/RenderContextStateBase.hpp create mode 100644 source/renderer/hal/base/RenderDeviceBase.cpp create mode 100644 source/renderer/hal/base/RenderDeviceBase.hpp create mode 100644 source/renderer/hal/base/ShaderBase.cpp create mode 100644 source/renderer/hal/base/ShaderBase.hpp create mode 100644 source/renderer/hal/base/ShaderConstantBase.cpp create mode 100644 source/renderer/hal/base/ShaderConstantBase.hpp create mode 100644 source/renderer/hal/base/ShaderConstantWithDataBase.cpp create mode 100644 source/renderer/hal/base/ShaderConstantWithDataBase.hpp create mode 100644 source/renderer/hal/base/ShaderContextBase.cpp create mode 100644 source/renderer/hal/base/ShaderContextBase.hpp create mode 100644 source/renderer/hal/base/ShaderProgramBase.cpp create mode 100644 source/renderer/hal/base/ShaderProgramBase.hpp create mode 100644 source/renderer/hal/base/TextureBase.cpp create mode 100644 source/renderer/hal/base/TextureBase.hpp create mode 100644 source/renderer/hal/enums/BlendTarget.hpp create mode 100644 source/renderer/hal/enums/BlendTarget_JsonParser.cpp create mode 100644 source/renderer/hal/enums/BufferType.hpp create mode 100644 source/renderer/hal/enums/ColorWriteMask.hpp create mode 100644 source/renderer/hal/enums/ComparisonFunc.hpp create mode 100644 source/renderer/hal/enums/ComparisonFunc_JsonParser.cpp create mode 100644 source/renderer/hal/enums/CullMode.hpp create mode 100644 source/renderer/hal/enums/DepthWriteMask.hpp create mode 100644 source/renderer/hal/enums/FogMode.hpp create mode 100644 source/renderer/hal/enums/PrimitiveMode.hpp create mode 100644 source/renderer/hal/enums/PrimitiveMode_JsonParser.cpp create mode 100644 source/renderer/hal/enums/RenderState.hpp create mode 100644 source/renderer/hal/enums/RenderState_JsonParser.cpp create mode 100644 source/renderer/hal/enums/RenderState_JsonParser.hpp create mode 100644 source/renderer/hal/enums/ShadeMode.hpp create mode 100644 source/renderer/hal/enums/ShaderPrimitiveTypes.cpp create mode 100644 source/renderer/hal/enums/ShaderPrimitiveTypes.hpp create mode 100644 source/renderer/hal/enums/ShaderStagesBits.hpp create mode 100644 source/renderer/hal/enums/ShaderStagesBits_JsonParser.cpp create mode 100644 source/renderer/hal/enums/ShaderType.hpp create mode 100644 source/renderer/hal/enums/StencilMask.hpp create mode 100644 source/renderer/hal/enums/StencilOp.hpp create mode 100644 source/renderer/hal/enums/StencilOp_JsonParser.cpp create mode 100644 source/renderer/hal/enums/TextureFiltering.hpp create mode 100644 source/renderer/hal/enums/TextureFiltering_JsonParser.cpp create mode 100644 source/renderer/hal/enums/TextureFormat.hpp create mode 100644 source/renderer/hal/enums/VertexField.hpp create mode 100644 source/renderer/hal/enums/VertexFieldType.hpp create mode 100644 source/renderer/hal/enums/VertexField_JsonParser.cpp create mode 100644 source/renderer/hal/helpers/ErrorHandler.cpp create mode 100644 source/renderer/hal/helpers/ErrorHandler.hpp create mode 100644 source/renderer/hal/helpers/TextureHelper.cpp create mode 100644 source/renderer/hal/helpers/TextureHelper.hpp create mode 100644 source/renderer/hal/interface/BlendState.cpp create mode 100644 source/renderer/hal/interface/BlendState.hpp create mode 100644 source/renderer/hal/interface/Buffer.cpp create mode 100644 source/renderer/hal/interface/Buffer.hpp create mode 100644 source/renderer/hal/interface/ConstantBuffer.cpp create mode 100644 source/renderer/hal/interface/ConstantBuffer.hpp create mode 100644 source/renderer/hal/interface/ConstantBufferConstants.hpp create mode 100644 source/renderer/hal/interface/ConstantBufferContainer.cpp create mode 100644 source/renderer/hal/interface/ConstantBufferContainer.hpp create mode 100644 source/renderer/hal/interface/DepthStencilState.cpp create mode 100644 source/renderer/hal/interface/DepthStencilState.hpp create mode 100644 source/renderer/hal/interface/FixedPipelineState.cpp create mode 100644 source/renderer/hal/interface/FixedPipelineState.hpp create mode 100644 source/renderer/hal/interface/FogState.cpp create mode 100644 source/renderer/hal/interface/FogState.hpp create mode 100644 source/renderer/hal/interface/ImmediateBuffer.cpp create mode 100644 source/renderer/hal/interface/ImmediateBuffer.hpp create mode 100644 source/renderer/hal/interface/RasterizerState.cpp create mode 100644 source/renderer/hal/interface/RasterizerState.hpp create mode 100644 source/renderer/hal/interface/RenderContext.cpp create mode 100644 source/renderer/hal/interface/RenderContext.hpp create mode 100644 source/renderer/hal/interface/RenderDevice.cpp create mode 100644 source/renderer/hal/interface/RenderDevice.hpp create mode 100644 source/renderer/hal/interface/Shader.cpp create mode 100644 source/renderer/hal/interface/Shader.hpp create mode 100644 source/renderer/hal/interface/ShaderConstant.hpp create mode 100644 source/renderer/hal/interface/ShaderConstantWithData.cpp create mode 100644 source/renderer/hal/interface/ShaderConstantWithData.hpp create mode 100644 source/renderer/hal/interface/ShaderProgram.cpp create mode 100644 source/renderer/hal/interface/ShaderProgram.hpp create mode 100644 source/renderer/hal/interface/Texture.cpp create mode 100644 source/renderer/hal/interface/Texture.hpp create mode 100644 source/renderer/hal/null/BlendStateNull.cpp create mode 100644 source/renderer/hal/null/BlendStateNull.hpp create mode 100644 source/renderer/hal/null/BufferNull.cpp create mode 100644 source/renderer/hal/null/BufferNull.hpp create mode 100644 source/renderer/hal/null/ConstantBufferContainerNull.cpp create mode 100644 source/renderer/hal/null/ConstantBufferContainerNull.hpp create mode 100644 source/renderer/hal/null/DepthStencilStateNull.cpp create mode 100644 source/renderer/hal/null/DepthStencilStateNull.hpp create mode 100644 source/renderer/hal/null/FixedPipelineStateNull.cpp create mode 100644 source/renderer/hal/null/FixedPipelineStateNull.hpp create mode 100644 source/renderer/hal/null/FogStateNull.cpp create mode 100644 source/renderer/hal/null/FogStateNull.hpp create mode 100644 source/renderer/hal/null/ImmediateBufferNull.cpp create mode 100644 source/renderer/hal/null/ImmediateBufferNull.hpp create mode 100644 source/renderer/hal/null/RasterizerStateNull.cpp create mode 100644 source/renderer/hal/null/RasterizerStateNull.hpp create mode 100644 source/renderer/hal/null/RenderContextNull.cpp create mode 100644 source/renderer/hal/null/RenderContextNull.hpp create mode 100644 source/renderer/hal/null/RenderDeviceNull.cpp create mode 100644 source/renderer/hal/null/RenderDeviceNull.hpp create mode 100644 source/renderer/hal/null/ShaderConstantNull.cpp create mode 100644 source/renderer/hal/null/ShaderConstantNull.hpp create mode 100644 source/renderer/hal/null/ShaderConstantWithDataNull.cpp create mode 100644 source/renderer/hal/null/ShaderConstantWithDataNull.hpp create mode 100644 source/renderer/hal/null/ShaderNull.cpp create mode 100644 source/renderer/hal/null/ShaderNull.hpp create mode 100644 source/renderer/hal/null/ShaderProgramNull.cpp create mode 100644 source/renderer/hal/null/ShaderProgramNull.hpp create mode 100644 source/renderer/hal/null/TextureNull.cpp create mode 100644 source/renderer/hal/null/TextureNull.hpp create mode 100644 source/renderer/hal/ogl/API_OGL.cpp create mode 100644 source/renderer/hal/ogl/API_OGL.hpp create mode 100644 source/renderer/hal/ogl/BlendStateOGL.cpp create mode 100644 source/renderer/hal/ogl/BlendStateOGL.hpp create mode 100644 source/renderer/hal/ogl/BufferOGL.cpp create mode 100644 source/renderer/hal/ogl/BufferOGL.hpp create mode 100644 source/renderer/hal/ogl/ConstantBufferContainerOGL.cpp create mode 100644 source/renderer/hal/ogl/ConstantBufferContainerOGL.hpp create mode 100644 source/renderer/hal/ogl/DepthStencilStateOGL.cpp create mode 100644 source/renderer/hal/ogl/DepthStencilStateOGL.hpp create mode 100644 source/renderer/hal/ogl/FixedPipelineStateOGL.cpp create mode 100644 source/renderer/hal/ogl/FixedPipelineStateOGL.hpp create mode 100644 source/renderer/hal/ogl/FogStateOGL.cpp create mode 100644 source/renderer/hal/ogl/FogStateOGL.hpp create mode 100644 source/renderer/hal/ogl/GPUEventsOGL.cpp create mode 100644 source/renderer/hal/ogl/GPUEventsOGL.hpp create mode 100644 source/renderer/hal/ogl/ImmediateBufferOGL.cpp create mode 100644 source/renderer/hal/ogl/ImmediateBufferOGL.hpp create mode 100644 source/renderer/hal/ogl/ProfileSectionOGL.cpp create mode 100644 source/renderer/hal/ogl/ProfileSectionOGL.hpp create mode 100644 source/renderer/hal/ogl/RasterizerStateOGL.cpp create mode 100644 source/renderer/hal/ogl/RasterizerStateOGL.hpp create mode 100644 source/renderer/hal/ogl/RenderContextOGL.cpp create mode 100644 source/renderer/hal/ogl/RenderContextOGL.hpp create mode 100644 source/renderer/hal/ogl/RenderDeviceOGL.cpp create mode 100644 source/renderer/hal/ogl/RenderDeviceOGL.hpp create mode 100644 source/renderer/hal/ogl/ResourceOGL.cpp create mode 100644 source/renderer/hal/ogl/ResourceOGL.hpp create mode 100644 source/renderer/hal/ogl/ShaderConstantOGL.cpp create mode 100644 source/renderer/hal/ogl/ShaderConstantOGL.hpp create mode 100644 source/renderer/hal/ogl/ShaderConstantWithDataOGL.cpp create mode 100644 source/renderer/hal/ogl/ShaderConstantWithDataOGL.hpp create mode 100644 source/renderer/hal/ogl/ShaderOGL.cpp create mode 100644 source/renderer/hal/ogl/ShaderOGL.hpp create mode 100644 source/renderer/hal/ogl/ShaderProgramOGL.cpp create mode 100644 source/renderer/hal/ogl/ShaderProgramOGL.hpp create mode 100644 source/renderer/hal/ogl/ShaderResourceOGL.cpp create mode 100644 source/renderer/hal/ogl/ShaderResourceOGL.hpp create mode 100644 source/renderer/hal/ogl/ShaderUniformOGL.cpp create mode 100644 source/renderer/hal/ogl/ShaderUniformOGL.hpp create mode 100644 source/renderer/hal/ogl/TextureOGL.cpp create mode 100644 source/renderer/hal/ogl/TextureOGL.hpp create mode 100644 source/renderer/platform/ogl/Extensions.cpp create mode 100644 source/renderer/platform/ogl/Extensions.hpp create mode 100644 source/renderer/platform/ogl/ShaderPrecision.cpp create mode 100644 source/renderer/platform/ogl/ShaderPrecision.hpp delete mode 100644 thirdparty/GL/GLExt.cpp create mode 100644 thirdparty/glm/CMakeLists.txt create mode 100644 thirdparty/glm/common.hpp create mode 100644 thirdparty/glm/detail/_features.hpp create mode 100644 thirdparty/glm/detail/_fixes.hpp create mode 100644 thirdparty/glm/detail/_literals.hpp create mode 100644 thirdparty/glm/detail/_noise.hpp create mode 100644 thirdparty/glm/detail/_swizzle.hpp create mode 100644 thirdparty/glm/detail/_swizzle_func.hpp create mode 100644 thirdparty/glm/detail/_vectorize.hpp create mode 100644 thirdparty/glm/detail/dummy.cpp create mode 100644 thirdparty/glm/detail/func_common.hpp create mode 100644 thirdparty/glm/detail/func_common.inl create mode 100644 thirdparty/glm/detail/func_exponential.hpp create mode 100644 thirdparty/glm/detail/func_exponential.inl create mode 100644 thirdparty/glm/detail/func_geometric.hpp create mode 100644 thirdparty/glm/detail/func_geometric.inl create mode 100644 thirdparty/glm/detail/func_integer.hpp create mode 100644 thirdparty/glm/detail/func_integer.inl create mode 100644 thirdparty/glm/detail/func_matrix.hpp create mode 100644 thirdparty/glm/detail/func_matrix.inl create mode 100644 thirdparty/glm/detail/func_noise.hpp create mode 100644 thirdparty/glm/detail/func_noise.inl create mode 100644 thirdparty/glm/detail/func_packing.hpp create mode 100644 thirdparty/glm/detail/func_packing.inl create mode 100644 thirdparty/glm/detail/func_trigonometric.hpp create mode 100644 thirdparty/glm/detail/func_trigonometric.inl create mode 100644 thirdparty/glm/detail/func_vector_relational.hpp create mode 100644 thirdparty/glm/detail/func_vector_relational.inl create mode 100644 thirdparty/glm/detail/glm.cpp create mode 100644 thirdparty/glm/detail/hint.hpp create mode 100644 thirdparty/glm/detail/intrinsic_common.hpp create mode 100644 thirdparty/glm/detail/intrinsic_common.inl create mode 100644 thirdparty/glm/detail/intrinsic_exponential.hpp create mode 100644 thirdparty/glm/detail/intrinsic_exponential.inl create mode 100644 thirdparty/glm/detail/intrinsic_geometric.hpp create mode 100644 thirdparty/glm/detail/intrinsic_geometric.inl create mode 100644 thirdparty/glm/detail/intrinsic_integer.hpp create mode 100644 thirdparty/glm/detail/intrinsic_integer.inl create mode 100644 thirdparty/glm/detail/intrinsic_matrix.hpp create mode 100644 thirdparty/glm/detail/intrinsic_matrix.inl create mode 100644 thirdparty/glm/detail/intrinsic_trigonometric.hpp create mode 100644 thirdparty/glm/detail/intrinsic_trigonometric.inl create mode 100644 thirdparty/glm/detail/intrinsic_vector_relational.hpp create mode 100644 thirdparty/glm/detail/intrinsic_vector_relational.inl create mode 100644 thirdparty/glm/detail/precision.hpp create mode 100644 thirdparty/glm/detail/precision.inl create mode 100644 thirdparty/glm/detail/setup.hpp create mode 100644 thirdparty/glm/detail/type_float.hpp create mode 100644 thirdparty/glm/detail/type_gentype.hpp create mode 100644 thirdparty/glm/detail/type_gentype.inl create mode 100644 thirdparty/glm/detail/type_half.hpp create mode 100644 thirdparty/glm/detail/type_half.inl create mode 100644 thirdparty/glm/detail/type_int.hpp create mode 100644 thirdparty/glm/detail/type_mat.hpp create mode 100644 thirdparty/glm/detail/type_mat.inl create mode 100644 thirdparty/glm/detail/type_mat2x2.hpp create mode 100644 thirdparty/glm/detail/type_mat2x2.inl create mode 100644 thirdparty/glm/detail/type_mat2x3.hpp create mode 100644 thirdparty/glm/detail/type_mat2x3.inl create mode 100644 thirdparty/glm/detail/type_mat2x4.hpp create mode 100644 thirdparty/glm/detail/type_mat2x4.inl create mode 100644 thirdparty/glm/detail/type_mat3x2.hpp create mode 100644 thirdparty/glm/detail/type_mat3x2.inl create mode 100644 thirdparty/glm/detail/type_mat3x3.hpp create mode 100644 thirdparty/glm/detail/type_mat3x3.inl create mode 100644 thirdparty/glm/detail/type_mat3x4.hpp create mode 100644 thirdparty/glm/detail/type_mat3x4.inl create mode 100644 thirdparty/glm/detail/type_mat4x2.hpp create mode 100644 thirdparty/glm/detail/type_mat4x2.inl create mode 100644 thirdparty/glm/detail/type_mat4x3.hpp create mode 100644 thirdparty/glm/detail/type_mat4x3.inl create mode 100644 thirdparty/glm/detail/type_mat4x4.hpp create mode 100644 thirdparty/glm/detail/type_mat4x4.inl create mode 100644 thirdparty/glm/detail/type_vec.hpp create mode 100644 thirdparty/glm/detail/type_vec.inl create mode 100644 thirdparty/glm/detail/type_vec1.hpp create mode 100644 thirdparty/glm/detail/type_vec1.inl create mode 100644 thirdparty/glm/detail/type_vec2.hpp create mode 100644 thirdparty/glm/detail/type_vec2.inl create mode 100644 thirdparty/glm/detail/type_vec3.hpp create mode 100644 thirdparty/glm/detail/type_vec3.inl create mode 100644 thirdparty/glm/detail/type_vec4.hpp create mode 100644 thirdparty/glm/detail/type_vec4.inl create mode 100644 thirdparty/glm/exponential.hpp create mode 100644 thirdparty/glm/ext.hpp create mode 100644 thirdparty/glm/fwd.hpp create mode 100644 thirdparty/glm/geometric.hpp create mode 100644 thirdparty/glm/glm.hpp create mode 100644 thirdparty/glm/gtc/constants.hpp create mode 100644 thirdparty/glm/gtc/constants.inl create mode 100644 thirdparty/glm/gtc/epsilon.hpp create mode 100644 thirdparty/glm/gtc/epsilon.inl create mode 100644 thirdparty/glm/gtc/matrix_access.hpp create mode 100644 thirdparty/glm/gtc/matrix_access.inl create mode 100644 thirdparty/glm/gtc/matrix_integer.hpp create mode 100644 thirdparty/glm/gtc/matrix_inverse.hpp create mode 100644 thirdparty/glm/gtc/matrix_inverse.inl create mode 100644 thirdparty/glm/gtc/matrix_transform.hpp create mode 100644 thirdparty/glm/gtc/matrix_transform.inl create mode 100644 thirdparty/glm/gtc/noise.hpp create mode 100644 thirdparty/glm/gtc/noise.inl create mode 100644 thirdparty/glm/gtc/packing.hpp create mode 100644 thirdparty/glm/gtc/packing.inl create mode 100644 thirdparty/glm/gtc/quaternion.hpp create mode 100644 thirdparty/glm/gtc/quaternion.inl create mode 100644 thirdparty/glm/gtc/random.hpp create mode 100644 thirdparty/glm/gtc/random.inl create mode 100644 thirdparty/glm/gtc/reciprocal.hpp create mode 100644 thirdparty/glm/gtc/reciprocal.inl create mode 100644 thirdparty/glm/gtc/type_precision.hpp create mode 100644 thirdparty/glm/gtc/type_precision.inl create mode 100644 thirdparty/glm/gtc/type_ptr.hpp create mode 100644 thirdparty/glm/gtc/type_ptr.inl create mode 100644 thirdparty/glm/gtc/ulp.hpp create mode 100644 thirdparty/glm/gtc/ulp.inl create mode 100644 thirdparty/glm/gtx/associated_min_max.hpp create mode 100644 thirdparty/glm/gtx/associated_min_max.inl create mode 100644 thirdparty/glm/gtx/bit.hpp create mode 100644 thirdparty/glm/gtx/bit.inl create mode 100644 thirdparty/glm/gtx/closest_point.hpp create mode 100644 thirdparty/glm/gtx/closest_point.inl create mode 100644 thirdparty/glm/gtx/color_space.hpp create mode 100644 thirdparty/glm/gtx/color_space.inl create mode 100644 thirdparty/glm/gtx/color_space_YCoCg.hpp create mode 100644 thirdparty/glm/gtx/color_space_YCoCg.inl create mode 100644 thirdparty/glm/gtx/compatibility.hpp create mode 100644 thirdparty/glm/gtx/compatibility.inl create mode 100644 thirdparty/glm/gtx/component_wise.hpp create mode 100644 thirdparty/glm/gtx/component_wise.inl create mode 100644 thirdparty/glm/gtx/constants.hpp create mode 100644 thirdparty/glm/gtx/dual_quaternion.hpp create mode 100644 thirdparty/glm/gtx/dual_quaternion.inl create mode 100644 thirdparty/glm/gtx/epsilon.hpp create mode 100644 thirdparty/glm/gtx/euler_angles.hpp create mode 100644 thirdparty/glm/gtx/euler_angles.inl create mode 100644 thirdparty/glm/gtx/extend.hpp create mode 100644 thirdparty/glm/gtx/extend.inl create mode 100644 thirdparty/glm/gtx/extented_min_max.hpp create mode 100644 thirdparty/glm/gtx/extented_min_max.inl create mode 100644 thirdparty/glm/gtx/fast_exponential.hpp create mode 100644 thirdparty/glm/gtx/fast_exponential.inl create mode 100644 thirdparty/glm/gtx/fast_square_root.hpp create mode 100644 thirdparty/glm/gtx/fast_square_root.inl create mode 100644 thirdparty/glm/gtx/fast_trigonometry.hpp create mode 100644 thirdparty/glm/gtx/fast_trigonometry.inl create mode 100644 thirdparty/glm/gtx/gradient_paint.hpp create mode 100644 thirdparty/glm/gtx/gradient_paint.inl create mode 100644 thirdparty/glm/gtx/handed_coordinate_space.hpp create mode 100644 thirdparty/glm/gtx/handed_coordinate_space.inl create mode 100644 thirdparty/glm/gtx/inertia.hpp create mode 100644 thirdparty/glm/gtx/inertia.inl create mode 100644 thirdparty/glm/gtx/int_10_10_10_2.hpp create mode 100644 thirdparty/glm/gtx/int_10_10_10_2.inl create mode 100644 thirdparty/glm/gtx/integer.hpp create mode 100644 thirdparty/glm/gtx/integer.inl create mode 100644 thirdparty/glm/gtx/intersect.hpp create mode 100644 thirdparty/glm/gtx/intersect.inl create mode 100644 thirdparty/glm/gtx/io.hpp create mode 100644 thirdparty/glm/gtx/io.inl create mode 100644 thirdparty/glm/gtx/log_base.hpp create mode 100644 thirdparty/glm/gtx/log_base.inl create mode 100644 thirdparty/glm/gtx/matrix_cross_product.hpp create mode 100644 thirdparty/glm/gtx/matrix_cross_product.inl create mode 100644 thirdparty/glm/gtx/matrix_interpolation.hpp create mode 100644 thirdparty/glm/gtx/matrix_interpolation.inl create mode 100644 thirdparty/glm/gtx/matrix_major_storage.hpp create mode 100644 thirdparty/glm/gtx/matrix_major_storage.inl create mode 100644 thirdparty/glm/gtx/matrix_operation.hpp create mode 100644 thirdparty/glm/gtx/matrix_operation.inl create mode 100644 thirdparty/glm/gtx/matrix_query.hpp create mode 100644 thirdparty/glm/gtx/matrix_query.inl create mode 100644 thirdparty/glm/gtx/matrix_transform_2d.hpp create mode 100644 thirdparty/glm/gtx/matrix_transform_2d.inl create mode 100644 thirdparty/glm/gtx/mixed_product.hpp create mode 100644 thirdparty/glm/gtx/mixed_product.inl create mode 100644 thirdparty/glm/gtx/multiple.hpp create mode 100644 thirdparty/glm/gtx/multiple.inl create mode 100644 thirdparty/glm/gtx/noise.hpp create mode 100644 thirdparty/glm/gtx/norm.hpp create mode 100644 thirdparty/glm/gtx/norm.inl create mode 100644 thirdparty/glm/gtx/normal.hpp create mode 100644 thirdparty/glm/gtx/normal.inl create mode 100644 thirdparty/glm/gtx/normalize_dot.hpp create mode 100644 thirdparty/glm/gtx/normalize_dot.inl create mode 100644 thirdparty/glm/gtx/number_precision.hpp create mode 100644 thirdparty/glm/gtx/number_precision.inl create mode 100644 thirdparty/glm/gtx/optimum_pow.hpp create mode 100644 thirdparty/glm/gtx/optimum_pow.inl create mode 100644 thirdparty/glm/gtx/orthonormalize.hpp create mode 100644 thirdparty/glm/gtx/orthonormalize.inl create mode 100644 thirdparty/glm/gtx/perpendicular.hpp create mode 100644 thirdparty/glm/gtx/perpendicular.inl create mode 100644 thirdparty/glm/gtx/polar_coordinates.hpp create mode 100644 thirdparty/glm/gtx/polar_coordinates.inl create mode 100644 thirdparty/glm/gtx/projection.hpp create mode 100644 thirdparty/glm/gtx/projection.inl create mode 100644 thirdparty/glm/gtx/quaternion.hpp create mode 100644 thirdparty/glm/gtx/quaternion.inl create mode 100644 thirdparty/glm/gtx/random.hpp create mode 100644 thirdparty/glm/gtx/raw_data.hpp create mode 100644 thirdparty/glm/gtx/raw_data.inl create mode 100644 thirdparty/glm/gtx/reciprocal.hpp create mode 100644 thirdparty/glm/gtx/rotate_normalized_axis.hpp create mode 100644 thirdparty/glm/gtx/rotate_normalized_axis.inl create mode 100644 thirdparty/glm/gtx/rotate_vector.hpp create mode 100644 thirdparty/glm/gtx/rotate_vector.inl create mode 100644 thirdparty/glm/gtx/scalar_relational.hpp create mode 100644 thirdparty/glm/gtx/scalar_relational.inl create mode 100644 thirdparty/glm/gtx/simd_mat4.hpp create mode 100644 thirdparty/glm/gtx/simd_mat4.inl create mode 100644 thirdparty/glm/gtx/simd_quat.hpp create mode 100644 thirdparty/glm/gtx/simd_quat.inl create mode 100644 thirdparty/glm/gtx/simd_vec4.hpp create mode 100644 thirdparty/glm/gtx/simd_vec4.inl create mode 100644 thirdparty/glm/gtx/spline.hpp create mode 100644 thirdparty/glm/gtx/spline.inl create mode 100644 thirdparty/glm/gtx/std_based_type.hpp create mode 100644 thirdparty/glm/gtx/std_based_type.inl create mode 100644 thirdparty/glm/gtx/string_cast.hpp create mode 100644 thirdparty/glm/gtx/string_cast.inl create mode 100644 thirdparty/glm/gtx/transform.hpp create mode 100644 thirdparty/glm/gtx/transform.inl create mode 100644 thirdparty/glm/gtx/transform2.hpp create mode 100644 thirdparty/glm/gtx/transform2.inl create mode 100644 thirdparty/glm/gtx/ulp.hpp create mode 100644 thirdparty/glm/gtx/unsigned_int.hpp create mode 100644 thirdparty/glm/gtx/unsigned_int.inl create mode 100644 thirdparty/glm/gtx/vec1.hpp create mode 100644 thirdparty/glm/gtx/vec1.inl create mode 100644 thirdparty/glm/gtx/vector_angle.hpp create mode 100644 thirdparty/glm/gtx/vector_angle.inl create mode 100644 thirdparty/glm/gtx/vector_query.hpp create mode 100644 thirdparty/glm/gtx/vector_query.inl create mode 100644 thirdparty/glm/gtx/wrap.hpp create mode 100644 thirdparty/glm/gtx/wrap.inl create mode 100644 thirdparty/glm/integer.hpp create mode 100644 thirdparty/glm/mat2x2.hpp create mode 100644 thirdparty/glm/mat2x3.hpp create mode 100644 thirdparty/glm/mat2x4.hpp create mode 100644 thirdparty/glm/mat3x2.hpp create mode 100644 thirdparty/glm/mat3x3.hpp create mode 100644 thirdparty/glm/mat3x4.hpp create mode 100644 thirdparty/glm/mat4x2.hpp create mode 100644 thirdparty/glm/mat4x3.hpp create mode 100644 thirdparty/glm/mat4x4.hpp create mode 100644 thirdparty/glm/matrix.hpp create mode 100644 thirdparty/glm/packing.hpp create mode 100644 thirdparty/glm/trigonometric.hpp create mode 100644 thirdparty/glm/vec2.hpp create mode 100644 thirdparty/glm/vec3.hpp create mode 100644 thirdparty/glm/vec4.hpp create mode 100644 thirdparty/glm/vector_relational.hpp create mode 100644 thirdparty/rapidjson/allocators.h create mode 100644 thirdparty/rapidjson/cursorstreamwrapper.h create mode 100644 thirdparty/rapidjson/document.h create mode 100644 thirdparty/rapidjson/encodedstream.h create mode 100644 thirdparty/rapidjson/encodings.h create mode 100644 thirdparty/rapidjson/error/en.h create mode 100644 thirdparty/rapidjson/error/error.h create mode 100644 thirdparty/rapidjson/filereadstream.h create mode 100644 thirdparty/rapidjson/filewritestream.h create mode 100644 thirdparty/rapidjson/fwd.h create mode 100644 thirdparty/rapidjson/internal/biginteger.h create mode 100644 thirdparty/rapidjson/internal/clzll.h create mode 100644 thirdparty/rapidjson/internal/diyfp.h create mode 100644 thirdparty/rapidjson/internal/dtoa.h create mode 100644 thirdparty/rapidjson/internal/ieee754.h create mode 100644 thirdparty/rapidjson/internal/itoa.h create mode 100644 thirdparty/rapidjson/internal/meta.h create mode 100644 thirdparty/rapidjson/internal/pow10.h create mode 100644 thirdparty/rapidjson/internal/regex.h create mode 100644 thirdparty/rapidjson/internal/stack.h create mode 100644 thirdparty/rapidjson/internal/strfunc.h create mode 100644 thirdparty/rapidjson/internal/strtod.h create mode 100644 thirdparty/rapidjson/internal/swap.h create mode 100644 thirdparty/rapidjson/istreamwrapper.h create mode 100644 thirdparty/rapidjson/memorybuffer.h create mode 100644 thirdparty/rapidjson/memorystream.h create mode 100644 thirdparty/rapidjson/msinttypes/inttypes.h create mode 100644 thirdparty/rapidjson/msinttypes/stdint.h create mode 100644 thirdparty/rapidjson/ostreamwrapper.h create mode 100644 thirdparty/rapidjson/pointer.h create mode 100644 thirdparty/rapidjson/prettywriter.h create mode 100644 thirdparty/rapidjson/rapidjson.h create mode 100644 thirdparty/rapidjson/reader.h create mode 100644 thirdparty/rapidjson/schema.h create mode 100644 thirdparty/rapidjson/stream.h create mode 100644 thirdparty/rapidjson/stringbuffer.h create mode 100644 thirdparty/rapidjson/uri.h create mode 100644 thirdparty/rapidjson/writer.h diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bdcff9bca..e8b54f6b5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,10 +11,10 @@ jobs: matrix: include: - name: SDL 2 - flags: '-DREMCPE_PLATFORM=sdl2' + flags: '-DREMCPE_PLATFORM=sdl2 -DREMCPE_GFX_API=OGL' packages: 'libsdl2-dev' - name: SDL 1.2 - flags: '-DREMCPE_PLATFORM=sdl1' + flags: '-DREMCPE_PLATFORM=sdl1 -DREMCPE_GFX_API=OGL' packages: 'libsdl1.2-dev' name: Linux (${{ matrix.name }}) runs-on: ubuntu-latest @@ -144,12 +144,12 @@ jobs: matrix: include: - name: Win32 - flags: '-DREMCPE_PLATFORM=windows' + flags: '-DREMCPE_PLATFORM=windows -DREMCPE_GFX_API=OGL' - name: SDL2 - flags: "-DREMCPE_PLATFORM=sdl2" + flags: "-DREMCPE_PLATFORM=sdl2 -DREMCPE_GFX_API=OGL" # CMake can't find it #- name: SDL 1.2 - # flags: "-DREMCPE_PLATFORM=sdl1" + # flags: '-DREMCPE_PLATFORM=sdl1 -DREMCPE_GFX_API=OGL' name: MinGW-w64 (${{ matrix.name }}) runs-on: ubuntu-latest steps: diff --git a/.gitignore b/.gitignore index 363d52ed8..6cd710843 100644 --- a/.gitignore +++ b/.gitignore @@ -132,137 +132,9 @@ xcuserdata/ # Ignore wasm build artifacts. /wasm -#-- The 'game' directory is the default working directory for Minecraft PE if running from VS directly. - -# Ignore original Minecraft PE assets. -/game/assets/environment/clouds.png -/game/assets/font/default.png -/game/assets/font/default8.png -/game/assets/gui/feedback.png -/game/assets/gui/feedback_fill.png -/game/assets/gui/feedback_outer.png -/game/assets/gui/background.png -/game/assets/gui/buynow.png -/game/assets/gui/default_world.png -/game/assets/gui/gui.png -/game/assets/gui/gui_blocks.png -/game/assets/gui/icons.png -/game/assets/gui/itemframe.png -/game/assets/gui/items.png -/game/assets/gui/menubuttons.png -/game/assets/gui/plusknapp.png -/game/assets/gui/raknet.png -/game/assets/gui/title.png -/game/assets/gui/touchgui.png -/game/assets/gui/controls/dpad.png -/game/assets/gui/controls/dpad_jump.png -/game/assets/gui/controls/dpadbutton.png -/game/assets/gui/selectworld/add.png -/game/assets/gui/startmenu/sm_multi.png -/game/assets/gui/startmenu/sm_options.png -/game/assets/gui/startmenu/sm_play.png -/game/assets/item/camera.png -/game/assets/misc/foliagecolor.png -/game/assets/misc/grasscolor.png -/game/assets/mob/char.png -/game/assets/mob/chicken.png -/game/assets/mob/cow.png -/game/assets/mob/creeper.png -/game/assets/mob/pig.png -/game/assets/mob/pigzombie.png -/game/assets/mob/sheep.png -/game/assets/mob/sheep_fur.png -/game/assets/mob/skeleton.png -/game/assets/mob/spider.png -/game/assets/mob/zombie.png -/game/assets/particles.png -/game/assets/terrain.png -/game/assets/gui/buynow.png -/game/assets/gui/controls/dpad.png -/game/assets/gui/controls/dpadbutton.png -/game/assets/gui/controls/dpad_jump.png -/game/assets/gui/feedback.png -/game/assets/gui/itemframe.png -/game/assets/gui/menubuttons.png -/game/assets/gui/plusknapp.png -/game/assets/gui/selectworld/add.png -/game/assets/gui/startmenu/sm_play.png -/game/assets/gui/startmenu/sm_multi.png -/game/assets/gui/startmenu/sm_options.png -/game/assets/gui/touchgui.png -/game/assets/gui/feedback_fill.png -/game/assets/gui/feedback_outer.png -/game/assets/snow.png -# Ignore all native iOS UI assets. -/game/assets/app/ios/ -# 0.7.0 -/game/assets/armor/chain_1.png -/game/assets/armor/chain_2.png -/game/assets/armor/cloth_1.png -/game/assets/armor/cloth_2.png -/game/assets/armor/diamond_1.png -/game/assets/armor/diamond_2.png -/game/assets/armor/gold_1.png -/game/assets/armor/gold_2.png -/game/assets/armor/iron_1.png -/game/assets/armor/iron_2.png -/game/assets/art/kz.png -/game/assets/gui/bg32.png -/game/assets/gui/spritesheet.png -/game/assets/gui/titleBG.png -/game/assets/gui/touchgui2.png -/game/assets/item/arrows.png -/game/assets/item/sign.png -# Sound -/game/assets/sound -/game/assets/newsound -/game/assets/sound3 -/game/assets/music -/game/assets/newmusic -# Java -/game/assets/terrain/sun.png -/game/assets/terrain/moon.png -/game/assets/misc/vignette.png -/game/assets/misc/shadow.png -/game/assets/misc/pumpkinblur.png -/game/assets/environment/rain.png -/game/assets/environment/snow.png -/game/assets/item/boat.png -/game/assets/item/cart.png -/game/assets/item/door.png -/game/assets/mob/ghast.png -/game/assets/mob/ghast_fire.png -/game/assets/mob/pigman.png -/game/assets/mob/saddle.png -/game/assets/mob/slime.png -/game/assets/mob/spider_eyes.png -/game/assets/mob/squid.png - -# Ignore the panorama textures. Adding them yourself will make the title screen use them. -/game/assets/gui/background/panorama_0.png -/game/assets/gui/background/panorama_1.png -/game/assets/gui/background/panorama_2.png -/game/assets/gui/background/panorama_3.png -/game/assets/gui/background/panorama_4.png -/game/assets/gui/background/panorama_5.png - -# Avoid including Minecraft Classic assets from Mojang, for now. -/game/assets/patches/*.png -/game/assets/patches/classic/*.png -!/game/assets/patches/n_rocket_launcher.png -!/game/assets/patches/n_rocket_launched.png -!/game/assets/patches/n_rocket.png - # Ignore keep directory - where you can keep files for later use /keep -# Ignore the games directory - where levels will be saved -/game/games - -# Ignore options.txt - where your configuration will be saved -/game/options.txt -/game/assetsO - # CLion /.idea /cmake-build-* @@ -270,4 +142,3 @@ xcuserdata/ # PCM sound extraction /tools/__pycache__ /tools/venv -/game/assets diff --git a/CMakeLists.txt b/CMakeLists.txt index 93580a9cc..ff4992991 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,6 +52,9 @@ else() link_libraries(Threads::Threads) endif() +# Disable thread local storage (needed for C++98 & iOS) +add_compile_options(-DRAPIDJSON_NO_THREAD_LOCAL -DSTBI_NO_THREAD_LOCALS) + # Android Logging if(ANDROID) link_libraries(log) diff --git a/GameMods.hpp b/GameMods.hpp index b102bd5a2..9ea563711 100644 --- a/GameMods.hpp +++ b/GameMods.hpp @@ -21,6 +21,7 @@ // Features (major changes) //#define FEATURE_PLANT_VEGGIES // Generates tall grass, and dead bushes around the world. +//#define FEATURE_GFX_SHADERS // Loads and uses Shaders from the assets folder for rendering. // Enhancements (minor changes) //#define ENH_ENTITY_SHADING // Allows shading of entities -- Currently we are abandoning this. Want to add normal support diff --git a/compat/LegacyCPP_Compat.hpp b/compat/LegacyCPP_Compat.hpp index 2d37ff0dd..4df9f87f4 100644 --- a/compat/LegacyCPP_Compat.hpp +++ b/compat/LegacyCPP_Compat.hpp @@ -3,6 +3,7 @@ #include "LegacyCPP_Info.hpp" #ifdef USE_OLD_CPP + #ifndef constexpr #define constexpr const #endif @@ -18,4 +19,46 @@ #ifndef noexcept #define noexcept #endif -#endif \ No newline at end of file + +/*#if !defined(_WIN32) + +namespace std +{ + template struct remove_reference { typedef T type; }; + template struct remove_reference { typedef T type; }; + template struct remove_reference { typedef T type; }; + + template< class T > + typename remove_reference::type&& move(T&& t) + { + return static_cast::type&&>(t); + } +} + +#endif // !defined(_WIN32)*/ + +#endif // USE_OLD_CPP + +// https://gcc.gnu.org/legacy-ml/gcc-help/2006-04/msg00062.html + +#define MC_FUNC_MOVE(className) \ +className& operator=(const className& move) \ +{ \ + className& other = const_cast(move); \ + _move(other); \ + return *this; \ +} + +#define MC_CTOR_MOVE(className) \ +className(const className& move) \ +{ \ + className& other = const_cast(move); \ + _move(other); \ +} + +#define MC_CTOR_MOVE_CUSTOM(className) \ +className(const className& move) \ +{ \ + className& other = const_cast(move); \ + _init(other); \ +} diff --git a/compat/PlatformDefinitions.h b/compat/PlatformDefinitions.h index d0aac412a..3404224e1 100644 --- a/compat/PlatformDefinitions.h +++ b/compat/PlatformDefinitions.h @@ -31,6 +31,13 @@ /* Apple - Device Simulator */ #define MC_PLATFORM_SIMULATOR (TARGET_OS_SIMULATOR || TARGET_IPHONE_SIMULATOR) +/* Google - Android */ +#if (defined(ANDROID)) +#define MC_PLATFORM_ANDROID 1 +#else +#define MC_PLATFORM_ANDROID 0 +#endif + /* Microsoft - Xbox */ #ifdef _XBOX #define MC_PLATFORM_XBOX 1 diff --git a/game/.gitignore b/game/.gitignore new file mode 100644 index 000000000..3034a9508 --- /dev/null +++ b/game/.gitignore @@ -0,0 +1,6 @@ +# Ignore the games directory - where levels will be saved +/games + +# Ignore options.txt - where your configuration will be saved +/options.txt +/assetsO \ No newline at end of file diff --git a/game/assets/.gitignore b/game/assets/.gitignore new file mode 100644 index 000000000..1d5645bc9 --- /dev/null +++ b/game/assets/.gitignore @@ -0,0 +1,123 @@ +#-- The 'game' directory is the default working directory for Minecraft PE if running from VS directly. + +# Ignore original Minecraft PE assets. +/environment/clouds.png +/font/default.png +/font/default8.png +/gui/feedback.png +/gui/feedback_fill.png +/gui/feedback_outer.png +/gui/background.png +/gui/buynow.png +/gui/default_world.png +/gui/gui.png +/gui/gui_blocks.png +/gui/icons.png +/gui/itemframe.png +/gui/items.png +/gui/menubuttons.png +/gui/plusknapp.png +/gui/raknet.png +/gui/title.png +/gui/touchgui.png +/gui/controls/dpad.png +/gui/controls/dpad_jump.png +/gui/controls/dpadbutton.png +/gui/selectworld/add.png +/gui/startmenu/sm_multi.png +/gui/startmenu/sm_options.png +/gui/startmenu/sm_play.png +/item/camera.png +/misc/foliagecolor.png +/misc/grasscolor.png +/mob/char.png +/mob/chicken.png +/mob/cow.png +/mob/creeper.png +/mob/pig.png +/mob/pigzombie.png +/mob/sheep.png +/mob/sheep_fur.png +/mob/skeleton.png +/mob/spider.png +/mob/zombie.png +/particles.png +/terrain.png +/gui/buynow.png +/gui/controls/dpad.png +/gui/controls/dpadbutton.png +/gui/controls/dpad_jump.png +/gui/feedback.png +/gui/itemframe.png +/gui/menubuttons.png +/gui/plusknapp.png +/gui/selectworld/add.png +/gui/startmenu/sm_play.png +/gui/startmenu/sm_multi.png +/gui/startmenu/sm_options.png +/gui/touchgui.png +/gui/feedback_fill.png +/gui/feedback_outer.png +/snow.png +# Ignore all native iOS UI assets. +/app/ios/ +# 0.7.0 +/armor/chain_1.png +/armor/chain_2.png +/armor/cloth_1.png +/armor/cloth_2.png +/armor/diamond_1.png +/armor/diamond_2.png +/armor/gold_1.png +/armor/gold_2.png +/armor/iron_1.png +/armor/iron_2.png +/art/kz.png +/gui/bg32.png +/gui/spritesheet.png +/gui/titleBG.png +/gui/touchgui2.png +/item/arrows.png +/item/sign.png +# Sound +/sound +/newsound +/sound3 +/music +/newmusic +# Java +/terrain/sun.png +/terrain/moon.png +/misc/vignette.png +/misc/shadow.png +/misc/pumpkinblur.png +/environment/rain.png +/environment/snow.png +/item/boat.png +/item/cart.png +/item/door.png +/mob/ghast.png +/mob/ghast_fire.png +/mob/pigman.png +/mob/saddle.png +/mob/slime.png +/mob/spider_eyes.png +/mob/squid.png + +# Ignore shaders for now +/shaders + +# Ignore the panorama textures. Adding them yourself will make the title screen use them. +/gui/background/panorama_0.png +/gui/background/panorama_1.png +/gui/background/panorama_2.png +/gui/background/panorama_3.png +/gui/background/panorama_4.png +/gui/background/panorama_5.png + +# Avoid including Minecraft Classic assets from Mojang, for now. +/patches/*.png +/patches/classic/*.png +!/patches/n_rocket_launcher.png +!/patches/n_rocket_launched.png +!/patches/n_rocket.png \ No newline at end of file diff --git a/game/assets/materials/common.json b/game/assets/materials/common.json new file mode 100644 index 000000000..de1f0b41d --- /dev/null +++ b/game/assets/materials/common.json @@ -0,0 +1,7 @@ +[ + {"path":"materials/particles.material"}, + {"path":"materials/shadows.material"}, + {"path":"materials/sky.material"}, + {"path":"materials/ui.material"}, + {"path":"materials/ui3D.material"} +] \ No newline at end of file diff --git a/game/assets/materials/entity.material b/game/assets/materials/entity.material new file mode 100644 index 000000000..329008c0a --- /dev/null +++ b/game/assets/materials/entity.material @@ -0,0 +1,121 @@ +{ + "entity_static": { + "states":["Textured"], + "vertexShader" : "shaders/entity.vertex", + "fragmentShader" : "shaders/entity.fragment" + }, + + "entity_flat_color": { + "vertexShader" : "shaders/position.vertex", + "fragmentShader" : "shaders/current_color.fragment" + }, + + "entity:entity_static": { + "defines":["USE_OVERLAY"] + }, + + "entity_change_color:entity_static": { + "defines":[ + "USE_OVERLAY", + "USE_COLOR_MASK" + ] + }, + + "entity_color_overlay": { + "states":["Blending"], + "depthFunc": "Equal", + "vertexShader" : "shaders/position.vertex", + "fragmentShader" : "shaders/current_color.fragment" + }, + + "entity_nocull:entity": { + "states":["DisableCulling"] + }, + + "entity_alphatest:entity_nocull": { + "states":["EnableAlphaTest"], + "defines":["ALPHA_TEST"] + }, + + "entity_alphatest_cull:entity": { + "states":["EnableAlphaTest"], + "defines":["ALPHA_TEST"] + }, + + "entity_alphablend:entity_nocull": { + "states" : [ + "Blending"] + }, + + "entity_emissive:entity": { + "defines":["USE_EMISSIVE"] + }, + + "entity_emissive_alpha:entity_nocull": { + "states":["EnableAlphaTest"], + "defines":[ + "ALPHA_TEST", + "USE_EMISSIVE"] + }, + + "entity_custom:entity": { + "states":["Blending", "EnableAlphaTest"], + "defines":["ALPHA_TEST", "Blending", "USE_OVERLAY", "USE_MASK"], + + "blendSrc": "SourceColor", + "blendDst": "Zero" + }, + + "primed_tnt:entity": { + "states":["Blending"], + + "blendSrc": "SourceAlpha", + "blendDst": "DestAlpha", + + "vertexShader" : "shaders/position.vertex", + "fragmentShader" : "shaders/current_color.fragment" + }, + + "slime_outer:entity": { + "states" : ["Blending"] + }, + + "item_in_hand:entity": { + "states": ["EnableAlphaTest"], + "defines": ["COLOR_BASED"] + }, + + "heavy_tile:entity_static": { + "states":["PolygonOffset"], + + "polygonOffsetLevel":-6 + }, + + "charged_creeper:entity_static": { + "defines": [ "USE_UV_ANIM" ], + "states": [ "Blending", "DisableCulling", "DisableDepthWrite" ], + "blendSrc":"One", + "blendDst":"One" + }, + + "item_in_hand_glint:item_in_hand": { + "defines": [ + "GLINT", + "USE_COLOR_MASK" + ] + }, + + "entity_glint:entity": { + "defines":[ + "GLINT", + "USE_COLOR_MASK" + ] + }, + + "entity_alphatest_glint:entity_alphatest": { + "defines":[ + "GLINT", + "USE_COLOR_MASK" + ] + } +} diff --git a/game/assets/materials/fancy.json b/game/assets/materials/fancy.json new file mode 100644 index 000000000..6baef0324 --- /dev/null +++ b/game/assets/materials/fancy.json @@ -0,0 +1,6 @@ +[ + {"path":"materials/fancy.material"}, + {"path":"materials/entity.material", "defines":["FANCY"]}, + {"path":"materials/terrain.material", "defines":["FANCY"]}, + {"path":"materials/terrain.material", "defines":["FANCY", "FOG"], "tag":"_fog"} +] \ No newline at end of file diff --git a/game/assets/materials/fancy.material b/game/assets/materials/fancy.material new file mode 100644 index 000000000..a65cfe2b7 --- /dev/null +++ b/game/assets/materials/fancy.material @@ -0,0 +1,15 @@ +{ + "clouds":{ + "states": [ + "Blending", + "DisableCulling", + "Textured", + "EnableAlphaTest" + ], + "depthFunc": "LessEqual", + + "vertexShader" : "shaders/cloud.vertex", + "fragmentShader" : "shaders/color.fragment" + } +} + diff --git a/game/assets/materials/particles.material b/game/assets/materials/particles.material new file mode 100644 index 000000000..d7b6c0ba9 --- /dev/null +++ b/game/assets/materials/particles.material @@ -0,0 +1,15 @@ +{ + "particles_opaque": { + "states": ["Textured"], + "vertexShader" : "shaders/color_uv.vertex", + "fragmentShader" : "shaders/color_texture.fragment" + }, + + "particles_alpha": { + "states":["Textured", "EnableAlphaTest"], + "defines":["ALPHA_TEST"], + + "vertexShader" : "shaders/color_uv.vertex", + "fragmentShader" : "shaders/color_texture.fragment" + } +} diff --git a/game/assets/materials/sad.json b/game/assets/materials/sad.json new file mode 100644 index 000000000..679799523 --- /dev/null +++ b/game/assets/materials/sad.json @@ -0,0 +1,6 @@ +[ + {"path":"materials/sad.material"}, + {"path":"materials/entity.material"}, + {"path":"materials/terrain.material"}, + {"path":"materials/terrain.material", "defines":["FOG"], "tag":"_fog"} +] \ No newline at end of file diff --git a/game/assets/materials/sad.material b/game/assets/materials/sad.material new file mode 100644 index 000000000..bb7901da3 --- /dev/null +++ b/game/assets/materials/sad.material @@ -0,0 +1,13 @@ +{ + "clouds":{ + "states": [ + "DisableCulling", + "Textured", + "EnableAlphaTest" + ], + + "vertexShader" : "shaders/cloud.vertex", + "fragmentShader" : "shaders/color.fragment" + } +} + diff --git a/game/assets/materials/shadows.material b/game/assets/materials/shadows.material new file mode 100644 index 000000000..d1c5e5237 --- /dev/null +++ b/game/assets/materials/shadows.material @@ -0,0 +1,108 @@ +{ + "shadow_front": { + "states": [ + "StencilWrite", + "DisableColorWrite", + "DisableDepthWrite", + "EnableStencilTest" + ], + + "vertexShader": "shaders/position.vertex", + "fragmentShader": "shaders/flat_white.fragment", + + "frontFace": { + "stencilFunc": "Always", + "stencilFailOp": "Keep", + "stencilDepthFailOp": "Keep", + "stencilPassOp": "Replace" + }, + + "backFace": { + "stencilFunc": "Always", + "stencilFailOp": "Keep", + "stencilDepthFailOp": "Keep", + "stencilPassOp": "Replace" + }, + + "stencilRef": 0, + "stencilReadMask": 255, + "stencilWriteMask": 1 + }, + + "shadow_back": { + "states": [ + "StencilWrite", + "DisableColorWrite", + "DisableDepthWrite", + "InvertCulling", + "EnableStencilTest" + ], + + "vertexShader": "shaders/position.vertex", + "fragmentShader": "shaders/flat_white.fragment", + + "frontFace": { + "stencilFunc": "Always", + "stencilFailOp": "Keep", + "stencilDepthFailOp": "Keep", + "stencilPassOp": "Replace" + }, + + "backFace": { + "stencilFunc": "Always", + "stencilFailOp": "Keep", + "stencilDepthFailOp": "Keep", + "stencilPassOp": "Replace" + }, + + "stencilRef": 1, + "stencilReadMask": 255, + "stencilWriteMask": 1 + }, + + "shadow_overlay": { + "states": [ + "DisableDepthTest", + "DisableCulling", + "Blending", + "EnableStencilTest" + ], + + "vertexShader": "shaders/color.vertex", + "fragmentShader": "shaders/color_ex.fragment", + + "frontFace": { + "stencilFunc": "Equal", + "stencilPass": "Replace" + }, + + "backFace": { + "stencilFunc": "Equal", + "stencilPass": "Replace" + }, + + "stencilRef": 1, + "stencilReadMask": 255, + "stencilWriteMask": 0 + }, + + "shadow_image_overlay": { + "states": [ + "DisableDepthWrite", + "Blending", + "Textured" + ], + + "vertexShader": "shaders/uv.vertex", + "fragmentShader": "shaders/texture.fragment" + }, + + "water_hole_front:shadow_front" : { + "stencilRef" : 1 + }, + + "water_hole_back:shadow_back" : { + "stencilRef" : 0 + } + +} diff --git a/game/assets/materials/sky.material b/game/assets/materials/sky.material new file mode 100644 index 000000000..05af52dc7 --- /dev/null +++ b/game/assets/materials/sky.material @@ -0,0 +1,47 @@ +{ + "sun_moon": { + "states":[ + "DisableDepthWrite", + "Blending", + "Textured"], + + "blendSrc": "SourceAlpha", + "blendDst": "One", + + "vertexShader" : "shaders/uv.vertex", + "fragmentShader" : "shaders/texture_ccolor.fragment" + }, + + "stars": { + "states":[ + "DisableDepthWrite", + "Blending"], + + "blendSrc": "OneMinusDestColor", + "blendDst": "One", + + "vertexShader" : "shaders/position.vertex", + "fragmentShader" : "shaders/current_color.fragment" + }, + + "sunrise": { + "states":[ + "DisableDepthWrite", + "Blending"], + + "blendSrc": "SourceAlpha", + "blendDst": "OneMinusSrcAlpha", + + "depthFunc": "LessEqual", + + "vertexShader" : "shaders/sky.vertex", + "fragmentShader" : "shaders/color.fragment" + }, + + "skyplane": { + "states":[ "DisableDepthWrite" ], + + "vertexShader" : "shaders/sky.vertex", + "fragmentShader" : "shaders/color.fragment" + } +} diff --git a/game/assets/materials/terrain.material b/game/assets/materials/terrain.material new file mode 100644 index 000000000..3d607ce05 --- /dev/null +++ b/game/assets/materials/terrain.material @@ -0,0 +1,116 @@ +{ + "terrain_opaque": { + "depthFunc": "LessEqual", + + "vertexShader": "shaders/renderchunk.vertex", + "fragmentShader": "shaders/renderchunk.fragment", + + "states": ["Textured"], + + "defines": [ "LOW_PRECISION" ] + }, + + "terrain_opaque_seasons:terrain_opaque": { + "defines": [ "SEASONS" ] + }, + + "terrain_blend:terrain_opaque": { + "defines": [ "BLEND", "NEAR_WATER" ], + "states": [ + "Blending", + "EnableStencilTest" + ], + + "frontFace": { + "stencilFunc": "NotEqual", + "stencilFailOp": "Keep", + "stencilDepthFailOp": "Keep", + "stencilPassOp": "Keep" + }, + + "backFace": { + "stencilFunc": "NotEqual", + "stencilFailOp": "Keep", + "stencilDepthFailOp": "Keep", + "stencilPassOp": "Keep" + }, + + "stencilRef": 1 + }, + + "terrain_blend_below:terrain_blend": { + "states": [ "InvertCulling" ] + }, + + "terrain_doubleside:terrain_opaque": { + "states": [ "DisableCulling" ] + }, + + "terrain_alpha_single_side:terrain_opaque": { + "states":["EnableAlphaTest"], + "defines": [ "ALPHA_TEST" ] + }, + + "terrain_alpha_seasons:terrain_opaque": { + "defines": [ "ALPHA_TEST", "SEASONS" ], + "states": [ "DisableCulling", "EnableAlphaTest" ] + }, + + "terrain_alpha:terrain_alpha_single_side": { + "states": [ "DisableCulling" ] + }, + + "terrain_opaque_fog:terrain_opaque": { + "defines": [ "FOG" ] + }, + + "terrain_blend_fog:terrain_blend": { + "defines": [ "FOG" ] + }, + + "terrain_doubleside_fog:terrain_doubleside": { + "defines": [ "FOG" ] + }, + + "terrain_alpha_single_side_fog:terrain_alpha_single_side": { + "defines": [ "FOG" ] + }, + + "terrain_alpha_fog:terrain_alpha": { + "defines": [ "FOG" ] + }, + + "terrain_far:terrain_opaque": { + "defines": [ + "FOG", + "LOW_PRECISION" + ] + }, + + "terrain_seasons_far:terrain_opaque_seasons": { + "defines": [ + "FOG", + "LOW_PRECISION" + ] + }, + + "terrain_seasons_far_alpha:terrain_opaque_seasons": { + "defines": [ + "FOG", + "LOW_PRECISION", + "SEASONS_FAR" + ] + }, + + "terrain_fading_in:terrain_far": { + "defines" : ["ALLOW_FADE"] + }, + + "terrain_seasons_fading_in:terrain_seasons_far": { + "defines": [ "ALLOW_FADE" ] + }, + + "terrain_seasons_fading_in_alpha:terrain_seasons_far_alpha": { + "defines" : ["ALLOW_FADE"] + } +} \ No newline at end of file diff --git a/game/assets/materials/ui.material b/game/assets/materials/ui.material new file mode 100644 index 000000000..8d2a173fe --- /dev/null +++ b/game/assets/materials/ui.material @@ -0,0 +1,228 @@ +{ + "ui_base": { + "states": [ + "EnableStencilTest", + "DisableDepthTest", + "Blending" + ], + + "frontFace": { + "stencilFunc": "Equal", + "stencilFailOp": "Keep", + "stencilDepthFailOp": "Keep", + "stencilPassOp": "Keep" + }, + + "backFace": { + "stencilFunc": "Equal", + "stencilFailOp": "Keep", + "stencilDepthFailOp": "Keep", + "stencilPassOp": "Keep" + }, + + "stencilReadMask": 127, + "stencilWriteMask": 127 + + }, + + "ui_texture_and_color:ui_base": { + "states": ["Textured"], + "vertexShader": "shaders/color_uv.vertex", + "fragmentShader": "shaders/color_texture.fragment" + }, + + "ui_texture_and_color_nocull:ui_texture_and_color": { + "states": ["DisableCulling"] + }, + + "ui_text:ui_texture_and_color": { + "states": [ + "EnableAlphaTest" + ], + "fragmentShader": "shaders/text.fragment" + }, + + "ui_fill_color:ui_base": { + + "vertexShader": "shaders/position.vertex", + "fragmentShader": "shaders/current_color.fragment" + }, + + "ui_fill_stencil:ui_base": { + + "vertexShader": "shaders/position.vertex", + "fragmentShader": "shaders/current_color.fragment", + + "states": [ + "StencilWrite", + "EnableStencilTest", + "DisableColorWrite", + "DisableDepthWrite" + ], + + "frontFace": { + "stencilFunc": "Always", + "stencilFailOp": "Replace", + "stencilDepthFailOp": "Replace", + "stencilPassOp": "Replace" + }, + + "backFace": { + "stencilFunc": "Always", + "stencilFailOp": "Replace", + "stencilDepthFailOp": "Replace", + "stencilPassOp": "Replace" + }, + + "stencilRef": 1 + }, + + "ui_fill_gradient:ui_base": { + + "vertexShader": "shaders/color.vertex", + "fragmentShader": "shaders/color.fragment" + }, + + "ui_textured:ui_base": { + "states": ["Textured"], + "vertexShader": "shaders/uv.vertex", + "fragmentShader": "shaders/texture.fragment" + }, + + "ui_textured_and_glcolor:ui_textured": { + "fragmentShader": "shaders/texture_ccolor.fragment" + }, + + "ui_item:ui_base": { + "vertexShader": "shaders/color_uv.vertex", + "fragmentShader": "shaders/color_texture.fragment", + + "states":["EnableAlphaTest", "Textured"], + + "defines": [ "ALPHA_TEST" ] + }, + + "ui_item_foil_stencil:ui_item": { + "vertexShader": "shaders/color_uv.vertex", + "fragmentShader": "shaders/color_texture.fragment", + + "states": [ + "StencilWrite", + "EnableStencilTest" + ], + + "frontFace": { + "stencilFunc": "Always", + "stencilPassOp": "Replace" + }, + + "backFace": { + "stencilFunc": "Always", + "stencilPassOp": "Replace" + }, + + "stencilRef": 255, + "stencilReadMask": 128, + "stencilWriteMask": 128, + + "defines": [ "ALPHA_TEST" ] + }, + + "ui_item_glint:ui_base": { + "states": ["Textured"], + "vertexShader": "shaders/color_uv.vertex", + "fragmentShader": "shaders/color_texture.fragment", + "defines": [ "GLINT" ] + }, + + "ui_inventory_item_glint:ui_item_glint": { + "blendSrc": "SourceColor", + "blendDst": "One", + + "states": [ "EnableStencilTest" ], + + "frontFace": { + "stencilFunc": "Equal" + }, + + "backFace": { + "stencilFunc": "Equal" + }, + + "stencilRef": 255, + "stencilReadMask": 128, + "stencilWriteMask": 0, + + "defines": [ "INVENTORY" ] + }, + + "ui_vignette:ui_textured": { + "blendSrc": "Zero", + "blendDst": "OneMinusSrcColor" + }, + + "ui_overlay:ui_base": { + "vertexShader": "shaders/position.vertex", + "fragmentShader": "shaders/flat_white.fragment" + }, + + "ui_invert_overlay:ui_overlay": { + "blendSrc": "OneMinusDestColor", + "blendDst": "OneMinusSrcColor" + }, + + "ui_overlay_textured:ui_overlay": { + "states": ["Textured"], + "vertexShader": "shaders/uv.vertex", + "fragmentShader": "shaders/texture.fragment" + }, + + "ui_invert_overlay_textured:ui_overlay_textured": { + "blendSrc": "OneMinusDestColor", + "blendDst": "OneMinusSrcColor" + }, + + "ui_cubemap:ui_base": { + "states": ["Textured"], + "vertexShader": "shaders/uv.vertex", + "fragmentShader": "shaders/texture.fragment" + }, + + "ui_background:ui_cubemap": { + "states": [ + "DisableCulling" + ] + }, + + "ui_title_tile": { + "vertexShader": "shaders/color_uv.vertex", + "fragmentShader": "shaders/color_texture.fragment", + + "states": [ + "EnableStencilTest", + "DisableCulling", + "Blending", + "EnableAlphaTest", + "Textured" + ], + + "defines": [ "ALPHA_TEST" ] + }, + + "ui_title_tile_shadow": { + "vertexShader": "shaders/color.vertex", + "fragmentShader": "shaders/color.fragment", + + "states": [ + "DisableCulling", + "Blending", + "Textured" + ] + }, + + "ui_crosshair:ui_invert_overlay": { + "states": ["Textured"], + "vertexShader": "shaders/uv.vertex", + "fragmentShader": "shaders/texture.fragment" + } +} diff --git a/game/assets/materials/ui3D.material b/game/assets/materials/ui3D.material new file mode 100644 index 000000000..9471136b8 --- /dev/null +++ b/game/assets/materials/ui3D.material @@ -0,0 +1,151 @@ +{ + "block_overlay": { + "states": [ + "PolygonOffset", + "Blending", + "Textured", + "EnableAlphaTest" + ], + + "polygonOffsetLevel": -0.6, + + "depthFunc": "LessEqual", + + "vertexShader": "shaders/uv.vertex", + "fragmentShader": "shaders/texture_cutout.fragment" + }, + + "selection_overlay:block_overlay": { + "blendSrc": "DestColor", + "blendDst": "SourceColor" + }, + + "selection_overlay_opaque:selection_overlay": { + "fragmentShader": "shaders/current_color.fragment" + }, + + "selection_overlay_double_sided:selection_overlay": { + "states": [ + "DisableCulling" + ] + }, + + "selection_box": { + "states": [ + "DisableDepthWrite", + "Blending" + ], + + "defines": [ "LINE_STRIP" ], + + "depthFunc": "LessEqual", + "vertexShader": "shaders/selection_box.vertex", + "fragmentShader": "shaders/current_color.fragment" + }, + + "cracks_overlay:block_overlay": { + + "blendSrc": "DestColor", + "blendDst": "SourceColor", + + "depthFunc": "LessEqual", + + "fragmentShader": "shaders/texture.fragment" + }, + + "cracks_overlay_tile_entity:cracks_overlay": { + "vertexShader": "shaders/uv_scale.vertex" + }, + + "name_tag": { + "states": [ "Blending", "DisableDepthWrite" ], + + "depthFunc": "Always", + + "vertexShader": "shaders/position.vertex", + "fragmentShader": "shaders/current_color.fragment" + }, + + "name_tag_depth_tested:name_tag": { + "depthFunc": "LessEqual" + }, + + "sign_text": { + "states": [ + "PolygonOffset", + "Blending", + "EnableAlphaTest" + ], + + "defines": [ + "ALPHA_TEST" + ], + + "depthFunc": "LessEqual", + + "vertexShader": "shaders/color_uv.vertex", + "fragmentShader": "shaders/text.fragment" + }, + + "name_text_depth_tested:sign_text": { + }, + + "white_mat": { + "vertexShader": "shaders/position.vertex", + "fragmentShader": "shaders/flat_white.fragment" + }, + + "rain": { + "states": [ "DisableCulling", "DisableDepthWrite", "Blending" ], + + "blendSrc": "SourceAlpha", + "blendDst": "OneMinusSrcAlpha", + + "depthFunc": "LessEqual", + + "vertexShader": "shaders/rain_snow.vertex", + "fragmentShader": "shaders/rain_snow.fragment" + }, + + "snow": { + "states": [ "DisableCulling", "DisableDepthWrite", "Blending" ], + + "blendSrc": "SourceAlpha", + "blendDst": "OneMinusSrcAlpha", + + "depthFunc": "LessEqual", + + "vertexShader": "shaders/rain_snow.vertex", + "fragmentShader": "shaders/rain_snow.fragment" + }, + + "weather": { + "defines": [ + "ALPHA_TEST" + ], + "states": [ "DisableCulling", "EnableAlphaTest" ], + + "depthFunc": "LessEqual", + + "vertexShader": "shaders/weather.vertex", + "fragmentShader": "shaders/weather.fragment" + }, + + "lightning": { + "states": [ "DisableCulling", "Blending" ], + + "depthFunc": "LessEqual", + "blendSrc": "SourceAlpha", + "blendDst": "One", + + "vertexShader": "shaders/color.vertex", + "fragmentShader": "shaders/color.fragment" + }, + + "debug": { + "depthFunc": "LessEqual", + + "vertexShader": "shaders/color.vertex", + "fragmentShader": "shaders/color.fragment" + } +} \ No newline at end of file diff --git a/platforms/android/AppPlatform_android.cpp b/platforms/android/AppPlatform_android.cpp index 2d0ce402f..f2e965dbb 100644 --- a/platforms/android/AppPlatform_android.cpp +++ b/platforms/android/AppPlatform_android.cpp @@ -135,38 +135,6 @@ std::string AppPlatform_android::getDateString(int time) return std::string(buffer); } -Texture AppPlatform_android::loadTexture(const std::string& str, bool bIsRequired) -{ - std::string realPath = str; - if (realPath.size() && realPath[0] == '/') - // trim it off - realPath = realPath.substr(1); - - AAsset* asset = AAssetManager_open(m_app->activity->assetManager, str.c_str(), AASSET_MODE_BUFFER); - if (!asset) { - LOG_E("File %s couldn't be opened", realPath.c_str()); - assert(!bIsRequired && "Hey, a texture couldn't be loaded"); - return Texture(0, 0, nullptr, 1, 0); - } - size_t cnt = AAsset_getLength(asset); - unsigned char* buffer = (unsigned char*)calloc(cnt, sizeof(unsigned char)); - AAsset_read(asset, (void*)buffer, cnt); - AAsset_close(asset); - - int width = 0, height = 0, channels = 0; - - stbi_uc* img = stbi_load_from_memory(buffer, cnt, &width, &height, &channels, STBI_rgb_alpha); - if (!img) - { - LOG_E("File %s couldn't be loaded via stb_image", realPath.c_str()); - assert(!bIsRequired && "Hey, a texture couldn't be loaded"); - return Texture(0, 0, nullptr, 1, 0); - } - - free(buffer); - return Texture(width, height, (uint32_t*)img, 1, 0); -} - SoundSystem* const AppPlatform_android::getSoundSystem() const { return m_pSoundSystem; @@ -185,53 +153,6 @@ bool AppPlatform_android::isTouchscreen() const return true; } -/* -std::vector AppPlatform_android::getOptionStrings() -{ - std::vector o; - - //o.push_back("mp_username"); - //o.push_back("iProgramInCpp"); - - std::ifstream ifs("options.txt"); - if (!ifs.is_open()) - return o; - - std::string str; - while (true) - { - if (!std::getline(ifs, str, '\n')) - break; - - if (str.empty() || str[0] == '#') - continue; - - std::stringstream ss; - ss << str; - - std::string key, value; - if (std::getline(ss, key, '|') && std::getline(ss, value)) - { - o.push_back(key); - o.push_back(value); - } - } - - return o; -} - -void AppPlatform_android::setOptionStrings(const std::vector& str) -{ - assert(str.size() % 2 == 0); - - std::ofstream os("options.txt"); - - os << "#Config file for Minecraft PE. The # at the start denotes a comment, removing it makes it a command.\n\n"; - - for (int i = 0; i < int(str.size()); i += 2) - os << str[i] << '|' << str[i + 1] << '\n'; -} -*/ void AppPlatform_android::setScreenSize(int width, int height) { m_ScreenWidth = width; diff --git a/platforms/android/AppPlatform_android.hpp b/platforms/android/AppPlatform_android.hpp index f7420a7c5..c9515eabd 100644 --- a/platforms/android/AppPlatform_android.hpp +++ b/platforms/android/AppPlatform_android.hpp @@ -14,9 +14,6 @@ #include "source/common/Utils.hpp" #include "android_native_app_glue.h" -// note: probably won't add AppPlatform_android until it's time -// to build an Android app - class AppPlatform_android : public AppPlatform { public: @@ -33,8 +30,6 @@ class AppPlatform_android : public AppPlatform int getScreenHeight() const override; void showDialog(eDialogType) override; std::string getDateString(int time) override; - Texture loadTexture(const std::string& str, bool b) override; - //std::vector getOptionStrings() override; // Also add these to allow proper turning within the game. void recenterMouse() override; @@ -50,8 +45,6 @@ class AppPlatform_android : public AppPlatform void hideKeyboard() override; int getKeyboardUpOffset() override; - // Also add these to allow saving options. - //void setOptionStrings(const std::vector & str) override; bool hasFileSystemAccess() override; SoundSystem* const getSoundSystem() const override; diff --git a/platforms/ios/AppPlatform_iOS.h b/platforms/ios/AppPlatform_iOS.h index 742924b9e..45cf6fa62 100644 --- a/platforms/ios/AppPlatform_iOS.h +++ b/platforms/ios/AppPlatform_iOS.h @@ -32,7 +32,7 @@ class AppPlatform_iOS : public AppPlatform int checkLicense() override; int getScreenWidth() const override; int getScreenHeight() const override; - Texture loadTexture(const std::string& path, bool b = false) override; + void loadImage(ImageData& data, const std::string& path) override; bool doesTextureExist(const std::string& path) const override; int getUserInputStatus() override; bool isTouchscreen() const override; diff --git a/platforms/ios/AppPlatform_iOS.mm b/platforms/ios/AppPlatform_iOS.mm index 6e929b500..62dd3583f 100644 --- a/platforms/ios/AppPlatform_iOS.mm +++ b/platforms/ios/AppPlatform_iOS.mm @@ -64,12 +64,8 @@ return m_pViewController.height; } -Texture AppPlatform_iOS::loadTexture(const std::string& path, bool b) +void AppPlatform_iOS::loadImage(ImageData& data, const std::string& path) { - Texture out; - out.m_hasAlpha = true; - out.field_D = 0; - std::string realPath = getAssetPath(path); UIImage * image = [UIImage imageWithContentsOfFile: @@ -78,28 +74,26 @@ if (!image || !image.CGImage) { LOG_E("Couldn't find file: %s", path.c_str()); - return out; + return; } - out.m_width = CGImageGetWidth(image.CGImage); - out.m_height = CGImageGetHeight(image.CGImage); - out.m_pixels = new uint32_t[out.m_width * out.m_height]; + data.m_width = CGImageGetWidth(image.CGImage); + data.m_height = CGImageGetHeight(image.CGImage); + data.m_data = (uint8_t*)new uint32_t[data.m_width * data.m_height]; CGColorSpace *colorSpace = CGColorSpaceCreateDeviceRGB(); - CGContextRef context = CGBitmapContextCreate(out.m_pixels, out.m_width, out.m_height, 8u, sizeof(uint32_t) * out.m_width, colorSpace, 0x4001u); + CGContextRef context = CGBitmapContextCreate(data.m_data, data.m_width, data.m_height, 8u, sizeof(uint32_t) * data.m_width, colorSpace, 0x4001u); CGColorSpaceRelease(colorSpace); CGRect rect; rect.origin.x = 0.0; rect.origin.y = 0.0; - rect.size.width = static_cast(out.m_width); - rect.size.height = static_cast(out.m_height); + rect.size.width = static_cast(data.m_width); + rect.size.height = static_cast(data.m_height); CGContextClearRect(context, rect); CGContextTranslateCTM(context, 0.0, 0.0); CGContextDrawImage(context, rect, image.CGImage); CGContextRelease(context); - - return out; } bool AppPlatform_iOS::doesTextureExist(const std::string& path) const @@ -158,6 +152,7 @@ size_t slashPos = path.rfind("/", -1, 1); size_t dotPos2 = path.rfind('.', -1); std::string fileName; + std::string fileDir = "assets/" + path.substr(0, slashPos + 1); std::string fileExtension = dotPos2 != std::string::npos ? path.substr(dotPos2+1, path.length()-dotPos2) : ""; if ((slashPos & dotPos) != std::string::npos) { @@ -171,7 +166,8 @@ return [[NSBundle mainBundle] pathForResource:[NSString stringWithUTF8String:fileName.c_str()] - ofType:[NSString stringWithUTF8String:fileExtension.c_str()]]; + ofType:[NSString stringWithUTF8String:fileExtension.c_str()] + inDirectory: [NSString stringWithUTF8String:fileDir.c_str()]]; } std::string AppPlatform_iOS::getAssetPath(const std::string &path) const diff --git a/platforms/macos/projects/Configuration/GlobalSettings.xcconfig b/platforms/macos/projects/Configuration/GlobalSettings.xcconfig index ffa5aa7b3..61dd18836 100644 --- a/platforms/macos/projects/Configuration/GlobalSettings.xcconfig +++ b/platforms/macos/projects/Configuration/GlobalSettings.xcconfig @@ -6,8 +6,8 @@ // // -GCC_PREPROCESSOR_DEFINITIONS_GLOBAL = $(inherited) USE_OPENAL HANDLE_CHARS_SEPARATELY +GCC_PREPROCESSOR_DEFINITIONS_GLOBAL = $(inherited) MCE_GFX_API_OGL=1 USE_OPENAL HANDLE_CHARS_SEPARATELY GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_GLOBAL) GCC_SYMBOLS_PRIVATE_EXTERN_GLOBAL = YES -GCC_SYMBOLS_PRIVATE_EXTERN = $(GCC_SYMBOLS_PRIVATE_EXTERN_GLOBAL) \ No newline at end of file +GCC_SYMBOLS_PRIVATE_EXTERN = $(GCC_SYMBOLS_PRIVATE_EXTERN_GLOBAL) diff --git a/platforms/macos/projects/Configuration/Settings_iOS.xcconfig b/platforms/macos/projects/Configuration/Settings_iOS.xcconfig index 37027b277..34a4bc1c5 100644 --- a/platforms/macos/projects/Configuration/Settings_iOS.xcconfig +++ b/platforms/macos/projects/Configuration/Settings_iOS.xcconfig @@ -8,7 +8,7 @@ #include "GlobalSettings.xcconfig" -GCC_PREPROCESSOR_DEFINITIONS_IOS = USE_GLES $(GCC_PREPROCESSOR_DEFINITIONS_GLOBAL) +GCC_PREPROCESSOR_DEFINITIONS_IOS = USE_GLES RAPIDJSON_NO_THREAD_LOCAL STBI_NO_THREAD_LOCALS $(GCC_PREPROCESSOR_DEFINITIONS_GLOBAL) GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_IOS) SDKROOT_IOS = iphoneos @@ -18,6 +18,8 @@ SDKROOT = $(SDKROOT_IOS) ARCHS_IOS = armv6 armv7 armv7s arm64 ARCHS = $(ARCHS_IOS) +// Set this to the iOS version of the device you intend to debug with // Should be raised if Xcode gives ambiguous error //IPHONEOS_DEPLOYMENT_TARGET = 3.0 // iOS 3.0 + TARGETED_DEVICE_FAMILY = 1,2 // iPhone/iPad diff --git a/platforms/macos/projects/Configuration/Settings_macOS.xcconfig b/platforms/macos/projects/Configuration/Settings_macOS.xcconfig index 4939da06c..27228e39d 100644 --- a/platforms/macos/projects/Configuration/Settings_macOS.xcconfig +++ b/platforms/macos/projects/Configuration/Settings_macOS.xcconfig @@ -33,5 +33,5 @@ VALID_ARCHS = $(VALID_ARCHS_MACOS) // Just use whatever Xcode is trying to use... ARCHS = $(ARCHS) -BACKEND_SDL1 = USE_SDL1 STBI_NO_THREAD_LOCALS -BACKEND_SDL2 = USE_SDL2 \ No newline at end of file +BACKEND_SDL1 = USE_SDL1 RAPIDJSON_NO_THREAD_LOCAL STBI_NO_THREAD_LOCALS +BACKEND_SDL2 = USE_SDL2 RAPIDJSON_NO_THREAD_LOCAL \ No newline at end of file diff --git a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj index 783d060b7..3584390a4 100644 --- a/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj +++ b/platforms/macos/projects/Minecraft/Minecraft.xcodeproj/project.pbxproj @@ -15,7 +15,6 @@ 8406FD302AF1820700B09C1D /* RakNetInstance.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD64F2AC810620006A435 /* RakNetInstance.hpp */; }; 8406FD322AF1823600B09C1D /* CThread.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD6272AC810620006A435 /* CThread.hpp */; }; 8406FD332AF1823600B09C1D /* Logger.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD6292AC810620006A435 /* Logger.hpp */; }; - 8406FD352AF1823600B09C1D /* Matrix.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD62C2AC810620006A435 /* Matrix.hpp */; }; 8406FD362AF1823600B09C1D /* Mth.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD62E2AC810620006A435 /* Mth.hpp */; }; 8406FD372AF1823600B09C1D /* Random.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD6302AC810620006A435 /* Random.hpp */; }; 8406FD392AF1823700B09C1D /* Timer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD6342AC810620006A435 /* Timer.hpp */; }; @@ -269,7 +268,6 @@ 8470AF3D2BE9B6FA00BCA54E /* FireworkParticle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 8470AF3B2BE9B6FA00BCA54E /* FireworkParticle.hpp */; }; 8470AF402BE9B80900BCA54E /* DisconnectionScreen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8470AF3E2BE9B80900BCA54E /* DisconnectionScreen.cpp */; }; 8470AF412BE9B80900BCA54E /* DisconnectionScreen.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 8470AF3F2BE9B80900BCA54E /* DisconnectionScreen.hpp */; }; - 8470AF442BE9B98000BCA54E /* clouds.png in Resources */ = {isa = PBXBuildFile; fileRef = 8470AF432BE9B8B600BCA54E /* clouds.png */; }; 8477B3A22C4DC374004E1AC5 /* ControllerBuildInput.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8477B39C2C4DC374004E1AC5 /* ControllerBuildInput.cpp */; }; 8477B3A32C4DC374004E1AC5 /* ControllerBuildInput.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 8477B39D2C4DC374004E1AC5 /* ControllerBuildInput.hpp */; }; 8477B3A42C4DC374004E1AC5 /* ControllerMoveInput.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8477B39E2C4DC374004E1AC5 /* ControllerMoveInput.cpp */; }; @@ -286,118 +284,23 @@ 8477B3B72C4DC414004E1AC5 /* EmptyLevelChunk.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 8477B3B22C4DC414004E1AC5 /* EmptyLevelChunk.hpp */; }; 8477B3BA2C4DC42E004E1AC5 /* Vec2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8477B3B82C4DC42E004E1AC5 /* Vec2.cpp */; }; 8477B3BB2C4DC42E004E1AC5 /* Vec2.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 8477B3B92C4DC42E004E1AC5 /* Vec2.hpp */; }; - 8477B4092C4DE77F004E1AC5 /* bg128.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3BE2C4DE77F004E1AC5 /* bg128.png */; }; - 8477B40A2C4DE77F004E1AC5 /* bg64.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3BF2C4DE77F004E1AC5 /* bg64.png */; }; - 8477B40B2C4DE77F004E1AC5 /* cancel_0.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3C12C4DE77F004E1AC5 /* cancel_0.png */; }; - 8477B40C2C4DE77F004E1AC5 /* cancel_0_1.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3C22C4DE77F004E1AC5 /* cancel_0_1.png */; }; - 8477B40D2C4DE77F004E1AC5 /* cancel_0_3.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3C32C4DE77F004E1AC5 /* cancel_0_3.png */; }; - 8477B40E2C4DE77F004E1AC5 /* cancel_1.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3C42C4DE77F004E1AC5 /* cancel_1.png */; }; - 8477B40F2C4DE77F004E1AC5 /* cancel_1_1.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3C52C4DE77F004E1AC5 /* cancel_1_1.png */; }; - 8477B4102C4DE77F004E1AC5 /* cancel_1_3.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3C62C4DE77F004E1AC5 /* cancel_1_3.png */; }; - 8477B4112C4DE77F004E1AC5 /* create_0.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3C72C4DE77F004E1AC5 /* create_0.png */; }; - 8477B4122C4DE77F004E1AC5 /* create_0_1.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3C82C4DE77F004E1AC5 /* create_0_1.png */; }; - 8477B4132C4DE77F004E1AC5 /* create_0_3.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3C92C4DE77F004E1AC5 /* create_0_3.png */; }; - 8477B4142C4DE77F004E1AC5 /* create_1.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3CA2C4DE77F004E1AC5 /* create_1.png */; }; - 8477B4152C4DE77F004E1AC5 /* create_1_1.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3CB2C4DE77F004E1AC5 /* create_1_1.png */; }; - 8477B4162C4DE77F004E1AC5 /* create_1_3.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3CC2C4DE77F004E1AC5 /* create_1_3.png */; }; - 8477B4172C4DE77F004E1AC5 /* cancel_0_4.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3CE2C4DE77F004E1AC5 /* cancel_0_4.png */; }; - 8477B4182C4DE77F004E1AC5 /* cancel_1_4.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3CF2C4DE77F004E1AC5 /* cancel_1_4.png */; }; - 8477B4192C4DE77F004E1AC5 /* create_0_4.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3D02C4DE77F004E1AC5 /* create_0_4.png */; }; - 8477B41A2C4DE77F004E1AC5 /* create_1_4.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3D12C4DE77F004E1AC5 /* create_1_4.png */; }; - 8477B41B2C4DE77F004E1AC5 /* creative_0_4.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3D22C4DE77F004E1AC5 /* creative_0_4.png */; }; - 8477B41C2C4DE77F004E1AC5 /* creative_1_4.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3D32C4DE77F004E1AC5 /* creative_1_4.png */; }; - 8477B41D2C4DE77F004E1AC5 /* creative_3_4.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3D42C4DE77F004E1AC5 /* creative_3_4.png */; }; - 8477B41E2C4DE77F004E1AC5 /* survival_0_4.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3D52C4DE77F004E1AC5 /* survival_0_4.png */; }; - 8477B41F2C4DE77F004E1AC5 /* survival_1_4.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3D62C4DE77F004E1AC5 /* survival_1_4.png */; }; - 8477B4202C4DE77F004E1AC5 /* survival_3_4.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3D72C4DE77F004E1AC5 /* survival_3_4.png */; }; - 8477B4212C4DE77F004E1AC5 /* worldname_ipad_4.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3D82C4DE77F004E1AC5 /* worldname_ipad_4.png */; }; - 8477B4222C4DE77F004E1AC5 /* save_0.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3D92C4DE77F004E1AC5 /* save_0.png */; }; - 8477B4232C4DE77F004E1AC5 /* save_0_3.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3DA2C4DE77F004E1AC5 /* save_0_3.png */; }; - 8477B4242C4DE77F004E1AC5 /* save_1.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3DB2C4DE77F004E1AC5 /* save_1.png */; }; - 8477B4252C4DE77F004E1AC5 /* save_1_3.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3DC2C4DE77F004E1AC5 /* save_1_3.png */; }; - 8477B4262C4DE77F004E1AC5 /* worldname_ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3DD2C4DE77F004E1AC5 /* worldname_ipad.png */; }; - 8477B4272C4DE77F004E1AC5 /* worldname_ipad_3.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3DE2C4DE77F004E1AC5 /* worldname_ipad_3.png */; }; - 8477B4282C4DE77F004E1AC5 /* worldname_iphone.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3DF2C4DE77F004E1AC5 /* worldname_iphone.png */; }; - 8477B4292C4DE77F004E1AC5 /* worldname_iphone_3.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3E02C4DE77F004E1AC5 /* worldname_iphone_3.png */; }; - 8477B42A2C4DE77F004E1AC5 /* cancel_0_1.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3E22C4DE77F004E1AC5 /* cancel_0_1.png */; }; - 8477B42B2C4DE77F004E1AC5 /* cancel_0_3.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3E32C4DE77F004E1AC5 /* cancel_0_3.png */; }; - 8477B42C2C4DE77F004E1AC5 /* cancel_1_1.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3E42C4DE77F004E1AC5 /* cancel_1_1.png */; }; - 8477B42D2C4DE77F004E1AC5 /* cancel_1_3.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3E52C4DE77F004E1AC5 /* cancel_1_3.png */; }; - 8477B42E2C4DE77F004E1AC5 /* create_0_1.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3E62C4DE77F004E1AC5 /* create_0_1.png */; }; - 8477B42F2C4DE77F004E1AC5 /* create_0_3.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3E72C4DE77F004E1AC5 /* create_0_3.png */; }; - 8477B4302C4DE77F004E1AC5 /* create_1_1.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3E82C4DE77F004E1AC5 /* create_1_1.png */; }; - 8477B4312C4DE77F004E1AC5 /* create_1_3.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3E92C4DE77F004E1AC5 /* create_1_3.png */; }; - 8477B4322C4DE77F004E1AC5 /* creative_0_3.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3EA2C4DE77F004E1AC5 /* creative_0_3.png */; }; - 8477B4332C4DE77F004E1AC5 /* creative_1_3.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3EB2C4DE77F004E1AC5 /* creative_1_3.png */; }; - 8477B4342C4DE77F004E1AC5 /* survival_0_3.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3EC2C4DE77F004E1AC5 /* survival_0_3.png */; }; - 8477B4352C4DE77F004E1AC5 /* survival_1_3.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3ED2C4DE77F004E1AC5 /* survival_1_3.png */; }; - 8477B4362C4DE77F004E1AC5 /* worldname.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3EE2C4DE77F004E1AC5 /* worldname.png */; }; - 8477B4372C4DE77F004E1AC5 /* worldname_3.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3EF2C4DE77F004E1AC5 /* worldname_3.png */; }; - 8477B4382C4DE77F004E1AC5 /* worldname_ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3F02C4DE77F004E1AC5 /* worldname_ipad.png */; }; - 8477B4392C4DE77F004E1AC5 /* worldname_ipad_3.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3F12C4DE77F004E1AC5 /* worldname_ipad_3.png */; }; - 8477B43A2C4DE77F004E1AC5 /* worldname_iphone.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3F22C4DE77F004E1AC5 /* worldname_iphone.png */; }; - 8477B43B2C4DE77F004E1AC5 /* worldname_iphone5_3.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3F32C4DE77F004E1AC5 /* worldname_iphone5_3.png */; }; - 8477B43C2C4DE77F004E1AC5 /* worldname_iphone_3.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3F42C4DE77F004E1AC5 /* worldname_iphone_3.png */; }; - 8477B43D2C4DE77F004E1AC5 /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3F62C4DE77F004E1AC5 /* Icon-72.png */; }; - 8477B43E2C4DE77F004E1AC5 /* Icon-72_lite.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3F72C4DE77F004E1AC5 /* Icon-72_lite.png */; }; - 8477B43F2C4DE77F004E1AC5 /* Icon-Small-50.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3F82C4DE77F004E1AC5 /* Icon-Small-50.png */; }; - 8477B4402C4DE77F004E1AC5 /* Icon-Small-50_lite.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3F92C4DE77F004E1AC5 /* Icon-Small-50_lite.png */; }; - 8477B4412C4DE77F004E1AC5 /* Icon-Small.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3FA2C4DE77F004E1AC5 /* Icon-Small.png */; }; - 8477B4422C4DE77F004E1AC5 /* Icon-Small@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3FB2C4DE77F004E1AC5 /* Icon-Small@2x.png */; }; - 8477B4432C4DE77F004E1AC5 /* Icon-Small@2x_lite.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3FC2C4DE77F004E1AC5 /* Icon-Small@2x_lite.png */; }; - 8477B4442C4DE77F004E1AC5 /* Icon-Small_lite.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3FD2C4DE77F004E1AC5 /* Icon-Small_lite.png */; }; - 8477B4452C4DE77F004E1AC5 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3FE2C4DE77F004E1AC5 /* Icon.png */; }; - 8477B4462C4DE77F004E1AC5 /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B3FF2C4DE77F004E1AC5 /* Icon@2x.png */; }; - 8477B4472C4DE77F004E1AC5 /* Icon@2x_lite.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B4002C4DE77F004E1AC5 /* Icon@2x_lite.png */; }; - 8477B4482C4DE77F004E1AC5 /* Icon_lite.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B4012C4DE77F004E1AC5 /* Icon_lite.png */; }; - 8477B4492C4DE77F004E1AC5 /* mcpe_ios_icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B4022C4DE77F004E1AC5 /* mcpe_ios_icon.png */; }; - 8477B44A2C4DE77F004E1AC5 /* mcpe_lite_ios_icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B4032C4DE77F004E1AC5 /* mcpe_lite_ios_icon.png */; }; - 8477B44B2C4DE77F004E1AC5 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B4052C4DE77F004E1AC5 /* Default-568h@2x.png */; }; - 8477B44C2C4DE77F004E1AC5 /* Default-Landscape~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B4062C4DE77F004E1AC5 /* Default-Landscape~ipad.png */; }; - 8477B44D2C4DE77F004E1AC5 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B4072C4DE77F004E1AC5 /* Default.png */; }; - 8477B44E2C4DE77F004E1AC5 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8477B4082C4DE77F004E1AC5 /* Default@2x.png */; }; 8488C08A2B1EDD4F001AEC4F /* ShowKeyboardView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8488C0892B1EDD4F001AEC4F /* ShowKeyboardView.mm */; }; 848CBD102AFD847C007634F6 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 848CBD0F2AFD847C007634F6 /* AVFoundation.framework */; }; 849259202AD8FCFC0081F5B9 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8489B3212A86E464004CA8EC /* Foundation.framework */; }; - 849259562AD8FD4F0081F5B9 /* minecraftpeViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 849259482AD8FD4F0081F5B9 /* minecraftpeViewController.xib */; }; 849259592AD8FD4F0081F5B9 /* minecraftpeAppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8492594E2AD8FD4F0081F5B9 /* minecraftpeAppDelegate.mm */; }; 8492595A2AD8FD4F0081F5B9 /* minecraftpeViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 849259502AD8FD4F0081F5B9 /* minecraftpeViewController.mm */; }; - 8492595B2AD8FD4F0081F5B9 /* Shader.fsh in Sources */ = {isa = PBXBuildFile; fileRef = 849259522AD8FD4F0081F5B9 /* Shader.fsh */; }; - 8492595C2AD8FD4F0081F5B9 /* Shader.vsh in Sources */ = {isa = PBXBuildFile; fileRef = 849259532AD8FD4F0081F5B9 /* Shader.vsh */; }; - 849259602AD8FDCB0081F5B9 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8492595E2AD8FDCB0081F5B9 /* InfoPlist.strings */; }; 849259622AD8FDD10081F5B9 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 849259612AD8FDD10081F5B9 /* main.m */; }; - 849259642AD8FDD90081F5B9 /* minecraftpe-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 849259632AD8FDD90081F5B9 /* minecraftpe-Info.plist */; }; - 8494882A2C92844C006DB706 /* foliagecolor.png in Resources */ = {isa = PBXBuildFile; fileRef = 849488252C92844C006DB706 /* foliagecolor.png */; }; - 8494882B2C92844C006DB706 /* grasscolor.png in Resources */ = {isa = PBXBuildFile; fileRef = 849488262C92844C006DB706 /* grasscolor.png */; }; - 8494882C2C92844C006DB706 /* pumpkinblur.png in Resources */ = {isa = PBXBuildFile; fileRef = 849488272C92844C006DB706 /* pumpkinblur.png */; }; - 8494882D2C92844C006DB706 /* shadow.png in Resources */ = {isa = PBXBuildFile; fileRef = 849488282C92844C006DB706 /* shadow.png */; }; - 8494882E2C92844C006DB706 /* vignette.png in Resources */ = {isa = PBXBuildFile; fileRef = 849488292C92844C006DB706 /* vignette.png */; }; - 849488322C928459006DB706 /* moon.png in Resources */ = {isa = PBXBuildFile; fileRef = 849488302C928459006DB706 /* moon.png */; }; - 849488332C928459006DB706 /* sun.png in Resources */ = {isa = PBXBuildFile; fileRef = 849488312C928459006DB706 /* sun.png */; }; + 849371312EE51DCD00081C5A /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 84E001BA2AF3AF9B009B9555 /* MainWindow.xib */; }; + 849371322EE51DE000081C5A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8492595E2AD8FDCB0081F5B9 /* InfoPlist.strings */; }; + 849371332EE51DE800081C5A /* minecraftpeViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 849259482AD8FD4F0081F5B9 /* minecraftpeViewController.xib */; }; + 849371392EE51EAB00081C5A /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 849371352EE51E6700081C5A /* Default-568h@2x.png */; }; + 8493713A2EE51EAB00081C5A /* Default-Landscape~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 849371362EE51E6700081C5A /* Default-Landscape~ipad.png */; }; + 8493713B2EE51EAB00081C5A /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 849371372EE51E6700081C5A /* Default.png */; }; + 8493713C2EE51EAB00081C5A /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 849371382EE51E6700081C5A /* Default@2x.png */; }; + 8493713E2EE51F4000081C5A /* icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 8493713D2EE51F2A00081C5A /* icon.png */; }; 849488362C9284DA006DB706 /* Lighting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 849488342C9284DA006DB706 /* Lighting.cpp */; }; 849488372C9284DA006DB706 /* Lighting.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 849488352C9284DA006DB706 /* Lighting.hpp */; }; 8495E4892AF0905B00A06901 /* AppPlatform_iOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8495E4882AF0905B00A06901 /* AppPlatform_iOS.mm */; }; - 849FF0B72AF465340013BAE3 /* default8.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E001672AF3A28B009B9555 /* default8.png */; }; - 849FF0B82AF465340013BAE3 /* panorama_0.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E0016A2AF3A28B009B9555 /* panorama_0.png */; }; - 849FF0B92AF465340013BAE3 /* panorama_1.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E0016B2AF3A28B009B9555 /* panorama_1.png */; }; - 849FF0BA2AF465340013BAE3 /* panorama_2.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E0016C2AF3A28B009B9555 /* panorama_2.png */; }; - 849FF0BB2AF465340013BAE3 /* panorama_3.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E0016D2AF3A28B009B9555 /* panorama_3.png */; }; - 849FF0BC2AF465340013BAE3 /* panorama_4.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E0016E2AF3A28B009B9555 /* panorama_4.png */; }; - 849FF0BD2AF465340013BAE3 /* panorama_5.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E0016F2AF3A28B009B9555 /* panorama_5.png */; }; - 849FF0BE2AF465340013BAE3 /* background.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E001702AF3A28B009B9555 /* background.png */; }; - 849FF0C32AF465340013BAE3 /* default_world.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E001762AF3A28B009B9555 /* default_world.png */; }; - 849FF0C52AF465340013BAE3 /* feedback_fill.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E001782AF3A28B009B9555 /* feedback_fill.png */; }; - 849FF0C62AF465340013BAE3 /* feedback_outer.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E001792AF3A28B009B9555 /* feedback_outer.png */; }; - 849FF0C72AF465340013BAE3 /* gui.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E0017A2AF3A28B009B9555 /* gui.png */; }; - 849FF0C82AF465340013BAE3 /* gui_blocks.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E0017B2AF3A28B009B9555 /* gui_blocks.png */; }; - 849FF0C92AF465340013BAE3 /* icons.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E0017C2AF3A28B009B9555 /* icons.png */; }; - 849FF0CB2AF465340013BAE3 /* items.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E0017E2AF3A28B009B9555 /* items.png */; }; - 849FF0D32AF465340013BAE3 /* title.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E001882AF3A28B009B9555 /* title.png */; }; - 849FF0D52AF465340013BAE3 /* icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E0018A2AF3A28B009B9555 /* icon.png */; }; - 849FF0DB2AF465340013BAE3 /* camera.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E0018C2AF3A28B009B9555 /* camera.png */; }; - 849FF0DC2AF465340013BAE3 /* char.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E0018E2AF3A28B009B9555 /* char.png */; }; - 849FF0DD2AF465340013BAE3 /* particles.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E0018F2AF3A28B009B9555 /* particles.png */; }; - 849FF0DE2AF465340013BAE3 /* terrain.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E001912AF3A28B009B9555 /* terrain.png */; }; 84A2FF162DB5B7B70090CE3E /* AssetFile.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84A2FF152DB5B7B70090CE3E /* AssetFile.hpp */; }; 84A2FF182DB61D440090CE3E /* SoundPathRepository.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84A2FF172DB61D3A0090CE3E /* SoundPathRepository.hpp */; }; 84A2FF1A2DB61D720090CE3E /* SoundPathRepository.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84A2FF192DB61D6D0090CE3E /* SoundPathRepository.cpp */; }; @@ -504,34 +407,7 @@ 84AA8C392B32F3F3003F5B82 /* VertexPT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84AA8BE82B32F3F3003F5B82 /* VertexPT.hpp */; }; 84AA8C3A2B32F3F3003F5B82 /* WaterSideTexture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8BE92B32F3F3003F5B82 /* WaterSideTexture.cpp */; }; 84AA8C3B2B32F3F3003F5B82 /* WaterTexture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8BEA2B32F3F3003F5B82 /* WaterTexture.cpp */; }; - 84AA8C5A2B32F535003F5B82 /* ChickenModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8C3C2B32F535003F5B82 /* ChickenModel.cpp */; }; - 84AA8C5B2B32F535003F5B82 /* ChickenModel.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84AA8C3D2B32F535003F5B82 /* ChickenModel.hpp */; }; - 84AA8C5C2B32F535003F5B82 /* CowModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8C3E2B32F535003F5B82 /* CowModel.cpp */; }; - 84AA8C5D2B32F535003F5B82 /* CowModel.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84AA8C3F2B32F535003F5B82 /* CowModel.hpp */; }; - 84AA8C5E2B32F535003F5B82 /* CreeperModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8C402B32F535003F5B82 /* CreeperModel.cpp */; }; - 84AA8C5F2B32F535003F5B82 /* CreeperModel.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84AA8C412B32F535003F5B82 /* CreeperModel.hpp */; }; - 84AA8C662B32F535003F5B82 /* ModelPart.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8C482B32F535003F5B82 /* ModelPart.cpp */; }; - 84AA8C672B32F535003F5B82 /* ModelPart.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84AA8C492B32F535003F5B82 /* ModelPart.hpp */; }; - 84AA8C682B32F535003F5B82 /* PigModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8C4A2B32F535003F5B82 /* PigModel.cpp */; }; - 84AA8C692B32F535003F5B82 /* PigModel.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84AA8C4B2B32F535003F5B82 /* PigModel.hpp */; }; - 84AA8C6C2B32F535003F5B82 /* QuadrupedModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8C4E2B32F535003F5B82 /* QuadrupedModel.cpp */; }; - 84AA8C6D2B32F535003F5B82 /* QuadrupedModel.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84AA8C4F2B32F535003F5B82 /* QuadrupedModel.hpp */; }; - 84AA8C6E2B32F535003F5B82 /* SheepFurModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8C502B32F535003F5B82 /* SheepFurModel.cpp */; }; - 84AA8C6F2B32F535003F5B82 /* SheepFurModel.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84AA8C512B32F535003F5B82 /* SheepFurModel.hpp */; }; - 84AA8C702B32F535003F5B82 /* SheepModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8C522B32F535003F5B82 /* SheepModel.cpp */; }; - 84AA8C712B32F535003F5B82 /* SheepModel.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84AA8C532B32F535003F5B82 /* SheepModel.hpp */; }; - 84AA8C722B32F535003F5B82 /* SkeletonModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8C542B32F535003F5B82 /* SkeletonModel.cpp */; }; - 84AA8C732B32F535003F5B82 /* SkeletonModel.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84AA8C552B32F535003F5B82 /* SkeletonModel.hpp */; }; - 84AA8C742B32F535003F5B82 /* SpiderModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8C562B32F535003F5B82 /* SpiderModel.cpp */; }; - 84AA8C752B32F536003F5B82 /* SpiderModel.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84AA8C572B32F535003F5B82 /* SpiderModel.hpp */; }; - 84AA8C762B32F536003F5B82 /* ZombieModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8C582B32F535003F5B82 /* ZombieModel.cpp */; }; - 84AA8C772B32F536003F5B82 /* ZombieModel.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84AA8C592B32F535003F5B82 /* ZombieModel.hpp */; }; - 84AA8C792B32F578003F5B82 /* gui_custom.png in Resources */ = {isa = PBXBuildFile; fileRef = 84AA8C782B32F578003F5B82 /* gui_custom.png */; }; 84AA8E802B32FB33003F5B82 /* stb_image_impl.c in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8E462B32FB33003F5B82 /* stb_image_impl.c */; }; - 84AAF6432AF18BD000BD67F4 /* GLExt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD7332AC810620006A435 /* GLExt.cpp */; }; - 84AAF6442AF18BE700BD67F4 /* GL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD7322AC810620006A435 /* GL.hpp */; }; - 84AAF6452AF18BE700BD67F4 /* glext.h in Headers */ = {isa = PBXBuildFile; fileRef = 840DD7342AC810620006A435 /* glext.h */; }; - 84AAF6482AF18C0C00BD67F4 /* libOpenGL.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84AAF6422AF18B9500BD67F4 /* libOpenGL.a */; }; 84B1E02F2E04FD4500ED000A /* ArrowRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84B1E02D2E04FD4500ED000A /* ArrowRenderer.cpp */; }; 84B1E0302E04FD4500ED000A /* ArrowRenderer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84B1E02E2E04FD4500ED000A /* ArrowRenderer.hpp */; }; 84B1E0392E04FD7900ED000A /* Arrow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84B1E0312E04FD7900ED000A /* Arrow.cpp */; }; @@ -542,336 +418,7 @@ 84B1E03E2E04FD7900ED000A /* Spider.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84B1E0362E04FD7900ED000A /* Spider.hpp */; }; 84B1E03F2E04FD7900ED000A /* Zombie.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84B1E0372E04FD7900ED000A /* Zombie.cpp */; }; 84B1E0402E04FD7900ED000A /* Zombie.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84B1E0382E04FD7900ED000A /* Zombie.hpp */; }; - 84B1E0552E050D2500ED000A /* ghast_fire.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0442E050D2500ED000A /* ghast_fire.png */; }; - 84B1E0562E050D2500ED000A /* ghast.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0452E050D2500ED000A /* ghast.png */; }; - 84B1E0582E050D2500ED000A /* pigman.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0472E050D2500ED000A /* pigman.png */; }; - 84B1E0592E050D2500ED000A /* pigzombie.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0482E050D2500ED000A /* pigzombie.png */; }; - 84B1E05A2E050D2500ED000A /* saddle.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0492E050D2500ED000A /* saddle.png */; }; - 84B1E05E2E050D2500ED000A /* slime.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E04D2E050D2500ED000A /* slime.png */; }; - 84B1E0612E050D2500ED000A /* squid.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0502E050D2500ED000A /* squid.png */; }; 84B1E0632E05194A00ED000A /* stb_vorbis.c in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8CD02B32FB32003F5B82 /* stb_vorbis.c */; }; - 84B1E0642E051B6400ED000A /* chicken.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0412E050D2500ED000A /* chicken.png */; }; - 84B1E0652E051B6400ED000A /* cow.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0422E050D2500ED000A /* cow.png */; }; - 84B1E0662E051B6400ED000A /* creeper.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0432E050D2500ED000A /* creeper.png */; }; - 84B1E0672E051B6400ED000A /* pig.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0462E050D2500ED000A /* pig.png */; }; - 84B1E0682E051B6400ED000A /* sheep.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E04B2E050D2500ED000A /* sheep.png */; }; - 84B1E0692E051B6400ED000A /* sheep_fur.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E04A2E050D2500ED000A /* sheep_fur.png */; }; - 84B1E06A2E051B6400ED000A /* skeleton.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E04C2E050D2500ED000A /* skeleton.png */; }; - 84B1E06B2E051B6400ED000A /* spider.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E04F2E050D2500ED000A /* spider.png */; }; - 84B1E06C2E051B6400ED000A /* spider_eyes.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E04E2E050D2500ED000A /* spider_eyes.png */; }; - 84B1E06D2E051B6400ED000A /* zombie.png in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0512E050D2500ED000A /* zombie.png */; }; - 84B1E1C22E051B7D00ED000A /* calm1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E06F2E051B7C00ED000A /* calm1.ogg */; }; - 84B1E1C32E051B7D00ED000A /* calm2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0702E051B7C00ED000A /* calm2.ogg */; }; - 84B1E1C42E051B7D00ED000A /* calm3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0712E051B7C00ED000A /* calm3.ogg */; }; - 84B1E1C52E051B7D00ED000A /* hal1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0732E051B7C00ED000A /* hal1.ogg */; }; - 84B1E1C62E051B7D00ED000A /* hal2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0742E051B7C00ED000A /* hal2.ogg */; }; - 84B1E1C72E051B7D00ED000A /* hal3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0752E051B7C00ED000A /* hal3.ogg */; }; - 84B1E1C82E051B7D00ED000A /* hal4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0762E051B7C00ED000A /* hal4.ogg */; }; - 84B1E1C92E051B7D00ED000A /* nuance1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0772E051B7C00ED000A /* nuance1.ogg */; }; - 84B1E1CA2E051B7D00ED000A /* nuance2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0782E051B7C00ED000A /* nuance2.ogg */; }; - 84B1E1CB2E051B7D00ED000A /* piano1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0792E051B7C00ED000A /* piano1.ogg */; }; - 84B1E1CC2E051B7D00ED000A /* piano2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E07A2E051B7C00ED000A /* piano2.ogg */; }; - 84B1E1CD2E051B7D00ED000A /* piano3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E07B2E051B7C00ED000A /* piano3.ogg */; }; - 84B1E1CE2E051B7D00ED000A /* cave1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E07F2E051B7C00ED000A /* cave1.ogg */; }; - 84B1E1CF2E051B7D00ED000A /* cave10.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0802E051B7C00ED000A /* cave10.ogg */; }; - 84B1E1D02E051B7D00ED000A /* cave11.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0812E051B7C00ED000A /* cave11.ogg */; }; - 84B1E1D12E051B7D00ED000A /* cave12.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0822E051B7C00ED000A /* cave12.ogg */; }; - 84B1E1D22E051B7D00ED000A /* cave13.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0832E051B7C00ED000A /* cave13.ogg */; }; - 84B1E1D32E051B7D00ED000A /* cave2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0842E051B7C00ED000A /* cave2.ogg */; }; - 84B1E1D42E051B7D00ED000A /* cave3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0852E051B7C00ED000A /* cave3.ogg */; }; - 84B1E1D52E051B7D00ED000A /* cave4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0862E051B7C00ED000A /* cave4.ogg */; }; - 84B1E1D62E051B7D00ED000A /* cave5.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0872E051B7C00ED000A /* cave5.ogg */; }; - 84B1E1D72E051B7D00ED000A /* cave6.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0882E051B7C00ED000A /* cave6.ogg */; }; - 84B1E1D82E051B7D00ED000A /* cave7.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0892E051B7C00ED000A /* cave7.ogg */; }; - 84B1E1D92E051B7D00ED000A /* cave8.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E08A2E051B7C00ED000A /* cave8.ogg */; }; - 84B1E1DA2E051B7D00ED000A /* cave9.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E08B2E051B7C00ED000A /* cave9.ogg */; }; - 84B1E1DB2E051B7D00ED000A /* rain1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E08D2E051B7C00ED000A /* rain1.ogg */; }; - 84B1E1DC2E051B7D00ED000A /* rain2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E08E2E051B7C00ED000A /* rain2.ogg */; }; - 84B1E1DD2E051B7D00ED000A /* rain3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E08F2E051B7C00ED000A /* rain3.ogg */; }; - 84B1E1DE2E051B7D00ED000A /* rain4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0902E051B7C00ED000A /* rain4.ogg */; }; - 84B1E1DF2E051B7D00ED000A /* thunder1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0912E051B7C00ED000A /* thunder1.ogg */; }; - 84B1E1E02E051B7D00ED000A /* thunder2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0922E051B7C00ED000A /* thunder2.ogg */; }; - 84B1E1E12E051B7D00ED000A /* thunder3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0932E051B7C00ED000A /* thunder3.ogg */; }; - 84B1E1E22E051B7D00ED000A /* fallbig1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0952E051B7C00ED000A /* fallbig1.ogg */; }; - 84B1E1E32E051B7D00ED000A /* fallbig2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0962E051B7C00ED000A /* fallbig2.ogg */; }; - 84B1E1E42E051B7D00ED000A /* fallsmall.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0972E051B7C00ED000A /* fallsmall.ogg */; }; - 84B1E1E52E051B7D00ED000A /* hurtflesh1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0982E051B7C00ED000A /* hurtflesh1.ogg */; }; - 84B1E1E62E051B7D00ED000A /* hurtflesh2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0992E051B7C00ED000A /* hurtflesh2.ogg */; }; - 84B1E1E72E051B7D00ED000A /* hurtflesh3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E09A2E051B7C00ED000A /* hurtflesh3.ogg */; }; - 84B1E1E82E051B7D00ED000A /* fire.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E09C2E051B7C00ED000A /* fire.ogg */; }; - 84B1E1E92E051B7D00ED000A /* ignite.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E09D2E051B7C00ED000A /* ignite.ogg */; }; - 84B1E1EA2E051B7D00ED000A /* lava.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E09F2E051B7C00ED000A /* lava.ogg */; }; - 84B1E1EB2E051B7D00ED000A /* lavapop.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0A02E051B7C00ED000A /* lavapop.ogg */; }; - 84B1E1EC2E051B7D00ED000A /* splash.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0A12E051B7C00ED000A /* splash.ogg */; }; - 84B1E1ED2E051B7D00ED000A /* water.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0A22E051B7C00ED000A /* water.ogg */; }; - 84B1E1EE2E051B7D00ED000A /* breathe1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0A52E051B7C00ED000A /* breathe1.ogg */; }; - 84B1E1EF2E051B7D00ED000A /* breathe2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0A62E051B7C00ED000A /* breathe2.ogg */; }; - 84B1E1F02E051B7D00ED000A /* breathe3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0A72E051B7C00ED000A /* breathe3.ogg */; }; - 84B1E1F12E051B7D00ED000A /* breathe4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0A82E051B7C00ED000A /* breathe4.ogg */; }; - 84B1E1F22E051B7D00ED000A /* death.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0A92E051B7C00ED000A /* death.ogg */; }; - 84B1E1F32E051B7D00ED000A /* hit1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0AA2E051B7C00ED000A /* hit1.ogg */; }; - 84B1E1F42E051B7D00ED000A /* hit2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0AB2E051B7C00ED000A /* hit2.ogg */; }; - 84B1E1F52E051B7D00ED000A /* hit3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0AC2E051B7C00ED000A /* hit3.ogg */; }; - 84B1E1F62E051B7D00ED000A /* hit4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0AD2E051B7C00ED000A /* hit4.ogg */; }; - 84B1E1F72E051B7D00ED000A /* hiss1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0AF2E051B7C00ED000A /* hiss1.ogg */; }; - 84B1E1F82E051B7D00ED000A /* hiss2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0B02E051B7C00ED000A /* hiss2.ogg */; }; - 84B1E1F92E051B7D00ED000A /* hiss3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0B12E051B7C00ED000A /* hiss3.ogg */; }; - 84B1E1FA2E051B7D00ED000A /* hitt1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0B22E051B7C00ED000A /* hitt1.ogg */; }; - 84B1E1FB2E051B7D00ED000A /* hitt2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0B32E051B7C00ED000A /* hitt2.ogg */; }; - 84B1E1FC2E051B7D00ED000A /* hitt3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0B42E051B7C00ED000A /* hitt3.ogg */; }; - 84B1E1FD2E051B7D00ED000A /* meow1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0B52E051B7C00ED000A /* meow1.ogg */; }; - 84B1E1FE2E051B7D00ED000A /* meow2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0B62E051B7C00ED000A /* meow2.ogg */; }; - 84B1E1FF2E051B7D00ED000A /* meow3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0B72E051B7C00ED000A /* meow3.ogg */; }; - 84B1E2002E051B7D00ED000A /* meow4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0B82E051B7C00ED000A /* meow4.ogg */; }; - 84B1E2012E051B7D00ED000A /* purr1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0B92E051B7C00ED000A /* purr1.ogg */; }; - 84B1E2022E051B7D00ED000A /* purr2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0BA2E051B7C00ED000A /* purr2.ogg */; }; - 84B1E2032E051B7D00ED000A /* purr3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0BB2E051B7C00ED000A /* purr3.ogg */; }; - 84B1E2042E051B7D00ED000A /* purreow1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0BC2E051B7C00ED000A /* purreow1.ogg */; }; - 84B1E2052E051B7D00ED000A /* purreow2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0BD2E051B7C00ED000A /* purreow2.ogg */; }; - 84B1E2062E051B7D00ED000A /* chicken1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0BE2E051B7C00ED000A /* chicken1.ogg */; }; - 84B1E2072E051B7D00ED000A /* chicken2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0BF2E051B7C00ED000A /* chicken2.ogg */; }; - 84B1E2082E051B7D00ED000A /* chicken3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0C02E051B7C00ED000A /* chicken3.ogg */; }; - 84B1E2092E051B7D00ED000A /* chickenhurt1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0C12E051B7C00ED000A /* chickenhurt1.ogg */; }; - 84B1E20A2E051B7D00ED000A /* chickenhurt2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0C22E051B7C00ED000A /* chickenhurt2.ogg */; }; - 84B1E20B2E051B7D00ED000A /* chickenplop.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0C32E051B7C00ED000A /* chickenplop.ogg */; }; - 84B1E20C2E051B7D00ED000A /* cow1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0C42E051B7C00ED000A /* cow1.ogg */; }; - 84B1E20D2E051B7D00ED000A /* cow2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0C52E051B7C00ED000A /* cow2.ogg */; }; - 84B1E20E2E051B7D00ED000A /* cow3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0C62E051B7C00ED000A /* cow3.ogg */; }; - 84B1E20F2E051B7D00ED000A /* cow4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0C72E051B7C00ED000A /* cow4.ogg */; }; - 84B1E2102E051B7D00ED000A /* cowhurt1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0C82E051B7C00ED000A /* cowhurt1.ogg */; }; - 84B1E2112E051B7D00ED000A /* cowhurt2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0C92E051B7C00ED000A /* cowhurt2.ogg */; }; - 84B1E2122E051B7D00ED000A /* cowhurt3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0CA2E051B7C00ED000A /* cowhurt3.ogg */; }; - 84B1E2132E051B7D00ED000A /* creeper1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0CB2E051B7C00ED000A /* creeper1.ogg */; }; - 84B1E2142E051B7D00ED000A /* creeper2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0CC2E051B7C00ED000A /* creeper2.ogg */; }; - 84B1E2152E051B7D00ED000A /* creeper3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0CD2E051B7C00ED000A /* creeper3.ogg */; }; - 84B1E2162E051B7D00ED000A /* creeper4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0CE2E051B7C00ED000A /* creeper4.ogg */; }; - 84B1E2172E051B7D00ED000A /* creeperdeath.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0CF2E051B7C00ED000A /* creeperdeath.ogg */; }; - 84B1E2182E051B7D00ED000A /* death.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0D12E051B7C00ED000A /* death.ogg */; }; - 84B1E2192E051B7D00ED000A /* hit1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0D22E051B7C00ED000A /* hit1.ogg */; }; - 84B1E21A2E051B7D00ED000A /* hit2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0D32E051B7C00ED000A /* hit2.ogg */; }; - 84B1E21B2E051B7D00ED000A /* hit3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0D42E051B7C00ED000A /* hit3.ogg */; }; - 84B1E21C2E051B7D00ED000A /* hit4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0D52E051B7C00ED000A /* hit4.ogg */; }; - 84B1E21D2E051B7D00ED000A /* idle1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0D62E051B7C00ED000A /* idle1.ogg */; }; - 84B1E21E2E051B7D00ED000A /* idle2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0D72E051B7C00ED000A /* idle2.ogg */; }; - 84B1E21F2E051B7D00ED000A /* idle3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0D82E051B7C00ED000A /* idle3.ogg */; }; - 84B1E2202E051B7D00ED000A /* idle4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0D92E051B7C00ED000A /* idle4.ogg */; }; - 84B1E2212E051B7D00ED000A /* idle5.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0DA2E051B7C00ED000A /* idle5.ogg */; }; - 84B1E2222E051B7D00ED000A /* portal.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0DB2E051B7C00ED000A /* portal.ogg */; }; - 84B1E2232E051B7D00ED000A /* portal2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0DC2E051B7C00ED000A /* portal2.ogg */; }; - 84B1E2242E051B7D00ED000A /* scream1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0DD2E051B7C00ED000A /* scream1.ogg */; }; - 84B1E2252E051B7D00ED000A /* scream2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0DE2E051B7C00ED000A /* scream2.ogg */; }; - 84B1E2262E051B7D00ED000A /* scream3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0DF2E051B7C00ED000A /* scream3.ogg */; }; - 84B1E2272E051B7D00ED000A /* scream4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0E02E051B7C00ED000A /* scream4.ogg */; }; - 84B1E2282E051B7D00ED000A /* stare.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0E12E051B7C00ED000A /* stare.ogg */; }; - 84B1E2292E051B7D00ED000A /* affectionate scream.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0E32E051B7C00ED000A /* affectionate scream.ogg */; }; - 84B1E22A2E051B7D00ED000A /* charge.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0E42E051B7C00ED000A /* charge.ogg */; }; - 84B1E22B2E051B7D00ED000A /* death.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0E52E051B7C00ED000A /* death.ogg */; }; - 84B1E22C2E051B7D00ED000A /* fireball4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0E62E051B7C00ED000A /* fireball4.ogg */; }; - 84B1E22D2E051B7D00ED000A /* moan1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0E72E051B7C00ED000A /* moan1.ogg */; }; - 84B1E22E2E051B7D00ED000A /* moan2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0E82E051B7C00ED000A /* moan2.ogg */; }; - 84B1E22F2E051B7D00ED000A /* moan3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0E92E051B7C00ED000A /* moan3.ogg */; }; - 84B1E2302E051B7D00ED000A /* moan4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0EA2E051B7C00ED000A /* moan4.ogg */; }; - 84B1E2312E051B7D00ED000A /* moan5.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0EB2E051B7C00ED000A /* moan5.ogg */; }; - 84B1E2322E051B7D00ED000A /* moan6.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0EC2E051B7C00ED000A /* moan6.ogg */; }; - 84B1E2332E051B7D00ED000A /* moan7.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0ED2E051B7C00ED000A /* moan7.ogg */; }; - 84B1E2342E051B7D00ED000A /* scream1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0EE2E051B7C00ED000A /* scream1.ogg */; }; - 84B1E2352E051B7D00ED000A /* scream2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0EF2E051B7C00ED000A /* scream2.ogg */; }; - 84B1E2362E051B7D00ED000A /* scream3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0F02E051B7C00ED000A /* scream3.ogg */; }; - 84B1E2372E051B7D00ED000A /* scream4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0F12E051B7C00ED000A /* scream4.ogg */; }; - 84B1E2382E051B7D00ED000A /* scream5.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0F22E051B7C00ED000A /* scream5.ogg */; }; - 84B1E2392E051B7D00ED000A /* death.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0F42E051B7C00ED000A /* death.ogg */; }; - 84B1E23A2E051B7D00ED000A /* hit1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0F52E051B7C00ED000A /* hit1.ogg */; }; - 84B1E23B2E051B7D00ED000A /* hit2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0F62E051B7C00ED000A /* hit2.ogg */; }; - 84B1E23C2E051B7D00ED000A /* hit3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0F72E051B7C00ED000A /* hit3.ogg */; }; - 84B1E23D2E051B7D00ED000A /* hit4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0F82E051B7C00ED000A /* hit4.ogg */; }; - 84B1E23E2E051B7D00ED000A /* throw.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0F92E051B7C00ED000A /* throw.ogg */; }; - 84B1E23F2E051B7D00ED000A /* walk1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0FA2E051B7C00ED000A /* walk1.ogg */; }; - 84B1E2402E051B7D00ED000A /* walk2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0FB2E051B7C00ED000A /* walk2.ogg */; }; - 84B1E2412E051B7D00ED000A /* walk3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0FC2E051B7C00ED000A /* walk3.ogg */; }; - 84B1E2422E051B7D00ED000A /* walk4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0FD2E051B7C00ED000A /* walk4.ogg */; }; - 84B1E2432E051B7D00ED000A /* big1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E0FF2E051B7C00ED000A /* big1.ogg */; }; - 84B1E2442E051B7D00ED000A /* big2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1002E051B7C00ED000A /* big2.ogg */; }; - 84B1E2452E051B7D00ED000A /* big3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1012E051B7C00ED000A /* big3.ogg */; }; - 84B1E2462E051B7D00ED000A /* big4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1022E051B7C00ED000A /* big4.ogg */; }; - 84B1E2472E051B7D00ED000A /* jump1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1032E051B7C00ED000A /* jump1.ogg */; }; - 84B1E2482E051B7D00ED000A /* jump2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1042E051B7C00ED000A /* jump2.ogg */; }; - 84B1E2492E051B7D00ED000A /* jump3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1052E051B7C00ED000A /* jump3.ogg */; }; - 84B1E24A2E051B7D00ED000A /* jump4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1062E051B7C00ED000A /* jump4.ogg */; }; - 84B1E24B2E051B7D00ED000A /* small1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1072E051B7C00ED000A /* small1.ogg */; }; - 84B1E24C2E051B7D00ED000A /* small2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1082E051B7C00ED000A /* small2.ogg */; }; - 84B1E24D2E051B7D00ED000A /* small3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1092E051B7C00ED000A /* small3.ogg */; }; - 84B1E24E2E051B7D00ED000A /* small4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E10A2E051B7C00ED000A /* small4.ogg */; }; - 84B1E24F2E051B7D00ED000A /* small5.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E10B2E051B7C00ED000A /* small5.ogg */; }; - 84B1E2502E051B7D00ED000A /* pig1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E10C2E051B7C00ED000A /* pig1.ogg */; }; - 84B1E2512E051B7D00ED000A /* pig2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E10D2E051B7C00ED000A /* pig2.ogg */; }; - 84B1E2522E051B7D00ED000A /* pig3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E10E2E051B7C00ED000A /* pig3.ogg */; }; - 84B1E2532E051B7D00ED000A /* pigdeath.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E10F2E051B7C00ED000A /* pigdeath.ogg */; }; - 84B1E2542E051B7D00ED000A /* sheep1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1102E051B7C00ED000A /* sheep1.ogg */; }; - 84B1E2552E051B7D00ED000A /* sheep2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1112E051B7C00ED000A /* sheep2.ogg */; }; - 84B1E2562E051B7D00ED000A /* sheep3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1122E051B7C00ED000A /* sheep3.ogg */; }; - 84B1E2572E051B7D00ED000A /* hit1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1142E051B7C00ED000A /* hit1.ogg */; }; - 84B1E2582E051B7D00ED000A /* hit2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1152E051B7C00ED000A /* hit2.ogg */; }; - 84B1E2592E051B7D00ED000A /* hit3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1162E051B7C00ED000A /* hit3.ogg */; }; - 84B1E25A2E051B7D00ED000A /* kill.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1172E051B7C00ED000A /* kill.ogg */; }; - 84B1E25B2E051B7D00ED000A /* say1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1182E051B7C00ED000A /* say1.ogg */; }; - 84B1E25C2E051B7D00ED000A /* say2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1192E051B7C00ED000A /* say2.ogg */; }; - 84B1E25D2E051B7D00ED000A /* say3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E11A2E051B7C00ED000A /* say3.ogg */; }; - 84B1E25E2E051B7D00ED000A /* say4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E11B2E051B7C00ED000A /* say4.ogg */; }; - 84B1E25F2E051B7D00ED000A /* step1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E11C2E051B7C00ED000A /* step1.ogg */; }; - 84B1E2602E051B7D00ED000A /* step2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E11D2E051B7C00ED000A /* step2.ogg */; }; - 84B1E2612E051B7D00ED000A /* step3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E11E2E051B7C00ED000A /* step3.ogg */; }; - 84B1E2622E051B7D00ED000A /* step4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E11F2E051B7C00ED000A /* step4.ogg */; }; - 84B1E2632E051B7D00ED000A /* skeleton1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1202E051B7C00ED000A /* skeleton1.ogg */; }; - 84B1E2642E051B7D00ED000A /* skeleton2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1212E051B7C00ED000A /* skeleton2.ogg */; }; - 84B1E2652E051B7D00ED000A /* skeleton3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1222E051B7C00ED000A /* skeleton3.ogg */; }; - 84B1E2662E051B7D00ED000A /* skeletondeath.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1232E051B7D00ED000A /* skeletondeath.ogg */; }; - 84B1E2672E051B7D00ED000A /* skeletonhurt1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1242E051B7D00ED000A /* skeletonhurt1.ogg */; }; - 84B1E2682E051B7D00ED000A /* skeletonhurt2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1252E051B7D00ED000A /* skeletonhurt2.ogg */; }; - 84B1E2692E051B7D00ED000A /* skeletonhurt3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1262E051B7D00ED000A /* skeletonhurt3.ogg */; }; - 84B1E26A2E051B7D00ED000A /* skeletonhurt4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1272E051B7D00ED000A /* skeletonhurt4.ogg */; }; - 84B1E26B2E051B7D00ED000A /* slime1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1282E051B7D00ED000A /* slime1.ogg */; }; - 84B1E26C2E051B7D00ED000A /* slime2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1292E051B7D00ED000A /* slime2.ogg */; }; - 84B1E26D2E051B7D00ED000A /* slime3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E12A2E051B7D00ED000A /* slime3.ogg */; }; - 84B1E26E2E051B7D00ED000A /* slime4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E12B2E051B7D00ED000A /* slime4.ogg */; }; - 84B1E26F2E051B7D00ED000A /* slime5.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E12C2E051B7D00ED000A /* slime5.ogg */; }; - 84B1E2702E051B7D00ED000A /* slimeattack1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E12D2E051B7D00ED000A /* slimeattack1.ogg */; }; - 84B1E2712E051B7D00ED000A /* slimeattack2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E12E2E051B7D00ED000A /* slimeattack2.ogg */; }; - 84B1E2722E051B7D00ED000A /* spider1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E12F2E051B7D00ED000A /* spider1.ogg */; }; - 84B1E2732E051B7D00ED000A /* spider2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1302E051B7D00ED000A /* spider2.ogg */; }; - 84B1E2742E051B7D00ED000A /* spider3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1312E051B7D00ED000A /* spider3.ogg */; }; - 84B1E2752E051B7D00ED000A /* spider4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1322E051B7D00ED000A /* spider4.ogg */; }; - 84B1E2762E051B7D00ED000A /* spiderdeath.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1332E051B7D00ED000A /* spiderdeath.ogg */; }; - 84B1E2772E051B7D00ED000A /* bark1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1352E051B7D00ED000A /* bark1.ogg */; }; - 84B1E2782E051B7D00ED000A /* bark2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1362E051B7D00ED000A /* bark2.ogg */; }; - 84B1E2792E051B7D00ED000A /* bark3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1372E051B7D00ED000A /* bark3.ogg */; }; - 84B1E27A2E051B7D00ED000A /* death.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1382E051B7D00ED000A /* death.ogg */; }; - 84B1E27B2E051B7D00ED000A /* growl1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1392E051B7D00ED000A /* growl1.ogg */; }; - 84B1E27C2E051B7D00ED000A /* growl2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E13A2E051B7D00ED000A /* growl2.ogg */; }; - 84B1E27D2E051B7D00ED000A /* growl3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E13B2E051B7D00ED000A /* growl3.ogg */; }; - 84B1E27E2E051B7D00ED000A /* howl1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E13C2E051B7D00ED000A /* howl1.ogg */; }; - 84B1E27F2E051B7D00ED000A /* howl2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E13D2E051B7D00ED000A /* howl2.ogg */; }; - 84B1E2802E051B7D00ED000A /* hurt1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E13E2E051B7D00ED000A /* hurt1.ogg */; }; - 84B1E2812E051B7D00ED000A /* hurt2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E13F2E051B7D00ED000A /* hurt2.ogg */; }; - 84B1E2822E051B7D00ED000A /* hurt3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1402E051B7D00ED000A /* hurt3.ogg */; }; - 84B1E2832E051B7D00ED000A /* panting.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1412E051B7D00ED000A /* panting.ogg */; }; - 84B1E2842E051B7D00ED000A /* shake.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1422E051B7D00ED000A /* shake.ogg */; }; - 84B1E2852E051B7D00ED000A /* whine.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1432E051B7D00ED000A /* whine.ogg */; }; - 84B1E2862E051B7D00ED000A /* metal1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1452E051B7D00ED000A /* metal1.ogg */; }; - 84B1E2872E051B7D00ED000A /* metal2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1462E051B7D00ED000A /* metal2.ogg */; }; - 84B1E2882E051B7D00ED000A /* metal3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1472E051B7D00ED000A /* metal3.ogg */; }; - 84B1E2892E051B7D00ED000A /* wood1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1482E051B7D00ED000A /* wood1.ogg */; }; - 84B1E28A2E051B7D00ED000A /* wood2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1492E051B7D00ED000A /* wood2.ogg */; }; - 84B1E28B2E051B7D00ED000A /* wood3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E14A2E051B7D00ED000A /* wood3.ogg */; }; - 84B1E28C2E051B7D00ED000A /* wood4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E14B2E051B7D00ED000A /* wood4.ogg */; }; - 84B1E28D2E051B7D00ED000A /* woodbreak.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E14C2E051B7D00ED000A /* woodbreak.ogg */; }; - 84B1E28E2E051B7D00ED000A /* zombie1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E14D2E051B7D00ED000A /* zombie1.ogg */; }; - 84B1E28F2E051B7D00ED000A /* zombie2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E14E2E051B7D00ED000A /* zombie2.ogg */; }; - 84B1E2902E051B7D00ED000A /* zombie3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E14F2E051B7D00ED000A /* zombie3.ogg */; }; - 84B1E2912E051B7D00ED000A /* zombiedeath.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1502E051B7D00ED000A /* zombiedeath.ogg */; }; - 84B1E2922E051B7D00ED000A /* zombiehurt1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1512E051B7D00ED000A /* zombiehurt1.ogg */; }; - 84B1E2932E051B7D00ED000A /* zombiehurt2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1522E051B7D00ED000A /* zombiehurt2.ogg */; }; - 84B1E2942E051B7D00ED000A /* zpig1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1542E051B7D00ED000A /* zpig1.ogg */; }; - 84B1E2952E051B7D00ED000A /* zpig2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1552E051B7D00ED000A /* zpig2.ogg */; }; - 84B1E2962E051B7D00ED000A /* zpig3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1562E051B7D00ED000A /* zpig3.ogg */; }; - 84B1E2972E051B7D00ED000A /* zpig4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1572E051B7D00ED000A /* zpig4.ogg */; }; - 84B1E2982E051B7D00ED000A /* zpigangry1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1582E051B7D00ED000A /* zpigangry1.ogg */; }; - 84B1E2992E051B7D00ED000A /* zpigangry2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1592E051B7D00ED000A /* zpigangry2.ogg */; }; - 84B1E29A2E051B7D00ED000A /* zpigangry3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E15A2E051B7D00ED000A /* zpigangry3.ogg */; }; - 84B1E29B2E051B7D00ED000A /* zpigangry4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E15B2E051B7D00ED000A /* zpigangry4.ogg */; }; - 84B1E29C2E051B7D00ED000A /* zpigdeath.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E15C2E051B7D00ED000A /* zpigdeath.ogg */; }; - 84B1E29D2E051B7D00ED000A /* zpighurt1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E15D2E051B7D00ED000A /* zpighurt1.ogg */; }; - 84B1E29E2E051B7D00ED000A /* zpighurt2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E15E2E051B7D00ED000A /* zpighurt2.ogg */; }; - 84B1E29F2E051B7D00ED000A /* bass.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1602E051B7D00ED000A /* bass.ogg */; }; - 84B1E2A02E051B7D00ED000A /* bassattack.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1612E051B7D00ED000A /* bassattack.ogg */; }; - 84B1E2A12E051B7D00ED000A /* bd.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1622E051B7D00ED000A /* bd.ogg */; }; - 84B1E2A22E051B7D00ED000A /* harp.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1632E051B7D00ED000A /* harp.ogg */; }; - 84B1E2A32E051B7D00ED000A /* hat.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1642E051B7D00ED000A /* hat.ogg */; }; - 84B1E2A42E051B7D00ED000A /* pling.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1652E051B7D00ED000A /* pling.ogg */; }; - 84B1E2A52E051B7D00ED000A /* snare.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1662E051B7D00ED000A /* snare.ogg */; }; - 84B1E2A62E051B7D00ED000A /* portal.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1682E051B7D00ED000A /* portal.ogg */; }; - 84B1E2A72E051B7D00ED000A /* travel.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1692E051B7D00ED000A /* travel.ogg */; }; - 84B1E2A82E051B7D00ED000A /* trigger.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E16A2E051B7D00ED000A /* trigger.ogg */; }; - 84B1E2A92E051B7D00ED000A /* bow.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E16C2E051B7D00ED000A /* bow.ogg */; }; - 84B1E2AA2E051B7D00ED000A /* bowhit1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E16D2E051B7D00ED000A /* bowhit1.ogg */; }; - 84B1E2AB2E051B7D00ED000A /* bowhit2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E16E2E051B7D00ED000A /* bowhit2.ogg */; }; - 84B1E2AC2E051B7D00ED000A /* bowhit3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E16F2E051B7D00ED000A /* bowhit3.ogg */; }; - 84B1E2AD2E051B7D00ED000A /* bowhit4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1702E051B7D00ED000A /* bowhit4.ogg */; }; - 84B1E2AE2E051B7D00ED000A /* break.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1712E051B7D00ED000A /* break.ogg */; }; - 84B1E2AF2E051B7D00ED000A /* breath.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1722E051B7D00ED000A /* breath.ogg */; }; - 84B1E2B02E051B7D00ED000A /* burp.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1732E051B7D00ED000A /* burp.ogg */; }; - 84B1E2B12E051B7D00ED000A /* chestclosed.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1742E051B7D00ED000A /* chestclosed.ogg */; }; - 84B1E2B22E051B7D00ED000A /* chestopen.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1752E051B7D00ED000A /* chestopen.ogg */; }; - 84B1E2B32E051B7D00ED000A /* click.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1762E051B7D00ED000A /* click.ogg */; }; - 84B1E2B42E051B7D00ED000A /* door_close.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1772E051B7D00ED000A /* door_close.ogg */; }; - 84B1E2B52E051B7D00ED000A /* door_open.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1782E051B7D00ED000A /* door_open.ogg */; }; - 84B1E2B62E051B7D00ED000A /* drink.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1792E051B7D00ED000A /* drink.ogg */; }; - 84B1E2B72E051B7D00ED000A /* drr.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E17A2E051B7D00ED000A /* drr.ogg */; }; - 84B1E2B82E051B7D00ED000A /* eat1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E17B2E051B7D00ED000A /* eat1.ogg */; }; - 84B1E2B92E051B7D00ED000A /* eat2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E17C2E051B7D00ED000A /* eat2.ogg */; }; - 84B1E2BA2E051B7D00ED000A /* eat3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E17D2E051B7D00ED000A /* eat3.ogg */; }; - 84B1E2BB2E051B7D00ED000A /* explode.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E17E2E051B7D00ED000A /* explode.ogg */; }; - 84B1E2BC2E051B7D00ED000A /* explode1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E17F2E051B7D00ED000A /* explode1.ogg */; }; - 84B1E2BD2E051B7D00ED000A /* explode2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1802E051B7D00ED000A /* explode2.ogg */; }; - 84B1E2BE2E051B7D00ED000A /* explode3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1812E051B7D00ED000A /* explode3.ogg */; }; - 84B1E2BF2E051B7D00ED000A /* explode4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1822E051B7D00ED000A /* explode4.ogg */; }; - 84B1E2C02E051B7D00ED000A /* fizz.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1832E051B7D00ED000A /* fizz.ogg */; }; - 84B1E2C12E051B7D00ED000A /* fuse.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1842E051B7D00ED000A /* fuse.ogg */; }; - 84B1E2C22E051B7D00ED000A /* glass1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1852E051B7D00ED000A /* glass1.ogg */; }; - 84B1E2C32E051B7D00ED000A /* glass2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1862E051B7D00ED000A /* glass2.ogg */; }; - 84B1E2C42E051B7D00ED000A /* glass3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1872E051B7D00ED000A /* glass3.ogg */; }; - 84B1E2C52E051B7D00ED000A /* hurt.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1882E051B7D00ED000A /* hurt.ogg */; }; - 84B1E2C62E051B7D00ED000A /* levelup.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1892E051B7D00ED000A /* levelup.ogg */; }; - 84B1E2C72E051B7D00ED000A /* old_explode.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E18A2E051B7D00ED000A /* old_explode.ogg */; }; - 84B1E2C82E051B7D00ED000A /* orb.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E18B2E051B7D00ED000A /* orb.ogg */; }; - 84B1E2C92E051B7D00ED000A /* pop.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E18C2E051B7D00ED000A /* pop.ogg */; }; - 84B1E2CA2E051B7D00ED000A /* splash.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E18D2E051B7D00ED000A /* splash.ogg */; }; - 84B1E2CB2E051B7D00ED000A /* wood click.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E18E2E051B7D00ED000A /* wood click.ogg */; }; - 84B1E2CC2E051B7D00ED000A /* cloth1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1902E051B7D00ED000A /* cloth1.ogg */; }; - 84B1E2CD2E051B7D00ED000A /* cloth2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1912E051B7D00ED000A /* cloth2.ogg */; }; - 84B1E2CE2E051B7D00ED000A /* cloth3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1922E051B7D00ED000A /* cloth3.ogg */; }; - 84B1E2CF2E051B7D00ED000A /* cloth4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1932E051B7D00ED000A /* cloth4.ogg */; }; - 84B1E2D02E051B7D00ED000A /* grass1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1942E051B7D00ED000A /* grass1.ogg */; }; - 84B1E2D12E051B7D00ED000A /* grass2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1952E051B7D00ED000A /* grass2.ogg */; }; - 84B1E2D22E051B7D00ED000A /* grass3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1962E051B7D00ED000A /* grass3.ogg */; }; - 84B1E2D32E051B7D00ED000A /* grass4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1972E051B7D00ED000A /* grass4.ogg */; }; - 84B1E2D42E051B7D00ED000A /* gravel1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1982E051B7D00ED000A /* gravel1.ogg */; }; - 84B1E2D52E051B7D00ED000A /* gravel2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1992E051B7D00ED000A /* gravel2.ogg */; }; - 84B1E2D62E051B7D00ED000A /* gravel3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E19A2E051B7D00ED000A /* gravel3.ogg */; }; - 84B1E2D72E051B7D00ED000A /* gravel4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E19B2E051B7D00ED000A /* gravel4.ogg */; }; - 84B1E2D82E051B7D00ED000A /* sand1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E19C2E051B7D00ED000A /* sand1.ogg */; }; - 84B1E2D92E051B7D00ED000A /* sand2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E19D2E051B7D00ED000A /* sand2.ogg */; }; - 84B1E2DA2E051B7D00ED000A /* sand3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E19E2E051B7D00ED000A /* sand3.ogg */; }; - 84B1E2DB2E051B7D00ED000A /* sand4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E19F2E051B7D00ED000A /* sand4.ogg */; }; - 84B1E2DC2E051B7D00ED000A /* snow1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1A02E051B7D00ED000A /* snow1.ogg */; }; - 84B1E2DD2E051B7D00ED000A /* snow2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1A12E051B7D00ED000A /* snow2.ogg */; }; - 84B1E2DE2E051B7D00ED000A /* snow3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1A22E051B7D00ED000A /* snow3.ogg */; }; - 84B1E2DF2E051B7D00ED000A /* snow4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1A32E051B7D00ED000A /* snow4.ogg */; }; - 84B1E2E02E051B7D00ED000A /* stone1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1A42E051B7D00ED000A /* stone1.ogg */; }; - 84B1E2E12E051B7D00ED000A /* stone2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1A52E051B7D00ED000A /* stone2.ogg */; }; - 84B1E2E22E051B7D00ED000A /* stone3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1A62E051B7D00ED000A /* stone3.ogg */; }; - 84B1E2E32E051B7D00ED000A /* stone4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1A72E051B7D00ED000A /* stone4.ogg */; }; - 84B1E2E42E051B7D00ED000A /* wood1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1A82E051B7D00ED000A /* wood1.ogg */; }; - 84B1E2E52E051B7D00ED000A /* wood2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1A92E051B7D00ED000A /* wood2.ogg */; }; - 84B1E2E62E051B7D00ED000A /* wood3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1AA2E051B7D00ED000A /* wood3.ogg */; }; - 84B1E2E72E051B7D00ED000A /* wood4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1AB2E051B7D00ED000A /* wood4.ogg */; }; - 84B1E2E82E051B7D00ED000A /* in.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1AE2E051B7D00ED000A /* in.ogg */; }; - 84B1E2E92E051B7D00ED000A /* out.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1AF2E051B7D00ED000A /* out.ogg */; }; - 84B1E2EA2E051B7D00ED000A /* grass1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1B22E051B7D00ED000A /* grass1.ogg */; }; - 84B1E2EB2E051B7D00ED000A /* grass2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1B32E051B7D00ED000A /* grass2.ogg */; }; - 84B1E2EC2E051B7D00ED000A /* grass3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1B42E051B7D00ED000A /* grass3.ogg */; }; - 84B1E2ED2E051B7D00ED000A /* grass4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1B52E051B7D00ED000A /* grass4.ogg */; }; - 84B1E2EE2E051B7D00ED000A /* gravel1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1B62E051B7D00ED000A /* gravel1.ogg */; }; - 84B1E2EF2E051B7D00ED000A /* gravel2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1B72E051B7D00ED000A /* gravel2.ogg */; }; - 84B1E2F02E051B7D00ED000A /* gravel3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1B82E051B7D00ED000A /* gravel3.ogg */; }; - 84B1E2F12E051B7D00ED000A /* gravel4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1B92E051B7D00ED000A /* gravel4.ogg */; }; - 84B1E2F22E051B7D00ED000A /* stone1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1BA2E051B7D00ED000A /* stone1.ogg */; }; - 84B1E2F32E051B7D00ED000A /* stone2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1BB2E051B7D00ED000A /* stone2.ogg */; }; - 84B1E2F42E051B7D00ED000A /* stone3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1BC2E051B7D00ED000A /* stone3.ogg */; }; - 84B1E2F52E051B7D00ED000A /* stone4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1BD2E051B7D00ED000A /* stone4.ogg */; }; - 84B1E2F62E051B7D00ED000A /* wood1.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1BE2E051B7D00ED000A /* wood1.ogg */; }; - 84B1E2F72E051B7D00ED000A /* wood2.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1BF2E051B7D00ED000A /* wood2.ogg */; }; - 84B1E2F82E051B7D00ED000A /* wood3.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1C02E051B7D00ED000A /* wood3.ogg */; }; - 84B1E2F92E051B7D00ED000A /* wood4.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 84B1E1C12E051B7D00ED000A /* wood4.ogg */; }; 84B8AEE82AF1890A008DE93D /* App.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD57E2AC810620006A435 /* App.cpp */; }; 84B8AEE92AF1890A008DE93D /* AppPlatform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD5802AC810620006A435 /* AppPlatform.cpp */; }; 84B8AEEA2AF1890A008DE93D /* Minecraft.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD5822AC810620006A435 /* Minecraft.cpp */; }; @@ -902,10 +449,6 @@ 84B8AF032AF1896F008DE93D /* SavingWorldScreen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD5B72AC810620006A435 /* SavingWorldScreen.cpp */; }; 84B8AF042AF1896F008DE93D /* SelectWorldScreen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD5B92AC810620006A435 /* SelectWorldScreen.cpp */; }; 84B8AF052AF1896F008DE93D /* StartMenuScreen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD5BB2AC810620006A435 /* StartMenuScreen.cpp */; }; - 84B8AF062AF1896F008DE93D /* Cube.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD5BE2AC810620006A435 /* Cube.cpp */; }; - 84B8AF072AF1896F008DE93D /* HumanoidModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD5C02AC810620006A435 /* HumanoidModel.cpp */; }; - 84B8AF082AF1896F008DE93D /* Model.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD5C22AC810620006A435 /* Model.cpp */; }; - 84B8AF092AF1896F008DE93D /* PolygonQuad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD5C42AC810620006A435 /* PolygonQuad.cpp */; }; 84B8AF0A2AF1896F008DE93D /* ClientSideNetworkHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD5C72AC810620006A435 /* ClientSideNetworkHandler.cpp */; }; 84B8AF0B2AF1896F008DE93D /* Options.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD5CA2AC810620006A435 /* Options.cpp */; }; 84B8AF0C2AF1896F008DE93D /* Controller.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD5CE2AC810620006A435 /* Controller.cpp */; }; @@ -949,10 +492,6 @@ 84B8AF512AF189D8008DE93D /* SavingWorldScreen.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD5B82AC810620006A435 /* SavingWorldScreen.hpp */; }; 84B8AF522AF189D8008DE93D /* SelectWorldScreen.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD5BA2AC810620006A435 /* SelectWorldScreen.hpp */; }; 84B8AF532AF189D8008DE93D /* StartMenuScreen.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD5BC2AC810620006A435 /* StartMenuScreen.hpp */; }; - 84B8AF542AF189D8008DE93D /* Cube.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD5BF2AC810620006A435 /* Cube.hpp */; }; - 84B8AF552AF189D8008DE93D /* HumanoidModel.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD5C12AC810620006A435 /* HumanoidModel.hpp */; }; - 84B8AF562AF189D8008DE93D /* Model.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD5C32AC810620006A435 /* Model.hpp */; }; - 84B8AF572AF189D8008DE93D /* PolygonQuad.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD5C52AC810620006A435 /* PolygonQuad.hpp */; }; 84B8AF582AF189D8008DE93D /* ClientSideNetworkHandler.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD5C82AC810620006A435 /* ClientSideNetworkHandler.hpp */; }; 84B8AF592AF189D8008DE93D /* Options.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD5CB2AC810620006A435 /* Options.hpp */; }; 84B8AF5A2AF189D8008DE93D /* Controller.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD5CF2AC810620006A435 /* Controller.hpp */; }; @@ -1172,8 +711,6 @@ 84BF63D42AF186C9008A9995 /* TreeTile.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD72B2AC810620006A435 /* TreeTile.hpp */; }; 84BF63D52AF186C9008A9995 /* WireTile.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 840DD72D2AC810620006A435 /* WireTile.hpp */; }; 84C0D8032B15A1D0007E1E76 /* PlatformDefinitions.h in Headers */ = {isa = PBXBuildFile; fileRef = 84C0D8022B15A1D0007E1E76 /* PlatformDefinitions.h */; }; - 84C208532AF88A5000BAE438 /* grass_side_transparent.png in Resources */ = {isa = PBXBuildFile; fileRef = 84C208512AF88A5000BAE438 /* grass_side_transparent.png */; }; - 84C208542AF88A5000BAE438 /* patch_data.txt in Resources */ = {isa = PBXBuildFile; fileRef = 84C208522AF88A5000BAE438 /* patch_data.txt */; }; 84C90EA52AF8861A008973F9 /* OptionList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84C90EA32AF8861A008973F9 /* OptionList.cpp */; }; 84C90EA62AF8861A008973F9 /* OptionList.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84C90EA42AF8861A008973F9 /* OptionList.hpp */; }; 84CCBC3F2E6183F300E251AF /* DataIO.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84CCBC3D2E6183F300E251AF /* DataIO.cpp */; }; @@ -1220,7 +757,8 @@ 84CED51F2E672826006BC585 /* ConvertWorldScreen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84CED51D2E672826006BC585 /* ConvertWorldScreen.cpp */; }; 84CED5202E672826006BC585 /* ConvertWorldScreen.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84CED51E2E672826006BC585 /* ConvertWorldScreen.hpp */; }; 84CEF0032AE3C97D006C5829 /* EAGLView.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CEF0022AE3C97D006C5829 /* EAGLView.m */; }; - 84D9A30E2AF18EC000B00AD3 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8489B3252A86E4B0004CA8EC /* OpenGL.framework */; }; + 84D770132EE5158C00701DCB /* stb_image_impl.c in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8E462B32FB33003F5B82 /* stb_image_impl.c */; }; + 84D772272EE5182B00701DCB /* assets in Resources */ = {isa = PBXBuildFile; fileRef = 84D772262EE5180600701DCB /* assets */; }; 84D9A30F2AF18EE700B00AD3 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8489B3252A86E4B0004CA8EC /* OpenGL.framework */; settings = {ATTRIBUTES = (Required, ); }; }; 84E0011B2AF39E84009B9555 /* BuildActionIntention.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E000FB2AF39E84009B9555 /* BuildActionIntention.hpp */; }; 84E0011C2AF39E84009B9555 /* CustomInputHolder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E000FC2AF39E84009B9555 /* CustomInputHolder.cpp */; }; @@ -1256,14 +794,8 @@ 84E0013A2AF39E84009B9555 /* UnifiedTurnBuild.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E0011A2AF39E84009B9555 /* UnifiedTurnBuild.hpp */; }; 84E001B82AF3A3CB009B9555 /* SmoothFloat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E001B62AF3A3CB009B9555 /* SmoothFloat.cpp */; }; 84E001B92AF3A3CB009B9555 /* SmoothFloat.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E001B72AF3A3CB009B9555 /* SmoothFloat.hpp */; }; - 84E001BB2AF3AF9B009B9555 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 84E001BA2AF3AF9B009B9555 /* MainWindow.xib */; }; 84E105F82E85157F00FAB6C5 /* AppPlatform_sdl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E105F62E85157F00FAB6C5 /* AppPlatform_sdl.cpp */; }; 84E105F92E85157F00FAB6C5 /* AppPlatform_sdl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E105F62E85157F00FAB6C5 /* AppPlatform_sdl.cpp */; }; - 84E1C9BA2E7FDAE3007D2F5D /* birch_sapling.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E1C9B52E7FDAE3007D2F5D /* birch_sapling.png */; }; - 84E1C9BB2E7FDAE3007D2F5D /* dead_bush.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E1C9B62E7FDAE3007D2F5D /* dead_bush.png */; }; - 84E1C9BC2E7FDAE3007D2F5D /* fern.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E1C9B72E7FDAE3007D2F5D /* fern.png */; }; - 84E1C9BD2E7FDAE3007D2F5D /* spruce_sapling.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E1C9B82E7FDAE3007D2F5D /* spruce_sapling.png */; }; - 84E1C9BE2E7FDAE3007D2F5D /* tall_grass.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E1C9B92E7FDAE3007D2F5D /* tall_grass.png */; }; 84E1C9CF2E7FDC26007D2F5D /* CactusTile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E1C9BF2E7FDC26007D2F5D /* CactusTile.cpp */; }; 84E1C9D02E7FDC26007D2F5D /* CactusTile.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E1C9C02E7FDC26007D2F5D /* CactusTile.hpp */; }; 84E1C9D12E7FDC26007D2F5D /* DeadBush.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E1C9C12E7FDC26007D2F5D /* DeadBush.cpp */; }; @@ -1291,7 +823,6 @@ 84E1C9F02E7FDC89007D2F5D /* VegetationFeature.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E1C9ED2E7FDC89007D2F5D /* VegetationFeature.cpp */; }; 84E4BFB52AE9869A0023E16A /* CThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD6262AC810620006A435 /* CThread.cpp */; }; 84E4BFB62AE9869A0023E16A /* Logger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD6282AC810620006A435 /* Logger.cpp */; }; - 84E4BFB72AE9869A0023E16A /* Matrix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD62B2AC810620006A435 /* Matrix.cpp */; }; 84E4BFB82AE9869A0023E16A /* Mth.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD62D2AC810620006A435 /* Mth.cpp */; }; 84E4BFB92AE9869A0023E16A /* Random.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD62F2AC810620006A435 /* Random.cpp */; }; 84E4BFBB2AE9869A0023E16A /* Timer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD6332AC810620006A435 /* Timer.cpp */; }; @@ -1305,16 +836,288 @@ 84E78C842B58B5FB00D515EF /* RocketItem.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E78C822B58B5FB00D515EF /* RocketItem.hpp */; }; 84E78C872B58B66B00D515EF /* RocketLauncherTile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E78C852B58B66B00D515EF /* RocketLauncherTile.cpp */; }; 84E78C882B58B66B00D515EF /* RocketLauncherTile.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84E78C862B58B66B00D515EF /* RocketLauncherTile.hpp */; }; - 84E78C8C2B58BB7400D515EF /* n_rocket_launched.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E78C892B58BB7400D515EF /* n_rocket_launched.png */; }; - 84E78C8D2B58BB7400D515EF /* n_rocket_launcher.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E78C8A2B58BB7400D515EF /* n_rocket_launcher.png */; }; - 84E78C8E2B58BB7400D515EF /* n_rocket.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E78C8B2B58BB7400D515EF /* n_rocket.png */; }; - 84E78C902B58C18C00D515EF /* black.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E78C8F2B58C18C00D515EF /* black.png */; }; 84E8DCE52E84ACBC00B30789 /* libRenderer.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8406FD292AF1814500B09C1D /* libRenderer.a */; }; 84EAE8DE2AF1EAA1000894E8 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84EAE8DD2AF1EAA1000894E8 /* UIKit.framework */; }; 84EAE8E02AF1EAA9000894E8 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84EAE8DF2AF1EAA9000894E8 /* CoreGraphics.framework */; }; 84EAE8E42AF1EABE000894E8 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84EAE8E32AF1EABE000894E8 /* OpenGLES.framework */; }; 84EAE8F72AF1EAFA000894E8 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EAE8F12AF1EAFA000894E8 /* main.cpp */; }; - 84ED99D52AFF12D1003B6AF0 /* minecraftpe.entitlements in Resources */ = {isa = PBXBuildFile; fileRef = 84ED99D42AFF12D1003B6AF0 /* minecraftpe.entitlements */; }; + 84EB09962EE2CC25008FB007 /* AppPlatformListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB09942EE2CC25008FB007 /* AppPlatformListener.cpp */; }; + 84EB09972EE2CC25008FB007 /* AppPlatformListener.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB09952EE2CC25008FB007 /* AppPlatformListener.hpp */; }; + 84EB099B2EE2CC3B008FB007 /* GuiElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB09982EE2CC3B008FB007 /* GuiElement.cpp */; }; + 84EB099C2EE2CC3B008FB007 /* GuiElement.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB09992EE2CC3B008FB007 /* GuiElement.hpp */; }; + 84EB099D2EE2CC3B008FB007 /* IntRectangle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB099A2EE2CC3B008FB007 /* IntRectangle.hpp */; }; + 84EB09C12EE2CC86008FB007 /* Cube.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB09A12EE2CC86008FB007 /* Cube.cpp */; }; + 84EB09C22EE2CC86008FB007 /* Cube.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB09A22EE2CC86008FB007 /* Cube.hpp */; }; + 84EB09C32EE2CC86008FB007 /* ModelPart.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB09A32EE2CC86008FB007 /* ModelPart.cpp */; }; + 84EB09C42EE2CC86008FB007 /* ModelPart.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB09A42EE2CC86008FB007 /* ModelPart.hpp */; }; + 84EB09C52EE2CC86008FB007 /* PolygonQuad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB09A52EE2CC86008FB007 /* PolygonQuad.cpp */; }; + 84EB09C62EE2CC86008FB007 /* PolygonQuad.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB09A62EE2CC86008FB007 /* PolygonQuad.hpp */; }; + 84EB09C72EE2CC86008FB007 /* TextureOffset.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB09A72EE2CC86008FB007 /* TextureOffset.hpp */; }; + 84EB09C82EE2CC86008FB007 /* ChickenModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB09A92EE2CC86008FB007 /* ChickenModel.cpp */; }; + 84EB09C92EE2CC86008FB007 /* ChickenModel.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB09AA2EE2CC86008FB007 /* ChickenModel.hpp */; }; + 84EB09CA2EE2CC86008FB007 /* CowModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB09AB2EE2CC86008FB007 /* CowModel.cpp */; }; + 84EB09CB2EE2CC86008FB007 /* CowModel.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB09AC2EE2CC86008FB007 /* CowModel.hpp */; }; + 84EB09CC2EE2CC86008FB007 /* CreeperModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB09AD2EE2CC86008FB007 /* CreeperModel.cpp */; }; + 84EB09CD2EE2CC86008FB007 /* CreeperModel.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB09AE2EE2CC86008FB007 /* CreeperModel.hpp */; }; + 84EB09CE2EE2CC86008FB007 /* HumanoidModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB09AF2EE2CC86008FB007 /* HumanoidModel.cpp */; }; + 84EB09CF2EE2CC86008FB007 /* HumanoidModel.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB09B02EE2CC86008FB007 /* HumanoidModel.hpp */; }; + 84EB09D02EE2CC86008FB007 /* Model.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB09B12EE2CC86008FB007 /* Model.cpp */; }; + 84EB09D12EE2CC86008FB007 /* Model.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB09B22EE2CC86008FB007 /* Model.hpp */; }; + 84EB09D22EE2CC86008FB007 /* PigModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB09B32EE2CC86008FB007 /* PigModel.cpp */; }; + 84EB09D32EE2CC86008FB007 /* PigModel.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB09B42EE2CC86008FB007 /* PigModel.hpp */; }; + 84EB09D42EE2CC86008FB007 /* QuadrupedModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB09B52EE2CC86008FB007 /* QuadrupedModel.cpp */; }; + 84EB09D52EE2CC86008FB007 /* QuadrupedModel.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB09B62EE2CC86008FB007 /* QuadrupedModel.hpp */; }; + 84EB09D62EE2CC86008FB007 /* SheepFurModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB09B72EE2CC86008FB007 /* SheepFurModel.cpp */; }; + 84EB09D72EE2CC86008FB007 /* SheepFurModel.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB09B82EE2CC86008FB007 /* SheepFurModel.hpp */; }; + 84EB09D82EE2CC86008FB007 /* SheepModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB09B92EE2CC86008FB007 /* SheepModel.cpp */; }; + 84EB09D92EE2CC86008FB007 /* SheepModel.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB09BA2EE2CC86008FB007 /* SheepModel.hpp */; }; + 84EB09DA2EE2CC86008FB007 /* SkeletonModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB09BB2EE2CC86008FB007 /* SkeletonModel.cpp */; }; + 84EB09DB2EE2CC86008FB007 /* SkeletonModel.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB09BC2EE2CC86008FB007 /* SkeletonModel.hpp */; }; + 84EB09DC2EE2CC86008FB007 /* SpiderModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB09BD2EE2CC86008FB007 /* SpiderModel.cpp */; }; + 84EB09DD2EE2CC86008FB007 /* SpiderModel.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB09BE2EE2CC86008FB007 /* SpiderModel.hpp */; }; + 84EB09DE2EE2CC86008FB007 /* ZombieModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB09BF2EE2CC86008FB007 /* ZombieModel.cpp */; }; + 84EB09DF2EE2CC86008FB007 /* ZombieModel.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB09C02EE2CC86008FB007 /* ZombieModel.hpp */; }; + 84EB09EF2EE2CCA8008FB007 /* Fog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB09E02EE2CCA8008FB007 /* Fog.cpp */; }; + 84EB09F02EE2CCA8008FB007 /* Fog.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB09E12EE2CCA8008FB007 /* Fog.hpp */; }; + 84EB09F12EE2CCA8008FB007 /* EntityShaderManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB09E32EE2CCA8008FB007 /* EntityShaderManager.cpp */; }; + 84EB09F22EE2CCA8008FB007 /* EntityShaderManager.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB09E42EE2CCA8008FB007 /* EntityShaderManager.hpp */; }; + 84EB09F32EE2CCA8008FB007 /* RenderMaterialGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB09E52EE2CCA8008FB007 /* RenderMaterialGroup.cpp */; }; + 84EB09F42EE2CCA8008FB007 /* RenderMaterialGroup.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB09E62EE2CCA8008FB007 /* RenderMaterialGroup.hpp */; }; + 84EB09F52EE2CCA8008FB007 /* ScreenRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB09E72EE2CCA8008FB007 /* ScreenRenderer.cpp */; }; + 84EB09F62EE2CCA8008FB007 /* ScreenRenderer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB09E82EE2CCA8008FB007 /* ScreenRenderer.hpp */; }; + 84EB09F72EE2CCA8008FB007 /* ColorSpace.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB09EA2EE2CCA8008FB007 /* ColorSpace.hpp */; }; + 84EB09F82EE2CCA8008FB007 /* ImageData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB09EB2EE2CCA8008FB007 /* ImageData.cpp */; }; + 84EB09F92EE2CCA8008FB007 /* ImageData.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB09EC2EE2CCA8008FB007 /* ImageData.hpp */; }; + 84EB09FA2EE2CCA8008FB007 /* TextureData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB09ED2EE2CCA8008FB007 /* TextureData.cpp */; }; + 84EB09FB2EE2CCA8008FB007 /* TextureData.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB09EE2EE2CCA8008FB007 /* TextureData.hpp */; }; + 84EB0D122EE2D4B3008FB007 /* Attribute.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C102EE2D4B2008FB007 /* Attribute.cpp */; }; + 84EB0D132EE2D4B3008FB007 /* Attribute.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C112EE2D4B2008FB007 /* Attribute.hpp */; }; + 84EB0D142EE2D4B3008FB007 /* ConstantBufferMetaData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C122EE2D4B2008FB007 /* ConstantBufferMetaData.cpp */; }; + 84EB0D152EE2D4B3008FB007 /* ConstantBufferMetaData.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C132EE2D4B2008FB007 /* ConstantBufferMetaData.hpp */; }; + 84EB0D162EE2D4B3008FB007 /* ConstantBufferMetaDataManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C142EE2D4B2008FB007 /* ConstantBufferMetaDataManager.cpp */; }; + 84EB0D172EE2D4B3008FB007 /* ConstantBufferMetaDataManager.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C152EE2D4B2008FB007 /* ConstantBufferMetaDataManager.hpp */; }; + 84EB0D182EE2D4B3008FB007 /* EnableScissorTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C162EE2D4B2008FB007 /* EnableScissorTest.cpp */; }; + 84EB0D192EE2D4B3008FB007 /* EnableScissorTest.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C172EE2D4B2008FB007 /* EnableScissorTest.hpp */; }; + 84EB0D1A2EE2D4B3008FB007 /* EntityConstants.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C182EE2D4B2008FB007 /* EntityConstants.cpp */; }; + 84EB0D1B2EE2D4B3008FB007 /* EntityConstants.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C192EE2D4B2008FB007 /* EntityConstants.hpp */; }; + 84EB0D1C2EE2D4B3008FB007 /* GlobalConstantBufferManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C1A2EE2D4B2008FB007 /* GlobalConstantBufferManager.cpp */; }; + 84EB0D1D2EE2D4B3008FB007 /* GlobalConstantBufferManager.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C1B2EE2D4B2008FB007 /* GlobalConstantBufferManager.hpp */; }; + 84EB0D1E2EE2D4B3008FB007 /* GlobalConstantBuffers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C1C2EE2D4B2008FB007 /* GlobalConstantBuffers.cpp */; }; + 84EB0D1F2EE2D4B3008FB007 /* GlobalConstantBuffers.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C1D2EE2D4B2008FB007 /* GlobalConstantBuffers.hpp */; }; + 84EB0D202EE2D4B3008FB007 /* BlendStateBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C202EE2D4B2008FB007 /* BlendStateBase.cpp */; }; + 84EB0D212EE2D4B3008FB007 /* BlendStateBase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C212EE2D4B2008FB007 /* BlendStateBase.hpp */; }; + 84EB0D222EE2D4B3008FB007 /* BufferBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C222EE2D4B2008FB007 /* BufferBase.cpp */; }; + 84EB0D232EE2D4B3008FB007 /* BufferBase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C232EE2D4B2008FB007 /* BufferBase.hpp */; }; + 84EB0D242EE2D4B3008FB007 /* ConstantBufferBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C242EE2D4B2008FB007 /* ConstantBufferBase.cpp */; }; + 84EB0D252EE2D4B3008FB007 /* ConstantBufferBase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C252EE2D4B2008FB007 /* ConstantBufferBase.hpp */; }; + 84EB0D262EE2D4B3008FB007 /* ConstantBufferConstantsBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C262EE2D4B2008FB007 /* ConstantBufferConstantsBase.cpp */; }; + 84EB0D272EE2D4B3008FB007 /* ConstantBufferConstantsBase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C272EE2D4B2008FB007 /* ConstantBufferConstantsBase.hpp */; }; + 84EB0D282EE2D4B3008FB007 /* ConstantBufferContainerBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C282EE2D4B2008FB007 /* ConstantBufferContainerBase.cpp */; }; + 84EB0D292EE2D4B3008FB007 /* ConstantBufferContainerBase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C292EE2D4B2008FB007 /* ConstantBufferContainerBase.hpp */; }; + 84EB0D2A2EE2D4B3008FB007 /* DepthStencilStateBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C2A2EE2D4B2008FB007 /* DepthStencilStateBase.cpp */; }; + 84EB0D2B2EE2D4B3008FB007 /* DepthStencilStateBase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C2B2EE2D4B2008FB007 /* DepthStencilStateBase.hpp */; }; + 84EB0D2C2EE2D4B3008FB007 /* FixedPipelineStateBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C2C2EE2D4B2008FB007 /* FixedPipelineStateBase.cpp */; }; + 84EB0D2D2EE2D4B3008FB007 /* FixedPipelineStateBase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C2D2EE2D4B2008FB007 /* FixedPipelineStateBase.hpp */; }; + 84EB0D2E2EE2D4B3008FB007 /* FogStateBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C2E2EE2D4B2008FB007 /* FogStateBase.cpp */; }; + 84EB0D2F2EE2D4B3008FB007 /* FogStateBase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C2F2EE2D4B2008FB007 /* FogStateBase.hpp */; }; + 84EB0D302EE2D4B3008FB007 /* FrameBufferObjectBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C302EE2D4B2008FB007 /* FrameBufferObjectBase.cpp */; }; + 84EB0D312EE2D4B3008FB007 /* FrameBufferObjectBase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C312EE2D4B2008FB007 /* FrameBufferObjectBase.hpp */; }; + 84EB0D322EE2D4B3008FB007 /* ImmediateBufferBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C322EE2D4B2008FB007 /* ImmediateBufferBase.cpp */; }; + 84EB0D332EE2D4B3008FB007 /* ImmediateBufferBase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C332EE2D4B2008FB007 /* ImmediateBufferBase.hpp */; }; + 84EB0D342EE2D4B3008FB007 /* RasterizerStateBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C342EE2D4B2008FB007 /* RasterizerStateBase.cpp */; }; + 84EB0D352EE2D4B3008FB007 /* RasterizerStateBase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C352EE2D4B2008FB007 /* RasterizerStateBase.hpp */; }; + 84EB0D362EE2D4B3008FB007 /* RenderContextBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C362EE2D4B2008FB007 /* RenderContextBase.cpp */; }; + 84EB0D372EE2D4B3008FB007 /* RenderContextBase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C372EE2D4B2008FB007 /* RenderContextBase.hpp */; }; + 84EB0D382EE2D4B3008FB007 /* RenderContextStateBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C382EE2D4B2008FB007 /* RenderContextStateBase.cpp */; }; + 84EB0D392EE2D4B3008FB007 /* RenderContextStateBase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C392EE2D4B2008FB007 /* RenderContextStateBase.hpp */; }; + 84EB0D3A2EE2D4B3008FB007 /* RenderDeviceBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C3A2EE2D4B2008FB007 /* RenderDeviceBase.cpp */; }; + 84EB0D3B2EE2D4B3008FB007 /* RenderDeviceBase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C3B2EE2D4B2008FB007 /* RenderDeviceBase.hpp */; }; + 84EB0D3C2EE2D4B3008FB007 /* ShaderBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C3C2EE2D4B2008FB007 /* ShaderBase.cpp */; }; + 84EB0D3D2EE2D4B3008FB007 /* ShaderBase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C3D2EE2D4B2008FB007 /* ShaderBase.hpp */; }; + 84EB0D3E2EE2D4B3008FB007 /* ShaderConstantBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C3E2EE2D4B2008FB007 /* ShaderConstantBase.cpp */; }; + 84EB0D3F2EE2D4B3008FB007 /* ShaderConstantBase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C3F2EE2D4B2008FB007 /* ShaderConstantBase.hpp */; }; + 84EB0D402EE2D4B3008FB007 /* ShaderConstantWithDataBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C402EE2D4B2008FB007 /* ShaderConstantWithDataBase.cpp */; }; + 84EB0D412EE2D4B3008FB007 /* ShaderConstantWithDataBase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C412EE2D4B2008FB007 /* ShaderConstantWithDataBase.hpp */; }; + 84EB0D422EE2D4B3008FB007 /* ShaderContextBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C422EE2D4B2008FB007 /* ShaderContextBase.cpp */; }; + 84EB0D432EE2D4B3008FB007 /* ShaderContextBase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C432EE2D4B2008FB007 /* ShaderContextBase.hpp */; }; + 84EB0D442EE2D4B3008FB007 /* ShaderProgramBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C442EE2D4B2008FB007 /* ShaderProgramBase.cpp */; }; + 84EB0D452EE2D4B3008FB007 /* ShaderProgramBase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C452EE2D4B2008FB007 /* ShaderProgramBase.hpp */; }; + 84EB0D462EE2D4B3008FB007 /* TextureBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C462EE2D4B2008FB007 /* TextureBase.cpp */; }; + 84EB0D472EE2D4B3008FB007 /* TextureBase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C472EE2D4B2008FB007 /* TextureBase.hpp */; }; + 84EB0D482EE2D4B3008FB007 /* BlendStateDescription.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C482EE2D4B3008FB007 /* BlendStateDescription.cpp */; }; + 84EB0D492EE2D4B3008FB007 /* BlendStateDescription.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C492EE2D4B3008FB007 /* BlendStateDescription.hpp */; }; + 84EB0D4A2EE2D4B3008FB007 /* DepthStencilStateDescription.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C4A2EE2D4B3008FB007 /* DepthStencilStateDescription.cpp */; }; + 84EB0D4B2EE2D4B3008FB007 /* DepthStencilStateDescription.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C4B2EE2D4B3008FB007 /* DepthStencilStateDescription.hpp */; }; + 84EB0D4C2EE2D4B3008FB007 /* BlendTarget.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C4D2EE2D4B3008FB007 /* BlendTarget.hpp */; }; + 84EB0D4D2EE2D4B3008FB007 /* BlendTarget_JsonParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C4E2EE2D4B3008FB007 /* BlendTarget_JsonParser.cpp */; }; + 84EB0D4E2EE2D4B3008FB007 /* BufferType.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C4F2EE2D4B3008FB007 /* BufferType.hpp */; }; + 84EB0D4F2EE2D4B3008FB007 /* ColorWriteMask.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C502EE2D4B3008FB007 /* ColorWriteMask.hpp */; }; + 84EB0D502EE2D4B3008FB007 /* ComparisonFunc.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C512EE2D4B3008FB007 /* ComparisonFunc.hpp */; }; + 84EB0D512EE2D4B3008FB007 /* ComparisonFunc_JsonParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C522EE2D4B3008FB007 /* ComparisonFunc_JsonParser.cpp */; }; + 84EB0D522EE2D4B3008FB007 /* CullMode.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C532EE2D4B3008FB007 /* CullMode.hpp */; }; + 84EB0D532EE2D4B3008FB007 /* DepthWriteMask.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C542EE2D4B3008FB007 /* DepthWriteMask.hpp */; }; + 84EB0D542EE2D4B3008FB007 /* FogMode.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C552EE2D4B3008FB007 /* FogMode.hpp */; }; + 84EB0D552EE2D4B3008FB007 /* PrimitiveMode.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C562EE2D4B3008FB007 /* PrimitiveMode.hpp */; }; + 84EB0D562EE2D4B3008FB007 /* PrimitiveMode_JsonParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C572EE2D4B3008FB007 /* PrimitiveMode_JsonParser.cpp */; }; + 84EB0D572EE2D4B3008FB007 /* RenderState.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C582EE2D4B3008FB007 /* RenderState.hpp */; }; + 84EB0D582EE2D4B3008FB007 /* RenderState_JsonParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C592EE2D4B3008FB007 /* RenderState_JsonParser.cpp */; }; + 84EB0D592EE2D4B3008FB007 /* RenderState_JsonParser.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C5A2EE2D4B3008FB007 /* RenderState_JsonParser.hpp */; }; + 84EB0D5A2EE2D4B3008FB007 /* ShadeMode.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C5B2EE2D4B3008FB007 /* ShadeMode.hpp */; }; + 84EB0D5B2EE2D4B3008FB007 /* ShaderPrimitiveTypes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C5C2EE2D4B3008FB007 /* ShaderPrimitiveTypes.cpp */; }; + 84EB0D5C2EE2D4B3008FB007 /* ShaderPrimitiveTypes.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C5D2EE2D4B3008FB007 /* ShaderPrimitiveTypes.hpp */; }; + 84EB0D5D2EE2D4B3008FB007 /* ShaderStagesBits.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C5E2EE2D4B3008FB007 /* ShaderStagesBits.hpp */; }; + 84EB0D5E2EE2D4B3008FB007 /* ShaderStagesBits_JsonParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C5F2EE2D4B3008FB007 /* ShaderStagesBits_JsonParser.cpp */; }; + 84EB0D5F2EE2D4B3008FB007 /* ShaderType.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C602EE2D4B3008FB007 /* ShaderType.hpp */; }; + 84EB0D602EE2D4B3008FB007 /* StencilMask.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C612EE2D4B3008FB007 /* StencilMask.hpp */; }; + 84EB0D612EE2D4B3008FB007 /* StencilOp.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C622EE2D4B3008FB007 /* StencilOp.hpp */; }; + 84EB0D622EE2D4B3008FB007 /* StencilOp_JsonParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C632EE2D4B3008FB007 /* StencilOp_JsonParser.cpp */; }; + 84EB0D632EE2D4B3008FB007 /* TextureFiltering.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C642EE2D4B3008FB007 /* TextureFiltering.hpp */; }; + 84EB0D642EE2D4B3008FB007 /* TextureFiltering_JsonParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C652EE2D4B3008FB007 /* TextureFiltering_JsonParser.cpp */; }; + 84EB0D652EE2D4B3008FB007 /* TextureFormat.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C662EE2D4B3008FB007 /* TextureFormat.hpp */; }; + 84EB0D662EE2D4B3008FB007 /* VertexField.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C672EE2D4B3008FB007 /* VertexField.hpp */; }; + 84EB0D672EE2D4B3008FB007 /* VertexField_JsonParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C682EE2D4B3008FB007 /* VertexField_JsonParser.cpp */; }; + 84EB0D682EE2D4B3008FB007 /* VertexFieldType.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C692EE2D4B3008FB007 /* VertexFieldType.hpp */; }; + 84EB0D692EE2D4B3008FB007 /* FixedPipelineStateDescription.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C6A2EE2D4B3008FB007 /* FixedPipelineStateDescription.cpp */; }; + 84EB0D6A2EE2D4B3008FB007 /* FixedPipelineStateDescription.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C6B2EE2D4B3008FB007 /* FixedPipelineStateDescription.hpp */; }; + 84EB0D6B2EE2D4B3008FB007 /* FogStateDescription.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C6C2EE2D4B3008FB007 /* FogStateDescription.cpp */; }; + 84EB0D6C2EE2D4B3008FB007 /* FogStateDescription.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C6D2EE2D4B3008FB007 /* FogStateDescription.hpp */; }; + 84EB0D6D2EE2D4B3008FB007 /* ErrorHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C6F2EE2D4B3008FB007 /* ErrorHandler.cpp */; }; + 84EB0D6E2EE2D4B3008FB007 /* ErrorHandler.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C702EE2D4B3008FB007 /* ErrorHandler.hpp */; }; + 84EB0D6F2EE2D4B3008FB007 /* TextureHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C712EE2D4B3008FB007 /* TextureHelper.cpp */; }; + 84EB0D702EE2D4B3008FB007 /* TextureHelper.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C722EE2D4B3008FB007 /* TextureHelper.hpp */; }; + 84EB0D712EE2D4B3008FB007 /* ImageDescription.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C732EE2D4B3008FB007 /* ImageDescription.cpp */; }; + 84EB0D722EE2D4B3008FB007 /* ImageDescription.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C742EE2D4B3008FB007 /* ImageDescription.hpp */; }; + 84EB0D732EE2D4B3008FB007 /* BlendState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C762EE2D4B3008FB007 /* BlendState.cpp */; }; + 84EB0D742EE2D4B3008FB007 /* BlendState.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C772EE2D4B3008FB007 /* BlendState.hpp */; }; + 84EB0D752EE2D4B3008FB007 /* Buffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C782EE2D4B3008FB007 /* Buffer.cpp */; }; + 84EB0D762EE2D4B3008FB007 /* Buffer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C792EE2D4B3008FB007 /* Buffer.hpp */; }; + 84EB0D772EE2D4B3008FB007 /* ConstantBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C7A2EE2D4B3008FB007 /* ConstantBuffer.cpp */; }; + 84EB0D782EE2D4B3008FB007 /* ConstantBuffer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C7B2EE2D4B3008FB007 /* ConstantBuffer.hpp */; }; + 84EB0D792EE2D4B3008FB007 /* ConstantBufferConstants.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C7C2EE2D4B3008FB007 /* ConstantBufferConstants.hpp */; }; + 84EB0D7A2EE2D4B3008FB007 /* ConstantBufferContainer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C7D2EE2D4B3008FB007 /* ConstantBufferContainer.cpp */; }; + 84EB0D7B2EE2D4B3008FB007 /* ConstantBufferContainer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C7E2EE2D4B3008FB007 /* ConstantBufferContainer.hpp */; }; + 84EB0D7C2EE2D4B3008FB007 /* DepthStencilState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C7F2EE2D4B3008FB007 /* DepthStencilState.cpp */; }; + 84EB0D7D2EE2D4B3008FB007 /* DepthStencilState.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C802EE2D4B3008FB007 /* DepthStencilState.hpp */; }; + 84EB0D7E2EE2D4B3008FB007 /* FixedPipelineState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C812EE2D4B3008FB007 /* FixedPipelineState.cpp */; }; + 84EB0D7F2EE2D4B3008FB007 /* FixedPipelineState.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C822EE2D4B3008FB007 /* FixedPipelineState.hpp */; }; + 84EB0D802EE2D4B3008FB007 /* FogState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C832EE2D4B3008FB007 /* FogState.cpp */; }; + 84EB0D812EE2D4B3008FB007 /* FogState.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C842EE2D4B3008FB007 /* FogState.hpp */; }; + 84EB0D822EE2D4B3008FB007 /* ImmediateBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C852EE2D4B3008FB007 /* ImmediateBuffer.cpp */; }; + 84EB0D832EE2D4B3008FB007 /* ImmediateBuffer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C862EE2D4B3008FB007 /* ImmediateBuffer.hpp */; }; + 84EB0D842EE2D4B3008FB007 /* RasterizerState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C872EE2D4B3008FB007 /* RasterizerState.cpp */; }; + 84EB0D852EE2D4B3008FB007 /* RasterizerState.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C882EE2D4B3008FB007 /* RasterizerState.hpp */; }; + 84EB0D862EE2D4B3008FB007 /* RenderContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C892EE2D4B3008FB007 /* RenderContext.cpp */; }; + 84EB0D872EE2D4B3008FB007 /* RenderContext.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C8A2EE2D4B3008FB007 /* RenderContext.hpp */; }; + 84EB0D882EE2D4B3008FB007 /* RenderDevice.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C8B2EE2D4B3008FB007 /* RenderDevice.cpp */; }; + 84EB0D892EE2D4B3008FB007 /* RenderDevice.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C8C2EE2D4B3008FB007 /* RenderDevice.hpp */; }; + 84EB0D8A2EE2D4B3008FB007 /* Shader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C8D2EE2D4B3008FB007 /* Shader.cpp */; }; + 84EB0D8B2EE2D4B3008FB007 /* Shader.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C8E2EE2D4B3008FB007 /* Shader.hpp */; }; + 84EB0D8C2EE2D4B3008FB007 /* ShaderConstant.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C8F2EE2D4B3008FB007 /* ShaderConstant.hpp */; }; + 84EB0D8D2EE2D4B3008FB007 /* ShaderConstantWithData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C902EE2D4B3008FB007 /* ShaderConstantWithData.cpp */; }; + 84EB0D8E2EE2D4B3008FB007 /* ShaderConstantWithData.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C912EE2D4B3008FB007 /* ShaderConstantWithData.hpp */; }; + 84EB0D8F2EE2D4B3008FB007 /* ShaderProgram.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C922EE2D4B3008FB007 /* ShaderProgram.cpp */; }; + 84EB0D902EE2D4B3008FB007 /* ShaderProgram.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C932EE2D4B3008FB007 /* ShaderProgram.hpp */; }; + 84EB0D912EE2D4B3008FB007 /* Texture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0C942EE2D4B3008FB007 /* Texture.cpp */; }; + 84EB0D922EE2D4B3008FB007 /* Texture.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0C952EE2D4B3008FB007 /* Texture.hpp */; }; + 84EB0DB12EE2D4B4008FB007 /* API_OGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CB62EE2D4B3008FB007 /* API_OGL.cpp */; }; + 84EB0DB22EE2D4B4008FB007 /* API_OGL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CB72EE2D4B3008FB007 /* API_OGL.hpp */; }; + 84EB0DB32EE2D4B4008FB007 /* BlendStateOGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CB82EE2D4B3008FB007 /* BlendStateOGL.cpp */; }; + 84EB0DB42EE2D4B4008FB007 /* BlendStateOGL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CB92EE2D4B3008FB007 /* BlendStateOGL.hpp */; }; + 84EB0DB52EE2D4B4008FB007 /* BufferOGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CBA2EE2D4B3008FB007 /* BufferOGL.cpp */; }; + 84EB0DB62EE2D4B4008FB007 /* BufferOGL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CBB2EE2D4B3008FB007 /* BufferOGL.hpp */; }; + 84EB0DB72EE2D4B4008FB007 /* ConstantBufferContainerOGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CBC2EE2D4B3008FB007 /* ConstantBufferContainerOGL.cpp */; }; + 84EB0DB82EE2D4B4008FB007 /* ConstantBufferContainerOGL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CBD2EE2D4B3008FB007 /* ConstantBufferContainerOGL.hpp */; }; + 84EB0DB92EE2D4B4008FB007 /* DepthStencilStateOGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CBE2EE2D4B3008FB007 /* DepthStencilStateOGL.cpp */; }; + 84EB0DBA2EE2D4B4008FB007 /* DepthStencilStateOGL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CBF2EE2D4B3008FB007 /* DepthStencilStateOGL.hpp */; }; + 84EB0DBB2EE2D4B4008FB007 /* FixedPipelineStateOGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CC02EE2D4B3008FB007 /* FixedPipelineStateOGL.cpp */; }; + 84EB0DBC2EE2D4B4008FB007 /* FixedPipelineStateOGL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CC12EE2D4B3008FB007 /* FixedPipelineStateOGL.hpp */; }; + 84EB0DBD2EE2D4B4008FB007 /* FogStateOGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CC22EE2D4B3008FB007 /* FogStateOGL.cpp */; }; + 84EB0DBE2EE2D4B4008FB007 /* FogStateOGL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CC32EE2D4B3008FB007 /* FogStateOGL.hpp */; }; + 84EB0DBF2EE2D4B4008FB007 /* GPUEventsOGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CC42EE2D4B3008FB007 /* GPUEventsOGL.cpp */; }; + 84EB0DC02EE2D4B4008FB007 /* GPUEventsOGL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CC52EE2D4B3008FB007 /* GPUEventsOGL.hpp */; }; + 84EB0DC12EE2D4B4008FB007 /* ImmediateBufferOGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CC62EE2D4B3008FB007 /* ImmediateBufferOGL.cpp */; }; + 84EB0DC22EE2D4B4008FB007 /* ImmediateBufferOGL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CC72EE2D4B3008FB007 /* ImmediateBufferOGL.hpp */; }; + 84EB0DC32EE2D4B4008FB007 /* ProfileSectionOGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CC82EE2D4B3008FB007 /* ProfileSectionOGL.cpp */; }; + 84EB0DC42EE2D4B4008FB007 /* ProfileSectionOGL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CC92EE2D4B3008FB007 /* ProfileSectionOGL.hpp */; }; + 84EB0DC52EE2D4B4008FB007 /* RasterizerStateOGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CCA2EE2D4B3008FB007 /* RasterizerStateOGL.cpp */; }; + 84EB0DC62EE2D4B4008FB007 /* RasterizerStateOGL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CCB2EE2D4B3008FB007 /* RasterizerStateOGL.hpp */; }; + 84EB0DC72EE2D4B4008FB007 /* RenderContextOGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CCC2EE2D4B3008FB007 /* RenderContextOGL.cpp */; }; + 84EB0DC82EE2D4B4008FB007 /* RenderContextOGL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CCD2EE2D4B3008FB007 /* RenderContextOGL.hpp */; }; + 84EB0DC92EE2D4B4008FB007 /* RenderDeviceOGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CCE2EE2D4B3008FB007 /* RenderDeviceOGL.cpp */; }; + 84EB0DCA2EE2D4B4008FB007 /* RenderDeviceOGL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CCF2EE2D4B3008FB007 /* RenderDeviceOGL.hpp */; }; + 84EB0DCB2EE2D4B4008FB007 /* ResourceOGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CD02EE2D4B3008FB007 /* ResourceOGL.cpp */; }; + 84EB0DCC2EE2D4B4008FB007 /* ResourceOGL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CD12EE2D4B3008FB007 /* ResourceOGL.hpp */; }; + 84EB0DCD2EE2D4B4008FB007 /* ShaderConstantOGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CD22EE2D4B3008FB007 /* ShaderConstantOGL.cpp */; }; + 84EB0DCE2EE2D4B4008FB007 /* ShaderConstantOGL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CD32EE2D4B3008FB007 /* ShaderConstantOGL.hpp */; }; + 84EB0DCF2EE2D4B4008FB007 /* ShaderConstantWithDataOGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CD42EE2D4B3008FB007 /* ShaderConstantWithDataOGL.cpp */; }; + 84EB0DD02EE2D4B4008FB007 /* ShaderConstantWithDataOGL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CD52EE2D4B3008FB007 /* ShaderConstantWithDataOGL.hpp */; }; + 84EB0DD12EE2D4B4008FB007 /* ShaderOGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CD62EE2D4B3008FB007 /* ShaderOGL.cpp */; }; + 84EB0DD22EE2D4B4008FB007 /* ShaderOGL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CD72EE2D4B3008FB007 /* ShaderOGL.hpp */; }; + 84EB0DD32EE2D4B4008FB007 /* ShaderProgramOGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CD82EE2D4B3008FB007 /* ShaderProgramOGL.cpp */; }; + 84EB0DD42EE2D4B4008FB007 /* ShaderProgramOGL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CD92EE2D4B3008FB007 /* ShaderProgramOGL.hpp */; }; + 84EB0DD52EE2D4B4008FB007 /* ShaderResourceOGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CDA2EE2D4B3008FB007 /* ShaderResourceOGL.cpp */; }; + 84EB0DD62EE2D4B4008FB007 /* ShaderResourceOGL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CDB2EE2D4B3008FB007 /* ShaderResourceOGL.hpp */; }; + 84EB0DD72EE2D4B4008FB007 /* ShaderUniformOGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CDC2EE2D4B3008FB007 /* ShaderUniformOGL.cpp */; }; + 84EB0DD82EE2D4B4008FB007 /* ShaderUniformOGL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CDD2EE2D4B3008FB007 /* ShaderUniformOGL.hpp */; }; + 84EB0DD92EE2D4B4008FB007 /* TextureOGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CDE2EE2D4B3008FB007 /* TextureOGL.cpp */; }; + 84EB0DDA2EE2D4B4008FB007 /* TextureOGL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CDF2EE2D4B3008FB007 /* TextureOGL.hpp */; }; + 84EB0DDB2EE2D4B4008FB007 /* RasterizerStateDescription.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CE02EE2D4B3008FB007 /* RasterizerStateDescription.cpp */; }; + 84EB0DDC2EE2D4B4008FB007 /* RasterizerStateDescription.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CE12EE2D4B3008FB007 /* RasterizerStateDescription.hpp */; }; + 84EB0DDD2EE2D4B4008FB007 /* ShaderStage.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CE22EE2D4B3008FB007 /* ShaderStage.hpp */; }; + 84EB0DDE2EE2D4B4008FB007 /* StencilFaceDescription.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CE32EE2D4B3008FB007 /* StencilFaceDescription.cpp */; }; + 84EB0DDF2EE2D4B4008FB007 /* StencilFaceDescription.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CE42EE2D4B3008FB007 /* StencilFaceDescription.hpp */; }; + 84EB0DE02EE2D4B4008FB007 /* TextureDescription.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CE52EE2D4B3008FB007 /* TextureDescription.cpp */; }; + 84EB0DE12EE2D4B4008FB007 /* TextureDescription.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CE62EE2D4B3008FB007 /* TextureDescription.hpp */; }; + 84EB0DE22EE2D4B4008FB007 /* MaterialPtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CE72EE2D4B3008FB007 /* MaterialPtr.cpp */; }; + 84EB0DE32EE2D4B4008FB007 /* MaterialPtr.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CE82EE2D4B3008FB007 /* MaterialPtr.hpp */; }; + 84EB0DE42EE2D4B4008FB007 /* MatrixStack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CE92EE2D4B3008FB007 /* MatrixStack.cpp */; }; + 84EB0DE52EE2D4B4008FB007 /* MatrixStack.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CEA2EE2D4B3008FB007 /* MatrixStack.hpp */; }; + 84EB0DE62EE2D4B4008FB007 /* Mesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CEB2EE2D4B3008FB007 /* Mesh.cpp */; }; + 84EB0DE72EE2D4B4008FB007 /* Mesh.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CEC2EE2D4B3008FB007 /* Mesh.hpp */; }; + 84EB0DE82EE2D4B4008FB007 /* PerFrameConstants.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CED2EE2D4B3008FB007 /* PerFrameConstants.cpp */; }; + 84EB0DE92EE2D4B4008FB007 /* PerFrameConstants.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CEE2EE2D4B3008FB007 /* PerFrameConstants.hpp */; }; + 84EB0DEA2EE2D4B4008FB007 /* Extensions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CF12EE2D4B3008FB007 /* Extensions.cpp */; }; + 84EB0DEB2EE2D4B4008FB007 /* Extensions.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CF22EE2D4B3008FB007 /* Extensions.hpp */; }; + 84EB0DEC2EE2D4B4008FB007 /* ShaderPrecision.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CF32EE2D4B3008FB007 /* ShaderPrecision.cpp */; }; + 84EB0DED2EE2D4B4008FB007 /* ShaderPrecision.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CF42EE2D4B3008FB007 /* ShaderPrecision.hpp */; }; + 84EB0DEE2EE2D4B4008FB007 /* PlatformDefinitions.h in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CF52EE2D4B3008FB007 /* PlatformDefinitions.h */; }; + 84EB0DEF2EE2D4B4008FB007 /* QuadIndexBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CF62EE2D4B3008FB007 /* QuadIndexBuffer.cpp */; }; + 84EB0DF02EE2D4B4008FB007 /* QuadIndexBuffer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CF72EE2D4B3008FB007 /* QuadIndexBuffer.hpp */; }; + 84EB0DF12EE2D4B4008FB007 /* RenderChunkConstants.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CF82EE2D4B3008FB007 /* RenderChunkConstants.cpp */; }; + 84EB0DF22EE2D4B4008FB007 /* RenderChunkConstants.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CF92EE2D4B3008FB007 /* RenderChunkConstants.hpp */; }; + 84EB0DF32EE2D4B4008FB007 /* RenderContextImmediate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CFA2EE2D4B3008FB007 /* RenderContextImmediate.cpp */; }; + 84EB0DF42EE2D4B4008FB007 /* RenderContextImmediate.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CFB2EE2D4B3008FB007 /* RenderContextImmediate.hpp */; }; + 84EB0DF52EE2D4B4008FB007 /* RenderMaterial.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CFC2EE2D4B3008FB007 /* RenderMaterial.cpp */; }; + 84EB0DF62EE2D4B4008FB007 /* RenderMaterial.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CFD2EE2D4B3008FB007 /* RenderMaterial.hpp */; }; + 84EB0DF72EE2D4B4008FB007 /* ShaderConstants.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0CFE2EE2D4B3008FB007 /* ShaderConstants.cpp */; }; + 84EB0DF82EE2D4B4008FB007 /* ShaderConstants.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0CFF2EE2D4B3008FB007 /* ShaderConstants.hpp */; }; + 84EB0DF92EE2D4B4008FB007 /* ShaderGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0D002EE2D4B3008FB007 /* ShaderGroup.cpp */; }; + 84EB0DFA2EE2D4B4008FB007 /* ShaderGroup.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0D012EE2D4B3008FB007 /* ShaderGroup.hpp */; }; + 84EB0DFB2EE2D4B4008FB007 /* ShaderGroupBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0D022EE2D4B3008FB007 /* ShaderGroupBase.cpp */; }; + 84EB0DFC2EE2D4B4008FB007 /* ShaderGroupBase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0D032EE2D4B3008FB007 /* ShaderGroupBase.hpp */; }; + 84EB0DFD2EE2D4B4008FB007 /* StencilRefObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0D042EE2D4B3008FB007 /* StencilRefObject.cpp */; }; + 84EB0DFE2EE2D4B4008FB007 /* StencilRefObject.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0D052EE2D4B3008FB007 /* StencilRefObject.hpp */; }; + 84EB0DFF2EE2D4B4008FB007 /* TextureGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0D062EE2D4B3008FB007 /* TextureGroup.cpp */; }; + 84EB0E002EE2D4B4008FB007 /* TextureGroup.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0D072EE2D4B3008FB007 /* TextureGroup.hpp */; }; + 84EB0E012EE2D4B4008FB007 /* TexturePtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0D082EE2D4B3008FB007 /* TexturePtr.cpp */; }; + 84EB0E022EE2D4B4008FB007 /* TexturePtr.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0D092EE2D4B3008FB007 /* TexturePtr.hpp */; }; + 84EB0E032EE2D4B4008FB007 /* UniformMetaData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0D0A2EE2D4B3008FB007 /* UniformMetaData.cpp */; }; + 84EB0E042EE2D4B4008FB007 /* UniformMetaData.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0D0B2EE2D4B3008FB007 /* UniformMetaData.hpp */; }; + 84EB0E052EE2D4B4008FB007 /* VertexFormat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0D0C2EE2D4B3008FB007 /* VertexFormat.cpp */; }; + 84EB0E062EE2D4B4008FB007 /* VertexFormat.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0D0D2EE2D4B3008FB007 /* VertexFormat.hpp */; }; + 84EB0E072EE2D4B4008FB007 /* WeatherConstants.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0D0E2EE2D4B3008FB007 /* WeatherConstants.cpp */; }; + 84EB0E082EE2D4B4008FB007 /* WeatherConstants.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0D0F2EE2D4B3008FB007 /* WeatherConstants.hpp */; }; + 84EB0E092EE2D4B4008FB007 /* WorldConstants.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0D102EE2D4B3008FB007 /* WorldConstants.cpp */; }; + 84EB0E0A2EE2D4B4008FB007 /* WorldConstants.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0D112EE2D4B3008FB007 /* WorldConstants.hpp */; }; + 84EB0E0B2EE2D4CA008FB007 /* Color.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB09FD2EE2CCC0008FB007 /* Color.cpp */; }; + 84EB0E0C2EE2D4CA008FB007 /* Color.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB09FE2EE2CCC0008FB007 /* Color.hpp */; }; + 84EB0E0D2EE2D4D4008FB007 /* AlignmentHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0A002EE2CCC0008FB007 /* AlignmentHelper.cpp */; }; + 84EB0E0E2EE2D4D4008FB007 /* AlignmentHelper.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0A012EE2CCC0008FB007 /* AlignmentHelper.hpp */; }; + 84EB0E0F2EE2D4D4008FB007 /* InheritanceTree.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0A022EE2CCC0008FB007 /* InheritanceTree.hpp */; }; + 84EB0E102EE2D4D4008FB007 /* JsonParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0A032EE2CCC0008FB007 /* JsonParser.cpp */; }; + 84EB0E112EE2D4D4008FB007 /* JsonParser.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0A042EE2CCC0008FB007 /* JsonParser.hpp */; }; + 84EB0E122EE2D4D4008FB007 /* Singleton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EB0A052EE2CCC0008FB007 /* Singleton.cpp */; }; + 84EB0E132EE2D4D4008FB007 /* Singleton.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EB0A062EE2CCC0008FB007 /* Singleton.hpp */; }; 84EE51312E8DCC9000D3DCA2 /* DataLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84EE512F2E8DCC9000D3DCA2 /* DataLayer.cpp */; }; 84EE51322E8DCC9000D3DCA2 /* DataLayer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EE51302E8DCC9000D3DCA2 /* DataLayer.hpp */; }; 84EE51342E8DCD4900D3DCA2 /* TileChange.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84EE51332E8DCD4900D3DCA2 /* TileChange.hpp */; }; @@ -1528,13 +1331,6 @@ remoteGlobalIDString = 84498A762AF18C7A005EF5A5; remoteInfo = ZLib; }; - 84AAF6462AF18C0600BD67F4 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 8489B08F2A86D4B2004CA8EC /* Project object */; - proxyType = 1; - remoteGlobalIDString = 84AAF5972AF18B9500BD67F4; - remoteInfo = OpenGL; - }; 84B8AF832AF18A25008DE93D /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 8489B08F2A86D4B2004CA8EC /* Project object */; @@ -1693,14 +1489,6 @@ 840DD5BA2AC810620006A435 /* SelectWorldScreen.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SelectWorldScreen.hpp; sourceTree = ""; }; 840DD5BB2AC810620006A435 /* StartMenuScreen.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StartMenuScreen.cpp; sourceTree = ""; }; 840DD5BC2AC810620006A435 /* StartMenuScreen.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StartMenuScreen.hpp; sourceTree = ""; }; - 840DD5BE2AC810620006A435 /* Cube.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Cube.cpp; sourceTree = ""; }; - 840DD5BF2AC810620006A435 /* Cube.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Cube.hpp; sourceTree = ""; }; - 840DD5C02AC810620006A435 /* HumanoidModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HumanoidModel.cpp; sourceTree = ""; }; - 840DD5C12AC810620006A435 /* HumanoidModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = HumanoidModel.hpp; sourceTree = ""; }; - 840DD5C22AC810620006A435 /* Model.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Model.cpp; sourceTree = ""; }; - 840DD5C32AC810620006A435 /* Model.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Model.hpp; sourceTree = ""; }; - 840DD5C42AC810620006A435 /* PolygonQuad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolygonQuad.cpp; sourceTree = ""; }; - 840DD5C52AC810620006A435 /* PolygonQuad.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PolygonQuad.hpp; sourceTree = ""; }; 840DD5C72AC810620006A435 /* ClientSideNetworkHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClientSideNetworkHandler.cpp; sourceTree = ""; }; 840DD5C82AC810620006A435 /* ClientSideNetworkHandler.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ClientSideNetworkHandler.hpp; sourceTree = ""; }; 840DD5CA2AC810620006A435 /* Options.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Options.cpp; sourceTree = ""; }; @@ -1733,8 +1521,6 @@ 840DD6272AC810620006A435 /* CThread.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CThread.hpp; sourceTree = ""; }; 840DD6282AC810620006A435 /* Logger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Logger.cpp; sourceTree = ""; }; 840DD6292AC810620006A435 /* Logger.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Logger.hpp; sourceTree = ""; }; - 840DD62B2AC810620006A435 /* Matrix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Matrix.cpp; sourceTree = ""; }; - 840DD62C2AC810620006A435 /* Matrix.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Matrix.hpp; sourceTree = ""; }; 840DD62D2AC810620006A435 /* Mth.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Mth.cpp; sourceTree = ""; }; 840DD62E2AC810620006A435 /* Mth.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Mth.hpp; sourceTree = ""; }; 840DD62F2AC810620006A435 /* Random.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Random.cpp; sourceTree = ""; }; @@ -1969,7 +1755,6 @@ 840DD72C2AC810620006A435 /* WireTile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WireTile.cpp; sourceTree = ""; }; 840DD72D2AC810620006A435 /* WireTile.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = WireTile.hpp; sourceTree = ""; }; 840DD7322AC810620006A435 /* GL.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = GL.hpp; sourceTree = ""; }; - 840DD7332AC810620006A435 /* GLExt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GLExt.cpp; sourceTree = ""; }; 840DD7342AC810620006A435 /* glext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glext.h; sourceTree = ""; }; 840DD7352AC810620006A435 /* readme.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = readme.txt; sourceTree = ""; }; 840DD73A2AC810620006A435 /* _FindFirst.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = _FindFirst.cpp; sourceTree = ""; }; @@ -2320,7 +2105,6 @@ 8470AF3B2BE9B6FA00BCA54E /* FireworkParticle.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FireworkParticle.hpp; sourceTree = ""; }; 8470AF3E2BE9B80900BCA54E /* DisconnectionScreen.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DisconnectionScreen.cpp; sourceTree = ""; }; 8470AF3F2BE9B80900BCA54E /* DisconnectionScreen.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DisconnectionScreen.hpp; sourceTree = ""; }; - 8470AF432BE9B8B600BCA54E /* clouds.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = clouds.png; sourceTree = ""; }; 8470AF452BE9BC8500BCA54E /* GameMods.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = GameMods.hpp; path = ../../../../GameMods.hpp; sourceTree = ""; }; 8477B39C2C4DC374004E1AC5 /* ControllerBuildInput.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ControllerBuildInput.cpp; sourceTree = ""; }; 8477B39D2C4DC374004E1AC5 /* ControllerBuildInput.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ControllerBuildInput.hpp; sourceTree = ""; }; @@ -2338,76 +2122,6 @@ 8477B3B22C4DC414004E1AC5 /* EmptyLevelChunk.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = EmptyLevelChunk.hpp; sourceTree = ""; }; 8477B3B82C4DC42E004E1AC5 /* Vec2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Vec2.cpp; sourceTree = ""; }; 8477B3B92C4DC42E004E1AC5 /* Vec2.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Vec2.hpp; sourceTree = ""; }; - 8477B3BE2C4DE77F004E1AC5 /* bg128.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = bg128.png; sourceTree = ""; }; - 8477B3BF2C4DE77F004E1AC5 /* bg64.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = bg64.png; sourceTree = ""; }; - 8477B3C12C4DE77F004E1AC5 /* cancel_0.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = cancel_0.png; sourceTree = ""; }; - 8477B3C22C4DE77F004E1AC5 /* cancel_0_1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = cancel_0_1.png; sourceTree = ""; }; - 8477B3C32C4DE77F004E1AC5 /* cancel_0_3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = cancel_0_3.png; sourceTree = ""; }; - 8477B3C42C4DE77F004E1AC5 /* cancel_1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = cancel_1.png; sourceTree = ""; }; - 8477B3C52C4DE77F004E1AC5 /* cancel_1_1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = cancel_1_1.png; sourceTree = ""; }; - 8477B3C62C4DE77F004E1AC5 /* cancel_1_3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = cancel_1_3.png; sourceTree = ""; }; - 8477B3C72C4DE77F004E1AC5 /* create_0.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = create_0.png; sourceTree = ""; }; - 8477B3C82C4DE77F004E1AC5 /* create_0_1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = create_0_1.png; sourceTree = ""; }; - 8477B3C92C4DE77F004E1AC5 /* create_0_3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = create_0_3.png; sourceTree = ""; }; - 8477B3CA2C4DE77F004E1AC5 /* create_1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = create_1.png; sourceTree = ""; }; - 8477B3CB2C4DE77F004E1AC5 /* create_1_1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = create_1_1.png; sourceTree = ""; }; - 8477B3CC2C4DE77F004E1AC5 /* create_1_3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = create_1_3.png; sourceTree = ""; }; - 8477B3CE2C4DE77F004E1AC5 /* cancel_0_4.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = cancel_0_4.png; sourceTree = ""; }; - 8477B3CF2C4DE77F004E1AC5 /* cancel_1_4.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = cancel_1_4.png; sourceTree = ""; }; - 8477B3D02C4DE77F004E1AC5 /* create_0_4.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = create_0_4.png; sourceTree = ""; }; - 8477B3D12C4DE77F004E1AC5 /* create_1_4.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = create_1_4.png; sourceTree = ""; }; - 8477B3D22C4DE77F004E1AC5 /* creative_0_4.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = creative_0_4.png; sourceTree = ""; }; - 8477B3D32C4DE77F004E1AC5 /* creative_1_4.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = creative_1_4.png; sourceTree = ""; }; - 8477B3D42C4DE77F004E1AC5 /* creative_3_4.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = creative_3_4.png; sourceTree = ""; }; - 8477B3D52C4DE77F004E1AC5 /* survival_0_4.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = survival_0_4.png; sourceTree = ""; }; - 8477B3D62C4DE77F004E1AC5 /* survival_1_4.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = survival_1_4.png; sourceTree = ""; }; - 8477B3D72C4DE77F004E1AC5 /* survival_3_4.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = survival_3_4.png; sourceTree = ""; }; - 8477B3D82C4DE77F004E1AC5 /* worldname_ipad_4.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = worldname_ipad_4.png; sourceTree = ""; }; - 8477B3D92C4DE77F004E1AC5 /* save_0.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = save_0.png; sourceTree = ""; }; - 8477B3DA2C4DE77F004E1AC5 /* save_0_3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = save_0_3.png; sourceTree = ""; }; - 8477B3DB2C4DE77F004E1AC5 /* save_1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = save_1.png; sourceTree = ""; }; - 8477B3DC2C4DE77F004E1AC5 /* save_1_3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = save_1_3.png; sourceTree = ""; }; - 8477B3DD2C4DE77F004E1AC5 /* worldname_ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = worldname_ipad.png; sourceTree = ""; }; - 8477B3DE2C4DE77F004E1AC5 /* worldname_ipad_3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = worldname_ipad_3.png; sourceTree = ""; }; - 8477B3DF2C4DE77F004E1AC5 /* worldname_iphone.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = worldname_iphone.png; sourceTree = ""; }; - 8477B3E02C4DE77F004E1AC5 /* worldname_iphone_3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = worldname_iphone_3.png; sourceTree = ""; }; - 8477B3E22C4DE77F004E1AC5 /* cancel_0_1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = cancel_0_1.png; sourceTree = ""; }; - 8477B3E32C4DE77F004E1AC5 /* cancel_0_3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = cancel_0_3.png; sourceTree = ""; }; - 8477B3E42C4DE77F004E1AC5 /* cancel_1_1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = cancel_1_1.png; sourceTree = ""; }; - 8477B3E52C4DE77F004E1AC5 /* cancel_1_3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = cancel_1_3.png; sourceTree = ""; }; - 8477B3E62C4DE77F004E1AC5 /* create_0_1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = create_0_1.png; sourceTree = ""; }; - 8477B3E72C4DE77F004E1AC5 /* create_0_3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = create_0_3.png; sourceTree = ""; }; - 8477B3E82C4DE77F004E1AC5 /* create_1_1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = create_1_1.png; sourceTree = ""; }; - 8477B3E92C4DE77F004E1AC5 /* create_1_3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = create_1_3.png; sourceTree = ""; }; - 8477B3EA2C4DE77F004E1AC5 /* creative_0_3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = creative_0_3.png; sourceTree = ""; }; - 8477B3EB2C4DE77F004E1AC5 /* creative_1_3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = creative_1_3.png; sourceTree = ""; }; - 8477B3EC2C4DE77F004E1AC5 /* survival_0_3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = survival_0_3.png; sourceTree = ""; }; - 8477B3ED2C4DE77F004E1AC5 /* survival_1_3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = survival_1_3.png; sourceTree = ""; }; - 8477B3EE2C4DE77F004E1AC5 /* worldname.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = worldname.png; sourceTree = ""; }; - 8477B3EF2C4DE77F004E1AC5 /* worldname_3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = worldname_3.png; sourceTree = ""; }; - 8477B3F02C4DE77F004E1AC5 /* worldname_ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = worldname_ipad.png; sourceTree = ""; }; - 8477B3F12C4DE77F004E1AC5 /* worldname_ipad_3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = worldname_ipad_3.png; sourceTree = ""; }; - 8477B3F22C4DE77F004E1AC5 /* worldname_iphone.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = worldname_iphone.png; sourceTree = ""; }; - 8477B3F32C4DE77F004E1AC5 /* worldname_iphone5_3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = worldname_iphone5_3.png; sourceTree = ""; }; - 8477B3F42C4DE77F004E1AC5 /* worldname_iphone_3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = worldname_iphone_3.png; sourceTree = ""; }; - 8477B3F62C4DE77F004E1AC5 /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72.png"; sourceTree = ""; }; - 8477B3F72C4DE77F004E1AC5 /* Icon-72_lite.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72_lite.png"; sourceTree = ""; }; - 8477B3F82C4DE77F004E1AC5 /* Icon-Small-50.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-Small-50.png"; sourceTree = ""; }; - 8477B3F92C4DE77F004E1AC5 /* Icon-Small-50_lite.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-Small-50_lite.png"; sourceTree = ""; }; - 8477B3FA2C4DE77F004E1AC5 /* Icon-Small.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-Small.png"; sourceTree = ""; }; - 8477B3FB2C4DE77F004E1AC5 /* Icon-Small@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-Small@2x.png"; sourceTree = ""; }; - 8477B3FC2C4DE77F004E1AC5 /* Icon-Small@2x_lite.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-Small@2x_lite.png"; sourceTree = ""; }; - 8477B3FD2C4DE77F004E1AC5 /* Icon-Small_lite.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-Small_lite.png"; sourceTree = ""; }; - 8477B3FE2C4DE77F004E1AC5 /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = ""; }; - 8477B3FF2C4DE77F004E1AC5 /* Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon@2x.png"; sourceTree = ""; }; - 8477B4002C4DE77F004E1AC5 /* Icon@2x_lite.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon@2x_lite.png"; sourceTree = ""; }; - 8477B4012C4DE77F004E1AC5 /* Icon_lite.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon_lite.png; sourceTree = ""; }; - 8477B4022C4DE77F004E1AC5 /* mcpe_ios_icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = mcpe_ios_icon.png; sourceTree = ""; }; - 8477B4032C4DE77F004E1AC5 /* mcpe_lite_ios_icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = mcpe_lite_ios_icon.png; sourceTree = ""; }; - 8477B4052C4DE77F004E1AC5 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; - 8477B4062C4DE77F004E1AC5 /* Default-Landscape~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-Landscape~ipad.png"; sourceTree = ""; }; - 8477B4072C4DE77F004E1AC5 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; - 8477B4082C4DE77F004E1AC5 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; 8484ABDC2B32935700076873 /* PlatformDefinitions_iOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformDefinitions_iOS.h; sourceTree = ""; }; 8488C0882B1EDD4F001AEC4F /* ShowKeyboardView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShowKeyboardView.h; sourceTree = ""; }; 8488C0892B1EDD4F001AEC4F /* ShowKeyboardView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ShowKeyboardView.mm; sourceTree = ""; }; @@ -2427,13 +2141,11 @@ 849259612AD8FDD10081F5B9 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 849259632AD8FDD90081F5B9 /* minecraftpe-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "minecraftpe-Info.plist"; sourceTree = ""; }; 849259722AD912890081F5B9 /* AppContext.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AppContext.hpp; sourceTree = ""; }; - 849488252C92844C006DB706 /* foliagecolor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = foliagecolor.png; sourceTree = ""; }; - 849488262C92844C006DB706 /* grasscolor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = grasscolor.png; sourceTree = ""; }; - 849488272C92844C006DB706 /* pumpkinblur.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pumpkinblur.png; sourceTree = ""; }; - 849488282C92844C006DB706 /* shadow.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = shadow.png; sourceTree = ""; }; - 849488292C92844C006DB706 /* vignette.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = vignette.png; sourceTree = ""; }; - 849488302C928459006DB706 /* moon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = moon.png; sourceTree = ""; }; - 849488312C928459006DB706 /* sun.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = sun.png; sourceTree = ""; }; + 849371352EE51E6700081C5A /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "../../game/assets/app/launch/Default-568h@2x.png"; sourceTree = ""; }; + 849371362EE51E6700081C5A /* Default-Landscape~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-Landscape~ipad.png"; path = "../../game/assets/app/launch/Default-Landscape~ipad.png"; sourceTree = ""; }; + 849371372EE51E6700081C5A /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Default.png; path = ../../game/assets/app/launch/Default.png; sourceTree = ""; }; + 849371382EE51E6700081C5A /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default@2x.png"; path = "../../game/assets/app/launch/Default@2x.png"; sourceTree = ""; }; + 8493713D2EE51F2A00081C5A /* icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = icon.png; path = ../../game/assets/icon.png; sourceTree = ""; }; 849488342C9284DA006DB706 /* Lighting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Lighting.cpp; sourceTree = ""; }; 849488352C9284DA006DB706 /* Lighting.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Lighting.hpp; sourceTree = ""; }; 8495E4872AF0905B00A06901 /* AppPlatform_iOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppPlatform_iOS.h; sourceTree = ""; }; @@ -2544,29 +2256,6 @@ 84AA8BE82B32F3F3003F5B82 /* VertexPT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = VertexPT.hpp; sourceTree = ""; }; 84AA8BE92B32F3F3003F5B82 /* WaterSideTexture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WaterSideTexture.cpp; sourceTree = ""; }; 84AA8BEA2B32F3F3003F5B82 /* WaterTexture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WaterTexture.cpp; sourceTree = ""; }; - 84AA8C3C2B32F535003F5B82 /* ChickenModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ChickenModel.cpp; sourceTree = ""; }; - 84AA8C3D2B32F535003F5B82 /* ChickenModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ChickenModel.hpp; sourceTree = ""; }; - 84AA8C3E2B32F535003F5B82 /* CowModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CowModel.cpp; sourceTree = ""; }; - 84AA8C3F2B32F535003F5B82 /* CowModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CowModel.hpp; sourceTree = ""; }; - 84AA8C402B32F535003F5B82 /* CreeperModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CreeperModel.cpp; sourceTree = ""; }; - 84AA8C412B32F535003F5B82 /* CreeperModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CreeperModel.hpp; sourceTree = ""; }; - 84AA8C482B32F535003F5B82 /* ModelPart.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ModelPart.cpp; sourceTree = ""; }; - 84AA8C492B32F535003F5B82 /* ModelPart.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ModelPart.hpp; sourceTree = ""; }; - 84AA8C4A2B32F535003F5B82 /* PigModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PigModel.cpp; sourceTree = ""; }; - 84AA8C4B2B32F535003F5B82 /* PigModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PigModel.hpp; sourceTree = ""; }; - 84AA8C4E2B32F535003F5B82 /* QuadrupedModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = QuadrupedModel.cpp; sourceTree = ""; }; - 84AA8C4F2B32F535003F5B82 /* QuadrupedModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = QuadrupedModel.hpp; sourceTree = ""; }; - 84AA8C502B32F535003F5B82 /* SheepFurModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SheepFurModel.cpp; sourceTree = ""; }; - 84AA8C512B32F535003F5B82 /* SheepFurModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SheepFurModel.hpp; sourceTree = ""; }; - 84AA8C522B32F535003F5B82 /* SheepModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SheepModel.cpp; sourceTree = ""; }; - 84AA8C532B32F535003F5B82 /* SheepModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SheepModel.hpp; sourceTree = ""; }; - 84AA8C542B32F535003F5B82 /* SkeletonModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SkeletonModel.cpp; sourceTree = ""; }; - 84AA8C552B32F535003F5B82 /* SkeletonModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SkeletonModel.hpp; sourceTree = ""; }; - 84AA8C562B32F535003F5B82 /* SpiderModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpiderModel.cpp; sourceTree = ""; }; - 84AA8C572B32F535003F5B82 /* SpiderModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SpiderModel.hpp; sourceTree = ""; }; - 84AA8C582B32F535003F5B82 /* ZombieModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ZombieModel.cpp; sourceTree = ""; }; - 84AA8C592B32F535003F5B82 /* ZombieModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ZombieModel.hpp; sourceTree = ""; }; - 84AA8C782B32F578003F5B82 /* gui_custom.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = gui_custom.png; sourceTree = ""; }; 84AA8CB72B32FB32003F5B82 /* stb_c_lexer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stb_c_lexer.h; sourceTree = ""; }; 84AA8CB82B32FB32003F5B82 /* stb_connected_components.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stb_connected_components.h; sourceTree = ""; }; 84AA8CB92B32FB32003F5B82 /* stb_divide.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stb_divide.h; sourceTree = ""; }; @@ -2589,8 +2278,6 @@ 84AA8CD02B32FB32003F5B82 /* stb_vorbis.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = stb_vorbis.c; sourceTree = ""; }; 84AA8CD12B32FB32003F5B82 /* stb_voxel_render.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stb_voxel_render.h; sourceTree = ""; }; 84AA8E462B32FB33003F5B82 /* stb_image_impl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = stb_image_impl.c; sourceTree = ""; }; - 84AAF6422AF18B9500BD67F4 /* libOpenGL.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libOpenGL.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 84AD710C2AF20B6A00DA73F9 /* readme.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = readme.txt; sourceTree = ""; }; 84B1E02D2E04FD4500ED000A /* ArrowRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ArrowRenderer.cpp; sourceTree = ""; }; 84B1E02E2E04FD4500ED000A /* ArrowRenderer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ArrowRenderer.hpp; sourceTree = ""; }; 84B1E0312E04FD7900ED000A /* Arrow.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Arrow.cpp; sourceTree = ""; }; @@ -2601,341 +2288,10 @@ 84B1E0362E04FD7900ED000A /* Spider.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Spider.hpp; sourceTree = ""; }; 84B1E0372E04FD7900ED000A /* Zombie.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Zombie.cpp; sourceTree = ""; }; 84B1E0382E04FD7900ED000A /* Zombie.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Zombie.hpp; sourceTree = ""; }; - 84B1E0412E050D2500ED000A /* chicken.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = chicken.png; sourceTree = ""; }; - 84B1E0422E050D2500ED000A /* cow.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = cow.png; sourceTree = ""; }; - 84B1E0432E050D2500ED000A /* creeper.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = creeper.png; sourceTree = ""; }; - 84B1E0442E050D2500ED000A /* ghast_fire.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ghast_fire.png; sourceTree = ""; }; - 84B1E0452E050D2500ED000A /* ghast.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ghast.png; sourceTree = ""; }; - 84B1E0462E050D2500ED000A /* pig.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pig.png; sourceTree = ""; }; - 84B1E0472E050D2500ED000A /* pigman.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pigman.png; sourceTree = ""; }; - 84B1E0482E050D2500ED000A /* pigzombie.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pigzombie.png; sourceTree = ""; }; - 84B1E0492E050D2500ED000A /* saddle.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = saddle.png; sourceTree = ""; }; - 84B1E04A2E050D2500ED000A /* sheep_fur.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = sheep_fur.png; sourceTree = ""; }; - 84B1E04B2E050D2500ED000A /* sheep.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = sheep.png; sourceTree = ""; }; - 84B1E04C2E050D2500ED000A /* skeleton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = skeleton.png; sourceTree = ""; }; - 84B1E04D2E050D2500ED000A /* slime.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = slime.png; sourceTree = ""; }; - 84B1E04E2E050D2500ED000A /* spider_eyes.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = spider_eyes.png; sourceTree = ""; }; - 84B1E04F2E050D2500ED000A /* spider.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = spider.png; sourceTree = ""; }; - 84B1E0502E050D2500ED000A /* squid.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = squid.png; sourceTree = ""; }; - 84B1E0512E050D2500ED000A /* zombie.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = zombie.png; sourceTree = ""; }; - 84B1E06F2E051B7C00ED000A /* calm1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = calm1.ogg; sourceTree = ""; }; - 84B1E0702E051B7C00ED000A /* calm2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = calm2.ogg; sourceTree = ""; }; - 84B1E0712E051B7C00ED000A /* calm3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = calm3.ogg; sourceTree = ""; }; - 84B1E0732E051B7C00ED000A /* hal1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hal1.ogg; sourceTree = ""; }; - 84B1E0742E051B7C00ED000A /* hal2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hal2.ogg; sourceTree = ""; }; - 84B1E0752E051B7C00ED000A /* hal3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hal3.ogg; sourceTree = ""; }; - 84B1E0762E051B7C00ED000A /* hal4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hal4.ogg; sourceTree = ""; }; - 84B1E0772E051B7C00ED000A /* nuance1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = nuance1.ogg; sourceTree = ""; }; - 84B1E0782E051B7C00ED000A /* nuance2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = nuance2.ogg; sourceTree = ""; }; - 84B1E0792E051B7C00ED000A /* piano1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = piano1.ogg; sourceTree = ""; }; - 84B1E07A2E051B7C00ED000A /* piano2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = piano2.ogg; sourceTree = ""; }; - 84B1E07B2E051B7C00ED000A /* piano3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = piano3.ogg; sourceTree = ""; }; - 84B1E07F2E051B7C00ED000A /* cave1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cave1.ogg; sourceTree = ""; }; - 84B1E0802E051B7C00ED000A /* cave10.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cave10.ogg; sourceTree = ""; }; - 84B1E0812E051B7C00ED000A /* cave11.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cave11.ogg; sourceTree = ""; }; - 84B1E0822E051B7C00ED000A /* cave12.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cave12.ogg; sourceTree = ""; }; - 84B1E0832E051B7C00ED000A /* cave13.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cave13.ogg; sourceTree = ""; }; - 84B1E0842E051B7C00ED000A /* cave2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cave2.ogg; sourceTree = ""; }; - 84B1E0852E051B7C00ED000A /* cave3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cave3.ogg; sourceTree = ""; }; - 84B1E0862E051B7C00ED000A /* cave4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cave4.ogg; sourceTree = ""; }; - 84B1E0872E051B7C00ED000A /* cave5.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cave5.ogg; sourceTree = ""; }; - 84B1E0882E051B7C00ED000A /* cave6.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cave6.ogg; sourceTree = ""; }; - 84B1E0892E051B7C00ED000A /* cave7.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cave7.ogg; sourceTree = ""; }; - 84B1E08A2E051B7C00ED000A /* cave8.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cave8.ogg; sourceTree = ""; }; - 84B1E08B2E051B7C00ED000A /* cave9.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cave9.ogg; sourceTree = ""; }; - 84B1E08D2E051B7C00ED000A /* rain1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = rain1.ogg; sourceTree = ""; }; - 84B1E08E2E051B7C00ED000A /* rain2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = rain2.ogg; sourceTree = ""; }; - 84B1E08F2E051B7C00ED000A /* rain3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = rain3.ogg; sourceTree = ""; }; - 84B1E0902E051B7C00ED000A /* rain4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = rain4.ogg; sourceTree = ""; }; - 84B1E0912E051B7C00ED000A /* thunder1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = thunder1.ogg; sourceTree = ""; }; - 84B1E0922E051B7C00ED000A /* thunder2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = thunder2.ogg; sourceTree = ""; }; - 84B1E0932E051B7C00ED000A /* thunder3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = thunder3.ogg; sourceTree = ""; }; - 84B1E0952E051B7C00ED000A /* fallbig1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = fallbig1.ogg; sourceTree = ""; }; - 84B1E0962E051B7C00ED000A /* fallbig2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = fallbig2.ogg; sourceTree = ""; }; - 84B1E0972E051B7C00ED000A /* fallsmall.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = fallsmall.ogg; sourceTree = ""; }; - 84B1E0982E051B7C00ED000A /* hurtflesh1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hurtflesh1.ogg; sourceTree = ""; }; - 84B1E0992E051B7C00ED000A /* hurtflesh2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hurtflesh2.ogg; sourceTree = ""; }; - 84B1E09A2E051B7C00ED000A /* hurtflesh3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hurtflesh3.ogg; sourceTree = ""; }; - 84B1E09C2E051B7C00ED000A /* fire.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = fire.ogg; sourceTree = ""; }; - 84B1E09D2E051B7C00ED000A /* ignite.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = ignite.ogg; sourceTree = ""; }; - 84B1E09F2E051B7C00ED000A /* lava.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = lava.ogg; sourceTree = ""; }; - 84B1E0A02E051B7C00ED000A /* lavapop.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = lavapop.ogg; sourceTree = ""; }; - 84B1E0A12E051B7C00ED000A /* splash.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = splash.ogg; sourceTree = ""; }; - 84B1E0A22E051B7C00ED000A /* water.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = water.ogg; sourceTree = ""; }; - 84B1E0A52E051B7C00ED000A /* breathe1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = breathe1.ogg; sourceTree = ""; }; - 84B1E0A62E051B7C00ED000A /* breathe2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = breathe2.ogg; sourceTree = ""; }; - 84B1E0A72E051B7C00ED000A /* breathe3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = breathe3.ogg; sourceTree = ""; }; - 84B1E0A82E051B7C00ED000A /* breathe4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = breathe4.ogg; sourceTree = ""; }; - 84B1E0A92E051B7C00ED000A /* death.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = death.ogg; sourceTree = ""; }; - 84B1E0AA2E051B7C00ED000A /* hit1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit1.ogg; sourceTree = ""; }; - 84B1E0AB2E051B7C00ED000A /* hit2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit2.ogg; sourceTree = ""; }; - 84B1E0AC2E051B7C00ED000A /* hit3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit3.ogg; sourceTree = ""; }; - 84B1E0AD2E051B7C00ED000A /* hit4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit4.ogg; sourceTree = ""; }; - 84B1E0AF2E051B7C00ED000A /* hiss1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hiss1.ogg; sourceTree = ""; }; - 84B1E0B02E051B7C00ED000A /* hiss2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hiss2.ogg; sourceTree = ""; }; - 84B1E0B12E051B7C00ED000A /* hiss3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hiss3.ogg; sourceTree = ""; }; - 84B1E0B22E051B7C00ED000A /* hitt1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hitt1.ogg; sourceTree = ""; }; - 84B1E0B32E051B7C00ED000A /* hitt2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hitt2.ogg; sourceTree = ""; }; - 84B1E0B42E051B7C00ED000A /* hitt3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hitt3.ogg; sourceTree = ""; }; - 84B1E0B52E051B7C00ED000A /* meow1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = meow1.ogg; sourceTree = ""; }; - 84B1E0B62E051B7C00ED000A /* meow2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = meow2.ogg; sourceTree = ""; }; - 84B1E0B72E051B7C00ED000A /* meow3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = meow3.ogg; sourceTree = ""; }; - 84B1E0B82E051B7C00ED000A /* meow4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = meow4.ogg; sourceTree = ""; }; - 84B1E0B92E051B7C00ED000A /* purr1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = purr1.ogg; sourceTree = ""; }; - 84B1E0BA2E051B7C00ED000A /* purr2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = purr2.ogg; sourceTree = ""; }; - 84B1E0BB2E051B7C00ED000A /* purr3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = purr3.ogg; sourceTree = ""; }; - 84B1E0BC2E051B7C00ED000A /* purreow1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = purreow1.ogg; sourceTree = ""; }; - 84B1E0BD2E051B7C00ED000A /* purreow2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = purreow2.ogg; sourceTree = ""; }; - 84B1E0BE2E051B7C00ED000A /* chicken1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = chicken1.ogg; sourceTree = ""; }; - 84B1E0BF2E051B7C00ED000A /* chicken2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = chicken2.ogg; sourceTree = ""; }; - 84B1E0C02E051B7C00ED000A /* chicken3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = chicken3.ogg; sourceTree = ""; }; - 84B1E0C12E051B7C00ED000A /* chickenhurt1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = chickenhurt1.ogg; sourceTree = ""; }; - 84B1E0C22E051B7C00ED000A /* chickenhurt2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = chickenhurt2.ogg; sourceTree = ""; }; - 84B1E0C32E051B7C00ED000A /* chickenplop.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = chickenplop.ogg; sourceTree = ""; }; - 84B1E0C42E051B7C00ED000A /* cow1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cow1.ogg; sourceTree = ""; }; - 84B1E0C52E051B7C00ED000A /* cow2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cow2.ogg; sourceTree = ""; }; - 84B1E0C62E051B7C00ED000A /* cow3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cow3.ogg; sourceTree = ""; }; - 84B1E0C72E051B7C00ED000A /* cow4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cow4.ogg; sourceTree = ""; }; - 84B1E0C82E051B7C00ED000A /* cowhurt1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cowhurt1.ogg; sourceTree = ""; }; - 84B1E0C92E051B7C00ED000A /* cowhurt2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cowhurt2.ogg; sourceTree = ""; }; - 84B1E0CA2E051B7C00ED000A /* cowhurt3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cowhurt3.ogg; sourceTree = ""; }; - 84B1E0CB2E051B7C00ED000A /* creeper1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = creeper1.ogg; sourceTree = ""; }; - 84B1E0CC2E051B7C00ED000A /* creeper2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = creeper2.ogg; sourceTree = ""; }; - 84B1E0CD2E051B7C00ED000A /* creeper3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = creeper3.ogg; sourceTree = ""; }; - 84B1E0CE2E051B7C00ED000A /* creeper4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = creeper4.ogg; sourceTree = ""; }; - 84B1E0CF2E051B7C00ED000A /* creeperdeath.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = creeperdeath.ogg; sourceTree = ""; }; - 84B1E0D12E051B7C00ED000A /* death.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = death.ogg; sourceTree = ""; }; - 84B1E0D22E051B7C00ED000A /* hit1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit1.ogg; sourceTree = ""; }; - 84B1E0D32E051B7C00ED000A /* hit2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit2.ogg; sourceTree = ""; }; - 84B1E0D42E051B7C00ED000A /* hit3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit3.ogg; sourceTree = ""; }; - 84B1E0D52E051B7C00ED000A /* hit4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit4.ogg; sourceTree = ""; }; - 84B1E0D62E051B7C00ED000A /* idle1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = idle1.ogg; sourceTree = ""; }; - 84B1E0D72E051B7C00ED000A /* idle2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = idle2.ogg; sourceTree = ""; }; - 84B1E0D82E051B7C00ED000A /* idle3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = idle3.ogg; sourceTree = ""; }; - 84B1E0D92E051B7C00ED000A /* idle4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = idle4.ogg; sourceTree = ""; }; - 84B1E0DA2E051B7C00ED000A /* idle5.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = idle5.ogg; sourceTree = ""; }; - 84B1E0DB2E051B7C00ED000A /* portal.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = portal.ogg; sourceTree = ""; }; - 84B1E0DC2E051B7C00ED000A /* portal2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = portal2.ogg; sourceTree = ""; }; - 84B1E0DD2E051B7C00ED000A /* scream1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = scream1.ogg; sourceTree = ""; }; - 84B1E0DE2E051B7C00ED000A /* scream2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = scream2.ogg; sourceTree = ""; }; - 84B1E0DF2E051B7C00ED000A /* scream3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = scream3.ogg; sourceTree = ""; }; - 84B1E0E02E051B7C00ED000A /* scream4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = scream4.ogg; sourceTree = ""; }; - 84B1E0E12E051B7C00ED000A /* stare.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = stare.ogg; sourceTree = ""; }; - 84B1E0E32E051B7C00ED000A /* affectionate scream.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = "affectionate scream.ogg"; sourceTree = ""; }; - 84B1E0E42E051B7C00ED000A /* charge.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = charge.ogg; sourceTree = ""; }; - 84B1E0E52E051B7C00ED000A /* death.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = death.ogg; sourceTree = ""; }; - 84B1E0E62E051B7C00ED000A /* fireball4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = fireball4.ogg; sourceTree = ""; }; - 84B1E0E72E051B7C00ED000A /* moan1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = moan1.ogg; sourceTree = ""; }; - 84B1E0E82E051B7C00ED000A /* moan2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = moan2.ogg; sourceTree = ""; }; - 84B1E0E92E051B7C00ED000A /* moan3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = moan3.ogg; sourceTree = ""; }; - 84B1E0EA2E051B7C00ED000A /* moan4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = moan4.ogg; sourceTree = ""; }; - 84B1E0EB2E051B7C00ED000A /* moan5.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = moan5.ogg; sourceTree = ""; }; - 84B1E0EC2E051B7C00ED000A /* moan6.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = moan6.ogg; sourceTree = ""; }; - 84B1E0ED2E051B7C00ED000A /* moan7.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = moan7.ogg; sourceTree = ""; }; - 84B1E0EE2E051B7C00ED000A /* scream1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = scream1.ogg; sourceTree = ""; }; - 84B1E0EF2E051B7C00ED000A /* scream2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = scream2.ogg; sourceTree = ""; }; - 84B1E0F02E051B7C00ED000A /* scream3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = scream3.ogg; sourceTree = ""; }; - 84B1E0F12E051B7C00ED000A /* scream4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = scream4.ogg; sourceTree = ""; }; - 84B1E0F22E051B7C00ED000A /* scream5.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = scream5.ogg; sourceTree = ""; }; - 84B1E0F42E051B7C00ED000A /* death.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = death.ogg; sourceTree = ""; }; - 84B1E0F52E051B7C00ED000A /* hit1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit1.ogg; sourceTree = ""; }; - 84B1E0F62E051B7C00ED000A /* hit2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit2.ogg; sourceTree = ""; }; - 84B1E0F72E051B7C00ED000A /* hit3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit3.ogg; sourceTree = ""; }; - 84B1E0F82E051B7C00ED000A /* hit4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit4.ogg; sourceTree = ""; }; - 84B1E0F92E051B7C00ED000A /* throw.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = throw.ogg; sourceTree = ""; }; - 84B1E0FA2E051B7C00ED000A /* walk1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = walk1.ogg; sourceTree = ""; }; - 84B1E0FB2E051B7C00ED000A /* walk2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = walk2.ogg; sourceTree = ""; }; - 84B1E0FC2E051B7C00ED000A /* walk3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = walk3.ogg; sourceTree = ""; }; - 84B1E0FD2E051B7C00ED000A /* walk4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = walk4.ogg; sourceTree = ""; }; - 84B1E0FF2E051B7C00ED000A /* big1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = big1.ogg; sourceTree = ""; }; - 84B1E1002E051B7C00ED000A /* big2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = big2.ogg; sourceTree = ""; }; - 84B1E1012E051B7C00ED000A /* big3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = big3.ogg; sourceTree = ""; }; - 84B1E1022E051B7C00ED000A /* big4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = big4.ogg; sourceTree = ""; }; - 84B1E1032E051B7C00ED000A /* jump1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = jump1.ogg; sourceTree = ""; }; - 84B1E1042E051B7C00ED000A /* jump2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = jump2.ogg; sourceTree = ""; }; - 84B1E1052E051B7C00ED000A /* jump3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = jump3.ogg; sourceTree = ""; }; - 84B1E1062E051B7C00ED000A /* jump4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = jump4.ogg; sourceTree = ""; }; - 84B1E1072E051B7C00ED000A /* small1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = small1.ogg; sourceTree = ""; }; - 84B1E1082E051B7C00ED000A /* small2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = small2.ogg; sourceTree = ""; }; - 84B1E1092E051B7C00ED000A /* small3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = small3.ogg; sourceTree = ""; }; - 84B1E10A2E051B7C00ED000A /* small4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = small4.ogg; sourceTree = ""; }; - 84B1E10B2E051B7C00ED000A /* small5.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = small5.ogg; sourceTree = ""; }; - 84B1E10C2E051B7C00ED000A /* pig1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = pig1.ogg; sourceTree = ""; }; - 84B1E10D2E051B7C00ED000A /* pig2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = pig2.ogg; sourceTree = ""; }; - 84B1E10E2E051B7C00ED000A /* pig3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = pig3.ogg; sourceTree = ""; }; - 84B1E10F2E051B7C00ED000A /* pigdeath.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = pigdeath.ogg; sourceTree = ""; }; - 84B1E1102E051B7C00ED000A /* sheep1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = sheep1.ogg; sourceTree = ""; }; - 84B1E1112E051B7C00ED000A /* sheep2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = sheep2.ogg; sourceTree = ""; }; - 84B1E1122E051B7C00ED000A /* sheep3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = sheep3.ogg; sourceTree = ""; }; - 84B1E1142E051B7C00ED000A /* hit1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit1.ogg; sourceTree = ""; }; - 84B1E1152E051B7C00ED000A /* hit2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit2.ogg; sourceTree = ""; }; - 84B1E1162E051B7C00ED000A /* hit3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hit3.ogg; sourceTree = ""; }; - 84B1E1172E051B7C00ED000A /* kill.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = kill.ogg; sourceTree = ""; }; - 84B1E1182E051B7C00ED000A /* say1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = say1.ogg; sourceTree = ""; }; - 84B1E1192E051B7C00ED000A /* say2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = say2.ogg; sourceTree = ""; }; - 84B1E11A2E051B7C00ED000A /* say3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = say3.ogg; sourceTree = ""; }; - 84B1E11B2E051B7C00ED000A /* say4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = say4.ogg; sourceTree = ""; }; - 84B1E11C2E051B7C00ED000A /* step1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = step1.ogg; sourceTree = ""; }; - 84B1E11D2E051B7C00ED000A /* step2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = step2.ogg; sourceTree = ""; }; - 84B1E11E2E051B7C00ED000A /* step3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = step3.ogg; sourceTree = ""; }; - 84B1E11F2E051B7C00ED000A /* step4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = step4.ogg; sourceTree = ""; }; - 84B1E1202E051B7C00ED000A /* skeleton1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = skeleton1.ogg; sourceTree = ""; }; - 84B1E1212E051B7C00ED000A /* skeleton2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = skeleton2.ogg; sourceTree = ""; }; - 84B1E1222E051B7C00ED000A /* skeleton3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = skeleton3.ogg; sourceTree = ""; }; - 84B1E1232E051B7D00ED000A /* skeletondeath.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = skeletondeath.ogg; sourceTree = ""; }; - 84B1E1242E051B7D00ED000A /* skeletonhurt1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = skeletonhurt1.ogg; sourceTree = ""; }; - 84B1E1252E051B7D00ED000A /* skeletonhurt2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = skeletonhurt2.ogg; sourceTree = ""; }; - 84B1E1262E051B7D00ED000A /* skeletonhurt3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = skeletonhurt3.ogg; sourceTree = ""; }; - 84B1E1272E051B7D00ED000A /* skeletonhurt4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = skeletonhurt4.ogg; sourceTree = ""; }; - 84B1E1282E051B7D00ED000A /* slime1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = slime1.ogg; sourceTree = ""; }; - 84B1E1292E051B7D00ED000A /* slime2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = slime2.ogg; sourceTree = ""; }; - 84B1E12A2E051B7D00ED000A /* slime3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = slime3.ogg; sourceTree = ""; }; - 84B1E12B2E051B7D00ED000A /* slime4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = slime4.ogg; sourceTree = ""; }; - 84B1E12C2E051B7D00ED000A /* slime5.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = slime5.ogg; sourceTree = ""; }; - 84B1E12D2E051B7D00ED000A /* slimeattack1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = slimeattack1.ogg; sourceTree = ""; }; - 84B1E12E2E051B7D00ED000A /* slimeattack2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = slimeattack2.ogg; sourceTree = ""; }; - 84B1E12F2E051B7D00ED000A /* spider1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = spider1.ogg; sourceTree = ""; }; - 84B1E1302E051B7D00ED000A /* spider2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = spider2.ogg; sourceTree = ""; }; - 84B1E1312E051B7D00ED000A /* spider3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = spider3.ogg; sourceTree = ""; }; - 84B1E1322E051B7D00ED000A /* spider4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = spider4.ogg; sourceTree = ""; }; - 84B1E1332E051B7D00ED000A /* spiderdeath.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = spiderdeath.ogg; sourceTree = ""; }; - 84B1E1352E051B7D00ED000A /* bark1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = bark1.ogg; sourceTree = ""; }; - 84B1E1362E051B7D00ED000A /* bark2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = bark2.ogg; sourceTree = ""; }; - 84B1E1372E051B7D00ED000A /* bark3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = bark3.ogg; sourceTree = ""; }; - 84B1E1382E051B7D00ED000A /* death.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = death.ogg; sourceTree = ""; }; - 84B1E1392E051B7D00ED000A /* growl1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = growl1.ogg; sourceTree = ""; }; - 84B1E13A2E051B7D00ED000A /* growl2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = growl2.ogg; sourceTree = ""; }; - 84B1E13B2E051B7D00ED000A /* growl3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = growl3.ogg; sourceTree = ""; }; - 84B1E13C2E051B7D00ED000A /* howl1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = howl1.ogg; sourceTree = ""; }; - 84B1E13D2E051B7D00ED000A /* howl2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = howl2.ogg; sourceTree = ""; }; - 84B1E13E2E051B7D00ED000A /* hurt1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hurt1.ogg; sourceTree = ""; }; - 84B1E13F2E051B7D00ED000A /* hurt2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hurt2.ogg; sourceTree = ""; }; - 84B1E1402E051B7D00ED000A /* hurt3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hurt3.ogg; sourceTree = ""; }; - 84B1E1412E051B7D00ED000A /* panting.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = panting.ogg; sourceTree = ""; }; - 84B1E1422E051B7D00ED000A /* shake.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = shake.ogg; sourceTree = ""; }; - 84B1E1432E051B7D00ED000A /* whine.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = whine.ogg; sourceTree = ""; }; - 84B1E1452E051B7D00ED000A /* metal1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = metal1.ogg; sourceTree = ""; }; - 84B1E1462E051B7D00ED000A /* metal2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = metal2.ogg; sourceTree = ""; }; - 84B1E1472E051B7D00ED000A /* metal3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = metal3.ogg; sourceTree = ""; }; - 84B1E1482E051B7D00ED000A /* wood1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = wood1.ogg; sourceTree = ""; }; - 84B1E1492E051B7D00ED000A /* wood2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = wood2.ogg; sourceTree = ""; }; - 84B1E14A2E051B7D00ED000A /* wood3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = wood3.ogg; sourceTree = ""; }; - 84B1E14B2E051B7D00ED000A /* wood4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = wood4.ogg; sourceTree = ""; }; - 84B1E14C2E051B7D00ED000A /* woodbreak.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = woodbreak.ogg; sourceTree = ""; }; - 84B1E14D2E051B7D00ED000A /* zombie1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zombie1.ogg; sourceTree = ""; }; - 84B1E14E2E051B7D00ED000A /* zombie2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zombie2.ogg; sourceTree = ""; }; - 84B1E14F2E051B7D00ED000A /* zombie3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zombie3.ogg; sourceTree = ""; }; - 84B1E1502E051B7D00ED000A /* zombiedeath.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zombiedeath.ogg; sourceTree = ""; }; - 84B1E1512E051B7D00ED000A /* zombiehurt1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zombiehurt1.ogg; sourceTree = ""; }; - 84B1E1522E051B7D00ED000A /* zombiehurt2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zombiehurt2.ogg; sourceTree = ""; }; - 84B1E1542E051B7D00ED000A /* zpig1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zpig1.ogg; sourceTree = ""; }; - 84B1E1552E051B7D00ED000A /* zpig2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zpig2.ogg; sourceTree = ""; }; - 84B1E1562E051B7D00ED000A /* zpig3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zpig3.ogg; sourceTree = ""; }; - 84B1E1572E051B7D00ED000A /* zpig4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zpig4.ogg; sourceTree = ""; }; - 84B1E1582E051B7D00ED000A /* zpigangry1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zpigangry1.ogg; sourceTree = ""; }; - 84B1E1592E051B7D00ED000A /* zpigangry2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zpigangry2.ogg; sourceTree = ""; }; - 84B1E15A2E051B7D00ED000A /* zpigangry3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zpigangry3.ogg; sourceTree = ""; }; - 84B1E15B2E051B7D00ED000A /* zpigangry4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zpigangry4.ogg; sourceTree = ""; }; - 84B1E15C2E051B7D00ED000A /* zpigdeath.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zpigdeath.ogg; sourceTree = ""; }; - 84B1E15D2E051B7D00ED000A /* zpighurt1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zpighurt1.ogg; sourceTree = ""; }; - 84B1E15E2E051B7D00ED000A /* zpighurt2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = zpighurt2.ogg; sourceTree = ""; }; - 84B1E1602E051B7D00ED000A /* bass.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = bass.ogg; sourceTree = ""; }; - 84B1E1612E051B7D00ED000A /* bassattack.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = bassattack.ogg; sourceTree = ""; }; - 84B1E1622E051B7D00ED000A /* bd.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = bd.ogg; sourceTree = ""; }; - 84B1E1632E051B7D00ED000A /* harp.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = harp.ogg; sourceTree = ""; }; - 84B1E1642E051B7D00ED000A /* hat.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hat.ogg; sourceTree = ""; }; - 84B1E1652E051B7D00ED000A /* pling.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = pling.ogg; sourceTree = ""; }; - 84B1E1662E051B7D00ED000A /* snare.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = snare.ogg; sourceTree = ""; }; - 84B1E1682E051B7D00ED000A /* portal.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = portal.ogg; sourceTree = ""; }; - 84B1E1692E051B7D00ED000A /* travel.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = travel.ogg; sourceTree = ""; }; - 84B1E16A2E051B7D00ED000A /* trigger.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = trigger.ogg; sourceTree = ""; }; - 84B1E16C2E051B7D00ED000A /* bow.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = bow.ogg; sourceTree = ""; }; - 84B1E16D2E051B7D00ED000A /* bowhit1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = bowhit1.ogg; sourceTree = ""; }; - 84B1E16E2E051B7D00ED000A /* bowhit2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = bowhit2.ogg; sourceTree = ""; }; - 84B1E16F2E051B7D00ED000A /* bowhit3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = bowhit3.ogg; sourceTree = ""; }; - 84B1E1702E051B7D00ED000A /* bowhit4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = bowhit4.ogg; sourceTree = ""; }; - 84B1E1712E051B7D00ED000A /* break.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = break.ogg; sourceTree = ""; }; - 84B1E1722E051B7D00ED000A /* breath.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = breath.ogg; sourceTree = ""; }; - 84B1E1732E051B7D00ED000A /* burp.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = burp.ogg; sourceTree = ""; }; - 84B1E1742E051B7D00ED000A /* chestclosed.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = chestclosed.ogg; sourceTree = ""; }; - 84B1E1752E051B7D00ED000A /* chestopen.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = chestopen.ogg; sourceTree = ""; }; - 84B1E1762E051B7D00ED000A /* click.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = click.ogg; sourceTree = ""; }; - 84B1E1772E051B7D00ED000A /* door_close.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = door_close.ogg; sourceTree = ""; }; - 84B1E1782E051B7D00ED000A /* door_open.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = door_open.ogg; sourceTree = ""; }; - 84B1E1792E051B7D00ED000A /* drink.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = drink.ogg; sourceTree = ""; }; - 84B1E17A2E051B7D00ED000A /* drr.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = drr.ogg; sourceTree = ""; }; - 84B1E17B2E051B7D00ED000A /* eat1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = eat1.ogg; sourceTree = ""; }; - 84B1E17C2E051B7D00ED000A /* eat2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = eat2.ogg; sourceTree = ""; }; - 84B1E17D2E051B7D00ED000A /* eat3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = eat3.ogg; sourceTree = ""; }; - 84B1E17E2E051B7D00ED000A /* explode.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = explode.ogg; sourceTree = ""; }; - 84B1E17F2E051B7D00ED000A /* explode1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = explode1.ogg; sourceTree = ""; }; - 84B1E1802E051B7D00ED000A /* explode2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = explode2.ogg; sourceTree = ""; }; - 84B1E1812E051B7D00ED000A /* explode3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = explode3.ogg; sourceTree = ""; }; - 84B1E1822E051B7D00ED000A /* explode4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = explode4.ogg; sourceTree = ""; }; - 84B1E1832E051B7D00ED000A /* fizz.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = fizz.ogg; sourceTree = ""; }; - 84B1E1842E051B7D00ED000A /* fuse.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = fuse.ogg; sourceTree = ""; }; - 84B1E1852E051B7D00ED000A /* glass1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = glass1.ogg; sourceTree = ""; }; - 84B1E1862E051B7D00ED000A /* glass2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = glass2.ogg; sourceTree = ""; }; - 84B1E1872E051B7D00ED000A /* glass3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = glass3.ogg; sourceTree = ""; }; - 84B1E1882E051B7D00ED000A /* hurt.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = hurt.ogg; sourceTree = ""; }; - 84B1E1892E051B7D00ED000A /* levelup.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = levelup.ogg; sourceTree = ""; }; - 84B1E18A2E051B7D00ED000A /* old_explode.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = old_explode.ogg; sourceTree = ""; }; - 84B1E18B2E051B7D00ED000A /* orb.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = orb.ogg; sourceTree = ""; }; - 84B1E18C2E051B7D00ED000A /* pop.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = pop.ogg; sourceTree = ""; }; - 84B1E18D2E051B7D00ED000A /* splash.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = splash.ogg; sourceTree = ""; }; - 84B1E18E2E051B7D00ED000A /* wood click.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = "wood click.ogg"; sourceTree = ""; }; - 84B1E1902E051B7D00ED000A /* cloth1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cloth1.ogg; sourceTree = ""; }; - 84B1E1912E051B7D00ED000A /* cloth2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cloth2.ogg; sourceTree = ""; }; - 84B1E1922E051B7D00ED000A /* cloth3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cloth3.ogg; sourceTree = ""; }; - 84B1E1932E051B7D00ED000A /* cloth4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = cloth4.ogg; sourceTree = ""; }; - 84B1E1942E051B7D00ED000A /* grass1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = grass1.ogg; sourceTree = ""; }; - 84B1E1952E051B7D00ED000A /* grass2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = grass2.ogg; sourceTree = ""; }; - 84B1E1962E051B7D00ED000A /* grass3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = grass3.ogg; sourceTree = ""; }; - 84B1E1972E051B7D00ED000A /* grass4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = grass4.ogg; sourceTree = ""; }; - 84B1E1982E051B7D00ED000A /* gravel1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = gravel1.ogg; sourceTree = ""; }; - 84B1E1992E051B7D00ED000A /* gravel2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = gravel2.ogg; sourceTree = ""; }; - 84B1E19A2E051B7D00ED000A /* gravel3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = gravel3.ogg; sourceTree = ""; }; - 84B1E19B2E051B7D00ED000A /* gravel4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = gravel4.ogg; sourceTree = ""; }; - 84B1E19C2E051B7D00ED000A /* sand1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = sand1.ogg; sourceTree = ""; }; - 84B1E19D2E051B7D00ED000A /* sand2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = sand2.ogg; sourceTree = ""; }; - 84B1E19E2E051B7D00ED000A /* sand3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = sand3.ogg; sourceTree = ""; }; - 84B1E19F2E051B7D00ED000A /* sand4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = sand4.ogg; sourceTree = ""; }; - 84B1E1A02E051B7D00ED000A /* snow1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = snow1.ogg; sourceTree = ""; }; - 84B1E1A12E051B7D00ED000A /* snow2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = snow2.ogg; sourceTree = ""; }; - 84B1E1A22E051B7D00ED000A /* snow3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = snow3.ogg; sourceTree = ""; }; - 84B1E1A32E051B7D00ED000A /* snow4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = snow4.ogg; sourceTree = ""; }; - 84B1E1A42E051B7D00ED000A /* stone1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = stone1.ogg; sourceTree = ""; }; - 84B1E1A52E051B7D00ED000A /* stone2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = stone2.ogg; sourceTree = ""; }; - 84B1E1A62E051B7D00ED000A /* stone3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = stone3.ogg; sourceTree = ""; }; - 84B1E1A72E051B7D00ED000A /* stone4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = stone4.ogg; sourceTree = ""; }; - 84B1E1A82E051B7D00ED000A /* wood1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = wood1.ogg; sourceTree = ""; }; - 84B1E1A92E051B7D00ED000A /* wood2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = wood2.ogg; sourceTree = ""; }; - 84B1E1AA2E051B7D00ED000A /* wood3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = wood3.ogg; sourceTree = ""; }; - 84B1E1AB2E051B7D00ED000A /* wood4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = wood4.ogg; sourceTree = ""; }; - 84B1E1AE2E051B7D00ED000A /* in.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = in.ogg; sourceTree = ""; }; - 84B1E1AF2E051B7D00ED000A /* out.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = out.ogg; sourceTree = ""; }; - 84B1E1B22E051B7D00ED000A /* grass1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = grass1.ogg; sourceTree = ""; }; - 84B1E1B32E051B7D00ED000A /* grass2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = grass2.ogg; sourceTree = ""; }; - 84B1E1B42E051B7D00ED000A /* grass3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = grass3.ogg; sourceTree = ""; }; - 84B1E1B52E051B7D00ED000A /* grass4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = grass4.ogg; sourceTree = ""; }; - 84B1E1B62E051B7D00ED000A /* gravel1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = gravel1.ogg; sourceTree = ""; }; - 84B1E1B72E051B7D00ED000A /* gravel2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = gravel2.ogg; sourceTree = ""; }; - 84B1E1B82E051B7D00ED000A /* gravel3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = gravel3.ogg; sourceTree = ""; }; - 84B1E1B92E051B7D00ED000A /* gravel4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = gravel4.ogg; sourceTree = ""; }; - 84B1E1BA2E051B7D00ED000A /* stone1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = stone1.ogg; sourceTree = ""; }; - 84B1E1BB2E051B7D00ED000A /* stone2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = stone2.ogg; sourceTree = ""; }; - 84B1E1BC2E051B7D00ED000A /* stone3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = stone3.ogg; sourceTree = ""; }; - 84B1E1BD2E051B7D00ED000A /* stone4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = stone4.ogg; sourceTree = ""; }; - 84B1E1BE2E051B7D00ED000A /* wood1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = wood1.ogg; sourceTree = ""; }; - 84B1E1BF2E051B7D00ED000A /* wood2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = wood2.ogg; sourceTree = ""; }; - 84B1E1C02E051B7D00ED000A /* wood3.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = wood3.ogg; sourceTree = ""; }; - 84B1E1C12E051B7D00ED000A /* wood4.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = wood4.ogg; sourceTree = ""; }; 84B8AEE72AF188D8008DE93D /* libClient.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libClient.a; sourceTree = BUILT_PRODUCTS_DIR; }; 84BF630B2AF1859D008A9995 /* libWorld.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libWorld.a; sourceTree = BUILT_PRODUCTS_DIR; }; 84C0D8002B159A0E007E1E76 /* GlobalSettings.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = GlobalSettings.xcconfig; path = ../Configuration/GlobalSettings.xcconfig; sourceTree = ""; }; 84C0D8022B15A1D0007E1E76 /* PlatformDefinitions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformDefinitions.h; sourceTree = ""; }; - 84C208512AF88A5000BAE438 /* grass_side_transparent.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = grass_side_transparent.png; sourceTree = ""; }; - 84C208522AF88A5000BAE438 /* patch_data.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = patch_data.txt; sourceTree = ""; }; 84C4D86E2A872C0100323E33 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; 84C90EA32AF8861A008973F9 /* OptionList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OptionList.cpp; sourceTree = ""; }; 84C90EA42AF8861A008973F9 /* OptionList.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = OptionList.hpp; sourceTree = ""; }; @@ -2981,6 +2337,7 @@ 84CEF0012AE3C97D006C5829 /* EAGLView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EAGLView.h; sourceTree = ""; }; 84CEF0022AE3C97D006C5829 /* EAGLView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EAGLView.m; sourceTree = ""; }; 84D6694F2B1EAEBF00B34FC1 /* GlobalDebugSettings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = GlobalDebugSettings.xcconfig; path = ../Configuration/GlobalDebugSettings.xcconfig; sourceTree = ""; }; + 84D772262EE5180600701DCB /* assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = assets; path = ../../../../game/assets; sourceTree = ""; }; 84E000FB2AF39E84009B9555 /* BuildActionIntention.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = BuildActionIntention.hpp; sourceTree = ""; }; 84E000FC2AF39E84009B9555 /* CustomInputHolder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustomInputHolder.cpp; sourceTree = ""; }; 84E000FD2AF39E84009B9555 /* CustomInputHolder.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CustomInputHolder.hpp; sourceTree = ""; }; @@ -3013,38 +2370,11 @@ 84E001182AF39E84009B9555 /* TouchscreenInput_TestFps.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TouchscreenInput_TestFps.hpp; sourceTree = ""; }; 84E001192AF39E84009B9555 /* UnifiedTurnBuild.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnifiedTurnBuild.cpp; sourceTree = ""; }; 84E0011A2AF39E84009B9555 /* UnifiedTurnBuild.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UnifiedTurnBuild.hpp; sourceTree = ""; }; - 84E001672AF3A28B009B9555 /* default8.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = default8.png; sourceTree = ""; }; - 84E0016A2AF3A28B009B9555 /* panorama_0.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = panorama_0.png; sourceTree = ""; }; - 84E0016B2AF3A28B009B9555 /* panorama_1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = panorama_1.png; sourceTree = ""; }; - 84E0016C2AF3A28B009B9555 /* panorama_2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = panorama_2.png; sourceTree = ""; }; - 84E0016D2AF3A28B009B9555 /* panorama_3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = panorama_3.png; sourceTree = ""; }; - 84E0016E2AF3A28B009B9555 /* panorama_4.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = panorama_4.png; sourceTree = ""; }; - 84E0016F2AF3A28B009B9555 /* panorama_5.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = panorama_5.png; sourceTree = ""; }; - 84E001702AF3A28B009B9555 /* background.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = background.png; sourceTree = ""; }; - 84E001762AF3A28B009B9555 /* default_world.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = default_world.png; sourceTree = ""; }; - 84E001782AF3A28B009B9555 /* feedback_fill.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = feedback_fill.png; sourceTree = ""; }; - 84E001792AF3A28B009B9555 /* feedback_outer.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = feedback_outer.png; sourceTree = ""; }; - 84E0017A2AF3A28B009B9555 /* gui.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = gui.png; sourceTree = ""; }; - 84E0017B2AF3A28B009B9555 /* gui_blocks.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = gui_blocks.png; sourceTree = ""; }; - 84E0017C2AF3A28B009B9555 /* icons.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = icons.png; sourceTree = ""; }; - 84E0017E2AF3A28B009B9555 /* items.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = items.png; sourceTree = ""; }; - 84E001882AF3A28B009B9555 /* title.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = title.png; sourceTree = ""; }; - 84E0018A2AF3A28B009B9555 /* icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = icon.png; sourceTree = ""; }; - 84E0018C2AF3A28B009B9555 /* camera.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = camera.png; sourceTree = ""; }; - 84E0018E2AF3A28B009B9555 /* char.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = char.png; sourceTree = ""; }; - 84E0018F2AF3A28B009B9555 /* particles.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = particles.png; sourceTree = ""; }; - 84E001902AF3A28B009B9555 /* readme.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = readme.txt; sourceTree = ""; }; - 84E001912AF3A28B009B9555 /* terrain.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = terrain.png; sourceTree = ""; }; 84E001B62AF3A3CB009B9555 /* SmoothFloat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SmoothFloat.cpp; sourceTree = ""; }; 84E001B72AF3A3CB009B9555 /* SmoothFloat.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SmoothFloat.hpp; sourceTree = ""; }; 84E001BA2AF3AF9B009B9555 /* MainWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = ""; }; 84E105F62E85157F00FAB6C5 /* AppPlatform_sdl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppPlatform_sdl.cpp; sourceTree = ""; }; 84E105F72E85157F00FAB6C5 /* AppPlatform_sdl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AppPlatform_sdl.hpp; sourceTree = ""; }; - 84E1C9B52E7FDAE3007D2F5D /* birch_sapling.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = birch_sapling.png; sourceTree = ""; }; - 84E1C9B62E7FDAE3007D2F5D /* dead_bush.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = dead_bush.png; sourceTree = ""; }; - 84E1C9B72E7FDAE3007D2F5D /* fern.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = fern.png; sourceTree = ""; }; - 84E1C9B82E7FDAE3007D2F5D /* spruce_sapling.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = spruce_sapling.png; sourceTree = ""; }; - 84E1C9B92E7FDAE3007D2F5D /* tall_grass.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = tall_grass.png; sourceTree = ""; }; 84E1C9BF2E7FDC26007D2F5D /* CactusTile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CactusTile.cpp; sourceTree = ""; }; 84E1C9C02E7FDC26007D2F5D /* CactusTile.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CactusTile.hpp; sourceTree = ""; }; 84E1C9C12E7FDC26007D2F5D /* DeadBush.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeadBush.cpp; sourceTree = ""; }; @@ -3079,16 +2409,289 @@ 84E78C822B58B5FB00D515EF /* RocketItem.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RocketItem.hpp; sourceTree = ""; }; 84E78C852B58B66B00D515EF /* RocketLauncherTile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RocketLauncherTile.cpp; sourceTree = ""; }; 84E78C862B58B66B00D515EF /* RocketLauncherTile.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RocketLauncherTile.hpp; sourceTree = ""; }; - 84E78C892B58BB7400D515EF /* n_rocket_launched.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = n_rocket_launched.png; sourceTree = ""; }; - 84E78C8A2B58BB7400D515EF /* n_rocket_launcher.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = n_rocket_launcher.png; sourceTree = ""; }; - 84E78C8B2B58BB7400D515EF /* n_rocket.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = n_rocket.png; sourceTree = ""; }; - 84E78C8F2B58C18C00D515EF /* black.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = black.png; sourceTree = ""; }; 84EAE8DD2AF1EAA1000894E8 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 84EAE8DF2AF1EAA9000894E8 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 84EAE8E12AF1EAB5000894E8 /* GLKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GLKit.framework; path = System/Library/Frameworks/GLKit.framework; sourceTree = SDKROOT; }; 84EAE8E32AF1EABE000894E8 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; 84EAE8F02AF1EAFA000894E8 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = ""; }; 84EAE8F12AF1EAFA000894E8 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; + 84EB09942EE2CC25008FB007 /* AppPlatformListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppPlatformListener.cpp; sourceTree = ""; }; + 84EB09952EE2CC25008FB007 /* AppPlatformListener.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AppPlatformListener.hpp; sourceTree = ""; }; + 84EB09982EE2CC3B008FB007 /* GuiElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GuiElement.cpp; sourceTree = ""; }; + 84EB09992EE2CC3B008FB007 /* GuiElement.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = GuiElement.hpp; sourceTree = ""; }; + 84EB099A2EE2CC3B008FB007 /* IntRectangle.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = IntRectangle.hpp; sourceTree = ""; }; + 84EB09A12EE2CC86008FB007 /* Cube.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Cube.cpp; sourceTree = ""; }; + 84EB09A22EE2CC86008FB007 /* Cube.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Cube.hpp; sourceTree = ""; }; + 84EB09A32EE2CC86008FB007 /* ModelPart.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ModelPart.cpp; sourceTree = ""; }; + 84EB09A42EE2CC86008FB007 /* ModelPart.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ModelPart.hpp; sourceTree = ""; }; + 84EB09A52EE2CC86008FB007 /* PolygonQuad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolygonQuad.cpp; sourceTree = ""; }; + 84EB09A62EE2CC86008FB007 /* PolygonQuad.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PolygonQuad.hpp; sourceTree = ""; }; + 84EB09A72EE2CC86008FB007 /* TextureOffset.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TextureOffset.hpp; sourceTree = ""; }; + 84EB09A92EE2CC86008FB007 /* ChickenModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ChickenModel.cpp; sourceTree = ""; }; + 84EB09AA2EE2CC86008FB007 /* ChickenModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ChickenModel.hpp; sourceTree = ""; }; + 84EB09AB2EE2CC86008FB007 /* CowModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CowModel.cpp; sourceTree = ""; }; + 84EB09AC2EE2CC86008FB007 /* CowModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CowModel.hpp; sourceTree = ""; }; + 84EB09AD2EE2CC86008FB007 /* CreeperModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CreeperModel.cpp; sourceTree = ""; }; + 84EB09AE2EE2CC86008FB007 /* CreeperModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CreeperModel.hpp; sourceTree = ""; }; + 84EB09AF2EE2CC86008FB007 /* HumanoidModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HumanoidModel.cpp; sourceTree = ""; }; + 84EB09B02EE2CC86008FB007 /* HumanoidModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = HumanoidModel.hpp; sourceTree = ""; }; + 84EB09B12EE2CC86008FB007 /* Model.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Model.cpp; sourceTree = ""; }; + 84EB09B22EE2CC86008FB007 /* Model.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Model.hpp; sourceTree = ""; }; + 84EB09B32EE2CC86008FB007 /* PigModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PigModel.cpp; sourceTree = ""; }; + 84EB09B42EE2CC86008FB007 /* PigModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PigModel.hpp; sourceTree = ""; }; + 84EB09B52EE2CC86008FB007 /* QuadrupedModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = QuadrupedModel.cpp; sourceTree = ""; }; + 84EB09B62EE2CC86008FB007 /* QuadrupedModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = QuadrupedModel.hpp; sourceTree = ""; }; + 84EB09B72EE2CC86008FB007 /* SheepFurModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SheepFurModel.cpp; sourceTree = ""; }; + 84EB09B82EE2CC86008FB007 /* SheepFurModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SheepFurModel.hpp; sourceTree = ""; }; + 84EB09B92EE2CC86008FB007 /* SheepModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SheepModel.cpp; sourceTree = ""; }; + 84EB09BA2EE2CC86008FB007 /* SheepModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SheepModel.hpp; sourceTree = ""; }; + 84EB09BB2EE2CC86008FB007 /* SkeletonModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SkeletonModel.cpp; sourceTree = ""; }; + 84EB09BC2EE2CC86008FB007 /* SkeletonModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SkeletonModel.hpp; sourceTree = ""; }; + 84EB09BD2EE2CC86008FB007 /* SpiderModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpiderModel.cpp; sourceTree = ""; }; + 84EB09BE2EE2CC86008FB007 /* SpiderModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SpiderModel.hpp; sourceTree = ""; }; + 84EB09BF2EE2CC86008FB007 /* ZombieModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ZombieModel.cpp; sourceTree = ""; }; + 84EB09C02EE2CC86008FB007 /* ZombieModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ZombieModel.hpp; sourceTree = ""; }; + 84EB09E02EE2CCA8008FB007 /* Fog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Fog.cpp; sourceTree = ""; }; + 84EB09E12EE2CCA8008FB007 /* Fog.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Fog.hpp; sourceTree = ""; }; + 84EB09E32EE2CCA8008FB007 /* EntityShaderManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EntityShaderManager.cpp; sourceTree = ""; }; + 84EB09E42EE2CCA8008FB007 /* EntityShaderManager.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = EntityShaderManager.hpp; sourceTree = ""; }; + 84EB09E52EE2CCA8008FB007 /* RenderMaterialGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMaterialGroup.cpp; sourceTree = ""; }; + 84EB09E62EE2CCA8008FB007 /* RenderMaterialGroup.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RenderMaterialGroup.hpp; sourceTree = ""; }; + 84EB09E72EE2CCA8008FB007 /* ScreenRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScreenRenderer.cpp; sourceTree = ""; }; + 84EB09E82EE2CCA8008FB007 /* ScreenRenderer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ScreenRenderer.hpp; sourceTree = ""; }; + 84EB09EA2EE2CCA8008FB007 /* ColorSpace.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ColorSpace.hpp; sourceTree = ""; }; + 84EB09EB2EE2CCA8008FB007 /* ImageData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageData.cpp; sourceTree = ""; }; + 84EB09EC2EE2CCA8008FB007 /* ImageData.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ImageData.hpp; sourceTree = ""; }; + 84EB09ED2EE2CCA8008FB007 /* TextureData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureData.cpp; sourceTree = ""; }; + 84EB09EE2EE2CCA8008FB007 /* TextureData.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TextureData.hpp; sourceTree = ""; }; + 84EB09FD2EE2CCC0008FB007 /* Color.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Color.cpp; sourceTree = ""; }; + 84EB09FE2EE2CCC0008FB007 /* Color.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Color.hpp; sourceTree = ""; }; + 84EB0A002EE2CCC0008FB007 /* AlignmentHelper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AlignmentHelper.cpp; sourceTree = ""; }; + 84EB0A012EE2CCC0008FB007 /* AlignmentHelper.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AlignmentHelper.hpp; sourceTree = ""; }; + 84EB0A022EE2CCC0008FB007 /* InheritanceTree.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = InheritanceTree.hpp; sourceTree = ""; }; + 84EB0A032EE2CCC0008FB007 /* JsonParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JsonParser.cpp; sourceTree = ""; }; + 84EB0A042EE2CCC0008FB007 /* JsonParser.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = JsonParser.hpp; sourceTree = ""; }; + 84EB0A052EE2CCC0008FB007 /* Singleton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Singleton.cpp; sourceTree = ""; }; + 84EB0A062EE2CCC0008FB007 /* Singleton.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Singleton.hpp; sourceTree = ""; }; + 84EB0C102EE2D4B2008FB007 /* Attribute.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Attribute.cpp; sourceTree = ""; }; + 84EB0C112EE2D4B2008FB007 /* Attribute.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Attribute.hpp; sourceTree = ""; }; + 84EB0C122EE2D4B2008FB007 /* ConstantBufferMetaData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConstantBufferMetaData.cpp; sourceTree = ""; }; + 84EB0C132EE2D4B2008FB007 /* ConstantBufferMetaData.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ConstantBufferMetaData.hpp; sourceTree = ""; }; + 84EB0C142EE2D4B2008FB007 /* ConstantBufferMetaDataManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConstantBufferMetaDataManager.cpp; sourceTree = ""; }; + 84EB0C152EE2D4B2008FB007 /* ConstantBufferMetaDataManager.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ConstantBufferMetaDataManager.hpp; sourceTree = ""; }; + 84EB0C162EE2D4B2008FB007 /* EnableScissorTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EnableScissorTest.cpp; sourceTree = ""; }; + 84EB0C172EE2D4B2008FB007 /* EnableScissorTest.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = EnableScissorTest.hpp; sourceTree = ""; }; + 84EB0C182EE2D4B2008FB007 /* EntityConstants.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EntityConstants.cpp; sourceTree = ""; }; + 84EB0C192EE2D4B2008FB007 /* EntityConstants.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = EntityConstants.hpp; sourceTree = ""; }; + 84EB0C1A2EE2D4B2008FB007 /* GlobalConstantBufferManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GlobalConstantBufferManager.cpp; sourceTree = ""; }; + 84EB0C1B2EE2D4B2008FB007 /* GlobalConstantBufferManager.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = GlobalConstantBufferManager.hpp; sourceTree = ""; }; + 84EB0C1C2EE2D4B2008FB007 /* GlobalConstantBuffers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GlobalConstantBuffers.cpp; sourceTree = ""; }; + 84EB0C1D2EE2D4B2008FB007 /* GlobalConstantBuffers.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = GlobalConstantBuffers.hpp; sourceTree = ""; }; + 84EB0C202EE2D4B2008FB007 /* BlendStateBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BlendStateBase.cpp; sourceTree = ""; }; + 84EB0C212EE2D4B2008FB007 /* BlendStateBase.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = BlendStateBase.hpp; sourceTree = ""; }; + 84EB0C222EE2D4B2008FB007 /* BufferBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BufferBase.cpp; sourceTree = ""; }; + 84EB0C232EE2D4B2008FB007 /* BufferBase.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = BufferBase.hpp; sourceTree = ""; }; + 84EB0C242EE2D4B2008FB007 /* ConstantBufferBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConstantBufferBase.cpp; sourceTree = ""; }; + 84EB0C252EE2D4B2008FB007 /* ConstantBufferBase.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ConstantBufferBase.hpp; sourceTree = ""; }; + 84EB0C262EE2D4B2008FB007 /* ConstantBufferConstantsBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConstantBufferConstantsBase.cpp; sourceTree = ""; }; + 84EB0C272EE2D4B2008FB007 /* ConstantBufferConstantsBase.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ConstantBufferConstantsBase.hpp; sourceTree = ""; }; + 84EB0C282EE2D4B2008FB007 /* ConstantBufferContainerBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConstantBufferContainerBase.cpp; sourceTree = ""; }; + 84EB0C292EE2D4B2008FB007 /* ConstantBufferContainerBase.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ConstantBufferContainerBase.hpp; sourceTree = ""; }; + 84EB0C2A2EE2D4B2008FB007 /* DepthStencilStateBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DepthStencilStateBase.cpp; sourceTree = ""; }; + 84EB0C2B2EE2D4B2008FB007 /* DepthStencilStateBase.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DepthStencilStateBase.hpp; sourceTree = ""; }; + 84EB0C2C2EE2D4B2008FB007 /* FixedPipelineStateBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FixedPipelineStateBase.cpp; sourceTree = ""; }; + 84EB0C2D2EE2D4B2008FB007 /* FixedPipelineStateBase.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FixedPipelineStateBase.hpp; sourceTree = ""; }; + 84EB0C2E2EE2D4B2008FB007 /* FogStateBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FogStateBase.cpp; sourceTree = ""; }; + 84EB0C2F2EE2D4B2008FB007 /* FogStateBase.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FogStateBase.hpp; sourceTree = ""; }; + 84EB0C302EE2D4B2008FB007 /* FrameBufferObjectBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FrameBufferObjectBase.cpp; sourceTree = ""; }; + 84EB0C312EE2D4B2008FB007 /* FrameBufferObjectBase.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FrameBufferObjectBase.hpp; sourceTree = ""; }; + 84EB0C322EE2D4B2008FB007 /* ImmediateBufferBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImmediateBufferBase.cpp; sourceTree = ""; }; + 84EB0C332EE2D4B2008FB007 /* ImmediateBufferBase.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ImmediateBufferBase.hpp; sourceTree = ""; }; + 84EB0C342EE2D4B2008FB007 /* RasterizerStateBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RasterizerStateBase.cpp; sourceTree = ""; }; + 84EB0C352EE2D4B2008FB007 /* RasterizerStateBase.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RasterizerStateBase.hpp; sourceTree = ""; }; + 84EB0C362EE2D4B2008FB007 /* RenderContextBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderContextBase.cpp; sourceTree = ""; }; + 84EB0C372EE2D4B2008FB007 /* RenderContextBase.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RenderContextBase.hpp; sourceTree = ""; }; + 84EB0C382EE2D4B2008FB007 /* RenderContextStateBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderContextStateBase.cpp; sourceTree = ""; }; + 84EB0C392EE2D4B2008FB007 /* RenderContextStateBase.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RenderContextStateBase.hpp; sourceTree = ""; }; + 84EB0C3A2EE2D4B2008FB007 /* RenderDeviceBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderDeviceBase.cpp; sourceTree = ""; }; + 84EB0C3B2EE2D4B2008FB007 /* RenderDeviceBase.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RenderDeviceBase.hpp; sourceTree = ""; }; + 84EB0C3C2EE2D4B2008FB007 /* ShaderBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShaderBase.cpp; sourceTree = ""; }; + 84EB0C3D2EE2D4B2008FB007 /* ShaderBase.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ShaderBase.hpp; sourceTree = ""; }; + 84EB0C3E2EE2D4B2008FB007 /* ShaderConstantBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShaderConstantBase.cpp; sourceTree = ""; }; + 84EB0C3F2EE2D4B2008FB007 /* ShaderConstantBase.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ShaderConstantBase.hpp; sourceTree = ""; }; + 84EB0C402EE2D4B2008FB007 /* ShaderConstantWithDataBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShaderConstantWithDataBase.cpp; sourceTree = ""; }; + 84EB0C412EE2D4B2008FB007 /* ShaderConstantWithDataBase.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ShaderConstantWithDataBase.hpp; sourceTree = ""; }; + 84EB0C422EE2D4B2008FB007 /* ShaderContextBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShaderContextBase.cpp; sourceTree = ""; }; + 84EB0C432EE2D4B2008FB007 /* ShaderContextBase.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ShaderContextBase.hpp; sourceTree = ""; }; + 84EB0C442EE2D4B2008FB007 /* ShaderProgramBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShaderProgramBase.cpp; sourceTree = ""; }; + 84EB0C452EE2D4B2008FB007 /* ShaderProgramBase.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ShaderProgramBase.hpp; sourceTree = ""; }; + 84EB0C462EE2D4B2008FB007 /* TextureBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureBase.cpp; sourceTree = ""; }; + 84EB0C472EE2D4B2008FB007 /* TextureBase.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TextureBase.hpp; sourceTree = ""; }; + 84EB0C482EE2D4B3008FB007 /* BlendStateDescription.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BlendStateDescription.cpp; sourceTree = ""; }; + 84EB0C492EE2D4B3008FB007 /* BlendStateDescription.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = BlendStateDescription.hpp; sourceTree = ""; }; + 84EB0C4A2EE2D4B3008FB007 /* DepthStencilStateDescription.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DepthStencilStateDescription.cpp; sourceTree = ""; }; + 84EB0C4B2EE2D4B3008FB007 /* DepthStencilStateDescription.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DepthStencilStateDescription.hpp; sourceTree = ""; }; + 84EB0C4D2EE2D4B3008FB007 /* BlendTarget.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = BlendTarget.hpp; sourceTree = ""; }; + 84EB0C4E2EE2D4B3008FB007 /* BlendTarget_JsonParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BlendTarget_JsonParser.cpp; sourceTree = ""; }; + 84EB0C4F2EE2D4B3008FB007 /* BufferType.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = BufferType.hpp; sourceTree = ""; }; + 84EB0C502EE2D4B3008FB007 /* ColorWriteMask.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ColorWriteMask.hpp; sourceTree = ""; }; + 84EB0C512EE2D4B3008FB007 /* ComparisonFunc.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ComparisonFunc.hpp; sourceTree = ""; }; + 84EB0C522EE2D4B3008FB007 /* ComparisonFunc_JsonParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ComparisonFunc_JsonParser.cpp; sourceTree = ""; }; + 84EB0C532EE2D4B3008FB007 /* CullMode.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CullMode.hpp; sourceTree = ""; }; + 84EB0C542EE2D4B3008FB007 /* DepthWriteMask.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DepthWriteMask.hpp; sourceTree = ""; }; + 84EB0C552EE2D4B3008FB007 /* FogMode.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FogMode.hpp; sourceTree = ""; }; + 84EB0C562EE2D4B3008FB007 /* PrimitiveMode.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PrimitiveMode.hpp; sourceTree = ""; }; + 84EB0C572EE2D4B3008FB007 /* PrimitiveMode_JsonParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrimitiveMode_JsonParser.cpp; sourceTree = ""; }; + 84EB0C582EE2D4B3008FB007 /* RenderState.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RenderState.hpp; sourceTree = ""; }; + 84EB0C592EE2D4B3008FB007 /* RenderState_JsonParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderState_JsonParser.cpp; sourceTree = ""; }; + 84EB0C5A2EE2D4B3008FB007 /* RenderState_JsonParser.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RenderState_JsonParser.hpp; sourceTree = ""; }; + 84EB0C5B2EE2D4B3008FB007 /* ShadeMode.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ShadeMode.hpp; sourceTree = ""; }; + 84EB0C5C2EE2D4B3008FB007 /* ShaderPrimitiveTypes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShaderPrimitiveTypes.cpp; sourceTree = ""; }; + 84EB0C5D2EE2D4B3008FB007 /* ShaderPrimitiveTypes.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ShaderPrimitiveTypes.hpp; sourceTree = ""; }; + 84EB0C5E2EE2D4B3008FB007 /* ShaderStagesBits.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ShaderStagesBits.hpp; sourceTree = ""; }; + 84EB0C5F2EE2D4B3008FB007 /* ShaderStagesBits_JsonParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShaderStagesBits_JsonParser.cpp; sourceTree = ""; }; + 84EB0C602EE2D4B3008FB007 /* ShaderType.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ShaderType.hpp; sourceTree = ""; }; + 84EB0C612EE2D4B3008FB007 /* StencilMask.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StencilMask.hpp; sourceTree = ""; }; + 84EB0C622EE2D4B3008FB007 /* StencilOp.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StencilOp.hpp; sourceTree = ""; }; + 84EB0C632EE2D4B3008FB007 /* StencilOp_JsonParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StencilOp_JsonParser.cpp; sourceTree = ""; }; + 84EB0C642EE2D4B3008FB007 /* TextureFiltering.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TextureFiltering.hpp; sourceTree = ""; }; + 84EB0C652EE2D4B3008FB007 /* TextureFiltering_JsonParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureFiltering_JsonParser.cpp; sourceTree = ""; }; + 84EB0C662EE2D4B3008FB007 /* TextureFormat.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TextureFormat.hpp; sourceTree = ""; }; + 84EB0C672EE2D4B3008FB007 /* VertexField.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = VertexField.hpp; sourceTree = ""; }; + 84EB0C682EE2D4B3008FB007 /* VertexField_JsonParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VertexField_JsonParser.cpp; sourceTree = ""; }; + 84EB0C692EE2D4B3008FB007 /* VertexFieldType.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = VertexFieldType.hpp; sourceTree = ""; }; + 84EB0C6A2EE2D4B3008FB007 /* FixedPipelineStateDescription.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FixedPipelineStateDescription.cpp; sourceTree = ""; }; + 84EB0C6B2EE2D4B3008FB007 /* FixedPipelineStateDescription.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FixedPipelineStateDescription.hpp; sourceTree = ""; }; + 84EB0C6C2EE2D4B3008FB007 /* FogStateDescription.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FogStateDescription.cpp; sourceTree = ""; }; + 84EB0C6D2EE2D4B3008FB007 /* FogStateDescription.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FogStateDescription.hpp; sourceTree = ""; }; + 84EB0C6F2EE2D4B3008FB007 /* ErrorHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ErrorHandler.cpp; sourceTree = ""; }; + 84EB0C702EE2D4B3008FB007 /* ErrorHandler.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ErrorHandler.hpp; sourceTree = ""; }; + 84EB0C712EE2D4B3008FB007 /* TextureHelper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureHelper.cpp; sourceTree = ""; }; + 84EB0C722EE2D4B3008FB007 /* TextureHelper.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TextureHelper.hpp; sourceTree = ""; }; + 84EB0C732EE2D4B3008FB007 /* ImageDescription.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageDescription.cpp; sourceTree = ""; }; + 84EB0C742EE2D4B3008FB007 /* ImageDescription.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ImageDescription.hpp; sourceTree = ""; }; + 84EB0C762EE2D4B3008FB007 /* BlendState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BlendState.cpp; sourceTree = ""; }; + 84EB0C772EE2D4B3008FB007 /* BlendState.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = BlendState.hpp; sourceTree = ""; }; + 84EB0C782EE2D4B3008FB007 /* Buffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Buffer.cpp; sourceTree = ""; }; + 84EB0C792EE2D4B3008FB007 /* Buffer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Buffer.hpp; sourceTree = ""; }; + 84EB0C7A2EE2D4B3008FB007 /* ConstantBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConstantBuffer.cpp; sourceTree = ""; }; + 84EB0C7B2EE2D4B3008FB007 /* ConstantBuffer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ConstantBuffer.hpp; sourceTree = ""; }; + 84EB0C7C2EE2D4B3008FB007 /* ConstantBufferConstants.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ConstantBufferConstants.hpp; sourceTree = ""; }; + 84EB0C7D2EE2D4B3008FB007 /* ConstantBufferContainer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConstantBufferContainer.cpp; sourceTree = ""; }; + 84EB0C7E2EE2D4B3008FB007 /* ConstantBufferContainer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ConstantBufferContainer.hpp; sourceTree = ""; }; + 84EB0C7F2EE2D4B3008FB007 /* DepthStencilState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DepthStencilState.cpp; sourceTree = ""; }; + 84EB0C802EE2D4B3008FB007 /* DepthStencilState.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DepthStencilState.hpp; sourceTree = ""; }; + 84EB0C812EE2D4B3008FB007 /* FixedPipelineState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FixedPipelineState.cpp; sourceTree = ""; }; + 84EB0C822EE2D4B3008FB007 /* FixedPipelineState.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FixedPipelineState.hpp; sourceTree = ""; }; + 84EB0C832EE2D4B3008FB007 /* FogState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FogState.cpp; sourceTree = ""; }; + 84EB0C842EE2D4B3008FB007 /* FogState.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FogState.hpp; sourceTree = ""; }; + 84EB0C852EE2D4B3008FB007 /* ImmediateBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImmediateBuffer.cpp; sourceTree = ""; }; + 84EB0C862EE2D4B3008FB007 /* ImmediateBuffer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ImmediateBuffer.hpp; sourceTree = ""; }; + 84EB0C872EE2D4B3008FB007 /* RasterizerState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RasterizerState.cpp; sourceTree = ""; }; + 84EB0C882EE2D4B3008FB007 /* RasterizerState.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RasterizerState.hpp; sourceTree = ""; }; + 84EB0C892EE2D4B3008FB007 /* RenderContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderContext.cpp; sourceTree = ""; }; + 84EB0C8A2EE2D4B3008FB007 /* RenderContext.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RenderContext.hpp; sourceTree = ""; }; + 84EB0C8B2EE2D4B3008FB007 /* RenderDevice.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderDevice.cpp; sourceTree = ""; }; + 84EB0C8C2EE2D4B3008FB007 /* RenderDevice.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RenderDevice.hpp; sourceTree = ""; }; + 84EB0C8D2EE2D4B3008FB007 /* Shader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Shader.cpp; sourceTree = ""; }; + 84EB0C8E2EE2D4B3008FB007 /* Shader.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Shader.hpp; sourceTree = ""; }; + 84EB0C8F2EE2D4B3008FB007 /* ShaderConstant.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ShaderConstant.hpp; sourceTree = ""; }; + 84EB0C902EE2D4B3008FB007 /* ShaderConstantWithData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShaderConstantWithData.cpp; sourceTree = ""; }; + 84EB0C912EE2D4B3008FB007 /* ShaderConstantWithData.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ShaderConstantWithData.hpp; sourceTree = ""; }; + 84EB0C922EE2D4B3008FB007 /* ShaderProgram.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShaderProgram.cpp; sourceTree = ""; }; + 84EB0C932EE2D4B3008FB007 /* ShaderProgram.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ShaderProgram.hpp; sourceTree = ""; }; + 84EB0C942EE2D4B3008FB007 /* Texture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Texture.cpp; sourceTree = ""; }; + 84EB0C952EE2D4B3008FB007 /* Texture.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Texture.hpp; sourceTree = ""; }; + 84EB0CB62EE2D4B3008FB007 /* API_OGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = API_OGL.cpp; sourceTree = ""; }; + 84EB0CB72EE2D4B3008FB007 /* API_OGL.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = API_OGL.hpp; sourceTree = ""; }; + 84EB0CB82EE2D4B3008FB007 /* BlendStateOGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BlendStateOGL.cpp; sourceTree = ""; }; + 84EB0CB92EE2D4B3008FB007 /* BlendStateOGL.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = BlendStateOGL.hpp; sourceTree = ""; }; + 84EB0CBA2EE2D4B3008FB007 /* BufferOGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BufferOGL.cpp; sourceTree = ""; }; + 84EB0CBB2EE2D4B3008FB007 /* BufferOGL.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = BufferOGL.hpp; sourceTree = ""; }; + 84EB0CBC2EE2D4B3008FB007 /* ConstantBufferContainerOGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConstantBufferContainerOGL.cpp; sourceTree = ""; }; + 84EB0CBD2EE2D4B3008FB007 /* ConstantBufferContainerOGL.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ConstantBufferContainerOGL.hpp; sourceTree = ""; }; + 84EB0CBE2EE2D4B3008FB007 /* DepthStencilStateOGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DepthStencilStateOGL.cpp; sourceTree = ""; }; + 84EB0CBF2EE2D4B3008FB007 /* DepthStencilStateOGL.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DepthStencilStateOGL.hpp; sourceTree = ""; }; + 84EB0CC02EE2D4B3008FB007 /* FixedPipelineStateOGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FixedPipelineStateOGL.cpp; sourceTree = ""; }; + 84EB0CC12EE2D4B3008FB007 /* FixedPipelineStateOGL.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FixedPipelineStateOGL.hpp; sourceTree = ""; }; + 84EB0CC22EE2D4B3008FB007 /* FogStateOGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FogStateOGL.cpp; sourceTree = ""; }; + 84EB0CC32EE2D4B3008FB007 /* FogStateOGL.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FogStateOGL.hpp; sourceTree = ""; }; + 84EB0CC42EE2D4B3008FB007 /* GPUEventsOGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GPUEventsOGL.cpp; sourceTree = ""; }; + 84EB0CC52EE2D4B3008FB007 /* GPUEventsOGL.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = GPUEventsOGL.hpp; sourceTree = ""; }; + 84EB0CC62EE2D4B3008FB007 /* ImmediateBufferOGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImmediateBufferOGL.cpp; sourceTree = ""; }; + 84EB0CC72EE2D4B3008FB007 /* ImmediateBufferOGL.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ImmediateBufferOGL.hpp; sourceTree = ""; }; + 84EB0CC82EE2D4B3008FB007 /* ProfileSectionOGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProfileSectionOGL.cpp; sourceTree = ""; }; + 84EB0CC92EE2D4B3008FB007 /* ProfileSectionOGL.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ProfileSectionOGL.hpp; sourceTree = ""; }; + 84EB0CCA2EE2D4B3008FB007 /* RasterizerStateOGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RasterizerStateOGL.cpp; sourceTree = ""; }; + 84EB0CCB2EE2D4B3008FB007 /* RasterizerStateOGL.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RasterizerStateOGL.hpp; sourceTree = ""; }; + 84EB0CCC2EE2D4B3008FB007 /* RenderContextOGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderContextOGL.cpp; sourceTree = ""; }; + 84EB0CCD2EE2D4B3008FB007 /* RenderContextOGL.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RenderContextOGL.hpp; sourceTree = ""; }; + 84EB0CCE2EE2D4B3008FB007 /* RenderDeviceOGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderDeviceOGL.cpp; sourceTree = ""; }; + 84EB0CCF2EE2D4B3008FB007 /* RenderDeviceOGL.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RenderDeviceOGL.hpp; sourceTree = ""; }; + 84EB0CD02EE2D4B3008FB007 /* ResourceOGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceOGL.cpp; sourceTree = ""; }; + 84EB0CD12EE2D4B3008FB007 /* ResourceOGL.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ResourceOGL.hpp; sourceTree = ""; }; + 84EB0CD22EE2D4B3008FB007 /* ShaderConstantOGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShaderConstantOGL.cpp; sourceTree = ""; }; + 84EB0CD32EE2D4B3008FB007 /* ShaderConstantOGL.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ShaderConstantOGL.hpp; sourceTree = ""; }; + 84EB0CD42EE2D4B3008FB007 /* ShaderConstantWithDataOGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShaderConstantWithDataOGL.cpp; sourceTree = ""; }; + 84EB0CD52EE2D4B3008FB007 /* ShaderConstantWithDataOGL.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ShaderConstantWithDataOGL.hpp; sourceTree = ""; }; + 84EB0CD62EE2D4B3008FB007 /* ShaderOGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShaderOGL.cpp; sourceTree = ""; }; + 84EB0CD72EE2D4B3008FB007 /* ShaderOGL.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ShaderOGL.hpp; sourceTree = ""; }; + 84EB0CD82EE2D4B3008FB007 /* ShaderProgramOGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShaderProgramOGL.cpp; sourceTree = ""; }; + 84EB0CD92EE2D4B3008FB007 /* ShaderProgramOGL.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ShaderProgramOGL.hpp; sourceTree = ""; }; + 84EB0CDA2EE2D4B3008FB007 /* ShaderResourceOGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShaderResourceOGL.cpp; sourceTree = ""; }; + 84EB0CDB2EE2D4B3008FB007 /* ShaderResourceOGL.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ShaderResourceOGL.hpp; sourceTree = ""; }; + 84EB0CDC2EE2D4B3008FB007 /* ShaderUniformOGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShaderUniformOGL.cpp; sourceTree = ""; }; + 84EB0CDD2EE2D4B3008FB007 /* ShaderUniformOGL.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ShaderUniformOGL.hpp; sourceTree = ""; }; + 84EB0CDE2EE2D4B3008FB007 /* TextureOGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureOGL.cpp; sourceTree = ""; }; + 84EB0CDF2EE2D4B3008FB007 /* TextureOGL.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TextureOGL.hpp; sourceTree = ""; }; + 84EB0CE02EE2D4B3008FB007 /* RasterizerStateDescription.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RasterizerStateDescription.cpp; sourceTree = ""; }; + 84EB0CE12EE2D4B3008FB007 /* RasterizerStateDescription.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RasterizerStateDescription.hpp; sourceTree = ""; }; + 84EB0CE22EE2D4B3008FB007 /* ShaderStage.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ShaderStage.hpp; sourceTree = ""; }; + 84EB0CE32EE2D4B3008FB007 /* StencilFaceDescription.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StencilFaceDescription.cpp; sourceTree = ""; }; + 84EB0CE42EE2D4B3008FB007 /* StencilFaceDescription.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StencilFaceDescription.hpp; sourceTree = ""; }; + 84EB0CE52EE2D4B3008FB007 /* TextureDescription.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureDescription.cpp; sourceTree = ""; }; + 84EB0CE62EE2D4B3008FB007 /* TextureDescription.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TextureDescription.hpp; sourceTree = ""; }; + 84EB0CE72EE2D4B3008FB007 /* MaterialPtr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MaterialPtr.cpp; sourceTree = ""; }; + 84EB0CE82EE2D4B3008FB007 /* MaterialPtr.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MaterialPtr.hpp; sourceTree = ""; }; + 84EB0CE92EE2D4B3008FB007 /* MatrixStack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MatrixStack.cpp; sourceTree = ""; }; + 84EB0CEA2EE2D4B3008FB007 /* MatrixStack.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MatrixStack.hpp; sourceTree = ""; }; + 84EB0CEB2EE2D4B3008FB007 /* Mesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Mesh.cpp; sourceTree = ""; }; + 84EB0CEC2EE2D4B3008FB007 /* Mesh.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Mesh.hpp; sourceTree = ""; }; + 84EB0CED2EE2D4B3008FB007 /* PerFrameConstants.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerFrameConstants.cpp; sourceTree = ""; }; + 84EB0CEE2EE2D4B3008FB007 /* PerFrameConstants.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PerFrameConstants.hpp; sourceTree = ""; }; + 84EB0CF12EE2D4B3008FB007 /* Extensions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Extensions.cpp; sourceTree = ""; }; + 84EB0CF22EE2D4B3008FB007 /* Extensions.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Extensions.hpp; sourceTree = ""; }; + 84EB0CF32EE2D4B3008FB007 /* ShaderPrecision.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShaderPrecision.cpp; sourceTree = ""; }; + 84EB0CF42EE2D4B3008FB007 /* ShaderPrecision.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ShaderPrecision.hpp; sourceTree = ""; }; + 84EB0CF52EE2D4B3008FB007 /* PlatformDefinitions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformDefinitions.h; sourceTree = ""; }; + 84EB0CF62EE2D4B3008FB007 /* QuadIndexBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = QuadIndexBuffer.cpp; sourceTree = ""; }; + 84EB0CF72EE2D4B3008FB007 /* QuadIndexBuffer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = QuadIndexBuffer.hpp; sourceTree = ""; }; + 84EB0CF82EE2D4B3008FB007 /* RenderChunkConstants.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderChunkConstants.cpp; sourceTree = ""; }; + 84EB0CF92EE2D4B3008FB007 /* RenderChunkConstants.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RenderChunkConstants.hpp; sourceTree = ""; }; + 84EB0CFA2EE2D4B3008FB007 /* RenderContextImmediate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderContextImmediate.cpp; sourceTree = ""; }; + 84EB0CFB2EE2D4B3008FB007 /* RenderContextImmediate.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RenderContextImmediate.hpp; sourceTree = ""; }; + 84EB0CFC2EE2D4B3008FB007 /* RenderMaterial.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMaterial.cpp; sourceTree = ""; }; + 84EB0CFD2EE2D4B3008FB007 /* RenderMaterial.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RenderMaterial.hpp; sourceTree = ""; }; + 84EB0CFE2EE2D4B3008FB007 /* ShaderConstants.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShaderConstants.cpp; sourceTree = ""; }; + 84EB0CFF2EE2D4B3008FB007 /* ShaderConstants.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ShaderConstants.hpp; sourceTree = ""; }; + 84EB0D002EE2D4B3008FB007 /* ShaderGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShaderGroup.cpp; sourceTree = ""; }; + 84EB0D012EE2D4B3008FB007 /* ShaderGroup.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ShaderGroup.hpp; sourceTree = ""; }; + 84EB0D022EE2D4B3008FB007 /* ShaderGroupBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShaderGroupBase.cpp; sourceTree = ""; }; + 84EB0D032EE2D4B3008FB007 /* ShaderGroupBase.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ShaderGroupBase.hpp; sourceTree = ""; }; + 84EB0D042EE2D4B3008FB007 /* StencilRefObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StencilRefObject.cpp; sourceTree = ""; }; + 84EB0D052EE2D4B3008FB007 /* StencilRefObject.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StencilRefObject.hpp; sourceTree = ""; }; + 84EB0D062EE2D4B3008FB007 /* TextureGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureGroup.cpp; sourceTree = ""; }; + 84EB0D072EE2D4B3008FB007 /* TextureGroup.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TextureGroup.hpp; sourceTree = ""; }; + 84EB0D082EE2D4B3008FB007 /* TexturePtr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TexturePtr.cpp; sourceTree = ""; }; + 84EB0D092EE2D4B3008FB007 /* TexturePtr.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TexturePtr.hpp; sourceTree = ""; }; + 84EB0D0A2EE2D4B3008FB007 /* UniformMetaData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UniformMetaData.cpp; sourceTree = ""; }; + 84EB0D0B2EE2D4B3008FB007 /* UniformMetaData.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UniformMetaData.hpp; sourceTree = ""; }; + 84EB0D0C2EE2D4B3008FB007 /* VertexFormat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VertexFormat.cpp; sourceTree = ""; }; + 84EB0D0D2EE2D4B3008FB007 /* VertexFormat.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = VertexFormat.hpp; sourceTree = ""; }; + 84EB0D0E2EE2D4B3008FB007 /* WeatherConstants.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WeatherConstants.cpp; sourceTree = ""; }; + 84EB0D0F2EE2D4B3008FB007 /* WeatherConstants.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = WeatherConstants.hpp; sourceTree = ""; }; + 84EB0D102EE2D4B3008FB007 /* WorldConstants.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorldConstants.cpp; sourceTree = ""; }; + 84EB0D112EE2D4B3008FB007 /* WorldConstants.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = WorldConstants.hpp; sourceTree = ""; }; 84ED99D42AFF12D1003B6AF0 /* minecraftpe.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = minecraftpe.entitlements; sourceTree = ""; }; 84EDD07A2E76E2B600375AEF /* LegacyCPP.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = LegacyCPP.hpp; sourceTree = ""; }; 84EDD07B2E76E2B600375AEF /* LegacyCPP_Compat.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = LegacyCPP_Compat.hpp; sourceTree = ""; }; @@ -3158,7 +2761,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 84AAF6482AF18C0C00BD67F4 /* libOpenGL.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3222,14 +2824,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 84AAF6392AF18B9500BD67F4 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 84D9A30E2AF18EC000B00AD3 /* OpenGL.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; 84B8AEE02AF188D8008DE93D /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -3331,15 +2925,17 @@ 840DD57D2AC810620006A435 /* app */ = { isa = PBXGroup; children = ( - 840DD57F2AC810620006A435 /* App.hpp */, 840DD57E2AC810620006A435 /* App.cpp */, - 840DD5812AC810620006A435 /* AppPlatform.hpp */, + 840DD57F2AC810620006A435 /* App.hpp */, 840DD5802AC810620006A435 /* AppPlatform.cpp */, + 840DD5812AC810620006A435 /* AppPlatform.hpp */, + 84EB09942EE2CC25008FB007 /* AppPlatformListener.cpp */, + 84EB09952EE2CC25008FB007 /* AppPlatformListener.hpp */, 84A2FF152DB5B7B70090CE3E /* AssetFile.hpp */, - 840DD5832AC810620006A435 /* Minecraft.hpp */, 840DD5822AC810620006A435 /* Minecraft.cpp */, - 840DD5852AC810620006A435 /* NinecraftApp.hpp */, + 840DD5832AC810620006A435 /* Minecraft.hpp */, 840DD5842AC810620006A435 /* NinecraftApp.cpp */, + 840DD5852AC810620006A435 /* NinecraftApp.hpp */, ); path = app; sourceTree = ""; @@ -3352,6 +2948,9 @@ 840DD5972AC810620006A435 /* Gui.hpp */, 840DD5982AC810620006A435 /* GuiComponent.cpp */, 840DD5992AC810620006A435 /* GuiComponent.hpp */, + 84EB09982EE2CC3B008FB007 /* GuiElement.cpp */, + 84EB09992EE2CC3B008FB007 /* GuiElement.hpp */, + 84EB099A2EE2CC3B008FB007 /* IntRectangle.hpp */, 840DD59A2AC810620006A435 /* Screen.cpp */, 840DD59B2AC810620006A435 /* Screen.hpp */, 840DD59C2AC810620006A435 /* screens */, @@ -3428,36 +3027,8 @@ 840DD5BD2AC810620006A435 /* model */ = { isa = PBXGroup; children = ( - 84AA8C3D2B32F535003F5B82 /* ChickenModel.hpp */, - 84AA8C3C2B32F535003F5B82 /* ChickenModel.cpp */, - 84AA8C3F2B32F535003F5B82 /* CowModel.hpp */, - 84AA8C3E2B32F535003F5B82 /* CowModel.cpp */, - 84AA8C412B32F535003F5B82 /* CreeperModel.hpp */, - 84AA8C402B32F535003F5B82 /* CreeperModel.cpp */, - 840DD5BF2AC810620006A435 /* Cube.hpp */, - 840DD5BE2AC810620006A435 /* Cube.cpp */, - 840DD5C12AC810620006A435 /* HumanoidModel.hpp */, - 840DD5C02AC810620006A435 /* HumanoidModel.cpp */, - 840DD5C32AC810620006A435 /* Model.hpp */, - 840DD5C22AC810620006A435 /* Model.cpp */, - 84AA8C492B32F535003F5B82 /* ModelPart.hpp */, - 84AA8C482B32F535003F5B82 /* ModelPart.cpp */, - 84AA8C4B2B32F535003F5B82 /* PigModel.hpp */, - 84AA8C4A2B32F535003F5B82 /* PigModel.cpp */, - 840DD5C52AC810620006A435 /* PolygonQuad.hpp */, - 840DD5C42AC810620006A435 /* PolygonQuad.cpp */, - 84AA8C4F2B32F535003F5B82 /* QuadrupedModel.hpp */, - 84AA8C4E2B32F535003F5B82 /* QuadrupedModel.cpp */, - 84AA8C512B32F535003F5B82 /* SheepFurModel.hpp */, - 84AA8C502B32F535003F5B82 /* SheepFurModel.cpp */, - 84AA8C532B32F535003F5B82 /* SheepModel.hpp */, - 84AA8C522B32F535003F5B82 /* SheepModel.cpp */, - 84AA8C552B32F535003F5B82 /* SkeletonModel.hpp */, - 84AA8C542B32F535003F5B82 /* SkeletonModel.cpp */, - 84AA8C572B32F535003F5B82 /* SpiderModel.hpp */, - 84AA8C562B32F535003F5B82 /* SpiderModel.cpp */, - 84AA8C592B32F535003F5B82 /* ZombieModel.hpp */, - 84AA8C582B32F535003F5B82 /* ZombieModel.cpp */, + 84EB09A02EE2CC86008FB007 /* geom */, + 84EB09A82EE2CC86008FB007 /* models */, ); path = model; sourceTree = ""; @@ -3579,8 +3150,7 @@ 84CCBC3E2E6183F300E251AF /* DataIO.hpp */, 840DD6282AC810620006A435 /* Logger.cpp */, 840DD6292AC810620006A435 /* Logger.hpp */, - 840DD62B2AC810620006A435 /* Matrix.cpp */, - 840DD62C2AC810620006A435 /* Matrix.hpp */, + 84EB09FC2EE2CCC0008FB007 /* math */, 840DD62D2AC810620006A435 /* Mth.cpp */, 840DD62E2AC810620006A435 /* Mth.hpp */, 840DD62F2AC810620006A435 /* Random.cpp */, @@ -3591,6 +3161,7 @@ 840DD6342AC810620006A435 /* Timer.hpp */, 840DD6352AC810620006A435 /* Util.cpp */, 840DD6362AC810620006A435 /* Util.hpp */, + 84EB09FF2EE2CCC0008FB007 /* utility */, 840DD6372AC810620006A435 /* Utils.cpp */, 840DD6382AC810620006A435 /* Utils.hpp */, ); @@ -3685,7 +3256,60 @@ 840DD6522AC810620006A435 /* renderer */ = { isa = PBXGroup; children = ( + 84EB0C102EE2D4B2008FB007 /* Attribute.cpp */, + 84EB0C112EE2D4B2008FB007 /* Attribute.hpp */, + 84EB0C122EE2D4B2008FB007 /* ConstantBufferMetaData.cpp */, + 84EB0C132EE2D4B2008FB007 /* ConstantBufferMetaData.hpp */, + 84EB0C142EE2D4B2008FB007 /* ConstantBufferMetaDataManager.cpp */, + 84EB0C152EE2D4B2008FB007 /* ConstantBufferMetaDataManager.hpp */, + 84EB0C162EE2D4B2008FB007 /* EnableScissorTest.cpp */, + 84EB0C172EE2D4B2008FB007 /* EnableScissorTest.hpp */, + 84EB0C182EE2D4B2008FB007 /* EntityConstants.cpp */, + 84EB0C192EE2D4B2008FB007 /* EntityConstants.hpp */, 840DD6532AC810620006A435 /* GL */, + 84EB0C1A2EE2D4B2008FB007 /* GlobalConstantBufferManager.cpp */, + 84EB0C1B2EE2D4B2008FB007 /* GlobalConstantBufferManager.hpp */, + 84EB0C1C2EE2D4B2008FB007 /* GlobalConstantBuffers.cpp */, + 84EB0C1D2EE2D4B2008FB007 /* GlobalConstantBuffers.hpp */, + 84EB0C1E2EE2D4B2008FB007 /* hal */, + 84EB0CE72EE2D4B3008FB007 /* MaterialPtr.cpp */, + 84EB0CE82EE2D4B3008FB007 /* MaterialPtr.hpp */, + 84EB0CE92EE2D4B3008FB007 /* MatrixStack.cpp */, + 84EB0CEA2EE2D4B3008FB007 /* MatrixStack.hpp */, + 84EB0CEB2EE2D4B3008FB007 /* Mesh.cpp */, + 84EB0CEC2EE2D4B3008FB007 /* Mesh.hpp */, + 84EB0CED2EE2D4B3008FB007 /* PerFrameConstants.cpp */, + 84EB0CEE2EE2D4B3008FB007 /* PerFrameConstants.hpp */, + 84EB0CEF2EE2D4B3008FB007 /* platform */, + 84EB0CF52EE2D4B3008FB007 /* PlatformDefinitions.h */, + 84EB0CF62EE2D4B3008FB007 /* QuadIndexBuffer.cpp */, + 84EB0CF72EE2D4B3008FB007 /* QuadIndexBuffer.hpp */, + 84EB0CF82EE2D4B3008FB007 /* RenderChunkConstants.cpp */, + 84EB0CF92EE2D4B3008FB007 /* RenderChunkConstants.hpp */, + 84EB0CFA2EE2D4B3008FB007 /* RenderContextImmediate.cpp */, + 84EB0CFB2EE2D4B3008FB007 /* RenderContextImmediate.hpp */, + 84EB0CFC2EE2D4B3008FB007 /* RenderMaterial.cpp */, + 84EB0CFD2EE2D4B3008FB007 /* RenderMaterial.hpp */, + 84EB0CFE2EE2D4B3008FB007 /* ShaderConstants.cpp */, + 84EB0CFF2EE2D4B3008FB007 /* ShaderConstants.hpp */, + 84EB0D002EE2D4B3008FB007 /* ShaderGroup.cpp */, + 84EB0D012EE2D4B3008FB007 /* ShaderGroup.hpp */, + 84EB0D022EE2D4B3008FB007 /* ShaderGroupBase.cpp */, + 84EB0D032EE2D4B3008FB007 /* ShaderGroupBase.hpp */, + 84EB0D042EE2D4B3008FB007 /* StencilRefObject.cpp */, + 84EB0D052EE2D4B3008FB007 /* StencilRefObject.hpp */, + 84EB0D062EE2D4B3008FB007 /* TextureGroup.cpp */, + 84EB0D072EE2D4B3008FB007 /* TextureGroup.hpp */, + 84EB0D082EE2D4B3008FB007 /* TexturePtr.cpp */, + 84EB0D092EE2D4B3008FB007 /* TexturePtr.hpp */, + 84EB0D0A2EE2D4B3008FB007 /* UniformMetaData.cpp */, + 84EB0D0B2EE2D4B3008FB007 /* UniformMetaData.hpp */, + 84EB0D0C2EE2D4B3008FB007 /* VertexFormat.cpp */, + 84EB0D0D2EE2D4B3008FB007 /* VertexFormat.hpp */, + 84EB0D0E2EE2D4B3008FB007 /* WeatherConstants.cpp */, + 84EB0D0F2EE2D4B3008FB007 /* WeatherConstants.hpp */, + 84EB0D102EE2D4B3008FB007 /* WorldConstants.cpp */, + 84EB0D112EE2D4B3008FB007 /* WorldConstants.hpp */, ); path = renderer; sourceTree = ""; @@ -4116,7 +3740,6 @@ isa = PBXGroup; children = ( 840DD7322AC810620006A435 /* GL.hpp */, - 840DD7332AC810620006A435 /* GLExt.cpp */, 840DD7342AC810620006A435 /* glext.h */, 840DD7352AC810620006A435 /* readme.txt */, ); @@ -4535,139 +4158,6 @@ path = desktop; sourceTree = ""; }; - 8470AF422BE9B8B600BCA54E /* environment */ = { - isa = PBXGroup; - children = ( - 8470AF432BE9B8B600BCA54E /* clouds.png */, - ); - path = environment; - sourceTree = ""; - }; - 8477B3BC2C4DE77F004E1AC5 /* app */ = { - isa = PBXGroup; - children = ( - 8477B3BD2C4DE77F004E1AC5 /* ios */, - 8477B4042C4DE77F004E1AC5 /* launch */, - ); - path = app; - sourceTree = ""; - }; - 8477B3BD2C4DE77F004E1AC5 /* ios */ = { - isa = PBXGroup; - children = ( - 8477B3BE2C4DE77F004E1AC5 /* bg128.png */, - 8477B3BF2C4DE77F004E1AC5 /* bg64.png */, - 8477B3C02C4DE77F004E1AC5 /* dialog */, - 8477B3E12C4DE77F004E1AC5 /* dialog2 */, - 8477B3F52C4DE77F004E1AC5 /* icons */, - ); - path = ios; - sourceTree = ""; - }; - 8477B3C02C4DE77F004E1AC5 /* dialog */ = { - isa = PBXGroup; - children = ( - 8477B3C12C4DE77F004E1AC5 /* cancel_0.png */, - 8477B3C22C4DE77F004E1AC5 /* cancel_0_1.png */, - 8477B3C32C4DE77F004E1AC5 /* cancel_0_3.png */, - 8477B3C42C4DE77F004E1AC5 /* cancel_1.png */, - 8477B3C52C4DE77F004E1AC5 /* cancel_1_1.png */, - 8477B3C62C4DE77F004E1AC5 /* cancel_1_3.png */, - 8477B3C72C4DE77F004E1AC5 /* create_0.png */, - 8477B3C82C4DE77F004E1AC5 /* create_0_1.png */, - 8477B3C92C4DE77F004E1AC5 /* create_0_3.png */, - 8477B3CA2C4DE77F004E1AC5 /* create_1.png */, - 8477B3CB2C4DE77F004E1AC5 /* create_1_1.png */, - 8477B3CC2C4DE77F004E1AC5 /* create_1_3.png */, - 8477B3CD2C4DE77F004E1AC5 /* ipad */, - 8477B3D92C4DE77F004E1AC5 /* save_0.png */, - 8477B3DA2C4DE77F004E1AC5 /* save_0_3.png */, - 8477B3DB2C4DE77F004E1AC5 /* save_1.png */, - 8477B3DC2C4DE77F004E1AC5 /* save_1_3.png */, - 8477B3DD2C4DE77F004E1AC5 /* worldname_ipad.png */, - 8477B3DE2C4DE77F004E1AC5 /* worldname_ipad_3.png */, - 8477B3DF2C4DE77F004E1AC5 /* worldname_iphone.png */, - 8477B3E02C4DE77F004E1AC5 /* worldname_iphone_3.png */, - ); - path = dialog; - sourceTree = ""; - }; - 8477B3CD2C4DE77F004E1AC5 /* ipad */ = { - isa = PBXGroup; - children = ( - 8477B3CE2C4DE77F004E1AC5 /* cancel_0_4.png */, - 8477B3CF2C4DE77F004E1AC5 /* cancel_1_4.png */, - 8477B3D02C4DE77F004E1AC5 /* create_0_4.png */, - 8477B3D12C4DE77F004E1AC5 /* create_1_4.png */, - 8477B3D22C4DE77F004E1AC5 /* creative_0_4.png */, - 8477B3D32C4DE77F004E1AC5 /* creative_1_4.png */, - 8477B3D42C4DE77F004E1AC5 /* creative_3_4.png */, - 8477B3D52C4DE77F004E1AC5 /* survival_0_4.png */, - 8477B3D62C4DE77F004E1AC5 /* survival_1_4.png */, - 8477B3D72C4DE77F004E1AC5 /* survival_3_4.png */, - 8477B3D82C4DE77F004E1AC5 /* worldname_ipad_4.png */, - ); - path = ipad; - sourceTree = ""; - }; - 8477B3E12C4DE77F004E1AC5 /* dialog2 */ = { - isa = PBXGroup; - children = ( - 8477B3E22C4DE77F004E1AC5 /* cancel_0_1.png */, - 8477B3E32C4DE77F004E1AC5 /* cancel_0_3.png */, - 8477B3E42C4DE77F004E1AC5 /* cancel_1_1.png */, - 8477B3E52C4DE77F004E1AC5 /* cancel_1_3.png */, - 8477B3E62C4DE77F004E1AC5 /* create_0_1.png */, - 8477B3E72C4DE77F004E1AC5 /* create_0_3.png */, - 8477B3E82C4DE77F004E1AC5 /* create_1_1.png */, - 8477B3E92C4DE77F004E1AC5 /* create_1_3.png */, - 8477B3EA2C4DE77F004E1AC5 /* creative_0_3.png */, - 8477B3EB2C4DE77F004E1AC5 /* creative_1_3.png */, - 8477B3EC2C4DE77F004E1AC5 /* survival_0_3.png */, - 8477B3ED2C4DE77F004E1AC5 /* survival_1_3.png */, - 8477B3EE2C4DE77F004E1AC5 /* worldname.png */, - 8477B3EF2C4DE77F004E1AC5 /* worldname_3.png */, - 8477B3F02C4DE77F004E1AC5 /* worldname_ipad.png */, - 8477B3F12C4DE77F004E1AC5 /* worldname_ipad_3.png */, - 8477B3F22C4DE77F004E1AC5 /* worldname_iphone.png */, - 8477B3F32C4DE77F004E1AC5 /* worldname_iphone5_3.png */, - 8477B3F42C4DE77F004E1AC5 /* worldname_iphone_3.png */, - ); - path = dialog2; - sourceTree = ""; - }; - 8477B3F52C4DE77F004E1AC5 /* icons */ = { - isa = PBXGroup; - children = ( - 8477B3F62C4DE77F004E1AC5 /* Icon-72.png */, - 8477B3F72C4DE77F004E1AC5 /* Icon-72_lite.png */, - 8477B3F82C4DE77F004E1AC5 /* Icon-Small-50.png */, - 8477B3F92C4DE77F004E1AC5 /* Icon-Small-50_lite.png */, - 8477B3FA2C4DE77F004E1AC5 /* Icon-Small.png */, - 8477B3FB2C4DE77F004E1AC5 /* Icon-Small@2x.png */, - 8477B3FC2C4DE77F004E1AC5 /* Icon-Small@2x_lite.png */, - 8477B3FD2C4DE77F004E1AC5 /* Icon-Small_lite.png */, - 8477B3FE2C4DE77F004E1AC5 /* Icon.png */, - 8477B3FF2C4DE77F004E1AC5 /* Icon@2x.png */, - 8477B4002C4DE77F004E1AC5 /* Icon@2x_lite.png */, - 8477B4012C4DE77F004E1AC5 /* Icon_lite.png */, - 8477B4022C4DE77F004E1AC5 /* mcpe_ios_icon.png */, - 8477B4032C4DE77F004E1AC5 /* mcpe_lite_ios_icon.png */, - ); - path = icons; - sourceTree = ""; - }; - 8477B4042C4DE77F004E1AC5 /* launch */ = { - isa = PBXGroup; - children = ( - 8477B4052C4DE77F004E1AC5 /* Default-568h@2x.png */, - 8477B4062C4DE77F004E1AC5 /* Default-Landscape~ipad.png */, - 8477B4072C4DE77F004E1AC5 /* Default.png */, - 8477B4082C4DE77F004E1AC5 /* Default@2x.png */, - ); - path = launch; - sourceTree = ""; - }; 84790AEC2AD7DA410076F2A1 /* ios */ = { isa = PBXGroup; children = ( @@ -4713,10 +4203,10 @@ children = ( 84D6694E2B1EAE3C00B34FC1 /* Configuration */, 8489B31E2A86E428004CA8EC /* Frameworks */, + 8489B0982A86D4B2004CA8EC /* Products */, + 84D772262EE5180600701DCB /* assets */, 840DD5782AC810620006A435 /* compat */, - 84AD70F52AF20B6A00DA73F9 /* game */, 840DD9BF2AC810750006A435 /* platforms */, - 8489B0982A86D4B2004CA8EC /* Products */, 840DD57B2AC810620006A435 /* source */, 840DD72E2AC810620006A435 /* thirdparty */, 8470AF452BE9BC8500BCA54E /* GameMods.hpp */, @@ -4734,7 +4224,6 @@ 8406FD292AF1814500B09C1D /* libRenderer.a */, 84BF630B2AF1859D008A9995 /* libWorld.a */, 84B8AEE72AF188D8008DE93D /* libClient.a */, - 84AAF6422AF18B9500BD67F4 /* libOpenGL.a */, 84498A832AF18C7A005EF5A5 /* libZLib.a */, 84CCBC452E61849800E251AF /* libNBT.a */, 844496762E76685C008CF2E0 /* MinecraftClient.SDL1 */, @@ -4761,6 +4250,11 @@ 8492595D2AD8FDB70081F5B9 /* Supporting Files */ = { isa = PBXGroup; children = ( + 849371352EE51E6700081C5A /* Default-568h@2x.png */, + 849371362EE51E6700081C5A /* Default-Landscape~ipad.png */, + 849371372EE51E6700081C5A /* Default.png */, + 849371382EE51E6700081C5A /* Default@2x.png */, + 8493713D2EE51F2A00081C5A /* icon.png */, 8492595E2AD8FDCB0081F5B9 /* InfoPlist.strings */, 849259612AD8FDD10081F5B9 /* main.m */, 849259632AD8FDD90081F5B9 /* minecraftpe-Info.plist */, @@ -4768,27 +4262,6 @@ name = "Supporting Files"; sourceTree = ""; }; - 849488242C92844C006DB706 /* misc */ = { - isa = PBXGroup; - children = ( - 849488252C92844C006DB706 /* foliagecolor.png */, - 849488262C92844C006DB706 /* grasscolor.png */, - 849488272C92844C006DB706 /* pumpkinblur.png */, - 849488282C92844C006DB706 /* shadow.png */, - 849488292C92844C006DB706 /* vignette.png */, - ); - path = misc; - sourceTree = ""; - }; - 8494882F2C928459006DB706 /* terrain */ = { - isa = PBXGroup; - children = ( - 849488302C928459006DB706 /* moon.png */, - 849488312C928459006DB706 /* sun.png */, - ); - path = terrain; - sourceTree = ""; - }; 84AA8B472B32F39A003F5B82 /* path */ = { isa = PBXGroup; children = ( @@ -4807,51 +4280,57 @@ 84AA8B982B32F3F3003F5B82 /* renderer */ = { isa = PBXGroup; children = ( - 84AA8B9A2B32F3F3003F5B82 /* Chunk.hpp */, 84AA8B992B32F3F3003F5B82 /* Chunk.cpp */, - 84AA8B9C2B32F3F3003F5B82 /* Culler.hpp */, + 84AA8B9A2B32F3F3003F5B82 /* Chunk.hpp */, 84AA8B9B2B32F3F3003F5B82 /* Culler.cpp */, - 84AA8B9E2B32F3F3003F5B82 /* DynamicTexture.hpp */, + 84AA8B9C2B32F3F3003F5B82 /* Culler.hpp */, 84AA8B9D2B32F3F3003F5B82 /* DynamicTexture.cpp */, + 84AA8B9E2B32F3F3003F5B82 /* DynamicTexture.hpp */, 84AA8B9F2B32F3F3003F5B82 /* entity */, 84AA8BC42B32F3F3003F5B82 /* FireTexture.cpp */, - 84AA8BC62B32F3F3003F5B82 /* FoliageColor.hpp */, + 84EB09E02EE2CCA8008FB007 /* Fog.cpp */, + 84EB09E12EE2CCA8008FB007 /* Fog.hpp */, 84AA8BC52B32F3F3003F5B82 /* FoliageColor.cpp */, - 84AA8BC82B32F3F3003F5B82 /* Font.hpp */, + 84AA8BC62B32F3F3003F5B82 /* FoliageColor.hpp */, 84AA8BC72B32F3F3003F5B82 /* Font.cpp */, - 84AA8BCA2B32F3F3003F5B82 /* Frustum.hpp */, + 84AA8BC82B32F3F3003F5B82 /* Font.hpp */, 84AA8BC92B32F3F3003F5B82 /* Frustum.cpp */, - 84AA8BCC2B32F3F3003F5B82 /* FrustumCuller.hpp */, + 84AA8BCA2B32F3F3003F5B82 /* Frustum.hpp */, 84AA8BCB2B32F3F3003F5B82 /* FrustumCuller.cpp */, - 84AA8BCE2B32F3F3003F5B82 /* GameRenderer.hpp */, + 84AA8BCC2B32F3F3003F5B82 /* FrustumCuller.hpp */, 84AA8BCD2B32F3F3003F5B82 /* GameRenderer.cpp */, - 84AA8BD02B32F3F3003F5B82 /* GrassColor.hpp */, + 84AA8BCE2B32F3F3003F5B82 /* GameRenderer.hpp */, 84AA8BCF2B32F3F3003F5B82 /* GrassColor.cpp */, - 84AA8BD22B32F3F3003F5B82 /* ItemInHandRenderer.hpp */, + 84AA8BD02B32F3F3003F5B82 /* GrassColor.hpp */, 84AA8BD12B32F3F3003F5B82 /* ItemInHandRenderer.cpp */, + 84AA8BD22B32F3F3003F5B82 /* ItemInHandRenderer.hpp */, 84AA8BD32B32F3F3003F5B82 /* LavaSideTexture.cpp */, 84AA8BD42B32F3F3003F5B82 /* LavaTexture.cpp */, - 84AA8BD62B32F3F3003F5B82 /* LevelRenderer.hpp */, 84AA8BD52B32F3F3003F5B82 /* LevelRenderer.cpp */, - 849488352C9284DA006DB706 /* Lighting.hpp */, + 84AA8BD62B32F3F3003F5B82 /* LevelRenderer.hpp */, 849488342C9284DA006DB706 /* Lighting.cpp */, - 84AA8BD82B32F3F3003F5B82 /* LightLayer.hpp */, + 849488352C9284DA006DB706 /* Lighting.hpp */, 84AA8BD72B32F3F3003F5B82 /* LightLayer.cpp */, - 84AA8BDA2B32F3F3003F5B82 /* LightUpdate.hpp */, + 84AA8BD82B32F3F3003F5B82 /* LightLayer.hpp */, 84AA8BD92B32F3F3003F5B82 /* LightUpdate.cpp */, - 84AA8BDC2B32F3F3003F5B82 /* PatchManager.hpp */, + 84AA8BDA2B32F3F3003F5B82 /* LightUpdate.hpp */, 84AA8BDB2B32F3F3003F5B82 /* PatchManager.cpp */, - 84AA8BDE2B32F3F3003F5B82 /* RenderChunk.hpp */, + 84AA8BDC2B32F3F3003F5B82 /* PatchManager.hpp */, 84AA8BDD2B32F3F3003F5B82 /* RenderChunk.cpp */, - 84AA8BE02B32F3F3003F5B82 /* RenderList.hpp */, + 84AA8BDE2B32F3F3003F5B82 /* RenderChunk.hpp */, + 84EB09E22EE2CCA8008FB007 /* renderer */, 84AA8BDF2B32F3F3003F5B82 /* RenderList.cpp */, - 84AA8BE22B32F3F3003F5B82 /* Tesselator.hpp */, + 84AA8BE02B32F3F3003F5B82 /* RenderList.hpp */, + 84EB09E72EE2CCA8008FB007 /* ScreenRenderer.cpp */, + 84EB09E82EE2CCA8008FB007 /* ScreenRenderer.hpp */, 84AA8BE12B32F3F3003F5B82 /* Tesselator.cpp */, + 84AA8BE22B32F3F3003F5B82 /* Tesselator.hpp */, + 84EB09E92EE2CCA8008FB007 /* texture */, 84AA8BE32B32F3F3003F5B82 /* Texture.hpp */, - 84AA8BE52B32F3F3003F5B82 /* Textures.hpp */, 84AA8BE42B32F3F3003F5B82 /* Textures.cpp */, - 84AA8BE72B32F3F3003F5B82 /* TileRenderer.hpp */, + 84AA8BE52B32F3F3003F5B82 /* Textures.hpp */, 84AA8BE62B32F3F3003F5B82 /* TileRenderer.cpp */, + 84AA8BE72B32F3F3003F5B82 /* TileRenderer.hpp */, 84AA8BE82B32F3F3003F5B82 /* VertexPT.hpp */, 84AA8BE92B32F3F3003F5B82 /* WaterSideTexture.cpp */, 84AA8BEA2B32F3F3003F5B82 /* WaterTexture.cpp */, @@ -4947,565 +4426,6 @@ path = src; sourceTree = ""; }; - 84AD70F52AF20B6A00DA73F9 /* game */ = { - isa = PBXGroup; - children = ( - 84E001642AF3A28B009B9555 /* assets */, - 84AD710C2AF20B6A00DA73F9 /* readme.txt */, - ); - name = game; - path = ../../../../game; - sourceTree = ""; - }; - 84B1E06E2E051B7C00ED000A /* music */ = { - isa = PBXGroup; - children = ( - 84B1E06F2E051B7C00ED000A /* calm1.ogg */, - 84B1E0702E051B7C00ED000A /* calm2.ogg */, - 84B1E0712E051B7C00ED000A /* calm3.ogg */, - ); - path = music; - sourceTree = ""; - }; - 84B1E0722E051B7C00ED000A /* newmusic */ = { - isa = PBXGroup; - children = ( - 84B1E0732E051B7C00ED000A /* hal1.ogg */, - 84B1E0742E051B7C00ED000A /* hal2.ogg */, - 84B1E0752E051B7C00ED000A /* hal3.ogg */, - 84B1E0762E051B7C00ED000A /* hal4.ogg */, - 84B1E0772E051B7C00ED000A /* nuance1.ogg */, - 84B1E0782E051B7C00ED000A /* nuance2.ogg */, - 84B1E0792E051B7C00ED000A /* piano1.ogg */, - 84B1E07A2E051B7C00ED000A /* piano2.ogg */, - 84B1E07B2E051B7C00ED000A /* piano3.ogg */, - ); - path = newmusic; - sourceTree = ""; - }; - 84B1E07C2E051B7C00ED000A /* newsound */ = { - isa = PBXGroup; - children = ( - 84B1E07D2E051B7C00ED000A /* ambient */, - 84B1E0942E051B7C00ED000A /* damage */, - 84B1E09B2E051B7C00ED000A /* fire */, - 84B1E09E2E051B7C00ED000A /* liquid */, - 84B1E0A32E051B7C00ED000A /* mob */, - 84B1E15F2E051B7D00ED000A /* note */, - 84B1E1672E051B7D00ED000A /* portal */, - 84B1E16B2E051B7D00ED000A /* random */, - 84B1E18F2E051B7D00ED000A /* step */, - 84B1E1AC2E051B7D00ED000A /* tile */, - ); - path = newsound; - sourceTree = ""; - }; - 84B1E07D2E051B7C00ED000A /* ambient */ = { - isa = PBXGroup; - children = ( - 84B1E07E2E051B7C00ED000A /* cave */, - 84B1E08C2E051B7C00ED000A /* weather */, - ); - path = ambient; - sourceTree = ""; - }; - 84B1E07E2E051B7C00ED000A /* cave */ = { - isa = PBXGroup; - children = ( - 84B1E07F2E051B7C00ED000A /* cave1.ogg */, - 84B1E0802E051B7C00ED000A /* cave10.ogg */, - 84B1E0812E051B7C00ED000A /* cave11.ogg */, - 84B1E0822E051B7C00ED000A /* cave12.ogg */, - 84B1E0832E051B7C00ED000A /* cave13.ogg */, - 84B1E0842E051B7C00ED000A /* cave2.ogg */, - 84B1E0852E051B7C00ED000A /* cave3.ogg */, - 84B1E0862E051B7C00ED000A /* cave4.ogg */, - 84B1E0872E051B7C00ED000A /* cave5.ogg */, - 84B1E0882E051B7C00ED000A /* cave6.ogg */, - 84B1E0892E051B7C00ED000A /* cave7.ogg */, - 84B1E08A2E051B7C00ED000A /* cave8.ogg */, - 84B1E08B2E051B7C00ED000A /* cave9.ogg */, - ); - path = cave; - sourceTree = ""; - }; - 84B1E08C2E051B7C00ED000A /* weather */ = { - isa = PBXGroup; - children = ( - 84B1E08D2E051B7C00ED000A /* rain1.ogg */, - 84B1E08E2E051B7C00ED000A /* rain2.ogg */, - 84B1E08F2E051B7C00ED000A /* rain3.ogg */, - 84B1E0902E051B7C00ED000A /* rain4.ogg */, - 84B1E0912E051B7C00ED000A /* thunder1.ogg */, - 84B1E0922E051B7C00ED000A /* thunder2.ogg */, - 84B1E0932E051B7C00ED000A /* thunder3.ogg */, - ); - path = weather; - sourceTree = ""; - }; - 84B1E0942E051B7C00ED000A /* damage */ = { - isa = PBXGroup; - children = ( - 84B1E0952E051B7C00ED000A /* fallbig1.ogg */, - 84B1E0962E051B7C00ED000A /* fallbig2.ogg */, - 84B1E0972E051B7C00ED000A /* fallsmall.ogg */, - 84B1E0982E051B7C00ED000A /* hurtflesh1.ogg */, - 84B1E0992E051B7C00ED000A /* hurtflesh2.ogg */, - 84B1E09A2E051B7C00ED000A /* hurtflesh3.ogg */, - ); - path = damage; - sourceTree = ""; - }; - 84B1E09B2E051B7C00ED000A /* fire */ = { - isa = PBXGroup; - children = ( - 84B1E09C2E051B7C00ED000A /* fire.ogg */, - 84B1E09D2E051B7C00ED000A /* ignite.ogg */, - ); - path = fire; - sourceTree = ""; - }; - 84B1E09E2E051B7C00ED000A /* liquid */ = { - isa = PBXGroup; - children = ( - 84B1E09F2E051B7C00ED000A /* lava.ogg */, - 84B1E0A02E051B7C00ED000A /* lavapop.ogg */, - 84B1E0A12E051B7C00ED000A /* splash.ogg */, - 84B1E0A22E051B7C00ED000A /* water.ogg */, - ); - path = liquid; - sourceTree = ""; - }; - 84B1E0A32E051B7C00ED000A /* mob */ = { - isa = PBXGroup; - children = ( - 84B1E0A42E051B7C00ED000A /* blaze */, - 84B1E0AE2E051B7C00ED000A /* cat */, - 84B1E0BE2E051B7C00ED000A /* chicken1.ogg */, - 84B1E0BF2E051B7C00ED000A /* chicken2.ogg */, - 84B1E0C02E051B7C00ED000A /* chicken3.ogg */, - 84B1E0C12E051B7C00ED000A /* chickenhurt1.ogg */, - 84B1E0C22E051B7C00ED000A /* chickenhurt2.ogg */, - 84B1E0C32E051B7C00ED000A /* chickenplop.ogg */, - 84B1E0C42E051B7C00ED000A /* cow1.ogg */, - 84B1E0C52E051B7C00ED000A /* cow2.ogg */, - 84B1E0C62E051B7C00ED000A /* cow3.ogg */, - 84B1E0C72E051B7C00ED000A /* cow4.ogg */, - 84B1E0C82E051B7C00ED000A /* cowhurt1.ogg */, - 84B1E0C92E051B7C00ED000A /* cowhurt2.ogg */, - 84B1E0CA2E051B7C00ED000A /* cowhurt3.ogg */, - 84B1E0CB2E051B7C00ED000A /* creeper1.ogg */, - 84B1E0CC2E051B7C00ED000A /* creeper2.ogg */, - 84B1E0CD2E051B7C00ED000A /* creeper3.ogg */, - 84B1E0CE2E051B7C00ED000A /* creeper4.ogg */, - 84B1E0CF2E051B7C00ED000A /* creeperdeath.ogg */, - 84B1E0D02E051B7C00ED000A /* endermen */, - 84B1E0E22E051B7C00ED000A /* ghast */, - 84B1E0F32E051B7C00ED000A /* irongolem */, - 84B1E0FE2E051B7C00ED000A /* magmacube */, - 84B1E10C2E051B7C00ED000A /* pig1.ogg */, - 84B1E10D2E051B7C00ED000A /* pig2.ogg */, - 84B1E10E2E051B7C00ED000A /* pig3.ogg */, - 84B1E10F2E051B7C00ED000A /* pigdeath.ogg */, - 84B1E1102E051B7C00ED000A /* sheep1.ogg */, - 84B1E1112E051B7C00ED000A /* sheep2.ogg */, - 84B1E1122E051B7C00ED000A /* sheep3.ogg */, - 84B1E1132E051B7C00ED000A /* silverfish */, - 84B1E1202E051B7C00ED000A /* skeleton1.ogg */, - 84B1E1212E051B7C00ED000A /* skeleton2.ogg */, - 84B1E1222E051B7C00ED000A /* skeleton3.ogg */, - 84B1E1232E051B7D00ED000A /* skeletondeath.ogg */, - 84B1E1242E051B7D00ED000A /* skeletonhurt1.ogg */, - 84B1E1252E051B7D00ED000A /* skeletonhurt2.ogg */, - 84B1E1262E051B7D00ED000A /* skeletonhurt3.ogg */, - 84B1E1272E051B7D00ED000A /* skeletonhurt4.ogg */, - 84B1E1282E051B7D00ED000A /* slime1.ogg */, - 84B1E1292E051B7D00ED000A /* slime2.ogg */, - 84B1E12A2E051B7D00ED000A /* slime3.ogg */, - 84B1E12B2E051B7D00ED000A /* slime4.ogg */, - 84B1E12C2E051B7D00ED000A /* slime5.ogg */, - 84B1E12D2E051B7D00ED000A /* slimeattack1.ogg */, - 84B1E12E2E051B7D00ED000A /* slimeattack2.ogg */, - 84B1E12F2E051B7D00ED000A /* spider1.ogg */, - 84B1E1302E051B7D00ED000A /* spider2.ogg */, - 84B1E1312E051B7D00ED000A /* spider3.ogg */, - 84B1E1322E051B7D00ED000A /* spider4.ogg */, - 84B1E1332E051B7D00ED000A /* spiderdeath.ogg */, - 84B1E1342E051B7D00ED000A /* wolf */, - 84B1E1442E051B7D00ED000A /* zombie */, - 84B1E14D2E051B7D00ED000A /* zombie1.ogg */, - 84B1E14E2E051B7D00ED000A /* zombie2.ogg */, - 84B1E14F2E051B7D00ED000A /* zombie3.ogg */, - 84B1E1502E051B7D00ED000A /* zombiedeath.ogg */, - 84B1E1512E051B7D00ED000A /* zombiehurt1.ogg */, - 84B1E1522E051B7D00ED000A /* zombiehurt2.ogg */, - 84B1E1532E051B7D00ED000A /* zombiepig */, - ); - path = mob; - sourceTree = ""; - }; - 84B1E0A42E051B7C00ED000A /* blaze */ = { - isa = PBXGroup; - children = ( - 84B1E0A52E051B7C00ED000A /* breathe1.ogg */, - 84B1E0A62E051B7C00ED000A /* breathe2.ogg */, - 84B1E0A72E051B7C00ED000A /* breathe3.ogg */, - 84B1E0A82E051B7C00ED000A /* breathe4.ogg */, - 84B1E0A92E051B7C00ED000A /* death.ogg */, - 84B1E0AA2E051B7C00ED000A /* hit1.ogg */, - 84B1E0AB2E051B7C00ED000A /* hit2.ogg */, - 84B1E0AC2E051B7C00ED000A /* hit3.ogg */, - 84B1E0AD2E051B7C00ED000A /* hit4.ogg */, - ); - path = blaze; - sourceTree = ""; - }; - 84B1E0AE2E051B7C00ED000A /* cat */ = { - isa = PBXGroup; - children = ( - 84B1E0AF2E051B7C00ED000A /* hiss1.ogg */, - 84B1E0B02E051B7C00ED000A /* hiss2.ogg */, - 84B1E0B12E051B7C00ED000A /* hiss3.ogg */, - 84B1E0B22E051B7C00ED000A /* hitt1.ogg */, - 84B1E0B32E051B7C00ED000A /* hitt2.ogg */, - 84B1E0B42E051B7C00ED000A /* hitt3.ogg */, - 84B1E0B52E051B7C00ED000A /* meow1.ogg */, - 84B1E0B62E051B7C00ED000A /* meow2.ogg */, - 84B1E0B72E051B7C00ED000A /* meow3.ogg */, - 84B1E0B82E051B7C00ED000A /* meow4.ogg */, - 84B1E0B92E051B7C00ED000A /* purr1.ogg */, - 84B1E0BA2E051B7C00ED000A /* purr2.ogg */, - 84B1E0BB2E051B7C00ED000A /* purr3.ogg */, - 84B1E0BC2E051B7C00ED000A /* purreow1.ogg */, - 84B1E0BD2E051B7C00ED000A /* purreow2.ogg */, - ); - path = cat; - sourceTree = ""; - }; - 84B1E0D02E051B7C00ED000A /* endermen */ = { - isa = PBXGroup; - children = ( - 84B1E0D12E051B7C00ED000A /* death.ogg */, - 84B1E0D22E051B7C00ED000A /* hit1.ogg */, - 84B1E0D32E051B7C00ED000A /* hit2.ogg */, - 84B1E0D42E051B7C00ED000A /* hit3.ogg */, - 84B1E0D52E051B7C00ED000A /* hit4.ogg */, - 84B1E0D62E051B7C00ED000A /* idle1.ogg */, - 84B1E0D72E051B7C00ED000A /* idle2.ogg */, - 84B1E0D82E051B7C00ED000A /* idle3.ogg */, - 84B1E0D92E051B7C00ED000A /* idle4.ogg */, - 84B1E0DA2E051B7C00ED000A /* idle5.ogg */, - 84B1E0DB2E051B7C00ED000A /* portal.ogg */, - 84B1E0DC2E051B7C00ED000A /* portal2.ogg */, - 84B1E0DD2E051B7C00ED000A /* scream1.ogg */, - 84B1E0DE2E051B7C00ED000A /* scream2.ogg */, - 84B1E0DF2E051B7C00ED000A /* scream3.ogg */, - 84B1E0E02E051B7C00ED000A /* scream4.ogg */, - 84B1E0E12E051B7C00ED000A /* stare.ogg */, - ); - path = endermen; - sourceTree = ""; - }; - 84B1E0E22E051B7C00ED000A /* ghast */ = { - isa = PBXGroup; - children = ( - 84B1E0E32E051B7C00ED000A /* affectionate scream.ogg */, - 84B1E0E42E051B7C00ED000A /* charge.ogg */, - 84B1E0E52E051B7C00ED000A /* death.ogg */, - 84B1E0E62E051B7C00ED000A /* fireball4.ogg */, - 84B1E0E72E051B7C00ED000A /* moan1.ogg */, - 84B1E0E82E051B7C00ED000A /* moan2.ogg */, - 84B1E0E92E051B7C00ED000A /* moan3.ogg */, - 84B1E0EA2E051B7C00ED000A /* moan4.ogg */, - 84B1E0EB2E051B7C00ED000A /* moan5.ogg */, - 84B1E0EC2E051B7C00ED000A /* moan6.ogg */, - 84B1E0ED2E051B7C00ED000A /* moan7.ogg */, - 84B1E0EE2E051B7C00ED000A /* scream1.ogg */, - 84B1E0EF2E051B7C00ED000A /* scream2.ogg */, - 84B1E0F02E051B7C00ED000A /* scream3.ogg */, - 84B1E0F12E051B7C00ED000A /* scream4.ogg */, - 84B1E0F22E051B7C00ED000A /* scream5.ogg */, - ); - path = ghast; - sourceTree = ""; - }; - 84B1E0F32E051B7C00ED000A /* irongolem */ = { - isa = PBXGroup; - children = ( - 84B1E0F42E051B7C00ED000A /* death.ogg */, - 84B1E0F52E051B7C00ED000A /* hit1.ogg */, - 84B1E0F62E051B7C00ED000A /* hit2.ogg */, - 84B1E0F72E051B7C00ED000A /* hit3.ogg */, - 84B1E0F82E051B7C00ED000A /* hit4.ogg */, - 84B1E0F92E051B7C00ED000A /* throw.ogg */, - 84B1E0FA2E051B7C00ED000A /* walk1.ogg */, - 84B1E0FB2E051B7C00ED000A /* walk2.ogg */, - 84B1E0FC2E051B7C00ED000A /* walk3.ogg */, - 84B1E0FD2E051B7C00ED000A /* walk4.ogg */, - ); - path = irongolem; - sourceTree = ""; - }; - 84B1E0FE2E051B7C00ED000A /* magmacube */ = { - isa = PBXGroup; - children = ( - 84B1E0FF2E051B7C00ED000A /* big1.ogg */, - 84B1E1002E051B7C00ED000A /* big2.ogg */, - 84B1E1012E051B7C00ED000A /* big3.ogg */, - 84B1E1022E051B7C00ED000A /* big4.ogg */, - 84B1E1032E051B7C00ED000A /* jump1.ogg */, - 84B1E1042E051B7C00ED000A /* jump2.ogg */, - 84B1E1052E051B7C00ED000A /* jump3.ogg */, - 84B1E1062E051B7C00ED000A /* jump4.ogg */, - 84B1E1072E051B7C00ED000A /* small1.ogg */, - 84B1E1082E051B7C00ED000A /* small2.ogg */, - 84B1E1092E051B7C00ED000A /* small3.ogg */, - 84B1E10A2E051B7C00ED000A /* small4.ogg */, - 84B1E10B2E051B7C00ED000A /* small5.ogg */, - ); - path = magmacube; - sourceTree = ""; - }; - 84B1E1132E051B7C00ED000A /* silverfish */ = { - isa = PBXGroup; - children = ( - 84B1E1142E051B7C00ED000A /* hit1.ogg */, - 84B1E1152E051B7C00ED000A /* hit2.ogg */, - 84B1E1162E051B7C00ED000A /* hit3.ogg */, - 84B1E1172E051B7C00ED000A /* kill.ogg */, - 84B1E1182E051B7C00ED000A /* say1.ogg */, - 84B1E1192E051B7C00ED000A /* say2.ogg */, - 84B1E11A2E051B7C00ED000A /* say3.ogg */, - 84B1E11B2E051B7C00ED000A /* say4.ogg */, - 84B1E11C2E051B7C00ED000A /* step1.ogg */, - 84B1E11D2E051B7C00ED000A /* step2.ogg */, - 84B1E11E2E051B7C00ED000A /* step3.ogg */, - 84B1E11F2E051B7C00ED000A /* step4.ogg */, - ); - path = silverfish; - sourceTree = ""; - }; - 84B1E1342E051B7D00ED000A /* wolf */ = { - isa = PBXGroup; - children = ( - 84B1E1352E051B7D00ED000A /* bark1.ogg */, - 84B1E1362E051B7D00ED000A /* bark2.ogg */, - 84B1E1372E051B7D00ED000A /* bark3.ogg */, - 84B1E1382E051B7D00ED000A /* death.ogg */, - 84B1E1392E051B7D00ED000A /* growl1.ogg */, - 84B1E13A2E051B7D00ED000A /* growl2.ogg */, - 84B1E13B2E051B7D00ED000A /* growl3.ogg */, - 84B1E13C2E051B7D00ED000A /* howl1.ogg */, - 84B1E13D2E051B7D00ED000A /* howl2.ogg */, - 84B1E13E2E051B7D00ED000A /* hurt1.ogg */, - 84B1E13F2E051B7D00ED000A /* hurt2.ogg */, - 84B1E1402E051B7D00ED000A /* hurt3.ogg */, - 84B1E1412E051B7D00ED000A /* panting.ogg */, - 84B1E1422E051B7D00ED000A /* shake.ogg */, - 84B1E1432E051B7D00ED000A /* whine.ogg */, - ); - path = wolf; - sourceTree = ""; - }; - 84B1E1442E051B7D00ED000A /* zombie */ = { - isa = PBXGroup; - children = ( - 84B1E1452E051B7D00ED000A /* metal1.ogg */, - 84B1E1462E051B7D00ED000A /* metal2.ogg */, - 84B1E1472E051B7D00ED000A /* metal3.ogg */, - 84B1E1482E051B7D00ED000A /* wood1.ogg */, - 84B1E1492E051B7D00ED000A /* wood2.ogg */, - 84B1E14A2E051B7D00ED000A /* wood3.ogg */, - 84B1E14B2E051B7D00ED000A /* wood4.ogg */, - 84B1E14C2E051B7D00ED000A /* woodbreak.ogg */, - ); - path = zombie; - sourceTree = ""; - }; - 84B1E1532E051B7D00ED000A /* zombiepig */ = { - isa = PBXGroup; - children = ( - 84B1E1542E051B7D00ED000A /* zpig1.ogg */, - 84B1E1552E051B7D00ED000A /* zpig2.ogg */, - 84B1E1562E051B7D00ED000A /* zpig3.ogg */, - 84B1E1572E051B7D00ED000A /* zpig4.ogg */, - 84B1E1582E051B7D00ED000A /* zpigangry1.ogg */, - 84B1E1592E051B7D00ED000A /* zpigangry2.ogg */, - 84B1E15A2E051B7D00ED000A /* zpigangry3.ogg */, - 84B1E15B2E051B7D00ED000A /* zpigangry4.ogg */, - 84B1E15C2E051B7D00ED000A /* zpigdeath.ogg */, - 84B1E15D2E051B7D00ED000A /* zpighurt1.ogg */, - 84B1E15E2E051B7D00ED000A /* zpighurt2.ogg */, - ); - path = zombiepig; - sourceTree = ""; - }; - 84B1E15F2E051B7D00ED000A /* note */ = { - isa = PBXGroup; - children = ( - 84B1E1602E051B7D00ED000A /* bass.ogg */, - 84B1E1612E051B7D00ED000A /* bassattack.ogg */, - 84B1E1622E051B7D00ED000A /* bd.ogg */, - 84B1E1632E051B7D00ED000A /* harp.ogg */, - 84B1E1642E051B7D00ED000A /* hat.ogg */, - 84B1E1652E051B7D00ED000A /* pling.ogg */, - 84B1E1662E051B7D00ED000A /* snare.ogg */, - ); - path = note; - sourceTree = ""; - }; - 84B1E1672E051B7D00ED000A /* portal */ = { - isa = PBXGroup; - children = ( - 84B1E1682E051B7D00ED000A /* portal.ogg */, - 84B1E1692E051B7D00ED000A /* travel.ogg */, - 84B1E16A2E051B7D00ED000A /* trigger.ogg */, - ); - path = portal; - sourceTree = ""; - }; - 84B1E16B2E051B7D00ED000A /* random */ = { - isa = PBXGroup; - children = ( - 84B1E16C2E051B7D00ED000A /* bow.ogg */, - 84B1E16D2E051B7D00ED000A /* bowhit1.ogg */, - 84B1E16E2E051B7D00ED000A /* bowhit2.ogg */, - 84B1E16F2E051B7D00ED000A /* bowhit3.ogg */, - 84B1E1702E051B7D00ED000A /* bowhit4.ogg */, - 84B1E1712E051B7D00ED000A /* break.ogg */, - 84B1E1722E051B7D00ED000A /* breath.ogg */, - 84B1E1732E051B7D00ED000A /* burp.ogg */, - 84B1E1742E051B7D00ED000A /* chestclosed.ogg */, - 84B1E1752E051B7D00ED000A /* chestopen.ogg */, - 84B1E1762E051B7D00ED000A /* click.ogg */, - 84B1E1772E051B7D00ED000A /* door_close.ogg */, - 84B1E1782E051B7D00ED000A /* door_open.ogg */, - 84B1E1792E051B7D00ED000A /* drink.ogg */, - 84B1E17A2E051B7D00ED000A /* drr.ogg */, - 84B1E17B2E051B7D00ED000A /* eat1.ogg */, - 84B1E17C2E051B7D00ED000A /* eat2.ogg */, - 84B1E17D2E051B7D00ED000A /* eat3.ogg */, - 84B1E17E2E051B7D00ED000A /* explode.ogg */, - 84B1E17F2E051B7D00ED000A /* explode1.ogg */, - 84B1E1802E051B7D00ED000A /* explode2.ogg */, - 84B1E1812E051B7D00ED000A /* explode3.ogg */, - 84B1E1822E051B7D00ED000A /* explode4.ogg */, - 84B1E1832E051B7D00ED000A /* fizz.ogg */, - 84B1E1842E051B7D00ED000A /* fuse.ogg */, - 84B1E1852E051B7D00ED000A /* glass1.ogg */, - 84B1E1862E051B7D00ED000A /* glass2.ogg */, - 84B1E1872E051B7D00ED000A /* glass3.ogg */, - 84B1E1882E051B7D00ED000A /* hurt.ogg */, - 84B1E1892E051B7D00ED000A /* levelup.ogg */, - 84B1E18A2E051B7D00ED000A /* old_explode.ogg */, - 84B1E18B2E051B7D00ED000A /* orb.ogg */, - 84B1E18C2E051B7D00ED000A /* pop.ogg */, - 84B1E18D2E051B7D00ED000A /* splash.ogg */, - 84B1E18E2E051B7D00ED000A /* wood click.ogg */, - ); - path = random; - sourceTree = ""; - }; - 84B1E18F2E051B7D00ED000A /* step */ = { - isa = PBXGroup; - children = ( - 84B1E1902E051B7D00ED000A /* cloth1.ogg */, - 84B1E1912E051B7D00ED000A /* cloth2.ogg */, - 84B1E1922E051B7D00ED000A /* cloth3.ogg */, - 84B1E1932E051B7D00ED000A /* cloth4.ogg */, - 84B1E1942E051B7D00ED000A /* grass1.ogg */, - 84B1E1952E051B7D00ED000A /* grass2.ogg */, - 84B1E1962E051B7D00ED000A /* grass3.ogg */, - 84B1E1972E051B7D00ED000A /* grass4.ogg */, - 84B1E1982E051B7D00ED000A /* gravel1.ogg */, - 84B1E1992E051B7D00ED000A /* gravel2.ogg */, - 84B1E19A2E051B7D00ED000A /* gravel3.ogg */, - 84B1E19B2E051B7D00ED000A /* gravel4.ogg */, - 84B1E19C2E051B7D00ED000A /* sand1.ogg */, - 84B1E19D2E051B7D00ED000A /* sand2.ogg */, - 84B1E19E2E051B7D00ED000A /* sand3.ogg */, - 84B1E19F2E051B7D00ED000A /* sand4.ogg */, - 84B1E1A02E051B7D00ED000A /* snow1.ogg */, - 84B1E1A12E051B7D00ED000A /* snow2.ogg */, - 84B1E1A22E051B7D00ED000A /* snow3.ogg */, - 84B1E1A32E051B7D00ED000A /* snow4.ogg */, - 84B1E1A42E051B7D00ED000A /* stone1.ogg */, - 84B1E1A52E051B7D00ED000A /* stone2.ogg */, - 84B1E1A62E051B7D00ED000A /* stone3.ogg */, - 84B1E1A72E051B7D00ED000A /* stone4.ogg */, - 84B1E1A82E051B7D00ED000A /* wood1.ogg */, - 84B1E1A92E051B7D00ED000A /* wood2.ogg */, - 84B1E1AA2E051B7D00ED000A /* wood3.ogg */, - 84B1E1AB2E051B7D00ED000A /* wood4.ogg */, - ); - path = step; - sourceTree = ""; - }; - 84B1E1AC2E051B7D00ED000A /* tile */ = { - isa = PBXGroup; - children = ( - 84B1E1AD2E051B7D00ED000A /* piston */, - ); - path = tile; - sourceTree = ""; - }; - 84B1E1AD2E051B7D00ED000A /* piston */ = { - isa = PBXGroup; - children = ( - 84B1E1AE2E051B7D00ED000A /* in.ogg */, - 84B1E1AF2E051B7D00ED000A /* out.ogg */, - ); - path = piston; - sourceTree = ""; - }; - 84B1E1B02E051B7D00ED000A /* sound */ = { - isa = PBXGroup; - children = ( - 84B1E1B12E051B7D00ED000A /* step */, - ); - path = sound; - sourceTree = ""; - }; - 84B1E1B12E051B7D00ED000A /* step */ = { - isa = PBXGroup; - children = ( - 84B1E1B22E051B7D00ED000A /* grass1.ogg */, - 84B1E1B32E051B7D00ED000A /* grass2.ogg */, - 84B1E1B42E051B7D00ED000A /* grass3.ogg */, - 84B1E1B52E051B7D00ED000A /* grass4.ogg */, - 84B1E1B62E051B7D00ED000A /* gravel1.ogg */, - 84B1E1B72E051B7D00ED000A /* gravel2.ogg */, - 84B1E1B82E051B7D00ED000A /* gravel3.ogg */, - 84B1E1B92E051B7D00ED000A /* gravel4.ogg */, - 84B1E1BA2E051B7D00ED000A /* stone1.ogg */, - 84B1E1BB2E051B7D00ED000A /* stone2.ogg */, - 84B1E1BC2E051B7D00ED000A /* stone3.ogg */, - 84B1E1BD2E051B7D00ED000A /* stone4.ogg */, - 84B1E1BE2E051B7D00ED000A /* wood1.ogg */, - 84B1E1BF2E051B7D00ED000A /* wood2.ogg */, - 84B1E1C02E051B7D00ED000A /* wood3.ogg */, - 84B1E1C12E051B7D00ED000A /* wood4.ogg */, - ); - path = step; - sourceTree = ""; - }; - 84C208502AF88A5000BAE438 /* patches */ = { - isa = PBXGroup; - children = ( - 84E1C9B52E7FDAE3007D2F5D /* birch_sapling.png */, - 84E1C9B62E7FDAE3007D2F5D /* dead_bush.png */, - 84E1C9B72E7FDAE3007D2F5D /* fern.png */, - 84E1C9B82E7FDAE3007D2F5D /* spruce_sapling.png */, - 84E1C9B92E7FDAE3007D2F5D /* tall_grass.png */, - 84C208512AF88A5000BAE438 /* grass_side_transparent.png */, - 84E78C8B2B58BB7400D515EF /* n_rocket.png */, - 84E78C892B58BB7400D515EF /* n_rocket_launched.png */, - 84E78C8A2B58BB7400D515EF /* n_rocket_launcher.png */, - 84C208522AF88A5000BAE438 /* patch_data.txt */, - ); - path = patches; - sourceTree = ""; - }; 84CCBC4E2E61857800E251AF /* nbt */ = { isa = PBXGroup; children = ( @@ -5554,131 +4474,355 @@ name = Configuration; sourceTree = ""; }; - 84E001642AF3A28B009B9555 /* assets */ = { + 84E105F52E85155F00FAB6C5 /* base */ = { + isa = PBXGroup; + children = ( + 84E105F62E85157F00FAB6C5 /* AppPlatform_sdl.cpp */, + 84E105F72E85157F00FAB6C5 /* AppPlatform_sdl.hpp */, + ); + path = base; + sourceTree = ""; + }; + 84E8DCE22E849A1600B30789 /* sdl2 */ = { isa = PBXGroup; children = ( - 8477B3BC2C4DE77F004E1AC5 /* app */, - 8470AF422BE9B8B600BCA54E /* environment */, - 84E001652AF3A28B009B9555 /* font */, - 84E001682AF3A28B009B9555 /* gui */, - 84E0018A2AF3A28B009B9555 /* icon.png */, - 84E0018B2AF3A28B009B9555 /* item */, - 849488242C92844C006DB706 /* misc */, - 84E0018D2AF3A28B009B9555 /* mob */, - 84B1E06E2E051B7C00ED000A /* music */, - 84B1E0722E051B7C00ED000A /* newmusic */, - 84B1E07C2E051B7C00ED000A /* newsound */, - 84E0018F2AF3A28B009B9555 /* particles.png */, - 84C208502AF88A5000BAE438 /* patches */, - 84E001902AF3A28B009B9555 /* readme.txt */, - 84B1E1B02E051B7D00ED000A /* sound */, - 8494882F2C928459006DB706 /* terrain */, - 84E001912AF3A28B009B9555 /* terrain.png */, - ); - path = assets; + 841DD8712AF8AA7A00AA3B66 /* base */, + 84EAE8F02AF1EAFA000894E8 /* CMakeLists.txt */, + 841DD8742AF8AA7A00AA3B66 /* desktop */, + 84EAE8F12AF1EAFA000894E8 /* main.cpp */, + ); + path = sdl2; sourceTree = ""; }; - 84E001652AF3A28B009B9555 /* font */ = { + 84EAE8E82AF1EAFA000894E8 /* sdl */ = { isa = PBXGroup; children = ( - 84E001672AF3A28B009B9555 /* default8.png */, + 84E105F52E85155F00FAB6C5 /* base */, + 8444968E2E766960008CF2E0 /* sdl1 */, + 84E8DCE22E849A1600B30789 /* sdl2 */, ); - path = font; + path = sdl; sourceTree = ""; }; - 84E001682AF3A28B009B9555 /* gui */ = { + 84EB09A02EE2CC86008FB007 /* geom */ = { isa = PBXGroup; children = ( - 84E001692AF3A28B009B9555 /* background */, - 84E001702AF3A28B009B9555 /* background.png */, - 84E78C8F2B58C18C00D515EF /* black.png */, - 84E001762AF3A28B009B9555 /* default_world.png */, - 84E001782AF3A28B009B9555 /* feedback_fill.png */, - 84E001792AF3A28B009B9555 /* feedback_outer.png */, - 84E0017A2AF3A28B009B9555 /* gui.png */, - 84E0017B2AF3A28B009B9555 /* gui_blocks.png */, - 84AA8C782B32F578003F5B82 /* gui_custom.png */, - 84E0017C2AF3A28B009B9555 /* icons.png */, - 84E0017E2AF3A28B009B9555 /* items.png */, - 84E001882AF3A28B009B9555 /* title.png */, + 84EB09A12EE2CC86008FB007 /* Cube.cpp */, + 84EB09A22EE2CC86008FB007 /* Cube.hpp */, + 84EB09A32EE2CC86008FB007 /* ModelPart.cpp */, + 84EB09A42EE2CC86008FB007 /* ModelPart.hpp */, + 84EB09A52EE2CC86008FB007 /* PolygonQuad.cpp */, + 84EB09A62EE2CC86008FB007 /* PolygonQuad.hpp */, + 84EB09A72EE2CC86008FB007 /* TextureOffset.hpp */, + ); + path = geom; + sourceTree = ""; + }; + 84EB09A82EE2CC86008FB007 /* models */ = { + isa = PBXGroup; + children = ( + 84EB09A92EE2CC86008FB007 /* ChickenModel.cpp */, + 84EB09AA2EE2CC86008FB007 /* ChickenModel.hpp */, + 84EB09AB2EE2CC86008FB007 /* CowModel.cpp */, + 84EB09AC2EE2CC86008FB007 /* CowModel.hpp */, + 84EB09AD2EE2CC86008FB007 /* CreeperModel.cpp */, + 84EB09AE2EE2CC86008FB007 /* CreeperModel.hpp */, + 84EB09AF2EE2CC86008FB007 /* HumanoidModel.cpp */, + 84EB09B02EE2CC86008FB007 /* HumanoidModel.hpp */, + 84EB09B12EE2CC86008FB007 /* Model.cpp */, + 84EB09B22EE2CC86008FB007 /* Model.hpp */, + 84EB09B32EE2CC86008FB007 /* PigModel.cpp */, + 84EB09B42EE2CC86008FB007 /* PigModel.hpp */, + 84EB09B52EE2CC86008FB007 /* QuadrupedModel.cpp */, + 84EB09B62EE2CC86008FB007 /* QuadrupedModel.hpp */, + 84EB09B72EE2CC86008FB007 /* SheepFurModel.cpp */, + 84EB09B82EE2CC86008FB007 /* SheepFurModel.hpp */, + 84EB09B92EE2CC86008FB007 /* SheepModel.cpp */, + 84EB09BA2EE2CC86008FB007 /* SheepModel.hpp */, + 84EB09BB2EE2CC86008FB007 /* SkeletonModel.cpp */, + 84EB09BC2EE2CC86008FB007 /* SkeletonModel.hpp */, + 84EB09BD2EE2CC86008FB007 /* SpiderModel.cpp */, + 84EB09BE2EE2CC86008FB007 /* SpiderModel.hpp */, + 84EB09BF2EE2CC86008FB007 /* ZombieModel.cpp */, + 84EB09C02EE2CC86008FB007 /* ZombieModel.hpp */, + ); + path = models; + sourceTree = ""; + }; + 84EB09E22EE2CCA8008FB007 /* renderer */ = { + isa = PBXGroup; + children = ( + 84EB09E32EE2CCA8008FB007 /* EntityShaderManager.cpp */, + 84EB09E42EE2CCA8008FB007 /* EntityShaderManager.hpp */, + 84EB09E52EE2CCA8008FB007 /* RenderMaterialGroup.cpp */, + 84EB09E62EE2CCA8008FB007 /* RenderMaterialGroup.hpp */, ); - path = gui; + path = renderer; sourceTree = ""; }; - 84E001692AF3A28B009B9555 /* background */ = { + 84EB09E92EE2CCA8008FB007 /* texture */ = { isa = PBXGroup; children = ( - 84E0016A2AF3A28B009B9555 /* panorama_0.png */, - 84E0016B2AF3A28B009B9555 /* panorama_1.png */, - 84E0016C2AF3A28B009B9555 /* panorama_2.png */, - 84E0016D2AF3A28B009B9555 /* panorama_3.png */, - 84E0016E2AF3A28B009B9555 /* panorama_4.png */, - 84E0016F2AF3A28B009B9555 /* panorama_5.png */, - ); - path = background; + 84EB09EA2EE2CCA8008FB007 /* ColorSpace.hpp */, + 84EB09EB2EE2CCA8008FB007 /* ImageData.cpp */, + 84EB09EC2EE2CCA8008FB007 /* ImageData.hpp */, + 84EB09ED2EE2CCA8008FB007 /* TextureData.cpp */, + 84EB09EE2EE2CCA8008FB007 /* TextureData.hpp */, + ); + path = texture; sourceTree = ""; }; - 84E0018B2AF3A28B009B9555 /* item */ = { + 84EB09FC2EE2CCC0008FB007 /* math */ = { isa = PBXGroup; children = ( - 84E0018C2AF3A28B009B9555 /* camera.png */, + 84EB09FD2EE2CCC0008FB007 /* Color.cpp */, + 84EB09FE2EE2CCC0008FB007 /* Color.hpp */, ); - path = item; + path = math; sourceTree = ""; }; - 84E0018D2AF3A28B009B9555 /* mob */ = { + 84EB09FF2EE2CCC0008FB007 /* utility */ = { isa = PBXGroup; children = ( - 84E0018E2AF3A28B009B9555 /* char.png */, - 84B1E0412E050D2500ED000A /* chicken.png */, - 84B1E0422E050D2500ED000A /* cow.png */, - 84B1E0432E050D2500ED000A /* creeper.png */, - 84B1E0452E050D2500ED000A /* ghast.png */, - 84B1E0442E050D2500ED000A /* ghast_fire.png */, - 84B1E0462E050D2500ED000A /* pig.png */, - 84B1E0472E050D2500ED000A /* pigman.png */, - 84B1E0482E050D2500ED000A /* pigzombie.png */, - 84B1E0492E050D2500ED000A /* saddle.png */, - 84B1E04B2E050D2500ED000A /* sheep.png */, - 84B1E04A2E050D2500ED000A /* sheep_fur.png */, - 84B1E04C2E050D2500ED000A /* skeleton.png */, - 84B1E04D2E050D2500ED000A /* slime.png */, - 84B1E04F2E050D2500ED000A /* spider.png */, - 84B1E04E2E050D2500ED000A /* spider_eyes.png */, - 84B1E0502E050D2500ED000A /* squid.png */, - 84B1E0512E050D2500ED000A /* zombie.png */, - ); - path = mob; + 84EB0A002EE2CCC0008FB007 /* AlignmentHelper.cpp */, + 84EB0A012EE2CCC0008FB007 /* AlignmentHelper.hpp */, + 84EB0A022EE2CCC0008FB007 /* InheritanceTree.hpp */, + 84EB0A032EE2CCC0008FB007 /* JsonParser.cpp */, + 84EB0A042EE2CCC0008FB007 /* JsonParser.hpp */, + 84EB0A052EE2CCC0008FB007 /* Singleton.cpp */, + 84EB0A062EE2CCC0008FB007 /* Singleton.hpp */, + ); + path = utility; sourceTree = ""; }; - 84E105F52E85155F00FAB6C5 /* base */ = { + 84EB0C1E2EE2D4B2008FB007 /* hal */ = { isa = PBXGroup; children = ( - 84E105F62E85157F00FAB6C5 /* AppPlatform_sdl.cpp */, - 84E105F72E85157F00FAB6C5 /* AppPlatform_sdl.hpp */, + 84EB0C1F2EE2D4B2008FB007 /* base */, + 84EB0C482EE2D4B3008FB007 /* BlendStateDescription.cpp */, + 84EB0C492EE2D4B3008FB007 /* BlendStateDescription.hpp */, + 84EB0C4A2EE2D4B3008FB007 /* DepthStencilStateDescription.cpp */, + 84EB0C4B2EE2D4B3008FB007 /* DepthStencilStateDescription.hpp */, + 84EB0C4C2EE2D4B3008FB007 /* enums */, + 84EB0C6A2EE2D4B3008FB007 /* FixedPipelineStateDescription.cpp */, + 84EB0C6B2EE2D4B3008FB007 /* FixedPipelineStateDescription.hpp */, + 84EB0C6C2EE2D4B3008FB007 /* FogStateDescription.cpp */, + 84EB0C6D2EE2D4B3008FB007 /* FogStateDescription.hpp */, + 84EB0C6E2EE2D4B3008FB007 /* helpers */, + 84EB0C732EE2D4B3008FB007 /* ImageDescription.cpp */, + 84EB0C742EE2D4B3008FB007 /* ImageDescription.hpp */, + 84EB0C752EE2D4B3008FB007 /* interface */, + 84EB0CB52EE2D4B3008FB007 /* ogl */, + 84EB0CE02EE2D4B3008FB007 /* RasterizerStateDescription.cpp */, + 84EB0CE12EE2D4B3008FB007 /* RasterizerStateDescription.hpp */, + 84EB0CE22EE2D4B3008FB007 /* ShaderStage.hpp */, + 84EB0CE32EE2D4B3008FB007 /* StencilFaceDescription.cpp */, + 84EB0CE42EE2D4B3008FB007 /* StencilFaceDescription.hpp */, + 84EB0CE52EE2D4B3008FB007 /* TextureDescription.cpp */, + 84EB0CE62EE2D4B3008FB007 /* TextureDescription.hpp */, + ); + path = hal; + sourceTree = ""; + }; + 84EB0C1F2EE2D4B2008FB007 /* base */ = { + isa = PBXGroup; + children = ( + 84EB0C202EE2D4B2008FB007 /* BlendStateBase.cpp */, + 84EB0C212EE2D4B2008FB007 /* BlendStateBase.hpp */, + 84EB0C222EE2D4B2008FB007 /* BufferBase.cpp */, + 84EB0C232EE2D4B2008FB007 /* BufferBase.hpp */, + 84EB0C242EE2D4B2008FB007 /* ConstantBufferBase.cpp */, + 84EB0C252EE2D4B2008FB007 /* ConstantBufferBase.hpp */, + 84EB0C262EE2D4B2008FB007 /* ConstantBufferConstantsBase.cpp */, + 84EB0C272EE2D4B2008FB007 /* ConstantBufferConstantsBase.hpp */, + 84EB0C282EE2D4B2008FB007 /* ConstantBufferContainerBase.cpp */, + 84EB0C292EE2D4B2008FB007 /* ConstantBufferContainerBase.hpp */, + 84EB0C2A2EE2D4B2008FB007 /* DepthStencilStateBase.cpp */, + 84EB0C2B2EE2D4B2008FB007 /* DepthStencilStateBase.hpp */, + 84EB0C2C2EE2D4B2008FB007 /* FixedPipelineStateBase.cpp */, + 84EB0C2D2EE2D4B2008FB007 /* FixedPipelineStateBase.hpp */, + 84EB0C2E2EE2D4B2008FB007 /* FogStateBase.cpp */, + 84EB0C2F2EE2D4B2008FB007 /* FogStateBase.hpp */, + 84EB0C302EE2D4B2008FB007 /* FrameBufferObjectBase.cpp */, + 84EB0C312EE2D4B2008FB007 /* FrameBufferObjectBase.hpp */, + 84EB0C322EE2D4B2008FB007 /* ImmediateBufferBase.cpp */, + 84EB0C332EE2D4B2008FB007 /* ImmediateBufferBase.hpp */, + 84EB0C342EE2D4B2008FB007 /* RasterizerStateBase.cpp */, + 84EB0C352EE2D4B2008FB007 /* RasterizerStateBase.hpp */, + 84EB0C362EE2D4B2008FB007 /* RenderContextBase.cpp */, + 84EB0C372EE2D4B2008FB007 /* RenderContextBase.hpp */, + 84EB0C382EE2D4B2008FB007 /* RenderContextStateBase.cpp */, + 84EB0C392EE2D4B2008FB007 /* RenderContextStateBase.hpp */, + 84EB0C3A2EE2D4B2008FB007 /* RenderDeviceBase.cpp */, + 84EB0C3B2EE2D4B2008FB007 /* RenderDeviceBase.hpp */, + 84EB0C3C2EE2D4B2008FB007 /* ShaderBase.cpp */, + 84EB0C3D2EE2D4B2008FB007 /* ShaderBase.hpp */, + 84EB0C3E2EE2D4B2008FB007 /* ShaderConstantBase.cpp */, + 84EB0C3F2EE2D4B2008FB007 /* ShaderConstantBase.hpp */, + 84EB0C402EE2D4B2008FB007 /* ShaderConstantWithDataBase.cpp */, + 84EB0C412EE2D4B2008FB007 /* ShaderConstantWithDataBase.hpp */, + 84EB0C422EE2D4B2008FB007 /* ShaderContextBase.cpp */, + 84EB0C432EE2D4B2008FB007 /* ShaderContextBase.hpp */, + 84EB0C442EE2D4B2008FB007 /* ShaderProgramBase.cpp */, + 84EB0C452EE2D4B2008FB007 /* ShaderProgramBase.hpp */, + 84EB0C462EE2D4B2008FB007 /* TextureBase.cpp */, + 84EB0C472EE2D4B2008FB007 /* TextureBase.hpp */, ); path = base; sourceTree = ""; }; - 84E8DCE22E849A1600B30789 /* sdl2 */ = { + 84EB0C4C2EE2D4B3008FB007 /* enums */ = { isa = PBXGroup; children = ( - 841DD8712AF8AA7A00AA3B66 /* base */, - 84EAE8F02AF1EAFA000894E8 /* CMakeLists.txt */, - 841DD8742AF8AA7A00AA3B66 /* desktop */, - 84EAE8F12AF1EAFA000894E8 /* main.cpp */, + 84EB0C4D2EE2D4B3008FB007 /* BlendTarget.hpp */, + 84EB0C4E2EE2D4B3008FB007 /* BlendTarget_JsonParser.cpp */, + 84EB0C4F2EE2D4B3008FB007 /* BufferType.hpp */, + 84EB0C502EE2D4B3008FB007 /* ColorWriteMask.hpp */, + 84EB0C512EE2D4B3008FB007 /* ComparisonFunc.hpp */, + 84EB0C522EE2D4B3008FB007 /* ComparisonFunc_JsonParser.cpp */, + 84EB0C532EE2D4B3008FB007 /* CullMode.hpp */, + 84EB0C542EE2D4B3008FB007 /* DepthWriteMask.hpp */, + 84EB0C552EE2D4B3008FB007 /* FogMode.hpp */, + 84EB0C562EE2D4B3008FB007 /* PrimitiveMode.hpp */, + 84EB0C572EE2D4B3008FB007 /* PrimitiveMode_JsonParser.cpp */, + 84EB0C582EE2D4B3008FB007 /* RenderState.hpp */, + 84EB0C592EE2D4B3008FB007 /* RenderState_JsonParser.cpp */, + 84EB0C5A2EE2D4B3008FB007 /* RenderState_JsonParser.hpp */, + 84EB0C5B2EE2D4B3008FB007 /* ShadeMode.hpp */, + 84EB0C5C2EE2D4B3008FB007 /* ShaderPrimitiveTypes.cpp */, + 84EB0C5D2EE2D4B3008FB007 /* ShaderPrimitiveTypes.hpp */, + 84EB0C5E2EE2D4B3008FB007 /* ShaderStagesBits.hpp */, + 84EB0C5F2EE2D4B3008FB007 /* ShaderStagesBits_JsonParser.cpp */, + 84EB0C602EE2D4B3008FB007 /* ShaderType.hpp */, + 84EB0C612EE2D4B3008FB007 /* StencilMask.hpp */, + 84EB0C622EE2D4B3008FB007 /* StencilOp.hpp */, + 84EB0C632EE2D4B3008FB007 /* StencilOp_JsonParser.cpp */, + 84EB0C642EE2D4B3008FB007 /* TextureFiltering.hpp */, + 84EB0C652EE2D4B3008FB007 /* TextureFiltering_JsonParser.cpp */, + 84EB0C662EE2D4B3008FB007 /* TextureFormat.hpp */, + 84EB0C672EE2D4B3008FB007 /* VertexField.hpp */, + 84EB0C682EE2D4B3008FB007 /* VertexField_JsonParser.cpp */, + 84EB0C692EE2D4B3008FB007 /* VertexFieldType.hpp */, + ); + path = enums; + sourceTree = ""; + }; + 84EB0C6E2EE2D4B3008FB007 /* helpers */ = { + isa = PBXGroup; + children = ( + 84EB0C6F2EE2D4B3008FB007 /* ErrorHandler.cpp */, + 84EB0C702EE2D4B3008FB007 /* ErrorHandler.hpp */, + 84EB0C712EE2D4B3008FB007 /* TextureHelper.cpp */, + 84EB0C722EE2D4B3008FB007 /* TextureHelper.hpp */, ); - path = sdl2; + path = helpers; sourceTree = ""; }; - 84EAE8E82AF1EAFA000894E8 /* sdl */ = { + 84EB0C752EE2D4B3008FB007 /* interface */ = { isa = PBXGroup; children = ( - 84E105F52E85155F00FAB6C5 /* base */, - 8444968E2E766960008CF2E0 /* sdl1 */, - 84E8DCE22E849A1600B30789 /* sdl2 */, + 84EB0C762EE2D4B3008FB007 /* BlendState.cpp */, + 84EB0C772EE2D4B3008FB007 /* BlendState.hpp */, + 84EB0C782EE2D4B3008FB007 /* Buffer.cpp */, + 84EB0C792EE2D4B3008FB007 /* Buffer.hpp */, + 84EB0C7A2EE2D4B3008FB007 /* ConstantBuffer.cpp */, + 84EB0C7B2EE2D4B3008FB007 /* ConstantBuffer.hpp */, + 84EB0C7C2EE2D4B3008FB007 /* ConstantBufferConstants.hpp */, + 84EB0C7D2EE2D4B3008FB007 /* ConstantBufferContainer.cpp */, + 84EB0C7E2EE2D4B3008FB007 /* ConstantBufferContainer.hpp */, + 84EB0C7F2EE2D4B3008FB007 /* DepthStencilState.cpp */, + 84EB0C802EE2D4B3008FB007 /* DepthStencilState.hpp */, + 84EB0C812EE2D4B3008FB007 /* FixedPipelineState.cpp */, + 84EB0C822EE2D4B3008FB007 /* FixedPipelineState.hpp */, + 84EB0C832EE2D4B3008FB007 /* FogState.cpp */, + 84EB0C842EE2D4B3008FB007 /* FogState.hpp */, + 84EB0C852EE2D4B3008FB007 /* ImmediateBuffer.cpp */, + 84EB0C862EE2D4B3008FB007 /* ImmediateBuffer.hpp */, + 84EB0C872EE2D4B3008FB007 /* RasterizerState.cpp */, + 84EB0C882EE2D4B3008FB007 /* RasterizerState.hpp */, + 84EB0C892EE2D4B3008FB007 /* RenderContext.cpp */, + 84EB0C8A2EE2D4B3008FB007 /* RenderContext.hpp */, + 84EB0C8B2EE2D4B3008FB007 /* RenderDevice.cpp */, + 84EB0C8C2EE2D4B3008FB007 /* RenderDevice.hpp */, + 84EB0C8D2EE2D4B3008FB007 /* Shader.cpp */, + 84EB0C8E2EE2D4B3008FB007 /* Shader.hpp */, + 84EB0C8F2EE2D4B3008FB007 /* ShaderConstant.hpp */, + 84EB0C902EE2D4B3008FB007 /* ShaderConstantWithData.cpp */, + 84EB0C912EE2D4B3008FB007 /* ShaderConstantWithData.hpp */, + 84EB0C922EE2D4B3008FB007 /* ShaderProgram.cpp */, + 84EB0C932EE2D4B3008FB007 /* ShaderProgram.hpp */, + 84EB0C942EE2D4B3008FB007 /* Texture.cpp */, + 84EB0C952EE2D4B3008FB007 /* Texture.hpp */, + ); + path = interface; + sourceTree = ""; + }; + 84EB0CB52EE2D4B3008FB007 /* ogl */ = { + isa = PBXGroup; + children = ( + 84EB0CB62EE2D4B3008FB007 /* API_OGL.cpp */, + 84EB0CB72EE2D4B3008FB007 /* API_OGL.hpp */, + 84EB0CB82EE2D4B3008FB007 /* BlendStateOGL.cpp */, + 84EB0CB92EE2D4B3008FB007 /* BlendStateOGL.hpp */, + 84EB0CBA2EE2D4B3008FB007 /* BufferOGL.cpp */, + 84EB0CBB2EE2D4B3008FB007 /* BufferOGL.hpp */, + 84EB0CBC2EE2D4B3008FB007 /* ConstantBufferContainerOGL.cpp */, + 84EB0CBD2EE2D4B3008FB007 /* ConstantBufferContainerOGL.hpp */, + 84EB0CBE2EE2D4B3008FB007 /* DepthStencilStateOGL.cpp */, + 84EB0CBF2EE2D4B3008FB007 /* DepthStencilStateOGL.hpp */, + 84EB0CC02EE2D4B3008FB007 /* FixedPipelineStateOGL.cpp */, + 84EB0CC12EE2D4B3008FB007 /* FixedPipelineStateOGL.hpp */, + 84EB0CC22EE2D4B3008FB007 /* FogStateOGL.cpp */, + 84EB0CC32EE2D4B3008FB007 /* FogStateOGL.hpp */, + 84EB0CC42EE2D4B3008FB007 /* GPUEventsOGL.cpp */, + 84EB0CC52EE2D4B3008FB007 /* GPUEventsOGL.hpp */, + 84EB0CC62EE2D4B3008FB007 /* ImmediateBufferOGL.cpp */, + 84EB0CC72EE2D4B3008FB007 /* ImmediateBufferOGL.hpp */, + 84EB0CC82EE2D4B3008FB007 /* ProfileSectionOGL.cpp */, + 84EB0CC92EE2D4B3008FB007 /* ProfileSectionOGL.hpp */, + 84EB0CCA2EE2D4B3008FB007 /* RasterizerStateOGL.cpp */, + 84EB0CCB2EE2D4B3008FB007 /* RasterizerStateOGL.hpp */, + 84EB0CCC2EE2D4B3008FB007 /* RenderContextOGL.cpp */, + 84EB0CCD2EE2D4B3008FB007 /* RenderContextOGL.hpp */, + 84EB0CCE2EE2D4B3008FB007 /* RenderDeviceOGL.cpp */, + 84EB0CCF2EE2D4B3008FB007 /* RenderDeviceOGL.hpp */, + 84EB0CD02EE2D4B3008FB007 /* ResourceOGL.cpp */, + 84EB0CD12EE2D4B3008FB007 /* ResourceOGL.hpp */, + 84EB0CD22EE2D4B3008FB007 /* ShaderConstantOGL.cpp */, + 84EB0CD32EE2D4B3008FB007 /* ShaderConstantOGL.hpp */, + 84EB0CD42EE2D4B3008FB007 /* ShaderConstantWithDataOGL.cpp */, + 84EB0CD52EE2D4B3008FB007 /* ShaderConstantWithDataOGL.hpp */, + 84EB0CD62EE2D4B3008FB007 /* ShaderOGL.cpp */, + 84EB0CD72EE2D4B3008FB007 /* ShaderOGL.hpp */, + 84EB0CD82EE2D4B3008FB007 /* ShaderProgramOGL.cpp */, + 84EB0CD92EE2D4B3008FB007 /* ShaderProgramOGL.hpp */, + 84EB0CDA2EE2D4B3008FB007 /* ShaderResourceOGL.cpp */, + 84EB0CDB2EE2D4B3008FB007 /* ShaderResourceOGL.hpp */, + 84EB0CDC2EE2D4B3008FB007 /* ShaderUniformOGL.cpp */, + 84EB0CDD2EE2D4B3008FB007 /* ShaderUniformOGL.hpp */, + 84EB0CDE2EE2D4B3008FB007 /* TextureOGL.cpp */, + 84EB0CDF2EE2D4B3008FB007 /* TextureOGL.hpp */, + ); + path = ogl; + sourceTree = ""; + }; + 84EB0CEF2EE2D4B3008FB007 /* platform */ = { + isa = PBXGroup; + children = ( + 84EB0CF02EE2D4B3008FB007 /* ogl */, ); - path = sdl; + path = platform; + sourceTree = ""; + }; + 84EB0CF02EE2D4B3008FB007 /* ogl */ = { + isa = PBXGroup; + children = ( + 84EB0CF12EE2D4B3008FB007 /* Extensions.cpp */, + 84EB0CF22EE2D4B3008FB007 /* Extensions.hpp */, + 84EB0CF32EE2D4B3008FB007 /* ShaderPrecision.cpp */, + 84EB0CF42EE2D4B3008FB007 /* ShaderPrecision.hpp */, + ); + path = ogl; sourceTree = ""; }; 84F77A042EA1C0050045C907 /* server */ = { @@ -5710,7 +4854,124 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 84EB0DFE2EE2D4B4008FB007 /* StencilRefObject.hpp in Headers */, + 84EB0DD02EE2D4B4008FB007 /* ShaderConstantWithDataOGL.hpp in Headers */, + 84EB0E002EE2D4B4008FB007 /* TextureGroup.hpp in Headers */, + 84EB0D4E2EE2D4B3008FB007 /* BufferType.hpp in Headers */, + 84EB0DD62EE2D4B4008FB007 /* ShaderResourceOGL.hpp in Headers */, + 84EB0D6A2EE2D4B3008FB007 /* FixedPipelineStateDescription.hpp in Headers */, + 84EB0DDD2EE2D4B4008FB007 /* ShaderStage.hpp in Headers */, + 84EB0D892EE2D4B3008FB007 /* RenderDevice.hpp in Headers */, + 84EB0D8E2EE2D4B3008FB007 /* ShaderConstantWithData.hpp in Headers */, + 84EB0D6C2EE2D4B3008FB007 /* FogStateDescription.hpp in Headers */, + 84EB0DE92EE2D4B4008FB007 /* PerFrameConstants.hpp in Headers */, + 84EB0D3F2EE2D4B3008FB007 /* ShaderConstantBase.hpp in Headers */, + 84EB0D522EE2D4B3008FB007 /* CullMode.hpp in Headers */, + 84EB0D602EE2D4B3008FB007 /* StencilMask.hpp in Headers */, + 84EB0DF02EE2D4B4008FB007 /* QuadIndexBuffer.hpp in Headers */, + 84EB0D8B2EE2D4B3008FB007 /* Shader.hpp in Headers */, + 84EB0DCA2EE2D4B4008FB007 /* RenderDeviceOGL.hpp in Headers */, + 84EB0DEB2EE2D4B4008FB007 /* Extensions.hpp in Headers */, + 84EB0DC02EE2D4B4008FB007 /* GPUEventsOGL.hpp in Headers */, + 84EB0D4C2EE2D4B3008FB007 /* BlendTarget.hpp in Headers */, + 84EB0DCE2EE2D4B4008FB007 /* ShaderConstantOGL.hpp in Headers */, + 84EB0D492EE2D4B3008FB007 /* BlendStateDescription.hpp in Headers */, + 84EB0D3D2EE2D4B3008FB007 /* ShaderBase.hpp in Headers */, + 84EB0D392EE2D4B3008FB007 /* RenderContextStateBase.hpp in Headers */, + 84EB0D292EE2D4B3008FB007 /* ConstantBufferContainerBase.hpp in Headers */, 84619B392AF1F73900B0DE81 /* GL.hpp in Headers */, + 84EB0DDC2EE2D4B4008FB007 /* RasterizerStateDescription.hpp in Headers */, + 84EB0D5C2EE2D4B3008FB007 /* ShaderPrimitiveTypes.hpp in Headers */, + 84EB0D7F2EE2D4B3008FB007 /* FixedPipelineState.hpp in Headers */, + 84EB0DB22EE2D4B4008FB007 /* API_OGL.hpp in Headers */, + 84EB0D1B2EE2D4B3008FB007 /* EntityConstants.hpp in Headers */, + 84EB0D762EE2D4B3008FB007 /* Buffer.hpp in Headers */, + 84EB0DED2EE2D4B4008FB007 /* ShaderPrecision.hpp in Headers */, + 84EB0DE32EE2D4B4008FB007 /* MaterialPtr.hpp in Headers */, + 84EB0D4F2EE2D4B3008FB007 /* ColorWriteMask.hpp in Headers */, + 84EB0D1D2EE2D4B3008FB007 /* GlobalConstantBufferManager.hpp in Headers */, + 84EB0E082EE2D4B4008FB007 /* WeatherConstants.hpp in Headers */, + 84EB0E022EE2D4B4008FB007 /* TexturePtr.hpp in Headers */, + 84EB0D5D2EE2D4B3008FB007 /* ShaderStagesBits.hpp in Headers */, + 84EB0D2B2EE2D4B3008FB007 /* DepthStencilStateBase.hpp in Headers */, + 84EB0DB62EE2D4B4008FB007 /* BufferOGL.hpp in Headers */, + 84EB0D742EE2D4B3008FB007 /* BlendState.hpp in Headers */, + 84EB0D232EE2D4B3008FB007 /* BufferBase.hpp in Headers */, + 84EB0D8C2EE2D4B3008FB007 /* ShaderConstant.hpp in Headers */, + 84EB0D3B2EE2D4B3008FB007 /* RenderDeviceBase.hpp in Headers */, + 84EB0D702EE2D4B3008FB007 /* TextureHelper.hpp in Headers */, + 84EB0D6E2EE2D4B3008FB007 /* ErrorHandler.hpp in Headers */, + 84EB0D852EE2D4B3008FB007 /* RasterizerState.hpp in Headers */, + 84EB0DD82EE2D4B4008FB007 /* ShaderUniformOGL.hpp in Headers */, + 84EB0E042EE2D4B4008FB007 /* UniformMetaData.hpp in Headers */, + 84EB0D812EE2D4B3008FB007 /* FogState.hpp in Headers */, + 84EB0D7B2EE2D4B3008FB007 /* ConstantBufferContainer.hpp in Headers */, + 84EB0D2D2EE2D4B3008FB007 /* FixedPipelineStateBase.hpp in Headers */, + 84EB0D312EE2D4B3008FB007 /* FrameBufferObjectBase.hpp in Headers */, + 84EB0DE12EE2D4B4008FB007 /* TextureDescription.hpp in Headers */, + 84EB0D662EE2D4B3008FB007 /* VertexField.hpp in Headers */, + 84EB0DBE2EE2D4B4008FB007 /* FogStateOGL.hpp in Headers */, + 84EB0D352EE2D4B3008FB007 /* RasterizerStateBase.hpp in Headers */, + 84EB0DBA2EE2D4B4008FB007 /* DepthStencilStateOGL.hpp in Headers */, + 84EB0D412EE2D4B3008FB007 /* ShaderConstantWithDataBase.hpp in Headers */, + 84EB0DC82EE2D4B4008FB007 /* RenderContextOGL.hpp in Headers */, + 84EB0D632EE2D4B3008FB007 /* TextureFiltering.hpp in Headers */, + 84EB0D172EE2D4B3008FB007 /* ConstantBufferMetaDataManager.hpp in Headers */, + 84EB0E062EE2D4B4008FB007 /* VertexFormat.hpp in Headers */, + 84EB0D502EE2D4B3008FB007 /* ComparisonFunc.hpp in Headers */, + 84EB0D572EE2D4B3008FB007 /* RenderState.hpp in Headers */, + 84EB0DCC2EE2D4B4008FB007 /* ResourceOGL.hpp in Headers */, + 84EB0D722EE2D4B3008FB007 /* ImageDescription.hpp in Headers */, + 84EB0DC22EE2D4B4008FB007 /* ImmediateBufferOGL.hpp in Headers */, + 84EB0E0A2EE2D4B4008FB007 /* WorldConstants.hpp in Headers */, + 84EB0D922EE2D4B3008FB007 /* Texture.hpp in Headers */, + 84EB0D332EE2D4B3008FB007 /* ImmediateBufferBase.hpp in Headers */, + 84EB0D272EE2D4B3008FB007 /* ConstantBufferConstantsBase.hpp in Headers */, + 84EB0D4B2EE2D4B3008FB007 /* DepthStencilStateDescription.hpp in Headers */, + 84EB0D5A2EE2D4B3008FB007 /* ShadeMode.hpp in Headers */, + 84EB0DB42EE2D4B4008FB007 /* BlendStateOGL.hpp in Headers */, + 84EB0D192EE2D4B3008FB007 /* EnableScissorTest.hpp in Headers */, + 84EB0DFC2EE2D4B4008FB007 /* ShaderGroupBase.hpp in Headers */, + 84EB0D252EE2D4B3008FB007 /* ConstantBufferBase.hpp in Headers */, + 84EB0DDA2EE2D4B4008FB007 /* TextureOGL.hpp in Headers */, + 84EB0DF42EE2D4B4008FB007 /* RenderContextImmediate.hpp in Headers */, + 84EB0D152EE2D4B3008FB007 /* ConstantBufferMetaData.hpp in Headers */, + 84EB0D652EE2D4B3008FB007 /* TextureFormat.hpp in Headers */, + 84EB0D902EE2D4B3008FB007 /* ShaderProgram.hpp in Headers */, + 84EB0D782EE2D4B3008FB007 /* ConstantBuffer.hpp in Headers */, + 84EB0D452EE2D4B3008FB007 /* ShaderProgramBase.hpp in Headers */, + 84EB0DD42EE2D4B4008FB007 /* ShaderProgramOGL.hpp in Headers */, + 84EB0D532EE2D4B3008FB007 /* DepthWriteMask.hpp in Headers */, + 84EB0D792EE2D4B3008FB007 /* ConstantBufferConstants.hpp in Headers */, + 84EB0DF22EE2D4B4008FB007 /* RenderChunkConstants.hpp in Headers */, + 84EB0DE72EE2D4B4008FB007 /* Mesh.hpp in Headers */, + 84EB0DC42EE2D4B4008FB007 /* ProfileSectionOGL.hpp in Headers */, + 84EB0DC62EE2D4B4008FB007 /* RasterizerStateOGL.hpp in Headers */, + 84EB0DE52EE2D4B4008FB007 /* MatrixStack.hpp in Headers */, + 84EB0DF62EE2D4B4008FB007 /* RenderMaterial.hpp in Headers */, + 84EB0D552EE2D4B3008FB007 /* PrimitiveMode.hpp in Headers */, + 84EB0DB82EE2D4B4008FB007 /* ConstantBufferContainerOGL.hpp in Headers */, + 84EB0D832EE2D4B3008FB007 /* ImmediateBuffer.hpp in Headers */, + 84EB0D212EE2D4B3008FB007 /* BlendStateBase.hpp in Headers */, + 84EB0DFA2EE2D4B4008FB007 /* ShaderGroup.hpp in Headers */, + 84EB0D132EE2D4B3008FB007 /* Attribute.hpp in Headers */, + 84EB0DBC2EE2D4B4008FB007 /* FixedPipelineStateOGL.hpp in Headers */, + 84EB0D542EE2D4B3008FB007 /* FogMode.hpp in Headers */, + 84EB0D612EE2D4B3008FB007 /* StencilOp.hpp in Headers */, + 84EB0DDF2EE2D4B4008FB007 /* StencilFaceDescription.hpp in Headers */, + 84EB0DD22EE2D4B4008FB007 /* ShaderOGL.hpp in Headers */, + 84EB0D5F2EE2D4B3008FB007 /* ShaderType.hpp in Headers */, + 84EB0D7D2EE2D4B3008FB007 /* DepthStencilState.hpp in Headers */, + 84EB0D872EE2D4B3008FB007 /* RenderContext.hpp in Headers */, + 84EB0DEE2EE2D4B4008FB007 /* PlatformDefinitions.h in Headers */, + 84EB0D432EE2D4B3008FB007 /* ShaderContextBase.hpp in Headers */, + 84EB0D2F2EE2D4B3008FB007 /* FogStateBase.hpp in Headers */, + 84EB0DF82EE2D4B4008FB007 /* ShaderConstants.hpp in Headers */, + 84EB0D472EE2D4B3008FB007 /* TextureBase.hpp in Headers */, + 84EB0D1F2EE2D4B3008FB007 /* GlobalConstantBuffers.hpp in Headers */, + 84EB0D682EE2D4B3008FB007 /* VertexFieldType.hpp in Headers */, + 84EB0D372EE2D4B3008FB007 /* RenderContextBase.hpp in Headers */, + 84EB0D592EE2D4B3008FB007 /* RenderState_JsonParser.hpp in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -5775,15 +5036,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 84AAF59C2AF18B9500BD67F4 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - 84AAF6442AF18BE700BD67F4 /* GL.hpp in Headers */, - 84AAF6452AF18BE700BD67F4 /* glext.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; 84B8AE142AF188D8008DE93D /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; @@ -5801,20 +5053,26 @@ 84B8AF3D2AF189D8008DE93D /* ScrolledSelectionList.hpp in Headers */, 84B8AF3E2AF189D8008DE93D /* SmallButton.hpp in Headers */, 84B8AF3F2AF189D8008DE93D /* TextInputBox.hpp in Headers */, + 84EB09F02EE2CCA8008FB007 /* Fog.hpp in Headers */, + 84EB09D72EE2CC86008FB007 /* SheepFurModel.hpp in Headers */, 84B8AF402AF189D8008DE93D /* WorldSelectionList.hpp in Headers */, 84B8AF412AF189D8008DE93D /* Gui.hpp in Headers */, 84B8AF422AF189D8008DE93D /* GuiComponent.hpp in Headers */, 84B8AF432AF189D8008DE93D /* Screen.hpp in Headers */, 8477B3A32C4DC374004E1AC5 /* ControllerBuildInput.hpp in Headers */, + 84EB09F62EE2CCA8008FB007 /* ScreenRenderer.hpp in Headers */, 84B8AF442AF189D8008DE93D /* ChatScreen.hpp in Headers */, 84B8AF452AF189D8008DE93D /* ConfirmScreen.hpp in Headers */, 84B8AF462AF189D8008DE93D /* CreateWorldScreen.hpp in Headers */, 84B8AF472AF189D8008DE93D /* DeathScreen.hpp in Headers */, 84B8AF482AF189D8008DE93D /* DeleteWorldScreen.hpp in Headers */, 84B8AF492AF189D8008DE93D /* DirectConnectScreen.hpp in Headers */, + 84EB09C42EE2CC86008FB007 /* ModelPart.hpp in Headers */, 84B8AF4A2AF189D8008DE93D /* IngameBlockSelectionScreen.hpp in Headers */, 84B8AF4B2AF189D8008DE93D /* InvalidLicenseScreen.hpp in Headers */, 84B8AF4C2AF189D8008DE93D /* JoinGameScreen.hpp in Headers */, + 84EB09F22EE2CCA8008FB007 /* EntityShaderManager.hpp in Headers */, + 84EB09DD2EE2CC86008FB007 /* SpiderModel.hpp in Headers */, 84B8AF4D2AF189D8008DE93D /* OptionsScreen.hpp in Headers */, 84B8AF4E2AF189D8008DE93D /* PauseScreen.hpp in Headers */, 84B8AF4F2AF189D8008DE93D /* ProgressScreen.hpp in Headers */, @@ -5822,14 +5080,14 @@ 84B8AF512AF189D8008DE93D /* SavingWorldScreen.hpp in Headers */, 84B8AF522AF189D8008DE93D /* SelectWorldScreen.hpp in Headers */, 84B8AF532AF189D8008DE93D /* StartMenuScreen.hpp in Headers */, - 84B8AF542AF189D8008DE93D /* Cube.hpp in Headers */, - 84B8AF552AF189D8008DE93D /* HumanoidModel.hpp in Headers */, - 84B8AF562AF189D8008DE93D /* Model.hpp in Headers */, - 84B8AF572AF189D8008DE93D /* PolygonQuad.hpp in Headers */, + 84EB099C2EE2CC3B008FB007 /* GuiElement.hpp in Headers */, + 84EB09D52EE2CC86008FB007 /* QuadrupedModel.hpp in Headers */, + 84EB09F42EE2CCA8008FB007 /* RenderMaterialGroup.hpp in Headers */, 84B8AF582AF189D8008DE93D /* ClientSideNetworkHandler.hpp in Headers */, 84B8AF592AF189D8008DE93D /* Options.hpp in Headers */, 84F77A6F2EA1C27B0045C907 /* LocalPlayer.hpp in Headers */, 84B8AF5A2AF189D8008DE93D /* Controller.hpp in Headers */, + 84EB09C62EE2CC86008FB007 /* PolygonQuad.hpp in Headers */, 84B8AF5B2AF189D8008DE93D /* ControllerTurnInput.hpp in Headers */, 84B8AF5C2AF189D8008DE93D /* ITurnInput.hpp in Headers */, 84B8AF5D2AF189D8008DE93D /* Keyboard.hpp in Headers */, @@ -5837,8 +5095,10 @@ 84B8AF5F2AF189D8008DE93D /* Mouse.hpp in Headers */, 84B8AF602AF189D8008DE93D /* MouseTurnInput.hpp in Headers */, 84B8AF612AF189D8008DE93D /* User.hpp in Headers */, + 84EB09CF2EE2CC86008FB007 /* HumanoidModel.hpp in Headers */, 84B8AF7E2AF189D8008DE93D /* SoundData.hpp in Headers */, 84B8AF7F2AF189D8008DE93D /* SoundDefs.hpp in Headers */, + 84EB09D32EE2CC86008FB007 /* PigModel.hpp in Headers */, 84B8AF802AF189D8008DE93D /* SoundEngine.hpp in Headers */, 84B8AF812AF189D8008DE93D /* SoundRepository.hpp in Headers */, 84B8AF822AF189D8008DE93D /* SoundSystem.hpp in Headers */, @@ -5854,16 +5114,20 @@ 84E0012C2AF39E84009B9555 /* MouseHandler.hpp in Headers */, 84E0012E2AF39E84009B9555 /* Multitouch.hpp in Headers */, 84E001302AF39E84009B9555 /* PolygonArea.hpp in Headers */, + 84EB09DF2EE2CC86008FB007 /* ZombieModel.hpp in Headers */, 84E001322AF39E84009B9555 /* RectangleArea.hpp in Headers */, 84E001342AF39E84009B9555 /* TouchAreaModel.hpp in Headers */, 84E001362AF39E84009B9555 /* TouchInputHolder.hpp in Headers */, 84E001382AF39E84009B9555 /* TouchscreenInput_TestFps.hpp in Headers */, + 84EB09CB2EE2CC86008FB007 /* CowModel.hpp in Headers */, 84E0013A2AF39E84009B9555 /* UnifiedTurnBuild.hpp in Headers */, + 84EB09D12EE2CC86008FB007 /* Model.hpp in Headers */, 84C90EA62AF8861A008973F9 /* OptionList.hpp in Headers */, 84AA8BEC2B32F3F3003F5B82 /* Chunk.hpp in Headers */, 84AA8BEE2B32F3F3003F5B82 /* Culler.hpp in Headers */, 84AA8BF02B32F3F3003F5B82 /* DynamicTexture.hpp in Headers */, 84AA8BF22B32F3F3003F5B82 /* ChickenRenderer.hpp in Headers */, + 84EB09C22EE2CC86008FB007 /* Cube.hpp in Headers */, 84AA8BF42B32F3F3003F5B82 /* CowRenderer.hpp in Headers */, 849488372C9284DA006DB706 /* Lighting.hpp in Headers */, 84AA8BF62B32F3F3003F5B82 /* CreeperRenderer.hpp in Headers */, @@ -5874,11 +5138,14 @@ 84AA8C002B32F3F3003F5B82 /* ItemRenderer.hpp in Headers */, 84AA8C022B32F3F3003F5B82 /* ItemSpriteRenderer.hpp in Headers */, 84AA8C042B32F3F3003F5B82 /* MobRenderer.hpp in Headers */, + 84EB09D92EE2CC86008FB007 /* SheepModel.hpp in Headers */, 84AA8C062B32F3F3003F5B82 /* PigRenderer.hpp in Headers */, 84AA8C082B32F3F3003F5B82 /* SheepFurRenderer.hpp in Headers */, + 84EB09C92EE2CC86008FB007 /* ChickenModel.hpp in Headers */, 84AA8C0A2B32F3F3003F5B82 /* SheepRenderer.hpp in Headers */, 84AA8C0E2B32F3F3003F5B82 /* SpiderRenderer.hpp in Headers */, 84AA8C102B32F3F3003F5B82 /* TntRenderer.hpp in Headers */, + 84EB09CD2EE2CC86008FB007 /* CreeperModel.hpp in Headers */, 84AA8C122B32F3F3003F5B82 /* TripodCameraRenderer.hpp in Headers */, 84AA8C172B32F3F3003F5B82 /* FoliageColor.hpp in Headers */, 84AA8C192B32F3F3003F5B82 /* Font.hpp in Headers */, @@ -5886,10 +5153,14 @@ 84AA8C1D2B32F3F3003F5B82 /* FrustumCuller.hpp in Headers */, 84AA8C1F2B32F3F3003F5B82 /* GameRenderer.hpp in Headers */, 84AA8C212B32F3F3003F5B82 /* GrassColor.hpp in Headers */, + 84EB09C72EE2CC86008FB007 /* TextureOffset.hpp in Headers */, + 84EB09F92EE2CCA8008FB007 /* ImageData.hpp in Headers */, 84AA8C232B32F3F3003F5B82 /* ItemInHandRenderer.hpp in Headers */, 84AA8C272B32F3F3003F5B82 /* LevelRenderer.hpp in Headers */, 84AA8C292B32F3F3003F5B82 /* LightLayer.hpp in Headers */, + 84EB09DB2EE2CC86008FB007 /* SkeletonModel.hpp in Headers */, 84A2FF182DB61D440090CE3E /* SoundPathRepository.hpp in Headers */, + 84EB09FB2EE2CCA8008FB007 /* TextureData.hpp in Headers */, 84B1E0302E04FD4500ED000A /* ArrowRenderer.hpp in Headers */, 84AA8C2B2B32F3F3003F5B82 /* LightUpdate.hpp in Headers */, 84AA8C2D2B32F3F3003F5B82 /* PatchManager.hpp in Headers */, @@ -5902,19 +5173,11 @@ 84AA8C362B32F3F3003F5B82 /* Textures.hpp in Headers */, 84AA8C382B32F3F3003F5B82 /* TileRenderer.hpp in Headers */, 84AA8C392B32F3F3003F5B82 /* VertexPT.hpp in Headers */, - 84AA8C5B2B32F535003F5B82 /* ChickenModel.hpp in Headers */, - 84AA8C5D2B32F535003F5B82 /* CowModel.hpp in Headers */, + 84EB09F72EE2CCA8008FB007 /* ColorSpace.hpp in Headers */, 84A2FF1C2DB61F650090CE3E /* SoundStream.hpp in Headers */, - 84AA8C5F2B32F535003F5B82 /* CreeperModel.hpp in Headers */, - 84AA8C672B32F535003F5B82 /* ModelPart.hpp in Headers */, - 84AA8C692B32F535003F5B82 /* PigModel.hpp in Headers */, + 84EB099D2EE2CC3B008FB007 /* IntRectangle.hpp in Headers */, + 84EB09972EE2CC25008FB007 /* AppPlatformListener.hpp in Headers */, 8477B3A72C4DC374004E1AC5 /* MouseBuildInput.hpp in Headers */, - 84AA8C6D2B32F535003F5B82 /* QuadrupedModel.hpp in Headers */, - 84AA8C6F2B32F535003F5B82 /* SheepFurModel.hpp in Headers */, - 84AA8C712B32F535003F5B82 /* SheepModel.hpp in Headers */, - 84AA8C732B32F535003F5B82 /* SkeletonModel.hpp in Headers */, - 84AA8C752B32F536003F5B82 /* SpiderModel.hpp in Headers */, - 84AA8C772B32F536003F5B82 /* ZombieModel.hpp in Headers */, 84E78C802B58B5CC00D515EF /* RocketRenderer.hpp in Headers */, 8470AF412BE9B80900BCA54E /* DisconnectionScreen.hpp in Headers */, ); @@ -6094,12 +5357,16 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 84EB0E0E2EE2D4D4008FB007 /* AlignmentHelper.hpp in Headers */, + 84EB0E112EE2D4D4008FB007 /* JsonParser.hpp in Headers */, 8406FD322AF1823600B09C1D /* CThread.hpp in Headers */, + 84EB0E0F2EE2D4D4008FB007 /* InheritanceTree.hpp in Headers */, 8406FD332AF1823600B09C1D /* Logger.hpp in Headers */, - 8406FD352AF1823600B09C1D /* Matrix.hpp in Headers */, 8406FD362AF1823600B09C1D /* Mth.hpp in Headers */, 8406FD372AF1823600B09C1D /* Random.hpp in Headers */, + 84EB0E0C2EE2D4CA008FB007 /* Color.hpp in Headers */, 8406FD392AF1823700B09C1D /* Timer.hpp in Headers */, + 84EB0E132EE2D4D4008FB007 /* Singleton.hpp in Headers */, 84CCBC402E6183F300E251AF /* DataIO.hpp in Headers */, 8406FD3A2AF1823700B09C1D /* Util.hpp in Headers */, 8406FD3B2AF1823700B09C1D /* Utils.hpp in Headers */, @@ -6292,7 +5559,6 @@ buildRules = ( ); dependencies = ( - 84AAF6472AF18C0600BD67F4 /* PBXTargetDependency */, ); name = Renderer; productName = Common; @@ -6394,23 +5660,6 @@ productReference = 8492591D2AD8FCFC0081F5B9 /* minecraftpe.app */; productType = "com.apple.product-type.application"; }; - 84AAF5972AF18B9500BD67F4 /* OpenGL */ = { - isa = PBXNativeTarget; - buildConfigurationList = 84AAF63C2AF18B9500BD67F4 /* Build configuration list for PBXNativeTarget "OpenGL" */; - buildPhases = ( - 84AAF59C2AF18B9500BD67F4 /* Headers */, - 84AAF5EA2AF18B9500BD67F4 /* Sources */, - 84AAF6392AF18B9500BD67F4 /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = OpenGL; - productName = OpenGL; - productReference = 84AAF6422AF18B9500BD67F4 /* libOpenGL.a */; - productType = "com.apple.product-type.library.static"; - }; 84B8AE132AF188D8008DE93D /* Client */ = { isa = PBXNativeTarget; buildConfigurationList = 84B8AEE12AF188D8008DE93D /* Build configuration list for PBXNativeTarget "Client" */; @@ -6564,7 +5813,6 @@ 8406FD162AF1814500B09C1D /* Renderer */, 84F779CE2EA1BF8E0045C907 /* Server */, 84BF62FE2AF1859D008A9995 /* World */, - 84AAF5972AF18B9500BD67F4 /* OpenGL */, 84498A762AF18C7A005EF5A5 /* ZLib */, ); }; @@ -6575,451 +5823,15 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 84B1E29F2E051B7D00ED000A /* bass.ogg in Resources */, - 8470AF442BE9B98000BCA54E /* clouds.png in Resources */, - 84B1E2C52E051B7D00ED000A /* hurt.ogg in Resources */, - 84B1E1F82E051B7D00ED000A /* hiss2.ogg in Resources */, - 84B1E26F2E051B7D00ED000A /* slime5.ogg in Resources */, - 8477B41C2C4DE77F004E1AC5 /* creative_1_4.png in Resources */, - 84B1E2B52E051B7D00ED000A /* door_open.ogg in Resources */, - 849259562AD8FD4F0081F5B9 /* minecraftpeViewController.xib in Resources */, - 84B1E1E72E051B7D00ED000A /* hurtflesh3.ogg in Resources */, - 84B1E2842E051B7D00ED000A /* shake.ogg in Resources */, - 84B1E1D22E051B7D00ED000A /* cave13.ogg in Resources */, - 84B1E1F92E051B7D00ED000A /* hiss3.ogg in Resources */, - 84B1E21B2E051B7D00ED000A /* hit3.ogg in Resources */, - 84B1E2CA2E051B7D00ED000A /* splash.ogg in Resources */, - 84B1E1C62E051B7D00ED000A /* hal2.ogg in Resources */, - 84B1E24D2E051B7D00ED000A /* small3.ogg in Resources */, - 84B1E27D2E051B7D00ED000A /* growl3.ogg in Resources */, - 84B1E06D2E051B6400ED000A /* zombie.png in Resources */, - 8477B4312C4DE77F004E1AC5 /* create_1_3.png in Resources */, - 8477B4482C4DE77F004E1AC5 /* Icon_lite.png in Resources */, - 8477B44D2C4DE77F004E1AC5 /* Default.png in Resources */, - 84B1E2ED2E051B7D00ED000A /* grass4.ogg in Resources */, - 849488332C928459006DB706 /* sun.png in Resources */, - 84B1E2432E051B7D00ED000A /* big1.ogg in Resources */, - 84B1E1FD2E051B7D00ED000A /* meow1.ogg in Resources */, - 84B1E2672E051B7D00ED000A /* skeletonhurt1.ogg in Resources */, - 8477B40A2C4DE77F004E1AC5 /* bg64.png in Resources */, - 84B1E2922E051B7D00ED000A /* zombiehurt1.ogg in Resources */, - 84B1E2892E051B7D00ED000A /* wood1.ogg in Resources */, - 84B1E2AC2E051B7D00ED000A /* bowhit3.ogg in Resources */, - 8477B4382C4DE77F004E1AC5 /* worldname_ipad.png in Resources */, - 84B1E2152E051B7D00ED000A /* creeper3.ogg in Resources */, - 84B1E2C32E051B7D00ED000A /* glass2.ogg in Resources */, - 84B1E29D2E051B7D00ED000A /* zpighurt1.ogg in Resources */, - 84B1E2232E051B7D00ED000A /* portal2.ogg in Resources */, - 84B1E2AB2E051B7D00ED000A /* bowhit2.ogg in Resources */, - 84B1E2352E051B7D00ED000A /* scream2.ogg in Resources */, - 84B1E23B2E051B7D00ED000A /* hit2.ogg in Resources */, - 84B1E2192E051B7D00ED000A /* hit1.ogg in Resources */, - 849259602AD8FDCB0081F5B9 /* InfoPlist.strings in Resources */, - 84B1E2CE2E051B7D00ED000A /* cloth3.ogg in Resources */, - 849259642AD8FDD90081F5B9 /* minecraftpe-Info.plist in Resources */, - 84B1E2EB2E051B7D00ED000A /* grass2.ogg in Resources */, - 84B1E22C2E051B7D00ED000A /* fireball4.ogg in Resources */, - 84B1E2C12E051B7D00ED000A /* fuse.ogg in Resources */, - 8477B4292C4DE77F004E1AC5 /* worldname_iphone_3.png in Resources */, - 8477B4102C4DE77F004E1AC5 /* cancel_1_3.png in Resources */, - 84B1E2342E051B7D00ED000A /* scream1.ogg in Resources */, - 8477B4152C4DE77F004E1AC5 /* create_1_1.png in Resources */, - 8477B40F2C4DE77F004E1AC5 /* cancel_1_1.png in Resources */, - 84E001BB2AF3AF9B009B9555 /* MainWindow.xib in Resources */, - 84B1E2EC2E051B7D00ED000A /* grass3.ogg in Resources */, - 84B1E2F32E051B7D00ED000A /* stone2.ogg in Resources */, - 84B1E2B42E051B7D00ED000A /* door_close.ogg in Resources */, - 84B1E0682E051B6400ED000A /* sheep.png in Resources */, - 84B1E20F2E051B7D00ED000A /* cow4.ogg in Resources */, - 8477B4422C4DE77F004E1AC5 /* Icon-Small@2x.png in Resources */, - 8494882B2C92844C006DB706 /* grasscolor.png in Resources */, - 84B1E2392E051B7D00ED000A /* death.ogg in Resources */, - 84B1E2D12E051B7D00ED000A /* grass2.ogg in Resources */, - 84B1E2272E051B7D00ED000A /* scream4.ogg in Resources */, - 84B1E27E2E051B7D00ED000A /* howl1.ogg in Resources */, - 849FF0B72AF465340013BAE3 /* default8.png in Resources */, - 84B1E2A22E051B7D00ED000A /* harp.ogg in Resources */, - 84B1E24B2E051B7D00ED000A /* small1.ogg in Resources */, - 84B1E2E62E051B7D00ED000A /* wood3.ogg in Resources */, - 84B1E06A2E051B6400ED000A /* skeleton.png in Resources */, - 84B1E29C2E051B7D00ED000A /* zpigdeath.ogg in Resources */, - 84B1E1C72E051B7D00ED000A /* hal3.ogg in Resources */, - 8477B4262C4DE77F004E1AC5 /* worldname_ipad.png in Resources */, - 84B1E2E92E051B7D00ED000A /* out.ogg in Resources */, - 8477B4212C4DE77F004E1AC5 /* worldname_ipad_4.png in Resources */, - 84B1E2C62E051B7D00ED000A /* levelup.ogg in Resources */, - 84B1E2D72E051B7D00ED000A /* gravel4.ogg in Resources */, - 84B1E25C2E051B7D00ED000A /* say2.ogg in Resources */, - 84B1E1D92E051B7D00ED000A /* cave8.ogg in Resources */, - 849FF0B82AF465340013BAE3 /* panorama_0.png in Resources */, - 84B1E2062E051B7D00ED000A /* chicken1.ogg in Resources */, - 8477B43B2C4DE77F004E1AC5 /* worldname_iphone5_3.png in Resources */, - 8477B4192C4DE77F004E1AC5 /* create_0_4.png in Resources */, - 84B1E2162E051B7D00ED000A /* creeper4.ogg in Resources */, - 84B1E2962E051B7D00ED000A /* zpig3.ogg in Resources */, - 84B1E2652E051B7D00ED000A /* skeleton3.ogg in Resources */, - 8477B4372C4DE77F004E1AC5 /* worldname_3.png in Resources */, - 84B1E2EA2E051B7D00ED000A /* grass1.ogg in Resources */, - 849FF0B92AF465340013BAE3 /* panorama_1.png in Resources */, - 84B1E26A2E051B7D00ED000A /* skeletonhurt4.ogg in Resources */, - 8477B4432C4DE77F004E1AC5 /* Icon-Small@2x_lite.png in Resources */, - 84B1E2732E051B7D00ED000A /* spider2.ogg in Resources */, - 84B1E1F52E051B7D00ED000A /* hit3.ogg in Resources */, - 84B1E1DC2E051B7D00ED000A /* rain2.ogg in Resources */, - 84B1E2402E051B7D00ED000A /* walk2.ogg in Resources */, - 84B1E2BB2E051B7D00ED000A /* explode.ogg in Resources */, - 84B1E24A2E051B7D00ED000A /* jump4.ogg in Resources */, - 84B1E27A2E051B7D00ED000A /* death.ogg in Resources */, - 849FF0BA2AF465340013BAE3 /* panorama_2.png in Resources */, - 84E1C9BC2E7FDAE3007D2F5D /* fern.png in Resources */, - 84B1E29B2E051B7D00ED000A /* zpigangry4.ogg in Resources */, - 84B1E29A2E051B7D00ED000A /* zpigangry3.ogg in Resources */, - 84B1E2912E051B7D00ED000A /* zombiedeath.ogg in Resources */, - 84B1E0612E050D2500ED000A /* squid.png in Resources */, - 8477B4272C4DE77F004E1AC5 /* worldname_ipad_3.png in Resources */, - 84B1E2AD2E051B7D00ED000A /* bowhit4.ogg in Resources */, - 84B1E25A2E051B7D00ED000A /* kill.ogg in Resources */, - 84B1E2CC2E051B7D00ED000A /* cloth1.ogg in Resources */, - 84B1E27B2E051B7D00ED000A /* growl1.ogg in Resources */, - 84B1E1CD2E051B7D00ED000A /* piano3.ogg in Resources */, - 84B1E2582E051B7D00ED000A /* hit2.ogg in Resources */, - 84B1E2E82E051B7D00ED000A /* in.ogg in Resources */, - 8477B4342C4DE77F004E1AC5 /* survival_0_3.png in Resources */, - 849FF0BB2AF465340013BAE3 /* panorama_3.png in Resources */, - 84B1E2AE2E051B7D00ED000A /* break.ogg in Resources */, - 84B1E2012E051B7D00ED000A /* purr1.ogg in Resources */, - 8477B44B2C4DE77F004E1AC5 /* Default-568h@2x.png in Resources */, - 84B1E26B2E051B7D00ED000A /* slime1.ogg in Resources */, - 84B1E2BA2E051B7D00ED000A /* eat3.ogg in Resources */, - 84B1E2BC2E051B7D00ED000A /* explode1.ogg in Resources */, - 84B1E2692E051B7D00ED000A /* skeletonhurt3.ogg in Resources */, - 84B1E2132E051B7D00ED000A /* creeper1.ogg in Resources */, - 84B1E2D02E051B7D00ED000A /* grass1.ogg in Resources */, - 84B1E2772E051B7D00ED000A /* bark1.ogg in Resources */, - 84B1E2852E051B7D00ED000A /* whine.ogg in Resources */, - 84B1E2752E051B7D00ED000A /* spider4.ogg in Resources */, - 8477B42E2C4DE77F004E1AC5 /* create_0_1.png in Resources */, - 84B1E20D2E051B7D00ED000A /* cow2.ogg in Resources */, - 84B1E2F12E051B7D00ED000A /* gravel4.ogg in Resources */, - 84B1E2F82E051B7D00ED000A /* wood3.ogg in Resources */, - 8477B4142C4DE77F004E1AC5 /* create_1.png in Resources */, - 84B1E2712E051B7D00ED000A /* slimeattack2.ogg in Resources */, - 84B1E2F72E051B7D00ED000A /* wood2.ogg in Resources */, - 84B1E1CA2E051B7D00ED000A /* nuance2.ogg in Resources */, - 84B1E1D02E051B7D00ED000A /* cave11.ogg in Resources */, - 84B1E0562E050D2500ED000A /* ghast.png in Resources */, - 849FF0BC2AF465340013BAE3 /* panorama_4.png in Resources */, - 84B1E1F42E051B7D00ED000A /* hit2.ogg in Resources */, - 84B1E2532E051B7D00ED000A /* pigdeath.ogg in Resources */, - 84B1E2982E051B7D00ED000A /* zpigangry1.ogg in Resources */, - 8477B4362C4DE77F004E1AC5 /* worldname.png in Resources */, - 8477B4412C4DE77F004E1AC5 /* Icon-Small.png in Resources */, - 84B1E2E52E051B7D00ED000A /* wood2.ogg in Resources */, - 84B1E2312E051B7D00ED000A /* moan5.ogg in Resources */, - 84B1E1FB2E051B7D00ED000A /* hitt2.ogg in Resources */, - 84B1E2332E051B7D00ED000A /* moan7.ogg in Resources */, - 84B1E2622E051B7D00ED000A /* step4.ogg in Resources */, - 84B1E2102E051B7D00ED000A /* cowhurt1.ogg in Resources */, - 84B1E0552E050D2500ED000A /* ghast_fire.png in Resources */, - 84B1E1D72E051B7D00ED000A /* cave6.ogg in Resources */, - 849FF0BD2AF465340013BAE3 /* panorama_5.png in Resources */, - 849FF0BE2AF465340013BAE3 /* background.png in Resources */, - 849FF0C32AF465340013BAE3 /* default_world.png in Resources */, - 84B1E2812E051B7D00ED000A /* hurt2.ogg in Resources */, - 84B1E1FC2E051B7D00ED000A /* hitt3.ogg in Resources */, - 84B1E2EF2E051B7D00ED000A /* gravel2.ogg in Resources */, - 84B1E1EE2E051B7D00ED000A /* breathe1.ogg in Resources */, - 84B1E20B2E051B7D00ED000A /* chickenplop.ogg in Resources */, - 8477B4352C4DE77F004E1AC5 /* survival_1_3.png in Resources */, - 84B1E2412E051B7D00ED000A /* walk3.ogg in Resources */, - 84B1E0582E050D2500ED000A /* pigman.png in Resources */, - 84B1E2B62E051B7D00ED000A /* drink.ogg in Resources */, - 849FF0C52AF465340013BAE3 /* feedback_fill.png in Resources */, - 84B1E2382E051B7D00ED000A /* scream5.ogg in Resources */, - 849FF0C62AF465340013BAE3 /* feedback_outer.png in Resources */, - 84B1E2302E051B7D00ED000A /* moan4.ogg in Resources */, - 84E1C9BA2E7FDAE3007D2F5D /* birch_sapling.png in Resources */, - 84B1E2792E051B7D00ED000A /* bark3.ogg in Resources */, - 8477B4112C4DE77F004E1AC5 /* create_0.png in Resources */, - 84B1E21C2E051B7D00ED000A /* hit4.ogg in Resources */, - 84B1E2CF2E051B7D00ED000A /* cloth4.ogg in Resources */, - 84B1E2BE2E051B7D00ED000A /* explode3.ogg in Resources */, - 84B1E1E92E051B7D00ED000A /* ignite.ogg in Resources */, - 84B1E1D32E051B7D00ED000A /* cave2.ogg in Resources */, - 84B1E1F72E051B7D00ED000A /* hiss1.ogg in Resources */, - 84B1E1CE2E051B7D00ED000A /* cave1.ogg in Resources */, - 84B1E1DA2E051B7D00ED000A /* cave9.ogg in Resources */, - 84B1E1C42E051B7D00ED000A /* calm3.ogg in Resources */, - 84B1E2002E051B7D00ED000A /* meow4.ogg in Resources */, - 84B1E20A2E051B7D00ED000A /* chickenhurt2.ogg in Resources */, - 84B1E2D52E051B7D00ED000A /* gravel2.ogg in Resources */, - 8477B42F2C4DE77F004E1AC5 /* create_0_3.png in Resources */, - 84B1E2872E051B7D00ED000A /* metal2.ogg in Resources */, - 84E1C9BD2E7FDAE3007D2F5D /* spruce_sapling.png in Resources */, - 84B1E2CB2E051B7D00ED000A /* wood click.ogg in Resources */, - 84B1E2552E051B7D00ED000A /* sheep2.ogg in Resources */, - 84B1E26E2E051B7D00ED000A /* slime4.ogg in Resources */, - 8477B44C2C4DE77F004E1AC5 /* Default-Landscape~ipad.png in Resources */, - 84B1E2902E051B7D00ED000A /* zombie3.ogg in Resources */, - 84B1E1F62E051B7D00ED000A /* hit4.ogg in Resources */, - 84B1E2B72E051B7D00ED000A /* drr.ogg in Resources */, - 84B1E06C2E051B6400ED000A /* spider_eyes.png in Resources */, - 84B1E1F22E051B7D00ED000A /* death.ogg in Resources */, - 84B1E1FA2E051B7D00ED000A /* hitt1.ogg in Resources */, - 84B1E1E52E051B7D00ED000A /* hurtflesh1.ogg in Resources */, - 8477B44A2C4DE77F004E1AC5 /* mcpe_lite_ios_icon.png in Resources */, - 84B1E2AA2E051B7D00ED000A /* bowhit1.ogg in Resources */, - 84B1E2E02E051B7D00ED000A /* stone1.ogg in Resources */, - 84B1E2DC2E051B7D00ED000A /* snow1.ogg in Resources */, - 84B1E2C92E051B7D00ED000A /* pop.ogg in Resources */, - 84B1E2262E051B7D00ED000A /* scream3.ogg in Resources */, - 8477B41D2C4DE77F004E1AC5 /* creative_3_4.png in Resources */, - 84B1E0692E051B6400ED000A /* sheep_fur.png in Resources */, - 8477B40D2C4DE77F004E1AC5 /* cancel_0_3.png in Resources */, - 84B1E2602E051B7D00ED000A /* step2.ogg in Resources */, - 84B1E28F2E051B7D00ED000A /* zombie2.ogg in Resources */, - 849FF0C72AF465340013BAE3 /* gui.png in Resources */, - 8477B43F2C4DE77F004E1AC5 /* Icon-Small-50.png in Resources */, - 84B1E1DD2E051B7D00ED000A /* rain3.ogg in Resources */, - 84B1E2D42E051B7D00ED000A /* gravel1.ogg in Resources */, - 84E1C9BB2E7FDAE3007D2F5D /* dead_bush.png in Resources */, - 84B1E2282E051B7D00ED000A /* stare.ogg in Resources */, - 84B1E0662E051B6400ED000A /* creeper.png in Resources */, - 84B1E2452E051B7D00ED000A /* big3.ogg in Resources */, - 84B1E2F62E051B7D00ED000A /* wood1.ogg in Resources */, - 849FF0C82AF465340013BAE3 /* gui_blocks.png in Resources */, - 84B1E23E2E051B7D00ED000A /* throw.ogg in Resources */, - 84B1E2B12E051B7D00ED000A /* chestclosed.ogg in Resources */, - 84B1E2782E051B7D00ED000A /* bark2.ogg in Resources */, - 84B1E2492E051B7D00ED000A /* jump3.ogg in Resources */, - 849FF0C92AF465340013BAE3 /* icons.png in Resources */, - 84B1E1E42E051B7D00ED000A /* fallsmall.ogg in Resources */, - 84B1E2D22E051B7D00ED000A /* grass3.ogg in Resources */, - 8477B4492C4DE77F004E1AC5 /* mcpe_ios_icon.png in Resources */, - 8477B4122C4DE77F004E1AC5 /* create_0_1.png in Resources */, - 8477B4232C4DE77F004E1AC5 /* save_0_3.png in Resources */, - 84B1E1D82E051B7D00ED000A /* cave7.ogg in Resources */, - 84B1E2E42E051B7D00ED000A /* wood1.ogg in Resources */, - 8477B4442C4DE77F004E1AC5 /* Icon-Small_lite.png in Resources */, - 84B1E1C32E051B7D00ED000A /* calm2.ogg in Resources */, - 8494882C2C92844C006DB706 /* pumpkinblur.png in Resources */, - 84B1E2A32E051B7D00ED000A /* hat.ogg in Resources */, - 84B1E22E2E051B7D00ED000A /* moan2.ogg in Resources */, - 84B1E1F02E051B7D00ED000A /* breathe3.ogg in Resources */, - 8477B4462C4DE77F004E1AC5 /* Icon@2x.png in Resources */, - 84B1E2662E051B7D00ED000A /* skeletondeath.ogg in Resources */, - 84B1E1C92E051B7D00ED000A /* nuance1.ogg in Resources */, - 8477B44E2C4DE77F004E1AC5 /* Default@2x.png in Resources */, - 8477B4202C4DE77F004E1AC5 /* survival_3_4.png in Resources */, - 84B1E2A12E051B7D00ED000A /* bd.ogg in Resources */, - 84B1E2F92E051B7D00ED000A /* wood4.ogg in Resources */, - 84B1E25D2E051B7D00ED000A /* say3.ogg in Resources */, - 84B1E2D62E051B7D00ED000A /* gravel3.ogg in Resources */, - 84B1E2092E051B7D00ED000A /* chickenhurt1.ogg in Resources */, - 8477B41A2C4DE77F004E1AC5 /* create_1_4.png in Resources */, - 84B1E2442E051B7D00ED000A /* big2.ogg in Resources */, - 84B1E28A2E051B7D00ED000A /* wood2.ogg in Resources */, - 84B1E28C2E051B7D00ED000A /* wood4.ogg in Resources */, - 84B1E1DB2E051B7D00ED000A /* rain1.ogg in Resources */, - 8477B4392C4DE77F004E1AC5 /* worldname_ipad_3.png in Resources */, - 84B1E2472E051B7D00ED000A /* jump1.ogg in Resources */, - 84B1E1EF2E051B7D00ED000A /* breathe2.ogg in Resources */, - 84B1E25E2E051B7D00ED000A /* say4.ogg in Resources */, - 84B1E24F2E051B7D00ED000A /* small5.ogg in Resources */, - 8477B40E2C4DE77F004E1AC5 /* cancel_1.png in Resources */, - 8477B4472C4DE77F004E1AC5 /* Icon@2x_lite.png in Resources */, - 84B1E2592E051B7D00ED000A /* hit3.ogg in Resources */, - 84B1E2742E051B7D00ED000A /* spider3.ogg in Resources */, - 84B1E1C52E051B7D00ED000A /* hal1.ogg in Resources */, - 849FF0CB2AF465340013BAE3 /* items.png in Resources */, - 84B1E2762E051B7D00ED000A /* spiderdeath.ogg in Resources */, - 84B1E2F52E051B7D00ED000A /* stone4.ogg in Resources */, - 84B1E2972E051B7D00ED000A /* zpig4.ogg in Resources */, - 84B1E2992E051B7D00ED000A /* zpigangry2.ogg in Resources */, - 84B1E28B2E051B7D00ED000A /* wood3.ogg in Resources */, - 84B1E2612E051B7D00ED000A /* step3.ogg in Resources */, - 84B1E20E2E051B7D00ED000A /* cow3.ogg in Resources */, - 84B1E1CF2E051B7D00ED000A /* cave10.ogg in Resources */, - 84B1E1D12E051B7D00ED000A /* cave12.ogg in Resources */, - 84B1E1DE2E051B7D00ED000A /* rain4.ogg in Resources */, - 84B1E2C82E051B7D00ED000A /* orb.ogg in Resources */, - 84B1E0642E051B6400ED000A /* chicken.png in Resources */, - 84B1E1D52E051B7D00ED000A /* cave4.ogg in Resources */, - 84B1E22A2E051B7D00ED000A /* charge.ogg in Resources */, - 84B1E1E12E051B7D00ED000A /* thunder3.ogg in Resources */, - 84B1E1CC2E051B7D00ED000A /* piano2.ogg in Resources */, - 84B1E2122E051B7D00ED000A /* cowhurt3.ogg in Resources */, - 84B1E23D2E051B7D00ED000A /* hit4.ogg in Resources */, - 84B1E22B2E051B7D00ED000A /* death.ogg in Resources */, - 8477B41E2C4DE77F004E1AC5 /* survival_0_4.png in Resources */, - 84B1E2252E051B7D00ED000A /* scream2.ogg in Resources */, - 84B1E25B2E051B7D00ED000A /* say1.ogg in Resources */, - 84B1E1F32E051B7D00ED000A /* hit1.ogg in Resources */, - 84B1E2822E051B7D00ED000A /* hurt3.ogg in Resources */, - 84B1E06B2E051B6400ED000A /* spider.png in Resources */, - 84B1E2112E051B7D00ED000A /* cowhurt2.ogg in Resources */, - 84B1E2DD2E051B7D00ED000A /* snow2.ogg in Resources */, - 84B1E2AF2E051B7D00ED000A /* breath.ogg in Resources */, - 849FF0D32AF465340013BAE3 /* title.png in Resources */, - 84B1E26D2E051B7D00ED000A /* slime3.ogg in Resources */, - 84B1E28D2E051B7D00ED000A /* woodbreak.ogg in Resources */, - 84B1E1CB2E051B7D00ED000A /* piano1.ogg in Resources */, - 8477B43A2C4DE77F004E1AC5 /* worldname_iphone.png in Resources */, - 84B1E2A02E051B7D00ED000A /* bassattack.ogg in Resources */, - 84B1E2832E051B7D00ED000A /* panting.ogg in Resources */, - 84B1E2C02E051B7D00ED000A /* fizz.ogg in Resources */, - 84B1E1ED2E051B7D00ED000A /* water.ogg in Resources */, - 84B1E2B22E051B7D00ED000A /* chestopen.ogg in Resources */, - 84B1E2E32E051B7D00ED000A /* stone4.ogg in Resources */, - 84B1E2322E051B7D00ED000A /* moan6.ogg in Resources */, - 84B1E2DB2E051B7D00ED000A /* sand4.ogg in Resources */, - 84B1E22F2E051B7D00ED000A /* moan3.ogg in Resources */, - 84B1E1D42E051B7D00ED000A /* cave3.ogg in Resources */, - 84B1E24C2E051B7D00ED000A /* small2.ogg in Resources */, - 84B1E2422E051B7D00ED000A /* walk4.ogg in Resources */, - 84B1E2952E051B7D00ED000A /* zpig2.ogg in Resources */, - 84B1E2632E051B7D00ED000A /* skeleton1.ogg in Resources */, - 84B1E2B92E051B7D00ED000A /* eat2.ogg in Resources */, - 84B1E2F22E051B7D00ED000A /* stone1.ogg in Resources */, - 8477B42C2C4DE77F004E1AC5 /* cancel_1_1.png in Resources */, - 84B1E26C2E051B7D00ED000A /* slime2.ogg in Resources */, - 84B1E2512E051B7D00ED000A /* pig2.ogg in Resources */, - 849FF0D52AF465340013BAE3 /* icon.png in Resources */, - 8477B4092C4DE77F004E1AC5 /* bg128.png in Resources */, - 8494882D2C92844C006DB706 /* shadow.png in Resources */, - 84B1E2172E051B7D00ED000A /* creeperdeath.ogg in Resources */, - 84B1E27C2E051B7D00ED000A /* growl2.ogg in Resources */, - 8477B43E2C4DE77F004E1AC5 /* Icon-72_lite.png in Resources */, - 8477B4222C4DE77F004E1AC5 /* save_0.png in Resources */, - 84B1E2292E051B7D00ED000A /* affectionate scream.ogg in Resources */, - 84B1E2A62E051B7D00ED000A /* portal.ogg in Resources */, - 849FF0DB2AF465340013BAE3 /* camera.png in Resources */, - 84B1E29E2E051B7D00ED000A /* zpighurt2.ogg in Resources */, - 84B1E1FE2E051B7D00ED000A /* meow2.ogg in Resources */, - 84B1E22D2E051B7D00ED000A /* moan1.ogg in Resources */, - 8477B4242C4DE77F004E1AC5 /* save_1.png in Resources */, - 84B1E1E32E051B7D00ED000A /* fallbig2.ogg in Resources */, - 8477B42A2C4DE77F004E1AC5 /* cancel_0_1.png in Resources */, - 84B1E2C42E051B7D00ED000A /* glass3.ogg in Resources */, - 8477B41F2C4DE77F004E1AC5 /* survival_1_4.png in Resources */, - 84B1E21D2E051B7D00ED000A /* idle1.ogg in Resources */, - 84B1E2082E051B7D00ED000A /* chicken3.ogg in Resources */, - 84B1E2022E051B7D00ED000A /* purr2.ogg in Resources */, - 84B1E1E62E051B7D00ED000A /* hurtflesh2.ogg in Resources */, - 849FF0DC2AF465340013BAE3 /* char.png in Resources */, - 84B1E21E2E051B7D00ED000A /* idle2.ogg in Resources */, - 84B1E2942E051B7D00ED000A /* zpig1.ogg in Resources */, - 8477B4452C4DE77F004E1AC5 /* Icon.png in Resources */, - 84B1E2B02E051B7D00ED000A /* burp.ogg in Resources */, - 849FF0DD2AF465340013BAE3 /* particles.png in Resources */, - 84B1E2CD2E051B7D00ED000A /* cloth2.ogg in Resources */, - 8477B41B2C4DE77F004E1AC5 /* creative_0_4.png in Resources */, - 84B1E2B32E051B7D00ED000A /* click.ogg in Resources */, - 84B1E2A72E051B7D00ED000A /* travel.ogg in Resources */, - 8477B4132C4DE77F004E1AC5 /* create_0_3.png in Resources */, - 84B1E2522E051B7D00ED000A /* pig3.ogg in Resources */, - 84B1E1E22E051B7D00ED000A /* fallbig1.ogg in Resources */, - 84B1E20C2E051B7D00ED000A /* cow1.ogg in Resources */, - 84B1E2D82E051B7D00ED000A /* sand1.ogg in Resources */, - 84B1E1EC2E051B7D00ED000A /* splash.ogg in Resources */, - 84B1E2D32E051B7D00ED000A /* grass4.ogg in Resources */, - 8477B4182C4DE77F004E1AC5 /* cancel_1_4.png in Resources */, - 84B1E05A2E050D2500ED000A /* saddle.png in Resources */, - 84B1E2702E051B7D00ED000A /* slimeattack1.ogg in Resources */, - 84B1E2DA2E051B7D00ED000A /* sand3.ogg in Resources */, - 84B1E2F42E051B7D00ED000A /* stone3.ogg in Resources */, - 849FF0DE2AF465340013BAE3 /* terrain.png in Resources */, - 84B1E2042E051B7D00ED000A /* purreow1.ogg in Resources */, - 84B1E1D62E051B7D00ED000A /* cave5.ogg in Resources */, - 84B1E2EE2E051B7D00ED000A /* gravel1.ogg in Resources */, - 84B1E1E82E051B7D00ED000A /* fire.ogg in Resources */, - 84B1E1FF2E051B7D00ED000A /* meow3.ogg in Resources */, - 84B1E2362E051B7D00ED000A /* scream3.ogg in Resources */, - 84B1E2862E051B7D00ED000A /* metal1.ogg in Resources */, - 84B1E2E12E051B7D00ED000A /* stone2.ogg in Resources */, - 84B1E2DE2E051B7D00ED000A /* snow3.ogg in Resources */, - 8477B40C2C4DE77F004E1AC5 /* cancel_0_1.png in Resources */, - 84B1E27F2E051B7D00ED000A /* howl2.ogg in Resources */, - 84B1E23F2E051B7D00ED000A /* walk1.ogg in Resources */, - 84B1E2C22E051B7D00ED000A /* glass1.ogg in Resources */, - 84B1E2372E051B7D00ED000A /* scream4.ogg in Resources */, - 84B1E2C72E051B7D00ED000A /* old_explode.ogg in Resources */, - 84C208532AF88A5000BAE438 /* grass_side_transparent.png in Resources */, - 84B1E23A2E051B7D00ED000A /* hit1.ogg in Resources */, - 84B1E2A52E051B7D00ED000A /* snare.ogg in Resources */, - 8477B43C2C4DE77F004E1AC5 /* worldname_iphone_3.png in Resources */, - 84B1E2072E051B7D00ED000A /* chicken2.ogg in Resources */, - 8477B4302C4DE77F004E1AC5 /* create_1_1.png in Resources */, - 84B1E2562E051B7D00ED000A /* sheep3.ogg in Resources */, - 8477B4252C4DE77F004E1AC5 /* save_1_3.png in Resources */, - 8494882E2C92844C006DB706 /* vignette.png in Resources */, - 8477B4162C4DE77F004E1AC5 /* create_1_3.png in Resources */, - 84B1E25F2E051B7D00ED000A /* step1.ogg in Resources */, - 84B1E2BD2E051B7D00ED000A /* explode2.ogg in Resources */, - 84B1E2542E051B7D00ED000A /* sheep1.ogg in Resources */, - 84B1E0652E051B6400ED000A /* cow.png in Resources */, - 84B1E2E22E051B7D00ED000A /* stone3.ogg in Resources */, - 84B1E2A92E051B7D00ED000A /* bow.ogg in Resources */, - 8494882A2C92844C006DB706 /* foliagecolor.png in Resources */, - 84B1E2242E051B7D00ED000A /* scream1.ogg in Resources */, - 84B1E1EA2E051B7D00ED000A /* lava.ogg in Resources */, - 84B1E2A82E051B7D00ED000A /* trigger.ogg in Resources */, - 84B1E2462E051B7D00ED000A /* big4.ogg in Resources */, - 84B1E21A2E051B7D00ED000A /* hit2.ogg in Resources */, - 84B1E1F12E051B7D00ED000A /* breathe4.ogg in Resources */, - 84B1E2682E051B7D00ED000A /* skeletonhurt2.ogg in Resources */, - 84B1E0592E050D2500ED000A /* pigzombie.png in Resources */, - 84C208542AF88A5000BAE438 /* patch_data.txt in Resources */, - 8477B40B2C4DE77F004E1AC5 /* cancel_0.png in Resources */, - 8477B43D2C4DE77F004E1AC5 /* Icon-72.png in Resources */, - 84B1E2182E051B7D00ED000A /* death.ogg in Resources */, - 84B1E2052E051B7D00ED000A /* purreow2.ogg in Resources */, - 84B1E0672E051B6400ED000A /* pig.png in Resources */, - 84B1E2212E051B7D00ED000A /* idle5.ogg in Resources */, - 84B1E1E02E051B7D00ED000A /* thunder2.ogg in Resources */, - 84B1E2BF2E051B7D00ED000A /* explode4.ogg in Resources */, - 84B1E2032E051B7D00ED000A /* purr3.ogg in Resources */, - 84B1E2F02E051B7D00ED000A /* gravel3.ogg in Resources */, - 84ED99D52AFF12D1003B6AF0 /* minecraftpe.entitlements in Resources */, - 84B1E2502E051B7D00ED000A /* pig1.ogg in Resources */, - 84AA8C792B32F578003F5B82 /* gui_custom.png in Resources */, - 84B1E21F2E051B7D00ED000A /* idle3.ogg in Resources */, - 84B1E2A42E051B7D00ED000A /* pling.ogg in Resources */, - 84B1E2722E051B7D00ED000A /* spider1.ogg in Resources */, - 84B1E05E2E050D2500ED000A /* slime.png in Resources */, - 8477B4402C4DE77F004E1AC5 /* Icon-Small-50_lite.png in Resources */, - 84B1E28E2E051B7D00ED000A /* zombie1.ogg in Resources */, - 84B1E23C2E051B7D00ED000A /* hit3.ogg in Resources */, - 84B1E24E2E051B7D00ED000A /* small4.ogg in Resources */, - 84B1E2B82E051B7D00ED000A /* eat1.ogg in Resources */, - 84B1E2482E051B7D00ED000A /* jump2.ogg in Resources */, - 84E78C8C2B58BB7400D515EF /* n_rocket_launched.png in Resources */, - 8477B4332C4DE77F004E1AC5 /* creative_1_3.png in Resources */, - 8477B42D2C4DE77F004E1AC5 /* cancel_1_3.png in Resources */, - 84B1E1C82E051B7D00ED000A /* hal4.ogg in Resources */, - 84B1E2642E051B7D00ED000A /* skeleton2.ogg in Resources */, - 84E1C9BE2E7FDAE3007D2F5D /* tall_grass.png in Resources */, - 84B1E2572E051B7D00ED000A /* hit1.ogg in Resources */, - 84B1E2932E051B7D00ED000A /* zombiehurt2.ogg in Resources */, - 84E78C8D2B58BB7400D515EF /* n_rocket_launcher.png in Resources */, - 84B1E2DF2E051B7D00ED000A /* snow4.ogg in Resources */, - 84B1E2882E051B7D00ED000A /* metal3.ogg in Resources */, - 84B1E1C22E051B7D00ED000A /* calm1.ogg in Resources */, - 8477B4282C4DE77F004E1AC5 /* worldname_iphone.png in Resources */, - 8477B4322C4DE77F004E1AC5 /* creative_0_3.png in Resources */, - 84B1E2142E051B7D00ED000A /* creeper2.ogg in Resources */, - 84E78C8E2B58BB7400D515EF /* n_rocket.png in Resources */, - 849488322C928459006DB706 /* moon.png in Resources */, - 84B1E1DF2E051B7D00ED000A /* thunder1.ogg in Resources */, - 84B1E2E72E051B7D00ED000A /* wood4.ogg in Resources */, - 84B1E2802E051B7D00ED000A /* hurt1.ogg in Resources */, - 84E78C902B58C18C00D515EF /* black.png in Resources */, - 84B1E1EB2E051B7D00ED000A /* lavapop.ogg in Resources */, - 84B1E2222E051B7D00ED000A /* portal.ogg in Resources */, - 84B1E2D92E051B7D00ED000A /* sand2.ogg in Resources */, - 8477B4172C4DE77F004E1AC5 /* cancel_0_4.png in Resources */, - 84B1E2202E051B7D00ED000A /* idle4.ogg in Resources */, - 8477B42B2C4DE77F004E1AC5 /* cancel_0_3.png in Resources */, + 84D772272EE5182B00701DCB /* assets in Resources */, + 849371392EE51EAB00081C5A /* Default-568h@2x.png in Resources */, + 8493713A2EE51EAB00081C5A /* Default-Landscape~ipad.png in Resources */, + 8493713B2EE51EAB00081C5A /* Default.png in Resources */, + 8493713C2EE51EAB00081C5A /* Default@2x.png in Resources */, + 8493713E2EE51F4000081C5A /* icon.png in Resources */, + 849371322EE51DE000081C5A /* InfoPlist.strings in Resources */, + 849371312EE51DCD00081C5A /* MainWindow.xib in Resources */, + 849371332EE51DE800081C5A /* minecraftpeViewController.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -7047,7 +5859,109 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 84EB0DC72EE2D4B4008FB007 /* RenderContextOGL.cpp in Sources */, + 84EB0D342EE2D4B3008FB007 /* RasterizerStateBase.cpp in Sources */, + 84EB0DC52EE2D4B4008FB007 /* RasterizerStateOGL.cpp in Sources */, + 84EB0DD72EE2D4B4008FB007 /* ShaderUniformOGL.cpp in Sources */, + 84EB0DE82EE2D4B4008FB007 /* PerFrameConstants.cpp in Sources */, + 84EB0DCD2EE2D4B4008FB007 /* ShaderConstantOGL.cpp in Sources */, + 84EB0DB12EE2D4B4008FB007 /* API_OGL.cpp in Sources */, + 84EB0D8F2EE2D4B3008FB007 /* ShaderProgram.cpp in Sources */, + 84EB0D142EE2D4B3008FB007 /* ConstantBufferMetaData.cpp in Sources */, + 84EB0DE02EE2D4B4008FB007 /* TextureDescription.cpp in Sources */, + 84EB0DC12EE2D4B4008FB007 /* ImmediateBufferOGL.cpp in Sources */, + 84EB0D442EE2D4B3008FB007 /* ShaderProgramBase.cpp in Sources */, + 84EB0E012EE2D4B4008FB007 /* TexturePtr.cpp in Sources */, + 84EB0D7A2EE2D4B3008FB007 /* ConstantBufferContainer.cpp in Sources */, + 84EB0D7E2EE2D4B3008FB007 /* FixedPipelineState.cpp in Sources */, + 84EB0D122EE2D4B3008FB007 /* Attribute.cpp in Sources */, + 84EB0D802EE2D4B3008FB007 /* FogState.cpp in Sources */, + 84EB0D242EE2D4B3008FB007 /* ConstantBufferBase.cpp in Sources */, + 84EB0DFB2EE2D4B4008FB007 /* ShaderGroupBase.cpp in Sources */, + 84EB0D4D2EE2D4B3008FB007 /* BlendTarget_JsonParser.cpp in Sources */, + 84EB0D6B2EE2D4B3008FB007 /* FogStateDescription.cpp in Sources */, + 84EB0D1E2EE2D4B3008FB007 /* GlobalConstantBuffers.cpp in Sources */, + 84EB0D382EE2D4B3008FB007 /* RenderContextStateBase.cpp in Sources */, + 84EB0D6D2EE2D4B3008FB007 /* ErrorHandler.cpp in Sources */, + 84EB0DFF2EE2D4B4008FB007 /* TextureGroup.cpp in Sources */, + 84EB0DCB2EE2D4B4008FB007 /* ResourceOGL.cpp in Sources */, + 84EB0D862EE2D4B3008FB007 /* RenderContext.cpp in Sources */, + 84EB0D912EE2D4B3008FB007 /* Texture.cpp in Sources */, + 84EB0D772EE2D4B3008FB007 /* ConstantBuffer.cpp in Sources */, + 84EB0D182EE2D4B3008FB007 /* EnableScissorTest.cpp in Sources */, + 84EB0D4A2EE2D4B3008FB007 /* DepthStencilStateDescription.cpp in Sources */, + 84EB0D162EE2D4B3008FB007 /* ConstantBufferMetaDataManager.cpp in Sources */, + 84EB0DC32EE2D4B4008FB007 /* ProfileSectionOGL.cpp in Sources */, + 84EB0D8A2EE2D4B3008FB007 /* Shader.cpp in Sources */, + 84EB0E092EE2D4B4008FB007 /* WorldConstants.cpp in Sources */, + 84EB0DB72EE2D4B4008FB007 /* ConstantBufferContainerOGL.cpp in Sources */, + 84EB0DB52EE2D4B4008FB007 /* BufferOGL.cpp in Sources */, + 84EB0D842EE2D4B3008FB007 /* RasterizerState.cpp in Sources */, + 84EB0DFD2EE2D4B4008FB007 /* StencilRefObject.cpp in Sources */, + 84EB0DF32EE2D4B4008FB007 /* RenderContextImmediate.cpp in Sources */, + 84EB0D642EE2D4B3008FB007 /* TextureFiltering_JsonParser.cpp in Sources */, + 84EB0DBD2EE2D4B4008FB007 /* FogStateOGL.cpp in Sources */, + 84EB0D322EE2D4B3008FB007 /* ImmediateBufferBase.cpp in Sources */, + 84EB0D282EE2D4B3008FB007 /* ConstantBufferContainerBase.cpp in Sources */, + 84EB0D2A2EE2D4B3008FB007 /* DepthStencilStateBase.cpp in Sources */, + 84EB0D5E2EE2D4B3008FB007 /* ShaderStagesBits_JsonParser.cpp in Sources */, + 84EB0D882EE2D4B3008FB007 /* RenderDevice.cpp in Sources */, + 84EB0D3E2EE2D4B3008FB007 /* ShaderConstantBase.cpp in Sources */, + 84EB0D1A2EE2D4B3008FB007 /* EntityConstants.cpp in Sources */, + 84EB0DDE2EE2D4B4008FB007 /* StencilFaceDescription.cpp in Sources */, + 84EB0D7C2EE2D4B3008FB007 /* DepthStencilState.cpp in Sources */, + 84EB0D622EE2D4B3008FB007 /* StencilOp_JsonParser.cpp in Sources */, + 84EB0DCF2EE2D4B4008FB007 /* ShaderConstantWithDataOGL.cpp in Sources */, + 84EB0DE62EE2D4B4008FB007 /* Mesh.cpp in Sources */, + 84EB0E072EE2D4B4008FB007 /* WeatherConstants.cpp in Sources */, + 84EB0D402EE2D4B3008FB007 /* ShaderConstantWithDataBase.cpp in Sources */, + 84EB0D3A2EE2D4B3008FB007 /* RenderDeviceBase.cpp in Sources */, + 84EB0DC92EE2D4B4008FB007 /* RenderDeviceOGL.cpp in Sources */, + 84EB0D2E2EE2D4B3008FB007 /* FogStateBase.cpp in Sources */, + 84EB0DE22EE2D4B4008FB007 /* MaterialPtr.cpp in Sources */, + 84EB0DEC2EE2D4B4008FB007 /* ShaderPrecision.cpp in Sources */, + 84EB0DB32EE2D4B4008FB007 /* BlendStateOGL.cpp in Sources */, + 84EB0DF52EE2D4B4008FB007 /* RenderMaterial.cpp in Sources */, + 84EB0D822EE2D4B3008FB007 /* ImmediateBuffer.cpp in Sources */, + 84EB0D1C2EE2D4B3008FB007 /* GlobalConstantBufferManager.cpp in Sources */, + 84EB0DBF2EE2D4B4008FB007 /* GPUEventsOGL.cpp in Sources */, + 84EB0DF92EE2D4B4008FB007 /* ShaderGroup.cpp in Sources */, + 84EB0DBB2EE2D4B4008FB007 /* FixedPipelineStateOGL.cpp in Sources */, + 84EB0DDB2EE2D4B4008FB007 /* RasterizerStateDescription.cpp in Sources */, + 84EB0DD32EE2D4B4008FB007 /* ShaderProgramOGL.cpp in Sources */, + 84EB0D262EE2D4B3008FB007 /* ConstantBufferConstantsBase.cpp in Sources */, + 84EB0D3C2EE2D4B3008FB007 /* ShaderBase.cpp in Sources */, + 84EB0D462EE2D4B3008FB007 /* TextureBase.cpp in Sources */, + 84EB0DEF2EE2D4B4008FB007 /* QuadIndexBuffer.cpp in Sources */, + 84EB0D362EE2D4B3008FB007 /* RenderContextBase.cpp in Sources */, + 84EB0E052EE2D4B4008FB007 /* VertexFormat.cpp in Sources */, + 84EB0D752EE2D4B3008FB007 /* Buffer.cpp in Sources */, + 84EB0D2C2EE2D4B3008FB007 /* FixedPipelineStateBase.cpp in Sources */, + 84EB0E032EE2D4B4008FB007 /* UniformMetaData.cpp in Sources */, + 84EB0D5B2EE2D4B3008FB007 /* ShaderPrimitiveTypes.cpp in Sources */, + 84EB0DF72EE2D4B4008FB007 /* ShaderConstants.cpp in Sources */, + 84EB0D562EE2D4B3008FB007 /* PrimitiveMode_JsonParser.cpp in Sources */, 8406FD2A2AF181B800B09C1D /* GL.cpp in Sources */, + 84EB0D692EE2D4B3008FB007 /* FixedPipelineStateDescription.cpp in Sources */, + 84EB0DD92EE2D4B4008FB007 /* TextureOGL.cpp in Sources */, + 84EB0DD52EE2D4B4008FB007 /* ShaderResourceOGL.cpp in Sources */, + 84EB0D732EE2D4B3008FB007 /* BlendState.cpp in Sources */, + 84EB0DB92EE2D4B4008FB007 /* DepthStencilStateOGL.cpp in Sources */, + 84EB0D222EE2D4B3008FB007 /* BufferBase.cpp in Sources */, + 84EB0D512EE2D4B3008FB007 /* ComparisonFunc_JsonParser.cpp in Sources */, + 84EB0DEA2EE2D4B4008FB007 /* Extensions.cpp in Sources */, + 84EB0D712EE2D4B3008FB007 /* ImageDescription.cpp in Sources */, + 84EB0D302EE2D4B3008FB007 /* FrameBufferObjectBase.cpp in Sources */, + 84EB0D202EE2D4B3008FB007 /* BlendStateBase.cpp in Sources */, + 84EB0D482EE2D4B3008FB007 /* BlendStateDescription.cpp in Sources */, + 84EB0D6F2EE2D4B3008FB007 /* TextureHelper.cpp in Sources */, + 84EB0D8D2EE2D4B3008FB007 /* ShaderConstantWithData.cpp in Sources */, + 84EB0DD12EE2D4B4008FB007 /* ShaderOGL.cpp in Sources */, + 84EB0D582EE2D4B3008FB007 /* RenderState_JsonParser.cpp in Sources */, + 84EB0D422EE2D4B3008FB007 /* ShaderContextBase.cpp in Sources */, + 84EB0D672EE2D4B3008FB007 /* VertexField_JsonParser.cpp in Sources */, + 84EB0DE42EE2D4B4008FB007 /* MatrixStack.cpp in Sources */, + 84EB0DF12EE2D4B4008FB007 /* RenderChunkConstants.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -7148,25 +6062,16 @@ files = ( 849259592AD8FD4F0081F5B9 /* minecraftpeAppDelegate.mm in Sources */, 8492595A2AD8FD4F0081F5B9 /* minecraftpeViewController.mm in Sources */, - 8492595B2AD8FD4F0081F5B9 /* Shader.fsh in Sources */, - 8492595C2AD8FD4F0081F5B9 /* Shader.vsh in Sources */, 849259622AD8FDD10081F5B9 /* main.m in Sources */, 8441F98F2DB4E911005977BD /* SoundSystemAL.cpp in Sources */, 84CEF0032AE3C97D006C5829 /* EAGLView.m in Sources */, + 84D770132EE5158C00701DCB /* stb_image_impl.c in Sources */, 8495E4892AF0905B00A06901 /* AppPlatform_iOS.mm in Sources */, 8435BB1A2DCD47F400D38282 /* SoundStreamAL.cpp in Sources */, 8488C08A2B1EDD4F001AEC4F /* ShowKeyboardView.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; - 84AAF5EA2AF18B9500BD67F4 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 84AAF6432AF18BD000BD67F4 /* GLExt.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; 84B8AE722AF188D8008DE93D /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -7183,11 +6088,7 @@ 84B8AF032AF1896F008DE93D /* SavingWorldScreen.cpp in Sources */, 84B8AF042AF1896F008DE93D /* SelectWorldScreen.cpp in Sources */, 84B8AF052AF1896F008DE93D /* StartMenuScreen.cpp in Sources */, - 84B8AF062AF1896F008DE93D /* Cube.cpp in Sources */, - 84B8AF072AF1896F008DE93D /* HumanoidModel.cpp in Sources */, 8477B3A22C4DC374004E1AC5 /* ControllerBuildInput.cpp in Sources */, - 84B8AF082AF1896F008DE93D /* Model.cpp in Sources */, - 84B8AF092AF1896F008DE93D /* PolygonQuad.cpp in Sources */, 84F77A682EA1C0A10045C907 /* MultiPlayerLevel.cpp in Sources */, 84B8AF0A2AF1896F008DE93D /* ClientSideNetworkHandler.cpp in Sources */, 84B8AF0B2AF1896F008DE93D /* Options.cpp in Sources */, @@ -7202,6 +6103,7 @@ 84B8AF332AF1896F008DE93D /* SoundEngine.cpp in Sources */, 84B8AF342AF1896F008DE93D /* SoundRepository.cpp in Sources */, 84B8AF352AF1896F008DE93D /* SoundSystem.cpp in Sources */, + 84EB09DE2EE2CC86008FB007 /* ZombieModel.cpp in Sources */, 84B1E02F2E04FD4500ED000A /* ArrowRenderer.cpp in Sources */, 84B8AEE82AF1890A008DE93D /* App.cpp in Sources */, 84B8AEE92AF1890A008DE93D /* AppPlatform.cpp in Sources */, @@ -7209,16 +6111,21 @@ 84B8AEEB2AF1890A008DE93D /* NinecraftApp.cpp in Sources */, 84B8AEEC2AF1890A008DE93D /* AvailableGamesList.cpp in Sources */, 84B8AEED2AF1890A008DE93D /* Button.cpp in Sources */, + 84EB09FA2EE2CCA8008FB007 /* TextureData.cpp in Sources */, 84B8AEEE2AF1890A008DE93D /* RolledSelectionList.cpp in Sources */, 84B8AEEF2AF1890A008DE93D /* ScrolledSelectionList.cpp in Sources */, 84B8AEF02AF1890A008DE93D /* SmallButton.cpp in Sources */, 84B8AEF12AF1890A008DE93D /* TextInputBox.cpp in Sources */, + 84EB09F12EE2CCA8008FB007 /* EntityShaderManager.cpp in Sources */, 84CED51F2E672826006BC585 /* ConvertWorldScreen.cpp in Sources */, 84B8AEF22AF1890A008DE93D /* WorldSelectionList.cpp in Sources */, + 84EB09F32EE2CCA8008FB007 /* RenderMaterialGroup.cpp in Sources */, 84B8AEF32AF1890A008DE93D /* Gui.cpp in Sources */, 84B8AEF42AF1890A008DE93D /* GuiComponent.cpp in Sources */, 84B8AEF52AF1890A008DE93D /* Screen.cpp in Sources */, 84B8AEF62AF1890A008DE93D /* ChatScreen.cpp in Sources */, + 84EB09C12EE2CC86008FB007 /* Cube.cpp in Sources */, + 84EB09D02EE2CC86008FB007 /* Model.cpp in Sources */, 84B8AEF72AF1890A008DE93D /* ConfirmScreen.cpp in Sources */, 84B8AEF82AF1890A008DE93D /* CreateWorldScreen.cpp in Sources */, 84B8AEF92AF1890A008DE93D /* DeathScreen.cpp in Sources */, @@ -7228,11 +6135,14 @@ 84E001212AF39E84009B9555 /* IInputHolder.cpp in Sources */, 84E001232AF39E84009B9555 /* IMoveInput.cpp in Sources */, 84E001252AF39E84009B9555 /* IncludeExcludeArea.cpp in Sources */, + 84EB09D62EE2CC86008FB007 /* SheepFurModel.cpp in Sources */, + 84EB09DA2EE2CC86008FB007 /* SkeletonModel.cpp in Sources */, 84E001272AF39E84009B9555 /* ITouchScreenModel.cpp in Sources */, 84E001292AF39E84009B9555 /* MouseDevice.cpp in Sources */, 84E0012B2AF39E84009B9555 /* MouseHandler.cpp in Sources */, 84E0012D2AF39E84009B9555 /* Multitouch.cpp in Sources */, 84E0012F2AF39E84009B9555 /* PolygonArea.cpp in Sources */, + 84EB09C32EE2CC86008FB007 /* ModelPart.cpp in Sources */, 84E001312AF39E84009B9555 /* RectangleArea.cpp in Sources */, 84E001332AF39E84009B9555 /* TouchAreaModel.cpp in Sources */, 84E001352AF39E84009B9555 /* TouchInputHolder.cpp in Sources */, @@ -7244,21 +6154,28 @@ 84AA8BEF2B32F3F3003F5B82 /* DynamicTexture.cpp in Sources */, 84AA8BF12B32F3F3003F5B82 /* ChickenRenderer.cpp in Sources */, 84AA8BF32B32F3F3003F5B82 /* CowRenderer.cpp in Sources */, + 84EB09CA2EE2CC86008FB007 /* CowModel.cpp in Sources */, 84AA8BF52B32F3F3003F5B82 /* CreeperRenderer.cpp in Sources */, 84AA8BF72B32F3F3003F5B82 /* EntityRenderDispatcher.cpp in Sources */, 8477B3A42C4DC374004E1AC5 /* ControllerMoveInput.cpp in Sources */, + 84EB09EF2EE2CCA8008FB007 /* Fog.cpp in Sources */, 84AA8BF92B32F3F3003F5B82 /* EntityRenderer.cpp in Sources */, + 84EB09C52EE2CC86008FB007 /* PolygonQuad.cpp in Sources */, 84AA8BFB2B32F3F3003F5B82 /* FallingTileRenderer.cpp in Sources */, + 84EB09C82EE2CC86008FB007 /* ChickenModel.cpp in Sources */, 84AA8BFD2B32F3F3003F5B82 /* HumanoidMobRenderer.cpp in Sources */, + 84EB09CE2EE2CC86008FB007 /* HumanoidModel.cpp in Sources */, 84AA8BFF2B32F3F3003F5B82 /* ItemRenderer.cpp in Sources */, 84AA8C012B32F3F3003F5B82 /* ItemSpriteRenderer.cpp in Sources */, 84AA8C032B32F3F3003F5B82 /* MobRenderer.cpp in Sources */, + 84EB09962EE2CC25008FB007 /* AppPlatformListener.cpp in Sources */, 84AA8C052B32F3F3003F5B82 /* PigRenderer.cpp in Sources */, 84AA8C072B32F3F3003F5B82 /* SheepFurRenderer.cpp in Sources */, 84AA8C092B32F3F3003F5B82 /* SheepRenderer.cpp in Sources */, 84AA8C0D2B32F3F3003F5B82 /* SpiderRenderer.cpp in Sources */, 84AA8C0F2B32F3F3003F5B82 /* TntRenderer.cpp in Sources */, 84AA8C112B32F3F3003F5B82 /* TripodCameraRenderer.cpp in Sources */, + 84EB09D42EE2CC86008FB007 /* QuadrupedModel.cpp in Sources */, 84F77A6E2EA1C27B0045C907 /* LocalPlayer.cpp in Sources */, 84F77A6A2EA1C0A10045C907 /* MultiplayerLocalPlayer.cpp in Sources */, 84AA8C152B32F3F3003F5B82 /* FireTexture.cpp in Sources */, @@ -7268,13 +6185,18 @@ 84AA8C1C2B32F3F3003F5B82 /* FrustumCuller.cpp in Sources */, 84A2FF1A2DB61D720090CE3E /* SoundPathRepository.cpp in Sources */, 84AA8C1E2B32F3F3003F5B82 /* GameRenderer.cpp in Sources */, + 84EB09F52EE2CCA8008FB007 /* ScreenRenderer.cpp in Sources */, 84AA8C202B32F3F3003F5B82 /* GrassColor.cpp in Sources */, 84AA8C222B32F3F3003F5B82 /* ItemInHandRenderer.cpp in Sources */, 84AA8C242B32F3F3003F5B82 /* LavaSideTexture.cpp in Sources */, 84AA8C252B32F3F3003F5B82 /* LavaTexture.cpp in Sources */, + 84EB09CC2EE2CC86008FB007 /* CreeperModel.cpp in Sources */, + 84EB099B2EE2CC3B008FB007 /* GuiElement.cpp in Sources */, 84AA8C262B32F3F3003F5B82 /* LevelRenderer.cpp in Sources */, 84AA8C282B32F3F3003F5B82 /* LightLayer.cpp in Sources */, + 84EB09D82EE2CC86008FB007 /* SheepModel.cpp in Sources */, 84AA8C2A2B32F3F3003F5B82 /* LightUpdate.cpp in Sources */, + 84EB09D22EE2CC86008FB007 /* PigModel.cpp in Sources */, 84AA8C2C2B32F3F3003F5B82 /* PatchManager.cpp in Sources */, 84AA8C2E2B32F3F3003F5B82 /* RenderChunk.cpp in Sources */, 849488362C9284DA006DB706 /* Lighting.cpp in Sources */, @@ -7285,18 +6207,9 @@ 84AA8C372B32F3F3003F5B82 /* TileRenderer.cpp in Sources */, 84AA8C3A2B32F3F3003F5B82 /* WaterSideTexture.cpp in Sources */, 84AA8C3B2B32F3F3003F5B82 /* WaterTexture.cpp in Sources */, - 84AA8C5A2B32F535003F5B82 /* ChickenModel.cpp in Sources */, - 84AA8C5C2B32F535003F5B82 /* CowModel.cpp in Sources */, - 84AA8C5E2B32F535003F5B82 /* CreeperModel.cpp in Sources */, + 84EB09DC2EE2CC86008FB007 /* SpiderModel.cpp in Sources */, + 84EB09F82EE2CCA8008FB007 /* ImageData.cpp in Sources */, 8477B3A62C4DC374004E1AC5 /* MouseBuildInput.cpp in Sources */, - 84AA8C662B32F535003F5B82 /* ModelPart.cpp in Sources */, - 84AA8C682B32F535003F5B82 /* PigModel.cpp in Sources */, - 84AA8C6C2B32F535003F5B82 /* QuadrupedModel.cpp in Sources */, - 84AA8C6E2B32F535003F5B82 /* SheepFurModel.cpp in Sources */, - 84AA8C702B32F535003F5B82 /* SheepModel.cpp in Sources */, - 84AA8C722B32F535003F5B82 /* SkeletonModel.cpp in Sources */, - 84AA8C742B32F535003F5B82 /* SpiderModel.cpp in Sources */, - 84AA8C762B32F536003F5B82 /* ZombieModel.cpp in Sources */, 84E78C7F2B58B5CC00D515EF /* RocketRenderer.cpp in Sources */, 8470AF402BE9B80900BCA54E /* DisconnectionScreen.cpp in Sources */, ); @@ -7490,14 +6403,17 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 84EB0E122EE2D4D4008FB007 /* Singleton.cpp in Sources */, 84E4BFB52AE9869A0023E16A /* CThread.cpp in Sources */, 84CCBC3F2E6183F300E251AF /* DataIO.cpp in Sources */, + 84EB0E102EE2D4D4008FB007 /* JsonParser.cpp in Sources */, 84E4BFB62AE9869A0023E16A /* Logger.cpp in Sources */, - 84E4BFB72AE9869A0023E16A /* Matrix.cpp in Sources */, 84E4BFB82AE9869A0023E16A /* Mth.cpp in Sources */, 84E4BFB92AE9869A0023E16A /* Random.cpp in Sources */, 84E4BFBB2AE9869A0023E16A /* Timer.cpp in Sources */, 84E4BFBC2AE9869A0023E16A /* Util.cpp in Sources */, + 84EB0E0B2EE2D4CA008FB007 /* Color.cpp in Sources */, + 84EB0E0D2EE2D4D4008FB007 /* AlignmentHelper.cpp in Sources */, 84E4BFBD2AE9869A0023E16A /* Utils.cpp in Sources */, 84E001B82AF3A3CB009B9555 /* SmoothFloat.cpp in Sources */, ); @@ -7662,11 +6578,6 @@ target = 84498A762AF18C7A005EF5A5 /* ZLib */; targetProxy = 84619B1C2AF1EC3500B0DE81 /* PBXContainerItemProxy */; }; - 84AAF6472AF18C0600BD67F4 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 84AAF5972AF18B9500BD67F4 /* OpenGL */; - targetProxy = 84AAF6462AF18C0600BD67F4 /* PBXContainerItemProxy */; - }; 84B8AF842AF18A25008DE93D /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 84E4BFAD2AE9854B0023E16A /* Common */; @@ -7819,6 +6730,10 @@ "\\\"$(DEVELOPER_FRAMEWORKS_DIR)\\\"", ); GCC_FAST_MATH = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(BACKEND_SDL2)", + "$(inherited)", + ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; @@ -8325,14 +7240,6 @@ }; name = "Debug [iOS] (Default)"; }; - 84619B2C2AF1F32500B0DE81 /* Debug [iOS] (Default) */ = { - isa = XCBuildConfiguration; - buildSettings = { - EXECUTABLE_PREFIX = lib; - PRODUCT_NAME = OpenGL; - }; - name = "Debug [iOS] (Default)"; - }; 84619B2D2AF1F32500B0DE81 /* Debug [iOS] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { @@ -8482,14 +7389,6 @@ }; name = "Release [iOS] (Default)"; }; - 84619B372AF1F33A00B0DE81 /* Release [iOS] (Default) */ = { - isa = XCBuildConfiguration; - buildSettings = { - EXECUTABLE_PREFIX = lib; - PRODUCT_NAME = OpenGL; - }; - name = "Release [iOS] (Default)"; - }; 84619B382AF1F33A00B0DE81 /* Release [iOS] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { @@ -8539,6 +7438,10 @@ ); GCC_FAST_MATH = YES; GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(BACKEND_SDL2)", + "$(inherited)", + ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; @@ -8605,6 +7508,10 @@ "\\\"$(DEVELOPER_FRAMEWORKS_DIR)\\\"", ); GCC_FAST_MATH = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(BACKEND_SDL2)", + "$(inherited)", + ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; @@ -8732,46 +7639,6 @@ }; name = "Release [SDL1] (x86-PPC)"; }; - 84AAF63D2AF18B9500BD67F4 /* Debug [SDL2] (Default) */ = { - isa = XCBuildConfiguration; - buildSettings = { - EXECUTABLE_PREFIX = lib; - PRODUCT_NAME = OpenGL; - }; - name = "Debug [SDL2] (Default)"; - }; - 84AAF63E2AF18B9500BD67F4 /* Release [SDL2] (Default) */ = { - isa = XCBuildConfiguration; - buildSettings = { - EXECUTABLE_PREFIX = lib; - PRODUCT_NAME = OpenGL; - }; - name = "Release [SDL2] (Default)"; - }; - 84AAF63F2AF18B9500BD67F4 /* Release [SDL2] (x86) */ = { - isa = XCBuildConfiguration; - buildSettings = { - EXECUTABLE_PREFIX = lib; - PRODUCT_NAME = OpenGL; - }; - name = "Release [SDL2] (x86)"; - }; - 84AAF6402AF18B9500BD67F4 /* Release [SDL1] (PPC) */ = { - isa = XCBuildConfiguration; - buildSettings = { - EXECUTABLE_PREFIX = lib; - PRODUCT_NAME = OpenGL; - }; - name = "Release [SDL1] (PPC)"; - }; - 84AAF6412AF18B9500BD67F4 /* Release [SDL1] (x86-PPC) */ = { - isa = XCBuildConfiguration; - buildSettings = { - EXECUTABLE_PREFIX = lib; - PRODUCT_NAME = OpenGL; - }; - name = "Release [SDL1] (x86-PPC)"; - }; 84B8AEE22AF188D8008DE93D /* Debug [SDL2] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { @@ -9107,14 +7974,6 @@ }; name = "Debug [SDL1] (Default)"; }; - 84EDCFE02E76D7BD00375AEF /* Debug [SDL1] (Default) */ = { - isa = XCBuildConfiguration; - buildSettings = { - EXECUTABLE_PREFIX = lib; - PRODUCT_NAME = OpenGL; - }; - name = "Debug [SDL1] (Default)"; - }; 84EDCFE12E76D7BD00375AEF /* Debug [SDL1] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { @@ -9287,14 +8146,6 @@ }; name = "Release [SDL1] (Default)"; }; - 84EDCFED2E76D7ED00375AEF /* Release [SDL1] (Default) */ = { - isa = XCBuildConfiguration; - buildSettings = { - EXECUTABLE_PREFIX = lib; - PRODUCT_NAME = OpenGL; - }; - name = "Release [SDL1] (Default)"; - }; 84EDCFEE2E76D7ED00375AEF /* Release [SDL1] (Default) */ = { isa = XCBuildConfiguration; buildSettings = { @@ -9538,22 +8389,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = "Release [SDL2] (Default)"; }; - 84AAF63C2AF18B9500BD67F4 /* Build configuration list for PBXNativeTarget "OpenGL" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 84AAF63D2AF18B9500BD67F4 /* Debug [SDL2] (Default) */, - 84EDCFE02E76D7BD00375AEF /* Debug [SDL1] (Default) */, - 84619B2C2AF1F32500B0DE81 /* Debug [iOS] (Default) */, - 84AAF63E2AF18B9500BD67F4 /* Release [SDL2] (Default) */, - 84EDCFED2E76D7ED00375AEF /* Release [SDL1] (Default) */, - 84619B372AF1F33A00B0DE81 /* Release [iOS] (Default) */, - 84AAF63F2AF18B9500BD67F4 /* Release [SDL2] (x86) */, - 84AAF6402AF18B9500BD67F4 /* Release [SDL1] (PPC) */, - 84AAF6412AF18B9500BD67F4 /* Release [SDL1] (x86-PPC) */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = "Release [SDL2] (Default)"; - }; 84B8AEE12AF188D8008DE93D /* Build configuration list for PBXNativeTarget "Client" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/platforms/sdl/base/AppPlatform_sdl.cpp b/platforms/sdl/base/AppPlatform_sdl.cpp index c3228ca09..de895767b 100644 --- a/platforms/sdl/base/AppPlatform_sdl.cpp +++ b/platforms/sdl/base/AppPlatform_sdl.cpp @@ -11,6 +11,7 @@ #include "stb_image.h" #include "stb_image_write.h" +// needed for screenshots #include "thirdparty/GL/GL.hpp" #include "AppPlatform_sdl.hpp" @@ -31,7 +32,6 @@ void AppPlatform_sdl::_init(std::string storageDir) m_hWND = _getHWND(); - m_pIconTexture = nullptr; m_pIcon = nullptr; m_bShiftPressed[0] = false; @@ -67,7 +67,8 @@ void AppPlatform_sdl::_init(std::string storageDir) AppPlatform_sdl::~AppPlatform_sdl() { if (m_pIcon) SDL_FreeSurface(m_pIcon); - SAFE_DELETE(m_pIconTexture); + // SDL_FreeSurface already frees it? + m_iconImage.m_data = nullptr; SAFE_DELETE(m_pSoundSystem); } @@ -126,23 +127,24 @@ void AppPlatform_sdl::_ensureDirectoryExists(const char* path) } } -void AppPlatform_sdl::_setIcon(const Texture& icon) +void AppPlatform_sdl::_setIcon(ImageData& image) { - if (!icon.m_pixels) + if (image.isEmpty()) return; - SAFE_DELETE(m_pIconTexture); if (m_pIcon) SDL_FreeSurface(m_pIcon); - m_pIconTexture = new Texture(icon); - m_pIcon = _GetSurfaceForTexture(*m_pIconTexture); + m_iconImage.move(image); + m_pIcon = _GetSurfaceForImage(m_iconImage); _updateWindowIcon(); } void AppPlatform_sdl::_setDefaultIcon() { - _setIcon(loadTexture("icon.png", false)); + ImageData data; + loadImage(data, "icon.png"); + _setIcon(data); } void AppPlatform_sdl::initSoundSystem() @@ -214,6 +216,7 @@ int AppPlatform_sdl::getUserInputStatus() void AppPlatform_sdl::saveScreenshot(const std::string& filename, int glWidth, int glHeight) { +#if MCE_GFX_API_OGL // Get Directory std::string screenshots = m_storageDir + "/screenshots"; @@ -288,58 +291,7 @@ void AppPlatform_sdl::saveScreenshot(const std::string& filename, int glWidth, i { delete[] pixels; } -} - -Texture AppPlatform_sdl::loadTexture(const std::string& path, bool bIsRequired) -{ - Texture out; - out.m_hasAlpha = true; - out.field_D = 0; - - // Get Full Path - std::string realPath = getAssetPath(path); - - // Read File - SDL_RWops* io = SDL_RWFromFile(realPath.c_str(), "rb"); - if (!io) - { - LOG_E("Couldn't find file: %s", path.c_str()); - return out; - } - Sint64 size; -#if SDL_MAJOR_VERSION >= 2 - size = SDL_RWsize(io); -#else - size = SDL_RWseek(io, 0, SEEK_END); - SDL_RWseek(io, 0, SEEK_SET); #endif - unsigned char* file = new unsigned char[size]; - SDL_RWread(io, file, size, 1); - SDL_RWclose(io); - - // Parse Image - int width = 0, height = 0, channels = 0; - stbi_uc* img = stbi_load_from_memory(file, size, &width, &height, &channels, STBI_rgb_alpha); - delete[] file; - if (!img) - { - // Failed To Parse Image - LOG_E("The image could not be loaded properly: %s", path.c_str()); - return out; - } - - // Copy Image - uint32_t* img2 = new uint32_t[width * height]; - memcpy(img2, img, width * height * sizeof(uint32_t)); - stbi_image_free(img); - - // Create Texture - out.m_width = width; - out.m_height = height; - out.m_pixels = img2; - - // Return - return out; } bool AppPlatform_sdl::doesTextureExist(const std::string& path) const @@ -446,21 +398,27 @@ AssetFile AppPlatform_sdl::readAssetFile(const std::string& str, bool quiet) con return AssetFile(size, buf); } -SDL_Surface* AppPlatform_sdl::_GetSurfaceForTexture(const Texture& texture) +SDL_Surface* AppPlatform_sdl::_GetSurfaceForImage(ImageData& image) { - void* pixels = texture.m_pixels; - int width = texture.m_width; - int height = texture.m_height; + image.forceRGBA(); + + void* pixels = image.m_data; + int width = image.m_width; + int height = image.m_height; int depth = 32; // Color depth (32-bit by default) - SDL_Surface* surface = SDL_CreateRGBSurfaceFrom( - pixels, width, height, depth, - width * 4, // Pitch + Uint32 Rmask, Gmask, Bmask, Amask; + #if MC_ENDIANNESS_LITTLE - 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 + Rmask = 0x000000FF; Gmask = 0x0000FF00; Bmask = 0x00FF0000; Amask = 0xFF000000; #else // MC_ENDIANNESS_BIG - 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF + Rmask = 0xFF000000; Gmask = 0x00FF0000; Bmask = 0x0000FF00; Amask = 0x000000FF; #endif + + SDL_Surface* surface = SDL_CreateRGBSurfaceFrom( + pixels, width, height, depth, + width * 4, // Pitch + Rmask, Gmask, Bmask, Amask ); if (!surface) LOG_E("Failed loading SDL_Surface from Texture: %s", SDL_GetError()); diff --git a/platforms/sdl/base/AppPlatform_sdl.hpp b/platforms/sdl/base/AppPlatform_sdl.hpp index f0de08ac1..3f17abcfd 100644 --- a/platforms/sdl/base/AppPlatform_sdl.hpp +++ b/platforms/sdl/base/AppPlatform_sdl.hpp @@ -26,7 +26,7 @@ class AppPlatform_sdl : public AppPlatform virtual void _ensureDirectoryExists(const char* path); // desktop only virtual void* _getHWND() const { return nullptr; } - void _setIcon(const Texture& icon); // note: this takes ownership of the texture, so no memory leaks! + void _setIcon(ImageData& image); void _setDefaultIcon(); public: @@ -37,7 +37,6 @@ class AppPlatform_sdl : public AppPlatform int checkLicense() override; int getUserInputStatus() override; void saveScreenshot(const std::string& fileName, int width, int height) override; - Texture loadTexture(const std::string& path, bool bIsRequired = false) override; bool doesTextureExist(const std::string& path) const override; SoundSystem* const getSoundSystem() const override { return m_pSoundSystem; } @@ -65,7 +64,7 @@ class AppPlatform_sdl : public AppPlatform AssetFile readAssetFile(const std::string&, bool) const override; protected: - static SDL_Surface* _GetSurfaceForTexture(const Texture& texture); + static SDL_Surface* _GetSurfaceForImage(ImageData& image); static int _SavePng(const char* filename, unsigned char* pixels, int line_size, int width, int height); static int _TranslateSDLKeyCodeToVirtual(int sdlCode); @@ -75,7 +74,7 @@ class AppPlatform_sdl : public AppPlatform static Keyboard::KeyState GetKeyState(uint8_t state); protected: - const Texture* m_pIconTexture; + ImageData m_iconImage; SDL_Surface* m_pIcon; bool m_bControlPressed[2]; bool m_bShiftPressed[2]; diff --git a/platforms/sdl/sdl1/base/AppPlatform_sdl1.cpp b/platforms/sdl/sdl1/base/AppPlatform_sdl1.cpp index 226d33b9c..65a993806 100644 --- a/platforms/sdl/sdl1/base/AppPlatform_sdl1.cpp +++ b/platforms/sdl/sdl1/base/AppPlatform_sdl1.cpp @@ -1,7 +1,6 @@ #include "AppPlatform_sdl1.hpp" #include "thirdparty/SDL/SDL_gamecontroller.h" -#include "thirdparty/GL/GL.hpp" #include "CustomSoundSystem.hpp" #include "client/player/input/Controller.hpp" diff --git a/platforms/sdl/sdl1/main.cpp b/platforms/sdl/sdl1/main.cpp index 5946c179e..02f0fd392 100644 --- a/platforms/sdl/sdl1/main.cpp +++ b/platforms/sdl/sdl1/main.cpp @@ -1,7 +1,6 @@ #include #include "thirdparty/SDL/SDL.h" #include "thirdparty/SDL/SDL_gamecontroller.h" -#include "thirdparty/GL/GL.hpp" #include "client/app/App.hpp" #include "desktop/AppPlatform_sdl1_desktop.hpp" @@ -10,6 +9,11 @@ typedef AppPlatform_sdl1_desktop UsedAppPlatform; #include "client/app/NinecraftApp.hpp" #include "client/player/input/Multitouch.hpp" +#ifndef MCE_GFX_API_NULL +#define MCE_GFX_API_OGL 1 +#include "renderer/platform/ogl/Extensions.hpp" +#endif + // Video Mode Flags #define VIDEO_FLAGS (SDL_OPENGL | SDL_RESIZABLE) @@ -20,6 +24,27 @@ NinecraftApp* g_pApp; SDL_Surface* screen = NULL; +static void preInitGraphics() +{ +#if MCE_GFX_API_OGL + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); +#else +#endif +} + +static void initGraphics() +{ +#if MCE_GFX_API_OGL + if (!mce::Platform::OGL::InitBindings()) + { + const char* const GL_ERROR_MSG = "Error initializing GL extensions. OpenGL 2.0 or later is required."; + exit(EXIT_FAILURE); + } +#else +#endif +} + static void teardown() { if (screen != NULL) @@ -156,8 +181,7 @@ int main(int argc, char* argv[]) exit(EXIT_FAILURE); } - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + preInitGraphics(); SDL_EnableUNICODE(SDL_TRUE); @@ -168,14 +192,7 @@ int main(int argc, char* argv[]) exit(EXIT_FAILURE); } -#ifdef _WIN32 - xglInit(); - if (!xglInitted()) - { - const char* const GL_ERROR_MSG = "Error initializing GL extensions. OpenGL 2.0 or later is required."; - exit(EXIT_FAILURE); - } -#endif + initGraphics(); atexit(teardown); diff --git a/platforms/sdl/sdl2/base/AppPlatform_sdl2.cpp b/platforms/sdl/sdl2/base/AppPlatform_sdl2.cpp index 4e969d8ad..5c733afab 100644 --- a/platforms/sdl/sdl2/base/AppPlatform_sdl2.cpp +++ b/platforms/sdl/sdl2/base/AppPlatform_sdl2.cpp @@ -7,8 +7,6 @@ #ifdef __EMSCRIPTEN__ #include -#else -#include "thirdparty/GL/GL.hpp" #endif #include "compat/KeyCodes.hpp" diff --git a/platforms/sdl/sdl2/emscripten/AppPlatform_sdl2_emscripten.cpp b/platforms/sdl/sdl2/emscripten/AppPlatform_sdl2_emscripten.cpp index 6110a71b8..db05db7f9 100644 --- a/platforms/sdl/sdl2/emscripten/AppPlatform_sdl2_emscripten.cpp +++ b/platforms/sdl/sdl2/emscripten/AppPlatform_sdl2_emscripten.cpp @@ -7,26 +7,19 @@ AppPlatform_sdl2_emscripten::AppPlatform_sdl2_emscripten(std::string storageDir, { } -Texture AppPlatform_sdl2_emscripten::loadTexture(const std::string& path, bool bIsRequired) +void AppPlatform_sdl2_emscripten::loadImage(ImageData& data, const std::string& path) { - Texture out; - out.m_hasAlpha = true; - out.field_D = 0; - std::string realPath = getAssetPath(path); - char *data = emscripten_get_preloaded_image_data(("/" + realPath).c_str(), &out.m_width, &out.m_height); - if (data != NULL) + char *rawData = emscripten_get_preloaded_image_data(("/" + realPath).c_str(), &data.m_width, &data.m_height); + if (rawData == nullptr) { - size_t data_size = out.m_width * out.m_height; - out.m_pixels = new uint32_t[data_size]; - memcpy(out.m_pixels, data, data_size * sizeof(uint32_t)); - free(data); - return out; + LOG_E("Couldn't find file: %s", realPath.c_str()); + return; } - - LOG_E("Couldn't find file: %s", realPath.c_str()); - return out; + + data.m_data = (uint8_t*)rawData; + data.m_colorSpace = COLOR_SPACE_RGBA; } bool AppPlatform_sdl2_emscripten::doesTextureExist(const std::string& path) const diff --git a/platforms/sdl/sdl2/emscripten/AppPlatform_sdl2_emscripten.hpp b/platforms/sdl/sdl2/emscripten/AppPlatform_sdl2_emscripten.hpp index 3a5fb454c..84f7b6195 100644 --- a/platforms/sdl/sdl2/emscripten/AppPlatform_sdl2_emscripten.hpp +++ b/platforms/sdl/sdl2/emscripten/AppPlatform_sdl2_emscripten.hpp @@ -12,6 +12,6 @@ class AppPlatform_sdl2_emscripten : public AppPlatform_sdl2 public: AppPlatform_sdl2_emscripten(std::string storageDir, SDL_Window *window); - Texture loadTexture(const std::string& path, bool b = false) override; + void loadImage(ImageData& data, const std::string& path) override; bool doesTextureExist(const std::string& path) const override; }; diff --git a/platforms/sdl/sdl2/main.cpp b/platforms/sdl/sdl2/main.cpp index a8e443881..4e02c9f7e 100644 --- a/platforms/sdl/sdl2/main.cpp +++ b/platforms/sdl/sdl2/main.cpp @@ -2,7 +2,6 @@ #include "thirdparty/SDL/SDL.h" -#include "thirdparty/GL/GL.hpp" #include "client/app/App.hpp" #ifdef __EMSCRIPTEN__ @@ -16,6 +15,11 @@ typedef AppPlatform_sdl2_desktop UsedAppPlatform; #include "client/app/NinecraftApp.hpp" #include "client/player/input/Multitouch.hpp" +#ifndef MCE_GFX_API_NULL +#define MCE_GFX_API_OGL 1 +#include "renderer/platform/ogl/Extensions.hpp" +#endif + // Video Mode Flags #define VIDEO_FLAGS (SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI) @@ -25,12 +29,76 @@ UsedAppPlatform *g_pAppPlatform; NinecraftApp *g_pApp; SDL_Window *window = NULL; -SDL_GLContext context = NULL; +SDL_GLContext glContext = NULL; + +static void preInitGraphics() +{ +#if MCE_GFX_API_OGL + // Configure OpenGL ES Context + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); +#ifdef USE_GLES + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); +#else + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); +#endif + // Double-Buffering + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); +#else +#endif +} + +static void initGraphics() +{ +#if MCE_GFX_API_OGL + // Create OpenGL ES Context + glContext = SDL_GL_CreateContext(window); + if (!glContext) + { + const char* const GL_ERROR_MSG = "Unable to create OpenGL context"; + LOG_E(GL_ERROR_MSG); + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "OpenGL Error", GL_ERROR_MSG, window); + exit(EXIT_FAILURE); + } + + // Enable V-Sync + // Not setting this explicitly results in undefined behavior + if (SDL_GL_SetSwapInterval(-1) == -1) // Try adaptive + { + LOG_W("Adaptive V-Sync is not supported on this platform. Falling back to standard V-Sync..."); + // fallback to standard + if (SDL_GL_SetSwapInterval(1) == -1) + { + LOG_W("Setting the swap interval for V-Sync is not supported on this platform!"); + } + } + + if (!mce::Platform::OGL::InitBindings()) + { + const char* const GL_ERROR_MSG = "Error initializing GL extensions. OpenGL 2.0 or later is required. Update your graphics drivers!"; + LOG_E(GL_ERROR_MSG); + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "OpenGL Error", GL_ERROR_MSG, window); + exit(EXIT_FAILURE); + } +#else +#endif +} + +static void teardownGraphics() +{ +#if MCE_GFX_API_OGL + SDL_GL_DeleteContext(glContext); +#else +#endif +} + static void teardown() { if (window != NULL) { - SDL_GL_DeleteContext(context); + teardownGraphics(); SDL_DestroyWindow(window); SDL_Quit(); window = NULL; @@ -241,9 +309,12 @@ static void handle_events() // Resizing static void resize() { - int drawWidth, drawHeight; + int drawWidth = 0, drawHeight = 0; +#if MCE_GFX_API_OGL SDL_GL_GetDrawableSize(window, &drawWidth, &drawHeight); +#else +#endif int windowWidth, windowHeight; SDL_GetWindowSize(window, @@ -314,18 +385,10 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - // Configure OpenGL ES Context - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); -#ifdef USE_GLES - SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); -#else - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); -#endif - // Double-Buffering - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + preInitGraphics(); + + // Lock To Landscape + SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeLeft LandscapeRight"); // Window Size #ifdef __EMSCRIPTEN__ @@ -333,9 +396,6 @@ int main(int argc, char *argv[]) Minecraft::height = std::stoi(argv[2]); #endif - // Lock To Landscape - SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeLeft LandscapeRight"); - // Create Window window = SDL_CreateWindow("ReMinecraftPE", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, Minecraft::width, Minecraft::height, VIDEO_FLAGS); if (!window) @@ -344,39 +404,7 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - // Create OpenGL ES Context - context = SDL_GL_CreateContext(window); - if (!context) - { - const char* const GL_ERROR_MSG = "Unable to create OpenGL context"; - LOG_E(GL_ERROR_MSG); - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "OpenGL Error", GL_ERROR_MSG, window); - exit(EXIT_FAILURE); - } - - // Enable V-Sync - // Not setting this explicitly results in undefined behavior - if (SDL_GL_SetSwapInterval(-1) == -1) // Try adaptive - { - LOG_W("Adaptive V-Sync is not supported on this platform. Falling back to standard V-Sync..."); - // fallback to standard - if (SDL_GL_SetSwapInterval(1) == -1) - { - LOG_W("Setting the swap interval for V-Sync is not supported on this platform!"); - } - } - -#ifdef _WIN32 - xglInit(); - - if (!xglInitted()) - { - const char* const GL_ERROR_MSG = "Error initializing GL extensions. OpenGL 2.0 or later is required. Update your graphics drivers!"; - LOG_E(GL_ERROR_MSG); - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "OpenGL Error", GL_ERROR_MSG, window); - exit(EXIT_FAILURE); - } -#endif + initGraphics(); // Setup Teardown #ifndef __EMSCRIPTEN__ diff --git a/platforms/windows/AppPlatform_win32.cpp b/platforms/windows/AppPlatform_win32.cpp index 5c072aa6d..5704fb2bf 100644 --- a/platforms/windows/AppPlatform_win32.cpp +++ b/platforms/windows/AppPlatform_win32.cpp @@ -16,6 +16,7 @@ #include "GameMods.hpp" #include "common/Logger.hpp" +// needed for screenshots #include "thirdparty/GL/GL.hpp" #include "thirdparty/stb_image/include/stb_image.h" @@ -159,51 +160,6 @@ std::string AppPlatform_win32::getDateString(int time) return std::string(buf); } -Texture AppPlatform_win32::loadTexture(const std::string& str, bool bIsRequired) -{ - std::string realPath = str; - if (realPath.size() && realPath[0] == '/') - // trim it off - realPath = realPath.substr(1); - - realPath = "assets/" + realPath; - - FILE* f = fopen(realPath.c_str(), "rb"); - if (!f) - { - LOG_E("File %s couldn't be opened", realPath.c_str()); - - _error: - if (!bIsRequired) - return Texture(0, 0, nullptr, 1, 0); - - const std::string msg = "Error loading " + realPath + ". Did you unzip the Minecraft assets?\n\nNote, you will be warned for every missing texture."; - MessageBoxA(_getHWND(), msg.c_str(), getWindowTitle(), MB_OK | MB_ICONERROR); - - if (f) - fclose(f); - - return Texture(0, 0, nullptr, 0, 0); - } - - int width = 0, height = 0, channels = 0; - - stbi_uc* img = stbi_load_from_file(f, &width, &height, &channels, STBI_rgb_alpha); - if (!img) - { - LOG_E("File %s couldn't be loaded via stb_image", realPath.c_str()); - goto _error; - } - - uint32_t* img2 = new uint32_t[width * height]; - memcpy(img2, img, width * height * sizeof(uint32_t)); - stbi_image_free(img); - img = nullptr; - - fclose(f); - return Texture(width, height, img2, 1, 0); -} - bool AppPlatform_win32::doesTextureExist(const std::string& path) const { // Get Full Path diff --git a/platforms/windows/AppPlatform_win32.hpp b/platforms/windows/AppPlatform_win32.hpp index 65042ae5d..3d546399d 100644 --- a/platforms/windows/AppPlatform_win32.hpp +++ b/platforms/windows/AppPlatform_win32.hpp @@ -8,7 +8,6 @@ #pragma once -#include "thirdparty/GL/GL.hpp" #include "client/app/AppPlatform.hpp" #include "client/player/input/Mouse.hpp" @@ -38,7 +37,6 @@ class AppPlatform_win32 : public AppPlatform int getScreenHeight() const override { return m_ScreenHeight; } void showDialog(eDialogType) override; std::string getDateString(int time) override; - Texture loadTexture(const std::string& str, bool bIsRequired) override; bool doesTextureExist(const std::string& path) const override; // From v0.1.1. Also add these to determine touch screen use within the game. diff --git a/platforms/windows/main.cpp b/platforms/windows/main.cpp index 48083237b..56fc67681 100644 --- a/platforms/windows/main.cpp +++ b/platforms/windows/main.cpp @@ -9,7 +9,6 @@ #include #include -#include "thirdparty/GL/GL.hpp" #include "compat/KeyCodes.hpp" #include "GameMods.hpp" @@ -18,6 +17,8 @@ #include "client/player/input/Multitouch.hpp" +#include "renderer/platform/ogl/Extensions.hpp" + #include "AppPlatform_win32.hpp" #include "resource.h" #include "LoggerWin32.hpp" @@ -174,9 +175,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine g_AppPlatform.initializeWindow(hWnd, nCmdShow); - xglInit(); - - if (!xglInitted()) + if (!mce::Platform::OGL::InitBindings()) { const char* const GL_ERROR_MSG = "Error initializing GL extensions. OpenGL 2.0 or later is required. Update your graphics drivers!"; LOG_E(GL_ERROR_MSG); @@ -223,13 +222,14 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine _cleanup: g_pApp->saveOptions(); + // Cleanup networking, renderer, sounds, textures, etc. + delete g_pApp; + // disable OpenGL for the window g_AppPlatform.disableOpenGL(); // destroy the window explicitly, since we ignored the WM_QUIT message g_AppPlatform.destroyWindow(); - delete g_pApp; - return 0; } diff --git a/platforms/windows/projects/Client/Client.vcxproj b/platforms/windows/projects/Client/Client.vcxproj index 1223943c8..6e44c6a80 100644 --- a/platforms/windows/projects/Client/Client.vcxproj +++ b/platforms/windows/projects/Client/Client.vcxproj @@ -101,12 +101,12 @@ - - - - - - + + + + + + @@ -172,15 +172,15 @@ - - - - - - - - - + + + + + + + + + @@ -199,6 +199,17 @@ + + + + + + + + + + + @@ -233,12 +244,12 @@ - - - - - - + + + + + + @@ -305,14 +316,14 @@ - - - - - - - - + + + + + + + + @@ -324,10 +335,18 @@ - + + + + + + + + + @@ -339,6 +358,11 @@ {38723be5-0310-4941-b11f-ea7ff21394d9} + true + true + false + true + false {f332cb57-ff16-4d43-bbe0-76f28301daa8} diff --git a/platforms/windows/projects/Client/Client.vcxproj.filters b/platforms/windows/projects/Client/Client.vcxproj.filters index c21c2a652..9da458552 100644 --- a/platforms/windows/projects/Client/Client.vcxproj.filters +++ b/platforms/windows/projects/Client/Client.vcxproj.filters @@ -87,6 +87,30 @@ {05de3cac-cea2-493b-a8c5-84601a5cd26a} + + {de650680-1915-489c-a5be-eb96787d1adf} + + + {02c6befe-2a85-492e-87d1-293fa26590c5} + + + {a77298bd-19e1-4d70-bd4c-90df3144a00b} + + + {936e5c8b-a3b9-4fc8-8d85-b6157dd551b6} + + + {434d2080-ff31-42d1-9c89-39efb6f33153} + + + {658788db-d839-4212-9afd-66f7e65cffeb} + + + {48d498c3-5cea-459c-9417-1b3fef53a2fd} + + + {dee8e1cc-9021-48b4-b8ac-f7a3f385cc26} + @@ -173,18 +197,6 @@ Header Files\GUI - - Header Files\Model - - - Header Files\Model - - - Header Files\Model - - - Header Files\Model - Header Files\Player\Input @@ -380,12 +392,6 @@ Header Files\Player\Input - - Header Files\Model - - - Header Files\Model - Header Files\Renderer @@ -416,36 +422,6 @@ Header Files\Renderer\Entity - - Header Files\Model - - - Header Files\Model - - - Header Files\Model - - - Header Files\Model - - - Header Files\Model - - - Header Files\Model - - - Header Files\Model - - - Header Files\Model - - - Header Files\Model - - - Header Files\Model - Header Files\Renderer\Entity @@ -482,6 +458,87 @@ Header Files\Multiplayer + + Header Files\App + + + Header Files\Renderer\Renderer + + + Header Files\Renderer\Texture + + + Header Files\Renderer\Texture + + + Header Files\Renderer\Texture + + + Header Files\Renderer + + + Header Files\GUI + + + Header Files\GUI + + + Header Files\Model\Geom + + + Header Files\Model\Models + + + Header Files\Model\Models + + + Header Files\Model\Models + + + Header Files\Model\Models + + + Header Files\Model\Models + + + Header Files\Model\Models + + + Header Files\Model\Models + + + Header Files\Model\Models + + + Header Files\Model\Models + + + Header Files\Model\Models + + + Header Files\Model\Models + + + Header Files\Model\Models + + + Header Files\Model\Models + + + Header Files\Model\Geom + + + Header Files\Model\Geom + + + Header Files\Model\Geom + + + Header Files\Renderer\Renderer + + + Header Files\Renderer + @@ -568,18 +625,6 @@ Source Files\GUI - - Source Files\Model - - - Source Files\Model - - - Source Files\Model - - - Source Files\Model - Source Files\Player\Input @@ -775,12 +820,6 @@ Source Files\Player\Input - - Source Files\Model - - - Source Files\Model - Source Files\GUI\Components @@ -790,30 +829,6 @@ Source Files\Renderer - - Source Files\Model - - - Source Files\Model - - - Source Files\Model - - - Source Files\Model - - - Source Files\Model - - - Source Files\Model - - - Source Files\Model - - - Source Files\Model - Source Files\Renderer\Entity @@ -850,9 +865,6 @@ Source Files\Renderer - - Source Files\Model - Source Files\Renderer\Entity @@ -865,5 +877,74 @@ Source Files\Multiplayer + + Source Files\App + + + Source Files\Renderer\Renderer + + + Source Files\Renderer\Texture + + + Source Files\Renderer\Texture + + + Source Files\Renderer + + + Source Files\GUI + + + Source Files\Model\Geom + + + Source Files\Model\Geom + + + Source Files\Model\Models + + + Source Files\Model\Models + + + Source Files\Model\Models + + + Source Files\Model\Models + + + Source Files\Model\Models + + + Source Files\Model\Models + + + Source Files\Model\Models + + + Source Files\Model\Models + + + Source Files\Model\Models + + + Source Files\Model\Models + + + Source Files\Model\Models + + + Source Files\Model\Models + + + Source Files\Model\Geom + + + Source Files\Renderer\Renderer + + + Source Files\Renderer + \ No newline at end of file diff --git a/platforms/windows/projects/Common/Common.vcxproj b/platforms/windows/projects/Common/Common.vcxproj index eef20b4ef..4023c1325 100644 --- a/platforms/windows/projects/Common/Common.vcxproj +++ b/platforms/windows/projects/Common/Common.vcxproj @@ -75,7 +75,6 @@ - @@ -83,11 +82,14 @@ + + + + - @@ -98,6 +100,11 @@ + + + + + diff --git a/platforms/windows/projects/Common/Common.vcxproj.filters b/platforms/windows/projects/Common/Common.vcxproj.filters index 3ce5c7017..24a1b96da 100644 --- a/platforms/windows/projects/Common/Common.vcxproj.filters +++ b/platforms/windows/projects/Common/Common.vcxproj.filters @@ -9,6 +9,18 @@ {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + {c390ed47-685f-4617-9de1-c590e54cfdc6} + + + {79b3759f-6b47-454b-a5eb-fa59fb69e149} + + + {bf9115c5-2bb6-4bfc-a140-ed36088b13c4} + + + {53e4ada8-db6a-4d9a-b3b1-4f5b0c3a8f39} + @@ -17,9 +29,6 @@ Source Files - - Source Files - Source Files @@ -41,6 +50,18 @@ Source Files + + Source Files\Math + + + Source Files\Utility + + + Source Files\Utility + + + Source Files\Utility + @@ -49,9 +70,6 @@ Header Files - - Header Files - Header Files @@ -82,5 +100,20 @@ Header Files + + Header Files\Math + + + Header Files\Utility + + + Header Files\Utility + + + Header Files\Utility + + + Header Files\Utility + \ No newline at end of file diff --git a/platforms/windows/projects/Directory.Build.props b/platforms/windows/projects/Directory.Build.props index c52e06603..684677e99 100644 --- a/platforms/windows/projects/Directory.Build.props +++ b/platforms/windows/projects/Directory.Build.props @@ -11,6 +11,8 @@ whattimeisit? $(ProjectDir)..\..\..\..\ $(MC_ROOT)thirdparty\raknet\ + OGL + MCE_GFX_API_OGL $(SolutionDir)$(Platform)\$(Configuration)\ @@ -38,7 +40,7 @@ $(MC_ROOT);$(MC_ROOT)\source;$(MC_ROOT)\thirdparty;$(RAKNET_PATH);%(AdditionalIncludeDirectories) - HANDLE_CHARS_SEPARATELY;NOMINMAX;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + HANDLE_CHARS_SEPARATELY;NOMINMAX;$(MC_GFX_API_MACRO);_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false /Zc:__cplusplus %(AdditionalOptions) diff --git a/platforms/windows/projects/OpenGL/OpenGL.vcxproj b/platforms/windows/projects/OpenGL/OpenGL.vcxproj index 465ee1047..c2ce03f9b 100644 --- a/platforms/windows/projects/OpenGL/OpenGL.vcxproj +++ b/platforms/windows/projects/OpenGL/OpenGL.vcxproj @@ -54,9 +54,6 @@ - - - {71774270-fd1b-4269-bd8f-f75a52d43eb6} diff --git a/platforms/windows/projects/OpenGL/OpenGL.vcxproj.filters b/platforms/windows/projects/OpenGL/OpenGL.vcxproj.filters index 36dfd2e12..23bd1be80 100644 --- a/platforms/windows/projects/OpenGL/OpenGL.vcxproj.filters +++ b/platforms/windows/projects/OpenGL/OpenGL.vcxproj.filters @@ -18,9 +18,4 @@ Header Files - - - Source Files - - \ No newline at end of file diff --git a/platforms/windows/projects/Renderer/Renderer.vcxproj b/platforms/windows/projects/Renderer/Renderer.vcxproj index 2165c38d1..3a999582c 100644 --- a/platforms/windows/projects/Renderer/Renderer.vcxproj +++ b/platforms/windows/projects/Renderer/Renderer.vcxproj @@ -20,15 +20,266 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - {2e1a5b55-a6d4-4743-a63a-4f27db03c0a1} - true - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 17.0 diff --git a/platforms/windows/projects/Renderer/Renderer.vcxproj.filters b/platforms/windows/projects/Renderer/Renderer.vcxproj.filters index 9b6f7aaf0..071307abf 100644 --- a/platforms/windows/projects/Renderer/Renderer.vcxproj.filters +++ b/platforms/windows/projects/Renderer/Renderer.vcxproj.filters @@ -9,15 +9,732 @@ {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - - Source Files - + + {c890ea02-9bf7-4344-aa67-b1a86cd70bf2} + + + {417c33a0-5b00-4ff5-8d82-2bc6df0d2581} + + + {33126d95-4e32-489d-b319-894160e6b7d7} + + + {f2f0eded-1568-4b30-b7b2-6a3e880d6cff} + + + {6b8a0b8f-e388-4150-be97-899c5d2eb3c8} + + + {7e3a7c9b-073f-46a4-9b4e-558e95661660} + + + {880f32fb-b980-4d50-9995-6800a678fe1e} + + + {2e16adab-9fe7-4b12-93dd-d9a0c5b9fc1d} + + + {00effb28-b6df-4580-b320-9ca792c62b40} + + + {1010641c-8953-4985-bade-84563c94150f} + + + {05343a63-1e1c-428f-b30d-0290f0423c41} + + + {bc39047f-ff86-4b7f-9c56-b8f2f21e1969} + + + {37981f99-afb1-454c-b6a1-713257aab854} + + + {458bfe8e-ecfd-4bbe-a0d2-d80f3b97393a} + + + {7816802e-84ac-4098-a982-295af4938dc5} + + + {3e87f138-1f9d-4fae-8949-29daac0d7c04} + + + {dddbe518-b175-428b-b9c2-5d49dfe045ed} + + + {401f738a-aea7-4a49-9844-842d2f62aadc} + + + {d8de1dcd-c91a-46a0-94ce-63c0d0b32491} + + + {d1d2f648-6a5d-4700-b21c-30831ad9f50c} + + Header Files\GL + + + Header Files\HAL\Base + + + Header Files\HAL\Base + + + Header Files\HAL\Base + + + Header Files\HAL\Base + + + Header Files\HAL\Base + + + Header Files\HAL\Base + + + Header Files\HAL\Base + + + Header Files\HAL\Base + + + Header Files\HAL\Base + + + Header Files\HAL\Base + + + Header Files\HAL\Base + + + Header Files\HAL\Base + + + Header Files\HAL\Base + + + Header Files\HAL\Base + + + Header Files\HAL\Base + + + Header Files\HAL\Base + + + Header Files\HAL\Base + + + Header Files\HAL\Base + + + Header Files\HAL\Base + + + Header Files\HAL\Base + + + Header Files\HAL\Enums + + + Header Files\HAL\Enums + + + Header Files\HAL\Enums + + + Header Files\HAL\Enums + + + Header Files\HAL\Enums + + + Header Files\HAL\Enums + + + Header Files\HAL\Enums + + + Header Files\HAL\Enums + + + Header Files\HAL\Enums + + + Header Files\HAL\Enums + + + Header Files\HAL\Enums + + + Header Files\HAL\Enums + + + Header Files\HAL\Enums + + + Header Files\HAL\Enums + + + Header Files\HAL\Enums + + + Header Files\HAL\Enums + + + Header Files\HAL\Enums + + + Header Files\HAL\Enums + + + Header Files\HAL\Enums + + + Header Files\HAL\Helpers + + + Header Files\HAL\Helpers + + + Header Files\HAL\Interface + + + Header Files\HAL\Interface + + + Header Files\HAL\Interface + + + Header Files\HAL\Interface + + + Header Files\HAL\Interface + + + Header Files\HAL\Interface + + + Header Files\HAL\Interface + + + Header Files\HAL\Interface + + + Header Files\HAL\Interface + + + Header Files\HAL\Interface + + + Header Files\HAL\Interface + + + Header Files\HAL\Interface + + + Header Files\HAL\Interface + + + Header Files\HAL\Interface + + + Header Files\HAL\Interface + + + Header Files\HAL\Interface + + + Header Files\HAL\Interface + + + Header Files\HAL\OGL + + + Header Files\HAL\OGL + + + Header Files\HAL\OGL + + + Header Files\HAL\OGL + + + Header Files\HAL\OGL + + + Header Files\HAL\OGL + + + Header Files\HAL\OGL + + + Header Files\HAL\OGL + + + Header Files\HAL\OGL + + + Header Files\HAL\OGL + + + Header Files\HAL\OGL + + + Header Files\HAL\OGL + + + Header Files\HAL\OGL + + + Header Files\HAL\OGL + + + Header Files\HAL\OGL + + + Header Files\HAL\OGL + + + Header Files\HAL\OGL + + + Header Files\HAL\OGL + + + Header Files\HAL\OGL + + + Header Files\HAL\OGL + + + Header Files\HAL\OGL + + + Header Files\Platform\OGL + + + Header Files\Platform\OGL + + + Header Files\HAL + + + Header Files\HAL + + + Header Files\HAL + + + Header Files\HAL + + + Header Files\HAL + + + Header Files\HAL + + + Header Files\HAL + + + Header Files\HAL + + + Header Files\HAL + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + Header Files + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files\GL + + + Source Files\HAL\Base + + + Source Files\HAL\Base + + + Source Files\HAL\Base + + + Source Files\HAL\Base + + + Source Files\HAL\Base + + + Source Files\HAL\Base + + + Source Files\HAL\Base + + + Source Files\HAL\Base + + + Source Files\HAL\Base + + + Source Files\HAL\Base + + + Source Files\HAL\Base + + + Source Files\HAL\Base + + + Source Files\HAL\Base + + + Source Files\HAL\Base + + + Source Files\HAL\Base + + + Source Files\HAL\Base + + + Source Files\HAL\Base + + + Source Files\HAL\Base + + + Source Files\HAL\Base + + + Source Files\HAL\Base + + + Source Files\HAL\Enums + + + Header Files\HAL\Enums + + + Source Files\HAL\Enums + + + Source Files\HAL\Enums + + + Source Files\HAL\Enums + + + Source Files\HAL\Enums + + + Source Files\HAL\Enums + + + Source Files\HAL\Enums + + + Source Files\HAL\Enums + + + Source Files\HAL\Enums + + + Source Files\HAL\Helpers + + + Source Files\HAL\Helpers + + + Source Files\HAL\Interface + + + Source Files\HAL\Interface + + + Source Files\HAL\Interface + + + Source Files\HAL\Interface + + + Source Files\HAL\Interface + + + Source Files\HAL\Interface + + + Source Files\HAL\Interface + + + Source Files\HAL\Interface + + + Source Files\HAL\Interface + + + Source Files\HAL\Interface + + + Source Files\HAL\Interface + + + Source Files\HAL\Interface + + + Source Files\HAL\Interface + + + Source Files\HAL\Interface + + + Source Files\HAL\Interface + + + Source Files\HAL\OGL + + + Source Files\HAL\OGL + + + Source Files\HAL\OGL + + + Source Files\HAL\OGL + + + Source Files\HAL\OGL + + + Source Files\HAL\OGL + + + Source Files\HAL\OGL + + + Source Files\HAL\OGL + + + Source Files\HAL\OGL + + + Source Files\HAL\OGL + + + Source Files\HAL\OGL + + + Source Files\HAL\OGL + + + Source Files\HAL\OGL + + + Source Files\HAL\OGL + + + Source Files\HAL\OGL + + + Source Files\HAL\OGL + + + Source Files\HAL\OGL + + + Source Files\HAL\OGL + + + Source Files\HAL\OGL + + + Source Files\HAL\OGL + + + Source Files\HAL\OGL + + + Source Files\HAL + + + Source Files\HAL + + + Source Files\HAL + + + Source Files\HAL + + + Source Files\HAL + + + Source Files\HAL + + + Source Files\HAL + + + Source Files\HAL + + + Source Files\Platform\OGL + + + Source Files\Platform\OGL + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + \ No newline at end of file diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 8a56ef786..1c7f11345 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -6,15 +6,19 @@ add_library(reminecraftpe-core STATIC common/CThread.cpp common/DataIO.cpp common/Logger.cpp - common/Matrix.cpp + common/math/Color.cpp common/Mth.cpp common/Random.cpp common/SmoothFloat.cpp common/Timer.cpp common/Util.cpp + common/utility/AlignmentHelper.cpp + common/utility/JsonParser.cpp + common/utility/Singleton.cpp common/Utils.cpp client/app/App.cpp client/app/AppPlatform.cpp + client/app/AppPlatformListener.cpp client/app/Minecraft.cpp client/app/NinecraftApp.cpp client/options/Options.cpp @@ -38,7 +42,12 @@ add_library(reminecraftpe-core STATIC client/renderer/entity/PigRenderer.cpp client/renderer/entity/ChickenRenderer.cpp client/renderer/entity/RocketRenderer.cpp + client/renderer/renderer/EntityShaderManager.cpp + client/renderer/renderer/RenderMaterialGroup.cpp + client/renderer/texture/ImageData.cpp + client/renderer/texture/TextureData.cpp client/renderer/RenderList.cpp + client/renderer/ScreenRenderer.cpp client/renderer/Chunk.cpp client/renderer/RenderChunk.cpp client/renderer/Frustum.cpp @@ -48,6 +57,7 @@ add_library(reminecraftpe-core STATIC client/renderer/Textures.cpp client/renderer/FrustumCuller.cpp client/renderer/LightUpdate.cpp + client/renderer/Fog.cpp client/renderer/Font.cpp client/renderer/WaterSideTexture.cpp client/renderer/Tesselator.cpp @@ -97,24 +107,25 @@ add_library(reminecraftpe-core STATIC client/gui/components/OptionList.cpp client/gui/Gui.cpp client/gui/GuiComponent.cpp - client/model/PolygonQuad.cpp - client/model/Model.cpp - client/model/Cube.cpp - client/model/ModelPart.cpp - client/model/QuadrupedModel.cpp - client/model/PigModel.cpp - client/model/SheepModel.cpp - client/model/HumanoidModel.cpp - client/model/SpiderModel.cpp - client/model/ZombieModel.cpp - client/model/SkeletonModel.cpp - client/model/SheepModel.cpp - client/model/SheepFurModel.cpp - client/model/CreeperModel.cpp - client/model/CowModel.cpp - client/model/ChickenModel.cpp - client/multiplayer/MultiPlayerLevel.cpp - client/multiplayer/MultiplayerLocalPlayer.cpp + client/gui/GuiElement.cpp + client/model/geom/PolygonQuad.cpp + client/model/geom/Cube.cpp + client/model/geom/ModelPart.cpp + client/model/models/QuadrupedModel.cpp + client/model/models/PigModel.cpp + client/model/models/SheepModel.cpp + client/model/models/HumanoidModel.cpp + client/model/models/Model.cpp + client/model/models/SpiderModel.cpp + client/model/models/ZombieModel.cpp + client/model/models/SkeletonModel.cpp + client/model/models/SheepModel.cpp + client/model/models/SheepFurModel.cpp + client/model/models/CreeperModel.cpp + client/model/models/CowModel.cpp + client/model/models/ChickenModel.cpp + client/multiplayer/MultiPlayerLevel.cpp + client/multiplayer/MultiplayerLocalPlayer.cpp client/player/input/Controller.cpp client/player/input/ControllerBuildInput.cpp client/player/input/ControllerMoveInput.cpp @@ -161,7 +172,7 @@ add_library(reminecraftpe-core STATIC network/packets/RequestChunkPacket.cpp network/packets/PlayerEquipmentPacket.cpp network/packets/InteractPacket.cpp - network/packets/UseItemPacket.cpp + network/packets/UseItemPacket.cpp network/packets/SetEntityDataPacket.cpp network/packets/SetHealthPacket.cpp network/packets/ChunkDataPacket.cpp @@ -278,7 +289,7 @@ add_library(reminecraftpe-core STATIC world/level/levelgen/chunk/ChunkCache.cpp world/level/levelgen/chunk/ChunkPos.cpp world/level/levelgen/chunk/ChunkSource.cpp - world/level/levelgen/chunk/DataLayer.cpp + world/level/levelgen/chunk/DataLayer.cpp world/level/levelgen/chunk/EmptyLevelChunk.cpp world/level/levelgen/chunk/PerformanceTestChunkSource.cpp world/level/levelgen/chunk/TestChunkSource.cpp @@ -352,9 +363,146 @@ add_library(reminecraftpe-core STATIC world/tile/Web.cpp world/tile/FenceTile.cpp renderer/GL/GL.cpp + renderer/Attribute.cpp + renderer/ConstantBufferMetaData.cpp + renderer/ConstantBufferMetaDataManager.cpp + renderer/EnableScissorTest.cpp + renderer/EntityConstants.cpp + renderer/GlobalConstantBufferManager.cpp + renderer/GlobalConstantBuffers.cpp + renderer/MaterialPtr.cpp + renderer/MatrixStack.cpp + renderer/Mesh.cpp + renderer/PerFrameConstants.cpp + renderer/QuadIndexBuffer.cpp + renderer/RenderChunkConstants.cpp + renderer/RenderContextImmediate.cpp + renderer/RenderMaterial.cpp + renderer/ShaderConstants.cpp + renderer/ShaderGroup.cpp + renderer/ShaderGroupBase.cpp + renderer/StencilRefObject.cpp + renderer/TextureGroup.cpp + renderer/TexturePtr.cpp + renderer/UniformMetaData.cpp + renderer/VertexFormat.cpp + renderer/WeatherConstants.cpp + renderer/WorldConstants.cpp + renderer/hal/BlendStateDescription.cpp + renderer/hal/DepthStencilStateDescription.cpp + renderer/hal/FixedPipelineStateDescription.cpp + renderer/hal/FogStateDescription.cpp + renderer/hal/ImageDescription.cpp + renderer/hal/RasterizerStateDescription.cpp + renderer/hal/StencilFaceDescription.cpp + renderer/hal/TextureDescription.cpp + renderer/hal/base/BlendStateBase.cpp + renderer/hal/base/BufferBase.cpp + renderer/hal/base/ConstantBufferBase.cpp + renderer/hal/base/ConstantBufferConstantsBase.cpp + renderer/hal/base/ConstantBufferContainerBase.cpp + renderer/hal/base/DepthStencilStateBase.cpp + renderer/hal/base/FixedPipelineStateBase.cpp + renderer/hal/base/FogStateBase.cpp + renderer/hal/base/FrameBufferObjectBase.cpp + renderer/hal/base/ImmediateBufferBase.cpp + renderer/hal/base/RasterizerStateBase.cpp + renderer/hal/base/RenderContextBase.cpp + renderer/hal/base/RenderContextStateBase.cpp + renderer/hal/base/RenderDeviceBase.cpp + renderer/hal/base/ShaderBase.cpp + renderer/hal/base/ShaderConstantBase.cpp + renderer/hal/base/ShaderConstantWithDataBase.cpp + renderer/hal/base/ShaderContextBase.cpp + renderer/hal/base/ShaderProgramBase.cpp + renderer/hal/base/TextureBase.cpp + renderer/hal/enums/BlendTarget_JsonParser.cpp + renderer/hal/enums/ComparisonFunc_JsonParser.cpp + renderer/hal/enums/PrimitiveMode_JsonParser.cpp + renderer/hal/enums/RenderState_JsonParser.cpp + renderer/hal/enums/RenderState_JsonParser.hpp + renderer/hal/enums/ShaderPrimitiveTypes.cpp + renderer/hal/enums/ShaderStagesBits_JsonParser.cpp + renderer/hal/enums/StencilOp_JsonParser.cpp + renderer/hal/enums/TextureFiltering_JsonParser.cpp + renderer/hal/enums/VertexField_JsonParser.cpp + renderer/hal/helpers/ErrorHandler.cpp + renderer/hal/helpers/TextureHelper.cpp + renderer/hal/interface/BlendState.cpp + renderer/hal/interface/Buffer.cpp + renderer/hal/interface/ConstantBuffer.cpp + renderer/hal/interface/ConstantBufferContainer.cpp + renderer/hal/interface/DepthStencilState.cpp + renderer/hal/interface/FixedPipelineState.cpp + renderer/hal/interface/FogState.cpp + renderer/hal/interface/ImmediateBuffer.cpp + renderer/hal/interface/RasterizerState.cpp + renderer/hal/interface/RenderContext.cpp + renderer/hal/interface/RenderDevice.cpp + renderer/hal/interface/Shader.cpp + renderer/hal/interface/ShaderConstantWithData.cpp + renderer/hal/interface/ShaderProgram.cpp + renderer/hal/interface/Texture.cpp ) target_include_directories(reminecraftpe-core PUBLIC . ..) +if(NOT DEFINED REMCPE_GFX_API) + message(STATUS "No GFX API specified, defaulting to OGL...") + set(REMCPE_GFX_API "OGL" CACHE STRING "HAL GFX API") +endif() + +message(STATUS "Selected GFX API: ${REMCPE_GFX_API}") + +if(REMCPE_GFX_API STREQUAL "OGL") + target_compile_options(reminecraftpe-core PRIVATE -DMCE_GFX_API_OGL=1) + target_sources(reminecraftpe-core PRIVATE + renderer/hal/ogl/API_OGL.cpp + renderer/hal/ogl/BlendStateOGL.cpp + renderer/hal/ogl/BufferOGL.cpp + renderer/hal/ogl/ConstantBufferContainerOGL.cpp + renderer/hal/ogl/DepthStencilStateOGL.cpp + renderer/hal/ogl/FixedPipelineStateOGL.cpp + renderer/hal/ogl/FogStateOGL.cpp + renderer/hal/ogl/GPUEventsOGL.cpp + renderer/hal/ogl/ImmediateBufferOGL.cpp + renderer/hal/ogl/ProfileSectionOGL.cpp + renderer/hal/ogl/RasterizerStateOGL.cpp + renderer/hal/ogl/RenderContextOGL.cpp + renderer/hal/ogl/RenderDeviceOGL.cpp + renderer/hal/ogl/ResourceOGL.cpp + renderer/hal/ogl/ShaderConstantOGL.cpp + renderer/hal/ogl/ShaderConstantWithDataOGL.cpp + renderer/hal/ogl/ShaderOGL.cpp + renderer/hal/ogl/ShaderProgramOGL.cpp + renderer/hal/ogl/ShaderResourceOGL.cpp + renderer/hal/ogl/ShaderUniformOGL.cpp + renderer/hal/ogl/TextureOGL.cpp + renderer/platform/ogl/Extensions.cpp + renderer/platform/ogl/ShaderPrecision.cpp + ) +elseif((NOT DEFINED REMCPE_GFX_API) OR (REMCPE_GFX_API STREQUAL "Null")) + target_compile_options(reminecraftpe-core PRIVATE -DMCE_GFX_API_NULL=1) + target_sources(reminecraftpe-core PRIVATE + renderer/hal/null/BlendStateNull.cpp + renderer/hal/null/BufferNull.cpp + renderer/hal/null/ConstantBufferContainerNull.cpp + renderer/hal/null/DepthStencilStateNull.cpp + renderer/hal/null/FixedPipelineStateNull.cpp + renderer/hal/null/FogStateNull.cpp + renderer/hal/null/ImmediateBufferNull.cpp + renderer/hal/null/RasterizerStateNull.cpp + renderer/hal/null/RenderContextNull.cpp + renderer/hal/null/RenderDeviceNull.cpp + renderer/hal/null/ShaderConstantNull.cpp + renderer/hal/null/ShaderConstantWithDataNull.cpp + renderer/hal/null/ShaderNull.cpp + renderer/hal/null/ShaderProgramNull.cpp + renderer/hal/null/TextureNull.cpp + ) +else() + message(FATAL_ERROR "An unknown or unsupported GFX API was specified: ${REMCPE_GFX_API}") +endif() + # RakNet add_subdirectory(../thirdparty/raknet raknet) target_link_libraries(reminecraftpe-core PUBLIC raknet) @@ -376,10 +524,6 @@ else() target_link_libraries(zlib-interface INTERFACE ZLIB::ZLIB) endif() target_link_libraries(reminecraftpe-core PUBLIC zlib-interface) -# OpenGL Support Code -if(MCPE_WIN32) - target_sources(reminecraftpe-core PRIVATE ../thirdparty/GL/GLExt.cpp) -endif() # OGG Support target_link_libraries(reminecraftpe-core PUBLIC stb_vorbis) diff --git a/source/client/app/AppPlatform.cpp b/source/client/app/AppPlatform.cpp index 39696635f..8682629ef 100644 --- a/source/client/app/AppPlatform.cpp +++ b/source/client/app/AppPlatform.cpp @@ -8,9 +8,12 @@ #include +#include "thirdparty/stb_image/include/stb_image.h" + #include "AppPlatform.hpp" #include "common/Logger.hpp" #include "compat/LegacyCPP.hpp" +#include "AppPlatformListener.hpp" AppPlatform* AppPlatform::m_singleton = nullptr; @@ -118,13 +121,38 @@ void AppPlatform::uploadPlatformDependentData(int, void*) } - -Texture AppPlatform::loadTexture(const std::string&, bool bIsRequired) +void AppPlatform::loadImage(ImageData& data, const std::string& path) { - return Texture(0, 0, nullptr, 1, 0); + AssetFile file = readAssetFile(path, true); + + if (!file.data) + return; + + // Parse Image + int desired_channels = STBI_rgb_alpha; // STB will convert the image for us + int channels = 0; + stbi_uc* img = stbi_load_from_memory(file.data, file.size, &data.m_width, &data.m_height, &channels, desired_channels); + delete[] file.data; + if (!img) + { + // Failed To Parse Image + LOG_E("The image could not be loaded properly: %s", path.c_str()); + return; + } + + if (desired_channels == STBI_rgb_alpha) + channels = STBI_rgb_alpha; + + data.m_data = img; + data.m_colorSpace = channels == 3 ? COLOR_SPACE_RGB : COLOR_SPACE_RGBA; } -#ifndef ORIGINAL_CODE +TextureData AppPlatform::loadTexture(const std::string& path, bool bIsRequired) +{ + TextureData out; + loadImage(out.m_imageData, path); + return out; +} bool AppPlatform::doesTextureExist(const std::string& path) const { @@ -223,32 +251,51 @@ std::string AppPlatform::getClipboardText() void AppPlatform::_fireLowMemory() { - + for (ListenerMap::iterator it = m_listeners.begin(); it != m_listeners.end(); it++) + { + it->second->onLowMemory(); + } } void AppPlatform::_fireAppSuspended() { - + for (ListenerMap::iterator it = m_listeners.begin(); it != m_listeners.end(); it++) + { + it->second->onAppSuspended(); + } + _fireLowMemory(); } void AppPlatform::_fireAppResumed() { - + for (ListenerMap::iterator it = m_listeners.begin(); it != m_listeners.end(); it++) + { + it->second->onAppResumed(); + } } void AppPlatform::_fireAppFocusLost() { - + for (ListenerMap::iterator it = m_listeners.begin(); it != m_listeners.end(); it++) + { + it->second->onAppFocusLost(); + } } void AppPlatform::_fireAppFocusGained() { - + for (ListenerMap::iterator it = m_listeners.begin(); it != m_listeners.end(); it++) + { + it->second->onAppFocusGained(); + } } void AppPlatform::_fireAppTerminated() { - + for (ListenerMap::iterator it = m_listeners.begin(); it != m_listeners.end(); it++) + { + it->second->terminate(); + } } bool AppPlatform::hasFileSystemAccess() @@ -258,13 +305,7 @@ bool AppPlatform::hasFileSystemAccess() std::string AppPlatform::getPatchData() { - AssetFile file = readAssetFile(_getPatchDataPath(), false); - if (!file.data) - return ""; - - std::string out = std::string(file.data, file.data + file.size); - delete file.data; - return out; + return readAssetFileStr(_getPatchDataPath(), false); } std::string AppPlatform::getAssetPath(const std::string& path) const @@ -312,7 +353,17 @@ AssetFile AppPlatform::readAssetFile(const std::string& path, bool quiet) const ifs.close(); // Return - return AssetFile((int64_t)size, (unsigned char*)buf); + return AssetFile((int64_t)size, (uint8_t*)buf); +} + +std::string AppPlatform::readAssetFileStr(const std::string& path, bool quiet) const +{ + AssetFile file = readAssetFile(path, quiet); + if (!file.data) + return ""; + std::string out = std::string(file.data, file.data + file.size); + delete file.data; + return out; } void AppPlatform::initSoundSystem() @@ -323,5 +374,3 @@ SoundSystem* const AppPlatform::getSoundSystem() const { return nullptr; } - -#endif diff --git a/source/client/app/AppPlatform.hpp b/source/client/app/AppPlatform.hpp index f26d7395a..f939169e7 100644 --- a/source/client/app/AppPlatform.hpp +++ b/source/client/app/AppPlatform.hpp @@ -10,8 +10,10 @@ #include #include +#include #include "client/renderer/Texture.hpp" +#include "client/renderer/texture/TextureData.hpp" #include "client/sound/SoundSystem.hpp" #include "AssetFile.hpp" @@ -28,8 +30,13 @@ #define C_DEFAULT_SCREEN_HEIGHT (720) #endif +class AppPlatformListener; + class AppPlatform { +public: + typedef std::multimap ListenerMap; + public: enum eDialogType { @@ -53,7 +60,7 @@ class AppPlatform virtual void _tick(); protected: - virtual std::string _getPatchDataPath() const { return "patches/patch_data.txt"; } + std::string _getPatchDataPath() const { return "patches/patch_data.txt"; } public: virtual void buyGame(); @@ -69,9 +76,8 @@ class AppPlatform virtual void saveScreenshot(const std::string&, int, int); virtual void showDialog(eDialogType); virtual void uploadPlatformDependentData(int, void*); - virtual Texture loadTexture(const std::string&, bool bIsRequired); - -#ifndef ORIGINAL_CODE + virtual void loadImage(ImageData& data, const std::string& path); + TextureData loadTexture(const std::string& path, bool bIsRequired = false); virtual bool doesTextureExist(const std::string& path) const; // From v0.1.1. Also add these to determine touch screen use within the game. virtual bool isTouchscreen() const; @@ -113,11 +119,11 @@ class AppPlatform virtual SoundSystem* const getSoundSystem() const; // Used For Sounds virtual std::string getAssetPath(const std::string& path) const; - virtual AssetFile readAssetFile(const std::string&, bool) const; -#endif + virtual AssetFile readAssetFile(const std::string& path, bool quiet) const; + virtual std::string readAssetFileStr(const std::string& path, bool quiet) const; public: - //std::multimap m_listeners; + ListenerMap m_listeners; void* m_hWND; // the Mojang solution }; diff --git a/source/client/app/AppPlatformListener.cpp b/source/client/app/AppPlatformListener.cpp new file mode 100644 index 000000000..61960314a --- /dev/null +++ b/source/client/app/AppPlatformListener.cpp @@ -0,0 +1,20 @@ +#include "AppPlatformListener.hpp" + +AppPlatformListener::AppPlatformListener(bool doInit) +{ + m_pPlatform = nullptr; + + if (doInit) initListener(); +} + +void AppPlatformListener::initListener(float priority) +{ + m_pPlatform = AppPlatform::singleton(); + m_pPlatform->m_listeners.insert(AppPlatform::ListenerMap::value_type(priority, this)); +} + +void AppPlatformListener::terminate() +{ + onAppFocusLost(); + m_pPlatform = nullptr; +} \ No newline at end of file diff --git a/source/client/app/AppPlatformListener.hpp b/source/client/app/AppPlatformListener.hpp new file mode 100644 index 000000000..41a8bcf00 --- /dev/null +++ b/source/client/app/AppPlatformListener.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include "AppPlatform.hpp" + +class AppPlatformListener +{ +public: + AppPlatformListener(bool doInit = true); + + virtual void onLowMemory() {} + virtual void onAppResumed() {} + virtual void onAppFocusLost() {} + virtual void onAppFocusGained() {} + virtual void onAppTerminated() {} + virtual void onAppSuspended() {} + + void initListener(float priority = 1.0f); + void terminate(); + +private: + AppPlatform* m_pPlatform; +}; diff --git a/source/client/app/AssetFile.hpp b/source/client/app/AssetFile.hpp index cb5a078c1..163087fcc 100644 --- a/source/client/app/AssetFile.hpp +++ b/source/client/app/AssetFile.hpp @@ -11,10 +11,11 @@ Minecraft: Pocket Edition - Decompilation Project #include #include "compat/LegacyCPP.hpp" -struct AssetFile { +struct AssetFile +{ int64_t size; - unsigned char *data; + uint8_t* data; AssetFile(): size(-1), data(nullptr) {} - AssetFile(int64_t size, unsigned char *data): size(size), data(data) {} + AssetFile(int64_t size, uint8_t* data): size(size), data(data) {} }; \ No newline at end of file diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp index 91bbb620e..586fba91e 100644 --- a/source/client/app/Minecraft.cpp +++ b/source/client/app/Minecraft.cpp @@ -38,8 +38,6 @@ #include "client/renderer/GrassColor.hpp" #include "client/renderer/FoliageColor.hpp" - -// custom: #include "client/renderer/PatchManager.hpp" float Minecraft::_renderScaleMultiplier = 1.0f; @@ -61,10 +59,9 @@ const char* Minecraft::progressMessages[] = "Saving chunks", }; -Minecraft::Minecraft() : - m_gui(this) +Minecraft::Minecraft() { - m_options = nullptr; + m_pOptions = nullptr; field_18 = false; m_bIsGamePaused = false; m_pLevelRenderer = nullptr; @@ -80,7 +77,8 @@ Minecraft::Minecraft() : m_pUser = nullptr; m_pLevel = nullptr; m_pLocalPlayer = nullptr; - m_pMobPersp = nullptr; // why is there a duplicate? + m_pCameraEntity = nullptr; // why is there a duplicate? + m_pGui = nullptr; field_D0C = 0; m_pPrepThread = nullptr; m_pScreen = nullptr; @@ -107,7 +105,8 @@ Minecraft::Minecraft() : Minecraft::~Minecraft() { - SAFE_DELETE(m_options); + SAFE_DELETE(m_pGui); + SAFE_DELETE(m_pOptions); SAFE_DELETE(m_pNetEventCallback); SAFE_DELETE(m_pRakNetInstance); SAFE_DELETE(m_pLevelRenderer); @@ -134,6 +133,73 @@ Minecraft::~Minecraft() //@BUG: potentially leaking a CThread instance if this is destroyed early? } +void Minecraft::_levelGenerated() +{ + onClientStartedLevel(m_pLevel, m_pLocalPlayer); + + if (m_pNetEventCallback) + m_pNetEventCallback->levelGenerated(m_pLevel); +} + +void Minecraft::_resetPlayer(Player* player) +{ + m_pLevel->validateSpawn(); + player->reset(); + + TilePos pos = m_pLevel->getSharedSpawnPos(); + player->setPos(pos); + player->resetPos(); +} + +GameMode* Minecraft::_createGameMode(GameType gameType, Level& level) +{ + switch (gameType) + { + case GAME_TYPE_SURVIVAL: + return new SurvivalMode(this, level); + case GAME_TYPE_CREATIVE: + return new CreativeMode(this, level); + default: + return nullptr; + } +} + +void Minecraft::_reloadInput() +{ + if (m_pInputHolder) + delete m_pInputHolder; + + if (isTouchscreen()) + { + m_pInputHolder = new TouchInputHolder(this, getOptions()); + } + else if (useController()) + { + m_pInputHolder = new CustomInputHolder( + new ControllerMoveInput(getOptions()), + new ControllerTurnInput(), + new ControllerBuildInput() + ); + } + else + { + m_pInputHolder = new CustomInputHolder( + new KeyboardInput(getOptions()), + new MouseTurnInput(this), + new MouseBuildInput() + ); + } + + m_mouseHandler.setTurnInput(m_pInputHolder->getTurnInput()); + + if (m_pLevel && m_pLocalPlayer) + { + m_pLocalPlayer->m_pMoveInput = m_pInputHolder->getMoveInput(); + } + + getOptions()->field_19 = !isTouchscreen(); +} + int Minecraft::getLicenseId() { if (m_licenseID < 0) @@ -232,21 +298,6 @@ void Minecraft::setScreen(Screen* pScreen) } } -void Minecraft::onGraphicsReset() -{ - m_pTextures->clear(); - _initTextures(); - m_pFont->onGraphicsReset(); - - if (m_pLevelRenderer) - m_pLevelRenderer->onGraphicsReset(); - - if (m_pGameRenderer) - m_pGameRenderer->onGraphicsReset(); - - EntityRenderDispatcher::getInstance()->onGraphicsReset(); -} - void Minecraft::saveOptions() { if (platform()->hasFileSystemAccess()) @@ -278,25 +329,12 @@ bool Minecraft::isTouchscreen() const bool Minecraft::useSplitControls() const { - return !m_bIsTouchscreen || m_options->m_bSplitControls; + return !m_bIsTouchscreen || getOptions()->m_bSplitControls; } bool Minecraft::useController() const { - return m_pPlatform->hasGamepad() && m_options->m_bUseController; -} - -GameMode* Minecraft::createGameMode(GameType gameType, Level& level) -{ - switch (gameType) - { - case GAME_TYPE_SURVIVAL: - return new SurvivalMode(this, level); - case GAME_TYPE_CREATIVE: - return new CreativeMode(this, level); - default: - return nullptr; - } + return m_pPlatform->hasGamepad() && getOptions()->m_bUseController; } void Minecraft::setGameMode(GameType gameType) @@ -304,7 +342,7 @@ void Minecraft::setGameMode(GameType gameType) if (m_pLevel) { SAFE_DELETE(m_pGameMode); - m_pGameMode = createGameMode(gameType, *m_pLevel); + m_pGameMode = _createGameMode(gameType, *m_pLevel); m_pGameMode->initLevel(m_pLevel); } } @@ -466,7 +504,7 @@ void Minecraft::tickInput() if (!m_pLocalPlayer) return; - bool bIsInGUI = m_gui.isInside(Mouse::getX(), Mouse::getY()); + bool bIsInGUI = m_pGui->isInside(Mouse::getX(), Mouse::getY()); while (Mouse::next()) { @@ -478,7 +516,7 @@ void Minecraft::tickInput() // @HACK: on SDL1, we don't recenter the mouse every tick, meaning the user can // unintentionally click the hotbar while swinging their fist if (platform()->getRecenterMouseEveryTick() || m_pScreen) - m_gui.handleClick(1, Mouse::getX(), Mouse::getY()); + m_pGui->handleClick(1, Mouse::getX(), Mouse::getY()); } MouseButtonType buttonType = Mouse::getEventButton(); @@ -486,7 +524,7 @@ void Minecraft::tickInput() #ifdef ENH_ALLOW_SCROLL_WHEEL if (buttonType == BUTTON_SCROLLWHEEL) - m_gui.handleScroll(bPressed); + m_pGui->handleScroll(bPressed); #endif } @@ -499,9 +537,9 @@ void Minecraft::tickInput() if (bPressed) { - m_gui.handleKeyPressed(keyCode); + m_pGui->handleKeyPressed(keyCode); - for (int i = 0; i < m_gui.getNumUsableSlots(); i++) + for (int i = 0; i < m_pGui->getNumUsableSlots(); i++) { if (getOptions()->isKey(eKeyMappingIndex(KM_SLOT_1 + i), keyCode)) m_pLocalPlayer->m_pInventory->selectSlot(i); @@ -637,7 +675,7 @@ void Minecraft::sendMessage(const std::string& message) if (m_pRakNetInstance) m_pRakNetInstance->send(new MessagePacket(message)); else - m_gui.addMessage("You aren't actually playing multiplayer!"); + m_pGui->addMessage("You aren't actually playing multiplayer!"); } else { @@ -646,7 +684,7 @@ void Minecraft::sendMessage(const std::string& message) if (m_pNetEventCallback && m_pRakNetInstance) m_pNetEventCallback->handle(m_pRakNetInstance->m_pRakPeerInterface->GetMyGUID(), &mp); else - m_gui.addMessage("You aren't hosting a multiplayer server!"); + m_pGui->addMessage("You aren't hosting a multiplayer server!"); } } @@ -658,71 +696,46 @@ void Minecraft::respawnPlayer() m_pRakNetInstance->send(new RespawnPacket(m_pLocalPlayer->m_EntityID, m_pLocalPlayer->m_pos)); } -std::string Minecraft::getVersionString(const std::string& str) const +void Minecraft::freeResources(bool bCopyMap) { - return "v0.2.0" + str + " alpha"; -} + m_pLevelRenderer->setLevel(nullptr); + m_pParticleEngine->setLevel(nullptr); -void Minecraft::_reloadInput() -{ - if (m_pInputHolder) - delete m_pInputHolder; + m_pCameraEntity = nullptr; + m_pLocalPlayer = nullptr; - if (isTouchscreen()) - { - m_pInputHolder = new TouchInputHolder(this, m_options); - } - else if (useController()) - { - m_pInputHolder = new CustomInputHolder( - new ControllerMoveInput(m_options), - new ControllerTurnInput(), - new ControllerBuildInput() - ); - } +#ifndef ENH_IMPROVED_SAVING + if (bCopyMap) + setScreen(new RenameMPLevelScreen("_LastJoinedServer")); else - { - m_pInputHolder = new CustomInputHolder( - new KeyboardInput(m_options), - new MouseTurnInput(this), - new MouseBuildInput() - ); - } + setScreen(new StartMenuScreen); +#endif - m_mouseHandler.setTurnInput(m_pInputHolder->getTurnInput()); + m_pGameRenderer->setLevel(nullptr, nullptr); - if (m_pLevel && m_pLocalPlayer) - { - m_pLocalPlayer->m_pMoveInput = m_pInputHolder->getMoveInput(); - } + delete m_pNetEventCallback; + m_pNetEventCallback = nullptr; - m_options->field_19 = !isTouchscreen(); -} +#ifdef ENH_IMPROVED_SAVING + m_bIsGamePaused = true; + setScreen(new SavingWorldScreen(bCopyMap/*, m_pLocalPlayer*/)); +#else + if (m_pLevel) + { + LevelStorage* pStorage = m_pLevel->getLevelStorage(); + SAFE_DELETE(pStorage); + SAFE_DELETE(m_pLevel); -void Minecraft::_levelGenerated() -{ - if (m_pNetEventCallback) - m_pNetEventCallback->levelGenerated(m_pLevel); -} + m_pLevel = nullptr; + } +#endif -void Minecraft::_initTextures() -{ - m_pTextures->loadAndBindTexture(C_TERRAIN_NAME); - GetPatchManager()->PatchTextures(platform(), TYPE_TERRAIN); - m_pTextures->loadAndBindTexture(C_ITEMS_NAME); - GetPatchManager()->PatchTextures(platform(), TYPE_ITEMS); - - GetPatchManager()->PatchTiles(); + field_D9C = 0; } -void Minecraft::_resetPlayer(Player* player) +std::string Minecraft::getVersionString(const std::string& str) const { - m_pLevel->validateSpawn(); - player->reset(); - - TilePos pos = m_pLevel->getSharedSpawnPos(); - player->setPos(pos); - player->resetPos(); + return "v0.2.0" + str + " alpha"; } void Minecraft::tick() @@ -737,7 +750,7 @@ void Minecraft::tick() tickInput(); - m_gui.tick(); + m_pGui->tick(); // if the level has been prepared, delete the prep thread if (!m_bPreparingLevel) @@ -753,7 +766,7 @@ void Minecraft::tick() if (m_pLevel && !isGamePaused()) { - m_pLevel->m_difficulty = m_options->m_difficulty; + m_pLevel->m_difficulty = getOptions()->m_difficulty; if (m_pLevel->m_bIsClientSide) { m_pLevel->m_difficulty = 3; @@ -779,7 +792,7 @@ void Minecraft::tick() m_pParticleEngine->tick(); #ifndef ORIGINAL_CODE - m_pSoundEngine->update(m_pMobPersp, m_timer.m_renderTicks); + m_pSoundEngine->update(m_pCameraEntity, m_timer.m_renderTicks); #endif } @@ -838,59 +851,7 @@ void Minecraft::update() void Minecraft::init() { - // Optional features that you really should be able to get away with not including. - Screen::setIsMenuPanoramaAvailable(platform()->doesTextureExist("gui/background/panorama_0.png")); - LevelRenderer::setAreCloudsAvailable(platform()->doesTextureExist("environment/clouds.png")); - LevelRenderer::setArePlanetsAvailable(platform()->doesTextureExist("terrain/sun.png") && platform()->doesTextureExist("terrain/moon.png")); - GrassColor::setIsAvailable(platform()->doesTextureExist("misc/grasscolor.png")); - FoliageColor::setIsAvailable(platform()->doesTextureExist("misc/foliagecolor.png")); - Gui::setIsVignetteAvailable(platform()->doesTextureExist("misc/vignette.png")); - EntityRenderer::setAreShadowsAvailable(platform()->doesTextureExist("misc/shadow.png")); - - GetPatchManager()->LoadPatchData(platform()->getPatchData()); - - m_bIsTouchscreen = platform()->isTouchscreen(); - m_pRakNetInstance = new RakNetInstance; - - m_pTextures = new Textures(m_options, platform()); - m_pTextures->addDynamicTexture(new WaterTexture); - m_pTextures->addDynamicTexture(new WaterSideTexture); - m_pTextures->addDynamicTexture(new LavaTexture); - m_pTextures->addDynamicTexture(new LavaSideTexture); - m_pTextures->addDynamicTexture(new FireTexture(0)); - m_pTextures->addDynamicTexture(new FireTexture(1)); - - if (platform()->hasFileSystemAccess()) - m_options = new Options(m_externalStorageDir); - else - m_options = new Options(); - - m_options->m_bUseController = platform()->hasGamepad(); - m_options->loadControls(); - - _reloadInput(); - _initTextures(); - - m_pSoundEngine = new SoundEngine(platform()->getSoundSystem(), 20.0f); // 20.0f on 0.7.0 - m_pSoundEngine->init(m_options, platform()); - - m_pLevelRenderer = new LevelRenderer(this, m_pTextures); - m_pGameRenderer = new GameRenderer(this); - m_pParticleEngine = new ParticleEngine(m_pLevel, m_pTextures); - m_pUser = new User(getOptions()->m_playerName, ""); - - // "Default.png" for the launch image overwrites "default.png" for the font during app packaging - m_pFont = new Font(m_options, "font/default8.png", m_pTextures); - - if (GrassColor::isAvailable()) - { - GrassColor::init(m_pPlatform->loadTexture("misc/grasscolor.png", true)); - } - if (FoliageColor::isAvailable()) - { - FoliageColor::init(m_pPlatform->loadTexture("misc/foliagecolor.png", true)); - } } void Minecraft::prepareLevel(const std::string& unused) @@ -1054,6 +1015,23 @@ float Minecraft::getBestScaleForThisScreenSize(int width, int height) return 1.0f; } +void Minecraft::setupLevelRendering(Level* pLevel, Dimension* pDimension, Mob* pCamera) +{ + m_pCameraEntity = pCamera; + + m_pParticleEngine->setLevel(pLevel); + m_pGameRenderer->setLevel(pLevel, pDimension); + m_pLevelRenderer->setLevel(pLevel); + m_pLevelRenderer->setDimension(pDimension); +} + +void Minecraft::onClientStartedLevel(Level* pLevel, LocalPlayer* pLocalPlayer) +{ + // already added in Level::loadPlayer() + //pLevel->addEntity(pLocalPlayer); // addPlayer on 0.12.1 + setupLevelRendering(pLevel, pLocalPlayer->getDimension(), pLocalPlayer); +} + void Minecraft::generateLevel(const std::string& unused, Level* pLevel) { float time = float(getTimeS()); //@UNUSED @@ -1069,30 +1047,19 @@ void Minecraft::generateLevel(const std::string& unused, Level* pLevel) if (!pLocalPlayer) { pLocalPlayer = m_pGameMode->createPlayer(pLevel); - m_pLocalPlayer = pLocalPlayer; + pLocalPlayer->resetPos(); m_pGameMode->initPlayer(pLocalPlayer); } if (pLocalPlayer) pLocalPlayer->m_pMoveInput = m_pInputHolder->getMoveInput(); - if (m_pLevelRenderer) - m_pLevelRenderer->setLevel(pLevel); - - if (m_pParticleEngine) - m_pParticleEngine->setLevel(pLevel); - - m_pGameMode->adjustPlayer(m_pLocalPlayer); - - // was after loadPlayer for some reason - if (m_pLocalPlayer) - m_pLocalPlayer->resetPos(); + m_pGameMode->adjustPlayer(pLocalPlayer); pLevel->validateSpawn(); - pLevel->loadPlayer(*m_pLocalPlayer); + pLevel->loadPlayer(*pLocalPlayer); - m_pMobPersp = m_pLocalPlayer; - m_pLevel = pLevel; + m_pLocalPlayer = pLocalPlayer; m_bPreparingLevel = false; @@ -1135,7 +1102,7 @@ bool Minecraft::resumeGame() void Minecraft::setLevel(Level* pLevel, const std::string& text, LocalPlayer* pLocalPlayer) { - m_pMobPersp = nullptr; + m_pCameraEntity = nullptr; if (pLevel) { @@ -1151,9 +1118,6 @@ void Minecraft::setLevel(Level* pLevel, const std::string& text, LocalPlayer* pL pLevel->addEntity(m_pLocalPlayer); } - if (m_pLocalPlayer) - m_pLocalPlayer->resetPos(); - m_pLevel = pLevel; m_bPreparingLevel = true; m_pPrepThread = new CThread(&Minecraft::prepareLevel_tspawn, this); @@ -1189,7 +1153,7 @@ void Minecraft::selectLevel(const LevelSummary& ls, bool forceConversion) void Minecraft::selectLevel(const std::string& levelDir, const std::string& levelName, const LevelSettings& levelSettings, bool forceConversion) { LevelStorage* pStor = m_pLevelStorageSource->selectLevel(levelDir, false, forceConversion); - Dimension* pDim = Dimension::getNew(0); + Dimension* pDim = Dimension::createNew(DIMENSION_NORMAL); m_pLevel = new Level(pStor, levelName, levelSettings, LEVEL_STORAGE_VERSION_DEFAULT, pDim); setLevel(m_pLevel, "Generating level", nullptr); @@ -1227,6 +1191,10 @@ ItemInstance* Minecraft::getSelectedItem() return pInst; } +void Minecraft::reloadFancy(bool isFancy) +{ +} + int Minecraft::getFpsIntlCounter() { return 0; @@ -1235,49 +1203,11 @@ int Minecraft::getFpsIntlCounter() void Minecraft::leaveGame(bool bCopyMap) { m_bPreparingLevel = false; + if (m_pRakNetInstance) m_pRakNetInstance->disconnect(); - m_pMobPersp = nullptr; - m_pLevelRenderer->setLevel(nullptr); - m_pParticleEngine->setLevel(nullptr); - -#ifndef ORIGINAL_CODE - // @BUG: Deleting ServerSideNetworkHandler too late! This causes - // access to invalid memory in the destructor seeing as we already deleted the level. - delete m_pNetEventCallback; -#endif - -#ifdef ENH_IMPROVED_SAVING - m_bIsGamePaused = true; - setScreen(new SavingWorldScreen(bCopyMap/*, m_pLocalPlayer*/)); -#else - if (m_pLevel) - { - LevelStorage* pStorage = m_pLevel->getLevelStorage(); - SAFE_DELETE(pStorage); - SAFE_DELETE(m_pLevel); - m_pLevel = nullptr; - } -#endif - -#ifdef ORIGINAL_CODE - delete m_pNetEventCallback; -#endif - - m_pLocalPlayer = nullptr; - m_pNetEventCallback = nullptr; - field_D9C = 0; - -#ifndef ENH_IMPROVED_SAVING - // this is safe to do, since on destruction, we don't actually delete it. - SAFE_DELETE(m_pLocalPlayer); - - if (bCopyMap) - setScreen(new RenameMPLevelScreen("_LastJoinedServer")); - else - setScreen(new StartMenuScreen); -#endif + freeResources(bCopyMap); } void Minecraft::hostMultiplayer() diff --git a/source/client/app/Minecraft.hpp b/source/client/app/Minecraft.hpp index 87fd0677f..4d1d2d6e2 100644 --- a/source/client/app/Minecraft.hpp +++ b/source/client/app/Minecraft.hpp @@ -37,6 +37,14 @@ class Minecraft : public App Minecraft(); virtual ~Minecraft(); +private: + void _levelGenerated(); + void _resetPlayer(Player* player); + GameMode* _createGameMode(GameType gameType, Level& level); + +protected: + void _reloadInput(); + public: int getLicenseId(); void setScreen(Screen * pScreen); @@ -64,6 +72,7 @@ class Minecraft : public App void resetInput(); void sendMessage(const std::string& message); void respawnPlayer(); + void freeResources(bool bCopyMap); std::string getVersionString(const std::string& str = Util::EMPTY_STRING) const; bool isTouchscreen() const; bool useSplitControls() const; @@ -71,13 +80,16 @@ class Minecraft : public App void setGameMode(GameType gameType); - virtual void update() override; - virtual void init() override; - virtual void onGraphicsReset(); - virtual void sizeUpdate(int newWidth, int newHeight) override; + void update() override; + void init() override; + void sizeUpdate(int newWidth, int newHeight) override; + + virtual void reloadFancy(bool isFancy); virtual int getFpsIntlCounter(); float getBestScaleForThisScreenSize(int width, int height); + void setupLevelRendering(Level* pLevel, Dimension* pDimension, Mob* pCamera); + void onClientStartedLevel(Level* pLevel, LocalPlayer* pLocalPlayer); void generateLevel(const std::string& unused, Level* pLevel); void prepareLevel(const std::string& unused); bool isOnline() const; @@ -88,14 +100,8 @@ class Minecraft : public App const char* getProgressMessage(); LevelStorageSource* getLevelSource(); ItemInstance* getSelectedItem(); - Options* getOptions() const { return m_options; } - -private: - void _reloadInput(); - void _levelGenerated(); - void _initTextures(); - void _resetPlayer(Player* player); - GameMode* createGameMode(GameType gameType, Level& level); + Options* getOptions() const { return m_pOptions; } + //const Entity& getCameraEntity() const { return *m_pCameraEntity; } private: // Value provided by the OS @@ -111,8 +117,8 @@ class Minecraft : public App static const bool DEADMAU5_CAMERA_CHEATS; static int customDebugId; -private: - Options *m_options; +protected: + Options *m_pOptions; public: bool field_18; @@ -132,8 +138,8 @@ class Minecraft : public App User* m_pUser; Level* m_pLevel; LocalPlayer* m_pLocalPlayer; - Mob* m_pMobPersp; // why is there a duplicate? - Gui m_gui; + Mob* m_pCameraEntity; + Gui* m_pGui; int field_D0C; CThread* m_pPrepThread; Screen* m_pScreen; diff --git a/source/client/app/NinecraftApp.cpp b/source/client/app/NinecraftApp.cpp index 70b72fa31..7553bf3ad 100644 --- a/source/client/app/NinecraftApp.cpp +++ b/source/client/app/NinecraftApp.cpp @@ -11,6 +11,17 @@ #include "world/entity/MobCategory.hpp" #include "client/player/input/Multitouch.hpp" #include "client/gui/screens/StartMenuScreen.hpp" +#include "client/renderer/FoliageColor.hpp" +#include "client/renderer/GrassColor.hpp" +#include "client/renderer/Lighting.hpp" +#include "client/renderer/PatchManager.hpp" +#include "client/renderer/renderer/RenderMaterialGroup.hpp" +#include "renderer/GlobalConstantBufferManager.hpp" +#include "renderer/GlobalConstantBuffers.hpp" +#include "renderer/ConstantBufferMetaDataManager.hpp" +#include "renderer/RenderContextImmediate.hpp" +#include "renderer/RenderMaterial.hpp" +#include "renderer/platform/ogl/Extensions.hpp" #ifdef DEMO #include "world/level/storage/MemoryLevelStorageSource.hpp" @@ -20,6 +31,119 @@ bool NinecraftApp::_hasInitedStatics; +void NinecraftApp::_initOptions() +{ + // Must be loaded before options, certain options states are forced based on this + _reloadOptionalFeatures(); + _reloadPatchData(); + + if (platform()->hasFileSystemAccess()) + m_pOptions = new Options(m_externalStorageDir); + else + m_pOptions = new Options(); +} + +void NinecraftApp::_initTextures() +{ + m_pTextures = new Textures(getOptions(), platform()); + + m_pTextures->addDynamicTexture(new WaterTexture); + m_pTextures->addDynamicTexture(new WaterSideTexture); + m_pTextures->addDynamicTexture(new LavaTexture); + m_pTextures->addDynamicTexture(new LavaSideTexture); + m_pTextures->addDynamicTexture(new FireTexture(0)); + m_pTextures->addDynamicTexture(new FireTexture(1)); + + //m_pTextures->loadList("startup.images"); + //m_pTextures->loadList("background.images"); + //m_pTextures->loadList("ingame.images", ...); + + _reloadTextures(); + + if (GrassColor::isAvailable()) + { + TextureData textureData = m_pPlatform->loadTexture("misc/grasscolor.png", true); + GrassColor::init(textureData); + } + if (FoliageColor::isAvailable()) + { + TextureData textureData = m_pPlatform->loadTexture("misc/foliagecolor.png", true); + FoliageColor::init(textureData); + } +} + +void NinecraftApp::_initMaterials() +{ + mce::RenderMaterialGroup::common.loadList("materials/common.json"); + _reloadFancy(getOptions()->m_bFancyGraphics); +} + +void NinecraftApp::_initInput() +{ + m_bIsTouchscreen = platform()->isTouchscreen(); + getOptions()->m_bUseController = platform()->hasGamepad(); + getOptions()->loadControls(); + _reloadInput(); +} + +void NinecraftApp::_updateStats() +{ + /* + int timeMs = getTimeMs(); + if (timeMs > field_2B0 + 999) + { + if (m_pLocalPlayer) + { + Vec3 &pos = m_pLocalPlayer->m_pos; + LOG_I("%d fps\t%3d chunk updates. (%.2f, %.2f, %.2f)", m_fps, Chunk::updates, pos.x, pos.y, pos.z); + LOG_I("%s", m_pLevelRenderer->gatherStats1().c_str()); + Chunk::updates = 0; + } + else + { + LOG_I("%d fps", m_fps); + } + + field_2B0 = timeMs; + m_fps = 0; + } + */ +} + +void NinecraftApp::_reloadTextures() +{ + TextureData* pTexture; + pTexture = m_pTextures->loadAndBindTexture(C_TERRAIN_NAME); + GetPatchManager()->PatchTextures(*pTexture, TYPE_TERRAIN); + pTexture = m_pTextures->loadAndBindTexture(C_ITEMS_NAME); + GetPatchManager()->PatchTextures(*pTexture, TYPE_ITEMS); + + GetPatchManager()->PatchTiles(); +} + +void NinecraftApp::_reloadFancy(bool isFancy) +{ + std::string listPath = isFancy ? "materials/fancy.json" : "materials/sad.json"; + mce::RenderMaterialGroup::switchable.loadList(listPath); +} + +void NinecraftApp::_reloadOptionalFeatures() +{ + // Optional features that you really should be able to get away with not including. + Screen::setIsMenuPanoramaAvailable(platform()->doesTextureExist("gui/background/panorama_0.png")); + LevelRenderer::setAreCloudsAvailable(platform()->doesTextureExist("environment/clouds.png")); + LevelRenderer::setArePlanetsAvailable(platform()->doesTextureExist("terrain/sun.png") && platform()->doesTextureExist("terrain/moon.png")); + GrassColor::setIsAvailable(platform()->doesTextureExist("misc/grasscolor.png")); + FoliageColor::setIsAvailable(platform()->doesTextureExist("misc/foliagecolor.png")); + Gui::setIsVignetteAvailable(platform()->doesTextureExist("misc/vignette.png")); + EntityRenderer::setAreShadowsAvailable(platform()->doesTextureExist("misc/shadow.png")); +} + +void NinecraftApp::_reloadPatchData() +{ + GetPatchManager()->LoadPatchData(platform()->getPatchData()); +} + bool NinecraftApp::handleBack(bool b) { if (m_bPreparingLevel) @@ -56,19 +180,6 @@ bool NinecraftApp::handleBack(bool b) return true; } -void NinecraftApp::initGLStates() -{ - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_LEQUAL); - glEnable(GL_ALPHA_TEST); - glAlphaFunc(GL_GREATER, 0.1f); - glCullFace(GL_BACK); - glEnable(GL_TEXTURE_2D); - glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); - glDisable(GL_LIGHTING); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -} - int NinecraftApp::getFpsIntlCounter() { int ofps = m_fps; @@ -92,10 +203,12 @@ void NinecraftApp::init() //TileEntity::initTileEntities(); } - initGLStates(); - Tesselator::instance.init(); - platform()->initSoundSystem(); + _initOptions(); + setupRenderer(); + _initTextures(); Minecraft::init(); + mce::RenderMaterial::InitContext(); + Tesselator::instance.init(); #ifdef DEMO m_pLevelStorageSource = new MemoryLevelStorageSource; @@ -103,21 +216,85 @@ void NinecraftApp::init() m_pLevelStorageSource = new ExternalFileLevelStorageSource(m_externalStorageDir); #endif + _initMaterials(); + + m_pGui = new Gui(this); + // "Default.png" for the launch image overwrites "default.png" for the font during app packaging + m_pFont = new Font(getOptions(), "font/default8.png", m_pTextures); + m_pLevelRenderer = new LevelRenderer(this, m_pTextures); + m_pGameRenderer = new GameRenderer(this); + m_pParticleEngine = new ParticleEngine(m_pLevel, m_pTextures); + m_pUser = new User(getOptions()->m_playerName, ""); + + _initInput(); + + platform()->initSoundSystem(); + m_pSoundEngine = new SoundEngine(platform()->getSoundSystem(), 20.0f); // 20.0f on 0.7.0 + m_pSoundEngine->init(getOptions(), platform()); + field_D9C = 0; setScreen(new StartMenuScreen); } +void NinecraftApp::setupRenderer() +{ + mce::GlobalConstantBufferManager::createInstance(); + mce::GlobalConstantBuffers::createInstance(); + if (mce::ConstantBufferMetaDataManager::createInstance()) + { +#ifdef FEATURE_GFX_SHADERS + mce::ConstantBufferMetaDataManager& metaDataManager = mce::ConstantBufferMetaDataManager::getInstance(); + std::string fileContents = AppPlatform::singleton()->readAssetFileStr("shaders/uniforms.json", false); + metaDataManager.loadJsonFile(fileContents); +#endif + } + mce::RenderDevice::createInstance(); + mce::GlobalConstantBufferManager::getInstance().allocateAndSetupConstantBuffersFromMetadata(mce::RenderContextImmediate::get()); +} + void NinecraftApp::onGraphicsReset() { - initGLStates(); + platform()->_fireAppSuspended(); + + // Needs to be called before materials are reloaded + mce::RenderContext& renderContext = mce::RenderContextImmediate::get(); + renderContext.lostContext(); + + platform()->_fireAppResumed(); + + // The rest should be in onAppResumed, but we haven't added that yet + + //mce::RenderContext& renderContext = mce::RenderContextImmediate::get(); + //renderContext.lostContext(); Tesselator::instance.init(); - Minecraft::onGraphicsReset(); + + m_pTextures->clear(); + _reloadTextures(); + m_pFont->onGraphicsReset(); + + if (m_pGameRenderer) + m_pGameRenderer->onGraphicsReset(); + + EntityRenderDispatcher::getInstance()->onGraphicsReset(); } void NinecraftApp::teardown() { + teardownRenderer(); +} + +void NinecraftApp::teardownRenderer() +{ + mce::GlobalConstantBuffers::deleteInstance(); + mce::GlobalConstantBufferManager::deleteInstance(); +} +void NinecraftApp::reloadFancy(bool isFancy) +{ + m_pLevelRenderer->allChanged(); + EntityRenderDispatcher::instance->onAppSuspended(); + _reloadFancy(isFancy); } void NinecraftApp::update() @@ -126,31 +303,7 @@ void NinecraftApp::update() Multitouch::commit(); Minecraft::update(); Mouse::reset2(); - updateStats(); -} - -void NinecraftApp::updateStats() -{ - /* - int timeMs = getTimeMs(); - if (timeMs > field_2B0 + 999) - { - if (m_pLocalPlayer) - { - Vec3 &pos = m_pLocalPlayer->m_pos; - LOG_I("%d fps\t%3d chunk updates. (%.2f, %.2f, %.2f)", m_fps, Chunk::updates, pos.x, pos.y, pos.z); - LOG_I("%s", m_pLevelRenderer->gatherStats1().c_str()); - Chunk::updates = 0; - } - else - { - LOG_I("%d fps", m_fps); - } - - field_2B0 = timeMs; - m_fps = 0; - } - */ + _updateStats(); } NinecraftApp::NinecraftApp() diff --git a/source/client/app/NinecraftApp.hpp b/source/client/app/NinecraftApp.hpp index f37cdcb1d..b15f30d89 100644 --- a/source/client/app/NinecraftApp.hpp +++ b/source/client/app/NinecraftApp.hpp @@ -20,14 +20,28 @@ class NinecraftApp : public Minecraft NinecraftApp(); virtual ~NinecraftApp(); +private: + void _initOptions(); + void _initTextures(); + void _initMaterials(); + void _initInput(); + void _updateStats(); + +protected: + void _reloadTextures(); + void _reloadFancy(bool isFancy); + void _reloadOptionalFeatures(); + void _reloadPatchData(); + +public: bool handleBack(bool) override; void init() override; + void setupRenderer(); void update() override; - void onGraphicsReset() override; + void onGraphicsReset(); void teardown(); - - void updateStats(); - void initGLStates(); + void teardownRenderer(); + void reloadFancy(bool isFancy) override; int getFpsIntlCounter() override; diff --git a/source/client/gui/Gui.cpp b/source/client/gui/Gui.cpp index f42ad242f..3e82a795b 100644 --- a/source/client/gui/Gui.cpp +++ b/source/client/gui/Gui.cpp @@ -10,11 +10,23 @@ #include "client/gui/screens/IngameBlockSelectionScreen.hpp" #include "client/gui/screens/ChatScreen.hpp" #include "client/renderer/entity/ItemRenderer.hpp" +#include "client/renderer/renderer/RenderMaterialGroup.hpp" +#include "renderer/ShaderConstants.hpp" #ifdef _WIN32 #pragma warning(disable : 4244) #endif +Gui::Materials::Materials() +{ + MATERIAL_PTR(common, ui_vignette); + MATERIAL_PTR(common, ui_overlay); + MATERIAL_PTR(common, ui_invert_overlay); + MATERIAL_PTR(common, ui_overlay_textured); + MATERIAL_PTR(common, ui_invert_overlay_textured); + MATERIAL_PTR(common, ui_crosshair); +} + #ifdef ENH_USE_GUI_SCALE_2 float Gui::InvGuiScale = 1.0f / 2.0f; #else @@ -25,7 +37,7 @@ bool Gui::_isVignetteAvailable = false; // false because PE never seemed to have Gui::Gui(Minecraft* pMinecraft) { - field_8 = 0; + m_progress = 0; field_C = ""; field_24 = 0; field_28 = 0; @@ -37,10 +49,17 @@ Gui::Gui(Minecraft* pMinecraft) field_A20 = 1.0f; field_A3C = true; m_bRenderMessages = true; + m_bRenderHunger = false; + m_width = 0; + m_height = 0; m_pMinecraft = pMinecraft; +} - xglGenBuffers(1, &m_renderChunk.field_0); +void Gui::_updateHudPositions() +{ + m_width = int(ceilf(Minecraft::width * InvGuiScale)); + m_height = int(ceilf(Minecraft::height * InvGuiScale)); } void Gui::addMessage(const std::string& s) @@ -92,44 +111,32 @@ void Gui::setNowPlaying(const std::string& str) void Gui::renderPumpkin(int var1, int var2) { - glDisable(GL_DEPTH_TEST); - glDepthMask(false); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glDisable(GL_ALPHA_TEST); + currentShaderColor = Color::WHITE; + currentShaderDarkColor = Color::WHITE; m_pMinecraft->m_pTextures->setSmoothing(true); m_pMinecraft->m_pTextures->loadAndBindTexture("/misc/pumpkinblur.png"); m_pMinecraft->m_pTextures->setSmoothing(false); Tesselator& t = Tesselator::instance; - t.begin(); + t.begin(4); t.vertexUV(0.0f, var2, -90.0f, 0.0f, 1.0f); t.vertexUV(var1, var2, -90.0f, 1.0f, 1.0f); t.vertexUV(var1, 0.0f, -90.0f, 1.0f, 0.0f); t.vertexUV(0.0f, 0.0f, -90.0f, 0.0f, 0.0f); - t.draw(); - - glDepthMask(true); - glEnable(GL_DEPTH_TEST); - glEnable(GL_ALPHA_TEST); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + t.draw(m_materials.ui_textured); } -void Gui::renderVignette(float a2, int a3, int a4) +void Gui::renderVignette(float brightness, int width, int height) { - a2 = 1.0f - a2; - if (a2 > 1.0f) - a2 = 1.0f; - if (a2 < 0.0f) - a2 = 0.0f; - - field_A20 += ((a2 - field_A20) * 0.01f); - glDisable(GL_DEPTH_TEST); - glDepthMask(false); - glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR); - glColor4f(field_A20, field_A20, field_A20, 1.0f); + brightness = 1.0f - brightness; + if (brightness > 1.0f) + brightness = 1.0f; + if (brightness < 0.0f) + brightness = 0.0f; + + field_A20 += ((brightness - field_A20) * 0.01f); //! @BUG: No misc/vignette.png to be found in the original. //! This function is unused anyways @@ -138,17 +145,13 @@ void Gui::renderVignette(float a2, int a3, int a4) m_pMinecraft->m_pTextures->setSmoothing(false); Tesselator& t = Tesselator::instance; - t.begin(); - t.vertexUV(0.0f, a4, -90.0f, 0.0f, 1.0f); - t.vertexUV(a3, a4, -90.0f, 1.0f, 1.0f); - t.vertexUV(a3, 0.0f, -90.0f, 1.0f, 0.0f); - t.vertexUV(0.0f, 0.0f, -90.0f, 0.0f, 0.0f); - t.draw(); - - glDepthMask(true); - glEnable(GL_DEPTH_TEST); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + t.begin(4); + t.color(field_A20, field_A20, field_A20); + t.vertexUV(0.0f, height, -90.0f, 0.0f, 1.0f); + t.vertexUV(width, height, -90.0f, 1.0f, 1.0f); + t.vertexUV(width, 0.0f, -90.0f, 1.0f, 0.0f); + t.vertexUV(0.0f, 0.0f, -90.0f, 0.0f, 0.0f); + t.draw(m_guiMaterials.ui_vignette); } void Gui::inventoryUpdated() @@ -158,247 +161,55 @@ void Gui::inventoryUpdated() void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY) { - Minecraft* mc = m_pMinecraft; - GameRenderer* renderer = mc->m_pGameRenderer; + Minecraft& mc = *m_pMinecraft; + GameRenderer& renderer = *mc.m_pGameRenderer; + Textures& textures = *mc.m_pTextures; + bool isTouchscreen = AppPlatform::singleton()->isTouchscreen(); - renderer->setupGuiScreen(); - - LocalPlayer* player = mc->m_pLocalPlayer; + renderer.setupGuiScreen(); - if (!mc->m_pLevel || !player) + if (!mc.m_pLevel || !mc.m_pLocalPlayer) return; - glEnable(GL_BLEND); + _updateHudPositions(); - int width = int(ceilf(Minecraft::width * InvGuiScale)), - height = int(ceilf(Minecraft::height * InvGuiScale)); - - if (mc->getOptions()->m_bFancyGraphics && isVignetteAvailable()) + if (mc.getOptions()->m_bFancyGraphics && isVignetteAvailable()) { - renderVignette(player->getBrightness(f), width, height); + renderVignette(mc.m_pLocalPlayer->getBrightness(f), m_width, m_height); // WARNING: TOO SPOOKY, DO NOT UNCOMMENT, YOU WILL GET SPOOKED - //renderPumpkin(width, height); + //renderPumpkin(m_width, m_height); } -#ifndef ENH_TRANSPARENT_HOTBAR - glColor4f(1.0f, 1.0f, 1.0f, 0.5f); -#else - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); -#endif - - Textures* textures = mc->m_pTextures; - - textures->loadAndBindTexture("gui/gui.png"); - - field_4 = -90.0f; - -#ifdef ENH_TRANSPARENT_HOTBAR - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -#endif - - // chat - //blit(width - 18, 0, 200, 82, 18, 18, 18, 18); - - int nSlots = getNumSlots(); - int hotbarWidth = 2 + nSlots * 20; - - // hotbar - int cenX = width / 2; - blit(cenX - hotbarWidth / 2, height - 22, 0, 0, hotbarWidth-2, 22, 0, 0); - blit(cenX + hotbarWidth / 2 -2, height - 22, 180, 0, 2, 22, 0, 0); - - Inventory* inventory = player->m_pInventory; - - // selection mark - blit(cenX - 1 - hotbarWidth / 2 + 20 * inventory->m_selectedHotbarSlot, height - 23, 0, 22, 24, 22, 0, 0); - - textures->loadAndBindTexture("gui/icons.png"); - - if (mc->useSplitControls()) - { -#ifndef ENH_TRANSPARENT_HOTBAR - //glEnable(GL_BLEND); -#endif + currentShaderColor = Color::WHITE; + currentShaderDarkColor = Color::WHITE; - // draw crosshair - glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR); - blit(cenX - 8, height / 2 - 8, 0, 0, 16, 16, 0, 0); + renderProgressIndicator(m_width, m_height); -#ifndef ENH_TRANSPARENT_HOTBAR - //glDisable(GL_BLEND); -#endif - } - else + if (mc.m_pGameMode->canHurtPlayer()) { - IInputHolder* input = mc->m_pInputHolder; - // if needed, draw feedback - - // NOTE: real Minecraft PE takes it directly from the gamemode as "current progress" and - // "last progress". Well guess what? The game mode in question updates our m_fSensitivity with - // the pre-interpolated break progress! Isn't that awesome?! - float breakProgress = field_8; + textures.loadAndBindTexture("gui/icons.png"); - // don't know about this if-structure, it feels like it'd be like - // if (m_bFoggy >= 0.0f && breakProgress <= 0.0f) - // that; - // else - // this; - if (breakProgress > 0.0f || input->m_feedbackAlpha < 0.0f) - { - if (breakProgress > 0.0f) - { - float xPos = input->m_feedbackX; - float yPos = input->m_feedbackY; + Tesselator& t = Tesselator::instance; + t.begin(0); + t.voidBeginAndEndCalls(true); - textures->loadAndBindTexture("gui/feedback_outer.png"); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - //glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - blit(InvGuiScale * xPos - 44.0f, InvGuiScale * yPos - 44.0f, 0, 0, 88, 88, 256, 256); + renderHearts(isTouchscreen); + renderBubbles(isTouchscreen); + if (m_bRenderHunger) + renderHunger(isTouchscreen); - glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR); - textures->loadAndBindTexture("gui/feedback_fill.png"); + t.voidBeginAndEndCalls(false); + t.draw(m_materials.ui_textured); - // note: scale starts from 4.0f - float halfWidth = (40.0f * breakProgress + 48.0f) / 2.0f; - - blit(InvGuiScale * xPos - halfWidth, InvGuiScale * yPos - halfWidth, 0, 0, halfWidth * 2, halfWidth * 2, 256, 256); - - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - //glDisable(GL_BLEND); - } - } - else - { - float xPos = input->m_feedbackX; - float yPos = input->m_feedbackY; - - textures->loadAndBindTexture("gui/feedback_outer.png"); - glColor4f(1.0f, 1.0f, 1.0f, Mth::Min(1.0f, input->m_feedbackAlpha)); - //glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - blit(InvGuiScale * xPos - 44.0f, InvGuiScale * yPos - 44.0f, 0, 0, 88, 88, 256, 256); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - //glDisable(GL_BLEND); - } + renderExperience(); } - glDisable(GL_BLEND); - - if (mc->m_pGameMode->canHurtPlayer()) - { - // why?? - m_random.init_genrand(312871 * field_9FC); - - int emptyHeartX = 16; - bool b1 = false; - if (player->m_invulnerableTime < 10) - { - b1 = player->m_invulnerableTime / 3 % 2; - emptyHeartX += 9 * b1; - } -#if defined(ANDROID) || defined(TARGET_OS_IPHONE) - //@NOTE: Pocket-style health UI. - int heartX = 2; - int heartYStart = 2; -#else - // @NOTE: At the default scale, this would go off screen. - int heartX = cenX - 191; // why? - int heartYStart = height - 10; - - //@NOTE: Alpha-style health UI. I'll probably remove this on release. - heartX = cenX - 91; - heartYStart = height - 32; -#endif - int playerHealth = player->m_health; - - for (int healthNo = 1; healthNo <= C_MAX_MOB_HEALTH; healthNo += 2) - { - int heartY = heartYStart; - - if (playerHealth <= 4 && m_random.genrand_int32() % 2) - heartY++; - - blit(heartX, heartY, emptyHeartX, 0, 9, 9, 0, 0); - - if (b1) - { - if (healthNo < player->m_lastHealth) - blit(heartX, heartY, 70, 0, 9, 9, 0, 0); - else if (healthNo == player->m_lastHealth) - blit(heartX, heartY, 79, 0, 9, 9, 0, 0); - } - - if (healthNo < playerHealth) - blit(heartX, heartY, 52, 0, 9, 9, 0, 0); - else if (healthNo == playerHealth) - blit(heartX, heartY, 61, 0, 9, 9, 0, 0); - - heartX += 8; - } - - if (player->isUnderLiquid(Material::water)) - { - int breathRaw = player->m_airCapacity; - int breathFull = int(ceilf((float(breathRaw - 2) * 10.0f) / 300.0f)); - int breathMeter = int(ceilf((float(breathRaw) * 10.0f) / 300.0f)) - breathFull; -#if defined(ANDROID) || defined(TARGET_OS_IPHONE) - // pe - int bubbleX = 2; - int bubbleY = 12; -#else - int bubbleX = cenX - 191; - int bubbleY = height - 19; - - bubbleX = cenX - 91; - bubbleY = height - 41; + float alpha = 1.0f; +#ifndef ENH_TRANSPARENT_HOTBAR + alpha = 0.50f; // 0.65f on 0.12.1 #endif - //@NOTE: Not sure this works as it should - - for (int bubbleNo = 0; bubbleNo < breathFull + breathMeter; bubbleNo++) - { - if (bubbleNo < breathFull) - blit(bubbleX, bubbleY, 16, 18, 9, 9, 0, 0); - else - blit(bubbleX, bubbleY, 25, 18, 9, 9, 0, 0); - - bubbleX += 8; - } - } - } - - textures->loadAndBindTexture(C_BLOCKS_NAME); + renderToolBar(f, alpha); - int diff = mc->isTouchscreen(); - - int slotX = cenX - hotbarWidth / 2 + 3; - for (int i = 0; i < nSlots - diff; i++) - { - renderSlot(i, slotX, height - 19, f); - - slotX += 20; - } - - slotX = cenX - hotbarWidth / 2 + 3; - for (int i = 0; i < nSlots - diff; i++) - { - renderSlotOverlay(i, slotX, height - 19, f); - - slotX += 20; - } - -#undef DIFF - - field_A3C = false; - - // blit the "more items" button - if (mc->isTouchscreen()) - { - textures->loadAndBindTexture(C_TERRAIN_NAME); - blit(cenX + hotbarWidth / 2 - 19, height - 19, 208, 208, 16, 16, 0, 0); - } - - // render messages if (m_bRenderMessages) { renderMessages(false); @@ -427,19 +238,21 @@ void Gui::renderSlot(int slot, int x, int y, float f) if (ItemInstance::isNull(pInst)) return; - float var6 = ((float)pInst->m_popTime) - f; - if (var6 > 0.0f) - { - glPushMatrix(); - float var7 = 1.0f + var6 / 5.0f; - glTranslatef(x + 8, y + 12, 0.0f); - glScalef(1.0f / var7, (var7 + 1.0f) / 2.0f, 1.0f); - glTranslatef(-(x + 8), -(y + 12), 0.0f); - } + { + MatrixStack::Ref matrix; + + float var6 = ((float)pInst->m_popTime) - f; + if (var6 > 0.0f) + { + float var7 = 1.0f + var6 / 5.0f; + matrix = MatrixStack::World.push(); + matrix->translate(Vec3(x + 8, y + 12, 0.0f)); + matrix->scale(Vec3(1.0f / var7, (var7 + 1.0f) / 2.0f, 1.0f)); + matrix->translate(Vec3(-(x + 8), -(y + 12), 0.0f)); + } - ItemRenderer::renderGuiItem(m_pMinecraft->m_pFont, m_pMinecraft->m_pTextures, pInst, x, y, true); - if (var6 > 0.0f) - glPopMatrix(); + ItemRenderer::singleton().renderGuiItem(m_pMinecraft->m_pFont, m_pMinecraft->m_pTextures, pInst, x, y, true); + } //ItemRenderer::renderGuiItemDecorations(m_pMinecraft->m_pFont, m_pMinecraft->m_pTextures, pInst, x, y); } @@ -452,7 +265,7 @@ void Gui::renderSlotOverlay(int slot, int x, int y, float f) if (ItemInstance::isNull(pInst)) return; - ItemRenderer::renderGuiItemOverlay(m_pMinecraft->m_pFont, m_pMinecraft->m_pTextures, pInst, x, y); + ItemRenderer::singleton().renderGuiItemOverlay(m_pMinecraft->m_pFont, m_pMinecraft->m_pTextures, pInst, x, y); } int Gui::getSlotIdAt(int mouseX, int mouseY) @@ -598,13 +411,252 @@ void Gui::renderMessages(bool bShowAll) } fill(2, topEdge, 322, topEdge + 9, bkgdColor); - glEnable(GL_BLEND); m_pMinecraft->m_pFont->drawShadow(msg.msg, 2, topEdge + 1, textColor); topEdge -= 9; } +} + +void Gui::renderHearts(bool topLeft) +{ + LocalPlayer* player = m_pMinecraft->m_pLocalPlayer; + + int cenX = m_width / 2; + + int emptyHeartX = 16; + bool b1 = false; + if (player->m_invulnerableTime < 10) + { + b1 = player->m_invulnerableTime / 3 % 2; + emptyHeartX += 9 * b1; + } + + int heartX; + int heartYStart; + + if (topLeft) + { + heartX = 2; + heartYStart = 2; + } + else + { + // @NOTE: At the default scale, this would go off screen. + // Renders to the left of the hotbar, why? + /*heartX = cenX - 191; // why? + heartYStart = m_height - 10;*/ + + heartX = cenX - 91; + heartYStart = m_height - 32; + } + + int playerHealth = player->m_health; + + for (int healthNo = 1; healthNo <= C_MAX_MOB_HEALTH; healthNo += 2) + { + int heartY = heartYStart; + + if (playerHealth <= 4 && m_random.genrand_int32() % 2) + heartY++; + + blit(heartX, heartY, emptyHeartX, 0, 9, 9, 0, 0); + + if (b1) + { + if (healthNo < player->m_lastHealth) + blit(heartX, heartY, 70, 0, 9, 9, 0, 0); + else if (healthNo == player->m_lastHealth) + blit(heartX, heartY, 79, 0, 9, 9, 0, 0); + } + + if (healthNo < playerHealth) + blit(heartX, heartY, 52, 0, 9, 9, 0, 0); + else if (healthNo == playerHealth) + blit(heartX, heartY, 61, 0, 9, 9, 0, 0); + + heartX += 8; + } +} + +void Gui::renderHunger(bool topLeft) +{ + +} + +void Gui::renderBubbles(bool topLeft) +{ + LocalPlayer* player = m_pMinecraft->m_pLocalPlayer; + + int cenX = m_width / 2; + + if (player->isUnderLiquid(Material::water)) + { + int breathRaw = player->m_airCapacity; + int breathFull = int(ceilf((float(breathRaw - 2) * 10.0f) / 300.0f)); + int breathMeter = int(ceilf((float(breathRaw) * 10.0f) / 300.0f)) - breathFull; + + int bubbleX; + int bubbleY; + + if (topLeft) + { + bubbleX = 2; + bubbleY = 12; + } + else if (m_bRenderHunger) + { + // @TODO + bubbleX = 2; + bubbleY = 12; + } + else + { + // Renders to the left of the hotbar, why? + /*bubbleX = cenX - 191; + bubbleY = m_height - 19;*/ + bubbleX = cenX - 91; + bubbleY = m_height - 41; + } + + //@NOTE: Not sure this works as it should + + for (int bubbleNo = 0; bubbleNo < breathFull + breathMeter; bubbleNo++) + { + if (bubbleNo < breathFull) + blit(bubbleX, bubbleY, 16, 18, 9, 9, 0, 0); + else + blit(bubbleX, bubbleY, 25, 18, 9, 9, 0, 0); + + bubbleX += 8; + } + } +} + +void Gui::renderProgressIndicator(int width, int height) +{ + Minecraft& mc = *m_pMinecraft; + Textures& textures = *mc.m_pTextures; + + currentShaderColor = Color::WHITE; + currentShaderDarkColor = Color::WHITE; + + if (m_pMinecraft->useSplitControls()) + { + // draw crosshair + textures.loadAndBindTexture("gui/icons.png"); + blit(width / 2 - 8, height / 2 - 8, 0, 0, 16, 16, 0, 0, &m_guiMaterials.ui_crosshair); + } + else + { + IInputHolder& input = *mc.m_pInputHolder; + // if needed, draw feedback + + // NOTE: real Minecraft PE takes it directly from the gamemode as "current progress" and + // "last progress". Well guess what? The game mode in question updates our m_fSensitivity with + // the pre-interpolated break progress! Isn't that awesome?! + float breakProgress = m_progress; + + // don't know about this if-structure, it feels like it'd be like + // if (m_bFoggy >= 0.0f && breakProgress <= 0.0f) + // that; + // else + // this; + if (breakProgress > 0.0f || input.m_feedbackAlpha < 0.0f) + { + if (breakProgress > 0.0f) + { + float xPos = input.m_feedbackX; + float yPos = input.m_feedbackY; + + textures.loadAndBindTexture("gui/feedback_outer.png"); + currentShaderColor = Color::WHITE; + blit(InvGuiScale * xPos - 44.0f, InvGuiScale * yPos - 44.0f, 0, 0, 88, 88, 256, 256, &m_guiMaterials.ui_overlay_textured); + + textures.loadAndBindTexture("gui/feedback_fill.png"); - glDisable(GL_BLEND); + // note: scale starts from 4.0f + float halfWidth = (40.0f * breakProgress + 48.0f) / 2.0f; + + blit(InvGuiScale * xPos - halfWidth, InvGuiScale * yPos - halfWidth, 0, 0, halfWidth * 2, halfWidth * 2, 256, 256, &m_guiMaterials.ui_invert_overlay_textured); + } + } + else + { + float xPos = input.m_feedbackX; + float yPos = input.m_feedbackY; + + textures.loadAndBindTexture("gui/feedback_outer.png"); + currentShaderColor = Color(1.0f, 1.0f, 1.0f, Mth::Min(1.0f, input.m_feedbackAlpha)); + blit(InvGuiScale * xPos - 44.0f, InvGuiScale * yPos - 44.0f, 0, 0, 88, 88, 256, 256, &m_guiMaterials.ui_overlay_textured); + } + } +} + +void Gui::renderExperience() +{ + +} + +void Gui::renderToolBar(float f, float alpha) +{ + Minecraft* mc = m_pMinecraft; + Textures* textures = mc->m_pTextures; + LocalPlayer* player = mc->m_pLocalPlayer; + + currentShaderColor.a = alpha; + + textures->loadAndBindTexture("gui/gui.png"); + + m_blitOffset = -90.0f; + + // chat + //blit(width - 18, 0, 200, 82, 18, 18, 18, 18); + + int nSlots = getNumSlots(); + int hotbarWidth = 2 + nSlots * 20; + + mce::MaterialPtr* material = &m_materials.ui_textured_and_glcolor; + + // hotbar + int cenX = m_width / 2; + blit(cenX - hotbarWidth / 2, m_height - 22, 0, 0, hotbarWidth - 2, 22, 0, 0, material); + blit(cenX + hotbarWidth / 2 - 2, m_height - 22, 180, 0, 2, 22, 0, 0, material); + + Inventory* inventory = player->m_pInventory; + + // selection mark + blit(cenX - 1 - hotbarWidth / 2 + 20 * inventory->m_selectedHotbarSlot, m_height - 23, 0, 22, 24, 22, 0, 0, material); + + textures->loadAndBindTexture(C_BLOCKS_NAME); + + int diff = mc->isTouchscreen(); + + int slotX = cenX - hotbarWidth / 2 + 3; + for (int i = 0; i < nSlots - diff; i++) + { + renderSlot(i, slotX, m_height - 19, f); + + slotX += 20; + } + + slotX = cenX - hotbarWidth / 2 + 3; + for (int i = 0; i < nSlots - diff; i++) + { + renderSlotOverlay(i, slotX, m_height - 19, f); + + slotX += 20; + } + +#undef DIFF + + field_A3C = false; + + // blit the "more items" button + if (mc->isTouchscreen()) + { + textures->loadAndBindTexture(C_TERRAIN_NAME); + blit(cenX + hotbarWidth / 2 - 19, m_height - 19, 208, 208, 16, 16, 0, 0, material); + } } int Gui::getNumSlots() diff --git a/source/client/gui/Gui.hpp b/source/client/gui/Gui.hpp index 76ebfdb73..2108fbb6f 100644 --- a/source/client/gui/Gui.hpp +++ b/source/client/gui/Gui.hpp @@ -9,9 +9,10 @@ #pragma once #include "GuiComponent.hpp" +#include "common/Random.hpp" #include "client/player/input/RectangleArea.hpp" #include "client/app/Minecraft.hpp" -#include "common/Random.hpp" +#include "client/renderer/RenderChunk.hpp" class Minecraft; // in case we're included from Minecraft.hpp @@ -25,6 +26,20 @@ struct GuiMessage class Gui : public GuiComponent { +protected: + class Materials + { + public: + mce::MaterialPtr ui_vignette; + mce::MaterialPtr ui_overlay; + mce::MaterialPtr ui_invert_overlay; + mce::MaterialPtr ui_overlay_textured; + mce::MaterialPtr ui_invert_overlay_textured; + mce::MaterialPtr ui_crosshair; + + Materials(); + }; + private: static bool _isVignetteAvailable; public: @@ -38,6 +53,10 @@ class Gui : public GuiComponent public: Gui(Minecraft* pMinecraft); +private: + void _updateHudPositions(); + +public: void addMessage(const std::string& str); void inventoryUpdated(); void setNowPlaying(const std::string& str); @@ -51,6 +70,12 @@ class Gui : public GuiComponent void handleScroll(bool down); void handleKeyPressed(int keyCode); void renderMessages(bool bShowAll); + void renderHearts(bool topLeft); + void renderHunger(bool topLeft); + void renderBubbles(bool topLeft); + void renderProgressIndicator(int width, int height); + void renderExperience(); + void renderToolBar(float f, float alpha); int getNumSlots(); // Gets the number of slots in the inventory. Includes the '...' if in touch mode. int getNumUsableSlots(); // Gets the number of usable slots in the inventory. Does not include the '...' if in touch mode. RectangleArea getRectangleArea(bool b); @@ -58,8 +83,11 @@ class Gui : public GuiComponent public: static float InvGuiScale; +protected: + Materials m_guiMaterials; + public: - float field_8; + float m_progress; std::string field_C; std::vector m_guiMessages; int field_24; @@ -75,5 +103,8 @@ class Gui : public GuiComponent RenderChunk m_renderChunk; bool field_A3C; bool m_bRenderMessages; + bool m_bRenderHunger; + int m_width; + int m_height; }; diff --git a/source/client/gui/GuiComponent.cpp b/source/client/gui/GuiComponent.cpp index d83a4bf67..2e892f5b7 100644 --- a/source/client/gui/GuiComponent.cpp +++ b/source/client/gui/GuiComponent.cpp @@ -1,92 +1 @@ -/******************************************************************** - Minecraft: Pocket Edition - Decompilation Project - Copyright (C) 2023 iProgramInCpp - - The following code is licensed under the BSD 1 clause license. - SPDX-License-Identifier: BSD-1-Clause - ********************************************************************/ - #include "GuiComponent.hpp" - -#ifdef _WIN32 -#pragma warning (disable : 4244) -#endif - -GuiComponent::GuiComponent() : field_4 (0) -{ -} - -void GuiComponent::blit(int dx, int dy, int sx, int sy, int tw, int th, int sw, int sh) -{ - Tesselator& t = Tesselator::instance; - - if (!sh) sh = th; - if (!sw) sw = tw; - - t.begin(); - t.vertexUV(dx, dy + th, field_4, float(sx) / 256.0f, float(sy + sh) / 256.0f); - t.vertexUV(dx + tw, dy + th, field_4, float(sx + sw) / 256.0f, float(sy + sh) / 256.0f); - t.vertexUV(dx + tw, dy, field_4, float(sx + sw) / 256.0f, float(sy) / 256.0f); - t.vertexUV(dx, dy, field_4, float(sx) / 256.0f, float(sy) / 256.0f); - t.draw(); -} - -void GuiComponent::drawCenteredString(Font* pFont, const std::string& str, int cx, int cy, int color) -{ - int width = pFont->width(str); - int height = pFont->height(str); - pFont->drawShadow(str, cx - width / 2, cy - height / 2, color); -} - -void GuiComponent::drawString(Font* pFont, const std::string& str, int cx, int cy, int color) -{ - pFont->drawShadow(str, cx, cy, color); -} - -void GuiComponent::fill(int a2, int a3, int a4, int a5, int a6) -{ - glEnable(GL_BLEND); - glDisable(GL_TEXTURE_2D); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor4f(float(GET_RED(a6)) / 255.0f, float(GET_GREEN(a6)) / 255.0f, float(GET_BLUE(a6)) / 255.0f, float(GET_ALPHA(a6)) / 255.0f); - - Tesselator& t = Tesselator::instance; - t.begin(); - - t.vertex(a2, a5, 0.0f); - t.vertex(a4, a5, 0.0f); - t.vertex(a4, a3, 0.0f); - t.vertex(a2, a3, 0.0f); - - t.draw(); - - glEnable(GL_TEXTURE_2D); - glDisable(GL_BLEND); -} - -void GuiComponent::fillGradient(int a2, int a3, int a4, int a5, int a6, int a7) -{ - glDisable(GL_TEXTURE_2D); - glEnable(GL_BLEND); - glDisable(GL_ALPHA_TEST); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glShadeModel(GL_SMOOTH); - - Tesselator& t = Tesselator::instance; - t.begin(); - - // note: for some stupid reason OG uses the float overload. - t.color(float(GET_RED(a6)) / 255.0f, float(GET_GREEN(a6)) / 255.0f, float(GET_BLUE(a6)) / 255.0f, float(GET_ALPHA(a6)) / 255.0f); - t.vertex(a2, a5, 0.0f); - t.vertex(a4, a5, 0.0f); - t.color(float(GET_RED(a7)) / 255.0f, float(GET_GREEN(a7)) / 255.0f, float(GET_BLUE(a7)) / 255.0f, float(GET_ALPHA(a7)) / 255.0f); - t.vertex(a4, a3, 0.0f); - t.vertex(a2, a3, 0.0f); - - t.draw(); - - glShadeModel(GL_FLAT); - glDisable(GL_BLEND); - glEnable(GL_ALPHA_TEST); - glEnable(GL_TEXTURE_2D); -} diff --git a/source/client/gui/GuiComponent.hpp b/source/client/gui/GuiComponent.hpp index 1263089b0..4ad672635 100644 --- a/source/client/gui/GuiComponent.hpp +++ b/source/client/gui/GuiComponent.hpp @@ -8,24 +8,12 @@ #pragma once -#include "client/renderer/Tesselator.hpp" -#include "client/renderer/Font.hpp" +#include "client/renderer/ScreenRenderer.hpp" -// @TODO: GuiElement (virtuals) inheriting GuiComponent -class GuiComponent +class GuiComponent : public ScreenRenderer { public: - GuiComponent(); virtual ~GuiComponent() {} - - void blit(int dstX, int dstY, int srcX, int srcY, int dstWidth, int dstHeight, int srcWidth, int srcHeight); - void drawCenteredString(Font*, const std::string&, int cx, int cy, int color); - void drawString(Font*, const std::string&, int cx, int cy, int color); - void fill(int left, int top, int right, int bottom, int color); - void fillGradient(int left, int top, int right, int bottom, int colorUp, int colorDown); - -public: - float field_4; }; diff --git a/source/client/gui/GuiElement.cpp b/source/client/gui/GuiElement.cpp new file mode 100644 index 000000000..0571e33dc --- /dev/null +++ b/source/client/gui/GuiElement.cpp @@ -0,0 +1,9 @@ +#include "GuiElement.hpp" + +GuiElement::GuiElement() +{ +} + +void GuiElement::setupPositions() +{ +} \ No newline at end of file diff --git a/source/client/gui/GuiElement.hpp b/source/client/gui/GuiElement.hpp new file mode 100644 index 000000000..a991533f4 --- /dev/null +++ b/source/client/gui/GuiElement.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include "GuiComponent.hpp" + +class GuiElement : public GuiComponent +{ +public: + GuiElement(); + +public: + virtual void setupPositions(); +}; + diff --git a/source/client/gui/IntRectangle.hpp b/source/client/gui/IntRectangle.hpp new file mode 100644 index 000000000..c20d52a84 --- /dev/null +++ b/source/client/gui/IntRectangle.hpp @@ -0,0 +1,17 @@ +#pragma once + +struct IntRectangle +{ + int x; + int y; + int w; + int h; + + IntRectangle() + { + x = 0; + y = 0; + w = 1; + h = 1; + } +}; \ No newline at end of file diff --git a/source/client/gui/Screen.cpp b/source/client/gui/Screen.cpp index 09b7a6e21..7f7f184f9 100644 --- a/source/client/gui/Screen.cpp +++ b/source/client/gui/Screen.cpp @@ -7,6 +7,16 @@ ********************************************************************/ #include "Screen.hpp" +#include "client/renderer/renderer/RenderMaterialGroup.hpp" +#include "renderer/ShaderConstants.hpp" +#include "renderer/RenderContextImmediate.hpp" +#include "renderer/hal/interface/RasterizerState.hpp" + +Screen::Materials::Materials() +{ + MATERIAL_PTR(common, ui_cubemap); + MATERIAL_PTR(common, ui_background); +} bool Screen::_isPanoramaAvailable = false; @@ -127,87 +137,72 @@ void Screen::renderMenuBackground(float f) aspectRatio = 1.0f; //aspectRatio = float(m_width) / float(m_height); - // not in 0.8 - glDisable(GL_BLEND); - glDisable(GL_CULL_FACE); - glDisable(GL_DEPTH_TEST); - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - gluPerspective(120.0f, aspectRatio, 0.05f, 10.0f); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glRotatef(180.0f, 1.0f, 0.0f, 0.0f); - glRotatef(Mth::sin((f + g_panoramaAngle) / 400.0f) * 25.0f + 20.0f, 1.0f, 0.0f, 0.0f); - glRotatef(-0.1f * (f + g_panoramaAngle), 0.0f, 1.0f, 0.0f); - - for (int i = 0; i < 6; i++) + // @HAL: this should be using ui_cubemap, but for whatever reason we need to disable culling + mce::MaterialPtr& materialPtr = m_screenMaterials.ui_background; + { - glPushMatrix(); + MatrixStack::Ref projMtx = MatrixStack::Projection.pushIdentity(); + projMtx->setPerspective(120.0f, aspectRatio, 0.05f, 10.0f); + + MatrixStack::Ref viewMtx = MatrixStack::View.pushIdentity(); + MatrixStack::Ref worldMtx = MatrixStack::World.push(); + currentShaderColor = Color::WHITE; + worldMtx->rotate(180.0f, Vec3::UNIT_X); + worldMtx->rotate(Mth::sin((f + g_panoramaAngle) / 400.0f) * 25.0f + 20.0f, Vec3::UNIT_X); + worldMtx->rotate(-0.1f * (f + g_panoramaAngle), Vec3::UNIT_Y); - float xm = 0.0f, ym = 0.0f, ang = 0.0f; - switch (i) + for (int i = 0; i < 6; i++) { + MatrixStack::Ref mtx = MatrixStack::World.push(); + + float ang = 0.0f; + Vec2 axis; + switch (i) + { case 1: ang = 90.0f; - xm = 0.0f; - ym = 1.0f; + axis = Vec2::UNIT_Y; break; case 2: ang = 180.0f; - xm = 0.0f; - ym = 1.0f; + axis = Vec2::UNIT_Y; break; case 3: ang = -90.0f; - xm = 0.0f; - ym = 1.0f; + axis = Vec2::UNIT_Y; break; case 4: ang = 90.0f; - ym = 0.0f; - xm = 1.0f; + axis = Vec2::UNIT_X; break; case 5: ang = -90.0f; - ym = 0.0f; - xm = 1.0f; + axis = Vec2::UNIT_X; break; default: goto skip_rotate; - } - - glRotatef(ang, xm, ym, 0.0f); - - skip_rotate: - m_pMinecraft->m_pTextures->setSmoothing(true); - m_pMinecraft->m_pTextures->setClampToEdge(true); - m_pMinecraft->m_pTextures->loadAndBindTexture(std::string(g_panoramaList[i])); - m_pMinecraft->m_pTextures->setSmoothing(false); - m_pMinecraft->m_pTextures->setClampToEdge(false); - - Tesselator& t = Tesselator::instance; - t.begin(); - t.vertexUV(-1.0f, -1.0f, 1.0f, 0.0f, 0.0f); - t.vertexUV(+1.0f, -1.0f, 1.0f, 1.0f, 0.0f); - t.vertexUV(+1.0f, +1.0f, 1.0f, 1.0f, 1.0f); - t.vertexUV(-1.0f, +1.0f, 1.0f, 0.0f, 1.0f); - t.draw(); + } - glPopMatrix(); + mtx->rotate(ang, Vec3(axis.x, axis.y, 0.0f)); + + skip_rotate: + m_pMinecraft->m_pTextures->setSmoothing(true); + m_pMinecraft->m_pTextures->setClampToEdge(true); + m_pMinecraft->m_pTextures->loadAndBindTexture(std::string(g_panoramaList[i])); + m_pMinecraft->m_pTextures->setSmoothing(false); + m_pMinecraft->m_pTextures->setClampToEdge(false); + + Tesselator& t = Tesselator::instance; + t.begin(4); + t.vertexUV(-1.0f, -1.0f, 1.0f, 0.0f, 0.0f); + t.vertexUV(+1.0f, -1.0f, 1.0f, 1.0f, 0.0f); + t.vertexUV(+1.0f, +1.0f, 1.0f, 1.0f, 1.0f); + t.vertexUV(-1.0f, +1.0f, 1.0f, 0.0f, 1.0f); + t.draw(materialPtr); + } } - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - glEnable(GL_BLEND); - glEnable(GL_CULL_FACE); - glEnable(GL_DEPTH_TEST); - - fillGradient(0, 0, m_width, m_height, 0x89000000, 0x89FFFFFF); + fillGradient(0, 0, m_width, m_height, Color(0, 0, 0, 137), Color(255, 255, 255, 137)); } void Screen::mouseClicked(int xPos, int yPos, int d) // d = clicked? @@ -323,16 +318,17 @@ void Screen::setSize(int width, int height) void Screen::onRender(int mouseX, int mouseY, float f) { m_yOffset = getYOffset(); - if (m_yOffset != 0) { + + MatrixStack::Ref matrix; + + if (m_yOffset != 0) + { // push the entire screen up - glPushMatrix(); - glTranslatef(0.0f, -float(m_yOffset), 0.0f); + matrix = MatrixStack::World.push(); + matrix->translate(Vec3(0.0f, -m_yOffset, 0.0f)); } render(mouseX, mouseY, f); - - if (m_yOffset != 0) - glPopMatrix(); } int Screen::getYOffset() @@ -408,17 +404,17 @@ void Screen::mouseEvent() handleScroll(Mouse::getEventButtonState()); } -void Screen::renderBackground(int unk) +void Screen::renderBackground(int vo) { if (m_pMinecraft->isLevelGenerated()) { // draw the background offset by the Y offset so that the smaller virtual // keyboards don't reveal undrawn areas - fillGradient(0, m_yOffset, m_width, m_height, 0xC0101010, 0xD0101010); + fillGradient(0, m_yOffset, m_width, m_height, Color(16, 16, 16, 192), Color(16, 16, 16, 208)); // 0xC0101010, 0xD0101010 } else { - renderDirtBackground(unk); + renderDirtBackground(vo); } } @@ -427,23 +423,21 @@ void Screen::renderBackground() renderBackground(0); } -void Screen::renderDirtBackground(int unk) +void Screen::renderDirtBackground(int vo) { - glDisable(GL_FOG); - m_pMinecraft->m_pTextures->loadAndBindTexture("gui/background.png"); - glColor4f(1, 1, 1, 1); + currentShaderColor = Color::WHITE; Tesselator& t = Tesselator::instance; - t.begin(); - t.offset(0, m_yOffset, 0); + t.begin(4); + //t.setOffset(0, m_yOffset, 0); t.color(0x404040); - t.vertexUV(0.0f, float(m_height), 0, 0, float(unk) + float(m_height) / 32.0f); - t.vertexUV(float(m_width), float(m_height), 0, float(m_width) / 32.0f, float(unk) + float(m_height) / 32.0f); - t.vertexUV(float(m_width), 0, 0, float(m_width) / 32.0f, float(unk) + 0.0f); - t.vertexUV(0.0f, 0, 0, 0, float(unk) + 0.0f); - t.offset(0, 0, 0); - t.draw(); + t.vertexUV(0.0f, float(m_height), 0, 0, float(vo) + float(m_height) / 32.0f); + t.vertexUV(float(m_width), float(m_height), 0, float(m_width) / 32.0f, float(vo) + float(m_height) / 32.0f); + t.vertexUV(float(m_width), 0, 0, float(m_width) / 32.0f, float(vo) + 0.0f); + t.vertexUV(0.0f, 0, 0, 0, float(vo) + 0.0f); + //t.setOffset(0, 0, 0); + t.draw(m_materials.ui_texture_and_color); } @@ -453,7 +447,7 @@ void Screen::updateTabButtonSelection() { for (int i = 0; i < int(m_buttonTabList.size()); i++) { - m_buttonTabList[i]->field_36 = m_tabButtonIndex == i; + m_buttonTabList[i]->m_bHovered = m_tabButtonIndex == i; } } } diff --git a/source/client/gui/Screen.hpp b/source/client/gui/Screen.hpp index eff282454..5a2abbfa4 100644 --- a/source/client/gui/Screen.hpp +++ b/source/client/gui/Screen.hpp @@ -8,6 +8,7 @@ #pragma once +#include "renderer/MaterialPtr.hpp" #include "client/player/input/Mouse.hpp" #include "client/player/input/Keyboard.hpp" #include "components/Button.hpp" @@ -18,6 +19,16 @@ class TextInputBox; class Screen : public GuiComponent { +protected: + class Materials + { + public: + mce::MaterialPtr ui_cubemap; + mce::MaterialPtr ui_background; + + Materials(); + }; + private: static bool _isPanoramaAvailable; public: @@ -49,9 +60,9 @@ class Screen : public GuiComponent virtual bool handleBackEvent(bool b) { return false; } virtual void tick(); virtual void removed() {}; - virtual void renderBackground(int); + virtual void renderBackground(int vo); virtual void renderBackground(); - virtual void renderDirtBackground(int); + virtual void renderDirtBackground(int vo); virtual bool isPauseScreen() { return true; } virtual bool isErrorScreen() { return false; } virtual bool isInGameScreen() { return true; } @@ -83,5 +94,8 @@ class Screen : public GuiComponent std::vector m_textInputs; int m_yOffset; #endif + +protected: + Materials m_screenMaterials; }; diff --git a/source/client/gui/components/AvailableGamesList.cpp b/source/client/gui/components/AvailableGamesList.cpp index 8d335a5a5..3dc2339c0 100644 --- a/source/client/gui/components/AvailableGamesList.cpp +++ b/source/client/gui/components/AvailableGamesList.cpp @@ -29,8 +29,8 @@ void AvailableGamesList::renderBackground(float f) void AvailableGamesList::renderItem(int idx, int x, int y, int width, Tesselator& t) { - drawString(m_pMinecraft->m_pFont, std::string(m_games[idx].m_name.C_String()), x, y + 2, 0xFFFFA0); - drawString(m_pMinecraft->m_pFont, std::string(m_games[idx].m_address.ToString()), x, y + 16, 0xFFFFA0); + drawString(*m_pMinecraft->m_pFont, std::string(m_games[idx].m_name.C_String()), x, y + 2, 0xFFFFA0); + drawString(*m_pMinecraft->m_pFont, std::string(m_games[idx].m_address.ToString()), x, y + 16, 0xFFFFA0); } void AvailableGamesList::selectItem(int index, bool b) diff --git a/source/client/gui/components/Button.cpp b/source/client/gui/components/Button.cpp index 07d743a33..9dd1629fc 100644 --- a/source/client/gui/components/Button.cpp +++ b/source/client/gui/components/Button.cpp @@ -7,6 +7,7 @@ ********************************************************************/ #include "Button.hpp" +#include "renderer/ShaderConstants.hpp" void Button::_init() { @@ -17,7 +18,7 @@ void Button::_init() m_text = ""; m_bEnabled = true; m_bVisible = true; - field_36 = false; + m_bHovered = false; #ifndef ORIGINAL_CODE m_lastX = 0; @@ -92,28 +93,28 @@ void Button::render(Minecraft* pMinecraft, int xPos, int yPos) if (!m_bVisible) return; if (!pMinecraft->useController()) - field_36 = clicked(pMinecraft, xPos, yPos); + m_bHovered = clicked(pMinecraft, xPos, yPos); - Font* pFont = pMinecraft->m_pFont; - Textures* pTexs = pMinecraft->m_pTextures; + Font& font = *pMinecraft->m_pFont; + Textures& texs = *pMinecraft->m_pTextures; - pTexs->loadAndBindTexture("gui/gui.png"); + texs.loadAndBindTexture("gui/gui.png"); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - int iYPos = 20 * getYImage(field_36) + 46; + currentShaderColor = Color::WHITE; + int iYPos = 20 * getYImage(m_bHovered) + 46; blit(m_xPos, m_yPos, 0, iYPos, m_width / 2, m_height, 0, 20); blit(m_xPos + m_width / 2, m_yPos, 200 - m_width / 2, iYPos, m_width / 2, m_height, 0, 20); renderBg(pMinecraft, xPos, yPos); - int textColor; + Color textColor; if (!m_bEnabled) - textColor = int(0xFFA0A0A0U); - else if (field_36) - textColor = int(0xFFFFA0U); + textColor = Color(160, 160, 160); // 0xFFA0A0A0 + else if (m_bHovered) + textColor = Color(255, 255, 160); // 0xFFFFA0U else - textColor = int(0xE0E0E0U); + textColor = Color(224, 224, 224); // 0xE0E0E0U - drawCenteredString(pFont, m_text, m_xPos + m_width / 2, m_yPos + (m_height - 8) / 2, textColor); + drawCenteredString(font, m_text, m_xPos + m_width / 2, m_yPos + (m_height - 8) / 2, textColor); } diff --git a/source/client/gui/components/Button.hpp b/source/client/gui/components/Button.hpp index b5b8a127a..7ba5fdfa2 100644 --- a/source/client/gui/components/Button.hpp +++ b/source/client/gui/components/Button.hpp @@ -38,7 +38,7 @@ class Button : public GuiComponent int m_buttonId; bool m_bEnabled; bool m_bVisible; - bool field_36; + bool m_bHovered; #ifndef ORIGINAL_CODE int m_lastX; diff --git a/source/client/gui/components/OptionList.cpp b/source/client/gui/components/OptionList.cpp index d2e283ba7..5916bd0c2 100644 --- a/source/client/gui/components/OptionList.cpp +++ b/source/client/gui/components/OptionList.cpp @@ -46,7 +46,7 @@ void BooleanOptionItem::onClick(OptionList* pList, int mouseX, int mouseY) void BooleanOptionItem::render(OptionList* pList, int x, int y) { pList->drawString( - pList->m_pMinecraft->m_pFont, + *pList->m_pMinecraft->m_pFont, m_text, x + 22, y + (C_OPTION_ITEM_HEIGHT - 8) / 2 - 2, @@ -88,6 +88,18 @@ void AORenderOptionItem::toggleState(OptionList* pList) pList->m_pMinecraft->m_pLevelRenderer->allChanged(); } + +FancyRenderOptionItem::FancyRenderOptionItem(bool* pValue, const std::string& text) : + RenderOptionItem(pValue, text) +{ +} + +void FancyRenderOptionItem::toggleState(OptionList* pList) +{ + BooleanOptionItem::toggleState(pList); + pList->m_pMinecraft->reloadFancy(*m_pValue); +} + HeaderOptionItem::HeaderOptionItem(const std::string& text) { m_text = text; @@ -96,11 +108,11 @@ HeaderOptionItem::HeaderOptionItem(const std::string& text) void HeaderOptionItem::render(OptionList* pList, int x, int y) { pList->drawString( - pList->m_pMinecraft->m_pFont, + *pList->m_pMinecraft->m_pFont, m_text, x + 2, y + (C_OPTION_ITEM_HEIGHT - 8) / 2 - 2, - 0xFFFFFF); + Color::WHITE); } DistanceOptionItem::DistanceOptionItem(int* pValue, const std::string& text) @@ -129,11 +141,11 @@ void DistanceOptionItem::onClick(OptionList* pList, int mouseX, int mouseY) void DistanceOptionItem::render(OptionList* pList, int x, int y) { pList->drawString( - pList->m_pMinecraft->m_pFont, + *pList->m_pMinecraft->m_pFont, m_text, x + 22, y + (C_OPTION_ITEM_HEIGHT - 8) / 2 - 2, - 0xCCCCCC); + Color(204, 204, 204)); const char* distanceText = "???"; switch (*m_pValue) @@ -152,7 +164,7 @@ void DistanceOptionItem::render(OptionList* pList, int x, int y) pList->fill(x + 0, y + 0, x + C_DISTANCE_SWITCH_WIDTH - 0, y + C_DISTANCE_SWITCH_HEIGHT - 0, 0xFF444444); pList->fill(x + 1, y + 1, x + C_DISTANCE_SWITCH_WIDTH - 1, y + C_DISTANCE_SWITCH_HEIGHT - 1, 0xFF111111); pList->drawCenteredString( - pList->m_pMinecraft->m_pFont, + *pList->m_pMinecraft->m_pFont, distanceTextStr, x + C_DISTANCE_SWITCH_WIDTH / 2, y + (C_DISTANCE_SWITCH_HEIGHT - 8) / 2, @@ -220,40 +232,26 @@ void OptionList::renderBackground(float f) void OptionList::renderHoleBackground(float a, float b, int c, int d) { - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glDisable(GL_TEXTURE_2D); - Tesselator& t = Tesselator::instance; - t.begin(); + t.begin(4); t.color(0x202020, 0xC0); t.vertexUV(0.0f, b, 0.0f, 0.0f, b / 32.0f); t.vertexUV(float(field_18), b, 0.0f, field_18 / 32.0f, b / 32.0f); t.vertexUV(float(field_18), a, 0.0f, field_18 / 32.0f, a / 32.0f); t.vertexUV(0.0f, a, 0.0f, 0.0f, a / 32.0f); - t.draw(); - - glEnable(GL_TEXTURE_2D); - glDisable(GL_BLEND); + t.draw(m_materials.ui_fill_color); } void OptionList::renderScrollBackground() { - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glDisable(GL_TEXTURE_2D); - Tesselator& t = Tesselator::instance; - t.begin(); + t.begin(4); t.color(0x202020, 0x90); t.vertexUV(field_24, field_10, 0.0f, field_24 / 32.0f, (field_10 + float(int(field_34))) / 32.0f); t.vertexUV(field_20, field_10, 0.0f, field_20 / 32.0f, (field_10 + float(int(field_34))) / 32.0f); t.vertexUV(field_20, field_C, 0.0f, field_20 / 32.0f, (field_C + float(int(field_34))) / 32.0f); t.vertexUV(field_24, field_C, 0.0f, field_24 / 32.0f, (field_C + float(int(field_34))) / 32.0f); - t.draw(); - - glEnable(GL_TEXTURE_2D); - glDisable(GL_BLEND); + t.draw(m_materials.ui_fill_color); } void OptionList::onClickItem(int index, int mouseX, int mouseY) @@ -295,7 +293,7 @@ void OptionList::initDefaultMenu() OPTION(Distance, m_iViewDistance, "Render Distance"); OPTION(Boolean, m_bThirdPerson, "Third Person View"); OPTION(AORender, m_bAmbientOcclusion, "Smooth Lighting"); - OPTION(Render, m_bFancyGraphics, "Fancy Graphics"); + OPTION(FancyRender, m_bFancyGraphics, "Fancy Graphics"); OPTION(Boolean, m_bViewBobbing, "View Bobbing"); OPTION(Boolean, m_bAnaglyphs, "3D Anaglyph"); OPTION(Boolean, m_bBlockOutlines, "Block Outlines"); diff --git a/source/client/gui/components/OptionList.hpp b/source/client/gui/components/OptionList.hpp index 0874c3f9a..133ecea98 100644 --- a/source/client/gui/components/OptionList.hpp +++ b/source/client/gui/components/OptionList.hpp @@ -37,6 +37,7 @@ class BooleanOptionItem : public OptionItem protected: friend class AORenderOptionItem; + friend class FancyRenderOptionItem; std::string m_text; bool* m_pValue; // Reference to the value to be modified by this item @@ -79,6 +80,13 @@ class AORenderOptionItem : public RenderOptionItem void toggleState(OptionList*) override; }; +class FancyRenderOptionItem : public RenderOptionItem +{ +public: + FancyRenderOptionItem(bool* pValue, const std::string& text); + void toggleState(OptionList*) override; +}; + class HeaderOptionItem : public OptionItem { public: diff --git a/source/client/gui/components/RolledSelectionList.cpp b/source/client/gui/components/RolledSelectionList.cpp index 96bc3e3d6..34e5fbc30 100644 --- a/source/client/gui/components/RolledSelectionList.cpp +++ b/source/client/gui/components/RolledSelectionList.cpp @@ -7,6 +7,7 @@ ********************************************************************/ #include "RolledSelectionList.hpp" +#include "renderer/RenderContextImmediate.hpp" static float g_RolledSelectionListUnk, g_RolledSelectionListUnk2; @@ -92,91 +93,18 @@ void RolledSelectionList::tick() void RolledSelectionList::render(int mouseX, int mouseY, float f) { + mce::RenderContext& renderContext = mce::RenderContextImmediate::get(); + renderBackground(); int nItems = getNumberOfItems(); + Tesselator& t = Tesselator::instance; - // @TODO: fix gotos. - if (!Mouse::isButtonDown(BUTTON_LEFT)) - { - if (field_28 < 0) - { - _crap: - field_28 = -1; - field_30 = getPos(f); - goto _done; - } - - if (g_RolledSelectionListUnk2 < 0.0f) - field_38 = Mth::Max(-20.0f, g_RolledSelectionListUnk2); - else - field_38 = Mth::Min(20.0f, g_RolledSelectionListUnk2); - - if (fabsf(field_38) < 2.0f) - { - field_38 = 0.0f; - - _continue: - if (getTimeMs() - field_4C < 300) - { - int idx = transformX(mouseX) / m_itemWidth; - if (idx >= 0) - { - if (field_50 == idx && abs(field_3C - mouseX) <= 9) - selectItem(field_50, 0); - } - goto _crap; - } - goto _crap; - } - - if (fabsf(field_38) > 10.0f) - { - goto _crap; - } - - goto _continue; - } - else - { - touched(); - - if (float(mouseY) >= field_20 && float(mouseY) <= field_24) - { - if (field_28 == -1) - { - field_4C = getTimeMs(); - field_3C = mouseX; - field_50 = getItemAtPosition(mouseX, field_1C / 2); - } - else if (field_28 >= 0) - { - field_34 = field_30 = field_30 - (float(mouseX) - field_2C); - } - - field_28 = 0; - } - } - -_done: - field_2C = float(mouseX); - - capXPosition(); - - glDisable(GL_LIGHTING); - glDisable(GL_FOG); + checkInput(mouseX, mouseY, f); m_pMinecraft->m_pTextures->loadAndBindTexture("gui/background.png"); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - Tesselator& t = Tesselator::instance; - t.begin(); - t.color(0x202020); - t.vertexUV(field_C, field_24, 0.0f, (field_C + float(int(field_30))) / 32.0f, field_24 / 32.0f); - t.vertexUV(field_10, field_24, 0.0f, (field_10 + float(int(field_30))) / 32.0f, field_24 / 32.0f); - t.vertexUV(field_10, field_20, 0.0f, (field_10 + float(int(field_30))) / 32.0f, field_20 / 32.0f); - t.vertexUV(field_C, field_20, 0.0f, (field_C + float(int(field_30))) / 32.0f, field_20 / 32.0f); - t.draw(); + renderScrollBackground(); if (!getNumberOfItems()) field_30 = 0.0f; @@ -194,10 +122,7 @@ void RolledSelectionList::render(int mouseX, int mouseY, float f) if (m_bRenderSelection && isSelectedItem(i)) { - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glDisable(GL_TEXTURE_2D); - - t.begin(); + t.begin(8); t.color(m_bComponentSelected ? 0x7F89BF : 0x808080); float right = itemX + width; @@ -213,88 +138,75 @@ void RolledSelectionList::render(int mouseX, int mouseY, float f) t.vertexUV(itemX - 1, dn - 1.0f, 0.0f, 1.0f, 0.0f); t.vertexUV(right + 1, dn - 1.0f, 0.0f, 1.0f, 1.0f); t.vertexUV(right + 1, up + 1.0f, 0.0f, 0.0f, 1.0f); - t.draw(); - - glEnable(GL_TEXTURE_2D); + t.draw(m_materials.ui_fill_color); } renderItem(i, int(itemX), field_1C / 2 - 40, int(width), t); } - glDisable(GL_DEPTH_TEST); - renderHoleBackground(0.0f, field_20, 255, 255); renderHoleBackground(field_24, float(field_1C), 255, 255); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glDisable(GL_ALPHA_TEST); - glShadeModel(GL_SMOOTH); - glDisable(GL_TEXTURE_2D); + renderContext.setShadeMode(mce::SHADE_MODE_SMOOTH); // @BUG: The X and Y coordinates have been swapped. This causes the gradient to not render // in the right place. #ifdef ORIGINAL_CODE - t.begin(); + t.begin(4); t.color(0, 0); t.vertexUV(m_culledEntities, m_rotX + 4.0f, 0.0f, 0.0f, 1.0f); t.vertexUV(field_24, m_rotX + 4.0f, 0.0f, 1.0f, 1.0f); t.color(0, 255); t.vertexUV(field_24, m_rotX, 0.0f, 1.0f, 0.0f); t.vertexUV(m_culledEntities, m_rotX, 0.0f, 0.0f, 0.0f); - t.draw(); + t.draw(m_materials.ui_fill_color); - t.begin(); + t.begin(4); t.color(0, 255); t.vertexUV(m_culledEntities, m_rotY, 0.0f, 0.0f, 1.0f); t.vertexUV(field_24, m_rotY, 0.0f, 1.0f, 1.0f); t.color(0, 0); t.vertexUV(field_24, m_rotY - 4.0f, 0.0f, 1.0f, 0.0f); t.vertexUV(m_culledEntities, m_rotY - 4.0f, 0.0f, 0.0f, 0.0f); - t.draw(); + t.draw(m_materials.ui_fill_color); #else - t.begin(); + t.begin(4); t.color(0, 0); t.vertexUV(field_C + 4.0f, field_20, 0.0f, 0.0f, 1.0f); t.vertexUV(field_C + 4.0f, field_24, 0.0f, 1.0f, 1.0f); t.color(0, 255); t.vertexUV(field_C, field_24, 0.0f, 1.0f, 0.0f); t.vertexUV(field_C, field_20, 0.0f, 0.0f, 0.0f); - t.draw(); + t.draw(m_materials.ui_fill_color); - t.begin(); + t.begin(4); t.color(0, 255); t.vertexUV(field_10, field_20, 0.0f, 0.0f, 1.0f); t.vertexUV(field_10, field_24, 0.0f, 1.0f, 1.0f); t.color(0, 0); t.vertexUV(field_10 - 4.0f, field_24, 0.0f, 1.0f, 0.0f); t.vertexUV(field_10 - 4.0f, field_20, 0.0f, 0.0f, 0.0f); - t.draw(); + t.draw(m_materials.ui_fill_color); #endif renderDecorations(mouseX, mouseY); - glEnable(GL_TEXTURE_2D); - glEnable(GL_DEPTH_TEST); - glShadeModel(GL_FLAT); - glEnable(GL_ALPHA_TEST); - glDisable(GL_BLEND); + renderContext.setShadeMode(mce::SHADE_MODE_FLAT); } void RolledSelectionList::renderHoleBackground(float y1, float y2, int a, int b) { m_pMinecraft->m_pTextures->loadAndBindTexture("gui/background.png"); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); Tesselator& t = Tesselator::instance; - t.begin(); + t.begin(4); t.color(0x505050, b); t.vertexUV(0.0f, y2, 0.0f, 0.0f, y2 / 32.0f); t.vertexUV(float(field_18), y2, 0.0f, float(field_18) / 32.0f, y2 / 32.0f); t.color(0x505050, a); t.vertexUV(float(field_18), y1, 0.0f, float(field_18) / 32.0f, y1 / 32.0f); t.vertexUV(0.0f, y1, 0.0f, 0.0f, y1 / 32.0f); - t.draw(); + t.draw(m_materials.ui_texture_and_color); } void RolledSelectionList::setRenderSelection(bool b) @@ -336,6 +248,88 @@ void RolledSelectionList::clickedHeader(int x, int y) } +void RolledSelectionList::checkInput(int mouseX, int mouseY, float f) +{ + // @TODO: fix gotos. + if (!Mouse::isButtonDown(BUTTON_LEFT)) + { + if (field_28 < 0) + { + _crap: + field_28 = -1; + field_30 = getPos(f); + goto _done; + } + + if (g_RolledSelectionListUnk2 < 0.0f) + field_38 = Mth::Max(-20.0f, g_RolledSelectionListUnk2); + else + field_38 = Mth::Min(20.0f, g_RolledSelectionListUnk2); + + if (fabsf(field_38) < 2.0f) + { + field_38 = 0.0f; + + _continue: + if (getTimeMs() - field_4C < 300) + { + int idx = transformX(mouseX) / m_itemWidth; + if (idx >= 0) + { + if (field_50 == idx && abs(field_3C - mouseX) <= 9) + selectItem(field_50, 0); + } + goto _crap; + } + goto _crap; + } + + if (fabsf(field_38) > 10.0f) + { + goto _crap; + } + + goto _continue; + } + else + { + touched(); + + if (float(mouseY) >= field_20 && float(mouseY) <= field_24) + { + if (field_28 == -1) + { + field_4C = getTimeMs(); + field_3C = mouseX; + field_50 = getItemAtPosition(mouseX, field_1C / 2); + } + else if (field_28 >= 0) + { + field_34 = field_30 = field_30 - (float(mouseX) - field_2C); + } + + field_28 = 0; + } + } + +_done: + field_2C = float(mouseX); + + capXPosition(); +} + +void RolledSelectionList::renderScrollBackground() +{ + Tesselator& t = Tesselator::instance; + t.begin(4); + t.color(0x202020); + t.vertexUV(field_C, field_24, 0.0f, (field_C + float(int(field_30))) / 32.0f, field_24 / 32.0f); + t.vertexUV(field_10, field_24, 0.0f, (field_10 + float(int(field_30))) / 32.0f, field_24 / 32.0f); + t.vertexUV(field_10, field_20, 0.0f, (field_10 + float(int(field_30))) / 32.0f, field_20 / 32.0f); + t.vertexUV(field_C, field_20, 0.0f, (field_C + float(int(field_30))) / 32.0f, field_20 / 32.0f); + t.draw(m_materials.ui_texture_and_color); +} + void RolledSelectionList::handleScroll(bool down) { float diff = 5.0f * (down ? -1.0f : 1.0f); diff --git a/source/client/gui/components/RolledSelectionList.hpp b/source/client/gui/components/RolledSelectionList.hpp index 031eb860a..e20f23814 100644 --- a/source/client/gui/components/RolledSelectionList.hpp +++ b/source/client/gui/components/RolledSelectionList.hpp @@ -34,6 +34,8 @@ class RolledSelectionList : public GuiComponent virtual void renderBackground() = 0; virtual void renderDecorations(int x, int y); virtual void clickedHeader(int, int); + virtual void checkInput(int mouseX, int mouseY, float f); + virtual void renderScrollBackground(); virtual void handleScroll(bool down); int getItemAtXPositionRaw(int x); diff --git a/source/client/gui/components/ScrolledSelectionList.cpp b/source/client/gui/components/ScrolledSelectionList.cpp index e0ffcc145..bcba7b804 100644 --- a/source/client/gui/components/ScrolledSelectionList.cpp +++ b/source/client/gui/components/ScrolledSelectionList.cpp @@ -9,6 +9,8 @@ // @TODO: Add keyboard based control #include "ScrolledSelectionList.hpp" +#include "renderer/EnableScissorTest.hpp" +#include "renderer/RenderContextImmediate.hpp" #define C_ITEM_WIDTH C_SCROLLED_LIST_ITEM_WIDTH @@ -86,13 +88,13 @@ void ScrolledSelectionList::onClickItem(int index, int mouseX, int mouseY) void ScrolledSelectionList::renderScrollBackground() { Tesselator& t = Tesselator::instance; - t.begin(); + t.begin(4); t.color(0x202020); t.vertexUV(field_24, field_10, 0.0f, field_24 / 32.0f, (field_10 + float(int(field_34))) / 32.0f); t.vertexUV(field_20, field_10, 0.0f, field_20 / 32.0f, (field_10 + float(int(field_34))) / 32.0f); t.vertexUV(field_20, field_C, 0.0f, field_20 / 32.0f, (field_C + float(int(field_34))) / 32.0f); t.vertexUV(field_24, field_C, 0.0f, field_24 / 32.0f, (field_C + float(int(field_34))) / 32.0f); - t.draw(); + t.draw(m_materials.ui_texture_and_color); } void ScrolledSelectionList::checkInput(int mouseX, int mouseY) @@ -149,6 +151,8 @@ void ScrolledSelectionList::checkInput(int mouseX, int mouseY) void ScrolledSelectionList::render(int mouseX, int mouseY, float f) { + mce::RenderContext& renderContext = mce::RenderContextImmediate::get(); + renderBackground(f); int nItems = getNumberOfItems(); @@ -160,11 +164,7 @@ void ScrolledSelectionList::render(int mouseX, int mouseY, float f) field_38 *= 0.75f; capYPosition(); - glDisable(GL_LIGHTING); - glDisable(GL_FOG); - m_pMinecraft->m_pTextures->loadAndBindTexture("gui/background.png"); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); renderScrollBackground(); @@ -177,95 +177,81 @@ void ScrolledSelectionList::render(int mouseX, int mouseY, float f) // Note, X/Y are the lower left's X/Y coordinates, not the upper left's. int lowerY = Minecraft::height - int(field_10 / Gui::InvGuiScale); int upperY = Minecraft::height - int(field_C / Gui::InvGuiScale); - glScissor(0, lowerY, Minecraft::width, upperY - lowerY); - glEnable(GL_SCISSOR_TEST); - for (int i = 0; i < nItems; i++) { - float itemY = float(field_48 + scrollY + i * m_itemHeight); - if (field_10 < itemY) - continue; - - float lowerY = itemY + m_itemHeight - 4; - if (lowerY < field_C) - continue; + mce::EnableScissorTest scissor(0, lowerY, Minecraft::width, upperY - lowerY); - if (m_bRenderSelection && isSelectedItem(i)) + for (int i = 0; i < nItems; i++) { - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glDisable(GL_TEXTURE_2D); - t.begin(); - t.color(0x808080); - t.vertexUV(float(field_18) / 2.0f - C_ITEM_WIDTH / 2.0f, lowerY + 2.0f, 0.0f, 0.0f, 1.0f); - t.vertexUV(float(field_18) / 2.0f + C_ITEM_WIDTH / 2.0f, lowerY + 2.0f, 0.0f, 1.0f, 1.0f); - t.vertexUV(float(field_18) / 2.0f + C_ITEM_WIDTH / 2.0f, itemY - 2.0f, 0.0f, 1.0f, 0.0f); - t.vertexUV(float(field_18) / 2.0f - C_ITEM_WIDTH / 2.0f, itemY - 2.0f, 0.0f, 0.0f, 0.0f); - t.color(0x000000); - t.vertexUV(float(field_18) / 2.0f - C_ITEM_WIDTH / 2.0f + 1, lowerY + 1.0f, 0.0f, 0.0f, 1.0f); - t.vertexUV(float(field_18) / 2.0f + C_ITEM_WIDTH / 2.0f - 1, lowerY + 1.0f, 0.0f, 1.0f, 1.0f); - t.vertexUV(float(field_18) / 2.0f + C_ITEM_WIDTH / 2.0f - 1, itemY - 1.0f, 0.0f, 1.0f, 0.0f); - t.vertexUV(float(field_18) / 2.0f - C_ITEM_WIDTH / 2.0f + 1, itemY - 1.0f, 0.0f, 0.0f, 0.0f); - t.draw(); - glEnable(GL_TEXTURE_2D); - } + float itemY = float(field_48 + scrollY + i * m_itemHeight); + if (field_10 < itemY) + continue; + + float lowerY = itemY + m_itemHeight - 4; + if (lowerY < field_C) + continue; - renderItem(i, itemX, int(itemY), int(m_itemHeight - 4.0f), t); + if (m_bRenderSelection && isSelectedItem(i)) + { + t.begin(8); + t.color(0x808080); + t.vertexUV(float(field_18) / 2.0f - C_ITEM_WIDTH / 2.0f, lowerY + 2.0f, 0.0f, 0.0f, 1.0f); + t.vertexUV(float(field_18) / 2.0f + C_ITEM_WIDTH / 2.0f, lowerY + 2.0f, 0.0f, 1.0f, 1.0f); + t.vertexUV(float(field_18) / 2.0f + C_ITEM_WIDTH / 2.0f, itemY - 2.0f, 0.0f, 1.0f, 0.0f); + t.vertexUV(float(field_18) / 2.0f - C_ITEM_WIDTH / 2.0f, itemY - 2.0f, 0.0f, 0.0f, 0.0f); + t.color(0x000000); + t.vertexUV(float(field_18) / 2.0f - C_ITEM_WIDTH / 2.0f + 1, lowerY + 1.0f, 0.0f, 0.0f, 1.0f); + t.vertexUV(float(field_18) / 2.0f + C_ITEM_WIDTH / 2.0f - 1, lowerY + 1.0f, 0.0f, 1.0f, 1.0f); + t.vertexUV(float(field_18) / 2.0f + C_ITEM_WIDTH / 2.0f - 1, itemY - 1.0f, 0.0f, 1.0f, 0.0f); + t.vertexUV(float(field_18) / 2.0f - C_ITEM_WIDTH / 2.0f + 1, itemY - 1.0f, 0.0f, 0.0f, 0.0f); + t.draw(m_materials.ui_fill_color); + } + + renderItem(i, itemX, int(itemY), int(m_itemHeight - 4.0f), t); + } } - - glDisable(GL_SCISSOR_TEST); - glDisable(GL_DEPTH_TEST); renderHoleBackground(0.0f, field_C, 255, 255); renderHoleBackground(field_10, float(field_1C), 255, 255); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glDisable(GL_ALPHA_TEST); - glShadeModel(GL_SMOOTH); - glDisable(GL_TEXTURE_2D); + renderContext.setShadeMode(mce::SHADE_MODE_SMOOTH); - t.begin(); + t.begin(4); t.color(0, 0); t.vertexUV(field_24, field_C + 4.0f, 0.0f, 0.0f, 1.0f); t.vertexUV(field_20, field_C + 4.0f, 0.0f, 1.0f, 1.0f); t.color(0, 255); t.vertexUV(field_20, field_C, 0.0f, 1.0f, 0.0f); t.vertexUV(field_24, field_C, 0.0f, 0.0f, 0.0f); - t.draw(); + t.draw(m_materials.ui_fill_color); - t.begin(); + t.begin(4); t.color(0, 255); t.vertexUV(field_24, field_10, 0.0f, 0.0f, 1.0f); t.vertexUV(field_20, field_10, 0.0f, 1.0f, 1.0f); t.color(0, 0); t.vertexUV(field_20, field_10 - 4.0f, 0.0f, 1.0f, 0.0f); t.vertexUV(field_24, field_10 - 4.0f, 0.0f, 0.0f, 0.0f); - t.draw(); + t.draw(m_materials.ui_fill_color); renderDecorations(mouseX, mouseY); - glEnable(GL_TEXTURE_2D); - glEnable(GL_DEPTH_TEST); - glShadeModel(GL_FLAT); - glEnable(GL_ALPHA_TEST); - glDisable(GL_BLEND); + renderContext.setShadeMode(mce::SHADE_MODE_FLAT); } void ScrolledSelectionList::renderHoleBackground(float a, float b, int c, int d) { m_pMinecraft->m_pTextures->loadAndBindTexture("gui/background.png"); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - Tesselator& t = Tesselator::instance; - t.begin(); + t.begin(4); t.color(0x505050, d); t.vertexUV(0.0f, b, 0.0f, 0.0f, b / 32.0f); t.vertexUV(float(field_18), b, 0.0f, field_18 / 32.0f, b / 32.0f); t.color(0x505050, c); t.vertexUV(float(field_18), a, 0.0f, field_18 / 32.0f, a / 32.0f); t.vertexUV(0.0f, a, 0.0f, 0.0f, a / 32.0f); - t.draw(); + t.draw(m_materials.ui_texture_and_color); } void ScrolledSelectionList::setRenderHeader(bool b, int i) diff --git a/source/client/gui/components/TextInputBox.cpp b/source/client/gui/components/TextInputBox.cpp index c868e69b7..7fe941915 100644 --- a/source/client/gui/components/TextInputBox.cpp +++ b/source/client/gui/components/TextInputBox.cpp @@ -434,7 +434,7 @@ void TextInputBox::render() rendered_text = getRenderedText(scroll_pos, rendered_text); int textYPos = (m_height - 8) / 2; - drawString(m_pFont, rendered_text, m_xPos + PADDING, m_yPos + textYPos, text_color); + drawString(*m_pFont, rendered_text, m_xPos + PADDING, m_yPos + textYPos, text_color); if (m_bCursorOn) { @@ -446,7 +446,7 @@ void TextInputBox::render() std::string str; str += CURSOR_CHAR; - drawString(m_pFont, str, m_xPos + xPos, m_yPos + textYPos + 2, 0xffffff); + drawString(*m_pFont, str, m_xPos + xPos, m_yPos + textYPos + 2, 0xffffff); } } } diff --git a/source/client/gui/components/WorldSelectionList.cpp b/source/client/gui/components/WorldSelectionList.cpp index b83783c6e..4c5ed01fa 100644 --- a/source/client/gui/components/WorldSelectionList.cpp +++ b/source/client/gui/components/WorldSelectionList.cpp @@ -149,28 +149,28 @@ void WorldSelectionList::renderItem(int index, int xPos, int yPos, int width, Te int x = xCenter + 5 - m_itemWidth / 2; // Draw name - drawString(m_pMinecraft->m_pFont, details[0], x, yPos + 50 + yPadding, color1); + drawString(*m_pMinecraft->m_pFont, details[0], x, yPos + 50 + yPadding, color1); // Draw other details for (unsigned int i = 1; i < details.size()-1; i++) { - drawString(m_pMinecraft->m_pFont, details[i], x, yPos + (50 + yPadding + (10 * i)), color2); + drawString(*m_pMinecraft->m_pFont, details[i], x, yPos + (50 + yPadding + (10 * i)), color2); } // Draw storage version - drawString(m_pMinecraft->m_pFont, details[details.size()-1], xCenter + 42, yPos + (50 + yPadding + (10 * 3)), color2); + drawString(*m_pMinecraft->m_pFont, details[details.size()-1], xCenter + 42, yPos + (50 + yPadding + (10 * 3)), color2); m_pMinecraft->m_pTextures->loadAndBindTexture(m_previewImages[index]); // @NOTE: useless assignment of color - t.color(0.3f, 1.0f, 0.2f); + //t.color(0.3f, 1.0f, 0.2f); - t.begin(); + t.begin(4); t.color(color1); float y = float(yPos) - 6.0f; - t.vertexUV(float(xCenter - 32), y, this->field_4, 0.0f, 0.0f); - t.vertexUV(float(xCenter - 32), y + 48.0f, this->field_4, 0.0f, 1.0f); - t.vertexUV(float(xCenter + 32), y + 48.0f, this->field_4, 1.0f, 1.0f); - t.vertexUV(float(xCenter + 32), y, this->field_4, 1.0f, 0.0f); - t.draw(); + t.vertexUV(float(xCenter - 32), y, m_blitOffset, 0.0f, 0.0f); + t.vertexUV(float(xCenter - 32), y + 48.0f, m_blitOffset, 0.0f, 1.0f); + t.vertexUV(float(xCenter + 32), y + 48.0f, m_blitOffset, 1.0f, 1.0f); + t.vertexUV(float(xCenter + 32), y, m_blitOffset, 1.0f, 0.0f); + t.draw(m_materials.ui_texture_and_color); } void WorldSelectionList::renderBackground() diff --git a/source/client/gui/screens/ChatScreen.cpp b/source/client/gui/screens/ChatScreen.cpp index 2d8dffd03..23e69e10c 100644 --- a/source/client/gui/screens/ChatScreen.cpp +++ b/source/client/gui/screens/ChatScreen.cpp @@ -44,7 +44,7 @@ void ChatScreen::init() void ChatScreen::removed() { // Now let them be rendered. - m_pMinecraft->m_gui.m_bRenderMessages = true; + m_pMinecraft->m_pGui->m_bRenderMessages = true; } void ChatScreen::render(int mouseX, int mouseY, float f) @@ -52,8 +52,8 @@ void ChatScreen::render(int mouseX, int mouseY, float f) renderBackground(); // override the default behavior of rendering chat messages - m_pMinecraft->m_gui.m_bRenderMessages = false; - m_pMinecraft->m_gui.renderMessages(true); + m_pMinecraft->m_pGui->m_bRenderMessages = false; + m_pMinecraft->m_pGui->renderMessages(true); Screen::render(mouseX, mouseY, f); } diff --git a/source/client/gui/screens/ConfirmScreen.cpp b/source/client/gui/screens/ConfirmScreen.cpp index 4df8d0a76..785161034 100644 --- a/source/client/gui/screens/ConfirmScreen.cpp +++ b/source/client/gui/screens/ConfirmScreen.cpp @@ -62,8 +62,8 @@ void ConfirmScreen::init() void ConfirmScreen::render(int mouseX, int mouseY, float f) { renderBackground(); - drawCenteredString(m_pFont, m_textLine1, m_width / 2, 50, 0xFFFFFF); - drawCenteredString(m_pFont, m_textLine2, m_width / 2, 70, 0xFFFFFF); + drawCenteredString(*m_pFont, m_textLine1, m_width / 2, 50, 0xFFFFFF); + drawCenteredString(*m_pFont, m_textLine2, m_width / 2, 70, 0xFFFFFF); Screen::render(mouseX, mouseY, f); } diff --git a/source/client/gui/screens/CreateWorldScreen.cpp b/source/client/gui/screens/CreateWorldScreen.cpp index 42f548e71..179b8813f 100644 --- a/source/client/gui/screens/CreateWorldScreen.cpp +++ b/source/client/gui/screens/CreateWorldScreen.cpp @@ -135,8 +135,8 @@ void CreateWorldScreen::render(int mouseX, int mouseY, float f) renderBackground(); Screen::render(mouseX, mouseY, f); - drawCenteredString(m_pFont, "Create New World", m_width / 2, CRAMPED() ? 10 : 30, 0xFFFFFF); - drawString(m_pFont, "World name", m_textName.m_xPos, m_textName.m_yPos - 10, 0xDDDDDD); - drawString(m_pFont, "Seed for the World Generator", m_textSeed.m_xPos, m_textSeed.m_yPos - 10, 0xDDDDDD); - drawString(m_pFont, "Leave blank for a random seed", m_textSeed.m_xPos, m_textSeed.m_yPos + 22, 0x999999); + drawCenteredString(*m_pFont, "Create New World", m_width / 2, CRAMPED() ? 10 : 30, 0xFFFFFF); + drawString(*m_pFont, "World name", m_textName.m_xPos, m_textName.m_yPos - 10, 0xDDDDDD); + drawString(*m_pFont, "Seed for the World Generator", m_textSeed.m_xPos, m_textSeed.m_yPos - 10, 0xDDDDDD); + drawString(*m_pFont, "Leave blank for a random seed", m_textSeed.m_xPos, m_textSeed.m_yPos + 22, 0x999999); } diff --git a/source/client/gui/screens/DeathScreen.cpp b/source/client/gui/screens/DeathScreen.cpp index 921ac9348..801779e9e 100644 --- a/source/client/gui/screens/DeathScreen.cpp +++ b/source/client/gui/screens/DeathScreen.cpp @@ -47,10 +47,11 @@ void DeathScreen::render(int x, int y, float f) { fillGradient(0, 0, m_width, m_height, 0xA0303080, 0x60000050); - glPushMatrix(); - glScalef(2.0f, 2.0f, 2.0f); - drawCenteredString(m_pFont, "You died!", m_width / 4, m_height / 8, 0xFFFFFF); - glPopMatrix(); + { + MatrixStack::Ref matrix = MatrixStack::World.push(); + matrix->scale(2.0f); + drawCenteredString(*m_pFont, "You died!", m_width / 4, m_height / 8, 0xFFFFFF); + } // render the buttons after 1.5 seconds if (m_tickCounter >= 30) diff --git a/source/client/gui/screens/DirectConnectScreen.cpp b/source/client/gui/screens/DirectConnectScreen.cpp index 639e229a2..517cf07d2 100644 --- a/source/client/gui/screens/DirectConnectScreen.cpp +++ b/source/client/gui/screens/DirectConnectScreen.cpp @@ -53,8 +53,8 @@ void DirectConnectScreen::render(int x, int y, float f) renderBackground(); Screen::render(x, y, f); - drawCenteredString(m_pFont, "Direct Connect", m_width / 2, 30, 0xFFFFFF); - drawString(m_pFont, "Server Address", m_textAddress.m_xPos, m_textAddress.m_yPos - 15, 0x999999); + drawCenteredString(*m_pFont, "Direct Connect", m_width / 2, 30, 0xFFFFFF); + drawString(*m_pFont, "Server Address", m_textAddress.m_xPos, m_textAddress.m_yPos - 15, 0x999999); } void DirectConnectScreen::buttonClicked(Button* pButton) diff --git a/source/client/gui/screens/DisconnectionScreen.cpp b/source/client/gui/screens/DisconnectionScreen.cpp index 276607eaa..33e9db272 100644 --- a/source/client/gui/screens/DisconnectionScreen.cpp +++ b/source/client/gui/screens/DisconnectionScreen.cpp @@ -34,7 +34,7 @@ void DisconnectionScreen::init() void DisconnectionScreen::render(int mouseX, int mouseY, float f) { renderBackground(); - drawCenteredString(m_pFont, m_text, m_width / 2, m_height / 2 - 32, 0xFFFFFF); + drawCenteredString(*m_pFont, m_text, m_width / 2, m_height / 2 - 32, 0xFFFFFF); Screen::render(mouseX, mouseY, f); } diff --git a/source/client/gui/screens/IngameBlockSelectionScreen.cpp b/source/client/gui/screens/IngameBlockSelectionScreen.cpp index 27008040f..9dd12eeb1 100644 --- a/source/client/gui/screens/IngameBlockSelectionScreen.cpp +++ b/source/client/gui/screens/IngameBlockSelectionScreen.cpp @@ -11,6 +11,7 @@ #include "ChatScreen.hpp" #include "client/app/Minecraft.hpp" #include "client/renderer/entity/ItemRenderer.hpp" +#include "renderer/ShaderConstants.hpp" std::string g_sNotAvailableInDemoVersion = "Not available in the demo version"; @@ -111,20 +112,20 @@ void IngameBlockSelectionScreen::renderSlot(int index, int x, int y, float f) if (ItemInstance::isNull(pItem)) return; - ItemRenderer::renderGuiItem(m_pMinecraft->m_pFont, m_pMinecraft->m_pTextures, pItem, x, y, true); - ItemRenderer::renderGuiItemOverlay(m_pMinecraft->m_pFont, m_pMinecraft->m_pTextures, pItem, x, y); + ItemRenderer::singleton().renderGuiItem(m_pMinecraft->m_pFont, m_pMinecraft->m_pTextures, pItem, x, y, true); + ItemRenderer::singleton().renderGuiItemOverlay(m_pMinecraft->m_pFont, m_pMinecraft->m_pTextures, pItem, x, y); } void IngameBlockSelectionScreen::renderSlots() { - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + currentShaderColor = Color::WHITE; m_pMinecraft->m_pTextures->loadAndBindTexture("gui/gui.png"); for (int y = 0; y != -22 * getSlotsHeight(); y -= 22) - blit(m_width / 2 - 182 / 2, m_height - 3 - getBottomY() + y, 0, 0, 182, 22, 0, 0); + blit(m_width / 2 - 182 / 2, m_height - 3 - getBottomY() + y, 0, 0, 182, 22, 0, 0, &m_materials.ui_textured_and_glcolor); if (m_selectedSlot >= 0) - blit(m_width / 2 - 92 + 20 * (m_selectedSlot % 9), m_height - 4 - getBottomY() - 22 * (m_selectedSlot / 9), 0, 22, 24, 22, 0, 0); + blit(m_width / 2 - 92 + 20 * (m_selectedSlot % 9), m_height - 4 - getBottomY() - 22 * (m_selectedSlot / 9), 0, 22, 24, 22, 0, 0, &m_materials.ui_textured_and_glcolor); for (int y = 0, index = 0; y < getSlotsHeight(); y++) { @@ -144,24 +145,20 @@ void IngameBlockSelectionScreen::renderDemoOverlay() int x = (getSlotPosX(4) + getSlotPosX(5)) / 2; int y = (getSlotPosY(0) + getSlotPosY(1)) / 2 + 5; - drawCenteredString(m_pMinecraft->m_pFont, g_sNotAvailableInDemoVersion, x, y, 0xFFFFFFFF); + drawCenteredString(*m_pMinecraft->m_pFont, g_sNotAvailableInDemoVersion, x, y, 0xFFFFFFFF); } void IngameBlockSelectionScreen::render(int x, int y, float f) { Screen::render(x, y, f); - glDisable(GL_DEPTH_TEST); fill(0, 0, m_width, m_height, 0x80000000); - glEnable(GL_BLEND); renderSlots(); #ifdef DEMO renderDemoOverlay(); #endif - - glEnable(GL_DEPTH_TEST); } void IngameBlockSelectionScreen::buttonClicked(Button* pButton) @@ -201,14 +198,14 @@ void IngameBlockSelectionScreen::mouseReleased(int x, int y, int type) void IngameBlockSelectionScreen::removed() { - m_pMinecraft->m_gui.inventoryUpdated(); + m_pMinecraft->m_pGui->inventoryUpdated(); } void IngameBlockSelectionScreen::selectSlotAndClose() { Inventory* pInv = getInventory(); - pInv->selectItem(m_selectedSlot, m_pMinecraft->m_gui.getNumUsableSlots()); + pInv->selectItem(m_selectedSlot, m_pMinecraft->m_pGui->getNumUsableSlots()); m_pMinecraft->m_pSoundEngine->playUI("random.click"); m_pMinecraft->setScreen(nullptr); diff --git a/source/client/gui/screens/InvalidLicenseScreen.cpp b/source/client/gui/screens/InvalidLicenseScreen.cpp index e804c4038..3ff76374f 100644 --- a/source/client/gui/screens/InvalidLicenseScreen.cpp +++ b/source/client/gui/screens/InvalidLicenseScreen.cpp @@ -64,7 +64,7 @@ void InvalidLicenseScreen::tick() void InvalidLicenseScreen::render(int mouseX, int mouseY, float f) { renderDirtBackground(0); - drawCenteredString(m_pMinecraft->m_pFont, m_textLine1, m_width / 2, field_E4, 0xFFFFFF); - drawCenteredString(m_pMinecraft->m_pFont, m_textLine2, m_width / 2, field_E4 + 24, 0xFFFFFF); + drawCenteredString(*m_pMinecraft->m_pFont, m_textLine1, m_width / 2, field_E4, 0xFFFFFF); + drawCenteredString(*m_pMinecraft->m_pFont, m_textLine2, m_width / 2, field_E4 + 24, 0xFFFFFF); Screen::render(mouseX, mouseY, f); } diff --git a/source/client/gui/screens/JoinGameScreen.cpp b/source/client/gui/screens/JoinGameScreen.cpp index e083e3418..6c719347b 100644 --- a/source/client/gui/screens/JoinGameScreen.cpp +++ b/source/client/gui/screens/JoinGameScreen.cpp @@ -99,7 +99,7 @@ void JoinGameScreen::render(int mouseX, int mouseY, float f) m_pAvailableGamesList->render(mouseX, mouseY, f); Screen::render(mouseX, mouseY, f); - drawCenteredString(m_pMinecraft->m_pFont, "Scanning for Games...", m_width / 2, 8, 0xFFFFFFFF); + drawCenteredString(*m_pMinecraft->m_pFont, "Scanning for Games...", m_width / 2, 8, 0xFFFFFFFF); } void JoinGameScreen::tick() diff --git a/source/client/gui/screens/OptionsScreen.cpp b/source/client/gui/screens/OptionsScreen.cpp index 31a731781..ce1dca477 100644 --- a/source/client/gui/screens/OptionsScreen.cpp +++ b/source/client/gui/screens/OptionsScreen.cpp @@ -50,7 +50,7 @@ void OptionsScreen::render(int mouseX, int mouseY, float f) Screen::render(mouseX, mouseY, f); - drawCenteredString(m_pFont, "Options", m_width / 2, 10, 0xFFFFFF); + drawCenteredString(*m_pFont, "Options", m_width / 2, 10, 0xFFFFFF); } void OptionsScreen::removed() @@ -302,7 +302,7 @@ void OptionsScreen::render(int a, int b, float c) } #ifndef ORIGINAL_CODE - drawCenteredString(m_pFont, "Options", m_width / 2, isCramped() ? 5 : 20, 0xFFFFFF); + drawCenteredString(*m_pFont, "Options", m_width / 2, isCramped() ? 5 : 20, 0xFFFFFF); Screen::render(a, b, c); #endif diff --git a/source/client/gui/screens/PauseScreen.cpp b/source/client/gui/screens/PauseScreen.cpp index 35d702ba0..7854597ac 100644 --- a/source/client/gui/screens/PauseScreen.cpp +++ b/source/client/gui/screens/PauseScreen.cpp @@ -120,7 +120,7 @@ void PauseScreen::render(int a, int b, float c) { renderBackground(); - drawCenteredString(m_pFont, "Game menu", m_width / 2, 24, 0xFFFFFF); + drawCenteredString(*m_pFont, "Game menu", m_width / 2, 24, 0xFFFFFF); Screen::render(a, b, c); } diff --git a/source/client/gui/screens/ProgressScreen.cpp b/source/client/gui/screens/ProgressScreen.cpp index 64e3def28..033f6c71d 100644 --- a/source/client/gui/screens/ProgressScreen.cpp +++ b/source/client/gui/screens/ProgressScreen.cpp @@ -27,13 +27,13 @@ void ProgressScreen::render(int a, int b, float c) int x_height = int(Minecraft::height * Gui::InvGuiScale); Tesselator& t = Tesselator::instance; - t.begin(); + t.begin(4); t.color(0x404040); t.vertexUV(0.0f, float(x_height), 0, 0, float(x_height) / 32.0f); t.vertexUV(float(x_width), float(x_height), 0, float(x_width) / 32.0f, float(x_height) / 32.0f); t.vertexUV(float(x_width), 0, 0, float(x_width) / 32.0f, 0); t.vertexUV(0.0f, 0, 0, 0, 0); - t.draw(); + t.draw(m_materials.ui_texture_and_color); int yPos = x_height / 2; @@ -42,10 +42,7 @@ void ProgressScreen::render(int a, int b, float c) float lX = float(x_width) / 2 - 50, rX = float(x_width) / 2 + 50; float prog = float(m_pMinecraft->m_progressPercent); - // disable the texturing - glDisable(GL_TEXTURE_2D); - - t.begin(); + t.begin(8); t.color(0x808080); // gray background t.vertex(lX, float(yPos + 16), 0); @@ -59,10 +56,7 @@ void ProgressScreen::render(int a, int b, float c) t.vertex(lX + prog, float(yPos + 18), 0); t.vertex(lX + prog, float(yPos + 16), 0); - t.draw(); - - // restore old state - glEnable(GL_TEXTURE_2D); + t.draw(m_materials.ui_fill_color); } //! Using m_pMinecraft->m_pFont instead of m_pFont. @@ -83,6 +77,7 @@ void ProgressScreen::updateEvents() { if (m_pMinecraft->isLevelGenerated()) { + m_pMinecraft->setScreen(nullptr); return; } diff --git a/source/client/gui/screens/SavingWorldScreen.cpp b/source/client/gui/screens/SavingWorldScreen.cpp index 1c498d6b8..3042407c4 100644 --- a/source/client/gui/screens/SavingWorldScreen.cpp +++ b/source/client/gui/screens/SavingWorldScreen.cpp @@ -60,7 +60,7 @@ void SavingWorldScreen::tick() //SAFE_DELETE(m_pEntityToDeleteAfterSave); // already done by the Level - m_pMinecraft->m_pMobPersp = m_pMinecraft->m_pLocalPlayer = nullptr; + m_pMinecraft->m_pCameraEntity = m_pMinecraft->m_pLocalPlayer = nullptr; m_pMinecraft->m_bUsingScreen = true; diff --git a/source/client/gui/screens/SelectWorldScreen.cpp b/source/client/gui/screens/SelectWorldScreen.cpp index f7ef36c3a..22a3dde23 100644 --- a/source/client/gui/screens/SelectWorldScreen.cpp +++ b/source/client/gui/screens/SelectWorldScreen.cpp @@ -69,10 +69,10 @@ void SelectWorldScreen::keyPressed(int code) if (m_pMinecraft->getOptions()->getKey(KM_MENU_OK) == code) m_pWorldSelectionList->selectItem(m_pWorldSelectionList->getItemAtPosition(m_width / 2, m_height / 2), false); - m_btnUnknown.field_36 = true; + m_btnUnknown.m_bHovered = true; #endif - if (m_btnUnknown.field_36) + if (m_btnUnknown.m_bHovered) { if (m_pMinecraft->getOptions()->getKey(KM_LEFT) == code) m_pWorldSelectionList->stepLeft(); @@ -89,7 +89,7 @@ static char g_SelectWorldFilterArray[] = { '/','\n','\r','\x09','\0','\xC','`',' void SelectWorldScreen::tick() { #ifndef ORIGINAL_CODE - m_btnUnknown.field_36 = true; + m_btnUnknown.m_bHovered = true; #endif if (field_130 == 1) @@ -168,9 +168,9 @@ void SelectWorldScreen::render(int mouseX, int mouseY, float f) { renderBackground(); #ifndef ORIGINAL_CODE - m_btnUnknown.field_36 = true; + m_btnUnknown.m_bHovered = true; #endif - m_pWorldSelectionList->setComponentSelected(m_btnUnknown.field_36); + m_pWorldSelectionList->setComponentSelected(m_btnUnknown.m_bHovered); if (field_12C) { m_pWorldSelectionList->render(mouseX, mouseY, f); @@ -183,7 +183,7 @@ void SelectWorldScreen::render(int mouseX, int mouseY, float f) Screen::render(mouseX, mouseY, f); - drawCenteredString(m_pMinecraft->m_pFont, "Select world", m_width / 2, 8, 0xFFFFFFFF); + drawCenteredString(*m_pMinecraft->m_pFont, "Select world", m_width / 2, 8, 0xFFFFFFFF); } bool SelectWorldScreen::handleBackEvent(bool b) diff --git a/source/client/gui/screens/StartMenuScreen.cpp b/source/client/gui/screens/StartMenuScreen.cpp index 56f3bc627..12b86e237 100644 --- a/source/client/gui/screens/StartMenuScreen.cpp +++ b/source/client/gui/screens/StartMenuScreen.cpp @@ -7,14 +7,18 @@ ********************************************************************/ #include "StartMenuScreen.hpp" + +#include "client/renderer/ScreenRenderer.hpp" +#include "client/renderer/renderer/RenderMaterialGroup.hpp" +#include "renderer/RenderContextImmediate.hpp" +#include "renderer/ShaderConstants.hpp" + #include "InvalidLicenseScreen.hpp" #include "OptionsScreen.hpp" #include "ProgressScreen.hpp" #include "SelectWorldScreen.hpp" #include "JoinGameScreen.hpp" -#define CAN_QUIT - // special mode so that we can crop out the title: //#define TITLE_CROP_MODE @@ -348,16 +352,30 @@ const char* gSplashes[] = // custom: "https://github.com/ReMinecraftPE/mcpe", + "100% (render)dragon free!", "Also try Minecraft!", "Also try Noita!", "Also try Castle Crashers!", "Also try Unturned!", "Controller support!", "Check out our GitHub!", + "Now with graphics abstraction!", + "Now with HAL!", + "Supports PowerPC!", + // These guys carried + "The Work of Aron Nieminen!", // https://minecraft.wiki/w/Aron_Nieminen + "The Work of Johan Bernhardsson!", // https://minecraft.wiki/w/Johan_Bernhardsson + "The Work of Tommaso Checchi!", // https://minecraft.wiki/w/Tommaso_Checchi "Woo, newgrounds!", - "Woo, curseforge!" + "Woo, curseforge!", }; +StartMenuScreen::Materials::Materials() +{ + MATERIAL_PTR(common, ui_title_tile); + MATERIAL_PTR(common, ui_title_tile_shadow); +} + StartMenuScreen::StartMenuScreen() : m_startButton (2, 0, 0, 160, 24, "Start Game"), m_joinButton (3, 0, 0, 160, 24, "Join Game"), @@ -424,10 +442,11 @@ void StartMenuScreen::buttonClicked(Button* pButton) TitleTile::regenerate(); return; #endif -#if !defined(DEMO) && defined(CAN_QUIT) - m_pMinecraft->quit(); + +#ifdef DEMO + m_pMinecraft->platform()->buyGame(); #else - m_pMinecraft->platform()->buyGame(); + m_pMinecraft->quit(); #endif } else if (pButton->m_buttonId == m_optionsButton.m_buttonId) @@ -463,9 +482,16 @@ void StartMenuScreen::init() m_buttons.push_back(&m_joinButton); m_buttons.push_back(&m_optionsButton); -#if defined(DEMO) || defined(CAN_QUIT) - m_buttons.push_back(&m_buyButton); + bool canQuit = false; + +#if defined(DEMO) || (!MC_PLATFORM_IOS && !MC_PLATFORM_ANDROID) + canQuit = true; #endif + + if (canQuit) + { + m_buttons.push_back(&m_buyButton); + } for (int i = 0; i < int(m_buttons.size()); i++) m_buttonTabList.push_back(m_buttons[i]); @@ -481,7 +507,7 @@ void StartMenuScreen::init() field_188 = (m_width - m_pFont->width(field_170)) / 2; -#if !defined(DEMO) && defined(CAN_QUIT) +#ifndef DEMO m_buyButton.m_text = "Quit"; #endif @@ -493,7 +519,7 @@ bool StartMenuScreen::isInGameScreen() return false; } -void StartMenuScreen::drawLegacyTitle() +void StartMenuScreen::draw2dTitle() { Textures* tx = m_pMinecraft->m_pTextures; @@ -502,88 +528,29 @@ void StartMenuScreen::drawLegacyTitle() //int titleYPos = 30; // -- MC Java position int titleYPos = 15; - int id = tx->loadTexture("gui/title.png", true); - Texture* pTex = tx->getTemporaryTextureData(id); + TextureData* pTex = tx->loadAndBindTexture("gui/title.png", true); if (pTex) { - if (id != tx->m_currBoundTex) - { - glBindTexture(GL_TEXTURE_2D, id); - tx->m_currBoundTex = id; - } - - int left = (m_width - pTex->m_width) / 2; - int width = pTex->m_width; - int height = pTex->m_height; + int left = (m_width - pTex->m_imageData.m_width) / 2; + int width = pTex->m_imageData.m_width; + int height = pTex->m_imageData.m_height; - if (m_width * 3 / 4 < width) + if (m_width * 3 / 4 < m_2dTitleBounds.w) { crampedMode = true; titleYPos = 4; } - Tesselator& t = Tesselator::instance; - glColor4f(1, 1, 1, 1); - t.begin(); - t.vertexUV(left, height + titleYPos, field_4, 0.0f, 1.0f); - t.vertexUV(left + width, height + titleYPos, field_4, 1.0f, 1.0f); - t.vertexUV(left + width, titleYPos, field_4, 1.0f, 0.0f); - t.vertexUV(left, titleYPos, field_4, 0.0f, 0.0f); - t.draw(); - } - -} - -void StartMenuScreen::render(int a, int b, float c) -{ -#ifdef TITLE_CROP_MODE - fill(0, 0, m_width, m_height, 0xFF00FF00); -#else - //renderBackground(); - renderMenuBackground(c); -#endif - - //int titleYPos = 4; - //int titleYPos = 30; // -- MC Java position. - int titleYPos = 15; - bool crampedMode = false; + m_2dTitleBounds.x = left; + m_2dTitleBounds.y = titleYPos; + m_2dTitleBounds.w = width; + m_2dTitleBounds.h = height; - if (m_width * 3 / 4 < 256) - { - crampedMode = true; - titleYPos = 4; + currentShaderColor = Color::WHITE; + blit(m_2dTitleBounds); } - if (m_pMinecraft->getOptions()->m_bOldTitleLogo) - drawLegacyTitle(); - else - draw3dTitle(c); - - drawString(m_pFont, field_170, field_188, 58 + titleYPos, 0xFFCCCCCC); - drawString(m_pFont, field_154, field_16C, m_height - 10, 0x00FFFFFF); - - // Draw the splash text, if we have enough room. -#ifndef TITLE_CROP_MODE - if (!crampedMode) - drawSplash(); -#endif - - Screen::render(a, b, c); -} - -void StartMenuScreen::tick() -{ - Screen::tick(); - _updateLicense(); - - if (m_pTiles) - { - int Width = int(sizeof gLogoLine1 - 1); - int Height = int(sizeof gLogoLines / sizeof * gLogoLines); - for (int i = 0; i < Width * Height; i++) - m_pTiles[i]->tick(); - } } void StartMenuScreen::draw3dTitle(float f) @@ -605,53 +572,63 @@ void StartMenuScreen::draw3dTitle(float f) if (m_width * 3 / 4 < 256) // cramped mode titleHeight = int(80 / Gui::InvGuiScale); - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - gluPerspective(70.0f, float(Minecraft::width) / titleHeight, 0.05f, 100.0f); - glViewport(0, Minecraft::height - titleHeight, Minecraft::width, titleHeight); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - //glDisable(GL_CULL_FACE); - glDepthMask(true); - - for (int i = 0; i < 3; i++) + MatrixStack::Ref projMtx = MatrixStack::Projection.pushIdentity(); + projMtx->setPerspective(70.0f, float(Minecraft::width) / titleHeight, 0.05f, 100.0f); + + mce::RenderContext& renderContext = mce::RenderContextImmediate::get(); + + renderContext.setViewport(0, Minecraft::height - titleHeight, Minecraft::width, titleHeight, 0.0f, 0.7f); + + MatrixStack::Ref viewMtx = MatrixStack::View.pushIdentity(); + + mce::MaterialPtr* pMaterial; + + for (int i = 0; i < 2; i++) { - glPushMatrix(); - glTranslatef(0.4f, 0.6f, -12.0f); + MatrixStack::Ref matrix = MatrixStack::World.push(); + matrix->translate(Vec3(0.4f, 0.6f, -12.0f)); switch (i) { - case 0: - glClear(GL_DEPTH_BUFFER_BIT); - glTranslatef(0.0f, -0.5f, -0.5f); - glEnable(GL_BLEND); + case 0: // shadow + //glClear(GL_DEPTH_BUFFER_BIT); + renderContext.clearDepthStencilBuffer(); + matrix->translate(Vec3(0.0f, -0.5f, -0.5f)); + //glEnable(GL_BLEND); //force set alpha - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // default break; - case 1: - glDisable(GL_BLEND); - glClear(GL_DEPTH_BUFFER_BIT); + case 1: // tiles + //glDisable(GL_BLEND); + //glClear(GL_DEPTH_BUFFER_BIT); + renderContext.clearDepthStencilBuffer(); //revert - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // default break; - case 2: - glEnable(GL_BLEND); + case 2: // tiles again + //glEnable(GL_BLEND); //glBlendFunc(GL_SRC_COLOR, GL_ONE); break; } - glScalef(1.0f, -1.0f, 1.0f); - glRotatef(8.0f, 1.0f, 0.0f, 0.0f); - //glRotatef(15.0f, 1.0f, 0.0f, 0.0f); - glScalef(0.89f, 1.0f, 0.4f); - glTranslatef(-Width * 0.5f, -Height * 0.5f, 0.0f); + matrix->scale(Vec3(1.0f, -1.0f, 1.0f)); + matrix->rotate(8.0f, Vec3::UNIT_X); + //matrix->rotate(15.0f, Vec3::UNIT_X); + matrix->scale(Vec3(0.89f, 1.0f, 0.4f)); + matrix->translate(Vec3(-Width * 0.5f, -Height * 0.5f, 0.0f)); m_pMinecraft->m_pTextures->loadAndBindTexture(C_TERRAIN_NAME); - if (i == 0) { + if (i == 0) + { m_pMinecraft->m_pTextures->loadAndBindTexture("gui/black.png"); + pMaterial = &m_screenMaterials.ui_title_tile_shadow; + //currentShaderColor = Color(0, 0, 0, 100); + } + else + { + pMaterial = &m_screenMaterials.ui_title_tile; + currentShaderColor = Color::WHITE; } for (int y = 0; y < Height; y++) @@ -663,7 +640,7 @@ void StartMenuScreen::draw3dTitle(float f) Tile* pTile = TitleTile::getTileFromChar(gLogoLines[y][x]); - glPushMatrix(); + MatrixStack::Ref matrix = MatrixStack::World.push(); TitleTile* pTTile = m_pTiles[y * Width + x]; float z = Mth::Lerp(pTTile->lastHeight, pTTile->height, f); @@ -678,50 +655,90 @@ void StartMenuScreen::draw3dTitle(float f) z = 0.0f; } - glTranslatef(float(x), float(y), z); - glScalef(scale, scale, scale); - glScalef(-1.0f, 1.0f, 1.0f); - glRotatef(rotation, 0.0f, 0.0f, 1.0f); + matrix->translate(Vec3(x, y, z)); + matrix->scale(scale); + matrix->scale(Vec3(-1.0f, 1.0f, 1.0f)); + matrix->rotate(rotation, Vec3::UNIT_Z); // rotate 90 deg on the X axis to correct lighting - glRotatef(90.0f, 1.0f, 0.0f, 0.0f); - m_tileRenderer.renderTile(pTile, i == 0 ? 255 : 0, bright, true); + matrix->rotate(90.0f, Vec3::UNIT_X); - glPopMatrix(); + m_tileRenderer.renderTile(FullTile(pTile, i == 0 ? 255 : 0), *pMaterial, bright, true); } } + } + + renderContext.setViewport(0, 0, Minecraft::width, Minecraft::height, 0.0f, 0.7f); +} - glPopMatrix(); +void StartMenuScreen::render(int a, int b, float c) +{ +#ifdef TITLE_CROP_MODE + fill(0, 0, m_width, m_height, 0xFF00FF00); +#else + //renderBackground(); + renderMenuBackground(c); +#endif + + //int titleYPos = 4; + //int titleYPos = 30; // -- MC Java position. + int titleYPos = 15; + bool crampedMode = false; + + if (m_width * 3 / 4 < 256) + { + crampedMode = true; + titleYPos = 4; } - glDisable(GL_BLEND); - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - glViewport(0, 0, Minecraft::width, Minecraft::height); - //glEnable(GL_CULL_FACE); + if (m_pMinecraft->getOptions()->m_bOldTitleLogo) + draw2dTitle(); + else + draw3dTitle(c); + + drawString(*m_pFont, field_170, field_188, 58 + titleYPos, Color(204, 204, 204)); + drawString(*m_pFont, field_154, field_16C, m_height - 10, Color::WHITE); + + // Draw the splash text, if we have enough room. +#ifndef TITLE_CROP_MODE + if (!crampedMode) + drawSplash(); +#endif + + Screen::render(a, b, c); +} + +void StartMenuScreen::tick() +{ + Screen::tick(); + _updateLicense(); + + if (m_pTiles) + { + int Width = int(sizeof gLogoLine1 - 1); + int Height = int(sizeof gLogoLines / sizeof * gLogoLines); + for (int i = 0; i < Width * Height; i++) + m_pTiles[i]->tick(); + } } void StartMenuScreen::drawSplash() { - glPushMatrix(); + MatrixStack::Ref mtx = MatrixStack::World.push(); std::string splashText = getSplashString(); int textWidth = m_pFont->width(splashText); //int textHeight = m_pFont->height(splashText); - glTranslatef(float(m_width) / 2.0f + 90.0f, 70.0f, 0.0f); - glRotatef(-20.0f, 0.0f, 0.0f, 1.0f); + mtx->translate(Vec3(float(m_width) / 2.0f + 90.0f, 70.0f, 0.0f)); + mtx->rotate(-20.0f, Vec3::UNIT_Z); float timeMS = float(getTimeMs() % 1000) / 1000.0f; float scale = 1.8f - Mth::abs(0.1f * Mth::sin(2.0f * float(M_PI) * timeMS)); scale = (scale * 100.0f) / (32.0f + textWidth); - glScalef(scale, scale, scale); - - drawCenteredString(m_pFont, splashText, 0, -8, 0xFFFF00); + mtx->scale(scale); - glPopMatrix(); + drawCenteredString(*m_pFont, splashText, 0, -8, Color::YELLOW); } std::string StartMenuScreen::getSplashString() @@ -785,15 +802,11 @@ Tile* TitleTile::getTileFromChar(char c) // NOTE: Using the tile enum instead of Tile::tileName->id, may want to.. not? static const int _tileBlockList[] = { TILE_BOOKSHELF, - TILE_STAIRS_WOOD, - TILE_STAIRS_STONE, TILE_TOPSNOW, TILE_GRASS, TILE_INFO_UPDATEGAME1, TILE_INFO_UPDATEGAME2, - TILE_STONESLAB_HALF, - TILE_CACTUS, - TILE_FENCE, + TILE_LEAVES_CARRIED }; static const int _tileBlockListSize = sizeof _tileBlockList / sizeof(int); @@ -816,7 +829,8 @@ Tile* TitleTile::getRandomTile(Tile* except1, Tile* except2) // If found a tile, check if it can be rendered Tile* pTile = Tile::tiles[id]; - if (!TileRenderer::canRender(pTile->getRenderShape())) + eRenderShape renderShape = pTile->getRenderShape(); + if (!TileRenderer::canRender(renderShape) || renderShape != SHAPE_SOLID) continue; if (pTile == except1 || pTile == except2) diff --git a/source/client/gui/screens/StartMenuScreen.hpp b/source/client/gui/screens/StartMenuScreen.hpp index a6a64ff72..5b4473dc3 100644 --- a/source/client/gui/screens/StartMenuScreen.hpp +++ b/source/client/gui/screens/StartMenuScreen.hpp @@ -9,6 +9,7 @@ #pragma once #include "../Screen.hpp" +#include "../IntRectangle.hpp" #include "client/renderer/TileRenderer.hpp" class StartMenuScreen; @@ -37,6 +38,16 @@ class TitleTile class StartMenuScreen : public Screen { +protected: + class Materials + { + public: + mce::MaterialPtr ui_title_tile; + mce::MaterialPtr ui_title_tile_shadow; + + Materials(); + }; + public: StartMenuScreen(); ~StartMenuScreen(); @@ -50,8 +61,8 @@ class StartMenuScreen : public Screen void tick() override; void drawSplash(); + void draw2dTitle(); void draw3dTitle(float f); - void drawLegacyTitle(); std::string getSplashString(); @@ -72,8 +83,11 @@ class StartMenuScreen : public Screen int m_chosenSplash; + IntRectangle m_2dTitleBounds; + TileRenderer m_tileRenderer; Random m_random; TitleTile** m_pTiles; + Materials m_screenMaterials; }; diff --git a/source/client/model/Model.cpp b/source/client/model/Model.cpp deleted file mode 100644 index 6c1df5550..000000000 --- a/source/client/model/Model.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************** - Minecraft: Pocket Edition - Decompilation Project - Copyright (C) 2023 iProgramInCpp - - The following code is licensed under the BSD 1 clause license. - SPDX-License-Identifier: BSD-1-Clause - ********************************************************************/ - -#include "Model.hpp" - -Model::Model(int width, int height) -{ - field_4 = 0.0f; - m_bRiding = false; - m_bIsBaby = true; // @HUH: Why is this true? - m_textureWidth = width; - m_textureHeight = height; -} - -void Model::onGraphicsReset() -{ - for (size_t i = 0; i < m_parts.size(); i++) - { - m_parts[i]->m_bCompiled = false; - } -} - -void Model::prepareMobModel(Mob*, float, float, float) -{ - -} - -void Model::render(float, float, float, float, float, float) -{ - -} - -void Model::setupAnim(float, float, float, float, float, float) -{ - -} - -void Model::setBrightness(float) -{ -} diff --git a/source/client/model/Model.hpp b/source/client/model/Model.hpp deleted file mode 100644 index 111bdcd07..000000000 --- a/source/client/model/Model.hpp +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************** - Minecraft: Pocket Edition - Decompilation Project - Copyright (C) 2023 iProgramInCpp - - The following code is licensed under the BSD 1 clause license. - SPDX-License-Identifier: BSD-1-Clause - ********************************************************************/ - -#pragma once - -#include "Cube.hpp" - -class Mob; -class ModelPart; - -class Model -{ -public: - Model(int width, int height); - virtual void onGraphicsReset(); - virtual void prepareMobModel(Mob*, float, float, float); - virtual void render(float, float, float, float, float, float); - virtual void setupAnim(float, float, float, float, float, float); - virtual void setBrightness(float); - -public: - float field_4; - bool m_bRiding; - int m_textureWidth; - int m_textureHeight; - std::vector m_parts; - bool m_bIsBaby; -}; diff --git a/source/client/model/ModelPart.cpp b/source/client/model/ModelPart.cpp deleted file mode 100644 index 43a19ad02..000000000 --- a/source/client/model/ModelPart.cpp +++ /dev/null @@ -1,285 +0,0 @@ -/******************************************************************** - Minecraft: Pocket Edition - Decompilation Project - Copyright (C) 2023 iProgramInCpp - - The following code is licensed under the BSD 1 clause license. - SPDX-License-Identifier: BSD-1-Clause - ********************************************************************/ -#include "ModelPart.hpp" -#include "renderer/GL/GL.hpp" - -#define MUL_DEG_TO_RAD (180.0f / float(M_PI)) // formerly known as Cube::c - -ModelPart::ModelPart(int a, int b) -{ - _init(a, b); -} - -ModelPart::ModelPart(Model* model, int a, int b) -{ - _init(a, b); - setModel(model); -} - -ModelPart::ModelPart(const std::string& baseId) -{ - m_pModel = nullptr; - field_34 = baseId; - field_40 = 0; - field_44 = 0; - _init(); -} - -ModelPart::~ModelPart() -{ - clear(); -} - -void ModelPart::_init() -{ - m_pos = Vec3::ZERO; - m_rot = Vec3::ZERO; - m_buffer = 0; - m_textureWidth = 64.0f; - m_textureHeight = 32.0f; - field_4C = 0; - m_bMirror = false; - field_48 = true; - field_49 = false; - m_bCompiled = false; -} - -void ModelPart::_init(int a, int b) -{ - m_pModel = nullptr; - field_40 = a; - field_44 = b; - _init(); -} - -void ModelPart::addChild(ModelPart* pPart) -{ - m_pChildren.push_back(pPart); -} - -void ModelPart::addBox(float a, float b, float c, int d, int e, int f, float g) -{ - Cube* pCube = new Cube(this, field_40, field_44, a, b, c, d, e, f, g); - m_pCubes.push_back(pCube); -} - -void ModelPart::addBox(const std::string& id, float a, float b, float c, int d, int e, int f, float g) -{ - Cube* pCube = new Cube(this, field_40, field_44, a, b, c, d, e, f, g); - pCube->setId(field_34 + "." + id); - m_pCubes.push_back(pCube); -} - -void ModelPart::clear() -{ - for (size_t i = 0; i < m_pCubes.size(); i++) - delete m_pCubes[i]; - m_pCubes.clear(); - - for (size_t i = 0; i < m_pChildren.size(); i++) - delete m_pChildren[i]; - m_pChildren.clear(); -} - -void ModelPart::compile(float scale) -{ - Tesselator& t = Tesselator::instance; - xglGenBuffers(1, &m_buffer); - t.begin(); - t.color(255, 255, 255, 255); - - // @HUH: Recompiling every cube six times?? -#ifdef ORIGINAL_CODE - for (int i = 0; i < 6; i++) - { -#endif - - for (size_t i = 0; i < m_pCubes.size(); i++) - { - m_pCubes[i]->compile(t, scale); - } - -#ifdef ORIGINAL_CODE - } -#endif - - t.end(m_buffer); - m_bCompiled = true; -} - -void ModelPart::draw() -{ - // We are not using drawArrayVTC here since that would use the color that's compiled initially into the ModelPart - // and would therefore not allow for on-the-fly coloring. - drawArrayVTN(this->m_buffer, 36 * (int)m_pCubes.size(), sizeof(Tesselator::Vertex)); -} - -void ModelPart::drawSlow(float scale) -{ - Tesselator& t = Tesselator::instance; - t.begin(); - - for (size_t i = 0; i < m_pCubes.size(); i++) - { - for (int f = 0; f < 6; f++) - m_pCubes[i]->m_faces[f].render(t, scale); - } - - t.draw(); -} - -void ModelPart::mimic(ModelPart* pPart) -{ - m_pos = pPart->m_pos; - m_rot = pPart->m_rot; -} - -void ModelPart::translatePosTo(float scale) -{ - glTranslatef(m_pos.x * scale, m_pos.y * scale, m_pos.z * scale); -} - -void ModelPart::translateRotTo(float scale) -{ - glTranslatef(m_pos.x * scale, m_pos.y * scale, m_pos.z * scale); - if (m_rot.z != 0) glRotatef(m_rot.z * MUL_DEG_TO_RAD, 0, 0, 1); - if (m_rot.y != 0) glRotatef(m_rot.y * MUL_DEG_TO_RAD, 0, 1, 0); - if (m_rot.x != 0) glRotatef(m_rot.x * MUL_DEG_TO_RAD, 1, 0, 0); -} - -void ModelPart::render(float scale) -{ - if (field_49) - return; - - if (!field_48) - return; - - if (!m_bCompiled) - compile(scale); - - if (!hasDefaultRot()) - { - glPushMatrix(); - - translateRotTo(scale); - draw(); - - glPopMatrix(); - } - else if (!hasDefaultPos()) - { - translatePosTo(scale); - draw(); - translatePosTo(-scale); - } - else - { - draw(); - } -} - -void ModelPart::renderHorrible(float scale) -{ - if (field_49) - return; - - if (!field_48) - return; - - if (!m_bCompiled) - compile(scale); - - if (!hasDefaultRot()) - { - glPushMatrix(); - - translateRotTo(scale); - drawSlow(scale); - - glPopMatrix(); - } - else if (!hasDefaultPos()) - { - translatePosTo(scale); - drawSlow(scale); - translatePosTo(-scale); - } - else - { - drawSlow(scale); - } -} - -void ModelPart::renderRollable(float scale) -{ - if (field_49) - return; - - if (!field_48) - return; - - if (!m_bCompiled) - compile(scale); - - glPushMatrix(); - translatePosTo(scale); - - translateRotTo(scale); - draw(); - - glPopMatrix(); -} - -void ModelPart::setModel(Model* pModel) -{ - m_pModel = pModel; - pModel->m_parts.push_back(this); - setTexSize(pModel->m_textureWidth, pModel->m_textureHeight); -} - -void ModelPart::setPos(const Vec3& pos) -{ - m_pos = pos; -} - -void ModelPart::setPos(float x, float y, float z) -{ - setPos(Vec3(x, y, z)); -} - -void ModelPart::setTexSize(int width, int height) -{ - m_textureWidth = float(width); - m_textureHeight = float(height); -} - -void ModelPart::texOffs(int a, int b) -{ - field_40 = a; - field_44 = b; -} - -void ModelPart::translateTo(float scale) -{ - if (field_49) - return; - - if (!field_48) - return; - - if (!hasDefaultRot()) - translateRotTo(scale); - else if (!hasDefaultPos()) - translatePosTo(scale); -} - -void ModelPart::setBrightness(float brightness) -{ - //no op -} diff --git a/source/client/model/Cube.cpp b/source/client/model/geom/Cube.cpp similarity index 94% rename from source/client/model/Cube.cpp rename to source/client/model/geom/Cube.cpp index 5fdef201e..0268fc36b 100644 --- a/source/client/model/Cube.cpp +++ b/source/client/model/geom/Cube.cpp @@ -7,11 +7,10 @@ ********************************************************************/ #include "Cube.hpp" -#include "renderer/GL/GL.hpp" #define MUL_DEG_TO_RAD (180.0f / float(M_PI)) -Cube::Cube(ModelPart* a2, int a3, int a4, float x, float y, float z, int d, int e, int f, float g) +Cube::Cube(ModelPart* a2, const TextureOffset& texOffs, float x, float y, float z, int d, int e, int f, float g) { float x1 = x, y1 = y, z1 = z; float x2 = x + float(d), y2 = y + float(e), z2 = z + float(f); @@ -42,7 +41,7 @@ Cube::Cube(ModelPart* a2, int a3, int a4, float x, float y, float z, int d, int m_verts[6] = VertexPT(x2, y2, z2, 8.0f, 8.0f); m_verts[7] = VertexPT(x1, y2, z2, 8.0f, 0.0f); - int m = a3, n = a4; + int m = texOffs.x, n = texOffs.y; m_faces[0] = PolygonQuad(&m_verts[5], &m_verts[1], &m_verts[2], &m_verts[6], m + f + d, n + f, m + f + d + f, n + f + e); // x2 face m_faces[1] = PolygonQuad(&m_verts[0], &m_verts[4], &m_verts[7], &m_verts[3], m, n + f, m + f, n + f + e); // x1 face diff --git a/source/client/model/Cube.hpp b/source/client/model/geom/Cube.hpp similarity index 88% rename from source/client/model/Cube.hpp rename to source/client/model/geom/Cube.hpp index 3a2f9e1b8..2c4fd5d00 100644 --- a/source/client/model/Cube.hpp +++ b/source/client/model/geom/Cube.hpp @@ -16,7 +16,7 @@ class ModelPart; class Cube { public: - Cube(ModelPart*, int, int, float, float, float, int, int, int, float); + Cube(ModelPart*, const TextureOffset& texOffs, float, float, float, int, int, int, float); void compile(Tesselator& t, float scale); void setId(const std::string& s); diff --git a/source/client/model/geom/ModelPart.cpp b/source/client/model/geom/ModelPart.cpp new file mode 100644 index 000000000..e97bad4cb --- /dev/null +++ b/source/client/model/geom/ModelPart.cpp @@ -0,0 +1,200 @@ +/******************************************************************** + Minecraft: Pocket Edition - Decompilation Project + Copyright (C) 2023 iProgramInCpp + + The following code is licensed under the BSD 1 clause license. + SPDX-License-Identifier: BSD-1-Clause + ********************************************************************/ +#include "ModelPart.hpp" +#include "../models/Model.hpp" + +#define MUL_DEG_TO_RAD (180.0f / float(M_PI)) // formerly known as Cube::c + +void ModelPart::_init() +{ + m_textureWidth = 64.0f; + m_textureHeight = 32.0f; + m_pMaterial = nullptr; + field_4C = 0; + m_bMirror = false; + field_48 = true; + field_49 = false; + m_bCompiled = false; + m_pModel = nullptr; +} + +void ModelPart::_init(int xTexOffs, int yTexOffs) +{ + _init(); + texOffs(xTexOffs, yTexOffs); +} + +ModelPart::ModelPart(int xTexOffs, int yTexOffs) +{ + _init(xTexOffs, yTexOffs); +} + +ModelPart::ModelPart(Model* model, int xTexOffs, int yTexOffs) +{ + _init(xTexOffs, yTexOffs); + setModel(model); +} + +ModelPart::ModelPart(const std::string& baseId) +{ + _init(); + field_34 = baseId; +} + +ModelPart::~ModelPart() +{ + clear(); +} + +void ModelPart::addChild(ModelPart* pPart) +{ + m_pChildren.push_back(pPart); +} + +void ModelPart::addBox(float a, float b, float c, int d, int e, int f, float g) +{ + Cube* pCube = new Cube(this, m_texOffs, a, b, c, d, e, f, g); + m_pCubes.push_back(pCube); +} + +void ModelPart::addBox(const std::string& id, float a, float b, float c, int d, int e, int f, float g) +{ + Cube* pCube = new Cube(this, m_texOffs, a, b, c, d, e, f, g); + pCube->setId(field_34 + "." + id); + m_pCubes.push_back(pCube); +} + +void ModelPart::clear() +{ + for (size_t i = 0; i < m_pCubes.size(); i++) + delete m_pCubes[i]; + m_pCubes.clear(); + + for (size_t i = 0; i < m_pChildren.size(); i++) + delete m_pChildren[i]; + m_pChildren.clear(); +} + +void ModelPart::compile(float scale) +{ + Tesselator& t = Tesselator::instance; + t.begin(24 * (m_pCubes.size() / 4)); + + for (size_t i = 0; i < m_pCubes.size(); i++) + { + m_pCubes[i]->compile(t, scale); + } + + m_mesh = t.end(); + m_bCompiled = true; +} + +void ModelPart::draw(float scale, const mce::MaterialPtr* materialOverride) +{ + // We are not using drawArrayVTC here since that would use the color that's compiled initially into the ModelPart + // and would therefore not allow for on-the-fly coloring. + //drawArrayVTN(this->m_buffer, 36 * (int)m_pCubes.size()); + + if (!m_mesh.isValid()) + compile(scale); + + mce::MaterialPtr& materialPtr = m_pMaterial ? *m_pMaterial : (m_pModel ? *m_pModel->m_pMaterial : mce::MaterialPtr::NONE); + m_mesh.render(materialOverride ? *materialOverride : materialPtr); +} + +void ModelPart::mimic(const ModelPart& other) +{ + m_pos = other.m_pos; + m_rot = other.m_rot; +} + +void ModelPart::translatePosTo(Matrix& matrix, float scale) +{ + matrix.translate(m_pos * scale); +} + +void ModelPart::translateRotTo(Matrix& matrix, float scale) +{ + translatePosTo(matrix, scale); + if (m_rot.z != 0.0f) matrix.rotate(m_rot.z * MUL_DEG_TO_RAD, Vec3::UNIT_Z); + if (m_rot.y != 0.0f) matrix.rotate(m_rot.y * MUL_DEG_TO_RAD, Vec3::UNIT_Y); + if (m_rot.x != 0.0f) matrix.rotate(m_rot.x * MUL_DEG_TO_RAD, Vec3::UNIT_X); +} + +void ModelPart::render(float scale, const mce::MaterialPtr* materialOverride) +{ + if (field_49) + return; + + if (!field_48) + return; + + if (!m_bCompiled) + compile(scale); + + if (!hasDefaultRot()) + { + MatrixStack::Ref mtx = MatrixStack::World.push(); + + translateRotTo(mtx, scale); + draw(scale, materialOverride); + } + else if (!hasDefaultPos()) + { + MatrixStack::Ref mtx = MatrixStack::World.push(); + + translatePosTo(mtx, scale); + draw(scale, materialOverride); + } + else + { + draw(scale, materialOverride); + } +} + +void ModelPart::setModel(Model* pModel) +{ + m_pModel = pModel; + pModel->m_parts.push_back(this); + setTexSize(pModel->m_textureWidth, pModel->m_textureHeight); +} + +void ModelPart::setPos(const Vec3& pos) +{ + m_pos = pos; +} + +void ModelPart::setPos(float x, float y, float z) +{ + setPos(Vec3(x, y, z)); +} + +void ModelPart::setTexSize(int width, int height) +{ + m_textureWidth = float(width); + m_textureHeight = float(height); +} + +void ModelPart::texOffs(int xTexOffs, int yTexOffs) +{ + m_texOffs.x = xTexOffs; + m_texOffs.y = yTexOffs; +} + +void ModelPart::translateTo(Matrix& matrix, float scale) +{ + if (!hasDefaultRot()) + translateRotTo(matrix, scale); + else if (!hasDefaultPos()) + translatePosTo(matrix, scale); +} + +void ModelPart::setBrightness(float brightness) +{ + //no op +} diff --git a/source/client/model/ModelPart.hpp b/source/client/model/geom/ModelPart.hpp similarity index 73% rename from source/client/model/ModelPart.hpp rename to source/client/model/geom/ModelPart.hpp index 104a2ae6a..e0b1d84c4 100644 --- a/source/client/model/ModelPart.hpp +++ b/source/client/model/geom/ModelPart.hpp @@ -8,15 +8,20 @@ #pragma once #include -#include "Cube.hpp" -#include "Model.hpp" +#include "renderer/MatrixStack.hpp" +#include "renderer/Mesh.hpp" #include "world/phys/Vec3.hpp" +#include "TextureOffset.hpp" class Cube; class Model; class ModelPart { +private: + void _init(); + void _init(int, int); + public: ModelPart(int, int); ModelPart(Model*, int, int); @@ -28,27 +33,22 @@ class ModelPart void addBox(const std::string& id, float a, float b, float c, int d, int e, int f, float g = 0); void clear(); void compile(float scale); - void draw(); - void drawSlow(float scale); - void mimic(ModelPart* pPart); - void render(float scale); - void renderHorrible(float scale); - void renderRollable(float scale); + void draw(float scale, const mce::MaterialPtr* materialOverride = nullptr); + void mimic(const ModelPart& other); + void render(float scale, const mce::MaterialPtr* materialOverride = nullptr); void setModel(Model* pModel); void setPos(const Vec3& pos); void setPos(float x, float y, float z); void setTexSize(int, int); void texOffs(int a, int b); - void translateTo(float scale); + void translateTo(Matrix& matrix, float scale); void setBrightness(float brightness); private: - void _init(); - void _init(int, int); bool hasDefaultPos() { return m_pos == Vec3::ZERO; } bool hasDefaultRot() { return m_rot == Vec3::ZERO; } - void translatePosTo(float scale); - void translateRotTo(float scale); + void translatePosTo(Matrix& matrix, float scale); + void translateRotTo(Matrix& matrix, float scale); public: Vec3 m_pos; @@ -59,13 +59,13 @@ class ModelPart std::string field_34; float m_textureWidth; float m_textureHeight; - int field_40; - int field_44; + mce::MaterialPtr* m_pMaterial; + TextureOffset m_texOffs; bool field_48; bool field_49; bool m_bCompiled; int field_4C; - GLuint m_buffer; + mce::Mesh m_mesh; Model* m_pModel; }; diff --git a/source/client/model/PolygonQuad.cpp b/source/client/model/geom/PolygonQuad.cpp similarity index 100% rename from source/client/model/PolygonQuad.cpp rename to source/client/model/geom/PolygonQuad.cpp diff --git a/source/client/model/PolygonQuad.hpp b/source/client/model/geom/PolygonQuad.hpp similarity index 100% rename from source/client/model/PolygonQuad.hpp rename to source/client/model/geom/PolygonQuad.hpp diff --git a/source/client/model/geom/TextureOffset.hpp b/source/client/model/geom/TextureOffset.hpp new file mode 100644 index 000000000..e1885494e --- /dev/null +++ b/source/client/model/geom/TextureOffset.hpp @@ -0,0 +1,19 @@ +#pragma once + +struct TextureOffset +{ + int x; + int y; + + TextureOffset() + { + x = 0; + y = 0; + } + + TextureOffset(int x, int y) + : x(x) + , y(y) + { + } +}; \ No newline at end of file diff --git a/source/client/model/ChickenModel.cpp b/source/client/model/models/ChickenModel.cpp similarity index 81% rename from source/client/model/ChickenModel.cpp rename to source/client/model/models/ChickenModel.cpp index 655c065b4..a90bc6f31 100644 --- a/source/client/model/ChickenModel.cpp +++ b/source/client/model/models/ChickenModel.cpp @@ -20,6 +20,8 @@ ChickenModel::ChickenModel() : m_beak(this, 14, 0), m_wattle(this, 14, 4) // Yes, it's called a wattle. Look it up. { + m_pMaterial = &m_materials.entity_alphatest; + m_head.addBox(-2, -6, -2, 4, 6, 3); m_head.setPos(0, 15, -4); m_beak.addBox(-2, -4, -4, 4, 2, 2, 0); @@ -48,21 +50,26 @@ void ChickenModel::render(float a, float b, float c, float d, float e, float f) if (m_bIsBaby) { - glPushMatrix(); - glTranslatef(0.0f, f * 5.0f, f * 2.0f); - m_head.render(f); - m_beak.render(f); - m_wattle.render(f); - glPopMatrix(); - glPushMatrix(); - glScalef(0.5f, 0.5f, 0.5f); - glTranslatef(0.0f, f * 24.0f, 0.0f); - m_body.render(f); - m_leg1.render(f); - m_leg2.render(f); - m_wing1.render(f); - m_wing2.render(f); - glPopMatrix(); + { + MatrixStack::Ref matrix = MatrixStack::World.push(); + matrix->translate(Vec3(0.0f, f * 5.0f, f * 2.0f)); + + m_head.render(f); + m_beak.render(f); + m_wattle.render(f); + } + + { + MatrixStack::Ref matrix = MatrixStack::World.push(); + matrix->scale(0.5f); + matrix->translate(Vec3(0.0f, f * 24.0f, 0.0f)); + + m_body.render(f); + m_leg1.render(f); + m_leg2.render(f); + m_wing1.render(f); + m_wing2.render(f); + } } else { diff --git a/source/client/model/ChickenModel.hpp b/source/client/model/models/ChickenModel.hpp similarity index 100% rename from source/client/model/ChickenModel.hpp rename to source/client/model/models/ChickenModel.hpp diff --git a/source/client/model/CowModel.cpp b/source/client/model/models/CowModel.cpp similarity index 100% rename from source/client/model/CowModel.cpp rename to source/client/model/models/CowModel.cpp diff --git a/source/client/model/CowModel.hpp b/source/client/model/models/CowModel.hpp similarity index 100% rename from source/client/model/CowModel.hpp rename to source/client/model/models/CowModel.hpp diff --git a/source/client/model/CreeperModel.cpp b/source/client/model/models/CreeperModel.cpp similarity index 100% rename from source/client/model/CreeperModel.cpp rename to source/client/model/models/CreeperModel.cpp diff --git a/source/client/model/CreeperModel.hpp b/source/client/model/models/CreeperModel.hpp similarity index 100% rename from source/client/model/CreeperModel.hpp rename to source/client/model/models/CreeperModel.hpp diff --git a/source/client/model/HumanoidModel.cpp b/source/client/model/models/HumanoidModel.cpp similarity index 100% rename from source/client/model/HumanoidModel.cpp rename to source/client/model/models/HumanoidModel.cpp diff --git a/source/client/model/HumanoidModel.hpp b/source/client/model/models/HumanoidModel.hpp similarity index 100% rename from source/client/model/HumanoidModel.hpp rename to source/client/model/models/HumanoidModel.hpp diff --git a/source/client/model/models/Model.cpp b/source/client/model/models/Model.cpp new file mode 100644 index 000000000..b7a4282c9 --- /dev/null +++ b/source/client/model/models/Model.cpp @@ -0,0 +1,76 @@ +/******************************************************************** + Minecraft: Pocket Edition - Decompilation Project + Copyright (C) 2023 iProgramInCpp + + The following code is licensed under the BSD 1 clause license. + SPDX-License-Identifier: BSD-1-Clause + ********************************************************************/ + +#include "Model.hpp" +#include "client/renderer/renderer/RenderMaterialGroup.hpp" + +Model::Materials::Materials() +{ + MATERIAL_PTR(switchable, entity); + MATERIAL_PTR(switchable, entity_alphatest); + MATERIAL_PTR(switchable, entity_alphatest_cull); + MATERIAL_PTR(switchable, entity_alphablend); + MATERIAL_PTR(switchable, entity_static); + MATERIAL_PTR(switchable, entity_emissive); + MATERIAL_PTR(switchable, entity_emissive_alpha); + MATERIAL_PTR(switchable, entity_change_color); + MATERIAL_PTR(switchable, entity_color_overlay); + MATERIAL_PTR(switchable, entity_glint); + MATERIAL_PTR(switchable, entity_alphatest_glint); +} + +Model::Model(int width, int height) +{ + field_4 = 0.0f; + m_bRiding = false; + m_bIsBaby = true; // @HUH: Why is this true? + m_textureWidth = width; + m_textureHeight = height; + m_pMaterial = &m_materials.entity; +} + +void Model::clear() +{ + for (size_t i = 0; i < m_parts.size(); i++) + { + m_parts[i]->m_mesh.reset(); + } +} + +void Model::onGraphicsReset() +{ + for (size_t i = 0; i < m_parts.size(); i++) + { + m_parts[i]->m_bCompiled = false; + } +} + +void Model::prepareMobModel(const Mob& mob, float, float, float) +{ + +} + +void Model::render(float, float, float, float, float, float) +{ + +} + +void Model::setupAnim(float, float, float, float, float, float) +{ + +} + +void Model::setBrightness(float) +{ +} + +void Model::copyModelPart(const ModelPart& a, ModelPart& b) +{ + b.m_rot = a.m_rot; + b.m_pos = a.m_pos; +} diff --git a/source/client/model/models/Model.hpp b/source/client/model/models/Model.hpp new file mode 100644 index 000000000..f3f2a75ee --- /dev/null +++ b/source/client/model/models/Model.hpp @@ -0,0 +1,59 @@ +/******************************************************************** + Minecraft: Pocket Edition - Decompilation Project + Copyright (C) 2023 iProgramInCpp + + The following code is licensed under the BSD 1 clause license. + SPDX-License-Identifier: BSD-1-Clause + ********************************************************************/ + +#pragma once + +#include "client/model/geom/Cube.hpp" +#include "client/app/AppPlatformListener.hpp" +#include "renderer/MaterialPtr.hpp" + +class Mob; +class ModelPart; + +class Model : public AppPlatformListener +{ +protected: + class Materials + { + public: + mce::MaterialPtr entity; + mce::MaterialPtr entity_alphatest; + mce::MaterialPtr entity_alphatest_cull; + mce::MaterialPtr entity_alphablend; + mce::MaterialPtr entity_static; + mce::MaterialPtr entity_emissive; + mce::MaterialPtr entity_emissive_alpha; + mce::MaterialPtr entity_change_color; + mce::MaterialPtr entity_color_overlay; + mce::MaterialPtr entity_glint; + mce::MaterialPtr entity_alphatest_glint; + + Materials(); + }; + +public: + Model(int width, int height); + virtual void clear(); + virtual void onGraphicsReset(); + virtual void prepareMobModel(const Mob&, float, float, float); + virtual void render(float, float, float, float, float, float); + virtual void setupAnim(float, float, float, float, float, float); + virtual void setBrightness(float); + + static void copyModelPart(const ModelPart& a, ModelPart& b); + +public: + float field_4; + bool m_bRiding; + bool m_bIsBaby; + int m_textureWidth; + int m_textureHeight; + mce::MaterialPtr* m_pMaterial; + Materials m_materials; + std::vector m_parts; +}; diff --git a/source/client/model/PigModel.cpp b/source/client/model/models/PigModel.cpp similarity index 79% rename from source/client/model/PigModel.cpp rename to source/client/model/models/PigModel.cpp index 3d6699dde..ab8bd17f0 100644 --- a/source/client/model/PigModel.cpp +++ b/source/client/model/models/PigModel.cpp @@ -10,6 +10,8 @@ PigModel::PigModel(float f) : QuadrupedModel(6, f) { + // this prevents the nose from appearing black if using the old flat-nosed texture + m_pMaterial = &m_materials.entity_alphatest_cull; m_head.texOffs(16, 16); m_head.addBox(-2, 0, -9, 4, 3, 1, f); field_28C = 4.0f; diff --git a/source/client/model/PigModel.hpp b/source/client/model/models/PigModel.hpp similarity index 100% rename from source/client/model/PigModel.hpp rename to source/client/model/models/PigModel.hpp diff --git a/source/client/model/QuadrupedModel.cpp b/source/client/model/models/QuadrupedModel.cpp similarity index 87% rename from source/client/model/QuadrupedModel.cpp rename to source/client/model/models/QuadrupedModel.cpp index 9dcaf8313..a1481478e 100644 --- a/source/client/model/QuadrupedModel.cpp +++ b/source/client/model/models/QuadrupedModel.cpp @@ -46,19 +46,22 @@ void QuadrupedModel::render(float a, float b, float c, float d, float e, float f if (m_bIsBaby) { - glPushMatrix(); - glTranslatef(0.0f, f * field_28C, f * field_290); - m_head.render(f); - glPopMatrix(); - glPushMatrix(); - glScalef(0.5f, 0.5f, 0.5f); - glTranslatef(0.0f, f * 24.0f, 0.0f); + { + MatrixStack::Ref matrix = MatrixStack::World.push(); + matrix->translate(Vec3(0.0f, f * field_28C, f * field_290)); + + m_head.render(f); + } + + MatrixStack::Ref matrix = MatrixStack::World.push(); + matrix->scale(0.5f); + matrix->translate(Vec3(0.0f, f * 24.0f, 0.0f)); + m_body.render(f); m_leg1.render(f); m_leg2.render(f); m_leg3.render(f); m_leg4.render(f); - glPopMatrix(); } else { diff --git a/source/client/model/QuadrupedModel.hpp b/source/client/model/models/QuadrupedModel.hpp similarity index 100% rename from source/client/model/QuadrupedModel.hpp rename to source/client/model/models/QuadrupedModel.hpp diff --git a/source/client/model/SheepFurModel.cpp b/source/client/model/models/SheepFurModel.cpp similarity index 100% rename from source/client/model/SheepFurModel.cpp rename to source/client/model/models/SheepFurModel.cpp diff --git a/source/client/model/SheepFurModel.hpp b/source/client/model/models/SheepFurModel.hpp similarity index 100% rename from source/client/model/SheepFurModel.hpp rename to source/client/model/models/SheepFurModel.hpp diff --git a/source/client/model/SheepModel.cpp b/source/client/model/models/SheepModel.cpp similarity index 100% rename from source/client/model/SheepModel.cpp rename to source/client/model/models/SheepModel.cpp diff --git a/source/client/model/SheepModel.hpp b/source/client/model/models/SheepModel.hpp similarity index 100% rename from source/client/model/SheepModel.hpp rename to source/client/model/models/SheepModel.hpp diff --git a/source/client/model/SkeletonModel.cpp b/source/client/model/models/SkeletonModel.cpp similarity index 92% rename from source/client/model/SkeletonModel.cpp rename to source/client/model/models/SkeletonModel.cpp index 61af699af..945c9d87b 100644 --- a/source/client/model/SkeletonModel.cpp +++ b/source/client/model/models/SkeletonModel.cpp @@ -2,6 +2,8 @@ SkeletonModel::SkeletonModel() : ZombieModel() { + m_pMaterial = &m_materials.entity_alphatest; + m_arm1.clear(); m_arm2.clear(); m_leg1.clear(); diff --git a/source/client/model/SkeletonModel.hpp b/source/client/model/models/SkeletonModel.hpp similarity index 100% rename from source/client/model/SkeletonModel.hpp rename to source/client/model/models/SkeletonModel.hpp diff --git a/source/client/model/SpiderModel.cpp b/source/client/model/models/SpiderModel.cpp similarity index 89% rename from source/client/model/SpiderModel.cpp rename to source/client/model/models/SpiderModel.cpp index 732043e29..204a0eed8 100644 --- a/source/client/model/SpiderModel.cpp +++ b/source/client/model/models/SpiderModel.cpp @@ -2,20 +2,20 @@ SpiderModel::SpiderModel() : Model(64, 64), - m_head(32, 4), - m_body0(0, 0), - m_body1(0, 12), - m_leg0(18, 0), - m_leg1(18, 0), - m_leg2(18, 0), - m_leg3(18, 0), - m_leg4(18, 0), - m_leg5(18, 0), - m_leg6(18, 0), - m_leg7(18, 0) + m_head(this, 32, 4), + m_body0(this, 0, 0), + m_body1(this, 0, 12), + m_leg0(this, 18, 0), + m_leg1(this, 18, 0), + m_leg2(this, 18, 0), + m_leg3(this, 18, 0), + m_leg4(this, 18, 0), + m_leg5(this, 18, 0), + m_leg6(this, 18, 0), + m_leg7(this, 18, 0) { - static float g = 0.0f; - static int yo = 15; + constexpr float g = 0.0f; + constexpr int yo = 15; m_head.addBox(-4.0f, -4.0f, -8.0f, 8, 8, 8, g); m_head.addBox(-4.0f, -4.0f, -8.0f, 8, 8, 8, g); @@ -77,7 +77,7 @@ void SpiderModel::setupAnim(float time, float r, float bob, float yRot, float xR m_head.m_rot.y = yRot / 57.295776f; m_head.m_rot.x = xRot / 57.295776f; - static float sr = 0.7853982f; + constexpr float sr = 0.7853982f; m_leg0.m_rot.z = -sr; m_leg1.m_rot.z = sr; m_leg2.m_rot.z = -sr * 0.74f; @@ -87,8 +87,8 @@ void SpiderModel::setupAnim(float time, float r, float bob, float yRot, float xR m_leg6.m_rot.z = -sr; m_leg7.m_rot.z = sr; - static float ro = -0.0f; - static float ur = 0.3926991f; + constexpr float ro = -0.0f; + constexpr float ur = 0.3926991f; m_leg0.m_rot.y = ur * 2.0f + ro; m_leg1.m_rot.y = -ur * 2.0f - ro; m_leg2.m_rot.y = ur * 1.0f + ro; diff --git a/source/client/model/SpiderModel.hpp b/source/client/model/models/SpiderModel.hpp similarity index 100% rename from source/client/model/SpiderModel.hpp rename to source/client/model/models/SpiderModel.hpp diff --git a/source/client/model/ZombieModel.cpp b/source/client/model/models/ZombieModel.cpp similarity index 100% rename from source/client/model/ZombieModel.cpp rename to source/client/model/models/ZombieModel.cpp diff --git a/source/client/model/ZombieModel.hpp b/source/client/model/models/ZombieModel.hpp similarity index 100% rename from source/client/model/ZombieModel.hpp rename to source/client/model/models/ZombieModel.hpp diff --git a/source/client/network/ClientSideNetworkHandler.cpp b/source/client/network/ClientSideNetworkHandler.cpp index ceb8f4bd3..e74d348d1 100644 --- a/source/client/network/ClientSideNetworkHandler.cpp +++ b/source/client/network/ClientSideNetworkHandler.cpp @@ -90,7 +90,7 @@ void ClientSideNetworkHandler::onDisconnect(const RakNet::RakNetGUID& rakGuid) if (m_pLevel) m_pLevel->m_bIsClientSide = false; - m_pMinecraft->m_gui.addMessage("Disconnected from server"); + m_pMinecraft->m_pGui->addMessage("Disconnected from server"); } void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, LoginStatusPacket* pPacket) @@ -112,7 +112,7 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, Message { puts_ignorable("MessagePacket"); - m_pMinecraft->m_gui.addMessage(pMsgPkt->m_str.C_String()); + m_pMinecraft->m_pGui->addMessage(pMsgPkt->m_str.C_String()); } void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, SetTimePacket* pPacket) @@ -192,7 +192,7 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, AddPlay *pItem = ItemInstance(pAddPlayerPkt->m_itemId, pAddPlayerPkt->m_itemAuxValue, 63); } - m_pMinecraft->m_gui.addMessage(pPlayer->m_name + " joined the game"); + m_pMinecraft->m_pGui->addMessage(pPlayer->m_name + " joined the game"); } void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, AddMobPacket* pAddMobPkt) diff --git a/source/client/player/input/TouchInputHolder.cpp b/source/client/player/input/TouchInputHolder.cpp index 6decfccba..95f7873fe 100644 --- a/source/client/player/input/TouchInputHolder.cpp +++ b/source/client/player/input/TouchInputHolder.cpp @@ -58,6 +58,6 @@ void TouchInputHolder::setScreenSize(int width, int height) { m_touchScreenInput.setScreenSize(width, height); m_unifiedTurnBuild.field_40 = m_touchScreenInput.getRectangleArea(); - m_unifiedTurnBuild.field_58 = m_pMinecraft->m_gui.getRectangleArea(false); + m_unifiedTurnBuild.field_58 = m_pMinecraft->m_pGui->getRectangleArea(false); m_unifiedTurnBuild.setScreenSize(width, height); } diff --git a/source/client/player/input/TouchscreenInput_TestFps.cpp b/source/client/player/input/TouchscreenInput_TestFps.cpp index 5021c92a3..63a20c226 100644 --- a/source/client/player/input/TouchscreenInput_TestFps.cpp +++ b/source/client/player/input/TouchscreenInput_TestFps.cpp @@ -11,6 +11,7 @@ #include "GameMods.hpp" #include "client/app/Minecraft.hpp" #include "client/options/Options.hpp" +#include "renderer/ShaderConstants.hpp" #include "world/entity/Player.hpp" TouchscreenInput_TestFps::TouchscreenInput_TestFps(Minecraft* pMinecraft, Options* pOptions) : @@ -308,14 +309,13 @@ static void RenderTouchButton(Tesselator* t, PolygonArea* pArea, int srcX, int s void TouchscreenInput_TestFps::render(float f) { - glDisable(GL_CULL_FACE); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - m_pMinecraft->m_pTextures->loadAndBindTexture("gui/gui.png"); + currentShaderColor = Color::WHITE; + currentShaderDarkColor = Color::WHITE; + Tesselator& t = Tesselator::instance; - t.begin(); + t.begin(0); #ifdef ENH_NEW_TOUCH_CONTROLS if (field_40 && !isButtonDown(100 + INPUT_JUMP)) { @@ -369,10 +369,7 @@ void TouchscreenInput_TestFps::render(float f) t.color(isButtonDown(100 + INPUT_JUMP) ? 0xC0C0C0 : 0xFFFFFF, 0x80); RenderTouchButton(&t, m_pAreaJump, 0, 176); #endif - t.draw(); - - glDisable(GL_BLEND); - glEnable(GL_CULL_FACE); + t.draw(m_materials.ui_texture_and_color_nocull); } RectangleArea TouchscreenInput_TestFps::getRectangleArea() diff --git a/source/client/renderer/Chunk.cpp b/source/client/renderer/Chunk.cpp index 42e70634e..a9b544d1f 100644 --- a/source/client/renderer/Chunk.cpp +++ b/source/client/renderer/Chunk.cpp @@ -7,24 +7,25 @@ ********************************************************************/ #include "Chunk.hpp" +#include "renderer/RenderContextImmediate.hpp" #include "world/level/Level.hpp" #include "world/level/Region.hpp" #include "TileRenderer.hpp" int Chunk::updates; -float Chunk::distanceToSqr(const Entity* pEnt) const +float Chunk::distanceToSqr(const Entity& entity) const { - float dX = pEnt->m_pos.x - float(m_pos2.x); - float dY = pEnt->m_pos.y - float(m_pos2.y); - float dZ = pEnt->m_pos.z - float(m_pos2.z); + float dX = entity.m_pos.x - float(m_posM.x); + float dY = entity.m_pos.y - float(m_posM.y); + float dZ = entity.m_pos.z - float(m_posM.z); return dX * dX + dY * dY + dZ * dZ; } -float Chunk::squishedDistanceToSqr(const Entity* pEnt) const +float Chunk::squishedDistanceToSqr(const Entity& entity) const { - float dX = pEnt->m_pos.x - float(m_pos2.x); - float dY = pEnt->m_pos.y - float(m_pos2.y); - float dZ = pEnt->m_pos.z - float(m_pos2.z); + float dX = entity.m_pos.x - float(m_posM.x); + float dY = entity.m_pos.y - float(m_posM.y); + float dZ = entity.m_pos.z - float(m_posM.z); dY *= 2; @@ -33,39 +34,41 @@ float Chunk::squishedDistanceToSqr(const Entity* pEnt) const void Chunk::reset() { - field_1C[0] = true; - field_1C[1] = true; + for (int i = Tile::RENDER_LAYERS_MIN; i <= Tile::RENDER_LAYERS_MAX; i++) + { + m_empty[i] = true; + } m_bVisible = false; - field_94 = false; + m_bCompiled = false; } -int Chunk::getList(int idx) +int Chunk::getList(Tile::RenderLayer layer) { if (!m_bVisible) return -1; - if (field_1C[idx]) + if (m_empty[layer]) return -1; - return field_8C + idx; + return m_lists + layer; } -RenderChunk* Chunk::getRenderChunk(int idx) +RenderChunk* Chunk::getRenderChunk(Tile::RenderLayer layer) { - return &m_renderChunks[idx]; + return &m_renderChunks[layer]; } -int Chunk::getAllLists(int* arr, int arr_idx, int idx) +int Chunk::getAllLists(int* displayLists, int p, Tile::RenderLayer layer) { if (!m_bVisible) - return arr_idx; + return p; - if (field_1C[idx]) - return arr_idx; + if (m_empty[layer]) + return p; - arr[arr_idx++] = field_8C + idx; + displayLists[p++] = m_lists + layer; - return arr_idx; + return p; } void Chunk::cull(Culler* pCuller) @@ -75,20 +78,20 @@ void Chunk::cull(Culler* pCuller) void Chunk::renderBB() { - + //glCallList(m_lists + 2); } bool Chunk::isEmpty() { - if (!field_94) - return false; - - if (!field_1C[0]) - return false; - - if (!field_1C[1]) + if (!m_bCompiled) return false; + for (int i = Tile::RENDER_LAYERS_MIN; i <= Tile::RENDER_LAYERS_MAX; i++) + { + if (!m_empty[i]) + return false; + } + return true; } @@ -104,9 +107,9 @@ void Chunk::setPos(const TilePos& pos) return; m_pos = pos; - m_pos2 = pos + field_10 / 2; + m_posM = pos + m_posS / 2; - m_aabb = AABB(m_pos - 1, m_pos + field_10 + 1); + m_aabb = AABB(m_pos - 1, m_pos + m_posS + 1); setDirty(); } @@ -130,20 +133,22 @@ void Chunk::rebuild() LevelChunk::touchedSky = false; - field_1C[0] = true; - field_1C[1] = true; - - TilePos min(m_pos), max(m_pos + field_10); + for (int i = Tile::RENDER_LAYERS_MIN; i <= Tile::RENDER_LAYERS_MAX; i++) + { + m_empty[i] = true; + } + TilePos min(m_pos), max(m_pos + m_posS); Region region(m_pLevel, min - 1, max + 1); - TileRenderer tileRenderer(®ion); + mce::RenderContext& renderContext = mce::RenderContextImmediate::get(); Tesselator& t = Tesselator::instance; + TileRenderer tileRenderer(t, ®ion); TilePos tp(min); - for (int layer = 0; layer < 2; layer++) + for (int layer = Tile::RENDER_LAYERS_MIN; layer <= Tile::RENDER_LAYERS_MAX; layer++) { - bool bTesselatedAnything = false, bDrewThisLayer = false, bNeedAnotherLayer = false; + bool started = false, rendered = false, renderNextLayer = false; for (tp.y = min.y; tp.y < max.y; tp.y++) { for (tp.z = min.z; tp.z < max.z; tp.z++) @@ -153,13 +158,15 @@ void Chunk::rebuild() TileID tile = region.getTile(tp); if (tile <= 0) continue; - if (!bTesselatedAnything) + if (!started) { - bTesselatedAnything = true; + started = true; if (tileRenderer.useAmbientOcclusion()) - glShadeModel(GL_SMOOTH); - t.begin(); - t.offset(float(-m_pos.x), float(-m_pos.y), float(-m_pos.z)); + { + renderContext.setShadeMode(mce::SHADE_MODE_SMOOTH); + } + t.begin(12000); + t.setOffset(-m_pos); } Tile* pTile = Tile::tiles[tile]; @@ -167,59 +174,50 @@ void Chunk::rebuild() if (layer == pTile->getRenderLayer()) { if (tileRenderer.tesselateInWorld(pTile, tp)) - bDrewThisLayer = true; + rendered = true; } else { - bNeedAnotherLayer = true; + renderNextLayer = true; } } } } - if (bTesselatedAnything) + if (started) { - RenderChunk rchk = t.end(field_90[layer]); + mce::Mesh chunkMesh = t.end(); RenderChunk* pRChk = &m_renderChunks[layer]; - *pRChk = rchk; - pRChk->field_C = float(m_pos.x); - pRChk->field_10 = float(m_pos.y); - pRChk->field_14 = float(m_pos.z); + *pRChk = RenderChunk(m_pos, chunkMesh); - t.offset(0.0f, 0.0f, 0.0f); + t.setOffset(Vec3::ZERO); - if (bDrewThisLayer) - field_1C[layer] = false; + if (rendered) + m_empty[layer] = false; } - if (!bNeedAnotherLayer) + if (!renderNextLayer) break; } field_54 = LevelChunk::touchedSky; - field_94 = true; -} - -void Chunk::translateToPos() -{ - glTranslatef(float(m_pos.x), float(m_pos.y), float(m_pos.z)); + m_bCompiled = true; } -Chunk::Chunk(Level* level, const TilePos& pos, int a, int b, GLuint* bufs) +Chunk::Chunk(Level* level, const TilePos& pos, int size, int lists) { - field_4D = true; - field_4E = false; - field_94 = false; + m_bOcclusionVisible = true; + m_bOcclusionQuerying = false; + m_bCompiled = false; m_bDirty = false; m_pLevel = level; - field_10 = TilePos(a, a, a); + m_posS = TilePos(size, size, size); m_pTesselator = &Tesselator::instance; - field_8C = b; + m_lists = lists; m_pos.x = -999; field_2C = Vec3(pos).lengthSqr() / 2; - field_90 = bufs; setPos(pos); } diff --git a/source/client/renderer/Chunk.hpp b/source/client/renderer/Chunk.hpp index 3bf2f88fc..aa12f31df 100644 --- a/source/client/renderer/Chunk.hpp +++ b/source/client/renderer/Chunk.hpp @@ -8,6 +8,7 @@ #pragma once +#include "world/tile/Tile.hpp" #include "FrustumCuller.hpp" #include "RenderList.hpp" #include "Tesselator.hpp" @@ -18,14 +19,15 @@ class Entity; class Chunk { public: - Chunk(Level*, const TilePos& pos, int, int, GLuint*); + Chunk(Level*, const TilePos& pos, int, int); - float distanceToSqr(const Entity*) const; - float squishedDistanceToSqr(const Entity*) const; +public: + float distanceToSqr(const Entity& entity) const; + float squishedDistanceToSqr(const Entity& entity) const; void reset(); - int getList(int idx); - RenderChunk* getRenderChunk(int idx); - int getAllLists(int* arr, int arr_idx, int idx); + int getList(Tile::RenderLayer layer); + RenderChunk* getRenderChunk(Tile::RenderLayer layer); + int getAllLists(int* displayLists, int p, Tile::RenderLayer layer); void cull(Culler* pCuller); void renderBB(); bool isEmpty(); @@ -34,7 +36,6 @@ class Chunk void setClean(); bool isDirty(); void rebuild(); - void translateToPos(); public: static int updates; @@ -42,22 +43,23 @@ class Chunk public: Level* m_pLevel; TilePos m_pos; - TilePos field_10; - bool field_1C[2]; - TilePos m_pos2; + TilePos m_posS; + bool m_empty[Tile::RENDER_LAYERS_COUNT]; + TilePos m_posM; float field_2C; AABB m_aabb; - int field_48; + int m_id; bool m_bVisible; - bool field_4D; - bool field_4E; - int field_50; + bool m_bOcclusionVisible; + bool m_bOcclusionQuerying; + int m_occlusionId; bool field_54; - RenderChunk m_renderChunks[2]; + RenderChunk m_renderChunks[Tile::RENDER_LAYERS_COUNT]; Tesselator* m_pTesselator; - int field_8C; - GLuint* field_90; - bool field_94; +private: + int m_lists; +public: + bool m_bCompiled; bool m_bDirty; }; diff --git a/source/client/renderer/Culler.cpp b/source/client/renderer/Culler.cpp index 190781ab0..f9894f80d 100644 --- a/source/client/renderer/Culler.cpp +++ b/source/client/renderer/Culler.cpp @@ -8,7 +8,7 @@ #include "Culler.hpp" -void Culler::prepare(float x, float y, float z) +void Culler::prepare(const Vec3& camPos) { } diff --git a/source/client/renderer/Culler.hpp b/source/client/renderer/Culler.hpp index 2e08df8a8..77b5015ac 100644 --- a/source/client/renderer/Culler.hpp +++ b/source/client/renderer/Culler.hpp @@ -14,9 +14,8 @@ class Culler { public: virtual ~Culler(); - virtual bool isVisible(const AABB&) = 0; - virtual bool cubeInFrustum(float, float, float, float, float, float) = 0; - virtual bool cubeFullyInFrustum(float, float, float, float, float, float) = 0; - virtual void prepare(float, float, float); + virtual bool isVisible(const AABB& aabb) = 0; + virtual bool cubeInFrustum(const Vec3& min, const Vec3& max) = 0; + virtual void prepare(const Vec3& camPos); }; diff --git a/source/client/renderer/DynamicTexture.cpp b/source/client/renderer/DynamicTexture.cpp index e05e6f1a9..a482ef898 100644 --- a/source/client/renderer/DynamicTexture.cpp +++ b/source/client/renderer/DynamicTexture.cpp @@ -17,9 +17,9 @@ DynamicTexture::DynamicTexture(int a2) : m_textureIndex(a2) memset(m_pixels, 0, sizeof m_pixels); } -bool DynamicTexture::bindTexture(Textures* pTextures) +TextureData* DynamicTexture::bindTexture(Textures* pTextures) { - return pTextures->loadAndBindTexture(C_TERRAIN_NAME) != -1; + return pTextures->loadAndBindTexture(C_TERRAIN_NAME); } DynamicTexture::~DynamicTexture() diff --git a/source/client/renderer/DynamicTexture.hpp b/source/client/renderer/DynamicTexture.hpp index a0f690d08..6e1f59e0f 100644 --- a/source/client/renderer/DynamicTexture.hpp +++ b/source/client/renderer/DynamicTexture.hpp @@ -19,7 +19,7 @@ class DynamicTexture { public: virtual void tick() = 0; - virtual bool bindTexture(Textures*); + virtual TextureData* bindTexture(Textures*); DynamicTexture(int a2); virtual ~DynamicTexture(); diff --git a/source/client/renderer/Fog.cpp b/source/client/renderer/Fog.cpp new file mode 100644 index 000000000..8f1e12634 --- /dev/null +++ b/source/client/renderer/Fog.cpp @@ -0,0 +1,41 @@ +#include "Fog.hpp" +#include "renderer/RenderContextImmediate.hpp" + +mce::FogState Fog::_currentState; +mce::FogStateDescription Fog::nextState; + +void Fog::_updateState(const mce::FogStateDescription desc) +{ + mce::RenderContext& renderContext = mce::RenderContextImmediate::get(); + + _currentState.createFogState(renderContext, desc); + _currentState.bindFogState(renderContext); +} + +void Fog::_setEnabled(bool enabled) +{ + nextState.enableFog = enabled; + updateState(); +} + +void Fog::updateState() +{ + _updateState(nextState); +} + +void Fog::updateRange(float startZ, float endZ) +{ + nextState.fogStartZ = startZ; + nextState.fogEndZ = endZ; + updateState(); +} + +void Fog::enable() +{ + _setEnabled(true); +} + +void Fog::disable() +{ + _setEnabled(false); +} \ No newline at end of file diff --git a/source/client/renderer/Fog.hpp b/source/client/renderer/Fog.hpp new file mode 100644 index 000000000..9612b7b3e --- /dev/null +++ b/source/client/renderer/Fog.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include "renderer/hal/interface/FogState.hpp" + +class Fog +{ +private: + static mce::FogState _currentState; +public: + static mce::FogStateDescription nextState; + +private: + static void _updateState(const mce::FogStateDescription desc); + static void _setEnabled(bool enabled); +public: + static void updateState(); + static void updateRange(float startZ, float endZ); + static void enable(); + static void disable(); +}; diff --git a/source/client/renderer/FoliageColor.cpp b/source/client/renderer/FoliageColor.cpp index ec2570e49..80acb1141 100644 --- a/source/client/renderer/FoliageColor.cpp +++ b/source/client/renderer/FoliageColor.cpp @@ -3,9 +3,9 @@ bool FoliageColor::_isAvailable = false; -Texture FoliageColor::texture; +TextureData FoliageColor::texture; -void FoliageColor::init(Texture texture) +void FoliageColor::init(TextureData& texture) { FoliageColor::texture = texture; } @@ -13,7 +13,7 @@ void FoliageColor::init(Texture texture) uint32_t FoliageColor::get(double x, double y) { y *= x; - uint32_t c = FoliageColor::texture.m_pixels[(int)((1.0 - y) * 255.0) << 8 | (int)((1.0 - x) * 255.0)]; + uint32_t c = FoliageColor::texture.getData()[(int)((1.0 - y) * 255.0) << 8 | (int)((1.0 - x) * 255.0)]; // @TODO: same as in GrassColor::get, should be abstracted #if MC_ENDIANNESS_BIG diff --git a/source/client/renderer/FoliageColor.hpp b/source/client/renderer/FoliageColor.hpp index a7208b7df..3f59ab806 100644 --- a/source/client/renderer/FoliageColor.hpp +++ b/source/client/renderer/FoliageColor.hpp @@ -2,7 +2,7 @@ #include -#include "client/renderer/Texture.hpp" +#include "client/renderer/texture/TextureData.hpp" class FoliageColor { @@ -10,7 +10,7 @@ class FoliageColor static bool isAvailable() { return _isAvailable; } static void setIsAvailable(bool value) { _isAvailable = value; } - static void init(Texture texture); + static void init(TextureData& texture); static uint32_t get(double x, double y); @@ -22,6 +22,6 @@ class FoliageColor private: static bool _isAvailable; - static Texture texture; + static TextureData texture; }; diff --git a/source/client/renderer/Font.cpp b/source/client/renderer/Font.cpp index c197613b0..72e3af384 100644 --- a/source/client/renderer/Font.cpp +++ b/source/client/renderer/Font.cpp @@ -8,9 +8,17 @@ #include "Font.hpp" #include "Tesselator.hpp" +#include "client/renderer/renderer/RenderMaterialGroup.hpp" +#include "renderer/ShaderConstants.hpp" +#include "renderer/MatrixStack.hpp" constexpr char COLOR_START_CHAR = '\xa7'; +Font::Materials::Materials() +{ + MATERIAL_PTR(common, ui_text); +} + Font::Font(Options* pOpts, const std::string& fileName, Textures* pTexs) : m_fileName(fileName), m_pOptions(pOpts), m_pTextures(pTexs) { @@ -21,8 +29,7 @@ Font::Font(Options* pOpts, const std::string& fileName, Textures* pTexs) : void Font::init(Options* pOpts) { - GLuint texID = m_pTextures->loadTexture(m_fileName, true); - Texture* pTexture = m_pTextures->getTemporaryTextureData(texID); + TextureData* pTexture = m_pTextures->getTextureData(m_fileName, true); if (!pTexture) return; for (int i = 0; i < 256; i++) // character number @@ -39,17 +46,17 @@ void Font::init(Options* pOpts) for (int j = 7; j >= 0; j--) // x position { int x = (i % 16), y = (i / 16); - int pixelDataIndex = pTexture->m_width * 8 * y + 8 * x + j; + int pixelDataIndex = pTexture->m_imageData.m_width * 8 * y + 8 * x + j; for (int k = 0; k < 8; k++) { - if ((uint8_t)pTexture->m_pixels[pixelDataIndex] != 0) + if ((uint8_t)pTexture->getData()[pixelDataIndex] != 0) { if (widthMax < j) widthMax = j; } - pixelDataIndex += pTexture->m_width; + pixelDataIndex += pTexture->m_imageData.m_width; } } } @@ -78,49 +85,49 @@ void Font::buildChar(unsigned char chr, float x, float y) #undef CO } -void Font::draw(const std::string& str, int x, int y, int color) +void Font::draw(const std::string& str, int x, int y, const Color& color) { draw(str, x, y, color, false); } -void Font::drawShadow(const std::string& str, int x, int y, int color) +void Font::drawShadow(const std::string& str, int x, int y, const Color& color) { draw(str, x + 1, y + 1, color, true); draw(str, x, y, color, false); } -void Font::draw(const std::string& str, int x, int y, int color, bool bShadow) +void Font::draw(const std::string& str, int x, int y, const Color& color, bool bShadow) { drawSlow(str, x, y, color, bShadow); } -void Font::drawSlow(const std::string& str, int x, int y, int colorI, bool bShadow) +void Font::drawSlow(const std::string& str, int x, int y, const Color& color, bool bShadow) { if (str.empty()) return; - uint32_t color = colorI; - if (bShadow) - color = (color & 0xFF000000U) + ((color & 0xFCFCFCu) >> 2); + { + currentShaderDarkColor = Color(0.25f, 0.25f, 0.25f); + } + else + { + currentShaderDarkColor = Color::WHITE; + } m_pTextures->loadAndBindTexture(m_fileName); - uint32_t red = (color >> 16) & 0xFF; - uint32_t grn = (color >> 8) & 0xFF; - uint32_t blu = (color >> 0) & 0xFF; - uint32_t alp = (color >> 24) & 0xFF; + Color finalColor = color; + // For hex colors which don't specify an alpha + if (finalColor.a == 0.0f) + finalColor.a = 1.0f; - float alpf = float(alp) / 255.0f; - if (alpf == 0.0f) - alpf = 1.0f; + currentShaderColor = finalColor; - glColor4f(float(red) / 255.0f, float(grn) / 255.0f, float(blu) / 255.0f, alpf); - glPushMatrix(); + MatrixStack::Ref mtx = MatrixStack::World.push(); + mtx->translate(Vec3(x, y, 0.0f)); Tesselator& t = Tesselator::instance; - t.begin(); - - glTranslatef(float(x), float(y), 0.0f); + t.begin(4 * str.size()); float cXPos = 0.0f, cYPos = 0.0f; @@ -140,9 +147,7 @@ void Font::drawSlow(const std::string& str, int x, int y, int colorI, bool bShad cXPos += m_charWidthFloat[x]; } - t.draw(); - - glPopMatrix(); + t.draw(m_materials.ui_text); } void Font::onGraphicsReset() diff --git a/source/client/renderer/Font.hpp b/source/client/renderer/Font.hpp index 8775f0136..7fb4c3291 100644 --- a/source/client/renderer/Font.hpp +++ b/source/client/renderer/Font.hpp @@ -10,18 +10,28 @@ #include "Textures.hpp" #include "client/options/Options.hpp" +#include "renderer/MaterialPtr.hpp" class Font { +protected: + class Materials + { + public: + mce::MaterialPtr ui_text; + + Materials(); + }; + public: Font(Options* pOpts, const std::string& fileName, Textures* pTexs); void init(Options* pOpts); void buildChar(unsigned char chr, float x, float y); - void draw(const std::string&, int x, int y, int color); - void draw(const std::string&, int x, int y, int color, bool bShadow); - void drawSlow(const std::string&, int x, int y, int color, bool bShadow); - void drawShadow(const std::string&, int x, int y, int color); + void draw(const std::string&, int x, int y, const Color& color); + void draw(const std::string&, int x, int y, const Color& color, bool bShadow); + void drawSlow(const std::string&, int x, int y, const Color& color, bool bShadow); + void drawShadow(const std::string&, int x, int y, const Color& color); //int Font::drawWordWrap(Font *this, const StlString *a2, int a3, int a4, int a5, int a6). // +- I probably won't actually implement this because @@ -41,5 +51,6 @@ class Font std::string m_fileName; Options* m_pOptions; Textures* m_pTextures; + Materials m_materials; }; diff --git a/source/client/renderer/Frustum.cpp b/source/client/renderer/Frustum.cpp index e0e45d0ea..4fa6cbce9 100644 --- a/source/client/renderer/Frustum.cpp +++ b/source/client/renderer/Frustum.cpp @@ -7,97 +7,91 @@ ********************************************************************/ #include "Frustum.hpp" +#include "thirdparty/glm/gtc/matrix_access.hpp" +#include "thirdparty/glm/gtc/type_ptr.hpp" Frustum Frustum::frustum; -void Frustum::doOurJobInGameRenderer() +void Frustum::calculateFrustum() { Frustum& f = Frustum::frustum; - f.m[16].fetchGL(GL_PROJECTION_MATRIX); - f.m[17].fetchGL(GL_MODELVIEW_MATRIX); + const Matrix& projMtx = MatrixStack::Projection.top(); + const Matrix& worldMtx = MatrixStack::World.top(); + const Matrix& viewMtx = MatrixStack::View.top(); + // Order matters! + Matrix worldViewProjMtx = projMtx * viewMtx * worldMtx; - f.m[18] = f.m[17] * f.m[16]; + glm::mat4& mtx = worldViewProjMtx._m; - for (int i = 0; i < 6; i++) - { - for (int j = 0; j < 4; j++) - { - f.m[i].c[j] = f.m[18].c[3 + j * 4] - f.m[18].c[i / 2 + j * 4]; - } + const glm::vec4 row0 = glm::row(mtx, 0); // X + const glm::vec4 row1 = glm::row(mtx, 1); // Y + const glm::vec4 row2 = glm::row(mtx, 2); // Z + const glm::vec4 row3 = glm::row(mtx, 3); // W - f.normalizePlane(f.m, i); - } -} - -void Frustum::normalizePlane(Matrix* pMtxArr, int idx) -{ - Matrix& mtx = pMtxArr[idx]; - - float x = Mth::invSqrt(mtx.c[1] * mtx.c[1] + mtx.c[0] * mtx.c[0] + mtx.c[2] * mtx.c[2]); - - mtx.c[0] *= x; - mtx.c[1] *= x; - mtx.c[2] *= x; - mtx.c[3] *= x; -} + f.m[0] = row3 - row0; // Right + f.m[1] = row3 + row0; // Left + f.m[2] = row3 + row1; // Bottom + f.m[3] = row3 - row1; // Top + f.m[4] = row3 - row2; // Far + f.m[5] = row3 + row2; // Near -bool FrustumData::pointInFrustum(float x, float y, float z) -{ - for (int i = 0; i < 6; i++) + for (int i = 0; i < 6; ++i) { - if ((this->x.m[i].c[0] * x) + (this->x.m[i].c[1] * y) + (this->x.m[i].c[2] * z) + this->x.m[i].c[3] <= 0.0f) - return false; + glm::vec4& vec = f.m[i]; + f.m[i] = glm::normalize(vec); } - return true; } -bool FrustumData::sphereInFrustum(float x, float y, float z, float radius) +bool FrustumData::pointInFrustum(const Vec3& vec) { for (int i = 0; i < 6; i++) { - if ((this->x.m[i].c[0] * x) + (this->x.m[i].c[1] * y) + (this->x.m[i].c[2] * z) + this->x.m[i].c[3] <= (-radius)) + float* mtx = glm::value_ptr(this->x.m[i]); + if ((mtx[0] * vec.x) + (mtx[1] * vec.y) + (mtx[2] * vec.z) + mtx[3] <= 0.0f) return false; } return true; } -bool FrustumData::cubeFullyInFrustum(float x1, float y1, float z1, float x2, float y2, float z2) +bool FrustumData::sphereInFrustum(const Vec3& vec, float radius) { - for (int i = 0; i < 6; i++) { - if ((this->x.m[i].c[0] * x1) + (this->x.m[i].c[1] * y1) + (this->x.m[i].c[2] * z1) + this->x.m[i].c[3] <= 0.0f || - (this->x.m[i].c[0] * x2) + (this->x.m[i].c[1] * y1) + (this->x.m[i].c[2] * z1) + this->x.m[i].c[3] <= 0.0f || - (this->x.m[i].c[0] * x1) + (this->x.m[i].c[1] * y2) + (this->x.m[i].c[2] * z1) + this->x.m[i].c[3] <= 0.0f || - (this->x.m[i].c[0] * x2) + (this->x.m[i].c[1] * y2) + (this->x.m[i].c[2] * z1) + this->x.m[i].c[3] <= 0.0f || - (this->x.m[i].c[0] * x1) + (this->x.m[i].c[1] * y1) + (this->x.m[i].c[2] * z2) + this->x.m[i].c[3] <= 0.0f || - (this->x.m[i].c[0] * x2) + (this->x.m[i].c[1] * y1) + (this->x.m[i].c[2] * z2) + this->x.m[i].c[3] <= 0.0f || - (this->x.m[i].c[0] * x1) + (this->x.m[i].c[1] * y2) + (this->x.m[i].c[2] * z2) + this->x.m[i].c[3] <= 0.0f || - (this->x.m[i].c[0] * x2) + (this->x.m[i].c[1] * y2) + (this->x.m[i].c[2] * z2) + this->x.m[i].c[3] <= 0.0f) - + for (int i = 0; i < 6; i++) + { + float* mtx = glm::value_ptr(this->x.m[i]); + if ((mtx[0] * vec.x) + (mtx[1] * vec.y) + (mtx[2] * vec.z) + mtx[3] <= (-radius)) return false; } return true; } -bool FrustumData::cubeInFrustum(float x1, float y1, float z1, float x2, float y2, float z2) +bool FrustumData::cubeInFrustum(const Vec3& min, const Vec3& max) { for (int i = 0; i < 6; i++) { - if ((this->x.m[i].c[0] * x1) + (this->x.m[i].c[1] * y1) + (this->x.m[i].c[2] * z1) + this->x.m[i].c[3] <= 0.0f && - (this->x.m[i].c[0] * x2) + (this->x.m[i].c[1] * y1) + (this->x.m[i].c[2] * z1) + this->x.m[i].c[3] <= 0.0f && - (this->x.m[i].c[0] * x1) + (this->x.m[i].c[1] * y2) + (this->x.m[i].c[2] * z1) + this->x.m[i].c[3] <= 0.0f && - (this->x.m[i].c[0] * x2) + (this->x.m[i].c[1] * y2) + (this->x.m[i].c[2] * z1) + this->x.m[i].c[3] <= 0.0f && - (this->x.m[i].c[0] * x1) + (this->x.m[i].c[1] * y1) + (this->x.m[i].c[2] * z2) + this->x.m[i].c[3] <= 0.0f && - (this->x.m[i].c[0] * x2) + (this->x.m[i].c[1] * y1) + (this->x.m[i].c[2] * z2) + this->x.m[i].c[3] <= 0.0f && - (this->x.m[i].c[0] * x1) + (this->x.m[i].c[1] * y2) + (this->x.m[i].c[2] * z2) + this->x.m[i].c[3] <= 0.0f && - (this->x.m[i].c[0] * x2) + (this->x.m[i].c[1] * y2) + (this->x.m[i].c[2] * z2) + this->x.m[i].c[3] <= 0.0f) - + const glm::vec4& plane = this->x.m[i]; + glm::vec3 normal = glm::vec3(plane); // The A, B, C components + + // Find the "Positive Vertex" (P-Vertex). + // This is the corner of the box that is furthest along the normal's direction. + glm::vec3 pVertex; + pVertex.x = (normal.x > 0) ? max.x : min.x; + pVertex.y = (normal.y > 0) ? max.y : min.y; + pVertex.z = (normal.z > 0) ? max.z : min.z; + + // Check distance from plane to the P-Vertex. + // Plane Equation: Ax + By + Cz + D = 0 + // If (dot(n, p) + d) < 0, the point is behind the plane. + // If the "furthest" point is behind the plane, the whole box is outside. + if (glm::dot(normal, pVertex) + plane.w < 0.0f) + { return false; + } } return true; } bool FrustumData::cubeInFrustum(const AABB& aabb) { - return cubeInFrustum(aabb.min.x, aabb.min.y, aabb.min.z, aabb.max.x, aabb.max.y, aabb.max.z); + return cubeInFrustum(aabb.min, aabb.max); } diff --git a/source/client/renderer/Frustum.hpp b/source/client/renderer/Frustum.hpp index 6165a0521..4b88843e2 100644 --- a/source/client/renderer/Frustum.hpp +++ b/source/client/renderer/Frustum.hpp @@ -8,30 +8,27 @@ #pragma once -#include "common/Matrix.hpp" +#include "renderer/MatrixStack.hpp" #include "world/phys/AABB.hpp" class Frustum { public: - void normalizePlane(Matrix*, int); - //it's inlined in GameRenderer - static void doOurJobInGameRenderer(); + static void calculateFrustum(); static Frustum frustum; public: - Matrix m[19]; + glm::vec4 m[6]; }; class FrustumData { public: - bool pointInFrustum(float x, float y, float z); - bool sphereInFrustum(float x, float y, float z, float radius); - bool cubeFullyInFrustum(float x1, float y1, float z1, float x2, float y2, float z2); - bool cubeInFrustum(float x1, float y1, float z1, float x2, float y2, float z2); + bool pointInFrustum(const Vec3& vec); + bool sphereInFrustum(const Vec3& vec, float radius); + bool cubeInFrustum(const Vec3& min, const Vec3& max); bool cubeInFrustum(const AABB& aabb); public: diff --git a/source/client/renderer/FrustumCuller.cpp b/source/client/renderer/FrustumCuller.cpp index 4b699aeef..d69590852 100644 --- a/source/client/renderer/FrustumCuller.cpp +++ b/source/client/renderer/FrustumCuller.cpp @@ -8,36 +8,17 @@ #include "FrustumCuller.hpp" -bool FrustumCuller::cubeFullyInFrustum(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) +bool FrustumCuller::cubeInFrustum(const Vec3& min, const Vec3& max) { - return m_frustumData.cubeFullyInFrustum( - minX - m_camPos.x, - minY - m_camPos.y, - minZ - m_camPos.z, - maxX - m_camPos.x, - maxY - m_camPos.y, - maxZ - m_camPos.z - ); -} - -bool FrustumCuller::cubeInFrustum(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) -{ - return m_frustumData.cubeInFrustum( - minX - m_camPos.x, - minY - m_camPos.y, - minZ - m_camPos.z, - maxX - m_camPos.x, - maxY - m_camPos.y, - maxZ - m_camPos.z - ); + return m_frustumData.cubeInFrustum(min - m_camPos, max - m_camPos); } bool FrustumCuller::isVisible(const AABB& aabb) { - return cubeInFrustum(aabb.min.x, aabb.min.y, aabb.min.z, aabb.max.x, aabb.max.y, aabb.max.z); + return cubeInFrustum(aabb.min, aabb.max); } -void FrustumCuller::prepare(float x, float y, float z) +void FrustumCuller::prepare(const Vec3& camPos) { - m_camPos = Vec3(x, y, z); + m_camPos = camPos; } diff --git a/source/client/renderer/FrustumCuller.hpp b/source/client/renderer/FrustumCuller.hpp index d775aba15..b06ac0bde 100644 --- a/source/client/renderer/FrustumCuller.hpp +++ b/source/client/renderer/FrustumCuller.hpp @@ -15,10 +15,9 @@ class FrustumCuller : public Culler { public: - bool cubeFullyInFrustum(float, float, float, float, float, float); - bool cubeInFrustum(float, float, float, float, float, float); - bool isVisible(const AABB&); - void prepare(float x, float y, float z); + bool cubeInFrustum(const Vec3& min, const Vec3& max); + bool isVisible(const AABB& aabb); + void prepare(const Vec3& camPos); public: FrustumData m_frustumData; diff --git a/source/client/renderer/GameRenderer.cpp b/source/client/renderer/GameRenderer.cpp index e3b7028b3..88a34baa0 100644 --- a/source/client/renderer/GameRenderer.cpp +++ b/source/client/renderer/GameRenderer.cpp @@ -6,16 +6,18 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ -#include "thirdparty/GL/GL.hpp" #include "GameRenderer.hpp" +#include "GameMods.hpp" #include "client/app/Minecraft.hpp" #include "client/player/input/Multitouch.hpp" #include "client/player/input/Controller.hpp" #include "Frustum.hpp" -#include "Lighting.hpp" #include "renderer/GL/GL.hpp" +#include "renderer/GlobalConstantBuffers.hpp" +#include "renderer/RenderContextImmediate.hpp" +#include "thirdparty/glm/glm.hpp" -// #define SHOW_VERTEX_COUNTER_GRAPHIC +//#define SHOW_VERTEX_COUNTER_GRAPHIC #if defined SHOW_VERTEX_COUNTER_GRAPHIC && !defined _DEBUG #undef SHOW_VERTEX_COUNTER_GRAPHIC @@ -27,8 +29,9 @@ int t_keepPic; void GameRenderer::_init() { //ItemInHandRenderer* m_pItemInHandRenderer = nullptr; + m_pLevel = nullptr; - field_8 = 0.0f; + m_renderDistance = 0.0f; field_C = 0; m_pHovered = nullptr; field_14 = 0.0f; @@ -43,26 +46,18 @@ void GameRenderer::_init() field_38 = 0.0f; field_3C = 0.0f; field_40 = 0.0f; - field_44 = 1.0f; - field_48 = 0.0f; - field_4C = 0.0f; + m_zoom = 1.0f; field_50 = 0.0f; field_54 = 0.0f; field_58 = 0.0f; field_5C = 0.0f; - field_60 = 0.0f; - field_64 = 0.0f; - field_68 = 0.0f; - field_6C = 0.0f; - field_70 = 0.0f; field_74 = 0.0f; field_78 = 0.0f; field_7C = 0.0f; field_80 = 0.0f; field_84 = 0.0f; - m_lastUpdatedMS = 0; - m_shownFPS = 0; - m_shownChunkUpdates = 0; + + m_shownFPS = m_shownChunkUpdates = m_lastUpdatedMS = 0; m_envTexturePresence = 0; } @@ -76,6 +71,10 @@ GameRenderer::GameRenderer(Minecraft* pMinecraft) : m_pItemInHandRenderer = new ItemInHandRenderer(pMinecraft); EntityRenderDispatcher::getInstance()->m_pItemInHandRenderer = m_pItemInHandRenderer; + +#ifdef FEATURE_GFX_SHADERS + mce::GlobalConstantBuffers::getInstance().init(); +#endif } GameRenderer::~GameRenderer() @@ -83,57 +82,202 @@ GameRenderer::~GameRenderer() delete m_pItemInHandRenderer; } -void GameRenderer::zoomRegion(float a, float b, float c) +void GameRenderer::_clearFrameBuffer() { - field_44 = a; - field_48 = b; - field_4C = c; + mce::RenderContext& renderContext = mce::RenderContextImmediate::get(); + + renderContext.setViewport(0, 0, Minecraft::width, Minecraft::height, 0.0f, 0.7f); + renderContext.setRenderTarget(); + renderContext.clearFrameBuffer(Color(0.0f, 0.3f, 0.2f, 0.0f)); + renderContext.clearDepthStencilBuffer(); +} + +void GameRenderer::_renderItemInHand(float f, int i) +{ + Matrix& viewMtx = MatrixStack::View.getTop(); + viewMtx = Matrix::IDENTITY; + + if (m_pMinecraft->getOptions()->m_bAnaglyphs) + { + viewMtx.translate(Vec3(float(2 * i - 1) * 0.1f, 0.0f, 0.0f)); + } + + MatrixStack::Ref matrix = MatrixStack::World.push(); + + bobHurt(matrix, f); + + if (m_pMinecraft->getOptions()->m_bViewBobbing) + { + bobView(matrix, f); + } + + if (!m_pMinecraft->getOptions()->m_bThirdPerson && !m_pMinecraft->getOptions()->m_bDontRenderGui) + { + mce::RenderContextImmediate::get().clearDepthStencilBuffer(); + m_pItemInHandRenderer->render(f); + } + + if (!m_pMinecraft->getOptions()->m_bThirdPerson) + { + m_pItemInHandRenderer->renderScreenEffect(f); + bobHurt(matrix, f); + } + + if (m_pMinecraft->getOptions()->m_bViewBobbing) + { + bobView(matrix, f); + } +} + +void GameRenderer::_renderDebugOverlay(float a) +{ + ScreenRenderer& screenRenderer = ScreenRenderer::singleton(); + Font& font = *m_pMinecraft->m_pFont; + + std::stringstream debugText; + debugText << "ReMinecraftPE " << m_pMinecraft->getVersionString(); + debugText << " (" << m_shownFPS << " fps, " << m_shownChunkUpdates << " chunk updates)" << "\n"; + + /* + * The "!m_pMinecraft->m_bPreparingLevel" check *needs* to be here. + * If said check is not here, when getBiome() is called for the biome display, + * it would allocate an array with a size of 1 before the level was even generated. + * Then, during level generation, said array would be written to as if it had a size + * of 256, leading to a heap corruption that took ASan to debug successfully. + * Unfortunately, ASan and DirectSound don't mix, and Microsoft's ASan team has stated that they don't even know why: + * https://developercommunity.visualstudio.com/t/ASAN-x64-causes-unhandled-exception-at-0/1365655#T-N10460750 + * Since all SoundSystems are backed with DirectSound, SoundSystemNull is needed to use ASan. + * This heap corruption bug, which (only if the F3 menu was open) would cause multiplayer functionality to be entirely + * based on luck, had been around since Commit 53200be, on March 5th of 2025, and was fixed on September 30th of 2025. + */ + if (m_pMinecraft->m_pLocalPlayer && !m_pMinecraft->m_bPreparingLevel) + { + char posStr[96]; + Vec3 pos = m_pMinecraft->m_pLocalPlayer->getPos(a); + sprintf(posStr, "%.2f / %.2f / %.2f", pos.x, pos.y, pos.z); + + debugText << m_pMinecraft->m_pLevelRenderer->gatherStats1(); + debugText << m_pMinecraft->m_pLevelRenderer->gatherStats2() << "\n"; + debugText << "XYZ: " << posStr << "\n"; + debugText << "Biome: " << m_pMinecraft->m_pLevel->getBiomeSource()->getBiome(pos)->m_name << "\n"; + } + +#ifdef SHOW_VERTEX_COUNTER_GRAPHIC + extern int g_nVertices; // Tesselator.cpp + debugText << "\nverts: " << g_nVertices; + + _renderVertexGraph(g_nVertices, int(Minecraft::height * Gui::InvGuiScale)); +#endif + + /*debugText << "\nController::stickValuesX[1]: " << Controller::stickValuesX[1]; + debugText << "\nController::stickValuesY[1]: " << Controller::stickValuesY[1]; + debugText << "\nGameRenderer::field_7C: " << field_7C; + debugText << "\nGameRenderer::field_80: " << field_80;*/ + + font.drawShadow(debugText.str(), 2, 2, Color::WHITE); + +#ifdef SHOW_VERTEX_COUNTER_GRAPHIC + g_nVertices = 0; +#endif +} + +void GameRenderer::_renderVertexGraph(int vertices, int h) +{ + ScreenRenderer& screenRenderer = ScreenRenderer::singleton(); + Font& font = *m_pMinecraft->m_pFont; + + static int vertGraph[200]; + memcpy(vertGraph, vertGraph + 1, sizeof(vertGraph) - sizeof(int)); + vertGraph[(sizeof(vertGraph) / sizeof(vertGraph[0])) - 1] = vertices; + + Tesselator& t = Tesselator::instance; + + int max = 0; + for (int i = 0; i < 200; i++) + max = std::max(max, vertGraph[i]); + + int maxht = 100; + + //glClear(GL_DEPTH_BUFFER_BIT); + currentShaderColor = Color::WHITE; + currentShaderDarkColor = Color::WHITE; + + t.begin(4); + t.color(1.0f, 1.0f, 1.0f, 0.15f); + t.vertex(000, h - maxht, 0); + t.vertex(000, h, 0); + t.vertex(200, h, 0); + t.vertex(200, h - maxht, 0); + t.draw(screenRenderer.m_materials.ui_fill_color); + + t.begin(200 * 4); + t.color(0.0f, 1.0f, 0.0f, 1.0f); + + for (int i = 0; i < 200 && max != 0; i++) + { + t.vertex(i + 0, h - (vertGraph[i] * maxht / max), 0); + t.vertex(i + 0, h - 0, 0); + t.vertex(i + 1, h - 0, 0); + t.vertex(i + 1, h - (vertGraph[i] * maxht / max), 0); + } + + t.draw(screenRenderer.m_materials.ui_fill_color); + + screenRenderer.drawString(font, SSTR(max), 200, h - maxht); +} + +void GameRenderer::zoomRegion(float zoom, const Vec2& region) +{ + m_zoom = zoom; + m_zoomRegion = region; } void GameRenderer::unZoomRegion() { - field_44 = 1.0f; + m_zoom = 1.0f; } void GameRenderer::setupCamera(float f, int i) { - field_8 = float(256 >> m_pMinecraft->getOptions()->m_iViewDistance); + m_renderDistance = float(256 >> m_pMinecraft->getOptions()->m_iViewDistance); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); + Matrix& projMtx = MatrixStack::Projection.getTop(); + projMtx = Matrix::IDENTITY; if (m_pMinecraft->getOptions()->m_bAnaglyphs) { - glTranslatef(float(1 - 2 * i) * 0.07f, 0.0f, 0.0f); + projMtx.translate(Vec3(float(1 - 2 * i) * 0.07f, 0.0f, 0.0f)); } - if (field_44 != 1.0) + if (m_zoom != 1.0) { - glTranslatef(field_48, -field_4C, 0.0); - glScalef(field_44, field_44, 1.0); + projMtx.translate(Vec3(m_zoomRegion.x, -m_zoomRegion.y, 0.0f)); + projMtx.scale(Vec3(m_zoom, m_zoom, 1.0f)); } float fov = getFov(f); - gluPerspective(fov, float(Minecraft::width) / float(Minecraft::height), 0.05f, field_8); + projMtx.setPerspective(fov, float(Minecraft::width) / float(Minecraft::height), 0.05f, m_renderDistance); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); + Matrix& viewMtx = MatrixStack::View.getTop(); + viewMtx = Matrix::IDENTITY; if (m_pMinecraft->getOptions()->m_bAnaglyphs) { - glTranslatef(float(2 * i - 1) * 0.1f, 0.0f, 0.0f); + viewMtx.translate(Vec3(float(2 * i - 1) * 0.1f, 0.0f, 0.0f)); } - bobHurt(f); + bobHurt(viewMtx, f); if (m_pMinecraft->getOptions()->m_bViewBobbing) - bobView(f); + { + bobView(viewMtx, f); + } - moveCameraToPlayer(f); + moveCameraToPlayer(viewMtx, f); } -void GameRenderer::moveCameraToPlayer(float f) +void GameRenderer::moveCameraToPlayer(Matrix& matrix, float f) { - Mob* pMob = m_pMinecraft->m_pMobPersp; + Mob* pMob = m_pMinecraft->m_pCameraEntity; float headHeightDiff = pMob->m_heightOffset - 1.62f; @@ -141,16 +285,16 @@ void GameRenderer::moveCameraToPlayer(float f) float posY = Mth::Lerp(pMob->m_oPos.y, pMob->m_pos.y, f); float posZ = Mth::Lerp(pMob->m_oPos.z, pMob->m_pos.z, f); - glRotatef(field_5C + f * (field_58 - field_5C), 0.0f, 0.0f, 1.0f); + matrix.rotate(field_5C + f * (field_58 - field_5C), Vec3::UNIT_Z); if (m_pMinecraft->getOptions()->m_bThirdPerson) { float v11 = field_30 + (field_2C - field_30) * f; if (m_pMinecraft->getOptions()->field_241) { - glTranslatef(0.0f, 0.0f, -v11); - glRotatef(field_38 + (field_34 - field_38) * f, 1.0f, 0.0f, 0.0f); - glRotatef(field_40 + (field_3C - field_40) * f, 0.0f, 1.0f, 0.0f); + matrix.translate(Vec3::NEG_UNIT_Z * v11); + matrix.rotate(field_38 + (field_34 - field_38) * f, Vec3::UNIT_X); + matrix.rotate(field_40 + (field_3C - field_40) * f, Vec3::UNIT_Y); } else { @@ -185,206 +329,106 @@ void GameRenderer::moveCameraToPlayer(float f) } } - // @HUH: Why the hell is it rotating by 0 - glRotatef(pMob->m_rot.y - mob_pitch, 1.0f, 0.0f, 0.0f); - glRotatef(pMob->m_rot.x - mob_yaw, 0.0f, 1.0f, 0.0f); - glTranslatef(0.0, 0.0, -v11); - glRotatef(mob_yaw - pMob->m_rot.x, 0.0f, 1.0f, 0.0f); - glRotatef(mob_pitch - pMob->m_rot.y, 1.0f, 0.0f, 0.0f); + matrix.rotate(pMob->m_rot.y - mob_pitch, Vec3::UNIT_X); + matrix.rotate(pMob->m_rot.x - mob_yaw, Vec3::UNIT_Y); + matrix.translate(Vec3::NEG_UNIT_Z * v11); + matrix.rotate(mob_yaw - pMob->m_rot.x, Vec3::UNIT_Y); + matrix.rotate(mob_pitch - pMob->m_rot.y, Vec3::UNIT_X); } } else { - glTranslatef(0.0f, 0.0f, -0.1f); + matrix.translate(Vec3(0.0f, 0.0f, -0.1f)); } if (!m_pMinecraft->getOptions()->field_241) { - glRotatef(pMob->m_oRot.y + f * (pMob->m_rot.y - pMob->m_oRot.y), 1.0f, 0.0f, 0.0f); - glRotatef(pMob->m_oRot.x + f * (pMob->m_rot.x - pMob->m_oRot.x) + 180.0f, 0.0f, 1.0f, 0.0f); + matrix.rotate(pMob->m_oRot.y + f * (pMob->m_rot.y - pMob->m_oRot.y), Vec3::UNIT_X); + matrix.rotate(pMob->m_oRot.x + f * (pMob->m_rot.x - pMob->m_oRot.x) + 180.0f, Vec3::UNIT_Y); } - glTranslatef(0.0f, headHeightDiff, 0.0f); + matrix.translate(Vec3::UNIT_Y * headHeightDiff); } void GameRenderer::saveMatrices() { - glGetFloatv(GL_PROJECTION_MATRIX, m_matrix_projection); - glGetFloatv(GL_MODELVIEW_MATRIX, m_matrix_model_view); + if (m_pMinecraft->useSplitControls() || !m_pMinecraft->m_pInputHolder->allowPicking()) + return; + + // Save projection matrix + m_mtxProj = MatrixStack::Projection.top(); + + // Save modelview matrix + const Matrix& worldMatrix = MatrixStack::World.top(); + const Matrix& viewMatrix = MatrixStack::View.top(); + // Order matters! + m_mtxView = viewMatrix * worldMatrix; } void GameRenderer::setupGuiScreen() { float x = Gui::InvGuiScale * Minecraft::width; float y = Gui::InvGuiScale * Minecraft::height; - glClear(GL_DEPTH_BUFFER_BIT); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - xglOrthof(0, x, y, 0, 2000.0f, 3000.0f); // @NOTE: for whatever reason, nearpl is 1000.0f on LCE - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0.0f, 0.0f, -2000.0f); + + Matrix& projMtx = MatrixStack::Projection.getTop(); + projMtx.setOrtho(0, x, y, 0, 2000.0f, 3000.0f); + + Matrix& viewMtx = MatrixStack::View.getTop(); + viewMtx = Matrix::IDENTITY; + viewMtx.translate(Vec3(0.0f, 0.0f, -2000.0f)); // -2000 to -3000 } -void GameRenderer::bobHurt(float f) +void GameRenderer::bobHurt(Matrix& matrix, float f) { - Mob* pMob = m_pMinecraft->m_pMobPersp; + Mob* pMob = m_pMinecraft->m_pCameraEntity; if (pMob->m_health <= 0) - glRotatef(-8000.0f / (float(pMob->m_deathTime) + f + 200.0f) + 40.0f, 0.0f, 0.0f, 1.0f); + { + matrix.rotate(-8000.0f / (float(pMob->m_deathTime) + f + 200.0f) + 40.0f, Vec3::UNIT_Z); + } if (pMob->m_hurtTime > 0) { float val = (pMob->m_hurtTime - f) / pMob->m_hurtDuration; - glRotatef(-pMob->m_hurtDir, 0.0f, 1.0f, 0.0f); - glRotatef(Mth::sin(val * val * val * val * 3.1416f) * -14.0f, 0.0f, 0.0f, 1.0f); - glRotatef(pMob->m_hurtDir, 0.0f, 1.0f, 0.0f); + matrix.rotate(-pMob->m_hurtDir, Vec3::UNIT_Y); + matrix.rotate(Mth::sin(val * val * val * val * 3.1416f) * -14.0f, Vec3::UNIT_Z); + matrix.rotate(pMob->m_hurtDir, Vec3::UNIT_Y); } } -void GameRenderer::bobView(float f) +void GameRenderer::bobView(Matrix& matrix, float f) { - if (!m_pMinecraft->m_pMobPersp->isPlayer()) + if (!m_pMinecraft->m_pCameraEntity->isPlayer()) return; - Player* player = (Player*)m_pMinecraft->m_pMobPersp; + Player* player = (Player*)m_pMinecraft->m_pCameraEntity; float f1 = Mth::Lerp(player->m_oBob, player->m_bob, f); float f2 = Mth::Lerp(player->m_oTilt, player->m_tilt, f); // @NOTE: Multiplying by M_PI inside of the paren makes it stuttery for some reason? Anyways it works now :) float f3 = -(player->m_walkDist + (player->m_walkDist - player->field_90) * f) * float(M_PI); float f4 = Mth::sin(f3); float f5 = Mth::cos(f3); - glTranslatef((f4 * f1) * 0.5f, -fabsf(f5 * f1), 0.0f); - float f6 = Mth::sin(f3); - glRotatef((f6 * f1) * 3.0f, 0.0f, 0.0f, 1.0f); - float f7 = Mth::cos(f3 - 0.2f); - glRotatef(fabsf(f7 * f1) * 5.0f, 1.0f, 0.0f, 0.0f); - glRotatef(f2, 1.0f, 0.0f, 0.0f); -} - -void GameRenderer::setupClearColor(float f) -{ - Minecraft* pMC = m_pMinecraft; - Level* pLevel = pMC->m_pLevel; - Mob* pMob = pMC->m_pMobPersp; - - float x1 = 1.0f - powf(1.0f / float(4 - pMC->getOptions()->m_iViewDistance), 0.25f); - - Vec3 skyColor = pLevel->getSkyColor(pMob, f), fogColor = pLevel->getFogColor(f); - - //@BUG: double set to these? - field_60 = fogColor.x; - field_64 = fogColor.y; - - field_60 = fogColor.x + (skyColor.x - fogColor.x) * x1; - field_64 = fogColor.y + (skyColor.y - fogColor.y) * x1; - field_68 = fogColor.z + (skyColor.z - fogColor.z) * x1; - - if (pMob->isUnderLiquid(Material::water)) - { - field_60 = 0.02f; - field_64 = 0.02f; - field_68 = 0.2f; - } - else if (pMob->isUnderLiquid(Material::lava)) - { - field_60 = 0.6f; - field_64 = 0.1f; - field_68 = 0.0f; - } - - float x2 = field_6C + (field_70 - field_6C) * f; + float f6 = Mth::cos(f3 - 0.2f); - field_60 *= x2; - field_64 *= x2; - field_68 *= x2; - - if (pMC->getOptions()->m_bAnaglyphs) - { - float r = (field_60 * 30.0f + field_64 * 59.0f + field_68 * 11.0f) / 100.0f; - float g = (field_60 * 30.0f + field_64 * 70.0f) / 100.0f; - float b = (field_60 * 30.0f + field_68 * 70.0f) / 100.0f; - - field_60 = r; - field_64 = g; - field_68 = b; - } - - glClearColor(field_60, field_64, field_68, 1.0f); + matrix.translate(Vec3((f4 * f1) * 0.5f, -fabsf(f5 * f1), 0.0f)); + matrix.rotate((f4 * f1) * 3.0f, Vec3::UNIT_Z); + matrix.rotate(fabsf(f6 * f1) * 5.0f, Vec3::UNIT_X); + matrix.rotate(f2, Vec3::UNIT_X); } #ifndef ORIGINAL_CODE void GameRenderer::renderNoCamera() { - glClearColor(1.0f, 1.0f, 1.0f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + mce::RenderContext& renderContext = mce::RenderContextImmediate::get(); + renderContext.clearFrameBuffer(Color::WHITE); + renderContext.clearDepthStencilBuffer(); } #endif -void GameRenderer::setupFog(int i) -{ - float fog_color[4]; - fog_color[0] = field_60; - fog_color[1] = field_64; - fog_color[2] = field_68; - fog_color[3] = 1.0f; - - glFogfv(GL_FOG_COLOR, fog_color); -#ifndef __EMSCRIPTEN__ - glNormal3f(0.0f, -1.0f, 0.0f); -#endif - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - - if (m_pMinecraft->m_pMobPersp->isUnderLiquid(Material::water)) - { - #if defined(ORIGINAL_CODE) || defined(ANDROID) - glFogx(GL_FOG_MODE, GL_EXP); - #else - glFogi(GL_FOG_MODE, GL_EXP); - #endif - - glFogf(GL_FOG_DENSITY, 0.1f); - } - else if (m_pMinecraft->m_pMobPersp->isUnderLiquid(Material::lava)) - { - #if defined(ORIGINAL_CODE) || defined(ANDROID) - glFogx(GL_FOG_MODE, GL_EXP); - #else - glFogi(GL_FOG_MODE, GL_EXP); - #endif - - glFogf(GL_FOG_DENSITY, 2.0f); - } - else - { - #if defined(ORIGINAL_CODE) || defined(ANDROID) - glFogx(GL_FOG_MODE, GL_LINEAR); - #else - glFogi(GL_FOG_MODE, GL_LINEAR); - #endif - - glFogf(GL_FOG_START, field_8 * 0.25f); - glFogf(GL_FOG_END, field_8); - if (i < 0) - { - glFogf(GL_FOG_START, 0.0f); - glFogf(GL_FOG_END, field_8 * 0.8f); - } - - if (m_pMinecraft->m_pLevel->m_pDimension->m_bFoggy) - { - glFogf(GL_FOG_START, 0.0f); - } - - } - - glEnable(GL_COLOR_MATERIAL); -} - float GameRenderer::getFov(float f) { - Mob* pMob = m_pMinecraft->m_pMobPersp; + Mob* pMob = m_pMinecraft->m_pCameraEntity; float x1 = 70.0f; @@ -402,11 +446,15 @@ float GameRenderer::getFov(float f) void GameRenderer::renderLevel(float f) { - if (!m_pMinecraft->m_pMobPersp) + if (!m_pLevel) + return; + + Mob*& pCamera = m_pMinecraft->m_pCameraEntity; + if (!pCamera) { - m_pMinecraft->m_pMobPersp = m_pMinecraft->m_pLocalPlayer; + pCamera = m_pMinecraft->m_pLocalPlayer; - if (!m_pMinecraft->m_pMobPersp) + if (!pCamera) { #ifndef ORIGINAL_CODE renderNoCamera(); @@ -417,142 +465,95 @@ void GameRenderer::renderLevel(float f) pick(f); - Mob* pMob = m_pMinecraft->m_pMobPersp; - Vec3 fCamPos; - - fCamPos.x = pMob->m_posPrev.x + (pMob->m_pos.x - pMob->m_posPrev.x) * f; - fCamPos.y = pMob->m_posPrev.y + (pMob->m_pos.y - pMob->m_posPrev.y) * f; - fCamPos.z = pMob->m_posPrev.z + (pMob->m_pos.z - pMob->m_posPrev.z) * f; + const Entity& camera = *pCamera; + Vec3 camPos = camera.m_posPrev + (camera.m_pos - camera.m_posPrev) * f; bool bAnaglyph = m_pMinecraft->getOptions()->m_bAnaglyphs; - LevelRenderer* pLR = m_pMinecraft->m_pLevelRenderer; - ParticleEngine* pPE = m_pMinecraft->m_pParticleEngine; + LevelRenderer& levelRenderer = *m_pMinecraft->m_pLevelRenderer; + ParticleEngine& particleEngine = *m_pMinecraft->m_pParticleEngine; + mce::RenderContext& renderContext = mce::RenderContextImmediate::get(); for (int i = 0; i < 2; i++) { if (bAnaglyph) { +#if MCE_GFX_API_OGL if (i > 0) glColorMask(true, false, false, false); else glColorMask(false, true, true, false); +#endif } - glViewport(0, 0, Minecraft::width, Minecraft::height); - setupClearColor(f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + renderContext.setViewport(0, 0, Minecraft::width, Minecraft::height, 0.0f, 0.7f); + renderContext.setRenderTarget(); + const Color& clearColor = levelRenderer.setupClearColor(f); + renderContext.clearFrameBuffer(clearColor); + renderContext.clearDepthStencilBuffer(); - glEnable(GL_CULL_FACE); setupCamera(f, i); saveMatrices(); - /* - if (m_pMinecraft->getOptions()->m_iViewDistance <= 1) - { + renderFramedItems(camPos, levelRenderer, camera, f, particleEngine, i); + + if (!bAnaglyph) + break; + } + + if (bAnaglyph) + { +#if MCE_GFX_API_OGL + glColorMask(true, true, true, false); +#endif + } +} + +void GameRenderer::renderFramedItems(const Vec3& camPos, LevelRenderer& levelRenderer, const Entity& camera, float f, ParticleEngine& particleEngine, float i) +{ + /* + if (m_pMinecraft->getOptions()->m_iViewDistance <= 1) + { #ifndef ORIGINAL_CODE // @NOTE: For whatever reason, Minecraft doesn't enable GL_FOG right away. // It appears to work in bluestacks for whatever reason though... - glEnable(GL_FOG); + Fog::enable(); #endif setupFog(-1); pLR->renderSky(f); } */ - glEnable(GL_FOG); - setupFog(1); - - if (m_pMinecraft->getOptions()->m_bAmbientOcclusion) - glShadeModel(GL_SMOOTH); - - Frustum& frust = Frustum::frustum; - Frustum::doOurJobInGameRenderer(); - - FrustumCuller frustumCuller; - frustumCuller.m_frustumData.x = frust; - frustumCuller.prepare(fCamPos.x, fCamPos.y, fCamPos.z); - - pLR->cull(&frustumCuller, f); - pLR->updateDirtyChunks(pMob, false); - - // TODO[v0.6.1]: what is (this+4)+63 (byte)? - prepareAndRenderClouds(pLR, f); - - setupFog(0); - glEnable(GL_FOG); - - m_pMinecraft->m_pTextures->loadAndBindTexture(C_TERRAIN_NAME); - - Lighting::turnOff(); - // render the opaque layer - pLR->render(pMob, 0, f); - - Lighting::turnOn(); - pLR->renderEntities(pMob->getPos(f), &frustumCuller, f); - pPE->renderLit(pMob, f); - Lighting::turnOff(); - pPE->render(pMob, f); - - // @BUG: The original demo calls GL_BLEND. We really should be enabling GL_BLEND. - //glEnable(GL_ALPHA); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - setupFog(0); + mce::RenderContext& renderContext = mce::RenderContextImmediate::get(); -#ifndef ORIGINAL_CODE - glShadeModel(GL_SMOOTH); -#endif - - //glEnable(GL_BLEND); - glDisable(GL_CULL_FACE); - // glDepthMask(false); -- added in 0.1.1j. Introduces more issues than fixes - - // render the alpha layer - m_pMinecraft->m_pTextures->loadAndBindTexture(C_TERRAIN_NAME); - pLR->render(pMob, 1, f); - - glDepthMask(true); - -#ifndef ORIGINAL_CODE - glShadeModel(GL_FLAT); -#endif - glEnable(GL_CULL_FACE); - glDisable(GL_BLEND); - - //renderNameTags(f); - if (field_44 == 1.0f && pMob->isPlayer() && m_pMinecraft->m_hitResult.m_hitType != HitResult::NONE && !pMob->isUnderLiquid(Material::water)) - { - glDisable(GL_ALPHA_TEST); - - // added by iProgramInCpp - renders the cracks - pLR->renderHit((Player*)pMob, m_pMinecraft->m_hitResult, 0, nullptr, f); + if (m_pMinecraft->getOptions()->m_bAmbientOcclusion) + { + renderContext.setShadeMode(mce::SHADE_MODE_SMOOTH); + } - if (m_pMinecraft->getOptions()->m_bBlockOutlines) - pLR->renderHitOutline((Player*)pMob, m_pMinecraft->m_hitResult, 0, nullptr, f); - else - pLR->renderHitSelect((Player*)pMob, m_pMinecraft->m_hitResult, 0, nullptr, f); + Frustum& frust = Frustum::frustum; + Frustum::calculateFrustum(); - glEnable(GL_ALPHA_TEST); - } + FrustumCuller frustumCuller; + frustumCuller.m_frustumData.x = frust; + frustumCuller.prepare(camPos); - glDisable(GL_FOG); + levelRenderer.renderLevel(camera, frustumCuller, 0.0f, f); - if (false) // TODO: Figure out how to enable weather - renderWeather(f); - - if (field_44 == 1.0f) - { - glClear(GL_DEPTH_BUFFER_BIT); - renderItemInHand(f, i); - } + if (m_zoom == 1.0f && camera.isPlayer() && m_pMinecraft->m_hitResult.m_hitType != HitResult::NONE && !camera.isUnderLiquid(Material::water)) + { + levelRenderer.renderCracks(camera, m_pMinecraft->m_hitResult, 0, nullptr, f); - if (!bAnaglyph) - break; + if (m_pMinecraft->getOptions()->m_bBlockOutlines) + levelRenderer.renderHitOutline(camera, m_pMinecraft->m_hitResult, 0, nullptr, f); + else + levelRenderer.renderHitSelect(camera, m_pMinecraft->m_hitResult, 0, nullptr, f); } - if (bAnaglyph) - glColorMask(true, true, true, false); + if (m_zoom == 1.0f) + { + _renderItemInHand(f, i); + } } void GameRenderer::render(float f) @@ -651,16 +652,17 @@ void GameRenderer::render(float f) return; } - m_pMinecraft->m_gui.render(f, m_pMinecraft->m_pScreen != nullptr, mouseX, mouseY); + m_pMinecraft->m_pGui->render(f, m_pMinecraft->m_pScreen != nullptr, mouseX, mouseY); } } else { - glViewport(0, 0, Minecraft::width, Minecraft::height); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); + _clearFrameBuffer(); + + MatrixStack::Projection.getTop() = Matrix::IDENTITY; + MatrixStack::View.getTop() = Matrix::IDENTITY; + MatrixStack::World.getTop() = Matrix::IDENTITY; + setupGuiScreen(); } @@ -670,7 +672,7 @@ void GameRenderer::render(float f) if (m_pMinecraft->m_pScreen) { - glClear(GL_DEPTH_BUFFER_BIT); + mce::RenderContextImmediate::get().clearDepthStencilBuffer(); m_pMinecraft->m_pScreen->onRender(mouseX, mouseY, f); if (m_pMinecraft->m_pScreen && !m_pMinecraft->m_pScreen->isInGameScreen()) @@ -682,95 +684,9 @@ void GameRenderer::render(float f) } } - // @TODO: Move to its own function - std::stringstream debugText; - debugText << "ReMinecraftPE " << m_pMinecraft->getVersionString(); - debugText << " (" << m_shownFPS << " fps, " << m_shownChunkUpdates << " chunk updates)" << "\n"; - if (m_pMinecraft->getOptions()->m_bDebugText) { - /* - * The "!m_pMinecraft->m_bPreparingLevel" check *needs* to be here. - * If said check is not here, when getBiome() is called for the biome display, - * it would allocate an array with a size of 1 before the level was even generated. - * Then, during level generation, said array would be written to as if it had a size - * of 256, leading to a heap corruption that took ASan to debug successfully. - * Unfortunately, ASan and DirectSound don't mix, and Microsoft's ASan team has stated that they don't even know why: - * https://developercommunity.visualstudio.com/t/ASAN-x64-causes-unhandled-exception-at-0/1365655#T-N10460750 - * Since all SoundSystems are backed with DirectSound, SoundSystemNull is needed to use ASan. - * This heap corruption bug, which (only if the F3 menu was open) would cause multiplayer functionality to be entirely - * based on luck, had been around since Commit 53200be, on March 5th of 2025, and was fixed on September 30th of 2025. - */ - if (m_pMinecraft->m_pLocalPlayer && !m_pMinecraft->m_bPreparingLevel) - { - char posStr[96]; - Vec3 pos = m_pMinecraft->m_pLocalPlayer->getPos(f); - sprintf(posStr, "%.2f / %.2f / %.2f", pos.x, pos.y, pos.z); - - debugText << m_pMinecraft->m_pLevelRenderer->gatherStats1(); - debugText << m_pMinecraft->m_pLevelRenderer->gatherStats2() << "\n"; - debugText << "XYZ: " << posStr << "\n"; - debugText << "Biome: " << m_pMinecraft->m_pLevel->getBiomeSource()->getBiome(pos)->m_name << "\n"; - } -#ifdef SHOW_VERTEX_COUNTER_GRAPHIC - extern int g_nVertices; // Tesselator.cpp - debugText << "\nverts: " << g_nVertices; - - static int vertGraph[200]; - memcpy(vertGraph, vertGraph + 1, sizeof(vertGraph) - sizeof(int)); - vertGraph [ (sizeof(vertGraph) / sizeof(vertGraph[0])) - 1 ] = g_nVertices; - - g_nVertices = 0; - - Tesselator& t = Tesselator::instance; - - int max = 0; - for (int i = 0; i < 200; i++) - max = std::max(max, vertGraph[i]); - - int maxht = 100; - int h = int(Minecraft::height * Gui::InvGuiScale); - - glDisable(GL_DEPTH_TEST); - glClear(GL_DEPTH_BUFFER_BIT); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - - t.begin(); - t.color(1.0f, 1.0f, 1.0f, 0.15f); - t.vertex(000, h-maxht, 0); - t.vertex(000, h, 0); - t.vertex(200, h, 0); - t.vertex(200, h-maxht, 0); - t.draw(); - - t.begin(); - t.color(0.0f, 1.0f, 0.0f, 1.0f); - - for (int i = 0; i < 200 && max != 0; i++) - { - t.vertex(i + 0, h - (vertGraph[i] * maxht / max), 0); - t.vertex(i + 0, h - 0, 0); - t.vertex(i + 1, h - 0, 0); - t.vertex(i + 1, h - (vertGraph[i] * maxht / max), 0); - } - - t.draw(); - glEnable(GL_DEPTH_TEST); - - - m_pMinecraft->m_pFont->drawShadow(std::to_string(max), 200, h - maxht, 0xFFFFFF); -#endif - - /*debugText << "\nController::stickValuesX[1]: " << Controller::stickValuesX[1]; - debugText << "\nController::stickValuesY[1]: " << Controller::stickValuesY[1]; - debugText << "\nGameRenderer::field_7C: " << field_7C; - debugText << "\nGameRenderer::field_80: " << field_80;*/ - - m_pMinecraft->m_pFont->drawShadow(debugText.str(), 2, 2, 0xFFFFFF); - -#ifdef SHOW_VERTEX_COUNTER_GRAPHIC - g_nVertices = 0; -#endif + _renderDebugOverlay(f); } int timeMs = getTimeMs(); @@ -820,93 +736,28 @@ void GameRenderer::tick() field_74 = 0.0f; field_78 = 0.0f; - field_6C = field_70; field_30 = field_2C; field_38 = field_34; field_40 = field_3C; field_54 = field_50; field_5C = field_58; - Mob* pMob = m_pMinecraft->m_pMobPersp; + Mob* pMob = m_pMinecraft->m_pCameraEntity; if (!pMob) { - pMob = m_pMinecraft->m_pMobPersp = m_pMinecraft->m_pLocalPlayer; + pMob = m_pMinecraft->m_pCameraEntity = m_pMinecraft->m_pLocalPlayer; } - float bright = m_pMinecraft->m_pLevel->getBrightness(pMob->m_pos); - float x3 = float(3 - m_pMinecraft->getOptions()->m_iViewDistance); - field_C++; - float x4 = x3 / 3.0f; - float x5 = (x4 + bright * (1.0f - x4) - field_70) * 0.1f; - - field_70 += x5; - m_pItemInHandRenderer->tick(); } -void GameRenderer::renderItemInHand(float f, int i) -{ - glLoadIdentity(); - - if (m_pMinecraft->getOptions()->m_bAnaglyphs) - glTranslatef(float(2 * i - 1) * 0.1f, 0.0f, 0.0f); - - glPushMatrix(); - bobHurt(f); - - if (m_pMinecraft->getOptions()->m_bViewBobbing) - bobView(f); - - if (!m_pMinecraft->getOptions()->m_bThirdPerson && !m_pMinecraft->getOptions()->m_bDontRenderGui) - m_pItemInHandRenderer->render(f); - - glPopMatrix(); - - if (!m_pMinecraft->getOptions()->m_bThirdPerson) - { - m_pItemInHandRenderer->renderScreenEffect(f); - bobHurt(f); - } - - if (m_pMinecraft->getOptions()->m_bViewBobbing) - bobView(f); -} - -void GameRenderer::prepareAndRenderClouds(LevelRenderer* pLR, float f) -{ - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - gluPerspective(getFov(f), float(Minecraft::width) / float(Minecraft::height), 0.05f, field_8 * 512.0f); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - setupFog(0); - glDepthMask(false); - glEnable(GL_FOG); - glFogf(GL_FOG_START, field_8 * 0.2f); - glFogf(GL_FOG_END, field_8 * 0.75f); - pLR->renderSky(f); - glFogf(GL_FOG_START, field_8 * 4.2f * 0.6f); - glFogf(GL_FOG_END, field_8 * 4.2f); - pLR->renderClouds(f); - glFogf(GL_FOG_START, field_8 * 0.6f); - glFogf(GL_FOG_END, field_8); - glDisable(GL_FOG); - glDepthMask(true); - setupFog(1); - glPopMatrix(); - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); -} - void GameRenderer::renderWeather(float f) { - if (m_envTexturePresence == 0) + /*if (m_envTexturePresence == 0) { - bool bLoadedSuccessfully = m_pMinecraft->m_pTextures->loadTexture("snow.png", false) >= 0; + bool bLoadedSuccessfully = m_pMinecraft->m_pTextures->loadTexture("environment/snow.png", false) != nullptr; m_envTexturePresence = bLoadedSuccessfully ? 2 : 1; } @@ -921,10 +772,7 @@ void GameRenderer::renderWeather(float f) Tesselator& t = Tesselator::instance; Level* pLevel = m_pMinecraft->m_pLevel; - glDisable(GL_CULL_FACE); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - m_pMinecraft->m_pTextures->loadAndBindTexture("snow.png"); + m_pMinecraft->m_pTextures->loadAndBindTexture("environment/snow.png"); int range = m_pMinecraft->getOptions()->m_bFancyGraphics ? 10 : 5; @@ -959,9 +807,10 @@ void GameRenderer::renderWeather(float f) float f2 = float(tp.z + 0.5f) - pLP->m_pos.z; float f3 = Mth::sqrt(f1 * f1 + f2 * f2) / float(range); float f4 = pLevel->getBrightness(tp); - t.begin(); - glColor4f(f4, f4, f4, (1.0f - f3 * f3) * 0.7f); - t.offset(-pos.x, -pos.y, -pos.z); + t.begin(8); + currentShaderColor = Color(f4, f4, f4, (1.0f - f3 * f3) * 0.7f); + currentShaderDarkColor = Color::WHITE; + t.setOffset(-pos.x, -pos.y, -pos.z); t.vertexUV(float(tp.x + 0), float(minY), float(tp.z + 0), 0.0f * offs + x3, float(minY) * offs / 8.0f + x2 * offs + x4); t.vertexUV(float(tp.x + 1), float(minY), float(tp.z + 1), 1.0f * offs + x3, float(minY) * offs / 8.0f + x2 * offs + x4); t.vertexUV(float(tp.x + 1), float(maxY), float(tp.z + 1), 1.0f * offs + x3, float(maxY) * offs / 8.0f + x2 * offs + x4); @@ -970,14 +819,21 @@ void GameRenderer::renderWeather(float f) t.vertexUV(float(tp.x + 1), float(minY), float(tp.z + 0), 1.0f * offs + x3, float(minY) * offs / 8.0f + x2 * offs + x4); t.vertexUV(float(tp.x + 1), float(maxY), float(tp.z + 0), 1.0f * offs + x3, float(maxY) * offs / 8.0f + x2 * offs + x4); t.vertexUV(float(tp.x + 0), float(maxY), float(tp.z + 1), 0.0f * offs + x3, float(maxY) * offs / 8.0f + x2 * offs + x4); - t.offset(0.0f, 0.0f, 0.0f); - t.draw(); + t.setOffset(0.0f, 0.0f, 0.0f); + t.draw(); // use "snow" or "weather" material } - } + }*/ +} + + +void GameRenderer::setLevel(Level* pLevel, Dimension* pDimension) +{ + m_pLevel = pLevel; + + if (!pLevel || !pDimension) + return; - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glEnable(GL_CULL_FACE); - glDisable(GL_BLEND); + //_tickLightTexture(pDimension, 1.0f); } void GameRenderer::onGraphicsReset() @@ -987,10 +843,10 @@ void GameRenderer::onGraphicsReset() void GameRenderer::pick(float f) { - if (!m_pMinecraft->m_pMobPersp || !m_pMinecraft->m_pLevel) + if (!m_pMinecraft->m_pCameraEntity || !m_pMinecraft->m_pLevel) return; - Mob* pMob = m_pMinecraft->m_pMobPersp; + Mob* pMob = m_pMinecraft->m_pCameraEntity; HitResult& mchr = m_pMinecraft->m_hitResult; float dist = m_pMinecraft->m_pGameMode->getBlockReachDistance(); bool isFirstPerson = !m_pMinecraft->getOptions()->m_bThirdPerson; @@ -1012,8 +868,8 @@ void GameRenderer::pick(float f) if (glhUnProjectf(m_pMinecraft->m_pInputHolder->m_feedbackX, Minecraft::height - m_pMinecraft->m_pInputHolder->m_feedbackY, 1.0f, - m_matrix_model_view, - m_matrix_projection, + m_mtxView.ptr(), + m_mtxProj.ptr(), viewport, obj_coord)) { @@ -1022,8 +878,8 @@ void GameRenderer::pick(float f) glhUnProjectf(m_pMinecraft->m_pInputHolder->m_feedbackX, Minecraft::height - m_pMinecraft->m_pInputHolder->m_feedbackY, 0.0f, - m_matrix_model_view, - m_matrix_projection, + m_mtxView.ptr(), + m_mtxProj.ptr(), viewport, obj_coord); @@ -1057,9 +913,9 @@ void GameRenderer::pick(float f) { HitResult hr = m_pMinecraft->m_pLevel->clip(foundPosNear, foundPosFar, false); - float diffX = float(hr.m_tilePos.x) - m_pMinecraft->m_pMobPersp->m_pos.x; - float diffY = float(hr.m_tilePos.y) - m_pMinecraft->m_pMobPersp->m_pos.y; - float diffZ = float(hr.m_tilePos.z) - m_pMinecraft->m_pMobPersp->m_pos.z; + float diffX = float(hr.m_tilePos.x) - m_pMinecraft->m_pCameraEntity->m_pos.x; + float diffY = float(hr.m_tilePos.y) - m_pMinecraft->m_pCameraEntity->m_pos.y; + float diffZ = float(hr.m_tilePos.z) - m_pMinecraft->m_pCameraEntity->m_pos.z; if (hr.m_hitType == HitResult::NONE || diffX * diffX + diffY * diffY + diffZ * diffZ > offset * offset) mchr.m_hitType = HitResult::NONE; diff --git a/source/client/renderer/GameRenderer.hpp b/source/client/renderer/GameRenderer.hpp index 19c2b8641..5c4d10937 100644 --- a/source/client/renderer/GameRenderer.hpp +++ b/source/client/renderer/GameRenderer.hpp @@ -9,11 +9,14 @@ #pragma once #include "ItemInHandRenderer.hpp" +#include "renderer/MatrixStack.hpp" +#include "renderer/hal/interface/DepthStencilState.hpp" class Minecraft; class Entity; class LevelRenderer; +class ParticleEngine; class GameRenderer { private: @@ -22,37 +25,44 @@ class GameRenderer GameRenderer() { _init(); } GameRenderer(Minecraft*); ~GameRenderer(); + +private: + void _clearFrameBuffer(); + void _renderItemInHand(float, int); + void _renderDebugOverlay(float a); + void _renderVertexGraph(int vertices, int h); + +public: void saveMatrices(); void setupCamera(float f, int i); - void bobHurt(float); - void bobView(float); - void moveCameraToPlayer(float); + void bobHurt(Matrix& matrix, float f); + void bobView(Matrix& matrix, float f); + void moveCameraToPlayer(Matrix& matrix, float f); #ifndef ORIGINAL_CODE void renderNoCamera(); #endif void renderLevel(float); + void renderFramedItems(const Vec3& camPos, LevelRenderer& levelRenderer, const Entity& camera, float f, ParticleEngine& particleEngine, float i); void render(float); + void renderWeather(float f); + void setLevel(Level* pLevel, Dimension* pDimension); void tick(); void setupGuiScreen(); void onGraphicsReset(); - void zoomRegion(float a, float b, float c); + void zoomRegion(float zoom, const Vec2& region); void unZoomRegion(); - void setupClearColor(float f); - void setupFog(int i); void pick(float); - void renderItemInHand(float, int); - void prepareAndRenderClouds(LevelRenderer* pLR, float f); - void renderWeather(float f); float getFov(float f); public: ItemInHandRenderer* m_pItemInHandRenderer; Minecraft* m_pMinecraft; + Level* m_pLevel; - float field_8; + float m_renderDistance; int field_C; Entity* m_pHovered; float field_14; @@ -67,26 +77,20 @@ class GameRenderer float field_38; float field_3C; float field_40; - float field_44; - float field_48; - float field_4C; + float m_zoom; + Vec2 m_zoomRegion; float field_50; float field_54; float field_58; float field_5C; - float field_60; - float field_64; - float field_68; - float field_6C; - float field_70; float field_74; float field_78; float field_7C; float field_80; float field_84; - float m_matrix_projection[16]; - float m_matrix_model_view[16]; + Matrix m_mtxProj; + Matrix m_mtxView; int m_shownFPS, m_shownChunkUpdates, m_lastUpdatedMS; diff --git a/source/client/renderer/GrassColor.cpp b/source/client/renderer/GrassColor.cpp index 9e934b05e..53398a9bf 100644 --- a/source/client/renderer/GrassColor.cpp +++ b/source/client/renderer/GrassColor.cpp @@ -3,9 +3,9 @@ bool GrassColor::_isAvailable = false; -Texture GrassColor::texture; +TextureData GrassColor::texture; -void GrassColor::init(Texture texture) +void GrassColor::init(TextureData& texture) { GrassColor::texture = texture; } @@ -13,7 +13,7 @@ void GrassColor::init(Texture texture) uint32_t GrassColor::get(double x, double y) { y *= x; - uint32_t c = GrassColor::texture.m_pixels[(int)((1.0 - y) * 255.0) << 8 | (int)((1.0 - x) * 255.0)]; + uint32_t c = GrassColor::texture.getData()[(int)((1.0 - y) * 255.0) << 8 | (int)((1.0 - x) * 255.0)]; #if MC_ENDIANNESS_BIG uint8_t r = c & 0xFF, g = (c >> 8) & 0xFF, b = (c >> 16) & 0xFF, a = (c >> 24) & 0xFF; diff --git a/source/client/renderer/GrassColor.hpp b/source/client/renderer/GrassColor.hpp index 69a967999..b4c5e67c2 100644 --- a/source/client/renderer/GrassColor.hpp +++ b/source/client/renderer/GrassColor.hpp @@ -2,7 +2,7 @@ #include -#include "client/renderer/Texture.hpp" +#include "client/renderer/texture/TextureData.hpp" class GrassColor { @@ -10,13 +10,13 @@ class GrassColor static bool isAvailable() { return _isAvailable; } static void setIsAvailable(bool value) { _isAvailable = value; } - static void init(Texture texture); + static void init(TextureData& texture); static uint32_t get(double x, double y); private: static bool _isAvailable; - static Texture texture; + static TextureData texture; }; diff --git a/source/client/renderer/ItemInHandRenderer.cpp b/source/client/renderer/ItemInHandRenderer.cpp index 074583839..1b4780f99 100644 --- a/source/client/renderer/ItemInHandRenderer.cpp +++ b/source/client/renderer/ItemInHandRenderer.cpp @@ -7,10 +7,22 @@ ********************************************************************/ #include "ItemInHandRenderer.hpp" -#include "client/app/Minecraft.hpp" #include "common/Mth.hpp" +#include "client/app/Minecraft.hpp" +#include "client/renderer/renderer/RenderMaterialGroup.hpp" +#include "renderer/ShaderConstants.hpp" #include "Lighting.hpp" +ItemInHandRenderer::Materials::Materials() +{ + MATERIAL_PTR(switchable, entity); + MATERIAL_PTR(switchable, entity_alphatest); + MATERIAL_PTR(switchable, item_in_hand); + MATERIAL_PTR(switchable, entity_glint); + MATERIAL_PTR(switchable, entity_alphatest_glint); + MATERIAL_PTR(switchable, item_in_hand_glint); +} + ItemInHandRenderer::ItemInHandRenderer(Minecraft* pMC) : m_selectedItem(0, 1, 0), m_pMinecraft(pMC) @@ -32,41 +44,130 @@ void ItemInHandRenderer::itemUsed() m_height = 0; } +void ItemInHandRenderer::render(float a) +{ + LocalPlayer* pLP = m_pMinecraft->m_pLocalPlayer; + +#ifndef FEATURE_GFX_SHADERS + // Apply lighting + { + MatrixStack::Ref matrix = MatrixStack::World.push(); + matrix->rotate(pLP->m_oRot.y + (pLP->m_rot.y - pLP->m_oRot.y) * a, Vec3::UNIT_X); + matrix->rotate(pLP->m_oRot.x + (pLP->m_rot.x - pLP->m_oRot.x) * a, Vec3::UNIT_Y); + + Lighting::turnOn(matrix); + } +#endif + + MatrixStack::Ref matrix = MatrixStack::World.push(); + + if (m_pMinecraft->getOptions()->m_bDynamicHand && m_pMinecraft->m_pCameraEntity == pLP) + { + float rYaw = Mth::Lerp(pLP->m_lastRenderArmRot.x, pLP->m_renderArmRot.x, a); + float rPitch = Mth::Lerp(pLP->m_lastRenderArmRot.y, pLP->m_renderArmRot.y, a); + matrix->rotate((pLP->m_rot.y - rPitch) * 0.1f, Vec3::UNIT_X); + matrix->rotate((pLP->m_rot.x - rYaw ) * 0.1f, Vec3::UNIT_Y); + } + + float fBright = m_pMinecraft->m_pLevel->getBrightness(pLP->m_pos); + currentShaderColor = Color::WHITE; + currentShaderDarkColor = Color(fBright, fBright, fBright); + + ItemInstance* pItem = &m_selectedItem; + /*if (pLP->m_fishing != null) + { + pItem = new ItemInstance(Item::stick); + }*/ + + float swing2, swing3; + float fAnim = pLP->getAttackAnim(a); + float h = m_oHeight + (m_height - m_oHeight) * a; + constexpr float d = 0.8f; + + if (!ItemInstance::isNull(pItem)) + { + matrix->translate(Vec3(-0.4f * Mth::sin(float(M_PI) * Mth::sqrt(fAnim)), 0.2f * Mth::sin(2.0f * float(M_PI) * Mth::sqrt(fAnim)), -0.2f * Mth::sin(float(M_PI) * fAnim))); + matrix->translate(Vec3(0.7f * d, -0.65f * d - (1.0f - h) * 0.6f, -0.9f * d)); + matrix->rotate(45.0f, Vec3::UNIT_Y); + +#if MCE_GFX_API_OGL + glEnable(GL_RESCALE_NORMAL); +#endif + + swing3 = Mth::sin(float(M_PI) * fAnim * fAnim); + swing2 = Mth::sin(float(M_PI) * Mth::sqrt(fAnim)); + + matrix->rotate(swing3 * -20.0f, Vec3::UNIT_Y); + matrix->rotate(swing2 * -20.0f, Vec3::UNIT_Z); + matrix->rotate(swing2 * -80.0f, Vec3::UNIT_X); + matrix->scale(0.4f); + + if (pItem->getItem()->isMirroredArt()) + { + matrix->rotate(180.0f, Vec3::UNIT_Y); + } + + renderItem(*pLP, *pItem, a); + } + else + { + matrix->translate(Vec3(-0.3f * Mth::sin(float(M_PI) * Mth::sqrt(fAnim)), 0.4f * Mth::sin(2.0f * float(M_PI) * Mth::sqrt(fAnim)), -0.4f * Mth::sin(float(M_PI) * fAnim))); + matrix->translate(Vec3(0.8f * d, -0.75f * d - (1.0f - h) * 0.6f, -0.9f * d)); + matrix->rotate(45.0f, Vec3::UNIT_Y); +#if MCE_GFX_API_OGL + glEnable(GL_RESCALE_NORMAL); +#endif + + matrix->rotate(Mth::sin(float(M_PI) * Mth::sqrt(fAnim)) * 70.0f, Vec3::UNIT_Y); + matrix->rotate(Mth::sin(float(M_PI) * fAnim * fAnim) * -20.0f, Vec3::UNIT_Z); + + m_pMinecraft->m_pTextures->loadAndBindTexture("mob/char.png"); + matrix->translate(Vec3(-1.0f, 3.6f, 3.5f)); + matrix->rotate(120.0f, Vec3::UNIT_Z); + matrix->rotate(200.0f, Vec3::UNIT_X); + matrix->rotate(-135.0f, Vec3::UNIT_Y); + matrix->scale(1.0f); + matrix->translate(Vec3(5.6f, 0.0f, 0.0f)); + + HumanoidMobRenderer* pRenderer = (HumanoidMobRenderer*)EntityRenderDispatcher::getInstance()->getRenderer(*pLP); + swing2 = 1.0f; + matrix->scale(swing2); + pRenderer->renderHand(); + } + +#if MCE_GFX_API_OGL + glDisable(GL_RESCALE_NORMAL); +#endif + Lighting::turnOff(); +} + #ifdef ENH_SHADE_HELD_TILES #define SHADE_IF_NEEDED(col) t.color(col*bright,col*bright,col*bright,1.0f) #else #define SHADE_IF_NEEDED(col) #endif -void ItemInHandRenderer::renderItem(ItemInstance* inst) +void ItemInHandRenderer::renderItem(const Entity& entity, const ItemInstance& item, float a) { -#ifndef ORIGINAL_CODE - if (ItemInstance::isNull(inst)) + if (item.isNull()) return; -#endif - - glPushMatrix(); + #ifdef ENH_SHADE_HELD_TILES - float bright = m_pMinecraft->m_pLocalPlayer->getBrightness(0.0f); + float bright = entity.getBrightness(0.0f); #endif - Tile* pTile = inst->getTile(); + Tile* pTile = item.getTile(); if (pTile && TileRenderer::canRender(pTile->getRenderShape())) { - float red, grn, blu, alp = 1.0f; + Color color = Color::WHITE; if (pTile == Tile::leaves) { - red = 0.35f; - grn = 0.65f; - blu = 0.25f; - } - else - { - blu = grn = red = 1.0f; + color = Color(0.35f, 0.65f, 0.25f); } - - glColor4f(red, grn, blu, alp); + + currentShaderColor = color; + currentShaderDarkColor = Color::WHITE; m_pMinecraft->m_pTextures->loadAndBindTexture(C_TERRAIN_NAME); @@ -76,7 +177,7 @@ void ItemInHandRenderer::renderItem(ItemInstance* inst) # define ARGPATCH #endif - m_tileRenderer.renderTile(pTile, inst->getAuxValue() ARGPATCH); + m_tileRenderer.renderTile(FullTile(pTile, item.getAuxValue()), m_materials.item_in_hand ARGPATCH); #ifdef ARGPATCH # undef ARGPATCH @@ -85,6 +186,8 @@ void ItemInHandRenderer::renderItem(ItemInstance* inst) } else { + MatrixStack::Ref matrix = MatrixStack::World.push(); + std::string toBind; if (pTile) toBind = C_TERRAIN_NAME; @@ -96,8 +199,8 @@ void ItemInHandRenderer::renderItem(ItemInstance* inst) constexpr float C_RATIO_2 = 1.0f / 512.0f; constexpr float C_ONE_PIXEL = 1.0f / 16.0f; - int textureX = inst->getIcon() % 16 * 16; - int textureY = inst->getIcon() / 16 * 16; + int textureX = item.getIcon() % 16 * 16; + int textureY = item.getIcon() / 16 * 16; float texU_1 = C_RATIO * float(textureX + 0.0f); float texU_2 = C_RATIO * float(textureX + 15.99f); @@ -105,29 +208,36 @@ void ItemInHandRenderer::renderItem(ItemInstance* inst) float texV_2 = C_RATIO * float(textureY + 15.99f); Tesselator& t = Tesselator::instance; - glTranslatef(-0.0f, -0.3f, 0.0f); - glScalef(1.5f, 1.5f, 1.5f); - glRotatef(50.0f, 0.0f, 1.0f, 0.0f); - glRotatef(335.0f, 0.0f, 0.0f, 1.0f); - glTranslatef(-0.9375f, -0.0625f, 0.0f); + + matrix->translate(Vec3(-0.0f, -0.3f, 0.0f)); + matrix->scale(1.5f); + matrix->rotate(50.0f, Vec3::UNIT_Y); + matrix->rotate(335.0f, Vec3::UNIT_Z); + matrix->translate(Vec3(-0.9375f, -0.0625f, 0.0f)); + /*matrix->translate(Vec3(0.075f, -0.245f, -0.1f)); + matrix->scale(0.0625f); + matrix->rotate(90.0f, Vec3::UNIT_Z); + matrix->rotate(-90.0f, Vec3::UNIT_X); + matrix->rotate(-90.0f, Vec3::UNIT_Y); + matrix->translate(Vec3(0.0f, 0.0f, -16.0f));*/ - t.begin(); + t.begin(264); SHADE_IF_NEEDED(1.0f); - t.normal(0.0f, 0.0f, 1.0f); + t.normal(Vec3::UNIT_Z); t.vertexUV(0.0f, 0.0f, 0.0f, texU_2, texV_2); t.vertexUV(1.0f, 0.0f, 0.0f, texU_1, texV_2); t.vertexUV(1.0f, 1.0f, 0.0f, texU_1, texV_1); t.vertexUV(0.0f, 1.0f, 0.0f, texU_2, texV_1); - t.normal(0.0f, 0.0f, -1.0f); + t.normal(Vec3::NEG_UNIT_Z); t.vertexUV(0.0f, 1.0f, -C_ONE_PIXEL, texU_2, texV_1); t.vertexUV(1.0f, 1.0f, -C_ONE_PIXEL, texU_1, texV_1); t.vertexUV(1.0f, 0.0f, -C_ONE_PIXEL, texU_1, texV_2); t.vertexUV(0.0f, 0.0f, -C_ONE_PIXEL, texU_2, texV_2); SHADE_IF_NEEDED(0.8f); - t.normal(-1.0f, 0.0f, 0.0f); + t.normal(Vec3::NEG_UNIT_X); for (int i = 0; i < 16; i++) { t.vertexUV(i * C_ONE_PIXEL, 0.0f, -C_ONE_PIXEL, Mth::Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_2); @@ -159,102 +269,42 @@ void ItemInHandRenderer::renderItem(ItemInstance* inst) t.vertexUV(1.0f, i * C_ONE_PIXEL, -C_ONE_PIXEL, texU_1, Mth::Lerp(texV_2, texV_1, i * C_ONE_PIXEL)); } - t.draw(); + t.draw(m_materials.item_in_hand); } - - glPopMatrix(); } -void ItemInHandRenderer::render(float f) +void ItemInHandRenderer::renderScreenEffect(float a) { - LocalPlayer* pLP = m_pMinecraft->m_pLocalPlayer; - - float h = m_oHeight + (m_height - m_oHeight) * f; - glPushMatrix(); - glRotatef(pLP->m_oRot.y + (pLP->m_rot.y - pLP->m_oRot.y) * f, 1.0f, 0.0f, 0.0f); - glRotatef(pLP->m_oRot.x + (pLP->m_rot.x - pLP->m_oRot.x) * f, 0.0f, 1.0f, 0.0f); - Lighting::turnOn(); // must be called before glPopMatrix() - glPopMatrix(); - - if (m_pMinecraft->getOptions()->m_bDynamicHand && m_pMinecraft->m_pMobPersp == pLP) - { - float rYaw = Mth::Lerp(pLP->m_lastRenderArmRot.x, pLP->m_renderArmRot.x, f); - float rPitch = Mth::Lerp(pLP->m_lastRenderArmRot.y, pLP->m_renderArmRot.y, f); - glRotatef((pLP->m_rot.y - rPitch) * 0.1f, 1.0f, 0.0f, 0.0f); - glRotatef((pLP->m_rot.x - rYaw ) * 0.1f, 0.0f, 1.0f, 0.0f); - } - - float fBright = m_pMinecraft->m_pLevel->getBrightness(pLP->m_pos); - glColor4f(fBright, fBright, fBright, 1.0f); - - ItemInstance* pItem = &m_selectedItem; - /*if (pLP->m_fishing != null) { - pItem = new ItemInstance(Item::stick); - }*/ - - glPushMatrix(); - - float swing2, swing3; - float fAnim = pLP->getAttackAnim(f); - constexpr float d = 0.8f; - - if (!ItemInstance::isNull(pItem)) - { - glTranslatef(-0.4f * Mth::sin(float(M_PI) * Mth::sqrt(fAnim)), 0.2f * Mth::sin(2.0f * float(M_PI) * Mth::sqrt(fAnim)), -0.2f * Mth::sin(float(M_PI) * fAnim)); - glTranslatef(0.7f * d, -0.65f * d - (1.0f - h) * 0.6f, -0.9f * d); - glRotatef(45.0f, 0.0f, 1.0f, 0.0f); - glEnable(GL_RESCALE_NORMAL); - - swing3 = Mth::sin(float(M_PI) * fAnim * fAnim); - swing2 = Mth::sin(float(M_PI) * Mth::sqrt(fAnim)); - - glRotatef(swing3 * -20.0f, 0.0f, 1.0f, 0.0f); - glRotatef(swing2 * -20.0f, 0.0f, 0.0f, 1.0f); - glRotatef(swing2 * -80.0f, 1.0f, 0.0f, 0.0f); - glScalef(0.4f, 0.4f, 0.4f); - - if (pItem->getItem()->isMirroredArt()) - glRotatef(180.0f, 0.0f, 1.0f, 0.0f); - - renderItem(pItem); - } - else - { - glTranslatef(-0.3f * Mth::sin(float(M_PI) * Mth::sqrt(fAnim)), 0.4f * Mth::sin(2.0f * float(M_PI) * Mth::sqrt(fAnim)), -0.4f * Mth::sin(float(M_PI) * fAnim)); - glTranslatef(0.8f * d, -0.75f * d - (1.0f - h) * 0.6f, -0.9f * d); - glRotatef(45.0f, 0.0f, 1.0f, 0.0f); - glEnable(GL_RESCALE_NORMAL); + LocalPlayer* player = m_pMinecraft->m_pLocalPlayer; + Textures* textures = m_pMinecraft->m_pTextures; + Level* level = m_pMinecraft->m_pLevel; - glRotatef(Mth::sin(float(M_PI) * Mth::sqrt(fAnim)) * 70.0f, 0.0f, 1.0f, 0.0f); - glRotatef(Mth::sin(float(M_PI) * fAnim * fAnim) * -20.0f, 0.0f, 0.0f, 1.0f); + if (player->isOnFire()) + { + textures->loadAndBindTexture(C_TERRAIN_NAME); + renderFire(a); + } - m_pMinecraft->m_pTextures->loadAndBindTexture("mob/char.png"); - glTranslatef(-1.0f, 3.6f, 3.5f); - glRotatef(120.0f, 0.0f, 0.0f, 1.0f); - glRotatef(200.0f, 1.0f, 0.0f, 0.0f); - glRotatef(-135.0f, 0.0f, 1.0f, 0.0f); - glScalef(1.0f, 1.0f, 1.0f); - glTranslatef(5.6f, 0.0f, 0.0f); - - HumanoidMobRenderer* pRenderer = (HumanoidMobRenderer*)EntityRenderDispatcher::getInstance()->getRenderer(pLP); - swing2 = 1.0f; - glScalef(swing2, swing2, swing2); - pRenderer->renderHand(); - } + if (player->isInWall() && !m_pMinecraft->getOptions()->m_bFlyCheat) + { + textures->loadAndBindTexture(C_TERRAIN_NAME); - glPopMatrix(); - glDisable(GL_RESCALE_NORMAL); - Lighting::turnOff(); + Tile* pTile = Tile::tiles[level->getTile(player->m_pos)]; + if (pTile) + { + int texture = pTile->getTexture(Facing::NORTH); + renderTex(a, texture); + } + } } -void ItemInHandRenderer::renderFire(float f) +void ItemInHandRenderer::renderFire(float a) { - glColor4f(1.0f, 1.0f, 1.0f, 0.9f); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + currentShaderColor = Color(1.0f, 1.0f, 1.0f, 0.9f); + currentShaderDarkColor = Color::WHITE; for (int i = 0; i < 2; i++) { - glPushMatrix(); + MatrixStack::Ref matrix = MatrixStack::World.push(); int texture = Tile::fire->m_TextureFrame + i * 16; float texX = 16.0f * float(texture % 16), texY = 16.0f * float(texture / 16); @@ -263,29 +313,23 @@ void ItemInHandRenderer::renderFire(float f) float texV_1 = texY / 256.0f; float texV_2 = (texY + 15.99f) / 256.0f; - glTranslatef(float(-(i * 2 - 1)) * 0.24f, -0.3f, 0.0f); - glRotatef(float(-(i * 2 - 1)) * 10.0f, 0.0f, 1.0f, 0.0f); + matrix->translate(Vec3(float(-(i * 2 - 1)) * 0.24f, -0.3f, 0.0f)); + matrix->rotate(float(-(i * 2 - 1)) * 10.0f, Vec3::UNIT_Y); - Tesselator& t = Tesselator::instance; - t.begin(); - t.vertexUV(-0.5f, -0.5f, -0.5f, texU_2, texV_2); - t.vertexUV(+0.5f, -0.5f, -0.5f, texU_1, texV_2); - t.vertexUV(+0.5f, +0.5f, -0.5f, texU_1, texV_1); - t.vertexUV(-0.5f, +0.5f, -0.5f, texU_2, texV_1); - t.draw(); - - glPopMatrix(); + ScreenRenderer& screenRenderer = ScreenRenderer::singleton(); + screenRenderer.blitRaw(-0.5f, 0.5f, -0.5f, 0.5f, -0.5f, texU_1, texU_2, texV_1, texV_2); } - - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glDisable(GL_BLEND); } -void ItemInHandRenderer::renderTex(float f, int texture) +void ItemInHandRenderer::renderTex(float a, int texture) { - //float brightness = m_pMinecraft->m_pLocalPlayer->getBrightness(f); - glColor4f(0.1f, 0.1f, 0.1f, 0.5f); - glPushMatrix(); + ScreenRenderer& screenRenderer = ScreenRenderer::singleton(); + + //m_pMinecraft->m_pLocalPlayer->getBrightness(a); + constexpr float br = 0.1f; // 0.3f on PE 0.12.1 + currentShaderColor = Color(br, br, br, 0.5f); + currentShaderDarkColor = Color::WHITE; + MatrixStack::Ref matrix = MatrixStack::World.push(); // @BUG: The texture x/y isn't multiplied by 16. This causes some weird textures to show up instead of the correct ones. #ifdef ORIGINAL_CODE @@ -300,15 +344,12 @@ void ItemInHandRenderer::renderTex(float f, int texture) float texV_2 = (texY + 15.99f) / 256.0f + 1 / 128.0f; Tesselator& t = Tesselator::instance; - t.begin(); + t.begin(4); t.vertexUV(-1.0f, -1.0f, -0.5f, texU_2, texV_2); t.vertexUV(+1.0f, -1.0f, -0.5f, texU_1, texV_2); t.vertexUV(+1.0f, +1.0f, -0.5f, texU_1, texV_1); t.vertexUV(-1.0f, +1.0f, -0.5f, texU_2, texV_1); - t.draw(); - - glPopMatrix(); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + t.draw(screenRenderer.m_materials.ui_textured_and_glcolor); } void ItemInHandRenderer::tick() @@ -357,32 +398,3 @@ void ItemInHandRenderer::turn(const Vec2& rot) { } -void ItemInHandRenderer::renderScreenEffect(float f) -{ - glDisable(GL_ALPHA_TEST); - - LocalPlayer* player = m_pMinecraft->m_pLocalPlayer; - Textures* textures = m_pMinecraft->m_pTextures; - Level* level = m_pMinecraft->m_pLevel; - - if (player->isOnFire()) - { - textures->loadAndBindTexture(C_TERRAIN_NAME); - renderFire(f); - } - - if (player->isInWall() && !m_pMinecraft->getOptions()->m_bFlyCheat) - { - textures->loadAndBindTexture(C_TERRAIN_NAME); - - Tile* pTile = Tile::tiles[level->getTile(player->m_pos)]; - if (pTile) - { - int texture = pTile->getTexture(Facing::NORTH); - renderTex(f, texture); - } - } - - glEnable(GL_ALPHA_TEST); -} - diff --git a/source/client/renderer/ItemInHandRenderer.hpp b/source/client/renderer/ItemInHandRenderer.hpp index a3615f137..f71b634fa 100644 --- a/source/client/renderer/ItemInHandRenderer.hpp +++ b/source/client/renderer/ItemInHandRenderer.hpp @@ -15,15 +15,29 @@ class Minecraft; class ItemInHandRenderer { +protected: + class Materials + { + public: + mce::MaterialPtr entity; + mce::MaterialPtr entity_alphatest; + mce::MaterialPtr item_in_hand; + mce::MaterialPtr entity_glint; + mce::MaterialPtr entity_alphatest_glint; + mce::MaterialPtr item_in_hand_glint; + + Materials(); + }; + public: ItemInHandRenderer(Minecraft* pMC); void itemPlaced(); void itemUsed(); - void render(float f); - void renderItem(ItemInstance*); - void renderScreenEffect(float f); - void renderFire(float f); - void renderTex(float f, int tex); + void render(float a); + void renderItem(const Entity& entity, const ItemInstance& item, float a); + void renderScreenEffect(float a); + void renderFire(float a); + void renderTex(float a, int tex); void tick(); void turn(const Vec2& rot); @@ -35,5 +49,6 @@ class ItemInHandRenderer float m_height; float m_oHeight; TileRenderer m_tileRenderer; + Materials m_materials; }; diff --git a/source/client/renderer/LevelRenderer.cpp b/source/client/renderer/LevelRenderer.cpp index 2128c4c26..74c0599df 100644 --- a/source/client/renderer/LevelRenderer.cpp +++ b/source/client/renderer/LevelRenderer.cpp @@ -11,20 +11,56 @@ #include "common/Logger.hpp" #include "common/Mth.hpp" #include "client/app/Minecraft.hpp" -#include "renderer/GL/GL.hpp" +#include "client/renderer/renderer/RenderMaterialGroup.hpp" +#include "renderer/ShaderConstants.hpp" +#include "renderer/RenderContextImmediate.hpp" + +#if MCE_GFX_API_OGL +#include "thirdparty/GL/GL.hpp" +#endif #include "world/tile/LeafTile.hpp" #include "world/tile/GrassTile.hpp" +#include "Fog.hpp" +#include "Lighting.hpp" + +TerrainLayer renderLayerToTerrainLayerMap[Tile::RENDER_LAYERS_COUNT] = { + /*RENDER_LAYER_DOUBLE_SIDED*/ TERRAIN_LAYER_DOUBLE_SIDED, + /*RENDER_LAYER_BLEND*/ TERRAIN_LAYER_BLEND, + /*RENDER_LAYER_OPAQUE*/ TERRAIN_LAYER_OPAQUE, + /*RENDER_LAYER_OPTIONAL_ALPHATEST*/ TERRAIN_LAYER_ALPHATEST_SINGLE_SIDE, // Shouldn't be single-sided, but this + /*RENDER_LAYER_ALPHATEST*/ TERRAIN_LAYER_ALPHATEST_SINGLE_SIDE, // breaks leaves and glass blocks. + /*RENDER_LAYER_SEASONS_OPAQUE*/ TERRAIN_LAYER_OPAQUE_SEASONS, + /*RENDER_LAYER_SEASONS_OPTIONAL_ALPHATEST*/ TERRAIN_LAYER_ALPHATEST_SEASONS +}; + +LevelRenderer::Materials::Materials() +{ + MATERIAL_PTR(common, shadow_back); + MATERIAL_PTR(common, shadow_front); + MATERIAL_PTR(common, shadow_overlay); + MATERIAL_PTR(common, shadow_image_overlay); + MATERIAL_PTR(common, stars); + MATERIAL_PTR(common, skyplane); + MATERIAL_PTR(common, sun_moon); + MATERIAL_PTR(common, sunrise); + MATERIAL_PTR(common, selection_overlay); + MATERIAL_PTR(common, selection_overlay_opaque); + MATERIAL_PTR(common, selection_overlay_double_sided); + MATERIAL_PTR(common, selection_box); + MATERIAL_PTR(common, cracks_overlay); + MATERIAL_PTR(common, cracks_overlay_tile_entity); + MATERIAL_PTR(switchable, clouds); +} + bool LevelRenderer::_areCloudsAvailable = false; // false because 0.1 didn't have them bool LevelRenderer::_arePlanetsAvailable = false; // false because 0.1 didn't have them LevelRenderer::LevelRenderer(Minecraft* pMC, Textures* pTexs) { - field_4 = -9999.0f; - field_8 = -9999.0f; - field_C = -9999.0f; - field_10 = 0.0f; + m_posPrev = -9999.0f; + m_destroyProgress = 0.0f; m_noEntityRenderFrames = 2; m_totalEntities = 0; m_renderedEntities = 0; @@ -36,49 +72,43 @@ LevelRenderer::LevelRenderer(Minecraft* pMC, Textures* pTexs) m_renderedChunks = 0; m_emptyChunks = 0; field_68 = 0; - m_resortedMinX = 0; - m_resortedMinY = 0; - m_resortedMinZ = 0; - m_resortedMaxX = 0; - m_resortedMaxY = 0; - m_resortedMaxZ = 0; + m_xMinChunk = 0; + m_yMinChunk = 0; + m_zMinChunk = 0; + m_xMaxChunk = 0; + m_yMaxChunk = 0; + m_zMaxChunk = 0; m_pLevel = nullptr; + m_pDimension = nullptr; m_chunks = nullptr; - field_98 = nullptr; + m_sortedChunks = nullptr; m_chunksLength = 0; m_pTileRenderer = nullptr; - field_A4 = 0; - field_A8 = 0; - field_AC = 0; - field_B0 = 0; - field_B8 = false; - field_BC = -1; + m_xChunks = 0; + m_yChunks = 0; + m_zChunks = 0; + m_chunkLists = 0; + m_bOcclusionCheck = false; // getOpenGLCapabilities().hasOcclusionChecks() + m_lastViewDistance = -1; m_ticksSinceStart = 0; - m_nBuffers = 26136; + m_fogBrO = 0.0f; + m_fogBr = 0.0f; m_pMinecraft = pMC; m_pTextures = pTexs; - m_pBuffers = new GLuint[m_nBuffers]; - xglGenBuffers(m_nBuffers, m_pBuffers); - LOG_I("numBuffers: %d", m_nBuffers); - - xglGenBuffers(1, &m_starBuffer); - generateStars(); - - xglGenBuffers(1, &m_skyBuffer); - xglGenBuffers(1, &m_darkBuffer); - generateSky(); // inlined in the 0.1.0 demo + _initResources(); + RenderChunk::InitMaterials(); } -void LevelRenderer::generateSky() +void LevelRenderer::_buildSkyMesh() { int s = 128; int d = 256 / s + 2; Tesselator& t = Tesselator::instance; - t.begin(); - m_skyBufferCount = 0; + // @TODO: 12-vertex MCPE sky + t.begin(324); float yy = 16.0f; for (int xx = -s * d; xx <= s * d; xx += s) @@ -89,17 +119,14 @@ void LevelRenderer::generateSky() t.vertex(xx + s, yy, zz + 0); t.vertex(xx + s, yy, zz + s); t.vertex(xx + 0, yy, zz + s); - - m_skyBufferCount += 4; } } - t.end(m_skyBuffer); + m_skyMesh = t.end(); // This code is almost the same, ugly - t.begin(); - m_darkBufferCount = 0; + t.begin(324); // pre-computed m_darkBufferCount yy = -16.0f; for (int xx = -s * d; xx <= s * d; xx += s) @@ -110,20 +137,17 @@ void LevelRenderer::generateSky() t.vertex(xx + 0, yy, zz + 0); t.vertex(xx + 0, yy, zz + s); t.vertex(xx + s, yy, zz + s); - - m_darkBufferCount += 4; } } - t.end(m_darkBuffer); + m_darkMesh = t.end(); } -void LevelRenderer::generateStars() +void LevelRenderer::_buildStarsMesh() { - Random random = Random(10842L); + Random random = Random(10842L); // is there any good reason why this specifically is a long? Tesselator& t = Tesselator::instance; - t.begin(); - m_starBufferCount = 0; + t.begin(3160); for (int i = 0; i < 1500; i++) { @@ -164,22 +188,243 @@ void LevelRenderer::generateStars() float zo = __zo * ySin + _xo * yCos; t.vertex(xp + xo, yp + _yo, zp + zo); } - m_starBufferCount += 4; } } - t.end(m_starBuffer); + m_starsMesh = t.end(); +} + +void LevelRenderer::_buildSunAndMoonMeshes() +{ + +} + +void LevelRenderer::_buildShadowVolume() +{ + +} + +void LevelRenderer::_buildShadowOverlay() +{ + +} + +void LevelRenderer::_initResources() +{ + _buildSkyMesh(); + _buildStarsMesh(); + _buildSunAndMoonMeshes(); + _buildShadowVolume(); + _buildShadowOverlay(); +} + +void LevelRenderer::_renderSunrise(float alpha) +{ + Tesselator& t = Tesselator::instance; + + float* c = m_pLevel->m_pDimension->getSunriseColor(m_pLevel->getTimeOfDay(alpha), alpha); + if (c != nullptr && arePlanetsAvailable()) + { + MatrixStack::Ref matrix = MatrixStack::World.push(); + matrix->rotate(90.0f, Vec3::UNIT_X); + matrix->rotate(m_pLevel->getTimeOfDay(alpha) > 0.5f ? 180 : 0, Vec3::UNIT_Z); + + int steps = 16; + + t.begin(mce::PRIMITIVE_MODE_TRIANGLE_STRIP, steps * 2); + + for (int i = 0; i <= steps; i++) + { + float a = i * 3.1415927f * 2.0f / steps; + float sin = Mth::sin(a); + float cos = Mth::cos(a); + + t.color(c[0], c[1], c[2], c[3]); + t.vertex(0.0f, 100.0f, 0.0f); + + t.color(c[0], c[1], c[2], 0.0f); + t.vertex((sin * 120.0f), (cos * 120.0f), (-cos * 40.0f * c[3])); + } + + t.draw(m_materials.sunrise); + } +} + +void LevelRenderer::_renderSolarSystem(float alpha) +{ + MatrixStack::Ref planetMtx = MatrixStack::World.push(); + + _renderSunAndMoon(alpha); + _renderStars(alpha); +} + +void LevelRenderer::_renderSunAndMoon(float alpha) +{ + Tesselator& t = Tesselator::instance; + + Matrix& matrix = MatrixStack::World.getTop(); + + Vec3 p = Vec3::ZERO; + + currentShaderColor = Color::WHITE; + currentShaderDarkColor = Color::WHITE; + + matrix.translate(p); + matrix.rotate(0.0f, Vec3::UNIT_Z); + matrix.rotate(m_pLevel->getTimeOfDay(alpha) * 360.0f, Vec3::UNIT_X); + + if (arePlanetsAvailable()) + { + float ss = 30.0f; + m_pTextures->loadAndBindTexture("terrain/sun.png"); + t.begin(4); + t.vertexUV(-ss, 100.0f, -ss, 0.0f, 0.0f); + t.vertexUV(ss, 100.0f, -ss, 1.0f, 0.0f); + t.vertexUV(ss, 100.0f, ss, 1.0f, 1.0f); + t.vertexUV(-ss, 100.0f, ss, 0.0f, 1.0f); + t.draw(m_materials.sun_moon); + + ss = 20.0f; + m_pTextures->loadAndBindTexture("terrain/moon.png"); + t.begin(4); + t.vertexUV(-ss, -100.0f, ss, 1.0f, 1.0f); + t.vertexUV(ss, -100.0f, ss, 0.0f, 1.0f); + t.vertexUV(ss, -100.0f, -ss, 0.0f, 0.0f); + t.vertexUV(-ss, -100.0f, -ss, 1.0f, 0.0f); + t.draw(m_materials.sun_moon); + } +} + +void LevelRenderer::_renderStars(float alpha) +{ + float a = m_pLevel->getStarBrightness(alpha); + if (a > 0.0f) + { + currentShaderColor = Color(a, a, a); + m_starsMesh.render(m_materials.stars); + } +} + +void LevelRenderer::_renderTileShadow(Tile* tt, const Vec3& pos, TilePos& tilePos, float pow, float r, const Vec3& oPos) +{ + Tesselator& t = Tesselator::instance; + if (!tt->isCubeShaped()) return; + + float a = (pow - (pos.y - ((float)tilePos.y + oPos.y)) / 2.0f) * 0.5f * m_pLevel->getBrightness(tilePos); + if (a < 0.0f) + return; + if (a > 1.0f) a = 1.0f; + + t.color(1.0f, 1.0f, 1.0f, a); + float x0 = (float)tilePos.x + tt->m_aabb.min.x + oPos.x; + float x1 = (float)tilePos.x + tt->m_aabb.max.x + oPos.x; + float y0 = (float)tilePos.y + tt->m_aabb.min.y + oPos.y + (1.0f / 64.0f); + float z0 = (float)tilePos.z + tt->m_aabb.min.z + oPos.z; + float z1 = (float)tilePos.z + tt->m_aabb.max.z + oPos.z; + float u0 = ((pos.x - x0) / 2.0f / r + 0.5f); + float u1 = ((pos.x - x1) / 2.0f / r + 0.5f); + float v0 = ((pos.z - z0) / 2.0f / r + 0.5f); + float v1 = ((pos.z - z1) / 2.0f / r + 0.5f); + t.vertexUV(x0, y0, z0, u0, v0); + t.vertexUV(x0, y0, z1, u0, v1); + t.vertexUV(x1, y0, z1, u1, v1); + t.vertexUV(x1, y0, z0, u1, v0); +} + +void LevelRenderer::_recreateTessellators() +{ + +} + +void LevelRenderer::_setupFog(const Entity& camera, int i) +{ + mce::RenderContext& renderContext = mce::RenderContextImmediate::get(); + mce::FogStateDescription& desc = Fog::nextState; + GameRenderer& gameRenderer = *m_pMinecraft->m_pGameRenderer; + float renderDistance = gameRenderer.m_renderDistance; + + if (camera.isUnderLiquid(Material::water)) + { + desc.fogMode = mce::FOG_MODE_EXP; + desc.fogDensity = 0.1f; + } + else if (camera.isUnderLiquid(Material::lava)) + { + desc.fogMode = mce::FOG_MODE_EXP; + desc.fogDensity = 2.0f; + } + else + { + desc.fogMode = mce::FOG_MODE_LINEAR; + + if (i < 0) + { + desc.fogStartZ = 0.0f; + desc.fogEndZ = renderDistance * 0.8f; + } + else + { + desc.fogStartZ = renderDistance * 0.25f; + desc.fogEndZ = renderDistance; + } + + if (m_pMinecraft->m_pLevel->m_pDimension->m_bFoggy) + { + desc.fogStartZ = 0.0f; + } + } + + Fog::updateState(); +} + +const mce::MaterialPtr& LevelRenderer::_chooseOverlayMaterial(Tile::RenderLayer layer) const +{ + switch (layer) + { + case Tile::RENDER_LAYER_DOUBLE_SIDED: + case Tile::RENDER_LAYER_OPTIONAL_ALPHATEST: + case Tile::RENDER_LAYER_ALPHATEST: + case Tile::RENDER_LAYER_SEASONS_OPTIONAL_ALPHATEST: + return m_materials.selection_overlay_double_sided; + case Tile::RENDER_LAYER_OPAQUE: + case Tile::RENDER_LAYER_SEASONS_OPAQUE: + return m_materials.selection_overlay_opaque; + default: + return m_materials.selection_overlay; + } +} + +void LevelRenderer::onLowMemory() +{ + Tesselator::instance.trim(); +} + +void LevelRenderer::onAppResumed() +{ + onGraphicsReset(); +} + +void LevelRenderer::onAppSuspended() +{ + m_renderList.reset(); + + //m_shadowVolumeMesh.reset(); + //m_shadowOverlayMesh.reset(); + m_starsMesh.reset(); + m_cloudsMesh.reset(); + m_skyMesh.reset(); + m_starsMesh.reset(); } void LevelRenderer::deleteChunks() { - for (int i = 0; i < field_AC; i++) + for (int i = 0; i < m_zChunks; i++) { - for (int j = 0; j < field_A8; j++) + for (int j = 0; j < m_yChunks; j++) { - for (int k = 0; k < field_A4; k++) + for (int k = 0; k < m_xChunks; k++) { - int index = k + field_A4 * (j + field_A8 * i); + int index = k + m_xChunks * (j + m_yChunks * i); delete m_chunks[index]; } } @@ -189,9 +434,9 @@ void LevelRenderer::deleteChunks() delete[] m_chunks; m_chunks = nullptr; - if (field_98) - delete[] field_98; - field_98 = nullptr; + if (m_sortedChunks) + delete[] m_sortedChunks; + m_sortedChunks = nullptr; } void LevelRenderer::cull(Culler* pCuller, float f) @@ -224,73 +469,74 @@ void LevelRenderer::allChanged() TileRenderer::m_bFancyGrass = m_pMinecraft->getOptions()->m_bFancyGrass; TileRenderer::m_bBiomeColors = m_pMinecraft->getOptions()->m_bBiomeColors; - field_BC = m_pMinecraft->getOptions()->m_iViewDistance; + m_lastViewDistance = m_pMinecraft->getOptions()->m_iViewDistance; - int x1 = 64 << (3 - field_BC); - if (x1 >= 400) - x1 = 400; + int dist = 64 << (3 - m_lastViewDistance); + if (dist > 400) + dist = 400; - field_A4 = x1 / 16 + 1; - field_AC = x1 / 16 + 1; - field_A8 = 8; + m_xChunks = dist / 16 + 1; + m_yChunks = 8; + m_zChunks = dist / 16 + 1; - m_chunksLength = field_A8 * field_A4 * field_AC; + m_chunksLength = m_yChunks * m_xChunks * m_zChunks; LOG_I("chunksLength: %d", m_chunksLength); m_chunks = new Chunk* [m_chunksLength]; - field_98 = new Chunk* [m_chunksLength]; + m_sortedChunks = new Chunk* [m_chunksLength]; - m_resortedMinX = 0; - m_resortedMinY = 0; - m_resortedMinZ = 0; + m_xMinChunk = 0; + m_yMinChunk = 0; + m_zMinChunk = 0; - field_88.clear(); + m_dirtyChunks.clear(); + //m_renderableTileEntities.clear(); - m_resortedMaxX = field_A4; - m_resortedMaxY = field_AC; - m_resortedMaxZ = field_A8; + m_xMaxChunk = m_xChunks; + m_yMaxChunk = m_yChunks; + m_zMaxChunk = m_zChunks; - int x2 = 0, x3 = 0; + int count = 0, id = 0; // These are actually Chunk coordinates that get converted to Tile coordinates TilePos cp(0, 0, 0); - for (cp.x = 0; cp.x < field_A4; cp.x++) + for (cp.x = 0; cp.x < m_xChunks; cp.x++) { - if (field_A8 <= 0) + if (m_yChunks <= 0) continue; - for (cp.y = 0; cp.y < field_A8; cp.y++) + for (cp.y = 0; cp.y < m_yChunks; cp.y++) { - for (cp.z = 0; cp.z < field_AC; cp.z++) + for (cp.z = 0; cp.z < m_zChunks; cp.z++) { - int index = cp.x + field_A4 * (cp.y + field_A8 * cp.z); + int index = (cp.z * m_yChunks + cp.y) * m_xChunks + cp.x; - Chunk* pChunk = new Chunk(m_pLevel, cp * 16, 16, x3 + field_B0, &m_pBuffers[x3]); + Chunk* pChunk = new Chunk(m_pLevel, cp * 16, 16, id + m_chunkLists); - if (field_B8) - pChunk->field_50 = 0; + if (m_bOcclusionCheck) + pChunk->m_occlusionId = 0; // m_occlusionCheckIds.get(count) - pChunk->field_4E = false; - pChunk->field_4D = true; + pChunk->m_bOcclusionQuerying = false; + pChunk->m_bOcclusionVisible = true; pChunk->m_bVisible = true; - pChunk->field_48 = x2++; + pChunk->m_id = count++; pChunk->setDirty(); m_chunks[index] = pChunk; - field_98[index] = pChunk; + m_sortedChunks[index] = pChunk; - x3 += 3; - field_88.push_back(pChunk); + id += 3; + m_dirtyChunks.push_back(pChunk); } } } if (m_pLevel) { - Mob* pMob = m_pMinecraft->m_pMobPersp; + Mob* pMob = m_pMinecraft->m_pCameraEntity; if (pMob) { resortChunks(pMob->m_pos); - std::sort(&field_98[0], &field_98[m_chunksLength], DistanceChunkSorter(pMob)); + std::sort(&m_sortedChunks[0], &m_sortedChunks[m_chunksLength], DistanceChunkSorter(*pMob)); } } @@ -300,17 +546,17 @@ void LevelRenderer::allChanged() void LevelRenderer::resortChunks(const TilePos& pos) { TilePos tp(pos - 8); - m_resortedMinX = 0x7FFFFFFF; - m_resortedMinY = 0x7FFFFFFF; - m_resortedMinZ = 0x7FFFFFFF; - m_resortedMaxX = 0x80000000; - m_resortedMaxY = 0x80000000; - m_resortedMaxZ = 0x80000000; - - int blkCount = field_A4 * 16; + m_xMinChunk = INT_MIN; + m_yMinChunk = INT_MIN; + m_zMinChunk = INT_MIN; + m_xMaxChunk = INT_MAX; + m_yMaxChunk = INT_MAX; + m_zMaxChunk = INT_MAX; + + int blkCount = m_xChunks * 16; int blkCntHalf = blkCount / 2; - for (int fx = 0; fx < field_A4; fx++) + for (int fx = 0; fx < m_xChunks; fx++) { int x1 = 16 * fx; int x2 = x1 + blkCntHalf - tp.x; @@ -318,12 +564,12 @@ void LevelRenderer::resortChunks(const TilePos& pos) x2 /= blkCount; x1 -= blkCount * x2; - if (m_resortedMinX > x1) - m_resortedMinX = x1; - if (m_resortedMaxX < x1) - m_resortedMaxX = x1; + if (m_xMinChunk > x1) + m_xMinChunk = x1; + if (m_xMaxChunk < x1) + m_xMaxChunk = x1; - for (int fz = 0; fz < field_AC; fz++) + for (int fz = 0; fz < m_zChunks; fz++) { int z1 = 16 * fz; int z2 = z1 + blkCntHalf - tp.z; @@ -331,25 +577,25 @@ void LevelRenderer::resortChunks(const TilePos& pos) z2 /= blkCount; z1 -= blkCount * z2; - if (m_resortedMinZ > z1) - m_resortedMinZ = z1; - if (m_resortedMaxZ < z1) - m_resortedMaxZ = z1; + if (m_zMinChunk > z1) + m_zMinChunk = z1; + if (m_zMaxChunk < z1) + m_zMaxChunk = z1; - for (int fy = 0; fy < field_A8; fy++) + for (int fy = 0; fy < m_yChunks; fy++) { int y1 = 16 * fy; - if (m_resortedMinY > y1) - m_resortedMinY = y1; - if (m_resortedMaxY < y1) - m_resortedMaxY = y1; + if (m_yMinChunk > y1) + m_yMinChunk = y1; + if (m_yMaxChunk < y1) + m_yMaxChunk = y1; - Chunk* pChunk = m_chunks[(fz * field_A8 + fy) * field_A4 + fx]; + Chunk* pChunk = m_chunks[(fz * m_yChunks + fy) * m_xChunks + fx]; bool wasDirty = pChunk->isDirty(); pChunk->setPos(TilePos(x1, y1, z1)); if (!wasDirty && pChunk->isDirty()) - field_88.push_back(pChunk); + m_dirtyChunks.push_back(pChunk); } } } @@ -389,35 +635,44 @@ std::string LevelRenderer::gatherStats2() void LevelRenderer::onGraphicsReset() { - xglGenBuffers(m_nBuffers, m_pBuffers); + mce::Mesh::clearGlobalBuffers(); + _initResources(); + _recreateTessellators(); allChanged(); - - xglGenBuffers(1, &m_starBuffer); - generateStars(); - - xglGenBuffers(1, &m_skyBuffer); - generateSky(); // inlined in the 0.1.0 demo } -void LevelRenderer::render(const AABB& aabb) const +void LevelRenderer::renderLineBox(const AABB& aabb, const mce::MaterialPtr& material, float lineWidth) const { +#if MCE_GFX_API_OGL + // Maximize Line Width + glEnable(GL_LINE_SMOOTH); + + float range[2]; + glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, range); + + if (lineWidth > range[1]) + lineWidth = range[1]; + + glLineWidth(lineWidth); +#endif + Tesselator& t = Tesselator::instance; - t.begin(GL_LINE_STRIP); + t.begin(mce::PRIMITIVE_MODE_LINE_STRIP, 5); t.vertex(aabb.min.x, aabb.min.y, aabb.min.z); t.vertex(aabb.max.x, aabb.min.y, aabb.min.z); t.vertex(aabb.max.x, aabb.min.y, aabb.max.z); t.vertex(aabb.min.x, aabb.min.y, aabb.max.z); t.vertex(aabb.min.x, aabb.min.y, aabb.min.z); - t.draw(); - t.begin(GL_LINE_STRIP); + t.draw(material); + t.begin(mce::PRIMITIVE_MODE_LINE_STRIP, 5); t.vertex(aabb.min.x, aabb.max.y, aabb.min.z); t.vertex(aabb.max.x, aabb.max.y, aabb.min.z); t.vertex(aabb.max.x, aabb.max.y, aabb.max.z); t.vertex(aabb.min.x, aabb.max.y, aabb.max.z); t.vertex(aabb.min.x, aabb.max.y, aabb.min.z); - t.draw(); - t.begin(GL_LINES); + t.draw(material); + t.begin(mce::PRIMITIVE_MODE_LINE_LIST, 5); t.vertex(aabb.min.x, aabb.min.y, aabb.min.z); t.vertex(aabb.min.x, aabb.max.y, aabb.min.z); t.vertex(aabb.max.x, aabb.min.y, aabb.min.z); @@ -426,36 +681,36 @@ void LevelRenderer::render(const AABB& aabb) const t.vertex(aabb.max.x, aabb.max.y, aabb.max.z); t.vertex(aabb.min.x, aabb.min.y, aabb.max.z); t.vertex(aabb.min.x, aabb.max.y, aabb.max.z); - t.draw(); + t.draw(material); } void LevelRenderer::checkQueryResults(int a, int b) { } -void LevelRenderer::renderSameAsLast(int a, float b) +void LevelRenderer::renderSameAsLast(TerrainLayer layer, float alpha, bool fog) { - m_renderList.render(); + m_renderList.render(layer, fog); } -int LevelRenderer::renderChunks(int start, int end, int a, float b) +int LevelRenderer::renderChunks(int start, int end, Tile::RenderLayer layer, float alpha, bool fog) { field_24.clear(); int result = 0; for (int i = start; i < end; i++) { - Chunk* pChunk = field_98[i]; - if (!a) + Chunk* pChunk = m_sortedChunks[i]; + if (layer == Tile::RENDER_LAYER_OPAQUE) { m_totalChunks++; - if (pChunk->field_1C[0]) + if (pChunk->m_empty[Tile::RENDER_LAYER_OPAQUE]) { m_emptyChunks++; } else if (pChunk->m_bVisible) { - if (!field_B8 || pChunk->field_4D) + if (!m_bOcclusionCheck || pChunk->m_bOcclusionVisible) m_renderedChunks++; else m_occludedChunks++; @@ -466,34 +721,31 @@ int LevelRenderer::renderChunks(int start, int end, int a, float b) } } - if (!pChunk->field_1C[a] && pChunk->m_bVisible && pChunk->field_4D && pChunk->getList(a) >= 0) + if (!pChunk->m_empty[layer] && pChunk->m_bVisible && pChunk->m_bOcclusionVisible && pChunk->getList(layer) >= 0) { result++; field_24.push_back(pChunk); } } - Mob* pMob = m_pMinecraft->m_pMobPersp; + Mob* pMob = m_pMinecraft->m_pCameraEntity; - float fPosX = pMob->m_posPrev.x + (pMob->m_pos.x - pMob->m_posPrev.x) * b; - float fPosY = pMob->m_posPrev.y + (pMob->m_pos.y - pMob->m_posPrev.y) * b; - float fPosZ = pMob->m_posPrev.z + (pMob->m_pos.z - pMob->m_posPrev.z) * b; + Vec3 fPos = pMob->m_posPrev + (pMob->m_pos - pMob->m_posPrev) * alpha; m_renderList.clear(); - m_renderList.init(fPosX, fPosY, fPosZ); + m_renderList.init(fPos); for (int i = 0; i < int(field_24.size()); i++) { Chunk* pChk = field_24[i]; - m_renderList.addR(*pChk->getRenderChunk(a)); - m_renderList.field_14++; + m_renderList.addR(pChk->getRenderChunk(layer), renderLayerToTerrainLayerMap[layer], fog); } - renderSameAsLast(a, b); + renderSameAsLast(renderLayerToTerrainLayerMap[layer], alpha, fog); return result; } -void LevelRenderer::render(Mob* pMob, int a, float b) +void LevelRenderer::render(const Entity& camera, Tile::RenderLayer layer, float alpha, bool fog) { for (int i = 0; i < 10; i++) { @@ -503,44 +755,49 @@ void LevelRenderer::render(Mob* pMob, int a, float b) if (!pChunk->m_bDirty) continue; - std::vector::iterator iter = std::find(field_88.begin(), field_88.end(), pChunk); - if (iter != field_88.end()) + std::vector::iterator iter = std::find(m_dirtyChunks.begin(), m_dirtyChunks.end(), pChunk); + if (iter != m_dirtyChunks.end()) continue; - field_88.push_back(pChunk); + m_dirtyChunks.push_back(pChunk); } - if (m_pMinecraft->getOptions()->m_iViewDistance != field_BC) + if (m_pMinecraft->getOptions()->m_iViewDistance != m_lastViewDistance) allChanged(); - if (!a) + if (layer == Tile::RENDER_LAYER_OPAQUE) m_totalChunks = m_offscreenChunks = m_occludedChunks = m_renderedChunks = m_emptyChunks = 0; - Vec3 mobPos = pMob->m_posPrev + (pMob->m_pos - pMob->m_posPrev) * b; + Vec3 cameraPos = camera.m_posPrev + (camera.m_pos - camera.m_posPrev) * alpha; - float dX = pMob->m_pos.x - field_4, dY = pMob->m_pos.y - field_8, dZ = pMob->m_pos.z - field_C; + float dX = camera.m_pos.x - m_posPrev.x, dY = camera.m_pos.y - m_posPrev.y, dZ = camera.m_pos.z - m_posPrev.z; if (dX * dX + dY * dY + dZ * dZ > 16.0f) { - field_4 = pMob->m_pos.x; - field_8 = pMob->m_pos.y; - field_C = pMob->m_pos.z; + m_posPrev = camera.m_pos; + + resortChunks(camera.m_pos); + std::sort(&m_sortedChunks[0], &m_sortedChunks[m_chunksLength], DistanceChunkSorter(camera)); + } - resortChunks(pMob->m_pos); - std::sort(&field_98[0], &field_98[m_chunksLength], DistanceChunkSorter(pMob)); + if (layer == Tile::RENDER_LAYER_BLEND) + { + mce::RenderContext& renderContext = mce::RenderContextImmediate::get(); + renderContext.clearStencilBuffer(); } - // @NOTE: Field_B8 doesn't appear to be used?? - if (field_B8 && !a && !m_pMinecraft->getOptions()->m_bAnaglyphs) + // @NOTE: m_bOcclusionCheck is always false + if (m_bOcclusionCheck && layer == Tile::RENDER_LAYER_OPAQUE && !m_pMinecraft->getOptions()->m_bAnaglyphs) { - int c = 16; + assert(false); + /*int c = 16; checkQueryResults(0, c); // @HUH: why 16? for (int i = 0; i < c; i++) - field_98[i]->field_4D = true; + m_sortedChunks[i]->m_bOcclusionVisible = true; - int d = renderChunks(0, c, 0, b); + int d = renderChunks(0, c, Tile::RENDER_LAYER_OPAQUE, alpha); do { @@ -571,22 +828,22 @@ void LevelRenderer::render(Mob* pMob, int a, float b) if (!m_chunks[i]->m_bVisible) { - m_chunks[i]->field_4D = true; + m_chunks[i]->m_bOcclusionVisible = true; continue; } - if (!m_chunks[i]->field_4E) + if (!m_chunks[i]->m_bOcclusionQuerying) continue; - int roughDist = int(Mth::sqrt(m_chunks[i]->distanceToSqr(pMob)) / 128.0f + 1.0f); + int roughDist = int(Mth::sqrt(m_chunks[i]->distanceToSqr(camera)) / 128.0f + 1.0f); if (m_ticksSinceStart % roughDist != i % roughDist) continue; float fXdiff, fYdiff, fZdiff; - fXdiff = float(m_chunks[i]->m_pos.x) - mobPos.x - lastX; - fYdiff = float(m_chunks[i]->m_pos.y) - mobPos.y - lastY; - fZdiff = float(m_chunks[i]->m_pos.z) - mobPos.z - lastZ; + fXdiff = float(m_chunks[i]->m_pos.x) - cameraPos.x - lastX; + fYdiff = float(m_chunks[i]->m_pos.y) - cameraPos.y - lastY; + fZdiff = float(m_chunks[i]->m_pos.z) - cameraPos.z - lastZ; if (fXdiff != 0.0f || fYdiff != 0.0f || fZdiff != 0.0f) { @@ -598,25 +855,67 @@ void LevelRenderer::render(Mob* pMob, int a, float b) } m_chunks[i]->renderBB(); - m_chunks[i]->field_4E = true; + m_chunks[i]->m_bOcclusionQuerying = true; } } - while (c < m_chunksLength); + while (c < m_chunksLength);*/ } else { - renderChunks(0, m_chunksLength, a, b); + renderChunks(0, m_chunksLength, layer, alpha, fog); } } +const Color& LevelRenderer::setupClearColor(float f) +{ + Minecraft& mc = *m_pMinecraft; + const Options& options = *mc.getOptions(); + Level& level = *mc.m_pLevel; + const Entity& camera = *mc.m_pCameraEntity; + + float x1 = 1.0f - powf(1.0f / float(4 - options.m_iViewDistance), 0.25f); + + Vec3 skyColor = level.getSkyColor(camera, f), fogColorVec = level.getFogColor(f); + + Color& fogColor = Fog::nextState.fogColor; + + fogColor.r = fogColorVec.x + (skyColor.x - fogColorVec.x) * x1; + fogColor.g = fogColorVec.y + (skyColor.y - fogColorVec.y) * x1; + fogColor.b = fogColorVec.z + (skyColor.z - fogColorVec.z) * x1; + fogColor.a = 1.0f; + + if (camera.isUnderLiquid(Material::water)) + { + fogColor = Color(0.02f, 0.02f, 0.2f); + } + else if (camera.isUnderLiquid(Material::lava)) + { + fogColor = Color(0.6f, 0.1f, 0.0f); + } + + float x2 = m_fogBrO + (m_fogBr - m_fogBrO) * f; + + fogColor *= x2; + + if (options.m_bAnaglyphs) + { + fogColor.r = (fogColor.r * 30.0f + fogColor.g * 59.0f + fogColor.b * 11.0f) / 100.0f; + fogColor.g = (fogColor.r * 30.0f + fogColor.g * 70.0f) / 100.0f; + fogColor.b = (fogColor.r * 30.0f + fogColor.b * 70.0f) / 100.0f; + } + + return fogColor; +} + void LevelRenderer::setLevel(Level* level) { + if (m_pLevel == level) + return; + if (m_pLevel) m_pLevel->removeListener(this); - field_4 = -9999.0f; - field_8 = -9999.0f; - field_C = -9999.0f; + m_posPrev = Vec3(-9999.0f, -9999.0f, -9999.0f); EntityRenderDispatcher::getInstance()->setLevel(level); EntityRenderDispatcher::getInstance()->setMinecraft(m_pMinecraft); @@ -624,11 +923,22 @@ void LevelRenderer::setLevel(Level* level) m_pLevel = level; delete m_pTileRenderer; - m_pTileRenderer = new TileRenderer(m_pLevel); + m_pTileRenderer = new TileRenderer(Tesselator::instance, m_pLevel); if (level) { level->addListener(this); + } + + allChanged(); +} + +void LevelRenderer::setDimension(Dimension* dimension) +{ + m_pDimension = dimension; + + if (dimension) + { allChanged(); } } @@ -644,27 +954,27 @@ void LevelRenderer::setDirty(const TilePos& min, const TilePos& max) for (int x = minX; x <= maxX; x++) { - int x1 = x % field_A4; + int x1 = x % m_xChunks; if (x1 < 0) - x1 += field_A4; + x1 += m_xChunks; for (int y = minY; y <= maxY; y++) { - int y1 = y % field_A8; + int y1 = y % m_yChunks; if (y1 < 0) - y1 += field_A8; + y1 += m_yChunks; for (int z = minZ; z <= maxZ; z++) { - int z1 = z % field_AC; + int z1 = z % m_zChunks; if (z1 < 0) - z1 += field_AC; + z1 += m_zChunks; - Chunk* pChunk = m_chunks[x1 + field_A4 * (y1 + field_A8 * z1)]; + Chunk* pChunk = m_chunks[x1 + m_xChunks * (y1 + m_yChunks * z1)]; if (pChunk->isDirty()) continue; - field_88.push_back(pChunk); + m_dirtyChunks.push_back(pChunk); pChunk->setDirty(); } } @@ -678,27 +988,40 @@ void LevelRenderer::setTilesDirty(const TilePos& min, const TilePos& max) void LevelRenderer::tick() { + const Entity& camera = *m_pMinecraft->m_pCameraEntity; + const Level& level = *m_pMinecraft->m_pLevel; + const Options& options = *m_pMinecraft->getOptions(); + + m_fogBrO = m_fogBr; + + float bright = level.getBrightness(camera.m_pos); + float x3 = float(3 - options.m_iViewDistance); + float x4 = x3 / 3.0f; + float x5 = (x4 + bright * (1.0f - x4) - m_fogBr) * 0.1f; + + m_fogBr += x5; + m_ticksSinceStart++; } typedef std::vector ChunkVector; typedef ChunkVector::iterator ChunkVectorIterator; -bool LevelRenderer::updateDirtyChunks(Mob* pMob, bool b) +bool LevelRenderer::updateDirtyChunks(const Entity& camera, bool b) { constexpr int C_MAX = 3; - DirtyChunkSorter dcs(pMob); + DirtyChunkSorter dcs(camera); Chunk* pChunks[C_MAX] = { nullptr }; - ChunkVector* pVec = nullptr; + ChunkVector* nearChunks = nullptr; - int nr1 = 0; - int sz = int(field_88.size()); - for (int i = 0; i < sz; i++) + int pendingChunkRemoved = 0; + int pendingChunkSize = int(m_dirtyChunks.size()); + for (int i = 0; i < pendingChunkSize; i++) { - Chunk* pChunk = field_88[i]; + Chunk* pChunk = m_dirtyChunks[i]; if (!b) { - if (pChunk->distanceToSqr(pMob) > 1024.0f) + if (pChunk->distanceToSqr(camera) > 1024.0f) { int j; // find place to insert this chunk within the pChunks array @@ -724,26 +1047,26 @@ bool LevelRenderer::updateDirtyChunks(Mob* pMob, bool b) continue; } - if (!pVec) - pVec = new ChunkVector; + if (!nearChunks) + nearChunks = new ChunkVector; - nr1++; - pVec->push_back(pChunk); - field_88[i] = nullptr; + pendingChunkRemoved++; + nearChunks->push_back(pChunk); + m_dirtyChunks[i] = nullptr; } - if (pVec) + if (nearChunks) { - if (pVec->size() > 1) - std::sort(pVec->begin(), pVec->end(), dcs); + if (nearChunks->size() > 1) + std::sort(nearChunks->begin(), nearChunks->end(), dcs); - for (int i = int(pVec->size()) - 1; i >= 0; i--) + for (int i = int(nearChunks->size()) - 1; i >= 0; i--) { - (*pVec)[i]->rebuild(); - (*pVec)[i]->setClean(); + (*nearChunks)[i]->rebuild(); + (*nearChunks)[i]->setClean(); } - SAFE_DELETE(pVec); + SAFE_DELETE(nearChunks); } int nr2 = 0; @@ -766,9 +1089,9 @@ bool LevelRenderer::updateDirtyChunks(Mob* pMob, bool b) int nr3 = 0; int nr4 = 0; - for (; nr4 < int(field_88.size()); nr4++) + for (; nr4 < int(m_dirtyChunks.size()); nr4++) { - Chunk* pChunk = field_88[nr4]; + Chunk* pChunk = m_dirtyChunks[nr4]; if (!pChunk) continue; @@ -783,78 +1106,67 @@ bool LevelRenderer::updateDirtyChunks(Mob* pMob, bool b) continue; if (nr3 != nr4) - field_88[nr3] = pChunk; + m_dirtyChunks[nr3] = pChunk; nr3++; } if (nr4 > nr3) - field_88.erase(field_88.begin() + nr3, field_88.end()); + m_dirtyChunks.erase(m_dirtyChunks.begin() + nr3, m_dirtyChunks.end()); - return nr1 + nr2 == sz; + return pendingChunkRemoved + nr2 == pendingChunkSize; } -void LevelRenderer::renderHit(Player* pPlayer, const HitResult& hr, int i, void* vp, float f) +void LevelRenderer::renderCracks(const Entity& camera, const HitResult& hr, int mode, const ItemInstance* inventoryItem, float a) { - glEnable(GL_BLEND); - glEnable(GL_ALPHA_TEST); - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - // @BUG: possible leftover from Minecraft Classic? This is overridden anyways - //glColor4f(1.0f, 1.0f, 1.0f, 0.5f * (0.4f + 0.2f * Mth::sin(float(getTimeMs()) / 100.0f))); + //currentShaderColor = Color(1.0f, 1.0f, 1.0f, (Mth::sin(float(getTimeMs()) / 100.0f) * 0.2f + 0.4f) * 0.5f); - if (!i && field_10 > 0.0f) + if (mode == 0) { - glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR); - - m_pTextures->loadAndBindTexture(C_TERRAIN_NAME); - glColor4f(1.0f, 1.0f, 1.0f, 0.5f); - glPushMatrix(); - Tile* pTile = nullptr; - TileID tile = m_pLevel->getTile(hr.m_tilePos); - if (tile > 0) - pTile = Tile::tiles[tile]; - glDisable(GL_ALPHA_TEST); - glPolygonOffset(-3.0f, -3.0f); - glEnable(GL_POLYGON_OFFSET_FILL); - - float px = pPlayer->m_posPrev.x + (pPlayer->m_pos.x - pPlayer->m_posPrev.x) * f; - float py = pPlayer->m_posPrev.y + (pPlayer->m_pos.y - pPlayer->m_posPrev.y) * f; - float pz = pPlayer->m_posPrev.z + (pPlayer->m_pos.z - pPlayer->m_posPrev.z) * f; - - Tesselator& t = Tesselator::instance; - glEnable(GL_ALPHA_TEST); // Fixes for b1.7.3 terrain - t.begin(); - t.offset(-px, -py, -pz); - t.noColor(); - if (!pTile) - pTile = Tile::rock; - - m_pTileRenderer->tesselateInWorld(pTile, hr.m_tilePos, 240 + int(field_10 * 10.0f)); - - t.draw(); - t.offset(0, 0, 0); - - glPolygonOffset(0.0f, 0.0f); - glDisable(GL_POLYGON_OFFSET_FILL); - - glDepthMask(true); //@HUH: What is the reason for this? You never disable the depth mask. - glPopMatrix(); - } + if (m_destroyProgress > 0.0f) + { + m_pTextures->loadAndBindTexture(C_TERRAIN_NAME); + currentShaderColor = Color::WHITE; + currentShaderDarkColor = Color(1.0f, 1.0f, 1.0f, 0.5f); + + MatrixStack::Ref matrix = MatrixStack::World.push(); + + Tile* pTile = nullptr; + TileID tile = m_pLevel->getTile(hr.m_tilePos); + if (tile > 0) + pTile = Tile::tiles[tile]; + + float px = camera.m_posPrev.x + (camera.m_pos.x - camera.m_posPrev.x) * a; + float py = camera.m_posPrev.y + (camera.m_pos.y - camera.m_posPrev.y) * a; + float pz = camera.m_posPrev.z + (camera.m_pos.z - camera.m_posPrev.z) * a; + + Tesselator& t = Tesselator::instance; + + t.begin(0); + t.setOffset(-px, -py, -pz); + t.noColor(); + if (!pTile) + pTile = Tile::rock; - glDisable(GL_BLEND); - glDisable(GL_ALPHA_TEST); + m_pTileRenderer->tesselateInWorld(pTile, hr.m_tilePos, 240 + int(m_destroyProgress * 10.0f)); + + t.draw(m_materials.cracks_overlay); + t.setOffset(0, 0, 0); + } + } + else if (inventoryItem != nullptr) + { + float br = Mth::sin((float)getTimeMs() / 100.0f) * 0.2f + 0.8f; + currentShaderColor = Color(br, br, br, Mth::sin((float)getTimeMs() / 200.0f) * 0.2f + 0.5f); + m_pTextures->loadAndBindTexture(C_TERRAIN_NAME); + TilePos tp = hr.m_tilePos.relative(hr.m_hitSide); + } } -void LevelRenderer::renderHitSelect(Player* pPlayer, const HitResult& hr, int i, void* vp, float f) +void LevelRenderer::renderHitSelect(const Entity& camera, const HitResult& hr, int mode, const ItemInstance* inventoryItem, float a) { - if (i) return; - - glEnable(GL_BLEND); - glDisable(GL_TEXTURE_2D); - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR); - glEnable(GL_DEPTH_TEST); + if (mode != 0) return; m_pMinecraft->m_pTextures->loadAndBindTexture(C_TERRAIN_NAME); @@ -863,60 +1175,38 @@ void LevelRenderer::renderHitSelect(Player* pPlayer, const HitResult& hr, int i, if (tileID > 0) pTile = Tile::tiles[tileID]; - glDisable(GL_ALPHA_TEST); - glColor4f(0.65f, 0.65f, 0.65f, 0.65f); - glPushMatrix(); - glPolygonOffset(-0.3f, -0.3f); - glEnable(GL_POLYGON_OFFSET_FILL); + currentShaderColor = Color(0.65f, 0.65f, 0.65f, 0.65f); - float px = pPlayer->m_posPrev.x + (pPlayer->m_pos.x - pPlayer->m_posPrev.x) * f; - float py = pPlayer->m_posPrev.y + (pPlayer->m_pos.y - pPlayer->m_posPrev.y) * f; - float pz = pPlayer->m_posPrev.z + (pPlayer->m_pos.z - pPlayer->m_posPrev.z) * f; + MatrixStack::Ref matrix = MatrixStack::World.push(); + + float px = camera.m_posPrev.x + (camera.m_pos.x - camera.m_posPrev.x) * a; + float py = camera.m_posPrev.y + (camera.m_pos.y - camera.m_posPrev.y) * a; + float pz = camera.m_posPrev.z + (camera.m_pos.z - camera.m_posPrev.z) * a; Tesselator& t = Tesselator::instance; - t.begin(); - t.offset(-px, -py, -pz); + t.begin(0); + t.setOffset(-px, -py, -pz); t.noColor(); if (!pTile) pTile = Tile::rock; m_pTileRenderer->tesselateInWorld(pTile, hr.m_tilePos); - t.draw(); - t.offset(0, 0, 0); + Tile::RenderLayer renderLayer = pTile->getRenderLayer(); + const mce::MaterialPtr& material = _chooseOverlayMaterial(renderLayer); - glPolygonOffset(0.0f, 0.0f); - glDisable(GL_POLYGON_OFFSET_FILL); - glEnable(GL_TEXTURE_2D); - glDepthMask(true); - glPopMatrix(); - glEnable(GL_ALPHA_TEST); - glDisable(GL_BLEND); + t.draw(material); + t.setOffset(0, 0, 0); } -void LevelRenderer::renderHitOutline(Player* pPlayer, const HitResult& hr, int i, void* vp, float f) +void LevelRenderer::renderHitOutline(const Entity& camera, const HitResult& hr, int mode, const ItemInstance* inventoryItem, float a) { - if (i != 0 || hr.m_hitType != 0) + if (mode != 0 || hr.m_hitType != 0) return; - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor4f(0.0f, 0.0f, 0.0f, 0.4f); - //glLineWidth(1.0f); - glDisable(GL_TEXTURE_2D); - glDepthMask(false); - - // Maximize Line Width - glEnable(GL_LINE_SMOOTH); - - float range[2]; - glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, range); + currentShaderColor = Color(0.0f, 0.0f, 0.0f, 0.4f); float lineWidth = 2.0f * Minecraft::getRenderScaleMultiplier(); - if (lineWidth > range[1]) - lineWidth = range[1]; - - glLineWidth(lineWidth); TileID tile = m_pLevel->getTile(hr.m_tilePos); if (tile > 0) @@ -924,9 +1214,9 @@ void LevelRenderer::renderHitOutline(Player* pPlayer, const HitResult& hr, int i Tile::tiles[tile]->updateShape( m_pLevel, hr.m_tilePos); - float posX = pPlayer->m_posPrev.x + ((pPlayer->m_pos.x - pPlayer->m_posPrev.x) * f); - float posY = pPlayer->m_posPrev.y + ((pPlayer->m_pos.y - pPlayer->m_posPrev.y) * f); - float posZ = pPlayer->m_posPrev.z + ((pPlayer->m_pos.z - pPlayer->m_posPrev.z) * f); + float posX = camera.m_posPrev.x + ((camera.m_pos.x - camera.m_posPrev.x) * a); + float posY = camera.m_posPrev.y + ((camera.m_pos.y - camera.m_posPrev.y) * a); + float posZ = camera.m_posPrev.z + ((camera.m_pos.z - camera.m_posPrev.z) * a); AABB aabb, tileAABB = Tile::tiles[tile]->getTileAABB(m_pLevel, hr.m_tilePos); aabb.min.y = tileAABB.min.y - 0.002f - posY; aabb.max.y = tileAABB.max.y + 0.002f - posY; @@ -934,12 +1224,8 @@ void LevelRenderer::renderHitOutline(Player* pPlayer, const HitResult& hr, int i aabb.max.z = tileAABB.max.z + 0.002f - posZ; aabb.min.x = tileAABB.min.x - 0.002f - posX; aabb.max.x = tileAABB.max.x + 0.002f - posX; - render(aabb); + renderLineBox(aabb, m_materials.selection_box, lineWidth); } - - glDepthMask(true); - glEnable(GL_TEXTURE_2D); - glDisable(GL_BLEND); } void LevelRenderer::tileChanged(const TilePos& pos) @@ -947,52 +1233,11 @@ void LevelRenderer::tileChanged(const TilePos& pos) setDirty(pos - 1, pos + 1); } -void LevelRenderer::renderEntities(Vec3 pos, Culler* culler, float f) -{ - if (m_noEntityRenderFrames > 0) - { - m_noEntityRenderFrames--; - return; - } - - Mob* mob = m_pMinecraft->m_pMobPersp; - - EntityRenderDispatcher::getInstance()->prepare(m_pLevel, m_pMinecraft->m_pTextures, m_pMinecraft->m_pFont, mob, m_pMinecraft->getOptions(), f); - - m_totalEntities = 0; - m_renderedEntities = 0; - m_culledEntities = 0; - - EntityRenderDispatcher::off = mob->m_posPrev + (mob->m_pos - mob->m_posPrev) * f; - - const EntityVector* pVec = m_pLevel->getAllEntities(); - m_totalEntities = int(pVec->size()); - - for (int i = 0; i < m_totalEntities; i++) - { - Entity* pEnt = (*pVec)[i]; - if (!pEnt->shouldRender(pos)) - continue; - - if (!culler->isVisible(pEnt->m_hitbox)) - continue; - - if (m_pMinecraft->m_pMobPersp == pEnt && !m_pMinecraft->getOptions()->m_bThirdPerson) - continue; - - if (m_pLevel->hasChunkAt(pEnt->m_pos)) - { - m_renderedEntities++; - EntityRenderDispatcher::getInstance()->render(pEnt, f); - } - } -} - extern int t_keepPic; void LevelRenderer::takePicture(TripodCamera* pCamera, Entity* pOwner) { - Mob* pOldMob = m_pMinecraft->m_pMobPersp; + Mob* pOldMob = m_pMinecraft->m_pCameraEntity; bool bOldDontRenderGui = m_pMinecraft->getOptions()->m_bDontRenderGui; bool bOldThirdPerson = m_pMinecraft->getOptions()->m_bThirdPerson; @@ -1001,11 +1246,11 @@ void LevelRenderer::takePicture(TripodCamera* pCamera, Entity* pOwner) g_bDisableParticles = true; #endif - m_pMinecraft->m_pMobPersp = pCamera; + m_pMinecraft->m_pCameraEntity = pCamera; m_pMinecraft->getOptions()->m_bDontRenderGui = true; m_pMinecraft->getOptions()->m_bThirdPerson = false; // really from the perspective of the camera m_pMinecraft->m_pGameRenderer->render(0.0f); - m_pMinecraft->m_pMobPersp = pOldMob; + m_pMinecraft->m_pCameraEntity = pOldMob; m_pMinecraft->getOptions()->m_bDontRenderGui = bOldDontRenderGui; m_pMinecraft->getOptions()->m_bThirdPerson = bOldThirdPerson; @@ -1033,7 +1278,7 @@ void LevelRenderer::addParticle(const std::string& name, const Vec3& pos, const if (name == "explodeColor") maxDist = 16384.0f; - if (m_pMinecraft->m_pMobPersp->distanceToSqr_inline(pos) > maxDist) + if (m_pMinecraft->m_pCameraEntity->distanceToSqr_inline(pos) > maxDist) return; ParticleEngine* pe = m_pMinecraft->m_pParticleEngine; @@ -1098,7 +1343,7 @@ void LevelRenderer::playSound(const std::string& name, const Vec3& pos, float vo { // TODO: Who's the genius who decided it'd be better to check a name string rather than an enum? float mult = 1.0f, maxDist = 16.0f; - float playerDist = m_pMinecraft->m_pMobPersp->distanceToSqr(pos); + float playerDist = m_pMinecraft->m_pCameraEntity->distanceToSqr(pos); if (volume > 1.0f) { @@ -1118,124 +1363,211 @@ void LevelRenderer::playSound(const std::string& name, const Vec3& pos, float vo m_pMinecraft->m_pSoundEngine->play(name, pos, volume, pitch); } -void LevelRenderer::renderSky(float alpha) +void LevelRenderer::renderLevel(const Entity& camera, FrustumCuller& culler, float a1, float f) { - if (m_pMinecraft->m_pLevel->m_pDimension->m_bFoggy) - return; + ParticleEngine& particleEngine = *m_pMinecraft->m_pParticleEngine; + Textures& textures = *m_pMinecraft->m_pTextures; + mce::RenderContext& renderContext = mce::RenderContextImmediate::get(); - glDisable(GL_TEXTURE_2D); + Fog::enable(); + _setupFog(camera, 1); - Vec3 sc = m_pLevel->getSkyColor(m_pMinecraft->m_pMobPersp, alpha); - if (m_pMinecraft->getOptions()->m_bAnaglyphs) + cull(&culler, f); + updateDirtyChunks(camera, false); + + // TODO[v0.6.1]: what is (this+4)+63 (byte)? + prepareAndRenderClouds(camera, f); + + _setupFog(camera, 0); + Fog::enable(); + + textures.loadAndBindTexture(C_TERRAIN_NAME); + Lighting::turnOff(); + render(camera, Tile::RENDER_LAYER_SEASONS_OPAQUE, f); + render(camera, Tile::RENDER_LAYER_OPAQUE, f); + render(camera, Tile::RENDER_LAYER_DOUBLE_SIDED, f); + + render(camera, Tile::RENDER_LAYER_ALPHATEST, f); + Lighting::turnOn(); + + renderEntities(camera.getPos(f), &culler, f); + particleEngine.renderLit(camera, f); + Lighting::turnOff(); + particleEngine.render(camera, f); + + _setupFog(camera, 0); + + renderContext.setShadeMode(mce::SHADE_MODE_SMOOTH); + + if (camera.isUnderLiquid(Material::water)) { - sc.x = (((sc.x * 30.0f) + (sc.y * 59.0f)) + (sc.z * 11.0f)) / 100.0f; - sc.y = ((sc.x * 30.0f) + (sc.y * 70.0f)) / 100.0f; - sc.z = ((sc.x * 30.0f) + (sc.z * 70.0f)) / 100.0f; + //renderWeather(f); + RenderChunk::SetUnderwater(true); + } + else + { + RenderChunk::SetUnderwater(false); } - glColor4f(sc.x, sc.y, Mth::Min(1.0f, sc.z), 1.0f); + textures.loadAndBindTexture(C_TERRAIN_NAME); + render(camera, Tile::RENDER_LAYER_BLEND, f); - Tesselator& t = Tesselator::instance; + renderContext.setShadeMode(mce::SHADE_MODE_FLAT); - glDepthMask(false); - glEnable(GL_FOG); - glColor4f(sc.x, sc.y, sc.z, 1.0f); + //renderNameTags(f); + + if (!camera.isUnderLiquid(Material::water)) + { + //renderWeather(f); + } + + // Was after renderCracks in GameRenderer + Fog::disable(); +} - drawArrayVT(m_skyBuffer, m_skyBufferCount, sizeof(Tesselator::Vertex)); +void LevelRenderer::renderEntities(Vec3 pos, Culler* culler, float f) +{ + if (m_noEntityRenderFrames > 0) + { + m_noEntityRenderFrames--; + return; + } - glDisable(GL_FOG); - glDisable(GL_ALPHA_TEST); + const Mob* camera = m_pMinecraft->m_pCameraEntity; - // Sunrise - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + EntityRenderDispatcher::getInstance()->prepare(m_pLevel, m_pMinecraft->m_pTextures, m_pMinecraft->m_pFont, camera, m_pMinecraft->getOptions(), f); - float* c = m_pLevel->m_pDimension->getSunriseColor(m_pLevel->getTimeOfDay(alpha), alpha); - if (c != nullptr && arePlanetsAvailable()) + m_totalEntities = 0; + m_renderedEntities = 0; + m_culledEntities = 0; + + EntityRenderDispatcher::off = camera->m_posPrev + (camera->m_pos - camera->m_posPrev) * f; + + const EntityVector* pVec = m_pLevel->getAllEntities(); + m_totalEntities = int(pVec->size()); + + for (int i = 0; i < m_totalEntities; i++) { - glDisable(GL_TEXTURE_2D); - //glShadeModel(GL_SMOOTH); // I'd rather fuck up the sunrise gradient than AO, but it doesn't even look like it does that + const Entity* entity = (*pVec)[i]; + if (!entity->shouldRender(pos)) + continue; - glPushMatrix(); - glRotatef(90.0f, 1.0f, 0.0f, 0.0f); - glRotatef(m_pLevel->getTimeOfDay(alpha) > 0.5f ? 180 : 0, 0.0f, 0.0f, 1.0f); + if (!culler->isVisible(entity->m_hitbox)) + continue; - t.begin(GL_TRIANGLE_FAN); - t.color(c[0], c[1], c[2], c[3]); - t.vertex(0.0f, 100.0f, 0.0f); - t.color(c[0], c[1], c[2], 0.0f); + if (m_pMinecraft->m_pCameraEntity == entity && !m_pMinecraft->getOptions()->m_bThirdPerson) + continue; - int steps = 16; - for (int i = 0; i <= steps; i++) + if (m_pLevel->hasChunkAt(entity->m_pos)) { - float a = i * 3.1415927f * 2.0f / steps; - float sin = Mth::sin(a); - float cos = Mth::cos(a); - t.vertex((sin * 120.0f), (cos * 120.0f), (-cos * 40.0f * c[3])); + m_renderedEntities++; + EntityRenderDispatcher::getInstance()->render(*entity, f); } - - t.draw(); - glPopMatrix(); - //glShadeModel(GL_FLAT); // fuck it, don't bother, doing this SOMEHOW breaks AO } +} - // Sun, moon, stars - glEnable(GL_TEXTURE_2D); - glBlendFunc(GL_ONE, GL_ONE); - glPushMatrix(); +void LevelRenderer::renderShadow(const Entity& entity, const Vec3& pos, float r, float pow, float a) +{ + Textures& textures = *m_pMinecraft->m_pTextures; - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glTranslatef(sc.x, sc.y, sc.z); - glRotatef(0.0f, 0.0f, 0.0f, 1.0f); - glRotatef(m_pLevel->getTimeOfDay(alpha) * 360.0f, 1.0f, 0.0f, 0.0f); + textures.setClampToEdge(true); + textures.loadAndBindTexture("misc/shadow.png"); + textures.setClampToEdge(false); - float ss = 30.0f; + Vec3 ePos(entity.m_posPrev + (entity.m_pos - entity.m_posPrev) * a); + ePos.y -= entity.m_heightOffset; // We gotta do this so the renderer can correctly determine if there's a tile below the entity + ePos.y += entity.getShadowHeightOffs(); - if (arePlanetsAvailable()) - { - m_pTextures->loadAndBindTexture("terrain/sun.png"); - t.begin(); - t.vertexUV(-ss, 100.0f, -ss, 0.0f, 0.0f); - t.vertexUV(ss, 100.0f, -ss, 1.0f, 0.0f); - t.vertexUV(ss, 100.0f, ss, 1.0f, 1.0f); - t.vertexUV(-ss, 100.0f, ss, 0.0f, 1.0f); - t.draw(); + TilePos tpMin(ePos - r); + TilePos tpMax(ePos.x + r, ePos.y, ePos.z + r); + Vec3 ePosO(pos - ePos); - ss = 20.0f; - m_pTextures->loadAndBindTexture("terrain/moon.png"); - t.begin(); - t.vertexUV(-ss, -100.0f, ss, 1.0f, 1.0f); - t.vertexUV(ss, -100.0f, ss, 0.0f, 1.0f); - t.vertexUV(ss, -100.0f, -ss, 0.0f, 0.0f); - t.vertexUV(-ss, -100.0f, -ss, 1.0f, 0.0f); - t.draw(); + Tesselator& tt = Tesselator::instance; + tt.begin(0); + TilePos tp(tpMin); + for (tp.x = tpMin.x; tp.x <= tpMax.x; tp.x++) + { + for (tp.y = tpMin.y; tp.y <= tpMax.y; tp.y++) + { + for (tp.z = tpMin.z; tp.z <= tpMax.z; tp.z++) + { + TileID t = m_pLevel->getTile(tp.below()); + if (t > 0 && m_pLevel->getRawBrightness(tp) > 3) + { + _renderTileShadow(Tile::tiles[t], + Vec3(pos.x, pos.y - entity.m_heightOffset + entity.getShadowHeightOffs(), pos.z), tp, + pow, r, + Vec3(ePosO.x, ePosO.y - entity.m_heightOffset + entity.getShadowHeightOffs(), ePosO.z) + ); + } + } + } } + tt.draw(m_materials.shadow_image_overlay); +} - glDisable(GL_TEXTURE_2D); +void LevelRenderer::renderSky(const Entity& camera, float alpha) +{ + if (m_pMinecraft->m_pLevel->m_pDimension->m_bFoggy) + return; - float a = m_pLevel->getStarBrightness(alpha); - if (a > 0.0f) + Vec3 sc = m_pLevel->getSkyColor(camera, alpha); + if (m_pMinecraft->getOptions()->m_bAnaglyphs) { - glColor4f(a, a, a, a); - drawArrayVT(m_starBuffer, m_starBufferCount, sizeof(Tesselator::Vertex)); + sc.x = (((sc.x * 30.0f) + (sc.y * 59.0f)) + (sc.z * 11.0f)) / 100.0f; + sc.y = ((sc.x * 30.0f) + (sc.y * 70.0f)) / 100.0f; + sc.z = ((sc.x * 30.0f) + (sc.z * 70.0f)) / 100.0f; } - // Dark plane - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glDisable(GL_BLEND); - glEnable(GL_ALPHA_TEST); - glEnable(GL_FOG); - glPopMatrix(); + // called again a few lines down, no min in Java, why is it here? + //currentShaderColor = Color(sc.x, sc.y, Mth::Min(1.0f, sc.z), 1.0f); + + Tesselator& t = Tesselator::instance; + + Fog::enable(); + currentShaderColor = Color(sc.x, sc.y, sc.z); + + m_skyMesh.render(m_materials.skyplane); - glColor4f(sc.x * 0.2f + 0.04f, sc.y * 0.2f + 0.04f, sc.z * 0.6f + 0.1f, 1.0f); - glDisable(GL_TEXTURE_2D); - drawArrayVT(m_darkBuffer, m_darkBufferCount, sizeof(Tesselator::Vertex)); - glEnable(GL_TEXTURE_2D); + Fog::disable(); - glDepthMask(true); + _renderSunrise(alpha); + _renderSolarSystem(alpha); + + Fog::enable(); + + currentShaderColor = Color(sc.x * 0.2f + 0.04f, sc.y * 0.2f + 0.04f, sc.z * 0.6f + 0.1f); + m_darkMesh.render(m_materials.skyplane); // this is probably not the right material for this } -void LevelRenderer::renderClouds(float alpha) +void LevelRenderer::prepareAndRenderClouds(const Entity& camera, float f) +{ + GameRenderer& gameRenderer = *m_pMinecraft->m_pGameRenderer; + float renderDistance = gameRenderer.m_renderDistance; + float fov = gameRenderer.getFov(f); + + MatrixStack::Ref projMtx = MatrixStack::Projection.pushIdentity(); + projMtx->setPerspective(fov, float(Minecraft::width) / float(Minecraft::height), 0.05f, renderDistance * 512.0f); + + MatrixStack::Ref viewMtx = MatrixStack::View.push(); + _setupFog(camera, 0); + + Fog::enable(); + + Fog::updateRange(renderDistance * 0.2f, renderDistance * 0.75f); + renderSky(camera, f); + + Fog::updateRange(renderDistance * 4.2f * 0.6f, renderDistance * 4.2f); + renderClouds(camera, f); + + Fog::updateRange(renderDistance * 0.6f, renderDistance); + + Fog::disable(); + + _setupFog(camera, 1); +} + +void LevelRenderer::renderClouds(const Entity& camera, float alpha) { if (!areCloudsAvailable()) return; @@ -1246,19 +1578,22 @@ void LevelRenderer::renderClouds(float alpha) return; } - glEnable(GL_TEXTURE_2D); - glDisable(GL_CULL_FACE); + mce::RenderContext& renderContext = mce::RenderContextImmediate::get(); - float yPos = Mth::Lerp(m_pMinecraft->m_pMobPersp->m_posPrev.y, m_pMinecraft->m_pMobPersp->m_pos.y, alpha); // not certain if this old pos Y is used - m_pTextures->loadAndBindTexture("environment/clouds.png"); + float yPos = Mth::Lerp(camera.m_posPrev.y, camera.m_pos.y, alpha); // not certain if this old pos Y is used + float yy = ((float)C_MAX_Y - yPos) + 0.33f; // 108.0f on b1.2_02, see below + + if (yy > 1.0f) + { + renderContext.setDepthRange(0.0f, 1.0f); + } - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + m_pTextures->loadAndBindTexture("environment/clouds.png"); Vec3 cloudColor = m_pLevel->getCloudColor(alpha); - float offX = Mth::Lerp(m_pMinecraft->m_pMobPersp->m_oPos.x, m_pMinecraft->m_pMobPersp->m_pos.x, alpha) + (float(m_ticksSinceStart) + alpha) * 0.03f; - float offZ = Mth::Lerp(m_pMinecraft->m_pMobPersp->m_oPos.z, m_pMinecraft->m_pMobPersp->m_pos.z, alpha); + float offX = Mth::Lerp(camera.m_oPos.x, camera.m_pos.x, alpha) + (float(m_ticksSinceStart) + alpha) * 0.03f; + float offZ = Mth::Lerp(camera.m_oPos.z, camera.m_pos.z, alpha); int dx2048 = Mth::floor(offX / 2048.0f); int dz2048 = Mth::floor(offZ / 2048.0f); @@ -1271,12 +1606,12 @@ void LevelRenderer::renderClouds(float alpha) float fYPos = ((float)C_MAX_Y - yPos) + 0.33f; offX /= 2048.0f; offZ /= 2048.0f; - t.begin(); + t.begin(1024); t.color(cloudColor.x, cloudColor.y, cloudColor.z, 0.8f); - const int incr = 16 * 2; - const int maxX = C_MAX_CHUNKS_X * 16; - const int maxZ = C_MAX_CHUNKS_Z * 16; + constexpr int incr = 16 * 2; + constexpr int maxX = C_MAX_CHUNKS_X * 16; + constexpr int maxZ = C_MAX_CHUNKS_Z * 16; for (int x = -maxX; x < maxX; x += incr) { for (int z = -maxZ; z < maxZ; z += incr) @@ -1290,36 +1625,30 @@ void LevelRenderer::renderClouds(float alpha) } t.voidBeginAndEndCalls(false); // why?? - t.draw(); + t.draw(m_materials.clouds); - - - - float yy = ((float)C_MAX_Y - yPos) + 0.33f; // 108.0f on b1.2_02, see below - - if (yy > 1.0f) { - glClear(GL_DEPTH_BUFFER_BIT); + if (yy > 1.0f) + { + renderContext.setDepthRange(0.0f, 0.7f); } - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glDisable(GL_BLEND); - glEnable(GL_CULL_FACE); + currentShaderColor = Color::WHITE; } void LevelRenderer::renderAdvancedClouds(float alpha) { - glDisable(GL_CULL_FACE); + mce::RenderContext& renderContext = mce::RenderContextImmediate::get(); - float yOffs = //Mth::Lerp(m_pMinecraft->m_pMobPersp->m_posPrev.y, m_pMinecraft->m_pMobPersp->m_pos.y, alpha); - m_pMinecraft->m_pMobPersp->m_posPrev.y + (m_pMinecraft->m_pMobPersp->m_pos.y - m_pMinecraft->m_pMobPersp->m_posPrev.y) * alpha; + float yOffs = //Mth::Lerp(m_pMinecraft->m_pCameraEntity->m_posPrev.y, m_pMinecraft->m_pCameraEntity->m_pos.y, alpha); + m_pMinecraft->m_pCameraEntity->m_posPrev.y + (m_pMinecraft->m_pCameraEntity->m_pos.y - m_pMinecraft->m_pCameraEntity->m_posPrev.y) * alpha; Tesselator& t = Tesselator::instance; constexpr float ss = 12.0f; constexpr float h = 4.0f; // @NOTE: Using Mth::Lerp will use incorrect logic - float xo = (m_pMinecraft->m_pMobPersp->m_oPos.x + (m_pMinecraft->m_pMobPersp->m_pos.x - m_pMinecraft->m_pMobPersp->m_oPos.x) * alpha + ((float(m_ticksSinceStart) + alpha) * 0.03f)) / ss; - float zo = (m_pMinecraft->m_pMobPersp->m_oPos.z + (m_pMinecraft->m_pMobPersp->m_pos.z - m_pMinecraft->m_pMobPersp->m_oPos.z) * alpha) / ss + 0.33f; + float xo = (m_pMinecraft->m_pCameraEntity->m_oPos.x + (m_pMinecraft->m_pCameraEntity->m_pos.x - m_pMinecraft->m_pCameraEntity->m_oPos.x) * alpha + ((float(m_ticksSinceStart) + alpha) * 0.03f)) / ss; + float zo = (m_pMinecraft->m_pCameraEntity->m_oPos.z + (m_pMinecraft->m_pCameraEntity->m_pos.z - m_pMinecraft->m_pCameraEntity->m_oPos.z) * alpha) / ss + 0.33f; float yy = ((float)C_MAX_Y - yOffs) + 0.33f; // 108.0f on b1.2_02, see below //float yy = 108.0f - yOffs + 0.33F; @@ -1330,9 +1659,12 @@ void LevelRenderer::renderAdvancedClouds(float alpha) xo -= xOffs * 2048; zo -= zOffs * 2048; + if (yy > 1.0f) + { + renderContext.setDepthRange(0.0f, 1.0f); + } + m_pTextures->loadAndBindTexture("environment/clouds.png"); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); Vec3 cc = m_pLevel->getCloudColor(alpha); float cr = cc.x; @@ -1369,20 +1701,29 @@ void LevelRenderer::renderAdvancedClouds(float alpha) constexpr int radius = 3; constexpr float e = 1.0f / 1024.0f; - glScalef(ss, 1.0f, ss); + Matrix& matrix = MatrixStack::View.getTop(); + matrix.scale(Vec3(ss, 1.0f, ss)); for (int pass = 0; pass < 2; pass++) { if (pass == 0) + { +#if MCE_GFX_API_OGL glColorMask(false, false, false, false); +#endif + } else + { +#if MCE_GFX_API_OGL glColorMask(true, true, true, true); +#endif + } for (int xPos = -radius + 1; xPos <= radius; xPos++) { for (int zPos = -radius + 1; zPos <= radius; zPos++) { - t.begin(); + t.begin(0); float xx = xPos * D; float zz = zPos * D; float xp = xx - xoffs; @@ -1411,7 +1752,7 @@ void LevelRenderer::renderAdvancedClouds(float alpha) if (xPos > -1) { - t.normal(-1.0f, 0.0f, 0.0f); + t.normal(Vec3::NEG_UNIT_X); for (int i = 0; i < D; i++) { @@ -1424,7 +1765,7 @@ void LevelRenderer::renderAdvancedClouds(float alpha) if (xPos <= 1) { - t.normal(1.0f, 0.0f, 0.0f); + t.normal(Vec3::UNIT_X); for (int i = 0; i < D; i++) { @@ -1438,7 +1779,7 @@ void LevelRenderer::renderAdvancedClouds(float alpha) t.color(cr * 0.8f, cg * 0.8f, cb * 0.8f, 0.8f); if (zPos > -1) { - t.normal(0.0f, 0.0f, -1.0f); + t.normal(Vec3::NEG_UNIT_Z); for (int i = 0; i < D; i++) { @@ -1451,7 +1792,7 @@ void LevelRenderer::renderAdvancedClouds(float alpha) if (zPos <= 1) { - t.normal(0.0f, 0.0f, 1.0f); + t.normal(Vec3::UNIT_Z); for (int i = 0; i < D; i++) { @@ -1462,19 +1803,15 @@ void LevelRenderer::renderAdvancedClouds(float alpha) } } - t.draw(); + t.draw(m_materials.clouds); } } } - if (yy > 1.0f) { - glDepthRange(0.f, 7.f); - glClear(GL_DEPTH_BUFFER_BIT); + if (yy > 1.0f) + { + renderContext.setDepthRange(0.0f, 0.7f); } - - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glDisable(GL_BLEND); - glEnable(GL_CULL_FACE); } void LevelRenderer::skyColorChanged() @@ -1488,7 +1825,7 @@ void LevelRenderer::skyColorChanged() if (pChunk->isDirty()) continue; - field_88.push_back(pChunk); + m_dirtyChunks.push_back(pChunk); pChunk->setDirty(); } } diff --git a/source/client/renderer/LevelRenderer.hpp b/source/client/renderer/LevelRenderer.hpp index e674f6f61..58e3fd92d 100644 --- a/source/client/renderer/LevelRenderer.hpp +++ b/source/client/renderer/LevelRenderer.hpp @@ -10,7 +10,8 @@ #include #include -#include "thirdparty/GL/GL.hpp" +#include "client/app/AppPlatformListener.hpp" +#include "renderer/hal/interface/FogState.hpp" #include "world/level/LevelListener.hpp" #include "Textures.hpp" #include "RenderList.hpp" @@ -20,18 +21,18 @@ class Minecraft; class DistanceChunkSorter { - Mob* m_pMob; + const Entity& m_entity; public: - DistanceChunkSorter(Mob* pMob) + DistanceChunkSorter(const Entity& entity) + : m_entity(entity) { - m_pMob = pMob; } bool operator()(const Chunk* a, const Chunk* b) { - float d1 = a->distanceToSqr(m_pMob); - float d2 = b->distanceToSqr(m_pMob); + float d1 = a->distanceToSqr(m_entity); + float d2 = b->distanceToSqr(m_entity); if (d1 > 1024.0f && a->m_pos.y <= 63) d1 *= 10.0f; if (d2 > 1024.0f && b->m_pos.y <= 63) d2 *= 10.0f; @@ -42,12 +43,12 @@ class DistanceChunkSorter class DirtyChunkSorter { - Mob* m_pMob; + const Entity& m_entity; public: - DirtyChunkSorter(Mob* pMob) + DirtyChunkSorter(const Entity& entity) + : m_entity(entity) { - m_pMob = pMob; } bool operator()(const Chunk* a, const Chunk* b) @@ -57,18 +58,41 @@ class DirtyChunkSorter if (!a->m_bVisible && b->m_bVisible) return true; - float d1 = a->distanceToSqr(m_pMob); - float d2 = b->distanceToSqr(m_pMob); + float d1 = a->distanceToSqr(m_entity); + float d2 = b->distanceToSqr(m_entity); if (d1 < d2) return false; if (d1 > d2) return true; - return a->field_48 > b->field_48; + return a->m_id > b->m_id; } }; -class LevelRenderer : public LevelListener +class LevelRenderer : public LevelListener, public AppPlatformListener { +protected: + class Materials + { + public: + mce::MaterialPtr shadow_back; + mce::MaterialPtr shadow_front; + mce::MaterialPtr shadow_overlay; + mce::MaterialPtr shadow_image_overlay; + mce::MaterialPtr stars; + mce::MaterialPtr skyplane; + mce::MaterialPtr sun_moon; + mce::MaterialPtr sunrise; + mce::MaterialPtr selection_overlay; + mce::MaterialPtr selection_overlay_opaque; + mce::MaterialPtr selection_overlay_double_sided; + mce::MaterialPtr selection_box; + mce::MaterialPtr cracks_overlay; + mce::MaterialPtr cracks_overlay_tile_entity; + mce::MaterialPtr clouds; + + Materials(); + }; + private: static bool _areCloudsAvailable; static bool _arePlanetsAvailable; @@ -81,6 +105,28 @@ class LevelRenderer : public LevelListener public: LevelRenderer(Minecraft*, Textures*); +protected: + void _buildSkyMesh(); + void _buildStarsMesh(); + void _buildSunAndMoonMeshes(); + void _buildShadowVolume(); + void _buildShadowOverlay(); + void _initResources(); + void _renderSunrise(float alpha); + void _renderSolarSystem(float alpha); + void _renderSunAndMoon(float alpha); + void _renderStars(float alpha); + void _renderTileShadow(Tile* tt, const Vec3& pos, TilePos& tilePos, float pow, float r, const Vec3& oPos); + void _recreateTessellators(); + void _setupFog(const Entity& camera, int i); + const mce::MaterialPtr& _chooseOverlayMaterial(Tile::RenderLayer layer) const; + +public: + // AppPlatformListener overrides + void onLowMemory() override; + void onAppResumed() override; + void onAppSuspended() override; + // LevelListener overrides void allChanged() override; void entityAdded(Entity*) override; @@ -92,36 +138,39 @@ class LevelRenderer : public LevelListener void skyColorChanged() override; void levelEvent(Player* pPlayer, LevelEvent::ID eventId, const TilePos& pos, LevelEvent::Data data) override; - void generateSky(); - void generateStars(); void cull(Culler*, float); void deleteChunks(); void resortChunks(const TilePos& pos); std::string gatherStats1(); std::string gatherStats2(); void onGraphicsReset(); - void render(const AABB& aabb) const; - void render(Mob* pMob, int a, float b); + void renderLineBox(const AABB& aabb, const mce::MaterialPtr& material, float lineWidth) const; + void render(const Entity& camera, Tile::RenderLayer layer, float alpha, bool fog = false); + void renderLevel(const Entity& camera, FrustumCuller& culler, float a1, float f); void renderEntities(Vec3 pos, Culler*, float f); - void renderSky(float); - void renderClouds(float); + void renderShadow(const Entity& entity, const Vec3& pos, float r, float pow, float a); + void renderSky(const Entity& camera, float alpha); + void prepareAndRenderClouds(const Entity& camera, float f); + void renderClouds(const Entity& camera, float f); void renderAdvancedClouds(float); void checkQueryResults(int, int); - void renderSameAsLast(int, float); - int renderChunks(int start, int end, int a, float b); + void renderSameAsLast(TerrainLayer layer, float alpha, bool fog); + int renderChunks(int start, int end, Tile::RenderLayer layer, float alpha, bool fog); + const Color& setupClearColor(float f); void setLevel(Level*); + void setDimension(Dimension*); void setDirty(const TilePos& min, const TilePos& max); void tick(); - bool updateDirtyChunks(Mob* pMob, bool b); - void renderHit(Player* pPlayer, const HitResult& hr, int, void*, float); - void renderHitSelect(Player* pPlayer, const HitResult& hr, int, void*, float); - void renderHitOutline(Player* pPlayer, const HitResult& hr, int, void*, float); + bool updateDirtyChunks(const Entity& camera, bool b); + void renderCracks(const Entity& camera, const HitResult& hr, int mode, const ItemInstance* inventoryItem, float a); + void renderHitSelect(const Entity& camera, const HitResult& hr, int mode, const ItemInstance* inventoryItem, float a); + void renderHitOutline(const Entity& camera, const HitResult& hr, int mode, const ItemInstance* inventoryItem, float a); +protected: + Materials m_materials; public: - float field_4; - float field_8; - float field_C; - float field_10; + Vec3 m_posPrev; + float m_destroyProgress; int m_noEntityRenderFrames; int m_totalEntities; int m_renderedEntities; @@ -135,35 +184,36 @@ class LevelRenderer : public LevelListener int m_renderedChunks; int m_emptyChunks; int field_68; - int m_resortedMinX; - int m_resortedMinY; - int m_resortedMinZ; - int m_resortedMaxX; - int m_resortedMaxY; - int m_resortedMaxZ; + int m_xMinChunk; + int m_yMinChunk; + int m_zMinChunk; + int m_xMaxChunk; + int m_yMaxChunk; + int m_zMaxChunk; Level* m_pLevel; - std::vector field_88; + Dimension* m_pDimension; + std::vector m_dirtyChunks; Chunk** m_chunks; - Chunk** field_98; + Chunk** m_sortedChunks; int m_chunksLength; TileRenderer* m_pTileRenderer; - int field_A4; - int field_A8; - int field_AC; - int field_B0; + int m_xChunks; + int m_yChunks; + int m_zChunks; + int m_chunkLists; Minecraft* m_pMinecraft; - bool field_B8; - int field_BC; + bool m_bOcclusionCheck; + int m_lastViewDistance; int m_ticksSinceStart; + float m_fogBrO; + float m_fogBr; //... - int m_nBuffers; - GLuint* m_pBuffers; - GLuint m_skyBuffer; - int m_skyBufferCount; - GLuint m_starBuffer; - int m_starBufferCount; - GLuint m_darkBuffer; - int m_darkBufferCount; + //mce::Mesh m_shadowVolumeMesh; + //mce::Mesh m_shadowOverlayMesh; + mce::Mesh m_skyMesh; + mce::Mesh m_cloudsMesh; + mce::Mesh m_starsMesh; + mce::Mesh m_darkMesh; //... Textures* m_pTextures; }; diff --git a/source/client/renderer/Lighting.cpp b/source/client/renderer/Lighting.cpp index 7d162cc54..8600eb153 100644 --- a/source/client/renderer/Lighting.cpp +++ b/source/client/renderer/Lighting.cpp @@ -1,58 +1,22 @@ #include "Lighting.hpp" +#include "renderer/RenderContextImmediate.hpp" -#include "world/phys/Vec3.hpp" - -#include "thirdparty/GL/GL.hpp" - -float Lighting::lb[4] = {}; - -void Lighting::turnOff() +void Lighting::turnOff(bool teardown) { -#ifdef USE_GL_NORMAL_LIGHTING - glDisable(GL_LIGHTING); - glDisable(GL_LIGHT0); - glDisable(GL_LIGHT1); - glDisable(GL_COLOR_MATERIAL); -#endif + mce::RenderContext& renderContext = mce::RenderContextImmediate::get(); + renderContext.disableFixedLighting(teardown); } -void Lighting::turnOn() +void Lighting::turnOn(bool init) { -#ifdef USE_GL_NORMAL_LIGHTING - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glEnable(GL_LIGHT1); - glEnable(GL_COLOR_MATERIAL); -#if !defined(__EMSCRIPTEN__) && !defined(USE_GLES) - glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); -#endif - - constexpr float a = 0.4f, d = 0.6f, s = 0.0f; - - Vec3 l = Vec3(0.2f, 1.0f, -0.7f).normalize(); - glLightfv(GL_LIGHT0, GL_POSITION, getBuffer(l.x, l.y, l.z, 0.0f)); - glLightfv(GL_LIGHT0, GL_DIFFUSE, getBuffer(d, d, d, 1.0f)); - glLightfv(GL_LIGHT0, GL_AMBIENT, getBuffer(0.0f, 0.0f, 0.0f, 1.0f)); - glLightfv(GL_LIGHT0, GL_SPECULAR, getBuffer(s, s, s, 1.0f)); - - l = Vec3(-0.2f, 1.0f, 0.7f).normalize(); - glLightfv(GL_LIGHT1, GL_POSITION, getBuffer(l.x, l.y, l.z, 0.0f)); - glLightfv(GL_LIGHT1, GL_DIFFUSE, getBuffer(d, d, d, 1.0f)); - glLightfv(GL_LIGHT1, GL_AMBIENT, getBuffer(0.0f, 0.0f, 0.0f, 1.0f)); - glLightfv(GL_LIGHT1, GL_SPECULAR, getBuffer(s, s, s, 1.0f)); -#endif - - glShadeModel(GL_FLAT); -#ifdef USE_GL_NORMAL_LIGHTING - glLightModelfv(GL_LIGHT_MODEL_AMBIENT, getBuffer(a, a, a, 1.0f)); -#endif + mce::RenderContext& renderContext = mce::RenderContextImmediate::get(); + renderContext.enableFixedLighting(init); + renderContext.setShadeMode(mce::SHADE_MODE_FLAT); } -float *Lighting::getBuffer(float a, float b, float c, float d) +void Lighting::turnOn(const Matrix& matrix) { - lb[0] = a; - lb[1] = b; - lb[2] = c; - lb[3] = d; - return (float*)&lb; + mce::RenderContext& renderContext = mce::RenderContextImmediate::get(); + renderContext.loadMatrix(MATRIX_VIEW, matrix); + turnOn(); } diff --git a/source/client/renderer/Lighting.hpp b/source/client/renderer/Lighting.hpp index 8480fa4af..daeef2056 100644 --- a/source/client/renderer/Lighting.hpp +++ b/source/client/renderer/Lighting.hpp @@ -1,15 +1,10 @@ #pragma once -#include - +class Matrix; class Lighting { -private: - static float lb[4]; - public: - static void turnOff(); - static void turnOn(); - - static float *getBuffer(float a, float b, float c, float d); + static void turnOff(bool teardown = true); + static void turnOn(bool init = true); + static void turnOn(const Matrix& matrix); }; diff --git a/source/client/renderer/PatchManager.cpp b/source/client/renderer/PatchManager.cpp index 96fb15d57..5dd7cdcf1 100644 --- a/source/client/renderer/PatchManager.cpp +++ b/source/client/renderer/PatchManager.cpp @@ -4,7 +4,7 @@ #include "client/app/AppPlatform.hpp" #include "world/tile/Tile.hpp" #include "world/item/Item.hpp" -#include "thirdparty/GL/GL.hpp" +#include "renderer/RenderContextImmediate.hpp" #define PM_SEPARATOR ('|') @@ -171,8 +171,10 @@ void PatchManager::LoadPatchData(const std::string& patchData) } } -void PatchManager::PatchTextures(AppPlatform* pAppPlatform, ePatchType patchType) +void PatchManager::PatchTextures(TextureData& texture, ePatchType patchType) { + mce::RenderContext& renderContext = mce::RenderContextImmediate::get(); + // Use glTexSubImage2D to patch the terrain.png texture on the fly. for (int i = 0; i < int(m_patchData.size()); i++) { @@ -192,8 +194,9 @@ void PatchManager::PatchTextures(AppPlatform* pAppPlatform, ePatchType patchType } // N.B. Well, in some cases, you do want things to fail nicely. - Texture texture = pAppPlatform->loadTexture("patches/" + pd.m_filename, false); - if (!texture.m_pixels || !texture.m_width || !texture.m_height) + ImageData image; + AppPlatform::singleton()->loadImage(image, "patches/" + pd.m_filename); + if (image.isEmpty()) { LOG_W("Image %s was not found?! Skipping", pd.m_filename.c_str()); if (bDisableFancyGrassIfFailed) @@ -201,19 +204,13 @@ void PatchManager::PatchTextures(AppPlatform* pAppPlatform, ePatchType patchType continue; } - glTexSubImage2D( - GL_TEXTURE_2D, - 0, - pd.m_destX, - pd.m_destY, - texture.m_width, - texture.m_height, - GL_RGBA, - GL_UNSIGNED_BYTE, - texture.m_pixels - ); - - SAFE_DELETE_ARRAY(texture.m_pixels); + if (image.m_colorSpace != COLOR_SPACE_RGBA) + { + LOG_E("Patch textures must be RGBA"); + throw std::bad_cast(); + } + + texture.m_texture.subBuffer(renderContext, image.m_data, pd.m_destX, pd.m_destY, image.m_width, image.m_height, 0); } } diff --git a/source/client/renderer/PatchManager.hpp b/source/client/renderer/PatchManager.hpp index 2628aa458..5eb750ca6 100644 --- a/source/client/renderer/PatchManager.hpp +++ b/source/client/renderer/PatchManager.hpp @@ -5,6 +5,7 @@ #include class AppPlatform; +class TextureData; enum ePatchType { @@ -73,7 +74,7 @@ class PatchManager void LoadPatchData(const std::string& patchData); - void PatchTextures(AppPlatform*, ePatchType); + void PatchTextures(TextureData& texture, ePatchType patchType); void PatchTiles(); // Features diff --git a/source/client/renderer/RenderChunk.cpp b/source/client/renderer/RenderChunk.cpp index 6b7734700..7eb5b2a0e 100644 --- a/source/client/renderer/RenderChunk.cpp +++ b/source/client/renderer/RenderChunk.cpp @@ -6,6 +6,117 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ +#include #include "RenderChunk.hpp" +#include "common/Util.hpp" +#include "client/renderer/renderer/RenderMaterialGroup.hpp" +#include "renderer/ShaderConstants.hpp" -int RenderChunk::runningId = 0; +bool RenderChunk::_isUnderwater; +mce::MaterialPtr RenderChunk::fogMaterialMap[10]; +mce::MaterialPtr RenderChunk::materialMap[10]; +mce::MaterialPtr RenderChunk::fadingSeasonsAlphaChunkMaterial; +mce::MaterialPtr RenderChunk::fadingSeasonsChunksMaterial; +mce::MaterialPtr RenderChunk::fadingChunksMaterial; + +void RenderChunk::_init() +{ + m_lastRebuilt = 0.0; +} + +void RenderChunk::_init(RenderChunk& other) +{ + _move(other); + _init(); +} + +RenderChunk::RenderChunk(const TilePos& pos, mce::Mesh& mesh) + : m_pos(pos) + , m_mesh(mesh) +{ + _init(); +} + +const mce::MaterialPtr& RenderChunk::_chooseMaterial(TerrainLayer layer, double a, bool fog) +{ + if (layer < TERRAIN_LAYERS_MIN || layer > TERRAIN_LAYERS_MAX) + throw std::out_of_range("Invalid TerrainLayer"); + + double diff = a - m_lastRebuilt; + + if (diff < 1.2) + { + currentShaderColor.r = (1.2 - diff) * 0.2; + switch (layer) + { + case TERRAIN_LAYER_SEASONS_FAR: + return fadingSeasonsChunksMaterial; + case TERRAIN_LAYER_SEASONS_FAR_ALPHATEST: + return fadingSeasonsAlphaChunkMaterial; + default: + return fadingChunksMaterial; + } + } + + mce::MaterialPtr* map; + if (fog) map = fogMaterialMap; + else map = materialMap; + + return map[layer]; +} + +void RenderChunk::_move(RenderChunk& other) +{ + m_pos = other.m_pos; + m_mesh = other.m_mesh; +} + +void RenderChunk::render(TerrainLayer layer, double a, bool fog) +{ + currentShaderColor = Color::WHITE; + currentShaderDarkColor = Color::WHITE; + m_mesh.render(_chooseMaterial(layer, a, fog)); +} + +void RenderChunk::reset() +{ + m_mesh.reset(); +} + +void RenderChunk::_InitLayers(mce::MaterialPtr* materials, const std::string& suffix) +{ + materials[TERRAIN_LAYER_OPAQUE] = GET_MATERIAL_PTR(switchable, "terrain_opaque" + suffix); + materials[TERRAIN_LAYER_OPAQUE_SEASONS] = GET_MATERIAL_PTR(switchable, "terrain_opaque_seasons" + suffix); + materials[TERRAIN_LAYER_BLEND] = GET_MATERIAL_PTR(switchable, "terrain_blend" + suffix); + materials[TERRAIN_LAYER_ALPHATEST] = GET_MATERIAL_PTR(switchable, "terrain_alpha" + suffix); + materials[TERRAIN_LAYER_ALPHATEST_SINGLE_SIDE] = GET_MATERIAL_PTR(switchable, "terrain_alpha_single_side" + suffix); + materials[TERRAIN_LAYER_ALPHATEST_SEASONS] = GET_MATERIAL_PTR(switchable, "terrain_alpha_seasons" + suffix); + materials[TERRAIN_LAYER_DOUBLE_SIDED] = GET_MATERIAL_PTR(switchable, "terrain_doubleside" + suffix); + materials[TERRAIN_LAYER_FAR] = GET_MATERIAL_PTR(switchable, "terrain_far" + suffix); + materials[TERRAIN_LAYER_SEASONS_FAR] = GET_MATERIAL_PTR(switchable, "terrain_seasons_far" + suffix); + materials[TERRAIN_LAYER_SEASONS_FAR_ALPHATEST] = GET_MATERIAL_PTR(switchable, "terrain_seasons_far_alpha" + suffix); +} + +void RenderChunk::InitMaterials() +{ + fadingChunksMaterial = GET_MATERIAL_PTR(switchable, "terrain_fading_in"); + fadingSeasonsChunksMaterial = GET_MATERIAL_PTR(switchable, "terrain_seasons_fading_in"); + fadingSeasonsAlphaChunkMaterial = GET_MATERIAL_PTR(switchable, "terrain_seasons_fading_in_alpha"); + + _InitLayers(materialMap, Util::EMPTY_STRING); + _InitLayers(fogMaterialMap, "_fog"); +} + +void RenderChunk::SetUnderwater(bool isUnderwater) +{ + if (_isUnderwater == isUnderwater) + return; + + _isUnderwater = isUnderwater; + + std::string materialName = isUnderwater ? "terrain_blend_below" : "terrain_blend"; + materialMap[TERRAIN_LAYER_BLEND] = GET_MATERIAL_PTR(switchable, materialName); + + materialName = isUnderwater ? "terrain_blend_below_fog" : "terrain_blend_fog"; + fogMaterialMap[TERRAIN_LAYER_BLEND] = GET_MATERIAL_PTR(switchable, materialName); +} \ No newline at end of file diff --git a/source/client/renderer/RenderChunk.hpp b/source/client/renderer/RenderChunk.hpp index 289633a9a..4957eadbd 100644 --- a/source/client/renderer/RenderChunk.hpp +++ b/source/client/renderer/RenderChunk.hpp @@ -8,40 +8,70 @@ #pragma once -#include "thirdparty/GL/GL.hpp" +#include "compat/LegacyCPP.hpp" +#include "renderer/Mesh.hpp" +#include "world/level/TilePos.hpp" + +enum TerrainLayer +{ + TERRAIN_LAYER_OPAQUE, + TERRAIN_LAYER_OPAQUE_SEASONS, + TERRAIN_LAYER_DOUBLE_SIDED, + TERRAIN_LAYER_ALPHATEST, + TERRAIN_LAYER_ALPHATEST_SINGLE_SIDE, + TERRAIN_LAYER_ALPHATEST_SEASONS, + TERRAIN_LAYER_BLEND, + TERRAIN_LAYER_FAR, + TERRAIN_LAYER_SEASONS_FAR, + TERRAIN_LAYER_SEASONS_FAR_ALPHATEST, + TERRAIN_LAYERS_MIN = TERRAIN_LAYER_OPAQUE, + TERRAIN_LAYERS_MAX = TERRAIN_LAYER_SEASONS_FAR_ALPHATEST, + TERRAIN_LAYERS_COUNT +}; class RenderChunk { - static int runningId; +private: + static bool _isUnderwater; +public: + static mce::MaterialPtr fogMaterialMap[10]; + static mce::MaterialPtr materialMap[10]; + static mce::MaterialPtr fadingSeasonsAlphaChunkMaterial; + static mce::MaterialPtr fadingSeasonsChunksMaterial; + static mce::MaterialPtr fadingChunksMaterial; + +private: + double m_lastRebuilt; +public: + TilePos m_pos; + mce::Mesh m_mesh; + +private: + void _init(); + void _init(RenderChunk& other); public: - GLuint field_0; - int field_4; - int m_id; - float field_C; - float field_10; - float field_14; + RenderChunk() { _init(); } + MC_CTOR_MOVE(RenderChunk); + RenderChunk(const TilePos& pos, mce::Mesh& mesh); + +private: + const mce::MaterialPtr& _chooseMaterial(TerrainLayer layer, double a, bool fog); + +public: + void _move(RenderChunk& other); + +public: + void render(TerrainLayer layer, double a, bool fog); + void reset(); + +public: + MC_FUNC_MOVE(RenderChunk); +private: + static void _InitLayers(mce::MaterialPtr* materials, const std::string& suffix); public: - RenderChunk() - { - field_0 = -1; - field_4 = 0; - field_C = 0.0f; - field_10 = 0.0f; - field_14 = 0.0f; - - m_id = ++runningId; - } - RenderChunk(GLuint a1, int a2) - { - field_C = 0.0f; - field_10 = 0.0f; - field_14 = 0.0f; - - m_id = ++runningId; - field_0 = a1; - field_4 = a2; - } + static void InitMaterials(); + static void SetUnderwater(bool isUnderwater); }; diff --git a/source/client/renderer/RenderList.cpp b/source/client/renderer/RenderList.cpp index 1de0d0189..b5d4b1c25 100644 --- a/source/client/renderer/RenderList.cpp +++ b/source/client/renderer/RenderList.cpp @@ -7,24 +7,19 @@ ********************************************************************/ #include "RenderList.hpp" -#include "Tesselator.hpp" - -#include +#include "renderer/MatrixStack.hpp" constexpr int C_MAX_RENDERS = 3072; RenderList::RenderList() { - m_posX = 0.0f; - m_posY = 0.0f; - m_posZ = 0.0f; field_14 = 0; - field_18 = false; - field_19 = false; + m_bInited = false; + m_bRendered = false; field_1C = 0; field_C = new int[C_MAX_RENDERS]; - field_10 = new RenderChunk[C_MAX_RENDERS]; + field_10 = new RenderChunk*[C_MAX_RENDERS]; } RenderList::~RenderList() @@ -36,101 +31,102 @@ RenderList::~RenderList() delete[] field_10; } -void RenderList::add(int x) +void RenderList::add(int x, TerrainLayer layer, bool fog) { // @BUG: If too many chunks are rendered, this has the potential to overflow. #ifndef ORIGINAL_CODE if (field_14 == C_MAX_RENDERS) { - render(); - init(m_posX, m_posY, m_posZ); + render(layer, fog); + init(m_pos); field_1C = 0; - field_19 = false; + m_bRendered = false; } #endif field_C[field_14] = x; if (field_14 == C_MAX_RENDERS) - render(); + render(layer, fog); } -void RenderList::addR(const RenderChunk& rc) +void RenderList::addR(RenderChunk* rc, TerrainLayer layer, bool fog) { // @BUG: If too many chunks are rendered, this has the potential to overflow. #ifndef ORIGINAL_CODE if (field_14 == C_MAX_RENDERS) { - render(); - init(m_posX, m_posY, m_posZ); + render(layer, fog); + init(m_pos); field_1C = 0; - field_19 = false; + m_bRendered = false; } #endif field_10[field_14] = rc; + + field_14++; } void RenderList::clear() { - field_18 = false; - field_19 = false; + m_bInited = false; + m_bRendered = false; } -void RenderList::init(float x, float y, float z) +void RenderList::reset() { - m_posX = x; - m_posY = y; - m_posZ = z; + for (int i = 0; i < field_1C; i++) + { + RenderChunk* chk = field_10[i]; + if (!chk) continue; + + chk->reset(); + } +} + +void RenderList::init(const Vec3& pos) +{ + m_pos = pos; field_14 = 0; - field_18 = true; + m_bInited = true; } -void RenderList::render() +void RenderList::render(TerrainLayer layer, bool fog) { - if (!field_18) return; + if (!m_bInited) return; - if (!field_19) + if (!m_bRendered) { - field_19 = true; + m_bRendered = true; field_1C = field_14; field_14 = 0; } if (field_14 < field_1C) { - glPushMatrix(); - glTranslatef(-m_posX, -m_posY, -m_posZ); - renderChunks(); - glPopMatrix(); + MatrixStack::Ref matrix = MatrixStack::World.push(); + matrix->translate(-m_pos); + + renderChunks(layer, fog); } } -void RenderList::renderChunks() +void RenderList::renderChunks(TerrainLayer layer, bool fog) { - xglEnableClientState(GL_VERTEX_ARRAY); - xglEnableClientState(GL_COLOR_ARRAY); - xglEnableClientState(GL_TEXTURE_COORD_ARRAY); + double time = getTimeS(); if (field_1C > 0) { for (int i = 0; i < field_1C; i++) { - RenderChunk& chk = field_10[i]; - glPushMatrix(); + RenderChunk* chk = field_10[i]; + if (!chk) continue; - glTranslatef(chk.field_C, chk.field_10, chk.field_14); - xglBindBuffer(GL_ARRAY_BUFFER, chk.field_0); - xglVertexPointer (3, GL_FLOAT, sizeof(Tesselator::Vertex), (void*)offsetof(Tesselator::Vertex, m_x)); - xglTexCoordPointer(2, GL_FLOAT, sizeof(Tesselator::Vertex), (void*)offsetof(Tesselator::Vertex, m_u)); - xglColorPointer (4, GL_UNSIGNED_BYTE, sizeof(Tesselator::Vertex), (void*)offsetof(Tesselator::Vertex, m_color)); - xglDrawArrays(GL_TRIANGLES, 0, chk.field_4); + MatrixStack::Ref matrix = MatrixStack::World.push(); + matrix->translate(chk->m_pos); - glPopMatrix(); + chk->render(layer, time, fog); } } - - xglDisableClientState(GL_VERTEX_ARRAY); - xglDisableClientState(GL_COLOR_ARRAY); - xglDisableClientState(GL_TEXTURE_COORD_ARRAY); } diff --git a/source/client/renderer/RenderList.hpp b/source/client/renderer/RenderList.hpp index 63eef9797..605ee9471 100644 --- a/source/client/renderer/RenderList.hpp +++ b/source/client/renderer/RenderList.hpp @@ -9,6 +9,7 @@ #pragma once #include "RenderChunk.hpp" +#include "world/phys/Vec3.hpp" class RenderList { @@ -16,22 +17,21 @@ class RenderList RenderList(); ~RenderList(); - void add(int x); - void addR(const RenderChunk&); + void add(int x, TerrainLayer layer, bool fog); + void addR(RenderChunk* rc, TerrainLayer layer, bool fog); void clear(); - void init(float, float, float); - void render(); - void renderChunks(); + void reset(); + void init(const Vec3& pos); + void render(TerrainLayer layer, bool fog); + void renderChunks(TerrainLayer layer, bool fog); -public: - float m_posX; - float m_posY; - float m_posZ; +private: + Vec3 m_pos; int* field_C; - RenderChunk* field_10; + RenderChunk** field_10; int field_14; - bool field_18; - bool field_19; + bool m_bInited; + bool m_bRendered; int field_1C; }; diff --git a/source/client/renderer/ScreenRenderer.cpp b/source/client/renderer/ScreenRenderer.cpp new file mode 100644 index 000000000..5dd9128a4 --- /dev/null +++ b/source/client/renderer/ScreenRenderer.cpp @@ -0,0 +1,132 @@ +#include "ScreenRenderer.hpp" +#include "renderer/RenderContextImmediate.hpp" +#include "renderer/RenderMaterialGroup.hpp" +#include "renderer/ShaderConstants.hpp" +#include "client/renderer/Tesselator.hpp" + +#ifdef _WIN32 +#pragma warning (disable : 4244) +#endif + +ScreenRenderer::Materials::Materials() +{ + MATERIAL_PTR(common, ui_textured); + MATERIAL_PTR(common, ui_fill_color); + MATERIAL_PTR(common, ui_fill_gradient); + MATERIAL_PTR(common, ui_texture_and_color); + MATERIAL_PTR(common, ui_texture_and_color_nocull); + MATERIAL_PTR(common, ui_textured_and_glcolor); + MATERIAL_PTR(common, ui_fill_stencil); +} + +ScreenRenderer* ScreenRenderer::singletonPtr = nullptr; + +ScreenRenderer& ScreenRenderer::singleton() +{ + if (!ScreenRenderer::singletonPtr) + { + ScreenRenderer::singletonPtr = new ScreenRenderer(); + } + + return *singletonPtr; +} + +ScreenRenderer::ScreenRenderer() +{ + m_blitOffset = 0.0f; +} + +void ScreenRenderer::blit(const IntRectangle& rect) +{ + Tesselator& t = Tesselator::instance; + t.begin(4); + t.vertexUV(rect.x, rect.h + rect.y, 0.0f, 0.0f, 1.0f); + t.vertexUV(rect.w + rect.x, rect.h + rect.y, 0.0f, 1.0f, 1.0f); + t.vertexUV(rect.w + rect.x, rect.y, 0.0f, 1.0f, 0.0f); + t.vertexUV(rect.x, rect.y, 0.0f, 0.0f, 0.0f); + t.draw(m_materials.ui_textured); +} + +void ScreenRenderer::blit(int dx, int dy, int sx, int sy, int tw, int th, int sw, int sh, mce::MaterialPtr* materialPtr) +{ + Tesselator& t = Tesselator::instance; + + if (!sh) sh = th; + if (!sw) sw = tw; + + t.begin(4); + t.vertexUV(dx + 0 , dy + th, m_blitOffset, float(sx + 0 ) / 256.0f, float(sy + sh) / 256.0f); + t.vertexUV(dx + tw, dy + th, m_blitOffset, float(sx + sw) / 256.0f, float(sy + sh) / 256.0f); + t.vertexUV(dx + tw, dy + 0 , m_blitOffset, float(sx + sw) / 256.0f, float(sy + 0 ) / 256.0f); + t.vertexUV(dx + 0 , dy + 0 , m_blitOffset, float(sx + 0 ) / 256.0f, float(sy + 0 ) / 256.0f); + t.draw(materialPtr ? *materialPtr : m_materials.ui_textured); +} + +void ScreenRenderer::blitRaw(float x1, float x2, float y1, float y2, float z, float u1, float u2, float v1, float v2) +{ + Tesselator& t = Tesselator::instance; + + t.begin(4); + t.vertexUV(x1, y1, z, u2, v2); + t.vertexUV(x2, y1, z, u1, v2); + t.vertexUV(x2, y2, z, u1, v1); + t.vertexUV(x1, y2, z, u2, v1); + t.draw(m_materials.ui_textured_and_glcolor); +} + +void ScreenRenderer::drawCenteredString(Font& font, const std::string& str, int cx, int cy, const Color& color) +{ + int width = font.width(str); + int height = font.height(str); + font.drawShadow(str, cx - width / 2, cy - height / 2, color); +} + +void ScreenRenderer::drawString(Font& font, const std::string& str, int cx, int cy, const Color& color) +{ + font.drawShadow(str, cx, cy, color); +} + +void ScreenRenderer::fill(float left, float top, float right, float bottom, const Color& color) +{ + currentShaderColor = color; + + Tesselator& t = Tesselator::instance; + t.begin(4); + + t.vertex(left, bottom, 0.0f); + t.vertex(right, bottom, 0.0f); + t.vertex(right, top, 0.0f); + t.vertex(left, top, 0.0f); + + t.draw(m_materials.ui_fill_color); +} + +void ScreenRenderer::fill(int left, int top, int right, int bottom, const Color& color) +{ + fill(float(left), float(top), float(right), float(bottom), color); +} + +void ScreenRenderer::fillGradient(float left, float top, float right, float bottom, const Color& colorUp, const Color& colorDown) +{ + mce::RenderContext& renderContext = mce::RenderContextImmediate::get(); + renderContext.setShadeMode(mce::SHADE_MODE_SMOOTH); + + Tesselator& t = Tesselator::instance; + t.begin(4); + + t.color(colorUp); + t.vertex(left, bottom, 0.0f); + t.vertex(right, bottom, 0.0f); + t.color(colorDown); + t.vertex(right, top, 0.0f); + t.vertex(left, top, 0.0f); + + t.draw(m_materials.ui_fill_gradient); + + renderContext.setShadeMode(mce::SHADE_MODE_FLAT); +} + +void ScreenRenderer::fillGradient(int left, int top, int right, int bottom, const Color& colorUp, const Color& colorDown) +{ + fillGradient(float(left), float(top), float(right), float(bottom), colorUp, colorDown); +} \ No newline at end of file diff --git a/source/client/renderer/ScreenRenderer.hpp b/source/client/renderer/ScreenRenderer.hpp new file mode 100644 index 000000000..754981005 --- /dev/null +++ b/source/client/renderer/ScreenRenderer.hpp @@ -0,0 +1,50 @@ +#pragma once + +#include "common/math/Color.hpp" +#include "client/gui/IntRectangle.hpp" +#include "client/renderer/Font.hpp" +#include "renderer/MaterialPtr.hpp" + +class ScreenRenderer +{ +protected: + class Materials + { + public: + mce::MaterialPtr ui_textured; + mce::MaterialPtr ui_fill_color; + mce::MaterialPtr ui_fill_gradient; + mce::MaterialPtr ui_texture_and_color; + mce::MaterialPtr ui_texture_and_color_nocull; + mce::MaterialPtr ui_textured_and_glcolor; + mce::MaterialPtr ui_fill_stencil; + + Materials(); + }; + +private: + static ScreenRenderer* singletonPtr; +public: + static ScreenRenderer& singleton(); + +public: + ScreenRenderer(); + +public: + void blit(const IntRectangle& rect); + void blit(int dstX, int dstY, int srcX, int srcY, int dstWidth, int dstHeight, int srcWidth, int srcHeight, mce::MaterialPtr* materialPtr = nullptr); + void blitRaw(float x1, float x2, float y1, float y2, float z, float u1, float u2, float v1, float v2); + void drawCenteredString(Font& font, const std::string& str, int cx, int cy, const Color& color = Color::WHITE); + void drawString(Font& font, const std::string& str, int cx, int cy, const Color& color = Color::WHITE); + void fill(float left, float top, float right, float bottom, const Color& color); + void fill(int left, int top, int right, int bottom, const Color& color); + void fillGradient(float left, float top, float right, float bottom, const Color& colorUp, const Color& colorDown); + void fillGradient(int left, int top, int right, int bottom, const Color& colorUp, const Color& colorDown); + + +protected: + float m_blitOffset; +public: + Materials m_materials; +}; + diff --git a/source/client/renderer/Tesselator.cpp b/source/client/renderer/Tesselator.cpp index 514c9d10a..59ef70a81 100644 --- a/source/client/renderer/Tesselator.cpp +++ b/source/client/renderer/Tesselator.cpp @@ -6,135 +6,180 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ +#include #include "Tesselator.hpp" -#include "thirdparty/GL/GL.hpp" +#include "GameMods.hpp" #include "common/Logger.hpp" #include "compat/EndianDefinitions.h" - -#include +#include "renderer/RenderContextImmediate.hpp" int g_nVertices = 0, g_nTriangles = 0; Tesselator Tesselator::instance; -void Tesselator::_init() +void Tesselator::CurrentVertexPointers::_init() { - m_vertices = 0; + clear(); + uvs[0] = nullptr; + uvs[1] = nullptr; + pFormat = nullptr; +} - m_nextVtxU = 0; - m_nextVtxV = 0; - m_nextVtxColor = 0; +Tesselator::CurrentVertexPointers::CurrentVertexPointers() +{ + _init(); +} - m_bHasColor = false; - m_bHasTexture = false; - m_bHasNormal = false; +Tesselator::CurrentVertexPointers::CurrentVertexPointers(void* vertexData, const mce::VertexFormat& vertexFormat) +{ + _init(); - m_count = 0; - m_bNoColorFlag = false; + pFormat = &vertexFormat; - m_drawArraysMode = 0; + pos = (Vec3*)vertexFormat.getFieldOffset(mce::VERTEX_FIELD_POSITION, vertexData); + + if (vertexFormat.hasField(mce::VERTEX_FIELD_COLOR)) + { + color = (uint32_t*)vertexFormat.getFieldOffset(mce::VERTEX_FIELD_COLOR, vertexData); + } - m_offsetX = 0.0f; - m_offsetY = 0.0f; - m_offsetZ = 0.0f; + if (vertexFormat.hasField(mce::VERTEX_FIELD_NORMAL)) + { + normal = (uint32_t*)vertexFormat.getFieldOffset(mce::VERTEX_FIELD_NORMAL, vertexData); + } - m_nextVtxNormal = 0; + if (vertexFormat.hasField(mce::VERTEX_FIELD_UV0)) + { + uvs[0] = (Vec2*)vertexFormat.getFieldOffset(mce::VERTEX_FIELD_UV0, vertexData); + } - m_bTesselating = false; + if (vertexFormat.hasField(mce::VERTEX_FIELD_UV1)) + { + uvs[1] = (Vec2*)vertexFormat.getFieldOffset(mce::VERTEX_FIELD_UV1, vertexData); + } +} - m_vboCounts = 1024; // 10 on Java - m_vboId = -1; +void Tesselator::CurrentVertexPointers::nextVertex() +{ + unsigned int vertexSize = pFormat->getVertexSize(); - field_28 = false; - m_nVertices = 0; + pos = (Vec3*)((uint8_t*)pos + vertexSize); - field_48 = 0; + if (color) color = (uint32_t*)((uint8_t*)color + vertexSize); + if (normal) normal = (uint32_t*)((uint8_t*)normal + vertexSize); + if (uvs[0]) uvs[0] = (Vec2*)((uint8_t*)uvs[0] + vertexSize); + if (uvs[1]) uvs[1] = (Vec2*)((uint8_t*)uvs[1] + vertexSize); +} - m_accessMode = 2; +void Tesselator::CurrentVertexPointers::clear() +{ + pos = nullptr; + color = nullptr; + normal = nullptr; } -Tesselator::Tesselator(int size) +void Tesselator::_init() { - _init(); + m_bHasIndices = false; - // Initialize buffer - m_maxVertices = size / sizeof(Vertex); - m_pVertices = new Vertex[m_maxVertices]; + m_indexSize = 0; + m_indexCount = 0; - // Setup VBO - m_bVboMode = USE_VBO; // && lwjgl::GLContext::getCapabilities()["GL_ARB_vertex_buffer_object"]; - if (m_bVboMode) - { - m_vboIds = new GLuint[m_vboCounts]; - //init(); // Java - } + m_vertices = 0; + + m_pendingVertices = 0; + + resetScale(); + + m_nextVtxColor = 0; + m_nextVtxNormal = 0; + + resetTilt(); + + m_count = 0; + m_bNoColorFlag = false; + + m_bTesselating = false; + m_drawMode = mce::PRIMITIVE_MODE_NONE; + + m_bVoidBeginEnd = false; } -Tesselator::~Tesselator() +Tesselator::Tesselator(int size) { - if (m_vboIds) - delete[] m_vboIds; - if (m_pVertices) - delete[] m_pVertices; + _init(); } -void Tesselator::addOffset(float x, float y, float z) +Tesselator::~Tesselator() { - m_offsetX += x; - m_offsetY += y; - m_offsetZ += z; } -void Tesselator::clear() +void* Tesselator::_allocateIndices(int count) { - m_accessMode = 2; - m_vertices = 0; - m_count = 0; - m_nVertices = 0; - field_28 = 0; + m_indices.resize(m_indexSize * count); + return &m_indices.front(); } -void Tesselator::color(int r, int g, int b, int a) +void Tesselator::_tex(const Vec2& uv, int count) { - if (m_bNoColorFlag) return; + m_nextVtxUVs[count] = uv; + + if (!isFormatFixed()) + { + m_vertexFormat.enableField((mce::VertexField)(mce::VERTEX_FIELD_UV0 + count)); + } +} - if (b >= 255) b = 255; - if (g >= 255) g = 255; - if (r >= 255) r = 255; - if (a >= 255) a = 255; +void Tesselator::clear() +{ + m_count = 0; + m_indices.clear(); + m_vertexFormat = mce::VertexFormat::EMPTY; + m_currentVertex.clear(); + m_indexCount = 0; + m_vertices = 0; + m_bVoidBeginEnd = false; + m_bTesselating = false; + m_bHasIndices = false; +} - // note: weird bit hacking (as in X & ~(X >> 31)) is used to perform the following: - if (b < 0) b = 0; - if (g < 0) g = 0; - if (r < 0) r = 0; - if (a < 0) a = 0; +void Tesselator::cancel() +{ + m_bTesselating = false; +} - m_bHasColor = true; +void Tesselator::color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) +{ #if MC_ENDIANNESS_BIG - m_nextVtxColor = a | (b << 8) | (g << 16) | (r << 24); + colorABGR(a | (b << 8) | (g << 16) | (r << 24)); #else // MC_ENDIANNESS_LITTLE - m_nextVtxColor = (a << 24) | (b << 16) | (g << 8) | r; + colorABGR((a << 24) | (b << 16) | (g << 8) | r); #endif } -void Tesselator::color(int r, int g, int b) +void Tesselator::color(uint8_t r, uint8_t g, uint8_t b) { - color(r, g, b, 255); + color(r, g, b, (uint8_t)255); } -void Tesselator::color(int c, int a) +void Tesselator::color(const Color& c) +{ + color(int8_t(c.r * 255), int8_t(c.g * 255), int8_t(c.b * 255), int8_t(c.a * 255)); +} + +void Tesselator::color(int32_t c, int a) { color((c >> 16) & 0xFF, (c >> 8) & 0xFF, c & 0xFF, a); } -void Tesselator::color(int c) +void Tesselator::color(int32_t c) { color((c >> 16) & 0xFF, (c >> 8) & 0xFF, c & 0xFF, 255); } -void Tesselator::color(char r, char g, char b) +void Tesselator::color(int r, int g, int b, int a) { - color(int(r), int(g), int(b)); + color(uint8_t(r), uint8_t(g), uint8_t(b), uint8_t(a)); } void Tesselator::color(float r, float g, float b) @@ -144,137 +189,102 @@ void Tesselator::color(float r, float g, float b) void Tesselator::color(float r, float g, float b, float a) { - color(int(r * 255), int(g * 255), int(b * 255), int(a * 255)); + color(Color(r, g, b, a)); } -void Tesselator::begin() +void Tesselator::colorABGR(uint32_t c) { - begin(GL_QUADS); + if (m_bNoColorFlag) return; + + m_nextVtxColor = c; + + if (!isFormatFixed()) + { + m_vertexFormat.enableField(mce::VERTEX_FIELD_COLOR); + } } -void Tesselator::begin(GLenum mode) +void Tesselator::begin(int maxVertices) { - if (m_bTesselating || field_28) return; + begin(mce::PRIMITIVE_MODE_QUAD_LIST, maxVertices); +} + +void Tesselator::begin(mce::PrimitiveMode mode, int maxVertices) +{ + if (m_bTesselating || m_bVoidBeginEnd) return; - m_bTesselating = true; clear(); - m_drawArraysMode = mode; - m_bHasNormal = false; - m_bHasColor = false; - m_bHasTexture = false; + + m_drawMode = mode; m_bNoColorFlag = false; + m_bTesselating = true; + m_vertexFormat.enableField(mce::VERTEX_FIELD_POSITION); + m_indexSize = 0; + m_indexCount = 0; + m_pendingVertices = maxVertices; } -void Tesselator::draw() +void Tesselator::draw(const mce::MaterialPtr& materialPtr) { - if (!m_bTesselating || field_28) + if (!m_bTesselating || m_bVoidBeginEnd) return; - m_bTesselating = false; - if (m_vertices > 0) { - if (m_bVboMode) - { - /*m_vboId++; - if (m_vboId >= m_vboCounts) - m_vboId = 0;*/ - m_vboId = (m_vboId + 1) % m_vboCounts; - - xglBindBuffer(GL_ARRAY_BUFFER, m_vboIds[m_vboId]); - xglBufferData(GL_ARRAY_BUFFER, sizeof(Vertex) * m_nVertices, m_pVertices, m_accessMode == 1 ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW); - } - - if (m_bHasTexture) - { - // it won't use address 12, because we've bound a buffer object - xglTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), (void*)offsetof(Vertex, m_u)); - xglEnableClientState(GL_TEXTURE_COORD_ARRAY); - } - if (m_bHasColor) - { - // it won't use address 12, because we've bound a buffer object - xglColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex), (void*)offsetof(Vertex, m_color)); - xglEnableClientState(GL_COLOR_ARRAY); - } -#ifdef USE_GL_NORMAL_LIGHTING - if (m_bHasNormal) - { - xglNormalPointer(GL_BYTE, sizeof(Vertex), (void*)offsetof(Vertex, m_normal)); - xglEnableClientState(GL_NORMAL_ARRAY); - } -#endif - - xglVertexPointer(3, GL_FLOAT, sizeof(Vertex), (void*)offsetof(Vertex, m_x)); - xglEnableClientState(GL_VERTEX_ARRAY); - - // if we want to draw quads, draw triangles actually - // otherwise, just pass the mode, it's fine - if (m_drawArraysMode == GL_QUADS && TRIANGLE_MODE) - xglDrawArrays(GL_TRIANGLES, 0, m_vertices); - else - xglDrawArrays(m_drawArraysMode, 0, m_vertices); - - xglDisableClientState(GL_VERTEX_ARRAY); -#ifdef USE_GL_NORMAL_LIGHTING - if (m_bHasNormal) - xglDisableClientState(GL_NORMAL_ARRAY); -#endif - if (m_bHasColor) - xglDisableClientState(GL_COLOR_ARRAY); - if (m_bHasTexture) - xglDisableClientState(GL_TEXTURE_COORD_ARRAY); + mce::Mesh mesh = end("draw", true); + mesh.render(materialPtr); } clear(); } -RenderChunk Tesselator::end(int vboIdx) +mce::Mesh Tesselator::end(const char* debugName, bool temporary) { - if (!m_bTesselating || field_28) + if (!m_bTesselating || m_bVoidBeginEnd) { //LOG_W("Not tesselating!"); - return RenderChunk(); // empty render chunk + return mce::Mesh(); } - int count = m_vertices; - m_bTesselating = false; - if (count > 0) + if (m_vertices && isFormatFixed()) { - // Bind VBO - if (m_bVboMode) - { - m_vboId++; - if (m_vboId >= m_vboCounts) - m_vboId = 0; - //m_vboId = (m_vboId + 1) % m_vboCounts; - if (vboIdx < 0) - vboIdx = m_vboIds[m_vboId]; - - xglBindBuffer(GL_ARRAY_BUFFER, vboIdx); - xglBufferData(GL_ARRAY_BUFFER, sizeof(Vertex) * m_nVertices, m_pVertices, m_accessMode == 1 ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW); - } - - field_48 += sizeof (Vertex) * m_nVertices; + mce::Mesh mesh(m_vertexFormat, + m_vertices, + m_indexCount, + m_indexSize, + m_drawMode, + &m_indices[0], + temporary); + + if (!temporary) + clear(); + + return mesh; } + else + { + m_bTesselating = false; + return mce::Mesh(); + } +} - clear(); - - RenderChunk rchk(vboIdx, count); - - m_VboIdxToRenderChunkID[vboIdx] = rchk.m_id; +bool Tesselator::isFormatFixed() const +{ + return m_currentVertex.pos != nullptr; +} - return rchk; +void Tesselator::init() +{ } -int Tesselator::getVboCount() +void Tesselator::trim() { - return m_vboCounts; + m_indices.clear(); } -void Tesselator::init() +void Tesselator::enableColor() { - xglGenBuffers(m_vboCounts, m_vboIds); + m_bNoColorFlag = false; } void Tesselator::noColor() @@ -282,127 +292,166 @@ void Tesselator::noColor() m_bNoColorFlag = true; } +void Tesselator::tilt() +{ + m_bTilt = true; +} + +void Tesselator::resetTilt() +{ + m_bTilt = false; +} + +void Tesselator::scale2d(float x, float y) +{ + m_scale2D.x *= x; + m_scale2D.y *= y; +} + +void Tesselator::scale3d(float x, float y, float z) +{ + m_scale3D.x *= x; + m_scale3D.y *= y; + m_scale3D.z *= z; +} + +void Tesselator::resetScale() +{ + // We cannot use Vec2::ONE here since Tesselator::instance is initialized dynamically before Vec2::ONE + m_scale2D = Vec2(1, 1); + m_scale3D = Vec3(1, 1, 1); +} + void Tesselator::normal(float x, float y, float z) { -#ifdef USE_GL_NORMAL_LIGHTING /*if (!m_bTesselating) LOG_W("But...");*/ - m_bHasNormal = true; - int8_t bx = static_cast(x * 128); - int8_t by = static_cast(y * 127); - int8_t bz = static_cast(z * 127); + int8_t bx = static_cast(ceilf(x * 127)); + int8_t by = static_cast(ceilf(y * 127)); + int8_t bz = static_cast(ceilf(z * 127)); #if MC_ENDIANNESS_BIG m_nextVtxNormal = (bx << 24) | (by << 16) | (bz << 8); #else // MC_ENDIANNESS_LITTLE m_nextVtxNormal = (bx << 0) | (by << 8) | (bz << 16); #endif -#endif + + if (!isFormatFixed()) + { + m_vertexFormat.enableField(mce::VERTEX_FIELD_NORMAL); + } +} + +void Tesselator::setOffset(const Vec3& pos) +{ + m_offset = pos; } -void Tesselator::offset(float x, float y, float z) +void Tesselator::addOffset(const Vec3& pos) { - m_offsetX = x; - m_offsetY = y; - m_offsetZ = z; + m_offset += pos; } -void Tesselator::setAccessMode(int mode) +void Tesselator::tex(const Vec2& uv) { - m_accessMode = mode; + _tex(uv, 0); +} + +void Tesselator::tex1(const Vec2& uv) +{ + _tex(uv, 1); } void Tesselator::tex(float u, float v) { - m_nextVtxU = u; - m_nextVtxV = v; - m_bHasTexture = true; + tex(Vec2(u, v)); } -void Tesselator::vertexUV(float x, float y, float z, float u, float v) +void Tesselator::tex1(float u, float v) { - tex(u, v); - vertex(x, y, z); + tex1(Vec2(u, v)); +} + +void Tesselator::triangle(unsigned int x, unsigned int y, unsigned int z) +{ + uint8_t* indices = (uint8_t*)_allocateIndices(3); + indices[0 * m_indexSize] = x; + indices[1 * m_indexSize] = y; + indices[2 * m_indexSize] = z; + m_indexCount += 3; } void Tesselator::vertex(float x, float y, float z) { - if (m_nVertices >= m_maxVertices) { - LOG_W("Overwriting the vertex buffer! This chunk/entity won't show up"); - clear(); - } + if (m_count == mce::RenderContext::getMaxVertexCount()) + return; m_count++; - if (m_drawArraysMode == GL_QUADS && TRIANGLE_MODE && (m_count % 4) == 0) - { - for (int idx = 3; idx != 1; idx--) - { - // duplicate the last 2 added vertices in quad mode - Vertex *pVert1 = &m_pVertices[m_nVertices - idx], *pVert2 = &m_pVertices[m_nVertices]; - if (m_bHasTexture) - { - pVert2->m_u = pVert1->m_u; - pVert2->m_v = pVert1->m_v; - } - - if (m_bHasColor) - { - pVert2->m_color = pVert1->m_color; - } - - // Wasn't here in Java cuz I guess it's not needed? - // TBR: This is needed with Emscripten's OpenGL implementation. -#ifdef USE_GL_NORMAL_LIGHTING - if (m_bHasNormal) - { - pVert2->m_normal = pVert1->m_normal; - } -#endif - pVert2->m_x = pVert1->m_x; - pVert2->m_y = pVert1->m_y; - pVert2->m_z = pVert1->m_z; + unsigned int vertexSize = m_vertexFormat.getVertexSize(); + uint8_t* oldIndicesPtr = !m_indices.empty() ? &m_indices.front() : nullptr; - m_vertices++; - m_nVertices++; + if (m_pendingVertices > 0) + { + m_indices.reserve(vertexSize * m_pendingVertices); + m_pendingVertices = 0; + } -#ifdef _DEBUG - g_nVertices++; -#endif + m_indices.resize((m_vertices+1) * vertexSize); - if (m_nVertices >= m_maxVertices) - return; - } + // Make sure m_indices front pointer hasn't changed from reallocation as a result of reserve or resize + if (isFormatFixed() && oldIndicesPtr == &m_indices.front()) + { + m_currentVertex.nextVertex(); } - - Vertex* pVert = &m_pVertices[m_nVertices]; - if (m_bHasTexture) + else { - pVert->m_u = m_nextVtxU; - pVert->m_v = m_nextVtxV; + m_currentVertex = CurrentVertexPointers(&m_indices[m_vertices * vertexSize], m_vertexFormat); } - if (m_bHasColor) + if (m_bTilt) { - pVert->m_color = m_nextVtxColor; + LOG_E("Tilt support not implemented"); + throw std::bad_cast(); } -#ifdef USE_GL_NORMAL_LIGHTING - if (m_bHasNormal) + // Set vertex pos + m_currentVertex.pos->x = (m_offset.x + (x * m_scale3D.x)) * m_scale2D.x; + m_currentVertex.pos->y = (m_offset.y + (y * m_scale3D.x)) * m_scale2D.y; + m_currentVertex.pos->z = m_offset.z + (z * m_scale3D.x); + + // Set vertex UVs + for (int i = 0; i < 2; i++) { - pVert->m_normal = m_nextVtxNormal; + if (m_currentVertex.uvs[i]) + { + m_currentVertex.uvs[i]->x = m_nextVtxUVs[0].x;//ceilf(m_nextVtxUVs[i].x * 65535.f); + m_currentVertex.uvs[i]->y = m_nextVtxUVs[0].y;//ceilf(m_nextVtxUVs[i].y * 65535.f); + } } -#endif - pVert->m_x = m_offsetX + x; - pVert->m_y = m_offsetY + y; - pVert->m_z = m_offsetZ + z; + // Set vertex color + if (m_currentVertex.color) + *m_currentVertex.color = m_nextVtxColor; + + // Set vertex normal + if (m_currentVertex.normal) + *m_currentVertex.normal = m_nextVtxNormal; m_vertices++; - m_nVertices++; + +#ifdef _DEBUG + g_nVertices++; +#endif +} + +void Tesselator::vertexUV(const Vec3& pos, float u, float v) +{ + tex(u, v); + vertex(pos); } void Tesselator::voidBeginAndEndCalls(bool b) { - field_28 = b; + m_bVoidBeginEnd = b; } diff --git a/source/client/renderer/Tesselator.hpp b/source/client/renderer/Tesselator.hpp index 9d9d2cd72..027bbde09 100644 --- a/source/client/renderer/Tesselator.hpp +++ b/source/client/renderer/Tesselator.hpp @@ -10,14 +10,14 @@ #include #include -#include "thirdparty/GL/GL.hpp" +#include #include "RenderChunk.hpp" +#include "world/phys/Vec2.hpp" #include "world/phys/Vec3.hpp" - -#define GET_RED(c) (uint8_t(((c) >> 0) & 0xFF)) -#define GET_GREEN(c) (uint8_t(((c) >> 8) & 0xFF)) -#define GET_BLUE(c) (uint8_t(((c) >> 16) & 0xFF)) -#define GET_ALPHA(c) (uint8_t(((c) >> 24) & 0xFF)) +#include "common/math/Color.hpp" +#include "renderer/VertexFormat.hpp" +#include "renderer/hal/enums/PrimitiveMode.hpp" +#include "renderer/Mesh.hpp" #define TRIANGLE_MODE true // false on Java @@ -29,21 +29,25 @@ class Tesselator static Tesselator instance; // singleton public: - struct Vertex + class CurrentVertexPointers { - // position - float m_x; - float m_y; - float m_z; - // texture mapping coords - float m_u; - float m_v; - // RGBA color - uint32_t m_color; -#ifdef USE_GL_NORMAL_LIGHTING - // the legend - uint32_t m_normal; -#endif + public: + Vec3* pos; + uint32_t* color; + uint32_t* normal; + Vec2* uvs[2]; + const mce::VertexFormat* pFormat; + + private: + void _init(); + + public: + CurrentVertexPointers(); + CurrentVertexPointers(void* vertexData, const mce::VertexFormat& vertexFormat); + + public: + void nextVertex(); + void clear(); }; private: @@ -53,82 +57,92 @@ class Tesselator Tesselator(int size = 0x800000); ~Tesselator(); - void addOffset(float x, float y, float z); - void addOffset(const Vec3& pos) { addOffset(pos.x, pos.y, pos.z); } - void begin(); - void begin(GLenum mode); +private: + void* _allocateIndices(int count); + void _tex(const Vec2& uv, int count); + +public: + void begin(int maxVertices); + void begin(mce::PrimitiveMode mode, int maxVertices); void clear(); - void color(int c); - void color(int c, int a); - void color(int r, int g, int b); + void cancel(); + void color(int32_t c); + void color(int32_t c, int a); + void color(uint8_t r, uint8_t g, uint8_t b); + void color(uint8_t r, uint8_t g, uint8_t b, uint8_t a); + void color(const Color& c); void color(int r, int g, int b, int a); - void color(char r, char g, char b); void color(float r, float g, float b); void color(float r, float g, float b, float a); - void draw(); - int getVboCount(); + void colorABGR(uint32_t c); + void draw(const mce::MaterialPtr& materialPtr); void init(); + void trim(); + void enableColor(); void noColor(); - void normal(float, float, float); + void tilt(); + void resetTilt(); + void scale2d(float x, float y); + void scale3d(float x, float y, float z); + void resetScale(); + void normal(float x, float y, float z); void normal(const Vec3& pos) { normal(pos.x, pos.y, pos.z); } - void offset(float, float, float); - void offset(const Vec3& pos) { offset(pos.x, pos.y, pos.z); } - void setAccessMode(int mode); // sets m_DrawArraysMode + void setOffset(const Vec3& pos); + void addOffset(const Vec3& pos); + void setOffset(float x, float y, float z) { setOffset(Vec3(x, y, z)); } + void addOffset(float x, float y, float z) { addOffset(Vec3(x, y, z)); } + void tex(const Vec2& uv); + void tex1(const Vec2& uv); void tex(float u, float v); + void tex1(float u, float v); + void triangle(unsigned int x, unsigned int y, unsigned int z); void vertex(float x, float y, float z); void vertex(const Vec3& pos) { vertex(pos.x, pos.y, pos.z); } - void vertexUV(float x, float y, float z, float u, float v); - void vertexUV(const Vec3& pos, float u, float v) { vertexUV(pos.x, pos.y, pos.z, u, v); } + void vertexUV(const Vec3& pos, float u, float v); + void vertexUV(float x, float y, float z, float u, float v) { vertexUV(Vec3(x, y, z), u, v); } void voidBeginAndEndCalls(bool b); - RenderChunk end(int); + mce::Mesh end(const char* debugName = nullptr, bool temporary = false); + + bool isFormatFixed() const; private: - // Buffer - Vertex* m_pVertices; + CurrentVertexPointers m_currentVertex; + + std::vector m_indices; + bool m_bHasIndices; + + uint8_t m_indexSize; + //_BYTE gap2D[3]; + unsigned int m_indexCount; + mce::VertexFormat m_vertexFormat; // Tesselation state - int m_vertices; + unsigned int m_vertices; + + int m_pendingVertices; + + Vec3 m_offset; + Vec3 m_scale3D; + Vec2 m_scale2D; - float m_nextVtxU; // u - float m_nextVtxV; // v + Vec2 m_nextVtxUVs[2]; // u, v uint32_t m_nextVtxColor; // col + uint32_t m_nextVtxNormal; // normalValue - bool m_bHasColor; - bool m_bHasTexture; - bool m_bHasNormal; + bool m_bTilt; int m_count; bool m_bNoColorFlag; - GLenum m_drawArraysMode; // draw_mode - - float m_offsetX; - float m_offsetY; - float m_offsetZ; - - uint32_t m_nextVtxNormal; // normalValue - // State bool m_bTesselating; - bool m_bVboMode; - - // VBO State - GLuint* m_vboIds; - int m_vboId; - int m_vboCounts; + mce::PrimitiveMode m_drawMode; // Buffer state int m_maxVertices; private: - bool field_28; - int m_nVertices; - - int field_48; - - int m_accessMode; - - std::map m_VboIdxToRenderChunkID; + bool m_bVoidBeginEnd; }; diff --git a/source/client/renderer/Textures.cpp b/source/client/renderer/Textures.cpp index c77b6c33c..5fb64fdec 100644 --- a/source/client/renderer/Textures.cpp +++ b/source/client/renderer/Textures.cpp @@ -7,110 +7,131 @@ ********************************************************************/ #include "Textures.hpp" +#include "common/Util.hpp" +#include "renderer/RenderContextImmediate.hpp" + +#define MIP_TAG "_mip" +#define MIP_TAG_SIZE 4 bool Textures::MIPMAP = false; -int Textures::loadTexture(const std::string& name, bool bIsRequired) +TextureData* Textures::loadTexture(const std::string& name, bool bIsRequired) { - std::map::iterator i = m_textures.find(name); - if (i != m_textures.end()) - { - return i->second != 0 ? i->second : -1; - } + TextureMap::iterator it = m_textures.find(name); + assert(it == m_textures.end()); - Texture t = m_pPlatform->loadTexture(name, bIsRequired); + TextureData t = m_pPlatform->loadTexture(name, bIsRequired); - if (!t.m_pixels) + if (t.isEmpty()) { if (bIsRequired) { - t.m_hasAlpha = true; - t.field_D = 0; - t.m_width = 2; - t.m_height = 2; - t.m_pixels = new uint32_t[4]; - t.m_pixels[0] = 0xfff800f8; - t.m_pixels[1] = 0xff000000; - t.m_pixels[3] = 0xfff800f8; - t.m_pixels[2] = 0xff000000; + t.m_imageData.m_colorSpace = COLOR_SPACE_RGBA; + t.m_imageData.m_width = 2; + t.m_imageData.m_height = 2; + uint32_t* placeholder = new uint32_t[4]; + placeholder[0] = 0xfff800f8; + placeholder[1] = 0xff000000; + placeholder[3] = 0xfff800f8; + placeholder[2] = 0xff000000; + t.m_imageData.m_data = (uint8_t*)placeholder; } else { // Record the fact that the texture file couldn't be loaded // This means we can stop checking the filesystem every frame to see if the texture can be found - m_textures[name] = 0; - return -1; + m_textures[name] = nullptr; + return nullptr; } } - return assignTexture(name, t); + t.m_bEnableFiltering = m_bBlur; + t.m_bWrap = !m_bClamp; + + return uploadTexture(name, t); } -int Textures::assignTexture(const std::string& name, Texture& texture) +size_t _mipTagStart(const std::string& path) { - GLuint textureID = 0; + // "_mip" + "0." + constexpr size_t mipSuffixLength = MIP_TAG_SIZE + 2; - glGenTextures(1, &textureID); - if (textureID != m_currBoundTex) - { - glBindTexture(GL_TEXTURE_2D, textureID); - m_currBoundTex = textureID; - } + std::string extension = Util::getExtension(path); - if (MIPMAP) - { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - } - else - { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - } + return path.length() - mipSuffixLength - extension.length(); +} - if (m_bBlur) - { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - } +bool _isMipmap(const std::string& path) +{ + std::string mipTag = path.substr(_mipTagStart(path), MIP_TAG_SIZE); + return mipTag == MIP_TAG; +} - if (m_bClamp) - { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - } - else +TextureData* Textures::uploadTexture(const std::string& name, TextureData& t) +{ + TextureData* result = nullptr; + + bool isMipmap = _isMipmap(name); + if (isMipmap && name.find(MIP_TAG)) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - } + if (mce::Texture::supportsMipMaps()) + { + // Find the starting position of the mipmap tag (e.g., "_mip") in the filename. + size_t mipTagPos = _mipTagStart(name); - GLuint internalFormat = GL_RGB; + // Reconstruct the base texture name from the mipmapped filename. + // e.g., "images/terrain-atlas_mip0.tga" -> "images/terrain-atlas.tga" + std::string basePathNoExtension = name.substr(0, mipTagPos); + std::string extension = Util::getExtension(name); // "tga" + std::string basePath = basePathNoExtension + "." + extension; - if (texture.m_hasAlpha) - internalFormat = GL_RGBA; + TextureMap::iterator it = m_textures.find(basePath); + if (it != m_textures.end()) + { + char mipLevelChar = name[mipTagPos + MIP_TAG_SIZE]; + t.m_imageData.m_mipCount = mipLevelChar - '0'; - glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, texture.m_width, texture.m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture.m_pixels); + TextureData* pBaseTexture = it->second; - m_textures[name] = textureID; + if (pBaseTexture) + { + pBaseTexture->loadMipmap(t.m_imageData); + } - m_textureData[textureID] = TextureData(textureID, texture); + result = pBaseTexture; + } + } + return result; + } + + t.load(); + result = new TextureData(t); + m_textures[name] = result; - return textureID; + return result; +} + +void Textures::unloadAll() +{ + for (TextureMap::iterator it = m_textures.begin(); it != m_textures.end(); it++) + { + TextureData* pTexture = it->second; + if (pTexture) + pTexture->unload(); + } + + TextureData::unbindAll(); } void Textures::clear() { + unloadAll(); // note: Textures::clear() does not touch the dynamic textures vector - for (std::map::iterator it = m_textures.begin(); it != m_textures.end(); it++) - glDeleteTextures(1, &it->second); - - for (std::map::iterator it = m_textureData.begin(); it != m_textureData.end(); it++) - delete[] it->second.textureData.m_pixels; + for (TextureMap::iterator it = m_textures.begin(); it != m_textures.end(); it++) + delete it->second; m_textures.clear(); - m_textureData.clear(); m_currBoundTex = -1; } @@ -139,58 +160,61 @@ Textures::~Textures() void Textures::tick() { + mce::RenderContext& renderContext = mce::RenderContextImmediate::get(); + // tick dynamic textures here for (std::vector::iterator it = m_dynamicTextures.begin(); it < m_dynamicTextures.end(); it++) { DynamicTexture* pDynaTex = *it; - pDynaTex->bindTexture(this); + TextureData* pData = pDynaTex->bindTexture(this); + if (!pData) continue; pDynaTex->tick(); + mce::Texture& texture = pData->m_texture; + for (int x = 0; x < pDynaTex->m_textureSize; x++) { for (int y = 0; y < pDynaTex->m_textureSize; y++) { - // texture is already bound so this is fine: - glTexSubImage2D( - GL_TEXTURE_2D, - 0, + texture.subBuffer(renderContext, + pDynaTex->m_pixels, 16 * (x + pDynaTex->m_textureIndex % 16), 16 * (y + pDynaTex->m_textureIndex / 16), - 16, 16, - GL_RGBA, - GL_UNSIGNED_BYTE, - pDynaTex->m_pixels - ); + 16, 16, 0); } } } } -int Textures::loadAndBindTexture(const std::string& name, bool isRequired) +TextureData* Textures::loadAndBindTexture(const std::string& name, bool isRequired, unsigned int textureUnit) { - int id = loadTexture(name, isRequired); + TextureMap::iterator it = m_textures.find(name); + TextureData* pTexture = getTextureData(name, isRequired); - if (m_currBoundTex != id) - { - m_currBoundTex = id; - glBindTexture(GL_TEXTURE_2D, id); - } + if (!pTexture) + return nullptr; + + // bound twice on initial load in _loadTexData + // if it was just loaded, this is our third call to glBindTexture + pTexture->bind(textureUnit); - return id; + return pTexture; } -void Textures::addDynamicTexture(DynamicTexture* pTexture) +TextureData* Textures::getTextureData(const std::string& name, bool isRequired) { - m_dynamicTextures.push_back(pTexture); - pTexture->tick(); + TextureMap::iterator it = m_textures.find(name); + TextureData* pTexture; + if (it != m_textures.end()) + pTexture = it->second; + else + pTexture = loadTexture(name, isRequired); + return pTexture; } -Texture* Textures::getTemporaryTextureData(GLuint id) +void Textures::addDynamicTexture(DynamicTexture* pTexture) { - std::map::iterator i = m_textureData.find(id); - if (i == m_textureData.end()) - return nullptr; - - return &i->second.textureData; -} + m_dynamicTextures.push_back(pTexture); + pTexture->tick(); +} \ No newline at end of file diff --git a/source/client/renderer/Textures.hpp b/source/client/renderer/Textures.hpp index 18ac6480e..6faeef8b1 100644 --- a/source/client/renderer/Textures.hpp +++ b/source/client/renderer/Textures.hpp @@ -9,7 +9,6 @@ #pragma once #include -#include "thirdparty/GL/GL.hpp" #include "client/options/Options.hpp" #include "client/app/AppPlatform.hpp" #include "DynamicTexture.hpp" @@ -20,31 +19,19 @@ class DynamicTexture; // in case we are being included from DynamicTexture. We don't store complete references to that -struct TextureData -{ - int glID; - Texture textureData; - - TextureData() - { - glID = 0; - } - TextureData(int i, Texture& x) - { - glID = i; - textureData = x; - } -}; - class Textures { +protected: + typedef std::map TextureMap; + public: - int loadTexture(const std::string& name, bool bRequired); - int loadAndBindTexture(const std::string& name, bool isRequired = true); + TextureData* loadTexture(const std::string& name, bool bRequired); + TextureData* loadAndBindTexture(const std::string& name, bool isRequired = true, unsigned int textureUnit = 0); + TextureData* getTextureData(const std::string& name, bool isRequired); + void unloadAll(); void clear(); void tick(); void addDynamicTexture(DynamicTexture* pTexture); - Texture* getTemporaryTextureData(GLuint id); // set smoothing for next texture to be loaded void setSmoothing(bool b) @@ -64,16 +51,15 @@ class Textures private: static bool MIPMAP; - int assignTexture(const std::string& name, Texture& t); + TextureData* uploadTexture(const std::string& name, TextureData& t); protected: - std::map m_textures; + TextureMap m_textures; Options* m_pOptions; AppPlatform* m_pPlatform; int m_currBoundTex; bool m_bClamp; bool m_bBlur; - std::map m_textureData; std::vector m_dynamicTextures; friend class StartMenuScreen; diff --git a/source/client/renderer/TileRenderer.cpp b/source/client/renderer/TileRenderer.cpp index c9345334b..1339b4500 100644 --- a/source/client/renderer/TileRenderer.cpp +++ b/source/client/renderer/TileRenderer.cpp @@ -11,19 +11,27 @@ #include "client/renderer/PatchManager.hpp" #include "client/renderer/GrassColor.hpp" #include "client/renderer/FoliageColor.hpp" +#include "client/renderer/renderer/RenderMaterialGroup.hpp" #include "world/tile/FireTile.hpp" #include "world/tile/LiquidTile.hpp" #include "GameMods.hpp" +TileRenderer::Materials::Materials() +{ + MATERIAL_PTR(common, ui_item); +} + bool TileRenderer::m_bFancyGrass = false; bool TileRenderer::m_bBiomeColors = false; void TileRenderer::_init() { - m_textureOverride = -1; - field_8 = false; - m_bDisableCulling = false; + m_fixedTexture = -1; + m_bXFlipTexture = false; + m_bNoCulling = false; m_bAmbientOcclusion = false; + + // AO stuff field_C = 0; field_10 = 0; field_14 = 0; @@ -66,19 +74,11 @@ void TileRenderer::_init() field_B7 = false; } -TileRenderer::TileRenderer() +TileRenderer::TileRenderer(Tesselator& tessellator, LevelSource* pLevelSource) + : m_tessellator(tessellator) { _init(); -#ifndef ORIGINAL_CODE - // @BUG: Not initializing level source - m_pLevelSource = nullptr; -#endif -} - -TileRenderer::TileRenderer(LevelSource* pLevelSource) -{ - _init(); - m_pLevelSource = pLevelSource; + m_pTileSource = pLevelSource; } float TileRenderer::getWaterHeight(const TilePos& pos, const Material* pCheckMtl) @@ -91,13 +91,13 @@ float TileRenderer::getWaterHeight(const TilePos& pos, const Material* pCheckMtl pos.y, pos.z - ((i >> 1) & 1)); - if (m_pLevelSource->getMaterial(TilePos(checkPos.x, checkPos.y + 1, checkPos.z)) == pCheckMtl) + if (m_pTileSource->getMaterial(TilePos(checkPos.x, checkPos.y + 1, checkPos.z)) == pCheckMtl) return 1.0f; - Material* pMtl = m_pLevelSource->getMaterial(checkPos); + Material* pMtl = m_pTileSource->getMaterial(checkPos); if (pMtl == pCheckMtl) { - TileData data = m_pLevelSource->getData(checkPos); + TileData data = m_pTileSource->getData(checkPos); if (data >= 8 || data == 0) { fHeight += LiquidTile::getWaterVolume(data) * 10.0f; @@ -132,8 +132,8 @@ void TileRenderer::renderEast(Tile* tile, const Vec3& pos, int texture) static constexpr float C_RATIO = 1.0f / 256.0f; - if (m_textureOverride >= 0) - texture = m_textureOverride; + if (m_fixedTexture >= 0) + texture = m_fixedTexture; float texX = float(16 * (texture % 16)); float texY = float(16 * (texture / 16)); @@ -148,7 +148,7 @@ void TileRenderer::renderEast(Tile* tile, const Vec3& pos, int texture) texU_r = C_RATIO * (texX + 15.99f); } // if flipping on the Z coordinate - else if (field_8) + else if (m_bXFlipTexture) { texU_r = C_RATIO * (texX + aabb.min.z * 16); texU_l = C_RATIO * (texX + aabb.max.z * 16 - 0.01f); @@ -191,7 +191,7 @@ void TileRenderer::renderEast(Tile* tile, const Vec3& pos, int texture) t.vertexUV(aabb.max.x + pos.x, aabb.max.y + pos.y, aabb.max.z + pos.z, texU_l, texV_u); if (tile->getRenderShape() == SHAPE_CACTUS) - tile->updateShape(m_pLevelSource, pos); + tile->updateShape(m_pTileSource, pos); } void TileRenderer::renderWest(Tile* tile, const Vec3& pos, int texture) @@ -201,8 +201,8 @@ void TileRenderer::renderWest(Tile* tile, const Vec3& pos, int texture) static constexpr float C_RATIO = 1.0f / 256.0f; - if (m_textureOverride >= 0) - texture = m_textureOverride; + if (m_fixedTexture >= 0) + texture = m_fixedTexture; float texX = float(16 * (texture % 16)); float texY = float(16 * (texture / 16)); @@ -217,7 +217,7 @@ void TileRenderer::renderWest(Tile* tile, const Vec3& pos, int texture) texU_r = C_RATIO * (texX + 15.99f); } // if flipping on the Z coordinate - else if (field_8) + else if (m_bXFlipTexture) { texU_r = C_RATIO * (texX + aabb.min.z * 16); texU_l = C_RATIO * (texX + aabb.max.z * 16 - 0.01f); @@ -260,7 +260,7 @@ void TileRenderer::renderWest(Tile* tile, const Vec3& pos, int texture) t.vertexUV(aabb.min.x + pos.x, aabb.min.y + pos.y, aabb.max.z + pos.z, texU_r, texV_d); if (tile->getRenderShape() == SHAPE_CACTUS) - tile->updateShape(m_pLevelSource, pos); + tile->updateShape(m_pTileSource, pos); } void TileRenderer::renderSouth(Tile* tile, const Vec3& pos, int texture) @@ -270,8 +270,8 @@ void TileRenderer::renderSouth(Tile* tile, const Vec3& pos, int texture) static constexpr float C_RATIO = 1.0f / 256.0f; - if (m_textureOverride >= 0) - texture = m_textureOverride; + if (m_fixedTexture >= 0) + texture = m_fixedTexture; float texX = float(16 * (texture % 16)); float texY = float(16 * (texture / 16)); @@ -286,7 +286,7 @@ void TileRenderer::renderSouth(Tile* tile, const Vec3& pos, int texture) texU_r = C_RATIO * (texX + 15.99f); } // if flipping on the X coordinate - else if (field_8) + else if (m_bXFlipTexture) { texU_r = C_RATIO * (texX + aabb.min.x * 16); texU_l = C_RATIO * (texX + aabb.max.x * 16 - 0.01f); @@ -329,7 +329,7 @@ void TileRenderer::renderSouth(Tile* tile, const Vec3& pos, int texture) t.vertexUV(aabb.max.x + pos.x, aabb.max.y + pos.y, aabb.max.z + pos.z, texU_r, texV_u); if (tile->getRenderShape() == SHAPE_CACTUS) - tile->updateShape(m_pLevelSource, pos); + tile->updateShape(m_pTileSource, pos); } void TileRenderer::renderNorth(Tile* tile, const Vec3& pos, int texture) @@ -339,8 +339,8 @@ void TileRenderer::renderNorth(Tile* tile, const Vec3& pos, int texture) static constexpr float C_RATIO = 1.0f / 256.0f; - if (m_textureOverride >= 0) - texture = m_textureOverride; + if (m_fixedTexture >= 0) + texture = m_fixedTexture; float texX = float(16 * (texture % 16)); float texY = float(16 * (texture / 16)); @@ -355,7 +355,7 @@ void TileRenderer::renderNorth(Tile* tile, const Vec3& pos, int texture) texU_r = C_RATIO * (texX + 15.99f); } // if flipping on the X coordinate - else if (field_8) + else if (m_bXFlipTexture) { texU_r = C_RATIO * (texX + aabb.min.x * 16); texU_l = C_RATIO * (texX + aabb.max.x * 16 - 0.01f); @@ -398,7 +398,7 @@ void TileRenderer::renderNorth(Tile* tile, const Vec3& pos, int texture) t.vertexUV(aabb.min.x + pos.x, aabb.min.y + pos.y, aabb.min.z + pos.z, texU_r, texV_d); if (tile->getRenderShape() == SHAPE_CACTUS) - tile->updateShape(m_pLevelSource, pos); + tile->updateShape(m_pTileSource, pos); } void TileRenderer::renderFaceDown(Tile* tile, const Vec3& pos, int texture) @@ -408,8 +408,8 @@ void TileRenderer::renderFaceDown(Tile* tile, const Vec3& pos, int texture) static constexpr float C_RATIO = 1.0f / 256.0f; - if (m_textureOverride >= 0) - texture = m_textureOverride; + if (m_fixedTexture >= 0) + texture = m_fixedTexture; float texX = float(16 * (texture % 16)); float texY = float(16 * (texture / 16)); @@ -461,7 +461,7 @@ void TileRenderer::renderFaceDown(Tile* tile, const Vec3& pos, int texture) t.vertexUV(aabb.min.x + pos.x, aabb.max.y + pos.y, aabb.max.z + pos.z, texU_1, texV_2); if (tile->getRenderShape() == SHAPE_CACTUS) - tile->updateShape(m_pLevelSource, pos); + tile->updateShape(m_pTileSource, pos); } void TileRenderer::renderFaceUp(Tile* tile, const Vec3& pos, int texture) @@ -471,8 +471,8 @@ void TileRenderer::renderFaceUp(Tile* tile, const Vec3& pos, int texture) static constexpr float C_RATIO = 1.0f / 256.0f; - if (m_textureOverride >= 0) - texture = m_textureOverride; + if (m_fixedTexture >= 0) + texture = m_fixedTexture; float texX = float(16 * (texture % 16)); float texY = float(16 * (texture / 16)); @@ -524,16 +524,18 @@ void TileRenderer::renderFaceUp(Tile* tile, const Vec3& pos, int texture) t.vertexUV(aabb.max.x + pos.x, aabb.min.y + pos.y, aabb.max.z + pos.z, texU_2, texV_2); if (tile->getRenderShape() == SHAPE_CACTUS) - tile->updateShape(m_pLevelSource, pos); + tile->updateShape(m_pTileSource, pos); } -void TileRenderer::tesselateCrossTexture(Tile* tile, TileData data, const Vec3& pos) +void TileRenderer::tesselateCrossTexture(const FullTile& tile, const Vec3& pos, bool simple) { static constexpr float C_RATIO = 1.0f / 256.0f; - int texture = m_textureOverride; + const Tile& tileType = *tile.getType(); + + int texture = m_fixedTexture; if (texture < 0) - texture = tile->getTexture(Facing::DOWN, data); + texture = tileType.getTexture(Facing::DOWN, tile.data); float texX = float(16 * (texture % 16)); float texY = float(16 * (texture / 16)); @@ -545,7 +547,7 @@ void TileRenderer::tesselateCrossTexture(Tile* tile, TileData data, const Vec3& float cenX = pos.x + 0.5f, cenZ = pos.z + 0.5f; float newY = pos.y; - if (tile->getRenderShape() == SHAPE_RANDOM_CROSS) + if (tileType.getRenderShape() == SHAPE_RANDOM_CROSS) { int64_t var17 = int64_t(pos.x * 3129871) ^ (int64_t)pos.z * 116129781L ^ (int64_t)pos.y; var17 = var17 * var17 * 42317861L + var17 * 11L; @@ -564,11 +566,15 @@ void TileRenderer::tesselateCrossTexture(Tile* tile, TileData data, const Vec3& t.vertexUV(x2, newY + 0, z2, texU_r, texV_d); t.vertexUV(x2, newY + 1, z2, texU_r, texV_u); - // face 2 - t.vertexUV(x2, newY + 1, z2, texU_l, texV_u); - t.vertexUV(x2, newY + 0, z2, texU_l, texV_d); - t.vertexUV(x1, newY + 0, z1, texU_r, texV_d); - t.vertexUV(x1, newY + 1, z1, texU_r, texV_u); + // Check if we're culling the other faces + if (!simple) + { + // face 2 + t.vertexUV(x2, newY + 1, z2, texU_l, texV_u); + t.vertexUV(x2, newY + 0, z2, texU_l, texV_d); + t.vertexUV(x1, newY + 0, z1, texU_r, texV_d); + t.vertexUV(x1, newY + 1, z1, texU_r, texV_u); + } // face 3 t.vertexUV(x1, newY + 1, z2, texU_l, texV_u); @@ -576,11 +582,14 @@ void TileRenderer::tesselateCrossTexture(Tile* tile, TileData data, const Vec3& t.vertexUV(x2, newY + 0, z1, texU_r, texV_d); t.vertexUV(x2, newY + 1, z1, texU_r, texV_u); - // face 4 - t.vertexUV(x2, newY + 1, z1, texU_l, texV_u); - t.vertexUV(x2, newY + 0, z1, texU_l, texV_d); - t.vertexUV(x1, newY + 0, z2, texU_r, texV_d); - t.vertexUV(x1, newY + 1, z2, texU_r, texV_u); + if (!simple) + { + // face 4 + t.vertexUV(x2, newY + 1, z1, texU_l, texV_u); + t.vertexUV(x2, newY + 0, z1, texU_l, texV_d); + t.vertexUV(x1, newY + 0, z2, texU_r, texV_d); + t.vertexUV(x1, newY + 1, z2, texU_r, texV_u); + } } bool TileRenderer::tesselateBlockInWorld(Tile* tile, const TilePos& pos, float r, float g, float b) @@ -592,102 +601,102 @@ bool TileRenderer::tesselateBlockInWorld(Tile* tile, const TilePos& pos, float r Tesselator& t = Tesselator::instance; - float fLightHere = tile->getBrightness(m_pLevelSource, pos); + float fLightHere = tile->getBrightness(m_pTileSource, pos); bool bDrewAnything = false; - if (m_bDisableCulling || tile->shouldRenderFace(m_pLevelSource, pos.below(), Facing::DOWN)) + if (m_bNoCulling || tile->shouldRenderFace(m_pTileSource, pos.below(), Facing::DOWN)) { bDrewAnything = true; - float fLight = tile->getBrightness(m_pLevelSource, pos.below()); + float fLight = tile->getBrightness(m_pTileSource, pos.below()); t.color(r * 0.5f * fLight, g * 0.5f * fLight, b * 0.5f * fLight); - renderFaceUp(tile, pos, tile->getTexture(m_pLevelSource, pos, Facing::DOWN)); + renderFaceUp(tile, pos, tile->getTexture(m_pTileSource, pos, Facing::DOWN)); } - if (m_bDisableCulling || tile->shouldRenderFace(m_pLevelSource, pos.above(), Facing::UP)) + if (m_bNoCulling || tile->shouldRenderFace(m_pTileSource, pos.above(), Facing::UP)) { bDrewAnything = true; - float fLight = tile->getBrightness(m_pLevelSource, pos.above()); + float fLight = tile->getBrightness(m_pTileSource, pos.above()); if (tile->m_aabb.max.y != 1.0f && !tile->m_pMaterial->isLiquid()) fLight = fLightHere; t.color(topR * fLight, topG * fLight, topB * fLight); - renderFaceDown(tile, pos, tile->getTexture(m_pLevelSource, pos, Facing::UP)); + renderFaceDown(tile, pos, tile->getTexture(m_pTileSource, pos, Facing::UP)); } - if (m_bDisableCulling || tile->shouldRenderFace(m_pLevelSource, pos.north(), Facing::NORTH)) + if (m_bNoCulling || tile->shouldRenderFace(m_pTileSource, pos.north(), Facing::NORTH)) { bDrewAnything = true; - float fLight = tile->getBrightness(m_pLevelSource, pos.north()); + float fLight = tile->getBrightness(m_pTileSource, pos.north()); if (tile->m_aabb.min.z > 0.0f) fLight = fLightHere; t.color(r * 0.8f * fLight, g * 0.8f * fLight, b * 0.8f * fLight); - int texture = tile->getTexture(m_pLevelSource, pos, Facing::NORTH); + int texture = tile->getTexture(m_pTileSource, pos, Facing::NORTH); renderNorth(tile, pos, texture); - if (m_bFancyGrass && texture == TEXTURE_GRASS_SIDE && this->m_textureOverride < 0) + if (m_bFancyGrass && texture == TEXTURE_GRASS_SIDE && this->m_fixedTexture < 0) { t.color(topR * 0.8f * fLight, topG * 0.8f * fLight, topB * 0.8f * fLight); renderNorth(tile, pos, TEXTURE_NONE84); } } - if (m_bDisableCulling || tile->shouldRenderFace(m_pLevelSource, pos.south(), Facing::SOUTH)) + if (m_bNoCulling || tile->shouldRenderFace(m_pTileSource, pos.south(), Facing::SOUTH)) { bDrewAnything = true; - float fLight = tile->getBrightness(m_pLevelSource, pos.south()); + float fLight = tile->getBrightness(m_pTileSource, pos.south()); if (tile->m_aabb.max.z < 1.0f) fLight = fLightHere; t.color(r * 0.8f * fLight, g * 0.8f * fLight, b * 0.8f * fLight); - int texture = tile->getTexture(m_pLevelSource, pos, Facing::SOUTH); + int texture = tile->getTexture(m_pTileSource, pos, Facing::SOUTH); renderSouth(tile, pos, texture); - if (m_bFancyGrass && texture == TEXTURE_GRASS_SIDE && this->m_textureOverride < 0) + if (m_bFancyGrass && texture == TEXTURE_GRASS_SIDE && this->m_fixedTexture < 0) { t.color(topR * 0.8f * fLight, topG * 0.8f * fLight, topB * 0.8f * fLight); renderSouth(tile, pos, TEXTURE_NONE84); } } - if (m_bDisableCulling || tile->shouldRenderFace(m_pLevelSource, pos.west(), Facing::WEST)) + if (m_bNoCulling || tile->shouldRenderFace(m_pTileSource, pos.west(), Facing::WEST)) { bDrewAnything = true; - float fLight = tile->getBrightness(m_pLevelSource, pos.west()); + float fLight = tile->getBrightness(m_pTileSource, pos.west()); if (tile->m_aabb.min.x > 0.0f) fLight = fLightHere; t.color(r * 0.6f * fLight, g * 0.6f * fLight, b * 0.6f * fLight); - int texture = tile->getTexture(m_pLevelSource, pos, Facing::WEST); + int texture = tile->getTexture(m_pTileSource, pos, Facing::WEST); renderWest(tile, pos, texture); - if (m_bFancyGrass && texture == TEXTURE_GRASS_SIDE && this->m_textureOverride < 0) + if (m_bFancyGrass && texture == TEXTURE_GRASS_SIDE && this->m_fixedTexture < 0) { t.color(topR * 0.6f * fLight, topG * 0.6f * fLight, topB * 0.6f * fLight); renderWest(tile, pos, TEXTURE_NONE84); } } - if (m_bDisableCulling || tile->shouldRenderFace(m_pLevelSource, pos.east(), Facing::EAST)) + if (m_bNoCulling || tile->shouldRenderFace(m_pTileSource, pos.east(), Facing::EAST)) { bDrewAnything = true; - float fLight = tile->getBrightness(m_pLevelSource, pos.east()); + float fLight = tile->getBrightness(m_pTileSource, pos.east()); if (tile->m_aabb.max.x < 1.0f) fLight = fLightHere; t.color(r * 0.6f * fLight, g * 0.6f * fLight, b * 0.6f * fLight); - int texture = tile->getTexture(m_pLevelSource, pos, Facing::EAST); + int texture = tile->getTexture(m_pTileSource, pos, Facing::EAST); renderEast(tile, pos, texture); - if (m_bFancyGrass && texture == TEXTURE_GRASS_SIDE && this->m_textureOverride < 0) + if (m_bFancyGrass && texture == TEXTURE_GRASS_SIDE && this->m_fixedTexture < 0) { t.color(topR * 0.6f * fLight, topG * 0.6f * fLight, topB * 0.6f * fLight); renderEast(tile, pos, TEXTURE_NONE84); @@ -707,11 +716,14 @@ bool TileRenderer::tesselateBlockInWorld(Tile* tile, const TilePos& pos) if (useAmbientOcclusion()) { + if (Tile::lightEmission[tile->m_ID] == 0 /*&& Tile::translucency[tile->m_ID] < 0.9*/) + { #ifdef ENH_USE_OWN_AO - return tesselateBlockInWorldWithAmbienceOcclusionV2(tile, pos, r, g, b); + return tesselateBlockInWorldWithAmbienceOcclusionV2(tile, pos, r, g, b); #else - return tesselateBlockInWorldWithAmbienceOcclusion(tile, pos, r, g, b); + return tesselateBlockInWorldWithAmbienceOcclusion(tile, pos, r, g, b); #endif + } } return tesselateBlockInWorld(tile, pos, r, g, b); @@ -721,7 +733,7 @@ bool TileRenderer::tesselateCrossInWorld(Tile* tile, const TilePos& pos) { Tesselator& t = Tesselator::instance; - float bright = tile->getBrightness(m_pLevelSource, pos); + float bright = tile->getBrightness(m_pTileSource, pos); int color = getTileColor(tile, pos); float r = bright * (float(GET_RED(color)) / 255.0f); float g = bright * (float(GET_GREEN(color)) / 255.0f); @@ -729,7 +741,7 @@ bool TileRenderer::tesselateCrossInWorld(Tile* tile, const TilePos& pos) t.color(r, g, b); - tesselateCrossTexture(tile, m_pLevelSource->getData(pos), pos); + tesselateCrossTexture(FullTile(tile, m_pTileSource->getData(pos)), pos); return true; } @@ -743,13 +755,13 @@ bool TileRenderer::tesselateWaterInWorld(Tile* tile1, const TilePos& pos) Tesselator& t = Tesselator::instance; - bRenderFaceDown = tile->shouldRenderFace(m_pLevelSource, pos.above(), Facing::UP); - bRenderFaceUp = tile->shouldRenderFace(m_pLevelSource, pos.below(), Facing::DOWN); + bRenderFaceDown = tile->shouldRenderFace(m_pTileSource, pos.above(), Facing::UP); + bRenderFaceUp = tile->shouldRenderFace(m_pTileSource, pos.below(), Facing::DOWN); - bRenderSides[0] = tile->shouldRenderFace(m_pLevelSource, pos.north(), Facing::NORTH); - bRenderSides[1] = tile->shouldRenderFace(m_pLevelSource, pos.south(), Facing::SOUTH); - bRenderSides[2] = tile->shouldRenderFace(m_pLevelSource, pos.west(), Facing::WEST); - bRenderSides[3] = tile->shouldRenderFace(m_pLevelSource, pos.east(), Facing::EAST); + bRenderSides[0] = tile->shouldRenderFace(m_pTileSource, pos.north(), Facing::NORTH); + bRenderSides[1] = tile->shouldRenderFace(m_pTileSource, pos.south(), Facing::SOUTH); + bRenderSides[2] = tile->shouldRenderFace(m_pTileSource, pos.west(), Facing::WEST); + bRenderSides[3] = tile->shouldRenderFace(m_pTileSource, pos.east(), Facing::EAST); if (!bRenderFaceDown && !bRenderFaceUp && @@ -759,7 +771,7 @@ bool TileRenderer::tesselateWaterInWorld(Tile* tile1, const TilePos& pos) !bRenderSides[3]) return false; - int tileData = m_pLevelSource->getData(pos); + int tileData = m_pTileSource->getData(pos); float fHeight1 = getWaterHeight(pos, tile->m_pMaterial), fHeight2 = getWaterHeight(TilePos(pos.x, pos.y, pos.z + 1), tile->m_pMaterial), @@ -768,7 +780,7 @@ bool TileRenderer::tesselateWaterInWorld(Tile* tile1, const TilePos& pos) // @TODO: fix gotos bool bFlag1, bFlag2; - if (!m_bDisableCulling) + if (!m_bNoCulling) { bFlag1 = bRenderFaceDown; if (!bRenderFaceDown) @@ -784,7 +796,7 @@ bool TileRenderer::tesselateWaterInWorld(Tile* tile1, const TilePos& pos) // @NOTE: Have to use tile1 because for whatever reason MSVC doesn't think an overload // for `tile` exists that takes 2 int arguments int texFaceDown = tile->getTexture(Facing::UP, tileData); - float slopeAngle = tile->getSlopeAngle(m_pLevelSource, pos, tile->m_pMaterial); + float slopeAngle = tile->getSlopeAngle(m_pTileSource, pos, tile->m_pMaterial); int texX, texY; @@ -816,7 +828,7 @@ bool TileRenderer::tesselateWaterInWorld(Tile* tile1, const TilePos& pos) texUV_3 = C_RATIO * 8.0f * Mth::sin(slopeAngle); texUV_4 = C_RATIO * 8.0f * Mth::cos(slopeAngle); - float bright = tile->getBrightness(m_pLevelSource, pos); + float bright = tile->getBrightness(m_pTileSource, pos); texUV_5 = texUV_1 - texUV_4; texUV_6 = texUV_2 - texUV_4; @@ -831,7 +843,7 @@ bool TileRenderer::tesselateWaterInWorld(Tile* tile1, const TilePos& pos) t.vertexUV(pos.x + 1.0f, pos.y + fHeight4, pos.z + 0.0f, texUV_8 - texUV_3, texUV_6 - texUV_3); } - if (m_bDisableCulling) + if (m_bNoCulling) goto label_7; bFlag1 = true; @@ -839,7 +851,7 @@ bool TileRenderer::tesselateWaterInWorld(Tile* tile1, const TilePos& pos) { label_6: label_7: - float bright = tile->getBrightness(m_pLevelSource, pos.below()); + float bright = tile->getBrightness(m_pTileSource, pos.below()); t.color(bright * 0.5f, bright * 0.5f, bright * 0.5f); renderFaceUp(tile1, pos, tile->getTexture(Facing::DOWN)); bFlag1 = true; @@ -861,7 +873,7 @@ bool TileRenderer::tesselateWaterInWorld(Tile* tile1, const TilePos& pos) } int texture = tile1->getTexture((Facing::Name)(dir + Facing::NORTH), tileData); - if (!m_bDisableCulling && !bRenderSides[dir]) + if (!m_bNoCulling && !bRenderSides[dir]) continue; float vtxX1, vtxX2, vtxZ1, vtxZ2, height1, height2; @@ -922,7 +934,7 @@ bool TileRenderer::tesselateWaterInWorld(Tile* tile1, const TilePos& pos) bRenderedSides = true; float brightMul = dir >= Facing::WEST ? 0.6f : 0.8f; - float bright = tile->getBrightness(m_pLevelSource, TilePos(checkX, pos.y, checkZ)); + float bright = tile->getBrightness(m_pTileSource, TilePos(checkX, pos.y, checkZ)); t.color(bright* brightMul, bright* brightMul, bright* brightMul); t.vertexUV(vtxX1, float(pos.y) + height1, vtxZ1, texU_1, texV_1); t.vertexUV(vtxX2, float(pos.y) + height2, vtxZ2, texU_2, texV_2); @@ -946,7 +958,7 @@ bool TileRenderer::tesselateStairsInWorld(Tile* tile, const TilePos& pos) { bool bRenderedAnything = false; - switch (m_pLevelSource->getData(pos)) + switch (m_pTileSource->getData(pos)) { case 0: { @@ -995,10 +1007,10 @@ bool TileRenderer::tesselateFenceInWorld(Tile* tile, const TilePos& pos) bool bRenderedAnything = tesselateBlockInWorld(tile, pos); - bool tileWest = m_pLevelSource->getTile(pos.west()) == tile->m_ID; - bool tileEast = m_pLevelSource->getTile(pos.east()) == tile->m_ID; - bool tileNorth = m_pLevelSource->getTile(pos.north()) == tile->m_ID; - bool tileSouth = m_pLevelSource->getTile(pos.south()) == tile->m_ID; + bool tileWest = m_pTileSource->getTile(pos.west()) == tile->m_ID; + bool tileEast = m_pTileSource->getTile(pos.east()) == tile->m_ID; + bool tileNorth = m_pTileSource->getTile(pos.north()) == tile->m_ID; + bool tileSouth = m_pTileSource->getTile(pos.south()) == tile->m_ID; bool connectsHorizontally = tileWest || tileEast; bool connectsVertically = tileNorth || tileSouth; @@ -1052,56 +1064,56 @@ bool TileRenderer::tesselateFenceInWorld(Tile* tile, const TilePos& pos) bool TileRenderer::tesselateDoorInWorld(Tile* tile, const TilePos& pos) { Tesselator& t = Tesselator::instance; - float fBrightHere = tile->getBrightness(m_pLevelSource, pos), fBright; + float fBrightHere = tile->getBrightness(m_pTileSource, pos), fBright; int texture; - fBright = tile->getBrightness(m_pLevelSource, pos.below()); + fBright = tile->getBrightness(m_pTileSource, pos.below()); if (tile->m_aabb.min.y > 0.0f) fBright = fBrightHere; if (Tile::lightEmission[tile->m_ID]) fBright = 1.0f; t.color(fBright * 0.5f, fBright * 0.5f, fBright * 0.5f); - renderFaceUp(tile, pos, tile->getTexture(m_pLevelSource, pos, Facing::DOWN)); + renderFaceUp(tile, pos, tile->getTexture(m_pTileSource, pos, Facing::DOWN)); - fBright = tile->getBrightness(m_pLevelSource, pos.above()); + fBright = tile->getBrightness(m_pTileSource, pos.above()); if (tile->m_aabb.max.y < 1.0f) fBright = fBrightHere; if (Tile::lightEmission[tile->m_ID]) fBright = 1.0f; t.color(fBright, fBright, fBright); - renderFaceDown(tile, pos, tile->getTexture(m_pLevelSource, pos, Facing::UP)); + renderFaceDown(tile, pos, tile->getTexture(m_pTileSource, pos, Facing::UP)); - fBright = tile->getBrightness(m_pLevelSource, pos - 1); + fBright = tile->getBrightness(m_pTileSource, pos - 1); if (tile->m_aabb.min.z > 0.0f) fBright = fBrightHere; if (Tile::lightEmission[tile->m_ID]) fBright = 1.0f; t.color(fBright * 0.8f, fBright * 0.8f, fBright * 0.8f); - texture = tile->getTexture(m_pLevelSource, pos, Facing::NORTH); - if (texture < 0) texture = -texture, field_8 = true; + texture = tile->getTexture(m_pTileSource, pos, Facing::NORTH); + if (texture < 0) texture = -texture, m_bXFlipTexture = true; renderNorth(tile, pos, texture); - field_8 = false; + m_bXFlipTexture = false; - fBright = tile->getBrightness(m_pLevelSource, pos + 1); + fBright = tile->getBrightness(m_pTileSource, pos + 1); if (tile->m_aabb.max.z < 1.0f) fBright = fBrightHere; if (Tile::lightEmission[tile->m_ID]) fBright = 1.0f; t.color(fBright * 0.8f, fBright * 0.8f, fBright * 0.8f); - texture = tile->getTexture(m_pLevelSource, pos, Facing::SOUTH); - if (texture < 0) texture = -texture, field_8 = true; + texture = tile->getTexture(m_pTileSource, pos, Facing::SOUTH); + if (texture < 0) texture = -texture, m_bXFlipTexture = true; renderSouth(tile, pos, texture); - field_8 = false; + m_bXFlipTexture = false; - fBright = tile->getBrightness(m_pLevelSource,pos.west()); + fBright = tile->getBrightness(m_pTileSource,pos.west()); if (tile->m_aabb.min.x > 0.0f) fBright = fBrightHere; if (Tile::lightEmission[tile->m_ID]) fBright = 1.0f; t.color(fBright * 0.6f, fBright * 0.6f, fBright * 0.6f); - texture = tile->getTexture(m_pLevelSource, pos, Facing::WEST); - if (texture < 0) texture = -texture, field_8 = true; + texture = tile->getTexture(m_pTileSource, pos, Facing::WEST); + if (texture < 0) texture = -texture, m_bXFlipTexture = true; renderWest(tile, pos, texture); - field_8 = false; + m_bXFlipTexture = false; - fBright = tile->getBrightness(m_pLevelSource, pos.east()); + fBright = tile->getBrightness(m_pTileSource, pos.east()); if (tile->m_aabb.max.x < 1.0f) fBright = fBrightHere; if (Tile::lightEmission[tile->m_ID]) fBright = 1.0f; t.color(fBright * 0.6f, fBright * 0.6f, fBright * 0.6f); - texture = tile->getTexture(m_pLevelSource, pos, Facing::EAST); - if (texture < 0) texture = -texture, field_8 = true; + texture = tile->getTexture(m_pTileSource, pos, Facing::EAST); + if (texture < 0) texture = -texture, m_bXFlipTexture = true; renderEast(tile, pos, texture); - field_8 = false; + m_bXFlipTexture = false; return true; } @@ -1115,8 +1127,8 @@ void TileRenderer::tesselateTorch(Tile* tile, const Vec3& pos, float a, float b) int texture = tile->getTexture(Facing::DOWN); - if (m_textureOverride >= 0) - texture = m_textureOverride; + if (m_fixedTexture >= 0) + texture = m_fixedTexture; // @TODO: Clean up a bit more @@ -1199,8 +1211,8 @@ void TileRenderer::tesselateTorch(Tile* tile, const Vec3& pos, float a, float b) bool TileRenderer::tesselateTorchInWorld(Tile* tile, const TilePos& pos) { - TileData data = m_pLevelSource->getData(pos); - float bright = tile->getBrightness(m_pLevelSource, pos); + TileData data = m_pTileSource->getData(pos); + float bright = tile->getBrightness(m_pTileSource, pos); if (Tile::lightEmission[tile->m_ID] > 0) bright = 1.0f; @@ -1238,10 +1250,10 @@ bool TileRenderer::tesselateLadderInWorld(Tile* tile, const TilePos& pos) int texture = tile->getTexture(Facing::DOWN); - if (m_textureOverride >= 0) - texture = m_textureOverride; + if (m_fixedTexture >= 0) + texture = m_fixedTexture; - float bright = m_pLevelSource->getBrightness(pos); + float bright = m_pTileSource->getBrightness(pos); t.color(bright, bright, bright); float texX = float(16 * (texture % 16)); @@ -1252,7 +1264,7 @@ bool TileRenderer::tesselateLadderInWorld(Tile* tile, const TilePos& pos) float texV_1 = C_RATIO * texY; float texV_2 = C_RATIO * (texY + 15.99f); - switch (m_pLevelSource->getData(pos)) + switch (m_pTileSource->getData(pos)) { case 2: t.vertexUV(float(pos.x + 1), float(pos.y + 1), float(pos.z + 1) - 0.05f, texU_1, texV_1); @@ -1290,7 +1302,7 @@ bool TileRenderer::tesselateFireInWorld(Tile* tile, const TilePos& pos) Tesselator& t = Tesselator::instance; int texture = tile->getTexture(Facing::DOWN); - float bright = tile->getBrightness(m_pLevelSource, pos); + float bright = tile->getBrightness(m_pTileSource, pos); t.color(bright, bright, bright); @@ -1305,7 +1317,7 @@ bool TileRenderer::tesselateFireInWorld(Tile* tile, const TilePos& pos) float texV_2 = C_RATIO * (texY + 15.99f); float xf = float(pos.x), yf = float(pos.y), zf = float(pos.z); - if (m_pLevelSource->isSolidTile(pos.below()) || pFireTile->canBurn(m_pLevelSource, pos.below())) + if (m_pTileSource->isSolidTile(pos.below()) || pFireTile->canBurn(m_pTileSource, pos.below())) { t.vertexUV(xf + 0.5f - 0.3f, yf + 1.4f, zf + 1.0f, texU_2, texV_1); t.vertexUV(xf + 0.5f + 0.2f, yf + 0.0f, zf + 1.0f, texU_2, texV_2); @@ -1353,7 +1365,7 @@ bool TileRenderer::tesselateFireInWorld(Tile* tile, const TilePos& pos) if (((pos.y / 2 + pos.x / 2 + pos.z / 2) & 1) == 0) std::swap(texU_1, texU_2); - if (pFireTile->canBurn(m_pLevelSource, pos.west())) + if (pFireTile->canBurn(m_pTileSource, pos.west())) { t.vertexUV(xf + 0.2f, (yf + 1.4f) + 0.0625f, zf + 1.0f, texU_1, texV_1); t.vertexUV(xf + 0.0f, (yf + 0.0f) + 0.0625f, zf + 1.0f, texU_1, texV_2); @@ -1365,7 +1377,7 @@ bool TileRenderer::tesselateFireInWorld(Tile* tile, const TilePos& pos) t.vertexUV(xf + 0.2f, (yf + 1.4f) + 0.0625f, zf + 1.0f, texU_1, texV_1); } - if (pFireTile->canBurn(m_pLevelSource, pos.east())) + if (pFireTile->canBurn(m_pTileSource, pos.east())) { t.vertexUV(xf + 1.0f - 0.2f, (pos.y + 1.4f) + 0.0625f, pos.z + 0.0f, texU_2, texV_1); t.vertexUV(xf + 1.0f + 0.0f, (pos.y + 0.0f) + 0.0625f, pos.z + 0.0f, texU_2, texV_2); @@ -1377,7 +1389,7 @@ bool TileRenderer::tesselateFireInWorld(Tile* tile, const TilePos& pos) t.vertexUV(xf + 1.0f - 0.2f, (pos.y + 1.4f) + 0.0625f, pos.z + 0.0f, texU_2, texV_1); } - if (pFireTile->canBurn(m_pLevelSource, pos - 1)) + if (pFireTile->canBurn(m_pTileSource, pos - 1)) { t.vertexUV(pos.x + 0.0f, (pos.y + 1.4f) + 0.0625f, pos.z + 0.2f, texU_1, texV_1); t.vertexUV(pos.x + 0.0f, (pos.y + 0.0f) + 0.0625f, pos.z + 0.0f, texU_1, texV_2); @@ -1389,7 +1401,7 @@ bool TileRenderer::tesselateFireInWorld(Tile* tile, const TilePos& pos) t.vertexUV(pos.x + 0.0f, (pos.y + 1.4f) + 0.0625f, pos.z + 0.2f, texU_1, texV_1); } - if (pFireTile->canBurn(m_pLevelSource, pos + 1)) + if (pFireTile->canBurn(m_pTileSource, pos + 1)) { t.vertexUV(pos.x + 1.0f, (pos.y + 1.4f) + 0.0625f, pos.z + 1.0f - 0.2f, texU_2, texV_1); t.vertexUV(pos.x + 1.0f, (pos.y + 0.0f) + 0.0625f, pos.z + 1.0f + 0.0f, texU_2, texV_2); @@ -1401,7 +1413,7 @@ bool TileRenderer::tesselateFireInWorld(Tile* tile, const TilePos& pos) t.vertexUV(pos.x + 1.0f, (pos.y + 1.4f) + 0.0625f, pos.z + 1.0f - 0.2f, texU_2, texV_1); } - if (pFireTile->canBurn(m_pLevelSource, pos.above())) + if (pFireTile->canBurn(m_pTileSource, pos.above())) { // @NOTE: Converting z and x to uint8_t for whatever reason if (((uint8_t(pos.z) + uint8_t(pos.x) + pos.y + 1) & 1) != 0) @@ -1437,7 +1449,7 @@ bool TileRenderer::tesselateFireInWorld(Tile* tile, const TilePos& pos) bool TileRenderer::tesselateInWorld(Tile* tile, const TilePos& pos) { int shape = tile->getRenderShape(); - tile->updateShape(m_pLevelSource, pos); + tile->updateShape(m_pTileSource, pos); switch (shape) { @@ -1476,17 +1488,17 @@ bool TileRenderer::tesselateInWorld(Tile* tile, const TilePos& pos) bool TileRenderer::tesselateInWorldNoCulling(Tile* tile, const TilePos& pos) { - m_bDisableCulling = true; + m_bNoCulling = true; bool r = tesselateInWorld(tile, pos); - m_bDisableCulling = false; + m_bNoCulling = false; return r; } bool TileRenderer::tesselateInWorld(Tile* tile, const TilePos& pos, int a) { - m_textureOverride = a; + m_fixedTexture = a; bool r = tesselateInWorld(tile, pos); - m_textureOverride = -1; + m_fixedTexture = -1; return r; } @@ -1705,62 +1717,62 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti int v222; // [sp+2Ch] [bp-3Ch] this->m_bAmbientOcclusion = true; - v12 = a2->getBrightness(this->m_pLevelSource, pos); - v13 = this->m_pLevelSource; + v12 = a2->getBrightness(this->m_pTileSource, pos); + v13 = this->m_pTileSource; this->field_C = v12; v14 = a2->getBrightness(v13, pos.west()); v218 = pos.y - 1; - v15 = this->m_pLevelSource; + v15 = this->m_pTileSource; this->field_10 = v14; v16 = a2->getBrightness(v15, pos.below()); v217 = pos.z - 1; - v17 = this->m_pLevelSource; + v17 = this->m_pTileSource; this->field_14 = v16; v18 = a2->getBrightness(v17, pos.north()); v214 = pos.x + 1; - v19 = this->m_pLevelSource; + v19 = this->m_pTileSource; this->field_18 = v18; v20 = a2->getBrightness(v19, pos.east()); v216 = pos.y + 1; - v21 = this->m_pLevelSource; + v21 = this->m_pTileSource; this->field_1C = v20; v22 = a2->getBrightness(v21, pos.above()); v215 = pos.z + 1; - v23 = this->m_pLevelSource; + v23 = this->m_pTileSource; this->field_20 = v22; this->field_24 = a2->getBrightness(v23, pos.south()); - v24 = Tile::translucent[this->m_pLevelSource->getTile(pos.above().east())]; - v25 = this->m_pLevelSource; + v24 = Tile::translucent[this->m_pTileSource->getTile(pos.above().east())]; + v25 = this->m_pTileSource; this->field_AD = v24; v26 = Tile::translucent[v25->getTile(pos.below().east())]; - v27 = this->m_pLevelSource; + v27 = this->m_pTileSource; this->field_B5 = v26; v28 = Tile::translucent[v27->getTile(pos.south().east())]; - v29 = this->m_pLevelSource; + v29 = this->m_pTileSource; this->field_B1 = v28; v30 = Tile::translucent[v29->getTile(pos.north().east())]; - v31 = this->m_pLevelSource; + v31 = this->m_pTileSource; this->field_B3 = v30; v32 = Tile::translucent[v31->getTile(pos.above().west())]; - v33 = this->m_pLevelSource; + v33 = this->m_pTileSource; this->field_AE = v32; v34 = Tile::translucent[v33->getTile(pos.below().west())]; - v35 = this->m_pLevelSource; + v35 = this->m_pTileSource; this->field_B6 = v34; v36 = Tile::translucent[v35->getTile(TilePos(pos.west() - 1))]; - v37 = this->m_pLevelSource; + v37 = this->m_pTileSource; this->field_B0 = v36; v38 = Tile::translucent[v37->getTile(TilePos(pos.west() + 1))]; - v39 = this->m_pLevelSource; + v39 = this->m_pTileSource; this->field_B2 = v38; v40 = Tile::translucent[v39->getTile(pos.above().south())]; - v41 = this->m_pLevelSource; + v41 = this->m_pTileSource; this->field_AF = v40; v42 = Tile::translucent[v41->getTile(pos.above().north())]; - v43 = this->m_pLevelSource; + v43 = this->m_pTileSource; this->field_AC = v42; v44 = Tile::translucent[v43->getTile(pos.below().south())]; - v45 = this->m_pLevelSource; + v45 = this->m_pTileSource; this->field_B7 = v44; this->field_B4 = Tile::translucent[v45->getTile(pos.below().north())]; if (a2->m_TextureFrame == 3) @@ -1779,41 +1791,41 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti v221 = 1; v222 = 1; } - if (!this->m_bDisableCulling - && !a2->shouldRenderFace(this->m_pLevelSource, TilePos(pos.x, v218, pos.z), Facing::DOWN)) + if (!this->m_bNoCulling + && !a2->shouldRenderFace(this->m_pTileSource, TilePos(pos.x, v218, pos.z), Facing::DOWN)) { v69 = 0; goto LABEL_20; } if (this->field_78 > 0) { - v47 = a2->getBrightness(this->m_pLevelSource, TilePos(pos.x - 1, v218, pos.z)); - v48 = this->m_pLevelSource; + v47 = a2->getBrightness(this->m_pTileSource, TilePos(pos.x - 1, v218, pos.z)); + v48 = this->m_pTileSource; this->field_2C = v47; v49 = a2->getBrightness(v48, TilePos(pos.x, v218, v217)); - v50 = this->m_pLevelSource; + v50 = this->m_pTileSource; this->field_34 = v49; v51 = a2->getBrightness(v50, TilePos(pos.x, v218, v215)); - v52 = this->m_pLevelSource; + v52 = this->m_pTileSource; this->field_38 = v51; v53 = a2->getBrightness(v52, TilePos(v214, v218, pos.z)); v54 = this->field_B4; this->field_40 = v53; if (v54 || this->field_B6) - this->field_28 = a2->getBrightness(this->m_pLevelSource, TilePos(pos.x - 1, v218, v217)); + this->field_28 = a2->getBrightness(this->m_pTileSource, TilePos(pos.x - 1, v218, v217)); else this->field_28 = this->field_2C; if (this->field_B7 || this->field_B6) - this->field_30 = a2->getBrightness(this->m_pLevelSource, TilePos(pos.x - 1, v218, v215)); + this->field_30 = a2->getBrightness(this->m_pTileSource, TilePos(pos.x - 1, v218, v215)); else this->field_30 = this->field_2C; if (this->field_B4 || this->field_B5) - this->field_3C = a2->getBrightness(this->m_pLevelSource, TilePos(v214, v218, v217)); + this->field_3C = a2->getBrightness(this->m_pTileSource, TilePos(v214, v218, v217)); else this->field_3C = this->field_40; if (this->field_B7 || this->field_B5) { - v203 = a2->getBrightness(this->m_pLevelSource, TilePos(v214, v218, v215)); + v203 = a2->getBrightness(this->m_pTileSource, TilePos(v214, v218, v215)); v55 = this->field_40; v56 = v203; this->field_44 = v203; @@ -1867,7 +1879,7 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti this->m_vtxGreen[1] = g * 0.5f; this->m_vtxGreen[0] = g * 0.5f; LABEL_19: - v68 = this->m_pLevelSource; + v68 = this->m_pTileSource; v69 = 1; this->m_vtxRed[0] = v60 * v65; this->m_vtxGreen[0] = v60 * v66; @@ -1884,7 +1896,7 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti v70 = a2->getTexture(v68, pos, Facing::DOWN); renderFaceUp(a2, pos, v70); LABEL_20: - if (this->m_bDisableCulling || a2->shouldRenderFace(this->m_pLevelSource, TilePos(pos.x, v216, pos.z), Facing::UP)) + if (this->m_bNoCulling || a2->shouldRenderFace(this->m_pTileSource, TilePos(pos.x, v216, pos.z), Facing::UP)) { if (this->field_78 <= 0) { @@ -1894,21 +1906,21 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti v85 = v87; goto LABEL_36; } - v71 = a2->getBrightness(this->m_pLevelSource, TilePos(pos.x - 1, v216, pos.z)); - v72 = this->m_pLevelSource; + v71 = a2->getBrightness(this->m_pTileSource, TilePos(pos.x - 1, v216, pos.z)); + v72 = this->m_pTileSource; this->field_4C = v71; v73 = a2->getBrightness(v72, TilePos(v214, v216, pos.z)); - v74 = this->m_pLevelSource; + v74 = this->m_pTileSource; this->field_5C = v73; v75 = a2->getBrightness(v74, TilePos(pos.x, v216, v217)); - v76 = this->m_pLevelSource; + v76 = this->m_pTileSource; this->field_54 = v75; v77 = a2->getBrightness(v76, TilePos(pos.x, v216, v215)); v78 = this->field_AC; this->field_60 = v77; if (v78 || this->field_AE) { - v197 = a2->getBrightness(this->m_pLevelSource, TilePos(pos.x - 1, v216, v217)); + v197 = a2->getBrightness(this->m_pTileSource, TilePos(pos.x - 1, v216, v217)); v198 = this->field_AC; this->field_48 = v197; if (v198) @@ -1924,7 +1936,7 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti LABEL_27: if (this->field_AF || this->field_AE) { - v211 = a2->getBrightness(this->m_pLevelSource, TilePos(pos.x - 1, v216, v215)); + v211 = a2->getBrightness(this->m_pTileSource, TilePos(pos.x - 1, v216, v215)); v212 = this->field_AF; this->field_50 = v211; if (v212) @@ -1950,7 +1962,7 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti v88 = (float)((float)(v79 + (float)(v82 + v86)) + this->field_58) * 0.25f; v89 = (float)(v86 + (float)(v82 + (float)(v81 + this->field_48))) * 0.25f; LABEL_36: - v90 = this->m_pLevelSource; + v90 = this->m_pTileSource; v69 = 1; this->m_vtxRed[0] = v85 * r; this->m_vtxGreen[0] = v85 * g; @@ -1969,20 +1981,20 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti goto LABEL_37; } LABEL_141: - v213 = a2->getBrightness(this->m_pLevelSource, TilePos(v214, v216, v215)); + v213 = a2->getBrightness(this->m_pTileSource, TilePos(v214, v216, v215)); v79 = this->field_5C; v80 = v213; this->field_64 = v213; goto LABEL_32; } LABEL_125: - this->field_58 = a2->getBrightness(this->m_pLevelSource, TilePos(v214, v216, v217)); + this->field_58 = a2->getBrightness(this->m_pTileSource, TilePos(v214, v216, v217)); goto LABEL_27; } LABEL_37: - if (!this->m_bDisableCulling && !a2->shouldRenderFace(this->m_pLevelSource, TilePos(pos.x, pos.y, v217), Facing::NORTH)) + if (!this->m_bNoCulling && !a2->shouldRenderFace(this->m_pTileSource, TilePos(pos.x, pos.y, v217), Facing::NORTH)) { - if (this->m_bDisableCulling) + if (this->m_bNoCulling) goto LABEL_54; goto LABEL_107; } @@ -1996,21 +2008,21 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti goto LABEL_50; goto LABEL_52; } - v92 = a2->getBrightness(this->m_pLevelSource, TilePos(pos.x - 1, pos.y, v217)); - v93 = this->m_pLevelSource; + v92 = a2->getBrightness(this->m_pTileSource, TilePos(pos.x - 1, pos.y, v217)); + v93 = this->m_pTileSource; this->field_68 = v92; v94 = a2->getBrightness(v93, TilePos(pos.x, v218, v217)); - v95 = this->m_pLevelSource; + v95 = this->m_pTileSource; this->field_34 = v94; v96 = a2->getBrightness(v95, TilePos(pos.x, v216, v217)); - v97 = this->m_pLevelSource; + v97 = this->m_pTileSource; this->field_54 = v96; v98 = a2->getBrightness(v97, TilePos(v214, pos.y, v217)); v99 = this->field_B0; this->field_6C = v98; if (v99 || this->field_B4) { - v201 = a2->getBrightness(this->m_pLevelSource, TilePos(pos.x - 1, v218, v217)); + v201 = a2->getBrightness(this->m_pTileSource, TilePos(pos.x - 1, v218, v217)); v202 = this->field_B0; this->field_28 = v201; if (v202) @@ -2023,14 +2035,14 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti if (this->field_AC) { LABEL_131: - this->field_48 = a2->getBrightness(this->m_pLevelSource, TilePos(pos.x - 1, v216, v217)); + this->field_48 = a2->getBrightness(this->m_pTileSource, TilePos(pos.x - 1, v216, v217)); goto LABEL_44; } this->field_48 = this->field_68; LABEL_44: if (this->field_B3 || this->field_B4) { - v204 = a2->getBrightness(this->m_pLevelSource, TilePos(v214, v218, v217)); + v204 = a2->getBrightness(this->m_pTileSource, TilePos(v214, v218, v217)); v205 = this->field_B3; this->field_3C = v204; if (v205) @@ -2048,7 +2060,7 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti goto LABEL_49; } LABEL_136: - v206 = a2->getBrightness(this->m_pLevelSource, TilePos(v214, v216, v217)); + v206 = a2->getBrightness(this->m_pTileSource, TilePos(v214, v216, v217)); v100 = this->field_6C; v101 = v206; this->field_58 = v206; @@ -2092,7 +2104,7 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti this->m_vtxGreen[1] = g * 0.8f; this->m_vtxGreen[0] = g * 0.8f; LABEL_53: - v115 = this->m_pLevelSource; + v115 = this->m_pTileSource; v69 = 1; this->m_vtxRed[0] = v108 * v113; this->m_vtxGreen[0] = v108 * v112; @@ -2108,12 +2120,12 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti this->m_vtxBlue[3] = v111 * v114; v116 = a2->getTexture(v115, pos, Facing::NORTH); renderNorth(a2, pos, v116); - if (this->m_bDisableCulling) + if (this->m_bNoCulling) goto LABEL_54; LABEL_107: - if (!a2->shouldRenderFace(this->m_pLevelSource, TilePos(pos.x, pos.y, v215), Facing::SOUTH)) + if (!a2->shouldRenderFace(this->m_pTileSource, TilePos(pos.x, pos.y, v215), Facing::SOUTH)) { - if (this->m_bDisableCulling) + if (this->m_bNoCulling) goto LABEL_70; goto LABEL_109; } @@ -2128,21 +2140,21 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti goto LABEL_66; goto LABEL_68; } - v117 = a2->getBrightness(this->m_pLevelSource, TilePos(pos.x - 1, pos.y, v215)); - v118 = this->m_pLevelSource; + v117 = a2->getBrightness(this->m_pTileSource, TilePos(pos.x - 1, pos.y, v215)); + v118 = this->m_pTileSource; this->field_70 = v117; v119 = a2->getBrightness(v118, TilePos(v214, pos.y, v215)); - v120 = this->m_pLevelSource; + v120 = this->m_pTileSource; this->field_74 = v119; v121 = a2->getBrightness(v120, TilePos(pos.x, v218, v215)); - v122 = this->m_pLevelSource; + v122 = this->m_pTileSource; this->field_38 = v121; v123 = a2->getBrightness(v122, TilePos(pos.x, v216, v215)); v124 = this->field_B2; this->field_60 = v123; if (v124 || this->field_B7) { - v199 = a2->getBrightness(this->m_pLevelSource, TilePos(pos.x - 1, v218, v215)); + v199 = a2->getBrightness(this->m_pTileSource, TilePos(pos.x - 1, v218, v215)); v200 = this->field_B2; this->field_30 = v199; if (v200) @@ -2155,14 +2167,14 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti if (this->field_AF) { LABEL_129: - this->field_50 = a2->getBrightness(this->m_pLevelSource, TilePos(pos.x - 1, v216, v215)); + this->field_50 = a2->getBrightness(this->m_pTileSource, TilePos(pos.x - 1, v216, v215)); goto LABEL_60; } this->field_50 = this->field_70; LABEL_60: if (this->field_B1 || this->field_B7) { - v208 = a2->getBrightness(this->m_pLevelSource, TilePos(v214, v218, v215)); + v208 = a2->getBrightness(this->m_pTileSource, TilePos(v214, v218, v215)); v209 = this->field_B1; this->field_44 = v208; if (v209) @@ -2180,7 +2192,7 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti goto LABEL_65; } LABEL_139: - v210 = a2->getBrightness(this->m_pLevelSource, TilePos(v214, v216, v215)); + v210 = a2->getBrightness(this->m_pTileSource, TilePos(v214, v216, v215)); v125 = this->field_74; v126 = v210; this->field_64 = v210; @@ -2222,7 +2234,7 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti this->m_vtxGreen[1] = g * 0.8f; this->m_vtxGreen[0] = g * 0.8f; LABEL_69: - v138 = this->m_pLevelSource; + v138 = this->m_pTileSource; v69 = 1; this->m_vtxRed[0] = v130 * v136; this->m_vtxGreen[0] = v130 * v135; @@ -2238,12 +2250,12 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti this->m_vtxBlue[3] = v132 * v137; v139 = a2->getTexture(v138, pos, Facing::SOUTH); renderSouth(a2, pos, v139); - if (this->m_bDisableCulling) + if (this->m_bNoCulling) goto LABEL_70; LABEL_109: - if (!a2->shouldRenderFace(this->m_pLevelSource, pos.west(), Facing::WEST)) + if (!a2->shouldRenderFace(this->m_pTileSource, pos.west(), Facing::WEST)) { - if (this->m_bDisableCulling) + if (this->m_bNoCulling) goto LABEL_88; goto LABEL_111; } @@ -2273,33 +2285,33 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti } else { - v140 = a2->getBrightness(this->m_pLevelSource, TilePos(pos.x - 1, v218, pos.z)); - v141 = this->m_pLevelSource; + v140 = a2->getBrightness(this->m_pTileSource, TilePos(pos.x - 1, v218, pos.z)); + v141 = this->m_pTileSource; this->field_2C = v140; v142 = a2->getBrightness(v141, TilePos(pos.x - 1, pos.y, v217)); - v143 = this->m_pLevelSource; + v143 = this->m_pTileSource; this->field_68 = v142; v144 = a2->getBrightness(v143, TilePos(pos.x - 1, pos.y, v215)); - v145 = this->m_pLevelSource; + v145 = this->m_pTileSource; this->field_70 = v144; v146 = a2->getBrightness(v145, TilePos(pos.x - 1, v216, pos.z)); v147 = this->field_B0; this->field_4C = v146; if (v147 || this->field_B6) - this->field_28 = a2->getBrightness(this->m_pLevelSource, TilePos(pos.x - 1, v218, v217)); + this->field_28 = a2->getBrightness(this->m_pTileSource, TilePos(pos.x - 1, v218, v217)); else this->field_28 = this->field_68; if (this->field_B2 || this->field_B6) - this->field_30 = a2->getBrightness(this->m_pLevelSource, TilePos(pos.x - 1, v218, v215)); + this->field_30 = a2->getBrightness(this->m_pTileSource, TilePos(pos.x - 1, v218, v215)); else this->field_30 = this->field_70; if (this->field_B0 || this->field_AE) - this->field_48 = a2->getBrightness(this->m_pLevelSource, TilePos(pos.x - 1, v216, v217)); + this->field_48 = a2->getBrightness(this->m_pTileSource, TilePos(pos.x - 1, v216, v217)); else this->field_48 = this->field_68; if (this->field_B2 || this->field_AE) { - v207 = a2->getBrightness(this->m_pLevelSource, TilePos(pos.x - 1, v216, v215)); + v207 = a2->getBrightness(this->m_pTileSource, TilePos(pos.x - 1, v216, v215)); v148 = this->field_70; v149 = v207; this->field_50 = v207; @@ -2335,7 +2347,7 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti this->m_vtxGreen[1] = g * 0.6f; this->m_vtxGreen[0] = g * 0.6f; LABEL_87: - v163 = this->m_pLevelSource; + v163 = this->m_pTileSource; v69 = 1; this->m_vtxRed[0] = v161 * v157; this->m_vtxGreen[0] = v160 * v157; @@ -2351,10 +2363,10 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti this->m_vtxBlue[3] = v162 * v156; v164 = a2->getTexture(v163, pos, Facing::WEST); renderWest(a2, pos, v164); - if (this->m_bDisableCulling) + if (this->m_bNoCulling) goto LABEL_88; LABEL_111: - if (!a2->shouldRenderFace(this->m_pLevelSource, TilePos(v214, pos.y, pos.z), Facing::EAST)) + if (!a2->shouldRenderFace(this->m_pTileSource, TilePos(v214, pos.y, pos.z), Facing::EAST)) goto LABEL_102; LABEL_88: if (this->field_78 <= 0) @@ -2379,21 +2391,21 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti v191 = 0.6f; goto LABEL_101; } - v165 = a2->getBrightness(this->m_pLevelSource, TilePos(v214, v218, pos.z)); - v166 = this->m_pLevelSource; + v165 = a2->getBrightness(this->m_pTileSource, TilePos(v214, v218, pos.z)); + v166 = this->m_pTileSource; this->field_40 = v165; v167 = a2->getBrightness(v166, TilePos(v214, pos.y, v217)); - v168 = this->m_pLevelSource; + v168 = this->m_pTileSource; this->field_6C = v167; v169 = a2->getBrightness(v168, TilePos(v214, pos.y, v215)); - v170 = this->m_pLevelSource; + v170 = this->m_pTileSource; this->field_74 = v169; v171 = a2->getBrightness(v170, TilePos(v214, v216, pos.z)); v172 = this->field_B5; this->field_5C = v171; if (v172 || this->field_B3) { - v173 = a2->getBrightness(this->m_pLevelSource, TilePos(v214, v218, v217)); + v173 = a2->getBrightness(this->m_pTileSource, TilePos(v214, v218, v217)); v174 = this->field_B5; this->field_3C = v173; if (v174 || this->field_B1) @@ -2407,11 +2419,11 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti if (!v196) goto LABEL_121; LABEL_93: - this->field_44 = a2->getBrightness(this->m_pLevelSource, TilePos(v214, v218, v215)); + this->field_44 = a2->getBrightness(this->m_pTileSource, TilePos(v214, v218, v215)); LABEL_94: if (this->field_AD || this->field_B3) { - v175 = a2->getBrightness(this->m_pLevelSource, TilePos(v214, v216, v217)); + v175 = a2->getBrightness(this->m_pTileSource, TilePos(v214, v216, v217)); v176 = this->field_AD; this->field_58 = v175; if (v176 || this->field_B1) @@ -2424,7 +2436,7 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti if (v195) { LABEL_98: - v177 = a2->getBrightness(this->m_pLevelSource, TilePos(v214, v216, v215)); + v177 = a2->getBrightness(this->m_pTileSource, TilePos(v214, v216, v215)); v178 = this->field_74; v179 = v177; this->field_64 = v177; @@ -2459,7 +2471,7 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti this->m_vtxGreen[1] = g * 0.6f; this->m_vtxGreen[0] = g * 0.6f; LABEL_101: - v192 = this->m_pLevelSource; + v192 = this->m_pTileSource; v69 = 1; this->m_vtxRed[0] = v189 * v182; this->m_vtxGreen[0] = v190 * v182; @@ -2495,9 +2507,9 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti #define SHADE_PREPARE do { \ red = bright, grn = bright, blu = bright; \ if (GetPatchManager()->IsGrassTinted()) { \ - if (tile->m_ID == Tile::leaves->m_ID) \ + if (tileType->m_ID == Tile::leaves->m_ID) \ red *= 0.35f, grn *= 0.65f, blu *= 0.25f; \ - if (tile->m_ID == Tile::grass->m_ID) \ + if (tileType->m_ID == Tile::grass->m_ID) \ red *= 0.25f, grn *= 0.60f, blu *= 0.25f; \ } \ } while (0) @@ -2505,7 +2517,7 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti #define SHADE_IF_NEEDED(col) if (preshade) t.color(col*red,col*grn,col*blu,1.0f); else t.color(red,grn,blu,1.0f) #define SHADE_FIXUP_GRASS do { \ - if (tile->m_ID == Tile::grass->m_ID) \ + if (tileType->m_ID == Tile::grass->m_ID) \ red = bright, grn = bright, blu = bright; \ } while (0) @@ -2519,9 +2531,10 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusion(Tile* a2, const Ti #endif -void TileRenderer::renderTile(Tile* tile, TileData data, float bright, bool preshade) +void TileRenderer::renderTile(const FullTile& tile, const mce::MaterialPtr& material, float bright, bool preshade) { Tesselator& t = Tesselator::instance; + Tile* tileType = tile.getType(); #ifndef ENH_SHADE_HELD_TILES bright = 1.0f; // 255 @@ -2530,7 +2543,7 @@ void TileRenderer::renderTile(Tile* tile, TileData data, float bright, bool pres preshade = true; #endif - int shape = tile->getRenderShape(); + int shape = tileType->getRenderShape(); switch (shape) { case SHAPE_SOLID: @@ -2538,45 +2551,45 @@ void TileRenderer::renderTile(Tile* tile, TileData data, float bright, bool pres { // N.B. If caller passes 255, they only want the face-down face. // This is a hack to accomodate the start menu screen procedurally generated title logo. -#define IF_NEEDED(x) do { if (data != 255) { (x); } } while (0) +#define IF_NEEDED(x) do { if (tile.data != 255) { (x); } } while (0) - glTranslatef(-0.5f, -0.5f, -0.5f); - t.begin(); + t.addOffset(-0.5f, -0.5f, -0.5f); + t.begin(0); SHADE_DEFINE; SHADE_PREPARE; SHADE_IF_NEEDED(1.0f); // Despite how it looks, Facing::UP is necessary for this to function correctly // Why? no idea t.normal(0.0f, 1.0f, 0.0f); - renderFaceDown(tile, Vec3::ZERO, tile->getTexture(Facing::UP, data)); + renderFaceDown(tileType, Vec3::ZERO, tileType->getTexture(Facing::UP, tile.data)); SHADE_FIXUP_GRASS; SHADE_IF_NEEDED(0.5f); // Despite how it looks, Facing::DOWN is necessary for this to function correctly // Why? no idea t.normal(0.0f, -1.0f, 0.0f); - IF_NEEDED(renderFaceUp(tile, Vec3::ZERO, tile->getTexture(Facing::DOWN, data))); + IF_NEEDED(renderFaceUp(tileType, Vec3::ZERO, tileType->getTexture(Facing::DOWN, tile.data))); SHADE_IF_NEEDED(0.8f); t.normal(0.0f, 0.0f, -1.0f); - IF_NEEDED(renderNorth(tile, Vec3::ZERO, tile->getTexture(Facing::NORTH, data))); + IF_NEEDED(renderNorth(tileType, Vec3::ZERO, tileType->getTexture(Facing::NORTH, tile.data))); t.normal(0.0f, 0.0f, 1.0f); - IF_NEEDED(renderSouth(tile, Vec3::ZERO, tile->getTexture(Facing::SOUTH, data))); + IF_NEEDED(renderSouth(tileType, Vec3::ZERO, tileType->getTexture(Facing::SOUTH, tile.data))); SHADE_IF_NEEDED(0.6f); t.normal(-1.0f, 0.0f, 0.0f); - IF_NEEDED(renderWest (tile, Vec3::ZERO, tile->getTexture(Facing::WEST, data))); + IF_NEEDED(renderWest (tileType, Vec3::ZERO, tileType->getTexture(Facing::WEST, tile.data))); t.normal(1.0f, 0.0f, 0.0f); - IF_NEEDED(renderEast (tile, Vec3::ZERO, tile->getTexture(Facing::EAST, data))); + IF_NEEDED(renderEast (tileType, Vec3::ZERO, tileType->getTexture(Facing::EAST, tile.data))); SHADE_IF_NEEDED(1.0f); - t.draw(); - glTranslatef(0.5f, 0.5f, 0.5f); + t.draw(material); + t.addOffset(0.5f, 0.5f, 0.5f); break; } case SHAPE_CROSS: { // unused as cross items render like regular items in the hand - t.begin(); - t.normal(0.0f, -1.0f, 0.0f); - tesselateCrossTexture(tile, data, Vec3(-0.5f, -0.5f, -0.5f)); - t.draw(); + t.begin(16); + t.normal(Vec3::NEG_UNIT_Y); + tesselateCrossTexture(tile, Vec3(-0.5f, -0.5f, -0.5f), true); + t.draw(material); break; } case SHAPE_STAIRS: @@ -2586,32 +2599,32 @@ void TileRenderer::renderTile(Tile* tile, TileData data, float bright, bool pres for (int i = 0; i < 2; i++) { if (!i) - tile->setShape(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.5f); + tileType->setShape(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.5f); else - tile->setShape(0.0f, 0.0f, 0.5f, 1.0f, 0.5f, 1.0f); + tileType->setShape(0.0f, 0.0f, 0.5f, 1.0f, 0.5f, 1.0f); - t.begin(); + t.begin(24); SHADE_DEFINE; SHADE_PREPARE; SHADE_IF_NEEDED(0.5f); t.normal(0.0f, -1.0f, 0.0f); - renderFaceUp (tile, Vec3::ZERO, tile->getTexture(Facing::DOWN, data)); + renderFaceUp (tileType, Vec3::ZERO, tileType->getTexture(Facing::DOWN, tile.data)); SHADE_IF_NEEDED(1.0f); t.normal(0.0f, 1.0f, 0.0f); - renderFaceDown(tile, Vec3::ZERO, tile->getTexture(Facing::UP, data)); + renderFaceDown(tileType, Vec3::ZERO, tileType->getTexture(Facing::UP, tile.data)); SHADE_IF_NEEDED(0.6f); t.normal(0.0f, 0.0f, -1.0f); - renderNorth (tile, Vec3::ZERO, tile->getTexture(Facing::NORTH, data)); + renderNorth (tileType, Vec3::ZERO, tileType->getTexture(Facing::NORTH, tile.data)); t.normal(0.0f, 0.0f, 1.0f); - renderSouth (tile, Vec3::ZERO, tile->getTexture(Facing::SOUTH, data)); + renderSouth (tileType, Vec3::ZERO, tileType->getTexture(Facing::SOUTH, tile.data)); SHADE_IF_NEEDED(0.8f); t.normal(-1.0f, 0.0f, 0.0f); - renderWest (tile, Vec3::ZERO, tile->getTexture(Facing::WEST, data)); + renderWest (tileType, Vec3::ZERO, tileType->getTexture(Facing::WEST, tile.data)); t.normal(1.0f, 0.0f, 0.0f); - renderEast (tile, Vec3::ZERO, tile->getTexture(Facing::EAST, data)); + renderEast (tileType, Vec3::ZERO, tileType->getTexture(Facing::EAST, tile.data)); SHADE_IF_NEEDED(1.0f); - t.draw(); + t.draw(material); } t.addOffset(0.5f, 0.5f, 0.5f); break; @@ -2624,36 +2637,36 @@ void TileRenderer::renderTile(Tile* tile, TileData data, float bright, bool pres for (int i = 0; i < 4; i++) { switch (i) { - case 0: tile->setShape(0.5f - v6, 0.0f, 0.0f, 0.5f + v6, 1.0f, v6 * 2.0f); break; - case 1: tile->setShape(0.5f - v6, 0.0f, 1.0f - (v6 * 2.0f), 0.5f + v6, 1.0f, 1.0f); break; - case 2: tile->setShape(0.5f - v5, 1.0f - v5 * 3.0f, -v5 * 2.0f, 0.5f + v5, 1.0f - v5, 1.0f + v5 * 2.0f); break; - case 3: tile->setShape(0.5f - v5, 0.5f - v5 * 3.0f, -v5 * 2.0f, 0.5f + v5, 0.5f - v5, 1.0f + v5 * 2.0f); break; + case 0: tileType->setShape(0.5f - v6, 0.0f, 0.0f, 0.5f + v6, 1.0f, v6 * 2.0f); break; + case 1: tileType->setShape(0.5f - v6, 0.0f, 1.0f - (v6 * 2.0f), 0.5f + v6, 1.0f, 1.0f); break; + case 2: tileType->setShape(0.5f - v5, 1.0f - v5 * 3.0f, -v5 * 2.0f, 0.5f + v5, 1.0f - v5, 1.0f + v5 * 2.0f); break; + case 3: tileType->setShape(0.5f - v5, 0.5f - v5 * 3.0f, -v5 * 2.0f, 0.5f + v5, 0.5f - v5, 1.0f + v5 * 2.0f); break; } - t.begin(); + t.begin(24); SHADE_DEFINE; SHADE_PREPARE; SHADE_IF_NEEDED(1.0f); t.normal(0.0f, 1.0f, 0.0f); - renderFaceDown(tile, Vec3::ZERO, tile->getTexture(Facing::UP, data)); + renderFaceDown(tileType, Vec3::ZERO, tileType->getTexture(Facing::UP, tile.data)); SHADE_IF_NEEDED(0.5f); t.normal(0.0f, -1.0f, 0.0f); - renderFaceUp(tile, Vec3::ZERO, tile->getTexture(Facing::DOWN, data)); + renderFaceUp(tileType, Vec3::ZERO, tileType->getTexture(Facing::DOWN, tile.data)); SHADE_IF_NEEDED(0.8f); t.normal(0.0f, 0.0f, -1.0f); - renderNorth(tile, Vec3::ZERO, tile->getTexture(Facing::NORTH, data)); + renderNorth(tileType, Vec3::ZERO, tileType->getTexture(Facing::NORTH, tile.data)); t.normal(0.0f, 0.0f, 1.0f); - renderSouth(tile, Vec3::ZERO, tile->getTexture(Facing::SOUTH, data)); + renderSouth(tileType, Vec3::ZERO, tileType->getTexture(Facing::SOUTH, tile.data)); SHADE_IF_NEEDED(0.6f); t.normal(-1.0f, 0.0f, 0.0f); - renderWest(tile, Vec3::ZERO, tile->getTexture(Facing::WEST, data)); + renderWest(tileType, Vec3::ZERO, tileType->getTexture(Facing::WEST, tile.data)); t.normal(1.0f, 0.0f, 0.0f); - renderEast(tile, Vec3::ZERO, tile->getTexture(Facing::EAST, data)); + renderEast(tileType, Vec3::ZERO, tileType->getTexture(Facing::EAST, tile.data)); SHADE_IF_NEEDED(1.0f); - t.draw(); + t.draw(material); } t.addOffset(0.5f, 0.5f, 0.5f); - tile->setShape(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); + tileType->setShape(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); break; } } @@ -2739,7 +2752,7 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusionV2(Tile* tile, cons pos.y + diffY[dir], pos.z + diffZ[dir]); - if (!m_bDisableCulling && !tile->shouldRenderFace(m_pLevelSource, tp, (Facing::Name)dir)) + if (!m_bNoCulling && !tile->shouldRenderFace(m_pTileSource, tp, (Facing::Name)dir)) continue; bBother = true; @@ -2756,16 +2769,16 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusionV2(Tile* tile, cons //Tesselator& t = Tesselator::instance; - //float fLightHere = tile->getBrightness(m_pLevelSource, pos); + //float fLightHere = tile->getBrightness(m_pTileSource, pos); float lights[ETILE_FACE_COUNT]; // Get the brightness of the tile we're processing, as well as all tiles around it - lights[ETILE_FACE_HERE] = tile->getBrightness(m_pLevelSource, pos); + lights[ETILE_FACE_HERE] = tile->getBrightness(m_pTileSource, pos); for (int i = 1; i < ETILE_FACE_COUNT; i++) { - lights[i] = tile->getBrightness(m_pLevelSource, TilePos(pos.x + diffEX[i], pos.y + diffEY[i], pos.z + diffEZ[i])); + lights[i] = tile->getBrightness(m_pTileSource, TilePos(pos.x + diffEX[i], pos.y + diffEY[i], pos.z + diffEZ[i])); } // Render all the faces. @@ -2776,7 +2789,7 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusionV2(Tile* tile, cons pos.z + diffZ[dir]); // check if we should bother in the first place - if (!m_bDisableCulling && !tile->shouldRenderFace(m_pLevelSource, tp, (Facing::Name)dir)) + if (!m_bNoCulling && !tile->shouldRenderFace(m_pTileSource, tp, (Facing::Name)dir)) { continue; } @@ -2817,26 +2830,26 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusionV2(Tile* tile, cons switch (dir) { case Facing::DOWN: - renderFaceUp (tile, pos, tile->getTexture(m_pLevelSource, pos, Facing::DOWN)); + renderFaceUp (tile, pos, tile->getTexture(m_pTileSource, pos, Facing::DOWN)); break; case Facing::UP: - renderFaceDown(tile, pos, tile->getTexture(m_pLevelSource, pos, Facing::UP)); + renderFaceDown(tile, pos, tile->getTexture(m_pTileSource, pos, Facing::UP)); break; case Facing::NORTH: - renderNorth (tile, pos, tile->getTexture(m_pLevelSource, pos, Facing::NORTH)); + renderNorth (tile, pos, tile->getTexture(m_pTileSource, pos, Facing::NORTH)); break; case Facing::SOUTH: - renderSouth (tile, pos, tile->getTexture(m_pLevelSource, pos, Facing::SOUTH)); + renderSouth (tile, pos, tile->getTexture(m_pTileSource, pos, Facing::SOUTH)); break; case Facing::WEST: - renderWest (tile, pos, tile->getTexture(m_pLevelSource, pos, Facing::WEST)); + renderWest (tile, pos, tile->getTexture(m_pTileSource, pos, Facing::WEST)); break; case Facing::EAST: - renderEast (tile, pos, tile->getTexture(m_pLevelSource, pos, Facing::EAST)); + renderEast (tile, pos, tile->getTexture(m_pTileSource, pos, Facing::EAST)); break; } - if (TileRenderer::m_bFancyGrass && tile->getTexture(m_pLevelSource, pos, (Facing::Name)dir) == TEXTURE_GRASS_SIDE && (dir == Facing::WEST || dir == Facing::EAST || dir == Facing::NORTH || dir == Facing::SOUTH)) + if (TileRenderer::m_bFancyGrass && tile->getTexture(m_pTileSource, pos, (Facing::Name)dir) == TEXTURE_GRASS_SIDE && (dir == Facing::WEST || dir == Facing::EAST || dir == Facing::NORTH || dir == Facing::SOUTH)) { for (int i = 0; i < 4; i++) m_vtxRed[i] = m_vtxGreen[i] = m_vtxBlue[i] = 1.0f; @@ -2902,12 +2915,12 @@ int TileRenderer::getTileColor(Tile* tile, const TilePos& pos) if ((tile == Tile::grass || tile == Tile::tallGrass) && GrassColor::isAvailable() && m_bBiomeColors) { - m_pLevelSource->getBiomeSource()->getBiomeBlock(pos, 1, 1); - return GrassColor::get(m_pLevelSource->getBiomeSource()->field_4[0], m_pLevelSource->getBiomeSource()->field_8[0]); + m_pTileSource->getBiomeSource()->getBiomeBlock(pos, 1, 1); + return GrassColor::get(m_pTileSource->getBiomeSource()->field_4[0], m_pTileSource->getBiomeSource()->field_8[0]); } if (tile == Tile::leaves && FoliageColor::isAvailable() && m_bBiomeColors) { - TileData data = m_pLevelSource->getData(pos); + TileData data = m_pTileSource->getData(pos); if ((data & 1) == 1) { @@ -2918,11 +2931,11 @@ int TileRenderer::getTileColor(Tile* tile, const TilePos& pos) return FoliageColor::getBirchColor(); } - m_pLevelSource->getBiomeSource()->getBiomeBlock(pos, 1, 1); - return FoliageColor::get(m_pLevelSource->getBiomeSource()->field_4[0], m_pLevelSource->getBiomeSource()->field_8[0]); + m_pTileSource->getBiomeSource()->getBiomeBlock(pos, 1, 1); + return FoliageColor::get(m_pTileSource->getBiomeSource()->field_4[0], m_pTileSource->getBiomeSource()->field_8[0]); } - return tile->getColor(m_pLevelSource, pos); + return tile->getColor(m_pTileSource, pos); } bool TileRenderer::useAmbientOcclusion() const diff --git a/source/client/renderer/TileRenderer.hpp b/source/client/renderer/TileRenderer.hpp index f76dcc33f..b9a1ef613 100644 --- a/source/client/renderer/TileRenderer.hpp +++ b/source/client/renderer/TileRenderer.hpp @@ -14,13 +14,22 @@ class TileRenderer { +protected: + class Materials + { + public: + mce::MaterialPtr ui_item; + + Materials(); + }; + private: void _init(); public: - TileRenderer(); - TileRenderer(LevelSource*); + TileRenderer(Tesselator& tessellator = Tesselator::instance, LevelSource* pLevelSource = nullptr); + float getWaterHeight(const TilePos& pos, const Material*); - void renderTile(Tile*, TileData data, float bright = 1.0f, bool preshade = false); + void renderTile(const FullTile& tile, const mce::MaterialPtr& material = mce::MaterialPtr::NONE, float bright = 1.0f, bool preshade = false); // TODO @@ -34,7 +43,7 @@ class TileRenderer void renderNorth(Tile*, const Vec3& pos, int texture); void renderFaceDown(Tile*, const Vec3& pos, int texture); void renderFaceUp(Tile*, const Vec3& pos, int texture); - void tesselateCrossTexture(Tile* tile, TileData data, const Vec3& pos); + void tesselateCrossTexture(const FullTile& tile, const Vec3& pos, bool simple = false); void tesselateTorch(Tile*, const Vec3& pos, float a, float b); bool tesselateBlockInWorldWithAmbienceOcclusion(Tile*, const TilePos& pos, float r, float g, float b); @@ -63,10 +72,10 @@ class TileRenderer static bool m_bBiomeColors; private: - LevelSource* m_pLevelSource; - int m_textureOverride; - bool field_8; - bool m_bDisableCulling; + LevelSource* m_pTileSource; + int m_fixedTexture; + bool m_bXFlipTexture; + bool m_bNoCulling; bool m_bAmbientOcclusion; float field_C; float field_10; @@ -117,4 +126,6 @@ class TileRenderer bool field_B5; bool field_B6; bool field_B7; + Materials m_materials; + Tesselator& m_tessellator; }; diff --git a/source/client/renderer/entity/ArrowRenderer.cpp b/source/client/renderer/entity/ArrowRenderer.cpp index f471ba76d..7c11babbf 100644 --- a/source/client/renderer/entity/ArrowRenderer.cpp +++ b/source/client/renderer/entity/ArrowRenderer.cpp @@ -1,5 +1,9 @@ #include "ArrowRenderer.hpp" -#include +#include "client/renderer/Tesselator.hpp" +#include "renderer/MatrixStack.hpp" +#include "world/entity/Arrow.hpp" + +#define ARROW_SCALE 0.05625f ArrowRenderer::ArrowRenderer() { @@ -9,65 +13,80 @@ ArrowRenderer::~ArrowRenderer() { } -void ArrowRenderer::render(Entity* ent, const Vec3& pos, float rot, float a) +void ArrowRenderer::_buildMesh() { - Arrow* arrow = reinterpret_cast(ent); - - glPushMatrix(); + Tesselator& t = Tesselator::instance; + + constexpr int type = 0; + constexpr float u0 = 0.0f; + constexpr float u1 = 0.5f; + constexpr float v0 = (0 + type * 10) / 32.0f; + constexpr float v1 = (5 + type * 10) / 32.0f; + constexpr float u02 = 0.0f; + constexpr float u12 = 0.15625f; + constexpr float v02 = (5 + type * 10) / 32.0f; + constexpr float v12 = (10 + type * 10) / 32.0f; + + t.begin(12); + + t.normal(Vec3::UNIT_X * ARROW_SCALE); + t.vertexUV(-7.0f, -2.0f, -2.0f, u02, v02); + t.vertexUV(-7.0f, -2.0f, 2.0f, u12, v02); + t.vertexUV(-7.0f, 2.0f, 2.0f, u12, v12); + t.vertexUV(-7.0f, 2.0f, -2.0f, u02, v12); + + /*t.normal(Vec3::NEG_UNIT_X * ARROW_SCALE); + t.vertexUV(-7.0f, 2.0f, -2.0f, u02, v02); + t.vertexUV(-7.0f, 2.0f, 2.0f, u12, v02); + t.vertexUV(-7.0f, -2.0f, 2.0f, u12, v12); + t.vertexUV(-7.0f, -2.0f, -2.0f, u02, v12);*/ + + t.normal(Vec3::UNIT_Z * ARROW_SCALE); + t.vertexUV(-8.0f, -2.0f, 0.0f, u0, v0); + t.vertexUV( 8.0f, -2.0f, 0.0f, u1, v0); + t.vertexUV( 8.0f, 2.0f, 0.0f, u1, v1); + t.vertexUV(-8.0f, 2.0f, 0.0f, u0, v1); + + t.normal(Vec3::UNIT_Y * ARROW_SCALE); + t.vertexUV(-8.0f, 0.0f, -2.0f, u0, v0); + t.vertexUV( 8.0f, 0.0f, -2.0f, u1, v0); + t.vertexUV( 8.0f, 0.0f, 2.0f, u1, v1); + t.vertexUV(-8.0f, 0.0f, 2.0f, u0, v1); + + m_mesh = t.end(); +} + +void ArrowRenderer::onAppSuspended() +{ + m_mesh.reset(); +} + +void ArrowRenderer::render(const Entity& entity, const Vec3& pos, float rot, float a) +{ + const Arrow& arrow = reinterpret_cast(entity); + + if (!m_mesh.isValid()) + _buildMesh(); + bindTexture("item/arrows.png"); - - glTranslatef(pos.x, pos.y, pos.z); - glRotatef(arrow->m_oRot.y + (arrow->m_rot.y - arrow->m_oRot.y) * a - 90.0f, 0.0f, 1.0f, 0.0f); - glRotatef(arrow->m_oRot.x + (arrow->m_rot.x - arrow->m_oRot.x) * a, 0.0f, 0.0f, 1.0f); - Tesselator& t = Tesselator::instance; - int type = 0; - float u0 = 0.0f; - float u1 = 0.5f; - float v0 = (0 + type * 10) / 32.0f; - float v1 = (5 + type * 10) / 32.0f; - float u02 = 0.0f; - float u12 = 0.15625f; - float v02 = (5 + type * 10) / 32.0f; - float v12 = (10 + type * 10) / 32.0f; - float ss = 0.05625f; - glEnable(32826); - float shake = arrow->m_shakeTime - a; - if (shake > 0.0f) { + MatrixStack::Ref matrix = MatrixStack::World.push(); + matrix->translate(pos); + matrix->rotate(arrow.m_oRot.y + (arrow.m_rot.y - arrow.m_oRot.y) * a - 90.0f, Vec3::UNIT_Y); + matrix->rotate(arrow.m_oRot.x + (arrow.m_rot.x - arrow.m_oRot.x) * a, Vec3::UNIT_Z); + + float shake = arrow.m_shakeTime - a; + if (shake > 0.0f) + { float pow = -Mth::sin(shake * 3.0f) * shake; - glRotatef(pow, 0.0f, 0.0f, 1.0f); + matrix->rotate(pow, Vec3::UNIT_Z); } - glRotatef(45.0f, 1.0f, 0.0f, 0.0f); - glScalef(ss, ss, ss); - glTranslatef(-4.0f, 0.0f, 0.0f); - glNormal3f(ss, 0.0f, 0.0f); - t.begin(); - t.vertexUV(-7.0, -2.0, -2.0, u02, v02); - t.vertexUV(-7.0, -2.0, 2.0, u12, v02); - t.vertexUV(-7.0, 2.0, 2.0, u12, v12); - t.vertexUV(-7.0, 2.0, -2.0, u02, v12); - t.draw(); - - glNormal3f(-ss, 0.0f, 0.0f); - t.begin(); - t.vertexUV(-7.0, 2.0, -2.0, u02, v02); - t.vertexUV(-7.0, 2.0, 2.0, u12, v02); - t.vertexUV(-7.0, -2.0, 2.0, u12, v12); - t.vertexUV(-7.0, -2.0, -2.0, u02, v12); - t.draw(); - - for (int i = 0; i < 4; ++i) { - glRotatef(90.0f, 1.0f, 0.0f, 0.0f); - glNormal3f(0.0f, 0.0f, ss); - t.begin(); - t.vertexUV(-8.0, -2.0, 0.0, u0, v0); - t.vertexUV(8.0, -2.0, 0.0, u1, v0); - t.vertexUV(8.0, 2.0, 0.0, u1, v1); - t.vertexUV(-8.0, 2.0, 0.0, u0, v1); - t.draw(); - } + matrix->rotate(45.0f, Vec3::UNIT_X); + matrix->scale(ARROW_SCALE); + matrix->translate(Vec3(-4.0f, 0.0f, 0.0f)); + + //_setupShaderParameters(ent, Color::NIL, a); - glDisable(32826); - glPopMatrix(); + m_mesh.render(m_materials.entity_alphatest); } \ No newline at end of file diff --git a/source/client/renderer/entity/ArrowRenderer.hpp b/source/client/renderer/entity/ArrowRenderer.hpp index 15a8f2209..49703a1ff 100644 --- a/source/client/renderer/entity/ArrowRenderer.hpp +++ b/source/client/renderer/entity/ArrowRenderer.hpp @@ -1,12 +1,22 @@ #pragma once #include "EntityRenderer.hpp" +#include "client/app/AppPlatformListener.hpp" +#include "renderer/Mesh.hpp" -class ArrowRenderer : public EntityRenderer +class ArrowRenderer : public EntityRenderer, public AppPlatformListener { public: ArrowRenderer(); ~ArrowRenderer(); - void render(Entity* ent, const Vec3& pos, float rot, float a) override; +private: + void _buildMesh(); + +public: + void onAppSuspended() override; + void render(const Entity& entity, const Vec3& pos, float rot, float a) override; + +private: + mce::Mesh m_mesh; }; diff --git a/source/client/renderer/entity/ChickenRenderer.cpp b/source/client/renderer/entity/ChickenRenderer.cpp index 37083650d..34ae11697 100644 --- a/source/client/renderer/entity/ChickenRenderer.cpp +++ b/source/client/renderer/entity/ChickenRenderer.cpp @@ -16,11 +16,11 @@ ChickenRenderer::~ChickenRenderer() { } -float ChickenRenderer::getBob(Mob* mob, float time) +float ChickenRenderer::getBob(const Mob& mob, float time) { - Chicken* chicken = (Chicken *)mob; + const Chicken& chicken = (const Chicken&)mob; - return (float)((Mth::sin((chicken->m_oFlap + (float)((float)(chicken->m_flap - chicken->m_oFlap) * time))/*, *(float*)&chicken->m_flap*/)) + return (float)((Mth::sin((chicken.m_oFlap + (float)((float)(chicken.m_flap - chicken.m_oFlap) * time))/*, *(float*)&chicken->m_flap*/)) + 1.0) - * chicken->m_oFlapSpeed + (float)((float)(chicken->m_flapSpeed - chicken->m_oFlapSpeed) * time); + * chicken.m_oFlapSpeed + (float)((float)(chicken.m_flapSpeed - chicken.m_oFlapSpeed) * time); } diff --git a/source/client/renderer/entity/ChickenRenderer.hpp b/source/client/renderer/entity/ChickenRenderer.hpp index ebf0f10ec..9b87df684 100644 --- a/source/client/renderer/entity/ChickenRenderer.hpp +++ b/source/client/renderer/entity/ChickenRenderer.hpp @@ -14,5 +14,5 @@ class ChickenRenderer : public MobRenderer public: ChickenRenderer(Model*, float); ~ChickenRenderer(); - float getBob(Mob*, float); + float getBob(const Mob& mob, float f) override; }; diff --git a/source/client/renderer/entity/CreeperRenderer.cpp b/source/client/renderer/entity/CreeperRenderer.cpp index cf825a448..231b82dd9 100644 --- a/source/client/renderer/entity/CreeperRenderer.cpp +++ b/source/client/renderer/entity/CreeperRenderer.cpp @@ -15,15 +15,15 @@ CreeperRenderer::~CreeperRenderer() { } -int CreeperRenderer::getOverlayColor(Mob* pMob, float a, float b) +Color CreeperRenderer::getOverlayColor(const Entity& entity, float a) { - Creeper* pCreeper = (Creeper*)pMob; + const Creeper& creeper = (const Creeper&)entity; - float step = pCreeper->getSwelling(b); + float step = creeper.getSwelling(a); if (static_cast(step * 10.0f) % 2 == 0) { - return 0; + return EntityShaderManager::getOverlayColor(entity, a); } int _a = step * 0.2f * 255.0f; @@ -32,18 +32,14 @@ int CreeperRenderer::getOverlayColor(Mob* pMob, float a, float b) if (_a > 255) { _a = 255; } - int red = 255; - int green = 255; - int blue = 255; - - return _a << 24 | red << 16 | green << 8 | blue; + return Color(255, 255, 255, _a); } -void CreeperRenderer::scale(Mob* pMob, float f) +void CreeperRenderer::scale(const Mob& mob, Matrix& matrix, float a) { - Creeper* pCreeper = (Creeper*)pMob; + const Creeper& creeper = (const Creeper&)mob; - float g = pCreeper->getSwelling(f); + float g = creeper.getSwelling(a); float wobble = 1.0f + Mth::sin(g * 100.0f) * g * 0.01f; if (g < 0.0f) @@ -62,5 +58,5 @@ void CreeperRenderer::scale(Mob* pMob, float f) float s = (1.0f + g * 0.4f) * wobble; float hs = (1.0f + g * 0.1f) / wobble; - glScalef(s, hs, s); + matrix.scale(Vec3(s, hs, s)); } diff --git a/source/client/renderer/entity/CreeperRenderer.hpp b/source/client/renderer/entity/CreeperRenderer.hpp index 89923edf3..833ad509c 100644 --- a/source/client/renderer/entity/CreeperRenderer.hpp +++ b/source/client/renderer/entity/CreeperRenderer.hpp @@ -16,6 +16,6 @@ class CreeperRenderer : public MobRenderer CreeperRenderer(Model*, float); ~CreeperRenderer(); - int getOverlayColor(Mob*, float, float) override; - void scale(Mob*, float) override; + Color getOverlayColor(const Entity& entity, float a) override; + void scale(const Mob& mob, Matrix& matrix, float a) override; }; diff --git a/source/client/renderer/entity/EntityRenderDispatcher.cpp b/source/client/renderer/entity/EntityRenderDispatcher.cpp index 7a9e72bd5..a57b2a849 100644 --- a/source/client/renderer/entity/EntityRenderDispatcher.cpp +++ b/source/client/renderer/entity/EntityRenderDispatcher.cpp @@ -8,37 +8,40 @@ #include "EntityRenderDispatcher.hpp" #include "client/app/Minecraft.hpp" +#include "renderer/ShaderConstants.hpp" #include "../ItemInHandRenderer.hpp" -#include "client/model/PigModel.hpp" -#include "client/model/SheepModel.hpp" -#include "client/model/CowModel.hpp" -#include "client/model/ChickenModel.hpp" -#include "client/model/CreeperModel.hpp" -#include "client/model/SpiderModel.hpp" -#include "client/model/SkeletonModel.hpp" -#include "client/model/ZombieModel.hpp" +#include "client/model/models/PigModel.hpp" +#include "client/model/models/SheepModel.hpp" +#include "client/model/models/CowModel.hpp" +#include "client/model/models/ChickenModel.hpp" +#include "client/model/models/CreeperModel.hpp" +#include "client/model/models/SpiderModel.hpp" +#include "client/model/models/SkeletonModel.hpp" +#include "client/model/models/ZombieModel.hpp" EntityRenderDispatcher* EntityRenderDispatcher::instance; Vec3 EntityRenderDispatcher::off; -EntityRenderDispatcher::EntityRenderDispatcher() : - m_HumanoidMobRenderer(new HumanoidModel(0.0f, 0.0f), 0.5f), - m_PigRenderer(new PigModel(0.0f), /*new PigModel(0.5f),*/ 0.7f), - m_SheepRenderer(new SheepModel(false), new SheepModel(true), 0.7f), - m_CowRenderer(new CowModel, 0.7f), - m_ChickenRenderer(new ChickenModel, 0.3f), - m_CreeperRenderer(new CreeperModel, 0.5f), - m_SpiderRenderer(), - m_SkeletonRenderer(new SkeletonModel, 0.5f), - m_ZombieRenderer(new ZombieModel, 0.5f), - m_ArrowRenderer() +EntityRenderDispatcher::EntityRenderDispatcher() + : m_HumanoidMobRenderer(new HumanoidModel(0.0f, 0.0f), 0.5f) + , m_PigRenderer(new PigModel(0.0f), /*new PigModel(0.5f),*/ 0.7f) + , m_SheepRenderer(new SheepModel(false), new SheepModel(true), 0.7f) + , m_CowRenderer(new CowModel, 0.7f) + , m_ChickenRenderer(new ChickenModel, 0.3f) + , m_CreeperRenderer(new CreeperModel, 0.5f) + , m_SpiderRenderer() + , m_SkeletonRenderer(new SkeletonModel, 0.5f) + , m_ZombieRenderer(new ZombieModel, 0.5f) + , m_ArrowRenderer() + , m_FallingTileRenderer() { m_pItemInHandRenderer = nullptr; + m_tileRenderer = new TileRenderer(); m_pTextures = nullptr; m_pLevel = nullptr; m_pMinecraft = nullptr; - m_pMob = nullptr; + m_pCamera = nullptr; m_rot = Vec2::ZERO; m_pOptions = nullptr; m_pFont = nullptr; @@ -54,6 +57,7 @@ EntityRenderDispatcher::EntityRenderDispatcher() : m_CreeperRenderer.init(this); m_ZombieRenderer.init(this); m_ArrowRenderer.init(this); + m_FallingTileRenderer.init(this); // TODO @@ -84,41 +88,42 @@ EntityRenderDispatcher* EntityRenderDispatcher::getInstance() return instance; } -EntityRenderer* EntityRenderDispatcher::getRenderer(int renderType) +EntityRenderer* EntityRenderDispatcher::getRenderer(Entity::RenderType renderType) { + // @HAL @TODO: make map switch (renderType) { - case RENDER_TNT: + case Entity::RENDER_TNT: return &m_TntRenderer; - case RENDER_HUMANOID: + case Entity::RENDER_HUMANOID: return &m_HumanoidMobRenderer; - case RENDER_ITEM: + case Entity::RENDER_ITEM: return &m_ItemRenderer; - case RENDER_CAMERA: + case Entity::RENDER_CAMERA: return &m_CameraRenderer; - case RENDER_CHICKEN: + case Entity::RENDER_CHICKEN: return &m_ChickenRenderer; - case RENDER_COW: + case Entity::RENDER_COW: return &m_CowRenderer; - case RENDER_PIG: + case Entity::RENDER_PIG: return &m_PigRenderer; - case RENDER_SHEEP: + case Entity::RENDER_SHEEP: return &m_SheepRenderer; - case RENDER_SPIDER: + case Entity::RENDER_SPIDER: return &m_SpiderRenderer; - case RENDER_SKELETON: + case Entity::RENDER_SKELETON: return &m_SkeletonRenderer; - case RENDER_CREEPER: + case Entity::RENDER_CREEPER: return &m_CreeperRenderer; - case RENDER_ZOMBIE: + case Entity::RENDER_ZOMBIE: return &m_ZombieRenderer; - case RENDER_ARROW: + case Entity::RENDER_ARROW: return &m_ArrowRenderer; - case RENDER_ROCKET: + case Entity::RENDER_ROCKET: return &m_RocketRenderer; #ifdef ENH_ALLOW_SAND_GRAVITY // TODO - case RENDER_FALLING_TILE: + case Entity::RENDER_FALLING_TILE: return &m_FallingTileRenderer; #endif } @@ -126,11 +131,11 @@ EntityRenderer* EntityRenderDispatcher::getRenderer(int renderType) return nullptr; } -EntityRenderer* EntityRenderDispatcher::getRenderer(Entity* pEnt) +EntityRenderer* EntityRenderDispatcher::getRenderer(const Entity& entity) { - int renderType = pEnt->field_C8; - if (renderType == RENDER_DYNAMIC) - renderType = pEnt->queryEntityRenderer(); + Entity::RenderType renderType = entity.m_renderType; + if (renderType == Entity::RENDER_DYNAMIC) + renderType = entity.queryEntityRenderer(); return getRenderer(renderType); } @@ -157,37 +162,37 @@ void EntityRenderDispatcher::onGraphicsReset() #endif } -void EntityRenderDispatcher::prepare(Level* level, Textures* textures, Font* font, Mob* mob, Options* options, float f) +void EntityRenderDispatcher::prepare(Level* level, Textures* textures, Font* font, const Mob* camera, Options* options, float f) { m_pLevel = level; m_pTextures = textures; - m_pMob = mob; + m_pCamera = camera; m_pFont = font; m_pOptions = options; - m_rot = mob->m_oRot + (mob->m_rot - mob->m_oRot) * f; - m_pos = mob->m_posPrev + (mob->m_pos - mob->m_posPrev) * f; + m_rot = camera->m_oRot + (camera->m_rot - camera->m_oRot) * f; + m_pos = camera->m_posPrev + (camera->m_pos - camera->m_posPrev) * f; } -void EntityRenderDispatcher::render(Entity* entity, float a) +void EntityRenderDispatcher::render(const Entity& entity, float a) { - Vec3 pos = Vec3(entity->m_posPrev + (entity->m_pos - entity->m_posPrev) * a); - float yaw = entity->m_oRot.x + a * (entity->m_rot.x - entity->m_oRot.x); + Vec3 pos = Vec3(entity.m_posPrev + (entity.m_pos - entity.m_posPrev) * a); + float yaw = entity.m_oRot.x + a * (entity.m_rot.x - entity.m_oRot.x); - float bright = entity->getBrightness(1.0f); - glColor4f(bright, bright, bright, 1.0f); + float bright = entity.getBrightness(1.0f); + currentShaderColor = Color::WHITE; + currentShaderDarkColor = Color(bright, bright, bright); render(entity, pos - off, yaw, a); } -void EntityRenderDispatcher::render(Entity* entity, const Vec3& pos, float rot, float a) +void EntityRenderDispatcher::render(const Entity& entity, const Vec3& pos, float rot, float a) { EntityRenderer* pRenderer = getRenderer(entity); if (!pRenderer) { - //LOG_E("Failed to fetch renderer for entity: %s", entity->getDescriptor().getEntityType().getName()); - assert(!"Failed to fetch renderer for an entity"); - return; + LOG_E("Failed to fetch renderer for entity: %s", entity.getDescriptor().getEntityType().getName().c_str()); + throw std::bad_cast(); } pRenderer->render(entity, pos, rot, a); @@ -203,3 +208,8 @@ void EntityRenderDispatcher::setMinecraft(Minecraft* mc) { m_pMinecraft = mc; } + +void EntityRenderDispatcher::onAppSuspended() +{ + //m_tileRenderer->clearTileCache(); +} diff --git a/source/client/renderer/entity/EntityRenderDispatcher.hpp b/source/client/renderer/entity/EntityRenderDispatcher.hpp index 8b1655ab6..20fd85f4c 100644 --- a/source/client/renderer/entity/EntityRenderDispatcher.hpp +++ b/source/client/renderer/entity/EntityRenderDispatcher.hpp @@ -30,25 +30,29 @@ class Entity; class Textures; class ItemInHandRenderer; -class EntityRenderDispatcher +class EntityRenderDispatcher : AppPlatformListener { public: EntityRenderDispatcher(); float distanceToSqr(const Vec3& pos); Font* getFont(); - EntityRenderer* getRenderer(Entity* pEnt); - EntityRenderer* getRenderer(int renderType); + EntityRenderer* getRenderer(const Entity& entity); + EntityRenderer* getRenderer(Entity::RenderType renderType); void onGraphicsReset(); - void prepare(Level*, Textures*, Font*, Mob*, Options*, float); - void render(Entity*, float); - void render(Entity*, const Vec3& pos, float rot, float a); + void prepare(Level*, Textures*, Font*, const Mob* camera, Options*, float); + void render(const Entity& entity, float); + void render(const Entity& entity, const Vec3& pos, float rot, float a); void setLevel(Level*); void setMinecraft(Minecraft*); + void onAppSuspended() override; + static EntityRenderDispatcher* getInstance(); public: ItemInHandRenderer* m_pItemInHandRenderer; + TileRenderer* m_tileRenderer; + HumanoidMobRenderer m_HumanoidMobRenderer; PigRenderer m_PigRenderer; SheepRenderer m_SheepRenderer; @@ -65,20 +69,20 @@ class EntityRenderDispatcher //SheepFurRenderer m_SheepFurRenderer; TripodCameraRenderer m_CameraRenderer; ArrowRenderer m_ArrowRenderer; +#ifdef ENH_ALLOW_SAND_GRAVITY + FallingTileRenderer m_FallingTileRenderer; +#endif RocketRenderer m_RocketRenderer; + Textures* m_pTextures; Level* m_pLevel; Minecraft* m_pMinecraft; - Mob* m_pMob; + const Mob* m_pCamera; Vec2 m_rot; Options* m_pOptions; Vec3 m_pos; Font* m_pFont; -#ifdef ENH_ALLOW_SAND_GRAVITY - FallingTileRenderer m_FallingTileRenderer; -#endif - static EntityRenderDispatcher* instance; static Vec3 off; }; diff --git a/source/client/renderer/entity/EntityRenderer.cpp b/source/client/renderer/entity/EntityRenderer.cpp index 2bc0726b3..60ce92243 100644 --- a/source/client/renderer/entity/EntityRenderer.cpp +++ b/source/client/renderer/entity/EntityRenderer.cpp @@ -7,11 +7,25 @@ ********************************************************************/ #include "EntityRenderer.hpp" +#include "client/app/Minecraft.hpp" +#include "client/renderer/renderer/RenderMaterialGroup.hpp" +#include "client/renderer/Lighting.hpp" +#include "renderer/ShaderConstants.hpp" #include "EntityRenderDispatcher.hpp" +EntityRenderer::Materials::Materials() +{ + MATERIAL_PTR(switchable, entity_alphatest); + MATERIAL_PTR(switchable, entity_alphatest_cull); + MATERIAL_PTR(switchable, entity_alphatest_glint); + MATERIAL_PTR(common, name_tag); + MATERIAL_PTR(common, name_tag_depth_tested); + MATERIAL_PTR(common, name_text_depth_tested); +} + bool EntityRenderer::_areShadowsAvailable = false; // false because PE used a reimplementation with geometry later on, rather than a texture -EntityRenderer::EntityRenderer() : m_model(0.0f, 0.0f) +EntityRenderer::EntityRenderer() { m_shadowRadius = 0.0f; m_shadowStrength = 1.0f; @@ -20,7 +34,7 @@ EntityRenderer::EntityRenderer() : m_model(0.0f, 0.0f) bool EntityRenderer::bindTexture(const std::string& file, bool isRequired) { - return m_pDispatcher->m_pTextures->loadAndBindTexture(file, isRequired) != -1; + return m_pDispatcher->m_pTextures->loadAndBindTexture(file, isRequired) != nullptr; } Font* EntityRenderer::getFont() @@ -38,12 +52,13 @@ void EntityRenderer::onGraphicsReset() } -void EntityRenderer::renderFlame(Entity* e, const Vec3& pos, float a) +void EntityRenderer::renderFlame(const Entity& entity, const Vec3& pos, float a) { Vec3 ePos(pos); - ePos.y -= e->m_heightOffset; // Fixed fire rendering above player's head in third-person + ePos.y -= entity.m_heightOffset; // Fixed fire rendering above player's head in third-person + + Lighting::turnOff(false); - glDisable(GL_LIGHTING); int tex = Tile::fire->getTexture(Facing::NORTH); int xt = (tex & 15) << 4; int yt = tex & 240; @@ -51,20 +66,24 @@ void EntityRenderer::renderFlame(Entity* e, const Vec3& pos, float a) float u1 = ((float)xt + 15.99f) / 256.0f; float v0 = (float)yt / 256.0f; float v1 = ((float)yt + 15.99f) / 256.0f; - glPushMatrix(); - glTranslatef(ePos.x, ePos.y, ePos.z); - float s = e->m_bbWidth * 1.4f; // bbWidth instead of e->m_hitbox.max.x - glScalef(s, s, s); + + MatrixStack::Ref matrix = MatrixStack::World.push(); + + float s = entity.m_bbWidth * 1.4f; // bbWidth instead of e->m_hitbox.max.x + float h = entity.m_bbHeight / entity.m_bbWidth; + + matrix->translate(ePos); + matrix->scale(s); + matrix->rotate(-m_pDispatcher->m_rot.x, Vec3::UNIT_Y); + matrix->translate(Vec3(0.0f, 0.0f, -0.4f + (float)((int)h) * 0.02f)); + bindTexture(C_TERRAIN_NAME); Tesselator& t = Tesselator::instance; float r = 1.0f; float xo = 0.5f; float yo = 0.0f; - float h = e->m_bbHeight / e->m_bbWidth; - glRotatef(-m_pDispatcher->m_rot.x, 0.0f, 1.0f, 0.0f); - glTranslatef(0.0f, 0.0f, -0.4f + (float)((int)h) * 0.02f); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - t.begin(); + currentShaderColor = Color::WHITE; + t.begin(12); while (h > 0.0f) { @@ -75,62 +94,12 @@ void EntityRenderer::renderFlame(Entity* e, const Vec3& pos, float a) --h; --yo; r *= 0.9f; - glTranslatef(0.0f, 0.0f, -0.04f); + matrix->translate(Vec3(0.0f, 0.0f, -0.04f)); } - t.draw(); - glPopMatrix(); - glEnable(GL_LIGHTING); -} - -void EntityRenderer::renderShadow(Entity* e, const Vec3& pos, float pow, float a) -{ - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - m_pDispatcher->m_pTextures->setClampToEdge(true); - bindTexture("misc/shadow.png"); - m_pDispatcher->m_pTextures->setClampToEdge(false); - - Level* level = getLevel(); + t.draw(m_materials.entity_alphatest_cull); - glDepthMask(false); - float r = m_shadowRadius; - - Vec3 ePos(e->m_posPrev + (e->m_pos - e->m_posPrev) * a); - ePos.y -= e->m_heightOffset; // We gotta do this so the renderer can correctly determine if there's a tile below the entity - ePos.y += e->getShadowHeightOffs(); - - TilePos tpMin(ePos - r); - TilePos tpMax(ePos.x + r, ePos.y, ePos.z + r); - Vec3 ePosO(pos - ePos); - - Tesselator& tt = Tesselator::instance; - tt.begin(); - TilePos tp(tpMin); - for (tp.x = tpMin.x; tp.x <= tpMax.x; tp.x++) - { - for (tp.y = tpMin.y; tp.y <= tpMax.y; tp.y++) - { - for (tp.z = tpMin.z; tp.z <= tpMax.z; tp.z++) - { - TileID t = level->getTile(tp.below()); - if (t > 0 && level->getRawBrightness(tp) > 3) - { - renderTileShadow(Tile::tiles[t], - Vec3(pos.x, pos.y - e->m_heightOffset + e->getShadowHeightOffs(), pos.z), tp, - pow, r, - Vec3(ePosO.x, ePosO.y - e->m_heightOffset + e->getShadowHeightOffs(), ePosO.z) - ); - } - } - } - } - tt.draw(); - - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glDisable(GL_BLEND); - glDepthMask(true); + Lighting::turnOn(false); } Level* EntityRenderer::getLevel() const @@ -138,41 +107,13 @@ Level* EntityRenderer::getLevel() const return m_pDispatcher->m_pLevel; } -void EntityRenderer::renderTileShadow(Tile* tt, const Vec3& pos, TilePos& tilePos, float pow, float r, const Vec3& oPos) -{ - Tesselator& t = Tesselator::instance; - if (!tt->isCubeShaped()) return; - - float a = (pow - (pos.y - ((float)tilePos.y + oPos.y)) / 2.0f) * 0.5f * getLevel()->getBrightness(tilePos); - if (a < 0.0f) - return; - if (a > 1.0f) a = 1.0f; - - t.color(1.0f, 1.0f, 1.0f, a); - float x0 = (float)tilePos.x + tt->m_aabb.min.x + oPos.x; - float x1 = (float)tilePos.x + tt->m_aabb.max.x + oPos.x; - float y0 = (float)tilePos.y + tt->m_aabb.min.y + oPos.y + (1.0f / 64.0f); - float z0 = (float)tilePos.z + tt->m_aabb.min.z + oPos.z; - float z1 = (float)tilePos.z + tt->m_aabb.max.z + oPos.z; - float u0 = ((pos.x - x0) / 2.0f / r + 0.5f); - float u1 = ((pos.x - x1) / 2.0f / r + 0.5f); - float v0 = ((pos.z - z0) / 2.0f / r + 0.5f); - float v1 = ((pos.z - z1) / 2.0f / r + 0.5f); - t.vertexUV(x0, y0, z0, u0, v0); - t.vertexUV(x0, y0, z1, u0, v1); - t.vertexUV(x1, y0, z1, u1, v1); - t.vertexUV(x1, y0, z0, u1, v0); -} - - void EntityRenderer::render(const AABB& aabb, const Vec3& pos) { - glDisable(GL_TEXTURE_2D); Tesselator& t = Tesselator::instance; - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - t.begin(); + currentShaderColor = Color::WHITE; + t.begin(24); //t.vertex(pos); // Why were we doing this? - t.offset(pos); + t.setOffset(pos); t.normal(0.0f, 0.0f, -1.0f); t.vertex(aabb.min.x, aabb.max.y, aabb.min.z); t.vertex(aabb.max.x, aabb.max.y, aabb.min.z); @@ -209,16 +150,15 @@ void EntityRenderer::render(const AABB& aabb, const Vec3& pos) t.vertex(aabb.max.x, aabb.max.y, aabb.max.z); t.vertex(aabb.max.x, aabb.min.y, aabb.max.z); - t.offset(Vec3::ZERO); - t.draw(); // t.end() on Java - glEnable(GL_TEXTURE_2D); + t.setOffset(Vec3::ZERO); + t.draw(m_shaderMaterials.entity); // t.end() on Java } void EntityRenderer::renderFlat(const AABB& aabb) { Tesselator& t = Tesselator::instance; - t.begin(); + t.begin(24); t.vertex(aabb.min.x, aabb.max.y, aabb.min.z); t.vertex(aabb.max.x, aabb.max.y, aabb.min.z); t.vertex(aabb.max.x, aabb.min.y, aabb.min.z); @@ -243,19 +183,19 @@ void EntityRenderer::renderFlat(const AABB& aabb) t.vertex(aabb.max.x, aabb.max.y, aabb.min.z); t.vertex(aabb.max.x, aabb.max.y, aabb.max.z); t.vertex(aabb.max.x, aabb.min.y, aabb.max.z); - t.draw(); // t.end() on Java + t.draw(m_shaderMaterials.entity); // t.end() on Java } -void EntityRenderer::postRender(Entity* entity, const Vec3& pos, float rot, float a) +void EntityRenderer::postRender(const Entity& entity, const Vec3& pos, float rot, float a) { if (m_pDispatcher->m_pOptions->m_bFancyGraphics && areShadowsAvailable() && m_shadowRadius > 0.0f) { - float dist = m_pDispatcher->distanceToSqr(entity->m_pos); + float dist = m_pDispatcher->distanceToSqr(entity.m_pos); float pow = (1.0f - dist / 256.0f) * m_shadowStrength; if (pow > 0.0f) - renderShadow(entity, pos, pow, a); + m_pDispatcher->m_pMinecraft->m_pLevelRenderer->renderShadow(entity, pos, m_shadowRadius, pow, a); } - if (entity->isOnFire()) + if (entity.isOnFire()) renderFlame(entity, pos, a); } diff --git a/source/client/renderer/entity/EntityRenderer.hpp b/source/client/renderer/entity/EntityRenderer.hpp index 463b487ba..b045760fa 100644 --- a/source/client/renderer/entity/EntityRenderer.hpp +++ b/source/client/renderer/entity/EntityRenderer.hpp @@ -8,17 +8,31 @@ #pragma once +#include "client/renderer/Font.hpp" +#include "client/renderer/renderer/EntityShaderManager.hpp" #include "world/phys/AABB.hpp" #include "world/phys/Vec3.hpp" -#include "client/model/HumanoidModel.hpp" -#include "client/renderer/Font.hpp" class EntityRenderDispatcher; class Level; class Tile; -class EntityRenderer +class EntityRenderer : public EntityShaderManager { +protected: + class Materials + { + public: + mce::MaterialPtr entity_alphatest; + mce::MaterialPtr entity_alphatest_cull; + mce::MaterialPtr entity_alphatest_glint; + mce::MaterialPtr name_tag; + mce::MaterialPtr name_tag_depth_tested; + mce::MaterialPtr name_text_depth_tested; + + Materials(); + }; + private: static bool _areShadowsAvailable; public: @@ -27,28 +41,24 @@ class EntityRenderer private: Level* getLevel() const; - void renderFlame(Entity* e, const Vec3& pos, float a); - void renderShadow(Entity* e, const Vec3& pos, float pow, float a); - void renderTileShadow(Tile* tt, const Vec3& pos, TilePos& tilePos, float pow, float r, const Vec3& oPos); + void renderFlame(const Entity& entity, const Vec3& pos, float a); public: EntityRenderer(); bool bindTexture(const std::string& file, bool isRequired = true); Font* getFont(); void init(EntityRenderDispatcher* d); - static void render(const AABB&, const Vec3& pos); - static void renderFlat(const AABB&); - void postRender(Entity* entity, const Vec3& pos, float rot, float a); + void render(const AABB&, const Vec3& pos); + void renderFlat(const AABB&); + void postRender(const Entity& entity, const Vec3& pos, float rot, float a); - virtual void render(Entity* entity, const Vec3& pos, float rot, float a) = 0; + virtual void render(const Entity& entity, const Vec3& pos, float rot, float a) = 0; virtual void onGraphicsReset(); +protected: + Materials m_materials; public: float m_shadowRadius; float m_shadowStrength; EntityRenderDispatcher* m_pDispatcher; - - // @HUH: Why is there a HumanoidModel here? There's another - // in HumanoidMobRenderer... - HumanoidModel m_model; }; diff --git a/source/client/renderer/entity/FallingTileRenderer.cpp b/source/client/renderer/entity/FallingTileRenderer.cpp index fc71b6342..17e045e33 100644 --- a/source/client/renderer/entity/FallingTileRenderer.cpp +++ b/source/client/renderer/entity/FallingTileRenderer.cpp @@ -9,19 +9,27 @@ #include "GameMods.hpp" #ifdef ENH_ALLOW_SAND_GRAVITY #include "FallingTileRenderer.hpp" +#include "client/renderer/entity/EntityRenderDispatcher.hpp" +#include "client/renderer/renderer/RenderMaterialGroup.hpp" +#include "renderer/MatrixStack.hpp" #include "world/entity/FallingTile.hpp" +FallingTileRenderer::Materials::Materials() +{ + MATERIAL_PTR(switchable, heavy_tile); +} + FallingTileRenderer::FallingTileRenderer() { m_shadowRadius = 0.5f; } -void FallingTileRenderer::render(Entity* entity, const Vec3& pos, float rot, float a) +void FallingTileRenderer::render(const Entity& entity, const Vec3& pos, float rot, float a) { - FallingTile* tile = (FallingTile*)entity; - - glPushMatrix(); - glTranslatef(pos.x, pos.y, pos.z); + const FallingTile& tile = (const FallingTile&)entity; + + MatrixStack::Ref matrix = MatrixStack::World.push(); + matrix->translate(pos); bindTexture(C_TERRAIN_NAME); @@ -30,14 +38,12 @@ void FallingTileRenderer::render(Entity* entity, const Vec3& pos, float rot, flo // Render the base #ifdef ENH_SHADE_HELD_TILES -#define ARGPATCH , entity->getBrightness(0.0f) +#define ARGPATCH , entity.getBrightness(0.0f) #else #define ARGPATCH #endif - m_tileRenderer.renderTile(Tile::tiles[tile->m_id], 0 ARGPATCH); - - glPopMatrix(); + m_pDispatcher->m_tileRenderer->renderTile(FullTile(tile.m_id, 0), m_heavyMaterials.heavy_tile ARGPATCH); #ifdef ARGPATCH #undef ARGPATCH diff --git a/source/client/renderer/entity/FallingTileRenderer.hpp b/source/client/renderer/entity/FallingTileRenderer.hpp index 74a98df28..59397eb3d 100644 --- a/source/client/renderer/entity/FallingTileRenderer.hpp +++ b/source/client/renderer/entity/FallingTileRenderer.hpp @@ -17,13 +17,22 @@ class FallingTileRenderer : public EntityRenderer { +protected: + class Materials + { + public: + mce::MaterialPtr heavy_tile; + + Materials(); + }; + public: FallingTileRenderer(); - void render(Entity* entity, const Vec3& pos, float rot, float a) override; + void render(const Entity& entity, const Vec3& pos, float rot, float a) override; -public: - TileRenderer m_tileRenderer; +protected: + Materials m_heavyMaterials; }; #endif diff --git a/source/client/renderer/entity/HumanoidMobRenderer.cpp b/source/client/renderer/entity/HumanoidMobRenderer.cpp index 4d408c270..4d83a87bf 100644 --- a/source/client/renderer/entity/HumanoidMobRenderer.cpp +++ b/source/client/renderer/entity/HumanoidMobRenderer.cpp @@ -19,64 +19,71 @@ HumanoidMobRenderer::HumanoidMobRenderer(HumanoidModel* pModel, float f) : MobRe m_pHumanoidModel = pModel; } -void HumanoidMobRenderer::additionalRendering(Mob* mob, float f) +void HumanoidMobRenderer::additionalRendering(const Mob& mob, float f) { - ItemInstance* inst = mob->getCarriedItem(); + const ItemInstance* inst = mob.getCarriedItem(); - glPushMatrix(); - m_pHumanoidModel->m_arm1.translateTo(0.0625f); - glTranslatef(-0.0625f, 0.4375f, 0.0625f); + MatrixStack::Ref matrix = MatrixStack::World.push(); + + m_pHumanoidModel->m_arm1.translateTo(matrix, 0.0625f); + matrix->translate(Vec3(-0.0625f, 0.4375f, 0.0625f)); if (inst && inst->getTile() && TileRenderer::canRender(inst->getTile()->getRenderShape())) { - glTranslatef(0.0f, 0.1875f, -0.3125f); - glRotatef(20.0f, 1.0f, 0.0f, 0.0f); - glRotatef(45.0f, 0.0f, 1.0f, 0.0f); - glScalef(0.375f, -0.375f, 0.375f); + constexpr float s = 0.5f * 0.75f; + matrix->translate(Vec3(0.0f, 0.1875f, -0.3125f)); + matrix->rotate(200.0f, Vec3::UNIT_X); + matrix->rotate(45.0f, Vec3::UNIT_Y); + matrix->scale(s); } else if (inst && inst->getItem() && inst->getItem()->isHandEquipped()) { - glTranslatef(0.0f, 0.1875f, 0.0f); - glScalef(0.625f, -0.625f, 0.625f); - glRotatef(-100.0f, 1.0f, 0.0f, 0.0f); - glRotatef(45.0f, 0.0f, 1.0f, 0.0f); + constexpr float s = 0.625f; + matrix->rotate(180.0f, Vec3::UNIT_Y); + // PE's fucked up translation value + //matrix->translate(Vec3(0.1f, 0.265f, 0.0f)); + matrix->translate(Vec3(0.06f, 0.1875f, 0.0f)); + matrix->scale(s); + matrix->rotate(80.0f, Vec3::UNIT_X); + matrix->rotate(35.0f, Vec3::UNIT_Y); } else { - glTranslatef(0.25f, 0.1875f, -0.1875f); - glScalef(0.375f, 0.375f, 0.375f); - glRotatef(60.0f, 0.0f, 0.0f, 1.0f); - glRotatef(-90.0f, 1.0f, 0.0f, 0.0f); - glRotatef(20.0f, 0.0f, 0.0f, 1.0f); + constexpr float s = 0.375; + matrix->translate(Vec3(0.25f, 0.1875f, -0.1875f)); + matrix->scale(s); + matrix->rotate(60.0f, Vec3::UNIT_Z); + matrix->rotate(-90.0f, Vec3::UNIT_X); + matrix->rotate(20.0f, Vec3::UNIT_Z); } - glEnable(GL_RESCALE_NORMAL); - m_pDispatcher->m_pItemInHandRenderer->renderItem(inst); - glPopMatrix(); - glDisable(GL_RESCALE_NORMAL); + if (inst) + { + m_pDispatcher->m_pItemInHandRenderer->renderItem(mob, *inst, f); + } } -void HumanoidMobRenderer::render(Entity* pEntity, const Vec3& pos, float f1, float f2) +void HumanoidMobRenderer::render(const Entity& entity, const Vec3& pos, float f1, float f2) { - if (pEntity->isPlayer()) + if (entity.isPlayer()) { - Player* player = (Player*)pEntity; - ItemInstance* item = player->getSelectedItem(); + const Player& player = (const Player&)entity; + ItemInstance* item = player.getSelectedItem(); m_pHumanoidModel->m_bHoldingRightHand = item != nullptr; } - if (pEntity->isSneaking()) + if (entity.isSneaking()) { m_pHumanoidModel->m_bSneaking = true; Vec3 pos2 = pos; pos2.y -= 0.125f; - MobRenderer::render(pEntity, pos2, f1, f2); + MobRenderer::render(entity, pos2, f1, f2); // https://github.com/ReMinecraftPE/mcpe/pull/197/#discussion_r2437985914 m_pHumanoidModel->m_bSneaking = false; } else { - MobRenderer::render(pEntity, pos, f1, f2); + MobRenderer::render(entity, pos, f1, f2); } } @@ -88,7 +95,7 @@ void HumanoidMobRenderer::onGraphicsReset() void HumanoidMobRenderer::renderHand() { m_pHumanoidModel->field_4 = 0; - m_pHumanoidModel->setBrightness(m_pDispatcher->m_pMinecraft->m_pMobPersp->getBrightness(1.0f)); + m_pHumanoidModel->setBrightness(m_pDispatcher->m_pMinecraft->m_pCameraEntity->getBrightness(1.0f)); m_pHumanoidModel->setupAnim(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0625f); m_pHumanoidModel->m_arm1.render(0.0625f); } diff --git a/source/client/renderer/entity/HumanoidMobRenderer.hpp b/source/client/renderer/entity/HumanoidMobRenderer.hpp index 231f5189c..b94ed1117 100644 --- a/source/client/renderer/entity/HumanoidMobRenderer.hpp +++ b/source/client/renderer/entity/HumanoidMobRenderer.hpp @@ -9,13 +9,14 @@ #pragma once #include "MobRenderer.hpp" +#include "client/model/models/HumanoidModel.hpp" class HumanoidMobRenderer : public MobRenderer { public: HumanoidMobRenderer(HumanoidModel*, float); - virtual void additionalRendering(Mob*, float) override; - virtual void render(Entity*, const Vec3&, float, float) override; + virtual void additionalRendering(const Mob& mob, float) override; + virtual void render(const Entity& entity, const Vec3&, float, float) override; virtual void onGraphicsReset() override; void renderHand(); diff --git a/source/client/renderer/entity/ItemRenderer.cpp b/source/client/renderer/entity/ItemRenderer.cpp index f52026bc5..2dcbf9ce9 100644 --- a/source/client/renderer/entity/ItemRenderer.cpp +++ b/source/client/renderer/entity/ItemRenderer.cpp @@ -10,10 +10,9 @@ #include "ItemRenderer.hpp" #include "EntityRenderDispatcher.hpp" #include "client/renderer/TileRenderer.hpp" +#include "client/renderer/renderer/RenderMaterialGroup.hpp" #include "world/entity/ItemEntity.hpp" -TileRenderer* ItemRenderer::tileRenderer = new TileRenderer; - #ifndef ENH_3D_INVENTORY_TILES const uint8_t g_ItemFrames[C_MAX_TILES] = { @@ -28,20 +27,45 @@ const uint8_t g_ItemFrames[C_MAX_TILES] = }; #endif +ItemRenderer::Materials::Materials() +{ + MATERIAL_PTR(common, ui_fill_color); + MATERIAL_PTR(common, ui_textured); + MATERIAL_PTR(common, ui_texture_and_color); + MATERIAL_PTR(common, ui_item); + MATERIAL_PTR(common, ui_item_glint); +} + +ItemRenderer* ItemRenderer::singletonPtr = nullptr; + +ItemRenderer& ItemRenderer::singleton() +{ + if (!ItemRenderer::singletonPtr) + { + ItemRenderer::singletonPtr = new ItemRenderer(); + } + + return *singletonPtr; +} + ItemRenderer::ItemRenderer() { + static TileRenderer* tileRenderer = new TileRenderer(); + m_pTileRenderer = tileRenderer; + m_shadowRadius = 0.15f; m_shadowStrength = 0.75f; } -void ItemRenderer::render(Entity* pEntity, const Vec3& pos, float rot, float a) +void ItemRenderer::render(const Entity& entity, const Vec3& pos, float rot, float a) { m_random.init_genrand(187); - ItemEntity* pItemEntity = (ItemEntity*)pEntity; + const ItemEntity& itemEntity = (const ItemEntity&)entity; - glPushMatrix(); - float yOffset = Mth::sin((float(pItemEntity->m_age) + a) / 10.0f + pItemEntity->m_bobOffs); - const ItemInstance* pItemInstance = pItemEntity->m_pItemInstance; + MatrixStack::Ref matrix = MatrixStack::World.push(); + + float yOffset = Mth::sin((float(itemEntity.m_age) + a) / 10.0f + itemEntity.m_bobOffs); + const ItemInstance* pItemInstance = itemEntity.m_pItemInstance; if (ItemInstance::isNull(pItemInstance)) { assert(!"Tried to render invalid ItemInstance for ItemEntity"); @@ -56,13 +80,17 @@ void ItemRenderer::render(Entity* pEntity, const Vec3& pos, float rot, float a) if (pItemInstance->m_count > 20) itemsToRender = 4; - glTranslatef(pos.x, pos.y + 0.1f + yOffset * 0.1f, pos.z); + matrix->translate(Vec3(pos.x, pos.y + 0.1f + yOffset * 0.1f, pos.z)); + +#if MCE_GFX_API_OGL glEnable(GL_RESCALE_NORMAL); +#endif Tile* pTile = pItemInstance->getTile(); if (pTile && TileRenderer::canRender(pTile->getRenderShape())) { - glRotatef(((float(pItemEntity->m_age) + a) / 20.0f + pItemEntity->m_bobOffs) * 57.296f, 0.0f, 1.0f, 0.0f); + matrix->rotate(((float(itemEntity.m_age) + a) / 20.0f + itemEntity.m_bobOffs) * 57.296f, Vec3::UNIT_Y); + bindTexture(C_TERRAIN_NAME); float scale = 0.5f; @@ -72,75 +100,74 @@ void ItemRenderer::render(Entity* pEntity, const Vec3& pos, float rot, float a) if (pTile->isCubeShaped() || pTile == Tile::stoneSlabHalf) scale = 0.25f; - glScalef(scale, scale, scale); + matrix->scale(scale); for (int i = 0; i < itemsToRender; i++) { - glPushMatrix(); + MatrixStack::Ref matrix = MatrixStack::World.push(); if (i != 0) { - glTranslatef( + matrix->translate(Vec3( 0.2f * (m_random.nextFloat() * 2.0f - 1.0f) / scale, 0.2f * (m_random.nextFloat() * 2.0f - 1.0f) / scale, - 0.2f * (m_random.nextFloat() * 2.0f - 1.0f) / scale); + 0.2f * (m_random.nextFloat() * 2.0f - 1.0f) / scale)); } - tileRenderer->renderTile(pTile, pItemInstance->getAuxValue(), pItemEntity->getBrightness(1.0f)); - glPopMatrix(); + m_pTileRenderer->renderTile(FullTile(pTile, pItemInstance->getAuxValue()), m_materials.entity_alphatest, itemEntity.getBrightness(1.0f)); } } else { - glScalef(0.5f, 0.5f, 0.5f); + matrix->scale(0.5f); int icon = pItemInstance->getIcon(); bindTexture(pItemInstance->getTile() ? C_TERRAIN_NAME : C_ITEMS_NAME); for (int i = 0; i < itemsToRender; i++) { - glPushMatrix(); + MatrixStack::Ref matrix = MatrixStack::World.push(); if (i != 0) { - glTranslatef( + matrix->translate(Vec3( 0.2f * (m_random.nextFloat() * 2.0f - 1.0f) * 0.3f, 0.2f * (m_random.nextFloat() * 2.0f - 1.0f) * 0.3f, - 0.2f * (m_random.nextFloat() * 2.0f - 1.0f) * 0.3f); + 0.2f * (m_random.nextFloat() * 2.0f - 1.0f) * 0.3f)); } - glRotatef(180.0f - m_pDispatcher->m_rot.x, 0.0f, 1.0f, 0.0f); + matrix->rotate(180.0f - m_pDispatcher->m_rot.x, Vec3::UNIT_Y); Tesselator& t = Tesselator::instance; - t.begin(); + t.begin(4); #ifdef ENH_SHADE_HELD_TILES - float bright = pItemEntity->getBrightness(1.0f); + float bright = itemEntity.getBrightness(1.0f); t.color(bright, bright, bright); #endif - t.normal(0.0f, 1.0f, 0.0f); + t.normal(Vec3::UNIT_Y); t.vertexUV(-0.5f, -0.25f, 0.0f, float(16 * (icon % 16)) / 256.0f, float(16 * (icon / 16 + 1)) / 256.0f); t.vertexUV(+0.5f, -0.25f, 0.0f, float(16 * (icon % 16 + 1)) / 256.0f, float(16 * (icon / 16 + 1)) / 256.0f); t.vertexUV(+0.5f, +0.75f, 0.0f, float(16 * (icon % 16 + 1)) / 256.0f, float(16 * (icon / 16)) / 256.0f); t.vertexUV(-0.5f, +0.75f, 0.0f, float(16 * (icon % 16)) / 256.0f, float(16 * (icon / 16)) / 256.0f); - t.draw(); - - glPopMatrix(); + t.draw(m_materials.entity_alphatest); } } +#if MCE_GFX_API_OGL glDisable(GL_RESCALE_NORMAL); - glPopMatrix(); +#endif } void ItemRenderer::blitRect(Tesselator& t, int x, int y, int w, int h, int color) { - t.begin(); + // UNUSED + t.begin(4); t.color(color); t.vertex(float(x), float(y), 0.0f); t.vertex(float(x), float(y + h), 0.0f); t.vertex(float(x + w), float(y + h), 0.0f); t.vertex(float(x + w), float(y), 0.0f); - t.draw(); + t.draw(m_itemMaterials.ui_fill_color); } void ItemRenderer::blit(int dx, int dy, int sx, int sy, int tw, int th) @@ -151,12 +178,12 @@ void ItemRenderer::blit(int dx, int dy, int sx, int sy, int tw, int th) float uw = float(tw), uh = float(th); float vx = float(sx), vy = float(sy); - t.begin(); + t.begin(4); t.vertexUV(ex, ey + uh, 0.0f, float(vx) / 256.0f, float(vy + uh) / 256.0f); t.vertexUV(ex + uw, ey + uh, 0.0f, float(vx + uw) / 256.0f, float(vy + uh) / 256.0f); t.vertexUV(ex + uw, ey, 0.0f, float(vx + uw) / 256.0f, float(vy) / 256.0f); t.vertexUV(ex, ey, 0.0f, float(vx) / 256.0f, float(vy) / 256.0f); - t.draw(); + t.draw(m_itemMaterials.ui_textured); } void ItemRenderer::renderGuiItemOverlay(Font* font, Textures* textures, ItemInstance* instance, int x, int y) @@ -232,28 +259,22 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures, ItemInstance* i #else textures->loadAndBindTexture(C_TERRAIN_NAME); - //glDisable(GL_BLEND); - //glEnable(GL_DEPTH_TEST); - - glPushMatrix(); + MatrixStack::Ref matrix = MatrixStack::World.push(); // scale, rotate, and translate the tile onto the correct screen coordinate - glTranslatef((GLfloat)x + 8, (GLfloat)y + 8, -8); - glScalef(10, 10, 10); - glRotatef(210.0f, 1.0f, 0.0f, 0.0f); - glRotatef(45.0f, 0.0f, 1.0f, 0.0f); + matrix->translate(Vec3(x + 8, y + 8, -8)); + matrix->scale(10); + matrix->rotate(210.0f, Vec3::UNIT_X); + matrix->rotate(45.0f, Vec3::UNIT_Y); // TODO: Why can't we rotate stairs 90deg also? What's rotating them!? if (pTile->getRenderShape() != SHAPE_STAIRS) - glRotatef(-90.0f, 0.0f, 1.0f, 0.0f); + { + matrix->rotate(-90.0f, Vec3::UNIT_Y); + } - tileRenderer->renderTile(pTile, instance->getAuxValue(), 1.0f, true); + m_pTileRenderer->renderTile(FullTile(pTile, instance->getAuxValue()), m_itemMaterials.ui_item, 1.0f, true); #undef PARM_HACK - - glPopMatrix(); - - //glDisable(GL_DEPTH_TEST); - //glEnable(GL_BLEND); #endif } else if (instance->getIcon() >= 0) diff --git a/source/client/renderer/entity/ItemRenderer.hpp b/source/client/renderer/entity/ItemRenderer.hpp index 2be7babd9..6701a22f2 100644 --- a/source/client/renderer/entity/ItemRenderer.hpp +++ b/source/client/renderer/entity/ItemRenderer.hpp @@ -14,18 +14,38 @@ class ItemRenderer : public EntityRenderer { +protected: + class Materials + { + public: + mce::MaterialPtr ui_fill_color; + mce::MaterialPtr ui_textured; + mce::MaterialPtr ui_texture_and_color; + mce::MaterialPtr ui_item; // only supposed to be in TileRenderer + mce::MaterialPtr ui_item_glint; + + Materials(); + }; + +private: + static ItemRenderer* singletonPtr; +public: + static ItemRenderer& singleton(); + public: ItemRenderer(); - void render(Entity* entity, const Vec3& pos, float rot, float a) override; + void render(const Entity& entity, const Vec3& pos, float rot, float a) override; void blitRect(Tesselator&, int, int, int, int, int); - static void blit(int, int, int, int, int, int); - static void renderGuiItem(Font*, Textures*, ItemInstance*, int, int, bool); - static void renderGuiItemOverlay(Font*, Textures*, ItemInstance*, int, int); + void blit(int dx, int dy, int sx, int sy, int tw, int th); + void renderGuiItem(Font*, Textures*, ItemInstance*, int, int, bool); + void renderGuiItemOverlay(Font*, Textures*, ItemInstance*, int, int); +private: + TileRenderer* m_pTileRenderer; + Materials m_itemMaterials; public: Random m_random; - static TileRenderer* tileRenderer; }; diff --git a/source/client/renderer/entity/ItemSpriteRenderer.cpp b/source/client/renderer/entity/ItemSpriteRenderer.cpp index aab2b1e99..640b94008 100644 --- a/source/client/renderer/entity/ItemSpriteRenderer.cpp +++ b/source/client/renderer/entity/ItemSpriteRenderer.cpp @@ -6,12 +6,18 @@ ItemSpriteRenderer::ItemSpriteRenderer(int sprite) m_sprite = sprite; } -void ItemSpriteRenderer::render(Entity* pEntity, const Vec3& pos, float rot, float a) +void ItemSpriteRenderer::render(const Entity& entity, const Vec3& pos, float rot, float a) { - glPushMatrix(); - glTranslatef(pos.x, pos.y, pos.z); + MatrixStack::Ref matrix = MatrixStack::World.push(); + + matrix->translate(pos); + +#if MCE_GFX_API_OGL glEnable(GL_RESCALE_NORMAL); - glScalef(0.5f, 0.5f, 0.5f); +#endif + + matrix->scale(0.5f); + bindTexture(C_ITEMS_NAME); /*float texU_1 = float(16 * (m_sprite % 16)) / 256.0f; @@ -19,19 +25,20 @@ void ItemSpriteRenderer::render(Entity* pEntity, const Vec3& pos, float rot, flo float texV_1 = float(16 * (m_sprite / 16)) / 256.0f; float texV_2 = float(16 * (m_sprite / 16 + 1)) / 256.0f;*/ - glRotatef(180.0f - m_pDispatcher->m_rot.x, 0.0f, 1.0f, 0.0f); - glRotatef(-m_pDispatcher->m_rot.y, 1.0f, 0.0f, 0.0f); + matrix->rotate(180.0f - m_pDispatcher->m_rot.x, Vec3::UNIT_Y); + matrix->rotate(-m_pDispatcher->m_rot.y, Vec3::UNIT_X); Tesselator& t = Tesselator::instance; - t.begin(); - t.color(1.0f, 1.0f, 1.0f); - t.normal(0.0f, 1.0f, 0.0f); + t.begin(4); + t.color(Color::WHITE); + t.normal(Vec3::UNIT_Y); t.vertexUV(-0.5f, -0.25f, 0.0f, float(16 * (m_sprite % 16)) / 256.0f, float(16 * (m_sprite / 16 + 1)) / 256.0f); t.vertexUV(+0.5f, -0.25f, 0.0f, float(16 * (m_sprite % 16 + 1)) / 256.0f, float(16 * (m_sprite / 16 + 1)) / 256.0f); t.vertexUV(+0.5f, +0.75f, 0.0f, float(16 * (m_sprite % 16 + 1)) / 256.0f, float(16 * (m_sprite / 16)) / 256.0f); t.vertexUV(-0.5f, +0.75f, 0.0f, float(16 * (m_sprite % 16)) / 256.0f, float(16 * (m_sprite / 16)) / 256.0f); - t.draw(); + t.draw(m_shaderMaterials.entity_alphatest); +#if MCE_GFX_API_OGL glDisable(GL_RESCALE_NORMAL); - glPopMatrix(); +#endif } diff --git a/source/client/renderer/entity/ItemSpriteRenderer.hpp b/source/client/renderer/entity/ItemSpriteRenderer.hpp index 0adda1cb6..ff73fa7bf 100644 --- a/source/client/renderer/entity/ItemSpriteRenderer.hpp +++ b/source/client/renderer/entity/ItemSpriteRenderer.hpp @@ -6,7 +6,7 @@ class ItemSpriteRenderer : public EntityRenderer { public: ItemSpriteRenderer(int sprite); - void render(Entity* entity, const Vec3& pos, float rot, float a) override; + void render(const Entity& entity, const Vec3& pos, float rot, float a) override; public: int m_sprite; diff --git a/source/client/renderer/entity/MobRenderer.cpp b/source/client/renderer/entity/MobRenderer.cpp index 0d19a1e48..1ce395bb2 100644 --- a/source/client/renderer/entity/MobRenderer.cpp +++ b/source/client/renderer/entity/MobRenderer.cpp @@ -9,8 +9,9 @@ #include #include "MobRenderer.hpp" -#include "EntityRenderDispatcher.hpp" #include "client/app/Minecraft.hpp" +#include "renderer/ShaderConstants.hpp" +#include "EntityRenderDispatcher.hpp" MobRenderer::MobRenderer(Model* pModel, float f) { @@ -30,173 +31,135 @@ void MobRenderer::setArmor(Model* model) m_pArmorModel = model; } -int MobRenderer::prepareArmor(Mob* mob, int a, float b) +int MobRenderer::prepareArmor(const Mob& mob, int a, float b) { return 0; } -void MobRenderer::additionalRendering(Mob* mob, float f) +void MobRenderer::additionalRendering(const Mob& mob, float f) { } -float MobRenderer::getAttackAnim(Mob* mob, float f) +float MobRenderer::getAttackAnim(const Mob& mob, float f) { - return mob->getAttackAnim(f); + return mob.getAttackAnim(f); } -float MobRenderer::getBob(Mob* mob, float f) +float MobRenderer::getBob(const Mob& mob, float f) { - return float(mob->m_tickCount) + f; + return float(mob.m_tickCount) + f; } -float MobRenderer::getFlipDegrees(Mob* mob) +float MobRenderer::getFlipDegrees(const Mob& mob) { return 90.0f; } -int MobRenderer::getOverlayColor(Mob* mob, float a, float b) -{ - return 0; -} - -void MobRenderer::scale(Mob*, float) -{ - -} - -void MobRenderer::setupPosition(Entity* entity, const Vec3& pos) +void MobRenderer::setupPosition(const Entity& entity, const Vec3& pos, Matrix& matrix) { // @HACK: I eye-balled a corrective offset of 1/13, since I still can't figure out why all mobs are floating - Brent // This was due to "0.059375f" being used for scale instead of "0.0625f" - glTranslatef(pos.x, pos.y, pos.z); + matrix.translate(pos); } -void MobRenderer::setupRotations(Entity* entity, float bob, float bodyRot, float a) +void MobRenderer::setupRotations(const Entity& entity, float bob, float bodyRot, Matrix& matrix, float a) { - glRotatef(180.0f - bodyRot, 0.0f, 1.0f, 0.0f); + matrix.rotate(180.0f - bodyRot, Vec3::UNIT_Y); - Mob* mob = (Mob*)entity; - if (mob->m_deathTime > 0) + const Mob& mob = (const Mob&)entity; + if (mob.m_deathTime > 0) { - float t = Mth::sqrt((float(mob->m_deathTime) + a - 1.0f) / 20.0f * 1.6f); + float t = Mth::sqrt((float(mob.m_deathTime) + a - 1.0f) / 20.0f * 1.6f); if (t > 1.0f) t = 1.0f; - glRotatef(getFlipDegrees(mob) * t, 0.0f, 0.0f, 1.0f); + matrix.rotate(getFlipDegrees(mob) * t, Vec3::UNIT_Z); } } -void MobRenderer::render(Entity* entity, const Vec3& pos, float unused, float f) +void MobRenderer::scale(const Mob& mob, Matrix& matrix, float a) { - Mob* pMob = (Mob*)entity; - glPushMatrix(); - glDisable(GL_CULL_FACE); +} - m_pModel->field_4 = getAttackAnim(pMob, f); - m_pModel->m_bRiding = false; - m_pModel->m_bIsBaby = pMob->isBaby(); +void MobRenderer::render(const Entity& entity, const Vec3& pos, float unused, float f) +{ + const Mob& mob = (const Mob&)entity; - if (m_pArmorModel != nullptr) { - m_pArmorModel->m_bRiding = m_pModel->m_bRiding; - m_pArmorModel->m_bIsBaby = m_pModel->m_bIsBaby; - } + MatrixStack::Ref matrix = MatrixStack::World.push(); - float aYaw = pMob->m_oRot.x + (pMob->m_rot.x - pMob->m_oRot.x) * f; - float aPitch = pMob->m_oRot.y + (pMob->m_rot.y - pMob->m_oRot.y) * f; - float fBob = getBob(pMob, f); - float fSmth = pMob->field_EC + (pMob->field_E8 - pMob->field_EC) * f; + m_pModel->field_4 = getAttackAnim(mob, f); + m_pModel->m_bRiding = false; + m_pModel->m_bIsBaby = mob.isBaby(); - setupPosition(pMob, Vec3(pos.x, pos.y - pMob->m_heightOffset, pos.z)); - setupRotations(pMob, fBob, fSmth, f); + if (m_pArmorModel != nullptr) + { + m_pArmorModel->m_bRiding = m_pModel->m_bRiding; + m_pArmorModel->m_bIsBaby = m_pModel->m_bIsBaby; + } - float fScale = 0.0625f; // the scale variable according to b1.2_02 - glScalef(-1.0f, -1.0f, 1.0f); - scale(pMob, f); - //glTranslatef(0.0f, -1.5078f, 0.0f); - glTranslatef(0.0f, -24.0f * fScale - (1.0f / 128.0f), 0.0f); + float aYaw = mob.m_oRot.x + (mob.m_rot.x - mob.m_oRot.x) * f; + float aPitch = mob.m_oRot.y + (mob.m_rot.y - mob.m_oRot.y) * f; + float fBob = getBob(mob, f); + float fSmth = mob.field_EC + (mob.field_E8 - mob.field_EC) * f; - float x1 = pMob->field_128 + (pMob->m_walkAnimSpeed - pMob->field_128) * f; - if (x1 > 1.0f) - x1 = 1.0f; - float x2 = pMob->field_130 - pMob->m_walkAnimSpeed * (1.0f - f); + setupPosition(mob, Vec3(pos.x, pos.y - mob.m_heightOffset, pos.z), matrix); + setupRotations(mob, fBob, fSmth, matrix, f); - bindTexture(pMob->getTexture()); - glEnable(GL_ALPHA_TEST); + constexpr float fScale = 0.0625f; // the scale variable according to b1.2_02 + matrix->scale(Vec3(-1.0f, -1.0f, 1.0f)); + scale(mob, matrix, f); + matrix->translate(Vec3(0.0f, -24.0f * fScale - (1.0f / 128.0f), 0.0f)); - m_pModel->setBrightness(entity->getBrightness(1.0f)); - m_pModel->prepareMobModel(pMob, x2, x1, f); - m_pModel->render(x2, x1, fBob, aYaw - fSmth, aPitch, fScale); // last float here (scale) was set to "0.059375f" for some reason + float x1 = mob.field_128 + (mob.m_walkAnimSpeed - mob.field_128) * f; + if (x1 > 1.0f) + x1 = 1.0f; + float x2 = mob.field_130 - mob.m_walkAnimSpeed * (1.0f - f); - for (int i = 0; i < 4; i++) - { - if (prepareArmor(pMob, i, f)) - { - m_pArmorModel->render(x2, x1, fBob, aYaw - fSmth, aPitch, fScale); - glDisable(GL_BLEND); - glEnable(GL_ALPHA_TEST); - } - } + bindTexture(mob.getTexture()); - additionalRendering(pMob, f); - - float fBright = pMob->getBrightness(f); - int iOverlayColor = getOverlayColor(pMob, fBright, f); + m_pModel->setBrightness(entity.getBrightness(1.0f)); + m_pModel->prepareMobModel(mob, x2, x1, f); + m_pModel->render(x2, x1, fBob, aYaw - fSmth, aPitch, fScale); - if (GET_ALPHA(iOverlayColor) || pMob->m_hurtTime > 0 || pMob->m_deathTime > 0) - { - glDisable(GL_TEXTURE_2D); - glDisable(GL_ALPHA_TEST); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glDepthFunc(GL_EQUAL); - - if (pMob->m_hurtTime > 0 || pMob->m_deathTime > 0) + for (int i = 0; i < 4; i++) { - glColor4f(fBright, 0.0f, 0.0f, 0.4f); - m_pModel->render(x2, x1, fBob, aYaw - fSmth, aPitch, fScale); // was 0.059375f. Why? - - for (int i = 0; i < 4; i++) + if (prepareArmor(mob, i, f)) { - if (prepareArmor(pMob, i, f)) - { - glColor4f(fBright, 0.0f, 0.0f, 0.4f); - m_pArmorModel->render(x2, x1, fBob, aYaw - fSmth, aPitch, fScale); - } + m_pArmorModel->render(x2, x1, fBob, aYaw - fSmth, aPitch, fScale); } - } - if (GET_ALPHA(iOverlayColor)) + + additionalRendering(mob, f); + + Color overlayColor = getOverlayColor(mob, f); + if (overlayColor.a > 0) { - float r = float(GET_RED(iOverlayColor)) / 255.0f; - float g = float(GET_GREEN(iOverlayColor)) / 255.0f; - float b = float(GET_BLUE(iOverlayColor)) / 255.0f; - float aa = float(GET_ALPHA(iOverlayColor)) / 255.0f; - glColor4f(r, g, b, aa); + currentShaderColor = overlayColor; + mce::MaterialPtr* pMaterial = m_pModel->m_pMaterial; + m_pModel->m_pMaterial = &m_pModel->m_materials.entity_color_overlay; m_pModel->render(x2, x1, fBob, aYaw - fSmth, aPitch, fScale); // same here for (int i = 0; i < 4; i++) { - if (prepareArmor(pMob, i, f)) + if (prepareArmor(mob, i, f)) { - glColor4f(r, g, b, aa); + mce::MaterialPtr* pMaterial = m_pArmorModel->m_pMaterial; + m_pArmorModel->m_pMaterial = &m_pArmorModel->m_materials.entity_color_overlay; + + currentShaderColor = overlayColor; m_pArmorModel->render(x2, x1, fBob, aYaw - fSmth, aPitch, fScale); + + m_pArmorModel->m_pMaterial = pMaterial; } } + m_pModel->m_pMaterial = pMaterial; } - - glDepthFunc(GL_LEQUAL); - glDisable(GL_BLEND); - glEnable(GL_TEXTURE_2D); - glEnable(GL_ALPHA_TEST); } - - glEnable(GL_CULL_FACE); - glPopMatrix(); - renderName(pMob, pos); + renderName(mob, pos); } void MobRenderer::onGraphicsReset() @@ -204,72 +167,58 @@ void MobRenderer::onGraphicsReset() m_pModel->onGraphicsReset(); } -void MobRenderer::renderName(Mob* mob, const Vec3& pos) +void MobRenderer::renderName(const Mob& mob, const Vec3& pos) { - if (mob->isPlayer()) + if (mob.isPlayer()) { - Player* player = (Player*)mob; - if (player == m_pDispatcher->m_pMinecraft->m_pLocalPlayer) + const Player& player = (const Player&)mob; + if (&player == m_pDispatcher->m_pMinecraft->m_pLocalPlayer) return; // @TODO: don't know why but I have to add this correction. look into it and fix it! - renderNameTag(mob, player->m_name, Vec3(pos.x, pos.y - 1.5f, pos.z), mob->isSneaking() ? 32 : 64); + renderNameTag(mob, player.m_name, Vec3(pos.x, pos.y - 1.5f, pos.z), mob.isSneaking() ? 32 : 64); } else { if (m_pDispatcher->m_pOptions->m_bDebugText) { std::stringstream ss; - ss << mob->m_EntityID; + ss << mob.m_EntityID; renderNameTag(mob, ss.str(), pos, 64); } } } -void MobRenderer::renderNameTag(Mob* mob, const std::string& str, const Vec3& pos, int a) +void MobRenderer::renderNameTag(const Mob& mob, const std::string& str, const Vec3& pos, int a) { - if (mob->distanceToSqr(m_pDispatcher->m_pMob) > float(a * a)) + if (mob.distanceToSqr(m_pDispatcher->m_pCamera) > float(a * a)) return; Font* font = getFont(); - glPushMatrix(); - glTranslatef(pos.x + 0.0f, pos.y + 2.3f, pos.z); -#ifndef __EMSCRIPTEN__ - glNormal3f(0.0f, 1.0f, 0.0f); -#endif + MatrixStack::Ref matrix = MatrixStack::World.push(); + matrix->translate(Vec3(pos.x + 0.0f, pos.y + 2.3f, pos.z)); + // billboard the name towards the camera - glRotatef(-m_pDispatcher->m_rot.x, 0.0f, 1.0f, 0.0f); - glRotatef(+m_pDispatcher->m_rot.y, 1.0f, 0.0f, 0.0f); - glScalef(-0.026667f, -0.026667f, 0.026667f); - glDepthMask(false); - glDisable(GL_DEPTH_TEST); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glDisable(GL_TEXTURE_2D); + matrix->rotate(-m_pDispatcher->m_rot.x, Vec3::UNIT_Y); + matrix->rotate(+m_pDispatcher->m_rot.y, Vec3::UNIT_X); + matrix->scale(Vec3(-0.026667f, -0.026667f, 0.026667f)); + currentShaderColor = Color(0.0f, 0.0f, 0.0f, 0.25f); + Tesselator& t = Tesselator::instance; - t.begin(); + t.begin(4); int width = font->width(str); float widthHalf = float(width / 2); - t.color(0.0f, 0.0f, 0.0f, 0.25f); + t.normal(Vec3::UNIT_Y); t.vertex(-1.0f - widthHalf, -1.0f, 0.0f); t.vertex(-1.0f - widthHalf, 8.0f, 0.0f); t.vertex(widthHalf + 1.0f, 8.0f, 0.0f); t.vertex(widthHalf + 1.0f, -1.0f, 0.0f); - t.draw(); - - glEnable(GL_TEXTURE_2D); + t.draw(m_materials.name_tag); font->draw(str, -font->width(str) / 2, 0, 0x20FFFFFF); - glEnable(GL_DEPTH_TEST); - glDepthMask(true); - font->draw(str, -font->width(str) / 2, 0, 0xFFFFFFFF); - - glDisable(GL_BLEND); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glPopMatrix(); } diff --git a/source/client/renderer/entity/MobRenderer.hpp b/source/client/renderer/entity/MobRenderer.hpp index 115ad81ec..f8f1f66a9 100644 --- a/source/client/renderer/entity/MobRenderer.hpp +++ b/source/client/renderer/entity/MobRenderer.hpp @@ -9,6 +9,7 @@ #pragma once #include "EntityRenderer.hpp" +#include "client/model/models/Model.hpp" class MobRenderer : public EntityRenderer { @@ -17,19 +18,18 @@ class MobRenderer : public EntityRenderer virtual ~MobRenderer(); void setArmor(Model*); - virtual void render(Entity*, const Vec3& pos, float, float) override; + virtual void render(const Entity& entity, const Vec3& pos, float, float) override; virtual void onGraphicsReset() override; - virtual int prepareArmor(Mob*, int, float); - virtual void setupPosition(Entity*, const Vec3& pos); - virtual void setupRotations(Entity*, float bob, float bodyRot, float a); - virtual float getAttackAnim(Mob*, float); - virtual float getBob(Mob*, float); - virtual float getFlipDegrees(Mob*); - virtual int getOverlayColor(Mob*, float, float); - virtual void scale(Mob*, float); - virtual void renderName(Mob*, const Vec3& pos); - virtual void renderNameTag(Mob*, const std::string&, const Vec3& pos, int); - virtual void additionalRendering(Mob*, float); + virtual int prepareArmor(const Mob& mob, int, float); + virtual void setupPosition(const Entity& entity, const Vec3& pos, Matrix& matrix); + virtual void setupRotations(const Entity& entity, float bob, float bodyRot, Matrix& matrix, float a); + virtual void scale(const Mob& mob, Matrix& matrix, float a); + virtual float getAttackAnim(const Mob& mob, float); + virtual float getBob(const Mob& mob, float f); + virtual float getFlipDegrees(const Mob& mob); + virtual void renderName(const Mob& mob, const Vec3& pos); + virtual void renderNameTag(const Mob& mob, const std::string&, const Vec3& pos, int); + virtual void additionalRendering(const Mob& mob, float); public: Model* m_pModel; diff --git a/source/client/renderer/entity/RocketRenderer.cpp b/source/client/renderer/entity/RocketRenderer.cpp index 3cd089a08..cccdc6c20 100644 --- a/source/client/renderer/entity/RocketRenderer.cpp +++ b/source/client/renderer/entity/RocketRenderer.cpp @@ -15,24 +15,22 @@ RocketRenderer::RocketRenderer() : m_shadowRadius = 0.5f; } -void RocketRenderer::render(Entity* entity, const Vec3& pos, float rot, float a) +void RocketRenderer::render(const Entity& entity, const Vec3& pos, float rot, float a) { - glPushMatrix(); - glTranslatef(pos.x, pos.y, pos.z); + MatrixStack::Ref matrix = MatrixStack::World.push(); + matrix->translate(pos); - float brightness = entity->getBrightness(1.0f); + float brightness = entity.getBrightness(1.0f); bindTexture(C_ITEMS_NAME); - m_renderer.renderTile(&m_tile, 0, brightness); - - glPopMatrix(); + m_renderer.renderTile(FullTile(&m_tile, 0), m_materials.entity_alphatest, brightness); } FakeRocketTile::FakeRocketTile() : Tile(0, 16*2+14, Material::plant) { } -int FakeRocketTile::getRenderShape() const +eRenderShape FakeRocketTile::getRenderShape() const { return SHAPE_CROSS; } diff --git a/source/client/renderer/entity/RocketRenderer.hpp b/source/client/renderer/entity/RocketRenderer.hpp index 4280e5377..4a60febb7 100644 --- a/source/client/renderer/entity/RocketRenderer.hpp +++ b/source/client/renderer/entity/RocketRenderer.hpp @@ -17,14 +17,14 @@ class FakeRocketTile : public Tile { public: FakeRocketTile(); - int getRenderShape() const override; + eRenderShape getRenderShape() const override; }; class RocketRenderer : public EntityRenderer { public: RocketRenderer(); - void render(Entity* entity, const Vec3& pos, float rot, float a) override; + void render(const Entity& entity, const Vec3& pos, float rot, float a) override; public: TileRenderer m_renderer; diff --git a/source/client/renderer/entity/SheepRenderer.cpp b/source/client/renderer/entity/SheepRenderer.cpp index f3f65a155..3e864a296 100644 --- a/source/client/renderer/entity/SheepRenderer.cpp +++ b/source/client/renderer/entity/SheepRenderer.cpp @@ -1,4 +1,5 @@ #include "SheepRenderer.hpp" +#include "renderer/ShaderConstants.hpp" SheepRenderer::SheepRenderer(Model* pModel, Model* pArmor, float f) : MobRenderer(pModel, f) { @@ -9,15 +10,16 @@ SheepRenderer::~SheepRenderer() { } -int SheepRenderer::prepareArmor(Mob* mob, int layer, float a) +int SheepRenderer::prepareArmor(const Mob& mob, int layer, float a) { - Sheep* pSheep = (Sheep*)mob; - if (layer == 0 && !pSheep->isSheared()) + const Sheep& sheep = (const Sheep&)mob; + if (layer == 0 && !sheep.isSheared()) { bindTexture("/mob/sheep_fur.png"); - float brightness = pSheep->getBrightness(a); - int color = pSheep->getColor(); - glColor4f(brightness * Sheep::COLOR[color][0], brightness * Sheep::COLOR[color][1], brightness * Sheep::COLOR[color][2], 1.0f); + float brightness = sheep.getBrightness(a); + int color = sheep.getColor(); + currentShaderColor = Sheep::COLOR[color]; + currentShaderDarkColor = Color(brightness, brightness, brightness); return 1; } else diff --git a/source/client/renderer/entity/SheepRenderer.hpp b/source/client/renderer/entity/SheepRenderer.hpp index 5e31e0585..4bf929492 100644 --- a/source/client/renderer/entity/SheepRenderer.hpp +++ b/source/client/renderer/entity/SheepRenderer.hpp @@ -9,5 +9,5 @@ class SheepRenderer : public MobRenderer SheepRenderer(Model*, Model*, float); ~SheepRenderer(); protected: - virtual int prepareArmor(Mob* mob, int, float) override; + virtual int prepareArmor(const Mob& mob, int, float) override; }; diff --git a/source/client/renderer/entity/SpiderRenderer.cpp b/source/client/renderer/entity/SpiderRenderer.cpp index 09be5dd2e..0e6fc6a8c 100644 --- a/source/client/renderer/entity/SpiderRenderer.cpp +++ b/source/client/renderer/entity/SpiderRenderer.cpp @@ -1,6 +1,7 @@ #include "SpiderRenderer.hpp" +#include "client/model/models/SpiderModel.hpp" +#include "renderer/ShaderConstants.hpp" #include "world/entity/Mob.hpp" -#include "client/model/SpiderModel.hpp" SpiderRenderer::SpiderRenderer() : MobRenderer(new SpiderModel, 1.0f) { @@ -11,7 +12,7 @@ SpiderRenderer::~SpiderRenderer() { } -int SpiderRenderer::prepareArmor(Mob* spider, int layer, float a) +int SpiderRenderer::prepareArmor(const Mob& spider, int layer, float a) { if (layer != 0) return 0; @@ -19,11 +20,9 @@ int SpiderRenderer::prepareArmor(Mob* spider, int layer, float a) if (!bindTexture("mob/spider_eyes.png", false)) return 0; - float br = (1.0f - spider->getBrightness(1.0f)) * 0.5f; - glEnable(GL_BLEND); - glDisable(GL_ALPHA_TEST); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor4f(1.0f, 1.0f, 1.0f, br); + float br = (1.0f - spider.getBrightness(1.0f)) * 0.5f; + currentShaderColor = Color::WHITE; + currentShaderDarkColor = Color(1.0f, 1.0f, 1.0f, br); return 1; } \ No newline at end of file diff --git a/source/client/renderer/entity/SpiderRenderer.hpp b/source/client/renderer/entity/SpiderRenderer.hpp index 1ddbbca02..0465e849e 100644 --- a/source/client/renderer/entity/SpiderRenderer.hpp +++ b/source/client/renderer/entity/SpiderRenderer.hpp @@ -8,6 +8,6 @@ class SpiderRenderer : public MobRenderer SpiderRenderer(); ~SpiderRenderer(); - float getFlipDegrees(Mob*) override { return 180.0f; } - int prepareArmor(Mob* spider, int layer, float a) override; + float getFlipDegrees(const Mob& mob) override { return 180.0f; } + int prepareArmor(const Mob& spider, int layer, float a) override; }; diff --git a/source/client/renderer/entity/TntRenderer.cpp b/source/client/renderer/entity/TntRenderer.cpp index 318d6a02f..ff2380f87 100644 --- a/source/client/renderer/entity/TntRenderer.cpp +++ b/source/client/renderer/entity/TntRenderer.cpp @@ -7,21 +7,29 @@ ********************************************************************/ #include "TntRenderer.hpp" +#include "client/renderer/renderer/RenderMaterialGroup.hpp" +#include "renderer/ShaderConstants.hpp" +#include "renderer/MatrixStack.hpp" #include "world/entity/PrimedTnt.hpp" +TntRenderer::Materials::Materials() +{ + MATERIAL_PTR(switchable, primed_tnt); +} + TntRenderer::TntRenderer() { m_shadowRadius = 0.5f; } -void TntRenderer::render(Entity* entity, const Vec3& pos, float rot, float a) +void TntRenderer::render(const Entity& entity, const Vec3& pos, float rot, float a) { - PrimedTnt* tnt = (PrimedTnt*)entity; + const PrimedTnt& tnt = (const PrimedTnt&)entity; - glPushMatrix(); - glTranslatef(pos.x, pos.y, pos.z); + MatrixStack::Ref matrix = MatrixStack::World.push(); + matrix->translate(pos); - float m = 1.0f + float(tnt->m_fuseTimer) - a; + float m = 1.0f + float(tnt.m_fuseTimer) - a; if (m < 10.0f) { float n = (m / -10.0f) + 1.0f; @@ -31,7 +39,7 @@ void TntRenderer::render(Entity* entity, const Vec3& pos, float rot, float a) n = 1.0f; float scale = 1.0f + 0.3f * n * n * n * n; - glScalef(scale, scale, scale); + matrix->scale(scale); } bindTexture(C_TERRAIN_NAME); @@ -46,23 +54,16 @@ void TntRenderer::render(Entity* entity, const Vec3& pos, float rot, float a) #define ARGPATCH #endif - m_tileRenderer.renderTile(Tile::tnt, 0 ARGPATCH); + m_tileRenderer.renderTile(FullTile(Tile::tnt, 0), mce::MaterialPtr::NONE ARGPATCH); // @NOTE: Converting to a uint8 for whatever reason - if (((uint8_t(tnt->m_fuseTimer) / 5) & 1) == 0) + if (((uint8_t(tnt.m_fuseTimer) / 5) & 1) == 0) { - glDisable(GL_TEXTURE_2D); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA); - glColor4f(1.0f, 1.0f, 1.0f, (((float(tnt->m_fuseTimer) - a) + 1.0f) / -100.0f + 1.0f) * 0.8f); - m_tileRenderer.renderTile(Tile::tnt, 0 ARGPATCH); - glColor4f(1.0f, 1.0, 1.0f, 1.0f); - glDisable(GL_BLEND); - glEnable(GL_TEXTURE_2D); + currentShaderColor = Color::WHITE; + currentShaderDarkColor = Color(1.0f, 1.0f, 1.0f, (((float(tnt.m_fuseTimer) - a) + 1.0f) / -100.0f + 1.0f) * 0.8f); + m_tileRenderer.renderTile(FullTile(Tile::tnt, 0), m_shaderMaterials.entity ARGPATCH); } - glPopMatrix(); - #ifdef ARGPATCH #undef ARGPATCH #endif diff --git a/source/client/renderer/entity/TntRenderer.hpp b/source/client/renderer/entity/TntRenderer.hpp index 81f3be2ad..24d6834c9 100644 --- a/source/client/renderer/entity/TntRenderer.hpp +++ b/source/client/renderer/entity/TntRenderer.hpp @@ -13,10 +13,19 @@ class TntRenderer : public EntityRenderer { +protected: + class Materials + { + public: + mce::MaterialPtr primed_tnt; + + Materials(); + }; + public: TntRenderer(); - void render(Entity*entity, const Vec3& pos, float rot, float a) override; + void render(const Entity& entity, const Vec3& pos, float rot, float a) override; public: TileRenderer m_tileRenderer; diff --git a/source/client/renderer/entity/TripodCameraRenderer.cpp b/source/client/renderer/entity/TripodCameraRenderer.cpp index aa29a683a..29458904e 100644 --- a/source/client/renderer/entity/TripodCameraRenderer.cpp +++ b/source/client/renderer/entity/TripodCameraRenderer.cpp @@ -8,6 +8,7 @@ #include "TripodCameraRenderer.hpp" #include "client/app/Minecraft.hpp" +#include "renderer/ShaderConstants.hpp" TripodCameraRenderer::TripodCameraRenderer() : m_tile(), @@ -15,33 +16,35 @@ TripodCameraRenderer::TripodCameraRenderer() : { m_modelPart.addBox(-4.0f, -4.0f, -6.0f, 8, 8, 10); m_modelPart.m_pos.y = 11.0f; + m_modelPart.m_pMaterial = &m_shaderMaterials.entity; m_shadowRadius = 0.5f; } -float TripodCameraRenderer::getFlashTime(TripodCamera* camera, float f) +float TripodCameraRenderer::getFlashTime(const TripodCamera& camera, float f) { - if (camera->field_B90 > 7 || camera->field_B90 < 0) + if (camera.field_B90 > 7 || camera.field_B90 < 0) return -1.0f; - return 0.125f * (float(camera->field_B90) - f); + return 0.125f * (float(camera.field_B90) - f); } -void TripodCameraRenderer::render(Entity* entity, const Vec3& pos, float rot, float a) +void TripodCameraRenderer::render(const Entity& entity, const Vec3& pos, float rot, float a) { - glPushMatrix(); - glTranslatef(pos.x, pos.y, pos.z); - m_modelPart.m_rot.x = 0.017453f * (180.0f + 0.5f * entity->m_rot.y); - m_modelPart.m_rot.y = -0.017453f * entity->m_rot.x; + MatrixStack::Ref matrix = MatrixStack::World.push(); + matrix->translate(pos); + + m_modelPart.m_rot.x = 0.017453f * (180.0f + 0.5f * entity.m_rot.y); + m_modelPart.m_rot.y = -0.017453f * entity.m_rot.x; //Tesselator& t = Tesselator::instance; //t.color(1.0f, 1.0f, 1.0f); - float brightness = entity->getBrightness(1.0f); + float brightness = entity.getBrightness(1.0f); bindTexture(C_ITEMS_NAME); //t.begin(); //m_renderer.tesselateCrossTexture(&m_tile, 0, -0.5f, -0.5f, -0.5f); - m_renderer.renderTile(&m_tile, 0, brightness); + m_renderer.renderTile(FullTile(&m_tile, 0), m_shaderMaterials.entity_alphatest, brightness, false); //t.draw(); bindTexture("item/camera.png"); @@ -50,34 +53,28 @@ void TripodCameraRenderer::render(Entity* entity, const Vec3& pos, float rot, fl Entity* pHREntity = m_pDispatcher->m_pMinecraft->m_hitResult.m_pEnt; - float time = getFlashTime((TripodCamera*)entity, a); + const TripodCamera& camera = (const TripodCamera&)entity; + + float time = getFlashTime(camera, a); if (time >= 0.0f) { - glColor4f(1.0f, 1.0f, 1.0f, sinf(float(M_PI) * 2.0f * time)); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); // @BUG: overwriting the sinf result with 1.0f + currentShaderColor = Color::WHITE; + currentShaderDarkColor = Color(1.0f, 1.0f, 1.0f, sinf(float(M_PI) * 2.0f * time)); } - if (entity == pHREntity) + if (&entity == pHREntity) { - glDisable(GL_TEXTURE_2D); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // @TODO FIX: With ENH_ENTITY_SHADING on, the cube is fully opaque. - glColor4f(0.5f, 0.5f, 0.5f, 0.5f); - m_modelPart.render(0.0625f); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glDisable(GL_BLEND); - glEnable(GL_TEXTURE_2D); + currentShaderColor = Color(0.5f, 0.5f, 0.5f, 0.5f); + m_modelPart.render(0.0625f, &m_shaderMaterials.entity_color_overlay); } - - glPopMatrix(); } TripodTile::TripodTile() : Tile(0, 243, Material::plant) { } -int TripodTile::getRenderShape() const +eRenderShape TripodTile::getRenderShape() const { return SHAPE_CROSS; } diff --git a/source/client/renderer/entity/TripodCameraRenderer.hpp b/source/client/renderer/entity/TripodCameraRenderer.hpp index 9d7cfd2fa..471fedcbb 100644 --- a/source/client/renderer/entity/TripodCameraRenderer.hpp +++ b/source/client/renderer/entity/TripodCameraRenderer.hpp @@ -9,6 +9,7 @@ #pragma once #include "EntityRenderer.hpp" +#include "client/model/geom/ModelPart.hpp" #include "client/renderer/TileRenderer.hpp" #include "world/tile/Tile.hpp" #include "world/entity/TripodCamera.hpp" @@ -17,7 +18,7 @@ class TripodTile : public Tile { public: TripodTile(); - int getRenderShape() const override; + eRenderShape getRenderShape() const override; }; class TripodCameraRenderer : public EntityRenderer @@ -25,9 +26,9 @@ class TripodCameraRenderer : public EntityRenderer public: TripodCameraRenderer(); - void render(Entity*, const Vec3& pos, float rot, float a) override; + void render(const Entity& entity, const Vec3& pos, float rot, float a) override; - static float getFlashTime(TripodCamera*, float f); + static float getFlashTime(const TripodCamera& camera, float f); public: TileRenderer m_renderer; diff --git a/source/client/renderer/renderer/EntityShaderManager.cpp b/source/client/renderer/renderer/EntityShaderManager.cpp new file mode 100644 index 000000000..8c31c6639 --- /dev/null +++ b/source/client/renderer/renderer/EntityShaderManager.cpp @@ -0,0 +1,38 @@ +#include "EntityShaderManager.hpp" + +#include "client/renderer/renderer/RenderMaterialGroup.hpp" +#include "world/entity/Mob.hpp" + +EntityShaderManager::Materials::Materials() +{ + MATERIAL_PTR(switchable, entity); + MATERIAL_PTR(switchable, entity_color_overlay); + MATERIAL_PTR(switchable, entity_alphatest); + MATERIAL_PTR(switchable, entity_static); +} + +Color EntityShaderManager::getOverlayColor(const Entity& entity, float a) +{ + /*if (entity.isOnFire()) + { + // Java does not apply an overlay color to entities that are on fire + float v6 = powf((float)entity.m_fireTicks / 200, 0.3f); + return Color(0.8f, 0.256f, 0.0f, (v6 + 0.35f) * 0.7f); + }*/ + + if (entity.isMob()) + { + const Mob& mob = (const Mob&)entity; + if (mob.m_hurtTime > 0 || mob.m_deathTime > 0) + { + // fucked up PE values (20% too red) + //return Color(1.0f, 0.0f, 0.0f, 0.6f); + + // proper Java values from MobRenderer::render() + float fBright = entity.getBrightness(a); + return Color(fBright, 0.0f, 0.0f, 0.4f); + } + } + + return Color::NIL; +} \ No newline at end of file diff --git a/source/client/renderer/renderer/EntityShaderManager.hpp b/source/client/renderer/renderer/EntityShaderManager.hpp new file mode 100644 index 000000000..faeee2caa --- /dev/null +++ b/source/client/renderer/renderer/EntityShaderManager.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include "common/math/Color.hpp" +#include "renderer/MaterialPtr.hpp" +#include "world/entity/Entity.hpp" + +class EntityShaderManager +{ +protected: + class Materials + { + public: + mce::MaterialPtr entity; + mce::MaterialPtr entity_color_overlay; + mce::MaterialPtr entity_alphatest; + mce::MaterialPtr entity_static; + + Materials(); + }; + +public: + virtual Color getOverlayColor(const Entity& entity, float a); + +protected: + Materials m_shaderMaterials; +}; diff --git a/source/client/renderer/renderer/RenderMaterialGroup.cpp b/source/client/renderer/renderer/RenderMaterialGroup.cpp new file mode 100644 index 000000000..efe5cd26e --- /dev/null +++ b/source/client/renderer/renderer/RenderMaterialGroup.cpp @@ -0,0 +1,244 @@ +#include "RenderMaterialGroup.hpp" + +#include "thirdparty/rapidjson/error/en.h" + +#include "common/Util.hpp" +#include "common/utility/InheritanceTree.hpp" + +#include "renderer/RenderMaterial.hpp" + +using namespace mce; + +RenderMaterialGroup RenderMaterialGroup::common; +RenderMaterialGroup RenderMaterialGroup::switchable; + +struct MaterialParent +{ + std::string parentName; + const rapidjson::Value* json; +}; + +typedef InheritanceTree MaterialTree; + +RenderMaterialGroup::RenderMaterialGroup() + : AppPlatformListener(false) +{ +} + +RenderMaterialGroup::~RenderMaterialGroup() +{ + _fireGroupDestroyed(); +} + +void RenderMaterialGroup::_fireGroupReloaded() +{ + for (std::set::iterator it = m_references.begin(); it != m_references.end(); it++) + { + (*it)->onGroupReloaded(); + } +} + +void RenderMaterialGroup::_fireGroupDestroyed() +{ + m_references.clear(); +} + +RenderMaterial& RenderMaterialGroup::_material(const std::string& fileName, const std::string& tag) +{ + return m_materials[fileName + tag]; +} + +void _getParent(const std::string& name, const std::string& materialIdentifier, std::string& parentName, std::string& childName) +{ + size_t separatorPos = name.find_last_of(":"); + childName = std::string(name, 0, separatorPos); + + if (separatorPos == std::string::npos) + parentName = Util::EMPTY_STRING; + else + parentName = name.substr(separatorPos + 1) + materialIdentifier; +} + +struct MaterialTreePopulator +{ + RenderMaterial& groupBaseParent; + RenderMaterialGroup& group; + + MaterialTreePopulator(RenderMaterialGroup& group, RenderMaterial& groupBaseParent) + : groupBaseParent(groupBaseParent) + , group(group) + { + } + + void operator()(const std::string& materialName, MaterialParent& materialParent) + { + // Construct material with parent and place in group + RenderMaterial& parentMaterial = group._getMaterialOrDefault(materialParent.parentName, groupBaseParent); + group.m_materials[materialName] = RenderMaterial(*materialParent.json, parentMaterial); + } +}; + +void RenderMaterialGroup::_loadMaterialSet(const rapidjson::Value& root, RenderMaterial& groupBaseParent, const std::string& materialIdentifier) +{ + MaterialTree familyTree; + + for (rapidjson::Value::ConstMemberIterator it = root.MemberBegin(); it != root.MemberEnd(); it++) + { + std::string fullName = it->name.GetString(); + std::string parentName, childName; + _getParent(fullName, materialIdentifier, parentName, childName); + MaterialTree::Node& childNode = familyTree._node(childName); + MaterialTree::Node& parentNode = familyTree._node(parentName); + childNode.val.parentName = parentName; + childNode.val.json = &it->value; + + parentNode.child.push_back(&childNode); + } + + // Construct all materials from the tree in order + MaterialTreePopulator visitor(*this, groupBaseParent); + familyTree.visitBFS(visitor); +} + +bool _isMaterialGroup(const rapidjson::Value& root) +{ + return !root.HasMember("vertexShader") || !root["vertexShader"].IsString(); +} + +void RenderMaterialGroup::_loadList() +{ + std::string fileContents = AppPlatform::singleton()->readAssetFileStr(m_listPath, false); + rapidjson::Document document; + document.Parse(fileContents.c_str()); + const rapidjson::Value& root = document.GetArray(); + + for (rapidjson::Value::ConstValueIterator it = root.Begin(); it != root.End(); it++) + { + const rapidjson::Value& value = (*it).GetObj(); + std::string path = value["path"].GetString(); + + RenderMaterial material; + + if (value.HasMember("defines")) + { + const rapidjson::Value& defines = value["defines"].GetArray(); + for (rapidjson::Value::ConstValueIterator it = defines.Begin(); it != defines.End(); it++) + { + material.m_defines.insert(it->GetString()); + } + } + + std::string tag; + if (value.HasMember("tag")) + { + tag = value["tag"].GetString(); + } + + fileContents = AppPlatform::singleton()->readAssetFileStr(path, false); + rapidjson::Document doc; + rapidjson::ParseResult ok = doc.Parse(fileContents.c_str()); + if (!ok) + { + LOG_E("Error parsing \"%s\", offset %u: %s", path.c_str(), ok.Offset(), rapidjson::GetParseError_En(ok.Code())); + continue; + } + + const rapidjson::Value& root = doc.GetObj(); + if (_isMaterialGroup(root)) + { + _loadMaterialSet(root, material, tag); + } + else + { + RenderMaterial& materialRef = _material(Util::getFileName(path), tag); + materialRef = RenderMaterial(root, materialRef); + } + } + + for (std::map::iterator it = m_materials.begin(); it != m_materials.end(); it++) + { + RenderMaterial& material = it->second; + if (material.m_pShader) + { + material.m_pShader->finalizeShaderUniforms(); + } + } + + Shader::freeCompilerResources(); +} + +void RenderMaterialGroup::_addRef(MaterialPtr& reference) +{ + m_references.insert(&reference); +} + +void RenderMaterialGroup::_removeRef(MaterialPtr& reference) +{ + m_references.erase(&reference); +} + +RenderMaterial* RenderMaterialGroup::_getMaterialPtr(const std::string& name) +{ + std::map::iterator it = m_materials.find(name); + if (it != m_materials.end()) + return &it->second; + + return nullptr; +} + +RenderMaterial* RenderMaterialGroup::_getMaterial(const std::string& name) +{ + RenderMaterial* materialPtr = _getMaterialPtr(name); + if (!materialPtr) + { + LOG_W("Material: %s not found", name.c_str()); + } + + return materialPtr; +} + +RenderMaterial& RenderMaterialGroup::_getMaterialOrDefault(const std::string& name, RenderMaterial& defaultMaterial) +{ + RenderMaterial* materialPtr = _getMaterialPtr(name); + if (materialPtr) + return *materialPtr; + else + return defaultMaterial; +} + +MaterialPtr RenderMaterialGroup::getMaterial(const std::string& name) +{ + return MaterialPtr(*this, name); +} + +void RenderMaterialGroup::loadList(const std::string listPath) +{ + if (!m_listPath.empty()) + { + m_materials.clear(); + m_listPath = listPath; + _loadList(); + _fireGroupReloaded(); + } + else + { + initListener(); + m_listPath = listPath; + _loadList(); + } +} + +void RenderMaterialGroup::onAppResumed() +{ + m_materials.clear(); + _loadList(); + _fireGroupReloaded(); +} + +void RenderMaterialGroup::onAppSuspended() +{ + for (std::map::iterator it = m_materials.begin(); it != m_materials.end(); it++) + { + it->second = RenderMaterial(); + } +} \ No newline at end of file diff --git a/source/client/renderer/renderer/RenderMaterialGroup.hpp b/source/client/renderer/renderer/RenderMaterialGroup.hpp new file mode 100644 index 000000000..91beae9aa --- /dev/null +++ b/source/client/renderer/renderer/RenderMaterialGroup.hpp @@ -0,0 +1,52 @@ +#pragma once + +#include +#include +#include + +#include "thirdparty/rapidjson/document.h" + +#include "client/app/AppPlatformListener.hpp" +#include "renderer/MaterialPtr.hpp" + +namespace mce +{ + class RenderMaterialGroup : public AppPlatformListener + { + public: + static RenderMaterialGroup common, switchable; + + public: + std::map m_materials; + std::set m_references; + std::string m_listPath; + + public: + RenderMaterialGroup(); + ~RenderMaterialGroup(); + + protected: + void _fireGroupReloaded(); + void _fireGroupDestroyed(); + RenderMaterial& _material(const std::string& fileName, const std::string& tag); + void _loadMaterialSet(const rapidjson::Value& root, RenderMaterial& groupBaseParent, const std::string& materialIdentifier); + void _loadList(); + + // These are public despite being prefixed with underscores + public: + void _addRef(MaterialPtr& reference); + void _removeRef(MaterialPtr& reference); + RenderMaterial* _getMaterialPtr(const std::string& name); + RenderMaterial* _getMaterial(const std::string& name); + RenderMaterial& _getMaterialOrDefault(const std::string& name, RenderMaterial& defaultMaterial); + + MaterialPtr getMaterial(const std::string& name); + void loadList(const std::string listPath); + + void onAppResumed() override; + void onAppSuspended() override; + }; + +#define GET_MATERIAL_PTR(group, name) mce::RenderMaterialGroup::group.getMaterial(name) +#define MATERIAL_PTR(group, name) name = GET_MATERIAL_PTR(group, #name) +} \ No newline at end of file diff --git a/source/client/renderer/texture/ColorSpace.hpp b/source/client/renderer/texture/ColorSpace.hpp new file mode 100644 index 000000000..1e2b4fb20 --- /dev/null +++ b/source/client/renderer/texture/ColorSpace.hpp @@ -0,0 +1,7 @@ +#pragma once + +enum ColorSpace +{ + COLOR_SPACE_RGBA, + COLOR_SPACE_RGB, +}; diff --git a/source/client/renderer/texture/ImageData.cpp b/source/client/renderer/texture/ImageData.cpp new file mode 100644 index 000000000..8dda842b5 --- /dev/null +++ b/source/client/renderer/texture/ImageData.cpp @@ -0,0 +1,91 @@ +#include +#include "ImageData.hpp" +#include "compat/LegacyCPP.hpp" +#include "common/Logger.hpp" + +void ImageData::_init() +{ + m_width = 0; + m_height = 0; + m_data = nullptr; + m_mipCount = 0; + m_colorSpace = COLOR_SPACE_RGBA; +} + +ImageData::ImageData() +{ + _init(); +} + +/*ImageData::ImageData(ImageData& other) +{ + _init(); + move(other); +}*/ + +ImageData::~ImageData() +{ + release(); +} + +void ImageData::release() +{ + if (m_data) + { + delete[] m_data; + m_data = nullptr; + } +} + +void ImageData::move(ImageData& other) +{ + this->m_height = other.m_height; + this->m_mipCount = other.m_mipCount; + this->m_width = other.m_width; + uint8_t* tempData = this->m_data; + this->m_data = other.m_data; + other.m_data = tempData; + this->m_colorSpace = other.m_colorSpace; + this->m_mipCount = other.m_mipCount; +} + +void ImageData::forceRGBA() +{ + if (m_colorSpace == COLOR_SPACE_RGBA || m_data == nullptr) + return; + + if (m_colorSpace != COLOR_SPACE_RGB) + { + LOG_E("Can't convert non-RGB image to RGBA"); + throw std::bad_cast(); + } + + size_t size = m_height * m_width; + uint8_t* rgbData = m_data; + uint8_t* rgbaData = new uint8_t[4 * size]; + + uint8_t* rgbDataItr = rgbData; + uint8_t* rgbaDataItr = rgbaData; + + // translate RGB buffer into RGBA buffer + uint8_t* rgbDataEnd = &rgbData[3 * size]; + while (rgbDataItr != rgbDataEnd) + { + rgbaDataItr[0] = rgbDataItr[0]; // red + rgbaDataItr[1] = rgbDataItr[1]; // green + rgbaDataItr[2] = rgbDataItr[2]; // blue + rgbaDataItr[3] = 255; // alpha + + rgbDataItr += 3; + rgbaDataItr += 4; + } + + m_data = rgbaData; + delete[] rgbData; + m_colorSpace = COLOR_SPACE_RGBA; +} + +bool ImageData::isEmpty() const +{ + return !m_data || m_width == 0 || m_height == 0; +} \ No newline at end of file diff --git a/source/client/renderer/texture/ImageData.hpp b/source/client/renderer/texture/ImageData.hpp new file mode 100644 index 000000000..6c2b32cf7 --- /dev/null +++ b/source/client/renderer/texture/ImageData.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include +#include +#include "ColorSpace.hpp" + +struct ImageData +{ + int m_width; + int m_height; + uint8_t* m_data; + unsigned int m_mipCount; + ColorSpace m_colorSpace; + +private: + void _init(); + +public: + ImageData(); + //ImageData(ImageData& other); + ~ImageData(); + + void release(); + void move(ImageData& other); + void forceRGBA(); + bool isEmpty() const; +}; \ No newline at end of file diff --git a/source/client/renderer/texture/TextureData.cpp b/source/client/renderer/texture/TextureData.cpp new file mode 100644 index 000000000..b522c094a --- /dev/null +++ b/source/client/renderer/texture/TextureData.cpp @@ -0,0 +1,175 @@ +#include "TextureData.hpp" +#include "common/Util.hpp" +#include "renderer/RenderContextImmediate.hpp" + +TextureData* TextureData::lastBoundTextureUnit; +TextureData* TextureData::lastBoundTexture[8]; + +void TextureData::_init() +{ + m_bEnableFiltering = false; + m_bWrap = false; +} + +void TextureData::_init(TextureData& other) +{ + _init(); + _move(other); +} + +TextureData::TextureData() +{ + _init(); +} + +TextureData::TextureData(unsigned int width, unsigned int height, bool enableFiltering) +{ + _init(); + + m_imageData.m_width = width; + m_imageData.m_height = height; + m_imageData.m_colorSpace = COLOR_SPACE_RGBA; + //m_imageData.m_data.resize(4 * height * width); + + m_bEnableFiltering = enableFiltering; +} + +TextureData::~TextureData() +{ + unload(); +} + +void TextureData::_move(TextureData& other) +{ + this->m_bEnableFiltering = other.m_bEnableFiltering; + this->m_imageData.move(other.m_imageData); + this->m_texture.move(other.m_texture); +} + +void TextureData::_loadTexData(mce::Texture& texture, bool enableFiltering, bool wrap) +{ + mce::TextureDescription desc; + desc.filteringLevel = enableFiltering ? mce::TEXTURE_FILTERING_BILINEAR : mce::TEXTURE_FILTERING_POINT; + desc.bWrap = wrap; + desc.width = m_imageData.m_width; + desc.height = m_imageData.m_height; + + m_imageData.forceRGBA(); + + switch (m_imageData.m_colorSpace) + { + case COLOR_SPACE_RGBA: + desc.textureFormat = mce::TEXTURE_FORMAT_R8G8B8A8_UNORM; + break; + default: + LOG_E("Failed to load texture for image with unsupported ColorSpace: %d", m_imageData.m_colorSpace); + throw std::bad_cast(); + } + + if (!texture.isLoaded()) + { + // texture bind #1 + texture.createTexture(mce::RenderContextImmediate::get(), desc); + } + + // texture bind #2 + texture.subBuffer(mce::RenderContextImmediate::get(), m_imageData.m_data); +} + +void TextureData::_loadMipmap(ImageData& data) +{ + if (data.m_colorSpace == COLOR_SPACE_RGB) + { + LOG_E("Functionality for mips and non RGBA textures isn't supported yet"); + throw std::bad_cast(); + } + + m_texture.convertToMipmapedTexture(mce::RenderContextImmediate::get(), 5); + m_texture.loadMipMap(mce::RenderContextImmediate::get(), data.m_data, data.m_mipCount); +} + +void TextureData::move(TextureData& other) +{ + unload(); + _move(other); +} + +void TextureData::unload() +{ + if (m_texture.isLoaded()) + { + m_texture.deleteTexture(); + } +} + +void TextureData::clear() +{ + unload(); + m_imageData.release(); +} + +void TextureData::bind(unsigned int textureUnit) +{ + if (m_texture.isLoaded() && lastBoundTexture[textureUnit] != this) + { + lastBoundTexture[textureUnit] = this; + m_texture.bindTexture(mce::RenderContextImmediate::get(), textureUnit); + } +} + +void TextureData::sync() +{ + if (m_texture.isLoaded()) + { + _loadTexData(m_texture, m_bEnableFiltering, m_bWrap); + } +} + +uint32_t* TextureData::getData() +{ + return (uint32_t*)m_imageData.m_data; +} + +void TextureData::setData(uint8_t* data) +{ + m_imageData.release(); + m_imageData.m_data = data; + sync(); +} + +void TextureData::load() +{ + _loadTexData(m_texture, m_bEnableFiltering, m_bWrap); + for (int i = 0; i < m_mipmaps.size(); i++) + { + _loadMipmap(m_mipmaps[i]); + } +} + +void TextureData::loadMipmap(ImageData& data) +{ + _loadMipmap(data); + m_mipmaps.push_back(data); +} + +bool TextureData::isEmpty() const +{ + return m_imageData.isEmpty(); +} + +void TextureData::unbind(unsigned int textureUnit) +{ + lastBoundTexture[textureUnit] = nullptr; +} + +void TextureData::unbindAll() +{ + lastBoundTexture[0] = nullptr; + lastBoundTexture[1] = nullptr; + lastBoundTexture[2] = nullptr; + lastBoundTexture[3] = nullptr; + lastBoundTexture[4] = nullptr; + lastBoundTexture[5] = nullptr; + lastBoundTexture[6] = nullptr; + lastBoundTexture[7] = nullptr; +} \ No newline at end of file diff --git a/source/client/renderer/texture/TextureData.hpp b/source/client/renderer/texture/TextureData.hpp new file mode 100644 index 000000000..d15e09e78 --- /dev/null +++ b/source/client/renderer/texture/TextureData.hpp @@ -0,0 +1,54 @@ +#pragma once + +#include +#include "compat/LegacyCPP.hpp" +#include "renderer/hal/interface/Texture.hpp" +#include "ImageData.hpp" + +class TextureData +{ +private: + static TextureData* lastBoundTextureUnit; + static TextureData* lastBoundTexture[8]; + +public: + ImageData m_imageData; + bool m_bEnableFiltering; + bool m_bWrap; + mce::Texture m_texture; + std::vector m_mipmaps; + +private: + void _init(); + void _init(TextureData& other); + +public: + TextureData(); + MC_CTOR_MOVE_CUSTOM(TextureData); + TextureData(unsigned int width, unsigned int height, bool enableFiltering); + ~TextureData(); + +private: + void _move(TextureData& other); + void _loadTexData(mce::Texture& texture, bool enableFiltering, bool wrap); + void _loadMipmap(ImageData& data); + +public: + void move(TextureData& other); + void unload(); + void clear(); + void bind(unsigned int textureUnit); + void sync(); + uint32_t* getData(); + void setData(uint8_t* data); + void load(); + void loadMipmap(ImageData& data); + bool isEmpty() const; + +public: + MC_FUNC_MOVE(TextureData); + +public: + static void unbind(unsigned int textureUnit); + static void unbindAll(); +}; \ No newline at end of file diff --git a/source/common/Matrix.cpp b/source/common/Matrix.cpp deleted file mode 100644 index 4fcbae44d..000000000 --- a/source/common/Matrix.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************** - Minecraft: Pocket Edition - Decompilation Project - Copyright (C) 2023 iProgramInCpp - - The following code is licensed under the BSD 1 clause license. - SPDX-License-Identifier: BSD-1-Clause - ********************************************************************/ - -#include "Matrix.hpp" - -Matrix::Matrix() -{ - c[0] = 0.0f; - - memset(c, 0, sizeof c); -} - -Matrix::Matrix(float x) -{ - memset(c, 0, sizeof c); - c[0] = c[4 * 1 + 1] = c[4 * 2 + 2] = c[4 * 3 + 3] = x; -} - -Matrix::Matrix(float* p) -{ - memcpy(c, p, sizeof c); -} - -Matrix::Matrix(float a, float b, float q, float d, float e, float f, float g, float h, float i, float j, float k, float l, float m, float n, float o, float p) -{ - c[0] = a, c[1] = b, c[2] = q, c[3] = d, c[4] = e, c[5] = f, c[6] = g, c[7] = h, c[8] = i, c[9] = j, c[10] = k, c[11] = l, c[12] = m, c[13] = n, c[14] = o, c[15] = p; -} - -void Matrix::fetchGL(GLenum pname) -{ - glGetFloatv(pname, c); -} - -Matrix operator*(const Matrix& a, const Matrix& b) -{ - Matrix result; - - //this is ugly - result.c[0] = a.c[0] * b.c[0] + a.c[1] * b.c[4] + a.c[2] * b.c[8] + a.c[3] * b.c[12]; - result.c[1] = a.c[0] * b.c[1] + a.c[1] * b.c[5] + a.c[2] * b.c[9] + a.c[3] * b.c[13]; - result.c[2] = a.c[0] * b.c[2] + a.c[1] * b.c[6] + a.c[2] * b.c[10] + a.c[3] * b.c[14]; - result.c[3] = a.c[0] * b.c[3] + a.c[1] * b.c[7] + a.c[2] * b.c[11] + a.c[3] * b.c[15]; - result.c[4] = a.c[4] * b.c[0] + a.c[5] * b.c[4] + a.c[6] * b.c[8] + a.c[7] * b.c[12]; - result.c[5] = a.c[4] * b.c[1] + a.c[5] * b.c[5] + a.c[6] * b.c[9] + a.c[7] * b.c[13]; - result.c[6] = a.c[4] * b.c[2] + a.c[5] * b.c[6] + a.c[6] * b.c[10] + a.c[7] * b.c[14]; - result.c[7] = a.c[4] * b.c[3] + a.c[5] * b.c[7] + a.c[6] * b.c[11] + a.c[7] * b.c[15]; - result.c[8] = a.c[8] * b.c[0] + a.c[9] * b.c[4] + a.c[10] * b.c[8] + a.c[11] * b.c[12]; - result.c[9] = a.c[8] * b.c[1] + a.c[9] * b.c[5] + a.c[10] * b.c[9] + a.c[11] * b.c[13]; - result.c[10] = a.c[8] * b.c[2] + a.c[9] * b.c[6] + a.c[10] * b.c[10] + a.c[11] * b.c[14]; - result.c[11] = a.c[8] * b.c[3] + a.c[9] * b.c[7] + a.c[10] * b.c[11] + a.c[11] * b.c[15]; - result.c[12] = a.c[12] * b.c[0] + a.c[13] * b.c[4] + a.c[14] * b.c[8] + a.c[15] * b.c[12]; - result.c[13] = a.c[12] * b.c[1] + a.c[13] * b.c[5] + a.c[14] * b.c[9] + a.c[15] * b.c[13]; - result.c[14] = a.c[12] * b.c[2] + a.c[13] * b.c[6] + a.c[14] * b.c[10] + a.c[15] * b.c[14]; - result.c[15] = a.c[12] * b.c[3] + a.c[13] * b.c[7] + a.c[14] * b.c[11] + a.c[15] * b.c[15]; - - return result; -} diff --git a/source/common/Matrix.hpp b/source/common/Matrix.hpp deleted file mode 100644 index ecbd24b48..000000000 --- a/source/common/Matrix.hpp +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************** - Minecraft: Pocket Edition - Decompilation Project - Copyright (C) 2023 iProgramInCpp - - The following code is licensed under the BSD 1 clause license. - SPDX-License-Identifier: BSD-1-Clause - ********************************************************************/ - -#pragma once - -#include -#include "Mth.hpp" -#include "thirdparty/GL/GL.hpp" - -class Matrix -{ -public: - Matrix(); // create an empty matrix - Matrix(float a); // create an identity matrix - Matrix(float* p); // load matrix from memory - Matrix(float a, float b, float c, float d, float e, float f, float g, float h, float i, float j, float k, float l, float m, float n, float o, float p); - void fetchGL(GLenum pname); - - friend Matrix operator*(const Matrix& a, const Matrix& b); - -public: - float c[16]; -}; - -Matrix operator*(const Matrix& a, const Matrix& b); - diff --git a/source/common/Util.cpp b/source/common/Util.cpp index 0229e8c75..e86698417 100644 --- a/source/common/Util.cpp +++ b/source/common/Util.cpp @@ -65,3 +65,45 @@ std::string Util::format(const char *fmt, ...) return str; } + +bool Util::isValidPath(const std::string& path) +{ + for (int i = 0; i < path.size(); i++) + { + switch (path.at(i)) + { + case '\n': + case '\r': + return false; + } + } + + return true; +} + +std::string Util::getFileName(const std::string& path) +{ + size_t namePos = 0; + size_t nameSize = std::string::npos; + + size_t lastOf = path.find_last_of("/\\"); + if (lastOf != std::string::npos) + namePos = lastOf + 1; + + size_t dotPos = path.rfind('.'); + if (dotPos != std::string::npos && dotPos > namePos) + nameSize = dotPos - namePos; + + return path.substr(namePos, nameSize); +} + +std::string Util::getExtension(const std::string& path) +{ + size_t dotPos = path.rfind('.'); + if (dotPos == std::string::npos) + { + return ""; + } + + return path.substr(dotPos + 1); +} \ No newline at end of file diff --git a/source/common/Util.hpp b/source/common/Util.hpp index a2625ba02..2be083a06 100644 --- a/source/common/Util.hpp +++ b/source/common/Util.hpp @@ -27,6 +27,11 @@ class Util static std::string vformat(const char* fmt, va_list argPtr); static std::string format(const char* fmt, ...); + static bool isValidPath(const std::string& path); + // Returns the name of a file, without its extension + static std::string getFileName(const std::string& path); + static std::string getExtension(const std::string& path); + template static bool remove(std::vector& vec, const T& t) { diff --git a/source/common/Utils.hpp b/source/common/Utils.hpp index 5c50dd81c..58b5899ef 100644 --- a/source/common/Utils.hpp +++ b/source/common/Utils.hpp @@ -523,16 +523,10 @@ enum eRenderShape SHAPE_RANDOM_CROSS }; -enum eRenderLayer -{ - LAYER_OPAQUE, - LAYER_ALPHA -}; - typedef uint8_t TileID; // @TODO: Rename this to "TileTypeId" // Rename "Tile" to "TileType" -// Create "Tile" class containing TileTypeId, and TileData +// Rename "FullTile" to "Tile" typedef uint8_t TileData; #define SAFE_DELETE(ptr) do { if (ptr) delete ptr; } while (0) diff --git a/source/common/math/Color.cpp b/source/common/math/Color.cpp new file mode 100644 index 000000000..412da5399 --- /dev/null +++ b/source/common/math/Color.cpp @@ -0,0 +1,80 @@ +#include + +#include "Color.hpp" + +Color Color::SHADE_WEST_EAST = Color(0.6f, 0.6f, 0.6f); +Color Color::SHADE_NORTH_SOUTH = Color(0.8f, 0.8f, 0.8f); +Color Color::SHADE_UP = Color(1.0f, 1.0f, 1.0f); +Color Color::SHADE_DOWN = Color(0.5f, 0.5f, 0.5f); + +Color Color::NIL = Color(0.0f, 0.0f, 0.0f, 0.0f); +Color Color::CYAN = Color(0.0f, 1.0f, 1.0f); +Color Color::PURPLE = Color(1.0f, 0.0f, 1.0f); +Color Color::YELLOW = Color(1.0f, 1.0f, 0.0f); +Color Color::BLUE = Color(0.0f, 0.0f, 1.0f); +Color Color::GREEN = Color(0.0f, 1.0f, 0.0f); +Color Color::RED = Color(1.0f, 0.0f, 0.0f); +Color Color::BLACK = Color(0.0f, 0.0f, 0.0f); +Color Color::GREY = Color(0.5f, 0.5f, 0.5f); +Color Color::WHITE = Color(1.0f, 1.0f, 1.0f); + +void Color::fromHSB(float h, float s, float b) +{ + if (s == 0.0f) + { + this->r = b; + this->g = b; + this->b = b; + this->a = 1.0f; + } + else + { + float v7 = (h - floorf(h)) * 6.0f; + float v10 = (1.0f - s) * b; + float v11 = v7 - floorf(v7); + float v12 = (1.0f - (v11 * s)) * b; + float v13 = b + (((v11 * s) - s) * b); + switch ((int)v7) + { + case 0: + this->r = b; + this->g = v13; + this->b = v10; + this->a = 1.0f; + break; + case 1: + this->r = v12; + this->g = b; + this->b = v10; + this->a = 1.0f; + break; + case 2: + this->r = v10; + this->g = b; + this->b = v13; + this->a = 1.0f; + break; + case 3: + this->r = v10; + this->g = v12; + this->b = b; + this->a = 1.0f; + break; + case 4: + this->r = v13; + this->g = v10; + this->b = b; + this->a = 1.0f; + break; + case 5: + this->r = b; + this->g = v10; + this->b = v12; + this->a = 1.0f; + break; + default: + *this = Color::NIL; + break; + } + } +} \ No newline at end of file diff --git a/source/common/math/Color.hpp b/source/common/math/Color.hpp new file mode 100644 index 000000000..cc1d1dcd5 --- /dev/null +++ b/source/common/math/Color.hpp @@ -0,0 +1,119 @@ +#pragma once + +#include + +#define GET_RED(c) (uint8_t(((c) >> 0) & 0xFF)) +#define GET_GREEN(c) (uint8_t(((c) >> 8) & 0xFF)) +#define GET_BLUE(c) (uint8_t(((c) >> 16) & 0xFF)) +#define GET_ALPHA(c) (uint8_t(((c) >> 24) & 0xFF)) + +struct Color +{ +public: + float r; + float g; + float b; + float a; + +private: + void _init(float r, float g, float b, float a) + { + this->r = r; + this->g = g; + this->b = b; + this->a = a; + } + + void _init(uint8_t r, uint8_t g, uint8_t b, uint8_t a) + { + this->r = float(r) / 255.0f; + this->g = float(g) / 255.0f; + this->b = float(b) / 255.0f; + this->a = float(a) / 255.0f; + } + +public: + Color() + { + *this = NIL; + } + + Color(float r, float g, float b, float a = 1.0f) + { + _init(r, g, b, a); + } + + Color(int r, int g, int b, int a = 255) + { + _init((uint8_t)r, (uint8_t)g, (uint8_t)b, (uint8_t)a); + } + + Color(unsigned int c) + { + _init(GET_RED(c), GET_GREEN(c), GET_BLUE(c), GET_ALPHA(c)); + } + + void fromHSB(float h, float s, float b); + + Color operator*(float f) const + { + return Color(r * f, g * f, b * f, a * f); + } + + Color operator*(const Color& c) const + { + return Color(r * c.r, g * c.g, b * c.b, a * c.a); + } + + Color& operator*=(const Color& c) + { + r *= c.r; + g *= c.g; + b *= c.b; + a *= c.a; + + return *this; + } + + Color& operator*=(float f) + { + r *= f; + g *= f; + b *= f; + + return *this; + } + + bool operator==(const Color& other) const + { + return this->r == other.r + && this->g == other.g + && this->b == other.b + && this->a == other.a; + } + + bool operator!=(const Color& other) const + { + return this->r != other.r + || this->g != other.g + || this->b != other.b + || this->a != other.a; + } + +public: + static Color SHADE_WEST_EAST; + static Color SHADE_NORTH_SOUTH; + static Color SHADE_UP; + static Color SHADE_DOWN; + + static Color NIL; + static Color CYAN; + static Color PURPLE; + static Color YELLOW; + static Color BLUE; + static Color GREEN; + static Color RED; + static Color BLACK; + static Color GREY; + static Color WHITE; +}; diff --git a/source/common/utility/AlignmentHelper.cpp b/source/common/utility/AlignmentHelper.cpp new file mode 100644 index 000000000..56fcbbaa8 --- /dev/null +++ b/source/common/utility/AlignmentHelper.cpp @@ -0,0 +1,17 @@ +#include "AlignmentHelper.hpp" + +using namespace mce; + +unsigned int AlignmentHelper::getAlignedOffset(unsigned int size, unsigned int a2) +{ + unsigned int v2; // r3 + bool v3; // cf + + v2 = 16 - (size & 0xF); + v3 = v2 >= 0x10; + if ( v2 != 16 ) + v3 = v2 >= a2; + if ( !v3 ) + size += v2; + return size; +} \ No newline at end of file diff --git a/source/common/utility/AlignmentHelper.hpp b/source/common/utility/AlignmentHelper.hpp new file mode 100644 index 000000000..133948cdd --- /dev/null +++ b/source/common/utility/AlignmentHelper.hpp @@ -0,0 +1,10 @@ +#pragma once + +namespace mce +{ + class AlignmentHelper + { + public: + static unsigned int getAlignedOffset(unsigned int, unsigned int); + }; +} \ No newline at end of file diff --git a/source/common/utility/InheritanceTree.hpp b/source/common/utility/InheritanceTree.hpp new file mode 100644 index 000000000..366bcc357 --- /dev/null +++ b/source/common/utility/InheritanceTree.hpp @@ -0,0 +1,75 @@ +#pragma once + +#include +#include +#include +#include + +template +class InheritanceTree +{ +public: + struct Node + { + std::string name; + T val; + std::vector child; + + Node() + { + } + + Node(const std::string& name) + { + this->name = name; + } + }; + +private: + std::map m_nodes; + +public: + InheritanceTree() {} + +public: + Node& _node(const std::string& name) + { + typename std::map::iterator it = m_nodes.find(name); + if (it != m_nodes.end()) + { + return it->second; + } + else + { + Node& node = m_nodes[name]; + node = Node(name); + return node; + } + } + + template + void visitBFS(TVisitor& visitor) + { + std::deque queue; + + queue.push_back(&m_nodes[""]); + + while (!queue.empty()) + { + Node* currentNode = queue.front(); + queue.pop_front(); + + // Skip root node + if (!currentNode->name.empty()) + { + visitor(currentNode->name, currentNode->val); + } + + // Queue child nodes + for (int i = 0; i < currentNode->child.size(); i++) + { + queue.push_back(currentNode->child[i]); + } + } + } +}; \ No newline at end of file diff --git a/source/common/utility/JsonParser.cpp b/source/common/utility/JsonParser.cpp new file mode 100644 index 000000000..d8dbf4dcf --- /dev/null +++ b/source/common/utility/JsonParser.cpp @@ -0,0 +1,2 @@ +#include "JsonParser.hpp" + diff --git a/source/common/utility/JsonParser.hpp b/source/common/utility/JsonParser.hpp new file mode 100644 index 000000000..5c8c4728e --- /dev/null +++ b/source/common/utility/JsonParser.hpp @@ -0,0 +1,28 @@ +#pragma once + +#include +#include + +#include "thirdparty/rapidjson/document.h" + +namespace mce +{ + template + bool parse(const rapidjson::Value& root, const std::string& name, const std::map& map, T& out) + { + if (root.IsNull() || !root.HasMember(name.c_str())) + return false; + + const rapidjson::Value& value = root[name.c_str()]; + if (value.IsNull()) + return false; + + std::string valueStr = value.GetString(); + out = ((std::map&)map)[valueStr]; + + return true; + } + + template + bool parse(const rapidjson::Value& root, const std::string& name, T& out); +} \ No newline at end of file diff --git a/source/common/utility/Singleton.cpp b/source/common/utility/Singleton.cpp new file mode 100644 index 000000000..48ef79330 --- /dev/null +++ b/source/common/utility/Singleton.cpp @@ -0,0 +1,3 @@ +#include "Singleton.hpp" + +using namespace mce; diff --git a/source/common/utility/Singleton.hpp b/source/common/utility/Singleton.hpp new file mode 100644 index 000000000..1fba3c5aa --- /dev/null +++ b/source/common/utility/Singleton.hpp @@ -0,0 +1,70 @@ +#pragma once + +#include +#include "compat/LegacyCPP.hpp" +#include "common/Logger.hpp" + +namespace mce +{ + template + class Singleton + { + private: + static T* instance; + + private: + static void internalCreateInstance() + { + T* newInstance = new T(); + T* oldInstance = instance; + + instance = newInstance; + + if (oldInstance) + delete oldInstance; + } + + public: + static bool createInstance() + { + if (!instance) + { + internalCreateInstance(); + return true; + } + + return false; + } + + static void deleteInstance() + { + if (instance) + delete instance; + instance = nullptr; + } + + static T& getInstance() + { + if (instance == nullptr) + { + LOG_E("The singleton instance doesn't exist"); + throw std::bad_cast(); + } + + return *instance; + } + + public: + Singleton() + { + if (instance != nullptr) + { + LOG_E("You attempted to create a singleton where one already exists"); + throw std::bad_cast(); + } + } + }; + + template + T* Singleton::instance = nullptr; +} \ No newline at end of file diff --git a/source/renderer/Attribute.cpp b/source/renderer/Attribute.cpp new file mode 100644 index 000000000..cd2175e83 --- /dev/null +++ b/source/renderer/Attribute.cpp @@ -0,0 +1,24 @@ +#include "Attribute.hpp" + +using namespace mce; + +Attribute::Attribute() +{ + m_vertexField = VertexField(); + m_location = 0; + m_count = 0; +} + +Attribute::Attribute(unsigned int location, unsigned int count, VertexField vertexField) +{ + m_vertexField = vertexField; + m_location = location; + m_count = count; +} + +bool Attribute::operator==(const Attribute &other) const +{ + return m_vertexField == other.m_vertexField && + m_location == other.m_location && + m_count == other.m_count; +} \ No newline at end of file diff --git a/source/renderer/Attribute.hpp b/source/renderer/Attribute.hpp new file mode 100644 index 000000000..4711ec8fd --- /dev/null +++ b/source/renderer/Attribute.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include "renderer/hal/enums/VertexField.hpp" + +namespace mce +{ + class Attribute + { + private: + VertexField m_vertexField; + unsigned int m_location; + unsigned int m_count; + + public: + Attribute(); + Attribute(unsigned int location, unsigned int count, VertexField vertexField); + + VertexField getVertexField() const { return m_vertexField; } + unsigned int getLocation() const { return m_location; } + + bool operator==(const Attribute& other) const; + }; +} \ No newline at end of file diff --git a/source/renderer/ConstantBufferMetaData.cpp b/source/renderer/ConstantBufferMetaData.cpp new file mode 100644 index 000000000..d7d545b3c --- /dev/null +++ b/source/renderer/ConstantBufferMetaData.cpp @@ -0,0 +1,53 @@ +#include "ConstantBufferMetaData.hpp" +#include "compat/LegacyCPP.hpp" +#include "common/utility/AlignmentHelper.hpp" + +using namespace mce; + +ConstantBufferMetaData::ConstantBufferMetaData() +{ + m_uniformMetaData = std::vector(); + m_constantBufferName = ""; +} + +void ConstantBufferMetaData::addUniformMetaData(UniformMetaData& uniformMetaData) +{ + if (!m_uniformMetaData.empty()) + { + const UniformMetaData& lastUniformMeta = m_uniformMetaData.back(); + uniformMetaData.m_byteOffset = AlignmentHelper::getAlignedOffset( + lastUniformMeta.m_byteOffset + lastUniformMeta.getSize(), + ShaderPrimitiveTypeHelper::sizeInBytesFromShaderPrimitiveType(uniformMetaData.m_shaderPrimitiveType) + ); + } + + m_uniformMetaData.push_back(uniformMetaData); +} + +const std::string& ConstantBufferMetaData::getConstantBufferName() const +{ + return m_constantBufferName; +} + +const UniformMetaData* ConstantBufferMetaData::getUniformMetaData(const std::string& uniformName) const +{ + for (int i = 0; i < m_uniformMetaData.size(); i++) + { + const UniformMetaData& uniformMeta = m_uniformMetaData[i]; + if (uniformMeta.m_uniformName == uniformName) + return &uniformMeta; + } + + return nullptr; +} + +unsigned int ConstantBufferMetaData::getRequiredSpaceForUniforms() const +{ + if (m_uniformMetaData.empty()) + return 0; + + const UniformMetaData& lastUniform = m_uniformMetaData.back(); + unsigned int unalignedSize = lastUniform.getSize() + lastUniform.m_byteOffset; + + return AlignmentHelper::getAlignedOffset(unalignedSize, 16); +} \ No newline at end of file diff --git a/source/renderer/ConstantBufferMetaData.hpp b/source/renderer/ConstantBufferMetaData.hpp new file mode 100644 index 000000000..81b8e3bdb --- /dev/null +++ b/source/renderer/ConstantBufferMetaData.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include +#include +#include "UniformMetaData.hpp" + +namespace mce +{ + class ConstantBufferMetaData + { + public: + std::string m_constantBufferName; + std::vector m_uniformMetaData; + + public: + ConstantBufferMetaData(); + + public: + // doesn't exist in 0.12.1, assuming it's in-lined + void addUniformMetaData(UniformMetaData& uniformMetaData); + + const std::string& getConstantBufferName() const; + const UniformMetaData* getUniformMetaData(const std::string& uniformName) const; + unsigned int getRequiredSpaceForUniforms() const; + }; +} \ No newline at end of file diff --git a/source/renderer/ConstantBufferMetaDataManager.cpp b/source/renderer/ConstantBufferMetaDataManager.cpp new file mode 100644 index 000000000..b3762fd4b --- /dev/null +++ b/source/renderer/ConstantBufferMetaDataManager.cpp @@ -0,0 +1,119 @@ +#include "thirdparty/rapidjson/document.h" + +#include "common/utility/AlignmentHelper.hpp" + +#include "ConstantBufferMetaDataManager.hpp" +#include "GlobalConstantBufferManager.hpp" + +using namespace mce; + +ConstantBufferMetaDataManager::ConstantBufferMetaDataManager() +{ +} + +void ConstantBufferMetaDataManager::allocateConstantBufferContainers() +{ + GlobalConstantBufferManager& bufferManager = GlobalConstantBufferManager::getInstance(); + bufferManager.m_constantBufferContainers.reserve(m_constantBufferMetaDataList.size()); + + for (int i = 0; i < m_constantBufferMetaDataList.size(); i++) + { + ConstantBufferMetaData& bufferMeta = m_constantBufferMetaDataList[i]; + ConstantBufferContainer buffer; + + unsigned int uniformCount = bufferMeta.m_uniformMetaData.size(); + unsigned int bufferSize = bufferMeta.getRequiredSpaceForUniforms(); + buffer.reserveMemoryForShaderConstants(uniformCount, bufferSize); + + buffer.m_constantBufferName = bufferMeta.getConstantBufferName(); + + for (int i = 0; i < bufferMeta.m_uniformMetaData.size(); i++) + { + UniformMetaData& uniformMeta = bufferMeta.m_uniformMetaData[i]; + buffer.registerReflectedShaderParameter(uniformMeta); + } + + buffer.finalizeConstantBufferLayout(); + bufferManager.m_constantBufferContainers.push_back(buffer); + } +} + +void ConstantBufferMetaDataManager::loadJsonFile(const std::string& document) +{ + using namespace rapidjson; + + Document d; + d.Parse(document.c_str()); + const Value& root = d.GetObj(); + m_constantBufferMetaDataList.reserve(root.MemberCount()); + + // + for (Value::ConstMemberIterator it = root.MemberBegin(); it != root.MemberEnd(); it++) + { + m_constantBufferMetaDataList.push_back(ConstantBufferMetaData()); + ConstantBufferMetaData& metaData = m_constantBufferMetaDataList.back(); + metaData.m_constantBufferName = it->name.GetString(); + + const Value& constantsDef = it->value; + + // "EntityConstants" + for (Value::ConstValueIterator it2 = constantsDef.Begin(); it2 != constantsDef.End(); it2++) + { + Value::ConstMemberIterator uniformDef = it2->MemberBegin(); + + ShaderPrimitiveTypes primitiveType = SHADER_PRIMITIVE_UNKNOWN; + const char* primitiveTypeStr = uniformDef->value.GetString(); + for (int i = 0; i <= SHADER_PRIMITIVES_MAX; i++) + { + if (strcmp(ShaderPrimitiveTypeToString[i], primitiveTypeStr) == 0) + { + primitiveType = (ShaderPrimitiveTypes)i; + break; + } + } + if (primitiveType == SHADER_PRIMITIVE_UNKNOWN) + { + LOG_E("Couldn't find shader primitive type: %s in the array of shader primitive types, typo perhaps?", primitiveTypeStr); + throw std::bad_cast(); + } + + UniformMetaData uniformMeta; + uniformMeta.m_shaderPrimitiveType = primitiveType; + uniformMeta.m_numberOfElements = 1; + uniformMeta.m_constantBufferMetaDataParent = &metaData; + uniformMeta.m_uniformName = uniformDef->name.GetString(); + metaData.addUniformMetaData(uniformMeta); + } + } + + allocateConstantBufferContainers(); +} + +const UniformMetaData& ConstantBufferMetaDataManager::findUniformMetaData(const std::string& uniformName) const +{ + for (int i = 0; i < m_constantBufferMetaDataList.size(); i++) + { + const ConstantBufferMetaData& bufferMeta = m_constantBufferMetaDataList[i]; + const UniformMetaData* uniformMeta = bufferMeta.getUniformMetaData(uniformName); + if (uniformMeta) + return *uniformMeta; + } + + LOG_E("Couldn't find uniform: %s in the constant buffer metadata list", uniformName.c_str()); + throw std::bad_cast(); +} + +const ConstantBufferMetaData& ConstantBufferMetaDataManager::findConstantBuffer(const std::string& bufferName) const +{ + for (int i = 0; i < m_constantBufferMetaDataList.size(); i++) + { + const ConstantBufferMetaData& bufferMeta = m_constantBufferMetaDataList[i]; + if (bufferMeta.getConstantBufferName() == bufferName) + { + return bufferMeta; + } + } + + LOG_E("Couldn't find the constant buffer named: %s was it properly reflected in the uniforms metadata file?", bufferName.c_str()); + throw std::bad_cast(); +} \ No newline at end of file diff --git a/source/renderer/ConstantBufferMetaDataManager.hpp b/source/renderer/ConstantBufferMetaDataManager.hpp new file mode 100644 index 000000000..9eb5f7897 --- /dev/null +++ b/source/renderer/ConstantBufferMetaDataManager.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include + +#include "common/utility/Singleton.hpp" +#include "ConstantBufferMetaData.hpp" + +namespace mce +{ + class ConstantBufferMetaDataManager : public Singleton + { + private: + std::vector m_constantBufferMetaDataList; + + public: + ConstantBufferMetaDataManager(); + + public: + void allocateConstantBufferContainers(); + void loadJsonFile(const std::string& document); + const UniformMetaData& findUniformMetaData(const std::string& uniformName) const; + const ConstantBufferMetaData& findConstantBuffer(const std::string& bufferName) const; + }; +} \ No newline at end of file diff --git a/source/renderer/EnableScissorTest.cpp b/source/renderer/EnableScissorTest.cpp new file mode 100644 index 000000000..28a7a5fa0 --- /dev/null +++ b/source/renderer/EnableScissorTest.cpp @@ -0,0 +1,32 @@ +#include "EnableScissorTest.hpp" + +using namespace mce; + +int EnableScissorTest::activeScissorBox[4]; +bool EnableScissorTest::scissorTestEnabled; + +void EnableScissorTest::_init(bool enableTest) +{ + m_testEnabled = enableTest; + scissorTestEnabled = enableTest; +} + +EnableScissorTest::EnableScissorTest(bool enableTest) +{ + _init(enableTest); +} + +EnableScissorTest::EnableScissorTest(int x, int y, int w, int h) +{ + _init(true); + activeScissorBox[0] = x; + activeScissorBox[1] = y; + activeScissorBox[2] = w; + activeScissorBox[3] = h; +} + +EnableScissorTest::~EnableScissorTest() +{ + if (m_testEnabled) + scissorTestEnabled = false; +} \ No newline at end of file diff --git a/source/renderer/EnableScissorTest.hpp b/source/renderer/EnableScissorTest.hpp new file mode 100644 index 000000000..7dc4d01cd --- /dev/null +++ b/source/renderer/EnableScissorTest.hpp @@ -0,0 +1,22 @@ +#pragma once + +namespace mce +{ + class EnableScissorTest + { + public: + static int activeScissorBox[4]; + static bool scissorTestEnabled; + + private: + bool m_testEnabled; + + private: + void _init(bool enableTest); + + public: + EnableScissorTest(bool enableTest); + EnableScissorTest(int x, int y, int w, int h); + ~EnableScissorTest(); + }; +} \ No newline at end of file diff --git a/source/renderer/EntityConstants.cpp b/source/renderer/EntityConstants.cpp new file mode 100644 index 000000000..cb2b8c0b5 --- /dev/null +++ b/source/renderer/EntityConstants.cpp @@ -0,0 +1,110 @@ +#include "EntityConstants.hpp" +#include "GlobalConstantBufferManager.hpp" + +using namespace mce; + +EntityConstants::EntityConstants() +{ + OVERLAY_COLOR = nullptr; + TILE_LIGHT_COLOR = nullptr; + CHANGE_COLOR = nullptr; + // only these were initialized for some reason. + // I guess everything else can go fuck itself +} + +void EntityConstants::init() +{ + GlobalConstantBufferManager& bufferManager = GlobalConstantBufferManager::getInstance(); + m_constantBuffer = bufferManager.findConstantBufferContainer("EntityConstants"); + + ShaderConstantBase* pOverlayColor = m_constantBuffer->getUnspecializedShaderConstant("OVERLAY_COLOR"); + if (pOverlayColor) + { + if (pOverlayColor->getType() == SHADER_PRIMITIVE_FLOAT4) + { + OVERLAY_COLOR = (ShaderConstantFloat4*)pOverlayColor; + } + else + { + OVERLAY_COLOR = nullptr; + } + } + + ShaderConstantBase* pTileLightColor = m_constantBuffer->getUnspecializedShaderConstant("TILE_LIGHT_COLOR"); + if (pTileLightColor) + { + if (pTileLightColor->getType() == SHADER_PRIMITIVE_FLOAT4) + { + TILE_LIGHT_COLOR = (ShaderConstantFloat4*)pTileLightColor; + } + else + { + TILE_LIGHT_COLOR = nullptr; + } + } + + ShaderConstantBase* pChangeColor = m_constantBuffer->getUnspecializedShaderConstant("CHANGE_COLOR"); + if (pChangeColor) + { + if (pChangeColor->getType() == SHADER_PRIMITIVE_FLOAT4) + { + CHANGE_COLOR = (ShaderConstantFloat4*)pChangeColor; + } + else + { + CHANGE_COLOR = nullptr; + } + } + + ShaderConstantBase* pUvAnim = m_constantBuffer->getUnspecializedShaderConstant("UV_ANIM"); + if (pUvAnim) + { + if (pUvAnim->getType() == SHADER_PRIMITIVE_FLOAT2) + { + UV_ANIM = (ShaderConstantFloat2*)pUvAnim; + } + else + { + UV_ANIM = nullptr; + } + } + + ShaderConstantBase* pUvOffset = m_constantBuffer->getUnspecializedShaderConstant("UV_OFFSET"); + if (pUvOffset) + { + if (pUvOffset->getType() == SHADER_PRIMITIVE_FLOAT2) + { + UV_OFFSET = (ShaderConstantFloat2*)pUvOffset; + } + else + { + UV_OFFSET = nullptr; + } + } + + ShaderConstantBase* pUvRotation = m_constantBuffer->getUnspecializedShaderConstant("UV_ROTATION"); + if (pUvRotation) + { + if (pUvRotation->getType() == SHADER_PRIMITIVE_FLOAT2) + { + UV_ROTATION = (ShaderConstantFloat2*)pUvRotation; + } + else + { + UV_ROTATION = nullptr; + } + } + + ShaderConstantBase* pGlintUvScale = m_constantBuffer->getUnspecializedShaderConstant("GLINT_UV_SCALE"); + if (pGlintUvScale) + { + if (pGlintUvScale->getType() == SHADER_PRIMITIVE_FLOAT2) + { + GLINT_UV_SCALE = (ShaderConstantFloat2*)pGlintUvScale; + } + else + { + GLINT_UV_SCALE = nullptr; + } + } +} \ No newline at end of file diff --git a/source/renderer/EntityConstants.hpp b/source/renderer/EntityConstants.hpp new file mode 100644 index 000000000..ed60f5910 --- /dev/null +++ b/source/renderer/EntityConstants.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include "renderer/hal/interface/ConstantBufferConstants.hpp" +#include "renderer/hal/interface/ShaderConstantWithData.hpp" + +namespace mce +{ + class EntityConstants : public ConstantBufferConstants + { + public: + ShaderConstantFloat4 *OVERLAY_COLOR; + ShaderConstantFloat4 *TILE_LIGHT_COLOR; + ShaderConstantFloat4 *CHANGE_COLOR; + ShaderConstantFloat2 *UV_ANIM; + ShaderConstantFloat2 *UV_OFFSET; + ShaderConstantFloat2 *UV_ROTATION; + ShaderConstantFloat2 *GLINT_UV_SCALE; + + public: + EntityConstants(); + + void init(); + }; +} \ No newline at end of file diff --git a/source/renderer/GL/GL.cpp b/source/renderer/GL/GL.cpp index cb3b3d3e5..9fde5e12b 100644 --- a/source/renderer/GL/GL.cpp +++ b/source/renderer/GL/GL.cpp @@ -1,55 +1,10 @@ +#include #include "GL.hpp" -void drawArrayVT(GLuint buffer, int count, int stride) -{ - xglBindBuffer(GL_ARRAY_BUFFER, buffer); - xglTexCoordPointer(2, GL_FLOAT, stride, (void*)12); - xglEnableClientState(GL_TEXTURE_COORD_ARRAY); - xglVertexPointer(3, GL_FLOAT, stride, nullptr); - xglEnableClientState(GL_VERTEX_ARRAY); - xglDrawArrays(GL_TRIANGLES, 0, count); - xglDisableClientState(GL_VERTEX_ARRAY); - xglDisableClientState(GL_TEXTURE_COORD_ARRAY); -} - -void drawArrayVTC(GLuint buffer, int count, int stride) -{ - xglBindBuffer(GL_ARRAY_BUFFER, buffer); - xglVertexPointer(3, GL_FLOAT, stride, nullptr); - xglTexCoordPointer(2, GL_FLOAT, stride, (void*)12); - xglColorPointer(4, GL_UNSIGNED_BYTE, stride, (void*)20); - xglEnableClientState(GL_VERTEX_ARRAY); - xglEnableClientState(GL_TEXTURE_COORD_ARRAY); - xglEnableClientState(GL_COLOR_ARRAY); - xglDrawArrays(GL_TRIANGLES, 0, count); - xglDisableClientState(GL_VERTEX_ARRAY); - xglDisableClientState(GL_TEXTURE_COORD_ARRAY); - xglDisableClientState(GL_COLOR_ARRAY); -} - -void drawArrayVTN(GLuint buffer, int count, int stride) -{ -#ifdef USE_GL_NORMAL_LIGHTING - xglBindBuffer(GL_ARRAY_BUFFER, buffer); - xglTexCoordPointer(2, GL_FLOAT, stride, (void*)12); - xglEnableClientState(GL_TEXTURE_COORD_ARRAY); - xglVertexPointer(3, GL_FLOAT, stride, nullptr); - xglEnableClientState(GL_VERTEX_ARRAY); - xglNormalPointer(GL_BYTE, stride, (void*)24); - xglEnableClientState(GL_NORMAL_ARRAY); - xglDrawArrays(GL_TRIANGLES, 0, count); - xglDisableClientState(GL_NORMAL_ARRAY); - xglDisableClientState(GL_VERTEX_ARRAY); - xglDisableClientState(GL_TEXTURE_COORD_ARRAY); -#else - drawArrayVT(buffer, count, stride); -#endif -} - // It appears Mojang took the code from: // https://www.khronos.org/opengl/wiki/GluProject_and_gluUnProject_code -int glhProjectf(float objx, float objy, float objz, float* modelview, float* projection, int* viewport, float* windowCoordinate) +int glhProjectf(float objx, float objy, float objz, const float* modelview, const float* projection, int* viewport, float* windowCoordinate) { // Transformation vectors float fTempo[8]; @@ -81,7 +36,7 @@ int glhProjectf(float objx, float objy, float objz, float* modelview, float* pro return 1; } -int glhUnProjectf(float winx, float winy, float winz, float* modelview, float* projection, int* viewport, float* objectCoordinate) +int glhUnProjectf(float winx, float winy, float winz, const float* modelview, const float* projection, int* viewport, float* objectCoordinate) { // Transformation matrices float m[16], A[16]; @@ -108,7 +63,7 @@ int glhUnProjectf(float winx, float winy, float winz, float* modelview, float* p return 1; } -void MultiplyMatrices4by4OpenGL_FLOAT(float* result, float* matrix1, float* matrix2) +void MultiplyMatrices4by4OpenGL_FLOAT(float* result, const float* matrix1, const float* matrix2) { result[0] = matrix1[0] * matrix2[0] + matrix1[4] * matrix2[1] + diff --git a/source/renderer/GL/GL.hpp b/source/renderer/GL/GL.hpp index 54ec316d3..c7118204a 100644 --- a/source/renderer/GL/GL.hpp +++ b/source/renderer/GL/GL.hpp @@ -1,14 +1,8 @@ #pragma once -#include "thirdparty/GL/GL.hpp" - -void drawArrayVT(GLuint buffer, int count, int stride); -void drawArrayVTC(GLuint buffer, int count, int stride); -void drawArrayVTN(GLuint buffer, int count, int stride); - int glhInvertMatrixf2(float* m, float* out); -int glhProjectf(float objx, float objy, float objz, float* modelview, float* projection, int* viewport, float* windowCoordinate); -int glhUnProjectf(float winx, float winy, float winz, float* modelview, float* projection, int* viewport, float* objectCoordinate); +int glhProjectf(float objx, float objy, float objz, const float* modelview, const float* projection, int* viewport, float* windowCoordinate); +int glhUnProjectf(float winx, float winy, float winz, const float* modelview, const float* projection, int* viewport, float* objectCoordinate); -void MultiplyMatrices4by4OpenGL_FLOAT(float* result, float* matrix1, float* matrix2); +void MultiplyMatrices4by4OpenGL_FLOAT(float* result, const float* matrix1, const float* matrix2); void MultiplyMatrixByVector4by4OpenGL_FLOAT(float* resultvector, const float* matrix, const float* pvector); diff --git a/source/renderer/GlobalConstantBufferManager.cpp b/source/renderer/GlobalConstantBufferManager.cpp new file mode 100644 index 000000000..ef710675b --- /dev/null +++ b/source/renderer/GlobalConstantBufferManager.cpp @@ -0,0 +1,38 @@ +#include +#include "GlobalConstantBuffers.hpp" +#include "ShaderConstants.hpp" +#include "GlobalConstantBufferManager.hpp" + +using namespace mce; + +GlobalConstantBufferManager::GlobalConstantBufferManager() +{ +} + +void GlobalConstantBufferManager::refreshWorldConstants() +{ + GlobalConstantBuffers& buffers = GlobalConstantBuffers::getInstance(); + + buffers.m_worldConstants.refreshWorldConstants(); + buffers.m_shaderConstants.setShaderColors(currentShaderColor, currentShaderDarkColor); +} + +void GlobalConstantBufferManager::allocateAndSetupConstantBuffersFromMetadata(RenderContext& context) +{ + for (std::vector::iterator it = m_constantBufferContainers.begin(); it != m_constantBufferContainers.end(); it++) + { + it->allocateRenderContextBuffer(context); + } +} + +ConstantBufferContainer* GlobalConstantBufferManager::findConstantBufferContainer(const std::string& bufferName) +{ + for (std::vector::iterator it = m_constantBufferContainers.begin(); it != m_constantBufferContainers.end(); it++) + { + if (it->getConstantBufferName() == bufferName) + return &*it; // solid + } + + LOG_E("Couldn't find the constant buffer named: %s was it properly reflected in the uniforms metadata file?", bufferName.c_str()); + throw std::bad_cast(); +} \ No newline at end of file diff --git a/source/renderer/GlobalConstantBufferManager.hpp b/source/renderer/GlobalConstantBufferManager.hpp new file mode 100644 index 000000000..7b33a4151 --- /dev/null +++ b/source/renderer/GlobalConstantBufferManager.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include + +#include "common/utility/Singleton.hpp" +#include "renderer/hal/interface/ConstantBufferContainer.hpp" + +namespace mce +{ + class GlobalConstantBufferManager : public Singleton + { + public: + std::vector m_constantBufferContainers; + + public: + GlobalConstantBufferManager(); + + public: + void refreshWorldConstants(); + void allocateAndSetupConstantBuffersFromMetadata(RenderContext& context); + ConstantBufferContainer* findConstantBufferContainer(const std::string& bufferName); + }; +} \ No newline at end of file diff --git a/source/renderer/GlobalConstantBuffers.cpp b/source/renderer/GlobalConstantBuffers.cpp new file mode 100644 index 000000000..d8fceddbf --- /dev/null +++ b/source/renderer/GlobalConstantBuffers.cpp @@ -0,0 +1,13 @@ +#include "GlobalConstantBuffers.hpp" + +using namespace mce; + +void GlobalConstantBuffers::init() +{ + m_worldConstants.init(); + m_renderChunkConstants.init(); + m_perFrameConstants.init(); + m_entityConstants.init(); + m_shaderConstants.init(); + m_weatherConstants.init(); +} \ No newline at end of file diff --git a/source/renderer/GlobalConstantBuffers.hpp b/source/renderer/GlobalConstantBuffers.hpp new file mode 100644 index 000000000..30a43cf0d --- /dev/null +++ b/source/renderer/GlobalConstantBuffers.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include "common/utility/Singleton.hpp" +#include "RenderChunkConstants.hpp" +#include "WorldConstants.hpp" +#include "PerFrameConstants.hpp" +#include "EntityConstants.hpp" +#include "ShaderConstants.hpp" +#include "WeatherConstants.hpp" + +namespace mce +{ + class GlobalConstantBuffers : public Singleton + { + public: + RenderChunkConstants m_renderChunkConstants; + WorldConstants m_worldConstants; + PerFrameConstants m_perFrameConstants; + EntityConstants m_entityConstants; + ShaderConstants m_shaderConstants; + WeatherConstants m_weatherConstants; + + public: + void init(); + }; +} \ No newline at end of file diff --git a/source/renderer/MaterialPtr.cpp b/source/renderer/MaterialPtr.cpp new file mode 100644 index 000000000..ba7af6644 --- /dev/null +++ b/source/renderer/MaterialPtr.cpp @@ -0,0 +1,84 @@ +#include + +#include "MaterialPtr.hpp" +#include "common/Logger.hpp" +#include "client/renderer/renderer/RenderMaterialGroup.hpp" + +using namespace mce; + +MaterialPtr MaterialPtr::NONE; + +MaterialPtr::MaterialPtr() +{ + m_pGroup = nullptr; + m_pMaterial = nullptr; +} + +MaterialPtr::MaterialPtr(RenderMaterialGroup& group, const std::string& name) + : m_pGroup(&group) + , m_pMaterial(nullptr) + , m_name(name) +{ + m_pGroup->_addRef(*this); + onGroupReloaded(); +} + +MaterialPtr::~MaterialPtr() +{ + _deref(); +} + +void MaterialPtr::_move(MaterialPtr& other) +{ + m_pGroup = other.m_pGroup; + m_pMaterial = other.m_pMaterial; + std::swap(m_name, other.m_name); + other._deref(); + m_pGroup->_addRef(*this); +} + +void MaterialPtr::_deref() +{ + if (m_pGroup != nullptr) + { + m_pGroup->_removeRef(*this); + m_pGroup = nullptr; + } + m_pMaterial = nullptr; +} + +void MaterialPtr::onGroupReloaded() +{ + if (m_pGroup == nullptr) + { + LOG_E("Null ptrs may never be registered!"); + throw std::bad_cast(); + } + + m_pMaterial = m_pGroup->_getMaterial(m_name); +} + +RenderMaterial* MaterialPtr::operator->() const +{ + if (!m_pMaterial) + { + LOG_E("Invalid dereference"); + throw std::bad_cast(); + } + return m_pMaterial; +} + +MaterialPtr::operator bool() const +{ + return *this != MaterialPtr::NONE; +} + +bool MaterialPtr::operator==(const MaterialPtr& other) const +{ + return this->m_pMaterial == other.m_pMaterial; +} + +bool MaterialPtr::operator!=(const MaterialPtr& other) const +{ + return this->m_pMaterial != other.m_pMaterial; +} \ No newline at end of file diff --git a/source/renderer/MaterialPtr.hpp b/source/renderer/MaterialPtr.hpp new file mode 100644 index 000000000..5e0378bdf --- /dev/null +++ b/source/renderer/MaterialPtr.hpp @@ -0,0 +1,38 @@ +#pragma once + +#include +#include "compat/LegacyCPP.hpp" + +namespace mce +{ + class RenderMaterial; + class RenderMaterialGroup; + + class MaterialPtr + { + public: + static MaterialPtr NONE; + + public: + RenderMaterialGroup* m_pGroup; + RenderMaterial* m_pMaterial; + std::string m_name; + + public: + MaterialPtr(); + MC_CTOR_MOVE(MaterialPtr); + MaterialPtr(RenderMaterialGroup& group, std::string const& name); + ~MaterialPtr(); + + void _deref(); + void _move(MaterialPtr& other); + + void onGroupReloaded(); + + RenderMaterial* operator->() const; + operator bool() const; + MC_FUNC_MOVE(MaterialPtr); + bool operator==(const MaterialPtr& other) const; + bool operator!=(const MaterialPtr& other) const; + }; +} \ No newline at end of file diff --git a/source/renderer/MatrixStack.cpp b/source/renderer/MatrixStack.cpp new file mode 100644 index 000000000..fcdc8470a --- /dev/null +++ b/source/renderer/MatrixStack.cpp @@ -0,0 +1,196 @@ +#include +#include "MatrixStack.hpp" +#include "thirdparty/glm/gtc/matrix_transform.hpp" +#include "thirdparty/glm/gtc/type_ptr.hpp" +#include "common/Logger.hpp" + +Matrix Matrix::EMPTY = Matrix(0.0f); +Matrix Matrix::IDENTITY = Matrix(1.0f); + +MatrixStack MatrixStack::View = MatrixStack(); +MatrixStack MatrixStack::World = MatrixStack(); +MatrixStack MatrixStack::Projection = MatrixStack(); + +Matrix::Matrix() +{ + // Empty glm::mat4 ctor makes identity matrix no matter what in GLM 0.9.5.4 + _m = glm::mat4(EMPTY._m); +} + +Matrix::Matrix(float s) +{ + _m = glm::mat4(s); +} + +Matrix::Matrix(const glm::mat4& v) +{ + _m = v; +} + +void Matrix::rotate(float angle, const Vec3& axis) +{ + _m = glm::rotate(_m, glm::radians(angle), glm::normalize(glm::vec3(axis.x, axis.y, axis.z))); +} + +void Matrix::scale(const Vec3& s) +{ + _m = glm::scale(_m, glm::vec3(s.x, s.y, s.z)); +} + +void Matrix::setOrtho(float left, float right, float bottom, float top, float Znear, float Zfar) +{ + _m = glm::ortho(left, right, bottom, top, Znear, Zfar); +} + +void Matrix::setPerspective(float fov, float aspect, float Znear, float Zfar) +{ + _m = glm::perspective(glm::radians(fov), aspect, Znear, Zfar); +} + +void Matrix::transform3(Vec3& outVec, float& outW) +{ + glm::vec4 temp_vec(glm::vec3(outVec.x, outVec.y, outVec.z), outW); + + glm::vec4 result = _m * temp_vec; + glm::vec3 result3(result); + + outVec = Vec3(result.x, result.y, result.z); + outW = result.w; +} + +void Matrix::translate(const Vec3& t) +{ + _m = glm::translate(_m, glm::vec3(t.x, t.y, t.z)); +} + +const float* Matrix::ptr() const +{ + return glm::value_ptr(_m); +} + +float* Matrix::getPtr() +{ + return glm::value_ptr(_m); +} + +Matrix Matrix::operator*(const Matrix& other) const +{ + return Matrix(this->_m * other._m); +} + +MatrixStack::MatrixStack() +{ + m_bIsDirty = true; + _pushIdentity(); +} + +MatrixStack::Ref MatrixStack::push() +{ + m_bIsDirty = true; + return Ref(*this, _push()); +} + +MatrixStack::Ref MatrixStack::pushIdentity() +{ + m_bIsDirty = true; + return Ref(*this, _pushIdentity()); +} + +Matrix& MatrixStack::_push() +{ + m_stack.push(Matrix(m_stack.top())); + return m_stack.top(); +} + +Matrix& MatrixStack::_pushIdentity() +{ + m_stack.push(Matrix(1.0f)); // cannot count on Matrix::IDENTITY being initialized + return m_stack.top(); +} + +const Matrix& MatrixStack::top() const +{ + return m_stack.top(); +} + +Matrix& MatrixStack::getTop() +{ + m_bIsDirty = true; + return m_stack.top(); +} + +void MatrixStack::pop() +{ + m_bIsDirty = true; + + if (empty()) + { + LOG_E("Bad stack usage"); + throw std::bad_cast(); + } + + m_stack.pop(); +} + +MatrixStack::Ref::Ref() +{ + m_pStack = nullptr; + m_pMatrix = nullptr; +} + +MatrixStack::Ref::Ref(MatrixStack& mtxStk, Matrix& mtx) +{ + m_pStack = &mtxStk; + m_pMatrix = &mtx; +} + +MatrixStack::Ref::~Ref() +{ + release(); +} + +void MatrixStack::Ref::_move(MatrixStack::Ref& other) +{ + if (this == &other) + return; + + if (m_pMatrix || m_pStack) + { + LOG_E("It doesn't really make sense to pop here, so can't release"); + throw std::bad_cast(); + } + + this->m_pStack = other.m_pStack; + this->m_pMatrix = other.m_pMatrix; + other.m_pStack = nullptr; +} + +void MatrixStack::Ref::release() +{ + if (m_pStack) + m_pStack->pop(); + m_pMatrix = nullptr; + m_pStack = nullptr; +} + +Matrix* MatrixStack::Ref::operator->() +{ + return m_pMatrix; +} + +Matrix* MatrixStack::Ref::operator*() +{ + if (!m_pMatrix) + { + LOG_E("Dereferencing a null reference"); + throw std::bad_cast(); + } + m_pStack->m_bIsDirty = true; + return m_pMatrix; +} + +MatrixStack::Ref& MatrixStack::Ref::operator=(const Matrix& value) +{ + *(this->m_pMatrix) = value; + return *this; +} diff --git a/source/renderer/MatrixStack.hpp b/source/renderer/MatrixStack.hpp new file mode 100644 index 000000000..3e7ce9120 --- /dev/null +++ b/source/renderer/MatrixStack.hpp @@ -0,0 +1,100 @@ +#pragma once + +#include +#define GLM_FORCE_RADIANS +#include "thirdparty/glm/glm.hpp" +#include "compat/LegacyCPP.hpp" +#include "world/phys/Vec3.hpp" + +enum MatrixType +{ + MATRIX_VIEW, + MATRIX_PROJECTION +}; + +class Matrix +{ +public: + static Matrix EMPTY; + static Matrix IDENTITY; + +public: + glm::mat4 _m; + +public: + Matrix(); // create an empty matrix + Matrix(float s); // create an identity matrix + Matrix(const glm::mat4& v); + + void rotate(float angle, const Vec3& axis); + void scale(const Vec3& s); + void setOrtho(float left, float right, float bottom, float top, float Znear, float Zfar); + void setPerspective(float fov, float aspect, float Znear, float Zfar); + void transform3(Vec3& outVec, float& outW); + void translate(const Vec3& t); + const float* ptr() const; + float* getPtr(); + + Matrix operator*(const Matrix& other) const; +}; + +class MatrixStack +{ +public: + class Ref; + +public: + static MatrixStack View; + static MatrixStack World; + static MatrixStack Projection; + +private: + std::stack m_stack; + bool m_bIsDirty; + +public: + MatrixStack(); + +private: + Matrix& _push(); + Matrix& _pushIdentity(); + +public: + const Matrix& top() const; + Matrix& getTop(); + bool empty() const { return m_stack.empty(); } + bool isDirty() const { return m_bIsDirty; } + void makeClean() { m_bIsDirty = false; }; + void pop(); + size_t size() const { return m_stack.size(); } + Ref push(); + Ref pushIdentity(); + + class Ref + { + private: + MatrixStack* m_pStack; + Matrix* m_pMatrix; + + public: + Ref(); + Ref(MatrixStack& mtxStk, Matrix& mtx); + MC_CTOR_MOVE(Ref); + ~Ref(); + + private: + void _move(Ref& other); + + public: + void release(); + + const MatrixStack* stack() const { return m_pStack; } + const Matrix* matrix() const { return m_pMatrix; } + + operator Matrix&() { return *m_pMatrix; } + Matrix* operator->(); + Matrix* operator*(); + Ref& operator=(const Matrix& value); + MC_FUNC_MOVE(Ref); + }; +}; \ No newline at end of file diff --git a/source/renderer/Mesh.cpp b/source/renderer/Mesh.cpp new file mode 100644 index 000000000..fb23b8b2d --- /dev/null +++ b/source/renderer/Mesh.cpp @@ -0,0 +1,182 @@ +#include "Mesh.hpp" +#include "GlobalConstantBufferManager.hpp" +#include "RenderContextImmediate.hpp" +#include "RenderMaterial.hpp" +#include "QuadIndexBuffer.hpp" +#include "MatrixStack.hpp" + +using namespace mce; + +Mesh::Mesh() +{ + m_indexCount = 0; + m_vertexCount = 0; + m_primitiveMode = PRIMITIVE_MODE_NONE; + m_indexSize = 0; + m_rawData = nullptr; +} + +Mesh::Mesh(const VertexFormat& vertexFormat, unsigned int vertexCount, unsigned int indexCount, uint8_t indexSize, PrimitiveMode primitiveMode, uint8_t *data, bool temporary) + : m_vertexCount(vertexCount) + , m_indexCount(indexCount) + , m_primitiveMode(primitiveMode) + , m_vertexFormat(vertexFormat) + , m_indexSize(indexSize) +{ + if (temporary) + { + m_rawData = data; + } + else + { + m_rawData = nullptr; + if (!loadRawData(RenderContextImmediate::get(), data)) + { + reset(); + } + } +} + +Mesh::~Mesh() +{ + reset(); +} + +void Mesh::_move(Mesh& other) +{ + this->m_vertexBuffer = other.m_vertexBuffer; + this->m_indexBuffer = other.m_indexBuffer; + this->m_vertexCount = other.m_vertexCount; + this->m_vertexFormat = other.m_vertexFormat; + this->m_indexCount = other.m_indexCount; + this->m_indexSize = other.m_indexSize; + this->m_primitiveMode = other.m_primitiveMode; + this->m_rawData = other.m_rawData; + + other.m_vertexFormat = VertexFormat::EMPTY; + other.m_indexCount = 0; + other.m_vertexCount = 0; +} + +void Mesh::reset() +{ + m_vertexBuffer.releaseBuffer(); + m_indexBuffer.releaseBuffer(); + m_vertexCount = 0; + m_indexCount = 0; + m_primitiveMode = PRIMITIVE_MODE_NONE; + m_vertexFormat = VertexFormat::EMPTY; + m_indexSize = 0; + m_rawData = nullptr; +} + +bool Mesh::loadRawData(RenderContext& context, uint8_t *data) +{ + if (!data) + return false; + if (m_vertexCount <= 2) + return false; + if (m_primitiveMode == PRIMITIVE_MODE_NONE) + return false; + if (!m_vertexFormat) + return false; + + unsigned int vertexSize = m_vertexFormat.getVertexSize(); + m_vertexBuffer.createVertexBuffer(context, vertexSize, data, m_vertexCount); + + if (m_indexCount == 0) + return true; + + unsigned int index = m_vertexCount * vertexSize; + m_indexBuffer.createIndexBuffer(context, m_indexSize, &data[index], m_indexCount); + + return true; +} + +void Mesh::render(const MaterialPtr& materialPtr, unsigned int startOffset, unsigned int count) +{ + RenderContext& context = RenderContextImmediate::get(); + + if (!isValid()) + return; + + unsigned int vertexCount = (count > 0) ? count : m_vertexCount; + + if (isTemporary()) + { + ImmediateBuffer& immediateBuffer = context.m_immediateBuffer; + + if (!immediateBuffer.isValid()) + { + // Create 1MB shared vertex buffer in VRAM + immediateBuffer.createDynamicBuffer(context, 1, nullptr, 0x100000, BUFFER_TYPE_VERTEX); + } + + unsigned int vertexSize = m_vertexFormat.getVertexSize(); + void* vertexData = m_rawData; + immediateBuffer.updateBuffer(context, vertexSize, vertexData, vertexCount); + } + else + { + m_vertexBuffer.bindBuffer(context); + } + + GlobalConstantBufferManager& bufferManager = GlobalConstantBufferManager::getInstance(); + bufferManager.refreshWorldConstants(); + + if (materialPtr) + { + materialPtr->useWith(context, m_vertexFormat, m_rawData); +#ifdef FEATURE_GFX_SHADERS + materialPtr->m_pShader->validateVertexFormat(m_vertexFormat); +#endif + } + else + { + assert(false); + } + +#ifndef FEATURE_GFX_SHADERS + context.setVertexState(m_vertexFormat); +#endif + + if (m_primitiveMode == PRIMITIVE_MODE_QUAD_LIST) + { + uint8_t indexSize = m_indexSize; + Buffer& quadIndexBuffer = QuadIndexBuffer::get(context, m_vertexCount, indexSize); + quadIndexBuffer.bindBuffer(context); + + unsigned int indexCountToDraw = (count > 0) ? count : (m_vertexCount / 4) * 6; // 6 vertecies per quad + context.drawIndexed(m_primitiveMode, indexCountToDraw, startOffset, indexSize); + } + else if (m_indexCount > 0) + { + m_indexBuffer.bindBuffer(context); + + unsigned int indexCountToDraw = (count > 0) ? count : m_indexCount; + context.drawIndexed(m_primitiveMode, indexCountToDraw, startOffset, m_indexSize); + } + else + { + context.draw(m_primitiveMode, startOffset, vertexCount); + } + +#ifndef FEATURE_GFX_SHADERS + context.clearVertexState(m_vertexFormat); +#endif +} + +bool Mesh::isValid() const +{ + return ((m_vertexBuffer.isValid() && m_vertexCount > 0) || isTemporary()) && m_vertexFormat; +} + +bool Mesh::isTemporary() const +{ + return m_rawData != nullptr; +} + +void Mesh::clearGlobalBuffers() +{ + // Empty on OGL and DX11 +} \ No newline at end of file diff --git a/source/renderer/Mesh.hpp b/source/renderer/Mesh.hpp new file mode 100644 index 000000000..24b761988 --- /dev/null +++ b/source/renderer/Mesh.hpp @@ -0,0 +1,45 @@ +#pragma once + +#include "renderer/hal/enums/PrimitiveMode.hpp" +#include "renderer/hal/interface/Buffer.hpp" + +#include "VertexFormat.hpp" +#include "MaterialPtr.hpp" + +namespace mce +{ + class Mesh + { + public: + unsigned int m_indexCount; + unsigned int m_vertexCount; + PrimitiveMode m_primitiveMode; + VertexFormat m_vertexFormat; + uint8_t m_indexSize; + Buffer m_vertexBuffer; + Buffer m_indexBuffer; + void *m_rawData; + + public: + Mesh(); + MC_CTOR_MOVE(Mesh); + Mesh(const VertexFormat& vertexFormat, unsigned int vertexCount, unsigned int indexCount, uint8_t indexSize, PrimitiveMode primitiveMode, uint8_t *data, bool temporary); + ~Mesh(); + + protected: + void _move(Mesh& other); + + public: + void reset(); + bool loadRawData(RenderContext& context, uint8_t *data); + void render(const MaterialPtr& materialPtr, unsigned int startOffset = 0, unsigned int count = 0); + bool isValid() const; + bool isTemporary() const; + + public: + MC_FUNC_MOVE(Mesh); + + public: + static void clearGlobalBuffers(); + }; +} \ No newline at end of file diff --git a/source/renderer/PerFrameConstants.cpp b/source/renderer/PerFrameConstants.cpp new file mode 100644 index 000000000..22d75cdd1 --- /dev/null +++ b/source/renderer/PerFrameConstants.cpp @@ -0,0 +1,112 @@ +#include "PerFrameConstants.hpp" +#include "GlobalConstantBufferManager.hpp" + +using namespace mce; + +PerFrameConstants::PerFrameConstants() +{ + VIEW_DIRECTION = nullptr; + TIME = nullptr; + VIEW_POS = nullptr; + FAR_CHUNKS_DISTANCE = nullptr; + FOG_COLOR = nullptr; + FOG_CONTROL = nullptr; + RENDER_DISTANCE = nullptr; +} + +void PerFrameConstants::init() +{ + GlobalConstantBufferManager& bufferManager = GlobalConstantBufferManager::getInstance(); + m_constantBuffer = bufferManager.findConstantBufferContainer("PerFrameConstants"); + + ShaderConstantBase* pViewDirection = m_constantBuffer->getUnspecializedShaderConstant("VIEW_DIRECTION"); + if (pViewDirection) + { + if (pViewDirection->getType() == SHADER_PRIMITIVE_FLOAT3) + { + VIEW_DIRECTION = (ShaderConstantFloat3*)pViewDirection; + } + else + { + VIEW_DIRECTION = nullptr; + } + } + + ShaderConstantBase* pTime = m_constantBuffer->getUnspecializedShaderConstant("TIME"); + if (pTime) + { + if (pTime->getType() == SHADER_PRIMITIVE_FLOAT1) + { + TIME = (ShaderConstantFloat1*)pTime; + } + else + { + TIME = nullptr; + } + } + + ShaderConstantBase* pViewPos = m_constantBuffer->getUnspecializedShaderConstant("VIEW_POS"); + if (pViewPos) + { + if (pViewPos->getType() == SHADER_PRIMITIVE_FLOAT3) + { + VIEW_POS = (ShaderConstantFloat3*)pViewPos; + } + else + { + VIEW_POS = nullptr; + } + } + + ShaderConstantBase* pFarChunksDistance = m_constantBuffer->getUnspecializedShaderConstant("FAR_CHUNKS_DISTANCE"); + if (pFarChunksDistance) + { + if (pFarChunksDistance->getType() == SHADER_PRIMITIVE_FLOAT1) + { + FAR_CHUNKS_DISTANCE = (ShaderConstantFloat1*)pFarChunksDistance; + } + else + { + FAR_CHUNKS_DISTANCE = nullptr; + } + } + + ShaderConstantBase* pFogColor = m_constantBuffer->getUnspecializedShaderConstant("FOG_COLOR"); + if (pFogColor) + { + if (pFogColor->getType() == SHADER_PRIMITIVE_FLOAT4) + { + FOG_COLOR = (ShaderConstantFloat4*)pFogColor; + } + else + { + FOG_COLOR = nullptr; + } + } + + ShaderConstantBase* pFogControl = m_constantBuffer->getUnspecializedShaderConstant("FOG_CONTROL"); + if (pFogControl) + { + if (pFogControl->getType() == SHADER_PRIMITIVE_FLOAT2) + { + FOG_CONTROL = (ShaderConstantFloat2*)pFogControl; + } + else + { + FOG_CONTROL = nullptr; + } + } + + ShaderConstantBase* pRenderDistance = m_constantBuffer->getUnspecializedShaderConstant("RENDER_DISTANCE"); + if (pRenderDistance) + { + if (pRenderDistance->getType() == SHADER_PRIMITIVE_FLOAT1) + { + RENDER_DISTANCE = (ShaderConstantFloat1*)pRenderDistance; + } + else + { + RENDER_DISTANCE = nullptr; + } + } +} \ No newline at end of file diff --git a/source/renderer/PerFrameConstants.hpp b/source/renderer/PerFrameConstants.hpp new file mode 100644 index 000000000..64381c52e --- /dev/null +++ b/source/renderer/PerFrameConstants.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include "renderer/hal/interface/ConstantBufferConstants.hpp" +#include "renderer/hal/interface/ShaderConstantWithData.hpp" + +namespace mce +{ + class PerFrameConstants : public ConstantBufferConstants + { + public: + ShaderConstantFloat3 *VIEW_DIRECTION; + ShaderConstantFloat1 *TIME; + ShaderConstantFloat3 *VIEW_POS; + ShaderConstantFloat1 *FAR_CHUNKS_DISTANCE; + ShaderConstantFloat4 *FOG_COLOR; + ShaderConstantFloat2 *FOG_CONTROL; + ShaderConstantFloat1 *RENDER_DISTANCE; + + public: + PerFrameConstants(); + + void init(); + }; +} \ No newline at end of file diff --git a/source/renderer/PlatformDefinitions.h b/source/renderer/PlatformDefinitions.h new file mode 100644 index 000000000..de3346a24 --- /dev/null +++ b/source/renderer/PlatformDefinitions.h @@ -0,0 +1,58 @@ +#include "GameMods.hpp" + +#if MCE_GFX_API_OGL +#define MCE_GFX_API OGL +#define MCE_GFX_API_DIR ogl +#endif + +#if MCE_GFX_API_D3D9 +#define MCE_GFX_API D3D9 +#define MCE_GFX_API_DIR d3d9 +#endif + +#if MCE_GFX_API_D3D11 +#define MCE_GFX_API D3D11 +#define MCE_GFX_API_DIR d3d11 +#endif + +#if MCE_GFX_API_GX1 +#define MCE_GFX_API GX1 +#define MCE_GFX_API_DIR gx1 +#endif + +#if MCE_GFX_API_GX2 +#define MCE_GFX_API GX2 +#define MCE_GFX_API_DIR gx2 +#endif + +#if MCE_GFX_API_NULL || !defined(MCE_GFX_API) +#define MCE_GFX_API Null +#define MCE_GFX_API_DIR null +#endif + +#define _MCE_GFX_CLASS_MANUA(className, api) className ## api +#define _MCE_GFX_CLASS_MANUAL(className, api) _MCE_GFX_CLASS_MANUA(className, api) +#define MCE_GFX_CLASS(className) _MCE_GFX_CLASS_MANUAL(className, MCE_GFX_API) + +// Macros are cursed +#define _STR(x) #x +#define STR(x) _STR(x) + +#define _MCE_GFX_CLASS_FILE(apiDir, className, fileExtension) STR(renderer/hal/apiDir/className.fileExtension) +#define _MCE_GFX_CLASS_HEADER_MANUAL(apiDir, className) _MCE_GFX_CLASS_FILE(apiDir, className, hpp) +#define MCE_GFX_CLASS_HEADER(className) _MCE_GFX_CLASS_HEADER_MANUAL(MCE_GFX_API_DIR, MCE_GFX_CLASS(className)) + +#define _MCE_GFX_CLASS_IMPL_MANUAL(apiDir, className) _MCE_GFX_CLASS_FILE(apiDir, className, cpp) +#define MCE_GFX_CLASS_IMPL(className) _MCE_GFX_CLASS_IMPL_MANUAL(MCE_GFX_API_DIR, MCE_GFX_CLASS(className)) + +#ifdef FEATURE_GFX_SHADERS +#define MCE_GFX_CLASS_SHADER(className) MCE_GFX_CLASS(className) +#define MCE_GFX_CLASS_HEADER_SHADER(className) MCE_GFX_CLASS_HEADER(className) +#define MCE_GFX_CLASS_FIXED(className) _MCE_GFX_CLASS_MANUA(className, Null) +#define MCE_GFX_CLASS_HEADER_FIXED(className) _MCE_GFX_CLASS_HEADER_MANUAL(null, MCE_GFX_CLASS_FIXED(className)) +#else +#define MCE_GFX_CLASS_SHADER(className) _MCE_GFX_CLASS_MANUA(className, Null) +#define MCE_GFX_CLASS_HEADER_SHADER(className) _MCE_GFX_CLASS_HEADER_MANUAL(null, MCE_GFX_CLASS_SHADER(className)) +#define MCE_GFX_CLASS_FIXED(className) MCE_GFX_CLASS(className) +#define MCE_GFX_CLASS_HEADER_FIXED(className) MCE_GFX_CLASS_HEADER(className) +#endif \ No newline at end of file diff --git a/source/renderer/QuadIndexBuffer.cpp b/source/renderer/QuadIndexBuffer.cpp new file mode 100644 index 000000000..ac4a9a63a --- /dev/null +++ b/source/renderer/QuadIndexBuffer.cpp @@ -0,0 +1,108 @@ +#include +#include +#include +#include "QuadIndexBuffer.hpp" + +using namespace mce; + +QuadIndexBuffer* QuadIndexBuffer::instance = nullptr; + +QuadIndexBuffer::QuadIndexBuffer() +{ + m_capacity = 0; + m_indexSize = 0; +} + +void QuadIndexBuffer::onAppTerminated() +{ + onAppSuspended(); +} + +void QuadIndexBuffer::onAppSuspended() +{ + m_capacity = 1; + m_globalBuffer.releaseBuffer(); + m_indexSize = 0; +} + +template +void _makeIndexBuffer(std::vector& indices, unsigned int vertexCount) +{ + constexpr unsigned int indexSize = sizeof(T) * 6; + const unsigned int quadCount = vertexCount / 4; + indices.resize(indexSize * quadCount); + for (unsigned int i = 0; i < quadCount; i++) + { + T baseVertex = static_cast(i * 4); + size_t baseIndex = i * indexSize; + + T* data = (T*)&indices[baseIndex]; + + // The index pattern creates two triangles for each quad (v, v+1, v+2, v+3): + // Triangle 1: (v+1, v+2, v) + data[0] = baseVertex + 1; + data[1] = baseVertex + 2; + data[2] = baseVertex + 0; + // Triangle 2: (v, v+2, v+3) + data[3] = baseVertex + 0; + data[4] = baseVertex + 2; + data[5] = baseVertex + 3; + } +} + +Buffer& QuadIndexBuffer::getGlobalQuadBuffer(RenderContext& context, unsigned int requiredCapacity, uint8_t& outIndexSize) +{ + if (m_capacity >= requiredCapacity) + { + outIndexSize = m_indexSize; + return m_globalBuffer; + } + + if (requiredCapacity == 0) + { + LOG_E("requiredCapacity cannot be 0"); + throw std::bad_cast(); + } + + while (m_capacity < requiredCapacity) + m_capacity *= 2; + + std::vector indices; + + // Use 16-bit indices for smaller buffers to save memory, otherwise use 32-bit. + if (m_capacity < 0x10000 || !RenderContext::supports32BitIndices()) + { + m_indexSize = sizeof(uint16_t); + _makeIndexBuffer(indices, m_capacity); + } + else + { + m_indexSize = sizeof(uint32_t); + _makeIndexBuffer(indices, m_capacity); + } + + void* data = &indices[0]; + + m_globalBuffer.createDynamicIndexBuffer(context, indices.size()); + m_globalBuffer.updateBuffer(context, m_indexSize, data, indices.size() / m_indexSize); + + outIndexSize = m_indexSize; + return m_globalBuffer; +} + +Buffer& QuadIndexBuffer::get(RenderContext& context, unsigned int requiredCapacity, uint8_t& outIndexSize) +{ + if (!instance) + { + instance = new QuadIndexBuffer(); + instance->m_capacity = 1; + } + + return instance->getGlobalQuadBuffer(context, requiredCapacity, outIndexSize); +} + +void QuadIndexBuffer::release() +{ + delete instance; + instance = nullptr; +} \ No newline at end of file diff --git a/source/renderer/QuadIndexBuffer.hpp b/source/renderer/QuadIndexBuffer.hpp new file mode 100644 index 000000000..e33660c50 --- /dev/null +++ b/source/renderer/QuadIndexBuffer.hpp @@ -0,0 +1,30 @@ +#pragma once + +#include "client/app/AppPlatformListener.hpp" +#include "renderer/hal/interface/Buffer.hpp" + +namespace mce +{ + class QuadIndexBuffer : public AppPlatformListener + { + private: + static QuadIndexBuffer* instance; + + private: + Buffer m_globalBuffer; + unsigned int m_capacity; + uint8_t m_indexSize; + + public: + QuadIndexBuffer(); + + public: + void onAppTerminated() override; + void onAppSuspended() override; + + Buffer& getGlobalQuadBuffer(RenderContext& context, unsigned int requiredCapacity, uint8_t& outIndexSize); + + static Buffer& get(RenderContext& context, unsigned int requiredCapacity, uint8_t& outIndexSize); + static void release(); + }; +} \ No newline at end of file diff --git a/source/renderer/RenderChunkConstants.cpp b/source/renderer/RenderChunkConstants.cpp new file mode 100644 index 000000000..2532b60d9 --- /dev/null +++ b/source/renderer/RenderChunkConstants.cpp @@ -0,0 +1,28 @@ +#include "RenderChunkConstants.hpp" +#include "GlobalConstantBufferManager.hpp" + +using namespace mce; + +RenderChunkConstants::RenderChunkConstants() +{ + CHUNK_ORIGIN = nullptr; +} + +void RenderChunkConstants::init() +{ + GlobalConstantBufferManager& bufferManager = GlobalConstantBufferManager::getInstance(); + m_constantBuffer = bufferManager.findConstantBufferContainer("RenderChunkConstants"); + + ShaderConstantBase* pChunkOrigin = m_constantBuffer->getUnspecializedShaderConstant("CHUNK_ORIGIN"); + if (pChunkOrigin) + { + if (pChunkOrigin->getType() == SHADER_PRIMITIVE_FLOAT3) + { + CHUNK_ORIGIN = (ShaderConstantFloat3*)pChunkOrigin; + } + else + { + CHUNK_ORIGIN = nullptr; + } + } +} \ No newline at end of file diff --git a/source/renderer/RenderChunkConstants.hpp b/source/renderer/RenderChunkConstants.hpp new file mode 100644 index 000000000..ab47ab1fa --- /dev/null +++ b/source/renderer/RenderChunkConstants.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include "renderer/hal/interface/ConstantBufferConstants.hpp" +#include "renderer/hal/interface/ShaderConstantWithData.hpp" + +namespace mce +{ + class RenderChunkConstants : public ConstantBufferConstants + { + public: + ShaderConstantFloat3* CHUNK_ORIGIN; + + public: + RenderChunkConstants(); + + void init(); + }; +} \ No newline at end of file diff --git a/source/renderer/RenderContextImmediate.cpp b/source/renderer/RenderContextImmediate.cpp new file mode 100644 index 000000000..1941e9713 --- /dev/null +++ b/source/renderer/RenderContextImmediate.cpp @@ -0,0 +1,14 @@ +#include "renderer/hal/interface/RenderDevice.hpp" +#include "RenderContextImmediate.hpp" + +using namespace mce; + +RenderContext& RenderContextImmediate::get() +{ + return RenderDevice::getInstance().getRenderContext(); +} + +const RenderContext& RenderContextImmediate::getAsConst() +{ + return RenderDevice::getInstance().getRenderContextAsConst(); +} \ No newline at end of file diff --git a/source/renderer/RenderContextImmediate.hpp b/source/renderer/RenderContextImmediate.hpp new file mode 100644 index 000000000..39c653b68 --- /dev/null +++ b/source/renderer/RenderContextImmediate.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include "renderer/hal/interface/RenderContext.hpp" + +namespace mce +{ + class RenderContextImmediate + { + public: + static RenderContext& get(); + static const RenderContext& getAsConst(); + }; +} \ No newline at end of file diff --git a/source/renderer/RenderMaterial.cpp b/source/renderer/RenderMaterial.cpp new file mode 100644 index 000000000..5909af9f2 --- /dev/null +++ b/source/renderer/RenderMaterial.cpp @@ -0,0 +1,305 @@ +#include "RenderMaterial.hpp" + +#include "PlatformDefinitions.h" + +#include "common/utility/JsonParser.hpp" + +#include "renderer/hal/enums/RenderState_JsonParser.hpp" +#include "renderer/hal/enums/ComparisonFunc.hpp" +#include "renderer/hal/enums/StencilOp.hpp" +#include "renderer/hal/enums/ShaderStagesBits.hpp" +#include "RenderContextImmediate.hpp" + +#include "EnableScissorTest.hpp" + +#if MCE_GFX_API_OGL +#include "platform/ogl/ShaderPrecision.hpp" +#endif + +using namespace mce; + +RenderMaterial* RenderMaterial::lastUsedMaterial = nullptr; + +RenderMaterial::RenderMaterial() +{ + m_stateMask = 0; + m_polygonOffsetLevel = -2.0f; + m_pShader = nullptr; +} + +RenderMaterial::RenderMaterial(const rapidjson::Value& root, const RenderMaterial& parent) +{ + *this = parent; + _parseRenderStates(root); + _parseRuntimeStates(root); + + + _parseShaderPaths(root); + if (!m_vertexShader.empty() && !m_fragmentShader.empty()) + { + _parseDefines(root); +#ifdef FEATURE_GFX_SHADERS + _loadShader(*ShaderGroup::singleton()); +#endif + } + + _applyRenderStates(); + + RenderContext& renderContext = RenderContextImmediate::get(); + m_blendState.createBlendState(renderContext, m_blendStateDescription); + m_depthStencilState.createDepthState(renderContext, m_depthStencilStateDescription); + m_rasterizerState.createRasterizerStateDescription(renderContext, m_rasterizerStateDescription); + m_fixedPipelineState.createFixedPipelineState(renderContext, m_fixedPipelineStateDescription); +} + +RenderState RenderMaterial::_parseStateName(const std::string& stateName) const +{ + return ((std::map)_renderStateMap)[stateName]; +} + +void RenderMaterial::_parseRenderStates(const rapidjson::Value& root) +{ + if (!root.HasMember("states")) + return; + + const rapidjson::Value& statesValue = root["states"]; + for (rapidjson::Value::ConstValueIterator it = statesValue.Begin(); it != statesValue.End(); it++) + { + std::string stateName = it->GetString(); + RenderState state = _parseStateName(stateName); + addState(state); + } +} + +void RenderMaterial::_parseRuntimeStates(const rapidjson::Value& root) +{ + _parseDepthStencilState(root); + _parseBlendState(root); + _parseFixedPipelineState(root); + + if (root.HasMember("polygonOffsetLevel")) + { + const rapidjson::Value& polygonOffsetLevelValue = root["polygonOffsetLevel"]; + if (!polygonOffsetLevelValue.IsNull()) + m_polygonOffsetLevel = polygonOffsetLevelValue.GetFloat(); + } +} + +void RenderMaterial::_parseDepthStencilFace(const rapidjson::Value& root, const char* depthStencilFaceName, StencilFaceDescription& faceDescription) const +{ + if (!root.HasMember("depthStencilFaceName")) + return; + + const rapidjson::Value& value = root[depthStencilFaceName]; + if (value.IsNull()) + return; + + parse(value, "stencilFunc", faceDescription.stencilFunc); + parse(value, "stencilFailOp", faceDescription.stencilFailOp); + parse(value, "stencilDepthFailOp", faceDescription.stencilDepthFailOp); + parse(value, "stencilPassOp", faceDescription.stencilPassOp); +} + +void RenderMaterial::_parseDepthStencilState(const rapidjson::Value& root) +{ + DepthStencilStateDescription& desc = m_depthStencilStateDescription; + + parse(root, "depthFunc", desc.depthFunc); + _parseDepthStencilFace(root, "frontFace", desc.frontFace); + _parseDepthStencilFace(root, "backFace", desc.frontFace); + + if (root.HasMember("stencilRef")) + { + const rapidjson::Value& stencilRefValue = root["stencilRef"]; + if (!stencilRefValue.IsNull()) + { + desc.overwroteStencilRef = true; + desc.stencilRef = stencilRefValue.GetUint(); + } + } + + if (root.HasMember("stencilReadMask")) + { + const rapidjson::Value& stencilReadMaskValue = root["stencilReadMask"]; + if (!stencilReadMaskValue.IsNull()) + { + desc.stencilReadMask = stencilReadMaskValue.GetUint(); + } + } +} + +void RenderMaterial::_parseBlendState(const rapidjson::Value& root) +{ + parse(root, "blendSrc", m_blendStateDescription.blendSource); + parse(root, "blendDst", m_blendStateDescription.blendDestination); +} + +void RenderMaterial::_parseFixedPipelineState(const rapidjson::Value& root) +{ + parse(root, "alphaFunc", m_fixedPipelineStateDescription.alphaFunc); + + if (root.HasMember("alphaRef")) + { + const rapidjson::Value& alphaRefValue = root["alphaRef"]; + if (!alphaRefValue.IsNull()) + m_fixedPipelineStateDescription.alphaRef = alphaRefValue.GetFloat(); + } +} + +void RenderMaterial::_parseDefines(const rapidjson::Value& root) +{ + if (!root.HasMember("defines")) + return; + + const rapidjson::Value& definesValue = root["defines"]; + for (rapidjson::Value::ConstValueIterator it = definesValue.Begin(); it != definesValue.End(); it++) + { + std::string defineStr = it->GetString(); + m_defines.insert(defineStr); + } +} + +void RenderMaterial::_parseShaderPaths(const rapidjson::Value& root) +{ + if (root.HasMember("vertexShader")) + { + const rapidjson::Value& pathValue = root["vertexShader"]; + if (!pathValue.IsNull()) + m_vertexShader = pathValue.GetString(); + } + if (root.HasMember("fragmentShader")) + { + const rapidjson::Value& pathValue = root["fragmentShader"]; + if (!pathValue.IsNull()) + m_fragmentShader = pathValue.GetString(); + } + if (root.HasMember("geometryShader")) + { + const rapidjson::Value& pathValue = root["geometryShader"]; + if (!pathValue.IsNull()) + m_geometryShader = pathValue.GetString(); + } +} + +#ifdef FEATURE_GFX_SHADERS + +std::string RenderMaterial::_buildHeader() +{ + std::string result; // Uses std::ostream in DX11 + +#if MCE_GFX_API_DX11 + // add R8G8B8A8_SNORM_UNSUPPORTED to defines if less than D3D_FEATURE_LEVEL_10_0 +#endif + + for (std::set::const_iterator it = m_defines.begin(); it != m_defines.end(); it++) + { + result += "#define " + *it + "\n"; + } + +#if MCE_GFX_API_OGL + result += Platform::OGL::Precision::buildHeader(); +#endif + + return result; +} + +void RenderMaterial::_loadShader(ShaderGroup& shaderGroup) +{ +#if MCE_GFX_API_DX11 + SpliceShaderPath(m_vertexShader); + SpliceShaderPath(m_fragmentShader); + SpliceShaderPath(m_geometryShader); +#endif + std::string header = _buildHeader(); + m_pShader = &shaderGroup.loadShader(header, m_vertexShader, m_fragmentShader, m_geometryShader); +} + +#endif // FEATURE_GFX_SHADERS + +void RenderMaterial::_applyRenderStates() +{ + ColorWriteMask colorWriteMask; + if (hasState(RS_DISABLE_COLOR_WRITE)) + colorWriteMask = COLOR_WRITE_MASK_NONE; + else + colorWriteMask = COLOR_WRITE_MASK_ALL; + + CullMode cullMode; + if (hasState(RS_INVERT_CULLING)) + cullMode = CULL_FRONT; + else + cullMode = CULL_BACK; + + if (hasState(RS_DISABLE_CULLING)) + cullMode = CULL_NONE; + + m_depthStencilStateDescription.depthTestEnabled = !hasState(RS_DISABLE_DEPTH_TEST); + m_depthStencilStateDescription.depthWriteMask = hasState(RS_DISABLE_DEPTH_WRITE) ? DEPTH_WRITE_MASK_NONE : DEPTH_WRITE_MASK_ALL; + m_depthStencilStateDescription.stencilTestEnabled = hasState(RS_ENABLE_STENCIL_TEST); + m_blendStateDescription.enableBlend = hasState(RS_BLENDING); + m_fixedPipelineStateDescription.enableAlphaTest = hasState(RS_ENABLE_ALPHA_TEST); + m_fixedPipelineStateDescription.enableTexture = hasState(RS_ENABLE_TEXTURE); + + float polygonOffsetLevel = 0.0f; + if (hasState(RS_POLYGON_OFFSET)) + polygonOffsetLevel = m_polygonOffsetLevel; + + m_blendStateDescription.colorWriteMask = colorWriteMask; + m_rasterizerStateDescription.cullMode = cullMode; + m_rasterizerStateDescription.depthBias = polygonOffsetLevel; +} + +void RenderMaterial::useWith(RenderContext& context, const VertexFormat& vertexFormat, const void *basePtr) +{ + m_blendState.bindBlendState(context); + + if (EnableScissorTest::scissorTestEnabled) + { + RasterizerStateDescription rasterizerDesc; + rasterizerDesc = m_rasterizerStateDescription; + rasterizerDesc.enableScissorTest = true; + + RasterizerState rasterizerState; + rasterizerState.createRasterizerStateDescription(context, rasterizerDesc); + rasterizerState.bindRasterizerState(context); + rasterizerState.setScissorRect( + context, + EnableScissorTest::activeScissorBox[0], EnableScissorTest::activeScissorBox[1], + EnableScissorTest::activeScissorBox[2], EnableScissorTest::activeScissorBox[3] + ); + } + else + { + m_rasterizerState.bindRasterizerState(context); + } + + m_depthStencilState.bindDepthStencilState(context); + + lastUsedMaterial = this; + +#ifdef FEATURE_GFX_SHADERS + m_pShader->bindShader(context, vertexFormat, basePtr, SHADER_STAGE_BITS_ALL); +#else + m_fixedPipelineState.bindFixedPipelineState(context); +#endif +} + +void RenderMaterial::addState(RenderState state) +{ + m_stateMask |= 1 << (state & 0x1F); +} + +void RenderMaterial::SpliceShaderPath(std::string& shaderName) +{ + size_t shaderPathPos = shaderName.find_first_not_of("shaders"); + if (shaderPathPos != std::string::npos && shaderName.find(".hlsl") == std::string::npos) + { + shaderName.insert(shaderPathPos, "/dx11"); + shaderName.append(".hlsl"); + } +} + +void RenderMaterial::InitContext() +{ + lastUsedMaterial = nullptr; +} \ No newline at end of file diff --git a/source/renderer/RenderMaterial.hpp b/source/renderer/RenderMaterial.hpp new file mode 100644 index 000000000..028da2cfc --- /dev/null +++ b/source/renderer/RenderMaterial.hpp @@ -0,0 +1,72 @@ +#pragma once + +#include +#include +#include + +#include "thirdparty/rapidjson/document.h" + +#include "renderer/hal/enums/RenderState.hpp" +#include "renderer/hal/interface/Shader.hpp" +#include "renderer/hal/interface/BlendState.hpp" +#include "renderer/hal/interface/DepthStencilState.hpp" +#include "renderer/hal/interface/RasterizerState.hpp" +#include "renderer/hal/interface/FixedPipelineState.hpp" + +#include "ShaderGroup.hpp" + +namespace mce +{ + class RenderMaterial + { + public: + static RenderMaterial* lastUsedMaterial; + + public: + std::set m_defines; + int32_t m_stateMask; + std::string m_vertexShader; + std::string m_fragmentShader; + std::string m_geometryShader; + float m_polygonOffsetLevel; + Shader *m_pShader; // we DO NOT own this, so don't delete it + BlendState m_blendState; + BlendStateDescription m_blendStateDescription; + DepthStencilState m_depthStencilState; + DepthStencilStateDescription m_depthStencilStateDescription; + RasterizerState m_rasterizerState; + RasterizerStateDescription m_rasterizerStateDescription; + FixedPipelineState m_fixedPipelineState; + FixedPipelineStateDescription m_fixedPipelineStateDescription; + + public: + RenderMaterial(); + RenderMaterial(const rapidjson::Value& root, const RenderMaterial& parent); + + protected: + RenderState _parseStateName(const std::string& stateName) const; + void _parseRenderStates(const rapidjson::Value& root); + void _parseRuntimeStates(const rapidjson::Value& root); + void _parseDepthStencilFace(const rapidjson::Value& root, const char* depthStencilFaceName, StencilFaceDescription& faceDescription) const; + void _parseDepthStencilState(const rapidjson::Value& root); + void _parseBlendState(const rapidjson::Value& root); + void _parseFixedPipelineState(const rapidjson::Value& root); + void _parseDefines(const rapidjson::Value& root); + void _parseShaderPaths(const rapidjson::Value& root); +#ifdef FEATURE_GFX_SHADERS + std::string _buildHeader(); + void _loadShader(ShaderGroup& shaderGroup); +#endif + void _applyRenderStates(); + + public: + void useWith(RenderContext& context, const VertexFormat& vertexFormat, const void *basePtr); + void addState(RenderState state); + bool hasState(RenderState state) const { return (m_stateMask & (1 << state)) != 0; } + + protected: + static void SpliceShaderPath(std::string& shaderName); + public: + static void InitContext(); + }; +} \ No newline at end of file diff --git a/source/renderer/ShaderConstants.cpp b/source/renderer/ShaderConstants.cpp new file mode 100644 index 000000000..6643e5120 --- /dev/null +++ b/source/renderer/ShaderConstants.cpp @@ -0,0 +1,78 @@ +#include "ShaderConstants.hpp" +#include "GlobalConstantBufferManager.hpp" +#include "RenderContextImmediate.hpp" + +using namespace mce; + +Color currentShaderColor = Color::WHITE; +Color currentShaderDarkColor = Color::WHITE; + +ShaderConstants::ShaderConstants() +{ + CURRENT_COLOR = nullptr; + DARKEN = nullptr; +} + +void ShaderConstants::setShaderColor(const Color& shaderColor) +{ +#ifdef FEATURE_GFX_SHADERS + Color* pCurrentColor = (Color*)CURRENT_COLOR->m_data; + *pCurrentColor = shaderColor; + CURRENT_COLOR->m_dirty = true; + + sync(); +#else + RenderContext& renderContext = RenderContextImmediate::get(); + renderContext.setCurrentColor(shaderColor); +#endif +} + +void ShaderConstants::setShaderColors(const Color& shaderColor, const Color& shaderDarkenColor) +{ +#ifdef FEATURE_GFX_SHADERS + Color* pCurrentColor = (Color*)CURRENT_COLOR->m_data; + *pCurrentColor = shaderColor; + CURRENT_COLOR->m_dirty = true; + + Color* pDarkenColor = (Color*)DARKEN->m_data; + *pDarkenColor = shaderDarkenColor; + DARKEN->m_dirty = true; + + sync(); +#else + RenderContext& renderContext = RenderContextImmediate::get(); + renderContext.setCurrentColor(shaderColor * shaderDarkenColor); +#endif +} + +void ShaderConstants::init() +{ + GlobalConstantBufferManager& bufferManager = GlobalConstantBufferManager::getInstance(); + m_constantBuffer = bufferManager.findConstantBufferContainer("ShaderConstants"); + + ShaderConstantBase* pCurrentColor = m_constantBuffer->getUnspecializedShaderConstant("CURRENT_COLOR"); + if (pCurrentColor) + { + if (pCurrentColor->getType() == SHADER_PRIMITIVE_FLOAT4) + { + CURRENT_COLOR = (ShaderConstantFloat4*)pCurrentColor; + } + else + { + CURRENT_COLOR = nullptr; + } + } + + ShaderConstantBase* pDarkenColor = m_constantBuffer->getUnspecializedShaderConstant("DARKEN"); + if (pDarkenColor) + { + if (pDarkenColor->getType() == SHADER_PRIMITIVE_FLOAT4) + { + DARKEN = (ShaderConstantFloat4*)pDarkenColor; + } + else + { + DARKEN = nullptr; + } + } +} \ No newline at end of file diff --git a/source/renderer/ShaderConstants.hpp b/source/renderer/ShaderConstants.hpp new file mode 100644 index 000000000..fd6926db0 --- /dev/null +++ b/source/renderer/ShaderConstants.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include "renderer/hal/interface/ConstantBufferConstants.hpp" +#include "renderer/hal/interface/ShaderConstantWithData.hpp" +#include "common/math/Color.hpp" + +extern Color currentShaderColor; +extern Color currentShaderDarkColor; + +namespace mce +{ + class ShaderConstants : public ConstantBufferConstants + { + public: + ShaderConstantFloat4* CURRENT_COLOR; + ShaderConstantFloat4* DARKEN; + + public: + ShaderConstants(); + + void setShaderColor(const Color& shaderColor); + void setShaderColors( const Color& shaderColor, const Color& shaderDarkenColor); + + void init(); + }; +} \ No newline at end of file diff --git a/source/renderer/ShaderGroup.cpp b/source/renderer/ShaderGroup.cpp new file mode 100644 index 000000000..19a850153 --- /dev/null +++ b/source/renderer/ShaderGroup.cpp @@ -0,0 +1,119 @@ +#include "ShaderGroup.hpp" +#include "common/Util.hpp" + +using namespace mce; + +ShaderGroup* ShaderGroup::singletonPtr = nullptr; + +ShaderGroup::ShaderGroup() + : ShaderGroupBase() +{ +} + +ShaderGroup::~ShaderGroup() +{ + +} + +void ShaderGroup::_clearShaders() +{ + for (int i = 0; i < m_shaders.size(); i++) + { + if (m_shaders[i]) + { + delete m_shaders[i]; + m_shaders[i] = nullptr; + } + } + m_shaders.clear(); +} + +void ShaderGroup::_clearPrograms() +{ + for (std::map::iterator it = m_programs.begin(); it != m_programs.end(); it++) + { + if (it->second) + { + delete it->second; + it->second = nullptr; + } + } + m_programs.clear(); +} + +void ShaderGroup::onAppSuspended() +{ + _clearShaders(); + _clearPrograms(); + + Shader::resetLastProgram(); +} + +ShaderProgram& ShaderGroup::getShaderProgram(ShaderType shaderType, const std::string& codeOrPath, const std::string& header) +{ + std::string programPath = codeOrPath + header; + std::map::iterator it = m_programs.find(programPath); + if (it != m_programs.end()) + return *(it->second); + + std::string programCode, shaderPath; + if (Util::isValidPath(codeOrPath)) + { + programCode = AppPlatform::singleton()->readAssetFileStr(codeOrPath, true); + shaderPath = codeOrPath; + + if (shaderType != SHADER_TYPE_GEOMETRY && programCode.empty()) + { + LOG_E("\nProgram not found: \"%s\"\n\n", codeOrPath.c_str()); + } + } + else + { + programCode = codeOrPath; + shaderPath = ""; + } + + if (!programCode.empty()) + { + programCode.insert(programCode.find('\n') + 1, header); + } + + ShaderProgram* shaderProgram = new ShaderProgram(shaderType, programCode, programPath, shaderPath); + ShaderProgram* oldShaderProgram = m_programs[programPath]; + m_programs[programPath] = shaderProgram; + if (oldShaderProgram) + { + delete oldShaderProgram; + } + + return *shaderProgram; +} + +Shader& ShaderGroup::loadShader(const std::string& header, const std::string& vertexCodeOrPath, const std::string& fragmentCodeOrPath, const std::string& geometryCodeOrPath) +{ + for (int i = 0; i < m_shaders.size(); i++) + { + Shader* shader = m_shaders[i]; + if (shader->isBuiltFrom(header, vertexCodeOrPath, fragmentCodeOrPath, geometryCodeOrPath)) + return *shader; + } + + ShaderProgram& vertexProgram = getShaderProgram(SHADER_TYPE_VERTEX, vertexCodeOrPath, header); + ShaderProgram& fragmentProgram = getShaderProgram(SHADER_TYPE_FRAGMENT, fragmentCodeOrPath, header); + ShaderProgram& geometryProgram = getShaderProgram(SHADER_TYPE_GEOMETRY, geometryCodeOrPath, header); + + Shader* shader = new Shader(vertexProgram, fragmentProgram, geometryProgram); + m_shaders.push_back(shader); + + return *shader; +} + +ShaderGroup* ShaderGroup::singleton() +{ + if (!singletonPtr) + { + singletonPtr = new ShaderGroup(); + } + + return singletonPtr; +} \ No newline at end of file diff --git a/source/renderer/ShaderGroup.hpp b/source/renderer/ShaderGroup.hpp new file mode 100644 index 000000000..1add6946b --- /dev/null +++ b/source/renderer/ShaderGroup.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include "ShaderGroupBase.hpp" +#include "client/app/AppPlatformListener.hpp" + +namespace mce +{ + class ShaderGroup : public ShaderGroupBase, public AppPlatformListener + { + protected: + static ShaderGroup* singletonPtr; + + public: + ShaderGroup(); + ~ShaderGroup(); + + protected: + void _clearShaders(); + void _clearPrograms(); + + public: + void onAppSuspended() override; + + ShaderProgram& getShaderProgram(ShaderType shaderType, const std::string& path, const std::string& header); + Shader& loadShader(const std::string& header, const std::string& vertexCodeOrPath, const std::string& fragmentCodeOrPath, const std::string& geometryCodeOrPath); + + static ShaderGroup* singleton(); + }; +} \ No newline at end of file diff --git a/source/renderer/ShaderGroupBase.cpp b/source/renderer/ShaderGroupBase.cpp new file mode 100644 index 000000000..89d896bb5 --- /dev/null +++ b/source/renderer/ShaderGroupBase.cpp @@ -0,0 +1,7 @@ +#include "ShaderGroupBase.hpp" + +using namespace mce; + +ShaderGroupBase::ShaderGroupBase() +{ +} \ No newline at end of file diff --git a/source/renderer/ShaderGroupBase.hpp b/source/renderer/ShaderGroupBase.hpp new file mode 100644 index 000000000..61f8419a1 --- /dev/null +++ b/source/renderer/ShaderGroupBase.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include +#include +#include +#include "renderer/hal/interface/Shader.hpp" +#include "renderer/hal/interface/ShaderProgram.hpp" + +namespace mce +{ + class ShaderGroupBase + { + public: + std::vector m_shaders; + std::map m_programs; + + public: + ShaderGroupBase(); + }; +} \ No newline at end of file diff --git a/source/renderer/StencilRefObject.cpp b/source/renderer/StencilRefObject.cpp new file mode 100644 index 000000000..f69bfc256 --- /dev/null +++ b/source/renderer/StencilRefObject.cpp @@ -0,0 +1,18 @@ +#include "StencilRefObject.hpp" + +using namespace mce; + +StencilRefObject::StencilRefObject(uint8_t ref) +{ + stencilRef = ref; +} + +bool StencilRefObject::operator==(const StencilRefObject& other) const +{ + return stencilRef == other.stencilRef; +} + +bool StencilRefObject::operator!=(const StencilRefObject& other) const +{ + return !(*this == other); +} \ No newline at end of file diff --git a/source/renderer/StencilRefObject.hpp b/source/renderer/StencilRefObject.hpp new file mode 100644 index 000000000..2a25e8a94 --- /dev/null +++ b/source/renderer/StencilRefObject.hpp @@ -0,0 +1,25 @@ +#pragma once + +#include + +namespace mce +{ + class StencilRefObject + { + private: + uint8_t stencilRef; + + public: + StencilRefObject(uint8_t ref = 0); + + uint8_t operator=(uint8_t value) + { + return stencilRef = value; + } + + bool operator==(const StencilRefObject& other) const; + bool operator!=(const StencilRefObject& other) const; + + operator uint8_t() const { return stencilRef; } + }; +} \ No newline at end of file diff --git a/source/renderer/TextureGroup.cpp b/source/renderer/TextureGroup.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/source/renderer/TextureGroup.hpp b/source/renderer/TextureGroup.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/source/renderer/TexturePtr.cpp b/source/renderer/TexturePtr.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/source/renderer/TexturePtr.hpp b/source/renderer/TexturePtr.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/source/renderer/UniformMetaData.cpp b/source/renderer/UniformMetaData.cpp new file mode 100644 index 000000000..36ab7cc7d --- /dev/null +++ b/source/renderer/UniformMetaData.cpp @@ -0,0 +1,17 @@ +#include "UniformMetaData.hpp" +#include "compat/LegacyCPP.hpp" + +using namespace mce; + +UniformMetaData::UniformMetaData() +{ + m_numberOfElements = 1; + m_byteOffset = 0; + m_shaderPrimitiveType = SHADER_PRIMITIVE_UNKNOWN; + m_constantBufferMetaDataParent = nullptr; +} + +unsigned int UniformMetaData::getSize() const +{ + return ShaderPrimitiveTypeHelper::sizeInBytesFromShaderPrimitiveType(m_shaderPrimitiveType); +} \ No newline at end of file diff --git a/source/renderer/UniformMetaData.hpp b/source/renderer/UniformMetaData.hpp new file mode 100644 index 000000000..fc4cc287b --- /dev/null +++ b/source/renderer/UniformMetaData.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include +#include "renderer/hal/enums/ShaderPrimitiveTypes.hpp" + +namespace mce +{ + class ConstantBufferMetaData; + + class UniformMetaData + { + public: + unsigned int m_numberOfElements; + unsigned int m_byteOffset; + ShaderPrimitiveTypes m_shaderPrimitiveType; + ConstantBufferMetaData* m_constantBufferMetaDataParent; + std::string m_uniformName; + + public: + UniformMetaData(); + + unsigned int getSize() const; + }; +} diff --git a/source/renderer/VertexFormat.cpp b/source/renderer/VertexFormat.cpp new file mode 100644 index 000000000..cfe211571 --- /dev/null +++ b/source/renderer/VertexFormat.cpp @@ -0,0 +1,77 @@ +#include + +#include "VertexFormat.hpp" +#include "world/phys/Vec2.hpp" +#include "world/phys/Vec3.hpp" + +using namespace mce; + +const VertexFormat VertexFormat::EMPTY = VertexFormat(); +const unsigned int VertexFormat::FieldSize[] = { + /* VERTEX_FIELD_POSITION */ sizeof(Vec3), + /* VERTEX_FIELD_COLOR */ sizeof(uint32_t), + /* VERTEX_FIELD_NORMAL */ sizeof(uint32_t), + /* VERTEX_FIELD_UV0 */ sizeof(Vec2), // 4 on 0.12.1. in our case, it's 8; 2 floats, one for U, and one for V + /* VERTEX_FIELD_UV1 */ sizeof(Vec2), + /* VERTEX_FIELD_UV2 */ 0, + /* VERTEX_FIELD_PBR_IDX */ 0, + /* VERTEX_FIELD_BONEID_0 */ 0 +}; + +void VertexFormat::_init() +{ + m_fieldMask = 0; + m_vertexSize = 0; + memset(m_fieldOffset, -1, sizeof(m_fieldOffset)); +} + +VertexFormat::VertexFormat() +{ + _init(); +} + +void VertexFormat::enableField(VertexField vertexField) +{ + if (hasField(vertexField)) return; + //if (vertexField != VERTEX_FIELD_POSITION) return; + + m_fieldOffset[vertexField] = m_vertexSize; + uint8_t v6 = m_vertexSize + VertexFormat::FieldSize[vertexField]; + uint8_t v8 = v6 & 3; + m_vertexSize = v6; + if (v8) + m_vertexSize += 4 - v8; + m_fieldMask |= (1 << vertexField); +} + +bool VertexFormat::hasField(VertexField vertexField) const +{ + return HasField(m_fieldMask, vertexField); +} + +const void* VertexFormat::getFieldOffset(VertexField vertexField, const void *vertexData) const +{ + return (uint8_t*)vertexData + m_fieldOffset[vertexField]; +} + +bool VertexFormat::operator==(const VertexFormat &other) const +{ + return m_fieldMask == other.m_fieldMask + && m_vertexSize == other.m_vertexSize + && memcmp(m_fieldOffset, other.m_fieldOffset, sizeof(m_fieldOffset)) == 0; +} + +bool VertexFormat::operator!=(const VertexFormat &other) const +{ + return !(*this == other); +} + +bool VertexFormat::operator<(const VertexFormat &other) const +{ + return (unsigned int)memcmp(this, &other, sizeof(VertexFormat)) >> 31; +} + +bool VertexFormat::HasField(uint8_t fieldMask, VertexField vertexField) +{ + return (fieldMask >> vertexField) & 1; +} \ No newline at end of file diff --git a/source/renderer/VertexFormat.hpp b/source/renderer/VertexFormat.hpp new file mode 100644 index 000000000..0b2c71fa0 --- /dev/null +++ b/source/renderer/VertexFormat.hpp @@ -0,0 +1,49 @@ +#pragma once + +#include + +#include "compat/LegacyCPP.hpp" +#include "renderer/hal/enums/VertexField.hpp" + +namespace mce +{ + class VertexFormat + { + struct FieldOffset + { + uint8_t m_offset; + uint8_t m_size; + }; + + public: + static const VertexFormat EMPTY; + static const unsigned int FieldSize[VERTEX_FIELDS_COUNT]; + + private: + uint8_t m_fieldMask; + uint8_t m_fieldOffset[5]; + uint8_t m_vertexSize; + + private: + void _init(); + + public: + VertexFormat(); + + public: + void enableField(VertexField vertexField); + + bool hasField(VertexField vertexField) const; + const void* getFieldOffset(VertexField vertexField, const void *vertexData = nullptr) const; + + unsigned int getID() const { return m_fieldMask; } + unsigned int getVertexSize() const { return m_vertexSize; } + + bool operator==(const VertexFormat &other) const; + bool operator!=(const VertexFormat &other) const; + bool operator<(const VertexFormat &other) const; + operator bool() const { return *this != VertexFormat::EMPTY; } + + static bool HasField(uint8_t fieldMask, VertexField vertexField); + }; +} \ No newline at end of file diff --git a/source/renderer/WeatherConstants.cpp b/source/renderer/WeatherConstants.cpp new file mode 100644 index 000000000..8705882c9 --- /dev/null +++ b/source/renderer/WeatherConstants.cpp @@ -0,0 +1,126 @@ +#include "WeatherConstants.hpp" +#include "GlobalConstantBufferManager.hpp" + +using namespace mce; + +WeatherConstants::WeatherConstants() +{ + POSITION_OFFSET = nullptr; + VELOCITY = nullptr; + ALPHA = nullptr; + VIEW_POSITION = nullptr; + SIZE_SCALE = nullptr; + FORWARD = nullptr; + UV_INFO = nullptr; + PARTICLE_BOX = nullptr; +} + +void WeatherConstants::init() +{ + GlobalConstantBufferManager& bufferManager = GlobalConstantBufferManager::getInstance(); + m_constantBuffer = bufferManager.findConstantBufferContainer("WeatherConstants"); + + ShaderConstantBase* pPositionOffset = m_constantBuffer->getUnspecializedShaderConstant("POSITION_OFFSET"); + if (pPositionOffset) + { + if (pPositionOffset->getType() == SHADER_PRIMITIVE_FLOAT4) + { + POSITION_OFFSET = (ShaderConstantFloat4*)pPositionOffset; + } + else + { + POSITION_OFFSET = nullptr; + } + } + + ShaderConstantBase* pVelocity = m_constantBuffer->getUnspecializedShaderConstant("VELOCITY"); + if (pVelocity) + { + if (pVelocity->getType() == SHADER_PRIMITIVE_FLOAT4) + { + VELOCITY = (ShaderConstantFloat4*)pVelocity; + } + else + { + VELOCITY = nullptr; + } + } + + ShaderConstantBase* pAlpha = m_constantBuffer->getUnspecializedShaderConstant("ALPHA"); + if (pAlpha) + { + if (pAlpha->getType() == SHADER_PRIMITIVE_FLOAT4) + { + ALPHA = (ShaderConstantFloat4*)pAlpha; + } + else + { + ALPHA = nullptr; + } + } + + ShaderConstantBase* pViewPosition = m_constantBuffer->getUnspecializedShaderConstant("VIEW_POSITION"); + if (pViewPosition) + { + if (pViewPosition->getType() == SHADER_PRIMITIVE_FLOAT4) + { + VIEW_POSITION = (ShaderConstantFloat4*)pViewPosition; + } + else + { + VIEW_POSITION = nullptr; + } + } + + ShaderConstantBase* pSizeScale = m_constantBuffer->getUnspecializedShaderConstant("SIZE_SCALE"); + if (pSizeScale) + { + if (pSizeScale->getType() == SHADER_PRIMITIVE_FLOAT4) + { + SIZE_SCALE = (ShaderConstantFloat4*)pSizeScale; + } + else + { + SIZE_SCALE = nullptr; + } + } + + ShaderConstantBase* pForward = m_constantBuffer->getUnspecializedShaderConstant("FORWARD"); + if (pForward) + { + if (pForward->getType() == SHADER_PRIMITIVE_FLOAT4) + { + FORWARD = (ShaderConstantFloat4*)pForward; + } + else + { + FORWARD = nullptr; + } + } + + ShaderConstantBase* pUvInfo = m_constantBuffer->getUnspecializedShaderConstant("UV_INFO"); + if (pUvInfo) + { + if (pUvInfo->getType() == SHADER_PRIMITIVE_FLOAT4) + { + UV_INFO = (ShaderConstantFloat4*)pUvInfo; + } + else + { + UV_INFO = nullptr; + } + } + + ShaderConstantBase* pParticleBox = m_constantBuffer->getUnspecializedShaderConstant("PARTICLE_BOX"); + if (pParticleBox) + { + if (pParticleBox->getType() == SHADER_PRIMITIVE_FLOAT4) + { + PARTICLE_BOX = (ShaderConstantFloat4*)pParticleBox; + } + else + { + PARTICLE_BOX = nullptr; + } + } +} \ No newline at end of file diff --git a/source/renderer/WeatherConstants.hpp b/source/renderer/WeatherConstants.hpp new file mode 100644 index 000000000..6da94e5f8 --- /dev/null +++ b/source/renderer/WeatherConstants.hpp @@ -0,0 +1,25 @@ +#pragma once + +#include "renderer/hal/interface/ConstantBufferConstants.hpp" +#include "renderer/hal/interface/ShaderConstantWithData.hpp" + +namespace mce +{ + class WeatherConstants : public ConstantBufferConstants + { + public: + ShaderConstantFloat4 *POSITION_OFFSET; + ShaderConstantFloat4 *VELOCITY; + ShaderConstantFloat4 *ALPHA; + ShaderConstantFloat4 *VIEW_POSITION; + ShaderConstantFloat4 *SIZE_SCALE; + ShaderConstantFloat4 *FORWARD; + ShaderConstantFloat4 *UV_INFO; + ShaderConstantFloat4 *PARTICLE_BOX; + + public: + WeatherConstants(); + + void init(); + }; +} \ No newline at end of file diff --git a/source/renderer/WorldConstants.cpp b/source/renderer/WorldConstants.cpp new file mode 100644 index 000000000..2b0b10703 --- /dev/null +++ b/source/renderer/WorldConstants.cpp @@ -0,0 +1,104 @@ +#include "MatrixStack.hpp" +#include "GlobalConstantBufferManager.hpp" +#include "RenderContextImmediate.hpp" +#include "WorldConstants.hpp" + +using namespace mce; + +WorldConstants::WorldConstants() +{ + WORLDVIEWPROJ = nullptr; + WORLD = nullptr; +} + +void WorldConstants::refreshWorldConstants() +{ +#ifdef FEATURE_GFX_SHADERS + if (!MatrixStack::Projection.isDirty() && + !MatrixStack::View.isDirty() && + !MatrixStack::World.isDirty()) + { + // Exit early if no matrices have been updated since the last frame. + return; + } + + // Get the current transformation matrices from the global stacks. + const Matrix& projMatrix = MatrixStack::Projection.top(); + const Matrix& viewMatrix = MatrixStack::View.top(); + const Matrix& worldMatrix = MatrixStack::World.top(); + + // Order matters! + Matrix worldViewProjMatrix = worldMatrix * viewMatrix * projMatrix; + + if (WORLDVIEWPROJ) + WORLDVIEWPROJ->setData(&worldViewProjMatrix); + + if (WORLD) + WORLD->setData(&worldMatrix); + + // Mark the stacks as clean to prevent redundant calculations in subsequent calls. + MatrixStack::Projection.makeClean(); + MatrixStack::View.makeClean(); + MatrixStack::World.makeClean(); + + // Sync the updated constant buffer data to the GPU. + sync(); +#else + + RenderContext& renderContext = RenderContextImmediate::get(); + + if (MatrixStack::Projection.isDirty()) + { + const Matrix& projMatrix = MatrixStack::Projection.top(); + + renderContext.loadMatrix(MATRIX_PROJECTION, projMatrix); + + MatrixStack::Projection.makeClean(); + } + + if (MatrixStack::World.isDirty() || MatrixStack::View.isDirty()) + { + const Matrix& worldMatrix = MatrixStack::World.top(); + const Matrix& viewMatrix = MatrixStack::View.top(); + // Order matters! + Matrix modelViewMatrix = viewMatrix * worldMatrix; + + renderContext.loadMatrix(MATRIX_VIEW, modelViewMatrix); + + MatrixStack::World.makeClean(); + MatrixStack::View.makeClean(); + } +#endif +} + +void WorldConstants::init() +{ + GlobalConstantBufferManager& bufferManager = GlobalConstantBufferManager::getInstance(); + m_constantBuffer = bufferManager.findConstantBufferContainer("WorldConstants"); + + ShaderConstantBase* pWorldViewProj = m_constantBuffer->getUnspecializedShaderConstant("WORLDVIEWPROJ"); + if (pWorldViewProj) + { + if (pWorldViewProj->getType() == SHADER_PRIMITIVE_MATRIX4x4) + { + WORLDVIEWPROJ = (ShaderConstantMatrix4x4*)pWorldViewProj; + } + else + { + WORLDVIEWPROJ = nullptr; + } + } + + ShaderConstantBase* pWorld = m_constantBuffer->getUnspecializedShaderConstant("WORLD"); + if (pWorld) + { + if (pWorld->getType() == SHADER_PRIMITIVE_MATRIX4x4) + { + WORLD = (ShaderConstantMatrix4x4*)pWorld; + } + else + { + WORLD = nullptr; + } + } +} \ No newline at end of file diff --git a/source/renderer/WorldConstants.hpp b/source/renderer/WorldConstants.hpp new file mode 100644 index 000000000..dcdb64fe2 --- /dev/null +++ b/source/renderer/WorldConstants.hpp @@ -0,0 +1,21 @@ +#pragma once + +#include "renderer/hal/interface/ConstantBufferConstants.hpp" +#include "renderer/hal/interface/ShaderConstantWithData.hpp" + +namespace mce +{ + class WorldConstants : public ConstantBufferConstants + { + public: + ShaderConstantMatrix4x4* WORLDVIEWPROJ; + ShaderConstantMatrix4x4* WORLD; + + public: + WorldConstants(); + + void refreshWorldConstants(); + + void init(); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/BlendStateDescription.cpp b/source/renderer/hal/BlendStateDescription.cpp new file mode 100644 index 000000000..2c2ccc9d3 --- /dev/null +++ b/source/renderer/hal/BlendStateDescription.cpp @@ -0,0 +1,24 @@ +#include "BlendStateDescription.hpp" + +using namespace mce; + +BlendStateDescription::BlendStateDescription() +{ + blendSource = BLEND_TARGET_SOURCE_ALPHA; + blendDestination = BLEND_TARGET_ONE_MINUS_SRC_ALPHA; + colorWriteMask = COLOR_WRITE_MASK_ALL; + enableBlend = false; +} + +bool BlendStateDescription::operator==(const BlendStateDescription& other) const +{ + return blendSource == other.blendSource && + blendDestination == other.blendDestination && + colorWriteMask == other.colorWriteMask && + enableBlend == other.enableBlend; +} + +bool BlendStateDescription::operator!=(const BlendStateDescription& other) const +{ + return !(*this == other); +} diff --git a/source/renderer/hal/BlendStateDescription.hpp b/source/renderer/hal/BlendStateDescription.hpp new file mode 100644 index 000000000..997bf1ebb --- /dev/null +++ b/source/renderer/hal/BlendStateDescription.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include "enums/BlendTarget.hpp" +#include "enums/ColorWriteMask.hpp" + +namespace mce +{ + struct BlendStateDescription + { + BlendTarget blendSource; + BlendTarget blendDestination; + ColorWriteMask colorWriteMask; + bool enableBlend; + + BlendStateDescription(); + + bool operator==(const BlendStateDescription& other) const; + bool operator!=(const BlendStateDescription& other) const; + }; +} diff --git a/source/renderer/hal/DepthStencilStateDescription.cpp b/source/renderer/hal/DepthStencilStateDescription.cpp new file mode 100644 index 000000000..5055a69b2 --- /dev/null +++ b/source/renderer/hal/DepthStencilStateDescription.cpp @@ -0,0 +1,35 @@ +#include "DepthStencilStateDescription.hpp" + +using namespace mce; + +DepthStencilStateDescription::DepthStencilStateDescription() + : stencilRef(0) +{ + depthFunc = COMPARISON_FUNC_LESS; + depthTestEnabled = true; + stencilTestEnabled = false; + frontFace = StencilFaceDescription(); + backFace = StencilFaceDescription(); + depthWriteMask = DEPTH_WRITE_MASK_ALL; + + overwroteStencilRef = false; + stencilReadMask = 0xFFFFFFFF; + stencilWriteMask = 0xFFFFFFFF; +} + +bool DepthStencilStateDescription::operator==(const DepthStencilStateDescription& other) const +{ + return depthTestEnabled == other.depthTestEnabled && + frontFace == other.frontFace && + backFace == other.backFace && + depthWriteMask == other.depthWriteMask && + stencilReadMask == other.stencilReadMask && + stencilWriteMask == other.stencilWriteMask && + stencilRef == other.stencilRef && + overwroteStencilRef == other.overwroteStencilRef; +} + +bool DepthStencilStateDescription::operator!=(const DepthStencilStateDescription& other) const +{ + return !(*this == other); +} \ No newline at end of file diff --git a/source/renderer/hal/DepthStencilStateDescription.hpp b/source/renderer/hal/DepthStencilStateDescription.hpp new file mode 100644 index 000000000..cdcb03a89 --- /dev/null +++ b/source/renderer/hal/DepthStencilStateDescription.hpp @@ -0,0 +1,28 @@ +#pragma once + +#include "StencilFaceDescription.hpp" +#include "renderer/StencilRefObject.hpp" +#include "enums/ComparisonFunc.hpp" +#include "enums/DepthWriteMask.hpp" + +namespace mce +{ + struct DepthStencilStateDescription + { + bool depthTestEnabled; + bool stencilTestEnabled; + ComparisonFunc depthFunc; + StencilFaceDescription frontFace; + StencilFaceDescription backFace; + DepthWriteMask depthWriteMask; + unsigned int stencilReadMask; + unsigned int stencilWriteMask; + StencilRefObject stencilRef; + bool overwroteStencilRef; + + DepthStencilStateDescription(); + + bool operator==(const DepthStencilStateDescription& other) const; + bool operator!=(const DepthStencilStateDescription& other) const; + }; +} diff --git a/source/renderer/hal/FixedPipelineStateDescription.cpp b/source/renderer/hal/FixedPipelineStateDescription.cpp new file mode 100644 index 000000000..3e9cdda25 --- /dev/null +++ b/source/renderer/hal/FixedPipelineStateDescription.cpp @@ -0,0 +1,25 @@ +#include "FixedPipelineStateDescription.hpp" + +using namespace mce; + +FixedPipelineStateDescription::FixedPipelineStateDescription() +{ + enableAlphaTest = false; + alphaFunc = COMPARISON_FUNC_GREATER_EQUAL; + alphaRef = 0.5f; + /* pre-HAL values + alphaFunc = COMPARISON_FUNC_GREATER; + alphaRef = 0.1f;*/ + enableTexture = false; +} + +bool FixedPipelineStateDescription::operator==(const FixedPipelineStateDescription& other) const +{ + return enableAlphaTest == other.enableAlphaTest && + enableTexture == other.enableTexture; +} + +bool FixedPipelineStateDescription::operator!=(const FixedPipelineStateDescription& other) const +{ + return !(*this == other); +} diff --git a/source/renderer/hal/FixedPipelineStateDescription.hpp b/source/renderer/hal/FixedPipelineStateDescription.hpp new file mode 100644 index 000000000..3b8a827d9 --- /dev/null +++ b/source/renderer/hal/FixedPipelineStateDescription.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include "enums/ComparisonFunc.hpp" + +namespace mce +{ + struct FixedPipelineStateDescription + { + bool enableAlphaTest; + ComparisonFunc alphaFunc; + float alphaRef; + bool enableTexture; + + FixedPipelineStateDescription(); + + bool operator==(const FixedPipelineStateDescription& other) const; + bool operator!=(const FixedPipelineStateDescription& other) const; + }; +} diff --git a/source/renderer/hal/FogStateDescription.cpp b/source/renderer/hal/FogStateDescription.cpp new file mode 100644 index 000000000..1bc73f386 --- /dev/null +++ b/source/renderer/hal/FogStateDescription.cpp @@ -0,0 +1,27 @@ +#include "FogStateDescription.hpp" + +using namespace mce; + +FogStateDescription::FogStateDescription() +{ + enableFog = false; + fogDensity = 1.0f; + fogStartZ = 0.0f; + fogEndZ = 0.0f; + fogMode = FOG_MODE_EXP; +} + +bool FogStateDescription::operator==(const FogStateDescription& other) const +{ + return enableFog == other.enableFog + && fogMode == other.fogMode + && fogDensity == other.fogDensity + && fogStartZ == other.fogStartZ + && fogEndZ == other.fogEndZ + && fogColor == other.fogColor; +} + +bool FogStateDescription::operator!=(const FogStateDescription& other) const +{ + return !(*this == other); +} diff --git a/source/renderer/hal/FogStateDescription.hpp b/source/renderer/hal/FogStateDescription.hpp new file mode 100644 index 000000000..c63413a70 --- /dev/null +++ b/source/renderer/hal/FogStateDescription.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include "common/math/Color.hpp" +#include "enums/FogMode.hpp" + +namespace mce +{ + struct FogStateDescription + { + bool enableFog; + FogMode fogMode; + float fogDensity; + float fogStartZ; + float fogEndZ; + Color fogColor; + + FogStateDescription(); + + bool operator==(const FogStateDescription& other) const; + bool operator!=(const FogStateDescription& other) const; + }; +} diff --git a/source/renderer/hal/ImageDescription.cpp b/source/renderer/hal/ImageDescription.cpp new file mode 100644 index 000000000..846a4007c --- /dev/null +++ b/source/renderer/hal/ImageDescription.cpp @@ -0,0 +1,19 @@ +#include "ImageDescription.hpp" +#include "compat/LegacyCPP.hpp" +#include "renderer/hal/helpers/TextureHelper.hpp" + +using namespace mce; + +ImageDescription::ImageDescription() +{ + width = 0; + height = 0; + pixels = nullptr; + textureFormat = TEXTURE_FORMAT_UNKNOWN; +} + +unsigned int ImageDescription::getSizeInBytes() const +{ + uint32_t size = width * height; + return TextureHelper::textureFormatToByteStride(textureFormat) * size; +} diff --git a/source/renderer/hal/ImageDescription.hpp b/source/renderer/hal/ImageDescription.hpp new file mode 100644 index 000000000..0237fd08a --- /dev/null +++ b/source/renderer/hal/ImageDescription.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include +#include "enums/TextureFormat.hpp" + +namespace mce +{ + struct ImageDescription + { + unsigned int width; + unsigned int height; + void* pixels; + TextureFormat textureFormat; + + ImageDescription(); + + unsigned int getSizeInBytes() const; + }; +} diff --git a/source/renderer/hal/RasterizerStateDescription.cpp b/source/renderer/hal/RasterizerStateDescription.cpp new file mode 100644 index 000000000..2bff1c7b1 --- /dev/null +++ b/source/renderer/hal/RasterizerStateDescription.cpp @@ -0,0 +1,21 @@ +#include "RasterizerStateDescription.hpp" + +using namespace mce; + +RasterizerStateDescription::RasterizerStateDescription() +{ + depthBias = 0.0f; + cullMode = CULL_BACK; + enableScissorTest = false; +} + +bool RasterizerStateDescription::operator==(const RasterizerStateDescription& other) const +{ + return this->depthBias == other.depthBias && + this->cullMode == other.cullMode; +} + +bool RasterizerStateDescription::operator!=(const RasterizerStateDescription& other) const +{ + return !(*this == other); +} diff --git a/source/renderer/hal/RasterizerStateDescription.hpp b/source/renderer/hal/RasterizerStateDescription.hpp new file mode 100644 index 000000000..e93487994 --- /dev/null +++ b/source/renderer/hal/RasterizerStateDescription.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include "enums/CullMode.hpp" + +namespace mce +{ + struct RasterizerStateDescription + { + float depthBias; + CullMode cullMode; + bool enableScissorTest; + + RasterizerStateDescription(); + + bool operator==(const RasterizerStateDescription& other) const; + bool operator!=(const RasterizerStateDescription& other) const; + }; +} diff --git a/source/renderer/hal/ShaderStage.hpp b/source/renderer/hal/ShaderStage.hpp new file mode 100644 index 000000000..204a418fe --- /dev/null +++ b/source/renderer/hal/ShaderStage.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include "enums/ShaderStagesBits.hpp" + +namespace mce +{ + class ShaderStage + { + public: + ShaderStagesBits m_shaderStageBitsEnum; + unsigned int m_shaderStageBits; + }; +} \ No newline at end of file diff --git a/source/renderer/hal/StencilFaceDescription.cpp b/source/renderer/hal/StencilFaceDescription.cpp new file mode 100644 index 000000000..2cd1eacc6 --- /dev/null +++ b/source/renderer/hal/StencilFaceDescription.cpp @@ -0,0 +1,24 @@ +#include "StencilFaceDescription.hpp" + +using namespace mce; + +StencilFaceDescription::StencilFaceDescription() +{ + stencilFunc = COMPARISON_FUNC_ALWAYS; + stencilDepthFailOp = STENCIL_OP_KEEP; + stencilPassOp = STENCIL_OP_KEEP; + stencilFailOp = STENCIL_OP_KEEP; +} + +bool StencilFaceDescription::operator==(const StencilFaceDescription& other) const +{ + return this->stencilFunc == other.stencilFunc && + this->stencilDepthFailOp == other.stencilDepthFailOp && + this->stencilPassOp == other.stencilPassOp && + this->stencilFailOp == other.stencilFailOp; +} + +bool StencilFaceDescription::operator!=(const StencilFaceDescription& other) const +{ + return !(*this == other); +} diff --git a/source/renderer/hal/StencilFaceDescription.hpp b/source/renderer/hal/StencilFaceDescription.hpp new file mode 100644 index 000000000..998bd01cb --- /dev/null +++ b/source/renderer/hal/StencilFaceDescription.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include "enums/ComparisonFunc.hpp" +#include "enums/StencilOp.hpp" + +namespace mce +{ + struct StencilFaceDescription + { + ComparisonFunc stencilFunc; + StencilOp stencilDepthFailOp; + StencilOp stencilPassOp; + StencilOp stencilFailOp; + + StencilFaceDescription(); + + bool operator==(const StencilFaceDescription& other) const; + bool operator!=(const StencilFaceDescription& other) const; + }; +} diff --git a/source/renderer/hal/TextureDescription.cpp b/source/renderer/hal/TextureDescription.cpp new file mode 100644 index 000000000..77df0fa3d --- /dev/null +++ b/source/renderer/hal/TextureDescription.cpp @@ -0,0 +1,12 @@ +#include "TextureDescription.hpp" + +using namespace mce; + +TextureDescription::TextureDescription() +{ + unknown1 = 0; + mipCount = 1; + bWrap = false; + filteringLevel = TEXTURE_FILTERING_POINT; + unknown3 = 0; +} \ No newline at end of file diff --git a/source/renderer/hal/TextureDescription.hpp b/source/renderer/hal/TextureDescription.hpp new file mode 100644 index 000000000..bf1083f62 --- /dev/null +++ b/source/renderer/hal/TextureDescription.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include +#include "ImageDescription.hpp" +#include "enums/TextureFiltering.hpp" + +namespace mce +{ + struct TextureDescription : public ImageDescription + { + unsigned int unknown1; + unsigned int mipCount; + bool bWrap; + TextureFiltering filteringLevel; + uint8_t unknown3; + + TextureDescription(); + }; +} diff --git a/source/renderer/hal/base/BlendStateBase.cpp b/source/renderer/hal/base/BlendStateBase.cpp new file mode 100644 index 000000000..3505b0c6c --- /dev/null +++ b/source/renderer/hal/base/BlendStateBase.cpp @@ -0,0 +1,18 @@ +#include "BlendStateBase.hpp" + +using namespace mce; + +BlendStateBase::BlendStateBase() +{ + m_description = BlendStateDescription(); +} + +void BlendStateBase::createBlendState(RenderContext& context, const BlendStateDescription& desc) +{ + m_description = desc; +} + +bool BlendStateBase::bindBlendState(RenderContext& context) +{ + return context.m_currentState.m_blendStateDescription == m_description; +} \ No newline at end of file diff --git a/source/renderer/hal/base/BlendStateBase.hpp b/source/renderer/hal/base/BlendStateBase.hpp new file mode 100644 index 000000000..4341368b4 --- /dev/null +++ b/source/renderer/hal/base/BlendStateBase.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include "renderer/hal/BlendStateDescription.hpp" +#include "renderer/hal/interface/RenderContext.hpp" + +namespace mce +{ + class BlendStateBase + { + public: + BlendStateDescription m_description; + + BlendStateBase(); + + void createBlendState(RenderContext& context, const BlendStateDescription& desc); + bool bindBlendState(RenderContext& context); + }; +} diff --git a/source/renderer/hal/base/BufferBase.cpp b/source/renderer/hal/base/BufferBase.cpp new file mode 100644 index 000000000..afb358b10 --- /dev/null +++ b/source/renderer/hal/base/BufferBase.cpp @@ -0,0 +1,77 @@ +#include +#include "BufferBase.hpp" +#include "compat/LegacyCPP.hpp" + +using namespace mce; + +BufferBase::BufferBase() +{ + m_internalSize = 0; + m_bufferOffset = 0; + + releaseBuffer(); +} + +BufferBase::~BufferBase() +{ + releaseBuffer(); +} + +void BufferBase::_init(BufferBase& other) +{ + _move(other); + releaseBuffer(); +} + +void BufferBase::_move(BufferBase& other) +{ + unsigned int stride = m_stride; + this->m_stride = other.m_stride; + other.m_stride = stride; + + BufferType bufferType = m_bufferType; + this->m_bufferType = other.m_bufferType; + other.m_bufferType = bufferType; + + unsigned int internalSize = m_internalSize; + this->m_internalSize = other.m_internalSize; + other.m_internalSize = internalSize; + + unsigned int count = m_count; + this->m_count = other.m_count; + other.m_count = count; +} + +void BufferBase::releaseBuffer() +{ + m_stride = 0; + m_bufferType = BUFFER_TYPE_NONE; + m_count = 0; +} + +void BufferBase::createBuffer(RenderContext& context, unsigned int stride, const void *data, unsigned int count, BufferType bufferType) +{ + m_stride = stride; + m_count = count; + m_internalSize = count * stride; + m_bufferType = bufferType; +} + +void BufferBase::createDynamicBuffer(RenderContext& context, unsigned int stride, const void* data, unsigned int count, BufferType bufferType) +{ + createBuffer(context, stride, data, count, bufferType); +} + +void BufferBase::updateBuffer(RenderContext& context, unsigned int stride, void*& data, unsigned int count) +{ + m_stride = stride; + m_count = count; +} + +void BufferBase::copy(BufferBase& other) +{ + other.m_bufferType = this->m_bufferType; + other.m_stride = this->m_stride; + other.m_count = this->m_count; + other.m_internalSize = this->m_internalSize; +} diff --git a/source/renderer/hal/base/BufferBase.hpp b/source/renderer/hal/base/BufferBase.hpp new file mode 100644 index 000000000..f17ef9089 --- /dev/null +++ b/source/renderer/hal/base/BufferBase.hpp @@ -0,0 +1,39 @@ +#pragma once + +#include "compat/LegacyCPP.hpp" +#include "renderer/hal/enums/BufferType.hpp" + +namespace mce +{ + class RenderContext; + class BufferBase + { + public: + BufferType m_bufferType; + unsigned int m_stride; + unsigned int m_count; + unsigned int m_internalSize; + unsigned int m_bufferOffset; + + protected: + void _init(BufferBase& other); + void _move(BufferBase& other); + + public: + BufferBase(); + ~BufferBase(); + MC_CTOR_MOVE_CUSTOM(BufferBase); + + void releaseBuffer(); + void bindBuffer(RenderContext& context) {} + void createBuffer(RenderContext& context, unsigned int stride, const void *data, unsigned int count, BufferType bufferType); + void createDynamicBuffer(RenderContext& context, unsigned int stride, const void* data, unsigned int count, BufferType bufferType); + void resizeBuffer(RenderContext& context, const void* data, unsigned int size) {} + void updateBuffer(RenderContext& context, unsigned int stride, void*& data, unsigned int count); + void copy(BufferBase& other); + unsigned int getInternalBufferSize() const { return m_internalSize; } + bool isValid() const { return false; } + + MC_FUNC_MOVE(BufferBase); + }; +} diff --git a/source/renderer/hal/base/ConstantBufferBase.cpp b/source/renderer/hal/base/ConstantBufferBase.cpp new file mode 100644 index 000000000..015ae9fe4 --- /dev/null +++ b/source/renderer/hal/base/ConstantBufferBase.cpp @@ -0,0 +1,13 @@ +#include "ConstantBufferBase.hpp" + +using namespace mce; + +void ConstantBufferBase::createConstantBuffer(RenderContext &context, unsigned int count) +{ + m_bindingSlots.resize(count); +} + +unsigned int& ConstantBufferBase::getInternalMemory() +{ + return m_bindingSlots.back(); +} \ No newline at end of file diff --git a/source/renderer/hal/base/ConstantBufferBase.hpp b/source/renderer/hal/base/ConstantBufferBase.hpp new file mode 100644 index 000000000..df518b226 --- /dev/null +++ b/source/renderer/hal/base/ConstantBufferBase.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include "renderer/hal/interface/ConstantBufferContainer.hpp" +#include "renderer/hal/ShaderStage.hpp" + +namespace mce +{ + class ConstantBufferBase + { + public: + std::vector m_bindingSlots; + ShaderStage m_shaderStage; + ConstantBufferContainer *m_constantBufferContainer; + + void createConstantBuffer(RenderContext &context, unsigned int count); + unsigned int& getInternalMemory(); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/base/ConstantBufferConstantsBase.cpp b/source/renderer/hal/base/ConstantBufferConstantsBase.cpp new file mode 100644 index 000000000..05ee5fcc9 --- /dev/null +++ b/source/renderer/hal/base/ConstantBufferConstantsBase.cpp @@ -0,0 +1,14 @@ +#include "ConstantBufferConstantsBase.hpp" +#include "renderer/RenderContextImmediate.hpp" + +using namespace mce; + +ConstantBufferConstantsBase::ConstantBufferConstantsBase() +{ + m_constantBuffer = nullptr; +}; + +void ConstantBufferConstantsBase::sync() +{ + m_constantBuffer->sync(RenderContextImmediate::get()); +} \ No newline at end of file diff --git a/source/renderer/hal/base/ConstantBufferConstantsBase.hpp b/source/renderer/hal/base/ConstantBufferConstantsBase.hpp new file mode 100644 index 000000000..009458324 --- /dev/null +++ b/source/renderer/hal/base/ConstantBufferConstantsBase.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include "renderer/hal/interface/ConstantBufferContainer.hpp" + +namespace mce +{ + class ConstantBufferConstantsBase + { + protected: + ConstantBufferContainer *m_constantBuffer; + + public: + ConstantBufferConstantsBase(); + virtual ~ConstantBufferConstantsBase() {}; + + virtual void init() = 0; + void sync(); + }; +} diff --git a/source/renderer/hal/base/ConstantBufferContainerBase.cpp b/source/renderer/hal/base/ConstantBufferContainerBase.cpp new file mode 100644 index 000000000..b6b1145ea --- /dev/null +++ b/source/renderer/hal/base/ConstantBufferContainerBase.cpp @@ -0,0 +1,114 @@ +#include + +#include "renderer/hal/interface/ShaderConstantWithData.hpp" +#include "ConstantBufferContainerBase.hpp" + +using namespace mce; + +void ConstantBufferContainerBase::_init() +{ + m_currentlyMapped = false; +} + +// causes more problems than it solves, only called in 0.12.1 in vector::reserve +/*ConstantBufferContainerBase::ConstantBufferContainerBase(ConstantBufferContainerBase&& other) +{ + _init(); + m_shaderConstants = other.m_shaderConstants; + other.m_shaderConstants = std::vector(); + m_constantBufferBytes = other.m_constantBufferBytes; + other.m_constantBufferBytes = std::vector(); +}*/ + +void ConstantBufferContainerBase::reserveMemoryForShaderConstants(unsigned int shaderConstSize, unsigned int constBufferSize) +{ + m_shaderConstants.reserve(shaderConstSize); + m_constantBufferBytes.resize(constBufferSize); +} + +void ConstantBufferContainerBase::registerReflectedShaderParameter(const UniformMetaData& uniMeta) +{ + ShaderConstantBase shaderConst(uniMeta); + + for (std::vector::iterator it = m_reflectedShaderConstants.begin(); it != m_reflectedShaderConstants.end(); it++) + { + if (*it == shaderConst) + { + *it = shaderConst; + return; + } + } + + m_reflectedShaderConstants.push_back(shaderConst); +} + +void ConstantBufferContainerBase::registerShaderParameter(const ShaderConstantBase &shaderConstantBase) +{ + ShaderConstantWithDataBase* newConst; + uint8_t* buffer = &m_constantBufferBytes[shaderConstantBase.m_byteOffset]; + //shaderConstantBase.getSize(); // called for fun? + + switch (shaderConstantBase.getType()) + { + case SHADER_PRIMITIVE_FLOAT1: + newConst = new ShaderConstantFloat1(); + break; + case SHADER_PRIMITIVE_FLOAT2: + newConst = new ShaderConstantFloat2(); + break; + case SHADER_PRIMITIVE_FLOAT3: + newConst = new ShaderConstantFloat3(); + break; + case SHADER_PRIMITIVE_FLOAT4: + newConst = new ShaderConstantFloat4(); + break; + case SHADER_PRIMITIVE_INT1: + newConst = new ShaderConstantInt1(); + break; + case SHADER_PRIMITIVE_INT2: + newConst = new ShaderConstantInt2(); + break; + case SHADER_PRIMITIVE_INT3: + newConst = new ShaderConstantInt3(); + break; + case SHADER_PRIMITIVE_INT4: + newConst = new ShaderConstantInt4(); + break; + case SHADER_PRIMITIVE_MATRIX2x2: + newConst = new ShaderConstantMatrix2x2(); + break; + case SHADER_PRIMITIVE_MATRIX3x3: + newConst = new ShaderConstantMatrix3x3(); + break; + case SHADER_PRIMITIVE_MATRIX4x4: + newConst = new ShaderConstantMatrix3x3(); + break; + default: + LOG_E("Unknown shaderConstantBase.shaderPrimitiveType: %d", shaderConstantBase.m_shaderPrimitiveType); // line 101 + throw std::bad_cast(); + } + + newConst->m_data = buffer; + newConst->m_name = shaderConstantBase.m_name; + newConst->m_byteOffset = shaderConstantBase.m_byteOffset; + m_shaderConstants.push_back(newConst); +} + +void ConstantBufferContainerBase::finalizeConstantBufferLayout() +{ + for (std::vector::iterator it = m_reflectedShaderConstants.begin(); it != m_reflectedShaderConstants.end(); it++) + { + registerShaderParameter(*it); + } +} + +bool ConstantBufferContainerBase::isDirty() const +{ + for (std::vector::const_iterator it = m_shaderConstants.begin(); it != m_shaderConstants.end(); it++) + { + if ((*it)->isDirty()) + return true; + } + + return false; +} \ No newline at end of file diff --git a/source/renderer/hal/base/ConstantBufferContainerBase.hpp b/source/renderer/hal/base/ConstantBufferContainerBase.hpp new file mode 100644 index 000000000..3841cf775 --- /dev/null +++ b/source/renderer/hal/base/ConstantBufferContainerBase.hpp @@ -0,0 +1,53 @@ +#pragma once + +#include +#include +#include "ShaderConstantBase.hpp" +#include "renderer/hal/interface/ShaderConstant.hpp" +#include "renderer/hal/interface/RenderContext.hpp" +#include "renderer/UniformMetaData.hpp" + +namespace mce +{ + class ConstantBufferContainerBase + { + public: + // confirmed std::vector + std::vector m_reflectedShaderConstants; + // confirmed std::vector> + std::vector m_shaderConstants; + std::vector m_constantBufferBytes; + std::string m_constantBufferName; + bool m_currentlyMapped; + + private: + void _init(); + public: + ConstantBufferContainerBase() { _init(); } + //ConstantBufferContainerBase(ConstantBufferContainerBase&& other); + + void bindConstantBuffer(RenderContext& context, unsigned int, unsigned int) { } + + void sync(RenderContext& context) { } + void allocateRenderContextBuffer(RenderContext& context) { } + void reserveMemoryForShaderConstants(unsigned int shaderConstSize, unsigned int constBufferSize); + void registerReflectedShaderParameter(const UniformMetaData& uniMeta); + void registerShaderParameter(const ShaderConstantBase &shaderConst); + void finalizeConstantBufferLayout(); + // gets inlined in ConstantBufferContainer::getUnspecializedShaderConstant + ShaderConstant* getUnspecializedShaderConstant(const std::string& name) + { + for (std::vector::iterator it = m_shaderConstants.begin(); it != m_shaderConstants.end(); it++) + { + if ((*it)->getName() == name) + { + return *it; + } + } + + return nullptr; + } + bool isDirty() const; + std::string getConstantBufferName() const { return m_constantBufferName; } + }; +} \ No newline at end of file diff --git a/source/renderer/hal/base/DepthStencilStateBase.cpp b/source/renderer/hal/base/DepthStencilStateBase.cpp new file mode 100644 index 000000000..3d8d71efe --- /dev/null +++ b/source/renderer/hal/base/DepthStencilStateBase.cpp @@ -0,0 +1,17 @@ +#include "DepthStencilStateBase.hpp" + +using namespace mce; + +DepthStencilStateBase::DepthStencilStateBase() +{ +} + +void DepthStencilStateBase::createDepthState(RenderContext& context, const DepthStencilStateDescription& description) +{ + m_description = description; +} + +bool DepthStencilStateBase::bindDepthStencilState(RenderContext& context) +{ + return context.m_currentState.m_depthStencilStateDescription == m_description; +} \ No newline at end of file diff --git a/source/renderer/hal/base/DepthStencilStateBase.hpp b/source/renderer/hal/base/DepthStencilStateBase.hpp new file mode 100644 index 000000000..e1a5a201d --- /dev/null +++ b/source/renderer/hal/base/DepthStencilStateBase.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include "renderer/hal/DepthStencilStateDescription.hpp" +#include "renderer/hal/interface/RenderContext.hpp" + +namespace mce +{ + class DepthStencilStateBase + { + public: + DepthStencilStateDescription m_description; + + public: + DepthStencilStateBase(); + + public: + void createDepthState(RenderContext& context, const DepthStencilStateDescription& description); + bool bindDepthStencilState(RenderContext& context); + }; +} diff --git a/source/renderer/hal/base/FixedPipelineStateBase.cpp b/source/renderer/hal/base/FixedPipelineStateBase.cpp new file mode 100644 index 000000000..f41ec7e55 --- /dev/null +++ b/source/renderer/hal/base/FixedPipelineStateBase.cpp @@ -0,0 +1,17 @@ +#include "FixedPipelineStateBase.hpp" + +using namespace mce; + +FixedPipelineStateBase::FixedPipelineStateBase() +{ +} + +void FixedPipelineStateBase::createFixedPipelineState(RenderContext& context, const FixedPipelineStateDescription& desc) +{ + m_description = desc; +} + +bool FixedPipelineStateBase::bindFixedPipelineState(RenderContext& context) +{ + return context.m_currentState.m_fixedPipelineStateDescription == m_description; +} \ No newline at end of file diff --git a/source/renderer/hal/base/FixedPipelineStateBase.hpp b/source/renderer/hal/base/FixedPipelineStateBase.hpp new file mode 100644 index 000000000..2b0555169 --- /dev/null +++ b/source/renderer/hal/base/FixedPipelineStateBase.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include "renderer/VertexFormat.hpp" +#include "renderer/hal/FixedPipelineStateDescription.hpp" +#include "renderer/hal/interface/RenderContext.hpp" + +namespace mce +{ + class FixedPipelineStateBase + { + protected: + VertexFormat m_lastVertexFormat; + public: + FixedPipelineStateDescription m_description; + + public: + FixedPipelineStateBase(); + + public: + void createFixedPipelineState(RenderContext& context, const FixedPipelineStateDescription& desc); + bool bindFixedPipelineState(RenderContext& context); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/base/FogStateBase.cpp b/source/renderer/hal/base/FogStateBase.cpp new file mode 100644 index 000000000..b9b2dceb6 --- /dev/null +++ b/source/renderer/hal/base/FogStateBase.cpp @@ -0,0 +1,18 @@ +#include "FogStateBase.hpp" + +using namespace mce; + +FogStateBase::FogStateBase() +{ + m_description = FogStateDescription(); +} + +void FogStateBase::createFogState(RenderContext& context, const FogStateDescription& desc) +{ + m_description = desc; +} + +bool FogStateBase::bindFogState(RenderContext& context) +{ + return context.m_currentState.m_fogStateDescription == m_description; +} \ No newline at end of file diff --git a/source/renderer/hal/base/FogStateBase.hpp b/source/renderer/hal/base/FogStateBase.hpp new file mode 100644 index 000000000..08011dccf --- /dev/null +++ b/source/renderer/hal/base/FogStateBase.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include "renderer/hal/FogStateDescription.hpp" +#include "renderer/hal/interface/RenderContext.hpp" + +namespace mce +{ + class FogStateBase + { + public: + FogStateDescription m_description; + + FogStateBase(); + + void createFogState(RenderContext& context, const FogStateDescription& desc); + bool bindFogState(RenderContext& context); + }; +} diff --git a/source/renderer/hal/base/FrameBufferObjectBase.cpp b/source/renderer/hal/base/FrameBufferObjectBase.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/source/renderer/hal/base/FrameBufferObjectBase.hpp b/source/renderer/hal/base/FrameBufferObjectBase.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/source/renderer/hal/base/ImmediateBufferBase.cpp b/source/renderer/hal/base/ImmediateBufferBase.cpp new file mode 100644 index 000000000..5478b7171 --- /dev/null +++ b/source/renderer/hal/base/ImmediateBufferBase.cpp @@ -0,0 +1,20 @@ +#include "ImmediateBufferBase.hpp" + +using namespace mce; + +ImmediateBufferBase::ImmediateBufferBase() +{ +} + +void ImmediateBufferBase::createDynamicBuffer(RenderContext& context, unsigned int stride, const void* data, unsigned int count, BufferType bufferType) +{ +} + +void ImmediateBufferBase::updateBuffer(RenderContext& context, unsigned int itemSize, void const* data, unsigned int bufferSize) +{ +} + +bool ImmediateBufferBase::isValid() const +{ + return false; +} \ No newline at end of file diff --git a/source/renderer/hal/base/ImmediateBufferBase.hpp b/source/renderer/hal/base/ImmediateBufferBase.hpp new file mode 100644 index 000000000..53db23d4e --- /dev/null +++ b/source/renderer/hal/base/ImmediateBufferBase.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include "renderer/hal/enums/BufferType.hpp" + +namespace mce +{ + class RenderContext; + + class ImmediateBufferBase + { + public: + ImmediateBufferBase(); + + void createDynamicBuffer(RenderContext& context, unsigned int stride, const void* data, unsigned int count, BufferType bufferType); + void updateBuffer(RenderContext& context, unsigned int stride, void const* data, unsigned int count); + + bool isValid() const; + }; +} diff --git a/source/renderer/hal/base/RasterizerStateBase.cpp b/source/renderer/hal/base/RasterizerStateBase.cpp new file mode 100644 index 000000000..298624310 --- /dev/null +++ b/source/renderer/hal/base/RasterizerStateBase.cpp @@ -0,0 +1,17 @@ +#include "RasterizerStateBase.hpp" + +using namespace mce; + +RasterizerStateBase::RasterizerStateBase() +{ +} + +void RasterizerStateBase::createRasterizerStateDescription(RenderContext& context, const RasterizerStateDescription& desc) +{ + m_description = desc; +} + +bool RasterizerStateBase::bindRasterizerState(RenderContext& context) +{ + return context.m_currentState.m_rasterizerStateDescription == m_description; +} \ No newline at end of file diff --git a/source/renderer/hal/base/RasterizerStateBase.hpp b/source/renderer/hal/base/RasterizerStateBase.hpp new file mode 100644 index 000000000..1af236918 --- /dev/null +++ b/source/renderer/hal/base/RasterizerStateBase.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include "renderer/hal/RasterizerStateDescription.hpp" +#include "renderer/hal/interface/RenderContext.hpp" + +namespace mce +{ + class RasterizerStateBase + { + public: + RasterizerStateDescription m_description; + + RasterizerStateBase(); + + void createRasterizerStateDescription(RenderContext& context, const RasterizerStateDescription& desc); + bool bindRasterizerState(RenderContext& context); + void setScissorRect(RenderContext &context, int x, int y, int width, int height) {} + }; +} diff --git a/source/renderer/hal/base/RenderContextBase.cpp b/source/renderer/hal/base/RenderContextBase.cpp new file mode 100644 index 000000000..b3fe677a3 --- /dev/null +++ b/source/renderer/hal/base/RenderContextBase.cpp @@ -0,0 +1,129 @@ +#include "RenderContextBase.hpp" + +using namespace mce; + +RenderContextBase::RenderContextBase() +{ + m_pRenderDevice = nullptr; + m_currentShadeMode = SHADE_MODE_SMOOTH; +} + +void RenderContextBase::loadMatrix(MatrixType matrixType, const Matrix& matrix) +{ +} + +void RenderContextBase::setVertexState(const VertexFormat& vertexFormat) +{ + m_lastVertexFormat = vertexFormat; +} + +void RenderContextBase::clearVertexState(const VertexFormat& vertexFormat) +{ +} + +void RenderContextBase::enableFixedLighting(bool init) +{ +} + +void RenderContextBase::disableFixedLighting(bool teardown) +{ +} + +bool RenderContextBase::setShadeMode(ShadeMode mode) +{ + if (mode == m_currentShadeMode) + return false; + + m_currentShadeMode = mode; + + return true; +} + +bool RenderContextBase::setCurrentColor(const Color& color) +{ + if (color == m_currentColor) + return false; + + m_currentColor = color; + + return true; +} + +void RenderContextBase::draw(PrimitiveMode primitiveMode, unsigned int startOffset, unsigned int count) +{ +} + +void RenderContextBase::drawIndexed(PrimitiveMode primitiveMode, unsigned int count, uint8_t indexSize) +{ +} + +void RenderContextBase::drawIndexed(PrimitiveMode primitiveMode, unsigned int count, unsigned int startOffset, uint8_t indexSize) +{ +} + +void RenderContextBase::setDepthRange(float nearVal, float farVal) +{ +} + +void RenderContextBase::setViewport(int topLeftX, int topLeftY, unsigned int width, unsigned int height, float nearVal, float farVal) +{ +} + +void RenderContextBase::clearFrameBuffer(const Color& color) +{ +} + +void RenderContextBase::clearStencilBuffer() +{ +} + +void RenderContextBase::clearDepthStencilBuffer() +{ +} + +void RenderContextBase::clearContextState() +{ + m_currentState.clear(); + m_immediateBuffer = ImmediateBuffer(); + m_lastShaderPrograms[SHADER_TYPE_VERTEX] = nullptr; + m_lastShaderPrograms[SHADER_TYPE_FRAGMENT] = nullptr; + m_lastShaderPrograms[SHADER_TYPE_GEOMETRY] = nullptr; +} + +void RenderContextBase::setRenderTarget() +{ +} + +void RenderContextBase::swapBuffers() +{ +} + +void RenderContextBase::lostContext() +{ + clearContextState(); +} + +RenderDevice* RenderContextBase::getDevice() +{ + return m_pRenderDevice; +} + +void RenderContextBase::setStencilReference(uint8_t value) +{ + m_stencilReference = value; +} + +uint8_t RenderContextBase::getStencilReference() const +{ + return m_stencilReference; +} + +int RenderContextBase::getMaxVertexCount() +{ + return 0; +} + +bool RenderContextBase::supports32BitIndices() +{ + return true; +} \ No newline at end of file diff --git a/source/renderer/hal/base/RenderContextBase.hpp b/source/renderer/hal/base/RenderContextBase.hpp new file mode 100644 index 000000000..bda305db8 --- /dev/null +++ b/source/renderer/hal/base/RenderContextBase.hpp @@ -0,0 +1,62 @@ +#pragma once + +#include "RenderContextStateBase.hpp" +#include "common/math/Color.hpp" +#include "renderer/VertexFormat.hpp" +#include "renderer/MatrixStack.hpp" +#include "renderer/hal/enums/PrimitiveMode.hpp" +#include "renderer/hal/enums/ShadeMode.hpp" +#include "renderer/hal/enums/ShaderType.hpp" +#include "renderer/hal/interface/ShaderProgram.hpp" +#include "renderer/hal/interface/ImmediateBuffer.hpp" +#include "renderer/hal/interface/RenderDevice.hpp" + +namespace mce +{ + class RenderContextBase + { + public: + RenderContextStateBase m_currentState; + VertexFormat m_lastVertexFormat; + Color m_currentColor; + ShadeMode m_currentShadeMode; + // Unused in OGL + int field_34; + // Only used in DX11 + ShaderProgram* m_lastShaderPrograms[SHADER_TYPES_COUNT]; + ImmediateBuffer m_immediateBuffer; + StencilRefObject m_stencilReference; + RenderDevice *m_pRenderDevice; + + public: + RenderContextBase(); + + public: + void loadMatrix(MatrixType matrixType, const Matrix& matrix); + void setVertexState(const VertexFormat& vertexFormat); + void clearVertexState(const VertexFormat& vertexFormat); + void enableFixedLighting(bool init); + void disableFixedLighting(bool teardown); + bool setShadeMode(ShadeMode mode); + bool setCurrentColor(const Color& color); + void draw(PrimitiveMode primitiveMode, unsigned int startOffset, unsigned int count); + void drawIndexed(PrimitiveMode primitiveMode, unsigned int count, uint8_t indexSize); + void drawIndexed(PrimitiveMode primitiveMode, unsigned int count, unsigned int startOffset, uint8_t indexSize); + void setDepthRange(float nearVal, float farVal); + void setViewport(int topLeftX, int topLeftY, unsigned int width, unsigned int height, float nearVal, float farVal); + void clearFrameBuffer(const Color& color); + void clearStencilBuffer(); + void clearDepthStencilBuffer(); + void clearContextState(); + void setRenderTarget(); + void swapBuffers(); + void lostContext(); + + RenderDevice* getDevice(); + void setStencilReference(uint8_t value); + uint8_t getStencilReference() const; + + static int getMaxVertexCount(); + static bool supports32BitIndices(); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/base/RenderContextStateBase.cpp b/source/renderer/hal/base/RenderContextStateBase.cpp new file mode 100644 index 000000000..0438ca3e3 --- /dev/null +++ b/source/renderer/hal/base/RenderContextStateBase.cpp @@ -0,0 +1,17 @@ +#include "RenderContextStateBase.hpp" + +using namespace mce; + +RenderContextStateBase::RenderContextStateBase() +{ + clear(); +} + +void RenderContextStateBase::clear() +{ + m_bBoundBlendState = false; + m_bBoundDepthStencilState = false; + m_bBoundRasterizerState = false; + m_bBoundFixedPipelineState = false; + m_bBoundFogState = false; +} \ No newline at end of file diff --git a/source/renderer/hal/base/RenderContextStateBase.hpp b/source/renderer/hal/base/RenderContextStateBase.hpp new file mode 100644 index 000000000..5951be42d --- /dev/null +++ b/source/renderer/hal/base/RenderContextStateBase.hpp @@ -0,0 +1,31 @@ +#pragma once + +#include "renderer/hal/BlendStateDescription.hpp" +#include "renderer/hal/DepthStencilStateDescription.hpp" +#include "renderer/hal/RasterizerStateDescription.hpp" +#include "renderer/hal/FixedPipelineStateDescription.hpp" +#include "renderer/hal/FogStateDescription.hpp" + +namespace mce +{ + class RenderContextStateBase + { + public: + BlendStateDescription m_blendStateDescription; + DepthStencilStateDescription m_depthStencilStateDescription; + RasterizerStateDescription m_rasterizerStateDescription; + FixedPipelineStateDescription m_fixedPipelineStateDescription; + FogStateDescription m_fogStateDescription; + bool m_bBoundBlendState; + bool m_bBoundDepthStencilState; + bool m_bBoundRasterizerState; + bool m_bBoundFixedPipelineState; + bool m_bBoundFogState; + + public: + RenderContextStateBase(); + + public: + void clear(); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/base/RenderDeviceBase.cpp b/source/renderer/hal/base/RenderDeviceBase.cpp new file mode 100644 index 000000000..5e15310e2 --- /dev/null +++ b/source/renderer/hal/base/RenderDeviceBase.cpp @@ -0,0 +1,28 @@ +#include "RenderDeviceBase.hpp" + +using namespace mce; + +RenderDeviceBase::RenderDeviceBase() +{ + m_bDeviceLost = false; +} + +const RenderDeviceBase::AttributeList& RenderDeviceBase::getAttributeList(unsigned int index) const +{ + return m_registeredAttributeLists[index]; +} + +unsigned int RenderDeviceBase::registerOrGetAttributeListIndex(const AttributeList& attributeList) +{ + for (int i = 0; i < m_registeredAttributeLists.size(); i++) + { + if (m_registeredAttributeLists[i] == attributeList) + { + return i; + } + } + + m_registeredAttributeLists.push_back(attributeList); + + return m_registeredAttributeLists.size() - 1; +} \ No newline at end of file diff --git a/source/renderer/hal/base/RenderDeviceBase.hpp b/source/renderer/hal/base/RenderDeviceBase.hpp new file mode 100644 index 000000000..ba79e396d --- /dev/null +++ b/source/renderer/hal/base/RenderDeviceBase.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include + +#include "renderer/Attribute.hpp" + +namespace mce +{ + class RenderContext; + + class RenderDeviceBase + { + public: + // Microsoft/Mojang were braindead and made this a struct with just `m_attributeList` + typedef std::vector AttributeList; + + std::vector m_registeredAttributeLists; + bool m_bDeviceLost; + + public: + RenderDeviceBase(); + + public: + const AttributeList& getAttributeList(unsigned int index) const; + unsigned int registerOrGetAttributeListIndex(const AttributeList& attributeList); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/base/ShaderBase.cpp b/source/renderer/hal/base/ShaderBase.cpp new file mode 100644 index 000000000..15a9e6516 --- /dev/null +++ b/source/renderer/hal/base/ShaderBase.cpp @@ -0,0 +1,76 @@ +#include + +#include "ShaderBase.hpp" +#include "renderer/RenderContextImmediate.hpp" + +using namespace mce; + +// I could not find anything responsible for setting this in 0.12.1 +std::map _CreateBuiltinAttributeMap() +{ + std::map m; + m["POSITION"] = VERTEX_FIELD_POSITION; + m["COLOR"] = VERTEX_FIELD_COLOR; + m["NORMAL"] = VERTEX_FIELD_NORMAL; + m["TEXCOORD_0"] = VERTEX_FIELD_UV0; + m["TEXCOORD_1"] = VERTEX_FIELD_UV1; + return m; +} +std::map ShaderBase::builtinAttributeMap = _CreateBuiltinAttributeMap(); + +ShaderBase::ShaderBase(ShaderProgram& vertex, ShaderProgram& fragment, ShaderProgram& geometry) + : m_vertexShader(vertex) + , m_fragmentShader(fragment) + , m_geometryShader(geometry) +{ + m_attributeListIndex = 0; +} + +void ShaderBase::finalizeShaderUniforms() +{ +} + +void ShaderBase::freeCompilerResources() +{ +} + +void ShaderBase::resetLastProgram() +{ +} + +bool ShaderBase::isBuiltFrom(const std::string& shaderName, const std::string& vertexPath, const std::string& fragmentPath, const std::string& geometryPath) const +{ + return m_vertexShader.m_header == (shaderName + vertexPath) && + m_fragmentShader.m_header == (shaderName + fragmentPath) && + (m_geometryShader.m_header == (shaderName + geometryPath) || !m_geometryShader.isValid()); +} + +void ShaderBase::validateVertexFormat(const VertexFormat& vertexFormat) +{ +} + +void ShaderBase::bindShader(RenderContext& context, const VertexFormat& format, const void *dataBasePtr, unsigned int shaderStageBits) +{ +} + +void ShaderBase::reflectShader(RenderDevice& renderDevice) +{ +} + +VertexField ShaderBase::getAttributeForName(const std::string& name, unsigned int id) const +{ + std::map::iterator it = builtinAttributeMap.find(name); + + if (it != builtinAttributeMap.end()) + { + return it->second; + } + else + { + std::stringstream ss; + ss << name << id; + it = builtinAttributeMap.find(ss.str()); + + return it->second; + } +} \ No newline at end of file diff --git a/source/renderer/hal/base/ShaderBase.hpp b/source/renderer/hal/base/ShaderBase.hpp new file mode 100644 index 000000000..ee9b12b38 --- /dev/null +++ b/source/renderer/hal/base/ShaderBase.hpp @@ -0,0 +1,37 @@ +#pragma once + +#include +#include + +#include "renderer/Attribute.hpp" +#include "renderer/VertexFormat.hpp" +#include "renderer/hal/interface/ShaderProgram.hpp" +#include "renderer/hal/interface/RenderDevice.hpp" + +namespace mce +{ + class ShaderBase + { + public: + static std::map builtinAttributeMap; + + public: + unsigned int m_attributeListIndex; + ShaderProgram& m_vertexShader; + ShaderProgram& m_fragmentShader; + ShaderProgram& m_geometryShader; + + public: + ShaderBase(ShaderProgram& vertex, ShaderProgram& fragment, ShaderProgram& geometry); + + public: + void finalizeShaderUniforms(); + static void freeCompilerResources(); + static void resetLastProgram(); + bool isBuiltFrom(const std::string& shaderName, const std::string& vertexPath, const std::string& fragmentPath, const std::string& geometryPath) const; + void validateVertexFormat(const VertexFormat& vertexFormat); + void bindShader(RenderContext& context, const VertexFormat& format, const void *dataBasePtr, unsigned int shaderStageBits); + void reflectShader(RenderDevice& renderDevice); + VertexField getAttributeForName(const std::string& name, unsigned int id) const; + }; +} \ No newline at end of file diff --git a/source/renderer/hal/base/ShaderConstantBase.cpp b/source/renderer/hal/base/ShaderConstantBase.cpp new file mode 100644 index 000000000..c2dd51842 --- /dev/null +++ b/source/renderer/hal/base/ShaderConstantBase.cpp @@ -0,0 +1,35 @@ +#include "renderer/UniformMetaData.hpp" + +#include "ShaderConstantBase.hpp" + +using namespace mce; + +void ShaderConstantBase::_init() +{ + m_numberOfElements = 0; + m_byteOffset = 0; + m_shaderPrimitiveType = SHADER_PRIMITIVE_UNKNOWN; + m_dirty = false; +} + +ShaderConstantBase::ShaderConstantBase(const UniformMetaData& uniMeta) +{ + _init(); + m_name = uniMeta.m_uniformName; + m_shaderPrimitiveType = uniMeta.m_shaderPrimitiveType; + m_numberOfElements = uniMeta.m_numberOfElements; + m_byteOffset = uniMeta.m_byteOffset; +} + +ShaderConstantBase::~ShaderConstantBase() +{ + +} + +bool ShaderConstantBase::operator==(const ShaderConstantBase& other) const +{ + return getName() == other.getName() && + m_numberOfElements == other.m_numberOfElements && + getType() == other.getType() && + m_byteOffset == other.m_byteOffset; +} \ No newline at end of file diff --git a/source/renderer/hal/base/ShaderConstantBase.hpp b/source/renderer/hal/base/ShaderConstantBase.hpp new file mode 100644 index 000000000..6bebbd1d2 --- /dev/null +++ b/source/renderer/hal/base/ShaderConstantBase.hpp @@ -0,0 +1,35 @@ +#pragma once + +#include +#include "renderer/hal/enums/ShaderPrimitiveTypes.hpp" + +namespace mce +{ + class UniformMetaData; + + class ShaderConstantBase + { + public: + std::string m_name; + unsigned int m_numberOfElements; + unsigned int m_byteOffset; + ShaderPrimitiveTypes m_shaderPrimitiveType; + bool m_dirty; + + private: + void _init(); + + public: + ShaderConstantBase() { _init(); } + ShaderConstantBase(const UniformMetaData&); + virtual ~ShaderConstantBase(); + + void release(); + const std::string& getName() const { return m_name; } + const unsigned int getSize() const { return ShaderPrimitiveTypeHelper::sizeInBytesFromShaderPrimitiveType(m_shaderPrimitiveType); } + ShaderPrimitiveTypes getType() const { return m_shaderPrimitiveType; } + bool isDirty() const { return m_dirty; } + + bool operator==(const ShaderConstantBase& other) const; + }; +} diff --git a/source/renderer/hal/base/ShaderConstantWithDataBase.cpp b/source/renderer/hal/base/ShaderConstantWithDataBase.cpp new file mode 100644 index 000000000..17289e7af --- /dev/null +++ b/source/renderer/hal/base/ShaderConstantWithDataBase.cpp @@ -0,0 +1 @@ +#include "ShaderConstantWithDataBase.hpp" diff --git a/source/renderer/hal/base/ShaderConstantWithDataBase.hpp b/source/renderer/hal/base/ShaderConstantWithDataBase.hpp new file mode 100644 index 000000000..645799e52 --- /dev/null +++ b/source/renderer/hal/base/ShaderConstantWithDataBase.hpp @@ -0,0 +1,25 @@ +#pragma once +#include +#include +#include "renderer/hal/interface/ShaderConstant.hpp" + +namespace mce +{ + class ShaderConstantWithDataBase : public ShaderConstant + { + public: + uint8_t* m_data; + + public: + ShaderConstantWithDataBase(ShaderPrimitiveTypes primitiveType) + { + m_shaderPrimitiveType = primitiveType; + } + + void setData(const void* data) + { + memcpy(m_data, data, getSize()); + m_dirty = true; + } + }; +} diff --git a/source/renderer/hal/base/ShaderContextBase.cpp b/source/renderer/hal/base/ShaderContextBase.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/source/renderer/hal/base/ShaderContextBase.hpp b/source/renderer/hal/base/ShaderContextBase.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/source/renderer/hal/base/ShaderProgramBase.cpp b/source/renderer/hal/base/ShaderProgramBase.cpp new file mode 100644 index 000000000..5602d89d7 --- /dev/null +++ b/source/renderer/hal/base/ShaderProgramBase.cpp @@ -0,0 +1,9 @@ +#include "ShaderProgramBase.hpp" + +using namespace mce; + +ShaderProgramBase::ShaderProgramBase(const std::string& header, const std::string& shaderPath, ShaderType shaderType) + : m_header(header), m_shaderPath(shaderPath), m_shaderType(shaderType) +{ + m_bValid = false; +} \ No newline at end of file diff --git a/source/renderer/hal/base/ShaderProgramBase.hpp b/source/renderer/hal/base/ShaderProgramBase.hpp new file mode 100644 index 000000000..60472356d --- /dev/null +++ b/source/renderer/hal/base/ShaderProgramBase.hpp @@ -0,0 +1,21 @@ +#pragma once + +#include +#include "renderer/hal/enums/ShaderType.hpp" + +namespace mce +{ + class ShaderProgramBase + { + protected: + bool m_bValid; + public: + const std::string m_header; + const std::string m_shaderPath; + const ShaderType m_shaderType; + + ShaderProgramBase(const std::string& header, const std::string& shaderPath, ShaderType shaderType); + + bool isValid() const { return m_bValid; } + }; +} \ No newline at end of file diff --git a/source/renderer/hal/base/TextureBase.cpp b/source/renderer/hal/base/TextureBase.cpp new file mode 100644 index 000000000..b4e4d4425 --- /dev/null +++ b/source/renderer/hal/base/TextureBase.cpp @@ -0,0 +1,96 @@ +#include + +#include "TextureBase.hpp" +#include "common/Logger.hpp" + +using namespace mce; + +TextureBase::TextureBase() +{ + m_bCreated = false; +} + +const TextureDescription& TextureBase::getDescription() const +{ + return m_description; +} + +void TextureBase::deleteTexture() +{ + m_bCreated = false; +} + +void TextureBase::bindTexture(RenderContext& context, unsigned int textureUnit, unsigned int shaderStagesBits) +{ +} + +bool TextureBase::isLoaded() const +{ + return m_bCreated; +} + +void TextureBase::convertToMipmapedTexture(unsigned int mipmaps) +{ + if (m_description.mipCount == mipmaps) + return; + + if (m_description.filteringLevel == TEXTURE_FILTERING_BILINEAR) + { + LOG_E("Unsupported filtering level for mip maps, please add the correct filtering case: %d", m_description.filteringLevel); + throw std::bad_cast(); + } + + m_description.filteringLevel = TEXTURE_FILTERING_MIPMAP_BILINEAR; +} + +void TextureBase::convertToMipmapedTexture(RenderContext& context, unsigned int mipmaps) +{ +} + +void TextureBase::subBuffer(RenderContext& context, const void* pixels, unsigned int xoffset, unsigned int yoffset, unsigned int width, unsigned int height, unsigned int level) +{ +} + +void TextureBase::subBuffer(RenderContext& context, const void* pixels) +{ +} + +void TextureBase::copyTexture(RenderContext& context, Texture* src, unsigned int startX, unsigned int startY, unsigned int width, unsigned int height) +{ +} + +void TextureBase::createMipMap(RenderContext& context, const void* pixels, unsigned int width, unsigned int height, unsigned int level) +{ +} + +void TextureBase::createTexture(const TextureDescription& description) +{ + m_description = description; +} + +void TextureBase::createTexture(RenderContext& context, TextureDescription const&) +{ +} + +void TextureBase::lock(RenderContext& context) +{ +} + +void TextureBase::unlock(RenderContext& context) +{ +} + +void TextureBase::move(TextureBase& other) +{ + TextureDescription tempDesc = this->m_description; + this->m_description = tempDesc; + other.m_description = other.m_description; + bool tempCreated = this->m_bCreated; + this->m_bCreated = other.m_bCreated; + other.m_bCreated = tempCreated; +} + +bool TextureBase::supportsMipMaps() +{ + return false; +} diff --git a/source/renderer/hal/base/TextureBase.hpp b/source/renderer/hal/base/TextureBase.hpp new file mode 100644 index 000000000..f11e29962 --- /dev/null +++ b/source/renderer/hal/base/TextureBase.hpp @@ -0,0 +1,47 @@ +#pragma once + +#include "renderer/hal/TextureDescription.hpp" +#include "renderer/hal/enums/ShaderStagesBits.hpp" + +namespace mce +{ + class RenderContext; + class Texture; + class TextureBase + { + public: + TextureDescription m_description; + + protected: + bool m_bCreated; + + public: + TextureBase(); + + public: + const TextureDescription& getDescription() const; + void deleteTexture(); + void bindTexture(RenderContext& context, unsigned int textureUnit = 0, unsigned int shaderStagesBits = SHADER_STAGE_BIT_PIXEL); + bool isLoaded() const; + + void convertToMipmapedTexture(unsigned int mipmaps); + void convertToMipmapedTexture(RenderContext& context, unsigned int mipmaps); + + void subBuffer(RenderContext& context, const void* pixels, unsigned int xoffset, unsigned int yoffset, unsigned int width, unsigned int height, unsigned int level); + void subBuffer(RenderContext& context, const void* pixels); + + void copyTexture(RenderContext& context, Texture* src, unsigned int startX, unsigned int startY, unsigned int width, unsigned int height); + + void createMipMap(RenderContext& context, const void* pixels, unsigned int width, unsigned int height, unsigned int level); + + void createTexture(const TextureDescription& description); + void createTexture(RenderContext& context, TextureDescription const&); + + void lock(RenderContext& context); + void unlock(RenderContext& context); + + void move(TextureBase& other); + + static bool supportsMipMaps(); + }; +} diff --git a/source/renderer/hal/enums/BlendTarget.hpp b/source/renderer/hal/enums/BlendTarget.hpp new file mode 100644 index 000000000..6474ab77e --- /dev/null +++ b/source/renderer/hal/enums/BlendTarget.hpp @@ -0,0 +1,17 @@ +#pragma once + +namespace mce +{ + enum BlendTarget + { + BLEND_TARGET_DEST_COLOR, + BLEND_TARGET_SOURCE_COLOR, + BLEND_TARGET_ZERO, + BLEND_TARGET_ONE, + BLEND_TARGET_ONE_MINUS_DEST_COLOR, + BLEND_TARGET_ONE_MINUS_SRC_COLOR, + BLEND_TARGET_SOURCE_ALPHA, + BLEND_TARGET_DEST_ALPHA, + BLEND_TARGET_ONE_MINUS_SRC_ALPHA + }; +} \ No newline at end of file diff --git a/source/renderer/hal/enums/BlendTarget_JsonParser.cpp b/source/renderer/hal/enums/BlendTarget_JsonParser.cpp new file mode 100644 index 000000000..47f647ad9 --- /dev/null +++ b/source/renderer/hal/enums/BlendTarget_JsonParser.cpp @@ -0,0 +1,27 @@ +#include "common/utility/JsonParser.hpp" +#include "BlendTarget.hpp" + +namespace mce +{ + std::map _CreateBlendTargetMap() + { + std::map m; + m["DestColor"] = BLEND_TARGET_DEST_COLOR; + m["SourceColor"] = BLEND_TARGET_SOURCE_COLOR; + m["Zero"] = BLEND_TARGET_ZERO; + m["One"] = BLEND_TARGET_ONE; + m["OneMinusDestColor"] = BLEND_TARGET_ONE_MINUS_DEST_COLOR; + m["OneMinusSrcColor"] = BLEND_TARGET_ONE_MINUS_SRC_COLOR; + m["SourceAlpha"] = BLEND_TARGET_SOURCE_ALPHA; + m["DestAlpha"] = BLEND_TARGET_DEST_ALPHA; + m["OneMinusSrcAlpha"] = BLEND_TARGET_ONE_MINUS_SRC_ALPHA; + return m; + } + const std::map _blendTargetMap = _CreateBlendTargetMap(); + + template <> + bool parse(const rapidjson::Value& root, const std::string& name, BlendTarget& out) + { + return parse(root, name, _blendTargetMap, out); + } +} \ No newline at end of file diff --git a/source/renderer/hal/enums/BufferType.hpp b/source/renderer/hal/enums/BufferType.hpp new file mode 100644 index 000000000..9a4531a30 --- /dev/null +++ b/source/renderer/hal/enums/BufferType.hpp @@ -0,0 +1,14 @@ +#pragma once + +namespace mce +{ + enum BufferType + { + BUFFER_TYPE_VERTEX, + BUFFER_TYPE_INDEX, + + BUFFER_TYPES_MIN = BUFFER_TYPE_VERTEX, + BUFFER_TYPES_MAX = BUFFER_TYPE_INDEX, + BUFFER_TYPE_NONE = 3 + }; +} \ No newline at end of file diff --git a/source/renderer/hal/enums/ColorWriteMask.hpp b/source/renderer/hal/enums/ColorWriteMask.hpp new file mode 100644 index 000000000..1fa6ef667 --- /dev/null +++ b/source/renderer/hal/enums/ColorWriteMask.hpp @@ -0,0 +1,14 @@ +#pragma once + +namespace mce +{ + enum ColorWriteMask + { + COLOR_WRITE_MASK_NONE = 0x0, + COLOR_WRITE_MASK_RED = 0x1, + COLOR_WRITE_MASK_GREEN = 0x2, + COLOR_WRITE_MASK_BLUE = 0x4, + COLOR_WRITE_MASK_ALPHA = 0x8, + COLOR_WRITE_MASK_ALL = 0xF + }; +} \ No newline at end of file diff --git a/source/renderer/hal/enums/ComparisonFunc.hpp b/source/renderer/hal/enums/ComparisonFunc.hpp new file mode 100644 index 000000000..2dae03462 --- /dev/null +++ b/source/renderer/hal/enums/ComparisonFunc.hpp @@ -0,0 +1,16 @@ +#pragma once + +namespace mce +{ + // Previously called DepthStencilFunc + enum ComparisonFunc + { + COMPARISON_FUNC_EQUAL, + COMPARISON_FUNC_NOT_EQUAL, + COMPARISON_FUNC_ALWAYS, + COMPARISON_FUNC_LESS, + COMPARISON_FUNC_GREATER, + COMPARISON_FUNC_GREATER_EQUAL, + COMPARISON_FUNC_LESS_EQUAL + }; +} \ No newline at end of file diff --git a/source/renderer/hal/enums/ComparisonFunc_JsonParser.cpp b/source/renderer/hal/enums/ComparisonFunc_JsonParser.cpp new file mode 100644 index 000000000..51d3b0c5a --- /dev/null +++ b/source/renderer/hal/enums/ComparisonFunc_JsonParser.cpp @@ -0,0 +1,27 @@ +#include "common/utility/JsonParser.hpp" +#include "ComparisonFunc.hpp" + +namespace mce +{ + + std::map _CreateComparisonFunctMap() + { + std::map m; + m["Always"] = COMPARISON_FUNC_ALWAYS; + m["Equal"] = COMPARISON_FUNC_EQUAL; + m["NotEqual"] = COMPARISON_FUNC_NOT_EQUAL; + m["Less"] = COMPARISON_FUNC_LESS; + m["Greater"] = COMPARISON_FUNC_GREATER; + m["GreaterEqual"] = COMPARISON_FUNC_GREATER_EQUAL; + m["LessEqual"] = COMPARISON_FUNC_LESS_EQUAL; + return m; + } + const std::map _comparisonFunctMap = _CreateComparisonFunctMap(); + + template <> + bool parse(const rapidjson::Value& root, const std::string& name, ComparisonFunc& out) + { + return parse(root, name, _comparisonFunctMap, out); + } + +} \ No newline at end of file diff --git a/source/renderer/hal/enums/CullMode.hpp b/source/renderer/hal/enums/CullMode.hpp new file mode 100644 index 000000000..4b4e1a860 --- /dev/null +++ b/source/renderer/hal/enums/CullMode.hpp @@ -0,0 +1,11 @@ +#pragma once + +namespace mce +{ + enum CullMode + { + CULL_NONE, + CULL_FRONT, + CULL_BACK + }; +} \ No newline at end of file diff --git a/source/renderer/hal/enums/DepthWriteMask.hpp b/source/renderer/hal/enums/DepthWriteMask.hpp new file mode 100644 index 000000000..26ef26bbd --- /dev/null +++ b/source/renderer/hal/enums/DepthWriteMask.hpp @@ -0,0 +1,10 @@ +#pragma once + +namespace mce +{ + enum DepthWriteMask + { + DEPTH_WRITE_MASK_NONE, + DEPTH_WRITE_MASK_ALL + }; +} \ No newline at end of file diff --git a/source/renderer/hal/enums/FogMode.hpp b/source/renderer/hal/enums/FogMode.hpp new file mode 100644 index 000000000..816c6de69 --- /dev/null +++ b/source/renderer/hal/enums/FogMode.hpp @@ -0,0 +1,11 @@ +#pragma once + +namespace mce +{ + enum FogMode + { + FOG_MODE_LINEAR, + FOG_MODE_EXP, + FOG_MODE_EXP2 + }; +} \ No newline at end of file diff --git a/source/renderer/hal/enums/PrimitiveMode.hpp b/source/renderer/hal/enums/PrimitiveMode.hpp new file mode 100644 index 000000000..fdb611c7e --- /dev/null +++ b/source/renderer/hal/enums/PrimitiveMode.hpp @@ -0,0 +1,18 @@ +#pragma once + +namespace mce +{ + enum PrimitiveMode + { + PRIMITIVE_MODE_NONE, + PRIMITIVE_MODE_QUAD_LIST, + PRIMITIVE_MODE_TRIANGLE_LIST, + PRIMITIVE_MODE_TRIANGLE_STRIP, + PRIMITIVE_MODE_LINE_LIST, + PRIMITIVE_MODE_LINE_STRIP, + + PRIMITIVE_MODE_COUNT, + PRIMITIVE_MODE_MIN = PRIMITIVE_MODE_NONE, + PRIMITIVE_MODE_MAX = PRIMITIVE_MODE_LINE_STRIP + }; +} \ No newline at end of file diff --git a/source/renderer/hal/enums/PrimitiveMode_JsonParser.cpp b/source/renderer/hal/enums/PrimitiveMode_JsonParser.cpp new file mode 100644 index 000000000..56472e884 --- /dev/null +++ b/source/renderer/hal/enums/PrimitiveMode_JsonParser.cpp @@ -0,0 +1,27 @@ +#include "common/utility/JsonParser.hpp" +#include "PrimitiveMode.hpp" + +namespace mce +{ + + std::map _CreatePrimitiveModeMap() + { + std::map m; + m["None"] = PRIMITIVE_MODE_NONE; + m["QuadList"] = PRIMITIVE_MODE_QUAD_LIST; + m["TriangleList"] = PRIMITIVE_MODE_TRIANGLE_LIST; + m["TriangleStrip"] = PRIMITIVE_MODE_TRIANGLE_STRIP; + m["LineList"] = PRIMITIVE_MODE_LINE_LIST; + m["Line"] = PRIMITIVE_MODE_LINE_STRIP; + return m; + } + + const std::map _primitiveModeMap = _CreatePrimitiveModeMap(); + + template <> + bool parse(const rapidjson::Value& root, const std::string& name, PrimitiveMode& out) + { + return parse(root, name, _primitiveModeMap, out); + } + +} diff --git a/source/renderer/hal/enums/RenderState.hpp b/source/renderer/hal/enums/RenderState.hpp new file mode 100644 index 000000000..f3748e73c --- /dev/null +++ b/source/renderer/hal/enums/RenderState.hpp @@ -0,0 +1,21 @@ +#pragma once + +namespace mce +{ + enum RenderState + { + RS_NONE, + RS_DISABLE_DEPTH_TEST, + RS_BLENDING, + RS_POLYGON_OFFSET, + RS_DISABLE_CULLING, + RS_DISABLE_COLOR_WRITE, + RS_DISABLE_DEPTH_WRITE, + RS_STENCIL_WRITE, + RS_INVERT_CULLING, + RS_ENABLE_STENCIL_TEST, + // Fixed pipeline stuff + RS_ENABLE_ALPHA_TEST, + RS_ENABLE_TEXTURE + }; +} \ No newline at end of file diff --git a/source/renderer/hal/enums/RenderState_JsonParser.cpp b/source/renderer/hal/enums/RenderState_JsonParser.cpp new file mode 100644 index 000000000..88af52671 --- /dev/null +++ b/source/renderer/hal/enums/RenderState_JsonParser.cpp @@ -0,0 +1,13 @@ +#include "common/utility/JsonParser.hpp" +#include "RenderState_JsonParser.hpp" + +namespace mce +{ + + template <> + bool parse(const rapidjson::Value& root, const std::string& name, RenderState& out) + { + return parse(root, name, _renderStateMap, out); + } + +} \ No newline at end of file diff --git a/source/renderer/hal/enums/RenderState_JsonParser.hpp b/source/renderer/hal/enums/RenderState_JsonParser.hpp new file mode 100644 index 000000000..9c7713c24 --- /dev/null +++ b/source/renderer/hal/enums/RenderState_JsonParser.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include +#include +#include "RenderState.hpp" + +namespace mce +{ + std::map _CreateRenderStateMap() + { + std::map m; + m["DisableDepthTest"] = RS_DISABLE_DEPTH_TEST; + m["Blending"] = RS_BLENDING; + m["PolygonOffset"] = RS_POLYGON_OFFSET; + m["DisableCulling"] = RS_DISABLE_CULLING; + m["DisableColorWrite"] = RS_DISABLE_COLOR_WRITE; + m["DisableDepthWrite"] = RS_DISABLE_DEPTH_WRITE; + m["StencilWrite"] = RS_STENCIL_WRITE; + m["InvertCulling"] = RS_INVERT_CULLING; + m["EnableStencilTest"] = RS_ENABLE_STENCIL_TEST; + m["EnableAlphaTest"] = RS_ENABLE_ALPHA_TEST; + m["Textured"] = RS_ENABLE_TEXTURE; + return m; + } + const std::map _renderStateMap = _CreateRenderStateMap(); +} diff --git a/source/renderer/hal/enums/ShadeMode.hpp b/source/renderer/hal/enums/ShadeMode.hpp new file mode 100644 index 000000000..1fbd387fc --- /dev/null +++ b/source/renderer/hal/enums/ShadeMode.hpp @@ -0,0 +1,10 @@ +#pragma once + +namespace mce +{ + enum ShadeMode + { + SHADE_MODE_FLAT, + SHADE_MODE_SMOOTH + }; +} \ No newline at end of file diff --git a/source/renderer/hal/enums/ShaderPrimitiveTypes.cpp b/source/renderer/hal/enums/ShaderPrimitiveTypes.cpp new file mode 100644 index 000000000..5428e8717 --- /dev/null +++ b/source/renderer/hal/enums/ShaderPrimitiveTypes.cpp @@ -0,0 +1,32 @@ +#include +#include "ShaderPrimitiveTypes.hpp" +#include "common/Logger.hpp" + +using namespace mce; + +int ShaderPrimitiveTypeHelper::sizeInBytesFromShaderPrimitiveType(ShaderPrimitiveTypes shaderPrimitiveType) +{ + switch (shaderPrimitiveType) + { + case SHADER_PRIMITIVE_FLOAT1: + case SHADER_PRIMITIVE_INT1: + return 4; + case SHADER_PRIMITIVE_FLOAT2: + case SHADER_PRIMITIVE_INT2: + return 8; + case SHADER_PRIMITIVE_FLOAT3: + case SHADER_PRIMITIVE_INT3: + return 12; + case SHADER_PRIMITIVE_FLOAT4: + case SHADER_PRIMITIVE_INT4: + case SHADER_PRIMITIVE_MATRIX2x2: + return 16; + case SHADER_PRIMITIVE_MATRIX3x3: + return 36; + case SHADER_PRIMITIVE_MATRIX4x4: + return 64; + default: + LOG_E("Unknown shaderPrimitiveType: %d", shaderPrimitiveType); + throw std::bad_cast(); + } +} diff --git a/source/renderer/hal/enums/ShaderPrimitiveTypes.hpp b/source/renderer/hal/enums/ShaderPrimitiveTypes.hpp new file mode 100644 index 000000000..69be613d7 --- /dev/null +++ b/source/renderer/hal/enums/ShaderPrimitiveTypes.hpp @@ -0,0 +1,47 @@ +#pragma once + +namespace mce +{ + enum ShaderPrimitiveTypes + { + SHADER_PRIMITIVE_UNKNOWN, + SHADER_PRIMITIVE_FLOAT1, + SHADER_PRIMITIVE_FLOAT2, + SHADER_PRIMITIVE_FLOAT3, + SHADER_PRIMITIVE_FLOAT4, + SHADER_PRIMITIVE_INT1, + SHADER_PRIMITIVE_INT2, + SHADER_PRIMITIVE_INT3, + SHADER_PRIMITIVE_INT4, + SHADER_PRIMITIVE_MATRIX2x2, + SHADER_PRIMITIVE_MATRIX3x3, + SHADER_PRIMITIVE_MATRIX4x4, + SHADER_PRIMITIVE_SAMPLER1D, + SHADER_PRIMITIVE_SAMPLER2D, + SHADER_PRIMITIVE_SAMPLER3D, + + SHADER_PRIMITIVES_MIN = SHADER_PRIMITIVE_UNKNOWN, + SHADER_PRIMITIVES_MAX = SHADER_PRIMITIVE_MATRIX4x4 + }; + + class ShaderPrimitiveTypeHelper + { + public: + static int sizeInBytesFromShaderPrimitiveType(ShaderPrimitiveTypes shaderPrimitiveType); + }; + + static const char* ShaderPrimitiveTypeToString[] = { + "UnknownPrimitiveType", + "Float1", + "Float2", + "Float3", + "Float4", + "Int1", + "Int2", + "Int3", + "Int4", + "Matrix2x2", + "Matrix3x3", + "Matrix4x4" + }; +} \ No newline at end of file diff --git a/source/renderer/hal/enums/ShaderStagesBits.hpp b/source/renderer/hal/enums/ShaderStagesBits.hpp new file mode 100644 index 000000000..62a5e2412 --- /dev/null +++ b/source/renderer/hal/enums/ShaderStagesBits.hpp @@ -0,0 +1,14 @@ +#pragma once + +namespace mce +{ + enum ShaderStagesBits + { + SHADER_STAGE_BIT_NO_SHADER = 0x0, + SHADER_STAGE_BIT_VERTEX = (1 << 0), + SHADER_STAGE_BIT_PIXEL = (1 << 1), + SHADER_STAGE_BIT_GEOMETRY = (1 << 2), + + SHADER_STAGE_BITS_ALL = SHADER_STAGE_BIT_VERTEX | SHADER_STAGE_BIT_PIXEL | SHADER_STAGE_BIT_GEOMETRY + }; +} \ No newline at end of file diff --git a/source/renderer/hal/enums/ShaderStagesBits_JsonParser.cpp b/source/renderer/hal/enums/ShaderStagesBits_JsonParser.cpp new file mode 100644 index 000000000..2d3963419 --- /dev/null +++ b/source/renderer/hal/enums/ShaderStagesBits_JsonParser.cpp @@ -0,0 +1,23 @@ +#include "common/utility/JsonParser.hpp" +#include "ShaderStagesBits.hpp" + +namespace mce +{ + + std::map _CreateShaderStageMap() + { + std::map m; + m["Vertex"] = SHADER_STAGE_BIT_VERTEX; + m["Pixel"] = SHADER_STAGE_BIT_PIXEL; + m["Geometry"] = SHADER_STAGE_BIT_GEOMETRY; + return m; + } + const std::map _shaderStageMap = _CreateShaderStageMap(); + + template <> + bool parse(const rapidjson::Value& root, const std::string& name, ShaderStagesBits& out) + { + return parse(root, name, _shaderStageMap, out); + } + +} \ No newline at end of file diff --git a/source/renderer/hal/enums/ShaderType.hpp b/source/renderer/hal/enums/ShaderType.hpp new file mode 100644 index 000000000..8388f6912 --- /dev/null +++ b/source/renderer/hal/enums/ShaderType.hpp @@ -0,0 +1,15 @@ +#pragma once + +namespace mce +{ + enum ShaderType + { + SHADER_TYPE_VERTEX, + SHADER_TYPE_FRAGMENT, + SHADER_TYPE_GEOMETRY, + + SHADER_TYPES_MIN = SHADER_TYPE_VERTEX, + SHADER_TYPES_MAX = SHADER_TYPE_GEOMETRY, + SHADER_TYPES_COUNT + }; +} \ No newline at end of file diff --git a/source/renderer/hal/enums/StencilMask.hpp b/source/renderer/hal/enums/StencilMask.hpp new file mode 100644 index 000000000..408294218 --- /dev/null +++ b/source/renderer/hal/enums/StencilMask.hpp @@ -0,0 +1,10 @@ +#pragma once + +namespace mce +{ + enum StencilMask + { + STENCIL_MASK_NONE = 0x0, + STENCIL_MASK_ALL = 0xFF + }; +} \ No newline at end of file diff --git a/source/renderer/hal/enums/StencilOp.hpp b/source/renderer/hal/enums/StencilOp.hpp new file mode 100644 index 000000000..c6580953b --- /dev/null +++ b/source/renderer/hal/enums/StencilOp.hpp @@ -0,0 +1,13 @@ +#pragma once + +namespace mce +{ + enum StencilOp + { + STENCIL_OP_KEEP = 0x1, + STENCIL_OP_ZERO = 0x2, + STENCIL_OP_REPLACE = 0x3, + STENCIL_OP_INCR = 0x7, + STENCIL_OP_DECR = 0x8 + }; +} \ No newline at end of file diff --git a/source/renderer/hal/enums/StencilOp_JsonParser.cpp b/source/renderer/hal/enums/StencilOp_JsonParser.cpp new file mode 100644 index 000000000..829dbd881 --- /dev/null +++ b/source/renderer/hal/enums/StencilOp_JsonParser.cpp @@ -0,0 +1,22 @@ +#include "common/utility/JsonParser.hpp" +#include "StencilOp.hpp" + +namespace mce +{ + + std::map _CreateStencilOpMap() + { + std::map m; + m["Keep"] = STENCIL_OP_KEEP; + m["Replace"] = STENCIL_OP_REPLACE; + return m; + } + const std::map _stencilOpMap = _CreateStencilOpMap(); + + template <> + bool parse(const rapidjson::Value& root, const std::string& name, StencilOp& out) + { + return parse(root, name, _stencilOpMap, out); + } + +} \ No newline at end of file diff --git a/source/renderer/hal/enums/TextureFiltering.hpp b/source/renderer/hal/enums/TextureFiltering.hpp new file mode 100644 index 000000000..65c59ba2d --- /dev/null +++ b/source/renderer/hal/enums/TextureFiltering.hpp @@ -0,0 +1,14 @@ +#pragma once + +namespace mce +{ + enum TextureFiltering + { + TEXTURE_FILTERING_POINT, + TEXTURE_FILTERING_BILINEAR, + TEXTURE_FILTERING_MIPMAP_BILINEAR, + TEXTURE_FILTERING_TRILINEAR, + TEXTURE_FILTERING_TEXEL_AA, + TEXTURE_FILTERING_PCF + }; +} \ No newline at end of file diff --git a/source/renderer/hal/enums/TextureFiltering_JsonParser.cpp b/source/renderer/hal/enums/TextureFiltering_JsonParser.cpp new file mode 100644 index 000000000..f0b78f7fa --- /dev/null +++ b/source/renderer/hal/enums/TextureFiltering_JsonParser.cpp @@ -0,0 +1,26 @@ +#include "common/utility/JsonParser.hpp" +#include "TextureFiltering.hpp" + +namespace mce +{ + + std::map _CreateTextureFilterMap() + { + std::map m; + m["Point"] = TEXTURE_FILTERING_POINT; + m["Bilinear"] = TEXTURE_FILTERING_BILINEAR; + m["Trilinear"] = TEXTURE_FILTERING_TRILINEAR; + m["MipMapBilinear"] = TEXTURE_FILTERING_MIPMAP_BILINEAR; + m["TexelAA"] = TEXTURE_FILTERING_TEXEL_AA; + m["PCF"] = TEXTURE_FILTERING_PCF; + return m; + } + const std::map _textureFilterMap = _CreateTextureFilterMap(); + + template <> + bool parse(const rapidjson::Value& root, const std::string& name, TextureFiltering& out) + { + return parse(root, name, _textureFilterMap, out); + } + +} \ No newline at end of file diff --git a/source/renderer/hal/enums/TextureFormat.hpp b/source/renderer/hal/enums/TextureFormat.hpp new file mode 100644 index 000000000..b519260ea --- /dev/null +++ b/source/renderer/hal/enums/TextureFormat.hpp @@ -0,0 +1,44 @@ +#pragma once + +namespace mce +{ + enum TextureFormat + { + TEXTURE_FORMAT_UNKNOWN = 0x0, + TEXTURE_FORMAT_R32G32B32A32_FLOAT = 0x2, + TEXTURE_FORMAT_R16G16B16A16_FLOAT = 0xA, + TEXTURE_FORMAT_R16G16B16A16_UNORM = 0xB, + TEXTURE_FORMAT_R32G32_FLOAT = 0x10, + TEXTURE_FORMAT_R10G10B10A2_UNORM = 0x18, + TEXTURE_FORMAT_R11G11B10_FLOAT = 0x1A, + TEXTURE_FORMAT_R8G8B8A8_UNORM = 0x1C, + TEXTURE_FORMAT_R8G8B8A8_UNORM_SRGB = 0x1D, + TEXTURE_FORMAT_R16G16_FLOAT = 0x22, + TEXTURE_FORMAT_R16G16_UNORM = 0x23, + TEXTURE_FORMAT_R16G16_UINT = 0x24, + TEXTURE_FORMAT_R16G16_SNORM = 0x25, + TEXTURE_FORMAT_D32_FLOAT = 0x28, + TEXTURE_FORMAT_R32_FLOAT = 0x29, + TEXTURE_FORMAT_R32_UINT = 0x2A, + TEXTURE_FORMAT_R24G8_TYPELESS = 0x2C, + TEXTURE_FORMAT_D24_UNORM_S8_UINT = 0x2D, + TEXTURE_FORMAT_R24_UNORM_X8_TYPELESS = 0x2E, + TEXTURE_FORMAT_R8G8_UNORM = 0x31, + TEXTURE_FORMAT_R8G8_SNORM = 0x33, + TEXTURE_FORMAT_R16_FLOAT = 0x36, + TEXTURE_FORMAT_D16_UNORM = 0x37, + TEXTURE_FORMAT_R8_UNORM = 0x3D, + TEXTURE_FORMAT_R8_UINT = 0x3E, + TEXTURE_FORMAT_A8_UNORM = 0x41, + TEXTURE_FORMAT_BC3_UNORM = 0x4D, + TEXTURE_FORMAT_R5G6B5_UNORM = 0x55, + TEXTURE_FORMAT_R5G5B5A1_UNORM = 0x56, + TEXTURE_FORMAT_B8G8R8A8_UNORM = 0x57, + TEXTURE_FORMAT_B8G8R8A8_UNORM_SRGB = 0x5B, + TEXTURE_FORMAT_BC7_UNORM = 0x62, + TEXTURE_FORMAT_R4G4B4A4_UNORM = 0x73, + TEXTURE_FORMAT_S8_UINT = 0x74, + TEXTURE_FORMAT_R8G8B8_UNORM = 0x75, + TEXTURE_FORMAT_COMPRESSED = 0x76 + }; +} \ No newline at end of file diff --git a/source/renderer/hal/enums/VertexField.hpp b/source/renderer/hal/enums/VertexField.hpp new file mode 100644 index 000000000..4281f8719 --- /dev/null +++ b/source/renderer/hal/enums/VertexField.hpp @@ -0,0 +1,26 @@ +#pragma once + +namespace mce +{ + enum VertexField + { + VERTEX_FIELD_POSITION, + VERTEX_FIELD_COLOR, + VERTEX_FIELD_NORMAL, + VERTEX_FIELD_UV0, + VERTEX_FIELD_UV1, + VERTEX_FIELD_UV2, + VERTEX_FIELD_PBR_IDX, + VERTEX_FIELD_BONEID_0, + VERTEX_FIELD_PREVIOUS_POSITION, + VERTEX_FIELD_HB_POSITION, + VERTEX_FIELD_HB_COLOR, + VERTEX_FIELD_HB_ADDITIONAL, + + VERTEX_FIELDS_MIN = VERTEX_FIELD_POSITION, + VERTEX_FIELDS_MAX = VERTEX_FIELD_BONEID_0, + VERTEX_FIELDS_COUNT, + + VERTEX_FIELD_INVALID = 0xFFFF + }; +} \ No newline at end of file diff --git a/source/renderer/hal/enums/VertexFieldType.hpp b/source/renderer/hal/enums/VertexFieldType.hpp new file mode 100644 index 000000000..7a966054c --- /dev/null +++ b/source/renderer/hal/enums/VertexFieldType.hpp @@ -0,0 +1,12 @@ +#pragma once + +namespace mce +{ + enum VertexFieldType + { + VERTEX_FIELD_TYPE_UNKNOWN, + VERTEX_FIELD_TYPE_NORMAL, + VERTEX_FIELD_TYPE_BONEID = 0x3, + VERTEX_FIELD_TYPE_TEXCOORD + }; +} \ No newline at end of file diff --git a/source/renderer/hal/enums/VertexField_JsonParser.cpp b/source/renderer/hal/enums/VertexField_JsonParser.cpp new file mode 100644 index 000000000..ada47235a --- /dev/null +++ b/source/renderer/hal/enums/VertexField_JsonParser.cpp @@ -0,0 +1,30 @@ +#include "common/utility/JsonParser.hpp" +#include "VertexField.hpp" + +namespace mce +{ + std::map _CreateVertexFieldMap() + { + std::map m; + m["Position"] = VERTEX_FIELD_POSITION; + m["Color"] = VERTEX_FIELD_COLOR; + m["Normal"] = VERTEX_FIELD_NORMAL; + m["UV0"] = VERTEX_FIELD_UV0; + m["UV1"] = VERTEX_FIELD_UV1; + m["UV2"] = VERTEX_FIELD_UV2; + m["PBRTextureIdx"] = VERTEX_FIELD_PBR_IDX; + m["BoneId0"] = VERTEX_FIELD_BONEID_0; + m["PreviousPosition"] = VERTEX_FIELD_PREVIOUS_POSITION; + m["HummingbirdPosition"] = VERTEX_FIELD_HB_POSITION; + m["HummingbirdColor"] = VERTEX_FIELD_HB_COLOR; + m["HummingbirdAdditional"] = VERTEX_FIELD_HB_ADDITIONAL; + return m; + } + const std::map _vertexFieldMap = _CreateVertexFieldMap(); + + template <> + bool parse(const rapidjson::Value& root, const std::string& name, VertexField& out) + { + return parse(root, name, _vertexFieldMap, out); + } +} diff --git a/source/renderer/hal/helpers/ErrorHandler.cpp b/source/renderer/hal/helpers/ErrorHandler.cpp new file mode 100644 index 000000000..187acf16e --- /dev/null +++ b/source/renderer/hal/helpers/ErrorHandler.cpp @@ -0,0 +1,23 @@ +#include "ErrorHandler.hpp" +#include "renderer/PlatformDefinitions.h" +#include "common/Logger.hpp" + +#if MCE_GFX_API_OGL +#include "renderer/hal/ogl/API_OGL.hpp" +#endif + +using namespace mce; + +void ErrorHandler::checkForErrors() +{ +#ifdef _DEBUG +#if MCE_GFX_API_OGL + GLenum __err = glGetError(); + if (__err != GL_NO_ERROR) + { + LOG_E("OpenGL Error: 0x%X", __err); + throw std::bad_cast(); + } +#endif +#endif +} \ No newline at end of file diff --git a/source/renderer/hal/helpers/ErrorHandler.hpp b/source/renderer/hal/helpers/ErrorHandler.hpp new file mode 100644 index 000000000..504b9a21a --- /dev/null +++ b/source/renderer/hal/helpers/ErrorHandler.hpp @@ -0,0 +1,10 @@ +#pragma once + +namespace mce +{ + class ErrorHandler + { + public: + static void checkForErrors(); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/helpers/TextureHelper.cpp b/source/renderer/hal/helpers/TextureHelper.cpp new file mode 100644 index 000000000..05312c3fe --- /dev/null +++ b/source/renderer/hal/helpers/TextureHelper.cpp @@ -0,0 +1,17 @@ +#include +#include "TextureHelper.hpp" +#include "common/Logger.hpp" + +using namespace mce; + +unsigned int TextureHelper::textureFormatToByteStride(TextureFormat textureFormat) +{ + switch (textureFormat) + { + case TEXTURE_FORMAT_R8G8B8A8_UNORM: + return 4; + default: + LOG_E("Unknown textureFormat: %d", textureFormat); + throw std::bad_cast(); + } +} \ No newline at end of file diff --git a/source/renderer/hal/helpers/TextureHelper.hpp b/source/renderer/hal/helpers/TextureHelper.hpp new file mode 100644 index 000000000..a0dc278b1 --- /dev/null +++ b/source/renderer/hal/helpers/TextureHelper.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include "renderer/hal/enums/TextureFormat.hpp" + +namespace mce +{ + class TextureHelper + { + public: + static unsigned int textureFormatToByteStride(TextureFormat textureFormat); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/interface/BlendState.cpp b/source/renderer/hal/interface/BlendState.cpp new file mode 100644 index 000000000..a44dc3281 --- /dev/null +++ b/source/renderer/hal/interface/BlendState.cpp @@ -0,0 +1,10 @@ +#include "BlendState.hpp" + +using namespace mce; + +BlendState::BlendState() + : MCE_GFX_CLASS(BlendState)() +{ +} + +//#include MCE_GFX_CLASS_IMPL(BlendState) \ No newline at end of file diff --git a/source/renderer/hal/interface/BlendState.hpp b/source/renderer/hal/interface/BlendState.hpp new file mode 100644 index 000000000..f704fdf4a --- /dev/null +++ b/source/renderer/hal/interface/BlendState.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include "renderer/PlatformDefinitions.h" +#include MCE_GFX_CLASS_HEADER(BlendState) + +namespace mce +{ + class BlendState : public MCE_GFX_CLASS(BlendState) + { + public: + BlendState(); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/interface/Buffer.cpp b/source/renderer/hal/interface/Buffer.cpp new file mode 100644 index 000000000..42fe70d3d --- /dev/null +++ b/source/renderer/hal/interface/Buffer.cpp @@ -0,0 +1,25 @@ +#include + +#include "Buffer.hpp" + +using namespace mce; + +void Buffer::createIndexBuffer(RenderContext& context, unsigned int sizeOfSingleIndice, const void *indices, unsigned int numberOfIndices) +{ + createBuffer(context, sizeOfSingleIndice, indices, numberOfIndices, BUFFER_TYPE_INDEX); +} + +void Buffer::createVertexBuffer(RenderContext& context, unsigned int vertexStride, const void *vertices, unsigned int numberOfVertices) +{ + createBuffer(context, vertexStride, vertices, numberOfVertices, BUFFER_TYPE_VERTEX); +} + +void Buffer::createDynamicIndexBuffer(RenderContext& context, unsigned int stride) +{ + createDynamicBuffer(context, 1, nullptr, stride, BUFFER_TYPE_INDEX); +} + +void Buffer::createDynamicVertexBuffer(RenderContext& context, unsigned int stride) +{ + createDynamicBuffer(context, 1, nullptr, stride, BUFFER_TYPE_VERTEX); +} diff --git a/source/renderer/hal/interface/Buffer.hpp b/source/renderer/hal/interface/Buffer.hpp new file mode 100644 index 000000000..b091a66b8 --- /dev/null +++ b/source/renderer/hal/interface/Buffer.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include "renderer/PlatformDefinitions.h" +#include MCE_GFX_CLASS_HEADER(Buffer) + +namespace mce +{ + class Buffer : public MCE_GFX_CLASS(Buffer) + { + public: + void createIndexBuffer(RenderContext& context, unsigned int sizeOfSingleIndice, const void *indices, unsigned int numberOfIndices); + void createVertexBuffer(RenderContext& context, unsigned int vertexStride, const void *vertices, unsigned int numberOfVertices); + void createDynamicIndexBuffer(RenderContext& context, unsigned int size); + void createDynamicVertexBuffer(RenderContext& context, unsigned int size); + + public: + MC_FUNC_MOVE(Buffer); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/interface/ConstantBuffer.cpp b/source/renderer/hal/interface/ConstantBuffer.cpp new file mode 100644 index 000000000..2a19b00a6 --- /dev/null +++ b/source/renderer/hal/interface/ConstantBuffer.cpp @@ -0,0 +1 @@ +#include "ConstantBuffer.hpp" diff --git a/source/renderer/hal/interface/ConstantBuffer.hpp b/source/renderer/hal/interface/ConstantBuffer.hpp new file mode 100644 index 000000000..9a0434e2b --- /dev/null +++ b/source/renderer/hal/interface/ConstantBuffer.hpp @@ -0,0 +1,11 @@ +#pragma once + +#include "renderer/hal/base/ConstantBufferBase.hpp" + +namespace mce +{ + class ConstantBuffer : public ConstantBufferBase + { + + }; +} \ No newline at end of file diff --git a/source/renderer/hal/interface/ConstantBufferConstants.hpp b/source/renderer/hal/interface/ConstantBufferConstants.hpp new file mode 100644 index 000000000..ddca4da84 --- /dev/null +++ b/source/renderer/hal/interface/ConstantBufferConstants.hpp @@ -0,0 +1,11 @@ +#pragma once + +#include "renderer/hal/base/ConstantBufferConstantsBase.hpp" + +namespace mce +{ + class ConstantBufferConstants : public ConstantBufferConstantsBase + { + + }; +} \ No newline at end of file diff --git a/source/renderer/hal/interface/ConstantBufferContainer.cpp b/source/renderer/hal/interface/ConstantBufferContainer.cpp new file mode 100644 index 000000000..aa7eb4c8e --- /dev/null +++ b/source/renderer/hal/interface/ConstantBufferContainer.cpp @@ -0,0 +1,8 @@ +#include "ConstantBufferContainer.hpp" + +using namespace mce; + +ConstantBufferContainer::ConstantBufferContainer() + : MCE_GFX_CLASS(ConstantBufferContainer)() +{ +} diff --git a/source/renderer/hal/interface/ConstantBufferContainer.hpp b/source/renderer/hal/interface/ConstantBufferContainer.hpp new file mode 100644 index 000000000..9652f6e71 --- /dev/null +++ b/source/renderer/hal/interface/ConstantBufferContainer.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include "renderer/PlatformDefinitions.h" +#include MCE_GFX_CLASS_HEADER(ConstantBufferContainer) + +namespace mce +{ + class ConstantBufferContainer : public MCE_GFX_CLASS(ConstantBufferContainer) + { + public: + ConstantBufferContainer(); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/interface/DepthStencilState.cpp b/source/renderer/hal/interface/DepthStencilState.cpp new file mode 100644 index 000000000..c7b17480a --- /dev/null +++ b/source/renderer/hal/interface/DepthStencilState.cpp @@ -0,0 +1,8 @@ +#include "DepthStencilState.hpp" + +using namespace mce; + +DepthStencilState::DepthStencilState() + : MCE_GFX_CLASS(DepthStencilState)() +{ +} \ No newline at end of file diff --git a/source/renderer/hal/interface/DepthStencilState.hpp b/source/renderer/hal/interface/DepthStencilState.hpp new file mode 100644 index 000000000..2dfd77703 --- /dev/null +++ b/source/renderer/hal/interface/DepthStencilState.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include "renderer/PlatformDefinitions.h" +#include MCE_GFX_CLASS_HEADER(DepthStencilState) + +namespace mce +{ + class DepthStencilState : public MCE_GFX_CLASS(DepthStencilState) + { + public: + DepthStencilState(); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/interface/FixedPipelineState.cpp b/source/renderer/hal/interface/FixedPipelineState.cpp new file mode 100644 index 000000000..ca349d49b --- /dev/null +++ b/source/renderer/hal/interface/FixedPipelineState.cpp @@ -0,0 +1,8 @@ +#include "FixedPipelineState.hpp" + +using namespace mce; + +FixedPipelineState::FixedPipelineState() + : MCE_GFX_CLASS(FixedPipelineState)() +{ +} \ No newline at end of file diff --git a/source/renderer/hal/interface/FixedPipelineState.hpp b/source/renderer/hal/interface/FixedPipelineState.hpp new file mode 100644 index 000000000..5bde0e7f3 --- /dev/null +++ b/source/renderer/hal/interface/FixedPipelineState.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include "renderer/PlatformDefinitions.h" +#include MCE_GFX_CLASS_HEADER_FIXED(FixedPipelineState) + +namespace mce +{ + class FixedPipelineState : public MCE_GFX_CLASS_FIXED(FixedPipelineState) + { + public: + FixedPipelineState(); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/interface/FogState.cpp b/source/renderer/hal/interface/FogState.cpp new file mode 100644 index 000000000..987ed08bf --- /dev/null +++ b/source/renderer/hal/interface/FogState.cpp @@ -0,0 +1,8 @@ +#include "FogState.hpp" + +using namespace mce; + +FogState::FogState() + : MCE_GFX_CLASS(FogState)() +{ +} diff --git a/source/renderer/hal/interface/FogState.hpp b/source/renderer/hal/interface/FogState.hpp new file mode 100644 index 000000000..c7bc41ca0 --- /dev/null +++ b/source/renderer/hal/interface/FogState.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include "renderer/PlatformDefinitions.h" +#include MCE_GFX_CLASS_HEADER_FIXED(FogState) + +namespace mce +{ + class FogState : public MCE_GFX_CLASS_FIXED(FogState) + { + public: + FogState(); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/interface/ImmediateBuffer.cpp b/source/renderer/hal/interface/ImmediateBuffer.cpp new file mode 100644 index 000000000..10c18b75b --- /dev/null +++ b/source/renderer/hal/interface/ImmediateBuffer.cpp @@ -0,0 +1,8 @@ +#include "ImmediateBuffer.hpp" + +using namespace mce; + +ImmediateBuffer::ImmediateBuffer() + : MCE_GFX_CLASS(ImmediateBuffer)() +{ +} \ No newline at end of file diff --git a/source/renderer/hal/interface/ImmediateBuffer.hpp b/source/renderer/hal/interface/ImmediateBuffer.hpp new file mode 100644 index 000000000..7046c71df --- /dev/null +++ b/source/renderer/hal/interface/ImmediateBuffer.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include "renderer/PlatformDefinitions.h" +#include MCE_GFX_CLASS_HEADER(ImmediateBuffer) + +namespace mce +{ + class ImmediateBuffer : public MCE_GFX_CLASS(ImmediateBuffer) + { + public: + ImmediateBuffer(); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/interface/RasterizerState.cpp b/source/renderer/hal/interface/RasterizerState.cpp new file mode 100644 index 000000000..9f1b942f4 --- /dev/null +++ b/source/renderer/hal/interface/RasterizerState.cpp @@ -0,0 +1,8 @@ +#include "RasterizerState.hpp" + +using namespace mce; + +RasterizerState::RasterizerState() + : MCE_GFX_CLASS(RasterizerState)() +{ +} \ No newline at end of file diff --git a/source/renderer/hal/interface/RasterizerState.hpp b/source/renderer/hal/interface/RasterizerState.hpp new file mode 100644 index 000000000..c3349f79f --- /dev/null +++ b/source/renderer/hal/interface/RasterizerState.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include "renderer/PlatformDefinitions.h" +#include MCE_GFX_CLASS_HEADER(RasterizerState) + +namespace mce +{ + class RasterizerState : public MCE_GFX_CLASS(RasterizerState) + { + public: + RasterizerState(); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/interface/RenderContext.cpp b/source/renderer/hal/interface/RenderContext.cpp new file mode 100644 index 000000000..182b7b2a2 --- /dev/null +++ b/source/renderer/hal/interface/RenderContext.cpp @@ -0,0 +1,14 @@ +#include "RenderContext.hpp" + +using namespace mce; + +RenderContext::RenderContext() + : MCE_GFX_CLASS(RenderContext)() +{ +} + +void RenderContext::lostContext() +{ + clearContextState(); + MCE_GFX_CLASS(RenderContext)::lostContext(); +} \ No newline at end of file diff --git a/source/renderer/hal/interface/RenderContext.hpp b/source/renderer/hal/interface/RenderContext.hpp new file mode 100644 index 000000000..5ef36ba3f --- /dev/null +++ b/source/renderer/hal/interface/RenderContext.hpp @@ -0,0 +1,16 @@ +#pragma once + +#include "renderer/PlatformDefinitions.h" +#include MCE_GFX_CLASS_HEADER(RenderContext) + +namespace mce +{ + class RenderContext : public MCE_GFX_CLASS(RenderContext) + { + public: + RenderContext(); + + public: + void lostContext(); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/interface/RenderDevice.cpp b/source/renderer/hal/interface/RenderDevice.cpp new file mode 100644 index 000000000..aa39b1d6c --- /dev/null +++ b/source/renderer/hal/interface/RenderDevice.cpp @@ -0,0 +1,38 @@ +#include "RenderDevice.hpp" +#include "RenderContext.hpp" + +using namespace mce; + +RenderDevice::RenderDevice() + : MCE_GFX_CLASS(RenderDevice)() +{ + m_immediateContext = new RenderContext(); +} + +RenderDevice::~RenderDevice() +{ + if (m_immediateContext) + delete m_immediateContext; +} + +RenderContext& RenderDevice::getRenderContext() +{ + if (!m_immediateContext) + { + LOG_E("Immediate context doesn't exist anymore!"); + throw std::bad_cast(); + } + + return *m_immediateContext; +} + +const RenderContext& RenderDevice::getRenderContextAsConst() const +{ + if (!m_immediateContext) + { + LOG_E("Immediate context doesn't exist anymore!"); + throw std::bad_cast(); + } + + return *m_immediateContext; +} \ No newline at end of file diff --git a/source/renderer/hal/interface/RenderDevice.hpp b/source/renderer/hal/interface/RenderDevice.hpp new file mode 100644 index 000000000..9d8fb392e --- /dev/null +++ b/source/renderer/hal/interface/RenderDevice.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include "common/utility/Singleton.hpp" +#include "renderer/PlatformDefinitions.h" +#include MCE_GFX_CLASS_HEADER(RenderDevice) + +namespace mce +{ + class RenderDevice : public MCE_GFX_CLASS(RenderDevice), public Singleton + { + public: + RenderContext *m_immediateContext; + + public: + RenderDevice(); + ~RenderDevice(); + + public: + RenderContext& getRenderContext(); + const RenderContext& getRenderContextAsConst() const; + }; +} \ No newline at end of file diff --git a/source/renderer/hal/interface/Shader.cpp b/source/renderer/hal/interface/Shader.cpp new file mode 100644 index 000000000..44996248a --- /dev/null +++ b/source/renderer/hal/interface/Shader.cpp @@ -0,0 +1,8 @@ +#include "Shader.hpp" + +using namespace mce; + +Shader::Shader(ShaderProgram& vertex, ShaderProgram& fragment, ShaderProgram& geometry) + : MCE_GFX_CLASS_SHADER(Shader)(vertex, fragment, geometry) +{ +} \ No newline at end of file diff --git a/source/renderer/hal/interface/Shader.hpp b/source/renderer/hal/interface/Shader.hpp new file mode 100644 index 000000000..c06fd6cc7 --- /dev/null +++ b/source/renderer/hal/interface/Shader.hpp @@ -0,0 +1,14 @@ +#pragma once + +#include "ShaderProgram.hpp" +#include "renderer/PlatformDefinitions.h" +#include MCE_GFX_CLASS_HEADER_SHADER(Shader) + +namespace mce +{ + class Shader : public MCE_GFX_CLASS_SHADER(Shader) + { + public: + Shader(ShaderProgram& vertex, ShaderProgram& fragment, ShaderProgram& geometry); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/interface/ShaderConstant.hpp b/source/renderer/hal/interface/ShaderConstant.hpp new file mode 100644 index 000000000..275ef015f --- /dev/null +++ b/source/renderer/hal/interface/ShaderConstant.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include "renderer/PlatformDefinitions.h" +#include MCE_GFX_CLASS_HEADER(ShaderConstant) + +namespace mce +{ + class ShaderConstant : public MCE_GFX_CLASS(ShaderConstant) + { + + }; +} \ No newline at end of file diff --git a/source/renderer/hal/interface/ShaderConstantWithData.cpp b/source/renderer/hal/interface/ShaderConstantWithData.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/source/renderer/hal/interface/ShaderConstantWithData.hpp b/source/renderer/hal/interface/ShaderConstantWithData.hpp new file mode 100644 index 000000000..6e169beeb --- /dev/null +++ b/source/renderer/hal/interface/ShaderConstantWithData.hpp @@ -0,0 +1,34 @@ +#pragma once + +#include "renderer/PlatformDefinitions.h" +#include MCE_GFX_CLASS_HEADER_SHADER(ShaderConstantWithData) + +namespace mce +{ + template + class ShaderConstantWithData : public MCE_GFX_CLASS_SHADER(ShaderConstantWithData) + { + public: + ShaderConstantWithData(): MCE_GFX_CLASS_SHADER(ShaderConstantWithData)(T) + { + } + + virtual void syncUniform(int value) + { + MCE_GFX_CLASS_SHADER(ShaderConstantWithData)::syncUniform(value); + ShaderConstant::syncUniform(value); + } + }; + + class ShaderConstantFloat1 : public ShaderConstantWithData {}; + class ShaderConstantFloat2 : public ShaderConstantWithData {}; + class ShaderConstantFloat3 : public ShaderConstantWithData {}; + class ShaderConstantFloat4 : public ShaderConstantWithData {}; + class ShaderConstantInt1 : public ShaderConstantWithData {}; + class ShaderConstantInt2 : public ShaderConstantWithData {}; + class ShaderConstantInt3 : public ShaderConstantWithData {}; + class ShaderConstantInt4 : public ShaderConstantWithData {}; + class ShaderConstantMatrix2x2 : public ShaderConstantWithData {}; + class ShaderConstantMatrix3x3 : public ShaderConstantWithData {}; + class ShaderConstantMatrix4x4 : public ShaderConstantWithData {}; +} diff --git a/source/renderer/hal/interface/ShaderProgram.cpp b/source/renderer/hal/interface/ShaderProgram.cpp new file mode 100644 index 000000000..315f3d080 --- /dev/null +++ b/source/renderer/hal/interface/ShaderProgram.cpp @@ -0,0 +1,8 @@ +#include "ShaderProgram.hpp" + +using namespace mce; + +ShaderProgram::ShaderProgram(ShaderType shaderType, const std::string& shaderSource, const std::string& header, const std::string& shaderPath) + : MCE_GFX_CLASS_SHADER(ShaderProgram)(shaderType, shaderSource, header, shaderPath) +{ +} \ No newline at end of file diff --git a/source/renderer/hal/interface/ShaderProgram.hpp b/source/renderer/hal/interface/ShaderProgram.hpp new file mode 100644 index 000000000..c3b99a94c --- /dev/null +++ b/source/renderer/hal/interface/ShaderProgram.hpp @@ -0,0 +1,16 @@ +#pragma once + +#include + +#include "renderer/hal/enums/ShaderType.hpp" +#include "renderer/PlatformDefinitions.h" +#include MCE_GFX_CLASS_HEADER_SHADER(ShaderProgram) + +namespace mce +{ + class ShaderProgram : public MCE_GFX_CLASS_SHADER(ShaderProgram) + { + public: + ShaderProgram(ShaderType shaderType, const std::string& shaderSource, const std::string& header, const std::string& shaderPath); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/interface/Texture.cpp b/source/renderer/hal/interface/Texture.cpp new file mode 100644 index 000000000..313035e83 --- /dev/null +++ b/source/renderer/hal/interface/Texture.cpp @@ -0,0 +1,20 @@ +#include "Texture.hpp" + +using namespace mce; + +Texture::Texture() + : MCE_GFX_CLASS(Texture)() +{ +} + +void Texture::loadMipMap(RenderContext& context, const void* rawTextureData, unsigned int mipMapLevel) +{ + const TextureDescription& description = getDescription(); + createMipMap( + context, + rawTextureData, + description.width >> mipMapLevel, + description.height >> mipMapLevel, + mipMapLevel + ); +} \ No newline at end of file diff --git a/source/renderer/hal/interface/Texture.hpp b/source/renderer/hal/interface/Texture.hpp new file mode 100644 index 000000000..136e1ce84 --- /dev/null +++ b/source/renderer/hal/interface/Texture.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include "RenderContext.hpp" +#include "renderer/PlatformDefinitions.h" +#include MCE_GFX_CLASS_HEADER(Texture) + +namespace mce +{ + class Texture : public MCE_GFX_CLASS(Texture) + { + public: + Texture(); + + public: + void loadMipMap(RenderContext& context, const void* rawTextureData, unsigned int mipMapLevel); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/null/BlendStateNull.cpp b/source/renderer/hal/null/BlendStateNull.cpp new file mode 100644 index 000000000..d18257115 --- /dev/null +++ b/source/renderer/hal/null/BlendStateNull.cpp @@ -0,0 +1,10 @@ +#include + +#include "BlendStateNull.hpp" + +using namespace mce; + +BlendStateNull::BlendStateNull() +{ + m_bEnableBlend = false; +} diff --git a/source/renderer/hal/null/BlendStateNull.hpp b/source/renderer/hal/null/BlendStateNull.hpp new file mode 100644 index 000000000..5c04affec --- /dev/null +++ b/source/renderer/hal/null/BlendStateNull.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include "renderer/hal/base/BlendStateBase.hpp" + +namespace mce +{ + class BlendStateNull : public BlendStateBase + { + public: + bool m_bEnableBlend; + + public: + BlendStateNull(); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/null/BufferNull.cpp b/source/renderer/hal/null/BufferNull.cpp new file mode 100644 index 000000000..62a322e54 --- /dev/null +++ b/source/renderer/hal/null/BufferNull.cpp @@ -0,0 +1,8 @@ +#include "BufferNull.hpp" + +using namespace mce; + +BufferNull::BufferNull() +{ + m_dataSize = 0; +} \ No newline at end of file diff --git a/source/renderer/hal/null/BufferNull.hpp b/source/renderer/hal/null/BufferNull.hpp new file mode 100644 index 000000000..ac579f06d --- /dev/null +++ b/source/renderer/hal/null/BufferNull.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include +#include +#include "renderer/hal/base/BufferBase.hpp" + +namespace mce +{ + class BufferNull : public BufferBase + { + private: + uint64_t m_dataSize; + + public: + BufferNull(); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/null/ConstantBufferContainerNull.cpp b/source/renderer/hal/null/ConstantBufferContainerNull.cpp new file mode 100644 index 000000000..544ce5c17 --- /dev/null +++ b/source/renderer/hal/null/ConstantBufferContainerNull.cpp @@ -0,0 +1,8 @@ +#include "ConstantBufferContainerNull.hpp" + +using namespace mce; + +ConstantBufferContainerNull::ConstantBufferContainerNull() + : ConstantBufferContainerBase() +{ +} \ No newline at end of file diff --git a/source/renderer/hal/null/ConstantBufferContainerNull.hpp b/source/renderer/hal/null/ConstantBufferContainerNull.hpp new file mode 100644 index 000000000..add7d475c --- /dev/null +++ b/source/renderer/hal/null/ConstantBufferContainerNull.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include "renderer/hal/base/ConstantBufferContainerBase.hpp" + +namespace mce +{ + class ConstantBufferContainerNull : public ConstantBufferContainerBase + { + public: + ConstantBufferContainerNull(); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/null/DepthStencilStateNull.cpp b/source/renderer/hal/null/DepthStencilStateNull.cpp new file mode 100644 index 000000000..3130099f7 --- /dev/null +++ b/source/renderer/hal/null/DepthStencilStateNull.cpp @@ -0,0 +1,8 @@ +#include "DepthStencilStateNull.hpp" + +using namespace mce; + +DepthStencilStateNull::DepthStencilStateNull() + : DepthStencilStateBase() +{ +} \ No newline at end of file diff --git a/source/renderer/hal/null/DepthStencilStateNull.hpp b/source/renderer/hal/null/DepthStencilStateNull.hpp new file mode 100644 index 000000000..628a1e376 --- /dev/null +++ b/source/renderer/hal/null/DepthStencilStateNull.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include "renderer/hal/base/DepthStencilStateBase.hpp" + +namespace mce +{ + class DepthStencilStateNull : public DepthStencilStateBase + { + public: + DepthStencilStateNull(); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/null/FixedPipelineStateNull.cpp b/source/renderer/hal/null/FixedPipelineStateNull.cpp new file mode 100644 index 000000000..0dac3ab10 --- /dev/null +++ b/source/renderer/hal/null/FixedPipelineStateNull.cpp @@ -0,0 +1,8 @@ +#include "FixedPipelineStateNull.hpp" + +using namespace mce; + +FixedPipelineStateNull::FixedPipelineStateNull() + : FixedPipelineStateBase() +{ +} \ No newline at end of file diff --git a/source/renderer/hal/null/FixedPipelineStateNull.hpp b/source/renderer/hal/null/FixedPipelineStateNull.hpp new file mode 100644 index 000000000..3a85b18cd --- /dev/null +++ b/source/renderer/hal/null/FixedPipelineStateNull.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include "renderer/hal/base/FixedPipelineStateBase.hpp" + +namespace mce +{ + class FixedPipelineStateNull : public FixedPipelineStateBase + { + public: + FixedPipelineStateNull(); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/null/FogStateNull.cpp b/source/renderer/hal/null/FogStateNull.cpp new file mode 100644 index 000000000..781148006 --- /dev/null +++ b/source/renderer/hal/null/FogStateNull.cpp @@ -0,0 +1,8 @@ +#include "FogStateNull.hpp" + +using namespace mce; + +FogStateNull::FogStateNull() + : FogStateBase() +{ +} \ No newline at end of file diff --git a/source/renderer/hal/null/FogStateNull.hpp b/source/renderer/hal/null/FogStateNull.hpp new file mode 100644 index 000000000..d9418baf5 --- /dev/null +++ b/source/renderer/hal/null/FogStateNull.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include "renderer/hal/base/FogStateBase.hpp" + +namespace mce +{ + class FogStateNull : public FogStateBase + { + public: + FogStateNull(); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/null/ImmediateBufferNull.cpp b/source/renderer/hal/null/ImmediateBufferNull.cpp new file mode 100644 index 000000000..a0836f0ec --- /dev/null +++ b/source/renderer/hal/null/ImmediateBufferNull.cpp @@ -0,0 +1,8 @@ +#include "ImmediateBufferNull.hpp" + +using namespace mce; + +ImmediateBufferNull::ImmediateBufferNull() + : ImmediateBufferBase() +{ +} \ No newline at end of file diff --git a/source/renderer/hal/null/ImmediateBufferNull.hpp b/source/renderer/hal/null/ImmediateBufferNull.hpp new file mode 100644 index 000000000..fbcc7c0c6 --- /dev/null +++ b/source/renderer/hal/null/ImmediateBufferNull.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include "renderer/hal/base/ImmediateBufferBase.hpp" + +namespace mce +{ + class ImmediateBufferNull : public ImmediateBufferBase + { + public: + ImmediateBufferNull(); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/null/RasterizerStateNull.cpp b/source/renderer/hal/null/RasterizerStateNull.cpp new file mode 100644 index 000000000..95872dc8d --- /dev/null +++ b/source/renderer/hal/null/RasterizerStateNull.cpp @@ -0,0 +1,8 @@ +#include "RasterizerStateNull.hpp" + +using namespace mce; + +RasterizerStateNull::RasterizerStateNull() + : RasterizerStateBase() +{ +} \ No newline at end of file diff --git a/source/renderer/hal/null/RasterizerStateNull.hpp b/source/renderer/hal/null/RasterizerStateNull.hpp new file mode 100644 index 000000000..189667b27 --- /dev/null +++ b/source/renderer/hal/null/RasterizerStateNull.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include "renderer/hal/base/RasterizerStateBase.hpp" + +namespace mce +{ + class RasterizerStateNull : public RasterizerStateBase + { + public: + RasterizerStateNull(); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/null/RenderContextNull.cpp b/source/renderer/hal/null/RenderContextNull.cpp new file mode 100644 index 000000000..ce9dd0f2b --- /dev/null +++ b/source/renderer/hal/null/RenderContextNull.cpp @@ -0,0 +1,8 @@ +#include "RenderContextNull.hpp" + +using namespace mce; + +RenderContextNull::RenderContextNull() + : RenderContextBase() +{ +} diff --git a/source/renderer/hal/null/RenderContextNull.hpp b/source/renderer/hal/null/RenderContextNull.hpp new file mode 100644 index 000000000..4d921aec0 --- /dev/null +++ b/source/renderer/hal/null/RenderContextNull.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include "renderer/hal/base/RenderContextBase.hpp" + +namespace mce +{ + class RenderContextNull : public RenderContextBase + { + public: + RenderContextNull(); + }; +} diff --git a/source/renderer/hal/null/RenderDeviceNull.cpp b/source/renderer/hal/null/RenderDeviceNull.cpp new file mode 100644 index 000000000..659b60048 --- /dev/null +++ b/source/renderer/hal/null/RenderDeviceNull.cpp @@ -0,0 +1 @@ +#include "RenderDeviceNull.hpp" \ No newline at end of file diff --git a/source/renderer/hal/null/RenderDeviceNull.hpp b/source/renderer/hal/null/RenderDeviceNull.hpp new file mode 100644 index 000000000..5dbeaab6f --- /dev/null +++ b/source/renderer/hal/null/RenderDeviceNull.hpp @@ -0,0 +1,10 @@ +#pragma once + +#include "renderer/hal/base/RenderDeviceBase.hpp" + +namespace mce +{ + class RenderDeviceNull : public RenderDeviceBase + { + }; +} \ No newline at end of file diff --git a/source/renderer/hal/null/ShaderConstantNull.cpp b/source/renderer/hal/null/ShaderConstantNull.cpp new file mode 100644 index 000000000..c1712c96d --- /dev/null +++ b/source/renderer/hal/null/ShaderConstantNull.cpp @@ -0,0 +1,3 @@ +#include "ShaderConstantNull.hpp" + +using namespace mce; diff --git a/source/renderer/hal/null/ShaderConstantNull.hpp b/source/renderer/hal/null/ShaderConstantNull.hpp new file mode 100644 index 000000000..b57098cea --- /dev/null +++ b/source/renderer/hal/null/ShaderConstantNull.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include "renderer/hal/base/ShaderConstantBase.hpp" + +namespace mce +{ + class ShaderConstantNull : public ShaderConstantBase + { + public: + void syncUniform(int) {} + }; +} \ No newline at end of file diff --git a/source/renderer/hal/null/ShaderConstantWithDataNull.cpp b/source/renderer/hal/null/ShaderConstantWithDataNull.cpp new file mode 100644 index 000000000..4be724579 --- /dev/null +++ b/source/renderer/hal/null/ShaderConstantWithDataNull.cpp @@ -0,0 +1,3 @@ +#include "ShaderConstantWithDataNull.hpp" + +using namespace mce; diff --git a/source/renderer/hal/null/ShaderConstantWithDataNull.hpp b/source/renderer/hal/null/ShaderConstantWithDataNull.hpp new file mode 100644 index 000000000..b84c72038 --- /dev/null +++ b/source/renderer/hal/null/ShaderConstantWithDataNull.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include "renderer/hal/base/ShaderConstantWithDataBase.hpp" + +namespace mce +{ + template + class ShaderConstantWithDataNull : public ShaderConstantWithDataBase + { + public: + ShaderConstantWithDataNull(ShaderPrimitiveTypes primitiveType) + : ShaderConstantWithDataBase(primitiveType) + { + } + + void syncUniform(int value) {}; + }; +} diff --git a/source/renderer/hal/null/ShaderNull.cpp b/source/renderer/hal/null/ShaderNull.cpp new file mode 100644 index 000000000..b0ba83d99 --- /dev/null +++ b/source/renderer/hal/null/ShaderNull.cpp @@ -0,0 +1,8 @@ +#include "ShaderNull.hpp" + +using namespace mce; + +ShaderNull::ShaderNull(ShaderProgram& vertex, ShaderProgram& fragment, ShaderProgram& geometry) + : ShaderBase(vertex, fragment, geometry) +{ +} diff --git a/source/renderer/hal/null/ShaderNull.hpp b/source/renderer/hal/null/ShaderNull.hpp new file mode 100644 index 000000000..ebf6bf16c --- /dev/null +++ b/source/renderer/hal/null/ShaderNull.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include "renderer/hal/base/ShaderBase.hpp" +#include "renderer/hal/interface/ShaderProgram.hpp" + +namespace mce +{ + class ShaderNull : public ShaderBase + { + public: + ShaderNull(ShaderProgram& vertex, ShaderProgram& fragment, ShaderProgram& geometry); + }; +} diff --git a/source/renderer/hal/null/ShaderProgramNull.cpp b/source/renderer/hal/null/ShaderProgramNull.cpp new file mode 100644 index 000000000..aaef77811 --- /dev/null +++ b/source/renderer/hal/null/ShaderProgramNull.cpp @@ -0,0 +1,8 @@ +#include "ShaderProgramNull.hpp" + +using namespace mce; + +ShaderProgramNull::ShaderProgramNull(ShaderType shaderType, const std::string& shaderSource, const std::string& header, const std::string& shaderPath) + : ShaderProgramBase(header, shaderPath, shaderType) +{ +} \ No newline at end of file diff --git a/source/renderer/hal/null/ShaderProgramNull.hpp b/source/renderer/hal/null/ShaderProgramNull.hpp new file mode 100644 index 000000000..5fd494b31 --- /dev/null +++ b/source/renderer/hal/null/ShaderProgramNull.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include "renderer/hal/base/ShaderProgramBase.hpp" + +namespace mce +{ + class ShaderProgramNull : public ShaderProgramBase + { + public: + ShaderProgramNull(ShaderType shaderType, const std::string& shaderSource, const std::string& header, const std::string& shaderPath); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/null/TextureNull.cpp b/source/renderer/hal/null/TextureNull.cpp new file mode 100644 index 000000000..d6d9f394a --- /dev/null +++ b/source/renderer/hal/null/TextureNull.cpp @@ -0,0 +1,8 @@ +#include "TextureNull.hpp" + +using namespace mce; + +TextureNull::TextureNull() + : TextureBase() +{ +} diff --git a/source/renderer/hal/null/TextureNull.hpp b/source/renderer/hal/null/TextureNull.hpp new file mode 100644 index 000000000..2aeb7baab --- /dev/null +++ b/source/renderer/hal/null/TextureNull.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include "renderer/hal/base/TextureBase.hpp" + +namespace mce +{ + class TextureNull : public TextureBase + { + public: + TextureNull(); + }; +} diff --git a/source/renderer/hal/ogl/API_OGL.cpp b/source/renderer/hal/ogl/API_OGL.cpp new file mode 100644 index 000000000..c8f44d8b6 --- /dev/null +++ b/source/renderer/hal/ogl/API_OGL.cpp @@ -0,0 +1,185 @@ +#include "API_OGL.hpp" + +gl::Version* gl::Version::singletonPtr = nullptr; + +const gl::Version& gl::Version::singleton() +{ + if (!gl::Version::singletonPtr) + { + gl::Version* versionPtr = new gl::Version(); + versionPtr->parse(); + gl::Version::singletonPtr = versionPtr; + } + + return *singletonPtr; +} + +void gl::Version::_findMajorMinor() +{ + major = 0; + minor = 0; + core = false; +#ifdef USE_GLES + gles = true; +#else + gles = false; +#endif + + const char* versionString = (const char*)glGetString(GL_VERSION); + if (!versionString) + return; + + char* endPtr; + + major = strtol(versionString, &endPtr, 10); + + if (*endPtr == '.') + minor = strtol(endPtr + 1, nullptr, 10); +} + +void gl::Version::parse() +{ + _findMajorMinor(); + + if (major == 2) + { + featureLevel = GLES_2_0; + } + else if (major >= 3) + { + if (minor == 0) + { + featureLevel = GLES_3_0; + } + else if (minor == 1) + { + featureLevel = GLES_3_1; + } + else if (minor >= 2) + { + featureLevel = GLES_3_2; + } + } +} + +std::string gl::getOpenGLVendor() +{ + static bool fetched = false; + static std::string glVendor; + if (!fetched) + { + const GLubyte* glVendorStr = glGetString(GL_VENDOR); + glVendor = glVendorStr ? std::string((char*)glVendorStr) : ""; + fetched = true; + } + return glVendor; +} + +std::string gl::getOpenGLRenderer() +{ + static bool fetched = false; + static std::string glRenderer; + if (!fetched) + { + const GLubyte* glRendererStr = glGetString(GL_RENDERER); + glRenderer = glRendererStr ? std::string((char*)glRendererStr) : ""; + fetched = true; + } + return glRenderer; +} + +std::string gl::getOpenGLVersion() +{ + static bool fetched = false; + static std::string glVersion; + if (!fetched) + { + const GLubyte* glVersionStr = glGetString(GL_VERSION); + glVersion = glVersionStr ? std::string((char*)glVersionStr) : ""; + fetched = true; + } + return glVersion; +} + +bool gl::isOpenGLES() +{ + const gl::Version& glVersion = gl::Version::singleton(); + + return glVersion.gles; +} + +bool gl::isOpenGLES3() +{ + if (gl::hardwareOverideOpenGLES3) + { + return false; + } + + const gl::Version& glVersion = gl::Version::singleton(); + + return glVersion.gles && glVersion.major >= 3; +} + +int gl::getMaxVertexCount() +{ + static int maxVertexCount = 0; + if (maxVertexCount == 0) + { + if (isOpenGLES3()) + maxVertexCount = -1; + else + maxVertexCount = 0xFFFF; + } + return maxVertexCount; +} + +const std::string& gl::getOpenGLExtensions() +{ + static bool fetched = false; + static std::string glExtensions; + if (!fetched) + { + const GLubyte* glExtensionsStr = glGetString(GL_EXTENSIONS); + glExtensions = glExtensionsStr ? std::string((char*)glExtensionsStr) : ""; + } + return glExtensions; +} + +bool gl::supportsMipmaps() +{ + static int supportsMipmaps = -1; + if (supportsMipmaps < 0) + { + const std::string& glExtensions = gl::getOpenGLExtensions(); + if (isOpenGLES3() || glExtensions.find("GL_APPLE_texture_max_level") != std::string::npos) + supportsMipmaps = 1; + } + return supportsMipmaps == 1; +} + +bool gl::supportsImmediateMode() +{ +#ifndef FEATURE_GFX_SHADERS + return false; +#endif + + static int supportsImmediateMode = -1; + if (supportsImmediateMode < 0) + { + const gl::Version& glVersion = gl::Version::singleton(); + supportsImmediateMode = glVersion.core == false; + } + return supportsImmediateMode == 1; +} + +bool gl::supports32BitIndices() +{ + static int isSupported = -1; + if (isSupported < 0) + { + const std::string& glExtensions = gl::getOpenGLExtensions(); + if (isOpenGLES3() || glExtensions.find("GL_OES_element_index") != std::string::npos) + isSupported = 1; + } + return isSupported == 1; +} diff --git a/source/renderer/hal/ogl/API_OGL.hpp b/source/renderer/hal/ogl/API_OGL.hpp new file mode 100644 index 000000000..a16e0d49c --- /dev/null +++ b/source/renderer/hal/ogl/API_OGL.hpp @@ -0,0 +1,52 @@ +#pragma once + +#include + +#include "thirdparty/GL/GL.hpp" + +// This file is actually titled "gl_header.h", but I like "API_OGL.hpp" better + +namespace gl +{ + class Version + { + public: + enum GL_FEATURE_LEVEL + { + GLES_2_0, + GLES_3_0, + GLES_3_1, + GLES_3_2, + }; + + private: + static Version* singletonPtr; + public: + static const Version& singleton(); + + public: + int major; + int minor; + GL_FEATURE_LEVEL featureLevel; + bool core; + bool gles; + + private: + void _findMajorMinor(); + public: + void parse(); + }; + + static bool hardwareOverideOpenGLES3 = false; + + std::string getOpenGLVendor(); + std::string getOpenGLRenderer(); + std::string getOpenGLVersion(); + bool isOpenGLES(); + bool isOpenGLES3(); + int getMaxVertexCount(); + const std::string& getOpenGLExtensions(); + bool supportsMipmaps(); + bool supportsImmediateMode(); + bool supports32BitIndices(); +} \ No newline at end of file diff --git a/source/renderer/hal/ogl/BlendStateOGL.cpp b/source/renderer/hal/ogl/BlendStateOGL.cpp new file mode 100644 index 000000000..72f0f93ea --- /dev/null +++ b/source/renderer/hal/ogl/BlendStateOGL.cpp @@ -0,0 +1,81 @@ +#include + +#include "BlendStateOGL.hpp" + +using namespace mce; + +BlendStateOGL::BlendStateOGL() +{ + m_bBlend = false; + m_bRed = true; + m_bGreen = true; + m_bBlue = true; + m_bAlpha = true; + m_sfactor = GL_NONE; + m_dfactor = GL_NONE; +} + +GLenum BlendStateOGL::translateBlendFunc(BlendTarget blendTarget) +{ + switch (blendTarget) + { + case BLEND_TARGET_DEST_COLOR: return GL_DST_COLOR; + case BLEND_TARGET_SOURCE_COLOR: return GL_SRC_COLOR; + case BLEND_TARGET_ZERO: return GL_ZERO; + case BLEND_TARGET_ONE: return GL_ONE; + case BLEND_TARGET_ONE_MINUS_DEST_COLOR: return GL_ONE_MINUS_DST_COLOR; + case BLEND_TARGET_ONE_MINUS_SRC_COLOR: return GL_ONE_MINUS_SRC_COLOR; + case BLEND_TARGET_SOURCE_ALPHA: return GL_SRC_ALPHA; + case BLEND_TARGET_DEST_ALPHA: return GL_DST_ALPHA; + case BLEND_TARGET_ONE_MINUS_SRC_ALPHA: return GL_ONE_MINUS_SRC_ALPHA; + default: + LOG_E("Unknown blendFunc: %d", blendTarget); + throw std::bad_cast(); + } +} + +void BlendStateOGL::createBlendState(RenderContext& context, const BlendStateDescription& desc) +{ + BlendStateBase::createBlendState(context, desc); + m_bBlend = desc.enableBlend; + m_bRed = (desc.colorWriteMask & 1) != 0; + m_bGreen = (desc.colorWriteMask & 2) != 0; + m_bBlue = (desc.colorWriteMask & 4) != 0; + m_bAlpha = (desc.colorWriteMask & 8) != 0; + m_sfactor = translateBlendFunc(desc.blendSource); + m_dfactor = translateBlendFunc(desc.blendDestination); + + if (!context.m_currentState.m_bBoundBlendState) + { + bindBlendState(context, true); + context.m_currentState.m_bBoundBlendState = true; + context.m_currentState.m_blendStateDescription = desc; + } +} + +bool BlendStateOGL::bindBlendState(RenderContext& context, bool forceBind) +{ + BlendStateDescription& ctxDesc = context.m_currentState.m_blendStateDescription; + + if (forceBind || ctxDesc.enableBlend != m_description.enableBlend) + { + if (m_bBlend) glEnable(GL_BLEND); + else glDisable(GL_BLEND); + ctxDesc.enableBlend = m_description.enableBlend; + } + + if (forceBind || ctxDesc.colorWriteMask != m_description.colorWriteMask) + { + glColorMask(m_bRed, m_bGreen, m_bBlue, m_bAlpha); + ctxDesc.colorWriteMask = m_description.colorWriteMask; + } + + if (forceBind || ctxDesc.blendSource != m_description.blendSource || ctxDesc.blendDestination != m_description.blendDestination) + { + glBlendFunc(m_sfactor, m_dfactor); + ctxDesc.blendSource = m_description.blendSource; + ctxDesc.blendDestination = m_description.blendDestination; + } + + return BlendStateBase::bindBlendState(context); +} \ No newline at end of file diff --git a/source/renderer/hal/ogl/BlendStateOGL.hpp b/source/renderer/hal/ogl/BlendStateOGL.hpp new file mode 100644 index 000000000..6697cf33f --- /dev/null +++ b/source/renderer/hal/ogl/BlendStateOGL.hpp @@ -0,0 +1,28 @@ +#pragma once + +#include "API_OGL.hpp" +#include "renderer/hal/base/BlendStateBase.hpp" + +namespace mce +{ + class BlendStateOGL : public BlendStateBase + { + public: + bool m_bBlend; + bool m_bRed; + bool m_bGreen; + bool m_bBlue; + bool m_bAlpha; + GLenum m_sfactor; + GLenum m_dfactor; + + public: + BlendStateOGL(); + + public: + GLenum translateBlendFunc(BlendTarget blendTarget); + + void createBlendState(RenderContext& context, const BlendStateDescription& desc); + bool bindBlendState(RenderContext& context, bool forceBind = false); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/ogl/BufferOGL.cpp b/source/renderer/hal/ogl/BufferOGL.cpp new file mode 100644 index 000000000..64a5bc601 --- /dev/null +++ b/source/renderer/hal/ogl/BufferOGL.cpp @@ -0,0 +1,143 @@ +#include +#include "BufferOGL.hpp" +#include "common/Logger.hpp" +#include "renderer/hal/helpers/ErrorHandler.hpp" +#include "renderer/hal/interface/RenderContext.hpp" + +using namespace mce; + +GLenum mce::glTargetFromBufferType(BufferType bufferType) +{ + switch (bufferType) + { + case BUFFER_TYPE_VERTEX: + return GL_ARRAY_BUFFER; + case BUFFER_TYPE_INDEX: + return GL_ELEMENT_ARRAY_BUFFER; + default: + LOG_E("Unknown bufferType: %d", bufferType); + throw std::bad_cast(); + } +} + +BufferOGL::BufferOGL() +{ + m_bufferName = GL_NONE; + m_target = GL_NONE; + m_usage = GL_STATIC_DRAW; +} + +BufferOGL::~BufferOGL() +{ + releaseBuffer(); +} + +void BufferOGL::_createBuffer(RenderContext& context, unsigned int stride, const void* data, unsigned int count, BufferType bufferType) +{ + ErrorHandler::checkForErrors(); + + m_target = mce::glTargetFromBufferType(bufferType); + + xglGenBuffers(1, &m_bufferName); + xglBindBuffer(m_target, m_bufferName); + + // Set active buffer + GLuint& activeBuffer = context.getActiveBuffer(m_bufferType); + activeBuffer = m_bufferName; + + xglBufferData(m_target, m_internalSize, data, m_usage); + + ErrorHandler::checkForErrors(); +} + +void BufferOGL::_move(BufferOGL& other) +{ + if (this != &other) + { + this->releaseBuffer(); + + this->m_target = other.m_target; + this->m_bufferName = other.m_bufferName; + this->m_usage = other.m_usage; + + other.m_bufferName = GL_NONE; + other.m_target = GL_NONE; + other.m_usage = GL_NONE; + } + + BufferBase::_move(other); +} + +void BufferOGL::releaseBuffer() +{ + if (isValid()) + xglDeleteBuffers(1, &m_bufferName); + + m_bufferName = GL_NONE; + m_target = GL_NONE; + + BufferBase::releaseBuffer(); +} + +void BufferOGL::bindBuffer(RenderContext& context) +{ + GLuint& activeBuffer = context.getActiveBuffer(m_bufferType); + if (activeBuffer == m_bufferName) + return; + + xglBindBuffer(m_target, m_bufferName); + activeBuffer = m_bufferName; +} + +void BufferOGL::createBuffer(RenderContext& context, unsigned int stride, const void *data, unsigned int count, BufferType bufferType) +{ + BufferBase::createBuffer(context, stride, data, count, bufferType); + + m_usage = GL_STATIC_DRAW; + _createBuffer(context, stride, data, count, bufferType); +} + +void BufferOGL::createDynamicBuffer(RenderContext& context, unsigned int stride, const void* data, unsigned int count, BufferType bufferType) +{ + BufferBase::createDynamicBuffer(context, stride, data, count, bufferType); + + // Mojang used GL_STREAM_DRAW in 0.16.1, and GL_STATIC_DRAW in 0.12.1 +#ifdef GL_STREAM_DRAW + m_usage = GL_STREAM_DRAW; +#else // GLES 1 + m_usage = GL_DYNAMIC_DRAW; +#endif + _createBuffer(context, stride, data, count, bufferType); +} + +void BufferOGL::resizeBuffer(RenderContext& context, const void* data, unsigned int size) +{ + xglBufferData(m_target, size, data, m_usage); + m_internalSize = size; +} + +void BufferOGL::updateBuffer(RenderContext& context, unsigned int stride, void*& data, unsigned int count) +{ + bindBuffer(context); + + // https://community.khronos.org/t/vbo-test-glbufferdata-vs-glbuffersubdata-vs-glmapbufferoes/2748 + // Summary: Calling glBufferData is significantly faster than calling glBufferSubData + // because whoever did the GLES 1 implementation at Apple is retarded. + // This may be fixed by acquiring a GLES 2 context, but doing that causes nothing to + // to be rendered, so perhaps some day... + // Additionally, we could try holding the vertex buffer data in memory and pass + // it in the draw call, as supposedly not even using buffers is faster. + bool useAppleWorkaround = false; +#if MC_PLATFORM_IOS + useAppleWorkaround = true; +#endif + + const unsigned int size = count * stride; + + if (!useAppleWorkaround && size <= m_internalSize) + xglBufferSubData(m_target, m_bufferOffset, size, data); + else + resizeBuffer(context, data, size); + + BufferBase::updateBuffer(context, stride, data, count); +} \ No newline at end of file diff --git a/source/renderer/hal/ogl/BufferOGL.hpp b/source/renderer/hal/ogl/BufferOGL.hpp new file mode 100644 index 000000000..c2dc4790b --- /dev/null +++ b/source/renderer/hal/ogl/BufferOGL.hpp @@ -0,0 +1,37 @@ +#pragma once + +#include "API_OGL.hpp" +#include "renderer/hal/base/BufferBase.hpp" + +namespace mce +{ + GLenum glTargetFromBufferType(BufferType bufferType); + + class BufferOGL : public BufferBase + { + protected: + GLuint m_bufferName; + GLenum m_target; + GLenum m_usage; + + public: + BufferOGL(); + MC_CTOR_MOVE(BufferOGL); + ~BufferOGL(); + + protected: + void _createBuffer(RenderContext& context, unsigned int stride, const void* data, unsigned int count, BufferType bufferType); + + public: + void _move(BufferOGL& other); + void releaseBuffer(); + void bindBuffer(RenderContext& context); + void createBuffer(RenderContext& context, unsigned int stride, const void *data, unsigned int count, BufferType bufferType); + void createDynamicBuffer(RenderContext& context, unsigned int stride, const void* data, unsigned int count, BufferType bufferType); + void resizeBuffer(RenderContext& context, const void* data, unsigned int size); + void updateBuffer(RenderContext& context, unsigned int stride, void*& data, unsigned int count); + bool isValid() const { return m_bufferName != GL_NONE; } + + MC_FUNC_MOVE(BufferOGL); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/ogl/ConstantBufferContainerOGL.cpp b/source/renderer/hal/ogl/ConstantBufferContainerOGL.cpp new file mode 100644 index 000000000..51976c535 --- /dev/null +++ b/source/renderer/hal/ogl/ConstantBufferContainerOGL.cpp @@ -0,0 +1,13 @@ +#include "ConstantBufferContainerOGL.hpp" + +using namespace mce; + +ConstantBufferContainerOGL::ConstantBufferContainerOGL() + : ConstantBufferContainerBase() +{ +} + +void ConstantBufferContainerOGL::sync(RenderContext& context) +{ + +} \ No newline at end of file diff --git a/source/renderer/hal/ogl/ConstantBufferContainerOGL.hpp b/source/renderer/hal/ogl/ConstantBufferContainerOGL.hpp new file mode 100644 index 000000000..0cbbab2f4 --- /dev/null +++ b/source/renderer/hal/ogl/ConstantBufferContainerOGL.hpp @@ -0,0 +1,14 @@ +#pragma once + +#include "renderer/hal/base/ConstantBufferContainerBase.hpp" + +namespace mce +{ + class ConstantBufferContainerOGL : public ConstantBufferContainerBase + { + public: + ConstantBufferContainerOGL(); + + void sync(RenderContext& context); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/ogl/DepthStencilStateOGL.cpp b/source/renderer/hal/ogl/DepthStencilStateOGL.cpp new file mode 100644 index 000000000..9c36e1d99 --- /dev/null +++ b/source/renderer/hal/ogl/DepthStencilStateOGL.cpp @@ -0,0 +1,165 @@ +#include "DepthStencilStateOGL.hpp" + +using namespace mce; + +DepthStencilStateOGL::DepthStencilStateOGL() + : DepthStencilStateBase() +{ + m_depthWriteMask = DEPTH_WRITE_MASK_ALL; + m_depthFunc = GL_NONE; + m_stencilReadMask = 0; + m_stencilWriteMask = 0; +} + +GLenum getStencilOpAction(StencilOp stencilOp) +{ + switch (stencilOp) + { + case STENCIL_OP_KEEP: return GL_KEEP; + case STENCIL_OP_REPLACE: return GL_REPLACE; + default: + LOG_E("Unknown stencilOp: %d", stencilOp); + throw std::bad_cast(); + } +} + +void DepthStencilStateOGL::createDepthState(RenderContext& context, const DepthStencilStateDescription& description) +{ + *this = DepthStencilStateOGL(); + DepthStencilStateBase::createDepthState(context, description); + + m_depthFunc = getComparisonFunc(description.depthFunc); + + m_frontFaceStencilInfo.func = getComparisonFunc(description.frontFace.stencilFunc); + m_frontFaceStencilInfo.stencilFailAction = getStencilOpAction(description.frontFace.stencilFailOp); + m_frontFaceStencilInfo.stencilPassDepthFailAction = getStencilOpAction(description.frontFace.stencilDepthFailOp); + m_frontFaceStencilInfo.stencilPassDepthPassAction = getStencilOpAction(description.frontFace.stencilPassOp); + + m_backFaceStencilInfo.func = getComparisonFunc(description.backFace.stencilFunc); + m_backFaceStencilInfo.stencilFailAction = getStencilOpAction(description.backFace.stencilFailOp); + m_backFaceStencilInfo.stencilPassDepthFailAction = getStencilOpAction(description.backFace.stencilDepthFailOp); + m_backFaceStencilInfo.stencilPassDepthPassAction = getStencilOpAction(description.backFace.stencilPassOp); + + m_depthWriteMask = description.depthWriteMask; + m_stencilReadMask = description.stencilReadMask; + m_stencilWriteMask = description.stencilWriteMask; + + if (!context.m_currentState.m_bBoundDepthStencilState) + { + bindDepthStencilState(context, true); + context.m_currentState.m_depthStencilStateDescription.depthTestEnabled = description.depthTestEnabled; + context.m_currentState.m_depthStencilStateDescription.frontFace.stencilDepthFailOp = description.frontFace.stencilDepthFailOp; + context.m_currentState.m_depthStencilStateDescription.backFace.stencilDepthFailOp = description.backFace.stencilDepthFailOp; + context.m_currentState.m_depthStencilStateDescription.stencilReadMask = description.stencilReadMask; + context.m_currentState.m_depthStencilStateDescription.stencilWriteMask = description.stencilWriteMask; + context.m_currentState.m_depthStencilStateDescription.stencilRef = description.stencilRef; + context.m_currentState.m_depthStencilStateDescription.overwroteStencilRef = description.overwroteStencilRef; + context.m_currentState.m_bBoundDepthStencilState = true; + } +} + +bool DepthStencilStateOGL::bindDepthStencilState(RenderContext& context, bool force) +{ + if (!m_description.overwroteStencilRef) + { + m_description.stencilRef = context.getStencilReference(); + } + + DepthStencilStateDescription& currentDesc = context.m_currentState.m_depthStencilStateDescription; + + if (force || currentDesc.depthTestEnabled != m_description.depthTestEnabled) + { + if (m_description.depthTestEnabled) + glEnable(GL_DEPTH_TEST); + else + glDisable(GL_DEPTH_TEST); + + currentDesc.depthTestEnabled = m_description.depthTestEnabled; + } + + if (force || currentDesc.stencilTestEnabled != m_description.stencilTestEnabled) + { + if (m_description.stencilTestEnabled) + glEnable(GL_STENCIL_TEST); + else + glDisable(GL_STENCIL_TEST); + + currentDesc.stencilTestEnabled = m_description.stencilTestEnabled; + } + + if (force + || currentDesc.frontFace.stencilFunc != m_description.frontFace.stencilFunc + || currentDesc.backFace.stencilFunc != m_description.backFace.stencilFunc + || currentDesc.stencilReadMask != m_description.stencilReadMask + || currentDesc.stencilRef != m_description.stencilRef) + { +#ifdef USE_GL_STENCIL_SEPARATE + xglStencilFuncSeparate(GL_FRONT, m_frontFaceStencilInfo.func, m_description.stencilRef, m_stencilReadMask); + xglStencilFuncSeparate(GL_BACK, m_backFaceStencilInfo.func, m_description.stencilRef, m_stencilReadMask); +#else + // This shit's running on thoughts and prayers + glStencilFunc(m_frontFaceStencilInfo.func, m_description.stencilRef, m_stencilReadMask); +#endif + + currentDesc.frontFace.stencilFunc = m_description.frontFace.stencilFunc; + currentDesc.backFace.stencilFunc = m_description.backFace.stencilFunc; + currentDesc.stencilReadMask = m_description.stencilReadMask; + currentDesc.stencilRef = m_description.stencilRef; + } + +#ifdef USE_GL_STENCIL_SEPARATE + if (force || currentDesc.frontFace.stencilDepthFailOp != m_description.frontFace.stencilDepthFailOp) + { + xglStencilOpSeparate(GL_FRONT, m_frontFaceStencilInfo.stencilFailAction, m_frontFaceStencilInfo.stencilPassDepthFailAction, m_frontFaceStencilInfo.stencilPassDepthPassAction); + currentDesc.frontFace.stencilDepthFailOp = m_description.frontFace.stencilDepthFailOp; + currentDesc.frontFace.stencilPassOp = m_description.frontFace.stencilPassOp; + currentDesc.frontFace.stencilFailOp = m_description.frontFace.stencilFailOp; + } + + if (force || currentDesc.backFace.stencilDepthFailOp != m_description.backFace.stencilDepthFailOp) + { + xglStencilOpSeparate(GL_BACK, m_backFaceStencilInfo.stencilFailAction, m_backFaceStencilInfo.stencilPassDepthFailAction, m_backFaceStencilInfo.stencilPassDepthPassAction); + currentDesc.backFace.stencilDepthFailOp = m_description.backFace.stencilDepthFailOp; + currentDesc.backFace.stencilPassOp = m_description.backFace.stencilPassOp; + currentDesc.backFace.stencilFailOp = m_description.backFace.stencilFailOp; + } +#else + if (force || currentDesc.frontFace.stencilDepthFailOp != m_description.frontFace.stencilDepthFailOp + || currentDesc.backFace.stencilDepthFailOp != m_description.backFace.stencilDepthFailOp) + { + // and this shit's running on hopes and dreams + glStencilOp(m_frontFaceStencilInfo.stencilFailAction, m_frontFaceStencilInfo.stencilPassDepthFailAction, m_frontFaceStencilInfo.stencilPassDepthPassAction); + + currentDesc.frontFace.stencilDepthFailOp = m_description.frontFace.stencilDepthFailOp; + currentDesc.frontFace.stencilPassOp = m_description.frontFace.stencilPassOp; + currentDesc.frontFace.stencilFailOp = m_description.frontFace.stencilFailOp; + + currentDesc.backFace.stencilDepthFailOp = m_description.backFace.stencilDepthFailOp; + currentDesc.backFace.stencilPassOp = m_description.backFace.stencilPassOp; + currentDesc.backFace.stencilFailOp = m_description.backFace.stencilFailOp; + } +#endif + + if (force || currentDesc.stencilWriteMask != m_description.stencilWriteMask) + { + glStencilMask(m_stencilWriteMask); + currentDesc.stencilWriteMask = m_description.stencilWriteMask; + } + + if (force || currentDesc.depthFunc != m_description.depthFunc) + { + glDepthFunc(m_depthFunc); + currentDesc.depthFunc = m_description.depthFunc; + } + + if (force || currentDesc.depthWriteMask != m_description.depthWriteMask) + { + glDepthMask(m_depthWriteMask); + currentDesc.depthWriteMask = m_description.depthWriteMask; + } + + currentDesc.overwroteStencilRef = m_description.overwroteStencilRef; + + + return DepthStencilStateBase::bindDepthStencilState(context); +} \ No newline at end of file diff --git a/source/renderer/hal/ogl/DepthStencilStateOGL.hpp b/source/renderer/hal/ogl/DepthStencilStateOGL.hpp new file mode 100644 index 000000000..bc1148602 --- /dev/null +++ b/source/renderer/hal/ogl/DepthStencilStateOGL.hpp @@ -0,0 +1,42 @@ +#pragma once + +#include "API_OGL.hpp" +#include "renderer/hal/base/DepthStencilStateBase.hpp" + +namespace mce +{ + class DepthStencilStateOGL : public DepthStencilStateBase + { + private: + struct StencilFaceDescriptionOGL + { + GLenum func; + GLenum stencilFailAction; + GLenum stencilPassDepthFailAction; + GLenum stencilPassDepthPassAction; + + StencilFaceDescriptionOGL() + { + func = GL_NONE; + stencilFailAction = GL_NONE; + stencilPassDepthFailAction = GL_NONE; + stencilPassDepthPassAction = GL_NONE; + } + }; + + private: + GLenum m_depthFunc; + StencilFaceDescriptionOGL m_frontFaceStencilInfo; + StencilFaceDescriptionOGL m_backFaceStencilInfo; + GLuint m_stencilReadMask; + GLuint m_stencilWriteMask; + uint8_t m_depthWriteMask; + + public: + DepthStencilStateOGL(); + + public: + void createDepthState(RenderContext& context, const DepthStencilStateDescription& description); + bool bindDepthStencilState(RenderContext& context, bool force = false); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/ogl/FixedPipelineStateOGL.cpp b/source/renderer/hal/ogl/FixedPipelineStateOGL.cpp new file mode 100644 index 000000000..a7cd5aaea --- /dev/null +++ b/source/renderer/hal/ogl/FixedPipelineStateOGL.cpp @@ -0,0 +1,55 @@ +#include "FixedPipelineStateOGL.hpp" + +using namespace mce; + +FixedPipelineStateOGL::FixedPipelineStateOGL() +{ + m_bAlphaTest = false; + m_alphaFunc = GL_NONE; + m_alphaRef = 0.0f; + m_bTexture = false; +} + +void FixedPipelineStateOGL::createFixedPipelineState(RenderContext& context, const FixedPipelineStateDescription& desc) +{ + FixedPipelineStateBase::createFixedPipelineState(context, desc); + m_bAlphaTest = desc.enableAlphaTest; + m_alphaFunc = getComparisonFunc(desc.alphaFunc); + m_alphaRef = desc.alphaRef; + m_bTexture = desc.enableTexture; + + if (!context.m_currentState.m_bBoundFixedPipelineState) + { + bindFixedPipelineState(context, true); + context.m_currentState.m_bBoundFixedPipelineState = true; + context.m_currentState.m_fixedPipelineStateDescription = desc; + } +} + +bool FixedPipelineStateOGL::bindFixedPipelineState(RenderContext& context, bool forceBind) +{ + FixedPipelineStateDescription& ctxDesc = context.m_currentState.m_fixedPipelineStateDescription; + + if (forceBind || ctxDesc.enableAlphaTest != m_description.enableAlphaTest) + { + if (m_bAlphaTest) glEnable(GL_ALPHA_TEST); + else glDisable(GL_ALPHA_TEST); + ctxDesc.enableAlphaTest = m_description.enableAlphaTest; + } + + if (forceBind || ctxDesc.alphaFunc != m_description.alphaFunc) + { + glAlphaFunc(m_alphaFunc, m_alphaRef); + ctxDesc.alphaFunc = m_description.alphaFunc; + ctxDesc.alphaRef = m_description.alphaRef; + } + + if (forceBind || ctxDesc.enableTexture != m_description.enableTexture) + { + if (m_bTexture) glEnable(GL_TEXTURE_2D); + else glDisable(GL_TEXTURE_2D); + ctxDesc.enableTexture = m_description.enableTexture; + } + + return FixedPipelineStateBase::bindFixedPipelineState(context); +} \ No newline at end of file diff --git a/source/renderer/hal/ogl/FixedPipelineStateOGL.hpp b/source/renderer/hal/ogl/FixedPipelineStateOGL.hpp new file mode 100644 index 000000000..88af69af2 --- /dev/null +++ b/source/renderer/hal/ogl/FixedPipelineStateOGL.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include "API_OGL.hpp" +#include "renderer/hal/base/FixedPipelineStateBase.hpp" + +namespace mce +{ + class FixedPipelineStateOGL : public FixedPipelineStateBase + { + public: + bool m_bAlphaTest; + GLenum m_alphaFunc; + float m_alphaRef; + bool m_bTexture; + + public: + FixedPipelineStateOGL(); + + public: + void createFixedPipelineState(RenderContext& context, const FixedPipelineStateDescription& desc); + bool bindFixedPipelineState(RenderContext& context, bool forceBind = false); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/ogl/FogStateOGL.cpp b/source/renderer/hal/ogl/FogStateOGL.cpp new file mode 100644 index 000000000..644983c26 --- /dev/null +++ b/source/renderer/hal/ogl/FogStateOGL.cpp @@ -0,0 +1,103 @@ +#include + +#include "FogStateOGL.hpp" + +using namespace mce; + +FogStateOGL::FogStateOGL() +{ + m_bFog = false; + m_fogDensity = 1.0f; + m_fogStart = 0.0f; + m_fogEnd = 1.0f; + m_fogMode = GL_EXP; +} + +GLenum FogStateOGL::translateFogMode(FogMode fogMode) +{ + switch (fogMode) + { + case FOG_MODE_LINEAR: return GL_LINEAR; + case FOG_MODE_EXP: return GL_EXP; + case FOG_MODE_EXP2: return GL_EXP2; + default: + LOG_E("Unknown fogMode: %d", fogMode); + throw std::bad_cast(); + } +} + +void FogStateOGL::createFogState(RenderContext& context, const FogStateDescription& desc) +{ + FogStateBase::createFogState(context, desc); + + m_bFog = desc.enableFog; + m_fogMode = translateFogMode(desc.fogMode); + m_fogDensity = desc.fogDensity; + m_fogStart = desc.fogStartZ; + m_fogEnd = desc.fogEndZ; + m_fogColor = desc.fogColor; + + if (!context.m_currentState.m_bBoundFogState) + { + bindFogState(context, true); + context.m_currentState.m_bBoundFogState = true; + context.m_currentState.m_fogStateDescription = desc; + } +} + +bool FogStateOGL::bindFogState(RenderContext& context, bool forceBind) +{ + FogStateDescription& ctxDesc = context.m_currentState.m_fogStateDescription; + +#ifndef __EMSCRIPTEN__ + glNormal3f(0.0f, -1.0f, 0.0f); +#endif + + if (forceBind || ctxDesc.enableFog != m_description.enableFog) + { + if (m_bFog) glEnable(GL_FOG); + else glDisable(GL_FOG); + ctxDesc.enableFog = m_description.enableFog; + } + + if (forceBind || ctxDesc.fogMode != m_description.fogMode) + { +#ifdef ANDROID + glFogx(GL_FOG_MODE, m_fogMode); +#else + glFogi(GL_FOG_MODE, m_fogMode); +#endif + ctxDesc.fogMode = m_description.fogMode; + } + + if (forceBind || ctxDesc.fogDensity != m_description.fogDensity) + { + glFogf(GL_FOG_DENSITY, m_fogDensity); + ctxDesc.fogDensity = m_description.fogDensity; + } + + if (forceBind || ctxDesc.fogStartZ != m_description.fogStartZ) + { + glFogf(GL_FOG_START, m_fogStart); + ctxDesc.fogStartZ = m_description.fogStartZ; + } + + if (forceBind || ctxDesc.fogEndZ != m_description.fogEndZ) + { + glFogf(GL_FOG_END, m_fogEnd); + ctxDesc.fogEndZ = m_description.fogEndZ; + } + + if (forceBind || ctxDesc.fogColor != m_description.fogColor) + { + glFogfv(GL_FOG_COLOR, (float*)&m_fogColor); + ctxDesc.fogColor = m_description.fogColor; + } + +#if !defined(__EMSCRIPTEN__) && !defined(USE_GLES) + glEnable(GL_COLOR_MATERIAL); + glColorMaterial(GL_FRONT, GL_AMBIENT); +#endif + + return FogStateBase::bindFogState(context); +} \ No newline at end of file diff --git a/source/renderer/hal/ogl/FogStateOGL.hpp b/source/renderer/hal/ogl/FogStateOGL.hpp new file mode 100644 index 000000000..acca22b15 --- /dev/null +++ b/source/renderer/hal/ogl/FogStateOGL.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include "API_OGL.hpp" +#include "renderer/hal/base/FogStateBase.hpp" + +namespace mce +{ + class FogStateOGL : public FogStateBase + { + public: + bool m_bFog; + GLenum m_fogMode; + float m_fogDensity; + float m_fogStart; + float m_fogEnd; + Color m_fogColor; + + public: + FogStateOGL(); + + public: + GLenum translateFogMode(FogMode fogMode); + + void createFogState(RenderContext& context, const FogStateDescription& desc); + bool bindFogState(RenderContext& context, bool forceBind = false); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/ogl/GPUEventsOGL.cpp b/source/renderer/hal/ogl/GPUEventsOGL.cpp new file mode 100644 index 000000000..fe25db9f6 --- /dev/null +++ b/source/renderer/hal/ogl/GPUEventsOGL.cpp @@ -0,0 +1,13 @@ +#include "GPUEventsOGL.hpp" + +using namespace mce; + +void GPUEventsOGL::beginProfileSection(char const* field_0) +{ + +} + +void GPUEventsOGL::endProfileEvent() +{ + +} \ No newline at end of file diff --git a/source/renderer/hal/ogl/GPUEventsOGL.hpp b/source/renderer/hal/ogl/GPUEventsOGL.hpp new file mode 100644 index 000000000..fa3fc3f9c --- /dev/null +++ b/source/renderer/hal/ogl/GPUEventsOGL.hpp @@ -0,0 +1,11 @@ +#pragma once + +namespace mce +{ + class GPUEventsOGL + { + public: + void beginProfileSection(char const*); + void endProfileEvent(); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/ogl/ImmediateBufferOGL.cpp b/source/renderer/hal/ogl/ImmediateBufferOGL.cpp new file mode 100644 index 000000000..df803cfa1 --- /dev/null +++ b/source/renderer/hal/ogl/ImmediateBufferOGL.cpp @@ -0,0 +1,62 @@ +#include + +#include "ImmediateBufferOGL.hpp" +#include "renderer/hal/interface/RenderContext.hpp" +#include "BufferOGL.hpp" + +using namespace mce; + +ImmediateBufferOGL::ImmediateBufferOGL() + : ImmediateBufferBase() +{ +} + +void ImmediateBufferOGL::createDynamicBuffer(RenderContext& context, unsigned int stride, const void* data, unsigned int count, BufferType bufferType) +{ + if (gl::supportsImmediateMode()) + { + BufferBase::createDynamicBuffer(context, stride, data, count, bufferType); + m_target = glTargetFromBufferType(bufferType); + } + else + { + BufferOGL::createDynamicBuffer(context, stride, data, count, bufferType); + } +} + +void ImmediateBufferOGL::updateBuffer(RenderContext& context, unsigned int stride, void*& data, unsigned int count) +{ + if (gl::supportsImmediateMode()) + { + // This is not what immediate mode is, and we should not be using buffer 0, it's reserved + // Not sure what Mojang was doing here + xglBindBuffer(m_target, GL_NONE); + GLuint& activeBuffer = context.getActiveBuffer(m_bufferType); + activeBuffer = GL_NONE; + + // @0.16.1: set *(context + 0x164) to 0 + /*if (m_bufferType == BUFFER_TYPE_INDEX) + *&context->m_activeTextureUnits[1].m_bIsShaderUniformDirty = 0;*/ + } + else + { + BufferOGL::updateBuffer(context, stride, data, count); + /* @0.16.1: Unnecessary, Tessellator only did the following to allow for non-temporary buffers + // More or less doing what the Tessellator did with the VBOs array + // except we're using one contiguous OGL buffer + unsigned int nextBufferOffset = m_bufferOffset + (count * stride); + if (nextBufferOffset > getInternalBufferSize()) + { + m_bufferOffset = 0; + } + BufferOGL::updateBuffer(context, stride, data, count); + data = (void*)m_bufferOffset; + m_bufferOffset += count * stride; + */ + } +} + +bool ImmediateBufferOGL::isValid() const +{ + return m_target != GL_NONE; +} \ No newline at end of file diff --git a/source/renderer/hal/ogl/ImmediateBufferOGL.hpp b/source/renderer/hal/ogl/ImmediateBufferOGL.hpp new file mode 100644 index 000000000..bb8dba0b9 --- /dev/null +++ b/source/renderer/hal/ogl/ImmediateBufferOGL.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include "API_OGL.hpp" +#include "renderer/hal/base/ImmediateBufferBase.hpp" +#include "BufferOGL.hpp" + +namespace mce +{ + class ImmediateBufferOGL : public ImmediateBufferBase, public BufferOGL + { + public: + ImmediateBufferOGL(); + + void createDynamicBuffer(RenderContext& context, unsigned int stride, const void* data, unsigned int count, BufferType bufferType); + void updateBuffer(RenderContext& context, unsigned int stride, void*& data, unsigned int count); + + bool isValid() const; + }; +} \ No newline at end of file diff --git a/source/renderer/hal/ogl/ProfileSectionOGL.cpp b/source/renderer/hal/ogl/ProfileSectionOGL.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/source/renderer/hal/ogl/ProfileSectionOGL.hpp b/source/renderer/hal/ogl/ProfileSectionOGL.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/source/renderer/hal/ogl/RasterizerStateOGL.cpp b/source/renderer/hal/ogl/RasterizerStateOGL.cpp new file mode 100644 index 000000000..392035882 --- /dev/null +++ b/source/renderer/hal/ogl/RasterizerStateOGL.cpp @@ -0,0 +1,96 @@ +#include +#include "RasterizerStateOGL.hpp" + +using namespace mce; + +RasterizerStateOGL::RasterizerStateOGL() + : RasterizerStateBase() +{ + m_cullMode = true; + m_depthBias = 0.0f; + m_cullFace = GL_NONE; + m_enableScissorTest = false; +} + +bool RasterizerStateOGL::bindRasterizerState(RenderContext& context, bool forceBind) +{ + RasterizerStateDescription& ctxDesc = context.m_currentState.m_rasterizerStateDescription; + + if (forceBind || ctxDesc.cullMode != m_description.cullMode) + { + if (m_cullMode) + { + glEnable(GL_CULL_FACE); + glCullFace(m_cullFace); + } + else + { + glDisable(GL_CULL_FACE); + } + ctxDesc.cullMode = m_description.cullMode; + } + + if (forceBind || ctxDesc.enableScissorTest != m_description.enableScissorTest) + { + if (m_enableScissorTest) + { + glEnable(GL_SCISSOR_TEST); + } + else + { + glDisable(GL_SCISSOR_TEST); + } + ctxDesc.enableScissorTest = m_description.enableScissorTest; + } + + if (forceBind || ctxDesc.depthBias != m_description.depthBias) + { + if (m_depthBias == 0.0f) + { + glDisable(GL_POLYGON_OFFSET_FILL); + } + else + { + glEnable(GL_POLYGON_OFFSET_FILL); + } + glPolygonOffset(m_depthBias * 5.0f, m_depthBias * 5.0f); + ctxDesc.depthBias = m_description.depthBias; + } + + return RasterizerStateBase::bindRasterizerState(context); +} + +void RasterizerStateOGL::createRasterizerStateDescription(RenderContext& context, const RasterizerStateDescription& desc) +{ + RasterizerStateBase::createRasterizerStateDescription(context, desc); + m_enableScissorTest = desc.enableScissorTest; + m_cullMode = desc.cullMode != CULL_NONE ? true : false; + switch (desc.cullMode) + { + case CULL_NONE: + break; + case CULL_FRONT: + m_cullFace = GL_FRONT; + break; + case CULL_BACK: + m_cullFace = GL_BACK; + break; + default: + LOG_E("Unknown cullMode: %d", desc.cullMode); + throw std::bad_cast(); + } + + m_depthBias = desc.depthBias; + if ( !context.m_currentState.m_bBoundRasterizerState ) + { + bindRasterizerState(context, true); + context.m_currentState.m_rasterizerStateDescription = desc; + context.m_currentState.m_bBoundRasterizerState = 1; + } +} + +void RasterizerStateOGL::setScissorRect(RenderContext& context, int x, int y, int width, int height) +{ + if (m_enableScissorTest) + glScissor(x, y, width, height); +} diff --git a/source/renderer/hal/ogl/RasterizerStateOGL.hpp b/source/renderer/hal/ogl/RasterizerStateOGL.hpp new file mode 100644 index 000000000..dedcbcd70 --- /dev/null +++ b/source/renderer/hal/ogl/RasterizerStateOGL.hpp @@ -0,0 +1,25 @@ +#pragma once + +#include "API_OGL.hpp" +#include "renderer/hal/base/RasterizerStateBase.hpp" +#include "renderer/hal/interface/RenderContext.hpp" + +namespace mce +{ + class RasterizerStateOGL : public RasterizerStateBase + { + private: + GLenum m_cullFace; + bool m_enableScissorTest; + bool m_cullMode; + GLfloat m_depthBias; + + public: + RasterizerStateOGL(); + + public: + bool bindRasterizerState(RenderContext& context, bool forceBind = false); + void createRasterizerStateDescription(RenderContext& context, const RasterizerStateDescription& desc); + void setScissorRect(RenderContext &context, int x, int y, int width, int height); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/ogl/RenderContextOGL.cpp b/source/renderer/hal/ogl/RenderContextOGL.cpp new file mode 100644 index 000000000..4a39e250a --- /dev/null +++ b/source/renderer/hal/ogl/RenderContextOGL.cpp @@ -0,0 +1,310 @@ +#include +#include "RenderContextOGL.hpp" +#include "common/Logger.hpp" +#include "renderer/hal/interface/DepthStencilState.hpp" +#include "world/phys/Vec3.hpp" + +using namespace mce; + +RenderContextOGL::RenderContextOGL() + : RenderContextBase() +{ + m_activeTexture = GL_NONE; + m_activeShaderProgram = GL_NONE; + + m_emptyDepthStencilState = new DepthStencilState(); + mce::DepthStencilStateDescription desc; + m_emptyDepthStencilState->createDepthState(*(RenderContext*)this, desc); + + clearContextState(); +} + +GLenum _getGLMatrixModeFromMatrixType(MatrixType matrixType) +{ + switch (matrixType) + { + case MATRIX_PROJECTION: return GL_PROJECTION; + case MATRIX_VIEW: return GL_MODELVIEW; + default: + LOG_E("Unknown matrixType: %d", matrixType); + throw std::bad_cast(); + } +} + +void RenderContextOGL::loadMatrix(MatrixType matrixType, const Matrix& matrix) +{ +#ifndef FEATURE_GFX_SHADERS + GLenum matrixMode = _getGLMatrixModeFromMatrixType(matrixType); + glMatrixMode(matrixMode); + glLoadMatrixf(matrix.ptr()); +#endif +} + +void RenderContextOGL::setVertexState(const VertexFormat& vertexFormat) +{ + RenderContextBase::setVertexState(vertexFormat); + +#ifndef FEATURE_GFX_SHADERS + unsigned int vertexSize = vertexFormat.getVertexSize(); + + if (vertexFormat.hasField(mce::VERTEX_FIELD_POSITION)) + { + xglVertexPointer(3, GL_FLOAT, vertexSize, vertexFormat.getFieldOffset(mce::VERTEX_FIELD_POSITION)); + xglEnableClientState(GL_VERTEX_ARRAY); + } + + if (vertexFormat.hasField(mce::VERTEX_FIELD_UV0)) + { + xglTexCoordPointer(2, GL_FLOAT, vertexSize, vertexFormat.getFieldOffset(mce::VERTEX_FIELD_UV0)); + xglEnableClientState(GL_TEXTURE_COORD_ARRAY); + } + + if (vertexFormat.hasField(mce::VERTEX_FIELD_COLOR)) + { + xglColorPointer(4, GL_UNSIGNED_BYTE, vertexSize, vertexFormat.getFieldOffset(mce::VERTEX_FIELD_COLOR)); + xglEnableClientState(GL_COLOR_ARRAY); + } + +#ifdef USE_GL_NORMAL_LIGHTING + if (vertexFormat.hasField(mce::VERTEX_FIELD_NORMAL)) + { + xglNormalPointer(GL_BYTE, vertexSize, vertexFormat.getFieldOffset(mce::VERTEX_FIELD_NORMAL)); + xglEnableClientState(GL_NORMAL_ARRAY); + } +#endif +#endif +} + +void RenderContextOGL::clearVertexState(const VertexFormat& vertexFormat) +{ +#ifndef FEATURE_GFX_SHADERS + if (vertexFormat.hasField(mce::VERTEX_FIELD_POSITION)) + xglDisableClientState(GL_VERTEX_ARRAY); +#ifdef USE_GL_NORMAL_LIGHTING + if (vertexFormat.hasField(mce::VERTEX_FIELD_NORMAL)) + xglDisableClientState(GL_NORMAL_ARRAY); +#endif + if (vertexFormat.hasField(mce::VERTEX_FIELD_COLOR)) + xglDisableClientState(GL_COLOR_ARRAY); + if (vertexFormat.hasField(mce::VERTEX_FIELD_UV0)) + xglDisableClientState(GL_TEXTURE_COORD_ARRAY); +#endif +} + +float* _getBuffer(const Vec3& abc, float d) +{ + static float lb[4] = {}; + + lb[0] = abc.x; + lb[1] = abc.y; + lb[2] = abc.z; + lb[3] = d; + return (float*)&lb; +} + +void RenderContextOGL::enableFixedLighting(bool init) +{ +#ifndef FEATURE_GFX_SHADERS +#ifdef USE_GL_NORMAL_LIGHTING + glEnable(GL_LIGHTING); +#endif + + if (init) + { +#ifdef USE_GL_NORMAL_LIGHTING + glEnable(GL_LIGHT0); + glEnable(GL_LIGHT1); +#if !defined(__EMSCRIPTEN__) && !defined(USE_GLES) + glEnable(GL_COLOR_MATERIAL); + glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); +#endif + + constexpr float a = 0.4f, d = 0.6f, s = 0.0f; + + Vec3 l = Vec3(0.2f, 1.0f, -0.7f).normalize(); + glLightfv(GL_LIGHT0, GL_POSITION, _getBuffer(l, 0.0f)); + glLightfv(GL_LIGHT0, GL_DIFFUSE, _getBuffer(d, 1.0f)); + glLightfv(GL_LIGHT0, GL_AMBIENT, _getBuffer(0.0f, 1.0f)); + glLightfv(GL_LIGHT0, GL_SPECULAR, _getBuffer(s, 1.0f)); + + l = Vec3(-0.2f, 1.0f, 0.7f).normalize(); + glLightfv(GL_LIGHT1, GL_POSITION, _getBuffer(l, 0.0f)); + glLightfv(GL_LIGHT1, GL_DIFFUSE, _getBuffer(d, 1.0f)); + glLightfv(GL_LIGHT1, GL_AMBIENT, _getBuffer(0.0f, 1.0f)); + glLightfv(GL_LIGHT1, GL_SPECULAR, _getBuffer(s, 1.0f)); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, _getBuffer(a, 1.0f)); +#endif +#endif + } +} + +void RenderContextOGL::disableFixedLighting(bool teardown) +{ +#ifndef FEATURE_GFX_SHADERS +#ifdef USE_GL_NORMAL_LIGHTING + glDisable(GL_LIGHTING); + if (teardown) + { + glDisable(GL_LIGHT0); + glDisable(GL_LIGHT1); + glDisable(GL_COLOR_MATERIAL); + } +#endif +#endif +} + +bool RenderContextOGL::setShadeMode(ShadeMode mode) +{ + if (!RenderContextBase::setShadeMode(mode)) + return false; + +#ifndef FEATURE_GFX_SHADERS + glShadeModel(shadeModeMap[mode]); +#endif + + return true; +} + +bool RenderContextOGL::setCurrentColor(const Color& color) +{ + if (!RenderContextBase::setCurrentColor(color)) + return false; + +#ifndef FEATURE_GFX_SHADERS + glColor4f(color.r, color.g, color.b, color.a); +#endif + + return true; +} + +void RenderContextOGL::draw(PrimitiveMode primitiveMode, unsigned int startOffset, unsigned int count) +{ + xglDrawArrays(modeMap[primitiveMode], startOffset, count); +} + +void RenderContextOGL::drawIndexed(PrimitiveMode primitiveMode, unsigned int count, uint8_t indexSize) +{ + glDrawElements(modeMap[primitiveMode], count, indexType[indexSize], nullptr); +} + +void RenderContextOGL::drawIndexed(PrimitiveMode primitiveMode, unsigned int count, unsigned int startOffset, uint8_t indexSize) +{ + glDrawElements(modeMap[primitiveMode], count, indexType[indexSize], (const GLvoid*)(startOffset * indexSize)); +} + +void RenderContextOGL::setDepthRange(float nearVal, float farVal) +{ + glDepthRange(nearVal, farVal); +} + +void RenderContextOGL::setViewport(int topLeftX, int topLeftY, unsigned int width, unsigned int height, float nearVal, float farVal) +{ + glViewport(topLeftX, topLeftY, width, height); + setDepthRange(nearVal, farVal); +} + +void RenderContextOGL::clearFrameBuffer(const Color& color) +{ + glClearColor(color.r, color.g, color.b, color.a); + glClear(GL_COLOR_BUFFER_BIT); +} + +void RenderContextOGL::clearStencilBuffer() +{ + glStencilMask(0xFFFFFFFF); + glClear(GL_STENCIL_BUFFER_BIT); +} + +void RenderContextOGL::clearDepthStencilBuffer() +{ + // Needed to enable depth write, so we can clear it + m_emptyDepthStencilState->bindDepthStencilState(*(RenderContext*)this); + + glStencilMask(0xFFFFFFFF); + glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); +} + +void RenderContextOGL::clearContextState() +{ + m_activeTexture = GL_NONE; + m_activeBuffer[0] = GL_NONE; + m_activeBuffer[1] = GL_NONE; + +#ifdef MC_GL_DEBUG_OUTPUT + glEnable(GL_DEBUG_OUTPUT); + glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); + xglDebugMessageCallback(&mce::Platform::OGL::DebugMessage, nullptr); +#endif + + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); +#ifndef FEATURE_GFX_SHADERS + disableFixedLighting(false); +#endif +} + +void RenderContextOGL::setRenderTarget() +{ +} + +void RenderContextOGL::swapBuffers() +{ +} + +int RenderContextOGL::getMaxVertexCount() +{ + return gl::getMaxVertexCount(); +} + +bool RenderContextOGL::supports32BitIndices() +{ + return gl::supports32BitIndices(); +} + +GLuint& RenderContextOGL::getActiveBuffer(BufferType bufferType) +{ + if (bufferType < BUFFER_TYPES_MIN || bufferType > BUFFER_TYPES_MAX) + throw std::out_of_range("m_activeBuffer[]"); + + return m_activeBuffer[bufferType]; +} + +GLuint RenderContextOGL::getActiveBuffer(BufferType bufferType) const +{ + if (bufferType < BUFFER_TYPES_MIN || bufferType > BUFFER_TYPES_MAX) + throw std::out_of_range("m_activeBuffer[]"); + + return m_activeBuffer[bufferType]; +} + +RenderContextOGL::ActiveTextureUnit& RenderContextOGL::getActiveTextureUnit(unsigned int index) +{ + if (index >= 8) + throw std::out_of_range("m_activeTextureUnits[]"); + + return m_activeTextureUnits[index]; +} + +const RenderContextOGL::ActiveTextureUnit& RenderContextOGL::getActiveTextureUnit(unsigned int index) const +{ + if (index >= 8) + throw std::out_of_range("m_activeTextureUnits[]"); + + return m_activeTextureUnits[index]; +} + +GLenum mce::getComparisonFunc(ComparisonFunc comparisonFunc) +{ + switch (comparisonFunc) + { + case COMPARISON_FUNC_EQUAL: return GL_EQUAL; + case COMPARISON_FUNC_NOT_EQUAL: return GL_NOTEQUAL; + case COMPARISON_FUNC_ALWAYS: return GL_ALWAYS; + case COMPARISON_FUNC_LESS: return GL_LESS; + case COMPARISON_FUNC_GREATER: return GL_GREATER; + case COMPARISON_FUNC_GREATER_EQUAL: return GL_GEQUAL; + case COMPARISON_FUNC_LESS_EQUAL: return GL_LEQUAL; + default: + LOG_E("Unknown comparisonFunc: %d", comparisonFunc); + throw std::bad_cast(); + } +} \ No newline at end of file diff --git a/source/renderer/hal/ogl/RenderContextOGL.hpp b/source/renderer/hal/ogl/RenderContextOGL.hpp new file mode 100644 index 000000000..7e9cbb5a7 --- /dev/null +++ b/source/renderer/hal/ogl/RenderContextOGL.hpp @@ -0,0 +1,93 @@ +#pragma once + +#include + +#include "API_OGL.hpp" +#include "renderer/hal/base/RenderContextBase.hpp" +#include "renderer/hal/enums/PrimitiveMode.hpp" + +namespace mce +{ + const GLenum modeMap[] = { + /*PRIMITIVE_MODE_NONE*/ GL_NONE, + /*PRIMITIVE_MODE_QUAD_LIST*/ GL_TRIANGLES, // intentionally not using GL_QUADS + /*PRIMITIVE_MODE_TRIANGLE_LIST*/ GL_TRIANGLES, + /*PRIMITIVE_MODE_TRIANGLE_STRIP*/ GL_TRIANGLE_STRIP, + /*PRIMITIVE_MODE_LINE_LIST*/ GL_LINES, + /*PRIMITIVE_MODE_LINE_STRIP*/ GL_LINE_STRIP + }; + const GLenum shadeModeMap[] = { + /*SHADE_MODE_FLAT*/ GL_FLAT, + /*SHADE_MODE_SMOOTH*/ GL_SMOOTH + }; + const GLenum indexType[] = { + GL_NONE, + GL_UNSIGNED_BYTE, + GL_UNSIGNED_SHORT, + GL_NONE, + GL_UNSIGNED_INT + }; + + class DepthStencilState; + class RenderContextOGL : public RenderContextBase + { + public: + struct ActiveTextureUnit + { + GLuint m_textureUnit; + bool m_bIsShaderUniformDirty; + + ActiveTextureUnit() + { + m_textureUnit = GL_NONE; + m_bIsShaderUniformDirty = true; + } + }; + + private: + GLuint m_activeBuffer[2]; // indexed by BufferType + ActiveTextureUnit m_activeTextureUnits[8]; + DepthStencilState* m_emptyDepthStencilState; + + public: + GLuint m_activeTexture; + GLuint m_activeShaderProgram; + //GLuint m_activeBuffer[2]; + //ActiveTextureUnit m_activeTextureUnits[8]; + std::vector m_activePixels; + + public: + RenderContextOGL(); + + public: + void loadMatrix(MatrixType matrixType, const Matrix& matrix); + void setVertexState(const VertexFormat& vertexFormat); + void clearVertexState(const VertexFormat& vertexFormat); + void enableFixedLighting(bool init); + void disableFixedLighting(bool teardown); + bool setShadeMode(ShadeMode mode); + bool setCurrentColor(const Color& color); + void draw(PrimitiveMode primitiveMode, unsigned int startOffset, unsigned int count); + void drawIndexed(PrimitiveMode primitiveMode, unsigned int count, uint8_t indexSize); + void drawIndexed(PrimitiveMode primitiveMode, unsigned int count, unsigned int startOffset, uint8_t indexSize); + void setDepthRange(float nearVal, float farVal); + void setViewport(int topLeftX, int topLeftY, unsigned int width, unsigned int height, float nearVal, float farVal); + void clearFrameBuffer(const Color& color); + void clearStencilBuffer(); + void clearDepthStencilBuffer(); + void clearContextState(); + void setRenderTarget(); + void swapBuffers(); + + static int getMaxVertexCount(); + static bool supports32BitIndices(); + + GLuint& getActiveBuffer(BufferType bufferType); + GLuint getActiveBuffer(BufferType bufferType) const; + + ActiveTextureUnit& getActiveTextureUnit(unsigned int index); + const ActiveTextureUnit& getActiveTextureUnit(unsigned int index) const; + }; + + GLenum getComparisonFunc(ComparisonFunc comparisonFunc); +} diff --git a/source/renderer/hal/ogl/RenderDeviceOGL.cpp b/source/renderer/hal/ogl/RenderDeviceOGL.cpp new file mode 100644 index 000000000..af94bf0c3 --- /dev/null +++ b/source/renderer/hal/ogl/RenderDeviceOGL.cpp @@ -0,0 +1 @@ +#include "RenderDeviceOGL.hpp" \ No newline at end of file diff --git a/source/renderer/hal/ogl/RenderDeviceOGL.hpp b/source/renderer/hal/ogl/RenderDeviceOGL.hpp new file mode 100644 index 000000000..8f187be2f --- /dev/null +++ b/source/renderer/hal/ogl/RenderDeviceOGL.hpp @@ -0,0 +1,10 @@ +#pragma once + +#include "renderer/hal/base/RenderDeviceBase.hpp" + +namespace mce +{ + class RenderDeviceOGL : public RenderDeviceBase + { + }; +} \ No newline at end of file diff --git a/source/renderer/hal/ogl/ResourceOGL.cpp b/source/renderer/hal/ogl/ResourceOGL.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/source/renderer/hal/ogl/ResourceOGL.hpp b/source/renderer/hal/ogl/ResourceOGL.hpp new file mode 100644 index 000000000..e69de29bb diff --git a/source/renderer/hal/ogl/ShaderConstantOGL.cpp b/source/renderer/hal/ogl/ShaderConstantOGL.cpp new file mode 100644 index 000000000..075659a88 --- /dev/null +++ b/source/renderer/hal/ogl/ShaderConstantOGL.cpp @@ -0,0 +1,8 @@ +#include "ShaderConstantOGL.hpp" + +using namespace mce; + +void ShaderConstantOGL::syncUniform(int value) +{ + m_dirty = false; +} \ No newline at end of file diff --git a/source/renderer/hal/ogl/ShaderConstantOGL.hpp b/source/renderer/hal/ogl/ShaderConstantOGL.hpp new file mode 100644 index 000000000..c91c0572f --- /dev/null +++ b/source/renderer/hal/ogl/ShaderConstantOGL.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include "renderer/hal/base/ShaderConstantBase.hpp" + +namespace mce +{ + class ShaderConstantOGL : public ShaderConstantBase + { + public: + void syncUniform(int); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/ogl/ShaderConstantWithDataOGL.cpp b/source/renderer/hal/ogl/ShaderConstantWithDataOGL.cpp new file mode 100644 index 000000000..fee19cc7d --- /dev/null +++ b/source/renderer/hal/ogl/ShaderConstantWithDataOGL.cpp @@ -0,0 +1,30 @@ +#include "ShaderConstantWithDataOGL.hpp" + +#ifdef FEATURE_GFX_SHADERS + +using namespace mce; + +template <> +void ShaderConstantWithDataOGL::syncUniform(int value) { xglUniform1fv(value, 1, (const GLfloat*)m_data); } +template <> +void ShaderConstantWithDataOGL::syncUniform(int value) { xglUniform2fv(value, 1, (const GLfloat*)m_data); } +template <> +void ShaderConstantWithDataOGL::syncUniform(int value) { xglUniform3fv(value, 1, (const GLfloat*)m_data); } +template <> +void ShaderConstantWithDataOGL::syncUniform(int value) { xglUniform4fv(value, 1, (const GLfloat*)m_data); } +template <> +void ShaderConstantWithDataOGL::syncUniform(int value) { xglUniform1iv(value, 1, (const GLint*)m_data); } +template <> +void ShaderConstantWithDataOGL::syncUniform(int value) { xglUniform2iv(value, 1, (const GLint*)m_data); } +template <> +void ShaderConstantWithDataOGL::syncUniform(int value) { xglUniform3iv(value, 1, (const GLint*)m_data); } +template <> +void ShaderConstantWithDataOGL::syncUniform(int value) { xglUniform4iv(value, 1, (const GLint*)m_data); } +template <> +void ShaderConstantWithDataOGL::syncUniform(int value) { xglUniformMatrix2fv(value, 1, 0, (const GLfloat*)m_data); } +template <> +void ShaderConstantWithDataOGL::syncUniform(int value) { xglUniformMatrix3fv(value, 1, 0, (const GLfloat*)m_data); } +template <> +void ShaderConstantWithDataOGL::syncUniform(int value) { xglUniformMatrix4fv(value, 1, 0, (const GLfloat*)m_data); } + +#endif // FEATURE_GFX_SHADERS \ No newline at end of file diff --git a/source/renderer/hal/ogl/ShaderConstantWithDataOGL.hpp b/source/renderer/hal/ogl/ShaderConstantWithDataOGL.hpp new file mode 100644 index 000000000..695c4cade --- /dev/null +++ b/source/renderer/hal/ogl/ShaderConstantWithDataOGL.hpp @@ -0,0 +1,25 @@ +#pragma once + +#include "API_OGL.hpp" +#include "GameMods.hpp" + +#ifdef FEATURE_GFX_SHADERS + +#include "renderer/hal/base/ShaderConstantWithDataBase.hpp" + +namespace mce +{ + template + class ShaderConstantWithDataOGL : public ShaderConstantWithDataBase + { + public: + ShaderConstantWithDataOGL(ShaderPrimitiveTypes primitiveType) + : ShaderConstantWithDataBase(primitiveType) + { + } + + void syncUniform(int value); + }; +} + +#endif // FEATURE_GFX_SHADERS \ No newline at end of file diff --git a/source/renderer/hal/ogl/ShaderOGL.cpp b/source/renderer/hal/ogl/ShaderOGL.cpp new file mode 100644 index 000000000..60c3482da --- /dev/null +++ b/source/renderer/hal/ogl/ShaderOGL.cpp @@ -0,0 +1,285 @@ +#include +#include + +#include "ShaderOGL.hpp" + +#ifdef FEATURE_GFX_SHADERS + +#include "renderer/GlobalConstantBufferManager.hpp" +#include "renderer/ConstantBufferMetaDataManager.hpp" +#include "renderer/RenderContextImmediate.hpp" + +using namespace mce; + +static ShaderOGL::VertexFieldFormat vertexFieldFormats[] = { + { GL_FLOAT, 3, GL_FALSE }, // VERTEX_FIELD_POSITION + { GL_UNSIGNED_BYTE, 4, GL_TRUE }, // VERTEX_FIELD_COLOR + { GL_BYTE, 4, GL_FALSE }, // VERTEX_FIELD_NORMAL + { GL_UNSIGNED_SHORT, 2, GL_TRUE }, // VERTEX_FIELD_UV0 + { GL_UNSIGNED_SHORT, 2, GL_TRUE } // VERTEX_FIELD_UV1 +}; + +ShaderOGL::ShaderOGL(ShaderProgram& vertex, ShaderProgram& fragment, ShaderProgram& geometry) + : ShaderBase(vertex, fragment, geometry) +{ + m_program = GL_NONE; + + createAndAttachPrograms(); + linkShader(); + reflectShader(); +} + +ShaderOGL::~ShaderOGL() +{ + deleteShader(); +} + +ShaderPrimitiveTypes ShaderOGL::shaderPrimitiveTypeFromOGLUniformType(GLenum uniformType) +{ + switch (uniformType) + { + case GL_INT: return SHADER_PRIMITIVE_INT1; + case GL_INT_VEC2: return SHADER_PRIMITIVE_INT2; + case GL_INT_VEC3: return SHADER_PRIMITIVE_INT3; + case GL_INT_VEC4: return SHADER_PRIMITIVE_INT4; + case GL_FLOAT: return SHADER_PRIMITIVE_FLOAT1; + case GL_FLOAT_VEC2: return SHADER_PRIMITIVE_FLOAT2; + case GL_FLOAT_VEC3: return SHADER_PRIMITIVE_FLOAT3; + case GL_FLOAT_VEC4: return SHADER_PRIMITIVE_FLOAT4; + case GL_FLOAT_MAT2: return SHADER_PRIMITIVE_MATRIX2x2; + case GL_FLOAT_MAT3: return SHADER_PRIMITIVE_MATRIX3x3; + case GL_FLOAT_MAT4: return SHADER_PRIMITIVE_MATRIX4x4; + case GL_SAMPLER_2D: return SHADER_PRIMITIVE_SAMPLER1D; + default: + LOG_E("Unknown type: %d", uniformType); + throw std::bad_cast(); + } +} + +void ShaderOGL::deleteShader() +{ + xglDeleteProgram(m_program); + m_program = GL_NONE; +} + +void ShaderOGL::finalizeShaderUniforms() +{ + for (int i = 0; i < m_uniformList.size(); i++) + { + ShaderUniformOGL& uniform = m_uniformList[i]; + uniform.m_shaderConstant = uniform.m_constantBufferContainer->getUnspecializedShaderConstant(uniform.m_name); + } +} + +void ShaderOGL::freeCompilerResources() +{ + xglReleaseShaderCompiler(); + glGetError(); +} + +void ShaderOGL::resetLastProgram() +{ + RenderContextImmediate::get().m_activeShaderProgram = GL_NONE; +} + +void ShaderOGL::createAndAttachPrograms() +{ + m_program = xglCreateProgram(); + + xglAttachShader(m_program, m_vertexShader.m_shaderName); + xglAttachShader(m_program, m_fragmentShader.m_shaderName); + if (m_geometryShader.isValid()) + xglAttachShader(m_program, m_geometryShader.m_shaderName); + + ErrorHandler::checkForErrors(); +} + +void ShaderOGL::linkShader() +{ + xglLinkProgram(m_program); + + ErrorHandler::checkForErrors(); + + GLint linkStatus; + xglGetProgramiv(m_program, GL_LINK_STATUS, &linkStatus); + + if (linkStatus == GL_TRUE) + return; + + if (m_geometryShader.isValid()) + { + LOG_E("Failed to link %s to %s and %s", m_vertexShader.m_shaderPath, m_fragmentShader.m_shaderPath, m_geometryShader.m_shaderPath); + throw std::bad_cast(); + } + else + { + LOG_E("Failed to link %s to %s", m_vertexShader.m_shaderPath, m_fragmentShader.m_shaderPath); + throw std::bad_cast(); + } + + GLint logLength = 0; + xglGetProgramiv(m_program, GL_INFO_LOG_LENGTH, &logLength); + + if (logLength > 1) + { + int charsWritten = 0; + char* infoLog; + xglGetProgramInfoLog(m_program, logLength, &charsWritten, infoLog); + + LOG_E("Compiler error:\n%s", infoLog); + throw std::bad_cast(); + } + + xglDeleteProgram(m_program); + m_program = 0; +} + +void ShaderOGL::bindVertexPointers(const VertexFormat& vertexFormat, const void* vertexData) +{ + RenderDevice& device = RenderDevice::getInstance(); + const RenderDeviceBase::AttributeList& attrList = device.getAttributeList(m_attributeListIndex); + + for (int i = 0; i < attrList.size(); i++) + { + const Attribute& attr = attrList[i]; + + VertexField vertexField = attr.getVertexField(); + if (!vertexFormat.hasField(vertexField)) + continue; + + GLuint location = attr.getLocation(); + const VertexFieldFormat& format = vertexFieldFormats[vertexField]; + xglVertexAttribPointer( + location, + format.components, + format.componentsType, + format.normalized, + vertexFormat.getVertexSize(), + vertexFormat.getFieldOffset(vertexField, vertexData) + ); + + ErrorHandler::checkForErrors(); + } +} + +void ShaderOGL::bindShader(RenderContext& context, const VertexFormat& format, const void *dataBasePtr, unsigned int shaderStageBits) +{ + bool shaderChanged = context.m_activeShaderProgram != m_program; + + if (shaderChanged) + { + xglUseProgram(m_program); + context.m_activeShaderProgram = m_program; + } + + bindVertexPointers(format, dataBasePtr); + + for (int i = 0; i < m_textureList.size(); i++) + { + const ShaderResourceOGL& resource = m_textureList[i]; + RenderContextOGL::ActiveTextureUnit& activeTextureUnit = context.getActiveTextureUnit(i); + if ((shaderChanged && resource.m_bValid) || activeTextureUnit.m_bIsShaderUniformDirty) + { + xglUniform1i(resource.m_location, activeTextureUnit.m_textureUnit); + activeTextureUnit.m_bIsShaderUniformDirty = false; + } + } + + for (int i = 0; i < m_uniformList.size(); i++) + { + ShaderUniformOGL& shaderUniform = m_uniformList[i]; + shaderUniform.bind(shaderChanged); + } +} + +void ShaderOGL::reflectShaderUniforms() +{ + GlobalConstantBufferManager& bufferManager = GlobalConstantBufferManager::getInstance(); + + GLint uniformCount; + xglGetProgramiv(m_program, GL_ACTIVE_UNIFORMS, &uniformCount); + + GLsizei length; + GLenum type; + GLint size; + char name[1024]; + for (int i = 0; i < uniformCount; i++) + { + xglGetActiveUniform(m_program, i, 1024, &length, &size, &type, name); + GLint location = xglGetUniformLocation(m_program, name); + + if (location < 0) + continue; + + ShaderPrimitiveTypes shaderPrimitiveType = shaderPrimitiveTypeFromOGLUniformType(type); + + if (shaderPrimitiveType == SHADER_PRIMITIVE_SAMPLER1D && + strlen(name) > 8 && strstr(name, "TEXTURE_") != NULL) + { + ShaderResourceOGL texture(name, location, size, shaderPrimitiveType); + texture.m_bValid = true; + m_textureList.push_back(texture); + if (m_textureList.size() > 8) + { + LOG_E("You've exeeded the gl spec for minimum number of texture units: %d", 8); + throw std::bad_cast(); + } + } + else + { + ShaderUniformOGL uniform(name, location, size, shaderPrimitiveType); + + const UniformMetaData& uniformMetadata = ConstantBufferMetaDataManager::getInstance().findUniformMetaData(name); + const std::string& bufferName = uniformMetadata.m_constantBufferMetaDataParent->getConstantBufferName(); + ConstantBufferContainer* pBufferContainer = bufferManager.findConstantBufferContainer(bufferName); + pBufferContainer->registerReflectedShaderParameter(uniformMetadata); + uniform.m_constantBufferContainer = pBufferContainer; + + m_uniformList.push_back(uniform); + } + } +} + +void ShaderOGL::reflectShaderAttributes() +{ + RenderDeviceBase::AttributeList attrList; + + GLint attrCount; + xglGetProgramiv(m_program, GL_ACTIVE_ATTRIBUTES, &attrCount); + + if (attrCount) + { + char name[1024]; + GLsizei nameLen; + GLint size; + GLenum type; + + for (GLint i = 0; i < attrCount; i++) + { + xglGetActiveAttrib(m_program, i, sizeof(name), &nameLen, &size, &type, name); + GLint location = xglGetAttribLocation(this->m_program, name); + if (location < 0) + continue; + + std::string attrName(name); + VertexField vertexField = getAttributeForName(attrName, 0); + + Attribute attr(location, size, vertexField); + attrList.push_back(attr); + + xglEnableVertexAttribArray(location); + xglVertexAttribPointer(0, 1, GL_UNSIGNED_BYTE, 0, 1, this); + } + } + + m_attributeListIndex = RenderDevice::getInstance().registerOrGetAttributeListIndex(attrList); +} + +void ShaderOGL::reflectShader() +{ + reflectShaderUniforms(); + reflectShaderAttributes(); +} + + +#endif // FEATURE_GFX_SHADERS \ No newline at end of file diff --git a/source/renderer/hal/ogl/ShaderOGL.hpp b/source/renderer/hal/ogl/ShaderOGL.hpp new file mode 100644 index 000000000..7deecc093 --- /dev/null +++ b/source/renderer/hal/ogl/ShaderOGL.hpp @@ -0,0 +1,55 @@ +#pragma once + +#include + +#include "API_OGL.hpp" + +#ifdef FEATURE_GFX_SHADERS + +#include "ShaderUniformOGL.hpp" +#include "renderer/VertexFormat.hpp" +#include "renderer/hal/base/ShaderBase.hpp" +#include "renderer/hal/enums/ShaderPrimitiveTypes.hpp" +#include "renderer/hal/helpers/ErrorHandler.hpp" +#include "renderer/hal/interface/ShaderProgram.hpp" +#include "renderer/hal/interface/RenderContext.hpp" + +namespace mce +{ + class ShaderOGL : public ShaderBase + { + public: + struct VertexFieldFormat + { + GLenum componentsType; + GLint components; + GLboolean normalized; + }; + + private: + GLuint m_program; + std::vector m_uniformList; + std::vector m_textureList; + + public: + ShaderOGL(ShaderProgram& vertex, ShaderProgram& fragment, ShaderProgram& geometry); + ~ShaderOGL(); + + public: + static ShaderPrimitiveTypes shaderPrimitiveTypeFromOGLUniformType(GLenum uniformType); + + void deleteShader(); + void finalizeShaderUniforms(); + static void freeCompilerResources(); + static void resetLastProgram(); + void createAndAttachPrograms(); + void linkShader(); + void bindVertexPointers(const VertexFormat&, const void*); + void bindShader(RenderContext& context, const VertexFormat& format, const void *dataBasePtr, unsigned int shaderStageBits); + void reflectShaderUniforms(); + void reflectShaderAttributes(); + void reflectShader(); + }; +} + +#endif // FEATURE_GFX_SHADERS \ No newline at end of file diff --git a/source/renderer/hal/ogl/ShaderProgramOGL.cpp b/source/renderer/hal/ogl/ShaderProgramOGL.cpp new file mode 100644 index 000000000..77c64768d --- /dev/null +++ b/source/renderer/hal/ogl/ShaderProgramOGL.cpp @@ -0,0 +1,59 @@ +#include "ShaderProgramOGL.hpp" + +#ifdef FEATURE_GFX_SHADERS + +#include "RenderContextOGL.hpp" + +using namespace mce; + +const GLenum shaderTypeMap[] = { + /*SHADER_TYPE_VERTEX*/ GL_VERTEX_SHADER, + /*SHADER_TYPE_FRAGMENT*/ GL_FRAGMENT_SHADER +}; + +ShaderProgramOGL::ShaderProgramOGL(ShaderType shaderType, const std::string& shaderSource, const std::string& header, const std::string& shaderPath) + : ShaderProgramBase(header, shaderPath, shaderType) +{ + if (shaderSource.empty() || shaderType > SHADER_TYPE_FRAGMENT) + { + m_bValid = false; + return; + } + + const GLint sourceLength = shaderSource.size(); + const GLchar* sourceStr = (const GLchar*)shaderSource.data(); + m_shaderName = xglCreateShader(shaderTypeMap[shaderType]); + xglShaderSource(m_shaderName, 1, &sourceStr, &sourceLength); + xglCompileShader(m_shaderName); + + GLint compileStatus; + xglGetShaderiv(m_shaderName, GL_COMPILE_STATUS, &compileStatus); + if (compileStatus == GL_FALSE) + { + GLint maxLength = 0; + xglGetShaderiv(m_shaderName, GL_INFO_LOG_LENGTH, &maxLength); + if (maxLength > 1) + { + std::string infoLog(maxLength, 0); + xglGetShaderInfoLog(m_shaderName, maxLength, &maxLength, (GLchar*)infoLog.data()); + LOG_E("Compiler error:\n %s", infoLog); + } + m_bValid = false; + return; + } + + m_bValid = true; +} + +ShaderProgramOGL::~ShaderProgramOGL() +{ + deleteShader(); +} + +void ShaderProgramOGL::deleteShader() +{ + xglDeleteShader(m_shaderName); + m_shaderName = GL_NONE; +} + +#endif // FEATURE_GFX_SHADERS \ No newline at end of file diff --git a/source/renderer/hal/ogl/ShaderProgramOGL.hpp b/source/renderer/hal/ogl/ShaderProgramOGL.hpp new file mode 100644 index 000000000..b77cca146 --- /dev/null +++ b/source/renderer/hal/ogl/ShaderProgramOGL.hpp @@ -0,0 +1,25 @@ +#pragma once + +#include "API_OGL.hpp" + +#ifdef FEATURE_GFX_SHADERS + +#include "renderer/hal/base/ShaderProgramBase.hpp" + +namespace mce +{ + class ShaderProgramOGL : public ShaderProgramBase + { + public: + GLuint m_shaderName; + + public: + ShaderProgramOGL(ShaderType shaderType, const std::string& shaderSource, const std::string& header, const std::string& shaderPath); + ~ShaderProgramOGL(); + + protected: + void deleteShader(); + }; +} + +#endif // FEATURE_GFX_SHADERS \ No newline at end of file diff --git a/source/renderer/hal/ogl/ShaderResourceOGL.cpp b/source/renderer/hal/ogl/ShaderResourceOGL.cpp new file mode 100644 index 000000000..fc7cd0667 --- /dev/null +++ b/source/renderer/hal/ogl/ShaderResourceOGL.cpp @@ -0,0 +1,12 @@ +#include "ShaderResourceOGL.hpp" + +using namespace mce; + +ShaderResourceOGL::ShaderResourceOGL(const std::string& name, int location, int elements, ShaderPrimitiveTypes shaderPrimitiveType) + : m_location(location) + , m_elements(elements) + , m_name(name) + , m_shaderPrimitiveType(shaderPrimitiveType) +{ + m_bValid = false; +} \ No newline at end of file diff --git a/source/renderer/hal/ogl/ShaderResourceOGL.hpp b/source/renderer/hal/ogl/ShaderResourceOGL.hpp new file mode 100644 index 000000000..1a7401978 --- /dev/null +++ b/source/renderer/hal/ogl/ShaderResourceOGL.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include + +#include "renderer/hal/enums/ShaderPrimitiveTypes.hpp" + +namespace mce +{ + class ShaderResourceOGL + { + public: + int m_location; + int m_elements; + ShaderPrimitiveTypes m_shaderPrimitiveType; + bool m_bValid; + std::string m_name; + + ShaderResourceOGL(const std::string& name, int location, int elements, ShaderPrimitiveTypes shaderPrimitiveType); + }; +} \ No newline at end of file diff --git a/source/renderer/hal/ogl/ShaderUniformOGL.cpp b/source/renderer/hal/ogl/ShaderUniformOGL.cpp new file mode 100644 index 000000000..03a386be9 --- /dev/null +++ b/source/renderer/hal/ogl/ShaderUniformOGL.cpp @@ -0,0 +1,18 @@ +#include "ShaderUniformOGL.hpp" + +using namespace mce; + +ShaderUniformOGL::ShaderUniformOGL(const std::string& name, int location, int elements, ShaderPrimitiveTypes shaderPrimitiveType) + : ShaderResourceOGL(name, location, elements, shaderPrimitiveType) +{ + m_shaderConstant = nullptr; + m_constantBufferContainer = nullptr; +} + +void ShaderUniformOGL::bind(bool forceBind) +{ + if (forceBind || m_shaderConstant->isDirty()) + { + m_shaderConstant->syncUniform(m_location); + } +} diff --git a/source/renderer/hal/ogl/ShaderUniformOGL.hpp b/source/renderer/hal/ogl/ShaderUniformOGL.hpp new file mode 100644 index 000000000..c47acc406 --- /dev/null +++ b/source/renderer/hal/ogl/ShaderUniformOGL.hpp @@ -0,0 +1,19 @@ +#include "ShaderResourceOGL.hpp" +#include "ShaderConstantOGL.hpp" +#include "renderer/hal/interface/ConstantBufferContainer.hpp" + +namespace mce +{ + // ShaderUniform is specific to OpenGL + class ShaderUniformOGL : public ShaderResourceOGL + { + public: + ShaderConstantOGL* m_shaderConstant; + ConstantBufferContainer *m_constantBufferContainer; + + public: + ShaderUniformOGL(const std::string& name, int location, int elements, ShaderPrimitiveTypes shaderPrimitiveType); + + void bind(bool forceBind); + }; +} diff --git a/source/renderer/hal/ogl/TextureOGL.cpp b/source/renderer/hal/ogl/TextureOGL.cpp new file mode 100644 index 000000000..a4a1377f3 --- /dev/null +++ b/source/renderer/hal/ogl/TextureOGL.cpp @@ -0,0 +1,210 @@ +#include + +#include "renderer/hal/helpers/ErrorHandler.hpp" +#include "API_OGL.hpp" +#include "TextureOGL.hpp" + +using namespace mce; + +TextureOGL::TextureOGL() + : TextureBase() +{ +} + +GLenum getOpenGLTextureFormat(TextureFormat textureFormat) +{ + switch (textureFormat) + { + case TEXTURE_FORMAT_R8G8B8A8_UNORM: + return GL_RGBA; + default: + LOG_E("Unknown textureFormat: %d", textureFormat); + throw std::bad_cast(); + } +} + +GLint getOpenGLInternalTextureFormatFromTextureFormat(TextureFormat textureFormat) +{ + switch (textureFormat) + { + case TEXTURE_FORMAT_R8G8B8A8_UNORM: + return GL_RGBA; + default: + LOG_E("Unknown textureFormat: %d", textureFormat); + throw std::bad_cast(); + } +} + +GLenum getOpenGLTextureTypeFromTextureFormat(TextureFormat textureFormat) +{ + switch (textureFormat) + { + case TEXTURE_FORMAT_R8G8B8A8_UNORM: + return GL_UNSIGNED_BYTE; + default: + LOG_E("Unknown textureFormat: %d", textureFormat); + throw std::bad_cast(); + } +} + +void TextureOGL::deleteTexture() +{ + ErrorHandler::checkForErrors(); + + glDeleteTextures(1, &m_state.m_textureName); + TextureBase::deleteTexture(); + + *this = TextureOGL(); + + ErrorHandler::checkForErrors(); +} + +void TextureOGL::bindTexture(RenderContext& context, unsigned int textureUnit, unsigned int shaderStagesBits) +{ + ErrorHandler::checkForErrors(); + + GLenum texture = GL_TEXTURE0 + textureUnit; + if (context.m_activeTexture != texture) + { + xglActiveTexture(texture); + context.m_activeTexture = texture; + } + + ErrorHandler::checkForErrors(); + + glBindTexture(m_state.m_textureTarget, m_state.m_textureName); + + RenderContextOGL::ActiveTextureUnit& activeTextureUnit = context.getActiveTextureUnit(textureUnit); + activeTextureUnit.m_textureUnit = textureUnit; + activeTextureUnit.m_bIsShaderUniformDirty = true; + + ErrorHandler::checkForErrors(); +} + +void TextureOGL::convertToMipmapedTexture(RenderContext& context, unsigned int mipmaps) +{ + if (mipmaps == 0) + { + LOG_E("You must have a positive number of mip maps that is greater than 1"); + throw std::bad_cast(); + } + + bindTexture(context); + TextureBase::convertToMipmapedTexture(mipmaps - 1); + + glTexParameteri(m_state.m_textureTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR); + if (gl::isOpenGLES3() || !gl::isOpenGLES()) + { + glTexParameteri(m_state.m_textureTarget, GL_TEXTURE_MAX_LEVEL, mipmaps - 1); + } + + ErrorHandler::checkForErrors(); +} + +void TextureOGL::subBuffer(RenderContext& context, const void* pixels, unsigned int xoffset, unsigned int yoffset, unsigned int width, unsigned int height, unsigned int level) +{ + bindTexture(context); + ErrorHandler::checkForErrors(); + + if (m_state.m_textureTarget != GL_TEXTURE_2D) + { + LOG_E("Unknown textureTarget %d", m_state.m_textureTarget); + throw std::bad_cast(); + } + + glTexSubImage2D(GL_TEXTURE_2D, level, xoffset, yoffset, width, height, m_state.m_textureFormat, m_state.m_textureType, pixels); + ErrorHandler::checkForErrors(); +} + +void TextureOGL::subBuffer(RenderContext& context, const void* pixels) +{ + subBuffer(context, pixels, 0, 0, m_description.width, m_description.height, 0); +} + +void TextureOGL::createMipMap(RenderContext& context, const void* pixels, unsigned int width, unsigned int height, unsigned int level) +{ + if (m_state.m_textureTarget != GL_TEXTURE_2D) + { + LOG_E("Unknown textureTarget %d", m_state.m_textureTarget); + throw std::bad_cast(); + } + + glTexImage2D(GL_TEXTURE_2D, level, m_state.m_internalTextureFormat, width, height, 0, m_state.m_textureFormat, m_state.m_textureType, pixels); + m_bCreated = true; + ErrorHandler::checkForErrors(); +} + +void TextureOGL::createTexture(RenderContext& context, const TextureDescription& description) +{ + TextureBase::createTexture(description); + glGenTextures(1, &m_state.m_textureName); + ErrorHandler::checkForErrors(); + + m_state.m_internalTextureFormat = getOpenGLInternalTextureFormatFromTextureFormat(description.textureFormat); + m_state.m_textureFormat = getOpenGLTextureFormat(description.textureFormat); + m_state.m_textureType = getOpenGLTextureTypeFromTextureFormat(description.textureFormat); + + bindTexture(context); + ErrorHandler::checkForErrors(); + createMipMap(context, nullptr, description.width, description.height, 0); + + switch (description.filteringLevel) + { + case TEXTURE_FILTERING_BILINEAR: + // @NOTE: Need GL 1.2 for GL_CLAMP_TO_EDGE + glTexParameteri(m_state.m_textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(m_state.m_textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(m_state.m_textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(m_state.m_textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + break; + case TEXTURE_FILTERING_POINT: + if (description.bWrap) + { + glTexParameteri(m_state.m_textureTarget, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(m_state.m_textureTarget, GL_TEXTURE_WRAP_T, GL_REPEAT); + } + else + { + glTexParameteri(m_state.m_textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(m_state.m_textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + } + glTexParameteri(m_state.m_textureTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(m_state.m_textureTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + break; + case TEXTURE_FILTERING_MIPMAP_BILINEAR: + glTexParameteri(m_state.m_textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(m_state.m_textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(m_state.m_textureTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR); + glTexParameteri(m_state.m_textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + break; + default: + break; + } + + ErrorHandler::checkForErrors(); +} + +void TextureOGL::lock(RenderContext& context) +{ + context.m_activePixels.resize(m_description.getSizeInBytes()); +} + +void TextureOGL::unlock(RenderContext& context) +{ + bindTexture(context); + subBuffer(context, &context.m_activePixels[0]); + context.m_activePixels.clear(); +} + +void TextureOGL::move(TextureOGL& other) +{ + TextureBase::move(other); + State tempState = this->m_state; + this->m_state = other.m_state; + other.m_state = tempState; +} + +bool TextureOGL::supportsMipMaps() +{ + return gl::supportsMipmaps(); +} \ No newline at end of file diff --git a/source/renderer/hal/ogl/TextureOGL.hpp b/source/renderer/hal/ogl/TextureOGL.hpp new file mode 100644 index 000000000..93255934b --- /dev/null +++ b/source/renderer/hal/ogl/TextureOGL.hpp @@ -0,0 +1,52 @@ +#pragma once + +#include "renderer/hal/base/TextureBase.hpp" +#include "renderer/hal/interface/RenderContext.hpp" + +namespace mce +{ + class TextureOGL : public TextureBase + { + private: + struct State + { + GLuint m_textureName; + GLenum m_textureTarget; + GLint m_internalTextureFormat; + GLenum m_textureFormat; + GLenum m_textureType; + + State() + { + m_textureName = 0; + m_textureTarget = GL_TEXTURE_2D; + m_internalTextureFormat = GL_NONE; + m_textureFormat = GL_NONE; + m_textureType = GL_NONE; + } + }; + private: + State m_state; + + public: + TextureOGL(); + + void deleteTexture(); + void bindTexture(RenderContext& context, unsigned int textureUnit = 0, unsigned int shaderStagesBits = SHADER_STAGE_BIT_PIXEL); + + void convertToMipmapedTexture(RenderContext& context, unsigned int mipmaps); + + void subBuffer(RenderContext& context, const void* pixels, unsigned int xoffset, unsigned int yoffset, unsigned int width, unsigned int height, unsigned int level); + void subBuffer(RenderContext& context, const void* pixels); + + void createMipMap(RenderContext& context, const void* pixels, unsigned int width, unsigned int height, unsigned int level); + void createTexture(RenderContext& context, const TextureDescription& description); + + void lock(RenderContext& context); + void unlock(RenderContext& context); + + void move(TextureOGL& other); + + static bool supportsMipMaps(); + }; +} diff --git a/source/renderer/platform/ogl/Extensions.cpp b/source/renderer/platform/ogl/Extensions.cpp new file mode 100644 index 000000000..f959475bb --- /dev/null +++ b/source/renderer/platform/ogl/Extensions.cpp @@ -0,0 +1,1000 @@ +#include "Extensions.hpp" +#include "common/Logger.hpp" +#include "GameMods.hpp" + +using namespace mce::Platform; + +bool OGL::InitBindings() +{ + bool result = true; + +#ifdef _WIN32 + xglInit(); + result = xglInitted(); +#endif + + return result; +} + +void* OGL::GetProcAddress(const char* name) +{ + void* result = nullptr; + +#ifdef _WIN32 + result = (void*)wglGetProcAddress(name); + if (result == nullptr) + { + HMODULE handle = GetModuleHandle("opengl32.dll"); + if (handle != NULL) + { + result = (void*)GetProcAddress(handle, name); + } + } +#endif + + return result; +} + +#ifdef MC_GL_DEBUG_OUTPUT +void APIENTRY OGL::DebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam) +{ + LOG_I("GL CALLBACK: type = 0x%x, severity = 0x%x, message = %s\n", type, severity, message); +} +#endif + +#if defined(_WIN32) || defined(__DREAMCAST__) + +#include + +#ifdef __DREAMCAST__ + +#define USE_GL_VBO_EMULATION + +#endif + +#ifdef _WIN32 +#ifndef USE_OPENGL_2_FEATURES +// this is stupidly hacky +typedef BOOL(WINAPI* PFNWGLSWAPINTERVALEXTPROC) (int interval); +#endif +#endif + +// USE_HARDWARE_GL_BUFFERS enables VBOs to be used using their OpenGL interfaces. +// Disabling it simulates VBO functionality using display lists, which is slower. +#ifndef USE_GL_VBO_EMULATION +#define USE_HARDWARE_GL_BUFFERS +#endif + +#ifdef USE_HARDWARE_GL_BUFFERS +#if GL_VERSION_1_3 +PFNGLACTIVETEXTUREPROC p_glActiveTexture; +#endif +#if GL_VERSION_1_5 +PFNGLBINDBUFFERPROC p_glBindBuffer; +PFNGLBUFFERDATAPROC p_glBufferData; +PFNGLGENBUFFERSPROC p_glGenBuffers; +PFNGLDELETEBUFFERSPROC p_glDeleteBuffers; +PFNGLBUFFERSUBDATAPROC p_glBufferSubData; +#endif +#if GL_VERSION_2_0 +PFNGLSTENCILFUNCSEPARATEPROC p_glStencilFuncSeparate; +PFNGLSTENCILOPSEPARATEPROC p_glStencilOpSeparate; +#endif // GL_VERSION_2_0 +#ifdef FEATURE_GFX_SHADERS +#if GL_VERSION_2_0 +PFNGLUNIFORM1IPROC p_glUniform1i; +PFNGLUNIFORM1FVPROC p_glUniform1fv; +PFNGLUNIFORM2FVPROC p_glUniform2fv; +PFNGLUNIFORM3FVPROC p_glUniform3fv; +PFNGLUNIFORM4FVPROC p_glUniform4fv; +PFNGLUNIFORM1IVPROC p_glUniform1iv; +PFNGLUNIFORM2IVPROC p_glUniform2iv; +PFNGLUNIFORM3IVPROC p_glUniform3iv; +PFNGLUNIFORM4IVPROC p_glUniform4iv; +PFNGLUNIFORMMATRIX2FVPROC p_glUniformMatrix2fv; +PFNGLUNIFORMMATRIX3FVPROC p_glUniformMatrix3fv; +PFNGLUNIFORMMATRIX4FVPROC p_glUniformMatrix4fv; +PFNGLCREATESHADERPROC p_glCreateShader; +PFNGLSHADERSOURCEPROC p_glShaderSource; +PFNGLCOMPILESHADERPROC p_glCompileShader; +PFNGLGETSHADERIVPROC p_glGetShaderiv; +PFNGLGETSHADERINFOLOGPROC p_glGetShaderInfoLog; +PFNGLDELETESHADERPROC p_glDeleteShader; +PFNGLDELETEPROGRAMPROC p_glDeleteProgram; +PFNGLCREATEPROGRAMPROC p_glCreateProgram; +PFNGLATTACHSHADERPROC p_glAttachShader; +PFNGLLINKPROGRAMPROC p_glLinkProgram; +PFNGLGETPROGRAMIVPROC p_glGetProgramiv; +PFNGLGETPROGRAMINFOLOGPROC p_glGetProgramInfoLog; +PFNGLVERTEXATTRIBPOINTERPROC p_glVertexAttribPointer; +PFNGLUSEPROGRAMPROC p_glUseProgram; +PFNGLGETACTIVEUNIFORMPROC p_glGetActiveUniform; +PFNGLGETACTIVEATTRIBPROC p_glGetActiveAttrib; +PFNGLGETUNIFORMLOCATIONPROC p_glGetUniformLocation; +PFNGLGETATTRIBLOCATIONPROC p_glGetAttribLocation; +PFNGLENABLEVERTEXATTRIBARRAYPROC p_glEnableVertexAttribArray; +#endif // GL_VERSION_2_0 +#if GL_VERSION_4_1 +PFNGLRELEASESHADERCOMPILERPROC p_glReleaseShaderCompiler; +PFNGLGETSHADERPRECISIONFORMATPROC p_glGetShaderPrecisionFormat; +#endif // GL_VERSION_4_1 +#endif // FEATURE_GFX_SHADERS +#ifdef MC_GL_DEBUG_OUTPUT +PFNGLDEBUGMESSAGECALLBACKARBPROC p_glDebugMessageCallback; +#endif +#endif +#ifndef USE_OPENGL_2_FEATURES +// Note: don't use xglSwapIntervalEXT if you want vsync, you don't know if it's supported +// on your platform so you need to query the extension APIs +PFNWGLSWAPINTERVALEXTPROC p_wglSwapIntervalEXT; +#endif + +bool xglInitted() +{ +#ifdef USE_HARDWARE_GL_BUFFERS + return p_glActiveTexture + && p_glBindBuffer + && p_glBufferData + && p_glGenBuffers + && p_glDeleteBuffers + && p_glBufferSubData +#if GL_VERSION_2_0 + && p_glStencilFuncSeparate + && p_glStencilOpSeparate +#ifdef FEATURE_GFX_SHADERS + && p_glUniform1i + && p_glUniform1fv + && p_glUniform2fv + && p_glUniform3fv + && p_glUniform4fv + && p_glUniform1iv + && p_glUniform2iv + && p_glUniform3iv + && p_glUniformMatrix2fv + && p_glUniformMatrix3fv + && p_glUniformMatrix4fv + && p_glCreateShader + && p_glShaderSource + && p_glCompileShader + && p_glGetShaderiv + && p_glGetShaderInfoLog + && p_glDeleteShader + && p_glDeleteProgram + && p_glCreateProgram + && p_glAttachShader + && p_glLinkProgram + && p_glGetProgramiv + && p_glGetProgramInfoLog + && p_glVertexAttribPointer + && p_glUseProgram + && p_glGetActiveUniform + && p_glGetActiveAttrib + && p_glGetUniformLocation + && p_glGetAttribLocation + && p_glEnableVertexAttribArray +#endif // FEATURE_GFX_SHADERS +#endif // GL_VERSION_2_0 +#ifdef MC_GL_DEBUG_OUTPUT + && p_glDebugMessageCallback +#endif + ; +#else + return true; +#endif +} + +// Only called on Win32 and SDL+Win32 +void xglInit() +{ +#ifdef USE_HARDWARE_GL_BUFFERS +#ifdef _WIN32 +#if GL_VERSION_1_3 + p_glActiveTexture = (PFNGLACTIVETEXTUREPROC)OGL::GetProcAddress("glActiveTexture"); +#endif +#if GL_VERSION_1_5 + p_glBindBuffer = (PFNGLBINDBUFFERPROC)OGL::GetProcAddress("glBindBuffer"); + p_glBufferData = (PFNGLBUFFERDATAPROC)OGL::GetProcAddress("glBufferData"); + p_glGenBuffers = (PFNGLGENBUFFERSPROC)OGL::GetProcAddress("glGenBuffers"); + p_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)OGL::GetProcAddress("glDeleteBuffers"); + p_glBufferSubData = (PFNGLBUFFERSUBDATAPROC)OGL::GetProcAddress("glBufferSubData"); +#endif +#if GL_VERSION_2_0 + p_glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC)OGL::GetProcAddress("glStencilFuncSeparate"); + p_glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC)OGL::GetProcAddress("glStencilOpSeparate"); +#endif +#ifdef FEATURE_GFX_SHADERS +#if GL_VERSION_2_0 + p_glUniform1i = (PFNGLUNIFORM1IPROC)OGL::GetProcAddress("glUniform1i"); + p_glUniform1fv = (PFNGLUNIFORM1FVPROC)OGL::GetProcAddress("glUniform1fv"); + p_glUniform2fv = (PFNGLUNIFORM2FVPROC)OGL::GetProcAddress("glUniform2fv"); + p_glUniform3fv = (PFNGLUNIFORM3FVPROC)OGL::GetProcAddress("glUniform3fv"); + p_glUniform4fv = (PFNGLUNIFORM4FVPROC)OGL::GetProcAddress("glUniform4fv"); + p_glUniform1iv = (PFNGLUNIFORM1IVPROC)OGL::GetProcAddress("glUniform1iv"); + p_glUniform2iv = (PFNGLUNIFORM2IVPROC)OGL::GetProcAddress("glUniform2iv"); + p_glUniform3iv = (PFNGLUNIFORM3IVPROC)OGL::GetProcAddress("glUniform3iv"); + p_glUniform4iv = (PFNGLUNIFORM4IVPROC)OGL::GetProcAddress("glUniform4iv"); + p_glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)OGL::GetProcAddress("glUniformMatrix2fv"); + p_glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)OGL::GetProcAddress("glUniformMatrix3fv"); + p_glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)OGL::GetProcAddress("glUniformMatrix4fv"); + p_glCreateShader = (PFNGLCREATESHADERPROC)OGL::GetProcAddress("glCreateShader"); + p_glShaderSource = (PFNGLSHADERSOURCEPROC)OGL::GetProcAddress("glShaderSource"); + p_glCompileShader = (PFNGLCOMPILESHADERPROC)OGL::GetProcAddress("glCompileShader"); + p_glGetShaderiv = (PFNGLGETSHADERIVPROC)OGL::GetProcAddress("glGetShaderiv"); + p_glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)OGL::GetProcAddress("glGetShaderInfoLog"); + p_glDeleteShader = (PFNGLDELETESHADERPROC)OGL::GetProcAddress("glDeleteShader"); + p_glDeleteProgram = (PFNGLDELETEPROGRAMPROC)OGL::GetProcAddress("glDeleteProgram"); + p_glCreateProgram = (PFNGLCREATEPROGRAMPROC)OGL::GetProcAddress("glCreateProgram"); + p_glAttachShader = (PFNGLATTACHSHADERPROC)OGL::GetProcAddress("glAttachShader"); + p_glLinkProgram = (PFNGLLINKPROGRAMPROC)OGL::GetProcAddress("glLinkProgram"); + p_glGetProgramiv = (PFNGLGETPROGRAMIVPROC)OGL::GetProcAddress("glGetProgramiv"); + p_glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)OGL::GetProcAddress("glGetProgramInfoLog"); + p_glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)OGL::GetProcAddress("glVertexAttribPointer"); + p_glUseProgram = (PFNGLUSEPROGRAMPROC)OGL::GetProcAddress("glUseProgram"); + p_glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)OGL::GetProcAddress("glGetActiveUniform"); + p_glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC)OGL::GetProcAddress("glGetActiveAttrib"); + p_glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)OGL::GetProcAddress("glGetUniformLocation"); + p_glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)OGL::GetProcAddress("glGetAttribLocation"); + p_glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)OGL::GetProcAddress("glEnableVertexAttribArray"); +#endif // GL_VERSION_2_0 +#if GL_VERSION_4_1 + p_glReleaseShaderCompiler = (PFNGLRELEASESHADERCOMPILERPROC)OGL::GetProcAddress("glReleaseShaderCompiler"); + p_glGetShaderPrecisionFormat = (PFNGLGETSHADERPRECISIONFORMATPROC)OGL::GetProcAddress("glGetShaderPrecisionFormat"); +#endif // GL_VERSION_4_1 +#endif // FEATURE_GFX_SHADERS +#ifdef MC_GL_DEBUG_OUTPUT + p_glDebugMessageCallback = (PFNGLDEBUGMESSAGECALLBACKARBPROC)OGL::GetProcAddress("glDebugMessageCallback"); +#endif +#else // !defined(_WIN32) // wtf would this even be? +#if GL_VERSION_1_3 + p_glActiveTexture = (PFNGLACTIVETEXTUREPROC)glActiveTexture; + p_glLoadTransposeMatrixf = (PFNGLLOADTRANSPOSEMATRIXFPROC)glLoadTransposeMatrixf; +#endif +#if GL_VERSION_1_5 + p_glBindBuffer = (PFNGLBINDBUFFERPROC)glBindBuffer; + p_glBufferData = (PFNGLBUFFERDATAPROC)glBufferData; + p_glGenBuffers = (PFNGLGENBUFFERSPROC)glGenBuffers; + p_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)glDeleteBuffers; + p_glBufferSubData = (PFNGLBUFFERSUBDATAPROC)glBufferSubData; +#endif +#if GL_VERSION_2_0 + p_glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC)glStencilFuncSeparate; + p_glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC)glStencilOpSeparate; +#endif +#ifdef FEATURE_GFX_SHADERS +#if GL_VERSION_2_0 + p_glUniform1i = (PFNGLUNIFORM1IPROC)glUniform1i; + p_glUniform1fv = (PFNGLUNIFORM1FVPROC)glUniform1fv; + p_glUniform2fv = (PFNGLUNIFORM2FVPROC)glUniform2fv; + p_glUniform3fv = (PFNGLUNIFORM3FVPROC)glUniform3fv; + p_glUniform4fv = (PFNGLUNIFORM4FVPROC)glUniform4fv; + p_glUniform1iv = (PFNGLUNIFORM1IVPROC)glUniform1iv; + p_glUniform2iv = (PFNGLUNIFORM2IVPROC)glUniform2iv; + p_glUniform3iv = (PFNGLUNIFORM3IVPROC)glUniform3iv; + p_glUniform4iv = (PFNGLUNIFORM4IVPROC)glUniform4iv; + p_glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)glUniformMatrix2fv; + p_glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)glUniformMatrix3fv; + p_glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)glUniformMatrix4fv; + p_glCreateShader = (PFNGLCREATESHADERPROC)glCreateShader; + p_glShaderSource = (PFNGLSHADERSOURCEPROC)glShaderSource; + p_glCompileShader = (PFNGLCOMPILESHADERPROC)glCompileShader; + p_glGetShaderiv = (PFNGLGETSHADERIVPROC)glGetShaderiv; + p_glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)glGetShaderInfoLog; + p_glDeleteShader = (PFNGLDELETESHADERPROC)glDeleteShader; + p_glDeleteProgram = (PFNGLDELETEPROGRAMPROC)glDeleteProgram; + p_glCreateProgram = (PFNGLCREATEPROGRAMPROC)glCreateProgram; + p_glAttachShader = (PFNGLATTACHSHADERPROC)glAttachShader; + p_glLinkProgram = (PFNGLLINKPROGRAMPROC)glLinkProgram; + p_glGetProgramiv = (PFNGLGETPROGRAMIVPROC)glGetProgramiv; + p_glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)glGetProgramInfoLog; + p_glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)glVertexAttribPointer; + p_glUseProgram = (PFNGLUSEPROGRAMPROC)glUseProgram; + p_glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)glGetActiveUniform; + p_glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC)glGetActiveAttrib; + p_glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)glGetUniformLocation; + p_glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)glGetAttribLocation; + p_glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)glEnableVertexAttribArray; +#endif // GL_VERSION_2_0 +#if GL_VERSION_4_1 + p_glReleaseShaderCompiler = (PFNGLRELEASESHADERCOMPILERPROC)glReleaseShaderCompiler; + p_glGetShaderPrecisionFormat = (PFNGLGETSHADERPRECISIONFORMATPROC)glGetShaderPrecisionFormat; +#endif // GL_VERSION_4_1 +#endif // FEATURE_GFX_SHADERS +#ifdef MC_GL_DEBUG_OUTPUT + p_glDebugMessageCallback = (PFNGLDEBUGMESSAGECALLBACKARBPROC)glDebugMessageCallbackARB; +#endif +#endif +#endif + +#ifndef USE_OPENGL_2_FEATURES + p_wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)OGL::GetProcAddress("wglSwapIntervalEXT"); +#endif +} + +#ifdef USE_HARDWARE_GL_BUFFERS + +#if GL_VERSION_1_3 + +void xglActiveTexture(GLenum texture) +{ + p_glActiveTexture(texture); +} + +#endif // GL_VERSION_1_3 + +#if GL_VERSION_1_5 + +void xglBindBuffer(GLenum target, GLuint buffer) +{ + p_glBindBuffer(target, buffer); +} + +void xglBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) +{ + p_glBufferData(target, size, data, usage); +} + +void xglGenBuffers(GLsizei num, GLuint* buffers) +{ + p_glGenBuffers(num, buffers); +} + +void xglDeleteBuffers(GLsizei num, GLuint* buffers) +{ + p_glDeleteBuffers(num, buffers); +} + +void xglBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data) +{ + p_glBufferSubData(target, offset, size, data); +} + +#endif // GL_VERSION_1_5 + +#if GL_VERSION_2_0 + +void xglStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) +{ + p_glStencilFuncSeparate(face, func, ref, mask); +} + +void xglStencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) +{ + p_glStencilOpSeparate(face, sfail, dpfail, dppass); +} + +#endif // GL_VERSION_2_0 + +#ifdef FEATURE_GFX_SHADERS + +#if GL_VERSION_2_0 + +void xglUniform1i(GLint location, GLint v0) +{ + p_glUniform1i(location, v0); +} + +void xglUniform1fv(GLint location, GLsizei count, const GLfloat* value) +{ + p_glUniform1fv(location, count, value); +} + +void xglUniform2fv(GLint location, GLsizei count, const GLfloat* value) +{ + p_glUniform2fv(location, count, value); +} + +void xglUniform3fv(GLint location, GLsizei count, const GLfloat* value) +{ + p_glUniform3fv(location, count, value); +} + +void xglUniform4fv(GLint location, GLsizei count, const GLfloat* value) +{ + p_glUniform4fv(location, count, value); +} + +void xglUniform1iv(GLint location, GLsizei count, const GLint* value) +{ + p_glUniform1iv(location, count, value); +} + +void xglUniform2iv(GLint location, GLsizei count, const GLint* value) +{ + p_glUniform2iv(location, count, value); +} + +void xglUniform3iv(GLint location, GLsizei count, const GLint* value) +{ + p_glUniform3iv(location, count, value); +} + +void xglUniform4iv(GLint location, GLsizei count, const GLint* value) +{ + p_glUniform4iv(location, count, value); +} + +void xglUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) +{ + p_glUniformMatrix2fv(location, count, transpose, value); +} + +void xglUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) +{ + p_glUniformMatrix3fv(location, count, transpose, value); +} + +void xglUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) +{ + p_glUniformMatrix4fv(location, count, transpose, value); +} + +GLuint xglCreateShader(GLenum type) +{ + return p_glCreateShader(type); +} + +void xglShaderSource(GLuint shader, GLsizei count, const GLchar** string, const GLint* length) +{ + p_glShaderSource(shader, count, string, length); +} + +void xglCompileShader(GLuint shader) +{ + p_glCompileShader(shader); +} + +void xglGetShaderiv(GLuint shader, GLenum pname, GLint* params) +{ + p_glGetShaderiv(shader, pname, params); +} + +void xglGetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog) +{ + p_glGetShaderInfoLog(shader, bufSize, length, infoLog); +} + +void xglDeleteShader(GLuint shader) +{ + p_glDeleteShader(shader); +} + +void xglDeleteProgram(GLuint program) +{ + p_glDeleteProgram(program); +} + +GLuint xglCreateProgram() +{ + return p_glCreateProgram(); +} + +void xglAttachShader(GLuint program, GLuint shader) +{ + p_glAttachShader(program, shader); +} + +void xglLinkProgram(GLuint program) +{ + p_glLinkProgram(program); +} + +void xglGetProgramiv(GLuint program, GLenum pname, GLint* params) +{ + p_glGetProgramiv(program, pname, params); +} + +void xglGetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog) +{ + p_glGetProgramInfoLog(program, bufSize, length, infoLog); +} + +void xglVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* pointer) +{ + p_glVertexAttribPointer(index, size, type, normalized, stride, pointer); +} + +void xglUseProgram(GLuint program) +{ + p_glUseProgram(program); +} + +void xglGetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) +{ + p_glGetActiveUniform(program, index, bufSize, length, size, type, name); +} + +void xglGetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) +{ + p_glGetActiveAttrib(program, index, bufSize, length, size, type, name); +} + +GLint xglGetUniformLocation(GLuint program, const GLchar* name) +{ + return p_glGetUniformLocation(program, name); +} + +GLint xglGetAttribLocation(GLuint program, const GLchar* name) +{ + return p_glGetAttribLocation(program, name); +} + +void xglEnableVertexAttribArray(GLuint index) +{ + p_glEnableVertexAttribArray(index); +} + +#endif // GL_VERSION_2_0 + +#if GL_VERSION_4_1 + +void xglReleaseShaderCompiler() +{ + if (!p_glReleaseShaderCompiler) + return; + + p_glReleaseShaderCompiler(); +} + +void xglGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) +{ + if (!p_glGetShaderPrecisionFormat) + return; + + p_glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision); +} + +#endif // GL_VERSION_4_1 + +#endif // FEATURE_GFX_SHADERS + +#ifdef MC_GL_DEBUG_OUTPUT +void xglDebugMessageCallback(DEBUGPROC callback, GLvoid* userParam) +{ + p_glDebugMessageCallback(callback, userParam); +} +#endif + +void xglEnableClientState(GLenum _array) +{ + glEnableClientState(_array); +} + +void xglDisableClientState(GLenum _array) +{ + glDisableClientState(_array); +} + +void xglTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) +{ + glTexCoordPointer(size, type, stride, pointer); +} + +void xglColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) +{ + glColorPointer(size, type, stride, pointer); +} + +void xglNormalPointer(GLenum type, GLsizei stride, const GLvoid* pointer) +{ +#ifdef USE_GL_NORMAL_LIGHTING + glNormalPointer(type, stride, pointer); +#endif +} + +void xglVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) +{ + glVertexPointer(size, type, stride, pointer); +} + +void xglDrawArrays(GLenum mode, GLint first, GLsizei count) +{ + glDrawArrays(mode, first, count); +} +#endif + +#ifndef xglOrthof + +void xglOrthof(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat nearpl, GLfloat farpl) +{ + return glOrtho(GLdouble(left), GLdouble(right), GLdouble(bottom), GLfloat(top), GLdouble(nearpl), GLdouble(farpl)); +} + +#endif + +void xglSwapIntervalEXT(int interval) +{ +#ifndef USE_OPENGL_2_FEATURES + if (!p_wglSwapIntervalEXT) + return; + + p_wglSwapIntervalEXT(interval); +#endif +} + +#ifndef USE_HARDWARE_GL_BUFFERS + +// ** Incomplete software based emulation of OpenGL vertex buffers. + +#define USE_DISPLAY_LISTS + +struct GLBuffer +{ + GLuint m_id; + GLvoid* m_pBufferData; + GLsizei m_bufferSize; + GLenum m_usage; // as passed into glBufferData + + // vertex pointer + GLint m_vtx_size; + GLenum m_vtx_type; + GLsizei m_vtx_stride; + GLint m_vtx_offset; + + // texture coord pointer + GLint m_tc_size; + GLenum m_tc_type; + GLsizei m_tc_stride; + GLint m_tc_offset; + + // color pointer + GLint m_col_size; + GLenum m_col_type; + GLsizei m_col_stride; + GLint m_col_offset; + + // normal pointer + GLenum m_nor_type; + GLsizei m_nor_stride; + GLint m_nor_offset; + + // associated display list + GLuint m_AssociatedDisplayList; // used if USE_DISPLAY_LISTS is on + + GLBuffer(GLuint id) + { + m_id = id; + m_pBufferData = nullptr; + m_bufferSize = 0; + m_usage = 0; + m_AssociatedDisplayList = 0; + } + + void DeletePreExistingDLIfNeeded() + { +#ifdef USE_DISPLAY_LISTS + if (m_AssociatedDisplayList != 0) + glDeleteLists(m_AssociatedDisplayList, 1); + + m_AssociatedDisplayList = 0; +#endif + } + + bool HasDisplayList() + { +#ifndef USE_DISPLAY_LISTS + return false; +#endif + return m_AssociatedDisplayList != 0; + } + + GLuint GetDisplayList() + { + return m_AssociatedDisplayList; + } + + void SetDisplayList(GLuint dl) + { + m_AssociatedDisplayList = dl; + } + + void SetVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* offset) + { + int ioffset = int(size_t(offset)); + if (m_vtx_size == size && + m_vtx_type == type && + m_vtx_stride == stride && + m_vtx_offset == ioffset) + return; + + DeletePreExistingDLIfNeeded(); + m_vtx_size = size; + m_vtx_type = type; + m_vtx_stride = stride; + m_vtx_offset = ioffset; + } + + void SetTextureCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* offset) + { + int ioffset = int(size_t(offset)); + if (m_tc_size == size && + m_tc_type == type && + m_tc_stride == stride && + m_tc_offset == ioffset) + return; + + DeletePreExistingDLIfNeeded(); + m_tc_size = size; + m_tc_type = type; + m_tc_stride = stride; + m_tc_offset = int(size_t(offset)); + } + + void SetColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* offset) + { + int ioffset = int(size_t(offset)); + if (m_col_size == size && + m_col_type == type && + m_col_stride == stride && + m_col_offset == ioffset) + return; + + DeletePreExistingDLIfNeeded(); + m_col_size = size; + m_col_type = type; + m_col_stride = stride; + m_col_offset = int(size_t(offset)); + } + + void SetNormalPointer(GLenum type, GLsizei stride, const GLvoid* offset) + { + int ioffset = int(size_t(offset)); + if (m_nor_type == type && + m_nor_stride == stride && + m_nor_offset == ioffset) + return; + + DeletePreExistingDLIfNeeded(); + m_nor_type = type; + m_nor_stride = stride; + m_nor_offset = int(size_t(offset)); + } +}; + +typedef std::unordered_map GLBufferMap; + +GLBufferMap g_GLBuffers; +GLBuffer* g_pCurrentlyBoundGLBuffer = nullptr; +GLuint g_NextGLBufferID; +bool g_bUseVertexArrays, g_bUseColorArrays, g_bUseNormalArrays, g_bUseTextureCoordArrays; // modified by xgl[En/Dis]ableClientState + +void xglGenBuffers(GLsizei num, GLuint* buffers) +{ + for (GLsizei i = 0; i < num; i++) + { + *buffers++ = ++g_NextGLBufferID; + g_GLBuffers[g_NextGLBufferID] = new GLBuffer(g_NextGLBufferID); + } + + LOG_I("g_NextGLBufferID=%d", g_NextGLBufferID); +} + +void xglAssert2(bool condition, const char* condstr, const char* file, int line) +{ + if (condition) return; + + LOG_E("Error: Assertion failed at %s:%d: %s", file, line, condstr); + +#ifdef _MSC_VER + assert(false); +#endif + + exit(1); +} +#define xglAssert(condition) xglAssert2(condition,#condition,__FILE__,__LINE__) + +void xglVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) +{ + xglAssert(g_pCurrentlyBoundGLBuffer != nullptr); + g_pCurrentlyBoundGLBuffer->SetVertexPointer(size, type, stride, pointer); +} + +void xglTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) +{ + xglAssert(g_pCurrentlyBoundGLBuffer != nullptr); + g_pCurrentlyBoundGLBuffer->SetTextureCoordPointer(size, type, stride, pointer); +} + +void xglColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) +{ + xglAssert(g_pCurrentlyBoundGLBuffer != nullptr); + g_pCurrentlyBoundGLBuffer->SetColorPointer(size, type, stride, pointer); +} + +void xglNormalPointer(GLenum type, GLsizei stride, const GLvoid* pointer) +{ + xglAssert(g_pCurrentlyBoundGLBuffer != nullptr); + g_pCurrentlyBoundGLBuffer->SetNormalPointer(type, stride, pointer); +} + +void xglBindBuffer(GLenum target, GLuint bufferID) +{ + xglAssert(target == GL_ARRAY_BUFFER); + + GLBufferMap::iterator iter = g_GLBuffers.find(bufferID); + if (iter == g_GLBuffers.end()) + return; + + g_pCurrentlyBoundGLBuffer = iter->second; +} + +void xglBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) +{ + xglAssert(target == GL_ARRAY_BUFFER); + xglAssert(g_pCurrentlyBoundGLBuffer != nullptr); + + GLBuffer* pBuf = g_pCurrentlyBoundGLBuffer; + + // check if the data is the SAME: + if (pBuf->m_bufferSize == size && memcmp(pBuf->m_pBufferData, data, size) == 0) + { + //nope + pBuf->m_usage = usage; + return; + } + + pBuf->DeletePreExistingDLIfNeeded(); + + // free the old data, if there was any + if (pBuf->m_pBufferData) + { + free(pBuf->m_pBufferData); + pBuf->m_pBufferData = nullptr; + } + + pBuf->m_pBufferData = (GLvoid*)malloc(size); + xglAssert(pBuf->m_pBufferData != nullptr); + + memcpy(pBuf->m_pBufferData, data, size); + + pBuf->m_usage = usage; +} + +void xglDeleteBuffer(GLsizei num) +{ + GLBufferMap::iterator iter = g_GLBuffers.find(num); + xglAssert(iter != g_GLBuffers.end()); + + if (iter->second == g_pCurrentlyBoundGLBuffer) + g_pCurrentlyBoundGLBuffer = nullptr; + + iter->second->DeletePreExistingDLIfNeeded(); + + delete iter->second; + g_GLBuffers.erase(iter); +} + +void xglDeleteBuffers(GLsizei num, GLuint* buffers) +{ + for (GLsizei i = 0; i < num; i++) + { + xglDeleteBuffer(buffers[i]); + buffers[i] = 0; + } +} + +void xglEnableClientState(GLenum _array) +{ + switch (_array) + { + case GL_VERTEX_ARRAY: + g_bUseVertexArrays = true; + return; + case GL_COLOR_ARRAY: + g_bUseColorArrays = true; + return; + case GL_NORMAL_ARRAY: + g_bUseNormalArrays = true; + return; + case GL_TEXTURE_COORD_ARRAY: + g_bUseTextureCoordArrays = true; + return; + default: + glEnableClientState(_array); + } +} + +void xglDisableClientState(GLenum _array) +{ + switch (_array) + { + case GL_VERTEX_ARRAY: + g_bUseVertexArrays = false; + return; + case GL_COLOR_ARRAY: + g_bUseColorArrays = false; + return; + case GL_NORMAL_ARRAY: + g_bUseNormalArrays = false; + return; + case GL_TEXTURE_COORD_ARRAY: + g_bUseTextureCoordArrays = false; + return; + default: + glDisableClientState(_array); + } +} + +void xglDrawArrays(GLenum mode, GLint first, GLsizei count) +{ + xglAssert(g_pCurrentlyBoundGLBuffer != nullptr); + GLBuffer* pBuf = g_pCurrentlyBoundGLBuffer; + +#ifdef USE_DISPLAY_LISTS + if (pBuf->HasDisplayList()) + { + glCallList(pBuf->GetDisplayList()); + return; + } + + GLuint currDL = glGenLists(1); + pBuf->SetDisplayList(currDL); + + glNewList(currDL, GL_COMPILE); +#endif + + glBegin(mode); + + for (GLsizeiptr i = first, j = 0; j < count; i++, j++) + { + uintptr_t addr = uintptr_t(pBuf->m_pBufferData); + + void* pVtx = (void*)(addr + pBuf->m_vtx_offset + i * pBuf->m_vtx_stride); + void* pCol = (void*)(addr + pBuf->m_col_offset + i * pBuf->m_col_stride); + void* pNor = (void*)(addr + pBuf->m_col_offset + i * pBuf->m_col_stride); + void* pTC = (void*)(addr + pBuf->m_tc_offset + i * pBuf->m_tc_stride); + + if (g_bUseTextureCoordArrays) + { + if (pBuf->m_tc_type == GL_FLOAT) + { + float* pfTC = (float*)pTC; + /**/ if (pBuf->m_tc_size == 2) + glTexCoord2fv(pfTC); + else xglAssert(!"Unimplemented texcoord size!"); + } + else xglAssert(!"Unimplemented texcoord type!"); + } + + if (g_bUseColorArrays) + { + if (pBuf->m_col_type == GL_UNSIGNED_BYTE) + { + uint8_t* pfCol = (uint8_t*)pCol; + /**/ if (pBuf->m_col_size == 4) + glColor4f(float(pfCol[0])/255.0f, float(pfCol[1])/255.0f, float(pfCol[2])/255.0f, float(pfCol[3])/255.0f); + else xglAssert(!"Unimplemented color size!"); + } + else xglAssert(!"Unimplemented color type!"); + } + + if (g_bUseNormalArrays) + { + //xglAssert(!"Unimplemented normal type!"); + } + + if (g_bUseVertexArrays) + { + if (pBuf->m_vtx_type == GL_FLOAT) + { + float* pfVtx = (float*)pVtx; + /**/ if (pBuf->m_vtx_size == 3) + glVertex3fv(pfVtx); + else if (pBuf->m_vtx_size == 2) + glVertex2fv(pfVtx); + else xglAssert(!"Unimplemented texcoord size!"); + } + else xglAssert(!"Unimplemented vertex type!"); + } + } + + glEnd(); +#ifdef USE_DISPLAY_LISTS + glEndList(); + + glCallList(pBuf->GetDisplayList()); +#endif +} + +#endif + +#endif diff --git a/source/renderer/platform/ogl/Extensions.hpp b/source/renderer/platform/ogl/Extensions.hpp new file mode 100644 index 000000000..63e6bb025 --- /dev/null +++ b/source/renderer/platform/ogl/Extensions.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include "renderer/hal/ogl/API_OGL.hpp" + +namespace mce +{ + namespace Platform + { + namespace OGL + { + bool InitBindings(); + void* GetProcAddress(const char* name); +#ifdef MC_GL_DEBUG_OUTPUT + void APIENTRY DebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam); +#endif + } + } +} \ No newline at end of file diff --git a/source/renderer/platform/ogl/ShaderPrecision.cpp b/source/renderer/platform/ogl/ShaderPrecision.cpp new file mode 100644 index 000000000..0ca550b64 --- /dev/null +++ b/source/renderer/platform/ogl/ShaderPrecision.cpp @@ -0,0 +1,92 @@ +#include + +#include "ShaderPrecision.hpp" + +#include "GameMods.hpp" +#ifdef FEATURE_GFX_SHADERS + +#include "common/Util.hpp" + +using namespace mce::Platform::OGL; + +const std::string Precision::name[3] = { + "lowp", + "mediump", + "highp" +}; + +const std::string Precision::typeName[3] = { + "fragment shader", + "vertex shader", + "geometry shader" +}; + +Precision::Precision(GLenum shaderType) +{ + m_precision[0] = _getPrecision(shaderType, GL_LOW_FLOAT); + m_precision[1] = _getPrecision(shaderType, GL_MEDIUM_FLOAT); + m_precision[2] = _getPrecision(shaderType, GL_HIGH_FLOAT); +} + +GLint Precision::_getPrecision(GLenum shaderType, GLenum precisionType) +{ + GLint range[2]; + GLint precision = -1; + +#if GL_VERSION_4_1 + xglGetShaderPrecisionFormat(shaderType, precisionType, range, &precision); +#endif + + // We only need precision + if (precision == -1) + { + // Default values for GL 4.1 + switch (shaderType) + { + case GL_VERTEX_SHADER: + switch (precisionType) + { + case GL_LOW_FLOAT: + precision = 10; + break; + case GL_MEDIUM_FLOAT: + precision = 10; + break; + case GL_HIGH_FLOAT: + precision = 23; + } + break; + } + } + + return precision; +} + +const std::string& Precision::atLeast(int atleast) +{ + static Precision info(GL_VERTEX_SHADER); + + for (int i = 0; i < 3; i++) + { + if (info.m_precision[i] >= atleast) + { + return name[i]; + } + } + + return Util::EMPTY_STRING; +} + +std::string Precision::buildHeader() +{ + std::stringstream headerStream; + + headerStream << "#define MAT4 " << Precision::atLeast(23) << " mat4\n"; + headerStream << "#define POS4 " << Precision::atLeast(23) << " vec4\n"; + headerStream << "#define POS3 " << Precision::atLeast(23) << " vec3\n"; + headerStream << "precision " << Precision::atLeast(9) << " float;\n"; + + return headerStream.str(); +} + +#endif // FEATURE_GFX_SHADERS \ No newline at end of file diff --git a/source/renderer/platform/ogl/ShaderPrecision.hpp b/source/renderer/platform/ogl/ShaderPrecision.hpp new file mode 100644 index 000000000..dd5b45f36 --- /dev/null +++ b/source/renderer/platform/ogl/ShaderPrecision.hpp @@ -0,0 +1,39 @@ +#pragma once + +#include + +#include "GameMods.hpp" +#ifdef FEATURE_GFX_SHADERS + +#include "renderer/hal/ogl/API_OGL.hpp" + +namespace mce +{ + namespace Platform + { + namespace OGL + { + class Precision + { + public: + static const std::string name[3]; + static const std::string typeName[3]; + + private: + GLint m_precision[3]; + + public: + Precision(GLenum shaderType); + + private: + static GLint _getPrecision(GLenum shaderType, GLenum precisionType); + + public: + static const std::string& atLeast(int atleast); + static std::string buildHeader(); + }; + } + } +} + +#endif // FEATURE_GFX_SHADERS \ No newline at end of file diff --git a/source/server/ServerSideNetworkHandler.cpp b/source/server/ServerSideNetworkHandler.cpp index 6548f23c6..2e1ec0775 100644 --- a/source/server/ServerSideNetworkHandler.cpp +++ b/source/server/ServerSideNetworkHandler.cpp @@ -213,7 +213,7 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, ReadyPacke else pPlayer->m_pInventory->prepareSurvivalInventory(); - m_pMinecraft->m_gui.addMessage(pPlayer->m_name + " joined the game"); + m_pMinecraft->m_pGui->addMessage(pPlayer->m_name + " joined the game"); #if NETWORK_PROTOCOL_VERSION >= 3 // send the connecting player info about all entities in the world @@ -631,7 +631,7 @@ Player* ServerSideNetworkHandler::popPendingPlayer(const RakNet::RakNetGUID& gui void ServerSideNetworkHandler::displayGameMessage(const std::string& msg) { - m_pMinecraft->m_gui.addMessage(msg); + m_pMinecraft->m_pGui->addMessage(msg); m_pRakNetInstance->send(new MessagePacket(msg)); } @@ -639,7 +639,7 @@ void ServerSideNetworkHandler::sendMessage(const RakNet::RakNetGUID& guid, const { if (m_pRakNetPeer->GetMyGUID() == guid) { - m_pMinecraft->m_gui.addMessage(msg); + m_pMinecraft->m_pGui->addMessage(msg); return; } diff --git a/source/world/entity/Arrow.cpp b/source/world/entity/Arrow.cpp index 73bba0311..29062c3c0 100644 --- a/source/world/entity/Arrow.cpp +++ b/source/world/entity/Arrow.cpp @@ -8,7 +8,7 @@ const unsigned int Arrow::ARROW_BASE_DAMAGE = 4; void Arrow::_init() { m_pDescriptor = &EntityTypeDescriptor::arrow; - field_C8 = RENDER_ARROW; + m_renderType = RENDER_ARROW; setSize(0.5f, 0.5f); m_tilePos = Vec3(-1, -1, -1); diff --git a/source/world/entity/Chicken.cpp b/source/world/entity/Chicken.cpp index d81a4b586..7642be65e 100644 --- a/source/world/entity/Chicken.cpp +++ b/source/world/entity/Chicken.cpp @@ -11,7 +11,7 @@ Chicken::Chicken(Level* pLevel) : Animal(pLevel) { m_pDescriptor = &EntityTypeDescriptor::chicken; - field_C8 = RENDER_CHICKEN; + m_renderType = RENDER_CHICKEN; m_texture = "mob/chicken.png"; setSize(0.3f, 0.7f); diff --git a/source/world/entity/Cow.cpp b/source/world/entity/Cow.cpp index dce04c8c2..be0d56953 100644 --- a/source/world/entity/Cow.cpp +++ b/source/world/entity/Cow.cpp @@ -10,7 +10,7 @@ Cow::Cow(Level* pLevel) : Animal(pLevel) { m_pDescriptor = &EntityTypeDescriptor::cow; - field_C8 = RENDER_COW; + m_renderType = RENDER_COW; m_texture = "mob/cow.png"; setSize(0.9f, 1.3f); } diff --git a/source/world/entity/Creeper.cpp b/source/world/entity/Creeper.cpp index 53d3f47b2..184a62ce3 100644 --- a/source/world/entity/Creeper.cpp +++ b/source/world/entity/Creeper.cpp @@ -3,7 +3,7 @@ Creeper::Creeper(Level* pLevel) : Monster(pLevel) { m_pDescriptor = &EntityTypeDescriptor::creeper; - field_C8 = RENDER_CREEPER; + m_renderType = RENDER_CREEPER; m_texture = "mob/creeper.png"; m_swell = 0; m_oldSwell = 0; diff --git a/source/world/entity/Entity.cpp b/source/world/entity/Entity.cpp index 155780683..fdd88a6da 100644 --- a/source/world/entity/Entity.cpp +++ b/source/world/entity/Entity.cpp @@ -55,7 +55,7 @@ void Entity::_init() m_fireTicks = 0; m_flameTime = 1; m_tickCount = 0; - field_C8 = 0; // @NOTE: Render type? (eEntityRenderType) + m_renderType = RENDER_NONE; m_distanceFallen = 0.0f; m_airSupply = TOTAL_AIR_SUPPLY; m_bWasInWater = false; @@ -162,7 +162,7 @@ void Entity::move(const Vec3& pos) bool validSneaking = m_bOnGround && isSneaking(); if (validSneaking) { - for (float dx = 0.05f; pos.x != 0.0f && m_pLevel->getCubes(this, AABB(m_hitbox).move(newPos.x, -1.0f, 0.0f))->size() == 0; cPosX = newPos.x) + for (float dx = 0.05f; newPos.x != 0.0f && m_pLevel->getCubes(this, AABB(m_hitbox).move(newPos.x, -1.0f, 0.0f))->size() == 0; cPosX = newPos.x) { if (newPos.x < dx && newPos.x >= -dx) newPos.x = 0.0; @@ -650,7 +650,27 @@ float Entity::getBrightness(float f) const return m_pLevel->getBrightness(tilePos); } -float Entity::distanceTo(Entity* pEnt) const +Vec3 Entity::getPos(float f) const +{ + if (f == 1.0f) + return m_pos; + + return Vec3( + Mth::Lerp(m_oPos.x, m_pos.x, f), + Mth::Lerp(m_oPos.y, m_pos.y, f), + Mth::Lerp(m_oPos.z, m_pos.z, f) + ); +} + +Vec2 Entity::getRot(float f) const +{ + return Vec2( + Mth::Lerp(m_oRot.x, m_rot.x, f), + Mth::Lerp(m_oRot.y, m_rot.y, f) + ); +} + +float Entity::distanceTo(const Entity* pEnt) const { return distanceTo(pEnt->m_pos); } @@ -660,7 +680,7 @@ float Entity::distanceTo(const Vec3& pos) const return m_pos.distanceTo(pos); } -float Entity::distanceToSqr(Entity* pEnt) const +float Entity::distanceToSqr(const Entity* pEnt) const { return distanceToSqr(pEnt->m_pos); } @@ -873,11 +893,11 @@ void Entity::lavaHurt() } } -int Entity::queryEntityRenderer() +Entity::RenderType Entity::queryEntityRenderer() const { - // If field_C8 is equal to RENDER_DYNAMIC, EntityRenderDispatcher + // If m_renderType is equal to RENDER_DYNAMIC, EntityRenderDispatcher // calls here. Used for sheared sheep. - return 0; + return RENDER_NONE; } const AABB* Entity::getCollideBox() const diff --git a/source/world/entity/Entity.hpp b/source/world/entity/Entity.hpp index 266459d18..87b262d57 100644 --- a/source/world/entity/Entity.hpp +++ b/source/world/entity/Entity.hpp @@ -11,6 +11,7 @@ #include "world/phys/Vec3.hpp" #include "world/phys/Vec2.hpp" #include "world/phys/AABB.hpp" +#include "world/level/Dimension.hpp" #include "world/level/Material.hpp" #include "world/level/levelgen/chunk/ChunkPos.hpp" #include "world/tile/Tile.hpp" @@ -27,30 +28,6 @@ class Player; class ItemInstance; class ItemEntity; -enum eEntityRenderType -{ - RENDER_NONE, - RENDER_DYNAMIC, - RENDER_TNT, - RENDER_HUMANOID, - RENDER_ITEM, - RENDER_CAMERA, - RENDER_CHICKEN, - RENDER_COW, - RENDER_PIG, - RENDER_SHEEP, - RENDER_SHEEP_FUR, - RENDER_ZOMBIE, - RENDER_SKELETON, - RENDER_SPIDER, - RENDER_CREEPER, - RENDER_ROCKET, - RENDER_ARROW, - - // custom - RENDER_FALLING_TILE = 50, -}; - struct EntityPos { Vec3 m_pos; @@ -103,6 +80,29 @@ class Entity STOP_ATTACKING }; }; + enum RenderType + { + RENDER_NONE, + RENDER_DYNAMIC, + RENDER_TNT, + RENDER_HUMANOID, + RENDER_ITEM, + RENDER_CAMERA, + RENDER_CHICKEN, + RENDER_COW, + RENDER_PIG, + RENDER_SHEEP, + RENDER_SHEEP_FUR, + RENDER_ZOMBIE, + RENDER_SKELETON, + RENDER_SPIDER, + RENDER_CREEPER, + RENDER_ROCKET, + RENDER_ARROW, + + // custom + RENDER_FALLING_TILE = 50, + }; private: void _init(); @@ -144,10 +144,13 @@ class Entity virtual float getHeadHeight() const { return 0.0f; } virtual float getShadowHeightOffs() const { return m_bbHeight / 2.0f; } virtual float getBrightness(float f) const; - virtual float distanceTo(Entity*) const; + virtual DimensionId getDimensionId() const { return m_dimensionId; } + virtual Vec3 getPos(float f) const; + virtual Vec2 getRot(float f) const; + virtual float distanceTo(const Entity*) const; virtual float distanceToSqr(const Vec3& pos) const; virtual float distanceTo(const Vec3& pos) const; - virtual float distanceToSqr(Entity*) const; + virtual float distanceToSqr(const Entity*) const; virtual int interactPreventDefault(); virtual bool interact(Player*); virtual void playerTouch(Player*); @@ -185,7 +188,7 @@ class Entity virtual void markHurt(); virtual void burn(int); virtual void lavaHurt(); - virtual int queryEntityRenderer(); + virtual RenderType queryEntityRenderer() const; virtual const AABB* getCollideBox() const; virtual AABB* getCollideAgainstBox(Entity* ent) const; virtual void handleInsidePortal(); @@ -230,6 +233,8 @@ class Entity int field_28; Entity::ID m_EntityID; float field_30; + //TileSource* m_pTileSource; + DimensionId m_dimensionId; bool m_bBlocksBuilding; Level* m_pLevel; Vec3 m_oPos; // "o" in Java or "xo" "yo" "zo" @@ -262,7 +267,7 @@ class Entity int m_airCapacity; int16_t m_fireTicks; int m_flameTime; - int field_C8; // @NOTE: Render type? (eEntityRenderType) + RenderType m_renderType; float m_distanceFallen; // Supposed to be protected int16_t m_airSupply; bool m_bWasInWater; diff --git a/source/world/entity/FallingTile.cpp b/source/world/entity/FallingTile.cpp index 86c5cc98b..dab99784c 100644 --- a/source/world/entity/FallingTile.cpp +++ b/source/world/entity/FallingTile.cpp @@ -29,7 +29,7 @@ FallingTile::FallingTile(Level* level, const Vec3& pos, int id) : Entity(level), m_vel = Vec3::ZERO; #if defined(ENH_ALLOW_SAND_GRAVITY) - field_C8 = RENDER_FALLING_TILE; + m_renderType = RENDER_FALLING_TILE; #endif } diff --git a/source/world/entity/ItemEntity.cpp b/source/world/entity/ItemEntity.cpp index 0afae862c..7ff3573c6 100644 --- a/source/world/entity/ItemEntity.cpp +++ b/source/world/entity/ItemEntity.cpp @@ -13,7 +13,7 @@ void ItemEntity::_init(ItemInstance* itemInstance) { m_pDescriptor = &EntityTypeDescriptor::item; - field_C8 = RENDER_ITEM; + m_renderType = RENDER_ITEM; m_age = 0; m_throwTime = 0; m_tickCount = 0; diff --git a/source/world/entity/Mob.cpp b/source/world/entity/Mob.cpp index 044245c86..a61636ebf 100644 --- a/source/world/entity/Mob.cpp +++ b/source/world/entity/Mob.cpp @@ -791,26 +791,6 @@ float Mob::getAttackAnim(float f) const return m_oAttackAnim + (x * f); } -Vec3 Mob::getPos(float f) const -{ - if (f == 1.0f) - return m_pos; - - return Vec3( - Mth::Lerp(m_oPos.x, m_pos.x, f), - Mth::Lerp(m_oPos.y, m_pos.y, f), - Mth::Lerp(m_oPos.z, m_pos.z, f) - ); -} - -Vec2 Mob::getRot(float f) const -{ - return Vec2( - Mth::Lerp(m_oRot.x, m_rot.x, f), - Mth::Lerp(m_oRot.y, m_rot.y, f) - ); -} - Vec3 Mob::getViewVector(float f) const { constexpr float C_180_OVER_PI = 0.017453f; diff --git a/source/world/entity/Mob.hpp b/source/world/entity/Mob.hpp index 797806f13..c49388894 100644 --- a/source/world/entity/Mob.hpp +++ b/source/world/entity/Mob.hpp @@ -68,12 +68,10 @@ class Mob : public Entity virtual void beforeRemove() {} virtual bool canSpawn(); virtual float getAttackAnim(float f) const; - virtual Vec3 getPos(float f) const; - virtual Vec2 getRot(float f) const; virtual Vec3 getLookAngle(float f) const { return getViewVector(1.0f); } virtual Vec3 getViewVector(float f) const; virtual int getMaxSpawnClusterSize() const { return 4; } - virtual ItemInstance* getCarriedItem() { return nullptr; } + virtual ItemInstance* getCarriedItem() const { return nullptr; } virtual bool isBaby() const { return false; } virtual bool removeWhenFarAway() const { return true; } virtual int getDeathLoot() const { return 0; } diff --git a/source/world/entity/Pig.cpp b/source/world/entity/Pig.cpp index cf2deba79..153163f49 100644 --- a/source/world/entity/Pig.cpp +++ b/source/world/entity/Pig.cpp @@ -10,7 +10,7 @@ Pig::Pig(Level* pLevel) : Animal(pLevel) { m_pDescriptor = &EntityTypeDescriptor::pig; - field_C8 = RENDER_PIG; + m_renderType = RENDER_PIG; m_texture = "mob/pig.png"; setSize(0.9f, 0.9f); // some dataitem stuff diff --git a/source/world/entity/Player.cpp b/source/world/entity/Player.cpp index 19abc7958..6fddc4aa1 100644 --- a/source/world/entity/Player.cpp +++ b/source/world/entity/Player.cpp @@ -29,7 +29,7 @@ Player::Player(Level* pLevel, GameType playerGameType) : Mob(pLevel) m_name = ""; m_bHasRespawnPos = false; - field_C8 = RENDER_HUMANOID; + m_renderType = RENDER_HUMANOID; setPlayerGameType(playerGameType); @@ -218,7 +218,7 @@ void Player::aiStep() updateAttackAnim(); } -ItemInstance* Player::getCarriedItem() +ItemInstance* Player::getCarriedItem() const { // This only gets the first row slot /*ItemInstance* item = m_pInventory->getItem(m_pInventory->m_selectedHotbarSlot); @@ -334,6 +334,11 @@ int Player::getInventorySlot(int x) const return 0; } +Dimension* Player::getDimension() const +{ + return m_pLevel->getDimension(getDimensionId()); +} + void Player::prepareCustomTextures() { diff --git a/source/world/entity/Player.hpp b/source/world/entity/Player.hpp index 884f099a0..adb457af8 100644 --- a/source/world/entity/Player.hpp +++ b/source/world/entity/Player.hpp @@ -46,7 +46,7 @@ class Player : public Mob void resetPos(bool respawn = false) override; void die(Entity* pCulprit) override; void aiStep() override; - ItemInstance* getCarriedItem() override; + ItemInstance* getCarriedItem() const override; bool isImmobile() const override { return m_health <= 0; } void updateAi() override; void addAdditionalSaveData(CompoundTag& tag) const override; @@ -73,6 +73,7 @@ class Player : public Mob int getInventorySlot(int x) const; TilePos getRespawnPosition() const { return m_respawnPos; } int getScore() const { return m_score; } + Dimension* getDimension() const; void prepareCustomTextures(); void respawn(); void rideTick(); diff --git a/source/world/entity/PrimedTnt.cpp b/source/world/entity/PrimedTnt.cpp index 084c625d0..e9376f0fc 100644 --- a/source/world/entity/PrimedTnt.cpp +++ b/source/world/entity/PrimedTnt.cpp @@ -13,7 +13,7 @@ void PrimedTnt::_init() { m_fuseTimer = 0; - field_C8 = RENDER_TNT; + m_renderType = RENDER_TNT; m_bBlocksBuilding = true; setSize(0.98f, 0.98f); m_heightOffset = m_bbHeight * 0.5f; diff --git a/source/world/entity/Rocket.cpp b/source/world/entity/Rocket.cpp index b5b8ccad0..73ed2ee93 100644 --- a/source/world/entity/Rocket.cpp +++ b/source/world/entity/Rocket.cpp @@ -14,7 +14,7 @@ Rocket::Rocket(Level* level, const Vec3& pos) : Entity(level) { field_B8C = 0; field_B90 = 80; - field_C8 = RENDER_ROCKET; + m_renderType = RENDER_ROCKET; m_bBlocksBuilding = true; diff --git a/source/world/entity/Sheep.cpp b/source/world/entity/Sheep.cpp index 4f933e705..4a65ebc21 100644 --- a/source/world/entity/Sheep.cpp +++ b/source/world/entity/Sheep.cpp @@ -4,23 +4,23 @@ #define DATA_WOOL_ID (16) -const float Sheep::COLOR[][3] = { - {1.00f, 1.00f, 1.00f}, - {0.95f, 0.70f, 0.20f}, - {0.90f, 0.50f, 0.85f}, - {0.60f, 0.70f, 0.95f}, - {0.90f, 0.90f, 0.20f}, - {0.50f, 0.80f, 0.10f}, - {0.95f, 0.70f, 0.80f}, - {0.30f, 0.30f, 0.30f}, - {0.60f, 0.60f, 0.60f}, - {0.30f, 0.60f, 0.70f}, - {0.70f, 0.40f, 0.90f}, - {0.20f, 0.40f, 0.80f}, - {0.50f, 0.40f, 0.30f}, - {0.40f, 0.50f, 0.20f}, - {0.80f, 0.30f, 0.30f}, - {0.10f, 0.10f, 0.10f} +const Color Sheep::COLOR[] = { + Color(1.00f, 1.00f, 1.00f), + Color(0.95f, 0.70f, 0.20f), + Color(0.90f, 0.50f, 0.85f), + Color(0.60f, 0.70f, 0.95f), + Color(0.90f, 0.90f, 0.20f), + Color(0.50f, 0.80f, 0.10f), + Color(0.95f, 0.70f, 0.80f), + Color(0.30f, 0.30f, 0.30f), + Color(0.60f, 0.60f, 0.60f), + Color(0.30f, 0.60f, 0.70f), + Color(0.70f, 0.40f, 0.90f), + Color(0.20f, 0.40f, 0.80f), + Color(0.50f, 0.40f, 0.30f), + Color(0.40f, 0.50f, 0.20f), + Color(0.80f, 0.30f, 0.30f), + Color(0.10f, 0.10f, 0.10f) }; const unsigned int Sheep::COLOR_COUNT = sizeof(Sheep::COLOR) / (sizeof(float) * 3); @@ -28,7 +28,7 @@ const unsigned int Sheep::COLOR_COUNT = sizeof(Sheep::COLOR) / (sizeof(float) * Sheep::Sheep(Level* pLevel) : Animal(pLevel) { m_pDescriptor = &EntityTypeDescriptor::sheep; - field_C8 = RENDER_SHEEP; + m_renderType = RENDER_SHEEP; m_texture = "mob/sheep.png"; setSize(0.9f, 1.3f); diff --git a/source/world/entity/Sheep.hpp b/source/world/entity/Sheep.hpp index 340f49bb4..6cd8f69bc 100644 --- a/source/world/entity/Sheep.hpp +++ b/source/world/entity/Sheep.hpp @@ -1,11 +1,12 @@ #pragma once #include "Animal.hpp" +#include "common/math/Color.hpp" class Sheep : public Animal { public: - static const float COLOR[][3]; + static const Color COLOR[]; static const unsigned int COLOR_COUNT; // NumColors on PE, stupid name public: diff --git a/source/world/entity/Skeleton.cpp b/source/world/entity/Skeleton.cpp index 212b405fb..1f378d8d3 100644 --- a/source/world/entity/Skeleton.cpp +++ b/source/world/entity/Skeleton.cpp @@ -3,7 +3,7 @@ Skeleton::Skeleton(Level* pLevel) : Monster(pLevel) { m_pDescriptor = &EntityTypeDescriptor::skeleton; - field_C8 = RENDER_SKELETON; + m_renderType = RENDER_SKELETON; m_texture = "mob/skeleton.png"; } @@ -57,7 +57,7 @@ void Skeleton::dropDeathLoot() } ItemInstance* Skeleton::bow = nullptr; -ItemInstance* Skeleton::getCarriedItem() +ItemInstance* Skeleton::getCarriedItem() const { if (!bow) bow = new ItemInstance(Item::bow, 1); diff --git a/source/world/entity/Skeleton.hpp b/source/world/entity/Skeleton.hpp index e1653f9b4..7a2a99e55 100644 --- a/source/world/entity/Skeleton.hpp +++ b/source/world/entity/Skeleton.hpp @@ -23,5 +23,5 @@ class Skeleton : public Monster void dropDeathLoot() override; - ItemInstance* getCarriedItem() override; + ItemInstance* getCarriedItem() const override; }; \ No newline at end of file diff --git a/source/world/entity/Spider.cpp b/source/world/entity/Spider.cpp index 47c39e095..8da067666 100644 --- a/source/world/entity/Spider.cpp +++ b/source/world/entity/Spider.cpp @@ -3,7 +3,7 @@ Spider::Spider(Level* pLevel) : Monster(pLevel) { m_pDescriptor = &EntityTypeDescriptor::spider; - field_C8 = RENDER_SPIDER; + m_renderType = RENDER_SPIDER; m_texture = "mob/spider.png"; setSize(1.4f, 0.9f); diff --git a/source/world/entity/TripodCamera.cpp b/source/world/entity/TripodCamera.cpp index db487bd37..aa193e799 100644 --- a/source/world/entity/TripodCamera.cpp +++ b/source/world/entity/TripodCamera.cpp @@ -17,7 +17,7 @@ TripodCamera::TripodCamera(Level* level, Player* player, const Vec3& pos) : Mob( m_bActive = false; m_owner = player; - field_C8 = RENDER_CAMERA; + m_renderType = RENDER_CAMERA; m_oRot = m_rot = player->m_rot; diff --git a/source/world/entity/Zombie.cpp b/source/world/entity/Zombie.cpp index 1b431ea47..ec5db143d 100644 --- a/source/world/entity/Zombie.cpp +++ b/source/world/entity/Zombie.cpp @@ -3,7 +3,7 @@ Zombie::Zombie(Level* pLevel) : Monster(pLevel) { m_pDescriptor = &EntityTypeDescriptor::zombie; - field_C8 = RENDER_ZOMBIE; + m_renderType = RENDER_ZOMBIE; m_texture = "mob/zombie.png"; m_runSpeed = 0.5f; m_attackDamage = 5; diff --git a/source/world/gamemode/CreativeMode.cpp b/source/world/gamemode/CreativeMode.cpp index fbd53dd03..79ddfda5d 100644 --- a/source/world/gamemode/CreativeMode.cpp +++ b/source/world/gamemode/CreativeMode.cpp @@ -62,14 +62,14 @@ void CreativeMode::render(float f) { if (m_destroyProgress <= 0.0f) { - m_pMinecraft->m_gui.field_8 = 0.0f; - m_pMinecraft->m_pLevelRenderer->field_10 = 0.0f; + m_pMinecraft->m_pGui->m_progress = 0.0f; + m_pMinecraft->m_pLevelRenderer->m_destroyProgress = 0.0f; } else { float x = m_lastDestroyProgress + (m_destroyProgress - m_lastDestroyProgress) * f; - m_pMinecraft->m_gui.field_8 = x; - m_pMinecraft->m_pLevelRenderer->field_10 = x; + m_pMinecraft->m_pGui->m_progress = x; + m_pMinecraft->m_pLevelRenderer->m_destroyProgress = x; } } diff --git a/source/world/gamemode/SurvivalMode.cpp b/source/world/gamemode/SurvivalMode.cpp index 90e45f4a5..23868c567 100644 --- a/source/world/gamemode/SurvivalMode.cpp +++ b/source/world/gamemode/SurvivalMode.cpp @@ -151,14 +151,14 @@ void SurvivalMode::render(float f) { if (m_destroyProgress <= 0.0f) { - m_pMinecraft->m_gui.field_8 = 0.0f; - m_pMinecraft->m_pLevelRenderer->field_10 = 0.0f; + m_pMinecraft->m_pGui->m_progress = 0.0f; + m_pMinecraft->m_pLevelRenderer->m_destroyProgress = 0.0f; } else { - float x = m_lastDestroyProgress + (m_destroyProgress - m_lastDestroyProgress) * f; - m_pMinecraft->m_gui.field_8 = x; - m_pMinecraft->m_pLevelRenderer->field_10 = x; + float dp = m_lastDestroyProgress + (m_destroyProgress - m_lastDestroyProgress) * f; + m_pMinecraft->m_pGui->m_progress = dp; + m_pMinecraft->m_pLevelRenderer->m_destroyProgress = dp; } } diff --git a/source/world/level/Dimension.cpp b/source/world/level/Dimension.cpp index 96689fdf2..2b6bd46d5 100644 --- a/source/world/level/Dimension.cpp +++ b/source/world/level/Dimension.cpp @@ -11,18 +11,21 @@ #include "world/level/levelgen/chunk/TestChunkSource.hpp" #include "world/level/levelgen/chunk/RandomLevelSource.hpp" #include "world/level/levelgen/chunk/ChunkCache.hpp" +#include "world/level/levelgen/biome/BiomeSource.hpp" +#include "world/level/levelgen/chunk/ChunkSource.hpp" +#include "Level.hpp" #define C_TIMEOFDAY_SCALE_JAVA 24000 #define C_TIMEOFDAY_SCALE_POCKET 14400 #define C_TIMEOFDAY_SCALE C_TIMEOFDAY_SCALE_JAVA -Dimension* Dimension::getNew(int type) +Dimension* Dimension::createNew(DimensionId type) { switch (type) { - case 0: + case DIMENSION_NORMAL: return new Dimension; - /*case -1: + /*case DIMENSION_HELL: return new HellDimension;*/ default: // type not supported return nullptr; @@ -120,15 +123,24 @@ float Dimension::getTimeOfDay(int32_t l, float f) void Dimension::updateLightRamp() { - for (int i = 0; i < 16; i++) + constexpr float var1 = 0.05f; + + for (int i = 0; i <= Brightness::MAX; i++) { + float f1 = float(i) / Brightness::MAX; + float f2 = 1.0f - f1; + #ifdef ENH_USE_JAVA_LIGHT_RAMP - float f1 = 1.0f - float(i) / 15.0f; - field_10[i] = ((1.0f - f1) / (f1 * 3.0f + 1.0f)) * (1.0f - 0.1f) + 0.1f; + m_brightnessRamp[i] = ((1.0f - f2) / (f2 * 3.0f + 1.0f)) * (1.0f - var1) + var1; #else + // 0.1.0 // @NOTE: Adjusted calculation causes full bright tiles to render at 80% brightness. // This was probably done so that highlighted tiles don't have their brightness blown up and the texture doesn't look weird. - field_10[i] = ((1.0f - ((i * -0.0625f) + 1.0f)) / ((((i * -0.0625f) + 1.0f) * 3.0f) + 1.0f)) * 0.95f + 0.05f; + m_brightnessRamp[i] = ((1.0f - ((i * -0.0625f) + 1.0f)) / ((((i * -0.0625f) + 1.0f) * 3.0f) + 1.0f)) * 0.95f + 0.05f; + + // 0.12.1 + /*float v6 = f1 / ((f2 * 3.0f) + 1.0f); + m_brightnessRamp[i] = Mth::clamp(v6, 0.0f, 1.0f);*/ #endif } } diff --git a/source/world/level/Dimension.hpp b/source/world/level/Dimension.hpp index b2b5a8249..978f36ac9 100644 --- a/source/world/level/Dimension.hpp +++ b/source/world/level/Dimension.hpp @@ -9,18 +9,23 @@ #pragma once #include "world/phys/Vec3.hpp" -#include "world/level/levelgen/biome/BiomeSource.hpp" -#include "world/level/levelgen/chunk/ChunkSource.hpp" -#include "Level.hpp" class Level; // if included from Level.hpp +class ChunkSource; +class BiomeSource; + +enum DimensionId +{ + DIMENSION_NORMAL, + DIMENSION_HELL +}; class Dimension { public: Dimension(); virtual ~Dimension(); - static Dimension* getNew(int type); + static Dimension* createNew(DimensionId type); virtual Vec3 getFogColor(float, float); virtual void init(); @@ -40,7 +45,7 @@ class Dimension bool m_bFoggy; bool field_D; bool field_E; - float field_10[16]; + float m_brightnessRamp[16]; int field_50; float m_sunriseColor[4]; }; diff --git a/source/world/level/Explosion.hpp b/source/world/level/Explosion.hpp index 3f280dde0..1ea15aff8 100644 --- a/source/world/level/Explosion.hpp +++ b/source/world/level/Explosion.hpp @@ -29,7 +29,7 @@ class Explosion Vec3 m_pos; float m_power; - //field_10, m_noEntityRenderFrames, m_totalEntities, m_renderedEntities - Likely a set + //m_destroyProgress, m_noEntityRenderFrames, m_totalEntities, m_renderedEntities - Likely a set std::set m_tiles; int field_20; diff --git a/source/world/level/Level.cpp b/source/world/level/Level.cpp index f547e2e72..36a1bc16f 100644 --- a/source/world/level/Level.cpp +++ b/source/world/level/Level.cpp @@ -20,6 +20,9 @@ #include "Explosion.hpp" #include "Region.hpp" +float Brightness::MIN = 0; +float Brightness::MAX = 15; + Level::Level(LevelStorage* pStor, const std::string& name, const LevelSettings& settings, int storageVersion, Dimension *pDimension) { m_bInstantTicking = false; @@ -151,6 +154,11 @@ BiomeSource* Level::getBiomeSource() const return m_pDimension->m_pBiomeSource; } +Dimension* Level::getDimension(DimensionId type) const +{ + return m_pDimension; +} + ChunkSource* Level::getChunkSource() const { return m_pChunkSource; @@ -199,7 +207,7 @@ int Level::getBrightness(const LightLayer& ll, const TilePos& pos) const float Level::getBrightness(const TilePos& pos) const { - return m_pDimension->field_10[getRawBrightness(pos)]; + return m_pDimension->m_brightnessRamp[getRawBrightness(pos)]; } int Level::getRawBrightness(const TilePos& pos) const @@ -1340,14 +1348,12 @@ bool Level::canSeeSky(const TilePos& pos) const return pChunk->isSkyLit(pos); } -Vec3 Level::getSkyColor(Entity* pEnt, float f) const +Vec3 Level::getSkyColor(const Entity& entity, float f) const { Vec3 result; float fTODCosAng = Mth::cos(getSunAngle(f)); - // @TODO: Fix the gotos - result.z = 2 * fTODCosAng + 0.5f; if (result.z < 0.0f) result.z = 0.0f; @@ -1355,8 +1361,8 @@ Vec3 Level::getSkyColor(Entity* pEnt, float f) const result.z = 1.0f; // @NOTE: Unused result. In JE, it tries to get the biome that the player is standing in. - Mth::floor(pEnt->m_pos.x); - Mth::floor(pEnt->m_pos.z); + //Mth::floor(entity.m_pos.x); + //Mth::floor(entity.m_pos.z); result.x = result.z * 0.6f; result.y = result.x; diff --git a/source/world/level/Level.hpp b/source/world/level/Level.hpp index 900b9005d..62c5554d0 100644 --- a/source/world/level/Level.hpp +++ b/source/world/level/Level.hpp @@ -37,6 +37,11 @@ class RakNetInstance; typedef std::vector EntityVector; typedef std::vector AABBVector; +struct Brightness +{ + static float MIN, MAX; +}; + class Level : public LevelSource { public: @@ -129,7 +134,7 @@ class Level : public LevelSource void setSpawnPos(const TilePos& pos) { m_pLevelData->setSpawn(pos); } void setSpawnSettings(bool a, bool b) { } bool canSeeSky(const TilePos& pos) const; - Vec3 getSkyColor(Entity* pEnt, float f) const; + Vec3 getSkyColor(const Entity& entity, float f) const; Vec3 getFogColor(float f) const; Vec3 getCloudColor(float f) const; bool isUnobstructed(AABB*) const; @@ -170,6 +175,7 @@ class Level : public LevelSource EntityVector getEntities(Entity* pAvoid, const AABB&) const; BiomeSource* getBiomeSource() const override; LevelStorage* getLevelStorage() const { return m_pLevelStorage; } + Dimension* getDimension(DimensionId type) const; const LevelData* getLevelData() const { return m_pLevelData; } AABBVector* getCubes(const Entity* pEnt, const AABB& aabb); std::vector* getLightsToUpdate(); diff --git a/source/world/level/Region.cpp b/source/world/level/Region.cpp index e38196cb7..9a7109ce6 100644 --- a/source/world/level/Region.cpp +++ b/source/world/level/Region.cpp @@ -73,7 +73,7 @@ int Region::getRawBrightness(const TilePos& pos) const float Region::getBrightness(const TilePos& pos) const { - return m_pLevel->m_pDimension->field_10[getRawBrightness(pos)]; + return m_pLevel->m_pDimension->m_brightnessRamp[getRawBrightness(pos)]; } TileData Region::getData(const TilePos& pos) const diff --git a/source/world/level/TilePos.cpp b/source/world/level/TilePos.cpp index 12310c482..bafc10b8b 100644 --- a/source/world/level/TilePos.cpp +++ b/source/world/level/TilePos.cpp @@ -23,7 +23,7 @@ TilePos::TilePos() TilePos::TilePos(int _x, int _y, int _z) { - _init(_x, _y < 0 ? 0 : _y, _z); + _init(_x, _y, _z); } TilePos::TilePos(float _x, float _y, float _z) diff --git a/source/world/particle/ParticleEngine.cpp b/source/world/particle/ParticleEngine.cpp index cafd62851..f57c7c59f 100644 --- a/source/world/particle/ParticleEngine.cpp +++ b/source/world/particle/ParticleEngine.cpp @@ -8,6 +8,13 @@ #include #include "ParticleEngine.hpp" +#include "client/renderer/renderer/RenderMaterialGroup.hpp" + +ParticleEngine::Materials::Materials() +{ + MATERIAL_PTR(common, particles_opaque); + MATERIAL_PTR(common, particles_alpha); +} ParticleEngine::ParticleEngine(Level* level, Textures* textures) { @@ -142,22 +149,22 @@ void ParticleEngine::destroyEffect(const TilePos& pos) bool g_bDisableParticles; #endif -void ParticleEngine::render(Entity* ent, float f) +void ParticleEngine::render(const Entity& camera, float f) { #ifdef ENH_CAMERA_NO_PARTICLES if (g_bDisableParticles) return; #endif - float x1 = Mth::cos(float(M_PI) * ent->m_rot.x / 180.0f); - float x3 = Mth::sin(float(M_PI) * ent->m_rot.x / 180.0f); - float x4 = -(x3 * Mth::sin(float(M_PI) * ent->m_rot.y / 180.0f)); - float x5 = x1 * Mth::sin(float(M_PI) * ent->m_rot.y / 180.0f); - float x2 = Mth::cos(float(M_PI) * ent->m_rot.y / 180.0f); + float x1 = Mth::cos(float(M_PI) * camera.m_rot.x / 180.0f); + float x3 = Mth::sin(float(M_PI) * camera.m_rot.x / 180.0f); + float x4 = -(x3 * Mth::sin(float(M_PI) * camera.m_rot.y / 180.0f)); + float x5 = x1 * Mth::sin(float(M_PI) * camera.m_rot.y / 180.0f); + float x2 = Mth::cos(float(M_PI) * camera.m_rot.y / 180.0f); - Particle::xOff = Mth::Lerp(ent->m_posPrev.x, ent->m_pos.x, f); - Particle::yOff = Mth::Lerp(ent->m_posPrev.y, ent->m_pos.y, f); - Particle::zOff = Mth::Lerp(ent->m_posPrev.z, ent->m_pos.z, f); + Particle::xOff = Mth::Lerp(camera.m_posPrev.x, camera.m_pos.x, f); + Particle::yOff = Mth::Lerp(camera.m_posPrev.y, camera.m_pos.y, f); + Particle::zOff = Mth::Lerp(camera.m_posPrev.z, camera.m_pos.z, f); // @BUG: Ignoring the last particle array. Invisible? Tesselator& t = Tesselator::instance; @@ -168,7 +175,7 @@ void ParticleEngine::render(Entity* ent, float f) else m_pTextures->loadAndBindTexture("particles.png"); - t.begin(); + t.begin(4 * m_particles[i].size()); for (std::vector::iterator it = m_particles[i].begin(); it != m_particles[i].end(); it++) { @@ -176,11 +183,11 @@ void ParticleEngine::render(Entity* ent, float f) pParticle->render(t, f, x1, x2, x3, x4, x5); } - t.draw(); + t.draw(m_materials.particles_alpha); } } -void ParticleEngine::renderLit(Entity* player, float a) +void ParticleEngine::renderLit(const Entity& camera, float a) { int tt = 3; if (m_particles[tt].size() != 0) diff --git a/source/world/particle/ParticleEngine.hpp b/source/world/particle/ParticleEngine.hpp index e53d4394d..3ca4a0515 100644 --- a/source/world/particle/ParticleEngine.hpp +++ b/source/world/particle/ParticleEngine.hpp @@ -14,6 +14,16 @@ class ParticleEngine { +protected: + class Materials + { + public: + mce::MaterialPtr particles_opaque; + mce::MaterialPtr particles_alpha; + + Materials(); + }; + public: ParticleEngine(Level*, Textures*); @@ -21,8 +31,8 @@ class ParticleEngine std::string countParticles(); void crack(const TilePos& tilePos, Facing::Name face); void destroyEffect(const TilePos& pos); - void render(Entity*, float f); - void renderLit(Entity*, float a); + void render(const Entity& camera, float f); + void renderLit(const Entity& camera, float a); void tick(); void setLevel(Level*); @@ -32,5 +42,6 @@ class ParticleEngine std::vector m_particles[4]; Textures* m_pTextures; Random m_random; + Materials m_materials; }; diff --git a/source/world/phys/HitResult.cpp b/source/world/phys/HitResult.cpp index aabd9e00d..a843dc307 100644 --- a/source/world/phys/HitResult.cpp +++ b/source/world/phys/HitResult.cpp @@ -16,10 +16,10 @@ void HitResult::_init() m_hitSide = Facing::DOWN; m_pEnt = nullptr; - m_bUnk24 = 0; + m_bUnk24 = false; } -HitResult::HitResult(const TilePos& tilePos, Facing::Name hitSide, const Vec3& vec) +HitResult::HitResult(const TilePos& tilePos, Facing::Name hitSide, const Vec3& pos) { _init(); @@ -27,7 +27,7 @@ HitResult::HitResult(const TilePos& tilePos, Facing::Name hitSide, const Vec3& v m_hitSide = hitSide; m_tilePos = tilePos; m_bUnk24 = false; - m_hitPos = vec; + m_hitPos = pos; } HitResult::HitResult(Entity* pEnt) diff --git a/source/world/phys/HitResult.hpp b/source/world/phys/HitResult.hpp index 67ba2a937..53891d627 100644 --- a/source/world/phys/HitResult.hpp +++ b/source/world/phys/HitResult.hpp @@ -25,24 +25,12 @@ class HitResult NONE, }; - // Replaced with Facing::Name - /*enum HitSide //: signed char - { - NOHIT = -1, - MINY = 0, - MAXY, // 1 - MINZ, // 2 - MAXZ, // 3 - MINX, // 4 - MAXX, // 5 - };*/ - private: void _init(); public: HitResult() { _init(); } HitResult(Entity*); - HitResult(const TilePos& tilePos, Facing::Name hitSide, const Vec3&); + HitResult(const TilePos& tilePos, Facing::Name hitSide, const Vec3& pos); bool isHit() const { return m_hitType != NONE; } diff --git a/source/world/phys/Vec2.cpp b/source/world/phys/Vec2.cpp index a36730858..a0df85b38 100644 --- a/source/world/phys/Vec2.cpp +++ b/source/world/phys/Vec2.cpp @@ -6,9 +6,14 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ +#include + #include "Vec2.hpp" -const Vec2 Vec2::ZERO = Vec2(0, 0); +const Vec2 Vec2::ZERO = Vec2(0, 0), Vec2::ONE = Vec2(1, 1); +const Vec2 Vec2::UNIT_X = Vec2(1, 0), Vec2::NEG_UNIT_X = Vec2(-1, 0); +const Vec2 Vec2::UNIT_Y = Vec2(0, 1), Vec2::NEG_UNIT_Y = Vec2(0, -1); +const Vec2 Vec2::MIN = Vec2(INT_MIN, INT_MIN), Vec2::MAX = Vec2(INT_MAX, INT_MAX); void Vec2::_init(float x, float y) { @@ -21,6 +26,11 @@ Vec2::Vec2() _init(0, 0); } +Vec2::Vec2(float xy) +{ + _init(xy, xy); +} + Vec2::Vec2(float x, float y) { _init(x, y); diff --git a/source/world/phys/Vec2.hpp b/source/world/phys/Vec2.hpp index 360279792..85ea3e5d6 100644 --- a/source/world/phys/Vec2.hpp +++ b/source/world/phys/Vec2.hpp @@ -15,7 +15,10 @@ class Vec2 { public: - static const Vec2 ZERO; + static const Vec2 ZERO, ONE; + static const Vec2 UNIT_X, NEG_UNIT_X; + static const Vec2 UNIT_Y, NEG_UNIT_Y; + static const Vec2 MIN, MAX; public: float x, y; @@ -26,6 +29,7 @@ class Vec2 public: // this constructor is nice to have, but it's probably inlined Vec2(); + Vec2(float xy); Vec2(float x, float y); Vec2 normalize() const; @@ -79,6 +83,12 @@ class Vec2 y == b.y; } + bool operator!=(const Vec2& b) const + { + return x != b.x && + y != b.y; + } + Vec2 translate(float tx, float ty) const { return Vec2(x + tx, y + ty); diff --git a/source/world/phys/Vec3.cpp b/source/world/phys/Vec3.cpp index 55d899763..50e1426bf 100644 --- a/source/world/phys/Vec3.cpp +++ b/source/world/phys/Vec3.cpp @@ -6,10 +6,16 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ +#include + #include "Vec3.hpp" #include "world/level/TilePos.hpp" -const Vec3 Vec3::ZERO = Vec3(0, 0, 0); +const Vec3 Vec3::ZERO = Vec3(0, 0, 0), Vec3::ONE = Vec3(1, 1, 1); +const Vec3 Vec3::UNIT_X = Vec3(1, 0, 0), Vec3::NEG_UNIT_X = Vec3(-1, 0, 0); +const Vec3 Vec3::UNIT_Y = Vec3(0, 1, 0), Vec3::NEG_UNIT_Y = Vec3(0, -1, 0); +const Vec3 Vec3::UNIT_Z = Vec3(0, 0, 1), Vec3::NEG_UNIT_Z = Vec3(0, 0, -1); +const Vec3 Vec3::MIN = Vec3(INT_MIN, INT_MIN, INT_MIN), Vec3::MAX = Vec3(INT_MAX, INT_MAX, INT_MAX); void Vec3::_init(float x, float y, float z) { @@ -23,6 +29,11 @@ Vec3::Vec3() _init(0, 0, 0); } +Vec3::Vec3(float xyz) +{ + _init(xyz, xyz, xyz); +} + Vec3::Vec3(float x, float y, float z) { _init(x, y, z); diff --git a/source/world/phys/Vec3.hpp b/source/world/phys/Vec3.hpp index d64c07c55..545348dc2 100644 --- a/source/world/phys/Vec3.hpp +++ b/source/world/phys/Vec3.hpp @@ -23,7 +23,11 @@ struct TilePos; class Vec3 { public: - static const Vec3 ZERO; + static const Vec3 ZERO, ONE; + static const Vec3 UNIT_X, NEG_UNIT_X; + static const Vec3 UNIT_Y, NEG_UNIT_Y; + static const Vec3 UNIT_Z, NEG_UNIT_Z; + static const Vec3 MIN, MAX; public: float x, y, z; @@ -34,6 +38,7 @@ class Vec3 public: // this constructor is nice to have, but it's probably inlined Vec3(); + Vec3(float xyz); Vec3(float x, float y, float z); Vec3(const TilePos& tilePos); @@ -172,5 +177,12 @@ class Vec3 y == b.y && z == b.z; } + + bool operator!=(const Vec3& b) const + { + return x != b.x && + y != b.y && + z != b.z; + } }; diff --git a/source/world/tile/Bush.cpp b/source/world/tile/Bush.cpp index 9c9a6e2f6..d9014cc78 100644 --- a/source/world/tile/Bush.cpp +++ b/source/world/tile/Bush.cpp @@ -12,11 +12,12 @@ Bush::Bush(TileID id, int texture) : Tile(id, Material::plant) { m_TextureFrame = texture; + m_renderLayer = RENDER_LAYER_ALPHATEST; setTicking(true); setShape(0.3f, 0.0f, 0.3f, 0.7f, 0.6f, 0.7f); } -int Bush::getRenderShape() const +eRenderShape Bush::getRenderShape() const { return SHAPE_CROSS; } diff --git a/source/world/tile/Bush.hpp b/source/world/tile/Bush.hpp index 8515edc1d..b4a01b0e3 100644 --- a/source/world/tile/Bush.hpp +++ b/source/world/tile/Bush.hpp @@ -15,14 +15,14 @@ class Bush : public Tile public: Bush(TileID id, int texture); - virtual bool canSurvive(const Level*, const TilePos& pos) const override; - virtual AABB* getAABB(const Level*, const TilePos& pos) override; - virtual int getRenderShape() const override; - virtual bool isCubeShaped() const override; - virtual bool isSolidRender() const override; - virtual bool mayPlace(const Level*, const TilePos& pos) const override; - virtual void tick(Level*, const TilePos& pos, Random*) override; - virtual void neighborChanged(Level*, const TilePos& pos, TileID tile) override; + bool canSurvive(const Level*, const TilePos& pos) const override; + AABB* getAABB(const Level*, const TilePos& pos) override; + eRenderShape getRenderShape() const override; + bool isCubeShaped() const override; + bool isSolidRender() const override; + bool mayPlace(const Level*, const TilePos& pos) const override; + void tick(Level*, const TilePos& pos, Random*) override; + void neighborChanged(Level*, const TilePos& pos, TileID tile) override; void checkAlive(Level*, const TilePos& pos); }; diff --git a/source/world/tile/CactusTile.cpp b/source/world/tile/CactusTile.cpp index 37315f303..a81fe345c 100644 --- a/source/world/tile/CactusTile.cpp +++ b/source/world/tile/CactusTile.cpp @@ -3,6 +3,7 @@ CactusTile::CactusTile(int id, int texture) : Tile(id, texture, Material::cactus) { + m_renderLayer = RENDER_LAYER_ALPHATEST; setTicking(true); } @@ -53,7 +54,7 @@ bool CactusTile::isCubeShaped() const return false; } -int CactusTile::getRenderShape() const +eRenderShape CactusTile::getRenderShape() const { return SHAPE_CACTUS; } diff --git a/source/world/tile/CactusTile.hpp b/source/world/tile/CactusTile.hpp index 6d7275d2a..485591d50 100644 --- a/source/world/tile/CactusTile.hpp +++ b/source/world/tile/CactusTile.hpp @@ -12,7 +12,7 @@ class CactusTile : public Tile void neighborChanged(Level* level, const TilePos& pos, TileID tile) override; bool isSolidRender() const override; bool isCubeShaped() const override; - int getRenderShape() const override; + eRenderShape getRenderShape() const override; void tick(Level*, const TilePos& pos, Random*) override; void entityInside(Level*, const TilePos& pos, Entity*) const override; int getTexture(Facing::Name face) const override; diff --git a/source/world/tile/DoorTile.cpp b/source/world/tile/DoorTile.cpp index 7d3261042..0b8b818bb 100644 --- a/source/world/tile/DoorTile.cpp +++ b/source/world/tile/DoorTile.cpp @@ -13,6 +13,7 @@ DoorTile::DoorTile(int ID, Material* pMtl) : Tile(ID, pMtl) { m_TextureFrame = TEXTURE_DOOR_BOTTOM; + m_renderLayer = RENDER_LAYER_ALPHATEST; if (pMtl == Material::metal) m_TextureFrame = TEXTURE_DOOR_IRON_BOTTOM; @@ -85,7 +86,7 @@ int DoorTile::getDir(TileData data) const return data & 3; } -int DoorTile::getRenderShape() const +eRenderShape DoorTile::getRenderShape() const { return SHAPE_DOOR; } diff --git a/source/world/tile/DoorTile.hpp b/source/world/tile/DoorTile.hpp index 59aeb9971..e0680ae86 100644 --- a/source/world/tile/DoorTile.hpp +++ b/source/world/tile/DoorTile.hpp @@ -19,7 +19,7 @@ class DoorTile : public Tile bool use(Level*, const TilePos& pos, Player*) override; HitResult clip(const Level*, const TilePos& pos, Vec3, Vec3) override; AABB* getAABB(const Level*, const TilePos& pos) override; - int getRenderShape() const override; + eRenderShape getRenderShape() const override; int getResource(TileData data, Random*) const override; int getTexture(Facing::Name face, TileData data) const override; AABB getTileAABB(const Level*, const TilePos& pos) override; diff --git a/source/world/tile/FenceTile.cpp b/source/world/tile/FenceTile.cpp index e5697cec7..7cd86c13f 100644 --- a/source/world/tile/FenceTile.cpp +++ b/source/world/tile/FenceTile.cpp @@ -36,7 +36,7 @@ bool FenceTile::isCubeShaped() const return false; } -int FenceTile::getRenderShape() const +eRenderShape FenceTile::getRenderShape() const { return SHAPE_FENCE; } \ No newline at end of file diff --git a/source/world/tile/FenceTile.hpp b/source/world/tile/FenceTile.hpp index a5cbbdf31..12fe401b3 100644 --- a/source/world/tile/FenceTile.hpp +++ b/source/world/tile/FenceTile.hpp @@ -10,5 +10,5 @@ class FenceTile : public Tile AABB* getAABB(const Level* pLevel, const TilePos& pos) override; bool isSolidRender() const override; bool isCubeShaped() const override; - int getRenderShape() const override; + eRenderShape getRenderShape() const override; }; diff --git a/source/world/tile/FireTile.cpp b/source/world/tile/FireTile.cpp index 87944a5e0..3687ad013 100644 --- a/source/world/tile/FireTile.cpp +++ b/source/world/tile/FireTile.cpp @@ -31,10 +31,12 @@ FireTile::FireTile(int ID, int texture) : Tile(ID, texture, Material::fire) m_burnOdds [Tile::cloth->m_ID] = 60; // @NOTE: Not setting the other cloths' properties + m_renderLayer = RENDER_LAYER_ALPHATEST; + setTicking(true); } -int FireTile::getRenderShape() const +eRenderShape FireTile::getRenderShape() const { // @BUG: Since the shape is set to FIRE, but TileRenderer doesn't handle it, // fire is invisible in this version of Minecraft. diff --git a/source/world/tile/FireTile.hpp b/source/world/tile/FireTile.hpp index f85ed9c4c..92302058a 100644 --- a/source/world/tile/FireTile.hpp +++ b/source/world/tile/FireTile.hpp @@ -16,7 +16,7 @@ class FireTile : public Tile FireTile(int ID, int texture); AABB* getAABB(const Level*, const TilePos& pos) override; - int getRenderShape() const override; + eRenderShape getRenderShape() const override; bool isCubeShaped() const override; bool isSolidRender() const override; int getResourceCount(Random*) const override; diff --git a/source/world/tile/GlassTile.cpp b/source/world/tile/GlassTile.cpp index 6a442b4b2..d2c902eeb 100644 --- a/source/world/tile/GlassTile.cpp +++ b/source/world/tile/GlassTile.cpp @@ -12,17 +12,10 @@ GlassTile::GlassTile(int a, int b, Material* c) : HalfTransparentTile(a, b, c) { + m_renderLayer = RENDER_LAYER_ALPHATEST; } int GlassTile::getResourceCount(Random* pRandom) const { return 0; } - -int GlassTile::getRenderLayer() const -{ - if (GetPatchManager()->IsGlassSemiTransparent()) - return LAYER_ALPHA; - - return LAYER_OPAQUE; -} diff --git a/source/world/tile/GlassTile.hpp b/source/world/tile/GlassTile.hpp index 272d7fac6..3977a3329 100644 --- a/source/world/tile/GlassTile.hpp +++ b/source/world/tile/GlassTile.hpp @@ -16,5 +16,4 @@ class GlassTile : public HalfTransparentTile GlassTile(int ID, int texture, Material*); int getResourceCount(Random*) const override; - int getRenderLayer() const override; }; diff --git a/source/world/tile/GrassTile.cpp b/source/world/tile/GrassTile.cpp index 216270cd1..0c4c550b4 100644 --- a/source/world/tile/GrassTile.cpp +++ b/source/world/tile/GrassTile.cpp @@ -13,6 +13,7 @@ GrassTile::GrassTile(TileID id, Material* c) : Tile(id, c) { m_TextureFrame = TEXTURE_GRASS_SIDE; + m_renderLayer = RENDER_LAYER_ALPHATEST; setTicking(true); } diff --git a/source/world/tile/IceTile.cpp b/source/world/tile/IceTile.cpp index c6bb5f47e..3b69b1c87 100644 --- a/source/world/tile/IceTile.cpp +++ b/source/world/tile/IceTile.cpp @@ -12,14 +12,10 @@ IceTile::IceTile(int a, int b, Material* c) : HalfTransparentTile(a, b, c) { m_friction = 0.98f; + m_renderLayer = RENDER_LAYER_BLEND; setTicking(true); } -int IceTile::getRenderLayer() const -{ - return LAYER_ALPHA; -} - int IceTile::getResourceCount(Random* pRandom) const { return 0; diff --git a/source/world/tile/IceTile.hpp b/source/world/tile/IceTile.hpp index c71fe90c6..330ed113e 100644 --- a/source/world/tile/IceTile.hpp +++ b/source/world/tile/IceTile.hpp @@ -15,7 +15,6 @@ class IceTile : public HalfTransparentTile public: IceTile(int ID, int texture, Material*); - int getRenderLayer() const override; int getResourceCount(Random*) const override; void onRemove(Level*, const TilePos& pos) override; bool shouldRenderFace(const LevelSource*, const TilePos& pos, Facing::Name face) const override; diff --git a/source/world/tile/InvisibleTile.cpp b/source/world/tile/InvisibleTile.cpp index a829f0d63..face221a7 100644 --- a/source/world/tile/InvisibleTile.cpp +++ b/source/world/tile/InvisibleTile.cpp @@ -15,7 +15,7 @@ InvisibleTile::InvisibleTile(TileID ID, int texture, Material* pMtl) : } -int InvisibleTile::getRenderShape() const +eRenderShape InvisibleTile::getRenderShape() const { return SHAPE_NONE; } diff --git a/source/world/tile/InvisibleTile.hpp b/source/world/tile/InvisibleTile.hpp index a1ef517d4..ea3da6685 100644 --- a/source/world/tile/InvisibleTile.hpp +++ b/source/world/tile/InvisibleTile.hpp @@ -14,6 +14,6 @@ class InvisibleTile : public Tile { public: InvisibleTile(TileID ID, int texture, Material*); - int getRenderShape() const override; + eRenderShape getRenderShape() const override; bool mayPick() const override; }; diff --git a/source/world/tile/LadderTile.cpp b/source/world/tile/LadderTile.cpp index 59ea66d46..c900367cf 100644 --- a/source/world/tile/LadderTile.cpp +++ b/source/world/tile/LadderTile.cpp @@ -11,9 +11,10 @@ LadderTile::LadderTile(int ID, int texture) : Tile(ID, texture, Material::decoration) { + m_renderLayer = RENDER_LAYER_ALPHATEST; } -int LadderTile::getRenderShape() const +eRenderShape LadderTile::getRenderShape() const { return SHAPE_LADDER; } diff --git a/source/world/tile/LadderTile.hpp b/source/world/tile/LadderTile.hpp index c57e3b5ab..7597246b5 100644 --- a/source/world/tile/LadderTile.hpp +++ b/source/world/tile/LadderTile.hpp @@ -17,7 +17,7 @@ class LadderTile : public Tile bool isCubeShaped() const override; bool isSolidRender() const override; - int getRenderShape() const override; + eRenderShape getRenderShape() const override; int getResourceCount(Random* random) const override; AABB* getAABB(const Level*, const TilePos& pos) override; AABB getTileAABB(const Level*, const TilePos& pos) override; diff --git a/source/world/tile/LeafTile.cpp b/source/world/tile/LeafTile.cpp index abc4e5128..817a3e7eb 100644 --- a/source/world/tile/LeafTile.cpp +++ b/source/world/tile/LeafTile.cpp @@ -23,6 +23,7 @@ LeafTile::LeafTile(TileID id) : TransparentTile(id, TEXTURE_LEAVES_TRANSPARENT, m_TextureFrame = TEXTURE_LEAVES_TRANSPARENT; field_74 = TEXTURE_LEAVES_TRANSPARENT; + m_renderLayer = RENDER_LAYER_ALPHATEST; // RENDER_LAYER_SEASONS_OPTIONAL_ALPHATEST setTicking(true); } diff --git a/source/world/tile/LiquidTile.cpp b/source/world/tile/LiquidTile.cpp index 265dcf032..f6314e4f8 100644 --- a/source/world/tile/LiquidTile.cpp +++ b/source/world/tile/LiquidTile.cpp @@ -11,6 +11,7 @@ LiquidTile::LiquidTile(int id, Material* pMtl) : Tile(id, pMtl == Material::lava ? TEXTURE_LAVA : TEXTURE_WATER, pMtl) { + m_renderLayer = m_pMaterial == Material::water ? RENDER_LAYER_BLEND : RENDER_LAYER_OPAQUE; field_6C = 0; field_70[0] = 0; field_74[0] = 0; @@ -138,12 +139,7 @@ Vec3 LiquidTile::getFlow(const LevelSource* level, const TilePos& pos) const return result.normalize(); } -int LiquidTile::getRenderLayer() const -{ - return m_pMaterial == Material::water ? LAYER_ALPHA : LAYER_OPAQUE; -} - -int LiquidTile::getRenderShape() const +eRenderShape LiquidTile::getRenderShape() const { return SHAPE_WATER; } diff --git a/source/world/tile/LiquidTile.hpp b/source/world/tile/LiquidTile.hpp index 0f0a4ec8c..9ad9a97d6 100644 --- a/source/world/tile/LiquidTile.hpp +++ b/source/world/tile/LiquidTile.hpp @@ -21,8 +21,7 @@ class LiquidTile : public Tile void animateTick(Level*, const TilePos& pos, Random* random) override; AABB* getAABB(const Level*, const TilePos& pos) override; float getBrightness(const LevelSource*, const TilePos& pos) const override; - int getRenderLayer() const override; - int getRenderShape() const override; + eRenderShape getRenderShape() const override; int getResource(TileData, Random*) const override; int getResourceCount(Random*) const override; int getTexture(Facing::Name face) const override; diff --git a/source/world/tile/ReedTile.cpp b/source/world/tile/ReedTile.cpp index 5f7d64c14..fbbf60fc5 100644 --- a/source/world/tile/ReedTile.cpp +++ b/source/world/tile/ReedTile.cpp @@ -12,13 +12,14 @@ ReedTile::ReedTile(TileID id) : Tile(id, Material::plant) { m_TextureFrame = TEXTURE_REEDS; + m_renderLayer = RENDER_LAYER_ALPHATEST; setShape(0.125f, 0.0f, 0.125f, 0.875f, 1.0f, 0.875f); setTicking(true); } -int ReedTile::getRenderShape() const +eRenderShape ReedTile::getRenderShape() const { - return 1; + return SHAPE_CROSS; } bool ReedTile::isCubeShaped() const diff --git a/source/world/tile/ReedTile.hpp b/source/world/tile/ReedTile.hpp index 023f5da22..2cb353e22 100644 --- a/source/world/tile/ReedTile.hpp +++ b/source/world/tile/ReedTile.hpp @@ -17,7 +17,7 @@ class ReedTile : public Tile bool canSurvive(const Level*, const TilePos& pos) const override; AABB* getAABB(const Level*, const TilePos& pos) override; - int getRenderShape() const override; + eRenderShape getRenderShape() const override; bool isCubeShaped() const override; bool isSolidRender() const override; bool mayPlace(const Level*, const TilePos& pos) const override; diff --git a/source/world/tile/RocketLauncherTile.cpp b/source/world/tile/RocketLauncherTile.cpp index 1cda4b703..5977c1584 100644 --- a/source/world/tile/RocketLauncherTile.cpp +++ b/source/world/tile/RocketLauncherTile.cpp @@ -11,6 +11,7 @@ RocketLauncherTile::RocketLauncherTile(TileID id) : Tile(id, 16*14+2, Material::wood) { + m_renderLayer = RENDER_LAYER_ALPHATEST; setTicking(true); } @@ -24,7 +25,7 @@ AABB* RocketLauncherTile::getAABB(const Level*, const TilePos& pos) return nullptr; } -int RocketLauncherTile::getRenderShape() const +eRenderShape RocketLauncherTile::getRenderShape() const { return SHAPE_CROSS; } diff --git a/source/world/tile/RocketLauncherTile.hpp b/source/world/tile/RocketLauncherTile.hpp index 1d6232123..eda267dc3 100644 --- a/source/world/tile/RocketLauncherTile.hpp +++ b/source/world/tile/RocketLauncherTile.hpp @@ -17,7 +17,7 @@ class RocketLauncherTile : public Tile int getTexture(Facing::Name face, TileData data) const override; AABB* getAABB(const Level*, const TilePos& pos) override; - int getRenderShape() const override; + eRenderShape getRenderShape() const override; bool isCubeShaped() const override; bool isSolidRender() const override; bool use(Level* pLevel, const TilePos& pos, Player* player) override; diff --git a/source/world/tile/StairTile.cpp b/source/world/tile/StairTile.cpp index 6fea274e7..385aa799a 100644 --- a/source/world/tile/StairTile.cpp +++ b/source/world/tile/StairTile.cpp @@ -76,7 +76,7 @@ bool StairTile::isCubeShaped() const return false; } -int StairTile::getRenderShape() const +eRenderShape StairTile::getRenderShape() const { return SHAPE_STAIRS; } @@ -192,7 +192,7 @@ void StairTile::wasExploded(Level* level, const TilePos& pos) return m_pParent->wasExploded(level, pos); } -int StairTile::getRenderLayer() const +Tile::RenderLayer StairTile::getRenderLayer() const { return m_pParent->getRenderLayer(); } diff --git a/source/world/tile/StairTile.hpp b/source/world/tile/StairTile.hpp index 029b265fb..27d0fc229 100644 --- a/source/world/tile/StairTile.hpp +++ b/source/world/tile/StairTile.hpp @@ -18,7 +18,7 @@ class StairTile : public Tile void addAABBs(const Level*, const TilePos& pos, const AABB*, std::vector&) override; bool isSolidRender() const override; bool isCubeShaped() const override; - int getRenderShape() const override; + eRenderShape getRenderShape() const override; // Just overloads to forward to parent tile. void addLights(Level*, const TilePos& pos) override; @@ -43,7 +43,7 @@ class StairTile : public Tile void spawnResources(Level*, const TilePos& pos, TileData data, float) override; float getExplosionResistance(Entity*) const override; void wasExploded(Level*, const TilePos& pos) override; - int getRenderLayer() const override; + RenderLayer getRenderLayer() const override; bool use(Level*, const TilePos& pos, Player*) override; void stepOn(Level*, const TilePos& pos, Entity*) override; void setPlacedBy(Level*, const TilePos& pos, Mob*) override; diff --git a/source/world/tile/TallGrass.cpp b/source/world/tile/TallGrass.cpp index ec1fcddd1..f339bd31e 100644 --- a/source/world/tile/TallGrass.cpp +++ b/source/world/tile/TallGrass.cpp @@ -34,7 +34,7 @@ int TallGrass::getTexture(const LevelSource* level, const TilePos& pos, Facing:: return data == 1 ? m_TextureFrame : (data == 2 ? m_TextureFrame + 16 + 1 : (data == 0 ? m_TextureFrame + 16 : m_TextureFrame)); } -int TallGrass::getRenderShape() const +eRenderShape TallGrass::getRenderShape() const { return SHAPE_RANDOM_CROSS; } diff --git a/source/world/tile/TallGrass.hpp b/source/world/tile/TallGrass.hpp index 6cf480a43..3143b297b 100644 --- a/source/world/tile/TallGrass.hpp +++ b/source/world/tile/TallGrass.hpp @@ -10,5 +10,5 @@ class TallGrass : public Bush bool isValidGrowTile(const TileID tile) const; int getColor(const LevelSource*, const TilePos& pos) const override; int getTexture(const LevelSource* level, const TilePos& pos, Facing::Name face) const override; - int getRenderShape() const override; + eRenderShape getRenderShape() const override; }; diff --git a/source/world/tile/Tile.cpp b/source/world/tile/Tile.cpp index 619da0ca2..9d5f0987b 100644 --- a/source/world/tile/Tile.cpp +++ b/source/world/tile/Tile.cpp @@ -105,6 +105,7 @@ void Tile::_init() m_hardness = 0.0f; m_blastResistance = 0.0f; m_descriptionID = ""; + m_renderLayer = RENDER_LAYER_OPAQUE; } void Tile::_init(TileID ID, Material* pMaterial, int texture) @@ -208,9 +209,9 @@ Tile* Tile::init() return this; } -int Tile::getRenderShape() const +eRenderShape Tile::getRenderShape() const { - return 0; + return SHAPE_SOLID; } void Tile::updateDefaultShape() @@ -238,9 +239,9 @@ bool Tile::isSignalSource() const return false; } -int Tile::getRenderLayer() const +Tile::RenderLayer Tile::getRenderLayer() const { - return LAYER_OPAQUE; + return m_renderLayer; } bool Tile::isSolidRender() const diff --git a/source/world/tile/Tile.hpp b/source/world/tile/Tile.hpp index 303e29b3c..feac3f2b1 100644 --- a/source/world/tile/Tile.hpp +++ b/source/world/tile/Tile.hpp @@ -30,7 +30,20 @@ class LiquidTile; class Tile { -public: // structs +public: // types + enum RenderLayer + { + RENDER_LAYER_DOUBLE_SIDED, + RENDER_LAYER_BLEND, + RENDER_LAYER_OPAQUE, + RENDER_LAYER_OPTIONAL_ALPHATEST, + RENDER_LAYER_ALPHATEST, + RENDER_LAYER_SEASONS_OPAQUE, + RENDER_LAYER_SEASONS_OPTIONAL_ALPHATEST, + RENDER_LAYERS_MIN = RENDER_LAYER_DOUBLE_SIDED, + RENDER_LAYERS_MAX = RENDER_LAYER_SEASONS_OPTIONAL_ALPHATEST, + RENDER_LAYERS_COUNT + }; struct SoundType { std::string m_name; @@ -42,7 +55,7 @@ class Tile public: // virtual functions virtual ~Tile(); virtual bool isCubeShaped() const; - virtual int getRenderShape() const; + virtual eRenderShape getRenderShape() const; virtual Tile* setShape(float, float, float, float, float, float); virtual void updateShape(const LevelSource*, const TilePos& pos); virtual void updateDefaultShape(); @@ -75,7 +88,7 @@ class Tile virtual float getExplosionResistance(Entity*) const; virtual HitResult clip(const Level*, const TilePos& pos, Vec3, Vec3); virtual void wasExploded(Level*, const TilePos& pos); - virtual int getRenderLayer() const; + virtual RenderLayer getRenderLayer() const; virtual bool use(Level*, const TilePos& pos, Player*); virtual void stepOn(Level*, const TilePos& pos, Entity*); virtual void setPlacedOnFace(Level*, const TilePos& pos, Facing::Name face); @@ -232,4 +245,37 @@ class Tile float m_blastResistance; AABB m_aabbReturned; std::string m_descriptionID; + +protected: + RenderLayer m_renderLayer; }; + +class FullTile +{ +private: + Tile* _tileType; +public: + TileData data; + +private: + void _init(Tile* tileType, TileData data) + { + this->_tileType = tileType; + this->data = data; + } + +public: + FullTile(TileID tileId, TileData data) + { + _init(Tile::tiles[tileId], data); + } + + FullTile(Tile* tileType, TileData data) + { + _init(tileType, data); + } + +public: + TileID getTypeId() const { return _tileType->m_ID; } + Tile* getType() const { return _tileType; } +}; \ No newline at end of file diff --git a/source/world/tile/TorchTile.cpp b/source/world/tile/TorchTile.cpp index 64fc7669e..9338b1cf7 100644 --- a/source/world/tile/TorchTile.cpp +++ b/source/world/tile/TorchTile.cpp @@ -11,6 +11,7 @@ TorchTile::TorchTile(int ID, int texture, Material* pMtl) : Tile(ID, texture, pMtl) { + m_renderLayer = RENDER_LAYER_ALPHATEST; setTicking(true); } @@ -19,7 +20,7 @@ AABB* TorchTile::getAABB(const Level*, const TilePos& pos) return nullptr; } -int TorchTile::getRenderShape() const +eRenderShape TorchTile::getRenderShape() const { return SHAPE_TORCH; } diff --git a/source/world/tile/TorchTile.hpp b/source/world/tile/TorchTile.hpp index 53e715ad4..cb054a52e 100644 --- a/source/world/tile/TorchTile.hpp +++ b/source/world/tile/TorchTile.hpp @@ -18,7 +18,7 @@ class TorchTile : public Tile AABB* getAABB(const Level*, const TilePos& pos) override; bool isSolidRender() const override; bool isCubeShaped() const override; - int getRenderShape() const override; + eRenderShape getRenderShape() const override; void animateTick(Level*, const TilePos& pos, Random*) override; HitResult clip(const Level*, const TilePos& pos, Vec3 a, Vec3 b) override; bool mayPlace(const Level*, const TilePos& pos) const override; diff --git a/source/world/tile/Web.cpp b/source/world/tile/Web.cpp index 64eb30d2f..972ef663e 100644 --- a/source/world/tile/Web.cpp +++ b/source/world/tile/Web.cpp @@ -3,9 +3,10 @@ Web::Web(TileID id, int texture) : Tile(id, texture, Material::web) { + m_renderLayer = RENDER_LAYER_ALPHATEST; } -int Web::getRenderShape() const +eRenderShape Web::getRenderShape() const { return SHAPE_CROSS; } diff --git a/source/world/tile/Web.hpp b/source/world/tile/Web.hpp index 16caa4904..7fc99c73f 100644 --- a/source/world/tile/Web.hpp +++ b/source/world/tile/Web.hpp @@ -8,7 +8,7 @@ class Web : public Tile Web(TileID id, int texture); AABB* getAABB(const Level*, const TilePos& pos) override; - virtual int getRenderShape() const override; + virtual eRenderShape getRenderShape() const override; virtual bool isCubeShaped() const override; virtual bool isSolidRender() const override; void entityInside(Level*, const TilePos& pos, Entity*) const override; diff --git a/thirdparty/GL/GL.hpp b/thirdparty/GL/GL.hpp index 3c11eabc6..2d78e995f 100644 --- a/thirdparty/GL/GL.hpp +++ b/thirdparty/GL/GL.hpp @@ -8,8 +8,9 @@ #pragma once -#include // it includes GL/gl.h -#include +#include "common/Utils.hpp" // needed for M_PI +#include "compat/PlatformDefinitions.h" +#include "GameMods.hpp" #ifdef USE_NATIVE_ANDROID #define USE_GLES @@ -19,6 +20,8 @@ // Disable this on OpenGL ES 2+ #define USE_GL_NORMAL_LIGHTING +//#define MC_GL_DEBUG_OUTPUT + #ifdef USE_GLES #if MC_PLATFORM_IOS #import @@ -28,7 +31,15 @@ #else #include #endif - #define GL_QUADS 0x7 + #ifndef GL_NONE + #define GL_NONE 0x0 + #endif + #ifndef GL_UNSIGNED_INT + #define GL_UNSIGNED_INT 0x1405 + #endif + #ifndef GL_TEXTURE_MAX_LEVEL + #define GL_TEXTURE_MAX_LEVEL 0x813D + #endif #define USE_OPENGL_2_FEATURES @@ -103,6 +114,23 @@ } #endif +#if defined(MC_GL_DEBUG_OUTPUT) && !defined(GL_ARB_debug_output) +#undef MC_GL_DEBUG_OUTPUT +#endif + +#ifdef MC_GL_DEBUG_OUTPUT +#ifndef GL_DEBUG_OUTPUT +#define GL_DEBUG_OUTPUT 0x92E0 +#endif +typedef void (APIENTRY* DEBUGPROC)(GLenum source, + GLenum type, + GLuint id, + GLenum severity, + GLsizei length, + const GLchar* message, + GLvoid* userParam); +#endif + #ifdef _WIN32 void xglInit(); bool xglInitted(); @@ -110,10 +138,15 @@ bool xglInitted(); #if defined(USE_OPENGL_2_FEATURES) && !defined(_WIN32) && !defined(__DREAMCAST__) +#if GL_VERSION_1_3 || GL_VERSION_ES_CM_1_0 +#define xglActiveTexture glActiveTexture +#endif // GL_VERSION_1_3 || GL_VERSION_ES_CM_1_0 +#if GL_VERSION_1_5 || GL_VERSION_ES_CM_1_0 #define xglBindBuffer glBindBuffer #define xglBufferData glBufferData #define xglGenBuffers glGenBuffers #define xglDeleteBuffers glDeleteBuffers +#define xglBufferSubData glBufferSubData #define xglEnableClientState glEnableClientState #define xglDisableClientState glDisableClientState #define xglTexCoordPointer glTexCoordPointer @@ -121,13 +154,113 @@ bool xglInitted(); #define xglNormalPointer glNormalPointer #define xglVertexPointer glVertexPointer #define xglDrawArrays glDrawArrays +#endif // GL_VERSION_1_5 || GL_VERSION_ES_CM_1_0 +#if GL_VERSION_2_0 || GL_ES_VERSION_2_0 +#define USE_GL_STENCIL_SEPARATE +#define xglStencilFuncSeparate glStencilFuncSeparate +#define xglStencilOpSeparate glStencilOpSeparate +#endif // GL_VERSION_2_0 || GL_VERSION_ES_CM_1_0 +#ifdef FEATURE_GFX_SHADERS +#if GL_VERSION_2_0 || GL_ES_VERSION_2_0 +#define xglUniform1i glUniform1i +#define xglUniform1fv glUniform1fv +#define xglUniform2fv glUniform2fv +#define xglUniform3fv glUniform3fv +#define xglUniform4fv glUniform4fv +#define xglUniform1iv glUniform1iv +#define xglUniform2iv glUniform2iv +#define xglUniform3iv glUniform3iv +#define xglUniform4iv glUniform4iv +#define xglUniformMatrix2fv glUniformMatrix2fv +#define xglUniformMatrix3fv glUniformMatrix3fv +#define xglUniformMatrix4fv glUniformMatrix4fv +#define xglCreateShader glCreateShader +#define xglShaderSource glShaderSource +#define xglCompileShader glCompileShader +#define xglGetShaderiv glGetShaderiv +#define xglGetShaderInfoLog glGetShaderInfoLog +#define xglDeleteShader glDeleteShader +#define xglDeleteProgram glDeleteProgram +#define xglCreateProgram glCreateProgram +#define xglAttachShader glAttachShader +#define xglLinkProgram glLinkProgram +#define xglGetProgramiv glGetProgramiv +#define xglGetProgramInfoLog glGetProgramInfoLog +#define xglVertexAttribPointer glVertexAttribPointer +#define xglUseProgram glUseProgram +#define xglGetActiveUniform glGetActiveUniform +#define xglGetActiveAttrib glGetActiveAttrib +#define xglGetUniformLocation glGetUniformLocation +#define xglGetAttribLocation glGetAttribLocation +#define xglEnableVertexAttribArray glEnableVertexAttribArray +#endif // GL_VERSION_2_0 || GL_ES_VERSION_2_0 +#if GL_VERSION_4_1 || GL_ES_VERSION_2_0 +#define xglReleaseShaderCompiler glReleaseShaderCompiler +#define xglGetShaderPrecisionFormat glGetShaderPrecisionFormat +#endif // GL_VERSION_4_1 || GL_ES_VERSION_2_0 +#endif // FEATURE_GFX_SHADERS +#ifdef MC_GL_DEBUG_OUTPUT +#define xglDebugMessageCallback glDebugMessageCallback +#endif #else +#if GL_VERSION_1_3 || GL_VERSION_ES_CM_1_0 +void xglActiveTexture(GLenum texture); +#endif // GL_VERSION_1_3 || GL_VERSION_ES_CM_1_0 +#if GL_VERSION_1_5 || GL_VERSION_ES_CM_1_0 void xglBindBuffer(GLenum target, GLuint buffer); void xglBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); void xglGenBuffers(GLsizei num, GLuint* buffers); void xglDeleteBuffers(GLsizei num, GLuint* buffers); +void xglBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data); +#endif // GL_VERSION_1_5 || GL_VERSION_ES_CM_1_0 +#if GL_VERSION_2_0 || GL_VERSION_ES_CM_1_0 +void xglStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask); +void xglStencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +#endif // GL_VERSION_2_0 || GL_VERSION_ES_CM_1_0 +#ifdef FEATURE_GFX_SHADERS +#if GL_VERSION_2_0 || GL_ES_VERSION_2_0 +void xglUniform1i(GLint location, GLint v0); +void xglUniform1fv(GLint location, GLsizei count, const GLfloat* value); +void xglUniform2fv(GLint location, GLsizei count, const GLfloat* value); +void xglUniform3fv(GLint location, GLsizei count, const GLfloat* value); +void xglUniform4fv(GLint location, GLsizei count, const GLfloat* value); +void xglUniform1iv(GLint location, GLsizei count, const GLint* value); +void xglUniform2iv(GLint location, GLsizei count, const GLint* value); +void xglUniform3iv(GLint location, GLsizei count, const GLint* value); +void xglUniform4iv(GLint location, GLsizei count, const GLint* value); +void xglUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +void xglUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +void xglUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GLuint xglCreateShader(GLenum type); +void xglShaderSource(GLuint shader, GLsizei count, const GLchar** string, const GLint* length); +void xglCompileShader(GLuint shader); +void xglGetShaderiv(GLuint shader, GLenum pname, GLint* params); +void xglGetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog); +void xglDeleteShader(GLuint shader); +void xglDeleteProgram(GLuint program); +GLuint xglCreateProgram(); +void xglAttachShader(GLuint program, GLuint shader); +void xglLinkProgram(GLuint program); +void xglGetProgramiv(GLuint program, GLenum pname, GLint* params); +void xglGetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog); +void xglVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* pointer); +void xglUseProgram(GLuint program); +void xglGetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); +void xglGetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); +GLint xglGetUniformLocation(GLuint program, const GLchar* name); +GLint xglGetAttribLocation(GLuint program, const GLchar* name); +void xglEnableVertexAttribArray(GLuint index); +#endif // GL_VERSION_2_0 || GL_ES_VERSION_2_0 +#if GL_VERSION_4_1 || GL_ES_VERSION_2_0 +void xglReleaseShaderCompiler(); +void xglGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); +#endif +#endif // FEATURE_GFX_SHADERS +#ifdef MC_GL_DEBUG_OUTPUT +void xglDebugMessageCallback(DEBUGPROC callback, GLvoid* userParam); +#endif void xglOrthof(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat nearpl, GLfloat farpl); void xglSwapIntervalEXT(int interval); void xglEnableClientState(GLenum _array); diff --git a/thirdparty/GL/GLExt.cpp b/thirdparty/GL/GLExt.cpp deleted file mode 100644 index f48f2d501..000000000 --- a/thirdparty/GL/GLExt.cpp +++ /dev/null @@ -1,540 +0,0 @@ -/******************************************************************** - Minecraft: Pocket Edition - Decompilation Project - Copyright (C) 2023 iProgramInCpp - - The following code is licensed under the BSD 1 clause license. - SPDX-License-Identifier: BSD-1-Clause - ********************************************************************/ - -#if defined(_WIN32) || defined(__DREAMCAST__) - -#ifdef __DREAMCAST__ - -#define USE_GL_VBO_EMULATION - -#endif - -#include "GL.hpp" -#include - -#ifdef _WIN32 -#ifndef USE_OPENGL_2_FEATURES -// this is stupidly hacky -typedef BOOL(WINAPI* PFNWGLSWAPINTERVALEXTPROC) (int interval); -#endif -#endif - -// USE_HARDWARE_GL_BUFFERS enables VBOs to be used using their OpenGL interfaces. -// Disabling it simulates VBO functionality using display lists, which is slower. -#ifndef USE_GL_VBO_EMULATION -#define USE_HARDWARE_GL_BUFFERS -#endif - -#ifdef USE_HARDWARE_GL_BUFFERS -PFNGLBINDBUFFERPROC p_glBindBuffer; -PFNGLBUFFERDATAPROC p_glBufferData; -PFNGLGENBUFFERSPROC p_glGenBuffers; -PFNGLDELETEBUFFERSPROC p_glDeleteBuffers; -#endif -#ifndef USE_OPENGL_2_FEATURES -// Note: don't use xglSwapIntervalEXT if you want vsync, you don't know if it's supported -// on your platform so you need to query the extension APIs -PFNWGLSWAPINTERVALEXTPROC p_wglSwapIntervalEXT; -#endif - -bool xglInitted() -{ -#ifdef USE_HARDWARE_GL_BUFFERS - return p_glBindBuffer && p_glBufferData && p_glGenBuffers && p_glDeleteBuffers; -#else - return true; -#endif -} - -// Only called on Win32 and SDL+Win32 -void xglInit() -{ -#ifdef USE_HARDWARE_GL_BUFFERS -#ifdef _WIN32 - p_glBindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBuffer"); - p_glBufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferData"); - p_glGenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffers"); - p_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffers"); -#else - p_glBindBuffer = (PFNGLBINDBUFFERPROC)glBindBuffer; - p_glBufferData = (PFNGLBUFFERDATAPROC)glBufferData; - p_glGenBuffers = (PFNGLGENBUFFERSPROC)glGenBuffers; - p_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)glDeleteBuffers; -#endif -#endif - -#ifndef USE_OPENGL_2_FEATURES - p_wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); -#endif -} - -#ifdef USE_HARDWARE_GL_BUFFERS -void xglBindBuffer(GLenum target, GLuint buffer) -{ - p_glBindBuffer(target, buffer); -} - -void xglBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) -{ - p_glBufferData(target, size, data, usage); -} - -void xglGenBuffers(GLsizei num, GLuint* buffers) -{ - p_glGenBuffers(num, buffers); -} - -void xglDeleteBuffers(GLsizei num, GLuint* buffers) -{ - p_glDeleteBuffers(num, buffers); -} - -void xglEnableClientState(GLenum _array) -{ - glEnableClientState(_array); -} - -void xglDisableClientState(GLenum _array) -{ - glDisableClientState(_array); -} - -void xglTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) -{ - glTexCoordPointer(size, type, stride, pointer); -} - -void xglColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) -{ - glColorPointer(size, type, stride, pointer); -} - -void xglNormalPointer(GLenum type, GLsizei stride, const GLvoid* pointer) -{ -#ifdef USE_GL_NORMAL_LIGHTING - glNormalPointer(type, stride, pointer); -#endif -} - -void xglVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) -{ - glVertexPointer(size, type, stride, pointer); -} - -void xglDrawArrays(GLenum mode, GLint first, GLsizei count) -{ - glDrawArrays(mode, first, count); -} -#endif - -#ifndef xglOrthof - -void xglOrthof(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat nearpl, GLfloat farpl) -{ - return glOrtho(GLdouble(left), GLdouble(right), GLdouble(bottom), GLfloat(top), GLdouble(nearpl), GLdouble(farpl)); -} - -#endif - -void xglSwapIntervalEXT(int interval) -{ -#ifndef USE_OPENGL_2_FEATURES - if (!p_wglSwapIntervalEXT) - return; - - p_wglSwapIntervalEXT(interval); -#endif -} - -#ifndef USE_HARDWARE_GL_BUFFERS - -// ** Incomplete software based emulation of OpenGL vertex buffers. - -#define USE_DISPLAY_LISTS - -struct GLBuffer -{ - GLuint m_id; - GLvoid* m_pBufferData; - GLsizei m_bufferSize; - GLenum m_usage; // as passed into glBufferData - - // vertex pointer - GLint m_vtx_size; - GLenum m_vtx_type; - GLsizei m_vtx_stride; - GLint m_vtx_offset; - - // texture coord pointer - GLint m_tc_size; - GLenum m_tc_type; - GLsizei m_tc_stride; - GLint m_tc_offset; - - // color pointer - GLint m_col_size; - GLenum m_col_type; - GLsizei m_col_stride; - GLint m_col_offset; - - // normal pointer - GLenum m_nor_type; - GLsizei m_nor_stride; - GLint m_nor_offset; - - // associated display list - GLuint m_AssociatedDisplayList; // used if USE_DISPLAY_LISTS is on - - GLBuffer(GLuint id) - { - m_id = id; - m_pBufferData = nullptr; - m_bufferSize = 0; - m_usage = 0; - m_AssociatedDisplayList = 0; - } - - void DeletePreExistingDLIfNeeded() - { -#ifdef USE_DISPLAY_LISTS - if (m_AssociatedDisplayList != 0) - glDeleteLists(m_AssociatedDisplayList, 1); - - m_AssociatedDisplayList = 0; -#endif - } - - bool HasDisplayList() - { -#ifndef USE_DISPLAY_LISTS - return false; -#endif - return m_AssociatedDisplayList != 0; - } - - GLuint GetDisplayList() - { - return m_AssociatedDisplayList; - } - - void SetDisplayList(GLuint dl) - { - m_AssociatedDisplayList = dl; - } - - void SetVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* offset) - { - int ioffset = int(size_t(offset)); - if (m_vtx_size == size && - m_vtx_type == type && - m_vtx_stride == stride && - m_vtx_offset == ioffset) - return; - - DeletePreExistingDLIfNeeded(); - m_vtx_size = size; - m_vtx_type = type; - m_vtx_stride = stride; - m_vtx_offset = ioffset; - } - - void SetTextureCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* offset) - { - int ioffset = int(size_t(offset)); - if (m_tc_size == size && - m_tc_type == type && - m_tc_stride == stride && - m_tc_offset == ioffset) - return; - - DeletePreExistingDLIfNeeded(); - m_tc_size = size; - m_tc_type = type; - m_tc_stride = stride; - m_tc_offset = int(size_t(offset)); - } - - void SetColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* offset) - { - int ioffset = int(size_t(offset)); - if (m_col_size == size && - m_col_type == type && - m_col_stride == stride && - m_col_offset == ioffset) - return; - - DeletePreExistingDLIfNeeded(); - m_col_size = size; - m_col_type = type; - m_col_stride = stride; - m_col_offset = int(size_t(offset)); - } - - void SetNormalPointer(GLenum type, GLsizei stride, const GLvoid* offset) - { - int ioffset = int(size_t(offset)); - if (m_nor_type == type && - m_nor_stride == stride && - m_nor_offset == ioffset) - return; - - DeletePreExistingDLIfNeeded(); - m_nor_type = type; - m_nor_stride = stride; - m_nor_offset = int(size_t(offset)); - } -}; - -typedef std::unordered_map GLBufferMap; - -GLBufferMap g_GLBuffers; -GLBuffer* g_pCurrentlyBoundGLBuffer = nullptr; -GLuint g_NextGLBufferID; -bool g_bUseVertexArrays, g_bUseColorArrays, g_bUseNormalArrays, g_bUseTextureCoordArrays; // modified by xgl[En/Dis]ableClientState - -void xglGenBuffers(GLsizei num, GLuint* buffers) -{ - for (GLsizei i = 0; i < num; i++) - { - *buffers++ = ++g_NextGLBufferID; - g_GLBuffers[g_NextGLBufferID] = new GLBuffer(g_NextGLBufferID); - } - - LOG_I("g_NextGLBufferID=%d", g_NextGLBufferID); -} - -void xglAssert2(bool condition, const char* condstr, const char* file, int line) -{ - if (condition) return; - - LOG_E("Error: Assertion failed at %s:%d: %s", file, line, condstr); - -#ifdef _MSC_VER - assert(false); -#endif - - exit(1); -} -#define xglAssert(condition) xglAssert2(condition,#condition,__FILE__,__LINE__) - -void xglVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) -{ - xglAssert(g_pCurrentlyBoundGLBuffer != nullptr); - g_pCurrentlyBoundGLBuffer->SetVertexPointer(size, type, stride, pointer); -} - -void xglTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) -{ - xglAssert(g_pCurrentlyBoundGLBuffer != nullptr); - g_pCurrentlyBoundGLBuffer->SetTextureCoordPointer(size, type, stride, pointer); -} - -void xglColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) -{ - xglAssert(g_pCurrentlyBoundGLBuffer != nullptr); - g_pCurrentlyBoundGLBuffer->SetColorPointer(size, type, stride, pointer); -} - -void xglNormalPointer(GLenum type, GLsizei stride, const GLvoid* pointer) -{ - xglAssert(g_pCurrentlyBoundGLBuffer != nullptr); - g_pCurrentlyBoundGLBuffer->SetNormalPointer(type, stride, pointer); -} - -void xglBindBuffer(GLenum target, GLuint bufferID) -{ - xglAssert(target == GL_ARRAY_BUFFER); - - GLBufferMap::iterator iter = g_GLBuffers.find(bufferID); - if (iter == g_GLBuffers.end()) - return; - - g_pCurrentlyBoundGLBuffer = iter->second; -} - -void xglBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) -{ - xglAssert(target == GL_ARRAY_BUFFER); - xglAssert(g_pCurrentlyBoundGLBuffer != nullptr); - - GLBuffer* pBuf = g_pCurrentlyBoundGLBuffer; - - // check if the data is the SAME: - if (pBuf->m_bufferSize == size && memcmp(pBuf->m_pBufferData, data, size) == 0) - { - //nope - pBuf->m_usage = usage; - return; - } - - pBuf->DeletePreExistingDLIfNeeded(); - - // free the old data, if there was any - if (pBuf->m_pBufferData) - { - free(pBuf->m_pBufferData); - pBuf->m_pBufferData = nullptr; - } - - pBuf->m_pBufferData = (GLvoid*)malloc(size); - xglAssert(pBuf->m_pBufferData != nullptr); - - memcpy(pBuf->m_pBufferData, data, size); - - pBuf->m_usage = usage; -} - -void xglDeleteBuffer(GLsizei num) -{ - GLBufferMap::iterator iter = g_GLBuffers.find(num); - xglAssert(iter != g_GLBuffers.end()); - - if (iter->second == g_pCurrentlyBoundGLBuffer) - g_pCurrentlyBoundGLBuffer = nullptr; - - iter->second->DeletePreExistingDLIfNeeded(); - - delete iter->second; - g_GLBuffers.erase(iter); -} - -void xglDeleteBuffers(GLsizei num, GLuint* buffers) -{ - for (GLsizei i = 0; i < num; i++) - { - xglDeleteBuffer(buffers[i]); - buffers[i] = 0; - } -} - -void xglEnableClientState(GLenum _array) -{ - switch (_array) - { - case GL_VERTEX_ARRAY: - g_bUseVertexArrays = true; - return; - case GL_COLOR_ARRAY: - g_bUseColorArrays = true; - return; - case GL_NORMAL_ARRAY: - g_bUseNormalArrays = true; - return; - case GL_TEXTURE_COORD_ARRAY: - g_bUseTextureCoordArrays = true; - return; - default: - glEnableClientState(_array); - } -} - -void xglDisableClientState(GLenum _array) -{ - switch (_array) - { - case GL_VERTEX_ARRAY: - g_bUseVertexArrays = false; - return; - case GL_COLOR_ARRAY: - g_bUseColorArrays = false; - return; - case GL_NORMAL_ARRAY: - g_bUseNormalArrays = false; - return; - case GL_TEXTURE_COORD_ARRAY: - g_bUseTextureCoordArrays = false; - return; - default: - glDisableClientState(_array); - } -} - -void xglDrawArrays(GLenum mode, GLint first, GLsizei count) -{ - xglAssert(g_pCurrentlyBoundGLBuffer != nullptr); - GLBuffer* pBuf = g_pCurrentlyBoundGLBuffer; - -#ifdef USE_DISPLAY_LISTS - if (pBuf->HasDisplayList()) - { - glCallList(pBuf->GetDisplayList()); - return; - } - - GLuint currDL = glGenLists(1); - pBuf->SetDisplayList(currDL); - - glNewList(currDL, GL_COMPILE); -#endif - - glBegin(mode); - - for (GLsizeiptr i = first, j = 0; j < count; i++, j++) - { - uintptr_t addr = uintptr_t(pBuf->m_pBufferData); - - void* pVtx = (void*)(addr + pBuf->m_vtx_offset + i * pBuf->m_vtx_stride); - void* pCol = (void*)(addr + pBuf->m_col_offset + i * pBuf->m_col_stride); - void* pNor = (void*)(addr + pBuf->m_col_offset + i * pBuf->m_col_stride); - void* pTC = (void*)(addr + pBuf->m_tc_offset + i * pBuf->m_tc_stride); - - if (g_bUseTextureCoordArrays) - { - if (pBuf->m_tc_type == GL_FLOAT) - { - float* pfTC = (float*)pTC; - /**/ if (pBuf->m_tc_size == 2) - glTexCoord2fv(pfTC); - else xglAssert(!"Unimplemented texcoord size!"); - } - else xglAssert(!"Unimplemented texcoord type!"); - } - - if (g_bUseColorArrays) - { - if (pBuf->m_col_type == GL_UNSIGNED_BYTE) - { - uint8_t* pfCol = (uint8_t*)pCol; - /**/ if (pBuf->m_col_size == 4) - glColor4f(float(pfCol[0])/255.0f, float(pfCol[1])/255.0f, float(pfCol[2])/255.0f, float(pfCol[3])/255.0f); - else xglAssert(!"Unimplemented color size!"); - } - else xglAssert(!"Unimplemented color type!"); - } - - if (g_bUseNormalArrays) - { - //xglAssert(!"Unimplemented normal type!"); - } - - if (g_bUseVertexArrays) - { - if (pBuf->m_vtx_type == GL_FLOAT) - { - float* pfVtx = (float*)pVtx; - /**/ if (pBuf->m_vtx_size == 3) - glVertex3fv(pfVtx); - else if (pBuf->m_vtx_size == 2) - glVertex2fv(pfVtx); - else xglAssert(!"Unimplemented texcoord size!"); - } - else xglAssert(!"Unimplemented vertex type!"); - } - } - - glEnd(); -#ifdef USE_DISPLAY_LISTS - glEndList(); - - glCallList(pBuf->GetDisplayList()); -#endif -} - -#endif - -#endif diff --git a/thirdparty/glm/CMakeLists.txt b/thirdparty/glm/CMakeLists.txt new file mode 100644 index 000000000..9dbe11cab --- /dev/null +++ b/thirdparty/glm/CMakeLists.txt @@ -0,0 +1,42 @@ +set(NAME glm_dummy) + +file(GLOB ROOT_SOURCE *.cpp) +file(GLOB ROOT_INLINE *.inl) +file(GLOB ROOT_HEADER *.hpp) +file(GLOB ROOT_TEXT ../*.txt) + +file(GLOB_RECURSE CORE_SOURCE ./detail/*.cpp) +file(GLOB_RECURSE CORE_INLINE ./detail/*.inl) +file(GLOB_RECURSE CORE_HEADER ./detail/*.hpp) + +file(GLOB_RECURSE GTC_SOURCE ./gtc/*.cpp) +file(GLOB_RECURSE GTC_INLINE ./gtc/*.inl) +file(GLOB_RECURSE GTC_HEADER ./gtc/*.hpp) + +file(GLOB_RECURSE GTX_SOURCE ./gtx/*.cpp) +file(GLOB_RECURSE GTX_INLINE ./gtx/*.inl) +file(GLOB_RECURSE GTX_HEADER ./gtx/*.hpp) + +source_group("Text Files" FILES ${ROOT_TEXT}) +source_group("Core Files" FILES ${CORE_SOURCE}) +source_group("Core Files" FILES ${CORE_INLINE}) +source_group("Core Files" FILES ${CORE_HEADER}) +source_group("GTC Files" FILES ${GTC_SOURCE}) +source_group("GTC Files" FILES ${GTC_INLINE}) +source_group("GTC Files" FILES ${GTC_HEADER}) +source_group("GTX Files" FILES ${GTX_SOURCE}) +source_group("GTX Files" FILES ${GTX_INLINE}) +source_group("GTX Files" FILES ${GTX_HEADER}) + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) + +if(GLM_TEST_ENABLE) + add_executable(${NAME} ${ROOT_TEXT} + ${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER} + ${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER} + ${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER} + ${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER}) +endif(GLM_TEST_ENABLE) + +#add_library(glm STATIC glm.cpp) +#add_library(glm_shared SHARED glm.cpp) diff --git a/thirdparty/glm/common.hpp b/thirdparty/glm/common.hpp new file mode 100644 index 000000000..2d787dde0 --- /dev/null +++ b/thirdparty/glm/common.hpp @@ -0,0 +1,34 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/common.hpp +/// @date 2013-12-24 / 2013-12-24 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_COMMON_INCLUDED +#define GLM_COMMON_INCLUDED + +#include "detail/func_common.hpp" + +#endif//GLM_COMMON_INCLUDED diff --git a/thirdparty/glm/detail/_features.hpp b/thirdparty/glm/detail/_features.hpp new file mode 100644 index 000000000..1c7fe8c96 --- /dev/null +++ b/thirdparty/glm/detail/_features.hpp @@ -0,0 +1,427 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/core/_features.hpp +/// @date 2013-02-20 / 2013-02-20 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef glm_core_features +#define glm_core_features + +// #define GLM_CXX98_EXCEPTIONS +// #define GLM_CXX98_RTTI + +// #define GLM_CXX11_RVALUE_REFERENCES +// Rvalue references - GCC 4.3 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2118.html + +// GLM_CXX11_TRAILING_RETURN +// Rvalue references for *this - GCC not supported +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2439.htm + +// GLM_CXX11_NONSTATIC_MEMBER_INIT +// Initialization of class objects by rvalues - GCC any +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1610.html + +// GLM_CXX11_NONSTATIC_MEMBER_INIT +// Non-static data member initializers - GCC 4.7 +// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2008/n2756.htm + +// #define GLM_CXX11_VARIADIC_TEMPLATE +// Variadic templates - GCC 4.3 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2242.pdf + +// +// Extending variadic template template parameters - GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2555.pdf + +// #define GLM_CXX11_GENERALIZED_INITIALIZERS +// Initializer lists - GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2672.htm + +// #define GLM_CXX11_STATIC_ASSERT +// Static assertions - GCC 4.3 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1720.html + +// #define GLM_CXX11_AUTO_TYPE +// auto-typed variables - GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1984.pdf + +// #define GLM_CXX11_AUTO_TYPE +// Multi-declarator auto - GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1737.pdf + +// #define GLM_CXX11_AUTO_TYPE +// Removal of auto as a storage-class specifier - GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2546.htm + +// #define GLM_CXX11_AUTO_TYPE +// New function declarator syntax - GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2541.htm + +// #define GLM_CXX11_LAMBDAS +// New wording for C++0x lambdas - GCC 4.5 +// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2927.pdf + +// #define GLM_CXX11_DECLTYPE +// Declared type of an expression - GCC 4.3 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2343.pdf + +// +// Right angle brackets - GCC 4.3 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1757.html + +// +// Default template arguments for function templates DR226 GCC 4.3 +// http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#226 + +// +// Solving the SFINAE problem for expressions DR339 GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2634.html + +// #define GLM_CXX11_ALIAS_TEMPLATE +// Template aliases N2258 GCC 4.7 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf + +// +// Extern templates N1987 Yes +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1987.htm + +// #define GLM_CXX11_NULLPTR +// Null pointer constant N2431 GCC 4.6 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2431.pdf + +// #define GLM_CXX11_STRONG_ENUMS +// Strongly-typed enums N2347 GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2347.pdf + +// +// Forward declarations for enums N2764 GCC 4.6 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2764.pdf + +// +// Generalized attributes N2761 GCC 4.8 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2761.pdf + +// +// Generalized constant expressions N2235 GCC 4.6 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2235.pdf + +// +// Alignment support N2341 GCC 4.8 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf + +// #define GLM_CXX11_DELEGATING_CONSTRUCTORS +// Delegating constructors N1986 GCC 4.7 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1986.pdf + +// +// Inheriting constructors N2540 GCC 4.8 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2540.htm + +// #define GLM_CXX11_EXPLICIT_CONVERSIONS +// Explicit conversion operators N2437 GCC 4.5 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2437.pdf + +// +// New character types N2249 GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2249.html + +// +// Unicode string literals N2442 GCC 4.5 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2442.htm + +// +// Raw string literals N2442 GCC 4.5 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2442.htm + +// +// Universal character name literals N2170 GCC 4.5 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2170.html + +// #define GLM_CXX11_USER_LITERALS +// User-defined literals N2765 GCC 4.7 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2765.pdf + +// +// Standard Layout Types N2342 GCC 4.5 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2342.htm + +// #define GLM_CXX11_DEFAULTED_FUNCTIONS +// #define GLM_CXX11_DELETED_FUNCTIONS +// Defaulted and deleted functions N2346 GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm + +// +// Extended friend declarations N1791 GCC 4.7 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1791.pdf + +// +// Extending sizeof N2253 GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2253.html + +// #define GLM_CXX11_INLINE_NAMESPACES +// Inline namespaces N2535 GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2535.htm + +// #define GLM_CXX11_UNRESTRICTED_UNIONS +// Unrestricted unions N2544 GCC 4.6 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2544.pdf + +// #define GLM_CXX11_LOCAL_TYPE_TEMPLATE_ARGS +// Local and unnamed types as template arguments N2657 GCC 4.5 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm + +// #define GLM_CXX11_RANGE_FOR +// Range-based for N2930 GCC 4.6 +// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2930.html + +// #define GLM_CXX11_OVERRIDE_CONTROL +// Explicit virtual overrides N2928 N3206 N3272 GCC 4.7 +// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2928.htm +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3206.htm +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3272.htm + +// +// Minimal support for garbage collection and reachability-based leak detection N2670 No +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2670.htm + +// #define GLM_CXX11_NOEXCEPT +// Allowing move constructors to throw [noexcept] N3050 GCC 4.6 (core language only) +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3050.html + +// +// Defining move special member functions N3053 GCC 4.6 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3053.html + +// +// Sequence points N2239 Yes +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2239.html + +// +// Atomic operations N2427 GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2239.html + +// +// Strong Compare and Exchange N2748 GCC 4.5 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2427.html + +// +// Bidirectional Fences N2752 GCC 4.8 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2752.htm + +// +// Memory model N2429 GCC 4.8 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2429.htm + +// +// Data-dependency ordering: atomics and memory model N2664 GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2664.htm + +// +// Propagating exceptions N2179 GCC 4.4 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2179.html + +// +// Abandoning a process and at_quick_exit N2440 GCC 4.8 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2440.htm + +// +// Allow atomics use in signal handlers N2547 Yes +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2547.htm + +// +// Thread-local storage N2659 GCC 4.8 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2659.htm + +// +// Dynamic initialization and destruction with concurrency N2660 GCC 4.3 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2660.htm + +// +// __func__ predefined identifier N2340 GCC 4.3 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2340.htm + +// +// C99 preprocessor N1653 GCC 4.3 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1653.htm + +// +// long long N1811 GCC 4.3 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1811.pdf + +// +// Extended integral types N1988 Yes +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1988.pdf + +#if(GLM_COMPILER & GLM_COMPILER_GCC) + +# if(GLM_COMPILER >= GLM_COMPILER_GCC43) +# define GLM_CXX11_STATIC_ASSERT +# endif + +#elif(GLM_COMPILER & GLM_COMPILER_CLANG) +# if(__has_feature(cxx_exceptions)) +# define GLM_CXX98_EXCEPTIONS +# endif + +# if(__has_feature(cxx_rtti)) +# define GLM_CXX98_RTTI +# endif + +# if(__has_feature(cxx_access_control_sfinae)) +# define GLM_CXX11_ACCESS_CONTROL_SFINAE +# endif + +# if(__has_feature(cxx_alias_templates)) +# define GLM_CXX11_ALIAS_TEMPLATE +# endif + +# if(__has_feature(cxx_alignas)) +# define GLM_CXX11_ALIGNAS +# endif + +# if(__has_feature(cxx_attributes)) +# define GLM_CXX11_ATTRIBUTES +# endif + +# if(__has_feature(cxx_constexpr)) +# define GLM_CXX11_CONSTEXPR +# endif + +# if(__has_feature(cxx_decltype)) +# define GLM_CXX11_DECLTYPE +# endif + +# if(__has_feature(cxx_default_function_template_args)) +# define GLM_CXX11_DEFAULT_FUNCTION_TEMPLATE_ARGS +# endif + +# if(__has_feature(cxx_defaulted_functions)) +# define GLM_CXX11_DEFAULTED_FUNCTIONS +# endif + +# if(__has_feature(cxx_delegating_constructors)) +# define GLM_CXX11_DELEGATING_CONSTRUCTORS +# endif + +# if(__has_feature(cxx_deleted_functions)) +# define GLM_CXX11_DELETED_FUNCTIONS +# endif + +# if(__has_feature(cxx_explicit_conversions)) +# define GLM_CXX11_EXPLICIT_CONVERSIONS +# endif + +# if(__has_feature(cxx_generalized_initializers)) +# define GLM_CXX11_GENERALIZED_INITIALIZERS +# endif + +# if(__has_feature(cxx_implicit_moves)) +# define GLM_CXX11_IMPLICIT_MOVES +# endif + +# if(__has_feature(cxx_inheriting_constructors)) +# define GLM_CXX11_INHERITING_CONSTRUCTORS +# endif + +# if(__has_feature(cxx_inline_namespaces)) +# define GLM_CXX11_INLINE_NAMESPACES +# endif + +# if(__has_feature(cxx_lambdas)) +# define GLM_CXX11_LAMBDAS +# endif + +# if(__has_feature(cxx_local_type_template_args)) +# define GLM_CXX11_LOCAL_TYPE_TEMPLATE_ARGS +# endif + +# if(__has_feature(cxx_noexcept)) +# define GLM_CXX11_NOEXCEPT +# endif + +# if(__has_feature(cxx_nonstatic_member_init)) +# define GLM_CXX11_NONSTATIC_MEMBER_INIT +# endif + +# if(__has_feature(cxx_nullptr)) +# define GLM_CXX11_NULLPTR +# endif + +# if(__has_feature(cxx_override_control)) +# define GLM_CXX11_OVERRIDE_CONTROL +# endif + +# if(__has_feature(cxx_reference_qualified_functions)) +# define GLM_CXX11_REFERENCE_QUALIFIED_FUNCTIONS +# endif + +# if(__has_feature(cxx_range_for)) +# define GLM_CXX11_RANGE_FOR +# endif + +# if(__has_feature(cxx_raw_string_literals)) +# define GLM_CXX11_RAW_STRING_LITERALS +# endif + +# if(__has_feature(cxx_rvalue_references)) +# define GLM_CXX11_RVALUE_REFERENCES +# endif + +# if(__has_feature(cxx_static_assert)) +# define GLM_CXX11_STATIC_ASSERT +# endif + +# if(__has_feature(cxx_auto_type)) +# define GLM_CXX11_AUTO_TYPE +# endif + +# if(__has_feature(cxx_strong_enums)) +# define GLM_CXX11_STRONG_ENUMS +# endif + +# if(__has_feature(cxx_trailing_return)) +# define GLM_CXX11_TRAILING_RETURN +# endif + +# if(__has_feature(cxx_unicode_literals)) +# define GLM_CXX11_UNICODE_LITERALS +# endif + +# if(__has_feature(cxx_unrestricted_unions)) +# define GLM_CXX11_UNRESTRICTED_UNIONS +# endif + +# if(__has_feature(cxx_user_literals)) +# define GLM_CXX11_USER_LITERALS +# endif + +# if(__has_feature(cxx_variadic_templates)) +# define GLM_CXX11_VARIADIC_TEMPLATES +# endif + +#endif//(GLM_COMPILER & GLM_COMPILER_CLANG) + +#endif//glm_core_features diff --git a/thirdparty/glm/detail/_fixes.hpp b/thirdparty/glm/detail/_fixes.hpp new file mode 100644 index 000000000..ce13bb1be --- /dev/null +++ b/thirdparty/glm/detail/_fixes.hpp @@ -0,0 +1,55 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/core/_fixes.hpp +/// @date 2011-02-21 / 2011-11-22 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +#include + +//! Workaround for compatibility with other libraries +#ifdef max +#undef max +#endif + +//! Workaround for compatibility with other libraries +#ifdef min +#undef min +#endif + +//! Workaround for Android +#ifdef isnan +#undef isnan +#endif + +//! Workaround for Android +#ifdef isinf +#undef isinf +#endif + +//! Workaround for Chrone Native Client +#ifdef log2 +#undef log2 +#endif + diff --git a/thirdparty/glm/detail/_literals.hpp b/thirdparty/glm/detail/_literals.hpp new file mode 100644 index 000000000..79780ccf6 --- /dev/null +++ b/thirdparty/glm/detail/_literals.hpp @@ -0,0 +1,51 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/core/_literals.hpp +/// @date 2013-05-06 / 2013-05-06 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef glm_core_literals +#define glm_core_literals + +namespace glm +{ +#define GLM_CXX11_USER_LITERALS +#ifdef GLM_CXX11_USER_LITERALS +/* + GLM_FUNC_QUALIFIER detail::half operator "" _h(long double const s) + { + return detail::half(s); + } + + GLM_FUNC_QUALIFIER float operator "" _f(long double const s) + { + return static_cast(s); + } +*/ +#endif//GLM_CXX11_USER_LITERALS + +}//namespace glm + +#endif//glm_core_literals diff --git a/thirdparty/glm/detail/_noise.hpp b/thirdparty/glm/detail/_noise.hpp new file mode 100644 index 000000000..e366e7c38 --- /dev/null +++ b/thirdparty/glm/detail/_noise.hpp @@ -0,0 +1,130 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/detail/_noise.hpp +/// @date 2013-12-24 / 2013-12-24 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_DETAIL_NOISE_INCLUDED +#define GLM_DETAIL_NOISE_INCLUDED + +namespace glm{ +namespace detail +{ + template + GLM_FUNC_QUALIFIER T mod289(T const & x) + { + return x - floor(x * static_cast(1.0) / static_cast(289.0)) * static_cast(289.0); + } + + template + GLM_FUNC_QUALIFIER T permute(T const & x) + { + return mod289(((x * static_cast(34)) + static_cast(1)) * x); + } + + template + GLM_FUNC_QUALIFIER tvec2 permute(tvec2 const & x) + { + return mod289(((x * static_cast(34)) + static_cast(1)) * x); + } + + template + GLM_FUNC_QUALIFIER tvec3 permute(tvec3 const & x) + { + return mod289(((x * static_cast(34)) + static_cast(1)) * x); + } + + template + GLM_FUNC_QUALIFIER tvec4 permute(tvec4 const & x) + { + return mod289(((x * static_cast(34)) + static_cast(1)) * x); + } +/* + template class vecType> + GLM_FUNC_QUALIFIER vecType permute(vecType const & x) + { + return mod289(((x * T(34)) + T(1)) * x); + } +*/ + template + GLM_FUNC_QUALIFIER T taylorInvSqrt(T const & r) + { + return T(1.79284291400159) - T(0.85373472095314) * r; + } + + template + GLM_FUNC_QUALIFIER detail::tvec2 taylorInvSqrt(detail::tvec2 const & r) + { + return T(1.79284291400159) - T(0.85373472095314) * r; + } + + template + GLM_FUNC_QUALIFIER detail::tvec3 taylorInvSqrt(detail::tvec3 const & r) + { + return T(1.79284291400159) - T(0.85373472095314) * r; + } + + template + GLM_FUNC_QUALIFIER detail::tvec4 taylorInvSqrt(detail::tvec4 const & r) + { + return T(1.79284291400159) - T(0.85373472095314) * r; + } +/* + template class vecType> + GLM_FUNC_QUALIFIER vecType taylorInvSqrt(vecType const & r) + { + return T(1.79284291400159) - T(0.85373472095314) * r; + } +*/ + + template + GLM_FUNC_QUALIFIER detail::tvec2 fade(detail::tvec2 const & t) + { + return (t * t * t) * (t * (t * T(6) - T(15)) + T(10)); + } + + template + GLM_FUNC_QUALIFIER detail::tvec3 fade(detail::tvec3 const & t) + { + return (t * t * t) * (t * (t * T(6) - T(15)) + T(10)); + } + + template + GLM_FUNC_QUALIFIER detail::tvec4 fade(detail::tvec4 const & t) + { + return (t * t * t) * (t * (t * T(6) - T(15)) + T(10)); + } +/* + template class vecType> + GLM_FUNC_QUALIFIER vecType fade(vecType const & t) + { + return (t * t * t) * (t * (t * T(6) - T(15)) + T(10)); + } +*/ +}//namespace detail +}//namespace glm + +#endif//GLM_DETAIL_NOISE_INCLUDED + diff --git a/thirdparty/glm/detail/_swizzle.hpp b/thirdparty/glm/detail/_swizzle.hpp new file mode 100644 index 000000000..407ffb49c --- /dev/null +++ b/thirdparty/glm/detail/_swizzle.hpp @@ -0,0 +1,840 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/core/_swizzle.hpp +/// @date 2006-04-20 / 2011-02-16 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef glm_core_swizzle +#define glm_core_swizzle + +namespace glm{ +namespace detail +{ + // Internal class for implementing swizzle operators + template + struct _swizzle_base0 + { + typedef T value_type; + + protected: + GLM_FUNC_QUALIFIER value_type& elem (size_t i) { return (reinterpret_cast(_buffer))[i]; } + GLM_FUNC_QUALIFIER const value_type& elem (size_t i) const { return (reinterpret_cast(_buffer))[i]; } + + // Use an opaque buffer to *ensure* the compiler doesn't call a constructor. + // The size 1 buffer is assumed to aligned to the actual members so that the + // elem() + char _buffer[1]; + }; + + template + struct _swizzle_base1 : public _swizzle_base0 + { + }; + + template + struct _swizzle_base1 : public _swizzle_base0 + { + GLM_FUNC_QUALIFIER V operator ()() const { return V(this->elem(E0), this->elem(E1)); } + }; + + template + struct _swizzle_base1 : public _swizzle_base0 + { + GLM_FUNC_QUALIFIER V operator ()() const { return V(this->elem(E0), this->elem(E1), this->elem(E2)); } + }; + + template + struct _swizzle_base1 : public _swizzle_base0 + { + GLM_FUNC_QUALIFIER V operator ()() const { return V(this->elem(E0), this->elem(E1), this->elem(E2), this->elem(E3)); } + }; + + // Internal class for implementing swizzle operators + /* + Template parameters: + + ValueType = type of scalar values (e.g. float, double) + VecType = class the swizzle is applies to (e.g. tvec3) + N = number of components in the vector (e.g. 3) + E0...3 = what index the n-th element of this swizzle refers to in the unswizzled vec + + DUPLICATE_ELEMENTS = 1 if there is a repeated element, 0 otherwise (used to specialize swizzles + containing duplicate elements so that they cannot be used as r-values). + */ + template + struct _swizzle_base2 : public _swizzle_base1 + { + typedef VecType vec_type; + typedef ValueType value_type; + + GLM_FUNC_QUALIFIER _swizzle_base2& operator= (const ValueType& t) + { + for (int i = 0; i < N; ++i) + (*this)[i] = t; + return *this; + } + + GLM_FUNC_QUALIFIER _swizzle_base2& operator= (const VecType& that) + { + struct op { + GLM_FUNC_QUALIFIER void operator() (value_type& e, value_type& t) { e = t; } + }; + _apply_op(that, op()); + return *this; + } + + GLM_FUNC_QUALIFIER void operator -= (const VecType& that) + { + struct op { + GLM_FUNC_QUALIFIER void operator() (value_type& e, value_type& t) { e -= t; } + }; + _apply_op(that, op()); + } + + GLM_FUNC_QUALIFIER void operator += (const VecType& that) + { + struct op { + GLM_FUNC_QUALIFIER void operator() (value_type& e, value_type& t) { e += t; } + }; + _apply_op(that, op()); + } + + GLM_FUNC_QUALIFIER void operator *= (const VecType& that) + { + struct op { + GLM_FUNC_QUALIFIER void operator() (value_type& e, value_type& t) { e *= t; } + }; + _apply_op(that, op()); + } + + GLM_FUNC_QUALIFIER void operator /= (const VecType& that) + { + struct op { + GLM_FUNC_QUALIFIER void operator() (value_type& e, value_type& t) { e /= t; } + }; + _apply_op(that, op()); + } + + GLM_FUNC_QUALIFIER value_type& operator[] (size_t i) + { +#ifndef __CUDA_ARCH__ + static +#endif + const int offset_dst[4] = { E0, E1, E2, E3 }; + return this->elem(offset_dst[i]); + } + GLM_FUNC_QUALIFIER value_type operator[] (size_t i) const + { +#ifndef __CUDA_ARCH__ + static +#endif + const int offset_dst[4] = { E0, E1, E2, E3 }; + return this->elem(offset_dst[i]); + } + protected: + template + GLM_FUNC_QUALIFIER void _apply_op(const VecType& that, T op) + { + // Make a copy of the data in this == &that. + // The copier should optimize out the copy in cases where the function is + // properly inlined and the copy is not necessary. + ValueType t[N]; + for (int i = 0; i < N; ++i) + t[i] = that[i]; + for (int i = 0; i < N; ++i) + op( (*this)[i], t[i] ); + } + }; + + // Specialization for swizzles containing duplicate elements. These cannot be modified. + template + struct _swizzle_base2 : public _swizzle_base1 + { + typedef VecType vec_type; + typedef ValueType value_type; + + struct Stub {}; + GLM_FUNC_QUALIFIER _swizzle_base2& operator= (Stub const &) { return *this; } + + GLM_FUNC_QUALIFIER value_type operator[] (size_t i) const + { +#ifndef __CUDA_ARCH__ + static +#endif + const int offset_dst[4] = { E0, E1, E2, E3 }; + return this->elem(offset_dst[i]); + } + }; + + template + struct _swizzle : public _swizzle_base2 + { + typedef _swizzle_base2 base_type; + + using base_type::operator=; + + GLM_FUNC_QUALIFIER operator VecType () const { return (*this)(); } + }; + +// +// To prevent the C++ syntax from getting entirely overwhelming, define some alias macros +// +#define _GLM_SWIZZLE_TEMPLATE1 template +#define _GLM_SWIZZLE_TEMPLATE2 template +#define _GLM_SWIZZLE_TYPE1 _swizzle +#define _GLM_SWIZZLE_TYPE2 _swizzle + +// +// Wrapper for a binary operator (e.g. u.yy + v.zy) +// +#define _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(OPERAND) \ + _GLM_SWIZZLE_TEMPLATE2 \ + GLM_FUNC_QUALIFIER V operator OPERAND ( const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE2& b) \ + { \ + return a() OPERAND b(); \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + GLM_FUNC_QUALIFIER V operator OPERAND ( const _GLM_SWIZZLE_TYPE1& a, const V& b) \ + { \ + return a() OPERAND b; \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + GLM_FUNC_QUALIFIER V operator OPERAND ( const V& a, const _GLM_SWIZZLE_TYPE1& b) \ + { \ + return a OPERAND b(); \ + } + +// +// Wrapper for a operand between a swizzle and a binary (e.g. 1.0f - u.xyz) +// +#define _GLM_SWIZZLE_SCALAR_BINARY_OPERATOR_IMPLEMENTATION(OPERAND) \ + _GLM_SWIZZLE_TEMPLATE1 \ + GLM_FUNC_QUALIFIER V operator OPERAND ( const _GLM_SWIZZLE_TYPE1& a, const T& b) \ + { \ + return a() OPERAND b; \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + GLM_FUNC_QUALIFIER V operator OPERAND ( const T& a, const _GLM_SWIZZLE_TYPE1& b) \ + { \ + return a OPERAND b(); \ + } + +// +// Macro for wrapping a function taking one argument (e.g. abs()) +// +#define _GLM_SWIZZLE_FUNCTION_1_ARGS(RETURN_TYPE,FUNCTION) \ + _GLM_SWIZZLE_TEMPLATE1 \ + GLM_FUNC_QUALIFIER typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a) \ + { \ + return FUNCTION(a()); \ + } + +// +// Macro for wrapping a function taking two vector arguments (e.g. dot()). +// +#define _GLM_SWIZZLE_FUNCTION_2_ARGS(RETURN_TYPE,FUNCTION) \ + _GLM_SWIZZLE_TEMPLATE2 \ + GLM_FUNC_QUALIFIER typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE2& b) \ + { \ + return FUNCTION(a(), b()); \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + GLM_FUNC_QUALIFIER typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE1& b) \ + { \ + return FUNCTION(a(), b()); \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + GLM_FUNC_QUALIFIER typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const typename V& b) \ + { \ + return FUNCTION(a(), b); \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + GLM_FUNC_QUALIFIER typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const V& a, const _GLM_SWIZZLE_TYPE1& b) \ + { \ + return FUNCTION(a, b()); \ + } + +// +// Macro for wrapping a function take 2 vec arguments followed by a scalar (e.g. mix()). +// +#define _GLM_SWIZZLE_FUNCTION_2_ARGS_SCALAR(RETURN_TYPE,FUNCTION) \ + _GLM_SWIZZLE_TEMPLATE2 \ + GLM_FUNC_QUALIFIER typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE2& b, const T& c) \ + { \ + return FUNCTION(a(), b(), c); \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + GLM_FUNC_QUALIFIER typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE1& b, const T& c) \ + { \ + return FUNCTION(a(), b(), c); \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + GLM_FUNC_QUALIFIER typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const typename S0::vec_type& b, const T& c)\ + { \ + return FUNCTION(a(), b, c); \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + GLM_FUNC_QUALIFIER typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const typename V& a, const _GLM_SWIZZLE_TYPE1& b, const T& c) \ + { \ + return FUNCTION(a, b(), c); \ + } + +}//namespace detail +}//namespace glm + +namespace glm +{ + namespace detail + { + _GLM_SWIZZLE_SCALAR_BINARY_OPERATOR_IMPLEMENTATION(-) + _GLM_SWIZZLE_SCALAR_BINARY_OPERATOR_IMPLEMENTATION(*) + _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(+) + _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(-) + _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(*) + _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(/) + } + + // + // Swizzles are distinct types from the unswizzled type. The below macros will + // provide template specializations for the swizzle types for the given functions + // so that the compiler does not have any ambiguity to choosing how to handle + // the function. + // + // The alternative is to use the operator()() when calling the function in order + // to explicitly convert the swizzled type to the unswizzled type. + // + + //_GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, abs); + //_GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, acos); + //_GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, acosh); + //_GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, all); + //_GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, any); + + //_GLM_SWIZZLE_FUNCTION_2_ARGS(value_type, dot); + //_GLM_SWIZZLE_FUNCTION_2_ARGS(vec_type, cross); + //_GLM_SWIZZLE_FUNCTION_2_ARGS(vec_type, step); + //_GLM_SWIZZLE_FUNCTION_2_ARGS_SCALAR(vec_type, mix); +} + +#define _GLM_SWIZZLE2_2_MEMBERS(T, P, V, E0,E1) \ + struct { _swizzle<2, T, P, V, 0,0,-1,-2> E0 ## E0; }; \ + struct { _swizzle<2, T, P, V, 0,1,-1,-2> E0 ## E1; }; \ + struct { _swizzle<2, T, P, V, 1,0,-1,-2> E1 ## E0; }; \ + struct { _swizzle<2, T, P, V, 1,1,-1,-2> E1 ## E1; }; + +#define _GLM_SWIZZLE2_3_MEMBERS(T, P, V, E0,E1) \ + struct { _swizzle<3,T, P, V, 0,0,0,-1> E0 ## E0 ## E0; }; \ + struct { _swizzle<3,T, P, V, 0,0,1,-1> E0 ## E0 ## E1; }; \ + struct { _swizzle<3,T, P, V, 0,1,0,-1> E0 ## E1 ## E0; }; \ + struct { _swizzle<3,T, P, V, 0,1,1,-1> E0 ## E1 ## E1; }; \ + struct { _swizzle<3,T, P, V, 1,0,0,-1> E1 ## E0 ## E0; }; \ + struct { _swizzle<3,T, P, V, 1,0,1,-1> E1 ## E0 ## E1; }; \ + struct { _swizzle<3,T, P, V, 1,1,0,-1> E1 ## E1 ## E0; }; \ + struct { _swizzle<3,T, P, V, 1,1,1,-1> E1 ## E1 ## E1; }; + +#define _GLM_SWIZZLE2_4_MEMBERS(T, P, V, E0,E1) \ + struct { _swizzle<4,T, P, V, 0,0,0,0> E0 ## E0 ## E0 ## E0; }; \ + struct { _swizzle<4,T, P, V, 0,0,0,1> E0 ## E0 ## E0 ## E1; }; \ + struct { _swizzle<4,T, P, V, 0,0,1,0> E0 ## E0 ## E1 ## E0; }; \ + struct { _swizzle<4,T, P, V, 0,0,1,1> E0 ## E0 ## E1 ## E1; }; \ + struct { _swizzle<4,T, P, V, 0,1,0,0> E0 ## E1 ## E0 ## E0; }; \ + struct { _swizzle<4,T, P, V, 0,1,0,1> E0 ## E1 ## E0 ## E1; }; \ + struct { _swizzle<4,T, P, V, 0,1,1,0> E0 ## E1 ## E1 ## E0; }; \ + struct { _swizzle<4,T, P, V, 0,1,1,1> E0 ## E1 ## E1 ## E1; }; \ + struct { _swizzle<4,T, P, V, 1,0,0,0> E1 ## E0 ## E0 ## E0; }; \ + struct { _swizzle<4,T, P, V, 1,0,0,1> E1 ## E0 ## E0 ## E1; }; \ + struct { _swizzle<4,T, P, V, 1,0,1,0> E1 ## E0 ## E1 ## E0; }; \ + struct { _swizzle<4,T, P, V, 1,0,1,1> E1 ## E0 ## E1 ## E1; }; \ + struct { _swizzle<4,T, P, V, 1,1,0,0> E1 ## E1 ## E0 ## E0; }; \ + struct { _swizzle<4,T, P, V, 1,1,0,1> E1 ## E1 ## E0 ## E1; }; \ + struct { _swizzle<4,T, P, V, 1,1,1,0> E1 ## E1 ## E1 ## E0; }; \ + struct { _swizzle<4,T, P, V, 1,1,1,1> E1 ## E1 ## E1 ## E1; }; + +#define _GLM_SWIZZLE3_2_MEMBERS(T, P, V, E0,E1,E2) \ + struct { _swizzle<2,T, P, V, 0,0,-1,-2> E0 ## E0; }; \ + struct { _swizzle<2,T, P, V, 0,1,-1,-2> E0 ## E1; }; \ + struct { _swizzle<2,T, P, V, 0,2,-1,-2> E0 ## E2; }; \ + struct { _swizzle<2,T, P, V, 1,0,-1,-2> E1 ## E0; }; \ + struct { _swizzle<2,T, P, V, 1,1,-1,-2> E1 ## E1; }; \ + struct { _swizzle<2,T, P, V, 1,2,-1,-2> E1 ## E2; }; \ + struct { _swizzle<2,T, P, V, 2,0,-1,-2> E2 ## E0; }; \ + struct { _swizzle<2,T, P, V, 2,1,-1,-2> E2 ## E1; }; \ + struct { _swizzle<2,T, P, V, 2,2,-1,-2> E2 ## E2; }; + +#define _GLM_SWIZZLE3_3_MEMBERS(T, P, V ,E0,E1,E2) \ + struct { _swizzle<3,T,P, V, 0,0,0,-1> E0 ## E0 ## E0; }; \ + struct { _swizzle<3,T,P, V, 0,0,1,-1> E0 ## E0 ## E1; }; \ + struct { _swizzle<3,T,P, V, 0,0,2,-1> E0 ## E0 ## E2; }; \ + struct { _swizzle<3,T,P, V, 0,1,0,-1> E0 ## E1 ## E0; }; \ + struct { _swizzle<3,T,P, V, 0,1,1,-1> E0 ## E1 ## E1; }; \ + struct { _swizzle<3,T,P, V, 0,1,2,-1> E0 ## E1 ## E2; }; \ + struct { _swizzle<3,T,P, V, 0,2,0,-1> E0 ## E2 ## E0; }; \ + struct { _swizzle<3,T,P, V, 0,2,1,-1> E0 ## E2 ## E1; }; \ + struct { _swizzle<3,T,P, V, 0,2,2,-1> E0 ## E2 ## E2; }; \ + struct { _swizzle<3,T,P, V, 1,0,0,-1> E1 ## E0 ## E0; }; \ + struct { _swizzle<3,T,P, V, 1,0,1,-1> E1 ## E0 ## E1; }; \ + struct { _swizzle<3,T,P, V, 1,0,2,-1> E1 ## E0 ## E2; }; \ + struct { _swizzle<3,T,P, V, 1,1,0,-1> E1 ## E1 ## E0; }; \ + struct { _swizzle<3,T,P, V, 1,1,1,-1> E1 ## E1 ## E1; }; \ + struct { _swizzle<3,T,P, V, 1,1,2,-1> E1 ## E1 ## E2; }; \ + struct { _swizzle<3,T,P, V, 1,2,0,-1> E1 ## E2 ## E0; }; \ + struct { _swizzle<3,T,P, V, 1,2,1,-1> E1 ## E2 ## E1; }; \ + struct { _swizzle<3,T,P, V, 1,2,2,-1> E1 ## E2 ## E2; }; \ + struct { _swizzle<3,T,P, V, 2,0,0,-1> E2 ## E0 ## E0; }; \ + struct { _swizzle<3,T,P, V, 2,0,1,-1> E2 ## E0 ## E1; }; \ + struct { _swizzle<3,T,P, V, 2,0,2,-1> E2 ## E0 ## E2; }; \ + struct { _swizzle<3,T,P, V, 2,1,0,-1> E2 ## E1 ## E0; }; \ + struct { _swizzle<3,T,P, V, 2,1,1,-1> E2 ## E1 ## E1; }; \ + struct { _swizzle<3,T,P, V, 2,1,2,-1> E2 ## E1 ## E2; }; \ + struct { _swizzle<3,T,P, V, 2,2,0,-1> E2 ## E2 ## E0; }; \ + struct { _swizzle<3,T,P, V, 2,2,1,-1> E2 ## E2 ## E1; }; \ + struct { _swizzle<3,T,P, V, 2,2,2,-1> E2 ## E2 ## E2; }; + +#define _GLM_SWIZZLE3_4_MEMBERS(T, P, V, E0,E1,E2) \ + struct { _swizzle<4,T, P, V, 0,0,0,0> E0 ## E0 ## E0 ## E0; }; \ + struct { _swizzle<4,T, P, V, 0,0,0,1> E0 ## E0 ## E0 ## E1; }; \ + struct { _swizzle<4,T, P, V, 0,0,0,2> E0 ## E0 ## E0 ## E2; }; \ + struct { _swizzle<4,T, P, V, 0,0,1,0> E0 ## E0 ## E1 ## E0; }; \ + struct { _swizzle<4,T, P, V, 0,0,1,1> E0 ## E0 ## E1 ## E1; }; \ + struct { _swizzle<4,T, P, V, 0,0,1,2> E0 ## E0 ## E1 ## E2; }; \ + struct { _swizzle<4,T, P, V, 0,0,2,0> E0 ## E0 ## E2 ## E0; }; \ + struct { _swizzle<4,T, P, V, 0,0,2,1> E0 ## E0 ## E2 ## E1; }; \ + struct { _swizzle<4,T, P, V, 0,0,2,2> E0 ## E0 ## E2 ## E2; }; \ + struct { _swizzle<4,T, P, V, 0,1,0,0> E0 ## E1 ## E0 ## E0; }; \ + struct { _swizzle<4,T, P, V, 0,1,0,1> E0 ## E1 ## E0 ## E1; }; \ + struct { _swizzle<4,T, P, V, 0,1,0,2> E0 ## E1 ## E0 ## E2; }; \ + struct { _swizzle<4,T, P, V, 0,1,1,0> E0 ## E1 ## E1 ## E0; }; \ + struct { _swizzle<4,T, P, V, 0,1,1,1> E0 ## E1 ## E1 ## E1; }; \ + struct { _swizzle<4,T, P, V, 0,1,1,2> E0 ## E1 ## E1 ## E2; }; \ + struct { _swizzle<4,T, P, V, 0,1,2,0> E0 ## E1 ## E2 ## E0; }; \ + struct { _swizzle<4,T, P, V, 0,1,2,1> E0 ## E1 ## E2 ## E1; }; \ + struct { _swizzle<4,T, P, V, 0,1,2,2> E0 ## E1 ## E2 ## E2; }; \ + struct { _swizzle<4,T, P, V, 0,2,0,0> E0 ## E2 ## E0 ## E0; }; \ + struct { _swizzle<4,T, P, V, 0,2,0,1> E0 ## E2 ## E0 ## E1; }; \ + struct { _swizzle<4,T, P, V, 0,2,0,2> E0 ## E2 ## E0 ## E2; }; \ + struct { _swizzle<4,T, P, V, 0,2,1,0> E0 ## E2 ## E1 ## E0; }; \ + struct { _swizzle<4,T, P, V, 0,2,1,1> E0 ## E2 ## E1 ## E1; }; \ + struct { _swizzle<4,T, P, V, 0,2,1,2> E0 ## E2 ## E1 ## E2; }; \ + struct { _swizzle<4,T, P, V, 0,2,2,0> E0 ## E2 ## E2 ## E0; }; \ + struct { _swizzle<4,T, P, V, 0,2,2,1> E0 ## E2 ## E2 ## E1; }; \ + struct { _swizzle<4,T, P, V, 0,2,2,2> E0 ## E2 ## E2 ## E2; }; \ + struct { _swizzle<4,T, P, V, 1,0,0,0> E1 ## E0 ## E0 ## E0; }; \ + struct { _swizzle<4,T, P, V, 1,0,0,1> E1 ## E0 ## E0 ## E1; }; \ + struct { _swizzle<4,T, P, V, 1,0,0,2> E1 ## E0 ## E0 ## E2; }; \ + struct { _swizzle<4,T, P, V, 1,0,1,0> E1 ## E0 ## E1 ## E0; }; \ + struct { _swizzle<4,T, P, V, 1,0,1,1> E1 ## E0 ## E1 ## E1; }; \ + struct { _swizzle<4,T, P, V, 1,0,1,2> E1 ## E0 ## E1 ## E2; }; \ + struct { _swizzle<4,T, P, V, 1,0,2,0> E1 ## E0 ## E2 ## E0; }; \ + struct { _swizzle<4,T, P, V, 1,0,2,1> E1 ## E0 ## E2 ## E1; }; \ + struct { _swizzle<4,T, P, V, 1,0,2,2> E1 ## E0 ## E2 ## E2; }; \ + struct { _swizzle<4,T, P, V, 1,1,0,0> E1 ## E1 ## E0 ## E0; }; \ + struct { _swizzle<4,T, P, V, 1,1,0,1> E1 ## E1 ## E0 ## E1; }; \ + struct { _swizzle<4,T, P, V, 1,1,0,2> E1 ## E1 ## E0 ## E2; }; \ + struct { _swizzle<4,T, P, V, 1,1,1,0> E1 ## E1 ## E1 ## E0; }; \ + struct { _swizzle<4,T, P, V, 1,1,1,1> E1 ## E1 ## E1 ## E1; }; \ + struct { _swizzle<4,T, P, V, 1,1,1,2> E1 ## E1 ## E1 ## E2; }; \ + struct { _swizzle<4,T, P, V, 1,1,2,0> E1 ## E1 ## E2 ## E0; }; \ + struct { _swizzle<4,T, P, V, 1,1,2,1> E1 ## E1 ## E2 ## E1; }; \ + struct { _swizzle<4,T, P, V, 1,1,2,2> E1 ## E1 ## E2 ## E2; }; \ + struct { _swizzle<4,T, P, V, 1,2,0,0> E1 ## E2 ## E0 ## E0; }; \ + struct { _swizzle<4,T, P, V, 1,2,0,1> E1 ## E2 ## E0 ## E1; }; \ + struct { _swizzle<4,T, P, V, 1,2,0,2> E1 ## E2 ## E0 ## E2; }; \ + struct { _swizzle<4,T, P, V, 1,2,1,0> E1 ## E2 ## E1 ## E0; }; \ + struct { _swizzle<4,T, P, V, 1,2,1,1> E1 ## E2 ## E1 ## E1; }; \ + struct { _swizzle<4,T, P, V, 1,2,1,2> E1 ## E2 ## E1 ## E2; }; \ + struct { _swizzle<4,T, P, V, 1,2,2,0> E1 ## E2 ## E2 ## E0; }; \ + struct { _swizzle<4,T, P, V, 1,2,2,1> E1 ## E2 ## E2 ## E1; }; \ + struct { _swizzle<4,T, P, V, 1,2,2,2> E1 ## E2 ## E2 ## E2; }; \ + struct { _swizzle<4,T, P, V, 2,0,0,0> E2 ## E0 ## E0 ## E0; }; \ + struct { _swizzle<4,T, P, V, 2,0,0,1> E2 ## E0 ## E0 ## E1; }; \ + struct { _swizzle<4,T, P, V, 2,0,0,2> E2 ## E0 ## E0 ## E2; }; \ + struct { _swizzle<4,T, P, V, 2,0,1,0> E2 ## E0 ## E1 ## E0; }; \ + struct { _swizzle<4,T, P, V, 2,0,1,1> E2 ## E0 ## E1 ## E1; }; \ + struct { _swizzle<4,T, P, V, 2,0,1,2> E2 ## E0 ## E1 ## E2; }; \ + struct { _swizzle<4,T, P, V, 2,0,2,0> E2 ## E0 ## E2 ## E0; }; \ + struct { _swizzle<4,T, P, V, 2,0,2,1> E2 ## E0 ## E2 ## E1; }; \ + struct { _swizzle<4,T, P, V, 2,0,2,2> E2 ## E0 ## E2 ## E2; }; \ + struct { _swizzle<4,T, P, V, 2,1,0,0> E2 ## E1 ## E0 ## E0; }; \ + struct { _swizzle<4,T, P, V, 2,1,0,1> E2 ## E1 ## E0 ## E1; }; \ + struct { _swizzle<4,T, P, V, 2,1,0,2> E2 ## E1 ## E0 ## E2; }; \ + struct { _swizzle<4,T, P, V, 2,1,1,0> E2 ## E1 ## E1 ## E0; }; \ + struct { _swizzle<4,T, P, V, 2,1,1,1> E2 ## E1 ## E1 ## E1; }; \ + struct { _swizzle<4,T, P, V, 2,1,1,2> E2 ## E1 ## E1 ## E2; }; \ + struct { _swizzle<4,T, P, V, 2,1,2,0> E2 ## E1 ## E2 ## E0; }; \ + struct { _swizzle<4,T, P, V, 2,1,2,1> E2 ## E1 ## E2 ## E1; }; \ + struct { _swizzle<4,T, P, V, 2,1,2,2> E2 ## E1 ## E2 ## E2; }; \ + struct { _swizzle<4,T, P, V, 2,2,0,0> E2 ## E2 ## E0 ## E0; }; \ + struct { _swizzle<4,T, P, V, 2,2,0,1> E2 ## E2 ## E0 ## E1; }; \ + struct { _swizzle<4,T, P, V, 2,2,0,2> E2 ## E2 ## E0 ## E2; }; \ + struct { _swizzle<4,T, P, V, 2,2,1,0> E2 ## E2 ## E1 ## E0; }; \ + struct { _swizzle<4,T, P, V, 2,2,1,1> E2 ## E2 ## E1 ## E1; }; \ + struct { _swizzle<4,T, P, V, 2,2,1,2> E2 ## E2 ## E1 ## E2; }; \ + struct { _swizzle<4,T, P, V, 2,2,2,0> E2 ## E2 ## E2 ## E0; }; \ + struct { _swizzle<4,T, P, V, 2,2,2,1> E2 ## E2 ## E2 ## E1; }; \ + struct { _swizzle<4,T, P, V, 2,2,2,2> E2 ## E2 ## E2 ## E2; }; + +#define _GLM_SWIZZLE4_2_MEMBERS(T, P, V, E0,E1,E2,E3) \ + struct { _swizzle<2,T, P, V, 0,0,-1,-2> E0 ## E0; }; \ + struct { _swizzle<2,T, P, V, 0,1,-1,-2> E0 ## E1; }; \ + struct { _swizzle<2,T, P, V, 0,2,-1,-2> E0 ## E2; }; \ + struct { _swizzle<2,T, P, V, 0,3,-1,-2> E0 ## E3; }; \ + struct { _swizzle<2,T, P, V, 1,0,-1,-2> E1 ## E0; }; \ + struct { _swizzle<2,T, P, V, 1,1,-1,-2> E1 ## E1; }; \ + struct { _swizzle<2,T, P, V, 1,2,-1,-2> E1 ## E2; }; \ + struct { _swizzle<2,T, P, V, 1,3,-1,-2> E1 ## E3; }; \ + struct { _swizzle<2,T, P, V, 2,0,-1,-2> E2 ## E0; }; \ + struct { _swizzle<2,T, P, V, 2,1,-1,-2> E2 ## E1; }; \ + struct { _swizzle<2,T, P, V, 2,2,-1,-2> E2 ## E2; }; \ + struct { _swizzle<2,T, P, V, 2,3,-1,-2> E2 ## E3; }; \ + struct { _swizzle<2,T, P, V, 3,0,-1,-2> E3 ## E0; }; \ + struct { _swizzle<2,T, P, V, 3,1,-1,-2> E3 ## E1; }; \ + struct { _swizzle<2,T, P, V, 3,2,-1,-2> E3 ## E2; }; \ + struct { _swizzle<2,T, P, V, 3,3,-1,-2> E3 ## E3; }; + +#define _GLM_SWIZZLE4_3_MEMBERS(T,P, V, E0,E1,E2,E3) \ + struct { _swizzle<3,T,P, V, 0,0,0,-1> E0 ## E0 ## E0; }; \ + struct { _swizzle<3,T,P, V, 0,0,1,-1> E0 ## E0 ## E1; }; \ + struct { _swizzle<3,T,P, V, 0,0,2,-1> E0 ## E0 ## E2; }; \ + struct { _swizzle<3,T,P, V, 0,0,3,-1> E0 ## E0 ## E3; }; \ + struct { _swizzle<3,T,P, V, 0,1,0,-1> E0 ## E1 ## E0; }; \ + struct { _swizzle<3,T,P, V, 0,1,1,-1> E0 ## E1 ## E1; }; \ + struct { _swizzle<3,T,P, V, 0,1,2,-1> E0 ## E1 ## E2; }; \ + struct { _swizzle<3,T,P, V, 0,1,3,-1> E0 ## E1 ## E3; }; \ + struct { _swizzle<3,T,P, V, 0,2,0,-1> E0 ## E2 ## E0; }; \ + struct { _swizzle<3,T,P, V, 0,2,1,-1> E0 ## E2 ## E1; }; \ + struct { _swizzle<3,T,P, V, 0,2,2,-1> E0 ## E2 ## E2; }; \ + struct { _swizzle<3,T,P, V, 0,2,3,-1> E0 ## E2 ## E3; }; \ + struct { _swizzle<3,T,P, V, 0,3,0,-1> E0 ## E3 ## E0; }; \ + struct { _swizzle<3,T,P, V, 0,3,1,-1> E0 ## E3 ## E1; }; \ + struct { _swizzle<3,T,P, V, 0,3,2,-1> E0 ## E3 ## E2; }; \ + struct { _swizzle<3,T,P, V, 0,3,3,-1> E0 ## E3 ## E3; }; \ + struct { _swizzle<3,T,P, V, 1,0,0,-1> E1 ## E0 ## E0; }; \ + struct { _swizzle<3,T,P, V, 1,0,1,-1> E1 ## E0 ## E1; }; \ + struct { _swizzle<3,T,P, V, 1,0,2,-1> E1 ## E0 ## E2; }; \ + struct { _swizzle<3,T,P, V, 1,0,3,-1> E1 ## E0 ## E3; }; \ + struct { _swizzle<3,T,P, V, 1,1,0,-1> E1 ## E1 ## E0; }; \ + struct { _swizzle<3,T,P, V, 1,1,1,-1> E1 ## E1 ## E1; }; \ + struct { _swizzle<3,T,P, V, 1,1,2,-1> E1 ## E1 ## E2; }; \ + struct { _swizzle<3,T,P, V, 1,1,3,-1> E1 ## E1 ## E3; }; \ + struct { _swizzle<3,T,P, V, 1,2,0,-1> E1 ## E2 ## E0; }; \ + struct { _swizzle<3,T,P, V, 1,2,1,-1> E1 ## E2 ## E1; }; \ + struct { _swizzle<3,T,P, V, 1,2,2,-1> E1 ## E2 ## E2; }; \ + struct { _swizzle<3,T,P, V, 1,2,3,-1> E1 ## E2 ## E3; }; \ + struct { _swizzle<3,T,P, V, 1,3,0,-1> E1 ## E3 ## E0; }; \ + struct { _swizzle<3,T,P, V, 1,3,1,-1> E1 ## E3 ## E1; }; \ + struct { _swizzle<3,T,P, V, 1,3,2,-1> E1 ## E3 ## E2; }; \ + struct { _swizzle<3,T,P, V, 1,3,3,-1> E1 ## E3 ## E3; }; \ + struct { _swizzle<3,T,P, V, 2,0,0,-1> E2 ## E0 ## E0; }; \ + struct { _swizzle<3,T,P, V, 2,0,1,-1> E2 ## E0 ## E1; }; \ + struct { _swizzle<3,T,P, V, 2,0,2,-1> E2 ## E0 ## E2; }; \ + struct { _swizzle<3,T,P, V, 2,0,3,-1> E2 ## E0 ## E3; }; \ + struct { _swizzle<3,T,P, V, 2,1,0,-1> E2 ## E1 ## E0; }; \ + struct { _swizzle<3,T,P, V, 2,1,1,-1> E2 ## E1 ## E1; }; \ + struct { _swizzle<3,T,P, V, 2,1,2,-1> E2 ## E1 ## E2; }; \ + struct { _swizzle<3,T,P, V, 2,1,3,-1> E2 ## E1 ## E3; }; \ + struct { _swizzle<3,T,P, V, 2,2,0,-1> E2 ## E2 ## E0; }; \ + struct { _swizzle<3,T,P, V, 2,2,1,-1> E2 ## E2 ## E1; }; \ + struct { _swizzle<3,T,P, V, 2,2,2,-1> E2 ## E2 ## E2; }; \ + struct { _swizzle<3,T,P, V, 2,2,3,-1> E2 ## E2 ## E3; }; \ + struct { _swizzle<3,T,P, V, 2,3,0,-1> E2 ## E3 ## E0; }; \ + struct { _swizzle<3,T,P, V, 2,3,1,-1> E2 ## E3 ## E1; }; \ + struct { _swizzle<3,T,P, V, 2,3,2,-1> E2 ## E3 ## E2; }; \ + struct { _swizzle<3,T,P, V, 2,3,3,-1> E2 ## E3 ## E3; }; \ + struct { _swizzle<3,T,P, V, 3,0,0,-1> E3 ## E0 ## E0; }; \ + struct { _swizzle<3,T,P, V, 3,0,1,-1> E3 ## E0 ## E1; }; \ + struct { _swizzle<3,T,P, V, 3,0,2,-1> E3 ## E0 ## E2; }; \ + struct { _swizzle<3,T,P, V, 3,0,3,-1> E3 ## E0 ## E3; }; \ + struct { _swizzle<3,T,P, V, 3,1,0,-1> E3 ## E1 ## E0; }; \ + struct { _swizzle<3,T,P, V, 3,1,1,-1> E3 ## E1 ## E1; }; \ + struct { _swizzle<3,T,P, V, 3,1,2,-1> E3 ## E1 ## E2; }; \ + struct { _swizzle<3,T,P, V, 3,1,3,-1> E3 ## E1 ## E3; }; \ + struct { _swizzle<3,T,P, V, 3,2,0,-1> E3 ## E2 ## E0; }; \ + struct { _swizzle<3,T,P, V, 3,2,1,-1> E3 ## E2 ## E1; }; \ + struct { _swizzle<3,T,P, V, 3,2,2,-1> E3 ## E2 ## E2; }; \ + struct { _swizzle<3,T,P, V, 3,2,3,-1> E3 ## E2 ## E3; }; \ + struct { _swizzle<3,T,P, V, 3,3,0,-1> E3 ## E3 ## E0; }; \ + struct { _swizzle<3,T,P, V, 3,3,1,-1> E3 ## E3 ## E1; }; \ + struct { _swizzle<3,T,P, V, 3,3,2,-1> E3 ## E3 ## E2; }; \ + struct { _swizzle<3,T,P, V, 3,3,3,-1> E3 ## E3 ## E3; }; + +#define _GLM_SWIZZLE4_4_MEMBERS(T, P, V, E0,E1,E2,E3) \ + struct { _swizzle<4, T, P, V, 0,0,0,0> E0 ## E0 ## E0 ## E0; }; \ + struct { _swizzle<4, T, P, V, 0,0,0,1> E0 ## E0 ## E0 ## E1; }; \ + struct { _swizzle<4, T, P, V, 0,0,0,2> E0 ## E0 ## E0 ## E2; }; \ + struct { _swizzle<4, T, P, V, 0,0,0,3> E0 ## E0 ## E0 ## E3; }; \ + struct { _swizzle<4, T, P, V, 0,0,1,0> E0 ## E0 ## E1 ## E0; }; \ + struct { _swizzle<4, T, P, V, 0,0,1,1> E0 ## E0 ## E1 ## E1; }; \ + struct { _swizzle<4, T, P, V, 0,0,1,2> E0 ## E0 ## E1 ## E2; }; \ + struct { _swizzle<4, T, P, V, 0,0,1,3> E0 ## E0 ## E1 ## E3; }; \ + struct { _swizzle<4, T, P, V, 0,0,2,0> E0 ## E0 ## E2 ## E0; }; \ + struct { _swizzle<4, T, P, V, 0,0,2,1> E0 ## E0 ## E2 ## E1; }; \ + struct { _swizzle<4, T, P, V, 0,0,2,2> E0 ## E0 ## E2 ## E2; }; \ + struct { _swizzle<4, T, P, V, 0,0,2,3> E0 ## E0 ## E2 ## E3; }; \ + struct { _swizzle<4, T, P, V, 0,0,3,0> E0 ## E0 ## E3 ## E0; }; \ + struct { _swizzle<4, T, P, V, 0,0,3,1> E0 ## E0 ## E3 ## E1; }; \ + struct { _swizzle<4, T, P, V, 0,0,3,2> E0 ## E0 ## E3 ## E2; }; \ + struct { _swizzle<4, T, P, V, 0,0,3,3> E0 ## E0 ## E3 ## E3; }; \ + struct { _swizzle<4, T, P, V, 0,1,0,0> E0 ## E1 ## E0 ## E0; }; \ + struct { _swizzle<4, T, P, V, 0,1,0,1> E0 ## E1 ## E0 ## E1; }; \ + struct { _swizzle<4, T, P, V, 0,1,0,2> E0 ## E1 ## E0 ## E2; }; \ + struct { _swizzle<4, T, P, V, 0,1,0,3> E0 ## E1 ## E0 ## E3; }; \ + struct { _swizzle<4, T, P, V, 0,1,1,0> E0 ## E1 ## E1 ## E0; }; \ + struct { _swizzle<4, T, P, V, 0,1,1,1> E0 ## E1 ## E1 ## E1; }; \ + struct { _swizzle<4, T, P, V, 0,1,1,2> E0 ## E1 ## E1 ## E2; }; \ + struct { _swizzle<4, T, P, V, 0,1,1,3> E0 ## E1 ## E1 ## E3; }; \ + struct { _swizzle<4, T, P, V, 0,1,2,0> E0 ## E1 ## E2 ## E0; }; \ + struct { _swizzle<4, T, P, V, 0,1,2,1> E0 ## E1 ## E2 ## E1; }; \ + struct { _swizzle<4, T, P, V, 0,1,2,2> E0 ## E1 ## E2 ## E2; }; \ + struct { _swizzle<4, T, P, V, 0,1,2,3> E0 ## E1 ## E2 ## E3; }; \ + struct { _swizzle<4, T, P, V, 0,1,3,0> E0 ## E1 ## E3 ## E0; }; \ + struct { _swizzle<4, T, P, V, 0,1,3,1> E0 ## E1 ## E3 ## E1; }; \ + struct { _swizzle<4, T, P, V, 0,1,3,2> E0 ## E1 ## E3 ## E2; }; \ + struct { _swizzle<4, T, P, V, 0,1,3,3> E0 ## E1 ## E3 ## E3; }; \ + struct { _swizzle<4, T, P, V, 0,2,0,0> E0 ## E2 ## E0 ## E0; }; \ + struct { _swizzle<4, T, P, V, 0,2,0,1> E0 ## E2 ## E0 ## E1; }; \ + struct { _swizzle<4, T, P, V, 0,2,0,2> E0 ## E2 ## E0 ## E2; }; \ + struct { _swizzle<4, T, P, V, 0,2,0,3> E0 ## E2 ## E0 ## E3; }; \ + struct { _swizzle<4, T, P, V, 0,2,1,0> E0 ## E2 ## E1 ## E0; }; \ + struct { _swizzle<4, T, P, V, 0,2,1,1> E0 ## E2 ## E1 ## E1; }; \ + struct { _swizzle<4, T, P, V, 0,2,1,2> E0 ## E2 ## E1 ## E2; }; \ + struct { _swizzle<4, T, P, V, 0,2,1,3> E0 ## E2 ## E1 ## E3; }; \ + struct { _swizzle<4, T, P, V, 0,2,2,0> E0 ## E2 ## E2 ## E0; }; \ + struct { _swizzle<4, T, P, V, 0,2,2,1> E0 ## E2 ## E2 ## E1; }; \ + struct { _swizzle<4, T, P, V, 0,2,2,2> E0 ## E2 ## E2 ## E2; }; \ + struct { _swizzle<4, T, P, V, 0,2,2,3> E0 ## E2 ## E2 ## E3; }; \ + struct { _swizzle<4, T, P, V, 0,2,3,0> E0 ## E2 ## E3 ## E0; }; \ + struct { _swizzle<4, T, P, V, 0,2,3,1> E0 ## E2 ## E3 ## E1; }; \ + struct { _swizzle<4, T, P, V, 0,2,3,2> E0 ## E2 ## E3 ## E2; }; \ + struct { _swizzle<4, T, P, V, 0,2,3,3> E0 ## E2 ## E3 ## E3; }; \ + struct { _swizzle<4, T, P, V, 0,3,0,0> E0 ## E3 ## E0 ## E0; }; \ + struct { _swizzle<4, T, P, V, 0,3,0,1> E0 ## E3 ## E0 ## E1; }; \ + struct { _swizzle<4, T, P, V, 0,3,0,2> E0 ## E3 ## E0 ## E2; }; \ + struct { _swizzle<4, T, P, V, 0,3,0,3> E0 ## E3 ## E0 ## E3; }; \ + struct { _swizzle<4, T, P, V, 0,3,1,0> E0 ## E3 ## E1 ## E0; }; \ + struct { _swizzle<4, T, P, V, 0,3,1,1> E0 ## E3 ## E1 ## E1; }; \ + struct { _swizzle<4, T, P, V, 0,3,1,2> E0 ## E3 ## E1 ## E2; }; \ + struct { _swizzle<4, T, P, V, 0,3,1,3> E0 ## E3 ## E1 ## E3; }; \ + struct { _swizzle<4, T, P, V, 0,3,2,0> E0 ## E3 ## E2 ## E0; }; \ + struct { _swizzle<4, T, P, V, 0,3,2,1> E0 ## E3 ## E2 ## E1; }; \ + struct { _swizzle<4, T, P, V, 0,3,2,2> E0 ## E3 ## E2 ## E2; }; \ + struct { _swizzle<4, T, P, V, 0,3,2,3> E0 ## E3 ## E2 ## E3; }; \ + struct { _swizzle<4, T, P, V, 0,3,3,0> E0 ## E3 ## E3 ## E0; }; \ + struct { _swizzle<4, T, P, V, 0,3,3,1> E0 ## E3 ## E3 ## E1; }; \ + struct { _swizzle<4, T, P, V, 0,3,3,2> E0 ## E3 ## E3 ## E2; }; \ + struct { _swizzle<4, T, P, V, 0,3,3,3> E0 ## E3 ## E3 ## E3; }; \ + struct { _swizzle<4, T, P, V, 1,0,0,0> E1 ## E0 ## E0 ## E0; }; \ + struct { _swizzle<4, T, P, V, 1,0,0,1> E1 ## E0 ## E0 ## E1; }; \ + struct { _swizzle<4, T, P, V, 1,0,0,2> E1 ## E0 ## E0 ## E2; }; \ + struct { _swizzle<4, T, P, V, 1,0,0,3> E1 ## E0 ## E0 ## E3; }; \ + struct { _swizzle<4, T, P, V, 1,0,1,0> E1 ## E0 ## E1 ## E0; }; \ + struct { _swizzle<4, T, P, V, 1,0,1,1> E1 ## E0 ## E1 ## E1; }; \ + struct { _swizzle<4, T, P, V, 1,0,1,2> E1 ## E0 ## E1 ## E2; }; \ + struct { _swizzle<4, T, P, V, 1,0,1,3> E1 ## E0 ## E1 ## E3; }; \ + struct { _swizzle<4, T, P, V, 1,0,2,0> E1 ## E0 ## E2 ## E0; }; \ + struct { _swizzle<4, T, P, V, 1,0,2,1> E1 ## E0 ## E2 ## E1; }; \ + struct { _swizzle<4, T, P, V, 1,0,2,2> E1 ## E0 ## E2 ## E2; }; \ + struct { _swizzle<4, T, P, V, 1,0,2,3> E1 ## E0 ## E2 ## E3; }; \ + struct { _swizzle<4, T, P, V, 1,0,3,0> E1 ## E0 ## E3 ## E0; }; \ + struct { _swizzle<4, T, P, V, 1,0,3,1> E1 ## E0 ## E3 ## E1; }; \ + struct { _swizzle<4, T, P, V, 1,0,3,2> E1 ## E0 ## E3 ## E2; }; \ + struct { _swizzle<4, T, P, V, 1,0,3,3> E1 ## E0 ## E3 ## E3; }; \ + struct { _swizzle<4, T, P, V, 1,1,0,0> E1 ## E1 ## E0 ## E0; }; \ + struct { _swizzle<4, T, P, V, 1,1,0,1> E1 ## E1 ## E0 ## E1; }; \ + struct { _swizzle<4, T, P, V, 1,1,0,2> E1 ## E1 ## E0 ## E2; }; \ + struct { _swizzle<4, T, P, V, 1,1,0,3> E1 ## E1 ## E0 ## E3; }; \ + struct { _swizzle<4, T, P, V, 1,1,1,0> E1 ## E1 ## E1 ## E0; }; \ + struct { _swizzle<4, T, P, V, 1,1,1,1> E1 ## E1 ## E1 ## E1; }; \ + struct { _swizzle<4, T, P, V, 1,1,1,2> E1 ## E1 ## E1 ## E2; }; \ + struct { _swizzle<4, T, P, V, 1,1,1,3> E1 ## E1 ## E1 ## E3; }; \ + struct { _swizzle<4, T, P, V, 1,1,2,0> E1 ## E1 ## E2 ## E0; }; \ + struct { _swizzle<4, T, P, V, 1,1,2,1> E1 ## E1 ## E2 ## E1; }; \ + struct { _swizzle<4, T, P, V, 1,1,2,2> E1 ## E1 ## E2 ## E2; }; \ + struct { _swizzle<4, T, P, V, 1,1,2,3> E1 ## E1 ## E2 ## E3; }; \ + struct { _swizzle<4, T, P, V, 1,1,3,0> E1 ## E1 ## E3 ## E0; }; \ + struct { _swizzle<4, T, P, V, 1,1,3,1> E1 ## E1 ## E3 ## E1; }; \ + struct { _swizzle<4, T, P, V, 1,1,3,2> E1 ## E1 ## E3 ## E2; }; \ + struct { _swizzle<4, T, P, V, 1,1,3,3> E1 ## E1 ## E3 ## E3; }; \ + struct { _swizzle<4, T, P, V, 1,2,0,0> E1 ## E2 ## E0 ## E0; }; \ + struct { _swizzle<4, T, P, V, 1,2,0,1> E1 ## E2 ## E0 ## E1; }; \ + struct { _swizzle<4, T, P, V, 1,2,0,2> E1 ## E2 ## E0 ## E2; }; \ + struct { _swizzle<4, T, P, V, 1,2,0,3> E1 ## E2 ## E0 ## E3; }; \ + struct { _swizzle<4, T, P, V, 1,2,1,0> E1 ## E2 ## E1 ## E0; }; \ + struct { _swizzle<4, T, P, V, 1,2,1,1> E1 ## E2 ## E1 ## E1; }; \ + struct { _swizzle<4, T, P, V, 1,2,1,2> E1 ## E2 ## E1 ## E2; }; \ + struct { _swizzle<4, T, P, V, 1,2,1,3> E1 ## E2 ## E1 ## E3; }; \ + struct { _swizzle<4, T, P, V, 1,2,2,0> E1 ## E2 ## E2 ## E0; }; \ + struct { _swizzle<4, T, P, V, 1,2,2,1> E1 ## E2 ## E2 ## E1; }; \ + struct { _swizzle<4, T, P, V, 1,2,2,2> E1 ## E2 ## E2 ## E2; }; \ + struct { _swizzle<4, T, P, V, 1,2,2,3> E1 ## E2 ## E2 ## E3; }; \ + struct { _swizzle<4, T, P, V, 1,2,3,0> E1 ## E2 ## E3 ## E0; }; \ + struct { _swizzle<4, T, P, V, 1,2,3,1> E1 ## E2 ## E3 ## E1; }; \ + struct { _swizzle<4, T, P, V, 1,2,3,2> E1 ## E2 ## E3 ## E2; }; \ + struct { _swizzle<4, T, P, V, 1,2,3,3> E1 ## E2 ## E3 ## E3; }; \ + struct { _swizzle<4, T, P, V, 1,3,0,0> E1 ## E3 ## E0 ## E0; }; \ + struct { _swizzle<4, T, P, V, 1,3,0,1> E1 ## E3 ## E0 ## E1; }; \ + struct { _swizzle<4, T, P, V, 1,3,0,2> E1 ## E3 ## E0 ## E2; }; \ + struct { _swizzle<4, T, P, V, 1,3,0,3> E1 ## E3 ## E0 ## E3; }; \ + struct { _swizzle<4, T, P, V, 1,3,1,0> E1 ## E3 ## E1 ## E0; }; \ + struct { _swizzle<4, T, P, V, 1,3,1,1> E1 ## E3 ## E1 ## E1; }; \ + struct { _swizzle<4, T, P, V, 1,3,1,2> E1 ## E3 ## E1 ## E2; }; \ + struct { _swizzle<4, T, P, V, 1,3,1,3> E1 ## E3 ## E1 ## E3; }; \ + struct { _swizzle<4, T, P, V, 1,3,2,0> E1 ## E3 ## E2 ## E0; }; \ + struct { _swizzle<4, T, P, V, 1,3,2,1> E1 ## E3 ## E2 ## E1; }; \ + struct { _swizzle<4, T, P, V, 1,3,2,2> E1 ## E3 ## E2 ## E2; }; \ + struct { _swizzle<4, T, P, V, 1,3,2,3> E1 ## E3 ## E2 ## E3; }; \ + struct { _swizzle<4, T, P, V, 1,3,3,0> E1 ## E3 ## E3 ## E0; }; \ + struct { _swizzle<4, T, P, V, 1,3,3,1> E1 ## E3 ## E3 ## E1; }; \ + struct { _swizzle<4, T, P, V, 1,3,3,2> E1 ## E3 ## E3 ## E2; }; \ + struct { _swizzle<4, T, P, V, 1,3,3,3> E1 ## E3 ## E3 ## E3; }; \ + struct { _swizzle<4, T, P, V, 2,0,0,0> E2 ## E0 ## E0 ## E0; }; \ + struct { _swizzle<4, T, P, V, 2,0,0,1> E2 ## E0 ## E0 ## E1; }; \ + struct { _swizzle<4, T, P, V, 2,0,0,2> E2 ## E0 ## E0 ## E2; }; \ + struct { _swizzle<4, T, P, V, 2,0,0,3> E2 ## E0 ## E0 ## E3; }; \ + struct { _swizzle<4, T, P, V, 2,0,1,0> E2 ## E0 ## E1 ## E0; }; \ + struct { _swizzle<4, T, P, V, 2,0,1,1> E2 ## E0 ## E1 ## E1; }; \ + struct { _swizzle<4, T, P, V, 2,0,1,2> E2 ## E0 ## E1 ## E2; }; \ + struct { _swizzle<4, T, P, V, 2,0,1,3> E2 ## E0 ## E1 ## E3; }; \ + struct { _swizzle<4, T, P, V, 2,0,2,0> E2 ## E0 ## E2 ## E0; }; \ + struct { _swizzle<4, T, P, V, 2,0,2,1> E2 ## E0 ## E2 ## E1; }; \ + struct { _swizzle<4, T, P, V, 2,0,2,2> E2 ## E0 ## E2 ## E2; }; \ + struct { _swizzle<4, T, P, V, 2,0,2,3> E2 ## E0 ## E2 ## E3; }; \ + struct { _swizzle<4, T, P, V, 2,0,3,0> E2 ## E0 ## E3 ## E0; }; \ + struct { _swizzle<4, T, P, V, 2,0,3,1> E2 ## E0 ## E3 ## E1; }; \ + struct { _swizzle<4, T, P, V, 2,0,3,2> E2 ## E0 ## E3 ## E2; }; \ + struct { _swizzle<4, T, P, V, 2,0,3,3> E2 ## E0 ## E3 ## E3; }; \ + struct { _swizzle<4, T, P, V, 2,1,0,0> E2 ## E1 ## E0 ## E0; }; \ + struct { _swizzle<4, T, P, V, 2,1,0,1> E2 ## E1 ## E0 ## E1; }; \ + struct { _swizzle<4, T, P, V, 2,1,0,2> E2 ## E1 ## E0 ## E2; }; \ + struct { _swizzle<4, T, P, V, 2,1,0,3> E2 ## E1 ## E0 ## E3; }; \ + struct { _swizzle<4, T, P, V, 2,1,1,0> E2 ## E1 ## E1 ## E0; }; \ + struct { _swizzle<4, T, P, V, 2,1,1,1> E2 ## E1 ## E1 ## E1; }; \ + struct { _swizzle<4, T, P, V, 2,1,1,2> E2 ## E1 ## E1 ## E2; }; \ + struct { _swizzle<4, T, P, V, 2,1,1,3> E2 ## E1 ## E1 ## E3; }; \ + struct { _swizzle<4, T, P, V, 2,1,2,0> E2 ## E1 ## E2 ## E0; }; \ + struct { _swizzle<4, T, P, V, 2,1,2,1> E2 ## E1 ## E2 ## E1; }; \ + struct { _swizzle<4, T, P, V, 2,1,2,2> E2 ## E1 ## E2 ## E2; }; \ + struct { _swizzle<4, T, P, V, 2,1,2,3> E2 ## E1 ## E2 ## E3; }; \ + struct { _swizzle<4, T, P, V, 2,1,3,0> E2 ## E1 ## E3 ## E0; }; \ + struct { _swizzle<4, T, P, V, 2,1,3,1> E2 ## E1 ## E3 ## E1; }; \ + struct { _swizzle<4, T, P, V, 2,1,3,2> E2 ## E1 ## E3 ## E2; }; \ + struct { _swizzle<4, T, P, V, 2,1,3,3> E2 ## E1 ## E3 ## E3; }; \ + struct { _swizzle<4, T, P, V, 2,2,0,0> E2 ## E2 ## E0 ## E0; }; \ + struct { _swizzle<4, T, P, V, 2,2,0,1> E2 ## E2 ## E0 ## E1; }; \ + struct { _swizzle<4, T, P, V, 2,2,0,2> E2 ## E2 ## E0 ## E2; }; \ + struct { _swizzle<4, T, P, V, 2,2,0,3> E2 ## E2 ## E0 ## E3; }; \ + struct { _swizzle<4, T, P, V, 2,2,1,0> E2 ## E2 ## E1 ## E0; }; \ + struct { _swizzle<4, T, P, V, 2,2,1,1> E2 ## E2 ## E1 ## E1; }; \ + struct { _swizzle<4, T, P, V, 2,2,1,2> E2 ## E2 ## E1 ## E2; }; \ + struct { _swizzle<4, T, P, V, 2,2,1,3> E2 ## E2 ## E1 ## E3; }; \ + struct { _swizzle<4, T, P, V, 2,2,2,0> E2 ## E2 ## E2 ## E0; }; \ + struct { _swizzle<4, T, P, V, 2,2,2,1> E2 ## E2 ## E2 ## E1; }; \ + struct { _swizzle<4, T, P, V, 2,2,2,2> E2 ## E2 ## E2 ## E2; }; \ + struct { _swizzle<4, T, P, V, 2,2,2,3> E2 ## E2 ## E2 ## E3; }; \ + struct { _swizzle<4, T, P, V, 2,2,3,0> E2 ## E2 ## E3 ## E0; }; \ + struct { _swizzle<4, T, P, V, 2,2,3,1> E2 ## E2 ## E3 ## E1; }; \ + struct { _swizzle<4, T, P, V, 2,2,3,2> E2 ## E2 ## E3 ## E2; }; \ + struct { _swizzle<4, T, P, V, 2,2,3,3> E2 ## E2 ## E3 ## E3; }; \ + struct { _swizzle<4, T, P, V, 2,3,0,0> E2 ## E3 ## E0 ## E0; }; \ + struct { _swizzle<4, T, P, V, 2,3,0,1> E2 ## E3 ## E0 ## E1; }; \ + struct { _swizzle<4, T, P, V, 2,3,0,2> E2 ## E3 ## E0 ## E2; }; \ + struct { _swizzle<4, T, P, V, 2,3,0,3> E2 ## E3 ## E0 ## E3; }; \ + struct { _swizzle<4, T, P, V, 2,3,1,0> E2 ## E3 ## E1 ## E0; }; \ + struct { _swizzle<4, T, P, V, 2,3,1,1> E2 ## E3 ## E1 ## E1; }; \ + struct { _swizzle<4, T, P, V, 2,3,1,2> E2 ## E3 ## E1 ## E2; }; \ + struct { _swizzle<4, T, P, V, 2,3,1,3> E2 ## E3 ## E1 ## E3; }; \ + struct { _swizzle<4, T, P, V, 2,3,2,0> E2 ## E3 ## E2 ## E0; }; \ + struct { _swizzle<4, T, P, V, 2,3,2,1> E2 ## E3 ## E2 ## E1; }; \ + struct { _swizzle<4, T, P, V, 2,3,2,2> E2 ## E3 ## E2 ## E2; }; \ + struct { _swizzle<4, T, P, V, 2,3,2,3> E2 ## E3 ## E2 ## E3; }; \ + struct { _swizzle<4, T, P, V, 2,3,3,0> E2 ## E3 ## E3 ## E0; }; \ + struct { _swizzle<4, T, P, V, 2,3,3,1> E2 ## E3 ## E3 ## E1; }; \ + struct { _swizzle<4, T, P, V, 2,3,3,2> E2 ## E3 ## E3 ## E2; }; \ + struct { _swizzle<4, T, P, V, 2,3,3,3> E2 ## E3 ## E3 ## E3; }; \ + struct { _swizzle<4, T, P, V, 3,0,0,0> E3 ## E0 ## E0 ## E0; }; \ + struct { _swizzle<4, T, P, V, 3,0,0,1> E3 ## E0 ## E0 ## E1; }; \ + struct { _swizzle<4, T, P, V, 3,0,0,2> E3 ## E0 ## E0 ## E2; }; \ + struct { _swizzle<4, T, P, V, 3,0,0,3> E3 ## E0 ## E0 ## E3; }; \ + struct { _swizzle<4, T, P, V, 3,0,1,0> E3 ## E0 ## E1 ## E0; }; \ + struct { _swizzle<4, T, P, V, 3,0,1,1> E3 ## E0 ## E1 ## E1; }; \ + struct { _swizzle<4, T, P, V, 3,0,1,2> E3 ## E0 ## E1 ## E2; }; \ + struct { _swizzle<4, T, P, V, 3,0,1,3> E3 ## E0 ## E1 ## E3; }; \ + struct { _swizzle<4, T, P, V, 3,0,2,0> E3 ## E0 ## E2 ## E0; }; \ + struct { _swizzle<4, T, P, V, 3,0,2,1> E3 ## E0 ## E2 ## E1; }; \ + struct { _swizzle<4, T, P, V, 3,0,2,2> E3 ## E0 ## E2 ## E2; }; \ + struct { _swizzle<4, T, P, V, 3,0,2,3> E3 ## E0 ## E2 ## E3; }; \ + struct { _swizzle<4, T, P, V, 3,0,3,0> E3 ## E0 ## E3 ## E0; }; \ + struct { _swizzle<4, T, P, V, 3,0,3,1> E3 ## E0 ## E3 ## E1; }; \ + struct { _swizzle<4, T, P, V, 3,0,3,2> E3 ## E0 ## E3 ## E2; }; \ + struct { _swizzle<4, T, P, V, 3,0,3,3> E3 ## E0 ## E3 ## E3; }; \ + struct { _swizzle<4, T, P, V, 3,1,0,0> E3 ## E1 ## E0 ## E0; }; \ + struct { _swizzle<4, T, P, V, 3,1,0,1> E3 ## E1 ## E0 ## E1; }; \ + struct { _swizzle<4, T, P, V, 3,1,0,2> E3 ## E1 ## E0 ## E2; }; \ + struct { _swizzle<4, T, P, V, 3,1,0,3> E3 ## E1 ## E0 ## E3; }; \ + struct { _swizzle<4, T, P, V, 3,1,1,0> E3 ## E1 ## E1 ## E0; }; \ + struct { _swizzle<4, T, P, V, 3,1,1,1> E3 ## E1 ## E1 ## E1; }; \ + struct { _swizzle<4, T, P, V, 3,1,1,2> E3 ## E1 ## E1 ## E2; }; \ + struct { _swizzle<4, T, P, V, 3,1,1,3> E3 ## E1 ## E1 ## E3; }; \ + struct { _swizzle<4, T, P, V, 3,1,2,0> E3 ## E1 ## E2 ## E0; }; \ + struct { _swizzle<4, T, P, V, 3,1,2,1> E3 ## E1 ## E2 ## E1; }; \ + struct { _swizzle<4, T, P, V, 3,1,2,2> E3 ## E1 ## E2 ## E2; }; \ + struct { _swizzle<4, T, P, V, 3,1,2,3> E3 ## E1 ## E2 ## E3; }; \ + struct { _swizzle<4, T, P, V, 3,1,3,0> E3 ## E1 ## E3 ## E0; }; \ + struct { _swizzle<4, T, P, V, 3,1,3,1> E3 ## E1 ## E3 ## E1; }; \ + struct { _swizzle<4, T, P, V, 3,1,3,2> E3 ## E1 ## E3 ## E2; }; \ + struct { _swizzle<4, T, P, V, 3,1,3,3> E3 ## E1 ## E3 ## E3; }; \ + struct { _swizzle<4, T, P, V, 3,2,0,0> E3 ## E2 ## E0 ## E0; }; \ + struct { _swizzle<4, T, P, V, 3,2,0,1> E3 ## E2 ## E0 ## E1; }; \ + struct { _swizzle<4, T, P, V, 3,2,0,2> E3 ## E2 ## E0 ## E2; }; \ + struct { _swizzle<4, T, P, V, 3,2,0,3> E3 ## E2 ## E0 ## E3; }; \ + struct { _swizzle<4, T, P, V, 3,2,1,0> E3 ## E2 ## E1 ## E0; }; \ + struct { _swizzle<4, T, P, V, 3,2,1,1> E3 ## E2 ## E1 ## E1; }; \ + struct { _swizzle<4, T, P, V, 3,2,1,2> E3 ## E2 ## E1 ## E2; }; \ + struct { _swizzle<4, T, P, V, 3,2,1,3> E3 ## E2 ## E1 ## E3; }; \ + struct { _swizzle<4, T, P, V, 3,2,2,0> E3 ## E2 ## E2 ## E0; }; \ + struct { _swizzle<4, T, P, V, 3,2,2,1> E3 ## E2 ## E2 ## E1; }; \ + struct { _swizzle<4, T, P, V, 3,2,2,2> E3 ## E2 ## E2 ## E2; }; \ + struct { _swizzle<4, T, P, V, 3,2,2,3> E3 ## E2 ## E2 ## E3; }; \ + struct { _swizzle<4, T, P, V, 3,2,3,0> E3 ## E2 ## E3 ## E0; }; \ + struct { _swizzle<4, T, P, V, 3,2,3,1> E3 ## E2 ## E3 ## E1; }; \ + struct { _swizzle<4, T, P, V, 3,2,3,2> E3 ## E2 ## E3 ## E2; }; \ + struct { _swizzle<4, T, P, V, 3,2,3,3> E3 ## E2 ## E3 ## E3; }; \ + struct { _swizzle<4, T, P, V, 3,3,0,0> E3 ## E3 ## E0 ## E0; }; \ + struct { _swizzle<4, T, P, V, 3,3,0,1> E3 ## E3 ## E0 ## E1; }; \ + struct { _swizzle<4, T, P, V, 3,3,0,2> E3 ## E3 ## E0 ## E2; }; \ + struct { _swizzle<4, T, P, V, 3,3,0,3> E3 ## E3 ## E0 ## E3; }; \ + struct { _swizzle<4, T, P, V, 3,3,1,0> E3 ## E3 ## E1 ## E0; }; \ + struct { _swizzle<4, T, P, V, 3,3,1,1> E3 ## E3 ## E1 ## E1; }; \ + struct { _swizzle<4, T, P, V, 3,3,1,2> E3 ## E3 ## E1 ## E2; }; \ + struct { _swizzle<4, T, P, V, 3,3,1,3> E3 ## E3 ## E1 ## E3; }; \ + struct { _swizzle<4, T, P, V, 3,3,2,0> E3 ## E3 ## E2 ## E0; }; \ + struct { _swizzle<4, T, P, V, 3,3,2,1> E3 ## E3 ## E2 ## E1; }; \ + struct { _swizzle<4, T, P, V, 3,3,2,2> E3 ## E3 ## E2 ## E2; }; \ + struct { _swizzle<4, T, P, V, 3,3,2,3> E3 ## E3 ## E2 ## E3; }; \ + struct { _swizzle<4, T, P, V, 3,3,3,0> E3 ## E3 ## E3 ## E0; }; \ + struct { _swizzle<4, T, P, V, 3,3,3,1> E3 ## E3 ## E3 ## E1; }; \ + struct { _swizzle<4, T, P, V, 3,3,3,2> E3 ## E3 ## E3 ## E2; }; \ + struct { _swizzle<4, T, P, V, 3,3,3,3> E3 ## E3 ## E3 ## E3; }; + +#endif//glm_core_swizzle diff --git a/thirdparty/glm/detail/_swizzle_func.hpp b/thirdparty/glm/detail/_swizzle_func.hpp new file mode 100644 index 000000000..c287bbf5b --- /dev/null +++ b/thirdparty/glm/detail/_swizzle_func.hpp @@ -0,0 +1,724 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/core/_swizzle_func.hpp +/// @date 2011-10-16 / 2011-10-16 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef glm_core_swizzle_func +#define glm_core_swizzle_func + +#define GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, CONST, A, B) \ + SWIZZLED_TYPE A ## B() CONST \ + { \ + return SWIZZLED_TYPE(this->A, this->B); \ + } + +#define GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, CONST, A, B, C) \ + SWIZZLED_TYPE A ## B ## C() CONST \ + { \ + return SWIZZLED_TYPE(this->A, this->B, this->C); \ + } + +#define GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, CONST, A, B, C, D) \ + SWIZZLED_TYPE A ## B ## C ## D() CONST \ + { \ + return SWIZZLED_TYPE(this->A, this->B, this->C, this->D); \ + } + +#define GLM_SWIZZLE_GEN_VEC2_ENTRY_DEF(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, CONST, A, B) \ + template \ + SWIZZLED_TYPE CLASS_TYPE::A ## B() CONST \ + { \ + return SWIZZLED_TYPE(this->A, this->B); \ + } + +#define GLM_SWIZZLE_GEN_VEC3_ENTRY_DEF(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, CONST, A, B, C) \ + template \ + SWIZZLED_TYPE CLASS_TYPE::A ## B ## C() CONST \ + { \ + return SWIZZLED_TYPE(this->A, this->B, this->C); \ + } + +#define GLM_SWIZZLE_GEN_VEC4_ENTRY_DEF(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, CONST, A, B, C, D) \ + template \ + SWIZZLED_TYPE CLASS_TYPE::A ## B ## C ## D() CONST \ + { \ + return SWIZZLED_TYPE(this->A, this->B, this->C, this->D); \ + } + +#define GLM_MUTABLE + +#define GLM_SWIZZLE_GEN_REF2_FROM_VEC2_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, A, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, B, A) + +#define GLM_SWIZZLE_GEN_REF_FROM_VEC2(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE) \ + GLM_SWIZZLE_GEN_REF2_FROM_VEC2_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, x, y) \ + GLM_SWIZZLE_GEN_REF2_FROM_VEC2_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, r, g) \ + GLM_SWIZZLE_GEN_REF2_FROM_VEC2_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, s, t) + +//GLM_SWIZZLE_GEN_REF_FROM_VEC2(valType, detail::vec2, detail::ref2) + +#define GLM_SWIZZLE_GEN_REF2_FROM_VEC3_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, A, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, A, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, B, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, B, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, C, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, C, B) + +#define GLM_SWIZZLE_GEN_REF3_FROM_VEC3_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, A, B, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, A, C, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, B, A, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, B, C, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, C, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, C, B, A) + +#define GLM_SWIZZLE_GEN_REF_FROM_VEC3_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, A, B, C) \ + GLM_SWIZZLE_GEN_REF3_FROM_VEC3_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC3_TYPE, A, B, C) \ + GLM_SWIZZLE_GEN_REF2_FROM_VEC3_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, A, B, C) + +#define GLM_SWIZZLE_GEN_REF_FROM_VEC3(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE) \ + GLM_SWIZZLE_GEN_REF_FROM_VEC3_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, x, y, z) \ + GLM_SWIZZLE_GEN_REF_FROM_VEC3_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, r, g, b) \ + GLM_SWIZZLE_GEN_REF_FROM_VEC3_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, s, t, p) + +//GLM_SWIZZLE_GEN_REF_FROM_VEC3(valType, detail::vec3, detail::ref2, detail::ref3) + +#define GLM_SWIZZLE_GEN_REF2_FROM_VEC4_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B, C, D) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, A, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, A, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, A, D) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, B, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, B, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, B, D) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, C, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, C, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, C, D) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, D, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, D, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, GLM_MUTABLE, D, C) + +#define GLM_SWIZZLE_GEN_REF3_FROM_VEC4_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B, C, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , A, B, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , A, B, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , A, C, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , A, C, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , A, D, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , A, D, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , B, A, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , B, A, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , B, C, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , B, C, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , B, D, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , B, D, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , C, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , C, A, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , C, B, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , C, B, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , C, D, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , C, D, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , D, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , D, A, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , D, B, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , D, B, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , D, C, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , D, C, B) + +#define GLM_SWIZZLE_GEN_REF4_FROM_VEC4_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , A, C, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , A, C, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , A, D, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , A, D, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , A, B, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , A, B, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , B, C, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , B, C, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , B, D, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , B, D, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , B, A, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , B, A, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , C, B, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , C, B, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , C, D, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , C, D, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , C, A, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , C, A, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , D, C, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , D, C, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , D, A, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , D, A, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , D, B, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, , D, B, C, A) + +#define GLM_SWIZZLE_GEN_REF_FROM_VEC4_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, A, B, C, D) \ + GLM_SWIZZLE_GEN_REF2_FROM_VEC4_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, A, B, C, D) \ + GLM_SWIZZLE_GEN_REF3_FROM_VEC4_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC3_TYPE, A, B, C, D) \ + GLM_SWIZZLE_GEN_REF4_FROM_VEC4_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC4_TYPE, A, B, C, D) + +#define GLM_SWIZZLE_GEN_REF_FROM_VEC4(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE) \ + GLM_SWIZZLE_GEN_REF_FROM_VEC4_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, x, y, z, w) \ + GLM_SWIZZLE_GEN_REF_FROM_VEC4_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, r, g, b, a) \ + GLM_SWIZZLE_GEN_REF_FROM_VEC4_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, s, t, p, q) + +//GLM_SWIZZLE_GEN_REF_FROM_VEC4(valType, detail::vec4, detail::ref2, detail::ref3, detail::ref4) + +#define GLM_SWIZZLE_GEN_VEC2_FROM_VEC2_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B) + +#define GLM_SWIZZLE_GEN_VEC3_FROM_VEC2_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, B) + +#define GLM_SWIZZLE_GEN_VEC4_FROM_VEC2_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, B, B) + +#define GLM_SWIZZLE_GEN_VEC_FROM_VEC2_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, A, B) \ + GLM_SWIZZLE_GEN_VEC2_FROM_VEC2_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, A, B) \ + GLM_SWIZZLE_GEN_VEC3_FROM_VEC2_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC3_TYPE, A, B) \ + GLM_SWIZZLE_GEN_VEC4_FROM_VEC2_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC4_TYPE, A, B) + +#define GLM_SWIZZLE_GEN_VEC_FROM_VEC2(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE) \ + GLM_SWIZZLE_GEN_VEC_FROM_VEC2_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, x, y) \ + GLM_SWIZZLE_GEN_VEC_FROM_VEC2_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, r, g) \ + GLM_SWIZZLE_GEN_VEC_FROM_VEC2_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, s, t) + +//GLM_SWIZZLE_GEN_VEC_FROM_VEC2(valType, detail::vec2, detail::vec2, detail::vec3, detail::vec4) + +#define GLM_SWIZZLE_GEN_VEC2_FROM_VEC3_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C) + +#define GLM_SWIZZLE_GEN_VEC3_FROM_VEC3_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, C) + +#define GLM_SWIZZLE_GEN_VEC4_FROM_VEC3_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, C, C) + +#define GLM_SWIZZLE_GEN_VEC_FROM_VEC3_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, A, B, C) \ + GLM_SWIZZLE_GEN_VEC2_FROM_VEC3_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, A, B, C) \ + GLM_SWIZZLE_GEN_VEC3_FROM_VEC3_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC3_TYPE, A, B, C) \ + GLM_SWIZZLE_GEN_VEC4_FROM_VEC3_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC4_TYPE, A, B, C) + +#define GLM_SWIZZLE_GEN_VEC_FROM_VEC3(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE) \ + GLM_SWIZZLE_GEN_VEC_FROM_VEC3_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, x, y, z) \ + GLM_SWIZZLE_GEN_VEC_FROM_VEC3_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, r, g, b) \ + GLM_SWIZZLE_GEN_VEC_FROM_VEC3_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, s, t, p) + +//GLM_SWIZZLE_GEN_VEC_FROM_VEC3(valType, detail::vec3, detail::vec2, detail::vec3, detail::vec4) + +#define GLM_SWIZZLE_GEN_VEC2_FROM_VEC4_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B, C, D) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C) \ + GLM_SWIZZLE_GEN_VEC2_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D) + +#define GLM_SWIZZLE_GEN_VEC3_FROM_VEC4_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B, C, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, D) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, A) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, B) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, C) \ + GLM_SWIZZLE_GEN_VEC3_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, D) + +#define GLM_SWIZZLE_GEN_VEC4_FROM_VEC4_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, A, B, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, A, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, B, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, C, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, A, D, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, A, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, B, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, C, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, B, D, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, A, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, B, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, C, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, C, D, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, A, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, B, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, C, D, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, A, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, A, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, A, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, A, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, B, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, B, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, B, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, B, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, C, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, C, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, C, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, C, D) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, D, A) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, D, B) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, D, C) \ + GLM_SWIZZLE_GEN_VEC4_ENTRY(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_TYPE, const, D, D, D, D) + +#define GLM_SWIZZLE_GEN_VEC_FROM_VEC4_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, A, B, C, D) \ + GLM_SWIZZLE_GEN_VEC2_FROM_VEC4_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, A, B, C, D) \ + GLM_SWIZZLE_GEN_VEC3_FROM_VEC4_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC3_TYPE, A, B, C, D) \ + GLM_SWIZZLE_GEN_VEC4_FROM_VEC4_SWIZZLE(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC4_TYPE, A, B, C, D) + +#define GLM_SWIZZLE_GEN_VEC_FROM_VEC4(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE) \ + GLM_SWIZZLE_GEN_VEC_FROM_VEC4_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, x, y, z, w) \ + GLM_SWIZZLE_GEN_VEC_FROM_VEC4_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, r, g, b, a) \ + GLM_SWIZZLE_GEN_VEC_FROM_VEC4_COMP(TMPL_TYPE, PRECISION, CLASS_TYPE, SWIZZLED_VEC2_TYPE, SWIZZLED_VEC3_TYPE, SWIZZLED_VEC4_TYPE, s, t, p, q) + +//GLM_SWIZZLE_GEN_VEC_FROM_VEC4(valType, detail::vec4, detail::vec2, detail::vec3, detail::vec4) + +#endif//glm_core_swizzle_func diff --git a/thirdparty/glm/detail/_vectorize.hpp b/thirdparty/glm/detail/_vectorize.hpp new file mode 100644 index 000000000..b653fa9f3 --- /dev/null +++ b/thirdparty/glm/detail/_vectorize.hpp @@ -0,0 +1,217 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/core/_vectorize.hpp +/// @date 2011-10-14 / 2011-10-14 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_CORE_DETAIL_INCLUDED +#define GLM_CORE_DETAIL_INCLUDED + +#include "type_vec1.hpp" +#include "type_vec2.hpp" +#include "type_vec3.hpp" +#include "type_vec4.hpp" + +#define VECTORIZE1_VEC(func) \ + template \ + GLM_FUNC_QUALIFIER detail::tvec1 func( \ + detail::tvec1 const & v) \ + { \ + return detail::tvec1( \ + func(v.x)); \ + } + +#define VECTORIZE2_VEC(func) \ + template \ + GLM_FUNC_QUALIFIER detail::tvec2 func( \ + detail::tvec2 const & v) \ + { \ + return detail::tvec2( \ + func(v.x), \ + func(v.y)); \ + } + +#define VECTORIZE3_VEC(func) \ + template \ + GLM_FUNC_QUALIFIER detail::tvec3 func( \ + detail::tvec3 const & v) \ + { \ + return detail::tvec3( \ + func(v.x), \ + func(v.y), \ + func(v.z)); \ + } + +#define VECTORIZE4_VEC(func) \ + template \ + GLM_FUNC_QUALIFIER detail::tvec4 func( \ + detail::tvec4 const & v) \ + { \ + return detail::tvec4( \ + func(v.x), \ + func(v.y), \ + func(v.z), \ + func(v.w)); \ + } + +#define VECTORIZE_VEC(func) \ + VECTORIZE1_VEC(func) \ + VECTORIZE2_VEC(func) \ + VECTORIZE3_VEC(func) \ + VECTORIZE4_VEC(func) + +#define VECTORIZE1_VEC_SCA(func) \ + template \ + GLM_FUNC_QUALIFIER detail::tvec1 func \ + ( \ + detail::tvec1 const & x, \ + T const & y \ + ) \ + { \ + return detail::tvec1( \ + func(x.x, y)); \ + } + +#define VECTORIZE2_VEC_SCA(func) \ + template \ + GLM_FUNC_QUALIFIER detail::tvec2 func \ + ( \ + detail::tvec2 const & x, \ + T const & y \ + ) \ + { \ + return detail::tvec2( \ + func(x.x, y), \ + func(x.y, y)); \ + } + +#define VECTORIZE3_VEC_SCA(func) \ + template \ + GLM_FUNC_QUALIFIER detail::tvec3 func \ + ( \ + detail::tvec3 const & x, \ + T const & y \ + ) \ + { \ + return detail::tvec3( \ + func(x.x, y), \ + func(x.y, y), \ + func(x.z, y)); \ + } + +#define VECTORIZE4_VEC_SCA(func) \ + template \ + GLM_FUNC_QUALIFIER detail::tvec4 func \ + ( \ + detail::tvec4 const & x, \ + T const & y \ + ) \ + { \ + return detail::tvec4( \ + func(x.x, y), \ + func(x.y, y), \ + func(x.z, y), \ + func(x.w, y)); \ + } + +#define VECTORIZE_VEC_SCA(func) \ + VECTORIZE1_VEC_SCA(func) \ + VECTORIZE2_VEC_SCA(func) \ + VECTORIZE3_VEC_SCA(func) \ + VECTORIZE4_VEC_SCA(func) + +#define VECTORIZE2_VEC_VEC(func) \ + template \ + GLM_FUNC_QUALIFIER detail::tvec2 func \ + ( \ + detail::tvec2 const & x, \ + detail::tvec2 const & y \ + ) \ + { \ + return detail::tvec2( \ + func(x.x, y.x), \ + func(x.y, y.y)); \ + } + +#define VECTORIZE3_VEC_VEC(func) \ + template \ + GLM_FUNC_QUALIFIER detail::tvec3 func \ + ( \ + detail::tvec3 const & x, \ + detail::tvec3 const & y \ + ) \ + { \ + return detail::tvec3( \ + func(x.x, y.x), \ + func(x.y, y.y), \ + func(x.z, y.z)); \ + } + +#define VECTORIZE4_VEC_VEC(func) \ + template \ + GLM_FUNC_QUALIFIER detail::tvec4 func \ + ( \ + detail::tvec4 const & x, \ + detail::tvec4 const & y \ + ) \ + { \ + return detail::tvec4( \ + func(x.x, y.x), \ + func(x.y, y.y), \ + func(x.z, y.z), \ + func(x.w, y.w)); \ + } + +#define VECTORIZE_VEC_VEC(func) \ + VECTORIZE2_VEC_VEC(func) \ + VECTORIZE3_VEC_VEC(func) \ + VECTORIZE4_VEC_VEC(func) + +namespace glm{ +namespace detail +{ + template + struct If + { + template + static GLM_FUNC_QUALIFIER T apply(F functor, const T& val) + { + return functor(val); + } + }; + + template<> + struct If + { + template + static GLM_FUNC_QUALIFIER T apply(F, const T& val) + { + return val; + } + }; +}//namespace detail +}//namespace glm + +#endif//GLM_CORE_DETAIL_INCLUDED diff --git a/thirdparty/glm/detail/dummy.cpp b/thirdparty/glm/detail/dummy.cpp new file mode 100644 index 000000000..98ca022ce --- /dev/null +++ b/thirdparty/glm/detail/dummy.cpp @@ -0,0 +1,190 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/core/dummy.cpp +/// @date 2011-01-19 / 2011-06-15 +/// @author Christophe Riccio +/// +/// GLM is a header only library. There is nothing to compile. +/// dummy.cpp exist only a wordaround for CMake file. +/////////////////////////////////////////////////////////////////////////////////// + +#define GLM_FORCE_RADIANS +#define GLM_MESSAGES +#include "../glm.hpp" +#include + +struct material +{ + glm::vec4 emission; // Ecm + glm::vec4 ambient; // Acm + glm::vec4 diffuse; // Dcm + glm::vec4 specular; // Scm + float shininess; // Srm +}; +struct light +{ + glm::vec4 ambient; // Acli + glm::vec4 diffuse; // Dcli + glm::vec4 specular; // Scli + glm::vec4 position; // Ppli + glm::vec4 halfVector; // Derived: Hi + glm::vec3 spotDirection; // Sdli + float spotExponent; // Srli + float spotCutoff; // Crli + // (range: [0.0,90.0], 180.0) + float spotCosCutoff; // Derived: cos(Crli) + // (range: [1.0,0.0],-1.0) + float constantAttenuation; // K0 + float linearAttenuation; // K1 + float quadraticAttenuation;// K2 +}; + +// Sample 1 +#include // glm::vec3 +#include // glm::cross, glm::normalize + +glm::vec3 computeNormal +( + glm::vec3 const & a, + glm::vec3 const & b, + glm::vec3 const & c +) +{ + return glm::normalize(glm::cross(c - a, b - a)); +} + +typedef unsigned int GLuint; +#define GL_FALSE 0 +void glUniformMatrix4fv(GLuint, int, int, float*){} + +// Sample 2 +#include // glm::vec3 +#include // glm::vec4, glm::ivec4 +#include // glm::mat4 +#include // glm::translate, glm::rotate, glm::scale, glm::perspective +#include // glm::value_ptr +void func(GLuint LocationMVP, float Translate, glm::vec2 const & Rotate) +{ + glm::mat4 Projection = glm::perspective(45.0f, 4.0f / 3.0f, 0.1f, 100.f); + glm::mat4 ViewTranslate = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -Translate)); + glm::mat4 ViewRotateX = glm::rotate(ViewTranslate, Rotate.y, glm::vec3(-1.0f, 0.0f, 0.0f)); + glm::mat4 View = glm::rotate(ViewRotateX, Rotate.x, glm::vec3(0.0f, 1.0f, 0.0f)); + glm::mat4 Model = glm::scale(glm::mat4(1.0f), glm::vec3(0.5f)); + glm::mat4 MVP = Projection * View * Model; + glUniformMatrix4fv(LocationMVP, 1, GL_FALSE, glm::value_ptr(MVP)); +} + +// Sample 3 +#include // glm::vec2 +#include // glm::packUnorm2x16 +#include // glm::uint +#include // glm::i8vec2, glm::i32vec2 +std::size_t const VertexCount = 4; +// Float quad geometry +std::size_t const PositionSizeF32 = VertexCount * sizeof(glm::vec2); +glm::vec2 const PositionDataF32[VertexCount] = +{ + glm::vec2(-1.0f,-1.0f), + glm::vec2( 1.0f,-1.0f), + glm::vec2( 1.0f, 1.0f), + glm::vec2(-1.0f, 1.0f) + }; +// Half-float quad geometry +std::size_t const PositionSizeF16 = VertexCount * sizeof(glm::uint); +glm::uint const PositionDataF16[VertexCount] = +{ + glm::uint(glm::packUnorm2x16(glm::vec2(-1.0f, -1.0f))), + glm::uint(glm::packUnorm2x16(glm::vec2( 1.0f, -1.0f))), + glm::uint(glm::packUnorm2x16(glm::vec2( 1.0f, 1.0f))), + glm::uint(glm::packUnorm2x16(glm::vec2(-1.0f, 1.0f))) +}; +// 8 bits signed integer quad geometry +std::size_t const PositionSizeI8 = VertexCount * sizeof(glm::i8vec2); +glm::i8vec2 const PositionDataI8[VertexCount] = +{ + glm::i8vec2(-1,-1), + glm::i8vec2( 1,-1), + glm::i8vec2( 1, 1), + glm::i8vec2(-1, 1) +}; +// 32 bits signed integer quad geometry +std::size_t const PositionSizeI32 = VertexCount * sizeof(glm::i32vec2); +glm::i32vec2 const PositionDataI32[VertexCount] = +{ + glm::i32vec2 (-1,-1), + glm::i32vec2 ( 1,-1), + glm::i32vec2 ( 1, 1), + glm::i32vec2 (-1, 1) +}; + +struct intersection +{ + glm::vec4 position; + glm::vec3 normal; +}; + +/* +// Sample 4 +#include // glm::vec3 +#include // glm::normalize, glm::dot, glm::reflect +#include // glm::pow +#include // glm::vecRand3 +glm::vec3 lighting +( + intersection const & Intersection, + material const & Material, + light const & Light, + glm::vec3 const & View +) +{ + glm::vec3 Color(0.0f); + glm::vec3 LightVertor(glm::normalize( + Light.position - Intersection.position + + glm::vecRand3(0.0f, Light.inaccuracy)); + + if(!shadow(Intersection.position, Light.position, LightVertor)) + { + float Diffuse = glm::dot(Intersection.normal, LightVector); + if(Diffuse <= 0.0f) + return Color; + if(Material.isDiffuse()) + Color += Light.color() * Material.diffuse * Diffuse; + if(Material.isSpecular()) + { + glm::vec3 Reflect(glm::reflect( + glm::normalize(-LightVector), + glm::normalize(Intersection.normal))); + float Dot = glm::dot(Reflect, View); + float Base = Dot > 0.0f ? Dot : 0.0f; + float Specular = glm::pow(Base, Material.exponent); + Color += Material.specular * Specular; + } + } + return Color; +} +*/ +int main() +{ + return 0; +} diff --git a/thirdparty/glm/detail/func_common.hpp b/thirdparty/glm/detail/func_common.hpp new file mode 100644 index 000000000..a3e5d6338 --- /dev/null +++ b/thirdparty/glm/detail/func_common.hpp @@ -0,0 +1,472 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/core/func_common.hpp +/// @date 2008-03-08 / 2010-01-26 +/// @author Christophe Riccio +/// +/// @see GLSL 4.20.8 specification, section 8.3 Common Functions +/// +/// @defgroup core_func_common Common functions +/// @ingroup core +/// +/// These all operate component-wise. The description is per component. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_FUNC_COMMON_INCLUDED +#define GLM_FUNC_COMMON_INCLUDED + +#include "setup.hpp" +#include "precision.hpp" +#include "type_int.hpp" +#include "_fixes.hpp" + +namespace glm +{ + /// @addtogroup core_func_common + /// @{ + + /// Returns x if x >= 0; otherwise, it returns -x. + /// + /// @tparam genType floating-point or signed integer; scalar or vector types. + /// + /// @see GLSL abs man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template + GLM_FUNC_DECL genType abs(genType const & x); + + /// Returns 1.0 if x > 0, 0.0 if x == 0, or -1.0 if x < 0. + /// + /// @tparam genType Floating-point or signed integer; scalar or vector types. + /// + /// @see GLSL sign man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template + GLM_FUNC_DECL genType sign(genType const & x); + + /// Returns a value equal to the nearest integer that is less then or equal to x. + /// + /// @tparam genType Floating-point scalar or vector types. + /// + /// @see GLSL floor man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template + GLM_FUNC_DECL genType floor(genType const & x); + + /// Returns a value equal to the nearest integer to x + /// whose absolute value is not larger than the absolute value of x. + /// + /// @tparam genType Floating-point scalar or vector types. + /// + /// @see GLSL trunc man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template + GLM_FUNC_DECL genType trunc(genType const & x); + + /// Returns a value equal to the nearest integer to x. + /// The fraction 0.5 will round in a direction chosen by the + /// implementation, presumably the direction that is fastest. + /// This includes the possibility that round(x) returns the + /// same value as roundEven(x) for all values of x. + /// + /// @tparam genType Floating-point scalar or vector types. + /// + /// @see GLSL round man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template + GLM_FUNC_DECL genType round(genType const & x); + + /// Returns a value equal to the nearest integer to x. + /// A fractional part of 0.5 will round toward the nearest even + /// integer. (Both 3.5 and 4.5 for x will return 4.0.) + /// + /// @tparam genType Floating-point scalar or vector types. + /// + /// @see GLSL roundEven man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + /// @see New round to even technique + template + GLM_FUNC_DECL genType roundEven(genType const & x); + + /// Returns a value equal to the nearest integer + /// that is greater than or equal to x. + /// + /// @tparam genType Floating-point scalar or vector types. + /// + /// @see GLSL ceil man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template + GLM_FUNC_DECL genType ceil(genType const & x); + + /// Return x - floor(x). + /// + /// @tparam genType Floating-point scalar or vector types. + /// + /// @see GLSL fract man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template + GLM_FUNC_DECL genType fract(genType const & x); + + /// Modulus. Returns x - y * floor(x / y) + /// for each component in x using the floating point value y. + /// + /// @tparam genType Floating-point scalar or vector types. + /// + /// @see GLSL mod man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template + GLM_FUNC_DECL genType mod( + genType const & x, + genType const & y); + + /// Modulus. Returns x - y * floor(x / y) + /// for each component in x using the floating point value y. + /// + /// @tparam genType Floating-point scalar or vector types. + /// + /// @see GLSL mod man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template + GLM_FUNC_DECL genType mod( + genType const & x, + typename genType::value_type const & y); + + /// Returns the fractional part of x and sets i to the integer + /// part (as a whole number floating point value). Both the + /// return value and the output parameter will have the same + /// sign as x. + /// + /// @tparam genType Floating-point scalar or vector types. + /// + /// @see GLSL modf man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template + GLM_FUNC_DECL genType modf( + genType const & x, + genType & i); + + /// Returns y if y < x; otherwise, it returns x. + /// + /// @tparam genType Floating-point or integer; scalar or vector types. + /// + /// @see GLSL min man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions<<<<<<< HEAD + template + GLM_FUNC_DECL genType min( + genType const & x, + genType const & y); + + template + GLM_FUNC_DECL genType min( + genType const & x, + typename genType::value_type const & y); + + /// Returns y if x < y; otherwise, it returns x. + /// + /// @tparam genType Floating-point or integer; scalar or vector types. + /// + /// @see GLSL max man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template + GLM_FUNC_DECL genType max( + genType const & x, + genType const & y); + + template + GLM_FUNC_DECL genType max( + genType const & x, + typename genType::value_type const & y); + + /// Returns min(max(x, minVal), maxVal) for each component in x + /// using the floating-point values minVal and maxVal. + /// + /// @tparam genType Floating-point or integer; scalar or vector types. + /// + /// @see GLSL clamp man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template + GLM_FUNC_DECL genType clamp( + genType const & x, + genType const & minVal, + genType const & maxVal); + + template + GLM_FUNC_DECL genType clamp( + genType const & x, + typename genType::value_type const & minVal, + typename genType::value_type const & maxVal); + + /// If genTypeU is a floating scalar or vector: + /// Returns x * (1.0 - a) + y * a, i.e., the linear blend of + /// x and y using the floating-point value a. + /// The value for a is not restricted to the range [0, 1]. + /// + /// If genTypeU is a boolean scalar or vector: + /// Selects which vector each returned component comes + /// from. For a component of that is false, the + /// corresponding component of x is returned. For a + /// component of a that is true, the corresponding + /// component of y is returned. Components of x and y that + /// are not selected are allowed to be invalid floating point + /// values and will have no effect on the results. Thus, this + /// provides different functionality than + /// genType mix(genType x, genType y, genType(a)) + /// where a is a Boolean vector. + /// + /// @see GLSL mix man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + /// + /// @param[in] x Value to interpolate. + /// @param[in] y Value to interpolate. + /// @param[in] a Interpolant. + /// + /// @tparam genTypeT Floating point scalar or vector. + /// @tparam genTypeU Floating point or boolean scalar or vector. It can't be a vector if it is the length of genTypeT. + /// + /// @code + /// #include + /// ... + /// float a; + /// bool b; + /// glm::dvec3 e; + /// glm::dvec3 f; + /// glm::vec4 g; + /// glm::vec4 h; + /// ... + /// glm::vec4 r = glm::mix(g, h, a); // Interpolate with a floating-point scalar two vectors. + /// glm::vec4 s = glm::mix(g, h, b); // Teturns g or h; + /// glm::dvec3 t = glm::mix(e, f, a); // Types of the third parameter is not required to match with the first and the second. + /// glm::vec4 u = glm::mix(g, h, r); // Interpolations can be perform per component with a vector for the last parameter. + /// @endcode + template class vecType> + GLM_FUNC_DECL vecType mix( + vecType const & x, + vecType const & y, + vecType const & a); + + template class vecType> + GLM_FUNC_DECL vecType mix( + vecType const & x, + vecType const & y, + U const & a); + + template + GLM_FUNC_DECL genTypeT mix( + genTypeT const & x, + genTypeT const & y, + genTypeU const & a); + + /// Returns 0.0 if x < edge, otherwise it returns 1.0 for each component of a genType. + /// + /// @see GLSL step man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template + GLM_FUNC_DECL genType step( + genType const & edge, + genType const & x); + + /// Returns 0.0 if x < edge, otherwise it returns 1.0. + /// + /// @see GLSL step man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template