mirror of
https://github.com/celisej567/mcpe.git
synced 2026-01-05 18:10:09 +03:00
Misc patches
This commit is contained in:
107
CMakeLists.txt
Normal file
107
CMakeLists.txt
Normal file
@@ -0,0 +1,107 @@
|
||||
# CMake build system
|
||||
# (c) Er2 2024 <er2@dismail.de>
|
||||
# Zlib License
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
if ("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
message(FATAL_ERROR "Prevented in-tree build.\n"
|
||||
"Use cmake -S. -Bbuild instead."
|
||||
)
|
||||
endif()
|
||||
|
||||
# Use actual name as some IDEs can show them
|
||||
project(ReMinecraftPE LANGUAGES CXX)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
set(PLATFORMS android sdl windows server)
|
||||
set(RENDERERS gl gles)
|
||||
|
||||
if (ANDROID)
|
||||
set(_DEFAULT_PLAT android)
|
||||
set(_DEFAULT_RENDER gles)
|
||||
elseif (WIN32)
|
||||
set(_DEFAULT_PLAT windows)
|
||||
set(_DEFAULT_RENDER gl) # TODO: DirectX
|
||||
else()
|
||||
set(_DEFAULT_PLAT sdl)
|
||||
set(_DEFAULT_RENDER gl)
|
||||
endif()
|
||||
|
||||
set(platform ${_DEFAULT_PLAT} CACHE STRING "Active platform")
|
||||
set(render ${_DEFAULT_RENDER} CACHE STRING "Active renderer")
|
||||
set_property(CACHE platform PROPERTY STRINGS ${PLATFORMS})
|
||||
set_property(CACHE render PROPERTY STRINGS ${RENDERERS})
|
||||
|
||||
message(STATUS "Active platform: ${platform}")
|
||||
message(STATUS "Active renderer: ${render}")
|
||||
|
||||
if (ANDROID)
|
||||
message(STATUS "Android library will be only built. For apk use gradle")
|
||||
elseif (EMSCRIPTEN)
|
||||
# Code should be built with -pthread to use pthread
|
||||
add_compile_options(-pthread)
|
||||
add_link_options(-pthread)
|
||||
elseif (platform STREQUAL macos)
|
||||
message(FATAL_ERROR "${PLATFORM} currently can't be built using cmake. Use XCode instead")
|
||||
elseif (platform STREQUAL sdl)
|
||||
set(USE_SDL 1)
|
||||
add_compile_definitions(USE_SDL)
|
||||
#elseif (platform STREQUAL server)
|
||||
# set(BUILD_SERVER 1)
|
||||
# add_compile_definitions(SERVER)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set(USE_GLES1_COMPATIBILITY_LAYER FALSE CACHE BOOL "" FORCE)
|
||||
elseif(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 OR platform STREQUAL sdl)
|
||||
# Prepare SDL library
|
||||
add_library(SDL INTERFACE)
|
||||
if (NOT platform STREQUAL sdl)
|
||||
message(FATAL_ERROR "GLESv1 compatibility layer can't be currently used without sdl2")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/app")
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
|
||||
|
||||
# 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("$<$<CONFIG:DEBUG>:-gsource-map>")
|
||||
endif()
|
||||
|
||||
# Threads
|
||||
if (EMSCRIPTEN)
|
||||
add_compile_and_link_options(-pthread)
|
||||
elseif (WIN32)
|
||||
# using winapi so no pthread
|
||||
else()
|
||||
find_package(Threads)
|
||||
link_libraries(Threads::Threads)
|
||||
endif()
|
||||
|
||||
# Platforms
|
||||
if ("${platform}" IN_LIST PLATFORMS)
|
||||
add_subdirectory(platforms/${platform})
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown platform!")
|
||||
endif()
|
||||
|
||||
set_property(DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY VS_STARTUP_PROJECT ReMinecraftPE)
|
||||
set_target_properties(${APP_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/app")
|
||||
|
||||
# Include source code
|
||||
add_subdirectory(source)
|
||||
@@ -9,10 +9,6 @@
|
||||
#define DEMO
|
||||
#else
|
||||
|
||||
#if defined ANDROID || defined TARGET_OS_IPHONE
|
||||
#define MOBILE
|
||||
#endif
|
||||
|
||||
// TODO: Since this is the modded version, we don't need these anymore. Remove them
|
||||
|
||||
// Mods
|
||||
|
||||
@@ -23,7 +23,7 @@ enum eSDLVirtualKeys
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#include <windows.h>
|
||||
#elif __APPLE__
|
||||
// https://i.stack.imgur.com/LD8pT.png
|
||||
#define AKEYCODE_FORWARD_DEL 0x75
|
||||
|
||||
@@ -12,6 +12,12 @@
|
||||
#include <TargetConditionals.h>
|
||||
#endif
|
||||
|
||||
#define MC_TARGET_OS_SIMULATOR (TARGET_OS_SIMULATOR || TARGET_IPHONE_SIMULATOR)
|
||||
#define MC_TARGET_OS_IOS (TARGET_OS_IPHONE && (TARGET_OS_IOS || !defined(TARGET_OS_IOS)))
|
||||
#define MC_TARGET_OS_MAC (TARGET_OS_MAC)
|
||||
#if TARGET_OS_SIMULATOR || TARGET_IPHONE_SIMULATOR
|
||||
# define MC_TARGET_OS_SIMULATOR 1
|
||||
#else
|
||||
#endif
|
||||
#if TARGET_OS_MAC
|
||||
# define MC_TARGET_OS_MAC 1
|
||||
#elif TARGET_OS_IOS && TARGET_OS_IPHONE
|
||||
# define MC_TARGET_OS_IOS 1
|
||||
#endif
|
||||
|
||||
@@ -4,17 +4,7 @@ CODE(ESCAPE)
|
||||
CODE(BACKSPACE)
|
||||
CODE(TAB)
|
||||
CODE(SPACE)
|
||||
CODE(EXCLAIM)
|
||||
CODE(QUOTEDBL)
|
||||
CODE(HASH)
|
||||
CODE(PERCENT)
|
||||
CODE(DOLLAR)
|
||||
CODE(AMPERSAND)
|
||||
CODE(QUOTE)
|
||||
CODE(LEFTPAREN)
|
||||
CODE(RIGHTPAREN)
|
||||
CODE(ASTERISK)
|
||||
CODE(PLUS)
|
||||
CODE(APOSTROPHE)
|
||||
CODE(COMMA)
|
||||
CODE(MINUS)
|
||||
CODE(PERIOD)
|
||||
@@ -29,45 +19,58 @@ CODE(6)
|
||||
CODE(7)
|
||||
CODE(8)
|
||||
CODE(9)
|
||||
CODE(COLON)
|
||||
CODE(SEMICOLON)
|
||||
CODE(LESS)
|
||||
CODE(EQUALS)
|
||||
CODE(GREATER)
|
||||
CODE(QUESTION)
|
||||
CODE(AT)
|
||||
CODE(LEFTBRACKET)
|
||||
CODE(BACKSLASH)
|
||||
CODE(NONUSBACKSLASH)
|
||||
CODE(NONUSHASH)
|
||||
CODE(RIGHTBRACKET)
|
||||
CODE(CARET)
|
||||
CODE(UNDERSCORE)
|
||||
CODE(BACKQUOTE)
|
||||
CODE(a)
|
||||
CODE(b)
|
||||
CODE(c)
|
||||
CODE(d)
|
||||
CODE(e)
|
||||
CODE(f)
|
||||
CODE(g)
|
||||
CODE(h)
|
||||
CODE(i)
|
||||
CODE(j)
|
||||
CODE(k)
|
||||
CODE(l)
|
||||
CODE(m)
|
||||
CODE(n)
|
||||
CODE(o)
|
||||
CODE(p)
|
||||
CODE(q)
|
||||
CODE(r)
|
||||
CODE(s)
|
||||
CODE(t)
|
||||
CODE(u)
|
||||
CODE(v)
|
||||
CODE(w)
|
||||
CODE(x)
|
||||
CODE(y)
|
||||
CODE(z)
|
||||
CODE(GRAVE)
|
||||
CODE(A)
|
||||
CODE(B)
|
||||
CODE(C)
|
||||
CODE(D)
|
||||
CODE(E)
|
||||
CODE(F)
|
||||
CODE(G)
|
||||
CODE(H)
|
||||
CODE(I)
|
||||
CODE(J)
|
||||
CODE(K)
|
||||
CODE(L)
|
||||
CODE(M)
|
||||
CODE(N)
|
||||
CODE(O)
|
||||
CODE(P)
|
||||
CODE(Q)
|
||||
CODE(R)
|
||||
CODE(S)
|
||||
CODE(T)
|
||||
CODE(U)
|
||||
CODE(V)
|
||||
CODE(W)
|
||||
CODE(X)
|
||||
CODE(Y)
|
||||
CODE(Z)
|
||||
CODE(INTERNATIONAL1)
|
||||
CODE(INTERNATIONAL2)
|
||||
CODE(INTERNATIONAL3)
|
||||
CODE(INTERNATIONAL4)
|
||||
CODE(INTERNATIONAL5)
|
||||
CODE(INTERNATIONAL6)
|
||||
CODE(INTERNATIONAL7)
|
||||
CODE(INTERNATIONAL8)
|
||||
CODE(INTERNATIONAL9)
|
||||
CODE(LANG1)
|
||||
CODE(LANG2)
|
||||
CODE(LANG3)
|
||||
CODE(LANG4)
|
||||
CODE(LANG5)
|
||||
CODE(LANG6)
|
||||
CODE(LANG7)
|
||||
CODE(LANG8)
|
||||
CODE(LANG9)
|
||||
CODE(CAPSLOCK)
|
||||
CODE(F1)
|
||||
CODE(F2)
|
||||
@@ -234,15 +237,11 @@ CODE(KBDILLUMDOWN)
|
||||
CODE(KBDILLUMUP)
|
||||
CODE(EJECT)
|
||||
CODE(SLEEP)
|
||||
#ifdef SDLK_APP1
|
||||
CODE(APP1)
|
||||
#endif
|
||||
#ifdef SDLK_APP2
|
||||
CODE(APP2)
|
||||
#endif
|
||||
#ifdef SDLK_AUDIOREWIND
|
||||
CODE(AUDIOREWIND)
|
||||
#endif
|
||||
#ifdef SDLK_AUDIOFASTFORWARD
|
||||
CODE(AUDIOFASTFORWARD)
|
||||
#endif
|
||||
CODE(SOFTLEFT)
|
||||
CODE(SOFTRIGHT)
|
||||
CODE(CALL)
|
||||
CODE(ENDCALL)
|
||||
|
||||
39
platforms/android/CMakeLists.txt
Normal file
39
platforms/android/CMakeLists.txt
Normal file
@@ -0,0 +1,39 @@
|
||||
SET(MC_ROOT ../..)
|
||||
|
||||
# Native Android Build
|
||||
add_compile_definitions(USE_NATIVE_ANDROID)
|
||||
set(USE_NATIVE_ANDROID TRUE)
|
||||
|
||||
add_library(reminecraftpe SHARED
|
||||
AppPlatform_android.cpp
|
||||
SoundSystemSL.cpp
|
||||
android_native_app_glue.c
|
||||
main.cpp
|
||||
)
|
||||
|
||||
# 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()
|
||||
|
||||
# Add the core as part of the library
|
||||
target_link_libraries(reminecraftpe Core)
|
||||
|
||||
# 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)
|
||||
@@ -4,39 +4,4 @@ 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)
|
||||
|
||||
# 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"
|
||||
)
|
||||
|
||||
# Core
|
||||
add_subdirectory("${MC_ROOT}/source" source)
|
||||
target_link_libraries(reminecraftpe reminecraftpe-core)
|
||||
|
||||
# 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)
|
||||
|
||||
# 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()
|
||||
add_subdirectory(${MC_ROOT} source)
|
||||
|
||||
@@ -3,28 +3,44 @@ project(reminecraftpe-openal)
|
||||
|
||||
# Build
|
||||
add_library(reminecraftpe-openal STATIC
|
||||
SoundSystemAL.cpp
|
||||
SoundSystemAL.cpp SoundSystemAL.hpp
|
||||
)
|
||||
|
||||
target_compile_definitions(reminecraftpe-openal PUBLIC USE_OPENAL)
|
||||
|
||||
# Core
|
||||
target_link_libraries(reminecraftpe-openal PUBLIC reminecraftpe-core)
|
||||
target_link_libraries(reminecraftpe-openal PUBLIC Core)
|
||||
|
||||
# OpenAL
|
||||
if(ANDROID)
|
||||
# Use Vendored 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 (WIN32)
|
||||
# Use vendored OpenAL
|
||||
set(ALSOFT_UTILS FALSE CACHE BOOL "" FORCE)
|
||||
set(ALSOFT_EXAMPLES FALSE CACHE BOOL "" FORCE)
|
||||
set(ALSOFT_TESTS FALSE CACHE BOOL "" FORCE)
|
||||
# WHY they are enabled for even not win32?
|
||||
set(ALSOFT_BACKEND_PIPEWIRE FALSE CACHE BOOL "" FORCE)
|
||||
set(ALSOFT_BACKEND_PULSEAUDIO FALSE 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}")
|
||||
# Use System OpenAL
|
||||
find_package(OpenAL REQUIRED)
|
||||
target_link_libraries(reminecraftpe-openal PUBLIC OpenAL::OpenAL)
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND (ANDROID OR WIN32))
|
||||
target_compile_options(OpenAL PRIVATE -Wno-ignored-attributes -Wno-sign-conversion -Wno-unused-function)
|
||||
endif()
|
||||
|
||||
# Headers
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#include <OpenAL/al.h>
|
||||
#include <OpenAL/alc.h>
|
||||
#else
|
||||
#include <AL/al.h>
|
||||
#include <AL/alc.h>
|
||||
#include <al.h>
|
||||
#include <alc.h>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -1,85 +1,75 @@
|
||||
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("$<$<CONFIG:DEBUG>:-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()
|
||||
#if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
# add_compile_options(-Wno-inconsistent-missing-override -Wno-enum-compare-switch -Wno-register)
|
||||
#endif()
|
||||
|
||||
# Network library
|
||||
if(HAIKU)
|
||||
if (HAIKU)
|
||||
link_libraries(network)
|
||||
endif()
|
||||
|
||||
# Threads
|
||||
if(EMSCRIPTEN)
|
||||
add_compile_and_link_options(-pthread)
|
||||
else()
|
||||
find_package(Threads)
|
||||
link_libraries(Threads::Threads)
|
||||
endif()
|
||||
|
||||
# Build
|
||||
set(SOURCES
|
||||
main.cpp
|
||||
base/AppPlatform_sdl_base.cpp
|
||||
base/AppPlatform_sdl_base.cpp base/AppPlatform_sdl_base.hpp
|
||||
)
|
||||
if(EMSCRIPTEN)
|
||||
list(APPEND SOURCES emscripten/AppPlatform_sdl.cpp)
|
||||
if (EMSCRIPTEN)
|
||||
list(APPEND SOURCES emscripten/AppPlatform_sdl.cpp emscripten/AppPlatform_sdl.hpp)
|
||||
else()
|
||||
list(APPEND SOURCES desktop/AppPlatform_sdl.cpp)
|
||||
list(APPEND SOURCES desktop/AppPlatform_sdl.cpp desktop/AppPlatform_sdl.hpp)
|
||||
endif()
|
||||
if(ANDROID)
|
||||
if (ANDROID)
|
||||
add_library(reminecraftpe SHARED ${SOURCES})
|
||||
set_target_properties(reminecraftpe PROPERTIES OUTPUT_NAME main)
|
||||
else()
|
||||
add_executable(reminecraftpe ${SOURCES})
|
||||
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)
|
||||
if (NOT EMSCRIPTEN)
|
||||
add_subdirectory(../../thirdparty/stb_image stb_image)
|
||||
target_link_libraries(reminecraftpe stb_image)
|
||||
endif()
|
||||
|
||||
# SDL
|
||||
if(TARGET SDL2::SDL2main)
|
||||
target_link_libraries(reminecraftpe
|
||||
Core
|
||||
SDL
|
||||
)
|
||||
|
||||
message(STATUS "Find dependencies")
|
||||
## SDL2
|
||||
if(ANDROID OR WIN32)
|
||||
message(STATUS "Vendored SDL2 (only for Android and Windows)")
|
||||
set(SDL_OPENGL TRUE CACHE BOOL "" FORCE)
|
||||
#set(SDL_OPENGLES TRUE CACHE BOOL "" FORCE)
|
||||
add_subdirectory(../../thirdparty/SDL2/src SDL EXCLUDE_FROM_ALL)
|
||||
target_link_libraries(SDL INTERFACE SDL2::SDL2)
|
||||
elseif(EMSCRIPTEN)
|
||||
message(STATUS "Emscripten's SDL2")
|
||||
set(SDL_FLAG -sUSE_SDL=2)
|
||||
target_compile_options(SDL "${SDL_FLAG}")
|
||||
target_link_options(SDL "${SDL_FLAG}")
|
||||
else()
|
||||
message(STATUS "System SDL2")
|
||||
find_package(SDL2 REQUIRED)
|
||||
target_link_libraries(SDL INTERFACE SDL2::SDL2)
|
||||
endif()
|
||||
|
||||
if (TARGET SDL2::SDL2main)
|
||||
target_link_libraries(reminecraftpe SDL2::SDL2main)
|
||||
endif()
|
||||
|
||||
# WASM
|
||||
if(EMSCRIPTEN)
|
||||
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()
|
||||
|
||||
@@ -50,6 +50,7 @@ void AppPlatform_sdl_base::_init(std::string storageDir, SDL_Window *window)
|
||||
m_bIsTouchscreen = false;
|
||||
}
|
||||
}
|
||||
m_bMouseGrabbed = false;
|
||||
}
|
||||
|
||||
void AppPlatform_sdl_base::initSoundSystem()
|
||||
@@ -140,22 +141,28 @@ const char* const AppPlatform_sdl_base::getWindowTitle() const
|
||||
return SDL_GetWindowTitle(_window);
|
||||
}
|
||||
|
||||
void AppPlatform_sdl_base::getScreenSize(int* width, int* height) const
|
||||
{
|
||||
SDL_GL_GetDrawableSize(_window, width, height);
|
||||
}
|
||||
|
||||
int AppPlatform_sdl_base::getScreenWidth() const
|
||||
{
|
||||
int width;
|
||||
SDL_GL_GetDrawableSize(_window, &width, nullptr);
|
||||
getScreenSize(&width, nullptr);
|
||||
return width;
|
||||
}
|
||||
|
||||
int AppPlatform_sdl_base::getScreenHeight() const
|
||||
{
|
||||
int height;
|
||||
SDL_GL_GetDrawableSize(_window, nullptr, &height);
|
||||
getScreenSize(nullptr, &height);
|
||||
return height;
|
||||
}
|
||||
|
||||
void AppPlatform_sdl_base::setMouseGrabbed(bool b)
|
||||
{
|
||||
m_bMouseGrabbed = b;
|
||||
SDL_SetWindowGrab(_window, b ? SDL_TRUE : SDL_FALSE);
|
||||
SDL_SetRelativeMouseMode(b ? SDL_TRUE : SDL_FALSE);
|
||||
}
|
||||
@@ -164,6 +171,15 @@ void AppPlatform_sdl_base::setMouseDiff(int x, int y)
|
||||
{
|
||||
xrel = x;
|
||||
yrel = y;
|
||||
|
||||
// Keep mouse centered if it's grabbed
|
||||
if (m_bMouseGrabbed)
|
||||
{
|
||||
int width, height;
|
||||
getScreenSize(&width, &height);
|
||||
SDL_WarpMouseInWindow(_window, width / 2, height / 2);
|
||||
Mouse::feed(MouseButtonType::BUTTON_NONE, false, width / 2, height / 2);
|
||||
}
|
||||
}
|
||||
|
||||
void AppPlatform_sdl_base::getMouseDiff(int& x, int& y)
|
||||
|
||||
@@ -23,6 +23,7 @@ public:
|
||||
|
||||
int checkLicense() override;
|
||||
const char* const getWindowTitle() const;
|
||||
void getScreenSize(int* width, int* height) const;
|
||||
int getScreenWidth() const override;
|
||||
int getScreenHeight() const override;
|
||||
Texture loadTexture(const std::string& path, bool bIsRequired = false) override = 0;
|
||||
@@ -66,6 +67,7 @@ private:
|
||||
SoundSystem* m_pSoundSystem;
|
||||
|
||||
bool m_bIsTouchscreen;
|
||||
bool m_bMouseGrabbed;
|
||||
|
||||
static SDL_Surface* getSurfaceForTexture(const Texture* const texture);
|
||||
protected:
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
AppPlatform_sdl::AppPlatform_sdl(std::string storageDir, SDL_Window *window)
|
||||
: AppPlatform_sdl_base(storageDir, window)
|
||||
{
|
||||
setIcon(loadTexture("icon.png", false));
|
||||
setIcon(AppPlatform_sdl::loadTexture("icon.png", false));
|
||||
}
|
||||
|
||||
// Take Screenshot
|
||||
@@ -37,7 +37,7 @@ void AppPlatform_sdl::ensureDirectoryExists(const char* path)
|
||||
{
|
||||
// Create Screenshots Folder
|
||||
#ifdef _WIN32
|
||||
int ret = XPL_MKDIR(path);
|
||||
int ret = XPL_MKDIR(path, 0);
|
||||
#else
|
||||
int ret = XPL_MKDIR(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
#endif
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
|
||||
#include "thirdparty/GL/GL.hpp"
|
||||
#include "client/app/App.hpp"
|
||||
#include "compat/KeyCodes.hpp"
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include "emscripten/AppPlatform_sdl.hpp"
|
||||
#else
|
||||
#include "desktop/AppPlatform_sdl.hpp"
|
||||
#include <libgen.h>
|
||||
#endif
|
||||
typedef AppPlatform_sdl UsedAppPlatform;
|
||||
|
||||
@@ -33,12 +35,13 @@ static void teardown()
|
||||
}
|
||||
}
|
||||
|
||||
static int TranslateSDLKeyCodeToVirtual(int sdlCode)
|
||||
static int TranslateSDLKeyCodeToVirtual(SDL_Scancode sdlCode)
|
||||
{
|
||||
switch (sdlCode) {
|
||||
#define CODE(x) case SDLK_ ## x: return SDLVK_ ## x;
|
||||
#define CODE(x) case SDL_SCANCODE_ ## x: return SDLVK_ ## x;
|
||||
#include "compat/SDLKeyCodes.h"
|
||||
#undef CODE
|
||||
case SDL_NUM_SCANCODES: break;
|
||||
}
|
||||
return SDLVK_UNKNOWN;
|
||||
}
|
||||
@@ -145,7 +148,7 @@ static void handle_events()
|
||||
}
|
||||
|
||||
// Normal Key Press
|
||||
Keyboard::feed(AppPlatform_sdl_base::GetKeyState(event), TranslateSDLKeyCodeToVirtual(event.key.keysym.sym));
|
||||
Keyboard::feed(AppPlatform_sdl_base::GetKeyState(event), TranslateSDLKeyCodeToVirtual(event.key.keysym.scancode));
|
||||
if (event.key.keysym.sym == SDLK_LSHIFT || event.key.keysym.sym == SDLK_RSHIFT)
|
||||
{
|
||||
g_pAppPlatform->setShiftPressed(event.key.state == SDL_PRESSED, event.key.keysym.sym == SDLK_LSHIFT);
|
||||
@@ -305,6 +308,11 @@ void CheckOptionalTextureAvailability()
|
||||
// Main
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#ifndef __EMSCRIPTEN__
|
||||
// automatically change dir to avoid missing files and manual cd command
|
||||
chdir(dirname(argv[0]));
|
||||
#endif
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0)
|
||||
{
|
||||
LOG_E("Unable To Initialize SDL: %s", SDL_GetError());
|
||||
@@ -330,6 +338,9 @@ int main(int argc, char *argv[])
|
||||
Minecraft::height = std::stoi(argv[2]);
|
||||
#endif
|
||||
|
||||
// disable blocking compositing
|
||||
SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0");
|
||||
|
||||
// Lock To Landscape
|
||||
SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeLeft LandscapeRight");
|
||||
|
||||
@@ -339,6 +350,7 @@ int main(int argc, char *argv[])
|
||||
if (!window)
|
||||
{
|
||||
LOG_E("Unable to create SDL window");
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "SDL Error", "Unable to create SDL window", window);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -389,15 +401,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (!storagePath.empty())
|
||||
createFolderIfNotExists(storagePath.c_str());
|
||||
|
||||
|
||||
// Start MCPE
|
||||
g_pApp = new NinecraftApp;
|
||||
g_pApp->m_externalStorageDir = storagePath;
|
||||
g_pAppPlatform = new UsedAppPlatform(g_pApp->m_externalStorageDir, window);
|
||||
g_pApp->m_pPlatform = g_pAppPlatform;
|
||||
g_pApp->init();
|
||||
|
||||
CheckOptionalTextureAvailability();
|
||||
g_pApp->init();
|
||||
|
||||
// Set Size
|
||||
resize();
|
||||
|
||||
17
platforms/windows/CMakeLists.txt
Normal file
17
platforms/windows/CMakeLists.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
# Windows Build
|
||||
|
||||
add_executable(ReMinecraftPE WIN32
|
||||
AppPlatform_win32.cpp AppPlatform_win32.hpp
|
||||
LoggerWin32.cpp LoggerWin32.hpp
|
||||
main.cpp
|
||||
)
|
||||
|
||||
if (NOT WINDOWS_STORE)
|
||||
target_sources(ReMinecraftPE PRIVATE SoundSystemDS.cpp SoundSystemDS.hpp)
|
||||
endif()
|
||||
|
||||
# stb_image
|
||||
add_subdirectory(../../thirdparty/stb_image stb_image)
|
||||
target_link_libraries(ReMinecraftPE stb_image)
|
||||
|
||||
target_link_libraries(ReMinecraftPE Core dsound dinput8 dxguid)
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <Windows.h>
|
||||
#include <windows.h>
|
||||
#include <uuids.h>
|
||||
#include <strmif.h>
|
||||
#include <stdexcept>
|
||||
@@ -49,4 +49,4 @@ private:
|
||||
IDirectSound8* m_directsound;
|
||||
LPDIRECTSOUND3DLISTENER8 m_listener;
|
||||
std::vector<BufferInfo> m_buffers;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
********************************************************************/
|
||||
|
||||
#include <cstdarg>
|
||||
#include <WindowsX.h>
|
||||
#include <windowsx.h>
|
||||
|
||||
#include "thirdparty/GL/GL.hpp"
|
||||
#include "compat/KeyCodes.hpp"
|
||||
|
||||
@@ -1,353 +1,33 @@
|
||||
cmake_minimum_required(VERSION 3.16.0)
|
||||
project(reminecraftpe-core)
|
||||
project(Core)
|
||||
|
||||
include_directories(. ..)
|
||||
|
||||
# Build
|
||||
add_library(reminecraftpe-core STATIC
|
||||
common/Random.cpp
|
||||
common/Utils.cpp
|
||||
common/Matrix.cpp
|
||||
common/Mth.cpp
|
||||
common/Timer.cpp
|
||||
common/CThread.cpp
|
||||
common/Util.cpp
|
||||
common/Logger.cpp
|
||||
common/SmoothFloat.cpp
|
||||
client/app/App.cpp
|
||||
client/app/AppPlatform.cpp
|
||||
client/app/Minecraft.cpp
|
||||
client/app/NinecraftApp.cpp
|
||||
client/options/Options.cpp
|
||||
client/renderer/LevelRenderer.cpp
|
||||
client/renderer/Culler.cpp
|
||||
client/renderer/entity/TntRenderer.cpp
|
||||
client/renderer/entity/MobRenderer.cpp
|
||||
client/renderer/entity/FallingTileRenderer.cpp
|
||||
client/renderer/entity/EntityRenderer.cpp
|
||||
client/renderer/entity/ItemRenderer.cpp
|
||||
client/renderer/entity/TripodCameraRenderer.cpp
|
||||
client/renderer/entity/ItemSpriteRenderer.cpp
|
||||
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/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/ChickenRenderer.cpp
|
||||
client/renderer/entity/RocketRenderer.cpp
|
||||
client/renderer/RenderList.cpp
|
||||
client/renderer/Chunk.cpp
|
||||
client/renderer/RenderChunk.cpp
|
||||
client/renderer/Frustum.cpp
|
||||
client/renderer/ItemInHandRenderer.cpp
|
||||
client/renderer/DynamicTexture.cpp
|
||||
client/renderer/GameRenderer.cpp
|
||||
client/renderer/Textures.cpp
|
||||
client/renderer/FrustumCuller.cpp
|
||||
client/renderer/LightUpdate.cpp
|
||||
client/renderer/Font.cpp
|
||||
client/renderer/WaterSideTexture.cpp
|
||||
client/renderer/Tesselator.cpp
|
||||
client/renderer/TileRenderer.cpp
|
||||
client/renderer/LightLayer.cpp
|
||||
client/renderer/WaterTexture.cpp
|
||||
client/renderer/PatchManager.cpp
|
||||
client/renderer/LavaTexture.cpp
|
||||
client/renderer/LavaSideTexture.cpp
|
||||
client/renderer/FireTexture.cpp
|
||||
client/renderer/FoliageColor.cpp
|
||||
client/renderer/GrassColor.cpp
|
||||
client/sound/SoundData.cpp
|
||||
client/sound/SoundSystem.cpp
|
||||
client/sound/SoundRepository.cpp
|
||||
client/sound/SoundEngine.cpp
|
||||
client/gui/Screen.cpp
|
||||
client/gui/screens/OptionsScreen.cpp
|
||||
client/gui/screens/StartMenuScreen.cpp
|
||||
client/gui/screens/CreateWorldScreen.cpp
|
||||
client/gui/screens/DirectConnectScreen.cpp
|
||||
client/gui/screens/SelectWorldScreen.cpp
|
||||
client/gui/screens/SavingWorldScreen.cpp
|
||||
client/gui/screens/InvalidLicenseScreen.cpp
|
||||
client/gui/screens/ConfirmScreen.cpp
|
||||
client/gui/screens/DeleteWorldScreen.cpp
|
||||
client/gui/screens/DeathScreen.cpp
|
||||
client/gui/screens/ChatScreen.cpp
|
||||
client/gui/screens/RenameMPLevelScreen.cpp
|
||||
client/gui/screens/ProgressScreen.cpp
|
||||
client/gui/screens/JoinGameScreen.cpp
|
||||
client/gui/screens/IngameBlockSelectionScreen.cpp
|
||||
client/gui/screens/PauseScreen.cpp
|
||||
client/gui/screens/DeathScreen.cpp
|
||||
client/gui/components/ScrolledSelectionList.cpp
|
||||
client/gui/components/AvailableGamesList.cpp
|
||||
client/gui/components/RolledSelectionList.cpp
|
||||
client/gui/components/Button.cpp
|
||||
client/gui/components/TextInputBox.cpp
|
||||
client/gui/components/SmallButton.cpp
|
||||
client/gui/components/WorldSelectionList.cpp
|
||||
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/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/player/input/ControllerTurnInput.cpp
|
||||
client/player/input/Controller.cpp
|
||||
client/player/input/Mouse.cpp
|
||||
client/player/input/Keyboard.cpp
|
||||
client/player/input/MouseTurnInput.cpp
|
||||
client/player/input/KeyboardInput.cpp
|
||||
client/player/input/ITurnInput.cpp
|
||||
client/player/input/IBuildInput.cpp
|
||||
client/player/input/IncludeExcludeArea.cpp
|
||||
client/player/input/MouseHandler.cpp
|
||||
client/player/input/PolygonArea.cpp
|
||||
client/player/input/RectangleArea.cpp
|
||||
client/player/input/MouseDevice.cpp
|
||||
client/player/input/Multitouch.cpp
|
||||
client/player/input/CustomInputHolder.cpp
|
||||
client/player/input/IInputHolder.cpp
|
||||
client/player/input/IMoveInput.cpp
|
||||
client/player/input/ITouchScreenModel.cpp
|
||||
client/player/input/TouchAreaModel.cpp
|
||||
client/player/input/TouchInputHolder.cpp
|
||||
client/player/input/TouchscreenInput_TestFps.cpp
|
||||
client/player/input/UnifiedTurnBuild.cpp
|
||||
client/network/ClientSideNetworkHandler.cpp
|
||||
network/packets/UpdateBlockPacket.cpp
|
||||
network/packets/RequestChunkPacket.cpp
|
||||
network/packets/PlayerEquipmentPacket.cpp
|
||||
network/packets/ChunkDataPacket.cpp
|
||||
network/packets/LevelDataPacket.cpp
|
||||
network/packets/PlaceBlockPacket.cpp
|
||||
network/packets/LoginPacket.cpp
|
||||
network/packets/StartGamePacket.cpp
|
||||
network/packets/RemoveEntityPacket.cpp
|
||||
network/packets/AddPlayerPacket.cpp
|
||||
network/packets/RemoveBlockPacket.cpp
|
||||
network/packets/MovePlayerPacket.cpp
|
||||
network/packets/MessagePacket.cpp
|
||||
network/ServerSideNetworkHandler.cpp
|
||||
network/RakNetInstance.cpp
|
||||
network/MinecraftPackets.cpp
|
||||
network/NetEventCallback.cpp
|
||||
world/level/levelgen/synth/Synth.cpp
|
||||
world/level/levelgen/synth/ImprovedNoise.cpp
|
||||
world/level/levelgen/synth/PerlinNoise.cpp
|
||||
world/level/path/Node.cpp
|
||||
world/level/path/Path.cpp
|
||||
world/level/path/BinaryHeap.cpp
|
||||
world/level/path/PathFinder.cpp
|
||||
world/phys/HitResult.cpp
|
||||
world/phys/Vec3.cpp
|
||||
world/phys/AABB.cpp
|
||||
world/gamemode/SurvivalMode.cpp
|
||||
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
|
||||
world/entity/FallingTile.cpp
|
||||
world/entity/TripodCamera.cpp
|
||||
world/entity/ItemEntity.cpp
|
||||
world/entity/PathfinderMob.cpp
|
||||
world/entity/Animal.cpp
|
||||
world/entity/WaterAnimal.cpp
|
||||
world/entity/Monster.cpp
|
||||
world/entity/Rocket.cpp
|
||||
world/level/Dimension.cpp
|
||||
world/level/Material.cpp
|
||||
world/level/LevelListener.cpp
|
||||
world/level/TickNextTickData.cpp
|
||||
world/level/Explosion.cpp
|
||||
world/level/storage/LevelStorageSource.cpp
|
||||
world/level/storage/MemoryLevelStorageSource.cpp
|
||||
world/level/storage/LevelData.cpp
|
||||
world/level/storage/ExternalFileLevelStorage.cpp
|
||||
world/level/storage/RegionFile.cpp
|
||||
world/level/storage/LevelStorage.cpp
|
||||
world/level/storage/MemoryLevelStorage.cpp
|
||||
world/level/storage/ChunkStorage.cpp
|
||||
world/level/storage/LevelSource.cpp
|
||||
world/level/storage/MemoryChunkStorage.cpp
|
||||
world/level/storage/ExternalFileLevelStorageSource.cpp
|
||||
world/level/path/Node.cpp
|
||||
world/level/path/Path.cpp
|
||||
world/level/path/PathFinder.cpp
|
||||
world/level/path/BinaryHeap.cpp
|
||||
world/level/levelgen/feature/BirchFeature.cpp
|
||||
world/level/levelgen/feature/LargeFeature.cpp
|
||||
world/level/levelgen/feature/Feature.cpp
|
||||
world/level/levelgen/feature/LargeCaveFeature.cpp
|
||||
world/level/levelgen/feature/SpringFeature.cpp
|
||||
world/level/levelgen/feature/TreeFeature.cpp
|
||||
world/level/levelgen/feature/PineFeature.cpp
|
||||
world/level/levelgen/feature/ReedsFeature.cpp
|
||||
world/level/levelgen/feature/OreFeature.cpp
|
||||
world/level/levelgen/feature/ClayFeature.cpp
|
||||
world/level/levelgen/feature/FlowerFeature.cpp
|
||||
world/level/levelgen/feature/SpruceFeature.cpp
|
||||
world/level/levelgen/biome/Biome.cpp
|
||||
world/level/levelgen/biome/BiomeSource.cpp
|
||||
world/level/levelgen/chunk/RandomLevelSource.cpp
|
||||
world/level/levelgen/chunk/LevelChunk.cpp
|
||||
world/level/levelgen/chunk/ChunkCache.cpp
|
||||
world/level/levelgen/chunk/ChunkSource.cpp
|
||||
world/level/levelgen/chunk/PerformanceTestChunkSource.cpp
|
||||
world/level/levelgen/chunk/TestChunkSource.cpp
|
||||
world/level/Level.cpp
|
||||
world/level/Region.cpp
|
||||
world/item/TilePlanterItem.cpp
|
||||
world/item/CameraItem.cpp
|
||||
world/item/TileItem.cpp
|
||||
world/item/Inventory.cpp
|
||||
world/item/DoorItem.cpp
|
||||
world/item/ItemInstance.cpp
|
||||
world/item/RocketItem.cpp
|
||||
world/item/Item.cpp
|
||||
world/particle/RedDustParticle.cpp
|
||||
world/particle/TerrainParticle.cpp
|
||||
world/particle/BubbleParticle.cpp
|
||||
world/particle/ExplodeParticle.cpp
|
||||
world/particle/ParticleEngine.cpp
|
||||
world/particle/FlameParticle.cpp
|
||||
world/particle/SmokeParticle.cpp
|
||||
world/particle/Particle.cpp
|
||||
world/particle/LavaParticle.cpp
|
||||
world/particle/FireworkParticle.cpp
|
||||
world/tile/InvisibleTile.cpp
|
||||
world/tile/Sapling.cpp
|
||||
world/tile/TreeTile.cpp
|
||||
world/tile/GrassTile.cpp
|
||||
world/tile/HalfTransparentTile.cpp
|
||||
world/tile/ClothTile.cpp
|
||||
world/tile/TorchTile.cpp
|
||||
world/tile/MetalTile.cpp
|
||||
world/tile/SpongeTile.cpp
|
||||
world/tile/GlassTile.cpp
|
||||
world/tile/SandTile.cpp
|
||||
world/tile/Tile.cpp
|
||||
world/tile/ClayTile.cpp
|
||||
world/tile/StoneTile.cpp
|
||||
world/tile/LadderTile.cpp
|
||||
world/tile/IceTile.cpp
|
||||
world/tile/TopSnowTile.cpp
|
||||
world/tile/ReedTile.cpp
|
||||
world/tile/Bush.cpp
|
||||
world/tile/RedStoneOreTile.cpp
|
||||
world/tile/DirtTile.cpp
|
||||
world/tile/LiquidTileStatic.cpp
|
||||
world/tile/BookshelfTile.cpp
|
||||
world/tile/TntTile.cpp
|
||||
world/tile/OreTile.cpp
|
||||
world/tile/StairTile.cpp
|
||||
world/tile/SandStoneTile.cpp
|
||||
world/tile/FireTile.cpp
|
||||
world/tile/StoneSlabTile.cpp
|
||||
world/tile/LiquidTile.cpp
|
||||
world/tile/GravelTile.cpp
|
||||
world/tile/LiquidTileDynamic.cpp
|
||||
world/tile/TransparentTile.cpp
|
||||
world/tile/LeafTile.cpp
|
||||
world/tile/ObsidianTile.cpp
|
||||
world/tile/FarmTile.cpp
|
||||
world/tile/DoorTile.cpp
|
||||
world/tile/RocketLauncherTile.cpp
|
||||
renderer/GL/GL.cpp
|
||||
add_subdirectory(common)
|
||||
add_subdirectory(network)
|
||||
add_subdirectory(server)
|
||||
add_subdirectory(world)
|
||||
|
||||
add_library(Core INTERFACE)
|
||||
target_include_directories(Core INTERFACE . ..)
|
||||
|
||||
target_link_libraries(Core INTERFACE
|
||||
Common
|
||||
Renderer
|
||||
Network
|
||||
Server
|
||||
World
|
||||
)
|
||||
target_include_directories(reminecraftpe-core PUBLIC . ..)
|
||||
|
||||
# RakNet
|
||||
add_subdirectory(../thirdparty/raknet raknet)
|
||||
target_link_libraries(reminecraftpe-core PUBLIC raknet)
|
||||
|
||||
# zlib
|
||||
add_library(zlib INTERFACE)
|
||||
if(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}")
|
||||
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::OpenGL)
|
||||
endif()
|
||||
elseif(USE_NATIVE_ANDROID)
|
||||
# OpenGL
|
||||
target_link_libraries(reminecraftpe-core PUBLIC EGL GLESv1_CM)
|
||||
if (NOT platform STREQUAL server)
|
||||
add_subdirectory(client)
|
||||
add_subdirectory(renderer)
|
||||
target_link_libraries(Core INTERFACE Client)
|
||||
endif()
|
||||
|
||||
# Android Logging
|
||||
if(ANDROID)
|
||||
target_link_libraries(reminecraftpe-core PUBLIC log)
|
||||
endif()
|
||||
|
||||
# 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)
|
||||
# Assets
|
||||
if (NOT ANDROID AND NOT EMSCRIPTEN)
|
||||
file(MAKE_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
|
||||
file(CREATE_LINK "${CMAKE_CURRENT_SOURCE_DIR}/../game/assets" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/assets" SYMBOLIC)
|
||||
endif()
|
||||
|
||||
110
source/client/CMakeLists.txt
Normal file
110
source/client/CMakeLists.txt
Normal file
@@ -0,0 +1,110 @@
|
||||
add_library(Client STATIC
|
||||
app/App.cpp app/App.hpp
|
||||
app/AppPlatform.cpp app/AppPlatform.hpp
|
||||
app/Minecraft.cpp app/Minecraft.hpp
|
||||
app/NinecraftApp.cpp app/NinecraftApp.hpp
|
||||
model/ChickenModel.cpp model/ChickenModel.hpp
|
||||
model/CowModel.cpp model/CowModel.hpp
|
||||
model/CreeperModel.cpp model/CreeperModel.hpp
|
||||
model/Cube.cpp model/Cube.hpp
|
||||
model/HumanoidModel.cpp model/HumanoidModel.hpp
|
||||
model/Model.cpp model/Model.hpp
|
||||
model/ModelPart.cpp model/ModelPart.hpp
|
||||
model/PigModel.cpp model/PigModel.hpp
|
||||
model/PolygonQuad.cpp model/PolygonQuad.hpp
|
||||
model/QuadrupedModel.cpp model/QuadrupedModel.hpp
|
||||
model/SheepFurModel.cpp model/SheepFurModel.hpp
|
||||
model/SheepModel.cpp model/SheepModel.hpp
|
||||
model/SkeletonModel.cpp model/SkeletonModel.hpp
|
||||
model/SpiderModel.cpp model/SpiderModel.hpp
|
||||
model/ZombieModel.cpp model/ZombieModel.hpp
|
||||
network/ClientSideNetworkHandler.cpp network/ClientSideNetworkHandler.hpp
|
||||
player/LocalPlayer.cpp player/LocalPlayer.hpp
|
||||
player/input/Controller.cpp player/input/Controller.hpp
|
||||
player/input/ControllerTurnInput.cpp player/input/ControllerTurnInput.hpp
|
||||
player/input/CustomInputHolder.cpp player/input/CustomInputHolder.hpp
|
||||
player/input/IBuildInput.cpp player/input/IBuildInput.hpp
|
||||
player/input/IInputHolder.cpp player/input/IInputHolder.hpp
|
||||
player/input/IMoveInput.cpp player/input/IMoveInput.hpp
|
||||
player/input/ITouchScreenModel.cpp player/input/ITouchScreenModel.hpp
|
||||
player/input/ITurnInput.cpp player/input/ITurnInput.hpp
|
||||
player/input/IncludeExcludeArea.cpp player/input/IncludeExcludeArea.hpp
|
||||
player/input/Keyboard.cpp player/input/Keyboard.hpp
|
||||
player/input/KeyboardInput.cpp player/input/KeyboardInput.hpp
|
||||
player/input/Mouse.cpp player/input/Mouse.hpp
|
||||
player/input/MouseDevice.cpp player/input/MouseDevice.hpp
|
||||
player/input/MouseHandler.cpp player/input/MouseHandler.hpp
|
||||
player/input/MouseTurnInput.cpp player/input/MouseTurnInput.hpp
|
||||
player/input/Multitouch.cpp player/input/Multitouch.hpp
|
||||
player/input/PolygonArea.cpp player/input/PolygonArea.hpp
|
||||
player/input/RectangleArea.cpp player/input/RectangleArea.hpp
|
||||
player/input/TouchAreaModel.cpp player/input/TouchAreaModel.hpp
|
||||
player/input/TouchInputHolder.cpp player/input/TouchInputHolder.hpp
|
||||
player/input/TouchscreenInput_TestFps.cpp player/input/TouchscreenInput_TestFps.hpp
|
||||
player/input/UnifiedTurnBuild.cpp player/input/UnifiedTurnBuild.hpp
|
||||
renderer/Chunk.cpp renderer/Chunk.hpp
|
||||
renderer/Culler.cpp renderer/Culler.hpp
|
||||
renderer/DynamicTexture.cpp renderer/DynamicTexture.hpp
|
||||
renderer/FireTexture.cpp
|
||||
renderer/FoliageColor.cpp renderer/FoliageColor.hpp
|
||||
renderer/Font.cpp renderer/Font.hpp
|
||||
renderer/Frustum.cpp renderer/Frustum.hpp
|
||||
renderer/FrustumCuller.cpp renderer/FrustumCuller.hpp
|
||||
renderer/GameRenderer.cpp renderer/GameRenderer.hpp
|
||||
renderer/GrassColor.cpp renderer/GrassColor.hpp
|
||||
renderer/ItemInHandRenderer.cpp renderer/ItemInHandRenderer.hpp
|
||||
renderer/LavaSideTexture.cpp
|
||||
renderer/LavaTexture.cpp
|
||||
renderer/LevelRenderer.cpp renderer/LevelRenderer.hpp
|
||||
renderer/PatchManager.cpp renderer/PatchManager.hpp
|
||||
renderer/RenderChunk.cpp renderer/RenderChunk.hpp
|
||||
renderer/RenderList.cpp renderer/RenderList.hpp
|
||||
renderer/Tesselator.cpp renderer/Tesselator.hpp
|
||||
renderer/Textures.cpp renderer/Textures.hpp
|
||||
renderer/TileRenderer.cpp renderer/TileRenderer.hpp
|
||||
renderer/WaterSideTexture.cpp
|
||||
renderer/WaterTexture.cpp
|
||||
renderer/entity/ChickenRenderer.cpp renderer/entity/ChickenRenderer.hpp
|
||||
renderer/entity/CowRenderer.cpp renderer/entity/CowRenderer.hpp
|
||||
renderer/entity/CreeperRenderer.cpp renderer/entity/CreeperRenderer.hpp
|
||||
renderer/entity/EntityRenderDispatcher.cpp renderer/entity/EntityRenderDispatcher.hpp
|
||||
renderer/entity/EntityRenderer.cpp renderer/entity/EntityRenderer.hpp
|
||||
renderer/entity/FallingTileRenderer.cpp renderer/entity/FallingTileRenderer.hpp
|
||||
renderer/entity/HumanoidMobRenderer.cpp renderer/entity/HumanoidMobRenderer.hpp
|
||||
renderer/entity/ItemRenderer.cpp renderer/entity/ItemRenderer.hpp
|
||||
renderer/entity/ItemSpriteRenderer.cpp renderer/entity/ItemSpriteRenderer.hpp
|
||||
renderer/entity/MobRenderer.cpp renderer/entity/MobRenderer.hpp
|
||||
renderer/entity/PigRenderer.cpp renderer/entity/PigRenderer.hpp
|
||||
renderer/entity/RocketRenderer.cpp renderer/entity/RocketRenderer.hpp
|
||||
renderer/entity/SheepFurRenderer.cpp renderer/entity/SheepFurRenderer.hpp
|
||||
renderer/entity/SheepRenderer.cpp renderer/entity/SheepRenderer.hpp
|
||||
renderer/entity/SkeletonRenderer.cpp renderer/entity/SkeletonRenderer.hpp
|
||||
renderer/entity/SpiderRenderer.cpp renderer/entity/SpiderRenderer.hpp
|
||||
renderer/entity/TntRenderer.cpp renderer/entity/TntRenderer.hpp
|
||||
renderer/entity/TripodCameraRenderer.cpp renderer/entity/TripodCameraRenderer.hpp
|
||||
renderer/entity/ZombieRenderer.cpp renderer/entity/ZombieRenderer.hpp
|
||||
sound/SoundData.cpp sound/SoundData.hpp
|
||||
sound/SoundEngine.cpp sound/SoundEngine.hpp
|
||||
sound/SoundRepository.cpp sound/SoundRepository.hpp
|
||||
sound/SoundSystem.cpp sound/SoundSystem.hpp
|
||||
)
|
||||
if (NEWUI)
|
||||
# NOTE: NEWUI definition is actually used only in Minecraft.cpp
|
||||
target_compile_definitions(Client PRIVATE NEWUI)
|
||||
add_subdirectory(newui)
|
||||
else()
|
||||
add_subdirectory(gui)
|
||||
endif()
|
||||
|
||||
# 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(Client PRIVATE MISSING_SOUND_DATA)
|
||||
endif()
|
||||
|
||||
target_link_libraries(Client PUBLIC
|
||||
Gui
|
||||
Renderer
|
||||
)
|
||||
@@ -37,7 +37,6 @@
|
||||
int Minecraft::width = C_DEFAULT_SCREEN_WIDTH;
|
||||
int Minecraft::height = C_DEFAULT_SCREEN_HEIGHT;
|
||||
float Minecraft::guiScaleMultiplier = 1.0f;
|
||||
bool Minecraft::useAmbientOcclusion = false;
|
||||
int Minecraft::customDebugId = 0;
|
||||
|
||||
//@HUH: For the demo, this is defined as TRUE.
|
||||
@@ -53,23 +52,19 @@ const char* Minecraft::progressMessages[] =
|
||||
};
|
||||
|
||||
Minecraft::Minecraft() :
|
||||
Server(false),
|
||||
m_gui(this)
|
||||
{
|
||||
m_options = nullptr;
|
||||
field_18 = false;
|
||||
field_288 = false;
|
||||
m_pLevelRenderer = nullptr;
|
||||
m_pGameRenderer = nullptr;
|
||||
m_pParticleEngine = nullptr;
|
||||
m_pSoundEngine = nullptr;
|
||||
m_pGameMode = nullptr;
|
||||
m_pTextures = nullptr;
|
||||
m_pFont = nullptr;
|
||||
m_pRakNetInstance = nullptr;
|
||||
m_pNetEventCallback = nullptr;
|
||||
field_2B0 = 0;
|
||||
m_pUser = nullptr;
|
||||
m_pLevel = nullptr;
|
||||
m_pLocalPlayer = nullptr;
|
||||
m_pMobPersp = nullptr; // why is there a duplicate?
|
||||
field_D0C = 0;
|
||||
@@ -224,7 +219,7 @@ bool Minecraft::isTouchscreen()
|
||||
|
||||
bool Minecraft::useSplitControls()
|
||||
{
|
||||
return !m_bIsTouchscreen || m_options->m_bSplitControls;
|
||||
return !m_bIsTouchscreen || m_pOptions->m_bSplitControls;
|
||||
}
|
||||
|
||||
void Minecraft::setGuiScaleMultiplier(float f)
|
||||
@@ -476,7 +471,14 @@ void Minecraft::tickInput()
|
||||
|
||||
if (getOptions()->isKey(KM_TOGGLE3RD, keyCode))
|
||||
{
|
||||
getOptions()->m_bThirdPerson = !getOptions()->m_bThirdPerson;
|
||||
bool thirdPerson = getOptions()->m_bThirdPerson;
|
||||
if (thirdPerson && !getOptions()->field_241)
|
||||
getOptions()->field_241 = 1;
|
||||
else
|
||||
{
|
||||
getOptions()->m_bThirdPerson = !thirdPerson;
|
||||
getOptions()->field_241 = 0;
|
||||
}
|
||||
}
|
||||
else if (getOptions()->isKey(KM_MENU_CANCEL, keyCode))
|
||||
{
|
||||
@@ -504,7 +506,6 @@ void Minecraft::tickInput()
|
||||
{
|
||||
// Toggle ambient occlusion.
|
||||
getOptions()->m_bAmbientOcclusion = !getOptions()->m_bAmbientOcclusion;
|
||||
Minecraft::useAmbientOcclusion = getOptions()->m_bAmbientOcclusion;
|
||||
m_pLevelRenderer->allChanged();
|
||||
}
|
||||
#endif
|
||||
@@ -537,9 +538,9 @@ void Minecraft::tickInput()
|
||||
|
||||
bool flag =
|
||||
// If we are mouse operated, the LMB is held down and it's not in the GUI
|
||||
((m_options->field_19 && Mouse::isButtonDown(BUTTON_LEFT) && !bIsInGUI) ||
|
||||
((m_pOptions->field_19 && Mouse::isButtonDown(BUTTON_LEFT) && !bIsInGUI) ||
|
||||
// We are instead keyboard operated, so check for the KM_DESTROY key being held down
|
||||
(!m_options->field_19 && Keyboard::isKeyDown(m_options->m_keyMappings[KM_DESTROY].value)) ||
|
||||
(!m_pOptions->field_19 && Keyboard::isKeyDown(m_pOptions->m_keyMappings[KM_DESTROY].value)) ||
|
||||
// The build action intention is a remove one
|
||||
(b && bai.isRemove()));
|
||||
|
||||
@@ -572,6 +573,11 @@ void Minecraft::handleCharInput(char chr)
|
||||
m_pScreen->charInput(chr);
|
||||
}
|
||||
|
||||
void Minecraft::addMessage(const std::string& message)
|
||||
{
|
||||
m_gui.addMessage(message);
|
||||
}
|
||||
|
||||
void Minecraft::sendMessage(const std::string& message)
|
||||
{
|
||||
if (isOnlineClient())
|
||||
@@ -580,7 +586,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!");
|
||||
addMessage("You aren't actually playing multiplayer!");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -589,7 +595,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!");
|
||||
addMessage("You aren't hosting a multiplayer server!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -644,12 +650,12 @@ void Minecraft::_reloadInput()
|
||||
|
||||
if (isTouchscreen())
|
||||
{
|
||||
m_pInputHolder = new TouchInputHolder(this, m_options);
|
||||
m_pInputHolder = new TouchInputHolder(this, m_pOptions);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pInputHolder = new CustomInputHolder(
|
||||
new KeyboardInput(m_options),
|
||||
new KeyboardInput(m_pOptions),
|
||||
#ifdef ORIGINAL_CODE
|
||||
new ControllerTurnInput,
|
||||
#else
|
||||
@@ -666,13 +672,13 @@ void Minecraft::_reloadInput()
|
||||
m_pLocalPlayer->m_pMoveInput = m_pInputHolder->getMoveInput();
|
||||
}
|
||||
|
||||
m_options->field_19 = !isTouchscreen();
|
||||
m_pOptions->field_19 = !isTouchscreen();
|
||||
}
|
||||
|
||||
void Minecraft::_levelGenerated()
|
||||
{
|
||||
if (m_pNetEventCallback)
|
||||
m_pNetEventCallback->levelGenerated(m_pLevel);
|
||||
m_pNetEventCallback->levelGenerated(m_pLevel, m_pLocalPlayer);
|
||||
}
|
||||
|
||||
void Minecraft::tick()
|
||||
@@ -796,7 +802,7 @@ void Minecraft::init()
|
||||
|
||||
m_pRakNetInstance = new RakNetInstance;
|
||||
|
||||
m_pTextures = new Textures(m_options, platform());
|
||||
m_pTextures = new Textures(m_pOptions, platform());
|
||||
m_pTextures->addDynamicTexture(new WaterTexture);
|
||||
m_pTextures->addDynamicTexture(new WaterSideTexture);
|
||||
m_pTextures->addDynamicTexture(new LavaTexture);
|
||||
@@ -804,9 +810,9 @@ void Minecraft::init()
|
||||
m_pTextures->addDynamicTexture(new FireTexture(0));
|
||||
|
||||
if (platform()->hasFileSystemAccess())
|
||||
m_options = new Options(m_externalStorageDir);
|
||||
m_pOptions = new Options(m_externalStorageDir);
|
||||
else
|
||||
m_options = new Options();
|
||||
m_pOptions = new Options();
|
||||
|
||||
_reloadInput();
|
||||
|
||||
@@ -818,7 +824,7 @@ void Minecraft::init()
|
||||
GetPatchManager()->PatchTiles();
|
||||
|
||||
m_pSoundEngine = new SoundEngine(platform()->getSoundSystem());
|
||||
m_pSoundEngine->init(m_options);
|
||||
m_pSoundEngine->init(m_pOptions);
|
||||
|
||||
m_pLevelRenderer = new LevelRenderer(this, m_pTextures);
|
||||
m_pGameRenderer = new GameRenderer(this);
|
||||
@@ -832,7 +838,7 @@ void Minecraft::init()
|
||||
#endif
|
||||
|
||||
// "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);
|
||||
m_pFont = new Font(m_pOptions, "font/default8.png", m_pTextures);
|
||||
|
||||
if (GrassColor::isAvailable())
|
||||
{
|
||||
@@ -846,14 +852,10 @@ 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);
|
||||
SAFE_DELETE(m_pSoundEngine);
|
||||
SAFE_DELETE(m_pGameMode);
|
||||
SAFE_DELETE(m_pFont);
|
||||
SAFE_DELETE(m_pTextures);
|
||||
|
||||
@@ -867,7 +869,6 @@ Minecraft::~Minecraft()
|
||||
}
|
||||
|
||||
SAFE_DELETE(m_pUser);
|
||||
SAFE_DELETE(m_pLevelStorageSource);
|
||||
SAFE_DELETE(m_pInputHolder);
|
||||
SAFE_DELETE(m_Logger);
|
||||
|
||||
@@ -1244,4 +1245,4 @@ void Minecraft::locateMultiplayer()
|
||||
m_pRakNetInstance->pingForHosts(C_DEFAULT_PORT);
|
||||
m_pNetEventCallback = new ClientSideNetworkHandler(this, m_pRakNetInstance);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "client/gui/Gui.hpp"
|
||||
#include "client/gui/Screen.hpp"
|
||||
#include "network/RakNetInstance.hpp"
|
||||
#include "network/NetEventCallback.hpp"
|
||||
#include "client/player/LocalPlayer.hpp"
|
||||
#include "client/player/input/IInputHolder.hpp"
|
||||
#include "client/player/input/MouseHandler.hpp"
|
||||
#include "client/player/input/BuildActionIntention.hpp"
|
||||
@@ -23,14 +23,14 @@
|
||||
#include "client/renderer/LevelRenderer.hpp"
|
||||
#include "client/renderer/entity/EntityRenderDispatcher.hpp"
|
||||
#include "client/sound/SoundEngine.hpp"
|
||||
#include "server/Server.hpp"
|
||||
#include "world/level/Level.hpp"
|
||||
#include "world/entity/LocalPlayer.hpp"
|
||||
#include "world/gamemode/GameMode.hpp"
|
||||
#include "world/particle/ParticleEngine.hpp"
|
||||
|
||||
class Screen; // in case we're included from Screen.hpp
|
||||
|
||||
class Minecraft : public App
|
||||
class Minecraft : public App, public Server
|
||||
{
|
||||
public:
|
||||
Minecraft();
|
||||
@@ -57,6 +57,7 @@ public:
|
||||
void locateMultiplayer();
|
||||
void tickMouse();
|
||||
void handleCharInput(char chr);
|
||||
virtual void addMessage(const std::string& message) override;
|
||||
void sendMessage(const std::string& message);
|
||||
void resetPlayer(Player* player);
|
||||
void respawnPlayer(Player* player);
|
||||
@@ -80,10 +81,9 @@ public:
|
||||
const char* getProgressMessage();
|
||||
LevelStorageSource* getLevelSource();
|
||||
ItemInstance* getSelectedItem();
|
||||
Options* getOptions() const { return m_options; }
|
||||
|
||||
static void setGuiScaleMultiplier(float f);
|
||||
|
||||
|
||||
private:
|
||||
void _reloadInput();
|
||||
void _levelGenerated();
|
||||
@@ -91,14 +91,12 @@ private:
|
||||
public:
|
||||
static float guiScaleMultiplier;
|
||||
static int width, height;
|
||||
static bool useAmbientOcclusion;
|
||||
static const char* progressMessages[];
|
||||
static const bool DEADMAU5_CAMERA_CHEATS;
|
||||
static int customDebugId;
|
||||
|
||||
private:
|
||||
Logger *m_Logger;
|
||||
Options *m_options;
|
||||
|
||||
public:
|
||||
bool field_18;
|
||||
@@ -107,16 +105,12 @@ public:
|
||||
GameRenderer* m_pGameRenderer;
|
||||
ParticleEngine* m_pParticleEngine;
|
||||
SoundEngine* m_pSoundEngine;
|
||||
GameMode* m_pGameMode;
|
||||
Textures* m_pTextures;
|
||||
Font* m_pFont;
|
||||
RakNetInstance* m_pRakNetInstance;
|
||||
NetEventCallback* m_pNetEventCallback;
|
||||
int field_2B0;
|
||||
int field_2B4;
|
||||
int field_2B8;
|
||||
User* m_pUser;
|
||||
Level* m_pLevel;
|
||||
LocalPlayer* m_pLocalPlayer;
|
||||
Mob* m_pMobPersp; // why is there a duplicate?
|
||||
Gui m_gui;
|
||||
@@ -131,9 +125,7 @@ public:
|
||||
HitResult m_hitResult;
|
||||
int m_progressPercent;
|
||||
std::string m_externalStorageDir;
|
||||
Timer m_timer;
|
||||
bool m_bPreparingLevel;
|
||||
LevelStorageSource* m_pLevelStorageSource; // TODO
|
||||
int field_D9C;
|
||||
int field_DA0;
|
||||
int field_DA4;
|
||||
|
||||
31
source/client/gui/CMakeLists.txt
Normal file
31
source/client/gui/CMakeLists.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
add_library(Gui STATIC
|
||||
Gui.cpp Gui.hpp
|
||||
GuiComponent.cpp GuiComponent.hpp
|
||||
Screen.cpp Screen.hpp
|
||||
components/AvailableGamesList.cpp components/AvailableGamesList.hpp
|
||||
components/Button.cpp components/Button.hpp
|
||||
components/OptionList.cpp components/OptionList.hpp
|
||||
components/RolledSelectionList.cpp components/RolledSelectionList.hpp
|
||||
components/ScrolledSelectionList.cpp components/ScrolledSelectionList.hpp
|
||||
components/SmallButton.cpp components/SmallButton.hpp
|
||||
components/TextInputBox.cpp components/TextInputBox.hpp
|
||||
components/WorldSelectionList.cpp components/WorldSelectionList.hpp
|
||||
screens/ChatScreen.cpp screens/ChatScreen.hpp
|
||||
screens/ConfirmScreen.cpp screens/ConfirmScreen.hpp
|
||||
screens/CreateWorldScreen.cpp screens/CreateWorldScreen.hpp
|
||||
screens/DeathScreen.cpp screens/DeathScreen.hpp
|
||||
screens/DeathScreen.cpp screens/DeathScreen.hpp
|
||||
screens/DeleteWorldScreen.cpp screens/DeleteWorldScreen.hpp
|
||||
screens/DirectConnectScreen.cpp screens/DirectConnectScreen.hpp
|
||||
screens/IngameBlockSelectionScreen.cpp screens/IngameBlockSelectionScreen.hpp
|
||||
screens/InvalidLicenseScreen.cpp screens/InvalidLicenseScreen.hpp
|
||||
screens/JoinGameScreen.cpp screens/JoinGameScreen.hpp
|
||||
screens/OptionsScreen.cpp screens/OptionsScreen.hpp
|
||||
screens/PauseScreen.cpp screens/PauseScreen.hpp
|
||||
screens/ProgressScreen.cpp screens/ProgressScreen.hpp
|
||||
screens/RenameMPLevelScreen.cpp screens/RenameMPLevelScreen.hpp
|
||||
screens/SavingWorldScreen.cpp screens/SavingWorldScreen.hpp
|
||||
screens/SelectWorldScreen.cpp screens/SelectWorldScreen.hpp
|
||||
screens/StartMenuScreen.cpp screens/StartMenuScreen.hpp
|
||||
)
|
||||
target_link_libraries(Gui PRIVATE Common Client)
|
||||
@@ -7,10 +7,10 @@
|
||||
********************************************************************/
|
||||
|
||||
#include "OptionList.hpp"
|
||||
#include "client/options/Options.hpp"
|
||||
#include "client/renderer/PatchManager.hpp"
|
||||
#include "client/renderer/FoliageColor.hpp"
|
||||
#include "client/renderer/GrassColor.hpp"
|
||||
#include "server/Options.hpp"
|
||||
|
||||
#define C_OPTION_ITEM_HEIGHT (20)
|
||||
|
||||
@@ -84,7 +84,7 @@ AORenderOptionItem::AORenderOptionItem(bool* pValue, const std::string& text) :
|
||||
void AORenderOptionItem::toggleState(OptionList* pList)
|
||||
{
|
||||
BooleanOptionItem::toggleState(pList);
|
||||
Minecraft::useAmbientOcclusion = *m_pValue;
|
||||
pList->m_pMinecraft->getOptions()->m_bAmbientOcclusion = *m_pValue;
|
||||
pList->m_pMinecraft->m_pLevelRenderer->allChanged();
|
||||
}
|
||||
|
||||
@@ -206,7 +206,6 @@ void OptionList::drawOnOffSwitch(int x, int y, bool state, bool disabled)
|
||||
|
||||
void OptionList::renderItem(int index, int x, int y, int height, Tesselator& t)
|
||||
{
|
||||
Font* f = m_pMinecraft->m_pFont;
|
||||
OptionItem* pItem = m_items[index];
|
||||
|
||||
pItem->render(this, x, y);
|
||||
@@ -321,6 +320,8 @@ void OptionList::initDefaultMenu()
|
||||
|
||||
#ifdef __EMSCRIPTEN
|
||||
m_items[idxLM]->setDisabled(true);
|
||||
#else
|
||||
(void)idxLM;
|
||||
#endif
|
||||
|
||||
if (!GetPatchManager()->IsGrassSidesTinted())
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "TextInputBox.hpp"
|
||||
#include "client/app/Minecraft.hpp"
|
||||
#include "compat/KeyCodes.hpp"
|
||||
#ifndef ORIGINAL_CODE
|
||||
|
||||
#ifdef USE_NATIVE_ANDROID
|
||||
@@ -52,9 +53,9 @@ void TextInputBox::keyPressed(Minecraft* minecraft, int key)
|
||||
if (!m_bFocused)
|
||||
return;
|
||||
|
||||
#if !defined(HANDLE_CHARS_SEPARATELY) && defined(__ANDROID__)
|
||||
bool bShiftPressed = minecraft->platform()->shiftPressed();
|
||||
|
||||
#ifndef HANDLE_CHARS_SEPARATELY
|
||||
char chr = '\0';
|
||||
if (key >= AKEYCODE_A && key <= AKEYCODE_Z)
|
||||
{
|
||||
@@ -131,6 +132,8 @@ void TextInputBox::keyPressed(Minecraft* minecraft, int key)
|
||||
#define AKEYCODE_ARROW_LEFT VK_LEFT
|
||||
#define AKEYCODE_ARROW_RIGHT VK_RIGHT
|
||||
#define AKEYCODE_DEL VK_BACK
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
|
||||
switch (key)
|
||||
|
||||
@@ -8,9 +8,10 @@
|
||||
|
||||
#include "ChatScreen.hpp"
|
||||
|
||||
// @NOTE: This is unused.
|
||||
|
||||
ChatScreen::ChatScreen(bool slash) : m_textChat(this, 1, 0, 0), m_btnSend(2, 0, 0, "Send")
|
||||
ChatScreen::ChatScreen(bool slash) :
|
||||
m_textChat(this, 1, 0, 0),
|
||||
m_btnSend(2, 0, 0, "Send"),
|
||||
m_btnBack(3, 0, 0, "Back")
|
||||
{
|
||||
if (slash)
|
||||
m_textChat.m_text = "/";
|
||||
@@ -20,24 +21,29 @@ void ChatScreen::buttonClicked(Button* pButton)
|
||||
{
|
||||
if (pButton->m_buttonId == m_btnSend.m_buttonId)
|
||||
sendMessageAndExit();
|
||||
if (pButton->m_buttonId == m_btnBack.m_buttonId)
|
||||
m_pMinecraft->setScreen(nullptr);
|
||||
}
|
||||
|
||||
void ChatScreen::init()
|
||||
{
|
||||
m_btnSend.m_height = 20;
|
||||
m_btnSend.m_width = 40;
|
||||
m_btnBack.m_height = m_btnSend.m_height = 20;
|
||||
m_btnBack.m_width = m_btnSend.m_width = 40;
|
||||
m_textChat.m_xPos = 0;
|
||||
m_textChat.m_yPos = m_height - 20;
|
||||
m_textChat.m_width = m_width - m_btnSend.m_width;
|
||||
m_textChat.m_height = 20;
|
||||
m_btnSend.m_yPos = m_height - 20;
|
||||
m_btnSend.m_xPos = m_textChat.m_xPos + m_textChat.m_width;
|
||||
m_btnBack.m_yPos = 10;
|
||||
m_btnBack.m_xPos = m_width - m_btnBack.m_width - 10;
|
||||
|
||||
// set focus directly on the chat text box
|
||||
m_textChat.init(m_pFont);
|
||||
m_textChat.setFocused(true);
|
||||
|
||||
m_buttons.push_back(&m_btnSend);
|
||||
m_buttons.push_back(&m_btnBack);
|
||||
m_textInputs.push_back(&m_textChat);
|
||||
}
|
||||
|
||||
@@ -55,6 +61,8 @@ void ChatScreen::render(int mouseX, int mouseY, float f)
|
||||
m_pMinecraft->m_gui.m_bRenderMessages = false;
|
||||
m_pMinecraft->m_gui.renderMessages(true);
|
||||
|
||||
m_btnBack.m_yPos = 10 + getYOffset();
|
||||
|
||||
Screen::render(mouseX, mouseY, f);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,5 +25,6 @@ public:
|
||||
private:
|
||||
TextInputBox m_textChat;
|
||||
Button m_btnSend;
|
||||
Button m_btnBack;
|
||||
};
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ void PauseScreen::init()
|
||||
m_btnOptions.m_yPos = currY;
|
||||
m_btnOptions.m_xPos = m_btnBack.m_xPos;
|
||||
#endif
|
||||
currY += inc;
|
||||
// currY += inc;
|
||||
|
||||
// add the buttons to the screen:
|
||||
m_buttons.push_back(&m_btnBack);
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "SelectWorldScreen.hpp"
|
||||
#include "JoinGameScreen.hpp"
|
||||
|
||||
#if defined(_WIN32) || (defined(TARGET_OS_MAC) && TARGET_OS_IPHONE == 0)
|
||||
#if defined(_WIN32) || defined(USE_SDL) && !MC_TARGET_OS_IOS && !defined(__ANDROID__)
|
||||
#define CAN_QUIT
|
||||
#endif
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
|
||||
#include <RakPeer.h>
|
||||
#include "thirdparty/raknet/RakPeer.h"
|
||||
#include "ClientSideNetworkHandler.hpp"
|
||||
#include "common/Utils.hpp"
|
||||
#include "client/gui/screens/StartMenuScreen.hpp"
|
||||
@@ -34,7 +34,7 @@ ClientSideNetworkHandler::ClientSideNetworkHandler(Minecraft* pMinecraft, RakNet
|
||||
m_field_24 = 0;
|
||||
}
|
||||
|
||||
void ClientSideNetworkHandler::levelGenerated(Level* level)
|
||||
void ClientSideNetworkHandler::levelGenerated(Level* level, LocalPlayer* pLP)
|
||||
{
|
||||
m_pLevel = level;
|
||||
requestNextChunk();
|
||||
|
||||
@@ -29,7 +29,7 @@ class ClientSideNetworkHandler : public NetEventCallback
|
||||
public:
|
||||
ClientSideNetworkHandler(Minecraft*, RakNetInstance*);
|
||||
|
||||
void levelGenerated(Level*) override;
|
||||
void levelGenerated(Level*, LocalPlayer*) override;
|
||||
void onConnect(const RakNet::RakNetGUID&) override;
|
||||
void onDisconnect(const RakNet::RakNetGUID&) override;
|
||||
void onUnableToConnect() override;
|
||||
|
||||
@@ -20,6 +20,7 @@ enum
|
||||
INPUT_RIGHT,
|
||||
INPUT_JUMP,
|
||||
INPUT_SNEAK,
|
||||
INPUT_CHAT,
|
||||
};
|
||||
|
||||
class IMoveInput
|
||||
|
||||
@@ -32,12 +32,12 @@ void KeyboardInput::setKey(int keyCode, bool b)
|
||||
{
|
||||
int index = -1;
|
||||
|
||||
if (m_pOptions->getKey(KM_FORWARD) == keyCode) index = 0;
|
||||
if (m_pOptions->getKey(KM_BACKWARD) == keyCode) index = 1;
|
||||
if (m_pOptions->getKey(KM_LEFT) == keyCode) index = 2;
|
||||
if (m_pOptions->getKey(KM_RIGHT) == keyCode) index = 3;
|
||||
if (m_pOptions->getKey(KM_JUMP) == keyCode) index = 4;
|
||||
if (m_pOptions->getKey(KM_SNEAK) == keyCode) index = 5;
|
||||
if (m_pOptions->getKey(KM_FORWARD) == keyCode) index = INPUT_FORWARD;
|
||||
if (m_pOptions->getKey(KM_BACKWARD) == keyCode) index = INPUT_BACKWARD;
|
||||
if (m_pOptions->getKey(KM_LEFT) == keyCode) index = INPUT_LEFT;
|
||||
if (m_pOptions->getKey(KM_RIGHT) == keyCode) index = INPUT_RIGHT;
|
||||
if (m_pOptions->getKey(KM_JUMP) == keyCode) index = INPUT_JUMP;
|
||||
if (m_pOptions->getKey(KM_SNEAK) == keyCode) index = INPUT_SNEAK;
|
||||
|
||||
if (index == -1)
|
||||
return;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "IMoveInput.hpp"
|
||||
|
||||
#include "client/options/Options.hpp"
|
||||
#include "server/Options.hpp"
|
||||
|
||||
class KeyboardInput : public IMoveInput
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "TouchInputHolder.hpp"
|
||||
#include "Multitouch.hpp"
|
||||
#include "client/app/Minecraft.hpp"
|
||||
#include "client/options/Options.hpp"
|
||||
#include "server/Options.hpp"
|
||||
|
||||
TouchInputHolder::TouchInputHolder(Minecraft* pMinecraft, Options* pOptions) :
|
||||
m_touchScreenInput(pMinecraft, pOptions),
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
#include "TouchscreenInput_TestFps.hpp"
|
||||
#include "Multitouch.hpp"
|
||||
#include "client/app/Minecraft.hpp"
|
||||
#include "client/options/Options.hpp"
|
||||
#include "client/gui/screens/ChatScreen.hpp"
|
||||
#include "server/Options.hpp"
|
||||
#include "world/entity/Player.hpp"
|
||||
|
||||
TouchscreenInput_TestFps::TouchscreenInput_TestFps(Minecraft* pMinecraft, Options* pOptions) :
|
||||
@@ -22,7 +23,8 @@ TouchscreenInput_TestFps::TouchscreenInput_TestFps(Minecraft* pMinecraft, Option
|
||||
m_pAreaRight(nullptr),
|
||||
m_pAreaForward(nullptr),
|
||||
m_pAreaBackward(nullptr),
|
||||
m_pAreaJump(nullptr)
|
||||
m_pAreaJump(nullptr),
|
||||
m_pAreaChat(nullptr)
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
field_30[i] = 0;
|
||||
@@ -38,7 +40,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 < 7; i++)
|
||||
field_6C[i] = false;
|
||||
}
|
||||
|
||||
@@ -55,15 +57,6 @@ static void CopyCoordinateArray(int count, float* xs, float* ys, float* xd, floa
|
||||
}
|
||||
}
|
||||
|
||||
static void MultiplyCoordinateArray(int count, float* x, float* y, float xm, float ym)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
x[i] *= xm;
|
||||
y[i] *= ym;
|
||||
}
|
||||
}
|
||||
|
||||
static void AddCoordinateArray(int count, float* x, float* y, float xd, float yd)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
@@ -73,10 +66,9 @@ static void AddCoordinateArray(int count, float* x, float* y, float xd, float yd
|
||||
}
|
||||
}
|
||||
|
||||
static void TransformArray(int count, float* x1, float* y1, float* x2, float* y2, float xd, float yd, float xm, float ym)
|
||||
static void TransformArray(int count, float* x1, float* y1, float* x2, float* y2, float xd, float yd)
|
||||
{
|
||||
CopyCoordinateArray(count, x1, y1, x2, y2);
|
||||
MultiplyCoordinateArray(count, x2, y2, xm, ym);
|
||||
AddCoordinateArray(count, x2, y2, xd, yd);
|
||||
}
|
||||
|
||||
@@ -106,26 +98,34 @@ void TouchscreenInput_TestFps::setScreenSize(int width, int height)
|
||||
float middleX = offX + widthM;
|
||||
float middleY = ry1 + heightM;
|
||||
|
||||
TransformArray(4, x1, y1, x2, y2, middleX, middleY - heightM, 1.0f, 1.0f);
|
||||
TransformArray(4, x1, y1, x2, y2, middleX, middleY - heightM);
|
||||
m_pAreaForward = new PolygonArea(4, x2, y2);
|
||||
m_touchAreaModel.addArea(100 + INPUT_FORWARD, m_pAreaForward);
|
||||
|
||||
TransformArray(4, x1, y1, x2, y2, middleX, middleY, 1.0f, 1.0f);
|
||||
TransformArray(4, x1, y1, x2, y2, middleX, middleY);
|
||||
m_pAreaJump = new PolygonArea(4, x2, y2);
|
||||
m_touchAreaModel.addArea(100 + INPUT_JUMP, m_pAreaJump);
|
||||
|
||||
TransformArray(4, x1, y1, x2, y2, middleX, middleY + heightM, 1.0f, 1.0f);
|
||||
TransformArray(4, x1, y1, x2, y2, middleX, middleY + heightM);
|
||||
m_pAreaBackward = new PolygonArea(4, x2, y2);
|
||||
m_touchAreaModel.addArea(100 + INPUT_BACKWARD, m_pAreaBackward);
|
||||
|
||||
TransformArray(4, x1, y1, x2, y2, middleX - widthM, ry1 + heightM, 1.0f, 1.0f);
|
||||
TransformArray(4, x1, y1, x2, y2, middleX - widthM, ry1 + heightM);
|
||||
m_pAreaLeft = new PolygonArea(4, x2, y2);
|
||||
m_touchAreaModel.addArea(100 + INPUT_LEFT, m_pAreaLeft);
|
||||
|
||||
TransformArray(4, x1, y1, x2, y2, middleX + widthM, ry1 + heightM, 1.0f, 1.0f);
|
||||
TransformArray(4, x1, y1, x2, y2, middleX + widthM, ry1 + heightM);
|
||||
m_pAreaRight = new PolygonArea(4, x2, y2);
|
||||
m_touchAreaModel.addArea(100 + INPUT_RIGHT, m_pAreaRight);
|
||||
|
||||
float scale = Gui::InvGuiScale;
|
||||
|
||||
x1[1] = x1[2] = 16.0f / scale;
|
||||
y1[2] = y1[3] = 16.0f / scale;
|
||||
TransformArray(4, x1, y1, x2, y2, width - 17.0f / scale, 1.0f / scale);
|
||||
m_pAreaChat = new PolygonArea(4, x2, y2);
|
||||
m_touchAreaModel.addArea(100 + INPUT_CHAT, m_pAreaChat);
|
||||
|
||||
// NOTE: We are not leaking memory! Since by default IArea's constructor sets
|
||||
// field_4 to true, TouchAreaModel owns the pointers, so when it's destroyed,
|
||||
// so are these areas we allocated.
|
||||
@@ -137,7 +137,7 @@ void TouchscreenInput_TestFps::tick(Player* pPlayer)
|
||||
m_vertInput = 0.0f;
|
||||
m_bJumpButton = false;
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
for (int i = 0; i < 7; i++)
|
||||
field_6C[i] = false;
|
||||
|
||||
const int* activePointers;
|
||||
@@ -201,6 +201,11 @@ void TouchscreenInput_TestFps::tick(Player* pPlayer)
|
||||
case 100 + INPUT_RIGHT:
|
||||
m_horzInput -= 1.0f;
|
||||
break;
|
||||
|
||||
case 100 + INPUT_CHAT:
|
||||
if (!m_pMinecraft->m_pScreen && Multitouch::isPressed(finger))
|
||||
m_pMinecraft->setScreen(new ChatScreen());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,16 +226,16 @@ void TouchscreenInput_TestFps::tick(Player* pPlayer)
|
||||
}
|
||||
}
|
||||
|
||||
static void RenderTouchButton(Tesselator* t, PolygonArea* pArea, int srcX, int srcY)
|
||||
static void RenderTouchButton(Tesselator* t, PolygonArea* pArea, int srcX, int srcY, float srcW, float srcH)
|
||||
{
|
||||
float tc[8];
|
||||
|
||||
tc[0] = float(srcX) / 256.0f;
|
||||
tc[1] = float(srcY) / 256.0f;
|
||||
tc[2] = tc[0] + 64.0f / 256.0f;
|
||||
tc[2] = tc[0] + srcW / 256.0f;
|
||||
tc[3] = tc[1];
|
||||
tc[4] = tc[2];
|
||||
tc[5] = tc[1] + 64.0f / 256.0f;
|
||||
tc[5] = tc[1] + srcH / 256.0f;
|
||||
tc[6] = tc[0];
|
||||
tc[7] = tc[5];
|
||||
|
||||
@@ -258,19 +263,30 @@ void TouchscreenInput_TestFps::render(float f)
|
||||
t.begin();
|
||||
|
||||
t.color(isButtonDown(100 + INPUT_LEFT) ? 0xC0C0C0 : 0xFFFFFF, 0x80);
|
||||
RenderTouchButton(&t, m_pAreaLeft, 64, 112);
|
||||
RenderTouchButton(&t, m_pAreaLeft, 64, 112, 64, 64);
|
||||
|
||||
t.color(isButtonDown(100 + INPUT_RIGHT) ? 0xC0C0C0 : 0xFFFFFF, 0x80);
|
||||
RenderTouchButton(&t, m_pAreaRight, 192, 112);
|
||||
RenderTouchButton(&t, m_pAreaRight, 192, 112, 64, 64);
|
||||
|
||||
t.color(isButtonDown(100 + INPUT_FORWARD) ? 0xC0C0C0 : 0xFFFFFF, 0x80);
|
||||
RenderTouchButton(&t, m_pAreaForward, 0, 112);
|
||||
RenderTouchButton(&t, m_pAreaForward, 0, 112, 64, 64);
|
||||
|
||||
t.color(isButtonDown(100 + INPUT_BACKWARD) ? 0xC0C0C0 : 0xFFFFFF, 0x80);
|
||||
RenderTouchButton(&t, m_pAreaBackward, 128, 112);
|
||||
RenderTouchButton(&t, m_pAreaBackward, 128, 112, 64, 64);
|
||||
|
||||
t.color(isButtonDown(100 + INPUT_JUMP) ? 0xC0C0C0 : 0xFFFFFF, 0x80);
|
||||
RenderTouchButton(&t, m_pAreaJump, 0, 176);
|
||||
RenderTouchButton(&t, m_pAreaJump, 0, 176, 64, 64);
|
||||
|
||||
t.draw();
|
||||
|
||||
t.begin();
|
||||
t.color(0xFFFFFF, 0x80);
|
||||
m_pMinecraft->m_pTextures->loadAndBindTexture("gui/gui_custom.png");
|
||||
|
||||
int srcX = 32;
|
||||
if (isButtonDown(100 + INPUT_CHAT))
|
||||
srcX += 18;
|
||||
RenderTouchButton(&t, m_pAreaChat, srcX, 18, 18, 18);
|
||||
|
||||
t.draw();
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ private:
|
||||
PolygonArea* m_pAreaForward;
|
||||
PolygonArea* m_pAreaBackward;
|
||||
PolygonArea* m_pAreaJump;
|
||||
PolygonArea* m_pAreaChat;
|
||||
bool field_6C[8];
|
||||
};
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ UnifiedTurnBuild::UnifiedTurnBuild(int a, int width, int height, float d, float
|
||||
{
|
||||
m_includeExcludeArea.field_4 = false;
|
||||
|
||||
setScreenSize(width, height);
|
||||
UnifiedTurnBuild::setScreenSize(width, height);
|
||||
field_B8 = getTimeS();
|
||||
field_CC = field_B8;
|
||||
field_D0 = 0;
|
||||
@@ -70,7 +70,7 @@ TurnDelta UnifiedTurnBuild::getTurnDelta()
|
||||
int finger = activePtrs[i];
|
||||
int x = Multitouch::getX(finger);
|
||||
int y = Multitouch::getY(finger);
|
||||
if (m_touchAreaModel.getPointerId(x, y, finger) == 100)
|
||||
if (m_touchAreaModel.getPointerId(x, y, finger) == 100 + INPUT_FORWARD)
|
||||
{
|
||||
touched = true;
|
||||
m1 = float(x) * 0.5f;
|
||||
@@ -202,7 +202,7 @@ bool UnifiedTurnBuild::tickBuild(Player* pPlayer, BuildActionIntention* pIntenti
|
||||
{
|
||||
int finger = m_touchAreaModel.getPointerId(pEvent->_posX, pEvent->_posY, pEvent->_fingerId);
|
||||
|
||||
if (finger == 100)
|
||||
if (finger == 100 + INPUT_FORWARD)
|
||||
{
|
||||
if (field_BC > 20.0f || pEvent->_buttonState || wroteIntention)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Textures.hpp"
|
||||
#include "client/options/Options.hpp"
|
||||
#include "server/Options.hpp"
|
||||
|
||||
class Font
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
********************************************************************/
|
||||
|
||||
#include "Frustum.hpp"
|
||||
#include "thirdparty/GL/GL.hpp"
|
||||
|
||||
Frustum Frustum::frustum;
|
||||
|
||||
@@ -14,8 +15,8 @@ void Frustum::doOurJobInGameRenderer()
|
||||
{
|
||||
Frustum& f = Frustum::frustum;
|
||||
|
||||
f.m[16].fetchGL(GL_PROJECTION_MATRIX);
|
||||
f.m[17].fetchGL(GL_MODELVIEW_MATRIX);
|
||||
glGetFloatv(GL_PROJECTION_MATRIX, f.m[16].c);
|
||||
glGetFloatv(GL_MODELVIEW_MATRIX, f.m[17].c);
|
||||
|
||||
f.m[18] = f.m[17] * f.m[16];
|
||||
|
||||
|
||||
@@ -138,6 +138,7 @@ void GameRenderer::moveCameraToPlayer(float f)
|
||||
if (m_pMinecraft->getOptions()->m_bThirdPerson)
|
||||
{
|
||||
float v11 = field_30 + (field_2C - field_30) * f;
|
||||
#if 0
|
||||
if (m_pMinecraft->getOptions()->field_241)
|
||||
{
|
||||
glTranslatef(0.0f, 0.0f, -v11);
|
||||
@@ -145,6 +146,7 @@ void GameRenderer::moveCameraToPlayer(float f)
|
||||
glRotatef(field_40 + (field_3C - field_40) * f, 0.0f, 1.0f, 0.0f);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
float mob_yaw = pMob->m_yaw;
|
||||
float mob_pitch = pMob->m_pitch;
|
||||
@@ -195,6 +197,11 @@ void GameRenderer::moveCameraToPlayer(float f)
|
||||
glRotatef(pMob->field_60 + f * (pMob->m_pitch - pMob->field_60), 1.0f, 0.0f, 0.0f);
|
||||
glRotatef(pMob->field_5C + f * (pMob->m_yaw - pMob->field_5C) + 180.0f, 0.0f, 1.0f, 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
glRotatef(pMob->field_60, -1.0f, 0.0f, 0.0f);
|
||||
glRotatef(pMob->field_5C, 0.0f, 1.0f, 0.0f);
|
||||
}
|
||||
|
||||
glTranslatef(0.0f, headHeightDiff, 0.0f);
|
||||
}
|
||||
@@ -670,12 +677,13 @@ void GameRenderer::render(float f)
|
||||
}
|
||||
}
|
||||
|
||||
std::stringstream debugText;
|
||||
debugText << "ReMinecraftPE " << m_pMinecraft->getVersionString();
|
||||
debugText << "\n" << m_shownFPS << " fps, " << m_shownChunkUpdates << " chunk updates";
|
||||
|
||||
if (m_pMinecraft->getOptions()->m_bDebugText)
|
||||
{
|
||||
std::stringstream debugText;
|
||||
std::stringstream debugTextRight;
|
||||
debugText << "ReMinecraftPE " << m_pMinecraft->getVersionString();
|
||||
debugText << "\n" << m_shownFPS << " fps, " << m_shownChunkUpdates << " chunk updates";
|
||||
|
||||
if (m_pMinecraft->m_pLocalPlayer)
|
||||
{
|
||||
char posStr[96];
|
||||
@@ -685,9 +693,24 @@ void GameRenderer::render(float f)
|
||||
debugText << "\npos: " << posStr;
|
||||
debugText << "\nentities: " << m_pMinecraft->m_pLevel->m_entities.size();
|
||||
debugText << "\n" << m_pMinecraft->m_pLevelRenderer->gatherStats1();
|
||||
|
||||
HitResult& hr = m_pMinecraft->m_hitResult;
|
||||
if (hr.m_hitType != HitResult::NONE) {
|
||||
sprintf(posStr, "%d, %d, %d", hr.m_tileX, hr.m_tileY, hr.m_tileZ);
|
||||
debugTextRight << "Looking at: " << posStr;
|
||||
Tile *pTile = nullptr;
|
||||
TileID tile = m_pMinecraft->m_pLevel->getTile(hr.m_tileX, hr.m_tileY, hr.m_tileZ);
|
||||
if (tile > 0) {
|
||||
pTile = Tile::tiles[tile];
|
||||
debugTextRight << "\nTile: " << std::to_string(tile) <<" "<< pTile->m_descriptionID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int screenWidth = Gui::InvGuiScale * Minecraft::width;
|
||||
int textWidth = m_pMinecraft->m_pFont->width(debugTextRight.str());
|
||||
m_pMinecraft->m_pFont->drawShadow(debugText.str(), 2, 2, 0xFFFFFF);
|
||||
m_pMinecraft->m_pFont->drawShadow(debugTextRight.str(), screenWidth - textWidth - 2, 2, 0xFFFFFF);
|
||||
}
|
||||
|
||||
int timeMs = getTimeMs();
|
||||
|
||||
@@ -141,6 +141,7 @@ void LevelRenderer::allChanged()
|
||||
|
||||
TileRenderer::m_bFancyGrass = m_pMinecraft->getOptions()->m_bFancyGrass;
|
||||
TileRenderer::m_bBiomeColors = m_pMinecraft->getOptions()->m_bBiomeColors;
|
||||
TileRenderer::m_bUseAmbientOcclusion = m_pMinecraft->getOptions()->m_bAmbientOcclusion;
|
||||
|
||||
field_BC = m_pMinecraft->getOptions()->m_iViewDistance;
|
||||
|
||||
@@ -765,10 +766,10 @@ bool LevelRenderer::updateDirtyChunks(Mob* pMob, bool b)
|
||||
ChunkVector* v40; // r0
|
||||
Chunk* v42[3]; // [sp+1Ch] [bp+0h] BYREF
|
||||
Chunk* a3; // [sp+28h] [bp+Ch] BYREF
|
||||
Entity* pMob_1; // [sp+2Ch] [bp+10h] BYREF
|
||||
// Entity* pMob_1; // [sp+2Ch] [bp+10h] BYREF
|
||||
|
||||
v3 = 0;
|
||||
pMob_1 = pMob;
|
||||
// pMob_1 = pMob; // lol it's unused
|
||||
DirtyChunkSorter dcs(pMob);
|
||||
memset(v42, 0, sizeof v42);
|
||||
field_88_Beg = this->field_88.begin();
|
||||
|
||||
@@ -19,11 +19,17 @@ int Textures::loadTexture(const std::string& name, bool bIsRequired)
|
||||
|
||||
Texture t = m_pPlatform->loadTexture(name, bIsRequired);
|
||||
|
||||
int result = -1;
|
||||
if (t.m_pixels)
|
||||
result = assignTexture(name, t);
|
||||
|
||||
return result;
|
||||
if (!t.m_pixels)
|
||||
{
|
||||
t.field_C = 1;
|
||||
t.field_D = 0;
|
||||
t.m_width = 2;
|
||||
t.m_height = 2;
|
||||
t.m_pixels = new uint32_t[t.m_width * t.m_height];
|
||||
t.m_pixels[0] = t.m_pixels[2] = 0xfff800f8;
|
||||
t.m_pixels[1] = t.m_pixels[3] = 0xff000000;
|
||||
}
|
||||
return assignTexture(name, t);
|
||||
}
|
||||
|
||||
int Textures::assignTexture(const std::string& name, Texture& texture)
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#include <map>
|
||||
|
||||
#include "thirdparty/GL/GL.hpp"
|
||||
#include "client/options/Options.hpp"
|
||||
#include "client/app/AppPlatform.hpp"
|
||||
#include "server/Options.hpp"
|
||||
#include "DynamicTexture.hpp"
|
||||
|
||||
class DynamicTexture; // in case we are being included from DynamicTexture. We don't store complete references to that
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
bool TileRenderer::m_bFancyGrass = false;
|
||||
bool TileRenderer::m_bBiomeColors = false;
|
||||
bool TileRenderer::m_bUseAmbientOcclusion = false;
|
||||
|
||||
void TileRenderer::_init()
|
||||
{
|
||||
@@ -658,7 +659,7 @@ bool TileRenderer::tesselateBlockInWorld(Tile* tile, int x, int y, int z)
|
||||
float g = float(GET_GREEN(color)) / 255.0f;
|
||||
float b = float(GET_BLUE (color)) / 255.0f;
|
||||
|
||||
if (Minecraft::useAmbientOcclusion)
|
||||
if (TileRenderer::m_bUseAmbientOcclusion)
|
||||
{
|
||||
#ifdef ENH_USE_OWN_AO
|
||||
return tesselateBlockInWorldWithAmbienceOcclusionV2(tile, x, y, z, r, g, b);
|
||||
@@ -796,7 +797,7 @@ bool TileRenderer::tesselateWaterInWorld(Tile* tile1, int x, int y, int z)
|
||||
|
||||
label_8:
|
||||
bFlag2 = bFlag1;
|
||||
bool bRenderedSides = false;
|
||||
// bool bRenderedSides = false;
|
||||
|
||||
for (int dir = 0; dir < 4; dir++)
|
||||
{
|
||||
@@ -868,7 +869,7 @@ label_8:
|
||||
texV_2 = C_RATIO * (float(texY) + (1.0f - height2) * 16.0f);
|
||||
texV_3 = C_RATIO * (float(texY + 16.0f) - 0.01f);
|
||||
bFlag2 = true;
|
||||
bRenderedSides = true;
|
||||
// bRenderedSides = true;
|
||||
|
||||
float brightMul = dir >= DIR_XNEG ? 0.6f : 0.8f;
|
||||
float bright = tile->getBrightness(m_pLevelSource, checkX, y, checkZ);
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
|
||||
static bool m_bFancyGrass;
|
||||
static bool m_bBiomeColors;
|
||||
|
||||
static bool m_bUseAmbientOcclusion;
|
||||
private:
|
||||
LevelSource* m_pLevelSource;
|
||||
int m_textureOverride;
|
||||
|
||||
@@ -104,7 +104,7 @@ EntityRenderer* EntityRenderDispatcher::getRenderer(int renderType)
|
||||
|
||||
EntityRenderer* EntityRenderDispatcher::getRenderer(Entity* pEnt)
|
||||
{
|
||||
int renderType = pEnt->field_C8;
|
||||
int renderType = pEnt->m_renderType;
|
||||
if (renderType == RENDER_DYNAMIC)
|
||||
renderType = pEnt->queryEntityRenderer();
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ TripodCameraRenderer::TripodCameraRenderer() :
|
||||
|
||||
float TripodCameraRenderer::getFlashTime(TripodCamera* camera, float f)
|
||||
{
|
||||
if (camera->field_B90 > 7 || camera->field_B90 < 0)
|
||||
if (camera->m_iTimer > 7 || camera->m_iTimer < 0)
|
||||
return -1.0f;
|
||||
|
||||
return 0.125f * (float(camera->field_B90) - f);
|
||||
return 0.125f * (float(camera->m_iTimer) - f);
|
||||
}
|
||||
|
||||
void TripodCameraRenderer::render(Entity* entity, float x, float y, float z, float a, float b)
|
||||
|
||||
@@ -16,5 +16,5 @@
|
||||
// Minecraft PE 0.1.3 .apk file.
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef MISSING_SOUND_DATA
|
||||
#include "../../sound_data/sounds.h"
|
||||
#include "sound_data/sounds.h"
|
||||
#endif
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "client/options/Options.hpp"
|
||||
#include "common/Random.hpp"
|
||||
#include "server/Options.hpp"
|
||||
#include "SoundSystem.hpp"
|
||||
#include "SoundRepository.hpp"
|
||||
|
||||
|
||||
33
source/common/CMakeLists.txt
Normal file
33
source/common/CMakeLists.txt
Normal file
@@ -0,0 +1,33 @@
|
||||
# Common (low-level?) stuff
|
||||
|
||||
add_library(Common STATIC
|
||||
CThread.cpp CThread.hpp
|
||||
Logger.cpp Logger.hpp
|
||||
LongHack.hpp
|
||||
Matrix.cpp Matrix.hpp
|
||||
Mth.cpp Mth.hpp
|
||||
Random.cpp Random.hpp
|
||||
SmoothFloat.cpp SmoothFloat.hpp
|
||||
Timer.cpp Timer.hpp
|
||||
Util.cpp Util.hpp
|
||||
Utils.cpp Utils.hpp
|
||||
../../GameMods.hpp
|
||||
)
|
||||
|
||||
#target_link_libraries(Common PRIVATE Renderer)
|
||||
|
||||
# zlib
|
||||
if (WIN32)
|
||||
# Use vendored ZLib
|
||||
add_subdirectory(../../thirdparty/zlib zlib)
|
||||
target_link_libraries(Common PRIVATE zlib)
|
||||
elseif (EMSCRIPTEN)
|
||||
# Use Emscripten's ZLib
|
||||
set(ZLIB_FLAG -sUSE_ZLIB=1)
|
||||
target_compile_options(Common PUBLIC "${ZLIB_FLAG}")
|
||||
target_link_options(Common PRIVATE "${ZLIB_FLAG}")
|
||||
else()
|
||||
# Use System ZLib
|
||||
find_package(ZLIB REQUIRED)
|
||||
target_link_libraries(Common PRIVATE ZLIB::ZLIB)
|
||||
endif()
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h> // for Sleep()
|
||||
#include <windows.h> // for Sleep()
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
@@ -31,11 +31,6 @@ Matrix::Matrix(float a, float b, float q, float d, float e, float f, float g, fl
|
||||
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;
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
|
||||
#include <cstring>
|
||||
#include "Mth.hpp"
|
||||
#include "thirdparty/GL/GL.hpp"
|
||||
|
||||
typedef unsigned int GLenum;
|
||||
|
||||
class Matrix
|
||||
{
|
||||
@@ -19,7 +20,6 @@ public:
|
||||
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);
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#include <windows.h>
|
||||
#include <io.h>
|
||||
#include <direct.h>
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
int g_TimeSecondsOnInit = 0;
|
||||
|
||||
#if (!defined(USE_SDL) || defined(_WIN32)) && !defined(ANDROID) && !MC_TARGET_OS_MAC
|
||||
#ifdef _WIN32
|
||||
|
||||
DIR* opendir(const char* name)
|
||||
{
|
||||
|
||||
@@ -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 <WinSock2.h>
|
||||
#include <Windows.h>
|
||||
#include <WS2tcpip.h>
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <direct.h>
|
||||
#include <io.h>
|
||||
|
||||
@@ -101,7 +101,6 @@ void closedir(DIR* dir);
|
||||
|
||||
#endif
|
||||
|
||||
#include "../../compat/KeyCodes.hpp"
|
||||
#include "Logger.hpp"
|
||||
|
||||
// options:
|
||||
|
||||
25
source/network/CMakeLists.txt
Normal file
25
source/network/CMakeLists.txt
Normal file
@@ -0,0 +1,25 @@
|
||||
add_library(Network STATIC
|
||||
MinecraftPackets.cpp MinecraftPackets.hpp
|
||||
NetEventCallback.cpp NetEventCallback.hpp
|
||||
Packet.hpp
|
||||
PingedCompatibleServer.hpp
|
||||
RakNetInstance.cpp RakNetInstance.hpp
|
||||
ServerSideNetworkHandler.cpp ServerSideNetworkHandler.hpp
|
||||
packets/AddPlayerPacket.cpp
|
||||
packets/ChunkDataPacket.cpp
|
||||
packets/LevelDataPacket.cpp
|
||||
packets/LoginPacket.cpp
|
||||
packets/MessagePacket.cpp
|
||||
packets/MovePlayerPacket.cpp
|
||||
packets/PlaceBlockPacket.cpp
|
||||
packets/PlayerEquipmentPacket.cpp
|
||||
packets/RemoveBlockPacket.cpp
|
||||
packets/RemoveEntityPacket.cpp
|
||||
packets/RequestChunkPacket.cpp
|
||||
packets/StartGamePacket.cpp
|
||||
packets/UpdateBlockPacket.cpp
|
||||
)
|
||||
# RakNet
|
||||
add_subdirectory(../../thirdparty/raknet raknet)
|
||||
target_link_libraries(Network PUBLIC raknet)
|
||||
target_link_libraries(Network PRIVATE World)
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "NetEventCallback.hpp"
|
||||
|
||||
void NetEventCallback::levelGenerated(Level* level)
|
||||
void NetEventCallback::levelGenerated(Level* level, LocalPlayer* pLP)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RakNetTypes.h"
|
||||
#include "thirdparty/raknet/RakNetTypes.h"
|
||||
#include "Packet.hpp"
|
||||
class Packet;
|
||||
class LoginPacket;
|
||||
@@ -25,6 +25,7 @@ class ChunkDataPacket;
|
||||
class PlayerEquipmentPacket;
|
||||
class LevelDataPacket;
|
||||
#include "world/level/Level.hpp"
|
||||
class LocalPlayer;
|
||||
class Level;
|
||||
class LevelChunk;
|
||||
|
||||
@@ -32,7 +33,7 @@ class NetEventCallback
|
||||
{
|
||||
public:
|
||||
virtual ~NetEventCallback() {}
|
||||
virtual void levelGenerated(Level*);
|
||||
virtual void levelGenerated(Level*, LocalPlayer*);
|
||||
virtual void onConnect(const RakNet::RakNetGUID&);
|
||||
virtual void onUnableToConnect();
|
||||
virtual void onNewClient(const RakNet::RakNetGUID&);
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
|
||||
#include <string>
|
||||
#include "common/LongHack.hpp"
|
||||
#include "RakNetTypes.h"
|
||||
#include "BitStream.h"
|
||||
#include "MessageIdentifiers.h"
|
||||
#include "thirdparty/raknet/RakNetTypes.h"
|
||||
#include "thirdparty/raknet/BitStream.h"
|
||||
#include "thirdparty/raknet/MessageIdentifiers.h"
|
||||
#include "NetEventCallback.hpp"
|
||||
|
||||
class NetEventCallback;
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "RakNetTypes.h"
|
||||
#include "RakString.h"
|
||||
#include "thirdparty/raknet/RakNetTypes.h"
|
||||
#include "thirdparty/raknet/RakString.h"
|
||||
|
||||
|
||||
struct PingedCompatibleServer
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "thirdparty/raknet/BitStream.h"
|
||||
#include "thirdparty/raknet/RakPeerInterface.h"
|
||||
#include "PingedCompatibleServer.hpp"
|
||||
#include "BitStream.h"
|
||||
#include "RakPeerInterface.h"
|
||||
#include "Packet.hpp"
|
||||
|
||||
class Packet;
|
||||
|
||||
@@ -8,6 +8,12 @@
|
||||
|
||||
#include "ServerSideNetworkHandler.hpp"
|
||||
#include "common/Utils.hpp"
|
||||
#include "client/player/LocalPlayer.hpp"
|
||||
|
||||
// summon command
|
||||
#include "world/entity/TripodCamera.hpp"
|
||||
#include "world/entity/Pig.hpp"
|
||||
#include "world/entity/PrimedTnt.hpp"
|
||||
|
||||
// This lets you make the server shut up and not log events in the debug console.
|
||||
#define VERBOSE_SERVER
|
||||
@@ -20,9 +26,9 @@
|
||||
#define printf_ignorable(str, ...)
|
||||
#endif
|
||||
|
||||
ServerSideNetworkHandler::ServerSideNetworkHandler(Minecraft* minecraft, RakNetInstance* rakNetInstance)
|
||||
ServerSideNetworkHandler::ServerSideNetworkHandler(Server* server, RakNetInstance* rakNetInstance)
|
||||
{
|
||||
m_pMinecraft = minecraft;
|
||||
m_pServer = server;
|
||||
m_pLevel = nullptr;
|
||||
m_pRakNetInstance = rakNetInstance;
|
||||
allowIncomingConnections(false);
|
||||
@@ -43,20 +49,20 @@ ServerSideNetworkHandler::~ServerSideNetworkHandler()
|
||||
m_onlinePlayers.clear();
|
||||
}
|
||||
|
||||
void ServerSideNetworkHandler::levelGenerated(Level* level)
|
||||
void ServerSideNetworkHandler::levelGenerated(Level* level, LocalPlayer* pLP)
|
||||
{
|
||||
m_pLevel = level;
|
||||
|
||||
if (m_pMinecraft->m_pLocalPlayer)
|
||||
if (pLP)
|
||||
{
|
||||
m_pMinecraft->m_pLocalPlayer->m_guid = m_pRakNetPeer->GetMyGUID();
|
||||
pLP->m_guid = m_pRakNetPeer->GetMyGUID();
|
||||
}
|
||||
|
||||
level->addListener(this);
|
||||
|
||||
allowIncomingConnections(m_pMinecraft->getOptions()->m_bServerVisibleDefault);
|
||||
allowIncomingConnections(m_pServer->getOptions()->m_bServerVisibleDefault);
|
||||
|
||||
m_onlinePlayers[m_pMinecraft->m_pLocalPlayer->m_guid] = new OnlinePlayer(m_pMinecraft->m_pLocalPlayer, m_pMinecraft->m_pLocalPlayer->m_guid);
|
||||
m_onlinePlayers[pLP->m_guid] = new OnlinePlayer(pLP, pLP->m_guid);
|
||||
}
|
||||
|
||||
void ServerSideNetworkHandler::onNewClient(const RakNet::RakNetGUID& guid)
|
||||
@@ -118,7 +124,7 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, LoginPacke
|
||||
sgp.field_18 = pPlayer->m_pos.z;
|
||||
sgp.m_version = 2;
|
||||
sgp.m_time = m_pLevel->getTime();
|
||||
|
||||
|
||||
RakNet::BitStream sgpbs;
|
||||
sgp.write(&sgpbs);
|
||||
m_pRakNetPeer->Send(&sgpbs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, guid, false);
|
||||
@@ -135,12 +141,12 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, LoginPacke
|
||||
|
||||
m_pLevel->addEntity(pPlayer);
|
||||
|
||||
if (m_pMinecraft->m_pGameMode->isCreativeType())
|
||||
if (m_pServer->getGameMode()->isCreativeType())
|
||||
pPlayer->m_pInventory->prepareCreativeInventory();
|
||||
else
|
||||
pPlayer->m_pInventory->prepareSurvivalInventory();
|
||||
|
||||
m_pMinecraft->m_gui.addMessage(pPlayer->m_name + " joined the game");
|
||||
displayGameMessage(pPlayer->m_name + " joined the game");
|
||||
|
||||
AddPlayerPacket app(guid, RakNet::RakString(pPlayer->m_name.c_str()), pPlayer->m_EntityID, pPlayer->m_pos.x, pPlayer->m_pos.y - pPlayer->field_84, pPlayer->m_pos.z);
|
||||
RakNet::BitStream appbs;
|
||||
@@ -257,10 +263,7 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, RemoveBloc
|
||||
if (pTile && setTileResult)
|
||||
{
|
||||
const Tile::SoundType* pSound = pTile->m_pSound;
|
||||
m_pMinecraft->m_pSoundEngine->play("step." + pSound->m_name, float(x) + 0.5f, float(y) + 0.5f, float(z) + 0.5f, 0.5f * (pSound->volume + 1.0f), pSound->pitch * 0.8f);
|
||||
|
||||
// redistribute the packet only if needed
|
||||
redistributePacket(packet, guid);
|
||||
m_pLevel->playSound(float(x) + 0.5f, float(y) + 0.5f, float(z) + 0.5f, "step." + pSound->m_name, 0.5f * (pSound->volume + 1.0f), pSound->pitch * 0.8f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,7 +348,7 @@ void ServerSideNetworkHandler::allowIncomingConnections(bool b)
|
||||
{
|
||||
if (b)
|
||||
{
|
||||
m_pRakNetInstance->announceServer(m_pMinecraft->getOptions()->m_playerName);
|
||||
m_pRakNetInstance->announceServer(m_pServer->getOptions()->m_playerName);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -357,7 +360,7 @@ void ServerSideNetworkHandler::allowIncomingConnections(bool b)
|
||||
|
||||
void ServerSideNetworkHandler::displayGameMessage(const std::string& msg)
|
||||
{
|
||||
m_pMinecraft->m_gui.addMessage(msg);
|
||||
m_pServer->addMessage(msg);
|
||||
m_pRakNetInstance->send(new MessagePacket(msg));
|
||||
}
|
||||
|
||||
@@ -365,7 +368,7 @@ void ServerSideNetworkHandler::sendMessage(const RakNet::RakNetGUID& guid, const
|
||||
{
|
||||
if (m_pRakNetPeer->GetMyGUID() == guid)
|
||||
{
|
||||
m_pMinecraft->m_gui.addMessage(msg);
|
||||
m_pServer->addMessage(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -398,12 +401,39 @@ 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["?"] = &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;
|
||||
}
|
||||
|
||||
static inline float convertCoord(const std::string value, float base)
|
||||
{
|
||||
float val;
|
||||
std::stringstream ss(value);
|
||||
if (ss.peek() == '~')
|
||||
{
|
||||
ss.ignore();
|
||||
ss >> val;
|
||||
val += base;
|
||||
}
|
||||
else
|
||||
{
|
||||
ss >> val;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline Vec3 convertCoords(const std::vector<std::string> value, int offset, Vec3 pos)
|
||||
{
|
||||
Vec3 coord;
|
||||
coord.x = convertCoord(value[0 + offset], pos.x);
|
||||
coord.y = convertCoord(value[1 + offset], pos.y);
|
||||
coord.z = convertCoord(value[2 + offset], pos.z);
|
||||
return coord;
|
||||
}
|
||||
|
||||
void ServerSideNetworkHandler::commandHelp(OnlinePlayer* player, const std::vector<std::string>& parms)
|
||||
@@ -426,7 +456,7 @@ void ServerSideNetworkHandler::commandStats(OnlinePlayer* player, const std::vec
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "Server uptime: " << getTimeS() << " seconds.\n";
|
||||
ss << "Host's name: " << m_pMinecraft->m_pUser->field_0 << "\n";
|
||||
//ss << "Host's name: " << m_pServer->m_pUser->field_0 << "\n";
|
||||
|
||||
int nPlayers = int(m_onlinePlayers.size());
|
||||
if (nPlayers == 1)
|
||||
@@ -479,44 +509,86 @@ void ServerSideNetworkHandler::commandTP(OnlinePlayer* player, const std::vector
|
||||
{
|
||||
if (!m_pLevel)
|
||||
return;
|
||||
|
||||
|
||||
if (parms.size() != 3)
|
||||
{
|
||||
sendMessage(player, "Usage: /tp <x> <y> <z>");
|
||||
return;
|
||||
}
|
||||
|
||||
if (player->m_pPlayer != this->m_pMinecraft->m_pLocalPlayer)
|
||||
|
||||
/*
|
||||
if (player->m_pPlayer != this->m_pServer->m_pLocalPlayer)
|
||||
{
|
||||
sendMessage(player, "Sorry, only the host can use this command at the moment");
|
||||
return;
|
||||
}
|
||||
|
||||
Vec3 pos = player->m_pPlayer->getPos(1.0f);
|
||||
|
||||
float x = pos.x, y = pos.y, z = pos.z;
|
||||
|
||||
*/
|
||||
|
||||
Vec3 playerPos = player->m_pPlayer->getPos(1.0f);
|
||||
Vec3 pos = convertCoords(parms, 0, playerPos);
|
||||
|
||||
std::stringstream ss;
|
||||
if (parms[0] != "~")
|
||||
{
|
||||
ss.str(parms[0]);
|
||||
ss >> x;
|
||||
}
|
||||
if (parms[1] != "~")
|
||||
{
|
||||
ss.str(parms[1]);
|
||||
ss >> y;
|
||||
}
|
||||
if (parms[2] != "~")
|
||||
{
|
||||
ss.str(parms[2]);
|
||||
ss >> z;
|
||||
}
|
||||
|
||||
ss.str(std::string());
|
||||
ss << "Teleported to " << x << ", " << y << ", " << z;
|
||||
|
||||
player->m_pPlayer->setPos(x, y, z);
|
||||
|
||||
ss << "Teleported to " << pos.x << ", " << pos.y << ", " << pos.z;
|
||||
|
||||
player->m_pPlayer->setPos(pos.x, pos.y, pos.z);
|
||||
|
||||
sendMessage(player, ss.str());
|
||||
}
|
||||
|
||||
void ServerSideNetworkHandler::commandSummon(OnlinePlayer* player, const std::vector<std::string>& parms)
|
||||
{
|
||||
if (!m_pLevel)
|
||||
return;
|
||||
|
||||
if (parms.size() < 4)
|
||||
{
|
||||
sendMessage(player, "Usage: /summon <entity> <x> <y> <z>");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string entity = parms[0];
|
||||
Entity *ent = nullptr;
|
||||
|
||||
Vec3 playerPos = player->m_pPlayer->getPos(1.0f);
|
||||
Vec3 pos;
|
||||
if (parms.size() > 1)
|
||||
{
|
||||
pos = convertCoords(parms, 1, playerPos);
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
|
||||
if (entity == "camera")
|
||||
{
|
||||
TripodCamera *cam = new TripodCamera(m_pLevel, player->m_pPlayer, pos.x, pos.y, pos.z);
|
||||
if (parms.size() > 4)
|
||||
cam->m_iTimer = std::stoi(parms[4]) * 20;
|
||||
ent = cam;
|
||||
}
|
||||
else if (entity == "tnt")
|
||||
{
|
||||
PrimedTnt *tnt = new PrimedTnt(m_pLevel, pos.x, pos.y, pos.z);
|
||||
if (parms.size() > 4)
|
||||
tnt->m_fuseTimer = std::stoi(parms[4]) * 20;
|
||||
else tnt->m_fuseTimer = 0; // as in original
|
||||
ent = tnt;
|
||||
}
|
||||
else if (entity == "pig")
|
||||
{
|
||||
Pig* pig = new Pig(m_pLevel);
|
||||
pig->setPos(pos.x, pos.y, pos.z);
|
||||
ent = pig;
|
||||
}
|
||||
|
||||
if (!ent)
|
||||
{
|
||||
ss << "Unknown entity " << '"' << entity << '"';
|
||||
sendMessage(player, ss.str());
|
||||
return;
|
||||
}
|
||||
|
||||
m_pLevel->addEntity(ent);
|
||||
ss << "Summoned " << entity << " at " << pos.x << ", " << pos.y << ", " << pos.z;
|
||||
|
||||
sendMessage(player, ss.str());
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
|
||||
#include <map>
|
||||
#include "NetEventCallback.hpp"
|
||||
#include "client/app/Minecraft.hpp"
|
||||
#include "server/Server.hpp"
|
||||
#include "RakNetInstance.hpp"
|
||||
#include "world/level/LevelListener.hpp"
|
||||
|
||||
class Minecraft;
|
||||
class Server;
|
||||
class ServerSideNetworkHandler;
|
||||
|
||||
struct OnlinePlayer
|
||||
@@ -36,11 +36,11 @@ public:
|
||||
|
||||
// @TODO: We can do the following to finally split Network code from Client code
|
||||
// ServerSideNetworkHandler(GameCallbacks *gameCallbacks, Level* level, GameMode* gameMode, RakNetInstance* rakNetInstance, PacketSender* packetSender, Player* localPlayer);
|
||||
ServerSideNetworkHandler(Minecraft* minecraft, RakNetInstance* rakNetInstance);
|
||||
ServerSideNetworkHandler(Server* server, RakNetInstance* rakNetInstance);
|
||||
~ServerSideNetworkHandler();
|
||||
|
||||
// Overridden from NetEventCallback
|
||||
void levelGenerated(Level*) override;
|
||||
void levelGenerated(Level*, LocalPlayer*) override;
|
||||
void onNewClient(const RakNet::RakNetGUID&) override;
|
||||
void onDisconnect(const RakNet::RakNetGUID&) override;
|
||||
void handle(const RakNet::RakNetGUID&, LoginPacket*) override;
|
||||
@@ -66,14 +66,15 @@ public:
|
||||
void setupCommands();
|
||||
|
||||
// Commands
|
||||
void commandHelp (OnlinePlayer*, const std::vector<std::string>&);
|
||||
void commandStats(OnlinePlayer*, const std::vector<std::string>&);
|
||||
void commandTime (OnlinePlayer*, const std::vector<std::string>&);
|
||||
void commandSeed (OnlinePlayer*, const std::vector<std::string>&);
|
||||
void commandTP (OnlinePlayer*, const std::vector<std::string>&);
|
||||
void commandHelp (OnlinePlayer*, const std::vector<std::string>&);
|
||||
void commandStats (OnlinePlayer*, const std::vector<std::string>&);
|
||||
void commandTime (OnlinePlayer*, const std::vector<std::string>&);
|
||||
void commandSeed (OnlinePlayer*, const std::vector<std::string>&);
|
||||
void commandTP (OnlinePlayer*, const std::vector<std::string>&);
|
||||
void commandSummon (OnlinePlayer*, const std::vector<std::string>&);
|
||||
|
||||
public:
|
||||
Minecraft* m_pMinecraft;
|
||||
Server* m_pServer;
|
||||
Level* m_pLevel;
|
||||
RakNetInstance* m_pRakNetInstance;
|
||||
RakNet::RakPeerInterface* m_pRakNetPeer;
|
||||
|
||||
@@ -60,7 +60,7 @@ void LevelDataPacket::write(RakNet::BitStream* pbs)
|
||||
|
||||
if (pCompressedData)
|
||||
{
|
||||
float ratio = 100.0f * float(compSize) / float(uncompSize);
|
||||
//float ratio = 100.0f * float(compSize) / float(uncompSize);
|
||||
//LOG_I("Compression ratio: %.2f (%d comp, %d uncomp)", ratio, int(compSize), int(uncompSize));
|
||||
|
||||
int cs2 = int(compSize), us2 = int(uncompSize);
|
||||
|
||||
42
source/renderer/CMakeLists.txt
Normal file
42
source/renderer/CMakeLists.txt
Normal file
@@ -0,0 +1,42 @@
|
||||
add_library(Renderer STATIC)
|
||||
|
||||
if (render STREQUAL gl)
|
||||
# OpenGL
|
||||
set(USE_GL 1)
|
||||
target_sources(Renderer PRIVATE GL/GL.cpp GL/GL.hpp)
|
||||
elseif (render STREQUAL gles)
|
||||
# OpenGL ES
|
||||
# nothing?
|
||||
target_sources(Renderer PRIVATE GL/GL.cpp GL/GL.hpp)
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown renderer!")
|
||||
endif()
|
||||
|
||||
#target_include_directories(Renderer PUBLIC .)
|
||||
target_include_directories(Renderer PRIVATE ../..)
|
||||
|
||||
# Find OpenGL library
|
||||
if(USE_GLES1_COMPATIBILITY_LAYER)
|
||||
message(STATUS "GLESv1 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(Renderer PUBLIC gles-compatibility-layer)
|
||||
target_compile_definitions(Renderer PUBLIC USE_GLES1_COMPATIBILITY_LAYER)
|
||||
if(EMSCRIPTEN)
|
||||
# Use WebGL 2
|
||||
target_link_options(Renderer PUBLIC -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2)
|
||||
endif()
|
||||
elseif(WIN32)
|
||||
message(STATUS "Windows's opengl32")
|
||||
target_link_libraries(Renderer PUBLIC opengl32 glu32)
|
||||
target_sources(Renderer PRIVATE ../../thirdparty/GL/GLExt.cpp)
|
||||
else()
|
||||
message(STATUS "System OpenGL")
|
||||
find_package(OpenGL REQUIRED)
|
||||
target_link_libraries(Renderer PUBLIC OpenGL::OpenGL)
|
||||
endif()
|
||||
if (platform STREQUAL sdl)
|
||||
target_link_libraries(Renderer PUBLIC SDL)
|
||||
endif()
|
||||
12
source/server/CMakeLists.txt
Normal file
12
source/server/CMakeLists.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
add_library(Server STATIC
|
||||
Options.cpp Options.hpp
|
||||
Server.cpp Server.hpp
|
||||
)
|
||||
target_link_libraries(Server PRIVATE
|
||||
Common
|
||||
Network
|
||||
World
|
||||
)
|
||||
if (USE_SDL)
|
||||
target_link_libraries(Server PRIVATE SDL)
|
||||
endif()
|
||||
@@ -10,12 +10,13 @@
|
||||
|
||||
#include "Options.hpp"
|
||||
#include "common/Util.hpp"
|
||||
#include "common/Utils.hpp"
|
||||
#include "compat/KeyCodes.hpp"
|
||||
#include "client/app/Minecraft.hpp"
|
||||
|
||||
#ifndef SERVER
|
||||
#include "client/renderer/PatchManager.hpp"
|
||||
#include "client/renderer/GrassColor.hpp"
|
||||
#include "client/renderer/FoliageColor.hpp"
|
||||
#endif
|
||||
|
||||
Options::Option
|
||||
Options::Option::MUSIC (0, "options.music", true, false),
|
||||
@@ -48,7 +49,7 @@ void Options::_initDefaultValues()
|
||||
m_bInvertMouse = false;
|
||||
m_bAnaglyphs = false;
|
||||
field_16 = 0;
|
||||
m_bAmbientOcclusion = Minecraft::useAmbientOcclusion;
|
||||
m_bAmbientOcclusion = false;
|
||||
field_240 = 1;
|
||||
m_iViewDistance = 2;
|
||||
m_bViewBobbing = 1;
|
||||
@@ -115,21 +116,21 @@ void Options::_initDefaultValues()
|
||||
|
||||
#define KM(idx,code) m_keyMappings[idx].value = code
|
||||
#ifdef USE_SDL
|
||||
KM(KM_FORWARD, SDLVK_w);
|
||||
KM(KM_LEFT, SDLVK_a);
|
||||
KM(KM_BACKWARD, SDLVK_s);
|
||||
KM(KM_RIGHT, SDLVK_d);
|
||||
KM(KM_FORWARD, SDLVK_W);
|
||||
KM(KM_LEFT, SDLVK_A);
|
||||
KM(KM_BACKWARD, SDLVK_S);
|
||||
KM(KM_RIGHT, SDLVK_D);
|
||||
KM(KM_JUMP, SDLVK_SPACE);
|
||||
KM(KM_DESTROY, SDLVK_x);
|
||||
KM(KM_PLACE, SDLVK_c);
|
||||
KM(KM_DESTROY, SDLVK_X);
|
||||
KM(KM_PLACE, SDLVK_C);
|
||||
KM(KM_MENU_NEXT, SDLVK_DOWN);
|
||||
KM(KM_MENU_PREVIOUS, SDLVK_UP);
|
||||
KM(KM_MENU_OK, SDLVK_RETURN);
|
||||
KM(KM_MENU_CANCEL, SDLVK_ESCAPE);
|
||||
KM(KM_DROP, SDLVK_q);
|
||||
KM(KM_CHAT, SDLVK_t);
|
||||
KM(KM_FOG, SDLVK_f);
|
||||
KM(KM_INVENTORY, SDLVK_e);
|
||||
KM(KM_DROP, SDLVK_Q);
|
||||
KM(KM_CHAT, SDLVK_T);
|
||||
KM(KM_FOG, SDLVK_F);
|
||||
KM(KM_INVENTORY, SDLVK_E);
|
||||
KM(KM_SNEAK, SDLVK_LSHIFT);
|
||||
KM(KM_SLOT_1, SDLVK_1);
|
||||
KM(KM_SLOT_2, SDLVK_2);
|
||||
@@ -145,10 +146,10 @@ void Options::_initDefaultValues()
|
||||
KM(KM_TOGGLEDEBUG, SDLVK_F3);
|
||||
KM(KM_TOGGLEAO, SDLVK_F4);
|
||||
KM(KM_TOGGLE3RD, SDLVK_F5);
|
||||
KM(KM_SLOT_L, SDLVK_y);
|
||||
KM(KM_SLOT_R, SDLVK_u);
|
||||
KM(KM_FLY_UP, SDLVK_c);
|
||||
KM(KM_FLY_DOWN, SDLVK_x);
|
||||
KM(KM_SLOT_L, SDLVK_Y);
|
||||
KM(KM_SLOT_R, SDLVK_U);
|
||||
KM(KM_FLY_UP, SDLVK_C);
|
||||
KM(KM_FLY_DOWN, SDLVK_X);
|
||||
KM(KM_CHAT_CMD, SDLVK_SLASH);
|
||||
#endif
|
||||
#ifdef USE_NATIVE_ANDROID
|
||||
@@ -250,7 +251,7 @@ void Options::_load()
|
||||
else if (key == "mp_server_visible_default")
|
||||
m_bServerVisibleDefault = readBool(value);
|
||||
else if (key == "gfx_smoothlighting")
|
||||
Minecraft::useAmbientOcclusion = m_bAmbientOcclusion = readBool(value);
|
||||
m_bAmbientOcclusion = readBool(value);
|
||||
else if (key == "gfx_viewdistance")
|
||||
m_iViewDistance = readInt(value);
|
||||
else if (key == "gfx_blockoutlines")
|
||||
@@ -258,16 +259,20 @@ void Options::_load()
|
||||
else if (key == "gfx_fancygrass")
|
||||
{
|
||||
m_bFancyGrass = readBool(value);
|
||||
#ifndef SERVER // TODO(Er2): Move this to client?
|
||||
if (!(GetPatchManager()->IsGrassSidesTinted()))
|
||||
m_bFancyGrass = false;
|
||||
#endif
|
||||
}
|
||||
else if (key == "gfx_biomecolors")
|
||||
{
|
||||
m_bBiomeColors = readBool(value);
|
||||
#ifndef SERVER // TODO(Er2): this too
|
||||
if (!GrassColor::isAvailable() && !FoliageColor::isAvailable())
|
||||
{
|
||||
m_bBiomeColors = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (key == "gfx_hidegui")
|
||||
m_bDontRenderGui = readBool(value);
|
||||
203
source/server/Server.cpp
Normal file
203
source/server/Server.cpp
Normal file
@@ -0,0 +1,203 @@
|
||||
#include "Server.hpp"
|
||||
#include "network/ServerSideNetworkHandler.hpp"
|
||||
#include "world/level/storage/ExternalFileLevelStorageSource.hpp"
|
||||
|
||||
Server::Server(bool standalone)
|
||||
{
|
||||
m_pOptions = new Options();
|
||||
m_pGameMode = nullptr;
|
||||
m_pLevel = nullptr;
|
||||
m_pLevelStorageSource = nullptr;
|
||||
m_pRakNetInstance = new RakNetInstance;
|
||||
|
||||
if (standalone)
|
||||
{
|
||||
m_pLevelStorageSource = new ExternalFileLevelStorageSource("level");
|
||||
setLevel("level", "Level", 123456);
|
||||
}
|
||||
|
||||
m_pNetEventCallback = new ServerSideNetworkHandler(this, m_pRakNetInstance);
|
||||
m_bRunning = true;
|
||||
}
|
||||
|
||||
void Server::setLevel(const std::string path, const std::string name, int seed)
|
||||
{
|
||||
LevelStorage* pStor = m_pLevelStorageSource->selectLevel(path, false);
|
||||
Dimension* pDim = Dimension::getNew(0);
|
||||
// don't delete pDim manually, it's deleted automatically by level
|
||||
|
||||
m_pLevel = new Level(pStor, name, seed, 1, pDim);
|
||||
}
|
||||
|
||||
Server::~Server()
|
||||
{
|
||||
delete m_pGameMode;
|
||||
delete m_pLevel;
|
||||
delete m_pLevelStorageSource;
|
||||
delete m_pRakNetInstance;
|
||||
delete m_pNetEventCallback;
|
||||
delete m_pOptions;
|
||||
}
|
||||
|
||||
Level* Server::getLevel()
|
||||
{
|
||||
return m_pLevel;
|
||||
}
|
||||
|
||||
RakNetInstance* Server::getRakNetInstance()
|
||||
{
|
||||
return m_pRakNetInstance;
|
||||
}
|
||||
|
||||
Options* Server::getOptions()
|
||||
{
|
||||
return m_pOptions;
|
||||
}
|
||||
|
||||
GameMode* Server::getGameMode()
|
||||
{
|
||||
return m_pGameMode;
|
||||
}
|
||||
|
||||
void Server::addMessage(const std::string& message)
|
||||
{
|
||||
LOG_I("MSG: %s", message.c_str());
|
||||
}
|
||||
|
||||
void Server::start(const std::string name)
|
||||
{
|
||||
m_pRakNetInstance->host(name, C_DEFAULT_PORT, C_MAX_CONNECTIONS);
|
||||
}
|
||||
|
||||
void Server::stop()
|
||||
{
|
||||
m_bRunning = false;
|
||||
}
|
||||
|
||||
void Server::generateLevel()
|
||||
{
|
||||
if (!m_pLevel)
|
||||
{
|
||||
LOG_W("Level wasn't initialized!");
|
||||
setLevel("level", "Level", 123456);
|
||||
}
|
||||
|
||||
LOG_I("Building terrain");
|
||||
|
||||
float startTime = getTimeS();
|
||||
Level* pLevel = m_pLevel;
|
||||
|
||||
if (!pLevel->field_B0C)
|
||||
{
|
||||
pLevel->setUpdateLights(0);
|
||||
}
|
||||
|
||||
printf("Processing");
|
||||
for (int i = 8, i2 = 0; i != 8 + C_MAX_CHUNKS_X * 16; i += 16)
|
||||
{
|
||||
for (int j = 8; j != 8 + C_MAX_CHUNKS_Z * 16; j += 16, i2 += 100)
|
||||
{
|
||||
// this looks like some kind of progress tracking
|
||||
printf("\r\033[KProcessing %i%%", i2 / (C_MAX_CHUNKS_X * C_MAX_CHUNKS_Z));
|
||||
fflush(stdout);
|
||||
|
||||
float time1 = getTimeS();
|
||||
|
||||
// generating all the chunks at once
|
||||
TileID unused = m_pLevel->getTile(i, (C_MAX_Y + C_MIN_Y) / 2, j);
|
||||
|
||||
if (time1 != -1.0f)
|
||||
getTimeS();
|
||||
|
||||
float time2 = getTimeS();
|
||||
if (m_pLevel->field_B0C)
|
||||
{
|
||||
while (m_pLevel->updateLights());
|
||||
}
|
||||
|
||||
if (time2 != -1.0f)
|
||||
getTimeS();
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
if (startTime != -1.0f)
|
||||
getTimeS();
|
||||
|
||||
m_pLevel->setUpdateLights(1);
|
||||
|
||||
startTime = getTimeS();
|
||||
|
||||
for (int x = 0; x < C_MAX_CHUNKS_X; x++)
|
||||
{
|
||||
for (int z = 0; z < C_MAX_CHUNKS_Z; z++)
|
||||
{
|
||||
LevelChunk* pChunk = m_pLevel->getChunk(x, z);
|
||||
if (!pChunk)
|
||||
continue;
|
||||
|
||||
if (pChunk->field_237)
|
||||
continue;
|
||||
|
||||
pChunk->m_bUnsaved = false;
|
||||
pChunk->clearUpdateMap();
|
||||
}
|
||||
}
|
||||
|
||||
if (startTime != -1.0f)
|
||||
getTimeS();
|
||||
|
||||
LOG_I("Saving chunks");
|
||||
|
||||
if (m_pLevel->field_B0C)
|
||||
{
|
||||
m_pLevel->setInitialSpawn();
|
||||
m_pLevel->saveLevelData();
|
||||
m_pLevel->getChunkSource()->saveAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pLevel->saveLevelData();
|
||||
}
|
||||
|
||||
LOG_I("Preparing");
|
||||
|
||||
startTime = getTimeS();
|
||||
|
||||
m_pLevel->prepare();
|
||||
|
||||
m_pNetEventCallback->levelGenerated(m_pLevel, nullptr);
|
||||
}
|
||||
|
||||
void Server::tick()
|
||||
{
|
||||
m_pLevel->tickEntities();
|
||||
m_pLevel->tick();
|
||||
}
|
||||
|
||||
void Server::host()
|
||||
{
|
||||
ServerSideNetworkHandler* pSSNH = (ServerSideNetworkHandler*)m_pNetEventCallback;
|
||||
pSSNH->allowIncomingConnections(true);
|
||||
LOG_I("Server is ready!");
|
||||
|
||||
while (m_bRunning)
|
||||
{
|
||||
m_pRakNetInstance->runEvents(m_pNetEventCallback);
|
||||
|
||||
// tick
|
||||
m_timer.advanceTime();
|
||||
|
||||
for (int i = 0; i < m_timer.m_ticks; i++)
|
||||
{
|
||||
tick();
|
||||
}
|
||||
|
||||
//sleepMs(1);
|
||||
}
|
||||
|
||||
LOG_I("Stopping server");
|
||||
LOG_I("Saving chunks");
|
||||
|
||||
m_pLevel->saveLevelData();
|
||||
}
|
||||
41
source/server/Server.hpp
Normal file
41
source/server/Server.hpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include "Options.hpp"
|
||||
#include "common/Timer.hpp"
|
||||
#include "network/RakNetInstance.hpp"
|
||||
#include "world/level/Level.hpp"
|
||||
#include "world/gamemode/GameMode.hpp"
|
||||
|
||||
class ServerSideNetworkHandler;
|
||||
|
||||
class Server
|
||||
{
|
||||
public:
|
||||
Server(bool standalone);
|
||||
~Server();
|
||||
|
||||
void setLevel(const std::string path, const std::string name, int seed);
|
||||
Level* getLevel();
|
||||
RakNetInstance* getRakNetInstance();
|
||||
Options* getOptions();
|
||||
GameMode* getGameMode();
|
||||
|
||||
void start(const std::string name);
|
||||
void stop();
|
||||
void generateLevel();
|
||||
void tick();
|
||||
void host();
|
||||
|
||||
virtual void addMessage(const std::string& message);
|
||||
public:
|
||||
Level* m_pLevel;
|
||||
RakNetInstance* m_pRakNetInstance;
|
||||
GameMode* m_pGameMode;
|
||||
LevelStorageSource* m_pLevelStorageSource;
|
||||
NetEventCallback* m_pNetEventCallback;
|
||||
protected:
|
||||
Options* m_pOptions;
|
||||
Timer m_timer;
|
||||
private:
|
||||
bool m_bRunning;
|
||||
};
|
||||
127
source/world/CMakeLists.txt
Normal file
127
source/world/CMakeLists.txt
Normal file
@@ -0,0 +1,127 @@
|
||||
add_library(World STATIC
|
||||
entity/Animal.cpp entity/Animal.hpp
|
||||
entity/Entity.cpp entity/Entity.hpp
|
||||
entity/FallingTile.cpp entity/FallingTile.hpp
|
||||
entity/ItemEntity.cpp entity/ItemEntity.hpp
|
||||
entity/Mob.cpp entity/Mob.hpp
|
||||
entity/PathfinderMob.cpp entity/PathfinderMob.hpp
|
||||
entity/Pig.cpp entity/Pig.hpp
|
||||
entity/Player.cpp entity/Player.hpp
|
||||
entity/PrimedTnt.cpp entity/PrimedTnt.hpp
|
||||
entity/Rocket.cpp entity/Rocket.hpp
|
||||
entity/TripodCamera.cpp entity/TripodCamera.hpp
|
||||
item/CameraItem.cpp item/CameraItem.hpp
|
||||
item/DoorItem.cpp item/DoorItem.hpp
|
||||
item/Inventory.cpp item/Inventory.hpp
|
||||
item/Item.cpp item/Item.hpp
|
||||
item/ItemInstance.cpp item/ItemInstance.hpp
|
||||
item/RocketItem.cpp item/RocketItem.hpp
|
||||
item/TileItem.cpp item/TileItem.hpp
|
||||
item/TilePlanterItem.cpp item/TilePlanterItem.hpp
|
||||
level/Dimension.cpp level/Dimension.hpp
|
||||
level/Explosion.cpp level/Explosion.hpp
|
||||
level/Level.cpp level/Level.hpp
|
||||
level/LevelListener.cpp level/LevelListener.hpp
|
||||
level/LightLayer.cpp level/LightLayer.hpp
|
||||
level/LightUpdate.cpp level/LightUpdate.hpp
|
||||
level/Material.cpp level/Material.hpp
|
||||
level/Region.cpp level/Region.hpp
|
||||
level/TickNextTickData.cpp level/TickNextTickData.hpp
|
||||
level/levelgen/biome/Biome.cpp level/levelgen/biome/Biome.hpp
|
||||
level/levelgen/biome/BiomeSource.cpp level/levelgen/biome/BiomeSource.hpp
|
||||
level/levelgen/chunk/ChunkCache.cpp level/levelgen/chunk/ChunkCache.hpp
|
||||
level/levelgen/chunk/ChunkSource.cpp level/levelgen/chunk/ChunkSource.hpp
|
||||
level/levelgen/chunk/LevelChunk.cpp level/levelgen/chunk/LevelChunk.hpp
|
||||
level/levelgen/chunk/PerformanceTestChunkSource.cpp level/levelgen/chunk/PerformanceTestChunkSource.hpp
|
||||
level/levelgen/chunk/RandomLevelSource.cpp level/levelgen/chunk/RandomLevelSource.hpp
|
||||
level/levelgen/chunk/TestChunkSource.cpp level/levelgen/chunk/TestChunkSource.hpp
|
||||
level/levelgen/feature/BirchFeature.cpp
|
||||
level/levelgen/feature/ClayFeature.cpp
|
||||
level/levelgen/feature/Feature.cpp level/levelgen/feature/Feature.hpp
|
||||
level/levelgen/feature/FlowerFeature.cpp
|
||||
level/levelgen/feature/LargeCaveFeature.cpp
|
||||
level/levelgen/feature/LargeFeature.cpp
|
||||
level/levelgen/feature/OreFeature.cpp
|
||||
level/levelgen/feature/PineFeature.cpp
|
||||
level/levelgen/feature/ReedsFeature.cpp
|
||||
level/levelgen/feature/SpringFeature.cpp
|
||||
level/levelgen/feature/SpruceFeature.cpp
|
||||
level/levelgen/feature/TreeFeature.cpp
|
||||
level/levelgen/synth/ImprovedNoise.cpp level/levelgen/synth/ImprovedNoise.hpp
|
||||
level/levelgen/synth/PerlinNoise.cpp level/levelgen/synth/PerlinNoise.hpp
|
||||
level/levelgen/synth/Synth.cpp level/levelgen/synth/Synth.hpp
|
||||
level/path/BinaryHeap.cpp level/path/BinaryHeap.hpp
|
||||
level/path/Node.cpp level/path/Node.hpp
|
||||
level/path/Path.cpp level/path/Path.hpp
|
||||
level/path/PathFinder.cpp level/path/PathFinder.hpp
|
||||
level/storage/ChunkStorage.cpp level/storage/ChunkStorage.hpp
|
||||
level/storage/ExternalFileLevelStorage.cpp level/storage/ExternalFileLevelStorage.hpp
|
||||
level/storage/ExternalFileLevelStorageSource.cpp level/storage/ExternalFileLevelStorageSource.hpp
|
||||
level/storage/LevelData.cpp level/storage/LevelData.hpp
|
||||
level/storage/LevelSource.cpp level/storage/LevelSource.hpp
|
||||
level/storage/LevelStorage.cpp level/storage/LevelStorage.hpp
|
||||
level/storage/LevelStorageSource.cpp level/storage/LevelStorageSource.hpp
|
||||
level/storage/MemoryChunkStorage.cpp level/storage/MemoryChunkStorage.hpp
|
||||
level/storage/MemoryLevelStorage.cpp level/storage/MemoryLevelStorage.hpp
|
||||
level/storage/MemoryLevelStorageSource.cpp level/storage/MemoryLevelStorageSource.hpp
|
||||
level/storage/RegionFile.cpp level/storage/RegionFile.hpp
|
||||
phys/AABB.cpp phys/AABB.hpp
|
||||
phys/HitResult.cpp phys/HitResult.hpp
|
||||
phys/Vec3.cpp phys/Vec3.hpp
|
||||
tile/BookshelfTile.cpp tile/BookshelfTile.hpp
|
||||
tile/Bush.cpp tile/Bush.hpp
|
||||
tile/ClayTile.cpp tile/ClayTile.hpp
|
||||
tile/ClothTile.cpp tile/ClothTile.hpp
|
||||
tile/DirtTile.cpp tile/DirtTile.hpp
|
||||
tile/DoorTile.cpp tile/DoorTile.hpp
|
||||
tile/FarmTile.cpp tile/FarmTile.hpp
|
||||
tile/FireTile.cpp tile/FireTile.hpp
|
||||
tile/GlassTile.cpp tile/GlassTile.hpp
|
||||
tile/GrassTile.cpp tile/GrassTile.hpp
|
||||
tile/GravelTile.cpp tile/GravelTile.hpp
|
||||
tile/HalfTransparentTile.cpp tile/HalfTransparentTile.hpp
|
||||
tile/IceTile.cpp tile/IceTile.hpp
|
||||
tile/InvisibleTile.cpp tile/InvisibleTile.hpp
|
||||
tile/LadderTile.cpp tile/LadderTile.hpp
|
||||
tile/LeafTile.cpp tile/LeafTile.hpp
|
||||
tile/LiquidTile.cpp tile/LiquidTile.hpp
|
||||
tile/LiquidTileDynamic.cpp tile/LiquidTileDynamic.hpp
|
||||
tile/LiquidTileStatic.cpp tile/LiquidTileStatic.hpp
|
||||
tile/MetalTile.cpp tile/MetalTile.hpp
|
||||
tile/ObsidianTile.cpp tile/ObsidianTile.hpp
|
||||
tile/OreTile.cpp tile/OreTile.hpp
|
||||
tile/RedStoneOreTile.cpp tile/RedStoneOreTile.hpp
|
||||
tile/ReedTile.cpp tile/ReedTile.hpp
|
||||
tile/RocketLauncherTile.cpp tile/RocketLauncherTile.hpp
|
||||
tile/SandStoneTile.cpp tile/SandStoneTile.hpp
|
||||
tile/SandTile.cpp tile/SandTile.hpp
|
||||
tile/Sapling.cpp tile/Sapling.hpp
|
||||
tile/SpongeTile.cpp tile/SpongeTile.hpp
|
||||
tile/StairTile.cpp tile/StairTile.hpp
|
||||
tile/StoneSlabTile.cpp tile/StoneSlabTile.hpp
|
||||
tile/StoneTile.cpp tile/StoneTile.hpp
|
||||
tile/Tile.cpp tile/Tile.hpp
|
||||
tile/TntTile.cpp tile/TntTile.hpp
|
||||
tile/TopSnowTile.cpp tile/TopSnowTile.hpp
|
||||
tile/TorchTile.cpp tile/TorchTile.hpp
|
||||
tile/TransparentTile.cpp tile/TransparentTile.hpp
|
||||
tile/TreeTile.cpp tile/TreeTile.hpp
|
||||
)
|
||||
if (NOT BUILD_SERVER)
|
||||
target_sources(World PRIVATE
|
||||
gamemode/CreativeMode.cpp gamemode/CreativeMode.hpp
|
||||
gamemode/GameMode.cpp gamemode/GameMode.hpp
|
||||
gamemode/SurvivalMode.cpp gamemode/SurvivalMode.hpp
|
||||
particle/BubbleParticle.cpp
|
||||
particle/ExplodeParticle.cpp
|
||||
particle/FlameParticle.cpp
|
||||
particle/LavaParticle.cpp
|
||||
particle/Particle.cpp particle/Particle.hpp
|
||||
particle/ParticleEngine.cpp particle/ParticleEngine.hpp
|
||||
particle/RedDustParticle.cpp
|
||||
particle/SmokeParticle.cpp
|
||||
particle/TerrainParticle.cpp
|
||||
)
|
||||
target_link_libraries(World PRIVATE Renderer)
|
||||
endif()
|
||||
target_link_libraries(World PUBLIC Common)
|
||||
@@ -49,7 +49,7 @@ void Entity::_init()
|
||||
field_B8 = 0;
|
||||
field_BC = 300;
|
||||
field_C0 = 0;
|
||||
field_C8 = 0; // @NOTE: Render type? (eEntityRenderType)
|
||||
m_renderType = RENDER_NONE;
|
||||
m_distanceFallen = 0.0f;
|
||||
field_D0 = 300;
|
||||
field_D4 = 0;
|
||||
@@ -64,7 +64,7 @@ Entity::Entity(Level* pLevel)
|
||||
|
||||
m_pLevel = pLevel;
|
||||
m_EntityID = ++entityCounter;
|
||||
setPos(0, 0, 0);
|
||||
Entity::setPos(0, 0, 0);
|
||||
}
|
||||
|
||||
Entity::~Entity()
|
||||
@@ -663,7 +663,7 @@ void Entity::baseTick()
|
||||
for (int i = 0; float(i) < field_88 * 20.0f + 1.0f; i++)
|
||||
{
|
||||
m_pLevel->addParticle(
|
||||
"splash",
|
||||
"bubble",
|
||||
m_pos.x + field_88 * (sharedRandom.nextFloat() * 2.0f - 1.0f),
|
||||
f1 + 1.0f,
|
||||
m_pos.z + field_88 * (sharedRandom.nextFloat() * 2.0f - 1.0f),
|
||||
|
||||
@@ -238,7 +238,7 @@ public:
|
||||
int field_BC;
|
||||
int field_C0;
|
||||
int field_C4;
|
||||
int field_C8; // @NOTE: Render type? (eEntityRenderType)
|
||||
int m_renderType;
|
||||
float m_distanceFallen;
|
||||
int field_D0;
|
||||
uint8_t field_D4;
|
||||
|
||||
@@ -30,7 +30,7 @@ FallingTile::FallingTile(Level* level, float x, float y, float z, int id) : Enti
|
||||
m_vel.z = 0.0f;
|
||||
|
||||
#if defined(ENH_ALLOW_SAND_GRAVITY)
|
||||
field_C8 = RENDER_FALLING_TILE;
|
||||
m_renderType = RENDER_FALLING_TILE;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ void ItemEntity::_init(ItemInstance* itemInstance, float x, float y, float z)
|
||||
{
|
||||
_init(itemInstance);
|
||||
|
||||
field_C8 = RENDER_ITEM;
|
||||
m_renderType = RENDER_ITEM;
|
||||
setPos(x, y, z);
|
||||
|
||||
m_yaw = 360.0f * Mth::random();
|
||||
@@ -103,7 +103,7 @@ void ItemEntity::tick()
|
||||
dragFactor = 0.588f;
|
||||
TileID tile = m_pLevel->getTile(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_acceleration * 0.98f;
|
||||
}
|
||||
|
||||
m_vel.x *= dragFactor;
|
||||
@@ -149,6 +149,7 @@ void ItemEntity::checkInTile(float x, float y, float z)
|
||||
if (!solidYP && 1.0f - ydiff < mindist) mindist = 1.0f - ydiff, mindir = 3;
|
||||
if (!solidZN && zdiff < mindist) mindist = zdiff, mindir = 4;
|
||||
if (!solidZP && 1.0f - zdiff < mindist) mindist = 1.0f - zdiff, mindir = 5;
|
||||
(void)mindist; // LMAO
|
||||
|
||||
// the -1 case will be handled accordingly
|
||||
float force = 0.1f + 0.2f * sharedRandom.nextFloat();
|
||||
|
||||
@@ -520,7 +520,7 @@ void Mob::travel(float a2, float a3)
|
||||
if (tile <= 0)
|
||||
_x1 = 0.546f;
|
||||
else
|
||||
_x1 = Tile::tiles[tile]->field_30 * 0.91f;
|
||||
_x1 = Tile::tiles[tile]->m_acceleration * 0.91f;
|
||||
|
||||
assert(_x1 != 0.0f);
|
||||
|
||||
@@ -543,7 +543,7 @@ void Mob::travel(float a2, float a3)
|
||||
if (tile <= 0)
|
||||
dragFactor = 0.546f;
|
||||
else
|
||||
dragFactor = Tile::tiles[tile]->field_30 * 0.91f;
|
||||
dragFactor = Tile::tiles[tile]->m_acceleration * 0.91f;
|
||||
}
|
||||
|
||||
if (onLadder())
|
||||
|
||||
@@ -12,6 +12,7 @@ PathfinderMob::PathfinderMob(Level* pLevel) : Mob(pLevel)
|
||||
{
|
||||
field_BA0 = false;
|
||||
field_BA4 = 0;
|
||||
m_pAttackTarget = nullptr;
|
||||
}
|
||||
|
||||
Entity* PathfinderMob::getAttackTarget()
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
Pig::Pig(Level* pLevel) : Animal(pLevel)
|
||||
{
|
||||
field_C8 = RENDER_PIG;
|
||||
m_renderType = RENDER_PIG;
|
||||
m_texture = "mob/pig.png";
|
||||
setSize(0.9f, 0.9f);
|
||||
// some dataitem stuff
|
||||
|
||||
@@ -22,7 +22,7 @@ Player::Player(Level* pLevel) : Mob(pLevel)
|
||||
field_BC4 = 0;
|
||||
m_bHaveRespawnPos = false;
|
||||
|
||||
field_C8 = RENDER_HUMANOID;
|
||||
m_renderType = RENDER_HUMANOID;
|
||||
|
||||
m_pInventory = new Inventory(this);
|
||||
|
||||
@@ -345,7 +345,7 @@ void Player::setRespawnPos(Pos* pos)
|
||||
m_bHaveRespawnPos = true;
|
||||
m_respawnPos.x = pos->x;
|
||||
m_respawnPos.y = pos->y;
|
||||
// @BUG: no m_respawnPos.z = pos->z ??
|
||||
m_respawnPos.z = pos->z;
|
||||
}
|
||||
|
||||
void Player::startCrafting(int x, int y, int z)
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
void PrimedTnt::_init()
|
||||
{
|
||||
m_fuseTimer = 0;
|
||||
field_C8 = RENDER_TNT;
|
||||
m_renderType = RENDER_TNT;
|
||||
field_34 = 1;
|
||||
setSize(0.98f, 0.98f);
|
||||
field_84 = field_8C * 0.5f;
|
||||
|
||||
@@ -14,7 +14,7 @@ Rocket::Rocket(Level* level, float x, float y, float z) : Entity(level)
|
||||
{
|
||||
field_B8C = 0;
|
||||
field_B90 = 80;
|
||||
field_C8 = RENDER_ROCKET;
|
||||
m_renderType = RENDER_ROCKET;
|
||||
|
||||
field_34 = 1;
|
||||
|
||||
|
||||
@@ -12,12 +12,11 @@
|
||||
|
||||
TripodCamera::TripodCamera(Level* level, Player* player, float x, float y, float z) : Mob(level)
|
||||
{
|
||||
field_B8C = 0;
|
||||
field_B90 = 80;
|
||||
m_iTimer = 80;
|
||||
m_bActive = false;
|
||||
|
||||
m_owner = player;
|
||||
field_C8 = RENDER_CAMERA;
|
||||
m_renderType = RENDER_CAMERA;
|
||||
|
||||
field_60 = m_pitch = player->m_pitch;
|
||||
field_5C = m_yaw = player->m_yaw;
|
||||
@@ -83,14 +82,14 @@ void TripodCamera::tick()
|
||||
if (!m_bActive)
|
||||
return;
|
||||
|
||||
field_B90--;
|
||||
if (field_B90 == 0)
|
||||
m_iTimer--;
|
||||
if (m_iTimer == 0)
|
||||
{
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
|
||||
if (field_B90 == 8)
|
||||
if (m_iTimer == 8)
|
||||
{
|
||||
m_pLevel->takePicture(this, m_owner);
|
||||
m_pLevel->addParticle("explode", m_pos.x, m_pos.y + 0.6f, m_pos.z, 0.0f, 0.0f, 0.0f);
|
||||
@@ -99,7 +98,7 @@ void TripodCamera::tick()
|
||||
return;
|
||||
}
|
||||
|
||||
if (field_B90 > 8)
|
||||
if (m_iTimer > 8)
|
||||
{
|
||||
m_pLevel->addParticle("smoke", m_pos.x, m_pos.y + 1.0f, m_pos.z, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
@@ -27,8 +27,7 @@ public:
|
||||
void tick() override;
|
||||
|
||||
public:
|
||||
int field_B8C;
|
||||
int field_B90;
|
||||
int m_iTimer;
|
||||
Player* m_owner;
|
||||
bool m_bActive;
|
||||
};
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "world/item/ItemInstance.hpp"
|
||||
|
||||
class Minecraft;
|
||||
class LocalPlayer;
|
||||
|
||||
class GameMode
|
||||
{
|
||||
|
||||
@@ -1709,6 +1709,7 @@ float Level::getSeenPercent(Vec3 vec, AABB aabb)
|
||||
float aabbSizeZ = aabb.max.z - aabb.min.z;
|
||||
|
||||
// This shoots a bunch of rays from a point and checks if the rays hit something. Stuupiiiddd
|
||||
// FIXME(Er2): clang-analyzer-security.FloatLoopCounter
|
||||
for (float xi = 0.0f; xi <= 1.0f; xi += 1.0f / (1.0f + 2 * aabbSizeX))
|
||||
{
|
||||
for (float yi = 0.0f; yi <= 1.0f; yi += 1.0f / (1.0f + 2 * aabbSizeY))
|
||||
|
||||
@@ -16,17 +16,16 @@
|
||||
|
||||
#include "world/tile/Tile.hpp"
|
||||
#include "world/entity/Entity.hpp"
|
||||
#include "world/entity/LocalPlayer.hpp"
|
||||
#include "world/level/levelgen/chunk/LevelChunk.hpp"
|
||||
#include "world/level/levelgen/chunk/ChunkSource.hpp"
|
||||
#include "world/level/storage/LevelStorageSource.hpp"
|
||||
#include "world/level/storage/LevelSource.hpp"
|
||||
#include "world/level/storage/LevelData.hpp"
|
||||
#include "world/level/path/PathFinder.hpp"
|
||||
#include "world/level/LightUpdate.hpp"
|
||||
#include "Dimension.hpp"
|
||||
#include "LevelListener.hpp"
|
||||
#include "TickNextTickData.hpp"
|
||||
#include "client/renderer/LightUpdate.hpp"
|
||||
|
||||
class Dimension;
|
||||
class Level;
|
||||
|
||||
@@ -85,6 +85,9 @@ LevelChunk* ChunkCache::getChunk(int x, int z)
|
||||
if (m_pChunkSource)
|
||||
pChunk = m_pChunkSource->getChunk(x, z);
|
||||
|
||||
if (!pChunk)
|
||||
return nullptr;
|
||||
|
||||
m_chunkMap[z][x] = pChunk;
|
||||
pChunk->lightLava();
|
||||
}
|
||||
@@ -92,6 +95,8 @@ LevelChunk* ChunkCache::getChunk(int x, int z)
|
||||
pChunk = m_chunkMap[z][x];
|
||||
if (pChunk)
|
||||
pChunk->load();
|
||||
else
|
||||
return nullptr;
|
||||
|
||||
if (!pChunk->field_234 && hasChunk(x + 1, z + 1) && hasChunk(x, z + 1) && hasChunk(x + 1, z))
|
||||
postProcess(this, x, z);
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include "common/Utils.hpp"
|
||||
#include "client/renderer/LightLayer.hpp"
|
||||
#include "world/level/LightLayer.hpp"
|
||||
#include "world/phys/AABB.hpp"
|
||||
|
||||
class Level;
|
||||
|
||||
@@ -74,19 +74,19 @@ bool BirchFeature::place(Level* level, Random* random, int x, int y, int z)
|
||||
for (int i = lowerY; i <= upperY; i++, diff = i - upperY)
|
||||
{
|
||||
int c1 = 1 - diff / 2;
|
||||
int c2 = diff / 2 - 1;
|
||||
//int c2 = diff / 2 - 1;
|
||||
for (int ax = x - c1; ax <= x + c1; ax++)
|
||||
{
|
||||
int c3 = c2;
|
||||
//int c3 = c2;
|
||||
int c4 = diff / 2 - 1;
|
||||
if (c2 < 0)
|
||||
c3 = -c2;
|
||||
//if (c2 < 0)
|
||||
// c3 = -c2;
|
||||
|
||||
//int c5 = c3;
|
||||
|
||||
for (int az = z - c1; az <= z + c1; az++, c4++)
|
||||
{
|
||||
if ((abs(ax - x) != c1 || abs(az - z) != c1 || (random->nextInt(2) != 0 && diff != 0)) && !Tile::solid[level->getTile(ax, i, az)])
|
||||
if ((abs(ax - x) != c1 || abs(az - z) != c1 || (random->nextInt(2) != 0 && diff != 0)) && !Tile::solid[level->getTile(ax, i, az)])
|
||||
{
|
||||
level->setTileAndDataNoUpdate(ax, i, az, Tile::leaves->m_ID, 2);
|
||||
}
|
||||
|
||||
@@ -74,19 +74,19 @@ bool TreeFeature::place(Level* level, Random* random, int x, int y, int z)
|
||||
for (int i = lowerY; i <= upperY; i++, diff = i - upperY)
|
||||
{
|
||||
int c1 = 1 - diff / 2;
|
||||
int c2 = diff / 2 - 1;
|
||||
//int c2 = diff / 2 - 1;
|
||||
for (int ax = x - c1; ax <= x + c1; ax++)
|
||||
{
|
||||
int c3 = c2;
|
||||
//int c3 = c2;
|
||||
int c4 = diff / 2 - 1;
|
||||
if (c2 < 0)
|
||||
c3 = -c2;
|
||||
//if (c2 < 0)
|
||||
// c3 = -c2;
|
||||
|
||||
//int c5 = c3;
|
||||
|
||||
for (int az = z - c1; az <= z + c1; az++, c4++)
|
||||
{
|
||||
if ((abs(ax - x) != c1 || abs(az - z) != c1 || (random->nextInt(2) != 0 && diff != 0)) && !Tile::solid[level->getTile(ax, i, az)])
|
||||
if ((abs(ax - x) != c1 || abs(az - z) != c1 || (random->nextInt(2) != 0 && diff != 0)) && !Tile::solid[level->getTile(ax, i, az)])
|
||||
{
|
||||
level->setTileNoUpdate(ax, i, az, Tile::leaves->m_ID);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "ExternalFileLevelStorage.hpp"
|
||||
#include "world/level/Level.hpp"
|
||||
#include "GetTime.h"
|
||||
#include "thirdparty/raknet/GetTime.h"
|
||||
|
||||
#ifndef DEMO
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ ExternalFileLevelStorageSource::ExternalFileLevelStorageSource(const std::string
|
||||
if (createFolderIfNotExists(m_worldsPath.c_str()))
|
||||
{
|
||||
std::vector<LevelSummary> vls;
|
||||
getLevelList(vls);
|
||||
ExternalFileLevelStorageSource::getLevelList(vls);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "BitStream.h"
|
||||
#include "thirdparty/raknet/BitStream.h"
|
||||
#include "common/Utils.hpp"
|
||||
#include "world/phys/Vec3.hpp"
|
||||
#include "world/item/Inventory.hpp"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user