diff --git a/cmake/patches/sol2-3.3.0-clang-optional.patch b/cmake/patches/sol2-3.3.0-clang-optional.patch index 65eb907..e988f05 100644 --- a/cmake/patches/sol2-3.3.0-clang-optional.patch +++ b/cmake/patches/sol2-3.3.0-clang-optional.patch @@ -1,14 +1,14 @@ --- a/include/sol/optional_implementation.hpp +++ b/include/sol/optional_implementation.hpp -@@ -2189,7 +2189,10 @@ +@@ -2190,6 +2190,9 @@ template T& emplace(Args&&... args) noexcept { static_assert(std::is_constructible::value, "T must be constructible with Args"); - +- ++ *this = nullopt; - this->construct(std::forward(args)...); + // Reference specialization stores a pointer; set it directly. + // construct() only exists in the non-reference specialization. + m_value = std::addressof(std::forward(args)...); -+ return *m_value; - } ++ return *m_value; \ No newline at end of file diff --git a/proj-web/CMakeLists.txt b/proj-web/CMakeLists.txt index 14284cb..473a959 100644 --- a/proj-web/CMakeLists.txt +++ b/proj-web/CMakeLists.txt @@ -169,6 +169,16 @@ target_include_directories(ShadowOverBishkekDemo PRIVATE ) # Сборка libzip через add_subdirectory (Emscripten соберет её из исходников) +set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) +set(BUILD_DOC OFF CACHE BOOL "" FORCE) +set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) +set(BUILD_OSSFUZZ OFF CACHE BOOL "" FORCE) +set(BUILD_REGRESS OFF CACHE BOOL "" FORCE) +set(BUILD_TOOLS OFF CACHE BOOL "" FORCE) +set(ENABLE_BZIP2 OFF CACHE BOOL "" FORCE) +set(ENABLE_LZMA OFF CACHE BOOL "" FORCE) +set(ENABLE_MBEDTLS OFF CACHE BOOL "" FORCE) +set(ENABLE_ZSTD OFF CACHE BOOL "" FORCE) set(ENABLE_GNUTLS OFF CACHE BOOL "" FORCE) set(ENABLE_OPENSSL OFF CACHE BOOL "" FORCE) set(ENABLE_WINDOWS_CRYPTO OFF CACHE BOOL "" FORCE) diff --git a/src/BoneAnimatedModelNew.cpp b/src/BoneAnimatedModelNew.cpp index 463908f..dd51604 100644 --- a/src/BoneAnimatedModelNew.cpp +++ b/src/BoneAnimatedModelNew.cpp @@ -1,4 +1,4 @@ -#include "BoneAnimatedModelNew.h" +#include "BoneAnimatedModelNew.h" #include #include #include @@ -8,7 +8,7 @@ namespace FRG { -#ifdef EMSCRIPTEN +#ifdef __EMSCRIPTEN__ using std::min; using std::max; #endif diff --git a/src/Environment.cpp b/src/Environment.cpp index f714cfd..3b344af 100644 --- a/src/Environment.cpp +++ b/src/Environment.cpp @@ -1,4 +1,4 @@ -#include "Environment.h" +#include "Environment.h" #include "utils/Utils.h" @@ -9,7 +9,7 @@ #include #endif -#ifdef EMSCRIPTEN +#ifdef __EMSCRIPTEN__ #include #endif @@ -27,7 +27,7 @@ bool Environment::enableLogging = false; SDL_Window* Environment::window = nullptr; -#ifdef EMSCRIPTEN +#ifdef __EMSCRIPTEN__ bool Environment::isFullscreen = false; #else bool Environment::isFullscreen = true; @@ -72,7 +72,7 @@ void Environment::computeProjectionDimensions() } void Environment::setFullscreen(bool enable) { -#ifdef EMSCRIPTEN +#ifdef __EMSCRIPTEN__ if (enable) { EmscriptenFullscreenStrategy strategy{}; strategy.scaleMode = EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH; diff --git a/src/Environment.h b/src/Environment.h index 816449a..9adddd4 100644 --- a/src/Environment.h +++ b/src/Environment.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #ifdef __linux__ #include #endif @@ -10,7 +10,7 @@ namespace FRG { -#ifdef EMSCRIPTEN +#ifdef __EMSCRIPTEN__ using std::min; using std::max; #endif diff --git a/src/Game.cpp b/src/Game.cpp index d6f3736..3d21beb 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -1,4 +1,4 @@ -#include "Game.h" +#include "Game.h" #include "AnimatedModel.h" #include "Localization.h" #include "utils/Utils.h" @@ -17,7 +17,7 @@ #endif -#ifdef EMSCRIPTEN +#ifdef __EMSCRIPTEN__ #include #endif @@ -34,7 +34,7 @@ namespace FRG static const float zoomMax = 20.0f; -#ifdef EMSCRIPTEN +#ifdef __EMSCRIPTEN__ const char* CONST_ZIP_FILE = "resources.zip"; const char* CONST_MUSIC_ZIP_FILE = "music.zip"; #else @@ -46,7 +46,7 @@ namespace FRG float y = 0; float z = 0; -#ifdef EMSCRIPTEN +#ifdef __EMSCRIPTEN__ Game* Game::s_instance = nullptr; // Коллбэк успешной загрузки resources.zip @@ -103,7 +103,7 @@ namespace FRG renderer.InitOpenGL(); //logger() << "Android test step 1 " << std::endl; -#if defined(EMSCRIPTEN) || defined(__ANDROID__) +#if defined(__EMSCRIPTEN__) || defined(__ANDROID__) // These shaders and loading.png are preloaded separately (not from zip), // so they are available immediately without waiting for resources.zip. //logger() << "Android test step 1 " << std::endl; @@ -143,7 +143,7 @@ namespace FRG loadingMesh.data = CreateRect2D({ 0.0f, 0.0f }, { minDimension * 0.5f, minDimension * 0.5f }, 3); loadingMesh.RefreshVBO(); -#ifdef EMSCRIPTEN +#ifdef __EMSCRIPTEN__ s_instance = this; std::string resPath = FRG::getPersistentResourcePath("resources.zip"); @@ -217,7 +217,7 @@ namespace FRG loadSteps.push([this]() { -#if defined(EMSCRIPTEN) || defined(__ANDROID__) +#if defined(__EMSCRIPTEN__) || defined(__ANDROID__) renderer.shaderManager.AddShaderFromFiles("env_sky", "resources/shaders/env_sky.vertex", "resources/shaders/env_sky_web.fragment", CONST_ZIP_FILE); renderer.shaderManager.AddShaderFromFiles("defaultAtmosphere", "resources/shaders/defaultAtmosphere.vertex", "resources/shaders/defaultAtmosphere_web.fragment", CONST_ZIP_FILE); renderer.shaderManager.AddShaderFromFiles("planetBake", "resources/shaders/planet_bake.vertex", "resources/shaders/planet_bake_web.fragment", CONST_ZIP_FILE); diff --git a/src/Game.h b/src/Game.h index b95cd43..1c2d7a9 100644 --- a/src/Game.h +++ b/src/Game.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "Character.h" #include "render/Renderer.h" #include "Environment.h" @@ -83,7 +83,7 @@ namespace FRG { void activateSlowMoEffect(); -#ifdef EMSCRIPTEN +#ifdef __EMSCRIPTEN__ static Game* s_instance; #endif @@ -163,7 +163,7 @@ namespace FRG { void endPinch(); int countNonUiPointers() const; -#ifdef EMSCRIPTEN +#ifdef __EMSCRIPTEN__ static void onResourcesZipLoaded(unsigned handle, void* userData, const char* filename); static void onResourcesZipError(unsigned handle, void* userData, int httpStatus); static void onResourcesZipProgress(unsigned handle, void* userData, int percentComplete); diff --git a/src/MenuManager.cpp b/src/MenuManager.cpp index 61ab985..1b45420 100644 --- a/src/MenuManager.cpp +++ b/src/MenuManager.cpp @@ -1,4 +1,4 @@ -#include "MenuManager.h" +#include "MenuManager.h" #include "Game.h" #include "Localization.h" #include "items/ItemRegistry.h" @@ -529,7 +529,7 @@ namespace FRG { -#if !defined(EMSCRIPTEN) && !defined(__ANDROID__) +#if !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) uiManager.setTextButtonCallback("menuExitButton", [this](const std::string&) { audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg"); Environment::exitGameLoop = true; @@ -581,7 +581,7 @@ namespace FRG { -#ifndef EMSCRIPTEN +#ifndef __EMSCRIPTEN__ uiManager.setTextButtonCallback("menuExitButton", [this](const std::string&) { audioPlayer_.playSoundAsync("resources/audio/751089__smallconfusion__mechanical-plastic-click-11.ogg"); Environment::exitGameLoop = true; @@ -2642,7 +2642,7 @@ namespace FRG { if (root.contains("soundEnabled")) audioPlayer_.setSoundEnabled(root["soundEnabled"].get()); if (root.contains("fullscreen")) { -#ifndef EMSCRIPTEN +#ifndef __EMSCRIPTEN__ Environment::setFullscreen(root["fullscreen"].get()); #endif } diff --git a/src/items/InteractiveObject.cpp b/src/items/InteractiveObject.cpp index c0445df..d02b30e 100644 --- a/src/items/InteractiveObject.cpp +++ b/src/items/InteractiveObject.cpp @@ -1,4 +1,4 @@ -#include "InteractiveObject.h" +#include "InteractiveObject.h" #include "render/Renderer.h" #include "render/TextureManager.h" #include "../TextModel.h" @@ -10,7 +10,7 @@ namespace FRG { extern const std::string textureUniformName; -#ifdef EMSCRIPTEN +#ifdef __EMSCRIPTEN__ using std::min; using std::max; #endif diff --git a/src/main.cpp b/src/main.cpp index 119d7e9..fd5d710 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,4 @@ -#include "Game.h" +#include "Game.h" #include "Environment.h" #include "utils/Utils.h" #include @@ -6,7 +6,7 @@ #include #endif -#ifdef EMSCRIPTEN +#ifdef __EMSCRIPTEN__ #include #include #endif @@ -50,7 +50,7 @@ void readSettings() } } -#if defined(EMSCRIPTEN) +#if defined(__EMSCRIPTEN__) static SDL_GLContext glContext_x; static bool g_isFsLoaded = false; // Флаг готовности @@ -109,7 +109,7 @@ static void applyResize(int logicalW, int logicalH) { #endif void MainLoop() { -#if defined(EMSCRIPTEN) +#if defined(__EMSCRIPTEN__) // Крутим цикл вхолостую, пока JS читает IndexedDB if (!g_isFsLoaded) return; @@ -128,7 +128,7 @@ void MainLoop() { g_game->update(); } -#ifdef EMSCRIPTEN +#ifdef __EMSCRIPTEN__ EM_BOOL onWebGLContextLost(int /*eventType*/, const void* /*reserved*/, void* /*userData*/) { @@ -482,7 +482,7 @@ int main(int argc, char* argv[]) { SDL_DestroyWindow(FRG::Environment::window); } //FRG::logger() << "Quitting step 8: " << std::endl; -#ifndef EMSCRIPTEN +#ifndef __EMSCRIPTEN__ // In Emscripten, SDL must stay alive across context loss/restore cycles // so the window remains valid when the game object is re-created. SDL_Quit(); diff --git a/src/render/OpenGlExtensions.h b/src/render/OpenGlExtensions.h index 2d644c9..aa6e851 100644 --- a/src/render/OpenGlExtensions.h +++ b/src/render/OpenGlExtensions.h @@ -1,8 +1,8 @@ -#pragma once +#pragma once #include "SDL.h" -#ifdef EMSCRIPTEN +#ifdef __EMSCRIPTEN__ //#define GL_GLEXT_PROTOTYPES 1 //#define EGL_EGLEXT_PROTOTYPES 1 //#include diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index bfa9e7f..3817b66 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -1,4 +1,4 @@ -#include "render/Renderer.h" +#include "render/Renderer.h" #include namespace FRG { @@ -116,7 +116,7 @@ namespace FRG { VAOHolder::VAOHolder() { -#ifndef EMSCRIPTEN +#ifndef __EMSCRIPTEN__ #ifndef ANDROID glGenVertexArrays(1, &vao); #endif @@ -125,7 +125,7 @@ namespace FRG { VAOHolder::~VAOHolder() { -#ifndef EMSCRIPTEN +#ifndef __EMSCRIPTEN__ #ifndef ANDROID #ifdef __linux__ glDeleteVertexArrays(1, &vao); @@ -382,7 +382,7 @@ namespace FRG { { //Check if main thread, check if data is not empty... -#ifndef EMSCRIPTEN +#ifndef __EMSCRIPTEN__ #ifndef __ANDROID__ if (!vao) { @@ -528,7 +528,7 @@ namespace FRG { glActiveTexture(GL_TEXTURE0); -#ifndef EMSCRIPTEN +#ifndef __EMSCRIPTEN__ #ifndef __ANDROID__ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); #endif @@ -922,7 +922,7 @@ namespace FRG { void Renderer::DrawVertexRenderStruct(const VertexRenderStruct& VertexRenderStruct) { -#ifndef EMSCRIPTEN +#ifndef __EMSCRIPTEN__ #ifndef __ANDROID__ if (VertexRenderStruct.vao) { glBindVertexArray(VertexRenderStruct.vao->getBuffer()); diff --git a/src/render/ShadowMap.cpp b/src/render/ShadowMap.cpp index ebca126..36c34cd 100644 --- a/src/render/ShadowMap.cpp +++ b/src/render/ShadowMap.cpp @@ -1,4 +1,4 @@ -#include "ShadowMap.h" +#include "ShadowMap.h" #include "Environment.h" #include #include @@ -56,7 +56,7 @@ namespace FRG { { glGenFramebuffers(1, &fbo); -#if defined(EMSCRIPTEN) || defined(__ANDROID__) +#if defined(__EMSCRIPTEN__) || defined(__ANDROID__) glGenTextures(1, &depthTexture); glBindTexture(GL_TEXTURE_2D, depthTexture); @@ -87,7 +87,7 @@ namespace FRG { GL_TEXTURE_2D, depthTexture, 0); // No color buffer for this FBO — depth only. -#if defined(EMSCRIPTEN) || defined(__ANDROID__) +#if defined(__EMSCRIPTEN__) || defined(__ANDROID__) GLenum drawBuffers[] = { GL_NONE }; glDrawBuffers(1, drawBuffers); #else diff --git a/src/render/TextureManager.cpp b/src/render/TextureManager.cpp index f7f30cd..8b10cfa 100644 --- a/src/render/TextureManager.cpp +++ b/src/render/TextureManager.cpp @@ -1,4 +1,4 @@ -#include "render/TextureManager.h" +#include "render/TextureManager.h" #include "render/OpenGlExtensions.h" #ifdef PNG_ENABLED #include "png.h" @@ -7,7 +7,7 @@ namespace FRG { -#ifdef EMSCRIPTEN +#ifdef __EMSCRIPTEN__ using std::min; using std::max; #endif @@ -88,7 +88,7 @@ namespace FRG case TextureDataStruct::R8: // Для WebGL 1.0 лучше использовать GL_LUMINANCE вместо GL_RED // Если используешь WebGL 2.0, можно оставить GL_RED -#if defined(EMSCRIPTEN) || defined(__ANDROID__) +#if defined(__EMSCRIPTEN__) || defined(__ANDROID__) internalFormat = GL_LUMINANCE; externalFormat = GL_LUMINANCE; #else @@ -167,7 +167,7 @@ namespace FRG glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); -#ifndef EMSCRIPTEN +#ifndef __EMSCRIPTEN__ #ifndef __ANDROID__ glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); #endif diff --git a/src/render/TextureManager.h b/src/render/TextureManager.h index 7f641ff..13984da 100644 --- a/src/render/TextureManager.h +++ b/src/render/TextureManager.h @@ -1,11 +1,11 @@ -#pragma once +#pragma once #include "render/OpenGlExtensions.h" #include "utils/Utils.h" #include #include -#if defined EMSCRIPTEN || defined __ANDROID__ +#if defined __EMSCRIPTEN__ || defined __ANDROID__ #define PNG_ENABLED #endif diff --git a/src/utils/TaskManager.cpp b/src/utils/TaskManager.cpp index 41b9dc6..6798188 100644 --- a/src/utils/TaskManager.cpp +++ b/src/utils/TaskManager.cpp @@ -1,4 +1,4 @@ -#include "TaskManager.h" +#include "TaskManager.h" namespace FRG @@ -6,7 +6,7 @@ namespace FRG TaskManager::TaskManager(size_t threadCount) { -#ifndef EMSCRIPTEN +#ifndef __EMSCRIPTEN__ workGuard = std::make_unique>(ioContext.get_executor()); for (size_t i = 0; i < threadCount; ++i) { @@ -18,7 +18,7 @@ namespace FRG } void TaskManager::EnqueueBackgroundTask(std::function task) { -#ifdef EMSCRIPTEN +#ifdef __EMSCRIPTEN__ task(); #else boost::asio::post(ioContext, task); @@ -26,7 +26,7 @@ namespace FRG } TaskManager::~TaskManager() { -#ifndef EMSCRIPTEN +#ifndef __EMSCRIPTEN__ workGuard.reset(); // Разрешаем ioContext.run() завершиться, когда задач не останется ioContext.stop(); // Опционально: немедленная остановка for (auto& t : workers) { @@ -36,7 +36,7 @@ namespace FRG } void MainThreadHandler::EnqueueMainThreadTask(std::function task) { -#ifndef EMSCRIPTEN +#ifndef __EMSCRIPTEN__ std::lock_guard lock(mainThreadMutex); #endif mainThreadTasks.push(task); @@ -45,7 +45,7 @@ namespace FRG void MainThreadHandler::processMainThreadTasks() { std::function task; -#ifdef EMSCRIPTEN +#ifdef __EMSCRIPTEN__ if (!mainThreadTasks.empty()) { task = std::move(mainThreadTasks.front()); mainThreadTasks.pop(); diff --git a/src/utils/TaskManager.h b/src/utils/TaskManager.h index daaa162..2bfe6be 100644 --- a/src/utils/TaskManager.h +++ b/src/utils/TaskManager.h @@ -1,6 +1,6 @@ -#pragma once +#pragma once -#ifndef EMSCRIPTEN +#ifndef __EMSCRIPTEN__ #include #include #endif @@ -15,7 +15,7 @@ namespace FRG { class TaskManager { private: -#ifndef EMSCRIPTEN +#ifndef __EMSCRIPTEN__ boost::asio::io_context ioContext; std::unique_ptr> workGuard; std::vector workers; @@ -29,7 +29,7 @@ namespace FRG { // Graceful shutdown ~TaskManager(); -#ifndef EMSCRIPTEN +#ifndef __EMSCRIPTEN__ boost::asio::io_context& getIOContext() { return ioContext; @@ -43,7 +43,7 @@ namespace FRG { private: std::queue> mainThreadTasks; -#ifndef EMSCRIPTEN +#ifndef __EMSCRIPTEN__ std::mutex mainThreadMutex; #endif public: diff --git a/src/utils/Utils.cpp b/src/utils/Utils.cpp index 290d095..4911951 100644 --- a/src/utils/Utils.cpp +++ b/src/utils/Utils.cpp @@ -1,4 +1,4 @@ -#include "utils/Utils.h" +#include "utils/Utils.h" #include #include #include @@ -110,7 +110,7 @@ namespace FRG return readFile(filename); } -#ifdef EMSCRIPTEN +#ifdef __EMSCRIPTEN__ std::string webZipFilename = getPersistentResourcePath(zipfilename); @@ -206,7 +206,7 @@ namespace FRG return false; } -#ifdef EMSCRIPTEN +#ifdef __EMSCRIPTEN__ std::string webZipFilename = getPersistentResourcePath(zipfilename); int zipErr = 0; @@ -320,7 +320,7 @@ namespace FRG #endif // На Web-платформе можно опустить имя разработчика, либо оставить для единообразия. - // Если в EMSCRIPTEN монтируется `/offline`, структура останется чистой. + // Если в __EMSCRIPTEN__ монтируется `/offline`, структура останется чистой. return baseDir / "Fish Run Games" / "Shadow Over Bishkek Demo"; }