diff --git a/.github/workflows/github.yml b/.github/workflows/github.yml index 2220e982e..0a29cdcef 100644 --- a/.github/workflows/github.yml +++ b/.github/workflows/github.yml @@ -90,6 +90,12 @@ jobs: preset: macos-arm-conan-ninja-release conan_profile: macos-arm artifact_platform: arm + - platform: ios + os: macos-12 + test: 0 + pack: 1 + extension: ipa + preset: ios-release - platform: mxe os: ubuntu-20.04 mxe: i686-w64-mingw32.shared @@ -189,6 +195,8 @@ jobs: cd '${{github.workspace}}/out/build/${{matrix.preset}}' CPACK_PATH=`which -a cpack | grep -m1 -v -i chocolatey` "$CPACK_PATH" -C ${{env.BUILD_TYPE}} ${{ matrix.cpack_args }} + test -f '${{github.workspace}}/CI/${{matrix.platform}}/post_pack.sh' \ + && '${{github.workspace}}/CI/${{matrix.platform}}/post_pack.sh' '${{github.workspace}}' "$(ls '${{ env.VCMI_PACKAGE_FILE_NAME }}'.*)" rm -rf _CPack_Packages - name: Additional logs diff --git a/.gitignore b/.gitignore index fb947fc5c..c91559bcd 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,8 @@ doc/* VCMI_VS11.sdf *.ipch VCMI_VS11.opensdf +.DS_Store +CMakeUserPresets.json # Visual Studio *.suo diff --git a/AI/BattleAI/BattleAI.h b/AI/BattleAI/BattleAI.h index 47dc84c47..82cecacc8 100644 --- a/AI/BattleAI/BattleAI.h +++ b/AI/BattleAI/BattleAI.h @@ -13,7 +13,12 @@ #include "PossibleSpellcast.h" #include "PotentialTargets.h" +VCMI_LIB_NAMESPACE_BEGIN + class CSpell; + +VCMI_LIB_NAMESPACE_END + class EnemyInfo; /* diff --git a/AI/BattleAI/CMakeLists.txt b/AI/BattleAI/CMakeLists.txt index 527ccdcd3..415ec9e79 100644 --- a/AI/BattleAI/CMakeLists.txt +++ b/AI/BattleAI/CMakeLists.txt @@ -33,7 +33,7 @@ endif() add_library(BattleAI SHARED ${battleAI_SRCS} ${battleAI_HEADERS}) target_include_directories(BattleAI PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(BattleAI PRIVATE vcmi) +target_link_libraries(BattleAI PRIVATE ${VCMI_LIB_TARGET}) vcmi_set_output_dir(BattleAI "AI") enable_pch(BattleAI) diff --git a/AI/BattleAI/EnemyInfo.h b/AI/BattleAI/EnemyInfo.h index 874e9e2b6..e9cb803de 100644 --- a/AI/BattleAI/EnemyInfo.h +++ b/AI/BattleAI/EnemyInfo.h @@ -9,11 +9,15 @@ */ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + namespace battle { class Unit; } +VCMI_LIB_NAMESPACE_END + class EnemyInfo { public: diff --git a/AI/BattleAI/PossibleSpellcast.h b/AI/BattleAI/PossibleSpellcast.h index 806832ad5..a4e0021c7 100644 --- a/AI/BattleAI/PossibleSpellcast.h +++ b/AI/BattleAI/PossibleSpellcast.h @@ -14,8 +14,12 @@ #include "../../lib/battle/Destination.h" +VCMI_LIB_NAMESPACE_BEGIN + class CSpell; +VCMI_LIB_NAMESPACE_END + class PossibleSpellcast { public: diff --git a/AI/BattleAI/StackWithBonuses.h b/AI/BattleAI/StackWithBonuses.h index eb8d57db5..75015503f 100644 --- a/AI/BattleAI/StackWithBonuses.h +++ b/AI/BattleAI/StackWithBonuses.h @@ -18,9 +18,14 @@ #include "../../lib/battle/BattleProxy.h" #include "../../lib/battle/CUnitState.h" -class HypotheticBattle; +VCMI_LIB_NAMESPACE_BEGIN + class CStack; +VCMI_LIB_NAMESPACE_END + +class HypotheticBattle; + ///Fake random generator, used by AI to evaluate random server behavior class RNGStub : public vstd::RNG { diff --git a/AI/BattleAI/StdInc.h b/AI/BattleAI/StdInc.h index 1e6eda607..ba1e8b9ee 100644 --- a/AI/BattleAI/StdInc.h +++ b/AI/BattleAI/StdInc.h @@ -13,3 +13,5 @@ // This header should be treated as a pre compiled header file(PCH) in the compiler building settings. // Here you can add specific libraries and macros which are specific to this project. + +VCMI_LIB_USING_NAMESPACE diff --git a/AI/EmptyAI/CMakeLists.txt b/AI/EmptyAI/CMakeLists.txt index 7d2c38377..b8656cc93 100644 --- a/AI/EmptyAI/CMakeLists.txt +++ b/AI/EmptyAI/CMakeLists.txt @@ -15,9 +15,9 @@ assign_source_group(${emptyAI_SRCS} ${emptyAI_HEADERS}) add_library(EmptyAI SHARED ${emptyAI_SRCS} ${emptyAI_HEADERS}) target_include_directories(EmptyAI PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(EmptyAI PRIVATE vcmi) +target_link_libraries(EmptyAI PRIVATE ${VCMI_LIB_TARGET}) vcmi_set_output_dir(EmptyAI "AI") enable_pch(EmptyAI) -install(TARGETS EmptyAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR}) +install(TARGETS EmptyAI RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR} OPTIONAL) diff --git a/AI/Nullkiller/AIGateway.h b/AI/Nullkiller/AIGateway.h index f940853f1..29066be81 100644 --- a/AI/Nullkiller/AIGateway.h +++ b/AI/Nullkiller/AIGateway.h @@ -25,8 +25,12 @@ #include "Pathfinding/AIPathfinder.h" #include "Engine/Nullkiller.h" +VCMI_LIB_NAMESPACE_BEGIN + struct QuestInfo; +VCMI_LIB_NAMESPACE_END + class AIStatus { boost::mutex mx; diff --git a/AI/Nullkiller/CMakeLists.txt b/AI/Nullkiller/CMakeLists.txt index e35e92af2..0ccf0a281 100644 --- a/AI/Nullkiller/CMakeLists.txt +++ b/AI/Nullkiller/CMakeLists.txt @@ -130,7 +130,7 @@ add_library(Nullkiller SHARED ${Nullkiller_SRCS} ${Nullkiller_HEADERS}) target_include_directories(Nullkiller PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(Nullkiller PRIVATE vcmi fuzzylite::fuzzylite) +target_link_libraries(Nullkiller PRIVATE ${VCMI_LIB_TARGET} fuzzylite::fuzzylite) target_link_libraries(Nullkiller PRIVATE TBB::tbb) @@ -138,3 +138,6 @@ vcmi_set_output_dir(Nullkiller "AI") enable_pch(Nullkiller) install(TARGETS Nullkiller RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR}) +if(APPLE_IOS) + install(IMPORTED_RUNTIME_ARTIFACTS TBB::tbb LIBRARY DESTINATION ${LIB_DIR}) # CMake 3.21+ +endif() diff --git a/AI/Nullkiller/Engine/FuzzyEngines.h b/AI/Nullkiller/Engine/FuzzyEngines.h index c0fbba89a..0e0c533da 100644 --- a/AI/Nullkiller/Engine/FuzzyEngines.h +++ b/AI/Nullkiller/Engine/FuzzyEngines.h @@ -11,8 +11,12 @@ #include #include "../Goals/AbstractGoal.h" +VCMI_LIB_NAMESPACE_BEGIN + class CArmedInstance; +VCMI_LIB_NAMESPACE_END + class engineBase //subclasses create fuzzylite variables with "new" that are not freed - this is desired as fl::Engine wants to destroy these... { protected: diff --git a/AI/Nullkiller/Engine/FuzzyHelper.h b/AI/Nullkiller/Engine/FuzzyHelper.h index f9bfcf23a..760b34279 100644 --- a/AI/Nullkiller/Engine/FuzzyHelper.h +++ b/AI/Nullkiller/Engine/FuzzyHelper.h @@ -10,7 +10,12 @@ #pragma once #include "FuzzyEngines.h" +VCMI_LIB_NAMESPACE_BEGIN + class CBank; + +VCMI_LIB_NAMESPACE_END + class Nullkiller; class DLL_EXPORT FuzzyHelper diff --git a/AI/Nullkiller/Engine/PriorityEvaluator.h b/AI/Nullkiller/Engine/PriorityEvaluator.h index 6bcd09c32..6156c08c2 100644 --- a/AI/Nullkiller/Engine/PriorityEvaluator.h +++ b/AI/Nullkiller/Engine/PriorityEvaluator.h @@ -12,9 +12,14 @@ #include "../Goals/CGoal.h" #include "../Pathfinding/AIPathfinder.h" +VCMI_LIB_NAMESPACE_BEGIN + +class CGWitchHut; + +VCMI_LIB_NAMESPACE_END + class BuildingInfo; class Nullkiller; -class CGWitchHut; class RewardEvaluator { diff --git a/AI/Nullkiller/Pathfinding/Actors.cpp b/AI/Nullkiller/Pathfinding/Actors.cpp index e6806a0b2..d4905d462 100644 --- a/AI/Nullkiller/Pathfinding/Actors.cpp +++ b/AI/Nullkiller/Pathfinding/Actors.cpp @@ -164,6 +164,7 @@ ExchangeResult ChainActor::tryExchangeNoLock(const ChainActor * specialActor, co return baseActor->tryExchangeNoLock(specialActor, other); } +VCMI_LIB_NAMESPACE_BEGIN namespace vstd { template @@ -180,6 +181,7 @@ namespace vstd return v; } } +VCMI_LIB_NAMESPACE_END ExchangeResult HeroActor::tryExchangeNoLock(const ChainActor * specialActor, const ChainActor * other) const { diff --git a/AI/Nullkiller/StdInc.h b/AI/Nullkiller/StdInc.h index 2e1a36a05..50855f6e5 100644 --- a/AI/Nullkiller/StdInc.h +++ b/AI/Nullkiller/StdInc.h @@ -1,3 +1,4 @@ #pragma once #include "../../Global.h" +VCMI_LIB_USING_NAMESPACE #include "../../CCallback.h" diff --git a/AI/StupidAI/CMakeLists.txt b/AI/StupidAI/CMakeLists.txt index 1943fa2ff..9230b57c3 100644 --- a/AI/StupidAI/CMakeLists.txt +++ b/AI/StupidAI/CMakeLists.txt @@ -14,7 +14,7 @@ set(stupidAI_HEADERS assign_source_group(${stupidAI_SRCS} ${stupidAI_HEADERS}) add_library(StupidAI SHARED ${stupidAI_SRCS} ${stupidAI_HEADERS}) -target_link_libraries(StupidAI PRIVATE vcmi) +target_link_libraries(StupidAI PRIVATE ${VCMI_LIB_TARGET}) target_include_directories(StupidAI PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) vcmi_set_output_dir(StupidAI "AI") diff --git a/AI/StupidAI/StdInc.h b/AI/StupidAI/StdInc.h index 81a6cb308..02b2c08f3 100644 --- a/AI/StupidAI/StdInc.h +++ b/AI/StupidAI/StdInc.h @@ -4,4 +4,6 @@ // This header should be treated as a pre compiled header file(PCH) in the compiler building settings. -// Here you can add specific libraries and macros which are specific to this project. \ No newline at end of file +// Here you can add specific libraries and macros which are specific to this project. + +VCMI_LIB_USING_NAMESPACE diff --git a/AI/VCAI/CMakeLists.txt b/AI/VCAI/CMakeLists.txt index e96423834..259129afe 100644 --- a/AI/VCAI/CMakeLists.txt +++ b/AI/VCAI/CMakeLists.txt @@ -107,7 +107,7 @@ add_library(VCAI SHARED ${VCAI_SRCS} ${VCAI_HEADERS}) target_include_directories(VCAI PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(VCAI PRIVATE vcmi fuzzylite::fuzzylite) +target_link_libraries(VCAI PRIVATE ${VCMI_LIB_TARGET} fuzzylite::fuzzylite) vcmi_set_output_dir(VCAI "AI") enable_pch(VCAI) diff --git a/AI/VCAI/FuzzyEngines.h b/AI/VCAI/FuzzyEngines.h index 95a58c482..f09920da7 100644 --- a/AI/VCAI/FuzzyEngines.h +++ b/AI/VCAI/FuzzyEngines.h @@ -11,8 +11,12 @@ #include #include "Goals/AbstractGoal.h" +VCMI_LIB_NAMESPACE_BEGIN + class CArmedInstance; +VCMI_LIB_NAMESPACE_END + class engineBase //subclasses create fuzzylite variables with "new" that are not freed - this is desired as fl::Engine wants to destroy these... { protected: diff --git a/AI/VCAI/FuzzyHelper.h b/AI/VCAI/FuzzyHelper.h index 036374acb..6973df463 100644 --- a/AI/VCAI/FuzzyHelper.h +++ b/AI/VCAI/FuzzyHelper.h @@ -10,8 +10,12 @@ #pragma once #include "FuzzyEngines.h" +VCMI_LIB_NAMESPACE_BEGIN + class CBank; +VCMI_LIB_NAMESPACE_END + class DLL_EXPORT FuzzyHelper { public: diff --git a/AI/VCAI/StdInc.h b/AI/VCAI/StdInc.h index 2bc4c254b..0c0f05a6b 100644 --- a/AI/VCAI/StdInc.h +++ b/AI/VCAI/StdInc.h @@ -1,2 +1,4 @@ #pragma once #include "../../Global.h" + +VCMI_LIB_USING_NAMESPACE diff --git a/AI/VCAI/VCAI.cpp b/AI/VCAI/VCAI.cpp index d24f171be..7f42b8d70 100644 --- a/AI/VCAI/VCAI.cpp +++ b/AI/VCAI/VCAI.cpp @@ -29,8 +29,12 @@ extern FuzzyHelper * fh; +VCMI_LIB_NAMESPACE_BEGIN + class CGVisitableOPW; +VCMI_LIB_NAMESPACE_END + const double SAFE_ATTACK_CONSTANT = 1.5; //one thread may be turn of AI and another will be handling a side effect for AI2 diff --git a/AI/VCAI/VCAI.h b/AI/VCAI/VCAI.h index f19fed2ba..acb6e5f5d 100644 --- a/AI/VCAI/VCAI.h +++ b/AI/VCAI/VCAI.h @@ -26,8 +26,12 @@ #include "../../lib/CondSh.h" #include "Pathfinding/AIPathfinder.h" +VCMI_LIB_NAMESPACE_BEGIN + struct QuestInfo; +VCMI_LIB_NAMESPACE_END + class AIhelper; class AIStatus diff --git a/AUTHORS b/AUTHORS index c58bbfd79..079f813e3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -78,6 +78,9 @@ Andrii Danylchenko Dmitry Orlov, * special buildings support in fan towns, new features and bug fixes - -Andrey Cherkas aka nordsoft, - * new terrain support, random map generator features and various bug fixes \ No newline at end of file + +Andrey Cherkas aka nordsoft, + * new terrain support, random map generator features and various bug fixes + +Andrey Filipenkov aka kambala-decapitator, + * iOS support, macOS improvements, various bug fixes diff --git a/CCallback.h b/CCallback.h index 36d93898a..6986153f1 100644 --- a/CCallback.h +++ b/CCallback.h @@ -13,6 +13,8 @@ #include "lib/battle/CPlayerBattleCallback.h" #include "lib/int3.h" // for int3 +VCMI_LIB_NAMESPACE_BEGIN + class CGHeroInstance; class CGameState; struct CPath; @@ -20,18 +22,22 @@ class CGObjectInstance; class CArmedInstance; class BattleAction; class CGTownInstance; -struct lua_State; -class CClient; class IShipyard; struct CGPathNode; struct CGPath; struct CPathsInfo; class PathfinderConfig; struct CPack; +struct CPackForServer; class IBattleEventsReceiver; class IGameEventsReceiver; struct ArtifactLocation; +VCMI_LIB_NAMESPACE_END + +class CClient; +struct lua_State; + class IBattleCallback { public: @@ -88,8 +94,6 @@ public: virtual int bulkMergeStacks(ObjectInstanceID armyId, SlotID srcSlot) = 0; }; -struct CPackForServer; - class CBattleCallback : public IBattleCallback, public CPlayerBattleCallback { protected: diff --git a/CI/ios/before_install.sh b/CI/ios/before_install.sh new file mode 100755 index 000000000..b19cd9828 --- /dev/null +++ b/CI/ios/before_install.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +echo DEVELOPER_DIR=/Applications/Xcode_13.4.1.app >> $GITHUB_ENV + +curl -L 'https://github.com/vcmi/vcmi-ios-deps/releases/latest/download/vcmi-ios-depends-xc13.2.1.txz' \ + | tar -xf - +build/fix_install_paths.command diff --git a/CI/ios/post_pack.sh b/CI/ios/post_pack.sh new file mode 100755 index 000000000..8fc66bd3d --- /dev/null +++ b/CI/ios/post_pack.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +"$1/ios/zip2ipa.sh" "$2" diff --git a/CMakeLists.txt b/CMakeLists.txt index 472a65cef..7b56ad53f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,18 @@ project(VCMI) # It's used currently to make sure that 3rd-party dependencies in git submodules get proper FOLDER property # - Make FindFuzzyLite check for the right version and disable FORCE_BUNDLED_FL by default +if(APPLE) + if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + set(APPLE_MACOS 1) + else() + set(APPLE_IOS 1) + endif() +endif() + +if(APPLE_IOS) + set(BUILD_SINGLE_APP 1) +endif() + ############################################ # User-provided options # ############################################ @@ -41,10 +53,19 @@ set(VCMI_VERSION_MAJOR 1) set(VCMI_VERSION_MINOR 0) set(VCMI_VERSION_PATCH 0) +set(APP_SHORT_VERSION "${VCMI_VERSION_MAJOR}.${VCMI_VERSION_MINOR}") +if(NOT VCMI_VERSION_PATCH EQUAL 0) + string(APPEND APP_SHORT_VERSION ".${VCMI_VERSION_PATCH}") +endif() + option(ENABLE_ERM "Enable compilation of ERM scripting module" OFF) option(ENABLE_LUA "Enable compilation of LUA scripting module" OFF) option(ENABLE_LAUNCHER "Enable compilation of launcher" ON) -option(ENABLE_TEST "Enable compilation of unit tests" ON) +if(APPLE_IOS) + set(BUNDLE_IDENTIFIER_PREFIX "" CACHE STRING "Bundle identifier prefix") +else() + option(ENABLE_TEST "Enable compilation of unit tests" ON) +endif() if(NOT ${CMAKE_VERSION} VERSION_LESS "3.16.0") option(ENABLE_PCH "Enable compilation using precompiled headers" ON) endif(NOT ${CMAKE_VERSION} VERSION_LESS "3.16.0") @@ -53,7 +74,9 @@ option(ENABLE_DEBUG_CONSOLE "Enable debug console for Windows builds" ON) option(ENABLE_MULTI_PROCESS_BUILDS "Enable /MP flag for MSVS solution" ON) # Used for Snap packages and also useful for debugging -option(ENABLE_MONOLITHIC_INSTALL "Install everything in single directory on Linux and Mac" OFF) +if(NOT APPLE_IOS) + option(ENABLE_MONOLITHIC_INSTALL "Install everything in single directory on Linux and Mac" OFF) +endif() # Allow to pass package name from Travis CI set(PACKAGE_NAME_SUFFIX "" CACHE STRING "Suffix for CPack package name") @@ -133,6 +156,34 @@ set(CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL MinSizeRel Release RelWithDebInfo "") # Release falls back to RelWithDebInfo, then MinSizeRel set(CMAKE_MAP_IMPORTED_CONFIG_RELEASE Release RelWithDebInfo MinSizeRel "") +set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES) +set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT[variant=Debug] dwarf) +set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE NO) +set(CMAKE_XCODE_ATTRIBUTE_ENABLE_NS_ASSERTIONS NO) +set(CMAKE_XCODE_ATTRIBUTE_ENABLE_NS_ASSERTIONS[variant=Debug] YES) +set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_64_TO_32_BIT_CONVERSION NO) +set(CMAKE_XCODE_ATTRIBUTE_MARKETING_VERSION ${APP_SHORT_VERSION}) +set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH NO) +set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH[variant=Debug] YES) + +if(BUILD_SINGLE_APP) + add_compile_definitions(SINGLE_PROCESS_APP=1) +endif() + +if(APPLE_IOS) + set(CMAKE_MACOSX_RPATH 1) + set(CMAKE_OSX_DEPLOYMENT_TARGET 10.0) + + list(APPEND CMAKE_FIND_ROOT_PATH "${CMAKE_PREFIX_PATH}") # required for Boost + set(CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH FALSE) + set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH FALSE) + + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED NO) + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED_FOR_APPS YES) + set(CMAKE_XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${BUNDLE_IDENTIFIER_PREFIX}.$(PRODUCT_NAME)") + set(CMAKE_XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2") +endif() + if(MINGW OR MSVC) # Windows Vista or newer for FuzzyLite 6 to compile add_definitions(-D_WIN32_WINNT=0x0600) @@ -209,7 +260,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR NOT WIN32) #so far all *nix compilers support suc endif() # Check if some platform-specific libraries are needed for linking -if(NOT WIN32) +if(NOT WIN32 AND NOT APPLE_IOS) include(CheckLibraryExists) # Shared memory functions used by Boost.Interprocess @@ -236,7 +287,12 @@ if(TARGET zlib::zlib) add_library(ZLIB::ZLIB ALIAS zlib::zlib) endif() -find_package(ffmpeg COMPONENTS avutil swscale avformat avcodec) +set(FFMPEG_COMPONENTS avutil swscale avformat avcodec) +if(APPLE_IOS) + list(APPEND FFMPEG_COMPONENTS swresample) +endif() +find_package(ffmpeg COMPONENTS ${FFMPEG_COMPONENTS}) + option(FORCE_BUNDLED_MINIZIP "Force bundled Minizip library" OFF) if(NOT FORCE_BUNDLED_MINIZIP) find_package(minizip) @@ -306,14 +362,19 @@ elseif(APPLE) set(LIB_DIR "." CACHE STRING "Where to install main library") set(DATA_DIR "." CACHE STRING "Where to install data files") else() - set(APP_BUNDLE_DIR "${CMAKE_PROJECT_NAME}.app") - set(APP_BUNDLE_CONTENTS_DIR "${APP_BUNDLE_DIR}/Contents") - set(APP_BUNDLE_BINARY_DIR "${APP_BUNDLE_CONTENTS_DIR}/MacOS") - set(APP_BUNDLE_RESOURCES_DIR "${APP_BUNDLE_CONTENTS_DIR}/Resources") + if(APPLE_MACOS) + set(APP_BUNDLE_DIR "${CMAKE_PROJECT_NAME}.app") + set(APP_BUNDLE_CONTENTS_DIR "${APP_BUNDLE_DIR}/Contents") + set(APP_BUNDLE_BINARY_DIR "${APP_BUNDLE_CONTENTS_DIR}/MacOS") + set(APP_BUNDLE_RESOURCES_DIR "${APP_BUNDLE_CONTENTS_DIR}/Resources") - set(BIN_DIR "${APP_BUNDLE_BINARY_DIR}" CACHE STRING "Where to install binaries") - set(LIB_DIR "${APP_BUNDLE_CONTENTS_DIR}/Frameworks" CACHE STRING "Where to install main library") - set(DATA_DIR "${APP_BUNDLE_RESOURCES_DIR}/Data" CACHE STRING "Where to install data files") + set(BIN_DIR "${APP_BUNDLE_BINARY_DIR}" CACHE STRING "Where to install binaries") + set(LIB_DIR "${APP_BUNDLE_CONTENTS_DIR}/Frameworks" CACHE STRING "Where to install main library") + set(DATA_DIR "${APP_BUNDLE_RESOURCES_DIR}/Data" CACHE STRING "Where to install data files") + else() + set(LIB_DIR "Frameworks") + set(DATA_DIR ".") + endif() endif() else() # includes lib path which determines where to install shared libraries (either /lib or /lib64) @@ -349,6 +410,20 @@ set(SCRIPTING_LIB_DIR "${LIB_DIR}/scripting") # Add subdirectories # ####################################### +if(APPLE_IOS) + add_subdirectory(ios) +endif() + +include(VCMI_lib) +if(BUILD_SINGLE_APP) + add_subdirectory(lib_client) + add_subdirectory(lib_server) + set(VCMI_LIB_TARGET vcmi_lib_client) +else() + add_subdirectory(lib) + set(VCMI_LIB_TARGET vcmi) +endif() + if(ENABLE_ERM) add_subdirectory(scripting/erm) endif() @@ -359,13 +434,13 @@ if(NOT TARGET minizip::minizip) add_subdirectory_with_folder("3rdparty" lib/minizip) add_library(minizip::minizip ALIAS minizip) endif() -add_subdirectory(lib) -add_subdirectory(client) -add_subdirectory(server) -add_subdirectory_with_folder("AI" AI) + if(ENABLE_LAUNCHER) add_subdirectory(launcher) endif() +add_subdirectory(client) +add_subdirectory(server) +add_subdirectory_with_folder("AI" AI) if(ENABLE_TEST) enable_testing() add_subdirectory(test) @@ -376,11 +451,13 @@ endif() ####################################### install(DIRECTORY config DESTINATION ${DATA_DIR}) -install(DIRECTORY scripts DESTINATION ${DATA_DIR}) install(DIRECTORY Mods DESTINATION ${DATA_DIR}) +if(ENABLE_LUA) + install(DIRECTORY scripts DESTINATION ${DATA_DIR}) +endif() -# that script is useless for Windows -if(NOT WIN32) +# that script is useless for Windows and iOS +if(NOT WIN32 AND NOT APPLE_IOS) install(FILES vcmibuilder DESTINATION ${BIN_DIR} PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE @@ -490,7 +567,7 @@ if(WIN32) add_subdirectory(osx) add_subdirectory(win) endif() -elseif(APPLE AND NOT ENABLE_MONOLITHIC_INSTALL) +elseif(APPLE_MACOS AND NOT ENABLE_MONOLITHIC_INSTALL) set(CPACK_MONOLITHIC_INSTALL 1) set(CPACK_GENERATOR "DragNDrop") set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/osx/dmg_background.png") @@ -520,6 +597,10 @@ elseif(APPLE AND NOT ENABLE_MONOLITHIC_INSTALL) # Bundle fixing code must be in separate directory to be executed after all other install code add_subdirectory(osx) +elseif(APPLE_IOS) + set(CPACK_GENERATOR ZIP) + set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF) + set(CPACK_INSTALL_CMAKE_PROJECTS "${CMAKE_CURRENT_BINARY_DIR};${CMAKE_PROJECT_NAME};app;/") else() set(CPACK_GENERATOR TGZ) endif() diff --git a/CMakePresets.json b/CMakePresets.json index 20a5a23ed..dc9db320c 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -2,19 +2,31 @@ "version": 2, "configurePresets": [ { - "name": "default-release", + "name": "release-binary-dir", + "hidden": true, + "binaryDir": "${sourceDir}/out/build/${presetName}" + }, + { + "name": "base-release", + "inherits": "release-binary-dir", "hidden": true, - "binaryDir": "${sourceDir}/out/build/${presetName}", - "generator": "Ninja", "cacheVariables": { "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}", "PACKAGE_FILE_NAME" : "$env{VCMI_PACKAGE_FILE_NAME}", "PACKAGE_NAME_SUFFIX" : "$env{VCMI_PACKAGE_NAME_SUFFIX}", "CMAKE_BUILD_TYPE": "RelWithDebInfo", - "FORCE_BUNDLED_FL": "OFF", "ENABLE_TEST": "OFF" } }, + { + "name": "default-release", + "inherits": "base-release", + "hidden": true, + "generator": "Ninja", + "cacheVariables": { + "FORCE_BUNDLED_FL": "OFF" + } + }, { "name" : "linux-release", "inherits" : "default-release", @@ -87,6 +99,41 @@ "description": "VCMI MacOS Xcode", "inherits": "default-release", "generator": "Xcode" + }, + { + "name": "ios-device", + "displayName": "Base iOS device", + "description": "Base VCMI preset for iOS device", + "generator": "Xcode", + "binaryDir": "../build-${presetName}", + "cacheVariables": { + "CMAKE_SYSTEM_NAME": "iOS", + "FORCE_BUNDLED_FL": "ON", + "FORCE_BUNDLED_MINIZIP": "ON" + } + }, + { + "name": "ios-simulator", + "displayName": "Base iOS simulator", + "description": "Base VCMI preset for iOS simulator", + "inherits": "ios-device", + "cacheVariables": { + "CMAKE_OSX_SYSROOT": "iphonesimulator" + } + }, + { + "name": "ios-release", + "displayName": "iOS release", + "description": "VCMI iOS release", + "inherits": [ + "base-release", + "ios-device", + "release-binary-dir" + ], + "cacheVariables": { + "BUNDLE_IDENTIFIER_PREFIX": "eu.vcmi", + "CMAKE_PREFIX_PATH": "${sourceDir}/build/iphoneos" + } } ], "buildPresets": [ @@ -135,6 +182,16 @@ "name": "windows-msvc-relwithdebinfo", "configurePreset": "windows-msvc-release", "inherits": "default-release" + }, + { + "name": "ios-release", + "configurePreset": "ios-release", + "inherits": "default-release", + "configuration": "Release", + "targets": ["vcmiclient"], + "nativeToolOptions": [ + "CODE_SIGNING_ALLOWED_FOR_APPS=NO" + ] } ], "testPresets": [ @@ -172,4 +229,4 @@ "inherits": "default-release" } ] -} \ No newline at end of file +} diff --git a/Global.h b/Global.h index 5bce068d7..80776b24f 100644 --- a/Global.h +++ b/Global.h @@ -68,7 +68,7 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size."); # define VCMI_UNIX # define VCMI_APPLE # include "TargetConditionals.h" -# if TARGET_IPHONE_SIMULATOR +# if TARGET_OS_SIMULATOR || TARGET_IPHONE_SIMULATOR # define VCMI_IOS # define VCMI_IOS_SIM # elif TARGET_OS_IPHONE @@ -82,10 +82,6 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size."); # error "VCMI supports only Windows, OSX, Linux and Android targets" #endif -#ifdef VCMI_IOS -# error "iOS system isn't yet supported." -#endif - // Each compiler uses own way to supress fall through warning. Try to find it. #ifdef __has_cpp_attribute # if __has_cpp_attribute(fallthrough) @@ -268,11 +264,35 @@ template char (&_ArrayCountObj(const T (&)[N]))[N]; // should be used for variables that becomes unused in release builds (e.g. only used for assert checks) #define UNUSED(VAR) ((void)VAR) +// old iOS SDKs compatibility +#ifdef VCMI_IOS +#include + +#ifndef __IPHONE_13_0 +#define __IPHONE_13_0 130000 +#endif +#endif // VCMI_IOS + +// single-process build makes 2 copies of the main lib by wrapping it in a namespace +#ifdef VCMI_LIB_NAMESPACE +#define VCMI_LIB_NAMESPACE_BEGIN namespace VCMI_LIB_NAMESPACE { +#define VCMI_LIB_NAMESPACE_END } +#define VCMI_LIB_USING_NAMESPACE using namespace VCMI_LIB_NAMESPACE; +#define VCMI_LIB_WRAP_NAMESPACE(x) VCMI_LIB_NAMESPACE::x +#else +#define VCMI_LIB_NAMESPACE_BEGIN +#define VCMI_LIB_NAMESPACE_END +#define VCMI_LIB_USING_NAMESPACE +#define VCMI_LIB_WRAP_NAMESPACE(x) x +#endif + /* ---------------------------------------------------------------------------- */ /* VCMI standard library */ /* ---------------------------------------------------------------------------- */ #include +VCMI_LIB_NAMESPACE_BEGIN + void inline handleException() { try @@ -743,3 +763,5 @@ namespace std } } #endif // NO_STD_TOSTRING + +VCMI_LIB_NAMESPACE_END diff --git a/README.md b/README.md index 76a9ea11a..ea125e563 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ To use VCMI you need to own original data files. * [Linux](https://wiki.vcmi.eu/Installation_on_Linux) * [macOS](https://wiki.vcmi.eu/Installation_on_macOS) * [Windows](https://wiki.vcmi.eu/Installation_on_Windows) + * [iOS](https://wiki.vcmi.eu/Installation_on_iOS) ## Building from source @@ -29,6 +30,7 @@ Platform support is constantly tested by continuous integration and CMake config * [On Linux for Windows with MXE](https://wiki.vcmi.eu/How_to_build_VCMI_(Linux/Cmake/MXE)) * [On macOS](https://wiki.vcmi.eu/How_to_build_VCMI_(macOS)) * [On Windows using MSVC and Vcpkg](https://wiki.vcmi.eu/How_to_build_VCMI_(Windows/Vcpkg)) + * [iOS on macOS](https://wiki.vcmi.eu/How_to_build_VCMI_(iOS)) ## Copyright and license diff --git a/Version.cpp.in b/Version.cpp.in index 3198034f1..3efea1c74 100644 --- a/Version.cpp.in +++ b/Version.cpp.in @@ -9,7 +9,11 @@ */ #include "Version.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace GameConstants { const char GIT_SHA1[] = "@GIT_SHA1@"; } + +VCMI_LIB_NAMESPACE_END diff --git a/Version.h b/Version.h index 93adced57..a1f1b97d5 100644 --- a/Version.h +++ b/Version.h @@ -1,6 +1,12 @@ #pragma once +#include "StdInc.h" + +VCMI_LIB_NAMESPACE_BEGIN + namespace GameConstants { extern const char GIT_SHA1[]; } + +VCMI_LIB_NAMESPACE_END diff --git a/client/CFocusableHelper.cpp b/client/CFocusableHelper.cpp new file mode 100644 index 000000000..e4e3c6cfe --- /dev/null +++ b/client/CFocusableHelper.cpp @@ -0,0 +1,21 @@ +/* + * CFocusableHelper.cpp, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ +#include "CFocusableHelper.h" +#include "../Global.h" +#include "widgets/TextControls.h" + +void removeFocusFromActiveInput() +{ + if(CFocusable::inputWithFocus == nullptr) + return; + CFocusable::inputWithFocus->focus = false; + CFocusable::inputWithFocus->redraw(); + CFocusable::inputWithFocus = nullptr; +} diff --git a/client/CFocusableHelper.h b/client/CFocusableHelper.h new file mode 100644 index 000000000..6ee0927a3 --- /dev/null +++ b/client/CFocusableHelper.h @@ -0,0 +1,11 @@ +/* + * CFocusableHelper.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + +void removeFocusFromActiveInput(); diff --git a/client/CGameInfo.h b/client/CGameInfo.h index 442be449d..3e6a31dfa 100644 --- a/client/CGameInfo.h +++ b/client/CGameInfo.h @@ -13,29 +13,33 @@ #include "../lib/ConstTransitivePtr.h" +VCMI_LIB_NAMESPACE_BEGIN + class CModHandler; -class CMapHandler; class CHeroHandler; class CCreatureHandler; class CSpellHandler; class CSkillHandler; class CBuildingHandler; class CObjectHandler; -class CSoundHandler; -class CMusicHandler; class CObjectClassesHandler; class CTownHandler; class CGeneralTextHandler; class CConsoleHandler; -class CCursorHandler; class CGameState; -class IMainVideoPlayer; -class CServerHandler; class BattleFieldHandler; class ObstacleHandler; class CMap; +VCMI_LIB_NAMESPACE_END + +class CMapHandler; +class CSoundHandler; +class CMusicHandler; +class CCursorHandler; +class IMainVideoPlayer; +class CServerHandler; //a class for non-mechanical client GUI classes class CClientState diff --git a/client/CMT.cpp b/client/CMT.cpp index 5754814b8..9a9139085 100644 --- a/client/CMT.cpp +++ b/client/CMT.cpp @@ -159,7 +159,7 @@ static void SDLLogCallback(void* userdata, #if defined(VCMI_WINDOWS) && !defined(__GNUC__) && defined(VCMI_WITH_DEBUG_CONSOLE) int wmain(int argc, wchar_t* argv[]) -#elif defined(VCMI_ANDROID) +#elif defined(VCMI_IOS) || defined(VCMI_ANDROID) int SDL_main(int argc, char *argv[]) #else int main(int argc, char * argv[]) @@ -170,7 +170,7 @@ int main(int argc, char * argv[]) setenv("LANG", "C", 1); #endif -#ifndef VCMI_ANDROID +#if !defined(VCMI_ANDROID) && !defined(VCMI_IOS) // Correct working dir executable folder (not bundle folder) so we can use executable relative paths boost::filesystem::current_path(boost::filesystem::system_complete(argv[0]).parent_path()); #endif @@ -217,12 +217,20 @@ int main(int argc, char * argv[]) if(vm.count("help")) { prog_help(opts); +#ifdef VCMI_IOS + exit(0); +#else return 0; +#endif } if(vm.count("version")) { prog_version(); +#ifdef VCMI_IOS + exit(0); +#else return 0; +#endif } // Init old logging system and new (temporary) logging system @@ -410,7 +418,7 @@ int main(int argc, char * argv[]) CCS->musich->setVolume((ui32)settings["general"]["music"].Float()); logGlobal->info("Initializing screen and sound handling: %d ms", pomtime.getDiff()); } -#ifdef __APPLE__ +#ifdef VCMI_MAC // Ctrl+click should be treated as a right click on Mac OS X SDL_SetHint(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, "1"); #endif @@ -1027,11 +1035,15 @@ static bool recreateWindow(int w, int h, int bpp, bool fullscreen, int displayIn if (displayIndex < 0) displayIndex = 0; } +#ifdef VCMI_IOS + SDL_GetWindowSize(mainWindow, &w, &h); +#else if(!checkVideoMode(displayIndex, w, h)) { logGlobal->error("Error: SDL says that %dx%d resolution is not available!", w, h); return false; } +#endif bool bufOnScreen = (screenBuf == screen); bool realFullscreen = settings["video"]["realFullscreen"].Bool(); @@ -1088,26 +1100,40 @@ static bool recreateWindow(int w, int h, int bpp, bool fullscreen, int displayIn if(nullptr == mainWindow) { +#if defined(VCMI_ANDROID) || defined(VCMI_IOS) + auto createWindow = [displayIndex](Uint32 extraFlags) -> bool { + mainWindow = SDL_CreateWindow(NAME.c_str(), SDL_WINDOWPOS_UNDEFINED_DISPLAY(displayIndex), SDL_WINDOWPOS_UNDEFINED_DISPLAY(displayIndex), 0, 0, SDL_WINDOW_FULLSCREEN | extraFlags); + return mainWindow != nullptr; + }; - #ifdef VCMI_ANDROID - mainWindow = SDL_CreateWindow(NAME.c_str(), SDL_WINDOWPOS_UNDEFINED_DISPLAY(displayIndex),SDL_WINDOWPOS_UNDEFINED_DISPLAY(displayIndex), 0, 0, SDL_WINDOW_FULLSCREEN); +# ifdef VCMI_IOS + SDL_SetHint(SDL_HINT_IOS_HIDE_HOME_INDICATOR, "1"); + SDL_SetHint(SDL_HINT_RETURN_KEY_HIDES_IME, "1"); + SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best"); - // SDL on Android doesn't do proper letterboxing, and will show an annoying flickering in the blank space in case you're not using the full screen estate + Uint32 windowFlags = SDL_WINDOW_BORDERLESS | SDL_WINDOW_ALLOW_HIGHDPI; + if(!createWindow(windowFlags | SDL_WINDOW_METAL)) + { + logGlobal->warn("Metal unavailable, using OpenGLES"); + createWindow(windowFlags); + } +# else + createWindow(0); +# endif // VCMI_IOS + + // SDL on mobile doesn't do proper letterboxing, and will show an annoying flickering in the blank space in case you're not using the full screen estate // That's why we need to make sure our width and height we'll use below have the same aspect ratio as the screen itself to ensure we fill the full screen estate SDL_Rect screenRect; if(SDL_GetDisplayBounds(0, &screenRect) == 0) { - int screenWidth, screenHeight; - double aspect; + const auto screenWidth = screenRect.w; + const auto screenHeight = screenRect.h; - screenWidth = screenRect.w; - screenHeight = screenRect.h; + const auto aspect = static_cast(screenWidth) / screenHeight; - aspect = (double)screenWidth / (double)screenHeight; - - logGlobal->info("Screen size and aspect ration: %dx%d (%lf)", screenWidth, screenHeight, aspect); + logGlobal->info("Screen size and aspect ratio: %dx%d (%lf)", screenWidth, screenHeight, aspect); if((double)w / aspect > (double)h) { @@ -1124,8 +1150,7 @@ static bool recreateWindow(int w, int h, int bpp, bool fullscreen, int displayIn { logGlobal->error("Can't fix aspect ratio for screen"); } - #else - +#else if(fullscreen) { if(realFullscreen) @@ -1138,7 +1163,7 @@ static bool recreateWindow(int w, int h, int bpp, bool fullscreen, int displayIn { mainWindow = SDL_CreateWindow(NAME.c_str(), SDL_WINDOWPOS_CENTERED_DISPLAY(displayIndex),SDL_WINDOWPOS_CENTERED_DISPLAY(displayIndex), w, h, 0); } - #endif +#endif // defined(VCMI_ANDROID) || defined(VCMI_IOS) if(nullptr == mainWindow) { @@ -1161,7 +1186,7 @@ static bool recreateWindow(int w, int h, int bpp, bool fullscreen, int displayIn } else { -#ifndef VCMI_ANDROID +#if !defined(VCMI_ANDROID) && !defined(VCMI_IOS) if(fullscreen) { @@ -1384,7 +1409,9 @@ static void handleEvent(SDL_Event & ev) { switch (ev.window.event) { case SDL_WINDOWEVENT_RESTORED: +#ifndef VCMI_IOS fullScreenChanged(); +#endif break; } return; diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 1274bab4e..1f487d175 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -145,6 +145,22 @@ set(client_HEADERS SDLRWwrapper.h ) +if(APPLE_IOS) + set(client_SRCS ${client_SRCS} + CFocusableHelper.cpp + ios/GameChatKeyboardHanlder.m + ios/main.m + ios/startSDL.mm + ios/utils.mm + ) + set(client_HEADERS ${client_HEADERS} + CFocusableHelper.h + ios/GameChatKeyboardHanlder.h + ios/startSDL.h + ios/utils.h + ) +endif() + assign_source_group(${client_SRCS} ${client_HEADERS} VCMI_client.rc) if(ANDROID) # android needs client/server to be libraries, not executables, so we can't reuse the build part of this script @@ -160,7 +176,16 @@ if(ENABLE_DEBUG_CONSOLE) else() add_executable(vcmiclient WIN32 ${client_SRCS} ${client_HEADERS} ${client_ICON}) endif(ENABLE_DEBUG_CONSOLE) + add_dependencies(vcmiclient vcmiserver BattleAI StupidAI VCAI Nullkiller) +if(APPLE_IOS) + if(ENABLE_ERM) + add_dependencies(vcmiclient vcmiERM) + endif() + if(ENABLE_LUA) + add_dependencies(vcmiclient vcmiLua) + endif() +endif() if(WIN32) set_target_properties(vcmiclient @@ -173,15 +198,55 @@ if(WIN32) target_link_libraries(vcmiclient SDL2::SDL2main) endif() target_compile_definitions(vcmiclient PRIVATE WINDOWS_IGNORE_PACKING_MISMATCH) +elseif(APPLE_IOS) + target_link_libraries(vcmiclient PRIVATE + iOS_utils + + # FFmpeg + bz2 + iconv + z + "-framework AudioToolbox" + "-framework AVFoundation" + "-framework CoreMedia" + "-framework VideoToolbox" + ) + + set_target_properties(vcmiclient PROPERTIES + MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_LIST_DIR}/ios/Info.plist" + XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/Frameworks" + XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "$(CODE_SIGNING_ALLOWED_FOR_APPS)" + XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME AppIcon + ) + + foreach(XCODE_RESOURCE LaunchScreen.storyboard Images.xcassets Settings.bundle vcmi_logo.png) + set(XCODE_RESOURCE_PATH ios/${XCODE_RESOURCE}) + target_sources(vcmiclient PRIVATE ${XCODE_RESOURCE_PATH}) + set_source_files_properties(${XCODE_RESOURCE_PATH} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) + + # workaround to prevent CMAKE_SKIP_PRECOMPILE_HEADERS being added as compile flag + # add max version condition when https://gitlab.kitware.com/cmake/cmake/-/merge_requests/7562 is merged + if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.22.0") + set_source_files_properties(${XCODE_RESOURCE_PATH} PROPERTIES LANGUAGE CXX) + endif() + endforeach() + + set(CMAKE_EXE_LINKER_FLAGS "-Wl,-e,_client_main") endif() +if(BUILD_SINGLE_APP) + target_link_libraries(vcmiclient PRIVATE vcmiserver) + if(ENABLE_LAUNCHER) + target_link_libraries(vcmiclient PRIVATE vcmilauncher) + endif() +endif() target_link_libraries(vcmiclient PRIVATE - vcmi SDL2::SDL2 SDL2::Image SDL2::Mixer SDL2::TTF + ${VCMI_LIB_TARGET} SDL2::SDL2 SDL2::Image SDL2::Mixer SDL2::TTF ) if(ffmpeg_LIBRARIES) target_link_libraries(vcmiclient PRIVATE - ffmpeg::swscale ffmpeg::avutil ffmpeg::avcodec ffmpeg::avformat + ${ffmpeg_LIBRARIES} ) else() target_compile_definitions(vcmiclient PRIVATE DISABLE_VIDEO) @@ -193,7 +258,15 @@ target_include_directories(vcmiclient vcmi_set_output_dir(vcmiclient "") enable_pch(vcmiclient) -install(TARGETS vcmiclient DESTINATION ${BIN_DIR}) +if(APPLE_IOS) + add_custom_command(TARGET vcmiclient POST_BUILD + COMMAND ${CMAKE_COMMAND} --install "${CMAKE_BINARY_DIR}" --component "${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}" --config "$" --prefix "$" + COMMAND ${CMAKE_SOURCE_DIR}/ios/codesign.sh + ) + install(TARGETS vcmiclient DESTINATION Payload COMPONENT app) # for ipa generation with cpack +else() + install(TARGETS vcmiclient DESTINATION ${BIN_DIR}) +endif() #install icons and desktop file on Linux if(NOT WIN32 AND NOT APPLE) diff --git a/client/CPlayerInterface.h b/client/CPlayerInterface.h index 9a5d5408b..f7907594c 100644 --- a/client/CPlayerInterface.h +++ b/client/CPlayerInterface.h @@ -19,30 +19,33 @@ #define sprintf_s snprintf #endif +VCMI_LIB_NAMESPACE_BEGIN + class Artifact; +struct TryMoveHero; +class CGHeroInstance; +class CStack; +class CCreature; +struct CGPath; +class CCreatureSet; +class CGObjectInstance; +struct UpgradeInfo; +template struct CondSh; +struct CPathsInfo; + +VCMI_LIB_NAMESPACE_END + class CButton; class CToggleGroup; -struct TryMoveHero; -class CGHeroInstance; class CAdvMapInt; class CCastleInterface; class CBattleInterface; -class CStack; class CComponent; -class CCreature; -struct SDL_Surface; -struct CGPath; class CCreatureAnimation; class CSelectableComponent; -class CCreatureSet; -class CGObjectInstance; class CSlider; -struct UpgradeInfo; -template struct CondSh; class CInGameConsole; -class CInGameConsole; -union SDL_Event; class CInfoWindow; class IShowActivatable; class ClickableL; @@ -52,7 +55,9 @@ class KeyInterested; class MotionInterested; class TimeInterested; class IShowable; -struct CPathsInfo; + +struct SDL_Surface; +union SDL_Event; namespace boost { diff --git a/client/CServerHandler.cpp b/client/CServerHandler.cpp index 46495145c..88d28067e 100644 --- a/client/CServerHandler.cpp +++ b/client/CServerHandler.cpp @@ -21,10 +21,15 @@ #include "mainmenu/CMainMenu.h" -#ifndef VCMI_ANDROID -#include "../lib/Interprocess.h" -#else +#ifdef VCMI_ANDROID #include "../lib/CAndroidVMHelper.h" +#elif defined(VCMI_IOS) +#include "ios/utils.h" +#include "../server/CVCMIServer.h" + +#include +#else +#include "../lib/Interprocess.h" #endif #include "../lib/CConfigHandler.h" #include "../lib/CGeneralTextHandler.h" @@ -76,7 +81,7 @@ public: bool applyOnLobbyHandler(CServerHandler * handler, void * pack) const override { T * ptr = static_cast(pack); - logNetwork->trace("\tImmidiately apply on lobby: %s", typeList.getTypeInfo(ptr)->name()); + logNetwork->trace("\tImmediately apply on lobby: %s", typeList.getTypeInfo(ptr)->name()); return ptr->applyOnLobbyHandler(handler); } @@ -132,7 +137,7 @@ void CServerHandler::resetStateForLobby(const StartInfo::EMode mode, const std:: else myNames.push_back(settings["general"]["playerName"].String()); -#ifndef VCMI_ANDROID +#if !defined(VCMI_ANDROID) && !defined(VCMI_IOS) shm.reset(); if(!settings["session"]["disable-shm"].Bool()) @@ -181,6 +186,14 @@ void CServerHandler::startLocalServerAndConnect() CAndroidVMHelper envHelper; envHelper.callStaticVoidMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "startServer", true); } +#elif defined(SINGLE_PROCESS_APP) + boost::condition_variable cond; + threadRunLocalServer = std::make_shared([&cond, this] { + setThreadName("CVCMIServer"); + CVCMIServer::create(&cond, uuid); + onServerFinished(); + }); + threadRunLocalServer->detach(); #else threadRunLocalServer = std::make_shared(&CServerHandler::threadRunServer, this); //runs server executable; #endif @@ -188,10 +201,7 @@ void CServerHandler::startLocalServerAndConnect() th->update(); -#ifndef VCMI_ANDROID - if(shm) - shm->sr->waitTillReady(); -#else +#ifdef VCMI_ANDROID logNetwork->info("waiting for server"); while(!androidTestServerReadyFlag.load()) { @@ -200,16 +210,40 @@ void CServerHandler::startLocalServerAndConnect() } logNetwork->info("waiting for server finished..."); androidTestServerReadyFlag = false; +#elif defined(SINGLE_PROCESS_APP) + { +#ifdef VCMI_IOS + dispatch_sync(dispatch_get_main_queue(), ^{ + iOS_utils::showLoadingIndicator(); + }); +#endif + + boost::mutex m; + boost::unique_lock lock{m}; + logNetwork->info("waiting for server"); + cond.wait(lock); + logNetwork->info("server is ready"); + +#ifdef VCMI_IOS + dispatch_sync(dispatch_get_main_queue(), ^{ + iOS_utils::hideLoadingIndicator(); + }); +#endif + } +#else + if(shm) + shm->sr->waitTillReady(); #endif logNetwork->trace("Waiting for server: %d ms", th->getDiff()); th->update(); //put breakpoint here to attach to server before it does something stupid -#ifndef VCMI_ANDROID - justConnectToServer(settings["server"]["server"].String(), shm ? shm->sr->port : 0); +#if !defined(VCMI_ANDROID) && !defined(VCMI_IOS) + const ui16 port = shm ? shm->sr->port : 0; #else - justConnectToServer(settings["server"]["server"].String()); + const ui16 port = 0; #endif + justConnectToServer(settings["server"]["server"].String(), port); logNetwork->trace("\tConnecting to the server: %d ms", th->getDiff()); } @@ -698,7 +732,7 @@ void CServerHandler::threadHandleConnection() void CServerHandler::threadRunServer() { -#ifndef VCMI_ANDROID +#if !defined(VCMI_ANDROID) && !defined(VCMI_IOS) setThreadName("CServerHandler::threadRunServer"); const std::string logName = (VCMIDirs::get().userLogsPath() / "server_log.txt").string(); std::string comm = VCMIDirs::get().serverPath().string() @@ -739,9 +773,14 @@ void CServerHandler::threadRunServer() logNetwork->error("Error: server failed to close correctly or crashed!"); logNetwork->error("Check %s for more info", logName); } + onServerFinished(); +#endif +} + +void CServerHandler::onServerFinished() +{ threadRunLocalServer.reset(); CSH->campaignServerRestartLock.setn(false); -#endif } void CServerHandler::sendLobbyPack(const CPackForLobby & pack) const diff --git a/client/CServerHandler.h b/client/CServerHandler.h index 03ac005ed..3b70d4343 100644 --- a/client/CServerHandler.h +++ b/client/CServerHandler.h @@ -14,7 +14,8 @@ #include "../lib/StartInfo.h" #include "../lib/CondSh.h" -struct SharedMemory; +VCMI_LIB_NAMESPACE_BEGIN + class CConnection; class PlayerColor; struct StartInfo; @@ -23,9 +24,15 @@ class CMapInfo; struct ClientPlayer; struct CPack; struct CPackForLobby; -class CClient; template class CApplier; + +VCMI_LIB_NAMESPACE_END + +struct SharedMemory; + +class CClient; + class CBaseForLobbyApply; // TODO: Add mutex so we can't set CONNECTION_CANCELLED if client already connected, but thread not setup yet @@ -76,6 +83,7 @@ class CServerHandler : public IServerAPI, public LobbyInfo void threadHandleConnection(); void threadRunServer(); + void onServerFinished(); void sendLobbyPack(const CPackForLobby & pack) const override; public: diff --git a/client/Client.h b/client/Client.h index 38a2b4551..569277e93 100644 --- a/client/Client.h +++ b/client/Client.h @@ -19,25 +19,22 @@ #include "../lib/CondSh.h" #include "../lib/CPathfinder.h" +VCMI_LIB_NAMESPACE_BEGIN + struct CPack; struct CPackForServer; class CCampaignState; -class CBattleCallback; class IGameEventsReceiver; class IBattleEventsReceiver; class CBattleGameInterface; class CGameState; class CGameInterface; -class CCallback; class BattleAction; -class CClient; struct CPathsInfo; class BinaryDeserializer; class BinarySerializer; -namespace boost { class thread; } template class CApplier; -class CBaseForCLApply; #if SCRIPTING_ENABLED namespace scripting @@ -51,6 +48,15 @@ namespace events class EventBus; } +VCMI_LIB_NAMESPACE_END + +class CBattleCallback; +class CCallback; +class CClient; +class CBaseForCLApply; + +namespace boost { class thread; } + template class ThreadSafeVector { diff --git a/client/Graphics.h b/client/Graphics.h index c1461b064..faf0aaf95 100644 --- a/client/Graphics.h +++ b/client/Graphics.h @@ -13,18 +13,23 @@ #include "../lib/GameConstants.h" #include "gui/Geometries.h" -struct SDL_Surface; +VCMI_LIB_NAMESPACE_BEGIN + class CGHeroInstance; class CGTownInstance; class CHeroClass; -struct SDL_Color; struct InfoAboutHero; struct InfoAboutTown; class CGObjectInstance; class ObjectTemplate; -class CAnimation; class EntityService; +VCMI_LIB_NAMESPACE_END + +struct SDL_Surface; +struct SDL_Color; +class CAnimation; + enum EFonts { FONT_BIG, FONT_CALLI, FONT_CREDITS, FONT_HIGH_SCORE, FONT_MEDIUM, FONT_SMALL, FONT_TIMES, FONT_TINY, FONT_VERD diff --git a/client/SDLRWwrapper.h b/client/SDLRWwrapper.h index ab1152a32..ea2f099e9 100644 --- a/client/SDLRWwrapper.h +++ b/client/SDLRWwrapper.h @@ -9,7 +9,12 @@ */ #pragma once -struct SDL_RWops; +VCMI_LIB_NAMESPACE_BEGIN + class CInputStream; +VCMI_LIB_NAMESPACE_END + +struct SDL_RWops; + SDL_RWops* MakeSDLRWops(std::unique_ptr in); diff --git a/client/StdInc.h b/client/StdInc.h index b03f5812c..8e35b9a2d 100644 --- a/client/StdInc.h +++ b/client/StdInc.h @@ -7,3 +7,5 @@ // This header should be treated as a pre compiled header file(PCH) in the compiler building settings. // Here you can add specific libraries and macros which are specific to this project. + +VCMI_LIB_USING_NAMESPACE diff --git a/client/battle/CBattleAnimations.h b/client/battle/CBattleAnimations.h index 93422e6d7..c71d78195 100644 --- a/client/battle/CBattleAnimations.h +++ b/client/battle/CBattleAnimations.h @@ -12,8 +12,13 @@ #include "../../lib/battle/BattleHex.h" #include "../widgets/Images.h" -class CBattleInterface; +VCMI_LIB_NAMESPACE_BEGIN + class CStack; + +VCMI_LIB_NAMESPACE_END + +class CBattleInterface; class CCreatureAnimation; struct CatapultProjectileInfo; struct StackAttackedInfo; diff --git a/client/battle/CBattleInterface.h b/client/battle/CBattleInterface.h index ed5eb1dc7..0fdd232fe 100644 --- a/client/battle/CBattleInterface.h +++ b/client/battle/CBattleInterface.h @@ -19,14 +19,11 @@ #include "../../lib/spells/CSpellHandler.h" //CSpell::TAnimation #include "../../lib/battle/CBattleInfoCallback.h" -class CLabel; +VCMI_LIB_NAMESPACE_BEGIN + class CCreatureSet; class CGHeroInstance; class CStack; -class CCallback; -class CButton; -class CToggleButton; -class CToggleGroup; struct BattleResult; struct BattleSpellCast; struct CObstacleInstance; @@ -35,8 +32,21 @@ struct SetStackEffect; class BattleAction; class CGTownInstance; struct CatapultAttack; -struct CatapultProjectileInfo; struct BattleTriggerEffect; +struct BattleHex; +struct InfoAboutHero; +class CBattleGameInterface; +struct CustomEffectInfo; +class CSpell; + +VCMI_LIB_NAMESPACE_END + +class CLabel; +class CCallback; +class CButton; +class CToggleButton; +class CToggleGroup; +struct CatapultProjectileInfo; class CBattleAnimation; class CBattleHero; class CBattleConsole; @@ -46,13 +56,8 @@ class CPlayerInterface; class CCreatureAnimation; struct ProjectileInfo; class CClickableHex; -struct BattleHex; -struct InfoAboutHero; -class CBattleGameInterface; -struct CustomEffectInfo; class CAnimation; class IImage; -class CSpell; /// Small struct which contains information about the id of the attacked stack, the damage dealt,... struct StackAttackedInfo diff --git a/client/battle/CBattleInterfaceClasses.h b/client/battle/CBattleInterfaceClasses.h index 079014ba7..c0b657d27 100644 --- a/client/battle/CBattleInterfaceClasses.h +++ b/client/battle/CBattleInterfaceClasses.h @@ -13,8 +13,20 @@ #include "../../lib/battle/BattleHex.h" #include "../windows/CWindowObject.h" -struct SDL_Surface; +VCMI_LIB_NAMESPACE_BEGIN + class CGHeroInstance; +struct BattleResult; +class CStack; + +namespace battle +{ +class Unit; +} + +VCMI_LIB_NAMESPACE_END + +struct SDL_Surface; class CBattleInterface; class CPicture; class CFilledTexture; @@ -23,12 +35,6 @@ class CToggleButton; class CToggleGroup; class CLabel; class CTextBox; -struct BattleResult; -class CStack; -namespace battle -{ - class Unit; -} class CAnimImage; class CPlayerInterface; diff --git a/client/gui/CAnimation.h b/client/gui/CAnimation.h index 0b1fa9e10..cb885fa36 100644 --- a/client/gui/CAnimation.h +++ b/client/gui/CAnimation.h @@ -21,8 +21,13 @@ #undef OUT #endif -struct SDL_Surface; +VCMI_LIB_NAMESPACE_BEGIN + class JsonNode; + +VCMI_LIB_NAMESPACE_END + +struct SDL_Surface; class CDefFile; class ColorShifter; diff --git a/client/gui/CGuiHandler.h b/client/gui/CGuiHandler.h index 18be56380..7f6373dfb 100644 --- a/client/gui/CGuiHandler.h +++ b/client/gui/CGuiHandler.h @@ -13,6 +13,12 @@ #include "Geometries.h" #include "SDL_Extensions.h" +VCMI_LIB_NAMESPACE_BEGIN + +template struct CondSh; + +VCMI_LIB_NAMESPACE_END + class CFramerateManager; class CGStatusBar; class CIntObject; @@ -20,7 +26,6 @@ class IUpdateable; class IShowActivatable; class IShowable; enum class EIntObjMouseBtnType; -template struct CondSh; // TODO: event handling need refactoring enum EUserEvent diff --git a/client/gui/Fonts.h b/client/gui/Fonts.h index f471e8967..a5aad2c46 100644 --- a/client/gui/Fonts.h +++ b/client/gui/Fonts.h @@ -9,8 +9,12 @@ */ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + class JsonNode; +VCMI_LIB_NAMESPACE_END + struct Point; struct SDL_Surface; struct SDL_Color; diff --git a/client/gui/SDL_Extensions.cpp b/client/gui/SDL_Extensions.cpp index e41b09f0c..410ddb4b8 100644 --- a/client/gui/SDL_Extensions.cpp +++ b/client/gui/SDL_Extensions.cpp @@ -20,6 +20,10 @@ #include #endif +#ifdef VCMI_IOS +#include "ios/utils.h" +#endif + const SDL_Color Colors::YELLOW = { 229, 215, 123, 0 }; const SDL_Color Colors::WHITE = { 255, 243, 222, 0 }; const SDL_Color Colors::METALLIC_GOLD = { 173, 142, 66, 0 }; @@ -790,15 +794,37 @@ SDL_Color CSDL_Ext::makeColor(ui8 r, ui8 g, ui8 b, ui8 a) void CSDL_Ext::startTextInput(SDL_Rect * where) { + auto impl = [](SDL_Rect * where) + { + if (SDL_IsTextInputActive() == SDL_FALSE) + { + SDL_StartTextInput(); + } + SDL_SetTextInputRect(where); + }; + #ifdef VCMI_APPLE dispatch_async(dispatch_get_main_queue(), ^{ #endif - if (SDL_IsTextInputActive() == SDL_FALSE) - { - SDL_StartTextInput(); - } - SDL_SetTextInputRect(where); +#ifdef VCMI_IOS + // TODO ios: looks like SDL bug actually, try fixing there + auto renderer = SDL_GetRenderer(mainWindow); + float scaleX, scaleY; + SDL_Rect viewport; + SDL_RenderGetScale(renderer, &scaleX, &scaleY); + SDL_RenderGetViewport(renderer, &viewport); + + const auto nativeScale = iOS_utils::screenScale(); + auto rectInScreenCoordinates = *where; + rectInScreenCoordinates.x = (viewport.x + rectInScreenCoordinates.x) * scaleX / nativeScale; + rectInScreenCoordinates.y = (viewport.y + rectInScreenCoordinates.y) * scaleY / nativeScale; + rectInScreenCoordinates.w = rectInScreenCoordinates.w * scaleX / nativeScale; + rectInScreenCoordinates.h = rectInScreenCoordinates.h * scaleY / nativeScale; + impl(&rectInScreenCoordinates); +#else + impl(where); +#endif #ifdef VCMI_APPLE }); diff --git a/client/ios/GameChatKeyboardHanlder.h b/client/ios/GameChatKeyboardHanlder.h new file mode 100644 index 000000000..8f4f8e9c2 --- /dev/null +++ b/client/ios/GameChatKeyboardHanlder.h @@ -0,0 +1,23 @@ +/* + * GameChatKeyboardHanlder.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface GameChatKeyboardHanlder : NSObject + +@property (nonatomic, weak) UITextField * textFieldSDL; + +- (void)triggerInput; + +@end + +NS_ASSUME_NONNULL_END diff --git a/client/ios/GameChatKeyboardHanlder.m b/client/ios/GameChatKeyboardHanlder.m new file mode 100644 index 000000000..24336f592 --- /dev/null +++ b/client/ios/GameChatKeyboardHanlder.m @@ -0,0 +1,107 @@ +/* + * GameChatKeyboardHanlder.m, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + +#import "GameChatKeyboardHanlder.h" + +#include + +static int watchReturnKey(void * userdata, SDL_Event * event); + +static void sendKeyEvent(SDL_KeyCode keyCode) +{ + SDL_Event keyEvent; + keyEvent.key = (SDL_KeyboardEvent){ + .type = SDL_KEYDOWN, + .keysym.sym = keyCode, + }; + SDL_PushEvent(&keyEvent); +} + +static CGRect keyboardFrame(NSNotification * n, NSString * userInfoKey) +{ + return [n.userInfo[userInfoKey] CGRectValue]; +} +static CGRect keyboardFrameBegin(NSNotification * n) { return keyboardFrame(n, UIKeyboardFrameBeginUserInfoKey); } +static CGRect keyboardFrameEnd (NSNotification * n) { return keyboardFrame(n, UIKeyboardFrameEndUserInfoKey); } + + +@interface GameChatKeyboardHanlder () +@property (nonatomic) BOOL wasChatMessageSent; +@end + +@implementation GameChatKeyboardHanlder + +- (void)triggerInput { + __auto_type notificationCenter = NSNotificationCenter.defaultCenter; + [notificationCenter addObserver:self selector:@selector(textDidBeginEditing:) name:UITextFieldTextDidBeginEditingNotification object:nil]; + [notificationCenter addObserver:self selector:@selector(textDidEndEditing:) name:UITextFieldTextDidEndEditingNotification object:nil]; + [notificationCenter addObserver:self selector:@selector(keyboardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil]; + [notificationCenter addObserver:self selector:@selector(keyboardDidChangeFrame:) name:UIKeyboardDidChangeFrameNotification object:nil]; + + self.wasChatMessageSent = NO; + sendKeyEvent(SDLK_TAB); +} + +- (void)positionTextFieldAboveKeyboardRect:(CGRect)kbFrame { + __auto_type r = kbFrame; + r.size.height = CGRectGetHeight(self.textFieldSDL.frame); + r.origin.y -= r.size.height; + self.textFieldSDL.frame = r; +} + +#pragma mark - Notifications + +- (void)textDidBeginEditing:(NSNotification *)n { + self.textFieldSDL.hidden = NO; + self.textFieldSDL.text = nil; + + // watch for pressing Return to ignore sending Escape key after keyboard is closed + SDL_AddEventWatch(watchReturnKey, (__bridge void *)self); +} + +- (void)textDidEndEditing:(NSNotification *)n { + [NSNotificationCenter.defaultCenter removeObserver:self]; + self.textFieldSDL.hidden = YES; + + // discard chat message + if(!self.wasChatMessageSent) + sendKeyEvent(SDLK_ESCAPE); +} + +- (void)keyboardWillChangeFrame:(NSNotification *)n { + // animate textfield together with keyboard + [UIView performWithoutAnimation:^{ + [self positionTextFieldAboveKeyboardRect:keyboardFrameBegin(n)]; + }]; + + NSTimeInterval kbAnimationDuration = [n.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue]; + NSUInteger kbAnimationCurve = [n.userInfo[UIKeyboardAnimationCurveUserInfoKey] unsignedIntegerValue]; + [UIView animateWithDuration:kbAnimationDuration delay:0 options:(kbAnimationCurve << 16) animations:^{ + [self positionTextFieldAboveKeyboardRect:keyboardFrameEnd(n)]; + } completion:nil]; +} + +- (void)keyboardDidChangeFrame:(NSNotification *)n { + [self positionTextFieldAboveKeyboardRect:keyboardFrameEnd(n)]; +} + +@end + + +static int watchReturnKey(void * userdata, SDL_Event * event) +{ + if(event->type == SDL_KEYDOWN && event->key.keysym.scancode == SDL_SCANCODE_RETURN) + { + __auto_type self = (__bridge GameChatKeyboardHanlder *)userdata; + self.wasChatMessageSent = YES; + SDL_DelEventWatch(watchReturnKey, userdata); + } + return 1; +} diff --git a/client/ios/Images.xcassets/AppIcon.appiconset/Contents.json b/client/ios/Images.xcassets/AppIcon.appiconset/Contents.json new file mode 100755 index 000000000..8122b0a0c --- /dev/null +++ b/client/ios/Images.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,121 @@ +{ + "images" : [ + { + "filename" : "Icon-App-20x20@2x.png", + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" + }, + { + "filename" : "Icon-App-20x20@3x.png", + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" + }, + { + "filename" : "Icon-App-29x29@1x.png", + "idiom" : "iphone", + "scale" : "1x", + "size" : "29x29" + }, + { + "filename" : "Icon-App-29x29@2x.png", + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" + }, + { + "filename" : "Icon-App-29x29@3x.png", + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" + }, + { + "filename" : "Icon-App-40x40@2x.png", + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "filename" : "Icon-App-40x40@3x.png", + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "filename" : "Icon-App-60x60@2x.png", + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "filename" : "Icon-App-60x60@3x.png", + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "filename" : "Icon-App-20x20@1x.png", + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" + }, + { + "filename" : "Icon-App-20x20@2x.png", + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" + }, + { + "filename" : "Icon-App-29x29@1x.png", + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" + }, + { + "filename" : "Icon-App-29x29@2x.png", + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" + }, + { + "filename" : "Icon-App-40x40@1x.png", + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" + }, + { + "filename" : "Icon-App-40x40@2x.png", + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" + }, + { + "filename" : "Icon-App-76x76@1x.png", + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" + }, + { + "filename" : "Icon-App-76x76@2x.png", + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" + }, + { + "filename" : "Icon-App-83.5x83.5@2x.png", + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" + }, + { + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 000000000..aee9354ef Binary files /dev/null and b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 000000000..e5583f4b7 Binary files /dev/null and b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 000000000..6c58aa09f Binary files /dev/null and b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 000000000..045a0bc89 Binary files /dev/null and b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 000000000..704fc9815 Binary files /dev/null and b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 000000000..3fb265c48 Binary files /dev/null and b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 000000000..e5583f4b7 Binary files /dev/null and b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 000000000..244512b03 Binary files /dev/null and b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 000000000..ca7b489be Binary files /dev/null and b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 000000000..ca7b489be Binary files /dev/null and b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 000000000..aa20b6471 Binary files /dev/null and b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 000000000..1fbffde17 Binary files /dev/null and b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 000000000..c184e5a54 Binary files /dev/null and b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 000000000..c08e86964 Binary files /dev/null and b/client/ios/Images.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/client/ios/Images.xcassets/Contents.json b/client/ios/Images.xcassets/Contents.json new file mode 100644 index 000000000..73c00596a --- /dev/null +++ b/client/ios/Images.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/client/ios/Info.plist b/client/ios/Info.plist new file mode 100644 index 000000000..153c44960 --- /dev/null +++ b/client/ios/Info.plist @@ -0,0 +1,60 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(PRODUCT_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + VCMI + CFBundlePackageType + APPL + CFBundleShortVersionString + $(MARKETING_VERSION) + CFBundleSignature + ???? + CFBundleURLTypes + + + CFBundleURLSchemes + + vcmi + + + + CFBundleVersion + 1 + LSRequiresIPhoneOS + + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + + UIApplicationSupportsIndirectInputEvents + + UIFileSharingEnabled + + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + armv7 + opengles-2 + + UIRequiresFullScreen + + UIStatusBarHidden + + UISupportedInterfaceOrientations + + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/client/ios/LaunchScreen.storyboard b/client/ios/LaunchScreen.storyboard new file mode 100644 index 000000000..5b159219d --- /dev/null +++ b/client/ios/LaunchScreen.storyboard @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/client/ios/Settings.bundle/Root.plist b/client/ios/Settings.bundle/Root.plist new file mode 100644 index 000000000..747935f4d --- /dev/null +++ b/client/ios/Settings.bundle/Root.plist @@ -0,0 +1,31 @@ + + + + + StringsTable + Root + PreferenceSpecifiers + + + Type + PSRadioGroupSpecifier + Title + LaunchType + Key + LaunchType + DefaultValue + 0 + Values + + 0 + 1 + + Titles + + Launcher + Game + + + + + diff --git a/client/ios/Settings.bundle/en.lproj/Root.strings b/client/ios/Settings.bundle/en.lproj/Root.strings new file mode 100644 index 000000000..4348ab181 --- /dev/null +++ b/client/ios/Settings.bundle/en.lproj/Root.strings @@ -0,0 +1,3 @@ +"LaunchType" = "App start type"; +"Launcher" = "Launcher"; +"Game" = "Game"; diff --git a/client/ios/Settings.bundle/ru.lproj/Root.strings b/client/ios/Settings.bundle/ru.lproj/Root.strings new file mode 100644 index 000000000..8661a436c --- /dev/null +++ b/client/ios/Settings.bundle/ru.lproj/Root.strings @@ -0,0 +1,3 @@ +"LaunchType" = "Тип запуска приложения"; +"Launcher" = "Конфигурация (лаунчер)"; +"Game" = "Игра"; diff --git a/client/ios/main.m b/client/ios/main.m new file mode 100644 index 000000000..dbba2cef3 --- /dev/null +++ b/client/ios/main.m @@ -0,0 +1,57 @@ +/* + * main.m, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ +#import "startSDL.h" + +#import + +#import + +#include + +static void startSDLManually(int argc, char * argv[]) +{ + id appDelegate; + @autoreleasepool { + __auto_type sdlAppDelegateClass = NSClassFromString(@"SDLUIKitDelegate"); + NSCAssert(sdlAppDelegateClass != nil, @"SDL AppDelegate class doesn't exist"); + NSCAssert(class_conformsToProtocol(sdlAppDelegateClass, @protocol(UIApplicationDelegate)), @"SDL AppDelegate doesn't conform to UIApplicationDelegate"); + appDelegate = [sdlAppDelegateClass new]; + } + UIApplication.sharedApplication.delegate = appDelegate; + + int result = startSDL(argc, argv, YES); + exit(result); +} + +int qt_main_wrapper(int argc, char * argv[]); + +int client_main(int argc, char * argv[]) +{ + NSInteger launchType; + __auto_type envVar = getenv("VCMI_LAUNCH_TYPE"); + if (envVar) + launchType = envVar[0] == '0' ? 0 : 1; + else { + @autoreleasepool { + launchType = [NSUserDefaults.standardUserDefaults integerForKey:@"LaunchType"]; + } + } + if (launchType == 1) + return startSDL(argc, argv, NO); + + @autoreleasepool { + id __block startGameObserver = [NSNotificationCenter.defaultCenter addObserverForName:@"StartGame" object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { + [NSNotificationCenter.defaultCenter removeObserver:startGameObserver]; + startGameObserver = nil; + startSDLManually(argc, argv); + }]; + return qt_main_wrapper(argc, argv); + } +} diff --git a/client/ios/startSDL.h b/client/ios/startSDL.h new file mode 100644 index 000000000..abd7419b5 --- /dev/null +++ b/client/ios/startSDL.h @@ -0,0 +1,19 @@ +/* + * startSDL.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ +#pragma once + +#ifdef __OBJC__ +#include +#endif + +#ifdef __cplusplus +extern "C" +#endif +int startSDL(int argc, char * argv[], BOOL startManually); diff --git a/client/ios/startSDL.mm b/client/ios/startSDL.mm new file mode 100644 index 000000000..6cf867478 --- /dev/null +++ b/client/ios/startSDL.mm @@ -0,0 +1,162 @@ +/* + * startSDL.mm, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ +#import "startSDL.h" +#import "GameChatKeyboardHanlder.h" + +#include "../Global.h" +#include "CMT.h" +#include "CServerHandler.h" +#include "CFocusableHelper.h" + +#include +#include +#include +#include + +#import + +@interface SDLViewObserver : NSObject +@property (nonatomic, strong) GameChatKeyboardHanlder * gameChatHandler; +@end + +@implementation SDLViewObserver + +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { + [object removeObserver:self forKeyPath:keyPath]; + + UIView * view = [object valueForKeyPath:keyPath]; + + UITextField * textField; + for (UIView * v in view.subviews) { + if ([v isKindOfClass:[UITextField class]]) { + textField = (UITextField *)v; + break; + } + } + + auto r = textField.frame; + r.size.height = 40; + textField.frame = r; + self.gameChatHandler.textFieldSDL = textField; + +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0 + if(@available(iOS 13.0, *)) + textField.backgroundColor = UIColor.systemBackgroundColor; + else +#endif + textField.backgroundColor = UIColor.whiteColor; + + auto longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)]; + longPress.minimumPressDuration = 0.2; + [view addGestureRecognizer:longPress]; + + auto pinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinch:)]; + [view addGestureRecognizer:pinch]; +} + +#pragma mark - Gestures + +- (void)handleLongPress:(UIGestureRecognizer *)gesture { + // send RMB click + SDL_EventType mouseButtonType; + switch (gesture.state) + { + case UIGestureRecognizerStateBegan: + mouseButtonType = SDL_MOUSEBUTTONDOWN; + break; + case UIGestureRecognizerStateEnded: + mouseButtonType = SDL_MOUSEBUTTONUP; + break; + default: + return; + } + + auto renderer = SDL_GetRenderer(mainWindow); + float scaleX, scaleY; + SDL_Rect viewport; + SDL_RenderGetScale(renderer, &scaleX, &scaleY); + SDL_RenderGetViewport(renderer, &viewport); + + auto touchedPoint = [gesture locationInView:gesture.view]; + auto screenScale = UIScreen.mainScreen.nativeScale; + Sint32 x = (int)touchedPoint.x * screenScale / scaleX - viewport.x; + Sint32 y = (int)touchedPoint.y * screenScale / scaleY - viewport.y; + + SDL_Event rmbEvent; + rmbEvent.button = (SDL_MouseButtonEvent){ + .type = mouseButtonType, + .button = SDL_BUTTON_RIGHT, + .clicks = 1, + .x = x, + .y = y, + }; + SDL_PushEvent(&rmbEvent); + + // small hack to prevent cursor jumping + if (mouseButtonType == SDL_MOUSEBUTTONUP) + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.025 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + SDL_Event motionEvent; + motionEvent.motion = (SDL_MouseMotionEvent){ + .type = SDL_MOUSEMOTION, + .x = x, + .y = y, + }; + SDL_PushEvent(&motionEvent); + }); +} + +- (void)handlePinch:(UIGestureRecognizer *)gesture { + if(gesture.state != UIGestureRecognizerStateBegan || CSH->state != EClientState::GAMEPLAY) + return; + [self.gameChatHandler triggerInput]; +} + +#pragma mark - UIGestureRecognizerDelegate + +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { + return [gestureRecognizer isKindOfClass:[UIPinchGestureRecognizer class]]; +} + +@end + + +int startSDL(int argc, char * argv[], BOOL startManually) +{ + @autoreleasepool { + auto observer = [SDLViewObserver new]; + observer.gameChatHandler = [GameChatKeyboardHanlder new]; + + id __block sdlWindowCreationObserver = [NSNotificationCenter.defaultCenter addObserverForName:UIWindowDidBecomeKeyNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { + [NSNotificationCenter.defaultCenter removeObserver:sdlWindowCreationObserver]; + sdlWindowCreationObserver = nil; + + UIWindow * sdlWindow = note.object; + [sdlWindow.rootViewController addObserver:observer forKeyPath:NSStringFromSelector(@selector(view)) options:NSKeyValueObservingOptionNew context:NULL]; + }]; + id textFieldObserver = [NSNotificationCenter.defaultCenter addObserverForName:UITextFieldTextDidEndEditingNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { + removeFocusFromActiveInput(); + }]; + + int result; + if (startManually) + { + // copied from -[SDLUIKitDelegate postFinishLaunch] + SDL_SetMainReady(); + SDL_iOSSetEventPump(SDL_TRUE); + result = SDL_main(argc, argv); + SDL_iOSSetEventPump(SDL_FALSE); + } + else + result = SDL_UIKitRunApp(argc, argv, SDL_main); + + [NSNotificationCenter.defaultCenter removeObserver:textFieldObserver]; + return result; + } +} diff --git a/client/ios/utils.h b/client/ios/utils.h new file mode 100644 index 000000000..f3a643d83 --- /dev/null +++ b/client/ios/utils.h @@ -0,0 +1,18 @@ +/* + * utils.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ +#pragma once + +namespace iOS_utils +{ +double screenScale(); + +void showLoadingIndicator(); +void hideLoadingIndicator(); +} diff --git a/client/ios/utils.mm b/client/ios/utils.mm new file mode 100644 index 000000000..41cb65f4f --- /dev/null +++ b/client/ios/utils.mm @@ -0,0 +1,46 @@ +/* + * utils.mm, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + +#include "utils.h" + +#import + +namespace +{ +UIActivityIndicatorView *indicator; +} + +namespace iOS_utils +{ +double screenScale() +{ + return UIScreen.mainScreen.nativeScale; +} + +void showLoadingIndicator() +{ + NSCAssert(!indicator, @"activity indicator must be hidden before attempting to show it again"); + indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; + [indicator startAnimating]; + + auto mainView = UIApplication.sharedApplication.keyWindow.rootViewController.view; + mainView.userInteractionEnabled = NO; + [mainView addSubview:indicator]; + indicator.center = {CGRectGetMidX(mainView.bounds), CGRectGetMidY(mainView.bounds)}; +} + +void hideLoadingIndicator() +{ + indicator.superview.userInteractionEnabled = YES; + [indicator stopAnimating]; + [indicator removeFromSuperview]; + indicator = nil; +} +} diff --git a/client/ios/vcmi_logo.png b/client/ios/vcmi_logo.png new file mode 100644 index 000000000..1762c14aa Binary files /dev/null and b/client/ios/vcmi_logo.png differ diff --git a/client/lobby/CBonusSelection.h b/client/lobby/CBonusSelection.h index 9c9c7d178..ecf322758 100644 --- a/client/lobby/CBonusSelection.h +++ b/client/lobby/CBonusSelection.h @@ -10,8 +10,13 @@ #pragma once #include "../windows/CWindowObject.h" -struct SDL_Surface; +VCMI_LIB_NAMESPACE_BEGIN + class CCampaignState; + +VCMI_LIB_NAMESPACE_END + +struct SDL_Surface; class CButton; class CTextBox; class CToggleGroup; @@ -90,4 +95,4 @@ public: std::shared_ptr buttonDifficultyLeft; std::shared_ptr buttonDifficultyRight; std::shared_ptr iconsMapSizes; -}; \ No newline at end of file +}; diff --git a/client/lobby/CSavingScreen.h b/client/lobby/CSavingScreen.h index 20c04141d..ac966a457 100644 --- a/client/lobby/CSavingScreen.h +++ b/client/lobby/CSavingScreen.h @@ -11,10 +11,15 @@ #include "CSelectionBase.h" -class CSelectionBase; +VCMI_LIB_NAMESPACE_BEGIN + struct StartInfo; class CMapInfo; +VCMI_LIB_NAMESPACE_END + +class CSelectionBase; + class CSavingScreen : public CSelectionBase { public: diff --git a/client/lobby/CSelectionBase.h b/client/lobby/CSelectionBase.h index e157607fd..7d2671f6c 100644 --- a/client/lobby/CSelectionBase.h +++ b/client/lobby/CSelectionBase.h @@ -11,6 +11,14 @@ #include "../mainmenu/CMainMenu.h" +VCMI_LIB_NAMESPACE_BEGIN + +class CMapInfo; +struct StartInfo; +struct PlayerInfo; + +VCMI_LIB_NAMESPACE_END + class CButton; class CTextBox; class CTextInput; @@ -21,9 +29,6 @@ class OptionsTab; class SelectionTab; class InfoCard; class CChatBox; -class CMapInfo; -struct StartInfo; -struct PlayerInfo; class CLabel; class CFlagBox; class CLabelGroup; diff --git a/client/lobby/RandomMapTab.h b/client/lobby/RandomMapTab.h index f9e9f42b0..f7e399a17 100644 --- a/client/lobby/RandomMapTab.h +++ b/client/lobby/RandomMapTab.h @@ -14,7 +14,12 @@ #include "../../lib/FunctionList.h" #include "../../lib/GameConstants.h" +VCMI_LIB_NAMESPACE_BEGIN + class CMapGenOptions; + +VCMI_LIB_NAMESPACE_END + class CToggleButton; class CLabel; class CLabelGroup; diff --git a/client/lobby/SelectionTab.cpp b/client/lobby/SelectionTab.cpp index 0d135a915..6f65dc57c 100644 --- a/client/lobby/SelectionTab.cpp +++ b/client/lobby/SelectionTab.cpp @@ -129,7 +129,7 @@ static ESortBy getSortBySelectionScreen(ESelectionScreen Type) } SelectionTab::SelectionTab(ESelectionScreen Type) - : CIntObject(LCLICK | WHEEL | KEYBOARD | DOUBLECLICK), callOnSelect(nullptr), tabType(Type), selectionPos(0), sortModeAscending(true) + : CIntObject(LCLICK | WHEEL | KEYBOARD | DOUBLECLICK), callOnSelect(nullptr), tabType(Type), selectionPos(0), sortModeAscending(true), inputNameRect{32, 539, 350, 20} { OBJ_CONSTRUCTION; @@ -140,7 +140,7 @@ SelectionTab::SelectionTab(ESelectionScreen Type) sortingBy = _format; background = std::make_shared("SCSELBCK.bmp", 0, 6); pos = background->pos; - inputName = std::make_shared(Rect(32, 539, 350, 20), Point(-32, -25), "GSSTRIP.bmp", 0); + inputName = std::make_shared(inputNameRect, Point(-32, -25), "GSSTRIP.bmp", 0); inputName->filters += CTextInput::filenameFilter; labelMapSizes = std::make_shared(87, 62, FONT_SMALL, EAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[510]); @@ -273,6 +273,11 @@ void SelectionTab::clickLeft(tribool down, bool previousState) { select(line); } +#ifdef VCMI_IOS + // focus input field if clicked inside it + else if(inputName && inputName->active && inputNameRect.isIn(GH.current->button.x, GH.current->button.y)) + inputName->giveFocus(); +#endif } } diff --git a/client/lobby/SelectionTab.h b/client/lobby/SelectionTab.h index a6a974796..b9eb15599 100644 --- a/client/lobby/SelectionTab.h +++ b/client/lobby/SelectionTab.h @@ -90,6 +90,7 @@ private: std::shared_ptr labelTabTitle; std::shared_ptr labelMapSizes; ESelectionScreen tabType; + Rect inputNameRect; void parseMaps(const std::unordered_set & files); void parseSaves(const std::unordered_set & files); diff --git a/client/mainmenu/CCampaignScreen.h b/client/mainmenu/CCampaignScreen.h index b0a1acb85..f40f78c8c 100644 --- a/client/mainmenu/CCampaignScreen.h +++ b/client/mainmenu/CCampaignScreen.h @@ -11,11 +11,16 @@ #include "../windows/CWindowObject.h" +VCMI_LIB_NAMESPACE_BEGIN + +class JsonNode; + +VCMI_LIB_NAMESPACE_END + class CLabel; class CPicture; class CButton; struct SDL_Surface; -class JsonNode; class CCampaignScreen : public CWindowObject { diff --git a/client/mainmenu/CMainMenu.cpp b/client/mainmenu/CMainMenu.cpp index b04bd8034..da9171f7a 100644 --- a/client/mainmenu/CMainMenu.cpp +++ b/client/mainmenu/CMainMenu.cpp @@ -428,7 +428,9 @@ CMultiPlayers::CMultiPlayers(const std::string & firstPlayer, ESelectionScreen S statusBar = CGStatusBar::create(std::make_shared(Rect(7, 381, 348, 18), 0)); //226, 472 inputNames[0]->setText(firstPlayer, true); +#ifndef VCMI_IOS inputNames[0]->giveFocus(); +#endif } void CMultiPlayers::onChange(std::string newText) @@ -490,6 +492,7 @@ void CSimpleJoinScreen::connectToServer() { textTitle->setText("Connecting..."); buttonOk->block(true); + CSDL_Ext::stopTextInput(); boost::thread(&CSimpleJoinScreen::connectThread, this, inputAddress->text, boost::lexical_cast(inputPort->text)); } diff --git a/client/mainmenu/CMainMenu.h b/client/mainmenu/CMainMenu.h index 6220230b3..4fdebb93d 100644 --- a/client/mainmenu/CMainMenu.h +++ b/client/mainmenu/CMainMenu.h @@ -12,7 +12,12 @@ #include "../windows/CWindowObject.h" #include "../../lib/JsonNode.h" +VCMI_LIB_NAMESPACE_BEGIN + class CCampaignState; + +VCMI_LIB_NAMESPACE_END + class CTextInput; class CGStatusBar; class CTextBox; diff --git a/client/mapHandler.h b/client/mapHandler.h index 4c440d8ce..6a0e5a7f9 100644 --- a/client/mapHandler.h +++ b/client/mapHandler.h @@ -23,17 +23,22 @@ #undef OUT #endif +VCMI_LIB_NAMESPACE_BEGIN + class CGObjectInstance; class CGHeroInstance; class CGBoat; class CMap; struct TerrainTile; +class PlayerColor; + +VCMI_LIB_NAMESPACE_END + struct SDL_Surface; struct SDL_Rect; class CAnimation; class IImage; class CFadeAnimation; -class PlayerColor; enum class EWorldViewIcon { diff --git a/client/widgets/AdventureMapClasses.h b/client/widgets/AdventureMapClasses.h index de9b98c8b..639732a9f 100644 --- a/client/widgets/AdventureMapClasses.h +++ b/client/widgets/AdventureMapClasses.h @@ -13,21 +13,26 @@ #include "../../lib/FunctionList.h" #include "Terrain.h" +VCMI_LIB_NAMESPACE_BEGIN + class CArmedInstance; -class CAnimation; -class CAnimImage; -class CShowableAnim; -class CFilledTexture; class CGGarrison; class CGObjectInstance; class CGHeroInstance; class CGTownInstance; -class CButton; struct Component; -class CComponent; struct InfoAboutArmy; struct InfoAboutHero; struct InfoAboutTown; + +VCMI_LIB_NAMESPACE_END + +class CAnimation; +class CAnimImage; +class CShowableAnim; +class CFilledTexture; +class CButton; +class CComponent; class CHeroTooltip; class CTownTooltip; class CTextBox; diff --git a/client/widgets/Buttons.h b/client/widgets/Buttons.h index 9e8ac298b..d370b515e 100644 --- a/client/widgets/Buttons.h +++ b/client/widgets/Buttons.h @@ -14,17 +14,21 @@ #include "../../lib/FunctionList.h" +VCMI_LIB_NAMESPACE_BEGIN + +namespace config +{ +struct ButtonInfo; +} + +VCMI_LIB_NAMESPACE_END + struct SDL_Surface; struct Rect; class CAnimImage; class CLabel; class CAnimation; -namespace config -{ - struct ButtonInfo; -} - /// Typical Heroes 3 button which can be inactive or active and can /// hold further information if you right-click it class CButton : public CKeyShortcut diff --git a/client/widgets/CArtifactHolder.h b/client/widgets/CArtifactHolder.h index cdf92e69e..eff474737 100644 --- a/client/widgets/CArtifactHolder.h +++ b/client/widgets/CArtifactHolder.h @@ -11,12 +11,16 @@ #include "MiscWidgets.h" +VCMI_LIB_NAMESPACE_BEGIN + +struct ArtifactLocation; + +VCMI_LIB_NAMESPACE_END + class CArtifactsOfHero; class CAnimImage; class CButton; -struct ArtifactLocation; - class CArtifactHolder { public: diff --git a/client/widgets/CComponent.h b/client/widgets/CComponent.h index f46428b25..ba7ad3065 100644 --- a/client/widgets/CComponent.h +++ b/client/widgets/CComponent.h @@ -11,7 +11,12 @@ #include "../gui/CIntObject.h" +VCMI_LIB_NAMESPACE_BEGIN + struct Component; + +VCMI_LIB_NAMESPACE_END + class CAnimImage; class CLabel; diff --git a/client/widgets/CGarrisonInt.h b/client/widgets/CGarrisonInt.h index c14502a97..3c7a7914e 100644 --- a/client/widgets/CGarrisonInt.h +++ b/client/widgets/CGarrisonInt.h @@ -11,13 +11,18 @@ #include "../windows/CWindowObject.h" +VCMI_LIB_NAMESPACE_BEGIN + +class CArmedInstance; +class CCreatureSet; +class CStackInstance; + +VCMI_LIB_NAMESPACE_END + class CGarrisonInt; class CButton; -class CArmedInstance; class CAnimImage; -class CCreatureSet; class CGarrisonSlot; -class CStackInstance; class CLabel; /// A single garrison slot which holds one creature of a specific amount diff --git a/client/widgets/MiscWidgets.h b/client/widgets/MiscWidgets.h index c5f1088d7..f97a41bbf 100644 --- a/client/widgets/MiscWidgets.h +++ b/client/widgets/MiscWidgets.h @@ -11,13 +11,18 @@ #include "../gui/CIntObject.h" -class CLabel; -class CCreatureAnim; -class CComponent; +VCMI_LIB_NAMESPACE_BEGIN + class CGGarrison; struct InfoAboutArmy; class CArmedInstance; class IBonusBearer; + +VCMI_LIB_NAMESPACE_END + +class CLabel; +class CCreatureAnim; +class CComponent; class CAnimImage; /// Shows a text by moving the mouse cursor over the object diff --git a/client/widgets/TextControls.cpp b/client/widgets/TextControls.cpp index ba38207ed..b7854f127 100644 --- a/client/widgets/TextControls.cpp +++ b/client/widgets/TextControls.cpp @@ -420,7 +420,7 @@ CTextInput::CTextInput(const Rect & Pos, EFonts font, const CFunctionList(bgName, bgOffset.x, bgOffset.y); addUsedEvents(LCLICK | KEYBOARD | TEXTINPUT); -#ifndef VCMI_ANDROID +#if !(defined(VCMI_ANDROID) || defined(VCMI_IOS)) giveFocus(); #endif } @@ -459,7 +459,7 @@ CTextInput::CTextInput(const Rect & Pos, SDL_Surface * srf) background->pos = pos; addUsedEvents(LCLICK | KEYBOARD | TEXTINPUT); -#ifndef VCMI_ANDROID +#if !(defined(VCMI_ANDROID) || defined(VCMI_IOS)) giveFocus(); #endif } diff --git a/client/windows/CAdvmapInterface.cpp b/client/windows/CAdvmapInterface.cpp index c42fc9019..7de5234f3 100644 --- a/client/windows/CAdvmapInterface.cpp +++ b/client/windows/CAdvmapInterface.cpp @@ -125,7 +125,7 @@ void CTerrainRect::clickLeft(tribool down, bool previousState) if(indeterminate(down)) return; -#ifdef VCMI_ANDROID +#if defined(VCMI_ANDROID) || defined(VCMI_IOS) if(adventureInt->swipeEnabled) { if(handleSwipeStateChange((bool)down == true)) @@ -138,7 +138,7 @@ void CTerrainRect::clickLeft(tribool down, bool previousState) #endif if(down == false) return; -#ifdef VCMI_ANDROID +#if defined(VCMI_ANDROID) || defined(VCMI_IOS) } #endif int3 mp = whichTileIsIt(); @@ -150,7 +150,7 @@ void CTerrainRect::clickLeft(tribool down, bool previousState) void CTerrainRect::clickRight(tribool down, bool previousState) { -#ifdef VCMI_ANDROID +#if defined(VCMI_ANDROID) || defined(VCMI_IOS) if(adventureInt->swipeEnabled && isSwiping) return; #endif @@ -179,11 +179,11 @@ void CTerrainRect::mouseMoved(const SDL_MouseMotionEvent & sEvent) void CTerrainRect::handleSwipeMove(const SDL_MouseMotionEvent & sEvent) { -#ifdef VCMI_ANDROID - if(sEvent.state == 0) // any "button" is enough on android -#else //!VCMI_ANDROID +#if defined(VCMI_ANDROID) || defined(VCMI_IOS) + if(sEvent.state == 0) // any "button" is enough on mobile +#else if((sEvent.state & SDL_BUTTON_MMASK) == 0) // swipe only works with middle mouse on other platforms -#endif //!VCMI_ANDROID +#endif { return; } @@ -1049,9 +1049,9 @@ void CAdvMapInt::show(SDL_Surface * to) { handleSwipeUpdate(); } -#ifdef VCMI_ANDROID // on android, map-moving mode is exclusive (TODO technically it might work with both enabled; to be checked) +#if defined(VCMI_ANDROID) || defined(VCMI_IOS) // on mobile, map-moving mode is exclusive (TODO technically it might work with both enabled; to be checked) else -#endif // VCMI_ANDROID +#endif { handleMapScrollingUpdate(); } @@ -1451,7 +1451,7 @@ void CAdvMapInt::select(const CArmedInstance *sel, bool centerView) void CAdvMapInt::mouseMoved( const SDL_MouseMotionEvent & sEvent ) { -#ifdef VCMI_ANDROID +#if defined(VCMI_ANDROID) || defined(VCMI_IOS) if(swipeEnabled) return; #endif diff --git a/client/windows/CAdvmapInterface.h b/client/windows/CAdvmapInterface.h index 6c851828d..eb38b3cd6 100644 --- a/client/windows/CAdvmapInterface.h +++ b/client/windows/CAdvmapInterface.h @@ -17,14 +17,19 @@ #include "../../lib/spells/ViewSpellInt.h" -class CCallback; +VCMI_LIB_NAMESPACE_BEGIN + struct CGPath; -class CAdvMapInt; class CGHeroInstance; class CGTownInstance; -class CHeroWindow; class CSpell; class IShipyard; + +VCMI_LIB_NAMESPACE_END + +class CCallback; +class CAdvMapInt; +class CHeroWindow; enum class EMapAnimRedrawStatus; class CFadeAnimation; diff --git a/client/windows/CCastleInterface.h b/client/windows/CCastleInterface.h index 088bb63bf..915e7579d 100644 --- a/client/windows/CCastleInterface.h +++ b/client/windows/CCastleInterface.h @@ -12,23 +12,28 @@ #include "../widgets/CGarrisonInt.h" #include "../widgets/Images.h" -class CButton; +VCMI_LIB_NAMESPACE_BEGIN + class CBuilding; +class CGTownInstance; +class CSpell; +struct CStructure; +class CGHeroInstance; +class CCreature; + +VCMI_LIB_NAMESPACE_END + +class CButton; class CCastleBuildings; class CCreaturePic; class CGStatusBar; -class CGTownInstance; class CLabel; class CMinorResDataBar; class CPicture; class CResDataBar; -class CSpell; class CTextBox; class CTownList; -struct CStructure; -class CGHeroInstance; class CGarrisonInt; -class CCreature; class CComponent; class CComponentBox; diff --git a/client/windows/CCreatureWindow.h b/client/windows/CCreatureWindow.h index f19f32689..ef51b57b8 100644 --- a/client/windows/CCreatureWindow.h +++ b/client/windows/CCreatureWindow.h @@ -13,11 +13,16 @@ #include "../widgets/MiscWidgets.h" #include "CWindowObject.h" -class UnitView; +VCMI_LIB_NAMESPACE_BEGIN + class CCommanderInstance; class CStackInstance; class CStack; struct UpgradeInfo; + +VCMI_LIB_NAMESPACE_END + +class UnitView; class CTabbedInt; class CButton; class CMultiLineLabel; diff --git a/client/windows/CHeroWindow.h b/client/windows/CHeroWindow.h index b973117e8..685741b23 100644 --- a/client/windows/CHeroWindow.h +++ b/client/windows/CHeroWindow.h @@ -13,9 +13,14 @@ #include "../widgets/CArtifactHolder.h" #include "../widgets/CGarrisonInt.h" +VCMI_LIB_NAMESPACE_BEGIN + +class CGHeroInstance; + +VCMI_LIB_NAMESPACE_END + class CButton; struct SDL_Surface; -class CGHeroInstance; class CHeroWindow; class LClickableAreaHero; class LRClickableAreaWText; diff --git a/client/windows/CQuestLog.cpp b/client/windows/CQuestLog.cpp index 85c1a2a5d..fd5763ec0 100644 --- a/client/windows/CQuestLog.cpp +++ b/client/windows/CQuestLog.cpp @@ -29,7 +29,12 @@ #include "../../lib/NetPacksBase.h" #include "../../lib/mapObjects/CQuest.h" +VCMI_LIB_NAMESPACE_BEGIN + struct QuestInfo; + +VCMI_LIB_NAMESPACE_END + class CAdvmapInterface; void CQuestLabel::clickLeft(tribool down, bool previousState) diff --git a/client/windows/CQuestLog.h b/client/windows/CQuestLog.h index 47a2dfa59..228776617 100644 --- a/client/windows/CQuestLog.h +++ b/client/windows/CQuestLog.h @@ -15,11 +15,17 @@ #include "../widgets/Images.h" #include "CWindowObject.h" +VCMI_LIB_NAMESPACE_BEGIN + class CCreature; class CStackInstance; +class CGHeroInstance; +struct QuestInfo; + +VCMI_LIB_NAMESPACE_END + class CButton; class CToggleButton; -class CGHeroInstance; class CComponentBox; class LRClickableAreaWText; class CButton; @@ -28,7 +34,6 @@ class CCreaturePic; class LRClickableAreaWTextComp; class CSlider; class CLabel; -struct QuestInfo; const int QUEST_COUNT = 6; const int DESCRIPTION_HEIGHT_MAX = 355; diff --git a/client/windows/CSpellWindow.h b/client/windows/CSpellWindow.h index e77a60267..b23891da1 100644 --- a/client/windows/CSpellWindow.h +++ b/client/windows/CSpellWindow.h @@ -11,17 +11,22 @@ #include "CWindowObject.h" +VCMI_LIB_NAMESPACE_BEGIN + +class CGHeroInstance; +class CSpell; + +VCMI_LIB_NAMESPACE_END + struct SDL_Surface; struct SDL_Rect; class IImage; class CAnimImage; class CPicture; class CLabel; -class CGHeroInstance; class CGStatusBar; class CPlayerInterface; class CSpellWindow; -class CSpell; /// The spell window class CSpellWindow : public CWindowObject diff --git a/client/windows/CTradeWindow.h b/client/windows/CTradeWindow.h index fd7049d69..a19a56a62 100644 --- a/client/windows/CTradeWindow.h +++ b/client/windows/CTradeWindow.h @@ -13,7 +13,12 @@ #include "CWindowObject.h" #include "../../lib/FunctionList.h" +VCMI_LIB_NAMESPACE_BEGIN + class IMarket; + +VCMI_LIB_NAMESPACE_END + class CSlider; class CTextBox; class CGStatusBar; diff --git a/client/windows/GUIClasses.h b/client/windows/GUIClasses.h index dc6bc9980..98494cfb6 100644 --- a/client/windows/GUIClasses.h +++ b/client/windows/GUIClasses.h @@ -17,9 +17,14 @@ #include "../widgets/CGarrisonInt.h" #include "../widgets/Images.h" +VCMI_LIB_NAMESPACE_BEGIN + class CGDwelling; -class CreatureCostBox; class IMarket; + +VCMI_LIB_NAMESPACE_END + +class CreatureCostBox; class CCreaturePic; class MoraleLuckBox; class CHeroArea; diff --git a/client/windows/InfoWindows.cpp b/client/windows/InfoWindows.cpp index 7f3ee26d3..25e6432e5 100644 --- a/client/windows/InfoWindows.cpp +++ b/client/windows/InfoWindows.cpp @@ -308,6 +308,10 @@ void CRClickPopup::createAndPush(const std::string &txt, const CInfoWindow::TCom auto temp = std::make_shared(txt, player, comps); temp->center(Point(GH.current->motion)); //center on mouse +#ifdef VCMI_IOS + // TODO: enable also for android? + temp->moveBy({0, -temp->pos.h / 2}); +#endif temp->fitToScreen(10); GH.pushIntT(temp); diff --git a/client/windows/InfoWindows.h b/client/windows/InfoWindows.h index 95924308d..c05983bcc 100644 --- a/client/windows/InfoWindows.h +++ b/client/windows/InfoWindows.h @@ -12,6 +12,12 @@ #include "CWindowObject.h" #include "../../lib/FunctionList.h" +VCMI_LIB_NAMESPACE_BEGIN + +class CGGarrison; + +VCMI_LIB_NAMESPACE_END + struct SDL_Surface; struct Rect; class CAnimImage; @@ -19,7 +25,6 @@ class CLabel; class CAnimation; class CComponent; class CSelectableComponent; -class CGGarrison; class CTextBox; class CButton; class CSlider; diff --git a/cmake_modules/FindSDL2.cmake b/cmake_modules/FindSDL2.cmake index c74890eb2..c3c537a42 100644 --- a/cmake_modules/FindSDL2.cmake +++ b/cmake_modules/FindSDL2.cmake @@ -273,7 +273,7 @@ if(SDL2_LIBRARY) # I think it has something to do with the CACHE STRING. # So I use a temporary variable until the end so I can set the # "real" variable in one-shot. - if(APPLE) + if(APPLE_MACOS) set(SDL2_LIBRARIES ${SDL2_LIBRARIES} -framework Cocoa) endif() @@ -342,8 +342,28 @@ if(SDL2_FOUND) if(APPLE) # For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa. # For more details, please see above. - set_property(TARGET SDL2::SDL2 APPEND PROPERTY - INTERFACE_LINK_OPTIONS -framework Cocoa) + if (APPLE_MACOS) + set_property(TARGET SDL2::SDL2 APPEND PROPERTY + INTERFACE_LINK_OPTIONS -framework Cocoa) + elseif (APPLE_IOS) + target_link_libraries(SDL2::SDL2 INTERFACE + "-framework AudioToolbox" + "-framework AVFoundation" + "-framework CoreAudio" + "-framework CoreBluetooth" + "-framework CoreFoundation" + "-framework CoreGraphics" + "-framework CoreMotion" + "-framework CoreVideo" + "-framework GameController" + "-framework IOKit" + "-framework Metal" + "-framework OpenGLES" + "-framework QuartzCore" + "-framework UIKit" + "-weak_framework CoreHaptics" + ) + endif() else() # For threads, as mentioned Apple doesn't need this. # For more details, please see above. diff --git a/cmake_modules/FindSDL2_image.cmake b/cmake_modules/FindSDL2_image.cmake index 7373818fb..96fa819c9 100644 --- a/cmake_modules/FindSDL2_image.cmake +++ b/cmake_modules/FindSDL2_image.cmake @@ -227,5 +227,14 @@ if(SDL2_IMAGE_FOUND) IMPORTED_LOCATION "${SDL2_IMAGE_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${SDL2_IMAGE_INCLUDE_DIR}" INTERFACE_LINK_LIBRARIES SDL2::SDL2) + if (APPLE_IOS) + target_link_libraries(SDL2::Image INTERFACE + "-framework CoreGraphics" + "-framework Foundation" + "-framework ImageIO" + "-framework MobileCoreServices" + "-framework UIKit" + ) + endif() endif() endif() diff --git a/cmake_modules/FindSDL2_mixer.cmake b/cmake_modules/FindSDL2_mixer.cmake index 89e246846..8e9c9ac10 100644 --- a/cmake_modules/FindSDL2_mixer.cmake +++ b/cmake_modules/FindSDL2_mixer.cmake @@ -216,5 +216,11 @@ if(SDL2_MIXER_FOUND) IMPORTED_LOCATION "${SDL2_MIXER_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${SDL2_MIXER_INCLUDE_DIR}" INTERFACE_LINK_LIBRARIES SDL2::SDL2) + if (APPLE_IOS) + target_link_libraries(SDL2::Mixer INTERFACE + "-framework AudioToolbox" + "-framework CoreServices" + ) + endif() endif() endif() diff --git a/cmake_modules/Findffmpeg.cmake b/cmake_modules/Findffmpeg.cmake index 4cd749c67..2e813d9a9 100644 --- a/cmake_modules/Findffmpeg.cmake +++ b/cmake_modules/Findffmpeg.cmake @@ -175,7 +175,7 @@ foreach (_ffmpeg_component IN LISTS ffmpeg_FIND_COMPONENTS) "${ffmpeg_${_ffmpeg_component}_INCLUDE_DIRS}") list(APPEND ffmpeg_LIBRARIES "${ffmpeg_${_ffmpeg_component}_LIBRARIES}") - if (FFMEG_FIND_REQUIRED_${_ffmpeg_component}) + if (FFMPEG_FIND_REQUIRED_${_ffmpeg_component}) list(APPEND _ffmpeg_required_vars "ffmpeg_${_ffmpeg_required_vars}_INCLUDE_DIRS" "ffmpeg_${_ffmpeg_required_vars}_LIBRARIES") diff --git a/cmake_modules/Findminizip.cmake b/cmake_modules/Findminizip.cmake index e5cf684b3..13b81b73c 100644 --- a/cmake_modules/Findminizip.cmake +++ b/cmake_modules/Findminizip.cmake @@ -33,7 +33,7 @@ else() set(VC_LIB_PATH_SUFFIX lib/x86) endif() -if (NOT WIN32) +if (NOT WIN32 AND NOT APPLE_IOS) find_package(PkgConfig) if (PKG_CONFIG_FOUND) pkg_check_modules(_MINIZIP minizip) diff --git a/cmake_modules/VCMI_lib.cmake b/cmake_modules/VCMI_lib.cmake new file mode 100644 index 000000000..b143c860e --- /dev/null +++ b/cmake_modules/VCMI_lib.cmake @@ -0,0 +1,536 @@ +macro(add_main_lib TARGET_NAME LIBRARY_TYPE) + set(MAIN_LIB_DIR "${CMAKE_SOURCE_DIR}/lib") + set(lib_SRCS + ${MAIN_LIB_DIR}/StdInc.cpp + ${CMAKE_BINARY_DIR}/Version.cpp + + ${MAIN_LIB_DIR}/battle/AccessibilityInfo.cpp + ${MAIN_LIB_DIR}/battle/BattleAction.cpp + ${MAIN_LIB_DIR}/battle/BattleAttackInfo.cpp + ${MAIN_LIB_DIR}/battle/BattleHex.cpp + ${MAIN_LIB_DIR}/battle/BattleInfo.cpp + ${MAIN_LIB_DIR}/battle/BattleProxy.cpp + ${MAIN_LIB_DIR}/battle/CBattleInfoCallback.cpp + ${MAIN_LIB_DIR}/battle/CBattleInfoEssentials.cpp + ${MAIN_LIB_DIR}/battle/CCallbackBase.cpp + ${MAIN_LIB_DIR}/battle/CObstacleInstance.cpp + ${MAIN_LIB_DIR}/battle/CPlayerBattleCallback.cpp + ${MAIN_LIB_DIR}/battle/CUnitState.cpp + ${MAIN_LIB_DIR}/battle/Destination.cpp + ${MAIN_LIB_DIR}/battle/IBattleState.cpp + ${MAIN_LIB_DIR}/battle/ReachabilityInfo.cpp + ${MAIN_LIB_DIR}/battle/SideInBattle.cpp + ${MAIN_LIB_DIR}/battle/SiegeInfo.cpp + ${MAIN_LIB_DIR}/battle/Unit.cpp + + ${MAIN_LIB_DIR}/events/ApplyDamage.cpp + ${MAIN_LIB_DIR}/events/GameResumed.cpp + ${MAIN_LIB_DIR}/events/ObjectVisitEnded.cpp + ${MAIN_LIB_DIR}/events/ObjectVisitStarted.cpp + ${MAIN_LIB_DIR}/events/PlayerGotTurn.cpp + ${MAIN_LIB_DIR}/events/TurnStarted.cpp + + ${MAIN_LIB_DIR}/filesystem/AdapterLoaders.cpp + ${MAIN_LIB_DIR}/filesystem/CArchiveLoader.cpp + ${MAIN_LIB_DIR}/filesystem/CBinaryReader.cpp + ${MAIN_LIB_DIR}/filesystem/CCompressedStream.cpp + ${MAIN_LIB_DIR}/filesystem/CFileInputStream.cpp + ${MAIN_LIB_DIR}/filesystem/CFilesystemLoader.cpp + ${MAIN_LIB_DIR}/filesystem/CMemoryBuffer.cpp + ${MAIN_LIB_DIR}/filesystem/CMemoryStream.cpp + ${MAIN_LIB_DIR}/filesystem/CZipLoader.cpp + ${MAIN_LIB_DIR}/filesystem/CZipSaver.cpp + ${MAIN_LIB_DIR}/filesystem/FileInfo.cpp + ${MAIN_LIB_DIR}/filesystem/FileStream.cpp + ${MAIN_LIB_DIR}/filesystem/Filesystem.cpp + ${MAIN_LIB_DIR}/filesystem/MinizipExtensions.cpp + ${MAIN_LIB_DIR}/filesystem/ResourceID.cpp + + ${MAIN_LIB_DIR}/logging/CBasicLogConfigurator.cpp + ${MAIN_LIB_DIR}/logging/CLogger.cpp + + ${MAIN_LIB_DIR}/mapObjects/CArmedInstance.cpp + ${MAIN_LIB_DIR}/mapObjects/CBank.cpp + ${MAIN_LIB_DIR}/mapObjects/CGHeroInstance.cpp + ${MAIN_LIB_DIR}/mapObjects/CGMarket.cpp + ${MAIN_LIB_DIR}/mapObjects/CGPandoraBox.cpp + ${MAIN_LIB_DIR}/mapObjects/CGTownInstance.cpp + ${MAIN_LIB_DIR}/mapObjects/CObjectClassesHandler.cpp + ${MAIN_LIB_DIR}/mapObjects/CObjectHandler.cpp + ${MAIN_LIB_DIR}/mapObjects/CommonConstructors.cpp + ${MAIN_LIB_DIR}/mapObjects/CQuest.cpp + ${MAIN_LIB_DIR}/mapObjects/CRewardableConstructor.cpp + ${MAIN_LIB_DIR}/mapObjects/CRewardableObject.cpp + ${MAIN_LIB_DIR}/mapObjects/JsonRandom.cpp + ${MAIN_LIB_DIR}/mapObjects/MiscObjects.cpp + ${MAIN_LIB_DIR}/mapObjects/ObjectTemplate.cpp + + ${MAIN_LIB_DIR}/mapping/CCampaignHandler.cpp + ${MAIN_LIB_DIR}/mapping/CDrawRoadsOperation.cpp + ${MAIN_LIB_DIR}/mapping/CMap.cpp + ${MAIN_LIB_DIR}/mapping/CMapEditManager.cpp + ${MAIN_LIB_DIR}/mapping/CMapInfo.cpp + ${MAIN_LIB_DIR}/mapping/CMapOperation.cpp + ${MAIN_LIB_DIR}/mapping/CMapService.cpp + ${MAIN_LIB_DIR}/mapping/MapEditUtils.cpp + ${MAIN_LIB_DIR}/mapping/MapFormatH3M.cpp + ${MAIN_LIB_DIR}/mapping/MapFormatJson.cpp + + ${MAIN_LIB_DIR}/registerTypes/RegisterTypes.cpp + ${MAIN_LIB_DIR}/registerTypes/TypesClientPacks1.cpp + ${MAIN_LIB_DIR}/registerTypes/TypesClientPacks2.cpp + ${MAIN_LIB_DIR}/registerTypes/TypesMapObjects1.cpp + ${MAIN_LIB_DIR}/registerTypes/TypesMapObjects2.cpp + ${MAIN_LIB_DIR}/registerTypes/TypesMapObjects3.cpp + ${MAIN_LIB_DIR}/registerTypes/TypesLobbyPacks.cpp + ${MAIN_LIB_DIR}/registerTypes/TypesServerPacks.cpp + + ${MAIN_LIB_DIR}/rmg/RmgArea.cpp + ${MAIN_LIB_DIR}/rmg/RmgObject.cpp + ${MAIN_LIB_DIR}/rmg/RmgPath.cpp + ${MAIN_LIB_DIR}/rmg/CMapGenerator.cpp + ${MAIN_LIB_DIR}/rmg/CMapGenOptions.cpp + ${MAIN_LIB_DIR}/rmg/CRmgTemplate.cpp + ${MAIN_LIB_DIR}/rmg/CRmgTemplateStorage.cpp + ${MAIN_LIB_DIR}/rmg/CZonePlacer.cpp + ${MAIN_LIB_DIR}/rmg/TileInfo.cpp + ${MAIN_LIB_DIR}/rmg/Zone.cpp + ${MAIN_LIB_DIR}/rmg/Functions.cpp + ${MAIN_LIB_DIR}/rmg/ObjectManager.cpp + ${MAIN_LIB_DIR}/rmg/RoadPlacer.cpp + ${MAIN_LIB_DIR}/rmg/TreasurePlacer.cpp + ${MAIN_LIB_DIR}/rmg/RmgMap.cpp + ${MAIN_LIB_DIR}/rmg/ConnectionsPlacer.cpp + ${MAIN_LIB_DIR}/rmg/WaterAdopter.cpp + ${MAIN_LIB_DIR}/rmg/TownPlacer.cpp + ${MAIN_LIB_DIR}/rmg/WaterProxy.cpp + ${MAIN_LIB_DIR}/rmg/WaterRoutes.cpp + ${MAIN_LIB_DIR}/rmg/RockPlacer.cpp + ${MAIN_LIB_DIR}/rmg/ObstaclePlacer.cpp + ${MAIN_LIB_DIR}/rmg/RiverPlacer.cpp + ${MAIN_LIB_DIR}/rmg/TerrainPainter.cpp + + ${MAIN_LIB_DIR}/serializer/BinaryDeserializer.cpp + ${MAIN_LIB_DIR}/serializer/BinarySerializer.cpp + ${MAIN_LIB_DIR}/serializer/CLoadIntegrityValidator.cpp + ${MAIN_LIB_DIR}/serializer/CMemorySerializer.cpp + ${MAIN_LIB_DIR}/serializer/Connection.cpp + ${MAIN_LIB_DIR}/serializer/CSerializer.cpp + ${MAIN_LIB_DIR}/serializer/CTypeList.cpp + ${MAIN_LIB_DIR}/serializer/JsonDeserializer.cpp + ${MAIN_LIB_DIR}/serializer/JsonSerializeFormat.cpp + ${MAIN_LIB_DIR}/serializer/JsonSerializer.cpp + ${MAIN_LIB_DIR}/serializer/JsonUpdater.cpp + + ${MAIN_LIB_DIR}/spells/AbilityCaster.cpp + ${MAIN_LIB_DIR}/spells/AdventureSpellMechanics.cpp + ${MAIN_LIB_DIR}/spells/BattleSpellMechanics.cpp + ${MAIN_LIB_DIR}/spells/BonusCaster.cpp + ${MAIN_LIB_DIR}/spells/CSpellHandler.cpp + ${MAIN_LIB_DIR}/spells/ISpellMechanics.cpp + ${MAIN_LIB_DIR}/spells/Problem.cpp + ${MAIN_LIB_DIR}/spells/ProxyCaster.cpp + ${MAIN_LIB_DIR}/spells/TargetCondition.cpp + ${MAIN_LIB_DIR}/spells/ViewSpellInt.cpp + + ${MAIN_LIB_DIR}/spells/effects/Catapult.cpp + ${MAIN_LIB_DIR}/spells/effects/Clone.cpp + ${MAIN_LIB_DIR}/spells/effects/Damage.cpp + ${MAIN_LIB_DIR}/spells/effects/Dispel.cpp + ${MAIN_LIB_DIR}/spells/effects/Effect.cpp + ${MAIN_LIB_DIR}/spells/effects/Effects.cpp + ${MAIN_LIB_DIR}/spells/effects/Heal.cpp + ${MAIN_LIB_DIR}/spells/effects/LocationEffect.cpp + ${MAIN_LIB_DIR}/spells/effects/Obstacle.cpp + ${MAIN_LIB_DIR}/spells/effects/Registry.cpp + ${MAIN_LIB_DIR}/spells/effects/UnitEffect.cpp + ${MAIN_LIB_DIR}/spells/effects/Summon.cpp + ${MAIN_LIB_DIR}/spells/effects/Teleport.cpp + ${MAIN_LIB_DIR}/spells/effects/Timed.cpp + ${MAIN_LIB_DIR}/spells/effects/RemoveObstacle.cpp + ${MAIN_LIB_DIR}/spells/effects/Sacrifice.cpp + + ${MAIN_LIB_DIR}/vstd/StringUtils.cpp + + ${MAIN_LIB_DIR}/BattleFieldHandler.cpp + ${MAIN_LIB_DIR}/CAndroidVMHelper.cpp + ${MAIN_LIB_DIR}/CArtHandler.cpp + ${MAIN_LIB_DIR}/CBonusTypeHandler.cpp + ${MAIN_LIB_DIR}/CBuildingHandler.cpp + ${MAIN_LIB_DIR}/CConfigHandler.cpp + ${MAIN_LIB_DIR}/CConsoleHandler.cpp + ${MAIN_LIB_DIR}/CCreatureHandler.cpp + ${MAIN_LIB_DIR}/CCreatureSet.cpp + ${MAIN_LIB_DIR}/CGameInfoCallback.cpp + ${MAIN_LIB_DIR}/CGameInterface.cpp + ${MAIN_LIB_DIR}/CGameState.cpp + ${MAIN_LIB_DIR}/CGeneralTextHandler.cpp + ${MAIN_LIB_DIR}/CHeroHandler.cpp + ${MAIN_LIB_DIR}/CModHandler.cpp + ${MAIN_LIB_DIR}/CPathfinder.cpp + ${MAIN_LIB_DIR}/CPlayerState.cpp + ${MAIN_LIB_DIR}/CRandomGenerator.cpp + ${MAIN_LIB_DIR}/CScriptingModule.cpp + ${MAIN_LIB_DIR}/CSkillHandler.cpp + ${MAIN_LIB_DIR}/CStack.cpp + ${MAIN_LIB_DIR}/CThreadHelper.cpp + ${MAIN_LIB_DIR}/CTownHandler.cpp + ${MAIN_LIB_DIR}/GameConstants.cpp + ${MAIN_LIB_DIR}/HeroBonus.cpp + ${MAIN_LIB_DIR}/IGameCallback.cpp + ${MAIN_LIB_DIR}/IHandlerBase.cpp + ${MAIN_LIB_DIR}/JsonDetail.cpp + ${MAIN_LIB_DIR}/JsonNode.cpp + ${MAIN_LIB_DIR}/LoadProgress.cpp + ${MAIN_LIB_DIR}/LogicalExpression.cpp + ${MAIN_LIB_DIR}/NetPacksLib.cpp + ${MAIN_LIB_DIR}/ObstacleHandler.cpp + ${MAIN_LIB_DIR}/StartInfo.cpp + ${MAIN_LIB_DIR}/ResourceSet.cpp + ${MAIN_LIB_DIR}/ScriptHandler.cpp + ${MAIN_LIB_DIR}/Terrain.cpp + ${MAIN_LIB_DIR}/VCMIDirs.cpp + ${MAIN_LIB_DIR}/VCMI_Lib.cpp + + ${VCMILIB_ADDITIONAL_SOURCES} + ) + + # Version.cpp is a generated file + set_source_files_properties(${CMAKE_BINARY_DIR}/Version.cpp + PROPERTIES GENERATED TRUE + ) + + set(lib_HEADERS + ${CMAKE_SOURCE_DIR}/include/vstd/CLoggerBase.h + ${CMAKE_SOURCE_DIR}/Global.h + ${MAIN_LIB_DIR}/StdInc.h + + ${CMAKE_SOURCE_DIR}/include/vstd/ContainerUtils.h + ${CMAKE_SOURCE_DIR}/include/vstd/RNG.h + ${CMAKE_SOURCE_DIR}/include/vstd/StringUtils.h + + ${CMAKE_SOURCE_DIR}/include/vcmi/events/ApplyDamage.h + ${CMAKE_SOURCE_DIR}/include/vcmi/events/Event.h + ${CMAKE_SOURCE_DIR}/include/vcmi/events/EventBus.h + ${CMAKE_SOURCE_DIR}/include/vcmi/events/SubscriptionRegistry.h + + ${CMAKE_SOURCE_DIR}/include/vcmi/scripting/Service.h + + ${CMAKE_SOURCE_DIR}/include/vcmi/spells/Caster.h + ${CMAKE_SOURCE_DIR}/include/vcmi/spells/Magic.h + ${CMAKE_SOURCE_DIR}/include/vcmi/spells/Service.h + ${CMAKE_SOURCE_DIR}/include/vcmi/spells/Spell.h + + ${CMAKE_SOURCE_DIR}/include/vcmi/Artifact.h + ${CMAKE_SOURCE_DIR}/include/vcmi/ArtifactService.h + ${CMAKE_SOURCE_DIR}/include/vcmi/Creature.h + ${CMAKE_SOURCE_DIR}/include/vcmi/CreatureService.h + ${CMAKE_SOURCE_DIR}/include/vcmi/Entity.h + ${CMAKE_SOURCE_DIR}/include/vcmi/Environment.h + ${CMAKE_SOURCE_DIR}/include/vcmi/Services.h + + ${MAIN_LIB_DIR}/abilities/Ability.h + + ${MAIN_LIB_DIR}/battle/AccessibilityInfo.h + ${MAIN_LIB_DIR}/battle/BattleAction.h + ${MAIN_LIB_DIR}/battle/BattleAttackInfo.h + ${MAIN_LIB_DIR}/battle/BattleHex.h + ${MAIN_LIB_DIR}/battle/BattleInfo.h + ${MAIN_LIB_DIR}/battle/BattleProxy.h + ${MAIN_LIB_DIR}/battle/CBattleInfoCallback.h + ${MAIN_LIB_DIR}/battle/CBattleInfoEssentials.h + ${MAIN_LIB_DIR}/battle/CCallbackBase.h + ${MAIN_LIB_DIR}/battle/CObstacleInstance.h + ${MAIN_LIB_DIR}/battle/CPlayerBattleCallback.h + ${MAIN_LIB_DIR}/battle/CUnitState.h + ${MAIN_LIB_DIR}/battle/Destination.h + ${MAIN_LIB_DIR}/battle/IBattleInfoCallback.h + ${MAIN_LIB_DIR}/battle/IBattleState.h + ${MAIN_LIB_DIR}/battle/IUnitInfo.h + ${MAIN_LIB_DIR}/battle/ReachabilityInfo.h + ${MAIN_LIB_DIR}/battle/SideInBattle.h + ${MAIN_LIB_DIR}/battle/SiegeInfo.h + ${MAIN_LIB_DIR}/battle/Unit.h + + ${MAIN_LIB_DIR}/events/ApplyDamage.h + ${MAIN_LIB_DIR}/events/GameResumed.h + ${MAIN_LIB_DIR}/events/ObjectVisitEnded.h + ${MAIN_LIB_DIR}/events/ObjectVisitStarted.h + ${MAIN_LIB_DIR}/events/PlayerGotTurn.h + ${MAIN_LIB_DIR}/events/TurnStarted.h + + ${MAIN_LIB_DIR}/filesystem/AdapterLoaders.h + ${MAIN_LIB_DIR}/filesystem/CArchiveLoader.h + ${MAIN_LIB_DIR}/filesystem/CBinaryReader.h + ${MAIN_LIB_DIR}/filesystem/CCompressedStream.h + ${MAIN_LIB_DIR}/filesystem/CFileInputStream.h + ${MAIN_LIB_DIR}/filesystem/CFilesystemLoader.h + ${MAIN_LIB_DIR}/filesystem/CInputOutputStream.h + ${MAIN_LIB_DIR}/filesystem/CInputStream.h + ${MAIN_LIB_DIR}/filesystem/CMemoryBuffer.h + ${MAIN_LIB_DIR}/filesystem/CMemoryStream.h + ${MAIN_LIB_DIR}/filesystem/COutputStream.h + ${MAIN_LIB_DIR}/filesystem/CStream.h + ${MAIN_LIB_DIR}/filesystem/CZipLoader.h + ${MAIN_LIB_DIR}/filesystem/CZipSaver.h + ${MAIN_LIB_DIR}/filesystem/FileInfo.h + ${MAIN_LIB_DIR}/filesystem/FileStream.h + ${MAIN_LIB_DIR}/filesystem/Filesystem.h + ${MAIN_LIB_DIR}/filesystem/ISimpleResourceLoader.h + ${MAIN_LIB_DIR}/filesystem/MinizipExtensions.h + ${MAIN_LIB_DIR}/filesystem/ResourceID.h + + ${MAIN_LIB_DIR}/logging/CBasicLogConfigurator.h + ${MAIN_LIB_DIR}/logging/CLogger.h + + ${MAIN_LIB_DIR}/mapObjects/CArmedInstance.h + ${MAIN_LIB_DIR}/mapObjects/CBank.h + ${MAIN_LIB_DIR}/mapObjects/CGHeroInstance.h + ${MAIN_LIB_DIR}/mapObjects/CGMarket.h + ${MAIN_LIB_DIR}/mapObjects/CGPandoraBox.h + ${MAIN_LIB_DIR}/mapObjects/CGTownInstance.h + ${MAIN_LIB_DIR}/mapObjects/CObjectClassesHandler.h + ${MAIN_LIB_DIR}/mapObjects/CObjectHandler.h + ${MAIN_LIB_DIR}/mapObjects/CommonConstructors.h + ${MAIN_LIB_DIR}/mapObjects/CQuest.h + ${MAIN_LIB_DIR}/mapObjects/CRewardableConstructor.h + ${MAIN_LIB_DIR}/mapObjects/CRewardableObject.h + ${MAIN_LIB_DIR}/mapObjects/JsonRandom.h + ${MAIN_LIB_DIR}/mapObjects/MapObjects.h + ${MAIN_LIB_DIR}/mapObjects/MiscObjects.h + ${MAIN_LIB_DIR}/mapObjects/ObjectTemplate.h + + ${MAIN_LIB_DIR}/mapping/CCampaignHandler.h + ${MAIN_LIB_DIR}/mapping/CDrawRoadsOperation.h + ${MAIN_LIB_DIR}/mapping/CMapDefines.h + ${MAIN_LIB_DIR}/mapping/CMapEditManager.h + ${MAIN_LIB_DIR}/mapping/CMap.h + ${MAIN_LIB_DIR}/mapping/CMapInfo.h + ${MAIN_LIB_DIR}/mapping/CMapOperation.h + ${MAIN_LIB_DIR}/mapping/CMapService.h + ${MAIN_LIB_DIR}/mapping/MapEditUtils.h + ${MAIN_LIB_DIR}/mapping/MapFormatH3M.h + ${MAIN_LIB_DIR}/mapping/MapFormatJson.h + + ${MAIN_LIB_DIR}/registerTypes/RegisterTypes.h + + ${MAIN_LIB_DIR}/rmg/RmgArea.h + ${MAIN_LIB_DIR}/rmg/RmgObject.h + ${MAIN_LIB_DIR}/rmg/RmgPath.h + ${MAIN_LIB_DIR}/rmg/CMapGenerator.h + ${MAIN_LIB_DIR}/rmg/CMapGenOptions.h + ${MAIN_LIB_DIR}/rmg/CRmgTemplate.h + ${MAIN_LIB_DIR}/rmg/CRmgTemplateStorage.h + ${MAIN_LIB_DIR}/rmg/CZonePlacer.h + ${MAIN_LIB_DIR}/rmg/TileInfo.h + ${MAIN_LIB_DIR}/rmg/Zone.h + ${MAIN_LIB_DIR}/rmg/Functions.h + ${MAIN_LIB_DIR}/rmg/ObjectManager.h + ${MAIN_LIB_DIR}/rmg/RoadPlacer.h + ${MAIN_LIB_DIR}/rmg/TreasurePlacer.h + ${MAIN_LIB_DIR}/rmg/RmgMap.h + ${MAIN_LIB_DIR}/rmg/ConnectionsPlacer.h + ${MAIN_LIB_DIR}/rmg/WaterAdopter.h + ${MAIN_LIB_DIR}/rmg/TownPlacer.h + ${MAIN_LIB_DIR}/rmg/WaterProxy.h + ${MAIN_LIB_DIR}/rmg/WaterRoutes.h + ${MAIN_LIB_DIR}/rmg/RockPlacer.h + ${MAIN_LIB_DIR}/rmg/ObstaclePlacer.h + ${MAIN_LIB_DIR}/rmg/RiverPlacer.h + ${MAIN_LIB_DIR}/rmg/TerrainPainter.h + ${MAIN_LIB_DIR}/rmg/float3.h + + ${MAIN_LIB_DIR}/serializer/BinaryDeserializer.h + ${MAIN_LIB_DIR}/serializer/BinarySerializer.h + ${MAIN_LIB_DIR}/serializer/CLoadIntegrityValidator.h + ${MAIN_LIB_DIR}/serializer/CMemorySerializer.h + ${MAIN_LIB_DIR}/serializer/Connection.h + ${MAIN_LIB_DIR}/serializer/CSerializer.h + ${MAIN_LIB_DIR}/serializer/CTypeList.h + ${MAIN_LIB_DIR}/serializer/JsonDeserializer.h + ${MAIN_LIB_DIR}/serializer/JsonSerializeFormat.h + ${MAIN_LIB_DIR}/serializer/JsonSerializer.h + ${MAIN_LIB_DIR}/serializer/JsonUpdater.h + ${MAIN_LIB_DIR}/serializer/Cast.h + + ${MAIN_LIB_DIR}/spells/AbilityCaster.h + ${MAIN_LIB_DIR}/spells/AdventureSpellMechanics.h + ${MAIN_LIB_DIR}/spells/BattleSpellMechanics.h + ${MAIN_LIB_DIR}/spells/BonusCaster.h + ${MAIN_LIB_DIR}/spells/CSpellHandler.h + ${MAIN_LIB_DIR}/spells/ISpellMechanics.h + ${MAIN_LIB_DIR}/spells/Problem.h + ${MAIN_LIB_DIR}/spells/ProxyCaster.h + ${MAIN_LIB_DIR}/spells/TargetCondition.h + ${MAIN_LIB_DIR}/spells/ViewSpellInt.h + + ${MAIN_LIB_DIR}/spells/effects/Catapult.h + ${MAIN_LIB_DIR}/spells/effects/Clone.h + ${MAIN_LIB_DIR}/spells/effects/Damage.h + ${MAIN_LIB_DIR}/spells/effects/Dispel.h + ${MAIN_LIB_DIR}/spells/effects/Effect.h + ${MAIN_LIB_DIR}/spells/effects/Effects.h + ${MAIN_LIB_DIR}/spells/effects/EffectsFwd.h + ${MAIN_LIB_DIR}/spells/effects/Heal.h + ${MAIN_LIB_DIR}/spells/effects/LocationEffect.h + ${MAIN_LIB_DIR}/spells/effects/Obstacle.h + ${MAIN_LIB_DIR}/spells/effects/Registry.h + ${MAIN_LIB_DIR}/spells/effects/UnitEffect.h + ${MAIN_LIB_DIR}/spells/effects/Summon.h + ${MAIN_LIB_DIR}/spells/effects/Teleport.h + ${MAIN_LIB_DIR}/spells/effects/Timed.h + ${MAIN_LIB_DIR}/spells/effects/RemoveObstacle.h + ${MAIN_LIB_DIR}/spells/effects/Sacrifice.h + + ${MAIN_LIB_DIR}/AI_Base.h + ${MAIN_LIB_DIR}/BattleFieldHandler.h + ${MAIN_LIB_DIR}/CAndroidVMHelper.h + ${MAIN_LIB_DIR}/CArtHandler.h + ${MAIN_LIB_DIR}/CBonusTypeHandler.h + ${MAIN_LIB_DIR}/CBuildingHandler.h + ${MAIN_LIB_DIR}/CConfigHandler.h + ${MAIN_LIB_DIR}/CConsoleHandler.h + ${MAIN_LIB_DIR}/CCreatureHandler.h + ${MAIN_LIB_DIR}/CCreatureSet.h + ${MAIN_LIB_DIR}/CGameInfoCallback.h + ${MAIN_LIB_DIR}/CGameInterface.h + ${MAIN_LIB_DIR}/CGameStateFwd.h + ${MAIN_LIB_DIR}/CGameState.h + ${MAIN_LIB_DIR}/CGeneralTextHandler.h + ${MAIN_LIB_DIR}/CHeroHandler.h + ${MAIN_LIB_DIR}/CModHandler.h + ${MAIN_LIB_DIR}/CondSh.h + ${MAIN_LIB_DIR}/ConstTransitivePtr.h + ${MAIN_LIB_DIR}/CPathfinder.h + ${MAIN_LIB_DIR}/CPlayerState.h + ${MAIN_LIB_DIR}/CRandomGenerator.h + ${MAIN_LIB_DIR}/CScriptingModule.h + ${MAIN_LIB_DIR}/CSkillHandler.h + ${MAIN_LIB_DIR}/CSoundBase.h + ${MAIN_LIB_DIR}/CStack.h + ${MAIN_LIB_DIR}/CStopWatch.h + ${MAIN_LIB_DIR}/CThreadHelper.h + ${MAIN_LIB_DIR}/CTownHandler.h + ${MAIN_LIB_DIR}/FunctionList.h + ${MAIN_LIB_DIR}/GameConstants.h + ${MAIN_LIB_DIR}/HeroBonus.h + ${MAIN_LIB_DIR}/IBonusTypeHandler.h + ${MAIN_LIB_DIR}/IGameCallback.h + ${MAIN_LIB_DIR}/IGameEventsReceiver.h + ${MAIN_LIB_DIR}/IHandlerBase.h + ${MAIN_LIB_DIR}/int3.h + ${MAIN_LIB_DIR}/Interprocess.h + ${MAIN_LIB_DIR}/JsonDetail.h + ${MAIN_LIB_DIR}/JsonNode.h + ${MAIN_LIB_DIR}/LoadProgress.h + ${MAIN_LIB_DIR}/LogicalExpression.h + ${MAIN_LIB_DIR}/NetPacksBase.h + ${MAIN_LIB_DIR}/NetPacks.h + ${MAIN_LIB_DIR}/NetPacksLobby.h + ${MAIN_LIB_DIR}/ObstacleHandler.h + ${MAIN_LIB_DIR}/PathfinderUtil.h + ${MAIN_LIB_DIR}/ResourceSet.h + ${MAIN_LIB_DIR}/ScriptHandler.h + ${MAIN_LIB_DIR}/ScopeGuard.h + ${MAIN_LIB_DIR}/StartInfo.h + ${MAIN_LIB_DIR}/StringConstants.h + ${MAIN_LIB_DIR}/Terrain.h + ${MAIN_LIB_DIR}/UnlockGuard.h + ${MAIN_LIB_DIR}/VCMIDirs.h + ${MAIN_LIB_DIR}/vcmi_endian.h + ${MAIN_LIB_DIR}/VCMI_Lib.h + ) + + assign_source_group(${lib_SRCS} ${lib_HEADERS}) + + add_library(${TARGET_NAME} ${LIBRARY_TYPE} ${lib_SRCS} ${lib_HEADERS}) + set_target_properties(${TARGET_NAME} PROPERTIES COMPILE_DEFINITIONS "VCMI_DLL=1") + target_link_libraries(${TARGET_NAME} PUBLIC + minizip::minizip ZLIB::ZLIB + ${SYSTEM_LIBS} Boost::boost Boost::thread Boost::filesystem Boost::program_options Boost::locale Boost::date_time + ) + if(APPLE_IOS) + target_link_libraries(${TARGET_NAME} PUBLIC iOS_utils) + endif() + + target_include_directories(${TARGET_NAME} + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} + PUBLIC ${CMAKE_SOURCE_DIR} + PUBLIC ${CMAKE_SOURCE_DIR}/include + PUBLIC ${MAIN_LIB_DIR} + PRIVATE ${SDL2_INCLUDE_DIR} + ) + + if(WIN32) + set_target_properties(${TARGET_NAME} + PROPERTIES + OUTPUT_NAME "VCMI_lib" + PROJECT_LABEL "VCMI_lib" + ) + endif() + + if(ANDROID) + return() + endif() + + vcmi_set_output_dir(${TARGET_NAME} "") + + enable_pch(${TARGET_NAME}) + + # We want to deploy assets into build directory for easier debugging without install + if(NOT APPLE_IOS) + add_custom_command(TARGET ${TARGET_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/config + COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/Mods + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/config ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/config + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/Mods ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/Mods + ) + endif() + + # Update version before vcmi compiling + if(TARGET update_version) + add_dependencies(${TARGET_NAME} update_version) + endif() + + if("${LIBRARY_TYPE}" STREQUAL SHARED) + install(TARGETS ${TARGET_NAME} RUNTIME DESTINATION ${LIB_DIR} LIBRARY DESTINATION ${LIB_DIR}) + endif() + if(APPLE_IOS) + get_target_property(LINKED_LIBS ${TARGET_NAME} LINK_LIBRARIES) + foreach(LINKED_LIB IN LISTS LINKED_LIBS) + if(NOT TARGET ${LINKED_LIB}) + if(LINKED_LIB MATCHES "\\${CMAKE_SHARED_LIBRARY_SUFFIX}$") + install(FILES ${LINKED_LIB} DESTINATION ${LIB_DIR}) + endif() + continue() + endif() + + get_target_property(LIB_TYPE ${LINKED_LIB} TYPE) + if(NOT LIB_TYPE STREQUAL "SHARED_LIBRARY") + continue() + endif() + + get_target_property(_aliased ${LINKED_LIB} ALIASED_TARGET) + if(_aliased) + set(LINKED_LIB_REAL ${_aliased}) + else() + set(LINKED_LIB_REAL ${LINKED_LIB}) + endif() + + get_target_property(_imported ${LINKED_LIB_REAL} IMPORTED) + if(_imported) + set(INSTALL_TYPE IMPORTED_RUNTIME_ARTIFACTS) + get_target_property(BOOST_DEPENDENCIES ${LINKED_LIB_REAL} INTERFACE_LINK_LIBRARIES) + foreach(BOOST_DEPENDENCY IN LISTS BOOST_DEPENDENCIES) + get_target_property(BOOST_DEPENDENCY_TYPE ${BOOST_DEPENDENCY} TYPE) + if(BOOST_DEPENDENCY_TYPE STREQUAL "SHARED_LIBRARY") + install(IMPORTED_RUNTIME_ARTIFACTS ${BOOST_DEPENDENCY} LIBRARY DESTINATION ${LIB_DIR}) + endif() + endforeach() + else() + set(INSTALL_TYPE TARGETS) + endif() + install(${INSTALL_TYPE} ${LINKED_LIB_REAL} LIBRARY DESTINATION ${LIB_DIR}) + endforeach() + endif() +endmacro() diff --git a/include/vcmi/Artifact.h b/include/vcmi/Artifact.h index 7ffd8431f..f9f7ad89e 100644 --- a/include/vcmi/Artifact.h +++ b/include/vcmi/Artifact.h @@ -12,6 +12,8 @@ #include "Entity.h" +VCMI_LIB_NAMESPACE_BEGIN + class ArtifactID; class CreatureID; @@ -25,3 +27,5 @@ public: virtual uint32_t getPrice() const = 0; virtual CreatureID getWarMachine() const = 0; }; + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/ArtifactService.h b/include/vcmi/ArtifactService.h index 3dc8588b1..ecd8ebc99 100644 --- a/include/vcmi/ArtifactService.h +++ b/include/vcmi/ArtifactService.h @@ -12,6 +12,8 @@ #include "EntityService.h" +VCMI_LIB_NAMESPACE_BEGIN + class ArtifactID; class Artifact; @@ -19,3 +21,5 @@ class DLL_LINKAGE ArtifactService : public EntityServiceT { public: }; + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/Creature.h b/include/vcmi/Creature.h index c3c5ba2a2..1ada50ce2 100644 --- a/include/vcmi/Creature.h +++ b/include/vcmi/Creature.h @@ -12,6 +12,8 @@ #include "Entity.h" +VCMI_LIB_NAMESPACE_BEGIN + class CreatureID; class DLL_LINKAGE Creature : public EntityWithBonuses @@ -43,3 +45,5 @@ public: virtual bool isDoubleWide() const = 0; }; + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/CreatureService.h b/include/vcmi/CreatureService.h index 2e3ad04e0..860a3a575 100644 --- a/include/vcmi/CreatureService.h +++ b/include/vcmi/CreatureService.h @@ -12,6 +12,8 @@ #include "EntityService.h" +VCMI_LIB_NAMESPACE_BEGIN + class CreatureID; class Creature; @@ -19,3 +21,5 @@ class DLL_LINKAGE CreatureService : public EntityServiceT { public: }; + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/Entity.h b/include/vcmi/Entity.h index 877cb3372..77a70f5d1 100644 --- a/include/vcmi/Entity.h +++ b/include/vcmi/Entity.h @@ -10,6 +10,8 @@ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + class IBonusBearer; class DLL_LINKAGE Entity @@ -40,3 +42,5 @@ class DLL_LINKAGE EntityWithBonuses : public EntityT public: virtual const IBonusBearer * accessBonuses() const = 0; }; + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/EntityService.h b/include/vcmi/EntityService.h index 1b818131e..96c90ca5d 100644 --- a/include/vcmi/EntityService.h +++ b/include/vcmi/EntityService.h @@ -10,6 +10,8 @@ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + class Entity; class DLL_LINKAGE EntityService @@ -30,3 +32,5 @@ public: virtual void forEach(const std::function & cb) const = 0; }; + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/Environment.h b/include/vcmi/Environment.h index 0fa63aa89..8c456bca2 100644 --- a/include/vcmi/Environment.h +++ b/include/vcmi/Environment.h @@ -10,6 +10,8 @@ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + class Services; class IGameInfoCallback; @@ -23,8 +25,8 @@ namespace events class DLL_LINKAGE Environment { public: - using BattleCb = ::IBattleInfoCallback; - using GameCb = ::IGameInfoCallback; + using BattleCb = IBattleInfoCallback; + using GameCb = IGameInfoCallback; virtual ~Environment() = default; @@ -34,3 +36,5 @@ public: virtual vstd::CLoggerBase * logger() const = 0; virtual events::EventBus * eventBus() const = 0; }; + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/Faction.h b/include/vcmi/Faction.h index 5fc52c2fb..de50f29b9 100644 --- a/include/vcmi/Faction.h +++ b/include/vcmi/Faction.h @@ -12,6 +12,8 @@ #include "Entity.h" +VCMI_LIB_NAMESPACE_BEGIN + class FactionID; class DLL_LINKAGE Faction : public EntityT @@ -19,3 +21,5 @@ class DLL_LINKAGE Faction : public EntityT public: virtual bool hasTown() const = 0; }; + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/FactionService.h b/include/vcmi/FactionService.h index 884d77868..94cf78122 100644 --- a/include/vcmi/FactionService.h +++ b/include/vcmi/FactionService.h @@ -12,6 +12,8 @@ #include "EntityService.h" +VCMI_LIB_NAMESPACE_BEGIN + class FactionID; class Faction; @@ -19,3 +21,5 @@ class DLL_LINKAGE FactionService : public EntityServiceT { public: }; + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/HeroClass.h b/include/vcmi/HeroClass.h index 713672003..5440910e0 100644 --- a/include/vcmi/HeroClass.h +++ b/include/vcmi/HeroClass.h @@ -12,6 +12,8 @@ #include "Entity.h" +VCMI_LIB_NAMESPACE_BEGIN + class HeroClassID; class DLL_LINKAGE HeroClass : public EntityT @@ -20,3 +22,5 @@ public: }; + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/HeroClassService.h b/include/vcmi/HeroClassService.h index 9fb85c00b..df872c08d 100644 --- a/include/vcmi/HeroClassService.h +++ b/include/vcmi/HeroClassService.h @@ -12,6 +12,8 @@ #include "EntityService.h" +VCMI_LIB_NAMESPACE_BEGIN + class HeroClassID; class HeroClass; @@ -19,3 +21,5 @@ class DLL_LINKAGE HeroClassService : public EntityServiceT @@ -20,3 +22,5 @@ public: }; + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/HeroTypeService.h b/include/vcmi/HeroTypeService.h index 81f4305bb..dca8a438f 100644 --- a/include/vcmi/HeroTypeService.h +++ b/include/vcmi/HeroTypeService.h @@ -12,6 +12,8 @@ #include "EntityService.h" +VCMI_LIB_NAMESPACE_BEGIN + class HeroTypeID; class HeroType; @@ -19,3 +21,5 @@ class DLL_LINKAGE HeroTypeService : public EntityServiceT { public: }; + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/Metatype.h b/include/vcmi/Metatype.h index e8101f4c8..0ed9b1464 100644 --- a/include/vcmi/Metatype.h +++ b/include/vcmi/Metatype.h @@ -10,6 +10,8 @@ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + enum class Metatype : uint32_t { UNKNOWN = 0, @@ -28,3 +30,5 @@ enum class Metatype : uint32_t SPELL }; + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/Player.h b/include/vcmi/Player.h index ac79e94a1..d559d1e7b 100644 --- a/include/vcmi/Player.h +++ b/include/vcmi/Player.h @@ -10,6 +10,8 @@ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + class PlayerColor; class TeamID; class IBonusBearer; @@ -24,7 +26,4 @@ public: virtual int getResourceAmount(int type) const = 0; }; - - - - +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/ServerCallback.h b/include/vcmi/ServerCallback.h index af35b4ea5..d69257009 100644 --- a/include/vcmi/ServerCallback.h +++ b/include/vcmi/ServerCallback.h @@ -10,6 +10,8 @@ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + namespace vstd { class RNG; @@ -44,3 +46,5 @@ public: virtual void apply(BattleObstaclesChanged * pack) = 0; virtual void apply(CatapultAttack * pack) = 0; }; + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/Services.h b/include/vcmi/Services.h index 1bc33a1dd..33535a1d4 100644 --- a/include/vcmi/Services.h +++ b/include/vcmi/Services.h @@ -12,6 +12,8 @@ #include "Metatype.h" +VCMI_LIB_NAMESPACE_BEGIN + class ArtifactService; class CreatureService; class FactionService; @@ -63,3 +65,5 @@ public: virtual spells::effects::Registry * spellEffects() = 0; //TODO: put map object types registry access here }; + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/Skill.h b/include/vcmi/Skill.h index 14b308486..363e67869 100644 --- a/include/vcmi/Skill.h +++ b/include/vcmi/Skill.h @@ -12,6 +12,8 @@ #include "Entity.h" +VCMI_LIB_NAMESPACE_BEGIN + class SecondarySkill; class DLL_LINKAGE Skill : public EntityT @@ -20,3 +22,5 @@ public: }; + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/SkillService.h b/include/vcmi/SkillService.h index 47a9bbce9..6e8618898 100644 --- a/include/vcmi/SkillService.h +++ b/include/vcmi/SkillService.h @@ -12,6 +12,8 @@ #include "EntityService.h" +VCMI_LIB_NAMESPACE_BEGIN + class SecondarySkill; class Skill; @@ -19,3 +21,5 @@ class DLL_LINKAGE SkillService : public EntityServiceT { public: }; + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/events/ApplyDamage.h b/include/vcmi/events/ApplyDamage.h index c92e80aeb..5ea190e4f 100644 --- a/include/vcmi/events/ApplyDamage.h +++ b/include/vcmi/events/ApplyDamage.h @@ -13,6 +13,8 @@ #include "Event.h" #include "SubscriptionRegistry.h" +VCMI_LIB_NAMESPACE_BEGIN + struct BattleStackAttacked; namespace battle @@ -43,3 +45,5 @@ public: }; } + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/events/Event.h b/include/vcmi/events/Event.h index 3f92a30bc..a1b44ccc7 100644 --- a/include/vcmi/events/Event.h +++ b/include/vcmi/events/Event.h @@ -10,6 +10,8 @@ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + namespace events { @@ -27,3 +29,5 @@ public: } + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/events/EventBus.h b/include/vcmi/events/EventBus.h index e77f53370..4e46be043 100644 --- a/include/vcmi/events/EventBus.h +++ b/include/vcmi/events/EventBus.h @@ -12,6 +12,8 @@ #include "SubscriptionRegistry.h" +VCMI_LIB_NAMESPACE_BEGIN + class Environment; namespace events @@ -42,3 +44,5 @@ public: } }; } + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/events/GameResumed.h b/include/vcmi/events/GameResumed.h index 33a8436f1..0bc7f99e7 100644 --- a/include/vcmi/events/GameResumed.h +++ b/include/vcmi/events/GameResumed.h @@ -13,6 +13,8 @@ #include "Event.h" #include "SubscriptionRegistry.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace events { @@ -33,3 +35,5 @@ public: }; } + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/events/ObjectVisitEnded.h b/include/vcmi/events/ObjectVisitEnded.h index b8508e260..7789d5e3a 100644 --- a/include/vcmi/events/ObjectVisitEnded.h +++ b/include/vcmi/events/ObjectVisitEnded.h @@ -13,6 +13,8 @@ #include "Event.h" #include "SubscriptionRegistry.h" +VCMI_LIB_NAMESPACE_BEGIN + class PlayerColor; class ObjectInstanceID; @@ -38,3 +40,5 @@ public: }; } + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/events/ObjectVisitStarted.h b/include/vcmi/events/ObjectVisitStarted.h index 8e8577ca0..747aaf02c 100644 --- a/include/vcmi/events/ObjectVisitStarted.h +++ b/include/vcmi/events/ObjectVisitStarted.h @@ -13,6 +13,8 @@ #include "Event.h" #include "SubscriptionRegistry.h" +VCMI_LIB_NAMESPACE_BEGIN + class PlayerColor; class ObjectInstanceID; @@ -41,3 +43,5 @@ public: }; } + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/events/PlayerGotTurn.h b/include/vcmi/events/PlayerGotTurn.h index 4b6fa009b..a75380cca 100644 --- a/include/vcmi/events/PlayerGotTurn.h +++ b/include/vcmi/events/PlayerGotTurn.h @@ -13,6 +13,8 @@ #include "Event.h" #include "SubscriptionRegistry.h" +VCMI_LIB_NAMESPACE_BEGIN + class PlayerColor; namespace events @@ -39,3 +41,5 @@ public: }; } + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/events/SubscriptionRegistry.h b/include/vcmi/events/SubscriptionRegistry.h index 01af2876f..0e273d79c 100644 --- a/include/vcmi/events/SubscriptionRegistry.h +++ b/include/vcmi/events/SubscriptionRegistry.h @@ -10,6 +10,8 @@ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + class Environment; namespace events @@ -164,3 +166,5 @@ private: } }; } + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/events/TurnStarted.h b/include/vcmi/events/TurnStarted.h index 1caccddf6..a5a600047 100644 --- a/include/vcmi/events/TurnStarted.h +++ b/include/vcmi/events/TurnStarted.h @@ -13,6 +13,8 @@ #include "Event.h" #include "SubscriptionRegistry.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace events { @@ -31,3 +33,5 @@ public: }; } + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/scripting/Service.h b/include/vcmi/scripting/Service.h index e94300598..c000ae052 100644 --- a/include/vcmi/scripting/Service.h +++ b/include/vcmi/scripting/Service.h @@ -13,6 +13,8 @@ #if SCRIPTING_ENABLED #include +VCMI_LIB_NAMESPACE_BEGIN + class Services; class JsonNode; class ServerCallback; @@ -20,8 +22,8 @@ class ServerCallback; namespace scripting { -using BattleCb = ::Environment::BattleCb; -using GameCb = ::Environment::GameCb; +using BattleCb = Environment::BattleCb; +using GameCb = Environment::GameCb; class DLL_LINKAGE Context { @@ -79,4 +81,6 @@ public: } + +VCMI_LIB_NAMESPACE_END #endif diff --git a/include/vcmi/spells/Caster.h b/include/vcmi/spells/Caster.h index 5ed5ca475..123865a97 100644 --- a/include/vcmi/spells/Caster.h +++ b/include/vcmi/spells/Caster.h @@ -10,6 +10,8 @@ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + class PlayerColor; struct MetaString; class ServerCallback; @@ -66,3 +68,5 @@ public: }; } + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/spells/Magic.h b/include/vcmi/spells/Magic.h index 65d7f5ef2..af69982f2 100644 --- a/include/vcmi/spells/Magic.h +++ b/include/vcmi/spells/Magic.h @@ -10,6 +10,8 @@ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + struct MetaString; namespace battle @@ -24,7 +26,7 @@ class Caster; class Spell; class Mechanics; class BattleCast; -using Destination = ::battle::Destination; +using Destination = battle::Destination; using Target = std::vector; @@ -67,3 +69,5 @@ public: }; } + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/spells/Service.h b/include/vcmi/spells/Service.h index badd9487a..98fb863a7 100644 --- a/include/vcmi/spells/Service.h +++ b/include/vcmi/spells/Service.h @@ -12,6 +12,8 @@ #include "../EntityService.h" +VCMI_LIB_NAMESPACE_BEGIN + class SpellID; namespace spells @@ -24,3 +26,5 @@ public: }; } + +VCMI_LIB_NAMESPACE_END diff --git a/include/vcmi/spells/Spell.h b/include/vcmi/spells/Spell.h index e64fb11a4..302ae05f6 100644 --- a/include/vcmi/spells/Spell.h +++ b/include/vcmi/spells/Spell.h @@ -12,6 +12,8 @@ #include "../Entity.h" +VCMI_LIB_NAMESPACE_BEGIN + class SpellID; namespace spells @@ -54,3 +56,5 @@ public: }; } + +VCMI_LIB_NAMESPACE_END diff --git a/include/vstd/CLoggerBase.h b/include/vstd/CLoggerBase.h index 0c5ad7f10..24df8a0a7 100644 --- a/include/vstd/CLoggerBase.h +++ b/include/vstd/CLoggerBase.h @@ -10,6 +10,8 @@ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + namespace ELogLevel { enum ELogLevel @@ -191,3 +193,5 @@ extern DLL_LINKAGE vstd::CLoggerBase * logNetwork; extern DLL_LINKAGE vstd::CLoggerBase * logAi; extern DLL_LINKAGE vstd::CLoggerBase * logAnim; extern DLL_LINKAGE vstd::CLoggerBase * logMod; + +VCMI_LIB_NAMESPACE_END diff --git a/include/vstd/ContainerUtils.h b/include/vstd/ContainerUtils.h index cb616a775..0e93a13e5 100644 --- a/include/vstd/ContainerUtils.h +++ b/include/vstd/ContainerUtils.h @@ -10,6 +10,8 @@ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + namespace vstd { template @@ -24,5 +26,4 @@ namespace vstd } } - - +VCMI_LIB_NAMESPACE_END diff --git a/include/vstd/RNG.h b/include/vstd/RNG.h index 5535b13e9..9a8653141 100644 --- a/include/vstd/RNG.h +++ b/include/vstd/RNG.h @@ -10,6 +10,8 @@ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + namespace vstd { @@ -56,3 +58,5 @@ namespace RandomGeneratorUtil } } } + +VCMI_LIB_NAMESPACE_END diff --git a/include/vstd/StringUtils.h b/include/vstd/StringUtils.h index 9b90fdbe3..b6d3ac8e4 100644 --- a/include/vstd/StringUtils.h +++ b/include/vstd/StringUtils.h @@ -1,5 +1,7 @@ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + namespace vstd { @@ -7,3 +9,5 @@ namespace vstd DLL_LINKAGE std::pair splitStringToPair(std::string input, char separator); } + +VCMI_LIB_NAMESPACE_END diff --git a/ios/CMakeLists.txt b/ios/CMakeLists.txt new file mode 100644 index 000000000..0f8359c1c --- /dev/null +++ b/ios/CMakeLists.txt @@ -0,0 +1,10 @@ +add_library(iOS_utils SHARED + iOS_utils.h + iOS_utils.mm +) +target_link_libraries(iOS_utils PRIVATE + "-framework Foundation" +) +target_include_directories(iOS_utils PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + +vcmi_set_output_dir(iOS_utils "") diff --git a/ios/codesign.sh b/ios/codesign.sh new file mode 100755 index 000000000..9c85eaf68 --- /dev/null +++ b/ios/codesign.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +if [[ "$PLATFORM_NAME" == *simulator* || "$CODE_SIGNING_ALLOWED_FOR_APPS" == 'NO' || -z "$EXPANDED_CODE_SIGN_IDENTITY" ]]; then + exit 0 +fi + +echo 'codesign dylibs' +for lib in $(find "$CODESIGNING_FOLDER_PATH/Frameworks" -type f -iname '*.dylib'); do + codesign --verbose=4 --force --timestamp=none --sign "$EXPANDED_CODE_SIGN_IDENTITY" "$lib" +done diff --git a/ios/iOS_utils.h b/ios/iOS_utils.h new file mode 100644 index 000000000..666644789 --- /dev/null +++ b/ios/iOS_utils.h @@ -0,0 +1,29 @@ +/* + * iOS_utils.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ +#pragma once + +#include + +#pragma GCC visibility push(default) +namespace iOS_utils +{ +const char *documentsPath(); +const char *cachesPath(); + +#if TARGET_OS_SIMULATOR +const char *hostApplicationSupportPath(); +#endif + +const char *bundlePath(); +const char *frameworksPath(); + +const char *bundleIdentifier(); +} +#pragma GCC visibility pop diff --git a/ios/iOS_utils.mm b/ios/iOS_utils.mm new file mode 100644 index 000000000..40772519c --- /dev/null +++ b/ios/iOS_utils.mm @@ -0,0 +1,49 @@ +/* + * iOS_utils.mm, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + +#include "iOS_utils.h" + +#import + +namespace +{ +NSString *standardPathNative(NSSearchPathDirectory directory) +{ + return [NSFileManager.defaultManager URLForDirectory:directory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:NULL].path; +} +const char *standardPath(NSSearchPathDirectory directory) { return standardPathNative(directory).fileSystemRepresentation; } +} + + +namespace iOS_utils +{ +const char *documentsPath() { return standardPath(NSDocumentDirectory); } +const char *cachesPath() { return standardPath(NSCachesDirectory); } + +#if TARGET_OS_SIMULATOR +const char *hostApplicationSupportPath() +{ + static NSString *applicationSupportPath; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + auto cachesPath = standardPathNative(NSCachesDirectory); + auto afterMacOsHomeDirPos = [cachesPath rangeOfString:@"Library/Developer"].location; + NSCAssert(afterMacOsHomeDirPos != NSNotFound, @"simulator directory location is not under user's home directory: %@", cachesPath); + applicationSupportPath = [[cachesPath substringToIndex:afterMacOsHomeDirPos] stringByAppendingPathComponent:@"Library/Application Support/vcmi"].stringByResolvingSymlinksInPath; + }); + return applicationSupportPath.fileSystemRepresentation; +} +#endif + +const char *bundlePath() { return NSBundle.mainBundle.bundlePath.fileSystemRepresentation; } +const char *frameworksPath() { return NSBundle.mainBundle.privateFrameworksPath.fileSystemRepresentation; } + +const char *bundleIdentifier() { return NSBundle.mainBundle.bundleIdentifier.UTF8String; } +} diff --git a/ios/zip2ipa.sh b/ios/zip2ipa.sh new file mode 100755 index 000000000..2c37459d1 --- /dev/null +++ b/ios/zip2ipa.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +generatedZip="$1" +if [[ -z "$generatedZip" ]]; then + echo 'generated zip not provided as param' + exit 1 +fi + +mv "$generatedZip" "$(basename "$generatedZip" .zip).ipa" diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index e9fd1ec00..695d1524a 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -43,6 +43,7 @@ set(launcher_HEADERS launcherdirs.h jsonutils.h updatedialog_moc.h + main.h ) set(launcher_FORMS @@ -53,6 +54,12 @@ set(launcher_FORMS updatedialog_moc.ui ) +if(APPLE_IOS) + list(APPEND launcher_SRCS + ios/main.m + ) +endif() + assign_source_group(${launcher_SRCS} ${launcher_HEADERS} VCMI_launcher.rc) # Tell CMake to run moc when necessary: @@ -76,7 +83,11 @@ if(WIN32) set(launcher_ICON VCMI_launcher.rc) endif() -add_executable(vcmilauncher WIN32 ${launcher_SRCS} ${launcher_HEADERS} ${launcher_UI_HEADERS} ${launcher_ICON}) +if(BUILD_SINGLE_APP) + add_library(vcmilauncher STATIC ${launcher_SRCS} ${launcher_HEADERS} ${launcher_UI_HEADERS}) +else() + add_executable(vcmilauncher WIN32 ${launcher_SRCS} ${launcher_HEADERS} ${launcher_UI_HEADERS} ${launcher_ICON}) +endif() if(WIN32) set_target_properties(vcmilauncher @@ -99,24 +110,30 @@ if(APPLE) set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER vcmilauncher) endif() -target_link_libraries(vcmilauncher vcmi Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network) +target_link_libraries(vcmilauncher ${VCMI_LIB_TARGET} Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network) target_include_directories(vcmilauncher PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ) vcmi_set_output_dir(vcmilauncher "") enable_pch(vcmilauncher) -# Copy to build directory for easier debugging -add_custom_command(TARGET vcmilauncher POST_BUILD - COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/launcher/icons - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/launcher/icons ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/launcher/icons -) +if(APPLE_IOS) + set(ICONS_DESTINATION ${DATA_DIR}) +else() + set(ICONS_DESTINATION ${DATA_DIR}/launcher) -install(TARGETS vcmilauncher DESTINATION ${BIN_DIR}) -# copy whole directory -install(DIRECTORY icons DESTINATION ${DATA_DIR}/launcher) -# Install icons and desktop file on Linux -if(NOT WIN32 AND NOT APPLE) - install(FILES "vcmilauncher.desktop" DESTINATION share/applications) - install(FILES "eu.vcmi.VCMI.metainfo.xml" DESTINATION share/metainfo) + # Copy to build directory for easier debugging + add_custom_command(TARGET vcmilauncher POST_BUILD + COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/launcher/icons + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/launcher/icons ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/launcher/icons + ) + + install(TARGETS vcmilauncher DESTINATION ${BIN_DIR}) + + # Install icons and desktop file on Linux + if(NOT WIN32 AND NOT APPLE) + install(FILES "vcmilauncher.desktop" DESTINATION share/applications) + install(FILES "eu.vcmi.VCMI.metainfo.xml" DESTINATION share/metainfo) + endif() endif() +install(DIRECTORY icons DESTINATION ${ICONS_DESTINATION}) diff --git a/launcher/StdInc.h b/launcher/StdInc.h index dcaee354c..e97483820 100644 --- a/launcher/StdInc.h +++ b/launcher/StdInc.h @@ -10,6 +10,8 @@ #include #include +VCMI_LIB_USING_NAMESPACE + inline QString pathToQString(const boost::filesystem::path & path) { #ifdef VCMI_WINDOWS diff --git a/launcher/ios/main.m b/launcher/ios/main.m new file mode 100644 index 000000000..5f14d4ff1 --- /dev/null +++ b/launcher/ios/main.m @@ -0,0 +1,30 @@ +/* + * main.m, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ +#import + +void launchGame(int argc, char * argv[]) { + @autoreleasepool { + __auto_type app = UIApplication.sharedApplication; + __auto_type qtNativeWindowIndex = [app.windows indexOfObjectPassingTest:^BOOL(__kindof UIWindow * _Nonnull window, NSUInteger idx, BOOL * _Nonnull stop) { + return [NSStringFromClass([window class]) isEqualToString:@"QUIWindow"]; + }]; + NSCAssert(qtNativeWindowIndex != NSNotFound, @"Qt native window doesn't exist"); + + __auto_type qtNativeWindow = app.windows[qtNativeWindowIndex]; + qtNativeWindow.hidden = YES; + [qtNativeWindow.rootViewController.view removeFromSuperview]; + qtNativeWindow.rootViewController = nil; +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0 + if (@available(iOS 13.0, *)) + qtNativeWindow.windowScene = nil; +#endif + } + [NSNotificationCenter.defaultCenter postNotificationName:@"StartGame" object:nil]; +} diff --git a/launcher/jsonutils.cpp b/launcher/jsonutils.cpp index fb2c66834..ccf7bd629 100644 --- a/launcher/jsonutils.cpp +++ b/launcher/jsonutils.cpp @@ -51,6 +51,8 @@ static JsonMap VariantToMap(QVariantMap variant) return map; } +VCMI_LIB_NAMESPACE_BEGIN + namespace JsonUtils { @@ -123,3 +125,5 @@ void JsonToFile(QString filename, QVariant object) } } + +VCMI_LIB_NAMESPACE_END diff --git a/launcher/jsonutils.h b/launcher/jsonutils.h index 09425b48f..6dd7e7bbf 100644 --- a/launcher/jsonutils.h +++ b/launcher/jsonutils.h @@ -12,6 +12,8 @@ #include #include "../lib/JsonNode.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace JsonUtils { QVariant toVariant(const JsonNode & node); @@ -20,3 +22,5 @@ QVariant JsonFromFile(QString filename); JsonNode toJson(QVariant object); void JsonToFile(QString filename, QVariant object); } + +VCMI_LIB_NAMESPACE_END diff --git a/launcher/main.cpp b/launcher/main.cpp index 5bfa2467b..343bc85a5 100644 --- a/launcher/main.cpp +++ b/launcher/main.cpp @@ -7,14 +7,25 @@ * Full text of license available in license.txt file, in main folder * */ -#include -#include "StdInc.h" +#include "main.h" #include "mainwindow_moc.h" +#include + int main(int argc, char * argv[]) { + int result; +#ifdef VCMI_IOS + { +#endif QApplication vcmilauncher(argc, argv); MainWindow mainWindow; mainWindow.show(); - return vcmilauncher.exec(); + result = vcmilauncher.exec(); +#ifdef VCMI_IOS + } + if (result == 0) + launchGame(argc, argv); +#endif + return result; } diff --git a/launcher/main.h b/launcher/main.h new file mode 100644 index 000000000..8c77747d2 --- /dev/null +++ b/launcher/main.h @@ -0,0 +1,14 @@ +/* + * main.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ +#pragma once + +#ifdef VCMI_IOS +extern "C" void launchGame(int argc, char * argv[]); +#endif diff --git a/launcher/mainwindow_moc.cpp b/launcher/mainwindow_moc.cpp index 4aca35f9a..82769300f 100644 --- a/launcher/mainwindow_moc.cpp +++ b/launcher/mainwindow_moc.cpp @@ -34,9 +34,13 @@ void MainWindow::load() CResourceHandler::initialize(); CResourceHandler::load("config/filesystem.json"); +#ifdef Q_OS_IOS + QDir::addSearchPath("icons", pathToQString(VCMIDirs::get().binaryPath() / "icons")); +#else for(auto & string : VCMIDirs::get().dataPaths()) QDir::addSearchPath("icons", pathToQString(string / "launcher" / "icons")); QDir::addSearchPath("icons", pathToQString(VCMIDirs::get().userDataPath() / "launcher" / "icons")); +#endif settings.init(); } @@ -99,9 +103,14 @@ MainWindow::~MainWindow() void MainWindow::on_startGameButton_clicked() { +#ifdef Q_OS_IOS + qApp->quit(); +#else startExecutable(pathToQString(VCMIDirs::get().clientPath())); +#endif } +#ifndef Q_OS_IOS void MainWindow::startExecutable(QString name) { QProcess process; @@ -119,6 +128,6 @@ void MainWindow::startExecutable(QString name) "Reason: " + process.errorString(), QMessageBox::Ok, QMessageBox::Ok); - return; } } +#endif diff --git a/launcher/mainwindow_moc.h b/launcher/mainwindow_moc.h index ce7c9d625..3ca4d9327 100644 --- a/launcher/mainwindow_moc.h +++ b/launcher/mainwindow_moc.h @@ -27,7 +27,9 @@ class MainWindow : public QMainWindow private: Ui::MainWindow * ui; void load(); +#ifndef Q_OS_IOS void startExecutable(QString name); +#endif public: explicit MainWindow(QWidget * parent = 0); diff --git a/launcher/modManager/cmodlist.h b/launcher/modManager/cmodlist.h index 2bce79c6d..0b3cc76b8 100644 --- a/launcher/modManager/cmodlist.h +++ b/launcher/modManager/cmodlist.h @@ -9,12 +9,18 @@ */ #pragma once +#include "StdInc.h" + #include #include #include +VCMI_LIB_NAMESPACE_BEGIN + class JsonNode; +VCMI_LIB_NAMESPACE_END + namespace ModStatus { enum EModStatus diff --git a/launcher/settingsView/csettingsview_moc.cpp b/launcher/settingsView/csettingsview_moc.cpp index 106666988..95c2a872a 100644 --- a/launcher/settingsView/csettingsview_moc.cpp +++ b/launcher/settingsView/csettingsview_moc.cpp @@ -67,9 +67,17 @@ void CSettingsView::loadSettings() int resIndex = ui->comboBoxResolution->findText(QString("%1x%2").arg(resX).arg(resY)); ui->comboBoxResolution->setCurrentIndex(resIndex); - ui->comboBoxFullScreen->setCurrentIndex(settings["video"]["fullscreen"].Bool()); ui->comboBoxShowIntro->setCurrentIndex(settings["video"]["showIntro"].Bool()); + +#ifdef Q_OS_IOS + ui->comboBoxFullScreen->setCurrentIndex(true); + ui->checkBoxFullScreen->setChecked(false); + for (auto widget : std::initializer_list{ui->comboBoxFullScreen, ui->checkBoxFullScreen}) + widget->setDisabled(true); +#else + ui->comboBoxFullScreen->setCurrentIndex(settings["video"]["fullscreen"].Bool()); ui->checkBoxFullScreen->setChecked(settings["video"]["realFullscreen"].Bool()); +#endif int friendlyAIIndex = ui->comboBoxFriendlyAI->findText(QString::fromUtf8(settings["server"]["friendlyAI"].String().c_str())); int neutralAIIndex = ui->comboBoxNeutralAI->findText(QString::fromUtf8(settings["server"]["neutralAI"].String().c_str())); diff --git a/launcher/updatedialog_moc.h b/launcher/updatedialog_moc.h index aab93ff89..93ec1f1ea 100644 --- a/launcher/updatedialog_moc.h +++ b/launcher/updatedialog_moc.h @@ -11,8 +11,12 @@ #include #include +VCMI_LIB_NAMESPACE_BEGIN + class JsonNode; +VCMI_LIB_NAMESPACE_END + namespace Ui { class UpdateDialog; } diff --git a/lib/BattleFieldHandler.cpp b/lib/BattleFieldHandler.cpp index 1155e1d3f..18fc7664c 100644 --- a/lib/BattleFieldHandler.cpp +++ b/lib/BattleFieldHandler.cpp @@ -12,6 +12,8 @@ #include #include "BattleFieldHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + BattleFieldInfo * BattleFieldHandler::loadFromJson(const std::string & scope, const JsonNode & json, const std::string & identifier, size_t index) { BattleFieldInfo * info = new BattleFieldInfo(BattleField(index), identifier); @@ -105,4 +107,6 @@ void BattleFieldInfo::registerIcons(const IconRegistar & cb) const BattleField BattleFieldInfo::getId() const { return battlefield; -} \ No newline at end of file +} + +VCMI_LIB_NAMESPACE_END diff --git a/lib/BattleFieldHandler.h b/lib/BattleFieldHandler.h index b9023f3d0..51822e0cc 100644 --- a/lib/BattleFieldHandler.h +++ b/lib/BattleFieldHandler.h @@ -17,6 +17,8 @@ #include "Terrain.h" #include "battle/BattleHex.h" +VCMI_LIB_NAMESPACE_BEGIN + class BattleFieldInfo : public EntityT { public: @@ -84,3 +86,5 @@ public: h & objects; } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CArtHandler.cpp b/lib/CArtHandler.cpp index daeaa632c..4cf2d9d69 100644 --- a/lib/CArtHandler.cpp +++ b/lib/CArtHandler.cpp @@ -48,6 +48,8 @@ ART_POS(SHOULDERS) \ ART_POS(HEAD) +VCMI_LIB_NAMESPACE_BEGIN + int32_t CArtifact::getIndex() const { return id.toEnum(); @@ -1434,3 +1436,5 @@ void CArtifactSet::serializeJsonSlot(JsonSerializeFormat & handler, const Artifa } } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CArtHandler.h b/lib/CArtHandler.h index 2bf087101..9a0d55be0 100644 --- a/lib/CArtHandler.h +++ b/lib/CArtHandler.h @@ -16,6 +16,8 @@ #include "GameConstants.h" #include "IHandlerBase.h" +VCMI_LIB_NAMESPACE_BEGIN + class CArtHandler; class CArtifact; class CGHeroInstance; @@ -358,3 +360,5 @@ private: void serializeJsonSlot(JsonSerializeFormat & handler, const ArtifactPosition & slot, CMap * map);//normal slots }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CBonusTypeHandler.cpp b/lib/CBonusTypeHandler.cpp index bb31926e0..00342ec9f 100644 --- a/lib/CBonusTypeHandler.cpp +++ b/lib/CBonusTypeHandler.cpp @@ -20,7 +20,9 @@ #include "CCreatureHandler.h" #include "spells/CSpellHandler.h" -template class std::vector; +template class std::vector; + +VCMI_LIB_NAMESPACE_BEGIN ///MacroString @@ -326,3 +328,5 @@ void CBonusTypeHandler::loadItem(const JsonNode & source, CBonusType & dest) } dest.buildMacros(); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CBonusTypeHandler.h b/lib/CBonusTypeHandler.h index 0b64a0434..977efe051 100644 --- a/lib/CBonusTypeHandler.h +++ b/lib/CBonusTypeHandler.h @@ -14,6 +14,8 @@ #include "IHandlerBase.h" #include "HeroBonus.h" +VCMI_LIB_NAMESPACE_BEGIN + class JsonNode; @@ -94,6 +96,8 @@ private: std::vector bonusTypes; //index = BonusTypeID }; +VCMI_LIB_NAMESPACE_END + #ifndef INSTANTIATE_CBonusTypeHandler_HERE -extern template class std::vector; +extern template class std::vector; #endif diff --git a/lib/CBuildingHandler.cpp b/lib/CBuildingHandler.cpp index 5543d9805..ee48359da 100644 --- a/lib/CBuildingHandler.cpp +++ b/lib/CBuildingHandler.cpp @@ -10,6 +10,8 @@ #include "StdInc.h" #include "CBuildingHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + BuildingID CBuildingHandler::campToERMU( int camp, int townType, std::set builtBuildings ) { static const std::vector campToERMU = @@ -75,3 +77,5 @@ BuildingID CBuildingHandler::campToERMU( int camp, int townType, std::set builtBuildings); }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CConfigHandler.cpp b/lib/CConfigHandler.cpp index cc962b3cd..d2de0e086 100644 --- a/lib/CConfigHandler.cpp +++ b/lib/CConfigHandler.cpp @@ -15,6 +15,8 @@ #include "../lib/GameConstants.h" #include "../lib/VCMIDirs.h" +VCMI_LIB_NAMESPACE_BEGIN + using namespace config; SettingsStorage settings; @@ -302,3 +304,5 @@ void config::CConfigHandler::init() // That way method definitions can sit in the cpp file template struct SettingsStorage::NodeAccessor; template struct SettingsStorage::NodeAccessor; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CConfigHandler.h b/lib/CConfigHandler.h index dad7e66ba..7a579d39a 100644 --- a/lib/CConfigHandler.h +++ b/lib/CConfigHandler.h @@ -11,6 +11,8 @@ #include "../lib/JsonNode.h" +VCMI_LIB_NAMESPACE_BEGIN + class Settings; class SettingsListener; @@ -188,3 +190,5 @@ namespace config extern DLL_LINKAGE SettingsStorage settings; extern DLL_LINKAGE config::CConfigHandler conf; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CConsoleHandler.cpp b/lib/CConsoleHandler.cpp index b5489b984..52d85bc91 100644 --- a/lib/CConsoleHandler.cpp +++ b/lib/CConsoleHandler.cpp @@ -13,6 +13,8 @@ #include "CThreadHelper.h" +VCMI_LIB_NAMESPACE_BEGIN + boost::mutex CConsoleHandler::smx; DLL_LINKAGE CConsoleHandler * console = nullptr; @@ -285,3 +287,5 @@ void CConsoleHandler::start() { thread = new boost::thread(std::bind(&CConsoleHandler::run,console)); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CConsoleHandler.h b/lib/CConsoleHandler.h index c521acdd5..4ac139260 100644 --- a/lib/CConsoleHandler.h +++ b/lib/CConsoleHandler.h @@ -9,6 +9,8 @@ */ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + namespace EConsoleTextColor { /** The color enum is used for colored text console output. */ @@ -92,3 +94,5 @@ private: }; extern DLL_LINKAGE CConsoleHandler * console; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CCreatureHandler.cpp b/lib/CCreatureHandler.cpp index 709b40242..bc27abe42 100644 --- a/lib/CCreatureHandler.cpp +++ b/lib/CCreatureHandler.cpp @@ -22,6 +22,8 @@ #include "serializer/JsonUpdater.h" #include "mapObjects/CObjectClassesHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + int32_t CCreature::getIndex() const { return idNumber.toEnum(); @@ -1360,3 +1362,5 @@ void CCreatureHandler::deserializationFix() { buildBonusTreeForTiers(); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CCreatureHandler.h b/lib/CCreatureHandler.h index 66f652a59..4a3bbe6e4 100644 --- a/lib/CCreatureHandler.h +++ b/lib/CCreatureHandler.h @@ -21,6 +21,8 @@ #include "CRandomGenerator.h" #include "Terrain.h" +VCMI_LIB_NAMESPACE_BEGIN + class CLegacyConfigParser; class CCreatureHandler; class CCreature; @@ -303,3 +305,5 @@ public: BONUS_TREE_DESERIALIZATION_FIX } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CCreatureSet.cpp b/lib/CCreatureSet.cpp index 35e6a4a24..6753c7174 100644 --- a/lib/CCreatureSet.cpp +++ b/lib/CCreatureSet.cpp @@ -23,6 +23,8 @@ #include "serializer/JsonSerializeFormat.h" #include "NetPacksBase.h" +VCMI_LIB_NAMESPACE_BEGIN + bool CreatureSlotComparer::operator()(const TPairCreatureSlot & lhs, const TPairCreatureSlot & rhs) { @@ -1074,3 +1076,5 @@ bool CSimpleArmy::setCreature(SlotID slot, CreatureID cre, TQuantity count) army[slot] = std::make_pair(cre, count); return true; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CCreatureSet.h b/lib/CCreatureSet.h index f073f5671..484133c2b 100644 --- a/lib/CCreatureSet.h +++ b/lib/CCreatureSet.h @@ -13,6 +13,8 @@ #include "GameConstants.h" #include "CArtHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + class JsonNode; class CCreature; class CGHeroInstance; @@ -262,3 +264,5 @@ public: } void sweep(); }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CGameInfoCallback.cpp b/lib/CGameInfoCallback.cpp index 0d0a8d6b0..6ec0febe7 100644 --- a/lib/CGameInfoCallback.cpp +++ b/lib/CGameInfoCallback.cpp @@ -21,6 +21,8 @@ #include "mapping/CMap.h" #include "CPlayerState.h" +VCMI_LIB_NAMESPACE_BEGIN + //TODO make clean #define ERROR_VERBOSE_OR_NOT_RET_VAL_IF(cond, verbose, txt, retVal) do {if(cond){if(verbose)logGlobal->error("%s: %s",BOOST_CURRENT_FUNCTION, txt); return retVal;}} while(0) #define ERROR_RET_IF(cond, txt) do {if(cond){logGlobal->error("%s: %s", BOOST_CURRENT_FUNCTION, txt); return;}} while(0) @@ -999,3 +1001,5 @@ bool CGameInfoCallback::isTeleportEntrancePassable(const CGTeleport * obj, Playe { return obj && obj->isEntrance() && !isTeleportChannelImpassable(obj->channel, player); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CGameInfoCallback.h b/lib/CGameInfoCallback.h index 53aa5524f..70d3a45cf 100644 --- a/lib/CGameInfoCallback.h +++ b/lib/CGameInfoCallback.h @@ -12,6 +12,9 @@ #include "int3.h" #include "ResourceSet.h" // for Res::ERes #include "battle/CCallbackBase.h" + +VCMI_LIB_NAMESPACE_BEGIN + class Player; class Team; @@ -239,3 +242,5 @@ public: //virtual const PlayerSettings * getPlayerSettings(PlayerColor color) const; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CGameInterface.cpp b/lib/CGameInterface.cpp index 84b9e9745..5abf49072 100644 --- a/lib/CGameInterface.cpp +++ b/lib/CGameInterface.cpp @@ -29,6 +29,8 @@ #endif +VCMI_LIB_NAMESPACE_BEGIN + template std::shared_ptr createAny(const boost::filesystem::path & libpath, const std::string & methodName) { @@ -257,3 +259,5 @@ void CAdventureAI::loadGame(BinaryDeserializer & h, const int version) /*loading battleAI->init(env, cbc); } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CGameInterface.h b/lib/CGameInterface.h index c4ab18378..2228a86e3 100644 --- a/lib/CGameInterface.h +++ b/lib/CGameInterface.h @@ -17,12 +17,15 @@ #include "mapObjects/CObjectHandler.h" +class CBattleCallback; +class CCallback; + +VCMI_LIB_NAMESPACE_BEGIN + using boost::logic::tribool; class Environment; -class CCallback; -class CBattleCallback; class ICallback; class CGlobalAI; struct Component; @@ -159,3 +162,5 @@ public: virtual void saveGame(BinarySerializer & h, const int version) override; virtual void loadGame(BinaryDeserializer & h, const int version) override; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CGameState.cpp b/lib/CGameState.cpp index c81a760c6..e70643c5f 100644 --- a/lib/CGameState.cpp +++ b/lib/CGameState.cpp @@ -37,6 +37,8 @@ #include "serializer/CMemorySerializer.h" #include "VCMIDirs.h" +VCMI_LIB_NAMESPACE_BEGIN + boost::shared_mutex CGameState::mutex; template class CApplyOnGS; @@ -3106,3 +3108,5 @@ CRandomGenerator & CGameState::getRandomGenerator() { return rand; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CGameState.h b/lib/CGameState.h index 84e3077b3..862ac4c2c 100644 --- a/lib/CGameState.h +++ b/lib/CGameState.h @@ -22,8 +22,14 @@ #include "CGameStateFwd.h" #include "CPathfinder.h" +namespace boost +{ +class shared_mutex; +} + +VCMI_LIB_NAMESPACE_BEGIN + class CTown; -class CCallback; class IGameCallback; class CCreatureSet; class CQuest; @@ -36,7 +42,6 @@ class CGObjectInstance; class CCreature; class CMap; struct StartInfo; -class CMapHandler; struct SetObjectProperty; struct MetaString; struct CPack; @@ -47,7 +52,6 @@ class CCampaign; class CCampaignState; class IModableArt; class CGGarrison; -class CGameInfo; struct QuestInfo; class CQuest; class CCampaignScenario; @@ -55,12 +59,6 @@ struct EventCondition; class CScenarioTravel; class IMapService; -namespace boost -{ - class shared_mutex; -} - - template class CApplier; class CBaseForGSApply; @@ -305,3 +303,5 @@ private: friend class CMapHandler; friend class CGameHandler; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CGameStateFwd.h b/lib/CGameStateFwd.h index 63904fcb1..1f1b5c660 100644 --- a/lib/CGameStateFwd.h +++ b/lib/CGameStateFwd.h @@ -12,6 +12,8 @@ #include "CCreatureSet.h" #include "int3.h" +VCMI_LIB_NAMESPACE_BEGIN + class CQuest; class CGObjectInstance; class CHeroClass; @@ -206,3 +208,5 @@ struct DLL_LINKAGE QuestInfo //universal interface for human and AI h & tile; } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CGeneralTextHandler.cpp b/lib/CGeneralTextHandler.cpp index aa19fdfb3..b8070c7e6 100644 --- a/lib/CGeneralTextHandler.cpp +++ b/lib/CGeneralTextHandler.cpp @@ -19,6 +19,8 @@ #include "VCMI_Lib.h" #include "Terrain.h" +VCMI_LIB_NAMESPACE_BEGIN + size_t Unicode::getCharacterSize(char firstByte) { // length of utf-8 character can be determined from 1st byte by counting number of highest bits set to 1: @@ -519,3 +521,5 @@ int32_t CGeneralTextHandler::pluralText(const int32_t textIndex, const int32_t c else return textIndex + 1; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CGeneralTextHandler.h b/lib/CGeneralTextHandler.h index 58feed9ce..b7bffd1f9 100644 --- a/lib/CGeneralTextHandler.h +++ b/lib/CGeneralTextHandler.h @@ -11,6 +11,8 @@ #include "JsonNode.h" +VCMI_LIB_NAMESPACE_BEGIN + /// Namespace that provides utilites for unicode support (UTF-8) namespace Unicode { @@ -149,3 +151,5 @@ public: CGeneralTextHandler(const CGeneralTextHandler&) = delete; CGeneralTextHandler operator=(const CGeneralTextHandler&) = delete; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CHeroHandler.cpp b/lib/CHeroHandler.cpp index 890189eeb..6ed393ae5 100644 --- a/lib/CHeroHandler.cpp +++ b/lib/CHeroHandler.cpp @@ -27,6 +27,8 @@ #include "mapObjects/CObjectClassesHandler.h" #include "BattleFieldHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + CHero::CHero() = default; CHero::~CHero() = default; @@ -991,3 +993,5 @@ std::vector CHeroHandler::getDefaultAllowed() const return allowedHeroes; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CHeroHandler.h b/lib/CHeroHandler.h index 87da89149..d24f3de15 100644 --- a/lib/CHeroHandler.h +++ b/lib/CHeroHandler.h @@ -20,8 +20,9 @@ #include "IHandlerBase.h" #include "Terrain.h" +VCMI_LIB_NAMESPACE_BEGIN + class CHeroClass; -class CGameInfo; class CGHeroInstance; struct BattleHex; class JsonNode; @@ -316,3 +317,5 @@ protected: const std::vector & getTypeNames() const override; CHero * loadFromJson(const std::string & scope, const JsonNode & node, const std::string & identifier, size_t index) override; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index c816b6331..d0536b245 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,487 +1 @@ -set(lib_SRCS - StdInc.cpp - ${CMAKE_BINARY_DIR}/Version.cpp - - battle/AccessibilityInfo.cpp - battle/BattleAction.cpp - battle/BattleAttackInfo.cpp - battle/BattleHex.cpp - battle/BattleInfo.cpp - battle/BattleProxy.cpp - battle/CBattleInfoCallback.cpp - battle/CBattleInfoEssentials.cpp - battle/CCallbackBase.cpp - battle/CObstacleInstance.cpp - battle/CPlayerBattleCallback.cpp - battle/CUnitState.cpp - battle/Destination.cpp - battle/IBattleState.cpp - battle/ReachabilityInfo.cpp - battle/SideInBattle.cpp - battle/SiegeInfo.cpp - battle/Unit.cpp - - events/ApplyDamage.cpp - events/GameResumed.cpp - events/ObjectVisitEnded.cpp - events/ObjectVisitStarted.cpp - events/PlayerGotTurn.cpp - events/TurnStarted.cpp - - filesystem/AdapterLoaders.cpp - filesystem/CArchiveLoader.cpp - filesystem/CBinaryReader.cpp - filesystem/CCompressedStream.cpp - filesystem/CFileInputStream.cpp - filesystem/CFilesystemLoader.cpp - filesystem/CMemoryBuffer.cpp - filesystem/CMemoryStream.cpp - filesystem/CZipLoader.cpp - filesystem/CZipSaver.cpp - filesystem/FileInfo.cpp - filesystem/FileStream.cpp - filesystem/Filesystem.cpp - filesystem/MinizipExtensions.cpp - filesystem/ResourceID.cpp - - logging/CBasicLogConfigurator.cpp - logging/CLogger.cpp - - mapObjects/CArmedInstance.cpp - mapObjects/CBank.cpp - mapObjects/CGHeroInstance.cpp - mapObjects/CGMarket.cpp - mapObjects/CGPandoraBox.cpp - mapObjects/CGTownInstance.cpp - mapObjects/CObjectClassesHandler.cpp - mapObjects/CObjectHandler.cpp - mapObjects/CommonConstructors.cpp - mapObjects/CQuest.cpp - mapObjects/CRewardableConstructor.cpp - mapObjects/CRewardableObject.cpp - mapObjects/JsonRandom.cpp - mapObjects/MiscObjects.cpp - mapObjects/ObjectTemplate.cpp - - mapping/CCampaignHandler.cpp - mapping/CDrawRoadsOperation.cpp - mapping/CMap.cpp - mapping/CMapEditManager.cpp - mapping/CMapInfo.cpp - mapping/CMapOperation.cpp - mapping/CMapService.cpp - mapping/MapEditUtils.cpp - mapping/MapFormatH3M.cpp - mapping/MapFormatJson.cpp - - registerTypes/RegisterTypes.cpp - registerTypes/TypesClientPacks1.cpp - registerTypes/TypesClientPacks2.cpp - registerTypes/TypesMapObjects1.cpp - registerTypes/TypesMapObjects2.cpp - registerTypes/TypesMapObjects3.cpp - registerTypes/TypesLobbyPacks.cpp - registerTypes/TypesServerPacks.cpp - - rmg/RmgArea.cpp - rmg/RmgObject.cpp - rmg/RmgPath.cpp - rmg/CMapGenerator.cpp - rmg/CMapGenOptions.cpp - rmg/CRmgTemplate.cpp - rmg/CRmgTemplateStorage.cpp - rmg/CZonePlacer.cpp - rmg/TileInfo.cpp - rmg/Zone.cpp - rmg/Functions.cpp - rmg/ObjectManager.cpp - rmg/RoadPlacer.cpp - rmg/TreasurePlacer.cpp - rmg/RmgMap.cpp - rmg/ConnectionsPlacer.cpp - rmg/WaterAdopter.cpp - rmg/TownPlacer.cpp - rmg/WaterProxy.cpp - rmg/WaterRoutes.cpp - rmg/RockPlacer.cpp - rmg/ObstaclePlacer.cpp - rmg/RiverPlacer.cpp - rmg/TerrainPainter.cpp - - serializer/BinaryDeserializer.cpp - serializer/BinarySerializer.cpp - serializer/CLoadIntegrityValidator.cpp - serializer/CMemorySerializer.cpp - serializer/Connection.cpp - serializer/CSerializer.cpp - serializer/CTypeList.cpp - serializer/JsonDeserializer.cpp - serializer/JsonSerializeFormat.cpp - serializer/JsonSerializer.cpp - serializer/JsonUpdater.cpp - - spells/AbilityCaster.cpp - spells/AdventureSpellMechanics.cpp - spells/BattleSpellMechanics.cpp - spells/BonusCaster.cpp - spells/CSpellHandler.cpp - spells/ISpellMechanics.cpp - spells/Problem.cpp - spells/ProxyCaster.cpp - spells/TargetCondition.cpp - spells/ViewSpellInt.cpp - - spells/effects/Catapult.cpp - spells/effects/Clone.cpp - spells/effects/Damage.cpp - spells/effects/Dispel.cpp - spells/effects/Effect.cpp - spells/effects/Effects.cpp - spells/effects/Heal.cpp - spells/effects/LocationEffect.cpp - spells/effects/Obstacle.cpp - spells/effects/Registry.cpp - spells/effects/UnitEffect.cpp - spells/effects/Summon.cpp - spells/effects/Teleport.cpp - spells/effects/Timed.cpp - spells/effects/RemoveObstacle.cpp - spells/effects/Sacrifice.cpp - - vstd/StringUtils.cpp - - BattleFieldHandler.cpp - CAndroidVMHelper.cpp - CArtHandler.cpp - CBonusTypeHandler.cpp - CBuildingHandler.cpp - CConfigHandler.cpp - CConsoleHandler.cpp - CCreatureHandler.cpp - CCreatureSet.cpp - CGameInfoCallback.cpp - CGameInterface.cpp - CGameState.cpp - CGeneralTextHandler.cpp - CHeroHandler.cpp - CModHandler.cpp - CPathfinder.cpp - CPlayerState.cpp - CRandomGenerator.cpp - CScriptingModule.cpp - CSkillHandler.cpp - CStack.cpp - CThreadHelper.cpp - CTownHandler.cpp - GameConstants.cpp - HeroBonus.cpp - IGameCallback.cpp - IHandlerBase.cpp - JsonDetail.cpp - JsonNode.cpp - LoadProgress.cpp - LogicalExpression.cpp - NetPacksLib.cpp - ObstacleHandler.cpp - StartInfo.cpp - ResourceSet.cpp - ScriptHandler.cpp - Terrain.cpp - VCMIDirs.cpp - VCMI_Lib.cpp - - ${VCMILIB_ADDITIONAL_SOURCES} -) - -# Version.cpp is a generated file -set_source_files_properties(${CMAKE_BINARY_DIR}/Version.cpp - PROPERTIES GENERATED TRUE -) - -set(lib_HEADERS - ../include/vstd/CLoggerBase.h - ../Global.h - StdInc.h - - ../include/vstd/ContainerUtils.h - ../include/vstd/RNG.h - ../include/vstd/StringUtils.h - - ../include/vcmi/events/ApplyDamage.h - ../include/vcmi/events/Event.h - ../include/vcmi/events/EventBus.h - ../include/vcmi/events/SubscriptionRegistry.h - - ../include/vcmi/scripting/Service.h - - ../include/vcmi/spells/Caster.h - ../include/vcmi/spells/Magic.h - ../include/vcmi/spells/Service.h - ../include/vcmi/spells/Spell.h - - ../include/vcmi/Artifact.h - ../include/vcmi/ArtifactService.h - ../include/vcmi/Creature.h - ../include/vcmi/CreatureService.h - ../include/vcmi/Entity.h - ../include/vcmi/Environment.h - ../include/vcmi/Services.h - - abilities/Ability.h - - battle/AccessibilityInfo.h - battle/BattleAction.h - battle/BattleAttackInfo.h - battle/BattleHex.h - battle/BattleInfo.h - battle/BattleProxy.h - battle/CBattleInfoCallback.h - battle/CBattleInfoEssentials.h - battle/CCallbackBase.h - battle/CObstacleInstance.h - battle/CPlayerBattleCallback.h - battle/CUnitState.h - battle/Destination.h - battle/IBattleInfoCallback.h - battle/IBattleState.h - battle/IUnitInfo.h - battle/ReachabilityInfo.h - battle/SideInBattle.h - battle/SiegeInfo.h - battle/Unit.h - - events/ApplyDamage.h - events/GameResumed.h - events/ObjectVisitEnded.h - events/ObjectVisitStarted.h - events/PlayerGotTurn.h - events/TurnStarted.h - - filesystem/AdapterLoaders.h - filesystem/CArchiveLoader.h - filesystem/CBinaryReader.h - filesystem/CCompressedStream.h - filesystem/CFileInputStream.h - filesystem/CFilesystemLoader.h - filesystem/CInputOutputStream.h - filesystem/CInputStream.h - filesystem/CMemoryBuffer.h - filesystem/CMemoryStream.h - filesystem/COutputStream.h - filesystem/CStream.h - filesystem/CZipLoader.h - filesystem/CZipSaver.h - filesystem/FileInfo.h - filesystem/FileStream.h - filesystem/Filesystem.h - filesystem/ISimpleResourceLoader.h - filesystem/MinizipExtensions.h - filesystem/ResourceID.h - - logging/CBasicLogConfigurator.h - logging/CLogger.h - - mapObjects/CArmedInstance.h - mapObjects/CBank.h - mapObjects/CGHeroInstance.h - mapObjects/CGMarket.h - mapObjects/CGPandoraBox.h - mapObjects/CGTownInstance.h - mapObjects/CObjectClassesHandler.h - mapObjects/CObjectHandler.h - mapObjects/CommonConstructors.h - mapObjects/CQuest.h - mapObjects/CRewardableConstructor.h - mapObjects/CRewardableObject.h - mapObjects/JsonRandom.h - mapObjects/MapObjects.h - mapObjects/MiscObjects.h - mapObjects/ObjectTemplate.h - - mapping/CCampaignHandler.h - mapping/CDrawRoadsOperation.h - mapping/CMapDefines.h - mapping/CMapEditManager.h - mapping/CMap.h - mapping/CMapInfo.h - mapping/CMapOperation.h - mapping/CMapService.h - mapping/MapEditUtils.h - mapping/MapFormatH3M.h - mapping/MapFormatJson.h - - registerTypes/RegisterTypes.h - - rmg/RmgArea.h - rmg/RmgObject.h - rmg/RmgPath.h - rmg/CMapGenerator.h - rmg/CMapGenOptions.h - rmg/CRmgTemplate.h - rmg/CRmgTemplateStorage.h - rmg/CZonePlacer.h - rmg/TileInfo.h - rmg/Zone.h - rmg/Functions.h - rmg/ObjectManager.h - rmg/RoadPlacer.h - rmg/TreasurePlacer.h - rmg/RmgMap.h - rmg/ConnectionsPlacer.h - rmg/WaterAdopter.h - rmg/TownPlacer.h - rmg/WaterProxy.h - rmg/WaterRoutes.h - rmg/RockPlacer.h - rmg/ObstaclePlacer.h - rmg/RiverPlacer.h - rmg/TerrainPainter.h - rmg/float3.h - - serializer/BinaryDeserializer.h - serializer/BinarySerializer.h - serializer/CLoadIntegrityValidator.h - serializer/CMemorySerializer.h - serializer/Connection.h - serializer/CSerializer.h - serializer/CTypeList.h - serializer/JsonDeserializer.h - serializer/JsonSerializeFormat.h - serializer/JsonSerializer.h - serializer/JsonUpdater.h - serializer/Cast.h - - spells/AbilityCaster.h - spells/AdventureSpellMechanics.h - spells/BattleSpellMechanics.h - spells/BonusCaster.h - spells/CSpellHandler.h - spells/ISpellMechanics.h - spells/Problem.h - spells/ProxyCaster.h - spells/TargetCondition.h - spells/ViewSpellInt.h - - spells/effects/Catapult.h - spells/effects/Clone.h - spells/effects/Damage.h - spells/effects/Dispel.h - spells/effects/Effect.h - spells/effects/Effects.h - spells/effects/EffectsFwd.h - spells/effects/Heal.h - spells/effects/LocationEffect.h - spells/effects/Obstacle.h - spells/effects/Registry.h - spells/effects/UnitEffect.h - spells/effects/Summon.h - spells/effects/Teleport.h - spells/effects/Timed.h - spells/effects/RemoveObstacle.h - spells/effects/Sacrifice.h - - AI_Base.h - BattleFieldHandler.h - CAndroidVMHelper.h - CArtHandler.h - CBonusTypeHandler.h - CBuildingHandler.h - CConfigHandler.h - CConsoleHandler.h - CCreatureHandler.h - CCreatureSet.h - CGameInfoCallback.h - CGameInterface.h - CGameStateFwd.h - CGameState.h - CGeneralTextHandler.h - CHeroHandler.h - CModHandler.h - CondSh.h - ConstTransitivePtr.h - CPathfinder.h - CPlayerState.h - CRandomGenerator.h - CScriptingModule.h - CSkillHandler.h - CSoundBase.h - CStack.h - CStopWatch.h - CThreadHelper.h - CTownHandler.h - FunctionList.h - GameConstants.h - HeroBonus.h - IBonusTypeHandler.h - IGameCallback.h - IGameEventsReceiver.h - IHandlerBase.h - int3.h - Interprocess.h - JsonDetail.h - JsonNode.h - LoadProgress.h - LogicalExpression.h - NetPacksBase.h - NetPacks.h - NetPacksLobby.h - ObstacleHandler.h - PathfinderUtil.h - ResourceSet.h - ScriptHandler.h - ScopeGuard.h - StartInfo.h - StringConstants.h - Terrain.h - UnlockGuard.h - VCMIDirs.h - vcmi_endian.h - VCMI_Lib.h -) - -assign_source_group(${lib_SRCS} ${lib_HEADERS}) - -add_library(vcmi SHARED ${lib_SRCS} ${lib_HEADERS}) -set_target_properties(vcmi PROPERTIES COMPILE_DEFINITIONS "VCMI_DLL=1") -target_link_libraries(vcmi PUBLIC - minizip::minizip ZLIB::ZLIB - ${SYSTEM_LIBS} Boost::boost Boost::thread Boost::filesystem Boost::program_options Boost::locale Boost::date_time -) - -target_include_directories(vcmi - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} - PUBLIC ${CMAKE_HOME_DIRECTORY} - PUBLIC ${CMAKE_HOME_DIRECTORY}/include - PRIVATE ${SDL2_INCLUDE_DIR} -) - -if(WIN32) - set_target_properties(vcmi - PROPERTIES - OUTPUT_NAME "VCMI_lib" - PROJECT_LABEL "VCMI_lib" - ) -endif() - -if(ANDROID) - return() -endif() - -vcmi_set_output_dir(vcmi "") - -enable_pch(vcmi) - -# We want to deploy assets into build directory for easier debugging without install -add_custom_command(TARGET vcmi POST_BUILD - COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/config - COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/Mods - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/config ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/config - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/Mods ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/Mods -) - -# Update version before vcmi compiling -if(TARGET update_version) - add_dependencies(vcmi update_version) -endif() - -install(TARGETS vcmi RUNTIME DESTINATION ${LIB_DIR} LIBRARY DESTINATION ${LIB_DIR}) +add_main_lib(vcmi SHARED) diff --git a/lib/CModHandler.cpp b/lib/CModHandler.cpp index e8a72cb5b..36a36dadc 100644 --- a/lib/CModHandler.cpp +++ b/lib/CModHandler.cpp @@ -30,6 +30,8 @@ #include +VCMI_LIB_NAMESPACE_BEGIN + CIdentifierStorage::CIdentifierStorage(): state(LOADING) { @@ -1144,3 +1146,5 @@ std::string CModHandler::makeFullIdentifier(const std::string & scope, const std return actualName == "" ? actualScope+ ":" + type : actualScope + ":" + type + "." + actualName; } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CModHandler.h b/lib/CModHandler.h index 1605f59fd..01f7a092b 100644 --- a/lib/CModHandler.h +++ b/lib/CModHandler.h @@ -14,6 +14,8 @@ #include "VCMI_Lib.h" #include "JsonNode.h" +VCMI_LIB_NAMESPACE_BEGIN + class CModHandler; class CModIndentifier; class CModInfo; @@ -398,3 +400,5 @@ public: h & identifiers; } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CPathfinder.cpp b/lib/CPathfinder.cpp index 6ae919db0..0961ee52a 100644 --- a/lib/CPathfinder.cpp +++ b/lib/CPathfinder.cpp @@ -20,6 +20,8 @@ #include "CPlayerState.h" #include "PathfinderUtil.h" +VCMI_LIB_NAMESPACE_BEGIN + bool canSeeObj(const CGObjectInstance * obj) { /// Pathfinder should ignore placed events @@ -1424,3 +1426,5 @@ bool PathNodeInfo::isNodeObjectVisitable() const return (node->layer == EPathfindingLayer::LAND || node->layer == EPathfindingLayer::SAIL) && (canSeeObj(nodeObject) || canSeeObj(nodeHero)); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CPathfinder.h b/lib/CPathfinder.h index c047701a4..a5ed9e764 100644 --- a/lib/CPathfinder.h +++ b/lib/CPathfinder.h @@ -17,6 +17,8 @@ #include +VCMI_LIB_NAMESPACE_BEGIN + class CGHeroInstance; class CGObjectInstance; @@ -610,3 +612,5 @@ public: int movementPointsAfterEmbark(int movement, int basicCost, bool disembark) const; bool passOneTurnLimitCheck(const PathNodeInfo & source) const; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CPlayerState.cpp b/lib/CPlayerState.cpp index 78ee6b68a..edcc8c0db 100644 --- a/lib/CPlayerState.cpp +++ b/lib/CPlayerState.cpp @@ -12,6 +12,8 @@ #include "CPlayerState.h" #include "CGameStateFwd.h" +VCMI_LIB_NAMESPACE_BEGIN + PlayerState::PlayerState() : color(-1), human(false), enteredWinningCheatCode(false), enteredLosingCheatCode(false), status(EPlayerStatus::INGAME) @@ -67,3 +69,5 @@ int PlayerState::getResourceAmount(int type) const { return vstd::atOrDefault(resources, static_cast(type), 0); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CPlayerState.h b/lib/CPlayerState.h index 1caafa314..4d042f434 100644 --- a/lib/CPlayerState.h +++ b/lib/CPlayerState.h @@ -15,6 +15,8 @@ #include "HeroBonus.h" #include "ResourceSet.h" +VCMI_LIB_NAMESPACE_BEGIN + class CGHeroInstance; class CGTownInstance; class CGDwelling; @@ -95,3 +97,5 @@ public: } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CRandomGenerator.cpp b/lib/CRandomGenerator.cpp index c05b126b3..f55e97030 100644 --- a/lib/CRandomGenerator.cpp +++ b/lib/CRandomGenerator.cpp @@ -11,6 +11,8 @@ #include "StdInc.h" #include "CRandomGenerator.h" +VCMI_LIB_NAMESPACE_BEGIN + boost::thread_specific_ptr CRandomGenerator::defaultRand; CRandomGenerator::CRandomGenerator() @@ -88,3 +90,5 @@ TGenerator & CRandomGenerator::getStdGenerator() { return rand; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CRandomGenerator.h b/lib/CRandomGenerator.h index 0d052b32b..0b14c65ee 100644 --- a/lib/CRandomGenerator.h +++ b/lib/CRandomGenerator.h @@ -12,6 +12,8 @@ #include +VCMI_LIB_NAMESPACE_BEGIN + typedef std::mt19937 TGenerator; typedef std::uniform_int_distribution TIntDist; typedef std::uniform_int_distribution TInt64Dist; @@ -98,3 +100,5 @@ public: } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CScriptingModule.cpp b/lib/CScriptingModule.cpp index c6da26f01..f54ea063d 100644 --- a/lib/CScriptingModule.cpp +++ b/lib/CScriptingModule.cpp @@ -12,6 +12,8 @@ #include "CScriptingModule.h" #if SCRIPTING_ENABLED +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { @@ -31,4 +33,6 @@ Module::Module() Module::~Module() = default; } + +VCMI_LIB_NAMESPACE_END #endif diff --git a/lib/CScriptingModule.h b/lib/CScriptingModule.h index 77b59249f..9197d4951 100644 --- a/lib/CScriptingModule.h +++ b/lib/CScriptingModule.h @@ -12,6 +12,8 @@ #if SCRIPTING_ENABLED #include +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { namespace effects @@ -46,4 +48,6 @@ public: }; } + +VCMI_LIB_NAMESPACE_END #endif diff --git a/lib/CSkillHandler.cpp b/lib/CSkillHandler.cpp index feea6b009..74da3179c 100644 --- a/lib/CSkillHandler.cpp +++ b/lib/CSkillHandler.cpp @@ -22,6 +22,8 @@ #include "CModHandler.h" #include "StringConstants.h" +VCMI_LIB_NAMESPACE_BEGIN + ///CSkill CSkill::LevelInfo::LevelInfo() { @@ -281,3 +283,5 @@ std::string CSkillHandler::encodeSkillWithType(const si32 index) { return CModHandler::makeFullIdentifier("", "skill", encodeSkill(index)); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CSkillHandler.h b/lib/CSkillHandler.h index 1f93b4678..2d06c3f3c 100644 --- a/lib/CSkillHandler.h +++ b/lib/CSkillHandler.h @@ -16,6 +16,8 @@ #include "GameConstants.h" #include "IHandlerBase.h" +VCMI_LIB_NAMESPACE_BEGIN + class JsonSerializeFormat; class DLL_LINKAGE CSkill : public Skill @@ -114,3 +116,5 @@ protected: const std::vector & getTypeNames() const override; CSkill * loadFromJson(const std::string & scope, const JsonNode & json, const std::string & identifier, size_t index) override; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CSoundBase.h b/lib/CSoundBase.h index 94ca7349c..d8b421494 100644 --- a/lib/CSoundBase.h +++ b/lib/CSoundBase.h @@ -9,6 +9,8 @@ */ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + // Use some magic to keep the list of files and their code name in sync. #define VCMI_SOUND_LIST \ @@ -1060,3 +1062,5 @@ public: #undef VCMI_SOUND_FILE #undef VCMI_SOUND_NAME }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CStack.cpp b/lib/CStack.cpp index 64c5e98f8..df76d3067 100644 --- a/lib/CStack.cpp +++ b/lib/CStack.cpp @@ -19,6 +19,8 @@ #include "spells/CSpellHandler.h" #include "NetPacks.h" +VCMI_LIB_NAMESPACE_BEGIN + ///CStack CStack::CStack(const CStackInstance * Base, PlayerColor O, int I, ui8 Side, SlotID S) @@ -410,3 +412,5 @@ void CStack::spendMana(ServerCallback * server, const int spellCost) const ssp.absolute = false; server->apply(&ssp); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CStack.h b/lib/CStack.h index f969efab3..645e4000e 100644 --- a/lib/CStack.h +++ b/lib/CStack.h @@ -18,6 +18,8 @@ #include "battle/CUnitState.h" +VCMI_LIB_NAMESPACE_BEGIN + struct BattleStackAttacked; class BattleInfo; @@ -139,3 +141,5 @@ public: private: const BattleInfo * battle; //do not serialize }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CStopWatch.h b/lib/CStopWatch.h index 0431e9c1a..46e3cb65c 100644 --- a/lib/CStopWatch.h +++ b/lib/CStopWatch.h @@ -19,6 +19,8 @@ #define TO_MS_DIVISOR (CLOCKS_PER_SEC / 1000) #endif +VCMI_LIB_NAMESPACE_BEGIN + class CStopWatch { si64 start, last, mem; @@ -53,7 +55,7 @@ public: private: si64 clock() { - #ifdef __FreeBSD__ + #ifdef __FreeBSD__ // TODO: enable also for Apple? struct rusage usage; getrusage(RUSAGE_SELF, &usage); return static_cast(usage.ru_utime.tv_sec + usage.ru_stime.tv_sec) * 1000000 + usage.ru_utime.tv_usec + usage.ru_stime.tv_usec; @@ -62,3 +64,5 @@ private: #endif } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CThreadHelper.cpp b/lib/CThreadHelper.cpp index 6e0c32e82..94ab6d541 100644 --- a/lib/CThreadHelper.cpp +++ b/lib/CThreadHelper.cpp @@ -16,6 +16,8 @@ #include #endif +VCMI_LIB_NAMESPACE_BEGIN + CThreadHelper::CThreadHelper(std::vector > *Tasks, int Threads) { currentTask = 0; amount = (int)Tasks->size(); @@ -84,5 +86,9 @@ void setThreadName(const std::string &name) #elif defined(__linux__) prctl(PR_SET_NAME, name.c_str(), 0, 0, 0); +#elif defined(VCMI_APPLE) + pthread_setname_np(name.c_str()); #endif } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CThreadHelper.h b/lib/CThreadHelper.h index 78205de22..a4eaf8f8b 100644 --- a/lib/CThreadHelper.h +++ b/lib/CThreadHelper.h @@ -9,6 +9,8 @@ */ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + ///DEPRECATED /// Can assign CPU work to other threads/cores @@ -81,3 +83,5 @@ private: void DLL_LINKAGE setThreadName(const std::string &name); + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CTownHandler.cpp b/lib/CTownHandler.cpp index bb5085f2b..393943d2d 100644 --- a/lib/CTownHandler.cpp +++ b/lib/CTownHandler.cpp @@ -24,6 +24,8 @@ #include "mapObjects/CObjectHandler.h" #include "HeroBonus.h" +VCMI_LIB_NAMESPACE_BEGIN + const int NAMES_PER_TOWN=16; // number of town names per faction in H3 files. Json can define any number const Terrain CTownHandler::defaultGoodTerrain{"grass"}; @@ -1179,3 +1181,5 @@ const std::vector & CTownHandler::getTypeNames() const return typeNames; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CTownHandler.h b/lib/CTownHandler.h index 7728d2992..47727abf0 100644 --- a/lib/CTownHandler.h +++ b/lib/CTownHandler.h @@ -22,6 +22,8 @@ #include "HeroBonus.h" #include "Terrain.h" +VCMI_LIB_NAMESPACE_BEGIN + class CLegacyConfigParser; class JsonNode; class CTown; @@ -430,3 +432,5 @@ protected: const std::vector & getTypeNames() const override; CFaction * loadFromJson(const std::string & scope, const JsonNode & data, const std::string & identifier, size_t index) override; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/CondSh.h b/lib/CondSh.h index 829af99a7..165e2a0c1 100644 --- a/lib/CondSh.h +++ b/lib/CondSh.h @@ -9,6 +9,8 @@ */ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + /// Used for multithreading, wraps boost functions template struct CondSh { @@ -63,3 +65,5 @@ template struct CondSh cond.wait(un); } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/ConstTransitivePtr.h b/lib/ConstTransitivePtr.h index 5aaaef5df..3fccbc554 100644 --- a/lib/ConstTransitivePtr.h +++ b/lib/ConstTransitivePtr.h @@ -11,6 +11,8 @@ class CGameHandler; +VCMI_LIB_NAMESPACE_BEGIN + template class ConstTransitivePtr { @@ -75,5 +77,7 @@ public: h & ptr; } - friend class CGameHandler; + friend class ::CGameHandler; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/FunctionList.h b/lib/FunctionList.h index eca94edfc..3c3ef4afe 100644 --- a/lib/FunctionList.h +++ b/lib/FunctionList.h @@ -9,6 +9,8 @@ */ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + /// List of functions that share the same signature - can be used to call all of them easily template class CFunctionList @@ -61,3 +63,5 @@ public: } } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/GameConstants.cpp b/lib/GameConstants.cpp index 7f6155316..a8d729d04 100644 --- a/lib/GameConstants.cpp +++ b/lib/GameConstants.cpp @@ -37,6 +37,8 @@ #include "BattleFieldHandler.h" #include "ObstacleHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + const SlotID SlotID::COMMANDER_SLOT_PLACEHOLDER = SlotID(-2); const SlotID SlotID::SUMMONED_SLOT_PLACEHOLDER = SlotID(-3); const SlotID SlotID::WAR_MACHINES_SLOT = SlotID(-4); @@ -322,3 +324,5 @@ Obstacle Obstacle::fromString(std::string identifier) else return Obstacle(-1); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/GameConstants.h b/lib/GameConstants.h index 54d098e12..642089dba 100644 --- a/lib/GameConstants.h +++ b/lib/GameConstants.h @@ -11,6 +11,8 @@ #include "ConstTransitivePtr.h" +VCMI_LIB_NAMESPACE_BEGIN + class Artifact; class ArtifactService; class Creature; @@ -1194,3 +1196,5 @@ typedef int TRmgTemplateZoneId; #undef ID_LIKE_OPERATORS_INTERNAL #undef INSTID_LIKE_CLASS_COMMON #undef OP_DECL_INT + +VCMI_LIB_NAMESPACE_END diff --git a/lib/HeroBonus.cpp b/lib/HeroBonus.cpp index 081d874f7..2fcdabeb7 100644 --- a/lib/HeroBonus.cpp +++ b/lib/HeroBonus.cpp @@ -25,6 +25,8 @@ #include "StringConstants.h" #include "battle/BattleInfo.h" +VCMI_LIB_NAMESPACE_BEGIN + #define FOREACH_PARENT(pname) TNodes lparents; getParents(lparents); for(CBonusSystemNode *pname : lparents) #define FOREACH_RED_CHILD(pname) TNodes lchildren; getRedChildren(lchildren); for(CBonusSystemNode *pname : lchildren) @@ -2559,3 +2561,5 @@ std::shared_ptr OwnerUpdater::createUpdatedBonus(const std::shared_ptrlimiter = std::make_shared(owner); return updated; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/HeroBonus.h b/lib/HeroBonus.h index 61941c27a..5afb1c92f 100644 --- a/lib/HeroBonus.h +++ b/lib/HeroBonus.h @@ -13,6 +13,8 @@ #include "JsonNode.h" #include "Terrain.h" +VCMI_LIB_NAMESPACE_BEGIN + class CCreature; struct Bonus; class IBonusBearer; @@ -1290,3 +1292,5 @@ public: virtual std::string toString() const override; virtual JsonNode toJsonNode() const override; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/IBonusTypeHandler.h b/lib/IBonusTypeHandler.h index 9563f4c87..f7edceb35 100644 --- a/lib/IBonusTypeHandler.h +++ b/lib/IBonusTypeHandler.h @@ -9,6 +9,8 @@ */ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + class IBonusBearer; struct Bonus; @@ -22,3 +24,5 @@ public: virtual std::string bonusToString(const std::shared_ptr & bonus, const IBonusBearer * bearer, bool description) const = 0; virtual std::string bonusToGraphics(const std::shared_ptr & bonus) const = 0; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/IGameCallback.cpp b/lib/IGameCallback.cpp index cf1d235f3..877eb0465 100644 --- a/lib/IGameCallback.cpp +++ b/lib/IGameCallback.cpp @@ -35,6 +35,8 @@ #include "serializer/Connection.h" +VCMI_LIB_NAMESPACE_BEGIN + void CPrivilegedInfoCallback::getFreeTiles(std::vector & tiles) const { std::vector floors; @@ -248,3 +250,5 @@ bool IGameCallback::isVisitCoveredByAnotherQuery(const CGObjectInstance *obj, co logGlobal->error("isVisitCoveredByAnotherQuery call on client side"); return false; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/IGameCallback.h b/lib/IGameCallback.h index 0f4ad0940..4850fdce1 100644 --- a/lib/IGameCallback.h +++ b/lib/IGameCallback.h @@ -14,6 +14,8 @@ #include "CGameInfoCallback.h" // for CGameInfoCallback #include "CRandomGenerator.h" +VCMI_LIB_NAMESPACE_BEGIN + struct SetMovePoints; struct GiveBonus; struct BlockingDialog; @@ -145,3 +147,5 @@ public: friend struct CPackForServer; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/IGameEventsReceiver.h b/lib/IGameEventsReceiver.h index 53cda9427..632489c76 100644 --- a/lib/IGameEventsReceiver.h +++ b/lib/IGameEventsReceiver.h @@ -14,6 +14,10 @@ #include "GameConstants.h" #include "int3.h" +class CCallback; + +VCMI_LIB_NAMESPACE_BEGIN + class CGTownInstance; class CCreature; class CArmedInstance; @@ -21,7 +25,6 @@ struct StackLocation; struct TryMoveHero; struct ArtifactLocation; class CGHeroInstance; -class CCallback; class IShipyard; class CGDwelling; struct Component; @@ -42,7 +45,6 @@ class CCreatureSet; struct BattleAttack; struct SetStackEffect; struct BattleTriggerEffect; -class CComponent; struct CObstacleInstance; struct CPackForServer; class EVictoryLossCheckResult; @@ -133,3 +135,5 @@ public: //TODO shouldn't be moved down the tree? virtual void heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID hero2, QueryID queryID){}; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/IHandlerBase.cpp b/lib/IHandlerBase.cpp index e4bfe44e7..fe35ed850 100644 --- a/lib/IHandlerBase.cpp +++ b/lib/IHandlerBase.cpp @@ -12,6 +12,8 @@ #include "IHandlerBase.h" #include "CModHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + void IHandlerBase::registerObject(std::string scope, std::string type_name, std::string name, si32 index) { @@ -22,3 +24,5 @@ std::string IHandlerBase::normalizeIdentifier(const std::string& scope, const st { return VLC->modh->normalizeIdentifier(scope, remoteScope, identifier); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/IHandlerBase.h b/lib/IHandlerBase.h index 18566f294..04aa4d0e7 100644 --- a/lib/IHandlerBase.h +++ b/lib/IHandlerBase.h @@ -12,6 +12,8 @@ #include "../lib/ConstTransitivePtr.h" #include "VCMI_Lib.h" +VCMI_LIB_NAMESPACE_BEGIN + class JsonNode; class Entity; @@ -163,3 +165,5 @@ protected: public: //todo: make private std::vector> objects; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/Interprocess.h b/lib/Interprocess.h index 8137e77b7..cafe9666f 100644 --- a/lib/Interprocess.h +++ b/lib/Interprocess.h @@ -15,6 +15,8 @@ #include #include +VCMI_LIB_NAMESPACE_BEGIN + struct ServerReady { bool ready; @@ -78,3 +80,5 @@ struct SharedMemory boost::interprocess::shared_memory_object::remove(name.c_str()); } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/JsonDetail.cpp b/lib/JsonDetail.cpp index fde2a7523..3d0a6c47e 100644 --- a/lib/JsonDetail.cpp +++ b/lib/JsonDetail.cpp @@ -18,6 +18,8 @@ #include "filesystem/Filesystem.h" #include "ScopeGuard.h" +VCMI_LIB_NAMESPACE_BEGIN + static const JsonNode nullNode; template @@ -1242,3 +1244,5 @@ namespace Validation } } // Validation namespace + +VCMI_LIB_NAMESPACE_END diff --git a/lib/JsonDetail.h b/lib/JsonDetail.h index 89d19d5a6..23d3d8fb2 100644 --- a/lib/JsonDetail.h +++ b/lib/JsonDetail.h @@ -11,6 +11,8 @@ #include "JsonNode.h" +VCMI_LIB_NAMESPACE_BEGIN + class JsonWriter { //prefix for each line (tabulation) @@ -127,3 +129,5 @@ namespace Validation std::string check(std::string schemaName, const JsonNode & data, ValidationData & validator); std::string check(const JsonNode & schema, const JsonNode & data, ValidationData & validator); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/JsonNode.cpp b/lib/JsonNode.cpp index f80e8cfba..bab8a4645 100644 --- a/lib/JsonNode.cpp +++ b/lib/JsonNode.cpp @@ -21,6 +21,40 @@ #include "JsonDetail.h" #include "StringConstants.h" +namespace +{ +// to avoid duplicating const and non-const code +template +Node & resolvePointer(Node & in, const std::string & pointer) +{ + if(pointer.empty()) + return in; + assert(pointer[0] == '/'); + + size_t splitPos = pointer.find('/', 1); + + std::string entry = pointer.substr(1, splitPos - 1); + std::string remainer = splitPos == std::string::npos ? "" : pointer.substr(splitPos); + + if(in.getType() == VCMI_LIB_WRAP_NAMESPACE(JsonNode)::JsonType::DATA_VECTOR) + { + if(entry.find_first_not_of("0123456789") != std::string::npos) // non-numbers in string + throw std::runtime_error("Invalid Json pointer"); + + if(entry.size() > 1 && entry[0] == '0') // leading zeros are not allowed + throw std::runtime_error("Invalid Json pointer"); + + size_t index = boost::lexical_cast(entry); + + if (in.Vector().size() > index) + return in.Vector()[index].resolvePointer(remainer); + } + return in[entry].resolvePointer(remainer); +} +} + +VCMI_LIB_NAMESPACE_BEGIN + using namespace JsonDetail; class LibClasses; @@ -406,35 +440,6 @@ const JsonNode & JsonNode::operator[](std::string child) const return nullNode; } -// to avoid duplicating const and non-const code -template -Node & resolvePointer(Node & in, const std::string & pointer) -{ - if (pointer.empty()) - return in; - assert(pointer[0] == '/'); - - size_t splitPos = pointer.find('/', 1); - - std::string entry = pointer.substr(1, splitPos -1); - std::string remainer = splitPos == std::string::npos ? "" : pointer.substr(splitPos); - - if (in.getType() == JsonNode::JsonType::DATA_VECTOR) - { - if (entry.find_first_not_of("0123456789") != std::string::npos) // non-numbers in string - throw std::runtime_error("Invalid Json pointer"); - - if (entry.size() > 1 && entry[0] == '0') // leading zeros are not allowed - throw std::runtime_error("Invalid Json pointer"); - - size_t index = boost::lexical_cast(entry); - - if (in.Vector().size() > index) - return in.Vector()[index].resolvePointer(remainer); - } - return in[entry].resolvePointer(remainer); -} - const JsonNode & JsonNode::resolvePointer(const std::string &jsonPointer) const { return ::resolvePointer(*this, jsonPointer); @@ -1212,3 +1217,5 @@ DLL_LINKAGE JsonNode JsonUtils::intNode(si64 value) node.Integer() = value; return node; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/JsonNode.h b/lib/JsonNode.h index e29865f49..44a1ebdfc 100644 --- a/lib/JsonNode.h +++ b/lib/JsonNode.h @@ -10,6 +10,8 @@ #pragma once #include "GameConstants.h" +VCMI_LIB_NAMESPACE_BEGIN + class JsonNode; typedef std::map JsonMap; typedef std::vector JsonVector; @@ -360,3 +362,5 @@ Type JsonNode::convertTo() const { return JsonDetail::JsonConverter::convert(*this); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/LogicalExpression.cpp b/lib/LogicalExpression.cpp index 42207afa8..e14891bf2 100644 --- a/lib/LogicalExpression.cpp +++ b/lib/LogicalExpression.cpp @@ -14,8 +14,12 @@ #include "VCMI_Lib.h" #include "CGeneralTextHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + std::string LogicalExpressionDetail::getTextForOperator(std::string operation) { //placed in cpp mostly to avoid unnecessary includes in header return VLC->generaltexth->localizedTexts["logicalExpressions"][operation].String(); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/LogicalExpression.h b/lib/LogicalExpression.h index d567eafa5..a1f2fb528 100644 --- a/lib/LogicalExpression.h +++ b/lib/LogicalExpression.h @@ -12,6 +12,8 @@ //FIXME: move some of code into .cpp to avoid this include? #include "JsonNode.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace LogicalExpressionDetail { /// class that defines required types for logical expressions @@ -625,3 +627,5 @@ public: h & data; } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/NetPacks.h b/lib/NetPacks.h index 3016b2d19..e7ec6341f 100644 --- a/lib/NetPacks.h +++ b/lib/NetPacks.h @@ -23,8 +23,11 @@ #include "spells/ViewSpellInt.h" class CClient; -class CGameState; class CGameHandler; + +VCMI_LIB_NAMESPACE_BEGIN + +class CGameState; class CArtifact; class CGObjectInstance; class CArtifactInstance; @@ -2451,3 +2454,5 @@ struct CenterView : public CPackForClient h & focusTime; } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/NetPacksBase.h b/lib/NetPacksBase.h index 868e50245..d14cf0eb4 100644 --- a/lib/NetPacksBase.h +++ b/lib/NetPacksBase.h @@ -9,9 +9,18 @@ */ #pragma once +#include + +#include "ConstTransitivePtr.h" +#include "GameConstants.h" +#include "JsonNode.h" + class CClient; -class CGameState; class CGameHandler; + +VCMI_LIB_NAMESPACE_BEGIN + +class CGameState; class CConnection; class CStackBasicDescriptor; class CGHeroInstance; @@ -21,12 +30,6 @@ class CArtifactSet; class CBonusSystemNode; struct ArtSlotInfo; -#include - -#include "ConstTransitivePtr.h" -#include "GameConstants.h" -#include "JsonNode.h" - struct DLL_LINKAGE CPack { std::shared_ptr c; // Pointer to connection that pack received from @@ -368,3 +371,5 @@ public: h & operation; } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/NetPacksLib.cpp b/lib/NetPacksLib.cpp index 3fa981434..fe303a849 100644 --- a/lib/NetPacksLib.cpp +++ b/lib/NetPacksLib.cpp @@ -28,6 +28,8 @@ #include "StartInfo.h" #include "CPlayerState.h" +VCMI_LIB_NAMESPACE_BEGIN + DLL_LINKAGE void SetResources::applyGs(CGameState *gs) { @@ -1698,3 +1700,5 @@ DLL_LINKAGE void EntitiesChanged::applyGs(CGameState * gs) for(const auto & change : changes) gs->updateEntity(change.metatype, change.entityIndex, change.data); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/NetPacksLobby.h b/lib/NetPacksLobby.h index f635d3fa0..923cb84b8 100644 --- a/lib/NetPacksLobby.h +++ b/lib/NetPacksLobby.h @@ -13,14 +13,17 @@ #include "StartInfo.h" -class CCampaignState; class CLobbyScreen; class CServerHandler; +class CVCMIServer; + +VCMI_LIB_NAMESPACE_BEGIN + +class CCampaignState; class CMapInfo; struct StartInfo; class CMapGenOptions; struct ClientPlayer; -class CVCMIServer; struct CPackForLobby : public CPack { @@ -309,3 +312,5 @@ struct LobbyForceSetPlayer : public CLobbyPackToServer h & targetPlayerColor; } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/ObstacleHandler.cpp b/lib/ObstacleHandler.cpp index a55fe0678..5e37d9a3d 100644 --- a/lib/ObstacleHandler.cpp +++ b/lib/ObstacleHandler.cpp @@ -11,6 +11,8 @@ #include "ObstacleHandler.h" #include "BattleFieldHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + int32_t ObstacleInfo::getIndex() const { return obstacle.getNum(); @@ -110,3 +112,5 @@ const std::vector & ObstacleHandler::getTypeNames() const static const std::vector types = { "obstacle" }; return types; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/ObstacleHandler.h b/lib/ObstacleHandler.h index 7075d140b..aa3e0be9c 100644 --- a/lib/ObstacleHandler.h +++ b/lib/ObstacleHandler.h @@ -16,6 +16,8 @@ #include "Terrain.h" #include "battle/BattleHex.h" +VCMI_LIB_NAMESPACE_BEGIN + class DLL_LINKAGE ObstacleInfo : public EntityT { public: @@ -92,3 +94,5 @@ public: h & objects; } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/PathfinderUtil.h b/lib/PathfinderUtil.h index 0e750e9d4..558ee651d 100644 --- a/lib/PathfinderUtil.h +++ b/lib/PathfinderUtil.h @@ -12,6 +12,8 @@ #include "mapping/CMapDefines.h" #include "CGameState.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace PathfinderUtil { using FoW = std::shared_ptr>; @@ -74,3 +76,5 @@ namespace PathfinderUtil return CGPathNode::ACCESSIBLE; } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/ResourceSet.cpp b/lib/ResourceSet.cpp index 3d922c6f2..0a3470c5a 100644 --- a/lib/ResourceSet.cpp +++ b/lib/ResourceSet.cpp @@ -16,6 +16,8 @@ #include "VCMI_Lib.h" #include "mapObjects/CObjectHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + Res::ResourceSet::ResourceSet() { resize(GameConstants::RESOURCE_QUANTITY, 0); @@ -68,19 +70,19 @@ bool Res::ResourceSet::nonZero() const void Res::ResourceSet::amax(const TResourceCap &val) { for(auto & elem : *this) - ::vstd::amax(elem, val); + vstd::amax(elem, val); } void Res::ResourceSet::amin(const TResourceCap &val) { for(auto & elem : *this) - ::vstd::amin(elem, val); + vstd::amin(elem, val); } void Res::ResourceSet::positive() { for(auto & elem : *this) - ::vstd::amax(elem, 0); + vstd::amax(elem, 0); } bool Res::ResourceSet::canBeAfforded(const ResourceSet &res) const @@ -172,3 +174,5 @@ Res::ResourceSet::nziterator::nziterator(const ResourceSet &RS) if(!valid()) advance(); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/ResourceSet.h b/lib/ResourceSet.h index 7a6e58123..1ac047962 100644 --- a/lib/ResourceSet.h +++ b/lib/ResourceSet.h @@ -10,6 +10,8 @@ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + typedef si32 TResource; typedef si64 TResourceCap; //to avoid overflow when adding integers. Signed values are easier to control. @@ -167,3 +169,5 @@ namespace Res typedef Res::ResourceSet TResources; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/ScopeGuard.h b/lib/ScopeGuard.h index 6c57a0ca0..d72903711 100644 --- a/lib/ScopeGuard.h +++ b/lib/ScopeGuard.h @@ -10,6 +10,8 @@ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + namespace vstd { @@ -45,3 +47,5 @@ namespace vstd return ScopeGuard(std::forward(exitScope)); } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/ScriptHandler.cpp b/lib/ScriptHandler.cpp index 955ca2852..b64b0de2b 100644 --- a/lib/ScriptHandler.cpp +++ b/lib/ScriptHandler.cpp @@ -23,6 +23,8 @@ #include "serializer/JsonSerializer.h" #include "filesystem/Filesystem.h" +VCMI_LIB_NAMESPACE_BEGIN + static const std::vector IMPLEMENTS_MAP = { "ANYTHING", @@ -69,7 +71,7 @@ const std::string & ScriptImpl::getSource() const return sourceText; } -void ScriptImpl::performRegistration(::Services * services) const +void ScriptImpl::performRegistration(Services * services) const { switch(implements) { @@ -312,4 +314,6 @@ void ScriptHandler::saveState(JsonNode & state) } + +VCMI_LIB_NAMESPACE_END #endif diff --git a/lib/ScriptHandler.h b/lib/ScriptHandler.h index 53d91110c..a4eda8ab2 100644 --- a/lib/ScriptHandler.h +++ b/lib/ScriptHandler.h @@ -15,6 +15,8 @@ #include "IHandlerBase.h" #include "JsonNode.h" +VCMI_LIB_NAMESPACE_BEGIN + class JsonNode; class JsonSerializeFormat; class Services; @@ -61,7 +63,7 @@ public: const std::string & getName() const override; const std::string & getSource() const override; - void performRegistration(::Services * services) const; + void performRegistration(Services * services) const; private: const ScriptHandler * owner; @@ -85,7 +87,7 @@ private: ServerCallback * srv; }; -class DLL_LINKAGE ScriptHandler : public ::IHandlerBase, public Service +class DLL_LINKAGE ScriptHandler : public IHandlerBase, public Service { public: ScriptMap objects; @@ -132,4 +134,6 @@ private: }; } + +VCMI_LIB_NAMESPACE_END #endif diff --git a/lib/StartInfo.cpp b/lib/StartInfo.cpp index 97b703616..ba98f09c0 100644 --- a/lib/StartInfo.cpp +++ b/lib/StartInfo.cpp @@ -14,6 +14,8 @@ #include "rmg/CMapGenOptions.h" #include "mapping/CMapInfo.h" +VCMI_LIB_NAMESPACE_BEGIN + PlayerSettings::PlayerSettings() : bonus(RANDOM), castle(NONE), hero(RANDOM), heroPortrait(RANDOM), color(0), handicap(NO_HANDICAP), team(0), compOnly(false) { @@ -193,3 +195,5 @@ TeamID LobbyInfo::getPlayerTeamId(PlayerColor color) else return TeamID::NO_TEAM; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/StartInfo.h b/lib/StartInfo.h index 2f0fb3b71..1bda6a40d 100644 --- a/lib/StartInfo.h +++ b/lib/StartInfo.h @@ -11,6 +11,8 @@ #include "GameConstants.h" +VCMI_LIB_NAMESPACE_BEGIN + class CMapGenOptions; class CCampaignState; class CMapInfo; @@ -175,3 +177,5 @@ struct DLL_LINKAGE LobbyInfo : public LobbyState TeamID getPlayerTeamId(PlayerColor color); }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/StringConstants.h b/lib/StringConstants.h index 721a070ae..08b0cbd9f 100644 --- a/lib/StringConstants.h +++ b/lib/StringConstants.h @@ -11,6 +11,8 @@ #include "GameConstants.h" +VCMI_LIB_NAMESPACE_BEGIN + /// /// String ID which are pointless to move to config file - these types are mostly hardcoded /// @@ -114,3 +116,5 @@ namespace NMetaclass "object", "primarySkill", "secondarySkill", "spell", "resource" }; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/Terrain.cpp b/lib/Terrain.cpp index 7f89447d2..12f7f72fb 100644 --- a/lib/Terrain.cpp +++ b/lib/Terrain.cpp @@ -13,6 +13,8 @@ #include "VCMI_Lib.h" #include "CModHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + //regular expression to change id for string at config //("allowedTerrain"\s*:\s*\[.*)9(.*\],\n) //\1"rock"\2 @@ -251,3 +253,5 @@ bool Terrain::isTransitionRequired() const { return Terrain::Manager::getInfo(*this).transitionRequired; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/Terrain.h b/lib/Terrain.h index 95fa343b0..b71dc172e 100644 --- a/lib/Terrain.h +++ b/lib/Terrain.h @@ -14,6 +14,7 @@ #include "GameConstants.h" #include "JsonNode.h" +VCMI_LIB_NAMESPACE_BEGIN class DLL_LINKAGE Terrain { @@ -103,3 +104,5 @@ protected: }; DLL_LINKAGE std::ostream & operator<<(std::ostream & os, const Terrain terrainType); + +VCMI_LIB_NAMESPACE_END diff --git a/lib/UnlockGuard.h b/lib/UnlockGuard.h index f8a2835d1..51ec8541d 100644 --- a/lib/UnlockGuard.h +++ b/lib/UnlockGuard.h @@ -9,6 +9,8 @@ */ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + namespace vstd { namespace detail @@ -114,3 +116,5 @@ namespace vstd typedef unlock_guard > unlock_shared_guard; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/VCMIDirs.cpp b/lib/VCMIDirs.cpp index ee42f02b5..86749fb17 100644 --- a/lib/VCMIDirs.cpp +++ b/lib/VCMIDirs.cpp @@ -11,6 +11,12 @@ #include "StdInc.h" #include "VCMIDirs.h" +#ifdef VCMI_IOS +#include "iOS_utils.h" +#endif + +VCMI_LIB_NAMESPACE_BEGIN + namespace bfs = boost::filesystem; bfs::path IVCMIDirs::userLogsPath() const { return userCachePath(); } @@ -349,7 +355,7 @@ class IVCMIDirsUNIX : public IVCMIDirs boost::filesystem::path clientPath() const override; boost::filesystem::path serverPath() const override; - bool developmentMode() const; + virtual bool developmentMode() const; }; bool IVCMIDirsUNIX::developmentMode() const @@ -362,22 +368,65 @@ bfs::path IVCMIDirsUNIX::clientPath() const { return binaryPath() / "vcmiclient" bfs::path IVCMIDirsUNIX::serverPath() const { return binaryPath() / "vcmiserver"; } #ifdef VCMI_APPLE -class VCMIDirsOSX final : public IVCMIDirsUNIX +class VCMIDirsApple : public IVCMIDirsUNIX { - public: - boost::filesystem::path userDataPath() const override; - boost::filesystem::path userCachePath() const override; - boost::filesystem::path userConfigPath() const override; - boost::filesystem::path userLogsPath() const override; +public: + bfs::path userConfigPath() const override; - std::vector dataPaths() const override; + std::string libraryName(const std::string& basename) const override; +}; - boost::filesystem::path libraryPath() const override; - boost::filesystem::path binaryPath() const override; +bfs::path VCMIDirsApple::userConfigPath() const { return userDataPath() / "config"; } - std::string libraryName(const std::string& basename) const override; +std::string VCMIDirsApple::libraryName(const std::string& basename) const { return "lib" + basename + ".dylib"; } - void init() override; +#ifdef VCMI_IOS +class VCMIDirsIOS final : public VCMIDirsApple +{ +public: + bfs::path userDataPath() const override; + bfs::path userCachePath() const override; + bfs::path userLogsPath() const override; + + std::vector dataPaths() const override; + + bfs::path libraryPath() const override; + bfs::path binaryPath() const override; +}; + +bfs::path VCMIDirsIOS::userDataPath() const { return {iOS_utils::documentsPath()}; } +bfs::path VCMIDirsIOS::userCachePath() const { return {iOS_utils::cachesPath()}; } +bfs::path VCMIDirsIOS::userLogsPath() const { return {iOS_utils::documentsPath()}; } + +std::vector VCMIDirsIOS::dataPaths() const +{ + std::vector paths; + paths.reserve(4); +#ifdef VCMI_IOS_SIM + paths.emplace_back(iOS_utils::hostApplicationSupportPath()); +#endif + paths.emplace_back(userDataPath()); + paths.emplace_back(iOS_utils::documentsPath()); + paths.emplace_back(binaryPath()); + return paths; +} + +bfs::path VCMIDirsIOS::libraryPath() const { return {iOS_utils::frameworksPath()}; } +bfs::path VCMIDirsIOS::binaryPath() const { return {iOS_utils::bundlePath()}; } +#elif defined(VCMI_MAC) +class VCMIDirsOSX final : public VCMIDirsApple +{ +public: + boost::filesystem::path userDataPath() const override; + boost::filesystem::path userCachePath() const override; + boost::filesystem::path userLogsPath() const override; + + std::vector dataPaths() const override; + + boost::filesystem::path libraryPath() const override; + boost::filesystem::path binaryPath() const override; + + void init() override; }; void VCMIDirsOSX::init() @@ -436,7 +485,6 @@ bfs::path VCMIDirsOSX::userDataPath() const return bfs::path(homeDir) / "Library" / "Application Support" / "vcmi"; } bfs::path VCMIDirsOSX::userCachePath() const { return userDataPath(); } -bfs::path VCMIDirsOSX::userConfigPath() const { return userDataPath() / "config"; } bfs::path VCMIDirsOSX::userLogsPath() const { @@ -463,8 +511,7 @@ std::vector VCMIDirsOSX::dataPaths() const bfs::path VCMIDirsOSX::libraryPath() const { return "."; } bfs::path VCMIDirsOSX::binaryPath() const { return "."; } - -std::string VCMIDirsOSX::libraryName(const std::string& basename) const { return "lib" + basename + ".dylib"; } +#endif // VCMI_IOS, VCMI_MAC #elif defined(VCMI_XDG) class VCMIDirsXDG : public IVCMIDirsUNIX { @@ -635,9 +682,11 @@ namespace VCMIDirs static VCMIDirsAndroid singleton; #elif defined(VCMI_XDG) static VCMIDirsXDG singleton; - #elif defined(VCMI_APPLE) + #elif defined(VCMI_MAC) static VCMIDirsOSX singleton; - #endif + #elif defined(VCMI_IOS) + static VCMIDirsIOS singleton; + #endif static bool initialized = false; if (!initialized) @@ -654,3 +703,5 @@ namespace VCMIDirs } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/VCMIDirs.h b/lib/VCMIDirs.h index deaa263ab..791f07483 100644 --- a/lib/VCMIDirs.h +++ b/lib/VCMIDirs.h @@ -9,6 +9,8 @@ */ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + class DLL_LINKAGE IVCMIDirs { public: @@ -64,3 +66,5 @@ namespace VCMIDirs { extern DLL_LINKAGE const IVCMIDirs & get(); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/VCMI_Lib.cpp b/lib/VCMI_Lib.cpp index d79a9003a..f1c862d7c 100644 --- a/lib/VCMI_Lib.cpp +++ b/lib/VCMI_Lib.cpp @@ -35,6 +35,8 @@ #include "BattleFieldHandler.h" #include "ObstacleHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + LibClasses * VLC = nullptr; DLL_LINKAGE void preinitDLL(CConsoleHandler * Console, bool onlyEssential) @@ -316,3 +318,5 @@ void LibClasses::setContent(std::shared_ptr content) { modh->content = content; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/VCMI_Lib.h b/lib/VCMI_Lib.h index 4b822751b..476819e36 100644 --- a/lib/VCMI_Lib.h +++ b/lib/VCMI_Lib.h @@ -11,6 +11,8 @@ #include +VCMI_LIB_NAMESPACE_BEGIN + class CConsoleHandler; class CArtHandler; class CHeroHandler; @@ -149,3 +151,5 @@ extern DLL_LINKAGE LibClasses * VLC; DLL_LINKAGE void preinitDLL(CConsoleHandler * Console, bool onlyEssential = false); DLL_LINKAGE void loadDLLClasses(bool onlyEssential = false); + +VCMI_LIB_NAMESPACE_END diff --git a/lib/abilities/Ability.h b/lib/abilities/Ability.h index 30f10fb67..14bf3d54e 100644 --- a/lib/abilities/Ability.h +++ b/lib/abilities/Ability.h @@ -7,6 +7,9 @@ * Full text of license available in license.txt file, in main folder * */ + +VCMI_LIB_NAMESPACE_BEGIN + namespace abilities { @@ -16,3 +19,5 @@ class DLL_LINKAGE Ability }; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/AccessibilityInfo.cpp b/lib/battle/AccessibilityInfo.cpp index 4ba58a802..2681dfeed 100644 --- a/lib/battle/AccessibilityInfo.cpp +++ b/lib/battle/AccessibilityInfo.cpp @@ -12,6 +12,8 @@ #include "Unit.h" #include "../GameConstants.h" +VCMI_LIB_NAMESPACE_BEGIN + bool AccessibilityInfo::accessible(BattleHex tile, const battle::Unit * stack) const { return accessible(tile, stack->doubleWide(), stack->unitSide()); @@ -37,3 +39,5 @@ bool AccessibilityInfo::accessible(BattleHex tile, bool doubleWide, ui8 side) co return true; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/AccessibilityInfo.h b/lib/battle/AccessibilityInfo.h index 7386b794f..597b1473e 100644 --- a/lib/battle/AccessibilityInfo.h +++ b/lib/battle/AccessibilityInfo.h @@ -11,6 +11,8 @@ #include "BattleHex.h" #include "../GameConstants.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace battle { class Unit; @@ -36,3 +38,5 @@ struct DLL_LINKAGE AccessibilityInfo : TAccessibilityArray bool accessible(BattleHex tile, const battle::Unit * stack) const; //checks for both tiles if stack is double wide bool accessible(BattleHex tile, bool doubleWide, ui8 side) const; //checks for both tiles if stack is double wide }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/BattleAction.cpp b/lib/battle/BattleAction.cpp index 36c53560b..9567ffbb1 100644 --- a/lib/battle/BattleAction.cpp +++ b/lib/battle/BattleAction.cpp @@ -13,6 +13,8 @@ #include "Unit.h" #include "CBattleInfoCallback.h" +VCMI_LIB_NAMESPACE_BEGIN + static const int32_t INVALID_UNIT_ID = -1000; BattleAction::BattleAction(): @@ -181,3 +183,5 @@ std::ostream & operator<<(std::ostream & os, const BattleAction & ba) os << ba.toString(); return os; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/BattleAction.h b/lib/battle/BattleAction.h index 228558ab5..ecce56ccb 100644 --- a/lib/battle/BattleAction.h +++ b/lib/battle/BattleAction.h @@ -11,6 +11,8 @@ #include "Destination.h" #include "../GameConstants.h" +VCMI_LIB_NAMESPACE_BEGIN + class CBattleInfoCallback; namespace battle @@ -73,3 +75,5 @@ private: }; DLL_EXPORT std::ostream & operator<<(std::ostream & os, const BattleAction & ba); //todo: remove + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/BattleAttackInfo.cpp b/lib/battle/BattleAttackInfo.cpp index 7b42e23c8..1d38d699b 100644 --- a/lib/battle/BattleAttackInfo.cpp +++ b/lib/battle/BattleAttackInfo.cpp @@ -11,6 +11,8 @@ #include "BattleAttackInfo.h" #include "CUnitState.h" +VCMI_LIB_NAMESPACE_BEGIN + BattleAttackInfo::BattleAttackInfo(const battle::Unit * Attacker, const battle::Unit * Defender, bool Shooting) : attacker(Attacker), defender(Defender) @@ -38,3 +40,5 @@ BattleAttackInfo BattleAttackInfo::reverse() const return ret; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/BattleAttackInfo.h b/lib/battle/BattleAttackInfo.h index c121dc177..b24376a30 100644 --- a/lib/battle/BattleAttackInfo.h +++ b/lib/battle/BattleAttackInfo.h @@ -9,14 +9,16 @@ */ #pragma once +#include "BattleHex.h" + +VCMI_LIB_NAMESPACE_BEGIN + namespace battle { class Unit; class CUnitState; } -#include "BattleHex.h" - struct DLL_LINKAGE BattleAttackInfo { const battle::Unit * attacker; @@ -34,3 +36,5 @@ struct DLL_LINKAGE BattleAttackInfo BattleAttackInfo(const battle::Unit * Attacker, const battle::Unit * Defender, bool Shooting = false); BattleAttackInfo reverse() const; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/BattleHex.cpp b/lib/battle/BattleHex.cpp index db83f9c4f..7763fb335 100644 --- a/lib/battle/BattleHex.cpp +++ b/lib/battle/BattleHex.cpp @@ -10,6 +10,8 @@ #include "StdInc.h" #include "BattleHex.h" +VCMI_LIB_NAMESPACE_BEGIN + BattleHex::BattleHex() : hex(INVALID) {} BattleHex::BattleHex(si16 _hex) : hex(_hex) {} @@ -224,3 +226,5 @@ static BattleHex::NeighbouringTilesCache calculateNeighbouringTiles() } const BattleHex::NeighbouringTilesCache BattleHex::neighbouringTilesCache = calculateNeighbouringTiles(); + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/BattleHex.h b/lib/battle/BattleHex.h index 6633da3e6..c79d77a0a 100644 --- a/lib/battle/BattleHex.h +++ b/lib/battle/BattleHex.h @@ -9,6 +9,8 @@ */ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + //TODO: change to enum class namespace BattleSide @@ -82,3 +84,5 @@ struct DLL_LINKAGE BattleHex //TODO: decide if this should be changed to class f }; DLL_EXPORT std::ostream & operator<<(std::ostream & os, const BattleHex & hex); + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/BattleInfo.cpp b/lib/battle/BattleInfo.cpp index 3ffa5d742..c7a1c533a 100644 --- a/lib/battle/BattleInfo.cpp +++ b/lib/battle/BattleInfo.cpp @@ -22,6 +22,8 @@ //TODO: remove #include "../IGameCallback.h" +VCMI_LIB_NAMESPACE_BEGIN + ///BattleInfo std::pair< std::vector, int > BattleInfo::getPath(BattleHex start, BattleHex dest, const CStack * stack) { @@ -1011,3 +1013,5 @@ CMP_stack::CMP_stack(int Phase, int Turn, uint8_t Side) turn = Turn; side = Side; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/BattleInfo.h b/lib/battle/BattleInfo.h index 73a4ad0cc..bfcb52641 100644 --- a/lib/battle/BattleInfo.h +++ b/lib/battle/BattleInfo.h @@ -15,6 +15,8 @@ #include "SiegeInfo.h" #include "SideInBattle.h" +VCMI_LIB_NAMESPACE_BEGIN + class CStack; class CStackInstance; class CStackBasicDescriptor; @@ -160,3 +162,5 @@ public: bool operator ()(const battle::Unit * a, const battle::Unit * b); CMP_stack(int Phase = 1, int Turn = 0, uint8_t Side = BattleSide::ATTACKER); }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/BattleProxy.cpp b/lib/battle/BattleProxy.cpp index 83df1520a..4c10cde52 100644 --- a/lib/battle/BattleProxy.cpp +++ b/lib/battle/BattleProxy.cpp @@ -12,6 +12,8 @@ #include "Unit.h" #include "Terrain.h" +VCMI_LIB_NAMESPACE_BEGIN + ///BattleProxy BattleProxy::BattleProxy(Subject subject_) @@ -112,3 +114,5 @@ const IBonusBearer * BattleProxy::asBearer() const return subject->getBattleNode(); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/BattleProxy.h b/lib/battle/BattleProxy.h index b756dadea..cd728ef53 100644 --- a/lib/battle/BattleProxy.h +++ b/lib/battle/BattleProxy.h @@ -12,6 +12,8 @@ #include "CBattleInfoCallback.h" #include "IBattleState.h" +VCMI_LIB_NAMESPACE_BEGIN + class DLL_LINKAGE BattleProxy : public CBattleInfoCallback, public IBattleState { public: @@ -52,3 +54,5 @@ public: protected: Subject subject; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/CBattleInfoCallback.cpp b/lib/battle/CBattleInfoCallback.cpp index fbeb7d20a..8d891a8f6 100644 --- a/lib/battle/CBattleInfoCallback.cpp +++ b/lib/battle/CBattleInfoCallback.cpp @@ -19,6 +19,8 @@ #include "../mapObjects/CGTownInstance.h" #include "../BattleFieldHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace SiegeStuffThatShouldBeMovedToHandlers // <=== TODO { /* @@ -1991,3 +1993,5 @@ boost::optional CBattleInfoCallback::battleIsFinished() const else return 1; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/CBattleInfoCallback.h b/lib/battle/CBattleInfoCallback.h index b5cd714c3..db88b9f11 100644 --- a/lib/battle/CBattleInfoCallback.h +++ b/lib/battle/CBattleInfoCallback.h @@ -15,6 +15,8 @@ #include "ReachabilityInfo.h" #include "BattleAttackInfo.h" +VCMI_LIB_NAMESPACE_BEGIN + class CGHeroInstance; class CStack; class ISpellCaster; @@ -151,3 +153,5 @@ protected: bool isInObstacle(BattleHex hex, const std::set & obstacles, const ReachabilityInfo::Parameters & params) const; std::set getStoppers(BattlePerspective::BattlePerspective whichSidePerspective) const; //get hexes with stopping obstacles (quicksands) }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/CBattleInfoEssentials.cpp b/lib/battle/CBattleInfoEssentials.cpp index 9d0370a1f..8ed3b44a5 100644 --- a/lib/battle/CBattleInfoEssentials.cpp +++ b/lib/battle/CBattleInfoEssentials.cpp @@ -14,6 +14,8 @@ #include "../NetPacks.h" #include "../mapObjects/CGTownInstance.h" +VCMI_LIB_NAMESPACE_BEGIN + Terrain CBattleInfoEssentials::battleTerrainType() const { RETURN_IF_NOT_BATTLE(Terrain()); @@ -423,3 +425,5 @@ bool CBattleInfoEssentials::battleMatchOwner(const PlayerColor & attacker, const return boost::logic::indeterminate(positivness) || (attacker == initialOwner) == (bool)positivness; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/CBattleInfoEssentials.h b/lib/battle/CBattleInfoEssentials.h index bc354ab78..cc3ec0992 100644 --- a/lib/battle/CBattleInfoEssentials.h +++ b/lib/battle/CBattleInfoEssentials.h @@ -11,6 +11,8 @@ #include "CCallbackBase.h" #include "IBattleInfoCallback.h" +VCMI_LIB_NAMESPACE_BEGIN + class CGTownInstance; class CGHeroInstance; class CStack; @@ -113,3 +115,5 @@ public: bool battleMatchOwner(const battle::Unit * attacker, const battle::Unit * defender, const boost::logic::tribool positivness = false) const; bool battleMatchOwner(const PlayerColor & attacker, const battle::Unit * defender, const boost::logic::tribool positivness = false) const; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/CCallbackBase.cpp b/lib/battle/CCallbackBase.cpp index 39bdb5087..6bf4f7840 100644 --- a/lib/battle/CCallbackBase.cpp +++ b/lib/battle/CCallbackBase.cpp @@ -11,6 +11,8 @@ #include "CCallbackBase.h" #include "IBattleState.h" +VCMI_LIB_NAMESPACE_BEGIN + bool CCallbackBase::duringBattle() const { return getBattle() != nullptr; @@ -39,3 +41,5 @@ boost::optional CCallbackBase::getPlayerID() const return player; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/CCallbackBase.h b/lib/battle/CCallbackBase.h index 43ff7cfc8..b83a8e82e 100644 --- a/lib/battle/CCallbackBase.h +++ b/lib/battle/CCallbackBase.h @@ -13,6 +13,8 @@ #define RETURN_IF_NOT_BATTLE(...) if(!duringBattle()) {logGlobal->error("%s called when no battle!", __FUNCTION__); return __VA_ARGS__; } #define ASSERT_IF_CALLED_WITH_PLAYER if(!player) {logGlobal->error(BOOST_CURRENT_FUNCTION); assert(0);} +VCMI_LIB_NAMESPACE_BEGIN + class IBattleInfo; class BattleInfo; class CBattleInfoEssentials; @@ -40,3 +42,5 @@ public: friend class CBattleInfoEssentials; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/CObstacleInstance.cpp b/lib/battle/CObstacleInstance.cpp index 78edff13b..92e07c76c 100644 --- a/lib/battle/CObstacleInstance.cpp +++ b/lib/battle/CObstacleInstance.cpp @@ -18,6 +18,8 @@ #include "../serializer/JsonDeserializer.h" #include "../serializer/JsonSerializer.h" +VCMI_LIB_NAMESPACE_BEGIN + CObstacleInstance::CObstacleInstance() { obstacleType = USUAL; @@ -213,3 +215,5 @@ std::vector MoatObstacle::getAffectedTiles() const { return (*VLC->townh)[ID]->town->moatHexes; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/CObstacleInstance.h b/lib/battle/CObstacleInstance.h index 041330779..c668b8ba4 100644 --- a/lib/battle/CObstacleInstance.h +++ b/lib/battle/CObstacleInstance.h @@ -10,6 +10,8 @@ #pragma once #include "BattleHex.h" +VCMI_LIB_NAMESPACE_BEGIN + class ObstacleInfo; class ObstacleChanges; class JsonSerializeFormat; @@ -118,3 +120,5 @@ struct DLL_LINKAGE SpellCreatedObstacle : CObstacleInstance h & customSize; } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/CPlayerBattleCallback.cpp b/lib/battle/CPlayerBattleCallback.cpp index 5dae89f11..abdc631ed 100644 --- a/lib/battle/CPlayerBattleCallback.cpp +++ b/lib/battle/CPlayerBattleCallback.cpp @@ -12,6 +12,8 @@ #include "../CStack.h" #include "../CGameState.h" +VCMI_LIB_NAMESPACE_BEGIN + bool CPlayerBattleCallback::battleCanFlee() const { RETURN_IF_NOT_BATTLE(false); @@ -52,3 +54,5 @@ InfoAboutHero CPlayerBattleCallback::battleGetEnemyHero() const return battleGetHeroInfo(!battleGetMySide()); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/CPlayerBattleCallback.h b/lib/battle/CPlayerBattleCallback.h index 38ac80baa..f903a37af 100644 --- a/lib/battle/CPlayerBattleCallback.h +++ b/lib/battle/CPlayerBattleCallback.h @@ -10,6 +10,8 @@ #pragma once #include "CBattleInfoCallback.h" +VCMI_LIB_NAMESPACE_BEGIN + class CGHeroInstance; class DLL_LINKAGE CPlayerBattleCallback : public CBattleInfoCallback @@ -24,3 +26,5 @@ public: InfoAboutHero battleGetEnemyHero() const; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/CUnitState.cpp b/lib/battle/CUnitState.cpp index 248dcfd10..770ce2b9d 100644 --- a/lib/battle/CUnitState.cpp +++ b/lib/battle/CUnitState.cpp @@ -19,6 +19,8 @@ #include "../serializer/JsonDeserializer.h" #include "../serializer/JsonSerializer.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace battle { ///CAmmo @@ -952,3 +954,5 @@ void CUnitStateDetached::spendMana(ServerCallback * server, const int spellCost) } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/CUnitState.h b/lib/battle/CUnitState.h index 46fee68b3..5bd3e02e4 100644 --- a/lib/battle/CUnitState.h +++ b/lib/battle/CUnitState.h @@ -12,6 +12,8 @@ #include "Unit.h" +VCMI_LIB_NAMESPACE_BEGIN + class JsonSerializeFormat; class UnitChanges; @@ -294,3 +296,5 @@ private: }; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/Destination.cpp b/lib/battle/Destination.cpp index ba7fea41d..406b51f97 100644 --- a/lib/battle/Destination.cpp +++ b/lib/battle/Destination.cpp @@ -13,6 +13,8 @@ #include "Unit.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace battle { @@ -62,3 +64,5 @@ Destination & Destination::operator=(const Destination & other) } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/Destination.h b/lib/battle/Destination.h index 8d5cb274f..904e8fc8d 100644 --- a/lib/battle/Destination.h +++ b/lib/battle/Destination.h @@ -12,6 +12,8 @@ #include "BattleHex.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace battle { @@ -37,3 +39,5 @@ public: using Target = std::vector; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/IBattleInfoCallback.h b/lib/battle/IBattleInfoCallback.h index fcce0c7f2..d1bb1a3d6 100644 --- a/lib/battle/IBattleInfoCallback.h +++ b/lib/battle/IBattleInfoCallback.h @@ -12,6 +12,8 @@ #include "BattleHex.h" +VCMI_LIB_NAMESPACE_BEGIN + struct CObstacleInstance; class BattleField; class Terrain; @@ -62,3 +64,5 @@ public: }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/IBattleState.h b/lib/battle/IBattleState.h index 02f21d935..6e88b13ac 100644 --- a/lib/battle/IBattleState.h +++ b/lib/battle/IBattleState.h @@ -11,6 +11,8 @@ #pragma once #include "CBattleInfoEssentials.h" +VCMI_LIB_NAMESPACE_BEGIN + class ObstacleChanges; class UnitChanges; struct Bonus; @@ -91,3 +93,5 @@ public: virtual void updateObstacle(const ObstacleChanges & changes) = 0; virtual void removeObstacle(uint32_t id) = 0; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/IUnitInfo.h b/lib/battle/IUnitInfo.h index e8edfe3f0..f91ccce2f 100644 --- a/lib/battle/IUnitInfo.h +++ b/lib/battle/IUnitInfo.h @@ -12,6 +12,8 @@ #include "../GameConstants.h" +VCMI_LIB_NAMESPACE_BEGIN + class CCreature; namespace battle @@ -41,3 +43,5 @@ public: }; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/ReachabilityInfo.cpp b/lib/battle/ReachabilityInfo.cpp index 2dc8caa61..0a5452e26 100644 --- a/lib/battle/ReachabilityInfo.cpp +++ b/lib/battle/ReachabilityInfo.cpp @@ -12,6 +12,8 @@ #include "ReachabilityInfo.h" #include "Unit.h" +VCMI_LIB_NAMESPACE_BEGIN + ReachabilityInfo::Parameters::Parameters() { @@ -72,3 +74,5 @@ int ReachabilityInfo::distToNearestNeighbour( return distToNearestNeighbour(attackableHexes, chosenHex); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/ReachabilityInfo.h b/lib/battle/ReachabilityInfo.h index 9078a3b86..502a269ec 100644 --- a/lib/battle/ReachabilityInfo.h +++ b/lib/battle/ReachabilityInfo.h @@ -12,6 +12,8 @@ #include "CBattleInfoEssentials.h" #include "AccessibilityInfo.h" +VCMI_LIB_NAMESPACE_BEGIN + // Reachability info is result of BFS calculation. It's dependent on stack (it's owner, whether it's flying), // startPosition and perpective. struct DLL_LINKAGE ReachabilityInfo @@ -55,3 +57,5 @@ struct DLL_LINKAGE ReachabilityInfo }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/SideInBattle.cpp b/lib/battle/SideInBattle.cpp index 3696f4128..638de4929 100644 --- a/lib/battle/SideInBattle.cpp +++ b/lib/battle/SideInBattle.cpp @@ -11,6 +11,8 @@ #include "SideInBattle.h" #include "../mapObjects/CArmedInstance.h" +VCMI_LIB_NAMESPACE_BEGIN + SideInBattle::SideInBattle() { color = PlayerColor::CANNOT_DETERMINE; @@ -29,3 +31,5 @@ void SideInBattle::init(const CGHeroInstance * Hero, const CArmedInstance * Army if(color == PlayerColor::UNFLAGGABLE) color = PlayerColor::NEUTRAL; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/SideInBattle.h b/lib/battle/SideInBattle.h index 9f571e614..14ff2cc13 100644 --- a/lib/battle/SideInBattle.h +++ b/lib/battle/SideInBattle.h @@ -10,6 +10,8 @@ #pragma once #include "../GameConstants.h" +VCMI_LIB_NAMESPACE_BEGIN + class CGHeroInstance; class CArmedInstance; @@ -37,3 +39,5 @@ struct DLL_LINKAGE SideInBattle h & enchanterCounter; } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/SiegeInfo.cpp b/lib/battle/SiegeInfo.cpp index 42a33e9de..13c2dc468 100644 --- a/lib/battle/SiegeInfo.cpp +++ b/lib/battle/SiegeInfo.cpp @@ -10,6 +10,8 @@ #include "StdInc.h" #include "SiegeInfo.h" +VCMI_LIB_NAMESPACE_BEGIN + SiegeInfo::SiegeInfo() { @@ -37,3 +39,5 @@ EWallState::EWallState SiegeInfo::applyDamage(EWallState::EWallState state, unsi return EWallState::NONE; } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/SiegeInfo.h b/lib/battle/SiegeInfo.h index 7859d2740..f508c1f14 100644 --- a/lib/battle/SiegeInfo.h +++ b/lib/battle/SiegeInfo.h @@ -10,6 +10,8 @@ #pragma once #include "../GameConstants.h" +VCMI_LIB_NAMESPACE_BEGIN + //only for use in BattleInfo struct DLL_LINKAGE SiegeInfo { @@ -27,3 +29,5 @@ struct DLL_LINKAGE SiegeInfo h & gateState; } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/Unit.cpp b/lib/battle/Unit.cpp index 663da7d89..d98cfe2e9 100644 --- a/lib/battle/Unit.cpp +++ b/lib/battle/Unit.cpp @@ -18,6 +18,8 @@ #include "../serializer/JsonDeserializer.h" #include "../serializer/JsonSerializer.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace battle { @@ -238,3 +240,5 @@ void UnitInfo::load(uint32_t id_, const JsonNode & data) } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/battle/Unit.h b/lib/battle/Unit.h index 26d834d93..656c7bd7a 100644 --- a/lib/battle/Unit.h +++ b/lib/battle/Unit.h @@ -17,6 +17,8 @@ #include "IUnitInfo.h" #include "BattleHex.h" +VCMI_LIB_NAMESPACE_BEGIN + struct MetaString; class JsonNode; class JsonSerializeFormat; @@ -129,3 +131,5 @@ public: }; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/events/ApplyDamage.cpp b/lib/events/ApplyDamage.cpp index 93b387899..b0466da64 100644 --- a/lib/events/ApplyDamage.cpp +++ b/lib/events/ApplyDamage.cpp @@ -15,6 +15,8 @@ #include "../../lib/NetPacks.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace events { @@ -58,3 +60,5 @@ const battle::Unit * CApplyDamage::getTarget() const }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/events/ApplyDamage.h b/lib/events/ApplyDamage.h index 178d12224..a7a426c45 100644 --- a/lib/events/ApplyDamage.h +++ b/lib/events/ApplyDamage.h @@ -12,6 +12,8 @@ #include +VCMI_LIB_NAMESPACE_BEGIN + namespace events { @@ -33,3 +35,5 @@ private: }; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/events/GameResumed.cpp b/lib/events/GameResumed.cpp index b7d98bb77..b2e493900 100644 --- a/lib/events/GameResumed.cpp +++ b/lib/events/GameResumed.cpp @@ -13,6 +13,8 @@ #include +VCMI_LIB_NAMESPACE_BEGIN + namespace events { @@ -37,3 +39,5 @@ bool CGameResumed::isEnabled() const } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/events/GameResumed.h b/lib/events/GameResumed.h index c0c36e3be..9fc3df73a 100644 --- a/lib/events/GameResumed.h +++ b/lib/events/GameResumed.h @@ -12,6 +12,8 @@ #include +VCMI_LIB_NAMESPACE_BEGIN + namespace events { @@ -24,3 +26,5 @@ public: }; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/events/ObjectVisitEnded.cpp b/lib/events/ObjectVisitEnded.cpp index 6c8f2e2af..61d4d801f 100644 --- a/lib/events/ObjectVisitEnded.cpp +++ b/lib/events/ObjectVisitEnded.cpp @@ -13,6 +13,8 @@ #include +VCMI_LIB_NAMESPACE_BEGIN + namespace events { @@ -53,3 +55,5 @@ ObjectInstanceID CObjectVisitEnded::getHero() const } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/events/ObjectVisitEnded.h b/lib/events/ObjectVisitEnded.h index a3b8323ab..2cdf22d2e 100644 --- a/lib/events/ObjectVisitEnded.h +++ b/lib/events/ObjectVisitEnded.h @@ -14,6 +14,8 @@ #include "../GameConstants.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace events { @@ -31,3 +33,5 @@ private: }; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/events/ObjectVisitStarted.cpp b/lib/events/ObjectVisitStarted.cpp index 863da819d..d535bd263 100644 --- a/lib/events/ObjectVisitStarted.cpp +++ b/lib/events/ObjectVisitStarted.cpp @@ -13,6 +13,8 @@ #include +VCMI_LIB_NAMESPACE_BEGIN + namespace events { @@ -65,3 +67,5 @@ void CObjectVisitStarted::setEnabled(bool enable) } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/events/ObjectVisitStarted.h b/lib/events/ObjectVisitStarted.h index d3754bddc..68fca2d8e 100644 --- a/lib/events/ObjectVisitStarted.h +++ b/lib/events/ObjectVisitStarted.h @@ -14,6 +14,8 @@ #include "../GameConstants.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace events { @@ -36,3 +38,5 @@ private: }; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/events/PlayerGotTurn.cpp b/lib/events/PlayerGotTurn.cpp index ae5453a7a..cbe7f7c2d 100644 --- a/lib/events/PlayerGotTurn.cpp +++ b/lib/events/PlayerGotTurn.cpp @@ -13,6 +13,8 @@ #include +VCMI_LIB_NAMESPACE_BEGIN + namespace events { @@ -59,3 +61,5 @@ void CPlayerGotTurn::setPlayerIndex(int32_t value) } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/events/PlayerGotTurn.h b/lib/events/PlayerGotTurn.h index 8258f25e6..78d61adc5 100644 --- a/lib/events/PlayerGotTurn.h +++ b/lib/events/PlayerGotTurn.h @@ -14,6 +14,8 @@ #include "../GameConstants.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace events { @@ -34,3 +36,5 @@ private: }; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/events/TurnStarted.cpp b/lib/events/TurnStarted.cpp index 015ab9ca0..655c32532 100644 --- a/lib/events/TurnStarted.cpp +++ b/lib/events/TurnStarted.cpp @@ -13,6 +13,8 @@ #include +VCMI_LIB_NAMESPACE_BEGIN + namespace events { @@ -37,3 +39,5 @@ bool CTurnStarted::isEnabled() const } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/events/TurnStarted.h b/lib/events/TurnStarted.h index a7bb3cb98..5a5520a02 100644 --- a/lib/events/TurnStarted.h +++ b/lib/events/TurnStarted.h @@ -12,6 +12,8 @@ #include +VCMI_LIB_NAMESPACE_BEGIN + namespace events { @@ -24,3 +26,5 @@ public: }; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/AdapterLoaders.cpp b/lib/filesystem/AdapterLoaders.cpp index 000f44fdd..4a9e18614 100644 --- a/lib/filesystem/AdapterLoaders.cpp +++ b/lib/filesystem/AdapterLoaders.cpp @@ -13,6 +13,8 @@ #include "../JsonNode.h" #include "Filesystem.h" +VCMI_LIB_NAMESPACE_BEGIN + CMappedFileLoader::CMappedFileLoader(const std::string & mountPoint, const JsonNode &config) { for(auto entry : config.Struct()) @@ -179,3 +181,5 @@ bool CFilesystemList::removeLoader(ISimpleResourceLoader * loader) } return false; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/AdapterLoaders.h b/lib/filesystem/AdapterLoaders.h index 460a54d63..7f5620c88 100644 --- a/lib/filesystem/AdapterLoaders.h +++ b/lib/filesystem/AdapterLoaders.h @@ -12,6 +12,8 @@ #include "ISimpleResourceLoader.h" #include "ResourceID.h" +VCMI_LIB_NAMESPACE_BEGIN + class CInputStream; class JsonNode; @@ -95,3 +97,5 @@ public: */ bool removeLoader(ISimpleResourceLoader * loader); }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/CArchiveLoader.cpp b/lib/filesystem/CArchiveLoader.cpp index 294f4db2d..f53241d46 100644 --- a/lib/filesystem/CArchiveLoader.cpp +++ b/lib/filesystem/CArchiveLoader.cpp @@ -15,6 +15,8 @@ #include "CBinaryReader.h" +VCMI_LIB_NAMESPACE_BEGIN + ArchiveEntry::ArchiveEntry() : offset(0), fullSize(0), compressedSize(0) { @@ -179,3 +181,5 @@ std::unordered_set CArchiveLoader::getFilteredFiles(std::function entries; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/CBinaryReader.cpp b/lib/filesystem/CBinaryReader.cpp index 5a4808003..a3c7fc706 100644 --- a/lib/filesystem/CBinaryReader.cpp +++ b/lib/filesystem/CBinaryReader.cpp @@ -15,6 +15,8 @@ #include "CInputStream.h" #include "../CGeneralTextHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + #if SDL_BYTEORDER == SDL_BIG_ENDIAN template CData readLE(CData data) @@ -117,3 +119,5 @@ std::string CBinaryReader::getEndOfStreamExceptionMsg(long bytesToRead) const return ss.str(); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/CBinaryReader.h b/lib/filesystem/CBinaryReader.h index 166adc0b3..c5a5f2829 100644 --- a/lib/filesystem/CBinaryReader.h +++ b/lib/filesystem/CBinaryReader.h @@ -9,6 +9,8 @@ */ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + class CInputStream; /** @@ -101,3 +103,5 @@ private: /** The underlying base stream */ CInputStream * stream; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/CCompressedStream.cpp b/lib/filesystem/CCompressedStream.cpp index 7fa23529f..520011784 100644 --- a/lib/filesystem/CCompressedStream.cpp +++ b/lib/filesystem/CCompressedStream.cpp @@ -12,6 +12,8 @@ #include +VCMI_LIB_NAMESPACE_BEGIN + static const int inflateBlockSize = 10000; CBufferedStream::CBufferedStream(): @@ -189,3 +191,5 @@ bool CCompressedStream::getNextBlock() reset(); return true; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/CCompressedStream.h b/lib/filesystem/CCompressedStream.h index 8f6191cdb..5c5930e67 100644 --- a/lib/filesystem/CCompressedStream.h +++ b/lib/filesystem/CCompressedStream.h @@ -13,6 +13,8 @@ struct z_stream_s; +VCMI_LIB_NAMESPACE_BEGIN + /// Abstract class that provides buffer for one-directional input streams (e.g. compressed data) /// Used for zip archives support and in .lod deflate compression class CBufferedStream : public CInputStream @@ -135,3 +137,5 @@ private: FINISHED }; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/CFileInputStream.cpp b/lib/filesystem/CFileInputStream.cpp index aa54e353c..eb14e3eda 100644 --- a/lib/filesystem/CFileInputStream.cpp +++ b/lib/filesystem/CFileInputStream.cpp @@ -10,6 +10,8 @@ #include "StdInc.h" #include "CFileInputStream.h" +VCMI_LIB_NAMESPACE_BEGIN + CFileInputStream::CFileInputStream(const boost::filesystem::path & file, si64 start, si64 size) : dataStart{start}, dataSize{size}, @@ -61,3 +63,5 @@ si64 CFileInputStream::getSize() { return dataSize; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/CFileInputStream.h b/lib/filesystem/CFileInputStream.h index e72755feb..4dd499188 100644 --- a/lib/filesystem/CFileInputStream.h +++ b/lib/filesystem/CFileInputStream.h @@ -12,6 +12,8 @@ #include "CInputStream.h" #include "FileStream.h" +VCMI_LIB_NAMESPACE_BEGIN + /** * A class which provides method definitions for reading a file from the filesystem. */ @@ -75,3 +77,5 @@ private: /** Native c++ input file stream object. */ FileStream fileStream; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/CFilesystemLoader.cpp b/lib/filesystem/CFilesystemLoader.cpp index d4c8b7e51..122d22bf8 100644 --- a/lib/filesystem/CFilesystemLoader.cpp +++ b/lib/filesystem/CFilesystemLoader.cpp @@ -13,6 +13,8 @@ #include "CFileInputStream.h" #include "FileStream.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace bfs = boost::filesystem; CFilesystemLoader::CFilesystemLoader(std::string _mountPoint, bfs::path baseDirectory, size_t depth, bool initial): @@ -164,3 +166,5 @@ std::unordered_map CFilesystemLoader::listFiles(const std return fileList; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/CFilesystemLoader.h b/lib/filesystem/CFilesystemLoader.h index e8230b91b..847aaa42c 100644 --- a/lib/filesystem/CFilesystemLoader.h +++ b/lib/filesystem/CFilesystemLoader.h @@ -12,6 +12,8 @@ #include "ISimpleResourceLoader.h" #include "ResourceID.h" +VCMI_LIB_NAMESPACE_BEGIN + class CInputStream; /** @@ -65,3 +67,5 @@ private: */ std::unordered_map listFiles(const std::string &mountPoint, size_t depth, bool initial) const; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/CInputOutputStream.h b/lib/filesystem/CInputOutputStream.h index 8c80c4bac..86d561997 100644 --- a/lib/filesystem/CInputOutputStream.h +++ b/lib/filesystem/CInputOutputStream.h @@ -12,7 +12,11 @@ #include "CInputStream.h" #include "COutputStream.h" +VCMI_LIB_NAMESPACE_BEGIN + class CInputOutputStream: public CInputStream, public COutputStream { }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/CInputStream.h b/lib/filesystem/CInputStream.h index 087534330..e5f2c0839 100644 --- a/lib/filesystem/CInputStream.h +++ b/lib/filesystem/CInputStream.h @@ -11,6 +11,8 @@ #include "CStream.h" +VCMI_LIB_NAMESPACE_BEGIN + /** * Abstract class which provides method definitions for reading from a stream. */ @@ -65,3 +67,5 @@ public: return checksum.checksum(); } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/CMemoryBuffer.cpp b/lib/filesystem/CMemoryBuffer.cpp index 849502e7a..a7fcbcc59 100644 --- a/lib/filesystem/CMemoryBuffer.cpp +++ b/lib/filesystem/CMemoryBuffer.cpp @@ -11,6 +11,8 @@ #include "StdInc.h" #include "CMemoryBuffer.h" +VCMI_LIB_NAMESPACE_BEGIN + ///CMemoryBuffer CMemoryBuffer::CMemoryBuffer(): position(0) @@ -71,3 +73,5 @@ si64 CMemoryBuffer::getSize() } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/CMemoryBuffer.h b/lib/filesystem/CMemoryBuffer.h index e35a78313..add14cf15 100644 --- a/lib/filesystem/CMemoryBuffer.h +++ b/lib/filesystem/CMemoryBuffer.h @@ -11,6 +11,8 @@ #include "CInputOutputStream.h" +VCMI_LIB_NAMESPACE_BEGIN + /** * A class which provides IO memory buffer. */ @@ -84,3 +86,5 @@ private: si64 position; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/CMemoryStream.cpp b/lib/filesystem/CMemoryStream.cpp index 36eaacfaa..3c3ef4ba3 100644 --- a/lib/filesystem/CMemoryStream.cpp +++ b/lib/filesystem/CMemoryStream.cpp @@ -10,6 +10,8 @@ #include "StdInc.h" #include "CMemoryStream.h" +VCMI_LIB_NAMESPACE_BEGIN + CMemoryStream::CMemoryStream(const ui8 * data, si64 size) : data(data), size(size), position(0) { @@ -47,3 +49,5 @@ si64 CMemoryStream::getSize() { return size; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/CMemoryStream.h b/lib/filesystem/CMemoryStream.h index 8af312cc3..f21e5ba14 100644 --- a/lib/filesystem/CMemoryStream.h +++ b/lib/filesystem/CMemoryStream.h @@ -11,6 +11,8 @@ #include "CInputStream.h" +VCMI_LIB_NAMESPACE_BEGIN + /** * A class which provides method definitions for reading from memory. * @deprecated use CMemoryBuffer @@ -75,3 +77,5 @@ private: /** Current reading position of the stream. */ si64 position; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/COutputStream.h b/lib/filesystem/COutputStream.h index 819fa8820..a6e3d008a 100644 --- a/lib/filesystem/COutputStream.h +++ b/lib/filesystem/COutputStream.h @@ -11,6 +11,8 @@ #include "CStream.h" +VCMI_LIB_NAMESPACE_BEGIN + /** * Abstract class which provides method definitions for writing into a stream. */ @@ -31,3 +33,5 @@ public: */ virtual si64 write(const ui8 * data, si64 size) = 0; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/CStream.h b/lib/filesystem/CStream.h index b8a0ca55f..0a1e6c961 100644 --- a/lib/filesystem/CStream.h +++ b/lib/filesystem/CStream.h @@ -9,6 +9,8 @@ */ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + class DLL_LINKAGE CStream : private boost::noncopyable { public: @@ -47,3 +49,5 @@ public: */ virtual si64 getSize() = 0; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/CZipLoader.cpp b/lib/filesystem/CZipLoader.cpp index 35e4cdcd8..30604b952 100644 --- a/lib/filesystem/CZipLoader.cpp +++ b/lib/filesystem/CZipLoader.cpp @@ -13,6 +13,8 @@ #include "../ScopeGuard.h" +VCMI_LIB_NAMESPACE_BEGIN + CZipStream::CZipStream(std::shared_ptr api, const boost::filesystem::path & archive, unz64_file_pos filepos) { zlib_filefunc64_def zlibApi; @@ -216,3 +218,5 @@ bool ZipArchive::extract(boost::filesystem::path from, boost::filesystem::path w } return true; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/CZipLoader.h b/lib/filesystem/CZipLoader.h index 0365c67c2..288362da3 100644 --- a/lib/filesystem/CZipLoader.h +++ b/lib/filesystem/CZipLoader.h @@ -16,6 +16,8 @@ #include "MinizipExtensions.h" +VCMI_LIB_NAMESPACE_BEGIN + class DLL_LINKAGE CZipStream : public CBufferedStream { unzFile file; @@ -70,3 +72,5 @@ namespace ZipArchive ///same as above, but extracts only files mentioned in "what" list bool DLL_LINKAGE extract(boost::filesystem::path from, boost::filesystem::path where, std::vector what); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/CZipSaver.cpp b/lib/filesystem/CZipSaver.cpp index 28647cb2b..87c3b848d 100644 --- a/lib/filesystem/CZipSaver.cpp +++ b/lib/filesystem/CZipSaver.cpp @@ -11,6 +11,8 @@ #include "StdInc.h" #include "CZipSaver.h" +VCMI_LIB_NAMESPACE_BEGIN + ///CZipOutputStream CZipOutputStream::CZipOutputStream(CZipSaver * owner_, zipFile archive, const std::string & archiveFilename): handle(archive), @@ -118,3 +120,5 @@ std::unique_ptr CZipSaver::addFile(const std::string & archiveFil return stream; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/CZipSaver.h b/lib/filesystem/CZipSaver.h index 88993f5d4..d9214468d 100644 --- a/lib/filesystem/CZipSaver.h +++ b/lib/filesystem/CZipSaver.h @@ -13,6 +13,8 @@ #include "MinizipExtensions.h" +VCMI_LIB_NAMESPACE_BEGIN + class CZipSaver; class DLL_LINKAGE CZipOutputStream: public COutputStream @@ -54,3 +56,5 @@ private: COutputStream * activeStream; friend class CZipOutputStream; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/FileInfo.cpp b/lib/filesystem/FileInfo.cpp index 89498a3a2..332fb71fa 100644 --- a/lib/filesystem/FileInfo.cpp +++ b/lib/filesystem/FileInfo.cpp @@ -11,6 +11,8 @@ #include "FileInfo.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace FileInfo { @@ -63,3 +65,5 @@ boost::string_ref GetPathStem(boost::string_ref path) } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/FileInfo.h b/lib/filesystem/FileInfo.h index 484f17ecd..a8cd7963c 100644 --- a/lib/filesystem/FileInfo.h +++ b/lib/filesystem/FileInfo.h @@ -11,6 +11,8 @@ #include +VCMI_LIB_NAMESPACE_BEGIN + namespace FileInfo { @@ -50,3 +52,5 @@ boost::string_ref DLL_LINKAGE GetParentPath(boost::string_ref path); boost::string_ref DLL_LINKAGE GetPathStem(boost::string_ref path); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/FileStream.cpp b/lib/filesystem/FileStream.cpp index d3d4796f8..a85fcc913 100644 --- a/lib/filesystem/FileStream.cpp +++ b/lib/filesystem/FileStream.cpp @@ -218,6 +218,10 @@ void fill_fopen64_filefunc(zlib_filefunc64_def* pzlib_filefunc_def) } +template struct boost::iostreams::stream; + +VCMI_LIB_NAMESPACE_BEGIN + zlib_filefunc64_def* FileStream::GetMinizipFilefunc() { static zlib_filefunc64_def MinizipFilefunc; @@ -231,8 +235,6 @@ zlib_filefunc64_def* FileStream::GetMinizipFilefunc() return &MinizipFilefunc; } -template struct boost::iostreams::stream; - /*static*/ bool FileStream::CreateFile(const boost::filesystem::path& filename) { @@ -322,3 +324,5 @@ std::streamoff FileBuf::seek(std::streamoff off, std::ios_base::seekdir way) return static_cast(std::ftell(GETFILE)); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/FileStream.h b/lib/filesystem/FileStream.h index 57b9b420d..145a2e067 100644 --- a/lib/filesystem/FileStream.h +++ b/lib/filesystem/FileStream.h @@ -12,6 +12,8 @@ #include #include +VCMI_LIB_NAMESPACE_BEGIN + class DLL_LINKAGE FileBuf { public: @@ -32,13 +34,17 @@ private: void* filePtr; }; +VCMI_LIB_NAMESPACE_END + struct zlib_filefunc64_def_s; typedef zlib_filefunc64_def_s zlib_filefunc64_def; #ifdef VCMI_DLL -extern template struct DLL_LINKAGE boost::iostreams::stream; +extern template struct DLL_LINKAGE boost::iostreams::stream; #endif +VCMI_LIB_NAMESPACE_BEGIN + class DLL_LINKAGE FileStream : public boost::iostreams::stream { public: @@ -50,3 +56,5 @@ public: static zlib_filefunc64_def* GetMinizipFilefunc(); }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/Filesystem.cpp b/lib/filesystem/Filesystem.cpp index d478d136e..5d1c60620 100644 --- a/lib/filesystem/Filesystem.cpp +++ b/lib/filesystem/Filesystem.cpp @@ -21,6 +21,8 @@ #include "../VCMIDirs.h" #include "../CStopWatch.h" +VCMI_LIB_NAMESPACE_BEGIN + std::map CResourceHandler::knownLoaders = std::map(); CResourceHandler CResourceHandler::globalResourceHandler; @@ -170,6 +172,10 @@ void CResourceHandler::initialize() // |-saves // |-config + // when built as single process, server can be started multiple times + if (globalResourceHandler.rootLoader) + return; + globalResourceHandler.rootLoader = vstd::make_unique(); knownLoaders["root"] = globalResourceHandler.rootLoader.get(); knownLoaders["saves"] = new CFilesystemLoader("SAVES/", VCMIDirs::get().userSavePath()); @@ -246,3 +252,5 @@ ISimpleResourceLoader * CResourceHandler::createFileSystem(const std::string & p generator.loadConfig(fsConfig); return generator.getFilesystem(); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/Filesystem.h b/lib/filesystem/Filesystem.h index 8839a0e9c..1ea993b4d 100644 --- a/lib/filesystem/Filesystem.h +++ b/lib/filesystem/Filesystem.h @@ -13,6 +13,8 @@ #include "ISimpleResourceLoader.h" #include "ResourceID.h" +VCMI_LIB_NAMESPACE_BEGIN + class CFilesystemList; class JsonNode; @@ -113,3 +115,5 @@ private: CResourceHandler() {}; std::unique_ptr rootLoader; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/ISimpleResourceLoader.h b/lib/filesystem/ISimpleResourceLoader.h index 05371a22b..833000df1 100644 --- a/lib/filesystem/ISimpleResourceLoader.h +++ b/lib/filesystem/ISimpleResourceLoader.h @@ -9,6 +9,8 @@ */ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + class CInputStream; class ResourceID; @@ -105,3 +107,5 @@ public: return std::vector(); } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/MinizipExtensions.cpp b/lib/filesystem/MinizipExtensions.cpp index 23edf26d4..3ddf40b09 100644 --- a/lib/filesystem/MinizipExtensions.cpp +++ b/lib/filesystem/MinizipExtensions.cpp @@ -13,6 +13,8 @@ #include "CMemoryBuffer.h" #include "FileStream.h" +VCMI_LIB_NAMESPACE_BEGIN + template inline uLong streamRead(voidpf opaque, voidpf stream, void * buf, uLong size) { assert(opaque != nullptr); @@ -252,3 +254,5 @@ int ZCALLBACK CProxyROIOApi::errorFileProxy(voidpf opaque, voidpf stream) { return 0; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/MinizipExtensions.h b/lib/filesystem/MinizipExtensions.h index 43c739440..d4029ed83 100644 --- a/lib/filesystem/MinizipExtensions.h +++ b/lib/filesystem/MinizipExtensions.h @@ -18,6 +18,9 @@ #include "../minizip/zip.h" #include "../minizip/ioapi.h" #endif + +VCMI_LIB_NAMESPACE_BEGIN + class CInputStream; class CInputOutputStream; class CMemoryBuffer; @@ -85,3 +88,5 @@ private: static int ZCALLBACK errorFileProxy(voidpf opaque, voidpf stream); }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/ResourceID.cpp b/lib/filesystem/ResourceID.cpp index 7b70d960c..63f61afca 100644 --- a/lib/filesystem/ResourceID.cpp +++ b/lib/filesystem/ResourceID.cpp @@ -11,6 +11,8 @@ #include "ResourceID.h" #include "FileInfo.h" +VCMI_LIB_NAMESPACE_BEGIN + // trivial to_upper that completely ignores localization and only work with ASCII // Technically not a problem since // 1) Right now VCMI does not supports unicode in filenames on Win @@ -205,3 +207,5 @@ std::string EResTypeHelper::getEResTypeAsString(EResType::Type type) return iter->second; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/filesystem/ResourceID.h b/lib/filesystem/ResourceID.h index 4310b5911..f53e40e69 100644 --- a/lib/filesystem/ResourceID.h +++ b/lib/filesystem/ResourceID.h @@ -9,6 +9,8 @@ */ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + /** * Specifies the resource type. @@ -114,19 +116,6 @@ private: std::string name; }; -namespace std -{ - template <> struct hash - { - size_t operator()(const ResourceID & resourceIdent) const - { - std::hash intHasher; - std::hash stringHasher; - return stringHasher(resourceIdent.getName()) ^ intHasher(static_cast(resourceIdent.getType())); - } - }; -} - /** * A helper class which provides a functionality to convert extension strings to EResTypes. */ @@ -149,3 +138,19 @@ public: */ static std::string getEResTypeAsString(EResType::Type type); }; + +VCMI_LIB_NAMESPACE_END + + +namespace std +{ +template <> struct hash +{ + size_t operator()(const VCMI_LIB_WRAP_NAMESPACE(ResourceID) & resourceIdent) const + { + std::hash intHasher; + std::hash stringHasher; + return stringHasher(resourceIdent.getName()) ^ intHasher(static_cast(resourceIdent.getType())); + } +}; +} diff --git a/lib/int3.h b/lib/int3.h index d8861e314..b77e508b4 100644 --- a/lib/int3.h +++ b/lib/int3.h @@ -9,6 +9,8 @@ */ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + /// Class which consists of three integer values. Represents position on adventure map. class int3 { @@ -216,3 +218,5 @@ int3 findClosestTile (Container & container, int3 dest) } return result; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/logging/CBasicLogConfigurator.cpp b/lib/logging/CBasicLogConfigurator.cpp index 94e37b17d..727386bf0 100644 --- a/lib/logging/CBasicLogConfigurator.cpp +++ b/lib/logging/CBasicLogConfigurator.cpp @@ -13,6 +13,8 @@ #include "../CConfigHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + CBasicLogConfigurator::CBasicLogConfigurator(boost::filesystem::path filePath, CConsoleHandler * const console) : filePath(std::move(filePath)), console(console), appendToLogFile(false) {} @@ -147,3 +149,5 @@ void CBasicLogConfigurator::deconfigure() if(l != nullptr) l->clearTargets(); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/logging/CBasicLogConfigurator.h b/lib/logging/CBasicLogConfigurator.h index df0bfe587..ba96f3d3f 100644 --- a/lib/logging/CBasicLogConfigurator.h +++ b/lib/logging/CBasicLogConfigurator.h @@ -12,6 +12,8 @@ #include "../CConsoleHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + class CConsoleHandler; class JsonNode; @@ -45,3 +47,5 @@ private: CConsoleHandler * console; bool appendToLogFile; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/logging/CLogger.cpp b/lib/logging/CLogger.cpp index fc6e57cfe..2fa3a933c 100644 --- a/lib/logging/CLogger.cpp +++ b/lib/logging/CLogger.cpp @@ -30,8 +30,15 @@ namespace ELogLevel return ANDROID_LOG_UNKNOWN; } } +#elif defined(VCMI_IOS) +#import "iOS_utils.h" +extern "C" { +#include +} #endif +VCMI_LIB_NAMESPACE_BEGIN + namespace vstd { @@ -353,6 +360,41 @@ void CLogConsoleTarget::write(const LogRecord & record) #ifdef VCMI_ANDROID __android_log_write(ELogLevel::toAndroid(record.level), ("VCMI-" + record.domain.getName()).c_str(), message.c_str()); +#elif defined(VCMI_IOS) + os_log_type_t type; + switch (record.level) + { + case ELogLevel::TRACE: + type = OS_LOG_TYPE_DEBUG; + break; + case ELogLevel::DEBUG: + type = OS_LOG_TYPE_DEFAULT; + break; + case ELogLevel::INFO: + type = OS_LOG_TYPE_INFO; + break; + case ELogLevel::WARN: + type = OS_LOG_TYPE_ERROR; + break; + case ELogLevel::ERROR: + type = OS_LOG_TYPE_FAULT; + break; + default: + return; + } + + os_log_t currentLog; + static std::unordered_map logs; + const auto& domainName = record.domain.getName(); + auto logIt = logs.find(domainName); + if (logIt != logs.end()) + currentLog = logIt->second; + else + { + currentLog = os_log_create(iOS_utils::bundleIdentifier(), domainName.c_str()); + logs.insert({domainName, currentLog}); + } + os_log_with_type(currentLog, type, "%{public}s", message.c_str()); #else const bool printToStdErr = record.level >= ELogLevel::WARN; @@ -407,3 +449,5 @@ CLogFileTarget::~CLogFileTarget() { file.close(); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/logging/CLogger.h b/lib/logging/CLogger.h index d2a15fb39..4f5ee2773 100644 --- a/lib/logging/CLogger.h +++ b/lib/logging/CLogger.h @@ -12,6 +12,8 @@ #include "../CConsoleHandler.h" #include "../filesystem/FileStream.h" +VCMI_LIB_NAMESPACE_BEGIN + class CLogger; struct LogRecord; class ILogTarget; @@ -225,3 +227,5 @@ private: CLogFormatter formatter; mutable boost::mutex mx; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/CArmedInstance.cpp b/lib/mapObjects/CArmedInstance.cpp index 5d23e8ef4..e98b4b719 100644 --- a/lib/mapObjects/CArmedInstance.cpp +++ b/lib/mapObjects/CArmedInstance.cpp @@ -17,6 +17,8 @@ #include "../CGameState.h" #include "../CPlayerState.h" +VCMI_LIB_NAMESPACE_BEGIN + void CArmedInstance::randomizeArmy(int type) { for (auto & elem : stacks) @@ -152,3 +154,5 @@ CBonusSystemNode * CArmedInstance::whatShouldBeAttached() { return this; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/CArmedInstance.h b/lib/mapObjects/CArmedInstance.h index a17a3998e..559e94e51 100644 --- a/lib/mapObjects/CArmedInstance.h +++ b/lib/mapObjects/CArmedInstance.h @@ -1,4 +1,4 @@ -/* +/* * CArmedInstance.h, part of VCMI engine * * Authors: listed in file AUTHORS in main folder @@ -12,6 +12,8 @@ #include "CObjectHandler.h" #include "../CCreatureSet.h" +VCMI_LIB_NAMESPACE_BEGIN + class BattleInfo; class CGameState; @@ -50,3 +52,5 @@ public: h & static_cast(*this); } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/CBank.cpp b/lib/mapObjects/CBank.cpp index 69e4d6459..7cbe050b1 100644 --- a/lib/mapObjects/CBank.cpp +++ b/lib/mapObjects/CBank.cpp @@ -1,4 +1,4 @@ -/* +/* * CBank.cpp, part of VCMI engine * * Authors: listed in file AUTHORS in main folder @@ -21,6 +21,8 @@ #include "../IGameCallback.h" #include "../CGameState.h" +VCMI_LIB_NAMESPACE_BEGIN + ///helpers static std::string & visitedTxt(const bool visited) { @@ -351,3 +353,5 @@ void CBank::blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) cons doVisit(hero); } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/CBank.h b/lib/mapObjects/CBank.h index c274fe653..22819005a 100644 --- a/lib/mapObjects/CBank.h +++ b/lib/mapObjects/CBank.h @@ -1,4 +1,4 @@ -/* +/* * CBank.h, part of VCMI engine * * Authors: listed in file AUTHORS in main folder @@ -12,6 +12,8 @@ #include "CObjectHandler.h" #include "CArmedInstance.h" +VCMI_LIB_NAMESPACE_BEGIN + struct BankConfig; class CBankInstanceConstructor; @@ -48,3 +50,5 @@ public: friend class CBankInstanceConstructor; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/CGHeroInstance.cpp b/lib/mapObjects/CGHeroInstance.cpp index 903de00dd..743af6b32 100644 --- a/lib/mapObjects/CGHeroInstance.cpp +++ b/lib/mapObjects/CGHeroInstance.cpp @@ -32,6 +32,8 @@ #include "../StringConstants.h" #include "../battle/Unit.h" +VCMI_LIB_NAMESPACE_BEGIN + ///helpers static void showInfoDialog(const PlayerColor playerID, const ui32 txtID, const ui16 soundID = 0) @@ -1642,3 +1644,5 @@ bool CGHeroInstance::isMissionCritical() const } return false; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/CGHeroInstance.h b/lib/mapObjects/CGHeroInstance.h index ea88e41b9..61a50aed0 100644 --- a/lib/mapObjects/CGHeroInstance.h +++ b/lib/mapObjects/CGHeroInstance.h @@ -17,6 +17,8 @@ #include "../CArtHandler.h" // For CArtifactSet #include "../CRandomGenerator.h" +VCMI_LIB_NAMESPACE_BEGIN + class CHero; class CGBoat; class CGTownInstance; @@ -315,3 +317,5 @@ public: BONUS_TREE_DESERIALIZATION_FIX } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/CGMarket.cpp b/lib/mapObjects/CGMarket.cpp index 81f7150c9..95687a963 100644 --- a/lib/mapObjects/CGMarket.cpp +++ b/lib/mapObjects/CGMarket.cpp @@ -20,6 +20,8 @@ #include "../CModHandler.h" #include "../CSkillHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + ///helpers static void openWindow(const OpenWindow::EWindow type, const int id1, const int id2 = -1) { @@ -339,3 +341,5 @@ void CGUniversity::onHeroVisit(const CGHeroInstance * h) const { openWindow(OpenWindow::UNIVERSITY_WINDOW,id.getNum(),h->id.getNum()); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/CGMarket.h b/lib/mapObjects/CGMarket.h index bdf7cba71..4697179d8 100644 --- a/lib/mapObjects/CGMarket.h +++ b/lib/mapObjects/CGMarket.h @@ -1,4 +1,4 @@ -/* +/* * CGMarket.h, part of VCMI engine * * Authors: listed in file AUTHORS in main folder @@ -11,6 +11,8 @@ #include "CObjectHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + class DLL_LINKAGE IMarket { public: @@ -85,3 +87,5 @@ public: h & skills; } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/CGPandoraBox.cpp b/lib/mapObjects/CGPandoraBox.cpp index c07de1358..e04dfa377 100644 --- a/lib/mapObjects/CGPandoraBox.cpp +++ b/lib/mapObjects/CGPandoraBox.cpp @@ -1,4 +1,4 @@ -/* +/* * CGPandoraBox.cpp, part of VCMI engine * * Authors: listed in file AUTHORS in main folder @@ -23,6 +23,8 @@ #include "../StringConstants.h" #include "../serializer/JsonSerializeFormat.h" +VCMI_LIB_NAMESPACE_BEGIN + ///helpers static void showInfoDialog(const PlayerColor playerID, const ui32 txtID, const ui16 soundID) { @@ -530,3 +532,5 @@ void CGEvent::serializeJsonOptions(JsonSerializeFormat & handler) handler.serializeIdArray("availableFor", availableFor, GameConstants::ALL_PLAYERS, decodePlayer, encodePlayer); } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/CGPandoraBox.h b/lib/mapObjects/CGPandoraBox.h index 3af409e0c..d525bf279 100644 --- a/lib/mapObjects/CGPandoraBox.h +++ b/lib/mapObjects/CGPandoraBox.h @@ -1,4 +1,4 @@ -/* +/* * CGPandoraBox.h, part of VCMI engine * * Authors: listed in file AUTHORS in main folder @@ -13,6 +13,8 @@ #include "CArmedInstance.h" #include "../ResourceSet.h" +VCMI_LIB_NAMESPACE_BEGIN + struct InfoWindow; class DLL_LINKAGE CGPandoraBox : public CArmedInstance @@ -93,3 +95,5 @@ private: void activated(const CGHeroInstance * h) const; void afterSuccessfulVisit() const override; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/CGTownInstance.cpp b/lib/mapObjects/CGTownInstance.cpp index 42cd5c2d2..a9d7dedbb 100644 --- a/lib/mapObjects/CGTownInstance.cpp +++ b/lib/mapObjects/CGTownInstance.cpp @@ -23,6 +23,8 @@ #include "../serializer/JsonSerializeFormat.h" #include "../HeroBonus.h" +VCMI_LIB_NAMESPACE_BEGIN + std::vector CGTownInstance::merchantArtifacts; std::vector CGTownInstance::universitySkills; @@ -1867,3 +1869,5 @@ const std::string CGTownBuilding::getCustomBonusGreeting(const Bonus & bonus) co std::string greeting = fmt.str(); return greeting; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/CGTownInstance.h b/lib/mapObjects/CGTownInstance.h index fea47b1a4..0d261f2af 100644 --- a/lib/mapObjects/CGTownInstance.h +++ b/lib/mapObjects/CGTownInstance.h @@ -15,6 +15,8 @@ #include "../CTownHandler.h" // For CTown +VCMI_LIB_NAMESPACE_BEGIN + class CCastleEvent; class CGTownInstance; class CGDwelling; @@ -365,3 +367,5 @@ private: void initOverriddenBids(); void addTownBonuses(); }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/CObjectClassesHandler.cpp b/lib/mapObjects/CObjectClassesHandler.cpp index 4a3e8ad12..03ed19e24 100644 --- a/lib/mapObjects/CObjectClassesHandler.cpp +++ b/lib/mapObjects/CObjectClassesHandler.cpp @@ -24,6 +24,8 @@ #include "CommonConstructors.h" #include "MapObjects.h" +VCMI_LIB_NAMESPACE_BEGIN + // FIXME: move into inheritNode? static void inheritNodeWithMeta(JsonNode & descendant, const JsonNode & base) { @@ -627,3 +629,5 @@ bool AObjectTypeHandler::isStaticObject() void AObjectTypeHandler::afterLoadFinalization() { } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/CObjectClassesHandler.h b/lib/mapObjects/CObjectClassesHandler.h index cff16a715..af7099b6a 100644 --- a/lib/mapObjects/CObjectClassesHandler.h +++ b/lib/mapObjects/CObjectClassesHandler.h @@ -17,6 +17,8 @@ #include "../JsonNode.h" #include "Terrain.h" +VCMI_LIB_NAMESPACE_BEGIN + class JsonNode; class CRandomGenerator; @@ -320,3 +322,5 @@ public: h & objects; } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/CObjectHandler.cpp b/lib/mapObjects/CObjectHandler.cpp index 35904fb65..0dc476d61 100644 --- a/lib/mapObjects/CObjectHandler.cpp +++ b/lib/mapObjects/CObjectHandler.cpp @@ -26,6 +26,8 @@ #include "../serializer/JsonSerializeFormat.h" +VCMI_LIB_NAMESPACE_BEGIN + IGameCallback * IObjectInterface::cb = nullptr; ///helpers @@ -524,3 +526,5 @@ const IShipyard * IShipyard::castFrom( const CGObjectInstance *obj ) { return castFrom(const_cast(obj)); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/CObjectHandler.h b/lib/mapObjects/CObjectHandler.h index 1afa229a6..387020f72 100644 --- a/lib/mapObjects/CObjectHandler.h +++ b/lib/mapObjects/CObjectHandler.h @@ -15,6 +15,8 @@ #include "../int3.h" #include "../HeroBonus.h" +VCMI_LIB_NAMESPACE_BEGIN + class CGHeroInstance; class IGameCallback; class CGObjectInstance; @@ -255,3 +257,5 @@ public: h & resVals; } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/CQuest.cpp b/lib/mapObjects/CQuest.cpp index 53e0dd43d..f22327ed7 100644 --- a/lib/mapObjects/CQuest.cpp +++ b/lib/mapObjects/CQuest.cpp @@ -28,6 +28,8 @@ #include "../CSkillHandler.h" #include "../mapping/CMap.h" +VCMI_LIB_NAMESPACE_BEGIN + std::map > CGKeys::playerKeyMap; @@ -1172,3 +1174,5 @@ bool CGBorderGate::passableFor(PlayerColor color) const { return wasMyColorVisited(color); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/CQuest.h b/lib/mapObjects/CQuest.h index 3fff59254..a2cb8b75f 100644 --- a/lib/mapObjects/CQuest.h +++ b/lib/mapObjects/CQuest.h @@ -15,6 +15,8 @@ #include "../CCreatureSet.h" #include "../NetPacksBase.h" +VCMI_LIB_NAMESPACE_BEGIN + class CGCreature; class DLL_LINKAGE CQuest @@ -239,3 +241,5 @@ public: h & static_cast(*this); //need to serialize or object will be empty } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/CRewardableConstructor.cpp b/lib/mapObjects/CRewardableConstructor.cpp index dbe59e68e..4a6442eb7 100644 --- a/lib/mapObjects/CRewardableConstructor.cpp +++ b/lib/mapObjects/CRewardableConstructor.cpp @@ -16,6 +16,8 @@ #include "JsonRandom.h" #include "../IGameCallback.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace { MetaString loadMessage(const JsonNode & value) { @@ -220,3 +222,5 @@ std::unique_ptr CRewardableConstructor::getObjectInfo(std::shared_p { return std::unique_ptr(new CRandomRewardObjectInfo(objectInfo)); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/CRewardableConstructor.h b/lib/mapObjects/CRewardableConstructor.h index 4157ae7cb..7dee06f27 100644 --- a/lib/mapObjects/CRewardableConstructor.h +++ b/lib/mapObjects/CRewardableConstructor.h @@ -14,6 +14,8 @@ #include "../JsonNode.h" +VCMI_LIB_NAMESPACE_BEGIN + class DLL_LINKAGE CRandomRewardObjectInfo : public IObjectInfo { JsonNode parameters; @@ -55,3 +57,5 @@ public: std::unique_ptr getObjectInfo(std::shared_ptr tmpl) const override; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/CRewardableObject.cpp b/lib/mapObjects/CRewardableObject.cpp index 34b57072d..8e78fc8e3 100644 --- a/lib/mapObjects/CRewardableObject.cpp +++ b/lib/mapObjects/CRewardableObject.cpp @@ -20,6 +20,8 @@ #include "CObjectClassesHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + bool CRewardLimiter::heroAllowed(const CGHeroInstance * hero) const { if(dayOfWeek != 0) @@ -1163,3 +1165,5 @@ std::vector CGMagicSpring::getAvailableRewards(const CGHeroInstance * hero // hero is either not on visitable tile (should not happen) or tile is already used return std::vector(); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/CRewardableObject.h b/lib/mapObjects/CRewardableObject.h index a259153ea..60ab5e386 100644 --- a/lib/mapObjects/CRewardableObject.h +++ b/lib/mapObjects/CRewardableObject.h @@ -15,6 +15,8 @@ #include "../NetPacksBase.h" #include "../ResourceSet.h" +VCMI_LIB_NAMESPACE_BEGIN + class CRandomRewardObjectInfo; /// Limiters of rewards. Rewards will be granted to hero only if he satisfies requirements @@ -403,3 +405,5 @@ public: // class DLL_LINKAGE CGSignBottle : public CGObjectInstance //signs and ocean bottles // class DLL_LINKAGE CGWitchHut : public CPlayersVisited // class DLL_LINKAGE CGScholar : public CGObjectInstance + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/CommonConstructors.cpp b/lib/mapObjects/CommonConstructors.cpp index 3b870847a..a7d39bb0d 100644 --- a/lib/mapObjects/CommonConstructors.cpp +++ b/lib/mapObjects/CommonConstructors.cpp @@ -20,6 +20,8 @@ #include "../CModHandler.h" #include "../IGameCallback.h" +VCMI_LIB_NAMESPACE_BEGIN + CObstacleConstructor::CObstacleConstructor() { } @@ -498,3 +500,5 @@ std::unique_ptr CBankInstanceConstructor::getObjectInfo(std::shared { return std::unique_ptr(new CBankInfo(levels)); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/CommonConstructors.h b/lib/mapObjects/CommonConstructors.h index 605ad429c..98b3e623b 100644 --- a/lib/mapObjects/CommonConstructors.h +++ b/lib/mapObjects/CommonConstructors.h @@ -13,6 +13,8 @@ #include "../CTownHandler.h" // for building ID-based filters #include "MapObjects.h" +VCMI_LIB_NAMESPACE_BEGIN + class CGObjectInstance; class CGTownInstance; class CGHeroInstance; @@ -233,3 +235,5 @@ public: h & static_cast&>(*this); } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/JsonRandom.cpp b/lib/mapObjects/JsonRandom.cpp index aecba04a9..b2d10559d 100644 --- a/lib/mapObjects/JsonRandom.cpp +++ b/lib/mapObjects/JsonRandom.cpp @@ -21,6 +21,8 @@ #include "../CCreatureSet.h" #include "../spells/CSpellHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace JsonRandom { si32 loadValue(const JsonNode & value, CRandomGenerator & rng, si32 defaultValue) @@ -225,3 +227,5 @@ namespace JsonRandom } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/JsonRandom.h b/lib/mapObjects/JsonRandom.h index 8eaf085fb..0ed636aae 100644 --- a/lib/mapObjects/JsonRandom.h +++ b/lib/mapObjects/JsonRandom.h @@ -12,6 +12,8 @@ #include "../GameConstants.h" #include "../ResourceSet.h" +VCMI_LIB_NAMESPACE_BEGIN + class JsonNode; typedef std::vector JsonVector; class CRandomGenerator; @@ -47,3 +49,5 @@ namespace JsonRandom DLL_LINKAGE std::vector loadBonuses(const JsonNode & value); //DLL_LINKAGE std::vector loadComponents(const JsonNode & value); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/MiscObjects.cpp b/lib/mapObjects/MiscObjects.cpp index 741ad4ba9..cd9b5a620 100644 --- a/lib/mapObjects/MiscObjects.cpp +++ b/lib/mapObjects/MiscObjects.cpp @@ -26,6 +26,8 @@ #include "../CPlayerState.h" #include "../serializer/JsonSerializeFormat.h" +VCMI_LIB_NAMESPACE_BEGIN + std::map > CGMagi::eyelist; ui8 CGObelisk::obeliskCount = 0; //how many obelisks are on map std::map CGObelisk::visited; //map: team_id => how many obelisks has been visited @@ -2207,4 +2209,6 @@ void CGLighthouse::giveBonusTo(PlayerColor player, bool onInit) const void CGLighthouse::serializeJsonOptions(JsonSerializeFormat& handler) { serializeJsonOwner(handler); -} \ No newline at end of file +} + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/MiscObjects.h b/lib/mapObjects/MiscObjects.h index 8949debeb..9eeeee41e 100644 --- a/lib/mapObjects/MiscObjects.h +++ b/lib/mapObjects/MiscObjects.h @@ -13,6 +13,8 @@ #include "CArmedInstance.h" #include "../ResourceSet.h" +VCMI_LIB_NAMESPACE_BEGIN + class CMap; /// Legacy class, use CRewardableObject instead @@ -541,3 +543,5 @@ public: return true; } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/ObjectTemplate.cpp b/lib/mapObjects/ObjectTemplate.cpp index 40f9693df..3eb23cd86 100644 --- a/lib/mapObjects/ObjectTemplate.cpp +++ b/lib/mapObjects/ObjectTemplate.cpp @@ -23,6 +23,8 @@ #include "CRewardableConstructor.h" +VCMI_LIB_NAMESPACE_BEGIN + static bool isOnVisitableFromTopList(int identifier, int type) { if(type == 2 || type == 3 || type == 4 || type == 5) //creature, hero, artifact, resource @@ -572,3 +574,4 @@ void ObjectTemplate::recalculate() calculateVisitableOffset(); } +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/ObjectTemplate.h b/lib/mapObjects/ObjectTemplate.h index e10f1efad..24a219ac0 100644 --- a/lib/mapObjects/ObjectTemplate.h +++ b/lib/mapObjects/ObjectTemplate.h @@ -12,6 +12,8 @@ #include "../GameConstants.h" #include "../int3.h" +VCMI_LIB_NAMESPACE_BEGIN + class CBinaryReader; class CLegacyConfigParser; class JsonNode; @@ -153,3 +155,5 @@ public: } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapping/CCampaignHandler.cpp b/lib/mapping/CCampaignHandler.cpp index 71c130383..60918e0b3 100644 --- a/lib/mapping/CCampaignHandler.cpp +++ b/lib/mapping/CCampaignHandler.cpp @@ -30,6 +30,8 @@ #include "serializer/JsonDeserializer.h" #include "serializer/JsonSerializer.h" +VCMI_LIB_NAMESPACE_BEGIN + CCampaignHeader::CCampaignHeader() : version(0), mapVersion(0), difficultyChoosenByPlayer(0), music(0), filename(), loadFromLod(0) { @@ -562,3 +564,5 @@ std::string CCampaignHandler::prologVoiceName(ui8 index) + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapping/CCampaignHandler.h b/lib/mapping/CCampaignHandler.h index 1e3e923c1..ebd11d459 100644 --- a/lib/mapping/CCampaignHandler.h +++ b/lib/mapping/CCampaignHandler.h @@ -11,6 +11,8 @@ #include "../../lib/GameConstants.h" +VCMI_LIB_NAMESPACE_BEGIN + struct StartInfo; class CGHeroInstance; class CBinaryReader; @@ -242,3 +244,5 @@ public: static std::unique_ptr getCampaign(const std::string & name); //name - name of appropriate file }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapping/CDrawRoadsOperation.cpp b/lib/mapping/CDrawRoadsOperation.cpp index d0dd1fff9..c7bd1d6e6 100644 --- a/lib/mapping/CDrawRoadsOperation.cpp +++ b/lib/mapping/CDrawRoadsOperation.cpp @@ -12,6 +12,8 @@ #include "CDrawRoadsOperation.h" #include "CMap.h" +VCMI_LIB_NAMESPACE_BEGIN + const std::vector CDrawLinesOperation::patterns = { //single tile. fall-back pattern @@ -389,3 +391,5 @@ void CDrawRiversOperation::updateTile(TerrainTile & tile, const LinePattern & pa tile.riverDir = gen->nextInt(mapping.first, mapping.second); tile.extTileFlags = (tile.extTileFlags & 0b00111111) | (flip << 2); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapping/CDrawRoadsOperation.h b/lib/mapping/CDrawRoadsOperation.h index b283c5dc8..67c9bb0ff 100644 --- a/lib/mapping/CDrawRoadsOperation.h +++ b/lib/mapping/CDrawRoadsOperation.h @@ -13,6 +13,8 @@ #include "../CRandomGenerator.h" #include "CMapEditManager.h" +VCMI_LIB_NAMESPACE_BEGIN + struct TerrainTile; class CDrawLinesOperation : public CMapOperation @@ -91,3 +93,5 @@ protected: private: std::string riverType; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapping/CMap.cpp b/lib/mapping/CMap.cpp index 742e709a8..fa0037f48 100644 --- a/lib/mapping/CMap.cpp +++ b/lib/mapping/CMap.cpp @@ -23,6 +23,8 @@ #include "CMapEditManager.h" #include "../serializer/JsonSerializeFormat.h" +VCMI_LIB_NAMESPACE_BEGIN + SHeroName::SHeroName() : heroId(-1) { @@ -713,3 +715,5 @@ void CMap::resetStaticData() CGObelisk::reset(); CGTownInstance::reset(); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapping/CMap.h b/lib/mapping/CMap.h index 1c1ae34db..e32d47ab6 100644 --- a/lib/mapping/CMap.h +++ b/lib/mapping/CMap.h @@ -20,6 +20,8 @@ #include "../LogicalExpression.h" #include "CMapDefines.h" +VCMI_LIB_NAMESPACE_BEGIN + class CArtifactInstance; class CGObjectInstance; class CGHeroInstance; @@ -496,3 +498,5 @@ public: h & instanceNames; } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapping/CMapDefines.h b/lib/mapping/CMapDefines.h index dbaf97f30..9e55436a1 100644 --- a/lib/mapping/CMapDefines.h +++ b/lib/mapping/CMapDefines.h @@ -10,6 +10,8 @@ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + /// The map event is an event which e.g. gives or takes resources of a specific /// amount to/from players and can appear regularly or once a time. class DLL_LINKAGE CMapEvent @@ -111,3 +113,5 @@ struct DLL_LINKAGE TerrainTile h & blockingObjects; } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapping/CMapEditManager.cpp b/lib/mapping/CMapEditManager.cpp index 2f8d44af9..ba8ab5d59 100644 --- a/lib/mapping/CMapEditManager.cpp +++ b/lib/mapping/CMapEditManager.cpp @@ -18,6 +18,8 @@ #include "../mapping/CMap.h" #include "CMapOperation.h" +VCMI_LIB_NAMESPACE_BEGIN + CMapUndoManager::CMapUndoManager() : undoRedoLimit(100000), //not sure if we ever need to bother about undo limit undoCallback([](bool, bool) {}) @@ -199,3 +201,5 @@ CMapUndoManager & CMapEditManager::getUndoManager() { return undoManager; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapping/CMapEditManager.h b/lib/mapping/CMapEditManager.h index 7fe216d16..7ce123e8a 100644 --- a/lib/mapping/CMapEditManager.h +++ b/lib/mapping/CMapEditManager.h @@ -14,6 +14,8 @@ #include "CMapOperation.h" #include "Terrain.h" +VCMI_LIB_NAMESPACE_BEGIN + class CGObjectInstance; class CTerrainViewPatternConfig; struct TerrainViewPattern; @@ -98,3 +100,5 @@ private: CTerrainSelection terrainSel; CObjectSelection objectSel; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapping/CMapInfo.cpp b/lib/mapping/CMapInfo.cpp index 25b6a78b8..3756ae580 100644 --- a/lib/mapping/CMapInfo.cpp +++ b/lib/mapping/CMapInfo.cpp @@ -23,6 +23,8 @@ #include "../CHeroHandler.h" #include "../CModHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + CMapInfo::CMapInfo() : scenarioOptionsOfSave(nullptr), amountOfPlayersOnMap(0), amountOfHumanControllablePlayers(0), amountOfHumanPlayersInSave(0), isRandomMap(false) { @@ -182,3 +184,5 @@ std::string CMapInfo::getMapSizeName() const return "C"; } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapping/CMapInfo.h b/lib/mapping/CMapInfo.h index c04058bd9..69c4e96de 100644 --- a/lib/mapping/CMapInfo.h +++ b/lib/mapping/CMapInfo.h @@ -20,6 +20,8 @@ #include "CMap.h" #include "CCampaignHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + struct StartInfo; /** @@ -69,3 +71,5 @@ public: h & isRandomMap; } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapping/CMapOperation.cpp b/lib/mapping/CMapOperation.cpp index 4e00496c1..c89a5518d 100644 --- a/lib/mapping/CMapOperation.cpp +++ b/lib/mapping/CMapOperation.cpp @@ -13,7 +13,9 @@ #include "../VCMI_Lib.h" #include "CMap.h" -#include "MapEditUtils.h" +#include "MapEditUtils.h" + +VCMI_LIB_NAMESPACE_BEGIN CMapOperation::CMapOperation(CMap* map) : map(map) { @@ -672,3 +674,5 @@ std::string CRemoveObjectOperation::getLabel() const { return "Remove Object"; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapping/CMapOperation.h b/lib/mapping/CMapOperation.h index 921832470..2121e9fad 100644 --- a/lib/mapping/CMapOperation.h +++ b/lib/mapping/CMapOperation.h @@ -13,6 +13,8 @@ #include "../int3.h" #include "MapEditUtils.h" +VCMI_LIB_NAMESPACE_BEGIN + class CGObjectInstance; class CMap; class CRandomGenerator; @@ -158,4 +160,6 @@ public: private: CGObjectInstance* obj; -}; \ No newline at end of file +}; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapping/CMapService.cpp b/lib/mapping/CMapService.cpp index 4c27ed957..2ad1c8430 100644 --- a/lib/mapping/CMapService.cpp +++ b/lib/mapping/CMapService.cpp @@ -21,6 +21,8 @@ #include "MapFormatH3M.h" #include "MapFormatJson.h" +VCMI_LIB_NAMESPACE_BEGIN + std::unique_ptr CMapService::loadMap(const ResourceID & name) const { @@ -138,3 +140,5 @@ std::unique_ptr CMapService::getMapPatcher(std::string scenarioName logGlobal->debug("Request to patch map %s", scenarioName); return std::unique_ptr(new CMapPatcher(node[scenarioName])); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapping/CMapService.h b/lib/mapping/CMapService.h index f0882640f..98aac2a4c 100644 --- a/lib/mapping/CMapService.h +++ b/lib/mapping/CMapService.h @@ -10,6 +10,8 @@ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + class ResourceID; class CMap; @@ -171,3 +173,5 @@ public: virtual ~IMapSaver(){} }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapping/MapEditUtils.cpp b/lib/mapping/MapEditUtils.cpp index 489954356..2d1b491f6 100644 --- a/lib/mapping/MapEditUtils.cpp +++ b/lib/mapping/MapEditUtils.cpp @@ -16,6 +16,8 @@ #include "CMap.h" #include "CMapOperation.h" +VCMI_LIB_NAMESPACE_BEGIN + MapRect::MapRect() : x(0), y(0), z(0), width(0), height(0) { @@ -369,3 +371,5 @@ void CTerrainViewPatternUtils::printDebuggingInfoAboutTile(const CMap * map, int logGlobal->debug(line); } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapping/MapEditUtils.h b/lib/mapping/MapEditUtils.h index 6df777a3d..d2f35781a 100644 --- a/lib/mapping/MapEditUtils.h +++ b/lib/mapping/MapEditUtils.h @@ -14,6 +14,8 @@ #include "../CRandomGenerator.h" #include "Terrain.h" +VCMI_LIB_NAMESPACE_BEGIN + class CGObjectInstance; class CMap; @@ -231,3 +233,5 @@ class DLL_LINKAGE CTerrainViewPatternUtils public: static void printDebuggingInfoAboutTile(const CMap * map, int3 pos); }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapping/MapFormatH3M.cpp b/lib/mapping/MapFormatH3M.cpp index 26faf348b..fdd35b68a 100644 --- a/lib/mapping/MapFormatH3M.cpp +++ b/lib/mapping/MapFormatH3M.cpp @@ -26,6 +26,8 @@ #include "../VCMI_Lib.h" #include "../NetPacksBase.h" +VCMI_LIB_NAMESPACE_BEGIN + const bool CMapLoaderH3M::IS_PROFILING_ENABLED = false; @@ -2266,3 +2268,5 @@ void CMapLoaderH3M::afterRead() } } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapping/MapFormatH3M.h b/lib/mapping/MapFormatH3M.h index 1a71f2d1d..908cef1a7 100644 --- a/lib/mapping/MapFormatH3M.h +++ b/lib/mapping/MapFormatH3M.h @@ -19,6 +19,8 @@ #include "../filesystem/CBinaryReader.h" +VCMI_LIB_NAMESPACE_BEGIN + class CGHeroInstance; class CArtifactInstance; class CGObjectInstance; @@ -260,3 +262,5 @@ private: CInputStream * inputStream; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapping/MapFormatJson.cpp b/lib/mapping/MapFormatJson.cpp index e14de101b..f06a84ce3 100644 --- a/lib/mapping/MapFormatJson.cpp +++ b/lib/mapping/MapFormatJson.cpp @@ -30,6 +30,8 @@ #include "../serializer/JsonDeserializer.h" #include "../serializer/JsonSerializer.h" +VCMI_LIB_NAMESPACE_BEGIN + class MapObjectResolver: public IInstanceResolver { public: @@ -1364,3 +1366,5 @@ void CMapSaverJson::writeObjects() addToArchive(data, OBJECTS_FILE_NAME); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/mapping/MapFormatJson.h b/lib/mapping/MapFormatJson.h index 4dc36df5a..149984e63 100644 --- a/lib/mapping/MapFormatJson.h +++ b/lib/mapping/MapFormatJson.h @@ -19,6 +19,8 @@ #include "../serializer/JsonSerializeFormat.h" +VCMI_LIB_NAMESPACE_BEGIN + struct TriggeredEvent; struct TerrainTile; struct PlayerInfo; @@ -265,3 +267,5 @@ private: std::shared_ptr ioApi; CZipSaver saver;///< object to handle zip archive operations }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/registerTypes/RegisterTypes.cpp b/lib/registerTypes/RegisterTypes.cpp index a3db27100..94b8436e5 100644 --- a/lib/registerTypes/RegisterTypes.cpp +++ b/lib/registerTypes/RegisterTypes.cpp @@ -24,6 +24,8 @@ #include "../serializer/BinarySerializer.h" #include "../serializer/CTypeList.h" +VCMI_LIB_NAMESPACE_BEGIN + // For reference: peak memory usage by gcc during compilation of register type templates // registerTypesMapObjects: 1.9 Gb // registerTypes2: 2.2 Gb @@ -49,3 +51,5 @@ DEFINE_EXTERNAL_METHOD(registerTypesLobbyPacks) template void registerTypes(BinaryDeserializer & s); template void registerTypes(BinarySerializer & s); template void registerTypes(CTypeList & s); + +VCMI_LIB_NAMESPACE_END diff --git a/lib/registerTypes/RegisterTypes.h b/lib/registerTypes/RegisterTypes.h index 17e46c54c..f50fac623 100644 --- a/lib/registerTypes/RegisterTypes.h +++ b/lib/registerTypes/RegisterTypes.h @@ -24,6 +24,8 @@ #include "../battle/CObstacleInstance.h" #include "../CStack.h" +VCMI_LIB_NAMESPACE_BEGIN + class BinarySerializer; class BinaryDeserializer; class CTypeList; @@ -408,3 +410,5 @@ extern template DLL_LINKAGE void registerTypes(CTypeList & s); #endif + +VCMI_LIB_NAMESPACE_END diff --git a/lib/registerTypes/TypesClientPacks1.cpp b/lib/registerTypes/TypesClientPacks1.cpp index 3044df426..305f53e56 100644 --- a/lib/registerTypes/TypesClientPacks1.cpp +++ b/lib/registerTypes/TypesClientPacks1.cpp @@ -29,7 +29,11 @@ #include "../serializer/BinarySerializer.h" #include "../serializer/CTypeList.h" +VCMI_LIB_NAMESPACE_BEGIN + template void registerTypesClientPacks1(BinaryDeserializer & s); template void registerTypesClientPacks1(BinarySerializer & s); template void registerTypesClientPacks1(CTypeList & s); + +VCMI_LIB_NAMESPACE_END diff --git a/lib/registerTypes/TypesClientPacks2.cpp b/lib/registerTypes/TypesClientPacks2.cpp index 4a6dd9b30..5d8400b80 100644 --- a/lib/registerTypes/TypesClientPacks2.cpp +++ b/lib/registerTypes/TypesClientPacks2.cpp @@ -31,9 +31,13 @@ #include "../serializer/BinarySerializer.h" #include "../serializer/CTypeList.h" +VCMI_LIB_NAMESPACE_BEGIN + template void registerTypesClientPacks2(BinaryDeserializer & s); template void registerTypesClientPacks2(BinarySerializer & s); template void registerTypesClientPacks2(CTypeList & s); + +VCMI_LIB_NAMESPACE_END diff --git a/lib/registerTypes/TypesLobbyPacks.cpp b/lib/registerTypes/TypesLobbyPacks.cpp index e7360a6e3..3a65eb231 100644 --- a/lib/registerTypes/TypesLobbyPacks.cpp +++ b/lib/registerTypes/TypesLobbyPacks.cpp @@ -31,7 +31,11 @@ #include "../serializer/BinarySerializer.h" #include "../serializer/CTypeList.h" +VCMI_LIB_NAMESPACE_BEGIN + template void registerTypesLobbyPacks(BinaryDeserializer & s); template void registerTypesLobbyPacks(BinarySerializer & s); template void registerTypesLobbyPacks(CTypeList & s); + +VCMI_LIB_NAMESPACE_END diff --git a/lib/registerTypes/TypesMapObjects1.cpp b/lib/registerTypes/TypesMapObjects1.cpp index 7fc2e66b6..690248cd5 100644 --- a/lib/registerTypes/TypesMapObjects1.cpp +++ b/lib/registerTypes/TypesMapObjects1.cpp @@ -29,8 +29,12 @@ #include "../serializer/BinarySerializer.h" #include "../serializer/CTypeList.h" +VCMI_LIB_NAMESPACE_BEGIN + template void registerTypesMapObjects1(BinaryDeserializer & s); template void registerTypesMapObjects1(BinarySerializer & s); template void registerTypesMapObjects1(CTypeList & s); + +VCMI_LIB_NAMESPACE_END diff --git a/lib/registerTypes/TypesMapObjects2.cpp b/lib/registerTypes/TypesMapObjects2.cpp index 7a52f3764..cc3a05e47 100644 --- a/lib/registerTypes/TypesMapObjects2.cpp +++ b/lib/registerTypes/TypesMapObjects2.cpp @@ -31,8 +31,12 @@ #include "../serializer/BinarySerializer.h" #include "../serializer/CTypeList.h" +VCMI_LIB_NAMESPACE_BEGIN + template void registerTypesMapObjects2(BinaryDeserializer & s); template void registerTypesMapObjects2(BinarySerializer & s); template void registerTypesMapObjects2(CTypeList & s); + +VCMI_LIB_NAMESPACE_END diff --git a/lib/registerTypes/TypesMapObjects3.cpp b/lib/registerTypes/TypesMapObjects3.cpp index 03022ffb7..fbac38dc0 100644 --- a/lib/registerTypes/TypesMapObjects3.cpp +++ b/lib/registerTypes/TypesMapObjects3.cpp @@ -29,6 +29,10 @@ #include "../serializer/BinarySerializer.h" #include "../serializer/CTypeList.h" +VCMI_LIB_NAMESPACE_BEGIN + template void registerTypesMapObjectTypes(BinaryDeserializer & s); template void registerTypesMapObjectTypes(BinarySerializer & s); template void registerTypesMapObjectTypes(CTypeList & s); + +VCMI_LIB_NAMESPACE_END diff --git a/lib/registerTypes/TypesServerPacks.cpp b/lib/registerTypes/TypesServerPacks.cpp index 18f9e53e3..82d00d4f0 100644 --- a/lib/registerTypes/TypesServerPacks.cpp +++ b/lib/registerTypes/TypesServerPacks.cpp @@ -29,6 +29,10 @@ #include "../serializer/BinarySerializer.h" #include "../serializer/CTypeList.h" +VCMI_LIB_NAMESPACE_BEGIN + template void registerTypesServerPacks(BinaryDeserializer & s); template void registerTypesServerPacks(BinarySerializer & s); template void registerTypesServerPacks(CTypeList & s); + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/CMapGenOptions.cpp b/lib/rmg/CMapGenOptions.cpp index dfd8f4ec8..774f374d5 100644 --- a/lib/rmg/CMapGenOptions.cpp +++ b/lib/rmg/CMapGenOptions.cpp @@ -18,6 +18,8 @@ #include "../VCMI_Lib.h" #include "../CTownHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + CMapGenOptions::CMapGenOptions() : width(CMapHeader::MAP_SIZE_MIDDLE), height(CMapHeader::MAP_SIZE_MIDDLE), hasTwoLevels(true), playerCount(RANDOM_SIZE), teamCount(RANDOM_SIZE), compOnlyPlayerCount(RANDOM_SIZE), compOnlyTeamCount(RANDOM_SIZE), @@ -491,3 +493,5 @@ void CMapGenOptions::CPlayerSettings::setPlayerType(EPlayerType::EPlayerType val { playerType = value; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/CMapGenOptions.h b/lib/rmg/CMapGenOptions.h index 01c2f815f..9017576b1 100644 --- a/lib/rmg/CMapGenOptions.h +++ b/lib/rmg/CMapGenOptions.h @@ -12,6 +12,8 @@ #include "../GameConstants.h" +VCMI_LIB_NAMESPACE_BEGIN + class CRmgTemplate; class CRandomGenerator; @@ -188,3 +190,5 @@ public: //TODO add name of template to class, enables selection of a template by a user } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/CMapGenerator.cpp b/lib/rmg/CMapGenerator.cpp index 60f54eee1..7796e5f49 100644 --- a/lib/rmg/CMapGenerator.cpp +++ b/lib/rmg/CMapGenerator.cpp @@ -27,6 +27,8 @@ #include "TreasurePlacer.h" #include "RoadPlacer.h" +VCMI_LIB_NAMESPACE_BEGIN + CMapGenerator::CMapGenerator(CMapGenOptions& mapGenOptions, int RandomSeed) : mapGenOptions(mapGenOptions), randomSeed(RandomSeed), prisonsRemaining(0), monolithIndex(0) @@ -396,3 +398,5 @@ Zone * CMapGenerator::getZoneWater() const return z.second.get(); return nullptr; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/CMapGenerator.h b/lib/rmg/CMapGenerator.h index 96c52ce98..5bbc575ae 100644 --- a/lib/rmg/CMapGenerator.h +++ b/lib/rmg/CMapGenerator.h @@ -17,6 +17,8 @@ #include "CRmgTemplate.h" #include "../LoadProgress.h" +VCMI_LIB_NAMESPACE_BEGIN + class CRmgTemplate; class CMapGenOptions; class JsonNode; @@ -100,3 +102,5 @@ private: void fillZones(); }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/CRmgTemplate.cpp b/lib/rmg/CRmgTemplate.cpp index 1025ff874..f1d8e8bec 100644 --- a/lib/rmg/CRmgTemplate.cpp +++ b/lib/rmg/CRmgTemplate.cpp @@ -20,6 +20,8 @@ #include "../serializer/JsonSerializeFormat.h" #include "../StringConstants.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace { si32 decodeZoneId(const std::string & json) @@ -799,3 +801,5 @@ void CRmgTemplate::serializePlayers(JsonSerializeFormat & handler, CPlayerCountR value.fromString(encodedValue); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/CRmgTemplate.h b/lib/rmg/CRmgTemplate.h index 2637d8c5a..31cc4bca7 100644 --- a/lib/rmg/CRmgTemplate.h +++ b/lib/rmg/CRmgTemplate.h @@ -16,6 +16,8 @@ #include "../Terrain.h" #include "CMapGenOptions.h" +VCMI_LIB_NAMESPACE_BEGIN + class JsonSerializeFormat; namespace ETemplateZoneType @@ -216,3 +218,5 @@ private: void serializeSize(JsonSerializeFormat & handler, int3 & value, const std::string & fieldName); void serializePlayers(JsonSerializeFormat & handler, CPlayerCountRange & value, const std::string & fieldName); }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/CRmgTemplateStorage.cpp b/lib/rmg/CRmgTemplateStorage.cpp index ec3f7e890..15648a224 100644 --- a/lib/rmg/CRmgTemplateStorage.cpp +++ b/lib/rmg/CRmgTemplateStorage.cpp @@ -15,6 +15,8 @@ #include "../serializer/JsonDeserializer.h" +VCMI_LIB_NAMESPACE_BEGIN + using namespace rmg; void CRmgTemplateStorage::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) @@ -78,3 +80,5 @@ std::vector CRmgTemplateStorage::getTemplates() const } return result; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/CRmgTemplateStorage.h b/lib/rmg/CRmgTemplateStorage.h index b59631802..0e6f66288 100644 --- a/lib/rmg/CRmgTemplateStorage.h +++ b/lib/rmg/CRmgTemplateStorage.h @@ -14,6 +14,8 @@ #include "../int3.h" #include "CRmgTemplate.h" +VCMI_LIB_NAMESPACE_BEGIN + class JsonNode; /// The CJsonRmgTemplateLoader loads templates from a JSON file. @@ -38,3 +40,5 @@ private: std::map templatesByName; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/CZonePlacer.cpp b/lib/rmg/CZonePlacer.cpp index 8200895a7..4c37f3458 100644 --- a/lib/rmg/CZonePlacer.cpp +++ b/lib/rmg/CZonePlacer.cpp @@ -17,6 +17,8 @@ #include "Zone.h" #include "Functions.h" +VCMI_LIB_NAMESPACE_BEGIN + class CRandomGenerator; CZonePlacer::CZonePlacer(RmgMap & map) @@ -576,3 +578,5 @@ void CZonePlacer::assignZones(CRandomGenerator * rand) } logGlobal->info("Finished zone colouring"); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/CZonePlacer.h b/lib/rmg/CZonePlacer.h index 6558435bb..8e26a7e7e 100644 --- a/lib/rmg/CZonePlacer.h +++ b/lib/rmg/CZonePlacer.h @@ -14,6 +14,8 @@ #include "../int3.h" #include "../GameConstants.h" +VCMI_LIB_NAMESPACE_BEGIN + class CZoneGraph; class CMap; class CRandomGenerator; @@ -58,3 +60,5 @@ private: //std::unique_ptr graph; RmgMap & map; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/ConnectionsPlacer.cpp b/lib/rmg/ConnectionsPlacer.cpp index bd4633398..dcdb2b28d 100644 --- a/lib/rmg/ConnectionsPlacer.cpp +++ b/lib/rmg/ConnectionsPlacer.cpp @@ -25,6 +25,8 @@ #include "WaterProxy.h" #include "TownPlacer.h" +VCMI_LIB_NAMESPACE_BEGIN + void ConnectionsPlacer::process() { collectNeighbourZones(); @@ -278,3 +280,5 @@ void ConnectionsPlacer::collectNeighbourZones() dNeighbourZones[zid].insert(i); } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/ConnectionsPlacer.h b/lib/rmg/ConnectionsPlacer.h index bdbd86740..ac577b687 100644 --- a/lib/rmg/ConnectionsPlacer.h +++ b/lib/rmg/ConnectionsPlacer.h @@ -12,6 +12,8 @@ #include "Zone.h" #include "RmgArea.h" +VCMI_LIB_NAMESPACE_BEGIN + class ConnectionsPlacer: public Modificator { public: @@ -33,3 +35,5 @@ protected: std::vector dConnections, dCompleted; std::map dNeighbourZones; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/Functions.cpp b/lib/rmg/Functions.cpp index 210bf9fe2..9795cc621 100644 --- a/lib/rmg/Functions.cpp +++ b/lib/rmg/Functions.cpp @@ -28,6 +28,8 @@ #include "../mapObjects/MapObjects.h" //needed to resolve templates for CommonConstructors.h #include "../VCMI_Lib.h" +VCMI_LIB_NAMESPACE_BEGIN + void createModificators(RmgMap & map) { for(auto & z : map.getZones()) @@ -176,3 +178,5 @@ void createObstaclesCommon2(RmgMap & map, CRandomGenerator & generator) } } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/Functions.h b/lib/rmg/Functions.h index 0be072e84..5696126da 100644 --- a/lib/rmg/Functions.h +++ b/lib/rmg/Functions.h @@ -13,6 +13,8 @@ #include "Zone.h" #include //A* +VCMI_LIB_NAMESPACE_BEGIN + class RmgMap; class ObjectManager; class ObjectTemplate; @@ -46,3 +48,5 @@ void initTerrainType(Zone & zone, CMapGenerator & gen); int chooseRandomAppearance(CRandomGenerator & generator, si32 ObjID, const Terrain & terrain); + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/ObjectManager.cpp b/lib/rmg/ObjectManager.cpp index 875b9974a..217c03017 100644 --- a/lib/rmg/ObjectManager.cpp +++ b/lib/rmg/ObjectManager.cpp @@ -24,6 +24,8 @@ #include "Functions.h" #include "RmgObject.h" +VCMI_LIB_NAMESPACE_BEGIN + void ObjectManager::process() { zone.fractalize(); @@ -491,3 +493,5 @@ bool ObjectManager::addGuard(rmg::Object & object, si32 strength, bool zoneGuard return true; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/ObjectManager.h b/lib/rmg/ObjectManager.h index 071b3ab8a..37ad5b1f0 100644 --- a/lib/rmg/ObjectManager.h +++ b/lib/rmg/ObjectManager.h @@ -14,6 +14,8 @@ #include "RmgObject.h" #include //A* +VCMI_LIB_NAMESPACE_BEGIN + class CGObjectInstance; class ObjectTemplate; class CGCreature; @@ -79,3 +81,5 @@ protected: boost::heap::priority_queue> tilesByDistance; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/ObstaclePlacer.cpp b/lib/rmg/ObstaclePlacer.cpp index 29fba34ab..519cacf00 100644 --- a/lib/rmg/ObstaclePlacer.cpp +++ b/lib/rmg/ObstaclePlacer.cpp @@ -24,6 +24,8 @@ #include "Functions.h" #include "../mapping/CMapEditManager.h" +VCMI_LIB_NAMESPACE_BEGIN + void ObstacleProxy::collectPossibleObstacles(const Terrain & terrain) { //get all possible obstacles for this terrain @@ -262,3 +264,5 @@ bool ObstaclePlacer::isProhibited(const rmg::Area & objArea) const void ObstaclePlacer::finalInsertion(CMapEditManager *, std::set &) { } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/ObstaclePlacer.h b/lib/rmg/ObstaclePlacer.h index b98d042aa..8f2fedbbe 100644 --- a/lib/rmg/ObstaclePlacer.h +++ b/lib/rmg/ObstaclePlacer.h @@ -11,10 +11,13 @@ #pragma once #include "Zone.h" +VCMI_LIB_NAMESPACE_BEGIN + class CMap; class CMapEditManager; class RiverPlacer; class ObjectManager; + class DLL_LINKAGE ObstacleProxy { public: @@ -69,3 +72,5 @@ private: RiverPlacer * riverManager; ObjectManager * manager; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/RiverPlacer.cpp b/lib/rmg/RiverPlacer.cpp index 599c1cded..b1d6229db 100644 --- a/lib/rmg/RiverPlacer.cpp +++ b/lib/rmg/RiverPlacer.cpp @@ -22,6 +22,8 @@ #include "WaterProxy.h" #include "RoadPlacer.h" +VCMI_LIB_NAMESPACE_BEGIN + const int RIVER_DELTA_ID = 143; const int RIVER_DELTA_SUBTYPE = 0; const std::map RIVER_DELTA_TEMPLATE_NAME @@ -402,3 +404,5 @@ void RiverPlacer::connectRiver(const int3 & tile) rivers.unite(pathToSource.getPathArea()); rivers.unite(pathToSink.getPathArea()); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/RiverPlacer.h b/lib/rmg/RiverPlacer.h index 46c6e1e23..f20233af7 100644 --- a/lib/rmg/RiverPlacer.h +++ b/lib/rmg/RiverPlacer.h @@ -11,6 +11,8 @@ #pragma once #include "Zone.h" +VCMI_LIB_NAMESPACE_BEGIN + class RiverPlacer: public Modificator { public: @@ -46,3 +48,5 @@ private: std::map heightMap; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/RmgArea.cpp b/lib/rmg/RmgArea.cpp index a2fb40045..f733a4d01 100644 --- a/lib/rmg/RmgArea.cpp +++ b/lib/rmg/RmgArea.cpp @@ -12,6 +12,8 @@ #include "RmgArea.h" #include "CMapGenerator.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace rmg { @@ -402,3 +404,5 @@ bool operator== (const Area & l, const Area & r) } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/RmgArea.h b/lib/rmg/RmgArea.h index cc995f6b0..a9b0f4d0b 100644 --- a/lib/rmg/RmgArea.h +++ b/lib/rmg/RmgArea.h @@ -13,6 +13,8 @@ #include "../GameConstants.h" #include "../int3.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace rmg { static const std::array dirs4 = { int3(0,1,0),int3(0,-1,0),int3(-1,0,0),int3(+1,0,0) }; @@ -84,3 +86,5 @@ namespace rmg mutable int3 dTotalShiftCache; }; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/RmgMap.cpp b/lib/rmg/RmgMap.cpp index 95c40acbb..ee8d35767 100644 --- a/lib/rmg/RmgMap.cpp +++ b/lib/rmg/RmgMap.cpp @@ -30,6 +30,8 @@ #include "Functions.h" #include "CMapGenerator.h" +VCMI_LIB_NAMESPACE_BEGIN + RmgMap::RmgMap(const CMapGenOptions& mapGenOptions) : mapGenOptions(mapGenOptions), zonesTotal(0) { @@ -338,3 +340,5 @@ void RmgMap::dump(bool zoneId) const } out << std::endl; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/RmgMap.h b/lib/rmg/RmgMap.h index ab5be9b78..a4702c362 100644 --- a/lib/rmg/RmgMap.h +++ b/lib/rmg/RmgMap.h @@ -13,6 +13,8 @@ #include "../GameConstants.h" #include "../mapping/CMap.h" +VCMI_LIB_NAMESPACE_BEGIN + class CMapEditManager; class TileInfo; class CMapGenOptions; @@ -79,3 +81,5 @@ private: boost::multi_array tiles; //[x][y][z] boost::multi_array zoneColouring; //[x][y][z] }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/RmgObject.cpp b/lib/rmg/RmgObject.cpp index 9635daf53..f7898f143 100644 --- a/lib/rmg/RmgObject.cpp +++ b/lib/rmg/RmgObject.cpp @@ -19,6 +19,8 @@ #include "../mapObjects/MapObjects.h" //needed to resolve templates for CommonConstructors.h #include "Functions.h" +VCMI_LIB_NAMESPACE_BEGIN + using namespace rmg; Object::Instance::Instance(const Object& parent, CGObjectInstance & object): dParent(parent), dObject(object) @@ -325,3 +327,5 @@ void Object::clear() dAccessibleAreaFullCache.clear(); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/RmgObject.h b/lib/rmg/RmgObject.h index e418631c3..9a4737c70 100644 --- a/lib/rmg/RmgObject.h +++ b/lib/rmg/RmgObject.h @@ -14,6 +14,8 @@ #include "../int3.h" #include "RmgArea.h" +VCMI_LIB_NAMESPACE_BEGIN + class CGObjectInstance; class RmgMap; class Terrain; @@ -85,3 +87,5 @@ private: ui32 dStrenght; }; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/RmgPath.cpp b/lib/rmg/RmgPath.cpp index 7e38ae04c..fe7319736 100644 --- a/lib/rmg/RmgPath.cpp +++ b/lib/rmg/RmgPath.cpp @@ -12,6 +12,8 @@ #include "RmgPath.h" #include //A* +VCMI_LIB_NAMESPACE_BEGIN + using namespace rmg; const std::function Path::DEFAULT_MOVEMENT_FUNCTION = @@ -191,3 +193,5 @@ const Area & Path::getPathArea() const { return dPath; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/RmgPath.h b/lib/rmg/RmgPath.h index 0866f856c..6f65c1454 100644 --- a/lib/rmg/RmgPath.h +++ b/lib/rmg/RmgPath.h @@ -14,6 +14,8 @@ #include "../int3.h" #include "RmgArea.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace rmg { class Path @@ -47,3 +49,5 @@ private: Area dPath; }; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/RoadPlacer.cpp b/lib/rmg/RoadPlacer.cpp index 8f605a0d6..8dde55600 100644 --- a/lib/rmg/RoadPlacer.cpp +++ b/lib/rmg/RoadPlacer.cpp @@ -18,6 +18,8 @@ #include "../mapping/CMapEditManager.h" #include "RmgPath.h" +VCMI_LIB_NAMESPACE_BEGIN + void RoadPlacer::process() { connectRoads(); @@ -121,3 +123,5 @@ char RoadPlacer::dump(const int3 & t) return 'i'; return Modificator::dump(t); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/RoadPlacer.h b/lib/rmg/RoadPlacer.h index 585679ee6..092f3499f 100644 --- a/lib/rmg/RoadPlacer.h +++ b/lib/rmg/RoadPlacer.h @@ -11,6 +11,8 @@ #pragma once #include "Zone.h" +VCMI_LIB_NAMESPACE_BEGIN + class RoadPlacer: public Modificator { public: @@ -35,3 +37,5 @@ protected: rmg::Area roads; //all tiles with roads rmg::Area areaRoads, isolated; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/RockPlacer.cpp b/lib/rmg/RockPlacer.cpp index 7688c690c..c07251a04 100644 --- a/lib/rmg/RockPlacer.cpp +++ b/lib/rmg/RockPlacer.cpp @@ -20,6 +20,8 @@ #include "../CRandomGenerator.h" #include "../mapping/CMapEditManager.h" +VCMI_LIB_NAMESPACE_BEGIN + void RockPlacer::process() { rockTerrain = Terrain::Manager::getInfo(zone.getTerrainType()).rockTerrain; @@ -101,3 +103,5 @@ char RockPlacer::dump(const int3 & t) } return Modificator::dump(t); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/RockPlacer.h b/lib/rmg/RockPlacer.h index c7217674f..76bd77a14 100644 --- a/lib/rmg/RockPlacer.h +++ b/lib/rmg/RockPlacer.h @@ -11,6 +11,8 @@ #pragma once #include "Zone.h" +VCMI_LIB_NAMESPACE_BEGIN + class RockPlacer: public Modificator { public: @@ -28,3 +30,5 @@ protected: rmg::Area rockArea, accessibleArea; Terrain rockTerrain; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/TerrainPainter.cpp b/lib/rmg/TerrainPainter.cpp index fba82c55c..bec92812b 100644 --- a/lib/rmg/TerrainPainter.cpp +++ b/lib/rmg/TerrainPainter.cpp @@ -19,6 +19,8 @@ #include "CMapGenerator.h" #include "RmgMap.h" +VCMI_LIB_NAMESPACE_BEGIN + void TerrainPainter::process() { initTerrainType(zone, generator); @@ -33,3 +35,5 @@ void TerrainPainter::init() POSTFUNCTION_ALL(ConnectionsPlacer); POSTFUNCTION(ObjectManager); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/TerrainPainter.h b/lib/rmg/TerrainPainter.h index 7052d883f..59024c9e1 100644 --- a/lib/rmg/TerrainPainter.h +++ b/lib/rmg/TerrainPainter.h @@ -11,6 +11,8 @@ #pragma once #include "Zone.h" +VCMI_LIB_NAMESPACE_BEGIN + class TerrainPainter: public Modificator { public: @@ -19,3 +21,5 @@ public: void process() override; void init() override; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/TileInfo.cpp b/lib/rmg/TileInfo.cpp index 9070333d3..a4475f0cf 100644 --- a/lib/rmg/TileInfo.cpp +++ b/lib/rmg/TileInfo.cpp @@ -11,6 +11,8 @@ #include "StdInc.h" #include "TileInfo.h" +VCMI_LIB_NAMESPACE_BEGIN + TileInfo::TileInfo():nearestObjectDistance(float(INT_MAX)), terrain() { occupied = ETileType::POSSIBLE; //all tiles are initially possible to place objects or passages @@ -76,3 +78,5 @@ void TileInfo::setRoadType(const std::string & value) roadType = value; // setOccupied(ETileType::FREE); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/TileInfo.h b/lib/rmg/TileInfo.h index 30ed5d90f..02b4887c0 100644 --- a/lib/rmg/TileInfo.h +++ b/lib/rmg/TileInfo.h @@ -13,6 +13,8 @@ #include "../GameConstants.h" #include "../Terrain.h" +VCMI_LIB_NAMESPACE_BEGIN + class TileInfo { public: @@ -39,3 +41,5 @@ private: Terrain terrain; std::string roadType; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/TownPlacer.cpp b/lib/rmg/TownPlacer.cpp index d33ae032b..d6971adfd 100644 --- a/lib/rmg/TownPlacer.cpp +++ b/lib/rmg/TownPlacer.cpp @@ -24,6 +24,8 @@ #include "WaterAdopter.h" #include "TileInfo.h" +VCMI_LIB_NAMESPACE_BEGIN + void TownPlacer::process() { auto * manager = zone.getModificator(); @@ -278,3 +280,5 @@ int TownPlacer::getTotalTowns() const { return totalTowns; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/TownPlacer.h b/lib/rmg/TownPlacer.h index 3c7fcadbe..d667852db 100644 --- a/lib/rmg/TownPlacer.h +++ b/lib/rmg/TownPlacer.h @@ -10,6 +10,8 @@ #pragma once #include "Zone.h" +VCMI_LIB_NAMESPACE_BEGIN + class ObjectManager; class CGTownInstance; @@ -35,3 +37,5 @@ protected: int totalTowns = 0; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/TreasurePlacer.cpp b/lib/rmg/TreasurePlacer.cpp index cf1d58abb..7ae6a37d7 100644 --- a/lib/rmg/TreasurePlacer.cpp +++ b/lib/rmg/TreasurePlacer.cpp @@ -24,6 +24,8 @@ #include "../mapping/CMap.h" #include "../mapping/CMapEditManager.h" +VCMI_LIB_NAMESPACE_BEGIN + void TreasurePlacer::process() { addAllPossibleObjects(); @@ -823,3 +825,5 @@ void ObjectInfo::setTemplate(si32 type, si32 subtype, Terrain terrainType) templ = templates.front(); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/TreasurePlacer.h b/lib/rmg/TreasurePlacer.h index 457ef35a8..baba38047 100644 --- a/lib/rmg/TreasurePlacer.h +++ b/lib/rmg/TreasurePlacer.h @@ -12,6 +12,8 @@ #include "Zone.h" #include "../mapObjects/ObjectTemplate.h" +VCMI_LIB_NAMESPACE_BEGIN + class CGObjectInstance; class ObjectManager; class RmgMap; @@ -65,3 +67,5 @@ protected: Zone * questArtZone = nullptr; //artifacts required for Seer Huts will be placed here - or not if null }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/WaterAdopter.cpp b/lib/rmg/WaterAdopter.cpp index df06e682d..2dd540995 100644 --- a/lib/rmg/WaterAdopter.cpp +++ b/lib/rmg/WaterAdopter.cpp @@ -25,6 +25,8 @@ #include "ConnectionsPlacer.h" #include "TileInfo.h" +VCMI_LIB_NAMESPACE_BEGIN + void WaterAdopter::process() { createWater(map.getMapGenOptions().getWaterContent()); @@ -259,3 +261,5 @@ char WaterAdopter::dump(const int3 & t) return Modificator::dump(t); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/WaterAdopter.h b/lib/rmg/WaterAdopter.h index 8b97b8d74..ef47d3fa8 100644 --- a/lib/rmg/WaterAdopter.h +++ b/lib/rmg/WaterAdopter.h @@ -11,6 +11,8 @@ #pragma once #include "Zone.h" +VCMI_LIB_NAMESPACE_BEGIN + class WaterAdopter: public Modificator { public: @@ -34,3 +36,5 @@ protected: std::map distanceMap; std::map reverseDistanceMap; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/WaterProxy.cpp b/lib/rmg/WaterProxy.cpp index 777cf8c11..a2a8c9f93 100644 --- a/lib/rmg/WaterProxy.cpp +++ b/lib/rmg/WaterProxy.cpp @@ -27,6 +27,8 @@ #include "WaterAdopter.h" #include "RmgArea.h" +VCMI_LIB_NAMESPACE_BEGIN + void WaterProxy::process() { for(auto & t : zone.area().getTilesVector()) @@ -358,3 +360,5 @@ char WaterProxy::dump(const int3 & t) return '~'; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/WaterProxy.h b/lib/rmg/WaterProxy.h index 769d70208..de50f7354 100644 --- a/lib/rmg/WaterProxy.h +++ b/lib/rmg/WaterProxy.h @@ -11,6 +11,8 @@ #pragma once #include "Zone.h" +VCMI_LIB_NAMESPACE_BEGIN + struct RouteInfo { rmg::Area blocked; @@ -53,3 +55,5 @@ protected: std::map lakeMap; //map tile on lakeId which is position of lake in lakes array +1 }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/WaterRoutes.cpp b/lib/rmg/WaterRoutes.cpp index 40569d4a2..8cca1e426 100644 --- a/lib/rmg/WaterRoutes.cpp +++ b/lib/rmg/WaterRoutes.cpp @@ -28,6 +28,8 @@ #include "WaterAdopter.h" #include "RmgArea.h" +VCMI_LIB_NAMESPACE_BEGIN + void WaterRoutes::process() { auto * wproxy = zone.getModificator(); @@ -117,3 +119,5 @@ char WaterRoutes::dump(const int3 & t) return ' '; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/WaterRoutes.h b/lib/rmg/WaterRoutes.h index 996318362..b693f3d2b 100644 --- a/lib/rmg/WaterRoutes.h +++ b/lib/rmg/WaterRoutes.h @@ -11,6 +11,8 @@ #pragma once #include "Zone.h" +VCMI_LIB_NAMESPACE_BEGIN + struct RouteInfo; class WaterRoutes: public Modificator @@ -25,3 +27,5 @@ public: private: std::vector result; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/Zone.cpp b/lib/rmg/Zone.cpp index 6b2f977f2..b66cf44c8 100644 --- a/lib/rmg/Zone.cpp +++ b/lib/rmg/Zone.cpp @@ -18,6 +18,8 @@ #include "CMapGenerator.h" #include "RmgPath.h" +VCMI_LIB_NAMESPACE_BEGIN + std::function AREA_NO_FILTER = [](const int3 & t) { return true; @@ -405,3 +407,5 @@ Modificator::~Modificator() { } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/Zone.h b/lib/rmg/Zone.h index 3679506c5..37cf07e22 100644 --- a/lib/rmg/Zone.h +++ b/lib/rmg/Zone.h @@ -33,6 +33,8 @@ postfunction(z.second->getModificator()); \ } +VCMI_LIB_NAMESPACE_BEGIN + class RmgMap; class CMapGenerator; class Zone; @@ -141,3 +143,5 @@ protected: Terrain terrainType; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/rmg/float3.h b/lib/rmg/float3.h index 13942d6fb..3398f2877 100644 --- a/lib/rmg/float3.h +++ b/lib/rmg/float3.h @@ -9,6 +9,8 @@ */ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + // FIXME: Class doesn't contain three float values. Update name and description. /// Class which consists of three float values. Represents position virtual RMG (0;1) area. class float3 @@ -161,3 +163,5 @@ struct Shashfloat3 return ret; } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/serializer/BinaryDeserializer.cpp b/lib/serializer/BinaryDeserializer.cpp index d48587c42..d1773b434 100644 --- a/lib/serializer/BinaryDeserializer.cpp +++ b/lib/serializer/BinaryDeserializer.cpp @@ -13,6 +13,8 @@ #include "../registerTypes/RegisterTypes.h" +VCMI_LIB_NAMESPACE_BEGIN + extern template void registerTypes(BinaryDeserializer & s); CLoadFile::CLoadFile(const boost::filesystem::path & fname, int minimalVersion) @@ -101,3 +103,5 @@ void CLoadFile::checkMagicBytes(const std::string &text) if(loaded != text) throw std::runtime_error("Magic bytes doesn't match!"); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/serializer/BinaryDeserializer.h b/lib/serializer/BinaryDeserializer.h index 16b7f22ce..bbb2b0774 100644 --- a/lib/serializer/BinaryDeserializer.h +++ b/lib/serializer/BinaryDeserializer.h @@ -15,6 +15,8 @@ #include "../mapObjects/CGHeroInstance.h" #include "../../Global.h" +VCMI_LIB_NAMESPACE_BEGIN + class CStackInstance; class FileStream; @@ -601,3 +603,5 @@ public: return * this; } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/serializer/BinarySerializer.cpp b/lib/serializer/BinarySerializer.cpp index 229860012..0e3870920 100644 --- a/lib/serializer/BinarySerializer.cpp +++ b/lib/serializer/BinarySerializer.cpp @@ -13,6 +13,8 @@ #include "../registerTypes/RegisterTypes.h" +VCMI_LIB_NAMESPACE_BEGIN + extern template void registerTypes(BinarySerializer & s); CSaveFile::CSaveFile(const boost::filesystem::path &fname) @@ -73,3 +75,5 @@ void CSaveFile::putMagicBytes(const std::string &text) { write(text.c_str(), (unsigned int)text.length()); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/serializer/BinarySerializer.h b/lib/serializer/BinarySerializer.h index 4b6df7d8d..be1cb377c 100644 --- a/lib/serializer/BinarySerializer.h +++ b/lib/serializer/BinarySerializer.h @@ -12,6 +12,8 @@ #include "CTypeList.h" #include "../mapObjects/CArmedInstance.h" +VCMI_LIB_NAMESPACE_BEGIN + class FileStream; class DLL_LINKAGE CSaverBase @@ -389,3 +391,5 @@ public: return * this; } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/serializer/CLoadIntegrityValidator.cpp b/lib/serializer/CLoadIntegrityValidator.cpp index 7b4637921..e04e4fbff 100644 --- a/lib/serializer/CLoadIntegrityValidator.cpp +++ b/lib/serializer/CLoadIntegrityValidator.cpp @@ -13,6 +13,8 @@ #include "../registerTypes/RegisterTypes.h" +VCMI_LIB_NAMESPACE_BEGIN + CLoadIntegrityValidator::CLoadIntegrityValidator(const boost::filesystem::path &primaryFileName, const boost::filesystem::path &controlFileName, int minimalVersion) : serializer(this), foundDesync(false) { @@ -63,3 +65,5 @@ void CLoadIntegrityValidator::checkMagicBytes( const std::string &text ) primaryFile->checkMagicBytes(text); controlFile->checkMagicBytes(text); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/serializer/CLoadIntegrityValidator.h b/lib/serializer/CLoadIntegrityValidator.h index 7ab627914..139e73db1 100644 --- a/lib/serializer/CLoadIntegrityValidator.h +++ b/lib/serializer/CLoadIntegrityValidator.h @@ -11,6 +11,8 @@ #include "BinaryDeserializer.h" +VCMI_LIB_NAMESPACE_BEGIN + /// Simple byte-to-byte saves comparator class DLL_LINKAGE CLoadIntegrityValidator : public IBinaryReader @@ -27,3 +29,5 @@ public: std::unique_ptr decay(); //returns primary file. CLoadIntegrityValidator stops being usable anymore }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/serializer/CMemorySerializer.cpp b/lib/serializer/CMemorySerializer.cpp index e63fa67b5..341ab925f 100644 --- a/lib/serializer/CMemorySerializer.cpp +++ b/lib/serializer/CMemorySerializer.cpp @@ -12,6 +12,8 @@ #include "../registerTypes/RegisterTypes.h" +VCMI_LIB_NAMESPACE_BEGIN + int CMemorySerializer::read(void * data, unsigned size) { if(buffer.size() < readPos + size) @@ -38,3 +40,5 @@ CMemorySerializer::CMemorySerializer(): iser(this), oser(this) iser.fileVersion = SERIALIZATION_VERSION; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/serializer/CMemorySerializer.h b/lib/serializer/CMemorySerializer.h index 799faa424..586220724 100644 --- a/lib/serializer/CMemorySerializer.h +++ b/lib/serializer/CMemorySerializer.h @@ -12,6 +12,8 @@ #include "BinarySerializer.h" #include "BinaryDeserializer.h" +VCMI_LIB_NAMESPACE_BEGIN + /// Serializer that stores objects in the dynamic buffer. Allows performing deep object copies. class DLL_LINKAGE CMemorySerializer : public IBinaryReader, public IBinaryWriter @@ -39,3 +41,5 @@ public: return ret; } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/serializer/CSerializer.cpp b/lib/serializer/CSerializer.cpp index ee9977f75..fe53ad072 100644 --- a/lib/serializer/CSerializer.cpp +++ b/lib/serializer/CSerializer.cpp @@ -15,6 +15,8 @@ #include "../CHeroHandler.h" #include "../mapObjects/CGHeroInstance.h" +VCMI_LIB_NAMESPACE_BEGIN + CSerializer::~CSerializer() { @@ -46,3 +48,5 @@ void CSerializer::addStdVecItems(CGameState *gs, LibClasses *lib) smartVectorMembersSerialization = true; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/serializer/CSerializer.h b/lib/serializer/CSerializer.h index 00891b786..9b0d14e47 100644 --- a/lib/serializer/CSerializer.h +++ b/lib/serializer/CSerializer.h @@ -12,6 +12,8 @@ #include "../ConstTransitivePtr.h" #include "../GameConstants.h" +VCMI_LIB_NAMESPACE_BEGIN + const ui32 SERIALIZATION_VERSION = 805; const ui32 MINIMAL_SERIALIZATION_VERSION = 805; const std::string SAVEGAME_MAGIC = "VCMISVG"; @@ -199,3 +201,5 @@ class DLL_LINKAGE IBinaryWriter : public virtual CSerializer public: virtual int write(const void * data, unsigned size) = 0; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/serializer/CTypeList.cpp b/lib/serializer/CTypeList.cpp index 8ff73749d..64ae07050 100644 --- a/lib/serializer/CTypeList.cpp +++ b/lib/serializer/CTypeList.cpp @@ -12,6 +12,8 @@ #include "../registerTypes/RegisterTypes.h" +VCMI_LIB_NAMESPACE_BEGIN + extern template void registerTypes(CTypeList & s); CTypeList typeList; @@ -135,3 +137,5 @@ CTypeList::TypeInfoPtr CTypeList::getTypeDescriptor(const std::type_info *type, THROW_FORMAT("Cannot find type descriptor for type %s. Was it registered?", type->name()); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/serializer/CTypeList.h b/lib/serializer/CTypeList.h index 951df3ec0..38ba68975 100644 --- a/lib/serializer/CTypeList.h +++ b/lib/serializer/CTypeList.h @@ -11,6 +11,8 @@ #include "CSerializer.h" +VCMI_LIB_NAMESPACE_BEGIN + struct IPointerCaster { virtual boost::any castRawPtr(const boost::any &ptr) const = 0; // takes From*, returns To* @@ -231,3 +233,5 @@ public: addApplier(typeList.getTypeID(d)); } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/serializer/Cast.h b/lib/serializer/Cast.h index 4bef39ce6..ebc7957af 100644 --- a/lib/serializer/Cast.h +++ b/lib/serializer/Cast.h @@ -13,6 +13,8 @@ #include #include "CTypeList.h" +VCMI_LIB_NAMESPACE_BEGIN + template inline const T * dynamic_ptr_cast(const F * ptr) { @@ -60,3 +62,5 @@ inline T * dynamic_ptr_cast(F * ptr) return static_cast(ptr); #endif } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/serializer/Connection.cpp b/lib/serializer/Connection.cpp index 5d799d666..40bb302a9 100644 --- a/lib/serializer/Connection.cpp +++ b/lib/serializer/Connection.cpp @@ -16,6 +16,8 @@ #include +VCMI_LIB_NAMESPACE_BEGIN + using namespace boost; using namespace boost::asio::ip; @@ -33,8 +35,15 @@ using namespace boost::asio::ip; void CConnection::init() { socket->set_option(boost::asio::ip::tcp::no_delay(true)); - socket->set_option(boost::asio::socket_base::send_buffer_size(4194304)); - socket->set_option(boost::asio::socket_base::receive_buffer_size(4194304)); + try + { + socket->set_option(boost::asio::socket_base::send_buffer_size(4194304)); + socket->set_option(boost::asio::socket_base::receive_buffer_size(4194304)); + } + catch (const boost::system::system_error & e) + { + logNetwork->error("error setting socket option: %s", e.what()); + } enableSmartPointerSerialization(); disableStackSendingByID(); @@ -274,3 +283,5 @@ std::string CConnection::toString() const fmt % name % connectionID % uuid; return fmt.str(); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/serializer/Connection.h b/lib/serializer/Connection.h index 6ba68d269..63a161b56 100644 --- a/lib/serializer/Connection.h +++ b/lib/serializer/Connection.h @@ -12,8 +12,6 @@ #include "BinaryDeserializer.h" #include "BinarySerializer.h" -struct CPack; - #if BOOST_VERSION >= 107000 // Boost version >= 1.70 #include typedef boost::asio::basic_stream_socket < boost::asio::ip::tcp > TSocket; @@ -51,6 +49,10 @@ typedef boost::asio::basic_socket_acceptor +VCMI_LIB_NAMESPACE_BEGIN + JsonDeserializer::JsonDeserializer(const IInstanceResolver * instanceResolver_, const JsonNode & root_): JsonTreeSerializer(instanceResolver_, &root_, false, false) { @@ -281,3 +283,5 @@ void JsonDeserializer::readLICPart(const JsonNode & part, const TDecoder & decod } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/serializer/JsonDeserializer.h b/lib/serializer/JsonDeserializer.h index bace8e371..8c19c15a2 100644 --- a/lib/serializer/JsonDeserializer.h +++ b/lib/serializer/JsonDeserializer.h @@ -11,6 +11,8 @@ #include "JsonTreeSerializer.h" +VCMI_LIB_NAMESPACE_BEGIN + class DLL_LINKAGE JsonDeserializer: public JsonTreeSerializer { public: @@ -38,3 +40,5 @@ private: void readLICPart(const JsonNode & part, const TDecoder & decoder, const bool val, std::vector & value); void readLICPart(const JsonNode & part, const TDecoder & decoder, std::set & value); }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/serializer/JsonSerializeFormat.cpp b/lib/serializer/JsonSerializeFormat.cpp index 8e7143629..7525685f3 100644 --- a/lib/serializer/JsonSerializeFormat.cpp +++ b/lib/serializer/JsonSerializeFormat.cpp @@ -12,6 +12,8 @@ #include "../JsonNode.h" +VCMI_LIB_NAMESPACE_BEGIN + //JsonSerializeHelper JsonSerializeHelper::JsonSerializeHelper(JsonSerializeHelper && other): owner(other.owner), @@ -151,3 +153,5 @@ void JsonSerializeFormat::serializeBool(const std::string & fieldName, bool & va { serializeBool(fieldName, value, true, false, defaultValue); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/serializer/JsonSerializeFormat.h b/lib/serializer/JsonSerializeFormat.h index 27070923a..83d171c90 100644 --- a/lib/serializer/JsonSerializeFormat.h +++ b/lib/serializer/JsonSerializeFormat.h @@ -11,6 +11,8 @@ #include "../JsonNode.h" +VCMI_LIB_NAMESPACE_BEGIN + class JsonSerializeFormat; class JsonStructSerializer; class JsonArraySerializer; @@ -523,3 +525,5 @@ void JsonArraySerializer::serializeInt(const size_t index, T & value) if (!owner->saving) value = static_cast(temp); }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/serializer/JsonSerializer.cpp b/lib/serializer/JsonSerializer.cpp index 7285d7e9e..d01ca0e4c 100644 --- a/lib/serializer/JsonSerializer.cpp +++ b/lib/serializer/JsonSerializer.cpp @@ -12,6 +12,8 @@ #include "../JsonNode.h" +VCMI_LIB_NAMESPACE_BEGIN + JsonSerializer::JsonSerializer(const IInstanceResolver * instanceResolver_, JsonNode & root_): JsonTreeSerializer(instanceResolver_, &root_, true, false) { @@ -185,3 +187,5 @@ void JsonSerializer::writeLICPartBuffer(const std::string & fieldName, const std } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/serializer/JsonSerializer.h b/lib/serializer/JsonSerializer.h index 8621750c9..c75bf1ac6 100644 --- a/lib/serializer/JsonSerializer.h +++ b/lib/serializer/JsonSerializer.h @@ -11,6 +11,8 @@ #include "JsonTreeSerializer.h" +VCMI_LIB_NAMESPACE_BEGIN + class DLL_LINKAGE JsonSerializer : public JsonTreeSerializer { public: @@ -44,3 +46,5 @@ private: void writeLICPartBuffer(const std::string & fieldName, const std::string & partName, std::vector & buffer); }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/serializer/JsonTreeSerializer.h b/lib/serializer/JsonTreeSerializer.h index c5d2becac..c1cb36e61 100644 --- a/lib/serializer/JsonTreeSerializer.h +++ b/lib/serializer/JsonTreeSerializer.h @@ -12,6 +12,8 @@ #include "JsonSerializeFormat.h" +VCMI_LIB_NAMESPACE_BEGIN + template class JsonTreeSerializer : public JsonSerializeFormat { @@ -71,3 +73,5 @@ private: currentObject = newCurrentObject; } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/serializer/JsonUpdater.cpp b/lib/serializer/JsonUpdater.cpp index dc69e991b..b5702236b 100644 --- a/lib/serializer/JsonUpdater.cpp +++ b/lib/serializer/JsonUpdater.cpp @@ -13,6 +13,8 @@ #include "../JsonNode.h" #include "../HeroBonus.h" +VCMI_LIB_NAMESPACE_BEGIN + JsonUpdater::JsonUpdater(const IInstanceResolver * instanceResolver_, const JsonNode & root_) : JsonTreeSerializer(instanceResolver_, &root_, false, true) { @@ -307,3 +309,5 @@ void JsonUpdater::readLICPart(const JsonNode & part, const TDecoder & decoder, s } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/serializer/JsonUpdater.h b/lib/serializer/JsonUpdater.h index d1caa7ec7..238058692 100644 --- a/lib/serializer/JsonUpdater.h +++ b/lib/serializer/JsonUpdater.h @@ -11,6 +11,8 @@ #include "JsonTreeSerializer.h" +VCMI_LIB_NAMESPACE_BEGIN + class CBonusSystemNode; class DLL_LINKAGE JsonUpdater: public JsonTreeSerializer @@ -42,3 +44,5 @@ private: void readLICPart(const JsonNode & part, const TDecoder & decoder, const bool val, std::vector & value); void readLICPart(const JsonNode & part, const TDecoder & decoder, std::set & value); }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/AbilityCaster.cpp b/lib/spells/AbilityCaster.cpp index 0a9192d89..1e9d23c3c 100644 --- a/lib/spells/AbilityCaster.cpp +++ b/lib/spells/AbilityCaster.cpp @@ -15,6 +15,8 @@ #include "../battle/Unit.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { @@ -58,3 +60,5 @@ void AbilityCaster::spendMana(ServerCallback * server, const int32_t spellCost) } } // namespace spells + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/AbilityCaster.h b/lib/spells/AbilityCaster.h index 86585ffdc..2b9c7c2ff 100644 --- a/lib/spells/AbilityCaster.h +++ b/lib/spells/AbilityCaster.h @@ -12,6 +12,8 @@ #include "ProxyCaster.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { @@ -32,3 +34,5 @@ private: }; } // namespace spells + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/AdventureSpellMechanics.cpp b/lib/spells/AdventureSpellMechanics.cpp index b428db9e3..2d00da72b 100644 --- a/lib/spells/AdventureSpellMechanics.cpp +++ b/lib/spells/AdventureSpellMechanics.cpp @@ -21,6 +21,8 @@ #include "../mapping/CMap.h" #include "../CPlayerState.h" +VCMI_LIB_NAMESPACE_BEGIN + ///AdventureSpellMechanics AdventureSpellMechanics::AdventureSpellMechanics(const CSpell * s): IAdventureSpellMechanics(s) @@ -612,3 +614,5 @@ bool ViewEarthMechanics::filterObject(const CGObjectInstance * obj, const int32_ return (obj->ID == Obj::RESOURCE) || (spellLevel > 1 && obj->ID == Obj::MINE); } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/AdventureSpellMechanics.h b/lib/spells/AdventureSpellMechanics.h index f8860f8b6..9b6a5cf63 100644 --- a/lib/spells/AdventureSpellMechanics.h +++ b/lib/spells/AdventureSpellMechanics.h @@ -12,6 +12,8 @@ #include "ISpellMechanics.h" +VCMI_LIB_NAMESPACE_BEGIN + class CGTownInstance; enum class ESpellCastResult @@ -99,3 +101,5 @@ protected: }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/BattleSpellMechanics.cpp b/lib/spells/BattleSpellMechanics.cpp index 3ab3fd991..135c9eee2 100644 --- a/lib/spells/BattleSpellMechanics.cpp +++ b/lib/spells/BattleSpellMechanics.cpp @@ -20,6 +20,8 @@ #include "../CStack.h" #include "../NetPacks.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { @@ -674,3 +676,5 @@ const Spell * BattleSpellMechanics::getSpell() const } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/BattleSpellMechanics.h b/lib/spells/BattleSpellMechanics.h index d4a792412..3742f1b23 100644 --- a/lib/spells/BattleSpellMechanics.h +++ b/lib/spells/BattleSpellMechanics.h @@ -14,6 +14,8 @@ #include "effects/Effects.h" +VCMI_LIB_NAMESPACE_BEGIN + struct BattleSpellCast; namespace spells @@ -69,3 +71,5 @@ private: } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/BonusCaster.cpp b/lib/spells/BonusCaster.cpp index e6f2a8959..09cafa4bd 100644 --- a/lib/spells/BonusCaster.cpp +++ b/lib/spells/BonusCaster.cpp @@ -17,6 +17,8 @@ #include "../HeroBonus.h" #include "../battle/Unit.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { @@ -57,3 +59,5 @@ void BonusCaster::spendMana(ServerCallback * server, const int spellCost) const } // namespace spells + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/BonusCaster.h b/lib/spells/BonusCaster.h index c102c662b..12f888b77 100644 --- a/lib/spells/BonusCaster.h +++ b/lib/spells/BonusCaster.h @@ -12,6 +12,8 @@ #include "ProxyCaster.h" +VCMI_LIB_NAMESPACE_BEGIN + struct Bonus; namespace spells @@ -34,3 +36,5 @@ private: } // namespace spells + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/CSpellHandler.cpp b/lib/spells/CSpellHandler.cpp index aca31549c..6595ab950 100644 --- a/lib/spells/CSpellHandler.cpp +++ b/lib/spells/CSpellHandler.cpp @@ -32,6 +32,8 @@ #include "ISpellMechanics.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace SpellConfig { static const std::string LEVEL_NAMES[] = {"none", "basic", "advanced", "expert"}; @@ -1017,4 +1019,6 @@ std::vector CSpellHandler::getDefaultAllowed() const } return allowedSpells; -} \ No newline at end of file +} + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/CSpellHandler.h b/lib/spells/CSpellHandler.h index f821abc46..53345fcfe 100644 --- a/lib/spells/CSpellHandler.h +++ b/lib/spells/CSpellHandler.h @@ -21,6 +21,8 @@ #include "../battle/BattleHex.h" #include "../HeroBonus.h" +VCMI_LIB_NAMESPACE_BEGIN + class CSpell; class IAdventureSpellMechanics; class CBattleInfoCallback; @@ -391,3 +393,5 @@ protected: const std::vector & getTypeNames() const override; CSpell * loadFromJson(const std::string & scope, const JsonNode & json, const std::string & identifier, size_t index) override; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/ISpellMechanics.cpp b/lib/spells/ISpellMechanics.cpp index 29578ff56..1a14e0d53 100644 --- a/lib/spells/ISpellMechanics.cpp +++ b/lib/spells/ISpellMechanics.cpp @@ -42,6 +42,8 @@ #include "../IGameCallback.h"//todo: remove #include "../BattleFieldHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { @@ -776,3 +778,5 @@ std::unique_ptr IAdventureSpellMechanics::createMechan return std::unique_ptr(); } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/ISpellMechanics.h b/lib/spells/ISpellMechanics.h index 927a5a308..6206da9ba 100644 --- a/lib/spells/ISpellMechanics.h +++ b/lib/spells/ISpellMechanics.h @@ -18,6 +18,8 @@ #include "../GameConstants.h" #include "../HeroBonus.h" +VCMI_LIB_NAMESPACE_BEGIN + struct Query; class IBattleState; class CRandomGenerator; @@ -362,3 +364,5 @@ public: protected: const CSpell * owner; }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/Problem.cpp b/lib/spells/Problem.cpp index 6e8c76766..7d17d0bbc 100644 --- a/lib/spells/Problem.cpp +++ b/lib/spells/Problem.cpp @@ -11,6 +11,8 @@ #include "Problem.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { namespace detail @@ -52,3 +54,5 @@ void ProblemImpl::getAll(std::vector & target) const } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/Problem.h b/lib/spells/Problem.h index b5432d98f..c3d5e247d 100644 --- a/lib/spells/Problem.h +++ b/lib/spells/Problem.h @@ -14,6 +14,8 @@ #include "../NetPacksBase.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { namespace detail @@ -36,3 +38,5 @@ private: } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/ProxyCaster.cpp b/lib/spells/ProxyCaster.cpp index 1ae601b62..e93afe58c 100644 --- a/lib/spells/ProxyCaster.cpp +++ b/lib/spells/ProxyCaster.cpp @@ -13,6 +13,8 @@ #include "../GameConstants.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { @@ -85,3 +87,5 @@ void ProxyCaster::spendMana(ServerCallback * server, const int32_t spellCost) co } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/ProxyCaster.h b/lib/spells/ProxyCaster.h index f3656e880..b3829da7f 100644 --- a/lib/spells/ProxyCaster.h +++ b/lib/spells/ProxyCaster.h @@ -12,6 +12,8 @@ #include +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { @@ -39,3 +41,5 @@ private: }; } // namespace spells + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/TargetCondition.cpp b/lib/spells/TargetCondition.cpp index cb4ddc976..cdcc2086e 100644 --- a/lib/spells/TargetCondition.cpp +++ b/lib/spells/TargetCondition.cpp @@ -20,6 +20,8 @@ #include "../VCMI_Lib.h" #include "../CModHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { @@ -512,3 +514,5 @@ void TargetCondition::loadConditions(const JsonNode & source, bool exclusive, bo } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/TargetCondition.h b/lib/spells/TargetCondition.h index c5ab39b9e..36dd413ae 100644 --- a/lib/spells/TargetCondition.h +++ b/lib/spells/TargetCondition.h @@ -12,6 +12,8 @@ #include "ISpellMechanics.h" +VCMI_LIB_NAMESPACE_BEGIN + class JsonNode; class JsonSerializeFormat; @@ -83,3 +85,5 @@ private: }; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/ViewSpellInt.cpp b/lib/spells/ViewSpellInt.cpp index 950da1447..7d436f284 100644 --- a/lib/spells/ViewSpellInt.cpp +++ b/lib/spells/ViewSpellInt.cpp @@ -14,6 +14,8 @@ #include "../mapObjects/CObjectHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + ObjectPosInfo::ObjectPosInfo(): pos(), id(Obj::NO_OBJ), subId(-1), owner(PlayerColor::CANNOT_DETERMINE) { @@ -25,3 +27,5 @@ ObjectPosInfo::ObjectPosInfo(const CGObjectInstance * obj): { } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/ViewSpellInt.h b/lib/spells/ViewSpellInt.h index 67efe94c6..d570967bf 100644 --- a/lib/spells/ViewSpellInt.h +++ b/lib/spells/ViewSpellInt.h @@ -13,6 +13,8 @@ #include "../int3.h" #include "../GameConstants.h" +VCMI_LIB_NAMESPACE_BEGIN + class CGObjectInstance; struct DLL_LINKAGE ObjectPosInfo @@ -33,3 +35,5 @@ } }; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/Catapult.cpp b/lib/spells/effects/Catapult.cpp index f1ed4051f..660be493e 100644 --- a/lib/spells/effects/Catapult.cpp +++ b/lib/spells/effects/Catapult.cpp @@ -21,6 +21,8 @@ #include "../../mapObjects/CGTownInstance.h" #include "../../serializer/JsonSerializeFormat.h" +VCMI_LIB_NAMESPACE_BEGIN + static const std::string EFFECT_NAME = "core:catapult"; namespace spells @@ -152,3 +154,5 @@ void Catapult::serializeJsonEffect(JsonSerializeFormat & handler) } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/Catapult.h b/lib/spells/effects/Catapult.h index 762cd49d6..d03ef8e35 100644 --- a/lib/spells/effects/Catapult.h +++ b/lib/spells/effects/Catapult.h @@ -12,6 +12,8 @@ #include "LocationEffect.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { namespace effects @@ -34,3 +36,5 @@ private: } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/Clone.cpp b/lib/spells/effects/Clone.cpp index 97e9e7ebd..58c7e2b11 100644 --- a/lib/spells/effects/Clone.cpp +++ b/lib/spells/effects/Clone.cpp @@ -17,6 +17,8 @@ #include "../../battle/CUnitState.h" #include "../../serializer/JsonSerializeFormat.h" +VCMI_LIB_NAMESPACE_BEGIN + static const std::string EFFECT_NAME = "core:clone"; namespace spells @@ -137,3 +139,5 @@ void Clone::serializeJsonUnitEffect(JsonSerializeFormat & handler) } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/Clone.h b/lib/spells/effects/Clone.h index 8047a0e51..824551f6e 100644 --- a/lib/spells/effects/Clone.h +++ b/lib/spells/effects/Clone.h @@ -12,6 +12,8 @@ #include "UnitEffect.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { namespace effects @@ -35,3 +37,5 @@ private: } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/Damage.cpp b/lib/spells/effects/Damage.cpp index 2db14bf46..88b0d1848 100644 --- a/lib/spells/effects/Damage.cpp +++ b/lib/spells/effects/Damage.cpp @@ -20,6 +20,8 @@ #include "../../CGeneralTextHandler.h" #include "../../serializer/JsonSerializeFormat.h" +VCMI_LIB_NAMESPACE_BEGIN + static const std::string EFFECT_NAME = "core:damage"; namespace spells @@ -225,3 +227,5 @@ void Damage::describeEffect(std::vector & log, const Mechanics * m, } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/Damage.h b/lib/spells/effects/Damage.h index 27e6bb5af..699d5005d 100644 --- a/lib/spells/effects/Damage.h +++ b/lib/spells/effects/Damage.h @@ -12,6 +12,8 @@ #include "UnitEffect.h" +VCMI_LIB_NAMESPACE_BEGIN + struct StacksInjured; namespace spells @@ -44,3 +46,5 @@ private: } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/Dispel.cpp b/lib/spells/effects/Dispel.cpp index 06d41dfba..ffe6bb454 100644 --- a/lib/spells/effects/Dispel.cpp +++ b/lib/spells/effects/Dispel.cpp @@ -21,6 +21,8 @@ #include "../../battle/Unit.h" #include "../../serializer/JsonSerializeFormat.h" +VCMI_LIB_NAMESPACE_BEGIN + static const std::string EFFECT_NAME = "core:dispel"; namespace spells @@ -142,3 +144,5 @@ std::shared_ptr Dispel::getBonuses(const Mechanics * m, const b } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/Dispel.h b/lib/spells/effects/Dispel.h index bebb1200a..54667f25f 100644 --- a/lib/spells/effects/Dispel.h +++ b/lib/spells/effects/Dispel.h @@ -12,6 +12,8 @@ #include "UnitEffect.h" +VCMI_LIB_NAMESPACE_BEGIN + struct Bonus; class CSelector; class BonusList; @@ -44,3 +46,5 @@ private: } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/Effect.cpp b/lib/spells/effects/Effect.cpp index 77f240f51..cb0462f6a 100644 --- a/lib/spells/effects/Effect.cpp +++ b/lib/spells/effects/Effect.cpp @@ -14,6 +14,8 @@ #include "../../serializer/JsonSerializeFormat.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { namespace effects @@ -64,3 +66,5 @@ std::shared_ptr Effect::create(const Registry * registry, const std::str } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/Effect.h b/lib/spells/effects/Effect.h index 8ebf0f332..a8f6ec387 100644 --- a/lib/spells/effects/Effect.h +++ b/lib/spells/effects/Effect.h @@ -12,6 +12,8 @@ #include +VCMI_LIB_NAMESPACE_BEGIN + struct BattleHex; class CBattleInfoCallback; class JsonSerializeFormat; @@ -28,7 +30,7 @@ using EffectTarget = Target; namespace effects { -using RNG = ::vstd::RNG; +using RNG = vstd::RNG; class Effects; class Effect; class Registry; @@ -36,7 +38,7 @@ class Registry; template class RegisterEffect; -using TargetType = ::spells::AimType; +using TargetType = spells::AimType; class DLL_LINKAGE Effect { @@ -72,3 +74,5 @@ protected: } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/Effects.cpp b/lib/spells/effects/Effects.cpp index 4a300d49b..f953ab0a7 100644 --- a/lib/spells/effects/Effects.cpp +++ b/lib/spells/effects/Effects.cpp @@ -17,6 +17,8 @@ #include "../../serializer/JsonSerializeFormat.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { @@ -156,3 +158,5 @@ void Effects::serializeJson(const Registry * registry, JsonSerializeFormat & han } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/Effects.h b/lib/spells/effects/Effects.h index f9bc264df..7dc7f4e21 100644 --- a/lib/spells/effects/Effects.h +++ b/lib/spells/effects/Effects.h @@ -13,6 +13,8 @@ #include "Effect.h" #include "../../GameConstants.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { namespace effects @@ -46,3 +48,5 @@ public: } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/EffectsFwd.h b/lib/spells/effects/EffectsFwd.h index d9db3e64f..b7c2bf9e9 100644 --- a/lib/spells/effects/EffectsFwd.h +++ b/lib/spells/effects/EffectsFwd.h @@ -10,6 +10,8 @@ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { namespace effects @@ -21,3 +23,5 @@ class Effects; } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/Heal.cpp b/lib/spells/effects/Heal.cpp index 4d07e15dd..b192315b8 100644 --- a/lib/spells/effects/Heal.cpp +++ b/lib/spells/effects/Heal.cpp @@ -19,6 +19,8 @@ #include "../../battle/Unit.h" #include "../../serializer/JsonSerializeFormat.h" +VCMI_LIB_NAMESPACE_BEGIN + static const std::string EFFECT_NAME = "core:heal"; @@ -137,3 +139,5 @@ void Heal::prepareHealEffect(int64_t value, BattleUnitsChanged & pack, RNG & rng } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/Heal.h b/lib/spells/effects/Heal.h index 0160be35f..138935626 100644 --- a/lib/spells/effects/Heal.h +++ b/lib/spells/effects/Heal.h @@ -13,6 +13,8 @@ #include "UnitEffect.h" #include "../../GameConstants.h" +VCMI_LIB_NAMESPACE_BEGIN + struct BattleUnitsChanged; namespace spells @@ -45,3 +47,5 @@ private: } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/LocationEffect.cpp b/lib/spells/effects/LocationEffect.cpp index e66d80e63..5bd88dd74 100644 --- a/lib/spells/effects/LocationEffect.cpp +++ b/lib/spells/effects/LocationEffect.cpp @@ -12,6 +12,8 @@ #include "LocationEffect.h" #include "../ISpellMechanics.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { namespace effects @@ -53,3 +55,5 @@ EffectTarget LocationEffect::transformTarget(const Mechanics * m, const Target & } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/LocationEffect.h b/lib/spells/effects/LocationEffect.h index d51c9568d..b13a375c7 100644 --- a/lib/spells/effects/LocationEffect.h +++ b/lib/spells/effects/LocationEffect.h @@ -12,6 +12,8 @@ #include "Effect.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { @@ -38,3 +40,5 @@ private: } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/Obstacle.cpp b/lib/spells/effects/Obstacle.cpp index 99b4a7f5b..5f8cbcc3e 100644 --- a/lib/spells/effects/Obstacle.cpp +++ b/lib/spells/effects/Obstacle.cpp @@ -19,6 +19,8 @@ #include "../../battle/CBattleInfoCallback.h" #include "../../serializer/JsonSerializeFormat.h" +VCMI_LIB_NAMESPACE_BEGIN + static const std::string EFFECT_NAME = "core:obstacle"; namespace spells @@ -340,3 +342,5 @@ void Obstacle::placeObstacles(ServerCallback * server, const Mechanics * m, cons } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/Obstacle.h b/lib/spells/effects/Obstacle.h index bea14ee1c..5cc1fd215 100644 --- a/lib/spells/effects/Obstacle.h +++ b/lib/spells/effects/Obstacle.h @@ -14,6 +14,8 @@ #include "../../battle/BattleHex.h" #include "../../battle/CObstacleInstance.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { namespace effects @@ -77,3 +79,5 @@ private: } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/Registry.cpp b/lib/spells/effects/Registry.cpp index 5d12c2283..09cecd826 100644 --- a/lib/spells/effects/Registry.cpp +++ b/lib/spells/effects/Registry.cpp @@ -11,6 +11,8 @@ #include "Registry.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { namespace effects @@ -56,3 +58,5 @@ Registry * GlobalRegistry::get() } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/Registry.h b/lib/spells/effects/Registry.h index 8e0eeac17..2f4ae202b 100644 --- a/lib/spells/effects/Registry.h +++ b/lib/spells/effects/Registry.h @@ -19,6 +19,8 @@ RegisterEffect register ## Type(Name);\ }\ \ +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { namespace effects @@ -78,3 +80,5 @@ public: } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/RemoveObstacle.cpp b/lib/spells/effects/RemoveObstacle.cpp index 7e12568ba..1953668d3 100644 --- a/lib/spells/effects/RemoveObstacle.cpp +++ b/lib/spells/effects/RemoveObstacle.cpp @@ -20,6 +20,8 @@ #include "../../battle/CObstacleInstance.h" #include "../../serializer/JsonSerializeFormat.h" +VCMI_LIB_NAMESPACE_BEGIN + static const std::string EFFECT_NAME = "core:removeObstacle"; namespace spells @@ -112,3 +114,5 @@ std::set RemoveObstacle::getTargets(const Mechanics * } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/RemoveObstacle.h b/lib/spells/effects/RemoveObstacle.h index bdbc2dd31..3e159c6b3 100644 --- a/lib/spells/effects/RemoveObstacle.h +++ b/lib/spells/effects/RemoveObstacle.h @@ -14,6 +14,8 @@ #include "../../GameConstants.h" +VCMI_LIB_NAMESPACE_BEGIN + struct CObstacleInstance; struct BattleObstaclesChanged; @@ -50,3 +52,5 @@ private: } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/Sacrifice.cpp b/lib/spells/effects/Sacrifice.cpp index 52e60920d..5ec826006 100644 --- a/lib/spells/effects/Sacrifice.cpp +++ b/lib/spells/effects/Sacrifice.cpp @@ -19,6 +19,8 @@ #include "../../battle/Unit.h" #include "../../serializer/JsonSerializeFormat.h" +VCMI_LIB_NAMESPACE_BEGIN + static const std::string EFFECT_NAME = "core:sacrifice"; @@ -174,3 +176,5 @@ int64_t Sacrifice::calculateHealEffectValue(const Mechanics * m, const battle::U } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/Sacrifice.h b/lib/spells/effects/Sacrifice.h index e89ef0c48..b449bbc7d 100644 --- a/lib/spells/effects/Sacrifice.h +++ b/lib/spells/effects/Sacrifice.h @@ -12,6 +12,8 @@ #include "Heal.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { namespace effects @@ -41,3 +43,5 @@ private: } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/Summon.cpp b/lib/spells/effects/Summon.cpp index 2601f7d52..83082b012 100644 --- a/lib/spells/effects/Summon.cpp +++ b/lib/spells/effects/Summon.cpp @@ -22,6 +22,8 @@ #include "../../CHeroHandler.h" #include "../../mapObjects/CGHeroInstance.h" +VCMI_LIB_NAMESPACE_BEGIN + static const std::string EFFECT_NAME = "core:summon"; @@ -197,3 +199,5 @@ EffectTarget Summon::transformTarget(const Mechanics * m, const Target & aimPoin } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/Summon.h b/lib/spells/effects/Summon.h index d12d5373b..97991c612 100644 --- a/lib/spells/effects/Summon.h +++ b/lib/spells/effects/Summon.h @@ -13,6 +13,8 @@ #include "Effect.h" #include "../../GameConstants.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { namespace effects @@ -49,3 +51,5 @@ private: } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/Teleport.cpp b/lib/spells/effects/Teleport.cpp index 5501a189e..6df50f0aa 100644 --- a/lib/spells/effects/Teleport.cpp +++ b/lib/spells/effects/Teleport.cpp @@ -17,6 +17,8 @@ #include "../../battle/CBattleInfoCallback.h" #include "../../battle/Unit.h" +VCMI_LIB_NAMESPACE_BEGIN + //TODO: Teleport effect static const std::string EFFECT_NAME = "core:teleport"; @@ -122,3 +124,5 @@ EffectTarget Teleport::transformTarget(const Mechanics * m, const Target & aimPo } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/Teleport.h b/lib/spells/effects/Teleport.h index b547bf7f6..04707400e 100644 --- a/lib/spells/effects/Teleport.h +++ b/lib/spells/effects/Teleport.h @@ -12,6 +12,8 @@ #include "UnitEffect.h" +VCMI_LIB_NAMESPACE_BEGIN + struct BattleStackMoved; namespace spells @@ -39,3 +41,5 @@ protected: } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/Timed.cpp b/lib/spells/effects/Timed.cpp index 300fbedce..c9d6322f3 100644 --- a/lib/spells/effects/Timed.cpp +++ b/lib/spells/effects/Timed.cpp @@ -18,6 +18,8 @@ #include "../../battle/Unit.h" #include "../../serializer/JsonSerializeFormat.h" +VCMI_LIB_NAMESPACE_BEGIN + static const std::string EFFECT_NAME = "core:timed"; namespace spells @@ -276,3 +278,5 @@ void Timed::serializeJsonUnitEffect(JsonSerializeFormat & handler) } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/Timed.h b/lib/spells/effects/Timed.h index 34bbde91c..3867692f6 100644 --- a/lib/spells/effects/Timed.h +++ b/lib/spells/effects/Timed.h @@ -12,6 +12,8 @@ #include "UnitEffect.h" +VCMI_LIB_NAMESPACE_BEGIN + struct Bonus; struct SetStackEffect; struct MetaString; @@ -43,3 +45,5 @@ private: } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/UnitEffect.cpp b/lib/spells/effects/UnitEffect.cpp index 583d86b24..665842750 100644 --- a/lib/spells/effects/UnitEffect.cpp +++ b/lib/spells/effects/UnitEffect.cpp @@ -18,6 +18,8 @@ #include "../../battle/Unit.h" #include "../../serializer/JsonSerializeFormat.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { namespace effects @@ -291,3 +293,5 @@ void UnitEffect::serializeJsonEffect(JsonSerializeFormat & handler) } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/effects/UnitEffect.h b/lib/spells/effects/UnitEffect.h index 1b076c660..81456e2e6 100644 --- a/lib/spells/effects/UnitEffect.h +++ b/lib/spells/effects/UnitEffect.h @@ -12,6 +12,8 @@ #include "Effect.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { namespace effects @@ -58,3 +60,5 @@ private: } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/vcmi_endian.h b/lib/vcmi_endian.h index 865be44be..45db01bfb 100644 --- a/lib/vcmi_endian.h +++ b/lib/vcmi_endian.h @@ -12,6 +12,8 @@ //FIXME:library file depends on SDL - make cause troubles #include +VCMI_LIB_NAMESPACE_BEGIN + /* Reading values from memory. * * read_le_u16, read_le_u32 : read a little endian value from @@ -68,3 +70,5 @@ static inline std::string readString(const ui8 * buffer, int & i) } return ret; } + +VCMI_LIB_NAMESPACE_END diff --git a/lib/vstd/StringUtils.cpp b/lib/vstd/StringUtils.cpp index e46779026..51499078c 100644 --- a/lib/vstd/StringUtils.cpp +++ b/lib/vstd/StringUtils.cpp @@ -1,6 +1,8 @@ #include "StdInc.h" #include +VCMI_LIB_NAMESPACE_BEGIN + namespace vstd { @@ -30,3 +32,5 @@ namespace vstd } } + +VCMI_LIB_NAMESPACE_END diff --git a/lib_client/CMakeLists.txt b/lib_client/CMakeLists.txt new file mode 100644 index 000000000..f51966e22 --- /dev/null +++ b/lib_client/CMakeLists.txt @@ -0,0 +1,2 @@ +add_main_lib(vcmi_lib_client SHARED) +target_compile_definitions(vcmi_lib_client PUBLIC VCMI_LIB_NAMESPACE=LIB_CLIENT) diff --git a/lib_server/CMakeLists.txt b/lib_server/CMakeLists.txt new file mode 100644 index 000000000..e9d097e05 --- /dev/null +++ b/lib_server/CMakeLists.txt @@ -0,0 +1,2 @@ +add_main_lib(vcmi_lib_server STATIC) +target_compile_definitions(vcmi_lib_server PUBLIC VCMI_LIB_NAMESPACE=LIB_SERVER) diff --git a/osx/CMakeLists.txt b/osx/CMakeLists.txt index 91d343074..6fbcb041b 100644 --- a/osx/CMakeLists.txt +++ b/osx/CMakeLists.txt @@ -1,6 +1,6 @@ # We need to keep this code into separate directory so CMake will execute it after all other subdirectories install code # Otherwise we can't fix Mac bundle dependencies since binaries wouldn't be there when this code executed -if(APPLE) +if(APPLE_MACOS) set(bundleDir "\${CMAKE_INSTALL_PREFIX}/${APP_BUNDLE_DIR}") set(bundleContentsDir "${bundleDir}/Contents") @@ -58,4 +58,4 @@ if(APPLE) ) endforeach() ") -endif(APPLE) \ No newline at end of file +endif() diff --git a/scripting/erm/CMakeLists.txt b/scripting/erm/CMakeLists.txt index c691094b7..99da95142 100644 --- a/scripting/erm/CMakeLists.txt +++ b/scripting/erm/CMakeLists.txt @@ -15,9 +15,13 @@ set(lib_HDRS ) add_library(vcmiERM SHARED ${lib_SRCS} ${lib_HDRS}) -target_link_libraries(vcmiERM Boost::boost vcmi) +target_link_libraries(vcmiERM Boost::boost ${VCMI_LIB_TARGET}) vcmi_set_output_dir(vcmiERM "scripting") enable_pch(vcmiERM) -install(TARGETS vcmiERM DESTINATION ${SCRIPTING_LIB_DIR}) +if(APPLE_IOS) + install(TARGETS vcmiERM LIBRARY DESTINATION ${SCRIPTING_LIB_DIR}) +else() + install(TARGETS vcmiERM DESTINATION ${SCRIPTING_LIB_DIR}) +endif() diff --git a/scripting/erm/StdInc.h b/scripting/erm/StdInc.h index 76f778c6e..02b2c08f3 100644 --- a/scripting/erm/StdInc.h +++ b/scripting/erm/StdInc.h @@ -6,3 +6,4 @@ // Here you can add specific libraries and macros which are specific to this project. +VCMI_LIB_USING_NAMESPACE diff --git a/scripting/lua/CMakeLists.txt b/scripting/lua/CMakeLists.txt index 1d43aca7a..a376c62c7 100644 --- a/scripting/lua/CMakeLists.txt +++ b/scripting/lua/CMakeLists.txt @@ -39,13 +39,60 @@ set(lib_SRCS api/StackInstance.cpp ) -add_library(vcmiLua SHARED ${lib_SRCS}) -target_link_libraries(vcmiLua Boost::boost luajit::luajit vcmi) +set(lib_HDRS + StdInc.h + LuaCallWrapper.h + LuaFunctor.h + LuaReference.h + LuaScriptModule.h + LuaScriptingContext.h + LuaSpellEffect.h + LuaStack.h + LuaWrapper.h + + api/battle/UnitProxy.h + + api/events/BattleEvents.h + api/events/EventBusProxy.h + api/events/GenericEvents.h + api/events/SubscriptionRegistryProxy.h + + api/netpacks/BattleLogMessage.h + api/netpacks/BattleStackMoved.h + api/netpacks/BattleUnitsChanged.h + api/netpacks/EntitiesChanged.h + api/netpacks/InfoWindow.h + api/netpacks/PackForClient.h + api/netpacks/SetResources.h + + api/Artifact.h + api/BattleCb.h + api/BonusSystem.h + api/Creature.h + api/Faction.h + api/GameCb.h + api/HeroClass.h + api/HeroInstance.h + api/HeroType.h + api/Registry.h + api/ServerCb.h + api/Services.h + api/Skill.h + api/Spell.h + api/StackInstance.h +) + +add_library(vcmiLua SHARED ${lib_SRCS} ${lib_HDRS}) +target_link_libraries(vcmiLua Boost::boost luajit::luajit ${VCMI_LIB_TARGET}) vcmi_set_output_dir(vcmiLua "scripting") enable_pch(vcmiLua) -install(TARGETS vcmiLua DESTINATION ${SCRIPTING_LIB_DIR}) +if(APPLE_IOS) + install(TARGETS vcmiLua LIBRARY DESTINATION ${SCRIPTING_LIB_DIR}) +else() + install(TARGETS vcmiLua DESTINATION ${SCRIPTING_LIB_DIR}) +endif() #manually copy lua dll from vcpkg folder to build directory on windows since vcpkg deps copy feature has flaws, using hardcoded paths based on vcmi windows deps package 1.1 from github if(MSVC) diff --git a/scripting/lua/LuaCallWrapper.h b/scripting/lua/LuaCallWrapper.h index d3f674a42..c098116a3 100644 --- a/scripting/lua/LuaCallWrapper.h +++ b/scripting/lua/LuaCallWrapper.h @@ -13,6 +13,8 @@ #include "api/Registry.h" #include "LuaStack.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { @@ -329,3 +331,5 @@ public: }; } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/LuaFunctor.h b/scripting/lua/LuaFunctor.h index 148062e91..5daab6262 100644 --- a/scripting/lua/LuaFunctor.h +++ b/scripting/lua/LuaFunctor.h @@ -10,6 +10,8 @@ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { @@ -21,3 +23,5 @@ public: }; } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/LuaReference.cpp b/scripting/lua/LuaReference.cpp index 3cc0f7d42..a5b8c2f44 100644 --- a/scripting/lua/LuaReference.cpp +++ b/scripting/lua/LuaReference.cpp @@ -11,6 +11,8 @@ #include "LuaReference.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { @@ -42,3 +44,5 @@ void LuaReference::push() } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/LuaReference.h b/scripting/lua/LuaReference.h index c28bac405..22290aa55 100644 --- a/scripting/lua/LuaReference.h +++ b/scripting/lua/LuaReference.h @@ -10,6 +10,8 @@ #pragma once +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { @@ -31,3 +33,4 @@ private: } +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/LuaScriptModule.cpp b/scripting/lua/LuaScriptModule.cpp index 302d30762..ab2f350b2 100644 --- a/scripting/lua/LuaScriptModule.cpp +++ b/scripting/lua/LuaScriptModule.cpp @@ -19,6 +19,8 @@ const char *g_cszAiName = "Lua interpreter"; +VCMI_LIB_NAMESPACE_BEGIN + extern "C" DLL_EXPORT void GetAiName(char * name) { strcpy_s(name, strlen(g_cszAiName) + 1, g_cszAiName); @@ -54,3 +56,5 @@ void LuaScriptModule::registerSpellEffect(spells::effects::Registry * registry, } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/LuaScriptModule.h b/scripting/lua/LuaScriptModule.h index 7bdfbc4b3..af64c3ebe 100644 --- a/scripting/lua/LuaScriptModule.h +++ b/scripting/lua/LuaScriptModule.h @@ -12,6 +12,8 @@ #include "../../lib/CScriptingModule.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { @@ -31,3 +33,5 @@ private: }; } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/LuaScriptingContext.cpp b/scripting/lua/LuaScriptingContext.cpp index 1b438b3e8..8fe13d813 100644 --- a/scripting/lua/LuaScriptingContext.cpp +++ b/scripting/lua/LuaScriptingContext.cpp @@ -26,6 +26,8 @@ #include "../../lib/CGameInfoCallback.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { @@ -605,3 +607,5 @@ int LuaContext::logErrorImpl() } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/LuaScriptingContext.h b/scripting/lua/LuaScriptingContext.h index 5ea346883..b563f8f1e 100644 --- a/scripting/lua/LuaScriptingContext.h +++ b/scripting/lua/LuaScriptingContext.h @@ -16,6 +16,8 @@ #include "../../lib/ScriptHandler.h" #include "../../lib/CScriptingModule.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { @@ -88,3 +90,5 @@ private: }; } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/LuaSpellEffect.cpp b/scripting/lua/LuaSpellEffect.cpp index d082cffe6..e698e52eb 100644 --- a/scripting/lua/LuaSpellEffect.cpp +++ b/scripting/lua/LuaSpellEffect.cpp @@ -24,6 +24,8 @@ static const std::string APPLICABLE_GENERAL = "applicable"; static const std::string APPLICABLE_TARGET = "applicableTarget"; static const std::string APPLY = "apply"; +VCMI_LIB_NAMESPACE_BEGIN + namespace spells { namespace effects @@ -184,3 +186,5 @@ void LuaSpellEffect::setContextVariables(const Mechanics * m, std::shared_ptr ArtifactProxy::REGISTER_CUSTOM = } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/Artifact.h b/scripting/lua/api/Artifact.h index bc26998bb..b20d8ad7a 100644 --- a/scripting/lua/api/Artifact.h +++ b/scripting/lua/api/Artifact.h @@ -14,6 +14,8 @@ #include "../LuaWrapper.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -29,3 +31,5 @@ public: } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/BattleCb.cpp b/scripting/lua/api/BattleCb.cpp index 0f8127797..098012ed4 100644 --- a/scripting/lua/api/BattleCb.cpp +++ b/scripting/lua/api/BattleCb.cpp @@ -19,6 +19,8 @@ #include "../../../lib/battle/Unit.h" #include "../../../lib/BattleFieldHandler.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -114,3 +116,5 @@ int BattleCbProxy::getUnitByPos(lua_State * L) } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/BattleCb.h b/scripting/lua/api/BattleCb.h index 1f3edfd7a..44bff6679 100644 --- a/scripting/lua/api/BattleCb.h +++ b/scripting/lua/api/BattleCb.h @@ -15,6 +15,8 @@ #include "../LuaWrapper.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -34,3 +36,5 @@ public: } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/BonusSystem.cpp b/scripting/lua/api/BonusSystem.cpp index 5aa67db9f..cb03f6481 100644 --- a/scripting/lua/api/BonusSystem.cpp +++ b/scripting/lua/api/BonusSystem.cpp @@ -18,6 +18,8 @@ #include "../LuaStack.h" #include "../LuaCallWrapper.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -253,3 +255,5 @@ int BonusBearerProxy::getBonuses(lua_State * L) } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/BonusSystem.h b/scripting/lua/api/BonusSystem.h index a6baa4ecb..657243670 100644 --- a/scripting/lua/api/BonusSystem.h +++ b/scripting/lua/api/BonusSystem.h @@ -12,6 +12,8 @@ #include "../LuaWrapper.h" +VCMI_LIB_NAMESPACE_BEGIN + struct Bonus; class BonusList; class IBonusBearer; @@ -70,3 +72,5 @@ public: } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/Creature.cpp b/scripting/lua/api/Creature.cpp index 17d9a81d6..0b4713a83 100644 --- a/scripting/lua/api/Creature.cpp +++ b/scripting/lua/api/Creature.cpp @@ -17,6 +17,8 @@ #include "../LuaCallWrapper.h" #include "../../../lib/HeroBonus.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -60,3 +62,5 @@ const std::vector CreatureProxy::REGISTER_CUSTOM = } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/Creature.h b/scripting/lua/api/Creature.h index e69f60231..f13a81296 100644 --- a/scripting/lua/api/Creature.h +++ b/scripting/lua/api/Creature.h @@ -14,6 +14,8 @@ #include "../LuaWrapper.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -30,3 +32,5 @@ public: } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/Faction.cpp b/scripting/lua/api/Faction.cpp index d1fa96010..358c43dcb 100644 --- a/scripting/lua/api/Faction.cpp +++ b/scripting/lua/api/Faction.cpp @@ -16,6 +16,8 @@ #include "../LuaStack.h" #include "../LuaCallWrapper.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -34,3 +36,5 @@ const std::vector FactionProxy::REGISTER_CUSTOM = } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/Faction.h b/scripting/lua/api/Faction.h index 19b8f170d..1c11ae1fa 100644 --- a/scripting/lua/api/Faction.h +++ b/scripting/lua/api/Faction.h @@ -14,6 +14,8 @@ #include "../LuaWrapper.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -28,3 +30,5 @@ public: } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/GameCb.cpp b/scripting/lua/api/GameCb.cpp index 7387fe9cf..5bf19b3df 100644 --- a/scripting/lua/api/GameCb.cpp +++ b/scripting/lua/api/GameCb.cpp @@ -17,6 +17,8 @@ #include "../../../lib/mapObjects/CGHeroInstance.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -39,3 +41,5 @@ const std::vector GameCbProxy::REGISTER_CUSTOM = } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/GameCb.h b/scripting/lua/api/GameCb.h index d485b0c06..5374de6b9 100644 --- a/scripting/lua/api/GameCb.h +++ b/scripting/lua/api/GameCb.h @@ -15,6 +15,8 @@ #include "../LuaWrapper.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -31,3 +33,5 @@ public: } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/HeroClass.cpp b/scripting/lua/api/HeroClass.cpp index 874b72a63..03835c4e5 100644 --- a/scripting/lua/api/HeroClass.cpp +++ b/scripting/lua/api/HeroClass.cpp @@ -16,6 +16,8 @@ #include "../LuaStack.h" #include "../LuaCallWrapper.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -32,3 +34,5 @@ const std::vector HeroClassProxy::REGISTER_CUSTOM } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/HeroClass.h b/scripting/lua/api/HeroClass.h index 9c228a21e..0e95ecdfd 100644 --- a/scripting/lua/api/HeroClass.h +++ b/scripting/lua/api/HeroClass.h @@ -14,6 +14,8 @@ #include "../LuaWrapper.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -29,3 +31,5 @@ public: } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/HeroInstance.cpp b/scripting/lua/api/HeroInstance.cpp index ba1e77630..c00d2c7de 100644 --- a/scripting/lua/api/HeroInstance.cpp +++ b/scripting/lua/api/HeroInstance.cpp @@ -16,6 +16,8 @@ #include "../LuaStack.h" #include "../LuaCallWrapper.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -31,3 +33,4 @@ const std::vector HeroInstanceProxy::REGISTER_ } } +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/HeroInstance.h b/scripting/lua/api/HeroInstance.h index a446e4ede..0b1503a84 100644 --- a/scripting/lua/api/HeroInstance.h +++ b/scripting/lua/api/HeroInstance.h @@ -16,6 +16,8 @@ #include "../../../lib/mapObjects/CGHeroInstance.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -32,3 +34,4 @@ public: } } +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/HeroType.cpp b/scripting/lua/api/HeroType.cpp index f7630731e..c48ee8f48 100644 --- a/scripting/lua/api/HeroType.cpp +++ b/scripting/lua/api/HeroType.cpp @@ -16,6 +16,8 @@ #include "../LuaStack.h" #include "../LuaCallWrapper.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -34,3 +36,5 @@ const std::vector HeroTypeProxy::REGISTER_CUSTOM = } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/HeroType.h b/scripting/lua/api/HeroType.h index d41f695e6..558ee4d4b 100644 --- a/scripting/lua/api/HeroType.h +++ b/scripting/lua/api/HeroType.h @@ -14,6 +14,8 @@ #include "../LuaWrapper.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -29,3 +31,5 @@ public: } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/ObjectInstance.cpp b/scripting/lua/api/ObjectInstance.cpp index dd13c3f15..34feb946a 100644 --- a/scripting/lua/api/ObjectInstance.cpp +++ b/scripting/lua/api/ObjectInstance.cpp @@ -34,3 +34,5 @@ const std::vector ObjectInstanceProxy::REGIS } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/ObjectInstance.h b/scripting/lua/api/ObjectInstance.h index 5e4513886..a5542a650 100644 --- a/scripting/lua/api/ObjectInstance.h +++ b/scripting/lua/api/ObjectInstance.h @@ -32,3 +32,5 @@ public: } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/Player.cpp b/scripting/lua/api/Player.cpp index c80ab8407..f5d0c12ef 100644 --- a/scripting/lua/api/Player.cpp +++ b/scripting/lua/api/Player.cpp @@ -36,3 +36,5 @@ const std::vector PlayerProxy::REGISTER_CUSTOM = } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/Player.h b/scripting/lua/api/Player.h index 71aa808a4..74a7e6f8b 100644 --- a/scripting/lua/api/Player.h +++ b/scripting/lua/api/Player.h @@ -29,3 +29,5 @@ public: } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/Registry.cpp b/scripting/lua/api/Registry.cpp index 10eabb014..5af09bc55 100644 --- a/scripting/lua/api/Registry.cpp +++ b/scripting/lua/api/Registry.cpp @@ -11,6 +11,8 @@ #include "api/Registry.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -86,3 +88,5 @@ const char * TypeRegistry::getKeyForType(const std::type_info & type) } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/Registry.h b/scripting/lua/api/Registry.h index c3148412c..d9a168c37 100644 --- a/scripting/lua/api/Registry.h +++ b/scripting/lua/api/Registry.h @@ -27,6 +27,8 @@ RegisterCoreAPI _register ## Type (Name);\ }\ \ +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -108,3 +110,5 @@ private: } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/ServerCb.cpp b/scripting/lua/api/ServerCb.cpp index 10887d60b..f448efb54 100644 --- a/scripting/lua/api/ServerCb.cpp +++ b/scripting/lua/api/ServerCb.cpp @@ -15,6 +15,9 @@ #include "../LuaStack.h" #include "../../../lib/NetPacks.h" + +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -100,3 +103,5 @@ int ServerCbProxy::apply(lua_State * L) } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/ServerCb.h b/scripting/lua/api/ServerCb.h index fc2ec656a..b0c069d85 100644 --- a/scripting/lua/api/ServerCb.h +++ b/scripting/lua/api/ServerCb.h @@ -14,6 +14,8 @@ #include "../LuaWrapper.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -33,3 +35,5 @@ public: } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/Services.cpp b/scripting/lua/api/Services.cpp index 78bfcbde6..5782f3b30 100644 --- a/scripting/lua/api/Services.cpp +++ b/scripting/lua/api/Services.cpp @@ -26,6 +26,8 @@ #include "../LuaCallWrapper.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -95,3 +97,5 @@ const std::vector SpellServiceProxy::REGISTER_ } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/Services.h b/scripting/lua/api/Services.h index 192caa41c..55392fe1a 100644 --- a/scripting/lua/api/Services.h +++ b/scripting/lua/api/Services.h @@ -22,6 +22,8 @@ #include "../LuaWrapper.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -87,3 +89,5 @@ public: } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/Skill.cpp b/scripting/lua/api/Skill.cpp index f322bf3bd..bf00a0cca 100644 --- a/scripting/lua/api/Skill.cpp +++ b/scripting/lua/api/Skill.cpp @@ -16,6 +16,8 @@ #include "../LuaStack.h" #include "../LuaCallWrapper.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -32,3 +34,5 @@ const std::vector SkillProxy::REGISTER_CUSTOM = } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/Skill.h b/scripting/lua/api/Skill.h index 8fa107ab8..28296f9bd 100644 --- a/scripting/lua/api/Skill.h +++ b/scripting/lua/api/Skill.h @@ -14,6 +14,8 @@ #include "../LuaWrapper.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -29,3 +31,5 @@ public: } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/Spell.cpp b/scripting/lua/api/Spell.cpp index 78ebc8444..cd3eb9a3f 100644 --- a/scripting/lua/api/Spell.cpp +++ b/scripting/lua/api/Spell.cpp @@ -16,6 +16,8 @@ #include "../LuaStack.h" #include "../LuaCallWrapper.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -51,3 +53,5 @@ const std::vector SpellProxy::REGISTER_CUSTOM = } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/Spell.h b/scripting/lua/api/Spell.h index 18fe7c2dd..1e0e9c88f 100644 --- a/scripting/lua/api/Spell.h +++ b/scripting/lua/api/Spell.h @@ -14,6 +14,8 @@ #include "../LuaWrapper.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -28,3 +30,5 @@ public: } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/StackInstance.cpp b/scripting/lua/api/StackInstance.cpp index 05c608693..b413a823f 100644 --- a/scripting/lua/api/StackInstance.cpp +++ b/scripting/lua/api/StackInstance.cpp @@ -17,6 +17,8 @@ #include "../LuaCallWrapper.h" #include +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -33,3 +35,4 @@ const std::vector StackInstanceProxy::REGISTE } } +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/StackInstance.h b/scripting/lua/api/StackInstance.h index b9f8b6fa5..47e0f5ea1 100644 --- a/scripting/lua/api/StackInstance.h +++ b/scripting/lua/api/StackInstance.h @@ -16,6 +16,8 @@ #include "../../../lib/CCreatureSet.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -32,3 +34,4 @@ public: } } +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/battle/UnitProxy.cpp b/scripting/lua/api/battle/UnitProxy.cpp index f99c2d63a..472861bad 100644 --- a/scripting/lua/api/battle/UnitProxy.cpp +++ b/scripting/lua/api/battle/UnitProxy.cpp @@ -16,6 +16,8 @@ #include "../../LuaCallWrapper.h" #include "../Registry.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -38,3 +40,5 @@ const std::vector UnitProxy::REGISTER_CUSTOM = } } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/battle/UnitProxy.h b/scripting/lua/api/battle/UnitProxy.h index 732b89148..e654b36cf 100644 --- a/scripting/lua/api/battle/UnitProxy.h +++ b/scripting/lua/api/battle/UnitProxy.h @@ -15,6 +15,8 @@ #include "../../LuaWrapper.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -34,3 +36,5 @@ public: } } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/events/AdventureEvents.cpp b/scripting/lua/api/events/AdventureEvents.cpp index b51beb163..f09081a85 100644 --- a/scripting/lua/api/events/AdventureEvents.cpp +++ b/scripting/lua/api/events/AdventureEvents.cpp @@ -38,3 +38,5 @@ const std::vector ObjectVisitStartedProx } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/events/AdventureEvents.h b/scripting/lua/api/events/AdventureEvents.h index a1f60e081..3a4beccbc 100644 --- a/scripting/lua/api/events/AdventureEvents.h +++ b/scripting/lua/api/events/AdventureEvents.h @@ -38,3 +38,5 @@ public: } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/events/BattleEvents.cpp b/scripting/lua/api/events/BattleEvents.cpp index d89a0af1b..6196f3c90 100644 --- a/scripting/lua/api/events/BattleEvents.cpp +++ b/scripting/lua/api/events/BattleEvents.cpp @@ -17,6 +17,8 @@ #include "../../../../lib/battle/Unit.h" #include "SubscriptionRegistryProxy.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -66,3 +68,5 @@ const std::vector ApplyDamageProxy::REGISTER_CU } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/events/BattleEvents.h b/scripting/lua/api/events/BattleEvents.h index 6d03cca0e..172f23fec 100644 --- a/scripting/lua/api/events/BattleEvents.h +++ b/scripting/lua/api/events/BattleEvents.h @@ -16,6 +16,8 @@ #include "EventBusProxy.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -34,4 +36,4 @@ public: } } - +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/events/EventBusProxy.cpp b/scripting/lua/api/events/EventBusProxy.cpp index 64f57c47d..8806d2fcd 100644 --- a/scripting/lua/api/events/EventBusProxy.cpp +++ b/scripting/lua/api/events/EventBusProxy.cpp @@ -16,6 +16,8 @@ #include "../Registry.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -30,3 +32,4 @@ const std::vector EventBusProxy::REGISTER_CUSTOM = } } +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/events/EventBusProxy.h b/scripting/lua/api/events/EventBusProxy.h index 6930b71d9..fb53210d9 100644 --- a/scripting/lua/api/events/EventBusProxy.h +++ b/scripting/lua/api/events/EventBusProxy.h @@ -14,6 +14,8 @@ #include "../../LuaWrapper.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -31,3 +33,5 @@ public: } } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/events/GenericEvents.cpp b/scripting/lua/api/events/GenericEvents.cpp index efa398ef5..8b42dcfc4 100644 --- a/scripting/lua/api/events/GenericEvents.cpp +++ b/scripting/lua/api/events/GenericEvents.cpp @@ -16,6 +16,8 @@ #include "../Registry.h" #include "SubscriptionRegistryProxy.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -86,3 +88,5 @@ const std::vector TurnStartedProxy::REGISTER_CU } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/events/GenericEvents.h b/scripting/lua/api/events/GenericEvents.h index 63294651b..bcd51dc50 100644 --- a/scripting/lua/api/events/GenericEvents.h +++ b/scripting/lua/api/events/GenericEvents.h @@ -16,6 +16,8 @@ #include "EventBusProxy.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -48,4 +50,4 @@ public: } } - +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/events/SubscriptionRegistryProxy.cpp b/scripting/lua/api/events/SubscriptionRegistryProxy.cpp index 0dd1c4602..cef1fcca0 100644 --- a/scripting/lua/api/events/SubscriptionRegistryProxy.cpp +++ b/scripting/lua/api/events/SubscriptionRegistryProxy.cpp @@ -13,6 +13,8 @@ #include "../Registry.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -25,3 +27,5 @@ const std::vector EventSubscriptionProxy: } } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/events/SubscriptionRegistryProxy.h b/scripting/lua/api/events/SubscriptionRegistryProxy.h index 430f7a0a4..b84002051 100644 --- a/scripting/lua/api/events/SubscriptionRegistryProxy.h +++ b/scripting/lua/api/events/SubscriptionRegistryProxy.h @@ -18,6 +18,8 @@ #include "../../LuaStack.h" #include "../../LuaReference.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -128,3 +130,5 @@ public: } } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/netpacks/BattleLogMessage.cpp b/scripting/lua/api/netpacks/BattleLogMessage.cpp index dbd03f4c5..77f87fe1b 100644 --- a/scripting/lua/api/netpacks/BattleLogMessage.cpp +++ b/scripting/lua/api/netpacks/BattleLogMessage.cpp @@ -15,6 +15,8 @@ #include "../Registry.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -56,3 +58,5 @@ int BattleLogMessageProxy::addText(lua_State * L) } } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/netpacks/BattleLogMessage.h b/scripting/lua/api/netpacks/BattleLogMessage.h index bf0c240d8..ebe6f049e 100644 --- a/scripting/lua/api/netpacks/BattleLogMessage.h +++ b/scripting/lua/api/netpacks/BattleLogMessage.h @@ -12,6 +12,8 @@ #include "PackForClient.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -32,3 +34,5 @@ public: } } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/netpacks/BattleStackMoved.cpp b/scripting/lua/api/netpacks/BattleStackMoved.cpp index 8661223da..888b1422e 100644 --- a/scripting/lua/api/netpacks/BattleStackMoved.cpp +++ b/scripting/lua/api/netpacks/BattleStackMoved.cpp @@ -15,6 +15,8 @@ #include "../Registry.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -82,3 +84,5 @@ int BattleStackMovedProxy::setTeleporting(lua_State * L) } } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/netpacks/BattleStackMoved.h b/scripting/lua/api/netpacks/BattleStackMoved.h index e46346119..3926a737e 100644 --- a/scripting/lua/api/netpacks/BattleStackMoved.h +++ b/scripting/lua/api/netpacks/BattleStackMoved.h @@ -12,6 +12,8 @@ #include "PackForClient.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -35,3 +37,5 @@ public: } } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/netpacks/BattleUnitsChanged.cpp b/scripting/lua/api/netpacks/BattleUnitsChanged.cpp index 07dc93cf4..5a938a396 100644 --- a/scripting/lua/api/netpacks/BattleUnitsChanged.cpp +++ b/scripting/lua/api/netpacks/BattleUnitsChanged.cpp @@ -15,6 +15,8 @@ #include "../Registry.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -112,3 +114,5 @@ int BattleUnitsChangedProxy::remove(lua_State * L) } } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/netpacks/BattleUnitsChanged.h b/scripting/lua/api/netpacks/BattleUnitsChanged.h index 269db559e..2344076e3 100644 --- a/scripting/lua/api/netpacks/BattleUnitsChanged.h +++ b/scripting/lua/api/netpacks/BattleUnitsChanged.h @@ -12,6 +12,8 @@ #include "PackForClient.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -35,3 +37,5 @@ public: } } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/netpacks/EntitiesChanged.cpp b/scripting/lua/api/netpacks/EntitiesChanged.cpp index fa62eb2a9..2765d9480 100644 --- a/scripting/lua/api/netpacks/EntitiesChanged.cpp +++ b/scripting/lua/api/netpacks/EntitiesChanged.cpp @@ -15,6 +15,8 @@ #include "../Registry.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -61,3 +63,5 @@ int EntitiesChangedProxy::update(lua_State * L) } } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/netpacks/EntitiesChanged.h b/scripting/lua/api/netpacks/EntitiesChanged.h index 362fe4134..4b7e0f0b8 100644 --- a/scripting/lua/api/netpacks/EntitiesChanged.h +++ b/scripting/lua/api/netpacks/EntitiesChanged.h @@ -10,9 +10,10 @@ #pragma once - #include "PackForClient.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -33,3 +34,5 @@ public: } } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/netpacks/InfoWindow.cpp b/scripting/lua/api/netpacks/InfoWindow.cpp index 5ae41afb0..41899448c 100644 --- a/scripting/lua/api/netpacks/InfoWindow.cpp +++ b/scripting/lua/api/netpacks/InfoWindow.cpp @@ -15,6 +15,8 @@ #include "../Registry.h" +VCMI_LIB_NAMESPACE_BEGIN + using scripting::api::netpacks::InfoWindowProxy; using scripting::api::RegisterAPI; @@ -126,3 +128,5 @@ int InfoWindowProxy::setPlayer(lua_State * L) } } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/netpacks/InfoWindow.h b/scripting/lua/api/netpacks/InfoWindow.h index 099ce923b..f941761f8 100644 --- a/scripting/lua/api/netpacks/InfoWindow.h +++ b/scripting/lua/api/netpacks/InfoWindow.h @@ -12,6 +12,8 @@ #include "PackForClient.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -33,3 +35,5 @@ public: } } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/netpacks/PackForClient.h b/scripting/lua/api/netpacks/PackForClient.h index 71618b68b..c81732ce3 100644 --- a/scripting/lua/api/netpacks/PackForClient.h +++ b/scripting/lua/api/netpacks/PackForClient.h @@ -14,6 +14,8 @@ #include "../../../../lib/NetPacks.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -43,3 +45,5 @@ public: } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/netpacks/SetResources.cpp b/scripting/lua/api/netpacks/SetResources.cpp index 37ae5ac83..af09837f9 100644 --- a/scripting/lua/api/netpacks/SetResources.cpp +++ b/scripting/lua/api/netpacks/SetResources.cpp @@ -15,6 +15,8 @@ #include "../Registry.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -157,3 +159,5 @@ int SetResourcesProxy::clear(lua_State * L) } } } + +VCMI_LIB_NAMESPACE_END diff --git a/scripting/lua/api/netpacks/SetResources.h b/scripting/lua/api/netpacks/SetResources.h index b555e71f2..d58908240 100644 --- a/scripting/lua/api/netpacks/SetResources.h +++ b/scripting/lua/api/netpacks/SetResources.h @@ -12,6 +12,8 @@ #include "PackForClient.h" +VCMI_LIB_NAMESPACE_BEGIN + namespace scripting { namespace api @@ -38,3 +40,5 @@ public: } } } + +VCMI_LIB_NAMESPACE_END diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 0604c48e8..9174f80a7 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -91,6 +91,7 @@ private: CGameHandler * gh; }; +VCMI_LIB_NAMESPACE_BEGIN namespace spells { @@ -185,6 +186,7 @@ private: }; }// +VCMI_LIB_NAMESPACE_END CondSh battleMadeAction(false); CondSh battleResult(nullptr); diff --git a/server/CGameHandler.h b/server/CGameHandler.h index 279fca93e..bcb69f2e8 100644 --- a/server/CGameHandler.h +++ b/server/CGameHandler.h @@ -18,8 +18,8 @@ #include "../lib/ScriptHandler.h" #include "CQuery.h" -class CGameHandler; -class CVCMIServer; +VCMI_LIB_NAMESPACE_BEGIN + class CGameState; struct StartInfo; struct BattleResult; @@ -43,6 +43,11 @@ namespace scripting template class CApplier; + +VCMI_LIB_NAMESPACE_END + +class CGameHandler; +class CVCMIServer; class CBaseForGHApply; struct PlayerStatus diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 653703d11..0f0313114 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -22,9 +22,14 @@ if(ANDROID) # android needs client/server to be libraries, not executables, so w return() endif() -add_executable(vcmiserver ${server_SRCS} ${server_HEADERS}) +if(BUILD_SINGLE_APP) + add_library(vcmiserver STATIC ${server_SRCS} ${server_HEADERS}) + set(server_LIBS vcmi_lib_server) +else() + add_executable(vcmiserver ${server_SRCS} ${server_HEADERS}) + set(server_LIBS vcmi) +endif() -set(server_LIBS vcmi) if(CMAKE_SYSTEM_NAME MATCHES FreeBSD) set(server_LIBS execinfo ${server_LIBS}) endif() @@ -45,4 +50,6 @@ endif() vcmi_set_output_dir(vcmiserver "") enable_pch(vcmiserver) -install(TARGETS vcmiserver DESTINATION ${BIN_DIR}) +if(NOT BUILD_SINGLE_APP) + install(TARGETS vcmiserver DESTINATION ${BIN_DIR}) +endif() diff --git a/server/CQuery.h b/server/CQuery.h index 45f6c11f3..aa5446f3c 100644 --- a/server/CQuery.h +++ b/server/CQuery.h @@ -12,9 +12,14 @@ #include "../lib/int3.h" #include "../lib/NetPacks.h" +VCMI_LIB_NAMESPACE_BEGIN + class CGObjectInstance; class CGHeroInstance; class CArmedInstance; + +VCMI_LIB_NAMESPACE_END + class CGameHandler; class CObjectVisitQuery; class CQuery; diff --git a/server/CVCMIServer.cpp b/server/CVCMIServer.cpp index 5cef5f553..ea7ab5eca 100644 --- a/server/CVCMIServer.cpp +++ b/server/CVCMIServer.cpp @@ -29,7 +29,7 @@ #include "../lib/rmg/CMapGenOptions.h" #ifdef VCMI_ANDROID #include "lib/CAndroidVMHelper.h" -#else +#elif !defined(VCMI_IOS) #include "../lib/Interprocess.h" #endif #include "../lib/VCMI_Lib.h" @@ -55,7 +55,7 @@ #include "../lib/CGameState.h" -#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(VCMI_ANDROID) +#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(VCMI_ANDROID) && !defined(VCMI_IOS) #include #endif @@ -112,8 +112,8 @@ public: } }; -std::string NAME_AFFIX = "server"; -std::string NAME = GameConstants::VCMI_VERSION + std::string(" (") + NAME_AFFIX + ')'; +std::string SERVER_NAME_AFFIX = "server"; +std::string SERVER_NAME = GameConstants::VCMI_VERSION + std::string(" (") + SERVER_NAME_AFFIX + ')'; CVCMIServer::CVCMIServer(boost::program_options::variables_map & opts) : port(3030), io(std::make_shared()), state(EServerState::LOBBY), cmdLineOptions(opts), currentClientId(1), currentPlayerId(1), restartGameplay(false) @@ -157,7 +157,7 @@ void CVCMIServer::run() if(!restartGameplay) { this->announceLobbyThread = vstd::make_unique(&CVCMIServer::threadAnnounceLobby, this); -#ifndef VCMI_ANDROID +#if !defined(VCMI_ANDROID) && !defined(VCMI_IOS) if(cmdLineOptions.count("enable-shm")) { std::string sharedMemoryName = "vcmi_memory"; @@ -171,14 +171,11 @@ void CVCMIServer::run() startAsyncAccept(); -#ifndef VCMI_ANDROID +#if !defined(VCMI_ANDROID) && !defined(VCMI_IOS) if(shm) { shm->sr->setToReadyAndNotify(port); } -#else - CAndroidVMHelper vmHelper; - vmHelper.callStaticVoidMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "onServerReady"); #endif } @@ -294,7 +291,7 @@ void CVCMIServer::connectionAccepted(const boost::system::error_code & ec) try { logNetwork->info("We got a new connection! :)"); - auto c = std::make_shared(upcomingConnection, NAME, uuid); + auto c = std::make_shared(upcomingConnection, SERVER_NAME, uuid); upcomingConnection.reset(); connections.insert(c); c->handler = std::make_shared(&CVCMIServer::threadHandleClient, this, c); @@ -373,7 +370,7 @@ void CVCMIServer::announcePack(std::unique_ptr pack) { for(auto c : connections) { - // FIXME: we need to avoid senting something to client that not yet get answer for LobbyClientConnected + // FIXME: we need to avoid sending something to client that not yet get answer for LobbyClientConnected // Until UUID set we only pass LobbyClientConnected to this client if(c->uuid == uuid && !dynamic_cast(pack.get())) continue; @@ -829,7 +826,7 @@ ui8 CVCMIServer::getIdOfFirstUnallocatedPlayer() const return 0; } -#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(VCMI_ANDROID) +#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(VCMI_ANDROID) && !defined(VCMI_IOS) void handleLinuxSignal(int sig) { const int STACKTRACE_SIZE = 100; @@ -859,6 +856,10 @@ void handleLinuxSignal(int sig) static void handleCommandOptions(int argc, char * argv[], boost::program_options::variables_map & options) { namespace po = boost::program_options; +#ifdef SINGLE_PROCESS_APP + options.emplace("run-by-client", po::variable_value{true, true}); + options.emplace("uuid", po::variable_value{std::string{argv[1]}, true}); +#else po::options_description opts("Allowed options"); opts.add_options() ("help,h", "display help and exit") @@ -880,8 +881,11 @@ static void handleCommandOptions(int argc, char * argv[], boost::program_options std::cerr << "Failure during parsing command-line options:\n" << e.what() << std::endl; } } +#endif po::notify(options); + +#ifndef SINGLE_PROCESS_APP if(options.count("help")) { auto time = std::time(0); @@ -900,24 +904,28 @@ static void handleCommandOptions(int argc, char * argv[], boost::program_options std::cout << VCMIDirs::get().genHelpString(); exit(0); } +#endif } +#ifdef SINGLE_PROCESS_APP +#define main server_main +#endif int main(int argc, char * argv[]) { -#ifndef VCMI_ANDROID +#if !defined(VCMI_ANDROID) && !defined(VCMI_IOS) // Correct working dir executable folder (not bundle folder) so we can use executable relative paths boost::filesystem::current_path(boost::filesystem::system_complete(argv[0]).parent_path()); #endif // Installs a sig sev segmentation violation handler // to log stacktrace -#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(VCMI_ANDROID) +#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(VCMI_ANDROID) && !defined(VCMI_IOS) signal(SIGSEGV, handleLinuxSignal); #endif console = new CConsoleHandler(); CBasicLogConfigurator logConfig(VCMIDirs::get().userLogsPath() / "VCMI_Server_log.txt", console); logConfig.configureDefault(); - logGlobal->info(NAME); + logGlobal->info(SERVER_NAME); boost::program_options::variables_map opts; handleCommandOptions(argc, argv, opts); @@ -927,6 +935,12 @@ int main(int argc, char * argv[]) loadDLLClasses(); srand((ui32)time(nullptr)); + +#ifdef SINGLE_PROCESS_APP + boost::condition_variable * cond = reinterpret_cast(argv[0]); + cond->notify_one(); +#endif + try { boost::asio::io_service io_service; @@ -972,4 +986,13 @@ void CVCMIServer::create() const char * foo[1] = {"android-server"}; main(1, const_cast(foo)); } +#elif defined(SINGLE_PROCESS_APP) +void CVCMIServer::create(boost::condition_variable * cond, const std::string & uuid) +{ + const std::initializer_list argv = { + cond, + uuid.c_str(), + }; + main(argv.size(), reinterpret_cast(const_cast(argv.begin()))); +} #endif diff --git a/server/CVCMIServer.h b/server/CVCMIServer.h index 111ded751..3370a0c66 100644 --- a/server/CVCMIServer.h +++ b/server/CVCMIServer.h @@ -14,10 +14,11 @@ #include +VCMI_LIB_NAMESPACE_BEGIN + class CMapInfo; struct CPackForLobby; -class CGameHandler; struct SharedMemory; struct StartInfo; @@ -26,6 +27,10 @@ struct PlayerSettings; class PlayerColor; template class CApplier; + +VCMI_LIB_NAMESPACE_END + +class CGameHandler; class CBaseForServerApply; class CBaseForGHApply; @@ -103,5 +108,7 @@ public: #ifdef VCMI_ANDROID static void create(); +#elif defined(SINGLE_PROCESS_APP) + static void create(boost::condition_variable * cond, const std::string & uuid); #endif }; diff --git a/server/StdInc.h b/server/StdInc.h index 9cc0f48e0..fbf8bbce5 100644 --- a/server/StdInc.h +++ b/server/StdInc.h @@ -18,3 +18,4 @@ #include #include +VCMI_LIB_USING_NAMESPACE diff --git a/vcmibuilder b/vcmibuilder index af4df023a..cdd1b337f 100755 --- a/vcmibuilder +++ b/vcmibuilder @@ -116,10 +116,10 @@ if [[ -n "$gog_file" ]] then currentver="$(innoextract --version | head -n1 | cut -d ' ' -f2)" requiredver="1.6" - if verlt $currentver $requiredver; - then - fail "innoextract version is $currentver, update it to version $requiredver or higher" - fi + if verlt $currentver $requiredver; + then + fail "innoextract version is $currentver, update it to version $requiredver or higher" + fi fi if [[ -n "$useffmpeg" ]] @@ -182,7 +182,7 @@ then # innoextract always reports error (iconv 84 error). Just test file for presence test -f "$gog_file" || fail "Error: gog.com executable was not found!" - gog_file="$(cd "$(dirname "$gog_file")"; pwd)/$(basename "$gog_file")" + gog_file="$(cd "$(dirname "$gog_file")"; pwd)/$(basename "$gog_file")" cd "$data_dir" && innoextract "$gog_file" fi @@ -190,7 +190,7 @@ if [[ -n "$cd1_dir" ]] then data_dir="$temp_dir"/cddir mkdir -p "$data_dir" - unshield -d "$data_dir" x "$cd1_dir"/_setup/data1.cab || fail "Error: failed to extract from Install Shield installer!" "rm -rf $data_dir" + unshield -d "$data_dir" x "$cd1_dir"/_setup/data1.cab || fail "Error: failed to extract from Install Shield installer!" "rm -rf $data_dir" # a bit tricky - different releases have different root directory. Move extracted files to data_dir if [ -d "$data_dir"/Heroes3 ]