forked from Kolyah35/minecraft-pe-0.6.1
FIX: Increased save time
This commit is contained in:
@@ -6,22 +6,45 @@ include(cmake/CPM.cmake)
|
|||||||
set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
||||||
set(CMAKE_POLICY_VERSION_MINIMUM 3.10)
|
set(CMAKE_POLICY_VERSION_MINIMUM 3.10)
|
||||||
|
|
||||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
set(CMAKE_CXX_FLAGS "-Wno-c++11-narrowing -Wno-narrowing -Wno-invalid-source-encoding -Wno-reserved-user-defined-literal")
|
set(CMAKE_CXX_FLAGS "-Wno-c++11-narrowing -Wno-narrowing -Wno-invalid-source-encoding -Wno-reserved-user-defined-literal")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# ## Config options ###
|
||||||
|
include(CMakeDependentOption)
|
||||||
|
include(cmake/EnumOption.cmake)
|
||||||
|
|
||||||
|
if(EMSCRIPTEN)
|
||||||
|
# When configuring web builds with "emcmake cmake -B build -S .", set PLATFORM to Web by default
|
||||||
|
set(PLATFORM Web CACHE STRING "Platform to build for.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
enum_option(PLATFORM "Desktop;Web" "Platform to build for.")
|
||||||
|
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
find_package(OpenSSL)
|
find_package(OpenSSL)
|
||||||
|
|
||||||
if(EMSCRIPTEN)
|
if (${PLATFORM} STREQUAL "Desktop")
|
||||||
set(AL_LIBTYPE "STATIC")
|
set(PLATFORM_CPP "PLATFORM_DESKTOP")
|
||||||
else()
|
|
||||||
set(AL_LIBTYPE "SHARED")
|
if (WIN32)
|
||||||
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||||
|
set(EXTRA_LIBS ws2_32)
|
||||||
|
elseif(UNIX)
|
||||||
|
find_library(pthread NAMES pthread)
|
||||||
|
set(EXTRA_LIBS pthread m)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
elseif (${PLATFORM} STREQUAL "Web")
|
||||||
|
set(PLATFORM_CPP "PLATFORM_WEB")
|
||||||
|
set(EXTRA_LIBS "idbfs.js")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# I totally shocked
|
# I totally shocked
|
||||||
if(EMSCRIPTEN)
|
if(${PLATFORM} MATCHES "Web")
|
||||||
set(PNG_LIB png)
|
set(PNG_LIB png)
|
||||||
|
set(AL_LIBTYPE "STATIC")
|
||||||
|
|
||||||
add_library(zlib INTERFACE IMPORTED)
|
add_library(zlib INTERFACE IMPORTED)
|
||||||
set_target_properties(zlib PROPERTIES
|
set_target_properties(zlib PROPERTIES
|
||||||
@@ -39,6 +62,7 @@ if(EMSCRIPTEN)
|
|||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
set(PNG_LIB png_shared)
|
set(PNG_LIB png_shared)
|
||||||
|
set(AL_LIBTYPE "SHARED")
|
||||||
|
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME "zlib"
|
NAME "zlib"
|
||||||
@@ -259,49 +283,32 @@ file(GLOB CLIENT_SOURCES
|
|||||||
"src/SharedConstants.cpp"
|
"src/SharedConstants.cpp"
|
||||||
"src/main.cpp"
|
"src/main.cpp"
|
||||||
"src/NinecraftApp.cpp"
|
"src/NinecraftApp.cpp"
|
||||||
|
|
||||||
|
"src/AppPlatform_glfw.cpp"
|
||||||
|
"src/main.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NOT DEFINED PLATFORM)
|
if (${PLATFORM} STREQUAL "Desktop")
|
||||||
set(PLATFORM "PLATFORM_GLFW")
|
list(APPEND CLIENT_SOURCES glad/src/glad.c)
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
if(PLATFORM STREQUAL "PLATFORM_WIN32")
|
|
||||||
list(APPEND CLIENT_SOURCES "src/AppPlatform_win32.cpp" "glad/src/glad.c")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(PLATFORM STREQUAL "PLATFORM_GLFW")
|
|
||||||
list(APPEND CLIENT_SOURCES "src/AppPlatform_glfw.cpp" "glad/src/glad.c")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(EMSCRIPTEN)
|
|
||||||
list(APPEND CLIENT_SOURCES "glad/src/glad.c")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Server
|
# Server
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
add_executable("${PROJECT_NAME}-server" ${SERVER_SOURCES})
|
add_executable("${PROJECT_NAME}-server" ${SERVER_SOURCES})
|
||||||
|
|
||||||
target_compile_definitions("${PROJECT_NAME}-server" PUBLIC "STANDALONE_SERVER" "SERVER_PROFILER")
|
target_compile_definitions("${PROJECT_NAME}-server" PUBLIC "STANDALONE_SERVER" "SERVER_PROFILER")
|
||||||
|
|
||||||
target_include_directories("${PROJECT_NAME}-server" PUBLIC
|
target_include_directories("${PROJECT_NAME}-server" PUBLIC
|
||||||
"${CMAKE_SOURCE_DIR}/src/"
|
"${CMAKE_SOURCE_DIR}/src/"
|
||||||
"project/lib_projects/raknet/jni/RaknetSources"
|
"project/lib_projects/raknet/jni/RaknetSources"
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries("${PROJECT_NAME}-server" ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries("${PROJECT_NAME}-server" ${CMAKE_THREAD_LIBS_INIT})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME} ${CLIENT_SOURCES})
|
add_executable(${PROJECT_NAME} ${CLIENT_SOURCES})
|
||||||
|
|
||||||
if(WIN32)
|
target_compile_definitions(${PROJECT_NAME} PUBLIC ${PLATFORM_CPP})
|
||||||
set(EXTRA_LIBS "ws2_32")
|
|
||||||
target_compile_definitions(${PROJECT_NAME} PUBLIC "_CRT_SECURE_NO_WARNINGS")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(PLATFORM STREQUAL "PLATFORM_WIN32" OR PLATFORM STREQUAL "PLATFORM_GLFW")
|
|
||||||
target_compile_definitions(${PROJECT_NAME} PUBLIC "PLATFORM_DESKTOP")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC
|
target_include_directories(${PROJECT_NAME} PUBLIC
|
||||||
"${CMAKE_SOURCE_DIR}/glad/include/"
|
"${CMAKE_SOURCE_DIR}/glad/include/"
|
||||||
@@ -311,7 +318,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC
|
|||||||
"lib/include"
|
"lib/include"
|
||||||
)
|
)
|
||||||
|
|
||||||
if(EMSCRIPTEN)
|
if(${PLATFORM} MATCHES "Web")
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
# uuuh i hate it
|
# uuuh i hate it
|
||||||
set(EM_FLAGS "-pthread -sUSE_PTHREADS=1 -sSHARED_MEMORY=1")
|
set(EM_FLAGS "-pthread -sUSE_PTHREADS=1 -sSHARED_MEMORY=1")
|
||||||
@@ -352,7 +359,6 @@ if(EMSCRIPTEN)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_compile_definitions(${PROJECT_NAME} PUBLIC "__EMSCRIPTEN__" "NO_SOUND" "NO_NETWORK")
|
target_compile_definitions(${PROJECT_NAME} PUBLIC "__EMSCRIPTEN__" "NO_SOUND" "NO_NETWORK")
|
||||||
set(EXTRA_LIBS "idbfs.js")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Client
|
# Client
|
||||||
@@ -373,7 +379,7 @@ if (NOT UNIX)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT EMSCRIPTEN)
|
if(NOT ${PLATFORM} MATCHES "Web")
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET ${PROJECT_NAME}
|
TARGET ${PROJECT_NAME}
|
||||||
POST_BUILD
|
POST_BUILD
|
||||||
@@ -385,4 +391,7 @@ else()
|
|||||||
POST_BUILD
|
POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/misc/web/index.html" $<TARGET_FILE_DIR:${PROJECT_NAME}>
|
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/misc/web/index.html" $<TARGET_FILE_DIR:${PROJECT_NAME}>
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
message(STATUS "Compiling with the flags:")
|
||||||
|
message(STATUS " PLATFORM=" ${PLATFORM_CPP})
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <SDL/SDL.h>
|
#include <SDL/SDL.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PLATFORM_GLFW
|
#ifdef PLATFORM_DESKTOP
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ void MouseHandler::grab() {
|
|||||||
SDL_ShowCursor(0);
|
SDL_ShowCursor(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PLATFORM_GLFW
|
#ifdef PLATFORM_DESKTOP
|
||||||
glfwSetInputMode(glfwGetCurrentContext(), GLFW_CURSOR, GLFW_CURSOR_DISABLED);
|
glfwSetInputMode(glfwGetCurrentContext(), GLFW_CURSOR, GLFW_CURSOR_DISABLED);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ void MouseHandler::release() {
|
|||||||
SDL_ShowCursor(1);
|
SDL_ShowCursor(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PLATFORM_GLFW
|
#ifdef PLATFORM_DESKTOP
|
||||||
glfwSetInputMode(glfwGetCurrentContext(), GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
glfwSetInputMode(glfwGetCurrentContext(), GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,12 +22,12 @@
|
|||||||
#include "NinecraftApp.h"
|
#include "NinecraftApp.h"
|
||||||
#define MAIN_CLASS NinecraftApp
|
#define MAIN_CLASS NinecraftApp
|
||||||
|
|
||||||
#ifdef PLATFORM_WINDOWS
|
// #ifdef PLATFORM_WINDOWS
|
||||||
#include "main_win32.h"
|
// #include "main_win32.h"
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef PLATFORM_GLFW
|
#ifdef PLATFORM_DESKTOP
|
||||||
#include "main_glfw.h"
|
#include "main_glfw.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "../chunk/LevelChunk.h"
|
#include "../chunk/LevelChunk.h"
|
||||||
#include "../Level.h"
|
#include "../Level.h"
|
||||||
#include "../LevelConstants.h"
|
#include "../LevelConstants.h"
|
||||||
|
#include "platform/log.h"
|
||||||
#include "../tile/TreeTile.h"
|
#include "../tile/TreeTile.h"
|
||||||
#include "../../entity/EntityFactory.h"
|
#include "../../entity/EntityFactory.h"
|
||||||
#include "../../../nbt/NbtIo.h"
|
#include "../../../nbt/NbtIo.h"
|
||||||
@@ -289,8 +290,9 @@ bool ExternalFileLevelStorage::readPlayerData(const std::string& filename, Level
|
|||||||
void ExternalFileLevelStorage::tick()
|
void ExternalFileLevelStorage::tick()
|
||||||
{
|
{
|
||||||
tickCount++;
|
tickCount++;
|
||||||
if ((tickCount % 50) == 0 && level)
|
if ((tickCount % 1000) == 0 && level) {
|
||||||
{
|
LOGI("Saving level...\n");
|
||||||
|
|
||||||
// look for chunks that needs to be saved
|
// look for chunks that needs to be saved
|
||||||
for (int z = 0; z < CHUNK_CACHE_WIDTH; z++)
|
for (int z = 0; z < CHUNK_CACHE_WIDTH; z++)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user