diff --git a/.github/workflows/cibuild.yml b/.github/workflows/cibuild.yml index 204dbfab41a..573f0c38124 100644 --- a/.github/workflows/cibuild.yml +++ b/.github/workflows/cibuild.yml @@ -89,18 +89,19 @@ jobs: # cc is always set for the correct naming of the job. # Both cc and cxx should be set if we want to change the compiler. # You may also want to set XRAY_LINKER when changing the compiler. - - { name: Ubuntu, os: ubuntu-latest, arch: amd64, cc: gcc, } - - { name: Ubuntu, os: ubuntu-latest, arch: amd64, cc: clang, cxx: clang++, flags: "-DXRAY_LINKER=lld", } - - { name: Ubuntu, os: ubuntu-24.04-arm, arch: arm64, cc: gcc } - #- { name: Ubuntu, os: ubuntu-latest, arch: ppc64el, cc: gcc, container: 'dockcross/linux-ppc64le:latest', } - - { name: Alpine, os: ubuntu-latest, arch: x86_64, cc: gcc, shell: 'alpine.sh {0}', flags: "-DXRAY_LINKER=mold", } - - { name: Alpine, os: ubuntu-latest, arch: x86, cc: gcc, shell: 'alpine.sh {0}', flags: "-DXRAY_LINKER=mold", } - - { name: Fedora, os: ubuntu-latest, arch: x86_64, cc: gcc, container: 'fedora:latest', } - #- { name: Haiku, os: ubuntu-latest, arch: x86_64, cc: x86_64-unknown-haiku-gcc, cxx: x86_64-unknown-haiku-g++, container: 'haiku/cross-compiler:x86_64-r1beta4', } - - { name: macOS 13, os: macos-13, arch: x86_64, cc: clang, flags: "-DCMAKE_OSX_DEPLOYMENT_TARGET=13.6" } - - { name: macOS 15, os: macos-15, arch: arm64, cc: clang, flags: "-DCMAKE_OSX_DEPLOYMENT_TARGET=15.0", threads: 3 } - - configuration: [Debug, Release] + #- { name: Windows, os: windows-latest, arch: x64, cc: cl, } + #- { name: Windows, os: windows-latest, arch: x86, cc: cl, } + - { name: Ubuntu, os: ubuntu-latest, arch: amd64, cc: gcc, } + - { name: Ubuntu, os: ubuntu-latest, arch: amd64, cc: clang, cxx: clang++, flags: "-DXRAY_LINKER=lld", } + - { name: Ubuntu, os: ubuntu-24.04-arm, arch: arm64, cc: gcc } + #- { name: Ubuntu, os: ubuntu-latest, arch: ppc64el, cc: gcc, container: 'dockcross/linux-ppc64le:latest', } + - { name: Alpine, os: ubuntu-latest, arch: x86_64, cc: gcc, shell: 'alpine.sh {0}', flags: "-DXRAY_LINKER=mold", } + - { name: Alpine, os: ubuntu-latest, arch: x86, cc: gcc, shell: 'alpine.sh {0}', flags: "-DXRAY_LINKER=mold", } + - { name: Fedora, os: ubuntu-latest, arch: x86_64, cc: gcc, container: 'fedora:latest', } + #- { name: Haiku, os: ubuntu-latest, arch: x86_64, cc: x86_64-unknown-haiku-gcc, cxx: x86_64-unknown-haiku-g++, container: 'haiku/cross-compiler:x86_64-r1beta4', } + - { name: macOS, os: macos-latest, arch: arm64, cc: clang, threads: 3 } + + configuration: [Debug, Mixed, Release, ReleaseMasterGold] steps: - name: Install latest stable Alpine Linux and packages @@ -150,7 +151,7 @@ jobs: submodules: recursive - name: Run CMake - run: cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DCMAKE_UNITY_BUILD=ON ${{ matrix.platform.flags }} + run: cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DCMAKE_UNITY_BUILD=ON ${{ matrix.platform.flags }} --log-level VERBOSE - name: Run CMake Build id: cmake-build @@ -183,7 +184,7 @@ jobs: fail-fast: false matrix: platform: - - { name: FreeBSD, os: freebsd, os-version: '14.2', arch: x86_64, + - { name: FreeBSD, os: freebsd, os-version: '14.3', arch: x86_64, install-cmd: "sudo pkg update && sudo pkg install -y cmake sdl2 lzo2 jpeg-turbo openal-soft libogg libtheora libvorbis" } - { name: OpenBSD, os: openbsd, os-version: '7.6', arch: x86_64, @@ -200,7 +201,7 @@ jobs: submodules: recursive - name: Setup ${{ matrix.platform.name }} and packages - uses: cross-platform-actions/action@v0.28.0 + uses: cross-platform-actions/action@v0.29.0 with: operating_system: ${{ matrix.platform.os }} architecture: ${{ matrix.platform.arch }} @@ -213,7 +214,7 @@ jobs: run: ${{ matrix.platform.install-cmd }} - name: Run CMake - uses: cross-platform-actions/action@v0.28.0 + uses: cross-platform-actions/action@v0.29.0 with: operating_system: ${{ matrix.platform.os }} architecture: ${{ matrix.platform.arch }} @@ -223,10 +224,10 @@ jobs: environment_variables: CFLAGS CXXFLAGS shutdown_vm: false sync_files: false - run: cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.Configuration }} -DCMAKE_UNITY_BUILD=ON + run: cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.Configuration }} -DCMAKE_UNITY_BUILD=ON --log-level VERBOSE - name: Run CMake Build - uses: cross-platform-actions/action@v0.28.0 + uses: cross-platform-actions/action@v0.29.0 with: operating_system: ${{ matrix.platform.os }} architecture: ${{ matrix.platform.arch }} diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 22a843a144d..145743e6d00 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -15,28 +15,28 @@ jobs: steps: - name: on new pull request if: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.opened == true || github.event.pull_request.reopened == true }} - uses: actions/labeler@v5.0.0 + uses: actions/labeler@v6.0.1 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" configuration-path: .github/labeler_on_new_pr.yml - name: on any pull request if: ${{ github.event_name == 'pull_request_target' }} - uses: actions/labeler@v5.0.0 + uses: actions/labeler@v6.0.1 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" configuration-path: .github/labeler.yml - name: on pull request approval if: ${{ github.event_name == 'pull_request_review' && github.event.review.state == 'approved' }} - uses: actions/labeler@v5.0.0 + uses: actions/labeler@v6.0.1 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" configuration-path: .github/labeler_on_pr_approved.yml - name: on pull request merged if: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.merged == true }} - uses: actions/labeler@v5.0.0 + uses: actions/labeler@v6.0.1 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" configuration-path: .github/labeler_on_pr_merged.yml diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml index 3f6834d6111..182b6eb9429 100644 --- a/.github/workflows/mirror.yml +++ b/.github/workflows/mirror.yml @@ -7,7 +7,7 @@ jobs: if: github.repository == 'OpenXRay/xray-16' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 diff --git a/.github/workflows/stylecheck.yml b/.github/workflows/stylecheck.yml index 158bbe113f6..b68c4eb2cef 100644 --- a/.github/workflows/stylecheck.yml +++ b/.github/workflows/stylecheck.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Install run: sudo apt-get install moreutils @@ -44,7 +44,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Install run: sudo apt-get install dos2unix recode @@ -75,7 +75,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: fetch-depth: 0 diff --git a/CMakeLists.txt b/CMakeLists.txt index a2209c2958c..67b4ca79553 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,15 +1,9 @@ cmake_minimum_required(VERSION 3.23) -message(STATUS "CMAKE_VERSION: ${CMAKE_VERSION}") - -cmake_policy(SET CMP0048 NEW) -cmake_policy(SET CMP0095 NEW) - list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +include(PreProjectInit) -include(utils) calculate_xray_build_id(XRAY_BUILD_ID) - project(OpenXRay DESCRIPTION "OpenXRay is an improved version of the X-Ray Engine, \ the game engine used in the world-famous S.T.A.L.K.E.R. game series by GSC Game World." @@ -18,290 +12,16 @@ project(OpenXRay LANGUAGES CXX C ) -message(STATUS "CMAKE_PROJECT_VERSION: ${CMAKE_PROJECT_VERSION}") - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - -option(CMAKE_VERBOSE_MAKEFILE "Verbose build output" OFF) -message(STATUS "CMAKE_VERBOSE_MAKEFILE: ${CMAKE_VERBOSE_MAKEFILE}") - -if (CMAKE_VERBOSE_MAKEFILE) - set(CMAKE_EXECUTE_PROCESS_COMMAND_ECHO STDOUT) -endif() - -if (CMAKE_VERSION VERSION_EQUAL "3.28.2" AND CMAKE_UNITY_BUILD) - # https://gitlab.kitware.com/cmake/cmake/-/issues/25650 - message(WARNING "In CMake 3.28.2, precompiled headers are broken when Unity build is enabled. This breaks project from compiling. \ - Please, update to CMake 3.28.3 or downgrade to 3.28.1.") - set(CMAKE_UNITY_BUILD OFF) -endif() - -if (NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE) -endif() - -# Redirecting the default installation path /usr/local to /usr no need to use -DCMAKE_INSTALL_PREFIX =/usr -if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - set(CMAKE_INSTALL_PREFIX "/usr") -endif() - -include(GNUInstallDirs) -include(packaging) - -set_git_info() - -# Output all libraries and executable to one folder -set(COMPILE_OUTPUT_FOLDER "${CMAKE_SOURCE_DIR}/bin/${CMAKE_SYSTEM_PROCESSOR}/${CMAKE_BUILD_TYPE}") -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${COMPILE_OUTPUT_FOLDER}") -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${COMPILE_OUTPUT_FOLDER}") -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${COMPILE_OUTPUT_FOLDER}") -set(CMAKE_PDB_OUTPUT_DIRECTORY "${COMPILE_OUTPUT_FOLDER}") -set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY "${COMPILE_OUTPUT_FOLDER}") - -if (DISABLE_PORTABLE_MODE) - add_compile_definitions(DISABLE_PORTABLE_MODE) -endif() - -set(CMAKE_BUILD_RPATH_USE_ORIGIN TRUE) -set(CMAKE_MACOSX_RPATH TRUE) - -message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}") -if (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") - set(PROJECT_PLATFORM_ARM64 TRUE) -elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "armv*") - set(PROJECT_PLATFORM_ARM TRUE) -elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "e2k") - set(PROJECT_PLATFORM_E2K TRUE) -elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64le") - set(PROJECT_PLATFORM_PPC TRUE) -endif() - -if (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") - set(MASTER_GOLD_DEFAULT_VALUE ON) -else() - set(MASTER_GOLD_DEFAULT_VALUE OFF) -endif() -message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") - -option(MASTER_GOLD "Build with MASTER_GOLD" ${MASTER_GOLD_DEFAULT_VALUE}) -if (MASTER_GOLD) - add_compile_definitions(MASTER_GOLD) -endif() -message(STATUS "MASTER_GOLD: ${MASTER_GOLD}") - -option(STATIC_BUILD "Use static build" ${MASTER_GOLD}) -if (STATIC_BUILD) - # XXX: Uncomment only after build with XRAY_STATIC_BUILD is fixed - #add_compile_definitions(XRAY_STATIC_BUILD) -endif() -message(STATUS "STATIC_BUILD: ${STATIC_BUILD}") - -option(CMAKE_UNITY_BUILD "Use unity build" OFF) -message(STATUS "CMAKE_UNITY_BUILD: ${CMAKE_UNITY_BUILD}") - -find_program(CCACHE_FOUND ccache) -if (CCACHE_FOUND) - set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) - set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) - set(ENV{CCACHE_SLOPPINESS} pch_defines,time_macros) -endif () - -if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0 AND NOT PROJECT_PLATFORM_E2K) - message(FATAL_ERROR "Building with a gcc version less than 8.0 is not supported.") - elseif (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0 AND PROJECT_PLATFORM_E2K) - message(FATAL_ERROR "Building with a MCST lcc version less than 1.25 is not supported.") - endif() -elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - # XXX: Remove -fdelayed-template-parsing - add_compile_options( - -fdelayed-template-parsing - -Wno-unused-command-line-argument - -Wno-inconsistent-missing-override - ) -endif() - -if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT XRAY_USE_DEFAULT_CXX_LIB) - if (NOT XRAY_CXX_LIB) - include(CheckCXXCompilerFlag) - CHECK_CXX_COMPILER_FLAG("-stdlib=libc++" LIBCPP_AVAILABLE) - CHECK_CXX_COMPILER_FLAG("-stdlib=libstdc++" LIBSTDCPP_AVAILABLE) - - if (LIBCPP_AVAILABLE) - set(XRAY_CXX_LIB "libc++" CACHE STRING "" FORCE) - elseif (LIBSTDCPP_AVAILABLE) - set(XRAY_CXX_LIB "libstdc++" CACHE STRING "" FORCE) - else() - message("Neither libstdc++ nor libc++ are available. Hopefully, system has another custom stdlib?") - endif() - endif() +option(BUILD_SHARED_LIBS "Build shared libraries" ${BUILD_SHARED_LIBS_DEFAULT_VALUE}) - if (XRAY_CXX_LIB STREQUAL "libstdc++") - add_compile_options(-stdlib=libstdc++) - elseif (XRAY_CXX_LIB STREQUAL "libc++") - add_compile_options(-stdlib=libc++) - if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") - add_compile_options(-lcxxrt) - else() - add_compile_options(-lc++abi) - endif() - endif() -endif() +option(XRAY_USE_LUAJIT "Use LuaJIT" ON) +option(XRAY_USE_ASAN "Use AddressSanitizer" OFF) +option(XRAY_ENABLE_TRACY "Enable tracy profiler" OFF) -add_compile_options(-Wno-attributes) -if (APPLE) - add_compile_options(-Wl,-undefined,error) -else() - add_compile_options(-Wl,--no-undefined) -endif() - -# TODO test -option(USE_ADDRESS_SANITIZER "Use AddressSanitizer" OFF) - -if (USE_ADDRESS_SANITIZER) - add_compile_options( - -fsanitize=address - -fsanitize=leak - -fsanitize=undefined - -fno-omit-frame-pointer - -fno-optimize-sibling-calls - -fno-sanitize=vptr - ) - - add_link_options( - $<$:-shared-libasan> - -fsanitize=address - -fsanitize=leak - -fsanitize=undefined - ) -endif() - -message(STATUS "USE_ADDRESS_SANITIZER: ${USE_ADDRESS_SANITIZER}") - -option(USE_LTO "Use Link Time Optimization" ${MASTER_GOLD}) -if (USE_LTO) - include(CheckIPOSupported) - check_ipo_supported(RESULT LTO_SUPPORTED) - - if (LTO_SUPPORTED) - # With clang cmake only enables '-flto=thin' but we want full LTO - if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - add_compile_options(-flto=full) - else() - set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) - endif() - endif() -endif() - -message(STATUS "USE_LTO: ${USE_LTO}") - -if (PROJECT_PLATFORM_ARM) - add_compile_options(-mfpu=neon) -elseif (PROJECT_PLATFORM_ARM64) - #add_compile_options() -elseif (PROJECT_PLATFORM_E2K) - add_compile_options(-Wno-unknown-pragmas) -elseif (PROJECT_PLATFORM_PPC) - add_compile_options( - -maltivec - -mabi=altivec - ) - add_compile_definitions(NO_WARN_X86_INTRINSICS) -else() - add_compile_options( - -mfpmath=sse - -msse3 - ) -endif() - -if (XRAY_LINKER) - add_link_options(-fuse-ld=${XRAY_LINKER}) -endif() - -if (CMAKE_BUILD_TYPE STREQUAL "Debug") - add_compile_definitions( - DEBUG - MIXED - ) - add_compile_options(-Og) -endif() - -add_compile_definitions( - _MT - _CPPUNWIND -) - -if (NOT WIN32) - find_package(SDL2 2.0.18 REQUIRED) - # Fix to support older SDL2 - # https://github.com/OpenXRay/xray-16/issues/1595 - if (NOT TARGET SDL2::SDL2 AND DEFINED SDL2_LIBRARIES) - add_library(SDL2::SDL2 UNKNOWN IMPORTED) - set_target_properties( - SDL2::SDL2 PROPERTIES - IMPORTED_LOCATION "${SDL2_LIBRARIES}" - INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}" - ) - endif() - find_package(OpenAL REQUIRED) - find_package(JPEG) - find_package(Ogg REQUIRED) - find_package(Vorbis REQUIRED) - find_package(Theora REQUIRED) - find_package(LZO REQUIRED) - find_package(mimalloc NAMES mimalloc2 mimalloc2.0 mimalloc) -endif() - -# Memory allocator option -if (mimalloc_FOUND) - set(MEMORY_ALLOCATOR "mimalloc" CACHE STRING "Use specific memory allocator (mimalloc/standard)") -else() - set(MEMORY_ALLOCATOR "standard" CACHE STRING "Use specific memory allocator (mimalloc/standard)") -endif() -set_property(CACHE MEMORY_ALLOCATOR PROPERTY STRINGS "mimalloc" "standard") - -if (MEMORY_ALLOCATOR STREQUAL "mimalloc" AND NOT mimalloc_FOUND) - message(FATAL_ERROR "mimalloc allocator requested but not found. Please, install mimalloc package or select standard allocator.") -endif() - -message("Using ${MEMORY_ALLOCATOR} memory allocator") - -option(XRAY_USE_LUAJIT "Use LuaJIT" ON) +include(XRay.Build) +include(XRay.Packaging) add_subdirectory(Externals) - -add_compile_options( - -Wall - #-Werror - -Wextra - #-pedantic - -Wno-unknown-pragmas - -Wno-strict-aliasing - -Wno-parentheses - -Wno-unused-label - -Wno-unused-parameter - -Wno-switch - #-Wno-padded - #-Wno-c++98-compat - #-Wno-c++98-compat-pedantic - #-Wno-c++11-compat - #-Wno-c++11-compat-pedantic - #-Wno-c++14-compat - #-Wno-c++14-compat-pedantic - #-Wno-newline-eof - $<$:$<$:-Wno-class-memaccess>> - $<$:$<$:-Wno-interference-size>> -) - add_subdirectory(src) add_subdirectory(res) add_subdirectory(misc) - -get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) - -if ("${LIB64}" STREQUAL "TRUE") - set(LIBSUFFIX 64) -else() - set(LIBSUFFIX "") -endif() diff --git a/Externals/CMakeLists.txt b/Externals/CMakeLists.txt index 3adde184cc0..4b438f03b6a 100644 --- a/Externals/CMakeLists.txt +++ b/Externals/CMakeLists.txt @@ -4,15 +4,15 @@ else() find_package(Lua51 REQUIRED) endif() +add_subdirectory(luabind) add_subdirectory(xrLuaFix) +add_subdirectory(OPCODE) add_subdirectory(ode) # Silence all warnings for external libraries -add_compile_options("-w") +add_compile_options(${XRAY_DISABLE_WARNINGS}) -add_subdirectory(luabind) add_subdirectory(GameSpy) -add_subdirectory(OPCODE) add_subdirectory(imgui-proj) if (NOT TARGET xrLuabind) diff --git a/Externals/DiscordGameSDK/DiscordGameSDK.vcxproj b/Externals/DiscordGameSDK/DiscordGameSDK.vcxproj index 23a91a8c5f4..09051b26417 100644 --- a/Externals/DiscordGameSDK/DiscordGameSDK.vcxproj +++ b/Externals/DiscordGameSDK/DiscordGameSDK.vcxproj @@ -33,9 +33,6 @@ discord_game_sdk.dll.lib;%(AdditionalDependencies) - - $(xrBinDir) - @@ -57,11 +54,6 @@ - - - Document - - diff --git a/Externals/DiscordGameSDK/DiscordGameSDK.vcxproj.filters b/Externals/DiscordGameSDK/DiscordGameSDK.vcxproj.filters index 7a11e06a688..214388c3342 100644 --- a/Externals/DiscordGameSDK/DiscordGameSDK.vcxproj.filters +++ b/Externals/DiscordGameSDK/DiscordGameSDK.vcxproj.filters @@ -60,7 +60,4 @@ {2074231d-b44a-4fd4-a569-01e1d1303636} - - - \ No newline at end of file diff --git a/Externals/GameSpy b/Externals/GameSpy index 61d061b4b3f..65992fcad9a 160000 --- a/Externals/GameSpy +++ b/Externals/GameSpy @@ -1 +1 @@ -Subproject commit 61d061b4b3f860865f97e659e496e11704f61eb3 +Subproject commit 65992fcad9a22a3d65e188c8aa4047897edd1d83 diff --git a/Externals/LuaJIT-proj/CMakeLists.txt b/Externals/LuaJIT-proj/CMakeLists.txt index 61b46d67392..834f6b1983f 100644 --- a/Externals/LuaJIT-proj/CMakeLists.txt +++ b/Externals/LuaJIT-proj/CMakeLists.txt @@ -18,7 +18,7 @@ set(NODOTABIVER 51) set(CMAKE_OSX_SYSROOT "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk") set(LUAJIT_DIR ${CMAKE_SOURCE_DIR}/Externals/LuaJIT/src CACHE PATH "Location of luajit sources") -option(LUAJIT_BUILD_STATIC_LIB "Build as static library" OFF) +option(BUILD_SHARED_LIBS "Build as shared library" ON) option(LUAJIT_BUILD_APP "Build application" OFF) # NOTE: Not working because there is no lib_package_rel.c file @@ -72,24 +72,14 @@ execute_process( WORKING_DIRECTORY ${LUAJIT_DIR} ) -# TODO: check windows supports same target name for static and shared lib -if (LUAJIT_BUILD_STATIC_LIB) - add_library(xrLuaJIT STATIC) -else() - add_library(xrLuaJIT SHARED) -endif() +add_library(xrLuaJIT) # Compiler options -if (PROJECT_PLATFORM_E2K) - # O3 on E2K mcst-lcc approximately equal to O2 at X86/ARM gcc - set(CCOPT_OPT_LEVEL "-O3") -else() - set(CCOPT_OPT_LEVEL "-O2") -endif() +set(CCOPT_OPT_LEVEL "-O3") set(CCOPT "${CMAKE_C_FLAGS} ${CCOPT_OPT_LEVEL}") -if (USE_ADDRESS_SANITIZER) +if (XRAY_USE_ASAN) set(CCOPT "${CCOPT} -fno-stack-protector") else() set(CCOPT "${CCOPT} -fomit-frame-pointer -fno-stack-protector") @@ -201,7 +191,7 @@ if (WIN32) " -shared -Wl,--out-implib,libluajit-${ABIVER}.dll.a" ) - if (NOT LUAJIT_BUILD_STATIC_LIB) + if (LUAJIT_BUILD_STATIC_LIB) string(APPEND HOST_XCFLAGS " -DLUA_BUILD_AS_DLL") endif() diff --git a/Externals/LuaJIT-proj/LuaJIT.vcxproj b/Externals/LuaJIT-proj/LuaJIT.vcxproj index a994a668e8d..ff1b86f8ef8 100644 --- a/Externals/LuaJIT-proj/LuaJIT.vcxproj +++ b/Externals/LuaJIT-proj/LuaJIT.vcxproj @@ -10,9 +10,6 @@ - - DynamicLibrary - @@ -25,6 +22,10 @@ lj_vm_$(PlatformShortName).obj;%(AdditionalDependencies) $(ProjectDir)intermediate\$(PlatformShortName);%(AdditionalLibraryDirectories) + + lj_vm_$(PlatformShortName).obj;%(AdditionalDependencies) + $(ProjectDir)intermediate\$(PlatformShortName);%(AdditionalLibraryDirectories) + $(ProjectDir)intermediate\$(PlatformShortName);%(AdditionalIncludeDirectories) LUA_BUILD_AS_DLL;%(PreprocessorDefinitions) diff --git a/Externals/ODE.vcxproj b/Externals/ODE.vcxproj index c0f50243998..22a0fee9e3b 100644 --- a/Externals/ODE.vcxproj +++ b/Externals/ODE.vcxproj @@ -14,9 +14,6 @@ false - - StaticLibrary - diff --git a/Externals/OPCODE/CMakeLists.txt b/Externals/OPCODE/CMakeLists.txt index 60656aa9f3c..9ceb91cdd73 100644 --- a/Externals/OPCODE/CMakeLists.txt +++ b/Externals/OPCODE/CMakeLists.txt @@ -1,13 +1,4 @@ -if (STATIC_BUILD) - add_library(xrOPCODE STATIC) - - target_compile_definitions(xrOPCODE - PRIVATE - OPCODE_STATIC - ) -else() - add_library(xrOPCODE SHARED) -endif() +add_library(xrOPCODE) target_sources(xrOPCODE PRIVATE OPC_AABBCollider.cpp @@ -87,13 +78,14 @@ target_link_libraries(xrOPCODE ) target_compile_definitions(xrOPCODE + PUBLIC + $<$>:OPCODE_STATIC> PRIVATE - OPCODE_EXPORTS + $<$:OPCODE_EXPORTS> ) set_target_properties(xrOPCODE PROPERTIES PREFIX "" - POSITION_INDEPENDENT_CODE ON ) target_precompile_headers(xrOPCODE @@ -101,7 +93,7 @@ target_precompile_headers(xrOPCODE pch.hpp ) -if (NOT STATIC_BUILD) +if (BUILD_SHARED_LIBS) install(TARGETS xrOPCODE LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ) diff --git a/Externals/OPCODE/OPCODE.vcxproj b/Externals/OPCODE/OPCODE.vcxproj index 772ed6ba698..ae5a6b7a660 100644 --- a/Externals/OPCODE/OPCODE.vcxproj +++ b/Externals/OPCODE/OPCODE.vcxproj @@ -12,9 +12,6 @@ - - StaticLibrary - diff --git a/Externals/imgui b/Externals/imgui index efe2b21a5fa..ab760992adb 160000 --- a/Externals/imgui +++ b/Externals/imgui @@ -1 +1 @@ -Subproject commit efe2b21a5fa0199c9bb7e26184a7f7df6ed07942 +Subproject commit ab760992adb66258e65f78bb67380a00113e8996 diff --git a/Externals/imgui-proj/CMakeLists.txt b/Externals/imgui-proj/CMakeLists.txt index 7c218627a03..2ea05dc1125 100644 --- a/Externals/imgui-proj/CMakeLists.txt +++ b/Externals/imgui-proj/CMakeLists.txt @@ -37,5 +37,5 @@ target_compile_definitions(xrImGui set_target_properties(xrImGui PROPERTIES PREFIX "" - POSITION_INDEPENDENT_CODE ON + POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS} ) diff --git a/Externals/luabind b/Externals/luabind index dd3db67b115..d712e65c372 160000 --- a/Externals/luabind +++ b/Externals/luabind @@ -1 +1 @@ -Subproject commit dd3db67b11580282604f2c8d862f9777eb3be6ed +Subproject commit d712e65c372dd5e4c7d94e149d09a72a7591179b diff --git a/Externals/luabind.vcxproj b/Externals/luabind.vcxproj index 3870888b703..964dfda1550 100644 --- a/Externals/luabind.vcxproj +++ b/Externals/luabind.vcxproj @@ -10,9 +10,6 @@ - - DynamicLibrary - diff --git a/Externals/ode/CMakeLists.txt b/Externals/ode/CMakeLists.txt index bd6cc37e5ed..cfea8374f11 100644 --- a/Externals/ode/CMakeLists.txt +++ b/Externals/ode/CMakeLists.txt @@ -1,8 +1,4 @@ -if (STATIC_BUILD) - add_library(xrODE STATIC) -else() - add_library(xrODE SHARED) -endif() +add_library(xrODE) target_sources(xrODE PRIVATE ode/src/array.cpp @@ -89,31 +85,18 @@ target_include_directories(xrODE "${CMAKE_CURRENT_SOURCE_DIR}/include" ) -# TODO platform-specific defines target_compile_definitions(xrODE PUBLIC dSINGLE - dNODEBUG - - PRIVATE - LINUX - __cdecl= + "$<$:dNODEBUG>" ) -if (MASTER_GOLD) - target_compile_definitions(xrODE - PUBLIC - dNODEBUG - ) -endif() - set_target_properties(xrODE PROPERTIES PREFIX "" - POSITION_INDEPENDENT_CODE ON UNITY_BUILD OFF ) -if (NOT STATIC_BUILD) +if (BUILD_SHARED_LIBS) install(TARGETS xrODE LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ) diff --git a/Externals/ode/ode/src/util.h b/Externals/ode/ode/src/util.h index bef6bb0b58d..2c05d528caa 100644 --- a/Externals/ode/ode/src/util.h +++ b/Externals/ode/ode/src/util.h @@ -24,10 +24,11 @@ #define _ODE_UTIL_H_ #include "objects.h" -#include "float.h" -#ifndef MSVC -#include // for fpclassify +#if defined(_MSC_VER) || defined(__MINGW_FPCLASS_DEFINED) +#include +#else +#include #endif void dInternalHandleAutoDisabling (dxWorld *world, dReal stepsize); @@ -43,7 +44,7 @@ void dxProcessIslands (dxWorld *world, dReal stepsize, dstepper_fn_t stepper); inline bool dValid(const float x) { -#ifdef MSVC +#if defined(_MSC_VER) || defined(__MINGW_FPCLASS_DEFINED) // check for: Signaling NaN, Quiet NaN, Negative infinity (-INF), Positive infinity (+INF), Negative denormalized, Positive denormalized int cls = _fpclass(double(x)); if (cls&(_FPCLASS_SNAN+_FPCLASS_QNAN+_FPCLASS_NINF+_FPCLASS_PINF+_FPCLASS_ND+_FPCLASS_PD)) @@ -59,13 +60,13 @@ inline bool dValid(const float x) default: break; } -#endif /* *****other cases are***** _FPCLASS_NN Negative normalized non-zero _FPCLASS_NZ Negative zero (-0) _FPCLASS_PZ Positive 0 (+0) _FPCLASS_PN Positive normalized non-zero */ +#endif return true; } #endif diff --git a/Externals/sse2neon b/Externals/sse2neon index 658eeac2fe8..42eee28683a 160000 --- a/Externals/sse2neon +++ b/Externals/sse2neon @@ -1 +1 @@ -Subproject commit 658eeac2fe8d37912bba074260f1c604cf037c73 +Subproject commit 42eee28683af2c31dafcc37315f9ba400003754f diff --git a/Externals/sse2rvv b/Externals/sse2rvv index f3a1d7d2508..373f7886c9d 160000 --- a/Externals/sse2rvv +++ b/Externals/sse2rvv @@ -1 +1 @@ -Subproject commit f3a1d7d25081bc5be973576b8f12c83cd389e61f +Subproject commit 373f7886c9d70237e426bd7fb7b3a021085427a2 diff --git a/Externals/xrLuaFix b/Externals/xrLuaFix index 67b77c92f49..0e89050f39f 160000 --- a/Externals/xrLuaFix +++ b/Externals/xrLuaFix @@ -1 +1 @@ -Subproject commit 67b77c92f49c766c7c180cc39ffdb12799f395d7 +Subproject commit 0e89050f39fc1e6b21b856ed8b7a3d68ff486ccb diff --git a/README.md b/README.md index 8fa52cc3e32..6a12d26ca3c 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ However, they know about many community projects, including this, and support S. Installation instructions are on the [How to install and play](https://github.com/OpenXRay/xray-16/wiki/[EN]-How-to-install-and-play) page. ## Supported game platforms -- Clear Sky 1.5.10. (minor bugs are possible, but the game is stable finishable. See [#382](https://github.com/OpenXRay/xray-16/issues/382)) -- Call of Pripyat 1.6.02. - Call of Chernobyl 1.4.22. +- Call of Pripyat 1.6.02. +- Clear Sky 1.5.10. (minor bugs are possible, but the game is stable finishable. See [#382](https://github.com/OpenXRay/xray-16/issues/382)) Shadow of Chernobyl is **not supported** yet. (see [#392](https://github.com/OpenXRay/xray-16/issues/392))
Legends of the Zone/Enhanced Edition is not supported and won't ever be likely. (see [#1865](https://github.com/OpenXRay/xray-16/issues/1865)) diff --git a/cmake/PreProjectInit.cmake b/cmake/PreProjectInit.cmake new file mode 100644 index 00000000000..b950c238274 --- /dev/null +++ b/cmake/PreProjectInit.cmake @@ -0,0 +1,18 @@ +include_guard() + +message(VERBOSE "CMAKE_VERSION: ${CMAKE_VERSION}") + +cmake_policy(SET CMP0138 NEW) # https://cmake.org/cmake/help/latest/policy/CMP0138.html +cmake_policy(SET CMP0149 NEW) # https://cmake.org/cmake/help/latest/policy/CMP0149.html +cmake_policy(SET CMP0162 NEW) # https://cmake.org/cmake/help/latest/policy/CMP0162.html +cmake_policy(SET CMP0164 NEW) # https://cmake.org/cmake/help/latest/policy/CMP0164.html + +include(XRay.Configurations) + +include(utils) + +if (CMAKE_BUILD_TYPE STREQUAL "ReleaseMasterGold") + set(BUILD_SHARED_LIBS_DEFAULT_VALUE OFF) +else() + set(BUILD_SHARED_LIBS_DEFAULT_VALUE ON) +endif() diff --git a/cmake/XRay.Build.cmake b/cmake/XRay.Build.cmake new file mode 100644 index 00000000000..951bf4ee77f --- /dev/null +++ b/cmake/XRay.Build.cmake @@ -0,0 +1,81 @@ +include_guard() + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +# Output all libraries and executables to one folder +set(XRAY_COMPILE_OUTPUT_FOLDER "${CMAKE_SOURCE_DIR}/bin/${CMAKE_SYSTEM_PROCESSOR}/$") +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${XRAY_COMPILE_OUTPUT_FOLDER}") +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${XRAY_COMPILE_OUTPUT_FOLDER}") +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${XRAY_COMPILE_OUTPUT_FOLDER}") +set(CMAKE_PDB_OUTPUT_DIRECTORY "${XRAY_COMPILE_OUTPUT_FOLDER}") +set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY "${XRAY_COMPILE_OUTPUT_FOLDER}") + +add_compile_definitions( + # _DEBUG, DEBUG, MIXED, NDEBUG defines + $<$:_DEBUG> + $<$:DEBUG> + $<$:MIXED> + $<$:NDEBUG> + # Tracy profiler + $<$:TRACY_ENABLE> + $<$:TRACY_NO_FRAME_IMAGE> + # Luabind + $<$:LUABIND_NO_EXCEPTIONS> + $<$:LUABIND_NO_ERROR_CHECKING> +) + +# Link-time optimization +include(CheckIPOSupported) +check_ipo_supported(RESULT LTO_IS_SUPPORTED) +if (LTO_IS_SUPPORTED) + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON) + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASEMASTERGOLD ON) +endif() + +# Main compiler settings +if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + include(XRay.Compiler.MSVC) +elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU|LCC|Clang") + include(XRay.Compiler.GNULike) +else() + message(FATAL_ERROR "Unsupported or unknown compiler.") +endif() + +# https://gitlab.kitware.com/cmake/cmake/-/issues/25650 +if (CMAKE_VERSION VERSION_EQUAL "3.28.2" AND CMAKE_UNITY_BUILD) + message(WARNING + "In CMake 3.28.2, precompiled headers are broken when Unity build is enabled. \ + We have to disable Unity build. Please, update to CMake 3.28.3 or downgrade to 3.28.1." + ) + set(CMAKE_UNITY_BUILD OFF) +endif() + +query_git_info(XRAY_GIT_SHA XRAY_GIT_BRANCH) + +message(VERBOSE "CMAKE_UNITY_BUILD: ${CMAKE_UNITY_BUILD}") +message(STATUS "CMAKE_PROJECT_VERSION: ${CMAKE_PROJECT_VERSION}") +message(STATUS "XRAY_GIT_SHA: ${XRAY_GIT_SHA}") +message(STATUS "XRAY_GIT_BRANCH: ${XRAY_GIT_BRANCH}") + +message(STATUS "BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}") +message(STATUS "LTO_IS_SUPPORTED: ${LTO_IS_SUPPORTED}") + +message(DEBUG) +message(DEBUG "C++ Flags:") +message(DEBUG " Global: ${CMAKE_CXX_FLAGS}") +message(DEBUG " Debug: ${CMAKE_CXX_FLAGS_DEBUG}") +message(DEBUG " Mixed: ${CMAKE_CXX_FLAGS_MIXED}") +message(DEBUG " Release: ${CMAKE_CXX_FLAGS_RELEASE}") +message(DEBUG "ReleaseMasterGold: ${CMAKE_CXX_FLAGS_RELEASEMASTERGOLD}") + +message(DEBUG) +message(DEBUG "C Flags:") +message(DEBUG " Global: ${CMAKE_C_FLAGS}") +message(DEBUG " Debug: ${CMAKE_C_FLAGS_DEBUG}") +message(DEBUG " Mixed: ${CMAKE_C_FLAGS_MIXED}") +message(DEBUG " Release: ${CMAKE_C_FLAGS_RELEASE}") +message(DEBUG "ReleaseMasterGold: ${CMAKE_C_FLAGS_RELEASEMASTERGOLD}") +message(DEBUG) + +unset(LTO_IS_SUPPORTED) diff --git a/cmake/XRay.Compiler.GNULike.cmake b/cmake/XRay.Compiler.GNULike.cmake new file mode 100644 index 00000000000..e3bb44d8889 --- /dev/null +++ b/cmake/XRay.Compiler.GNULike.cmake @@ -0,0 +1,205 @@ +include_guard() + +if (APPLE) + if (NOT CMAKE_OSX_DEPLOYMENT_TARGET) + if ($ENV{MACOSX_DEPLOYMENT_TARGET}) + set(CMAKE_OSX_DEPLOYMENT_TARGET $ENV{MACOSX_DEPLOYMENT_TARGET}) + else() + message(NOTICE "CMAKE_OSX_DEPLOYMENT_TARGET is not set, defaulting it to your system's version: ${CMAKE_SYSTEM_VERSION}") + set(CMAKE_OSX_DEPLOYMENT_TARGET ${CMAKE_SYSTEM_VERSION}) + endif() + endif() + message(STATUS "CMAKE_OSX_DEPLOYMENT_TARGET: ${CMAKE_OSX_DEPLOYMENT_TARGET}") +endif() + +# Redirecting the default installation path /usr/local to /usr no need to use -DCMAKE_INSTALL_PREFIX =/usr +if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "/usr") +endif() + +include(GNUInstallDirs) + +if (DISABLE_PORTABLE_MODE) + add_compile_definitions(DISABLE_PORTABLE_MODE) +endif() + +set(CMAKE_BUILD_RPATH_USE_ORIGIN TRUE) +set(CMAKE_MACOSX_RPATH TRUE) + +find_program(CCACHE_FOUND ccache) +if (CCACHE_FOUND) + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) + set(ENV{CCACHE_SLOPPINESS} pch_defines,time_macros) +endif () + +if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0) + message(FATAL_ERROR "Building with a gcc version less than 8.0 is not supported.") + endif() +elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # XXX: Remove -fdelayed-template-parsing + add_compile_options( + -fdelayed-template-parsing + -Wno-unused-command-line-argument + -Wno-inconsistent-missing-override + ) +endif() + +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT XRAY_USE_DEFAULT_CXX_LIB) + if (NOT XRAY_CXX_LIB) + include(CheckCXXCompilerFlag) + CHECK_CXX_COMPILER_FLAG("-stdlib=libc++" LIBCPP_AVAILABLE) + CHECK_CXX_COMPILER_FLAG("-stdlib=libstdc++" LIBSTDCPP_AVAILABLE) + + if (LIBCPP_AVAILABLE) + set(XRAY_CXX_LIB "libc++" CACHE STRING "" FORCE) + elseif (LIBSTDCPP_AVAILABLE) + set(XRAY_CXX_LIB "libstdc++" CACHE STRING "" FORCE) + else() + message("Neither libstdc++ nor libc++ are available. Hopefully, system has another custom stdlib?") + endif() + endif() + + if (XRAY_CXX_LIB STREQUAL "libstdc++") + add_compile_options(-stdlib=libstdc++) + add_link_options(-stdlib=libstdc++) + elseif (XRAY_CXX_LIB STREQUAL "libc++") + add_compile_options(-stdlib=libc++) + add_link_options(-stdlib=libc++) + if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + add_compile_options(-lcxxrt) + add_link_options(-lcxxrt) + else() + add_compile_options(-lc++abi) + add_link_options(-lc++abi) + endif() + endif() +endif() + +add_compile_options(-Wno-attributes) +if (APPLE) + add_compile_options(-Wl,-undefined,error) +else() + add_compile_options(-Wl,--no-undefined) +endif() + +# TODO test +if (XRAY_USE_ASAN) + add_compile_options( + -fsanitize=address + -fsanitize=leak + -fsanitize=undefined + -fno-omit-frame-pointer + -fno-optimize-sibling-calls + -fno-sanitize=vptr + ) + + add_link_options( + $<$:-shared-libasan> + -fsanitize=address + -fsanitize=leak + -fsanitize=undefined + ) +endif() + +if (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") + set(PROJECT_PLATFORM_ARM64 TRUE) +elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "armv*") + set(PROJECT_PLATFORM_ARM TRUE) +elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "e2k") + set(PROJECT_PLATFORM_E2K TRUE) +elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64le") + set(PROJECT_PLATFORM_PPC TRUE) +endif() + +if (PROJECT_PLATFORM_ARM) + add_compile_options(-mfpu=neon) +elseif (PROJECT_PLATFORM_ARM64) + #add_compile_options() +elseif (PROJECT_PLATFORM_E2K) + add_compile_options(-Wno-unknown-pragmas) +elseif (PROJECT_PLATFORM_PPC) + add_compile_options( + -maltivec + -mabi=altivec + ) + add_compile_definitions(NO_WARN_X86_INTRINSICS) +else() + add_compile_options( + -mfpmath=sse + -msse3 + ) +endif() + +if (XRAY_LINKER) + add_link_options(-fuse-ld=${XRAY_LINKER}) +endif() + +if (CMAKE_BUILD_TYPE STREQUAL "Debug") + add_compile_options(-Og) +endif() + +add_compile_definitions( + _MT + _CPPUNWIND +) + +if (NOT WIN32) + find_package(SDL2 2.0.18 REQUIRED) + find_package(OpenAL REQUIRED) + find_package(JPEG) + find_package(Ogg REQUIRED) + find_package(Vorbis REQUIRED) + find_package(Theora REQUIRED) + find_package(LZO REQUIRED) + find_package(mimalloc NAMES mimalloc2 mimalloc2.0 mimalloc) +endif() + +# Memory allocator option +if (mimalloc_FOUND) + set(MEMORY_ALLOCATOR "mimalloc" CACHE STRING "Use specific memory allocator (mimalloc/standard)") +else() + set(MEMORY_ALLOCATOR "standard" CACHE STRING "Use specific memory allocator (mimalloc/standard)") +endif() +set_property(CACHE MEMORY_ALLOCATOR PROPERTY STRINGS "mimalloc" "standard") + +if (MEMORY_ALLOCATOR STREQUAL "mimalloc" AND NOT mimalloc_FOUND) + message(FATAL_ERROR "mimalloc allocator requested but not found. Please, install mimalloc package or select standard allocator.") +endif() + +message(STATUS "Using ${MEMORY_ALLOCATOR} memory allocator") + +get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) + +if ("${LIB64}" STREQUAL "TRUE") + set(LIBSUFFIX 64) +else() + set(LIBSUFFIX "") +endif() + +set(XRAY_ENABLE_WARNINGS + -Wall + #-Werror + -Wextra + #-pedantic + -Wno-unknown-pragmas + -Wno-strict-aliasing + -Wno-parentheses + -Wno-unused-label + -Wno-unused-parameter + -Wno-switch + -Wno-trigraphs + #-Wno-padded + #-Wno-c++98-compat + #-Wno-c++98-compat-pedantic + #-Wno-c++11-compat + #-Wno-c++11-compat-pedantic + #-Wno-c++14-compat + #-Wno-c++14-compat-pedantic + #-Wno-newline-eof + $<$:$<$:-Wno-class-memaccess>> + $<$:$<$:-Wno-interference-size>> +) + +set(XRAY_DISABLE_WARNINGS "-w") diff --git a/cmake/XRay.Compiler.MSVC.cmake b/cmake/XRay.Compiler.MSVC.cmake new file mode 100644 index 00000000000..05e7bfddaa7 --- /dev/null +++ b/cmake/XRay.Compiler.MSVC.cmake @@ -0,0 +1,34 @@ +include_guard() + +# The MSVC compiler settings: +# Set properties: +set(CMAKE_VS_USE_DEBUG_LIBRARIES "$") + +# Clear predefined flags which we going to define ourselves +string(REGEX REPLACE "/EH[a-z]+" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # exceptions +string(REGEX REPLACE "/Z(7|i|I)" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) # debug information format + +# Enable standard C++ exceptions everywhere except ReleaseMasterGold +add_compile_options($<$>:/EHsc>) + +# Disable MS STL exceptions on ReleaseMasterGold +add_compile_definitions($<$:_HAS_EXCEPTIONS=0>) + +# Enable debug information for all configurations +add_compile_options(/Zi) + +# Enable SSE2 for 32-bit build +# (on x64 it's always enabled and produces error if try to to enable it) +add_compile_options($<$:/arch:SSE2>) + +# Disable specific warnings +add_compile_options( + /wd4201 # nonstandard extension used : nameless struct/union + /wd4251 # class 'x' needs to have dll-interface to be used by clients of class 'y' + /wd4275 # non dll-interface class 'x' used as base for dll-interface class 'y' +) + +# The MSVC linker settings: +add_link_options("/LARGEADDRESSAWARE") + +set(XRAY_DISABLE_WARNINGS "/w") diff --git a/cmake/XRay.Configurations.cmake b/cmake/XRay.Configurations.cmake new file mode 100644 index 00000000000..c6ac8733880 --- /dev/null +++ b/cmake/XRay.Configurations.cmake @@ -0,0 +1,34 @@ +include_guard() + +set(CMAKE_CONFIGURATION_TYPES + Debug + Mixed + Release + ReleaseMasterGold +) + +set(XRAY_DEFAULT_BUILD_TYPE ReleaseMasterGold) + +get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if (is_multi_config) + if (NOT CMAKE_DEFAULT_BUILD_TYPE) + set(CMAKE_DEFAULT_BUILD_TYPE ${XRAY_DEFAULT_BUILD_TYPE}) + endif() + if (CMAKE_BUILD_TYPE) + message(WARNING "CMAKE_BUILD_TYPE is ignored with multi-config generator.") + unset(CMAKE_BUILD_TYPE) + endif() +else() + message(DEBUG "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") + if (NOT CMAKE_BUILD_TYPE) + message(WARNING "CMAKE_BUILD_TYPE isn't defined, setting it to ${XRAY_DEFAULT_BUILD_TYPE}.") + set(CMAKE_BUILD_TYPE ${XRAY_DEFAULT_BUILD_TYPE}) + elseif (CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") + message(WARNING "MinSizeRel is unsupported, CMAKE_BUILD_TYPE is set to ${XRAY_DEFAULT_BUILD_TYPE}.") + set(CMAKE_BUILD_TYPE ${XRAY_DEFAULT_BUILD_TYPE}) + elseif (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") + message(WARNING "RelWithDebInfo equals Release in OpenXRay. Please, use Release build type directly.") + set(CMAKE_BUILD_TYPE Release) + endif() +endif() +unset(is_multi_config) diff --git a/cmake/packaging.cmake b/cmake/XRay.Packaging.cmake similarity index 99% rename from cmake/packaging.cmake rename to cmake/XRay.Packaging.cmake index cb188e7aa70..a61993f20c9 100644 --- a/cmake/packaging.cmake +++ b/cmake/XRay.Packaging.cmake @@ -1,3 +1,5 @@ +include_guard() + set(CPACK_PACKAGE_VENDOR "OpenXRay Team") set(CPACK_PACKAGE_CONTACT "OpenXRay ") set(CPACK_PACKAGE_DESCRIPTION ${CMAKE_PROJECT_DESCRIPTION}) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index 5d45f55158c..a7366dbaa5e 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -1,3 +1,5 @@ +include_guard() + function(target_sources_grouped) cmake_parse_arguments( PARSED_ARGS @@ -24,14 +26,13 @@ function(target_sources_grouped) source_group(${PARSED_ARGS_NAME} FILES ${PARSED_ARGS_FILES}) endfunction() -macro(set_git_info) +function(query_git_info output_sha output_branch) execute_process(COMMAND git rev-parse --verify HEAD WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE GIT_SHA1 ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE ) - message(STATUS "git commit: ${GIT_SHA1}") execute_process(COMMAND git rev-parse --abbrev-ref HEAD WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" @@ -39,8 +40,10 @@ macro(set_git_info) ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE ) - message(STATUS "git branch: ${GIT_BRANCH}") -endmacro() + + set(${output_sha} ${GIT_SHA1} PARENT_SCOPE) + set(${output_branch} ${GIT_BRANCH} PARENT_SCOPE) +endfunction() function(calculate_xray_build_id output) set(XRAY_START_DAY 31) diff --git a/res/gamedata/configs/openxray.ltx b/res/gamedata/configs/openxray.ltx index a97091cc2af..96564608316 100644 --- a/res/gamedata/configs/openxray.ltx +++ b/res/gamedata/configs/openxray.ltx @@ -12,6 +12,7 @@ sun_dir_azimuth = 0.0 ; Note, that the player can turn on firsteye himself ; if you set freelook or fixedlook actor_death_camera = freelook +currency = RU [lua_scripting] ; This will allow you to skip errors diff --git a/res/gamedata/configs/text/cze/openxray.xml b/res/gamedata/configs/text/cze/openxray.xml new file mode 100644 index 00000000000..694ef1f45f8 --- /dev/null +++ b/res/gamedata/configs/text/cze/openxray.xml @@ -0,0 +1,171 @@ + + + + Po sebrání automaticky vyložit zbraò + + + Vyložit všechny zbranì + + + Odstranit výbavu + + + Darovat + + + Naèítání svìtel + + + KLIENT: Pøipojování k + + + KLIENT: Objevování + + + KLIENT: Synchronizace + + + Vytváøení nové hry + + + Nepozastavovat pøi Alt+Tab + + + Polomìr detailu trávy + + + Styl rozhraní + + + Call of Pripyat + + + Zjednodušené sbírání pøedmìtù + + + Hromadné sbírání pøedmìtù + + + Zobrazit fáze naèítání + + + Pokroèilé dynamické osvìtlení (OpenGL) + + + Režim okna + + + Okno + + + Okno bez okrajù + + + Celá obrazovka + + + Celá obrazovka (rychlé Alt+Tab) + + + Kvalita stínù + + + Blízké mokré povrchy + + + Vzdálené mokré povrchy + + + Kvalita mokrých povrchù + + + Úhel pohledu + + + Úhel pohledu HUD + + + Jazyk + + + Nastavení gamepadu + + + Limit FPS ve høe + + + Limit FPS v menu + + + Grafický režim + + + pùvodní + + + vylepšený (výchozí) + + + vylepšený (vysoký) + + + Barevná korekce + + + výchozí + + + chladná + + + Filmová 1 + + + Filmová 2 + + + Filmová 3 + + + Hollywood + + + Pùvodní + + + Vibrant + + + Teplá + + + Èeština (Czech) + + + Angliètina (English) + + + Francouzština (French) + + + Nìmèina (German) + + + Italština (Italian) + + + Polština (Polish) + + + Ruština (Russian) + + + Španìlština (Spanish) + + + Ukrajinština (Ukrainian) + + + Japonština (Japan) + + \ No newline at end of file diff --git a/res/gamedata/configs/text/eng/openxray.xml b/res/gamedata/configs/text/eng/openxray.xml index 61b16ec7296..e5746f801ff 100644 --- a/res/gamedata/configs/text/eng/openxray.xml +++ b/res/gamedata/configs/text/eng/openxray.xml @@ -81,6 +81,9 @@ Field of view + + HUD field of view + Language @@ -135,6 +138,9 @@ warm + + Czech + English @@ -147,6 +153,9 @@ Italian + + Japanese + Polish diff --git a/res/gamedata/configs/text/ger/openxray.xml b/res/gamedata/configs/text/ger/openxray.xml index 2c112d4c471..253f5c377bf 100644 --- a/res/gamedata/configs/text/ger/openxray.xml +++ b/res/gamedata/configs/text/ger/openxray.xml @@ -1,4 +1,4 @@ - + wegstecken @@ -73,7 +73,10 @@ Nassflachen Qualitat - Blickwinkel (FOV) + Sichtfeld + + + Sichtfeld der HUD Spiel-FPS-Limit @@ -126,6 +129,9 @@ warm + + Tschechisch (Czech) + Englisch (English) diff --git a/res/gamedata/configs/text/pol/openxray.xml b/res/gamedata/configs/text/pol/openxray.xml index e254e3e8070..c36495fe925 100644 --- a/res/gamedata/configs/text/pol/openxray.xml +++ b/res/gamedata/configs/text/pol/openxray.xml @@ -1,4 +1,4 @@ - + roz³aduj wszystkie bronie @@ -13,7 +13,7 @@ Wczytywanie oœwietlenia - Klient: Czenie z + Klient: £¹czenie z Klient: Odradzanie @@ -76,7 +76,10 @@ Jakoœæ mokrych powierzchni - Pole widzenia + K¹t widzenia + + + K¹t widzenia HUD Jêzyk @@ -91,25 +94,25 @@ Limit FPS w menu - Graphics mode + Tryb graficzny - vanilla + Vanilla - enhanced (Default) + Rozszerzany (Domyœlny) - enhanced (High) + Rozszerzany (Wysoki) - Colour grading + Kolorystyka - default + Domyœlna - cold + Ch³odna Filmic 1 @@ -130,7 +133,10 @@ Vibrant - warm + Ciep³a + + + Czeski (Czech) Angielski (English) @@ -141,6 +147,9 @@ Niemiecki (German) + + Japoñski (Japanese) + W³oski (Italian) @@ -154,6 +163,6 @@ Hiszpañski (Spanish) - Ukrainski (Ukrainian) + Ukraiñski (Ukrainian) diff --git a/res/gamedata/configs/text/rus/openxray.xml b/res/gamedata/configs/text/rus/openxray.xml index f509b4eb0a4..041ef74fd65 100644 --- a/res/gamedata/configs/text/rus/openxray.xml +++ b/res/gamedata/configs/text/rus/openxray.xml @@ -85,7 +85,10 @@ Êà÷åñòâî íàìîêàíèÿ - Ïîëå çðåíèÿ + Óãîë îáçîðà + + + Óãîë îáçîðà HUD ßçûê @@ -141,6 +144,9 @@ ò¸ïëàÿ + + ×åøñêèé (Czech) + Àíãëèéñêèé (English) @@ -153,6 +159,9 @@ Èòàëüÿíñêèé (Italian) + + ßïîíñêèé (Japanese) + Ïîëüñêèé (Polish) diff --git a/res/gamedata/configs/text/ukr/openxray.xml b/res/gamedata/configs/text/ukr/openxray.xml index 87d87767fe1..767c3272777 100644 --- a/res/gamedata/configs/text/ukr/openxray.xml +++ b/res/gamedata/configs/text/ukr/openxray.xml @@ -85,7 +85,10 @@ ßê³ñòü íàìîêàííÿ - Ïîëå çîðó + Êóò îãëÿäó + + + Êóò îãëÿäó HUD Ìîâà @@ -141,6 +144,9 @@ òåïëà + + ×åñüêà (Czech) + Àíãë³éñüêà (English) diff --git a/res/gamedata/configs/ui/ui_mm_opt.xml b/res/gamedata/configs/ui/ui_mm_opt.xml index 4e76b90b0e8..889259f9296 100644 --- a/res/gamedata/configs/ui/ui_mm_opt.xml +++ b/res/gamedata/configs/ui/ui_mm_opt.xml @@ -630,6 +630,16 @@ + + ui_mm_hud_fov + + + + + 0 + + + ui_mm_show_crosshair diff --git a/res/gamedata/configs/ui/ui_mm_opt_16.xml b/res/gamedata/configs/ui/ui_mm_opt_16.xml index 9ef450d7a56..54a0f3364e4 100644 --- a/res/gamedata/configs/ui/ui_mm_opt_16.xml +++ b/res/gamedata/configs/ui/ui_mm_opt_16.xml @@ -633,6 +633,16 @@ + + ui_mm_hud_fov + + + + + 0 + + + ui_mm_show_crosshair diff --git a/res/gamedata/scripts/ui_mm_opt_gameplay.script b/res/gamedata/scripts/ui_mm_opt_gameplay.script index 7d052c87dc1..23f4228d747 100644 --- a/res/gamedata/scripts/ui_mm_opt_gameplay.script +++ b/res/gamedata/scripts/ui_mm_opt_gameplay.script @@ -39,6 +39,11 @@ function opt_gameplay:InitControls(x, y, xml, handler) xml:InitTrackBar("tab_gameplay:track_fov", _st) self.scroll_v:AddWindow(_st, true) + _st = xml:InitStatic("tab_gameplay:templ_item", nil) + xml:InitStatic("tab_gameplay:cap_hud_fov", _st) + xml:InitTrackBar("tab_gameplay:track_hud_fov", _st) + self.scroll_v:AddWindow(_st, true) + _st = xml:InitStatic("tab_gameplay:templ_item", nil) xml:InitStatic("tab_gameplay:cap_check_tips", _st) xml:InitCheck("tab_gameplay:check_tips", _st) diff --git a/src/.clang-format b/src/.clang-format deleted file mode 100644 index b07e62caebd..00000000000 --- a/src/.clang-format +++ /dev/null @@ -1,168 +0,0 @@ -# Configured for clang-format 21 ---- -Language: Cpp -Standard: c++17 -IndentWidth: 4 -TabWidth: 4 -UseTab: Never -AccessModifierOffset: -4 -AlignAfterOpenBracket: DontAlign -AlignArrayOfStructures: Right -AlignConsecutiveAssignments: None -AlignConsecutiveBitFields: AcrossComments -AlignConsecutiveDeclarations: None -AlignConsecutiveMacros: None -AlignConsecutiveShortCaseStatements: AcrossComments -AlignEscapedNewlines: LeftWithLastLine -AlignOperands: DontAlign -AlignTrailingComments: - Kind: Always -AllowAllArgumentsOnNextLine: false -AllowAllParametersOfDeclarationOnNextLine: false -AllowBreakBeforeNoexceptSpecifier: Never -AllowShortBlocksOnASingleLine: Empty -AllowShortCaseLabelsOnASingleLine: true -AllowShortCompoundRequirementOnASingleLine: true -AllowShortEnumsOnASingleLine: false -AllowShortFunctionsOnASingleLine: Empty -AllowShortIfStatementsOnASingleLine: Never -AllowShortLambdasOnASingleLine: Empty -AllowShortLoopsOnASingleLine: false -AllowShortNamespacesOnASingleLine: false -AlwaysBreakBeforeMultilineStrings: false -BinPackArguments: true -BinPackParameters: true -BitFieldColonSpacing: Both -BraceWrapping: - AfterCaseLabel: true - AfterClass: true - AfterControlStatement: Always - AfterEnum: true - AfterFunction: true - AfterNamespace: true - AfterStruct: true - AfterUnion: true - AfterExternBlock: true - BeforeCatch: true - BeforeElse: true - BeforeLambdaBody: true - BeforeWhile: false - IndentBraces: false - SplitEmptyFunction: false - SplitEmptyRecord: false - SplitEmptyNamespace: true -BreakAfterAttributes: Leave -BreakAfterReturnType: Automatic -BreakBeforeBinaryOperators: None -BreakBeforeBraces: Custom -BreakBeforeConceptDeclarations: Always -BreakBeforeTemplateCloser: true -BreakBeforeTernaryOperators: false -BreakBinaryOperations: RespectPrecedence -BreakConstructorInitializers: BeforeColon -BreakFunctionDefinitionParameters: false -BreakInheritanceList: AfterComma -BreakStringLiterals: true -BreakTemplateDeclarations: Yes -ColumnLimit: 160 # for a monitor with a resolution width of 1920 pixels -CommentPragmas: '^ (IWYU pragma:|NOLINT)' -CompactNamespaces: false -#ConstructorInitializerAllOnOneLineOrOnePerLine: false -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: false -EmptyLineAfterAccessModifier: Never -EmptyLineBeforeAccessModifier: LogicalBlock -EnumTrailingComma: Leave -FixNamespaceComments: true -#IncludeBlocks: Regroup -IncludeCategories: - - Regex: '(stdafx.h|pch.hpp|pch.h|precompiled.h)' - Priority: -1 - - Regex: '^<' - Priority: 1 - - Regex: '^"' - Priority: 2 -IndentAccessModifiers: false -IndentCaseBlocks: false -IndentCaseLabels: false -IndentExportBlock: false -IndentExternBlock: NoIndent -IndentGotoLabels: false -IndentPPDirectives: AfterHash -IndentRequiresClause: false -IndentWrappedFunctionNames: false -InsertBraces: false -InsertNewlineAtEOF: true -InsertTrailingCommas: false -KeepEmptyLines: - AtEndOfFile: false - AtStartOfBlock: false - AtStartOfFile: false -LambdaBodyIndentation: Signature -# MacroBlockBegin: '' -# MacroBlockEnd: '' -# Macros: -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None -PackConstructorInitializers: BinPack -PenaltyBreakAssignment: 0 -PenaltyBreakBeforeFirstCallParameter: 100 -PenaltyBreakBeforeMemberAccess: 0 -PenaltyBreakComment: 300 -PenaltyBreakFirstLessLess: 120 -PenaltyBreakOpenParenthesis: 300 -PenaltyBreakScopeResolution: 25 -PenaltyBreakString: 1000 -PenaltyExcessCharacter: 10 -PenaltyReturnTypeOnItsOwnLine: 1000000 -PointerAlignment: Left -QualifierOrder: [friend, volatile, inline, static, constexpr, const, restrict, type] -ReferenceAlignment: Pointer -ReflowComments: IndentOnly -RemoveEmptyLinesInUnwrappedLines: true -# RemoveSemicolon: true -RequiresClausePosition: WithPreceding -RequiresExpressionIndentation: OuterScope -SeparateDefinitionBlocks: Always -ShortNamespaceLines: 5 -# SortIncludes: true -SortUsingDeclarations: Lexicographic -SpaceAfterCStyleCast: false -SpaceAfterLogicalNot: false -SpaceAfterOperatorKeyword: false -SpaceAfterTemplateKeyword: true -SpaceAroundPointerQualifiers: Default -SpaceBeforeAssignmentOperators: true -SpaceBeforeCaseColon: false -SpaceBeforeCpp11BracedList: false -SpaceBeforeCtorInitializerColon: true -SpaceBeforeInheritanceColon: true -SpaceBeforeParens: Custom -SpaceBeforeParensOptions: - AfterControlStatements: true - AfterForeachMacros: false - AfterFunctionDeclarationName: false - AfterFunctionDefinitionName: false - AfterIfMacros: false - AfterOverloadedOperator: false - AfterPlacementOperator: true - AfterRequiresInClause: true - AfterRequiresInExpression: true - BeforeNonEmptyParentheses: false -SpaceBeforeRangeBasedForLoopColon: true -SpaceBeforeSquareBrackets: false -SpaceInEmptyBlock: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: Never -SpacesInContainerLiterals: false -SpacesInLineCommentPrefix: - Minimum: 1 - Maximum: -1 -SpacesInParens: Never -SpacesInSquareBrackets: false -# StatementAttributeLikeMacros: -# StatementMacros: -# WhitespaceSensitiveMacros: -WrapNamespaceBodyWithEmptyLines: Never -... diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 26d661147a5..d9a18001a4e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,10 @@ +add_compile_definitions( + $<$:MASTER_GOLD> + $<$>:XRAY_STATIC_BUILD> +) + +add_compile_options(${XRAY_ENABLE_WARNINGS}) + add_subdirectory(utils) add_subdirectory(Layers) add_subdirectory(xr_3da) diff --git a/src/Common/Config.hpp b/src/Common/Config.hpp index 6932a7d073b..ec6ec337cbb 100644 --- a/src/Common/Config.hpp +++ b/src/Common/Config.hpp @@ -1,9 +1,6 @@ #pragma once // CONFIG_PROFILE_LOCKS -// XXX: convert to command line params -// CONFIG_SCRIPT_ENGINE_LOG_EXPORTS -// CONFIG_SCRIPT_ENGINE_LOG_SKIPPED_EXPORTS /* Callbacks */ //#define ACTOR_BEFORE_DEATH_CALLBACK // For extending the life of the actor to fake death or do other tasks that need to happen before actor is dead diff --git a/src/Common/object_loader.h b/src/Common/object_loader.h index 76ebbcb6df6..b0ac6d1fafb 100644 --- a/src/Common/object_loader.h +++ b/src/Common/object_loader.h @@ -134,7 +134,7 @@ struct CLoader { shared_str S; stream.r_stringZ(S); - data = xr_strdup(*S); + data = xr_strdup(S.c_str()); } static void load_data(shared_str& data, M& stream, const P& p) { stream.r_stringZ(data); } @@ -142,7 +142,7 @@ struct CLoader { shared_str S; stream.r_stringZ(S); - data = *S; + data = S.c_str(); } template diff --git a/src/Include/xrAPI/xrAPI.h b/src/Include/xrAPI/xrAPI.h index 4699f6e6f2c..bc85a0629ea 100644 --- a/src/Include/xrAPI/xrAPI.h +++ b/src/Include/xrAPI/xrAPI.h @@ -1,9 +1,13 @@ #pragma once -#ifdef XRAPI_EXPORTS -#define XRAPI_API XR_EXPORT +#ifdef XRAY_STATIC_BUILD +# define XRAPI_API #else -#define XRAPI_API XR_IMPORT +# ifdef XRAPI_EXPORTS +# define XRAPI_API XR_EXPORT +# else +# define XRAPI_API XR_IMPORT +# endif #endif class IRender; diff --git a/src/Include/xrRender/UIRender.h b/src/Include/xrRender/UIRender.h index 10ce2a10e7e..34d92eb8505 100644 --- a/src/Include/xrRender/UIRender.h +++ b/src/Include/xrRender/UIRender.h @@ -58,7 +58,6 @@ class IUIRender //. virtual void StartLineList(u32 iMaxVerts) = 0; //. virtual void FlushLineList() = 0; virtual void SetScissor(Irect* rect = nullptr) = 0; - virtual void GetActiveTextureResolution(Fvector2& res) = 0; //. virtual void PushPoint(float x, float y, u32 c, float u, float v) = 0; //. virtual void PushPoint(int x, int y, u32 c, float u, float v) = 0; diff --git a/src/Include/xrRender/UIShader.h b/src/Include/xrRender/UIShader.h index 4c042aaac37..5db35eb1314 100644 --- a/src/Include/xrRender/UIShader.h +++ b/src/Include/xrRender/UIShader.h @@ -10,6 +10,9 @@ class IUIShader virtual void create(LPCSTR sh, LPCSTR tex = nullptr) = 0; virtual bool inited() = 0; virtual void destroy() = 0; + + virtual bool GetBaseTextureResolution(Fvector2& res) = 0; + virtual xrImTextureData GetImGuiTextureId() = 0; }; #endif // UIShader_included diff --git a/src/Include/xrRender/WallMarkArray.h b/src/Include/xrRender/WallMarkArray.h index f1e6c80bbec..80329592b3a 100644 --- a/src/Include/xrRender/WallMarkArray.h +++ b/src/Include/xrRender/WallMarkArray.h @@ -3,8 +3,8 @@ #pragma once #include "FactoryPtr.h" -#include "UIShader.h" +class IUIShader; typedef FactoryPtr wm_shader; class IWallMarkArray diff --git a/src/Layers/CMakeLists.txt b/src/Layers/CMakeLists.txt index 3b3c39c24f1..d4bfcdcc5ea 100644 --- a/src/Layers/CMakeLists.txt +++ b/src/Layers/CMakeLists.txt @@ -1,6 +1,5 @@ add_subdirectory(xrAPI) -# TODO test on Windows if (WIN32) add_subdirectory(xrRenderPC_R4) endif() diff --git a/src/Layers/xrAPI/CMakeLists.txt b/src/Layers/xrAPI/CMakeLists.txt index 2d6408900a2..4f3a9ac5f60 100644 --- a/src/Layers/xrAPI/CMakeLists.txt +++ b/src/Layers/xrAPI/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(xrAPI SHARED) +add_library(xrAPI) target_sources(xrAPI PRIVATE stdafx.h @@ -25,6 +25,8 @@ target_precompile_headers(xrAPI stdafx.h ) -install(TARGETS xrAPI LIBRARY - DESTINATION "${CMAKE_INSTALL_LIBDIR}" -) +if (BUILD_SHARED_LIBS) + install(TARGETS xrAPI LIBRARY + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) +endif() diff --git a/src/Layers/xrRender/Blender_CLSID.h b/src/Layers/xrRender/Blender_CLSID.h index b6ce5cbe03d..2a56ae01304 100644 --- a/src/Layers/xrRender/Blender_CLSID.h +++ b/src/Layers/xrRender/Blender_CLSID.h @@ -3,34 +3,34 @@ namespace xray::render::RENDER_NAMESPACE { // Main blenders for level -constexpr CLASS_ID B_DEFAULT = MK_CLSID('L', 'M', ' ', ' ', ' ', ' ', ' ', ' '); -constexpr CLASS_ID B_DEFAULT_AREF = MK_CLSID('L', 'M', '_', 'A', 'R', 'E', 'F', ' '); -constexpr CLASS_ID B_VERT = MK_CLSID('V', ' ', ' ', ' ', ' ', ' ', ' ', ' '); -constexpr CLASS_ID B_VERT_AREF = MK_CLSID('V', '_', 'A', 'R', 'E', 'F', ' ', ' '); -constexpr CLASS_ID B_LmBmmD = MK_CLSID('L', 'm', 'B', 'm', 'm', 'D', ' ', ' '); -constexpr CLASS_ID B_LaEmB = MK_CLSID('L', 'a', 'E', 'm', 'B', ' ', ' ', ' '); -constexpr CLASS_ID B_LmEbB = MK_CLSID('L', 'm', 'E', 'b', 'B', ' ', ' ', ' '); -constexpr CLASS_ID B_B = MK_CLSID('B', 'm', 'm', 'D', ' ', ' ', ' ', ' '); -constexpr CLASS_ID B_BmmD = MK_CLSID('B', 'm', 'm', 'D', 'o', 'l', 'd', ' '); +constexpr CLASS_ID B_DEFAULT = make_clsid("LM "); +constexpr CLASS_ID B_DEFAULT_AREF = make_clsid("LM_AREF "); +constexpr CLASS_ID B_VERT = make_clsid("V "); +constexpr CLASS_ID B_VERT_AREF = make_clsid("V_AREF "); +constexpr CLASS_ID B_LmBmmD = make_clsid("LmBmmD "); +constexpr CLASS_ID B_LaEmB = make_clsid("LaEmB "); +constexpr CLASS_ID B_LmEbB = make_clsid("LmEbB "); +constexpr CLASS_ID B_B = make_clsid("BmmD "); +constexpr CLASS_ID B_BmmD = make_clsid("BmmDold "); -constexpr CLASS_ID B_PARTICLE = MK_CLSID('P', 'A', 'R', 'T', 'I', 'C', 'L', 'E'); +constexpr CLASS_ID B_PARTICLE = make_clsid("PARTICLE"); // Screen space blenders -constexpr CLASS_ID B_SCREEN_SET = MK_CLSID('S', '_', 'S', 'E', 'T', ' ', ' ', ' '); -constexpr CLASS_ID B_SCREEN_GRAY = MK_CLSID('S', '_', 'G', 'R', 'A', 'Y', ' ', ' '); +constexpr CLASS_ID B_SCREEN_SET = make_clsid("S_SET "); +constexpr CLASS_ID B_SCREEN_GRAY = make_clsid("S_GRAY "); -constexpr CLASS_ID B_LIGHT = MK_CLSID('L', 'I', 'G', 'H', 'T', ' ', ' ', ' '); -constexpr CLASS_ID B_BLUR = MK_CLSID('B', 'L', 'U', 'R', ' ', ' ', ' ', ' '); -constexpr CLASS_ID B_SHADOW_TEX = MK_CLSID('S', 'H', '_', 'T', 'E', 'X', ' ', ' '); -constexpr CLASS_ID B_SHADOW_WORLD = MK_CLSID('S', 'H', '_', 'W', 'O', 'R', 'L', 'D'); +constexpr CLASS_ID B_LIGHT = make_clsid("LIGHT "); +constexpr CLASS_ID B_BLUR = make_clsid("BLUR "); +constexpr CLASS_ID B_SHADOW_TEX = make_clsid("SH_TEX "); +constexpr CLASS_ID B_SHADOW_WORLD = make_clsid("SH_WORLD"); -constexpr CLASS_ID B_DETAIL = MK_CLSID('D', '_', 'S', 'T', 'I', 'L', 'L', ' '); -constexpr CLASS_ID B_TREE = MK_CLSID('D', '_', 'T', 'R', 'E', 'E', ' ', ' '); +constexpr CLASS_ID B_DETAIL = make_clsid("D_STILL "); +constexpr CLASS_ID B_TREE = make_clsid("D_TREE "); -constexpr CLASS_ID B_MODEL = MK_CLSID('M', 'O', 'D', 'E', 'L', ' ', ' ', ' '); -constexpr CLASS_ID B_MODEL_EbB = MK_CLSID('M', 'O', 'D', 'E', 'L', 'E', 'b', 'B'); +constexpr CLASS_ID B_MODEL = make_clsid("MODEL "); +constexpr CLASS_ID B_MODEL_EbB = make_clsid("MODELEbB"); // Editor -constexpr CLASS_ID B_EDITOR_WIRE = MK_CLSID('E', '_', 'W', 'I', 'R', 'E', ' ', ' '); -constexpr CLASS_ID B_EDITOR_SEL = MK_CLSID('E', '_', 'S', 'E', 'L', ' ', ' ', ' '); +constexpr CLASS_ID B_EDITOR_WIRE = make_clsid("E_WIRE "); +constexpr CLASS_ID B_EDITOR_SEL = make_clsid("E_SEL "); } // namespace xray::render::RENDER_NAMESPACE diff --git a/src/Layers/xrRender/Blender_Recorder.cpp b/src/Layers/xrRender/Blender_Recorder.cpp index cbb4f3c6c8a..1f8c2275ad8 100644 --- a/src/Layers/xrRender/Blender_Recorder.cpp +++ b/src/Layers/xrRender/Blender_Recorder.cpp @@ -64,8 +64,8 @@ void CBlender_Compile::_cpp_Compile(ShaderElement* _SH) if (id >= 0) { if (id >= int(lst.size())) - xrDebug::Fatal(DEBUG_INFO, "Not enought textures for shader. Base texture: '%s'.", *lst[0]); - base = *lst[id]; + xrDebug::Fatal(DEBUG_INFO, "Not enought textures for shader. Base texture: '%s'.", lst[0].c_str()); + base = lst[id].c_str(); } if (!RImplementation.Resources->m_textures_description.GetDetailTexture(base, detail_texture, detail_scaler)) bDetail = false; @@ -83,8 +83,8 @@ void CBlender_Compile::_cpp_Compile(ShaderElement* _SH) if (id >= 0) { if (id >= int(lst.size())) - xrDebug::Fatal(DEBUG_INFO, "Not enought textures for shader. Base texture: '%s'.", *lst[0]); - base = *lst[id]; + xrDebug::Fatal(DEBUG_INFO, "Not enought textures for shader. Base texture: '%s'.", lst[0].c_str()); + base = lst[id].c_str(); } } // Igor @@ -332,8 +332,8 @@ void CBlender_Compile::Stage_Texture(LPCSTR name, u32, u32 fmin, u32 fmip, u32 f if (id >= 0) { if (id >= int(lst.size())) - xrDebug::Fatal(DEBUG_INFO, "Not enought textures for shader. Base texture: '%s'.", *lst[0]); - N = *lst[id]; + xrDebug::Fatal(DEBUG_INFO, "Not enought textures for shader. Base texture: '%s'.", lst[0].c_str()); + N = lst[id].c_str(); } passTextures.emplace_back(Stage(), ref_texture(RImplementation.Resources->_CreateTexture(N))); // i_Address (Stage(),address); @@ -343,7 +343,7 @@ void CBlender_Compile::Stage_Matrix(LPCSTR name, int iChannel) { sh_list& lst = L_matrices; int id = ParseName(name); - CMatrix* M = RImplementation.Resources->_CreateMatrix((id >= 0) ? *lst[id] : name); + CMatrix* M = RImplementation.Resources->_CreateMatrix((id >= 0) ? lst[id].c_str() : name); passMatrices.push_back(M); // Setup transform pipeline @@ -369,7 +369,7 @@ void CBlender_Compile::Stage_Constant(LPCSTR name) { sh_list& lst = L_constants; int id = ParseName(name); - passConstants.push_back(RImplementation.Resources->_CreateConstant((id >= 0) ? *lst[id] : name)); + passConstants.push_back(RImplementation.Resources->_CreateConstant((id >= 0) ? lst[id].c_str() : name)); } void CBlender_Compile::SetupSampler(u32 stage, pcstr sampler) diff --git a/src/Layers/xrRender/Blender_Recorder_StandartBinding.cpp b/src/Layers/xrRender/Blender_Recorder_StandartBinding.cpp index 44466737be4..5e72696a094 100644 --- a/src/Layers/xrRender/Blender_Recorder_StandartBinding.cpp +++ b/src/Layers/xrRender/Blender_Recorder_StandartBinding.cpp @@ -696,7 +696,7 @@ void CBlender_Compile::SetMapping() for (u32 it = 0; it < RImplementation.Resources->v_constant_setup.size(); it++) { std::pair cs = RImplementation.Resources->v_constant_setup[it]; - r_Constant(*cs.first, cs.second); + r_Constant(cs.first.c_str(), cs.second); } // Anomaly diff --git a/src/Layers/xrRender/D3DXRenderBase.cpp b/src/Layers/xrRender/D3DXRenderBase.cpp index e8d9fdc9650..78a126af2df 100644 --- a/src/Layers/xrRender/D3DXRenderBase.cpp +++ b/src/Layers/xrRender/D3DXRenderBase.cpp @@ -351,6 +351,19 @@ void D3DXRenderBase::OnAssetsChanged() Resources->m_textures_description.Load(); } +xrImTextureData D3DXRenderBase::GetImGuiTextureId(pcstr texture_name) +{ + const auto texture = Resources->_CreateTexture(texture_name); + return + { + texture->GetImTextureID(), + { + (float)texture->get_Width(), + (float)texture->get_Height() + } + }; +} + void D3DXRenderBase::DumpStatistics(IGameFont& font, IPerformanceAlert* alert) { BasicStats.FrameEnd(); diff --git a/src/Layers/xrRender/D3DXRenderBase.h b/src/Layers/xrRender/D3DXRenderBase.h index a34aef40777..ab0cab10abd 100644 --- a/src/Layers/xrRender/D3DXRenderBase.h +++ b/src/Layers/xrRender/D3DXRenderBase.h @@ -60,6 +60,8 @@ class D3DXRenderBase : public IRender, public pureFrame virtual void OnAssetsChanged() override; virtual void DumpStatistics(class IGameFont& font, class IPerformanceAlert* alert) override; + xrImTextureData GetImGuiTextureId(pcstr texture_name) override; + RenderContext GetCurrentContext() const override { return IRender::PrimaryContext; } void MakeContextCurrent(RenderContext /*context*/) override {} diff --git a/src/Layers/xrRender/FVisual.cpp b/src/Layers/xrRender/FVisual.cpp index 10b412f50c9..0a531cc13df 100644 --- a/src/Layers/xrRender/FVisual.cpp +++ b/src/Layers/xrRender/FVisual.cpp @@ -81,7 +81,7 @@ void Fvisual::Load(const char* N, IReader* data, u32 dwFlags) ID = def().r_u32(); m_fast->iBase = def().r_u32(); m_fast->iCount = def().r_u32(); - m_fast->dwPrimitives = iCount / 3; + m_fast->dwPrimitives = m_fast->iCount / 3; VERIFY(nullptr == m_fast->p_rm_Indices); m_fast->p_rm_Indices = RImplementation.getIB(ID, true); diff --git a/src/Layers/xrRender/ModelPool.cpp b/src/Layers/xrRender/ModelPool.cpp index 10ce2e0ac9d..678236a5492 100644 --- a/src/Layers/xrRender/ModelPool.cpp +++ b/src/Layers/xrRender/ModelPool.cpp @@ -137,9 +137,9 @@ dxRender_Visual* CModelPool::Instance_Load(const char* N, BOOL allow_register) for (u16 k = 0; k < cnt; k++) { CBoneData& bd = K->LL_GetData(k); - if (*(bd.game_mtl_name)) + if (bd.game_mtl_name.c_str()) { - bd.game_mtl_idx = GMLib.GetMaterialIdx(*bd.game_mtl_name); + bd.game_mtl_idx = GMLib.GetMaterialIdx(bd.game_mtl_name.c_str()); R_ASSERT2(GMLib.GetMaterialByIdx(bd.game_mtl_idx)->Flags.is(SGameMtl::flDynamic), "Required dynamic game material"); } @@ -232,7 +232,7 @@ dxRender_Visual* CModelPool::Instance_Find(LPCSTR N) xr_vector::iterator I; for (I = Models.begin(); I != Models.end(); ++I) { - if (I->name[0] && (0 == xr_strcmp(*I->name, N))) + if (I->name[0] && 0 == xr_strcmp(I->name.c_str(), N)) { Model = I->model; break; @@ -383,7 +383,7 @@ void CModelPool::Discard(dxRender_Visual*& V, BOOL b_complete) { if (I->name == name) { - if (b_complete || strchr(*name, '#')) + if (b_complete || strchr(name.c_str(), '#')) { VERIFY(I->refs > 0); I->refs--; diff --git a/src/Layers/xrRender/ParticleEffectDef.cpp b/src/Layers/xrRender/ParticleEffectDef.cpp index e4ecafd7dbc..f6c9fbf3a35 100644 --- a/src/Layers/xrRender/ParticleEffectDef.cpp +++ b/src/Layers/xrRender/ParticleEffectDef.cpp @@ -46,9 +46,9 @@ CPEDef::~CPEDef() } void CPEDef::CreateShader() { - if (*m_ShaderName && *m_TextureName) + if (m_ShaderName.c_str() && m_TextureName.c_str()) { - m_CachedShader.create(*m_ShaderName, *m_TextureName); + m_CachedShader.create(m_ShaderName.c_str(), m_TextureName.c_str()); } } void CPEDef::DestroyShader() { m_CachedShader.destroy(); } diff --git a/src/Layers/xrRender/ParticleEffectDef.h b/src/Layers/xrRender/ParticleEffectDef.h index e47f2b48df8..60233521819 100644 --- a/src/Layers/xrRender/ParticleEffectDef.h +++ b/src/Layers/xrRender/ParticleEffectDef.h @@ -99,7 +99,7 @@ class ECORE_API CPEDef ~CPEDef(); void SetName(LPCSTR name); - LPCSTR Name() const { return *m_Name; } + pcstr Name() const { return m_Name.c_str(); } void CreateShader(); void DestroyShader(); diff --git a/src/Layers/xrRender/ParticleGroup.cpp b/src/Layers/xrRender/ParticleGroup.cpp index 3b7c12680bd..59728b1f17c 100644 --- a/src/Layers/xrRender/ParticleGroup.cpp +++ b/src/Layers/xrRender/ParticleGroup.cpp @@ -318,10 +318,10 @@ void OnGroupParticleBirth(void* owner, u32 param, PAPI::Particle& m, u32 idx) const CPGDef::SEffect* eff = PGD->m_Effects[param]; if (eff->m_Flags.is(CPGDef::SEffect::flOnBirthChild)) - PG->items[param].StartFreeChild(PE, *eff->m_OnBirthChildName, m); + PG->items[param].StartFreeChild(PE, eff->m_OnBirthChildName.c_str(), m); if (eff->m_Flags.is(CPGDef::SEffect::flOnPlayChild)) - PG->items[param].StartRelatedChild(PE, *eff->m_OnPlayChildName, m); + PG->items[param].StartRelatedChild(PE, eff->m_OnPlayChildName.c_str(), m); } void OnGroupParticleDead(void* owner, u32 param, PAPI::Particle& m, u32 idx) { @@ -341,7 +341,7 @@ void OnGroupParticleDead(void* owner, u32 param, PAPI::Particle& m, u32 idx) PG->items[param].StopRelatedChild(idx); if (eff->m_Flags.is(CPGDef::SEffect::flOnDeadChild)) - PG->items[param].StartFreeChild(PE, *eff->m_OnDeadChildName, m); + PG->items[param].StartFreeChild(PE, eff->m_OnDeadChildName.c_str(), m); } //------------------------------------------------------------------------------ void CParticleGroup::SItem::OnFrame(u32 u_dt, const CPGDef::SEffect& def, Fbox& box, bool& bPlaying) @@ -555,7 +555,7 @@ BOOL CParticleGroup::Compile(CPGDef* def) items.resize(m_Def->m_Effects.size()); for (CPGDef::EffectVec::const_iterator e_it = m_Def->m_Effects.begin(); e_it != m_Def->m_Effects.end(); ++e_it) { - CParticleEffect* eff = (CParticleEffect*)RImplementation.model_CreatePE(*(*e_it)->m_EffectName); + CParticleEffect* eff = (CParticleEffect*)RImplementation.model_CreatePE((*e_it)->m_EffectName.c_str()); eff->SetBirthDeadCB(OnGroupParticleBirth, OnGroupParticleDead, this, u32(e_it - m_Def->m_Effects.begin())); items[e_it - def->m_Effects.begin()].Set(eff); } diff --git a/src/Layers/xrRender/R_Backend.h b/src/Layers/xrRender/R_Backend.h index 9483dffad82..9ab2b11c0fd 100644 --- a/src/Layers/xrRender/R_Backend.h +++ b/src/Layers/xrRender/R_Backend.h @@ -428,7 +428,7 @@ class ECORE_API CBackend IC void set_FillMode(u32 _mode); void set_ClipPlanes(u32 _enable, Fplane* _planes = nullptr, u32 count = 0); void set_ClipPlanes(u32 _enable, Fmatrix* _xform = nullptr, u32 fmask = 0xff); - IC void set_Scissor(Irect* rect = nullptr); + IC void set_Scissor(const Irect* rect = nullptr); IC void SetViewport(const D3D_VIEWPORT& viewport) const; IC void SetTextureFactor(u32 factor) const; diff --git a/src/Layers/xrRender/ResourceManager.h b/src/Layers/xrRender/ResourceManager.h index ba4031d3942..8151e5ff15d 100644 --- a/src/Layers/xrRender/ResourceManager.h +++ b/src/Layers/xrRender/ResourceManager.h @@ -7,9 +7,8 @@ #include "Shader.h" #include "tss_def.h" #include "TextureDescrManager.h" + #include "xrScriptEngine/script_engine.hpp" -// refs -struct lua_State; namespace xray::render::RENDER_NAMESPACE { diff --git a/src/Layers/xrRender/ResourceManager_Resources.cpp b/src/Layers/xrRender/ResourceManager_Resources.cpp index 333e6255efe..a0003b8a6f0 100644 --- a/src/Layers/xrRender/ResourceManager_Resources.cpp +++ b/src/Layers/xrRender/ResourceManager_Resources.cpp @@ -122,14 +122,14 @@ void CResourceManager::_DeleteRT(const CRT* RT) { if (0 == (RT->dwFlags & xr_resource_flagged::RF_REGISTERED)) return; - pstr N = pstr(*RT->cName); + pstr N = pstr(RT->cName.c_str()); map_RT::iterator I = m_rtargets.find(N); if (I != m_rtargets.end()) { m_rtargets.erase(I); return; } - Msg("! ERROR: Failed to find render-target '%s'", *RT->cName); + Msg("! ERROR: Failed to find render-target '%s'", RT->cName.c_str()); } // DX10 cut @@ -263,14 +263,14 @@ void CResourceManager::_DeleteTexture(const CTexture* T) if (0 == (T->dwFlags & xr_resource_flagged::RF_REGISTERED)) return; - pstr N = pstr(*T->cName); + pstr N = pstr(T->cName.c_str()); map_Texture::iterator I = m_textures.find(N); if (I != m_textures.end()) { m_textures.erase(I); return; } - Msg("! ERROR: Failed to find texture surface '%s'", *T->cName); + Msg("! ERROR: Failed to find texture surface '%s'", T->cName.c_str()); } #ifdef DEBUG @@ -283,7 +283,7 @@ void CResourceManager::DBG_VerifyTextures() R_ASSERT(I->first); R_ASSERT(I->second); R_ASSERT(I->second->cName); - R_ASSERT(0 == xr_strcmp(I->first, *I->second->cName)); + R_ASSERT(0 == xr_strcmp(I->first, I->second->cName.c_str())); } } #endif @@ -312,14 +312,14 @@ void CResourceManager::_DeleteMatrix(const CMatrix* M) { if (0 == (M->dwFlags & xr_resource_flagged::RF_REGISTERED)) return; - pstr N = pstr(*M->cName); + pstr N = pstr(M->cName.c_str()); map_Matrix::iterator I = m_matrices.find(N); if (I != m_matrices.end()) { m_matrices.erase(I); return; } - Msg("! ERROR: Failed to find xform-def '%s'", *M->cName); + Msg("! ERROR: Failed to find xform-def '%s'", M->cName.c_str()); } void CResourceManager::ED_UpdateMatrix(LPCSTR Name, CMatrix* data) @@ -351,14 +351,14 @@ void CResourceManager::_DeleteConstant(const CConstant* C) { if (0 == (C->dwFlags & xr_resource_flagged::RF_REGISTERED)) return; - pstr N = pstr(*C->cName); + pstr N = pstr(C->cName.c_str()); map_Constant::iterator I = m_constants.find(N); if (I != m_constants.end()) { m_constants.erase(I); return; } - Msg("! ERROR: Failed to find R1-constant-def '%s'", *C->cName); + Msg("! ERROR: Failed to find R1-constant-def '%s'", C->cName.c_str()); } void CResourceManager::ED_UpdateConstant(LPCSTR Name, CConstant* data) diff --git a/src/Layers/xrRender/ResourceManager_Scripting.cpp b/src/Layers/xrRender/ResourceManager_Scripting.cpp index bddde0db32e..eb7cd6801cb 100644 --- a/src/Layers/xrRender/ResourceManager_Scripting.cpp +++ b/src/Layers/xrRender/ResourceManager_Scripting.cpp @@ -6,7 +6,7 @@ #include "Blender.h" #include "Blender_Recorder.h" #include "xrScriptEngine/script_engine.hpp" -#include "luabind/return_reference_to_policy.hpp" +#include "xrScriptEngine/script_space.hpp" #include "xrCore/Threading/ScopeLock.hpp" #ifdef DEBUG diff --git a/src/Layers/xrRender/SH_Texture.h b/src/Layers/xrRender/SH_Texture.h index 5046b97133e..46df12b878c 100644 --- a/src/Layers/xrRender/SH_Texture.h +++ b/src/Layers/xrRender/SH_Texture.h @@ -111,7 +111,25 @@ class ECORE_API CTexture : public xr_resource_named virtual ~CTexture(); #if defined(USE_DX11) - ID3DShaderResourceView* get_SRView() { return m_pSRView; } + ID3DShaderResourceView* get_SRView() const { return m_pSRView; } +#endif + +#if defined(USE_DX11) + ImTextureID GetImTextureID() + { + if (!flags.bLoaded) + Load(); + return reinterpret_cast(m_pSRView); + } +#elif defined(USE_OGL) + ImTextureID GetImTextureID() + { + if (!flags.bLoaded) + Load(); + return static_cast(pSurface); + } +#else +# error No graphics API selected or enabled! #endif private: diff --git a/src/Layers/xrRender/ShaderResourceTraits.h b/src/Layers/xrRender/ShaderResourceTraits.h index 24d532b11cb..e4425ea6bab 100644 --- a/src/Layers/xrRender/ShaderResourceTraits.h +++ b/src/Layers/xrRender/ShaderResourceTraits.h @@ -720,7 +720,7 @@ bool CResourceManager::DestroyShader(const T* sh) typename ShaderTypeTraits::MapType& sh_map = GetShaderMap::MapType>(); - pstr N = pstr(*sh->cName); + pstr N = pstr(sh->cName.c_str()); auto iterator = sh_map.find(N); if (iterator != sh_map.end()) diff --git a/src/Layers/xrRender/SkeletonAnimated.cpp b/src/Layers/xrRender/SkeletonAnimated.cpp index b94d4c15639..990799cb0ff 100644 --- a/src/Layers/xrRender/SkeletonAnimated.cpp +++ b/src/Layers/xrRender/SkeletonAnimated.cpp @@ -73,7 +73,7 @@ std::pair CKinematicsAnimated::LL_MotionDefName_dbg(MotionID ID) shared_motions& s_mots = m_Motions[ID.slot].motions; for (auto &it : *s_mots.motion_map()) if (it.second == ID.idx) - return std::make_pair(*it.first, *s_mots.id()); + return std::make_pair(it.first.c_str(), s_mots.id().c_str()); return std::make_pair((LPCSTR)nullptr, (LPCSTR)nullptr); } @@ -179,7 +179,7 @@ u16 CKinematicsAnimated::LL_PartID(LPCSTR B) CPartDef& P = (*m_Partition)[id]; if (nullptr == P.Name) continue; - if (0 == xr_stricmp(B, *P.Name)) + if (0 == xr_stricmp(B, P.Name.c_str())) return id; } return BI_NONE; diff --git a/src/Layers/xrRender/SkeletonCustom.cpp b/src/Layers/xrRender/SkeletonCustom.cpp index 0d634f9edea..5f27211cf0c 100644 --- a/src/Layers/xrRender/SkeletonCustom.cpp +++ b/src/Layers/xrRender/SkeletonCustom.cpp @@ -29,11 +29,11 @@ u16 CKinematics::LL_BoneID(LPCSTR B) { const auto I = std::lower_bound(bone_map_N->begin(), bone_map_N->end(), B, [](const auto& N, pcstr B) { - return xr_strcmp(*N.first, B) < 0; + return xr_strcmp(N.first.c_str(), B) < 0; }); if (I == bone_map_N->end()) return BI_NONE; - if (0 != xr_strcmp(*(I->first), B)) + if (0 != xr_strcmp(I->first.c_str(), B)) return BI_NONE; return u16(I->second); } @@ -401,7 +401,7 @@ void CKinematics::LL_Validate() BD.IK_data.ik_flags.set(SJointIKData::flBreakable, FALSE); } #ifdef DEBUG - Msg("! ERROR: Invalid breakable object: '%s'", *dbg_name); + Msg("! ERROR: Invalid breakable object: '%s'", dbg_name.c_str()); #endif } } diff --git a/src/Layers/xrRender/TextureDescrManager.cpp b/src/Layers/xrRender/TextureDescrManager.cpp index 14038699400..9de661e55b1 100644 --- a/src/Layers/xrRender/TextureDescrManager.cpp +++ b/src/Layers/xrRender/TextureDescrManager.cpp @@ -73,7 +73,7 @@ void CTextureDescrMngr::LoadLTX(pcstr initial, bool listTHM) string_path T; float s; - const int res = sscanf(*item.second, "%[^,],%f", T, &s); + const int res = sscanf(item.second.c_str(), "%[^,],%f", T, &s); R_ASSERT4(res == 2, "Bad texture association", item.first.c_str(), fname); desc.m_assoc->detail_name = T; if (dts) diff --git a/src/Layers/xrRender/blenders/Blender_Lm(EbB).cpp b/src/Layers/xrRender/blenders/Blender_Lm(EbB).cpp index b0e188f7e5a..71e7f958baf 100644 --- a/src/Layers/xrRender/blenders/Blender_Lm(EbB).cpp +++ b/src/Layers/xrRender/blenders/Blender_Lm(EbB).cpp @@ -226,7 +226,7 @@ void CBlender_LmEbB::compile_L(CBlender_Compile& C) const void CBlender_LmEbB::CompileProgrammable(CBlender_Compile& C) const { - R_ASSERT3(C.L_textures.size() >= 2, "Not enought textures for shader, base tex: %s", *C.L_textures[0]); + R_ASSERT3(C.L_textures.size() >= 2, "Not enought textures for shader, base tex: %s", C.L_textures[0].c_str()); switch (C.iElement) { @@ -242,13 +242,13 @@ void CBlender_LmEbB::CompileProgrammable(CBlender_Compile& C) const C.r_dx11Sampler("smp_base"); C.r_dx11Texture("s_lmap", C.L_textures[1]); C.r_dx11Sampler("smp_linear"); - C.r_dx11Texture("s_hemi", *C.L_textures[2]); + C.r_dx11Texture("s_hemi", C.L_textures[2].c_str()); C.r_dx11Sampler("smp_rtlinear"); C.r_dx11Texture("s_env", oT2_Name); #else C.r_Sampler("s_base", C.L_textures[0]); C.r_Sampler("s_lmap", C.L_textures[1]); - C.r_Sampler_clf("s_hemi", *C.L_textures[2]); + C.r_Sampler_clf("s_hemi", C.L_textures[2].c_str()); C.r_Sampler("s_env", oT2_Name, false, D3DTADDRESS_CLAMP); #endif C.r_End(); diff --git a/src/Layers/xrRender/blenders/blender_deffer_aref.cpp b/src/Layers/xrRender/blenders/blender_deffer_aref.cpp index 0bc644774ba..3f26a31906d 100644 --- a/src/Layers/xrRender/blenders/blender_deffer_aref.cpp +++ b/src/Layers/xrRender/blenders/blender_deffer_aref.cpp @@ -104,7 +104,7 @@ void CBlender_deffer_aref::Compile(CBlender_Compile& C) oAREF.value); C.r_Sampler("s_base", C.L_textures[0]); C.r_Sampler("s_lmap", C.L_textures[1]); - C.r_Sampler_clf("s_hemi", *C.L_textures[2]); + C.r_Sampler_clf("s_hemi", C.L_textures[2].c_str()); C.r_Sampler("s_env", r2_T_envs0, false, D3DTADDRESS_CLAMP); C.r_End(); } @@ -204,7 +204,7 @@ void CBlender_deffer_aref::Compile(CBlender_Compile& C) C.r_dx11Texture("s_base", C.L_textures[0]); C.r_dx11Texture("s_lmap", C.L_textures[1]); - C.r_dx11Texture("s_hemi", *C.L_textures[2]); + C.r_dx11Texture("s_hemi", C.L_textures[2].c_str()); C.r_dx11Texture("s_env", r2_T_envs0); C.r_dx11Sampler("smp_base"); diff --git a/src/Layers/xrRender/blenders/uber_deffer.cpp b/src/Layers/xrRender/blenders/uber_deffer.cpp index 31cb12c0bb0..5ba66556a7e 100644 --- a/src/Layers/xrRender/blenders/uber_deffer.cpp +++ b/src/Layers/xrRender/blenders/uber_deffer.cpp @@ -10,7 +10,7 @@ void uber_deffer(CBlender_Compile& C, bool hq, LPCSTR _vspec, LPCSTR _pspec, BOO { // Uber-parse string256 fname, fnameA, fnameB; - xr_strcpy(fname, *C.L_textures[0]); //. andy if (strext(fname)) *strext(fname)=0; + xr_strcpy(fname, C.L_textures[0].c_str()); //. andy if (strext(fname)) *strext(fname)=0; fix_texture_name(fname); ref_texture _t; _t.create(fname); @@ -250,7 +250,7 @@ void uber_shadow(CBlender_Compile& C, LPCSTR _vspec) { // Uber-parse string256 fname, fnameA, fnameB; - xr_strcpy(fname, *C.L_textures[0]); //. andy if (strext(fname)) *strext(fname)=0; + xr_strcpy(fname, C.L_textures[0].c_str()); //. andy if (strext(fname)) *strext(fname)=0; fix_texture_name(fname); ref_texture _t; _t.create(fname); diff --git a/src/Layers/xrRender/dxUIRender.cpp b/src/Layers/xrRender/dxUIRender.cpp index 8d9cdd407cc..f9fc4198076 100644 --- a/src/Layers/xrRender/dxUIRender.cpp +++ b/src/Layers/xrRender/dxUIRender.cpp @@ -149,14 +149,6 @@ void dxUIRender::SetScissor(Irect* rect) #endif // (RENDER == R_R3) || (RENDER == R_R4) } -void dxUIRender::GetActiveTextureResolution(Fvector2& res) -{ - R_constant* C = RCache.get_c(c_sbase)._get(); // get sampler - CTexture* T = RCache.get_ActiveTexture(C ? C->samp.index : 0); - R_ASSERT(T); - res.set(float(T->get_Width()), float(T->get_Height())); -} - LPCSTR dxUIRender::UpdateShaderName(LPCSTR tex_name, LPCSTR sh_name) { string_path buff; diff --git a/src/Layers/xrRender/dxUIRender.h b/src/Layers/xrRender/dxUIRender.h index 30f59c6775a..142e9f98861 100644 --- a/src/Layers/xrRender/dxUIRender.h +++ b/src/Layers/xrRender/dxUIRender.h @@ -24,7 +24,6 @@ class dxUIRender : public IUIRender //. virtual void StartLineList(u32 iMaxVerts); //. virtual void FlushLineList(); virtual void SetScissor(Irect* rect = nullptr); - virtual void GetActiveTextureResolution(Fvector2& res); //. virtual void PushPoint(float x, float y, u32 c, float u, float v); // virtual void PushPoint(int x, int y, u32 c, float u, float v); diff --git a/src/Layers/xrRender/dxUIShader.cpp b/src/Layers/xrRender/dxUIShader.cpp index a7bd346420b..cdb22fde13a 100644 --- a/src/Layers/xrRender/dxUIShader.cpp +++ b/src/Layers/xrRender/dxUIShader.cpp @@ -6,4 +6,51 @@ namespace xray::render::RENDER_NAMESPACE void dxUIShader::Copy(IUIShader& _in) { *this = *((dxUIShader*)&_in); } void dxUIShader::create(LPCSTR sh, LPCSTR tex) { hShader.create(sh, tex); } void dxUIShader::destroy() { hShader.destroy(); } + +CTexture* dxUIShader::GetBaseTexture() const +{ + if (!hShader) + return nullptr; + + const SPass& pass = *hShader->E[0]->passes[0]; + if (!pass.T) + return nullptr; + + const STextureList& textures = *pass.T; + if (textures.empty()) + return nullptr; + + const R_constant* sbase = pass.constants->get(baseTexture)._get(); + + return textures[sbase ? sbase->samp.index : 0].second._get(); +} + +xrImTextureData dxUIShader::GetImGuiTextureId() +{ + const auto texture = GetBaseTexture(); + if (!texture) + return {}; + + return + { + texture->GetImTextureID(), + { + (float)texture->get_Width(), + (float)texture->get_Height() + } + }; +} + +bool dxUIShader::GetBaseTextureResolution(Fvector2& res) +{ + const auto texture = GetBaseTexture(); + if (!texture) + { + res = {}; + return false; + } + + res = { float(texture->get_Width()), float(texture->get_Height()) }; + return true; +} } // namespace xray::render::RENDER_NAMESPACE diff --git a/src/Layers/xrRender/dxUIShader.h b/src/Layers/xrRender/dxUIShader.h index 6eccff00f32..14d9c6618b8 100644 --- a/src/Layers/xrRender/dxUIShader.h +++ b/src/Layers/xrRender/dxUIShader.h @@ -12,13 +12,17 @@ class dxUIShader : public IUIShader friend class CRender; public: - virtual ~dxUIShader() { ; } virtual void Copy(IUIShader& _in); virtual void create(LPCSTR sh, LPCSTR tex = nullptr); virtual bool inited() { return hShader; } virtual void destroy(); + CTexture* GetBaseTexture() const; + bool GetBaseTextureResolution(Fvector2& res) override; + xrImTextureData GetImGuiTextureId() override; + private: ref_shader hShader; + shared_str baseTexture{ "s_base" }; }; } // namespace xray::render::RENDER_NAMESPACE diff --git a/src/Layers/xrRender/r_constants.cpp b/src/Layers/xrRender/r_constants.cpp index 92232abe1d3..d0e059f6e4d 100644 --- a/src/Layers/xrRender/r_constants.cpp +++ b/src/Layers/xrRender/r_constants.cpp @@ -28,7 +28,7 @@ ref_constant R_constant_table::get(pcstr S, u16 type /*= u16(-1)*/) const { it = std::lower_bound(table.cbegin(), table.cend(), S, [](const ref_constant& C, cpcstr S) { - return xr_strcmp(*C->name, S) < 0; + return xr_strcmp(C->name.c_str(), S) < 0; }); } else @@ -82,7 +82,7 @@ void R_constant_table::merge(R_constant_table* T) for (u32 it = 0; it < T->table.size(); it++) { ref_constant src = T->table[it]; - ref_constant C = get(*src->name, dx9compatibility ? src->type : u16(-1)); + ref_constant C = get(src->name.c_str(), dx9compatibility ? src->type : u16(-1)); if (!C || (dx9compatibility && C->type != src->type)) { C = xr_new(); //.g_constant_allocator.create(); diff --git a/src/Layers/xrRenderDX11/dx11ConstantBuffer_impl.h b/src/Layers/xrRenderDX11/dx11ConstantBuffer_impl.h index f7b686277df..2b10ab430aa 100644 --- a/src/Layers/xrRenderDX11/dx11ConstantBuffer_impl.h +++ b/src/Layers/xrRenderDX11/dx11ConstantBuffer_impl.h @@ -47,7 +47,7 @@ IC void dx11ConstantBuffer::set(R_constant* C, R_constant_load& L, const Fmatrix break; default: #ifdef DEBUG - xrDebug::Fatal(DEBUG_INFO, "Invalid constant run-time-type for '%s'", *C->name); + xrDebug::Fatal(DEBUG_INFO, "Invalid constant run-time-type for '%s'", C->name.c_str()); #else NODEFAULT; #endif @@ -147,7 +147,7 @@ IC void dx11ConstantBuffer::seta(R_constant* C, R_constant_load& L, u32 e, const break; default: #ifdef DEBUG - xrDebug::Fatal(DEBUG_INFO, "Invalid constant run-time-type for '%s'", *C->name); + xrDebug::Fatal(DEBUG_INFO, "Invalid constant run-time-type for '%s'", C->name.c_str()); #else NODEFAULT; #endif diff --git a/src/Layers/xrRenderDX11/dx11R_Backend_Runtime.h b/src/Layers/xrRenderDX11/dx11R_Backend_Runtime.h index 1beba088685..de3a974c08a 100644 --- a/src/Layers/xrRenderDX11/dx11R_Backend_Runtime.h +++ b/src/Layers/xrRenderDX11/dx11R_Backend_Runtime.h @@ -397,7 +397,7 @@ IC void CBackend::set_Geometry(SGeometry* _geom) set_Indices(_geom->ib); } -IC void CBackend::set_Scissor(Irect* R) +IC void CBackend::set_Scissor(const Irect* R) { if (R) { diff --git a/src/Layers/xrRenderDX11/dx11ResourceManager_Scripting.cpp b/src/Layers/xrRenderDX11/dx11ResourceManager_Scripting.cpp index d7e3f2f8923..7e67bbcf5e3 100644 --- a/src/Layers/xrRenderDX11/dx11ResourceManager_Scripting.cpp +++ b/src/Layers/xrRenderDX11/dx11ResourceManager_Scripting.cpp @@ -6,7 +6,7 @@ #include "Layers/xrRender/blender_recorder.h" // adopt_compiler don't have = operator And it can't have = operator #include "xrScriptEngine/script_engine.hpp" -#include "luabind/return_reference_to_policy.hpp" +#include "xrScriptEngine/script_space.hpp" #include "xrCore/Threading/ScopeLock.hpp" #ifdef DEBUG @@ -578,8 +578,8 @@ ShaderElement* CBlender_Compile::_lua_Compile(LPCSTR namesp, LPCSTR name) RS.Invalidate(); // Compile - LPCSTR t_0 = *L_textures[0] ? *L_textures[0] : "null"; - LPCSTR t_1 = (L_textures.size() > 1) ? *L_textures[1] : "null"; + LPCSTR t_0 = L_textures[0].c_str() ? L_textures[0].c_str() : "null"; + LPCSTR t_1 = (L_textures.size() > 1) ? L_textures[1].c_str() : "null"; LPCSTR t_d = detail_texture ? detail_texture : "null"; const object shader = RImplementation.Resources->ScriptEngine.name_space(namesp); const functor element = (object)shader[name]; diff --git a/src/Layers/xrRenderDX11/dx11SH_RT.cpp b/src/Layers/xrRenderDX11/dx11SH_RT.cpp index 14fa48b09b6..67607bf89ae 100644 --- a/src/Layers/xrRenderDX11/dx11SH_RT.cpp +++ b/src/Layers/xrRenderDX11/dx11SH_RT.cpp @@ -292,7 +292,7 @@ void CRT::set_slice_write(u32 context_id, int slice) void CRT::reset_begin() { destroy(); } -void CRT::reset_end() { create(*cName, dwWidth, dwHeight, fmt, sampleCount, n_slices, { dwFlags }); } +void CRT::reset_end() { create(cName.c_str(), dwWidth, dwHeight, fmt, sampleCount, n_slices, { dwFlags }); } void CRT::resolve_into(CRT& destination) const // TODO: this should be moved into backend { diff --git a/src/Layers/xrRenderDX11/dx11SH_Texture.cpp b/src/Layers/xrRenderDX11/dx11SH_Texture.cpp index 556239189ea..b02de3e99e8 100644 --- a/src/Layers/xrRenderDX11/dx11SH_Texture.cpp +++ b/src/Layers/xrRenderDX11/dx11SH_Texture.cpp @@ -318,7 +318,7 @@ void CTexture::Load() flags.bUser = false; flags.MemoryUsage = 0; - if (0 == xr_stricmp(*cName, "$null")) + if (0 == xr_stricmp(cName.c_str(), "$null")) return; // we need to check only the beginning of the string, // so let's use strncmp instead of strstr. @@ -336,7 +336,7 @@ void CTexture::Load() // Check for OGM string_path fn; - if (FS.exist(fn, "$game_textures$", *cName, ".ogm")) + if (FS.exist(fn, "$game_textures$", cName.c_str(), ".ogm")) { // AVI pTheora = xr_new(); @@ -386,7 +386,7 @@ void CTexture::Load() } } } - else if (FS.exist(fn, "$game_textures$", *cName, ".avi")) + else if (FS.exist(fn, "$game_textures$", cName.c_str(), ".avi")) { // AVI pAVI = xr_new(); @@ -431,7 +431,7 @@ void CTexture::Load() } } } - else if (FS.exist(fn, "$game_textures$", *cName, ".seq")) + else if (FS.exist(fn, "$game_textures$", cName.c_str(), ".seq")) { // Sequence string256 buffer; @@ -472,7 +472,7 @@ void CTexture::Load() { // Normal texture u32 mem = 0; - pSurface = RImplementation.texture_load(*cName, mem); + pSurface = RImplementation.texture_load(cName.c_str(), mem); // Calc memory usage and preload into vid-mem if (pSurface) diff --git a/src/Layers/xrRenderGL/glR_Backend_Runtime.h b/src/Layers/xrRenderGL/glR_Backend_Runtime.h index a861d55759f..fc37884139c 100644 --- a/src/Layers/xrRenderGL/glR_Backend_Runtime.h +++ b/src/Layers/xrRenderGL/glR_Backend_Runtime.h @@ -351,7 +351,7 @@ IC void CBackend::set_Geometry(SGeometry* _geom) set_Indices(_geom->ib); } -IC void CBackend::set_Scissor(Irect* R) +IC void CBackend::set_Scissor(const Irect* R) { if (R) { diff --git a/src/Layers/xrRenderGL/glResourceManager_Resources.cpp b/src/Layers/xrRenderGL/glResourceManager_Resources.cpp index 24600158b88..417c82ed64e 100644 --- a/src/Layers/xrRenderGL/glResourceManager_Resources.cpp +++ b/src/Layers/xrRenderGL/glResourceManager_Resources.cpp @@ -127,7 +127,7 @@ void CResourceManager::_DeletePP(const SPP* pp) if (0 == (pp->dwFlags & xr_resource_flagged::RF_REGISTERED)) return; - const pstr N = const_cast(*pp->cName); + const pstr N = const_cast(pp->cName.c_str()); auto iterator = m_pp.find(N); if (iterator != m_pp.end()) diff --git a/src/Layers/xrRenderGL/glResourceManager_Scripting.cpp b/src/Layers/xrRenderGL/glResourceManager_Scripting.cpp index c56cedb68f8..be51f7e4bd9 100644 --- a/src/Layers/xrRenderGL/glResourceManager_Scripting.cpp +++ b/src/Layers/xrRenderGL/glResourceManager_Scripting.cpp @@ -1,13 +1,13 @@ #include "stdafx.h" #pragma hdrstop -#include "Layers/xrRender/ResourceManager.h" -#include "Layers/xrRender/tss.h" -#include "Layers/xrRender/Blender.h" -#include "Layers/xrRender/Blender_Recorder.h" +#include "Layers/xrRender/ResourceManager.h" +#include "Layers/xrRender/tss.h" +#include "Layers/xrRender/Blender.h" +#include "Layers/xrRender/Blender_Recorder.h" // adopt_compiler don't have = operator And it can't have = operator -#include "xrScriptEngine/script_engine.hpp" -#include "luabind/return_reference_to_policy.hpp" +#include "xrScriptEngine/script_engine.hpp" +#include "xrScriptEngine/script_space.hpp" #include "xrCore/Threading/ScopeLock.hpp" #ifdef DEBUG @@ -544,9 +544,9 @@ ShaderElement* CBlender_Compile::_lua_Compile(LPCSTR namesp, LPCSTR name) RS.Invalidate(); // Compile - LPCSTR t_0 = *L_textures[0] ? *L_textures[0] : "null"; - LPCSTR t_1 = L_textures.size() > 1 ? *L_textures[1] : "null"; - LPCSTR t_d = detail_texture ? detail_texture : "null"; + pcstr t_0 = L_textures[0].c_str() ? L_textures[0].c_str() : "null"; + pcstr t_1 = L_textures.size() > 1 ? L_textures[1].c_str() : "null"; + pcstr t_d = detail_texture ? detail_texture : "null"; object shader = RImplementation.Resources->ScriptEngine.name_space(namesp); functor element = object_cast>(shader[name]); bool bFirstPass = false; diff --git a/src/Layers/xrRenderGL/glSH_RT.cpp b/src/Layers/xrRenderGL/glSH_RT.cpp index 6ad2981eab3..5d967334bbc 100644 --- a/src/Layers/xrRenderGL/glSH_RT.cpp +++ b/src/Layers/xrRenderGL/glSH_RT.cpp @@ -82,7 +82,7 @@ void CRT::reset_begin() void CRT::reset_end() { - create(*cName, dwWidth, dwHeight, fmt, sampleCount, { dwFlags }); + create(cName.c_str(), dwWidth, dwHeight, fmt, sampleCount, { dwFlags }); } void CRT::resolve_into(CRT& destination) const diff --git a/src/Layers/xrRenderGL/glSH_Texture.cpp b/src/Layers/xrRenderGL/glSH_Texture.cpp index 6a1f7452ce9..d7393f78ec7 100644 --- a/src/Layers/xrRenderGL/glSH_Texture.cpp +++ b/src/Layers/xrRenderGL/glSH_Texture.cpp @@ -158,9 +158,9 @@ void CTexture::Load() flags.bUser = false; flags.MemoryUsage = 0; - if (nullptr == *cName) + if (nullptr == cName.c_str()) return; - if (0 == xr_stricmp(*cName, "$null")) return; + if (0 == xr_stricmp(cName.c_str(), "$null")) return; // we need to check only the beginning of the string, // so let's use strncmp instead of strstr. if (0 == strncmp(cName.c_str(), "$user$", sizeof("$user$") - 1)) @@ -175,7 +175,7 @@ void CTexture::Load() // Check for OGM string_path fn; - if (FS.exist(fn, "$game_textures$", *cName, ".ogm")) + if (FS.exist(fn, "$game_textures$", cName.c_str(), ".ogm")) { // AVI pTheora = xr_new(); @@ -216,7 +216,7 @@ void CTexture::Load() } } } - else if (FS.exist(fn, "$game_textures$", *cName, ".avi")) + else if (FS.exist(fn, "$game_textures$", cName.c_str(), ".avi")) { #ifdef XR_PLATFORM_WINDOWS // TODO // AVI @@ -253,7 +253,7 @@ void CTexture::Load() } #endif } - else if (FS.exist(fn, "$game_textures$", *cName, ".seq")) + else if (FS.exist(fn, "$game_textures$", cName.c_str(), ".seq")) { // Sequence string256 buffer; @@ -293,7 +293,7 @@ void CTexture::Load() { // Normal texture u32 mem = 0; - pSurface = RImplementation.texture_load(*cName, mem, desc); + pSurface = RImplementation.texture_load(cName.c_str(), mem, desc); // Calc memory usage and preload into vid-mem if (pSurface) diff --git a/src/Layers/xrRenderGL/glr_constants_cache.h b/src/Layers/xrRenderGL/glr_constants_cache.h index a878a5c1176..8ecf54063b8 100644 --- a/src/Layers/xrRenderGL/glr_constants_cache.h +++ b/src/Layers/xrRenderGL/glr_constants_cache.h @@ -44,7 +44,7 @@ class ECORE_API R_constants default: #ifdef DEBUG - xrDebug::Fatal(DEBUG_INFO, "Invalid constant run-time-type for '%s'", *C->name); + xrDebug::Fatal(DEBUG_INFO, "Invalid constant run-time-type for '%s'", C->name.c_str()); #else NODEFAULT; #endif @@ -79,7 +79,7 @@ class ECORE_API R_constants default: #ifdef DEBUG - xrDebug::Fatal(DEBUG_INFO, "Invalid constant run-time-type for '%s'", *C->name); + xrDebug::Fatal(DEBUG_INFO, "Invalid constant run-time-type for '%s'", C->name.c_str()); #else NODEFAULT; #endif @@ -114,7 +114,7 @@ class ECORE_API R_constants default: #ifdef DEBUG - xrDebug::Fatal(DEBUG_INFO, "Invalid constant run-time-type for '%s'", *C->name); + xrDebug::Fatal(DEBUG_INFO, "Invalid constant run-time-type for '%s'", C->name.c_str()); #else NODEFAULT; #endif diff --git a/src/Layers/xrRenderPC_GL/CMakeLists.txt b/src/Layers/xrRenderPC_GL/CMakeLists.txt index afe5cf576da..2f333dcafcc 100644 --- a/src/Layers/xrRenderPC_GL/CMakeLists.txt +++ b/src/Layers/xrRenderPC_GL/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(xrRender_GL SHARED) +add_library(xrRender_GL) target_sources(xrRender_GL PRIVATE gl_rendertarget_accum_direct.cpp @@ -431,6 +431,8 @@ target_precompile_headers(xrRender_GL $<$:stdafx.h> ) -install(TARGETS xrRender_GL LIBRARY - DESTINATION "${CMAKE_INSTALL_LIBDIR}" -) +if (BUILD_SHARED_LIBS) + install(TARGETS xrRender_GL LIBRARY + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) +endif() diff --git a/src/Layers/xrRenderPC_R4/CMakeLists.txt b/src/Layers/xrRenderPC_R4/CMakeLists.txt index 59cfdf4b7f4..12e2072b7bf 100644 --- a/src/Layers/xrRenderPC_R4/CMakeLists.txt +++ b/src/Layers/xrRenderPC_R4/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(xrRenderPC_R4 SHARED) +add_library(xrRenderPC_R4) target_sources(xrRenderPC_R4 PRIVATE packages.config @@ -37,6 +37,7 @@ target_link_libraries(xrRenderPC_R4 target_compile_definitions(xrRenderPC_R4 PRIVATE XRRENDER_R4_EXPORTS + USE_DX11 ) set_target_properties(xrRenderPC_R4 PROPERTIES @@ -48,6 +49,8 @@ target_precompile_headers(xrRenderPC_R4 stdafx.h ) -install(TARGETS xrRenderPC_R4 LIBRARY - DESTINATION "${CMAKE_INSTALL_LIBDIR}" -) +if (BUILD_SHARED_LIBS) + install(TARGETS xrRenderPC_R4 LIBRARY + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) +endif() diff --git a/src/Layers/xrRenderPC_R4/xrRender_R4.vcxproj b/src/Layers/xrRenderPC_R4/xrRender_R4.vcxproj index 4bf4967b48a..b808f8f9e55 100644 --- a/src/Layers/xrRenderPC_R4/xrRender_R4.vcxproj +++ b/src/Layers/xrRenderPC_R4/xrRender_R4.vcxproj @@ -37,6 +37,14 @@ $(xrExternals)nvapi\x86;%(AdditionalLibraryDirectories) $(xrExternals)nvapi\amd64;%(AdditionalLibraryDirectories) + + dxguid.lib;d3dcompiler.lib;nvapi$(PlatformArchitecture).lib;%(AdditionalDependencies) + amd_ags_$(PlatformShortName)_2019_MD.lib;%(AdditionalDependencies) + amd_ags_$(PlatformShortName)_2019_MDd.lib;%(AdditionalDependencies) + $(xrExternals)OpenAutomate\libraries;$(xrExternals)AGS_SDK\ags_lib\lib;%(AdditionalLibraryDirectories) + $(xrExternals)nvapi\x86;%(AdditionalLibraryDirectories) + $(xrExternals)nvapi\amd64;%(AdditionalLibraryDirectories) + @@ -474,9 +482,6 @@ - - Document - diff --git a/src/Layers/xrRenderPC_R4/xrRender_R4.vcxproj.filters b/src/Layers/xrRenderPC_R4/xrRender_R4.vcxproj.filters index 3f5b2ed56c5..2ad60a71cb1 100644 --- a/src/Layers/xrRenderPC_R4/xrRender_R4.vcxproj.filters +++ b/src/Layers/xrRenderPC_R4/xrRender_R4.vcxproj.filters @@ -1371,9 +1371,4 @@ - - - Kernel - - \ No newline at end of file diff --git a/src/engine.sln b/src/engine.sln index b69bc97976b..ebc6f19af6f 100644 --- a/src/engine.sln +++ b/src/engine.sln @@ -9,14 +9,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XR_3DA", "xr_3da\xr_3da.vcx {AC9B12ED-A2D7-4337-A981-5BD8430E96D8} = {AC9B12ED-A2D7-4337-A981-5BD8430E96D8} EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "utils", "utils", "{89F6A7EE-3BBE-45D3-A8A8-5D9366CD987B}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Externals", "Externals", "{2BFC806B-CE92-4EA4-8FE8-5F2EA54BA348}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ODE", "..\Externals\ODE.vcxproj", "{1BF75FEB-87DD-486C-880B-227987D191C2}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xrCompress", "utils\xrCompress\xrCompress.vcxproj", "{EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xrCDB", "xrCDB\xrCDB.vcxproj", "{A19B1DF2-82EC-4364-8BDF-85D13A1C89B5}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xrCore", "xrCore\xrCore.vcxproj", "{A0F7D1FB-59A7-4717-A7E4-96F37E91998E}" @@ -39,12 +35,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xrPhysics", "xrPhysics\xrPh EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xrRender_R4", "Layers\xrRenderPC_R4\xrRender_R4.vcxproj", "{AC9B12ED-A2D7-4337-A981-5BD8430E96D8}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mp_configs_verifyer", "utils\mp_configs_verifyer\mp_configs_verifyer.vcxproj", "{1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "editors", "editors", "{CB0C814D-FB4E-453B-B7A0-716F4A1EACA4}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xrWeatherEditor", "editors\xrWeatherEditor\xrWeatherEditor.vcxproj", "{492D3DFE-9068-4E7E-A008-7C2420A651C0}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xrAICore", "xrAICore\xrAICore.vcxproj", "{5CB057D8-4464-40A6-AF10-C26B826D1D90}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xrScriptEngine", "xrScriptEngine\xrScriptEngine.vcxproj", "{132C62DE-DE85-4978-9675-C78ED4DA46F0}" @@ -55,14 +45,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Common", "Common\Common.vcx EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameSpy", "..\Externals\GameSpy.vcxproj", "{67FF193E-2C20-402A-9026-9F5F6327503C}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dummy", "dummy\dummy.vcxproj", "{B5A3098C-C768-45FF-8B6C-1F707C0344F0}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xrMiscMath", "utils\xrMiscMath\xrMiscMath.vcxproj", "{7885CF3C-EE04-4C67-9467-1FBF9A36B037}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libs", "libs", "{49438080-78B8-4056-BDCB-4DACAD652C21}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "LuaJIT", "LuaJIT", "{DAEF6FB5-4F98-4B34-B049-8828EFEC9250}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BuildVm", "..\Externals\LuaJIT-proj\BuildVm.vcxproj", "{58AE014E-0DA3-4D9B-9034-21984C305447}" ProjectSection(ProjectDependencies) = postProject {CDC5E78D-FF1C-4164-AE72-3578F60A27BA} = {CDC5E78D-FF1C-4164-AE72-3578F60A27BA} @@ -81,8 +65,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xrRender_GL", "Layers\xrRen EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xrUICore", "xrUICore\xrUICore.vcxproj", "{37B3642C-B706-4C93-BC54-BADADC8FC9B1}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xrWeatherEngine", "editors\xrWeatherEngine\xrWeatherEngine.vcxproj", "{FABD5BBF-EA6F-4633-A34F-95CDC553CA36}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imgui", "..\Externals\imgui.vcxproj", "{C8FBC3CE-D6DE-4FC3-BC15-7B647614DB09}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xrLuaFix", "..\Externals\xrLuaFix\xrLuaFix.vcxproj", "{4E076FEB-DC78-4BF7-99C7-AC8267247989}" @@ -175,38 +157,6 @@ Global {1BF75FEB-87DD-486C-880B-227987D191C2}.Release|x64.Build.0 = Release|x64 {1BF75FEB-87DD-486C-880B-227987D191C2}.Release|x86.ActiveCfg = Release|Win32 {1BF75FEB-87DD-486C-880B-227987D191C2}.Release|x86.Build.0 = Release|Win32 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Debug|ARM.ActiveCfg = Debug|Win32 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Debug|ARM.Build.0 = Debug|Win32 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Debug|ARM64.ActiveCfg = Debug|x64 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Debug|ARM64.Build.0 = Debug|x64 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Debug|x64.ActiveCfg = Debug|x64 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Debug|x64.Build.0 = Debug|x64 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Debug|x86.ActiveCfg = Debug|Win32 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Debug|x86.Build.0 = Debug|Win32 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Mixed|ARM.ActiveCfg = Mixed|ARM - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Mixed|ARM.Build.0 = Mixed|ARM - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Mixed|ARM64.ActiveCfg = Mixed|ARM64 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Mixed|ARM64.Build.0 = Mixed|ARM64 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Mixed|x64.ActiveCfg = Mixed|x64 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Mixed|x64.Build.0 = Mixed|x64 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Mixed|x86.ActiveCfg = Mixed|Win32 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Mixed|x86.Build.0 = Mixed|Win32 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Release Master Gold|ARM.ActiveCfg = Release Master Gold|ARM - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Release Master Gold|ARM.Build.0 = Release Master Gold|ARM - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Release Master Gold|ARM64.ActiveCfg = Release Master Gold|ARM64 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Release Master Gold|ARM64.Build.0 = Release Master Gold|ARM64 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Release Master Gold|x64.ActiveCfg = Release Master Gold|x64 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Release Master Gold|x64.Build.0 = Release Master Gold|x64 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Release Master Gold|x86.ActiveCfg = Release Master Gold|Win32 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Release Master Gold|x86.Build.0 = Release Master Gold|Win32 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Release|ARM.ActiveCfg = Release|Win32 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Release|ARM.Build.0 = Release|Win32 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Release|ARM64.ActiveCfg = Release|x64 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Release|ARM64.Build.0 = Release|x64 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Release|x64.ActiveCfg = Release|x64 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Release|x64.Build.0 = Release|x64 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Release|x86.ActiveCfg = Release|Win32 - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B}.Release|x86.Build.0 = Release|Win32 {A19B1DF2-82EC-4364-8BDF-85D13A1C89B5}.Debug|ARM.ActiveCfg = Debug|Win32 {A19B1DF2-82EC-4364-8BDF-85D13A1C89B5}.Debug|ARM.Build.0 = Debug|Win32 {A19B1DF2-82EC-4364-8BDF-85D13A1C89B5}.Debug|ARM64.ActiveCfg = Debug|x64 @@ -559,54 +509,6 @@ Global {AC9B12ED-A2D7-4337-A981-5BD8430E96D8}.Release|x64.Build.0 = Release|x64 {AC9B12ED-A2D7-4337-A981-5BD8430E96D8}.Release|x86.ActiveCfg = Release|Win32 {AC9B12ED-A2D7-4337-A981-5BD8430E96D8}.Release|x86.Build.0 = Release|Win32 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Debug|ARM.ActiveCfg = Debug|Win32 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Debug|ARM.Build.0 = Debug|Win32 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Debug|ARM64.ActiveCfg = Debug|x64 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Debug|ARM64.Build.0 = Debug|x64 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Debug|x64.ActiveCfg = Debug|x64 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Debug|x64.Build.0 = Debug|x64 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Debug|x86.ActiveCfg = Debug|Win32 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Debug|x86.Build.0 = Debug|Win32 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Mixed|ARM.ActiveCfg = Mixed|ARM - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Mixed|ARM.Build.0 = Mixed|ARM - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Mixed|ARM64.ActiveCfg = Mixed|ARM64 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Mixed|ARM64.Build.0 = Mixed|ARM64 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Mixed|x64.ActiveCfg = Mixed|x64 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Mixed|x64.Build.0 = Mixed|x64 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Mixed|x86.ActiveCfg = Mixed|Win32 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Mixed|x86.Build.0 = Mixed|Win32 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Release Master Gold|ARM.ActiveCfg = Release Master Gold|ARM - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Release Master Gold|ARM.Build.0 = Release Master Gold|ARM - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Release Master Gold|ARM64.ActiveCfg = Release Master Gold|ARM64 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Release Master Gold|ARM64.Build.0 = Release Master Gold|ARM64 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Release Master Gold|x64.ActiveCfg = Release Master Gold|x64 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Release Master Gold|x64.Build.0 = Release Master Gold|x64 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Release Master Gold|x86.ActiveCfg = Release Master Gold|Win32 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Release Master Gold|x86.Build.0 = Release Master Gold|Win32 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Release|ARM.ActiveCfg = Release|Win32 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Release|ARM.Build.0 = Release|Win32 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Release|ARM64.ActiveCfg = Release|x64 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Release|ARM64.Build.0 = Release|x64 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Release|x64.ActiveCfg = Release|x64 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Release|x64.Build.0 = Release|x64 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Release|x86.ActiveCfg = Release|Win32 - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B}.Release|x86.Build.0 = Release|Win32 - {492D3DFE-9068-4E7E-A008-7C2420A651C0}.Debug|ARM.ActiveCfg = Debug|Win32 - {492D3DFE-9068-4E7E-A008-7C2420A651C0}.Debug|ARM64.ActiveCfg = Debug|x64 - {492D3DFE-9068-4E7E-A008-7C2420A651C0}.Debug|x64.ActiveCfg = Debug|x64 - {492D3DFE-9068-4E7E-A008-7C2420A651C0}.Debug|x86.ActiveCfg = Debug|Win32 - {492D3DFE-9068-4E7E-A008-7C2420A651C0}.Mixed|ARM.ActiveCfg = Mixed|ARM - {492D3DFE-9068-4E7E-A008-7C2420A651C0}.Mixed|ARM64.ActiveCfg = Mixed|ARM64 - {492D3DFE-9068-4E7E-A008-7C2420A651C0}.Mixed|x64.ActiveCfg = Mixed|x64 - {492D3DFE-9068-4E7E-A008-7C2420A651C0}.Mixed|x86.ActiveCfg = Mixed|Win32 - {492D3DFE-9068-4E7E-A008-7C2420A651C0}.Release Master Gold|ARM.ActiveCfg = Release Master Gold|ARM - {492D3DFE-9068-4E7E-A008-7C2420A651C0}.Release Master Gold|ARM64.ActiveCfg = Release Master Gold|ARM64 - {492D3DFE-9068-4E7E-A008-7C2420A651C0}.Release Master Gold|x64.ActiveCfg = Release Master Gold|x64 - {492D3DFE-9068-4E7E-A008-7C2420A651C0}.Release Master Gold|x86.ActiveCfg = Release Master Gold|Win32 - {492D3DFE-9068-4E7E-A008-7C2420A651C0}.Release|ARM.ActiveCfg = Release|Win32 - {492D3DFE-9068-4E7E-A008-7C2420A651C0}.Release|ARM64.ActiveCfg = Release|x64 - {492D3DFE-9068-4E7E-A008-7C2420A651C0}.Release|x64.ActiveCfg = Release|x64 - {492D3DFE-9068-4E7E-A008-7C2420A651C0}.Release|x86.ActiveCfg = Release|Win32 {5CB057D8-4464-40A6-AF10-C26B826D1D90}.Debug|ARM.ActiveCfg = Debug|Win32 {5CB057D8-4464-40A6-AF10-C26B826D1D90}.Debug|ARM.Build.0 = Debug|Win32 {5CB057D8-4464-40A6-AF10-C26B826D1D90}.Debug|ARM64.ActiveCfg = Debug|x64 @@ -751,22 +653,6 @@ Global {67FF193E-2C20-402A-9026-9F5F6327503C}.Release|x64.Build.0 = Release|x64 {67FF193E-2C20-402A-9026-9F5F6327503C}.Release|x86.ActiveCfg = Release|Win32 {67FF193E-2C20-402A-9026-9F5F6327503C}.Release|x86.Build.0 = Release|Win32 - {B5A3098C-C768-45FF-8B6C-1F707C0344F0}.Debug|ARM.ActiveCfg = Debug|Win32 - {B5A3098C-C768-45FF-8B6C-1F707C0344F0}.Debug|ARM64.ActiveCfg = Debug|x64 - {B5A3098C-C768-45FF-8B6C-1F707C0344F0}.Debug|x64.ActiveCfg = Debug|x64 - {B5A3098C-C768-45FF-8B6C-1F707C0344F0}.Debug|x86.ActiveCfg = Debug|Win32 - {B5A3098C-C768-45FF-8B6C-1F707C0344F0}.Mixed|ARM.ActiveCfg = Mixed|ARM - {B5A3098C-C768-45FF-8B6C-1F707C0344F0}.Mixed|ARM64.ActiveCfg = Mixed|ARM64 - {B5A3098C-C768-45FF-8B6C-1F707C0344F0}.Mixed|x64.ActiveCfg = Mixed|x64 - {B5A3098C-C768-45FF-8B6C-1F707C0344F0}.Mixed|x86.ActiveCfg = Mixed|Win32 - {B5A3098C-C768-45FF-8B6C-1F707C0344F0}.Release Master Gold|ARM.ActiveCfg = Release Master Gold|ARM - {B5A3098C-C768-45FF-8B6C-1F707C0344F0}.Release Master Gold|ARM64.ActiveCfg = Release Master Gold|ARM64 - {B5A3098C-C768-45FF-8B6C-1F707C0344F0}.Release Master Gold|x64.ActiveCfg = Release Master Gold|x64 - {B5A3098C-C768-45FF-8B6C-1F707C0344F0}.Release Master Gold|x86.ActiveCfg = Release Master Gold|Win32 - {B5A3098C-C768-45FF-8B6C-1F707C0344F0}.Release|ARM.ActiveCfg = Release|Win32 - {B5A3098C-C768-45FF-8B6C-1F707C0344F0}.Release|ARM64.ActiveCfg = Release|x64 - {B5A3098C-C768-45FF-8B6C-1F707C0344F0}.Release|x64.ActiveCfg = Release|x64 - {B5A3098C-C768-45FF-8B6C-1F707C0344F0}.Release|x86.ActiveCfg = Release|Win32 {7885CF3C-EE04-4C67-9467-1FBF9A36B037}.Debug|ARM.ActiveCfg = Debug|Win32 {7885CF3C-EE04-4C67-9467-1FBF9A36B037}.Debug|ARM.Build.0 = Debug|Win32 {7885CF3C-EE04-4C67-9467-1FBF9A36B037}.Debug|ARM64.ActiveCfg = Debug|x64 @@ -991,22 +877,6 @@ Global {37B3642C-B706-4C93-BC54-BADADC8FC9B1}.Release|x64.Build.0 = Release|x64 {37B3642C-B706-4C93-BC54-BADADC8FC9B1}.Release|x86.ActiveCfg = Release|Win32 {37B3642C-B706-4C93-BC54-BADADC8FC9B1}.Release|x86.Build.0 = Release|Win32 - {FABD5BBF-EA6F-4633-A34F-95CDC553CA36}.Debug|ARM.ActiveCfg = Debug|Win32 - {FABD5BBF-EA6F-4633-A34F-95CDC553CA36}.Debug|ARM64.ActiveCfg = Debug|x64 - {FABD5BBF-EA6F-4633-A34F-95CDC553CA36}.Debug|x64.ActiveCfg = Debug|x64 - {FABD5BBF-EA6F-4633-A34F-95CDC553CA36}.Debug|x86.ActiveCfg = Debug|Win32 - {FABD5BBF-EA6F-4633-A34F-95CDC553CA36}.Mixed|ARM.ActiveCfg = Mixed|ARM - {FABD5BBF-EA6F-4633-A34F-95CDC553CA36}.Mixed|ARM64.ActiveCfg = Mixed|ARM64 - {FABD5BBF-EA6F-4633-A34F-95CDC553CA36}.Mixed|x64.ActiveCfg = Mixed|x64 - {FABD5BBF-EA6F-4633-A34F-95CDC553CA36}.Mixed|x86.ActiveCfg = Mixed|Win32 - {FABD5BBF-EA6F-4633-A34F-95CDC553CA36}.Release Master Gold|ARM.ActiveCfg = Release Master Gold|ARM - {FABD5BBF-EA6F-4633-A34F-95CDC553CA36}.Release Master Gold|ARM64.ActiveCfg = Release Master Gold|ARM64 - {FABD5BBF-EA6F-4633-A34F-95CDC553CA36}.Release Master Gold|x64.ActiveCfg = Release Master Gold|x64 - {FABD5BBF-EA6F-4633-A34F-95CDC553CA36}.Release Master Gold|x86.ActiveCfg = Release Master Gold|Win32 - {FABD5BBF-EA6F-4633-A34F-95CDC553CA36}.Release|ARM.ActiveCfg = Release|Win32 - {FABD5BBF-EA6F-4633-A34F-95CDC553CA36}.Release|ARM64.ActiveCfg = Release|x64 - {FABD5BBF-EA6F-4633-A34F-95CDC553CA36}.Release|x64.ActiveCfg = Release|x64 - {FABD5BBF-EA6F-4633-A34F-95CDC553CA36}.Release|x86.ActiveCfg = Release|Win32 {C8FBC3CE-D6DE-4FC3-BC15-7B647614DB09}.Debug|ARM.ActiveCfg = Debug|ARM {C8FBC3CE-D6DE-4FC3-BC15-7B647614DB09}.Debug|ARM.Build.0 = Debug|ARM {C8FBC3CE-D6DE-4FC3-BC15-7B647614DB09}.Debug|ARM64.ActiveCfg = Debug|ARM64 @@ -1141,21 +1011,13 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {1BF75FEB-87DD-486C-880B-227987D191C2} = {2BFC806B-CE92-4EA4-8FE8-5F2EA54BA348} - {EF76867B-6EB8-4DC0-A1D6-E964FAD6FC7B} = {89F6A7EE-3BBE-45D3-A8A8-5D9366CD987B} - {1924EF23-A05E-40E5-93F2-6CCD64BE1F8B} = {89F6A7EE-3BBE-45D3-A8A8-5D9366CD987B} - {492D3DFE-9068-4E7E-A008-7C2420A651C0} = {CB0C814D-FB4E-453B-B7A0-716F4A1EACA4} {CCD4AFAE-AA10-42C6-A452-FDEE497CCDF1} = {2BFC806B-CE92-4EA4-8FE8-5F2EA54BA348} {67FF193E-2C20-402A-9026-9F5F6327503C} = {2BFC806B-CE92-4EA4-8FE8-5F2EA54BA348} - {B5A3098C-C768-45FF-8B6C-1F707C0344F0} = {89F6A7EE-3BBE-45D3-A8A8-5D9366CD987B} - {7885CF3C-EE04-4C67-9467-1FBF9A36B037} = {49438080-78B8-4056-BDCB-4DACAD652C21} - {DAEF6FB5-4F98-4B34-B049-8828EFEC9250} = {2BFC806B-CE92-4EA4-8FE8-5F2EA54BA348} - {58AE014E-0DA3-4D9B-9034-21984C305447} = {DAEF6FB5-4F98-4B34-B049-8828EFEC9250} - {CDC5E78D-FF1C-4164-AE72-3578F60A27BA} = {DAEF6FB5-4F98-4B34-B049-8828EFEC9250} - {632AEEB6-DC06-4E15-9551-B2B09A4B73C5} = {DAEF6FB5-4F98-4B34-B049-8828EFEC9250} + {58AE014E-0DA3-4D9B-9034-21984C305447} = {2BFC806B-CE92-4EA4-8FE8-5F2EA54BA348} + {CDC5E78D-FF1C-4164-AE72-3578F60A27BA} = {2BFC806B-CE92-4EA4-8FE8-5F2EA54BA348} + {632AEEB6-DC06-4E15-9551-B2B09A4B73C5} = {2BFC806B-CE92-4EA4-8FE8-5F2EA54BA348} {DAFD6D98-3DCD-40AD-BC85-EC71797B6767} = {2BFC806B-CE92-4EA4-8FE8-5F2EA54BA348} - {FABD5BBF-EA6F-4633-A34F-95CDC553CA36} = {CB0C814D-FB4E-453B-B7A0-716F4A1EACA4} {C8FBC3CE-D6DE-4FC3-BC15-7B647614DB09} = {2BFC806B-CE92-4EA4-8FE8-5F2EA54BA348} - {4E076FEB-DC78-4BF7-99C7-AC8267247989} = {49438080-78B8-4056-BDCB-4DACAD652C21} {CFF9F0DD-C2FC-424C-800B-BFBA35003932} = {2BFC806B-CE92-4EA4-8FE8-5F2EA54BA348} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/utils/mp_configs_verifyer/mp_configs_verifyer.vcxproj b/src/utils/mp_configs_verifyer/mp_configs_verifyer.vcxproj index ec58c08cbc8..f81d1629a75 100644 --- a/src/utils/mp_configs_verifyer/mp_configs_verifyer.vcxproj +++ b/src/utils/mp_configs_verifyer/mp_configs_verifyer.vcxproj @@ -59,7 +59,19 @@ + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + \ No newline at end of file diff --git a/src/utils/mp_configs_verifyer/mp_configs_verifyer.vcxproj.filters b/src/utils/mp_configs_verifyer/mp_configs_verifyer.vcxproj.filters index 9f7b0e63ef8..2d409e7bf9d 100644 --- a/src/utils/mp_configs_verifyer/mp_configs_verifyer.vcxproj.filters +++ b/src/utils/mp_configs_verifyer/mp_configs_verifyer.vcxproj.filters @@ -25,4 +25,7 @@ + + + \ No newline at end of file diff --git a/src/utils/mp_configs_verifyer/packages.config b/src/utils/mp_configs_verifyer/packages.config new file mode 100644 index 00000000000..cdb39895107 --- /dev/null +++ b/src/utils/mp_configs_verifyer/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/utils/xrMiscMath/CMakeLists.txt b/src/utils/xrMiscMath/CMakeLists.txt index 507c4072515..4e6b9252ade 100644 --- a/src/utils/xrMiscMath/CMakeLists.txt +++ b/src/utils/xrMiscMath/CMakeLists.txt @@ -16,7 +16,7 @@ target_include_directories(xrMiscMath ) set_target_properties(xrMiscMath PROPERTIES - POSITION_INDEPENDENT_CODE ON + POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS} ) target_precompile_headers(xrMiscMath diff --git a/src/utils/xrMiscMath/pch.hpp b/src/utils/xrMiscMath/pch.hpp index 79351f07714..9f5122e4aa4 100644 --- a/src/utils/xrMiscMath/pch.hpp +++ b/src/utils/xrMiscMath/pch.hpp @@ -1,7 +1,13 @@ #pragma once #include "Common/Common.hpp" -#define XRCORE_API XR_IMPORT // XXX: Get rid of xrMiscMath + +// XXX: Get rid of xrMiscMath +#ifdef XRAY_STATIC_BUILD +# define XRCORE_API +#else +# define XRCORE_API XR_IMPORT +#endif #include "xrCommon/math_funcs_inline.h" #include "xrCore/_std_extensions.h" diff --git a/src/xrAICore/CMakeLists.txt b/src/xrAICore/CMakeLists.txt index d6c9507dd16..cf1d5d2dd68 100644 --- a/src/xrAICore/CMakeLists.txt +++ b/src/xrAICore/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(xrAICore SHARED) +add_library(xrAICore) target_sources_grouped( TARGET xrAICore @@ -28,7 +28,6 @@ target_sources_grouped( TARGET xrAICore NAME "AI\\Component\\ProblemSolver\\ConditionState\\ScriptWorldState" FILES - Components/script_world_state.h Components/script_world_state_script.cpp ) @@ -52,8 +51,6 @@ target_sources_grouped( TARGET xrAICore NAME "AI\\Component\\ProblemSolver\\OperatorCondition\\ScriptWorldProperty" FILES - Components/script_world_property.h - Components/script_world_property_inline.h Components/script_world_property_script.cpp ) @@ -316,6 +313,8 @@ target_precompile_headers(xrAICore pch.hpp ) -install(TARGETS xrAICore LIBRARY - DESTINATION "${CMAKE_INSTALL_LIBDIR}" -) +if (BUILD_SHARED_LIBS) + install(TARGETS xrAICore LIBRARY + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) +endif() diff --git a/src/xrAICore/Components/condition_state_inline.h b/src/xrAICore/Components/condition_state_inline.h index d405dfd4382..8eb89fccccd 100644 --- a/src/xrAICore/Components/condition_state_inline.h +++ b/src/xrAICore/Components/condition_state_inline.h @@ -7,7 +7,6 @@ //////////////////////////////////////////////////////////////////////////// #pragma once -#include "xrScriptEngine/DebugMacros.hpp" // for THROW // XXX: move debug macros to xrCore #define TEMPLATE_SPECIALIZATION template #define CConditionStateAbstract CConditionState<_world_property> diff --git a/src/xrAICore/Components/script_world_property.h b/src/xrAICore/Components/script_world_property.h deleted file mode 100644 index d7b0a0e562b..00000000000 --- a/src/xrAICore/Components/script_world_property.h +++ /dev/null @@ -1,19 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// Module : script_world_property.h -// Created : 19.03.2004 -// Modified : 19.03.2004 -// Author : Dmitriy Iassenev -// Description : Script world property -//////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "xrAICore/Navigation/graph_engine_space.h" - -typedef GraphEngineSpace::CWorldProperty CScriptWorldProperty; - -class CScriptWorldPropertyWrapper -{ -}; - -#include "xrAICore/Components/script_world_property_inline.h" diff --git a/src/xrAICore/Components/script_world_property_inline.h b/src/xrAICore/Components/script_world_property_inline.h deleted file mode 100644 index a0f3faea49b..00000000000 --- a/src/xrAICore/Components/script_world_property_inline.h +++ /dev/null @@ -1,14 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// Module : script_world_property_inline.h -// Created : 19.03.2004 -// Modified : 19.03.2004 -// Author : Dmitriy Iassenev -// Description : Script world property inline functions -//////////////////////////////////////////////////////////////////////////// - -#pragma once - -// IC CScriptWorldProperty::CScriptWorldProperty (const _condition_type condition, const _value_type value) : -// inherited (condition,value) -//{ -//} diff --git a/src/xrAICore/Components/script_world_property_script.cpp b/src/xrAICore/Components/script_world_property_script.cpp index 5009acc87b0..3bb725e26e4 100644 --- a/src/xrAICore/Components/script_world_property_script.cpp +++ b/src/xrAICore/Components/script_world_property_script.cpp @@ -1,5 +1,5 @@ //////////////////////////////////////////////////////////////////////////// -// Module : script_world_property_script.h +// Module : script_world_property_script.cpp // Created : 19.03.2004 // Modified : 19.03.2004 // Author : Dmitriy Iassenev @@ -7,21 +7,27 @@ //////////////////////////////////////////////////////////////////////////// #include "pch.hpp" -#include "script_world_property.h" + #include "operator_abstract.h" -#include "xrScriptEngine/ScriptExporter.hpp" +#include "Navigation/graph_engine_space.h" + +#include "xrScriptEngine/script_space.hpp" -SCRIPT_EXPORT(CScriptWorldProperty, (), +namespace GraphEngineSpace +{ +void CScriptWorldProperty::script_register(lua_State* luaState) { using namespace luabind; + using GraphEngineSpace::CWorldProperty; module(luaState) [ - class_("world_property") - .def(constructor()) - .def("condition", &CScriptWorldProperty::condition) - .def("value", &CScriptWorldProperty::value) - .def(const_self < other()) - .def(const_self == other()) -]; -}); + class_("world_property") + .def(constructor()) + .def("condition", &CWorldProperty::condition) + .def("value", &CWorldProperty::value) + .def(const_self < other()) + .def(const_self == other()) + ]; +} +} // namespace GraphEngineSpace diff --git a/src/xrAICore/Components/script_world_state.h b/src/xrAICore/Components/script_world_state.h deleted file mode 100644 index 89b0e13c6eb..00000000000 --- a/src/xrAICore/Components/script_world_state.h +++ /dev/null @@ -1,17 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// Module : script_world_state.h -// Created : 19.03.2004 -// Modified : 19.03.2004 -// Author : Dmitriy Iassenev -// Description : Script world state -//////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "xrAICore/Navigation/graph_engine_space.h" - -typedef GraphEngineSpace::CWorldState CScriptWorldState; - -class CScriptWorldStateWrapper -{ -}; diff --git a/src/xrAICore/Components/script_world_state_script.cpp b/src/xrAICore/Components/script_world_state_script.cpp index d8ec5b0183c..35cc78fd55f 100644 --- a/src/xrAICore/Components/script_world_state_script.cpp +++ b/src/xrAICore/Components/script_world_state_script.cpp @@ -7,27 +7,31 @@ //////////////////////////////////////////////////////////////////////////// #include "pch.hpp" -#include "script_world_state.h" + #include "condition_state.h" -#include "xrScriptEngine/ScriptExporter.hpp" +#include "Navigation/graph_engine_space.h" + +#include "xrScriptEngine/script_space.hpp" -SCRIPT_EXPORT(CScriptWorldState, (), +namespace GraphEngineSpace +{ +void CScriptWorldState::script_register(lua_State* luaState) { using namespace luabind; + using GraphEngineSpace::CWorldState; module(luaState) [ - class_("world_state") + class_("world_state") .def(constructor<>()) - .def(constructor()) - .def("add_property", (void (CScriptWorldState::*)(const CScriptWorldState::COperatorCondition&))( - &CScriptWorldState::add_condition)) - .def("remove_property", - (void (CScriptWorldState::*)(const CScriptWorldState::COperatorCondition::condition_type&))( - &CScriptWorldState::remove_condition)) - .def("clear", &CScriptWorldState::clear) - .def("includes", &CScriptWorldState::includes) - .def("property", &CScriptWorldState::property) - .def(const_self < CScriptWorldState()) - .def(const_self == CScriptWorldState())]; -}); + .def(constructor()) + .def("add_property", (void (CWorldState::*)(const CWorldState::COperatorCondition&))&CWorldState::add_condition) + .def("remove_property", &CWorldState::remove_condition) + .def("clear", &CWorldState::clear) + .def("includes", &CWorldState::includes) + .def("property", &CWorldState::property) + .def(const_self < CWorldState()) + .def(const_self == CWorldState()) + ]; +} +} // namespace GraphEngineSpace diff --git a/src/xrAICore/Navigation/PatrolPath/patrol_path_params.cpp b/src/xrAICore/Navigation/PatrolPath/patrol_path_params.cpp index 4bd2294e566..1f9a265d499 100644 --- a/src/xrAICore/Navigation/PatrolPath/patrol_path_params.cpp +++ b/src/xrAICore/Navigation/PatrolPath/patrol_path_params.cpp @@ -7,12 +7,13 @@ //////////////////////////////////////////////////////////////////////////// #include "pch.hpp" + #include "patrol_path_params.h" #include "patrol_path_storage.h" -#include "xrScriptEngine/script_engine.hpp" -#include "xrScriptEngine/DebugMacros.hpp" // for THROW3 // XXX: move debug macros to xrCore #include "AISpaceBase.hpp" +#include "xrScriptEngine/script_engine.hpp" + CPatrolPathParams::CPatrolPathParams(LPCSTR caPatrolPathToGo, EPatrolStartType tPatrolPathStart, EPatrolRouteType tPatrolPathStop, bool bRandom, u32 index) : m_path_name(caPatrolPathToGo) @@ -41,7 +42,7 @@ const Fvector& CPatrolPathParams::point(u32 index) const if (!m_path->vertex(index)) { GEnv.ScriptEngine->script_log(LuaMessageType::Error, - "Can't get information about patrol point number %d in the patrol way %s", index, *m_path_name); + "Can't get information about patrol point number %d in the patrol way %s", index, m_path_name.c_str()); index = (*m_path->vertices().begin()).second->vertex_id(); } VERIFY(m_path->vertex(index)); @@ -83,7 +84,7 @@ Flags32 CPatrolPathParams::flags(u32 index) const LPCSTR CPatrolPathParams::name(u32 index) const { VERIFY(m_path->vertex(index)); - return (*m_path->vertex(index)->data().name()); + return m_path->vertex(index)->data().name().c_str(); } bool CPatrolPathParams::terminal(u32 index) const diff --git a/src/xrAICore/Navigation/PatrolPath/patrol_path_params.h b/src/xrAICore/Navigation/PatrolPath/patrol_path_params.h index b0dc18348cb..4fd16201af4 100644 --- a/src/xrAICore/Navigation/PatrolPath/patrol_path_params.h +++ b/src/xrAICore/Navigation/PatrolPath/patrol_path_params.h @@ -11,6 +11,8 @@ #include "xrAICore/Navigation/game_graph_space.h" #include "xrAICore/Navigation/PatrolPath/patrol_path.h" +#include "xrScriptEngine/ScriptExporter.hpp" + class CPatrolPath; class CPatrolPathStorage; @@ -38,6 +40,9 @@ class XRAICORE_API CPatrolPathParams bool flag(u32 index, u8 flag_index) const; Flags32 flags(u32 index) const; bool terminal(u32 index) const; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #include "xrAICore/Navigation/PatrolPath/patrol_path_params_inline.h" diff --git a/src/xrAICore/Navigation/PatrolPath/patrol_path_params_script.cpp b/src/xrAICore/Navigation/PatrolPath/patrol_path_params_script.cpp index 7291b805e14..cd46d0a026c 100644 --- a/src/xrAICore/Navigation/PatrolPath/patrol_path_params_script.cpp +++ b/src/xrAICore/Navigation/PatrolPath/patrol_path_params_script.cpp @@ -7,9 +7,10 @@ //////////////////////////////////////////////////////////////////////////// #include "pch.hpp" + #include "patrol_path_params.h" -#include "xrScriptEngine/ScriptExporter.hpp" -#include "xrScriptEngine/DebugMacros.hpp" // for THROW3 // XXX: move debug macros to xrCore + +#include "xrScriptEngine/script_space.hpp" Fvector CPatrolPathParams__point(const CPatrolPathParams* params, u32 index) { @@ -17,7 +18,7 @@ Fvector CPatrolPathParams__point(const CPatrolPathParams* params, u32 index) return params->point(index); } -SCRIPT_EXPORT(CPatrolPathParams, (), +void CPatrolPathParams::script_register(lua_State* luaState) { using namespace luabind; @@ -55,4 +56,4 @@ SCRIPT_EXPORT(CPatrolPathParams, (), .def("flags", &CPatrolPathParams::flags) .def("terminal", &CPatrolPathParams::terminal) ]; -}); +} diff --git a/src/xrAICore/Navigation/PatrolPath/patrol_path_storage.cpp b/src/xrAICore/Navigation/PatrolPath/patrol_path_storage.cpp index 48ca11aa511..862010621d2 100644 --- a/src/xrAICore/Navigation/PatrolPath/patrol_path_storage.cpp +++ b/src/xrAICore/Navigation/PatrolPath/patrol_path_storage.cpp @@ -33,7 +33,7 @@ void CPatrolPathStorage::load_raw( shared_str patrol_name; sub_chunk->r_stringZ(patrol_name); - VERIFY3(m_registry.find(patrol_name) == m_registry.end(), "Duplicated patrol path found", *patrol_name); + VERIFY3(m_registry.find(patrol_name) == m_registry.end(), "Duplicated patrol path found", patrol_name.c_str()); m_registry.emplace( patrol_name, &(xr_new(patrol_name))->load_raw(level_graph, cross, game_graph, *sub_chunk) ); diff --git a/src/xrAICore/Navigation/PatrolPath/patrol_path_storage.h b/src/xrAICore/Navigation/PatrolPath/patrol_path_storage.h index fb164b83eb3..5172bd324b8 100644 --- a/src/xrAICore/Navigation/PatrolPath/patrol_path_storage.h +++ b/src/xrAICore/Navigation/PatrolPath/patrol_path_storage.h @@ -7,9 +7,9 @@ //////////////////////////////////////////////////////////////////////////// #pragma once + #include "Common/object_interfaces.h" #include "xrCore/Containers/AssociativeVector.hpp" -#include "xrScriptEngine/DebugMacros.hpp" #include "xrCore/xrstring.h" class CPatrolPath; diff --git a/src/xrAICore/Navigation/PatrolPath/patrol_point.cpp b/src/xrAICore/Navigation/PatrolPath/patrol_point.cpp index 40ca4d1840a..d87fca1d380 100644 --- a/src/xrAICore/Navigation/PatrolPath/patrol_point.cpp +++ b/src/xrAICore/Navigation/PatrolPath/patrol_point.cpp @@ -7,18 +7,19 @@ //////////////////////////////////////////////////////////////////////////// #include "pch.hpp" + #include "patrol_point.h" #include "Navigation/level_graph.h" #include "Navigation/level_graph.h" #include "Navigation/game_level_cross_table.h" #include "Navigation/game_graph.h" -#include "Common/object_broker.h" -#include "xrScriptEngine/DebugMacros.hpp" -#include "AISpaceBase.hpp" #ifdef DEBUG #include "Navigation/PatrolPath/patrol_path.h" #endif +#include "AISpaceBase.hpp" +#include "Common/object_broker.h" + CPatrolPoint::CPatrolPoint(const CPatrolPath* path) : m_flags(0), m_level_vertex_id(u32(-1)), m_game_vertex_id(GameGraph::_GRAPH_ID(-1)) #ifdef DEBUG @@ -41,7 +42,7 @@ void CPatrolPoint::verify_vertex_id( VERIFY(m_path); string1024 temp; - xr_sprintf(temp, "\n! Patrol point %s in path %s is not on the level graph vertex!", *m_name, *m_path->m_name); + xr_sprintf(temp, "\n! Patrol point %s in path %s is not on the level graph vertex!", m_name.c_str(), m_path->m_name.c_str()); THROW2(level_graph->valid_vertex_id(m_level_vertex_id), temp); } #endif diff --git a/src/xrAICore/Navigation/a_star.h b/src/xrAICore/Navigation/a_star.h index d127ac4472b..14d7009f64a 100644 --- a/src/xrAICore/Navigation/a_star.h +++ b/src/xrAICore/Navigation/a_star.h @@ -11,7 +11,6 @@ #include "xrAICore/Navigation/vertex_path.h" #include "xrAICore/Navigation/data_storage_constructor.h" #include "xrAICore/Navigation/dijkstra.h" -#include "xrScriptEngine/DebugMacros.hpp" // XXX: move debug macros to xrCore template struct AStarVertexData diff --git a/src/xrAICore/Navigation/game_graph.h b/src/xrAICore/Navigation/game_graph.h index 24435a2f967..ac196e1254d 100644 --- a/src/xrAICore/Navigation/game_graph.h +++ b/src/xrAICore/Navigation/game_graph.h @@ -11,9 +11,11 @@ #include "xrAICore/Navigation/game_graph_space.h" #include "xrAICore/Navigation/game_level_cross_table.h" +#include "xrScriptEngine/ScriptExporter.hpp" + constexpr cpcstr GRAPH_NAME = "game.graph"; -class CGameGraph +class XRAICORE_API CGameGraph { private: friend class CRenumbererConverter; @@ -74,6 +76,9 @@ class CGameGraph IC _GRAPH_ID vertex_id(const CGameVertex* vertex) const; IC void set_current_level(u32 level_id); IC const _GRAPH_ID& current_level_vertex() const; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #include "xrAICore/Navigation/game_graph_inline.h" diff --git a/src/xrAICore/Navigation/game_graph_script.cpp b/src/xrAICore/Navigation/game_graph_script.cpp index b469bd30bde..4e75854400f 100644 --- a/src/xrAICore/Navigation/game_graph_script.cpp +++ b/src/xrAICore/Navigation/game_graph_script.cpp @@ -7,11 +7,12 @@ //////////////////////////////////////////////////////////////////////////// #include "pch.hpp" + #include "game_graph.h" -#include "xrScriptEngine/ScriptExporter.hpp" -#include "xrScriptEngine/DebugMacros.hpp" // for THROW // XXX: move debug macros to xrCore #include "AISpaceBase.hpp" +#include "xrScriptEngine/script_space.hpp" + const CGameGraph* get_game_graph() { return &GEnv.AISpace->game_graph(); } const CGameGraph::CHeader* get_header(const CGameGraph* self_) { return (&self_->header()); } bool get_accessible1(const CGameGraph* self_, const u32& vertex_id) { return (self_->accessible(vertex_id)); } @@ -34,7 +35,7 @@ GameGraph::LEVEL_MAP const& get_levels(CGameGraph const* graph) return graph->header().levels(); } -SCRIPT_EXPORT(CGameGraph, (), +void CGameGraph::script_register(lua_State* luaState) { using namespace luabind; using namespace luabind::policy; @@ -62,4 +63,4 @@ SCRIPT_EXPORT(CGameGraph, (), .def("level_id", &CGameVertex::level_id) .def("level_vertex_id", &CGameVertex::level_vertex_id) ]; -}); +} diff --git a/src/xrAICore/Navigation/graph_engine_space.h b/src/xrAICore/Navigation/graph_engine_space.h index ba5ad230f67..690ea8f1b26 100644 --- a/src/xrAICore/Navigation/graph_engine_space.h +++ b/src/xrAICore/Navigation/graph_engine_space.h @@ -9,6 +9,7 @@ #pragma once #include "xrCore/xrCore.h" +#include "xrScriptEngine/ScriptExporter.hpp" template class COperatorConditionAbstract; @@ -84,4 +85,14 @@ using CNearestVertexParameters = SNearestVertex<_dist_type, _index_type, _iterat using CGameLevelParams = SGameLevel<_dist_type, _index_type, _iteration_type>; using CGameVertexParams = SGameVertex<_dist_type, _index_type, _iteration_type>; + +class XRAICORE_API CScriptWorldProperty +{ + DECLARE_SCRIPT_REGISTER_FUNCTION(); +}; + +class XRAICORE_API CScriptWorldState +{ + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; +} // namespace GraphEngineSpace diff --git a/src/xrAICore/xrAICore.vcxproj b/src/xrAICore/xrAICore.vcxproj index bb680e8430b..8e82bda96a9 100644 --- a/src/xrAICore/xrAICore.vcxproj +++ b/src/xrAICore/xrAICore.vcxproj @@ -58,9 +58,6 @@ - - - diff --git a/src/xrAICore/xrAICore.vcxproj.filters b/src/xrAICore/xrAICore.vcxproj.filters index 1c4a89a1962..e23330f51c3 100644 --- a/src/xrAICore/xrAICore.vcxproj.filters +++ b/src/xrAICore/xrAICore.vcxproj.filters @@ -345,15 +345,6 @@ AI\Components\ProblemSolver\OperatorCondition - - AI\Components\ProblemSolver\ConditionState\ScriptWorldState - - - AI\Components\ProblemSolver\OperatorCondition\ScriptWorldProperty - - - AI\Components\ProblemSolver\OperatorCondition\ScriptWorldProperty - AI\Components\ProblemSolver\ConditionState diff --git a/src/xrCDB/CMakeLists.txt b/src/xrCDB/CMakeLists.txt index 2d4ff876ebe..a8ba235fc75 100644 --- a/src/xrCDB/CMakeLists.txt +++ b/src/xrCDB/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(xrCDB SHARED) +add_library(xrCDB) target_sources_grouped( TARGET xrCDB @@ -54,7 +54,6 @@ target_link_libraries(xrCDB target_compile_definitions(xrCDB PRIVATE XRCDB_EXPORTS - $<$:OPCODE_STATIC> ) set_target_properties(xrCDB PROPERTIES @@ -66,6 +65,8 @@ target_precompile_headers(xrCDB stdafx.h ) -install(TARGETS xrCDB LIBRARY - DESTINATION "${CMAKE_INSTALL_LIBDIR}" -) +if (BUILD_SHARED_LIBS) + install(TARGETS xrCDB LIBRARY + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) +endif() diff --git a/src/xrCDB/ISpatial.cpp b/src/xrCDB/ISpatial.cpp index 65140adf26b..3566a72c0e8 100644 --- a/src/xrCDB/ISpatial.cpp +++ b/src/xrCDB/ISpatial.cpp @@ -1,16 +1,17 @@ #include "stdafx.h" + #include "ISpatial.h" + +#include "xrCore/_fbox.h" +#include "xrCore/Threading/Lock.hpp" +#include "xrCore/Threading/ScopeLock.hpp" + #include "xrEngine/Engine.h" -#include "xrEngine/Render.h" + #ifdef DEBUG #include "xrEngine/xr_object.h" #include "xrEngine/PS_instance.h" #endif -#include "xrEngine/device.h" -#include "xrEngine/GameFont.h" -#include "xrEngine/PerformanceAlert.hpp" -#include "xrCore/Threading/Lock.hpp" -#include "xrCore/Threading/ScopeLock.hpp" Fvector c_spatial_offset[8] = { {-1, -1, -1}, {1, -1, -1}, {-1, 1, -1}, {1, 1, -1}, {-1, -1, 1}, {1, -1, 1}, {-1, 1, 1}, {1, 1, 1}}; diff --git a/src/xrCore/CMakeLists.txt b/src/xrCore/CMakeLists.txt index aaf17c28256..0f8e2cf4f2c 100644 --- a/src/xrCore/CMakeLists.txt +++ b/src/xrCore/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(xrCore SHARED) +add_library(xrCore) target_sources_grouped( TARGET xrCore @@ -476,8 +476,8 @@ target_compile_definitions(xrCore GITHUB_RUN_ID=\"$ENV{GITHUB_RUN_ID}\" GITHUB_RUN_NUMBER=\"$ENV{GITHUB_RUN_NUMBER}\" GITHUB_REPOSITORY=\"$ENV{GITHUB_REPOSITORY}\" - GIT_INFO_CURRENT_COMMIT=\"${GIT_SHA1}\" - GIT_INFO_CURRENT_BRANCH=\"${GIT_BRANCH}\" + GIT_INFO_CURRENT_COMMIT=\"${XRAY_GIT_SHA1}\" + GIT_INFO_CURRENT_BRANCH=\"${XRAY_GIT_BRANCH}\" OPENSSL_NO_DEPRECATED ) @@ -496,6 +496,8 @@ target_precompile_headers(xrCore stdafx.h ) -install(TARGETS xrCore LIBRARY - DESTINATION "${CMAKE_INSTALL_LIBDIR}" -) +if (BUILD_SHARED_LIBS) + install(TARGETS xrCore LIBRARY + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) +endif() diff --git a/src/xrCore/Crypto/trivial_encryptor.h b/src/xrCore/Crypto/trivial_encryptor.h index cc4446e888b..47f9b00ad05 100644 --- a/src/xrCore/Crypto/trivial_encryptor.h +++ b/src/xrCore/Crypto/trivial_encryptor.h @@ -26,11 +26,11 @@ class XRCORE_API trivial_encryptor key m_key; public: + key_flag m_current_key = key_flag::russian; const key m_key_russian; const key m_key_worldwide; private: - key_flag m_current_key; type m_alphabet[alphabet_size]; type m_alphabet_back[alphabet_size]; diff --git a/src/xrCore/FS.h b/src/xrCore/FS.h index 1347c15150b..b95ef1d340c 100644 --- a/src/xrCore/FS.h +++ b/src/xrCore/FS.h @@ -69,12 +69,12 @@ class XRCORE_API IWriter IC void w_stringZ(const char* p) { w(p, xr_strlen(p) + 1); } IC void w_stringZ(const shared_str& p) { - w(*p ? *p : "", p.size()); + w(p.c_str() ? p.c_str() : "", p.size()); w_u8(0); } IC void w_stringZ(shared_str& p) { - w(*p ? *p : "", p.size()); + w(p.c_str() ? p.c_str() : "", p.size()); w_u8(0); } IC void w_stringZ(const xr_string& p) diff --git a/src/xrCore/FileSystem.cpp b/src/xrCore/FileSystem.cpp index 00177629620..062bb67f1c5 100644 --- a/src/xrCore/FileSystem.cpp +++ b/src/xrCore/FileSystem.cpp @@ -311,7 +311,7 @@ pcstr EFS_Utils::AppendFolderToName( { *d = 0; if (depth < sv_depth) - xr_strcat(dest_name, dest_name_size, *tmp); + xr_strcat(dest_name, dest_name_size, tmp.c_str()); } else { diff --git a/src/xrCore/LocatorAPI.cpp b/src/xrCore/LocatorAPI.cpp index 6bd4332ca9a..792b5735bf8 100644 --- a/src/xrCore/LocatorAPI.cpp +++ b/src/xrCore/LocatorAPI.cpp @@ -305,7 +305,7 @@ IReader* open_chunk(void* ptr, u32 ID, pcstr archiveName, size_t archiveSize, bo size_t dest_sz = 0; if (shouldDecrypt) // Try WW key first - g_trivial_encryptor.decode(src_data, dwSize, src_data); + g_trivial_encryptor.decode(src_data, dwSize, src_data, trivial_encryptor::key_flag::russian); bool result = _decompressLZ(&dest, &dest_sz, src_data, dwSize, archiveSize); @@ -478,11 +478,11 @@ void CLocatorAPI::archive::open() if (hSrcFile && hSrcMap) return; - hSrcFile = CreateFile(*path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr); + hSrcFile = CreateFile(path.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr); R_ASSERT(hSrcFile != INVALID_HANDLE_VALUE); hSrcMap = CreateFileMapping(hSrcFile, nullptr, PAGE_READONLY, 0, 0, nullptr); R_ASSERT(hSrcMap != INVALID_HANDLE_VALUE); - stat(*path, &file_info); + stat(path.c_str(), &file_info); modif = file_info.st_mtime; #elif defined(XR_PLATFORM_LINUX) || defined(XR_PLATFORM_BSD) || defined(XR_PLATFORM_APPLE) // Open the file @@ -1415,7 +1415,7 @@ void CLocatorAPI::file_from_archive(IReader*& R, pcstr fname, const file& desc) #endif string1024 temp; - xr_sprintf(temp, sizeof temp, "%s:%s", *A.path, fname); + xr_sprintf(temp, sizeof temp, "%s:%s", A.path.c_str(), fname); #ifdef FS_DEBUG register_file_mapping(ptr, sz, temp); diff --git a/src/xrCore/NET_utils.cpp b/src/xrCore/NET_utils.cpp index d3fb9b3dd74..81c8f4e3035 100644 --- a/src/xrCore/NET_utils.cpp +++ b/src/xrCore/NET_utils.cpp @@ -56,8 +56,8 @@ void NET_Packet::w_sdir(const Fvector& D) void NET_Packet::w_stringZ(const shared_str& p) { W_guard g(&w_allow); - if (*p) - w(*p, p.size() + 1); + if (p.c_str()) + w(p.c_str(), p.size() + 1); else { IIniFileStream* tmp = inistream; diff --git a/src/xrCore/PostProcess/PostProcess.hpp b/src/xrCore/PostProcess/PostProcess.hpp index a0c13a86340..2c3587880bf 100644 --- a/src/xrCore/PostProcess/PostProcess.hpp +++ b/src/xrCore/PostProcess/PostProcess.hpp @@ -143,7 +143,7 @@ class XRCORE_API BasicPostProcessAnimator virtual ~BasicPostProcessAnimator(); void Clear(); virtual void Load(pcstr name, bool internalFs = true); - IC pcstr Name() { return *m_Name; } + pcstr Name() const { return m_Name.c_str(); } virtual void Stop(float speed); void SetDesiredFactor(float f, float sp); void SetCurrentFactor(float f); diff --git a/src/xrCore/XML/XMLDocument.cpp b/src/xrCore/XML/XMLDocument.cpp index 7614cc34e25..0d7c4fcd2d9 100644 --- a/src/xrCore/XML/XMLDocument.cpp +++ b/src/xrCore/XML/XMLDocument.cpp @@ -147,7 +147,7 @@ bool XMLDocument::Load(pcstr path_alias, pcstr path, pcstr xml_filename, bool fa shared_str fn = correct_file_name(path, xml_filename); string_path str; - xr_sprintf(str, "%s" DELIMITER "%s", path, *fn); + xr_sprintf(str, "%s" DELIMITER "%s", path, fn.c_str()); return Load(path_alias, str, fatal); } @@ -157,12 +157,12 @@ bool XMLDocument::Load(pcstr path_alias, pcstr path, pcstr path2, pcstr xml_file shared_str fn = correct_file_name(path, xml_filename); string_path str; - xr_sprintf(str, "%s" DELIMITER "%s", path, *fn); + xr_sprintf(str, "%s" DELIMITER "%s", path, fn.c_str()); if (Load(path_alias, str, false)) return true; fn = correct_file_name(path2, xml_filename); - xr_sprintf(str, "%s" DELIMITER "%s", path2, *fn); + xr_sprintf(str, "%s" DELIMITER "%s", path2, fn.c_str()); return Load(path_alias, str, fatal); } diff --git a/src/xrCore/_math.cpp b/src/xrCore/_math.cpp index d8455de3746..0fb873cb8a2 100644 --- a/src/xrCore/_math.cpp +++ b/src/xrCore/_math.cpp @@ -136,65 +136,3 @@ void _initialize_cpu_thread() } } - -void spline1(float t, Fvector* p, Fvector* ret) -{ - float t2 = t * t; - float t3 = t2 * t; - float m[4]; - - ret->x = 0.0f; - ret->y = 0.0f; - ret->z = 0.0f; - m[0] = (0.5f * ((-1.0f * t3) + (2.0f * t2) + (-1.0f * t))); - m[1] = (0.5f * ((3.0f * t3) + (-5.0f * t2) + (0.0f * t) + 2.0f)); - m[2] = (0.5f * ((-3.0f * t3) + (4.0f * t2) + (1.0f * t))); - m[3] = (0.5f * ((1.0f * t3) + (-1.0f * t2) + (0.0f * t))); - - for (int i = 0; i < 4; i++) - { - ret->x += p[i].x * m[i]; - ret->y += p[i].y * m[i]; - ret->z += p[i].z * m[i]; - } -} - -void spline2(float t, Fvector* p, Fvector* ret) -{ - float s = 1.0f - t; - float t2 = t * t; - float t3 = t2 * t; - float m[4]; - - m[0] = s * s * s; - m[1] = 3.0f * t3 - 6.0f * t2 + 4.0f; - m[2] = -3.0f * t3 + 3.0f * t2 + 3.0f * t + 1; - m[3] = t3; - - ret->x = (p[0].x * m[0] + p[1].x * m[1] + p[2].x * m[2] + p[3].x * m[3]) / 6.0f; - ret->y = (p[0].y * m[0] + p[1].y * m[1] + p[2].y * m[2] + p[3].y * m[3]) / 6.0f; - ret->z = (p[0].z * m[0] + p[1].z * m[1] + p[2].z * m[2] + p[3].z * m[3]) / 6.0f; -} - -#define beta1 1.0f -#define beta2 0.8f - -void spline3(float t, Fvector* p, Fvector* ret) -{ - float s = 1.0f - t; - float t2 = t * t; - float t3 = t2 * t; - float b12 = beta1 * beta2; - float b13 = b12 * beta1; - float delta = 2.0f - b13 + 4.0f * b12 + 4.0f * beta1 + beta2 + 2.0f; - float d = 1.0f / delta; - float b0 = 2.0f * b13 * d * s * s * s; - float b3 = 2.0f * t3 * d; - float b1 = d * (2 * b13 * t * (t2 - 3 * t + 3) + 2 * b12 * (t3 - 3 * t2 + 2) + 2 * beta1 * (t3 - 3 * t + 2) + - beta2 * (2 * t3 - 3 * t2 + 1)); - float b2 = d * (2 * b12 * t2 * (-t + 3) + 2 * beta1 * t * (-t2 + 3) + beta2 * t2 * (-2 * t + 3) + 2 * (-t3 + 1)); - - ret->x = p[0].x * b0 + p[1].x * b1 + p[2].x * b2 + p[3].x * b3; - ret->y = p[0].y * b0 + p[1].y * b1 + p[2].y * b2 + p[3].y * b3; - ret->z = p[0].z * b0 + p[1].z * b1 + p[2].z * b2 + p[3].z * b3; -} diff --git a/src/xrCore/clsid.cpp b/src/xrCore/clsid.cpp index 64b87fe3b9e..a8c223bb991 100644 --- a/src/xrCore/clsid.cpp +++ b/src/xrCore/clsid.cpp @@ -10,6 +10,7 @@ XRCORE_API void CLSID2TEXT(CLASS_ID id, pstr text) id >>= 8; } } + XRCORE_API CLASS_ID TEXT2CLSID(pcstr text) { VERIFY3(xr_strlen(text) <= 8, "Beer from creator CLASS_ID:", text); @@ -22,5 +23,5 @@ XRCORE_API CLASS_ID TEXT2CLSID(pcstr text) buf[8 - need] = ' '; need--; } - return MK_CLSID(buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]); + return xray::make_clsid(buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]); } diff --git a/src/xrCore/clsid.h b/src/xrCore/clsid.h index 289c28f0f03..a0a6e4f649b 100644 --- a/src/xrCore/clsid.h +++ b/src/xrCore/clsid.h @@ -5,12 +5,34 @@ //***** CLASS ID type using CLASS_ID = u64; -#define MK_CLSID(a, b, c, d, e, f, g, h) \ - CLASS_ID((CLASS_ID(a) << CLASS_ID(56)) | (CLASS_ID(b) << CLASS_ID(48)) | (CLASS_ID(c) << CLASS_ID(40)) | \ - (CLASS_ID(d) << CLASS_ID(32)) | (CLASS_ID(e) << CLASS_ID(24)) | (CLASS_ID(f) << CLASS_ID(16)) | \ - (CLASS_ID(g) << CLASS_ID(8)) | (CLASS_ID(h))) +namespace xray +{ +constexpr CLASS_ID make_clsid(const char(&str)[9]) +{ + return static_cast(str[0]) << static_cast(56) | + static_cast(str[1]) << static_cast(48) | + static_cast(str[2]) << static_cast(40) | + static_cast(str[3]) << static_cast(32) | + static_cast(str[4]) << static_cast(24) | + static_cast(str[5]) << static_cast(16) | + static_cast(str[6]) << static_cast(8) | + static_cast(str[7]); +} -#define MK_CLSID_INV(a, b, c, d, e, f, g, h) MK_CLSID(h, g, f, e, d, c, b, a) +constexpr CLASS_ID make_clsid(const char a, const char b, const char c, const char d, const char e, const char f, const char g, const char h) +{ + return static_cast(a) << static_cast(56) | + static_cast(b) << static_cast(48) | + static_cast(c) << static_cast(40) | + static_cast(d) << static_cast(32) | + static_cast(e) << static_cast(24) | + static_cast(f) << static_cast(16) | + static_cast(g) << static_cast(8) | + static_cast(h); +} +} // namespace xray + +#define MK_CLSID(a, b, c, d, e, f, g, h) xray::make_clsid(a, b, c, d, e, f, g, h) extern XRCORE_API void CLSID2TEXT(CLASS_ID id, pstr text); extern XRCORE_API CLASS_ID TEXT2CLSID(pcstr text); diff --git a/src/xrCore/xrCore.h b/src/xrCore/xrCore.h index 85df6e7f606..71851a16161 100644 --- a/src/xrCore/xrCore.h +++ b/src/xrCore/xrCore.h @@ -65,7 +65,7 @@ struct XRCORE_API xr_rtoken : name(_nm), id(_id) {} void rename(pcstr _nm) { name = _nm; } - bool equal(pcstr _nm) const { return (0 == xr_strcmp(*name, _nm)); } + bool equal(pcstr _nm) const { return (0 == xr_strcmp(name.c_str(), _nm)); } }; #include "xr_shortcut.h" diff --git a/src/xrCore/xrCore.vcxproj b/src/xrCore/xrCore.vcxproj index 5482ce193e7..1bde5f68fe2 100644 --- a/src/xrCore/xrCore.vcxproj +++ b/src/xrCore/xrCore.vcxproj @@ -30,6 +30,11 @@ mimalloc-static.lib;%(AdditionalDependencies) mimalloc-static-debug.lib;%(AdditionalDependencies) + + BugTrap.lib;DbgHelp.lib;FaultRep.lib;lzo.lib;jpeg-static.lib;libcrypto.lib;%(AdditionalDependencies) + mimalloc-static.lib;%(AdditionalDependencies) + mimalloc-static-debug.lib;%(AdditionalDependencies) + where /q git if errorlevel 1 ( @@ -258,18 +263,6 @@ call .GitInfo.cmd - - Document - - - Document - - - Document - - - Document - diff --git a/src/xrCore/xrCore.vcxproj.filters b/src/xrCore/xrCore.vcxproj.filters index 47e0bca64e3..aba29a2158c 100644 --- a/src/xrCore/xrCore.vcxproj.filters +++ b/src/xrCore/xrCore.vcxproj.filters @@ -736,11 +736,4 @@ - - - - - - - \ No newline at end of file diff --git a/src/xrCore/xrDebug.cpp b/src/xrCore/xrDebug.cpp index 703bcd12fbc..20265c942db 100644 --- a/src/xrCore/xrDebug.cpp +++ b/src/xrCore/xrDebug.cpp @@ -603,10 +603,11 @@ int out_of_memory_handler(size_t size) { Memory.mem_compact(); const size_t processHeap = Memory.mem_usage(); - const size_t ecoStrings = g_pStringContainer->stat_economy(); + const auto [ecoStringsBytes, ecoStringsCount] = g_pStringContainer->stat_economy(); const size_t ecoSmem = g_pSharedMemoryContainer->stat_economy(); Msg("* [x-ray]: process heap[%zu K]", processHeap / 1024); - Msg("* [x-ray]: economy: strings[%zu K], smem[%zu K]", ecoStrings / 1024, ecoSmem); + Msg("* [x-ray]: shared strings: memory[%ld K], count[%lu]", ecoStringsBytes / 1024, ecoStringsCount); + Msg("* [x-ray]: shared memory[%ld K]", ecoSmem); } xrDebug::Fatal(DEBUG_INFO, "Out of memory. Memory request: %zu K", size / 1024); return 1; diff --git a/src/xrCore/xrDebug_macros.h b/src/xrCore/xrDebug_macros.h index 5a5a45821aa..37d88c40f9c 100644 --- a/src/xrCore/xrDebug_macros.h +++ b/src/xrCore/xrDebug_macros.h @@ -1,6 +1,5 @@ #pragma once -#ifndef xrDebug_macrosH -#define xrDebug_macrosH + #include "xrDebug.h" #define DEBUG_INFO {__FILE__, __LINE__, __FUNCTION__} @@ -203,6 +202,29 @@ #define CHK_DX(expr) expr #define CHK_GL(expr) expr #endif // DEBUG + +#if XRAY_EXCEPTIONS +#define THROW3(expr, msg0, msg1)\ + do\ + {\ + if (!(expr))\ + {\ + string4096 assertionInfo;\ + xrDebug::GatherInfo(assertionInfo, sizeof(assertionInfo), DEBUG_INFO, #expr, msg0, msg1, nullptr);\ + throw assertionInfo;\ + }\ + }\ + while (false) + +#define THROW(expr) THROW3(expr, nullptr, nullptr) +#define THROW2(expr, msg0) THROW3(expr, msg0, nullptr) + +#else +#define THROW VERIFY +#define THROW2 VERIFY2 +#define THROW3 VERIFY3 +#endif + //--------------------------------------------------------------------------------------------- // FIXMEs / TODOs / NOTE macros //--------------------------------------------------------------------------------------------- @@ -224,4 +246,3 @@ #define todo(x) message(__FILE__LINE__" TODO : " #x "\n") #define fixme(x) message(__FILE__LINE__" FIXME: " #x "\n") -#endif // xrDebug_macrosH diff --git a/src/xrCore/xr_ini.cpp b/src/xrCore/xr_ini.cpp index fb0316e045a..93449df00f8 100644 --- a/src/xrCore/xr_ini.cpp +++ b/src/xrCore/xr_ini.cpp @@ -243,14 +243,14 @@ void CInifile::Destroy(CInifile* ini) { xr_delete(ini); } bool sect_pred(const CInifile::Sect* x, pcstr val) { - return xr_strcmp(*x->Name, val) < 0; + return xr_strcmp(x->Name.c_str(), val) < 0; } bool item_pred(const CInifile::Item& x, pcstr val) { if (!x.first || !val) return x.first < val; - return xr_strcmp(*x.first, val) < 0; + return xr_strcmp(x.first.c_str(), val) < 0; } XRCORE_API bool _parse(pstr dest, pcstr src) @@ -316,10 +316,10 @@ XRCORE_API void _decorate(pstr dest, pcstr src) bool CInifile::Sect::line_exist(pcstr line, pcstr* value) { auto A = std::lower_bound(Data.begin(), Data.end(), line, item_pred); - if (A != Data.end() && xr_strcmp(*A->first, line) == 0) + if (A != Data.end() && xr_strcmp(A->first.c_str(), line) == 0) { if (value) - *value = *A->second; + *value = A->second.c_str(); return true; } return false; @@ -378,7 +378,7 @@ CInifile::~CInifile() static void insert_item(CInifile::Sect* tgt, const CInifile::Item& I) { - auto sect_it = std::lower_bound(tgt->Data.begin(), tgt->Data.end(), *I.first, item_pred); + auto sect_it = std::lower_bound(tgt->Data.begin(), tgt->Data.end(), I.first.c_str(), item_pred); if (sect_it != tgt->Data.end() && sect_it->first.equal(I.first)) { sect_it->second = I.second; @@ -482,9 +482,9 @@ void CInifile::Load(IReader* F, pcstr path, allow_include_func_t allow_include_f if (Current) { // store previous section - auto I = std::lower_bound(DATA.begin(), DATA.end(), *Current->Name, sect_pred); + auto I = std::lower_bound(DATA.begin(), DATA.end(), Current->Name.c_str(), sect_pred); if (I != DATA.end() && (*I)->Name == Current->Name) - xrDebug::Fatal(DEBUG_INFO, "Duplicate section '%s' found.", *Current->Name); + xrDebug::Fatal(DEBUG_INFO, "Duplicate section '%s' found.", Current->Name.c_str()); DATA.insert(I, Current); } Current = xr_new(); @@ -596,12 +596,12 @@ void CInifile::Load(IReader* F, pcstr path, allow_include_func_t allow_include_f if (m_flags.test(eReadOnly)) { - if (*I.first) + if (I.first.c_str()) insert_item(Current, I); } else { - if (*I.first || *I.second + if (I.first.c_str() || I.second.c_str() //#ifdef DEBUG // || *I.comment //#endif @@ -613,9 +613,9 @@ void CInifile::Load(IReader* F, pcstr path, allow_include_func_t allow_include_f } if (Current) { - auto I = std::lower_bound(DATA.begin(), DATA.end(), *Current->Name, sect_pred); + auto I = std::lower_bound(DATA.begin(), DATA.end(), Current->Name.c_str(), sect_pred); if (I != DATA.end() && (*I)->Name == Current->Name) - xrDebug::Fatal(DEBUG_INFO, "Duplicate section '%s' found.", *Current->Name); + xrDebug::Fatal(DEBUG_INFO, "Duplicate section '%s' found.", Current->Name.c_str()); DATA.insert(I, Current); } } @@ -637,11 +637,11 @@ void CInifile::save_as(IWriter& writer, bool bcheck) const for (auto s_it = (*r_it)->Data.begin(); s_it != (*r_it)->Data.end(); ++s_it) { const Item& I = *s_it; - if (*I.first) + if (I.first.c_str()) { - if (*I.second) + if (I.second.c_str()) { - _decorate(val, *I.second); + _decorate(val, I.second.c_str()); // only name and value xr_sprintf(temp, sizeof temp, "%8s%-32s = %-32s", " ", I.first.c_str(), val); } @@ -684,7 +684,7 @@ bool CInifile::save_as(pcstr new_fname) bool CInifile::section_exist(pcstr S) const { auto I = std::lower_bound(DATA.begin(), DATA.end(), S, sect_pred); - return I != DATA.end() && xr_strcmp(*(*I)->Name, S) == 0; + return I != DATA.end() && xr_strcmp((*I)->Name.c_str(), S) == 0; } bool CInifile::line_exist(pcstr S, pcstr L) const @@ -693,7 +693,7 @@ bool CInifile::line_exist(pcstr S, pcstr L) const return false; Sect& I = r_section(S); auto A = std::lower_bound(I.Data.begin(), I.Data.end(), L, item_pred); - return A != I.Data.end() && xr_strcmp(*A->first, L) == 0; + return A != I.Data.end() && xr_strcmp(A->first.c_str(), L) == 0; } u32 CInifile::line_count(pcstr Sname) const @@ -701,17 +701,17 @@ u32 CInifile::line_count(pcstr Sname) const Sect& S = r_section(Sname); u32 C = 0; for (const auto& item : S.Data) - if (*item.first) + if (item.first.c_str()) C++; return C; } u32 CInifile::section_count() const { return DATA.size(); } //-------------------------------------------------------------------------------------- -CInifile::Sect& CInifile::r_section(const shared_str& S) const { return r_section(*S); } -bool CInifile::line_exist(const shared_str& S, const shared_str& L)const { return line_exist(*S, *L); } -u32 CInifile::line_count(const shared_str& S) const { return line_count(*S); } -bool CInifile::section_exist(const shared_str& S) const { return section_exist(*S); } +CInifile::Sect& CInifile::r_section(const shared_str& S) const { return r_section(S.c_str()); } +bool CInifile::line_exist(const shared_str& S, const shared_str& L)const { return line_exist(S.c_str(), L.c_str()); } +u32 CInifile::line_count(const shared_str& S) const { return line_count(S.c_str()); } +bool CInifile::section_exist(const shared_str& S) const { return section_exist(S.c_str()); } //-------------------------------------------------------------------------------------- // Read functions //-------------------------------------------------------------------------------------- @@ -723,7 +723,7 @@ CInifile::Sect& CInifile::r_section(pcstr S) const auto I = std::lower_bound(DATA.cbegin(), DATA.cend(), section, sect_pred); if (I == DATA.cend()) xrDebug::Fatal(DEBUG_INFO, "Can't find section '%s'.", S); - else if (xr_strcmp(*(*I)->Name, section)) + else if (xr_strcmp((*I)->Name.c_str(), section)) { // g_pStringContainer->verify(); @@ -736,7 +736,7 @@ CInifile::Sect& CInifile::r_section(pcstr S) const // F->w_string ("shared strings:"); // g_pStringContainer->dump(F); // FS.w_close (F); - xrDebug::Fatal(DEBUG_INFO, "Can't open section '%s' (only '%s' avail). Please attach [*.ini_log] file to your bug report", section, *(*I)->Name); + xrDebug::Fatal(DEBUG_INFO, "Can't open section '%s' (only '%s' avail). Please attach [*.ini_log] file to your bug report", section, (*I)->Name.c_str()); } return **I; } @@ -746,8 +746,8 @@ pcstr CInifile::r_string(pcstr S, pcstr L) const Sect const& I = r_section(S); auto A = std::lower_bound(I.Data.cbegin(), I.Data.cend(), L, item_pred); - if (A != I.Data.cend() && xr_strcmp(*A->first, L) == 0) - return *A->second; + if (A != I.Data.cend() && xr_strcmp(A->first.c_str(), L) == 0) + return A->second.c_str(); xrDebug::Fatal(DEBUG_INFO, "Can't find variable %s in [%s]", L, S); return nullptr; @@ -928,14 +928,14 @@ bool CInifile::r_line(pcstr S, int L, pcstr* N, pcstr* V) const for (auto I = SS.Data.cbegin(); I != SS.Data.cend(); ++I) if (!L--) { - *N = *I->first; - *V = *I->second; + *N = I->first.c_str(); + *V = I->second.c_str(); return true; } return false; } -bool CInifile::r_line(const shared_str& S, int L, pcstr* N, pcstr* V) const { return r_line(*S, L, N, V); } +bool CInifile::r_line(const shared_str& S, int L, pcstr* N, pcstr* V) const { return r_line(S.c_str(), L, N, V); } //-------------------------------------------------------------------------------------------------------- // Write functions //-------------------------------------------------------------------------------------- @@ -972,12 +972,12 @@ void CInifile::w_string(pcstr S, pcstr L, pcstr V, pcstr comment) //#ifdef DEBUG // I.comment = (comment?comment:0); //#endif - auto it = std::lower_bound(data.Data.begin(), data.Data.end(), *I.first, item_pred); + auto it = std::lower_bound(data.Data.begin(), data.Data.end(), I.first.c_str(), item_pred); if (it != data.Data.end()) { // Check for "first" matching - if (0 == xr_strcmp(*it->first, *I.first)) + if (0 == xr_strcmp(it->first.c_str(), I.first.c_str())) { bool b = m_flags.test(eOverrideNames); R_ASSERT2(b, make_string("name[%s] already exist in section[%s]", line, sect).c_str()); @@ -1118,7 +1118,7 @@ void CInifile::remove_line(pcstr S, pcstr L) { Sect& data = r_section(S); auto A = std::lower_bound(data.Data.begin(), data.Data.end(), L, item_pred); - R_ASSERT(A != data.Data.end() && xr_strcmp(*A->first, L) == 0); + R_ASSERT(A != data.Data.end() && xr_strcmp(A->first.c_str(), L) == 0); data.Data.erase(A); } } diff --git a/src/xrCore/xr_ini.h b/src/xrCore/xr_ini.h index cbfcbdaa2e2..653a2d3946e 100644 --- a/src/xrCore/xr_ini.h +++ b/src/xrCore/xr_ini.h @@ -194,45 +194,45 @@ class XRCORE_API CInifile // Generic reading functions CLASS_ID r_clsid(pcstr S, pcstr L) const; - CLASS_ID r_clsid(const shared_str& S, pcstr L) const { return r_clsid(*S, L); } + CLASS_ID r_clsid(const shared_str& S, pcstr L) const { return r_clsid(S.c_str(), L); } pcstr r_string(pcstr S, pcstr L) const; // Left quotes in place - pcstr r_string(const shared_str& S, pcstr L) const { return r_string(*S, L); } // Left quotes in place + pcstr r_string(const shared_str& S, pcstr L) const { return r_string(S.c_str(), L); } // Left quotes in place shared_str r_string_wb(pcstr S, pcstr L) const; // Remove quotes - shared_str r_string_wb(const shared_str& S, pcstr L) const { return r_string_wb(*S, L); } // Remove quotes + shared_str r_string_wb(const shared_str& S, pcstr L) const { return r_string_wb(S.c_str(), L); } // Remove quotes u8 r_u8(pcstr S, pcstr L) const; - u8 r_u8(const shared_str& S, pcstr L) const { return r_u8(*S, L); } + u8 r_u8(const shared_str& S, pcstr L) const { return r_u8(S.c_str(), L); } u16 r_u16(pcstr S, pcstr L) const; - u16 r_u16(const shared_str& S, pcstr L) const { return r_u16(*S, L); } + u16 r_u16(const shared_str& S, pcstr L) const { return r_u16(S.c_str(), L); } u32 r_u32(pcstr S, pcstr L) const; - u32 r_u32(const shared_str& S, pcstr L) const { return r_u32(*S, L); } + u32 r_u32(const shared_str& S, pcstr L) const { return r_u32(S.c_str(), L); } u64 r_u64(pcstr S, pcstr L) const; s8 r_s8(pcstr S, pcstr L) const; - s8 r_s8(const shared_str& S, pcstr L) const { return r_s8(*S, L); } + s8 r_s8(const shared_str& S, pcstr L) const { return r_s8(S.c_str(), L); } s16 r_s16(pcstr S, pcstr L) const; - s16 r_s16(const shared_str& S, pcstr L) const { return r_s16(*S, L); } + s16 r_s16(const shared_str& S, pcstr L) const { return r_s16(S.c_str(), L); } s32 r_s32(pcstr S, pcstr L) const; - s32 r_s32(const shared_str& S, pcstr L) const { return r_s32(*S, L); } + s32 r_s32(const shared_str& S, pcstr L) const { return r_s32(S.c_str(), L); } s64 r_s64(pcstr S, pcstr L) const; float r_float(pcstr S, pcstr L) const; - float r_float(const shared_str& S, pcstr L) const { return r_float(*S, L); } + float r_float(const shared_str& S, pcstr L) const { return r_float(S.c_str(), L); } Fcolor r_fcolor(pcstr S, pcstr L) const; - Fcolor r_fcolor(const shared_str& S, pcstr L) const { return r_fcolor(*S, L); } + Fcolor r_fcolor(const shared_str& S, pcstr L) const { return r_fcolor(S.c_str(), L); } u32 r_color(pcstr S, pcstr L) const; - u32 r_color(const shared_str& S, pcstr L) const { return r_color(*S, L); } + u32 r_color(const shared_str& S, pcstr L) const { return r_color(S.c_str(), L); } Ivector2 r_ivector2(pcstr S, pcstr L) const; - Ivector2 r_ivector2(const shared_str& S, pcstr L) const { return r_ivector2(*S, L); } + Ivector2 r_ivector2(const shared_str& S, pcstr L) const { return r_ivector2(S.c_str(), L); } Ivector3 r_ivector3(pcstr S, pcstr L) const; - Ivector3 r_ivector3(const shared_str& S, pcstr L) const { return r_ivector3(*S, L); } + Ivector3 r_ivector3(const shared_str& S, pcstr L) const { return r_ivector3(S.c_str(), L); } Ivector4 r_ivector4(pcstr S, pcstr L) const; - Ivector4 r_ivector4(const shared_str& S, pcstr L) const { return r_ivector4(*S, L); } + Ivector4 r_ivector4(const shared_str& S, pcstr L) const { return r_ivector4(S.c_str(), L); } Fvector2 r_fvector2(pcstr S, pcstr L) const; - Fvector2 r_fvector2(const shared_str& S, pcstr L) const { return r_fvector2(*S, L); } + Fvector2 r_fvector2(const shared_str& S, pcstr L) const { return r_fvector2(S.c_str(), L); } Fvector3 r_fvector3(pcstr S, pcstr L) const; - Fvector3 r_fvector3(const shared_str& S, pcstr L) const { return r_fvector3(*S, L); } + Fvector3 r_fvector3(const shared_str& S, pcstr L) const { return r_fvector3(S.c_str(), L); } Fvector4 r_fvector4(pcstr S, pcstr L) const; - Fvector4 r_fvector4(const shared_str& S, pcstr L) const { return r_fvector4(*S, L); } + Fvector4 r_fvector4(const shared_str& S, pcstr L) const { return r_fvector4(S.c_str(), L); } bool r_bool(pcstr S, pcstr L) const; - bool r_bool(const shared_str& S, pcstr L) const { return r_bool(*S, L); } + bool r_bool(const shared_str& S, pcstr L) const { return r_bool(S.c_str(), L); } int r_token(pcstr S, pcstr L, const xr_token* token_list) const; bool r_line(pcstr S, int L, pcstr* N, pcstr* V) const; bool r_line(const shared_str& S, int L, pcstr* N, pcstr* V) const; diff --git a/src/xrCore/xr_resource.h b/src/xrCore/xr_resource.h index a659caa65f2..31f823caa6b 100644 --- a/src/xrCore/xr_resource.h +++ b/src/xrCore/xr_resource.h @@ -39,7 +39,7 @@ struct xr_resource_named : public xr_resource_flagged const char* set_name(const char* name) { cName = name; - return *cName; + return cName.c_str(); } }; diff --git a/src/xrCore/xr_trims.cpp b/src/xrCore/xr_trims.cpp index 09e5232baf9..fedf37cfe48 100644 --- a/src/xrCore/xr_trims.cpp +++ b/src/xrCore/xr_trims.cpp @@ -388,11 +388,11 @@ shared_str _ListToSequence(const xr_vector& lst) xr_string out; if (lst.size()) { - out = *lst.front(); + out = lst.front().c_str(); for (auto s_it = lst.cbegin() + 1; s_it != lst.cend(); ++s_it) { out += ","; - out += **s_it; + out += s_it->c_str(); } } return shared_str(out.c_str()); diff --git a/src/xrCore/xrstring.cpp b/src/xrCore/xrstring.cpp index e747128527c..e498aaf6426 100644 --- a/src/xrCore/xrstring.cpp +++ b/src/xrCore/xrstring.cpp @@ -121,21 +121,20 @@ struct str_container_impl } } - ptrdiff_t stat_economy() const + std::pair stat_economy() const { - ptrdiff_t counter = 0; + size_t bytes{}, count{}; for (size_t i = 0; i < buffer_size; ++i) { const str_value* value = buffer[i]; while (value) { - counter -= sizeof(str_value); - counter += (value->dwReference - 1) * (value->dwLength + 1); + ++count; + bytes += (value->dwReference - 1) * (value->dwLength + 1); value = value->next; } } - - return counter; + return { bytes, count }; } }; @@ -234,14 +233,12 @@ void str_container::dump(IWriter* W) const impl->cs.Leave(); } -size_t str_container::stat_economy() const +std::pair str_container::stat_economy() const { impl->cs.Enter(); - ptrdiff_t counter = 0; - counter -= sizeof(*this); - counter += impl->stat_economy(); + const auto [bytes, count] = impl->stat_economy(); impl->cs.Leave(); - return size_t(counter); + return { bytes, count }; } str_container::~str_container() diff --git a/src/xrCore/xrstring.h b/src/xrCore/xrstring.h index e0d42e6fee0..29e0824ce51 100644 --- a/src/xrCore/xrstring.h +++ b/src/xrCore/xrstring.h @@ -48,7 +48,7 @@ class XRCORE_API str_container void verify() const; [[nodiscard]] - size_t stat_economy() const; + std::pair stat_economy() const; private: str_container_impl* impl; @@ -225,14 +225,14 @@ ICF int xr_strcmp(const char* S1, const char* S2) return strcmp(S1, S2); } -IC int xr_strcmp(const shared_str& a, const char* b) noexcept { return xr_strcmp(*a, b); } -IC int xr_strcmp(const char* a, const shared_str& b) noexcept { return xr_strcmp(a, *b); } +IC int xr_strcmp(const shared_str& a, const char* b) noexcept { return xr_strcmp(a.c_str(), b); } +IC int xr_strcmp(const char* a, const shared_str& b) noexcept { return xr_strcmp(a, b.c_str()); } IC int xr_strcmp(const shared_str& a, const shared_str& b) noexcept { if (a.equal(b)) return 0; else - return xr_strcmp(*a, *b); + return xr_strcmp(a.c_str(), b.c_str()); } IC char* xr_strlwr(char* src) @@ -248,7 +248,7 @@ IC char* xr_strlwr(char* src) IC void xr_strlwr(shared_str& src) { - if (*src) + if (src.c_str()) { char* lp = xr_strdup(src.c_str()); xr_strlwr(lp); diff --git a/src/xrEngine/CMakeLists.txt b/src/xrEngine/CMakeLists.txt index 01400a88526..54056bf9a8b 100644 --- a/src/xrEngine/CMakeLists.txt +++ b/src/xrEngine/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(xrEngine SHARED) +add_library(xrEngine) target_sources_grouped( TARGET xrEngine @@ -29,6 +29,7 @@ target_sources_grouped( XR_IOConsole_callback.cpp XR_IOConsole_control.cpp XR_IOConsole_get.cpp + XR_IOConsole_script.cpp ) target_sources_grouped( @@ -399,6 +400,14 @@ target_sources_grouped( # xrLoadSurface.cpp #) +target_sources(xrEngine + PRIVATE + ClientServer.txt + "Effects description.txt" + features.txt + TODO.txt +) + target_include_directories(xrEngine PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" @@ -420,9 +429,10 @@ target_link_libraries(xrEngine xrScriptEngine xrNetServer xrImGui - ${OPENAL_LIBRARY} + OpenAL::OpenAL Ogg::Ogg Theora::Theora + SDL2::SDL2 ) target_compile_definitions(xrEngine @@ -440,6 +450,8 @@ target_precompile_headers(xrEngine stdafx.h ) -install(TARGETS xrEngine LIBRARY - DESTINATION "${CMAKE_INSTALL_LIBDIR}" -) +if (BUILD_SHARED_LIBS) + install(TARGETS xrEngine LIBRARY + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) +endif() diff --git a/src/xrEngine/CameraBase.cpp b/src/xrEngine/CameraBase.cpp index c0fc6a327fb..7727830b32e 100644 --- a/src/xrEngine/CameraBase.cpp +++ b/src/xrEngine/CameraBase.cpp @@ -7,29 +7,6 @@ #include "CameraBase.h" -CCameraBase::CCameraBase(IGameObject* p, u32 flags) -{ - m_Flags.assign(flags); - vPosition.set(0, 0, 0); - vDirection.set(0, 0, 1); - vNormal.set(0, 1, 0); - yaw = 0; - pitch = 0; - roll = 0; - lim_yaw.set(0.f, 0.f); - lim_pitch.set(0.f, 0.f); - lim_roll.set(0.f, 0.f); - bClampYaw = false; - bClampPitch = false; - bClampRoll = false; - SetParent(p); - f_fov = 90; - f_aspect = 1.f; - tag = 0; - m_bInputDisabled = false; //--#SM+#-- -} - -CCameraBase::~CCameraBase() {} void CCameraBase::Load(pcstr section) { rot_speed = pSettings->r_fvector3(section, "rot_speed"); @@ -46,48 +23,28 @@ void CCameraBase::Load(pcstr section) yaw = (lim_yaw[0] + lim_yaw[1]) * 0.5f; } -IC float AClamp(Fvector2& l, float v) { return (2 * v - l[0] - l[1]) / (l[1] - l[0]); } +ICF float AClamp(const Fvector2& l, float v) +{ + return (2 * v - l[0] - l[1]) / (l[1] - l[0]); +} + float CCameraBase::CheckLimYaw() { if (bClampYaw) - { return AClamp(lim_yaw, yaw); - } - else - return 0; + return 0; } float CCameraBase::CheckLimPitch() { if (bClampYaw) - { return AClamp(lim_pitch, pitch); - } - else - return 0; + return 0; } float CCameraBase::CheckLimRoll() { if (bClampYaw) - { return AClamp(lim_roll, roll); - } - else - return 0; -} -SCamEffectorInfo::SCamEffectorInfo() -{ - p.set(0, 0, 0); - d.set(0, 0, 1); - n.set(0, 1, 0); - - fFov = 90.0f; - fNear = VIEWPORT_NEAR; - fFar = 100.0f; - fAspect = 1.f; - offsetX = 0.f; - offsetY = 0.f; - dont_apply = false; - affected_on_hud = true; + return 0; } diff --git a/src/xrEngine/CameraBase.h b/src/xrEngine/CameraBase.h index a7587cd565f..14371ebfb6c 100644 --- a/src/xrEngine/CameraBase.h +++ b/src/xrEngine/CameraBase.h @@ -2,65 +2,76 @@ // ////////////////////////////////////////////////////////////////////// -#if !defined(AFX_CAMERABASE_H__B11F8AE1_1213_11D4_B4E3_4854E82A090D__INCLUDED_) -#define AFX_CAMERABASE_H__B11F8AE1_1213_11D4_B4E3_4854E82A090D__INCLUDED_ #pragma once #include "CameraDefs.h" #include "device.h" + // refs class IGameObject; +// XXX: refactor: +// 1. tag and style are used for the same purpose, +// 2. Convert remaining bools to flags class ENGINE_API CCameraBase { protected: IGameObject* parent; public: - bool bClampYaw, bClampPitch, bClampRoll; - float yaw, pitch, roll; - - enum + enum : u8 { - flRelativeLink = (1 << 0), - flPositionRigid = (1 << 1), - flDirectionRigid = (1 << 2), + flRelativeLink = 1 << 0, + flPositionRigid = 1 << 1, + flDirectionRigid = 1 << 2, }; - Flags32 m_Flags; + Flags8 m_Flags; + + u8 tag{}; + bool bClampYaw : 1 {}; + bool bClampPitch : 1 {}; + bool bClampRoll : 1 {}; + + float yaw{}, pitch{}, roll{}; - ECameraStyle style; - Fvector2 lim_yaw, lim_pitch, lim_roll; - Fvector rot_speed; + Fvector2 lim_yaw{}, lim_pitch{}, lim_roll{}; + Fvector rot_speed{}; - Fvector vPosition; - Fvector vDirection; - Fvector vNormal; - float f_fov; - float f_aspect; + Fvector vPosition { 0, 0, 0 }; + Fvector vDirection{ 0, 0, 1 }; + Fvector vNormal { 0, 1, 0 }; - bool m_bInputDisabled; //--#SM+#-- Флаг, запрещающий любые повороты камеры игроком [flag for disable all user input] + float f_fov { 90.0f }; + float f_aspect{ 1.0f }; - IC Fvector Position() const { return vPosition; } - IC Fvector Direction() const { return vDirection; } - IC Fvector Up() const { return vNormal; } - IC Fvector Right() const { return Fvector().crossproduct(vNormal, vDirection); } - IC float Fov() const { return f_fov; } - IC float Aspect() const { return f_aspect; } - int tag; + Fvector Position() const { return vPosition; } + Fvector Direction() const { return vDirection; } + Fvector Up() const { return vNormal; } + Fvector Right() const { return Fvector().crossproduct(vNormal, vDirection); } + float Fov() const { return f_fov; } + float Aspect() const { return f_aspect; } public: - CCameraBase(IGameObject* p, u32 flags); - virtual ~CCameraBase(); + CCameraBase(IGameObject* p, u8 flags) + : parent(p), m_Flags{ flags } + { + VERIFY(p); + } + + virtual ~CCameraBase() = 0; + virtual void Load(pcstr section); + void SetParent(IGameObject* p) { parent = p; VERIFY(p); } + virtual void OnActivate(CCameraBase* old_cam) { ; } virtual void OnDeactivate() { ; } - virtual void Move(int cmd, float val = 0, float factor = 1.0f) { ; } - virtual void Update(Fvector& point, Fvector& noise_angle) { ; } + virtual void Move(int cmd, float val = 0, float factor = 1.0f) {} + virtual void Update(const Fvector& point, Fvector& noise_angle) {} virtual void Get(Fvector& P, Fvector& D, Fvector& N) { P.set(vPosition); @@ -80,17 +91,17 @@ class ENGINE_API CCameraBase roll = R; } - virtual float GetWorldYaw() { return 0; }; - virtual float GetWorldPitch() { return 0; }; + virtual float GetWorldYaw() { return 0; } + virtual float GetWorldPitch() { return 0; } virtual float CheckLimYaw(); virtual float CheckLimPitch(); virtual float CheckLimRoll(); private: //--#SM+#-- - float saved_yaw, saved_pitch, saved_roll; - Fvector vSavedPosition; - Fvector vSavedDirection; - Fvector vSavedNormal; + float saved_yaw{}, saved_pitch{}, saved_roll{}; + Fvector vSavedPosition{}; + Fvector vSavedDirection{}; + Fvector vSavedNormal{}; public: //--#SM+#-- virtual void SaveCamVec() @@ -114,6 +125,8 @@ class ENGINE_API CCameraBase virtual IGameObject* GetOwner() { return parent; } }; +inline CCameraBase::~CCameraBase() = default; + template IC void viewport_size(float _viewport_near, const T& cam_info, float& h_w, float& h_h) { @@ -123,5 +136,3 @@ IC void viewport_size(float _viewport_near, const T& cam_info, float& h_w, float VERIFY(aspect > EPS); h_w = h_h / aspect; } - -#endif // !defined(AFX_CAMERABASE_H__B11F8AE1_1213_11D4_B4E3_4854E82A090D__INCLUDED_) diff --git a/src/xrEngine/CameraDefs.h b/src/xrEngine/CameraDefs.h index 75b4e3edfc9..01cffbb2067 100644 --- a/src/xrEngine/CameraDefs.h +++ b/src/xrEngine/CameraDefs.h @@ -1,57 +1,33 @@ #pragma once -#ifndef CAMERA_DEFS_H_INCLUDED -#define CAMERA_DEFS_H_INCLUDED #include "xrCore/fastdelegate.h" #include "xrCore/_vector3d.h" -struct ENGINE_API SBaseEffector +#include "device.h" + +struct SBaseEffector { - typedef fastdelegate::FastDelegate0<> CB_ON_B_REMOVE; + using CB_ON_B_REMOVE = fastdelegate::FastDelegate0<>; CB_ON_B_REMOVE m_on_b_remove_callback; - virtual ~SBaseEffector() {} + virtual ~SBaseEffector() = 0; }; -struct ENGINE_API SCamEffectorInfo -{ - Fvector p; - Fvector d; - Fvector n; - Fvector r; - float fFov; - float fNear; - float fFar; - float fAspect; - float offsetX; // Required for Nvidia Ansel - float offsetY; // Required for Nvidia Ansel - bool dont_apply; - bool affected_on_hud; - SCamEffectorInfo(); - SCamEffectorInfo& operator=(const SCamEffectorInfo& other) - { - p = other.p; - d = other.d; - n = other.n; - r = other.r; - fFov = other.fFov; - fNear = other.fNear; - fFar = other.fFar; - fAspect = other.fAspect; - offsetX = other.offsetX; - offsetY = other.offsetY; - dont_apply = other.dont_apply; - affected_on_hud = other.affected_on_hud; - return *this; - } -}; +inline SBaseEffector::~SBaseEffector() = default; -enum ECameraStyle : u32 +struct SCamEffectorInfo { - csCamDebug, - csFirstEye, - csLookAt, - csMax, - csFixed, + Fvector p{ 0, 0, 0 }; + Fvector d{ 0, 0, 1 }; + Fvector n{ 0, 1, 0 }; + Fvector r{}; + float fFov{ 90.0f }; + float fNear{ VIEWPORT_NEAR }; + float fFar{ 100.0f }; + float fAspect{ 1.f }; + float offsetX{}; // Required for Nvidia Ansel + float offsetY{}; // Required for Nvidia Ansel + bool dont_apply{}; + bool affected_on_hud{ true }; }; enum ECamEffectorType @@ -70,5 +46,3 @@ enum EEffectorPPType class ENGINE_API CCameraBase; class ENGINE_API CEffectorCam; class ENGINE_API CEffectorPP; - -#endif diff --git a/src/xrEngine/Device_imgui.cpp b/src/xrEngine/Device_imgui.cpp index 79ce68144aa..d4ad7842c55 100644 --- a/src/xrEngine/Device_imgui.cpp +++ b/src/xrEngine/Device_imgui.cpp @@ -13,6 +13,8 @@ void CRenderDevice::InitializeImGui() ZoneScoped; + IMGUI_CHECKVERSION(); + ImGui::SetAllocatorFunctions( [](size_t size, void* /*user_data*/) { @@ -43,6 +45,17 @@ void CRenderDevice::InitializeImGui() io.BackendPlatformName = "OpenXRay"; + io.ConfigDebugIsDebuggerPresent = xrDebug::DebuggerIsPresent(); +#ifdef DEBUG + io.ConfigErrorRecoveryEnableAssert = true; + io.ConfigErrorRecoveryEnableTooltip = true; + io.ConfigDebugHighlightIdConflicts = true; +#else + io.ConfigErrorRecoveryEnableAssert = false; + io.ConfigErrorRecoveryEnableTooltip = false; + io.ConfigDebugHighlightIdConflicts = false; +#endif + // Register platform interface (will be coupled with a renderer interface) ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO(); @@ -69,12 +82,12 @@ void CRenderDevice::InitializeImGui() { if (data->WantVisible) { - /*const*/ SDL_Rect r // this is not const because older versions of SDL accept non-const rect + const SDL_Rect r { - /*.x =*/ (int)(data->InputPos.x - viewport->Pos.x), - /*.y =*/ (int)(data->InputPos.y - viewport->Pos.y + data->InputLineHeight), - /*.w =*/ 1, - /*.h =*/ (int)data->InputLineHeight, + .x = (int)(data->InputPos.x - viewport->Pos.x), + .y = (int)(data->InputPos.y - viewport->Pos.y + data->InputLineHeight), + .w = 1, + .h = (int)data->InputLineHeight, }; SDL_SetTextInputRect(&r); } diff --git a/src/xrEngine/EngineAPI.cpp b/src/xrEngine/EngineAPI.cpp index 31b00067dc4..ba885f3bf8c 100644 --- a/src/xrEngine/EngineAPI.cpp +++ b/src/xrEngine/EngineAPI.cpp @@ -11,6 +11,7 @@ #include "xrCore/xr_token.h" #include "xrScriptEngine/ScriptExporter.hpp" +#include "xrScriptEngine/script_space.hpp" extern xr_vector VidQualityToken; @@ -173,11 +174,18 @@ void CEngineAPI::CreateRendererList(const std::array& module modes.emplace_back(nullptr, -1); } -SCRIPT_EXPORT(CheckRendererSupport, (), +struct CEngineAPIExport +{ + // Not in CEngineAPI directly due to linking problems with xrCDB + DECLARE_SCRIPT_REGISTER_FUNCTION(); +}; + +void CEngineAPIExport::script_register(lua_State* luaState) { using namespace luabind; module(luaState) [ + def("is_enough_address_space_available", &is_enough_address_space_available), def("xrRender_test_r2_hw", +[](){ return true; }) ]; -}); +} diff --git a/src/xrEngine/EngineAPI.h b/src/xrEngine/EngineAPI.h index a53d9a95175..e8da27c8e57 100644 --- a/src/xrEngine/EngineAPI.h +++ b/src/xrEngine/EngineAPI.h @@ -7,8 +7,8 @@ #include -#include "xrEngine/Engine.h" #include "xrCore/clsid.h" +#include "xrEngine/Engine.h" class IGame_Persistent; diff --git a/src/xrEngine/Environment.cpp b/src/xrEngine/Environment.cpp index 70951527604..a83aa8c0088 100644 --- a/src/xrEngine/Environment.cpp +++ b/src/xrEngine/Environment.cpp @@ -179,7 +179,7 @@ void CEnvironment::SetWeather(shared_str name, bool forced) Msg("! Invalid weather name: %s", name.c_str()); return; } - R_ASSERT3(it != WeatherCycles.end(), "Invalid weather name.", *name); + R_ASSERT3(it != WeatherCycles.end(), "Invalid weather name.", name.c_str()); CurrentCycleName = it->first; if (forced) { @@ -196,7 +196,7 @@ void CEnvironment::SetWeather(shared_str name, bool forced) SelectEnvs(fGameTime); } #ifdef WEATHER_LOGGING - Msg("Starting Cycle: %s [%s]", *name, forced ? "forced" : "deferred"); + Msg("Starting Cycle: %s [%s]", name.c_str(), forced ? "forced" : "deferred"); #endif } else @@ -214,7 +214,7 @@ bool CEnvironment::SetWeatherFX(shared_str name) if (name.size()) { auto it = WeatherFXs.find(name); - R_ASSERT3(it != WeatherFXs.end(), "Invalid weather effect name.", *name); + R_ASSERT3(it != WeatherFXs.end(), "Invalid weather effect name.", name.c_str()); EnvVec* PrevWeather = CurrentWeather; VERIFY(PrevWeather); CurrentWeather = &it->second; @@ -264,7 +264,7 @@ bool CEnvironment::SetWeatherFX(shared_str name) Current[0] = C0; Current[1] = C1; #ifdef WEATHER_LOGGING - Msg("Starting WFX: '%s' - %3.2f sec", *name, wfx_time); + Msg("Starting WFX: '%s' - %3.2f sec", name.c_str(), wfx_time); // for (auto l_it=CurrentWeather->begin(); l_it!=CurrentWeather->end(); l_it++) // Msg (". Env: '%s' Tm: %3.2f",*(*l_it)->m_identifier.c_str(),(*l_it)->exec_time); #endif diff --git a/src/xrEngine/FDemoPlay.cpp b/src/xrEngine/FDemoPlay.cpp index 3dc0800bb83..306719def31 100644 --- a/src/xrEngine/FDemoPlay.cpp +++ b/src/xrEngine/FDemoPlay.cpp @@ -191,10 +191,7 @@ void CDemoPlay::stat_Stop() } } -#define FIX(a) \ - while (a >= m_count) \ - a -= m_count -void spline1(float t, Fvector* p, Fvector* ret) +static void spline1(float t, Fvector* p, Fvector* ret) { float t2 = t * t; float t3 = t2 * t; @@ -275,14 +272,23 @@ bool CDemoPlay::ProcessCam(SCamEffectorInfo& info) // stat_Start (); } + const auto clamp_by_max = [this](int& f) + { + while (f >= m_count) + f -= m_count; + }; + int f1 = frame; - FIX(f1); + clamp_by_max(f1); + int f2 = f1 + 1; - FIX(f2); + clamp_by_max(f2); + int f3 = f2 + 1; - FIX(f3); + clamp_by_max(f3); + int f4 = f3 + 1; - FIX(f4); + clamp_by_max(f4); Fmatrix *m1, *m2, *m3, *m4; Fvector v[4]; diff --git a/src/xrEngine/FDemoRecord.cpp b/src/xrEngine/FDemoRecord.cpp index a1c6b358cfd..9c8a2ef5dc4 100644 --- a/src/xrEngine/FDemoRecord.cpp +++ b/src/xrEngine/FDemoRecord.cpp @@ -257,9 +257,9 @@ void CDemoRecord::MakeLevelMapProcess() string_path tmp; if (m_iLMScreenshotFragment == -1) - xr_sprintf(tmp, sizeof(tmp), "map_%s", *g_pGameLevel->name()); + xr_sprintf(tmp, sizeof(tmp), "map_%s", g_pGameLevel->name().c_str()); else - xr_sprintf(tmp, sizeof(tmp), "map_%s#%d", *g_pGameLevel->name(), m_iLMScreenshotFragment); + xr_sprintf(tmp, sizeof(tmp), "map_%s#%d", g_pGameLevel->name().c_str(), m_iLMScreenshotFragment); if (m_iLMScreenshotFragment != -1) { diff --git a/src/xrEngine/IInputReceiver.h b/src/xrEngine/IInputReceiver.h index 51e22787eef..098a24f82d9 100644 --- a/src/xrEngine/IInputReceiver.h +++ b/src/xrEngine/IInputReceiver.h @@ -3,16 +3,12 @@ ////////////////////////////////////////////////////////////////////// #pragma once -#ifndef IINPUTRECEIVERH -#define IINPUTRECEIVERH + #include "xrCore/_flags.h" -#include "xrEngine/xr_level_controller.h" -// fwd. decl. -template -struct _vector2; -using Fvector2 = _vector2; -using Ivector2 = _vector2; +// despite being unused in this file, it's almost always used in IR_* functions +// so it's logically correct to include it +#include "xr_level_controller.h" class ENGINE_API IInputReceiver { @@ -67,5 +63,3 @@ enum EControllerFlags ControllerInvertY, ControllerEnableSensors, }; - -#endif diff --git a/src/xrEngine/IRenderable.cpp b/src/xrEngine/IRenderable.cpp index 3df93bc4ae1..b3ea72a65c7 100644 --- a/src/xrEngine/IRenderable.cpp +++ b/src/xrEngine/IRenderable.cpp @@ -1,7 +1,10 @@ #include "stdafx.h" -#include "xrCDB/ISpatial.h" + #include "IRenderable.h" -// XXX: rename this file to RenderableBase.cpp +#include "Render.h" + +#include "xrCDB/ISpatial.h" + RenderableBase::RenderableBase() { renderable.xform.identity(); diff --git a/src/xrEngine/IRenderable.h b/src/xrEngine/IRenderable.h index 772f04aa76e..aadf0803e46 100644 --- a/src/xrEngine/IRenderable.h +++ b/src/xrEngine/IRenderable.h @@ -1,7 +1,7 @@ -#ifndef IRENDERABLE_H_INCLUDED -#define IRENDERABLE_H_INCLUDED +#pragma once -#include "Render.h" +class IRenderVisual; +class IRender_ObjectSpecific; ////////////////////////////////////////////////////////////////////////// // definition ("Renderable") @@ -52,5 +52,3 @@ class ENGINE_API /*XR_NOVTABLE*/ RenderableBase : public virtual IRenderable bool renderable_HUD() override { return renderable.hud; } void renderable_HUD(bool value) override { renderable.hud = value; } }; - -#endif // IRENDERABLE_H_INCLUDED diff --git a/src/xrEngine/ISheduled.cpp b/src/xrEngine/ISheduled.cpp index 5f50a1989c5..67f1c088b2d 100644 --- a/src/xrEngine/ISheduled.cpp +++ b/src/xrEngine/ISheduled.cpp @@ -16,7 +16,7 @@ ScheduledBase::ScheduledBase() ScheduledBase::~ScheduledBase() { #ifndef MASTER_GOLD - VERIFY2(!Engine.Sheduler.Registered(this), make_string("0x%08x : %s", this, *shedule_Name())); + VERIFY2(!Engine.Sheduler.Registered(this), make_string("0x%08x : %s", this, shedule_Name().c_str())); #endif // XXX: WTF??? diff --git a/src/xrEngine/LightAnimLibrary.cpp b/src/xrEngine/LightAnimLibrary.cpp index 27ba559dd2e..9dc1d1ed4a0 100644 --- a/src/xrEngine/LightAnimLibrary.cpp +++ b/src/xrEngine/LightAnimLibrary.cpp @@ -3,6 +3,10 @@ #pragma hdrstop #include "LightAnimLibrary.h" + +#include "xrScriptEngine/ScriptExporter.hpp" +#include "xrScriptEngine/script_space.hpp" + //--------------------------------------------------------------------------- #define LANIM_VERSION 0x0001 //--------------------------------------------------------------------------- @@ -339,3 +343,50 @@ void ELightAnimLibrary::RenameObject(pcstr nm0, pcstr nm1, EItemType type) } //--------------------------------------------------------------------------- #endif + +struct lanim_wrapper +{ + CLAItem* item; + +public: + lanim_wrapper(pcstr name) + { + load(name); + } + + void load(pcstr name) + { + item = LALib.FindItem(name); + R_ASSERT3(item, "Can't find color anim:", name); + } + + u32 length() const + { + VERIFY(item); + return item->Length_ms(); + } + + Fcolor calculate(float T) const + { + int frame; + VERIFY(item); + return Fcolor(item->CalculateRGB(T, frame)); + } + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); +}; + +void lanim_wrapper::script_register(lua_State* luaState) +{ + using namespace luabind; + + module(luaState) + [ + class_("color_animator") + .def(constructor()) + .def("load", &lanim_wrapper::load) + .def("calculate", &lanim_wrapper::calculate) + .def("length", &lanim_wrapper::length) + ]; +} diff --git a/src/xrEngine/ObjectAnimator.h b/src/xrEngine/ObjectAnimator.h index bbc042f52a8..94ca99372d5 100644 --- a/src/xrEngine/ObjectAnimator.h +++ b/src/xrEngine/ObjectAnimator.h @@ -30,7 +30,7 @@ class ENGINE_API CObjectAnimator void Clear(); void Load(pcstr name); - IC pcstr Name() const { return *m_Name; } + pcstr Name() const { return m_Name.c_str(); } float& Speed() { return m_Speed; } COMotion* Play(bool bLoop, pcstr name = 0); void Pause(bool val) { return m_MParam.Pause(val); } diff --git a/src/xrEngine/Render.h b/src/xrEngine/Render.h index afda4821afa..6418fd43def 100644 --- a/src/xrEngine/Render.h +++ b/src/xrEngine/Render.h @@ -115,6 +115,12 @@ class ENGINE_API IRender_ObjectSpecific virtual ~IRender_ObjectSpecific(){}; }; +struct xrImTextureData +{ + ImTextureID texture{}; + Fvector2 size{}; +}; + enum class DeviceState { Normal = 0, @@ -282,6 +288,8 @@ class ENGINE_API IRender // virtual ref_shader getShader (int id) = 0; virtual IRenderVisual* getVisual(int id) = 0; + virtual xrImTextureData GetImGuiTextureId(pcstr texture_name) = 0; + // Main virtual void add_Visual(u32 context_id, IRenderable* root, IRenderVisual* V, Fmatrix& m) = 0; // add visual leaf (no culling performed at all) // virtual void add_StaticWallmark (ref_shader& S, const Fvector& P, float s, CDB::TRI* T, Fvector* V)=0; diff --git a/src/xrEngine/StringTable/StringTable.cpp b/src/xrEngine/StringTable/StringTable.cpp index 44139a36ccf..117b8622281 100644 --- a/src/xrEngine/StringTable/StringTable.cpp +++ b/src/xrEngine/StringTable/StringTable.cpp @@ -71,6 +71,13 @@ void CStringTable::Init() Load(fn); } + if (!translate("st_currency", pData->m_sCurrency) && + !translate("ui_st_money_descr", pData->m_sCurrency) && // OGSR + !translate("ui_st_money_regional", pData->m_sCurrency)) // xp-dev + { + pData->m_sCurrency = pSettingsOpenXRay->read_if_exists("gameplay", "currency", "RU"); + } + #ifndef MASTER_GOLD Msg("StringTable: loaded %d files", fset.size()); #endif @@ -195,6 +202,11 @@ shared_str CStringTable::GetCurrentFontPrefix() const return pData ? pData->m_fontPrefix : nullptr; } +shared_str CStringTable::GetCurrency() const +{ + return pData ? pData->m_sCurrency : "RU"; +} + xr_token* CStringTable::GetLanguagesToken() const { return languagesToken.data(); } void CStringTable::Load(LPCSTR xml_file_full) diff --git a/src/xrEngine/StringTable/StringTable.h b/src/xrEngine/StringTable/StringTable.h index 84a067fe73f..5eda57009a7 100644 --- a/src/xrEngine/StringTable/StringTable.h +++ b/src/xrEngine/StringTable/StringTable.h @@ -19,6 +19,7 @@ struct STRING_TABLE_DATA { shared_str m_fontPrefix; shared_str m_sLanguage; + shared_str m_sCurrency; STRING_TABLE_MAP m_StringTable; }; @@ -37,7 +38,9 @@ class ENGINE_API CStringTable final shared_str GetCurrentLanguage() const; shared_str GetCurrentFontPrefix() const; + shared_str GetCurrency() const; xr_token* GetLanguagesToken() const; + static u32 LanguageID; static string32 LanguageIDInLTX; diff --git a/src/xrEngine/XR_IOConsole.h b/src/xrEngine/XR_IOConsole.h index 373bcb08c80..69f44fa4e83 100644 --- a/src/xrEngine/XR_IOConsole.h +++ b/src/xrEngine/XR_IOConsole.h @@ -193,6 +193,8 @@ class ENGINE_API CConsole : void update_tips(); void select_for_filter(pcstr filter_str, const vecTips& in_v, vecTipsEx& out_v); +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; // class CConsole ENGINE_API extern CConsole* Console; diff --git a/src/xrEngine/XR_IOConsole_script.cpp b/src/xrEngine/XR_IOConsole_script.cpp new file mode 100644 index 00000000000..9302f696b71 --- /dev/null +++ b/src/xrEngine/XR_IOConsole_script.cpp @@ -0,0 +1,53 @@ +#include "stdafx.h" + +#include "XR_IOConsole.h" +#include "xr_ioc_cmd.h" + +#include "xrScriptEngine/script_space.hpp" + +void CConsole::script_register(lua_State* luaState) +{ + using namespace luabind; + + module(luaState) + [ + def("get_console", +[]() + { + return Console; + }), + + class_("CConsole") + .def("execute", &CConsole::Execute) + .def("execute_script", &CConsole::ExecuteScript) + .def("show", &CConsole::Show) + .def("hide", &CConsole::Hide) + + .def("get_string", &CConsole::GetString) + .def("get_integer", +[](const CConsole* self, pcstr cmd) + { + int min = 0, max = 0; + const int val = self->GetInteger(cmd, min, max); + return val; + }) + .def("get_bool", +[](const CConsole* self, pcstr cmd) + { + return self->GetBool(cmd); + }) + .def("get_float", +[](const CConsole* self, pcstr cmd) + { + float min = 0.0f, max = 0.0f; + const float val = self->GetFloat(cmd, min, max); + return val; + }) + .def("get_token", &CConsole::GetToken) + .def("execute_deferred", +[](CConsole*, pcstr string_to_execute) + { + Engine.Event.Defer("KERNEL:console", size_t(xr_strdup(string_to_execute))); + }), + + def("renderer_allow_override", +[]() + { + return renderer_allow_override; + }) + ]; +} diff --git a/src/xrEngine/device.cpp b/src/xrEngine/device.cpp index a08a2f5ddc5..01a427c0d6f 100644 --- a/src/xrEngine/device.cpp +++ b/src/xrEngine/device.cpp @@ -4,7 +4,6 @@ #include "xrCore/FS_impl.h" #include "xrCore/Threading/TaskManager.hpp" -#include "xrScriptEngine/ScriptExporter.hpp" #include "XR_IOConsole.h" #include "xr_input.h" @@ -12,6 +11,8 @@ #include "IGame_Level.h" #include "IGame_Persistent.h" +#include "xrScriptEngine/script_space.hpp" + #include ENGINE_API CRenderDevice Device; @@ -609,21 +610,58 @@ void CRenderDevice::RemoveSeqFrame(pureFrame* f) seqFrame.Remove(f); } -CRenderDevice* get_device() { return &Device; } -u32 script_time_global() { return Device.dwTimeGlobal; } -u32 script_time_global_async() { return Device.TimerAsync_MMT(); } - -SCRIPT_EXPORT(Device, (), +void CRenderDevice::script_register(lua_State* luaState) { using namespace luabind; module(luaState) [ - def("time_global", &script_time_global), - def("time_global_async", &script_time_global_async), - def("device", &get_device), - def("is_enough_address_space_available", &is_enough_address_space_available) + class_("render_device") + .def_readonly("width", &CRenderDevice::dwWidth) + .def_readonly("height", &CRenderDevice::dwHeight) + .def_readonly("time_delta", &CRenderDevice::dwTimeDelta) + .def_readonly("f_time_delta", &CRenderDevice::fTimeDelta) + .def_readonly("cam_pos", &CRenderDevice::vCameraPosition) + .def_readonly("cam_dir", &CRenderDevice::vCameraDirection) + .def_readonly("cam_top", &CRenderDevice::vCameraTop) + .def_readonly("cam_right", &CRenderDevice::vCameraRight) + // .def_readonly("view", &CRenderDevice::mView) + // .def_readonly("projection", &CRenderDevice::mProject) + // .def_readonly("full_transform", &CRenderDevice::mFullTransform) + .def_readonly("fov", &CRenderDevice::fFOV) + .def_readonly("aspect_ratio", &CRenderDevice::fASPECT) + .def_readonly("precache_frame", &CRenderDevice::dwPrecacheFrame) + .def_readonly("frame", &CRenderDevice::dwFrame) + .def("time_global", +[](const CRenderDevice* self) + { + return (self->dwTimeGlobal); + }) + .def("is_paused", +[](CRenderDevice* device) + { + return device->Paused(); + }) + .def("pause", +[](CRenderDevice* device, bool b) + { + device->Pause(b, TRUE, FALSE, "set_device_paused_script"); + }), + + def("app_ready", +[]() + { + return g_pGamePersistent->IsLoaded(); + }), + def("device", +[]() + { + return &Device; + }), + def("time_global", +[]() + { + return Device.dwTimeGlobal; + }), + def("time_global_async", +[]() + { + return Device.TimerAsync_MMT(); + }) ]; -}); +}; void CLoadScreenRenderer::Start(bool b_user_input) { diff --git a/src/xrEngine/device.h b/src/xrEngine/device.h index 025a18cf0c7..718d1a2d139 100644 --- a/src/xrEngine/device.h +++ b/src/xrEngine/device.h @@ -15,20 +15,22 @@ #include "xrCore/fastdelegate.h" #include "xrCore/ModuleLookup.hpp" -#define VIEWPORT_NEAR 0.2f -#define HUD_VIEWPORT_NEAR 0.05f - #define DEVICE_RESET_PRECACHE_FRAME_COUNT 10 #include "editor_base.h" #include "Include/xrRender/FactoryPtr.h" #include "Render.h" +#include "xrScriptEngine/ScriptExporter.hpp" + #include // refs class Task; +constexpr float VIEWPORT_NEAR = 0.2f; +constexpr float HUD_VIEWPORT_NEAR = 0.05f; + class ENGINE_API CRenderDevice : public IWindowHandler { public: @@ -303,6 +305,9 @@ class ENGINE_API CRenderDevice : public IWindowHandler ImGuiContext* m_imgui_context{}; IImGuiRender* m_imgui_render{}; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; extern ENGINE_API CRenderDevice Device; diff --git a/src/xrEngine/editor_base.cpp b/src/xrEngine/editor_base.cpp index e063ece43fe..d8011ee3099 100644 --- a/src/xrEngine/editor_base.cpp +++ b/src/xrEngine/editor_base.cpp @@ -24,6 +24,8 @@ ImGuiWindowFlags ide_tool::get_default_window_flags() const void ide::RegisterTool(ide_tool* tool) { m_tools.emplace_back(tool); + // can't sort here, because the tool is constructing right now + m_tool_added = true; } void ide::UnregisterTool(const ide_tool* tool) @@ -104,6 +106,14 @@ void ide::ShowMain() #ifndef MASTER_GOLD if (ImGui::BeginMenu("Tools")) { + if (m_tool_added) + { + std::sort(m_tools.begin(), m_tools.end(), [](const ide_tool* left, const ide_tool* right) + { + return xr_strcmp(left->tool_name(), right->tool_name()) < 0; + }); + m_tool_added = false; + } for (const auto& tool : m_tools) { ImGui::MenuItem(tool->tool_name(), nullptr, &tool->get_open_state()); diff --git a/src/xrEngine/editor_base.h b/src/xrEngine/editor_base.h index 7009abf7a37..0b492d4b38e 100644 --- a/src/xrEngine/editor_base.h +++ b/src/xrEngine/editor_base.h @@ -111,6 +111,7 @@ class ENGINE_API ide final : private: visible_state m_state{}; + bool m_tool_added{}; struct ImGuiBackend { diff --git a/src/xrEngine/editor_base_input.cpp b/src/xrEngine/editor_base_input.cpp index 747808ba582..fe3fcc7103b 100644 --- a/src/xrEngine/editor_base_input.cpp +++ b/src/xrEngine/editor_base_input.cpp @@ -361,7 +361,7 @@ void ide::IR_OnKeyboardPress(int key) break; case kQUIT: - if (io.WantTextInput) + if (io.WantTextInput || Device.GetImGuiContext()->DebugItemPickerActive) break; // bypass to ImGui // First diff --git a/src/xrEngine/key_binding_registrator_script.cpp b/src/xrEngine/key_binding_registrator_script.cpp index 88910861f13..dde638ec05f 100644 --- a/src/xrEngine/key_binding_registrator_script.cpp +++ b/src/xrEngine/key_binding_registrator_script.cpp @@ -2,10 +2,9 @@ #include "xr_level_controller.h" -#include "xrScriptEngine/ScriptExporter.hpp" +#include "xrScriptEngine/script_space.hpp" -// clang-format off -SCRIPT_EXPORT(KeyBindings, (), +void key_binding_registrator::script_register(lua_State* luaState) { class EnumGameActionsContexts {}; class EnumGameActions {}; @@ -528,5 +527,4 @@ SCRIPT_EXPORT(KeyBindings, (), value("GAMEPAD_DPAD_TOUCHPAD", int(XR_CONTROLLER_BUTTON_TOUCHPAD)) ] ]; -}); -// clang-format on +} diff --git a/src/xrEngine/profiler.cpp b/src/xrEngine/profiler.cpp index fdcc8f91282..d7df194f301 100644 --- a/src/xrEngine/profiler.cpp +++ b/src/xrEngine/profiler.cpp @@ -166,7 +166,8 @@ void CProfiler::show_stats (IGameFont &font, bool show) m_section.Enter (); - if (!m_portions.empty()) { + if (!m_portions.empty()) + { std::sort(m_portions.begin(), m_portions.end(), [](const CProfileResultPortion& first, const CProfileResultPortion& second) { return xr_strcmp(first.m_timer_id, second.m_timer_id) < 0; @@ -193,16 +194,17 @@ void CProfiler::show_stats (IGameFont &font, bool show) m_section.Leave (); - if (!m_actual) { + if (!m_actual) + { u32 max_string_size = 0; TIMERS::iterator I = m_timers.begin(); TIMERS::iterator E = m_timers.end(); for ( ; I != E; ++I) - max_string_size = _max(max_string_size,compute_string_length(*(*I).first)); + max_string_size = _max(max_string_size,compute_string_length(I->first.c_str())); I = m_timers.begin(); for ( ; I != E; ++I) - convert_string (*(*I).first,(*I).second.m_name,max_string_size); + convert_string (I->first.c_str(), I->second.m_name, max_string_size); m_actual = true; } @@ -229,7 +231,7 @@ void CProfiler::show_stats (IGameFont &font, bool show) font.OutNext ( // "%s.. %8.3f %8.3f %8.3f %8.3f %8.3f %8d %12.3f", "%s%c%c %8.3f %8.3f %8.3f %6.1f %8d %12.3f", - *(*I).second.m_name, + I->second.m_name.c_str(), white_character, white_character, (*I).second.m_time, diff --git a/src/xrEngine/profiler.h b/src/xrEngine/profiler.h index d9dad8e7110..653ec73ccc6 100644 --- a/src/xrEngine/profiler.h +++ b/src/xrEngine/profiler.h @@ -61,7 +61,7 @@ class ENGINE_API CProfiler struct pred_rstr { bool operator()(const shared_str &lhs, const shared_str &rhs) const - { return xr_strcmp(*lhs, *rhs)<0; } + { return xr_strcmp(lhs.c_str(), rhs.c_str()) < 0; } }; protected: diff --git a/src/xrEngine/xrEngine.vcxproj b/src/xrEngine/xrEngine.vcxproj index 243a497bf85..f4ae2cb859a 100644 --- a/src/xrEngine/xrEngine.vcxproj +++ b/src/xrEngine/xrEngine.vcxproj @@ -27,6 +27,9 @@ libogg_static.lib;libtheora_static.lib;vfw32.lib;%(AdditionalDependencies) + + libogg_static.lib;libtheora_static.lib;vfw32.lib;%(AdditionalDependencies) + @@ -182,6 +185,7 @@ + @@ -238,11 +242,6 @@ - - - Document - - diff --git a/src/xrEngine/xrEngine.vcxproj.filters b/src/xrEngine/xrEngine.vcxproj.filters index b113dd11576..b328af2219c 100644 --- a/src/xrEngine/xrEngine.vcxproj.filters +++ b/src/xrEngine/xrEngine.vcxproj.filters @@ -614,6 +614,9 @@ Game API\Environment + + Engine\Console + @@ -624,9 +627,6 @@ - - - diff --git a/src/xrEngine/xr_collide_form.cpp b/src/xrEngine/xr_collide_form.cpp index 7aacab80a6d..49a0c4f810b 100644 --- a/src/xrEngine/xr_collide_form.cpp +++ b/src/xrEngine/xr_collide_form.cpp @@ -88,7 +88,7 @@ CCF_Skeleton::CCF_Skeleton(IGameObject* O) : ICollisionForm(O, cftObject) { // getVisData IRenderVisual* pVisual = O->Visual(); - VERIFY3(PKinematics(pVisual), "Can't create skeleton without Kinematics.", *O->cNameVisual()); + VERIFY3(PKinematics(pVisual), "Can't create skeleton without Kinematics.", O->cNameVisual().c_str()); // bv_box.set (K->vis.box); bv_box.set(pVisual->getVisData().box); bv_box.getsphere(bv_sphere.P, bv_sphere.R); diff --git a/src/xrEngine/xr_efflensflare.cpp b/src/xrEngine/xr_efflensflare.cpp index 8965340f832..cf418e4eb53 100644 --- a/src/xrEngine/xr_efflensflare.cpp +++ b/src/xrEngine/xr_efflensflare.cpp @@ -148,10 +148,10 @@ CLensFlareDescriptor::CLensFlareDescriptor(shared_str sect, CInifile const* pIni void CLensFlareDescriptor::OnDeviceCreate() { // shaders - m_Gradient.m_pRender->CreateShader(*m_Gradient.shader, *m_Gradient.texture); - m_Source.m_pRender->CreateShader(*m_Source.shader, *m_Source.texture); + m_Gradient.m_pRender->CreateShader(m_Gradient.shader.c_str(), m_Gradient.texture.c_str()); + m_Source.m_pRender->CreateShader(m_Source.shader.c_str(), m_Source.texture.c_str()); for (const auto& flare : m_Flares) - flare.m_pRender->CreateShader(*flare.shader, *flare.texture); + flare.m_pRender->CreateShader(flare.shader.c_str(), flare.texture.c_str()); } void CLensFlareDescriptor::OnDeviceDestroy() diff --git a/src/xrEngine/xr_input.cpp b/src/xrEngine/xr_input.cpp index 5fca97b24cf..b8caddd9ab1 100644 --- a/src/xrEngine/xr_input.cpp +++ b/src/xrEngine/xr_input.cpp @@ -6,7 +6,6 @@ #include "GameFont.h" #include "XR_IOConsole.h" #include "xrCore/Text/StringConversion.hpp" -#include "xrCore/xr_token.h" #include diff --git a/src/xrEngine/xr_input.h b/src/xrEngine/xr_input.h index 955b0cdb626..1f63228fd8d 100644 --- a/src/xrEngine/xr_input.h +++ b/src/xrEngine/xr_input.h @@ -4,6 +4,8 @@ #include +#include "xrCore/_vector2.h" + #if !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IOS) && !defined(__amigaos4__) # define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE 1 #else diff --git a/src/xrEngine/xr_level_controller.cpp b/src/xrEngine/xr_level_controller.cpp index 74f8979c2cd..f3f2444661d 100644 --- a/src/xrEngine/xr_level_controller.cpp +++ b/src/xrEngine/xr_level_controller.cpp @@ -1166,7 +1166,7 @@ void ConsoleBindCmds::save(IWriter* f) for (; it != m_bindConsoleCmds.end(); ++it) { pcstr keyname = DikToKeyname(it->first); - f->w_printf("bind_console %s %s\n", *it->second.cmd, keyname); + f->w_printf("bind_console %s %s\n", it->second.cmd.c_str(), keyname); } } diff --git a/src/xrEngine/xr_level_controller.h b/src/xrEngine/xr_level_controller.h index f50c79db9b2..0a8d977cb77 100644 --- a/src/xrEngine/xr_level_controller.h +++ b/src/xrEngine/xr_level_controller.h @@ -1,9 +1,14 @@ #pragma once -#include "xrCore/xrstring.h" + #include "xrCommon/xr_string.h" #include "xrCommon/xr_map.h" + +#include "xrCore/xrstring.h" + #include "xrEngine/xr_input.h" // Don't remove this include +#include "xrScriptEngine/ScriptExporter.hpp" + enum EGameActions : u32 { kLOOK_AROUND, // gamepad @@ -300,3 +305,8 @@ class ENGINE_API ConsoleBindCmds }; extern ENGINE_API ConsoleBindCmds g_consoleBindCmds; + +struct ENGINE_API key_binding_registrator +{ + DECLARE_SCRIPT_REGISTER_FUNCTION(); +}; diff --git a/src/xrEngine/xr_object.h b/src/xrEngine/xr_object.h index 578c9103a2d..77afeb74dfe 100644 --- a/src/xrEngine/xr_object.h +++ b/src/xrEngine/xr_object.h @@ -1,21 +1,24 @@ #pragma once +#include "xrCommon/misc_math_types.h" // SRotation + +#include "xrCore/FixedVector.h" + #include "xrCDB/ISpatial.h" #include "ISheduled.h" #include "IRenderable.h" #include "ICollidable.h" #include "EngineAPI.h" -#include "device.h" -#include "xrServerEntities/xrServer_Space.h" #include "xrGame/game_object_space.h" #include "xrServerEntities/alife_space.h" -#include "xrCommon/misc_math_types.h" // SRotation +#include "xrServerEntities/xrServer_Space.h" // fwd. decl. class IRender_Sector; class IRender_ObjectSpecific; +class IKinematics; class CCustomHUD; class NET_Packet; class CSE_Abstract; @@ -34,7 +37,6 @@ class CInventoryItem; class CEntity; class CEntityAlive; class CActor; -class CGameObject; // XXX: remove class CCustomZone; class CPhysicsShellHolder; class IInputReceiver; @@ -246,7 +248,6 @@ class XR_NOVTABLE IGameObject virtual CEntity* cast_entity() = 0; virtual CEntityAlive* cast_entity_alive() = 0; virtual CActor* cast_actor() = 0; - virtual CGameObject* cast_game_object() = 0; virtual CCustomZone* cast_custom_zone() = 0; virtual CPhysicsShellHolder* cast_physics_shell_holder() = 0; virtual IInputReceiver* cast_input_receiver() = 0; diff --git a/src/xrEngine/xr_object_list.cpp b/src/xrEngine/xr_object_list.cpp index 08edf2fce32..ff35516ff9f 100644 --- a/src/xrEngine/xr_object_list.cpp +++ b/src/xrEngine/xr_object_list.cpp @@ -143,7 +143,7 @@ void CObjectList::SingleUpdate(IGameObject* O) O->UpdateCL(); - VERIFY3(O->GetDbgUpdateFrame() == Device.dwFrame, "Broken sequence of calls to 'UpdateCL'", *O->cName()); + VERIFY3(O->GetDbgUpdateFrame() == Device.dwFrame, "Broken sequence of calls to 'UpdateCL'", O->cName().c_str()); #if 0 // ndef DEBUG __try { @@ -151,8 +151,8 @@ void CObjectList::SingleUpdate(IGameObject* O) if (O->H_Parent() && (O->H_Parent()->getDestroy() || O->H_Root()->getDestroy())) { // Push to destroy-queue if it isn't here already - Msg("! ERROR: incorrect destroy sequence for object[%d:%s], section[%s], parent[%d:%s]", O->ID(), *O->cName(), - *O->cNameSect(), O->H_Parent()->ID(), *O->H_Parent()->cName()); + Msg("! ERROR: incorrect destroy sequence for object[%d:%s], section[%s], parent[%d:%s]", O->ID(), O->cName().c_str(), + O->cNameSect().c_str(), O->H_Parent()->ID(), O->H_Parent()->cName().c_str()); } #if 0 // ndef DEBUG } @@ -160,7 +160,7 @@ void CObjectList::SingleUpdate(IGameObject* O) { IGameObject* parent_obj = O->H_Parent(); IGameObject* root_obj = O->H_Root(); - Msg ("! ERROR: going to crush: [%d:%s], section[%s], parent_obj_addr[0x%08x], root_obj_addr[0x%08x]",O->ID(),*O->cName(),*O->cNameSect(), *((u32*)&parent_obj), *((u32*)&root_obj)); + Msg ("! ERROR: going to crush: [%d:%s], section[%s], parent_obj_addr[0x%08x], root_obj_addr[0x%08x]",O->ID(),O->cName().c_str(),*O->cNameSect(), *((u32*)&parent_obj), *((u32*)&root_obj)); if (parent_obj) { __try @@ -335,7 +335,7 @@ void CObjectList::Update(bool bForce) // Msg ("Object [%x]", O); #ifdef DEBUG if (debug_destroy) - Msg("Destroying object[%x][%x] [%d][%s] frame[%d]", dynamic_cast(O), O, O->ID(), *O->cName(), + Msg("Destroying object[%x][%x] [%d][%s] frame[%d]", dynamic_cast(O), O, O->ID(), O->cName().c_str(), Device.dwFrame); #endif // DEBUG O->net_Destroy(); @@ -395,14 +395,14 @@ u32 CObjectList::net_Export(NET_Packet* _Packet, u32 start, u32 max_object_size) if (size >= 256) { xrDebug::Fatal(DEBUG_INFO, "Object [%s][%d] exceed network-data limit\n size=%d, Pend=%d, Pstart=%d", - *P->cName(), P->ID(), size, Packet.w_tell(), position); + P->cName().c_str(), P->ID(), size, Packet.w_tell(), position); } } #endif if (g_Dump_Export_Obj) { u32 size = u32(Packet.w_tell() - position) - sizeof(u8); - Msg("* %s : %d", *(P->cNameSect()), size); + Msg("* %s : %d", P->cNameSect().c_str(), size); } Packet.w_chunk_close8(position); // if (0==(--count)) @@ -437,7 +437,7 @@ void CObjectList::net_Import(NET_Packet* Packet) P->net_Import(*Packet); if (g_Dump_Import_Obj) - Msg("* %s : %d - %d", *(P->cNameSect()), size, Packet->r_tell() - rsize); + Msg("* %s : %d - %d", P->cNameSect().c_str(), size, Packet->r_tell() - rsize); } else Packet->r_advance(size); @@ -471,12 +471,12 @@ void CObjectList::Unload() while (objects_sleeping.size()) { IGameObject* O = objects_sleeping.back(); - Msg("! [%x] s[%4d]-[%s]-[%s]", O, O->ID(), *O->cNameSect(), *O->cName()); + Msg("! [%x] s[%4d]-[%s]-[%s]", O, O->ID(), O->cNameSect().c_str(), O->cName().c_str()); O->setDestroy(true); #ifdef DEBUG if (debug_destroy) - Msg("Destroying object [%d][%s]", O->ID(), *O->cName()); + Msg("Destroying object [%d][%s]", O->ID(), O->cName().c_str()); #endif O->net_Destroy(); Destroy(O); @@ -484,12 +484,12 @@ void CObjectList::Unload() while (objects_active.size()) { IGameObject* O = objects_active.back(); - Msg("! [%x] a[%4d]-[%s]-[%s]", O, O->ID(), *O->cNameSect(), *O->cName()); + Msg("! [%x] a[%4d]-[%s]-[%s]", O, O->ID(), O->cNameSect().c_str(), O->cName().c_str()); O->setDestroy(true); #ifdef DEBUG if (debug_destroy) - Msg("Destroying object [%d][%s]", O->ID(), *O->cName()); + Msg("Destroying object [%d][%s]", O->ID(), O->cName().c_str()); #endif O->net_Destroy(); Destroy(O); diff --git a/src/xrGame/AI_PhraseDialogManager.cpp b/src/xrGame/AI_PhraseDialogManager.cpp index b8d5e1e9600..ce975bde45e 100644 --- a/src/xrGame/AI_PhraseDialogManager.cpp +++ b/src/xrGame/AI_PhraseDialogManager.cpp @@ -77,8 +77,8 @@ void CAI_PhraseDialogManager::UpdateAvailableDialogs(CPhraseDialogManager* partn m_AvailableDialogs.clear(); m_CheckedDialogs.clear(); - if (*m_sStartDialog) - inherited::AddAvailableDialog(*m_sStartDialog, partner); + if (m_sStartDialog.c_str()) + inherited::AddAvailableDialog(m_sStartDialog.c_str(), partner); inherited::AddAvailableDialog("hello_dialog", partner); inherited::UpdateAvailableDialogs(partner); diff --git a/src/xrGame/Actor.h b/src/xrGame/Actor.h index a41e04022dc..46915170faa 100644 --- a/src/xrGame/Actor.h +++ b/src/xrGame/Actor.h @@ -358,7 +358,8 @@ class CActor : public CEntityAlive, CGameObject* ObjectWeLookingAt() { return m_pObjectWeLookingAt; } CInventoryOwner* PersonWeLookingAt() { return m_pPersonWeLookingAt; } - LPCSTR GetDefaultActionForObject() { return *m_sDefaultObjAction; } + pcstr GetDefaultActionForObject() const { return m_sDefaultObjAction.c_str(); } + protected: CGameObject* m_pUsableObject; // Person we're looking at @@ -810,6 +811,9 @@ class CActor : public CEntityAlive, { mstate_wishful = state; } + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; extern bool isActorAccelerated(u32 mstate, bool ZoomMode); diff --git a/src/xrGame/ActorAnimation.cpp b/src/xrGame/ActorAnimation.cpp index 8403dd2ca0e..c3ca7c5099a 100644 --- a/src/xrGame/ActorAnimation.cpp +++ b/src/xrGame/ActorAnimation.cpp @@ -447,7 +447,7 @@ void CActor::g_SetAnimation(u32 mstate_rl) M_torso = TW->drop; if (!M_torso) { - Msg("! drop animation for %s", *(H->object().cName())); + Msg("! drop animation for %s", H->object().cName().c_str()); M_torso = ST->m_torso_idle; }; m_bAnimTorsoPlayed = TRUE; diff --git a/src/xrGame/ActorCondition.h b/src/xrGame/ActorCondition.h index 5d9f71f540f..4e1503fa2bd 100644 --- a/src/xrGame/ActorCondition.h +++ b/src/xrGame/ActorCondition.h @@ -174,6 +174,9 @@ class CActorCondition : public CEntityCondition // typedef xr_vector::iterator BOOSTS_VECTOR_ITER; // BOOSTS_VECTOR m_vecBoosts; ref_sound m_use_sound; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; class CActorDeathEffector diff --git a/src/xrGame/EntityCondition_script.cpp b/src/xrGame/ActorCondition_script.cpp similarity index 96% rename from src/xrGame/EntityCondition_script.cpp rename to src/xrGame/ActorCondition_script.cpp index f4dd97201d4..cd9b6e475d6 100644 --- a/src/xrGame/EntityCondition_script.cpp +++ b/src/xrGame/ActorCondition_script.cpp @@ -1,14 +1,33 @@ #include "pch_script.h" + #include "ActorCondition.h" #include "Wound.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CEntityCondition, (), +void CActorCondition::script_register(lua_State* luaState) { using namespace luabind; module(luaState) [ + class_("SBooster") + .def(constructor<>()) + .def_readwrite("fBoostTime", &SBooster::fBoostTime) + .def_readwrite("fBoostValue", &SBooster::fBoostValue) + .def_readwrite("m_type", &SBooster::m_type), + + class_("CWound") + .def("TypeSize", &CWound::TypeSize) + .def("BloodSize", &CWound::BloodSize) + .def("AddHit", &CWound::AddHit) + .def("Incarnation", &CWound::Incarnation) + .def("TotalSize", &CWound::TotalSize) + .def("SetBoneNum", &CWound::SetBoneNum) + .def("GetBoneNum", &CWound::GetBoneNum) + .def("GetParticleBoneNum", &CWound::GetParticleBoneNum) + .def("SetParticleBoneNum", &CWound::SetParticleBoneNum) + .def("SetDestroy", &CWound::SetDestroy) + .def("GetDestroy", &CWound::GetDestroy), + class_("CEntityCondition") .def("AddWound", &CEntityCondition::AddWound) .def("ClearWounds", &CEntityCondition::ClearWounds) @@ -51,33 +70,8 @@ SCRIPT_EXPORT(CEntityCondition, (), value("eBoostStrikeImmunity", int(EBoostParams::eBoostStrikeImmunity)), value("eBoostFireWoundImmunity", int(EBoostParams::eBoostFireWoundImmunity)), value("eBoostWoundImmunity", int(EBoostParams::eBoostWoundImmunity)) - ] - ]; -}); + ], -SCRIPT_EXPORT(CActorCondition, (CEntityCondition), -{ - using namespace luabind; - - module(luaState) - [ - class_("SBooster") - .def(constructor<>()) - .def_readwrite("fBoostTime", &SBooster::fBoostTime) - .def_readwrite("fBoostValue", &SBooster::fBoostValue) - .def_readwrite("m_type", &SBooster::m_type), - class_("CWound") - .def("TypeSize", &CWound::TypeSize) - .def("BloodSize", &CWound::BloodSize) - .def("AddHit", &CWound::AddHit) - .def("Incarnation", &CWound::Incarnation) - .def("TotalSize", &CWound::TotalSize) - .def("SetBoneNum", &CWound::SetBoneNum) - .def("GetBoneNum", &CWound::GetBoneNum) - .def("GetParticleBoneNum", &CWound::GetParticleBoneNum) - .def("SetParticleBoneNum", &CWound::SetParticleBoneNum) - .def("SetDestroy", &CWound::SetDestroy) - .def("GetDestroy", &CWound::GetDestroy), class_("CActorCondition") .def("ClearAllBoosters", &CActorCondition::ClearAllBoosters) .def("ApplyBooster", &CActorCondition::ApplyBooster_script) @@ -107,4 +101,4 @@ SCRIPT_EXPORT(CActorCondition, (CEntityCondition), .def("IsCantSprint", &CActorCondition::IsCantSprint) .def_readwrite("m_MaxWalkWeight", &CActorCondition::m_MaxWalkWeight) ]; -}); +} diff --git a/src/xrGame/ActorHelmet.cpp b/src/xrGame/ActorHelmet.cpp index 3b6e4a5d435..79dfbfe5320 100644 --- a/src/xrGame/ActorHelmet.cpp +++ b/src/xrGame/ActorHelmet.cpp @@ -29,11 +29,24 @@ void CHelmet::Load(LPCSTR section) m_HitTypeProtection[ALife::eHitTypeTelepatic] = pSettings->r_float(section, "telepatic_protection"); m_HitTypeProtection[ALife::eHitTypeChemicalBurn] = pSettings->r_float(section, "chemical_burn_protection"); m_HitTypeProtection[ALife::eHitTypeExplosion] = pSettings->r_float(section, "explosion_protection"); - m_HitTypeProtection[ALife::eHitTypeFireWound] = 0.0f; // pSettings->r_float(section,"fire_wound_protection"); + m_HitTypeProtection[ALife::eHitTypeFireWound] = pSettings->read_if_exists(section, "fire_wound_protection", 0.0f); m_HitTypeProtection[ALife::eHitTypePhysicStrike] = pSettings->read_if_exists( section, "physic_strike_protection", m_HitTypeProtection[ALife::eHitTypeStrike]); m_HitTypeProtection[ALife::eHitTypeLightBurn] = m_HitTypeProtection[ALife::eHitTypeBurn]; - m_boneProtection->m_fHitFracActor = pSettings->r_float(section, "hit_fraction_actor"); + + if (pSettings->line_exist(section, "hit_fraction_actor")) + { + m_boneProtection->m_fHitFrac = pSettings->r_float(section, "hit_fraction_actor"); + + // Since hit_fraction_actor exists both in CS and COP, but fire_wound_protection was removed in COP, + // We can use this hacky solution to determine which damage formula to use. + // It not robust for mods, because they can have fire_wound_protection in configs, despite that + // original COP engine doesn't read it. + if (pSettings->line_exist(section, "fire_wound_protection")) + m_boneProtection->m_hitFracType = SBoneProtections::HitFractionActorCS; + else + m_boneProtection->m_hitFracType = SBoneProtections::HitFractionActorCOP; + } if (pSettings->line_exist(section, "nightvision_sect")) m_NightVisionSect = pSettings->r_string(section, "nightvision_sect"); @@ -130,19 +143,32 @@ void CHelmet::Hit(float hit_power, ALife::EHitType hit_type) ChangeCondition(-hit_power); } -float CHelmet::GetDefHitTypeProtection(ALife::EHitType hit_type) +float CHelmet::GetDefHitTypeProtection(ALife::EHitType hit_type) const +{ + const float base = m_HitTypeProtection[hit_type] * GetCondition(); + + if (m_boneProtection->m_hitFracType == SBoneProtections::HitFraction) + return 1.0f - base; // SOC + + return base; // CS/COP +} + +float CHelmet::GetHitTypeProtection(ALife::EHitType hit_type, s16 element) const { - return m_HitTypeProtection[hit_type] * GetCondition(); + const float base = m_HitTypeProtection[hit_type] * GetCondition(); + const float bone = m_boneProtection->getBoneProtection(element); + + if (m_boneProtection->m_hitFracType == SBoneProtections::HitFraction) + return 1.0f - base * bone; // SOC + + return base * bone; // CS/COP } -float CHelmet::GetHitTypeProtection(ALife::EHitType hit_type, s16 element) +float CHelmet::GetBoneArmor(s16 element) const { - float fBase = m_HitTypeProtection[hit_type] * GetCondition(); - float bone = m_boneProtection->getBoneProtection(element); - return fBase * bone; + return m_boneProtection->getBoneArmor(element); } -float CHelmet::GetBoneArmor(s16 element) { return m_boneProtection->getBoneArmor(element); } bool CHelmet::install_upgrade_impl(LPCSTR section, bool test) { bool result = inherited::install_upgrade_impl(section, test); @@ -196,6 +222,12 @@ bool CHelmet::install_upgrade_impl(LPCSTR section, bool test) if (result2 && !test) AddBonesProtection(str); + if (m_boneProtection->m_hitFracType == SBoneProtections::HitFractionActorCS || + m_boneProtection->m_hitFracType == SBoneProtections::HitFractionActorCOP) + { + result |= process_if_exists(section, "hit_fraction_actor", &CInifile::r_float, m_boneProtection->m_fHitFrac, test); + } + return result; } @@ -212,51 +244,131 @@ void CHelmet::AddBonesProtection(LPCSTR bones_section) float CHelmet::HitThroughArmor(float hit_power, s16 element, float ap, bool& add_wound, ALife::EHitType hit_type) { float NewHitPower = hit_power; - if (hit_type == ALife::eHitTypeFireWound) + + switch (m_boneProtection->m_hitFracType) { - float ba = GetBoneArmor(element); - if (ba < 0.0f) - return NewHitPower; + default: + case SBoneProtections::HitFractionActorCOP: + { + if (hit_type == ALife::eHitTypeFireWound) + { + const float ba = GetBoneArmor(element); + if (ba < 0.0f) + return NewHitPower; - float BoneArmor = ba * GetCondition(); - if (/*!fis_zero(ba, EPS) && */ (ap > BoneArmor)) + float BoneArmor = ba * GetCondition(); + if (/*!fis_zero(ba, EPS) && */ ap > BoneArmor) + { + //Ð¿ÑƒÐ»Ñ Ð¿Ñ€Ð¾Ð±Ð¸Ð»Ð° бронь + if (!IsGameTypeSingle()) + { + float hit_fraction = (ap - BoneArmor) / ap; + if (hit_fraction < m_boneProtection->m_fHitFrac) + hit_fraction = m_boneProtection->m_fHitFrac; + + NewHitPower *= hit_fraction; + NewHitPower *= m_boneProtection->getBoneProtection(element); + } + + VERIFY(NewHitPower >= 0.0f); + } + else + { + //Ð¿ÑƒÐ»Ñ ÐЕ пробила бронь + NewHitPower *= m_boneProtection->m_fHitFrac; + add_wound = false; //раны нет + } + } + else { - //Ð¿ÑƒÐ»Ñ Ð¿Ñ€Ð¾Ð±Ð¸Ð»Ð° бронь - if (!IsGameTypeSingle()) + float one = 0.1f; + if (hit_type == ALife::eHitTypeStrike || + hit_type == ALife::eHitTypeWound || + hit_type == ALife::eHitTypeWound_2 || + hit_type == ALife::eHitTypeExplosion) { - float hit_fraction = (ap - BoneArmor) / ap; - if (hit_fraction < m_boneProtection->m_fHitFracActor) - hit_fraction = m_boneProtection->m_fHitFracActor; - - NewHitPower *= hit_fraction; - NewHitPower *= m_boneProtection->getBoneProtection(element); + one = 1.0f; } + const float protect = GetDefHitTypeProtection(hit_type); + NewHitPower -= protect * one; + + if (NewHitPower < 0.f) + NewHitPower = 0.f; + } + + //увеличить изношенноÑть шлема + Hit(hit_power, hit_type); + break; + } + case SBoneProtections::HitFractionActorCS: + { + if (hit_type == ALife::eHitTypeFireWound) + { + const float BoneArmor = m_boneProtection->getBoneArmor(element) * GetCondition(); + + if (ap > EPS && ap > BoneArmor) + { + //Ð¿ÑƒÐ»Ñ Ð¿Ñ€Ð¾Ð±Ð¸Ð»Ð° бронь + const float d_ap = ap - BoneArmor; + NewHitPower *= (d_ap / ap); + + if (NewHitPower < m_boneProtection->m_fHitFrac) + NewHitPower = m_boneProtection->m_fHitFrac; + + if (!IsGameTypeSingle()) + { + NewHitPower *= m_boneProtection->getBoneProtection(element); + } - VERIFY(NewHitPower >= 0.0f); + if (NewHitPower < 0.0f) + NewHitPower = 0.0f; + } + else + { + //Ð¿ÑƒÐ»Ñ ÐЕ пробила бронь + NewHitPower *= m_boneProtection->m_fHitFrac; + add_wound = false; //раны нет + } } else { - //Ð¿ÑƒÐ»Ñ ÐЕ пробила бронь - NewHitPower *= m_boneProtection->m_fHitFracActor; - add_wound = false; //раны нет + float one = 0.1f; + if (hit_type == ALife::eHitTypeWound || + hit_type == ALife::eHitTypeWound_2 || + hit_type == ALife::eHitTypeExplosion) + { + one = 1.0f; + } + + const float protect = GetHitTypeProtection(hit_type, element); + NewHitPower -= protect * one; + if (NewHitPower < 0.0f) + NewHitPower = 0.0f; } + + //увеличить изношенноÑть шлема + Hit(NewHitPower, hit_type); + break; } - else + case SBoneProtections::HitFraction: { - float one = 0.1f; - if (hit_type == ALife::eHitTypeStrike || hit_type == ALife::eHitTypeWound || - hit_type == ALife::eHitTypeWound_2 || hit_type == ALife::eHitTypeExplosion) + if (hit_type == ALife::eHitTypeFireWound) + { + const float BoneArmor = m_boneProtection->getBoneArmor(element) * GetCondition() * (1 - ap); + NewHitPower -= BoneArmor; + if (NewHitPower < hit_power * m_boneProtection->m_fHitFrac) + NewHitPower = hit_power * m_boneProtection->m_fHitFrac; + } + else { - one = 1.0f; + NewHitPower *= GetHitTypeProtection(hit_type, element); } - float protect = GetDefHitTypeProtection(hit_type); - NewHitPower -= protect * one; - if (NewHitPower < 0.f) - NewHitPower = 0.f; + //увеличить изношенноÑть шлема + Hit(hit_power, hit_type); + break; } - //увеличить изношенноÑть шлема - Hit(hit_power, hit_type); + } // switch (m_boneProtection->m_hitFracType) return NewHitPower; } diff --git a/src/xrGame/ActorHelmet.h b/src/xrGame/ActorHelmet.h index eeff88ddc3b..fecf4f3d9b7 100644 --- a/src/xrGame/ActorHelmet.h +++ b/src/xrGame/ActorHelmet.h @@ -6,7 +6,6 @@ struct SBoneProtections; class CHelmet : public CInventoryItemObject { - friend void CHelmet_Export(lua_State* luaState); using inherited = CInventoryItemObject; public: @@ -27,9 +26,9 @@ class CHelmet : public CInventoryItemObject virtual void net_Import(NET_Packet& P); virtual void OnH_A_Chield(); - float GetDefHitTypeProtection(ALife::EHitType hit_type); - float GetHitTypeProtection(ALife::EHitType hit_type, s16 element); - float GetBoneArmor(s16 element); + [[nodiscard]] float GetDefHitTypeProtection(ALife::EHitType hit_type) const; + [[nodiscard]] float GetHitTypeProtection(ALife::EHitType hit_type, s16 element) const; + [[nodiscard]] float GetBoneArmor(s16 element) const; float HitThroughArmor(float hit_power, s16 element, float ap, bool& add_wound, ALife::EHitType hit_type); @@ -46,9 +45,12 @@ class CHelmet : public CInventoryItemObject void AddBonesProtection(LPCSTR bones_section); protected: - HitImmunity::HitTypeSVec m_HitTypeProtection; + mutable HitImmunity::HitTypeSVec m_HitTypeProtection; SBoneProtections* m_boneProtection; protected: virtual bool install_upgrade_impl(LPCSTR section, bool test); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; diff --git a/src/xrGame/ActorInput.cpp b/src/xrGame/ActorInput.cpp index a62bf8eb324..47d79d2b702 100644 --- a/src/xrGame/ActorInput.cpp +++ b/src/xrGame/ActorInput.cpp @@ -200,7 +200,7 @@ void CActor::IR_OnKeyboardPress(int cmd) StaticDrawableWrapper* _s = CurrentGameUI()->AddCustomStatic("item_used", true, compat ? 3.0f : -1.0f); string1024 str; - strconcat(sizeof(str), str, *StringTable().translate("st_item_used"), ": ", itm->NameItem()); + strconcat(sizeof(str), str, StringTable().translate("st_item_used").c_str(), ": ", itm->NameItem()); _s->wnd()->SetText(str); if (quickSlot) CurrentGameUI()->GetActorMenu().m_pQuickSlot->ReloadReferences(this); diff --git a/src/xrGame/ActorVehicle.cpp b/src/xrGame/ActorVehicle.cpp index ee3074f275f..1dea6959e0a 100644 --- a/src/xrGame/ActorVehicle.cpp +++ b/src/xrGame/ActorVehicle.cpp @@ -29,9 +29,9 @@ void CActor::attach_Vehicle(CHolderCustom* vehicle) if(!vehicle || m_holder) return; - CCar* car = smart_cast(vehicle); - if (!car) - return; + CCar* car = smart_cast(vehicle); + if (!car) + return; //PickupModeOff(); m_holder=vehicle; diff --git a/src/xrGame/Artefact.h b/src/xrGame/Artefact.h index 5edd3815d33..62618df5dfa 100644 --- a/src/xrGame/Artefact.h +++ b/src/xrGame/Artefact.h @@ -129,6 +129,9 @@ class CArtefact : public CHudItemObject, public CPHUpdateObject o_fastmode = FALSE; // processing_deactivate (); } + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; struct SArtefactDetectorsSupport diff --git a/src/xrGame/BastArtifact.cpp b/src/xrGame/BastArtifact.cpp index f70167032b1..3f86b93c563 100644 --- a/src/xrGame/BastArtifact.cpp +++ b/src/xrGame/BastArtifact.cpp @@ -184,7 +184,7 @@ void CBastArtefact::UpdateCLChild() if (m_fEnergy > 0 && ::Random.randF(0.f, 1.0f) < (m_fEnergy / (m_fStrikeImpulse * 100.f))) { CParticlesObject* pStaticPG; - pStaticPG = CParticlesObject::Create(*m_sParticleName, TRUE); + pStaticPG = CParticlesObject::Create(m_sParticleName.c_str(), TRUE); Fmatrix pos; pos.set(XFORM()); Fvector vel; diff --git a/src/xrGame/BlackGraviArtifact.cpp b/src/xrGame/BlackGraviArtifact.cpp index 4e3b5afbde7..6fa9897bca2 100644 --- a/src/xrGame/BlackGraviArtifact.cpp +++ b/src/xrGame/BlackGraviArtifact.cpp @@ -88,7 +88,7 @@ void CBlackGraviArtefact::UpdateCLChild() GraviStrike(); CParticlesObject* pStaticPG; - pStaticPG = CParticlesObject::Create(*m_sParticleName, TRUE); + pStaticPG = CParticlesObject::Create(m_sParticleName.c_str(), TRUE); Fmatrix pos; pos.set(XFORM()); Fvector vel; diff --git a/src/xrGame/BoneProtections.cpp b/src/xrGame/BoneProtections.cpp index e391ac9ee49..d6fa634efe7 100644 --- a/src/xrGame/BoneProtections.cpp +++ b/src/xrGame/BoneProtections.cpp @@ -2,7 +2,7 @@ #include "BoneProtections.h" #include "Include/xrRender/Kinematics.h" #include "xrCore/Animation/Bone.hpp" -#include "Level.h" +#include "game_type.h" float SBoneProtections::getBoneProtection(s16 bone_id) const { @@ -35,12 +35,26 @@ void SBoneProtections::reload(const shared_str& bone_sect, IKinematics* kinemati { VERIFY(kinematics); - float defaultHitFraction = 0.1f; - if (ShadowOfChernobylMode || ClearSkyMode) + if (m_hitFracType != HitFractionActorCS && m_hitFracType != HitFractionActorCOP) { - defaultHitFraction = pSettings->read_if_exists(bone_sect, "hit_fraction", defaultHitFraction); + if (pSettings->line_exist(bone_sect, HIT_FRACTION_NPC)) + { + m_hitFracType = HitFractionNPC; + m_fHitFrac = pSettings->r_float(bone_sect, HIT_FRACTION_NPC); + } + else if (pSettings->line_exist(bone_sect, HIT_FRACTION)) + { + m_hitFracType = HitFraction; + m_fHitFrac = pSettings->r_float(bone_sect, HIT_FRACTION); + } + else + { + const bool is_cop = GMLib.GetLibraryVersion() >= GAMEMTL_VERSION_COP; + + m_hitFracType = is_cop ? HitFractionNPC : HitFraction; + m_fHitFrac = 0.1f; + } } - m_fHitFracNpc = pSettings->read_if_exists(bone_sect, "hit_fraction_npc", defaultHitFraction); m_bones_koeff.clear(); m_bones_koeff[BI_NONE] = BoneProtection{}; @@ -48,7 +62,9 @@ void SBoneProtections::reload(const shared_str& bone_sect, IKinematics* kinemati CInifile::Sect& protections = pSettings->r_section(bone_sect); for (const auto& [name, value] : protections.Data) { - if (xr_strcmp(name.c_str(), "hit_fraction") == 0) + if (xr_strcmp(name.c_str(), HIT_FRACTION) == 0) + continue; + if (xr_strcmp(name.c_str(), HIT_FRACTION_NPC) == 0) continue; string256 buffer; @@ -85,17 +101,17 @@ void SBoneProtections::add(const shared_str& bone_sect, IKinematics* kinematics) VERIFY(kinematics); - float defaultHitFraction = 0.0f; - if (ShadowOfChernobylMode || ClearSkyMode) - { - defaultHitFraction = READ_IF_EXISTS(pSettings, r_float, bone_sect, "hit_fraction", defaultHitFraction); - } - m_fHitFracNpc += READ_IF_EXISTS(pSettings, r_float, bone_sect.c_str(), "hit_fraction_npc", defaultHitFraction); + if (m_hitFracType == HitFractionNPC) + m_fHitFrac += pSettings->read_if_exists(bone_sect, HIT_FRACTION_NPC, 0.0f); + else if (m_hitFracType == HitFraction) + m_fHitFrac += pSettings->read_if_exists(bone_sect, HIT_FRACTION, 0.0f); CInifile::Sect& protections = pSettings->r_section(bone_sect); for (const auto& [name, value] : protections.Data) { - if (xr_strcmp(name.c_str(), "hit_fraction") == 0) + if (xr_strcmp(name.c_str(), HIT_FRACTION) == 0) + continue; + if (xr_strcmp(name.c_str(), HIT_FRACTION_NPC) == 0) continue; string256 buffer; diff --git a/src/xrGame/BoneProtections.h b/src/xrGame/BoneProtections.h index 4c73ffdbdf7..46a19adcd5e 100644 --- a/src/xrGame/BoneProtections.h +++ b/src/xrGame/BoneProtections.h @@ -4,6 +4,24 @@ class IKinematics; struct SBoneProtections { + static constexpr cpcstr HIT_FRACTION = "hit_fraction"; + static constexpr cpcstr HIT_FRACTION_NPC = "hit_fraction_npc"; + + enum HitFractionType : u8 + { + // Exists in SOC and CS + HitFraction, + + // Introduced in CS, externally assigned + HitFractionActorCS, + + // Introduced in COP + HitFractionNPC, + + // Hit formula changed in COP, externally assigned + HitFractionActorCOP, + }; + struct BoneProtection { float koeff{ 1.0f }; @@ -13,8 +31,8 @@ struct SBoneProtections mutable xr_map m_bones_koeff; - float m_fHitFracNpc{ 0.1f }; - float m_fHitFracActor{ 0.1f }; + float m_fHitFrac{ 0.1f }; + HitFractionType m_hitFracType{ HitFractionNPC }; [[nodiscard]] float getBoneProtection(s16 bone_id) const; [[nodiscard]] float getBoneArmor(s16 bone_id) const; diff --git a/src/xrGame/BottleItem.cpp b/src/xrGame/BottleItem.cpp index ac25b731939..405ff8bddea 100644 --- a/src/xrGame/BottleItem.cpp +++ b/src/xrGame/BottleItem.cpp @@ -40,11 +40,11 @@ void CBottleItem::BreakToPieces() sndBreaking.play_at_pos(0, Position(), false); //отыграть партиклы Ñ€Ð°Ð·Ð±Ð¸Ð²Ð°Ð½Ð¸Ñ - if (*m_sBreakParticles) + if (m_sBreakParticles.c_str()) { //показываем Ñффекты CParticlesObject* pStaticPG; - pStaticPG = CParticlesObject::Create(*m_sBreakParticles, TRUE); + pStaticPG = CParticlesObject::Create(m_sBreakParticles.c_str(), TRUE); pStaticPG->play_at_pos(Position()); } diff --git a/src/xrGame/CMakeLists.txt b/src/xrGame/CMakeLists.txt index d329a2ad2f4..212a3a6f9c3 100644 --- a/src/xrGame/CMakeLists.txt +++ b/src/xrGame/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(xrGame SHARED) +add_library(xrGame) target_sources(xrGame PRIVATE abstract_location_selector.h @@ -35,6 +35,7 @@ target_sources(xrGame PRIVATE actor_communication.cpp ActorCondition.cpp ActorCondition.h + ActorCondition_script.cpp Actor.cpp actor_defs.h ActorEffector.cpp @@ -335,7 +336,6 @@ target_sources(xrGame PRIVATE configs_dump_verifyer.h console_commands.cpp console_commands_mp.cpp - console_registrator_script.cpp ContextMenu.cpp ContextMenu.h control_action.h @@ -471,7 +471,6 @@ target_sources(xrGame PRIVATE entity_alive_inline.h EntityCondition.cpp EntityCondition.h - EntityCondition_script.cpp Entity.cpp Entity.h ExoOutfit.cpp @@ -895,8 +894,6 @@ target_sources(xrGame PRIVATE pda_space.h PHCollisionDamageReceiver.cpp PHCollisionDamageReceiver.h - PHCommander.cpp - PHCommander.h PHDebug.cpp PHDebug.h PHDestroyable.cpp @@ -916,15 +913,9 @@ target_sources(xrGame PRIVATE Phrase.h PhraseScript.cpp PhraseScript.h - PHReqComparer.h - PHScriptCall.cpp - PHScriptCall.h PHShellCreator.cpp PHShellCreator.h ph_shell_interface.h - PHSimpleCalls.cpp - PHSimpleCalls.h - PHSimpleCallsScript.cpp PHSkeleton.cpp PHSkeleton.h PHSoundPlayer.cpp @@ -935,25 +926,16 @@ target_sources(xrGame PRIVATE PhysicObject.cpp PhysicObject.h PhysicObject_script.cpp - physics_element_scripted.cpp - physics_element_scripted.h physics_game.cpp physics_game.h PhysicsGamePars.cpp PhysicsGamePars.h - physics_joint_scripted.cpp - physics_joint_scripted.h physics_shell_animated.cpp physics_shell_animated.h PhysicsShellHolder.cpp PhysicsShellHolder.h - #PhysicsShellScript.cpp - physics_shell_scripted.cpp - physics_shell_scripted.h PhysicsSkeletonObject.cpp PhysicsSkeletonObject.h - physics_world_scripted.cpp - physics_world_scripted.h player_account.cpp player_account.h player_hud.cpp @@ -1098,7 +1080,6 @@ target_sources(xrGame PRIVATE script_hit.h script_hit_inline.h script_hit_script.cpp - script_lanim.cpp script_monster_action.cpp script_monster_action.h script_monster_action_inline.h @@ -1126,7 +1107,6 @@ target_sources(xrGame PRIVATE script_property_evaluator_wrapper.cpp script_property_evaluator_wrapper.h script_property_evaluator_wrapper_inline.h - script_render_device_script.cpp script_sound_action.cpp script_sound_action.h script_sound_action_inline.h @@ -2373,7 +2353,6 @@ target_sources(xrGame PRIVATE ui/UIWeightBar.h ui/UIWheelMenu.cpp ui/UIWheelMenu.h - ui/UIWindow_script.cpp ui/UIWpnParams.cpp ui/UIWpnParams.h ui/UIXmlInit.cpp @@ -2407,6 +2386,8 @@ target_sources(xrGame PRIVATE ../xrServerEntities/object_factory_register.cpp ../xrServerEntities/object_factory_script.cpp ../xrServerEntities/object_factory_space.h + ../xrServerEntities/object_factory_spawner.cpp + ../xrServerEntities/object_factory_spawner.h ../xrServerEntities/object_item_abstract.h ../xrServerEntities/object_item_abstract_inline.h ../xrServerEntities/object_item_client_server.h @@ -2437,7 +2418,6 @@ target_sources(xrGame PRIVATE ../xrServerEntities/script_rtoken_list.h ../xrServerEntities/script_rtoken_list_inline.h ../xrServerEntities/script_rtoken_list_script.cpp - ../xrServerEntities/script_sound_type_script.cpp ../xrServerEntities/script_token_list.cpp ../xrServerEntities/script_token_list.h ../xrServerEntities/script_token_list_script.cpp @@ -2470,15 +2450,14 @@ target_sources(xrGame PRIVATE ../xrServerEntities/xrServer_Objects_ALife.h ../xrServerEntities/xrServer_Objects_ALife_Items.cpp ../xrServerEntities/xrServer_Objects_ALife_Items.h - ../xrServerEntities/xrServer_Objects_ALife_Items_script2.cpp - ../xrServerEntities/xrServer_Objects_ALife_Items_script3.cpp ../xrServerEntities/xrServer_Objects_ALife_Items_script.cpp + ../xrServerEntities/xrServer_Objects_ALife_Items_script2.cpp ../xrServerEntities/xrServer_Objects_ALife_Monsters.cpp ../xrServerEntities/xrServer_Objects_ALife_Monsters.h + ../xrServerEntities/xrServer_Objects_ALife_Monsters_script.cpp ../xrServerEntities/xrServer_Objects_ALife_Monsters_script2.cpp ../xrServerEntities/xrServer_Objects_ALife_Monsters_script3.cpp ../xrServerEntities/xrServer_Objects_ALife_Monsters_script4.cpp - ../xrServerEntities/xrServer_Objects_ALife_Monsters_script.cpp ../xrServerEntities/xrServer_Objects_ALife_script2.cpp ../xrServerEntities/xrServer_Objects_ALife_script3.cpp ../xrServerEntities/xrServer_Objects_ALife_script.cpp @@ -2531,18 +2510,13 @@ target_compile_definitions(xrGame XRGAME_EXPORTS ) -target_compile_options(xrGame - PRIVATE - -Wno-trigraphs -) - -# E2K: hack for debug compile (MCST lcc compiler does not support a file > 4Gb, this is a bug in EDG frontend) -if ((CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") AND PROJECT_PLATFORM_E2K) +# E2K hack: MCST lcc compiler does not support object files greater than 4Gb due to a bug in EDG frontend +if (CMAKE_CXX_COMPILER_ID MATCHES "LCC") target_compile_options(xrGame PRIVATE -g0 ) - message(STATUS "Build type is ${CMAKE_BUILD_TYPE}, so disable generation of debug info for xrGame module, because MCST lcc compiler does not support a file > 4 GB (this is a bug in EDG frontend).") + message("Debug information generation is disabled for xrGame, because MCST lcc compiler does not support object files greater than 4 GB (EDG frontend bug).") endif() set_target_properties(xrGame PROPERTIES @@ -2556,6 +2530,8 @@ target_precompile_headers(xrGame $<$:pch_script.h> ) -install(TARGETS xrGame LIBRARY - DESTINATION "${CMAKE_INSTALL_LIBDIR}" -) +if (BUILD_SHARED_LIBS) + install(TARGETS xrGame LIBRARY + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) +endif() diff --git a/src/xrGame/CameraFirstEye.cpp b/src/xrGame/CameraFirstEye.cpp index 39209929c71..7088090820d 100644 --- a/src/xrGame/CameraFirstEye.cpp +++ b/src/xrGame/CameraFirstEye.cpp @@ -10,14 +10,6 @@ // Construction/Destruction ////////////////////////////////////////////////////////////////////// -CCameraFirstEye::CCameraFirstEye(IGameObject* p, u32 flags) : CCameraBase(p, flags), lookat_active(false) {} -CCameraFirstEye::~CCameraFirstEye() {} -void CCameraFirstEye::Load(LPCSTR section) -{ - inherited::Load(section); - style = csFirstEye; -} - void CCameraFirstEye::UpdateLookat() { if (!lookat_active) @@ -42,7 +34,7 @@ void CCameraFirstEye::UpdateLookat() pitch = angle_inertion_var(pitch, xyz.x, 1.0f, PI, PI, Device.fTimeDelta); } -void CCameraFirstEye::Update(Fvector& point, Fvector& noise_dangle) +void CCameraFirstEye::Update(const Fvector& point, Fvector& noise_dangle) { vPosition.set(point); diff --git a/src/xrGame/CameraFirstEye.h b/src/xrGame/CameraFirstEye.h index 31ff8288908..ef2cae0f6b4 100644 --- a/src/xrGame/CameraFirstEye.h +++ b/src/xrGame/CameraFirstEye.h @@ -1,32 +1,30 @@ -#ifndef __CAMERA_FE_H__ -#define __CAMERA_FE_H__ +#pragma once #include "xrEngine/CameraBase.h" class CCameraFirstEye : public CCameraBase { - typedef CCameraBase inherited; - Fvector lookat_point; - bool lookat_active; + using inherited = CCameraBase; + + Fvector lookat_point{}; + bool lookat_active{}; + void UpdateLookat(); public: - CCameraFirstEye(IGameObject* p, u32 flags = 0); - virtual ~CCameraFirstEye(); + CCameraFirstEye(IGameObject* p, u8 flags = 0) : CCameraBase(p, flags) {} - virtual void Load(LPCSTR section); - virtual void Move(int cmd, float val = 0, float factor = 1.0f); + void Move(int cmd, float val = 0, float factor = 1.0f) override; - virtual void OnActivate(CCameraBase* old_cam); - virtual void Update(Fvector& point, Fvector& noise_angle); + void OnActivate(CCameraBase* old_cam) override; + void Update(const Fvector& point, Fvector& noise_angle) override; - virtual float GetWorldYaw() { return -yaw; }; - virtual float GetWorldPitch() { return pitch; }; - void LookAtPoint(Fvector p) + float GetWorldYaw() override { return -yaw; } + float GetWorldPitch() override { return pitch; } + + void LookAtPoint(const Fvector& p) { lookat_point = p; lookat_active = true; } }; - -#endif // __CAMERALOOK_H__ diff --git a/src/xrGame/CameraLook.cpp b/src/xrGame/CameraLook.cpp index fbc323be645..a78b2cfa72b 100644 --- a/src/xrGame/CameraLook.cpp +++ b/src/xrGame/CameraLook.cpp @@ -1,23 +1,24 @@ #include "StdAfx.h" #pragma hdrstop -#include "CameraLook.h" #include "xrEngine/CameraManager.h" #include "xrEngine/xr_level_controller.h" +#include "xrEngine/xr_input.h" + +#include "CameraLook.h" #include "Actor.h" +#include "actor_memory.h" +#include "visual_memory_manager.h" -CCameraLook::CCameraLook(IGameObject* p, u32 flags) : CCameraBase(p, flags) {} -void CCameraLook::Load(LPCSTR section) +void CCameraLook::Load(pcstr section) { inherited::Load(section); - style = csLookAt; lim_zoom = pSettings->r_fvector2(section, "lim_zoom"); dist = (lim_zoom[0] + lim_zoom[1]) * 0.5f; prev_d = 0; } -CCameraLook::~CCameraLook() {} -void CCameraLook::Update(Fvector& point, Fvector& /**noise_dangle**/) +void CCameraLook::Update(const Fvector& point, Fvector& /**noise_dangle**/) { vPosition.set(point); Fmatrix mR; @@ -34,7 +35,7 @@ void CCameraLook::Update(Fvector& point, Fvector& /**noise_dangle**/) UpdateDistance(point); } -void CCameraLook::UpdateDistance(Fvector& point) +void CCameraLook::UpdateDistance(const Fvector& point) { Fvector vDir; collide::rq_result R; @@ -81,13 +82,9 @@ void CCameraLook::OnActivate(CCameraBase* old_cam) yaw += PI_MUL_2; } -#include "xrEngine/xr_input.h" -#include "visual_memory_manager.h" -#include "actor_memory.h" - Fvector CCameraLook2::m_cam_offset; -void CCameraLook2::OnActivate(CCameraBase* old_cam) { CCameraLook::OnActivate(old_cam); } -void CCameraLook2::Update(Fvector& point, Fvector&) + +void CCameraLook2::Update(const Fvector& point, Fvector&) { bool keyPressed = false; ForAllActionKeys(kCAM_AUTOAIM, [&](size_t /*keyboard_index*/, int key) @@ -135,7 +132,7 @@ void CCameraLook2::Update(Fvector& point, Fvector&) { if (!keyPressed) { - m_locked_enemy = NULL; + m_locked_enemy = nullptr; //. Msg ("enemy is NILL"); } } @@ -180,7 +177,7 @@ void CCameraLook2::UpdateAutoAim() angle_inertion_var(pitch, xyz.x, m_autoaim_inertion_pitch.x, m_autoaim_inertion_pitch.y, PI, Device.fTimeDelta); } -void CCameraLook2::Load(LPCSTR section) +void CCameraLook2::Load(pcstr section) { CCameraLook::Load(section); m_cam_offset = pSettings->r_fvector3(section, "offset"); @@ -188,12 +185,6 @@ void CCameraLook2::Load(LPCSTR section) m_autoaim_inertion_pitch = pSettings->r_fvector2(section, "autoaim_speed_x"); } -void CCameraFixedLook::Load(LPCSTR section) -{ - CCameraLook::Load(section); - style = csFixed; -} - void CCameraFixedLook::OnActivate(CCameraBase* old_cam) { inherited::OnActivate(old_cam); @@ -213,7 +204,8 @@ void CCameraFixedLook::OnActivate(CCameraBase* old_cam) } void CCameraFixedLook::Move(int cmd, float val, float factor) {} -void CCameraFixedLook::Update(Fvector& point, Fvector& noise_dangle) + +void CCameraFixedLook::Update(const Fvector& point, Fvector& noise_dangle) { Fquaternion new_dir; new_dir.slerp(m_current_dir, m_final_dir, Device.fTimeDelta); // 1 sec diff --git a/src/xrGame/CameraLook.h b/src/xrGame/CameraLook.h index 3af24fb507a..affa41fc8b1 100644 --- a/src/xrGame/CameraLook.h +++ b/src/xrGame/CameraLook.h @@ -1,27 +1,29 @@ #pragma once + #include "xrEngine/CameraBase.h" #include "xrCore/_quaternion.h" class CCameraLook : public CCameraBase { - typedef CCameraBase inherited; + using inherited = CCameraBase; - Fvector2 lim_zoom; - float dist, prev_d; + Fvector2 lim_zoom{}; + float dist{}, prev_d{}; public: - CCameraLook(IGameObject* p, u32 flags = 0); - virtual ~CCameraLook(); - virtual void Load(LPCSTR section); - virtual void Move(int cmd, float val = 0, float factor = 1.0f); + CCameraLook(IGameObject* p, u8 flags = 0) : CCameraBase(p, flags) {} + + void Load(pcstr section) override; + void Move(int cmd, float val = 0, float factor = 1.0f) override; + + void OnActivate(CCameraBase* old_cam) override; + void Update(const Fvector& point, Fvector& noise_dangle) override; - virtual void OnActivate(CCameraBase* old_cam); - virtual void Update(Fvector& point, Fvector& noise_dangle); + float GetWorldYaw() override { return -yaw; } + float GetWorldPitch() override { return pitch; } - virtual float GetWorldYaw() { return -yaw; }; - virtual float GetWorldPitch() { return pitch; }; protected: - void UpdateDistance(Fvector& point); + void UpdateDistance(const Fvector& point); }; class CCameraLook2 : public CCameraLook @@ -30,17 +32,16 @@ class CCameraLook2 : public CCameraLook static Fvector m_cam_offset; protected: - IGameObject* m_locked_enemy; - Fvector2 m_autoaim_inertion_yaw; - Fvector2 m_autoaim_inertion_pitch; + IGameObject* m_locked_enemy{}; + Fvector2 m_autoaim_inertion_yaw{}; + Fvector2 m_autoaim_inertion_pitch{}; void UpdateAutoAim(); public: - CCameraLook2(IGameObject* p, u32 flags = 0) : CCameraLook(p, flags) { m_locked_enemy = NULL; }; - virtual ~CCameraLook2() {} - virtual void OnActivate(CCameraBase* old_cam); - virtual void Update(Fvector& point, Fvector& noise_dangle); - virtual void Load(LPCSTR section); + CCameraLook2(IGameObject* p, u8 flags = 0) : CCameraLook(p, flags) {} + + void Update(const Fvector& point, Fvector& noise_dangle) override; + void Load(pcstr section) override; }; class CCameraFixedLook : public CCameraLook @@ -48,15 +49,14 @@ class CCameraFixedLook : public CCameraLook typedef CCameraLook inherited; public: - CCameraFixedLook(IGameObject* p, u32 flags = 0) : CCameraLook(p, flags){}; - virtual ~CCameraFixedLook(){}; - virtual void Load(LPCSTR section); - virtual void Move(int cmd, float val = 0, float factor = 1.0f); - virtual void OnActivate(CCameraBase* old_cam); - virtual void Update(Fvector& point, Fvector& noise_dangle); - virtual void Set(float Y, float P, float R); + CCameraFixedLook(IGameObject* p, u8 flags = 0) : CCameraLook(p, flags) {} + + void Move(int cmd, float val = 0, float factor = 1.0f) override; + void OnActivate(CCameraBase* old_cam) override; + void Update(const Fvector& point, Fvector& noise_dangle) override; + void Set(float Y, float P, float R) override; private: - Fquaternion m_final_dir; - Fquaternion m_current_dir; + Fquaternion m_final_dir{}; + Fquaternion m_current_dir{}; }; diff --git a/src/xrGame/Car.cpp b/src/xrGame/Car.cpp index 014d5157abb..c3ab3b0586b 100644 --- a/src/xrGame/Car.cpp +++ b/src/xrGame/Car.cpp @@ -939,17 +939,17 @@ void CCar::Init() for (auto I = data.Data.cbegin(); I != data.Data.cend(); ++I) { const CInifile::Item& item = *I; - u16 index = pKinematics->LL_BoneID(*item.first); - R_ASSERT3(index != BI_NONE, "Wrong bone name", *item.first); + u16 index = pKinematics->LL_BoneID(item.first.c_str()); + R_ASSERT3(index != BI_NONE, "Wrong bone name", item.first.c_str()); xr_map::iterator i = m_wheels_map.find(index); if (i != m_wheels_map.end()) - i->second.CDamagableHealthItem::Init(float(atof(*item.second)), 2); + i->second.CDamagableHealthItem::Init(float(atof(item.second.c_str())), 2); else { xr_map::iterator i = m_doors.find(index); - R_ASSERT3(i != m_doors.end(), "only wheel and doors bones allowed for damage defs", *item.first); - i->second.CDamagableHealthItem::Init(float(atof(*item.second)), 1); + R_ASSERT3(i != m_doors.end(), "only wheel and doors bones allowed for damage defs", item.first.c_str()); + i->second.CDamagableHealthItem::Init(float(atof(item.second.c_str())), 1); } } } diff --git a/src/xrGame/Car.h b/src/xrGame/Car.h index 9513a6703ed..1df5b5adda7 100644 --- a/src/xrGame/Car.h +++ b/src/xrGame/Car.h @@ -671,4 +671,6 @@ class CCar : public CEntity, virtual CHolderCustom* cast_holder_custom() { return this; } private: car_memory* m_memory; + + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject, CHolderCustom); }; diff --git a/src/xrGame/CarDamageParticles.cpp b/src/xrGame/CarDamageParticles.cpp index 6f7cf906174..af188df61f3 100644 --- a/src/xrGame/CarDamageParticles.cpp +++ b/src/xrGame/CarDamageParticles.cpp @@ -45,7 +45,7 @@ void CCarDamageParticles::Init(CCar* car) void CCarDamageParticles::Play1(CCar* car) { - if (*m_car_damage_particles1) + if (m_car_damage_particles1.c_str()) for (auto& bone : bones1) car->StartParticles(m_car_damage_particles1, bone, Fvector().set(0, 1, 0), car->ID()); } @@ -53,7 +53,7 @@ void CCarDamageParticles::Play1(CCar* car) void CCarDamageParticles::Play2(CCar* car) { VERIFY(!physics_world()->Processing()); - if (*m_car_damage_particles2) + if (m_car_damage_particles2.c_str()) for (auto& bone : bones2) car->StartParticles(m_car_damage_particles2, bone, Fvector().set(0, 1, 0), car->ID()); } @@ -62,7 +62,7 @@ void CCarDamageParticles::Play2(CCar* car) // функции Ð´Ð»Ñ Ð²Ñ‹ÐºÐ»ÑŽÑ‡ÐµÐ½Ð¸Ñ Ð¿Ð°Ñ€Ñ‚Ð¸ÐºÐ»Ð¾Ð² дыма void CCarDamageParticles::Stop1(CCar* car) { - if(*m_car_damage_particles1) + if(m_car_damage_particles1.c_str()) for (auto& bone : bones1) car->StopParticles(car->ID(), bone, false); } @@ -70,7 +70,7 @@ void CCarDamageParticles::Stop1(CCar* car) void CCarDamageParticles::Stop2(CCar* car) { VERIFY(!physics_world()->Processing()); - if(*m_car_damage_particles2) + if(m_car_damage_particles2.c_str()) for (auto& bone : bones2) car->StopParticles(car->ID(), bone, false); } @@ -80,14 +80,14 @@ void CCarDamageParticles::Stop2(CCar* car) void CCarDamageParticles::PlayWheel1(CCar* car, u16 bone_id) const { VERIFY(!physics_world()->Processing()); - if (*m_wheels_damage_particles1) + if (m_wheels_damage_particles1.c_str()) car->StartParticles(m_wheels_damage_particles1, bone_id, Fvector().set(0, 1, 0), car->ID()); } void CCarDamageParticles::PlayWheel2(CCar* car, u16 bone_id) const { VERIFY(!physics_world()->Processing()); - if (*m_wheels_damage_particles2) + if (m_wheels_damage_particles2.c_str()) car->StartParticles(m_wheels_damage_particles2, bone_id, Fvector().set(0, 1, 0), car->ID()); } diff --git a/src/xrGame/CarExhaust.cpp b/src/xrGame/CarExhaust.cpp index a8a05bcb89a..3565ae58709 100644 --- a/src/xrGame/CarExhaust.cpp +++ b/src/xrGame/CarExhaust.cpp @@ -26,7 +26,7 @@ void CCar::SExhaust::Init() // pelement->InterpolateGlobalTransform(&element_transform); // element_transform.invert(); // transform.mulA(element_transform); - p_pgobject = CParticlesObject::Create(*pcar->m_exhaust_particles, FALSE); + p_pgobject = CParticlesObject::Create(pcar->m_exhaust_particles.c_str(), FALSE); Fvector zero_vector; zero_vector.set(0.f, 0.f, 0.f); p_pgobject->UpdateParent(pcar->XFORM(), zero_vector); diff --git a/src/xrGame/CarScript.cpp b/src/xrGame/CarScript.cpp index 9ee40f84919..d828eb5302f 100644 --- a/src/xrGame/CarScript.cpp +++ b/src/xrGame/CarScript.cpp @@ -1,11 +1,11 @@ #include "pch_script.h" + #include "alife_space.h" #include "Car.h" #include "CarWeapon.h" #include "script_game_object.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CCar, (CGameObject, CHolderCustom), +void CCar::script_register(lua_State* luaState) { using namespace luabind; @@ -55,4 +55,4 @@ SCRIPT_EXPORT(CCar, (CGameObject, CHolderCustom), /***** added by Ray Twitty (aka Shadows) END *****/ .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/CharacterPhysicsSupport.cpp b/src/xrGame/CharacterPhysicsSupport.cpp index 6d3e4f98c5e..6bcabcd5701 100644 --- a/src/xrGame/CharacterPhysicsSupport.cpp +++ b/src/xrGame/CharacterPhysicsSupport.cpp @@ -161,7 +161,7 @@ void CCharacterPhysicsSupport::in_NetSpawn(CSE_Abstract* e) IKinematicsAnimated* ka = smart_cast(pVisual); IKinematics* pK = smart_cast(pVisual); VERIFY(&e->spawn_ini()); - m_death_anims.setup(ka, *e->s_name, pSettings); + m_death_anims.setup(ka, e->s_name.c_str(), pSettings); if (!m_EntityAlife.g_Alive()) { if (m_eType == etStalker) @@ -235,7 +235,7 @@ void CCharacterPhysicsSupport::SpawnInitPhysics(CSE_Abstract* e) { #ifdef DEBUG if (ph_dbg_draw_mask1.test(ph_m1_DbgTrackObject) && - xr_stricmp(PH_DBG_ObjectTrackName(), *m_EntityAlife.cName()) == 0) + xr_stricmp(PH_DBG_ObjectTrackName(), m_EntityAlife.cName().c_str()) == 0) { Msg("CCharacterPhysicsSupport::SpawnInitPhysics obj %s before collision correction %f,%f,%f", PH_DBG_ObjectTrackName(), m_EntityAlife.Position().x, m_EntityAlife.Position().y, @@ -254,7 +254,7 @@ void CCharacterPhysicsSupport::SpawnInitPhysics(CSE_Abstract* e) #ifdef DEBUG if (ph_dbg_draw_mask1.test(ph_m1_DbgTrackObject) && - xr_stricmp(PH_DBG_ObjectTrackName(), *m_EntityAlife.cName()) == 0) + xr_stricmp(PH_DBG_ObjectTrackName(), m_EntityAlife.cName().c_str()) == 0) { Msg("CCharacterPhysicsSupport::SpawnInitPhysics obj %s after collision correction %f,%f,%f", PH_DBG_ObjectTrackName(), m_EntityAlife.Position().x, m_EntityAlife.Position().y, @@ -654,7 +654,7 @@ void CCharacterPhysicsSupport::CreateSkeleton(CPhysicsShell*& pShell) pShell->Build(); #ifdef DEBUG - Msg("shell for %s[%d] created in %f ms", *m_EntityAlife.cName(), m_EntityAlife.ID(), t.GetElapsed_sec() * 1000.f); + Msg("shell for %s[%d] created in %f ms", m_EntityAlife.cName().c_str(), m_EntityAlife.ID(), t.GetElapsed_sec() * 1000.f); #endif } diff --git a/src/xrGame/CustomMonster_inline.h b/src/xrGame/CustomMonster_inline.h index e0e5d56b096..28aa82d7d8f 100644 --- a/src/xrGame/CustomMonster_inline.h +++ b/src/xrGame/CustomMonster_inline.h @@ -66,6 +66,6 @@ IC void CCustomMonster::invulnerable(const bool& invulnerable) { m_invulnerable IC bool CCustomMonster::invulnerable() const { return (m_invulnerable); } IC moving_object* CCustomMonster::get_moving_object() const { - VERIFY2(m_moving_object, make_string("object [%d][%s]", ID(), *cName())); + VERIFY2(m_moving_object, make_string("object [%d][%s]", ID(), cName().c_str())); return (m_moving_object); } diff --git a/src/xrGame/CustomOutfit.cpp b/src/xrGame/CustomOutfit.cpp index 2e356c947ab..caeb9aa3ca6 100644 --- a/src/xrGame/CustomOutfit.cpp +++ b/src/xrGame/CustomOutfit.cpp @@ -66,11 +66,24 @@ void CCustomOutfit::Load(LPCSTR section) m_HitTypeProtection[ALife::eHitTypeTelepatic] = pSettings->r_float(section, "telepatic_protection"); m_HitTypeProtection[ALife::eHitTypeChemicalBurn] = pSettings->r_float(section, "chemical_burn_protection"); m_HitTypeProtection[ALife::eHitTypeExplosion] = pSettings->r_float(section, "explosion_protection"); - m_HitTypeProtection[ALife::eHitTypeFireWound] = 0.f; // pSettings->r_float(section,"fire_wound_protection"); + m_HitTypeProtection[ALife::eHitTypeFireWound] = pSettings->read_if_exists(section, "fire_wound_protection", 0.0f); m_HitTypeProtection[ALife::eHitTypePhysicStrike] = pSettings->read_if_exists( section, "physic_strike_protection", m_HitTypeProtection[ALife::eHitTypeStrike]); m_HitTypeProtection[ALife::eHitTypeLightBurn] = m_HitTypeProtection[ALife::eHitTypeBurn]; - m_boneProtection->m_fHitFracActor = pSettings->read_if_exists(section, "hit_fraction_actor", 0.1f); + + if (pSettings->line_exist(section, "hit_fraction_actor")) + { + m_boneProtection->m_fHitFrac = pSettings->r_float(section, "hit_fraction_actor"); + + // Since hit_fraction_actor exists both in CS and COP, but fire_wound_protection was removed in COP, + // We can use this hacky solution to determine which damage formula to use. + // It not robust for mods, because they can have fire_wound_protection in configs, despite that + // original COP engine doesn't read it. + if (pSettings->line_exist(section, "fire_wound_protection")) + m_boneProtection->m_hitFracType = SBoneProtections::HitFractionActorCS; + else + m_boneProtection->m_hitFracType = SBoneProtections::HitFractionActorCOP; + } if (pSettings->line_exist(section, "nightvision_sect")) m_NightVisionSect = pSettings->r_string(section, "nightvision_sect"); @@ -122,67 +135,160 @@ void CCustomOutfit::Hit(float hit_power, ALife::EHitType hit_type) ChangeCondition(-hit_power); } -float CCustomOutfit::GetDefHitTypeProtection(ALife::EHitType hit_type) +float CCustomOutfit::GetDefHitTypeProtection(ALife::EHitType hit_type) const { - return m_HitTypeProtection[hit_type] * GetCondition(); + const float base = m_HitTypeProtection[hit_type] * GetCondition(); + + if (m_boneProtection->m_hitFracType == SBoneProtections::HitFraction) + return 1.0f - base; // SOC + + return base; // CS/COP } -float CCustomOutfit::GetHitTypeProtection(ALife::EHitType hit_type, s16 element) +float CCustomOutfit::GetHitTypeProtection(ALife::EHitType hit_type, s16 element) const { - float fBase = m_HitTypeProtection[hit_type] * GetCondition(); - float bone = m_boneProtection->getBoneProtection(element); - return fBase * bone; + const float base = m_HitTypeProtection[hit_type] * GetCondition(); + const float bone = m_boneProtection->getBoneProtection(element); + + if (m_boneProtection->m_hitFracType == SBoneProtections::HitFraction) + return 1.0f - base * bone; // SOC + + return base * bone; // CS/COP +} + +float CCustomOutfit::GetBoneArmor(s16 element) const +{ + return m_boneProtection->getBoneArmor(element); } -float CCustomOutfit::GetBoneArmor(s16 element) { return m_boneProtection->getBoneArmor(element); } float CCustomOutfit::HitThroughArmor(float hit_power, s16 element, float ap, bool& add_wound, ALife::EHitType hit_type) { float NewHitPower = hit_power; - if (hit_type == ALife::eHitTypeFireWound) - { - float ba = GetBoneArmor(element); - if (ba < 0.0f) - return NewHitPower; - float BoneArmor = ba * GetCondition(); - if (/*!fis_zero(ba, EPS) && */ (ap > BoneArmor)) + switch (m_boneProtection->m_hitFracType) + { + default: + case SBoneProtections::HitFractionActorCOP: + { + if (hit_type == ALife::eHitTypeFireWound) { - //Ð¿ÑƒÐ»Ñ Ð¿Ñ€Ð¾Ð±Ð¸Ð»Ð° бронь - if (!IsGameTypeSingle()) + const float ba = GetBoneArmor(element); + if (ba < 0.0f) + return NewHitPower; + + float BoneArmor = ba * GetCondition(); + if (/*!fis_zero(ba, EPS) &&*/ ap > BoneArmor) { - float hit_fraction = (ap - BoneArmor) / ap; - if (hit_fraction < m_boneProtection->m_fHitFracActor) - hit_fraction = m_boneProtection->m_fHitFracActor; + //Ð¿ÑƒÐ»Ñ Ð¿Ñ€Ð¾Ð±Ð¸Ð»Ð° бронь + if (!IsGameTypeSingle()) + { + float hit_fraction = (ap - BoneArmor) / ap; + if (hit_fraction < m_boneProtection->m_fHitFrac) + hit_fraction = m_boneProtection->m_fHitFrac; - NewHitPower *= hit_fraction; - NewHitPower *= m_boneProtection->getBoneProtection(element); + NewHitPower *= hit_fraction; + NewHitPower *= m_boneProtection->getBoneProtection(element); + } + + VERIFY(NewHitPower >= 0.0f); + } + else + { + //Ð¿ÑƒÐ»Ñ ÐЕ пробила бронь + NewHitPower *= m_boneProtection->m_fHitFrac; + add_wound = false; //раны нет + } + } + else + { + float one = 0.1f; + if (hit_type == ALife::eHitTypeStrike || + hit_type == ALife::eHitTypeWound || + hit_type == ALife::eHitTypeWound_2 || + hit_type == ALife::eHitTypeExplosion) + { + one = 1.0f; } + const float protect = GetDefHitTypeProtection(hit_type); + NewHitPower -= protect * one; - VERIFY(NewHitPower >= 0.0f); + if (NewHitPower < 0.f) + NewHitPower = 0.f; + } + + //увеличить изношенноÑть коÑтюма + Hit(hit_power, hit_type); + break; + } + case SBoneProtections::HitFractionActorCS: + { + if (hit_type == ALife::eHitTypeFireWound) + { + const float BoneArmor = m_boneProtection->getBoneArmor(element) * GetCondition(); + + if (ap > EPS && ap > BoneArmor) + { + //Ð¿ÑƒÐ»Ñ Ð¿Ñ€Ð¾Ð±Ð¸Ð»Ð° бронь + const float d_ap = ap - BoneArmor; + NewHitPower *= (d_ap / ap); + + if (NewHitPower < m_boneProtection->m_fHitFrac) + NewHitPower = m_boneProtection->m_fHitFrac; + + if (!IsGameTypeSingle()) + { + NewHitPower *= m_boneProtection->getBoneProtection(element); + } + + if (NewHitPower < 0.0f) + NewHitPower = 0.0f; + } + else + { + //Ð¿ÑƒÐ»Ñ ÐЕ пробила бронь + NewHitPower *= m_boneProtection->m_fHitFrac; + add_wound = false; //раны нет + } } else { - //Ð¿ÑƒÐ»Ñ ÐЕ пробила бронь - NewHitPower *= m_boneProtection->m_fHitFracActor; - add_wound = false; //раны нет + float one = 0.1f; + if (hit_type == ALife::eHitTypeWound || + hit_type == ALife::eHitTypeWound_2 || + hit_type == ALife::eHitTypeExplosion) + { + one = 1.0f; + } + + const float protect = GetHitTypeProtection(hit_type, element); + NewHitPower -= protect * one; + if (NewHitPower < 0.0f) + NewHitPower = 0.0f; } + + //увеличить изношенноÑть коÑтюма + Hit(NewHitPower, hit_type); + break; } - else + case SBoneProtections::HitFraction: { - float one = 0.1f; - if (hit_type == ALife::eHitTypeStrike || hit_type == ALife::eHitTypeWound || - hit_type == ALife::eHitTypeWound_2 || hit_type == ALife::eHitTypeExplosion) + if (hit_type == ALife::eHitTypeFireWound) + { + const float BoneArmor = m_boneProtection->getBoneArmor(element) * GetCondition() * (1 - ap); + NewHitPower -= BoneArmor; + if (NewHitPower < hit_power * m_boneProtection->m_fHitFrac) + NewHitPower = hit_power * m_boneProtection->m_fHitFrac; + } + else { - one = 1.0f; + NewHitPower *= GetHitTypeProtection(hit_type, element); } - float protect = GetDefHitTypeProtection(hit_type); - NewHitPower -= protect * one; - if (NewHitPower < 0.f) - NewHitPower = 0.f; + //увеличить изношенноÑть коÑтюма + Hit(hit_power, hit_type); + break; } - //увеличить изношенноÑть коÑтюма - Hit(hit_power, hit_type); + } // switch (m_boneProtection->m_hitFracType) return NewHitPower; } @@ -220,13 +326,13 @@ void CCustomOutfit::ApplySkinModel(CActor* pActor, bool bDress, bool bHUDOnly) const auto TeamSection = Game().getTeamSection(pActor->g_Team()); if (TeamSection) { - if (pSettings->line_exist(TeamSection, *cNameSect())) + if (pSettings->line_exist(TeamSection, cNameSect().c_str())) { - NewVisual = pSettings->r_string(TeamSection, *cNameSect()); + NewVisual = pSettings->r_string(TeamSection, cNameSect().c_str()); string256 SkinName; xr_strcpy(SkinName, pSettings->r_string("mp_skins_path", "skin_path")); - xr_strcat(SkinName, *NewVisual); + xr_strcat(SkinName, NewVisual.c_str()); xr_strcat(SkinName, ".ogf"); NewVisual._set(SkinName); } @@ -276,7 +382,26 @@ void CCustomOutfit::OnMoveToRuck(const SInvItemPlace& prev) } }; -u32 CCustomOutfit::ef_equipment_type() const { return (m_ef_equipment_type); } +u32 CCustomOutfit::ef_equipment_type() const +{ + return m_ef_equipment_type; +} + +float CCustomOutfit::GetPowerLoss() const +{ + // Hit fraction and power loss are unrelated, + // but it's the only way we can distinguish between SOC/CS and COP. + // Sorry. + if (m_boneProtection->m_hitFracType != SBoneProtections::HitFractionActorCOP) + { + if (m_fPowerLoss < 1 && GetCondition() <= 0) + { + return 1.0f; + } + } + return m_fPowerLoss; +}; + bool CCustomOutfit::install_upgrade_impl(LPCSTR section, bool test) { bool result = inherited::install_upgrade_impl(section, test); @@ -318,10 +443,13 @@ bool CCustomOutfit::install_upgrade_impl(LPCSTR section, bool test) result2 = process_if_exists_set(section, "bones_koeff_protection_add", &CInifile::r_string, str, test); if (result2 && !test) AddBonesProtection(str); - result |= result2; - result |= - process_if_exists(section, "hit_fraction_actor", &CInifile::r_float, m_boneProtection->m_fHitFracActor, test); + + if (m_boneProtection->m_hitFracType == SBoneProtections::HitFractionActorCS || + m_boneProtection->m_hitFracType == SBoneProtections::HitFractionActorCOP) + { + result |= process_if_exists(section, "hit_fraction_actor", &CInifile::r_float, m_boneProtection->m_fHitFrac, test); + } result |= process_if_exists(section, "additional_inventory_weight", &CInifile::r_float, m_additional_weight, test); result |= diff --git a/src/xrGame/CustomOutfit.h b/src/xrGame/CustomOutfit.h index 8fbcf042b6e..882593be31d 100644 --- a/src/xrGame/CustomOutfit.h +++ b/src/xrGame/CustomOutfit.h @@ -6,7 +6,6 @@ struct SBoneProtections; class CCustomOutfit : public CInventoryItemObject { - friend void CCustomOutfit_Export(lua_State* luaState); using inherited = CInventoryItemObject; public: @@ -21,9 +20,13 @@ class CCustomOutfit : public CInventoryItemObject //коÑффициенты на которые домножаетÑÑ Ñ…Ð¸Ñ‚ //при ÑоответÑтвующем типе воздейÑÑ‚Ð²Ð¸Ñ //еÑли на перÑонаже надет коÑтюм - float GetHitTypeProtection(ALife::EHitType hit_type, s16 element); - float GetDefHitTypeProtection(ALife::EHitType hit_type); - float GetBoneArmor(s16 element); + [[nodiscard]] float GetHitTypeProtection(ALife::EHitType hit_type, s16 element) const; + [[nodiscard]] float GetDefHitTypeProtection(ALife::EHitType hit_type) const; + [[nodiscard]] float GetBoneArmor(s16 element) const; + + //коÑффициент на который домножаетÑÑ Ð¿Ð¾Ñ‚ÐµÑ€Ñ Ñилы + //еÑли на перÑонаже надет коÑтюм + [[nodiscard]] float GetPowerLoss() const; float HitThroughArmor(float hit_power, s16 element, float ap, bool& add_wound, ALife::EHitType hit_type); @@ -32,7 +35,7 @@ class CCustomOutfit : public CInventoryItemObject virtual void OnH_A_Chield(); protected: - HitImmunity::HitTypeSVec m_HitTypeProtection; + mutable HitImmunity::HitTypeSVec m_HitTypeProtection; shared_str m_ActorVisual; shared_str m_full_icon_name; @@ -71,4 +74,7 @@ class CCustomOutfit : public CInventoryItemObject protected: virtual bool install_upgrade_impl(LPCSTR section, bool test); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; diff --git a/src/xrGame/CustomOutfit_script.cpp b/src/xrGame/CustomOutfit_script.cpp index 37a0d145fce..66341ab4773 100644 --- a/src/xrGame/CustomOutfit_script.cpp +++ b/src/xrGame/CustomOutfit_script.cpp @@ -1,9 +1,9 @@ #include "pch_script.h" + #include "CustomOutfit.h" #include "ActorHelmet.h" -#include "xrScriptEngine/ScriptExporter.hpp" -void CCustomOutfit_Export(lua_State* luaState) +void CCustomOutfit::script_register(lua_State* luaState) { using namespace luabind; @@ -35,9 +35,7 @@ void CCustomOutfit_Export(lua_State* luaState) ]; } -SCRIPT_EXPORT_FUNC(CCustomOutfit, (CGameObject), CCustomOutfit_Export); - -void CHelmet_Export(lua_State* luaState) +void CHelmet::script_register(lua_State* luaState) { using namespace luabind; @@ -63,5 +61,3 @@ void CHelmet_Export(lua_State* luaState) .def("GetBoneArmor", &CHelmet::GetBoneArmor) ]; } - -SCRIPT_EXPORT_FUNC(CHelmet, (CGameObject), CHelmet_Export); diff --git a/src/xrGame/CustomRocket.cpp b/src/xrGame/CustomRocket.cpp index 1c17a1cb8a5..1c51d254b8e 100644 --- a/src/xrGame/CustomRocket.cpp +++ b/src/xrGame/CustomRocket.cpp @@ -584,7 +584,7 @@ void CCustomRocket::StartEngineParticles() VERIFY(m_pEngineParticles == NULL); if (!m_sEngineParticles) return; - m_pEngineParticles = CParticlesObject::Create(*m_sEngineParticles, FALSE); + m_pEngineParticles = CParticlesObject::Create(m_sEngineParticles.c_str(), FALSE); UpdateParticles(); m_pEngineParticles->Play(false); @@ -608,13 +608,13 @@ void CCustomRocket::StartFlyParticles() if (!m_sFlyParticles) return; - m_pFlyParticles = CParticlesObject::Create(*m_sFlyParticles, FALSE); + m_pFlyParticles = CParticlesObject::Create(m_sFlyParticles.c_str(), FALSE); UpdateParticles(); m_pFlyParticles->Play(false); VERIFY(m_pFlyParticles); - VERIFY3(m_pFlyParticles->IsLooped(), "must be a looped particle system for rocket fly: %s", *m_sFlyParticles); + VERIFY3(m_pFlyParticles->IsLooped(), "must be a looped particle system for rocket fly: %s", m_sFlyParticles.c_str()); } void CCustomRocket::StopFlyParticles() { diff --git a/src/xrGame/CustomZone.cpp b/src/xrGame/CustomZone.cpp index ee5e7a8eeb0..a9284779c03 100644 --- a/src/xrGame/CustomZone.cpp +++ b/src/xrGame/CustomZone.cpp @@ -788,7 +788,7 @@ void CCustomZone::PlayIdleParticles(bool bIdleLight) { m_idle_sound.play_at_pos(0, Position(), true); - if (*m_sIdleParticles) + if (m_sIdleParticles.c_str()) { if (!m_pIdleParticles) { @@ -861,7 +861,7 @@ void CCustomZone::PlayBlowoutParticles() return; CParticlesObject* pParticles; - pParticles = CParticlesObject::Create(*m_sBlowoutParticles, TRUE); + pParticles = CParticlesObject::Create(m_sBlowoutParticles.c_str(), TRUE); pParticles->UpdateParent(XFORM(), zero_vel); pParticles->Play(false); m_fBlowoutTimeLeft = (float)Device.dwTimeGlobal + m_BendGrass_Blowout_time; @@ -1017,7 +1017,7 @@ void CCustomZone::PlayBulletParticles(Fvector& pos) return; CParticlesObject* pParticles; - pParticles = CParticlesObject::Create(*m_sEntranceParticlesSmall, TRUE); + pParticles = CParticlesObject::Create(m_sEntranceParticlesSmall.c_str(), TRUE); Fmatrix M; M = XFORM(); @@ -1385,9 +1385,9 @@ void CCustomZone::ThrowOutArtefact(CArtefact* pArtefact) pArtefact->XFORM().c.set(Position()); pArtefact->XFORM().c.y += m_fArtefactSpawnHeight; - if (*m_sArtefactSpawnParticles) + if (m_sArtefactSpawnParticles.c_str()) { - CParticlesObject* pParticles = CParticlesObject::Create(*m_sArtefactSpawnParticles, TRUE); + CParticlesObject* pParticles = CParticlesObject::Create(m_sArtefactSpawnParticles.c_str(), TRUE); pParticles->UpdateParent(pArtefact->XFORM(), zero_vel); pParticles->Play(false); } @@ -1545,7 +1545,7 @@ void CCustomZone::PlayAccumParticles() if (m_sAccumParticles.size()) { CParticlesObject* pParticles; - pParticles = CParticlesObject::Create(*m_sAccumParticles, TRUE); + pParticles = CParticlesObject::Create(m_sAccumParticles.c_str(), TRUE); pParticles->UpdateParent(XFORM(), zero_vel); pParticles->Play(false); } @@ -1559,7 +1559,7 @@ void CCustomZone::PlayAwakingParticles() if (m_sAwakingParticles.size()) { CParticlesObject* pParticles; - pParticles = CParticlesObject::Create(*m_sAwakingParticles, TRUE); + pParticles = CParticlesObject::Create(m_sAwakingParticles.c_str(), TRUE); pParticles->UpdateParent(XFORM(), zero_vel); pParticles->Play(false); } diff --git a/src/xrGame/DemoInfo.cpp b/src/xrGame/DemoInfo.cpp index ac35c54b8bc..9c1557c864c 100644 --- a/src/xrGame/DemoInfo.cpp +++ b/src/xrGame/DemoInfo.cpp @@ -1,11 +1,13 @@ #include "StdAfx.h" + +#include "xrCore/stream_reader.h" + #include "game_sv_mp.h" #include "game_cl_mp.h" #include "Level.h" #include "DemoInfo.h" -#include "xrCore/stream_reader.h" + #include "Common/object_broker.h" -#include "xrScriptEngine/ScriptExporter.hpp" LPCSTR GameTypeToString(EGameIDs gt, bool bShort); @@ -172,7 +174,7 @@ demo_player_info const* demo_info::get_player(u32 player_index) const return m_players[player_index]; } -SCRIPT_EXPORT(demo_player_info, (), +void demo_player_info::script_register(lua_State* luaState) { using namespace luabind; @@ -187,9 +189,9 @@ SCRIPT_EXPORT(demo_player_info, (), .def("get_team", &demo_player_info::get_team) .def("get_rank", &demo_player_info::get_rank) ]; -}); +} -SCRIPT_EXPORT(demo_info, (), +void demo_info::script_register(lua_State* luaState) { using namespace luabind; @@ -204,4 +206,4 @@ SCRIPT_EXPORT(demo_info, (), .def("get_players_count", &demo_info::get_players_count) .def("get_player", &demo_info::get_player) ]; -}); +} diff --git a/src/xrGame/DemoInfo.h b/src/xrGame/DemoInfo.h index 731299277cb..0c43be43cbe 100644 --- a/src/xrGame/DemoInfo.h +++ b/src/xrGame/DemoInfo.h @@ -43,6 +43,9 @@ class demo_player_info : private Noncopyable u8 const get_team() const { return m_team; }; u8 const get_rank() const { return m_rank; }; static u32 const demo_info_max_size; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; // class demo_player_info class demo_info : private Noncopyable @@ -77,6 +80,9 @@ class demo_info : private Noncopyable demo_player_info const* get_player(u32 player_index) const; static u32 const max_demo_info_size; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; // class DemoInfo #endif //#ifndef DEMOINFO_H diff --git a/src/xrGame/EffectorZoomInertion.cpp b/src/xrGame/EffectorZoomInertion.cpp index 6b15257d7c4..5aed72c25b6 100644 --- a/src/xrGame/EffectorZoomInertion.cpp +++ b/src/xrGame/EffectorZoomInertion.cpp @@ -64,7 +64,7 @@ void CEffectorZoomInertion::Init(CWeaponMagazined* pWeapon) if (!pWeapon) return; - LoadParams(*pWeapon->cNameSect(), "ezi_"); + LoadParams(pWeapon->cNameSect().c_str(), "ezi_"); }; void CEffectorZoomInertion::SetParams(float disp) diff --git a/src/xrGame/Entity.cpp b/src/xrGame/Entity.cpp index b140bbfb758..ea53ed2b6a7 100644 --- a/src/xrGame/Entity.cpp +++ b/src/xrGame/Entity.cpp @@ -197,7 +197,7 @@ bool CEntity::net_Spawn(CSE_Abstract* DC) if (monster) { MONSTER_COMMUNITY monster_community; - monster_community.set(pSettings->r_string(*cNameSect(), "species")); + monster_community.set(pSettings->r_string(cNameSect().c_str(), "species")); if (monster_community.team() != NO_COMMUNITY_INDEX) id_Team = monster_community.team(); @@ -273,14 +273,14 @@ void CEntity::KillEntity(u16 whoID, bool bypass_actor_check) #ifdef DEBUG if (m_killer_id != ALife::_OBJECT_ID(-1)) { - Msg("! Entity [%s][%s] already has killer with id %d, but new killer id arrived - %d", *cNameSect(), - *cName(), m_killer_id, whoID); + Msg("! Entity [%s][%s] already has killer with id %d, but new killer id arrived - %d", cNameSect().c_str(), + cName().c_str(), m_killer_id, whoID); IGameObject* old_killer = Level().Objects.net_Find(m_killer_id); - Msg("! Old killer is %s", old_killer ? *old_killer->cName() : "unknown"); + Msg("! Old killer is %s", old_killer ? old_killer->cName().c_str() : "unknown"); IGameObject* new_killer = Level().Objects.net_Find(whoID); - Msg("! New killer is %s", new_killer ? *new_killer->cName() : "unknown"); + Msg("! New killer is %s", new_killer ? new_killer->cName().c_str() : "unknown"); VERIFY(m_killer_id == ALife::_OBJECT_ID(-1)); } diff --git a/src/xrGame/EntityCondition.cpp b/src/xrGame/EntityCondition.cpp index 5bc7c71be59..9e818f01fa7 100644 --- a/src/xrGame/EntityCondition.cpp +++ b/src/xrGame/EntityCondition.cpp @@ -328,7 +328,7 @@ float CEntityCondition::HitPowerEffect(float power_loss) if (!pOutfit) return power_loss * 0.5f; - float new_power_loss = power_loss * pOutfit->m_fPowerLoss; + const float new_power_loss = power_loss * pOutfit->GetPowerLoss(); return new_power_loss; } diff --git a/src/xrGame/Explosive.cpp b/src/xrGame/Explosive.cpp index ff6a41591c1..eb5a8e9ca2c 100644 --- a/src/xrGame/Explosive.cpp +++ b/src/xrGame/Explosive.cpp @@ -363,7 +363,7 @@ void CExplosive::Explode() explode_matrix.c.set(pos); CParticlesObject* pStaticPG; - pStaticPG = CParticlesObject::Create(*m_sExplodeParticles, !m_bDynamicParticles); + pStaticPG = CParticlesObject::Create(m_sExplodeParticles.c_str(), !m_bDynamicParticles); if (m_bDynamicParticles) m_pExpParticle = pStaticPG; pStaticPG->UpdateParent(explode_matrix, vel); @@ -393,8 +393,8 @@ void CExplosive::Explode() CCartridge cartridge; cartridge.param_s.kDist = 1.f; cartridge.param_s.kHit = 1.f; - //. cartridge.param_s.kCritical = 1.f; cartridge.param_s.kImpulse = 1.f; + cartridge.param_s.kPierce = 1.f; cartridge.param_s.kAP = 1.f; cartridge.param_s.fWallmarkSize = fWallmarkSize; cartridge.bullet_material_idx = GMLib.GetMaterialIdx(WEAPON_MATERIAL_NAME); diff --git a/src/xrGame/Explosive.h b/src/xrGame/Explosive.h index a0d7335d0e7..b525a1d37bd 100644 --- a/src/xrGame/Explosive.h +++ b/src/xrGame/Explosive.h @@ -119,12 +119,12 @@ class CExplosive : public IDamageSource //ВремÑ, через которое надо Ñделать взрывчатку невиимой, еÑли она не ÑтановитÑÑ Ð½ÐµÐ²Ð¸Ð´Ð¸Ð¼Ð¾Ð¹ во Ð²Ñ€ÐµÐ¼Ñ Ð²Ð·Ñ€Ñ‹Ð²Ð° float m_fExplodeHideDurationMax; //флаг ÑоÑтоÑÐ½Ð¸Ñ Ð²Ð·Ñ€Ñ‹Ð²Ð° - enum + enum : u8 { - flExploding = 1 << 0, + flExploding = 1 << 0, flExplodEventSent = 1 << 1, - flReadyToExplode = 1 << 2, - flExploded = 1 << 3 + flReadyToExplode = 1 << 2, + flExploded = 1 << 3, }; Flags8 m_explosion_flags; /////////////////////////////////////////////// @@ -167,6 +167,9 @@ class CExplosive : public IDamageSource { shared_str effect_sect_name; } effector; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; void random_point_in_object_box(Fvector& out_pos, IGameObject* obj); diff --git a/src/xrGame/ExplosiveItem.cpp b/src/xrGame/ExplosiveItem.cpp index 54af0f1eb2e..6203631f8fb 100644 --- a/src/xrGame/ExplosiveItem.cpp +++ b/src/xrGame/ExplosiveItem.cpp @@ -47,7 +47,7 @@ void CExplosiveItem::Hit(SHit* pHDS) void CExplosiveItem::StartTimerEffects() { CParticlesPlayer::StartParticles( - pSettings->r_string(*cNameSect(), "set_timer_particles"), Fvector().set(0, 1, 0), ID()); + pSettings->r_string(cNameSect().c_str(), "set_timer_particles"), Fvector().set(0, 1, 0), ID()); } void CExplosiveItem::OnEvent(NET_Packet& P, u16 type) { diff --git a/src/xrGame/ExplosiveScript.cpp b/src/xrGame/ExplosiveScript.cpp index c6671436926..981975c9e51 100644 --- a/src/xrGame/ExplosiveScript.cpp +++ b/src/xrGame/ExplosiveScript.cpp @@ -1,8 +1,8 @@ #include "pch_script.h" + #include "Explosive.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CExplosive, (), +void CExplosive::script_register(lua_State* luaState) { using namespace luabind; @@ -11,4 +11,4 @@ SCRIPT_EXPORT(CExplosive, (), class_("explosive") .def("explode", &CExplosive::Explode) ]; -}); +} diff --git a/src/xrGame/F1.h b/src/xrGame/F1.h index 30a36e578aa..a776e836518 100644 --- a/src/xrGame/F1.h +++ b/src/xrGame/F1.h @@ -9,4 +9,7 @@ class CF1 : public CGrenade public: CF1() {} virtual ~CF1() {} + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject, CExplosive); }; diff --git a/src/xrGame/GameObject.h b/src/xrGame/GameObject.h index d22ad1a801b..7ddc4836f4c 100644 --- a/src/xrGame/GameObject.h +++ b/src/xrGame/GameObject.h @@ -7,14 +7,15 @@ #define AFX_GAMEOBJECT_H__3DA72D03_C759_4688_AEBB_89FA812AA873__INCLUDED_ #include "xrEngine/xr_object.h" + #include "xrServer_Space.h" #include "alife_space.h" -#include "xrScriptEngine/script_space_forward.hpp" -#include "xrScriptEngine/DebugMacros.hpp" // XXX: move debug macros to xrCore #include "script_binder.h" #include "Hit.h" #include "game_object_space.h" +#include "xrScriptEngine/script_space_forward.hpp" + class CPhysicsShell; class CSE_Abstract; class CPHSynchronize; @@ -197,7 +198,7 @@ class CGameObject : public IGameObject, virtual CEntity* cast_entity() override { return NULL; } virtual CEntityAlive* cast_entity_alive() override { return NULL; } virtual CActor* cast_actor() override { return NULL; } - virtual CGameObject* cast_game_object() override { return this; } + CGameObject* cast_game_object() { return this; } virtual CCustomZone* cast_custom_zone() override { return NULL; } virtual CPhysicsShellHolder* cast_physics_shell_holder() override { return NULL; } virtual IInputReceiver* cast_input_receiver() override { return NULL; } @@ -383,6 +384,9 @@ class CGameObject : public IGameObject, u32 new_level_vertex_id() const; void update_ai_locations(bool decrement_reference); void SetKinematicsCallback(bool set); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #pragma pack(pop) diff --git a/src/xrGame/GameTask.h b/src/xrGame/GameTask.h index 930005bf45d..443a3cc0e4b 100644 --- a/src/xrGame/GameTask.h +++ b/src/xrGame/GameTask.h @@ -1,7 +1,8 @@ #pragma once + #include "encyclopedia_article_defs.h" #include "GameTaskDefs.h" -struct lua_State; + // XXX: include "xrScriptEngine/script_space_forward.hpp" into Functor.hpp, define functor #include "xrScriptEngine/Functor.hpp" @@ -211,4 +212,7 @@ class CGameTask final : public SGameTaskObjective, public Noncopyable void AddObjective_script(SGameTaskObjective* O); SGameTaskObjective* GetObjective_script(TASK_OBJECTIVE_ID objective_id); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; diff --git a/src/xrGame/GameTask_script.cpp b/src/xrGame/GameTask_script.cpp index 5bd95580e8b..9e803bc3fd4 100644 --- a/src/xrGame/GameTask_script.cpp +++ b/src/xrGame/GameTask_script.cpp @@ -1,6 +1,6 @@ #include "pch_script.h" + #include "GameTask.h" -#include "xrScriptEngine/ScriptExporter.hpp" void CGameTask::AddObjective_script(SGameTaskObjective* O) { @@ -13,7 +13,7 @@ SGameTaskObjective* CGameTask::GetObjective_script(TASK_OBJECTIVE_ID objective_i return &Objective(objective_id); } -SCRIPT_EXPORT(CGameTask, (), +void CGameTask::script_register(lua_State* luaState) { using namespace luabind; using namespace luabind::policy; @@ -96,9 +96,9 @@ SCRIPT_EXPORT(CGameTask, (), .def("get_objective", &CGameTask::GetObjective_script) .def("get_objectives_cnt", &CGameTask::GetObjectivesCount) - .def("get_objectives_cnt", +[](CGameTask* self) + .def("get_objectives_cnt", +[](const CGameTask* self) { return self->GetObjectivesCount(false); }) ]; -}); +} diff --git a/src/xrGame/HUDTarget.cpp b/src/xrGame/HUDTarget.cpp index a046025a6c4..4f1cd800fd0 100644 --- a/src/xrGame/HUDTarget.cpp +++ b/src/xrGame/HUDTarget.cpp @@ -186,8 +186,8 @@ void CHUDTarget::Render() if (fuzzyShowInfo > 0.5f) { F->SetColor(subst_alpha(C, u8(iFloor(255.f * (fuzzyShowInfo - 0.5f) * 2.f)))); - F->OutNext("%s", *StringTable().translate(others_inv_owner->Name())); - F->OutNext("%s", *StringTable().translate(others_inv_owner->CharacterInfo().Community().id())); + F->OutNext("%s", StringTable().translate(others_inv_owner->Name()).c_str()); + F->OutNext("%s", StringTable().translate(others_inv_owner->CharacterInfo().Community().id()).c_str()); } } @@ -238,7 +238,7 @@ void CHUDTarget::Render() const int alpha_C = iFloor(255.f * (fuzzyShowInfo - 0.5f) * 2.f); const u8 alpha_b = u8(alpha_C & 0x00ff); F->SetColor(subst_alpha(C, alpha_b)); - F->OutNext("%s", *PP.RQ.O->cName()); + F->OutNext("%s", PP.RQ.O->cName().c_str()); } } }; diff --git a/src/xrGame/HairsZone.h b/src/xrGame/HairsZone.h index 3b139c0439d..f2cc75df8db 100644 --- a/src/xrGame/HairsZone.h +++ b/src/xrGame/HairsZone.h @@ -16,4 +16,7 @@ class CHairsZone : public CVisualZone float m_min_speed_to_react; virtual bool BlowoutState(); virtual void CheckForAwaking(); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; diff --git a/src/xrGame/HairsZone_script.cpp b/src/xrGame/HairsZone_script.cpp index 82e2ef2856c..631e887e9cc 100644 --- a/src/xrGame/HairsZone_script.cpp +++ b/src/xrGame/HairsZone_script.cpp @@ -1,10 +1,10 @@ #include "pch_script.h" + #include "HairsZone.h" #include "AmebaZone.h" #include "NoGravityZone.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CHairsZone, (CGameObject), +void CHairsZone::script_register(lua_State* luaState) { using namespace luabind; @@ -17,4 +17,4 @@ SCRIPT_EXPORT(CHairsZone, (CGameObject), class_("CNoGravityZone") .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/HangingLamp.cpp b/src/xrGame/HangingLamp.cpp index 097d1f93f32..fa0102810fa 100644 --- a/src/xrGame/HangingLamp.cpp +++ b/src/xrGame/HangingLamp.cpp @@ -1,4 +1,5 @@ #include "pch_script.h" + #include "HangingLamp.h" #include "xrEngine/LightAnimLibrary.h" #include "xrEngine/xr_collide_form.h" @@ -10,7 +11,6 @@ #include "game_object_space.h" #include "xrScriptEngine/script_callback_ex.h" #include "script_game_object.h" -#include "xrScriptEngine/ScriptExporter.hpp" ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -406,9 +406,14 @@ void CHangingLamp::CreateBody(CSE_ALifeObjectHangingLamp* lamp) void CHangingLamp::net_Export(NET_Packet& P) { VERIFY(Local()); } void CHangingLamp::net_Import(NET_Packet& P) { VERIFY(Remote()); } bool CHangingLamp::UsedAI_Locations() { return (FALSE); } -SCRIPT_EXPORT(CHangingLamp, (CGameObject), { - luabind::module(luaState)[luabind::class_("hanging_lamp") - .def(luabind::constructor<>()) - .def("turn_on", &CHangingLamp::TurnOn) - .def("turn_off", &CHangingLamp::TurnOff)]; -}); + +void CHangingLamp::script_register(lua_State* luaState) +{ + luabind::module(luaState) + [ + luabind::class_("hanging_lamp") + .def(luabind::constructor<>()) + .def("turn_on", &CHangingLamp::TurnOn) + .def("turn_off", &CHangingLamp::TurnOff) + ]; +} diff --git a/src/xrGame/HangingLamp.h b/src/xrGame/HangingLamp.h index 12e768e76da..a5e8f4dcc97 100644 --- a/src/xrGame/HangingLamp.h +++ b/src/xrGame/HangingLamp.h @@ -65,6 +65,9 @@ class CHangingLamp : public CPhysicsShellHolder, public CPHSkeleton virtual void Center(Fvector& C) const; virtual float Radius() const; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; #endif // HangingLampH diff --git a/src/xrGame/HelicopterWeapon.cpp b/src/xrGame/HelicopterWeapon.cpp index 0d12943bf5f..a277505e719 100644 --- a/src/xrGame/HelicopterWeapon.cpp +++ b/src/xrGame/HelicopterWeapon.cpp @@ -56,14 +56,14 @@ void CHelicopter::MGunUpdateFire() float time_f = Device.fTimeGlobal - delta_t; float fire_time; - if (pSettings->line_exist(*cNameSect(), "fire_time")) - fire_time = pSettings->r_float(*cNameSect(), "fire_time"); + if (pSettings->line_exist(cNameSect(), "fire_time")) + fire_time = pSettings->r_float(cNameSect(), "fire_time"); else fire_time = -1; float no_fire_time; - if (pSettings->line_exist(*cNameSect(), "no_fire_time")) - no_fire_time = pSettings->r_float(*cNameSect(), "no_fire_time"); + if (pSettings->line_exist(cNameSect(), "no_fire_time")) + no_fire_time = pSettings->r_float(cNameSect(), "no_fire_time"); else no_fire_time = -1; @@ -134,7 +134,7 @@ void CHelicopter::OnShot() dist = (m_enemy.fire_trail_length_curr / 2.0f) - dist; } - static float fire_trace_width = pSettings->r_float(*cNameSect(), "fire_trace_width"); + static float fire_trace_width = pSettings->r_float(cNameSect(), "fire_trace_width"); enemy_pos.mad(fd, dist); Fvector disp_dir; disp_dir.random_point(fire_trace_width); diff --git a/src/xrGame/Level.cpp b/src/xrGame/Level.cpp index 19f025daeae..08857070f7d 100644 --- a/src/xrGame/Level.cpp +++ b/src/xrGame/Level.cpp @@ -29,7 +29,6 @@ #include "ClimableObject.h" #include "xrAICore/Navigation/level_graph.h" #include "mt_config.h" -#include "PHCommander.h" #include "map_manager.h" #include "xrEngine/CameraManager.h" #include "level_sounds.h" @@ -47,6 +46,7 @@ #include "DemoInfo.h" #include "CustomDetector.h" #include "xrPhysics/IPHWorld.h" +#include "xrPhysics/PHCommander.h" #include "xrPhysics/console_vars.h" #include "xrNetServer/NET_Messages.h" #include "xrEngine/GameFont.h" @@ -129,7 +129,6 @@ CLevel::~CLevel() if (physics_world()) { destroy_physics_world(); - xr_delete(m_ph_commander_physics_worldstep); } // destroy PSs for (auto& ps : m_StaticParticles) diff --git a/src/xrGame/Level.h b/src/xrGame/Level.h index 938436244f8..c3788fb4f49 100644 --- a/src/xrGame/Level.h +++ b/src/xrGame/Level.h @@ -115,7 +115,6 @@ class CLevel : public IGame_Level, public IPureClient #endif CPHCommander* m_ph_commander = nullptr; CPHCommander* m_ph_commander_scripts = nullptr; - CPHCommander* m_ph_commander_physics_worldstep = nullptr; // Local events EVENT eChangeRP; @@ -356,7 +355,6 @@ class CLevel : public IGame_Level, public IPureClient void script_gc(); // GC-cycle IC CPHCommander& ph_commander(); IC CPHCommander& ph_commander_scripts(); - IC CPHCommander& ph_commander_physics_worldstep(); CLevel(); virtual ~CLevel(); @@ -435,6 +433,9 @@ class CLevel : public IGame_Level, public IPureClient #ifdef DEBUG LevelGraphDebugRender* GetLevelGraphDebugRender() const { return levelGraphDebugRender; } #endif + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; // XXX nitrocaster: should not cast to inherited @@ -490,10 +491,4 @@ IC CPHCommander& CLevel::ph_commander_scripts() return *m_ph_commander_scripts; } -IC CPHCommander& CLevel::ph_commander_physics_worldstep() -{ - VERIFY(m_ph_commander_scripts); - return *m_ph_commander_physics_worldstep; -} - extern bool g_bDebugEvents; diff --git a/src/xrGame/Level_Bullet_Manager.cpp b/src/xrGame/Level_Bullet_Manager.cpp index f04b2b09ae6..75306cce6db 100644 --- a/src/xrGame/Level_Bullet_Manager.cpp +++ b/src/xrGame/Level_Bullet_Manager.cpp @@ -28,13 +28,13 @@ float const CBulletManager::parent_ignore_distance = 3.f; #ifdef DEBUG float air_resistance_epsilon = .1f; #else // #ifdef DEBUG -static float const air_resistance_epsilon = .1f; +constexpr float air_resistance_epsilon = .1f; #endif // #ifdef DEBUG float g_bullet_time_factor = 1.f; SBullet::SBullet(const Fvector& position, const Fvector& direction, float starting_speed, float power, - /*float power_critical,*/ float impulse, u16 sender_id, u16 sendersweapon_id, ALife::EHitType e_hit_type, - float maximum_distance, const CCartridge& cartridge, float const air_resistance_factor, bool SendHit, int iShotNum /*= 0*/) + float impulse, u16 sender_id, u16 sendersweapon_id, ALife::EHitType e_hit_type, float maximum_distance, + const CCartridge& cartridge, float const air_resistance_factor, bool SendHit, int iShotNum /*= 0*/) { bullet_pos = position; speed = max_speed = starting_speed; @@ -67,7 +67,7 @@ SBullet::SBullet(const Fvector& position, const Fvector& direction, float starti VERIFY(u16(-1) != bullet_material_idx); //Alundaio: Tracer for every 5th bullet - if (flags.allow_tracer && cartridge.m_4to1_tracer && iShotNum % 5 != 0) + if (flags.allow_tracer && cartridge.m_flags.test(CCartridge::cf4to1Tracer) && iShotNum % 5 != 0) flags.allow_tracer = false; //-Alundaio @@ -153,7 +153,7 @@ void CBulletManager::PlayExplodePS(const Fmatrix& xf) return; shared_str const& ps_name = m_ExplodeParticles[Random.randI(0, m_ExplodeParticles.size())]; - CParticlesObject* const ps = CParticlesObject::Create(*ps_name, TRUE); + CParticlesObject* const ps = CParticlesObject::Create(ps_name.c_str(), TRUE); ps->UpdateParent(xf, zero_vel); GamePersistent().ps_needtoplay.push_back(ps); } @@ -178,7 +178,6 @@ void CBulletManager::Clear() } void CBulletManager::AddBullet(const Fvector& position, const Fvector& direction, float starting_speed, float power, - //. float power_critical, float impulse, u16 sender_id, u16 sendersweapon_id, ALife::EHitType e_hit_type, float maximum_distance, const CCartridge& cartridge, float const air_resistance_factor, bool SendHit, bool AimBullet, int iShotNum /*= 0*/) { @@ -190,7 +189,7 @@ void CBulletManager::AddBullet(const Fvector& position, const Fvector& direction VERIFY(u16(-1) != cartridge.bullet_material_idx); // u32 CurID = Level().CurrentControlEntity()->ID(); // u32 OwnerID = sender_id; - SBullet& bullet = m_Bullets.emplace_back(position, direction, starting_speed, power, /*power_critical,*/ impulse, sender_id, + SBullet& bullet = m_Bullets.emplace_back(position, direction, starting_speed, power, impulse, sender_id, sendersweapon_id, e_hit_type, maximum_distance, cartridge, air_resistance_factor, SendHit, iShotNum); // bullet.frame_num = Device.dwFrame; bullet.flags.aim_bullet = AimBullet; @@ -562,6 +561,13 @@ static void update_bullet( update_bullet_parabolic(bullet, data, gravity, air_resistance); } +// callback Ñ„ÑƒÐ½ÐºÑ†Ð¸Ñ +// result.O; // 0-static else IGameObject* +// result.range; // range from start to element +// result.element; // if (O) "num tri" else "num bone" +// params; // user defined abstract data +// Device.Statistic.TEST0.End(); +// return TRUE-продолжить траÑÑировку / FALSE-закончить траÑÑировку bool CBulletManager::firetrace_callback(collide::rq_result& result, LPVOID params) { bullet_test_callback_data& data = *(bullet_test_callback_data*)params; diff --git a/src/xrGame/Level_Bullet_Manager.h b/src/xrGame/Level_Bullet_Manager.h index 67c9fe8a213..c1351949023 100644 --- a/src/xrGame/Level_Bullet_Manager.h +++ b/src/xrGame/Level_Bullet_Manager.h @@ -62,30 +62,36 @@ struct SBullet //------------------------------------------------------------------- float max_speed; // maxspeed*cartridge float max_dist; // maxdist*cartridge - float armor_piercing; // ap + float material_piercing; + float armor_piercing; float wallmark_size; //------------------------------------------------------------------- - u8 m_u8ColorID; //тип наноÑимого хита ALife::EHitType hit_type; //--------------------------------- u32 m_dwID; - ref_sound m_whine_snd; - ref_sound m_mtl_snd; //--------------------------------- u16 targetID{}; + u8 m_u8ColorID; //--------------------------------- bool density_mode{}; float density; Fvector begin_density; - bool operator==(u32 ID) { return ID == m_dwID; } + + ref_sound m_whine_snd; + ref_sound m_mtl_snd; + + [[nodiscard]] + bool operator==(const u32 id) const { return id == m_dwID; } + public: - SBullet(const Fvector& position, const Fvector& direction, float start_speed, float power, - /*float power_critical,*/ float impulse, u16 sender_id, u16 sendersweapon_id, ALife::EHitType e_hit_type, - float maximum_distance, const CCartridge& cartridge, float const air_resistance_factor, bool SendHit, int iShotNum = 0); + SBullet(const Fvector& position, const Fvector& direction, float starting_speed, float power, + float impulse, u16 sender_id, u16 sendersweapon_id, ALife::EHitType e_hit_type, float maximum_distance, + const CCartridge& cartridge, float const air_resistance_factor, bool SendHit, int iShotNum = 0); - bool CanBeRenderedNow() const { return (Device.dwFrame > init_frame_num); } + [[nodiscard]] + bool CanBeRenderedNow() const { return Device.dwFrame > init_frame_num; } }; class CLevel; @@ -205,7 +211,7 @@ class CBulletManager void Load(); void Clear(); void AddBullet(const Fvector& position, const Fvector& direction, float starting_speed, float power, - /*float power_critical,*/ float impulse, u16 sender_id, u16 sendersweapon_id, ALife::EHitType e_hit_type, + float impulse, u16 sender_id, u16 sendersweapon_id, ALife::EHitType e_hit_type, float maximum_distance, const CCartridge& cartridge, float const air_resistance_factor, bool SendHit, bool AimBullet = false, int iShotNum = 0); diff --git a/src/xrGame/Level_bullet_manager_firetrace.cpp b/src/xrGame/Level_bullet_manager_firetrace.cpp index 6bbcfede7e4..032bbb4266b 100644 --- a/src/xrGame/Level_bullet_manager_firetrace.cpp +++ b/src/xrGame/Level_bullet_manager_firetrace.cpp @@ -161,19 +161,11 @@ bool CBulletManager::test_callback(const collide::ray_defs& rd, IGameObject* obj return bRes; } -// callback Ñ„ÑƒÐ½ÐºÑ†Ð¸Ñ -// result.O; // 0-static else IGameObject* -// result.range; // range from start to element -// result.element; // if (O) "num tri" else "num bone" -// params; // user defined abstract data -// Device.Statistic.TEST0.End(); -// return TRUE-продолжить траÑÑировку / FALSE-закончить траÑÑировку - void CBulletManager::FireShotmark(SBullet* bullet, const Fvector& vDir, const Fvector& vEnd, collide::rq_result& R, u16 target_material, const Fvector& vNormal, bool ShowMark) { SGameMtlPair* mtl_pair = GMLib.GetMaterialPairByIndices(bullet->bullet_material_idx, target_material); - Fvector particle_dir = vNormal; + Fvector particle_dir; if (R.O) { @@ -205,6 +197,7 @@ void CBulletManager::FireShotmark(SBullet* bullet, const Fvector& vDir, const Fv else { //вычиÑлить нормаль к пораженной поверхноÑти + particle_dir = vNormal; Fvector* pVerts = Level().ObjectSpace.GetStaticVerts(); CDB::TRI* pTri = Level().ObjectSpace.GetStaticTris() + R.element; @@ -229,7 +222,7 @@ void CBulletManager::FireShotmark(SBullet* bullet, const Fvector& vDir, const Fv LPCSTR ps_name = (!mtl_pair || mtl_pair->CollideParticles.empty()) ? NULL : - *mtl_pair->CollideParticles[::Random.randI(0, mtl_pair->CollideParticles.size())]; + mtl_pair->CollideParticles[::Random.randI(0, mtl_pair->CollideParticles.size())].c_str(); SGameMtl* tgt_mtl = GMLib.GetMaterialByIdx(target_material); BOOL bStatic = !tgt_mtl->Flags.test(SGameMtl::flDynamic); @@ -320,7 +313,7 @@ void CBulletManager::DynamicObjectHit(CBulletManager::_event& E) if (V) { - VERIFY3(V->LL_GetBoneVisible(u16(E.R.element)), *E.R.O->cNameVisual(), V->LL_BoneName_dbg(u16(E.R.element))); + VERIFY3(V->LL_GetBoneVisible(u16(E.R.element)), E.R.O->cNameVisual().c_str(), V->LL_BoneName_dbg(u16(E.R.element))); Fmatrix& m_bone = (V->LL_GetBoneInstance(u16(E.R.element))).mTransform; Fmatrix m_inv_bone; m_inv_bone.invert(m_bone); @@ -376,8 +369,7 @@ bool CBulletManager::ObjectHit(SBullet_Hit* hit_res, SBullet* bullet, const Fvec if (R.O) { //вернуть нормаль по которой играть партиклы - CCF_Skeleton* skeleton = smart_cast(R.O->GetCForm()); - if (skeleton) + if (CCF_Skeleton* skeleton = smart_cast(R.O->GetCForm())) { Fvector e_center; hit_normal.set(0, 0, 0); diff --git a/src/xrGame/Level_network.cpp b/src/xrGame/Level_network.cpp index eda2d6e3688..c6f8664726f 100644 --- a/src/xrGame/Level_network.cpp +++ b/src/xrGame/Level_network.cpp @@ -4,7 +4,6 @@ #include "xrServer.h" #include "xrMessages.h" #include "game_cl_base.h" -#include "PHCommander.h" #include "NET_Queue.h" #include "MainMenu.h" #include "space_restriction_manager.h" @@ -21,6 +20,7 @@ #include "xrNetServer/NET_Messages.h" #include "xrPhysics/PhysicsCommon.h" +#include "xrPhysics/PHCommander.h" const int max_objects_size = 2 * 1024; const int max_objects_size_in_save = 8 * 1024; diff --git a/src/xrGame/Level_network_start_client.cpp b/src/xrGame/Level_network_start_client.cpp index c932b29f3e6..c32bbd92e1b 100644 --- a/src/xrGame/Level_network_start_client.cpp +++ b/src/xrGame/Level_network_start_client.cpp @@ -11,9 +11,8 @@ #include "xrNetServer/NET_Messages.h" #include "xrPhysics/IPHWorld.h" - -#include "PHCommander.h" #include "physics_game.h" + extern pureFrame* g_pNetProcessor; bool CLevel::net_Start_client(const char* options) { return false; } @@ -26,8 +25,8 @@ bool CLevel::net_start_client1() // name_of_server string64 name_of_server = ""; // xr_strcpy (name_of_server,*m_caClientOptions); - if (strchr(*m_caClientOptions, '/')) - strncpy_s(name_of_server, *m_caClientOptions, strchr(*m_caClientOptions, '/') - *m_caClientOptions); + if (strchr(m_caClientOptions.c_str(), '/')) + strncpy_s(name_of_server, m_caClientOptions.c_str(), strchr(m_caClientOptions.c_str(), '/') - m_caClientOptions.c_str()); if (strchr(name_of_server, '/')) *strchr(name_of_server, '/') = 0; @@ -60,7 +59,7 @@ bool CLevel::net_start_client2() } } - connected_to_server = Connect2Server(*m_caClientOptions); + connected_to_server = Connect2Server(m_caClientOptions.c_str()); return true; } @@ -138,13 +137,10 @@ bool CLevel::net_start_client4() // Send physics to single or multithreaded mode - create_physics_world(!!psDeviceFlags.test(mtPhysics), &ObjectSpace, &Objects); + create_physics_world(psDeviceFlags.test(mtPhysics), &ObjectSpace, &Objects); R_ASSERT(physics_world()); - m_ph_commander_physics_worldstep = xr_new(); - physics_world()->set_update_callback(m_ph_commander_physics_worldstep); - physics_world()->set_default_contact_shotmark(ContactShotMark); physics_world()->set_default_character_contact_shotmark(CharacterContactShotMark); diff --git a/src/xrGame/MainMenu.cpp b/src/xrGame/MainMenu.cpp index c6acfd8874e..220287563a8 100644 --- a/src/xrGame/MainMenu.cpp +++ b/src/xrGame/MainMenu.cpp @@ -294,7 +294,7 @@ bool CMainMenu::ReloadUI() m_startDialog->HideDialog(); CleanInternals(); } - IFactoryObject* dlg = NEW_INSTANCE(TEXT2CLSID("MAIN_MNU")); + IFactoryObject* dlg = NEW_INSTANCE(xray::make_clsid("MAIN_MNU")); if (!dlg) { m_Flags.set(flActive | flNeedChangeCapture, FALSE); diff --git a/src/xrGame/MainMenu.h b/src/xrGame/MainMenu.h index 53e1d3731fd..2aadfcabf7e 100644 --- a/src/xrGame/MainMenu.h +++ b/src/xrGame/MainMenu.h @@ -200,6 +200,9 @@ class CMainMenu : public IMainMenu, demo_info const* GetDemoInfo(LPCSTR file_name); CEventNotifierCallback::CID m_script_reset_event_cid; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CDialogHolder); }; extern CMainMenu* MainMenu(); diff --git a/src/xrGame/Mincer.cpp b/src/xrGame/Mincer.cpp index 302d3ddd9d6..5451739b0b4 100644 --- a/src/xrGame/Mincer.cpp +++ b/src/xrGame/Mincer.cpp @@ -114,7 +114,7 @@ void CMincer::NotificateDestroy(CPHDestroyableNotificate* dn) CPhysicsShellHolder* obj = dn->PPhysicsShellHolder(); m_telekinetics.draw_out_impact(dir, impulse); CParticlesPlayer* PP = smart_cast(obj); - if (PP && *m_torn_particles) + if (PP && m_torn_particles.c_str()) { PP->StartParticles(m_torn_particles, Fvector().set(0, 1, 0), ID()); } diff --git a/src/xrGame/Mincer.h b/src/xrGame/Mincer.h index 0f625095e68..ebcb770e560 100644 --- a/src/xrGame/Mincer.h +++ b/src/xrGame/Mincer.h @@ -42,4 +42,7 @@ class CMincer : public CBaseGraviZone, public CPHDestroyableNotificator virtual void Center(Fvector& C) const; virtual void NotificateDestroy(CPHDestroyableNotificate* dn); virtual float BlowoutRadiusPercent(CPhysicsShellHolder* GO); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; diff --git a/src/xrGame/Missile.cpp b/src/xrGame/Missile.cpp index 8bbff88cb24..3dda567c853 100644 --- a/src/xrGame/Missile.cpp +++ b/src/xrGame/Missile.cpp @@ -143,8 +143,8 @@ void CMissile::spawn_fake_missile() if (!getDestroy()) { - CSE_Abstract* object = Level().spawn_item( - *cNameSect(), Position(), (GEnv.isDedicatedServer) ? u32(-1) : ai_location().level_vertex_id(), ID(), true); + CSE_Abstract* object = Level().spawn_item(cNameSect().c_str(), Position(), + GEnv.isDedicatedServer ? u32(-1) : ai_location().level_vertex_id(), ID(), true); CSE_ALifeObject* alife_object = smart_cast(object); VERIFY(alife_object); diff --git a/src/xrGame/MosquitoBald.h b/src/xrGame/MosquitoBald.h index 9a31586f0bf..778c8347d78 100644 --- a/src/xrGame/MosquitoBald.h +++ b/src/xrGame/MosquitoBald.h @@ -21,4 +21,7 @@ class CMosquitoBald : public CCustomZone //Ð´Ð»Ñ Ñ‚Ð¾Ð³Ð¾ чтобы blowout обновилÑÑ Ð¾Ð´Ð¸Ð½ раз //поÑле того как зона перключилаÑÑŒ в другое ÑоÑтоÑние bool m_bLastBlowoutUpdate; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; diff --git a/src/xrGame/MosquitoBald_script.cpp b/src/xrGame/MosquitoBald_script.cpp index 9421b68b407..f023763b6e3 100644 --- a/src/xrGame/MosquitoBald_script.cpp +++ b/src/xrGame/MosquitoBald_script.cpp @@ -1,10 +1,10 @@ #include "pch_script.h" + #include "MosquitoBald.h" #include "ZoneCampfire.h" #include "TorridZone.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CMosquitoBald, (CGameObject), +void CMosquitoBald::script_register(lua_State* luaState) { using namespace luabind; @@ -20,4 +20,4 @@ SCRIPT_EXPORT(CMosquitoBald, (CGameObject), .def("turn_off", &CZoneCampfire::turn_off_script) .def("is_on", &CZoneCampfire::is_on) ]; -}); +} diff --git a/src/xrGame/PHCollisionDamageReceiver.cpp b/src/xrGame/PHCollisionDamageReceiver.cpp index 30dc5ac8c61..0eeb306006c 100644 --- a/src/xrGame/PHCollisionDamageReceiver.cpp +++ b/src/xrGame/PHCollisionDamageReceiver.cpp @@ -23,9 +23,9 @@ void CPHCollisionDamageReceiver::Init() CInifile::Sect& data = ini->r_section("collision_damage"); for (const auto& item : data.Data) { - u16 index = K->LL_BoneID(*item.first); - R_ASSERT3(index != BI_NONE, "Wrong bone name", *item.first); - BoneInsert(index, float(atof(*item.second))); + u16 index = K->LL_BoneID(item.first.c_str()); + R_ASSERT3(index != BI_NONE, "Wrong bone name", item.first.c_str()); + BoneInsert(index, float(atof(item.second.c_str()))); CODEGeom* og = sh->PPhysicsShell()->get_GeomByID(index); // R_ASSERT3(og, "collision damage bone has no physics collision", *item.first); if (og) diff --git a/src/xrGame/PHDebug.cpp b/src/xrGame/PHDebug.cpp index 84c3e054a89..436ab20f5a8 100644 --- a/src/xrGame/PHDebug.cpp +++ b/src/xrGame/PHDebug.cpp @@ -802,7 +802,7 @@ static void DBG_DrawTarckObj() IRenderVisual* v = trace_object->Visual(); if (!v) return; - DBG_OutText("visual name: %s ", *trace_object->cNameVisual()); + DBG_OutText("visual name: %s ", trace_object->cNameVisual().c_str()); IKinematics* k = smart_cast(v); if (!k) return; diff --git a/src/xrGame/PHDestroyable.cpp b/src/xrGame/PHDestroyable.cpp index 550be31c776..b5b8bead335 100644 --- a/src/xrGame/PHDestroyable.cpp +++ b/src/xrGame/PHDestroyable.cpp @@ -54,7 +54,7 @@ void CPHDestroyable::GenSpawnReplace(u16 ref_id, LPCSTR section, shared_str visu CSE_Abstract* D = F_entity_Create(section); //*cNameSect() VERIFY(D); CSE_Visual* V = smart_cast(D); - V->set_visual(*visual_name); + V->set_visual(visual_name.c_str()); CSE_PHSkeleton* l_tpPHSkeleton = smart_cast(D); VERIFY(l_tpPHSkeleton); l_tpPHSkeleton->source_id = ref_id; diff --git a/src/xrGame/PHMovementControl.cpp b/src/xrGame/PHMovementControl.cpp index 1e3b113bd7b..44da33b2bba 100644 --- a/src/xrGame/PHMovementControl.cpp +++ b/src/xrGame/PHMovementControl.cpp @@ -44,7 +44,7 @@ CPHMovementControl::CPHMovementControl(IGameObject* parent) #ifdef DEBUG if (debug_output().ph_dbg_draw_mask1().test(ph_m1_DbgTrackObject) && (!!pObject->cName()) && - xr_stricmp(debug_output().PH_DBG_ObjectTrackName(), *pObject->cName()) == 0) + xr_stricmp(debug_output().PH_DBG_ObjectTrackName(), pObject->cName().c_str()) == 0) { Msg("CPHMovementControl::CPHMovementControl %s (constructor) %f,%f,%pObjectf", debug_output().PH_DBG_ObjectTrackName(), pObject->Position().x, pObject->Position().y, @@ -322,7 +322,7 @@ void CPHMovementControl::Calculate( { #ifdef DEBUG if (debug_output().ph_dbg_draw_mask1().test(ph_m1_DbgTrackObject) && (!!pObject->cName()) && - xr_stricmp(debug_output().PH_DBG_ObjectTrackName(), *pObject->cName()) == 0) + xr_stricmp(debug_output().PH_DBG_ObjectTrackName(), pObject->cName().c_str()) == 0) { Msg("CPHMovementControl::Calculate in %s (Object Position) %f,%f,%f", debug_output().PH_DBG_ObjectTrackName(), pObject->Position().x, pObject->Position().y, pObject->Position().z); @@ -580,7 +580,7 @@ void CPHMovementControl::PathNearestPoint(const xr_vectorcName()) && - xr_stricmp(PH_DBG_ObjectTrackName(), *pObject->cName()) == 0) + xr_stricmp(PH_DBG_ObjectTrackName(), pObject->cName().c_str()) == 0) { Msg("CPHMovementControl::Calculate out %s (Object Position) %f,%f,%f", PH_DBG_ObjectTrackName(), pObject->Position().x, pObject->Position().y, pObject->Position().z); @@ -970,7 +970,7 @@ void CPHMovementControl::SetPosition(const Fvector& P) { #ifdef DEBUG if (ph_dbg_draw_mask1.test(ph_m1_DbgTrackObject) && (!!pObject->cName()) && - xr_stricmp(PH_DBG_ObjectTrackName(), *pObject->cName()) == 0) + xr_stricmp(PH_DBG_ObjectTrackName(), pObject->cName().c_str()) == 0) { Msg("CPHMovementControl::SetPosition %s (Object Position) %f,%f,%f", PH_DBG_ObjectTrackName(), pObject->Position().x, pObject->Position().y, pObject->Position().z); @@ -989,7 +989,7 @@ bool CPHMovementControl::TryPosition(Fvector& pos) #ifdef DEBUG if (ph_dbg_draw_mask1.test(ph_m1_DbgTrackObject) && (!!pObject->cName()) && - xr_stricmp(PH_DBG_ObjectTrackName(), *pObject->cName()) == 0) + xr_stricmp(PH_DBG_ObjectTrackName(), pObject->cName().c_str()) == 0) { Msg("CPHMovementControl::TryPosition %s (Object Position) %f,%f,%f", PH_DBG_ObjectTrackName(), pObject->Position().x, pObject->Position().y, pObject->Position().z); @@ -1015,7 +1015,7 @@ void CPHMovementControl::GetPosition(Fvector& P) #ifdef DEBUG if (ph_dbg_draw_mask1.test(ph_m1_DbgTrackObject) && (!!pObject->cName()) && - xr_stricmp(PH_DBG_ObjectTrackName(), *pObject->cName()) == 0) + xr_stricmp(PH_DBG_ObjectTrackName(), pObject->cName().c_str()) == 0) { Msg("CPHMovementControl::GetPosition %s (Object Position) %f,%f,%f", PH_DBG_ObjectTrackName(), pObject->Position().x, pObject->Position().y, pObject->Position().z); @@ -1045,7 +1045,7 @@ void CPHMovementControl::AllocateCharacterObject(CharacterType type) m_character->SetPosition(vPosition); #ifdef DEBUG if (ph_dbg_draw_mask1.test(ph_m1_DbgTrackObject) && (!!pObject->cName()) && - xr_stricmp(PH_DBG_ObjectTrackName(), *pObject->cName()) == 0) + xr_stricmp(PH_DBG_ObjectTrackName(), pObject->cName().c_str()) == 0) { Msg("CPHMovementControl::AllocateCharacterObject %s (Object Position) %f,%f,%f", PH_DBG_ObjectTrackName(), pObject->Position().x, pObject->Position().y, pObject->Position().z); @@ -1087,7 +1087,7 @@ void CPHMovementControl::PHCaptureObject(CPhysicsShellHolder* object, u16 elemen Fvector CPHMovementControl::PHCaptureGetNearestElemPos(const CPhysicsShellHolder* object) { - R_ASSERT3((object->m_pPhysicsShell != NULL), "NO Phisics Shell for object ", *object->cName()); + R_ASSERT3((object->m_pPhysicsShell != NULL), "NO Phisics Shell for object ", object->cName().c_str()); CPhysicsElement* ph_elem = object->m_pPhysicsShell->NearestToPoint(vPosition); @@ -1211,7 +1211,7 @@ void CPHMovementControl::CreateCharacter() m_character->SetAirControlFactor(fAirControlParam); #ifdef DEBUG if (ph_dbg_draw_mask1.test(ph_m1_DbgTrackObject) && (!!pObject->cName()) && - xr_stricmp(PH_DBG_ObjectTrackName(), *pObject->cName()) == 0) + xr_stricmp(PH_DBG_ObjectTrackName(), pObject->cName().c_str()) == 0) { Msg("CPHMovementControl::CreateCharacter %s (Object Position) %f,%f,%f", PH_DBG_ObjectTrackName(), pObject->Position().x, pObject->Position().y, pObject->Position().z); diff --git a/src/xrGame/PHSkeleton.cpp b/src/xrGame/PHSkeleton.cpp index 760a9711a94..8e38866cb1b 100644 --- a/src/xrGame/PHSkeleton.cpp +++ b/src/xrGame/PHSkeleton.cpp @@ -358,8 +358,8 @@ void CPHSkeleton::UnsplitSingle(CPHSkeleton* SO) SO->CopySpawnInit(); CopySpawnInit(); - VERIFY3(CheckObjectSize(pKinematics), *(O->cNameVisual()), "Object unsplit whith no size"); - VERIFY3(CheckObjectSize(newKinematics), *(O->cNameVisual()), "Object unsplit whith no size"); + VERIFY3(CheckObjectSize(pKinematics), O->cNameVisual().c_str(), "Object unsplit whith no size"); + VERIFY3(CheckObjectSize(newKinematics), O->cNameVisual().c_str(), "Object unsplit whith no size"); } void CPHSkeleton::CopySpawnInit() @@ -416,7 +416,7 @@ void CPHSkeleton::InitServerObject(CSE_Abstract* D) l_tpALifePhysicObject->m_tGraphID = obj->ai_location().game_vertex_id(); l_tpALifeDynamicObject->m_tNodeID = obj->ai_location().level_vertex_id(); - l_tpALifePhysicObject->set_visual(*obj->cNameVisual()); + l_tpALifePhysicObject->set_visual(obj->cNameVisual().c_str()); l_tpALifePhysicObject->source_id = u16(obj->ID()); l_tpALifePhysicObject->startup_animation = m_startup_anim; diff --git a/src/xrGame/ParticlesPlayer.cpp b/src/xrGame/ParticlesPlayer.cpp index c9b85f3ac13..0bbb2578a0a 100644 --- a/src/xrGame/ParticlesPlayer.cpp +++ b/src/xrGame/ParticlesPlayer.cpp @@ -28,7 +28,7 @@ CParticlesPlayer::SParticlesInfo* CParticlesPlayer::SBoneInfo::AppendParticles( return pi; particles.push_back(SParticlesInfo()); pi = &particles.back(); - pi->ps = CParticlesObject::Create(*ps_name, FALSE); + pi->ps = CParticlesObject::Create(ps_name.c_str(), FALSE); return pi; } void CParticlesPlayer::SBoneInfo::StopParticles(const shared_str& ps_name, bool bDestroy) @@ -84,10 +84,10 @@ void CParticlesPlayer::LoadParticles(IKinematics* K) CInifile::Sect& data = ini->r_section("particle_bones"); for (const auto& item : data.Data) { - u16 index = K->LL_BoneID(*item.first); - R_ASSERT3(index != BI_NONE, "Particles bone not found", *item.first); + u16 index = K->LL_BoneID(item.first.c_str()); + R_ASSERT3(index != BI_NONE, "Particles bone not found", item.first.c_str()); Fvector offs; - sscanf(*item.second, "%f,%f,%f", &offs.x, &offs.y, &offs.z); + sscanf(item.second.c_str(), "%f,%f,%f", &offs.x, &offs.y, &offs.z); m_Bones.push_back(SBoneInfo(index, offs)); bone_mask |= u64(1) << u64(index); } @@ -136,7 +136,7 @@ void CParticlesPlayer::StartParticles( const shared_str& particles_name, u16 bone_num, const Fmatrix& xform, u16 sender_id, int life_time, bool auto_stop) { VERIFY(fis_zero(xform.c.magnitude())); - R_ASSERT(*particles_name); + R_ASSERT(particles_name.c_str()); IGameObject* object = m_self_object; VERIFY(object); diff --git a/src/xrGame/PhraseDialog.h b/src/xrGame/PhraseDialog.h index 4a86afaff19..791a0868938 100644 --- a/src/xrGame/PhraseDialog.h +++ b/src/xrGame/PhraseDialog.h @@ -136,10 +136,6 @@ class CPhraseDialog : public CSharedClass, public: CPhrase* AddPhrase(LPCSTR text, const shared_str& phrase_id, const shared_str& prev_phrase_id, int goodwil_level); - CPhrase* AddPhrase_script(LPCSTR text, LPCSTR phrase_id, LPCSTR prev_phrase_id, int goodwil_level) - { - return AddPhrase(text, phrase_id, prev_phrase_id, goodwil_level); - }; void SetCaption(LPCSTR str); void SetPriority(int val); CPhrase* GetPhrase(const shared_str& phrase_id); diff --git a/src/xrGame/PhraseDialog_script.cpp b/src/xrGame/PhraseDialog_script.cpp index dc5e80db9e9..8a82d07fb3d 100644 --- a/src/xrGame/PhraseDialog_script.cpp +++ b/src/xrGame/PhraseDialog_script.cpp @@ -1,6 +1,6 @@ #include "pch_script.h" + #include "PhraseDialog.h" -#include "xrScriptEngine/ScriptExporter.hpp" void CDialogScriptHelper::AddPrecondition(LPCSTR str) { m_Preconditions.push_back(str); } void CDialogScriptHelper::AddAction(LPCSTR str) { m_ScriptActions.push_back(str); } @@ -8,12 +8,21 @@ void CDialogScriptHelper::AddHasInfo(LPCSTR str) { m_HasInfo.push_back(str); } void CDialogScriptHelper::AddDontHasInfo(LPCSTR str) { m_DontHasInfo.push_back(str); } void CDialogScriptHelper::AddGiveInfo(LPCSTR str) { m_GiveInfo.push_back(str); } void CDialogScriptHelper::AddDisableInfo(LPCSTR str) { m_DisableInfo.push_back(str); } -SCRIPT_EXPORT(CPhraseDialogExporter, (), + +void CDialogScriptHelper::script_register(lua_State* luaState) { using namespace luabind; - module(luaState)[class_("CPhrase").def("GetPhraseScript", &CPhrase::GetScriptHelper), - class_("CPhraseDialog").def("AddPhrase", &CPhraseDialog::AddPhrase_script), + module(luaState) + [ + class_("CPhrase") + .def("GetPhraseScript", &CPhrase::GetScriptHelper), + + class_("CPhraseDialog") + .def("AddPhrase", +[](CPhraseDialog* self, pcstr text, pcstr phrase_id, pcstr prev_phrase_id, int goodwil_level) + { + return self->AddPhrase(text, phrase_id, prev_phrase_id, goodwil_level); + }), class_("CPhraseScript") .def("AddPrecondition", &CDialogScriptHelper::AddPrecondition) @@ -22,5 +31,6 @@ SCRIPT_EXPORT(CPhraseDialogExporter, (), .def("AddDontHasInfo", &CDialogScriptHelper::AddDontHasInfo) .def("AddGiveInfo", &CDialogScriptHelper::AddGiveInfo) .def("AddDisableInfo", &CDialogScriptHelper::AddDisableInfo) - .def("SetScriptText", &CDialogScriptHelper::SetScriptText)]; -}); + .def("SetScriptText", &CDialogScriptHelper::SetScriptText) + ]; +} diff --git a/src/xrGame/PhraseScript.h b/src/xrGame/PhraseScript.h index 75efa9b0537..e97a2d0088b 100644 --- a/src/xrGame/PhraseScript.h +++ b/src/xrGame/PhraseScript.h @@ -65,4 +65,7 @@ class CDialogScriptHelper //проверка наличиÑ/отÑутÑÑ‚Ð²Ð¸Ñ Ð¸Ð½Ñ„Ð¾Ñ€Ð¼Ð°Ñ†Ð¸Ð¸ INFO_VECTOR m_HasInfo; INFO_VECTOR m_DontHasInfo; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; diff --git a/src/xrGame/PhysicObject.h b/src/xrGame/PhysicObject.h index bb8e97aee08..257cd4d3046 100644 --- a/src/xrGame/PhysicObject.h +++ b/src/xrGame/PhysicObject.h @@ -137,4 +137,7 @@ class CPhysicObject : public CPhysicsShellHolder, public CPHSkeleton Flags16 m_flags; bool m_just_after_spawn; bool m_activated; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; diff --git a/src/xrGame/PhysicObject_script.cpp b/src/xrGame/PhysicObject_script.cpp index a29e2062beb..5a2a6c5d00a 100644 --- a/src/xrGame/PhysicObject_script.cpp +++ b/src/xrGame/PhysicObject_script.cpp @@ -1,13 +1,13 @@ #include "pch_script.h" + #include "PhysicObject.h" #include "PHCollisionDamageReceiver.h" #include "PHDestroyable.h" #include "hit_immunity.h" #include "damage_manager.h" #include "DestroyablePhysicsObject.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CPhysicObject, (CGameObject), +void CPhysicObject::script_register(lua_State* luaState) { using namespace luabind; @@ -28,4 +28,4 @@ SCRIPT_EXPORT(CPhysicObject, (CGameObject), class_("CDestroyablePhysicsObject") .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/PhysicsShellHolder.cpp b/src/xrGame/PhysicsShellHolder.cpp index 828a8c0bb34..a7f58289468 100644 --- a/src/xrGame/PhysicsShellHolder.cpp +++ b/src/xrGame/PhysicsShellHolder.cpp @@ -1,4 +1,5 @@ #include "pch_script.h" + #include "PhysicsShellHolder.h" #include "xrPhysics/PhysicsShell.h" #include "xrMessages.h" @@ -6,8 +7,8 @@ #include "Include/xrRender/Kinematics.h" #include "xrScriptEngine/script_callback_ex.h" #include "Level.h" -#include "PHCommander.h" -#include "PHScriptCall.h" +#include "xrPhysics/PHCommander.h" +#include "xrPhysics/PHScriptCall.h" #include "CustomRocket.h" #include "Grenade.h" diff --git a/src/xrGame/PhysicsShellScript.cpp b/src/xrGame/PhysicsShellScript.cpp deleted file mode 100644 index ff5d87be75b..00000000000 --- a/src/xrGame/PhysicsShellScript.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#include "pch_script.h" -#include "physicsshell.h" - -Fmatrix global_transform(CPhysicsElement* E) -{ - Fmatrix m; - E->GetGlobalTransformDynamic(&m); - return m; -} - -#pragma optimize("s", on) -void CPhysicsShell::script_register(lua_State* L) -{ - using namespace luabind; - - module(L)[class_("physics_shell") - .def("apply_force", (void (CPhysicsShell::*)(float, float, float))(&CPhysicsShell::applyForce)) - .def("get_element_by_bone_name", - (CPhysicsElement * (CPhysicsShell::*)(LPCSTR))(&CPhysicsShell::get_Element)) - .def("get_element_by_bone_id", (CPhysicsElement * (CPhysicsShell::*)(u16))(&CPhysicsShell::get_Element)) - .def("get_element_by_order", - (CPhysicsElement * (CPhysicsShell::*)(u16))(&CPhysicsShell::get_ElementByStoreOrder)) - .def("get_elements_number", &CPhysicsShell::get_ElementsNumber) - .def("get_joint_by_bone_name", (CPhysicsJoint * (CPhysicsShell::*)(LPCSTR))(&CPhysicsShell::get_Joint)) - .def("get_joint_by_bone_id", (CPhysicsJoint * (CPhysicsShell::*)(u16))(&CPhysicsShell::get_Joint)) - .def("get_joint_by_order", &CPhysicsShell::get_JointByStoreOrder) - .def("get_joints_number", &CPhysicsShell::get_JointsNumber) - .def("block_breaking", &CPhysicsShell::BlockBreaking) - .def("unblock_breaking", &CPhysicsShell::UnblockBreaking) - .def("is_breaking_blocked", &CPhysicsShell::IsBreakingBlocked) - .def("is_breakable", &CPhysicsShell::isBreakable) - .def("get_linear_vel", &CPhysicsShell::get_LinearVel) - .def("get_angular_vel", &CPhysicsShell::get_AngularVel)]; -} - -void CPhysicsElement::script_register(lua_State* L) -{ - using namespace luabind; - - module(L)[class_("physics_element") - .def("apply_force", (void (CPhysicsElement::*)(float, float, float))(&CPhysicsElement::applyForce)) - .def("is_breakable", &CPhysicsElement::isBreakable) - .def("get_linear_vel", &CPhysicsElement::get_LinearVel) - .def("get_angular_vel", &CPhysicsElement::get_AngularVel) - .def("get_mass", &CPhysicsElement::getMass) - .def("get_density", &CPhysicsElement::getDensity) - .def("get_volume", &CPhysicsElement::getVolume) - .def("fix", &CPhysicsElement::Fix) - .def("release_fixed", &CPhysicsElement::ReleaseFixed) - .def("is_fixed", &CPhysicsElement::isFixed) - .def("global_transform", &global_transform)]; -} - -void CPhysicsJoint::script_register(lua_State* L) -{ - using namespace luabind; - - module(L)[class_("physics_joint") - .def("get_bone_id", &CPhysicsJoint::BoneID) - .def("get_first_element", &CPhysicsJoint::PFirst_element) - .def("get_stcond_element", &CPhysicsJoint::PSecond_element) - .def("set_anchor_global", - (void (CPhysicsJoint::*)(const float, const float, const float))(&CPhysicsJoint::SetAnchor)) - .def("set_anchor_vs_first_element", (void (CPhysicsJoint::*)(const float, const float, const float))( - &CPhysicsJoint::SetAnchorVsFirstElement)) - .def("set_anchor_vs_second_element", (void (CPhysicsJoint::*)(const float, const float, const float))( - &CPhysicsJoint::SetAnchorVsSecondElement)) - .def("get_axes_number", &CPhysicsJoint::GetAxesNumber) - .def("set_axis_spring_dumping_factors", &CPhysicsJoint::SetAxisSDfactors) - .def("set_joint_spring_dumping_factors", &CPhysicsJoint::SetJointSDfactors) - .def("set_axis_dir_global", (void (CPhysicsJoint::*)(const float, const float, const float, - const int))(&CPhysicsJoint::SetAxisDir)) - .def("set_axis_dir_vs_first_element", (void (CPhysicsJoint::*)(const float, const float, const float, - const int))(&CPhysicsJoint::SetAxisDirVsFirstElement)) - .def("set_axis_dir_vs_second_element", (void (CPhysicsJoint::*)(const float, const float, const float, - const int))(&CPhysicsJoint::SetAxisDirVsSecondElement)) - .def("set_limits", &CPhysicsJoint::SetLimits) - .def("set_max_force_and_velocity", &CPhysicsJoint::SetForceAndVelocity) - .def("get_max_force_and_velocity", &CPhysicsJoint::GetMaxForceAndVelocity) - .def("get_axis_angle", &CPhysicsJoint::GetAxisAngle) - .def("get_limits", &CPhysicsJoint::GetLimits, out_value(_2) + out_value(_3)) - .def("get_axis_dir", &CPhysicsJoint::GetAxisDirDynamic) - .def("get_anchor", &CPhysicsJoint::GetAnchorDynamic) - .def("is_breakable", &CPhysicsJoint::isBreakable)]; -} diff --git a/src/xrGame/PostprocessAnimator.cpp b/src/xrGame/PostprocessAnimator.cpp index eb55950e812..2ba188e0a25 100644 --- a/src/xrGame/PostprocessAnimator.cpp +++ b/src/xrGame/PostprocessAnimator.cpp @@ -83,7 +83,7 @@ bool CPostprocessAnimator::Process(SPPInfo& PPInfo) if (PPInfo.noise.grain <= 0.0f) { - R_ASSERT3(0, "noise.grain cant be zero! see postprocess", *m_Name); + R_ASSERT3(0, "noise.grain cant be zero! see postprocess", m_Name.c_str()); } if (fsimilar(m_factor, 0.0001f, EPS_S)) diff --git a/src/xrGame/RGD5.h b/src/xrGame/RGD5.h index 9553d0a1a96..8b16c06654a 100644 --- a/src/xrGame/RGD5.h +++ b/src/xrGame/RGD5.h @@ -9,4 +9,7 @@ class CRGD5 : public CGrenade public: CRGD5() {} virtual ~CRGD5() {} + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject, CExplosive); }; diff --git a/src/xrGame/Scope.cpp b/src/xrGame/Scope.cpp index a6e58945450..62d4f4572fc 100644 --- a/src/xrGame/Scope.cpp +++ b/src/xrGame/Scope.cpp @@ -2,12 +2,8 @@ #include "Scope.h" #include "Silencer.h" #include "GrenadeLauncher.h" -#include "xrScriptEngine/ScriptExporter.hpp" -CScope::CScope() {} -CScope::~CScope() {} - -SCRIPT_EXPORT(CScope, (CGameObject), +void CScope::script_register(lua_State* luaState) { using namespace luabind; @@ -22,4 +18,4 @@ SCRIPT_EXPORT(CScope, (CGameObject), class_("CGrenadeLauncher") .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/Scope.h b/src/xrGame/Scope.h index d116b7d5cd9..0d659cc1ae6 100644 --- a/src/xrGame/Scope.h +++ b/src/xrGame/Scope.h @@ -7,12 +7,11 @@ #include "inventory_item_object.h" -class CScope : public CInventoryItemObject +class CScope final : public CInventoryItemObject { -private: +protected: typedef CInventoryItemObject inherited; -public: - CScope(); - virtual ~CScope(); +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; diff --git a/src/xrGame/ScriptXMLInit.cpp b/src/xrGame/ScriptXMLInit.cpp index d7646ed0089..1c90c2ee346 100644 --- a/src/xrGame/ScriptXMLInit.cpp +++ b/src/xrGame/ScriptXMLInit.cpp @@ -1,4 +1,5 @@ #include "pch_script.h" + #include "ScriptXMLInit.h" #include "ui/UIXmlInit.h" #include "xrUICore/XML/UITextureMaster.h" @@ -23,7 +24,6 @@ #include "xrUICore/ScrollView/UIScrollView.h" #include "xrUICore/ListWnd/UIListWnd.h" #include "xrUICore/ProgressBar/UIProgressBar.h" -#include "xrScriptEngine/ScriptExporter.hpp" void _attach_child(CUIWindow* _child, CUIWindow* _parent) { @@ -269,7 +269,7 @@ CUIEditBox* CScriptXmlInit::InitMPPlayerName(LPCSTR path, CUIWindow* parent) return pWnd; } -SCRIPT_EXPORT(CScriptXmlInit, (), +void CScriptXmlInit::script_register(lua_State* luaState) { using namespace luabind; @@ -309,4 +309,4 @@ SCRIPT_EXPORT(CScriptXmlInit, (), .def("InitListBox", &CScriptXmlInit::InitListBox) .def("InitProgressBar", &CScriptXmlInit::InitProgressBar) ]; -}); +} diff --git a/src/xrGame/ScriptXMLInit.h b/src/xrGame/ScriptXMLInit.h index 7db15ebc382..244ed8fc8a0 100644 --- a/src/xrGame/ScriptXMLInit.h +++ b/src/xrGame/ScriptXMLInit.h @@ -69,4 +69,7 @@ class CScriptXmlInit protected: CUIXml m_xml; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; diff --git a/src/xrGame/ShootingObject.cpp b/src/xrGame/ShootingObject.cpp index 0693acfd559..91a8927a1f0 100644 --- a/src/xrGame/ShootingObject.cpp +++ b/src/xrGame/ShootingObject.cpp @@ -87,44 +87,44 @@ void CShootingObject::LoadFireParams(LPCSTR section) s_sHitPower = pSettings->r_string_wb(section, "hit_power"); //читаем Ñтроку Ñилы хита пули Ð¾Ñ€ÑƒÐ¶Ð¸Ñ s_sHitPowerCritical = READ_IF_EXISTS(pSettings, r_string_wb, section, "hit_power_critical", s_sHitPower); fvHitPower[egdMaster] = - (float)atof(_GetItem(*s_sHitPower, 0, buffer)); //первый параметр - Ñто хит Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ð¸Ð³Ñ€Ñ‹ маÑтер + (float)atof(_GetItem(s_sHitPower.c_str(), 0, buffer)); //первый параметр - Ñто хит Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ð¸Ð³Ñ€Ñ‹ маÑтер fvHitPowerCritical[egdMaster] = - (float)atof(_GetItem(*s_sHitPowerCritical, 0, buffer)); //первый параметр - Ñто хит Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ð¸Ð³Ñ€Ñ‹ маÑтер + (float)atof(_GetItem(s_sHitPowerCritical.c_str(), 0, buffer)); //первый параметр - Ñто хит Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ð¸Ð³Ñ€Ñ‹ маÑтер fvHitPower[egdNovice] = fvHitPower[egdStalker] = fvHitPower[egdVeteran] = fvHitPower[egdMaster]; //изначально параметры Ð´Ð»Ñ Ð´Ñ€ÑƒÐ³Ð¸Ñ… уровней ÑложноÑти такие же fvHitPowerCritical[egdNovice] = fvHitPowerCritical[egdStalker] = fvHitPowerCritical[egdVeteran] = fvHitPowerCritical[egdMaster]; //изначально параметры Ð´Ð»Ñ Ð´Ñ€ÑƒÐ³Ð¸Ñ… уровней ÑложноÑти такие же - int num_game_diff_param = _GetItemCount(*s_sHitPower); //узнаём колличеÑтво параметров Ð´Ð»Ñ Ñ…Ð¸Ñ‚Ð¾Ð² + int num_game_diff_param = _GetItemCount(s_sHitPower.c_str()); //узнаём колличеÑтво параметров Ð´Ð»Ñ Ñ…Ð¸Ñ‚Ð¾Ð² if (num_game_diff_param > 1) //еÑли задан второй параметр хита { - fvHitPower[egdVeteran] = (float)atof(_GetItem(*s_sHitPower, 1, buffer)); //то вычитываем его Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ð²ÐµÑ‚ÐµÑ€Ð°Ð½Ð° + fvHitPower[egdVeteran] = (float)atof(_GetItem(s_sHitPower.c_str(), 1, buffer)); //то вычитываем его Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ð²ÐµÑ‚ÐµÑ€Ð°Ð½Ð° } if (num_game_diff_param > 2) //еÑли задан третий параметр хита { - fvHitPower[egdStalker] = (float)atof(_GetItem(*s_sHitPower, 2, buffer)); //то вычитываем его Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ñталкера + fvHitPower[egdStalker] = (float)atof(_GetItem(s_sHitPower.c_str(), 2, buffer)); //то вычитываем его Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ñталкера } if (num_game_diff_param > 3) //еÑли задан четвёртый параметр хита { - fvHitPower[egdNovice] = (float)atof(_GetItem(*s_sHitPower, 3, buffer)); //то вычитываем его Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ð½Ð¾Ð²Ð¸Ñ‡ÐºÐ° + fvHitPower[egdNovice] = (float)atof(_GetItem(s_sHitPower.c_str(), 3, buffer)); //то вычитываем его Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ð½Ð¾Ð²Ð¸Ñ‡ÐºÐ° } - num_game_diff_param = _GetItemCount(*s_sHitPowerCritical); //узнаём колличеÑтво параметров + num_game_diff_param = _GetItemCount(s_sHitPowerCritical.c_str()); //узнаём колличеÑтво параметров if (num_game_diff_param > 1) //еÑли задан второй параметр хита { fvHitPowerCritical[egdVeteran] = - (float)atof(_GetItem(*s_sHitPowerCritical, 1, buffer)); //то вычитываем его Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ð²ÐµÑ‚ÐµÑ€Ð°Ð½Ð° + (float)atof(_GetItem(s_sHitPowerCritical.c_str(), 1, buffer)); //то вычитываем его Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ð²ÐµÑ‚ÐµÑ€Ð°Ð½Ð° } if (num_game_diff_param > 2) //еÑли задан третий параметр хита { fvHitPowerCritical[egdStalker] = - (float)atof(_GetItem(*s_sHitPowerCritical, 2, buffer)); //то вычитываем его Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ñталкера + (float)atof(_GetItem(s_sHitPowerCritical.c_str(), 2, buffer)); //то вычитываем его Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ñталкера } if (num_game_diff_param > 3) //еÑли задан четвёртый параметр хита { fvHitPowerCritical[egdNovice] = - (float)atof(_GetItem(*s_sHitPowerCritical, 3, buffer)); //то вычитываем его Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ð½Ð¾Ð²Ð¸Ñ‡ÐºÐ° + (float)atof(_GetItem(s_sHitPowerCritical.c_str(), 3, buffer)); //то вычитываем его Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ð½Ð¾Ð²Ð¸Ñ‡ÐºÐ° } fHitImpulse = pSettings->r_float(section, "hit_impulse"); @@ -293,7 +293,7 @@ void CShootingObject::OnShellDrop(const Fvector& play_pos, const Fvector& parent if (Device.vCameraPosition.distance_to_sqr(play_pos) > 2 * 2) return; - CParticlesObject* pShellParticles = CParticlesObject::Create(*m_sShellParticles, TRUE); + CParticlesObject* pShellParticles = CParticlesObject::Create(m_sShellParticles.c_str(), TRUE); Fmatrix particles_pos; particles_pos.set(get_ParticlesXFORM()); @@ -319,7 +319,7 @@ void CShootingObject::OnShellDrop(const Fvector& play_pos, const Fvector& parent void CShootingObject::StartSmokeParticles(const Fvector& play_pos, const Fvector& parent_vel) { CParticlesObject* pSmokeParticles = NULL; - StartParticles(pSmokeParticles, *m_sSmokeParticlesCurrent, play_pos, parent_vel, true); + StartParticles(pSmokeParticles, m_sSmokeParticlesCurrent.c_str(), play_pos, parent_vel, true); } void CShootingObject::StartFlameParticles() @@ -335,7 +335,7 @@ void CShootingObject::StartFlameParticles() } StopFlameParticles(); - m_pFlameParticles = CParticlesObject::Create(*m_sFlameParticlesCurrent, FALSE); + m_pFlameParticles = CParticlesObject::Create(m_sFlameParticlesCurrent.c_str(), FALSE); UpdateFlameParticles(); CSpectator* tmp_spectr = smart_cast(Level().CurrentControlEntity()); @@ -512,5 +512,5 @@ void CShootingObject::FireEnd() { bWorking = false; } void CShootingObject::StartShotParticles() { CParticlesObject* pSmokeParticles = NULL; - StartParticles(pSmokeParticles, *m_sShotParticles, m_vCurrentShootPos, m_vCurrentShootDir, true); + StartParticles(pSmokeParticles, m_sShotParticles.c_str(), m_vCurrentShootPos, m_vCurrentShootDir, true); } diff --git a/src/xrGame/Spectator.cpp b/src/xrGame/Spectator.cpp index f9b7aa60338..bf6f14ffbf1 100644 --- a/src/xrGame/Spectator.cpp +++ b/src/xrGame/Spectator.cpp @@ -647,16 +647,16 @@ void CSpectator::GetSpectatorString(string1024& pStr) { case eacFreeFly: { - SpectatorMsg = *StringTable().translate("mp_spectator"); + SpectatorMsg = StringTable().translate("mp_spectator").c_str(); SpectatorMsg += " "; - SpectatorMsg += *StringTable().translate("mp_free_fly"); + SpectatorMsg += StringTable().translate("mp_free_fly").c_str(); break; } case eacFirstEye: { - SpectatorMsg = *StringTable().translate("mp_spectator"); + SpectatorMsg = StringTable().translate("mp_spectator").c_str(); SpectatorMsg += " "; - SpectatorMsg += *StringTable().translate("mp_first_eye"); + SpectatorMsg += StringTable().translate("mp_first_eye").c_str(); SpectatorMsg += " "; // SpectatorMsg = "SPECTATOR (First-Eye): "; SpectatorMsg += m_pActorToLookAt ? m_pActorToLookAt->Name() : ""; @@ -664,9 +664,9 @@ void CSpectator::GetSpectatorString(string1024& pStr) } case eacFreeLook: { - SpectatorMsg = *StringTable().translate("mp_spectator"); + SpectatorMsg = StringTable().translate("mp_spectator").c_str(); SpectatorMsg += " "; - SpectatorMsg += *StringTable().translate("mp_free_look"); + SpectatorMsg += StringTable().translate("mp_free_look").c_str(); SpectatorMsg += " "; // SpectatorMsg = "SPECTATOR (Free-Look):"; SpectatorMsg += m_pActorToLookAt ? m_pActorToLookAt->Name() : ""; @@ -674,9 +674,9 @@ void CSpectator::GetSpectatorString(string1024& pStr) } case eacLookAt: { - SpectatorMsg = *StringTable().translate("mp_spectator"); + SpectatorMsg = StringTable().translate("mp_spectator").c_str(); SpectatorMsg += " "; - SpectatorMsg += *StringTable().translate("mp_look_at"); + SpectatorMsg += StringTable().translate("mp_look_at").c_str(); SpectatorMsg += " "; // SpectatorMsg = "SPECTATOR (Look-At):"; SpectatorMsg += m_pActorToLookAt ? m_pActorToLookAt->Name() : ""; diff --git a/src/xrGame/StalkerOutfit.cpp b/src/xrGame/StalkerOutfit.cpp index c7a36dbbd35..1272f49bbdd 100644 --- a/src/xrGame/StalkerOutfit.cpp +++ b/src/xrGame/StalkerOutfit.cpp @@ -1,12 +1,12 @@ #include "pch_script.h" + #include "StalkerOutfit.h" #include "ActorHelmet.h" -#include "xrScriptEngine/ScriptExporter.hpp" CStalkerOutfit::CStalkerOutfit() {} CStalkerOutfit::~CStalkerOutfit() {} -SCRIPT_EXPORT(CStalkerOutfit, (CGameObject), +void CStalkerOutfit::script_register(lua_State* luaState) { using namespace luabind; @@ -15,4 +15,4 @@ SCRIPT_EXPORT(CStalkerOutfit, (CGameObject), class_("CStalkerOutfit") .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/StalkerOutfit.h b/src/xrGame/StalkerOutfit.h index 14e24dbf20b..7a759f0ddc8 100644 --- a/src/xrGame/StalkerOutfit.h +++ b/src/xrGame/StalkerOutfit.h @@ -15,4 +15,7 @@ class CStalkerOutfit : public CCustomOutfit public: CStalkerOutfit(void); virtual ~CStalkerOutfit(void); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; diff --git a/src/xrGame/StdAfx.h b/src/xrGame/StdAfx.h index cee8789d13a..6d9929da0a9 100644 --- a/src/xrGame/StdAfx.h +++ b/src/xrGame/StdAfx.h @@ -14,10 +14,8 @@ //#include // ~440 - but it has no include guard! Perhaps that's intentional? #include #include // ~360 -#include "luabind/luabind.hpp" // luabind/*, almost 5000 #include "xrServerEntities/smart_cast.h" // a lot #include "xrScriptEngine/script_space_forward.hpp" // ~765 // XXX: See to it this goes to pch_script -#include "xrScriptEngine/DebugMacros.hpp" // ~700 // XXX: See to it this goes to pch_script #include "Common/LevelStructure.hpp" // ~730 #include "xrCommon/misc_math_types.h" // ~770 #include "xrEngine/ISheduled.h" // ~740 @@ -64,7 +62,6 @@ #include "loki/NullType.h" // only ~50, so small it's OK. #include "xrPhysics/PhysicsShell.h" // ~350 #include "xrServerEntities/ShapeData.h" // ~330 -#include "xrScriptEngine/ScriptExporter.hpp" // ~330 // XXX: See to it this goes to pch_script #include "xrServerEntities/specific_character.h" // ~330 #include "xrServerEntities/shared_data.h" // ~330 #include "xrServerEntities/xml_str_id_loader.h" // ~330 @@ -102,7 +99,6 @@ #include "xrCore/Crypto/xr_dsa_verifyer.h" // ~70, very heavy to compile #include "xrServerEntities/restriction_space.h" // only ~110, so small it's worth it #include "xrAICore/Components/condition_state.h" // only ~100, but it includes more -//#include "xrScriptEngine/script_engine.hpp" // ~210 // XXX: See to it this goes to pch_script //#include "xrCore/dump_string.h" // ~260 //#include "xrCore/Math/Random32.hpp" // ~220 //#include "xrEngine/LightAnimLibrary.h" // ~200 diff --git a/src/xrGame/Torch.cpp b/src/xrGame/Torch.cpp index cdeb21d913a..2e003208d0d 100644 --- a/src/xrGame/Torch.cpp +++ b/src/xrGame/Torch.cpp @@ -107,7 +107,7 @@ void CTorch::SwitchNightVision(bool vision_on, bool use_sounds) m_night_vision = xr_new(cNameSect()); LPCSTR disabled_names = pSettings->r_string(cNameSect(), "disabled_maps"); - LPCSTR curr_map = *Level().name(); + pcstr curr_map = Level().name().c_str(); u32 cnt = _GetItemCount(disabled_names); bool b_allow = true; string512 tmp; @@ -199,7 +199,7 @@ void CTorch::Switch(bool light_on) } glow_render->set_active(light_on); - if (*light_trace_bone) + if (light_trace_bone.c_str()) { IKinematics* pVisual = smart_cast(Visual()); VERIFY(pVisual); diff --git a/src/xrGame/Torch.h b/src/xrGame/Torch.h index 1ab1279d6c2..d247fdd4d72 100644 --- a/src/xrGame/Torch.h +++ b/src/xrGame/Torch.h @@ -80,6 +80,9 @@ class CTorch : public CInventoryItemObject virtual void setup_physic_shell(); virtual void afterDetach(); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; class CNightVisionEffector diff --git a/src/xrGame/UIDialogHolder.h b/src/xrGame/UIDialogHolder.h index 32548d5693a..31b2a321865 100644 --- a/src/xrGame/UIDialogHolder.h +++ b/src/xrGame/UIDialogHolder.h @@ -84,4 +84,7 @@ class CDialogHolder : public pureFrame, public CUIDebuggable pcstr GetDebugType() override { return "CDialogHolder"; } bool FillDebugTree(const CUIDebugState& debugState) override; void FillDebugInfo() override; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; diff --git a/src/xrGame/UIGameCTA.cpp b/src/xrGame/UIGameCTA.cpp index 97c3cca6edc..88c81bfd01f 100644 --- a/src/xrGame/UIGameCTA.cpp +++ b/src/xrGame/UIGameCTA.cpp @@ -910,7 +910,7 @@ void CUIGameCTA::LoadDefItemsForRank() const shared_str& ItemName = m_pCurBuyMenu->GetWeaponNameByIndex(pDefItem->SlotID, pDefItem->ItemID); if (!ItemName.size()) continue; - if (!xr_strcmp(*ItemName, "mp_wpn_knife")) + if (!xr_strcmp(ItemName.c_str(), "mp_wpn_knife")) continue; if (!pSettings->line_exist(ItemName, "ammo_class")) continue; diff --git a/src/xrGame/UIGameCustom.h b/src/xrGame/UIGameCustom.h index d43544130c3..b54d4fe7ceb 100644 --- a/src/xrGame/UIGameCustom.h +++ b/src/xrGame/UIGameCustom.h @@ -133,6 +133,9 @@ class CUIGameCustom : public FactoryObjectBase, public CDialogHolder, public CUI pcstr GetDebugType() override { return "CUIGameCustom"; } bool FillDebugTree(const CUIDebugState& debugState) override; void FillDebugInfo() override; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CDialogHolder); }; extern CUIGameCustom* CurrentGameUI(); diff --git a/src/xrGame/UIGameCustom_script.cpp b/src/xrGame/UIGameCustom_script.cpp index 563f68e86c0..2080b93bd03 100644 --- a/src/xrGame/UIGameCustom_script.cpp +++ b/src/xrGame/UIGameCustom_script.cpp @@ -1,17 +1,16 @@ #include "pch_script.h" + +#include "xrUICore/Static/UIStatic.h" + #include "UIGameCustom.h" #include "Level.h" -#include "xrUICore/Static/UIStatic.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CUIGameCustom, (CDialogHolder), +void CUIGameCustom::script_register(lua_State* luaState) { using namespace luabind; module(luaState) [ - def("get_hud", +[]() -> CUIGameCustom* { return CurrentGameUI(); }), - class_("StaticDrawableWrapper") .def_readwrite("m_endTime", &StaticDrawableWrapper::m_endTime) .def("wnd", &StaticDrawableWrapper::wnd), @@ -36,6 +35,8 @@ SCRIPT_EXPORT(CUIGameCustom, (CDialogHolder), .def("hide_messages", &CUIGameCustom::HideMessagesWindow) .def("GetCustomStatic", &CUIGameCustom::GetCustomStatic) .def("update_fake_indicators", &CUIGameCustom::update_fake_indicators) - .def("enable_fake_indicators", &CUIGameCustom::enable_fake_indicators) + .def("enable_fake_indicators", &CUIGameCustom::enable_fake_indicators), + + def("get_hud", +[]() -> CUIGameCustom* { return CurrentGameUI(); }) ]; -}); +} diff --git a/src/xrGame/UIGameSP.cpp b/src/xrGame/UIGameSP.cpp index 1563a41e5cd..362b15b7aa6 100644 --- a/src/xrGame/UIGameSP.cpp +++ b/src/xrGame/UIGameSP.cpp @@ -158,26 +158,34 @@ bool CUIGameSP::IR_UIOnKeyboardPress(int dik) CGameTask* t1 = Level().GameTaskManager().ActiveTask(eTaskTypeStoryline); CGameTask* t2 = Level().GameTaskManager().ActiveTask(eTaskTypeAdditional); + // WERASIK2AA: SOC ISSUE + if (ShadowOfChernobylMode) + { + CGameTask* t = t1 ? t1 : t2; + if (t) + m_game_objective->m_static->SetTextST(*t->m_Description); + else + m_game_objective->m_static->SetTextST("st_no_active_task"); + break; + } + if (t1 && t2) { m_game_objective->m_static->SetTextST(t1->m_Title.c_str()); StaticDrawableWrapper* sm2 = AddCustomStatic("secondary_task", true); - sm2->m_static->SetTextST(t2->m_Title.c_str()); + sm2->m_static->SetTextST(*t2->m_Title); + break; } - else - { - if (t1 || t2) - { - CGameTask* t = (t1) ? t1 : t2; - m_game_objective->m_static->SetTextST(t->m_Title.c_str()); - StaticDrawableWrapper* sm2 = AddCustomStatic("secondary_task", true); - sm2->m_static->TextItemControl()->SetTextST(t->m_Description.c_str()); - } - else - { - m_game_objective->m_static->TextItemControl()->SetTextST("st_no_active_task"); - } + + // WERASIK2AA: T1? + CGameTask* t = t1 ? t1 : t2; + if (t) { + m_game_objective->m_static->SetTextST(t->m_Title.c_str()); + StaticDrawableWrapper* sm2 = AddCustomStatic("secondary_task", true); + sm2->m_static->TextItemControl()->SetTextST(*t->m_Description); } + else + m_game_objective->m_static->TextItemControl()->SetTextST("st_no_active_task"); } break; } diff --git a/src/xrGame/UIGame_custom_script.h b/src/xrGame/UIGame_custom_script.h index 171c7dd82a8..2f729097a15 100644 --- a/src/xrGame/UIGame_custom_script.h +++ b/src/xrGame/UIGame_custom_script.h @@ -1,4 +1,5 @@ #pragma once + #include "UIGameCustom.h" #include "script_export_space.h" #include "game_cl_Base.h" @@ -11,8 +12,7 @@ class UIGame_custom_script : public CUIGameCustom UIGame_custom_script() : inherited(){}; virtual void SetClGame(game_cl_GameState* g) { inherited::SetClGame(g); }; virtual void Init(){}; - DECLARE_SCRIPT_REGISTER_FUNCTION + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CUIGameCustom); }; -add_to_type_list(UIGame_custom_script) -#undef script_type_list -#define script_type_list save_type_list(UIGame_custom_script) diff --git a/src/xrGame/UITimeDilator.cpp b/src/xrGame/UITimeDilator.cpp index 25b31381bc5..fef6c98a8c4 100644 --- a/src/xrGame/UITimeDilator.cpp +++ b/src/xrGame/UITimeDilator.cpp @@ -1,6 +1,7 @@ -#include "UITimeDilator.h" #include "StdAfx.h" +#include "UITimeDilator.h" + UITimeDilator* time_dilator; UITimeDilator* TimeDilator() @@ -25,9 +26,12 @@ void UITimeDilator::SetUiTimeFactor(float timeFactor) { uiTimeFactor = timeFactor; startTimeDilation(); -}; +} -float UITimeDilator::GetUiTimeFactor() { return uiTimeFactor; }; +float UITimeDilator::GetUiTimeFactor() const +{ + return uiTimeFactor; +} void UITimeDilator::SetModeEnability(UIMode mode, bool status) { @@ -43,7 +47,10 @@ void UITimeDilator::SetModeEnability(UIMode mode, bool status) } } -bool UITimeDilator::GetModeEnability(UIMode mode) { return enabledModes.is(mode); } +bool UITimeDilator::GetModeEnability(UIMode mode) const +{ + return enabledModes.is(mode); +} void UITimeDilator::SetCurrentMode(UIMode mode) { @@ -66,5 +73,5 @@ void UITimeDilator::startTimeDilation() void UITimeDilator::stopTimeDilation() { - Device.time_factor(1.0); + Device.time_factor(1.0f); } diff --git a/src/xrGame/UITimeDilator.h b/src/xrGame/UITimeDilator.h index feddc428048..51381817088 100644 --- a/src/xrGame/UITimeDilator.h +++ b/src/xrGame/UITimeDilator.h @@ -1,9 +1,10 @@ #pragma once + class UITimeDilator { public: - enum UIMode + enum UIMode : u8 { None = 0, Inventory = 1 << 0, @@ -11,16 +12,16 @@ class UITimeDilator }; void SetUiTimeFactor(float timeFactor); - float GetUiTimeFactor(); + float GetUiTimeFactor() const; void SetModeEnability(UIMode mode, bool status); - bool GetModeEnability(UIMode mode); + bool GetModeEnability(UIMode mode) const; void SetCurrentMode(UIMode mode); private: float uiTimeFactor = 1.0; - Flags32 enabledModes; + Flags8 enabledModes; UIMode currMode; void startTimeDilation(); diff --git a/src/xrGame/UIZoneMap.cpp b/src/xrGame/UIZoneMap.cpp index 71f643d0b69..98774f7833c 100644 --- a/src/xrGame/UIZoneMap.cpp +++ b/src/xrGame/UIZoneMap.cpp @@ -93,10 +93,19 @@ void CUIZoneMap::Init(bool motionIconAttached) if (IsGameTypeSingle()) { - CUIXmlInit::InitStatic(uiXml, "minimap:static_counter", 0, &m_Counter); - m_background.AttachChild(&m_Counter); - CUIXmlInit::InitStatic(uiXml, "minimap:static_counter:text_static", 0, &m_Counter_text); - m_Counter.AttachChild(&m_Counter_text); + if (ShadowOfChernobylMode) + { + CUIXmlInit::InitStatic(uiXml, "minimap:background", 0, &m_Counter); + m_background.AttachChild(&m_Counter); + CUIXmlInit::InitStatic(uiXml, "minimap:background:dist_text", 0, &m_Counter_text); + m_Counter.AttachChild(&m_Counter_text); + } + else { + CUIXmlInit::InitStatic(uiXml, "minimap:static_counter", 0, &m_Counter); + m_background.AttachChild(&m_Counter); + CUIXmlInit::InitStatic(uiXml, "minimap:static_counter:text_static", 0, &m_Counter_text); + m_Counter.AttachChild(&m_Counter_text); + } if (motionIconAttached) { diff --git a/src/xrGame/Weapon.h b/src/xrGame/Weapon.h index c7d28d2b3eb..3f4c723efe4 100644 --- a/src/xrGame/Weapon.h +++ b/src/xrGame/Weapon.h @@ -529,4 +529,7 @@ class CWeapon : public CHudItemObject, public CShootingObject virtual void DumpActiveParams(shared_str const& section_name, CInifile& dst_ini) const; virtual shared_str const GetAnticheatSectionName() const { return cNameSect(); }; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; diff --git a/src/xrGame/WeaponAK74.h b/src/xrGame/WeaponAK74.h index 7a4da3c2416..df23697f04d 100644 --- a/src/xrGame/WeaponAK74.h +++ b/src/xrGame/WeaponAK74.h @@ -10,4 +10,7 @@ class CWeaponAK74 : public CWeaponMagazinedWGrenade public: CWeaponAK74(ESoundTypes eSoundType = SOUND_TYPE_WEAPON_SUBMACHINEGUN); virtual ~CWeaponAK74(); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CWeaponMagazinedWGrenade); }; diff --git a/src/xrGame/WeaponAmmo.cpp b/src/xrGame/WeaponAmmo.cpp index 70d4ec4da8d..e499df23142 100644 --- a/src/xrGame/WeaponAmmo.cpp +++ b/src/xrGame/WeaponAmmo.cpp @@ -12,13 +12,6 @@ #define BULLET_MANAGER_SECTION "bullet_manager" -CCartridge::CCartridge() -{ - m_flags.assign(cfTracer | cfRicochet); - param_s.Init(); - bullet_material_idx = u16(-1); -} - void CCartridge::Load(LPCSTR section, u8 LocalAmmoType) { m_ammoSect = section; @@ -26,10 +19,16 @@ void CCartridge::Load(LPCSTR section, u8 LocalAmmoType) param_s.kDist = pSettings->r_float(section, "k_dist"); param_s.kDisp = pSettings->r_float(section, "k_disp"); param_s.kHit = pSettings->r_float(section, "k_hit"); - //. param_s.kCritical = pSettings->r_float(section, "k_hit_critical"); param_s.kImpulse = pSettings->r_float(section, "k_impulse"); - // m_kPierce = pSettings->r_float(section, "k_pierce"); - param_s.kAP = READ_IF_EXISTS(pSettings, r_float, section, "k_ap", 0.0f); + + if (GMLib.GetLibraryVersion() >= GAMEMTL_VERSION_CS) + param_s.kAP = pSettings->r_float(section, "k_ap"); + else + { + param_s.kPierce = pSettings->r_float(section, "k_pierce"); + param_s.kAP = pSettings->read_if_exists(section, "k_ap", 0.0f); + } + param_s.u8ColorID = READ_IF_EXISTS(pSettings, r_u8, section, "tracer_color_ID", 0); if (pSettings->line_exist(section, "k_air_resistance")) @@ -57,7 +56,7 @@ void CCartridge::Load(LPCSTR section, u8 LocalAmmoType) } if (pSettings->line_exist(section, "4to1_tracer")) - m_4to1_tracer = pSettings->r_bool(section, "4to1_tracer");; + m_flags.set(cf4to1Tracer, pSettings->r_bool(section, "4to1_tracer")); if (pSettings->line_exist(section, "can_be_unlimited")) m_flags.set(cfCanBeUnlimited, pSettings->r_bool(section, "can_be_unlimited")); @@ -67,8 +66,6 @@ void CCartridge::Load(LPCSTR section, u8 LocalAmmoType) bullet_material_idx = GMLib.GetMaterialIdx(WEAPON_MATERIAL_NAME); VERIFY(u16(-1) != bullet_material_idx); VERIFY(param_s.fWallmarkSize > 0); - - m_InvShortName = StringTable().translate(pSettings->r_string(section, "inv_name_short")); } float CCartridge::Weight() const @@ -87,8 +84,6 @@ float CCartridge::Weight() const return res; } -CWeaponAmmo::CWeaponAmmo(void) {} -CWeaponAmmo::~CWeaponAmmo(void) {} void CWeaponAmmo::Load(LPCSTR section) { inherited::Load(section); @@ -96,10 +91,16 @@ void CWeaponAmmo::Load(LPCSTR section) cartridge_param.kDist = pSettings->r_float(section, "k_dist"); cartridge_param.kDisp = pSettings->r_float(section, "k_disp"); cartridge_param.kHit = pSettings->r_float(section, "k_hit"); - //. cartridge_param.kCritical = pSettings->r_float(section, "k_hit_critical"); cartridge_param.kImpulse = pSettings->r_float(section, "k_impulse"); - // m_kPierce = pSettings->r_float(section, "k_pierce"); - cartridge_param.kAP = READ_IF_EXISTS(pSettings, r_float, section, "k_ap", 0.0f); + + if (GMLib.GetLibraryVersion() >= GAMEMTL_VERSION_CS) + cartridge_param.kAP = pSettings->r_float(section, "k_ap"); + else + { + cartridge_param.kPierce = pSettings->r_float(section, "k_pierce"); + cartridge_param.kAP = pSettings->read_if_exists(section, "k_ap", 0.0f); + } + cartridge_param.u8ColorID = READ_IF_EXISTS(pSettings, r_u8, section, "tracer_color_ID", 0); if (pSettings->line_exist(section, "k_air_resistance")) @@ -174,9 +175,8 @@ bool CWeaponAmmo::Get(CCartridge& cartridge) cartridge.param_s = cartridge_param; cartridge.m_flags.set(CCartridge::cfTracer, m_tracer); - cartridge.m_4to1_tracer = m_4to1_tracer; + cartridge.m_flags.set(CCartridge::cf4to1Tracer, m_4to1_tracer); cartridge.bullet_material_idx = GMLib.GetMaterialIdx(WEAPON_MATERIAL_NAME); - cartridge.m_InvShortName = NameShort(); --m_boxCurr; if (m_pInventory) m_pInventory->InvalidateState(); @@ -191,14 +191,14 @@ void CWeaponAmmo::renderable_Render(u32 context_id, IRenderable* root) void CWeaponAmmo::UpdateCL() { - VERIFY2(_valid(renderable.xform), *cName()); + VERIFY2(_valid(renderable.xform), cName().c_str()); inherited::UpdateCL(); - VERIFY2(_valid(renderable.xform), *cName()); + VERIFY2(_valid(renderable.xform), cName().c_str()); if (!IsGameTypeSingle()) make_Interpolation(); - VERIFY2(_valid(renderable.xform), *cName()); + VERIFY2(_valid(renderable.xform), cName().c_str()); } void CWeaponAmmo::net_Export(NET_Packet& P) diff --git a/src/xrGame/WeaponAmmo.h b/src/xrGame/WeaponAmmo.h index b6f732367c0..47d8c0d2c9b 100644 --- a/src/xrGame/WeaponAmmo.h +++ b/src/xrGame/WeaponAmmo.h @@ -2,88 +2,83 @@ #include "inventory_item_object.h" #include "anticheat_dumpable_object.h" +#pragma pack(push, 1) struct SCartridgeParam { - float kDist, kDisp, kHit /*, kCritical*/, kImpulse, kAP, kAirRes; - int buckShot; - float impair; - float fWallmarkSize; - u8 u8ColorID; - - IC void Init() - { - kDist = kDisp = kHit = kImpulse = 1.0f; - // kCritical = 0.0f; - kAP = 0.0f; - kAirRes = 0.0f; - buckShot = 1; - impair = 1.0f; - fWallmarkSize = 0.0f; - u8ColorID = 0; - } + float kDist = 1.0f; + float kDisp = 1.0f; + float kHit = 1.0f; + float kImpulse = 1.0f; + float kPierce = 1.0f; + float kAP{}; + float kAirRes{}; + int buckShot = 1; + float impair = 1.0f; + float fWallmarkSize{}; + u8 u8ColorID{}; }; +#pragma pack(pop) class CCartridge : public IAnticheatDumpable { public: - CCartridge(); void Load(LPCSTR section, u8 LocalAmmoType); - float Weight() const; + + [[nodiscard]] float Weight() const; shared_str m_ammoSect; - enum + enum : u8 { - cfTracer = (1 << 0), - cfRicochet = (1 << 1), - cfCanBeUnlimited = (1 << 2), - cfExplosive = (1 << 3), - cfMagneticBeam = (1 << 4), + cfTracer = 1 << 0, + cfRicochet = 1 << 1, + cfCanBeUnlimited = 1 << 2, + cfExplosive = 1 << 3, + cfMagneticBeam = 1 << 4, + cf4to1Tracer = 1 << 5, }; SCartridgeParam param_s; u8 m_LocalAmmoType; - bool m_4to1_tracer{}; - u16 bullet_material_idx; - Flags8 m_flags; + u16 bullet_material_idx{ u16(-1) }; + Flags8 m_flags{ cfTracer | cfRicochet }; - shared_str m_InvShortName; - virtual void DumpActiveParams(shared_str const& section_name, CInifile& dst_ini) const; - virtual shared_str const GetAnticheatSectionName() const { return m_ammoSect; }; + void DumpActiveParams(shared_str const& section_name, CInifile& dst_ini) const override; + [[nodiscard]] shared_str const GetAnticheatSectionName() const override { return m_ammoSect; } }; class CWeaponAmmo : public CInventoryItemObject { - typedef CInventoryItemObject inherited; +protected: + using inherited = CInventoryItemObject; public: - CWeaponAmmo(void); - virtual ~CWeaponAmmo(void); - - virtual CWeaponAmmo* cast_weapon_ammo() { return this; } - virtual void Load(LPCSTR section); - virtual bool net_Spawn(CSE_Abstract* DC); - virtual void net_Destroy(); - virtual void net_Export(NET_Packet& P); - virtual void net_Import(NET_Packet& P); - virtual void OnH_B_Chield(); - virtual void OnH_B_Independent(bool just_before_destroy); - virtual void UpdateCL(); + void Load(LPCSTR section) override; + bool net_Spawn(CSE_Abstract* DC) override; + void net_Destroy() override; + void net_Export(NET_Packet& P) override; + void net_Import(NET_Packet& P) override; + void OnH_B_Chield() override; + void OnH_B_Independent(bool just_before_destroy) override; + void UpdateCL() override; + void renderable_Render(u32 context_id, IRenderable* root) override; - virtual bool Useful() const; - virtual float Weight() const; - virtual u32 Cost() const; + CWeaponAmmo* cast_weapon_ammo() override { return this; } + + [[nodiscard]] bool Useful() const override; + [[nodiscard]] float Weight() const override; + [[nodiscard]] u32 Cost() const override; bool Get(CCartridge& cartridge); SCartridgeParam cartridge_param; - u16 m_boxSize; - u16 m_boxCurr; bool m_tracer; bool m_4to1_tracer{}; + u16 m_boxSize; + u16 m_boxCurr; public: - virtual CInventoryItem* can_make_killing(const CInventory* inventory) const; + CInventoryItem* can_make_killing(const CInventory* inventory) const override; }; diff --git a/src/xrGame/WeaponAutomaticShotgun.cpp b/src/xrGame/WeaponAutomaticShotgun.cpp index 1fbfaa406c2..1b8f8e64585 100644 --- a/src/xrGame/WeaponAutomaticShotgun.cpp +++ b/src/xrGame/WeaponAutomaticShotgun.cpp @@ -260,7 +260,7 @@ void CWeaponAutomaticShotgun::net_Import(NET_Packet& P) if (LocalAmmoType == l_cartridge.m_LocalAmmoType) continue; #ifdef DEBUG - Msg("! %s reload to %s", *l_cartridge.m_ammoSect, m_ammoTypes[LocalAmmoType].c_str()); + Msg("! %s reload to %s", l_cartridge.m_ammoSect.c_str(), m_ammoTypes[LocalAmmoType].c_str()); #endif l_cartridge.Load(m_ammoTypes[LocalAmmoType].c_str(), LocalAmmoType); } diff --git a/src/xrGame/WeaponAutomaticShotgun.h b/src/xrGame/WeaponAutomaticShotgun.h index f280930cb8b..3ec23628909 100644 --- a/src/xrGame/WeaponAutomaticShotgun.h +++ b/src/xrGame/WeaponAutomaticShotgun.h @@ -37,4 +37,7 @@ class CWeaponAutomaticShotgun : public CWeaponMagazined ESoundTypes m_eSoundOpen; ESoundTypes m_eSoundAddCartridge; ESoundTypes m_eSoundClose; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CWeaponMagazined); }; diff --git a/src/xrGame/WeaponBinoculars.h b/src/xrGame/WeaponBinoculars.h index 5f984b54ef4..ceea41d8101 100644 --- a/src/xrGame/WeaponBinoculars.h +++ b/src/xrGame/WeaponBinoculars.h @@ -40,4 +40,7 @@ class CWeaponBinoculars : public CWeaponCustomPistol protected: CBinocularsVision* m_binoc_vision; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CWeaponMagazined); }; diff --git a/src/xrGame/WeaponFN2000.h b/src/xrGame/WeaponFN2000.h index c2de797923a..f3a2858d2a6 100644 --- a/src/xrGame/WeaponFN2000.h +++ b/src/xrGame/WeaponFN2000.h @@ -13,6 +13,9 @@ class CWeaponFN2000 : public CWeaponMagazined public: CWeaponFN2000(); virtual ~CWeaponFN2000(); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CWeaponMagazined); }; #endif //__XR_WEAPON_FN2000_H__ diff --git a/src/xrGame/WeaponFORT.h b/src/xrGame/WeaponFORT.h index 3f15cf0fe93..4e5ee0303e5 100644 --- a/src/xrGame/WeaponFORT.h +++ b/src/xrGame/WeaponFORT.h @@ -11,4 +11,7 @@ class CWeaponFORT : public CWeaponPistol public: CWeaponFORT() {} virtual ~CWeaponFORT() {} + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CWeaponMagazined); }; diff --git a/src/xrGame/WeaponFire.cpp b/src/xrGame/WeaponFire.cpp index 1a2a1c58189..cc1a6c6b8e5 100644 --- a/src/xrGame/WeaponFire.cpp +++ b/src/xrGame/WeaponFire.cpp @@ -144,7 +144,7 @@ void CWeapon::FireEnd() void CWeapon::StartFlameParticles2() { - CShootingObject::StartParticles(m_pFlameParticles2, *m_sFlameParticles2, get_LastFP2()); + CShootingObject::StartParticles(m_pFlameParticles2, m_sFlameParticles2.c_str(), get_LastFP2()); } void CWeapon::StopFlameParticles2() { CShootingObject::StopParticles(m_pFlameParticles2); } void CWeapon::UpdateFlameParticles2() diff --git a/src/xrGame/WeaponGroza.h b/src/xrGame/WeaponGroza.h index 518647e85a8..66ea3c39ce8 100644 --- a/src/xrGame/WeaponGroza.h +++ b/src/xrGame/WeaponGroza.h @@ -9,4 +9,7 @@ class CWeaponGroza : public CWeaponMagazinedWGrenade public: CWeaponGroza(); virtual ~CWeaponGroza(); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CWeaponMagazinedWGrenade); }; diff --git a/src/xrGame/WeaponHPSA.h b/src/xrGame/WeaponHPSA.h index c75e12bdd39..e99c5df7395 100644 --- a/src/xrGame/WeaponHPSA.h +++ b/src/xrGame/WeaponHPSA.h @@ -14,6 +14,9 @@ class CWeaponHPSA : public CWeaponPistol public: CWeaponHPSA(); virtual ~CWeaponHPSA(); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CWeaponMagazined); }; #endif //__XR_WEAPON_HPSA_H__ diff --git a/src/xrGame/WeaponKnife.cpp b/src/xrGame/WeaponKnife.cpp index df68d3058b9..3aada844a35 100644 --- a/src/xrGame/WeaponKnife.cpp +++ b/src/xrGame/WeaponKnife.cpp @@ -268,8 +268,8 @@ void CWeaponKnife::MakeShot(Fvector const& pos, Fvector const& dir, float const cartridge.param_s.impair = 1.0f; cartridge.param_s.kDisp = 1.0f; cartridge.param_s.kHit = k_hit; - //. cartridge.param_s.kCritical = 1.0f; cartridge.param_s.kImpulse = 1.0f; + cartridge.param_s.kPierce = 1.0f; cartridge.param_s.kAP = EPS_L; cartridge.m_flags.set(CCartridge::cfTracer, FALSE); cartridge.m_flags.set(CCartridge::cfRicochet, FALSE); @@ -461,47 +461,47 @@ void CWeaponKnife::LoadFireParams(LPCSTR section) s_sHitPowerCritical_2 = READ_IF_EXISTS(pSettings, r_string_wb, section, "hit_power_critical_2", s_sHitPower_2); fvHitPower_2[egdMaster] = - (float)atof(_GetItem(*s_sHitPower_2, 0, buffer)); //первый параметр - Ñто хит Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ð¸Ð³Ñ€Ñ‹ маÑтер + (float)atof(_GetItem(s_sHitPower_2.c_str(), 0, buffer)); //первый параметр - Ñто хит Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ð¸Ð³Ñ€Ñ‹ маÑтер fvHitPowerCritical_2[egdMaster] = - (float)atof(_GetItem(*s_sHitPowerCritical_2, 0, buffer)); //первый параметр - Ñто хит Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ð¸Ð³Ñ€Ñ‹ маÑтер + (float)atof(_GetItem(s_sHitPowerCritical_2.c_str(), 0, buffer)); //первый параметр - Ñто хит Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ð¸Ð³Ñ€Ñ‹ маÑтер fvHitPower_2[egdNovice] = fvHitPower_2[egdStalker] = fvHitPower_2[egdVeteran] = fvHitPower_2[egdMaster]; //изначально параметры Ð´Ð»Ñ Ð´Ñ€ÑƒÐ³Ð¸Ñ… уровней ÑложноÑти такие же fvHitPowerCritical_2[egdNovice] = fvHitPowerCritical_2[egdStalker] = fvHitPowerCritical_2[egdVeteran] = fvHitPowerCritical_2[egdMaster]; //изначально параметры Ð´Ð»Ñ Ð´Ñ€ÑƒÐ³Ð¸Ñ… уровней ÑложноÑти такие же - int num_game_diff_param = _GetItemCount(*s_sHitPower_2); //узнаём колличеÑтво параметров Ð´Ð»Ñ Ñ…Ð¸Ñ‚Ð¾Ð² + int num_game_diff_param = _GetItemCount(s_sHitPower_2.c_str()); //узнаём количеÑтво параметров Ð´Ð»Ñ Ñ…Ð¸Ñ‚Ð¾Ð² if (num_game_diff_param > 1) //еÑли задан второй параметр хита { fvHitPower_2[egdVeteran] = - (float)atof(_GetItem(*s_sHitPower_2, 1, buffer)); //то вычитываем его Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ð²ÐµÑ‚ÐµÑ€Ð°Ð½Ð° + (float)atof(_GetItem(s_sHitPower_2.c_str(), 1, buffer)); //то вычитываем его Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ð²ÐµÑ‚ÐµÑ€Ð°Ð½Ð° } if (num_game_diff_param > 2) //еÑли задан третий параметр хита { fvHitPower_2[egdStalker] = - (float)atof(_GetItem(*s_sHitPower_2, 2, buffer)); //то вычитываем его Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ñталкера + (float)atof(_GetItem(s_sHitPower_2.c_str(), 2, buffer)); //то вычитываем его Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ñталкера } if (num_game_diff_param > 3) //еÑли задан четвёртый параметр хита { fvHitPower_2[egdNovice] = - (float)atof(_GetItem(*s_sHitPower_2, 3, buffer)); //то вычитываем его Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ð½Ð¾Ð²Ð¸Ñ‡ÐºÐ° + (float)atof(_GetItem(s_sHitPower_2.c_str(), 3, buffer)); //то вычитываем его Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ð½Ð¾Ð²Ð¸Ñ‡ÐºÐ° } - num_game_diff_param = _GetItemCount(*s_sHitPowerCritical_2); //узнаём колличеÑтво параметров + num_game_diff_param = _GetItemCount(s_sHitPowerCritical_2.c_str()); //узнаём количеÑтво параметров if (num_game_diff_param > 1) //еÑли задан второй параметр хита { fvHitPowerCritical_2[egdVeteran] = - (float)atof(_GetItem(*s_sHitPowerCritical_2, 1, buffer)); //то вычитываем его Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ð²ÐµÑ‚ÐµÑ€Ð°Ð½Ð° + (float)atof(_GetItem(s_sHitPowerCritical_2.c_str(), 1, buffer)); //то вычитываем его Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ð²ÐµÑ‚ÐµÑ€Ð°Ð½Ð° } if (num_game_diff_param > 2) //еÑли задан третий параметр хита { fvHitPowerCritical_2[egdStalker] = - (float)atof(_GetItem(*s_sHitPowerCritical_2, 2, buffer)); //то вычитываем его Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ñталкера + (float)atof(_GetItem(s_sHitPowerCritical_2.c_str(), 2, buffer)); //то вычитываем его Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ñталкера } if (num_game_diff_param > 3) //еÑли задан четвёртый параметр хита { fvHitPowerCritical_2[egdNovice] = - (float)atof(_GetItem(*s_sHitPowerCritical_2, 3, buffer)); //то вычитываем его Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ð½Ð¾Ð²Ð¸Ñ‡ÐºÐ° + (float)atof(_GetItem(s_sHitPowerCritical_2.c_str(), 3, buffer)); //то вычитываем его Ð´Ð»Ñ ÑƒÑ€Ð¾Ð²Ð½Ñ Ð½Ð¾Ð²Ð¸Ñ‡ÐºÐ° } fHitImpulse_2 = pSettings->r_float(section, "hit_impulse_2"); diff --git a/src/xrGame/WeaponKnife.h b/src/xrGame/WeaponKnife.h index 152d0681c78..c1d1f83ba05 100644 --- a/src/xrGame/WeaponKnife.h +++ b/src/xrGame/WeaponKnife.h @@ -180,4 +180,7 @@ class CWeaponKnife : public CWeapon void fill_shapes_list(CEntityAlive const* entity, Fvector const& camera_endpos, victims_shapes_list_t& dest_shapes); void make_hit_sort_vectors(Fvector& basis_hit_specific, float& max_dist); void fill_shots_list(victims_shapes_list_t& victims_shapres, Fsphere const& query, shot_targets_t& dest_shots); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CWeapon); }; diff --git a/src/xrGame/WeaponLR300.h b/src/xrGame/WeaponLR300.h index 0887c2f36bc..860d1d43e9f 100644 --- a/src/xrGame/WeaponLR300.h +++ b/src/xrGame/WeaponLR300.h @@ -20,6 +20,9 @@ class CWeaponLR300 : public CWeaponMagazined CWeaponLR300(); virtual ~CWeaponLR300(); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CWeaponMagazined); }; #endif //__XR_WEAPON_LR300_H__ diff --git a/src/xrGame/WeaponMagazined.h b/src/xrGame/WeaponMagazined.h index c4fcd0fa5bf..4313581dd3e 100644 --- a/src/xrGame/WeaponMagazined.h +++ b/src/xrGame/WeaponMagazined.h @@ -180,4 +180,7 @@ class CWeaponMagazined : public CWeapon //Alundaio: LAYERED_SND_SHOOT HUD_SOUND_COLLECTION_LAYERED m_layered_sounds; //-Alundaio + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CWeapon); }; diff --git a/src/xrGame/WeaponMagazinedWGrenade.cpp b/src/xrGame/WeaponMagazinedWGrenade.cpp index 73960f96db9..455ab96f034 100644 --- a/src/xrGame/WeaponMagazinedWGrenade.cpp +++ b/src/xrGame/WeaponMagazinedWGrenade.cpp @@ -83,7 +83,7 @@ bool CWeaponMagazinedWGrenade::net_Spawn(CSE_Abstract* DC) shared_str grenade_name = m_DefaultCartridge2.m_ammoSect; shared_str fake_grenade_name = pSettings->r_string(grenade_name, "fake_grenade_name"); - CRocketLauncher::SpawnRocket(*fake_grenade_name, this); + CRocketLauncher::SpawnRocket(fake_grenade_name.c_str(), this); } } else @@ -101,7 +101,7 @@ bool CWeaponMagazinedWGrenade::net_Spawn(CSE_Abstract* DC) { shared_str fake_grenade_name = pSettings->r_string(pM->back().m_ammoSect, "fake_grenade_name"); - CRocketLauncher::SpawnRocket(*fake_grenade_name, this); + CRocketLauncher::SpawnRocket(fake_grenade_name.c_str(), this); } } return l_res; @@ -399,7 +399,7 @@ void CWeaponMagazinedWGrenade::ReloadMagazine() { shared_str fake_grenade_name = pSettings->r_string(m_ammoTypes[m_ammoType].c_str(), "fake_grenade_name"); - CRocketLauncher::SpawnRocket(*fake_grenade_name, this); + CRocketLauncher::SpawnRocket(fake_grenade_name.c_str(), this); } } @@ -457,7 +457,7 @@ bool CWeaponMagazinedWGrenade::CanAttach(PIItem pIItem) if (pGrenadeLauncher && ALife::eAddonAttachable == m_eGrenadeLauncherStatus && 0 == (m_flagsAddOnState & CSE_ALifeItemWeapon::eWeaponAddonGrenadeLauncher) && - !xr_strcmp(*m_sGrenadeLauncherName, pIItem->object().cNameSect())) + !xr_strcmp(m_sGrenadeLauncherName.c_str(), pIItem->object().cNameSect())) return true; else return inherited::CanAttach(pIItem); @@ -467,7 +467,7 @@ bool CWeaponMagazinedWGrenade::CanDetach(LPCSTR item_section_name) { if (ALife::eAddonAttachable == m_eGrenadeLauncherStatus && 0 != (m_flagsAddOnState & CSE_ALifeItemWeapon::eWeaponAddonGrenadeLauncher) && - !xr_strcmp(*m_sGrenadeLauncherName, item_section_name)) + !xr_strcmp(m_sGrenadeLauncherName.c_str(), item_section_name)) return true; else return inherited::CanDetach(item_section_name); @@ -479,7 +479,7 @@ bool CWeaponMagazinedWGrenade::Attach(PIItem pIItem, bool b_send_event) if (pGrenadeLauncher && ALife::eAddonAttachable == m_eGrenadeLauncherStatus && 0 == (m_flagsAddOnState & CSE_ALifeItemWeapon::eWeaponAddonGrenadeLauncher) && - !xr_strcmp(*m_sGrenadeLauncherName, pIItem->object().cNameSect())) + !xr_strcmp(m_sGrenadeLauncherName.c_str(), pIItem->object().cNameSect())) { m_flagsAddOnState |= CSE_ALifeItemWeapon::eWeaponAddonGrenadeLauncher; @@ -507,7 +507,7 @@ bool CWeaponMagazinedWGrenade::Detach(LPCSTR item_section_name, bool b_spawn_ite { if (ALife::eAddonAttachable == m_eGrenadeLauncherStatus && 0 != (m_flagsAddOnState & CSE_ALifeItemWeapon::eWeaponAddonGrenadeLauncher) && - !xr_strcmp(*m_sGrenadeLauncherName, item_section_name)) + !xr_strcmp(m_sGrenadeLauncherName.c_str(), item_section_name)) { m_flagsAddOnState &= ~CSE_ALifeItemWeapon::eWeaponAddonGrenadeLauncher; @@ -536,7 +536,7 @@ void CWeaponMagazinedWGrenade::InitAddons() { if (IsGrenadeLauncherAttached()) { - CRocketLauncher::m_fLaunchSpeed = pSettings->r_float(*m_sGrenadeLauncherName, "grenade_vel"); + CRocketLauncher::m_fLaunchSpeed = pSettings->r_float(m_sGrenadeLauncherName.c_str(), "grenade_vel"); } } } diff --git a/src/xrGame/WeaponMagazinedWGrenade.h b/src/xrGame/WeaponMagazinedWGrenade.h index 331a2c5530a..971d15a9c6e 100644 --- a/src/xrGame/WeaponMagazinedWGrenade.h +++ b/src/xrGame/WeaponMagazinedWGrenade.h @@ -89,4 +89,7 @@ class CWeaponMagazinedWGrenade : public CWeaponMagazined, public CRocketLauncher u8 iAmmoElapsed2; virtual void UpdateGrenadeVisibility(bool visibility); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CWeaponMagazined); }; diff --git a/src/xrGame/WeaponPM.h b/src/xrGame/WeaponPM.h index f46e6d7f2c9..7a217766601 100644 --- a/src/xrGame/WeaponPM.h +++ b/src/xrGame/WeaponPM.h @@ -14,6 +14,9 @@ class CWeaponPM : public CWeaponPistol public: CWeaponPM(); virtual ~CWeaponPM(); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CWeaponMagazined); }; #endif //__XR_WEAPON_PM_H__ diff --git a/src/xrGame/WeaponRG6.cpp b/src/xrGame/WeaponRG6.cpp index 89849b5d3a9..1fb439ce80a 100644 --- a/src/xrGame/WeaponRG6.cpp +++ b/src/xrGame/WeaponRG6.cpp @@ -28,10 +28,10 @@ bool CWeaponRG6::net_Spawn(CSE_Abstract* DC) while (k) { k--; - inheritedRL::SpawnRocket(*fake_grenade_name, this); + inheritedRL::SpawnRocket(fake_grenade_name.c_str(), this); } } - // inheritedRL::SpawnRocket(*fake_grenade_name, this); + // inheritedRL::SpawnRocket(fake_grenade_name.c_str(), this); } return l_res; @@ -140,7 +140,7 @@ u8 CWeaponRG6::AddCartridge(u8 cnt) while (k) { --k; - inheritedRL::SpawnRocket(*fake_grenade_name, this); + inheritedRL::SpawnRocket(fake_grenade_name.c_str(), this); } return k; } diff --git a/src/xrGame/WeaponRG6.h b/src/xrGame/WeaponRG6.h index e4b20565ca5..9089c45b5d4 100644 --- a/src/xrGame/WeaponRG6.h +++ b/src/xrGame/WeaponRG6.h @@ -17,4 +17,7 @@ class CWeaponRG6 : public CRocketLauncher, public CWeaponShotgun protected: virtual void FireStart(); virtual u8 AddCartridge(u8 cnt); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CWeaponShotgun); }; diff --git a/src/xrGame/WeaponRPG7.h b/src/xrGame/WeaponRPG7.h index 1b1a4a9da37..bff9b557327 100644 --- a/src/xrGame/WeaponRPG7.h +++ b/src/xrGame/WeaponRPG7.h @@ -32,4 +32,7 @@ class CWeaponRPG7 : public CWeaponCustomPistol, public CRocketLauncher virtual void PlayAnimReload(); shared_str m_sRocketSection; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CWeaponMagazined); }; diff --git a/src/xrGame/WeaponSVD.h b/src/xrGame/WeaponSVD.h index 54c5f439bc0..8781802d3ca 100644 --- a/src/xrGame/WeaponSVD.h +++ b/src/xrGame/WeaponSVD.h @@ -13,4 +13,7 @@ class CWeaponSVD : public CWeaponCustomPistol public: CWeaponSVD(void); virtual ~CWeaponSVD(void); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CWeaponMagazined); }; diff --git a/src/xrGame/WeaponSVU.h b/src/xrGame/WeaponSVU.h index e0843010067..828c43720c3 100644 --- a/src/xrGame/WeaponSVU.h +++ b/src/xrGame/WeaponSVU.h @@ -9,4 +9,7 @@ class CWeaponSVU : public CWeaponCustomPistol public: CWeaponSVU() {} virtual ~CWeaponSVU() {} + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CWeaponMagazined); }; diff --git a/src/xrGame/WeaponScript.cpp b/src/xrGame/WeaponScript.cpp index 083fa8055df..43687f85671 100644 --- a/src/xrGame/WeaponScript.cpp +++ b/src/xrGame/WeaponScript.cpp @@ -1,4 +1,5 @@ #include "pch_script.h" + #include "Weapon.h" #include "WeaponMagazined.h" #include "WeaponMagazinedWGrenade.h" @@ -31,9 +32,8 @@ #include "BottleItem.h" #include "ExplosiveItem.h" #include "InventoryBox.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CWeapon, (CGameObject), +void CWeapon::script_register(lua_State* luaState) { using namespace luabind; @@ -43,9 +43,9 @@ SCRIPT_EXPORT(CWeapon, (CGameObject), .def(constructor<>()) .def("can_kill", (bool (CWeapon::*)() const)&CWeapon::can_kill) ]; -}); +} -SCRIPT_EXPORT(CWeaponMagazined, (CWeapon), +void CWeaponMagazined::script_register(lua_State* luaState) { using namespace luabind; @@ -54,9 +54,9 @@ SCRIPT_EXPORT(CWeaponMagazined, (CWeapon), class_("CWeaponMagazined") .def(constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CWeaponMagazinedWGrenade, (CWeaponMagazined), +void CWeaponMagazinedWGrenade::script_register(lua_State* luaState) { using namespace luabind; @@ -65,9 +65,9 @@ SCRIPT_EXPORT(CWeaponMagazinedWGrenade, (CWeaponMagazined), class_("CWeaponMagazinedWGrenade") .def(constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CWeaponBinoculars, (CWeaponMagazined), +void CWeaponBinoculars::script_register(lua_State* luaState) { using namespace luabind; @@ -76,9 +76,20 @@ SCRIPT_EXPORT(CWeaponBinoculars, (CWeaponMagazined), class_("CWeaponBinoculars") .def(constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CWeaponBM16, (CWeaponShotgun), +void CWeaponShotgun::script_register(lua_State* luaState) +{ + using namespace luabind; + + module(luaState) + [ + class_("CWeaponShotgun") + .def(constructor<>()) + ]; +} + +void CWeaponBM16::script_register(lua_State* luaState) { using namespace luabind; @@ -87,9 +98,9 @@ SCRIPT_EXPORT(CWeaponBM16, (CWeaponShotgun), class_("CWeaponBM16") .def(constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CWeaponFN2000, (CWeaponMagazined), +void CWeaponFN2000::script_register(lua_State* luaState) { using namespace luabind; @@ -98,9 +109,9 @@ SCRIPT_EXPORT(CWeaponFN2000, (CWeaponMagazined), class_("CWeaponFN2000") .def(constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CWeaponFORT, (CWeaponMagazined), +void CWeaponFORT::script_register(lua_State* luaState) { using namespace luabind; @@ -109,9 +120,9 @@ SCRIPT_EXPORT(CWeaponFORT, (CWeaponMagazined), class_("CWeaponFORT") .def(constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CF1, (CGameObject, CExplosive), +void CF1::script_register(lua_State* luaState) { using namespace luabind; @@ -135,9 +146,9 @@ SCRIPT_EXPORT(CF1, (CGameObject, CExplosive), class_>("CExplosiveItem") .def(constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CWeaponHPSA, (CWeaponMagazined), +void CWeaponHPSA::script_register(lua_State* luaState) { using namespace luabind; @@ -146,9 +157,9 @@ SCRIPT_EXPORT(CWeaponHPSA, (CWeaponMagazined), class_("CWeaponHPSA") .def(constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CWeaponKnife, (CWeapon), +void CWeaponKnife::script_register(lua_State* luaState) { using namespace luabind; @@ -157,9 +168,9 @@ SCRIPT_EXPORT(CWeaponKnife, (CWeapon), class_("CWeaponKnife") .def(constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CWeaponLR300, (CWeaponMagazined), +void CWeaponLR300::script_register(lua_State* luaState) { using namespace luabind; @@ -168,9 +179,9 @@ SCRIPT_EXPORT(CWeaponLR300, (CWeaponMagazined), class_("CWeaponLR300") .def(constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CWeaponPM, (CWeaponMagazined), +void CWeaponPM::script_register(lua_State* luaState) { using namespace luabind; @@ -179,9 +190,9 @@ SCRIPT_EXPORT(CWeaponPM, (CWeaponMagazined), class_("CWeaponPM") .def(constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CRGD5, (CGameObject, CExplosive), +void CRGD5::script_register(lua_State* luaState) { using namespace luabind; @@ -190,9 +201,9 @@ SCRIPT_EXPORT(CRGD5, (CGameObject, CExplosive), class_>("CRGD5") .def(constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CWeaponRPG7, (CWeaponMagazined), +void CWeaponRPG7::script_register(lua_State* luaState) { using namespace luabind; @@ -201,9 +212,9 @@ SCRIPT_EXPORT(CWeaponRPG7, (CWeaponMagazined), class_("CWeaponRPG7") .def(constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CWeaponSVD, (CWeaponMagazined), +void CWeaponSVD::script_register(lua_State* luaState) { using namespace luabind; @@ -212,9 +223,9 @@ SCRIPT_EXPORT(CWeaponSVD, (CWeaponMagazined), class_("CWeaponSVD") .def(constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CWeaponSVU, (CWeaponMagazined), +void CWeaponSVU::script_register(lua_State* luaState) { using namespace luabind; @@ -223,9 +234,9 @@ SCRIPT_EXPORT(CWeaponSVU, (CWeaponMagazined), class_("CWeaponSVU") .def(constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CWeaponAK74, (CWeaponMagazinedWGrenade), +void CWeaponAK74::script_register(lua_State* luaState) { using namespace luabind; @@ -234,9 +245,9 @@ SCRIPT_EXPORT(CWeaponAK74, (CWeaponMagazinedWGrenade), class_("CWeaponAK74") .def(constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CWeaponAutomaticShotgun, (CWeaponMagazined), +void CWeaponAutomaticShotgun::script_register(lua_State* luaState) { using namespace luabind; @@ -245,9 +256,9 @@ SCRIPT_EXPORT(CWeaponAutomaticShotgun, (CWeaponMagazined), class_("CWeaponAutomaticShotgun") .def(constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CWeaponGroza, (CWeaponMagazinedWGrenade), +void CWeaponGroza::script_register(lua_State* luaState) { using namespace luabind; @@ -256,9 +267,9 @@ SCRIPT_EXPORT(CWeaponGroza, (CWeaponMagazinedWGrenade), class_("CWeaponGroza") .def(constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CWeaponRG6, (CWeaponShotgun), +void CWeaponRG6::script_register(lua_State* luaState) { using namespace luabind; @@ -267,20 +278,9 @@ SCRIPT_EXPORT(CWeaponRG6, (CWeaponShotgun), class_("CWeaponRG6") .def(constructor<>()) ]; -}); - -SCRIPT_EXPORT(CWeaponShotgun, (CWeaponMagazined), -{ - using namespace luabind; - - module(luaState) - [ - class_("CWeaponShotgun") - .def(constructor<>()) - ]; -}); +} -SCRIPT_EXPORT(CWeaponUSP45, (CWeaponMagazined), +void CWeaponUSP45::script_register(lua_State* luaState) { using namespace luabind; @@ -289,9 +289,9 @@ SCRIPT_EXPORT(CWeaponUSP45, (CWeaponMagazined), class_("CWeaponUSP45") .def(constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CWeaponVal, (CWeaponMagazined), +void CWeaponVal::script_register(lua_State* luaState) { using namespace luabind; @@ -300,9 +300,9 @@ SCRIPT_EXPORT(CWeaponVal, (CWeaponMagazined), class_("CWeaponVal") .def(constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CWeaponVintorez, (CWeaponMagazined), +void CWeaponVintorez::script_register(lua_State* luaState) { using namespace luabind; @@ -311,9 +311,9 @@ SCRIPT_EXPORT(CWeaponVintorez, (CWeaponMagazined), class_("CWeaponVintorez") .def(constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CWeaponWalther, (CWeaponMagazined), +void CWeaponWalther::script_register(lua_State* luaState) { using namespace luabind; @@ -322,4 +322,4 @@ SCRIPT_EXPORT(CWeaponWalther, (CWeaponMagazined), class_("CWeaponWalther") .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/WeaponShotgun.cpp b/src/xrGame/WeaponShotgun.cpp index 774a85b91e1..a6434351485 100644 --- a/src/xrGame/WeaponShotgun.cpp +++ b/src/xrGame/WeaponShotgun.cpp @@ -268,7 +268,7 @@ void CWeaponShotgun::net_Import(NET_Packet& P) if (LocalAmmoType == l_cartridge.m_LocalAmmoType) continue; #ifdef DEBUG - Msg("! %s reload to %s", *l_cartridge.m_ammoSect, m_ammoTypes[LocalAmmoType].c_str()); + Msg("! %s reload to %s", l_cartridge.m_ammoSect.c_str(), m_ammoTypes[LocalAmmoType].c_str()); #endif l_cartridge.Load(m_ammoTypes[LocalAmmoType].c_str(), LocalAmmoType); } diff --git a/src/xrGame/WeaponShotgun.h b/src/xrGame/WeaponShotgun.h index b989ec13ee0..d71b434fba3 100644 --- a/src/xrGame/WeaponShotgun.h +++ b/src/xrGame/WeaponShotgun.h @@ -39,4 +39,7 @@ class CWeaponShotgun : public CWeaponCustomPistol ESoundTypes m_eSoundOpen; ESoundTypes m_eSoundAddCartridge; ESoundTypes m_eSoundClose; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CWeaponMagazined); }; diff --git a/src/xrGame/WeaponUSP45.h b/src/xrGame/WeaponUSP45.h index b2f3ed338c9..a5969b71d03 100644 --- a/src/xrGame/WeaponUSP45.h +++ b/src/xrGame/WeaponUSP45.h @@ -9,4 +9,7 @@ class CWeaponUSP45 : public CWeaponPistol public: CWeaponUSP45() {} virtual ~CWeaponUSP45() {} + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CWeaponMagazined); }; diff --git a/src/xrGame/WeaponUpgrade.cpp b/src/xrGame/WeaponUpgrade.cpp index 362b7df8a26..f974a4b83f0 100644 --- a/src/xrGame/WeaponUpgrade.cpp +++ b/src/xrGame/WeaponUpgrade.cpp @@ -144,21 +144,21 @@ bool CWeapon::install_upgrade_hit(LPCSTR section, bool test) if (result2 && !test) { string32 buffer; - fvHitPower[egdMaster] = (float)atof(_GetItem(*s_sHitPower, 0, buffer)); + fvHitPower[egdMaster] = (float)atof(_GetItem(s_sHitPower.c_str(), 0, buffer)); fvHitPower[egdNovice] = fvHitPower[egdStalker] = fvHitPower[egdVeteran] = fvHitPower[egdMaster]; - int num_game_diff_param = _GetItemCount(*s_sHitPower); + int num_game_diff_param = _GetItemCount(s_sHitPower.c_str()); if (num_game_diff_param > 1) { - fvHitPower[egdVeteran] = (float)atof(_GetItem(*s_sHitPower, 1, buffer)); + fvHitPower[egdVeteran] = (float)atof(_GetItem(s_sHitPower.c_str(), 1, buffer)); } if (num_game_diff_param > 2) { - fvHitPower[egdStalker] = (float)atof(_GetItem(*s_sHitPower, 2, buffer)); + fvHitPower[egdStalker] = (float)atof(_GetItem(s_sHitPower.c_str(), 2, buffer)); } if (num_game_diff_param > 3) { - fvHitPower[egdNovice] = (float)atof(_GetItem(*s_sHitPower, 3, buffer)); + fvHitPower[egdNovice] = (float)atof(_GetItem(s_sHitPower.c_str(), 3, buffer)); } } result |= result2; @@ -168,22 +168,22 @@ bool CWeapon::install_upgrade_hit(LPCSTR section, bool test) if (result2 && !test) { string32 buffer; - fvHitPowerCritical[egdMaster] = (float)atof(_GetItem(*s_sHitPowerCritical, 0, buffer)); + fvHitPowerCritical[egdMaster] = (float)atof(_GetItem(s_sHitPowerCritical.c_str(), 0, buffer)); fvHitPowerCritical[egdNovice] = fvHitPowerCritical[egdStalker] = fvHitPowerCritical[egdVeteran] = fvHitPowerCritical[egdMaster]; - int num_game_diff_param = _GetItemCount(*s_sHitPowerCritical); + int num_game_diff_param = _GetItemCount(s_sHitPowerCritical.c_str()); if (num_game_diff_param > 1) { - fvHitPowerCritical[egdVeteran] = (float)atof(_GetItem(*s_sHitPowerCritical, 1, buffer)); + fvHitPowerCritical[egdVeteran] = (float)atof(_GetItem(s_sHitPowerCritical.c_str(), 1, buffer)); } if (num_game_diff_param > 2) { - fvHitPowerCritical[egdStalker] = (float)atof(_GetItem(*s_sHitPowerCritical, 2, buffer)); + fvHitPowerCritical[egdStalker] = (float)atof(_GetItem(s_sHitPowerCritical.c_str(), 2, buffer)); } if (num_game_diff_param > 3) { - fvHitPowerCritical[egdNovice] = (float)atof(_GetItem(*s_sHitPowerCritical, 3, buffer)); + fvHitPowerCritical[egdNovice] = (float)atof(_GetItem(s_sHitPowerCritical.c_str(), 3, buffer)); } } result |= result2; diff --git a/src/xrGame/WeaponVal.h b/src/xrGame/WeaponVal.h index 70af2c8abe1..8918a95d297 100644 --- a/src/xrGame/WeaponVal.h +++ b/src/xrGame/WeaponVal.h @@ -9,4 +9,7 @@ class CWeaponVal : public CWeaponMagazined public: CWeaponVal(void); virtual ~CWeaponVal(void); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CWeaponMagazined); }; diff --git a/src/xrGame/WeaponVintorez.h b/src/xrGame/WeaponVintorez.h index eebc6ea13e3..f00cefd17c2 100644 --- a/src/xrGame/WeaponVintorez.h +++ b/src/xrGame/WeaponVintorez.h @@ -9,4 +9,7 @@ class CWeaponVintorez : public CWeaponMagazined public: CWeaponVintorez(void); virtual ~CWeaponVintorez(void); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CWeaponMagazined); }; diff --git a/src/xrGame/WeaponWalther.h b/src/xrGame/WeaponWalther.h index 99b5d9325d0..2aac14e6dcd 100644 --- a/src/xrGame/WeaponWalther.h +++ b/src/xrGame/WeaponWalther.h @@ -8,4 +8,7 @@ class CWeaponWalther : public CWeaponPistol public: CWeaponWalther() {} virtual ~CWeaponWalther() {} + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CWeaponMagazined); }; diff --git a/src/xrGame/account_manager.h b/src/xrGame/account_manager.h index fce9e2b1f1a..5988503f83c 100644 --- a/src/xrGame/account_manager.h +++ b/src/xrGame/account_manager.h @@ -130,6 +130,9 @@ class account_manager : private Noncopyable /*static void __cdecl profiles_cb (GPConnection * connection, void * arg, void * param);*/ + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; // class account_manager } // namespace gamespy_gp diff --git a/src/xrGame/account_manager_script.cpp b/src/xrGame/account_manager_script.cpp index 98e3ba1cd5b..063ff3efdb9 100644 --- a/src/xrGame/account_manager_script.cpp +++ b/src/xrGame/account_manager_script.cpp @@ -1,8 +1,10 @@ #include "StdAfx.h" + #include "account_manager.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(account_manager, (), +namespace gamespy_gp +{ +void account_manager::script_register(lua_State* luaState) { using namespace luabind; using namespace luabind::policy; @@ -32,68 +34,10 @@ SCRIPT_EXPORT(account_manager, (), .def("search_for_email", &account_manager::search_for_email) .def("stop_searching_email", &account_manager::stop_searching_email) ]; -}); +} +} // namespace gamespy_gp -SCRIPT_EXPORT(suggest_nicks_cb, (), -{ - using namespace luabind; - using namespace gamespy_gp; - - module(luaState) - [ - class_("suggest_nicks_cb") - .def(constructor<>()) - .def(constructor()) - .def("bind", (suggest_nicks_cb::lua_bind_type)(&suggest_nicks_cb::bind)) - .def("clear", &suggest_nicks_cb::clear) - ]; -}); - -SCRIPT_EXPORT(account_operation_cb, (), -{ - using namespace luabind; - using namespace gamespy_gp; - - module(luaState) - [ - class_("account_operation_cb") - .def(constructor<>()) - .def(constructor()) - .def("bind", (account_operation_cb::lua_bind_type)(&account_operation_cb::bind)) - .def("clear", &account_operation_cb::clear) - ]; -}); - -SCRIPT_EXPORT(account_profiles_cb, (), -{ - using namespace luabind; - using namespace gamespy_gp; - - module(luaState) - [ - class_("account_profiles_cb") - .def(constructor<>()) - .def(constructor()) - .def("bind", (account_profiles_cb::lua_bind_type)(&account_profiles_cb::bind)) - .def("clear", &account_profiles_cb::clear) - ]; -}); - -SCRIPT_EXPORT(found_email_cb, (), -{ - using namespace luabind; - using namespace gamespy_gp; - - module(luaState) - [ - class_("found_email_cb") - .def(constructor<>()) - .def(constructor()) - .def("bind", (found_email_cb::lua_bind_type)(&found_email_cb::bind)) - .def("clear", &found_email_cb::clear) - ]; -}); +DEFINE_MIXED_DELEGATE_SCRIPT(gamespy_gp::suggest_nicks_cb, "suggest_nicks_cb"); +DEFINE_MIXED_DELEGATE_SCRIPT(gamespy_gp::account_operation_cb, "account_operation_cb"); +DEFINE_MIXED_DELEGATE_SCRIPT(gamespy_gp::account_profiles_cb, "account_profiles_cb"); +DEFINE_MIXED_DELEGATE_SCRIPT(gamespy_gp::found_email_cb, "found_email_cb"); diff --git a/src/xrGame/action_base.h b/src/xrGame/action_base.h index 319e9227061..fa08398112d 100644 --- a/src/xrGame/action_base.h +++ b/src/xrGame/action_base.h @@ -80,6 +80,12 @@ class CActionBase : public GraphEngineSpace::CWorldOperator virtual void save(NET_Packet& packet) {} virtual void load(IReader& packet) {} }; -typedef CActionBase CScriptActionBase; + +using CScriptActionBase = CActionBase; + +class CScriptActionBaseExport +{ + DECLARE_SCRIPT_REGISTER_FUNCTION(); +}; #include "action_base_inline.h" diff --git a/src/xrGame/action_base_script.cpp b/src/xrGame/action_base_script.cpp index 6bc1e2f0a20..b7fe581f493 100644 --- a/src/xrGame/action_base_script.cpp +++ b/src/xrGame/action_base_script.cpp @@ -7,11 +7,11 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "script_action_wrapper.h" #include "script_game_object.h" -#include "xrScriptEngine/ScriptExporter.hpp" -IC static void CScriptActionBase_Export(lua_State* luaState) +void CScriptActionBaseExport::script_register(lua_State* luaState) { using namespace luabind; @@ -45,5 +45,3 @@ IC static void CScriptActionBase_Export(lua_State* luaState) #endif ]; } - -SCRIPT_EXPORT_FUNC(CScriptActionBase, (), CScriptActionBase_Export); diff --git a/src/xrGame/action_planner.h b/src/xrGame/action_planner.h index 870969a2bc8..9fed4bfcbd1 100644 --- a/src/xrGame/action_planner.h +++ b/src/xrGame/action_planner.h @@ -88,6 +88,12 @@ class CActionPlanner virtual void save(NET_Packet& packet); virtual void load(IReader& packet); }; -typedef CActionPlanner CScriptActionPlanner; + +using CScriptActionPlanner = CActionPlanner; + +class CScriptActionPlannerExport +{ + DECLARE_SCRIPT_REGISTER_FUNCTION(); +}; #include "action_planner_inline.h" diff --git a/src/xrGame/action_planner_action.h b/src/xrGame/action_planner_action.h index 98a38b09b87..c0f9caed490 100644 --- a/src/xrGame/action_planner_action.h +++ b/src/xrGame/action_planner_action.h @@ -55,6 +55,12 @@ class CActionPlannerAction : public CActionPlanner<_object_type>, public CAction inherited_action::load(packet); } }; -typedef CActionPlannerAction CScriptActionPlannerAction; + +using CScriptActionPlannerAction = CActionPlannerAction; + +class CScriptActionPlannerActionExport +{ + DECLARE_SCRIPT_REGISTER_FUNCTION(CScriptActionPlannerExport, CScriptActionBaseExport); +}; #include "action_planner_action_inline.h" diff --git a/src/xrGame/action_planner_action_script.cpp b/src/xrGame/action_planner_action_script.cpp index 8ffc96f5fcf..d5e1573bf72 100644 --- a/src/xrGame/action_planner_action_script.cpp +++ b/src/xrGame/action_planner_action_script.cpp @@ -7,11 +7,11 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "script_action_planner_action_wrapper.h" #include "script_game_object.h" -#include "xrScriptEngine/ScriptExporter.hpp" -IC static void CScriptActionPlannerAction_Export(lua_State* luaState) +void CScriptActionPlannerActionExport::script_register(lua_State* luaState) { using namespace luabind; @@ -38,5 +38,3 @@ IC static void CScriptActionPlannerAction_Export(lua_State* luaState) &CScriptActionPlannerActionWrapper::weight_static) ]; } - -SCRIPT_EXPORT_FUNC(CScriptActionPlannerAction, (CScriptActionPlanner, CScriptActionBase), CScriptActionPlannerAction_Export); diff --git a/src/xrGame/action_planner_inline.h b/src/xrGame/action_planner_inline.h index 247d551acb6..21013529cef 100644 --- a/src/xrGame/action_planner_inline.h +++ b/src/xrGame/action_planner_inline.h @@ -179,7 +179,7 @@ LPCSTR CPlanner::property2string(const _condition_type& property_id) } TEMPLATE_SPECIALIZATION -LPCSTR CPlanner::object_name() const { return (*m_object->cName()); } +pcstr CPlanner::object_name() const { return m_object->cName().c_str(); } #endif TEMPLATE_SPECIALIZATION diff --git a/src/xrGame/action_planner_script.cpp b/src/xrGame/action_planner_script.cpp index c7f51ac1430..099b24fdcfb 100644 --- a/src/xrGame/action_planner_script.cpp +++ b/src/xrGame/action_planner_script.cpp @@ -7,21 +7,27 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "script_action_planner_wrapper.h" #include "script_game_object.h" #include "action_base.h" -#include "xrScriptEngine/ScriptExporter.hpp" void set_goal_world_state(CScriptActionPlanner* action_planner, CScriptActionPlanner::CState* world_state) { action_planner->set_target_state(*world_state); } -bool get_actual(const CScriptActionPlanner* action_planner) { return (action_planner->actual()); } +bool get_actual(const CScriptActionPlanner* action_planner) +{ + return (action_planner->actual()); +} -CScriptActionPlanner* cast_planner(CScriptActionBase* action) { return (smart_cast(action)); } +CScriptActionPlanner* cast_planner(CScriptActionBase* action) +{ + return (smart_cast(action)); +} -IC static void CScriptActionPlanner_Export(lua_State* luaState) +void CScriptActionPlannerExport::script_register(lua_State* luaState) { using namespace luabind; using namespace luabind::policy; @@ -60,5 +66,3 @@ IC static void CScriptActionPlanner_Export(lua_State* luaState) def("cast_planner", &cast_planner) ]; } - -SCRIPT_EXPORT_FUNC(CScriptActionPlanner, (), CScriptActionPlanner_Export); diff --git a/src/xrGame/actor_mp_server.cpp b/src/xrGame/actor_mp_server.cpp index f7d9bc87870..11baff36593 100644 --- a/src/xrGame/actor_mp_server.cpp +++ b/src/xrGame/actor_mp_server.cpp @@ -28,7 +28,6 @@ BOOL CSE_ActorMP::Net_Relevant() return (inherited::Net_Relevant()); } -#ifdef XRGAME_EXPORTS void CSE_ActorMP::on_death(CSE_Abstract* killer) { inherited::on_death(killer); @@ -37,4 +36,3 @@ void CSE_ActorMP::on_death(CSE_Abstract* killer) fill_state(state); m_state_holder.relevant(state); } -#endif diff --git a/src/xrGame/actor_mp_server.h b/src/xrGame/actor_mp_server.h index cb64715a351..83563ba1926 100644 --- a/src/xrGame/actor_mp_server.h +++ b/src/xrGame/actor_mp_server.h @@ -24,9 +24,7 @@ class CSE_ActorMP : public CSE_ALifeCreatureActor virtual void STATE_Write(NET_Packet& packet); virtual BOOL Net_Relevant(); -#ifdef XRGAME_EXPORTS virtual void on_death(CSE_Abstract* killer); -#endif }; #endif // ACTOR_MP_SERVER_H diff --git a/src/xrGame/actor_script.cpp b/src/xrGame/actor_script.cpp index 36a34cbefcd..d252fd5dbdd 100644 --- a/src/xrGame/actor_script.cpp +++ b/src/xrGame/actor_script.cpp @@ -7,12 +7,12 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "Actor.h" #include "ActorCondition.h" #include "level_changer.h" -#include "xrScriptEngine/ScriptExporter.hpp" -IC static void CActor_Export(lua_State* luaState) +void CActor::script_register(lua_State* luaState) { using namespace luabind; @@ -24,6 +24,4 @@ IC static void CActor_Export(lua_State* luaState) class_("CLevelChanger") .def(constructor<>()) ]; -}; - -SCRIPT_EXPORT_FUNC(CActor, (CGameObject), CActor_Export); +} diff --git a/src/xrGame/ai/crow/ai_crow.h b/src/xrGame/ai/crow/ai_crow.h index dbe5393661a..a262c846378 100644 --- a/src/xrGame/ai/crow/ai_crow.h +++ b/src/xrGame/ai/crow/ai_crow.h @@ -142,6 +142,9 @@ class CAI_Crow : public CEntity virtual bool IsVisibleForZones() { return false; } virtual bool UsedAI_Locations(); virtual void create_physic_shell(); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; #endif diff --git a/src/xrGame/ai/monsters/ai_monster_defs.h b/src/xrGame/ai/monsters/ai_monster_defs.h index 14de0844b83..d0619e641db 100644 --- a/src/xrGame/ai/monsters/ai_monster_defs.h +++ b/src/xrGame/ai/monsters/ai_monster_defs.h @@ -3,7 +3,7 @@ #include "Include/xrRender/KinematicsAnimated.h" #include "xrEngine/CameraManager.h" -typedef u32 TTime; +using TTime = u32; #define COLOR color_xrgb #define COLOR_RED COLOR(255, 0, 0) @@ -43,20 +43,22 @@ class CBlend; #define HIT_LOW 0 #define HIT_HIGH 1 -// Enemy flags -#define FLAG_ENEMY_DIE (1 << 0) -#define FLAG_ENEMY_LOST_SIGHT (1 << 1) -#define FLAG_ENEMY_GO_CLOSER (1 << 2) -#define FLAG_ENEMY_GO_FARTHER (1 << 3) -#define FLAG_ENEMY_GO_CLOSER_FAST (1 << 4) -#define FLAG_ENEMY_GO_FARTHER_FAST (1 << 5) -#define FLAG_ENEMY_STANDING (1 << 6) -#define FLAG_ENEMY_HIDING (1 << 7) -#define FLAG_ENEMY_RUN_AWAY (1 << 8) -#define FLAG_ENEMY_DOESNT_KNOW_ABOUT_ME (1 << 9) -#define FLAG_ENEMY_GO_OFFLINE (1 << 10) -#define FLAG_ENEMY_DOESNT_SEE_ME (1 << 11) -#define FLAG_ENEMY_STATS_NOT_READY (1 << 12) +enum EnemyFlags : u16 +{ + FLAG_ENEMY_DIE = 1 << 0, + FLAG_ENEMY_LOST_SIGHT = 1 << 1, + FLAG_ENEMY_GO_CLOSER = 1 << 2, + FLAG_ENEMY_GO_FARTHER = 1 << 3, + FLAG_ENEMY_GO_CLOSER_FAST = 1 << 4, + FLAG_ENEMY_GO_FARTHER_FAST = 1 << 5, + FLAG_ENEMY_STANDING = 1 << 6, + FLAG_ENEMY_HIDING = 1 << 7, + FLAG_ENEMY_RUN_AWAY = 1 << 8, + FLAG_ENEMY_DOESNT_KNOW_ABOUT_ME = 1 << 9, + FLAG_ENEMY_GO_OFFLINE = 1 << 10, + FLAG_ENEMY_DOESNT_SEE_ME = 1 << 11, + FLAG_ENEMY_STATS_NOT_READY = 1 << 12, +}; #define SOUND_ATTACK_HIT_MIN_DELAY 1000 #define MORALE_NORMAL 0.5f @@ -89,23 +91,14 @@ struct SVelocityParam { struct { - float linear; - float angular_path; - float angular_real; - } velocity; - float min_factor; - float max_factor; - - SVelocityParam() - { - velocity.linear = 0.f; - velocity.angular_real = 0.f; - velocity.angular_path = 0.f; - min_factor = 1.0f; - max_factor = 1.0f; - } - - void Load(LPCSTR section, LPCSTR line) + float linear{}; + float angular_path{}; + float angular_real{}; + } velocity{}; + float min_factor{ 1.0f }; + float max_factor{ 1.0f }; + + void Load(pcstr section, pcstr line) { string32 buffer; velocity.linear = float(atof(_GetItem(pSettings->r_string(section, line), 0, buffer))); @@ -117,9 +110,9 @@ struct SVelocityParam }; // Activities -enum EMotionAnim +enum EMotionAnim : u8 { - eAnimStandIdle = u32(0), + eAnimStandIdle, eAnimCapturePrepare, eAnimStandTurnLeft, eAnimStandTurnRight, @@ -229,13 +222,13 @@ enum EMotionAnim eAnimFastStandTurnRight, eAnimCount, - eAnimUndefined = u32(-1) + eAnimUndefined = u8(-1), }; // Generic actions -enum EAction +enum EAction : u8 { - ACT_STAND_IDLE = u32(0), + ACT_STAND_IDLE, ACT_SIT_IDLE, ACT_LIE_IDLE, ACT_WALK_FWD, @@ -251,10 +244,10 @@ enum EAction ACT_LOOK_AROUND, ACT_HOME_WALK_GROWL, ACT_HOME_WALK_SMELLING, - ACT_NONE = u32(-1) + ACT_NONE = u8(-1), }; -enum EPState +enum EPState : u8 { PS_STAND, PS_SIT, @@ -262,43 +255,40 @@ enum EPState PS_STAND_UPPER }; -enum EHitSide +enum EHitSide : u8 { - eSideFront = u32(0), + eSideFront, eSideBack, eSideLeft, eSideRight, eSideCount }; -typedef shared_str anim_string; -#define DEFAULT_ANIM eAnimStandIdle +using anim_string = shared_str; + +constexpr auto DEFAULT_ANIM = eAnimStandIdle; // Ñлемент анимации struct SAnimItem { anim_string target_name; // "stand_idle_" - anim_string target_name2; // "stand_idle_" - bool target_may_not_exist; - int spec_id; // (-1) - any, (0 - ...) - идентификатор 3 + s8 spec_id; // (-1) - any, (0 - 127) - идентификатор 3 u8 count; // количеÑтво анимаций : "idle_0", "idle_1", "idle_2" + EPState pos_state; SVelocityParam velocity; - EPState pos_state; - - struct + struct Effects { anim_string front; anim_string back; anim_string left; anim_string right; - std::bitset may_not_exist; } fxs; }; -#define SKIP_IF_AGGRESSIVE true +constexpr bool SKIP_IF_AGGRESSIVE = true; // опиÑание перехода struct STransition @@ -338,7 +328,7 @@ struct SReplacedAnim }; // Определение времени аттаки по анимации -typedef struct +struct SAttackAnimation { EMotionAnim anim; // параметры конкретной анимации u32 anim_i3; @@ -361,8 +351,7 @@ typedef struct float pitch_from; float pitch_to; float dist; - -} SAttackAnimation; +}; struct SAAParam { @@ -401,27 +390,32 @@ struct SCurrentAnimationInfo struct { - IC void _set_current(float v) + void _set_current(float v) { current = v; VERIFY2(_abs(v) < 1000, "_set_current(). monster speed is too big"); } - IC void _set_target(float v) + void _set_target(float v) { target = v; VERIFY2(_abs(v) < 1000, "_set_target(). monster speed is too big"); } - IC float _get_current() { return current; } - IC float _get_target() { return target; } + + [[nodiscard]] + float _get_current() const { return current; } + + [[nodiscard]] + float _get_target() const { return target; } private: float current; float target; } speed; - void set_motion(EMotionAnim new_motion); - EMotionAnim get_motion() const { return motion; } + [[nodiscard]] + auto get_motion() const { return motion; } + void set_motion(const EMotionAnim new_motion) { motion = new_motion; } }; ////////////////////////////////////////////////////////////////////////// @@ -432,16 +426,7 @@ struct t_fx_index s8 back; }; -using ANIM_ITEM_VECTOR = xr_vector; -using TRANSITION_ANIM_VECTOR = xr_vector; -using MOTION_ITEM_MAP = xr_map; using SEQ_VECTOR = xr_vector; -using ATTACK_ANIM = xr_vector; -using REPLACED_ANIM = xr_vector; - -using FX_MAP_U16 = xr_map; -using FX_MAP_STRING = xr_map; - using VELOCITY_CHAIN_VEC = xr_vector; struct SVelocity @@ -467,13 +452,13 @@ struct SMotionVel } }; -enum EAccelType +enum EAccelType : u8 { eAT_Calm, eAT_Aggressive }; -enum EAccelValue +enum EAccelValue : u8 { eAV_Accel, eAV_Braking @@ -531,16 +516,16 @@ using CORPSE_MAP_IT = CORPSE_MAP::iterator; struct SMonsterHit { IGameObject* object; + Fvector position; TTime time; EHitSide side; - Fvector position; - bool operator==(const IGameObject* obj) { return (object == obj); } + bool operator==(const IGameObject* obj) const { return (object == obj); } }; using MONSTER_HIT_VECTOR = xr_vector; -enum EDangerType +enum EDangerType : u8 { eWeak, eNormal, diff --git a/src/xrGame/ai/monsters/bloodsucker/bloodsucker.cpp b/src/xrGame/ai/monsters/bloodsucker/bloodsucker.cpp index 81e63ecd645..cde154b4816 100644 --- a/src/xrGame/ai/monsters/bloodsucker/bloodsucker.cpp +++ b/src/xrGame/ai/monsters/bloodsucker/bloodsucker.cpp @@ -104,7 +104,7 @@ void CAI_Bloodsucker::Load(LPCSTR section) anim().AddAnim(eAnimStandTurnLeft, "stand_turn_ls_", -1, &velocity_turn, PS_STAND); anim().AddAnim(eAnimStandTurnRight, "stand_turn_rs_", -1, &velocity_turn, PS_STAND); anim().AddAnim(eAnimSleep, "lie_sleep_", -1, &velocity_none, PS_LIE); - anim().AddAnim(eAnimSleepStanding, { "stand_sleep_", true }, -1, &velocity_none, PS_STAND); + anim().AddAnim(eAnimSleepStanding, "stand_sleep_", -1, &velocity_none, PS_STAND, false); anim().AddAnim(eAnimWalkFwd, "stand_walk_fwd_", -1, &velocity_walk, PS_STAND); anim().AddAnim(eAnimWalkDamaged, "stand_walk_fwd_dmg_", -1, &velocity_walk_dmg, PS_STAND); anim().AddAnim(eAnimRun, "stand_run_", -1, &velocity_run, PS_STAND); @@ -135,65 +135,41 @@ void CAI_Bloodsucker::Load(LPCSTR section) } else { - anim().AddAnim(eAnimStandIdle, "stand_idle_", -1, &velocity_none, PS_STAND, "fx_run_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimStandDamaged, "stand_damaged_", -1, &velocity_none, PS_STAND, "fx_run_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimStandTurnLeft, "stand_turn_ls_", -1, &velocity_turn, PS_STAND, "fx_run_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimStandTurnRight, "stand_turn_rs_", -1, &velocity_turn, PS_STAND, "fx_run_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim( - eAnimSleep, "lie_sleep_", -1, &velocity_none, PS_LIE, "fx_run_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimSleepStanding, { "stand_sleep_", true }, -1, &velocity_none, PS_STAND, "fx_run_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimWalkFwd, "stand_walk_fwd_", -1, &velocity_walk, PS_STAND, "fx_run_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimWalkDamaged, "stand_walk_fwd_dmg_", -1, &velocity_walk_dmg, PS_STAND, "fx_run_f", - "fx_stand_b", "fx_stand_l", "fx_stand_r"); - anim().AddAnim( - eAnimRun, "stand_run_", -1, &velocity_run, PS_STAND, "fx_run_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimRunDamaged, "stand_run_dmg_", -1, &velocity_run_dmg, PS_STAND, "fx_run_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - - anim().AddAnim(eAnimRunTurnLeft, "stand_run_turn_left_", -1, &velocity_run, PS_STAND, "fx_run_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimRunTurnRight, "stand_run_turn_right_", -1, &velocity_run, PS_STAND, "fx_run_f", - "fx_stand_b", "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimScared, "stand_scared_", -1, &velocity_none, PS_STAND, "fx_run_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - - anim().AddAnim(eAnimCheckCorpse, "stand_check_corpse_", -1, &velocity_none, PS_STAND, "fx_run_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim( - eAnimEat, "sit_eat_", -1, &velocity_none, PS_SIT, "fx_run_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); - - anim().AddAnim(eAnimDie, "stand_idle_", -1, &velocity_none, PS_STAND, "fx_run_f", "fx_stand_b", "fx_stand_l", - "fx_stand_r"); - - anim().AddAnim(eAnimAttack, "stand_attack_", -1, &velocity_turn, PS_STAND, "fx_run_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimAttackRun, "stand_attack_run_", -1, &velocity_run, PS_STAND, "fx_run_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - - anim().AddAnim(eAnimLookAround, "stand_look_around_", -1, &velocity_none, PS_STAND, "fx_run_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimSitIdle, "sit_idle_", -1, &velocity_none, PS_SIT, "fx_run_f", "fx_stand_b", "fx_stand_l", - "fx_stand_r"); - anim().AddAnim(eAnimSitStandUp, "sit_stand_up_", -1, &velocity_none, PS_SIT, "fx_run_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimSitToSleep, "sit_sleep_down_", -1, &velocity_none, PS_SIT, "fx_run_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimStandSitDown, "stand_sit_down_", -1, &velocity_none, PS_STAND, "fx_run_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - - anim().AddAnim(eAnimSteal, "stand_steal_", -1, &velocity_steal, PS_STAND, "fx_run_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - - anim().AddAnim(eAnimThreaten, "stand_threaten_", -1, &velocity_none, PS_STAND, "fx_run_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimMiscAction_00, "stand_to_aggressive_", -1, &velocity_none, PS_STAND, "fx_run_f", - "fx_stand_b", "fx_stand_l", "fx_stand_r"); + const SAnimItem::Effects fxs{ "fx_run_f", "fx_stand_b", "fx_stand_l", "fx_stand_r" }; + + anim().AddAnim(eAnimStandIdle, "stand_idle_", -1, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimStandDamaged, "stand_damaged_", -1, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimStandTurnLeft, "stand_turn_ls_", -1, &velocity_turn, PS_STAND, fxs); + anim().AddAnim(eAnimStandTurnRight, "stand_turn_rs_", -1, &velocity_turn, PS_STAND, fxs); + anim().AddAnim(eAnimSleep, "lie_sleep_", -1, &velocity_none, PS_LIE, fxs); + anim().AddAnim(eAnimSleepStanding, "stand_sleep_", -1, &velocity_none, PS_STAND, fxs, false); + anim().AddAnim(eAnimWalkFwd, "stand_walk_fwd_", -1, &velocity_walk, PS_STAND, fxs); + anim().AddAnim(eAnimWalkDamaged, "stand_walk_fwd_dmg_", -1, &velocity_walk_dmg, PS_STAND, fxs); + anim().AddAnim(eAnimRun, "stand_run_", -1, &velocity_run, PS_STAND, fxs); + anim().AddAnim(eAnimRunDamaged, "stand_run_dmg_", -1, &velocity_run_dmg, PS_STAND, fxs); + + anim().AddAnim(eAnimRunTurnLeft, "stand_run_turn_left_", -1, &velocity_run, PS_STAND, fxs); + anim().AddAnim(eAnimRunTurnRight, "stand_run_turn_right_", -1, &velocity_run, PS_STAND, fxs); + anim().AddAnim(eAnimScared, "stand_scared_", -1, &velocity_none, PS_STAND, fxs); + + anim().AddAnim(eAnimCheckCorpse, "stand_check_corpse_", -1, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimEat, "sit_eat_", -1, &velocity_none, PS_SIT, fxs); + + anim().AddAnim(eAnimDie, "stand_idle_", -1, &velocity_none, PS_STAND, fxs); + + anim().AddAnim(eAnimAttack, "stand_attack_", -1, &velocity_turn, PS_STAND, fxs); + anim().AddAnim(eAnimAttackRun, "stand_attack_run_", -1, &velocity_run, PS_STAND, fxs); + + anim().AddAnim(eAnimLookAround, "stand_look_around_", -1, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimSitIdle, "sit_idle_", -1, &velocity_none, PS_SIT, fxs); + anim().AddAnim(eAnimSitStandUp, "sit_stand_up_", -1, &velocity_none, PS_SIT, fxs); + anim().AddAnim(eAnimSitToSleep, "sit_sleep_down_", -1, &velocity_none, PS_SIT, fxs); + anim().AddAnim(eAnimStandSitDown, "stand_sit_down_", -1, &velocity_none, PS_STAND, fxs); + + anim().AddAnim(eAnimSteal, "stand_steal_", -1, &velocity_steal, PS_STAND, fxs); + + anim().AddAnim(eAnimThreaten, "stand_threaten_", -1, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimMiscAction_00, "stand_to_aggressive_", -1, &velocity_none, PS_STAND, fxs); } // define transitions @@ -701,7 +677,7 @@ void CAI_Bloodsucker::predator_start() return; cNameVisual_set(m_visual_predator); - CDamageManager::reload(*cNameSect(), "damage", pSettings); + CDamageManager::reload(cNameSect().c_str(), "damage", pSettings); control().animation().restart(); @@ -729,10 +705,10 @@ void CAI_Bloodsucker::predator_stop() return; } - cNameVisual_set(*m_visual_default); + cNameVisual_set(m_visual_default.c_str()); character_physics_support()->in_ChangeVisual(); - CDamageManager::reload(*cNameSect(), "damage", pSettings); + CDamageManager::reload(cNameSect().c_str(), "damage", pSettings); control().animation().restart(); diff --git a/src/xrGame/ai/monsters/bloodsucker/bloodsucker.h b/src/xrGame/ai/monsters/bloodsucker/bloodsucker.h index 4670473c16b..58f3ff8241b 100644 --- a/src/xrGame/ai/monsters/bloodsucker/bloodsucker.h +++ b/src/xrGame/ai/monsters/bloodsucker/bloodsucker.h @@ -226,4 +226,7 @@ class CAI_Bloodsucker : public CBaseMonster, public CControlledActor int m_sufficient_hits_before_vampire_random; virtual void on_attack_on_run_hit(); bool done_enough_hits_before_vampire(); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; diff --git a/src/xrGame/ai/monsters/bloodsucker/bloodsucker_script.cpp b/src/xrGame/ai/monsters/bloodsucker/bloodsucker_script.cpp index cb9c8b8548f..6c55cc1c28a 100644 --- a/src/xrGame/ai/monsters/bloodsucker/bloodsucker_script.cpp +++ b/src/xrGame/ai/monsters/bloodsucker/bloodsucker_script.cpp @@ -1,8 +1,8 @@ #include "pch_script.h" + #include "bloodsucker.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CAI_Bloodsucker, (CGameObject), +void CAI_Bloodsucker::script_register(lua_State* luaState) { using namespace luabind; @@ -12,4 +12,4 @@ SCRIPT_EXPORT(CAI_Bloodsucker, (CGameObject), .def(constructor<>()) .def("force_visibility_state", &CAI_Bloodsucker::force_visibility_state) ]; -}); +} diff --git a/src/xrGame/ai/monsters/boar/boar.cpp b/src/xrGame/ai/monsters/boar/boar.cpp index ea1adbb6513..c766c971177 100644 --- a/src/xrGame/ai/monsters/boar/boar.cpp +++ b/src/xrGame/ai/monsters/boar/boar.cpp @@ -7,14 +7,6 @@ #include "ai/monsters/control_animation_base.h" #include "ai/monsters/control_movement_base.h" -#define FX_STAND_FRONT { "fx_stand_f", true } -#define FX_STAND_BACK { "fx_stand_b", true } -#define FX_STAND_LEFT { "fx_stand_l", true } -#define FX_STAND_RIGHT { "fx_stand_r", true } - -#define FX_STAND_ALL FX_STAND_FRONT, FX_STAND_BACK, FX_STAND_LEFT, FX_STAND_RIGHT - - CAI_Boar::CAI_Boar() { StateMan = xr_new(this); @@ -51,35 +43,37 @@ void CAI_Boar::Load(LPCSTR section) SVelocityParam& velocity_steal = move().get_velocity(MonsterMovement::eVelocityParameterSteal); SVelocityParam& velocity_drag = move().get_velocity(MonsterMovement::eVelocityParameterDrag); - anim().AddAnim(eAnimStandIdle, "stand_idle_", -1, &velocity_none, PS_STAND, FX_STAND_ALL); - anim().AddAnim(eAnimStandTurnLeft, "stand_turn_ls_", -1, &velocity_turn, PS_STAND, FX_STAND_ALL); - anim().AddAnim(eAnimStandTurnRight, "stand_turn_rs_", -1, &velocity_turn, PS_STAND, FX_STAND_ALL); - - anim().AddAnim(eAnimLieIdle, "lie_sleep_", -1, &velocity_none, PS_LIE, FX_STAND_ALL); - anim().AddAnim(eAnimSleep, "lie_sleep_", -1, &velocity_none, PS_LIE, FX_STAND_ALL); - - anim().AddAnim(eAnimWalkFwd, "stand_walk_fwd_", -1, &velocity_walk, PS_STAND, FX_STAND_ALL); - anim().AddAnim(eAnimWalkDamaged, "stand_walk_fwd_dmg_", -1, &velocity_walk_dmg, PS_STAND, FX_STAND_ALL); - anim().AddAnim(eAnimRun, "stand_run_fwd_", -1, &velocity_run, PS_STAND, FX_STAND_ALL); - anim().AddAnim(eAnimRunDamaged, "stand_run_dmg_", -1, &velocity_run_dmg, PS_STAND, FX_STAND_ALL); - anim().AddAnim(eAnimCheckCorpse, "stand_check_corpse_", -1, &velocity_none, PS_STAND, FX_STAND_ALL); - anim().AddAnim(eAnimEat, "stand_eat_", -1, &velocity_none, PS_STAND, FX_STAND_ALL); - - anim().AddAnim(eAnimAttack, "stand_attack_", -1, &velocity_turn, PS_STAND, FX_STAND_ALL); - - anim().AddAnim(eAnimStandLieDown, "stand_lie_down_", -1, &velocity_none, PS_STAND, FX_STAND_ALL); - anim().AddAnim(eAnimLieStandUp, "lie_stand_up_", -1, &velocity_none, PS_LIE, FX_STAND_ALL); - anim().AddAnim(eAnimLieToSleep, "lie_to_sleep_", -1, &velocity_none, PS_LIE, FX_STAND_ALL); - anim().AddAnim(eAnimDragCorpse, "stand_drag_", -1, &velocity_drag, PS_STAND, FX_STAND_ALL); - anim().AddAnim(eAnimLookAround, "stand_idle_", 2, &velocity_none, PS_STAND, FX_STAND_ALL); - anim().AddAnim(eAnimSteal, "stand_steal_", -1, &velocity_steal, PS_STAND, FX_STAND_ALL); - anim().AddAnim(eAnimDie, "stand_idle_", -1, &velocity_none, PS_STAND, FX_STAND_ALL); - anim().AddAnim(eAnimJumpLeft, "stand_jump_left_", -1, &velocity_turn, PS_STAND, FX_STAND_ALL); - anim().AddAnim(eAnimJumpRight, "stand_jump_right_", -1, &velocity_turn, PS_STAND, FX_STAND_ALL); - - anim().AddAnim(eAnimRunTurnLeft, "stand_run_look_left_", -1, &velocity_run, PS_STAND, FX_STAND_ALL); - anim().AddAnim(eAnimRunTurnRight, "stand_run_look_right_", -1, &velocity_run, PS_STAND, FX_STAND_ALL); - anim().AddAnim(eAnimAttackRun, { "stand_run_attack_", true }, -1, &velocity_run, PS_STAND, FX_STAND_ALL); + const SAnimItem::Effects fxs{ "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r" }; + + anim().AddAnim(eAnimStandIdle, "stand_idle_", -1, &velocity_none, PS_STAND); + anim().AddAnim(eAnimStandTurnLeft, "stand_turn_ls_", -1, &velocity_turn, PS_STAND, fxs); + anim().AddAnim(eAnimStandTurnRight, "stand_turn_rs_", -1, &velocity_turn, PS_STAND, fxs); + + anim().AddAnim(eAnimLieIdle, "lie_sleep_", -1, &velocity_none, PS_LIE, fxs); + anim().AddAnim(eAnimSleep, "lie_sleep_", -1, &velocity_none, PS_LIE, fxs); + + anim().AddAnim(eAnimWalkFwd, "stand_walk_fwd_", -1, &velocity_walk, PS_STAND, fxs); + anim().AddAnim(eAnimWalkDamaged, "stand_walk_fwd_dmg_", -1, &velocity_walk_dmg, PS_STAND, fxs); + anim().AddAnim(eAnimRun, "stand_run_fwd_", -1, &velocity_run, PS_STAND, fxs); + anim().AddAnim(eAnimRunDamaged, "stand_run_dmg_", -1, &velocity_run_dmg, PS_STAND, fxs); + anim().AddAnim(eAnimCheckCorpse, "stand_check_corpse_", -1, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimEat, "stand_eat_", -1, &velocity_none, PS_STAND, fxs); + + anim().AddAnim(eAnimAttack, "stand_attack_", -1, &velocity_turn, PS_STAND, fxs); + + anim().AddAnim(eAnimStandLieDown, "stand_lie_down_", -1, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimLieStandUp, "lie_stand_up_", -1, &velocity_none, PS_LIE, fxs); + anim().AddAnim(eAnimLieToSleep, "lie_to_sleep_", -1, &velocity_none, PS_LIE, fxs); + anim().AddAnim(eAnimDragCorpse, "stand_drag_", -1, &velocity_drag, PS_STAND, fxs); + anim().AddAnim(eAnimLookAround, "stand_idle_", 2, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimSteal, "stand_steal_", -1, &velocity_steal, PS_STAND, fxs); + anim().AddAnim(eAnimDie, "stand_idle_", -1, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimJumpLeft, "stand_jump_left_", -1, &velocity_turn, PS_STAND, fxs); + anim().AddAnim(eAnimJumpRight, "stand_jump_right_", -1, &velocity_turn, PS_STAND, fxs); + + anim().AddAnim(eAnimRunTurnLeft, "stand_run_look_left_", -1, &velocity_run, PS_STAND, fxs); + anim().AddAnim(eAnimRunTurnRight, "stand_run_look_right_", -1, &velocity_run, PS_STAND, fxs); + //anim().AddAnim(eAnimAttackRun, "stand_run_attack_", -1, &velocity_run, PS_STAND, fxs, false); // define transitions anim().AddTransition(eAnimStandLieDown, eAnimSleep, eAnimLieToSleep, false); diff --git a/src/xrGame/ai/monsters/boar/boar.h b/src/xrGame/ai/monsters/boar/boar.h index 193103ad7cb..48474dbd2ad 100644 --- a/src/xrGame/ai/monsters/boar/boar.h +++ b/src/xrGame/ai/monsters/boar/boar.h @@ -30,4 +30,7 @@ class CAI_Boar : public CBaseMonster, public CControlledEntity virtual bool ability_can_drag() { return true; } pcstr get_monster_class_name() override { return "boar"; } + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; diff --git a/src/xrGame/ai/monsters/boar/boar_script.cpp b/src/xrGame/ai/monsters/boar/boar_script.cpp index 4092b7f8fd4..5bc53b32925 100644 --- a/src/xrGame/ai/monsters/boar/boar_script.cpp +++ b/src/xrGame/ai/monsters/boar/boar_script.cpp @@ -1,14 +1,14 @@ #include "pch_script.h" + #include "boar.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CAI_Boar, (CGameObject), +void CAI_Boar::script_register(lua_State* luaState) { using namespace luabind; module(luaState) [ class_("CAI_Boar") - .def(constructor<>()) + .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/ai/monsters/boar/boar_state_manager.cpp b/src/xrGame/ai/monsters/boar/boar_state_manager.cpp index 66ae15da85c..2a939ea1ae3 100644 --- a/src/xrGame/ai/monsters/boar/boar_state_manager.cpp +++ b/src/xrGame/ai/monsters/boar/boar_state_manager.cpp @@ -21,10 +21,7 @@ CStateManagerBoar::CStateManagerBoar(CAI_Boar* monster) : inherited(monster) { add_state(eStateRest, xr_new>(monster)); add_state(eStatePanic, xr_new>(monster)); - - CStateMonsterAttackMoveToHomePoint* move2home = xr_new>(monster); - - add_state(eStateAttack, xr_new>(monster, move2home)); + add_state(eStateAttack, xr_new>(monster)); add_state(eStateEat, xr_new>(monster)); add_state(eStateHearInterestingSound, xr_new>(monster)); add_state(eStateHearDangerousSound, xr_new>(monster)); diff --git a/src/xrGame/ai/monsters/burer/burer.cpp b/src/xrGame/ai/monsters/burer/burer.cpp index e11e746c7b8..a54215c2008 100644 --- a/src/xrGame/ai/monsters/burer/burer.cpp +++ b/src/xrGame/ai/monsters/burer/burer.cpp @@ -22,13 +22,6 @@ #include "xrCore/_vector3d_ext.h" #include "ai/monsters/control_direction_base.h" -#define FX_STAND_FRONT { "fx_stand_f", true } -#define FX_STAND_BACK { "fx_stand_b", true } -#define FX_STAND_LEFT { "fx_stand_l", true } -#define FX_STAND_RIGHT { "fx_stand_r", true } - -#define FX_STAND_ALL FX_STAND_FRONT, FX_STAND_BACK, FX_STAND_LEFT, FX_STAND_RIGHT - bool CBurer::can_scan = true; CBurer::CBurer() @@ -74,16 +67,9 @@ void CBurer::Load(LPCSTR section) { inherited::Load(section); - // anim().AddReplacedAnim (&m_bDamaged, eAnimStandIdle, eAnimStandDamaged); - // anim().AddReplacedAnim (&m_bDamaged, eAnimRun, eAnimRunDamaged); - // anim().AddReplacedAnim (&m_bDamaged, eAnimWalkFwd, eAnimWalkDamaged); - anim().accel_load(section); anim().accel_chain_add(eAnimWalkFwd, eAnimRun); - anim().AddReplacedAnim(&m_bRunTurnLeft, eAnimRun, eAnimRunTurnLeft); - anim().AddReplacedAnim(&m_bRunTurnRight, eAnimRun, eAnimRunTurnRight); - particle_gravi_wave = pSettings->r_string(section, "Particle_Gravi_Wave"); particle_gravi_prepare = pSettings->r_string(section, "Particle_Gravi_Prepare"); particle_tele_object = pSettings->r_string(section, "Particle_Tele_Object"); @@ -92,9 +78,6 @@ void CBurer::Load(LPCSTR section) sound_tele_hold.create(pSettings->r_string(section, "sound_tele_hold"), st_Effect, SOUND_TYPE_WORLD); sound_tele_throw.create(pSettings->r_string(section, "sound_tele_throw"), st_Effect, SOUND_TYPE_WORLD); - m_gravi.cooldown = pSettings->r_u32(section, "Gravi_Cooldown"); - m_gravi.min_dist = pSettings->r_float(section, "Gravi_MinDist"); - m_gravi.max_dist = pSettings->r_float(section, "Gravi_MaxDist"); m_gravi.speed = pSettings->r_float(section, "Gravi_Speed"); m_gravi.step = pSettings->r_float(section, "Gravi_Step"); m_gravi.time_to_hold = pSettings->r_u32(section, "Gravi_Time_To_Hold"); @@ -103,6 +86,12 @@ void CBurer::Load(LPCSTR section) m_gravi.impulse_to_enemy = pSettings->r_float(section, "Gravi_Impulse_To_Enemy"); m_gravi.hit_power = pSettings->r_float(section, "Gravi_Hit_Power"); + m_gravi.min_dist = pSettings->read_if_exists(section, "Gravi_MinDist", 1.0f); + m_gravi.max_dist = pSettings->read_if_exists(section, "Gravi_MaxDist", m_gravi.radius * 3.0f); + + const u32 default_cooldown = u32(std::round(m_gravi.impulse_to_enemy / m_gravi.hit_power * 5.0f)); + m_gravi.cooldown = pSettings->read_if_exists(section, "Gravi_Cooldown", default_cooldown); + m_weight_to_stamina_hit = READ_IF_EXISTS(pSettings, r_float, section, "weight_to_stamina_hit", 0.02f); m_weapon_drop_stamina_k = READ_IF_EXISTS(pSettings, r_float, section, "weapon_drop_stamina_k", 3.f); @@ -134,87 +123,107 @@ void CBurer::Load(LPCSTR section) SVelocityParam& velocity_none = move().get_velocity(MonsterMovement::eVelocityParameterIdle); SVelocityParam& velocity_turn = move().get_velocity(MonsterMovement::eVelocityParameterStand); SVelocityParam& velocity_walk = move().get_velocity(MonsterMovement::eVelocityParameterWalkNormal); - SVelocityParam& velocity_run = move().get_velocity(MonsterMovement::eVelocityParameterRunNormal); - // SVelocityParam &velocity_walk_dmg = move().get_velocity(MonsterMovement::eVelocityParameterWalkDamaged); - // SVelocityParam &velocity_run_dmg = move().get_velocity(MonsterMovement::eVelocityParameterRunDamaged); - // SVelocityParam &velocity_steal = move().get_velocity(MonsterMovement::eVelocityParameterSteal); - // SVelocityParam &velocity_drag = move().get_velocity(MonsterMovement::eVelocityParameterDrag); - - anim().AddAnim(eAnimStandIdle, "stand_idle_", -1, &velocity_none, - PS_STAND, FX_STAND_ALL); - anim().AddAnim(eAnimStandTurnLeft, "stand_turn_ls_", -1, &velocity_turn, - PS_STAND, FX_STAND_ALL); - anim().AddAnim(eAnimStandTurnRight, "stand_turn_rs_", -1, &velocity_turn, - PS_STAND, FX_STAND_ALL); - // anim().AddAnim(eAnimStandDamaged, "stand_idle_dmg_", -1, &velocity_none, PS_STAND); //, "fx_stand_f", - //"fx_stand_b", "fx_stand_l", "fx_stand_r"); - - anim().AddAnim(eAnimWalkFwd, "stand_walk_fwd_", -1, &velocity_walk, - PS_STAND, FX_STAND_ALL); - // anim().AddAnim(eAnimWalkDamaged, "stand_walk_fwd_dmg_", -1, &velocity_walk_dmg, PS_STAND); //, "fx_stand_f", - // "fx_stand_b", "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimRun, "stand_run_fwd_", -1, &velocity_run, - PS_STAND, FX_STAND_ALL); - // anim().AddAnim(eAnimRunDamaged, "stand_run_dmg_", -1, &velocity_run_dmg, PS_STAND); //, "fx_stand_f", - // "fx_stand_b", "fx_stand_l", "fx_stand_r"); - - anim().AddAnim(eAnimAttack, "stand_attack_", -1, &velocity_turn, - PS_STAND, FX_STAND_ALL); - - anim().AddAnim(eAnimDie, "stand_die_", -1, &velocity_none, - PS_STAND, FX_STAND_ALL); - - anim().AddAnim(eAnimShieldStart, "stand_shield_", -1, &velocity_turn, - PS_STAND, FX_STAND_ALL); - anim().AddAnim(eAnimShieldContinue, "stand_shield_idle_", -1, &velocity_turn, - PS_STAND, FX_STAND_ALL); - - anim().AddAnim(eAnimTeleFire, "stand_power_attack_", -1, &velocity_turn, - PS_STAND, FX_STAND_ALL); - anim().AddAnim(eAnimTelekinesis, "telekinesis_", -1, &velocity_turn, - PS_STAND, FX_STAND_ALL); - anim().AddAnim(eAnimGraviFire, "stand_power_attack_", -1, &velocity_turn, - PS_STAND, FX_STAND_ALL); - - anim().AddAnim(eAnimRunTurnLeft, "stand_run_fwd_turn_left_", -1, &velocity_run, PS_STAND); - anim().AddAnim(eAnimRunTurnRight, "stand_run_fwd_turn_right_", -1, &velocity_run, PS_STAND); - - // anim().AddAnim(eAnimScared, "stand_scared_", -1, &velocity_none, PS_STAND); //, "fx_stand_f", - // "fx_stand_b", - // "fx_stand_l", "fx_stand_r"); - // anim().AddAnim(eAnimSteal, "stand_steal_", -1, &velocity_steal, PS_STAND); //, "fx_stand_f", - // "fx_stand_b", - // "fx_stand_l", "fx_stand_r"); - // anim().AddAnim(eAnimEat, "sit_eat_", -1, &velocity_none, PS_SIT); //, "fx_stand_f", - // "fx_stand_b", - // "fx_stand_l", "fx_stand_r"); - // - // anim().AddAnim(eAnimSitIdle, "sit_idle_", -1, &velocity_none, PS_SIT); //, "fx_stand_f", - // "fx_stand_b", - // "fx_stand_l", "fx_stand_r"); - // anim().AddAnim(eAnimCheckCorpse, "sit_check_corpse_", -1, &velocity_none, PS_SIT); //, "fx_stand_f", - // "fx_stand_b", "fx_stand_l", "fx_stand_r"); - // anim().AddAnim(eAnimSitStandUp, "sit_stand_up_", -1, &velocity_none, PS_SIT); //, "fx_stand_f", - // "fx_stand_b", "fx_stand_l", "fx_stand_r"); - // anim().AddAnim(eAnimStandSitDown, "stand_sit_down_", -1, &velocity_none, PS_STAND); //, "fx_stand_f", - // "fx_stand_b", "fx_stand_l", "fx_stand_r"); - - // anim().AddTransition(PS_SIT, PS_STAND, eAnimSitStandUp, false); - // anim().AddTransition(PS_STAND, PS_SIT, eAnimStandSitDown, false); + SVelocityParam& velocity_run = move().get_velocity(MonsterMovement::eVelocityParameterRunNormal); + SVelocityParam& velocity_walk_dmg = move().get_velocity(MonsterMovement::eVelocityParameterWalkDamaged); + SVelocityParam& velocity_run_dmg = move().get_velocity(MonsterMovement::eVelocityParameterRunDamaged); + SVelocityParam& velocity_steal = move().get_velocity(MonsterMovement::eVelocityParameterSteal); + + const SAnimItem::Effects fxs{ "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r" }; + + // Stand idle + damaged + turn + look around + anim().AddAnim(eAnimStandIdle, "stand_idle_", -1, &velocity_none, PS_STAND); anim().LinkAction(ACT_STAND_IDLE, eAnimStandIdle); - // anim().LinkAction (ACT_SIT_IDLE, eAnimSitIdle); - // anim().LinkAction (ACT_LIE_IDLE, eAnimSitIdle); + + if (anim().AddAnim(eAnimStandDamaged, "stand_idle_dmg_", -1, &velocity_none, PS_STAND, fxs, false)) + anim().AddReplacedAnim(&m_bDamaged, eAnimStandIdle, eAnimStandDamaged); + + anim().AddAnim(eAnimStandTurnLeft, "stand_turn_ls_", -1, &velocity_turn, PS_STAND, fxs); + anim().AddAnim(eAnimStandTurnRight, "stand_turn_rs_", -1, &velocity_turn, PS_STAND, fxs); + + if (anim().AddAnim(eAnimLookAround, "stand_idle_look_around", -1, &velocity_none, PS_STAND, fxs, false)) + anim().LinkAction(ACT_LOOK_AROUND, eAnimLookAround); + + // Stand walk + damaged + anim().AddAnim(eAnimWalkFwd, "stand_walk_fwd_", -1, &velocity_walk, PS_STAND, fxs); anim().LinkAction(ACT_WALK_FWD, eAnimWalkFwd); anim().LinkAction(ACT_WALK_BKWD, eAnimWalkFwd); - anim().LinkAction(ACT_RUN, eAnimRun); - // anim().LinkAction(ACT_EAT, eAnimEat); - anim().LinkAction(ACT_SLEEP, eAnimStandIdle); // eAnimSitIdle); - anim().LinkAction(ACT_REST, eAnimStandIdle); // eAnimSitIdle); anim().LinkAction(ACT_DRAG, eAnimWalkFwd); + + if (anim().AddAnim(eAnimWalkDamaged, "stand_walk_fwd_dmg_", -1, &velocity_walk_dmg, PS_STAND, fxs, false)) + anim().AddReplacedAnim(&m_bDamaged, eAnimWalkFwd, eAnimWalkDamaged); + + // Stand run + damaged + rurn + anim().AddAnim(eAnimRun, "stand_run_fwd_", -1, &velocity_run, PS_STAND, fxs); + anim().LinkAction(ACT_RUN, eAnimRun); + + if (anim().AddAnim(eAnimRunDamaged, "stand_run_dmg_", -1, &velocity_run_dmg, PS_STAND, fxs, false)) + anim().AddReplacedAnim(&m_bDamaged, eAnimRun, eAnimRunDamaged); + + if (anim().AddAnim(eAnimRunTurnLeft, "stand_run_fwd_turn_left_", -1, &velocity_run, PS_STAND, false)) + anim().AddReplacedAnim(&m_bRunTurnLeft, eAnimRun, eAnimRunTurnLeft); + if (anim().AddAnim(eAnimRunTurnRight, "stand_run_fwd_turn_right_", -1, &velocity_run, PS_STAND, false)) + anim().AddReplacedAnim(&m_bRunTurnRight, eAnimRun, eAnimRunTurnRight); + + // Stand steal + if (anim().AddAnim(eAnimSteal, "stand_steal_", -1, &velocity_steal, PS_STAND, fxs, false)) + anim().LinkAction(ACT_STEAL, eAnimSteal); + + // anim().AddAnim(eAnimScared, "stand_scared_", -1, &velocity_none, PS_STAND, fxs, false); + + // Attack + anim().AddAnim(eAnimAttack, "stand_attack_", -1, &velocity_turn, PS_STAND, fxs); anim().LinkAction(ACT_ATTACK, eAnimAttack); -// anim().LinkAction(ACT_STEAL, eAnimSteal); -// anim().LinkAction(ACT_LOOK_AROUND, eAnimScared); + + // Die + anim().AddAnim(eAnimDie, "stand_die_", -1, &velocity_none, PS_STAND, fxs); + + // Shield + if (!anim().AddAnim(eAnimShieldStart, "stand_shield_", -1, &velocity_turn, PS_STAND, fxs, false)) + anim().AddAnim(eAnimShieldStart, "stand_gravi_", 0, &velocity_turn, PS_STAND, fxs, false); + + if (!anim().AddAnim(eAnimShieldContinue, "stand_shield_idle_", -1, &velocity_turn, PS_STAND, fxs, false)) + anim().AddAnim(eAnimShieldContinue, "stand_gravi_", 1, &velocity_turn, PS_STAND, fxs, false); + + // Telekinesis + if (!anim().AddAnim(eAnimTelekinesis, "telekinesis_", -1, &velocity_turn, PS_STAND, fxs, false)) + anim().AddAnim(eAnimTelekinesis, "stand_tele_", -1, &velocity_turn, PS_STAND, fxs, false); + + if (!anim().AddAnim(eAnimTeleFire, "stand_power_attack_", -1, &velocity_turn, PS_STAND, fxs, false)) + anim().AddAnim(eAnimTeleFire, "stand_tele_", 2, &velocity_turn, PS_STAND, fxs, false); + + // Gravi attack + m_use_three_gravi_anims = false; + if (!anim().AddAnim(eAnimGraviFire, "stand_power_attack_", -1, &velocity_turn, PS_STAND, fxs, false)) + { + if (anim().AddAnim(eAnimGraviFire, "stand_gravi_", -1, &velocity_turn, PS_STAND, fxs, false)) + m_use_three_gravi_anims = true; + } + + // Sit + if (anim().AddAnim(eAnimSitStandUp, "sit_stand_up_", -1, &velocity_none, PS_SIT, fxs, false)) + anim().AddTransition(PS_SIT, PS_STAND, eAnimSitStandUp, false); + + if (anim().AddAnim(eAnimStandSitDown, "stand_sit_down_", -1, &velocity_none, PS_STAND, fxs, false)) + anim().AddTransition(PS_STAND, PS_SIT, eAnimStandSitDown, false); + + if (anim().AddAnim(eAnimSitIdle, "sit_idle_", -1, &velocity_none, PS_SIT, fxs, false)) + { + anim().LinkAction(ACT_SIT_IDLE, eAnimSitIdle); + anim().LinkAction(ACT_LIE_IDLE, eAnimSitIdle); + anim().LinkAction(ACT_SLEEP, eAnimSitIdle); + anim().LinkAction(ACT_REST, eAnimSitIdle); + } + else + { + anim().LinkAction(ACT_SLEEP, eAnimStandIdle); + anim().LinkAction(ACT_REST, eAnimStandIdle); + } + + if (anim().AddAnim(eAnimEat, "sit_eat_", -1, &velocity_none, PS_SIT, fxs, false)) + anim().LinkAction(ACT_EAT, eAnimEat); + + // anim().AddAnim(eAnimCheckCorpse, "sit_check_corpse_", -1, &velocity_none, PS_SIT, fxs, false); #ifdef DEBUG anim().accel_chain_test(); @@ -481,7 +490,7 @@ void CBurer::net_Relcase(IGameObject* O) { inherited::net_Relcase(O); - TTelekinesis::remove_links(O); + CTelekinesis::remove_links(O); if (m_gravi_object.enemy == O) m_gravi_object.deactivate(); @@ -522,18 +531,25 @@ void CBurer::face_enemy() set_action(ACT_STAND_IDLE); } -extern CActor* g_actor; - -bool actor_is_reloading_weapon() +bool CBurer::CanDeactivateShieldEarly() const { - if (!g_actor) - { + CEntityAlive const* enemy = EnemyMan.get_enemy(); + if (!enemy) + return true; + + auto* inv_owner = smart_cast(enemy); + if (!inv_owner) return false; - } - CWeapon* const active_weapon = smart_cast(Actor()->inventory().ActiveItem()); + CWeapon* const active_weapon = smart_cast(inv_owner->inventory().ActiveItem()); + + // When there's no weapon we should return false, otherwise + // it would be easy to exploit the shield: + // i.e. hide the weapon, see shield deactivated, take the weapon again. if (active_weapon && active_weapon->GetState() == CWeapon::eReload) { + // We want burers to be smart enough, so return true only + // if the enemy has a weapon right now and reloading it. return true; } diff --git a/src/xrGame/ai/monsters/burer/burer.h b/src/xrGame/ai/monsters/burer/burer.h index 71e1e51e9f7..fe3b4908c83 100644 --- a/src/xrGame/ai/monsters/burer/burer.h +++ b/src/xrGame/ai/monsters/burer/burer.h @@ -20,8 +20,6 @@ class CBurer : public CBaseMonster, public CTelekinesis u32 last_hit_frame; u32 time_last_scan; - typedef CTelekinesis TTelekinesis; - struct GraviObject { bool active; @@ -120,6 +118,7 @@ class CBurer : public CBaseMonster, public CTelekinesis LPCSTR particle_fire_shield; CBurerFastGravi* m_fast_gravi; + bool m_use_three_gravi_anims{}; public: CBurer(); @@ -151,6 +150,9 @@ class CBurer : public CBaseMonster, public CTelekinesis void ActivateShield(); void DeactivateShield(); + [[nodiscard]] + bool CanDeactivateShieldEarly() const; + bool need_shotmark() const { return !m_shield_active; } virtual bool ability_distant_feel() { return true; } pcstr get_monster_class_name() override { return "burer"; } @@ -167,6 +169,7 @@ class CBurer : public CBaseMonster, public CTelekinesis public: void face_enemy(); -}; -bool actor_is_reloading_weapon(); +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); +}; diff --git a/src/xrGame/ai/monsters/burer/burer_script.cpp b/src/xrGame/ai/monsters/burer/burer_script.cpp index 7201dc34370..653e5c1ca31 100644 --- a/src/xrGame/ai/monsters/burer/burer_script.cpp +++ b/src/xrGame/ai/monsters/burer/burer_script.cpp @@ -1,8 +1,8 @@ #include "pch_script.h" + #include "burer.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CBurer, (CGameObject), +void CBurer::script_register(lua_State* luaState) { using namespace luabind; @@ -11,4 +11,4 @@ SCRIPT_EXPORT(CBurer, (CGameObject), class_("CBurer") .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/ai/monsters/burer/burer_state_attack_gravi.h b/src/xrGame/ai/monsters/burer/burer_state_attack_gravi.h index d0bc8ddf992..08d82a33dd9 100644 --- a/src/xrGame/ai/monsters/burer/burer_state_attack_gravi.h +++ b/src/xrGame/ai/monsters/burer/burer_state_attack_gravi.h @@ -17,12 +17,6 @@ class CStateBurerAttackGravi : public CState<_Object> virtual bool check_start_conditions(); virtual bool check_completion(); -private: - // выполнÑть ÑоÑтоÑние - void ExecuteGraviStart(); - void ExecuteGraviContinue(); - void ExecuteGraviFire(); - private: enum { diff --git a/src/xrGame/ai/monsters/burer/burer_state_attack_gravi_inline.h b/src/xrGame/ai/monsters/burer/burer_state_attack_gravi_inline.h index 5f7e6e3691b..ffcb3361663 100644 --- a/src/xrGame/ai/monsters/burer/burer_state_attack_gravi_inline.h +++ b/src/xrGame/ai/monsters/burer/burer_state_attack_gravi_inline.h @@ -23,34 +23,88 @@ void CStateBurerAttackGravi::initialize() template void CStateBurerAttackGravi::execute() { + this->object->face_enemy(); + + const bool triple = this->object->m_use_three_gravi_anims; + switch (m_action) { - case ACTION_GRAVI_STARTED: ExecuteGraviStart(); break; + case ACTION_GRAVI_STARTED: + { + this->object->anim().set_override_animation(eAnimGraviFire, 0); - case ACTION_GRAVI_CONTINUE: ExecuteGraviContinue(); break; + if (!m_time_gravi_started) + { + float const time = this->object->anim().get_animation_length(eAnimGraviFire, 0); + m_anim_end_tick = xr_current_time() + TTime(time * 1000); + m_time_gravi_started = Device.dwTimeGlobal; + this->object->StartGraviPrepare(); + } + if (triple && xr_current_time() <= m_anim_end_tick) + break; - case ACTION_GRAVI_FIRE: - ExecuteGraviFire(); - m_action = ACTION_WAIT_ANIM_END; + m_action = ACTION_GRAVI_CONTINUE; break; + } + case ACTION_GRAVI_CONTINUE: + { + const u32 anim_idx = triple ? 1 : 0; + this->object->anim().set_override_animation(eAnimGraviFire, anim_idx); - case ACTION_WAIT_ANIM_END: - if (xr_current_time() > m_anim_end_tick) + // проверить на грави удар + const float dist = this->object->Position().distance_to(this->object->EnemyMan.get_enemy()->Position()); + + float time_to_hold = (abs(dist - this->object->m_gravi.min_dist) / this->object->m_gravi.min_dist); + clamp(time_to_hold, 0.f, 1.f); + time_to_hold *= float(this->object->m_gravi.time_to_hold); + + if (m_time_gravi_started + u32(time_to_hold) >= Device.dwTimeGlobal) + break; + + m_action = ACTION_GRAVI_FIRE; + + if (triple) { - m_action = ACTION_COMPLETED; + this->object->anim().clear_override_animation(); + this->object->anim().set_override_animation(eAnimGraviFire, 2); + float const time = this->object->anim().get_animation_length(eAnimGraviFire, 2); + m_anim_end_tick = xr_current_time() + TTime(time * 1000); } - - case ACTION_COMPLETED: break; + break; } + case ACTION_GRAVI_FIRE: + { + const u32 anim_idx = triple ? 2 : 0; + this->object->anim().set_override_animation(eAnimGraviFire, anim_idx); - this->object->face_enemy(); + Fvector from_pos = this->object->Position(); + from_pos.y += 0.5f; - if (xr_current_time() < m_anim_end_tick) + Fvector target_pos = this->object->EnemyMan.get_enemy()->Position(); + target_pos.y += 0.5f; + + this->object->m_gravi_object.activate(this->object->EnemyMan.get_enemy(), from_pos, target_pos); + + this->object->StopGraviPrepare(); + this->object->sound().play(CBurer::eMonsterSoundGraviAttack); + + // Interactive Grass FX + g_pGamePersistent->GrassBendersAddExplosion(this->object->ID(), from_pos, this->object->Direction(), + 1.33f, 3.0f, ps_ssfx_grass_interactive.w, 13.0f); + + m_action = ACTION_WAIT_ANIM_END; + break; + } + case ACTION_WAIT_ANIM_END: { - this->object->anim().set_override_animation(eAnimGraviFire); + if (xr_current_time() > m_anim_end_tick) + { + m_action = ACTION_COMPLETED; + } } - - this->object->set_action(ACT_STAND_IDLE); + case ACTION_COMPLETED: + break; + } // switch (m_action) } template @@ -95,49 +149,3 @@ bool CStateBurerAttackGravi::check_completion() { return m_action == ACTION_COMPLETED; } - -////////////////////////////////////////////////////////////////////////// - -template -void CStateBurerAttackGravi::ExecuteGraviStart() -{ - float const time = this->object->anim().get_animation_length(eAnimGraviFire, 0); - m_anim_end_tick = xr_current_time() + TTime(time * 1000); - m_action = ACTION_GRAVI_CONTINUE; - m_time_gravi_started = Device.dwTimeGlobal; - this->object->StartGraviPrepare(); -} - -template -void CStateBurerAttackGravi::ExecuteGraviContinue() -{ - // проверить на грави удар - const float dist = this->object->Position().distance_to(this->object->EnemyMan.get_enemy()->Position()); - - float time_to_hold = (abs(dist - this->object->m_gravi.min_dist) / this->object->m_gravi.min_dist); - clamp(time_to_hold, 0.f, 1.f); - time_to_hold *= float(this->object->m_gravi.time_to_hold); - - if (m_time_gravi_started + u32(time_to_hold) < Device.dwTimeGlobal) - { - m_action = ACTION_GRAVI_FIRE; - } -} - -extern ENGINE_API Fvector4 ps_ssfx_grass_interactive; -template -void CStateBurerAttackGravi::ExecuteGraviFire() -{ - Fvector from_pos = this->object->Position(); - from_pos.y += 0.5f; - - Fvector target_pos = this->object->EnemyMan.get_enemy()->Position(); - target_pos.y += 0.5f; - - this->object->m_gravi_object.activate(this->object->EnemyMan.get_enemy(), from_pos, target_pos); - - this->object->StopGraviPrepare(); - this->object->sound().play(CBurer::eMonsterSoundGraviAttack); - // Interactive Grass FX - g_pGamePersistent->GrassBendersAddExplosion(this->object->ID(), from_pos, this->object->Direction(), 1.33f, 3.0f, ps_ssfx_grass_interactive.w, 13.0f); -} diff --git a/src/xrGame/ai/monsters/burer/burer_state_attack_inline.h b/src/xrGame/ai/monsters/burer/burer_state_attack_inline.h index e4e76a3cdab..2e110dce35d 100644 --- a/src/xrGame/ai/monsters/burer/burer_state_attack_inline.h +++ b/src/xrGame/ai/monsters/burer/burer_state_attack_inline.h @@ -82,6 +82,9 @@ void CStateBurerAttack::execute() if (this->get_state_current()->check_completion()) { m_wait_state_end = false; + // Set a dummy state to workaround getting stuck in a state + // if the cooldown is set to small enough value. + this->select_state(eStateBurerAttack_FaceEnemy); } else { diff --git a/src/xrGame/ai/monsters/burer/burer_state_attack_shield_inline.h b/src/xrGame/ai/monsters/burer/burer_state_attack_shield_inline.h index 874f3cd5e06..7c67aad4dc3 100644 --- a/src/xrGame/ai/monsters/burer/burer_state_attack_shield_inline.h +++ b/src/xrGame/ai/monsters/burer/burer_state_attack_shield_inline.h @@ -78,18 +78,5 @@ bool CStateBurerShield::check_completion() if (xr_current_time() > m_last_shield_started + this->object->m_shield_time) return true; - CEntityAlive const* enemy = this->object->EnemyMan.get_enemy(); - if (!enemy) - return true; - - if (enemy == Actor()) - { - if (actor_is_reloading_weapon()) - return true; - } - - if (!this->object->EnemyMan.get_enemy()) - return true; - - return false; + return this->object->CanDeactivateShieldEarly(); } diff --git a/src/xrGame/ai/monsters/cat/cat.h b/src/xrGame/ai/monsters/cat/cat.h index 81bc9229507..5e7b21675c6 100644 --- a/src/xrGame/ai/monsters/cat/cat.h +++ b/src/xrGame/ai/monsters/cat/cat.h @@ -21,4 +21,7 @@ class CCat : public CBaseMonster virtual void HitEntityInJump(const CEntity* pEntity); pcstr get_monster_class_name() override { return "cat"; } + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; diff --git a/src/xrGame/ai/monsters/cat/cat_script.cpp b/src/xrGame/ai/monsters/cat/cat_script.cpp index fe6520a872f..e2fbaf105ce 100644 --- a/src/xrGame/ai/monsters/cat/cat_script.cpp +++ b/src/xrGame/ai/monsters/cat/cat_script.cpp @@ -1,8 +1,8 @@ #include "pch_script.h" + #include "cat.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CCat, (CGameObject), +void CCat::script_register(lua_State* luaState) { using namespace luabind; @@ -11,4 +11,4 @@ SCRIPT_EXPORT(CCat, (CGameObject), class_("CCat") .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/ai/monsters/chimera/chimera.cpp b/src/xrGame/ai/monsters/chimera/chimera.cpp index 6b4fc03db70..f9b268f7a2c 100644 --- a/src/xrGame/ai/monsters/chimera/chimera.cpp +++ b/src/xrGame/ai/monsters/chimera/chimera.cpp @@ -123,7 +123,7 @@ void CChimera::reinit() { inherited::reinit(); - move().load_velocity(*cNameSect(), "Velocity_JumpGround", MonsterMovement::eChimeraVelocityParameterJumpGround); + move().load_velocity(cNameSect().c_str(), "Velocity_JumpGround", MonsterMovement::eChimeraVelocityParameterJumpGround); com_man().load_jump_data(0, //"jump_attack_0", 0, //"jump_attack_0", diff --git a/src/xrGame/ai/monsters/chimera/chimera.h b/src/xrGame/ai/monsters/chimera/chimera.h index 85ff8c3fc63..31d25fb9e4a 100644 --- a/src/xrGame/ai/monsters/chimera/chimera.h +++ b/src/xrGame/ai/monsters/chimera/chimera.h @@ -39,4 +39,7 @@ class CChimera : public CBaseMonster public: attack_params const& get_attack_params() const { return m_attack_params; } + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; diff --git a/src/xrGame/ai/monsters/chimera/chimera_script.cpp b/src/xrGame/ai/monsters/chimera/chimera_script.cpp index 92755589c76..cd5ad1fd690 100644 --- a/src/xrGame/ai/monsters/chimera/chimera_script.cpp +++ b/src/xrGame/ai/monsters/chimera/chimera_script.cpp @@ -1,8 +1,8 @@ #include "pch_script.h" + #include "chimera.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CChimera, (CGameObject), +void CChimera::script_register(lua_State* luaState) { using namespace luabind; @@ -11,4 +11,4 @@ SCRIPT_EXPORT(CChimera, (CGameObject), class_("CChimera") .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/ai/monsters/control_animation.cpp b/src/xrGame/ai/monsters/control_animation.cpp index 3eacb6b325f..e6636d42bf1 100644 --- a/src/xrGame/ai/monsters/control_animation.cpp +++ b/src/xrGame/ai/monsters/control_animation.cpp @@ -122,13 +122,6 @@ void CControlAnimation::play_part(SAnimationPart& part, PlayCallback callback) part.blend = m_skeleton_animated->LL_PlayCycle(bone_or_part, part.get_motion(), TRUE, callback, this); - /////////////////////////////////////////////////////////////////////////////// - //#ifdef _DEBUG - // Msg("Monster[%s] Time[%u] Anim[%s]",*(m_object->cName()), - // Device.dwTimeGlobal,*(m_object->anim().GetAnimTranslation(part.motion))); - //#endif - /////////////////////////////////////////////////////////////////////////////// - // synchronize prev and current animations if ((pos > 0) && part.blend && !part.blend->stop_at_end) { diff --git a/src/xrGame/ai/monsters/control_animation_base.cpp b/src/xrGame/ai/monsters/control_animation_base.cpp index 1f9a98b9ca0..46c67db1214 100644 --- a/src/xrGame/ai/monsters/control_animation_base.cpp +++ b/src/xrGame/ai/monsters/control_animation_base.cpp @@ -17,7 +17,6 @@ constexpr pcstr dbg_action_name_table[] = {"ACT_STAND_IDLE", "ACT_SIT_IDLE", "AC "ACT_RUN", "ACT_EAT", "ACT_SLEEP", "ACT_REST", "ACT_DRAG", "ACT_ATTACK", "ACT_STEAL", "ACT_LOOK_AROUND", "ACT_JUMP"}; -void SCurrentAnimationInfo::set_motion(EMotionAnim new_motion) { motion = new_motion; } CControlAnimationBase::CControlAnimationBase() { m_override_animation = eAnimUndefined; @@ -38,10 +37,7 @@ void CControlAnimationBase::reinit() accel_init(); - aa_time_last_attack = 0; - // обновить количеÑтво анимаций - m_anim_motion_map.clear(); UpdateAnimCount(); // Ð¸Ð½Ð¸Ñ†Ð¸Ð°Ð»Ð¸Ð·Ð°Ñ†Ð¸Ñ Ð¸Ð½Ñ„Ð¾Ñ€Ð¼Ð°Ñ†Ð¸Ð¸ о текущей анимации @@ -63,7 +59,7 @@ void CControlAnimationBase::reinit() m_man->capture(this, ControlCom::eControlAnimation); m_man->subscribe(this, ControlCom::eventAnimationSignal); - AA_reload(pSettings->r_string(*(m_object->cNameSect()), "attack_params")); + AA_reload(pSettings->r_string(m_object->cNameSect().c_str(), "attack_params")); braking_mode = false; @@ -214,7 +210,7 @@ void CControlAnimationBase::select_animation(bool anim_end) // уÑтановить анимацию string128 s1, s2; MotionID cur_anim = smart_cast( - m_object->Visual())->ID_Cycle_Safe(strconcat(sizeof(s2), s2, *anim_it->target_name, xr_itoa(index, s1, 10))); + m_object->Visual())->ID_Cycle_Safe(strconcat(sizeof(s2), s2, anim_it->target_name.c_str(), xr_itoa(index, s1, 10))); if (!cur_anim.valid()) FATAL(s2); @@ -225,7 +221,7 @@ void CControlAnimationBase::select_animation(bool anim_end) // Заполнить текущую анимацию string64 st, tmp; - strconcat(sizeof(st), st, *anim_it->target_name, xr_itoa(index, tmp, 10)); + strconcat(sizeof(st), st, anim_it->target_name.c_str(), xr_itoa(index, tmp, 10)); // xr_sprintf (st, "%s%d", *anim_it->second.target_name, index); m_cur_anim.name = st; m_cur_anim.index = u8(index); @@ -347,26 +343,23 @@ void CControlAnimationBase::FX_Play(EHitSide side, float amount) if (fx_time_last_play + FX_CAN_PLAY_MIN_INTERVAL > m_object->m_dwCurrentTime) return; - SAnimItem* anim_it = m_anim_storage[cur_anim_info().get_motion()]; + const SAnimItem* anim_it = m_anim_storage[cur_anim_info().get_motion()]; VERIFY(anim_it); clamp(amount, 0.f, 1.f); - shared_str* p_str = 0; + pcstr fx{}; switch (side) { - case eSideFront: p_str = &anim_it->fxs.front; break; - case eSideBack: p_str = &anim_it->fxs.back; break; - case eSideLeft: p_str = &anim_it->fxs.left; break; - case eSideRight: p_str = &anim_it->fxs.right; break; + case eSideFront: fx = anim_it->fxs.front.c_str(); break; + case eSideBack: fx = anim_it->fxs.back.c_str(); break; + case eSideLeft: fx = anim_it->fxs.left.c_str(); break; + case eSideRight: fx = anim_it->fxs.right.c_str(); break; } - if (p_str && p_str->size()) + if (fx && fx[0]) { - if (anim_it->fxs.may_not_exist[side]) - smart_cast(m_object->Visual())->PlayFX_Safe(*(*p_str), amount); - else - smart_cast(m_object->Visual())->PlayFX(*(*p_str), amount); + smart_cast(m_object->Visual())->PlayFX(fx, amount); } fx_time_last_play = m_object->m_dwCurrentTime; @@ -452,16 +445,16 @@ EAction CControlAnimationBase::GetActionFromPath() ////////////////////////////////////////////////////////////////////////// // Debug -LPCSTR CControlAnimationBase::GetAnimationName(EMotionAnim anim) +pcstr CControlAnimationBase::GetAnimationName(EMotionAnim anim) const { SAnimItem* item_it = m_anim_storage[anim]; VERIFY2(item_it, make_string("animation not found in m_anim_storage!")); ; - return *item_it->target_name; + return item_it->target_name.c_str(); } -LPCSTR CControlAnimationBase::GetActionName(EAction action) { return dbg_action_name_table[action]; } +pcstr CControlAnimationBase::GetActionName(EAction action) { return dbg_action_name_table[action]; } /////////////////////////////////////////////////////////////////////////////////////// void CControlAnimationBase::ValidateAnimation() @@ -502,7 +495,7 @@ void CControlAnimationBase::ValidateAnimation() void CControlAnimationBase::UpdateAnimCount() { IKinematicsAnimated* skel = smart_cast(m_object->Visual()); - xr_vector subjectsToDelete; + xr_vector subjectsToDelete; for (auto it = m_anim_storage.begin(); it != m_anim_storage.end(); ++it) { @@ -518,50 +511,30 @@ void CControlAnimationBase::UpdateAnimCount() for (int i = 0;; ++i) { - strconcat(sizeof(s_temp), s_temp, *((*it)->target_name), xr_itoa(i, s, 10)); + strconcat(sizeof(s_temp), s_temp, (*it)->target_name.c_str(), xr_itoa(i, s, 10)); LPCSTR name = s_temp; MotionID id = skel->ID_Cycle_Safe(name); if (id.valid()) { count++; - AddAnimTranslation(id, name); } else break; } - if (count == 0 && (*it)->target_name2.size()) - { - for (int i = 0;; ++i) - { - strconcat(sizeof(s_temp), s_temp, *((*it)->target_name2), xr_itoa(i, s, 10)); - LPCSTR name = s_temp; - MotionID id = skel->ID_Cycle_Safe(name); - - if (id.valid()) - { - count++; - AddAnimTranslation(id, name); - } - else - break; - } - } - if (count != 0) (*it)->count = count; - else if ((*it)->target_may_not_exist) - subjectsToDelete.push_back(std::distance(m_anim_storage.begin(), it)); else { - xr_sprintf(s, "Error! No animation: %s for monster %s", *((*it)->target_name), *m_object->cName()); - R_ASSERT2(count != 0, s); - subjectsToDelete.push_back(std::distance(m_anim_storage.begin(), it)); + xr_sprintf(s, "Error! No animation: %s for monster %s", (*it)->target_name.c_str(), m_object->cName().c_str()); + Msg("! %s", s); + VERIFY2(count != 0, s); + subjectsToDelete.emplace_back(std::distance(m_anim_storage.begin(), it)); } } - for (u32 idx : subjectsToDelete) + for (size_t idx : subjectsToDelete) { xr_delete(m_anim_storage[idx]); while (true) @@ -584,31 +557,17 @@ void CControlAnimationBase::UpdateAnimCount() } void CControlAnimationBase::SetCurAnim(EMotionAnim a) { cur_anim_info().set_motion(a); } -CMotionDef* CControlAnimationBase::get_motion_def(SAnimItem* it, u32 index) + +CMotionDef* CControlAnimationBase::get_motion_def(SAnimItem* it, u32 index) const { string128 s1, s2; IKinematicsAnimated* skeleton_animated = smart_cast(m_object->Visual()); const MotionID& motion_id = - skeleton_animated->ID_Cycle_Safe(strconcat(sizeof(s2), s2, *it->target_name, xr_itoa(index, s1, 10))); + skeleton_animated->ID_Cycle_Safe(strconcat(sizeof(s2), s2, it->target_name.c_str(), xr_itoa(index, s1, 10))); return (skeleton_animated->LL_GetMotionDef(motion_id)); } -void CControlAnimationBase::AddAnimTranslation(const MotionID& motion, LPCSTR str) -{ - m_anim_motion_map.insert(std::make_pair(motion, str)); -} -shared_str CControlAnimationBase::GetAnimTranslation(const MotionID& motion) -{ - shared_str ret_value; - - auto anim_it = m_anim_motion_map.find(motion); - if (anim_it != m_anim_motion_map.end()) - ret_value = anim_it->second; - - return ret_value; -} - -MotionID CControlAnimationBase::get_motion_id(EMotionAnim a, u32 index) +MotionID CControlAnimationBase::get_motion_id(EMotionAnim a, u32 index) const { // получить Ñлемент SAnimItem, ÑоответÑтвующий текущей анимации SAnimItem* anim_it = m_anim_storage[a]; @@ -628,7 +587,7 @@ MotionID CControlAnimationBase::get_motion_id(EMotionAnim a, u32 index) string128 s1, s2; return (smart_cast(m_object->Visual()) - ->ID_Cycle_Safe(strconcat(sizeof(s2), s2, *anim_it->target_name, xr_itoa(index, s1, 10)))); + ->ID_Cycle_Safe(strconcat(sizeof(s2), s2, anim_it->target_name.c_str(), xr_itoa(index, s1, 10)))); } void CControlAnimationBase::stop_now() diff --git a/src/xrGame/ai/monsters/control_animation_base.h b/src/xrGame/ai/monsters/control_animation_base.h index dfa6b7a6dfd..b2fc042acdb 100644 --- a/src/xrGame/ai/monsters/control_animation_base.h +++ b/src/xrGame/ai/monsters/control_animation_base.h @@ -7,7 +7,7 @@ struct SEventVelocityBounce : public ControlCom::IEventData { float m_ratio; - IC SEventVelocityBounce(float ratio) : m_ratio(ratio) {} + SEventVelocityBounce(const float ratio) : m_ratio(ratio) {} }; ////////////////////////////////////////////////////////////////////////// @@ -16,27 +16,15 @@ class CControlAnimationBase : public CControl_ComBase typedef CControl_ComBase inherited; protected: - REPLACED_ANIM m_tReplacedAnims; // анимации подмены - - // Ñохранённые анимации - EMotionAnim prev_motion; - - // иÑÐ¿Ñ€Ð°Ð²Ð»ÐµÐ½Ð¸Ñ ÑоÑоÑÐ½Ð¸Ñ 'бега на меÑте' - TTime time_start_stand; - - // работа Ñ Ð°Ð½Ð¸Ð¼Ð°Ñ†Ð¸Ñми атаки - TTime aa_time_last_attack; // Ð²Ñ€ÐµÐ¼Ñ Ð¿Ð¾Ñледнего нанеÑÐµÐ½Ð¸Ñ Ñ…Ð¸Ñ‚Ð° - - // ------------------------------------------------------------------------- - u32 spec_params; // дополнительные параметры - - TTime fx_time_last_play; + // Ð¸Ð½Ñ„Ð¾Ñ€Ð¼Ð°Ñ†Ð¸Ñ Ð¾ текущей анимации + SCurrentAnimationInfo m_cur_anim; // ------------------------------------------------------------------------------------- // Acceleration - struct { + VELOCITY_CHAIN_VEC chain; + bool active; bool enable_braking; // не иÑпользовать при торможении @@ -44,38 +32,40 @@ class CControlAnimationBase : public CControl_ComBase float calm; float aggressive; - - VELOCITY_CHAIN_VEC chain; } m_accel; - // --------------------------------------------------------------------------------------- + xr_vector m_anim_storage; - EMotionAnim spec_anim; + // анимации подмены + xr_vector m_tReplacedAnims; - MOTION_ITEM_MAP m_tMotions; // карта ÑоответÑвий EAction к SMotionItem - TRANSITION_ANIM_VECTOR m_tTransitions; // вектор переходов из одной анимации в другую +public: + EAction m_tAction; - t_fx_index default_fx_indexes; - FX_MAP_STRING fx_map_string; - FX_MAP_U16 fx_map_u16; - bool map_converted; +protected: + EMotionAnim spec_anim; + EMotionAnim prev_motion; - AA_VECTOR m_attack_anims; + EMotionAnim m_override_animation; // used if != eAnimUndefined + u32 m_override_animation_index; // used if != -1 + + // ------------------------------------------------------------------------- + u32 spec_params; // дополнительные параметры + TTime fx_time_last_play; + float m_prev_character_velocity; bool m_state_attack; + bool braking_mode; + // --------------------------------------------------------------------------------------- -protected: - ANIM_TO_MOTION_MAP m_anim_motion_map; + xr_map m_tMotions; // карта ÑоответÑвий EAction к SMotionItem + xr_vector m_tTransitions; // вектор переходов из одной анимации в другую + xr_vector m_attack_anims; // работа Ñ Ð°Ð½Ð¸Ð¼Ð°Ñ†Ð¸Ñми атаки - ANIM_ITEM_VECTOR m_anim_storage; +protected: void init_anim_storage(); void free_anim_storage(); -public: - EAction m_tAction; - - float m_prev_character_velocity; - public: CControlAnimationBase(); virtual ~CControlAnimationBase(); @@ -90,26 +80,12 @@ class CControlAnimationBase : public CControl_ComBase void ScheduledInit(); // Ñоздание карты анимаций (выполнÑть на Monster::Load) - void AddAnim(EMotionAnim ma, LPCSTR tn, int s_id, SVelocityParam* vel, EPState p_s); - - void AddAnim2(EMotionAnim ma, std::pair target, int s_id, SVelocityParam* vel, EPState p_s); - - void AddAnim(EMotionAnim ma, std::pair target, int s_id, SVelocityParam* vel, EPState p_s); - - void AddAnim(EMotionAnim ma, LPCSTR tn, int s_id, SVelocityParam* vel, EPState p_s, LPCSTR fx_front, LPCSTR fx_back, - LPCSTR fx_left, LPCSTR fx_right); - - void AddAnim(EMotionAnim ma, std::pair target, int s_id, SVelocityParam* vel, EPState p_s, - LPCSTR fx_front, LPCSTR fx_back, - LPCSTR fx_left, LPCSTR fx_right); - - void AddAnim(EMotionAnim ma, std::pair target, int s_id, SVelocityParam* vel, EPState p_s, - std::pair fx_front, std::pair fx_back, - std::pair fx_left, std::pair fx_right); + ICF bool AddAnim(const EMotionAnim ma, cpcstr tn, const int s_id, SVelocityParam* vel, const EPState p_s, const bool required = true) + { + return AddAnim(ma, tn, s_id, vel, p_s, {}, required); + } - void AddAnim(EMotionAnim ma, LPCSTR tn, int s_id, SVelocityParam* vel, EPState p_s, - std::pair fx_front, std::pair fx_back, - std::pair fx_left, std::pair fx_right); + bool AddAnim(EMotionAnim ma, pcstr tn, int s_id, SVelocityParam* vel, EPState p_s, const SAnimItem::Effects& fxs, bool required = true); // ------------------------------------- @@ -134,7 +110,7 @@ class CControlAnimationBase : public CControl_ComBase void SetSpecParams(u32 param) { spec_params |= param; } void SetCurAnim(EMotionAnim a); - EMotionAnim GetCurAnim() { return cur_anim_info().get_motion(); } + EMotionAnim GetCurAnim() const { return cur_anim_info().get_motion(); } // работа Ñ Ð°Ð½Ð¸Ð¼Ð°Ñ†Ð¸Ñми атак void AA_reload(LPCSTR section); SAAParam& AA_GetParams(LPCSTR anim_name); @@ -143,7 +119,7 @@ class CControlAnimationBase : public CControl_ComBase // FX's void FX_Play(EHitSide side, float amount); - MotionID get_motion_id(EMotionAnim a, u32 index = u32(-1)); + MotionID get_motion_id(EMotionAnim a, u32 index = u32(-1)) const; protected: void UpdateAnimCount(); @@ -156,7 +132,7 @@ class CControlAnimationBase : public CControl_ComBase EPState GetState(EMotionAnim a); void CheckReplacedAnim(); - CMotionDef* get_motion_def(SAnimItem* it, u32 index); + CMotionDef* get_motion_def(SAnimItem* it, u32 index) const; public: float GetAnimSpeed(EMotionAnim anim); @@ -177,12 +153,15 @@ class CControlAnimationBase : public CControl_ComBase void stop_now(); +protected: ////////////////////////////////////////////////////////////////////////// // DEBUG -protected: - LPCSTR GetAnimationName(EMotionAnim anim); - LPCSTR GetActionName(EAction action); + [[nodiscard]] + pcstr GetAnimationName(EMotionAnim anim) const; + + [[nodiscard]] + static pcstr GetActionName(EAction action); // end DEBUG ////////////////////////////////////////////////////////////////////////// @@ -192,18 +171,21 @@ class CControlAnimationBase : public CControl_ComBase // Acceleration void accel_init(); - void accel_load(LPCSTR section); + void accel_load(pcstr section); void accel_activate(EAccelType type); - IC void accel_deactivate() + + void accel_deactivate() { m_accel.active = false; m_accel.enable_braking = false; } - IC void accel_set_braking(bool val = true) { m_accel.enable_braking = val; } - float accel_get(EAccelValue val = eAV_Accel); - IC bool accel_active(EAccelValue val = eAV_Accel) + void accel_set_braking(bool val = true) { m_accel.enable_braking = val; } + + [[nodiscard]] float accel_get(EAccelValue val = eAV_Accel) const; + + [[nodiscard]] bool accel_active(const EAccelValue val = eAV_Accel) const { return (val == eAV_Accel) ? m_accel.active : m_accel.enable_braking; } @@ -213,7 +195,6 @@ class CControlAnimationBase : public CControl_ComBase bool accel_chain_test(); bool accel_check_braking(float before_interval, float nominal_speed); - bool braking_mode; // -------------------------------------------------------------------------------- @@ -222,14 +203,13 @@ class CControlAnimationBase : public CControl_ComBase // Other void SetTurnAnimation(); - // MotionDef to animation name translation - void AddAnimTranslation(const MotionID& motion, LPCSTR str); - shared_str GetAnimTranslation(const MotionID& motion); - public: - // Ð¸Ð½Ñ„Ð¾Ñ€Ð¼Ð°Ñ†Ð¸Ñ Ð¾ текущей анимации - SCurrentAnimationInfo m_cur_anim; + [[nodiscard]] SCurrentAnimationInfo& cur_anim_info() { return m_cur_anim; } + + [[nodiscard]] + const SCurrentAnimationInfo& cur_anim_info() const { return m_cur_anim; } + void select_animation(bool anim_end = false); void set_animation_speed(); @@ -239,13 +219,11 @@ class CControlAnimationBase : public CControl_ComBase bool get_animation_info(EMotionAnim anim, u32 index, MotionID& motion, float& length) const; float get_animation_hit_time(EMotionAnim anim, u32 index) const; u32 get_animation_variants_count(EMotionAnim anim) const; + // you need to call it with default arguments to turn it off void set_override_animation(EMotionAnim anim = eAnimUndefined, u32 index = -1); void set_override_animation(pcstr name); void clear_override_animation(); EMotionAnim get_override_animation() const { return m_override_animation; } bool has_override_animation() const { return get_override_animation() != eAnimUndefined; } -private: - u32 m_override_animation_index; // used if != -1 - EMotionAnim m_override_animation; // used if != eAnimUndefined }; diff --git a/src/xrGame/ai/monsters/control_animation_base_accel.cpp b/src/xrGame/ai/monsters/control_animation_base_accel.cpp index 705cc0b52ca..6fa87036bc2 100644 --- a/src/xrGame/ai/monsters/control_animation_base_accel.cpp +++ b/src/xrGame/ai/monsters/control_animation_base_accel.cpp @@ -5,7 +5,7 @@ #include "monster_velocity_space.h" void CControlAnimationBase::accel_init() { m_accel.active = false; } -void CControlAnimationBase::accel_load(LPCSTR section) +void CControlAnimationBase::accel_load(pcstr section) { m_accel.calm = pSettings->r_float(section, "Accel_Calm"); m_accel.aggressive = pSettings->r_float(section, "Accel_Aggressive"); @@ -19,16 +19,16 @@ void CControlAnimationBase::accel_activate(EAccelType type) m_accel.enable_braking = true; } -float CControlAnimationBase::accel_get(EAccelValue val) +float CControlAnimationBase::accel_get(EAccelValue val) const { if (!accel_active(val)) return flt_max; switch (m_accel.type) { + default: case eAT_Calm: return m_accel.calm; case eAT_Aggressive: return m_accel.aggressive; - default: return m_accel.calm; } } @@ -37,10 +37,10 @@ float CControlAnimationBase::accel_get(EAccelValue val) void CControlAnimationBase::accel_chain_add(EMotionAnim anim1, EMotionAnim anim2) { SEQ_VECTOR v_temp; - v_temp.push_back(anim1); - v_temp.push_back(anim2); + v_temp.emplace_back(anim1); + v_temp.emplace_back(anim2); - m_accel.chain.push_back(v_temp); + m_accel.chain.emplace_back(v_temp); } bool CControlAnimationBase::accel_chain_get( @@ -123,7 +123,7 @@ bool CControlAnimationBase::accel_chain_test() const float to = anim_to->velocity.velocity.linear * anim_to->velocity.min_factor; xr_sprintf(error_msg, "Incompatible speed ranges. Monster[%s] From animation [%s] To animation [%s]", - *m_object->cName(), *anim_from->target_name, *anim_to->target_name); + m_object->cName().c_str(), anim_from->target_name.c_str(), anim_to->target_name.c_str()); VERIFY2(to < from, error_msg); #endif anim_from = anim_to; diff --git a/src/xrGame/ai/monsters/control_animation_base_load.cpp b/src/xrGame/ai/monsters/control_animation_base_load.cpp index f1f3e9c0968..3483a08dea3 100644 --- a/src/xrGame/ai/monsters/control_animation_base_load.cpp +++ b/src/xrGame/ai/monsters/control_animation_base_load.cpp @@ -1,148 +1,53 @@ #include "StdAfx.h" #include "control_animation_base.h" +#include "basemonster/base_monster.h" -void CControlAnimationBase::AddAnim(EMotionAnim ma, std::pair target, int s_id, SVelocityParam* vel, EPState p_s, std::pair fx_front, std::pair fx_back, std::pair fx_left, std::pair fx_right) +bool CControlAnimationBase::AddAnim(EMotionAnim ma, pcstr tn, int s_id, SVelocityParam* vel, EPState p_s, + const SAnimItem::Effects& fxs, bool required /*= true*/) { - SAnimItem* new_item = xr_new(); - - new_item->target_name = target.first; - new_item->target_may_not_exist = target.second; - new_item->spec_id = s_id; - new_item->velocity = *vel; - new_item->pos_state = p_s; - - new_item->fxs.front = fx_front.first; - new_item->fxs.back = fx_back.first; - new_item->fxs.left = fx_left.first; - new_item->fxs.right = fx_right.first; - - new_item->fxs.may_not_exist[0] = fx_front.second; - new_item->fxs.may_not_exist[1] = fx_back.second; - new_item->fxs.may_not_exist[2] = fx_left.second; - new_item->fxs.may_not_exist[3] = fx_right.second; - - new_item->count = 0; - - m_anim_storage[ma] = new_item; -} + const auto visual = smart_cast(m_object->Visual()); + VERIFY(visual); + + if (!required) + { + string128 buf; + strconcat(buf, tn, "0"); + if (!visual->ID_Cycle_Safe(buf).valid() && + !visual->ID_Cycle_Safe(tn).valid()) + { + return false; + } + } -void CControlAnimationBase::AddAnim(EMotionAnim ma, LPCSTR tn, int s_id, SVelocityParam* vel, EPState p_s, - std::pair fx_front, std::pair fx_back, - std::pair fx_left, std::pair fx_right) -{ SAnimItem* new_item = xr_new(); new_item->target_name = tn; - new_item->target_may_not_exist = false; new_item->spec_id = s_id; new_item->velocity = *vel; new_item->pos_state = p_s; - - new_item->fxs.front = fx_front.first; - new_item->fxs.back = fx_back.first; - new_item->fxs.left = fx_left.first; - new_item->fxs.right = fx_right.first; - - new_item->fxs.may_not_exist[0] = fx_front.second; - new_item->fxs.may_not_exist[1] = fx_back.second; - new_item->fxs.may_not_exist[2] = fx_left.second; - new_item->fxs.may_not_exist[3] = fx_right.second; - new_item->count = 0; - m_anim_storage[ma] = new_item; -} + const auto fx_exist = [&visual](const anim_string& anim_fx) + { + if (anim_fx.empty()) + return false; + return visual->ID_FX_Safe(anim_fx.c_str()).valid(); + }; -void CControlAnimationBase::AddAnim(EMotionAnim ma, LPCSTR tn, int s_id, SVelocityParam* vel, EPState p_s, - LPCSTR fx_front, LPCSTR fx_back, LPCSTR fx_left, LPCSTR fx_right) -{ - SAnimItem* new_item = xr_new(); - - new_item->target_name = tn; - new_item->target_may_not_exist = false; - new_item->spec_id = s_id; - new_item->velocity = *vel; - new_item->pos_state = p_s; - - new_item->fxs.front = fx_front; - new_item->fxs.back = fx_back; - new_item->fxs.left = fx_left; - new_item->fxs.right = fx_right; - - new_item->fxs.may_not_exist.reset(); - - new_item->count = 0; - - m_anim_storage[ma] = new_item; -} - -void CControlAnimationBase::AddAnim(EMotionAnim ma, std::pair target, int s_id, SVelocityParam* vel, EPState p_s, - LPCSTR fx_front, LPCSTR fx_back, LPCSTR fx_left, LPCSTR fx_right) -{ - SAnimItem* new_item = xr_new(); - - new_item->target_name = target.first; - new_item->target_may_not_exist = target.second; - new_item->spec_id = s_id; - new_item->velocity = *vel; - new_item->pos_state = p_s; + if (fx_exist(fxs.front)) + new_item->fxs.front = fxs.front; - new_item->fxs.front = fx_front; - new_item->fxs.back = fx_back; - new_item->fxs.left = fx_left; - new_item->fxs.right = fx_right; + if (fx_exist(fxs.back)) + new_item->fxs.back = fxs.back; - new_item->fxs.may_not_exist.reset(); + if (fx_exist(fxs.left)) + new_item->fxs.left = fxs.left; - new_item->count = 0; - - m_anim_storage[ma] = new_item; -} - -void CControlAnimationBase::AddAnim(EMotionAnim ma, std::pair target, int s_id, SVelocityParam* vel, EPState p_s) -{ - SAnimItem* new_item = xr_new(); - - new_item->target_name = target.first; - new_item->target_may_not_exist = target.second; - new_item->spec_id = s_id; - new_item->velocity = *vel; - new_item->pos_state = p_s; - - new_item->count = 0; - - m_anim_storage[ma] = new_item; -} - -void CControlAnimationBase::AddAnim2(EMotionAnim ma, std::pair target, int s_id, SVelocityParam* vel, EPState p_s) -{ - SAnimItem* new_item = xr_new(); - - new_item->target_name = target.first; - new_item->target_name2 = target.second; - new_item->target_may_not_exist = false; - new_item->spec_id = s_id; - new_item->velocity = *vel; - new_item->pos_state = p_s; - - new_item->count = 0; - - m_anim_storage[ma] = new_item; -} - -void CControlAnimationBase::AddAnim(EMotionAnim ma, LPCSTR tn, int s_id, SVelocityParam* vel, EPState p_s) -{ - SAnimItem* new_item = xr_new(); - - new_item->target_name = tn; - new_item->target_may_not_exist = false; - new_item->spec_id = s_id; - new_item->velocity = *vel; - new_item->pos_state = p_s; - - new_item->count = 0; + if (fx_exist(fxs.right)) + new_item->fxs.right = fxs.right; m_anim_storage[ma] = new_item; + return true; } void CControlAnimationBase::AddTransition( @@ -161,7 +66,7 @@ void CControlAnimationBase::AddTransition( new_item.skip_if_aggressive = skip_aggressive; - m_tTransitions.push_back(new_item); + m_tTransitions.emplace_back(new_item); } void CControlAnimationBase::AddTransition( @@ -179,7 +84,7 @@ void CControlAnimationBase::AddTransition( new_item.chain = chain; new_item.skip_if_aggressive = skip_aggressive; - m_tTransitions.push_back(new_item); + m_tTransitions.emplace_back(new_item); } void CControlAnimationBase::AddTransition( @@ -197,7 +102,7 @@ void CControlAnimationBase::AddTransition( new_item.chain = chain; new_item.skip_if_aggressive = skip_aggressive; - m_tTransitions.push_back(new_item); + m_tTransitions.emplace_back(new_item); } void CControlAnimationBase::AddTransition(EPState from, EPState to, EMotionAnim trans, bool chain, bool skip_aggressive) @@ -214,7 +119,7 @@ void CControlAnimationBase::AddTransition(EPState from, EPState to, EMotionAnim new_item.chain = chain; new_item.skip_if_aggressive = skip_aggressive; - m_tTransitions.push_back(new_item); + m_tTransitions.emplace_back(new_item); } void CControlAnimationBase::LinkAction( @@ -228,7 +133,7 @@ void CControlAnimationBase::LinkAction( new_item.turn.anim_right = pmt_right; new_item.turn.min_angle = pmt_angle; - m_tMotions.insert(std::make_pair(act, new_item)); + m_tMotions.emplace(act, new_item); } void CControlAnimationBase::LinkAction(EAction act, EMotionAnim pmt_motion) @@ -238,7 +143,7 @@ void CControlAnimationBase::LinkAction(EAction act, EMotionAnim pmt_motion) new_item.anim = pmt_motion; new_item.is_turn_params = false; - m_tMotions.insert(std::make_pair(act, new_item)); + m_tMotions.emplace(act, new_item); } void CControlAnimationBase::AddReplacedAnim(bool* b_flag, EMotionAnim pmt_cur_anim, EMotionAnim pmt_new_anim) @@ -249,5 +154,5 @@ void CControlAnimationBase::AddReplacedAnim(bool* b_flag, EMotionAnim pmt_cur_an ra.cur_anim = pmt_cur_anim; ra.new_anim = pmt_new_anim; - m_tReplacedAnims.push_back(ra); + m_tReplacedAnims.emplace_back(ra); } diff --git a/src/xrGame/ai/monsters/control_com_defs.h b/src/xrGame/ai/monsters/control_com_defs.h index 201d59f32ba..34f3d2b5eb7 100644 --- a/src/xrGame/ai/monsters/control_com_defs.h +++ b/src/xrGame/ai/monsters/control_com_defs.h @@ -2,10 +2,10 @@ namespace ControlCom { -enum EControlType +enum EControlType : u8 { // 1st level - eControlMovement = u32(0), // linear velocity + eControlMovement, // linear velocity eControlPath, // path builder eControlDir, // model direction eControlAnimation, // animation manager @@ -34,8 +34,7 @@ enum EControlType eAntiAim, eControllersCount, - - eControlInvalid = u32(-1) + eControlInvalid = u8(-1), }; struct IComData @@ -45,9 +44,9 @@ struct IEventData { }; -enum EEventType +enum EEventType : u8 { - eventAnimationStart = u32(0), + eventAnimationStart, eventAnimationEnd, eventLegsAnimationEnd, eventTorsoAnimationEnd, @@ -70,7 +69,7 @@ enum EEventType eventPathUpdated, eventPathSelectorFailed, eventThreatenEnd, - eventCriticalWoundEnd + eventCriticalWoundEnd, }; enum ECaptureType @@ -79,4 +78,4 @@ enum ECaptureType eCaptureMovement = u32(1) << 1, eCaptureDir = u32(1) << 2, }; -}; +} // namespace ControlCom diff --git a/src/xrGame/ai/monsters/control_combase.h b/src/xrGame/ai/monsters/control_combase.h index 3faa7e04fe9..e8781660c1e 100644 --- a/src/xrGame/ai/monsters/control_combase.h +++ b/src/xrGame/ai/monsters/control_combase.h @@ -12,44 +12,55 @@ class CControl_ComControlling; class CControl_Com { public: - CControl_Com() { m_inited = false; } - virtual ~CControl_Com() {} + CControl_Com() = default; + + virtual ~CControl_Com() = default; + // common routines void init_external(CControl_Manager* cm, CBaseMonster* obj) { m_man = cm; m_object = obj; } - virtual void load(LPCSTR section) {} + virtual void load(pcstr section) {} + virtual void reinit() { m_active = false; m_inited = true; } - virtual void reload(LPCSTR section) {} + + virtual void reload(pcstr section) {} + // update virtual void update_schedule() {} virtual void update_frame() {} + virtual CControl_ComControlled* ced() { return 0; } virtual CControl_ComControlling* cing() { return 0; } + void set_active(bool val = true) { m_active = val; val ? activate() : deactivate(); } - bool is_active() { return m_active; } - bool is_inited() { return m_inited; } - virtual bool check_start_conditions() { return true; } + + [[nodiscard]] bool is_active() const { return m_active; } + [[nodiscard]] bool is_inited() const { return m_inited; } + + [[nodiscard]] virtual bool check_start_conditions() { return true; } + protected: virtual void activate() {} virtual void deactivate() {} + protected: - CControl_Manager* m_man; - CBaseMonster* m_object; + CControl_Manager* m_man{}; + CBaseMonster* m_object{}; private: - bool m_active; - bool m_inited; + bool m_active{}; + bool m_inited{}; }; ////////////////////////////////////////////////////////////////////////// diff --git a/src/xrGame/ai/monsters/control_manager.h b/src/xrGame/ai/monsters/control_manager.h index b6c1476763d..3cdc469eabc 100644 --- a/src/xrGame/ai/monsters/control_manager.h +++ b/src/xrGame/ai/monsters/control_manager.h @@ -31,8 +31,7 @@ class CControl_Manager CONTROLLERS_MAP m_control_elems; CONTROLLERS_MAP m_base_elems; - using COM_VEC = xr_vector; - COM_VEC m_active_elems; + xr_vector m_active_elems; CControlAnimation* m_animation; CControlDirection* m_direction; @@ -81,10 +80,10 @@ class CControl_Manager ControlCom::IComData* data(CControl_Com*, ControlCom::EControlType); - CControlAnimation& animation() { return (*m_animation); } - CControlDirection& direction() { return (*m_direction); } - CControlPathBuilder& path_builder() { return (*m_path); } - CControlMovement& movement() { return (*m_movement); } + CControlAnimation& animation() const { return (*m_animation); } + CControlDirection& direction() const { return (*m_direction); } + CControlPathBuilder& path_builder() const { return (*m_path); } + CControlMovement& movement() const { return (*m_movement); } void install_path_manager(CControlPathBuilder*); bool is_captured(ControlCom::EControlType); diff --git a/src/xrGame/ai/monsters/control_manager_custom.cpp b/src/xrGame/ai/monsters/control_manager_custom.cpp index e9ec5208d5e..63172621f4c 100644 --- a/src/xrGame/ai/monsters/control_manager_custom.cpp +++ b/src/xrGame/ai/monsters/control_manager_custom.cpp @@ -651,7 +651,6 @@ void CControlManagerCustom::fill_rotation_data( { motion = skeleton_animated->ID_Cycle_Safe(left1); data.anim_stop_ls = motion; - m_object->anim().AddAnimTranslation(motion, left1); } else { @@ -662,7 +661,6 @@ void CControlManagerCustom::fill_rotation_data( { motion = skeleton_animated->ID_Cycle_Safe(left2); data.anim_run_ls = motion; - m_object->anim().AddAnimTranslation(motion, left2); } else { @@ -673,7 +671,6 @@ void CControlManagerCustom::fill_rotation_data( { motion = skeleton_animated->ID_Cycle_Safe(right1); data.anim_stop_rs = motion; - m_object->anim().AddAnimTranslation(motion, right1); } else { @@ -684,7 +681,6 @@ void CControlManagerCustom::fill_rotation_data( { motion = skeleton_animated->ID_Cycle_Safe(right2); data.anim_run_rs = motion; - m_object->anim().AddAnimTranslation(motion, right2); } else { diff --git a/src/xrGame/ai/monsters/control_path_builder.cpp b/src/xrGame/ai/monsters/control_path_builder.cpp index afb322638b1..b2d9dc13f86 100644 --- a/src/xrGame/ai/monsters/control_path_builder.cpp +++ b/src/xrGame/ai/monsters/control_path_builder.cpp @@ -234,7 +234,7 @@ void CControlPathBuilder::fix_position(const Fvector& pos, u32 node, Fvector& re VPUSH(res_pos)); } VERIFY3((level_vertex_id == node) || show_restrictions(m_restricted_object), - "Invalid restrictions (see log for details) for object ", *(CControl_Com::m_object->cName())); + "Invalid restrictions (see log for details) for object ", CControl_Com::m_object->cName().c_str()); #endif } } diff --git a/src/xrGame/ai/monsters/controller/controller.cpp b/src/xrGame/ai/monsters/controller/controller.cpp index 8056787e296..7fa745ffb8e 100644 --- a/src/xrGame/ai/monsters/controller/controller.cpp +++ b/src/xrGame/ai/monsters/controller/controller.cpp @@ -682,7 +682,7 @@ void CController::TranslateActionToPathParams() bool CController::is_relation_enemy(const CEntityAlive* tpEntityAlive) const { // MONSTER_COMMUNITY_ID - if (xr_strcmp(*(tpEntityAlive->cNameSect()), "stalker_zombied") == 0) + if (xr_strcmp(tpEntityAlive->cNameSect().c_str(), "stalker_zombied") == 0) return false; if (is_community_friend_overrides(tpEntityAlive)) return false; diff --git a/src/xrGame/ai/monsters/controller/controller.h b/src/xrGame/ai/monsters/controller/controller.h index a676e4e456f..fb05de7d136 100644 --- a/src/xrGame/ai/monsters/controller/controller.h +++ b/src/xrGame/ai/monsters/controller/controller.h @@ -169,4 +169,7 @@ class CController : public CBaseMonster, public CControlledActor public: virtual bool run_home_point_when_enemy_inaccessible() const { return false; } + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; diff --git a/src/xrGame/ai/monsters/controller/controller_script.cpp b/src/xrGame/ai/monsters/controller/controller_script.cpp index 6274668dccf..e5059ef11e2 100644 --- a/src/xrGame/ai/monsters/controller/controller_script.cpp +++ b/src/xrGame/ai/monsters/controller/controller_script.cpp @@ -1,8 +1,8 @@ #include "pch_script.h" + #include "controller.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CController, (CGameObject), +void CController::script_register(lua_State* luaState) { using namespace luabind; @@ -11,4 +11,4 @@ SCRIPT_EXPORT(CController, (CGameObject), class_("CController") .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/ai/monsters/dog/dog.cpp b/src/xrGame/ai/monsters/dog/dog.cpp index d97eeef2dfb..f69d70fc5a0 100644 --- a/src/xrGame/ai/monsters/dog/dog.cpp +++ b/src/xrGame/ai/monsters/dog/dog.cpp @@ -94,14 +94,14 @@ void CAI_Dog::Load(LPCSTR section) anim().AddAnim(eAnimRunTurnRight, "stand_run_turn_right_", -1, &velocity_run, PS_STAND); anim().AddAnim(eAnimCheckCorpse, "stand_check_corpse_", -1, &velocity_none, PS_STAND); - anim().AddAnim2(eAnimDragCorpse, { "stand_drage_", "stand_drag_" }, -1, &velocity_drag, PS_STAND); + anim().AddAnim(eAnimDragCorpse, "stand_drage_", -1, &velocity_drag, PS_STAND); // anim().AddAnim(eAnimSniff, "stand_sniff_", -1, &velocity_none, PS_STAND); // anim().AddAnim(eAnimHowling, "stand_howling_", -1, &velocity_none, PS_STAND); // anim().AddAnim(eAnimJumpGlide, "jump_glide_", -1, &velocity_none, PS_STAND); anim().AddAnim(eAnimJumpGlide, "stand_jump_left_", 0, &velocity_none, PS_STAND); - anim().AddAnim2(eAnimSteal, { "stand_walk_fwd_", "stand_steal_" }, -1, &velocity_steal, PS_STAND); + anim().AddAnim(eAnimSteal, "stand_walk_fwd_", -1, &velocity_steal, PS_STAND); anim().AddAnim(eAnimThreaten, "stand_threaten_", -1, &velocity_none, PS_STAND); anim().AddAnim(eAnimSitLieDown, "sit_lie_down_", -1, &velocity_none, PS_SIT); @@ -115,8 +115,8 @@ void CAI_Dog::Load(LPCSTR section) /////////////mob home - anim().AddAnim(eAnimHomeWalkSmelling, { "stand_walk_smelling_", true }, -1, &velocity_walk_smell, PS_STAND); - anim().AddAnim(eAnimHomeWalkGrowl, { "stand_growl_walk_", true }, -1, &velocity_walk_growl, PS_STAND); + anim().AddAnim(eAnimHomeWalkSmelling, "stand_walk_smelling_", -1, &velocity_walk_smell, PS_STAND); + anim().AddAnim(eAnimHomeWalkGrowl, "stand_growl_walk_", -1, &velocity_walk_growl, PS_STAND); /////////////end mob home diff --git a/src/xrGame/ai/monsters/dog/dog.h b/src/xrGame/ai/monsters/dog/dog.h index a30b1a25c06..f2396f919e8 100644 --- a/src/xrGame/ai/monsters/dog/dog.h +++ b/src/xrGame/ai/monsters/dog/dog.h @@ -61,4 +61,7 @@ class CAI_Dog : public CBaseMonster, public CControlledEntity #ifdef _DEBUG virtual void debug_on_key(int key); #endif + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; diff --git a/src/xrGame/ai/monsters/dog/dog_script.cpp b/src/xrGame/ai/monsters/dog/dog_script.cpp index 17bcb2bea2a..e267685c119 100644 --- a/src/xrGame/ai/monsters/dog/dog_script.cpp +++ b/src/xrGame/ai/monsters/dog/dog_script.cpp @@ -1,8 +1,8 @@ #include "pch_script.h" + #include "dog.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CAI_Dog, (CGameObject), +void CAI_Dog::script_register(lua_State* luaState) { using namespace luabind; @@ -11,4 +11,4 @@ SCRIPT_EXPORT(CAI_Dog, (CGameObject), class_("CAI_Dog") .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/ai/monsters/flesh/flesh.h b/src/xrGame/ai/monsters/flesh/flesh.h index aa298dc4bb7..d132afe0c97 100644 --- a/src/xrGame/ai/monsters/flesh/flesh.h +++ b/src/xrGame/ai/monsters/flesh/flesh.h @@ -22,4 +22,7 @@ class CAI_Flesh : public CBaseMonster, public CControlledEntity private: bool ConeSphereIntersection( Fvector ConeVertex, float ConeAngle, Fvector ConeDir, Fvector SphereCenter, float SphereRadius); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; diff --git a/src/xrGame/ai/monsters/flesh/flesh_script.cpp b/src/xrGame/ai/monsters/flesh/flesh_script.cpp index f72d2a60462..30b7351271f 100644 --- a/src/xrGame/ai/monsters/flesh/flesh_script.cpp +++ b/src/xrGame/ai/monsters/flesh/flesh_script.cpp @@ -1,8 +1,8 @@ #include "pch_script.h" + #include "flesh.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CAI_Flesh, (CGameObject), +void CAI_Flesh::script_register(lua_State* luaState) { using namespace luabind; @@ -11,4 +11,4 @@ SCRIPT_EXPORT(CAI_Flesh, (CGameObject), class_("CAI_Flesh") .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/ai/monsters/flesh/flesh_state_manager.cpp b/src/xrGame/ai/monsters/flesh/flesh_state_manager.cpp index 31193b3dcc3..967942c53a2 100644 --- a/src/xrGame/ai/monsters/flesh/flesh_state_manager.cpp +++ b/src/xrGame/ai/monsters/flesh/flesh_state_manager.cpp @@ -14,18 +14,12 @@ #include "ai/monsters/states/monster_state_hitted.h" #include "ai/monsters/states/monster_state_controlled.h" #include "ai/monsters/states/monster_state_help_sound.h" -#include "ai/monsters/group_states/group_state_home_point_attack.h" CStateManagerFlesh::CStateManagerFlesh(CAI_Flesh* monster) : inherited(monster) { add_state(eStateRest, xr_new>(monster)); add_state(eStatePanic, xr_new>(monster)); - - CStateMonsterAttackMoveToHomePoint* move2home = - xr_new>(monster); - - add_state(eStateAttack, xr_new>(monster, move2home)); - + add_state(eStateAttack, xr_new>(monster)); add_state(eStateEat, xr_new>(monster)); add_state(eStateHearInterestingSound, xr_new>(monster)); add_state(eStateHearDangerousSound, xr_new>(monster)); diff --git a/src/xrGame/ai/monsters/fracture/fracture.h b/src/xrGame/ai/monsters/fracture/fracture.h index 363756aaf82..0a55cca00fe 100644 --- a/src/xrGame/ai/monsters/fracture/fracture.h +++ b/src/xrGame/ai/monsters/fracture/fracture.h @@ -15,4 +15,7 @@ class CFracture : public CBaseMonster virtual void CheckSpecParams(u32 spec_params); pcstr get_monster_class_name() override { return "fracture"; } + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; diff --git a/src/xrGame/ai/monsters/fracture/fracture_script.cpp b/src/xrGame/ai/monsters/fracture/fracture_script.cpp index 37c44496c1b..a6e14dd7f9f 100644 --- a/src/xrGame/ai/monsters/fracture/fracture_script.cpp +++ b/src/xrGame/ai/monsters/fracture/fracture_script.cpp @@ -1,8 +1,8 @@ #include "pch_script.h" + #include "fracture.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CFracture, (CGameObject), +void CFracture::script_register(lua_State* luaState) { using namespace luabind; @@ -11,4 +11,4 @@ SCRIPT_EXPORT(CFracture, (CGameObject), class_("CFracture") .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/ai/monsters/monster_enemy_manager.cpp b/src/xrGame/ai/monsters/monster_enemy_manager.cpp index 6930f6e0bf1..1b98e10b4b9 100644 --- a/src/xrGame/ai/monsters/monster_enemy_manager.cpp +++ b/src/xrGame/ai/monsters/monster_enemy_manager.cpp @@ -9,23 +9,16 @@ #include "actor_memory.h" CMonsterEnemyManager::CMonsterEnemyManager() - : vertex(0), time_last_seen(0), expediency(false), - enemy_see_me(false), m_script_enemy(nullptr) { - monster = nullptr; - enemy = nullptr; flags.zero(); - forced = false; - prev_enemy = 0; - danger_type = eNone; - my_vertex_enemy_last_seen = u32(-1); - enemy_vertex_enemy_last_seen = u32(-1); - m_time_updated = 0; - m_time_start_see_enemy = 0; + +} + +void CMonsterEnemyManager::init_external(CBaseMonster* m) +{ + monster = m; } -CMonsterEnemyManager::~CMonsterEnemyManager() {} -void CMonsterEnemyManager::init_external(CBaseMonster* M) { monster = M; } void CMonsterEnemyManager::update() { if (m_script_enemy && (m_script_enemy->getDestroy() || !m_script_enemy->g_Alive())) @@ -82,7 +75,7 @@ void CMonsterEnemyManager::update() } // проверить видимоÑть - enemy_see_me = is_faced(enemy, monster); + const bool enemy_see_me = is_faced(enemy, monster); // обновить опаÑноÑть врага danger_type = eNone; @@ -107,11 +100,10 @@ void CMonsterEnemyManager::update() if (!enemy_see_me) flags._or (FLAG_ENEMY_DOESNT_SEE_ME); - float dist_now, dist_prev; if (prev_enemy == enemy) { - dist_now = position.distance_to(monster->Position()); - dist_prev = prev_enemy_position.distance_to(monster->Position()); + const float dist_now = position.distance_to(monster->Position()); + const float dist_prev = prev_enemy_position.distance_to(monster->Position()); if (_abs(dist_now - dist_prev) < 0.2f) flags._or (FLAG_ENEMY_STANDING); @@ -141,8 +133,6 @@ void CMonsterEnemyManager::update() prev_enemy = enemy; prev_enemy_position = position; - expediency = true; - if (enemy && see_enemy_now()) { my_vertex_enemy_last_seen = monster->ai_location().level_vertex_id(); @@ -186,14 +176,18 @@ void CMonsterEnemyManager::unforce_enemy() update(); } -u32 CMonsterEnemyManager::get_enemies_count() { return monster->EnemyMemory.get_enemies_count(); } +size_t CMonsterEnemyManager::get_enemies_count() const +{ + return monster->EnemyMemory.get_enemies_count(); +} + void CMonsterEnemyManager::reinit() { - enemy = 0; + enemy = nullptr; time_last_seen = 0; flags.zero(); forced = false; - prev_enemy = 0; + prev_enemy = nullptr; danger_type = eNone; my_vertex_enemy_last_seen = monster->ai_location().level_vertex_id(); @@ -205,32 +199,41 @@ void CMonsterEnemyManager::reinit() script_enemy(); } -void CMonsterEnemyManager::add_enemy(const CEntityAlive* enemy) { monster->EnemyMemory.add_enemy(enemy); } -bool CMonsterEnemyManager::see_enemy_now() { return monster->memory().visual().visible_right_now(enemy); } -bool CMonsterEnemyManager::see_enemy_now(const CEntityAlive* enemy) +void CMonsterEnemyManager::add_enemy(const CEntityAlive* enemy) +{ + monster->EnemyMemory.add_enemy(enemy); +} + +bool CMonsterEnemyManager::see_enemy_now() const +{ + return monster->memory().visual().visible_right_now(enemy); +} + +bool CMonsterEnemyManager::see_enemy_now(const CEntityAlive* enemy) const { return monster->memory().visual().visible_right_now(enemy); } -bool CMonsterEnemyManager::see_enemy_recently() { return see_enemy_recently(enemy); } -bool CMonsterEnemyManager::see_enemy_recently(const CEntityAlive* enemy) +bool CMonsterEnemyManager::see_enemy_recently() const +{ + return see_enemy_recently(enemy); +} + +bool CMonsterEnemyManager::see_enemy_recently(const CEntityAlive* enemy) const { return monster->memory().visual().visible_now(enemy); } -bool CMonsterEnemyManager::enemy_see_me_now() +bool CMonsterEnemyManager::enemy_see_me_now() const { if (Actor() == enemy) { - return (Actor()->memory().visual().visible_right_now(monster)); + return Actor()->memory().visual().visible_right_now(monster); } - else + + if (const CCustomMonster* cm = const_cast(enemy)->cast_custom_monster()) { - CCustomMonster* cm = const_cast(enemy)->cast_custom_monster(); - if (cm) - { - return cm->memory().visual().visible_right_now(monster); - } + return cm->memory().visual().visible_right_now(monster); } return false; @@ -264,12 +267,11 @@ bool CMonsterEnemyManager::is_faced(const CEntityAlive* object0, const CEntityAl return angle_difference(yaw1, yaw2) <= fYawFov && angle_difference(pitch1, pitch2) <= fPitchFov; } -bool CMonsterEnemyManager::is_enemy(const CEntityAlive* obj) +bool CMonsterEnemyManager::is_enemy(const CEntityAlive* obj) const { return ((monster->g_Team() != obj->g_Team()) && monster->is_relation_enemy(obj) && obj->g_Alive()); } -const Fvector& CMonsterEnemyManager::get_enemy_position() { return position; } void CMonsterEnemyManager::transfer_enemy(CBaseMonster* friend_monster) { // еÑли у friend_monster нет врага @@ -280,25 +282,29 @@ void CMonsterEnemyManager::transfer_enemy(CBaseMonster* friend_monster) friend_monster->EnemyMan.get_enemy_vertex(), friend_monster->EnemyMan.get_enemy_time_last_seen()); } -u32 CMonsterEnemyManager::see_enemy_duration() +u32 CMonsterEnemyManager::see_enemy_duration() const { return ((m_time_start_see_enemy == 0) ? 0 : (time() - m_time_start_see_enemy)); } -void CMonsterEnemyManager::script_enemy() { m_script_enemy = 0; } -void CMonsterEnemyManager::script_enemy(const CEntityAlive& enemy) { m_script_enemy = &enemy; } +void CMonsterEnemyManager::script_enemy() +{ + m_script_enemy = nullptr; +} + +void CMonsterEnemyManager::script_enemy(const CEntityAlive& enemy) +{ + m_script_enemy = &enemy; +} + void CMonsterEnemyManager::remove_links(IGameObject* O) { if (enemy == O) - { - enemy = NULL; - } + enemy = nullptr; + if (prev_enemy == O) - { - prev_enemy = NULL; - } + prev_enemy = nullptr; + if (m_script_enemy == O) - { - m_script_enemy = NULL; - } + m_script_enemy = nullptr; } diff --git a/src/xrGame/ai/monsters/monster_enemy_manager.h b/src/xrGame/ai/monsters/monster_enemy_manager.h index 1af66a26289..40644afad31 100644 --- a/src/xrGame/ai/monsters/monster_enemy_manager.h +++ b/src/xrGame/ai/monsters/monster_enemy_manager.h @@ -5,38 +5,34 @@ class CBaseMonster; class CMonsterEnemyManager { - CBaseMonster* monster; + CBaseMonster* monster{}; - const CEntityAlive* enemy; + const CEntityAlive* enemy{}; + const CEntityAlive* prev_enemy{}; Fvector position; - u32 vertex; - u32 time_last_seen; - - Flags32 flags; - bool forced; - - bool expediency; - - const CEntityAlive* prev_enemy; Fvector prev_enemy_position; - bool enemy_see_me; + u32 vertex{}; + u32 time_last_seen{}; + + Flags16 flags; + bool forced{}; - EDangerType danger_type; + EDangerType danger_type{ eNone }; // node, where monster saw enemy last time - u32 my_vertex_enemy_last_seen; + u32 my_vertex_enemy_last_seen{ u32(-1) }; // node, of enemy (its always valid unlike vertex) - u32 enemy_vertex_enemy_last_seen; + u32 enemy_vertex_enemy_last_seen{ u32(-1) }; - u32 m_time_updated; - u32 m_time_start_see_enemy; + u32 m_time_updated{}; + u32 m_time_start_see_enemy{}; public: CMonsterEnemyManager(); - ~CMonsterEnemyManager(); - void init_external(CBaseMonster* M); + + void init_external(CBaseMonster* m); void reinit(); void update(); @@ -44,39 +40,48 @@ class CMonsterEnemyManager void force_enemy(const CEntityAlive* enemy); void unforce_enemy(); - const CEntityAlive* get_enemy() { return enemy; } - EDangerType get_danger_type() { return danger_type; } - const Fvector& get_enemy_position(); - u32 get_enemy_vertex() { return vertex; } - TTime get_enemy_time_last_seen() { return time_last_seen; } - Flags32& get_flags() { return flags; } - bool see_enemy_now(); - bool see_enemy_now(const CEntityAlive* enemy); - bool see_enemy_recently(); - bool see_enemy_recently(const CEntityAlive* enemy); - bool enemy_see_me_now(); + [[nodiscard]] const CEntityAlive* get_enemy() const { return enemy; } + + [[nodiscard]] EDangerType get_danger_type() const { return danger_type; } + + [[nodiscard]] const Fvector& get_enemy_position() const { return position; } + + [[nodiscard]] u32 get_enemy_vertex() const { return vertex; } + + [[nodiscard]] TTime get_enemy_time_last_seen() const { return time_last_seen; } + + [[nodiscard]] Flags16& get_flags() { return flags; } + + [[nodiscard]] const Flags16& get_flags() const { return flags; } + + [[nodiscard]] bool see_enemy_now() const; + [[nodiscard]] bool see_enemy_now(const CEntityAlive* enemy) const; + [[nodiscard]] bool see_enemy_recently() const; + [[nodiscard]] bool see_enemy_recently(const CEntityAlive* enemy) const; + [[nodiscard]] bool enemy_see_me_now() const; // вернуть количеÑтво врагов - u32 get_enemies_count(); + [[nodiscard]] size_t get_enemies_count() const; void add_enemy(const CEntityAlive*); - bool is_faced(const CEntityAlive* object0, const CEntityAlive* object1); + [[nodiscard]] bool is_faced(const CEntityAlive* object0, const CEntityAlive* object1); - bool is_enemy(const CEntityAlive* obj); + [[nodiscard]] bool is_enemy(const CEntityAlive* obj) const; // обновить врага в ÑоответÑтвии Ñ Ð²Ñ€Ð°Ð³Ð¾Ð¼ у monster void transfer_enemy(CBaseMonster* friend_monster); - u32 get_my_vertex_enemy_last_seen() { return my_vertex_enemy_last_seen; } - u32 get_enemy_vertex_enemy_last_seen() { return enemy_vertex_enemy_last_seen; } - u32 see_enemy_duration(); + [[nodiscard]] u32 get_my_vertex_enemy_last_seen() const { return my_vertex_enemy_last_seen; } + [[nodiscard]] u32 get_enemy_vertex_enemy_last_seen() const { return enemy_vertex_enemy_last_seen; } + [[nodiscard]] u32 see_enemy_duration() const; private: - const CEntityAlive* m_script_enemy; + const CEntityAlive* m_script_enemy{}; public: - const CEntityAlive* get_script_enemy() { return m_script_enemy; } + const CEntityAlive* get_script_enemy() const { return m_script_enemy; } void script_enemy(); void script_enemy(const CEntityAlive& enemy); + void remove_links(IGameObject* O); }; diff --git a/src/xrGame/ai/monsters/monster_hit_memory.cpp b/src/xrGame/ai/monsters/monster_hit_memory.cpp index 49a141b230b..adba1ecb74a 100644 --- a/src/xrGame/ai/monsters/monster_hit_memory.cpp +++ b/src/xrGame/ai/monsters/monster_hit_memory.cpp @@ -2,13 +2,6 @@ #include "monster_hit_memory.h" #include "basemonster/base_monster.h" -CMonsterHitMemory::CMonsterHitMemory() -{ - monster = 0; - time_memory = 10000; -} - -CMonsterHitMemory::~CMonsterHitMemory() {} void CMonsterHitMemory::init_external(CBaseMonster* M, TTime mem_time) { monster = M; @@ -21,23 +14,23 @@ void CMonsterHitMemory::update() remove_non_actual(); } -bool CMonsterHitMemory::is_hit(IGameObject* pO) +bool CMonsterHitMemory::is_hit(const IGameObject* pO) { - return (std::find(m_hits.begin(), m_hits.end(), pO) != m_hits.end()); + return std::find(m_hits.begin(), m_hits.end(), pO) != m_hits.end(); } void CMonsterHitMemory::add_hit(IGameObject* who, EHitSide side) { - SMonsterHit new_hit_info; - new_hit_info.object = who; - new_hit_info.time = Device.dwTimeGlobal; - new_hit_info.side = side; - new_hit_info.position = monster->Position(); - - auto it = std::find(m_hits.begin(), m_hits.end(), who); - - if (it == m_hits.end()) - m_hits.push_back(new_hit_info); + SMonsterHit new_hit_info + { + .object = who, + .position = monster->Position(), + .time = Device.dwTimeGlobal, + .side = side, + }; + + if (const auto it = std::find(m_hits.begin(), m_hits.end(), who); it == m_hits.end()) + m_hits.emplace_back(new_hit_info); else *it = new_hit_info; } @@ -53,7 +46,7 @@ struct predicate_old_hit this->mem_time = mem_time; } - IC bool operator()(const SMonsterHit& hit_info) + IC bool operator()(const SMonsterHit& hit_info) const { if ((mem_time + hit_info.time) < cur_time) return true; @@ -108,7 +101,7 @@ Fvector CMonsterHitMemory::get_last_hit_dir() return dir; } -TTime CMonsterHitMemory::get_last_hit_time() +TTime CMonsterHitMemory::get_last_hit_time() const { SMonsterHit last_hit; last_hit.time = 0; @@ -122,7 +115,7 @@ TTime CMonsterHitMemory::get_last_hit_time() return last_hit.time; } -IGameObject* CMonsterHitMemory::get_last_hit_object() +IGameObject* CMonsterHitMemory::get_last_hit_object() const { SMonsterHit last_hit; last_hit.object = 0; @@ -137,7 +130,7 @@ IGameObject* CMonsterHitMemory::get_last_hit_object() return last_hit.object; } -Fvector CMonsterHitMemory::get_last_hit_position() +Fvector CMonsterHitMemory::get_last_hit_position() const { SMonsterHit last_hit; last_hit.time = 0; @@ -157,7 +150,7 @@ struct predicate_old_info const IGameObject* object; predicate_old_info(const IGameObject* obj) : object(obj) {} - IC bool operator()(const SMonsterHit& hit_info) { return (object == hit_info.object); } + IC bool operator()(const SMonsterHit& hit_info) const { return (object == hit_info.object); } }; void CMonsterHitMemory::remove_hit_info(const IGameObject* obj) diff --git a/src/xrGame/ai/monsters/monster_hit_memory.h b/src/xrGame/ai/monsters/monster_hit_memory.h index c7579937421..8180b1c9188 100644 --- a/src/xrGame/ai/monsters/monster_hit_memory.h +++ b/src/xrGame/ai/monsters/monster_hit_memory.h @@ -5,30 +5,26 @@ class CBaseMonster; class CMonsterHitMemory { - CBaseMonster* monster; - TTime time_memory; + CBaseMonster* monster{}; + TTime time_memory{ 10000 }; MONSTER_HIT_VECTOR m_hits; public: - CMonsterHitMemory(); - ~CMonsterHitMemory(); - void init_external(CBaseMonster* M, TTime mem_time); void update(); - // ----------------------------------------------------- - bool is_hit() { return !m_hits.empty(); } - bool is_hit(IGameObject* pO); + [[nodiscard]] bool is_hit() const { return !m_hits.empty(); } + [[nodiscard]] bool is_hit(const IGameObject* pO); // Lain: added - int get_num_hits() { return m_hits.size(); } + auto get_num_hits() const { return m_hits.size(); } void add_hit(IGameObject* who, EHitSide side); Fvector get_last_hit_dir(); - TTime get_last_hit_time(); - IGameObject* get_last_hit_object(); - Fvector get_last_hit_position(); + TTime get_last_hit_time() const; + IGameObject* get_last_hit_object() const; + Fvector get_last_hit_position() const; void clear() { m_hits.clear(); } void remove_hit_info(const IGameObject* obj); diff --git a/src/xrGame/ai/monsters/monster_home.cpp b/src/xrGame/ai/monsters/monster_home.cpp index d3455b0467c..0eb9b7f00b8 100644 --- a/src/xrGame/ai/monsters/monster_home.cpp +++ b/src/xrGame/ai/monsters/monster_home.cpp @@ -52,8 +52,8 @@ void CMonsterHome::load(LPCSTR line) if (m_object->spawn_ini()->line_exist(line, "radius_max")) m_radius_max = m_object->spawn_ini()->r_float(line, "radius_max"); - VERIFY3( - m_radius_max > m_radius_min, "Error: Wrong home point radius specified for monster ", *m_object->cName()); + VERIFY3(m_radius_max > m_radius_min, "Error: Wrong home point radius specified for monster ", + m_object->cName().c_str()); if (m_object->spawn_ini()->line_exist(line, "radius_middle")) { diff --git a/src/xrGame/ai/monsters/poltergeist/poltergeist.cpp b/src/xrGame/ai/monsters/poltergeist/poltergeist.cpp index b97277dd017..d3350ff9601 100644 --- a/src/xrGame/ai/monsters/poltergeist/poltergeist.cpp +++ b/src/xrGame/ai/monsters/poltergeist/poltergeist.cpp @@ -66,34 +66,22 @@ void CPoltergeist::Load(LPCSTR section) // SVelocityParam &velocity_steal = move().get_velocity(MonsterMovement::eVelocityParameterSteal); // SVelocityParam &velocity_drag = move().get_velocity(MonsterMovement::eVelocityParameterDrag); - anim().AddAnim(eAnimStandIdle, "stand_idle_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimStandTurnLeft, "stand_turn_ls_", -1, &velocity_turn, PS_STAND, "fx_stand_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimStandTurnRight, "stand_turn_rs_", -1, &velocity_turn, PS_STAND, "fx_stand_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimWalkFwd, "stand_walk_fwd_", -1, &velocity_walk, PS_STAND, "fx_stand_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimRun, "stand_run_fwd_", -1, &velocity_run, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", - "fx_stand_r"); - anim().AddAnim(eAnimAttack, "stand_attack_", -1, &velocity_turn, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", - "fx_stand_r"); - anim().AddAnim( - eAnimDie, "stand_idle_", 0, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimMiscAction_00, "fall_down_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimMiscAction_01, "fly_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", - "fx_stand_r"); - anim().AddAnim(eAnimCheckCorpse, "stand_check_corpse_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim( - eAnimEat, "stand_eat_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimLookAround, "stand_look_around_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimWalkDamaged, "stand_walk_dmg_", -1, &velocity_walk_dmg, PS_STAND, "fx_stand_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimRunDamaged, "stand_walk_dmg_", -1, &velocity_run_dmg, PS_STAND, "fx_stand_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); + const SAnimItem::Effects fxs{ "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r" }; + + anim().AddAnim(eAnimStandIdle, "stand_idle_", -1, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimStandTurnLeft, "stand_turn_ls_", -1, &velocity_turn, PS_STAND, fxs); + anim().AddAnim(eAnimStandTurnRight, "stand_turn_rs_", -1, &velocity_turn, PS_STAND, fxs); + anim().AddAnim(eAnimWalkFwd, "stand_walk_fwd_", -1, &velocity_walk, PS_STAND, fxs); + anim().AddAnim(eAnimRun, "stand_run_fwd_", -1, &velocity_run, PS_STAND, fxs); + anim().AddAnim(eAnimAttack, "stand_attack_", -1, &velocity_turn, PS_STAND, fxs); + anim().AddAnim(eAnimDie, "stand_idle_", 0, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimMiscAction_00, "fall_down_", -1, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimMiscAction_01, "fly_", -1, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimCheckCorpse, "stand_check_corpse_", -1, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimEat, "stand_eat_", -1, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimLookAround, "stand_look_around_", -1, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimWalkDamaged, "stand_walk_dmg_", -1, &velocity_walk_dmg, PS_STAND, fxs); + anim().AddAnim(eAnimRunDamaged, "stand_walk_dmg_", -1, &velocity_run_dmg, PS_STAND, fxs); anim().LinkAction(ACT_STAND_IDLE, eAnimStandIdle); anim().LinkAction(ACT_SIT_IDLE, eAnimStandIdle); diff --git a/src/xrGame/ai/monsters/poltergeist/poltergeist.h b/src/xrGame/ai/monsters/poltergeist/poltergeist.h index dfe474506bb..91c77348c6c 100644 --- a/src/xrGame/ai/monsters/poltergeist/poltergeist.h +++ b/src/xrGame/ai/monsters/poltergeist/poltergeist.h @@ -133,6 +133,9 @@ class CPoltergeist : public CBaseMonster, public CTelekinesis, public CEnergyHol #endif friend class CPolterFlame; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; ////////////////////////////////////////////////////////////////////////// diff --git a/src/xrGame/ai/monsters/poltergeist/poltergeist_script.cpp b/src/xrGame/ai/monsters/poltergeist/poltergeist_script.cpp index ff49c3339d8..31c702646a8 100644 --- a/src/xrGame/ai/monsters/poltergeist/poltergeist_script.cpp +++ b/src/xrGame/ai/monsters/poltergeist/poltergeist_script.cpp @@ -1,8 +1,8 @@ #include "pch_script.h" + #include "poltergeist.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CPoltergeist, (CGameObject), +void CPoltergeist::script_register(lua_State* luaState) { using namespace luabind; @@ -11,4 +11,4 @@ SCRIPT_EXPORT(CPoltergeist, (CGameObject), class_("CPoltergeist") .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/ai/monsters/pseudodog/pseudodog.h b/src/xrGame/ai/monsters/pseudodog/pseudodog.h index 2eac1578b24..778ff32d0c5 100644 --- a/src/xrGame/ai/monsters/pseudodog/pseudodog.h +++ b/src/xrGame/ai/monsters/pseudodog/pseudodog.h @@ -45,4 +45,7 @@ class CAI_PseudoDog : public CBaseMonster #ifdef _DEBUG virtual void debug_on_key(int key); #endif + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; diff --git a/src/xrGame/ai/monsters/pseudodog/pseudodog_script.cpp b/src/xrGame/ai/monsters/pseudodog/pseudodog_script.cpp index bf5f489b3f8..2d19acac5fd 100644 --- a/src/xrGame/ai/monsters/pseudodog/pseudodog_script.cpp +++ b/src/xrGame/ai/monsters/pseudodog/pseudodog_script.cpp @@ -1,9 +1,9 @@ #include "pch_script.h" + #include "pseudodog.h" #include "psy_dog.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CAI_PseudoDog, (CGameObject), +void CAI_PseudoDog::script_register(lua_State* luaState) { using namespace luabind; @@ -12,9 +12,9 @@ SCRIPT_EXPORT(CAI_PseudoDog, (CGameObject), class_("CAI_PseudoDog") .def(constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CPsyDog, (CGameObject), +void CPsyDog::script_register(lua_State* luaState) { using namespace luabind; @@ -23,9 +23,9 @@ SCRIPT_EXPORT(CPsyDog, (CGameObject), class_("CPsyDog") .def(constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CPsyDogPhantom, (CGameObject), +void CPsyDogPhantom::script_register(lua_State* luaState) { using namespace luabind; @@ -34,4 +34,4 @@ SCRIPT_EXPORT(CPsyDogPhantom, (CGameObject), class_("CPsyDogPhantom") .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/ai/monsters/pseudodog/pseudodog_state_manager.cpp b/src/xrGame/ai/monsters/pseudodog/pseudodog_state_manager.cpp index cba8364b136..d698a83ff8c 100644 --- a/src/xrGame/ai/monsters/pseudodog/pseudodog_state_manager.cpp +++ b/src/xrGame/ai/monsters/pseudodog/pseudodog_state_manager.cpp @@ -19,12 +19,7 @@ CStateManagerPseudodog::CStateManagerPseudodog(CAI_PseudoDog* monster) : inherit { add_state(eStateRest, xr_new>(monster)); add_state(eStatePanic, xr_new>(monster)); - - CStateMonsterAttackMoveToHomePoint* move2home = - xr_new>(monster); - - add_state(eStateAttack, xr_new>(monster, move2home)); - + add_state(eStateAttack, xr_new>(monster)); add_state(eStateEat, xr_new>(monster)); add_state(eStateHearInterestingSound, xr_new>(monster)); add_state(eStateHearDangerousSound, xr_new>(monster)); diff --git a/src/xrGame/ai/monsters/pseudodog/psy_dog.cpp b/src/xrGame/ai/monsters/pseudodog/psy_dog.cpp index 1a8008b6bca..9b001a80ca4 100644 --- a/src/xrGame/ai/monsters/pseudodog/psy_dog.cpp +++ b/src/xrGame/ai/monsters/pseudodog/psy_dog.cpp @@ -68,21 +68,19 @@ void CPsyDog::reload(LPCSTR section) { inherited::reload(section); } ////////////////////////////////////////////////////////////////////////// void CPsyDog::register_phantom(CPsyDogPhantom* phantom) { m_storage.push_back(phantom); } + void CPsyDog::unregister_phantom(CPsyDogPhantom* phantom) { - xr_vector::iterator it = std::find(m_storage.begin(), m_storage.end(), phantom); - - for (int i = 0; i < m_max_phantoms_count; ++i) - { - if (m_phantoms_die_time[i] == s_phantom_alive_flag) - { - m_phantoms_die_time[i] = time(); - break; - } - } - + const auto it = std::find(m_storage.begin(), m_storage.end(), phantom); VERIFY(it != m_storage.end()); + if (it == m_storage.end()) + return; + m_storage.erase(it); + + const auto idx = std::distance(m_storage.begin(), it); + if (idx < m_max_phantoms_count) + m_phantoms_die_time[idx] = time(); } ////////////////////////////////////////////////////////////////////////// @@ -193,11 +191,11 @@ bool CPsyDogPhantom::net_Spawn(CSE_Abstract* dc) // load effector // Load psi postprocess -------------------------------------------------------- - load_effector(*cNameSect(), "appear_effector", m_appear_effector); + load_effector(cNameSect().c_str(), "appear_effector", m_appear_effector); // -------------------------------------------------------------------------------- - m_particles_appear = pSettings->r_string(*cNameSect(), "particles_appear"); - m_particles_disappear = pSettings->r_string(*cNameSect(), "particles_disappear"); + m_particles_appear = pSettings->r_string(cNameSect(), "particles_appear"); + m_particles_disappear = pSettings->r_string(cNameSect(), "particles_disappear"); m_time_spawned = time(); diff --git a/src/xrGame/ai/monsters/pseudodog/psy_dog.h b/src/xrGame/ai/monsters/pseudodog/psy_dog.h index 189b19e6000..3013a8d284a 100644 --- a/src/xrGame/ai/monsters/pseudodog/psy_dog.h +++ b/src/xrGame/ai/monsters/pseudodog/psy_dog.h @@ -56,6 +56,9 @@ class CPsyDog : public CAI_PseudoDog private: xr_vector m_storage; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CAI_PseudoDog); }; ////////////////////////////////////////////////////////////////////////// @@ -99,4 +102,7 @@ class CPsyDogPhantom : public CAI_PseudoDog void destroy_me(); void try_to_register_to_parent(); bool is_wait_to_destroy_object() { return (m_parent_id == 0xffff); } + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CAI_PseudoDog); }; diff --git a/src/xrGame/ai/monsters/pseudogigant/pseudo_gigant.cpp b/src/xrGame/ai/monsters/pseudogigant/pseudo_gigant.cpp index 9fd34082bb7..8af90a4cb43 100644 --- a/src/xrGame/ai/monsters/pseudogigant/pseudo_gigant.cpp +++ b/src/xrGame/ai/monsters/pseudogigant/pseudo_gigant.cpp @@ -35,8 +35,6 @@ void CPseudoGigant::Load(LPCSTR section) anim().AddReplacedAnim(&m_bDamaged, eAnimRun, eAnimRunDamaged); anim().AddReplacedAnim(&m_bDamaged, eAnimWalkFwd, eAnimWalkDamaged); - // anim().AddReplacedAnim(&m_bRunTurnLeft, eAnimRun, eAnimRunTurnLeft); - // anim().AddReplacedAnim(&m_bRunTurnRight, eAnimRun, eAnimRunTurnRight); anim().accel_load(section); // anim().accel_chain_add (eAnimWalkFwd, eAnimRun); @@ -51,102 +49,35 @@ void CPseudoGigant::Load(LPCSTR section) SVelocityParam& velocity_none = move().get_velocity(MonsterMovement::eVelocityParameterIdle); SVelocityParam& velocity_turn = move().get_velocity(MonsterMovement::eVelocityParameterStand); SVelocityParam& velocity_walk = move().get_velocity(MonsterMovement::eVelocityParameterWalkNormal); - SVelocityParam& velocity_run = move().get_velocity(MonsterMovement::eVelocityParameterRunNormal); + // SVelocityParam& velocity_run = move().get_velocity(MonsterMovement::eVelocityParameterRunNormal); SVelocityParam& velocity_walk_dmg = move().get_velocity(MonsterMovement::eVelocityParameterWalkDamaged); // SVelocityParam &velocity_run_dmg = move().get_velocity(MonsterMovement::eVelocityParameterRunDamaged); SVelocityParam& velocity_steal = move().get_velocity(MonsterMovement::eVelocityParameterSteal); - anim().AddAnim(eAnimStandIdle, "stand_idle_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimStandTurnLeft, "stand_turn_ls_", -1, &velocity_turn, PS_STAND, "fx_stand_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimStandTurnRight, "stand_turn_rs_", -1, &velocity_turn, PS_STAND, "fx_stand_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimLieIdle, "stand_sleep_", -1, &velocity_none, PS_LIE, "fx_stand_f", "fx_stand_b", "fx_stand_l", - "fx_stand_r"); - anim().AddAnim( - eAnimSitIdle, "sit_idle_", -1, &velocity_none, PS_SIT, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); - anim().AddAnim( - eAnimSleep, "stand_sleep_", -1, &velocity_none, PS_LIE, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimWalkFwd, "stand_walk_fwd_", -1, &velocity_walk, PS_STAND, "fx_stand_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimWalkDamaged, "stand_walk_fwd_dmg_", -1, &velocity_walk_dmg, PS_STAND, "fx_stand_f", - "fx_stand_b", "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimRun, "stand_walk_fwd_", -1, &velocity_walk, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", - "fx_stand_r"); - anim().AddAnim(eAnimRunDamaged, "stand_walk_fwd_dmg_", -1, &velocity_walk_dmg, PS_STAND, "fx_stand_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim( - eAnimEat, "stand_eat_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimAttack, "stand_attack_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", - "fx_stand_r"); - anim().AddAnim(eAnimLookAround, "stand_idle_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimSteal, "stand_steal_", -1, &velocity_steal, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", - "fx_stand_r"); - anim().AddAnim( - eAnimDie, "stand_idle_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimStandLieDown, "stand_lie_down_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimLieToSleep, "lie_to_sleep_", -1, &velocity_none, PS_LIE, "fx_stand_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - - // anim().AddAnim(eAnimStandIdle, "stand_idle_", -1, &velocity_none, PS_STAND, "fx_stand_f", - // "fx_stand_b", - // "fx_stand_l", "fx_stand_r"); - // anim().AddAnim(eAnimStandTurnLeft, "stand_turn_ls_", -1, &velocity_turn, PS_STAND, "fx_stand_f", - // "fx_stand_b", - // "fx_stand_l", "fx_stand_r"); - // anim().AddAnim(eAnimStandTurnRight, "stand_turn_rs_", -1, &velocity_turn, PS_STAND, "fx_stand_f", - // "fx_stand_b", - // "fx_stand_l", "fx_stand_r"); - // anim().AddAnim(eAnimLieIdle, "stand_sleep_", -1, &velocity_none, PS_LIE, "fx_stand_f", - // "fx_stand_b", - // "fx_stand_l", "fx_stand_r"); - // anim().AddAnim(eAnimSitIdle, "sit_idle_", -1, &velocity_none, PS_SIT, "fx_stand_f", - // "fx_stand_b", - // "fx_stand_l", "fx_stand_r"); - // anim().AddAnim(eAnimSleep, "stand_sleep_", -1, &velocity_none, PS_LIE, "fx_stand_f", - // "fx_stand_b", - // "fx_stand_l", "fx_stand_r"); - // anim().AddAnim(eAnimWalkFwd, "stand_walk_fwd_", -1, &velocity_walk, PS_STAND, "fx_stand_f", - // "fx_stand_b", - // "fx_stand_l", "fx_stand_r"); - // anim().AddAnim(eAnimWalkDamaged, "stand_walk_fwd_dmg_", -1, &velocity_walk_dmg, PS_STAND, "fx_stand_f", - // "fx_stand_b", "fx_stand_l", "fx_stand_r"); - // anim().AddAnim(eAnimRun, "stand_run_fwd_", -1, &velocity_run, PS_STAND, "fx_stand_f", - // "fx_stand_b", - // "fx_stand_l", "fx_stand_r"); - // anim().AddAnim(eAnimRunDamaged, "stand_run_dmg_", -1, &velocity_run_dmg, PS_STAND, "fx_stand_f", - // "fx_stand_b", - // "fx_stand_l", "fx_stand_r"); - // anim().AddAnim(eAnimEat, "stand_eat_", -1, &velocity_none, PS_STAND, "fx_stand_f", - // "fx_stand_b", - // "fx_stand_l", "fx_stand_r"); - // anim().AddAnim(eAnimAttack, "stand_attack_", -1, &velocity_turn, PS_STAND, "fx_stand_f", - // "fx_stand_b", - // "fx_stand_l", "fx_stand_r"); - // anim().AddAnim(eAnimLookAround, "stand_idle_", -1, &velocity_none, PS_STAND, "fx_stand_f", - // "fx_stand_b", - // "fx_stand_l", "fx_stand_r"); - // anim().AddAnim(eAnimSteal, "stand_steal_", -1, &velocity_steal, PS_STAND, "fx_stand_f", - // "fx_stand_b", - // "fx_stand_l", "fx_stand_r"); - // anim().AddAnim(eAnimDie, "stand_idle_", -1, &velocity_none, PS_STAND, "fx_stand_f", - // "fx_stand_b", - // "fx_stand_l", "fx_stand_r"); - // anim().AddAnim(eAnimStandLieDown, "stand_lie_down_", -1, &velocity_none, PS_STAND, "fx_stand_f", - // "fx_stand_b", - // "fx_stand_l", "fx_stand_r"); - // anim().AddAnim(eAnimLieToSleep, "lie_to_sleep_", -1, &velocity_none, PS_LIE, "fx_stand_f", - // "fx_stand_b", - // "fx_stand_l", "fx_stand_r"); - // anim().AddAnim(eAnimThreaten, "stand_kick_", -1, &velocity_none, PS_STAND, "fx_stand_f", - // "fx_stand_b", - // "fx_stand_l", "fx_stand_r"); - - anim().AddAnim(eAnimRunTurnLeft, { "stand_run_left_", true }, -1, &velocity_run, PS_STAND); - anim().AddAnim(eAnimRunTurnRight, { "stand_run_right_", true }, -1, &velocity_run, PS_STAND); + const SAnimItem::Effects fxs{ "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r" }; + + anim().AddAnim(eAnimStandIdle, "stand_idle_", -1, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimStandTurnLeft, "stand_turn_ls_", -1, &velocity_turn, PS_STAND, fxs); + anim().AddAnim(eAnimStandTurnRight, "stand_turn_rs_", -1, &velocity_turn, PS_STAND, fxs); + anim().AddAnim(eAnimLieIdle, "stand_sleep_", -1, &velocity_none, PS_LIE, fxs); + anim().AddAnim(eAnimSitIdle, "sit_idle_", -1, &velocity_none, PS_SIT, fxs); + anim().AddAnim(eAnimSleep, "stand_sleep_", -1, &velocity_none, PS_LIE, fxs); + anim().AddAnim(eAnimWalkFwd, "stand_walk_fwd_", -1, &velocity_walk, PS_STAND, fxs); + anim().AddAnim(eAnimWalkDamaged, "stand_walk_fwd_dmg_", -1, &velocity_walk_dmg, PS_STAND, fxs); + anim().AddAnim(eAnimRun, "stand_walk_fwd_", -1, &velocity_walk, PS_STAND, fxs); + anim().AddAnim(eAnimRunDamaged, "stand_walk_fwd_dmg_", -1, &velocity_walk_dmg, PS_STAND, fxs); + anim().AddAnim(eAnimEat, "stand_eat_", -1, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimAttack, "stand_attack_", -1, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimLookAround, "stand_idle_", -1, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimSteal, "stand_steal_", -1, &velocity_steal, PS_STAND, fxs); + anim().AddAnim(eAnimDie, "stand_idle_", -1, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimStandLieDown, "stand_lie_down_", -1, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimLieToSleep, "lie_to_sleep_", -1, &velocity_none, PS_LIE, fxs); + + // anim().AddAnim(eAnimRunTurnLeft, "stand_run_left_", -1, &velocity_run, PS_STAND, false); + // anim().AddAnim(eAnimRunTurnRight, "stand_run_right_", -1, &velocity_run, PS_STAND, false); + // anim().AddReplacedAnim(&m_bRunTurnLeft, eAnimRun, eAnimRunTurnLeft); + // anim().AddReplacedAnim(&m_bRunTurnRight, eAnimRun, eAnimRunTurnRight); anim().LinkAction(ACT_STAND_IDLE, eAnimStandIdle); anim().LinkAction(ACT_SIT_IDLE, eAnimSitIdle); @@ -219,8 +150,8 @@ void CPseudoGigant::reinit() m_time_next_threaten = 0; - move().load_velocity(*cNameSect(), "Velocity_JumpPrepare", MonsterMovement::eGiantVelocityParameterJumpPrepare); - move().load_velocity(*cNameSect(), "Velocity_JumpGround", MonsterMovement::eGiantVelocityParameterJumpGround); + move().load_velocity(cNameSect().c_str(), "Velocity_JumpPrepare", MonsterMovement::eGiantVelocityParameterJumpPrepare); + move().load_velocity(cNameSect().c_str(), "Velocity_JumpGround", MonsterMovement::eGiantVelocityParameterJumpGround); // com_man().load_jump_data(0,"jump_attack_0", "jump_attack_1", "jump_attack_2", // MonsterMovement::eGiantVelocityParameterJumpPrepare, MonsterMovement::eGiantVelocityParameterJumpGround,0); diff --git a/src/xrGame/ai/monsters/pseudogigant/pseudo_gigant.h b/src/xrGame/ai/monsters/pseudogigant/pseudo_gigant.h index e319ee1871b..a9624ef8a5b 100644 --- a/src/xrGame/ai/monsters/pseudogigant/pseudo_gigant.h +++ b/src/xrGame/ai/monsters/pseudogigant/pseudo_gigant.h @@ -56,4 +56,7 @@ class CPseudoGigant : public CBaseMonster, public CControlledEntity("CPseudoGigant") .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/ai/monsters/snork/snork.cpp b/src/xrGame/ai/monsters/snork/snork.cpp index 1f01ac903fc..868fbbc5e73 100644 --- a/src/xrGame/ai/monsters/snork/snork.cpp +++ b/src/xrGame/ai/monsters/snork/snork.cpp @@ -17,13 +17,6 @@ #include "ai/monsters/monster_cover_manager.h" #endif -#define STAND_FX_FRONT { "stand_fx_f", true } -#define STAND_FX_BACK { "stand_fx_b", true } -#define STAND_FX_LEFT { "stand_fx_l", true } -#define STAND_FX_RIGHT { "stand_fx_r", true } - -#define STAND_FX_ALL STAND_FX_FRONT, STAND_FX_BACK, STAND_FX_LEFT, STAND_FX_RIGHT - CSnork::CSnork() { StateMan = xr_new(this); @@ -41,8 +34,6 @@ void CSnork::Load(LPCSTR section) anim().AddReplacedAnim(&m_bDamaged, eAnimStandIdle, eAnimStandDamaged); anim().AddReplacedAnim(&m_bDamaged, eAnimRun, eAnimRunDamaged); anim().AddReplacedAnim(&m_bDamaged, eAnimWalkFwd, eAnimWalkDamaged); - anim().AddReplacedAnim(&m_bRunTurnLeft, eAnimRun, eAnimRunTurnLeft); - anim().AddReplacedAnim(&m_bRunTurnRight, eAnimRun, eAnimRunTurnRight); SVelocityParam& velocity_none = move().get_velocity(MonsterMovement::eVelocityParameterIdle); SVelocityParam& velocity_turn = move().get_velocity(MonsterMovement::eVelocityParameterStand); @@ -53,23 +44,34 @@ void CSnork::Load(LPCSTR section) SVelocityParam& velocity_steal = move().get_velocity(MonsterMovement::eVelocityParameterSteal); // SVelocityParam &velocity_drag = move().get_velocity(MonsterMovement::eVelocityParameterDrag); - anim().AddAnim(eAnimStandIdle, "stand_idle_", -1, &velocity_none, PS_STAND, STAND_FX_ALL); - anim().AddAnim(eAnimStandDamaged, "stand_idle_damaged_", -1, &velocity_none, PS_STAND, STAND_FX_ALL); - anim().AddAnim(eAnimWalkDamaged, "stand_walk_damaged_", -1, &velocity_walk_dmg, PS_STAND, STAND_FX_ALL); - anim().AddAnim(eAnimRunDamaged, "stand_run_damaged_", -1, &velocity_run_dmg, PS_STAND, STAND_FX_ALL); - anim().AddAnim(eAnimStandTurnLeft, "stand_turn_ls_", -1, &velocity_turn, PS_STAND, STAND_FX_ALL); - anim().AddAnim(eAnimStandTurnRight, "stand_turn_rs_", -1, &velocity_turn, PS_STAND, STAND_FX_ALL); - anim().AddAnim(eAnimWalkFwd, "stand_walk_fwd_", -1, &velocity_walk, PS_STAND, STAND_FX_ALL); - anim().AddAnim(eAnimRun, "stand_run_", -1, &velocity_run, PS_STAND, STAND_FX_ALL); - anim().AddAnim(eAnimAttack, "stand_attack_", -1, &velocity_turn, PS_STAND, STAND_FX_ALL); - anim().AddAnim(eAnimDie, "stand_die_", 0, &velocity_none, PS_STAND, STAND_FX_ALL); - anim().AddAnim(eAnimLookAround, "stand_look_around_", -1, &velocity_none, PS_STAND, STAND_FX_ALL); - anim().AddAnim(eAnimSteal, "stand_steal_", -1, &velocity_steal, PS_STAND, STAND_FX_ALL); - anim().AddAnim(eAnimEat, "stand_eat_", -1, &velocity_none, PS_STAND, STAND_FX_ALL); - anim().AddAnim(eAnimCheckCorpse, "stand_check_corpse_", -1, &velocity_none, PS_STAND, STAND_FX_ALL); - - anim().AddAnim(eAnimRunTurnLeft, { "stand_run_look_left_", true }, -1, &velocity_run, PS_STAND, STAND_FX_ALL); - anim().AddAnim(eAnimRunTurnRight, { "stand_run_look_right_", true }, -1, &velocity_run, PS_STAND, STAND_FX_ALL); + const SAnimItem::Effects fxs{ "stand_fx_f", "stand_fx_b", "stand_fx_l", "stand_fx_r" }; + + anim().AddAnim(eAnimStandIdle, "stand_idle_", -1, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimStandDamaged, "stand_idle_damaged_", -1, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimWalkDamaged, "stand_walk_damaged_", -1, &velocity_walk_dmg, PS_STAND, fxs); + anim().AddAnim(eAnimRunDamaged, "stand_run_damaged_", -1, &velocity_run_dmg, PS_STAND, fxs); + anim().AddAnim(eAnimStandTurnLeft, "stand_turn_ls_", -1, &velocity_turn, PS_STAND, fxs); + anim().AddAnim(eAnimStandTurnRight, "stand_turn_rs_", -1, &velocity_turn, PS_STAND, fxs); + anim().AddAnim(eAnimWalkFwd, "stand_walk_fwd_", -1, &velocity_walk, PS_STAND, fxs); + anim().AddAnim(eAnimRun, "stand_run_", -1, &velocity_run, PS_STAND, fxs); + anim().AddAnim(eAnimAttack, "stand_attack_", -1, &velocity_turn, PS_STAND, fxs); + anim().AddAnim(eAnimDie, "stand_die_", 0, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimLookAround, "stand_look_around_", -1, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimSteal, "stand_steal_", -1, &velocity_steal, PS_STAND, fxs); + anim().AddAnim(eAnimEat, "stand_eat_", -1, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimCheckCorpse, "stand_check_corpse_", -1, &velocity_none, PS_STAND, fxs); + + if (anim().AddAnim(eAnimRunTurnLeft, "stand_run_look_left_", -1, &velocity_run, PS_STAND, fxs, false) || + anim().AddAnim(eAnimRunTurnLeft, "run_look_left_", -1, &velocity_run, PS_STAND, fxs, false)) + { + anim().AddReplacedAnim(&m_bRunTurnLeft, eAnimRun, eAnimRunTurnLeft); + } + + if (anim().AddAnim(eAnimRunTurnRight, "stand_run_look_right_", -1, &velocity_run, PS_STAND, fxs, false) || + anim().AddAnim(eAnimRunTurnRight, "run_look_right_", -1, &velocity_run, PS_STAND, fxs, false)) + { + anim().AddReplacedAnim(&m_bRunTurnRight, eAnimRun, eAnimRunTurnRight); + } anim().LinkAction(ACT_STAND_IDLE, eAnimStandIdle); anim().LinkAction(ACT_SIT_IDLE, eAnimStandIdle); @@ -96,7 +98,7 @@ void CSnork::reinit() { inherited::reinit(); - move().load_velocity(*cNameSect(), "Velocity_JumpGround", MonsterMovement::eSnorkVelocityParameterJumpGround); + move().load_velocity(cNameSect().c_str(), "Velocity_JumpGround", MonsterMovement::eSnorkVelocityParameterJumpGround); com_man().load_jump_data("stand_attack_2_0", 0, "stand_attack_2_1", "stand_somersault_0", u32(-1), MonsterMovement::eSnorkVelocityParameterJumpGround, 0); @@ -275,10 +277,11 @@ bool CSnork::check_start_conditions(ControlCom::EControlType type) if (type == ControlCom::eControlThreaten) { - return false; - // if (!start_threaten) return false; - // start_threaten = false; - // if (Random.randI(100) < 50) return false; + if (!start_threaten) + return false; + start_threaten = false; + if (Random.randI(100) < 50) + return false; } return true; diff --git a/src/xrGame/ai/monsters/snork/snork.h b/src/xrGame/ai/monsters/snork/snork.h index b72e93457d2..b9cd4b80312 100644 --- a/src/xrGame/ai/monsters/snork/snork.h +++ b/src/xrGame/ai/monsters/snork/snork.h @@ -39,4 +39,7 @@ class CSnork : public CBaseMonster public: u32 m_target_node; bool start_threaten; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; diff --git a/src/xrGame/ai/monsters/snork/snork_script.cpp b/src/xrGame/ai/monsters/snork/snork_script.cpp index 10001a18c04..8713948cf11 100644 --- a/src/xrGame/ai/monsters/snork/snork_script.cpp +++ b/src/xrGame/ai/monsters/snork/snork_script.cpp @@ -1,8 +1,8 @@ #include "pch_script.h" + #include "snork.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CSnork, (CGameObject), +void CSnork::script_register(lua_State* luaState) { using namespace luabind; @@ -11,4 +11,4 @@ SCRIPT_EXPORT(CSnork, (CGameObject), class_("CSnork") .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/ai/monsters/states/monster_state_attack.h b/src/xrGame/ai/monsters/states/monster_state_attack.h index 690d71097ef..6795da0eac9 100644 --- a/src/xrGame/ai/monsters/states/monster_state_attack.h +++ b/src/xrGame/ai/monsters/states/monster_state_attack.h @@ -17,7 +17,6 @@ class CStateMonsterAttack : public CState<_Object> public: CStateMonsterAttack(_Object* obj); - CStateMonsterAttack(_Object* obj, state_ptr state_move2home); CStateMonsterAttack(_Object* obj, state_ptr state_run, state_ptr state_melee); virtual ~CStateMonsterAttack(); diff --git a/src/xrGame/ai/monsters/states/monster_state_attack_inline.h b/src/xrGame/ai/monsters/states/monster_state_attack_inline.h index 6d8d6d672a0..e3a12272815 100644 --- a/src/xrGame/ai/monsters/states/monster_state_attack_inline.h +++ b/src/xrGame/ai/monsters/states/monster_state_attack_inline.h @@ -33,21 +33,6 @@ CStateMonsterAttackAbstract::CStateMonsterAttack(_Object* obj) : inherited(obj) this->add_state(eStateAttack_MoveToHomePoint, xr_new>(obj)); } -// Lain: added -TEMPLATE_SPECIALIZATION -CStateMonsterAttackAbstract::CStateMonsterAttack(_Object* obj, state_ptr state_move2home) : inherited(obj) -{ - this->add_state(eStateAttack_Run, xr_new>(obj)); - this->add_state(eStateAttack_Melee, xr_new>(obj)); - this->add_state(eStateAttack_RunAttack, xr_new>(obj)); - this->add_state(eStateAttack_Attack_On_Run, xr_new>(obj)); - this->add_state(eStateAttack_RunAway, xr_new>(obj)); - this->add_state(eStateAttack_FindEnemy, xr_new>(obj)); - this->add_state(eStateAttack_Steal, xr_new>(obj)); - this->add_state(eStateAttackCamp, xr_new>(obj)); - this->add_state(eStateAttack_MoveToHomePoint, state_move2home); -} - TEMPLATE_SPECIALIZATION CStateMonsterAttackAbstract::CStateMonsterAttack(_Object* obj, state_ptr state_run, state_ptr state_melee) : inherited(obj) diff --git a/src/xrGame/ai/monsters/states/state_data.h b/src/xrGame/ai/monsters/states/state_data.h index eaacab1df92..7f6b2960ef9 100644 --- a/src/xrGame/ai/monsters/states/state_data.h +++ b/src/xrGame/ai/monsters/states/state_data.h @@ -5,20 +5,11 @@ ////////////////////////////////////////////////////////////////////////// struct SStateDataAction { - EAction action; - u32 spec_params; - u32 time_out; - u32 sound_type; - u32 sound_delay; - - SStateDataAction() - { - action = ACT_STAND_IDLE; - spec_params = 0; - time_out = 0; - sound_type = u32(-1); - sound_delay = u32(-1); - } + EAction action{ ACT_STAND_IDLE }; + u32 spec_params{}; + u32 time_out{}; + u32 sound_type{ u32(-1) }; + u32 sound_delay{ u32(-1) }; }; ////////////////////////////////////////////////////////////////////////// @@ -26,26 +17,17 @@ struct SStateDataAction ////////////////////////////////////////////////////////////////////////// struct SStateDataMoveToPoint { - Fvector point; - u32 vertex; - Fvector target_direction; - - bool accelerated; - bool braking; - u8 accel_type; - - float completion_dist; - - SStateDataAction action; - - SStateDataMoveToPoint(): braking(false), accel_type(0) - { - point.set(0.f, 0.f, 0.f); - target_direction.set(0.f, 0.f, 0.f); - vertex = u32(-1); - accelerated = false; - completion_dist = 0.f; - } + Fvector point{}; + u32 vertex{ u32(-1) }; + Fvector target_direction{}; + + bool accelerated{}; + bool braking{}; + u8 accel_type{}; + + float completion_dist{}; + + SStateDataAction action{}; }; ////////////////////////////////////////////////////////////////////////// @@ -53,9 +35,7 @@ struct SStateDataMoveToPoint ////////////////////////////////////////////////////////////////////////// struct SStateDataMoveToPointEx : public SStateDataMoveToPoint { - u32 time_to_rebuild; // u32(-1) - не переÑтраивать, 0-по-умолчанию, ... - - SStateDataMoveToPointEx() { time_to_rebuild = u32(-1); } + u32 time_to_rebuild{ u32(-1) }; // u32(-1) - не переÑтраивать, 0-по-умолчанию, ... }; ////////////////////////////////////////////////////////////////////////// @@ -63,32 +43,19 @@ struct SStateDataMoveToPointEx : public SStateDataMoveToPoint ////////////////////////////////////////////////////////////////////////// struct SStateHideFromPoint { - Fvector point; - - bool accelerated; - bool braking; - u8 accel_type; + Fvector point{}; - float distance; + bool accelerated{}; + bool braking{}; + u8 accel_type{}; - float cover_min_dist; - float cover_max_dist; - float cover_search_radius; + float distance{ 1.0f }; - SStateDataAction action; + float cover_min_dist{ 10.f }; + float cover_max_dist{ 30.f }; + float cover_search_radius{ 20.f }; - SStateHideFromPoint(): braking(false), accel_type(0) - { - point.set(0.f, 0.f, 0.f); - - accelerated = false; - - distance = 1.f; - - cover_min_dist = 10.f; - cover_max_dist = 30.f; - cover_search_radius = 20.f; - } + SStateDataAction action{}; }; ////////////////////////////////////////////////////////////////////////// @@ -96,15 +63,9 @@ struct SStateHideFromPoint ////////////////////////////////////////////////////////////////////////// struct SStateDataLookToPoint { - Fvector point; - u32 face_delay; - SStateDataAction action; - - SStateDataLookToPoint() - { - point.set(0.f, 0.f, 0.f); - face_delay = 0; - } + Fvector point{}; + u32 face_delay{}; + SStateDataAction action{}; }; ////////////////////////////////////////////////////////////////////////// @@ -112,24 +73,16 @@ struct SStateDataLookToPoint ////////////////////////////////////////////////////////////////////////// struct SStateDataMoveAroundPoint { - Fvector point; - u32 vertex; + Fvector point{}; + u32 vertex{ u32(-1) }; - float radius; + float radius{ 10.f }; - bool accelerated; - bool braking; - u8 accel_type; + bool accelerated{}; + bool braking{}; + u8 accel_type{}; - SStateDataAction action; - - SStateDataMoveAroundPoint(): braking(false), accel_type(0) - { - point.set(0.f, 0.f, 0.f); - vertex = u32(-1); - accelerated = false; - radius = 10.f; - } + SStateDataAction action{}; }; ////////////////////////////////////////////////////////////////////////// @@ -137,7 +90,5 @@ struct SStateDataMoveAroundPoint ////////////////////////////////////////////////////////////////////////// struct SStateDataActionLook : public SStateDataAction { - Fvector point; - - SStateDataActionLook() { point.set(0.f, 0.f, 0.f); } + Fvector point{}; }; diff --git a/src/xrGame/ai/monsters/tushkano/tushkano.h b/src/xrGame/ai/monsters/tushkano/tushkano.h index 359a2b64adf..10e8678222c 100644 --- a/src/xrGame/ai/monsters/tushkano/tushkano.h +++ b/src/xrGame/ai/monsters/tushkano/tushkano.h @@ -14,4 +14,7 @@ class CTushkano : public CBaseMonster, public CControlledEntity virtual void Load(LPCSTR section); virtual void CheckSpecParams(u32 spec_params); pcstr get_monster_class_name() override { return "tushkano"; } + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; diff --git a/src/xrGame/ai/monsters/tushkano/tushkano_script.cpp b/src/xrGame/ai/monsters/tushkano/tushkano_script.cpp index 5e835f8b3f6..0e659895215 100644 --- a/src/xrGame/ai/monsters/tushkano/tushkano_script.cpp +++ b/src/xrGame/ai/monsters/tushkano/tushkano_script.cpp @@ -1,8 +1,8 @@ #include "pch_script.h" + #include "tushkano.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CTushkano, (CGameObject), +void CTushkano::script_register(lua_State* luaState) { using namespace luabind; @@ -11,4 +11,4 @@ SCRIPT_EXPORT(CTushkano, (CGameObject), class_("CTushkano") .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/ai/monsters/zombie/zombie.cpp b/src/xrGame/ai/monsters/zombie/zombie.cpp index 0219667dcb0..3e620ecab9e 100644 --- a/src/xrGame/ai/monsters/zombie/zombie.cpp +++ b/src/xrGame/ai/monsters/zombie/zombie.cpp @@ -36,20 +36,15 @@ void CZombie::Load(LPCSTR section) // SVelocityParam &velocity_steal = move().get_velocity(MonsterMovement::eVelocityParameterSteal); // SVelocityParam &velocity_drag = move().get_velocity(MonsterMovement::eVelocityParameterDrag); - anim().AddAnim(eAnimStandIdle, "stand_idle_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimStandTurnLeft, "stand_turn_ls_", -1, &velocity_turn, PS_STAND, "fx_stand_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimStandTurnRight, "stand_turn_rs_", -1, &velocity_turn, PS_STAND, "fx_stand_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimWalkFwd, "stand_walk_fwd_", -1, &velocity_walk, PS_STAND, "fx_stand_f", "fx_stand_b", - "fx_stand_l", "fx_stand_r"); - anim().AddAnim( - eAnimRun, "stand_run_", -1, &velocity_run, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); - anim().AddAnim(eAnimAttack, "stand_attack_", -1, &velocity_turn, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", - "fx_stand_r"); - anim().AddAnim( - eAnimDie, "stand_die_", 0, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); + const SAnimItem::Effects fxs{ "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r" }; + + anim().AddAnim(eAnimStandIdle, "stand_idle_", -1, &velocity_none, PS_STAND, fxs); + anim().AddAnim(eAnimStandTurnLeft, "stand_turn_ls_", -1, &velocity_turn, PS_STAND, fxs); + anim().AddAnim(eAnimStandTurnRight, "stand_turn_rs_", -1, &velocity_turn, PS_STAND, fxs); + anim().AddAnim(eAnimWalkFwd, "stand_walk_fwd_", -1, &velocity_walk, PS_STAND, fxs); + anim().AddAnim(eAnimRun, "stand_run_", -1, &velocity_run, PS_STAND, fxs); + anim().AddAnim(eAnimAttack, "stand_attack_", -1, &velocity_turn, PS_STAND, fxs); + anim().AddAnim(eAnimDie, "stand_die_", 0, &velocity_none, PS_STAND, fxs); anim().LinkAction(ACT_STAND_IDLE, eAnimStandIdle); anim().LinkAction(ACT_SIT_IDLE, eAnimStandIdle); diff --git a/src/xrGame/ai/monsters/zombie/zombie.h b/src/xrGame/ai/monsters/zombie/zombie.h index 7f2db923282..24c556ccd2c 100644 --- a/src/xrGame/ai/monsters/zombie/zombie.h +++ b/src/xrGame/ai/monsters/zombie/zombie.h @@ -52,4 +52,7 @@ class CZombie : public CBaseMonster, public CControlledEntity #ifdef _DEBUG virtual void debug_on_key(int key); #endif + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; diff --git a/src/xrGame/ai/monsters/zombie/zombie_script.cpp b/src/xrGame/ai/monsters/zombie/zombie_script.cpp index 5a0dc98712b..d6f0bbbd9b5 100644 --- a/src/xrGame/ai/monsters/zombie/zombie_script.cpp +++ b/src/xrGame/ai/monsters/zombie/zombie_script.cpp @@ -1,8 +1,8 @@ #include "pch_script.h" + #include "zombie.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CZombie, (CGameObject), +void CZombie::script_register(lua_State* luaState) { using namespace luabind; @@ -11,4 +11,4 @@ SCRIPT_EXPORT(CZombie, (CGameObject), class_("CZombie") .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/ai/stalker/ai_stalker.h b/src/xrGame/ai/stalker/ai_stalker.h index 501f2587152..1813769bb16 100644 --- a/src/xrGame/ai/stalker/ai_stalker.h +++ b/src/xrGame/ai/stalker/ai_stalker.h @@ -811,6 +811,8 @@ class CAI_Stalker : public CCustomMonster, public CObjectHandler, public CAI_Phr private: ignored_touched_objects_type m_ignored_touched_objects; + + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject, CScriptActionPlannerExport); }; #include "ai_stalker_inline.h" diff --git a/src/xrGame/ai/stalker/ai_stalker_fire.cpp b/src/xrGame/ai/stalker/ai_stalker_fire.cpp index 0d3778f7ae7..5d312481953 100644 --- a/src/xrGame/ai/stalker/ai_stalker_fire.cpp +++ b/src/xrGame/ai/stalker/ai_stalker_fire.cpp @@ -242,51 +242,63 @@ void CAI_Stalker::Hit(SHit* pHDS) if (m_boneHitProtection && HDS.hit_type == ALife::eHitTypeFireWound) { - float BoneArmor = m_boneHitProtection->getBoneArmor(HDS.bone()); - float ap = HDS.armor_piercing; + const float BoneArmor = m_boneHitProtection->getBoneArmor(HDS.bone()); - if (ShadowOfChernobylMode || ClearSkyMode) + if (wounded()) // уже лежит => добивание { - if (ap > EPS && ap > BoneArmor) + hit_power = 1000.f; + } + else if (m_boneHitProtection->m_hitFracType == SBoneProtections::HitFractionNPC) // COP + { + if (!fis_zero(BoneArmor, EPS)) { - const float d_ap = ap - BoneArmor; - hit_power *= (d_ap / ap); + const float ap = HDS.armor_piercing; - if (hit_power < m_boneHitProtection->m_fHitFracNpc) + if (ap > BoneArmor) { - hit_power = m_boneHitProtection->m_fHitFracNpc; + float d_hit_power = (ap - BoneArmor) / ap; + if (d_hit_power < m_boneHitProtection->m_fHitFrac) + d_hit_power = m_boneHitProtection->m_fHitFrac; + + hit_power *= d_hit_power; + VERIFY(hit_power >= 0.0f); } - if (hit_power < 0.0f) { - hit_power = 0.0f; + else + { + hit_power *= m_boneHitProtection->m_fHitFrac; + HDS.add_wound = false; } } - else - { - hit_power *= m_boneHitProtection->m_fHitFracNpc; - HDS.add_wound = false; - } } - else if (!fis_zero(BoneArmor, EPS)) + else if (GMLib.GetLibraryVersion() >= GAMEMTL_VERSION_CS) { - if (ap > BoneArmor) + const float ap = HDS.armor_piercing; + + if (ap > EPS && ap > BoneArmor) { - float d_hit_power = (ap - BoneArmor) / ap; - if (d_hit_power < m_boneHitProtection->m_fHitFracNpc) - d_hit_power = m_boneHitProtection->m_fHitFracNpc; + const float d_ap = ap - BoneArmor; + hit_power *= (d_ap / ap); - hit_power *= d_hit_power; - VERIFY(hit_power >= 0.0f); + if (hit_power < m_boneHitProtection->m_fHitFrac) + hit_power = m_boneHitProtection->m_fHitFrac; + + if (hit_power < 0.0f) + hit_power = 0.0f; } else { - hit_power *= m_boneHitProtection->m_fHitFracNpc; + hit_power *= m_boneHitProtection->m_fHitFrac; HDS.add_wound = false; } } - - if (wounded()) //уже лежит => добивание + else if (GMLib.GetLibraryVersion() == GAMEMTL_VERSION_SOC) { - hit_power = 1000.f; + const float NewHitPower = HDS.damage() - BoneArmor; + + if (NewHitPower < HDS.power * m_boneHitProtection->m_fHitFrac) + hit_power = HDS.power * m_boneHitProtection->m_fHitFrac; + else + hit_power = NewHitPower; } } HDS.power = hit_power; diff --git a/src/xrGame/ai/stalker/ai_stalker_script.cpp b/src/xrGame/ai/stalker/ai_stalker_script.cpp index f31559dad08..6f955222a69 100644 --- a/src/xrGame/ai/stalker/ai_stalker_script.cpp +++ b/src/xrGame/ai/stalker/ai_stalker_script.cpp @@ -7,14 +7,14 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "ai_stalker.h" #include "stalker_decision_space.h" #include "ai_stalker_space.h" #include "script_game_object.h" #include "stalker_planner.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CStalkerPlanner, (CScriptActionPlanner), +void CAI_Stalker::script_register(lua_State* luaState) { using namespace luabind; @@ -164,17 +164,9 @@ SCRIPT_EXPORT(CStalkerPlanner, (CScriptActionPlanner), value("sound_enemy_killed_or_wounded", StalkerSpace::eStalkerSoundMaskEnemyKilledOrWounded), value("sound_script", StalkerSpace::eStalkerSoundScript) - ] - ]; -}); - -SCRIPT_EXPORT(CAI_Stalker, (CGameObject), -{ - using namespace luabind; + ], - module(luaState) - [ class_("CAI_Stalker") .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/ai/stalker/ai_stalker_script_entity.cpp b/src/xrGame/ai/stalker/ai_stalker_script_entity.cpp index 4e8ee136c23..a53fc682dd9 100644 --- a/src/xrGame/ai/stalker/ai_stalker_script_entity.cpp +++ b/src/xrGame/ai/stalker/ai_stalker_script_entity.cpp @@ -296,7 +296,7 @@ bool CAI_Stalker::bfAssignObject(CScriptEntityAction* tpEntityAction) } case eObjectActionTake: { - if (inventory().GetItemFromInventory(*l_tObjectAction.m_tpObject->cName())) + if (inventory().GetItemFromInventory(l_tObjectAction.m_tpObject->cName().c_str())) { GEnv.ScriptEngine->script_log(LuaMessageType::Error, "item is already in the inventory!"); return ((l_tObjectAction.m_bCompleted = true) == false); @@ -307,7 +307,7 @@ bool CAI_Stalker::bfAssignObject(CScriptEntityAction* tpEntityAction) } case eObjectActionDrop: { - if (!inventory().GetItemFromInventory(*l_tObjectAction.m_tpObject->cName())) + if (!inventory().GetItemFromInventory(l_tObjectAction.m_tpObject->cName().c_str())) { GEnv.ScriptEngine->script_log(LuaMessageType::Error, "item is not in the inventory!"); return ((l_tObjectAction.m_bCompleted = true) == false); diff --git a/src/xrGame/ai/trader/ai_trader.h b/src/xrGame/ai/trader/ai_trader.h index b551202d925..b427e13ed99 100644 --- a/src/xrGame/ai/trader/ai_trader.h +++ b/src/xrGame/ai/trader/ai_trader.h @@ -129,4 +129,7 @@ class CAI_Trader : public CEntityAlive, public CInventoryOwner, public CScriptEn public: CTraderAnimation& animation() { return (*AnimMan); } + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; diff --git a/src/xrGame/ai/trader/ai_trader_script.cpp b/src/xrGame/ai/trader/ai_trader_script.cpp index 17141668328..988840f47cc 100644 --- a/src/xrGame/ai/trader/ai_trader_script.cpp +++ b/src/xrGame/ai/trader/ai_trader_script.cpp @@ -1,8 +1,7 @@ #include "pch_script.h" #include "ai_trader.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CAI_Trader, (CGameObject), +void CAI_Trader::script_register(lua_State* luaState) { using namespace luabind; @@ -11,4 +10,4 @@ SCRIPT_EXPORT(CAI_Trader, (CGameObject), class_("CAI_Trader") .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/ai_crow_script.cpp b/src/xrGame/ai_crow_script.cpp index 1e1e92d6769..f7366fec4f7 100644 --- a/src/xrGame/ai_crow_script.cpp +++ b/src/xrGame/ai_crow_script.cpp @@ -7,10 +7,10 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "ai/crow/ai_crow.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CAI_Crow, (CGameObject), +void CAI_Crow::script_register(lua_State* luaState) { using namespace luabind; @@ -19,4 +19,4 @@ SCRIPT_EXPORT(CAI_Crow, (CGameObject), class_("CAI_Crow") .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/ai_space.cpp b/src/xrGame/ai_space.cpp index 74dfe403e9e..0390237ea1f 100644 --- a/src/xrGame/ai_space.cpp +++ b/src/xrGame/ai_space.cpp @@ -88,11 +88,11 @@ void CAI_Space::RegisterScriptClasses() } shared_str registrators = READ_IF_EXISTS(l_tpIniFile, r_string, "common", "class_registrators", ""); xr_delete(l_tpIniFile); - u32 registratorCount = _GetItemCount(*registrators); + u32 registratorCount = _GetItemCount(registrators.c_str()); string256 I; for (u32 i = 0; i < registratorCount; i++) { - _GetItem(*registrators, i, I); + _GetItem(registrators.c_str(), i, I); luabind::functor result; if (!GEnv.ScriptEngine->functor(I, result)) { @@ -123,11 +123,11 @@ void CAI_Space::LoadCommonScripts() if (l_tpIniFile->line_exist("common", "script")) { shared_str scriptString = l_tpIniFile->r_string("common", "script"); - u32 scriptCount = _GetItemCount(*scriptString); + u32 scriptCount = _GetItemCount(scriptString.c_str()); string256 scriptName; for (u32 i = 0; i < scriptCount; i++) { - _GetItem(*scriptString, i, scriptName); + _GetItem(scriptString.c_str(), i, scriptName); GEnv.ScriptEngine->load_file(scriptName, CScriptEngine::GlobalNamespace); } } @@ -139,11 +139,14 @@ void CAI_Space::SetupScriptEngine() { ZoneScoped; - XRay::ScriptExporter::Reset(); // mark all nodes as undone - GEnv.ScriptEngine->init(XRay::ScriptExporter::Export, true); + GEnv.ScriptEngine->init(xray::script_export::node::export_all, true); RegisterScriptClasses(); object_factory().register_script(); LoadCommonScripts(); + +#ifndef MASTER_GOLD + g_object_factory->init_spawn_data(); +#endif } void CAI_Space::RestartScriptEngine() diff --git a/src/xrGame/ai_space.h b/src/xrGame/ai_space.h index ab626bfe09e..93cde4518a6 100644 --- a/src/xrGame/ai_space.h +++ b/src/xrGame/ai_space.h @@ -8,10 +8,10 @@ #pragma once -#include "xrAICore/AISpaceBase.hpp" #include "xrCommon/xr_array.h" #include "xrCommon/xr_smart_pointers.h" #include "xrCore/Events/Notifier.h" +#include "xrAICore/AISpaceBase.hpp" class CGameGraph; class CGameLevelCrossTable; diff --git a/src/xrGame/alife_anomalous_zone.cpp b/src/xrGame/alife_anomalous_zone.cpp index 911191ffa5a..caaed8ba93c 100644 --- a/src/xrGame/alife_anomalous_zone.cpp +++ b/src/xrGame/alife_anomalous_zone.cpp @@ -113,8 +113,8 @@ void CSE_ALifeAnomalousZone::spawn_artefacts() } if (p < n) { - CSE_Abstract* l_tpSE_Abstract = alife().spawn_item(*weights[p].first, position(), m_tNodeID, m_tGraphID, 0xffff); - R_ASSERT3(l_tpSE_Abstract, "Can't spawn artefact ", *weights[p].first); + CSE_Abstract* l_tpSE_Abstract = alife().spawn_item(weights[p].first.c_str(), position(), m_tNodeID, m_tGraphID, 0xffff); + R_ASSERT3(l_tpSE_Abstract, "Can't spawn artefact ", weights[p].first.c_str()); CSE_ALifeDynamicObject* object = smart_cast(l_tpSE_Abstract); R_ASSERT2(object, "Non-ALife object in the 'game.spawn'"); diff --git a/src/xrGame/alife_graph_registry.cpp b/src/xrGame/alife_graph_registry.cpp index c16986cdc4b..9cd9c4f4e74 100644 --- a/src/xrGame/alife_graph_registry.cpp +++ b/src/xrGame/alife_graph_registry.cpp @@ -92,9 +92,9 @@ void CALifeGraphRegistry::setup_current_level() ai().game_graph().header().levels().find(ai().game_graph().vertex(actor()->m_tGraphID)->level_id()); R_ASSERT2(ai().game_graph().header().levels().end() != I, "Graph point level ID not found!"); - [[maybe_unused]] const int id = g_pGamePersistent->Level_ID(*(*I).second.name(), "1.0", true); - VERIFY3(id >= 0, "Level is corrupted or doesn't exist", *(*I).second.name()); - ai().load(*(*I).second.name()); + [[maybe_unused]] const int id = g_pGamePersistent->Level_ID(I->second.name().c_str(), "1.0", true); + VERIFY3(id >= 0, "Level is corrupted or doesn't exist", I->second.name().c_str()); + ai().load(I->second.name().c_str()); g_start_game_vertex_id = 0; } @@ -158,7 +158,7 @@ void CALifeGraphRegistry::detach(CSE_Abstract& object, CSE_ALifeInventoryItem* i { Msg("! ERROR: can't detach independant object. entity[%s:%d], parent[%s:%d], section[%s]", item->base()->name_replace(), item->base()->ID, object.name_replace(), object.ID, - *item->base()->s_name); + item->base()->s_name.c_str()); } #endif // DEBUG // R_ASSERT2 (value,"Can't detach an item which is not on my own"); diff --git a/src/xrGame/alife_graph_registry_inline.h b/src/xrGame/alife_graph_registry_inline.h index b43e9dbcc99..83675517bb6 100644 --- a/src/xrGame/alife_graph_registry_inline.h +++ b/src/xrGame/alife_graph_registry_inline.h @@ -17,8 +17,8 @@ IC CALifeLevelRegistry& CALifeGraphRegistry::level() const IC void CALifeGraphRegistry::change( CSE_ALifeDynamicObject* object, GameGraph::_GRAPH_ID tGraphPointID, GameGraph::_GRAPH_ID tNextGraphPointID) { - VERIFY3(object->used_ai_locations() /** && (object->interactive() || object->m_bOnline)**/, *object->s_name, - object->name_replace()); + VERIFY3(object->used_ai_locations() /** && (object->interactive() || object->m_bOnline)**/, + object->s_name.c_str(), object->name_replace()); remove(object, tGraphPointID); add(object, tNextGraphPointID); object->m_tGraphID = tNextGraphPointID; diff --git a/src/xrGame/alife_human_brain_script.cpp b/src/xrGame/alife_human_brain_script.cpp index 2e334abe23e..b86db541bc4 100644 --- a/src/xrGame/alife_human_brain_script.cpp +++ b/src/xrGame/alife_human_brain_script.cpp @@ -7,10 +7,10 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "alife_human_brain.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CALifeHumanBrain, (CALifeMonsterBrain), +void CALifeHumanBrain::script_register(lua_State* luaState) { using namespace luabind; @@ -18,4 +18,4 @@ SCRIPT_EXPORT(CALifeHumanBrain, (CALifeMonsterBrain), [ class_("CALifeHumanBrain") ]; -}); +} diff --git a/src/xrGame/alife_level_registry.h b/src/xrGame/alife_level_registry.h index 99613c98f09..c9a99a9c67d 100644 --- a/src/xrGame/alife_level_registry.h +++ b/src/xrGame/alife_level_registry.h @@ -8,11 +8,11 @@ #pragma once -#include "safe_map_iterator.h" -#include "xrServer_Objects_ALife.h" #include "xrAICore/Navigation/game_graph.h" -#include "xrScriptEngine/DebugMacros.hpp" // XXX: move debug macros to xrCore + #include "ai_debug.h" +#include "safe_map_iterator.h" +#include "xrServer_Objects_ALife.h" //#define FULL_LEVEL_UPDATE diff --git a/src/xrGame/alife_monster_brain_script.cpp b/src/xrGame/alife_monster_brain_script.cpp index e8ebdd0bb76..a135574f5fd 100644 --- a/src/xrGame/alife_monster_brain_script.cpp +++ b/src/xrGame/alife_monster_brain_script.cpp @@ -7,21 +7,25 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "alife_monster_brain.h" #include "alife_monster_movement_manager.h" -#include "xrScriptEngine/ScriptExporter.hpp" - -CALifeMonsterMovementManager* get_movement(const CALifeMonsterBrain* brain) { return (&brain->movement()); } -SCRIPT_EXPORT(CALifeMonsterBrain, (), +void CALifeMonsterBrain::script_register(lua_State* luaState) { using namespace luabind; module(luaState) [ class_("CALifeMonsterBrain") - .def("movement", &get_movement) - .def("update", &CALifeMonsterBrain::update_script) + .def("movement", +[](const CALifeMonsterBrain* brain) + { + return &brain->movement(); + }) + .def("update", +[](CALifeMonsterBrain* self) + { + self->update(true); + }) .def("can_choose_alife_tasks", (void (CALifeMonsterBrain::*)(bool)) & CALifeMonsterBrain::can_choose_alife_tasks) ]; -}); +} diff --git a/src/xrGame/alife_monster_detail_path_manager.cpp b/src/xrGame/alife_monster_detail_path_manager.cpp index adaec763040..2c7cdf57487 100644 --- a/src/xrGame/alife_monster_detail_path_manager.cpp +++ b/src/xrGame/alife_monster_detail_path_manager.cpp @@ -124,7 +124,7 @@ void CALifeMonsterDetailPathManager::actualize() { const CGameGraph::CGameVertex* vertex = ai().game_graph().vertex(object().get_object().m_tGraphID); Msg("! [%d][%s][%f][%f][%f]", object().get_object().m_tGraphID, - *ai().game_graph().header().level(vertex->level_id()).name(), VPUSH(vertex->level_point())); + ai().game_graph().header().level(vertex->level_id()).name().c_str(), VPUSH(vertex->level_point())); Msg("! game_graph_mask -> [ %d, %d, %d, %d]", vertex->vertex_type()[0], vertex->vertex_type()[1], vertex->vertex_type()[2], vertex->vertex_type()[3]); } @@ -132,7 +132,7 @@ void CALifeMonsterDetailPathManager::actualize() { const CGameGraph::CGameVertex* vertex = ai().game_graph().vertex(m_destination.m_game_vertex_id); Msg("! [%d][%s][%f][%f][%f]", m_destination.m_game_vertex_id, - *ai().game_graph().header().level(vertex->level_id()).name(), VPUSH(vertex->level_point())); + ai().game_graph().header().level(vertex->level_id()).name().c_str(), VPUSH(vertex->level_point())); Msg("! game_graph_mask -> [ %d, %d, %d, %d]", vertex->vertex_type()[0], vertex->vertex_type()[1], vertex->vertex_type()[2], vertex->vertex_type()[3]); } diff --git a/src/xrGame/alife_monster_detail_path_manager.h b/src/xrGame/alife_monster_detail_path_manager.h index f0b0ae6759a..bfa7b529853 100644 --- a/src/xrGame/alife_monster_detail_path_manager.h +++ b/src/xrGame/alife_monster_detail_path_manager.h @@ -77,6 +77,9 @@ class CALifeMonsterDetailPathManager IC const PATH& path() const; IC const float& walked_distance() const; Fvector draw_level_position() const; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #include "alife_monster_detail_path_manager_inline.h" diff --git a/src/xrGame/alife_monster_detail_path_manager_script.cpp b/src/xrGame/alife_monster_detail_path_manager_script.cpp index e4f904ae609..454914e1c44 100644 --- a/src/xrGame/alife_monster_detail_path_manager_script.cpp +++ b/src/xrGame/alife_monster_detail_path_manager_script.cpp @@ -7,11 +7,11 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "alife_monster_detail_path_manager.h" #include "alife_smart_terrain_task.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CALifeMonsterDetailPathManager, (), +void CALifeMonsterDetailPathManager::script_register(lua_State* luaState) { using namespace luabind; @@ -32,4 +32,4 @@ SCRIPT_EXPORT(CALifeMonsterDetailPathManager, (), .def("actual", &CALifeMonsterDetailPathManager::actual) .def("failed", &CALifeMonsterDetailPathManager::failed) ]; -}); +} diff --git a/src/xrGame/alife_monster_movement_manager.h b/src/xrGame/alife_monster_movement_manager.h index cd22249de89..1bf295b86cf 100644 --- a/src/xrGame/alife_monster_movement_manager.h +++ b/src/xrGame/alife_monster_movement_manager.h @@ -50,6 +50,9 @@ class CALifeMonsterMovementManager public: bool completed() const; bool actual() const; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #include "alife_monster_movement_manager_inline.h" diff --git a/src/xrGame/alife_monster_movement_manager_script.cpp b/src/xrGame/alife_monster_movement_manager_script.cpp index 62823424533..2757d167f71 100644 --- a/src/xrGame/alife_monster_movement_manager_script.cpp +++ b/src/xrGame/alife_monster_movement_manager_script.cpp @@ -7,24 +7,21 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "movement_manager_space.h" #include "alife_monster_movement_manager.h" #include "alife_monster_detail_path_manager.h" #include "alife_monster_patrol_path_manager.h" -#include "xrScriptEngine/ScriptExporter.hpp" - -CALifeMonsterDetailPathManager* get_detail(const CALifeMonsterMovementManager* self) { return (&self->detail()); } -CALifeMonsterPatrolPathManager* get_patrol(const CALifeMonsterMovementManager* self) { return (&self->patrol()); } -SCRIPT_EXPORT(CALifeMonsterMovementManager, (), +void CALifeMonsterMovementManager::script_register(lua_State* luaState) { using namespace luabind; module(luaState) [ class_("CALifeMonsterMovementManager") - .def("detail", &get_detail) - .def("patrol", &get_patrol) + .def("detail", +[](const CALifeMonsterMovementManager* self) { return (&self->detail()); }) + .def("patrol", +[](const CALifeMonsterMovementManager* self) { return (&self->patrol()); }) .def("path_type", (void (CALifeMonsterMovementManager::*)(const MovementManager::EPathType&))( &CALifeMonsterMovementManager::path_type)) .def("path_type", (const MovementManager::EPathType& (CALifeMonsterMovementManager::*)() @@ -32,4 +29,4 @@ SCRIPT_EXPORT(CALifeMonsterMovementManager, (), .def("actual", &CALifeMonsterMovementManager::actual) .def("completed", &CALifeMonsterMovementManager::completed) ]; -}); +} diff --git a/src/xrGame/alife_monster_patrol_path_manager.h b/src/xrGame/alife_monster_patrol_path_manager.h index cca937c5363..fe92bdc19d7 100644 --- a/src/xrGame/alife_monster_patrol_path_manager.h +++ b/src/xrGame/alife_monster_patrol_path_manager.h @@ -64,6 +64,9 @@ class CALifeMonsterPatrolPathManager const _GRAPH_ID& target_game_vertex_id() const; const u32& target_level_vertex_id() const; const Fvector& target_position() const; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #include "alife_monster_patrol_path_manager_inline.h" diff --git a/src/xrGame/alife_monster_patrol_path_manager_script.cpp b/src/xrGame/alife_monster_patrol_path_manager_script.cpp index 18c051c5f45..d7375efec49 100644 --- a/src/xrGame/alife_monster_patrol_path_manager_script.cpp +++ b/src/xrGame/alife_monster_patrol_path_manager_script.cpp @@ -7,17 +7,11 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "alife_monster_patrol_path_manager.h" #include "xrAICore/Navigation/PatrolPath/patrol_path.h" -#include "xrScriptEngine/ScriptExporter.hpp" -Fvector CALifeMonsterPatrolPathManager__target_position(CALifeMonsterPatrolPathManager* self) -{ - THROW(self); - return self->target_position(); -} - -SCRIPT_EXPORT(CALifeMonsterPatrolPathManager, (), +void CALifeMonsterPatrolPathManager::script_register(lua_State* luaState) { using namespace luabind; @@ -42,6 +36,6 @@ SCRIPT_EXPORT(CALifeMonsterPatrolPathManager, (), &CALifeMonsterPatrolPathManager::use_randomness)) .def("target_game_vertex_id", &CALifeMonsterPatrolPathManager::target_game_vertex_id) .def("target_level_vertex_id", &CALifeMonsterPatrolPathManager::target_level_vertex_id) - .def("target_position", &CALifeMonsterPatrolPathManager__target_position) + .def("target_position", +[](const CALifeMonsterPatrolPathManager* self) { return self->target_position(); }) ]; -}); +} diff --git a/src/xrGame/alife_object.cpp b/src/xrGame/alife_object.cpp index 389527e9713..8136c96a03e 100644 --- a/src/xrGame/alife_object.cpp +++ b/src/xrGame/alife_object.cpp @@ -12,7 +12,7 @@ #include "xrServer_Objects_ALife_Items.h" #include "xrCommon/xr_vector.h" -void CSE_ALifeObject::spawn_supplies() { spawn_supplies(*m_ini_string); } +void CSE_ALifeObject::spawn_supplies() { spawn_supplies(m_ini_string.c_str()); } void CSE_ALifeObject::spawn_supplies(LPCSTR ini_string) { diff --git a/src/xrGame/alife_online_offline_group_brain.cpp b/src/xrGame/alife_online_offline_group_brain.cpp index f4ed71a8358..697e49f027b 100644 --- a/src/xrGame/alife_online_offline_group_brain.cpp +++ b/src/xrGame/alife_online_offline_group_brain.cpp @@ -11,7 +11,6 @@ #include "Common/object_broker.h" #include "xrServer_Objects_ALife_Monsters.h" -#ifdef XRGAME_EXPORTS #include "alife_monster_movement_manager.h" #include "alife_monster_detail_path_manager.h" #include "alife_monster_patrol_path_manager.h" @@ -30,28 +29,22 @@ #include "map_location.h" #include "map_manager.h" #endif -#endif CALifeOnlineOfflineGroupBrain::CALifeOnlineOfflineGroupBrain(object_type* object) { VERIFY(object); m_object = object; -#ifdef XRGAME_EXPORTS m_movement_manager = xr_new(object); -#endif } CALifeOnlineOfflineGroupBrain::~CALifeOnlineOfflineGroupBrain() { -#ifdef XRGAME_EXPORTS xr_delete(m_movement_manager); -#endif } void CALifeOnlineOfflineGroupBrain::on_state_write(NET_Packet& packet) {} void CALifeOnlineOfflineGroupBrain::on_state_read(NET_Packet& packet) {} -#ifdef XRGAME_EXPORTS void CALifeOnlineOfflineGroupBrain::on_register() {} void CALifeOnlineOfflineGroupBrain::on_unregister() {} @@ -67,4 +60,3 @@ void CALifeOnlineOfflineGroupBrain::update() void CALifeOnlineOfflineGroupBrain::on_switch_online() { movement().on_switch_online(); } void CALifeOnlineOfflineGroupBrain::on_switch_offline() { movement().on_switch_offline(); } -#endif // XRGAME_EXPORTS diff --git a/src/xrGame/alife_simulator.h b/src/xrGame/alife_simulator.h index 227aecb4c9e..86c92db964b 100644 --- a/src/xrGame/alife_simulator.h +++ b/src/xrGame/alife_simulator.h @@ -33,6 +33,8 @@ class CALifeSimulator : public CALifeUpdateManager, public CALifeInteractionMana private: typedef xr_list> configs_type; mutable configs_type m_configs_lru; + + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #pragma warning(pop) diff --git a/src/xrGame/alife_simulator_script.cpp b/src/xrGame/alife_simulator_script.cpp index 4f2c6668c60..fcf26f6db78 100644 --- a/src/xrGame/alife_simulator_script.cpp +++ b/src/xrGame/alife_simulator_script.cpp @@ -7,6 +7,7 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "alife_simulator.h" #include "ai_space.h" #include "alife_object_registry.h" @@ -19,7 +20,7 @@ #include "alife_registry_container.h" #include "xrServer.h" #include "Level.h" -#include "xrScriptEngine/ScriptExporter.hpp" + #include "xrNetServer/NET_Messages.h" typedef xr_vector> STORY_PAIRS; @@ -440,7 +441,7 @@ void set_start_game_vertex_id(int id) g_start_game_vertex_id = id; } -SCRIPT_EXPORT(CALifeSimulator, (), +void CALifeSimulator::script_register(lua_State* luaState) { using namespace luabind; using namespace luabind::policy; @@ -489,7 +490,7 @@ SCRIPT_EXPORT(CALifeSimulator, (), .def("set_switch_distance", (void (CALifeSimulator::*)(float)) (&CALifeSimulator::set_switch_distance)) //Alundaio: renamed to set_switch_distance from switch_distance //Alundaio: extend alife simulator exports - .def("teleport_object", &teleport_object) + .def("teleport_object", &CALifeSimulator::teleport_object) .def("iterate_objects", &iterate_objects) .def("iterate_info", &IterateInfo) .def("clone_weapon", (CSE_Abstract* (*)(CALifeSimulator*, CSE_Abstract*, pcstr, const Fvector&, u32, @@ -498,7 +499,7 @@ SCRIPT_EXPORT(CALifeSimulator, (), GameGraph::_GRAPH_ID, ALife::_OBJECT_ID, bool))&try_to_clone_object) .def("register", &reprocess_spawn) .def("set_objects_per_update", &set_objects_per_update) - .def("set_process_time", &set_process_time) + .def("set_process_time", &CALifeSimulator::set_process_time) .def("get_children", &get_children, return_stl_iterator()), //Alundaio: END @@ -546,7 +547,7 @@ SCRIPT_EXPORT(CALifeSimulator, (), luabind::module(luaState)[instance]; } -}); +} #if 0 // def DEBUG struct dummy { diff --git a/src/xrGame/alife_smart_terrain_task.cpp b/src/xrGame/alife_smart_terrain_task.cpp index fd3f867f9ff..4b4f066e262 100644 --- a/src/xrGame/alife_smart_terrain_task.cpp +++ b/src/xrGame/alife_smart_terrain_task.cpp @@ -84,8 +84,8 @@ GameGraph::_GRAPH_ID CALifeSmartTerrainTask::game_vertex_id() const { if (m_game_vertex_id == GameGraph::_GRAPH_ID(-1)) { - VERIFY3(ai().game_graph().valid_vertex_id(patrol_point().game_vertex_id()), *m_patrol_path_name, - *m_patrol_point->name()); + VERIFY3(ai().game_graph().valid_vertex_id(patrol_point().game_vertex_id()), m_patrol_path_name.c_str(), + m_patrol_point->name().c_str()); return (patrol_point().game_vertex_id()); } else @@ -99,8 +99,8 @@ u32 CALifeSmartTerrainTask::level_vertex_id() const { if (m_level_vertex_id == u32(-1)) { - VERIFY3(ai().game_graph().valid_vertex_id(patrol_point().game_vertex_id()), *m_patrol_path_name, - *m_patrol_point->name()); + VERIFY3(ai().game_graph().valid_vertex_id(patrol_point().game_vertex_id()), m_patrol_path_name.c_str(), + m_patrol_point->name().c_str()); return (patrol_point().level_vertex_id()); } else diff --git a/src/xrGame/alife_smart_terrain_task.h b/src/xrGame/alife_smart_terrain_task.h index 50679ae81f4..44c9630063d 100644 --- a/src/xrGame/alife_smart_terrain_task.h +++ b/src/xrGame/alife_smart_terrain_task.h @@ -43,6 +43,9 @@ class CALifeSmartTerrainTask GameGraph::_GRAPH_ID game_vertex_id() const; u32 level_vertex_id() const; Fvector position() const; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #include "alife_smart_terrain_task_inline.h" diff --git a/src/xrGame/alife_smart_terrain_task_script.cpp b/src/xrGame/alife_smart_terrain_task_script.cpp index 9c9a72b8ee4..5f6cf73d6ce 100644 --- a/src/xrGame/alife_smart_terrain_task_script.cpp +++ b/src/xrGame/alife_smart_terrain_task_script.cpp @@ -7,10 +7,10 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "alife_smart_terrain_task.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CALifeSmartTerrainTask, (), +void CALifeSmartTerrainTask::script_register(lua_State* luaState) { using namespace luabind; @@ -24,4 +24,4 @@ SCRIPT_EXPORT(CALifeSmartTerrainTask, (), .def("level_vertex_id", &CALifeSmartTerrainTask::level_vertex_id) .def("position", &CALifeSmartTerrainTask::position) ]; -}); +} diff --git a/src/xrGame/alife_spawn_registry.cpp b/src/xrGame/alife_spawn_registry.cpp index 843021cee25..5eb410f2288 100644 --- a/src/xrGame/alife_spawn_registry.cpp +++ b/src/xrGame/alife_spawn_registry.cpp @@ -63,8 +63,8 @@ void CALifeSpawnRegistry::load(IReader& file_stream, LPCSTR game_name) chunk->close(); string_path file_name; - bool file_exists = !!FS.exist(file_name, "$game_spawn$", *m_spawn_name, ".spawn"); - R_ASSERT3(file_exists, "Can't find spawn file:", *m_spawn_name); + bool file_exists = !!FS.exist(file_name, "$game_spawn$", m_spawn_name.c_str(), ".spawn"); + R_ASSERT3(file_exists, "Can't find spawn file:", m_spawn_name.c_str()); VERIFY(!m_file); m_file = FS.r_open(file_name); @@ -78,7 +78,7 @@ void CALifeSpawnRegistry::load(LPCSTR spawn_name) Msg("* Loading spawn registry..."); m_spawn_name = spawn_name; string_path file_name; - R_ASSERT3(FS.exist(file_name, "$game_spawn$", *m_spawn_name, ".spawn"), "Can't find spawn file:", *m_spawn_name); + R_ASSERT3(FS.exist(file_name, "$game_spawn$", m_spawn_name.c_str(), ".spawn"), "Can't find spawn file:", m_spawn_name.c_str()); VERIFY(!m_file); m_file = FS.r_open(file_name); diff --git a/src/xrGame/alife_storage_manager.cpp b/src/xrGame/alife_storage_manager.cpp index a9792ba71b2..cd21d91910b 100644 --- a/src/xrGame/alife_storage_manager.cpp +++ b/src/xrGame/alife_storage_manager.cpp @@ -237,7 +237,7 @@ void CALifeStorageManager::save(NET_Packet& net_packet) shared_str game_name; net_packet.r_stringZ(game_name); - save(*game_name, !!net_packet.r_u8()); + save(game_name.c_str(), !!net_packet.r_u8()); } void CALifeStorageManager::prepare_objects_for_save() diff --git a/src/xrGame/alife_story_registry.cpp b/src/xrGame/alife_story_registry.cpp index 34d734e85ec..6223069ce8f 100644 --- a/src/xrGame/alife_story_registry.cpp +++ b/src/xrGame/alife_story_registry.cpp @@ -20,7 +20,7 @@ void CALifeStoryRegistry::add(ALife::_STORY_ID id, CSE_ALifeDynamicObject* objec #ifdef DEBUG Msg("Adding Story item ID [%u], Object [%s] at level [%s]", id, object->name_replace(), - *ai().game_graph().header().level(ai().game_graph().vertex(object->m_tGraphID)->level_id()).name()); + ai().game_graph().header().level(ai().game_graph().vertex(object->m_tGraphID)->level_id()).name().c_str()); #endif auto I = m_objects.find(id); diff --git a/src/xrGame/alife_surge_manager.cpp b/src/xrGame/alife_surge_manager.cpp index 6e289de1ba7..ed467b0b93e 100644 --- a/src/xrGame/alife_surge_manager.cpp +++ b/src/xrGame/alife_surge_manager.cpp @@ -42,8 +42,8 @@ void CALifeSurgeManager::spawn_new_spawns() create(object, spawn, *I); #ifdef DEBUG if (psAI_Flags.test(aiALife)) - Msg("LSS : SURGE : SPAWN : [%s],[%s], level %s, time %f ms", *spawn->s_name, spawn->name_replace(), - *ai().game_graph().header().level(ai().game_graph().vertex(spawn->m_tGraphID)->level_id()).name(), + Msg("LSS : SURGE : SPAWN : [%s],[%s], level %s, time %f ms", spawn->s_name.c_str(), spawn->name_replace(), + ai().game_graph().header().level(ai().game_graph().vertex(spawn->m_tGraphID)->level_id()).name().c_str(), timer.GetElapsed_sec() * 1000.f); #endif } diff --git a/src/xrGame/alife_switch_manager.cpp b/src/xrGame/alife_switch_manager.cpp index 6837e602eb5..bc28689bcc4 100644 --- a/src/xrGame/alife_switch_manager.cpp +++ b/src/xrGame/alife_switch_manager.cpp @@ -67,7 +67,7 @@ void CALifeSwitchManager::add_online(CSE_ALifeDynamicObject* object, bool update #ifndef MASTER_GOLD if (psAI_Flags.test(aiALife)) - Msg("[LSS] Spawning object [%s][%s][%d]", object->name_replace(), *object->s_name, object->ID); + Msg("[LSS] Spawning object [%s][%s][%d]", object->name_replace(), object->s_name.c_str(), object->ID); #endif object->add_online(update_registries); @@ -96,7 +96,7 @@ void CALifeSwitchManager::remove_online(CSE_ALifeDynamicObject* object, bool upd #ifdef DEBUG if (psAI_Flags.test(aiALife)) - Msg("[LSS] Destroying object [%s][%s][%d]", object->name_replace(), *object->s_name, object->ID); + Msg("[LSS] Destroying object [%s][%s][%d]", object->name_replace(), object->s_name.c_str(), object->ID); #endif object->add_offline(m_saved_chidren, update_registries); @@ -133,7 +133,7 @@ bool CALifeSwitchManager::synchronize_location(CSE_ALifeDynamicObject* I) { START_PROFILE("ALife/switch/synchronize_location") #ifdef DEBUG - VERIFY3(ai().level_graph().level_id() == ai().game_graph().vertex(I->m_tGraphID)->level_id(), *I->s_name, + VERIFY3(ai().level_graph().level_id() == ai().game_graph().vertex(I->m_tGraphID)->level_id(), I->s_name.c_str(), I->name_replace()); if (!I->children.empty()) { diff --git a/src/xrGame/alife_trader_abstract.cpp b/src/xrGame/alife_trader_abstract.cpp index e4571f86706..c8cd214e1db 100644 --- a/src/xrGame/alife_trader_abstract.cpp +++ b/src/xrGame/alife_trader_abstract.cpp @@ -31,12 +31,10 @@ void CSE_ALifeTraderAbstract::spawn_supplies() CSE_ALifeItemPDA* pda = smart_cast(abstract); pda->m_original_owner = base()->ID; -#ifdef XRGAME_EXPORTS character_profile(); m_SpecificCharacter = shared_str(); m_community_index = NO_COMMUNITY_INDEX; pda->m_specific_character = specific_character(); -#endif if (m_SpecificCharacter.size()) { @@ -49,7 +47,7 @@ void CSE_ALifeTraderAbstract::spawn_supplies() { #pragma warning(push) #pragma warning(disable : 4238) - IReader reader((void*)(*dynamic_object->m_ini_string), xr_strlen(dynamic_object->m_ini_string)); + IReader reader((void*)dynamic_object->m_ini_string.c_str(), xr_strlen(dynamic_object->m_ini_string)); CInifile ini(&reader, FS.get_path("$game_config$")->m_Path); #pragma warning(pop) diff --git a/src/xrGame/alife_update_manager.cpp b/src/xrGame/alife_update_manager.cpp index a4552ae2be2..8012d38824f 100644 --- a/src/xrGame/alife_update_manager.cpp +++ b/src/xrGame/alife_update_manager.cpp @@ -190,7 +190,7 @@ bool CALifeUpdateManager::change_level(NET_Packet& net_packet) string256 autoave_name; strconcat(sizeof(autoave_name), autoave_name, Core.UserName, " - ", "autosave"); - LPCSTR temp0 = strchr(**m_server_command_line, '/'); + LPCSTR temp0 = strchr(m_server_command_line->c_str(), '/'); VERIFY(temp0); string256 temp; *m_server_command_line = strconcat(sizeof(temp), temp, autoave_name, temp0); @@ -298,7 +298,7 @@ bool CALifeUpdateManager::load_game(LPCSTR game_name, bool no_assert) } string512 S, S1; - xr_strcpy(S, **m_server_command_line); + xr_strcpy(S, m_server_command_line->c_str()); pstr temp = strchr(S, '/'); R_ASSERT2(temp, "Invalid server options!"); strconcat(sizeof(S1), S1, game_name, temp); @@ -388,10 +388,10 @@ void CALifeUpdateManager::teleport_object( { Msg("[LSS] teleporting object [%s][%s][%d] from level [%s], position [%f][%f][%f] to level [%s], position " "[%f][%f][%f]", - object->name_replace(), *object->s_name, object->ID, - *(ai().game_graph().header().level(ai().game_graph().vertex(object->m_tGraphID)->level_id()).name()), + object->name_replace(), object->s_name.c_str(), object->ID, + ai().game_graph().header().level(ai().game_graph().vertex(object->m_tGraphID)->level_id()).name().c_str(), VPUSH(ai().game_graph().vertex(object->m_tGraphID)->level_point()), - *(ai().game_graph().header().level(ai().game_graph().vertex(game_vertex_id)->level_id()).name()), + ai().game_graph().header().level(ai().game_graph().vertex(game_vertex_id)->level_id()).name().c_str(), VPUSH(ai().game_graph().vertex(game_vertex_id)->level_point())); } #endif diff --git a/src/xrGame/artefact_activation.cpp b/src/xrGame/artefact_activation.cpp index 7d9ae4481d4..e7eeab98a14 100644 --- a/src/xrGame/artefact_activation.cpp +++ b/src/xrGame/artefact_activation.cpp @@ -39,7 +39,7 @@ void SArtefactActivation::Load() for (int i = 0; i < (int)eMax; ++i) m_activation_states.push_back(SStateDef()); - LPCSTR activation_seq = pSettings->r_string(*m_af->cNameSect(), "artefact_activation_seq"); + LPCSTR activation_seq = pSettings->r_string(m_af->cNameSect().c_str(), "artefact_activation_seq"); m_activation_states[(int)eStarting].Load(activation_seq, "starting"); m_activation_states[(int)eFlying].Load(activation_seq, "flying"); @@ -131,7 +131,7 @@ void SArtefactActivation::ChangeEffects() if (state_def.m_snd.size()) { - m_snd.create(*state_def.m_snd, st_Effect, sg_SourceType); + m_snd.create(state_def.m_snd.c_str(), st_Effect, sg_SourceType); m_snd.play_at_pos(m_af, m_af->Position()); }; @@ -149,7 +149,7 @@ void SArtefactActivation::ChangeEffects() { IKinematicsAnimated* K = smart_cast(m_af->Visual()); if (K) - K->PlayCycle(*state_def.m_animation); + K->PlayCycle(state_def.m_animation.c_str()); } } @@ -166,7 +166,7 @@ void SArtefactActivation::SpawnAnomaly() { VERIFY(!physics_world()->Processing()); string128 tmp; - cpcstr str = pSettings->r_string("artefact_spawn_zones", *m_af->cNameSect()); + cpcstr str = pSettings->r_string("artefact_spawn_zones", m_af->cNameSect().c_str()); VERIFY3(3 == _GetItemCount(str), "Bad record format in artefact_spawn_zones", str); const float zone_radius = (float)atof(_GetItem(str, 1, tmp)); const float zone_power = (float)atof(_GetItem(str, 2, tmp)); @@ -193,7 +193,7 @@ void SArtefactActivation::SpawnAnomaly() Level().Send(P, net_flags(TRUE)); F_entity_Destroy(object); //. #ifdef DEBUG - Msg("artefact [%s] spawned a zone [%s] at [%f]", *m_af->cName(), zone_sect, Device.fTimeGlobal); + Msg("artefact [%s] spawned a zone [%s] at [%f]", m_af->cName().c_str(), zone_sect, Device.fTimeGlobal); //. #endif } shared_str clear_brackets(LPCSTR src) diff --git a/src/xrGame/artefact_script.cpp b/src/xrGame/artefact_script.cpp index b34b6d92832..d69c8e8f2c4 100644 --- a/src/xrGame/artefact_script.cpp +++ b/src/xrGame/artefact_script.cpp @@ -14,9 +14,8 @@ #include "RustyHairArtifact.h" #include "GalantineArtifact.h" #include "cta_game_artefact.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CArtefact, (CGameObject), +void CArtefact::script_register(lua_State* luaState) { using namespace luabind; @@ -53,4 +52,4 @@ SCRIPT_EXPORT(CArtefact, (CGameObject), class_("CGraviArtefact") .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/attachment_owner.cpp b/src/xrGame/attachment_owner.cpp index 30c54fcc92b..a33f04c47ac 100644 --- a/src/xrGame/attachment_owner.cpp +++ b/src/xrGame/attachment_owner.cpp @@ -36,7 +36,7 @@ void CAttachmentOwner::net_Destroy() #ifdef DEBUG if (!attached_objects().empty()) { - Msg("Object %s has attached items :", *smart_cast(this)->cName()); + Msg("Object %s has attached items :", smart_cast(this)->cName().c_str()); // xr_vector::const_iterator I = attached_objects().begin(); // xr_vector::const_iterator E = attached_objects().end(); // for ( ; I != E; ++I) diff --git a/src/xrGame/base_client_classes_script.cpp b/src/xrGame/base_client_classes_script.cpp index 4405e479a98..2b190ec2ffd 100644 --- a/src/xrGame/base_client_classes_script.cpp +++ b/src/xrGame/base_client_classes_script.cpp @@ -7,63 +7,46 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "base_client_classes_wrappers.h" + #include "xrEngine/Feel_Sound.h" #include "Include/xrRender/RenderVisual.h" #include "Include/xrRender/Kinematics.h" #include "ai/stalker/ai_stalker.h" -#include "xrScriptEngine/ScriptExporter.hpp" -// clang-format off -SCRIPT_EXPORT(IFactoryObject, (), -{ - using namespace luabind; - - module(luaState) - [ - // 'DLL_Pure' is preserved to maintain backward compatibility with mod scripts - class_("DLL_Pure") - .def(constructor<>()) - .def("_construct", &IFactoryObject::_construct, &FactoryObjectWrapper::_construct_static) - ]; -}); +// Include files below to force the linker to include the symbols +#include "script_effector.h" +#include "script_particles.h" -SCRIPT_EXPORT(ISheduled, (), +void CGameObject::script_register(lua_State* luaState) { using namespace luabind; module(luaState) [ - class_("ISheduled") - ]; -}); + class_("CBlend"), -SCRIPT_EXPORT(IRenderable, (), -{ - using namespace luabind; + class_("IKinematicsAnimated") + .def("PlayCycle", +[](IKinematicsAnimated* sa, pcstr anim) + { + sa->PlayCycle(anim); + }), - module(luaState) - [ - class_("IRenderable") - ]; -}); + class_("IRender_Visual") + .def("dcast_PKinematicsAnimated", &IRenderVisual::dcast_PKinematicsAnimated), -SCRIPT_EXPORT(ICollidable, (), -{ - using namespace luabind; + // 'DLL_Pure' is preserved to maintain backward compatibility with mod scripts + class_("DLL_Pure") + .def(constructor<>()) + .def("_construct", &IFactoryObject::_construct, &FactoryObjectWrapper::_construct_static), - module(luaState) - [ - class_("ICollidable") - ]; -}); + class_("ISheduled"), -SCRIPT_EXPORT(CGameObject, (IFactoryObject, ISheduled, ICollidable, IRenderable), -{ - using namespace luabind; + class_("IRenderable"), + + class_("ICollidable"), - module(luaState) - [ class_, default_holder, CGameObjectWrapper>("CGameObject") .def(constructor<>()) @@ -79,39 +62,4 @@ SCRIPT_EXPORT(CGameObject, (IFactoryObject, ISheduled, ICollidable, IRenderable) .def("getVisible", &CGameObject::getVisible) .def("getEnabled", &CGameObject::getEnabled) ]; -}); - -SCRIPT_EXPORT(IRenderVisual, (), -{ - using namespace luabind; - - module(luaState) - [ - class_("IRender_Visual") - .def("dcast_PKinematicsAnimated", &IRenderVisual::dcast_PKinematicsAnimated) - ]; -}); - -void IKinematicsAnimated_PlayCycle(IKinematicsAnimated* sa, pcstr anim) { sa->PlayCycle(anim); } - -SCRIPT_EXPORT(IKinematicsAnimated, (), -{ - using namespace luabind; - - module(luaState) - [ - class_("IKinematicsAnimated") - .def("PlayCycle", &IKinematicsAnimated_PlayCycle) - ]; -}); - -SCRIPT_EXPORT(CBlend, (), -{ - using namespace luabind; - - module(luaState) - [ - class_("CBlend") - ]; -}); -// clang-format on +} diff --git a/src/xrGame/base_client_classes_wrappers.h b/src/xrGame/base_client_classes_wrappers.h index 6ebb267e857..a0d9e5f158b 100644 --- a/src/xrGame/base_client_classes_wrappers.h +++ b/src/xrGame/base_client_classes_wrappers.h @@ -26,8 +26,14 @@ class FactoryObjectWrapperTpl : public TBase, public luabind::wrap_base FactoryObjectWrapperTpl() = default; virtual ~FactoryObjectWrapperTpl() = default; - virtual IFactoryObject* _construct() { return (luabind::call_member(this, "_construct")); } - static IFactoryObject* _construct_static(TBase* self) { return (self->TBase::_construct()); } + virtual IFactoryObject* _construct() + { + return (luabind::call_member(this, "_construct")); + } + static IFactoryObject* _construct_static(TBase* self) + { + return (self->TBase::_construct()); + } private: // not exported @@ -38,7 +44,7 @@ class FactoryObjectWrapperTpl : public TBase, public luabind::wrap_base } }; -typedef FactoryObjectWrapperTpl FactoryObjectWrapper; +using FactoryObjectWrapper = FactoryObjectWrapperTpl; template class ISheduledWrapper : public TBase, public TClasses... @@ -58,7 +64,7 @@ class ISheduledWrapper : public TBase, public TClasses... } }; -typedef ISheduledWrapper CISheduledWrapper; +using CISheduledWrapper = ISheduledWrapper; template class IRenderableWrapper : public TBaseClasses... @@ -80,13 +86,41 @@ class CGameObjectWrapper : public CGameObjectIRenderable CGameObjectWrapper() = default; virtual ~CGameObjectWrapper() = default; - virtual bool use(CGameObject* who_use) { return call("use", who_use); } - static bool use_static(CGameObject* self, CGameObject* who_use) { return self->CGameObject::use(who_use); } - virtual void net_Import(NET_Packet& packet) { call("net_Import", &packet); } - static void net_Import_static(CGameObject* self, NET_Packet* packet) { self->CGameObject::net_Import(*packet); } - virtual void net_Export(NET_Packet& packet) { call("net_Export", &packet); } - static void net_Export_static(CGameObject* self, NET_Packet* packet) { self->CGameObject::net_Export(*packet); } - virtual bool net_Spawn(CSE_Abstract* data) { return (luabind::call_member(this, "net_Spawn", data)); } + virtual bool use(CGameObject* who_use) + { + return call("use", who_use); + } + + static bool use_static(CGameObject* self, CGameObject* who_use) + { + return self->CGameObject::use(who_use); + } + + virtual void net_Import(NET_Packet& packet) + { + call("net_Import", &packet); + } + + static void net_Import_static(CGameObject* self, NET_Packet* packet) + { + self->CGameObject::net_Import(*packet); + } + + virtual void net_Export(NET_Packet& packet) + { + call("net_Export", &packet); + } + + static void net_Export_static(CGameObject* self, NET_Packet* packet) + { + self->CGameObject::net_Export(*packet); + } + + virtual bool net_Spawn(CSE_Abstract* data) + { + return (luabind::call_member(this, "net_Spawn", data)); + } + static bool net_Spawn_static(CGameObject* self, CSE_Abstract* abstract) { return (!!self->CGameObject::net_Spawn(abstract)); @@ -121,3 +155,38 @@ class CEntityWrapper : public CEntity, public luabind::wrap_base LuaMessageType::Error, "You are trying to call a pure virtual function CEntity::HitImpulse!"); } }; + +class CScriptFlags +{ + DECLARE_SCRIPT_REGISTER_FUNCTION(); +}; + +class CScriptFcolor +{ + DECLARE_SCRIPT_REGISTER_FUNCTION(); +}; + +class CScriptFvector +{ + DECLARE_SCRIPT_REGISTER_FUNCTION(); +}; + +class CScriptFmatrix +{ + DECLARE_SCRIPT_REGISTER_FUNCTION(); +}; + +class fs_registrator +{ + DECLARE_SCRIPT_REGISTER_FUNCTION(); +}; + +class CScriptReader +{ + DECLARE_SCRIPT_REGISTER_FUNCTION(CScriptFvector); +}; + +class CScriptNetPacket +{ + DECLARE_SCRIPT_REGISTER_FUNCTION(CScriptFvector, CScriptFmatrix); +}; diff --git a/src/xrGame/client_spawn_manager.h b/src/xrGame/client_spawn_manager.h index d9693472f47..bbe0f911bef 100644 --- a/src/xrGame/client_spawn_manager.h +++ b/src/xrGame/client_spawn_manager.h @@ -57,6 +57,9 @@ class CClientSpawnManager void dump() const; void dump(ALife::_OBJECT_ID requesting_id) const; #endif // DEBUG + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #include "client_spawn_manager_inline.h" diff --git a/src/xrGame/client_spawn_manager_script.cpp b/src/xrGame/client_spawn_manager_script.cpp index e10c24099d7..6d1ca2c5d91 100644 --- a/src/xrGame/client_spawn_manager_script.cpp +++ b/src/xrGame/client_spawn_manager_script.cpp @@ -7,10 +7,10 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "client_spawn_manager.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CClientSpawnManager, (), +void CClientSpawnManager::script_register(lua_State* luaState) { using namespace luabind; @@ -25,4 +25,4 @@ SCRIPT_EXPORT(CClientSpawnManager, (), .def("remove", (void (CClientSpawnManager::*)(ALife::_OBJECT_ID, ALife::_OBJECT_ID))( &CClientSpawnManager::remove)) ]; -}); +} diff --git a/src/xrGame/console_commands.cpp b/src/xrGame/console_commands.cpp index 2b9807678b7..e0f325402bf 100644 --- a/src/xrGame/console_commands.cpp +++ b/src/xrGame/console_commands.cpp @@ -19,6 +19,7 @@ #include "Actor_Flags.h" #include "CustomZone.h" #include "xrScriptEngine/script_engine.hpp" +#include "xrScriptEngine/script_profiler.hpp" #include "xrScriptEngine/script_process.hpp" #include "xrServer_Objects.h" #include "ui/UIMainIngameWnd.h" @@ -167,11 +168,12 @@ static void full_memory_stats() GEnv.Render->ResourcesGetMemoryUsage(m_base, c_base, m_lmaps, c_lmaps); log_vminfo(); size_t _process_heap = ::Memory.mem_usage(); - int _eco_strings = (int)g_pStringContainer->stat_economy(); + const auto [_eco_strings_bytes, _eco_strings_count] = g_pStringContainer->stat_economy(); int _eco_smem = (int)g_pSharedMemoryContainer->stat_economy(); Msg("* [ render ]: textures[%d K]", (m_base + m_lmaps) / 1024); Msg("* [ x-ray ]: process heap[%u K]", _process_heap / 1024); - Msg("* [ x-ray ]: economy: strings[%d K], smem[%d K]", _eco_strings / 1024, _eco_smem); + Msg("* [ x-ray ]: shared strings: memory[%ld K], count[%lu]", _eco_strings_bytes / 1024, _eco_strings_count); + Msg("* [ x-ray ]: shared memory[%ld K]", _eco_smem); #ifdef FS_DEBUG Msg("* [ x-ray ]: file mapping: memory[%d K], count[%d]", g_file_mapped_memory / 1024, g_file_mapped_count); dump_file_mappings(); @@ -2226,9 +2228,9 @@ void CCC_RegisterCommands() CMD3(CCC_Mask, "ai_use_smart_covers", &psAI_Flags, aiUseSmartCovers); CMD3(CCC_Mask, "ai_use_smart_covers_animation_slots", &psAI_Flags, (u32)aiUseSmartCoversAnimationSlot); CMD4(CCC_Float, "ai_smart_factor", &g_smart_cover_factor, 0.f, 1000000.f); - CMD3(CCC_Mask, "lua_debug", &g_LuaDebug, 1); #endif // MASTER_GOLD + CMD3(CCC_Mask, "lua_debug", &g_LuaDebug, 1); CMD4(CCC_Integer, "lua_dump_depth", &g_LuaDumpDepth, 0, 16); CMD1(CCC_LuaProfiler, CCC_LuaProfiler::COMMAND_LUA_PROFILER_STATUS); diff --git a/src/xrGame/console_commands_mp.cpp b/src/xrGame/console_commands_mp.cpp index b6a3a725888..1032f89607a 100644 --- a/src/xrGame/console_commands_mp.cpp +++ b/src/xrGame/console_commands_mp.cpp @@ -255,7 +255,7 @@ class CCC_Dbg_NumObjects : public IConsole_Command IGameObject* pObj = Level().Objects.net_Find(CObjID[CO]); char color = (pObj->ID() == pEntity->ID) ? '-' : '!'; - Msg("%c %4d: Client - %20s[%5d] <===> Server - %s [%d]", color, CO + 1, *(pObj->cNameSect()), pObj->ID(), + Msg("%c %4d: Client - %20s[%5d] <===> Server - %s [%d]", color, CO + 1, pObj->cNameSect().c_str(), pObj->ID(), pEntity->s_name.c_str(), pEntity->ID); } else @@ -263,7 +263,7 @@ class CCC_Dbg_NumObjects : public IConsole_Command if (CO < CLObjNum) { IGameObject* pObj = Level().Objects.net_Find(CObjID[CO]); - Msg("! %2d: Client - %s [%d] <===> Server - -----------------", CO + 1, *(pObj->cNameSect()), + Msg("! %2d: Client - %s [%d] <===> Server - -----------------", CO + 1, pObj->cNameSect().c_str(), pObj->ID()); } else diff --git a/src/xrGame/console_registrator_script.cpp b/src/xrGame/console_registrator_script.cpp deleted file mode 100644 index 4670c302e57..00000000000 --- a/src/xrGame/console_registrator_script.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include "pch_script.h" -#include "xrEngine/XR_IOConsole.h" -#include "xrEngine/xr_ioc_cmd.h" -#include "xrScriptEngine/ScriptExporter.hpp" - -CConsole* console() { return Console; } - -bool get_renderer_command_state(void) -{ - return renderer_allow_override; -} - -int get_console_integer(CConsole* c, LPCSTR cmd) -{ - int min = 0, max = 0; - int val = c->GetInteger(cmd, min, max); - return val; -} - -float get_console_float(CConsole* c, LPCSTR cmd) -{ - float min = 0.0f, max = 0.0f; - float val = c->GetFloat(cmd, min, max); - return val; -} - -bool get_console_bool(CConsole* c, LPCSTR cmd) { return c->GetBool(cmd); } -void execute_console_command_deferred(CConsole* c, LPCSTR string_to_execute) -{ - Engine.Event.Defer("KERNEL:console", size_t(xr_strdup(string_to_execute))); -} - -SCRIPT_EXPORT(CConsole, (), -{ - using namespace luabind; - - module(luaState) - [ - def("get_console", &console), - - class_("CConsole") - .def("execute", &CConsole::Execute) - .def("execute_script", &CConsole::ExecuteScript) - .def("show", &CConsole::Show) - .def("hide", &CConsole::Hide) - - .def("get_string", &CConsole::GetString) - .def("get_integer", &get_console_integer) - .def("get_bool", &get_console_bool) - .def("get_float", &get_console_float) - .def("get_token", &CConsole::GetToken) - .def("execute_deferred", &execute_console_command_deferred), - - def("renderer_allow_override", &get_renderer_command_state)]; -}); diff --git a/src/xrGame/cover_point.h b/src/xrGame/cover_point.h index 68d359789ab..f06ca753335 100644 --- a/src/xrGame/cover_point.h +++ b/src/xrGame/cover_point.h @@ -20,6 +20,9 @@ class CCoverPoint IC Fvector const& position() const; IC u32 level_vertex_id() const; IC bool operator==(CCoverPoint const& point) const; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #include "cover_point_inline.h" diff --git a/src/xrGame/cover_point_script.cpp b/src/xrGame/cover_point_script.cpp index 60ee44364f4..dbf68fe4b78 100644 --- a/src/xrGame/cover_point_script.cpp +++ b/src/xrGame/cover_point_script.cpp @@ -7,17 +7,21 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" -#include "cover_point.h" -#include "xrScriptEngine/ScriptExporter.hpp" -bool CCoverPoint__is_smart_cover(CCoverPoint const* cover) { return (cover->m_is_smart_cover); } +#include "cover_point.h" -SCRIPT_EXPORT(CCoverPoint, (), +void CCoverPoint::script_register(lua_State* luaState) { using namespace luabind; - module(luaState)[class_("cover_point") - .def("position", &CCoverPoint::position) - .def("level_vertex_id", &CCoverPoint::level_vertex_id) - .def("is_smart_cover", &CCoverPoint__is_smart_cover)]; -}); + module(luaState) + [ + class_("cover_point") + .def("position", &CCoverPoint::position) + .def("level_vertex_id", &CCoverPoint::level_vertex_id) + .def("is_smart_cover", +[](const CCoverPoint* cover) + { + return (cover->m_is_smart_cover); + }) + ]; +} diff --git a/src/xrGame/damage_manager.cpp b/src/xrGame/damage_manager.cpp index db5e7365786..e120ea45ac6 100644 --- a/src/xrGame/damage_manager.cpp +++ b/src/xrGame/damage_manager.cpp @@ -77,22 +77,22 @@ void CDamageManager::load_section(LPCSTR section, CInifile const* ini) CInifile::Sect& damages = ini->r_section(section); for (const auto & i : damages.Data) { - if (xr_strcmp(*i.first, "default")) + if (xr_strcmp(i.first.c_str(), "default")) { // read all except default line VERIFY(m_object); int bone = kinematics->LL_BoneID(i.first); - R_ASSERT2(BI_NONE != bone, *i.first); + R_ASSERT2(BI_NONE != bone, i.first.c_str()); CBoneInstance& bone_instance = kinematics->LL_GetBoneInstance(u16(bone)); - bone_instance.set_param(0, (float)atof(_GetItem(*i.second, 0, buffer))); - bone_instance.set_param(1, (float)atoi(_GetItem(*i.second, 1, buffer))); - bone_instance.set_param(2, (float)atof(_GetItem(*i.second, 2, buffer))); - if (_GetItemCount(*i.second) < 4) + bone_instance.set_param(0, (float)atof(_GetItem(i.second.c_str(), 0, buffer))); + bone_instance.set_param(1, (float)atoi(_GetItem(i.second.c_str(), 1, buffer))); + bone_instance.set_param(2, (float)atof(_GetItem(i.second.c_str(), 2, buffer))); + if (_GetItemCount(i.second.c_str()) < 4) { - bone_instance.set_param(3, (float)atof(_GetItem(*i.second, 0, buffer))); + bone_instance.set_param(3, (float)atof(_GetItem(i.second.c_str(), 0, buffer))); } else { - bone_instance.set_param(3, (float)atof(_GetItem(*i.second, 3, buffer))); + bone_instance.set_param(3, (float)atof(_GetItem(i.second.c_str(), 3, buffer))); } if (0 == bone && (fis_zero(bone_instance.get_param(0)) || fis_zero(bone_instance.get_param(2)))) { diff --git a/src/xrGame/detail_path_manager.cpp b/src/xrGame/detail_path_manager.cpp index dd211985c03..c8d36069680 100644 --- a/src/xrGame/detail_path_manager.cpp +++ b/src/xrGame/detail_path_manager.cpp @@ -120,7 +120,7 @@ void CDetailPathManager::build_path(const xr_vector& level_path, u32 interm #endif // #ifndef MASTER_GOLD #ifdef DEBUG Msg("! DetailPathManager has failed for object %s : from [%f,%f,%f] to [%f,%f,%f]", - m_restricted_object ? *m_restricted_object->object().cName() : "unknown", + m_restricted_object ? m_restricted_object->object().cName().c_str() : "unknown", VPUSH(ai().level_graph().vertex_position(level_path.front())), VPUSH(ai().level_graph().vertex_position(level_path.back()))); Msg("List of available velocities :"); diff --git a/src/xrGame/detail_path_manager_inline.h b/src/xrGame/detail_path_manager_inline.h index 794136b644b..19f78db973c 100644 --- a/src/xrGame/detail_path_manager_inline.h +++ b/src/xrGame/detail_path_manager_inline.h @@ -8,9 +8,6 @@ #pragma once -// XXX: Get rid of this dependency, and replace THROW2 below with something more approrpriate? -#include "xrScriptEngine/DebugMacros.hpp" - IC bool CDetailPathManager::actual() const { return (m_actuality); } IC void CDetailPathManager::make_inactual() { m_actuality = false; } IC bool CDetailPathManager::failed() const { return (m_failed); } diff --git a/src/xrGame/detail_path_manager_smooth.cpp b/src/xrGame/detail_path_manager_smooth.cpp index aef7c40acfb..f4b41154063 100644 --- a/src/xrGame/detail_path_manager_smooth.cpp +++ b/src/xrGame/detail_path_manager_smooth.cpp @@ -854,7 +854,7 @@ void CDetailPathManager::build_smooth_path(const xr_vector& level_path, u32 alvi ? '+' : '-', asp ? '+' : '-'); } VERIFY3((alvi && asp) || (!asp && !alvi) || show_restrictions(m_restricted_object), - "Invalid restrictions (see log for details) for object ", *m_restricted_object->object().cName()); + "Invalid restrictions (see log for details) for object ", m_restricted_object->object().cName().c_str()); #endif m_restricted_object->add_border(start.vertex_id, dest.vertex_id); } diff --git a/src/xrGame/ef_storage.h b/src/xrGame/ef_storage.h index 790ac70646a..291587efb66 100644 --- a/src/xrGame/ef_storage.h +++ b/src/xrGame/ef_storage.h @@ -183,6 +183,9 @@ class CEF_Storage IC void alife_evaluation(bool value); IC CNonALifeParams& non_alife(); IC CALifeParams& alife(); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #include "ef_storage_inline.h" diff --git a/src/xrGame/ef_storage_script.cpp b/src/xrGame/ef_storage_script.cpp index eedf6f451d2..66d1c06f3bc 100644 --- a/src/xrGame/ef_storage_script.cpp +++ b/src/xrGame/ef_storage_script.cpp @@ -7,15 +7,16 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + +#include "xrScriptEngine/script_engine.hpp" + #include "ef_storage.h" #include "ai_space.h" #include "script_game_object.h" #include "script_game_object_impl.h" #include "entity_alive.h" -#include "xrScriptEngine/script_engine.hpp" #include "ef_base.h" #include "xrServer_Objects_ALife.h" -#include "xrScriptEngine/ScriptExporter.hpp" CEF_Storage* ef_storage() { return (&ai().ef_storage()); } float evaluate(CEF_Storage* ef_storage, LPCSTR function, CScriptGameObject* _0, CScriptGameObject* _1, @@ -117,7 +118,7 @@ float evaluate(CEF_Storage* ef_storage, LPCSTR function, CSE_ALifeObject* _0) return (evaluate(ef_storage, function, _0, 0, 0, 0)); } -SCRIPT_EXPORT(CEF_Storage, (), +void CEF_Storage::script_register(lua_State* luaState) { using namespace luabind; @@ -135,4 +136,4 @@ SCRIPT_EXPORT(CEF_Storage, (), .def("evaluate", (float (*)(CEF_Storage*, LPCSTR, CSE_ALifeObject*, CSE_ALifeObject*, CSE_ALifeObject*))(&evaluate)) .def("evaluate", (float (*)(CEF_Storage*, LPCSTR, CSE_ALifeObject*, CSE_ALifeObject*, CSE_ALifeObject*, CSE_ALifeObject*))(&evaluate)) ]; -}); +} diff --git a/src/xrGame/encyclopedia_article.cpp b/src/xrGame/encyclopedia_article.cpp index c631216ce51..ff2de8e045c 100644 --- a/src/xrGame/encyclopedia_article.cpp +++ b/src/xrGame/encyclopedia_article.cpp @@ -57,7 +57,7 @@ void CEncyclopediaArticle::load_shared(LPCSTR) // loading from XML XML_NODE pNode = pXML->NavigateToNode(id_to_index::tag_name, item_data.pos_in_file); - THROW3(pNode, "encyclopedia article id=", *item_data.id); + THROW3(pNode, "encyclopedia article id=", item_data.id.c_str()); //текÑÑ‚ data()->text = pXML->Read(pNode, "text", 0, ""); @@ -134,7 +134,7 @@ void CEncyclopediaArticle::load_shared(LPCSTR) } else { - Msg("incorrect article type definition for [%s]", *item_data.id); + Msg("incorrect article type definition for [%s]", item_data.id.c_str()); } data()->ui_template_name = pXML->ReadAttrib(pNode, "ui_template", "common"); diff --git a/src/xrGame/fs_registrator_script.cpp b/src/xrGame/fs_registrator_script.cpp index 1cfd65a2ce6..c47b25b6e41 100644 --- a/src/xrGame/fs_registrator_script.cpp +++ b/src/xrGame/fs_registrator_script.cpp @@ -1,6 +1,8 @@ #include "pch_script.h" + #include "xrCore/LocatorAPI.h" -#include "xrScriptEngine/ScriptExporter.hpp" + +#include "base_client_classes_wrappers.h" LPCSTR get_file_age_str(CLocatorAPI* fs, LPCSTR nm); CLocatorAPI* getFS() { return &FS; } @@ -175,7 +177,7 @@ LPCSTR get_file_age_str(CLocatorAPI* fs, LPCSTR nm) return asctime(newtime); } -SCRIPT_EXPORT(fs_registrator, (), +void fs_registrator::script_register(lua_State* luaState) { using namespace luabind; @@ -281,5 +283,6 @@ SCRIPT_EXPORT(fs_registrator, (), .def("file_list_open", &file_list_open_script_2) .def("file_list_open_ex", &file_list_open_ex), - def("getFS", getFS)]; -}); + def("getFS", getFS) + ]; +} diff --git a/src/xrGame/game_base.cpp b/src/xrGame/game_base.cpp index 691b547de6c..44a80ee1213 100644 --- a/src/xrGame/game_base.cpp +++ b/src/xrGame/game_base.cpp @@ -224,17 +224,17 @@ CLASS_ID game_GameState::getCLASS_ID(LPCSTR game_type_name, bool isServer) EGameIDs gameID = ParseStringToGameType(game_type_name); switch (gameID) { - case eGameIDSingle: return (isServer) ? TEXT2CLSID("SV_SINGL") : TEXT2CLSID("CL_SINGL"); break; + case eGameIDSingle: return isServer ? xray::make_clsid("SV_SINGL") : xray::make_clsid("CL_SINGL"); - case eGameIDDeathmatch: return (isServer) ? TEXT2CLSID("SV_DM") : TEXT2CLSID("CL_DM"); break; + case eGameIDDeathmatch: return isServer ? xray::make_clsid("SV_DM ") : xray::make_clsid("CL_DM "); - case eGameIDTeamDeathmatch: return (isServer) ? TEXT2CLSID("SV_TDM") : TEXT2CLSID("CL_TDM"); break; + case eGameIDTeamDeathmatch: return isServer ? xray::make_clsid("SV_TDM ") : xray::make_clsid("CL_TDM "); - case eGameIDArtefactHunt: return (isServer) ? TEXT2CLSID("SV_AHUNT") : TEXT2CLSID("CL_AHUNT"); break; + case eGameIDArtefactHunt: return isServer ? xray::make_clsid("SV_AHUNT") : xray::make_clsid("CL_AHUNT"); - case eGameIDCaptureTheArtefact: return (isServer) ? TEXT2CLSID("SV_CTA") : TEXT2CLSID("CL_CTA"); break; + case eGameIDCaptureTheArtefact: return isServer ? xray::make_clsid("SV_CTA ") : xray::make_clsid("CL_CTA "); - default: return (TEXT2CLSID("")); break; + default: return (xray::make_clsid(" ")); } } diff --git a/src/xrGame/game_base.h b/src/xrGame/game_base.h index e5f504aec6f..e07df45e485 100644 --- a/src/xrGame/game_base.h +++ b/src/xrGame/game_base.h @@ -1,12 +1,13 @@ #pragma once +#include "xrCommon/xr_deque.h" +#include "xrCommon/xr_vector.h" +#include "xrEngine/EngineAPI.h" +#include "GameObject.h" // Only for script export dependency #include "game_base_space.h" #include "alife_space.h" #include "gametype_chooser.h" #include "player_account.h" -#include "xrCommon/xr_deque.h" -#include "xrCommon/xr_vector.h" -#include "xrEngine/EngineAPI.h" #pragma pack(push, 1) @@ -24,6 +25,9 @@ struct RPoint RPoint() = default; bool operator==(const u16& ID) const { return (bBlocked && BlockedByID == ID); } + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; struct Bonus_Money_Struct @@ -114,6 +118,9 @@ struct game_PlayerState s32 LastBuyAcount; bool m_bClearRun; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; struct game_TeamState @@ -201,9 +208,6 @@ class game_GameState : public FactoryObjectBase, public virtual IGameState // moved from game_sv_base (time routines) -private: - friend void game_GameState_script_register(lua_State* luaState); - private: // scripts u64 m_qwStartProcessorTime; @@ -213,4 +217,7 @@ class game_GameState : public FactoryObjectBase, public virtual IGameState u64 m_qwEStartProcessorTime; u64 m_qwEStartGameTime; float m_fETimeFactor; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; diff --git a/src/xrGame/game_base_script.cpp b/src/xrGame/game_base_script.cpp index ce1def20efb..4286c3301cd 100644 --- a/src/xrGame/game_base_script.cpp +++ b/src/xrGame/game_base_script.cpp @@ -1,4 +1,5 @@ #include "pch_script.h" + #include "game_base.h" #include "xrServer_script_macroses.h" #include "xrCore/client_id.h" @@ -16,7 +17,7 @@ struct CGamePlayerStateWrapperBase : public T, public luabind::wrap_base DEFINE_LUA_WRAPPER_METHOD_V0(clear) }; -SCRIPT_EXPORT(game_PlayerState, (), +void game_PlayerState::script_register(lua_State* luaState) { using namespace luabind; @@ -52,14 +53,31 @@ SCRIPT_EXPORT(game_PlayerState, (), .def("net_Export", &BaseType::net_Export, &WrapType::net_Export_static) .def("net_Import", &BaseType::net_Import, &WrapType::net_Import_static) ]; -}); +} -void game_GameState_script_register(lua_State* luaState) +void game_GameState::script_register(lua_State* luaState) { + class EnumGameIDs {}; + using namespace luabind; module(luaState) [ + class_("GAME_TYPE") + .enum_("gametype") + [ + value("GAME_UNKNOWN", int(eGameIDNoGame)), + // SOC IDs + value("GAME_DEATHMATCH", int(eGameIDDeathmatch)), + value("GAME_TEAMDEATHMATCH", int(eGameIDTeamDeathmatch_SoC)), + value("GAME_ARTEFACTHUNT", int(eGameIDArtefactHunt_SoC)), + // CS/COP ids + value("eGameIDDeathmatch", int(eGameIDDeathmatch)), + value("eGameIDTeamDeathmatch", int(eGameIDTeamDeathmatch)), + value("eGameIDArtefactHunt", int(eGameIDArtefactHunt)), + value("eGameIDCaptureTheArtefact", int(eGameIDCaptureTheArtefact)) + ], + class_("game_GameState") .def(constructor<>()) @@ -73,4 +91,3 @@ void game_GameState_script_register(lua_State* luaState) .def("StartTime", &game_GameState::StartTime) ]; } -SCRIPT_EXPORT_FUNC(game_GameState, (IFactoryObject), game_GameState_script_register); diff --git a/src/xrGame/game_cl_artefacthunt.cpp b/src/xrGame/game_cl_artefacthunt.cpp index 107c64aa414..812b21ff3d3 100644 --- a/src/xrGame/game_cl_artefacthunt.cpp +++ b/src/xrGame/game_cl_artefacthunt.cpp @@ -186,7 +186,7 @@ void game_cl_ArtefactHunt::TranslateGameMessage(u32 msg, NET_Packet& P) if (!pPlayer) break; - xr_sprintf(tmp, "%s%s", "%s%s %s", *st.translate("mp_has_tak_art")); + xr_sprintf(tmp, "%s%s", "%s%s %s", st.translate("mp_has_tak_art").c_str()); xr_sprintf(Text, tmp, CTeamInfo::GetTeam_color_tag(int(Team)), pPlayer->getName(), Color_Main, Color_Artefact); @@ -213,7 +213,7 @@ void game_cl_ArtefactHunt::TranslateGameMessage(u32 msg, NET_Packet& P) if (!pPlayer) break; - xr_sprintf(tmp, "%s%s", "%s%s %s", *st.translate("mp_has_drop_art")); + xr_sprintf(tmp, "%s%s", "%s%s %s", st.translate("mp_has_drop_art").c_str()); xr_sprintf(Text, tmp, CTeamInfo::GetTeam_color_tag(int(Team)), pPlayer->getName(), Color_Main, Color_Artefact); if (CurrentGameUI()) @@ -233,7 +233,7 @@ void game_cl_ArtefactHunt::TranslateGameMessage(u32 msg, NET_Packet& P) if (!pPlayer) break; - xr_sprintf(tmp, "%s%s", "%s%s %s", *st.translate("mp_scores")); + xr_sprintf(tmp, "%s%s", "%s%s %s", st.translate("mp_scores").c_str()); xr_sprintf(Text, tmp, CTeamInfo::GetTeam_color_tag(int(Team)), CTeamInfo::GetTeam_name(int(Team)), Color_Main); if (CurrentGameUI()) @@ -251,7 +251,7 @@ void game_cl_ArtefactHunt::TranslateGameMessage(u32 msg, NET_Packet& P) break; case GAME_EVENT_ARTEFACT_SPAWNED: // ahunt { - xr_sprintf(Text, "%s%s", Color_Main, *st.translate("mp_art_spowned")); + xr_sprintf(Text, "%s%s", Color_Main, st.translate("mp_art_spowned").c_str()); if (CurrentGameUI()) CurrentGameUI()->CommonMessageOut(Text); @@ -260,7 +260,7 @@ void game_cl_ArtefactHunt::TranslateGameMessage(u32 msg, NET_Packet& P) break; case GAME_EVENT_ARTEFACT_DESTROYED: // ahunt { - xr_sprintf(Text, "%s%s", Color_Main, *st.translate("mp_art_destroyed")); + xr_sprintf(Text, "%s%s", Color_Main, st.translate("mp_art_destroyed").c_str()); u16 ArtefactID = P.r_u16(); //------------------------------------------- IGameObject* pObj = Level().Objects.net_Find(ArtefactID); @@ -381,7 +381,7 @@ void game_cl_ArtefactHunt::shedule_Update(u32 dt) { if (!(pCurBuyMenu && pCurBuyMenu->IsShown()) && !(pCurSkinMenu && pCurSkinMenu->IsShown())) { - xr_sprintf(msg, *StringTable().translate("mp_press_to_buy"), "B"); + xr_sprintf(msg, StringTable().translate("mp_press_to_buy").c_str(), "B"); if (m_game_ui) m_game_ui->SetBuyMsgCaption(msg); }; @@ -675,7 +675,7 @@ bool game_cl_ArtefactHunt::NeedToSendReady_Spectator(int key, game_PlayerState* { string1024 BuySpawnText; xr_sprintf( - BuySpawnText, *StringTable().translate("mp_press_yes2pay"), abs(local_player->money_for_round), abs(m_iSpawn_Cost)); + BuySpawnText, StringTable().translate("mp_press_yes2pay").c_str(), abs(local_player->money_for_round), abs(m_iSpawn_Cost)); m_game_ui->m_pBuySpawnMsgBox->SetText(BuySpawnText); if (m_bTeamSelected && m_bSkinSelected) diff --git a/src/xrGame/game_cl_base.h b/src/xrGame/game_cl_base.h index d9056d4f93f..89351cdc000 100644 --- a/src/xrGame/game_cl_base.h +++ b/src/xrGame/game_cl_base.h @@ -18,6 +18,9 @@ struct SZoneMapEntityData pos.set(.0f, .0f, .0f); color = 0xff00ff00; } + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; struct WeaponUsageStatistic; @@ -61,7 +64,7 @@ class game_cl_GameState : public game_GameState, public ScheduledBase public: game_cl_GameState(); virtual ~game_cl_GameState(); - LPCSTR type_name() const { return *m_game_type_name; }; + pcstr type_name() const override { return m_game_type_name.c_str(); }; void set_type_name(LPCSTR s); virtual void Init(){}; virtual void net_import_state(NET_Packet& P); diff --git a/src/xrGame/game_cl_base_script.cpp b/src/xrGame/game_cl_base_script.cpp index eff6cf2e617..a270aabafac 100644 --- a/src/xrGame/game_cl_base_script.cpp +++ b/src/xrGame/game_cl_base_script.cpp @@ -1,7 +1,7 @@ #include "pch_script.h" #include "game_cl_base.h" -SCRIPT_EXPORT(SZoneMapEntityData, (), +void SZoneMapEntityData::script_register(lua_State* luaState) { using namespace luabind; @@ -10,23 +10,15 @@ SCRIPT_EXPORT(SZoneMapEntityData, (), class_("SZoneMapEntityData") .def(constructor<>()) .def_readwrite("pos", &SZoneMapEntityData::pos) - .def_readwrite("color", &SZoneMapEntityData::color) - ]; -}); - -SCRIPT_EXPORT(SZoneMapEntities, (), -{ - using namespace luabind; + .def_readwrite("color", &SZoneMapEntityData::color), - module(luaState) - [ class_>("ZoneMapEntities") .def("push_back", (void (xr_vector::*)(const SZoneMapEntityData&)) (&xr_vector::push_back)) ]; -}); +} -SCRIPT_EXPORT(RPoint, (), +void RPoint::script_register(lua_State* luaState) { using namespace luabind; @@ -37,4 +29,4 @@ SCRIPT_EXPORT(RPoint, (), .def_readwrite("P", &RPoint::P) .def_readwrite("A", &RPoint::A) ]; -}); +} diff --git a/src/xrGame/game_cl_base_weapon_usage_statistic_save.cpp b/src/xrGame/game_cl_base_weapon_usage_statistic_save.cpp index a838c05591f..cbca57095ac 100644 --- a/src/xrGame/game_cl_base_weapon_usage_statistic_save.cpp +++ b/src/xrGame/game_cl_base_weapon_usage_statistic_save.cpp @@ -81,7 +81,7 @@ void WeaponUsageStatistic::SaveData() #ifdef XR_PLATFORM_WINDOWS SYSTEMTIME Time; GetLocalTime(&Time); - xr_sprintf(mFileName, "(%s)_(%s)_%02d.%02d.%02d_%02d.%02d.%02d.wus", *(Level().name()), GameType, Time.wMonth, + xr_sprintf(mFileName, "(%s)_(%s)_%02d.%02d.%02d_%02d.%02d.%02d.wus", Level().name().c_str(), GameType, Time.wMonth, Time.wDay, Time.wYear, Time.wHour, Time.wMinute, Time.wSecond); #else time_t Time; @@ -167,7 +167,7 @@ void Player_Statistic::Write(FILE* pFile) if (!pFile) return; //---------------------------------------------- - fwrite(*PName, xr_strlen(PName) + 1, 1, pFile); + fwrite(PName.c_str(), xr_strlen(PName) + 1, 1, pFile); fwrite(&m_dwTotalShots, 4, 1, pFile); fwrite(m_dwTotalAliveTime, 4, 3, pFile); fwrite(m_dwTotalMoneyRound, 4, 3, pFile); @@ -249,8 +249,8 @@ void Weapon_Statistic::Write(FILE* pFile) if (!pFile) return; //---------------------------------------------- - fwrite(*WName, xr_strlen(WName) + 1, 1, pFile); - fwrite(*InvName, xr_strlen(InvName) + 1, 1, pFile); + fwrite(WName.c_str(), xr_strlen(WName) + 1, 1, pFile); + fwrite(InvName.c_str(), xr_strlen(InvName) + 1, 1, pFile); //---------------------------------------------- fwrite(&NumBought, 4, 1, pFile); fwrite(&m_dwRoundsFired, 4, 1, pFile); @@ -329,6 +329,6 @@ void HitData::Write(FILE* pFile) fwrite(&BoneID, 2, 1, pFile); fwrite(&Deadly, 1, 1, pFile); - fwrite(*TargetName, xr_strlen(TargetName) + 1, 1, pFile); - fwrite(*BoneName, xr_strlen(BoneName) + 1, 1, pFile); + fwrite(TargetName.c_str(), xr_strlen(TargetName) + 1, 1, pFile); + fwrite(BoneName.c_str(), xr_strlen(BoneName) + 1, 1, pFile); }; diff --git a/src/xrGame/game_cl_capture_the_artefact_captions_manager.cpp b/src/xrGame/game_cl_capture_the_artefact_captions_manager.cpp index 036d2daa79f..8b85a6badb9 100644 --- a/src/xrGame/game_cl_capture_the_artefact_captions_manager.cpp +++ b/src/xrGame/game_cl_capture_the_artefact_captions_manager.cpp @@ -180,12 +180,12 @@ u32 CTAGameClCaptionsManager::SetWarmupTime(u32 current_warmup_time, u32 current warmup_message[0] = 0; // bad style if (time_remains > 10000) { - strconcat(sizeof(warmup_message), warmup_message, *st.translate("mp_time2start"), " ", time_str); + strconcat(sizeof(warmup_message), warmup_message, st.translate("mp_time2start").c_str(), " ", time_str); } else { if (time_remains < 1000) - strconcat(sizeof(warmup_message), warmup_message, *st.translate("mp_go"), ""); + strconcat(sizeof(warmup_message), warmup_message, st.translate("mp_go").c_str(), ""); else { u32 dwCurTimeRemains = time_remains / 1000; @@ -198,7 +198,7 @@ u32 CTAGameClCaptionsManager::SetWarmupTime(u32 current_warmup_time, u32 current } dwLastTimeRemains = dwCurTimeRemains; xr_itoa(dwCurTimeRemains, time_str, 10); - strconcat(sizeof(warmup_message), warmup_message, *st.translate("mp_ready"), "...", time_str); + strconcat(sizeof(warmup_message), warmup_message, st.translate("mp_ready").c_str(), "...", time_str); } }; return ret_value; diff --git a/src/xrGame/game_cl_capture_the_artefact_messages_menu.cpp b/src/xrGame/game_cl_capture_the_artefact_messages_menu.cpp index bd7f054837f..77eecff0bc5 100644 --- a/src/xrGame/game_cl_capture_the_artefact_messages_menu.cpp +++ b/src/xrGame/game_cl_capture_the_artefact_messages_menu.cpp @@ -31,7 +31,7 @@ void game_cl_CaptureTheArtefact::OnSpeechMessage(NET_Packet& P) if (ps->team == local_player->team) { if (CurrentGameUI()) - CurrentGameUI()->m_pMessagesWnd->AddChatMessage(*StringTable().translate(*(pMMessage->pMessage)), ps->getName()); + CurrentGameUI()->m_pMessagesWnd->AddChatMessage(StringTable().translate(pMMessage->pMessage).c_str(), ps->getName()); if (!Level().MapManager().HasMapLocation(FRIEND_RADION_LOCATION, ps->GameID)) { @@ -59,7 +59,7 @@ void game_cl_CaptureTheArtefact::OnSpeechMessage(NET_Packet& P) { pMSound->mSound_Radio.play_at_pos(NULL, Fvector().set(0, 0, 0), sm_2D, 0); } - Msg("%s said: %s", ps->getName(), *StringTable().translate(pMMessage->pMessage)); + Msg("%s said: %s", ps->getName(), StringTable().translate(pMMessage->pMessage).c_str()); } else { diff --git a/src/xrGame/game_cl_mp.cpp b/src/xrGame/game_cl_mp.cpp index 332cc7a02a3..107ca9e52c9 100644 --- a/src/xrGame/game_cl_mp.cpp +++ b/src/xrGame/game_cl_mp.cpp @@ -348,7 +348,7 @@ void game_cl_mp::TranslateGameMessage(u32 msg, NET_Packet& P) break; case GAME_EVENT_VOTE_START: { - xr_sprintf(Text, "%s%s", Color_Main, *StringTable().translate("mp_voting_started_msg")); + xr_sprintf(Text, "%s%s", Color_Main, StringTable().translate("mp_voting_started_msg").c_str()); if (CurrentGameUI()) CurrentGameUI()->CommonMessageOut(Text); OnVoteStart(P); @@ -356,7 +356,7 @@ void game_cl_mp::TranslateGameMessage(u32 msg, NET_Packet& P) break; case GAME_EVENT_VOTE_STOP: { - xr_sprintf(Text, "%s%s", Color_Main, *StringTable().translate("mp_voting_broken")); + xr_sprintf(Text, "%s%s", Color_Main, StringTable().translate("mp_voting_broken").c_str()); if (CurrentGameUI()) CurrentGameUI()->CommonMessageOut(Text); @@ -367,7 +367,7 @@ void game_cl_mp::TranslateGameMessage(u32 msg, NET_Packet& P) { string4096 Reason; P.r_stringZ(Reason); - xr_sprintf(Text, "%s%s", Color_Main, *StringTable().translate(Reason)); + xr_sprintf(Text, "%s%s", Color_Main, StringTable().translate(Reason).c_str()); if (CurrentGameUI()) CurrentGameUI()->CommonMessageOut(Text); OnVoteEnd(P); @@ -404,7 +404,7 @@ void game_cl_mp::TranslateGameMessage(u32 msg, NET_Packet& P) { string1024 mess; P.r_stringZ(mess); - xr_sprintf(Text, "%s%s", Color_Red, *StringTable().translate(mess)); + xr_sprintf(Text, "%s%s", Color_Red, StringTable().translate(mess).c_str()); if (CurrentGameUI()) CurrentGameUI()->CommonMessageOut(Text); } @@ -536,9 +536,9 @@ void game_cl_mp::OnChatMessage(NET_Packet* P) ///#ifdef DEBUG switch (team) { - case 0: Msg("%s: %s : %s", *StringTable().translate("mp_chat"), PlayerName.c_str(), ChatMsg.c_str()); break; - case 1: Msg("- %s: %s : %s", *StringTable().translate("mp_chat"), PlayerName.c_str(), ChatMsg.c_str()); break; - case 2: Msg("@ %s: %s : %s", *StringTable().translate("mp_chat"), PlayerName.c_str(), ChatMsg.c_str()); break; + case 0: Msg("%s: %s : %s", StringTable().translate("mp_chat").c_str(), PlayerName.c_str(), ChatMsg.c_str()); break; + case 1: Msg("- %s: %s : %s", StringTable().translate("mp_chat").c_str(), PlayerName.c_str(), ChatMsg.c_str()); break; + case 2: Msg("@ %s: %s : %s", StringTable().translate("mp_chat").c_str(), PlayerName.c_str(), ChatMsg.c_str()); break; } //#endif @@ -673,8 +673,8 @@ void game_cl_mp::OnPlayerVoted(game_PlayerState* ps) string1024 resStr; xr_sprintf(resStr, "%s\"%s\" %s%s %s\"%s\"", Color_Teams[ps->team], ps->getName(), Color_Main, - *StringTable().translate("mp_voted"), ps->m_bCurrentVoteAgreed ? Color_Green : Color_Red, - *StringTable().translate(ps->m_bCurrentVoteAgreed ? "mp_voted_yes" : "mp_voted_no")); + StringTable().translate("mp_voted").c_str(), ps->m_bCurrentVoteAgreed ? Color_Green : Color_Red, + StringTable().translate(ps->m_bCurrentVoteAgreed ? "mp_voted_yes" : "mp_voted_no").c_str()); if (CurrentGameUI()) CurrentGameUI()->CommonMessageOut(resStr); } @@ -858,7 +858,7 @@ void game_cl_mp::OnPlayerKilled(NET_Packet& P) KMS.m_initiator.m_rect.y1 = 202; KMS.m_initiator.m_rect.x2 = KMS.m_initiator.m_rect.x1 + 31; KMS.m_initiator.m_rect.y2 = KMS.m_initiator.m_rect.y1 + 30; - xr_sprintf(sWeapon, *StringTable().translate("mp_by_explosion")); + xr_sprintf(sWeapon, StringTable().translate("mp_by_explosion").c_str()); } else { @@ -877,7 +877,7 @@ void game_cl_mp::OnPlayerKilled(NET_Packet& P) KMS.m_initiator.m_rect.y1 = 202; KMS.m_initiator.m_rect.x2 = KMS.m_initiator.m_rect.x1 + 31; KMS.m_initiator.m_rect.y2 = KMS.m_initiator.m_rect.y1 + 30; - xr_sprintf(sWeapon, *StringTable().translate("mp_by_anomaly")); + xr_sprintf(sWeapon, StringTable().translate("mp_by_anomaly").c_str()); } } } @@ -894,14 +894,14 @@ void game_cl_mp::OnPlayerKilled(NET_Packet& P) KMS.m_initiator.m_rect.y1 = 202; KMS.m_initiator.m_rect.x2 = KMS.m_initiator.m_rect.x1 + 31; KMS.m_initiator.m_rect.y2 = KMS.m_initiator.m_rect.y1 + 30; - Msg("%s killed by anomaly", *KMS.m_victim.m_name); + Msg("%s killed by anomaly", KMS.m_victim.m_name.c_str()); break; } }; if (pKiller) { - KMS.m_killer.m_name = pKiller ? pKiller->getName() : *(pOKiller->cNameSect()); + KMS.m_killer.m_name = pKiller ? pKiller->getName() : pOKiller->cNameSect().c_str(); KMS.m_killer.m_color = pKiller ? Color_Teams_u32[ModifyTeam(pKiller->team) + 1] : Color_Neutral_u32; }; }; @@ -933,7 +933,7 @@ void game_cl_mp::OnPlayerKilled(NET_Packet& P) KMS.m_ext_info.m_rect.y2 = pBS->IconRects[0].y1 + pBS->IconRects[0].y2; }; - xr_sprintf(sSpecial, *StringTable().translate("mp_with_headshot")); + xr_sprintf(sSpecial, StringTable().translate("mp_with_headshot").c_str()); if (pOKiller && pOKiller == Level().CurrentViewEntity()) PlaySndMessage(ID_HEADSHOT); @@ -952,7 +952,7 @@ void game_cl_mp::OnPlayerKilled(NET_Packet& P) KMS.m_ext_info.m_rect.y2 = pBS->IconRects[0].y1 + pBS->IconRects[0].y2; }; - xr_sprintf(sSpecial, *StringTable().translate("mp_with_eyeshot")); + xr_sprintf(sSpecial, StringTable().translate("mp_with_eyeshot").c_str()); if (pOKiller && pOKiller == Level().CurrentViewEntity()) PlaySndMessage(ID_ASSASSIN); @@ -971,7 +971,7 @@ void game_cl_mp::OnPlayerKilled(NET_Packet& P) KMS.m_ext_info.m_rect.y2 = pBS->IconRects[0].y1 + pBS->IconRects[0].y2; }; - xr_sprintf(sSpecial, *StringTable().translate("mp_with_backstab")); + xr_sprintf(sSpecial, StringTable().translate("mp_with_backstab").c_str()); if (pOKiller && pOKiller == Level().CurrentViewEntity()) PlaySndMessage(ID_ASSASSIN); break; @@ -988,13 +988,13 @@ void game_cl_mp::OnPlayerKilled(NET_Packet& P) KMS.m_ext_info.m_rect.x2 = KMS.m_ext_info.m_rect.x1 + 30; KMS.m_ext_info.m_rect.y2 = KMS.m_ext_info.m_rect.y1 + 30; //------------------------------------- - Msg(sWeapon[0] ? "%s killed himself by %s" : "%s killed himself", *KMS.m_killer.m_name, + Msg(sWeapon[0] ? "%s killed himself by %s" : "%s killed himself", KMS.m_killer.m_name.c_str(), sWeapon[0] ? sWeapon + 5 : ""); } else { //------------------------------------- - Msg("%s killed %s %s%s", *KMS.m_killer.m_name, *KMS.m_victim.m_name, sWeapon, sSpecial[0] ? sSpecial : ""); + Msg("%s killed %s %s%s", KMS.m_killer.m_name.c_str(), KMS.m_victim.m_name.c_str(), sWeapon, sSpecial[0] ? sSpecial : ""); } } break; @@ -1018,22 +1018,22 @@ void game_cl_mp::OnPlayerKilled(NET_Packet& P) KMS.m_ext_info.m_rect.x2 = KMS.m_ext_info.m_rect.x1 + 31; KMS.m_ext_info.m_rect.y2 = KMS.m_ext_info.m_rect.y1 + 30; - Msg("%s died from bleeding, thanks to anomaly", *KMS.m_victim.m_name); + Msg("%s died from bleeding, thanks to anomaly", KMS.m_victim.m_name.c_str()); break; } }; if (pKiller) { - KMS.m_killer.m_name = pKiller ? pKiller->getName() : *(pOKiller->cNameSect()); + KMS.m_killer.m_name = pKiller ? pKiller->getName() : pOKiller->cNameSect().c_str(); KMS.m_killer.m_color = pKiller ? Color_Teams_u32[ModifyTeam(pKiller->team) + 1] : Color_Neutral_u32; //----------------------------------------------------------------------- - Msg("%s died from bleeding, thanks to %s ", *KMS.m_victim.m_name, *KMS.m_killer.m_name); + Msg("%s died from bleeding, thanks to %s ", KMS.m_victim.m_name.c_str(), KMS.m_killer.m_name.c_str()); } else { //----------------------------------------------------------------- - Msg("%s died from bleeding", *KMS.m_victim.m_name); + Msg("%s died from bleeding", KMS.m_victim.m_name.c_str()); }; } break; @@ -1046,7 +1046,7 @@ void game_cl_mp::OnPlayerKilled(NET_Packet& P) KMS.m_initiator.m_rect.x2 = KMS.m_initiator.m_rect.x1 + 24; KMS.m_initiator.m_rect.y2 = KMS.m_initiator.m_rect.y1 + 24; //--------------------------------------------------------- - Msg("%s killed by radiation", *KMS.m_victim.m_name); + Msg("%s killed by radiation", KMS.m_victim.m_name.c_str()); } break; } @@ -1065,8 +1065,8 @@ void game_cl_mp::OnPlayerChangeName(NET_Packet& P) P.r_stringZ(NewName); string1024 resStr; - xr_sprintf(resStr, "%s\"%s\" %s%s %s\"%s\"", Color_Teams[Team], OldName, Color_Main, *StringTable().translate("mp_is_now"), - Color_Teams[Team], NewName); + xr_sprintf(resStr, "%s\"%s\" %s%s %s\"%s\"", Color_Teams[Team], OldName, Color_Main, + StringTable().translate("mp_is_now").c_str(), Color_Teams[Team], NewName); if (CurrentGameUI()) CurrentGameUI()->CommonMessageOut(resStr); Msg(NewName); @@ -1097,8 +1097,8 @@ void game_cl_mp::OnRankChanged(u8 OldRank) string256 tmp; string1024 RankStr; xr_sprintf(tmp, "rank_%d", local_player->rank); - xr_sprintf(RankStr, "%s : %s", *StringTable().translate("mp_your_rank"), - *StringTable().translate(READ_IF_EXISTS(pSettings, r_string, tmp, "rank_name", ""))); + xr_sprintf(RankStr, "%s : %s", StringTable().translate("mp_your_rank").c_str(), + StringTable().translate(READ_IF_EXISTS(pSettings, r_string, tmp, "rank_name", "")).c_str()); if (CurrentGameUI()) CurrentGameUI()->CommonMessageOut(RankStr); #ifdef DEBUG @@ -1315,7 +1315,7 @@ void game_cl_mp::OnGameRoundStarted() { // xr_sprintf(Text, "%sRound started !!!",Color_Main); string512 Text; - xr_sprintf(Text, "%s%s", Color_Main, *StringTable().translate("mp_match_started")); + xr_sprintf(Text, "%s%s", Color_Main, StringTable().translate("mp_match_started").c_str()); if (CurrentGameUI()) CurrentGameUI()->CommonMessageOut(Text); OnSwitchPhase_InProgress(); diff --git a/src/xrGame/game_cl_mp.h b/src/xrGame/game_cl_mp.h index 8d988f563ec..83612c681c0 100644 --- a/src/xrGame/game_cl_mp.h +++ b/src/xrGame/game_cl_mp.h @@ -314,4 +314,7 @@ class game_cl_mp : public game_cl_GameState static xr_string sanitize_filename(const xr_string& base_name); //------------------------------------------------------------------------------------------------- #include "game_cl_mp_messages_menu.h" + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(game_GameState); }; diff --git a/src/xrGame/game_cl_mp_messages_menu.cpp b/src/xrGame/game_cl_mp_messages_menu.cpp index 095c76b7fc2..cdb46954a24 100644 --- a/src/xrGame/game_cl_mp_messages_menu.cpp +++ b/src/xrGame/game_cl_mp_messages_menu.cpp @@ -23,11 +23,11 @@ void game_cl_mp::AddMessageMenu(LPCSTR menu_section, LPCSTR snd_path, LPCSTR tea { shared_str LineName; LineName.printf("phrase_%d", i); - if (!pSettings->line_exist(menu_section, *LineName)) + if (!pSettings->line_exist(menu_section, LineName.c_str())) break; //--------------------------------------------------------- string4096 Line; - xr_strcpy(Line, pSettings->r_string(menu_section, *LineName)); + xr_strcpy(Line, pSettings->r_string(menu_section, LineName.c_str())); u32 count = _GetItemCount(Line); if (!count) continue; @@ -90,10 +90,10 @@ void game_cl_mp::LoadMessagesMenu(LPCSTR menus_section) { shared_str LineName; LineName.printf("menu_%d", i); - if (!pSettings->line_exist(menus_section, *LineName)) + if (!pSettings->line_exist(menus_section, LineName.c_str())) break; - shared_str menu_section = pSettings->r_string(menus_section, *LineName); - AddMessageMenu(*menu_section, *Sounds_Path, *Team_Prefix); + shared_str menu_section = pSettings->r_string(menus_section, LineName.c_str()); + AddMessageMenu(menu_section.c_str(), Sounds_Path.c_str(), Team_Prefix.c_str()); } }; @@ -202,7 +202,7 @@ void game_cl_mp::OnSpeechMessage(NET_Packet& P) { pMSound->mSound_Radio.play_at_pos(nullptr, Fvector().set(0, 0, 0), sm_2D, 0); } - Msg("%s said: %s", ps->getName(), *StringTable().translate(pMMessage->pMessage)); + Msg("%s said: %s", ps->getName(), StringTable().translate(pMMessage->pMessage).c_str()); } else { diff --git a/src/xrGame/game_cl_mp_script.cpp b/src/xrGame/game_cl_mp_script.cpp index 4f525527fa4..2f67f12fbf0 100644 --- a/src/xrGame/game_cl_mp_script.cpp +++ b/src/xrGame/game_cl_mp_script.cpp @@ -1,4 +1,5 @@ #include "pch_script.h" + #include "game_cl_mp_script.h" #include "xrServer_script_macroses.h" #include "UIGameCustom.h" @@ -73,7 +74,7 @@ LPCSTR game_cl_mp_script::GetRoundTime() return bufTime; } -SCRIPT_EXPORT(game_cl_GameState, (game_GameState), +void game_cl_mp::script_register(lua_State* luaState) { using namespace luabind; @@ -81,22 +82,13 @@ SCRIPT_EXPORT(game_cl_GameState, (game_GameState), [ class_("game_cl_GameState") .def_readwrite("local_svdpnid", &game_cl_GameState::local_svdpnid) - .def_readwrite("local_player", &game_cl_GameState::local_player) - ]; -}); - -SCRIPT_EXPORT(game_cl_mp, (game_cl_GameState), -{ - using namespace luabind; + .def_readwrite("local_player", &game_cl_GameState::local_player), - module(luaState) - [ class_("game_cl_mp") ]; +} -}); - -void game_cl_mp_script_script_register(lua_State* luaState) +void game_cl_mp_script::script_register(lua_State* luaState) { using namespace luabind; using namespace luabind::policy; @@ -135,5 +127,3 @@ void game_cl_mp_script_script_register(lua_State* luaState) .def("createGameUI", &BaseType::createGameUI, &WrapType::createGameUI_static, adopt<0>()) ]; } - -SCRIPT_EXPORT_FUNC(game_cl_mp_script, (game_cl_mp), game_cl_mp_script_script_register); diff --git a/src/xrGame/game_cl_mp_script.h b/src/xrGame/game_cl_mp_script.h index 6019b269e0e..9fe5a4d44c2 100644 --- a/src/xrGame/game_cl_mp_script.h +++ b/src/xrGame/game_cl_mp_script.h @@ -6,8 +6,6 @@ class CScriptGameObject; class game_cl_mp_script : public game_cl_mp { - friend void game_cl_mp_script_script_register(lua_State* luaState); - using inherited = game_cl_mp; protected: @@ -23,4 +21,7 @@ class game_cl_mp_script : public game_cl_mp void GameEventGen(NET_Packet* P, u16 dest); void EventSend(NET_Packet* P); LPCSTR GetRoundTime(); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(game_cl_mp); }; diff --git a/src/xrGame/game_cl_single.cpp b/src/xrGame/game_cl_single.cpp index 5d26569503f..f82bfc061b3 100644 --- a/src/xrGame/game_cl_single.cpp +++ b/src/xrGame/game_cl_single.cpp @@ -1,4 +1,5 @@ #include "pch_script.h" + #include "game_cl_single.h" #include "UIGameSP.h" #include "Actor.h" @@ -6,7 +7,6 @@ #include "ai_space.h" #include "alife_simulator.h" #include "alife_time_manager.h" -#include "xrScriptEngine/ScriptExporter.hpp" #include "xrCore/xr_token.h" ESingleGameDifficulty g_SingleGameDifficulty = egdStalker; @@ -90,24 +90,3 @@ void game_cl_Single::SetEnvironmentGameTimeFactor(ALife::_TIME_ID GameTime, cons else inherited::SetEnvironmentGameTimeFactor(GameTime, fTimeFactor); } - -SCRIPT_EXPORT(CScriptGameDifficulty, (), -{ - using namespace luabind; - - class CScriptGameDifficulty - { - }; - - module(luaState) - [ - class_("game_difficulty") - .enum_("game_difficulty") - [ - value("novice", int(egdNovice)), - value("stalker", int(egdStalker)), - value("veteran", int(egdVeteran)), - value("master", int(egdMaster)) - ] - ]; -}); diff --git a/src/xrGame/game_sv_base.cpp b/src/xrGame/game_sv_base.cpp index c8fbddbcafa..10bf23ae384 100644 --- a/src/xrGame/game_sv_base.cpp +++ b/src/xrGame/game_sv_base.cpp @@ -458,7 +458,7 @@ void game_sv_GameState::Create(shared_str& options) void game_sv_GameState::ReadOptions(shared_str& options) { - g_sv_base_dwRPointFreezeTime = get_option_i(*options, "rpfrz", g_sv_base_dwRPointFreezeTime / 1000) * 1000; + g_sv_base_dwRPointFreezeTime = get_option_i(options.c_str(), "rpfrz", g_sv_base_dwRPointFreezeTime / 1000) * 1000; //. xr_strcpy(MAPROT_LIST, MAPROT_LIST_NAME); //. if (!FS.exist(MAPROT_LIST)) @@ -466,7 +466,7 @@ void game_sv_GameState::ReadOptions(shared_str& options) if (FS.exist(MAPROT_LIST)) Console->ExecuteScript(MAPROT_LIST); - g_sv_base_iVotingEnabled = get_option_i(*options, "vote", (g_sv_base_iVotingEnabled)); + g_sv_base_iVotingEnabled = get_option_i(options.c_str(), "vote", (g_sv_base_iVotingEnabled)); //--------------------------- // Convert old vote param if (g_sv_base_iVotingEnabled != 0) @@ -1066,8 +1066,8 @@ shared_str game_sv_GameState::parse_level_version(const shared_str& server_optio shared_str game_sv_GameState::parse_level_name(const shared_str& server_options) { string64 l_name = ""; - VERIFY(_GetItemCount(*server_options, '/')); - return (_GetItem(*server_options, 0, l_name, '/')); + VERIFY(_GetItemCount(server_options.c_str(), '/')); + return (_GetItem(server_options.c_str(), 0, l_name, '/')); } void game_sv_GameState::on_death(CSE_Abstract* e_dest, CSE_Abstract* e_src) diff --git a/src/xrGame/game_sv_base.h b/src/xrGame/game_sv_base.h index 8e1d132dae5..7bc7d20ac43 100644 --- a/src/xrGame/game_sv_base.h +++ b/src/xrGame/game_sv_base.h @@ -274,4 +274,7 @@ class game_sv_GameState : public game_GameState, public IServerGameState virtual void DumpOnlineStatistic(){}; bool CheckNewPlayer(xrClientData* CL); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(game_GameState); }; diff --git a/src/xrGame/game_sv_base_script.cpp b/src/xrGame/game_sv_base_script.cpp index ca051d7db09..afc24f1025e 100644 --- a/src/xrGame/game_sv_base_script.cpp +++ b/src/xrGame/game_sv_base_script.cpp @@ -7,13 +7,14 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "game_sv_base.h" #include "xrMessages.h" template class enum_exporter {}; -SCRIPT_EXPORT(game_sv_GameState, (game_GameState), +void game_sv_GameState::script_register(lua_State* luaState) { using namespace luabind; @@ -37,63 +38,55 @@ SCRIPT_EXPORT(game_sv_GameState, (game_GameState), .def("GenerateGameMessage", &game_sv_GameState::GenerateGameMessage) .def("getRP", &game_sv_GameState::getRP) - .def("getRPcount", &game_sv_GameState::getRPcount) - ]; -}); - -SCRIPT_EXPORT(EGameEnums, (), -{ - using namespace luabind; + .def("getRPcount", &game_sv_GameState::getRPcount), - module (luaState) - [ class_>("game_player_flags") - .enum_("flags") - [ - value("GAME_PLAYER_FLAG_LOCAL", int(GAME_PLAYER_FLAG_LOCAL)), - value("GAME_PLAYER_FLAG_READY", int(GAME_PLAYER_FLAG_READY)), - value("GAME_PLAYER_FLAG_VERY_VERY_DEAD", int(GAME_PLAYER_FLAG_VERY_VERY_DEAD)), - value("GAME_PLAYER_FLAG_SPECTATOR", int(GAME_PLAYER_FLAG_SPECTATOR)), - value("GAME_PLAYER_FLAG_SCRIPT_BEGINS_FROM", int(GAME_PLAYER_FLAG_SCRIPT_BEGINS_FROM)) - ], + .enum_("flags") + [ + value("GAME_PLAYER_FLAG_LOCAL", int(GAME_PLAYER_FLAG_LOCAL)), + value("GAME_PLAYER_FLAG_READY", int(GAME_PLAYER_FLAG_READY)), + value("GAME_PLAYER_FLAG_VERY_VERY_DEAD", int(GAME_PLAYER_FLAG_VERY_VERY_DEAD)), + value("GAME_PLAYER_FLAG_SPECTATOR", int(GAME_PLAYER_FLAG_SPECTATOR)), + value("GAME_PLAYER_FLAG_SCRIPT_BEGINS_FROM", int(GAME_PLAYER_FLAG_SCRIPT_BEGINS_FROM)) + ], class_>("game_phases") - .enum_("phases") - [ - value("GAME_PHASE_NONE", int(GAME_PHASE_NONE)), - value("GAME_PHASE_INPROGRESS", int(GAME_PHASE_INPROGRESS)), - value("GAME_PHASE_PENDING", int(GAME_PHASE_PENDING)), - value("GAME_PHASE_TEAM1_SCORES", int(GAME_PHASE_TEAM1_SCORES)), - value("GAME_PHASE_TEAM2_SCORES", int(GAME_PHASE_TEAM2_SCORES)), - value("GAME_PHASE_TEAMS_IN_A_DRAW", int(GAME_PHASE_TEAMS_IN_A_DRAW)), - value("GAME_PHASE_SCRIPT_BEGINS_FROM", int(GAME_PHASE_SCRIPT_BEGINS_FROM)) - ], + .enum_("phases") + [ + value("GAME_PHASE_NONE", int(GAME_PHASE_NONE)), + value("GAME_PHASE_INPROGRESS", int(GAME_PHASE_INPROGRESS)), + value("GAME_PHASE_PENDING", int(GAME_PHASE_PENDING)), + value("GAME_PHASE_TEAM1_SCORES", int(GAME_PHASE_TEAM1_SCORES)), + value("GAME_PHASE_TEAM2_SCORES", int(GAME_PHASE_TEAM2_SCORES)), + value("GAME_PHASE_TEAMS_IN_A_DRAW", int(GAME_PHASE_TEAMS_IN_A_DRAW)), + value("GAME_PHASE_SCRIPT_BEGINS_FROM", int(GAME_PHASE_SCRIPT_BEGINS_FROM)) + ], class_>("game_messages") - .enum_("messages") - [ - value("GAME_EVENT_PLAYER_READY", int(GAME_EVENT_PLAYER_READY)), - value("GAME_EVENT_PLAYER_CHANGE_TEAM", int(GAME_EVENT_PLAYER_GAME_MENU)), - value("GAME_EVENT_PLAYER_KILL", int(GAME_EVENT_PLAYER_KILL)), - value("GAME_EVENT_PLAYER_BUY_FINISHED", int(GAME_EVENT_PLAYER_BUY_FINISHED)), - value("GAME_EVENT_PLAYER_CHANGE_SKIN", int(GAME_EVENT_PLAYER_GAME_MENU)), - value("GAME_EVENT_PLAYER_CONNECTED", int(GAME_EVENT_PLAYER_CONNECTED)), - value("GAME_EVENT_PLAYER_DISCONNECTED", int(GAME_EVENT_PLAYER_DISCONNECTED)), - value("GAME_EVENT_PLAYER_KILLED", int(GAME_EVENT_PLAYER_KILLED)), - value("GAME_EVENT_PLAYER_JOIN_TEAM", int(GAME_EVENT_PLAYER_JOIN_TEAM)), - value("GAME_EVENT_ROUND_STARTED", int(GAME_EVENT_ROUND_STARTED)), - value("GAME_EVENT_ROUND_END", int(GAME_EVENT_ROUND_END)), - value("GAME_EVENT_ARTEFACT_SPAWNED", int(GAME_EVENT_ARTEFACT_SPAWNED)), - value("GAME_EVENT_ARTEFACT_DESTROYED", int(GAME_EVENT_ARTEFACT_DESTROYED)), - value("GAME_EVENT_ARTEFACT_TAKEN", int(GAME_EVENT_ARTEFACT_TAKEN)), - value("GAME_EVENT_ARTEFACT_DROPPED", int(GAME_EVENT_ARTEFACT_DROPPED)), - value("GAME_EVENT_ARTEFACT_ONBASE", int(GAME_EVENT_ARTEFACT_ONBASE)), - value("GAME_EVENT_PLAYER_ENTER_TEAM_BASE", int(GAME_EVENT_PLAYER_ENTER_TEAM_BASE)), - value("GAME_EVENT_PLAYER_LEAVE_TEAM_BASE", int(GAME_EVENT_PLAYER_LEAVE_TEAM_BASE)), - value("GAME_EVENT_BUY_MENU_CLOSED", int(GAME_EVENT_BUY_MENU_CLOSED)), - value("GAME_EVENT_TEAM_MENU_CLOSED", int(GAME_EVENT_TEAM_MENU_CLOSED)), - value("GAME_EVENT_SKIN_MENU_CLOSED", int(GAME_EVENT_SKIN_MENU_CLOSED)), - value("GAME_EVENT_SCRIPT_BEGINS_FROM", int(GAME_EVENT_SCRIPT_BEGINS_FROM)) - ] + .enum_("messages") + [ + value("GAME_EVENT_PLAYER_READY", int(GAME_EVENT_PLAYER_READY)), + value("GAME_EVENT_PLAYER_CHANGE_TEAM", int(GAME_EVENT_PLAYER_GAME_MENU)), + value("GAME_EVENT_PLAYER_KILL", int(GAME_EVENT_PLAYER_KILL)), + value("GAME_EVENT_PLAYER_BUY_FINISHED", int(GAME_EVENT_PLAYER_BUY_FINISHED)), + value("GAME_EVENT_PLAYER_CHANGE_SKIN", int(GAME_EVENT_PLAYER_GAME_MENU)), + value("GAME_EVENT_PLAYER_CONNECTED", int(GAME_EVENT_PLAYER_CONNECTED)), + value("GAME_EVENT_PLAYER_DISCONNECTED", int(GAME_EVENT_PLAYER_DISCONNECTED)), + value("GAME_EVENT_PLAYER_KILLED", int(GAME_EVENT_PLAYER_KILLED)), + value("GAME_EVENT_PLAYER_JOIN_TEAM", int(GAME_EVENT_PLAYER_JOIN_TEAM)), + value("GAME_EVENT_ROUND_STARTED", int(GAME_EVENT_ROUND_STARTED)), + value("GAME_EVENT_ROUND_END", int(GAME_EVENT_ROUND_END)), + value("GAME_EVENT_ARTEFACT_SPAWNED", int(GAME_EVENT_ARTEFACT_SPAWNED)), + value("GAME_EVENT_ARTEFACT_DESTROYED", int(GAME_EVENT_ARTEFACT_DESTROYED)), + value("GAME_EVENT_ARTEFACT_TAKEN", int(GAME_EVENT_ARTEFACT_TAKEN)), + value("GAME_EVENT_ARTEFACT_DROPPED", int(GAME_EVENT_ARTEFACT_DROPPED)), + value("GAME_EVENT_ARTEFACT_ONBASE", int(GAME_EVENT_ARTEFACT_ONBASE)), + value("GAME_EVENT_PLAYER_ENTER_TEAM_BASE", int(GAME_EVENT_PLAYER_ENTER_TEAM_BASE)), + value("GAME_EVENT_PLAYER_LEAVE_TEAM_BASE", int(GAME_EVENT_PLAYER_LEAVE_TEAM_BASE)), + value("GAME_EVENT_BUY_MENU_CLOSED", int(GAME_EVENT_BUY_MENU_CLOSED)), + value("GAME_EVENT_TEAM_MENU_CLOSED", int(GAME_EVENT_TEAM_MENU_CLOSED)), + value("GAME_EVENT_SKIN_MENU_CLOSED", int(GAME_EVENT_SKIN_MENU_CLOSED)), + value("GAME_EVENT_SCRIPT_BEGINS_FROM", int(GAME_EVENT_SCRIPT_BEGINS_FROM)) + ] ]; -}); +} diff --git a/src/xrGame/game_sv_deathmatch.h b/src/xrGame/game_sv_deathmatch.h index 4d000b86665..ba946b921b7 100644 --- a/src/xrGame/game_sv_deathmatch.h +++ b/src/xrGame/game_sv_deathmatch.h @@ -212,4 +212,7 @@ class game_sv_Deathmatch : public game_sv_mp, private pure_relcase virtual void WriteGameState(CInifile& ini, LPCSTR sect, bool bRoundResult); shared_str m_not_free_ammo_str; virtual bool CanChargeFreeAmmo(char const* ammo_section); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(game_sv_GameState); }; diff --git a/src/xrGame/game_sv_deathmatch_script.cpp b/src/xrGame/game_sv_deathmatch_script.cpp index c4c292ccdb0..24ab11b6978 100644 --- a/src/xrGame/game_sv_deathmatch_script.cpp +++ b/src/xrGame/game_sv_deathmatch_script.cpp @@ -12,7 +12,7 @@ struct CGameSvDeathmatchWrapperBase : T, luabind::wrap_base // DEFINE_LUA_WRAPPER_METHOD_1(Money_SetStart, void, u32) }; -SCRIPT_EXPORT(game_sv_Deathmatch, (game_sv_GameState), +void game_sv_Deathmatch::script_register(lua_State* luaState) { using BaseType = game_sv_Deathmatch; using WrapType = CGameSvDeathmatchWrapperBase; @@ -27,4 +27,4 @@ SCRIPT_EXPORT(game_sv_Deathmatch, (game_sv_GameState), .def("type_name", &BaseType::type_name, &WrapType::type_name_static) // .def("Money_SetStart", &WrapType::Money_SetStart, &WrapType::Money_SetStart_static) ]; -}); +} diff --git a/src/xrGame/game_sv_mp.h b/src/xrGame/game_sv_mp.h index 26d21835d32..a84cb05a023 100644 --- a/src/xrGame/game_sv_mp.h +++ b/src/xrGame/game_sv_mp.h @@ -22,8 +22,6 @@ struct Rank_Struct class game_sv_mp : public game_sv_GameState { - friend void game_sv_mp_script_register(lua_State* luaState); - using inherited = game_sv_GameState; protected: @@ -212,6 +210,9 @@ class game_sv_mp : public game_sv_GameState virtual void Player_ExperienceFin(game_PlayerState* ps); virtual void Player_AddMoney(game_PlayerState* ps, s32 MoneyAmount); void SpawnPlayer(ClientID id, LPCSTR N); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(game_sv_GameState); }; struct SearcherClientByName diff --git a/src/xrGame/game_sv_mp_script.cpp b/src/xrGame/game_sv_mp_script.cpp index e70c255f684..4fd759a9d23 100644 --- a/src/xrGame/game_sv_mp_script.cpp +++ b/src/xrGame/game_sv_mp_script.cpp @@ -179,8 +179,7 @@ struct CGameSvMpScriptWrapperBase : public T, public luabind::wrap_base #pragma warning(pop) -#pragma optimize("s", on) -void game_sv_mp_script_register(lua_State* luaState) +void game_sv_mp::script_register(lua_State* luaState) { using namespace luabind; @@ -195,7 +194,7 @@ void game_sv_mp_script_register(lua_State* luaState) ]; } -void game_sv_mp_script_script_register(lua_State* luaState) +void game_sv_mp_script::script_register(lua_State* luaState) { using namespace luabind; using namespace luabind::policy; @@ -229,6 +228,3 @@ void game_sv_mp_script_script_register(lua_State* luaState) .def("createPlayerState", &BaseType::createPlayerState, &WrapType::createPlayerState_static, adopt<0>()) ]; } - -SCRIPT_EXPORT_FUNC(game_sv_mp, (game_sv_GameState), game_sv_mp_script_register); -SCRIPT_EXPORT_FUNC(game_sv_mp_script, (game_sv_mp), game_sv_mp_script_script_register); diff --git a/src/xrGame/game_sv_mp_script.h b/src/xrGame/game_sv_mp_script.h index 92137df89ad..4d2eaac3773 100644 --- a/src/xrGame/game_sv_mp_script.h +++ b/src/xrGame/game_sv_mp_script.h @@ -4,8 +4,6 @@ class game_sv_mp_script : public game_sv_mp { - friend void game_sv_mp_script_script_register(lua_State* luaState); - using inherited = game_sv_mp; private: @@ -36,4 +34,7 @@ class game_sv_mp_script : public game_sv_mp float GetHitParamsImpulse(NET_Packet* P); virtual void switch_Phase(u32 new_phase); void SpawnPlayer(ClientID id, LPCSTR N, LPCSTR SkinName, RPoint rp); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(game_sv_mp); }; diff --git a/src/xrGame/gamespy/GameSpy_QR2_callbacks.cpp b/src/xrGame/gamespy/GameSpy_QR2_callbacks.cpp index 6c8b3bc99e3..5ab6c801237 100644 --- a/src/xrGame/gamespy/GameSpy_QR2_callbacks.cpp +++ b/src/xrGame/gamespy/GameSpy_QR2_callbacks.cpp @@ -59,7 +59,7 @@ void __cdecl callback_serverkey(int keyid, qr2_buffer_t outbuf, void* userdata) break; // pQR2->BufferAdd(outbuf, gameState->type_name()); break; case GAMEMODE_KEY: pQR2->BufferAdd(outbuf, "openplaying"); break; case PASSWORD_KEY: - if (0 == *(pServer->Password)) + if (0 == pServer->Password.c_str()) { pQR2->BufferAdd_Int(outbuf, 0); } diff --git a/src/xrGame/group_hierarchy_holder.cpp b/src/xrGame/group_hierarchy_holder.cpp index ad6e48b8ead..b6c8634435d 100644 --- a/src/xrGame/group_hierarchy_holder.cpp +++ b/src/xrGame/group_hierarchy_holder.cpp @@ -103,7 +103,7 @@ void CGroupHierarchyHolder::unregister_in_group(CEntity* member) { VERIFY(member); MEMBER_REGISTRY::iterator I = std::find(m_members.begin(), m_members.end(), member); - VERIFY3(I != m_members.end(), "Specified group member cannot be found", *member->cName()); + VERIFY3(I != m_members.end(), "Specified group member cannot be found", member->cName().c_str()); m_members.erase(I); } diff --git a/src/xrGame/helicopter.h b/src/xrGame/helicopter.h index 9119f982f96..321afc9393d 100644 --- a/src/xrGame/helicopter.h +++ b/src/xrGame/helicopter.h @@ -369,4 +369,7 @@ class CHelicopter : public CEntity, public: virtual void OnRender(); #endif + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; diff --git a/src/xrGame/helicopter_script.cpp b/src/xrGame/helicopter_script.cpp index 9b16433d471..c84f660b8e8 100644 --- a/src/xrGame/helicopter_script.cpp +++ b/src/xrGame/helicopter_script.cpp @@ -1,13 +1,13 @@ #include "pch_script.h" + #include "helicopter.h" #include "script_game_object.h" -#include "xrScriptEngine/ScriptExporter.hpp" int CHelicopter::GetMovementState() { return m_movement.type; } int CHelicopter::GetHuntState() { return m_enemy.type; } int CHelicopter::GetBodyState() { return m_body.type; } -SCRIPT_EXPORT(CHelicopter, (CGameObject), +void CHelicopter::script_register(lua_State* luaState) { using namespace luabind; @@ -100,4 +100,4 @@ SCRIPT_EXPORT(CHelicopter, (CGameObject), .def_readonly("m_exploded", &CHelicopter::m_exploded) .def_readonly("m_dead", &CHelicopter::m_dead) ]; -}); +} diff --git a/src/xrGame/holder_custom.h b/src/xrGame/holder_custom.h index d24f7d5c0e5..ec7af9e64c2 100644 --- a/src/xrGame/holder_custom.h +++ b/src/xrGame/holder_custom.h @@ -65,4 +65,7 @@ class CHolderCustom virtual void Action(u16 id, u32 flags){}; virtual void SetParam(int id, Fvector2 val){}; virtual void SetParam(int id, Fvector val){}; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; diff --git a/src/xrGame/holder_custom_script.cpp b/src/xrGame/holder_custom_script.cpp index b76564cfcac..cec1d0fd783 100644 --- a/src/xrGame/holder_custom_script.cpp +++ b/src/xrGame/holder_custom_script.cpp @@ -1,8 +1,8 @@ #include "pch_script.h" + #include "holder_custom.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CHolderCustom, (), +void CHolderCustom::script_register(lua_State* luaState) { using namespace luabind; @@ -16,4 +16,4 @@ SCRIPT_EXPORT(CHolderCustom, (), .def("SetEnterLocked", &CHolderCustom::SetEnterLocked) .def("SetExitLocked", &CHolderCustom::SetExitLocked) ]; -}); +} diff --git a/src/xrGame/ik/IKLimb.cpp b/src/xrGame/ik/IKLimb.cpp index 327059483ec..c7ec811d483 100644 --- a/src/xrGame/ik/IKLimb.cpp +++ b/src/xrGame/ik/IKLimb.cpp @@ -282,7 +282,7 @@ u16 get_ik_bone(IKinematics* K, LPCSTR S, u16 i) #ifdef DEBUG if (BI_NONE == bone) { - Msg("ik bone: %s does not found in visual: %s", sbone, *smart_cast(K)->getDebugName()); + Msg("ik bone: %s does not found in visual: %s", sbone, smart_cast(K)->getDebugName().c_str()); VERIFY(false); } #endif diff --git a/src/xrGame/ini_id_loader.h b/src/xrGame/ini_id_loader.h index abded7370cf..8297415af14 100644 --- a/src/xrGame/ini_id_loader.h +++ b/src/xrGame/ini_id_loader.h @@ -105,7 +105,7 @@ const ITEM_DATA* CSINI_IdToIndex::GetById(const T_ID& str_id, bool no_assert) if (m_pItemDataVector->end() == it) { - R_ASSERT3(no_assert, "item not found, id", *str_id); + R_ASSERT3(no_assert, "item not found, id", str_id.c_str()); return NULL; } diff --git a/src/xrGame/ini_table_loader.h b/src/xrGame/ini_table_loader.h index 3b3af18bc9b..57277d881f5 100644 --- a/src/xrGame/ini_table_loader.h +++ b/src/xrGame/ini_table_loader.h @@ -111,7 +111,7 @@ typename CSIni_Table::ITEM_TABLE& CSIni_Table::table() (*m_pTable)[cur_index].resize(cur_table_width); for (size_t j = 0; j < cur_table_width; j++) { - (*m_pTable)[cur_index][j] = convert(_GetItem(*(*i).second, (int)j, buffer)); + (*m_pTable)[cur_index][j] = convert(_GetItem(i->second.c_str(), (int)j, buffer)); } } diff --git a/src/xrGame/inventory_item.h b/src/xrGame/inventory_item.h index a615f2b67e7..1c6bd2d9fad 100644 --- a/src/xrGame/inventory_item.h +++ b/src/xrGame/inventory_item.h @@ -18,7 +18,7 @@ #include "xrEngine/pure.h" #endif -enum EHandDependence +enum EHandDependence : u8 { hdNone = 0, hd1Hand = 1, diff --git a/src/xrGame/inventory_upgrade_manager.cpp b/src/xrGame/inventory_upgrade_manager.cpp index 2015076f530..2d93230bd62 100644 --- a/src/xrGame/inventory_upgrade_manager.cpp +++ b/src/xrGame/inventory_upgrade_manager.cpp @@ -183,9 +183,7 @@ void Manager::load_all_properties() if (!pSettings->section_exist(properties_section) && ShadowOfChernobylMode) return; - - VERIFY2( - pSettings->section_exist(properties_section), make_string("Section [%s] does not exist !", properties_section)); + VERIFY2(pSettings->section_exist(properties_section), make_string("Section [%s] does not exist !", properties_section)); VERIFY2(pSettings->line_count(properties_section), make_string("Section [%s] is empty !", properties_section)); CInifile::Sect& inv_section = pSettings->r_section(properties_section); diff --git a/src/xrGame/level_script.cpp b/src/xrGame/level_script.cpp index 17216c8bcc5..be3b5b97661 100644 --- a/src/xrGame/level_script.cpp +++ b/src/xrGame/level_script.cpp @@ -21,22 +21,20 @@ #include "date_time.h" #include "ai_space.h" #include "xrAICore/Navigation/level_graph.h" -#include "PHCommander.h" -#include "PHScriptCall.h" +#include "xrPhysics/PHCommander.h" +#include "xrPhysics/PHScriptCall.h" #include "xrScriptEngine/script_engine.hpp" #include "game_cl_single.h" #include "game_sv_single.h" #include "map_manager.h" #include "map_spot.h" #include "map_location.h" -#include "physics_world_scripted.h" #include "alife_simulator.h" #include "alife_time_manager.h" #include "ui/UIGameTutorial.h" #include "ui/UIInventoryUtilities.h" #include "alife_object_registry.h" #include "xrServer_Objects_ALife_Monsters.h" -#include "xrScriptEngine/ScriptExporter.hpp" #include "HUDManager.h" #include "raypick.h" #include "xrCDB/xr_collide_defs.h" @@ -374,10 +372,6 @@ void remove_calls_for_object(const luabind::object& lua_object) Level().ph_commander_scripts().remove_calls(&c); } -cphysics_world_scripted* physics_world_scripted() -{ - return get_script_wrapper(*physics_world()); -} CEnvironment* environment() { return (g_pGamePersistent->pEnvironment); } CEnvDescriptor* current_environment(CEnvironment* self) { return &self->CurrentEnv; } extern bool g_bDisableAllInput; @@ -709,7 +703,7 @@ void jump_to_level(const Fvector& m_position, u32 m_level_vertex_id, GameGraph:: template struct EnumCallbackType {}; -IC static void CLevel_Export(lua_State* luaState) +void CLevel::script_register(lua_State* luaState) { using namespace luabind; using namespace luabind::policy; @@ -721,6 +715,47 @@ IC static void CLevel_Export(lua_State* luaState) class_("CEnvironment") .def("current", current_environment); + module(luaState) + [ + class_("ray_pick") + .def(constructor<>()) + .def(constructor()) + .def("set_position", &CRayPick::set_position) + .def("set_direction", &CRayPick::set_direction) + .def("set_range", &CRayPick::set_range) + .def("set_flags", &CRayPick::set_flags) + .def("set_ignore_object", &CRayPick::set_ignore_object) + .def("query", &CRayPick::query) + .def("get_result", &CRayPick::get_result) + .def("get_object", &CRayPick::get_object) + .def("get_distance", &CRayPick::get_distance) + .def("get_element", &CRayPick::get_element), + class_("rq_result") + .def_readonly("object", &script_rq_result::O) + .def_readonly("range", &script_rq_result::range) + .def_readonly("element", &script_rq_result::element) + .def(constructor<>()), + class_>("rq_target") + .enum_("targets") + [ + value("rqtNone", int(collide::rqtNone)), + value("rqtObject", int(collide::rqtObject)), + value("rqtStatic", int(collide::rqtStatic)), + value("rqtShape", int(collide::rqtShape)), + value("rqtObstacle", int(collide::rqtObstacle)), + value("rqtBoth", int(collide::rqtBoth)), + value("rqtDyn", int(collide::rqtDyn)) + ], + class_("game_difficulty") + .enum_("game_difficulty") + [ + value("novice", int(egdNovice)), + value("stalker", int(egdStalker)), + value("veteran", int(egdVeteran)), + value("master", int(egdMaster)) + ] + ]; + module(luaState, "level") [ //Alundaio: Extend level namespace exports @@ -742,34 +777,50 @@ IC static void CLevel_Export(lua_State* luaState) // obsolete\deprecated def("object_by_id", get_object_by_id), #ifdef DEBUG - def("debug_object", get_object_by_name), def("debug_actor", tpfGetActor), def("check_object", check_object), + def("debug_object", get_object_by_name), + def("debug_actor", tpfGetActor), + def("check_object", check_object), #endif - def("get_weather", get_weather), def("set_weather", set_weather), def("set_weather_fx", set_weather_fx), - def("start_weather_fx_from_time", start_weather_fx_from_time), def("is_wfx_playing", is_wfx_playing), - def("get_wfx_time", get_wfx_time), def("stop_weather_fx", stop_weather_fx), + def("get_weather", get_weather), + def("set_weather", set_weather), + def("set_weather_fx", set_weather_fx), + def("start_weather_fx_from_time", start_weather_fx_from_time), + def("is_wfx_playing", is_wfx_playing), + def("get_wfx_time", get_wfx_time), + def("stop_weather_fx", stop_weather_fx), def("environment", environment), - def("set_time_factor", set_time_factor), def("get_time_factor", get_time_factor), - - def("set_game_difficulty", set_game_difficulty), def("get_game_difficulty", get_game_difficulty), - - def("get_time_days", get_time_days), def("get_time_hours", get_time_hours), - def("get_time_minutes", get_time_minutes), def("change_game_time", change_game_time), - - def("high_cover_in_direction", high_cover_in_direction), def("low_cover_in_direction", low_cover_in_direction), - def("vertex_in_direction", vertex_in_direction), def("rain_factor", rain_factor), - def("rain_wetness", rain_wetness), def("rain_hemi", rain_hemi), - def("patrol_path_exists", patrol_path_exists), def("vertex_position", vertex_position), + def("set_time_factor", set_time_factor), + def("get_time_factor", get_time_factor), + + def("set_game_difficulty", set_game_difficulty), + def("get_game_difficulty", get_game_difficulty), + + def("get_time_days", get_time_days), + def("get_time_hours", get_time_hours), + def("get_time_minutes", get_time_minutes), + def("change_game_time", change_game_time), + + def("high_cover_in_direction", high_cover_in_direction), + def("low_cover_in_direction", low_cover_in_direction), + def("vertex_in_direction", vertex_in_direction), + def("rain_factor", rain_factor), + def("rain_wetness", rain_wetness), + def("rain_hemi", rain_hemi), + def("patrol_path_exists", patrol_path_exists), + def("vertex_position", vertex_position), def("name", +[]() { return Level().name().c_str(); }), def("prefetch_sound", prefetch_sound), def("client_spawn_manager", get_client_spawn_manager), - def("map_add_object_spot_ser", map_add_object_spot_ser), def("map_add_object_spot", map_add_object_spot), + def("map_add_object_spot_ser", map_add_object_spot_ser), + def("map_add_object_spot", map_add_object_spot), // def("map_add_object_spot_complex", map_add_object_spot_complex), - def("map_remove_object_spot", map_remove_object_spot), def("map_has_object_spot", map_has_object_spot), + def("map_remove_object_spot", map_remove_object_spot), + def("map_has_object_spot", map_has_object_spot), def("map_change_spot_hint", map_change_spot_hint), def("start_stop_menu", start_stop_menu), @@ -779,7 +830,8 @@ IC static void CLevel_Export(lua_State* luaState) def("hide_indicators", hide_indicators), def("hide_indicators_safe", hide_indicators_safe), - def("show_indicators", show_indicators), def("show_weapon", show_weapon), + def("show_indicators", show_indicators), + def("show_weapon", show_weapon), def("add_call", ((void (*)(const luabind::functor&, const luabind::functor&)) & add_call)), def("add_call", ((void (*)(const luabind::object&, const luabind::functor&, const luabind::functor&)) & @@ -793,13 +845,13 @@ IC static void CLevel_Export(lua_State* luaState) def("remove_calls_for_object", remove_calls_for_object), def("present", is_level_present), def("disable_input", disable_input), - def("enable_input", enable_input), def("spawn_phantom", spawn_phantom), + def("enable_input", enable_input), + def("spawn_phantom", spawn_phantom), def("get_bounding_volume", get_bounding_volume), def("iterate_sounds", &iterate_sounds1), def("iterate_sounds", &iterate_sounds2), - def("physics_world", &physics_world_scripted), def("get_snd_volume", &get_snd_volume), def("set_snd_volume", &set_snd_volume), @@ -819,18 +871,14 @@ IC static void CLevel_Export(lua_State* luaState) def("add_complex_effector", &add_complex_effector), def("remove_complex_effector", &remove_complex_effector), - def("game_id", &GameID), - def("ray_pick", &ray_pick) - ]; - - module(luaState, "level") - [ def("vertex_id", +[](Fvector position) -> u64 { // Original luabind converts 4294967295 (which is u32(-1)) to 4294967296 const u32 id = ai().level_graph().vertex_id(position); return id == u32(-1) ? id + 1 : id; // reproduce original behaviour - }) + }), + def("game_id", &GameID), + def("ray_pick", &ray_pick) ]; module(luaState, "actor_stats") @@ -840,44 +888,12 @@ IC static void CLevel_Export(lua_State* luaState) def("get_points", &get_actor_points) ]; - module(luaState) - [ - class_("ray_pick") - .def(constructor<>()) - .def(constructor()) - .def("set_position", &CRayPick::set_position) - .def("set_direction", &CRayPick::set_direction) - .def("set_range", &CRayPick::set_range) - .def("set_flags", &CRayPick::set_flags) - .def("set_ignore_object", &CRayPick::set_ignore_object) - .def("query", &CRayPick::query) - .def("get_result", &CRayPick::get_result) - .def("get_object", &CRayPick::get_object) - .def("get_distance", &CRayPick::get_distance) - .def("get_element", &CRayPick::get_element), - class_("rq_result") - .def_readonly("object", &script_rq_result::O) - .def_readonly("range", &script_rq_result::range) - .def_readonly("element", &script_rq_result::element) - .def(constructor<>()), - class_>("rq_target") - .enum_("targets") - [ - value("rqtNone", int(collide::rqtNone)), - value("rqtObject", int(collide::rqtObject)), - value("rqtStatic", int(collide::rqtStatic)), - value("rqtShape", int(collide::rqtShape)), - value("rqtObstacle", int(collide::rqtObstacle)), - value("rqtBoth", int(collide::rqtBoth)), - value("rqtDyn", int(collide::rqtDyn)) - ] - ]; - module(luaState) [ def("command_line", &command_line), def("IsGameTypeSingle", (bool (*)())&IsGameTypeSingle), - def("IsDynamicMusic", &IsDynamicMusic), def("render_get_dx_level", &render_get_dx_level), + def("IsDynamicMusic", &IsDynamicMusic), + def("render_get_dx_level", &render_get_dx_level), def("IsImportantSave", &IsImportantSave) ]; @@ -887,7 +903,8 @@ IC static void CLevel_Export(lua_State* luaState) def("set_community_goodwill", &g_set_community_goodwill), def("change_community_goodwill", &g_change_community_goodwill), - def("community_relation", &g_get_community_relation), def("set_community_relation", &g_set_community_relation), + def("community_relation", &g_get_community_relation), + def("set_community_relation", &g_set_community_relation), def("get_general_goodwill_between", &g_get_general_goodwill_between) ]; @@ -958,6 +975,4 @@ IC static void CLevel_Export(lua_State* luaState) jump_to_level(m_position, m_level_vertex_id, m_game_vertex_id, {}); }) ]; -}; - -SCRIPT_EXPORT_FUNC(CLevel, (), CLevel_Export); +} diff --git a/src/xrGame/login_manager.h b/src/xrGame/login_manager.h index f7a5b2c7419..c0deda47746 100644 --- a/src/xrGame/login_manager.h +++ b/src/xrGame/login_manager.h @@ -31,11 +31,13 @@ struct profile char const* unique_nick() const { return m_unique_nick.c_str(); }; bool online() const { return m_online; }; GPProfile profile_id() const { return m_profile_id; }; - // copy constructor is valid + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; // struct profile -// typedef fastdelegate::FastDelegate login_operation_cb; -typedef mixed_delegate login_operation_cb; +//using login_operation_cb = fastdelegate::FastDelegate; +using login_operation_cb = mixed_delegate; class login_manager : private Noncopyable { @@ -107,11 +109,14 @@ class login_manager : private Noncopyable static void __cdecl wslogin_cb(GHTTPResult httpResult, WSLoginResponse* response, void* userData); static void __cdecl setunick_cb(GPConnection* connection, void* arg, void* param); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; // class login_manager } // namespace gamespy_gp -typedef gamespy_gp::profile gamespy_gp_profile; -typedef gamespy_gp::login_operation_cb gamespy_gp_login_operation_cb; -typedef gamespy_gp::login_manager gamespy_gp_login_manager; +using gamespy_gp_profile = gamespy_gp::profile; +using gamespy_gp_login_operation_cb = gamespy_gp::login_operation_cb; +using gamespy_gp_login_manager = gamespy_gp::login_manager; #endif //#ifndef LOGIN_MANAGER diff --git a/src/xrGame/login_manager_script.cpp b/src/xrGame/login_manager_script.cpp index ffb747638b8..27bae7b5193 100644 --- a/src/xrGame/login_manager_script.cpp +++ b/src/xrGame/login_manager_script.cpp @@ -1,11 +1,12 @@ #include "StdAfx.h" + #include "login_manager.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(login_manager, (), +namespace gamespy_gp +{ +void login_manager::script_register(lua_State* luaState) { using namespace luabind; - using namespace gamespy_gp; module(luaState) [ @@ -28,12 +29,11 @@ SCRIPT_EXPORT(login_manager, (), .def("forgot_password", &login_manager::forgot_password) ]; -}); +} -SCRIPT_EXPORT(profile, (), +void profile::script_register(lua_State* luaState) { using namespace luabind; - using namespace gamespy_gp; module(luaState) [ @@ -41,19 +41,7 @@ SCRIPT_EXPORT(profile, (), .def("unique_nick", &profile::unique_nick) .def("online", &profile::online) ]; -}); - -SCRIPT_EXPORT(login_operation_cb, (), -{ - using namespace luabind; - using namespace gamespy_gp; +} +} // namespace gamespy_gp - module(luaState) - [ - class_("login_operation_cb") - .def(constructor<>()) - .def(constructor()) - .def("bind", (login_operation_cb::lua_bind_type)(&login_operation_cb::bind)) - .def("clear", &login_operation_cb::clear) - ]; -}); +DEFINE_MIXED_DELEGATE_SCRIPT(gamespy_gp::login_operation_cb, "login_operation_cb"); diff --git a/src/xrGame/map_location.cpp b/src/xrGame/map_location.cpp index f59115257b1..219b4a69185 100644 --- a/src/xrGame/map_location.cpp +++ b/src/xrGame/map_location.cpp @@ -338,7 +338,7 @@ void CMapLocation::CalcLevelName() bool CMapLocation::Update() // returns actual { - R_ASSERT(m_cached.m_updatedFrame != Device.dwFrame); + R_ASSERT1_CURE(m_cached.m_updatedFrame != Device.dwFrame, return m_cached.m_Actuality); if (m_flags.test(eTTL)) { @@ -674,7 +674,8 @@ pcstr CMapLocation::GetHint() const CMapSpotPointer* CMapLocation::GetSpotPointer(CMapSpot* sp) { - R_ASSERT(sp); + R_ASSERT1_CURE(sp, return nullptr); + if (!PointerEnabled()) { return NULL; @@ -697,7 +698,8 @@ CMapSpotPointer* CMapLocation::GetSpotPointer(CMapSpot* sp) CMapSpot* CMapLocation::GetSpotBorder(CMapSpot* sp) { - R_ASSERT(sp); + R_ASSERT1_CURE(sp, return nullptr); + auto& uiXml = CMapManager::m_uiSpotXml; if (PointerEnabled()) { diff --git a/src/xrGame/map_location.h b/src/xrGame/map_location.h index eaf6e5c1bb7..defbe2d37bf 100644 --- a/src/xrGame/map_location.h +++ b/src/xrGame/map_location.h @@ -120,6 +120,9 @@ class CMapLocation : public IPureDestroyableObject #ifdef DEBUG virtual void Dump(){}; #endif + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; class CRelationMapLocation : public CMapLocation diff --git a/src/xrGame/map_manager.h b/src/xrGame/map_manager.h index 7313df07f1b..088cb102ce2 100644 --- a/src/xrGame/map_manager.h +++ b/src/xrGame/map_manager.h @@ -37,4 +37,7 @@ class CMapManager : public CUIResetNotifier void OnUIReset() override; inline static CUIXml m_uiSpotXml; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; diff --git a/src/xrGame/map_script.cpp b/src/xrGame/map_script.cpp index 9cf1daa9f30..4fe0cdca7a7 100644 --- a/src/xrGame/map_script.cpp +++ b/src/xrGame/map_script.cpp @@ -1,9 +1,9 @@ #include "pch_script.h" + #include "map_location.h" #include "map_manager.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CMapManager, (), +void CMapManager::script_register(lua_State* luaState) { using namespace luabind; @@ -15,9 +15,9 @@ SCRIPT_EXPORT(CMapManager, (), .def("RemoveMapLocation", (void (CMapManager::*)(CMapLocation*))&CMapManager::RemoveMapLocation) .def("DisableAllPointers", &CMapManager::DisableAllPointers) ]; -}); +} -SCRIPT_EXPORT(CMapLocation, (), +void CMapLocation::script_register(lua_State* luaState) { using namespace luabind; @@ -50,4 +50,4 @@ SCRIPT_EXPORT(CMapLocation, (), .def("ObjectID", &CMapLocation::ObjectID) .def("GetLastPosition", &CMapLocation::GetLastPosition) ]; -}); +} diff --git a/src/xrGame/memory_space.h b/src/xrGame/memory_space.h index 86c68034d6f..7a5cbe4bdc4 100644 --- a/src/xrGame/memory_space.h +++ b/src/xrGame/memory_space.h @@ -189,6 +189,9 @@ struct CMemoryInfo : public CVisibleObject m_sound_info = false; m_hit_info = false; } + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; template diff --git a/src/xrGame/memory_space_script.cpp b/src/xrGame/memory_space_script.cpp index 6a7d04902be..30e7df60484 100644 --- a/src/xrGame/memory_space_script.cpp +++ b/src/xrGame/memory_space_script.cpp @@ -7,12 +7,12 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "memory_space.h" #include "script_game_object.h" #include "GameObject.h" #include "entity_alive.h" #include "danger_object.h" -#include "xrScriptEngine/ScriptExporter.hpp" CScriptGameObject* not_yet_visible_object(const MemorySpace::CNotYetVisibleObject& object) { @@ -48,7 +48,7 @@ Fvector CDangerObject__position(const CDangerObject* self) return (self->position()); } -IC static void CMemoryInfo_Export(lua_State* luaState) +void CMemoryInfo::script_register(lua_State* luaState) { using namespace luabind; @@ -150,5 +150,3 @@ IC static void CMemoryInfo_Export(lua_State* luaState) .def("dependent_object", &CDangerObject_dependent_object) ]; } - -SCRIPT_EXPORT_FUNC(CMemoryInfo, (), CMemoryInfo_Export); diff --git a/src/xrGame/mincer_script.cpp b/src/xrGame/mincer_script.cpp index 9da5e6c9b46..fc491df3951 100644 --- a/src/xrGame/mincer_script.cpp +++ b/src/xrGame/mincer_script.cpp @@ -1,9 +1,9 @@ #include "pch_script.h" + #include "Mincer.h" #include "RadioactiveZone.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CMincer, (CGameObject), +void CMincer::script_register(lua_State* luaState) { using namespace luabind; @@ -14,4 +14,4 @@ SCRIPT_EXPORT(CMincer, (CGameObject), class_("CRadioactiveZone") .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/mixed_delegate.h b/src/xrGame/mixed_delegate.h index feae1eb3581..4d60c10d2ae 100644 --- a/src/xrGame/mixed_delegate.h +++ b/src/xrGame/mixed_delegate.h @@ -91,6 +91,24 @@ class mixed_delegate private: fastdelegate_type m_cpp_delegate; lua_delegate_type m_lua_delegate; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; // class mixed_delegate +#define DEFINE_MIXED_DELEGATE_SCRIPT(type, name_str) \ + template <> \ + void type::script_register(lua_State* luaState) \ + { \ + using namespace luabind; \ + module(luaState) \ + [ \ + class_(name_str)\ + .def( constructor<>()) \ + .def( constructor()) \ + .def("bind", (type::lua_bind_type)(&type::bind)) \ + .def("clear", &type::clear) \ + ]; \ + } + #endif //#ifndef MIXED_DELEGATE_INCLUDED diff --git a/src/xrGame/particle_params.h b/src/xrGame/particle_params.h index b4ac015e54e..c6d3f752a48 100644 --- a/src/xrGame/particle_params.h +++ b/src/xrGame/particle_params.h @@ -18,5 +18,8 @@ struct CParticleParams final : m_tParticlePosition(tPositionOffset), m_tParticleAngles(tAnglesOffset), m_tParticleVelocity(tVelocity) {} void initialize() {} + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; diff --git a/src/xrGame/particle_params_script.cpp b/src/xrGame/particle_params_script.cpp index 529d3846b65..af7e1fa82ab 100644 --- a/src/xrGame/particle_params_script.cpp +++ b/src/xrGame/particle_params_script.cpp @@ -7,10 +7,10 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "particle_params.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CParticleParams, (), +void CParticleParams::script_register(lua_State* luaState) { using namespace luabind; @@ -22,4 +22,4 @@ SCRIPT_EXPORT(CParticleParams, (), .def(constructor()) .def(constructor()) ]; -}); +} diff --git a/src/xrGame/physics_element_scripted.cpp b/src/xrGame/physics_element_scripted.cpp deleted file mode 100644 index a82eb6bf559..00000000000 --- a/src/xrGame/physics_element_scripted.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "pch_script.h" -#include "physics_element_scripted.h" -#include "xrScriptEngine/ScriptExporter.hpp" - -Fmatrix global_transform(cphysics_element_scripted* E) -{ - Fmatrix m; - E->GetGlobalTransformDynamic(&m); - return m; -} - -SCRIPT_EXPORT(cphysics_element_scripted, (), -{ - using namespace luabind; - - module(luaState) - [ - class_("physics_element") - .def("apply_force", (void (cphysics_element_scripted::*)(float, float, float))( - &cphysics_element_scripted::applyForce)) - .def("is_breakable", &cphysics_element_scripted::isBreakable) - .def("get_linear_vel", &cphysics_element_scripted::get_LinearVel) - .def("get_angular_vel", &cphysics_element_scripted::get_AngularVel) - .def("get_mass", &cphysics_element_scripted::getMass) - .def("get_density", &cphysics_element_scripted::getDensity) - .def("get_volume", &cphysics_element_scripted::getVolume) - .def("fix", &cphysics_element_scripted::Fix) - .def("release_fixed", &cphysics_element_scripted::ReleaseFixed) - .def("is_fixed", &cphysics_element_scripted::isFixed) - .def("global_transform", &global_transform) - ]; -}); diff --git a/src/xrGame/physics_element_scripted.h b/src/xrGame/physics_element_scripted.h deleted file mode 100644 index 0911cd9fefa..00000000000 --- a/src/xrGame/physics_element_scripted.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once -#include "xrPhysics/iphysics_scripted.h" -#include "xrPhysics/PhysicsShell.h" - -class CPhysicsElement; - -class cphysics_element_scripted : public cphysics_game_scripted -{ -public: - cphysics_element_scripted(CPhysicsElement* imp) : cphysics_game_scripted(imp) {} - void applyForce(float x, float y, float z) { physics_impl().applyForce(x, y, z); } - bool isBreakable() { return physics_impl().isBreakable(); } - void get_LinearVel(Fvector& velocity) const { physics_impl().get_LinearVel(velocity); } - void get_AngularVel(Fvector& velocity) const { physics_impl().get_AngularVel(velocity); } - float getMass() { return physics_impl().getMass(); } - float getDensity() { return physics_impl().getDensity(); } - float getVolume() { return physics_impl().getVolume(); } - void Fix() { physics_impl().Fix(); } - void ReleaseFixed() { physics_impl().ReleaseFixed(); } - bool isFixed() { return physics_impl().isFixed(); } - void GetGlobalTransformDynamic(Fmatrix* m) const { physics_impl().GetGlobalTransformDynamic(m); } -}; diff --git a/src/xrGame/physics_game.cpp b/src/xrGame/physics_game.cpp index ca9ce08f101..51c324f059b 100644 --- a/src/xrGame/physics_game.cpp +++ b/src/xrGame/physics_game.cpp @@ -9,11 +9,11 @@ #include "xrPhysics/PhysicsExternalCommon.h" #include "PHSoundPlayer.h" #include "PhysicsShellHolder.h" -#include "PHCommander.h" +#include "xrPhysics/PHCommander.h" #include "xrPhysics/MathUtils.h" #include "xrPhysics/IPHWorld.h" -#include "PHReqComparer.h" +#include "xrPhysics/PHReqComparer.h" #include "Include/xrRender/FactoryPtr.h" #include "Include/xrRender/WallMarkArray.h" diff --git a/src/xrGame/physics_joint_scripted.cpp b/src/xrGame/physics_joint_scripted.cpp deleted file mode 100644 index 36b0ad4b406..00000000000 --- a/src/xrGame/physics_joint_scripted.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include "pch_script.h" -#include "physics_joint_scripted.h" -#include "physics_element_scripted.h" -#include "xrScriptEngine/ScriptExporter.hpp" - -cphysics_element_scripted* cphysics_joint_scripted::PFirst_element() -{ - CPhysicsElement* E = physics_impl().PFirst_element(); - if (!E) - return 0; - return get_script_wrapper(*E); -} - -cphysics_element_scripted* cphysics_joint_scripted::PSecond_element() -{ - CPhysicsElement* E = physics_impl().PSecond_element(); - if (!E) - return 0; - return get_script_wrapper(*E); -} - -SCRIPT_EXPORT(cphysics_joint_scripted, (), -{ - using namespace luabind; - using namespace luabind::policy; - - constexpr auto out_value_23 = policy_list, out_value<3>>(); - - module(luaState) - [ - class_("physics_joint") - .def("get_bone_id", &cphysics_joint_scripted::BoneID) - .def("get_first_element", &cphysics_joint_scripted::PFirst_element) - .def("get_stcond_element", &cphysics_joint_scripted::PSecond_element) - .def("set_anchor_global", &cphysics_joint_scripted::SetAnchor) - .def("set_anchor_vs_first_element", &cphysics_joint_scripted::SetAnchorVsFirstElement) - .def("set_anchor_vs_second_element", &cphysics_joint_scripted::SetAnchorVsSecondElement) - .def("get_axes_number", &cphysics_joint_scripted::GetAxesNumber) - .def("set_axis_spring_dumping_factors", &cphysics_joint_scripted::SetAxisSDfactors) - .def("set_joint_spring_dumping_factors", &cphysics_joint_scripted::SetJointSDfactors) - .def("set_axis_dir_global", &cphysics_joint_scripted::SetAxisDir) - .def("set_axis_dir_vs_first_element", &cphysics_joint_scripted::SetAxisDirVsFirstElement) - .def("set_axis_dir_vs_second_element", &cphysics_joint_scripted::SetAxisDirVsSecondElement) - .def("set_limits", &cphysics_joint_scripted::SetLimits) - .def("set_max_force_and_velocity", &cphysics_joint_scripted::SetForceAndVelocity) - .def("get_max_force_and_velocity", &cphysics_joint_scripted::GetMaxForceAndVelocity, out_value_23) - .def("get_axis_angle", &cphysics_joint_scripted::GetAxisAngle) - .def("get_limits", &cphysics_joint_scripted::GetLimits, out_value_23) - .def("get_axis_dir", &cphysics_joint_scripted::GetAxisDirDynamic) - .def("get_anchor", &cphysics_joint_scripted::GetAnchorDynamic) - .def("is_breakable", &cphysics_joint_scripted::isBreakable) - ]; -}); diff --git a/src/xrGame/physics_joint_scripted.h b/src/xrGame/physics_joint_scripted.h deleted file mode 100644 index dd183aeda71..00000000000 --- a/src/xrGame/physics_joint_scripted.h +++ /dev/null @@ -1,73 +0,0 @@ -#pragma once - -#include "xrPhysics/iphysics_scripted.h" -#include "xrPhysics/PhysicsShell.h" - -class cphysics_element_scripted; -class CPhysicsJoint; - -class cphysics_joint_scripted : public cphysics_game_scripted -{ -public: - cphysics_joint_scripted(CPhysicsJoint* imp) : cphysics_game_scripted(imp) {} - u16 BoneID() { return physics_impl().BoneID(); } - cphysics_element_scripted* PFirst_element(); - cphysics_element_scripted* PSecond_element(); - - u16 GetAxesNumber() { return physics_impl().GetAxesNumber(); } - void SetAxisSDfactors(float spring_factor, float damping_factor, int axis_num) - { - physics_impl().SetAxisSDfactors(spring_factor, damping_factor, axis_num); - } - void SetJointSDfactors(float spring_factor, float damping_factor) - { - physics_impl().SetJointSDfactors(spring_factor, damping_factor); - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SetAnchor(const float x, const float y, const float z) { physics_impl().SetAnchor(x, y, z); } - void SetAnchorVsFirstElement(const float x, const float y, const float z) - { - physics_impl().SetAnchorVsFirstElement(x, y, z); - } - void SetAnchorVsSecondElement(const float x, const float y, const float z) - { - physics_impl().SetAnchorVsSecondElement(x, y, z); - } - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SetAxisDir(const float x, const float y, const float z, const int axis_num) - { - physics_impl().SetAxisDir(x, y, z, axis_num); - } - void SetAxisDirVsFirstElement(const float x, const float y, const float z, const int axis_num) - { - physics_impl().SetAxisDirVsFirstElement(x, y, z, axis_num); - } - void SetAxisDirVsSecondElement(const float x, const float y, const float z, const int axis_num) - { - physics_impl().SetAxisDirVsSecondElement(x, y, z, axis_num); - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SetLimits(const float low, const float high, const int axis_num) - { - physics_impl().SetLimits(low, high, axis_num); - } - - void SetForceAndVelocity(const float force, const float velocity = 0.f, const int axis_num = -1) - { - physics_impl().SetForceAndVelocity(force, velocity, axis_num); - } - void GetMaxForceAndVelocity(float& force, float& velocity, int axis_num) - { - physics_impl().GetMaxForceAndVelocity(force, velocity, axis_num); - } - float GetAxisAngle(int axis_num) { return physics_impl().GetAxisAngle(axis_num); } - void GetLimits(float& lo_limit, float& hi_limit, int axis_num) - { - physics_impl().GetLimits(lo_limit, hi_limit, axis_num); - } - void GetAxisDirDynamic(int num, Fvector& axis) { physics_impl().GetAxisDirDynamic(num, axis); } - void GetAnchorDynamic(Fvector& anchor) { physics_impl().GetAnchorDynamic(anchor); } - bool isBreakable() { return physics_impl().isBreakable(); } -}; diff --git a/src/xrGame/physics_shell_scripted.cpp b/src/xrGame/physics_shell_scripted.cpp deleted file mode 100644 index 88bf2e89516..00000000000 --- a/src/xrGame/physics_shell_scripted.cpp +++ /dev/null @@ -1,150 +0,0 @@ -#include "pch_script.h" -#include "physics_shell_scripted.h" -#include "physics_element_scripted.h" -#include "physics_joint_scripted.h" -#include "xrScriptEngine/ScriptExporter.hpp" - -cphysics_element_scripted* cphysics_shell_scripted::get_Element(LPCSTR bone_name) -{ - CPhysicsElement* E = physics_impl().get_Element(bone_name); - if (!E) - return 0; - return get_script_wrapper(*E); -} -cphysics_element_scripted* cphysics_shell_scripted::get_Element(u16 bone_id) -{ - CPhysicsElement* E = physics_impl().get_Element(bone_id); - if (!E) - return 0; - return get_script_wrapper(*E); -} - -cphysics_element_scripted* cphysics_shell_scripted::get_ElementByStoreOrder(u16 idx) -{ - CPhysicsElement* E = physics_impl().get_ElementByStoreOrder(idx); - R_ASSERT(E); - return get_script_wrapper(*E); -} - -cphysics_joint_scripted* cphysics_shell_scripted::get_Joint(LPCSTR bone_name) -{ - CPhysicsJoint* J = physics_impl().get_Joint(bone_name); - if (!J) - return 0; - return get_script_wrapper(*J); -} - -cphysics_joint_scripted* cphysics_shell_scripted::get_Joint(u16 bone_id) -{ - CPhysicsJoint* J = physics_impl().get_Joint(bone_id); - if (!J) - return 0; - return get_script_wrapper(*J); -} -cphysics_joint_scripted* cphysics_shell_scripted::get_JointByStoreOrder(u16 idx) -{ - CPhysicsJoint* J = physics_impl().get_JointByStoreOrder(idx); - R_ASSERT(J); - return get_script_wrapper(*J); -} - -SCRIPT_EXPORT(cphysics_shell_scripted, (), -{ - using namespace luabind; - - module(luaState) - [ - class_("physics_shell") - .def("apply_force", (void (cphysics_shell_scripted::*)(float, float, float))( - &cphysics_shell_scripted::applyForce)) - .def("get_element_by_bone_name", - (cphysics_element_scripted * (cphysics_shell_scripted::*)(LPCSTR))( - &cphysics_shell_scripted::get_Element)) - .def("get_element_by_bone_id", (cphysics_element_scripted * (cphysics_shell_scripted::*)(u16))( - &cphysics_shell_scripted::get_Element)) - .def("get_element_by_order", (cphysics_element_scripted * (cphysics_shell_scripted::*)(u16))( - &cphysics_shell_scripted::get_ElementByStoreOrder)) - .def("get_elements_number", &cphysics_shell_scripted::get_ElementsNumber) - .def("get_joint_by_bone_name", (cphysics_joint_scripted * (cphysics_shell_scripted::*)(LPCSTR))( - &cphysics_shell_scripted::get_Joint)) - .def("get_joint_by_bone_id", (cphysics_joint_scripted * (cphysics_shell_scripted::*)(u16))( - &cphysics_shell_scripted::get_Joint)) - .def("get_joint_by_order", &cphysics_shell_scripted::get_JointByStoreOrder) - .def("get_joints_number", &cphysics_shell_scripted::get_JointsNumber) - .def("block_breaking", &cphysics_shell_scripted::BlockBreaking) - .def("unblock_breaking", &cphysics_shell_scripted::UnblockBreaking) - .def("is_breaking_blocked", &cphysics_shell_scripted::IsBreakingBlocked) - .def("is_breakable", &cphysics_shell_scripted::isBreakable) - .def("get_linear_vel", &cphysics_shell_scripted::get_LinearVel) - .def("get_angular_vel", &cphysics_shell_scripted::get_AngularVel) - ]; -}); - -/* -Fmatrix global_transform(CPhysicsElement* E) -{ - Fmatrix m; - E->GetGlobalTransformDynamic(&m); - return m; -} - -SCRIPT_EXPORT(CPhysicsElement, (), -{ - using namespace luabind; - - module(luaState) - [ - class_("physics_element") - .def("apply_force", (void -(CPhysicsElement::*)(float,float,float))(&CPhysicsElement::applyForce)) - .def("is_breakable", &CPhysicsElement::isBreakable) - .def("get_linear_vel", &CPhysicsElement::get_LinearVel) - .def("get_angular_vel", &CPhysicsElement::get_AngularVel) - .def("get_mass", &CPhysicsElement::getMass) - .def("get_density", &CPhysicsElement::getDensity) - .def("get_volume", &CPhysicsElement::getVolume) - .def("fix", &CPhysicsElement::Fix) - .def("release_fixed", &CPhysicsElement::ReleaseFixed) - .def("is_fixed", &CPhysicsElement::isFixed) - .def("global_transform", &global_transform) - ]; -}); - -SCRIPT_EXPORT(CPhysicsJoint, (), -{ - using namespace luabind; - - module(luaState) - [ - class_("physics_joint") - .def("get_bone_id", &CPhysicsJoint::BoneID) - .def("get_first_element", &CPhysicsJoint::PFirst_element) - .def("get_stcond_element", &CPhysicsJoint::PSecond_element) - .def("set_anchor_global", (void(CPhysicsJoint::*)(const float,const float,const -float))(&CPhysicsJoint::SetAnchor)) - .def("set_anchor_vs_first_element", (void(CPhysicsJoint::*)(const float,const float,const -float))(&CPhysicsJoint::SetAnchorVsFirstElement)) - .def("set_anchor_vs_second_element", (void(CPhysicsJoint::*)(const float,const float,const -float))(&CPhysicsJoint::SetAnchorVsSecondElement)) - .def("get_axes_number", &CPhysicsJoint::GetAxesNumber) - .def("set_axis_spring_dumping_factors", &CPhysicsJoint::SetAxisSDfactors) - .def("set_joint_spring_dumping_factors", &CPhysicsJoint::SetJointSDfactors) - .def("set_axis_dir_global", (void(CPhysicsJoint::*)(const float,const float,const float,const -int ))(&CPhysicsJoint::SetAxisDir)) - .def("set_axis_dir_vs_first_element", (void(CPhysicsJoint::*)(const float,const float,const float,const -int ))(&CPhysicsJoint::SetAxisDirVsFirstElement)) - .def("set_axis_dir_vs_second_element", (void(CPhysicsJoint::*)(const float,const float,const float,const -int ))(&CPhysicsJoint::SetAxisDirVsSecondElement)) - .def("set_limits", &CPhysicsJoint::SetLimits) - .def("set_max_force_and_velocity", &CPhysicsJoint::SetForceAndVelocity) - .def("get_max_force_and_velocity", &CPhysicsJoint::GetMaxForceAndVelocity) - .def("get_axis_angle", &CPhysicsJoint::GetAxisAngle) - .def("get_limits", &CPhysicsJoint::GetLimits, policy_list, -out_value<3>>()) - .def("get_axis_dir", &CPhysicsJoint::GetAxisDirDynamic) - .def("get_anchor", &CPhysicsJoint::GetAnchorDynamic) - .def("is_breakable", &CPhysicsJoint::isBreakable) - ]; -}); - -*/ diff --git a/src/xrGame/physics_shell_scripted.h b/src/xrGame/physics_shell_scripted.h deleted file mode 100644 index 7cef99754f8..00000000000 --- a/src/xrGame/physics_shell_scripted.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include "xrPhysics/iphysics_scripted.h" -#include "xrPhysics/PhysicsShell.h" - -class CPhysicsShell; -class cphysics_element_scripted; -class cphysics_joint_scripted; - -class cphysics_shell_scripted : public cphysics_game_scripted -{ -public: - cphysics_shell_scripted(CPhysicsShell* imp) : cphysics_game_scripted(imp) {} - void applyForce(float x, float y, float z) { physics_impl().applyForce(x, y, z); } - cphysics_element_scripted* get_Element(LPCSTR bone_name); - cphysics_element_scripted* get_Element(u16 bone_id); - cphysics_element_scripted* get_ElementByStoreOrder(u16 idx); - - u16 get_ElementsNumber() { return physics_impl().get_ElementsNumber(); } - cphysics_joint_scripted* get_Joint(LPCSTR bone_name); - cphysics_joint_scripted* get_Joint(u16 bone_id); - cphysics_joint_scripted* get_JointByStoreOrder(u16 idx); - - //&cphysics_shell_scripted::get_JointByStoreOrder) - - u16 get_JointsNumber() { return physics_impl().get_JointsNumber(); } - void BlockBreaking() { physics_impl().BlockBreaking(); } - void UnblockBreaking() { physics_impl().UnblockBreaking(); } - bool IsBreakingBlocked() { return physics_impl().IsBreakingBlocked(); } - bool isBreakable() { return physics_impl().isBreakable(); } - void get_LinearVel(Fvector& velocity) const { physics_impl().get_LinearVel(velocity); } - void get_AngularVel(Fvector& velocity) const { physics_impl().get_AngularVel(velocity); } -}; diff --git a/src/xrGame/physics_world_scripted.cpp b/src/xrGame/physics_world_scripted.cpp deleted file mode 100644 index 13c3a64f610..00000000000 --- a/src/xrGame/physics_world_scripted.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "pch_script.h" -#include "physics_world_scripted.h" -#include "Level.h" -#include "PHCommander.h" -#include "xrScriptEngine/ScriptExporter.hpp" - -void cphysics_world_scripted::AddCall(CPHCondition* c, CPHAction* a) -{ - Level().ph_commander_physics_worldstep().add_call_threadsafety(c, a); -} - -SCRIPT_EXPORT(cphysics_world_scripted, (), -{ - using namespace luabind; - - module(luaState) - [ - class_("physics_world") - .def("set_gravity", &cphysics_world_scripted::SetGravity) - .def("gravity", &cphysics_world_scripted::Gravity) - .def("add_call", &cphysics_world_scripted::AddCall) - ]; -}); diff --git a/src/xrGame/physics_world_scripted.h b/src/xrGame/physics_world_scripted.h deleted file mode 100644 index 0eeadde4e6f..00000000000 --- a/src/xrGame/physics_world_scripted.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include "xrPhysics/iphysics_scripted.h" -#include "xrPhysics/IPHWorld.h" - -class CPHCondition; -class CPHAction; - -class cphysics_world_scripted : public cphysics_game_scripted -{ -public: - cphysics_world_scripted(IPHWorld* imp) : cphysics_game_scripted(imp) {} - float Gravity() { return physics_impl().Gravity(); } - void SetGravity(float g) { return physics_impl().SetGravity(g); } - void AddCall(CPHCondition* c, CPHAction* a); -}; diff --git a/src/xrGame/player_hud.cpp b/src/xrGame/player_hud.cpp index 43852792303..317a090d1c9 100644 --- a/src/xrGame/player_hud.cpp +++ b/src/xrGame/player_hud.cpp @@ -11,7 +11,7 @@ player_hud* g_player_hud = nullptr; extern ENGINE_API shared_str current_player_hud_sect; -// clang-format off + // --#SM+# Begin-- constexpr float PITCH_OFFSET_R = 0.0f; // ÐаÑколько Ñильно Ñтвол ÑмещаетÑÑ Ð²Ð±Ð¾Ðº (влево) при вертикальных поворотах камеры constexpr float PITCH_OFFSET_N = 0.0f; // ÐаÑколько Ñильно Ñтвол поднимаетÑÑ\опуÑкаетÑÑ Ð¿Ñ€Ð¸ вертикальных поворотах камеры @@ -22,7 +22,6 @@ constexpr float ORIGIN_OFFSET_AIM = -0.03f; // (Ð”Ð»Ñ Ð¿Ñ€Ð¸Ñ†ÐµÐ»Ð¸Ð²Ð°Ð½Ð¸Ñ) constexpr float TENDTO_SPEED = 5.f; // СкороÑть нормализации Ð¿Ð¾Ð»Ð¾Ð¶ÐµÐ½Ð¸Ñ Ñтвола constexpr float TENDTO_SPEED_AIM = 8.f; // (Ð”Ð»Ñ Ð¿Ñ€Ð¸Ñ†ÐµÐ»Ð¸Ð²Ð°Ð½Ð¸Ñ) // --#SM+# End-- -// clang-format on float CalcMotionSpeed(const shared_str& anim_name, const float anim_speed) { diff --git a/src/xrGame/profile_data_types_script.cpp b/src/xrGame/profile_data_types_script.cpp index 01ab1179d81..e5690ac8f68 100644 --- a/src/xrGame/profile_data_types_script.cpp +++ b/src/xrGame/profile_data_types_script.cpp @@ -1,12 +1,13 @@ #include "StdAfx.h" + #include "profile_data_types.h" -#include "xrScriptEngine/ScriptExporter.hpp" #include "profile_data_types_script.h" -SCRIPT_EXPORT(profile_data_script_registrator, (), +namespace gamespy_profile +{ +void profile_data_script_registrator::script_register(lua_State* luaState) { using namespace luabind; - using namespace gamespy_profile; module(luaState) [ @@ -22,20 +23,6 @@ SCRIPT_EXPORT(profile_data_script_registrator, (), .def_readonly("first", &all_best_scores_t::value_type::first) .def_readonly("second", &all_best_scores_t::value_type::second) ]; -}); - -SCRIPT_EXPORT(store_operation_cb, (), -{ - using namespace luabind; - using namespace gamespy_profile; - - module(luaState) - [ - class_("store_operation_cb") - .def(constructor<>()) - .def(constructor()) - .def("bind", (store_operation_cb::lua_bind_type)(&store_operation_cb::bind)) - .def("clear", &store_operation_cb::clear) - ]; -}); +} +} // namespace gamespy_profile +DEFINE_MIXED_DELEGATE_SCRIPT(gamespy_profile::store_operation_cb, "store_operation_cb"); diff --git a/src/xrGame/profile_data_types_script.h b/src/xrGame/profile_data_types_script.h index 4f193b7cab3..2ce7d1a357e 100644 --- a/src/xrGame/profile_data_types_script.h +++ b/src/xrGame/profile_data_types_script.h @@ -11,4 +11,9 @@ namespace gamespy_profile { using store_operation_cb = mixed_delegate; + +class profile_data_script_registrator +{ + DECLARE_SCRIPT_REGISTER_FUNCTION(); +}; } diff --git a/src/xrGame/profile_store.h b/src/xrGame/profile_store.h index ac59ee12948..f4e81fc9eb8 100644 --- a/src/xrGame/profile_store.h +++ b/src/xrGame/profile_store.h @@ -22,5 +22,8 @@ class profile_store // These are dummies all_awards_t m_awards; all_best_scores_t m_best_scores; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; // class profile_store } // namespace gamespy_profile diff --git a/src/xrGame/profile_store_script.cpp b/src/xrGame/profile_store_script.cpp index c1bb703fe5c..9fd52b9474f 100644 --- a/src/xrGame/profile_store_script.cpp +++ b/src/xrGame/profile_store_script.cpp @@ -1,8 +1,10 @@ #include "StdAfx.h" + #include "profile_store.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(profile_store, (), +namespace gamespy_profile +{ +void profile_store::script_register(lua_State* luaState) { using namespace luabind; using namespace luabind::policy; @@ -33,4 +35,5 @@ SCRIPT_EXPORT(profile_store, (), value("bst_score_types_count", int(bst_score_types_count)) ] ]; -}); +} +} // namespace gamespy_profile diff --git a/src/xrGame/property_evaluator.h b/src/xrGame/property_evaluator.h index d69f2d25304..b0421e62032 100644 --- a/src/xrGame/property_evaluator.h +++ b/src/xrGame/property_evaluator.h @@ -17,8 +17,8 @@ template class CPropertyEvaluator { public: - typedef GraphEngineSpace::_solver_condition_type _condition_type; - typedef GraphEngineSpace::_solver_value_type _value_type; + using _condition_type = GraphEngineSpace::_solver_condition_type; + using _value_type = GraphEngineSpace::_solver_value_type; public: _object_type* m_object; @@ -39,6 +39,12 @@ class CPropertyEvaluator virtual void save(NET_Packet& packet) {} virtual void load(IReader& packet) {} }; -typedef CPropertyEvaluator CScriptPropertyEvaluator; + +using CScriptPropertyEvaluator = CPropertyEvaluator; + +struct CScriptPropertyEvaluatorExport +{ + DECLARE_SCRIPT_REGISTER_FUNCTION(); +}; #include "property_evaluator_inline.h" diff --git a/src/xrGame/property_evaluator_script.cpp b/src/xrGame/property_evaluator_script.cpp index bf031b83274..eba2642b70d 100644 --- a/src/xrGame/property_evaluator_script.cpp +++ b/src/xrGame/property_evaluator_script.cpp @@ -7,12 +7,12 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "script_property_evaluator_wrapper.h" #include "script_game_object.h" #include "property_evaluator_const.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CScriptPropertyEvaluator, (), +void CScriptPropertyEvaluatorExport::script_register(lua_State* luaState) { using namespace luabind; @@ -33,4 +33,4 @@ SCRIPT_EXPORT(CScriptPropertyEvaluator, (), class_, CScriptPropertyEvaluator>("property_evaluator_const") .def(constructor::_value_type>()) ]; -}); +} diff --git a/src/xrGame/property_storage.h b/src/xrGame/property_storage.h index b326a0ab8ea..3a256041f8e 100644 --- a/src/xrGame/property_storage.h +++ b/src/xrGame/property_storage.h @@ -25,6 +25,9 @@ class CPropertyStorage IC void clear(); IC void set_property(const _condition_type& condition_id, const _value_type& value); IC const _value_type& property(const _condition_type& condition_id) const; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #include "property_storage_inline.h" diff --git a/src/xrGame/property_storage_inline.h b/src/xrGame/property_storage_inline.h index 5ad4fb3902d..582024aa07a 100644 --- a/src/xrGame/property_storage_inline.h +++ b/src/xrGame/property_storage_inline.h @@ -7,7 +7,6 @@ //////////////////////////////////////////////////////////////////////////// #pragma once -#include "xrScriptEngine/DebugMacros.hpp" IC void CPropertyStorage::set_property(const _condition_type& condition_id, const _value_type& value) { diff --git a/src/xrGame/property_storage_script.cpp b/src/xrGame/property_storage_script.cpp index 8c3661be505..42426ff4766 100644 --- a/src/xrGame/property_storage_script.cpp +++ b/src/xrGame/property_storage_script.cpp @@ -7,10 +7,10 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "property_storage.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CPropertyStorage, (), +void CPropertyStorage::script_register(lua_State* luaState) { using namespace luabind; @@ -21,4 +21,4 @@ SCRIPT_EXPORT(CPropertyStorage, (), .def("set_property", &CPropertyStorage::set_property) .def("property", &CPropertyStorage::property) ]; -}); +} diff --git a/src/xrGame/saved_game_wrapper.h b/src/xrGame/saved_game_wrapper.h index d85d836ebbe..fed7448aaa1 100644 --- a/src/xrGame/saved_game_wrapper.h +++ b/src/xrGame/saved_game_wrapper.h @@ -33,6 +33,9 @@ class CSavedGameWrapper inline const _LEVEL_ID& level_id() const; inline LPCSTR level_name() const; inline const float& actor_health() const; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #include "saved_game_wrapper_inline.h" diff --git a/src/xrGame/saved_game_wrapper_script.cpp b/src/xrGame/saved_game_wrapper_script.cpp index 7d94e25ab3c..1e4004467fa 100644 --- a/src/xrGame/saved_game_wrapper_script.cpp +++ b/src/xrGame/saved_game_wrapper_script.cpp @@ -7,15 +7,12 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "saved_game_wrapper.h" #include "ai_space.h" -#include "xrAICore/Navigation/game_graph.h" #include "xr_time.h" -#include "xrScriptEngine/ScriptExporter.hpp" - -xrTime CSavedGameWrapper__game_time(const CSavedGameWrapper* self) { return (xrTime(self->game_time())); } -SCRIPT_EXPORT(CSavedGameWrapper, (), +void CSavedGameWrapper::script_register(lua_State* luaState) { using namespace luabind; @@ -23,11 +20,14 @@ SCRIPT_EXPORT(CSavedGameWrapper, (), [ class_("CSavedGameWrapper") .def(constructor()) - .def("game_time", &CSavedGameWrapper__game_time) + .def("game_time", +[](const CSavedGameWrapper* self) + { + return (xrTime(self->game_time())); + }) .def("level_id", &CSavedGameWrapper::level_id) .def("level_name", &CSavedGameWrapper::level_name) .def("actor_health", &CSavedGameWrapper::actor_health), def("valid_saved_game", (bool (*)(pcstr))(&CSavedGameWrapper::valid_saved_game)) ]; -}); +} diff --git a/src/xrGame/script_action_condition.h b/src/xrGame/script_action_condition.h index 0959dfe7d9f..997724dc5df 100644 --- a/src/xrGame/script_action_condition.h +++ b/src/xrGame/script_action_condition.h @@ -34,6 +34,9 @@ class CScriptActionCondition final IC CScriptActionCondition() = default; IC CScriptActionCondition(u32 dwFlags, double dTime = -1); IC void initialize(); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #include "script_action_condition_inline.h" diff --git a/src/xrGame/script_action_condition_script.cpp b/src/xrGame/script_action_condition_script.cpp index 5feb6a7ddd5..edcf6ea2423 100644 --- a/src/xrGame/script_action_condition_script.cpp +++ b/src/xrGame/script_action_condition_script.cpp @@ -7,10 +7,10 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "script_action_condition.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CScriptActionCondition, (), +void CScriptActionCondition::script_register(lua_State* luaState) { using namespace luabind; @@ -31,4 +31,4 @@ SCRIPT_EXPORT(CScriptActionCondition, (), .def(constructor()) .def(constructor()) ]; -}); +} diff --git a/src/xrGame/script_animation_action.h b/src/xrGame/script_animation_action.h index e12eca63486..bac7ba23e98 100644 --- a/src/xrGame/script_animation_action.h +++ b/src/xrGame/script_animation_action.h @@ -39,6 +39,9 @@ class CScriptAnimationAction : public CScriptAbstractAction IC void SetAnimation(LPCSTR caAnimationToPlay); IC void SetMentalState(MonsterSpace::EMentalState tMentalState); IC void initialize(); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #include "script_animation_action_inline.h" diff --git a/src/xrGame/script_animation_action_script.cpp b/src/xrGame/script_animation_action_script.cpp index 6d2ec454861..0cb165809dc 100644 --- a/src/xrGame/script_animation_action_script.cpp +++ b/src/xrGame/script_animation_action_script.cpp @@ -7,10 +7,10 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "script_animation_action.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CScriptAnimationAction, (), +void CScriptAnimationAction::script_register(lua_State* luaState) { using namespace luabind; @@ -49,4 +49,4 @@ SCRIPT_EXPORT(CScriptAnimationAction, (), .def("type", &CScriptAnimationAction::SetMentalState) .def("completed", &CScriptAbstractAction::completed) ]; -}); +} diff --git a/src/xrGame/script_binder.cpp b/src/xrGame/script_binder.cpp index 9910987125c..4425c6a81de 100644 --- a/src/xrGame/script_binder.cpp +++ b/src/xrGame/script_binder.cpp @@ -118,7 +118,7 @@ void CScriptBinder::net_Destroy() if (m_object) { #ifdef _DEBUG - Msg("* Core object %s is UNbinded from the script object", owner->cName()); + Msg("* Core object %s is UNbinded from the script object", owner->cName().c_str()); #endif // _DEBUG try { @@ -138,7 +138,7 @@ void CScriptBinder::set_object(CScriptBinderObject* object) { VERIFY2(!m_object, "Cannot bind to the object twice!"); #ifdef _DEBUG - Msg("* Core object %s is binded with the script object", owner->cName()); + Msg("* Core object %s is binded with the script object", owner->cName().c_str()); #endif // _DEBUG m_object = object; } diff --git a/src/xrGame/script_binder_object.h b/src/xrGame/script_binder_object.h index 3fc8befea2a..1002a9f72cb 100644 --- a/src/xrGame/script_binder_object.h +++ b/src/xrGame/script_binder_object.h @@ -32,4 +32,7 @@ class CScriptBinderObject virtual void load(IReader* input_packet); virtual bool net_SaveRelevant(); virtual void net_Relcase(CScriptGameObject* object); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; diff --git a/src/xrGame/script_binder_object_script.cpp b/src/xrGame/script_binder_object_script.cpp index d2970edfc8c..8e552d5e5f6 100644 --- a/src/xrGame/script_binder_object_script.cpp +++ b/src/xrGame/script_binder_object_script.cpp @@ -7,12 +7,12 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "script_binder_object.h" #include "script_binder_object_wrapper.h" #include "xrServer_Objects_ALife.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CScriptBinderObject, (), +void CScriptBinderObject::script_register(lua_State* luaState) { using namespace luabind; @@ -33,4 +33,4 @@ SCRIPT_EXPORT(CScriptBinderObject, (), .def("net_save_relevant", &CScriptBinderObject::net_SaveRelevant, &CScriptBinderObjectWrapper::net_SaveRelevant_static) .def("net_Relcase", &CScriptBinderObject::net_Relcase, &CScriptBinderObjectWrapper::net_Relcase_static) ]; -}); +} diff --git a/src/xrGame/script_effector.cpp b/src/xrGame/script_effector.cpp index 6713a265cee..b15f34b2a7c 100644 --- a/src/xrGame/script_effector.cpp +++ b/src/xrGame/script_effector.cpp @@ -7,11 +7,18 @@ //////////////////////////////////////////////////////////////////////////// #include "StdAfx.h" + #include "script_effector.h" #include "Actor.h" #include "ActorEffector.h" -CScriptEffector::~CScriptEffector() { Msg("CScriptEffector::~CScriptEffector() called"); } +CScriptEffector::~CScriptEffector() +{ +#ifdef DEBUG + Log("CScriptEffector::~CScriptEffector() called"); +#endif +} + bool CScriptEffector::Process(SPPInfo& pp) { return (!!process(&pp)); } bool CScriptEffector::process(SPPInfo* pp) { return (!!inherited::Process(*pp)); } void CScriptEffector::Add() { Actor()->Cameras().AddPPEffector(this); } diff --git a/src/xrGame/script_effector.h b/src/xrGame/script_effector.h index 24481a20fed..1928007c83e 100644 --- a/src/xrGame/script_effector.h +++ b/src/xrGame/script_effector.h @@ -8,8 +8,8 @@ #pragma once +#include "xrCore/PostProcess/PPInfo.hpp" #include "xrEngine/Effector.h" -#include "xrEngine/CameraManager.h" class CScriptEffector : public CEffectorPP { @@ -23,6 +23,9 @@ class CScriptEffector : public CEffectorPP virtual bool process(SPPInfo* pp); virtual void Add(); virtual void Remove(); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #include "script_effector_inline.h" diff --git a/src/xrGame/script_effector_script.cpp b/src/xrGame/script_effector_script.cpp index 9d5a0331f3c..3df4370e7b8 100644 --- a/src/xrGame/script_effector_script.cpp +++ b/src/xrGame/script_effector_script.cpp @@ -7,15 +7,11 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "script_effector.h" #include "script_effector_wrapper.h" -#include "xrScriptEngine/ScriptExporter.hpp" - -void SPPInfo_assign(SPPInfo* self, SPPInfo* obj) { *self = *obj; } -void add_effector(CScriptEffector* self) { self->Add(); } -void remove_effector(CScriptEffector* self) { self->Remove(); } -SCRIPT_EXPORT(CScriptEffector, (), +void CScriptEffector::script_register(lua_State* luaState) { using namespace luabind; using namespace luabind::policy; @@ -54,12 +50,12 @@ SCRIPT_EXPORT(CScriptEffector, (), .def_readwrite("color_gray", &SPPInfo::color_gray) .def_readwrite("color_add", &SPPInfo::color_add) .def(constructor<>()) - .def("assign", &SPPInfo_assign), + .def("assign", +[](SPPInfo* self, const SPPInfo* obj) { *self = *obj; }), class_("effector") .def(constructor()) - .def("start", &add_effector, adopt<1>()) - .def("finish", &remove_effector, adopt<1>()) + .def("start", +[](CScriptEffector* self) { self->Add(); }, adopt<1>()) + .def("finish", +[](CScriptEffector* self) { self->Remove(); }, adopt<1>()) .def("process", &CScriptEffector::process, &CScriptEffectorWrapper::process_static) ]; -}); +} diff --git a/src/xrGame/script_entity_action.h b/src/xrGame/script_entity_action.h index 539fbd83131..8c101b4511b 100644 --- a/src/xrGame/script_entity_action.h +++ b/src/xrGame/script_entity_action.h @@ -66,6 +66,9 @@ class CScriptEntityAction final IC const CScriptObjectAction& object(); IC const CScriptActionCondition& cond(); IC void* data(); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #include "script_entity_action_inline.h" diff --git a/src/xrGame/script_entity_action_script.cpp b/src/xrGame/script_entity_action_script.cpp index 08f9e17f120..dfaae7a54b6 100644 --- a/src/xrGame/script_entity_action_script.cpp +++ b/src/xrGame/script_entity_action_script.cpp @@ -7,10 +7,10 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "script_entity_action.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CScriptEntityAction, (), +void CScriptEntityAction::script_register(lua_State* luaState) { using namespace luabind; @@ -37,4 +37,4 @@ SCRIPT_EXPORT(CScriptEntityAction, (), .def("all", (bool (CScriptEntityAction::*)())(&CScriptEntityAction::CheckIfActionCompleted)) .def("completed", (bool (CScriptEntityAction::*)())(&CScriptEntityAction::CheckIfActionCompleted)) ]; -}); +} diff --git a/src/xrGame/script_game_object.cpp b/src/xrGame/script_game_object.cpp index b687cbd0073..56124459bd3 100644 --- a/src/xrGame/script_game_object.cpp +++ b/src/xrGame/script_game_object.cpp @@ -38,7 +38,6 @@ #include "smart_cover_object.h" #include "smart_cover.h" #include "smart_cover_description.h" -#include "physics_shell_scripted.h" #include "CharacterPhysicsSupport.h" //Alundaio: For set_visual #include "damage_manager.h" //Alundaio: For set_visual #include "ai/phantom/phantom.h" @@ -161,14 +160,12 @@ u16 CScriptGameObject::get_bone_id(LPCSTR bone_name) const return object().Visual()->dcast_PKinematics()->LL_BoneID(bone_name); } -cphysics_shell_scripted* CScriptGameObject::get_physics_shell() const +CPhysicsShell* CScriptGameObject::get_physics_shell() const { CPhysicsShellHolder* ph_shell_holder = smart_cast(&object()); if (!ph_shell_holder) - return NULL; - if (!ph_shell_holder->PPhysicsShell()) - return NULL; - return get_script_wrapper(*ph_shell_holder->PPhysicsShell()); + return nullptr; + return ph_shell_holder->PPhysicsShell(); } ////////////////////////////////////////////////////////////////////////// diff --git a/src/xrGame/script_game_object.h b/src/xrGame/script_game_object.h index b4eea41e71f..ee175756185 100644 --- a/src/xrGame/script_game_object.h +++ b/src/xrGame/script_game_object.h @@ -99,7 +99,7 @@ class CScriptMonsterHitInfo; class CScriptBinderObject; class CCoverPoint; class CScriptIniFile; -class cphysics_shell_scripted; +class CPhysicsShell; class CHelicopter; class CHangingLamp; class CHolderCustom; @@ -631,7 +631,7 @@ class CScriptGameObject Fvector bone_position(LPCSTR bone_name) const; bool is_body_turning() const; - cphysics_shell_scripted* get_physics_shell() const; + CPhysicsShell* get_physics_shell() const; u16 get_bone_id(LPCSTR bone_name) const; bool weapon_strapped() const; bool weapon_unstrapped() const; @@ -947,6 +947,9 @@ class CScriptGameObject //-Alundaio doors::door* m_door; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; extern void sell_condition(CScriptIniFile* ini_file, LPCSTR section); diff --git a/src/xrGame/script_game_object_script.cpp b/src/xrGame/script_game_object_script.cpp index 640131fdf5e..001af6d19e1 100644 --- a/src/xrGame/script_game_object_script.cpp +++ b/src/xrGame/script_game_object_script.cpp @@ -7,17 +7,17 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "script_game_object.h" #include "game_object_space.h" #include "script_ini_file.h" #include "sight_manager_space.h" -#include "xrScriptEngine/ScriptExporter.hpp" extern luabind::class_& script_register_game_object1(luabind::class_&); extern luabind::class_& script_register_game_object2(luabind::class_&); extern luabind::class_& script_register_game_object_trader(luabind::class_&); -SCRIPT_EXPORT(CScriptGameObject, (), +void CScriptGameObject::script_register(lua_State* luaState) { using namespace luabind; @@ -130,4 +130,4 @@ SCRIPT_EXPORT(CScriptGameObject, (), def("sell_condition", (void (*)(float, float))(&::sell_condition)), def("show_condition", &::show_condition) ]; -}); +} diff --git a/src/xrGame/script_game_object_script3.cpp b/src/xrGame/script_game_object_script3.cpp index 9494f81ced8..94f04eaa298 100644 --- a/src/xrGame/script_game_object_script3.cpp +++ b/src/xrGame/script_game_object_script3.cpp @@ -23,7 +23,6 @@ #include "script_monster_hit_info.h" #include "script_entity_action.h" #include "action_planner.h" -#include "physics_shell_scripted.h" #include "helicopter.h" #include "HangingLamp.h" #include "holder_custom.h" diff --git a/src/xrGame/script_game_object_use.cpp b/src/xrGame/script_game_object_use.cpp index 44a642f88dc..60347a173d7 100644 --- a/src/xrGame/script_game_object_use.cpp +++ b/src/xrGame/script_game_object_use.cpp @@ -12,10 +12,10 @@ #include "enemy_manager.h" #include "movement_manager.h" #include "patrol_path_manager.h" -#include "PHCommander.h" -#include "PHScriptCall.h" -#include "PHSimpleCalls.h" #include "xrPhysics/IPHWorld.h" +#include "xrPhysics/PHCommander.h" +#include "xrPhysics/PHScriptCall.h" +#include "xrPhysics/PHSimpleCalls.h" #include "doors_manager.h" void CScriptGameObject::SetTipText(LPCSTR tip_text) { object().set_tip_text(tip_text); } @@ -209,6 +209,5 @@ void CScriptGameObject::set_const_force(const Fvector& dir, float value, u32 tim CPHConstForceAction* a = xr_new(shell, force); CPHExpireOnStepCondition* cn = xr_new(); cn->set_time_interval(time_interval); - // ph_world->AddCall(cn,a); - Level().ph_commander_physics_worldstep().add_call_threadsafety(cn, a); + physics_world()->AddCall(cn, a); } diff --git a/src/xrGame/script_hit.h b/src/xrGame/script_hit.h index 77b539d27bc..29a455086a8 100644 --- a/src/xrGame/script_hit.h +++ b/src/xrGame/script_hit.h @@ -27,6 +27,9 @@ class CScriptHit IC CScriptHit(const CScriptHit* tpLuaHit); virtual ~CScriptHit(); IC void set_bone_name(LPCSTR bone_name); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #include "script_hit_inline.h" diff --git a/src/xrGame/script_hit_script.cpp b/src/xrGame/script_hit_script.cpp index 89535ea53d5..42239e91caa 100644 --- a/src/xrGame/script_hit_script.cpp +++ b/src/xrGame/script_hit_script.cpp @@ -7,11 +7,11 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "script_hit.h" #include "script_game_object.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CScriptHit, (), +void CScriptHit::script_register(lua_State* luaState) { using namespace luabind; @@ -42,4 +42,4 @@ SCRIPT_EXPORT(CScriptHit, (), .def(constructor()) .def("bone", &CScriptHit::set_bone_name) ]; -}); +} diff --git a/src/xrGame/script_lanim.cpp b/src/xrGame/script_lanim.cpp deleted file mode 100644 index c1ce03940a5..00000000000 --- a/src/xrGame/script_lanim.cpp +++ /dev/null @@ -1,55 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// Module : script_ini_file.cpp -// Created : 21.05.2004 -// Modified : 21.05.2004 -// Author : Dmitriy Iassenev -// Description : Script ini file class -//////////////////////////////////////////////////////////////////////////// - -#include "pch_script.h" -#include "xrEngine/LightAnimLibrary.h" -#include "xrScriptEngine/ScriptExporter.hpp" - -struct lanim_wrapper -{ - CLAItem* item; - -public: - lanim_wrapper(pcstr name) - { - load(name); - } - - void load(pcstr name) - { - item = LALib.FindItem(name); - R_ASSERT3(item, "Can't find color anim:", name); - } - - u32 length() - { - VERIFY(item); - return item->Length_ms(); - } - - Fcolor calculate(float T) - { - int frame; - VERIFY(item); - return Fcolor(item->CalculateRGB(T, frame)); - } -}; - -SCRIPT_EXPORT(lanim_wrapper, (), -{ - using namespace luabind; - - module(luaState) - [ - class_("color_animator") - .def(constructor()) - .def("load", &lanim_wrapper::load) - .def("calculate", &lanim_wrapper::calculate) - .def("length", &lanim_wrapper::length) - ]; -}); diff --git a/src/xrGame/script_monster_action.h b/src/xrGame/script_monster_action.h index 569b7e2f8de..dd874f45075 100644 --- a/src/xrGame/script_monster_action.h +++ b/src/xrGame/script_monster_action.h @@ -24,6 +24,9 @@ class CScriptMonsterAction : public CScriptAbstractAction IC CScriptMonsterAction(MonsterSpace::EScriptMonsterGlobalAction action); IC CScriptMonsterAction(MonsterSpace::EScriptMonsterGlobalAction action, CScriptGameObject* tObj); void SetObject(CScriptGameObject* tObj); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #include "script_monster_action_inline.h" diff --git a/src/xrGame/script_monster_action_script.cpp b/src/xrGame/script_monster_action_script.cpp index d96728e9f9c..aeb23d5c0c1 100644 --- a/src/xrGame/script_monster_action_script.cpp +++ b/src/xrGame/script_monster_action_script.cpp @@ -7,11 +7,11 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "script_monster_action.h" #include "script_game_object.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CScriptMonsterAction, (), +void CScriptMonsterAction::script_register(lua_State* luaState) { using namespace luabind; @@ -30,4 +30,4 @@ SCRIPT_EXPORT(CScriptMonsterAction, (), .def(constructor()) .def(constructor()) ]; -}); +} diff --git a/src/xrGame/script_monster_hit_info.h b/src/xrGame/script_monster_hit_info.h index ff68b6b3505..221978c2a10 100644 --- a/src/xrGame/script_monster_hit_info.h +++ b/src/xrGame/script_monster_hit_info.h @@ -22,4 +22,7 @@ class CScriptMonsterHitInfo direction = p_direction; time = p_time; } + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; diff --git a/src/xrGame/script_monster_hit_info_script.cpp b/src/xrGame/script_monster_hit_info_script.cpp index 604e733e65f..ac011a7f250 100644 --- a/src/xrGame/script_monster_hit_info_script.cpp +++ b/src/xrGame/script_monster_hit_info_script.cpp @@ -1,15 +1,15 @@ #include "pch_script.h" + #include "script_monster_hit_info.h" #include "script_game_object.h" #include "ai_monster_space.h" #include "ai/monsters/monster_sound_defs.h" -#include "xrScriptEngine/ScriptExporter.hpp" struct CMonsterSpace { }; -SCRIPT_EXPORT(CScriptMonsterHitInfo, (), +void CScriptMonsterHitInfo::script_register(lua_State* luaState) { using namespace luabind; @@ -34,4 +34,4 @@ SCRIPT_EXPORT(CScriptMonsterHitInfo, (), value("head_anim_kind", MonsterSpace::eHeadAnimKind) ] ]; -}); +} diff --git a/src/xrGame/script_movement_action.h b/src/xrGame/script_movement_action.h index e229170f7ca..9c793e7c4e9 100644 --- a/src/xrGame/script_movement_action.h +++ b/src/xrGame/script_movement_action.h @@ -122,6 +122,9 @@ class CScriptMovementAction : public CScriptAbstractAction IC void SetPatrolRandom(bool bRandom); IC void SetInputKeys(const EInputKeys tInputKeys); IC void initialize(); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #include "script_movement_action_inline.h" diff --git a/src/xrGame/script_movement_action_script.cpp b/src/xrGame/script_movement_action_script.cpp index 262e27a83e5..384dfa6b4b5 100644 --- a/src/xrGame/script_movement_action_script.cpp +++ b/src/xrGame/script_movement_action_script.cpp @@ -7,15 +7,16 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "script_movement_action.h" #include "script_game_object.h" #include "detail_path_manager_space.h" #include "ai_monster_space.h" + #include "xrAICore/Navigation/PatrolPath/patrol_path_params.h" #include "xrAICore/Navigation/PatrolPath/patrol_path.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CScriptMovementAction, (), +void CScriptMovementAction::script_register(lua_State* luaState) { using namespace luabind; @@ -116,4 +117,4 @@ SCRIPT_EXPORT(CScriptMovementAction, (), .def("input", &CScriptMovementAction::SetInputKeys) .def("completed", &CScriptAbstractAction::completed) ]; -}); +} diff --git a/src/xrGame/script_object_action.h b/src/xrGame/script_object_action.h index 19d07d0edad..0b59d36e5b7 100644 --- a/src/xrGame/script_object_action.h +++ b/src/xrGame/script_object_action.h @@ -33,6 +33,9 @@ class CScriptObjectAction : public CScriptAbstractAction IC void SetObjectAction(MonsterSpace::EObjectAction tObjectActionType); IC void SetQueueSize(u32 dwQueueSize); IC void initialize(); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #include "script_object_action_inline.h" diff --git a/src/xrGame/script_object_action_script.cpp b/src/xrGame/script_object_action_script.cpp index 9e7c1be684c..6dd80400c60 100644 --- a/src/xrGame/script_object_action_script.cpp +++ b/src/xrGame/script_object_action_script.cpp @@ -7,11 +7,11 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "script_object_action.h" #include "script_game_object.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CScriptObjectAction, (), +void CScriptObjectAction::script_register(lua_State* luaState) { using namespace luabind; @@ -53,4 +53,4 @@ SCRIPT_EXPORT(CScriptObjectAction, (), (void (CScriptObjectAction::*)(CScriptGameObject*))(&CScriptObjectAction::SetObject)) .def("completed", &CScriptAbstractAction::completed) ]; -}); +} diff --git a/src/xrGame/script_particle_action.h b/src/xrGame/script_particle_action.h index a1e602e9ee7..450fa60b597 100644 --- a/src/xrGame/script_particle_action.h +++ b/src/xrGame/script_particle_action.h @@ -47,6 +47,9 @@ class CScriptParticleAction : public CScriptAbstractAction IC void SetAngles(const Fvector& tAngleOffset); IC void SetVelocity(const Fvector& tVelocity); IC void initialize(); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #include "script_particle_action_inline.h" diff --git a/src/xrGame/script_particle_action_script.cpp b/src/xrGame/script_particle_action_script.cpp index dfacf6a6b12..72a0fa3a5d1 100644 --- a/src/xrGame/script_particle_action_script.cpp +++ b/src/xrGame/script_particle_action_script.cpp @@ -7,10 +7,10 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "script_particle_action.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CScriptParticleAction, (), +void CScriptParticleAction::script_register(lua_State* luaState) { using namespace luabind; @@ -30,4 +30,4 @@ SCRIPT_EXPORT(CScriptParticleAction, (), .def("set_velocity", &CScriptParticleAction::SetVelocity) .def("completed", &CScriptAbstractAction::completed) ]; -}); +} diff --git a/src/xrGame/script_particles.h b/src/xrGame/script_particles.h index 5388a116166..173c19fbc5b 100644 --- a/src/xrGame/script_particles.h +++ b/src/xrGame/script_particles.h @@ -60,6 +60,9 @@ class CScriptParticles void StartPath(bool looped); void StopPath(); void PausePath(bool val); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #include "script_particles_inline.h" diff --git a/src/xrGame/script_particles_script.cpp b/src/xrGame/script_particles_script.cpp index b410fa179a9..813edefa443 100644 --- a/src/xrGame/script_particles_script.cpp +++ b/src/xrGame/script_particles_script.cpp @@ -7,10 +7,10 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "script_particles.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CScriptParticles, (), +void CScriptParticles::script_register(lua_State* luaState) { using namespace luabind; @@ -21,8 +21,6 @@ SCRIPT_EXPORT(CScriptParticles, (), .def("play", &CScriptParticles::Play) .def("play_at_pos", &CScriptParticles::PlayAtPos) .def("stop", &CScriptParticles::Stop) - // preserved for backwards compatibility - // XXX: review .def("stop_deffered", &CScriptParticles::StopDeferred) .def("stop_deferred", &CScriptParticles::StopDeferred) @@ -40,4 +38,4 @@ SCRIPT_EXPORT(CScriptParticles, (), .def("stop_path", &CScriptParticles::StopPath) .def("pause_path", &CScriptParticles::PausePath) ]; -}); +} diff --git a/src/xrGame/script_render_device_script.cpp b/src/xrGame/script_render_device_script.cpp deleted file mode 100644 index 21e342223dc..00000000000 --- a/src/xrGame/script_render_device_script.cpp +++ /dev/null @@ -1,48 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// Module : script_render_device_script.cpp -// Created : 28.06.2004 -// Modified : 28.06.2004 -// Author : Dmitriy Iassenev -// Description : Script render device script export -//////////////////////////////////////////////////////////////////////////// - -#include "pch_script.h" -#include "xrScriptEngine/ScriptExporter.hpp" - -bool is_device_paused(CRenderDevice* d) { return !!Device.Paused(); } -void set_device_paused(CRenderDevice* d, bool b) { Device.Pause(b, TRUE, FALSE, "set_device_paused_script"); } -bool is_app_ready() { return g_pGamePersistent->IsLoaded(); } -u32 time_global(const CRenderDevice* self) -{ - THROW(self); - return (self->dwTimeGlobal); -} - -SCRIPT_EXPORT(CRenderDevice, (), -{ - using namespace luabind; - - module(luaState) - [ - class_("render_device") - .def_readonly("width", &CRenderDevice::dwWidth) - .def_readonly("height", &CRenderDevice::dwHeight) - .def_readonly("time_delta", &CRenderDevice::dwTimeDelta) - .def_readonly("f_time_delta", &CRenderDevice::fTimeDelta) - .def_readonly("cam_pos", &CRenderDevice::vCameraPosition) - .def_readonly("cam_dir", &CRenderDevice::vCameraDirection) - .def_readonly("cam_top", &CRenderDevice::vCameraTop) - .def_readonly("cam_right", &CRenderDevice::vCameraRight) - // .def_readonly("view", &CRenderDevice::mView) - // .def_readonly("projection", &CRenderDevice::mProject) - // .def_readonly("full_transform", &CRenderDevice::mFullTransform) - .def_readonly("fov", &CRenderDevice::fFOV) - .def_readonly("aspect_ratio", &CRenderDevice::fASPECT) - .def("time_global", &time_global) - .def_readonly("precache_frame", &CRenderDevice::dwPrecacheFrame) - .def_readonly("frame", &CRenderDevice::dwFrame) - .def("is_paused", &is_device_paused) - .def("pause", &set_device_paused), - def("app_ready", &is_app_ready) - ]; -}); diff --git a/src/xrGame/script_sound.h b/src/xrGame/script_sound.h index 22a94fc6b78..b3bb9d3d4cf 100644 --- a/src/xrGame/script_sound.h +++ b/src/xrGame/script_sound.h @@ -48,6 +48,9 @@ class CScriptSound IC float GetMaxDistance() const; IC float GetVolume() const; IC bool IsPlaying() const; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #include "script_sound_inline.h" diff --git a/src/xrGame/script_sound_action.h b/src/xrGame/script_sound_action.h index 05ce3d07294..b0ed6fe6c57 100644 --- a/src/xrGame/script_sound_action.h +++ b/src/xrGame/script_sound_action.h @@ -67,6 +67,9 @@ class CScriptSoundAction : public CScriptAbstractAction IC void SetAngles(const Fvector& tAngles); IC void SetSoundType(const ESoundTypes sound_type); IC void initialize(); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #include "script_sound_action_inline.h" diff --git a/src/xrGame/script_sound_action_script.cpp b/src/xrGame/script_sound_action_script.cpp index c5ebf056895..254468da9bb 100644 --- a/src/xrGame/script_sound_action_script.cpp +++ b/src/xrGame/script_sound_action_script.cpp @@ -7,13 +7,15 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "script_sound_action.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CScriptSoundAction, (), +void CScriptSoundAction::script_register(lua_State* luaState) { using namespace luabind; + class CScriptSoundType {}; + module(luaState) [ class_("sound") @@ -57,6 +59,57 @@ SCRIPT_EXPORT(CScriptSoundAction, (), .def("set_bone", &CScriptSoundAction::SetBone) .def("set_position", &CScriptSoundAction::SetPosition) .def("set_angles", &CScriptSoundAction::SetAngles) - .def("completed", &CScriptAbstractAction::completed) + .def("completed", &CScriptAbstractAction::completed), + + class_("snd_type") + .enum_("sound_types") + [ + value("no_sound", int(SOUND_TYPE_NO_SOUND)), + value("weapon", int(SOUND_TYPE_WEAPON)), + value("item", int(SOUND_TYPE_ITEM)), + value("monster", int(SOUND_TYPE_MONSTER)), + value("anomaly", int(SOUND_TYPE_ANOMALY)), + value("world", int(SOUND_TYPE_WORLD)), + value("pick_up", int(SOUND_TYPE_PICKING_UP)), + value("drop", int(SOUND_TYPE_DROPPING)), + value("hide", int(SOUND_TYPE_HIDING)), + value("take", int(SOUND_TYPE_TAKING)), + value("use", int(SOUND_TYPE_USING)), + value("shoot", int(SOUND_TYPE_SHOOTING)), + value("empty", int(SOUND_TYPE_EMPTY_CLICKING)), + value("bullet_hit", int(SOUND_TYPE_BULLET_HIT)), + value("reload", int(SOUND_TYPE_RECHARGING)), + value("die", int(SOUND_TYPE_DYING)), + value("injure", int(SOUND_TYPE_INJURING)), + value("step", int(SOUND_TYPE_STEP)), + value("talk", int(SOUND_TYPE_TALKING)), + value("attack", int(SOUND_TYPE_ATTACKING)), + value("eat", int(SOUND_TYPE_EATING)), + value("idle", int(SOUND_TYPE_IDLE)), + value("object_break", int(SOUND_TYPE_OBJECT_BREAKING)), + value("object_collide", int(SOUND_TYPE_OBJECT_COLLIDING)), + value("object_explode", int(SOUND_TYPE_OBJECT_EXPLODING)), + value("ambient", int(SOUND_TYPE_AMBIENT)), + value("item_pick_up", int(SOUND_TYPE_ITEM_PICKING_UP)), + value("item_drop", int(SOUND_TYPE_ITEM_DROPPING)), + value("item_hide", int(SOUND_TYPE_ITEM_HIDING)), + value("item_take", int(SOUND_TYPE_ITEM_TAKING)), + value("item_use", int(SOUND_TYPE_ITEM_USING)), + value("weapon_shoot", int(SOUND_TYPE_WEAPON_SHOOTING)), + value("weapon_empty", int(SOUND_TYPE_WEAPON_EMPTY_CLICKING)), + value("weapon_bullet_hit", int(SOUND_TYPE_WEAPON_BULLET_HIT)), + value("weapon_reload", int(SOUND_TYPE_WEAPON_RECHARGING)), + value("monster_die", int(SOUND_TYPE_MONSTER_DYING)), + value("monster_injure", int(SOUND_TYPE_MONSTER_INJURING)), + value("monster_step", int(SOUND_TYPE_MONSTER_STEP)), + value("monster_talk", int(SOUND_TYPE_MONSTER_TALKING)), + value("monster_attack", int(SOUND_TYPE_MONSTER_ATTACKING)), + value("monster_eat", int(SOUND_TYPE_MONSTER_EATING)), + value("anomaly_idle", int(SOUND_TYPE_ANOMALY_IDLE)), + value("world_object_break", int(SOUND_TYPE_WORLD_OBJECT_BREAKING)), + value("world_object_collide", int(SOUND_TYPE_WORLD_OBJECT_COLLIDING)), + value("world_object_explode", int(SOUND_TYPE_WORLD_OBJECT_EXPLODING)), + value("world_ambient", int(SOUND_TYPE_WORLD_AMBIENT)) + ] ]; -}); +} diff --git a/src/xrGame/script_sound_info.h b/src/xrGame/script_sound_info.h index dfd45f2adf1..41205cd9377 100644 --- a/src/xrGame/script_sound_info.h +++ b/src/xrGame/script_sound_info.h @@ -28,4 +28,7 @@ class CScriptSoundInfo time = p_time; dangerous = int(p_danger); } + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; diff --git a/src/xrGame/script_sound_info_script.cpp b/src/xrGame/script_sound_info_script.cpp index 67004000897..8dbf5a9c8bc 100644 --- a/src/xrGame/script_sound_info_script.cpp +++ b/src/xrGame/script_sound_info_script.cpp @@ -1,9 +1,9 @@ #include "pch_script.h" + #include "script_sound_info.h" #include "script_game_object.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CScriptSoundInfo, (), +void CScriptSoundInfo::script_register(lua_State* luaState) { using namespace luabind; @@ -16,4 +16,4 @@ SCRIPT_EXPORT(CScriptSoundInfo, (), .def_readwrite("power", &CScriptSoundInfo::power) .def_readwrite("time", &CScriptSoundInfo::time) ]; -}); +} diff --git a/src/xrGame/script_sound_script.cpp b/src/xrGame/script_sound_script.cpp index 06961f525fe..eda8de7c014 100644 --- a/src/xrGame/script_sound_script.cpp +++ b/src/xrGame/script_sound_script.cpp @@ -7,11 +7,11 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "script_sound.h" #include "script_game_object.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CScriptSound, (), +void CScriptSound::script_register(lua_State* luaState) { using namespace luabind; @@ -49,12 +49,10 @@ SCRIPT_EXPORT(CScriptSound, (), (void (CScriptSound::*)(CScriptGameObject*, const Fvector&, float, int))(&CScriptSound::PlayAtPos)) .def("play_no_feedback", &CScriptSound::PlayNoFeedback) .def("stop", &CScriptSound::Stop) - // preserved for backwards compatibility - // XXX: review .def("stop_deffered", &CScriptSound::StopDeferred) .def("stop_deferred", &CScriptSound::StopDeferred) .def("playing", &CScriptSound::IsPlaying) .def("length", &CScriptSound::Length) .def("attach_tail", &CScriptSound::AttachTail) ]; -}); +} diff --git a/src/xrGame/script_watch_action.h b/src/xrGame/script_watch_action.h index 9d63a7baefb..82aad519b26 100644 --- a/src/xrGame/script_watch_action.h +++ b/src/xrGame/script_watch_action.h @@ -56,6 +56,9 @@ class CScriptWatchAction : public CScriptAbstractAction IC void SetWatchDirection(const Fvector& tDirection); IC void SetWatchBone(LPCSTR bone_to_watch); IC void initialize(); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #include "script_watch_action_inline.h" diff --git a/src/xrGame/script_watch_action_script.cpp b/src/xrGame/script_watch_action_script.cpp index 94e42f802b9..22b8170bba5 100644 --- a/src/xrGame/script_watch_action_script.cpp +++ b/src/xrGame/script_watch_action_script.cpp @@ -7,12 +7,12 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "script_watch_action.h" #include "script_game_object.h" #include "sight_manager_space.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CScriptWatchAction, (), +void CScriptWatchAction::script_register(lua_State* luaState) { using namespace luabind; @@ -45,4 +45,4 @@ SCRIPT_EXPORT(CScriptWatchAction, (), .def("bone", &CScriptWatchAction::SetWatchBone) .def("completed", &CScriptAbstractAction::completed) ]; -}); +} diff --git a/src/xrGame/script_zone.h b/src/xrGame/script_zone.h index cabfc2b539e..e93297a434b 100644 --- a/src/xrGame/script_zone.h +++ b/src/xrGame/script_zone.h @@ -35,4 +35,7 @@ class CScriptZone : public CSpaceRestrictor, public Feel::Touch #ifdef DEBUG virtual void OnRender(); #endif + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; diff --git a/src/xrGame/script_zone_script.cpp b/src/xrGame/script_zone_script.cpp index adb95f20583..722968e324c 100644 --- a/src/xrGame/script_zone_script.cpp +++ b/src/xrGame/script_zone_script.cpp @@ -7,12 +7,11 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "script_zone.h" #include "smart_zone.h" -#include "xrScriptEngine/ScriptExporter.hpp" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CScriptZone, (IFactoryObject), +void CScriptZone::script_register(lua_State* luaState) { using namespace luabind; @@ -21,9 +20,9 @@ SCRIPT_EXPORT(CScriptZone, (IFactoryObject), class_("ce_script_zone") .def(constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CSmartZone, (IFactoryObject), +void CSmartZone::script_register(lua_State* luaState) { using namespace luabind; @@ -32,4 +31,4 @@ SCRIPT_EXPORT(CSmartZone, (IFactoryObject), class_("ce_smart_zone") .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/smart_cover_object.cpp b/src/xrGame/smart_cover_object.cpp index 5e9962f03b4..d6756a0893d 100644 --- a/src/xrGame/smart_cover_object.cpp +++ b/src/xrGame/smart_cover_object.cpp @@ -26,14 +26,6 @@ void dbg_draw_frustum(float FOV, float _FAR, float A, Fvector& P, Fvector& D, Fv namespace smart_cover { -void object::Load(LPCSTR section) -{ - inherited::Load(section); - - m_enter_min_enemy_distance = pSettings->r_float(section, "enter_min_enemy_distance"); - m_exit_min_enemy_distance = pSettings->r_float(section, "exit_min_enemy_distance"); -} - bool object::net_Spawn(CSE_Abstract* server_entity) { CSE_SmartCover* smart_cover = smart_cast(server_entity); @@ -72,6 +64,9 @@ bool object::net_Spawn(CSE_Abstract* server_entity) spatial.type &= ~STYPE_VISIBLEFORAI; + m_enter_min_enemy_distance = smart_cover->m_enter_min_enemy_distance; + m_exit_min_enemy_distance = smart_cover->m_exit_min_enemy_distance; + if (ai().get_alife() && smart_cover->m_description.size()) m_cover = ai().cover_manager().add_smart_cover(smart_cover->m_description.c_str(), *this, smart_cover->m_is_combat_cover ? true : false, smart_cover->m_can_fire ? true : false, diff --git a/src/xrGame/smart_cover_object.h b/src/xrGame/smart_cover_object.h index 83b169fdc48..6b1cbae120e 100644 --- a/src/xrGame/smart_cover_object.h +++ b/src/xrGame/smart_cover_object.h @@ -23,12 +23,11 @@ class object : public CGameObject typedef CGameObject inherited; private: - cover const* m_cover; + cover const* m_cover{}; float m_enter_min_enemy_distance; float m_exit_min_enemy_distance; public: - virtual void Load(LPCSTR section); virtual bool feel_touch_on_contact(IGameObject*) { return FALSE; } virtual bool use(CGameObject* who_use) { return false; } virtual bool net_Spawn(CSE_Abstract* DC); @@ -50,6 +49,9 @@ class object : public CGameObject IC float const& enter_min_enemy_distance() const; IC float const& exit_min_enemy_distance() const; IC cover const& get_cover() const; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; } // namespace smart_cover diff --git a/src/xrGame/smart_cover_object_script.cpp b/src/xrGame/smart_cover_object_script.cpp index 6ea19e6071f..e5472abb61d 100644 --- a/src/xrGame/smart_cover_object_script.cpp +++ b/src/xrGame/smart_cover_object_script.cpp @@ -7,16 +7,19 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "smart_cover.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(smart_cover_object, (CGameObject), +namespace smart_cover +{ +void object::script_register(lua_State* luaState) { using namespace luabind; module(luaState) [ class_("smart_cover_object") - .def(constructor<>()) + .def(constructor<>()) ]; -}); +} +} // namespace smart_cover diff --git a/src/xrGame/smart_zone.h b/src/xrGame/smart_zone.h index 6c243b0106b..e3f2b3206dd 100644 --- a/src/xrGame/smart_zone.h +++ b/src/xrGame/smart_zone.h @@ -14,4 +14,7 @@ class CSmartZone : public CSpaceRestrictor { public: virtual bool register_schedule() const { return true; } + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; diff --git a/src/xrGame/space_restriction_abstract_inline.h b/src/xrGame/space_restriction_abstract_inline.h index e44f725e04a..ee3025f5668 100644 --- a/src/xrGame/space_restriction_abstract_inline.h +++ b/src/xrGame/space_restriction_abstract_inline.h @@ -20,7 +20,7 @@ IC const xr_vector& CSpaceRestrictionAbstract::border() initialize(); THROW(initialized()); - VERIFY3(!m_border.empty(), "Space restrictor has no border!", *name()); + VERIFY3(!m_border.empty(), "Space restrictor has no border!", name().c_str()); return (m_border); } @@ -32,7 +32,7 @@ IC const xr_vector& CSpaceRestrictionAbstract::accessible_neighbour_border( prepare_accessible_neighbour_border(restriction, out_restriction); VERIFY2(!m_accessible_neighbour_border.empty(), - make_string("space restrictor %s has no accessible neighbours (border size[%d])", *name(), border().size())); + make_string("space restrictor %s has no accessible neighbours (border size[%d])", name().c_str(), border().size())); return (m_accessible_neighbour_border); } diff --git a/src/xrGame/space_restrictor.h b/src/xrGame/space_restrictor.h index cafe8a84464..c18e1a9deed 100644 --- a/src/xrGame/space_restrictor.h +++ b/src/xrGame/space_restrictor.h @@ -68,6 +68,9 @@ class CSpaceRestrictor : public CGameObject #ifdef DEBUG virtual void OnRender(); #endif + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CGameObject); }; #include "space_restrictor_inline.h" diff --git a/src/xrGame/space_restrictor_script.cpp b/src/xrGame/space_restrictor_script.cpp index e8d8f4e24ad..4e28381a06a 100644 --- a/src/xrGame/space_restrictor_script.cpp +++ b/src/xrGame/space_restrictor_script.cpp @@ -1,8 +1,8 @@ #include "pch_script.h" + #include "space_restrictor.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CSpaceRestrictor, (CGameObject), +void CSpaceRestrictor::script_register(lua_State* luaState) { using namespace luabind; @@ -11,4 +11,4 @@ SCRIPT_EXPORT(CSpaceRestrictor, (CGameObject), class_("CSpaceRestrictor") .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/torch_script.cpp b/src/xrGame/torch_script.cpp index 6bd4d2da777..0cbeefa64e1 100644 --- a/src/xrGame/torch_script.cpp +++ b/src/xrGame/torch_script.cpp @@ -1,12 +1,12 @@ #include "pch_script.h" + #include "Torch.h" #include "PDA.h" #include "SimpleDetector.h" #include "EliteDetector.h" #include "AdvancedDetector.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CTorch, (CGameObject), +void CTorch::script_register(lua_State* luaState) { using namespace luabind; @@ -25,4 +25,4 @@ SCRIPT_EXPORT(CTorch, (CGameObject), class_("CSimpleDetector") .def(constructor<>()) ]; -}); +} diff --git a/src/xrGame/ui/FactionState.cpp b/src/xrGame/ui/FactionState.cpp index a7c78294b51..9b091e5e1fc 100644 --- a/src/xrGame/ui/FactionState.cpp +++ b/src/xrGame/ui/FactionState.cpp @@ -54,7 +54,7 @@ void FactionState::ResetStates() }*/ } -SCRIPT_EXPORT(FactionState, (), +void FactionState::script_register(lua_State* luaState) { using namespace luabind; @@ -88,7 +88,7 @@ SCRIPT_EXPORT(FactionState, (), .property("war_state_hint4", &FactionState::get_war_state_hint4, &FactionState::set_war_state_hint4) .property("war_state_hint5", &FactionState::get_war_state_hint5, &FactionState::set_war_state_hint5) ]; -}) +} void FactionState::update_info() { @@ -110,4 +110,3 @@ void FactionState::update_info() R_ASSERT(GEnv.ScriptEngine->functor( "pda.fill_faction_state", m_functor)); m_functor(this); } - diff --git a/src/xrGame/ui/FactionState.h b/src/xrGame/ui/FactionState.h index 154c452a225..38228f318f1 100644 --- a/src/xrGame/ui/FactionState.h +++ b/src/xrGame/ui/FactionState.h @@ -6,6 +6,7 @@ //////////////////////////////////////////////////////////////////////////// #pragma once + #include "xrUICore/Windows/UIWindow.h" class FactionState @@ -95,6 +96,8 @@ class FactionState shared_str m_war_state_str[war_state_count]; shared_str m_war_state_hint_str[war_state_count]; +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; // struct FactionState #include "FactionState_inline.h" diff --git a/src/xrGame/ui/FractionState.cpp b/src/xrGame/ui/FractionState.cpp index a8e72c469a8..6ace4e3078e 100644 --- a/src/xrGame/ui/FractionState.cpp +++ b/src/xrGame/ui/FractionState.cpp @@ -35,7 +35,7 @@ FractionState::~FractionState() { } -SCRIPT_EXPORT(FractionState, (), +void FractionState::script_register(lua_State* luaState) { using namespace luabind; @@ -58,7 +58,7 @@ SCRIPT_EXPORT(FractionState, (), .property("target_desc", &FractionState::get_target_desc, &FractionState::set_target_desc) .property("location", &FractionState::get_location, &FractionState::set_location) ]; -}) +} void FractionState::update_info() { diff --git a/src/xrGame/ui/FractionState.h b/src/xrGame/ui/FractionState.h index e1a8c9b96c5..9eee2db3bed 100644 --- a/src/xrGame/ui/FractionState.h +++ b/src/xrGame/ui/FractionState.h @@ -62,6 +62,8 @@ class FractionState shared_str m_target_desc; shared_str m_location; +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; // struct FractionState diff --git a/src/xrGame/ui/UIActorMenu.cpp b/src/xrGame/ui/UIActorMenu.cpp index 694985e1655..d497272d0d2 100644 --- a/src/xrGame/ui/UIActorMenu.cpp +++ b/src/xrGame/ui/UIActorMenu.cpp @@ -985,7 +985,7 @@ void CUIActorMenu::UpdateActorMP() int money = Game().local_player->money_for_round; string64 buf; - xr_sprintf(buf, "%d RU", money); + xr_sprintf(buf, "%d %s", money, StringTable().GetCurrency().c_str()); m_ActorMoney->SetText(buf); GetModeSpecificActorInfo()->InitCharacterMP(Game().local_player->getName(), "ui_npc_u_nebo_1"); diff --git a/src/xrGame/ui/UIActorMenu.h b/src/xrGame/ui/UIActorMenu.h index 224b765c88a..f80f063d226 100644 --- a/src/xrGame/ui/UIActorMenu.h +++ b/src/xrGame/ui/UIActorMenu.h @@ -409,4 +409,7 @@ class CUIActorMenu final : public CUIDialogWnd, public CUIWndCallback void DonateCurrentItem(CUICellItem* cell_item); //Alundaio: Donate item via context menu while in trade menu pcstr GetDebugType() override { return "CUIActorMenu"; } + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CUIDialogWnd); }; // class CUIActorMenu diff --git a/src/xrGame/ui/UIActorMenuTrade.cpp b/src/xrGame/ui/UIActorMenuTrade.cpp index 4b7ff00b089..04d4ffcdfac 100644 --- a/src/xrGame/ui/UIActorMenuTrade.cpp +++ b/src/xrGame/ui/UIActorMenuTrade.cpp @@ -330,7 +330,7 @@ void CUIActorMenu::UpdateActor() if (IsGameTypeSingle()) { string64 buf; - xr_sprintf(buf, "%d RU", m_pActorInvOwner->get_money()); + xr_sprintf(buf, "%d %s", m_pActorInvOwner->get_money(), StringTable().GetCurrency().c_str()); m_ActorMoney->SetText(buf); if (m_ActorMoney != m_TradeActorMoney) m_TradeActorMoney->SetText(buf); @@ -360,14 +360,13 @@ void CUIActorMenu::UpdatePartnerBag() { m_PartnerMoney->SetText(""); } - else if (m_pPartnerInvOwner->InfinitiveMoney()) - { - m_PartnerMoney->SetText("--- RU"); - } else { string64 buf; - xr_sprintf(buf, "%d RU", m_pPartnerInvOwner->get_money()); + if (m_pPartnerInvOwner->InfinitiveMoney()) + xr_sprintf(buf, "--- %s", StringTable().GetCurrency().c_str()); + else + xr_sprintf(buf, "%d %s", m_pPartnerInvOwner->get_money(), StringTable().GetCurrency().c_str()); m_PartnerMoney->SetText(buf); } diff --git a/src/xrGame/ui/UIActorMenu_script.cpp b/src/xrGame/ui/UIActorMenu_script.cpp index c0a28730a6c..2af72cb06aa 100644 --- a/src/xrGame/ui/UIActorMenu_script.cpp +++ b/src/xrGame/ui/UIActorMenu_script.cpp @@ -13,7 +13,6 @@ #include "UICellItem.h" #include "ai_space.h" #include "xrScriptEngine/script_engine.hpp" -#include "xrScriptEngine/ScriptExporter.hpp" #include "xrUICore/TabControl/UITabControl.h" #include "xrGame/ui/UIMainIngameWnd.h" #include "eatable_item.h" @@ -105,7 +104,7 @@ void CUIActorMenu::CurModeToScript() template class enum_dummy {}; -SCRIPT_EXPORT(CUIActorMenu, (CUIDialogWnd), +void CUIActorMenu::script_register(lua_State* luaState) { using namespace luabind; @@ -136,26 +135,8 @@ SCRIPT_EXPORT(CUIActorMenu, (CUIDialogWnd), .def("ShowDialog", &CUIActorMenu::ShowDialog) .def("HideDialog", &CUIActorMenu::HideDialog) .def("ToSlot", &CUIActorMenu::ToSlotScript) - .def("ToBelt", &CUIActorMenu::ToBeltScript) - ]; - - using namespace luabind; + .def("ToBelt", &CUIActorMenu::ToBeltScript), - module(luaState, "ActorMenu") - [ - def("get_pda_menu", +[](){ return &CurrentGameUI()->GetPdaMenu(); }), - def("get_actor_menu", +[](){ return &CurrentGameUI()->GetActorMenu(); }), - def("get_menu_mode", +[](){ return CurrentGameUI()->GetActorMenu().GetMenuMode(); }), - def("get_maingame", +[](){ return CurrentGameUI()->UIMainIngameWnd; }) - ]; -}); - -SCRIPT_EXPORT(CUIPdaWnd, (CUIDialogWnd), -{ - using namespace luabind; - - module(luaState) - [ class_("CUIPdaWnd") .def(constructor<>()) .def("IsShown", &CUIPdaWnd::IsShown) @@ -167,4 +148,12 @@ SCRIPT_EXPORT(CUIPdaWnd, (CUIDialogWnd), .def("GetActiveSection", &CUIPdaWnd::GetActiveSection) .def("GetTabControl", &CUIPdaWnd::GetTabControl) ]; -}); + + module(luaState, "ActorMenu") + [ + def("get_pda_menu", +[](){ return &CurrentGameUI()->GetPdaMenu(); }), + def("get_actor_menu", +[](){ return &CurrentGameUI()->GetActorMenu(); }), + def("get_menu_mode", +[](){ return CurrentGameUI()->GetActorMenu().GetMenuMode(); }), + def("get_maingame", +[](){ return CurrentGameUI()->UIMainIngameWnd; }) + ]; +} diff --git a/src/xrGame/ui/UICellItem.cpp b/src/xrGame/ui/UICellItem.cpp index a332df38578..d231fb12e72 100644 --- a/src/xrGame/ui/UICellItem.cpp +++ b/src/xrGame/ui/UICellItem.cpp @@ -255,7 +255,7 @@ void CUICellItem::UpdateConditionProgressBar() else cond = (float)remaining_uses * 0.125f - 0.0625f; - m_pConditionState->m_bUseGradient = false; + m_pConditionState->UseGradient(false); } } diff --git a/src/xrGame/ui/UIDialogWnd.h b/src/xrGame/ui/UIDialogWnd.h index a2e8f89c776..cadcba05283 100644 --- a/src/xrGame/ui/UIDialogWnd.h +++ b/src/xrGame/ui/UIDialogWnd.h @@ -1,8 +1,8 @@ #pragma once + #include "xrUICore/Windows/UIWindow.h" -#include "UIDialogHolder.h" -class CDialogHolder; +#include "UIDialogHolder.h" class CUIDialogWnd : public CUIWindow { @@ -37,4 +37,7 @@ class CUIDialogWnd : public CUIWindow pcstr GetDebugType() override { return "CUIDialogWnd"; } void FillDebugInfo() override; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CUIWindow, CDialogHolder); }; diff --git a/src/xrGame/ui/UIHudStatesWnd.cpp b/src/xrGame/ui/UIHudStatesWnd.cpp index 9cfcb6307e1..404f38a5f94 100644 --- a/src/xrGame/ui/UIHudStatesWnd.cpp +++ b/src/xrGame/ui/UIHudStatesWnd.cpp @@ -854,7 +854,7 @@ float CUIHudStatesWnd::get_zone_cur_power(ALife::EHitType hit_type) void CUIHudStatesWnd::DrawZoneIndicators() { CActor* actor = smart_cast(Level().CurrentViewEntity()); - if (!actor) + if (!actor || ShadowOfChernobylMode) return; UpdateIndicators(actor); diff --git a/src/xrGame/ui/UIItemInfo.cpp b/src/xrGame/ui/UIItemInfo.cpp index d613444d4d0..3834ce3f1ad 100644 --- a/src/xrGame/ui/UIItemInfo.cpp +++ b/src/xrGame/ui/UIItemInfo.cpp @@ -216,7 +216,7 @@ void CUIItemInfo::InitItem(CUICellItem* pCellItem, CInventoryItem* pCompareItem, { if (item_price != u32(-1)) { - xr_sprintf(str, "%d RU", item_price); // will be owerwritten in multiplayer + xr_sprintf(str, "%d %s", item_price, StringTable().GetCurrency().c_str()); // will be owerwritten in multiplayer UICost->SetText(str); pos.x = UICost->GetWndPos().x; if (m_complex_desc) diff --git a/src/xrGame/ui/UIMainIngameWnd.cpp b/src/xrGame/ui/UIMainIngameWnd.cpp index eadd88bdae2..dddb108a09f 100644 --- a/src/xrGame/ui/UIMainIngameWnd.cpp +++ b/src/xrGame/ui/UIMainIngameWnd.cpp @@ -76,7 +76,7 @@ void CUIMainIngameWnd::Init() CUIXml uiXml; uiXml.Load(CONFIG_PATH, UI_PATH, UI_PATH_DEFAULT, MAININGAME_XML); - CUIXmlInit::InitWindow(uiXml, "main", 0, this); + CUIXmlInit::InitWindow(uiXml, "main", 0, this, !ShadowOfChernobylMode); Enable(false); @@ -220,7 +220,7 @@ void CUIMainIngameWnd::Init() AttachChild(UIMotionIcon); } - UIStaticDiskIO = UIHelper::CreateStatic(uiXml, "disk_io", this); + UIStaticDiskIO = UIHelper::CreateStatic(uiXml, "disk_io", this, !ShadowOfChernobylMode); if (IsGameTypeSingle() && uiXml.NavigateToNode("artefact_panel", 0)) { @@ -229,10 +229,12 @@ void CUIMainIngameWnd::Init() this->AttachChild(UIArtefactPanel); } - m_ui_hud_states = xr_new(); - m_ui_hud_states->SetAutoDelete(true); - AttachChild(m_ui_hud_states); - m_ui_hud_states->InitFromXml(uiXml, "hud_states"); + if (!ShadowOfChernobylMode) { + m_ui_hud_states = xr_new(); + m_ui_hud_states->SetAutoDelete(true); + AttachChild(m_ui_hud_states); + m_ui_hud_states->InitFromXml(uiXml, "hud_states"); + } int i = 0; while (true) @@ -270,13 +272,15 @@ void CUIMainIngameWnd::Draw() if (IOActive) UIStaticDiskIO_start_time = Device.fTimeGlobal; - if ((UIStaticDiskIO_start_time + 1.0f) < Device.fTimeGlobal) - UIStaticDiskIO->Show(false); - else - { - u32 alpha = clampr(iFloor(255.f * (1.f - (Device.fTimeGlobal - UIStaticDiskIO_start_time) / 1.f)), 0, 255); - UIStaticDiskIO->Show(true); - UIStaticDiskIO->SetTextureColor(color_rgba(255, 255, 255, alpha)); + if (UIStaticDiskIO) { + if ((UIStaticDiskIO_start_time + 1.0f) < Device.fTimeGlobal) + UIStaticDiskIO->Show(false); + else + { + u32 alpha = clampr(iFloor(255.f * (1.f - (Device.fTimeGlobal - UIStaticDiskIO_start_time) / 1.f)), 0, 255); + UIStaticDiskIO->Show(true); + UIStaticDiskIO->SetTextureColor(color_rgba(255, 255, 255, alpha)); + } } FS.dwOpenCounter = 0; diff --git a/src/xrGame/ui/UIMapInfo.h b/src/xrGame/ui/UIMapInfo.h index 6ad42609b38..c687d2a077f 100644 --- a/src/xrGame/ui/UIMapInfo.h +++ b/src/xrGame/ui/UIMapInfo.h @@ -17,4 +17,7 @@ class CUIMapInfo final : public CUIWindow protected: CUIScrollView* m_view; shared_str m_large_desc; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CUIWindow); }; diff --git a/src/xrGame/ui/UIMapInfo_script.cpp b/src/xrGame/ui/UIMapInfo_script.cpp index dea6ea4d0e3..92951b79b2d 100644 --- a/src/xrGame/ui/UIMapInfo_script.cpp +++ b/src/xrGame/ui/UIMapInfo_script.cpp @@ -1,8 +1,8 @@ #include "pch_script.h" + #include "UIMapInfo.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CUIMapInfo, (CUIWindow), +void CUIMapInfo::script_register(lua_State* luaState) { using namespace luabind; @@ -13,4 +13,4 @@ SCRIPT_EXPORT(CUIMapInfo, (CUIWindow), .def("Init", &CUIMapInfo::InitMapInfo) .def("InitMap", &CUIMapInfo::InitMap) ]; -}); +} diff --git a/src/xrGame/ui/UIMpTradeWnd_misc.cpp b/src/xrGame/ui/UIMpTradeWnd_misc.cpp index 677709ff680..69f05ac8f75 100644 --- a/src/xrGame/ui/UIMpTradeWnd_misc.cpp +++ b/src/xrGame/ui/UIMpTradeWnd_misc.cpp @@ -109,7 +109,7 @@ void CUIMpTradeWnd::UpdateMoneyIndicator() void CUIMpTradeWnd::SetMoneyChangeString(int diff) { string128 buff; - xr_sprintf(buff, "%+d RU", diff); + xr_sprintf(buff, "%+d %s", diff, StringTable().GetCurrency().c_str()); m_static_money_change->SetText(buff); u32 clr = (diff > 0) ? m_text_color_money_positive : m_text_color_money_negative; m_static_money_change->SetTextColor(clr); diff --git a/src/xrGame/ui/UINewsItemWnd.cpp b/src/xrGame/ui/UINewsItemWnd.cpp index 18406af4f45..98dd75a6503 100644 --- a/src/xrGame/ui/UINewsItemWnd.cpp +++ b/src/xrGame/ui/UINewsItemWnd.cpp @@ -18,7 +18,10 @@ void CUINewsItemWnd::Init(CUIXml& uiXml, LPCSTR start_from) uiXml.SetLocalRoot(node); m_UIImage = UIHelper::CreateStatic(uiXml, "image", this); - m_UICaption = UIHelper::CreateStatic(uiXml, "caption_static", this, false); // no caption tag in SOC + if (ShadowOfChernobylMode) + m_UICaption = UIHelper::CreateStatic(uiXml, "caption_static", this, false); // no caption tag in SOC + else + m_UICaption = UIHelper::CreateStatic(uiXml, "updated_section_static", this, false); // no caption tag in SOC m_UIText = UIHelper::CreateStatic(uiXml, "text_static", this, false); m_UIDate = UIHelper::CreateStatic(uiXml, "date_static", this, false); diff --git a/src/xrGame/ui/UIPdaWnd.cpp b/src/xrGame/ui/UIPdaWnd.cpp index 1f17e502dfd..78bb785ab35 100644 --- a/src/xrGame/ui/UIPdaWnd.cpp +++ b/src/xrGame/ui/UIPdaWnd.cpp @@ -78,9 +78,14 @@ void CUIPdaWnd::Init() CUIXmlInit::InitWindow(uiXml, "main", 0, this); - UIMainPdaFrame = UIHelper::CreateStatic(uiXml, "background_static", this); - m_caption = UIHelper::CreateStatic(uiXml, "caption_static", this); - m_caption_const = (m_caption->GetText()); + UIMainPdaFrame = UIHelper::CreateStatic(uiXml, "background_static", this, false); + + if (ShadowOfChernobylMode) + m_caption = UIHelper::CreateStatic(uiXml, "timer_frame_line:title", this); // no caption tag in SOC + else + m_caption = UIHelper::CreateStatic(uiXml, "caption_static", this); // no caption tag in SOC + + m_caption_const = m_caption ? m_caption->GetText() : ""; m_clock = UIHelper::CreateStatic(uiXml, "clock_wnd", this, false); if (uiXml.NavigateToNode("anim_static")) // XXX: Replace with UIHelper @@ -91,11 +96,17 @@ void CUIPdaWnd::Init() CUIXmlInit::InitAnimatedStatic(uiXml, "anim_static", 0, anim_static); } - m_btn_close = UIHelper::Create3tButton(uiXml, "close_button", this); + if (ShadowOfChernobylMode) + m_btn_close = UIHelper::Create3tButton(uiXml, "off_button", this); + else + m_btn_close = UIHelper::Create3tButton(uiXml, "close_button", this); + m_btn_close->SetAccelerator(kUI_BACK, false, 2); UI().Focus().UnregisterFocusable(m_btn_close); - m_hint_wnd = UIHelper::CreateHint(uiXml, "hint_wnd"); + + if (!ShadowOfChernobylMode) + m_hint_wnd = UIHelper::CreateHint(uiXml, "hint_wnd", false); if (IsGameTypeSingle()) { @@ -368,8 +379,9 @@ void CUIPdaWnd::DrawHint() pUIMapWnd->DrawHint(); else if (m_pActiveDialog == pUIRankingWnd && pUIRankingWnd) pUIRankingWnd->DrawHint(); - - m_hint_wnd->Draw(); + + if (m_hint_wnd) + m_hint_wnd->Draw(); } bool CUIPdaWnd::NeedCursor() const diff --git a/src/xrGame/ui/UIPdaWnd.h b/src/xrGame/ui/UIPdaWnd.h index 4949d38dc3f..3394dff1fcc 100644 --- a/src/xrGame/ui/UIPdaWnd.h +++ b/src/xrGame/ui/UIPdaWnd.h @@ -79,6 +79,7 @@ class CUIPdaWnd final : public CUIDialogWnd void Show_SecondTaskWnd(bool status); void Show_MapWnd(bool status); void Show_ContactsWnd(bool status); + void DrawUpdatedSections(); void SetActiveDialog(CUIWindow* wnd) { m_pActiveDialog = wnd; } CUIWindow* GetActiveDialog() const { return m_pActiveDialog; } diff --git a/src/xrGame/ui/UIRankingWnd.cpp b/src/xrGame/ui/UIRankingWnd.cpp index 2aaad9906f0..0ed64c40a7d 100644 --- a/src/xrGame/ui/UIRankingWnd.cpp +++ b/src/xrGame/ui/UIRankingWnd.cpp @@ -38,13 +38,13 @@ CUIRankingWnd::~CUIRankingWnd() xr_delete(achievement); m_achieves_vec.clear(); - //Alundaio: CoC Rankings + //Alundaio: CoC Rankings for (auto& ranking : m_coc_ranking_vec) xr_delete(ranking); - m_coc_ranking_vec.clear(); + m_coc_ranking_vec.clear(); - xr_delete(m_coc_ranking_actor); - //-Alundaio + xr_delete(m_coc_ranking_actor); + //-Alundaio } void CUIRankingWnd::Show(bool status) @@ -57,7 +57,7 @@ void CUIRankingWnd::Show(bool status) if (m_money_value) { string64 buf; - xr_sprintf(buf, sizeof(buf), "%d %s", Actor()->get_money(), "RU"); + xr_sprintf(buf, sizeof(buf), "%d %s", Actor()->get_money(), StringTable().GetCurrency().c_str()); m_money_value->SetText(buf); m_money_value->AdjustWidthToText(); } @@ -137,7 +137,7 @@ bool CUIRankingWnd::Init() std::ignore = UIHelper::CreateFrameLine(xml, "fraction_line1", this, false); std::ignore = UIHelper::CreateFrameLine(xml, "fraction_line2", this, false); - // Dynamic stats + // Dynamic stats XML_NODE stored_root = xml.GetLocalRoot(); XML_NODE node = xml.NavigateToNode("stat_info", 0); xml.SetLocalRoot(node); @@ -328,7 +328,7 @@ void CUIRankingWnd::DrawHint() achievement->DrawHint(); } - //Alundaio: CoC Ranking + //Alundaio: CoC Ranking for (const auto& ranking : m_coc_ranking_vec) { if (ranking->IsShown()) @@ -336,8 +336,8 @@ void CUIRankingWnd::DrawHint() } if (m_coc_ranking_actor && m_coc_ranking_actor->IsShown()) - m_coc_ranking_actor->DrawHint(); - //-Alundaio + m_coc_ranking_actor->DrawHint(); + //-Alundaio } void CUIRankingWnd::get_statistic() const @@ -464,13 +464,13 @@ void CUIRankingWnd::ResetAll() for (const auto& achievement : m_achieves_vec) achievement->Reset(); - //Alundaio: CoC Rankings + //Alundaio: CoC Rankings for (const auto& ranking : m_coc_ranking_vec) ranking->Reset(); if (m_coc_ranking_actor) m_coc_ranking_actor->Reset(); - //-Alundaio + //-Alundaio inherited::ResetAll(); } diff --git a/src/xrGame/ui/UIScriptWnd.h b/src/xrGame/ui/UIScriptWnd.h index 16e96ae1370..65b67f87933 100644 --- a/src/xrGame/ui/UIScriptWnd.h +++ b/src/xrGame/ui/UIScriptWnd.h @@ -31,4 +31,7 @@ class CUIDialogWndEx : public CUIDialogWnd, public FactoryObjectBase T* GetControl(pcstr name); pcstr GetDebugType() override { return "CUIDialogWndEx"; } + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CUIDialogWnd, CGameObject); }; diff --git a/src/xrGame/ui/UIScriptWnd_script.cpp b/src/xrGame/ui/UIScriptWnd_script.cpp index 3aaabbc9ecf..5b6dc6846f7 100644 --- a/src/xrGame/ui/UIScriptWnd_script.cpp +++ b/src/xrGame/ui/UIScriptWnd_script.cpp @@ -9,8 +9,6 @@ #include "xrUICore/MessageBox/UIMessageBox.h" #include "xrUICore/PropertiesBox/UIPropertiesBox.h" -#include "xrScriptEngine/ScriptExporter.hpp" - #if LUA_VERSION_NUM < 502 # define lua_getuservalue lua_getfenv # define lua_setuservalue lua_setfenv @@ -211,8 +209,7 @@ struct CUIDialogWndExWrapperBase final : public CUIDialogWndEx, public luabind:: } }; -// clang-format off -SCRIPT_EXPORT(CUIDialogWndEx, (CUIDialogWnd, IFactoryObject), +void CUIDialogWndEx::script_register(lua_State* luaState) { using namespace luabind; using BaseType = CUIDialogWndEx; @@ -252,5 +249,4 @@ SCRIPT_EXPORT(CUIDialogWndEx, (CUIDialogWnd, IFactoryObject), .def("GetListBox", &BaseType::GetControl) .def("GetListWnd", &BaseType::GetControl) ]; -}); -// clang-format on +} diff --git a/src/xrGame/ui/UISleepStatic.h b/src/xrGame/ui/UISleepStatic.h index 7bb6ea0109c..28ad7910f6c 100644 --- a/src/xrGame/ui/UISleepStatic.h +++ b/src/xrGame/ui/UISleepStatic.h @@ -15,4 +15,7 @@ class CUISleepStatic final : public CUIStatic virtual void Update(); virtual void InitTextureEx(LPCSTR tex_name, LPCSTR sh_name = "hud" DELIMITER "default"); pcstr GetDebugType() override { return "CUISleepStatic"; } + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CUIStatic); }; diff --git a/src/xrGame/ui/UITalkDialogWnd.cpp b/src/xrGame/ui/UITalkDialogWnd.cpp index 837bd468ae2..f1062084b8c 100644 --- a/src/xrGame/ui/UITalkDialogWnd.cpp +++ b/src/xrGame/ui/UITalkDialogWnd.cpp @@ -212,10 +212,12 @@ void CUITalkDialogWnd::AddQuestion(LPCSTR str, LPCSTR value, int number, bool b_ ++number; // zero-based index if (number <= 10) { - string16 buff; - xr_sprintf(buff, "%d.", (number == 10) ? 0 : number); if (itm->m_num_text) + { + string16 buff; + xr_sprintf(buff, "%d.", (number == 10) ? 0 : number); itm->m_num_text->SetText(buff); + } itm->m_text->SetAccelerator(SDL_SCANCODE_1 - 1 + number, true, 0); } if (b_finalizer) diff --git a/src/xrGame/ui/UITradeBar.cpp b/src/xrGame/ui/UITradeBar.cpp index ad05147db65..f59f3c83f69 100644 --- a/src/xrGame/ui/UITradeBar.cpp +++ b/src/xrGame/ui/UITradeBar.cpp @@ -28,7 +28,7 @@ void CUITradeBar::UpdateData(u32 price, float weight) const if (m_TradePrice) { - xr_sprintf(buf, "%d RU", price); + xr_sprintf(buf, "%d %s", price, StringTable().GetCurrency().c_str()); m_TradePrice->SetText(buf); m_TradePrice->AdjustWidthToText(); } diff --git a/src/xrGame/ui/UIWindow_script.cpp b/src/xrGame/ui/UIWindow_script.cpp deleted file mode 100644 index fe95d123fd4..00000000000 --- a/src/xrGame/ui/UIWindow_script.cpp +++ /dev/null @@ -1,201 +0,0 @@ -#include "pch_script.h" -#include "UIDialogWnd.h" -#include "UIDialogHolder.h" -#include "GamePersistent.h" -#include "UIMessageBoxEx.h" -#include "UILabel.h" -#include "UIMMShniaga.h" -#include "UISleepStatic.h" -#include "ServerList.h" -#include "UIMapInfo.h" -#include "xrUICore/ComboBox/UIComboBox.h" -#include "UIMapList.h" -#include "ScriptXMLInit.h" -#include "xrScriptEngine/ScriptExporter.hpp" - -// clang-format off -SCRIPT_EXPORT(CDialogHolder, (CUIWindow), -{ - using namespace luabind; - - module(luaState) - [ - class_("CDialogHolder") - .def("TopInputReceiver", &CDialogHolder::TopInputReceiver) - .def("MainInputReceiver", &CDialogHolder::TopInputReceiver) - .def("SetTopInputReceiver", &CDialogHolder::SetMainInputReceiver) - .def("SetMainInputReceiver", &CDialogHolder::SetMainInputReceiver) - .def("start_stop_menu", &CDialogHolder::StartStopMenu) - .def("AddDialogToRender", &CDialogHolder::AddDialogToRender) - .def("RemoveDialogToRender", &CDialogHolder::RemoveDialogToRender) - ]; -}); - -SCRIPT_EXPORT(CUIDialogWnd, (CDialogHolder), -{ - using namespace luabind; - - module(luaState) - [ - class_("CUIDialogWnd") - .def("ShowDialog", &CUIDialogWnd::ShowDialog) - .def("HideDialog", &CUIDialogWnd::HideDialog) - .def("GetHolder", &CUIDialogWnd::GetHolder) - .def("SetHolder", &CUIDialogWnd::SetHolder) - ]; -}); - -SCRIPT_EXPORT(CUIMessageBoxEx, (CUIDialogWnd), -{ - using namespace luabind; - - module(luaState) - [ - class_("CUIMessageBoxEx") - .def(constructor<>()) - .def("Init", &CUIMessageBoxEx::InitMessageBox) - .def("InitMessageBox", &CUIMessageBoxEx::InitMessageBox) - .def("SetText", &CUIMessageBoxEx::SetText) - .def("GetHost", &CUIMessageBoxEx::GetHost) - .def("GetPassword", &CUIMessageBoxEx::GetPassword) - ]; -}); - -SCRIPT_EXPORT(CUIMMShniaga, (CUIWindow), -{ - using namespace luabind; - - module(luaState) - [ - class_("CUIMMShniaga") - .enum_("enum_page_id") - [ - value("epi_main", CUIMMShniaga::epi_main), - value("epi_new_game", CUIMMShniaga::epi_new_game), - value("epi_new_network_game", CUIMMShniaga::epi_new_network_game) - ] - .def("SetVisibleMagnifier", &CUIMMShniaga::SetVisibleMagnifier) - .def("SetPage", &CUIMMShniaga::SetPage) - .def("ShowPage", &CUIMMShniaga::ShowPage) - ]; -}); - -SCRIPT_EXPORT(CUISleepStatic, (CUIStatic), -{ - using namespace luabind; - - module(luaState) - [ - class_("CUISleepStatic") - .def(constructor<>()) - ]; -}); - -SCRIPT_EXPORT(SServerFilters, (), -{ - using namespace luabind; - - module(luaState) - [ - class_("SServerFilters") - .def(constructor<>()) - .def_readwrite("empty", &SServerFilters::empty) - .def_readwrite("full", &SServerFilters::full) - .def_readwrite("with_pass", &SServerFilters::with_pass) - .def_readwrite("without_pass", &SServerFilters::without_pass) - .def_readwrite("without_ff", &SServerFilters::without_ff) - .def_readwrite("with_battleye", &SServerFilters::with_battleye) - .def_readwrite("listen_servers", &SServerFilters::listen_servers) - ]; -}); - -SCRIPT_EXPORT(connect_error_cb, (), -{ - using namespace luabind; - - module(luaState) - [ - class_("connect_error_cb") - .def(constructor<>()) - .def(constructor()) - .def("bind", (connect_error_cb::lua_bind_type)(&connect_error_cb::bind)) - .def("clear", &connect_error_cb::clear) - ]; -}); - -SCRIPT_EXPORT(CServerList, (CUIWindow), -{ - using namespace luabind; - - module(luaState) - [ - class_("CServerList") - .def(constructor<>()) - .enum_("enum_connect_errcode") - [ - value("ece_unique_nick_not_registred", int(ece_unique_nick_not_registred)), - value("ece_unique_nick_expired", int(ece_unique_nick_expired)) - ] - .def("SetConnectionErrCb", &CServerList::SetConnectionErrCb) - .def("ConnectToSelected", &CServerList::ConnectToSelected) - .def("SetFilters", &CServerList::SetFilters) - .def("SetPlayerName", &CServerList::SetPlayerName) - .def("RefreshList", &CServerList::RefreshGameSpyList) - .def("RefreshQuick", &CServerList::RefreshQuick) - .def("ShowServerInfo", &CServerList::ShowServerInfo) - .def("NetRadioChanged", &CServerList::NetRadioChanged) - .def("SetSortFunc", &CServerList::SetSortFunc) - ]; -}); - -SCRIPT_EXPORT(CUIMapList, (CUIWindow), -{ - using namespace luabind; - - module(luaState) - [ - class_("CUIMapList") - .def(constructor<>()) - .def("SetWeatherSelector", &CUIMapList::SetWeatherSelector) - .def("SetModeSelector", &CUIMapList::SetModeSelector) - .def("OnModeChange", &CUIMapList::OnModeChange) - .def("LoadMapList", &CUIMapList::LoadMapList) - .def("SaveMapList", &CUIMapList::SaveMapList) - .def("GetCommandLine", &CUIMapList::GetCommandLine) - .def("SetServerParams", &CUIMapList::SetServerParams) - .def("GetCurGameType", &CUIMapList::GetCurGameType) - .def("StartDedicatedServer", &CUIMapList::StartDedicatedServer) - .def("SetMapPic", &CUIMapList::SetMapPic) - .def("SetMapInfo", &CUIMapList::SetMapInfo) - .def("ClearList", &CUIMapList::ClearList) - .def("IsEmpty", &CUIMapList::IsEmpty) - ]; -}); - -SCRIPT_EXPORT(EnumGameIDs, (), -{ - using namespace luabind; - - class EnumGameIDs - { - }; - - module(luaState) - [ - class_("GAME_TYPE") - .enum_("gametype") - [ - value("GAME_UNKNOWN", int(-1)), - // SOC IDs - value("GAME_DEATHMATCH", int(eGameIDDeathmatch)), - value("GAME_TEAMDEATHMATCH", int(eGameIDTeamDeathmatch)), - value("GAME_ARTEFACTHUNT", int(eGameIDArtefactHunt)), - // CS/COP ids - value("eGameIDDeathmatch", int(eGameIDDeathmatch)), - value("eGameIDTeamDeathmatch", int(eGameIDTeamDeathmatch)), - value("eGameIDArtefactHunt", int(eGameIDArtefactHunt)), - value("eGameIDCaptureTheArtefact", int(eGameIDCaptureTheArtefact)) - ] - ]; -}); -// clang-format on diff --git a/src/xrGame/ui_export_script.cpp b/src/xrGame/ui_export_script.cpp index 9c073bc30f1..1ed28770686 100644 --- a/src/xrGame/ui_export_script.cpp +++ b/src/xrGame/ui_export_script.cpp @@ -1,17 +1,65 @@ #include "pch_script.h" + #include "MainMenu.h" -#include "UIGameCustom.h" -#include "ui/UIScriptWnd.h" -#include "ui/UIMapInfo.h" -#include "ScriptXMLInit.h" + #include "login_manager.h" #include "account_manager.h" #include "profile_store.h" -#include "xrScriptEngine/ScriptExporter.hpp" -CMainMenu* MainMenu(); +#include "xrUICore/ComboBox/UIComboBox.h" + +// Including CScriptXmlInit to prevent it being optimized out by the linker +#include "ScriptXMLInit.h" // don't remove! + +#include "ui/ServerList.h" + +#include "ui/UIMapList.h" +#include "ui/UIScriptWnd.h" +#include "ui/UIMapInfo.h" +#include "ui/UIMessageBoxEx.h" +#include "ui/UIMMShniaga.h" +#include "ui/UISleepStatic.h" + +void CDialogHolder::script_register(lua_State* luaState) +{ + using namespace luabind; + + module(luaState) + [ + class_("CDialogHolder") + .def("TopInputReceiver", &CDialogHolder::TopInputReceiver) + .def("MainInputReceiver", &CDialogHolder::TopInputReceiver) + .def("SetTopInputReceiver", &CDialogHolder::SetMainInputReceiver) + .def("SetMainInputReceiver", &CDialogHolder::SetMainInputReceiver) + .def("start_stop_menu", &CDialogHolder::StartStopMenu) + .def("AddDialogToRender", &CDialogHolder::AddDialogToRender) + .def("RemoveDialogToRender", &CDialogHolder::RemoveDialogToRender) + ]; +} + +void CUIDialogWnd::script_register(lua_State* luaState) +{ + using namespace luabind; + + module(luaState) + [ + class_("CUIDialogWnd") + .def("ShowDialog", &CUIDialogWnd::ShowDialog) + .def("HideDialog", &CUIDialogWnd::HideDialog) + .def("GetHolder", &CUIDialogWnd::GetHolder) + .def("SetHolder", &CUIDialogWnd::SetHolder), + + class_("CUIMessageBoxEx") + .def(constructor<>()) + .def("Init", &CUIMessageBoxEx::InitMessageBox) + .def("InitMessageBox", &CUIMessageBoxEx::InitMessageBox) + .def("SetText", &CUIMessageBoxEx::SetText) + .def("GetHost", &CUIMessageBoxEx::GetHost) + .def("GetPassword", &CUIMessageBoxEx::GetPassword) + ]; +} -ICF static void UIRegistratorScriptExport(lua_State* luaState) +void CMainMenu::script_register(lua_State* luaState) { using namespace luabind; @@ -41,7 +89,61 @@ ICF static void UIRegistratorScriptExport(lua_State* luaState) .def("GetDemoInfo", &CMainMenu::GetDemoInfo) .def("GetLoginMngr", &CMainMenu::GetLoginMngr) .def("GetAccountMngr", &CMainMenu::GetAccountMngr) - .def("GetProfileStore", &CMainMenu::GetProfileStore) + .def("GetProfileStore", &CMainMenu::GetProfileStore), + + class_("CUIMMShniaga") + .enum_("enum_page_id") + [ + value("epi_main", CUIMMShniaga::epi_main), + value("epi_new_game", CUIMMShniaga::epi_new_game), + value("epi_new_network_game", CUIMMShniaga::epi_new_network_game) + ] + .def("SetVisibleMagnifier", &CUIMMShniaga::SetVisibleMagnifier) + .def("SetPage", &CUIMMShniaga::SetPage) + .def("ShowPage", &CUIMMShniaga::ShowPage), + + class_("SServerFilters") + .def(constructor<>()) + .def_readwrite("empty", &SServerFilters::empty) + .def_readwrite("full", &SServerFilters::full) + .def_readwrite("with_pass", &SServerFilters::with_pass) + .def_readwrite("without_pass", &SServerFilters::without_pass) + .def_readwrite("without_ff", &SServerFilters::without_ff) + .def_readwrite("with_battleye", &SServerFilters::with_battleye) + .def_readwrite("listen_servers", &SServerFilters::listen_servers), + + class_("CServerList") + .def(constructor<>()) + .enum_("enum_connect_errcode") + [ + value("ece_unique_nick_not_registred", int(ece_unique_nick_not_registred)), + value("ece_unique_nick_expired", int(ece_unique_nick_expired)) + ] + .def("SetConnectionErrCb", &CServerList::SetConnectionErrCb) + .def("ConnectToSelected", &CServerList::ConnectToSelected) + .def("SetFilters", &CServerList::SetFilters) + .def("SetPlayerName", &CServerList::SetPlayerName) + .def("RefreshList", &CServerList::RefreshGameSpyList) + .def("RefreshQuick", &CServerList::RefreshQuick) + .def("ShowServerInfo", &CServerList::ShowServerInfo) + .def("NetRadioChanged", &CServerList::NetRadioChanged) + .def("SetSortFunc", &CServerList::SetSortFunc), + + class_("CUIMapList") + .def(constructor<>()) + .def("SetWeatherSelector", &CUIMapList::SetWeatherSelector) + .def("SetModeSelector", &CUIMapList::SetModeSelector) + .def("OnModeChange", &CUIMapList::OnModeChange) + .def("LoadMapList", &CUIMapList::LoadMapList) + .def("SaveMapList", &CUIMapList::SaveMapList) + .def("GetCommandLine", &CUIMapList::GetCommandLine) + .def("SetServerParams", &CUIMapList::SetServerParams) + .def("GetCurGameType", &CUIMapList::GetCurGameType) + .def("StartDedicatedServer", &CUIMapList::StartDedicatedServer) + .def("SetMapPic", &CUIMapList::SetMapPic) + .def("SetMapInfo", &CUIMapList::SetMapInfo) + .def("ClearList", &CUIMapList::ClearList) + .def("IsEmpty", &CUIMapList::IsEmpty) ]; module(luaState, "main_menu") @@ -50,4 +152,15 @@ ICF static void UIRegistratorScriptExport(lua_State* luaState) ]; } -SCRIPT_EXPORT_FUNC(UIRegistrator, (CDialogHolder), UIRegistratorScriptExport) +void CUISleepStatic::script_register(lua_State* luaState) +{ + using namespace luabind; + + module(luaState) + [ + class_("CUISleepStatic") + .def(constructor<>()) + ]; +} + +DEFINE_MIXED_DELEGATE_SCRIPT(connect_error_cb, "connect_error_cb"); diff --git a/src/xrGame/visual_memory_manager.cpp b/src/xrGame/visual_memory_manager.cpp index 6f7d5dc9409..8ff7f505506 100644 --- a/src/xrGame/visual_memory_manager.cpp +++ b/src/xrGame/visual_memory_manager.cpp @@ -152,7 +152,7 @@ void CVisualMemoryManager::reload(LPCSTR section) else if (m_object) { m_free.Load(READ_IF_EXISTS(pSettings, r_string, section, "vision_free_section", section), !!m_client); - m_danger.Load(READ_IF_EXISTS(pSettings, r_string, section, "vision_free_section", section), !!m_client); + m_danger.Load(READ_IF_EXISTS(pSettings, r_string, section, "vision_danger_section", section), !!m_client); } else { diff --git a/src/xrGame/weaponBM16.h b/src/xrGame/weaponBM16.h index 9e84bdcb320..d01f218e133 100644 --- a/src/xrGame/weaponBM16.h +++ b/src/xrGame/weaponBM16.h @@ -20,4 +20,7 @@ class CWeaponBM16 : public CWeaponShotgun virtual void PlayAnimShow(); virtual void PlayAnimHide(); virtual void PlayAnimBore(); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CWeaponShotgun); }; diff --git a/src/xrGame/xrGame.cpp b/src/xrGame/xrGame.cpp index 9bd5f441afc..c2010a5b923 100644 --- a/src/xrGame/xrGame.cpp +++ b/src/xrGame/xrGame.cpp @@ -26,7 +26,7 @@ extern float g_fTimeFactor; extern "C" { -XR_EXPORT IFactoryObject* __cdecl xrFactory_Create(CLASS_ID clsid) +XRGAME_API IFactoryObject* __cdecl xrFactory_Create(CLASS_ID clsid) { IFactoryObject* object = object_factory().client_object(clsid); #ifdef DEBUG @@ -38,7 +38,7 @@ XR_EXPORT IFactoryObject* __cdecl xrFactory_Create(CLASS_ID clsid) return (object); } -XR_EXPORT void __cdecl xrFactory_Destroy(IFactoryObject* O) { xr_delete(O); } +XRGAME_API void __cdecl xrFactory_Destroy(IFactoryObject* O) { xr_delete(O); } } void xrGameModule::initialize(Factory_Create*& pCreate, Factory_Destroy*& pDestroy) diff --git a/src/xrGame/xrGame.vcxproj b/src/xrGame/xrGame.vcxproj index e911aabcfcb..b24dd1c2c20 100644 --- a/src/xrGame/xrGame.vcxproj +++ b/src/xrGame/xrGame.vcxproj @@ -36,6 +36,10 @@ AnselSDK$(PlatformArchitecture).dll; AnselSDK$(PlatformArchitecture).lib;%(AdditionalDependencies) + + AnselSDK$(PlatformArchitecture).dll; + AnselSDK$(PlatformArchitecture).lib;%(AdditionalDependencies) + @@ -59,6 +63,7 @@ + @@ -919,7 +924,6 @@ - @@ -929,22 +933,15 @@ - - - - - - - @@ -1424,6 +1421,7 @@ pch_script.h $(IntDir)$(ProjectName)_script.pch + pch_script.h $(IntDir)$(ProjectName)_script.pch @@ -1471,10 +1469,6 @@ pch_script.h $(IntDir)$(ProjectName)_script.pch - - pch_script.h - $(IntDir)$(ProjectName)_script.pch - pch_script.h @@ -1496,10 +1490,6 @@ pch_script.h $(IntDir)$(ProjectName)_script.pch - - pch_script.h - $(IntDir)$(ProjectName)_script.pch - pch_script.h @@ -1572,6 +1562,10 @@ pch_script.h $(IntDir)$(ProjectName)_script.pch + + pch_script.h + $(IntDir)$(ProjectName)_script.pch + pch_script.h @@ -2056,10 +2050,6 @@ $(IntDir)$(ProjectName)_script.pch - - pch_script.h - $(IntDir)$(ProjectName)_script.pch - @@ -2143,10 +2133,6 @@ - - pch_script.h - $(IntDir)$(ProjectName)_script.pch - pch_script.h $(IntDir)$(ProjectName)_script.pch @@ -2519,7 +2505,6 @@ $(IntDir)$(ProjectName)_script.pch - @@ -2539,16 +2524,7 @@ pch_script.h $(IntDir)$(ProjectName)_script.pch - - pch_script.h - $(IntDir)$(ProjectName)_script.pch - - - - pch_script.h - $(IntDir)$(ProjectName)_script.pch - @@ -2565,24 +2541,8 @@ $(IntDir)$(ProjectName)_script.pch - - pch_script.h - $(IntDir)$(ProjectName)_script.pch - - - pch_script.h - $(IntDir)$(ProjectName)_script.pch - - - pch_script.h - $(IntDir)$(ProjectName)_script.pch - - - pch_script.h - $(IntDir)$(ProjectName)_script.pch - @@ -2745,10 +2705,6 @@ pch_script.h $(IntDir)$(ProjectName)_script.pch - - pch_script.h - $(IntDir)$(ProjectName)_script.pch - pch_script.h @@ -2783,10 +2739,6 @@ pch_script.h $(IntDir)$(ProjectName)_script.pch - - pch_script.h - $(IntDir)$(ProjectName)_script.pch - @@ -3279,10 +3231,6 @@ - - pch_script.h - $(IntDir)$(ProjectName)_script.pch - pch_script.h $(IntDir)$(ProjectName)_script.pch diff --git a/src/xrGame/xrGame.vcxproj.filters b/src/xrGame/xrGame.vcxproj.filters index 9a90ca1a782..dc88506d03f 100644 --- a/src/xrGame/xrGame.vcxproj.filters +++ b/src/xrGame/xrGame.vcxproj.filters @@ -2047,9 +2047,6 @@ {0c046796-e4c9-4297-9421-3ac357864e14} - - {d04f4571-bedc-4927-9b28-e0c0e659aafe} - {c95f3f47-da51-41f0-82c0-7efba6382172} @@ -2068,9 +2065,6 @@ {d559c651-5980-4621-8d74-09ea88469ff1} - - {66d4d9cb-fbc2-4e9a-8483-4eb5c1738ed9} - {ab1b2732-d901-4a34-ba14-eaf215d9bd6d} @@ -2152,15 +2146,9 @@ {809e504b-a9aa-414d-9340-974bf409d048} - - {078eb1f4-96f0-4ca0-b580-a649b7d8ecdb} - {0db7dc10-e1ad-4a8d-a173-8831662a2508} - - {246a7da2-6c1f-4bb8-9583-284e9ab2bf5a} - {b08ee833-e28c-4687-b6b5-0907349836ab} @@ -2170,15 +2158,9 @@ {ef5a4212-e157-425e-b5d5-87e90474397d} - - {e256099f-7f69-49b3-900a-087c7fde9645} - {9902c3e6-be5f-44b6-b539-cca3243e5e07} - - {0b7f91ec-8546-438f-9598-b42cc9f39725} - {735fa48e-0a26-4a28-993c-166e47ac4a79} @@ -6090,18 +6072,6 @@ Physics\CharacterSupport\interactive_anims - - Physics\PHCommander - - - Physics\PHCommander - - - Physics\PHCommander - - - Physics\PHCommander - Physics\DamagableItem @@ -6192,18 +6162,6 @@ Physics\MovementControl - - Physics\scripts - - - Physics\scripts - - - Physics\scripts - - - Physics\scripts - UI\Multiplayer\Voting @@ -6347,6 +6305,9 @@ AI\AMonsters\common\monster states\Move + + Core\Common\ObjectFactory + @@ -7645,15 +7606,9 @@ ScriptClasses\ScriptNetPacket - - ScriptClasses\ScriptRenderDevice - ScriptClasses\ScriptSoundInfo - - ScriptClasses\ScriptSoundType - ScriptClasses\UI @@ -7666,15 +7621,9 @@ ScriptClasses\ScriptFS - - ScriptClasses\Console - ScriptClasses\BaseClientClasses - - ScriptClasses\ScriptLAnim - ScriptClasses\ScriptFcolor @@ -7918,6 +7867,9 @@ Core\Client\Objects\actor\base + + Core\Client\Objects\actor\base + Core\Client\Objects\actor\base @@ -7939,9 +7891,6 @@ Core\Client\Objects\base\EntityAlive - - Core\Client\Objects\base\EntityCondition - Core\Client\Objects\base\EntityCondition @@ -8800,9 +8749,6 @@ Core\Server\ServerEntities\objects_alife_items - - Core\Server\ServerEntities\objects_alife_items - Core\Server\ServerEntities\objects_alife_monsters @@ -9079,9 +9025,6 @@ UI\UIWindows\Windows - - UI\UIWindows\Windows - UI\UIWindows\ScriptWnd @@ -9346,18 +9289,6 @@ Physics\CharacterSupport\interactive_anims - - Physics\PHCommander - - - Physics\PHCommander - - - Physics\PHCommander - - - Physics\PHCommander - Physics\DamagableItem @@ -9436,18 +9367,6 @@ Physics\MovementControl - - Physics\scripts - - - Physics\scripts - - - Physics\scripts - - - Physics\scripts - UI\Multiplayer\Voting @@ -9573,6 +9492,9 @@ Core\Server\ServerEntities\scripts\script_properties_list_helper + + Core\Common\ObjectFactory + diff --git a/src/xrGameSpy/CMakeLists.txt b/src/xrGameSpy/CMakeLists.txt index 7c6b6254140..4957545e73b 100644 --- a/src/xrGameSpy/CMakeLists.txt +++ b/src/xrGameSpy/CMakeLists.txt @@ -1,9 +1,4 @@ -if (STATIC_BUILD) - add_library(xrGameSpy STATIC) -else() - add_library(xrGameSpy SHARED) -endif() - +add_library(xrGameSpy) target_sources_grouped( TARGET xrGameSpy @@ -67,7 +62,6 @@ target_compile_definitions(xrGameSpy set_target_properties(xrGameSpy PROPERTIES PREFIX "" - POSITION_INDEPENDENT_CODE ON ) target_precompile_headers(xrGameSpy @@ -75,7 +69,7 @@ target_precompile_headers(xrGameSpy stdafx.h ) -if (NOT STATIC_BUILD) +if (BUILD_SHARED_LIBS) install(TARGETS xrGameSpy LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ) diff --git a/src/xrGameSpy/stdafx.h b/src/xrGameSpy/stdafx.h index eee67295a98..67949e39359 100644 --- a/src/xrGameSpy/stdafx.h +++ b/src/xrGameSpy/stdafx.h @@ -17,5 +17,14 @@ // XXX: remove hack #undef min #undef max +#undef accept +#undef bind +#undef connect +#undef getpeername +#undef getsockname +#undef getsockopt +#undef recvfrom +#undef sendto +#undef setsockopt #include "xrCore/xrCore.h" diff --git a/src/xrGameSpy/xrGameSpy.h b/src/xrGameSpy/xrGameSpy.h index f16710f61a5..828c4d1f1c7 100644 --- a/src/xrGameSpy/xrGameSpy.h +++ b/src/xrGameSpy/xrGameSpy.h @@ -12,8 +12,7 @@ #include #include -// XXX: temporary use MASTER_GOLD here, switch to XRAY_STATIC_BUILD later -#ifdef MASTER_GOLD // XRAY_STATIC_BUILD +#ifdef XRAY_STATIC_BUILD # define XRGAMESPY_API #else # ifdef XRGAMESPY_EXPORTS @@ -38,3 +37,12 @@ XRGAMESPY_API void GetGameID(int* GameID, int verID); // XXX: remove hack #undef min #undef max +#undef accept +#undef bind +#undef connect +#undef getpeername +#undef getsockname +#undef getsockopt +#undef recvfrom +#undef sendto +#undef setsockopt diff --git a/src/xrGameSpy/xrGameSpy.vcxproj b/src/xrGameSpy/xrGameSpy.vcxproj index b3a726494ee..1baac68de55 100644 --- a/src/xrGameSpy/xrGameSpy.vcxproj +++ b/src/xrGameSpy/xrGameSpy.vcxproj @@ -12,9 +12,6 @@ - - StaticLibrary - diff --git a/src/xrMaterialSystem/CMakeLists.txt b/src/xrMaterialSystem/CMakeLists.txt index f0ee8cc20ce..6519ca1e96c 100644 --- a/src/xrMaterialSystem/CMakeLists.txt +++ b/src/xrMaterialSystem/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(xrMaterialSystem SHARED) +add_library(xrMaterialSystem) target_sources_grouped( TARGET xrMaterialSystem @@ -38,6 +38,8 @@ target_precompile_headers(xrMaterialSystem stdafx.h ) -install(TARGETS xrMaterialSystem LIBRARY - DESTINATION "${CMAKE_INSTALL_LIBDIR}" -) +if (BUILD_SHARED_LIBS) + install(TARGETS xrMaterialSystem LIBRARY + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) +endif() diff --git a/src/xrMaterialSystem/GameMtlLib.cpp b/src/xrMaterialSystem/GameMtlLib.cpp index 5942854771a..355afac6d14 100644 --- a/src/xrMaterialSystem/GameMtlLib.cpp +++ b/src/xrMaterialSystem/GameMtlLib.cpp @@ -10,7 +10,7 @@ const char* SGameMtlPair::dbg_Name() const static string256 nm; const SGameMtl* M0 = GMLib.GetMaterialByID(GetMtl0()); const SGameMtl* M1 = GMLib.GetMaterialByID(GetMtl1()); - xr_sprintf(nm, sizeof(nm), "Pair: %s - %s", *M0->m_Name, *M1->m_Name); + xr_sprintf(nm, sizeof(nm), "Pair: %s - %s", M0->m_Name.c_str(), M1->m_Name.c_str()); return nm; } #endif @@ -94,8 +94,10 @@ bool assign_default_acoustics(const shared_str& material, SGameMtl::MtlAcoustics return found; } -void SGameMtl::Load(IReader& fs) +EGameMtlVersion SGameMtl::Load(IReader& fs) { + EGameMtlVersion vers{ GAMEMTL_VERSION_SOC }; + R_ASSERT(fs.find_chunk(GAMEMTL_CHUNK_MAIN)); ID = fs.r_u32(); fs.r_stringZ(m_Name); @@ -121,11 +123,6 @@ void SGameMtl::Load(IReader& fs) fVisTransparencyFactor = fs.r_float(); fSndOcclusionFactor = fs.r_float(); - if (fs.find_chunk(GAMEMTL_CHUNK_FACTORS_MP)) - fShootFactorMP = fs.r_float(); - else - fShootFactorMP = fShootFactor; - if (fs.find_chunk(GAMEMTL_CHUNK_FLOTATION)) fFlotationFactor = fs.r_float(); @@ -133,7 +130,18 @@ void SGameMtl::Load(IReader& fs) fInjuriousSpeed = fs.r_float(); if (fs.find_chunk(GAMEMTL_CHUNK_DENSITY)) + { fDensityFactor = fs.r_float(); + vers = GAMEMTL_VERSION_CS; + } + + if (fs.find_chunk(GAMEMTL_CHUNK_FACTORS_MP)) + { + fShootFactorMP = fs.r_float(); + vers = GAMEMTL_VERSION_COP; + } + else + fShootFactorMP = fShootFactor; if (fs.find_chunk(GAMEMTL_CHUNK_ACOUSTICS)) fs.r(&Acoustics, sizeof(Acoustics)); @@ -147,6 +155,8 @@ void SGameMtl::Load(IReader& fs) Acoustics.fAbsorption[2] = fSndOcclusionFactor; } } + + return vers; } CGameMtlLibrary::CGameMtlLibrary() @@ -173,10 +183,10 @@ void CGameMtlLibrary::Load() IReader& fs = *F; R_ASSERT(fs.find_chunk(GAMEMTLS_CHUNK_VERSION)); - m_version = static_cast(fs.r_u16()); - if (GAMEMTL_CURRENT_VERSION != m_version) + const auto file_version = static_cast(fs.r_u16()); + if (file_version != GAMEMTL_VERSION_COP) { - Msg("CGameMtlLibrary: unsupported version [%u]. Library can't load.", m_version); + Msg("CGameMtlLibrary: unsupported version [%u]. Library can't load.", file_version); FS.r_close(F); return; } @@ -190,6 +200,8 @@ void CGameMtlLibrary::Load() materials.reserve(material_index); material_pairs.reserve(material_pair_index); + auto detected_version{ GAMEMTL_VERSION_SOC }; + IReader* OBJ = fs.open_chunk(GAMEMTLS_CHUNK_MTLS); if (OBJ) { @@ -197,10 +209,12 @@ void CGameMtlLibrary::Load() for (IReader* O = OBJ->open_chunk_iterator(count); O; O = OBJ->open_chunk_iterator(count, O)) { SGameMtl* M = materials.emplace_back(xr_new()); - M->Load(*O); + const auto version = M->Load(*O); + detected_version = std::max(detected_version, version); } OBJ->close(); } + m_version = detected_version; OBJ = fs.open_chunk(GAMEMTLS_CHUNK_MTLS_PAIR); if (OBJ) @@ -213,8 +227,8 @@ void CGameMtlLibrary::Load() } OBJ->close(); } - const u32 mtlCount = materials.size(); - material_pairs_rt.resize(mtlCount * mtlCount, 0); + const auto mtlCount = materials.size(); + material_pairs_rt.resize(mtlCount * mtlCount, nullptr); for (const auto& mtlPair : material_pairs) { const int idx0 = GetMaterialIdx(mtlPair->mtl0) * mtlCount + GetMaterialIdx(mtlPair->mtl1); diff --git a/src/xrMaterialSystem/GameMtlLib.h b/src/xrMaterialSystem/GameMtlLib.h index 629431b8bf9..2ada0474597 100644 --- a/src/xrMaterialSystem/GameMtlLib.h +++ b/src/xrMaterialSystem/GameMtlLib.h @@ -8,10 +8,14 @@ #include "Include/xrRender/WallMarkArray.h" #include "Include/xrRender/RenderFactory.h" -#ifdef XRMTL_LIB_EXPORTS -#define MTL_EXPORT_API XR_EXPORT +#ifdef XRAY_STATIC_BUILD +# define MTL_EXPORT_API #else -#define MTL_EXPORT_API XR_IMPORT +# ifdef XRMTL_LIB_EXPORTS +# define MTL_EXPORT_API XR_EXPORT +# else +# define MTL_EXPORT_API XR_IMPORT +# endif #endif constexpr u32 GAMEMTLS_CHUNK_VERSION = 0x1000; @@ -44,20 +48,23 @@ constexpr u32 GAMEMTL_NONE_IDX = u16(-1); constexpr pcstr GAMEMTL_FILENAME = "gamemtl.xr"; -enum EGameMtlVersion : u16 +enum EGameMtlVersion : s32 { // The big issue is that GSC had version 1 in SOC, // then they introduced a significant change in CS, // but didn't change the version number... // In fact, they NEVER have changed the number // since the system was introduced in 2002. - // So, we introduce helper values: - GAMEMTL_VERSION_SOC = u16(-1), + // So, we introduce virtual values: + GAMEMTL_VERSION_SOC = -2, + GAMEMTL_VERSION_CS = -1, GAMEMTL_VERSION_UNKNOWN = 0, // Real version numbers in GAMEMTL_FILENAME: - GAMEMTL_CURRENT_VERSION = 1, + GAMEMTL_VERSION_COP = 1, + + GAMEMTL_CURRENT_VERSION = GAMEMTL_VERSION_COP, }; // fwd. decl. @@ -69,49 +76,53 @@ struct MTL_EXPORT_API SGameMtl friend class CGameMtlLibrary; protected: - int ID; // auto number + int ID{ -1 }; // auto number + public: enum : u32 { - flBreakable = (1ul << 0ul), - // flShootable = (1ul<<1ul), - flBounceable = (1ul << 2ul), - flSkidmark = (1ul << 3ul), - flBloodmark = (1ul << 4ul), - flClimable = (1ul << 5ul), - // flWalkOn = (1ul<<6ul), // obsolette - flPassable = (1ul << 7ul), - flDynamic = (1ul << 8ul), - flLiquid = (1ul << 9ul), - flSuppressShadows = (1ul << 10ul), - flSuppressWallmarks = (1ul << 11ul), - flActorObstacle = (1ul << 12ul), - flNoRicoshet = (1ul << 13ul), - flInjurious = (1ul << 28ul), // flInjurious = fInjuriousSpeed > 0.f - flShootable = (1ul << 29ul), - flTransparent = (1ul << 30ul), - flSlowDown = (1ul << 31ul) // flSlowDown = (fFlotationFactor<1.f) + flBreakable = 1ul << 0ul, + // flShootable = 1ul << 1ul, + flBounceable = 1ul << 2ul, + flSkidmark = 1ul << 3ul, + flBloodmark = 1ul << 4ul, + flClimable = 1ul << 5ul, + //flWalkOn = 1ul << 6ul, // obsolette + flPassable = 1ul << 7ul, + flDynamic = 1ul << 8ul, + flLiquid = 1ul << 9ul, + flSuppressShadows = 1ul << 10ul, + flSuppressWallmarks = 1ul << 11ul, + flActorObstacle = 1ul << 12ul, + flNoRicoshet = 1ul << 13ul, + + flInjurious = 1ul << 28ul, // flInjurious = fInjuriousSpeed > 0.f + flShootable = 1ul << 29ul, + flTransparent = 1ul << 30ul, + flSlowDown = 1ul << 31ul, // flSlowDown = (fFlotationFactor<1.f) }; public: - shared_str m_Name; + shared_str m_Name{ "unknown" }; shared_str m_Desc; - Flags32 Flags; + Flags32 Flags{}; + // physics part - float fPHFriction; // ? - float fPHDamping; // ? - float fPHSpring; // ? - float fPHBounceStartVelocity; // ? - float fPHBouncing; // ? - // shoot&bounce&visibility&flotation - float fFlotationFactor; // 0.f - 1.f (1.f-полноÑтью проходимый) - float fShootFactor; // 0.f - 1.f (1.f-полноÑтью проÑтреливаемый) - float fShootFactorMP; // 0.f - 1.f (1.f-полноÑтью проÑтреливаемый) - float fBounceDamageFactor; // 0.f - 100.f - float fInjuriousSpeed; // 0.f - ... (0.f-не отбирает здоровье (ÑкороÑть ÑƒÐ¼ÐµÐ½ÑŒÑˆÐµÐ½Ð¸Ñ Ð·Ð´Ð¾Ñ€Ð¾Ð²ÑŒÑ)) - float fVisTransparencyFactor; // 0.f - 1.f (1.f-полноÑтью прозрачный) - float fSndOcclusionFactor; // 0.f - 1.f (1.f-полноÑтью Ñлышен) - float fDensityFactor; + float fPHFriction{ 1.0f }; + float fPHDamping{ 1.0f }; + float fPHSpring{ 1.0f }; + float fPHBounceStartVelocity{ 0.0f }; + float fPHBouncing{ 0.1f }; + + // shoot & bounce & visibility & flotation + float fFlotationFactor{ 1.0f }; // 0.f - 1.f (1.f-полноÑтью проходимый) + float fShootFactor{ 0.0f }; // 0.f - 1.f (1.f-полноÑтью проÑтреливаемый) + float fShootFactorMP{ 0.0f }; // 0.f - 1.f (1.f-полноÑтью проÑтреливаемый) + float fBounceDamageFactor{ 1.0f }; // 0.f - 100.f + float fInjuriousSpeed{ 0.0f }; // 0.f - ... (0.f-не отбирает здоровье (ÑкороÑть ÑƒÐ¼ÐµÐ½ÑŒÑˆÐµÐ½Ð¸Ñ Ð·Ð´Ð¾Ñ€Ð¾Ð²ÑŒÑ)) + float fVisTransparencyFactor{ 0.0f }; // 0.f - 1.f (1.f-полноÑтью прозрачный) + float fSndOcclusionFactor{ 0.0f }; // 0.f - 1.f (1.f-полноÑтью Ñлышен) + float fDensityFactor{ 0.0f }; struct MtlAcoustics { @@ -122,30 +133,11 @@ struct MTL_EXPORT_API SGameMtl MtlAcoustics Acoustics{}; public: - SGameMtl() - { - ID = -1; - m_Name = "unknown"; - Flags.zero(); - // factors - fFlotationFactor = 1.f; - fShootFactor = 0.f; - fShootFactorMP = 0.f; - fBounceDamageFactor = 1.f; - fInjuriousSpeed = 0.f; - fVisTransparencyFactor = 0.f; - fSndOcclusionFactor = 0.f; - // physics - fPHFriction = 1.f; - fPHDamping = 1.f; - fPHSpring = 1.f; - fPHBounceStartVelocity = 0.f; - fPHBouncing = 0.1f; - fDensityFactor = 0.0f; - } - void Load(IReader& fs); + EGameMtlVersion Load(IReader& fs); void Save(IWriter& fs); - int GetID() const { return ID; } + + [[nodiscard]] int GetID() const { return ID; } + #ifdef _EDITOR void FillProp(PropItemVec& values, ListItem* owner); #endif @@ -154,25 +146,27 @@ struct MTL_EXPORT_API SGameMtl struct MTL_EXPORT_API SGameMtlPair { friend class CGameMtlLibrary; + enum { - // flFlotation = (1<<0), - flBreakingSounds = (1 << 1), - flStepSounds = (1 << 2), - // flCollideSounds = (1<<3), - flCollideSounds = (1 << 4), - flCollideParticles = (1 << 5), - flCollideMarks = (1 << 6) + // flFlotation = 1 << 0, + flBreakingSounds = 1 << 1, + flStepSounds = 1 << 2, + // flCollideSounds = 1 << 3, + flCollideSounds = 1 << 4, + flCollideParticles = 1 << 5, + flCollideMarks = 1 << 6, }; + CGameMtlLibrary* m_Owner; private: - int mtl0; - int mtl1; + int mtl0{ -1 }; + int mtl1{ -1 }; protected: - int ID; // auto number - int ID_parent; + int ID{ -1 }; // auto number + int ID_parent{ - 1 }; public: Flags32 OwnProps; @@ -187,31 +181,36 @@ struct MTL_EXPORT_API SGameMtlPair public: SGameMtlPair(CGameMtlLibrary* owner) { - mtl0 = -1; - mtl1 = -1; - ID = -1; - ID_parent = -1; m_Owner = owner; OwnProps.one(); } + ~SGameMtlPair(); - int GetMtl0() const { return mtl0; } - int GetMtl1() const { return mtl1; } - int GetID() const { return ID; } - void SetPair(int m0, int m1) + [[nodiscard]] int GetMtl0() const { return mtl0; } + [[nodiscard]] int GetMtl1() const { return mtl1; } + [[nodiscard]] int GetID() const { return ID; } + + void SetPair(const int m0, const int m1) { mtl0 = m0; mtl1 = m1; } - bool IsPair(int m0, int m1) const + + [[nodiscard]] + bool IsPair(const int m0, const int m1) const { return (mtl0 == m0 && mtl1 == m1) || (mtl0 == m1 && mtl1 == m0); } + + [[nodiscard]] int GetParent() const { return ID_parent; } + void Save(IWriter& fs); void Load(IReader& fs); + #ifdef DEBUG + [[nodiscard]] const char* dbg_Name() const; #endif @@ -252,6 +251,7 @@ class MTL_EXPORT_API CGameMtlLibrary public: CGameMtlLibrary(); ~CGameMtlLibrary() {} + void Unload() { m_library_crc32 = 0; @@ -264,60 +264,70 @@ class MTL_EXPORT_API CGameMtlLibrary material_pairs.clear(); } - auto GetMaterialIt(pcstr name) + [[nodiscard]] auto GetMaterialIt(pcstr name) { auto pred = [&](const SGameMtl* mtl) { return !xr_strcmpi(mtl->m_Name.c_str(), name); }; return std::find_if(materials.begin(), materials.end(), pred); } - auto GetMaterialIt(const shared_str& name) + + [[nodiscard]] auto GetMaterialIt(const shared_str& name) { auto pred = [&](const SGameMtl* mtl) { return mtl->m_Name.equal(name); }; return std::find_if(materials.begin(), materials.end(), pred); } - auto GetMaterialItByID(int id) + + [[nodiscard]] auto GetMaterialItByID(int id) { auto pred = [&](const SGameMtl* mtl) { return mtl->ID == id; }; return std::find_if(materials.begin(), materials.end(), pred); } - u32 GetMaterialID(pcstr name) + + [[nodiscard]] u32 GetMaterialID(pcstr name) { const auto it = GetMaterialIt(name); return it == materials.end() ? GAMEMTL_NONE_ID : (*it)->ID; } - SGameMtl* GetMaterial(pcstr name) + + [[nodiscard]] SGameMtl* GetMaterial(pcstr name) { const auto it = GetMaterialIt(name); return materials.end() != it ? *it : nullptr; } - SGameMtl* GetMaterialByID(s32 id) + + [[nodiscard]] SGameMtl* GetMaterialByID(s32 id) { const auto it = GetMaterialItByID(id); return it != materials.end() ? *it : nullptr; } - u16 GetMaterialIdx(int ID) + + [[nodiscard]] u16 GetMaterialIdx(int ID) { const auto it = GetMaterialItByID(ID); VERIFY(materials.end() != it); return u16(it - materials.begin()); } - u16 GetMaterialIdx(pcstr name) + + [[nodiscard]] u16 GetMaterialIdx(pcstr name) { const auto it = GetMaterialIt(name); VERIFY(materials.end() != it); return u16(it - materials.begin()); } - SGameMtl* GetMaterialByIdx(u16 idx) const + + [[nodiscard]] SGameMtl* GetMaterialByIdx(u16 idx) const { - VERIFY(idx < (u16)materials.size()); + VERIFY(idx < materials.size()); return materials[idx]; } - auto FirstMaterial() { return materials.begin(); } - auto LastMaterial() { return materials.end(); } + [[nodiscard]] auto FirstMaterial() { return materials.begin(); } + [[nodiscard]] auto LastMaterial() { return materials.end(); } + [[nodiscard]] const auto& Materials() const { return materials; } - u32 CountMaterial() const { return materials.size(); } + [[nodiscard]] + auto CountMaterial() const { return materials.size(); } #ifdef _EDITOR SGameMtl* AppendMaterial(SGameMtl* parent); @@ -342,15 +352,22 @@ class MTL_EXPORT_API CGameMtlLibrary #endif // _EDITOR // game + [[nodiscard]] SGameMtlPair* GetMaterialPairByIndices(u16 i0, u16 i1) const { - const u32 mtlCount = materials.size(); + const auto mtlCount = materials.size(); R_ASSERT(i0 < mtlCount && i1 < mtlCount); return material_pairs_rt[i1 * mtlCount + i0]; } - GameMtlPairIt FirstMaterialPair() { return material_pairs.begin(); } - GameMtlPairIt LastMaterialPair() { return material_pairs.end(); } + [[nodiscard]] GameMtlPairIt FirstMaterialPair() { return material_pairs.begin(); } + [[nodiscard]] GameMtlPairIt LastMaterialPair() { return material_pairs.end(); } + + [[nodiscard]] + auto GetLibraryVersion() const noexcept + { + return m_version; + } [[nodiscard]] auto GetLibraryCrc32() const noexcept diff --git a/src/xrMaterialSystem/GameMtlLib_Engine.cpp b/src/xrMaterialSystem/GameMtlLib_Engine.cpp index 66b9bb7c230..234464e285e 100644 --- a/src/xrMaterialSystem/GameMtlLib_Engine.cpp +++ b/src/xrMaterialSystem/GameMtlLib_Engine.cpp @@ -70,19 +70,19 @@ void SGameMtlPair::Load(IReader& fs) R_ASSERT(fs.find_chunk(GAMEMTLPAIR_CHUNK_BREAKING)); fs.r_stringZ(buf); - CreateSounds(BreakingSounds, *buf); + CreateSounds(BreakingSounds, buf.c_str()); R_ASSERT(fs.find_chunk(GAMEMTLPAIR_CHUNK_STEP)); fs.r_stringZ(buf); - CreateSounds(StepSounds, *buf); + CreateSounds(StepSounds, buf.c_str()); R_ASSERT(fs.find_chunk(GAMEMTLPAIR_CHUNK_COLLIDE)); fs.r_stringZ(buf); - CreateSounds(CollideSounds, *buf); + CreateSounds(CollideSounds, buf.c_str()); fs.r_stringZ(buf); - CreatePSs(CollideParticles, *buf); + CreatePSs(CollideParticles, buf.c_str()); fs.r_stringZ(buf); - CreateMarks(&*CollideMarks, *buf); + CreateMarks(&*CollideMarks, buf.c_str()); } diff --git a/src/xrNetServer/CMakeLists.txt b/src/xrNetServer/CMakeLists.txt index 84012b9f117..a2c959c8558 100644 --- a/src/xrNetServer/CMakeLists.txt +++ b/src/xrNetServer/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(xrNetServer SHARED) +add_library(xrNetServer) target_sources(xrNetServer PRIVATE guids.cpp @@ -52,6 +52,8 @@ target_precompile_headers(xrNetServer stdafx.h ) -install(TARGETS xrNetServer LIBRARY - DESTINATION "${CMAKE_INSTALL_LIBDIR}" -) +if (BUILD_SHARED_LIBS) + install(TARGETS xrNetServer LIBRARY + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) +endif() diff --git a/src/xrNetServer/NET_Client.cpp b/src/xrNetServer/NET_Client.cpp index 60542819e32..dab8641e58a 100644 --- a/src/xrNetServer/NET_Client.cpp +++ b/src/xrNetServer/NET_Client.cpp @@ -591,7 +591,7 @@ bool IPureClient::Connect(pcstr options) net_csEnumeration.Enter(); // real connect for (u32 I = 0; I < net_Hosts.size(); I++) - Msg("* HOST #%d: %s\n", I + 1, *net_Hosts[I].dpSessionName); + Msg("* HOST #%d: %s\n", I + 1, net_Hosts[I].dpSessionName.c_str()); R_CHK(net_Hosts.front().pHostAddress->Duplicate(&pHostAddress)); // dump_URL ("! c2s ", pHostAddress); diff --git a/src/xrParticles/CMakeLists.txt b/src/xrParticles/CMakeLists.txt index 4863ded0863..1bc37e985e4 100644 --- a/src/xrParticles/CMakeLists.txt +++ b/src/xrParticles/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(xrParticles SHARED) +add_library(xrParticles) target_sources_grouped( TARGET xrParticles @@ -55,6 +55,8 @@ target_precompile_headers(xrParticles stdafx.h ) -install(TARGETS xrParticles LIBRARY - DESTINATION "${CMAKE_INSTALL_LIBDIR}" -) +if (BUILD_SHARED_LIBS) + install(TARGETS xrParticles LIBRARY + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) +endif() diff --git a/src/xrPhysics/CMakeLists.txt b/src/xrPhysics/CMakeLists.txt index b072f9150ea..6c3e6299ca6 100644 --- a/src/xrPhysics/CMakeLists.txt +++ b/src/xrPhysics/CMakeLists.txt @@ -1,8 +1,4 @@ -if (STATIC_BUILD) - add_library(xrPhysics STATIC) -else() - add_library(xrPhysics SHARED) -endif() +add_library(xrPhysics) target_sources_grouped( TARGET xrPhysics @@ -74,6 +70,7 @@ target_sources_grouped( IPhysicsShellHolder.h PhysicsShell.cpp PhysicsShell.h + PhysicsShellScript.cpp ) target_sources_grouped( @@ -163,6 +160,20 @@ target_sources_grouped( PHMoveStorage.h ) +target_sources_grouped( + TARGET xrPhysics + NAME "Physics\\Base\\Objects\\PHCommander" + FILES + PHCommander.cpp + PHCommander.h + PHReqComparer.h + PHScriptCall.cpp + PHScriptCall.h + PHSimpleCalls.cpp + PHSimpleCalls.h + PHSimpleCallsScript.cpp +) + target_sources_grouped( TARGET xrPhysics NAME "Physics\\Base\\Objects\\PHIsland" @@ -239,15 +250,6 @@ target_sources_grouped( PHSimpleCharacterInline.h ) -target_sources_grouped( - TARGET xrPhysics - NAME "Physics\\Base\\Objects\\script" - FILES - iphysics_scripted.h - physics_scripted.cpp - physics_scripted.h -) - target_sources_grouped( TARGET xrPhysics NAME "Physics\\Base\\Objects\\Shell" @@ -328,6 +330,7 @@ target_sources_grouped( PHItemList.h PHWorld.cpp PHWorld.h + PHWorldScript.cpp Physics.cpp Physics.h ) @@ -379,7 +382,8 @@ target_sources_grouped( tri-colliderknoopc/dTriSphere.cpp tri-colliderknoopc/dTriSphere.h tri-colliderknoopc/dxTriList.h - tri-colliderknoopc/TriPrimitiveCollideClassDef.h) + tri-colliderknoopc/TriPrimitiveCollideClassDef.h +) target_sources_grouped( TARGET xrPhysics @@ -389,7 +393,6 @@ target_sources_grouped( icollisiondamagereceiver.h ) - target_include_directories(xrPhysics PUBLIC "${CMAKE_SOURCE_DIR}/Externals" @@ -423,7 +426,6 @@ target_compile_definitions(xrPhysics set_target_properties(xrPhysics PROPERTIES PREFIX "" - POSITION_INDEPENDENT_CODE ON ) target_precompile_headers(xrPhysics @@ -431,7 +433,7 @@ target_precompile_headers(xrPhysics StdAfx.h ) -if (NOT STATIC_BUILD) +if (BUILD_SHARED_LIBS) install(TARGETS xrPhysics LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ) diff --git a/src/xrPhysics/ExtendedGeom.h b/src/xrPhysics/ExtendedGeom.h index b86e95a292c..caffb2773d6 100644 --- a/src/xrPhysics/ExtendedGeom.h +++ b/src/xrPhysics/ExtendedGeom.h @@ -1,8 +1,5 @@ #pragma once -#ifndef dSINGLE -#define dSINGLE -#endif #include "PHObject.h" #include diff --git a/src/xrPhysics/IPHWorld.h b/src/xrPhysics/IPHWorld.h index 7f919f617a6..7c233c889fd 100644 --- a/src/xrPhysics/IPHWorld.h +++ b/src/xrPhysics/IPHWorld.h @@ -1,22 +1,17 @@ #pragma once -#include "PhysicsExternalCommon.h" -#include "iphysics_scripted.h" + #include "xrCore/FTimer.h" #include "xrCDB/xrCDB.h" // build_callback +#include "PhysicsExternalCommon.h" +class CObjectSpace; +class CObjectList; +class CGameMtlLibrary; class CPhysicsShell; +class CPHCondition; +class CPHAction; -class IPHWorldUpdateCallbck -{ -public: - virtual void update_step() = 0; - virtual void phys_shell_relcase(CPhysicsShell* sh) = 0; - -protected: - virtual ~IPHWorldUpdateCallbck() {} -}; - -class IPHWorld : public iphysics_scripted_class +class IPHWorld { public: struct PHWorldStatistics @@ -57,7 +52,7 @@ class IPHWorld : public iphysics_scripted_class virtual void set_default_contact_shotmark(ContactCallbackFun* f) = 0; virtual void set_default_character_contact_shotmark(ContactCallbackFun* f) = 0; virtual void set_step_time_callback(PhysicsStepTimeCallback* cb) = 0; - virtual void set_update_callback(IPHWorldUpdateCallbck* cb) = 0; + virtual void AddCall(CPHCondition* c, CPHAction* a) = 0; virtual const PHWorldStatistics& GetStats() = 0; virtual void DumpStatistics(class IGameFont& font, class IPerformanceAlert* alert) = 0; #ifdef DEBUG @@ -67,11 +62,7 @@ class IPHWorld : public iphysics_scripted_class #endif }; -extern "C" XRPHYSICS_API IPHWorld* physics_world(); -class CObjectSpace; -class CObjectList; -extern "C" XRPHYSICS_API void create_physics_world( - bool mt, CObjectSpace* os, CObjectList* lo); -extern "C" XRPHYSICS_API void destroy_physics_world(); -class CGameMtlLibrary; -extern "C" XRPHYSICS_API void destroy_object_space(CObjectSpace*& os); +XRPHYSICS_API IPHWorld* physics_world(); +XRPHYSICS_API void create_physics_world(bool mt, CObjectSpace* os, CObjectList* lo); +XRPHYSICS_API void destroy_physics_world(); +XRPHYSICS_API void destroy_object_space(CObjectSpace*& os); diff --git a/src/xrPhysics/PHCharacter.h b/src/xrPhysics/PHCharacter.h index b9fa5bb1da9..651bb83cd11 100644 --- a/src/xrPhysics/PHCharacter.h +++ b/src/xrPhysics/PHCharacter.h @@ -1,7 +1,5 @@ #pragma once -#ifndef dSINGLE -#define dSINGLE -#endif + #include "PHObject.h" #include "PHInterpolation.h" #include "xrServerEntities/PHSynchronize.h" diff --git a/src/xrGame/PHCommander.cpp b/src/xrPhysics/PHCommander.cpp similarity index 94% rename from src/xrGame/PHCommander.cpp rename to src/xrPhysics/PHCommander.cpp index d8f44201b8f..edcdaea81f0 100644 --- a/src/xrGame/PHCommander.cpp +++ b/src/xrPhysics/PHCommander.cpp @@ -1,9 +1,10 @@ #include "StdAfx.h" + #include "PHCommander.h" #include "PHSimpleCalls.h" #ifdef DEBUG -#include "xrPhysics/IPHWorld.h" +//#include "PHWorld.h" #endif CPHCall::CPHCall(CPHCondition* condition, CPHAction* action) @@ -160,8 +161,8 @@ void CPHCommander::remove_call(PHCALL_I i) float m = f.magnitude(); if (m > EPS_S) f.mul(1.f / m); - // Msg(" const force removed: force: %f, remove step: %d world step: %d ,dir(%f,%f,%f) ", m, esc->step(), - // (u32)physics_world()->StepsNum(), f.x, f.y , f.z ); + //Msg(" const force removed: force: %f, remove step: %u world step: %u, dir(%f, %f, %f) ", + // m, esc->step(), (u32)ph_world->StepsNum(), VPUSH(f)); } #endif delete_call(*i); @@ -262,9 +263,3 @@ void CPHCommander::RemoveCallsDeferred(CPHReqComparerV* comparer) } } } - -void CPHCommander::phys_shell_relcase(CPhysicsShell* sh) -{ - CPHReqComparerHasShell c(sh); - remove_calls_threadsafety(&c); -} diff --git a/src/xrGame/PHCommander.h b/src/xrPhysics/PHCommander.h similarity index 89% rename from src/xrGame/PHCommander.h rename to src/xrPhysics/PHCommander.h index fadf3e6f676..39c68c26c52 100644 --- a/src/xrGame/PHCommander.h +++ b/src/xrPhysics/PHCommander.h @@ -1,7 +1,6 @@ #pragma once -#ifndef PH_COMMANDER_H -#define PH_COMMANDER_H -#include "xrPhysics/IPHWorld.h" + +#include "xrCommon/xr_unordered_map.h" #include "xrCore/Threading/Lock.hpp" class CPHReqBase; @@ -49,7 +48,7 @@ class CPHDummiAction : public CPHAction virtual bool obsolete() const { return false; } }; -class CPHCall +class XRPHYSICS_API CPHCall { CPHAction* m_action; CPHCondition* m_condition; @@ -69,10 +68,11 @@ class CPHCall using PHCALL_STORAGE = xr_vector; using PHCALL_I = PHCALL_STORAGE::iterator; -class CPHCommander : public IPHWorldUpdateCallbck + +class XRPHYSICS_API CPHCommander { - Lock lock; - PHCALL_STORAGE m_calls; + Lock lock; + PHCALL_STORAGE m_calls; xr_unordered_map m_callsUpdateDeferred; public: @@ -100,7 +100,4 @@ class CPHCommander : public IPHWorldUpdateCallbck private: void UpdateDeferred(); - virtual void update_step() { update_threadsafety(); } - virtual void phys_shell_relcase(CPhysicsShell* sh); }; -#endif diff --git a/src/xrPhysics/PHElement.h b/src/xrPhysics/PHElement.h index 112540bbc73..92d1b6e7bba 100644 --- a/src/xrPhysics/PHElement.h +++ b/src/xrPhysics/PHElement.h @@ -7,23 +7,21 @@ #include "Geometry.h" #include "PHDefs.h" #include "PhysicsCommon.h" -#include "xrServerEntities/PHSynchronize.h" #include "PHDisabling.h" #include "PHGeometryOwner.h" #include "PHInterpolation.h" #include "PHFracture.h" -#include "physics_scripted.h" -class CPHElement; -class CPHShell; + +#include "xrServerEntities/PHSynchronize.h" struct SPHImpact; +class CPHShell; class CPHFracturesHolder; class CPHElement : public CPhysicsElement, public CPHSynchronize, public CPHDisablingFull, - public CPHGeometryOwner, - public cphysics_scripted + public CPHGeometryOwner { friend class CPHFracturesHolder; @@ -284,9 +282,6 @@ class CPHElement : public CPhysicsElement, // bool CheckBreakConsistent () CPHElement(); // aux virtual ~CPHElement(); // aux -private: - virtual iphysics_scripted& get_scripted() { return *this; } -public: }; IC CPHElement* cast_PHElement(CPhysicsElement* e) { return static_cast(static_cast(e)); } diff --git a/src/xrPhysics/PHJoint.cpp b/src/xrPhysics/PHJoint.cpp index e1979013771..dbbe8a9a1d2 100644 --- a/src/xrPhysics/PHJoint.cpp +++ b/src/xrPhysics/PHJoint.cpp @@ -1,4 +1,5 @@ #include "StdAfx.h" + #include "PHDynamicData.h" #include "Physics.h" #include "tri-colliderknoopc/dTriList.h" diff --git a/src/xrPhysics/PHJoint.h b/src/xrPhysics/PHJoint.h index 29b7d417d5d..28baad6f86b 100644 --- a/src/xrPhysics/PHJoint.h +++ b/src/xrPhysics/PHJoint.h @@ -1,10 +1,13 @@ #pragma once #include "PhysicsShell.h" + #include -#include "physics_scripted.h" + +class CPHShell; class CPHJointDestroyInfo; -class CPHJoint : public CPhysicsJoint, public cphysics_scripted + +class CPHJoint : public CPhysicsJoint { /////////////////////////////////////////////////////// u16 m_bone_id; @@ -149,10 +152,6 @@ class CPHJoint : public CPhysicsJoint, public cphysics_scripted void SetShell(CPHShell* p); void ClearDestroyInfo(); - -private: - virtual iphysics_scripted& get_scripted() { return *this; } -public: }; /////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/xrGame/PHReqComparer.h b/src/xrPhysics/PHReqComparer.h similarity index 100% rename from src/xrGame/PHReqComparer.h rename to src/xrPhysics/PHReqComparer.h diff --git a/src/xrGame/PHScriptCall.cpp b/src/xrPhysics/PHScriptCall.cpp similarity index 99% rename from src/xrGame/PHScriptCall.cpp rename to src/xrPhysics/PHScriptCall.cpp index b1969ad57c2..9f97add8ccb 100644 --- a/src/xrGame/PHScriptCall.cpp +++ b/src/xrPhysics/PHScriptCall.cpp @@ -1,4 +1,4 @@ -#include "pch_script.h" +#include "StdAfx.h" #include "PHScriptCall.h" #include "PHCommander.h" diff --git a/src/xrGame/PHScriptCall.h b/src/xrPhysics/PHScriptCall.h similarity index 92% rename from src/xrGame/PHScriptCall.h rename to src/xrPhysics/PHScriptCall.h index 0a413230069..c6f51ed5e46 100644 --- a/src/xrGame/PHScriptCall.h +++ b/src/xrPhysics/PHScriptCall.h @@ -1,12 +1,14 @@ #pragma once + #include "PHReqComparer.h" #include "PHCommander.h" + +#include "xrEngine/xr_object.h" + #include "xrScriptEngine/script_engine.hpp" -#include "xrScriptEngine/script_space_forward.hpp" #include "xrScriptEngine/script_callback_ex.h" -#include "xrEngine/xr_object.h" -class CPHScriptCondition : public CPHCondition, public CPHReqComparerV +class XRPHYSICS_API CPHScriptCondition : public CPHCondition, public CPHReqComparerV { luabind::functor* m_lua_function; @@ -26,7 +28,7 @@ class CPHScriptCondition : public CPHCondition, public CPHReqComparerV } }; -class CPHScriptAction : public CPHAction, public CPHReqComparerV +class XRPHYSICS_API CPHScriptAction : public CPHAction, public CPHReqComparerV { bool b_obsolete; luabind::functor* m_lua_function; @@ -46,7 +48,7 @@ class CPHScriptAction : public CPHAction, public CPHReqComparerV } }; -class CPHScriptObjectCondition : public CPHCondition, public CPHReqComparerV +class XRPHYSICS_API CPHScriptObjectCondition : public CPHCondition, public CPHReqComparerV { luabind::object* m_lua_object; shared_str m_method_name; @@ -62,7 +64,7 @@ class CPHScriptObjectCondition : public CPHCondition, public CPHReqComparerV virtual bool compare(const CPHScriptObjectCondition* v) const; }; -class CPHScriptObjectAction : public CPHAction, public CPHReqComparerV +class XRPHYSICS_API CPHScriptObjectAction : public CPHAction, public CPHReqComparerV { bool b_obsolete; luabind::object* m_lua_object; @@ -80,7 +82,7 @@ class CPHScriptObjectAction : public CPHAction, public CPHReqComparerV }; ////////////////////////////////////////////////////////////////////////////////////////// -class CPHScriptObjectConditionN : public CPHCondition, public CPHReqComparerV +class XRPHYSICS_API CPHScriptObjectConditionN : public CPHCondition, public CPHReqComparerV { CScriptCallbackEx m_callback; @@ -94,7 +96,7 @@ class CPHScriptObjectConditionN : public CPHCondition, public CPHReqComparerV virtual bool compare(const CPHScriptObjectConditionN* v) const { return m_callback == v->m_callback; } }; -class CPHScriptObjectActionN : public CPHAction, public CPHReqComparerV +class XRPHYSICS_API CPHScriptObjectActionN : public CPHAction, public CPHReqComparerV { bool b_obsolete; CScriptCallbackEx m_callback; diff --git a/src/xrPhysics/PHShell.h b/src/xrPhysics/PHShell.h index 1ae7c0c77e9..35f9509fccc 100644 --- a/src/xrPhysics/PHShell.h +++ b/src/xrPhysics/PHShell.h @@ -1,17 +1,15 @@ #pragma once -class CPHShell; -class CPHShellSplitterHolder; #include "PHJoint.h" #include "PHElement.h" #include "PHDefs.h" #include "PHShellSplitter.h" #include "PHMoveStorage.h" -#include "physics_scripted.h" +class CPHShellSplitterHolder; class CPhysicsShellAnimator; -class CPHShell : public CPhysicsShell, public CPHObject, public cphysics_scripted +class CPHShell : public CPhysicsShell, public CPHObject { friend class CPHShellSplitterHolder; enum @@ -294,8 +292,6 @@ class CPHShell : public CPhysicsShell, public CPHObject, public cphysics_scripte return *(*elements.begin()); } -private: - virtual iphysics_scripted& get_scripted() { return *this; } public: #ifdef DEBUG virtual void dbg_draw_velocity(float scale, u32 color); diff --git a/src/xrGame/PHSimpleCalls.cpp b/src/xrPhysics/PHSimpleCalls.cpp similarity index 82% rename from src/xrGame/PHSimpleCalls.cpp rename to src/xrPhysics/PHSimpleCalls.cpp index f0ebe2b72a8..fc69f169c17 100644 --- a/src/xrGame/PHSimpleCalls.cpp +++ b/src/xrPhysics/PHSimpleCalls.cpp @@ -1,29 +1,30 @@ #include "StdAfx.h" -#include "xrPhysics/PhysicsShell.h" + +#include "PhysicsShell.h" #include "PHSimpleCalls.h" +#include "PHWorld.h" -// extern CPHWorld *ph_world; -#include "xrPhysics/IPHWorld.h" +#include "xrEngine/device.h" CPHCallOnStepCondition::CPHCallOnStepCondition() { - if (physics_world()) - set_step(physics_world()->StepsNum()); + if (ph_world) + set_step(ph_world->StepsNum()); else set_step(0); } -IC bool CPHCallOnStepCondition::time_out() const { return physics_world()->StepsNum() > m_step; } +IC bool CPHCallOnStepCondition::time_out() const { return ph_world->StepsNum() > m_step; } bool CPHCallOnStepCondition::is_true() { return time_out(); } bool CPHCallOnStepCondition::obsolete() const { return time_out(); } -void CPHCallOnStepCondition::set_steps_interval(u64 steps) { set_step(physics_world()->StepsNum() + steps); } +void CPHCallOnStepCondition::set_steps_interval(u64 steps) { set_step(ph_world->StepsNum() + steps); } void CPHCallOnStepCondition::set_time_interval(float time) { set_steps_interval(iCeil(time / fixed_step)); } void CPHCallOnStepCondition::set_time_interval(u32 time) { set_time_interval(float(time) / 1000.f); } void CPHCallOnStepCondition::set_global_time(float time) { float time_interval = Device.fTimeGlobal - time; if (time_interval < 0.f) - set_step(physics_world()->StepsNum()); + set_step(ph_world->StepsNum()); set_time_interval(time_interval); } void CPHCallOnStepCondition::set_global_time(u32 time) { set_global_time(float(time) / 1000.f); } diff --git a/src/xrGame/PHSimpleCalls.h b/src/xrPhysics/PHSimpleCalls.h similarity index 74% rename from src/xrGame/PHSimpleCalls.h rename to src/xrPhysics/PHSimpleCalls.h index 7077cf83fe0..2bac64c23c5 100644 --- a/src/xrGame/PHSimpleCalls.h +++ b/src/xrPhysics/PHSimpleCalls.h @@ -2,10 +2,12 @@ #include "PHCommander.h" #include "PHReqComparer.h" -#include "alife_space.h" + +#include "xrScriptEngine/ScriptExporter.hpp" class CPhysicsShell; -class CPHCallOnStepCondition : public CPHCondition + +class XRPHYSICS_API CPHCallOnStepCondition : public CPHCondition { u64 m_step; @@ -24,15 +26,21 @@ class CPHCallOnStepCondition : public CPHCondition #endif private: IC bool time_out() const; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; -class CPHExpireOnStepCondition : public CPHCallOnStepCondition +class XRPHYSICS_API CPHExpireOnStepCondition : public CPHCallOnStepCondition { public: virtual bool is_true() { return true; } + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CPHCallOnStepCondition); }; -class CPHShellBasedAction : public CPHAction +class XRPHYSICS_API CPHShellBasedAction : public CPHAction { protected: CPhysicsShell* m_shell; @@ -44,7 +52,7 @@ class CPHShellBasedAction : public CPHAction virtual bool obsolete() const; }; -class CPHConstForceAction : public CPHShellBasedAction +class XRPHYSICS_API CPHConstForceAction : public CPHShellBasedAction { Fvector m_force; @@ -57,6 +65,9 @@ class CPHConstForceAction : public CPHShellBasedAction #ifdef DEBUG const Fvector& force() const { return m_force; } #endif + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; class CPHReqComparerHasShell : public CPHReqComparerV diff --git a/src/xrGame/PHSimpleCallsScript.cpp b/src/xrPhysics/PHSimpleCallsScript.cpp similarity index 81% rename from src/xrGame/PHSimpleCallsScript.cpp rename to src/xrPhysics/PHSimpleCallsScript.cpp index 459ddb45d33..fe324412ba5 100644 --- a/src/xrGame/PHSimpleCallsScript.cpp +++ b/src/xrPhysics/PHSimpleCallsScript.cpp @@ -1,9 +1,11 @@ -#include "pch_script.h" +#include "StdAfx.h" + #include "PHSimpleCalls.h" -#include "xrPhysics/PhysicsShell.h" -#include "xrScriptEngine/ScriptExporter.hpp" +#include "PhysicsShell.h" + +#include "xrScriptEngine/script_space.hpp" -SCRIPT_EXPORT(CPHCallOnStepCondition, (), +void CPHCallOnStepCondition::script_register(lua_State* luaState) { using namespace luabind; @@ -22,9 +24,9 @@ SCRIPT_EXPORT(CPHCallOnStepCondition, (), (void (CPHCallOnStepCondition::*)(float))(&CPHCallOnStepCondition::set_time_interval)) .def(constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CPHExpireOnStepCondition, (CPHCallOnStepCondition), +void CPHExpireOnStepCondition::script_register(lua_State* luaState) { using namespace luabind; @@ -33,9 +35,9 @@ SCRIPT_EXPORT(CPHExpireOnStepCondition, (CPHCallOnStepCondition), class_("phcondition_expireonstep") .def(constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CPHConstForceAction, (), +void CPHConstForceAction::script_register(lua_State* luaState) { using namespace luabind; @@ -44,4 +46,4 @@ SCRIPT_EXPORT(CPHConstForceAction, (), class_("phaction_constforce") .def(constructor()) ]; -}); +} diff --git a/src/xrPhysics/PHWorld.cpp b/src/xrPhysics/PHWorld.cpp index f755d1aacd0..bb359d78cfe 100644 --- a/src/xrPhysics/PHWorld.cpp +++ b/src/xrPhysics/PHWorld.cpp @@ -7,9 +7,6 @@ #include "ExtendedGeom.h" #include "dRayMotions.h" #include "PHCollideValidator.h" -#include "xrEngine/device.h" -#include "xrEngine/GameFont.h" -#include "xrEngine/PerformanceAlert.hpp" #include "params.h" #ifdef DEBUG @@ -20,10 +17,17 @@ #include "xrServerEntities/PHNetState.h" #include "GeometryBits.h" #include "console_vars.h" -#include "xrEngine/device.h" -#include "xrEngine/defines.h" -#include "xrCDB/xr_area.h" +#include "PHCommander.h" +#include "PHSimpleCalls.h" + #include "xrCore/FS_internal.h" + +#include "xrCDB/xr_area.h" +#include "xrEngine/defines.h" +#include "xrEngine/device.h" +#include "xrEngine/GameFont.h" +#include "xrEngine/PerformanceAlert.hpp" + #ifdef DEBUG // void DBG_ObjAfterPhDataUpdate ( CPHObject *obj ); // void DBG_ObjBeforePhDataUpdate ( CPHObject *obj ); @@ -42,10 +46,10 @@ CPHWorld* ph_world = 0; IPHWorld* physics_world() { return ph_world; } void create_physics_world( - bool mt, CObjectSpace* os, CObjectList* lo) // IPHWorldUpdateCallbck &commander, + bool mt, CObjectSpace* os, CObjectList* lo) { ZoneScoped; - ph_world = xr_new(); //&commander + ph_world = xr_new(); VERIFY(os); // VERIFY( lo ); ph_world->Create(mt, os, lo); @@ -87,17 +91,9 @@ dGeomID plane; void CPHWorld::OnRender() { debug_output().PH_DBG_Render(); } #endif -static struct sempty_update_callback : public IPHWorldUpdateCallbck -{ - void update_step(){}; - void phys_shell_relcase(CPhysicsShell* sh){}; -} empty_update_callback; - CPHWorld::CPHWorld() - : // IPHWorldUpdateCallbck *_update_callback - m_update_callback(&empty_update_callback), - m_default_contact_shotmark(0), m_default_character_contact_shotmark(0), physics_step_time_callback(0), - m_object_space(0), m_level_objects(0) + : m_object_space(0), m_level_objects(0), m_default_contact_shotmark(0), + m_default_character_contact_shotmark(0), physics_step_time_callback(0) { disable_count = 0; m_frame_time = 0.f; @@ -140,8 +136,8 @@ void CPHWorld::Create(bool mt, CObjectSpace* os, CObjectList* lo) m_object_space = os; m_level_objects = lo; Device.AddSeqFrame(this, mt); + m_commander = xr_new(); -// m_commander =new CPHCommander(); // dVector3 extensions={2048,256,2048}; /* Fbox level_box = Level().ObjectSpace.GetBoundingVolume(); @@ -191,7 +187,7 @@ void CPHWorld::Destroy() ZoneScoped; r_spatial.clear(); - // xr_delete(m_commander); + xr_delete(m_commander); Mesh.Destroy(); #ifdef PH_PLAIN dGeomDestroy(plane); @@ -342,9 +338,7 @@ void CPHWorld::Step() debug_output().dbg_islands_num() = 0; #endif ////////////////////////////////////////////////////////////////////// - VERIFY(m_update_callback); - m_update_callback->update_step(); - // m_commander ->update(); + m_commander->update_threadsafety(); ////////////////////////////////////////////////////////////////////// for (i_object = m_objects.begin(); m_objects.end() != i_object;) { @@ -568,12 +562,9 @@ void CPHWorld::CutVelocity(float l_limit, float a_limit) } void CPHWorld::NetRelcase(CPhysicsShell* s) { - /* - CPHReqComparerHasShell c(s); - m_commander->remove_calls(&c); - */ - VERIFY(m_update_callback); - m_update_callback->phys_shell_relcase(s); + CPHReqComparerHasShell c(s); + m_commander->remove_calls_threadsafety(&c); + PH_UPDATE_OBJECT_I i_update_object; for (i_update_object = m_update_objects.begin(); m_update_objects.end() != i_update_object;) { @@ -583,12 +574,12 @@ void CPHWorld::NetRelcase(CPhysicsShell* s) // obj->PhTune(fixed_step); } } -/* -void CPHWorld::AddCall(CPHCondition*c,CPHAction*a) + +void CPHWorld::AddCall(CPHCondition* c,CPHAction* a) { - m_commander->add_call(c,a); + m_commander->add_call_threadsafety(c, a); } -*/ + u16 CPHWorld::ObjectsNumber() { return m_objects.count(); } u16 CPHWorld::UpdateObjectsNumber() { return m_update_objects.count(); } void CPHWorld::GetState(V_PH_WORLD_STATE& state) diff --git a/src/xrPhysics/PHWorld.h b/src/xrPhysics/PHWorld.h index 85c27ef6162..4e1ddf63619 100644 --- a/src/xrPhysics/PHWorld.h +++ b/src/xrPhysics/PHWorld.h @@ -1,19 +1,24 @@ #pragma once +#include "Common/Noncopyable.hpp" + +#include "xrEngine/pure.h" + #include "Physics.h" #include "PHUpdateObject.h" #include "IPHWorld.h" -#include "Common/Noncopyable.hpp" -#include "physics_scripted.h" -#include "xrEngine/pure.h" + +#include "xrScriptEngine/ScriptExporter.hpp" + // refs struct SGameMtlPair; -// class CPHCommander; -// class CPHCondition; -// class CPHAction; +class CPHCommander; +class CPHCondition; +class CPHAction; struct SPHNetState; class CPHSynchronize; typedef xr_vector> V_PH_WORLD_STATE; + class CPHMesh { dGeomID Geom; @@ -30,13 +35,12 @@ class CPHMesh ///////////////////////////////////////////////////////////////////////////// class CObjectSpace; class CObjectList; -class CPHWorld : public pureFrame, - public IPHWorld, - public cphysics_scripted, - private Noncopyable +class CPHWorld final : public IPHWorld, + public pureFrame, + private Noncopyable #ifdef DEBUG - , - public pureRender + , + public pureRender #endif { private: @@ -59,8 +63,7 @@ class CPHWorld : public pureFrame, PH_UPDATE_OBJECT_STORAGE m_update_objects; PH_UPDATE_OBJECT_STORAGE m_freezed_update_objects; dGeomID m_motion_ray; - // CPHCommander *m_commander; - IPHWorldUpdateCallbck* m_update_callback; + CPHCommander* m_commander; CObjectSpace* m_object_space; CObjectList* m_level_objects; @@ -89,7 +92,6 @@ class CPHWorld : public pureFrame, public: CPHWorld(); - virtual ~CPHWorld(){}; // IC dSpaceID GetSpace () {return Space;} ; IC bool Exist() { return b_exist; } @@ -140,7 +142,8 @@ class CPHWorld : public pureFrame, return *m_level_objects; } -// void AddCall (CPHCondition*c,CPHAction*a); + void AddCall(CPHCondition* c, CPHAction* a) override; + #ifdef DEBUG virtual void OnRender(); #endif @@ -150,13 +153,11 @@ class CPHWorld : public pureFrame, private: void StepNumIterations(int num_it); - iphysics_scripted& get_scripted() { return *this; } void set_step_time_callback(PhysicsStepTimeCallback* cb) { physics_step_time_callback = cb; } - void set_update_callback(IPHWorldUpdateCallbck* cb) - { - VERIFY(cb); - m_update_callback = cb; - } + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; + extern XRPHYSICS_API CPHWorld* ph_world; IC CPHWorld& inl_ph_world() { return *ph_world; } diff --git a/src/xrPhysics/PHWorldScript.cpp b/src/xrPhysics/PHWorldScript.cpp new file mode 100644 index 00000000000..d13f6b70e22 --- /dev/null +++ b/src/xrPhysics/PHWorldScript.cpp @@ -0,0 +1,28 @@ +#include "StdAfx.h" + +#include "Physics.h" +#include "PHWorld.h" +#include "PHCommander.h" + +#include "xrScriptEngine/script_space.hpp" + +void CPHWorld::script_register(lua_State* luaState) +{ + using namespace luabind; + + module(luaState) + [ + class_("physics_world") + .def("set_gravity", &CPHWorld::SetGravity) + .def("gravity", &CPHWorld::Gravity) + .def("add_call", &CPHWorld::AddCall) + ]; + + module(luaState, "level") + [ + def("physics_world", +[] + { + return ph_world; + }) + ]; +} diff --git a/src/xrPhysics/PhysicsShell.h b/src/xrPhysics/PhysicsShell.h index 6a700082da1..8c8b853f648 100644 --- a/src/xrPhysics/PhysicsShell.h +++ b/src/xrPhysics/PhysicsShell.h @@ -1,13 +1,14 @@ #pragma once +#include "xrCore/_flags.h" +#include "xrEngine/IPhysicsShell.h" + #include "PHDefs.h" #include "PhysicsCommon.h" #include "ICollideValidator.h" #include "xrServerEntities/alife_space.h" -#include "xrCore/_flags.h" -#include "xrEngine/IPhysicsShell.h" -#include "iphysics_scripted.h" +#include "xrScriptEngine/ScriptExporter.hpp" // fwd. decl. class CPhysicsJoint; @@ -57,7 +58,7 @@ using BONE_P_PAIR_CIT = const BONE_P_MAP::iterator; class CPhysicsBase; extern XRPHYSICS_API void get_box(const CPhysicsBase* shell, const Fmatrix& form, Fvector& sz, Fvector& c); -class XRPHYSICS_API CPhysicsBase : public iphysics_scripted_class +class XRPHYSICS_API CPhysicsBase { public: Fmatrix mXFORM; // In parent space @@ -201,6 +202,9 @@ class XRPHYSICS_API CPhysicsElement : public CPhysicsBase, public IPhysicsElemen virtual void get_Box(Fvector& sz, Fvector& c) const { return CPhysicsBase::get_Box(sz, c); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// virtual ~CPhysicsElement(){}; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; XRPHYSICS_API float NonElasticCollisionEnergy( @@ -209,7 +213,7 @@ XRPHYSICS_API float NonElasticCollisionEnergy( // ABSTRACT: // Joint between two elements -class XRPHYSICS_API CPhysicsJoint : public iphysics_scripted_class +class XRPHYSICS_API CPhysicsJoint { public: bool bActive; @@ -287,6 +291,9 @@ class XRPHYSICS_API CPhysicsJoint : public iphysics_scripted_class virtual bool IsHingeJoint() = 0; virtual void SetForce(const float force, const int axis_num = -1) = 0; virtual void SetVelocity(const float velocity = 0.f, const int axis_num = -1) = 0; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; // ABSTRACT: @@ -417,6 +424,9 @@ class XRPHYSICS_API CPhysicsShell : public CPhysicsBase, public IPhysicsShell virtual void SetPrefereExactIntegration() = 0; virtual ~CPhysicsShell(); // build_FromKinematics in returns elements & joint pointers according bone IDs; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; struct dContact; diff --git a/src/xrPhysics/PhysicsShellScript.cpp b/src/xrPhysics/PhysicsShellScript.cpp new file mode 100644 index 00000000000..bd40ef674b5 --- /dev/null +++ b/src/xrPhysics/PhysicsShellScript.cpp @@ -0,0 +1,95 @@ +#include "StdAfx.h" + +#include "PhysicsShell.h" + +#include "xrScriptEngine/script_space.hpp" + +void CPhysicsShell::script_register(lua_State* L) +{ + using namespace luabind; + + module(L) + [ + class_("physics_shell") + .def("apply_force", (void (CPhysicsShell::*)(float, float, float))(&CPhysicsShell::applyForce)) + .def("get_element_by_bone_name", (CPhysicsElement * (CPhysicsShell::*)(LPCSTR))(&CPhysicsShell::get_Element)) + .def("get_element_by_bone_id", (CPhysicsElement * (CPhysicsShell::*)(u16))(&CPhysicsShell::get_Element)) + .def("get_element_by_order", (CPhysicsElement * (CPhysicsShell::*)(u16))(&CPhysicsShell::get_ElementByStoreOrder)) + .def("get_elements_number", &CPhysicsShell::get_ElementsNumber) + .def("get_joint_by_bone_name", (CPhysicsJoint * (CPhysicsShell::*)(LPCSTR))(&CPhysicsShell::get_Joint)) + .def("get_joint_by_bone_id", (CPhysicsJoint * (CPhysicsShell::*)(u16))(&CPhysicsShell::get_Joint)) + .def("get_joint_by_order", &CPhysicsShell::get_JointByStoreOrder) + .def("get_joints_number", &CPhysicsShell::get_JointsNumber) + .def("block_breaking", &CPhysicsShell::BlockBreaking) + .def("unblock_breaking", &CPhysicsShell::UnblockBreaking) + .def("is_breaking_blocked", &CPhysicsShell::IsBreakingBlocked) + .def("is_breakable", &CPhysicsShell::isBreakable) + .def("get_linear_vel", &CPhysicsShell::get_LinearVel) + .def("get_angular_vel", &CPhysicsShell::get_AngularVel) + ]; +} + +void CPhysicsElement::script_register(lua_State* L) +{ + using namespace luabind; + + module(L) + [ + class_("physics_element") + .def("apply_force", (void (CPhysicsElement::*)(float, float, float))(&CPhysicsElement::applyForce)) + .def("is_breakable", &CPhysicsElement::isBreakable) + .def("get_linear_vel", &CPhysicsElement::get_LinearVel) + .def("get_angular_vel", &CPhysicsElement::get_AngularVel) + .def("get_mass", &CPhysicsElement::getMass) + .def("get_density", &CPhysicsElement::getDensity) + .def("get_volume", &CPhysicsElement::getVolume) + .def("fix", &CPhysicsElement::Fix) + .def("release_fixed", &CPhysicsElement::ReleaseFixed) + .def("is_fixed", &CPhysicsElement::isFixed) + .def("global_transform", +[](const CPhysicsElement* E) + { + Fmatrix m; + E->GetGlobalTransformDynamic(&m); + return m; + }) + ]; +} + +void CPhysicsJoint::script_register(lua_State* L) +{ + using namespace luabind; + using namespace luabind::policy; + + constexpr auto out_value_23 = policy_list, out_value<3>>(); + + module(L) + [ + class_("physics_joint") + .def("get_bone_id", &CPhysicsJoint::BoneID) + .def("get_first_element", &CPhysicsJoint::PFirst_element) + .def("get_stcond_element", &CPhysicsJoint::PSecond_element) + .def("set_anchor_global", (void (CPhysicsJoint::*)(const float, const float, const float))( + &CPhysicsJoint::SetAnchor)) + .def("set_anchor_vs_first_element", (void (CPhysicsJoint::*)(const float, const float, const float))( + &CPhysicsJoint::SetAnchorVsFirstElement)) + .def("set_anchor_vs_second_element", (void (CPhysicsJoint::*)(const float, const float, const float))( + &CPhysicsJoint::SetAnchorVsSecondElement)) + .def("get_axes_number", &CPhysicsJoint::GetAxesNumber) + .def("set_axis_spring_dumping_factors", &CPhysicsJoint::SetAxisSDfactors) + .def("set_joint_spring_dumping_factors", &CPhysicsJoint::SetJointSDfactors) + .def("set_axis_dir_global", (void (CPhysicsJoint::*)(const float, const float, const float, + const int))(&CPhysicsJoint::SetAxisDir)) + .def("set_axis_dir_vs_first_element", (void (CPhysicsJoint::*)(const float, const float, const float, + const int))(&CPhysicsJoint::SetAxisDirVsFirstElement)) + .def("set_axis_dir_vs_second_element", (void (CPhysicsJoint::*)(const float, const float, const float, + const int))(&CPhysicsJoint::SetAxisDirVsSecondElement)) + .def("set_limits", &CPhysicsJoint::SetLimits) + .def("set_max_force_and_velocity", &CPhysicsJoint::SetForceAndVelocity) + .def("get_max_force_and_velocity", &CPhysicsJoint::GetMaxForceAndVelocity, out_value_23) + .def("get_axis_angle", &CPhysicsJoint::GetAxisAngle) + .def("get_limits", &CPhysicsJoint::GetLimits, out_value_23) + .def("get_axis_dir", &CPhysicsJoint::GetAxisDirDynamic) + .def("get_anchor", &CPhysicsJoint::GetAnchorDynamic) + .def("is_breakable", &CPhysicsJoint::isBreakable) + ]; +} diff --git a/src/xrPhysics/dRayMotions.cpp b/src/xrPhysics/dRayMotions.cpp index e2336bd4328..5958390e201 100644 --- a/src/xrPhysics/dRayMotions.cpp +++ b/src/xrPhysics/dRayMotions.cpp @@ -1,10 +1,12 @@ #include "StdAfx.h" #include "dcylinder/dCylinder.h" -struct dContactGeom; -int dCollideCylRay(dxGeom* o1, dxGeom* o2, int flags, dContactGeom* contact, int skip); +#include "tri-colliderknoopc/dTriColliderCommon.h" #include "ode/ode/src/collision_std.h" +struct dContactGeom; +int dCollideCylRay(dxGeom* o1, dxGeom* o2, int flags, dContactGeom* contact, int skip); + struct dxRayMotions { dGeomID ray; @@ -18,8 +20,6 @@ struct dxRayMotions int dRayMotionsClassUser = -1; -#define CONTACT(p, skip) ((dContactGeom*)(((char*)p) + (skip))) - int dCollideRMB(dxGeom* o1, dxGeom* o2, int flags, dContactGeom* contact, int skip) { dxRayMotions* rm = (dxRayMotions*)dGeomGetClassData(o1); diff --git a/src/xrPhysics/iphysics_scripted.h b/src/xrPhysics/iphysics_scripted.h deleted file mode 100644 index cdab4e4ef15..00000000000 --- a/src/xrPhysics/iphysics_scripted.h +++ /dev/null @@ -1,65 +0,0 @@ -#pragma once - -#include "xrServerEntities/smart_cast.h" // get_script_wrapper() needs it - -class iphysics_scripted; - -class XR_NOVTABLE iphysics_game_scripted -{ -public: - virtual ~iphysics_game_scripted() = default; - virtual iphysics_scripted& iphysics_impl() = 0; - // protected: - // virtual ~iphysics_game_scripted () =0 {} -}; - -class XR_NOVTABLE iphysics_scripted -{ -public: - virtual void set(iphysics_game_scripted* g) = 0; - virtual iphysics_game_scripted* get() = 0; - virtual ~iphysics_scripted() = default; -}; - -class XR_NOVTABLE iphysics_scripted_class -{ -public: - // virtual ~iphysics_scripted_class () = 0; - virtual iphysics_scripted& get_scripted() = 0; - -protected: - virtual ~iphysics_scripted_class() = 0; -}; - -inline iphysics_scripted_class::~iphysics_scripted_class() = default; - -template -class cphysics_game_scripted : public iphysics_game_scripted, private Noncopyable -{ - T& impl; - -public: - cphysics_game_scripted(T* im) : impl(*im) {} - virtual ~cphysics_game_scripted(){}; - virtual iphysics_scripted& iphysics_impl() { return impl.get_scripted(); } -protected: - virtual T& physics_impl() { return impl; } - virtual const T& physics_impl() const { return impl; } -public: - typedef T type_impl; -}; - -template -wrap* get_script_wrapper(typename wrap::type_impl& E) -{ - wrap* e = smart_cast(E.get_scripted().get()); - if (e) - return e; - - e = xr_new(&E); - E.get_scripted().set(e); - - VERIFY(smart_cast(E.get_scripted().get()) == e); - - return e; -} diff --git a/src/xrPhysics/ode_include.h b/src/xrPhysics/ode_include.h index c1769ec3424..f98aa63400e 100644 --- a/src/xrPhysics/ode_include.h +++ b/src/xrPhysics/ode_include.h @@ -1,7 +1,3 @@ -#ifndef dSINGLE -#define dSINGLE -#endif - #pragma warning(push) #pragma warning(disable : 4995) #pragma warning(disable : 4267) diff --git a/src/xrPhysics/physics_scripted.cpp b/src/xrPhysics/physics_scripted.cpp deleted file mode 100644 index 1feaa7f7347..00000000000 --- a/src/xrPhysics/physics_scripted.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "StdAfx.h" - -#include "physics_scripted.h" - -cphysics_scripted::~cphysics_scripted() { xr_delete(m_game_scripted); } -void cphysics_scripted::set(iphysics_game_scripted* g) -{ - R_ASSERT(g); - R_ASSERT(!m_game_scripted); - R_ASSERT(&(g->iphysics_impl()) == this); - m_game_scripted = g; -} diff --git a/src/xrPhysics/physics_scripted.h b/src/xrPhysics/physics_scripted.h deleted file mode 100644 index e05034ffc22..00000000000 --- a/src/xrPhysics/physics_scripted.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "iphysics_scripted.h" - -class cphysics_scripted : public iphysics_scripted -{ - iphysics_game_scripted* m_game_scripted; - -public: - cphysics_scripted() : m_game_scripted(0) {} - virtual ~cphysics_scripted(); - virtual void set(iphysics_game_scripted* g); - virtual iphysics_game_scripted* get() { return m_game_scripted; }; -}; diff --git a/src/xrPhysics/tri-colliderknoopc/dcTriListCollider.cpp b/src/xrPhysics/tri-colliderknoopc/dcTriListCollider.cpp index cf658e14d5f..de1f21d2584 100644 --- a/src/xrPhysics/tri-colliderknoopc/dcTriListCollider.cpp +++ b/src/xrPhysics/tri-colliderknoopc/dcTriListCollider.cpp @@ -17,9 +17,6 @@ dcTriListCollider::dcTriListCollider(dxGeom* Geometry) dcTriListCollider::~dcTriListCollider() {} int dCollideBP(const dxGeom* o1, const dxGeom* o2, int flags, dContactGeom* contact, int skip); // ODE internal function -//#define CONTACT(Ptr, Stride) ((dContactGeom*) (((byte*)Ptr) + (Stride))) -//#define SURFACE(Ptr, Stride) ((dSurfaceParameters*) (((byte*)Ptr) + (Stride-sizeof(dSurfaceParameters)))) - int dcTriListCollider::CollideBox(dxGeom* Box, int Flags, dContactGeom* Contacts, int Stride) { Fvector AABB; diff --git a/src/xrPhysics/xrPhysics.h b/src/xrPhysics/xrPhysics.h index 0debc581faf..92a747c05d1 100644 --- a/src/xrPhysics/xrPhysics.h +++ b/src/xrPhysics/xrPhysics.h @@ -1,7 +1,6 @@ #pragma once -// XXX: temporary use MASTER_GOLD here, switch to XRAY_STATIC_BUILD later -#ifdef MASTER_GOLD // XRAY_STATIC_BUILD +#ifdef XRAY_STATIC_BUILD # define XRPHYSICS_API #else # ifdef XRPHYSICS_EXPORTS diff --git a/src/xrPhysics/xrPhysics.vcxproj b/src/xrPhysics/xrPhysics.vcxproj index 8d8deeee8b4..739e9a43057 100644 --- a/src/xrPhysics/xrPhysics.vcxproj +++ b/src/xrPhysics/xrPhysics.vcxproj @@ -11,9 +11,6 @@ - - StaticLibrary - @@ -56,6 +53,7 @@ + @@ -69,20 +67,24 @@ + + + + - + Create @@ -124,7 +126,6 @@ - @@ -140,6 +141,7 @@ + @@ -156,9 +158,12 @@ + + + @@ -173,7 +178,6 @@ - @@ -220,6 +224,12 @@ {2c419512-6eee-4707-bc51-2e834855552e} + + {ccd4afae-aa10-42c6-a452-fdee497ccdf1} + + + {632aeeb6-dc06-4e15-9551-b2b09a4b73c5} + diff --git a/src/xrPhysics/xrPhysics.vcxproj.filters b/src/xrPhysics/xrPhysics.vcxproj.filters index 9061ad1b4d5..ad95a649e64 100644 --- a/src/xrPhysics/xrPhysics.vcxproj.filters +++ b/src/xrPhysics/xrPhysics.vcxproj.filters @@ -121,9 +121,6 @@ {5711bf0c-b30d-47a5-aef3-9366c2330984} - - {3a301380-824e-4e8b-a766-0fc216e31552} - {fe321485-7dc2-4ac0-a2b8-96c420de4247} @@ -136,6 +133,9 @@ {633b90c0-0e90-4a1d-b5da-22e81159c94d} + + {fe49908d-5e25-4c90-b5f7-f59ad8993975} + @@ -306,9 +306,6 @@ physics\Base\Objects\StaticShell - - physics\Base\Objects\script - physics\Base\Debug @@ -318,6 +315,24 @@ physics\damage_receiver + + physics\Base\Objects\BaseShell + + + physics\Base\Objects\World + + + physics\Base\Objects\PHCommander + + + physics\Base\Objects\PHCommander + + + physics\Base\Objects\PHCommander + + + physics\Base\Objects\PHCommander + @@ -575,12 +590,6 @@ physics\Base\Objects\StaticShell - - physics\Base\Objects\script - - - physics\Base\Objects\script - physics\Base\Impact @@ -596,6 +605,18 @@ physics\Base\Objects\Utils\Math + + physics\Base\Objects\PHCommander + + + physics\Base\Objects\PHCommander + + + physics\Base\Objects\PHCommander + + + physics\Base\Objects\PHCommander + diff --git a/src/xrScriptEngine/BindingsDumper.hpp b/src/xrScriptEngine/BindingsDumper.hpp index bedb2dae16b..5b2f9ab4046 100644 --- a/src/xrScriptEngine/BindingsDumper.hpp +++ b/src/xrScriptEngine/BindingsDumper.hpp @@ -1,6 +1,6 @@ #pragma once -#include "xrScriptEngine/xrScriptEngine.hpp" -#include "xrCore/xrCore.h" + +#include "xrScriptEngine.hpp" class BindingsDumper { diff --git a/src/xrScriptEngine/CMakeLists.txt b/src/xrScriptEngine/CMakeLists.txt index a8e96e4d004..77d2555215c 100644 --- a/src/xrScriptEngine/CMakeLists.txt +++ b/src/xrScriptEngine/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(xrScriptEngine SHARED) +add_library(xrScriptEngine) target_sources_grouped( TARGET xrScriptEngine @@ -28,6 +28,7 @@ target_sources_grouped( Functor.hpp script_engine.cpp script_engine.hpp + script_space.hpp script_space_forward.hpp ScriptEngineScript.cpp ScriptEngineScript.hpp @@ -46,10 +47,8 @@ target_sources_grouped( TARGET xrScriptEngine NAME "Kernel" FILES - DebugMacros.hpp pch.cpp pch.hpp - ScriptEngineConfig.hpp xrScriptEngine.cpp xrScriptEngine.hpp ) @@ -105,9 +104,6 @@ target_link_libraries(xrScriptEngine target_compile_definitions(xrScriptEngine PRIVATE XRSCRIPTENGINE_EXPORTS - # Uncomment next string for debug script engine - #CONFIG_SCRIPT_ENGINE_LOG_EXPORTS - #CONFIG_SCRIPT_ENGINE_LOG_SKIPPED_EXPORTS ) set_target_properties(xrScriptEngine PROPERTIES @@ -119,6 +115,8 @@ target_precompile_headers(xrScriptEngine pch.hpp ) -install(TARGETS xrScriptEngine LIBRARY - DESTINATION "${CMAKE_INSTALL_LIBDIR}" -) +if (BUILD_SHARED_LIBS) + install(TARGETS xrScriptEngine LIBRARY + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) +endif() diff --git a/src/xrScriptEngine/DebugMacros.hpp b/src/xrScriptEngine/DebugMacros.hpp deleted file mode 100644 index 22c4da6aa79..00000000000 --- a/src/xrScriptEngine/DebugMacros.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#pragma once -//#include "xrCore/xrCore.h" -#include "xrCore/xr_types.h" -#include "xrCore/xrDebug.h" - -#if XRAY_EXCEPTIONS -#define THROW(expr) \ - \ -do \ - { \ - if (!(expr)) \ - { \ - string4096 assertionInfo; \ - xrDebug::GatherInfo(assertionInfo, sizeof(assertionInfo), DEBUG_INFO, #expr, nullptr, nullptr, nullptr); \ - throw assertionInfo; \ - } \ - \ -} \ - while (false) -#define THROW2(expr, msg0) \ - \ -do \ - { \ - if (!(expr)) \ - { \ - string4096 assertionInfo; \ - xrDebug::GatherInfo(assertionInfo, sizeof(assertionInfo), DEBUG_INFO, #expr, msg0, nullptr, nullptr); \ - throw assertionInfo; \ - } \ - \ -} \ - while (false) -#define THROW3(expr, msg0, msg1) \ - \ -do \ - { \ - if (!(expr)) \ - { \ - string4096 assertionInfo; \ - xrDebug::GatherInfo(assertionInfo, sizeof(assertionInfo), DEBUG_INFO, #expr, msg0, msg1, nullptr); \ - throw assertionInfo; \ - } \ - \ -} \ - while (false) -#else -#define THROW VERIFY -#define THROW2 VERIFY2 -#define THROW3 VERIFY3 -#endif diff --git a/src/xrScriptEngine/Functor.hpp b/src/xrScriptEngine/Functor.hpp index d6adbd2fe61..4e830e0ef5c 100644 --- a/src/xrScriptEngine/Functor.hpp +++ b/src/xrScriptEngine/Functor.hpp @@ -1,7 +1,9 @@ #pragma once -#include "xrScriptEngine/xrScriptEngine.hpp" #include + +#include "script_space.hpp" + #include namespace luabind diff --git a/src/xrScriptEngine/ScriptEngineConfig.hpp b/src/xrScriptEngine/ScriptEngineConfig.hpp deleted file mode 100644 index 52373098df8..00000000000 --- a/src/xrScriptEngine/ScriptEngineConfig.hpp +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once -// XXX: move to config -#if defined(DEBUG) && 0 -#define CONFIG_SCRIPT_ENGINE_LOG_EXPORTS -#endif diff --git a/src/xrScriptEngine/ScriptEngineScript.cpp b/src/xrScriptEngine/ScriptEngineScript.cpp index 90d14591e8c..033aed09345 100644 --- a/src/xrScriptEngine/ScriptEngineScript.cpp +++ b/src/xrScriptEngine/ScriptEngineScript.cpp @@ -7,12 +7,11 @@ //////////////////////////////////////////////////////////////////////////// #include "pch.hpp" + #include "ScriptEngineScript.hpp" #include "script_engine.hpp" #include "script_profiler.hpp" #include "script_debugger.hpp" -#include "DebugMacros.hpp" -#include "ScriptExporter.hpp" void LuaLog(pcstr caMessage) { @@ -36,13 +35,6 @@ void ErrorLog(pcstr caMessage) R_ASSERT2(0, caMessage); } -//AVO: -void PrintStack() -{ - GEnv.ScriptEngine->print_stack(); -} -//-AVO - void FlushLogs() { #ifdef DEBUG @@ -51,24 +43,54 @@ void FlushLogs() #endif } -void verify_if_thread_is_running() +void CScriptEngine::script_register(lua_State* luaState) { - THROW2(GEnv.ScriptEngine->current_thread(), "coroutine.yield() is called outside the LUA thread!"); -} + using namespace luabind; -bool is_editor() -{ - return GEnv.ScriptEngine->is_editor(); + module(luaState) + [ + def("log", &LuaLog), + def("error_log", &ErrorLog), + def("flush", &FlushLogs), + def("print_stack", +[]() + { + GEnv.ScriptEngine->print_stack(); + }), + def("prefetch", +[](pcstr file_name) + { + GEnv.ScriptEngine->process_file(file_name); + }), + def("verify_if_thread_is_running", +[]() + { + THROW2(GEnv.ScriptEngine->current_thread(), "coroutine.yield() is called outside the LUA thread!"); + }), + def("bit_and", +[](const int i, const int j) + { + return i & j; + }), + def("bit_or", +[](const int i, const int j) + { + return i | j; + }), + def("bit_xor", +[](const int i, const int j) + { + return i ^ j; + }), + def("bit_not", +[](const int i) + { + return ~i; + }), + def("editor", +[]() + { + return GEnv.ScriptEngine->is_editor(); + }), + def("user_name", +[]() + { + return Core.UserName; + }) + ]; } -inline int bit_and(const int i, const int j) { return i & j; } -inline int bit_or(const int i, const int j) { return i | j; } -inline int bit_xor(const int i, const int j) { return i ^ j; } -inline int bit_not(const int i) { return ~i; } -inline const char* user_name() { return Core.UserName; } - -void prefetch_module(pcstr file_name) { GEnv.ScriptEngine->process_file(file_name); } - struct profile_timer_script { using Clock = std::chrono::high_resolution_clock; @@ -130,8 +152,12 @@ inline profile_timer_script operator+(const profile_timer_script& portion0, cons return result; } -std::ostream& operator<<(std::ostream& os, const profile_timer_script& pt) { return os << pt.time(); } -SCRIPT_EXPORT(CScriptEngine, (), +std::ostream& operator<<(std::ostream& os, const profile_timer_script& pt) +{ + return os << pt.time(); +} + +void CScriptProfiler::script_register(lua_State* luaState) { using namespace luabind; @@ -149,20 +175,7 @@ SCRIPT_EXPORT(CScriptEngine, (), .def(tostring(self)) .def("start", &profile_timer_script::start) .def("stop", &profile_timer_script::stop) - .def("time", &profile_timer_script::time), - - def("log", &LuaLog), - def("error_log", &ErrorLog), - def("flush", &FlushLogs), - def("print_stack", &PrintStack), - def("prefetch", &prefetch_module), - def("verify_if_thread_is_running", &verify_if_thread_is_running), - def("bit_and", &bit_and), - def("bit_or", &bit_or), - def("bit_xor", &bit_xor), - def("bit_not", &bit_not), - def("editor", &is_editor), - def("user_name", &user_name) + .def("time", &profile_timer_script::time) ]; module(luaState, "profiler") @@ -216,4 +229,4 @@ SCRIPT_EXPORT(CScriptEngine, (), GEnv.ScriptEngine->m_profiler->SaveReport(); }) ]; -}); +} diff --git a/src/xrScriptEngine/ScriptEngineScript.hpp b/src/xrScriptEngine/ScriptEngineScript.hpp index f18e489c1d2..a063180fe28 100644 --- a/src/xrScriptEngine/ScriptEngineScript.hpp +++ b/src/xrScriptEngine/ScriptEngineScript.hpp @@ -1,6 +1,6 @@ #pragma once -#include "xrCore/xrCore.h" -#include "xrScriptEngine/xrScriptEngine.hpp" + +#include "xrScriptEngine.hpp" using ScriptTimeGlobalFunc = u32(__cdecl*)(); diff --git a/src/xrScriptEngine/ScriptExporter.cpp b/src/xrScriptEngine/ScriptExporter.cpp index 17d3a29fdbf..2b70ce69bbc 100644 --- a/src/xrScriptEngine/ScriptExporter.cpp +++ b/src/xrScriptEngine/ScriptExporter.cpp @@ -1,147 +1,101 @@ #include "pch.hpp" -#include "ScriptEngineConfig.hpp" + #include "ScriptExporter.hpp" -#include "xrCore/xrCore.h" -using namespace XRay; +#include "xrCommon/xr_unordered_map.h" + +namespace xray::script_export +{ +static size_t nodes_count = 0; -ScriptExporter::Node* ScriptExporter::Node::firstNode = nullptr; -ScriptExporter::Node* ScriptExporter::Node::lastNode = nullptr; -size_t ScriptExporter::Node::nodeCount = 0; +node* node::first_node = nullptr; -ScriptExporter::Node::Node(const char* id, size_t depCount, const char* const* deps, ExporterFunc exporterFunc) +node::node(export_func export_func, dependencies_getter deps_getter) + : m_next_node(first_node), m_export_func(export_func), m_deps_getter(deps_getter) { - this->id = id; - this->depCount = depCount; - this->deps = deps; - this->exporterFunc = exporterFunc; - done = false; - InsertAfter(nullptr, this); + first_node = this; + ++nodes_count; } -ScriptExporter::Node::~Node() +node::~node() { - // Remap locals - // ... <-> N <-> this <-> N <-> ... - { - if (prevNode) - prevNode->nextNode = this->nextNode; - - if (nextNode) - nextNode->prevNode = this->prevNode; - } - - // Remap globals + if (first_node == this) + first_node = m_next_node; + else { - // this <-> N <-> ... - if (firstNode == this) - firstNode = this->nextNode; - - // ... <-> N <-> this - if (lastNode == this) - lastNode = this->prevNode; + node* prev = first_node; + while (prev && prev->m_next_node != this) + prev = prev->m_next_node; + if (prev) + prev->m_next_node = m_next_node; } } -void ScriptExporter::Node::Export(lua_State* luaState) +void node::sort() { - if (done) + enum class state { -#ifdef CONFIG_SCRIPT_ENGINE_LOG_SKIPPED_EXPORTS - Msg("* ScriptExporter: skipping exported node %s", id); -#endif - return; - } + not_visited, visiting, done + }; + xr_unordered_map map; + map.reserve(nodes_count); - ZoneScoped; + for (auto n = first_node; n; n = n->m_next_node) + map[n] = state::not_visited; - // export dependencies recursively - for (size_t i = 0; i < depCount; i++) - { - // check if 'deps[i]' depends on 'node' - for (Node* n = GetFirst(); n; n = n->GetNext()) - { - if (!n->done && !strcmp(deps[i], n->id)) - { - n->Export(luaState); - break; - } - } - } -#ifdef CONFIG_SCRIPT_ENGINE_LOG_EXPORTS - Msg("* ScriptExporter: exporting node %s", id); -#endif - exporterFunc(luaState); - done = true; -} + xr_vector sorted; + sorted.reserve(map.size()); -bool ScriptExporter::Node::HasDependency(const Node* node) const -{ - for (size_t i = 0; i < depCount; i++) + std::function depth_first_search = [&](const node* n) { - if (!strcmp(deps[i], node->id)) - return true; - } - for (size_t i = 0; i < depCount; i++) - { - // check if 'deps[i]' depends on 'node' - for (Node* n = GetFirst(); n; n = n->GetNext()) + const auto it = map.find(n); + if (it != map.end()) { - if (!strcmp(deps[i], n->id)) - { - if (n->HasDependency(node)) - return true; - break; - } + R_ASSERT2(it->second != state::visiting, "Cyclic dependency in script export!"); + if (it->second == state::done) + return; } - } - return false; -} -void ScriptExporter::Node::InsertAfter(Node* target, Node* node) -{ - if (!target) - { - node->prevNode = nullptr; - node->nextNode = firstNode; - if (firstNode) - firstNode->prevNode = node; - else - lastNode = node; - firstNode = node; - } - else + map[n] = state::visiting; + + const auto& [deps, deps_count] = n->m_deps_getter(); + for (size_t i = 0; i < deps_count; i++) + depth_first_search(deps[i]); + + map[n] = state::done; + sorted.push_back(const_cast(n)); + }; + + for (auto& [n, _] : map) + depth_first_search(n); + + node* prev = nullptr; + for (auto it = sorted.rbegin(); it != sorted.rend(); ++it) { - node->prevNode = target; - node->nextNode = target->nextNode; - if (target == lastNode) - lastNode = node; - target->nextNode = node; + (*it)->m_next_node = prev; + prev = *it; } - nodeCount++; + first_node = prev; + + // This is always logged to help find out if some nodes are missing + Msg("* Script exporter has %zu nodes registered.", nodes_count); } -void ScriptExporter::Export(lua_State* luaState) +void node::export_all(lua_State* luaState) { + if (!first_node) + return; + ZoneScoped; -#ifdef CONFIG_SCRIPT_ENGINE_LOG_EXPORTS - Msg("* ScriptExporter: total nodes: %zu", Node::GetCount()); - for (auto node = Node::GetFirst(); node; node = node->GetNext()) + + static bool sorted = false; + if (!sorted) { - Msg("* %s", node->GetId()); - size_t depCount = node->GetDependencyCount(); - const char* const* depIds = node->GetDependencyIds(); - for (int i = 0; i < depCount; i++) - Msg("* <- %s", depIds[i]); + sort(); + sorted = true; } -#endif - for (auto node = Node::GetFirst(); node; node = node->GetNext()) - node->Export(luaState); -} -void ScriptExporter::Reset() -{ - ZoneScoped; - for (auto node = Node::GetFirst(); node; node = node->GetNext()) - node->Reset(); + for (auto node = first_node; node; node = node->m_next_node) + node->m_export_func(luaState); } +} // namespace xray::script_export diff --git a/src/xrScriptEngine/ScriptExporter.hpp b/src/xrScriptEngine/ScriptExporter.hpp index e36b62cd160..179afb08b15 100644 --- a/src/xrScriptEngine/ScriptExporter.hpp +++ b/src/xrScriptEngine/ScriptExporter.hpp @@ -1,113 +1,68 @@ #pragma once + #include "xrScriptEngine.hpp" -struct lua_State; +#include -namespace XRay -{ -class XRSCRIPTENGINE_API ScriptExporter +namespace xray::script_export { -public: - class XRSCRIPTENGINE_API Node - { - public: - using ExporterFunc = void(__cdecl*)(lua_State* luaState); +class XRSCRIPTENGINE_API node; - private: - const char* id; - size_t depCount; - const char* const* deps; - ExporterFunc exporterFunc; - bool done; - Node* prevNode; - Node* nextNode; - static Node* firstNode; - static Node* lastNode; - static size_t nodeCount; +using export_func = void(*)(lua_State* luaState); +using dependencies_getter = std::pair(*)(); - public: - Node(const char* id, size_t depCount, const char* const* deps, ExporterFunc exporterFunc); - ~Node(); +class XRSCRIPTENGINE_API node +{ + node(const node&) = delete; + node(node&&) = delete; - void Export(lua_State* luaState); - void Reset() { done = false; } - const char* GetId() const { return id; } - size_t GetDependencyCount() const { return depCount; } - const char* const* GetDependencyIds() const { return deps; } - Node* GetPrev() const { return prevNode; } - Node* GetNext() const { return nextNode; } - static Node* GetFirst() { return firstNode; } - static Node* GetLast() { return lastNode; } - static size_t GetCount() { return nodeCount; } - private: - bool HasDependency(const Node* node) const; - static void InsertAfter(Node* target, Node* node); - }; + node& operator=(const node&) = delete; + node& operator=(node&&) = delete; - ScriptExporter() = delete; - static void Export(lua_State* luaState); - static void Reset(); -}; -} +public: + node(export_func export_func, dependencies_getter deps_getter); + ~node(); -#define NOOP(...) __VA_ARGS__ -#define GLUE(x, y) x y -#define ARG_COUNT(_1, _2, _3, _4, count, ...) count -#define EXPAND_ARGS(args) ARG_COUNT args -#define ARG_COUNT_4(...) EXPAND_ARGS((__VA_ARGS__, 4, 3, 2, 1, 0)) -#define OVERLOAD_MACRO2(name, count) name##count -#define OVERLOAD_MACRO1(name, count) OVERLOAD_MACRO2(name, count) -#define OVERLOAD_MACRO(name, count) OVERLOAD_MACRO1(name, count) -#define CALL_OVERLOAD(name, ...) GLUE(OVERLOAD_MACRO(name, ARG_COUNT_4(__VA_ARGS__)), (__VA_ARGS__)) + static void export_all(lua_State* luaState); -#define SCRIPT_INHERIT1(_1) #_1 -#define SCRIPT_INHERIT2(_1, _2) #_1, #_2 -#define SCRIPT_INHERIT3(_1, _2, _3) #_1, #_2, #_3 -#define SCRIPT_INHERIT4(_1, _2, _3, _4) #_1, #_2, #_3, #_4 -#define SCRIPT_INHERIT(...) CALL_OVERLOAD(SCRIPT_INHERIT, __VA_ARGS__) +private: + static void sort(); -#define SCRIPT_EXPORT_WRAP(id, dependencies, ...) \ - \ -namespace XRay \ - \ -{ \ - \ -namespace ScriptExportDetails \ - \ -{ \ - __pragma(warning(push)) __pragma(warning(disable : 4003)) static const char* const id##_Deps[] = { \ - nullptr, SCRIPT_INHERIT(NOOP dependencies)}; \ - __pragma(warning(pop)) __pragma(optimize("s", on)) static void id##_ScriptExport(lua_State* luaState) \ - __VA_ARGS__ static const ScriptExporter::Node id##_ScriptExporterNode( \ - #id, sizeof(id##_Deps) / sizeof(*id##_Deps) - 1, id##_Deps + 1, id##_ScriptExport); \ - \ -} \ - \ -} + static node* first_node; + + node* m_next_node{}; + export_func m_export_func{}; + dependencies_getter m_deps_getter{}; +}; -#define SCRIPT_EXPORT_FUNC_WRAP(id, dependencies, func) \ - \ -namespace XRay \ - \ -{ \ - \ -namespace ScriptExportDetails \ - \ -{ \ - __pragma(warning(push)) __pragma(warning(disable : 4003)) static const char* const id##_Deps[] = { \ - nullptr, SCRIPT_INHERIT(NOOP dependencies)}; \ - __pragma(warning(pop)) __pragma(optimize("s", on)) static void id##_ScriptExport(lua_State* luaState) \ - { \ - func(luaState); \ - } \ - static const ScriptExporter::Node id##_ScriptExporterNode( \ - #id, sizeof(id##_Deps) / sizeof(*id##_Deps) - 1, id##_Deps + 1, id##_ScriptExport); \ - \ -} \ - \ +namespace detail +{ +template +auto get_dependencies() +{ + static const std::array dependencies + { + Args::script_export_node()... + }; + return std::pair + { + dependencies.data(), + dependencies.size() + }; } +} // namespace detail +} // namespace xray::::script_export -// register script exporter (accepts function body) -#define SCRIPT_EXPORT(id, dependencies, ...) SCRIPT_EXPORT_WRAP(id, dependencies, __VA_ARGS__) -// register script exporter (accepts function) -#define SCRIPT_EXPORT_FUNC(id, dependencies, func) SCRIPT_EXPORT_FUNC_WRAP(id, dependencies, func) +#define DECLARE_SCRIPT_REGISTER_FUNCTION(...) \ + static void script_register(lua_State* luaState); \ + template \ + friend auto xray::script_export::detail::get_dependencies(); \ + static const xray::script_export::node* script_export_node() \ + { \ + return &m_script_export_node; \ + } \ + inline static const xray::script_export::node m_script_export_node \ + { \ + &script_register, \ + xray::script_export::detail::get_dependencies<__VA_ARGS__> \ + } diff --git a/src/xrScriptEngine/mslotutils.h b/src/xrScriptEngine/mslotutils.h index efbdc53687b..4309019d644 100644 --- a/src/xrScriptEngine/mslotutils.h +++ b/src/xrScriptEngine/mslotutils.h @@ -1,4 +1,5 @@ #pragma once + #include "xrCore/xrCore.h" class CMailSlotMsg diff --git a/src/xrScriptEngine/pch.hpp b/src/xrScriptEngine/pch.hpp index 6d75a76d6a4..5c96ea44063 100644 --- a/src/xrScriptEngine/pch.hpp +++ b/src/xrScriptEngine/pch.hpp @@ -2,5 +2,7 @@ #include "Common/Common.hpp" -#include "xrScriptEngine.hpp" #include "xrCore/xrCore.h" + +#include "xrScriptEngine.hpp" +#include "script_space.hpp" diff --git a/src/xrScriptEngine/script_callStack.hpp b/src/xrScriptEngine/script_callStack.hpp index b4ceff2441b..e830c381299 100644 --- a/src/xrScriptEngine/script_callStack.hpp +++ b/src/xrScriptEngine/script_callStack.hpp @@ -1,6 +1,6 @@ #pragma once -#include "xrCore/xrCore.h" -#include "xrScriptEngine/xrScriptEngine.hpp" + +#include "xrScriptEngine.hpp" class CScriptDebugger; diff --git a/src/xrScriptEngine/script_callback_ex.h b/src/xrScriptEngine/script_callback_ex.h index 96f47df1140..08984cf8eb7 100644 --- a/src/xrScriptEngine/script_callback_ex.h +++ b/src/xrScriptEngine/script_callback_ex.h @@ -7,7 +7,8 @@ //////////////////////////////////////////////////////////////////////////// #pragma once -#include "xrScriptEngine/script_engine.hpp" + +#include "script_engine.hpp" IC bool compare_safe(const luabind::object& o1, const luabind::object& o2) { diff --git a/src/xrScriptEngine/script_debugger.cpp b/src/xrScriptEngine/script_debugger.cpp index 2f285a84b56..d65f2a23492 100644 --- a/src/xrScriptEngine/script_debugger.cpp +++ b/src/xrScriptEngine/script_debugger.cpp @@ -383,7 +383,7 @@ bool CScriptDebugger::HasBreakPoint(const char* fileName, s32 lineNum) for (size_t i = 0; i < m_breakPoints.size(); i++) { SBreakPoint bp(m_breakPoints[i]); - if (bp.nLine == lineNum && xr_strlen(bp.fileName) == filenameLength && !xr_stricmp(*bp.fileName, sFileName)) + if (bp.nLine == lineNum && xr_strlen(bp.fileName) == filenameLength && !xr_stricmp(bp.fileName.c_str(), sFileName)) return true; } return false; diff --git a/src/xrScriptEngine/script_debugger.hpp b/src/xrScriptEngine/script_debugger.hpp index 38ff88c4b4f..17bc89529f2 100644 --- a/src/xrScriptEngine/script_debugger.hpp +++ b/src/xrScriptEngine/script_debugger.hpp @@ -1,13 +1,12 @@ #pragma once -#include "xrScriptEngine/xrScriptEngine.hpp" +#include "xrScriptEngine.hpp" #include "script_lua_helper.hpp" #include "script_debugger_threads.hpp" #include "script_callStack.hpp" #include "script_debugger_messages.hpp" class CMailSlotMsg; -struct lua_State; #define DMOD_NONE 0 #define DMOD_STEP_INTO 1 diff --git a/src/xrScriptEngine/script_debugger_messages.hpp b/src/xrScriptEngine/script_debugger_messages.hpp index 277aeaa108f..702bfc96793 100644 --- a/src/xrScriptEngine/script_debugger_messages.hpp +++ b/src/xrScriptEngine/script_debugger_messages.hpp @@ -1,5 +1,7 @@ #pragma once +#include "xrScriptEngine.hpp" + struct StackTrace { char szDesc[255]; @@ -28,8 +30,6 @@ struct Variable } }; -struct lua_State; - struct SScriptThread { // void *pScript; diff --git a/src/xrScriptEngine/script_debugger_threads.cpp b/src/xrScriptEngine/script_debugger_threads.cpp index 34fa87d3c29..33d6ab1026e 100644 --- a/src/xrScriptEngine/script_debugger_threads.cpp +++ b/src/xrScriptEngine/script_debugger_threads.cpp @@ -30,8 +30,8 @@ u32 CDbgScriptThreads::FillFrom(CScriptProcess* sp) th.lua = scriptThread->lua(); th.scriptID = scriptThread->thread_reference(); th.active = scriptThread->active(); - xr_strcat(th.name, *scriptThread->script_name()); - xr_strcat(th.process, *sp->name()); + xr_strcat(th.name, scriptThread->script_name().c_str()); + xr_strcat(th.process, sp->name().c_str()); m_threads.push_back(th); } return m_threads.size(); diff --git a/src/xrScriptEngine/script_debugger_threads.hpp b/src/xrScriptEngine/script_debugger_threads.hpp index 49b31544aa4..fdb66879013 100644 --- a/src/xrScriptEngine/script_debugger_threads.hpp +++ b/src/xrScriptEngine/script_debugger_threads.hpp @@ -1,11 +1,10 @@ #pragma once -#include "xrCore/xrCore.h" -#include "xrScriptEngine/xrScriptEngine.hpp" + +#include "xrScriptEngine.hpp" #include "script_debugger_messages.hpp" class CScriptProcess; class CScriptDebugger; -struct lua_State; class XRSCRIPTENGINE_API CDbgScriptThreads { diff --git a/src/xrScriptEngine/script_engine.cpp b/src/xrScriptEngine/script_engine.cpp index 40e426814bb..c204ff0447b 100644 --- a/src/xrScriptEngine/script_engine.cpp +++ b/src/xrScriptEngine/script_engine.cpp @@ -7,11 +7,14 @@ //////////////////////////////////////////////////////////////////////////// #include "pch.hpp" + +#include "Common/Noncopyable.hpp" +#include "xrCore/ModuleLookup.hpp" + #include "script_engine.hpp" #include "script_process.hpp" #include "script_profiler.hpp" #include "script_thread.hpp" -#include "ScriptExporter.hpp" #include "BindingsDumper.hpp" #ifdef USE_DEBUGGER #include "script_debugger.hpp" @@ -19,14 +22,15 @@ #ifdef DEBUG #include "script_thread.hpp" #endif -#include -#include "Common/Noncopyable.hpp" -#include "xrCore/ModuleLookup.hpp" + #include "xrLuaFix/xrLuaFix.h" -#include "luabind/class_info.hpp" #include +#include + +#include + Flags32 g_LuaDebug; int g_LuaDumpDepth = 3; @@ -777,7 +781,7 @@ struct luajit } }; -void CScriptEngine::init(ExporterFunc exporterFunc, bool loadGlobalNamespace) +void CScriptEngine::init(export_func exporter, bool loadGlobalNamespace) { ZoneScoped; @@ -799,8 +803,8 @@ void CScriptEngine::init(ExporterFunc exporterFunc, bool loadGlobalNamespace) luabind::bind_class_info(lua()); setup_callbacks(); - if (exporterFunc) - exporterFunc(lua()); + if (exporter) + exporter(lua()); if (std::strstr(Core.Params, "-dump_bindings") && !bindingsDumped) { bindingsDumped = true; @@ -1124,7 +1128,7 @@ CScriptThread* CScriptEngine::CreateScriptThread(LPCSTR caNamespaceName, bool do void CScriptEngine::DestroyScriptThread(const CScriptThread* thread) { #ifdef DEBUG - Msg("* Destroying script thread %s", *thread->script_name()); + Msg("* Destroying script thread %s", thread->script_name().c_str()); #endif try { diff --git a/src/xrScriptEngine/script_engine.hpp b/src/xrScriptEngine/script_engine.hpp index 9eebccfcd4d..a5f5a9ebfd1 100644 --- a/src/xrScriptEngine/script_engine.hpp +++ b/src/xrScriptEngine/script_engine.hpp @@ -7,30 +7,28 @@ //////////////////////////////////////////////////////////////////////////// #pragma once -#include "xrCore/xrCore.h" -#include "xrScriptEngine/xrScriptEngine.hpp" -#include "xrScriptEngine/ScriptExporter.hpp" -#include "xrScriptEngine/script_profiler.hpp" -#include "xrScriptEngine/script_space_forward.hpp" -#include "xrScriptEngine/Functor.hpp" -#include "xrCore/Threading/Lock.hpp" + #include "xrCommon/xr_unordered_map.h" -struct lua_State; +#include "xrCore/Containers/AssociativeVector.hpp" +#include "xrCore/Threading/Lock.hpp" + +#include "xrScriptEngine.hpp" +#include "ScriptExporter.hpp" +#include "script_space_forward.hpp" +#include "Functor.hpp" #ifndef MASTER_GOLD #define USE_DEBUGGER #define USE_LUA_STUDIO #endif -#include "xrCore/Containers/AssociativeVector.hpp" //#define DBG_DISABLE_SCRIPTS class CScriptProcess; +class CScriptProfiler; class CScriptThread; -struct lua_State; -struct lua_Debug; #ifdef USE_DEBUGGER class CScriptDebugger; @@ -170,7 +168,7 @@ class XRSCRIPTENGINE_API CScriptEngine { int result = 0; - if (g_LuaDebug.test(1) || message == LuaMessageType::Error) + if (message == LuaMessageType::Error || g_LuaDebug.test(1)) { string4096 log; result = xr_sprintf(log, format, std::forward(args)...); @@ -207,10 +205,11 @@ class XRSCRIPTENGINE_API CScriptEngine // Expands the tables/userdata and logs their contents too void log_value(lua_State* L, pcstr name, int depth); - using ExporterFunc = XRay::ScriptExporter::Node::ExporterFunc; + using export_func = xray::script_export::export_func; + CScriptEngine(bool is_editor = false, bool is_with_profiler = false); virtual ~CScriptEngine(); - void init(ExporterFunc exporterFunc, bool loadGlobalNamespace); + void init(export_func exporterFunc, bool loadGlobalNamespace); virtual void unload(); static int lua_panic(lua_State* L); static void lua_error(lua_State* L); @@ -245,6 +244,9 @@ class XRSCRIPTENGINE_API CScriptEngine // This function is called from CScriptThread destructor void DestroyScriptThread(const CScriptThread* thread); bool is_editor(); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; template diff --git a/src/xrScriptEngine/script_lua_helper.hpp b/src/xrScriptEngine/script_lua_helper.hpp index 083b9c04ce4..45e4da1f3e5 100644 --- a/src/xrScriptEngine/script_lua_helper.hpp +++ b/src/xrScriptEngine/script_lua_helper.hpp @@ -1,9 +1,7 @@ #pragma once -#include "xrScriptEngine/xrScriptEngine.hpp" -struct lua_State; -struct Proto; -struct lua_Debug; +#include "xrScriptEngine.hpp" + class CScriptDebugger; class XRSCRIPTENGINE_API CDbgLuaHelper diff --git a/src/xrScriptEngine/script_process.cpp b/src/xrScriptEngine/script_process.cpp index 259d3cb7a5b..ab84e8c22bf 100644 --- a/src/xrScriptEngine/script_process.cpp +++ b/src/xrScriptEngine/script_process.cpp @@ -18,11 +18,11 @@ CScriptProcess::CScriptProcess(CScriptEngine* scriptEngine, shared_str name, sha { this->scriptEngine = scriptEngine; #ifdef DEBUG - Msg("* Initializing %s script process", *m_name); + Msg("* Initializing %s script process", m_name.c_str()); #endif string256 I; - for (u32 i = 0, n = _GetItemCount(*scripts); i < n; i++) - add_script(_GetItem(*scripts, i, I), false, false); + for (u32 i = 0, n = _GetItemCount(scripts.c_str()); i < n; i++) + add_script(_GetItem(scripts.c_str(), i, I), false, false); m_iterator = 0; } diff --git a/src/xrScriptEngine/script_process.hpp b/src/xrScriptEngine/script_process.hpp index a08d0cc92de..649ae09129d 100644 --- a/src/xrScriptEngine/script_process.hpp +++ b/src/xrScriptEngine/script_process.hpp @@ -7,8 +7,8 @@ //////////////////////////////////////////////////////////////////////////// #pragma once -#include "xrCore/xrCore.h" -#include "xrScriptEngine/xrScriptEngine.hpp" + +#include "xrScriptEngine.hpp" class CScriptThread; diff --git a/src/xrScriptEngine/script_profiler.cpp b/src/xrScriptEngine/script_profiler.cpp index 256c36c7739..fd162891eaa 100644 --- a/src/xrScriptEngine/script_profiler.cpp +++ b/src/xrScriptEngine/script_profiler.cpp @@ -447,7 +447,7 @@ void CScriptProfiler::SaveSamplingReport(shared_str filename) if (IWriter* file = FS.w_open(filename.c_str())) { for (auto& it : m_sampling_profiling_log) - file->w_string(*it.GetFoldedStack()); + file->w_string(it.GetFoldedStack().c_str()); FS.w_close(file); } diff --git a/src/xrScriptEngine/script_profiler.hpp b/src/xrScriptEngine/script_profiler.hpp index 5fa9e183533..a40b849cce7 100644 --- a/src/xrScriptEngine/script_profiler.hpp +++ b/src/xrScriptEngine/script_profiler.hpp @@ -2,6 +2,8 @@ #include "xrCommon/xr_unordered_map.h" +#include "xrScriptEngine.hpp" +#include "ScriptExporter.hpp" #include "script_profiler_portions.hpp" enum class CScriptProfilerType : u32 @@ -77,4 +79,7 @@ class XRSCRIPTENGINE_API CScriptProfiler static shared_str LuaJitProfilerDumpToString(lua_State* L, cpcstr format, int depth); static std::pair LuaJitProfilerDump(lua_State* L, cpcstr format, int depth); static std::pair LuaDebugStackInfo(lua_State* L, int level, cpcstr what); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; diff --git a/src/xrScriptEngine/script_space.hpp b/src/xrScriptEngine/script_space.hpp new file mode 100644 index 00000000000..1ef9bc6338e --- /dev/null +++ b/src/xrScriptEngine/script_space.hpp @@ -0,0 +1,38 @@ +//////////////////////////////////////////////////////////////////////////// +// Module : ai_script_space.h +// Created : 22.09.2003 +// Modified : 22.09.2003 +// Author : Dmitriy Iassenev +// Description : XRay Script space +//////////////////////////////////////////////////////////////////////////// + +#pragma once + +#pragma warning(push) + +#pragma warning(disable : 4244) +#pragma warning(disable : 4995) +#pragma warning(disable : 4267) +#pragma warning(disable : 4100) // unreferenced formal parameter + +#include "lua.hpp" + +#pragma warning(disable : 4127) // conditional expression is constant +#pragma warning(disable : 4456) // declaration of 'x' hides previous local declaration +#pragma warning(disable : 4458) // declaration of 'x' hides class member +#pragma warning(disable : 4459) // declaration of 'x' hides global declaration +#pragma warning(disable : 4913) // user defined binary operator 'x' exists but no overload could convert all operands +#pragma warning(disable : 4297) // function assumed not to throw exception but does + +#include +#include +#include +#include +#include +#include +#include +#include + +#pragma warning(pop) + +XRSCRIPTENGINE_API size_t luabind_it_distance(luabind::iterator first, const luabind::iterator& last); diff --git a/src/xrScriptEngine/script_stack_tracker.hpp b/src/xrScriptEngine/script_stack_tracker.hpp index f971a3f8662..81ebb6b8e7c 100644 --- a/src/xrScriptEngine/script_stack_tracker.hpp +++ b/src/xrScriptEngine/script_stack_tracker.hpp @@ -8,20 +8,14 @@ #pragma once -#include "xrCore/xrCore.h" -#include "xrScriptEngine/xrScriptEngine.hpp" +#include "xrScriptEngine.hpp" -struct lua_Debug; -struct lua_State; class CScriptEngine; class XRSCRIPTENGINE_API CScriptStackTracker { protected: - enum consts - { - max_stack_size = u32(256), - }; + static constexpr size_t max_stack_size = 256; protected: CScriptEngine* scriptEngine; diff --git a/src/xrScriptEngine/script_thread.cpp b/src/xrScriptEngine/script_thread.cpp index 16334df4f90..45f9623b3d6 100644 --- a/src/xrScriptEngine/script_thread.cpp +++ b/src/xrScriptEngine/script_thread.cpp @@ -52,14 +52,14 @@ CScriptThread::CScriptThread(CScriptEngine* scriptEngine, LPCSTR caNamespaceName l_iErrorCode = lua_pcall(engineLua, 0, 0, 0); if (l_iErrorCode) { - CScriptEngine::print_output(engineLua, *m_script_name, l_iErrorCode); + CScriptEngine::print_output(engineLua, m_script_name.c_str(), l_iErrorCode); CScriptEngine::on_error(engineLua); return; } } else { - CScriptEngine::print_output(engineLua, *m_script_name, l_iErrorCode); + CScriptEngine::print_output(engineLua, m_script_name.c_str(), l_iErrorCode); CScriptEngine::on_error(engineLua); return; } @@ -99,7 +99,7 @@ bool CScriptThread::update() int l_iErrorCode = lua_resume(lua(), 0); if (l_iErrorCode && l_iErrorCode != LUA_YIELD) { - CScriptEngine::print_output(lua(), *script_name(), l_iErrorCode); + CScriptEngine::print_output(lua(), m_script_name.c_str(), l_iErrorCode); CScriptEngine::on_error(scriptEngine->lua()); #ifdef DEBUG print_stack(lua()); @@ -113,14 +113,14 @@ bool CScriptThread::update() #ifdef DEBUG if (m_current_stack_level) { - CScriptEngine::print_output(lua(), *script_name(), l_iErrorCode); + CScriptEngine::print_output(lua(), m_script_name.c_str(), l_iErrorCode); CScriptEngine::on_error(scriptEngine->lua()); // print_stack(lua()); } #endif m_active = false; #ifdef DEBUG - scriptEngine->script_log(LuaMessageType::Info, "Script %s is finished!", *m_script_name); + scriptEngine->script_log(LuaMessageType::Info, "Script %s is finished!", m_script_name.c_str()); #endif } else diff --git a/src/xrScriptEngine/script_thread.hpp b/src/xrScriptEngine/script_thread.hpp index dd55cd5b7ee..46fbc5d7ace 100644 --- a/src/xrScriptEngine/script_thread.hpp +++ b/src/xrScriptEngine/script_thread.hpp @@ -8,16 +8,14 @@ #pragma once -#include "xrScriptEngine/xrScriptEngine.hpp" -#include "xrCore/xrCore.h" +#include "xrScriptEngine.hpp" + #ifdef DEBUG #include "script_stack_tracker.hpp" #endif #define LUABIND_HAS_BUGS_WITH_LUA_THREADS -struct lua_State; - #ifdef DEBUG class XRSCRIPTENGINE_API CScriptThread : public CScriptStackTracker #else diff --git a/src/xrScriptEngine/xrScriptEngine.hpp b/src/xrScriptEngine/xrScriptEngine.hpp index fc16f5fcb55..c679ff52ae0 100644 --- a/src/xrScriptEngine/xrScriptEngine.hpp +++ b/src/xrScriptEngine/xrScriptEngine.hpp @@ -1,35 +1,5 @@ #pragma once -#pragma warning(push) -#pragma warning(disable : 4244) -#pragma warning(disable : 4995) -#pragma warning(disable : 4267) -#pragma warning(disable : 4100) // unreferenced formal parameter - -extern "C" { -#include -#include -#include -#include -} - -#pragma warning(disable : 4127) // conditional expression is constant -#pragma warning(disable : 4456) // declaration of 'x' hides previous local declaration -#pragma warning(disable : 4458) // declaration of 'x' hides class member -#pragma warning(disable : 4459) // declaration of 'x' hides global declaration -#pragma warning(disable : 4913) // user defined binary operator 'x' exists but no overload could convert all operands -#pragma warning(disable : 4297) // function assumed not to throw exception but does -#include -#include -#include -#include -#include -#include -#include -#include - -#pragma warning(pop) - #ifdef XRAY_STATIC_BUILD # define XRSCRIPTENGINE_API #else @@ -40,4 +10,8 @@ extern "C" { # endif #endif -XRSCRIPTENGINE_API size_t luabind_it_distance(luabind::iterator first, const luabind::iterator& last); +extern "C" +{ +typedef struct lua_State lua_State; +typedef struct lua_Debug lua_Debug; +} diff --git a/src/xrScriptEngine/xrScriptEngine.vcxproj b/src/xrScriptEngine/xrScriptEngine.vcxproj index 8e4f40c0d18..ea10a985c2f 100644 --- a/src/xrScriptEngine/xrScriptEngine.vcxproj +++ b/src/xrScriptEngine/xrScriptEngine.vcxproj @@ -27,11 +27,9 @@ - - @@ -45,6 +43,7 @@ + diff --git a/src/xrScriptEngine/xrScriptEngine.vcxproj.filters b/src/xrScriptEngine/xrScriptEngine.vcxproj.filters index c8acab1b862..97a183b1f14 100644 --- a/src/xrScriptEngine/xrScriptEngine.vcxproj.filters +++ b/src/xrScriptEngine/xrScriptEngine.vcxproj.filters @@ -72,12 +72,6 @@ Thread\StackTracker - - Kernel - - - Kernel - Export @@ -96,6 +90,9 @@ ScriptCallbackEx + + Engine + diff --git a/src/xrServerEntities/alife_human_brain.cpp b/src/xrServerEntities/alife_human_brain.cpp index 763d7bdd269..fc027064623 100644 --- a/src/xrServerEntities/alife_human_brain.cpp +++ b/src/xrServerEntities/alife_human_brain.cpp @@ -11,7 +11,6 @@ #include "Common/object_broker.h" #include "xrServer_Objects_ALife_Monsters.h" -#ifdef XRGAME_EXPORTS #include "alife_human_object_handler.h" #include "alife_monster_movement_manager.h" #include "alife_monster_detail_path_manager.h" @@ -30,28 +29,23 @@ #include "map_location.h" #include "map_manager.h" #endif -#endif CALifeHumanBrain::CALifeHumanBrain(object_type* object) : inherited(object) { VERIFY(object); m_object = object; -#ifdef XRGAME_EXPORTS m_object_handler = xr_new(object); -#endif m_dwTotalMoney = 0; m_cpEquipmentPreferences.resize(5); m_cpMainWeaponPreferences.resize(4); -#ifdef XRGAME_EXPORTS m_cpEquipmentPreferences.resize(iFloor(ai().ef_storage().m_pfEquipmentType->ffGetMaxResultValue() + .5f)); m_cpMainWeaponPreferences.resize(iFloor(ai().ef_storage().m_pfMainWeaponType->ffGetMaxResultValue() + .5f)); R_ASSERT2((iFloor(ai().ef_storage().m_pfEquipmentType->ffGetMaxResultValue() + .5f) == 5) && (iFloor(ai().ef_storage().m_pfMainWeaponType->ffGetMaxResultValue() + .5f) == 4), "Recompile Level Editor and xrAI and rebuild file \"game.spawn\"!"); -#endif for (int i = 0, n = m_cpEquipmentPreferences.size(); i < n; ++i) m_cpEquipmentPreferences[i] = u8(::Random.randI(3)); @@ -62,9 +56,7 @@ CALifeHumanBrain::CALifeHumanBrain(object_type* object) : inherited(object) CALifeHumanBrain::~CALifeHumanBrain() { -#ifdef XRGAME_EXPORTS xr_delete(m_object_handler); -#endif } void CALifeHumanBrain::on_state_write(NET_Packet& packet) diff --git a/src/xrServerEntities/alife_human_brain.h b/src/xrServerEntities/alife_human_brain.h index 8ec1e28e763..35062fdd47d 100644 --- a/src/xrServerEntities/alife_human_brain.h +++ b/src/xrServerEntities/alife_human_brain.h @@ -46,6 +46,9 @@ class CALifeHumanBrain : public CALifeMonsterBrain public: IC object_type& object() const; IC object_handler_type& objects() const; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CALifeMonsterBrain); }; #include "alife_human_brain_inline.h" diff --git a/src/xrServerEntities/alife_monster_brain.cpp b/src/xrServerEntities/alife_monster_brain.cpp index f7fcdb0dc11..6f452bbd467 100644 --- a/src/xrServerEntities/alife_monster_brain.cpp +++ b/src/xrServerEntities/alife_monster_brain.cpp @@ -11,7 +11,6 @@ #include "Common/object_broker.h" #include "xrServer_Objects_ALife_Monsters.h" -#ifdef XRGAME_EXPORTS #include "alife_monster_movement_manager.h" #include "alife_monster_detail_path_manager.h" #include "alife_monster_patrol_path_manager.h" @@ -29,7 +28,6 @@ #include "map_location.h" #include "map_manager.h" #endif -#endif CALifeMonsterBrain::CALifeMonsterBrain(object_type* object) { @@ -38,30 +36,23 @@ CALifeMonsterBrain::CALifeMonsterBrain(object_type* object) m_last_search_time = 0; m_smart_terrain = nullptr; -#ifdef XRGAME_EXPORTS m_movement_manager = xr_new(object); -#endif -#ifdef XRGAME_EXPORTS u32 hours, minutes, seconds; sscanf(pSettings->r_string(this->object().name(), "smart_terrain_choose_interval"), "%d:%d:%d", &hours, &minutes, &seconds); m_time_interval = (u32)generate_time(1, 1, 1, hours, minutes, seconds); -#endif m_can_choose_alife_tasks = true; } CALifeMonsterBrain::~CALifeMonsterBrain() { -#ifdef XRGAME_EXPORTS xr_delete(m_movement_manager); -#endif } void CALifeMonsterBrain::on_state_write(NET_Packet& /*packet*/) {} void CALifeMonsterBrain::on_state_read(NET_Packet& /*packet*/) {} -#ifdef XRGAME_EXPORTS bool CALifeMonsterBrain::perform_attack() { return (false); } ALife::EMeetActionType CALifeMonsterBrain::action_type( @@ -157,4 +148,3 @@ void CALifeMonsterBrain::update(const bool forced) void CALifeMonsterBrain::default_behaviour() { movement().path_type(MovementManager::ePathTypeNoPath); } void CALifeMonsterBrain::on_switch_online() { movement().on_switch_online(); } void CALifeMonsterBrain::on_switch_offline() { movement().on_switch_offline(); } -#endif // XRGAME_EXPORTS diff --git a/src/xrServerEntities/alife_monster_brain.h b/src/xrServerEntities/alife_monster_brain.h index 83563c20f12..367c8495035 100644 --- a/src/xrServerEntities/alife_monster_brain.h +++ b/src/xrServerEntities/alife_monster_brain.h @@ -57,7 +57,6 @@ class CALifeMonsterBrain public: void update(const bool forced = false); - void update_script() { this->update(true); } bool perform_attack(); ALife::EMeetActionType action_type( CSE_ALifeSchedulable* tpALifeSchedulable, const int& iGroupIndex, const bool& bMutualDetection); @@ -67,6 +66,9 @@ class CALifeMonsterBrain IC movement_manager_type& movement() const; CSE_ALifeSmartZone& smart_terrain(); IC void can_choose_alife_tasks(bool value); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #include "alife_monster_brain_inline.h" diff --git a/src/xrServerEntities/alife_movement_manager_holder.h b/src/xrServerEntities/alife_movement_manager_holder.h index 988cf3a333f..4c1e0711150 100644 --- a/src/xrServerEntities/alife_movement_manager_holder.h +++ b/src/xrServerEntities/alife_movement_manager_holder.h @@ -19,10 +19,8 @@ class CMovementManagerHolder float m_fDistanceToPoint; GameGraph::TERRAIN_VECTOR m_tpaTerrain; -#ifdef XRGAME_EXPORTS public: virtual void on_location_change() const = 0; virtual CSE_ALifeDynamicObject const& get_object() const = 0; virtual CSE_ALifeDynamicObject& get_object() = 0; -#endif //#ifdef XRGAME_EXPORTS }; // CMovementManagerHolder diff --git a/src/xrServerEntities/character_info.cpp b/src/xrServerEntities/character_info.cpp index 5ee5744b5a2..b3b6346db4c 100644 --- a/src/xrServerEntities/character_info.cpp +++ b/src/xrServerEntities/character_info.cpp @@ -6,46 +6,16 @@ #include "StdAfx.h" #include "character_info.h" -#ifdef XRGAME_EXPORTS #include "xrUICore/XML/xrUIXmlParser.h" #include "PhraseDialog.h" #include "xrServer_Objects_ALife_Monsters.h" -#else // XRGAME_EXPORTS -#include "xrUIXmlParser.h" -#endif // XRGAME_EXPORTS -////////////////////////////////////////////////////////////////////////// -SCharacterProfile::SCharacterProfile() -{ - m_CharacterId = nullptr; - m_Rank = NO_RANK; - m_Reputation = NO_REPUTATION; -} - -SCharacterProfile::~SCharacterProfile() {} -////////////////////////////////////////////////////////////////////////// - -CCharacterInfo::CCharacterInfo() -{ - m_ProfileId = nullptr; - m_SpecificCharacterId = nullptr; - -#ifdef XRGAME_EXPORTS - m_CurrentRank.set(NO_RANK); - m_CurrentReputation.set(NO_REPUTATION); - m_Sympathy = 0.0f; -#endif -} - -CCharacterInfo::~CCharacterInfo() {} void CCharacterInfo::Load(shared_str id) { m_ProfileId = id; inherited_shared::load_shared(m_ProfileId, nullptr); } -#ifdef XRGAME_EXPORTS - void CCharacterInfo::InitSpecificCharacter(shared_str new_id) { R_ASSERT(new_id.size()); @@ -62,8 +32,6 @@ void CCharacterInfo::InitSpecificCharacter(shared_str new_id) m_StartDialog = m_SpecificCharacter.data()->m_StartDialog; } -#endif - void CCharacterInfo::load_shared(LPCSTR) { const ITEM_DATA& item_data = *id_to_index::GetById(m_ProfileId); @@ -72,7 +40,7 @@ void CCharacterInfo::load_shared(LPCSTR) pXML->SetLocalRoot(pXML->GetRoot()); XML_NODE item_node = pXML->NavigateToNode(id_to_index::tag_name, item_data.pos_in_file); - R_ASSERT3(item_node, "profile id=", *item_data.id); + R_ASSERT3(item_node, "profile id=", item_data.id.c_str()); pXML->SetLocalRoot(item_node); @@ -100,7 +68,6 @@ void CCharacterInfo::load_shared(LPCSTR) data()->m_CharacterId = spec_char; } -#ifdef XRGAME_EXPORTS void CCharacterInfo::Init(CSE_ALifeTraderAbstract* trader) { SetCommunity(trader->m_community_index); @@ -141,7 +108,6 @@ const DIALOG_ID_VECTOR& CCharacterInfo::ActorDialogs() const void CCharacterInfo::load(IReader& stream) { stream.r_stringZ(m_StartDialog); } void CCharacterInfo::save(NET_Packet& stream) { stream.w_stringZ(m_StartDialog); } -#endif void CCharacterInfo::InitXmlIdToIndex() { diff --git a/src/xrServerEntities/character_info.h b/src/xrServerEntities/character_info.h index a3c819eeff8..c848202e036 100644 --- a/src/xrServerEntities/character_info.h +++ b/src/xrServerEntities/character_info.h @@ -9,28 +9,23 @@ #include "shared_data.h" #include "xml_str_id_loader.h" -class NET_Packet; - #ifndef AI_COMPILER #include "specific_character.h" #endif -#ifdef XRGAME_EXPORTS #include "PhraseDialogDefs.h" #include "character_community.h" #include "character_rank.h" #include "character_reputation.h" + +class NET_Packet; class CSE_ALifeTraderAbstract; -#endif ////////////////////////////////////////////////////////////////////////// // SCharacterProfile: данные Ð¿Ñ€Ð¾Ñ„Ð¸Ð»Ñ Ð¿ÐµÑ€Ñонажа ////////////////////////////////////////////////////////////////////////// struct SCharacterProfile : CSharedResource { - SCharacterProfile(); - virtual ~SCharacterProfile(); - //еÑли задано, то выбираетÑÑ Ð¸Ð¼ÐµÐ½Ð½Ð¾ такой профиль, //иначе ищетÑÑ Ñлучайно,удовлетворÑющее шаблону shared_str m_CharacterId; @@ -55,12 +50,8 @@ class CCharacterInfo : public CSharedClass friend CSE_ALifeTraderAbstract; public: - CCharacterInfo(); - ~CCharacterInfo(); - virtual void Load(shared_str id); -#ifdef XRGAME_EXPORTS void load(IReader&); void save(NET_Packet&); @@ -69,7 +60,6 @@ class CCharacterInfo : public CSharedClass //указанному индекÑу void Init(CSE_ALifeTraderAbstract* trader); void InitSpecificCharacter(shared_str new_id); -#endif protected: const SCharacterProfile* data() const @@ -95,15 +85,12 @@ class CCharacterInfo : public CSharedClass //иÑпользуетÑÑ Ð² данном ÑкземплÑре клаÑÑа shared_str m_SpecificCharacterId; -#ifdef XRGAME_EXPORTS shared_str m_StartDialog; //Ð·Ð°Ð³Ñ€ÑƒÐ¶ÐµÐ½Ð½Ð°Ñ Ð¸Ð½Ñ„Ð¾Ñ€Ð¼Ð°Ñ†Ð¸Ñ Ð¾ конкретном перÑонаже CSpecificCharacter m_SpecificCharacter; -#endif public: -#ifdef XRGAME_EXPORTS shared_str Profile() const; LPCSTR Name() const; shared_str Bio() const; @@ -124,13 +111,10 @@ class CCharacterInfo : public CSharedClass shared_str StartDialog() const; const DIALOG_ID_VECTOR& ActorDialogs() const; -#endif protected: -#ifdef XRGAME_EXPORTS CHARACTER_RANK m_CurrentRank; CHARACTER_REPUTATION m_CurrentReputation; CHARACTER_COMMUNITY m_CurrentCommunity; - float m_Sympathy; // % влиÑÐ½Ð¸Ñ Ð½Ð° группировку -#endif + float m_Sympathy{}; // % влиÑÐ½Ð¸Ñ Ð½Ð° группировку }; diff --git a/src/xrServerEntities/clsid_game.h b/src/xrServerEntities/clsid_game.h index e1a591b4ade..17ed5cfa680 100644 --- a/src/xrServerEntities/clsid_game.h +++ b/src/xrServerEntities/clsid_game.h @@ -1,235 +1,236 @@ #pragma once + #include "xrCore/clsid.h" -constexpr CLASS_ID CLSID_OBJECT_ACTOR = MK_CLSID('O', '_', 'A', 'C', 'T', 'O', 'R', ' '); -constexpr CLASS_ID CLSID_OBJECT_HLAMP = MK_CLSID('O', '_', 'H', 'L', 'A', 'M', 'P', ' '); -constexpr CLASS_ID CLSID_ENTITY = MK_CLSID('E', 'N', 'T', 'I', 'T', 'Y', ' ', ' '); -constexpr CLASS_ID CLSID_SPECTATOR = MK_CLSID('S', 'P', 'E', 'C', 'T', ' ', ' ', ' '); -constexpr CLASS_ID CLSID_OBJECT_PROJECTOR = MK_CLSID('O', '_', 'S', 'E', 'A', 'R', 'C', 'H'); +constexpr CLASS_ID CLSID_OBJECT_ACTOR = xray::make_clsid("O_ACTOR "); +constexpr CLASS_ID CLSID_OBJECT_HLAMP = xray::make_clsid("O_HLAMP "); +constexpr CLASS_ID CLSID_ENTITY = xray::make_clsid("ENTITY "); +constexpr CLASS_ID CLSID_SPECTATOR = xray::make_clsid("SPECT "); +constexpr CLASS_ID CLSID_OBJECT_PROJECTOR = xray::make_clsid("O_SEARCH"); // all the monsters -constexpr CLASS_ID CLSID_LEVEL_POINT = MK_CLSID('L', 'V', 'L', 'P', 'O', 'I', 'N', 'T'); -constexpr CLASS_ID CLSID_SCRIPT_OBJECT = MK_CLSID('S', 'C', 'R', 'P', 'T', 'O', 'B', 'J'); -constexpr CLASS_ID CLSID_AI_GRAPH = MK_CLSID('A', 'I', '_', 'G', 'R', 'A', 'P', 'H'); -constexpr CLASS_ID CLSID_AI_CROW = MK_CLSID('A', 'I', '_', 'C', 'R', 'O', 'W', ' '); - -constexpr CLASS_ID CLSID_AI_ZOMBIE = MK_CLSID('A', 'I', '_', 'Z', 'O', 'M', ' ', ' '); -constexpr CLASS_ID CLSID_AI_POLTERGEIST = MK_CLSID('A', 'I', '_', 'P', 'O', 'L', 'T', 'R'); - -constexpr CLASS_ID CLSID_AI_FLESH = MK_CLSID('A', 'I', '_', 'F', 'L', 'E', 'S', 'H'); -constexpr CLASS_ID CLSID_AI_FLESH_GROUP = MK_CLSID('A', 'I', '_', 'F', 'L', 'E', '_', 'G'); - -constexpr CLASS_ID CLSID_AI_PHANTOM = MK_CLSID('A', 'I', '_', 'P', 'H', 'A', 'N', 'T'); -constexpr CLASS_ID CLSID_AI_SPONGER = MK_CLSID('A', 'I', '_', 'S', 'P', 'O', 'N', 'G'); -constexpr CLASS_ID CLSID_AI_CONTROLLER = MK_CLSID('A', 'I', '_', 'C', 'O', 'N', 'T', 'R'); -constexpr CLASS_ID CLSID_AI_BLOODSUCKER = MK_CLSID('A', 'I', '_', 'B', 'L', 'O', 'O', 'D'); -constexpr CLASS_ID CLSID_AI_STALKER = MK_CLSID('A', 'I', '_', 'S', 'T', 'L', ' ', ' '); -constexpr CLASS_ID CLSID_AI_BURER = MK_CLSID('A', 'I', '_', 'B', 'U', 'R', 'E', 'R'); -constexpr CLASS_ID CLSID_AI_GIANT = MK_CLSID('A', 'I', '_', 'G', 'I', 'A', 'N', 'T'); -constexpr CLASS_ID CLSID_AI_CHIMERA = MK_CLSID('A', 'I', '_', 'H', 'I', 'M', 'E', 'R'); -constexpr CLASS_ID CLSID_AI_FRACTURE = MK_CLSID('A', 'I', '_', 'F', 'R', 'A', 'C', 'T'); -constexpr CLASS_ID CLSID_AI_DOG_BLACK = MK_CLSID('A', 'I', '_', 'D', 'O', 'G', '_', 'B'); -constexpr CLASS_ID CLSID_AI_DOG_RED = MK_CLSID('A', 'I', '_', 'D', 'O', 'G', '_', 'R'); -constexpr CLASS_ID CLSID_AI_DOG_PSY = MK_CLSID('A', 'I', '_', 'D', 'O', 'G', '_', 'P'); -constexpr CLASS_ID CLSID_AI_DOG_PSY_PHANTOM = MK_CLSID('A', 'I', '_', 'D', 'O', 'G', '_', 'F'); -constexpr CLASS_ID CLSID_AI_TRADER = MK_CLSID('A', 'I', '_', 'T', 'R', 'A', 'D', 'E'); -constexpr CLASS_ID CLSID_AI_BOAR = MK_CLSID('A', 'I', '_', 'B', 'O', 'A', 'R', ' '); -constexpr CLASS_ID CLSID_AI_SNORK = MK_CLSID('A', 'I', '_', 'S', 'N', 'O', 'R', 'K'); -constexpr CLASS_ID CLSID_AI_CAT = MK_CLSID('A', 'I', '_', 'C', 'A', 'T', ' ', ' '); -constexpr CLASS_ID CLSID_AI_TUSHKANO = MK_CLSID('A', 'I', '_', 'T', 'U', 'S', 'H', ' '); -constexpr CLASS_ID CLSID_AI_RAT = MK_CLSID('A', 'I', '_', 'R', 'A', 'T', ' ', ' '); +constexpr CLASS_ID CLSID_LEVEL_POINT = xray::make_clsid("LVLPOINT"); +constexpr CLASS_ID CLSID_SCRIPT_OBJECT = xray::make_clsid("SCRPTOBJ"); +constexpr CLASS_ID CLSID_AI_GRAPH = xray::make_clsid("AI_GRAPH"); +constexpr CLASS_ID CLSID_AI_CROW = xray::make_clsid("AI_CROW "); + +constexpr CLASS_ID CLSID_AI_ZOMBIE = xray::make_clsid("AI_ZOM "); +constexpr CLASS_ID CLSID_AI_POLTERGEIST = xray::make_clsid("AI_POLTR"); + +constexpr CLASS_ID CLSID_AI_FLESH = xray::make_clsid("AI_FLESH"); +constexpr CLASS_ID CLSID_AI_FLESH_GROUP = xray::make_clsid("AI_FLE_G"); + +constexpr CLASS_ID CLSID_AI_PHANTOM = xray::make_clsid("AI_PHANT"); +constexpr CLASS_ID CLSID_AI_SPONGER = xray::make_clsid("AI_SPONG"); +constexpr CLASS_ID CLSID_AI_CONTROLLER = xray::make_clsid("AI_CONTR"); +constexpr CLASS_ID CLSID_AI_BLOODSUCKER = xray::make_clsid("AI_BLOOD"); +constexpr CLASS_ID CLSID_AI_STALKER = xray::make_clsid("AI_STL "); +constexpr CLASS_ID CLSID_AI_BURER = xray::make_clsid("AI_BURER"); +constexpr CLASS_ID CLSID_AI_GIANT = xray::make_clsid("AI_GIANT"); +constexpr CLASS_ID CLSID_AI_CHIMERA = xray::make_clsid("AI_HIMER"); +constexpr CLASS_ID CLSID_AI_FRACTURE = xray::make_clsid("AI_FRACT"); +constexpr CLASS_ID CLSID_AI_DOG_BLACK = xray::make_clsid("AI_DOG_B"); +constexpr CLASS_ID CLSID_AI_DOG_RED = xray::make_clsid("AI_DOG_R"); +constexpr CLASS_ID CLSID_AI_DOG_PSY = xray::make_clsid("AI_DOG_P"); +constexpr CLASS_ID CLSID_AI_DOG_PSY_PHANTOM = xray::make_clsid("AI_DOG_F"); +constexpr CLASS_ID CLSID_AI_TRADER = xray::make_clsid("AI_TRADE"); +constexpr CLASS_ID CLSID_AI_BOAR = xray::make_clsid("AI_BOAR "); +constexpr CLASS_ID CLSID_AI_SNORK = xray::make_clsid("AI_SNORK"); +constexpr CLASS_ID CLSID_AI_CAT = xray::make_clsid("AI_CAT "); +constexpr CLASS_ID CLSID_AI_TUSHKANO = xray::make_clsid("AI_TUSH "); +constexpr CLASS_ID CLSID_AI_RAT = xray::make_clsid("AI_RAT "); // vehicles -constexpr CLASS_ID CLSID_CAR = MK_CLSID('C', '_', 'N', 'I', 'V', 'A', ' ', ' '); -constexpr CLASS_ID CLSID_VEHICLE_HELICOPTER = MK_CLSID('C', '_', 'H', 'L', 'C', 'P', 'T', 'R'); +constexpr CLASS_ID CLSID_CAR = xray::make_clsid("C_NIVA "); +constexpr CLASS_ID CLSID_VEHICLE_HELICOPTER = xray::make_clsid("C_HLCPTR"); -constexpr CLASS_ID CLSID_EVENT = MK_CLSID('E', 'V', 'E', 'N', 'T', ' ', ' ', ' '); -constexpr CLASS_ID CLSID_OBJECT_FLYER = MK_CLSID('O', '_', 'F', 'L', 'Y', 'E', 'R', ' '); -constexpr CLASS_ID CLSID_OBJECT_DOOR = MK_CLSID('O', '_', 'D', 'O', 'O', 'R', ' ', ' '); -constexpr CLASS_ID CLSID_OBJECT_LIFT = MK_CLSID('O', '_', 'L', 'I', 'F', 'T', ' ', ' '); +constexpr CLASS_ID CLSID_EVENT = xray::make_clsid("EVENT "); +constexpr CLASS_ID CLSID_OBJECT_FLYER = xray::make_clsid("O_FLYER "); +constexpr CLASS_ID CLSID_OBJECT_DOOR = xray::make_clsid("O_DOOR "); +constexpr CLASS_ID CLSID_OBJECT_LIFT = xray::make_clsid("O_LIFT "); // Artefacts -constexpr CLASS_ID CLSID_AF_MERCURY_BALL = MK_CLSID('A', 'F', '_', 'M', 'B', 'A', 'L', 'L'); -constexpr CLASS_ID CLSID_AF_GRAVI = MK_CLSID('A', 'F', '_', 'G', 'R', 'A', 'V', 'I'); -constexpr CLASS_ID CLSID_AF_BLACKDROPS = MK_CLSID('A', 'F', '_', 'B', 'D', 'R', 'O', 'P'); -constexpr CLASS_ID CLSID_AF_NEEDLES = MK_CLSID('A', 'F', '_', 'N', 'E', 'E', 'D', 'L'); -constexpr CLASS_ID CLSID_AF_BAST = MK_CLSID('A', 'F', '_', 'B', 'A', 'S', 'T', ' '); -constexpr CLASS_ID CLSID_AF_BLACK_GRAVI = MK_CLSID('A', 'F', '_', 'B', 'G', 'R', 'A', 'V'); -constexpr CLASS_ID CLSID_AF_DUMMY = MK_CLSID('A', 'F', '_', 'D', 'U', 'M', 'M', 'Y'); -constexpr CLASS_ID CLSID_AF_ZUDA = MK_CLSID('A', 'F', '_', 'Z', 'U', 'D', 'A', ' '); -constexpr CLASS_ID CLSID_AF_THORN = MK_CLSID('A', 'F', '_', 'T', 'H', 'O', 'R', 'N'); -constexpr CLASS_ID CLSID_AF_FADED_BALL = MK_CLSID('A', 'F', '_', 'F', 'B', 'A', 'L', 'L'); -constexpr CLASS_ID CLSID_AF_ELECTRIC_BALL = MK_CLSID('A', 'F', '_', 'E', 'B', 'A', 'L', 'L'); -constexpr CLASS_ID CLSID_AF_RUSTY_HAIR = MK_CLSID('A', 'F', '_', 'R', 'H', 'A', 'I', 'R'); -constexpr CLASS_ID CLSID_AF_GALANTINE = MK_CLSID('A', 'F', '_', 'G', 'A', 'L', 'A', 'N'); -constexpr CLASS_ID CLSID_AF_CTA = MK_CLSID('A', 'F', '_', 'C', 'T', 'A', ' ', ' '); - -constexpr CLASS_ID CLSID_ARTEFACT = MK_CLSID('A', 'R', 'T', 'E', 'F', 'A', 'C', 'T'); +constexpr CLASS_ID CLSID_AF_MERCURY_BALL = xray::make_clsid("AF_MBALL"); +constexpr CLASS_ID CLSID_AF_GRAVI = xray::make_clsid("AF_GRAVI"); +constexpr CLASS_ID CLSID_AF_BLACKDROPS = xray::make_clsid("AF_BDROP"); +constexpr CLASS_ID CLSID_AF_NEEDLES = xray::make_clsid("AF_NEEDL"); +constexpr CLASS_ID CLSID_AF_BAST = xray::make_clsid("AF_BAST "); +constexpr CLASS_ID CLSID_AF_BLACK_GRAVI = xray::make_clsid("AF_BGRAV"); +constexpr CLASS_ID CLSID_AF_DUMMY = xray::make_clsid("AF_DUMMY"); +constexpr CLASS_ID CLSID_AF_ZUDA = xray::make_clsid("AF_ZUDA "); +constexpr CLASS_ID CLSID_AF_THORN = xray::make_clsid("AF_THORN"); +constexpr CLASS_ID CLSID_AF_FADED_BALL = xray::make_clsid("AF_FBALL"); +constexpr CLASS_ID CLSID_AF_ELECTRIC_BALL = xray::make_clsid("AF_EBALL"); +constexpr CLASS_ID CLSID_AF_RUSTY_HAIR = xray::make_clsid("AF_RHAIR"); +constexpr CLASS_ID CLSID_AF_GALANTINE = xray::make_clsid("AF_GALAN"); +constexpr CLASS_ID CLSID_AF_CTA = xray::make_clsid("AF_CTA "); + +constexpr CLASS_ID CLSID_ARTEFACT = xray::make_clsid("ARTEFACT"); // Weapons -constexpr CLASS_ID CLSID_OBJECT_W_M134 = MK_CLSID('W', '_', 'M', '1', '3', '4', ' ', ' '); -constexpr CLASS_ID CLSID_OBJECT_W_FN2000 = MK_CLSID('W', '_', 'F', 'N', '2', '0', '0', '0'); -constexpr CLASS_ID CLSID_OBJECT_W_AK74 = MK_CLSID('W', '_', 'A', 'K', '7', '4', ' ', ' '); -constexpr CLASS_ID CLSID_OBJECT_W_LR300 = MK_CLSID('W', '_', 'L', 'R', '3', '0', '0', ' '); -constexpr CLASS_ID CLSID_OBJECT_W_HPSA = MK_CLSID('W', '_', 'H', 'P', 'S', 'A', ' ', ' '); -constexpr CLASS_ID CLSID_OBJECT_W_PM = MK_CLSID('W', '_', 'P', 'M', ' ', ' ', ' ', ' '); -constexpr CLASS_ID CLSID_OBJECT_W_FORT = MK_CLSID('W', '_', 'F', 'O', 'R', 'T', ' ', ' '); -constexpr CLASS_ID CLSID_OBJECT_W_BINOCULAR = MK_CLSID('W', '_', 'B', 'I', 'N', 'O', 'C', ' '); -constexpr CLASS_ID CLSID_OBJECT_W_SHOTGUN = MK_CLSID('W', '_', 'S', 'H', 'O', 'T', 'G', 'N'); -constexpr CLASS_ID CLSID_OBJECT_W_ASHOTGUN = MK_CLSID('W', '_', 'A', 'S', 'H', 'T', 'G', 'N'); +constexpr CLASS_ID CLSID_OBJECT_W_M134 = xray::make_clsid("W_M134 "); +constexpr CLASS_ID CLSID_OBJECT_W_FN2000 = xray::make_clsid("W_FN2000"); +constexpr CLASS_ID CLSID_OBJECT_W_AK74 = xray::make_clsid("W_AK74 "); +constexpr CLASS_ID CLSID_OBJECT_W_LR300 = xray::make_clsid("W_LR300 "); +constexpr CLASS_ID CLSID_OBJECT_W_HPSA = xray::make_clsid("W_HPSA "); +constexpr CLASS_ID CLSID_OBJECT_W_PM = xray::make_clsid("W_PM "); +constexpr CLASS_ID CLSID_OBJECT_W_FORT = xray::make_clsid("W_FORT "); +constexpr CLASS_ID CLSID_OBJECT_W_BINOCULAR = xray::make_clsid("W_BINOC "); +constexpr CLASS_ID CLSID_OBJECT_W_SHOTGUN = xray::make_clsid("W_SHOTGN"); +constexpr CLASS_ID CLSID_OBJECT_W_ASHOTGUN = xray::make_clsid("W_ASHTGN"); // [8/15/2006] -constexpr CLASS_ID CLSID_OBJECT_W_MAGAZINED = MK_CLSID('W', '_', 'W', 'M', 'A', 'G', 'A', 'Z'); +constexpr CLASS_ID CLSID_OBJECT_W_MAGAZINED = xray::make_clsid("W_WMAGAZ"); // [8/15/2006] // [8/17/2006] -constexpr CLASS_ID CLSID_OBJECT_W_MAGAZWGL = MK_CLSID('W', '_', 'W', 'M', 'A', 'G', 'G', 'L'); +constexpr CLASS_ID CLSID_OBJECT_W_MAGAZWGL = xray::make_clsid("W_WMAGGL"); // [8/17/2006] -constexpr CLASS_ID CLSID_OBJECT_W_SVD = MK_CLSID('W', '_', 'S', 'V', 'D', ' ', ' ', ' '); -constexpr CLASS_ID CLSID_OBJECT_W_SVU = MK_CLSID('W', '_', 'S', 'V', 'U', ' ', ' ', ' '); -constexpr CLASS_ID CLSID_OBJECT_W_RPG7 = MK_CLSID('W', '_', 'R', 'P', 'G', '7', ' ', ' '); -constexpr CLASS_ID CLSID_OBJECT_W_VAL = MK_CLSID('W', '_', 'V', 'A', 'L', ' ', ' ', ' '); -constexpr CLASS_ID CLSID_OBJECT_W_VINTOREZ = MK_CLSID('W', '_', 'V', 'I', 'N', 'T', ' ', ' '); -constexpr CLASS_ID CLSID_OBJECT_W_WALTHER = MK_CLSID('W', '_', 'W', 'A', 'L', 'T', 'H', 'R'); -constexpr CLASS_ID CLSID_OBJECT_W_USP45 = MK_CLSID('W', '_', 'U', 'S', 'P', '4', '5', ' '); -constexpr CLASS_ID CLSID_OBJECT_W_GROZA = MK_CLSID('W', '_', 'G', 'R', 'O', 'Z', 'A', ' '); -constexpr CLASS_ID CLSID_OBJECT_W_KNIFE = MK_CLSID('W', '_', 'K', 'N', 'I', 'F', 'E', ' '); -constexpr CLASS_ID CLSID_OBJECT_W_BM16 = MK_CLSID('W', '_', 'B', 'M', '1', '6', ' ', ' '); -constexpr CLASS_ID CLSID_OBJECT_W_RG6 = MK_CLSID('W', '_', 'R', 'G', '6', ' ', ' ', ' '); - -constexpr CLASS_ID CLSID_OBJECT_W_STATMGUN = MK_CLSID('W', '_', 'S', 'T', 'M', 'G', 'U', 'N'); +constexpr CLASS_ID CLSID_OBJECT_W_SVD = xray::make_clsid("W_SVD "); +constexpr CLASS_ID CLSID_OBJECT_W_SVU = xray::make_clsid("W_SVU "); +constexpr CLASS_ID CLSID_OBJECT_W_RPG7 = xray::make_clsid("W_RPG7 "); +constexpr CLASS_ID CLSID_OBJECT_W_VAL = xray::make_clsid("W_VAL "); +constexpr CLASS_ID CLSID_OBJECT_W_VINTOREZ = xray::make_clsid("W_VINT "); +constexpr CLASS_ID CLSID_OBJECT_W_WALTHER = xray::make_clsid("W_WALTHR"); +constexpr CLASS_ID CLSID_OBJECT_W_USP45 = xray::make_clsid("W_USP45 "); +constexpr CLASS_ID CLSID_OBJECT_W_GROZA = xray::make_clsid("W_GROZA "); +constexpr CLASS_ID CLSID_OBJECT_W_KNIFE = xray::make_clsid("W_KNIFE "); +constexpr CLASS_ID CLSID_OBJECT_W_BM16 = xray::make_clsid("W_BM16 "); +constexpr CLASS_ID CLSID_OBJECT_W_RG6 = xray::make_clsid("W_RG6 "); + +constexpr CLASS_ID CLSID_OBJECT_W_STATMGUN = xray::make_clsid("W_STMGUN"); // Weapons Ammo -constexpr CLASS_ID CLSID_OBJECT_AMMO = MK_CLSID('A', 'M', 'M', 'O', ' ', ' ', ' ', ' '); +constexpr CLASS_ID CLSID_OBJECT_AMMO = xray::make_clsid("AMMO "); //------------------------------------------ ----------------------------------- -constexpr CLASS_ID CLSID_OBJECT_A_VOG25 = MK_CLSID('A', '_', 'V', 'O', 'G', '2', '5', ' '); -constexpr CLASS_ID CLSID_OBJECT_A_OG7B = MK_CLSID('A', '_', 'O', 'G', '7', 'B', ' ', ' '); -constexpr CLASS_ID CLSID_OBJECT_A_M209 = MK_CLSID('A', '_', 'M', '2', '0', '9', ' ', ' '); +constexpr CLASS_ID CLSID_OBJECT_A_VOG25 = xray::make_clsid("A_VOG25 "); +constexpr CLASS_ID CLSID_OBJECT_A_OG7B = xray::make_clsid("A_OG7B "); +constexpr CLASS_ID CLSID_OBJECT_A_M209 = xray::make_clsid("A_M209 "); //------------------------------------------ ----------------------------------- // Weapons Add-ons -constexpr CLASS_ID CLSID_OBJECT_W_SCOPE = MK_CLSID('W', '_', 'S', 'C', 'O', 'P', 'E', ' '); -constexpr CLASS_ID CLSID_OBJECT_W_SILENCER = MK_CLSID('W', '_', 'S', 'I', 'L', 'E', 'N', 'C'); -constexpr CLASS_ID CLSID_OBJECT_W_GLAUNCHER = MK_CLSID('W', '_', 'G', 'L', 'A', 'U', 'N', 'C'); +constexpr CLASS_ID CLSID_OBJECT_W_SCOPE = xray::make_clsid("W_SCOPE "); +constexpr CLASS_ID CLSID_OBJECT_W_SILENCER = xray::make_clsid("W_SILENC"); +constexpr CLASS_ID CLSID_OBJECT_W_GLAUNCHER = xray::make_clsid("W_GLAUNC"); // Modifiers -constexpr CLASS_ID CLSID_OBJECT_M_QDAMAGE = MK_CLSID('O', '_', 'Q', 'D', 'M', 'G', ' ', ' '); -constexpr CLASS_ID CLSID_OBJECT_M_IMMORTAL = MK_CLSID('O', '_', 'I', 'M', 'M', 'O', 'R', 'T'); -constexpr CLASS_ID CLSID_OBJECT_M_INVIS = MK_CLSID('O', '_', 'I', 'N', 'V', 'I', 'S', ' '); +constexpr CLASS_ID CLSID_OBJECT_M_QDAMAGE = xray::make_clsid("O_QDMG "); +constexpr CLASS_ID CLSID_OBJECT_M_IMMORTAL = xray::make_clsid("O_IMMORT"); +constexpr CLASS_ID CLSID_OBJECT_M_INVIS = xray::make_clsid("O_INVIS "); -constexpr CLASS_ID CLSID_OBJECT_HEALTH = MK_CLSID('O', '_', 'H', 'E', 'A', 'L', 'T', 'H'); -constexpr CLASS_ID CLSID_OBJECT_ARMOR = MK_CLSID('O', '_', 'A', 'R', 'M', 'O', 'R', ' '); +constexpr CLASS_ID CLSID_OBJECT_HEALTH = xray::make_clsid("O_HEALTH"); +constexpr CLASS_ID CLSID_OBJECT_ARMOR = xray::make_clsid("O_ARMOR "); -constexpr CLASS_ID CLSID_OBJECT_TRIGGER = MK_CLSID('O', '_', 'T', 'R', 'I', 'G', 'E', 'R'); +constexpr CLASS_ID CLSID_OBJECT_TRIGGER = xray::make_clsid("O_TRIGER"); // Targets -constexpr CLASS_ID CLSID_TARGET = MK_CLSID('T', '_', 'B', 'A', 'S', 'E', ' ', ' '); -constexpr CLASS_ID CLSID_TARGET_ASSAULT = MK_CLSID('T', '_', 'A', 'S', 'S', ' ', ' ', ' '); -constexpr CLASS_ID CLSID_TARGET_CS_BASE = MK_CLSID('T', '_', 'C', 'S', 'B', 'A', 'S', 'E'); -constexpr CLASS_ID CLSID_TARGET_CS = MK_CLSID('T', '_', 'C', 'S', ' ', ' ', ' ', ' '); -constexpr CLASS_ID CLSID_TARGET_CS_CASK = MK_CLSID('T', '_', 'C', 'S', 'C', 'A', 'S', 'K'); +constexpr CLASS_ID CLSID_TARGET = xray::make_clsid("T_BASE "); +constexpr CLASS_ID CLSID_TARGET_ASSAULT = xray::make_clsid("T_ASS "); +constexpr CLASS_ID CLSID_TARGET_CS_BASE = xray::make_clsid("T_CSBASE"); +constexpr CLASS_ID CLSID_TARGET_CS = xray::make_clsid("T_CS "); +constexpr CLASS_ID CLSID_TARGET_CS_CASK = xray::make_clsid("T_CSCASK"); // Standard level object -constexpr CLASS_ID CLSID_OBJECT_ITEM_STD = MK_CLSID('O', '_', 'I', 'T', 'E', 'M', ' ', ' '); -constexpr CLASS_ID CLSID_OBJECT_BREAKABLE = MK_CLSID('O', '_', 'B', 'R', 'K', 'B', 'L', ' '); -constexpr CLASS_ID CLSID_OBJECT_CLIMABLE = MK_CLSID('O', '_', 'C', 'L', 'M', 'B', 'L', ' '); -constexpr CLASS_ID CLSID_OBJECT_HOLDER_ENT = MK_CLSID('O', '_', 'H', 'L', 'D', 'R', '_', 'E'); +constexpr CLASS_ID CLSID_OBJECT_ITEM_STD = xray::make_clsid("O_ITEM "); +constexpr CLASS_ID CLSID_OBJECT_BREAKABLE = xray::make_clsid("O_BRKBL "); +constexpr CLASS_ID CLSID_OBJECT_CLIMABLE = xray::make_clsid("O_CLMBL "); +constexpr CLASS_ID CLSID_OBJECT_HOLDER_ENT = xray::make_clsid("O_HLDR_E"); // -constexpr CLASS_ID CLSID_PH_SKELETON_OBJECT = MK_CLSID('P', '_', 'S', 'K', 'E', 'L', 'E', 'T'); -constexpr CLASS_ID CLSID_OBJECT_PHYSIC = MK_CLSID('O', '_', 'P', 'H', 'Y', 'S', 'I', 'C'); -constexpr CLASS_ID CLSID_PHYSICS_DESTROYABLE = MK_CLSID('P', '_', 'D', 'S', 'T', 'R', 'B', 'L'); -constexpr CLASS_ID CLSID_INVENTORY_BOX = MK_CLSID('O', '_', 'I', 'N', 'V', 'B', 'O', 'X'); +constexpr CLASS_ID CLSID_PH_SKELETON_OBJECT = xray::make_clsid("P_SKELET"); +constexpr CLASS_ID CLSID_OBJECT_PHYSIC = xray::make_clsid("O_PHYSIC"); +constexpr CLASS_ID CLSID_PHYSICS_DESTROYABLE = xray::make_clsid("P_DSTRBL"); +constexpr CLASS_ID CLSID_INVENTORY_BOX = xray::make_clsid("O_INVBOX"); // Zones -constexpr CLASS_ID CLSID_ZONE = MK_CLSID('Z', '_', 'Z', 'O', 'N', 'E', ' ', ' '); -constexpr CLASS_ID CLSID_Z_MBALD = MK_CLSID('Z', '_', 'M', 'B', 'A', 'L', 'D', ' '); -constexpr CLASS_ID CLSID_Z_MINCER = MK_CLSID('Z', '_', 'M', 'I', 'N', 'C', 'E', 'R'); -constexpr CLASS_ID CLSID_Z_ACIDF = MK_CLSID('Z', '_', 'A', 'C', 'I', 'D', 'F', ' '); -constexpr CLASS_ID CLSID_Z_GALANT = MK_CLSID('Z', '_', 'G', 'A', 'L', 'A', 'N', 'T'); -constexpr CLASS_ID CLSID_Z_RADIO = MK_CLSID('Z', '_', 'R', 'A', 'D', 'I', 'O', ' '); -constexpr CLASS_ID CLSID_Z_BFUZZ = MK_CLSID('Z', '_', 'B', 'F', 'U', 'Z', 'Z', ' '); -constexpr CLASS_ID CLSID_Z_RUSTYH = MK_CLSID('Z', '_', 'R', 'U', 'S', 'T', 'Y', 'H'); -constexpr CLASS_ID CLSID_Z_AMEBA = MK_CLSID('Z', '_', 'A', 'M', 'E', 'B', 'A', ' '); -constexpr CLASS_ID CLSID_Z_NOGRAVITY = MK_CLSID('Z', '_', 'N', 'O', 'G', 'R', 'A', 'V'); -constexpr CLASS_ID CLSID_Z_FRYUP = MK_CLSID('Z', '_', 'F', 'R', 'Y', 'U', 'P ', ' '); -constexpr CLASS_ID CLSID_Z_DEAD = MK_CLSID('Z', '_', 'D', 'E', 'A', 'D', ' ', ' '); +constexpr CLASS_ID CLSID_ZONE = xray::make_clsid("Z_ZONE "); +constexpr CLASS_ID CLSID_Z_MBALD = xray::make_clsid("Z_MBALD "); +constexpr CLASS_ID CLSID_Z_MINCER = xray::make_clsid("Z_MINCER"); +constexpr CLASS_ID CLSID_Z_ACIDF = xray::make_clsid("Z_ACIDF "); +constexpr CLASS_ID CLSID_Z_GALANT = xray::make_clsid("Z_GALANT"); +constexpr CLASS_ID CLSID_Z_RADIO = xray::make_clsid("Z_RADIO "); +constexpr CLASS_ID CLSID_Z_BFUZZ = xray::make_clsid("Z_BFUZZ "); +constexpr CLASS_ID CLSID_Z_RUSTYH = xray::make_clsid("Z_RUSTYH"); +constexpr CLASS_ID CLSID_Z_AMEBA = xray::make_clsid("Z_AMEBA "); +constexpr CLASS_ID CLSID_Z_NOGRAVITY = xray::make_clsid("Z_NOGRAV"); +constexpr CLASS_ID CLSID_Z_FRYUP = xray::make_clsid("Z_FRYUP "); +constexpr CLASS_ID CLSID_Z_DEAD = xray::make_clsid("Z_DEAD "); // Read more about this clsids in object_factory_register.cpp -constexpr CLASS_ID CLSID_LEVEL_CHANGER = MK_CLSID('L', 'V', 'L', 'C', 'H', 'N', 'G', 'R'); -constexpr CLASS_ID CLSID_LEVEL_CHANGER_S = MK_CLSID('L', 'V', 'L', '_', 'C', 'H', 'N', 'G'); +constexpr CLASS_ID CLSID_LEVEL_CHANGER = xray::make_clsid("LVLCHNGR"); +constexpr CLASS_ID CLSID_LEVEL_CHANGER_S = xray::make_clsid("LVL_CHNG"); -constexpr CLASS_ID CLSID_SCRIPT_ZONE = MK_CLSID('S', 'C', 'R', 'I', 'P', 'T', 'Z', 'N'); -constexpr CLASS_ID CLSID_Z_TEAM_BASE = MK_CLSID('Z', '_', 'T', 'E', 'A', 'M', 'B', 'S'); -constexpr CLASS_ID CLSID_Z_TORRID = MK_CLSID('Z', '_', 'T', 'O', 'R', 'R', 'I', 'D'); -constexpr CLASS_ID CLSID_SPACE_RESTRICTOR = MK_CLSID('S', 'P', 'A', 'C', 'E', '_', 'R', 'S'); -constexpr CLASS_ID CLSID_SMART_ZONE = MK_CLSID('S', 'M', 'R', 'T', 'Z', 'O', 'N', 'E'); -constexpr CLASS_ID CLSID_Z_CAMPFIRE = MK_CLSID('Z', '_', 'C', 'F', 'I', 'R', 'E', ' '); +constexpr CLASS_ID CLSID_SCRIPT_ZONE = xray::make_clsid("SCRIPTZN"); +constexpr CLASS_ID CLSID_Z_TEAM_BASE = xray::make_clsid("Z_TEAMBS"); +constexpr CLASS_ID CLSID_Z_TORRID = xray::make_clsid("Z_TORRID"); +constexpr CLASS_ID CLSID_SPACE_RESTRICTOR = xray::make_clsid("SPACE_RS"); +constexpr CLASS_ID CLSID_SMART_ZONE = xray::make_clsid("SMRTZONE"); +constexpr CLASS_ID CLSID_Z_CAMPFIRE = xray::make_clsid("Z_CFIRE "); // Detectors -constexpr CLASS_ID CLSID_DETECTOR_SIMPLE = MK_CLSID('D', '_', 'S', 'I', 'M', 'D', 'E', 'T'); -constexpr CLASS_ID CLSID_DETECTOR_VISUAL = MK_CLSID('D','_','V','I','S','D','E','T'); -constexpr CLASS_ID CLSID_DETECTOR_ADVANCED = MK_CLSID('D', '_', 'A', 'D', 'V', 'A', 'N', 'C'); -constexpr CLASS_ID CLSID_DETECTOR_ELITE = MK_CLSID('D', '_', 'E', 'L', 'I', 'T', 'E', ' '); -constexpr CLASS_ID CLSID_DETECTOR_SCIENTIFIC = MK_CLSID('D', '_', 'S', 'C', 'I', 'E', 'N', 'T'); +constexpr CLASS_ID CLSID_DETECTOR_SIMPLE = xray::make_clsid("D_SIMDET"); +constexpr CLASS_ID CLSID_DETECTOR_VISUAL = xray::make_clsid("D_VISDET"); +constexpr CLASS_ID CLSID_DETECTOR_ADVANCED = xray::make_clsid("D_ADVANC"); +constexpr CLASS_ID CLSID_DETECTOR_ELITE = xray::make_clsid("D_ELITE "); +constexpr CLASS_ID CLSID_DETECTOR_SCIENTIFIC = xray::make_clsid("D_SCIENT"); // PDA -constexpr CLASS_ID CLSID_DEVICE_PDA = MK_CLSID('D', '_', 'P', 'D', 'A', ' ', ' ', ' '); +constexpr CLASS_ID CLSID_DEVICE_PDA = xray::make_clsid("D_PDA "); // Devices -constexpr CLASS_ID CLSID_DEVICE_TORCH = MK_CLSID('D', '_', 'T', 'O', 'R', 'C', 'H', ' '); -constexpr CLASS_ID CLSID_DEVICE_AF_MERGER = MK_CLSID('D', '_', 'A', 'F', 'M', 'E', 'R', 'G'); -constexpr CLASS_ID CLSID_DEVICE_FLARE = MK_CLSID('D', '_', 'F', 'L', 'A', 'R', 'E', ' '); +constexpr CLASS_ID CLSID_DEVICE_TORCH = xray::make_clsid("D_TORCH "); +constexpr CLASS_ID CLSID_DEVICE_AF_MERGER = xray::make_clsid("D_AFMERG"); +constexpr CLASS_ID CLSID_DEVICE_FLARE = xray::make_clsid("D_FLARE "); // Inventory items -constexpr CLASS_ID CLSID_IITEM_BOLT = MK_CLSID('I', 'I', '_', 'B', 'O', 'L', 'T', ' '); +constexpr CLASS_ID CLSID_IITEM_BOLT = xray::make_clsid("II_BOLT "); -constexpr CLASS_ID CLSID_IITEM_MEDKIT = MK_CLSID('I', 'I', '_', 'M', 'E', 'D', 'K', 'I'); -constexpr CLASS_ID CLSID_IITEM_BANDAGE = MK_CLSID('I', 'I', '_', 'B', 'A', 'N', 'D', 'G'); -constexpr CLASS_ID CLSID_IITEM_FOOD = MK_CLSID('I', 'I', '_', 'F', 'O', 'O', 'D', ' '); -constexpr CLASS_ID CLSID_IITEM_BOTTLE = MK_CLSID('I', 'I', '_', 'B', 'O', 'T', 'T', 'L'); -constexpr CLASS_ID CLSID_IITEM_ANTIRAD = MK_CLSID('I', 'I', '_', 'A', 'N', 'T', 'I', 'R'); -constexpr CLASS_ID CLSID_IITEM_EXPLOSIVE = MK_CLSID('I', 'I', '_', 'E', 'X', 'P', 'L', 'O'); +constexpr CLASS_ID CLSID_IITEM_MEDKIT = xray::make_clsid("II_MEDKI"); +constexpr CLASS_ID CLSID_IITEM_BANDAGE = xray::make_clsid("II_BANDG"); +constexpr CLASS_ID CLSID_IITEM_FOOD = xray::make_clsid("II_FOOD "); +constexpr CLASS_ID CLSID_IITEM_BOTTLE = xray::make_clsid("II_BOTTL"); +constexpr CLASS_ID CLSID_IITEM_ANTIRAD = xray::make_clsid("II_ANTIR"); +constexpr CLASS_ID CLSID_IITEM_EXPLOSIVE = xray::make_clsid("II_EXPLO"); // Info Document -constexpr CLASS_ID CLSID_IITEM_DOCUMENT = MK_CLSID('I', 'I', '_', 'D', 'O', 'C', ' ', ' '); +constexpr CLASS_ID CLSID_IITEM_DOCUMENT = xray::make_clsid("II_DOC "); -constexpr CLASS_ID CLSID_IITEM_ATTACH = MK_CLSID('I', 'I', '_', 'A', 'T', 'T', 'C', 'H'); +constexpr CLASS_ID CLSID_IITEM_ATTACH = xray::make_clsid("II_ATTCH"); // Grenades -constexpr CLASS_ID CLSID_GRENADE_F1 = MK_CLSID('G', '_', 'F', '1', ' ', ' ', ' ', ' '); -constexpr CLASS_ID CLSID_OBJECT_G_RPG7 = MK_CLSID('G', '_', 'R', 'P', 'G', '7', ' ', ' '); -constexpr CLASS_ID CLSID_GRENADE_RGD5 = MK_CLSID('G', '_', 'R', 'G', 'D', '5', ' ', ' '); -constexpr CLASS_ID CLSID_OBJECT_G_FAKE = MK_CLSID('G', '_', 'F', 'A', 'K', 'E', ' ', ' '); +constexpr CLASS_ID CLSID_GRENADE_F1 = xray::make_clsid("G_F1 "); +constexpr CLASS_ID CLSID_OBJECT_G_RPG7 = xray::make_clsid("G_RPG7 "); +constexpr CLASS_ID CLSID_GRENADE_RGD5 = xray::make_clsid("G_RGD5 "); +constexpr CLASS_ID CLSID_OBJECT_G_FAKE = xray::make_clsid("G_FAKE "); //--------------------------------------------------------------------------------- -constexpr CLASS_ID CLSID_OBJECT_PLAYERS_BAG = MK_CLSID('M', 'P', '_', 'P', 'L', 'B', 'A', 'G'); +constexpr CLASS_ID CLSID_OBJECT_PLAYERS_BAG = xray::make_clsid("MP_PLBAG"); //--------------------------------------------------------------------------------- // Equipment -constexpr CLASS_ID CLSID_EQUIPMENT_SIMPLE = MK_CLSID('E', 'Q', 'U', '_', 'S', 'M', 'P', 'L'); -constexpr CLASS_ID CLSID_EQUIPMENT_SCIENTIFIC = MK_CLSID('E', 'Q', 'U', '_', 'S', 'C', 'I', 'E'); -constexpr CLASS_ID CLSID_EQUIPMENT_STALKER = MK_CLSID('E', 'Q', 'U', '_', 'S', 'T', 'L', 'K'); -constexpr CLASS_ID CLSID_EQUIPMENT_MILITARY = MK_CLSID('E', 'Q', 'U', '_', 'M', 'L', 'T', 'R'); -constexpr CLASS_ID CLSID_EQUIPMENT_EXO = MK_CLSID('E', 'Q', 'U', '_', 'E', 'X', 'O', ' '); -constexpr CLASS_ID CLSID_EQUIPMENT_HELMET = MK_CLSID('E', 'Q', '_', 'H', 'L', 'M', 'E', 'T'); -constexpr CLASS_ID CLSID_EQUIPMENT_BACKPACK = MK_CLSID('E', 'Q', '_', 'B', 'A', 'K', 'P', 'K'); +constexpr CLASS_ID CLSID_EQUIPMENT_SIMPLE = xray::make_clsid("EQU_SMPL"); +constexpr CLASS_ID CLSID_EQUIPMENT_SCIENTIFIC = xray::make_clsid("EQU_SCIE"); +constexpr CLASS_ID CLSID_EQUIPMENT_STALKER = xray::make_clsid("EQU_STLK"); +constexpr CLASS_ID CLSID_EQUIPMENT_MILITARY = xray::make_clsid("EQU_MLTR"); +constexpr CLASS_ID CLSID_EQUIPMENT_EXO = xray::make_clsid("EQU_EXO "); +constexpr CLASS_ID CLSID_EQUIPMENT_HELMET = xray::make_clsid("EQ_HLMET"); +constexpr CLASS_ID CLSID_EQUIPMENT_BACKPACK = xray::make_clsid("EQ_BAKPK"); // Game types -constexpr CLASS_ID CLSID_SV_GAME_SINGLE = MK_CLSID('S', 'V', '_', 'S', 'I', 'N', 'G', 'L'); -constexpr CLASS_ID CLSID_SV_GAME_DEATHMATCH = MK_CLSID('S', 'V', '_', 'D', 'M', ' ', ' ', ' '); -constexpr CLASS_ID CLSID_SV_GAME_TEAMDEATHMATCH = MK_CLSID('S', 'V', '_', 'T', 'D', 'M', ' ', ' '); -constexpr CLASS_ID CLSID_SV_GAME_ARTEFACTHUNT = MK_CLSID('S', 'V', '_', 'A', 'H', 'U', 'N', 'T'); -constexpr CLASS_ID CLSID_SV_GAME_CAPTURETHEARTEFACT = MK_CLSID('S', 'V', '_', 'C', 'T', 'A', ' ', ' '); -//constexpr CLASS_ID CLSID_GAME_CS = MK_CLSID('S','V','_','C','S',' ',' ',' '); -constexpr CLASS_ID CLSID_CL_GAME_SINGLE = MK_CLSID('C', 'L', '_', 'S', 'I', 'N', 'G', 'L'); -constexpr CLASS_ID CLSID_CL_GAME_DEATHMATCH = MK_CLSID('C', 'L', '_', 'D', 'M', ' ', ' ', ' '); -constexpr CLASS_ID CLSID_CL_GAME_TEAMDEATHMATCH = MK_CLSID('C', 'L', '_', 'T', 'D', 'M', ' ', ' '); -constexpr CLASS_ID CLSID_CL_GAME_ARTEFACTHUNT = MK_CLSID('C', 'L', '_', 'A', 'H', 'U', 'N', 'T'); -constexpr CLASS_ID CLSID_CL_GAME_CAPTURETHEARTEFACT = MK_CLSID('C', 'L', '_', 'C', 'T', 'A', ' ', ' '); +constexpr CLASS_ID CLSID_SV_GAME_SINGLE = xray::make_clsid("SV_SINGL"); +constexpr CLASS_ID CLSID_SV_GAME_DEATHMATCH = xray::make_clsid("SV_DM "); +constexpr CLASS_ID CLSID_SV_GAME_TEAMDEATHMATCH = xray::make_clsid("SV_TDM "); +constexpr CLASS_ID CLSID_SV_GAME_ARTEFACTHUNT = xray::make_clsid("SV_AHUNT"); +constexpr CLASS_ID CLSID_SV_GAME_CAPTURETHEARTEFACT = xray::make_clsid("SV_CTA "); +//constexpr CLASS_ID CLSID_GAME_CS = xray::make_clsid("SV_CS "); +constexpr CLASS_ID CLSID_CL_GAME_SINGLE = xray::make_clsid("CL_SINGL"); +constexpr CLASS_ID CLSID_CL_GAME_DEATHMATCH = xray::make_clsid("CL_DM "); +constexpr CLASS_ID CLSID_CL_GAME_TEAMDEATHMATCH = xray::make_clsid("CL_TDM "); +constexpr CLASS_ID CLSID_CL_GAME_ARTEFACTHUNT = xray::make_clsid("CL_AHUNT"); +constexpr CLASS_ID CLSID_CL_GAME_CAPTURETHEARTEFACT = xray::make_clsid("CL_CTA "); // Game UI types -constexpr CLASS_ID CLSID_GAME_UI_SINGLE = MK_CLSID('U', 'I', '_', 'S', 'I', 'N', 'G', 'L'); -constexpr CLASS_ID CLSID_GAME_UI_DEATHMATCH = MK_CLSID('U', 'I', '_', 'D', 'M', ' ', ' ', ' '); -constexpr CLASS_ID CLSID_GAME_UI_TEAMDEATHMATCH = MK_CLSID('U', 'I', '_', 'T', 'D', 'M', ' ', ' '); -constexpr CLASS_ID CLSID_GAME_UI_ARTEFACTHUNT = MK_CLSID('U', 'I', '_', 'A', 'H', 'U', 'N', 'T'); -constexpr CLASS_ID CLSID_GAME_UI_CAPTURETHEARTEFACT = MK_CLSID('U', 'I', '_', 'C', 'T', 'A', ' ', ' '); +constexpr CLASS_ID CLSID_GAME_UI_SINGLE = xray::make_clsid("UI_SINGL"); +constexpr CLASS_ID CLSID_GAME_UI_DEATHMATCH = xray::make_clsid("UI_DM "); +constexpr CLASS_ID CLSID_GAME_UI_TEAMDEATHMATCH = xray::make_clsid("UI_TDM "); +constexpr CLASS_ID CLSID_GAME_UI_ARTEFACTHUNT = xray::make_clsid("UI_AHUNT"); +constexpr CLASS_ID CLSID_GAME_UI_CAPTURETHEARTEFACT = xray::make_clsid("UI_CTA "); -constexpr CLASS_ID CLSID_ONLINE_OFFLINE_GROUP = MK_CLSID('O', 'N', '_', 'O', 'F', 'F', '_', 'G'); +constexpr CLASS_ID CLSID_ONLINE_OFFLINE_GROUP = xray::make_clsid("ON_OFF_G"); diff --git a/src/xrServerEntities/object_factory.h b/src/xrServerEntities/object_factory.h index 3cff55cec54..5ce57a6fad3 100644 --- a/src/xrServerEntities/object_factory.h +++ b/src/xrServerEntities/object_factory.h @@ -8,10 +8,15 @@ #pragma once +#include "xrEngine/editor_base.h" + #include "object_item_abstract.h" -#include "xrServer_Objects.h" +#include "object_factory_spawner.h" class CObjectFactory +#ifndef MASTER_GOLD + : public xray::editor::ide_tool +#endif { public: using ClientObjectBaseClass = ObjectFactory::ClientObjectBaseClass; @@ -78,6 +83,22 @@ class CObjectFactory void register_script_class(LPCSTR client_class, LPCSTR server_class, LPCSTR clsid, LPCSTR script_clsid); void register_script_class(LPCSTR unknown_class, LPCSTR clsid, LPCSTR script_clsid); void register_script_classes(); + +#ifndef MASTER_GOLD +public: + void on_tool_frame() override; + void init_spawn_data(); + +private: + pcstr tool_name() const override { return "Spawner"; } + + static constexpr auto CATEGORIES_COUNT = static_cast(xray::SpawnCategory::CategoriesCount); + + std::array m_spawner_sections; +#endif + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; extern CObjectFactory* g_object_factory; diff --git a/src/xrServerEntities/object_factory_inline.h b/src/xrServerEntities/object_factory_inline.h index f5af6298f1d..25fdf3a9018 100644 --- a/src/xrServerEntities/object_factory_inline.h +++ b/src/xrServerEntities/object_factory_inline.h @@ -93,6 +93,7 @@ IC void CObjectFactory::add(CObjectItemAbstract* item) { const_iterator I; +#ifdef DEBUG I = std::find_if(clsids().begin(), clsids().end(), CObjectItemPredicateCLSID(item->clsid())); if (I != clsids().end()) { @@ -101,7 +102,6 @@ IC void CObjectFactory::add(CObjectItemAbstract* item) VERIFY2(0, make_string("clsid is duplicated : %s", temp)); } -#ifndef NO_XR_GAME I = std::find_if(clsids().begin(), clsids().end(), CObjectItemPredicateScript(item->script_clsid())); VERIFY(I == clsids().end()); #endif diff --git a/src/xrServerEntities/object_factory_register.cpp b/src/xrServerEntities/object_factory_register.cpp index 385d772e180..84975ba15f8 100644 --- a/src/xrServerEntities/object_factory_register.cpp +++ b/src/xrServerEntities/object_factory_register.cpp @@ -17,7 +17,6 @@ #include "clsid_game.h" // client entities includes -#ifndef NO_XR_GAME #include "Actor.h" #include "Spectator.h" @@ -176,20 +175,16 @@ #include "actor_mp_server.h" #include "actor_mp_client.h" #include "smart_cover_object.h" -#endif // NO_XR_GAME -#ifndef NO_XR_GAME #define ADD(a, b, c, d) add(c, d) #define ADD_MP(a, b, c, d, e, f) add(xr_new>(e, f)) -#else -#define ADD(a, b, c, d) add(c, d) -#endif void CObjectFactory::register_classes() { + using namespace xray; + ZoneScoped; -#ifndef NO_XR_GAME // Server Game type add(CLSID_SV_GAME_SINGLE, "game_sv_single"); add(CLSID_SV_GAME_DEATHMATCH, "game_sv_deathmatch"); @@ -208,16 +203,11 @@ void CObjectFactory::register_classes() add(CLSID_GAME_UI_TEAMDEATHMATCH, "game_ui_team_deathmatch"); add(CLSID_GAME_UI_ARTEFACTHUNT, "game_ui_artefact_hunt"); add(CLSID_GAME_UI_CAPTURETHEARTEFACT, "game_ui_capture_the_artefact"); -#endif // NO_XR_GAME -#ifndef NO_XR_GAME - if (!ShadowOfChernobylMode) - ADD_MP(CActor, CActorMP, CSE_ALifeCreatureActor, CSE_ActorMP, CLSID_OBJECT_ACTOR, "actor"); - else -#endif - { + if (ShadowOfChernobylMode) ADD(CActor, CSE_ALifeCreatureActor, CLSID_OBJECT_ACTOR, "actor"); - } + else + ADD_MP(CActor, CActorMP, CSE_ALifeCreatureActor, CSE_ActorMP, CLSID_OBJECT_ACTOR, "actor"); // server entities add>(CLSID_AI_FLESH_GROUP, "flesh_group"); @@ -352,18 +342,14 @@ void CObjectFactory::register_classes() ADD(CHairsZone, CSE_ALifeZoneVisual, CLSID_Z_BFUZZ, "zone_bfuzz"); ADD(CHairsZone, CSE_ALifeZoneVisual, CLSID_Z_RUSTYH, "zone_rusty_hair"); ADD(CMosquitoBald, CSE_ALifeAnomalousZone, CLSID_Z_DEAD, "zone_dead"); + // We can't register both, since CLSID_LEVEL_CHANGER_S is created in COP scripts as "level_changer_s" // But in SOC scripts CLSID_LEVEL_CHANGER_S may be used as "level_changer" -#ifndef NO_XR_GAME if (ShadowOfChernobylMode) - { ADD(CLevelChanger, CSE_ALifeLevelChanger, CLSID_LEVEL_CHANGER_S, "level_changer"); - } else -#endif // NO_XR_GAME - { ADD(CLevelChanger, CSE_ALifeLevelChanger, CLSID_LEVEL_CHANGER, "level_changer"); - } + ADD(CScriptZone, CSE_ALifeSpaceRestrictor, CLSID_SCRIPT_ZONE, "script_zone"); ADD(CSmartZone, CSE_ALifeSmartZone, CLSID_SMART_ZONE, "smart_zone"); ADD(CTeamBaseZone, CSE_ALifeTeamBaseZone, CLSID_Z_TEAM_BASE, "team_base_zone"); @@ -399,9 +385,8 @@ void CObjectFactory::register_classes() ADD(CHolderEntityObject, CSE_ALifeDynamicObjectVisual, CLSID_OBJECT_HOLDER_ENT, "obj_holder_ent"); ADD(CInventoryBox, CSE_ALifeInventoryBox, CLSID_INVENTORY_BOX, "inventory_box"); - ADD(smart_cover::object, CSE_SmartCover, TEXT2CLSID("SMRTCOVR"), "smart_cover"); + ADD(smart_cover::object, CSE_SmartCover, make_clsid("SMRTCOVR"), "smart_cover"); -#ifndef NO_XR_GAME // hack, for dedicated server only // because we do not have scripts // and script functionality is not @@ -409,36 +394,35 @@ void CObjectFactory::register_classes() if (!GEnv.isDedicatedServer) return; - ADD(CElectricBall, CSE_ALifeItemArtefact, TEXT2CLSID("SCRPTART"), "artefact_s"); - // ADD(CtaGameArtefact ,CSE_ALifeItemArtefact ,TEXT2CLSID("AF_CTA") ,"ctaartefact_s"); - ADD(CTorch, CSE_ALifeItemTorch, TEXT2CLSID("TORCH_S"), "device_torch_s"); - ADD(CHangingLamp, CSE_ALifeObjectHangingLamp, TEXT2CLSID("SO_HLAMP"), "hlamp_s"); - ADD(CStalkerOutfit, CSE_ALifeItemCustomOutfit, TEXT2CLSID("E_STLK"), "equ_stalker_s"); - ADD(CScope, CSE_ALifeItem, TEXT2CLSID("WP_SCOPE"), "wpn_scope_s"); - ADD(CWeaponAK74, CSE_ALifeItemWeaponMagazinedWGL, TEXT2CLSID("WP_AK74"), "wpn_ak74_s"); - ADD(CWeaponLR300, CSE_ALifeItemWeaponMagazined, TEXT2CLSID("WP_LR300"), "wpn_lr300_s"); - ADD(CWeaponBinoculars, CSE_ALifeItemWeaponMagazined, TEXT2CLSID("WP_BINOC"), "wpn_binocular_s"); - ADD(CWeaponBM16, CSE_ALifeItemWeaponShotGun, TEXT2CLSID("WP_BM16"), "wpn_bm16_s"); - ADD(CWeaponGroza, CSE_ALifeItemWeaponMagazinedWGL, TEXT2CLSID("WP_GROZA"), "wpn_groza_s"); - ADD(CWeaponSVD, CSE_ALifeItemWeaponMagazined, TEXT2CLSID("WP_SVD"), "wpn_svd_s"); - ADD(CWeaponHPSA, CSE_ALifeItemWeaponMagazined, TEXT2CLSID("WP_HPSA"), "wpn_hpsa_s"); - ADD(CWeaponKnife, CSE_ALifeItemWeapon, TEXT2CLSID("WP_KNIFE"), "wpn_knife_s"); - ADD(CWeaponPM, CSE_ALifeItemWeaponMagazined, TEXT2CLSID("WP_PM"), "wpn_pm_s"); - ADD(CWeaponRG6, CSE_ALifeItemWeaponShotGun, TEXT2CLSID("WP_RG6"), "wpn_rg6_s"); - ADD(CWeaponRPG7, CSE_ALifeItemWeaponMagazined, TEXT2CLSID("WP_RPG7"), "wpn_rpg7_s"); - ADD(CWeaponShotgun, CSE_ALifeItemWeaponShotGun, TEXT2CLSID("WP_SHOTG"), "wpn_shotgun_s"); - ADD(CWeaponSVU, CSE_ALifeItemWeaponMagazined, TEXT2CLSID("WP_SVU"), "wpn_svu_s"); - ADD(CWeaponUSP45, CSE_ALifeItemWeaponMagazined, TEXT2CLSID("WP_USP45"), "wpn_usp45_s"); - ADD(CWeaponVal, CSE_ALifeItemWeaponMagazined, TEXT2CLSID("WP_VAL"), "wpn_val_s"); - ADD(CWeaponVintorez, CSE_ALifeItemWeaponMagazined, TEXT2CLSID("WP_VINT"), "wpn_vintorez_s"); - ADD(CWeaponWalther, CSE_ALifeItemWeaponMagazined, TEXT2CLSID("WP_WALTH"), "wpn_walther_s"); - ADD(CHairsZone, CSE_ALifeZoneVisual, TEXT2CLSID("ZS_BFUZZ"), "zone_bfuzz_s"); - ADD(CMosquitoBald, CSE_ALifeAnomalousZone, TEXT2CLSID("ZS_MBALD"), "zone_mbald_s"); - ADD(CMincer, CSE_ALifeAnomalousZone, TEXT2CLSID("ZS_GALAN"), "zone_galant_s"); - ADD(CMincer, CSE_ALifeAnomalousZone, TEXT2CLSID("ZS_MINCE"), "zone_mincer_s"); - ADD(CAmebaZone, CSE_ALifeZoneVisual , TEXT2CLSID("ZS_AMEBA"), "zone_ameba_s"); - ADD(CRadioactiveZone, CSE_ALifeAnomalousZone, TEXT2CLSID("ZS_RADIO"), "zone_radio_s"); - ADD(CNoGravityZone, CSE_ALifeAnomalousZone, TEXT2CLSID("ZS_NGRAV"), "zone_nograv_s"); - ADD(CSpaceRestrictor, CSE_ALifeSpaceRestrictor, TEXT2CLSID("SPC_RS_S"), "script_restr"); -#endif // NO_XR_GAME + ADD(CElectricBall, CSE_ALifeItemArtefact, make_clsid("SCRPTART"), "artefact_s"); + // ADD(CtaGameArtefact, CSE_ALifeItemArtefact, make_clsid("AF_CTA "), "ctaartefact_s"); + ADD(CTorch, CSE_ALifeItemTorch, make_clsid("TORCH_S "), "device_torch_s"); + ADD(CHangingLamp, CSE_ALifeObjectHangingLamp, make_clsid("SO_HLAMP"), "hlamp_s"); + ADD(CStalkerOutfit, CSE_ALifeItemCustomOutfit, make_clsid("E_STLK "), "equ_stalker_s"); + ADD(CScope, CSE_ALifeItem, make_clsid("WP_SCOPE"), "wpn_scope_s"); + ADD(CWeaponAK74, CSE_ALifeItemWeaponMagazinedWGL, make_clsid("WP_AK74 "), "wpn_ak74_s"); + ADD(CWeaponLR300, CSE_ALifeItemWeaponMagazined, make_clsid("WP_LR300"), "wpn_lr300_s"); + ADD(CWeaponBinoculars, CSE_ALifeItemWeaponMagazined, make_clsid("WP_BINOC"), "wpn_binocular_s"); + ADD(CWeaponBM16, CSE_ALifeItemWeaponShotGun, make_clsid("WP_BM16 "), "wpn_bm16_s"); + ADD(CWeaponGroza, CSE_ALifeItemWeaponMagazinedWGL, make_clsid("WP_GROZA"), "wpn_groza_s"); + ADD(CWeaponSVD, CSE_ALifeItemWeaponMagazined, make_clsid("WP_SVD "), "wpn_svd_s"); + ADD(CWeaponHPSA, CSE_ALifeItemWeaponMagazined, make_clsid("WP_HPSA "), "wpn_hpsa_s"); + ADD(CWeaponKnife, CSE_ALifeItemWeapon, make_clsid("WP_KNIFE"), "wpn_knife_s"); + ADD(CWeaponPM, CSE_ALifeItemWeaponMagazined, make_clsid("WP_PM "), "wpn_pm_s"); + ADD(CWeaponRG6, CSE_ALifeItemWeaponShotGun, make_clsid("WP_RG6 "), "wpn_rg6_s"); + ADD(CWeaponRPG7, CSE_ALifeItemWeaponMagazined, make_clsid("WP_RPG7 "), "wpn_rpg7_s"); + ADD(CWeaponShotgun, CSE_ALifeItemWeaponShotGun, make_clsid("WP_SHOTG"), "wpn_shotgun_s"); + ADD(CWeaponSVU, CSE_ALifeItemWeaponMagazined, make_clsid("WP_SVU "), "wpn_svu_s"); + ADD(CWeaponUSP45, CSE_ALifeItemWeaponMagazined, make_clsid("WP_USP45"), "wpn_usp45_s"); + ADD(CWeaponVal, CSE_ALifeItemWeaponMagazined, make_clsid("WP_VAL "), "wpn_val_s"); + ADD(CWeaponVintorez, CSE_ALifeItemWeaponMagazined, make_clsid("WP_VINT "), "wpn_vintorez_s"); + ADD(CWeaponWalther, CSE_ALifeItemWeaponMagazined, make_clsid("WP_WALTH"), "wpn_walther_s"); + ADD(CHairsZone, CSE_ALifeZoneVisual, make_clsid("ZS_BFUZZ"), "zone_bfuzz_s"); + ADD(CMosquitoBald, CSE_ALifeAnomalousZone, make_clsid("ZS_MBALD"), "zone_mbald_s"); + ADD(CMincer, CSE_ALifeAnomalousZone, make_clsid("ZS_GALAN"), "zone_galant_s"); + ADD(CMincer, CSE_ALifeAnomalousZone, make_clsid("ZS_MINCE"), "zone_mincer_s"); + ADD(CAmebaZone, CSE_ALifeZoneVisual , make_clsid("ZS_AMEBA"), "zone_ameba_s"); + ADD(CRadioactiveZone, CSE_ALifeAnomalousZone, make_clsid("ZS_RADIO"), "zone_radio_s"); + ADD(CNoGravityZone, CSE_ALifeAnomalousZone, make_clsid("ZS_NGRAV"), "zone_nograv_s"); + ADD(CSpaceRestrictor, CSE_ALifeSpaceRestrictor, make_clsid("SPC_RS_S"), "script_restr"); } diff --git a/src/xrServerEntities/object_factory_script.cpp b/src/xrServerEntities/object_factory_script.cpp index 82f0f5e22e4..8ba708028c9 100644 --- a/src/xrServerEntities/object_factory_script.cpp +++ b/src/xrServerEntities/object_factory_script.cpp @@ -7,11 +7,12 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "object_factory.h" +#include "object_item_script.h" #include "ai_space.h" + #include "xrScriptEngine/script_engine.hpp" -#include "object_item_script.h" -#include "xrScriptEngine/ScriptExporter.hpp" void CObjectFactory::register_script_class(LPCSTR client_class, LPCSTR server_class, LPCSTR clsid, LPCSTR script_clsid) { @@ -79,7 +80,7 @@ void CObjectFactory::register_script() const luabind::module(GEnv.ScriptEngine->lua())[instance]; } -SCRIPT_EXPORT(CObjectFactory, (), +void CObjectFactory::script_register(lua_State* luaState) { using namespace luabind; @@ -91,4 +92,4 @@ SCRIPT_EXPORT(CObjectFactory, (), .def("register", (void (CObjectFactory::*)(LPCSTR, LPCSTR, LPCSTR))( &CObjectFactory::register_script_class)) ]; -}); +} diff --git a/src/xrServerEntities/object_factory_space.h b/src/xrServerEntities/object_factory_space.h index b72596a77fd..9f915c20a82 100644 --- a/src/xrServerEntities/object_factory_space.h +++ b/src/xrServerEntities/object_factory_space.h @@ -8,10 +8,6 @@ #pragma once -#ifndef XRGAME_EXPORTS -#define NO_XR_GAME -#endif - class IFactoryObject; class CSE_Abstract; diff --git a/src/xrServerEntities/object_factory_spawner.cpp b/src/xrServerEntities/object_factory_spawner.cpp new file mode 100644 index 00000000000..834c2f08c23 --- /dev/null +++ b/src/xrServerEntities/object_factory_spawner.cpp @@ -0,0 +1,579 @@ +#include "StdAfx.h" + + +#ifndef MASTER_GOLD +#include "xrEngine/editor_helper.h" + +#include "object_factory.h" +#include "object_factory_spawner.h" + +#include "alife_smart_terrain_registry.h" + +extern CSE_Abstract* CALifeSimulator__spawn_item2(CALifeSimulator* self, + pcstr section, const Fvector& position, u32 level_vertex_id, + GameGraph::_GRAPH_ID game_vertex_id, ALife::_OBJECT_ID id_parent); + +void CObjectFactory::init_spawn_data() +{ + using namespace xray; + + for (CInifile::Sect* section : pSettings->sections()) + { + const auto& name = section->Name; + if (name.empty()) + continue; + + if (!section->line_exist("class")) + continue; + + const auto clsid = pSettings->r_clsid(name, "class"); + if (!item(clsid, true)) + continue; + + const auto kind = pSettings->read_if_exists(name, "kind", nullptr); + const auto wpclass = pSettings->read_if_exists(name, "weapon_class", nullptr); + + SpawnCategory category = try_detect_spawn_category(kind, wpclass, clsid); + + if (category >= SpawnCategory::Artefacts && category <= SpawnCategory::WeaponsMiscellaneous) + { + const auto width = pSettings->read_if_exists(name, "inv_grid_width", 0); + const auto height = pSettings->read_if_exists(name, "inv_grid_height", 0); + + if (width == 0 && height == 0) // ban fake items + category = SpawnCategory::Unknown; + else if (pSettings->read_if_exists(name, "quest_item", false)) + category = SpawnCategory::ItemsQuest; + } + + if (category >= SpawnCategory::WeaponsAmmo && category <= SpawnCategory::WeaponsExplosives) + { + cpcstr parent_section = pSettings->read_if_exists(name, "parent_section", name.c_str()); + if (parent_section != name) + category = SpawnCategory::Unknown; + } + else if (category == SpawnCategory::SquadsStalkers) + { + category = SpawnCategory::Unknown; + + xr_string temp; + cpcstr npc = pSettings->read_if_exists(name, "npc", nullptr); + cpcstr npc_random = pSettings->read_if_exists(name, "npc_random", ""); + _GetItem(npc ? npc : npc_random, 0, temp); + + if (!temp.empty()) + { + const auto npc_clsid = pSettings->r_clsid(temp.c_str(), "class"); + const auto npc_kind = pSettings->read_if_exists(temp.c_str(), "kind", nullptr); + const auto npc_category = try_detect_spawn_category(npc_kind, nullptr, npc_clsid); + + if (npc_category == SpawnCategory::CreaturesStalkers) + category = SpawnCategory::SquadsStalkers; + else if (npc_category == SpawnCategory::CreaturesMutants) + category = SpawnCategory::SquadsMutants; + } + } + else if (category == SpawnCategory::Vehicles || category == SpawnCategory::Physics) + { + if (!section->line_exist("visual")) + category = SpawnCategory::Unknown; + } + + if (category == SpawnCategory::Unknown) + continue; + + m_spawner_sections[static_cast(category)].emplace_back(section); + } +} + +static void print_ini_values(const CInifile::Sect* section, std::initializer_list list_of_interest = {}) +{ + if (ImGui::BeginTable("section values", 3)) + { + for (cpcstr name : list_of_interest) + { + if (!pSettings->line_exist(section->Name, name)) + continue; + ImGui::TableNextRow(); + ImGui::TableSetColumnIndex(0); + ImGui::Text("%s", name); + ImGui::TableSetColumnIndex(1); + ImGui::Text("="); + ImGui::TableSetColumnIndex(2); + cpcstr value = pSettings->r_string(section->Name, name); + ImGui::Text("%s", value ? value : ""); + } + if (std::empty(list_of_interest)) + { + for (const auto& [name, value] : section->Data) + { + ImGui::TableNextRow(); + ImGui::TableSetColumnIndex(0); + ImGui::Text("%s", name.c_str()); + ImGui::TableSetColumnIndex(1); + ImGui::Text("="); + ImGui::TableSetColumnIndex(2); + ImGui::Text("%s", !value.empty() ? value.c_str() : ""); + } + } + ImGui::EndTable(); + } +} + +static void print_npc(const CInifile::Sect* section) +{ + print_ini_values(section, + { + "$spawn", + "character_profile", + "spec_rank", + "community", + "story_id", + "custom_data", + }); +} + +static void print_sim_squad_scripted(const CInifile::Sect* section) +{ + print_ini_values(section, + { + "faction", + "behaviour", + "common", + "relationship", + "sympathy", + "invulnerability", + "spawn_point", + "target_smart", + "target_random_smart", + "on_death", + "item_on_all", + "rush", + "idle_time", + "show_spot", + "always_walk", + "always_arrived", + "npc_in_squad", + "npc", + "npc_random", + "story_id", + }); +} + +void CObjectFactory::on_tool_frame() +{ + using namespace xray; + + if (!get_open_state()) + return; + + if (!ImGui::Begin(tool_name(), &get_open_state(), get_default_window_flags() & ~ImGuiWindowFlags_MenuBar)) + { + ImGui::End(); + return; + } + + enum class Spawn : u8 + { + NearActor, + ToInventory, + OnSmart, + }; + + pcstr spawn_section{}; + + static auto spawn_category{ SpawnCategory::Artefacts }; + static int spawn_amount{ 1 }; + static Spawn where_to_spawn{ Spawn::NearActor }; + + static const GameGraph::SLevel* selected_level{}; + static const CSE_ALifeSmartZone* selected_smart{}; + + auto window_size = ImGui::GetContentRegionAvail(); + ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar; + ImGuiChildFlags child_flags = ImGuiChildFlags_AlwaysUseWindowPadding | ImGuiChildFlags_NavFlattened; + + // 1. Display available items categories + if (ImGui::BeginChild("Spawn categories", { 0, window_size.y }, child_flags | ImGuiChildFlags_AutoResizeX, window_flags)) + { + if (ImGui::BeginMenuBar()) + { + ImGui::Text("Spawn categories"); + ImGui::EndMenuBar(); + } + + for (u8 i = 0; i < CATEGORIES_COUNT; ++i) + { + if (m_spawner_sections[i].empty()) + continue; + + const auto category = static_cast(i); + + cpcstr name = spawn_category_to_text(category); + + if (ImGui::Selectable(name, category == spawn_category)) + spawn_category = category; + } + } + window_size = ImGui::GetWindowSize(); // order dependent, don't move this line anywhere + ImGui::EndChild(); + ImGui::SameLine(); + + window_size.x = std::max(window_size.x, ImGui::GetContentRegionAvail().x / 3.0f); + + const auto& sections = m_spawner_sections[u8(spawn_category)]; + + // 2. Display the list of items available for spawning + if (ImGui::BeginChild("Sections list", window_size, child_flags, window_flags)) + { + enum DisplayMode : int + { + DisplayGameNames, + DisplayLTXSections, + }; + static int display_mode = DisplayLTXSections; + + if (ImGui::BeginMenuBar()) + { + ImGui::Text("Available: %zu", sections.size()); + + constexpr pcstr styles[] = + { + "Game", + "LTX" + }; + + ImGui::SetNextItemWidth(ImGui::CalcTextSize(" Game ").x); // shrink to minimal + ImGui::SliderInt("", &display_mode, 0, std::size(styles) - 1, styles[display_mode], ImGuiSliderFlags_NoInput); + if (ImGui::IsItemDeactivated() && !ImGui::IsItemDeactivatedAfterEdit()) + { + display_mode = !display_mode; + } + + imgui::ItemHelp("Left-click on the item in this list to spawn it.\n" + "You can also select between displaying game names or ltx sections by using a switch."); + ImGui::EndMenuBar(); + } + + for (const CInifile::Sect* section : sections) + { + xr_string name; + switch (static_cast(display_mode)) + { + case DisplayGameNames: + { + const std::locale locale(""); + if (cpcstr inv_name = pSettings->read_if_exists(section->Name.c_str(), "inv_name", nullptr)) + { + const auto translated = StringTable().translate(inv_name); + name = StringToUTF8(translated.c_str(), locale); + break; + } + if (cpcstr character_profile = pSettings->read_if_exists(section->Name.c_str(), "character_profile", nullptr)) + { + if (CSpecificCharacter::GetById(character_profile, true)) + { + CSpecificCharacter character; + character.Load(character_profile); + cpcstr character_name = character.Name(); + if (character_name[0] && !strstr(character_name, "GENERATE_NAME")) + { + const auto translated = StringTable().translate(character_name); + name = StringToUTF8(translated.c_str(), locale); + break; + } + } + } + [[fallthrough]]; + } + default: + case DisplayLTXSections: + name = section->Name.c_str(); + break; + } // switch (static_cast(display_mode)) + + ImGui::PushID(section->Name.c_str()); + if (ImGui::Button(name.c_str())) + spawn_section = section->Name.c_str(); + ImGui::PopID(); + + ImGui::SetNextWindowSizeConstraints({}, { 600.f, 738.f }); + if (ImGui::BeginPopupContextItem()) + { + ImGui::Text("[%s]", section->Name.c_str()); + print_ini_values(section); + ImGui::EndPopup(); + } + + ImGui::SetNextWindowSizeConstraints({}, { 600.f, 738.f }); + if (ImGui::BeginItemTooltip()) + { + ImGui::Text("[%s]", section->Name.c_str()); + + switch (spawn_category) + { + case SpawnCategory::CreaturesStalkers: + case SpawnCategory::CreaturesMutants: + print_npc(section); + break; + case SpawnCategory::SquadsStalkers: + case SpawnCategory::SquadsMutants: + print_sim_squad_scripted(section); + break; + } // switch (spawn_category) + + ImGui::BeginDisabled(); + ImGui::Spacing(); + ImGui::Spacing(); + ImGui::Text("Right-click to see all config values."); + ImGui::EndDisabled(); + ImGui::EndTooltip(); + } + } + } + ImGui::EndChild(); + ImGui::SameLine(); + window_size = ImGui::GetContentRegionAvail(); + + // 3. Display spawn options + if (ImGui::BeginChild("Spawn", window_size, child_flags, window_flags)) + { + // 3.1. Draw the header options + if (ImGui::BeginMenuBar()) + { + ImGui::Text("Spawn"); + + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 12.f); + + ImGui::SetNextItemWidth(ImGui::CalcTextSize("100").x); // shrink to minimal + ImGui::DragInt("", &spawn_amount, 0.5f, 1, 100); + + ImGui::PopStyleVar(); + + ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_None; + if (ImGui::BeginTabBar("Where to spawn", tab_bar_flags)) + { + if (ImGui::BeginTabItem("near player")) + { + where_to_spawn = Spawn::NearActor; + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("to inventory")) + { + where_to_spawn = Spawn::ToInventory; + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("on smart")) + { + where_to_spawn = Spawn::OnSmart; + ImGui::EndTabItem(); + } + ImGui::EndTabBar(); + } + + imgui::ItemHelp("Select the amount of items to spawn and where you want to spawn them."); + ImGui::EndMenuBar(); + } + + switch (where_to_spawn) + { + case Spawn::NearActor: + case Spawn::ToInventory: + { + ImGui::PushStyleColor(ImGuiCol_Button, 0); + + const auto tex = InventoryUtilities::GetEquipmentIconsShader()->GetImGuiTextureId(); + + for (const CInifile::Sect* section : sections) + { + const float w = pSettings->read_if_exists(section->Name, "inv_grid_width", 0) * INV_GRID_WIDTH; + const float h = pSettings->read_if_exists(section->Name, "inv_grid_height", 0) * INV_GRID_HEIGHT; + + if (fis_zero(w) || fis_zero(h)) + continue; + + const float x = pSettings->r_float(section->Name, "inv_grid_x") * INV_GRID_WIDTH; + const float y = pSettings->r_float(section->Name, "inv_grid_y") * INV_GRID_HEIGHT; + + const bool spawn = ImGui::ImageButton(section->Name.c_str(), tex.texture, { w , h }, + { x / tex.size.x, y / tex.size.y }, { (x + w) / tex.size.x, (y + h) / tex.size.y }); + if (spawn) + spawn_section = section->Name.c_str(); + } + ImGui::PopStyleColor(); + break; + } + case Spawn::OnSmart: + { + auto* alife = ai().get_alife(); + const auto* game_graph = ai().get_game_graph(); + + if (!alife || !game_graph) + { + ImGui::TextWrapped("A-Life should be loaded for this spawn method to work."); + break; + } + + // Get current level using the level graph, if nothing selected + if (!selected_level && ai().get_level_graph()) + { + selected_level = &game_graph->header().level(ai().level_graph().level_id()); + } + + // Display levels list + if (ImGui::BeginCombo("Level", selected_level ? selected_level->name().c_str() : "")) + { + for (const auto& [_, level] : game_graph->header().levels()) + { + if (ImGui::Selectable(level.name().c_str(), &level == selected_level)) + selected_level = &level; + } + ImGui::EndCombo(); + } + + // Select nearest to camera smart, if nothing selected + if (!selected_smart) + { + const auto& smarts = alife->smart_terrains().objects(); + const auto it = std::min_element(smarts.begin(), smarts.end(), [](const auto& left, const auto& right) + { + if (!left.second->m_bOnline) + return false; + + const float d1 = left.second->Position().distance_to_sqr(Device.vCameraPosition); + const float d2 = right.second->Position().distance_to_sqr(Device.vCameraPosition); + return d1 < d2; + }); + if (it != smarts.end() && it->second->m_bOnline) + selected_smart = it->second; + } + // Re-select smart terrain if we just changed the selected level + else if (game_graph->vertex(selected_smart->m_tGraphID)->level_id() != selected_level->id()) + { + for (const auto& [_, smart] : alife->smart_terrains().objects()) + { + const auto* game_vertex = game_graph->vertex(smart->m_tGraphID); + if (game_vertex->level_id() == selected_level->id()) + { + selected_smart = smart; + break; + } + } + } + + // Display smart list + if (ImGui::BeginCombo("Smart", selected_smart ? selected_smart->name_replace() : "")) + { + for (const auto& [_, smart] : alife->smart_terrains().objects()) + { + const auto* game_vertex = game_graph->vertex(smart->m_tGraphID); + if (game_vertex->level_id() != selected_level->id()) + continue; + if (ImGui::Selectable(smart->name_replace(), smart == selected_smart)) + selected_smart = smart; + } + ImGui::EndCombo(); + } + break; + } + } // switch (where_to_spawn) + + if (spawn_category == SpawnCategory::SquadsStalkers || spawn_category == SpawnCategory::SquadsMutants) + { + ImGui::TextWrapped("Squads are not supported for spawning right now."); + } + } + ImGui::EndChild(); + + // Finita la comedia. + if (spawn_section && g_pGameLevel) + { + auto entity = Level().CurrentViewEntity(); + if (!entity) + entity = Level().CurrentControlEntity(); + + Fvector pos; + u32 level_vertex_id = u32(-1); + auto game_vertex_id = GameGraph::_GRAPH_ID(-1); + auto parent_id = ALife::_OBJECT_ID(-1); + + switch (where_to_spawn) + { + case Spawn::ToInventory: + if (entity && spawn_category <= SpawnCategory::WeaponsMiscellaneous) + parent_id = entity->ID(); + [[fallthrough]]; + + case Spawn::NearActor: + if (entity) + { + pos = entity->Position(); + level_vertex_id = entity->ai_location().level_vertex_id(); + game_vertex_id = entity->ai_location().game_vertex_id(); + } + else if (ai().get_level_graph() && ai().get_cross_table()) + { + pos = Device.vCameraPosition; + level_vertex_id = ai().level_graph().vertex_id(pos); + game_vertex_id = ai().cross_table().vertex(level_vertex_id).game_vertex_id(); + } + break; + + case Spawn::OnSmart: + if (selected_smart) + { + pos = selected_smart->Position(); + level_vertex_id = selected_smart->m_tNodeID; + game_vertex_id = selected_smart->m_tGraphID; + } + break; + } + + auto* alife = const_cast(ai().get_alife()); + + for (int i = 0; i < spawn_amount; i++) + { + if (spawn_category == SpawnCategory::SquadsStalkers || spawn_category == SpawnCategory::SquadsMutants) + { + + } + else if (!alife || spawn_category == SpawnCategory::CreaturesPhantoms) + { + auto* abstract = Level().spawn_item(spawn_section, pos, level_vertex_id, parent_id, true); + + if (auto* anomaly = abstract ? abstract->cast_anomalous_zone() : nullptr) + { + CShapeData::shape_def shape + { + .type = CShapeData::cfSphere, + .data = { Fsphere{ .P = {}, .R = 3.0f } }, + }; + anomaly->assign_shapes(&shape, 1); + } + + NET_Packet P; + abstract->Spawn_Write(P, TRUE); // Not sure if it should be true or false (i.e. local or not) + Level().Send(P, net_flags(TRUE)); + F_entity_Destroy(abstract); + } + else if (level_vertex_id != u32(-1) && game_vertex_id != GameGraph::_GRAPH_ID(-1)) + { + auto* abstract = CALifeSimulator__spawn_item2(alife, spawn_section, pos, + level_vertex_id, game_vertex_id, parent_id); + + if (auto* anomaly = abstract ? abstract->cast_anomalous_zone() : nullptr) + { + CShapeData::shape_def shape + { + .type = CShapeData::cfSphere, + .data = { Fsphere{ .P = {}, .R = 3.0f } }, + }; + anomaly->assign_shapes(&shape, 1); + } + } + } + } + + ImGui::End(); +} +#endif diff --git a/src/xrServerEntities/object_factory_spawner.h b/src/xrServerEntities/object_factory_spawner.h new file mode 100644 index 00000000000..c1311f95e84 --- /dev/null +++ b/src/xrServerEntities/object_factory_spawner.h @@ -0,0 +1,446 @@ +#pragma once + +#ifndef MASTER_GOLD +#include "clsid_game.h" + +namespace xray +{ +enum class SpawnCategory : u8 +{ + Artefacts, + ArtefactContainers, + + ItemsFood, + ItemsDrink, + ItemsMedicine, + ItemsDevices, + ItemsTools, + ItemsRepair, + ItemsParts, + ItemsMiscellaneous, + ItemsNotes, + ItemsQuest, + ItemsUpgrades, + + Helmets, + OutfitsAttachments, + OutfitsLight, + OutfitsMedium, + OutfitsHeavy, + + WeaponsAmmo, + WeaponsMelee, + WeaponsPistols, + WeaponsShotguns, + WeaponsSMG, + WeaponsRifles, + WeaponsSniperRifles, + WeaponsExplosives, + WeaponsMiscellaneous, + + Vehicles, + Physics, + + CreaturesStalkers, + CreaturesMutants, + CreaturesPhantoms, + SquadsStalkers, + SquadsMutants, + + Zones, + + CategoriesCount, + Unknown = u8(-1) +}; + +constexpr pcstr spawn_category_to_text(SpawnCategory category) +{ + switch (category) + { + case SpawnCategory::Artefacts: return "Artefacts"; + case SpawnCategory::ArtefactContainers: return "Artefact containers"; + + case SpawnCategory::ItemsFood: return "Items (Food)"; + case SpawnCategory::ItemsDrink: return "Items (Drink)"; + case SpawnCategory::ItemsMedicine: return "Items (Medicine)"; + case SpawnCategory::ItemsDevices: return "Items (Devices)"; + case SpawnCategory::ItemsTools: return "Items (Tools)"; + case SpawnCategory::ItemsRepair: return "Items (Repair)"; + case SpawnCategory::ItemsParts: return "Items (Parts)"; + case SpawnCategory::ItemsMiscellaneous: return "Items (Misc.)"; + case SpawnCategory::ItemsNotes: return "Items (Notes)"; + case SpawnCategory::ItemsQuest: return "Items (Quest)"; + case SpawnCategory::ItemsUpgrades: return "Items (Upgrades)"; + + case SpawnCategory::Helmets: return "Helmets"; + case SpawnCategory::OutfitsAttachments: return "Outfits (Attachments)"; + case SpawnCategory::OutfitsLight: return "Outfits (Light)"; + case SpawnCategory::OutfitsMedium: return "Outfits (Medium)"; + case SpawnCategory::OutfitsHeavy: return "Outfits (Heavy)"; + + case SpawnCategory::WeaponsAmmo: return "Weapons (Ammo)"; + case SpawnCategory::WeaponsMelee: return "Weapons (Melee)"; + case SpawnCategory::WeaponsPistols: return "Weapons (Pistols)"; + case SpawnCategory::WeaponsShotguns: return "Weapons (Shotguns)"; + case SpawnCategory::WeaponsSMG: return "Weapons (SMG)"; + case SpawnCategory::WeaponsRifles: return "Weapons (Rifles)"; + case SpawnCategory::WeaponsSniperRifles: return "Weapons (Sniper)"; + case SpawnCategory::WeaponsExplosives: return "Weapons (Explosives)"; + case SpawnCategory::WeaponsMiscellaneous: return "Weapons (Misc.)"; + + case SpawnCategory::Vehicles: return "Vehicles"; + case SpawnCategory::Physics: return "Physic (Misc.)"; + + case SpawnCategory::CreaturesStalkers: return "NPC (Stalkers)"; + case SpawnCategory::CreaturesMutants: return "NPC (Mutants)"; + case SpawnCategory::CreaturesPhantoms: return "Phantoms"; + case SpawnCategory::SquadsStalkers: return "Squads (Stalkers)"; + case SpawnCategory::SquadsMutants: return "Squads (Mutants)"; + + case SpawnCategory::Zones: return "Anomalies"; + + default: + case SpawnCategory::Unknown: return "Unknown"; + } // switch (category) +} + +constexpr SpawnCategory kind_to_spawn_category(pcstr kind) +{ + switch (strhash(kind)) + { + case "i_arty"_hash: return SpawnCategory::Artefacts; + case "i_arty_junk"_hash: return SpawnCategory::Artefacts; + case "i_arty_cont"_hash: return SpawnCategory::ArtefactContainers; + + case "i_food"_hash: return SpawnCategory::ItemsFood; + case "i_mutant_raw"_hash: return SpawnCategory::ItemsFood; + case "i_mutant_cooked"_hash: return SpawnCategory::ItemsFood; + case "i_drink"_hash: return SpawnCategory::ItemsDrink; + case "i_medical"_hash: return SpawnCategory::ItemsMedicine; + case "i_device"_hash: return SpawnCategory::ItemsDevices; + case "i_kit"_hash: return SpawnCategory::ItemsTools; + case "i_tool"_hash: return SpawnCategory::ItemsTools; + case "i_repair"_hash: return SpawnCategory::ItemsRepair; + case "i_part"_hash: return SpawnCategory::ItemsParts; + case "i_mutant_part"_hash: return SpawnCategory::ItemsMiscellaneous; + case "i_misc"_hash: return SpawnCategory::ItemsMiscellaneous; + case "i_letter"_hash: return SpawnCategory::ItemsNotes; + case "i_quest"_hash: return SpawnCategory::ItemsQuest; + case "i_upgrade"_hash: return SpawnCategory::ItemsUpgrades; + + case "o_helmet"_hash: return SpawnCategory::Helmets; + case "i_mutant_belt"_hash: return SpawnCategory::OutfitsAttachments; + case "i_attach"_hash: return SpawnCategory::OutfitsAttachments; + case "i_backpack"_hash: return SpawnCategory::OutfitsAttachments; + case "o_light"_hash: return SpawnCategory::OutfitsLight; + case "o_medium"_hash: return SpawnCategory::OutfitsMedium; + case "o_sci"_hash: return SpawnCategory::OutfitsMedium; + case "o_heavy"_hash: return SpawnCategory::OutfitsHeavy; + + case "w_ammo"_hash: return SpawnCategory::WeaponsAmmo; + case "w_melee"_hash: return SpawnCategory::WeaponsMelee; + case "w_pistol"_hash: return SpawnCategory::WeaponsPistols; + case "w_shotgun"_hash: return SpawnCategory::WeaponsShotguns; + case "w_smg"_hash: return SpawnCategory::WeaponsSMG; + case "w_rifle"_hash: return SpawnCategory::WeaponsRifles; + case "w_sniper"_hash: return SpawnCategory::WeaponsSniperRifles; + case "w_explosive"_hash: return SpawnCategory::WeaponsExplosives; + case "w_misc"_hash: return SpawnCategory::WeaponsMiscellaneous; + + case "S_WPN_MISC"_hash: return SpawnCategory::WeaponsMiscellaneous; + case "SM_KARLIK"_hash: return SpawnCategory::CreaturesMutants; + case "SM_LURKER"_hash: return SpawnCategory::CreaturesMutants; + case "SM_PSYSUCKER"_hash: return SpawnCategory::CreaturesMutants; + } // switch (strhash(kind)) + + return SpawnCategory::Unknown; +} + +constexpr SpawnCategory clsid_to_spawn_category(CLASS_ID clsid) +{ + switch (clsid) + { + case CLSID_ARTEFACT: + case CLSID_AF_MERCURY_BALL: + case CLSID_AF_GRAVI: + case CLSID_AF_BLACKDROPS: + case CLSID_AF_NEEDLES: + case CLSID_AF_BAST: + case CLSID_AF_BLACK_GRAVI: + case CLSID_AF_DUMMY: + case CLSID_AF_ZUDA: + case CLSID_AF_THORN: + case CLSID_AF_FADED_BALL: + case CLSID_AF_ELECTRIC_BALL: + case CLSID_AF_RUSTY_HAIR: + case CLSID_AF_GALANTINE: + case CLSID_AF_CTA: + case make_clsid("SCRPTART"): + return SpawnCategory::Artefacts; + + case CLSID_IITEM_FOOD: + case make_clsid("S_FOOD "): + return SpawnCategory::ItemsFood; + + case CLSID_IITEM_BOTTLE: + return SpawnCategory::ItemsDrink; + + case CLSID_IITEM_MEDKIT: + case CLSID_IITEM_BANDAGE: + case CLSID_IITEM_ANTIRAD: + return SpawnCategory::ItemsMedicine; + + case CLSID_DETECTOR_SIMPLE: + case CLSID_DETECTOR_VISUAL: + case CLSID_DETECTOR_ADVANCED: + case CLSID_DETECTOR_ELITE: + case CLSID_DETECTOR_SCIENTIFIC: + case make_clsid("DET_SIMP"): + case make_clsid("DET_ADVA"): + case make_clsid("DET_ELIT"): + case make_clsid("DET_SCIE"): + return SpawnCategory::ItemsDevices; + + case CLSID_IITEM_ATTACH: + case CLSID_DEVICE_PDA: + case CLSID_DEVICE_TORCH: + case CLSID_DEVICE_FLARE: + case make_clsid("EQ_PATCH"): + case make_clsid("II_BTTCH"): + case make_clsid("TORCH_S "): + case make_clsid("D_FLALIT"): + case make_clsid("D_DSMETR"): + case make_clsid("S_PDA "): + return SpawnCategory::ItemsMiscellaneous; + + case CLSID_IITEM_DOCUMENT: + return SpawnCategory::ItemsNotes; + + case CLSID_EQUIPMENT_HELMET: + case make_clsid("E_HLMET "): + return SpawnCategory::Helmets; + + case CLSID_EQUIPMENT_BACKPACK: + return SpawnCategory::OutfitsAttachments; + + case CLSID_EQUIPMENT_SIMPLE: + return SpawnCategory::OutfitsLight; + + case CLSID_EQUIPMENT_SCIENTIFIC: + case CLSID_EQUIPMENT_STALKER: + case make_clsid("E_STLK "): + return SpawnCategory::OutfitsMedium; + + case CLSID_EQUIPMENT_MILITARY: + case CLSID_EQUIPMENT_EXO: + return SpawnCategory::OutfitsHeavy; + + case CLSID_OBJECT_AMMO: + case CLSID_OBJECT_A_VOG25: + case CLSID_OBJECT_A_OG7B: + case CLSID_OBJECT_A_M209: + case make_clsid("AMMO_S "): + case make_clsid("S_VOG25 "): + case make_clsid("S_OG7B "): + case make_clsid("S_M209 "): + return SpawnCategory::WeaponsAmmo; + + case CLSID_OBJECT_W_KNIFE: + case make_clsid("WP_KNIFE"): + return SpawnCategory::WeaponsMelee; + + case CLSID_OBJECT_W_HPSA: + case CLSID_OBJECT_W_PM: + case CLSID_OBJECT_W_FORT: + case CLSID_OBJECT_W_WALTHER: + case CLSID_OBJECT_W_USP45: + case make_clsid("WP_HPSA "): + case make_clsid("WP_PM "): + case make_clsid("WP_USP45"): + case make_clsid("WP_WALTH"): + return SpawnCategory::WeaponsPistols; + + case CLSID_OBJECT_W_SHOTGUN: + case CLSID_OBJECT_W_ASHOTGUN: + case CLSID_OBJECT_W_BM16: + case make_clsid("WP_SHOTG"): + case make_clsid("WP_ASHTG"): + case make_clsid("WP_BM16 "): + return SpawnCategory::WeaponsShotguns; + + case CLSID_OBJECT_W_FN2000: + case CLSID_OBJECT_W_AK74: + case CLSID_OBJECT_W_LR300: + case CLSID_OBJECT_W_MAGAZINED: + case CLSID_OBJECT_W_MAGAZWGL: + case CLSID_OBJECT_W_VAL: + case CLSID_OBJECT_W_VINTOREZ: + case CLSID_OBJECT_W_GROZA: + case make_clsid("WP_GROZA"): + case make_clsid("WP_AK74 "): + case make_clsid("WP_LR300"): + case make_clsid("WP_MAGAZ"): + case make_clsid("WP_VAL "): + case make_clsid("WP_VINT "): + return SpawnCategory::WeaponsRifles; + + case CLSID_OBJECT_W_SVD: + case CLSID_OBJECT_W_SVU: + case make_clsid("WP_SVD "): + case make_clsid("WP_SVU "): + return SpawnCategory::WeaponsSniperRifles; + + case CLSID_OBJECT_W_RPG7: + case CLSID_OBJECT_W_RG6: + case CLSID_GRENADE_F1: + case CLSID_GRENADE_RGD5: + case make_clsid("WP_RG6 "): + case make_clsid("WP_RPG7 "): + case make_clsid("G_F1_S "): + case make_clsid("G_RGD5_S"): + return SpawnCategory::WeaponsExplosives; + + case CLSID_OBJECT_W_BINOCULAR: + case CLSID_OBJECT_W_SCOPE: + case CLSID_OBJECT_W_SILENCER: + case CLSID_OBJECT_W_GLAUNCHER: + case CLSID_IITEM_BOLT: + case CLSID_OBJECT_W_STATMGUN: + case make_clsid("WP_SCOPE"): + case make_clsid("WP_SILEN"): + case make_clsid("WP_GLAUN"): + case make_clsid("WP_BINOC"): + return SpawnCategory::WeaponsMiscellaneous; + + case CLSID_CAR: + case CLSID_VEHICLE_HELICOPTER: + case make_clsid("C_HLCP_S"): + case make_clsid("SCRPTCAR"): + return SpawnCategory::Vehicles; + + case CLSID_OBJECT_HLAMP: + case CLSID_OBJECT_PROJECTOR: + case CLSID_OBJECT_BREAKABLE: + case CLSID_OBJECT_CLIMABLE: + case CLSID_OBJECT_HOLDER_ENT: + case CLSID_PH_SKELETON_OBJECT: + case CLSID_OBJECT_PHYSIC: + case CLSID_PHYSICS_DESTROYABLE: + case CLSID_INVENTORY_BOX: + case CLSID_IITEM_EXPLOSIVE: + case make_clsid("SO_HLAMP"): + case make_clsid("O_PHYS_S"): + case make_clsid("O_DSTR_S"): + case make_clsid("S_INVBOX"): + case make_clsid("S_EXPLO "): + return SpawnCategory::Physics; + + case CLSID_AI_CROW: + case CLSID_AI_ZOMBIE: + case CLSID_AI_POLTERGEIST: + case CLSID_AI_FLESH: + case CLSID_AI_CONTROLLER: + case CLSID_AI_BLOODSUCKER: + case CLSID_AI_BURER: + case CLSID_AI_GIANT: + case CLSID_AI_CHIMERA: + case CLSID_AI_FRACTURE: + case CLSID_AI_DOG_BLACK: + case CLSID_AI_DOG_RED: + case CLSID_AI_DOG_PSY: + case CLSID_AI_BOAR: + case CLSID_AI_SNORK: + case CLSID_AI_CAT: + case CLSID_AI_TUSHKANO: + case CLSID_AI_RAT: + case make_clsid("SM_BLOOD"): + case make_clsid("SM_BOARW"): + case make_clsid("SM_DOG_S"): + case make_clsid("SM_FLESH"): + case make_clsid("SM_P_DOG"): + case make_clsid("SM_BURER"): + case make_clsid("SM_CAT_S"): + case make_clsid("SM_CHIMS"): + case make_clsid("SM_CONTR"): + case make_clsid("SM_IZLOM"): + case make_clsid("SM_POLTR"): + case make_clsid("SM_GIANT"): + case make_clsid("SM_ZOMBI"): + case make_clsid("SM_SNORK"): + case make_clsid("SM_TUSHK"): + case make_clsid("SM_RAT "): + case make_clsid("SM_DOG_P"): + return SpawnCategory::CreaturesMutants; + + case CLSID_AI_STALKER: + case CLSID_AI_TRADER: + case make_clsid("AI_STL_S"): + case make_clsid("AI_TRD_S"): + return SpawnCategory::CreaturesStalkers; + + case CLSID_AI_PHANTOM: + case CLSID_AI_DOG_PSY_PHANTOM: + case make_clsid("SM_DOG_F"): + return SpawnCategory::CreaturesPhantoms; + + case CLSID_ONLINE_OFFLINE_GROUP: + case make_clsid("ON_OFF_S"): + return SpawnCategory::SquadsStalkers; + + case CLSID_ZONE: + case CLSID_Z_MBALD: + case CLSID_Z_MINCER: + case CLSID_Z_ACIDF: + case CLSID_Z_GALANT: + case CLSID_Z_RADIO: + case CLSID_Z_BFUZZ: + case CLSID_Z_RUSTYH: + case CLSID_Z_AMEBA: + case CLSID_Z_NOGRAVITY: + case CLSID_Z_FRYUP: + case CLSID_Z_DEAD: + case CLSID_Z_TORRID: + case CLSID_Z_CAMPFIRE: + case make_clsid("ZS_BFUZZ"): + case make_clsid("ZS_MBALD"): + case make_clsid("ZS_GALAN"): + case make_clsid("ZS_MINCE"): + case make_clsid("ZS_RADIO"): + case make_clsid("ZS_TORRD"): + case make_clsid("ZS_AMEBA"): + case make_clsid("ZS_NGRAV"): + return SpawnCategory::Zones; + } // switch (clsid) + + return SpawnCategory::Unknown; +} + +constexpr SpawnCategory weapon_class_to_spawn_category(pcstr wpclass) +{ + switch (strhash(wpclass)) + { + case "shotgun"_hash: return SpawnCategory::WeaponsShotguns; + case "assault_rifle"_hash: return SpawnCategory::WeaponsRifles; + case "heavy_weapon"_hash: return SpawnCategory::WeaponsRifles; + case "sniper_rifle"_hash: return SpawnCategory::WeaponsSniperRifles; + } + return SpawnCategory::Unknown; +} + +constexpr SpawnCategory try_detect_spawn_category(pcstr kind, pcstr wpclass, CLASS_ID clsid) +{ + SpawnCategory category{ SpawnCategory::Unknown }; + + if (kind) + category = kind_to_spawn_category(kind); + + if (wpclass && category == SpawnCategory::Unknown) + category = weapon_class_to_spawn_category(wpclass); + + if (clsid && category == SpawnCategory::Unknown) + category = clsid_to_spawn_category(clsid); + + return category; +} +} // namespace xray +#endif // MASTER_GOLD diff --git a/src/xrServerEntities/pch_script.h b/src/xrServerEntities/pch_script.h index 319a6a5039b..a23ebf2ead2 100644 --- a/src/xrServerEntities/pch_script.h +++ b/src/xrServerEntities/pch_script.h @@ -6,10 +6,8 @@ // Description : precompiled header for lua and luabind users //////////////////////////////////////////////////////////////////////////// -#ifndef PCH_SCRIPT_H -#define PCH_SCRIPT_H +#pragma once #include "StdAfx.h" -#include "xrScriptEngine/xrScriptEngine.hpp" - -#endif // PCH_SCRIPT_H +#include "xrScriptEngine/ScriptExporter.hpp" +#include "xrScriptEngine/script_space.hpp" diff --git a/src/xrServerEntities/script_fcolor_script.cpp b/src/xrServerEntities/script_fcolor_script.cpp index 70c21a22b12..9c4771ae024 100644 --- a/src/xrServerEntities/script_fcolor_script.cpp +++ b/src/xrServerEntities/script_fcolor_script.cpp @@ -1,5 +1,5 @@ //////////////////////////////////////////////////////////////////////////// -// Module : script_Fcolor_script.cpp +// Module : script_fcolor_script.cpp // Created : 28.06.2004 // Modified : 28.06.2004 // Author : Dmitriy Iassenev @@ -7,9 +7,10 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(Fcolor, (), +#include "base_client_classes_wrappers.h" + +void CScriptFcolor::script_register(lua_State* luaState) { using namespace luabind; using namespace luabind::policy; @@ -22,9 +23,8 @@ SCRIPT_EXPORT(Fcolor, (), .def_readwrite("b", &Fcolor::b) .def_readwrite("a", &Fcolor::a) .def(constructor<>()) - .def("set", (Fcolor & (Fcolor::*)(float, float, float, float))(&Fcolor::set), - return_reference_to<1>()) + .def("set", (Fcolor & (Fcolor::*)(float, float, float, float))(&Fcolor::set), return_reference_to<1>()) .def("set", (Fcolor & (Fcolor::*)(const Fcolor&))(&Fcolor::set), return_reference_to<1>()) .def("set", (Fcolor & (Fcolor::*)(u32))(&Fcolor::set), return_reference_to<1>()) ]; -}); +} diff --git a/src/xrServerEntities/script_flags_script.cpp b/src/xrServerEntities/script_flags_script.cpp index b4df8f013f1..3c709f58110 100644 --- a/src/xrServerEntities/script_flags_script.cpp +++ b/src/xrServerEntities/script_flags_script.cpp @@ -7,8 +7,9 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" -#include "xrScriptEngine/ScriptExporter.hpp" + #include "Common/object_type_traits.h" +#include "base_client_classes_wrappers.h" template T& set(T* self, const typename T::TYPE mask, bool value) @@ -52,7 +53,7 @@ void one(T* self) self->assign(typename T::TYPE(-1)); } -SCRIPT_EXPORT(Flags8, (), +void CScriptFlags::script_register(lua_State* luaState) { using namespace luabind; @@ -77,16 +78,8 @@ SCRIPT_EXPORT(Flags8, (), .def("is_any", &is_any) .def("test", &test) .def("equal", (bool(*)(Flags8*, const Flags8&))(&equal)) - .def("equal", (bool(*)(Flags8*, const Flags8&, const Flags8::TYPE))(&equal)) - ]; -}); + .def("equal", (bool(*)(Flags8*, const Flags8&, const Flags8::TYPE))(&equal)), -SCRIPT_EXPORT(Flags16, (), -{ - using namespace luabind; - - module(luaState) - [ class_("flags16") .def(constructor<>()) .def("get", REMOVE_NOEXCEPT(&Flags16::get)) @@ -106,16 +99,8 @@ SCRIPT_EXPORT(Flags16, (), .def("is_any", &is_any) .def("test", &test) .def("equal", (bool (*)(Flags16*, const Flags16&))(&equal)) - .def("equal", (bool (*)(Flags16*, const Flags16&, const Flags16::TYPE))(&equal)) - ]; -}); - -SCRIPT_EXPORT(Flags32, (), -{ - using namespace luabind; + .def("equal", (bool (*)(Flags16*, const Flags16&, const Flags16::TYPE))(&equal)), - module(luaState) - [ class_("flags32") .def(constructor<>()) .def("get", REMOVE_NOEXCEPT(&Flags32::get)) @@ -137,4 +122,4 @@ SCRIPT_EXPORT(Flags32, (), .def("equal", (bool(*)(Flags32*, const Flags32&))(&equal)) .def("equal", (bool(*)(Flags32*, const Flags32&, const Flags32::TYPE))(&equal)) ]; -}); +} diff --git a/src/xrServerEntities/script_fmatrix_script.cpp b/src/xrServerEntities/script_fmatrix_script.cpp index 943b317e0e9..29d062e899d 100644 --- a/src/xrServerEntities/script_fmatrix_script.cpp +++ b/src/xrServerEntities/script_fmatrix_script.cpp @@ -7,12 +7,14 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" -#include "xrScriptEngine/ScriptExporter.hpp" + +#include "xrCore/_quaternion.h" +#include "base_client_classes_wrappers.h" void get_matrix_hpb(Fmatrix* self, float* h, float* p, float* b) { self->getHPB(*h, *p, *b); } void matrix_transform(Fmatrix* self, Fvector* v) { self->transform(*v); } -SCRIPT_EXPORT(Fmatrix, (), +void CScriptFmatrix::script_register(lua_State* luaState) { using namespace luabind; using namespace luabind::policy; @@ -20,130 +22,129 @@ SCRIPT_EXPORT(Fmatrix, (), module(luaState) [ class_("matrix") - .def_readwrite("i", &Fmatrix::i) - .def_readwrite("_14_", &Fmatrix::_14_) - .def_readwrite("j", &Fmatrix::j) - .def_readwrite("_24_", &Fmatrix::_24_) - .def_readwrite("k", &Fmatrix::k) - .def_readwrite("_34_", &Fmatrix::_34_) - .def_readwrite("c", &Fmatrix::c) - .def_readwrite("_44_", &Fmatrix::_44_) - .def(constructor<>()) - .def("set", (Fmatrix & (Fmatrix::*)(const Fmatrix&))(&Fmatrix::set), return_reference_to<1>()) - .def("set", (Fmatrix & (Fmatrix::*)(const Fvector&, const Fvector&, const Fvector&, const Fvector&))( - &Fmatrix::set), - return_reference_to<1>()) - .def("identity", &Fmatrix::identity, return_reference_to<1>()) - .def("mk_xform", &Fmatrix::mk_xform, return_reference_to<1>()) - .def("mul", (Fmatrix & (Fmatrix::*)(const Fmatrix&, const Fmatrix&))(&Fmatrix::mul), - return_reference_to<1>()) - .def("mul", (Fmatrix & (Fmatrix::*)(const Fmatrix&, float))(&Fmatrix::mul), return_reference_to<1>()) - .def("mul", (Fmatrix & (Fmatrix::*)(float))(&Fmatrix::mul), return_reference_to<1>()) - .def("div", (Fmatrix & (Fmatrix::*)(const Fmatrix&, float))(&Fmatrix::div), return_reference_to<1>()) - .def("div", (Fmatrix & (Fmatrix::*)(float))(&Fmatrix::div), return_reference_to<1>()) - // .def("invert", (Fmatrix & (Fmatrix::*)())(&Fmatrix::invert), - // return_reference_to<1>()) - // .def("invert", (Fmatrix & (Fmatrix::*)(const Fmatrix - //&))(&Fmatrix::invert), return_reference_to<1>()) - // .def("transpose", (Fmatrix & (Fmatrix::*)())(&Fmatrix::transpose), - // return_reference_to<1>()) - // .def("transpose", (Fmatrix & (Fmatrix::*)(const Fmatrix - //&))(&Fmatrix::transpose), return_reference_to<1>()) - // .def("translate", (Fmatrix & (Fmatrix::*)(const Fvector - //&))(&Fmatrix::translate), return_reference_to<1>()) - // .def("translate", (Fmatrix & (Fmatrix::*)(float, float, - // float))(&Fmatrix::translate), return_reference_to<1>()) - // .def("translate_over", (Fmatrix & (Fmatrix::*)(const Fvector - //&))(&Fmatrix::translate_over), return_reference_to<1>()) - // .def("translate_over", (Fmatrix & (Fmatrix::*)(float, float, - // float))(&Fmatrix::translate_over), return_reference_to<1>()) - // .def("translate_add", &Fmatrix::translate_add, - // return_reference_to<1>()) - // .def("scale", (Fmatrix & (Fmatrix::*)(const Fvector - //&))(&Fmatrix::scale), return_reference_to<1>()) - // .def("scale", (Fmatrix & (Fmatrix::*)(float, float, - // float))(&Fmatrix::scale), return_reference_to<1>()) - // .def("rotateX", &Fmatrix::rotateX, - // return_reference_to<1>()) - // .def("rotateY", &Fmatrix::rotateY, - // return_reference_to<1>()) - // .def("rotateZ", &Fmatrix::rotateZ, - // return_reference_to<1>()) - // .def("rotation", (Fmatrix & (Fmatrix::*)(const Fvector &, const Fvector - //&))(&Fmatrix::rotation), return_reference_to<1>()) - // .def("rotation", (Fmatrix & (Fmatrix::*)(const Fvector &, - // float))(&Fmatrix::rotation), return_reference_to<1>()) - // .def("rotation", &Fmatrix::rotation, - // return_reference_to<1>()) - /* - .def("mapXYZ", &Fmatrix::mapXYZ, - return_reference_to<1>()) - .def("mapXZY", &Fmatrix::mapXZY, - return_reference_to<1>()) - .def("mapYXZ", &Fmatrix::mapYXZ, - return_reference_to<1>()) - .def("mapYZX", &Fmatrix::mapYZX, - return_reference_to<1>()) - .def("mapZXY", &Fmatrix::mapZXY, - return_reference_to<1>()) - .def("mapZYX", &Fmatrix::mapZYX, - return_reference_to<1>()) - .def("mirrorX", &Fmatrix::mirrorX, - return_reference_to<1>()) - .def("mirrorX_over", &Fmatrix::mirrorX_over, - return_reference_to<1>()) - .def("mirrorX_add ", &Fmatrix::mirrorX_add, - return_reference_to<1>()) - .def("mirrorY", &Fmatrix::mirrorY, - return_reference_to<1>()) - .def("mirrorY_over", &Fmatrix::mirrorY_over, - return_reference_to<1>()) - .def("mirrorY_add ", &Fmatrix::mirrorY_add, - return_reference_to<1>()) - .def("mirrorZ", &Fmatrix::mirrorZ, - return_reference_to<1>()) - .def("mirrorZ_over", &Fmatrix::mirrorZ_over, - return_reference_to<1>()) - .def("mirrorZ_add ", &Fmatrix::mirrorZ_add, - return_reference_to<1>()) - */ - // .def("build_projection", &Fmatrix::build_projection, - // return_reference_to<1>()) - // .def("build_projection_HAT", &Fmatrix::build_projection_HAT, - // return_reference_to<1>()) - // .def("build_projection_ortho", &Fmatrix::build_projection_ortho, - // return_reference_to<1>()) - // .def("build_camera", &Fmatrix::build_camera, - // return_reference_to<1>()) - // .def("build_camera_dir", &Fmatrix::build_camera_dir, - // return_reference_to<1>()) - // .def("inertion", &Fmatrix::inertion, - // return_reference_to<1>()) - // .def("transform_tiny32", &Fmatrix::transform_tiny32) - // .def("transform_tiny23", &Fmatrix::transform_tiny23) - // .def("transform_tiny", (void (Fmatrix::*)(Fvector &) - // const)(&Fmatrix::transform_tiny), out_value<2>()) - // .def("transform_tiny", (void (Fmatrix::*)(Fvector &, const Fvector &) - // const)(&Fmatrix::transform_tiny), out_value<2>()) - // .def("transform_dir", (void (Fmatrix::*)(Fvector &) - // const)(&Fmatrix::transform_dir), out_value<2>()) - // .def("transform_dir", (void (Fmatrix::*)(Fvector &, const Fvector &) - // const)(&Fmatrix::transform_dir), out_value<2>()) - // .def("transform", (void (Fmatrix::*)(Fvector &) - // const)(&Fmatrix::transform), out_value<2>()) - // .def("transform", &matrix_transform) - .def("setHPB", &Fmatrix::setHPB, return_reference_to<1>()) - // .def("setXYZ", (Fmatrix & (Fmatrix::*)(Fvector &))(&Fmatrix::setXYZ), - // policy_list, out_value<2>>()) - .def( - "setXYZ", (Fmatrix & (Fmatrix::*)(float, float, float))(&Fmatrix::setXYZ), return_reference_to<1>()) - // .def("setXYZi", (Fmatrix & (Fmatrix::*)(Fvector - //&))(&Fmatrix::setXYZi), policy_list, out_value<2>>()) - .def("setXYZi", (Fmatrix & (Fmatrix::*)(float, float, float))(&Fmatrix::setXYZi), - return_reference_to<1>()) - // .def("getHPB", (void (Fmatrix::*)(Fvector &) - // const)(&Fmatrix::getHPB), out_value<2>()) - .def("getHPB", &get_matrix_hpb) + .def_readwrite("i", &Fmatrix::i) + .def_readwrite("_14_", &Fmatrix::_14_) + .def_readwrite("j", &Fmatrix::j) + .def_readwrite("_24_", &Fmatrix::_24_) + .def_readwrite("k", &Fmatrix::k) + .def_readwrite("_34_", &Fmatrix::_34_) + .def_readwrite("c", &Fmatrix::c) + .def_readwrite("_44_", &Fmatrix::_44_) + .def(constructor<>()) + .def("set", (Fmatrix & (Fmatrix::*)(const Fmatrix&))(&Fmatrix::set), return_reference_to<1>()) + .def("set", (Fmatrix & (Fmatrix::*)(const Fvector&, const Fvector&, const Fvector&, const Fvector&))(&Fmatrix::set), + return_reference_to<1>()) + .def("identity", &Fmatrix::identity, return_reference_to<1>()) + .def("mk_xform", &Fmatrix::mk_xform, return_reference_to<1>()) + .def("mul", (Fmatrix & (Fmatrix::*)(const Fmatrix&, const Fmatrix&))(&Fmatrix::mul), + return_reference_to<1>()) + .def("mul", (Fmatrix & (Fmatrix::*)(const Fmatrix&, float))(&Fmatrix::mul), return_reference_to<1>()) + .def("mul", (Fmatrix & (Fmatrix::*)(float))(&Fmatrix::mul), return_reference_to<1>()) + .def("div", (Fmatrix & (Fmatrix::*)(const Fmatrix&, float))(&Fmatrix::div), return_reference_to<1>()) + .def("div", (Fmatrix & (Fmatrix::*)(float))(&Fmatrix::div), return_reference_to<1>()) + // .def("invert", (Fmatrix & (Fmatrix::*)())(&Fmatrix::invert), + // return_reference_to<1>()) + // .def("invert", (Fmatrix & (Fmatrix::*)(const Fmatrix + //&))(&Fmatrix::invert), return_reference_to<1>()) + // .def("transpose", (Fmatrix & (Fmatrix::*)())(&Fmatrix::transpose), + // return_reference_to<1>()) + // .def("transpose", (Fmatrix & (Fmatrix::*)(const Fmatrix + //&))(&Fmatrix::transpose), return_reference_to<1>()) + // .def("translate", (Fmatrix & (Fmatrix::*)(const Fvector + //&))(&Fmatrix::translate), return_reference_to<1>()) + // .def("translate", (Fmatrix & (Fmatrix::*)(float, float, + // float))(&Fmatrix::translate), return_reference_to<1>()) + // .def("translate_over", (Fmatrix & (Fmatrix::*)(const Fvector + //&))(&Fmatrix::translate_over), return_reference_to<1>()) + // .def("translate_over", (Fmatrix & (Fmatrix::*)(float, float, + // float))(&Fmatrix::translate_over), return_reference_to<1>()) + // .def("translate_add", &Fmatrix::translate_add, + // return_reference_to<1>()) + // .def("scale", (Fmatrix & (Fmatrix::*)(const Fvector + //&))(&Fmatrix::scale), return_reference_to<1>()) + // .def("scale", (Fmatrix & (Fmatrix::*)(float, float, + // float))(&Fmatrix::scale), return_reference_to<1>()) + // .def("rotateX", &Fmatrix::rotateX, + // return_reference_to<1>()) + // .def("rotateY", &Fmatrix::rotateY, + // return_reference_to<1>()) + // .def("rotateZ", &Fmatrix::rotateZ, + // return_reference_to<1>()) + // .def("rotation", (Fmatrix & (Fmatrix::*)(const Fvector &, const Fvector + //&))(&Fmatrix::rotation), return_reference_to<1>()) + // .def("rotation", (Fmatrix & (Fmatrix::*)(const Fvector &, + // float))(&Fmatrix::rotation), return_reference_to<1>()) + // .def("rotation", &Fmatrix::rotation, + // return_reference_to<1>()) + /* + .def("mapXYZ", &Fmatrix::mapXYZ, + return_reference_to<1>()) + .def("mapXZY", &Fmatrix::mapXZY, + return_reference_to<1>()) + .def("mapYXZ", &Fmatrix::mapYXZ, + return_reference_to<1>()) + .def("mapYZX", &Fmatrix::mapYZX, + return_reference_to<1>()) + .def("mapZXY", &Fmatrix::mapZXY, + return_reference_to<1>()) + .def("mapZYX", &Fmatrix::mapZYX, + return_reference_to<1>()) + .def("mirrorX", &Fmatrix::mirrorX, + return_reference_to<1>()) + .def("mirrorX_over", &Fmatrix::mirrorX_over, + return_reference_to<1>()) + .def("mirrorX_add ", &Fmatrix::mirrorX_add, + return_reference_to<1>()) + .def("mirrorY", &Fmatrix::mirrorY, + return_reference_to<1>()) + .def("mirrorY_over", &Fmatrix::mirrorY_over, + return_reference_to<1>()) + .def("mirrorY_add ", &Fmatrix::mirrorY_add, + return_reference_to<1>()) + .def("mirrorZ", &Fmatrix::mirrorZ, + return_reference_to<1>()) + .def("mirrorZ_over", &Fmatrix::mirrorZ_over, + return_reference_to<1>()) + .def("mirrorZ_add ", &Fmatrix::mirrorZ_add, + return_reference_to<1>()) + */ + // .def("build_projection", &Fmatrix::build_projection, + // return_reference_to<1>()) + // .def("build_projection_HAT", &Fmatrix::build_projection_HAT, + // return_reference_to<1>()) + // .def("build_projection_ortho", &Fmatrix::build_projection_ortho, + // return_reference_to<1>()) + // .def("build_camera", &Fmatrix::build_camera, + // return_reference_to<1>()) + // .def("build_camera_dir", &Fmatrix::build_camera_dir, + // return_reference_to<1>()) + // .def("inertion", &Fmatrix::inertion, + // return_reference_to<1>()) + // .def("transform_tiny32", &Fmatrix::transform_tiny32) + // .def("transform_tiny23", &Fmatrix::transform_tiny23) + // .def("transform_tiny", (void (Fmatrix::*)(Fvector &) + // const)(&Fmatrix::transform_tiny), out_value<2>()) + // .def("transform_tiny", (void (Fmatrix::*)(Fvector &, const Fvector &) + // const)(&Fmatrix::transform_tiny), out_value<2>()) + // .def("transform_dir", (void (Fmatrix::*)(Fvector &) + // const)(&Fmatrix::transform_dir), out_value<2>()) + // .def("transform_dir", (void (Fmatrix::*)(Fvector &, const Fvector &) + // const)(&Fmatrix::transform_dir), out_value<2>()) + // .def("transform", (void (Fmatrix::*)(Fvector &) + // const)(&Fmatrix::transform), out_value<2>()) + // .def("transform", &matrix_transform) + .def("setHPB", &Fmatrix::setHPB, return_reference_to<1>()) + // .def("setXYZ", (Fmatrix & (Fmatrix::*)(Fvector &))(&Fmatrix::setXYZ), + // policy_list, out_value<2>>()) + .def( + "setXYZ", (Fmatrix & (Fmatrix::*)(float, float, float))(&Fmatrix::setXYZ), return_reference_to<1>()) + // .def("setXYZi", (Fmatrix & (Fmatrix::*)(Fvector + //&))(&Fmatrix::setXYZi), policy_list, out_value<2>>()) + .def("setXYZi", (Fmatrix & (Fmatrix::*)(float, float, float))(&Fmatrix::setXYZi), + return_reference_to<1>()) + // .def("getHPB", (void (Fmatrix::*)(Fvector &) + // const)(&Fmatrix::getHPB), out_value<2>()) + .def("getHPB", &get_matrix_hpb) // .def("getXYZ", (void (Fmatrix::*)(Fvector &) const)(&Fmatrix::getXYZ), // out_value<2>()) // .def("getXYZ", (void (Fmatrix::*)(float &, float &, float &) @@ -154,4 +155,4 @@ SCRIPT_EXPORT(Fmatrix, (), // .def("getXYZi", (void (Fmatrix::*)(float &, float &, float &) // const)(&Fmatrix::getXYZi)) ]; -}); +} diff --git a/src/xrServerEntities/script_fvector_script.cpp b/src/xrServerEntities/script_fvector_script.cpp index 14829498cc8..6ec407aead8 100644 --- a/src/xrServerEntities/script_fvector_script.cpp +++ b/src/xrServerEntities/script_fvector_script.cpp @@ -7,9 +7,10 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(Fvector, (), +#include "base_client_classes_wrappers.h" + +void CScriptFvector::script_register(lua_State* luaState) { using namespace luabind; using namespace luabind::policy; @@ -111,48 +112,21 @@ SCRIPT_EXPORT(Fvector, (), .def("getP", &Fvector::getP) .def("reflect", &Fvector::reflect, return_reference_to<1>()) - .def("slide", &Fvector::slide, return_reference_to<1>()) + .def("slide", &Fvector::slide, return_reference_to<1>()), // .def("generate_orthonormal_basis", &Fvector::generate_orthonormal_basis), - ]; -}); - -SCRIPT_EXPORT(Fvector2, (), -{ - using namespace luabind; - using namespace luabind::policy; - module(luaState) - [ class_("vector2") .def_readwrite("x", &Fvector2::x) .def_readwrite("y", &Fvector2::y) .def(constructor<>()) .def("set", (Fvector2 & (Fvector2::*)(float, float))(&Fvector2::set), return_reference_to<1>()) - .def("set", (Fvector2 & (Fvector2::*)(const Fvector2&))(&Fvector2::set), - return_reference_to<1>()) - ]; -}); + .def("set", (Fvector2 & (Fvector2::*)(const Fvector2&))(&Fvector2::set), return_reference_to<1>()), -SCRIPT_EXPORT(Fbox, (), -{ - using namespace luabind; - - module(luaState) - [ class_("Fbox") .def_readwrite("min", &Fbox::vMin) .def_readwrite("max", &Fbox::vMax) - .def(constructor<>()) - ]; -}); + .def(constructor<>()), -SCRIPT_EXPORT(Frect, (), -{ - using namespace luabind; - using namespace luabind::policy; - - module(luaState) - [ class_("Frect") .def(constructor<>()) .def("set", (Frect& (Frect::*)(float, float, float, float))(&Frect::set), return_reference_to<1>()) @@ -163,4 +137,4 @@ SCRIPT_EXPORT(Frect, (), .def_readwrite("y1", &Frect::y1) .def_readwrite("y2", &Frect::y2) ]; -}); +} diff --git a/src/xrServerEntities/script_ini_file.cpp b/src/xrServerEntities/script_ini_file.cpp index 0edb9798f17..e86054ae108 100644 --- a/src/xrServerEntities/script_ini_file.cpp +++ b/src/xrServerEntities/script_ini_file.cpp @@ -23,7 +23,7 @@ LPCSTR CScriptIniFile::update(LPCSTR initial, LPCSTR file_name) { string_path S1; FS.update_path(S1, initial, file_name); - return *shared_str(S1); + return shared_str(S1).c_str(); // XXX: dangling pointer } int CScriptIniFile::r_clsid(LPCSTR S, LPCSTR L) diff --git a/src/xrServerEntities/script_ini_file.h b/src/xrServerEntities/script_ini_file.h index e28df805941..426e5cda8a5 100644 --- a/src/xrServerEntities/script_ini_file.h +++ b/src/xrServerEntities/script_ini_file.h @@ -49,4 +49,7 @@ class CScriptIniFile : public CInifile void w_u8(pcstr S, pcstr L, u8 V, pcstr comment /* = nullptr */); bool save_as(pcstr new_fname /* = nullptr */); void remove_line(pcstr S, pcstr L); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; diff --git a/src/xrServerEntities/script_ini_file_script.cpp b/src/xrServerEntities/script_ini_file_script.cpp index d296b15b2a4..14c69099466 100644 --- a/src/xrServerEntities/script_ini_file_script.cpp +++ b/src/xrServerEntities/script_ini_file_script.cpp @@ -7,12 +7,10 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "script_ini_file.h" -#include "xrScriptEngine/ScriptExporter.hpp" #include "xrScriptEngine/Functor.hpp" -CScriptIniFile* get_system_ini() { return (CScriptIniFile*)pSettings; } - bool r_line(const CScriptIniFile* self, pcstr S, int L, luabind::string& N, luabind::string& V) { THROW3(self->section_exist(S), "Cannot find section", S); @@ -67,11 +65,7 @@ CScriptIniFile* reload_system_ini() } //Alundaio: END -#ifdef XRGAME_EXPORTS -CScriptIniFile* get_game_ini() { return (CScriptIniFile*)pGameIni; } -#endif - -static void CScriptIniFile_Export(lua_State* luaState) +void CScriptIniFile::script_register(lua_State* luaState) { using namespace luabind; using namespace luabind::policy; @@ -139,14 +133,22 @@ static void CScriptIniFile_Export(lua_State* luaState) // XXX: uncomment after we check that out_value policy is working //.def("r_line", &::r_line2, policy_list, out_value<5>>()) , -#ifdef XRGAME_EXPORTS - def("game_ini", &get_game_ini), -#endif - //Alundaio: extend + + def("system_ini", +[]() + { + return (CScriptIniFile*)pSettings; + }), + def("game_ini", +[]() + { + return (CScriptIniFile*)pGameIni; + }), + def("openxray_ini", +[]() + { + return (CScriptIniFile*)pSettingsOpenXRay; + }), + def("reload_system_ini", &reload_system_ini), - //Alundaio:: END - def("system_ini", &get_system_ini), def("create_ini_file", &create_ini_file, adopt<0>()) + + def("create_ini_file", &create_ini_file, adopt<0>()) ]; } - -SCRIPT_EXPORT_FUNC(CScriptIniFile, (), CScriptIniFile_Export); diff --git a/src/xrServerEntities/script_net_packet_script.cpp b/src/xrServerEntities/script_net_packet_script.cpp index cf2643552a1..2cbf48a1b6d 100644 --- a/src/xrServerEntities/script_net_packet_script.cpp +++ b/src/xrServerEntities/script_net_packet_script.cpp @@ -7,32 +7,13 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" -#include "xrServer_Object_Base.h" -#include "xrScriptEngine/ScriptExporter.hpp" -bool r_eof(NET_Packet* self) { return (!!self->r_eof()); } -pcstr r_stringZ(NET_Packet* self) -{ - shared_str temp; - self->r_stringZ(temp); - return (*temp); -} - -void w_bool(NET_Packet* self, bool value) { self->w_u8(value ? 1 : 0); } -bool r_bool(NET_Packet* self) { return (!!self->r_u8()); } - -ClientID r_clientID(NET_Packet* self) -{ - ClientID clientID; - self->r_clientID(clientID); - return clientID; -} +#include "base_client_classes_wrappers.h" -//extern u16 script_server_object_version(); - -SCRIPT_EXPORT(ClientID, (), +void CScriptNetPacket::script_register(lua_State* luaState) { using namespace luabind; + using namespace luabind::policy; module(luaState) [ @@ -40,18 +21,8 @@ SCRIPT_EXPORT(ClientID, (), .def(constructor<>()) .def("value", &ClientID::value) .def("set", &ClientID::set) - .def(self == other()) - ]; -}); - -SCRIPT_EXPORT(NET_Packet, (), -{ - using namespace luabind; - using namespace luabind::policy; + .def(self == other()), - module(luaState) - [ - def("script_server_object_version", &script_server_object_version), class_("net_packet") .def(constructor<>()) .def("w_begin", &NET_Packet::w_begin) @@ -68,7 +39,10 @@ SCRIPT_EXPORT(NET_Packet, (), .def("w_s16", &NET_Packet::w_s16) .def("w_u8", &NET_Packet::w_u8) // .def("w_s8", &NET_Packet::w_s8 ) - .def("w_bool", &w_bool) + .def("w_bool", +[](NET_Packet* self, bool value) + { + self->w_u8(value ? 1 : 0); + }) .def("w_float_q16", &NET_Packet::w_float_q16) .def("w_float_q8", &NET_Packet::w_float_q8) .def("w_angle16", &NET_Packet::w_angle16) @@ -88,7 +62,10 @@ SCRIPT_EXPORT(NET_Packet, (), .def("r_tell", &NET_Packet::r_tell) // XXX: used as r_vec3(vec) -- remove pure_out_value? .def("r_vec3", (void (NET_Packet::*)(Fvector&))(&NET_Packet::r_vec3), pure_out_value<2>()) - .def("r_bool", &r_bool) + .def("r_bool", +[](NET_Packet* self) + { + return (!!self->r_u8()); + }) .def("r_float", (float (NET_Packet::*)())(&NET_Packet::r_float)) .def("r_u64", (u64(NET_Packet::*)())(&NET_Packet::r_u64)) .def("r_s64", (s64(NET_Packet::*)())(&NET_Packet::r_s64)) @@ -103,11 +80,24 @@ SCRIPT_EXPORT(NET_Packet, (), .def("r_angle8", &NET_Packet::r_angle8, out_value<2>()) .def("r_dir", &NET_Packet::r_dir) .def("r_sdir", &NET_Packet::r_sdir) - .def("r_stringZ", &r_stringZ) + .def("r_stringZ", +[](NET_Packet* self) + { + shared_str temp; + self->r_stringZ(temp); + return (*temp); + }) .def("r_matrix", &NET_Packet::r_matrix) - .def("r_clientID", &r_clientID) + .def("r_clientID", +[](NET_Packet* self) + { + ClientID clientID; + self->r_clientID(clientID); + return clientID; + }) .def("r_elapsed", &NET_Packet::r_elapsed) .def("r_advance", &NET_Packet::r_advance) - .def("r_eof", &r_eof) + .def("r_eof", +[](NET_Packet* self) + { + return self->r_eof(); + }) ]; -}); +} diff --git a/src/xrServerEntities/script_properties_list_helper.cpp b/src/xrServerEntities/script_properties_list_helper.cpp index db17cf111ac..3b9a420b382 100644 --- a/src/xrServerEntities/script_properties_list_helper.cpp +++ b/src/xrServerEntities/script_properties_list_helper.cpp @@ -70,7 +70,7 @@ void CScriptPropertiesListHelper::FvectorRDOnDraw (PropValue* sender) { shared_str temp; PHelper().FvectorRDOnDraw(sender,temp); - draw_val = *temp; + draw_val = temp.c_str(); } */ @@ -89,7 +89,7 @@ void CScriptPropertiesListHelper::floatRDOnDraw (PropValue* sender, pcstr& dr { shared_str temp; PHelper().floatRDOnDraw(sender,temp); - draw_val = *temp; + draw_val = temp.c_str(); } */ @@ -97,7 +97,7 @@ bool CScriptPropertiesListHelper::NameAfterEdit(PropValue* sender, pcstr& edit_v { shared_str temp; bool result = PHelper().NameAfterEdit(sender, temp); - edit_val = *temp; + edit_val = temp.c_str(); return result; } @@ -105,7 +105,7 @@ void CScriptPropertiesListHelper::NameBeforeEdit(PropValue* sender, pcstr& edit_ { shared_str temp; PHelper().NameBeforeEdit(sender, temp); - edit_val = *temp; + edit_val = temp.c_str(); } /* @@ -113,7 +113,7 @@ void CScriptPropertiesListHelper::NameDraw (PropValue* sender, pcstr& draw_v { shared_str temp; PHelper().NameDraw(sender,temp); - draw_val = *temp; + draw_val = temp.c_str(); } */ diff --git a/src/xrServerEntities/script_properties_list_helper.h b/src/xrServerEntities/script_properties_list_helper.h index 5ed910c109e..c8ee3f3a38b 100644 --- a/src/xrServerEntities/script_properties_list_helper.h +++ b/src/xrServerEntities/script_properties_list_helper.h @@ -168,4 +168,7 @@ struct CScriptPropertiesListHelper // RTextValue* CreateNameCB (PropItemVec* items, pcstr key, luabind::object object, pcstr //name, // TOnDrawTextEvent=0, RTextValue::TOnBeforeEditEvent=0, RTextValue::TOnAfterEditEvent=0 + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; diff --git a/src/xrServerEntities/script_properties_list_helper_script.cpp b/src/xrServerEntities/script_properties_list_helper_script.cpp index 31c7811b7f6..2e95df8f763 100644 --- a/src/xrServerEntities/script_properties_list_helper_script.cpp +++ b/src/xrServerEntities/script_properties_list_helper_script.cpp @@ -12,7 +12,6 @@ #include "ai_space.h" #include "xrCore/ModuleLookup.hpp" #include "xrScriptEngine/script_engine.hpp" -#include "xrScriptEngine/ScriptExporter.hpp" #include "xrServerEntities/script_token_list.h" struct CChooseType @@ -57,7 +56,7 @@ IPropHelper& PHelper() return _PHelper(); } -SCRIPT_EXPORT(CScriptPropertiesListHelper, (), +void CScriptPropertiesListHelper::script_register(lua_State* luaState) { using namespace luabind; @@ -341,4 +340,4 @@ SCRIPT_EXPORT(CScriptPropertiesListHelper, (), return (g_property_list_helper); }) ]; -}); +} diff --git a/src/xrServerEntities/script_reader_script.cpp b/src/xrServerEntities/script_reader_script.cpp index 8e8d1e353a5..d00cfde5de9 100644 --- a/src/xrServerEntities/script_reader_script.cpp +++ b/src/xrServerEntities/script_reader_script.cpp @@ -7,9 +7,10 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(IReader, (), +#include "base_client_classes_wrappers.h" + +void CScriptReader::script_register(lua_State* luaState) { using namespace luabind; @@ -45,4 +46,4 @@ SCRIPT_EXPORT(IReader, (), .def("r_advance", &IReader::advance) .def("r_eof", &IReader::eof) ]; -}); +} diff --git a/src/xrServerEntities/script_rtoken_list.h b/src/xrServerEntities/script_rtoken_list.h index e2dcab6b8ee..84be8b27137 100644 --- a/src/xrServerEntities/script_rtoken_list.h +++ b/src/xrServerEntities/script_rtoken_list.h @@ -23,6 +23,9 @@ class CScriptRTokenList IC u32 size(); IC void clear(); IC RTOKEN_LIST& tokens(); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; #include "script_rtoken_list_inline.h" diff --git a/src/xrServerEntities/script_rtoken_list_inline.h b/src/xrServerEntities/script_rtoken_list_inline.h index 5440afffc6c..3af2bf45d85 100644 --- a/src/xrServerEntities/script_rtoken_list_inline.h +++ b/src/xrServerEntities/script_rtoken_list_inline.h @@ -20,7 +20,7 @@ IC LPCSTR CScriptRTokenList::get(u32 index) { if (index >= size()) return (nullptr); - return (*m_values[index]); + return m_values[index].c_str(); } IC u32 CScriptRTokenList::size() { return (u32(m_values.size())); } diff --git a/src/xrServerEntities/script_rtoken_list_script.cpp b/src/xrServerEntities/script_rtoken_list_script.cpp index c54347b93bc..1ffbe75a1a8 100644 --- a/src/xrServerEntities/script_rtoken_list_script.cpp +++ b/src/xrServerEntities/script_rtoken_list_script.cpp @@ -7,10 +7,10 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "script_rtoken_list.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CScriptRTokenList, (), +void CScriptRTokenList::script_register(lua_State* luaState) { using namespace luabind; @@ -24,4 +24,4 @@ SCRIPT_EXPORT(CScriptRTokenList, (), .def("count", &CScriptRTokenList::size) .def("get", &CScriptRTokenList::get) ]; -}); +} diff --git a/src/xrServerEntities/script_sound_type_script.cpp b/src/xrServerEntities/script_sound_type_script.cpp deleted file mode 100644 index ef45f9be2f6..00000000000 --- a/src/xrServerEntities/script_sound_type_script.cpp +++ /dev/null @@ -1,74 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// Module : script_sound_type_script.cpp -// Created : 28.06.2004 -// Modified : 28.06.2004 -// Author : Dmitriy Iassenev -// Description : Script sound type script export -//////////////////////////////////////////////////////////////////////////// - -#include "pch_script.h" -#include "ai_sounds.h" -#include "xrScriptEngine/ScriptExporter.hpp" - -SCRIPT_EXPORT(CScriptSoundType, (), -{ - using namespace luabind; - - class CScriptSoundType - { - }; - - module(luaState) - [ - class_("snd_type") - .enum_("sound_types") - [ - value("no_sound", int(SOUND_TYPE_NO_SOUND)), - value("weapon", int(SOUND_TYPE_WEAPON)), - value("item", int(SOUND_TYPE_ITEM)), - value("monster", int(SOUND_TYPE_MONSTER)), - value("anomaly", int(SOUND_TYPE_ANOMALY)), - value("world", int(SOUND_TYPE_WORLD)), - value("pick_up", int(SOUND_TYPE_PICKING_UP)), - value("drop", int(SOUND_TYPE_DROPPING)), - value("hide", int(SOUND_TYPE_HIDING)), - value("take", int(SOUND_TYPE_TAKING)), - value("use", int(SOUND_TYPE_USING)), - value("shoot", int(SOUND_TYPE_SHOOTING)), - value("empty", int(SOUND_TYPE_EMPTY_CLICKING)), - value("bullet_hit", int(SOUND_TYPE_BULLET_HIT)), - value("reload", int(SOUND_TYPE_RECHARGING)), - value("die", int(SOUND_TYPE_DYING)), - value("injure", int(SOUND_TYPE_INJURING)), - value("step", int(SOUND_TYPE_STEP)), - value("talk", int(SOUND_TYPE_TALKING)), - value("attack", int(SOUND_TYPE_ATTACKING)), - value("eat", int(SOUND_TYPE_EATING)), - value("idle", int(SOUND_TYPE_IDLE)), - value("object_break", int(SOUND_TYPE_OBJECT_BREAKING)), - value("object_collide", int(SOUND_TYPE_OBJECT_COLLIDING)), - value("object_explode", int(SOUND_TYPE_OBJECT_EXPLODING)), - value("ambient", int(SOUND_TYPE_AMBIENT)), - value("item_pick_up", int(SOUND_TYPE_ITEM_PICKING_UP)), - value("item_drop", int(SOUND_TYPE_ITEM_DROPPING)), - value("item_hide", int(SOUND_TYPE_ITEM_HIDING)), - value("item_take", int(SOUND_TYPE_ITEM_TAKING)), - value("item_use", int(SOUND_TYPE_ITEM_USING)), - value("weapon_shoot", int(SOUND_TYPE_WEAPON_SHOOTING)), - value("weapon_empty", int(SOUND_TYPE_WEAPON_EMPTY_CLICKING)), - value("weapon_bullet_hit", int(SOUND_TYPE_WEAPON_BULLET_HIT)), - value("weapon_reload", int(SOUND_TYPE_WEAPON_RECHARGING)), - value("monster_die", int(SOUND_TYPE_MONSTER_DYING)), - value("monster_injure", int(SOUND_TYPE_MONSTER_INJURING)), - value("monster_step", int(SOUND_TYPE_MONSTER_STEP)), - value("monster_talk", int(SOUND_TYPE_MONSTER_TALKING)), - value("monster_attack", int(SOUND_TYPE_MONSTER_ATTACKING)), - value("monster_eat", int(SOUND_TYPE_MONSTER_EATING)), - value("anomaly_idle", int(SOUND_TYPE_ANOMALY_IDLE)), - value("world_object_break", int(SOUND_TYPE_WORLD_OBJECT_BREAKING)), - value("world_object_collide", int(SOUND_TYPE_WORLD_OBJECT_COLLIDING)), - value("world_object_explode", int(SOUND_TYPE_WORLD_OBJECT_EXPLODING)), - value("world_ambient", int(SOUND_TYPE_WORLD_AMBIENT)) - ] - ]; -}); diff --git a/src/xrServerEntities/script_token_list.h b/src/xrServerEntities/script_token_list.h index 28eea73466f..bb6174517f8 100644 --- a/src/xrServerEntities/script_token_list.h +++ b/src/xrServerEntities/script_token_list.h @@ -50,4 +50,7 @@ class CScriptTokenList pcstr name(int id); const TOKEN_LIST& tokens() const noexcept { return m_token_list; } TOKEN_LIST& tokens() noexcept { return m_token_list; } + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; diff --git a/src/xrServerEntities/script_token_list_script.cpp b/src/xrServerEntities/script_token_list_script.cpp index 468268ef4e6..0c7fe41bc45 100644 --- a/src/xrServerEntities/script_token_list_script.cpp +++ b/src/xrServerEntities/script_token_list_script.cpp @@ -7,10 +7,10 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "script_token_list.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CScriptTokenList, (), +void CScriptTokenList::script_register(lua_State* luaState) { using namespace luabind; @@ -28,4 +28,4 @@ SCRIPT_EXPORT(CScriptTokenList, (), .def("clear", &CScriptTokenList::clear) .def("id", &CScriptTokenList::id) .def("name", &CScriptTokenList::name)]; -}); +} diff --git a/src/xrServerEntities/script_value_wrapper.h b/src/xrServerEntities/script_value_wrapper.h index 710959d7fd6..bf70ad3937e 100644 --- a/src/xrServerEntities/script_value_wrapper.h +++ b/src/xrServerEntities/script_value_wrapper.h @@ -50,7 +50,7 @@ class CScriptValueWrapperImpl : public CScriptValue m_value = luabind::object_cast(object[name]); } - virtual void assign() { m_object[*m_name] = !!m_value; } + virtual void assign() { m_object[m_name.c_str()] = !!m_value; } virtual BOOL* value() { return (&m_value); } }; @@ -71,9 +71,9 @@ class CScriptValueWrapperImpl : public CScriptValue virtual void assign() { - if (!*m_value) + if (!m_value.c_str()) m_value = shared_str(""); - m_object[*m_name] = *m_value; + m_object[m_name.c_str()] = m_value.c_str(); } virtual shared_str* value() { return (&m_value); } diff --git a/src/xrServerEntities/script_value_wrapper_inline.h b/src/xrServerEntities/script_value_wrapper_inline.h index c9600211d76..931ec2e8604 100644 --- a/src/xrServerEntities/script_value_wrapper_inline.h +++ b/src/xrServerEntities/script_value_wrapper_inline.h @@ -18,7 +18,7 @@ IC CScriptValueWrapperImpl::CScriptValueWrapperImpl(luabind::object object, L template IC void CScriptValueWrapperImpl::assign() { - m_object[*m_name] = m_value; + m_object[m_name.c_str()] = m_value; } template diff --git a/src/xrServerEntities/specific_character.cpp b/src/xrServerEntities/specific_character.cpp index 825568a2475..080a77b5a53 100644 --- a/src/xrServerEntities/specific_character.cpp +++ b/src/xrServerEntities/specific_character.cpp @@ -1,24 +1,8 @@ #include "StdAfx.h" #include "specific_character.h" -#ifdef XRGAME_EXPORTS #include "PhraseDialog.h" -SSpecificCharacterData::SSpecificCharacterData() -{ - m_sGameName.clear(); - m_sVisual.clear(); - m_sSupplySpawn.clear(); - m_sNpcConfigSect.clear(); - - m_ActorDialogs.clear(); -} - -SSpecificCharacterData::~SSpecificCharacterData() {} -#endif - -CSpecificCharacter::CSpecificCharacter() { m_OwnId = nullptr; } -CSpecificCharacter::~CSpecificCharacter() {} void CSpecificCharacter::InitXmlIdToIndex() { if (!id_to_index::tag_name) @@ -47,7 +31,7 @@ void CSpecificCharacter::load_shared(LPCSTR) pXML->SetLocalRoot(pXML->GetRoot()); XML_NODE item_node = pXML->NavigateToNode(id_to_index::tag_name, item_data.pos_in_file); - R_ASSERT3(item_node, "specific_character id=", *item_data.id); + R_ASSERT3(item_node, "specific_character id=", item_data.id.c_str()); pXML->SetLocalRoot(item_node); @@ -64,9 +48,7 @@ void CSpecificCharacter::load_shared(LPCSTR) data()->m_bDefaultForCommunity = false; R_ASSERT3(!(data()->m_bNoRandom && data()->m_bDefaultForCommunity), - "cannot set 'no_random' and 'team_default' flags simultaneously, profile id", *shared_str(item_data.id)); - -#ifdef XRGAME_EXPORTS + "cannot set 'no_random' and 'team_default' flags simultaneously, profile id", shared_str(item_data.id).c_str()); LPCSTR start_dialog = pXML->Read("start_dialog", 0, NULL); if (start_dialog) @@ -97,11 +79,8 @@ void CSpecificCharacter::load_shared(LPCSTR) data()->m_critical_wound_weights = pXML->Read("critical_wound_weights", 0, "1"); -#endif - data()->m_sVisual = pXML->Read("visual", 0, ""); -#ifdef XRGAME_EXPORTS data()->m_sSupplySpawn = pXML->Read("supplies", 0, ""); if (!data()->m_sSupplySpawn.empty()) @@ -121,8 +100,6 @@ void CSpecificCharacter::load_shared(LPCSTR) data()->m_terrain_sect = pXML->Read("terrain_sect", 0, ""); -#endif - data()->m_Classes.clear(); int classes_num = pXML->GetNodesNum(pXML->GetLocalRoot(), "class"); for (int i = 0; i < classes_num; i++) @@ -137,10 +114,8 @@ void CSpecificCharacter::load_shared(LPCSTR) } } -#ifdef XRGAME_EXPORTS - LPCSTR team = pXML->Read("community", 0, NULL); - R_ASSERT3(team != NULL, "'community' field not fulfiled for specific character", *m_OwnId); + R_ASSERT3(team != NULL, "'community' field not fulfiled for specific character", m_OwnId.c_str()); char* buf_str = xr_strdup(team); xr_strlwr(buf_str); @@ -148,13 +123,13 @@ void CSpecificCharacter::load_shared(LPCSTR) xr_free(buf_str); if (data()->m_Community.index() == NO_COMMUNITY_INDEX) - xrDebug::Fatal(DEBUG_INFO, "wrong 'community' '%s' in specific character %s ", team, *m_OwnId); + xrDebug::Fatal(DEBUG_INFO, "wrong 'community' '%s' in specific character %s ", team, m_OwnId.c_str()); data()->m_Rank = pXML->ReadInt("rank", 0, NO_RANK); - R_ASSERT3(data()->m_Rank != NO_RANK, "'rank' field not fulfiled for specific character", *m_OwnId); + R_ASSERT3(data()->m_Rank != NO_RANK, "'rank' field not fulfiled for specific character", m_OwnId.c_str()); data()->m_Reputation = pXML->ReadInt("reputation", 0, NO_REPUTATION); R_ASSERT3( - data()->m_Reputation != NO_REPUTATION, "'reputation' field not fulfiled for specific character", *m_OwnId); + data()->m_Reputation != NO_REPUTATION, "'reputation' field not fulfiled for specific character", m_OwnId.c_str()); if (pXML->NavigateToNode(pXML->GetLocalRoot(), "money", 0)) { @@ -170,15 +145,11 @@ void CSpecificCharacter::load_shared(LPCSTR) MoneyDef().inf_money = false; } -#endif - #if 0 Msg ("CSpecificCharacter::load_shared() takes %f milliseconds",timer.GetElapsed_sec()*1000.f); #endif } -#ifdef XRGAME_EXPORTS - LPCSTR CSpecificCharacter::Name() const { return data()->m_sGameName.c_str(); } shared_str CSpecificCharacter::Bio() const { return data()->m_sBioText; } const CHARACTER_COMMUNITY& CSpecificCharacter::Community() const { return data()->m_Community; } @@ -190,7 +161,6 @@ float CSpecificCharacter::hit_probability_factor() const { return data()->m_fHit int CSpecificCharacter::crouch_type() const { return data()->m_crouch_type; } bool CSpecificCharacter::upgrade_mechanic() const { return data()->m_upgrade_mechanic; } LPCSTR CSpecificCharacter::critical_wound_weights() const { return data()->m_critical_wound_weights.c_str(); } -#endif shared_str CSpecificCharacter::terrain_sect() const { return data()->m_terrain_sect; } CHARACTER_RANK_VALUE CSpecificCharacter::Rank() const { return data()->m_Rank; } diff --git a/src/xrServerEntities/specific_character.h b/src/xrServerEntities/specific_character.h index c635951609d..3b89b02d323 100644 --- a/src/xrServerEntities/specific_character.h +++ b/src/xrServerEntities/specific_character.h @@ -9,23 +9,14 @@ #include "shared_data.h" #include "xml_str_id_loader.h" -#ifdef XRGAME_EXPORTS - #include "PhraseDialogDefs.h" #include "character_community.h" -#endif - ////////////////////////////////////////////////////////////////////////// // SSpecificCharacterData: данные о конкретном перÑонаже ////////////////////////////////////////////////////////////////////////// struct SSpecificCharacterData : CSharedResource { -#ifdef XRGAME_EXPORTS - - SSpecificCharacterData(); - virtual ~SSpecificCharacterData(); - //игровое Ð¸Ð¼Ñ Ð¿ÐµÑ€Ñонажа xr_string m_sGameName; //текÑÑ‚ Ñ Ð±Ð¸Ð¾Ð³Ñ€Ð°Ñ„Ð¸ÐµÐ¹ перÑонажа (линк на string table) @@ -43,14 +34,12 @@ struct SSpecificCharacterData : CSharedResource bool m_upgrade_mechanic{}; xr_string m_critical_wound_weights; -#endif + shared_str m_terrain_sect; //Ð¸Ð¼Ñ Ð¼Ð¾Ð´ÐµÐ»Ð¸ xr_string m_sVisual; -#ifdef XRGAME_EXPORTS - //начальный диалог shared_str m_StartDialog; //диалоги актера, которые будут доÑтупны только при вÑтрече Ñ Ð´Ð°Ð½Ð½Ñ‹Ð¼ перÑонажем @@ -60,8 +49,6 @@ struct SSpecificCharacterData : CSharedResource //команда CHARACTER_COMMUNITY m_Community; -#endif - //ранг CHARACTER_RANK_VALUE m_Rank{ NO_RANK }; //Ñ€ÐµÐ¿ÑƒÑ‚Ð°Ñ†Ð¸Ñ @@ -76,7 +63,7 @@ struct SSpecificCharacterData : CSharedResource bool m_bNoRandom{}; //еÑли перÑонаж ÑвлÑетÑÑ Ð·Ð°Ð´Ð°Ð½Ñ‹Ð¼ по умолчанию Ð´Ð»Ñ Ñвоей команды bool m_bDefaultForCommunity{}; -#ifdef XRGAME_EXPORTS + struct SMoneyDef { u32 min_money; @@ -84,7 +71,6 @@ struct SSpecificCharacterData : CSharedResource bool inf_money; }; SMoneyDef money_def; -#endif }; class CInventoryOwner; @@ -104,9 +90,6 @@ class CSpecificCharacter : public CSharedClassmoney_def; } -#endif CHARACTER_RANK_VALUE Rank() const; CHARACTER_REPUTATION_VALUE Reputation() const; LPCSTR Visual() const; -#ifdef XRGAME_EXPORTS LPCSTR SupplySpawn() const; LPCSTR NpcConfigSect() const; LPCSTR sound_voice_prefix() const; @@ -150,7 +130,7 @@ class CSpecificCharacter : public CSharedClassm_icon_name; }; -#endif + shared_str terrain_sect() const; }; diff --git a/src/xrServerEntities/xml_str_id_loader.h b/src/xrServerEntities/xml_str_id_loader.h index 667442cc3dc..cae5c5fe298 100644 --- a/src/xrServerEntities/xml_str_id_loader.h +++ b/src/xrServerEntities/xml_str_id_loader.h @@ -1,11 +1,8 @@ #pragma once -#ifdef XRGAME_EXPORTS -#include "xrUICore/XML/xrUIXmlParser.h" -#else // XRGAME_EXPORTS -#include "xrUIXmlParser.h" #include "Common/object_broker.h" -#endif // XRGAME_EXPORTS + +#include "xrUICore/XML/xrUIXmlParser.h" // T_INIT - клаÑÑ Ð³Ð´Ðµ определена ÑтатичеÑÐºÐ°Ñ InitXmlIdToIndex // Ñ„ÑƒÐ½ÐºÑ†Ð¸Ñ Ð¸Ð½Ð¸Ñ†Ð¸Ð°Ð»Ð¸Ð·Ð°Ñ†Ð¸Ð¸ file_str и tag_name @@ -90,7 +87,7 @@ const ITEM_DATA* CSXML_IdToIndex::GetById(const shared_str& str_id, bool no_asse Msg("[%d]=[%s]", i, *(*it).id); #endif - R_ASSERT3(no_assert, "item not found, id", *str_id); + R_ASSERT3(no_assert, "item not found, id", str_id.c_str()); return nullptr; } diff --git a/src/xrServerEntities/xrServer_Object_Base.cpp b/src/xrServerEntities/xrServer_Object_Base.cpp index 58f295c11b3..b749292361d 100644 --- a/src/xrServerEntities/xrServer_Object_Base.cpp +++ b/src/xrServerEntities/xrServer_Object_Base.cpp @@ -146,7 +146,7 @@ CInifile& CSE_Abstract::spawn_ini() #pragma warning(push) #pragma warning(disable : 4238) // XXX: what a casting mess.. Do we need to use shared_str for m_ini_string? - IReader reader((void*)(*(m_ini_string)), m_ini_string.size()); + IReader reader((void*)m_ini_string.c_str(), m_ini_string.size()); m_ini_file = xr_new(&reader, FS.get_path(_game_config_)->m_Path); #pragma warning(pop) } @@ -354,7 +354,7 @@ void CSE_Abstract::load(NET_Packet& tNetPacket) CSE_Abstract* CSE_Abstract::base() { return (this); } const CSE_Abstract* CSE_Abstract::base() const { return (this); } CSE_Abstract* CSE_Abstract::init() { return (this); } -LPCSTR CSE_Abstract::name() const { return (*s_name); } +LPCSTR CSE_Abstract::name() const { return s_name.c_str(); } LPCSTR CSE_Abstract::name_replace() const { return (s_name_replace); } Fvector& CSE_Abstract::position() { return (o_Position); } Fvector& CSE_Abstract::angle() { return (o_Angle); } diff --git a/src/xrServerEntities/xrServer_Object_Base.h b/src/xrServerEntities/xrServer_Object_Base.h index a2ebc1f73cb..dfc8692b3e9 100644 --- a/src/xrServerEntities/xrServer_Object_Base.h +++ b/src/xrServerEntities/xrServer_Object_Base.h @@ -48,6 +48,9 @@ class CPureServerObject : public IPureServerObject virtual void save(IWriter& tMemoryStream); virtual void load(NET_Packet& tNetPacket); virtual void save(NET_Packet& tNetPacket); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; class CSE_Abstract : public IServerEntity, public CPureServerObject, public CScriptValueContainer @@ -182,6 +185,9 @@ class CSE_Abstract : public IServerEntity, public CPureServerObject, public CScr virtual CSE_ALifeSmartZone* cast_smart_zone() { return nullptr; } virtual CSE_ALifeOnlineOfflineGroup* cast_online_offline_group() { return nullptr; } virtual CSE_ALifeItemPDA* cast_item_pda() { return nullptr; } + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CPureServerObject); }; extern u16 script_server_object_version(); diff --git a/src/xrServerEntities/xrServer_Objects.cpp b/src/xrServerEntities/xrServer_Objects.cpp index 13871ee38e1..ccae2a9e0c8 100644 --- a/src/xrServerEntities/xrServer_Objects.cpp +++ b/src/xrServerEntities/xrServer_Objects.cpp @@ -250,5 +250,5 @@ void CSE_AbstractVisual::FillProps(LPCSTR pref, PropItemVec& values) void CSE_AbstractVisual::UPDATE_Read(NET_Packet& tNetPacket) {} void CSE_AbstractVisual::UPDATE_Write(NET_Packet& tNetPacket) {} -LPCSTR CSE_AbstractVisual::getStartupAnimation() { return *startup_animation; } +pcstr CSE_AbstractVisual::getStartupAnimation() const { return startup_animation.c_str(); } CSE_Visual* CSE_AbstractVisual::visual() { return this; } diff --git a/src/xrServerEntities/xrServer_Objects.h b/src/xrServerEntities/xrServer_Objects.h index 7aae990b771..e7114c498a1 100644 --- a/src/xrServerEntities/xrServer_Objects.h +++ b/src/xrServerEntities/xrServer_Objects.h @@ -179,6 +179,9 @@ class CSE_Shape : public IServerEntityShape, public CShapeData virtual ~CSE_Shape(); virtual IServerEntityShape* shape() = 0; virtual void assign_shapes(CShapeData::shape_def* shapes, u32 cnt); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; class CSE_Spectator : public CSE_Abstract @@ -194,6 +197,9 @@ class CSE_Spectator : public CSE_Abstract virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_Abstract); }; class CSE_Temporary : public CSE_Abstract @@ -209,6 +215,9 @@ class CSE_Temporary : public CSE_Abstract virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_Abstract); }; class CSE_PHSkeleton @@ -242,6 +251,9 @@ class CSE_PHSkeleton virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; class CSE_AbstractVisual : public CSE_Abstract, public CSE_Visual @@ -251,14 +263,17 @@ class CSE_AbstractVisual : public CSE_Abstract, public CSE_Visual using inherited2 = CSE_Visual; CSE_AbstractVisual(LPCSTR caSection); - virtual ~CSE_AbstractVisual(); + virtual ~CSE_AbstractVisual(); virtual CSE_Visual* visual(); - LPCSTR getStartupAnimation(); - virtual void UPDATE_Read(NET_Packet& P); - virtual void UPDATE_Write(NET_Packet& P); - virtual void STATE_Read(NET_Packet& P, u16 size); - virtual void STATE_Write(NET_Packet& P); + pcstr getStartupAnimation() const; + virtual void UPDATE_Read(NET_Packet& P); + virtual void UPDATE_Write(NET_Packet& P); + virtual void STATE_Read(NET_Packet& P, u16 size); + virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_Visual, CSE_Abstract); }; #ifndef AI_COMPILER diff --git a/src/xrServerEntities/xrServer_Objects_ALife.cpp b/src/xrServerEntities/xrServer_Objects_ALife.cpp index 3c4df27525a..272d0690a61 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife.cpp @@ -172,8 +172,12 @@ void SFillPropData::load() std::sort(character_profiles.begin(), character_profiles.end(), SortStringsByAlphabetPred); #endif // AI_COMPILER - luabind::object table; + if (ShadowOfChernobylMode) { + Msg("![ERROR] SHADOW OF CHERNOBYL DOESN'T HAVE this smart_covers.descriptions!!!"); + return; + } + luabind::object table; R_ASSERT(GEnv.ScriptEngine->function_object("smart_covers.descriptions", table, LUA_TTABLE)); for (luabind::iterator I(table), E; I != E; ++I) @@ -219,10 +223,10 @@ SFillPropData fp_data; #ifndef MASTER_GOLD void CSE_ALifeTraderAbstract::FillProps(LPCSTR pref, PropItemVec& items) { - PHelper().CreateU32(items, PrepareKey(pref, *base()->s_name, "Money"), &m_dwMoney, 0, u32(-1)); - PHelper().CreateFlag32(items, PrepareKey(pref, *base()->s_name, "Trader" DELIMITER "Infinite ammo"), + PHelper().CreateU32(items, PrepareKey(pref, base()->s_name.c_str(), "Money"), &m_dwMoney, 0, u32(-1)); + PHelper().CreateFlag32(items, PrepareKey(pref, base()->s_name.c_str(), "Trader" DELIMITER "Infinite ammo"), &m_trader_flags, eTraderFlagInfiniteAmmo); - RListValue* value = PHelper().CreateRList(items, PrepareKey(pref, *base()->s_name, "npc profile"), + RListValue* value = PHelper().CreateRList(items, PrepareKey(pref, base()->s_name.c_str(), "npc profile"), &m_sCharacterProfile, &*fp_data.character_profiles.begin(), fp_data.character_profiles.size()); value->OnChangeEvent.bind(this, &CSE_ALifeTraderAbstract::OnChangeProfile); @@ -279,17 +283,17 @@ void CSE_ALifeGraphPoint::UPDATE_Write(NET_Packet& /*tNetPacket*/) {} #ifndef MASTER_GOLD void CSE_ALifeGraphPoint::FillProps(LPCSTR pref, PropItemVec& items) { - PHelper().CreateRToken8(items, PrepareKey(pref, *s_name, "Location" DELIMITER "1"), &m_tLocations[0], + PHelper().CreateRToken8(items, PrepareKey(pref, s_name.c_str(), "Location" DELIMITER "1"), &m_tLocations[0], &*fp_data.locations[0].begin(), fp_data.locations[0].size()); - PHelper().CreateRToken8(items, PrepareKey(pref, *s_name, "Location" DELIMITER "2"), &m_tLocations[1], + PHelper().CreateRToken8(items, PrepareKey(pref, s_name.c_str(), "Location" DELIMITER "2"), &m_tLocations[1], &*fp_data.locations[1].begin(), fp_data.locations[1].size()); - PHelper().CreateRToken8(items, PrepareKey(pref, *s_name, "Location" DELIMITER "3"), &m_tLocations[2], + PHelper().CreateRToken8(items, PrepareKey(pref, s_name.c_str(), "Location" DELIMITER "3"), &m_tLocations[2], &*fp_data.locations[2].begin(), fp_data.locations[2].size()); - PHelper().CreateRToken8(items, PrepareKey(pref, *s_name, "Location" DELIMITER "4"), &m_tLocations[3], + PHelper().CreateRToken8(items, PrepareKey(pref, s_name.c_str(), "Location" DELIMITER "4"), &m_tLocations[3], &*fp_data.locations[3].begin(), fp_data.locations[3].size()); - PHelper().CreateRList(items, PrepareKey(pref, *s_name, "Connection" DELIMITER "Level name"), &m_caConnectionLevelName, + PHelper().CreateRList(items, PrepareKey(pref, s_name.c_str(), "Connection" DELIMITER "Level name"), &m_caConnectionLevelName, &*fp_data.level_ids.begin(), fp_data.level_ids.size()); - PHelper().CreateRText(items, PrepareKey(pref, *s_name, "Connection" DELIMITER "Point name"), &m_caConnectionPointName); + PHelper().CreateRText(items, PrepareKey(pref, s_name.c_str(), "Connection" DELIMITER "Point name"), &m_caConnectionPointName); } void CSE_ALifeGraphPoint::on_render(CDUInterface* du, IServerEntityLEOwner* owner, @@ -470,18 +474,18 @@ void CSE_ALifeObject::UPDATE_Read(NET_Packet& /*tNetPacket*/) {}; void CSE_ALifeObject::FillProps(LPCSTR pref, PropItemVec& items) { inherited::FillProps(pref, items); - PHelper().CreateRText(items, PrepareKey(pref, *s_name, "Custom data"), &m_ini_string); + PHelper().CreateRText(items, PrepareKey(pref, s_name.c_str(), "Custom data"), &m_ini_string); if (m_flags.is(flUseSwitches)) { - PHelper().CreateFlag32(items, PrepareKey(pref, *s_name, "ALife" DELIMITER "Can switch online"), &m_flags, flSwitchOnline); + PHelper().CreateFlag32(items, PrepareKey(pref, s_name.c_str(), "ALife" DELIMITER "Can switch online"), &m_flags, flSwitchOnline); PHelper().CreateFlag32( - items, PrepareKey(pref, *s_name, "ALife" DELIMITER "Can switch offline"), &m_flags, flSwitchOffline); + items, PrepareKey(pref, s_name.c_str(), "ALife" DELIMITER "Can switch offline"), &m_flags, flSwitchOffline); } - PHelper().CreateFlag32(items, PrepareKey(pref, *s_name, "ALife" DELIMITER "Interactive"), &m_flags, flInteractive); - PHelper().CreateFlag32(items, PrepareKey(pref, *s_name, "ALife" DELIMITER "Used AI locations"), &m_flags, flUsedAI_Locations); - PHelper().CreateRToken32(items, PrepareKey(pref, *s_name, "ALife" DELIMITER "Story ID"), &m_story_id, + PHelper().CreateFlag32(items, PrepareKey(pref, s_name.c_str(), "ALife" DELIMITER "Interactive"), &m_flags, flInteractive); + PHelper().CreateFlag32(items, PrepareKey(pref, s_name.c_str(), "ALife" DELIMITER "Used AI locations"), &m_flags, flUsedAI_Locations); + PHelper().CreateRToken32(items, PrepareKey(pref, s_name.c_str(), "ALife" DELIMITER "Story ID"), &m_story_id, &*fp_data.story_names.begin(), fp_data.story_names.size()); - PHelper().CreateRToken32(items, PrepareKey(pref, *s_name, "ALife" DELIMITER "Spawn Story ID"), &m_spawn_story_id, + PHelper().CreateRToken32(items, PrepareKey(pref, s_name.c_str(), "ALife" DELIMITER "Spawn Story ID"), &m_spawn_story_id, &*fp_data.spawn_story_names.begin(), fp_data.spawn_story_names.size()); } #endif // #ifndef MASTER_GOLD @@ -729,8 +733,8 @@ void CSE_ALifeSpaceRestrictor::FillProps(LPCSTR pref, PropItemVec& items) { inherited1::FillProps(pref, items); PHelper().CreateToken8( - items, PrepareKey(pref, *s_name, "restrictor type"), &m_space_restrictor_type, defaul_retrictor_types); - PHelper().CreateFlag32(items, PrepareKey(pref, *s_name, "check for separator"), &m_flags, flCheckForSeparator); + items, PrepareKey(pref, s_name.c_str(), "restrictor type"), &m_space_restrictor_type, defaul_retrictor_types); + PHelper().CreateFlag32(items, PrepareKey(pref, s_name.c_str(), "check for separator"), &m_flags, flCheckForSeparator); } #endif // #ifndef MASTER_GOLD @@ -804,11 +808,11 @@ void CSE_ALifeLevelChanger::FillProps(LPCSTR pref, PropItemVec& items) { inherited::FillProps(pref, items); - PHelper().CreateRList(items, PrepareKey(pref, *s_name, "Level to change"), &m_caLevelToChange, + PHelper().CreateRList(items, PrepareKey(pref, s_name.c_str(), "Level to change"), &m_caLevelToChange, &*fp_data.level_ids.begin(), fp_data.level_ids.size()); - PHelper().CreateRText(items, PrepareKey(pref, *s_name, "Level point to change"), &m_caLevelPointToChange); + PHelper().CreateRText(items, PrepareKey(pref, s_name.c_str(), "Level point to change"), &m_caLevelPointToChange); - PHelper().CreateBOOL(items, PrepareKey(pref, *s_name, "Silent mode"), &m_bSilentMode); + PHelper().CreateBOOL(items, PrepareKey(pref, s_name.c_str(), "Silent mode"), &m_bSilentMode); } #endif // #ifndef MASTER_GOLD @@ -1108,12 +1112,12 @@ void CSE_ALifeObjectPhysic::FillProps(LPCSTR pref, PropItemVec& values) inherited1::FillProps(pref, values); inherited2::FillProps(pref, values); - PHelper().CreateToken32(values, PrepareKey(pref, *s_name, "Type"), &type, po_types); - PHelper().CreateFloat(values, PrepareKey(pref, *s_name, "Mass"), &mass, 0.1f, 10000.f); - PHelper().CreateFlag8(values, PrepareKey(pref, *s_name, "Active"), &_flags, flActive); + PHelper().CreateToken32(values, PrepareKey(pref, s_name.c_str(), "Type"), &type, po_types); + PHelper().CreateFloat(values, PrepareKey(pref, s_name.c_str(), "Mass"), &mass, 0.1f, 10000.f); + PHelper().CreateFlag8(values, PrepareKey(pref, s_name.c_str(), "Active"), &_flags, flActive); // motions & bones - PHelper().CreateChoose(values, PrepareKey(pref, *s_name, "Model" DELIMITER "Fixed bones"), &fixed_bones, smSkeletonBones, nullptr, + PHelper().CreateChoose(values, PrepareKey(pref, s_name.c_str(), "Model" DELIMITER "Fixed bones"), &fixed_bones, smSkeletonBones, nullptr, (void*)visual()->get_visual(), 8); } #endif // #ifndef MASTER_GOLD @@ -1293,63 +1297,63 @@ void CSE_ALifeObjectHangingLamp::FillProps(LPCSTR pref, PropItemVec& values) inherited2::FillProps(pref, values); PropValue* P = nullptr; - PHelper().CreateFlag16(values, PrepareKey(pref, *s_name, "Flags" DELIMITER "Physic"), &flags, flPhysic); - PHelper().CreateFlag16(values, PrepareKey(pref, *s_name, "Flags" DELIMITER "Cast Shadow"), &flags, flCastShadow); - PHelper().CreateFlag16(values, PrepareKey(pref, *s_name, "Flags" DELIMITER "Allow R1"), &flags, flR1); - PHelper().CreateFlag16(values, PrepareKey(pref, *s_name, "Flags" DELIMITER "Allow R2"), &flags, flR2); - P = PHelper().CreateFlag16(values, PrepareKey(pref, *s_name, "Flags" DELIMITER "Allow Ambient"), &flags, flPointAmbient); + PHelper().CreateFlag16(values, PrepareKey(pref, s_name.c_str(), "Flags" DELIMITER "Physic"), &flags, flPhysic); + PHelper().CreateFlag16(values, PrepareKey(pref, s_name.c_str(), "Flags" DELIMITER "Cast Shadow"), &flags, flCastShadow); + PHelper().CreateFlag16(values, PrepareKey(pref, s_name.c_str(), "Flags" DELIMITER "Allow R1"), &flags, flR1); + PHelper().CreateFlag16(values, PrepareKey(pref, s_name.c_str(), "Flags" DELIMITER "Allow R2"), &flags, flR2); + P = PHelper().CreateFlag16(values, PrepareKey(pref, s_name.c_str(), "Flags" DELIMITER "Allow Ambient"), &flags, flPointAmbient); P->OnChangeEvent.bind(this, &CSE_ALifeObjectHangingLamp::OnChangeFlag); // - P = PHelper().CreateFlag16(values, PrepareKey(pref, *s_name, "Light" DELIMITER "Type"), &flags, flTypeSpot, "Point", "Spot"); + P = PHelper().CreateFlag16(values, PrepareKey(pref, s_name.c_str(), "Light" DELIMITER "Type"), &flags, flTypeSpot, "Point", "Spot"); P->OnChangeEvent.bind(this, &CSE_ALifeObjectHangingLamp::OnChangeFlag); - PHelper().CreateColor(values, PrepareKey(pref, *s_name, "Light" DELIMITER "Main" DELIMITER "Color"), &color); - PHelper().CreateFloat(values, PrepareKey(pref, *s_name, "Light" DELIMITER "Main" DELIMITER "Brightness"), &brightness, 0.1f, 5.f); - PHelper().CreateChoose(values, PrepareKey(pref, *s_name, "Light" DELIMITER "Main" DELIMITER "Color Animator"), &color_animator, smLAnim); - PHelper().CreateFloat(values, PrepareKey(pref, *s_name, "Light" DELIMITER "Main" DELIMITER "Range"), &range, 0.1f, 1000.f); - PHelper().CreateFloat(values, PrepareKey(pref, *s_name, "Light" DELIMITER "Main" DELIMITER "Virtual Size"), &m_virtual_size, 0.f, 100.f); + PHelper().CreateColor(values, PrepareKey(pref, s_name.c_str(), "Light" DELIMITER "Main" DELIMITER "Color"), &color); + PHelper().CreateFloat(values, PrepareKey(pref, s_name.c_str(), "Light" DELIMITER "Main" DELIMITER "Brightness"), &brightness, 0.1f, 5.f); + PHelper().CreateChoose(values, PrepareKey(pref, s_name.c_str(), "Light" DELIMITER "Main" DELIMITER "Color Animator"), &color_animator, smLAnim); + PHelper().CreateFloat(values, PrepareKey(pref, s_name.c_str(), "Light" DELIMITER "Main" DELIMITER "Range"), &range, 0.1f, 1000.f); + PHelper().CreateFloat(values, PrepareKey(pref, s_name.c_str(), "Light" DELIMITER "Main" DELIMITER "Virtual Size"), &m_virtual_size, 0.f, 100.f); PHelper().CreateChoose( - values, PrepareKey(pref, *s_name, "Light" DELIMITER "Main" DELIMITER "Texture"), &light_texture, smTexture, "lights"); - PHelper().CreateChoose(values, PrepareKey(pref, *s_name, "Light" DELIMITER "Main" DELIMITER "Bone"), &light_main_bone, smSkeletonBones, nullptr, + values, PrepareKey(pref, s_name.c_str(), "Light" DELIMITER "Main" DELIMITER "Texture"), &light_texture, smTexture, "lights"); + PHelper().CreateChoose(values, PrepareKey(pref, s_name.c_str(), "Light" DELIMITER "Main" DELIMITER "Bone"), &light_main_bone, smSkeletonBones, nullptr, (void*)visual()->get_visual()); if (flags.is(flTypeSpot)) { PHelper().CreateAngle( - values, PrepareKey(pref, *s_name, "Light" DELIMITER "Main" DELIMITER "Cone Angle"), &spot_cone_angle, deg2rad(1.f), deg2rad(120.f)); - // PHelper().CreateFlag16 (values, PrepareKey(pref,*s_name,"Light" DELIMITER "Main" DELIMITER "Volumetric"), &flags, + values, PrepareKey(pref, s_name.c_str(), "Light" DELIMITER "Main" DELIMITER "Cone Angle"), &spot_cone_angle, deg2rad(1.f), deg2rad(120.f)); + // PHelper().CreateFlag16 (values, PrepareKey(pref,s_name.c_str(),"Light" DELIMITER "Main" DELIMITER "Volumetric"), &flags, // flVolumetric); - P = PHelper().CreateFlag16(values, PrepareKey(pref, *s_name, "Flags" DELIMITER "Volumetric"), &flags, flVolumetric); + P = PHelper().CreateFlag16(values, PrepareKey(pref, s_name.c_str(), "Flags" DELIMITER "Volumetric"), &flags, flVolumetric); P->OnChangeEvent.bind(this, &CSE_ALifeObjectHangingLamp::OnChangeFlag); } if (flags.is(flPointAmbient)) { PHelper().CreateFloat( - values, PrepareKey(pref, *s_name, "Light" DELIMITER "Ambient" DELIMITER "Radius"), &m_ambient_radius, 0.f, 1000.f); - PHelper().CreateFloat(values, PrepareKey(pref, *s_name, "Light" DELIMITER "Ambient" DELIMITER "Power"), &m_ambient_power); + values, PrepareKey(pref, s_name.c_str(), "Light" DELIMITER "Ambient" DELIMITER "Radius"), &m_ambient_radius, 0.f, 1000.f); + PHelper().CreateFloat(values, PrepareKey(pref, s_name.c_str(), "Light" DELIMITER "Ambient" DELIMITER "Power"), &m_ambient_power); PHelper().CreateChoose( - values, PrepareKey(pref, *s_name, "Light" DELIMITER "Ambient" DELIMITER "Texture"), &m_ambient_texture, smTexture, "lights"); - PHelper().CreateChoose(values, PrepareKey(pref, *s_name, "Light" DELIMITER "Ambient" DELIMITER "Bone"), &light_ambient_bone, + values, PrepareKey(pref, s_name.c_str(), "Light" DELIMITER "Ambient" DELIMITER "Texture"), &m_ambient_texture, smTexture, "lights"); + PHelper().CreateChoose(values, PrepareKey(pref, s_name.c_str(), "Light" DELIMITER "Ambient" DELIMITER "Bone"), &light_ambient_bone, smSkeletonBones, nullptr, (void*)visual()->get_visual()); } if (flags.is(flVolumetric)) { PHelper().CreateFloat( - values, PrepareKey(pref, *s_name, "Light" DELIMITER "Volumetric" DELIMITER "Quality"), &m_volumetric_quality, 0.f, 1.f); + values, PrepareKey(pref, s_name.c_str(), "Light" DELIMITER "Volumetric" DELIMITER "Quality"), &m_volumetric_quality, 0.f, 1.f); PHelper().CreateFloat( - values, PrepareKey(pref, *s_name, "Light" DELIMITER "Volumetric" DELIMITER "Intensity"), &m_volumetric_intensity, 0.f, 10.f); + values, PrepareKey(pref, s_name.c_str(), "Light" DELIMITER "Volumetric" DELIMITER "Intensity"), &m_volumetric_intensity, 0.f, 10.f); PHelper().CreateFloat( - values, PrepareKey(pref, *s_name, "Light" DELIMITER "Volumetric" DELIMITER "Distance"), &m_volumetric_distance, 0.f, 1.f); + values, PrepareKey(pref, s_name.c_str(), "Light" DELIMITER "Volumetric" DELIMITER "Distance"), &m_volumetric_distance, 0.f, 1.f); } // fixed bones - PHelper().CreateChoose(values, PrepareKey(pref, *s_name, "Model" DELIMITER "Fixed bones"), &fixed_bones, smSkeletonBones, nullptr, + PHelper().CreateChoose(values, PrepareKey(pref, s_name.c_str(), "Model" DELIMITER "Fixed bones"), &fixed_bones, smSkeletonBones, nullptr, (void*)visual()->get_visual(), 8); // glow - PHelper().CreateFloat(values, PrepareKey(pref, *s_name, "Glow" DELIMITER "Radius"), &glow_radius, 0.01f, 100.f); - PHelper().CreateChoose(values, PrepareKey(pref, *s_name, "Glow" DELIMITER "Texture"), &glow_texture, smTexture, "glow"); + PHelper().CreateFloat(values, PrepareKey(pref, s_name.c_str(), "Glow" DELIMITER "Radius"), &glow_radius, 0.01f, 100.f); + PHelper().CreateChoose(values, PrepareKey(pref, s_name.c_str(), "Glow" DELIMITER "Texture"), &glow_texture, smTexture, "glow"); // game - PHelper().CreateFloat(values, PrepareKey(pref, *s_name, "Game" DELIMITER "Health"), &m_health, 0.f, 100.f); + PHelper().CreateFloat(values, PrepareKey(pref, s_name.c_str(), "Game" DELIMITER "Health"), &m_health, 0.f, 100.f); } #define VIS_RADIUS 0.25f @@ -1361,11 +1365,11 @@ CDUInterface* du, IServerEntityLEOwner* owner, bool bSelected, const Fmatrix& pa { u32 clr = bSelected ? 0x00FFFFFF : 0x00FFFF00; Fmatrix main_xform, ambient_xform; - owner->get_bone_xform(*light_main_bone, main_xform); + owner->get_bone_xform(light_main_bone.c_str(), main_xform); main_xform.mulA_43(parent); if (flags.is(flPointAmbient)) { - owner->get_bone_xform(*light_ambient_bone, ambient_xform); + owner->get_bone_xform(light_ambient_bone.c_str(), ambient_xform); ambient_xform.mulA_43(parent); } if (bSelected) @@ -1540,7 +1544,7 @@ void CSE_ALifeHelicopter::FillProps(LPCSTR pref, PropItemVec& values) inherited2::FillProps(pref, values); inherited3::FillProps(pref, values); - PHelper().CreateChoose(values, PrepareKey(pref, *s_name, "Engine Sound"), &engine_sound, smSoundSource); + PHelper().CreateChoose(values, PrepareKey(pref, s_name.c_str(), "Engine Sound"), &engine_sound, smSoundSource); } #endif // #ifndef MASTER_GOLD @@ -1670,7 +1674,7 @@ void CSE_ALifeCar::FillProps(LPCSTR pref, PropItemVec& values) { inherited1::FillProps(pref, values); inherited2::FillProps(pref, values); - PHelper().CreateFloat(values, PrepareKey(pref, *s_name, "Health"), &health, 0.f, 1.0f); + PHelper().CreateFloat(values, PrepareKey(pref, s_name.c_str(), "Health"), &health, 0.f, 1.0f); } #endif // #ifndef MASTER_GOLD @@ -1703,7 +1707,7 @@ void CSE_ALifeObjectBreakable::UPDATE_Write(NET_Packet& tNetPacket) { inherited: void CSE_ALifeObjectBreakable::FillProps(LPCSTR pref, PropItemVec& values) { inherited::FillProps(pref, values); - PHelper().CreateFloat(values, PrepareKey(pref, *s_name, "Health"), &m_health, 0.f, 100.f); + PHelper().CreateFloat(values, PrepareKey(pref, s_name.c_str(), "Health"), &m_health, 0.f, 100.f); } #endif // #ifndef MASTER_GOLD @@ -1759,7 +1763,7 @@ void CSE_ALifeObjectClimable::FillProps(LPCSTR pref, PropItemVec& values) { // inherited1::FillProps (pref,values); inherited2::FillProps(pref, values); - // PHelper().CreateFloat (values, PrepareKey(pref,*s_name,"Health"), &m_health, 0.f, 100.f); + // PHelper().CreateFloat (values, PrepareKey(pref,s_name.c_str(),"Health"), &m_health, 0.f, 100.f); } void CSE_ALifeObjectClimable::set_additional_info(void* info) @@ -1829,7 +1833,7 @@ void CSE_ALifeTeamBaseZone::UPDATE_Write(NET_Packet& tNetPacket) { inherited::UP void CSE_ALifeTeamBaseZone::FillProps(LPCSTR pref, PropItemVec& items) { inherited::FillProps(pref, items); - PHelper().CreateU8(items, PrepareKey(pref, *s_name, "team"), &m_team, 0, 16); + PHelper().CreateU8(items, PrepareKey(pref, s_name.c_str(), "team"), &m_team, 0, 16); } #endif // #ifndef MASTER_GOLD diff --git a/src/xrServerEntities/xrServer_Objects_ALife.h b/src/xrServerEntities/xrServer_Objects_ALife.h index 189f805687a..a78952d1df6 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife.h +++ b/src/xrServerEntities/xrServer_Objects_ALife.h @@ -84,6 +84,9 @@ class CSE_ALifeSchedulable : public IPureSchedulableObject virtual bool bfActive() = 0; virtual CSE_ALifeDynamicObject* tpfGetBestDetector() = 0; #endif + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; class CSE_ALifeGraphPoint : public CSE_Abstract @@ -107,6 +110,9 @@ class CSE_ALifeGraphPoint : public CSE_Abstract virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_Abstract); }; class CSE_ALifeObject : public CSE_Abstract, public CRandom @@ -180,6 +186,9 @@ class CSE_ALifeObject : public CSE_Abstract, public CRandom virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_Abstract); }; class CSE_ALifeGroupAbstract @@ -210,6 +219,9 @@ class CSE_ALifeGroupAbstract virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; template @@ -315,6 +327,9 @@ class CSE_ALifeDynamicObject : public CSE_ALifeObject virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeObject); }; class CSE_ALifeDynamicObjectVisual : public CSE_ALifeDynamicObject, public CSE_Visual @@ -331,6 +346,9 @@ class CSE_ALifeDynamicObjectVisual : public CSE_ALifeDynamicObject, public CSE_V virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeDynamicObject, CSE_Visual); }; class CSE_ALifePHSkeletonObject : public CSE_ALifeDynamicObjectVisual, public CSE_PHSkeleton @@ -351,6 +369,9 @@ class CSE_ALifePHSkeletonObject : public CSE_ALifeDynamicObjectVisual, public CS virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeDynamicObjectVisual, CSE_PHSkeleton); }; class CSE_ALifeSpaceRestrictor : public CSE_ALifeDynamicObject, public CSE_Shape @@ -371,6 +392,9 @@ class CSE_ALifeSpaceRestrictor : public CSE_ALifeDynamicObject, public CSE_Shape virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeDynamicObject, CSE_Shape); }; class CSE_ALifeLevelChanger : public CSE_ALifeSpaceRestrictor @@ -393,6 +417,9 @@ class CSE_ALifeLevelChanger : public CSE_ALifeSpaceRestrictor virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeSpaceRestrictor); }; class CSE_ALifeSmartZone : public CSE_ALifeSpaceRestrictor, public CSE_ALifeSchedulable @@ -431,6 +458,9 @@ class CSE_ALifeSmartZone : public CSE_ALifeSpaceRestrictor, public CSE_ALifeSche virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeSpaceRestrictor, CSE_ALifeSchedulable); }; class CSE_ALifeObjectPhysic : public CSE_ALifeDynamicObjectVisual, public CSE_PHSkeleton @@ -497,6 +527,9 @@ class CSE_ALifeObjectPhysic : public CSE_ALifeDynamicObjectVisual, public CSE_PH virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeDynamicObjectVisual, CSE_PHSkeleton); }; class CSE_ALifeObjectHangingLamp : public CSE_ALifeDynamicObjectVisual, public CSE_PHSkeleton @@ -563,6 +596,9 @@ class CSE_ALifeObjectHangingLamp : public CSE_ALifeDynamicObjectVisual, public C virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeDynamicObjectVisual, CSE_PHSkeleton); }; class CSE_ALifeObjectProjector : public CSE_ALifeDynamicObjectVisual @@ -578,6 +614,9 @@ class CSE_ALifeObjectProjector : public CSE_ALifeDynamicObjectVisual virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeDynamicObjectVisual); }; class CSE_ALifeHelicopter : public CSE_ALifeDynamicObjectVisual, public CSE_Motion, public CSE_PHSkeleton @@ -600,6 +639,9 @@ class CSE_ALifeHelicopter : public CSE_ALifeDynamicObjectVisual, public CSE_Moti virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeDynamicObjectVisual, CSE_Motion, CSE_PHSkeleton); }; class CSE_ALifeCar : public CSE_ALifeDynamicObjectVisual, public CSE_PHSkeleton @@ -640,6 +682,9 @@ class CSE_ALifeCar : public CSE_ALifeDynamicObjectVisual, public CSE_PHSkeleton virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeDynamicObjectVisual, CSE_PHSkeleton); }; class CSE_ALifeObjectBreakable : public CSE_ALifeDynamicObjectVisual @@ -657,6 +702,9 @@ class CSE_ALifeObjectBreakable : public CSE_ALifeDynamicObjectVisual virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeDynamicObjectVisual); }; class CSE_ALifeObjectClimable : public CSE_Shape, public CSE_ALifeDynamicObject @@ -680,6 +728,9 @@ class CSE_ALifeObjectClimable : public CSE_Shape, public CSE_ALifeDynamicObject virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_Shape, CSE_Abstract); }; class CSE_ALifeMountedWeapon : public CSE_ALifeDynamicObjectVisual @@ -694,6 +745,9 @@ class CSE_ALifeMountedWeapon : public CSE_ALifeDynamicObjectVisual virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeDynamicObjectVisual); }; class CSE_ALifeStationaryMgun : public CSE_ALifeDynamicObjectVisual @@ -728,6 +782,9 @@ class CSE_ALifeTeamBaseZone : public CSE_ALifeSpaceRestrictor virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeSpaceRestrictor); }; class CSE_ALifeInventoryBox : public CSE_ALifeDynamicObjectVisual @@ -750,6 +807,9 @@ class CSE_ALifeInventoryBox : public CSE_ALifeDynamicObjectVisual virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeDynamicObjectVisual); }; #pragma warning(pop) diff --git a/src/xrServerEntities/xrServer_Objects_ALife_Items.cpp b/src/xrServerEntities/xrServer_Objects_ALife_Items.cpp index 23d94864015..674744112f4 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_Items.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife_Items.cpp @@ -307,12 +307,12 @@ void CSE_ALifeInventoryItem::UPDATE_Read(NET_Packet& tNetPacket) #ifndef MASTER_GOLD void CSE_ALifeInventoryItem::FillProps(LPCSTR pref, PropItemVec& values) { - PHelper().CreateFloat(values, PrepareKey(pref, *base()->s_name, "Item condition"), &m_fCondition, 0.f, 1.f); + PHelper().CreateFloat(values, PrepareKey(pref, base()->s_name.c_str(), "Item condition"), &m_fCondition, 0.f, 1.f); CSE_ALifeObject* alife_object = smart_cast(base()); R_ASSERT(alife_object); - PHelper().CreateFlag32(values, PrepareKey(pref, *base()->s_name, "ALife" DELIMITER "Useful for AI"), &alife_object->m_flags, + PHelper().CreateFlag32(values, PrepareKey(pref, base()->s_name.c_str(), "ALife" DELIMITER "Useful for AI"), &alife_object->m_flags, CSE_ALifeObject::flUsefulForAI); - PHelper().CreateFlag32(values, PrepareKey(pref, *base()->s_name, "ALife" DELIMITER "Visible for AI"), &alife_object->m_flags, + PHelper().CreateFlag32(values, PrepareKey(pref, base()->s_name.c_str(), "ALife" DELIMITER "Visible for AI"), &alife_object->m_flags, CSE_ALifeObject::flVisibleForAI); } #endif // #ifndef MASTER_GOLD @@ -621,19 +621,19 @@ BOOL CSE_ALifeItemWeapon::Net_Relevant() void CSE_ALifeItemWeapon::FillProps(LPCSTR pref, PropItemVec& items) { inherited::FillProps(pref, items); - PHelper().CreateU8(items, PrepareKey(pref, *s_name, "Ammo type:"), &ammo_type, 0, 255, 1); - PHelper().CreateU16(items, PrepareKey(pref, *s_name, "Ammo: in magazine"), &a_elapsed, 0, 30, 1); + PHelper().CreateU8(items, PrepareKey(pref, s_name.c_str(), "Ammo type:"), &ammo_type, 0, 255, 1); + PHelper().CreateU16(items, PrepareKey(pref, s_name.c_str(), "Ammo: in magazine"), &a_elapsed, 0, 30, 1); if (m_scope_status == ALife::eAddonAttachable) - PHelper().CreateFlag8(items, PrepareKey(pref, *s_name, "Addons" DELIMITER "Scope"), &m_addon_flags, eWeaponAddonScope); + PHelper().CreateFlag8(items, PrepareKey(pref, s_name.c_str(), "Addons" DELIMITER "Scope"), &m_addon_flags, eWeaponAddonScope); if (m_silencer_status == ALife::eAddonAttachable) PHelper().CreateFlag8( - items, PrepareKey(pref, *s_name, "Addons" DELIMITER "Silencer"), &m_addon_flags, eWeaponAddonSilencer); + items, PrepareKey(pref, s_name.c_str(), "Addons" DELIMITER "Silencer"), &m_addon_flags, eWeaponAddonSilencer); if (m_grenade_launcher_status == ALife::eAddonAttachable) PHelper().CreateFlag8( - items, PrepareKey(pref, *s_name, "Addons" DELIMITER "Podstvolnik"), &m_addon_flags, eWeaponAddonGrenadeLauncher); + items, PrepareKey(pref, s_name.c_str(), "Addons" DELIMITER "Podstvolnik"), &m_addon_flags, eWeaponAddonGrenadeLauncher); } #endif // #ifndef MASTER_GOLD @@ -781,7 +781,7 @@ void CSE_ALifeItemAmmo::UPDATE_Write(NET_Packet& tNetPacket) void CSE_ALifeItemAmmo::FillProps(LPCSTR pref, PropItemVec& values) { inherited::FillProps(pref, values); - PHelper().CreateU16(values, PrepareKey(pref, *s_name, "Ammo: left"), &a_elapsed, 0, m_boxSize, m_boxSize); + PHelper().CreateU16(values, PrepareKey(pref, s_name.c_str(), "Ammo: left"), &a_elapsed, 0, m_boxSize, m_boxSize); } #endif // #ifndef MASTER_GOLD @@ -824,7 +824,7 @@ void CSE_ALifeItemArtefact::UPDATE_Write(NET_Packet& tNetPacket) { inherited::UP void CSE_ALifeItemArtefact::FillProps(LPCSTR pref, PropItemVec& items) { inherited::FillProps(pref, items); - PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Anomaly value:"), &m_fAnomalyValue, 0.f, 200.f); + PHelper().CreateFloat(items, PrepareKey(pref, s_name.c_str(), "Anomaly value:"), &m_fAnomalyValue, 0.f, 200.f); } #endif // #ifndef MASTER_GOLD @@ -918,8 +918,8 @@ void CSE_ALifeItemDocument::UPDATE_Write(NET_Packet& tNetPacket) { inherited::UP void CSE_ALifeItemDocument::FillProps(LPCSTR pref, PropItemVec& items) { inherited::FillProps(pref, items); - // PHelper().CreateU16 (items, PrepareKey(pref, *s_name, "Document index :"), &m_wDocIndex, 0, 65535); - PHelper().CreateRText(items, PrepareKey(pref, *s_name, "Info portion :"), &m_wDoc); + // PHelper().CreateU16 (items, PrepareKey(pref, s_name.c_str(), "Document index :"), &m_wDocIndex, 0, 65535); + PHelper().CreateRText(items, PrepareKey(pref, s_name.c_str(), "Info portion :"), &m_wDoc); } #endif // #ifndef MASTER_GOLD diff --git a/src/xrServerEntities/xrServer_Objects_ALife_Items.h b/src/xrServerEntities/xrServer_Objects_ALife_Items.h index 12f68afffb0..f2c8c21c83a 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_Items.h +++ b/src/xrServerEntities/xrServer_Objects_ALife_Items.h @@ -98,6 +98,9 @@ class CSE_ALifeInventoryItem virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; class CSE_ALifeItem : public CSE_ALifeDynamicObjectVisual, public CSE_ALifeInventoryItem @@ -122,6 +125,9 @@ class CSE_ALifeItem : public CSE_ALifeDynamicObjectVisual, public CSE_ALifeInven virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeDynamicObjectVisual, CSE_ALifeInventoryItem); }; class CSE_ALifeItemTorch : public CSE_ALifeItem @@ -146,6 +152,9 @@ class CSE_ALifeItemTorch : public CSE_ALifeItem virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeItem); }; class CSE_ALifeItemAmmo : public CSE_ALifeItem @@ -166,6 +175,9 @@ class CSE_ALifeItemAmmo : public CSE_ALifeItem virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeItem); }; class CSE_ALifeItemWeapon : public CSE_ALifeItem @@ -238,6 +250,9 @@ class CSE_ALifeItemWeapon : public CSE_ALifeItem virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeItem); }; class CSE_ALifeItemWeaponMagazined : public CSE_ALifeItemWeapon @@ -255,6 +270,9 @@ class CSE_ALifeItemWeaponMagazined : public CSE_ALifeItemWeapon virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeItemWeapon); }; class CSE_ALifeItemWeaponMagazinedWGL : public CSE_ALifeItemWeaponMagazined @@ -272,6 +290,9 @@ class CSE_ALifeItemWeaponMagazinedWGL : public CSE_ALifeItemWeaponMagazined virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeItemWeaponMagazined); }; class CSE_ALifeItemWeaponShotGun : public CSE_ALifeItemWeaponMagazined @@ -289,6 +310,9 @@ class CSE_ALifeItemWeaponShotGun : public CSE_ALifeItemWeaponMagazined virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeItemWeapon); }; class CSE_ALifeItemWeaponAutoShotGun : public CSE_ALifeItemWeaponShotGun @@ -305,6 +329,9 @@ class CSE_ALifeItemWeaponAutoShotGun : public CSE_ALifeItemWeaponShotGun virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeItemWeapon); }; class CSE_ALifeItemDetector : public CSE_ALifeItem @@ -322,6 +349,9 @@ class CSE_ALifeItemDetector : public CSE_ALifeItem virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeItem); }; class CSE_ALifeItemArtefact : public CSE_ALifeItem @@ -338,6 +368,9 @@ class CSE_ALifeItemArtefact : public CSE_ALifeItem virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeItem); }; class CSE_ALifeItemPDA : public CSE_ALifeItem @@ -356,6 +389,9 @@ class CSE_ALifeItemPDA : public CSE_ALifeItem virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeItem); }; class CSE_ALifeItemDocument : public CSE_ALifeItem @@ -370,6 +406,9 @@ class CSE_ALifeItemDocument : public CSE_ALifeItem virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeItem); }; class CSE_ALifeItemGrenade : public CSE_ALifeItem @@ -386,6 +425,9 @@ class CSE_ALifeItemGrenade : public CSE_ALifeItem virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeItem); }; class CSE_ALifeItemExplosive : public CSE_ALifeItem @@ -400,6 +442,9 @@ class CSE_ALifeItemExplosive : public CSE_ALifeItem virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeItem); }; class CSE_ALifeItemBolt : public CSE_ALifeItem @@ -418,6 +463,9 @@ class CSE_ALifeItemBolt : public CSE_ALifeItem virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeItem); }; class CSE_ALifeItemCustomOutfit : public CSE_ALifeItem @@ -435,6 +483,9 @@ class CSE_ALifeItemCustomOutfit : public CSE_ALifeItem virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeItem); }; class CSE_ALifeItemHelmet : public CSE_ALifeItem @@ -450,6 +501,9 @@ class CSE_ALifeItemHelmet : public CSE_ALifeItem virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeItem); }; #pragma warning(pop) diff --git a/src/xrServerEntities/xrServer_Objects_ALife_Items_script.cpp b/src/xrServerEntities/xrServer_Objects_ALife_Items_script.cpp index efba4b35719..911664cd9c8 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_Items_script.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife_Items_script.cpp @@ -7,11 +7,11 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "xrServer_Objects_ALife_Items.h" #include "xrServer_script_macroses.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CSE_ALifeInventoryItem, (), +void CSE_ALifeInventoryItem::script_register(lua_State* luaState) { using namespace luabind; @@ -28,9 +28,9 @@ SCRIPT_EXPORT(CSE_ALifeInventoryItem, (), ta->add_upgrade(str); }) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeItem, (CSE_ALifeDynamicObjectVisual, CSE_ALifeInventoryItem), +void CSE_ALifeItem::script_register(lua_State* luaState) { using namespace luabind; @@ -39,9 +39,9 @@ SCRIPT_EXPORT(CSE_ALifeItem, (CSE_ALifeDynamicObjectVisual, CSE_ALifeInventoryIt luabind_class_item2( // luabind_class_abstract2( CSE_ALifeItem, "cse_alife_item", CSE_ALifeDynamicObjectVisual, CSE_ALifeInventoryItem)]; -}); +} -SCRIPT_EXPORT(CSE_ALifeItemTorch, (CSE_ALifeItem), +void CSE_ALifeItemTorch::script_register(lua_State* luaState) { using namespace luabind; @@ -49,9 +49,9 @@ SCRIPT_EXPORT(CSE_ALifeItemTorch, (CSE_ALifeItem), [ luabind_class_item1(CSE_ALifeItemTorch, "cse_alife_item_torch", CSE_ALifeItem) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeItemAmmo, (CSE_ALifeItem), +void CSE_ALifeItemAmmo::script_register(lua_State* luaState) { using namespace luabind; @@ -59,9 +59,9 @@ SCRIPT_EXPORT(CSE_ALifeItemAmmo, (CSE_ALifeItem), [ luabind_class_item1(CSE_ALifeItemAmmo, "cse_alife_item_ammo", CSE_ALifeItem) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeItemWeapon, (CSE_ALifeItem), +void CSE_ALifeItemWeapon::script_register(lua_State* luaState) { using namespace luabind; @@ -82,9 +82,9 @@ SCRIPT_EXPORT(CSE_ALifeItemWeapon, (CSE_ALifeItem), .def("get_ammo_elapsed", &CSE_ALifeItemWeapon::get_ammo_elapsed) .def("get_ammo_magsize", &CSE_ALifeItemWeapon::get_ammo_magsize) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeItemWeaponShotGun, (CSE_ALifeItemWeapon), +void CSE_ALifeItemWeaponShotGun::script_register(lua_State* luaState) { using namespace luabind; @@ -93,9 +93,9 @@ SCRIPT_EXPORT(CSE_ALifeItemWeaponShotGun, (CSE_ALifeItemWeapon), luabind_class_item1( CSE_ALifeItemWeaponShotGun, "cse_alife_item_weapon_shotgun", CSE_ALifeItemWeapon) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeItemWeaponAutoShotGun, (CSE_ALifeItemWeapon), +void CSE_ALifeItemWeaponAutoShotGun::script_register(lua_State* luaState) { using namespace luabind; @@ -104,9 +104,9 @@ SCRIPT_EXPORT(CSE_ALifeItemWeaponAutoShotGun, (CSE_ALifeItemWeapon), luabind_class_item1( CSE_ALifeItemWeaponAutoShotGun, "cse_alife_item_weapon_auto_shotgun", CSE_ALifeItemWeapon) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeItemDetector, (CSE_ALifeItem), +void CSE_ALifeItemDetector::script_register(lua_State* luaState) { using namespace luabind; @@ -114,9 +114,9 @@ SCRIPT_EXPORT(CSE_ALifeItemDetector, (CSE_ALifeItem), [ luabind_class_item1(CSE_ALifeItemDetector, "cse_alife_item_detector", CSE_ALifeItem) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeItemArtefact, (CSE_ALifeItem), +void CSE_ALifeItemArtefact::script_register(lua_State* luaState) { using namespace luabind; @@ -124,4 +124,4 @@ SCRIPT_EXPORT(CSE_ALifeItemArtefact, (CSE_ALifeItem), [ luabind_class_item1(CSE_ALifeItemArtefact, "cse_alife_item_artefact", CSE_ALifeItem) ]; -}); +} diff --git a/src/xrServerEntities/xrServer_Objects_ALife_Items_script2.cpp b/src/xrServerEntities/xrServer_Objects_ALife_Items_script2.cpp index bf56c031cd5..9404b3fd684 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_Items_script2.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife_Items_script2.cpp @@ -7,11 +7,11 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "xrServer_Objects_ALife_Items.h" #include "xrServer_script_macroses.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CSE_ALifeItemPDA, (CSE_ALifeItem), +void CSE_ALifeItemPDA::script_register(lua_State* luaState) { using namespace luabind; @@ -19,9 +19,9 @@ SCRIPT_EXPORT(CSE_ALifeItemPDA, (CSE_ALifeItem), [ luabind_class_item1(CSE_ALifeItemPDA, "cse_alife_item_pda", CSE_ALifeItem) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeItemDocument, (CSE_ALifeItem), +void CSE_ALifeItemDocument::script_register(lua_State* luaState) { using namespace luabind; @@ -29,9 +29,9 @@ SCRIPT_EXPORT(CSE_ALifeItemDocument, (CSE_ALifeItem), [ luabind_class_item1(CSE_ALifeItemDocument, "cse_alife_item_document", CSE_ALifeItem) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeItemGrenade, (CSE_ALifeItem), +void CSE_ALifeItemGrenade::script_register(lua_State* luaState) { using namespace luabind; @@ -39,9 +39,9 @@ SCRIPT_EXPORT(CSE_ALifeItemGrenade, (CSE_ALifeItem), [ luabind_class_item1(CSE_ALifeItemGrenade, "cse_alife_item_grenade", CSE_ALifeItem) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeItemExplosive, (CSE_ALifeItem), +void CSE_ALifeItemExplosive::script_register(lua_State* luaState) { using namespace luabind; @@ -49,9 +49,9 @@ SCRIPT_EXPORT(CSE_ALifeItemExplosive, (CSE_ALifeItem), [ luabind_class_item1(CSE_ALifeItemExplosive, "cse_alife_item_explosive", CSE_ALifeItem) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeItemBolt, (CSE_ALifeItem), +void CSE_ALifeItemBolt::script_register(lua_State* luaState) { using namespace luabind; @@ -59,9 +59,9 @@ SCRIPT_EXPORT(CSE_ALifeItemBolt, (CSE_ALifeItem), [ luabind_class_item1(CSE_ALifeItemBolt, "cse_alife_item_bolt", CSE_ALifeItem) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeItemCustomOutfit, (CSE_ALifeItem), +void CSE_ALifeItemCustomOutfit::script_register(lua_State* luaState) { using namespace luabind; @@ -69,9 +69,9 @@ SCRIPT_EXPORT(CSE_ALifeItemCustomOutfit, (CSE_ALifeItem), [ luabind_class_item1(CSE_ALifeItemCustomOutfit, "cse_alife_item_custom_outfit", CSE_ALifeItem) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeItemHelmet, (CSE_ALifeItem), +void CSE_ALifeItemHelmet::script_register(lua_State* luaState) { using namespace luabind; @@ -79,9 +79,9 @@ SCRIPT_EXPORT(CSE_ALifeItemHelmet, (CSE_ALifeItem), [ luabind_class_item1(CSE_ALifeItemHelmet, "cse_alife_item_helmet", CSE_ALifeItem) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeItemWeaponMagazined, (CSE_ALifeItemWeapon), +void CSE_ALifeItemWeaponMagazined::script_register(lua_State* luaState) { using namespace luabind; @@ -90,4 +90,15 @@ SCRIPT_EXPORT(CSE_ALifeItemWeaponMagazined, (CSE_ALifeItemWeapon), luabind_class_item1( CSE_ALifeItemWeaponMagazined, "cse_alife_item_weapon_magazined", CSE_ALifeItemWeapon) ]; -}); +} + +void CSE_ALifeItemWeaponMagazinedWGL::script_register(lua_State* luaState) +{ + using namespace luabind; + + module(luaState) + [ + luabind_class_item1( + CSE_ALifeItemWeaponMagazinedWGL, "cse_alife_item_weapon_magazined_w_gl", CSE_ALifeItemWeaponMagazined) + ]; +} diff --git a/src/xrServerEntities/xrServer_Objects_ALife_Items_script3.cpp b/src/xrServerEntities/xrServer_Objects_ALife_Items_script3.cpp deleted file mode 100644 index 86698f2e061..00000000000 --- a/src/xrServerEntities/xrServer_Objects_ALife_Items_script3.cpp +++ /dev/null @@ -1,23 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// Module : xrServer_Objects_ALife_Items_script3.cpp -// Created : 19.09.2002 -// Modified : 04.06.2003 -// Author : Dmitriy Iassenev -// Description : Server items for ALife simulator, script export, the second part -//////////////////////////////////////////////////////////////////////////// - -#include "pch_script.h" -#include "xrServer_Objects_ALife_Items.h" -#include "xrServer_script_macroses.h" -#include "xrScriptEngine/ScriptExporter.hpp" - -SCRIPT_EXPORT(CSE_ALifeItemWeaponMagazinedWGL, (CSE_ALifeItemWeaponMagazined), -{ - using namespace luabind; - - module(luaState) - [ - luabind_class_item1( - CSE_ALifeItemWeaponMagazinedWGL, "cse_alife_item_weapon_magazined_w_gl", CSE_ALifeItemWeaponMagazined) - ]; -}); diff --git a/src/xrServerEntities/xrServer_Objects_ALife_Monsters.cpp b/src/xrServerEntities/xrServer_Objects_ALife_Monsters.cpp index f1005fbd7c9..aa603ddb372 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_Monsters.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife_Monsters.cpp @@ -47,7 +47,7 @@ void setup_location_types_section(GameGraph::TERRAIN_VECTOR& m_vertex_types, CIn auto E = sect.Data.cend(); for (; I != E; ++I) { - pcstr S = *(*I).first; + pcstr S = I->first.c_str(); string16 I2; u32 N = _GetItemCount(S); @@ -147,7 +147,7 @@ CSE_Abstract* CSE_ALifeTraderAbstract::init() string4096 S; // xr_sprintf (S,"%s\r\n[game_info]\r\nname_id = default\r\n",!*base()->m_ini_string ? "" : // *base()->m_ini_string); - xr_sprintf(S, "%s\r\n[game_info]\r\n", !*base()->m_ini_string ? "" : *base()->m_ini_string); + xr_sprintf(S, "%s\r\n[game_info]\r\n", !base()->m_ini_string.c_str() ? "" : base()->m_ini_string.c_str()); base()->m_ini_string = S; return (base()); @@ -356,7 +356,7 @@ shared_str CSE_ALifeTraderAbstract::specific_character() } } R_ASSERT3( - !m_DefaultCharacters.empty(), "no default specific character set for class", *char_info.data()->m_Class); + !m_DefaultCharacters.empty(), "no default specific character set for class", char_info.data()->m_Class.c_str()); #ifdef XRGAME_EXPORTS if (m_CheckedCharacters.empty()) @@ -419,7 +419,7 @@ void CSE_ALifeTraderAbstract::set_specific_character(shared_str new_spec_char) CSE_ALifeMonsterAbstract* monster = smart_cast(base()); if (monster && selected_char.terrain_sect().size()) { - setup_location_types_section(monster->m_tpaTerrain, pSettings, *(selected_char.terrain_sect())); + setup_location_types_section(monster->m_tpaTerrain, pSettings, selected_char.terrain_sect().c_str()); } //---- if (NO_RANK == m_rank) @@ -430,7 +430,7 @@ void CSE_ALifeTraderAbstract::set_specific_character(shared_str new_spec_char) m_icon_name = selected_char.IconName(); - m_character_name = *(StringTable().translate(selected_char.Name())); + m_character_name = StringTable().translate(selected_char.Name()).c_str(); LPCSTR gen_name = "GENERATE_NAME_"; if (strstr(m_character_name.c_str(), gen_name)) @@ -448,14 +448,14 @@ void CSE_ALifeTraderAbstract::set_specific_character(shared_str new_spec_char) n += subset; n += "_"; n += xr_itoa(::Random.randI(name_cnt), S, 10); - m_character_name = *(StringTable().translate(n.c_str())); + m_character_name = StringTable().translate(n.c_str()).c_str(); m_character_name += " "; n = "lname_"; n += subset; n += "_"; n += xr_itoa(::Random.randI(last_name_cnt), S, 10); - m_character_name += *(StringTable().translate(n.c_str())); + m_character_name += StringTable().translate(n.c_str()).c_str(); } u32 min_m = selected_char.MoneyDef().min_money; u32 max_m = selected_char.MoneyDef().max_money; @@ -480,7 +480,7 @@ shared_str CSE_ALifeTraderAbstract::character_profile() { return m_sCharacterPro //Ð´Ð»Ñ Ñ€Ð°Ð±Ð¾Ñ‚Ñ‹ Ñ relation system u16 CSE_ALifeTraderAbstract::object_id() const { return base()->ID; } CHARACTER_COMMUNITY_INDEX CSE_ALifeTraderAbstract::Community() const { return m_community_index; } -LPCSTR CSE_ALifeTraderAbstract::CommunityName() const { return *CHARACTER_COMMUNITY::IndexToId(m_community_index); } +LPCSTR CSE_ALifeTraderAbstract::CommunityName() const { return CHARACTER_COMMUNITY::IndexToId(m_community_index).c_str(); } CHARACTER_RANK_VALUE CSE_ALifeTraderAbstract::Rank() { specific_character(); @@ -660,11 +660,11 @@ void CSE_ALifeCustomZone::FillProps(LPCSTR pref, PropItemVec& items) { inherited::FillProps(pref, items); PHelper().CreateU32( - items, PrepareKey(pref, *s_name, "on/off mode" DELIMITER "Shift time (sec)"), &m_start_time_shift, 0, 100000); + items, PrepareKey(pref, s_name.c_str(), "on/off mode" DELIMITER "Shift time (sec)"), &m_start_time_shift, 0, 100000); PHelper().CreateU32( - items, PrepareKey(pref, *s_name, "on/off mode" DELIMITER "Enabled time (sec)"), &m_enabled_time, 0, 100000); + items, PrepareKey(pref, s_name.c_str(), "on/off mode" DELIMITER "Enabled time (sec)"), &m_enabled_time, 0, 100000); PHelper().CreateU32( - items, PrepareKey(pref, *s_name, "on/off mode" DELIMITER "Disabled time (sec)"), &m_disabled_time, 0, 100000); + items, PrepareKey(pref, s_name.c_str(), "on/off mode" DELIMITER "Disabled time (sec)"), &m_disabled_time, 0, 100000); } #endif // #ifndef MASTER_GOLD @@ -756,10 +756,10 @@ void CSE_ALifeAnomalousZone::FillProps(LPCSTR pref, PropItemVec& items) { inherited::FillProps(pref, items); PHelper().CreateFloat( - items, PrepareKey(pref, *s_name, "offline interactive radius"), &m_offline_interactive_radius, 0.f, 100.f); + items, PrepareKey(pref, s_name.c_str(), "offline interactive radius"), &m_offline_interactive_radius, 0.f, 100.f); PHelper().CreateU16( - items, PrepareKey(pref, *s_name, "ALife" DELIMITER "Artefact spawn places count"), &m_artefact_spawn_count, 32, 256); - PHelper().CreateFlag32(items, PrepareKey(pref, *s_name, "ALife" DELIMITER "Visible for AI"), &m_flags, flVisibleForAI); + items, PrepareKey(pref, s_name.c_str(), "ALife" DELIMITER "Artefact spawn places count"), &m_artefact_spawn_count, 32, 256); + PHelper().CreateFlag32(items, PrepareKey(pref, s_name.c_str(), "ALife" DELIMITER "Visible for AI"), &m_flags, flVisibleForAI); } #endif // #ifndef MASTER_GOLD @@ -831,7 +831,7 @@ void CSE_ALifeZoneVisual::FillProps(LPCSTR pref, PropItemVec& values) IServerEntity* abstract = smart_cast(this); VERIFY(abstract); PHelper().CreateChoose(values, PrepareKey(pref, abstract->name(), "Attack animation"), &attack_animation, - smSkeletonAnims, nullptr, (void*)*visual_name); + smSkeletonAnims, nullptr, (void*)visual_name.c_str()); } #endif // #ifndef MASTER_GOLD //------------------------------------------------------------------------- @@ -973,10 +973,10 @@ u8 CSE_ALifeCreatureAbstract::g_group() { return s_group; } void CSE_ALifeCreatureAbstract::FillProps(LPCSTR pref, PropItemVec& items) { inherited::FillProps(pref, items); - PHelper().CreateU8(items, PrepareKey(pref, *s_name, "Team"), &s_team, 0, 64, 1); - PHelper().CreateU8(items, PrepareKey(pref, *s_name, "Squad"), &s_squad, 0, 64, 1); - PHelper().CreateU8(items, PrepareKey(pref, *s_name, "Group"), &s_group, 0, 64, 1); - PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Personal", "Health"), &fHealth, 0, 2, 5); + PHelper().CreateU8(items, PrepareKey(pref, s_name.c_str(), "Team"), &s_team, 0, 64, 1); + PHelper().CreateU8(items, PrepareKey(pref, s_name.c_str(), "Squad"), &s_squad, 0, 64, 1); + PHelper().CreateU8(items, PrepareKey(pref, s_name.c_str(), "Group"), &s_group, 0, 64, 1); + PHelper().CreateFloat(items, PrepareKey(pref, s_name.c_str(), "Personal", "Health"), &fHealth, 0, 2, 5); } #endif // #ifndef MASTER_GOLD @@ -1147,15 +1147,15 @@ void CSE_ALifeMonsterAbstract::FillProps(LPCSTR pref, PropItemVec& items) { inherited1::FillProps(pref, items); - PHelper().CreateFlag32(items, PrepareKey(pref, *s_name, "ALife" DELIMITER "No move in offline"), &m_flags, flOfflineNoMove); - PHelper().CreateFlag32(items, PrepareKey(pref, *s_name, "Use smart terrain tasks"), &m_flags, flUseSmartTerrains); + PHelper().CreateFlag32(items, PrepareKey(pref, s_name.c_str(), "ALife" DELIMITER "No move in offline"), &m_flags, flOfflineNoMove); + PHelper().CreateFlag32(items, PrepareKey(pref, s_name.c_str(), "Use smart terrain tasks"), &m_flags, flUseSmartTerrains); if (pSettings->line_exist(s_name, "SpaceRestrictionSection")) { LPCSTR gcs = pSettings->r_string(s_name, "SpaceRestrictionSection"); - PHelper().CreateChoose(items, PrepareKey(pref, *s_name, "out space restrictions"), &m_out_space_restrictors, + PHelper().CreateChoose(items, PrepareKey(pref, s_name.c_str(), "out space restrictions"), &m_out_space_restrictors, smSpawnItem, nullptr, (void*)gcs, 16); - PHelper().CreateChoose(items, PrepareKey(pref, *s_name, "in space restrictions"), &m_in_space_restrictors, + PHelper().CreateChoose(items, PrepareKey(pref, s_name.c_str(), "in space restrictions"), &m_in_space_restrictors, smSpawnItem, nullptr, (void*)gcs, 16); } } @@ -1540,34 +1540,34 @@ void CSE_ALifeMonsterRat::FillProps(LPCSTR pref, PropItemVec& items) inherited1::FillProps(pref, items); inherited2::FillProps(pref, items); // personal characteristics - PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Personal", "Field of view"), &fEyeFov, 0, 170, 10); - PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Personal", "Eye range"), &fEyeRange, 0, 300, 10); - PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Personal", "Minimum speed"), &fMinSpeed, 0, 10, 0.1f); - PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Personal", "Maximum speed"), &fMaxSpeed, 0, 10, 0.1f); - PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Personal", "Attack speed"), &fAttackSpeed, 0, 10, 0.1f); + PHelper().CreateFloat(items, PrepareKey(pref, s_name.c_str(), "Personal", "Field of view"), &fEyeFov, 0, 170, 10); + PHelper().CreateFloat(items, PrepareKey(pref, s_name.c_str(), "Personal", "Eye range"), &fEyeRange, 0, 300, 10); + PHelper().CreateFloat(items, PrepareKey(pref, s_name.c_str(), "Personal", "Minimum speed"), &fMinSpeed, 0, 10, 0.1f); + PHelper().CreateFloat(items, PrepareKey(pref, s_name.c_str(), "Personal", "Maximum speed"), &fMaxSpeed, 0, 10, 0.1f); + PHelper().CreateFloat(items, PrepareKey(pref, s_name.c_str(), "Personal", "Attack speed"), &fAttackSpeed, 0, 10, 0.1f); PHelper().CreateFloat( - items, PrepareKey(pref, *s_name, "Personal", "Pursuit distance"), &fMaxPursuitRadius, 0, 300, 10); - PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Personal", "Home distance"), &fMaxHomeRadius, 0, 300, 10); + items, PrepareKey(pref, s_name.c_str(), "Personal", "Pursuit distance"), &fMaxPursuitRadius, 0, 300, 10); + PHelper().CreateFloat(items, PrepareKey(pref, s_name.c_str(), "Personal", "Home distance"), &fMaxHomeRadius, 0, 300, 10); // morale PHelper().CreateFloat( - items, PrepareKey(pref, *s_name, "Morale", "Success attack quant"), &fMoraleSuccessAttackQuant, -100, 100, 5); - PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Morale", "Death quant"), &fMoraleDeathQuant, -100, 100, 5); - PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Morale", "Fear quant"), &fMoraleFearQuant, -100, 100, 5); + items, PrepareKey(pref, s_name.c_str(), "Morale", "Success attack quant"), &fMoraleSuccessAttackQuant, -100, 100, 5); + PHelper().CreateFloat(items, PrepareKey(pref, s_name.c_str(), "Morale", "Death quant"), &fMoraleDeathQuant, -100, 100, 5); + PHelper().CreateFloat(items, PrepareKey(pref, s_name.c_str(), "Morale", "Fear quant"), &fMoraleFearQuant, -100, 100, 5); PHelper().CreateFloat( - items, PrepareKey(pref, *s_name, "Morale", "Restore quant"), &fMoraleRestoreQuant, -100, 100, 5); - PHelper().CreateU16(items, PrepareKey(pref, *s_name, "Morale", "Restore time interval"), + items, PrepareKey(pref, s_name.c_str(), "Morale", "Restore quant"), &fMoraleRestoreQuant, -100, 100, 5); + PHelper().CreateU16(items, PrepareKey(pref, s_name.c_str(), "Morale", "Restore time interval"), &u16MoraleRestoreTimeInterval, 0, 65535, 500); - PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Morale", "Minimum value"), &fMoraleMinValue, -100, 100, 5); - PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Morale", "Maximum value"), &fMoraleMaxValue, -100, 100, 5); + PHelper().CreateFloat(items, PrepareKey(pref, s_name.c_str(), "Morale", "Minimum value"), &fMoraleMinValue, -100, 100, 5); + PHelper().CreateFloat(items, PrepareKey(pref, s_name.c_str(), "Morale", "Maximum value"), &fMoraleMaxValue, -100, 100, 5); PHelper().CreateFloat( - items, PrepareKey(pref, *s_name, "Morale", "Normal value"), &fMoraleNormalValue, -100, 100, 5); + items, PrepareKey(pref, s_name.c_str(), "Morale", "Normal value"), &fMoraleNormalValue, -100, 100, 5); // attack - PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Attack", "Hit power"), &fHitPower, 0, 200, 5); - PHelper().CreateU16(items, PrepareKey(pref, *s_name, "Attack", "Hit interval"), &u16HitInterval, 0, 65535, 500); - PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Attack", "Distance"), &fAttackDistance, 0, 300, 10); - PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Attack", "Maximum angle"), &fAttackAngle, 0, 180, 10); + PHelper().CreateFloat(items, PrepareKey(pref, s_name.c_str(), "Attack", "Hit power"), &fHitPower, 0, 200, 5); + PHelper().CreateU16(items, PrepareKey(pref, s_name.c_str(), "Attack", "Hit interval"), &u16HitInterval, 0, 65535, 500); + PHelper().CreateFloat(items, PrepareKey(pref, s_name.c_str(), "Attack", "Distance"), &fAttackDistance, 0, 300, 10); + PHelper().CreateFloat(items, PrepareKey(pref, s_name.c_str(), "Attack", "Maximum angle"), &fAttackAngle, 0, 180, 10); PHelper().CreateFloat( - items, PrepareKey(pref, *s_name, "Attack", "Success probability"), &fAttackSuccessProbability, 0, 100, 1); + items, PrepareKey(pref, s_name.c_str(), "Attack", "Success probability"), &fAttackSuccessProbability, 0, 100, 1); } #endif // #ifndef MASTER_GOLD @@ -1644,19 +1644,19 @@ void CSE_ALifeMonsterZombie::FillProps(LPCSTR pref, PropItemVec& items) { inherited::FillProps(pref, items); // personal characteristics - PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Personal", "Field of view"), &fEyeFov, 0, 170, 10); - PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Personal", "Eye range"), &fEyeRange, 0, 300, 10); - PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Personal", "Minimum speed"), &fMinSpeed, 0, 10, 0.1f); - PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Personal", "Maximum speed"), &fMaxSpeed, 0, 10, 0.1f); - PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Personal", "Attack speed"), &fAttackSpeed, 0, 10, 0.1f); + PHelper().CreateFloat(items, PrepareKey(pref, s_name.c_str(), "Personal", "Field of view"), &fEyeFov, 0, 170, 10); + PHelper().CreateFloat(items, PrepareKey(pref, s_name.c_str(), "Personal", "Eye range"), &fEyeRange, 0, 300, 10); + PHelper().CreateFloat(items, PrepareKey(pref, s_name.c_str(), "Personal", "Minimum speed"), &fMinSpeed, 0, 10, 0.1f); + PHelper().CreateFloat(items, PrepareKey(pref, s_name.c_str(), "Personal", "Maximum speed"), &fMaxSpeed, 0, 10, 0.1f); + PHelper().CreateFloat(items, PrepareKey(pref, s_name.c_str(), "Personal", "Attack speed"), &fAttackSpeed, 0, 10, 0.1f); PHelper().CreateFloat( - items, PrepareKey(pref, *s_name, "Personal", "Pursuit distance"), &fMaxPursuitRadius, 0, 300, 10); - PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Personal", "Home distance"), &fMaxHomeRadius, 0, 300, 10); + items, PrepareKey(pref, s_name.c_str(), "Personal", "Pursuit distance"), &fMaxPursuitRadius, 0, 300, 10); + PHelper().CreateFloat(items, PrepareKey(pref, s_name.c_str(), "Personal", "Home distance"), &fMaxHomeRadius, 0, 300, 10); // attack - PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Attack", "Hit power"), &fHitPower, 0, 200, 5); - PHelper().CreateU16(items, PrepareKey(pref, *s_name, "Attack", "Hit interval"), &u16HitInterval, 0, 65535, 500); - PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Attack", "Distance"), &fAttackDistance, 0, 300, 10); - PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Attack", "Maximum angle"), &fAttackAngle, 0, 100, 1); + PHelper().CreateFloat(items, PrepareKey(pref, s_name.c_str(), "Attack", "Hit power"), &fHitPower, 0, 200, 5); + PHelper().CreateU16(items, PrepareKey(pref, s_name.c_str(), "Attack", "Hit interval"), &u16HitInterval, 0, 65535, 500); + PHelper().CreateFloat(items, PrepareKey(pref, s_name.c_str(), "Attack", "Distance"), &fAttackDistance, 0, 300, 10); + PHelper().CreateFloat(items, PrepareKey(pref, s_name.c_str(), "Attack", "Maximum angle"), &fAttackAngle, 0, 100, 1); } #endif // #ifndef MASTER_GOLD @@ -1793,7 +1793,7 @@ void CSE_ALifeHumanAbstract::FillProps(LPCSTR pref, PropItemVec& items) { inherited1::FillProps(pref, items); inherited2::FillProps(pref, items); - PHelper().CreateFlag32(items, PrepareKey(pref, *s_name, "Group behaviour"), &m_flags, flGroupBehaviour); + PHelper().CreateFlag32(items, PrepareKey(pref, s_name.c_str(), "Group behaviour"), &m_flags, flGroupBehaviour); } #endif // #ifndef MASTER_GOLD diff --git a/src/xrServerEntities/xrServer_Objects_ALife_Monsters.h b/src/xrServerEntities/xrServer_Objects_ALife_Monsters.h index e86dca7302c..a600d1b8676 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_Monsters.h +++ b/src/xrServerEntities/xrServer_Objects_ALife_Monsters.h @@ -100,6 +100,9 @@ class CSE_ALifeTraderAbstract virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; class CSE_ALifeTrader : public CSE_ALifeDynamicObjectVisual, public CSE_ALifeTraderAbstract @@ -133,6 +136,9 @@ class CSE_ALifeTrader : public CSE_ALifeDynamicObjectVisual, public CSE_ALifeTra virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeDynamicObjectVisual, CSE_ALifeTraderAbstract); }; class CSE_ALifeCustomZone : public CSE_ALifeSpaceRestrictor @@ -154,6 +160,9 @@ class CSE_ALifeCustomZone : public CSE_ALifeSpaceRestrictor virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeDynamicObject, CSE_Shape); }; class CSE_ALifeAnomalousZone : public CSE_ALifeCustomZone @@ -191,6 +200,9 @@ class CSE_ALifeAnomalousZone : public CSE_ALifeCustomZone virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeCustomZone); }; class CSE_ALifeTorridZone : public CSE_ALifeCustomZone, public CSE_Motion @@ -207,6 +219,9 @@ class CSE_ALifeTorridZone : public CSE_ALifeCustomZone, public CSE_Motion virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeCustomZone, CSE_Motion); }; class CSE_ALifeZoneVisual : public CSE_ALifeAnomalousZone, public CSE_Visual @@ -224,6 +239,9 @@ class CSE_ALifeZoneVisual : public CSE_ALifeAnomalousZone, public CSE_Visual virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeAnomalousZone, CSE_Visual); }; class CSE_ALifeCreatureAbstract : public CSE_ALifeDynamicObjectVisual @@ -289,6 +307,9 @@ class CSE_ALifeCreatureAbstract : public CSE_ALifeDynamicObjectVisual virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeDynamicObjectVisual); }; class CSE_ALifeMonsterAbstract : public CSE_ALifeCreatureAbstract, @@ -383,6 +404,9 @@ class CSE_ALifeMonsterAbstract : public CSE_ALifeCreatureAbstract, virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeCreatureAbstract, CSE_ALifeSchedulable); }; class CSE_ALifeCreatureActor : public CSE_ALifeCreatureAbstract, public CSE_ALifeTraderAbstract, public CSE_PHSkeleton @@ -435,6 +459,9 @@ class CSE_ALifeCreatureActor : public CSE_ALifeCreatureAbstract, public CSE_ALif virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeCreatureAbstract, CSE_ALifeTraderAbstract, CSE_PHSkeleton); }; class CSE_ALifeCreatureCrow : public CSE_ALifeCreatureAbstract @@ -450,6 +477,9 @@ class CSE_ALifeCreatureCrow : public CSE_ALifeCreatureAbstract virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeCreatureAbstract); }; class CSE_ALifeCreaturePhantom : public CSE_ALifeCreatureAbstract @@ -465,6 +495,9 @@ class CSE_ALifeCreaturePhantom : public CSE_ALifeCreatureAbstract virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeCreatureAbstract); }; class CSE_ALifeMonsterRat : public CSE_ALifeMonsterAbstract, public CSE_ALifeInventoryItem @@ -510,6 +543,9 @@ class CSE_ALifeMonsterRat : public CSE_ALifeMonsterAbstract, public CSE_ALifeInv virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeMonsterAbstract, CSE_ALifeInventoryItem); }; class CSE_ALifeMonsterZombie : public CSE_ALifeMonsterAbstract @@ -538,6 +574,9 @@ class CSE_ALifeMonsterZombie : public CSE_ALifeMonsterAbstract virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeMonsterAbstract); }; class CSE_ALifeMonsterBase : public CSE_ALifeMonsterAbstract, public CSE_PHSkeleton @@ -564,6 +603,9 @@ class CSE_ALifeMonsterBase : public CSE_ALifeMonsterAbstract, public CSE_PHSkele virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeMonsterAbstract, CSE_PHSkeleton); }; class CSE_ALifePsyDogPhantom : public CSE_ALifeMonsterBase @@ -580,6 +622,9 @@ class CSE_ALifePsyDogPhantom : public CSE_ALifeMonsterBase virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeMonsterBase); }; class CSE_ALifeHumanAbstract : public CSE_ALifeTraderAbstract, public CSE_ALifeMonsterAbstract @@ -632,6 +677,9 @@ class CSE_ALifeHumanAbstract : public CSE_ALifeTraderAbstract, public CSE_ALifeM virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeTraderAbstract, CSE_ALifeMonsterAbstract); }; class CSE_ALifeHumanStalker : public CSE_ALifeHumanAbstract, public CSE_PHSkeleton @@ -651,6 +699,9 @@ class CSE_ALifeHumanStalker : public CSE_ALifeHumanAbstract, public CSE_PHSkelet virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeHumanAbstract, CSE_PHSkeleton); }; class CSE_ALifeOnlineOfflineGroup : public CSE_ALifeDynamicObject, @@ -734,6 +785,9 @@ class CSE_ALifeOnlineOfflineGroup : public CSE_ALifeDynamicObject, virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeDynamicObject, CSE_ALifeSchedulable); }; #pragma warning(pop) diff --git a/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script.cpp b/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script.cpp index 77b41630446..cc119da67f4 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script.cpp @@ -13,10 +13,7 @@ #include "xrServer_Objects_ALife_Monsters.h" #include "xrServer_script_macroses.h" -#include "xrScriptEngine/ScriptExporter.hpp" - -#ifdef XRGAME_EXPORTS -SCRIPT_EXPORT(CSE_ALifeTraderAbstract, (), +void CSE_ALifeTraderAbstract::script_register(lua_State* luaState) { using namespace luabind; @@ -44,27 +41,9 @@ SCRIPT_EXPORT(CSE_ALifeTraderAbstract, (), return *ta->m_icon_name; }) ]; -}); -#else -pcstr profile_name_script(CSE_ALifeTraderAbstract* ta) { return *ta->character_profile(); } +} -SCRIPT_EXPORT(CSE_ALifeTraderAbstract, (), -{ - using namespace luabind; - - module(luaState) - [ - class_("cse_alife_trader_abstract") - // .def( constructor()) - //.def("community", &CSE_ALifeTraderAbstract::CommunityName) - .def("profile_name", &profile_name_script) - //.def("rank", &CSE_ALifeTraderAbstract::Rank) - /*.def("reputation", &CSE_ALifeTraderAbstract::Reputation)*/ - ]; - }); -#endif - -SCRIPT_EXPORT(CSE_ALifeTrader, (CSE_ALifeDynamicObjectVisual, CSE_ALifeTraderAbstract), +void CSE_ALifeTrader::script_register(lua_State* luaState) { using namespace luabind; @@ -73,19 +52,20 @@ SCRIPT_EXPORT(CSE_ALifeTrader, (CSE_ALifeDynamicObjectVisual, CSE_ALifeTraderAbs luabind_class_dynamic_alife2( CSE_ALifeTrader, "cse_alife_trader", CSE_ALifeDynamicObjectVisual, CSE_ALifeTraderAbstract) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeCustomZone, (CSE_ALifeDynamicObject, CSE_Shape), +void CSE_ALifeCustomZone::script_register(lua_State* luaState) { using namespace luabind; module(luaState) [ luabind_class_dynamic_alife2( - CSE_ALifeCustomZone, "cse_custom_zone", CSE_ALifeDynamicObject, CSE_Shape)]; -}); + CSE_ALifeCustomZone, "cse_custom_zone", CSE_ALifeDynamicObject, CSE_Shape) + ]; +} -SCRIPT_EXPORT(CSE_ALifeAnomalousZone, (CSE_ALifeCustomZone), +void CSE_ALifeAnomalousZone::script_register(lua_State* luaState) { using namespace luabind; @@ -93,9 +73,9 @@ SCRIPT_EXPORT(CSE_ALifeAnomalousZone, (CSE_ALifeCustomZone), [ luabind_class_dynamic_alife1(CSE_ALifeAnomalousZone, "cse_anomalous_zone", CSE_ALifeCustomZone) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeMonsterRat, (CSE_ALifeMonsterAbstract, CSE_ALifeInventoryItem), +void CSE_ALifeMonsterRat::script_register(lua_State* luaState) { using namespace luabind; @@ -104,4 +84,4 @@ SCRIPT_EXPORT(CSE_ALifeMonsterRat, (CSE_ALifeMonsterAbstract, CSE_ALifeInventory luabind_class_monster2( CSE_ALifeMonsterRat, "cse_alife_monster_rat", CSE_ALifeMonsterAbstract, CSE_ALifeInventoryItem) ]; -}); +} diff --git a/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script2.cpp b/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script2.cpp index f80d6a8c207..a0c2f9b49cd 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script2.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script2.cpp @@ -7,11 +7,11 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "xrServer_Objects_ALife_Monsters.h" #include "xrServer_script_macroses.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CSE_ALifeCreatureCrow, (CSE_ALifeCreatureAbstract), +void CSE_ALifeCreatureCrow::script_register(lua_State* luaState) { using namespace luabind; @@ -19,9 +19,9 @@ SCRIPT_EXPORT(CSE_ALifeCreatureCrow, (CSE_ALifeCreatureAbstract), [ luabind_class_creature1(CSE_ALifeCreatureCrow, "cse_alife_creature_crow", CSE_ALifeCreatureAbstract) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeMonsterZombie, (CSE_ALifeMonsterAbstract), +void CSE_ALifeMonsterZombie::script_register(lua_State* luaState) { using namespace luabind; @@ -29,9 +29,9 @@ SCRIPT_EXPORT(CSE_ALifeMonsterZombie, (CSE_ALifeMonsterAbstract), [ luabind_class_monster1(CSE_ALifeMonsterZombie, "cse_alife_monster_zombie", CSE_ALifeMonsterAbstract) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeMonsterBase, (CSE_ALifeMonsterAbstract, CSE_PHSkeleton), +void CSE_ALifeMonsterBase::script_register(lua_State* luaState) { using namespace luabind; @@ -39,9 +39,9 @@ SCRIPT_EXPORT(CSE_ALifeMonsterBase, (CSE_ALifeMonsterAbstract, CSE_PHSkeleton), [ luabind_class_monster2(CSE_ALifeMonsterBase, "cse_alife_monster_base", CSE_ALifeMonsterAbstract, CSE_PHSkeleton) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeHumanStalker, (CSE_ALifeHumanAbstract, CSE_PHSkeleton), +void CSE_ALifeHumanStalker::script_register(lua_State* luaState) { using namespace luabind; @@ -49,4 +49,4 @@ SCRIPT_EXPORT(CSE_ALifeHumanStalker, (CSE_ALifeHumanAbstract, CSE_PHSkeleton), [ luabind_class_monster2(CSE_ALifeHumanStalker, "cse_alife_human_stalker", CSE_ALifeHumanAbstract, CSE_PHSkeleton) ]; -}); +} diff --git a/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script3.cpp b/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script3.cpp index 056e515124c..b3555630725 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script3.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script3.cpp @@ -7,11 +7,11 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "xrServer_Objects_ALife_Monsters.h" #include "xrServer_script_macroses.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CSE_ALifeCreatureActor, (CSE_ALifeCreatureAbstract, CSE_ALifeTraderAbstract, CSE_PHSkeleton), +void CSE_ALifeCreatureActor::script_register(lua_State* luaState) { using namespace luabind; @@ -20,9 +20,9 @@ SCRIPT_EXPORT(CSE_ALifeCreatureActor, (CSE_ALifeCreatureAbstract, CSE_ALifeTrade luabind_class_creature3(CSE_ALifeCreatureActor, "cse_alife_creature_actor", CSE_ALifeCreatureAbstract, CSE_ALifeTraderAbstract, CSE_PHSkeleton) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeTorridZone, (CSE_ALifeCustomZone, CSE_Motion), +void CSE_ALifeTorridZone::script_register(lua_State* luaState) { using namespace luabind; @@ -30,9 +30,9 @@ SCRIPT_EXPORT(CSE_ALifeTorridZone, (CSE_ALifeCustomZone, CSE_Motion), [ luabind_class_dynamic_alife2(CSE_ALifeTorridZone, "cse_torrid_zone", CSE_ALifeCustomZone, CSE_Motion) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeZoneVisual, (CSE_ALifeAnomalousZone, CSE_Visual), +void CSE_ALifeZoneVisual::script_register(lua_State* luaState) { using namespace luabind; @@ -40,9 +40,9 @@ SCRIPT_EXPORT(CSE_ALifeZoneVisual, (CSE_ALifeAnomalousZone, CSE_Visual), [ luabind_class_dynamic_alife2(CSE_ALifeZoneVisual, "cse_zone_visual", CSE_ALifeAnomalousZone, CSE_Visual) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeCreaturePhantom, (CSE_ALifeCreatureAbstract), +void CSE_ALifeCreaturePhantom::script_register(lua_State* luaState) { using namespace luabind; @@ -50,11 +50,9 @@ SCRIPT_EXPORT(CSE_ALifeCreaturePhantom, (CSE_ALifeCreatureAbstract), [ luabind_class_creature1(CSE_ALifeCreaturePhantom, "cse_alife_creature_phantom", CSE_ALifeCreatureAbstract) ]; -}); - -static SRotation* CSE_ALifeCreatureAbstract__o_torso(CSE_ALifeCreatureAbstract* self) { return (&self->o_torso); } +} -SCRIPT_EXPORT(CSE_ALifeCreatureAbstract, (CSE_ALifeDynamicObjectVisual), +void CSE_ALifeCreatureAbstract::script_register(lua_State* luaState) { using namespace luabind; @@ -66,20 +64,20 @@ SCRIPT_EXPORT(CSE_ALifeCreatureAbstract, (CSE_ALifeDynamicObjectVisual), .def_readwrite("team", &CSE_ALifeCreatureAbstract::s_team) .def_readwrite("squad", &CSE_ALifeCreatureAbstract::s_squad) .def_readwrite("group", &CSE_ALifeCreatureAbstract::s_group) - .def("o_torso", &CSE_ALifeCreatureAbstract__o_torso) + .def("o_torso", +[](CSE_ALifeCreatureAbstract* self) { return &self->o_torso; }) ]; -}); +} -static void CSE_ALifeOnlineOfflineGroup_Export(lua_State* luaState) +void CSE_ALifeOnlineOfflineGroup::script_register(lua_State* luaState) { using namespace luabind; using namespace luabind::policy; module(luaState) [ - class_("MEMBERS__value_type") - .def_readonly("id", &CSE_ALifeOnlineOfflineGroup::MEMBERS::value_type::first) - .def_readonly("object", &CSE_ALifeOnlineOfflineGroup::MEMBERS::value_type::second), + class_("MEMBERS__value_type") + .def_readonly("id", &MEMBERS::value_type::first) + .def_readonly("object", &MEMBERS::value_type::second), luabind_class_online_offline_group2(CSE_ALifeOnlineOfflineGroup, "cse_alife_online_offline_group", CSE_ALifeDynamicObject, CSE_ALifeSchedulable) @@ -96,5 +94,3 @@ static void CSE_ALifeOnlineOfflineGroup_Export(lua_State* luaState) #endif ]; } - -SCRIPT_EXPORT_FUNC(CSE_ALifeOnlineOfflineGroup, (CSE_ALifeDynamicObject, CSE_ALifeSchedulable), CSE_ALifeOnlineOfflineGroup_Export); diff --git a/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script4.cpp b/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script4.cpp index b74a17a6936..a8b1c81cb27 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script4.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script4.cpp @@ -14,8 +14,6 @@ #include "relation_registry.h" #endif // #ifdef XRGAME_EXPORTS -#include "xrScriptEngine/ScriptExporter.hpp" - CALifeMonsterBrain* monster_brain(CSE_ALifeMonsterAbstract* monster) { THROW(monster); @@ -66,7 +64,7 @@ void ForceSetGoodwill(CSE_ALifeMonsterAbstract* self, int goodwill, ALife::_OBJE } #endif // #ifdef XRGAME_EXPORTS -static void CSE_ALifeMonsterAbstract_Export(lua_State* luaState) +void CSE_ALifeMonsterAbstract::script_register(lua_State* luaState) { using namespace luabind; @@ -93,9 +91,8 @@ static void CSE_ALifeMonsterAbstract_Export(lua_State* luaState) #endif ]; } -SCRIPT_EXPORT_FUNC(CSE_ALifeMonsterAbstract, (CSE_ALifeCreatureAbstract, CSE_ALifeSchedulable), CSE_ALifeMonsterAbstract_Export); -static void CSE_ALifeHumanAbstract_Export(lua_State* luaState) +void CSE_ALifeHumanAbstract::script_register(lua_State* luaState) { using namespace luabind; @@ -111,9 +108,7 @@ static void CSE_ALifeHumanAbstract_Export(lua_State* luaState) ]; } -SCRIPT_EXPORT_FUNC(CSE_ALifeHumanAbstract, (CSE_ALifeTraderAbstract, CSE_ALifeMonsterAbstract), CSE_ALifeHumanAbstract_Export); - -SCRIPT_EXPORT(CSE_ALifePsyDogPhantom, (CSE_ALifeMonsterBase), +void CSE_ALifePsyDogPhantom::script_register(lua_State* luaState) { using namespace luabind; @@ -121,4 +116,4 @@ SCRIPT_EXPORT(CSE_ALifePsyDogPhantom, (CSE_ALifeMonsterBase), [ luabind_class_monster1(CSE_ALifePsyDogPhantom, "cse_alife_psydog_phantom", CSE_ALifeMonsterBase) ]; -}); +} diff --git a/src/xrServerEntities/xrServer_Objects_ALife_script.cpp b/src/xrServerEntities/xrServer_Objects_ALife_script.cpp index c11690ff3aa..f9841e94baa 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_script.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife_script.cpp @@ -7,11 +7,11 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "xrServer_Objects_ALife.h" #include "xrServer_script_macroses.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CSE_ALifeSchedulable, (), +void CSE_ALifeSchedulable::script_register(lua_State* luaState) { using namespace luabind; @@ -23,9 +23,9 @@ SCRIPT_EXPORT(CSE_ALifeSchedulable, (), class_("cse_alife_schedulable") // .def( constructor()) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeGraphPoint, (CSE_Abstract), +void CSE_ALifeGraphPoint::script_register(lua_State* luaState) { using namespace luabind; @@ -33,9 +33,9 @@ SCRIPT_EXPORT(CSE_ALifeGraphPoint, (CSE_Abstract), [ luabind_class_abstract1(CSE_ALifeGraphPoint, "cse_alife_graph_point", CSE_Abstract) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeObject, (CSE_Abstract), +void CSE_ALifeObject::script_register(lua_State* luaState) { using namespace luabind; @@ -54,9 +54,9 @@ SCRIPT_EXPORT(CSE_ALifeObject, (CSE_Abstract), .def_readonly("m_game_vertex_id", &CSE_ALifeObject::m_tGraphID) .def_readonly("m_story_id", &CSE_ALifeObject::m_story_id) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeGroupAbstract, (), +void CSE_ALifeGroupAbstract::script_register(lua_State* luaState) { using namespace luabind; @@ -65,16 +65,19 @@ SCRIPT_EXPORT(CSE_ALifeGroupAbstract, (), class_("cse_alife_group_abstract") // .def( constructor()) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeDynamicObject, (CSE_ALifeObject), +void CSE_ALifeDynamicObject::script_register(lua_State* luaState) { using namespace luabind; - module(luaState)[luabind_class_dynamic_alife1(CSE_ALifeDynamicObject, "cse_alife_dynamic_object", CSE_ALifeObject)]; -}); + module(luaState) + [ + luabind_class_dynamic_alife1(CSE_ALifeDynamicObject, "cse_alife_dynamic_object", CSE_ALifeObject) + ]; +} -SCRIPT_EXPORT(CSE_ALifeDynamicObjectVisual, (CSE_ALifeDynamicObject, CSE_Visual), +void CSE_ALifeDynamicObjectVisual::script_register(lua_State* luaState) { using namespace luabind; @@ -83,9 +86,9 @@ SCRIPT_EXPORT(CSE_ALifeDynamicObjectVisual, (CSE_ALifeDynamicObject, CSE_Visual) luabind_class_dynamic_alife2( CSE_ALifeDynamicObjectVisual, "cse_alife_dynamic_object_visual", CSE_ALifeDynamicObject, CSE_Visual) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifePHSkeletonObject, (CSE_ALifeDynamicObjectVisual, CSE_PHSkeleton), +void CSE_ALifePHSkeletonObject::script_register(lua_State* luaState) { using namespace luabind; @@ -94,9 +97,9 @@ SCRIPT_EXPORT(CSE_ALifePHSkeletonObject, (CSE_ALifeDynamicObjectVisual, CSE_PHSk luabind_class_dynamic_alife2( CSE_ALifePHSkeletonObject, "cse_alife_ph_skeleton_object", CSE_ALifeDynamicObjectVisual, CSE_PHSkeleton) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeSpaceRestrictor, (CSE_ALifeDynamicObject, CSE_Shape), +void CSE_ALifeSpaceRestrictor::script_register(lua_State* luaState) { using namespace luabind; @@ -105,9 +108,9 @@ SCRIPT_EXPORT(CSE_ALifeSpaceRestrictor, (CSE_ALifeDynamicObject, CSE_Shape), luabind_class_dynamic_alife2( CSE_ALifeSpaceRestrictor, "cse_alife_space_restrictor", CSE_ALifeDynamicObject, CSE_Shape) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeLevelChanger, (CSE_ALifeSpaceRestrictor), +void CSE_ALifeLevelChanger::script_register(lua_State* luaState) { using namespace luabind; @@ -118,9 +121,9 @@ SCRIPT_EXPORT(CSE_ALifeLevelChanger, (CSE_ALifeSpaceRestrictor), ) .property("get_dest_level_name", +[](CSE_ALifeLevelChanger* self) { return self->m_caLevelToChange.c_str(); }) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeInventoryBox, (CSE_ALifeDynamicObjectVisual), +void CSE_ALifeInventoryBox::script_register(lua_State* luaState) { using namespace luabind; @@ -129,4 +132,4 @@ SCRIPT_EXPORT(CSE_ALifeInventoryBox, (CSE_ALifeDynamicObjectVisual), luabind_class_dynamic_alife1( CSE_ALifeInventoryBox, "cse_alife_inventory_box", CSE_ALifeDynamicObjectVisual) ]; -}); +} diff --git a/src/xrServerEntities/xrServer_Objects_ALife_script2.cpp b/src/xrServerEntities/xrServer_Objects_ALife_script2.cpp index e9eda086399..aa36c46d115 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_script2.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife_script2.cpp @@ -7,11 +7,11 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "xrServer_Objects_ALife_Monsters.h" #include "xrServer_script_macroses.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CSE_ALifeObjectProjector, (CSE_ALifeDynamicObjectVisual), +void CSE_ALifeObjectProjector::script_register(lua_State* luaState) { using namespace luabind; @@ -20,9 +20,9 @@ SCRIPT_EXPORT(CSE_ALifeObjectProjector, (CSE_ALifeDynamicObjectVisual), luabind_class_dynamic_alife1( CSE_ALifeObjectProjector, "cse_alife_object_projector", CSE_ALifeDynamicObjectVisual) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeHelicopter, (CSE_ALifeDynamicObjectVisual, CSE_Motion, CSE_PHSkeleton), +void CSE_ALifeHelicopter::script_register(lua_State* luaState) { using namespace luabind; @@ -31,9 +31,9 @@ SCRIPT_EXPORT(CSE_ALifeHelicopter, (CSE_ALifeDynamicObjectVisual, CSE_Motion, CS luabind_class_dynamic_alife3( CSE_ALifeHelicopter, "cse_alife_helicopter", CSE_ALifeDynamicObjectVisual, CSE_Motion, CSE_PHSkeleton) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeCar, (CSE_ALifeDynamicObjectVisual, CSE_PHSkeleton), +void CSE_ALifeCar::script_register(lua_State* luaState) { using namespace luabind; @@ -42,9 +42,9 @@ SCRIPT_EXPORT(CSE_ALifeCar, (CSE_ALifeDynamicObjectVisual, CSE_PHSkeleton), luabind_class_dynamic_alife2( CSE_ALifeCar, "cse_alife_car", CSE_ALifeDynamicObjectVisual, CSE_PHSkeleton) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeObjectBreakable, (CSE_ALifeDynamicObjectVisual), +void CSE_ALifeObjectBreakable::script_register(lua_State* luaState) { using namespace luabind; @@ -53,9 +53,9 @@ SCRIPT_EXPORT(CSE_ALifeObjectBreakable, (CSE_ALifeDynamicObjectVisual), luabind_class_dynamic_alife1( CSE_ALifeObjectBreakable, "cse_alife_object_breakable", CSE_ALifeDynamicObjectVisual) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeObjectClimable, (CSE_Shape, CSE_Abstract), +void CSE_ALifeObjectClimable::script_register(lua_State* luaState) { using namespace luabind; @@ -64,9 +64,9 @@ SCRIPT_EXPORT(CSE_ALifeObjectClimable, (CSE_Shape, CSE_Abstract), luabind_class_abstract2( CSE_ALifeObjectClimable, "cse_alife_object_climable", CSE_Shape, CSE_Abstract) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeMountedWeapon, (CSE_ALifeDynamicObjectVisual), +void CSE_ALifeMountedWeapon::script_register(lua_State* luaState) { using namespace luabind; @@ -75,9 +75,9 @@ SCRIPT_EXPORT(CSE_ALifeMountedWeapon, (CSE_ALifeDynamicObjectVisual), luabind_class_dynamic_alife1( CSE_ALifeMountedWeapon, "cse_alife_mounted_weapon", CSE_ALifeDynamicObjectVisual) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeTeamBaseZone, (CSE_ALifeSpaceRestrictor), +void CSE_ALifeTeamBaseZone::script_register(lua_State* luaState) { using namespace luabind; @@ -86,4 +86,4 @@ SCRIPT_EXPORT(CSE_ALifeTeamBaseZone, (CSE_ALifeSpaceRestrictor), luabind_class_dynamic_alife1( CSE_ALifeTeamBaseZone, "cse_alife_team_base_zone", CSE_ALifeSpaceRestrictor) ]; -}); +} diff --git a/src/xrServerEntities/xrServer_Objects_ALife_script3.cpp b/src/xrServerEntities/xrServer_Objects_ALife_script3.cpp index 126ba47f39d..269b8485e41 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_script3.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife_script3.cpp @@ -7,13 +7,11 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "xrServer_Objects_ALife_Monsters.h" #include "xrServer_script_macroses.h" -#include "xrScriptEngine/ScriptExporter.hpp" - -void set_yaw(CSE_ALifeObjectPhysic* obj, const float yaw) { obj->o_Angle.y = yaw; } -SCRIPT_EXPORT(CSE_ALifeObjectHangingLamp, (CSE_ALifeDynamicObjectVisual, CSE_PHSkeleton), +void CSE_ALifeObjectHangingLamp::script_register(lua_State* luaState) { using namespace luabind; @@ -22,9 +20,9 @@ SCRIPT_EXPORT(CSE_ALifeObjectHangingLamp, (CSE_ALifeDynamicObjectVisual, CSE_PHS luabind_class_dynamic_alife2( CSE_ALifeObjectHangingLamp, "cse_alife_object_hanging_lamp", CSE_ALifeDynamicObjectVisual, CSE_PHSkeleton) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeObjectPhysic, (CSE_ALifeDynamicObjectVisual, CSE_PHSkeleton), +void CSE_ALifeObjectPhysic::script_register(lua_State* luaState) { using namespace luabind; @@ -33,11 +31,11 @@ SCRIPT_EXPORT(CSE_ALifeObjectPhysic, (CSE_ALifeDynamicObjectVisual, CSE_PHSkelet luabind_class_dynamic_alife2( CSE_ALifeObjectPhysic, "cse_alife_object_physic", CSE_ALifeDynamicObjectVisual, CSE_PHSkeleton ) - .def("set_yaw", &set_yaw) + .def("set_yaw", +[](CSE_ALifeObjectPhysic* obj, const float yaw) { obj->o_Angle.y = yaw; }) ]; -}); +} -SCRIPT_EXPORT(CSE_ALifeSmartZone, (CSE_ALifeSpaceRestrictor, CSE_ALifeSchedulable), +void CSE_ALifeSmartZone::script_register(lua_State* luaState) { using namespace luabind; @@ -46,4 +44,4 @@ SCRIPT_EXPORT(CSE_ALifeSmartZone, (CSE_ALifeSpaceRestrictor, CSE_ALifeSchedulabl luabind_class_zone2( CSE_ALifeSmartZone, "cse_alife_smart_zone", CSE_ALifeSpaceRestrictor, CSE_ALifeSchedulable) ]; -}); +} diff --git a/src/xrServerEntities/xrServer_Objects_Abstract.cpp b/src/xrServerEntities/xrServer_Objects_Abstract.cpp index 152f6e56fdb..a9ef28bf7a9 100644 --- a/src/xrServerEntities/xrServer_Objects_Abstract.cpp +++ b/src/xrServerEntities/xrServer_Objects_Abstract.cpp @@ -80,7 +80,7 @@ void CSE_Visual::FillProps(LPCSTR pref, PropItemVec& items) PHelper().CreateChoose(items, PrepareKey(pref, abstract->name(), "Model" DELIMITER "Visual"), &visual_name, smVisual); V->OnChangeEvent.bind(this, &CSE_Visual::OnChangeVisual); V = PHelper().CreateChoose(items, PrepareKey(pref, abstract->name(), "Model" DELIMITER "Animation"), &startup_animation, - smSkeletonAnims, nullptr, (void*)*visual_name); + smSkeletonAnims, nullptr, (void*)visual_name.c_str()); V->OnChangeEvent.bind(this, &CSE_Visual::OnChangeAnim); PHelper().CreateFlag8(items, PrepareKey(pref, abstract->name(), "Model" DELIMITER "Obstacle"), &flags, flObstacle); } diff --git a/src/xrServerEntities/xrServer_Objects_Abstract.h b/src/xrServerEntities/xrServer_Objects_Abstract.h index e7a98a8613f..b9778a44a9e 100644 --- a/src/xrServerEntities/xrServer_Objects_Abstract.h +++ b/src/xrServerEntities/xrServer_Objects_Abstract.h @@ -62,13 +62,16 @@ class CSE_Visual void visual_write(NET_Packet& P); void set_visual(LPCSTR name, bool load = true); - LPCSTR get_visual() const { return *visual_name; } + LPCSTR get_visual() const { return visual_name.c_str(); } #ifndef MASTER_GOLD virtual void FillProps(LPCSTR pref, PropItemVec& items); #endif virtual CSE_Visual* visual() = 0; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; class CSE_Motion @@ -87,13 +90,16 @@ class CSE_Motion void motion_write(NET_Packet& P); void set_motion(LPCSTR name); - LPCSTR get_motion() const { return *motion_name; } + LPCSTR get_motion() const { return motion_name.c_str(); } #ifndef MASTER_GOLD virtual void FillProps(LPCSTR pref, PropItemVec& items); #endif virtual CSE_Motion* motion() = 0; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; class XR_NOVTABLE IServerEntityLEOwner diff --git a/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers.cpp b/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers.cpp index 719423ebd66..757eb479386 100644 --- a/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers.cpp +++ b/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers.cpp @@ -79,9 +79,11 @@ bool CSE_SmartCover::can_switch_online() const /* noexcept */ { return true; } bool CSE_SmartCover::can_switch_offline() const /* noexcept */ { return false; } bool CSE_SmartCover::interactive() const /* noexcept */ { return false; } LPCSTR CSE_SmartCover::description() const { return (m_description.c_str()); } -#ifndef AI_COMPILER -void CSE_SmartCover::set_available_loopholes(luabind::object table) { m_available_loopholes = table; } -#endif // #ifndef AI_COMPILER + +void CSE_SmartCover::set_available_loopholes(luabind::object table) +{ + m_available_loopholes = table; +} void CSE_SmartCover::STATE_Read(NET_Packet& tNetPacket, u16 size) { diff --git a/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers.h b/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers.h index fa9c88131b9..052ada3471f 100644 --- a/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers.h +++ b/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers.h @@ -41,9 +41,8 @@ class CSE_SmartCover : public CSE_ALifeDynamicObject, public CSE_Shape BOOL m_is_combat_cover; BOOL m_can_fire; bool m_need_to_reparse_loopholes; -#ifndef AI_COMPILER + luabind::object m_available_loopholes; -#endif // #ifndef AI_COMPILER #ifndef MASTER_GOLD private: @@ -69,9 +68,8 @@ class CSE_SmartCover : public CSE_ALifeDynamicObject, public CSE_Shape virtual bool can_switch_offline() const /* noexcept */; virtual bool interactive() const /* noexcept */; LPCSTR description() const; -#ifndef AI_COMPILER + void set_available_loopholes(luabind::object table); -#endif // #ifndef AI_COMPILER #ifndef MASTER_GOLD virtual void on_render(CDUInterface* du, IServerEntityLEOwner* owner, bool bSelected, @@ -92,6 +90,9 @@ class CSE_SmartCover : public CSE_ALifeDynamicObject, public CSE_Shape virtual void STATE_Read(NET_Packet& P, u16 size); virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CSE_ALifeDynamicObject); }; #pragma warning(pop) #endif diff --git a/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers_script.cpp b/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers_script.cpp index 597a3a76b57..a7da9976f4d 100644 --- a/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers_script.cpp +++ b/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers_script.cpp @@ -7,11 +7,11 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "xrServer_Objects_Alife_Smartcovers.h" #include "xrServer_script_macroses.h" -#include "xrScriptEngine/ScriptExporter.hpp" -static void CSE_SmartCover_Export(lua_State* luaState) +void CSE_SmartCover::script_register(lua_State* luaState) { using namespace luabind; @@ -19,13 +19,9 @@ static void CSE_SmartCover_Export(lua_State* luaState) [ luabind_class_dynamic_alife1(CSE_SmartCover, "cse_smart_cover", CSE_ALifeDynamicObject) .def("description", &CSE_SmartCover::description) -#ifndef AI_COMPILER .def("set_available_loopholes", &CSE_SmartCover::set_available_loopholes) -#endif #ifndef MASTER_GOLD .def("set_loopholes_table_checker", &CSE_SmartCover::set_loopholes_table_checker) #endif ]; } - -SCRIPT_EXPORT_FUNC(CSE_SmartCover, (CSE_ALifeDynamicObject), CSE_SmartCover_Export); diff --git a/src/xrServerEntities/xrServer_Objects_script.cpp b/src/xrServerEntities/xrServer_Objects_script.cpp index adbd11796a9..7adc1ac84ad 100644 --- a/src/xrServerEntities/xrServer_Objects_script.cpp +++ b/src/xrServerEntities/xrServer_Objects_script.cpp @@ -7,11 +7,11 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" + #include "xrServer_Objects.h" #include "PHNetState.h" #include "xrServer_script_macroses.h" #include "script_ini_file.h" -#include "xrScriptEngine/ScriptExporter.hpp" pcstr get_section_name(const CSE_Abstract* abstract) { return (abstract->name()); } pcstr get_name(const CSE_Abstract* abstract) { return (abstract->name_replace()); } @@ -51,7 +51,7 @@ struct CSEAbstractWrapperBase : public T, public luabind::wrap_base } }; -SCRIPT_EXPORT(CPureServerObject, (), +void CPureServerObject::script_register(lua_State* luaState) { using namespace luabind; @@ -62,9 +62,9 @@ SCRIPT_EXPORT(CPureServerObject, (), class_("cpure_server_object") // .def( constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CSE_Abstract, (CPureServerObject), +void CSE_Abstract::script_register(lua_State* luaState) { using namespace luabind; @@ -73,6 +73,8 @@ SCRIPT_EXPORT(CSE_Abstract, (CPureServerObject), module(luaState) [ + def("script_server_object_version", &script_server_object_version), + class_("cse_abstract") .def_readonly("id", &BaseType::ID) .def_readonly("parent_id", &BaseType::ID_Parent) @@ -89,9 +91,9 @@ SCRIPT_EXPORT(CSE_Abstract, (CPureServerObject), .def("UPDATE_Write", &BaseType::UPDATE_Write, &WrapType::UPDATE_Write_static) // .def( constructor()) ]; -}); +} -SCRIPT_EXPORT(CSE_Shape, (), +void CSE_Shape::script_register(lua_State* luaState) { using namespace luabind; @@ -100,9 +102,9 @@ SCRIPT_EXPORT(CSE_Shape, (), class_("cse_shape") // .def( constructor<>()) ]; -}); +} -SCRIPT_EXPORT(CSE_Visual, (), +void CSE_Visual::script_register(lua_State* luaState) { using namespace luabind; @@ -112,9 +114,9 @@ SCRIPT_EXPORT(CSE_Visual, (), // .def( constructor<>()) // .def( constructor()) ]; -}); +} -SCRIPT_EXPORT(CSE_Motion, (), +void CSE_Motion::script_register(lua_State* luaState) { using namespace luabind; @@ -124,9 +126,9 @@ SCRIPT_EXPORT(CSE_Motion, (), // .def( constructor<>()) // .def( constructor()) ]; -}); +} -SCRIPT_EXPORT(CSE_Spectator, (CSE_Abstract), +void CSE_Spectator::script_register(lua_State* luaState) { using namespace luabind; @@ -134,9 +136,9 @@ SCRIPT_EXPORT(CSE_Spectator, (CSE_Abstract), [ luabind_class_abstract1(CSE_Spectator, "cse_spectator", CSE_Abstract) ]; -}); +} -SCRIPT_EXPORT(CSE_Temporary, (CSE_Abstract), +void CSE_Temporary::script_register(lua_State* luaState) { using namespace luabind; @@ -144,4 +146,4 @@ SCRIPT_EXPORT(CSE_Temporary, (CSE_Abstract), [ luabind_class_abstract1(CSE_Temporary, "cse_temporary", CSE_Abstract) ]; -}); +} diff --git a/src/xrServerEntities/xrServer_Objects_script2.cpp b/src/xrServerEntities/xrServer_Objects_script2.cpp index eb736b20b1d..5452512a59b 100644 --- a/src/xrServerEntities/xrServer_Objects_script2.cpp +++ b/src/xrServerEntities/xrServer_Objects_script2.cpp @@ -1,9 +1,9 @@ #include "pch_script.h" + #include "xrServer_Objects.h" #include "xrServer_script_macroses.h" -#include "xrScriptEngine/ScriptExporter.hpp" -SCRIPT_EXPORT(CSE_PHSkeleton, (), +void CSE_PHSkeleton::script_register(lua_State* luaState) { using namespace luabind; @@ -11,9 +11,9 @@ SCRIPT_EXPORT(CSE_PHSkeleton, (), [ class_("cse_ph_skeleton") ]; -}); +} -SCRIPT_EXPORT(CSE_AbstractVisual, (CSE_Visual, CSE_Abstract), +void CSE_AbstractVisual::script_register(lua_State* luaState) { using namespace luabind; @@ -22,16 +22,4 @@ SCRIPT_EXPORT(CSE_AbstractVisual, (CSE_Visual, CSE_Abstract), luabind_class_abstract2(CSE_AbstractVisual, "CSE_AbstractVisual", CSE_Visual, CSE_Abstract) .def("getStartupAnimation", &CSE_AbstractVisual::getStartupAnimation) ]; -}); - -/** -SCRIPT_EXPORT(CSE_SpawnGroup, (CSE_Abstract), -{ - using namespace luabind; - - module(luaState) - [ - luabind_class_abstract1(CSE_SpawnGroup, "cse_event", CSE_Abstract) - ]; -}); -**/ +} diff --git a/src/xrServerEntities/xrServer_script_macroses.h b/src/xrServerEntities/xrServer_script_macroses.h index d7c68c217d8..827677582aa 100644 --- a/src/xrServerEntities/xrServer_script_macroses.h +++ b/src/xrServerEntities/xrServer_script_macroses.h @@ -12,6 +12,7 @@ #include "xrEProps.h" #include "ai_space.h" #include "xrScriptEngine/script_engine.hpp" +#include "xrScriptEngine/script_space.hpp" #include "luabind/error.hpp" #ifdef XRGAME_EXPORTS #include "alife_smart_terrain_task.h" diff --git a/src/xrSound/CMakeLists.txt b/src/xrSound/CMakeLists.txt index 8d27602eb22..bd190368f78 100644 --- a/src/xrSound/CMakeLists.txt +++ b/src/xrSound/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(xrSound SHARED) +add_library(xrSound) target_sources_grouped( TARGET xrSound @@ -74,6 +74,8 @@ target_sources_grouped( stdafx.h ) +set_source_files_properties(guids.cpp PROPERTIES SKIP_PRECOMPILE_HEADERS ON) + target_sources_grouped( TARGET xrSound NAME "Source" @@ -120,7 +122,6 @@ target_include_directories(xrSound PRIVATE "${CMAKE_SOURCE_DIR}/src" "${CMAKE_SOURCE_DIR}/src/xrEngine" - "${OPENAL_INCLUDE_DIR}" ) target_link_libraries(xrSound @@ -130,7 +131,7 @@ target_link_libraries(xrSound xrAPI xrCDB xrMaterialSystem - ${OPENAL_LIBRARY} + OpenAL::OpenAL Ogg::Ogg Vorbis::Vorbis Vorbis::VorbisFile @@ -150,6 +151,8 @@ target_precompile_headers(xrSound stdafx.h ) -install(TARGETS xrSound LIBRARY - DESTINATION "${CMAKE_INSTALL_LIBDIR}" -) +if (BUILD_SHARED_LIBS) + install(TARGETS xrSound LIBRARY + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) +endif() diff --git a/src/xrSound/SoundRender_Environment.cpp b/src/xrSound/SoundRender_Environment.cpp index 79437ab8e5d..0434b18d9d5 100644 --- a/src/xrSound/SoundRender_Environment.cpp +++ b/src/xrSound/SoundRender_Environment.cpp @@ -190,14 +190,14 @@ void SoundEnvironment_LIB::Unload() int SoundEnvironment_LIB::GetID(pcstr name) { for (auto it = library.begin(); it != library.end(); ++it) - if (0 == xr_stricmp(name, *(*it)->name)) + if (0 == xr_stricmp(name, (*it)->name.c_str())) return int(it - library.begin()); return -1; } CSoundRender_Environment* SoundEnvironment_LIB::Get(pcstr name) { for (const auto& it : library) - if (0 == xr_stricmp(name, *it->name)) + if (0 == xr_stricmp(name, it->name.c_str())) return it; return nullptr; } @@ -210,7 +210,7 @@ CSoundRender_Environment* SoundEnvironment_LIB::Append(CSoundRender_Environment* void SoundEnvironment_LIB::Remove(pcstr name) { for (auto it = library.begin(); it != library.end(); ++it) - if (0 == xr_stricmp(name, *(*it)->name)) + if (0 == xr_stricmp(name, (*it)->name.c_str())) { xr_delete(*it); library.erase(it); diff --git a/src/xrSound/SoundRender_Source.h b/src/xrSound/SoundRender_Source.h index d8edc8c5d28..3c3c4a65a44 100644 --- a/src/xrSound/SoundRender_Source.h +++ b/src/xrSound/SoundRender_Source.h @@ -2,7 +2,7 @@ struct OggVorbis_File; -enum class SoundFormat +enum class SoundFormat : u8 { Unknown, PCM, diff --git a/src/xrSound/xrSound.vcxproj b/src/xrSound/xrSound.vcxproj index b23ca399f16..bcbe5942066 100644 --- a/src/xrSound/xrSound.vcxproj +++ b/src/xrSound/xrSound.vcxproj @@ -28,6 +28,10 @@ libogg_static.lib;libvorbis_static.lib;libvorbisfile.lib;OpenAL32.lib;%(AdditionalDependencies) + + libogg_static.lib;libvorbis_static.lib;libvorbisfile.lib;OpenAL32.lib;%(AdditionalDependencies) + + @@ -87,14 +91,6 @@ {2c419512-6eee-4707-bc51-2e834855552e} - - - Document - - - Document - - diff --git a/src/xrSound/xrSound.vcxproj.filters b/src/xrSound/xrSound.vcxproj.filters index 04c1619480b..c194d703fc3 100644 --- a/src/xrSound/xrSound.vcxproj.filters +++ b/src/xrSound/xrSound.vcxproj.filters @@ -138,8 +138,4 @@ - - - - \ No newline at end of file diff --git a/src/xrUICore/Buttons/UIButton.h b/src/xrUICore/Buttons/UIButton.h index 29e42e439e2..171b055c184 100644 --- a/src/xrUICore/Buttons/UIButton.h +++ b/src/xrUICore/Buttons/UIButton.h @@ -1,10 +1,11 @@ #pragma once + #include "xrUICore/Static/UIStatic.h" class XRUICORE_API CUIButton : public CUIStatic { -private: - typedef CUIStatic inherited; +protected: + using inherited = CUIStatic; public: CUIButton(); @@ -23,11 +24,12 @@ class XRUICORE_API CUIButton : public CUIStatic virtual void OnFocusLost(); //ÑоÑтоÑÐ½Ð¸Ñ Ð² которых находитÑÑ ÐºÐ½Ð¾Ð¿ÐºÐ° - typedef enum { + enum E_BUTTON_STATE : u8 + { BUTTON_NORMAL, //кнопка никак не затрагиваетÑÑ BUTTON_PUSHED, //в нажатом ÑотоÑнии BUTTON_UP //при удерживаемой кнопки мыши - } E_BUTTON_STATE; + }; //заново подготовить ÑоÑтоÑние virtual void Reset(); @@ -49,13 +51,16 @@ class XRUICORE_API CUIButton : public CUIStatic pcstr GetDebugType() override { return "CUIButton"; } protected: - struct ButtonAccelerator + struct alignas(2) ButtonAccelerator { - s16 accel; - bool isKey; + s16 accel : 15; + bool isKey : 1; }; - E_BUTTON_STATE m_eButtonState; ButtonAccelerator m_accelerators[4]{}; + E_BUTTON_STATE m_eButtonState; bool m_bIsSwitch; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CUIStatic, CUIWindow); }; diff --git a/src/xrUICore/Buttons/UIButton_script.cpp b/src/xrUICore/Buttons/UIButton_script.cpp deleted file mode 100644 index 34ff9cf3d3a..00000000000 --- a/src/xrUICore/Buttons/UIButton_script.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include "pch.hpp" -#include "UIButton.h" -#include "UI3tButton.h" -#include "UICheckButton.h" -#include "SpinBox/UISpinNum.h" -#include "SpinBox/UISpinText.h" -#include "TrackBar/UITrackBar.h" -#include "xrScriptEngine/ScriptExporter.hpp" - -SCRIPT_EXPORT(CUIButton, (CUIStatic, CUIWindow), -{ - using namespace luabind; - - module(luaState) - [ - class_("CUIButton") - .def("Init", +[](CUIButton* self, float x, float y, float width, float height) - { - const Frect rect { x, y, width, height }; - self->SetWndRect(rect); - }) - .def("Init", +[](CUIButton* self, cpcstr texture, float x, float y, float width, float height) - { - const Frect rect { x, y, width, height }; - self->SetWndRect(rect); - self->InitTexture(texture); - }) - .def(constructor<>()), - - class_("CUI3tButton") - .def(constructor<>()), - - class_("CUICheckButton") - .def(constructor<>()) - .def("GetCheck", &CUICheckButton::GetCheck) - .def("SetCheck", &CUICheckButton::SetCheck) - .def("SetDependControl", &CUICheckButton::SetDependControl), - - class_("CUICustomSpin") - .def("Init", +[](CUICustomSpin* self, float x, float y, float width, float height) - { - const Fvector2 pos { x, y }; - const Fvector2 size { width, height }; - - self->InitSpin(pos, size); - }) - .def("GetText", &CUICustomSpin::GetText), - - class_("CUISpinNum") - .def(constructor<>()), - - class_("CUISpinFlt") - .def(constructor<>()), - - class_("CUISpinText") - .def(constructor<>()), - - class_("CUITrackBar") - .def(constructor<>()) - .def("GetCheck", &CUITrackBar::GetCheck) - .def("SetCheck", &CUITrackBar::SetCheck) - .def("GetIValue", &CUITrackBar::GetIValue) - .def("GetFValue", &CUITrackBar::GetFValue) - .def("SetOptIBounds", &CUITrackBar::SetOptIBounds) - .def("SetOptFBounds", &CUITrackBar::SetOptFBounds) - .def("SetCurrentValue", &CUITrackBar::SetCurrentOptValue)]; -}); diff --git a/src/xrUICore/CMakeLists.txt b/src/xrUICore/CMakeLists.txt index 2b2ffbfb2fd..ae52d311ec3 100644 --- a/src/xrUICore/CMakeLists.txt +++ b/src/xrUICore/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(xrUICore SHARED) +add_library(xrUICore) target_sources(xrUICore PRIVATE pch.cpp @@ -8,6 +8,7 @@ target_sources(xrUICore PRIVATE ui_debug.cpp ui_debug.h ui_defs.h + ui_export_script.cpp ui_focus.cpp ui_focus.h ui_styles.cpp @@ -22,7 +23,6 @@ target_sources(xrUICore PRIVATE Buttons/UIBtnHint.h Buttons/UIButton.cpp Buttons/UIButton.h - Buttons/UIButton_script.cpp Buttons/UICheckButton.cpp Buttons/UICheckButton.h Buttons/UIRadioButton.cpp @@ -32,7 +32,6 @@ target_sources(xrUICore PRIVATE Callbacks/callback_info.h ComboBox/UIComboBox.cpp ComboBox/UIComboBox.h - ComboBox/UIComboBox_script.cpp Cursor/UICursor.cpp Cursor/UICursor.h EditBox/UICustomEdit.cpp @@ -41,7 +40,6 @@ target_sources(xrUICore PRIVATE EditBox/UIEditBox.h EditBox/UIEditBoxEx.cpp EditBox/UIEditBoxEx.h - EditBox/UIEditBox_script.cpp FontManager/FontManager.cpp FontManager/FontManager.h Hint/UIHint.cpp @@ -61,7 +59,6 @@ target_sources(xrUICore PRIVATE ListBox/UIListBoxItem.h ListBox/UIListBoxItemMsgChain.cpp ListBox/UIListBoxItemMsgChain.h - ListBox/UIListBox_script.cpp ListWnd/UIListItem.cpp ListWnd/UIListItem.h ListWnd/UIListItemEx.cpp @@ -69,26 +66,20 @@ target_sources(xrUICore PRIVATE ListWnd/UIListWnd.cpp ListWnd/UIListWnd.h ListWnd/UIListWnd_inline.h - ListWnd/UIListWnd_script.cpp MessageBox/UIMessageBox.cpp MessageBox/UIMessageBox.h - MessageBox/UIMessageBox_script.cpp Options/UIOptionsItem.cpp Options/UIOptionsItem.h Options/UIOptionsManager.cpp Options/UIOptionsManager.h - Options/UIOptionsManagerScript.cpp - Options/UIOptionsManagerScript.h ProgressBar/UIDoubleProgressBar.cpp ProgressBar/UIDoubleProgressBar.h ProgressBar/UIProgressBar.cpp ProgressBar/UIProgressBar.h - ProgressBar/UIProgressBar_script.cpp ProgressBar/UIProgressShape.cpp ProgressBar/UIProgressShape.h PropertiesBox/UIPropertiesBox.cpp PropertiesBox/UIPropertiesBox.h - PropertiesBox/UIPropertiesBox_script.cpp ScrollBar/UIFixedScrollBar.cpp ScrollBar/UIFixedScrollBar.h ScrollBar/UIScrollBar.cpp @@ -111,12 +102,10 @@ target_sources(xrUICore PRIVATE Static/UIStatic.h Static/UIStaticItem.cpp Static/UIStaticItem.h - Static/UIStatic_script.cpp TabControl/UITabButton.cpp TabControl/UITabButton.h TabControl/UITabControl.cpp TabControl/UITabControl.h - TabControl/UITabControl_script.cpp TrackBar/UITrackBar.cpp TrackBar/UITrackBar.h Windows/UIFrameLineWnd.cpp @@ -127,7 +116,6 @@ target_sources(xrUICore PRIVATE Windows/UITextFrameLineWnd.h Windows/UIWindow.cpp Windows/UIWindow.h - Windows/UIWindow_script.cpp XML/UITextureMaster.cpp XML/UITextureMaster.h XML/UIXmlInitBase.cpp @@ -153,11 +141,6 @@ target_link_libraries(xrUICore xrSound ) -if (WIN32) - add_compile_options(/fp:fast "/Yupch.hpp") - set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/pch.cpp" PROPERTIES COMPILE_FLAGS /Yc) -endif() - target_compile_definitions(xrUICore PRIVATE XRUICORE_EXPORTS @@ -173,6 +156,8 @@ target_precompile_headers(xrUICore pch.hpp ) -install(TARGETS xrUICore LIBRARY - DESTINATION "${CMAKE_INSTALL_LIBDIR}" -) +if (BUILD_SHARED_LIBS) + install(TARGETS xrUICore LIBRARY + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) +endif() diff --git a/src/xrUICore/ComboBox/UIComboBox.cpp b/src/xrUICore/ComboBox/UIComboBox.cpp index 5e450299a37..6117e1b1975 100644 --- a/src/xrUICore/ComboBox/UIComboBox.cpp +++ b/src/xrUICore/ComboBox/UIComboBox.cpp @@ -156,7 +156,7 @@ void CUIComboBox::SetCurrentOptValue() tok++; } - cpcstr cur_val = *StringTable().translate(GetOptTokenValue()); + cpcstr cur_val = StringTable().translate(GetOptTokenValue()).c_str(); m_text.SetText(cur_val); m_list_box.SetSelectedText(cur_val); diff --git a/src/xrUICore/ComboBox/UIComboBox.h b/src/xrUICore/ComboBox/UIComboBox.h index dacdbc7c165..611c3c6be23 100644 --- a/src/xrUICore/ComboBox/UIComboBox.h +++ b/src/xrUICore/ComboBox/UIComboBox.h @@ -10,7 +10,12 @@ class CUIListBoxItem; class XRUICORE_API CUIComboBox final : public CUIWindow, public CUIOptionsItem, public pureRender { friend class CUIXmlInitBase; - typedef enum { LIST_EXPANDED, LIST_FONDED } E_COMBO_STATE; + + enum E_COMBO_STATE : u8 + { + LIST_EXPANDED, + LIST_FONDED + }; xr_vector m_disabled; @@ -67,11 +72,11 @@ class XRUICORE_API CUIComboBox final : public CUIWindow, public CUIOptionsItem, u32 GetSize() const; protected: - bool m_bInited; int m_iListHeight; int m_itoken_id; - E_COMBO_STATE m_eState; int m_opt_backup_value; + E_COMBO_STATE m_eState; + bool m_bInited; CUI_IB_FrameLineWnd m_frameLine; CUIStatic m_text{ "Text" }; @@ -83,4 +88,7 @@ class XRUICORE_API CUIComboBox final : public CUIWindow, public CUIOptionsItem, CUIListBox m_list_box; void SetTextColor(u32 color) { m_textColor[0] = color; }; void SetTextColorD(u32 color) { m_textColor[1] = color; }; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CUIWindow); }; diff --git a/src/xrUICore/ComboBox/UIComboBox_script.cpp b/src/xrUICore/ComboBox/UIComboBox_script.cpp deleted file mode 100644 index beecad65483..00000000000 --- a/src/xrUICore/ComboBox/UIComboBox_script.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// File: UIComboBox_script.cpp -// Description: exports CUIComobBox to LUA environment -// Created: 11.12.2004 -// Author: Serhiy O. Vynnychenko -// Mail: narrator@gsc-game.kiev.ua -// -// Copyright 2004 GSC Game World -// - -#include "pch.hpp" -#include "UIComboBox.h" -#include "ListBox/UIListBoxItem.h" -#include "xrScriptEngine/ScriptExporter.hpp" - -SCRIPT_EXPORT(CUIComboBox, (CUIWindow), -{ - using namespace luabind; - - module(luaState) - [ - class_("CUIComboBox") - .def(constructor<>()) - .def("Init", +[](CUIComboBox* self, float x, float y, float width) - { - const Fvector2 pos { x, y }; - self->InitComboBox(pos, width); - }) - .def("Init", +[](CUIComboBox* self, float x, float y, float width, float /*height*/) - { - const Fvector2 pos { x, y }; - self->InitComboBox(pos, width); - }) - .def("SetVertScroll", &CUIComboBox::SetVertScroll) - .def("SetListLength", &CUIComboBox::SetListLength) - .def("CurrentID", &CUIComboBox::CurrentID) - .def("SetCurrentID", &CUIComboBox::SetItemIDX) - .def("disable_id", &CUIComboBox::disable_id) - .def("enable_id", &CUIComboBox::enable_id) - .def("AddItem", &CUIComboBox::AddItem_) - .def("GetText", &CUIComboBox::GetText) - .def("GetTextOf", &CUIComboBox::GetTextOf) - .def("SetText", &CUIComboBox::SetText) - .def("ClearList", &CUIComboBox::ClearList) - .def("SetCurrentValue", &CUIComboBox::SetCurrentOptValue) - .def("SetCurrentOptValue", &CUIComboBox::SetCurrentOptValue) - .def("SetCurrentIdx", &CUIComboBox::SetSelectedIDX) - .def("GetCurrentIdx", &CUIComboBox::GetSelectedIDX) - ]; -}); diff --git a/src/xrUICore/EditBox/UICustomEdit.h b/src/xrUICore/EditBox/UICustomEdit.h index 8e18d0ee4ac..2b7833c2e06 100644 --- a/src/xrUICore/EditBox/UICustomEdit.h +++ b/src/xrUICore/EditBox/UICustomEdit.h @@ -9,8 +9,8 @@ enum init_mode : u32; class XRUICORE_API CUICustomEdit : public CUIStatic { -private: - typedef CUIStatic inherited; +protected: + using inherited = CUIStatic; public: CUICustomEdit(); @@ -53,10 +53,8 @@ class XRUICORE_API CUICustomEdit : public CUIStatic protected: typedef fastdelegate::FastDelegate0 Callback; - enum - { - EDIT_BUF_SIZE = 256 - }; + static constexpr size_t EDIT_BUF_SIZE = 256; + text_editor::line_edit_control* m_editor_control; text_editor::line_edit_control& ec(); text_editor::line_edit_control const& ec() const; diff --git a/src/xrUICore/EditBox/UIEditBox.h b/src/xrUICore/EditBox/UIEditBox.h index b7e4d1e10d8..a9518a578c5 100644 --- a/src/xrUICore/EditBox/UIEditBox.h +++ b/src/xrUICore/EditBox/UIEditBox.h @@ -27,4 +27,7 @@ class XRUICORE_API CUIEditBox : public CUIOptionsItem, public CUICustomEdit protected: CUIFrameLineWnd* m_frameLine; shared_str m_opt_backup_value; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CUIWindow); }; diff --git a/src/xrUICore/EditBox/UIEditBox_script.cpp b/src/xrUICore/EditBox/UIEditBox_script.cpp deleted file mode 100644 index 075d1fe8571..00000000000 --- a/src/xrUICore/EditBox/UIEditBox_script.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "pch.hpp" -#include "UIEditBox.h" -#include "xrScriptEngine/ScriptExporter.hpp" - -SCRIPT_EXPORT(CUIEditBox, (CUIWindow), -{ - using namespace luabind; - - module(luaState) - [ - class_("CUICustomEdit") - .def("SetText", &CUICustomEdit::SetText) - .def("GetText", &CUICustomEdit::GetText) - .def("CaptureFocus", &CUICustomEdit::CaptureFocus) - .def("SetNextFocusCapturer", &CUICustomEdit::SetNextFocusCapturer), - - class_("CUIEditBox") - .def(constructor<>()) - .def("InitTexture", &CUIEditBox::InitTexture) - .def("InitTexture", +[](CUIEditBox* self, pcstr texture) { self->InitTexture(texture); }) - ]; -}); diff --git a/src/xrUICore/InteractiveBackground/UIInteractiveBackground.h b/src/xrUICore/InteractiveBackground/UIInteractiveBackground.h index dbbfb78ac05..a80bdd76dc9 100644 --- a/src/xrUICore/InteractiveBackground/UIInteractiveBackground.h +++ b/src/xrUICore/InteractiveBackground/UIInteractiveBackground.h @@ -16,7 +16,7 @@ #include "xrUICore/Windows/UIWindow.h" #include "xrUICore/Windows/UIFrameLineWnd.h" -enum IBState +enum IBState : u8 { S_Enabled = 0, S_Disabled, diff --git a/src/xrUICore/Lines/UILines.cpp b/src/xrUICore/Lines/UILines.cpp index f0955296e5d..1e8ee2579c7 100644 --- a/src/xrUICore/Lines/UILines.cpp +++ b/src/xrUICore/Lines/UILines.cpp @@ -60,7 +60,7 @@ void CUILines::SetText(const char* text) Reset(); } } -void CUILines::SetTextST(LPCSTR str_id) { SetText(*StringTable().translate(str_id)); } +void CUILines::SetTextST(LPCSTR str_id) { SetText(StringTable().translate(str_id).c_str()); } LPCSTR CUILines::GetText() const { return m_text.c_str(); } void CUILines::Reset() { m_lines.clear(); } float get_str_width(CGameFont* pFont, char ch) diff --git a/src/xrUICore/ListBox/UIListBox.h b/src/xrUICore/ListBox/UIListBox.h index eb7fd53986d..93f6739910f 100644 --- a/src/xrUICore/ListBox/UIListBox.h +++ b/src/xrUICore/ListBox/UIListBox.h @@ -1,4 +1,5 @@ #pragma once + #include "xrUICore/ScrollView/UIScrollView.h" class CUIListBoxItem; @@ -50,4 +51,7 @@ class XRUICORE_API CUIListBox final : public CUIScrollView shared_str m_selection_texture; bool m_bImmediateSelection; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CUIScrollView); }; diff --git a/src/xrUICore/ListBox/UIListBoxItem.h b/src/xrUICore/ListBox/UIListBoxItem.h index 649c6a8c024..bd58cd15f54 100644 --- a/src/xrUICore/ListBox/UIListBoxItem.h +++ b/src/xrUICore/ListBox/UIListBoxItem.h @@ -1,4 +1,5 @@ #pragma once + #include "xrUICore/Windows/UIFrameLineWnd.h" class CUIStatic; @@ -41,4 +42,7 @@ class XRUICORE_API CUIListBoxItem : public CUIFrameLineWnd, public CUISelectable u32 tag; void* pData; float FieldsLength() const; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CUIFrameLineWnd); }; diff --git a/src/xrUICore/ListBox/UIListBox_script.cpp b/src/xrUICore/ListBox/UIListBox_script.cpp deleted file mode 100644 index 3ac627d7d9f..00000000000 --- a/src/xrUICore/ListBox/UIListBox_script.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include "pch.hpp" -#include "UIListBox.h" -#include "UIListBoxItem.h" -#include "UIListBoxItemMsgChain.h" -#include "SpinBox/UISpinText.h" -#include "ComboBox/UIComboBox.h" -#include "xrScriptEngine/ScriptExporter.hpp" - -struct CUIListBoxItemWrapper : public CUIListBoxItem, public luabind::wrap_base -{ - CUIListBoxItemWrapper(float h) : CUIListBoxItem(h) {} - pcstr GetDebugType() override { return "CUIListBoxItemScript"; } -}; - -struct CUIListBoxItemMsgChainWrapper : public CUIListBoxItemMsgChain, public luabind::wrap_base -{ - CUIListBoxItemMsgChainWrapper(float h) : CUIListBoxItemMsgChain(h) {} - pcstr GetDebugType() override { return "CUIListBoxItemMsgChainScript"; } -}; - -// clang-format off -SCRIPT_EXPORT(CUIListBox, (CUIScrollView), -{ - using namespace luabind; - using namespace luabind::policy; - - module(luaState) - [ - class_("CUIListBox") - .def(constructor<>()) - .def("ShowSelectedItem", &CUIListBox::Show) - .def("RemoveAll", &CUIListBox::Clear) - .def("GetSize", &CUIListBox::GetSize) - .def("GetSelectedItem", &CUIListBox::GetSelectedItem) - .def("GetSelectedIndex", &CUIListBox::GetSelectedIDX) - .def("SetSelectedIndex", &CUIListBox::SetSelectedIDX) - .def("SetItemHeight", &CUIListBox::SetItemHeight) - .def("GetItemHeight", &CUIListBox::GetItemHeight) - .def("GetItemByIndex", &CUIListBox::GetItemByIDX) - .def("GetItem", &CUIListBox::GetItem) - .def("RemoveItem", &CUIListBox::RemoveWindow) - .def("AddTextItem", &CUIListBox::AddTextItem) - .def("AddExistingItem", &CUIListBox::AddExistingItem, adopt<2>()) - ]; -}); - -SCRIPT_EXPORT(CUIListBoxItem, (CUIFrameLineWnd), -{ - using namespace luabind; - - module(luaState) - [ - class_("CUIListBoxItem") - .def(constructor()) - .def("GetTextItem", &CUIListBoxItem::GetTextItem) - .def("AddTextField", &CUIListBoxItem::AddTextField) - .def("AddIconField", &CUIListBoxItem::AddIconField) - .def("SetTextColor", &CUIListBoxItem::SetTextColor) - ]; -}); - -SCRIPT_EXPORT(CUIListBoxItemMsgChain, (CUIListBoxItem), -{ - using namespace luabind; - - module(luaState) - [ - class_("CUIListBoxItemMsgChain") - .def(constructor()) - ]; -}); -// clang-format on diff --git a/src/xrUICore/ListWnd/UIListItem.h b/src/xrUICore/ListWnd/UIListItem.h index bd8f0c3e981..b48b2689985 100644 --- a/src/xrUICore/ListWnd/UIListItem.h +++ b/src/xrUICore/ListWnd/UIListItem.h @@ -55,4 +55,7 @@ class XRUICORE_API CUIListItem : public CUIButton // подÑвечиваетÑÑ ÐºÐ½Ð¾Ð¿ÐºÐ° или нет? bool m_bHighlightText; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CUIButton); }; diff --git a/src/xrUICore/ListWnd/UIListWnd.cpp b/src/xrUICore/ListWnd/UIListWnd.cpp index 292771dd0f3..147d02d1d1a 100644 --- a/src/xrUICore/ListWnd/UIListWnd.cpp +++ b/src/xrUICore/ListWnd/UIListWnd.cpp @@ -1,8 +1,9 @@ #include"pch.hpp" + #include "UIListWnd.h" -//.#include "uiscrollbar.h" -#include "Cursor/UICursor.h" +#include "ScrollBar/UIScrollBar.h" #include "Windows/UIFrameLineWnd.h" +#include "Cursor/UICursor.h" //#define ACTIVE_BACKGROUND "ui\\ui_pop_up_active_back" //#define ACTIVE_BACKGROUND_WIDTH 16 @@ -57,7 +58,7 @@ void CUIListWnd::InitListWnd(Fvector2 pos, Fvector2 size, float item_height) AttachChild(m_ScrollBar); if (!!m_scrollbar_profile) - m_ScrollBar->InitScrollBar(Fvector2().set(size.x, 0.0f), size.y, false, *m_scrollbar_profile); + m_ScrollBar->InitScrollBar(Fvector2().set(size.x, 0.0f), size.y, false, m_scrollbar_profile.c_str()); else m_ScrollBar->InitScrollBar(Fvector2().set(size.x, 0.0f), size.y, false); diff --git a/src/xrUICore/ListWnd/UIListWnd.h b/src/xrUICore/ListWnd/UIListWnd.h index e005a763a2a..529eac04d68 100644 --- a/src/xrUICore/ListWnd/UIListWnd.h +++ b/src/xrUICore/ListWnd/UIListWnd.h @@ -40,8 +40,6 @@ class XRUICORE_API CUIListWnd final : public CUIWindow bool AddItem(const char* str, const float shift = 0.0f, void* pData = NULL, int value = 0, int insertBeforeIdx = -1); - virtual bool AddItem_script(CUIListItem* item); - template bool AddItem(Element* pItem, int insertBeforeIdx = -1); @@ -157,6 +155,9 @@ class XRUICORE_API CUIListWnd final : public CUIWindow // Текущий уникальный идентификатор int m_iLastUniqueID; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CUIWindow); }; #include "UIListWnd_inline.h" diff --git a/src/xrUICore/ListWnd/UIListWnd_script.cpp b/src/xrUICore/ListWnd/UIListWnd_script.cpp deleted file mode 100644 index 58b638bfd1e..00000000000 --- a/src/xrUICore/ListWnd/UIListWnd_script.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include "pch.hpp" -#include "xrScriptEngine/ScriptExporter.hpp" -#include "UIListWnd.h" -#include "UIListItemEx.h" - -bool CUIListWnd::AddItem_script(CUIListItem* item) -{ - return AddItem(item, -1); -} - -struct CUIListItemWrapper final : public CUIListItem, public luabind::wrap_base -{ - pcstr GetDebugType() override { return "CUIListItemScript"; } -}; - -struct CUIListItemExWrapper final : public CUIListItemEx, public luabind::wrap_base -{ - pcstr GetDebugType() override { return "CUIListItemExScript"; } -}; - -// clang-format off -#pragma optimize("s", on) -SCRIPT_EXPORT(CUIListWnd, (CUIWindow), -{ - using namespace luabind; - using namespace luabind::policy; - - module(luaState) - [ - class_("CUIListWnd") - .def(constructor<>()) - //.def("AddText", &CUIListWnd::AddText_script) - .def("AddItem", &CUIListWnd::AddItem_script, adopt<2>()) - .def("RemoveItem", &CUIListWnd::RemoveItem) - .def("RemoveAll", &CUIListWnd::RemoveAll) - .def("EnableScrollBar", &CUIListWnd::EnableScrollBar) - .def("IsScrollBarEnabled", &CUIListWnd::IsScrollBarEnabled) - .def("ScrollToBegin", &CUIListWnd::ScrollToBegin) - .def("ScrollToEnd", &CUIListWnd::ScrollToEnd) - .def("SetItemHeight", &CUIListWnd::SetItemHeight) - .def("GetItem", &CUIListWnd::GetItem) - .def("GetItemPos", &CUIListWnd::GetItemPos) - .def("GetSize", &CUIListWnd::GetItemsCount) - .def("ScrollToBegin", &CUIListWnd::ScrollToBegin) - .def("ScrollToEnd", &CUIListWnd::ScrollToEnd) - .def("ScrollToPos", +[](CUIListWnd* self, int position) - { - self->ScrollToPos(position, 0.0f); - }) - .def("ScrollToPos", &CUIListWnd::ScrollToPos) - .def("SetWidth", &CUIListWnd::SetWidth) - .def("SetTextColor", &CUIListWnd::SetTextColor) - .def("ActivateList", &CUIListWnd::ActivateList) - .def("IsListActive", &CUIListWnd::IsListActive) - .def("SetVertFlip", &CUIListWnd::SetVertFlip) - .def("GetVertFlip", &CUIListWnd::GetVertFlip) - .def("SetFocusedItem", &CUIListWnd::SetFocusedItem) - .def("GetFocusedItem", &CUIListWnd::GetFocusedItem) - .def("ShowSelectedItem", &CUIListWnd::ShowSelectedItem) - - .def("GetSelectedItem", &CUIListWnd::GetSelectedItem) - .def("ResetFocusCapture", &CUIListWnd::ResetFocusCapture) - ]; -}); - -SCRIPT_EXPORT(CUIListItem, (CUIButton), -{ - using namespace luabind; - - module(luaState) - [ - class_("CUIListItem") - .def(constructor<>()) - ]; -}); - -SCRIPT_EXPORT(CUIListItemEx, (CUIListItem), -{ - using namespace luabind; - - module(luaState) - [ - class_("CUIListItemEx") - .def(constructor<>()) - .def("SetSelectionColor", &CUIListItemEx::SetSelectionColor) - ]; -}); -// clang-format on diff --git a/src/xrUICore/MessageBox/UIMessageBox.h b/src/xrUICore/MessageBox/UIMessageBox.h index 15236374dc6..038d32a8db5 100644 --- a/src/xrUICore/MessageBox/UIMessageBox.h +++ b/src/xrUICore/MessageBox/UIMessageBox.h @@ -66,4 +66,7 @@ class XRUICORE_API CUIMessageBox final : public CUIStatic E_MESSAGEBOX_STYLE m_eMessageBoxStyle; bool m_allowInputHandling{}; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CUIStatic); }; diff --git a/src/xrUICore/MessageBox/UIMessageBox_script.cpp b/src/xrUICore/MessageBox/UIMessageBox_script.cpp deleted file mode 100644 index 63c42f208eb..00000000000 --- a/src/xrUICore/MessageBox/UIMessageBox_script.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "pch.hpp" -#include "UIMessageBox.h" -#include "xrScriptEngine/ScriptExporter.hpp" - -SCRIPT_EXPORT(CUIMessageBox, (CUIStatic), -{ - using namespace luabind; - - module(luaState) - [ - class_("CUIMessageBox") - .def(constructor<>()) - .def("Init", &CUIMessageBox::InitMessageBox) - .def("InitMessageBox", &CUIMessageBox::InitMessageBox) - .def("SetText", &CUIMessageBox::SetText) - .def("GetHost", &CUIMessageBox::GetHost) - .def("GetPassword", &CUIMessageBox::GetPassword) - ]; -}); diff --git a/src/xrUICore/Options/UIOptionsItem.h b/src/xrUICore/Options/UIOptionsItem.h index c2c0ced5f87..99152fc538a 100644 --- a/src/xrUICore/Options/UIOptionsItem.h +++ b/src/xrUICore/Options/UIOptionsItem.h @@ -7,7 +7,7 @@ struct xr_token; class XRUICORE_API CUIOptionsItem { public: - enum ESystemDepends + enum ESystemDepends : u8 { sdNothing, sdVidRestart, diff --git a/src/xrUICore/Options/UIOptionsManager.h b/src/xrUICore/Options/UIOptionsManager.h index ee0c43c072e..90f6263228c 100644 --- a/src/xrUICore/Options/UIOptionsManager.h +++ b/src/xrUICore/Options/UIOptionsManager.h @@ -1,4 +1,5 @@ #pragma once + #include "xrCore/xrstring.h" #include "xrCommon/xr_vector.h" #include "xrCommon/xr_map.h" @@ -38,12 +39,15 @@ class XRUICORE_API CUIOptionsManager groups m_groups; - enum + enum : u8 { e_vid_restart = (1 << 0), e_snd_restart = (1 << 1), e_ui_restart = (1 << 2), e_system_restart = (1 << 3) }; - u16 m_restart_flags; + u8 m_restart_flags; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; diff --git a/src/xrUICore/Options/UIOptionsManagerScript.cpp b/src/xrUICore/Options/UIOptionsManagerScript.cpp deleted file mode 100644 index f27947a66a4..00000000000 --- a/src/xrUICore/Options/UIOptionsManagerScript.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "pch.hpp" -#include "UIOptionsItem.h" -#include "UIOptionsManagerScript.h" -#include "xrScriptEngine/ScriptExporter.hpp" - -void CUIOptionsManagerScript::SetCurrentValues(pcstr group) -{ - CUIOptionsItem::GetOptionsManager()->SetCurrentValues(group); -} - -void CUIOptionsManagerScript::SaveBackupValues(pcstr group) -{ - CUIOptionsItem::GetOptionsManager()->SaveBackupValues(group); -} - -void CUIOptionsManagerScript::SaveValues(pcstr group) { CUIOptionsItem::GetOptionsManager()->SaveValues(group); } -void CUIOptionsManagerScript::UndoGroup(pcstr group) { CUIOptionsItem::GetOptionsManager()->UndoGroup(group); } -void CUIOptionsManagerScript::OptionsPostAccept() { CUIOptionsItem::GetOptionsManager()->OptionsPostAccept(); } -void CUIOptionsManagerScript::SendMessage2Group(pcstr group, pcstr message) -{ - CUIOptionsItem::GetOptionsManager()->SendMessage2Group(group, message); -} - -bool CUIOptionsManagerScript::NeedSystemRestart() { return CUIOptionsItem::GetOptionsManager()->NeedSystemRestart(); } -bool CUIOptionsManagerScript::NeedVidRestart() { return CUIOptionsItem::GetOptionsManager()->NeedVidRestart(); } - -SCRIPT_EXPORT(CUIOptionsManagerScript, (), -{ - using namespace luabind; - - module(luaState) - [ - class_("COptionsManager") - .def(constructor<>()) - .def("SaveBackupValues", &CUIOptionsManagerScript::SaveBackupValues) - .def("SetCurrentValues", &CUIOptionsManagerScript::SetCurrentValues) - .def("SaveValues", &CUIOptionsManagerScript::SaveValues) - .def("UndoGroup", &CUIOptionsManagerScript::UndoGroup) - .def("OptionsPostAccept", &CUIOptionsManagerScript::OptionsPostAccept) - .def("SendMessage2Group", &CUIOptionsManagerScript::SendMessage2Group) - .def("NeedSystemRestart", &CUIOptionsManagerScript::NeedSystemRestart) - .def("NeedVidRestart", &CUIOptionsManagerScript::NeedVidRestart) - ]; -}); diff --git a/src/xrUICore/Options/UIOptionsManagerScript.h b/src/xrUICore/Options/UIOptionsManagerScript.h deleted file mode 100644 index f5754a45c44..00000000000 --- a/src/xrUICore/Options/UIOptionsManagerScript.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -class CUIOptionsManagerScript -{ -public: - void SaveBackupValues(pcstr group); - void SetCurrentValues(pcstr group); - void SaveValues(pcstr group); - void UndoGroup(pcstr group); - void OptionsPostAccept(); - void SendMessage2Group(pcstr group, pcstr message); - bool NeedSystemRestart(); - bool NeedVidRestart(); -}; diff --git a/src/xrUICore/ProgressBar/UIProgressBar.cpp b/src/xrUICore/ProgressBar/UIProgressBar.cpp index 2f2b603fb97..60bf32da033 100644 --- a/src/xrUICore/ProgressBar/UIProgressBar.cpp +++ b/src/xrUICore/ProgressBar/UIProgressBar.cpp @@ -19,11 +19,9 @@ CUIProgressBar::CUIProgressBar() m_ProgressPos.x = 0.0f; m_ProgressPos.y = 0.0f; m_inertion = 0.0f; - m_last_render_frame = u32(-1); m_orient_mode = om_horz; } -CUIProgressBar::~CUIProgressBar(void) {} void CUIProgressBar::InitProgressBar(Fvector2 pos, Fvector2 size, EOrientMode mode) { m_orient_mode = mode; @@ -151,5 +149,4 @@ void CUIProgressBar::Draw() m_UIProgressItem.Draw(); UI().PopScissor(); } - m_last_render_frame = Device.dwFrame; } diff --git a/src/xrUICore/ProgressBar/UIProgressBar.h b/src/xrUICore/ProgressBar/UIProgressBar.h index b189d6b3e06..bfc7b0e6022 100644 --- a/src/xrUICore/ProgressBar/UIProgressBar.h +++ b/src/xrUICore/ProgressBar/UIProgressBar.h @@ -5,11 +5,11 @@ class XRUICORE_API CUIProgressBar final : public CUIWindow { friend class CUIXmlInitBase; - typedef CUIWindow inherited; protected: - // bool m_bIsHorizontal; - enum EOrientMode + using inherited = CUIWindow; + + enum EOrientMode : u8 { om_horz = 0, om_vert = 1, @@ -20,52 +20,59 @@ class XRUICORE_API CUIProgressBar final : public CUIWindow om_count } m_orient_mode; + bool m_bBackgroundPresent : 1 {}; + bool m_bUseColor : 1 {}; + bool m_bUseMiddleColor : 1 {}; // Hrust: optional middle color for CS/SoC compatibility, without middle color it doesn't looks correctly + bool m_bUseGradient : 1 { true }; //Alundaio: if false then use only solid color with m_maxColor + Fvector2 m_ProgressPos; // x-current y-dest float m_MinPos; float m_MaxPos; float m_CurrentLength; - bool m_bBackgroundPresent; - Fvector2 m_BackgroundOffset; - u32 m_last_render_frame; - void UpdateProgressBar(); - -public: - bool m_bUseColor; - bool m_bUseMiddleColor; // Hrust: optional middle color for CS/SoC compatibility, without middle color it doesn't looks correctly - bool m_bUseGradient; //Alundaio: if false then use only solid color with m_maxColor Fcolor m_minColor; Fcolor m_middleColor; Fcolor m_maxColor; - float m_inertion; // + float m_inertion; + +protected: + void UpdateProgressBar(); public: CUIStatic m_UIProgressItem; CUIStatic m_UIBackgroundItem; CUIProgressBar(); - virtual ~CUIProgressBar(); void InitProgressBar(Fvector2 pos, Fvector2 size, EOrientMode mode); + void Draw() override; + void Update() override; + void SetRange(float min, float max) { m_MinPos = min; m_MaxPos = max; UpdateProgressBar(); } - float GetRange_min() { return m_MinPos; } - float GetRange_max() { return m_MaxPos; } + [[nodiscard]] float GetRange_min() const { return m_MinPos; } + [[nodiscard]] float GetRange_max() const { return m_MaxPos; } + + [[nodiscard]] + float GetProgressPos() const { return m_ProgressPos.y; } void SetProgressPos(float pos); void ForceSetProgressPos(float pos); - float GetProgressPos() { return m_ProgressPos.y; } + [[nodiscard]] + bool IsShownBackground() const { return m_bBackgroundPresent; } void ShowBackground(bool status) { m_bBackgroundPresent = status; } - bool IsShownBackground() { return m_bBackgroundPresent; } - virtual void Draw(); - virtual void Update(); + + void UseGradient(bool status) { m_bUseGradient = status; } pcstr GetDebugType() override { return "CUIProgressBar"; } + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CUIWindow); }; diff --git a/src/xrUICore/ProgressBar/UIProgressBar_script.cpp b/src/xrUICore/ProgressBar/UIProgressBar_script.cpp deleted file mode 100644 index 95102e77fa4..00000000000 --- a/src/xrUICore/ProgressBar/UIProgressBar_script.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "pch.hpp" -#include "UIProgressBar.h" -#include "xrScriptEngine/ScriptExporter.hpp" - -SCRIPT_EXPORT(CUIProgressBar, (CUIWindow), -{ - using namespace luabind; - - module(luaState) - [ - class_("CUIProgressBar") - .def(constructor<>()) - .def("SetProgressPos", &CUIProgressBar::SetProgressPos) - .def("GetProgressPos", &CUIProgressBar::GetProgressPos) - - .def("GetRange_min", &CUIProgressBar::GetRange_min) - .def("GetRange_max", &CUIProgressBar::GetRange_max) - ]; -}); diff --git a/src/xrUICore/ProgressBar/UIProgressShape.cpp b/src/xrUICore/ProgressBar/UIProgressShape.cpp index adb66d64960..18f2a5b4b11 100644 --- a/src/xrUICore/ProgressBar/UIProgressShape.cpp +++ b/src/xrUICore/ProgressBar/UIProgressShape.cpp @@ -59,8 +59,8 @@ void CUIProgressShape::Draw() GEnv.UIRender->SetShader(*origin->GetShader()); - Fvector2 tsize; - GEnv.UIRender->GetActiveTextureResolution(tsize); + Fvector2 tsize{}; + origin->GetShader()->GetBaseTextureResolution(tsize); GEnv.UIRender->StartPrimitive(m_sectorCount * 3, IUIRender::ptTriList, UI().m_currentPointType); diff --git a/src/xrUICore/PropertiesBox/UIPropertiesBox.h b/src/xrUICore/PropertiesBox/UIPropertiesBox.h index 5ab1b56482a..cb118e2d9b3 100644 --- a/src/xrUICore/PropertiesBox/UIPropertiesBox.h +++ b/src/xrUICore/PropertiesBox/UIPropertiesBox.h @@ -1,4 +1,5 @@ #pragma once + #include "xrUICore/Windows/UIFrameWindow.h" #include "xrUICore/ListBox/UIListBox.h" @@ -48,4 +49,7 @@ class XRUICORE_API CUIPropertiesBox final : public CUIFrameWindow, public CUIWnd Frect m_last_show_rect; CUIPropertiesBox* m_parent_sub_menu; // warning !!! dubling pointers to the same object !!! CUIWindow* m_item_sub_menu_initiator; // fills in ShowSubMenu + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CUIFrameWindow); }; diff --git a/src/xrUICore/PropertiesBox/UIPropertiesBox_script.cpp b/src/xrUICore/PropertiesBox/UIPropertiesBox_script.cpp deleted file mode 100644 index 1e3b7484100..00000000000 --- a/src/xrUICore/PropertiesBox/UIPropertiesBox_script.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "pch.hpp" -#include "UIPropertiesBox.h" -#include "ListBox/UIListBoxItem.h" -#include "xrScriptEngine/ScriptExporter.hpp" - -SCRIPT_EXPORT(CUIPropertiesBox, (CUIFrameWindow), -{ - using namespace luabind; - - module(luaState) - [ - class_("CUIPropertiesBox") - .def(constructor<>()) - .def("RemoveItem", &CUIPropertiesBox::RemoveItemByTAG) - .def("RemoveAll", &CUIPropertiesBox::RemoveAll) - .def("Show", (void (CUIPropertiesBox::*)(int, int)) &CUIPropertiesBox::Show) - .def("Hide", &CUIPropertiesBox::Hide) - .def("GetSelectedItem", &CUIPropertiesBox::GetClickedItem) - .def("AutoUpdateSize", &CUIPropertiesBox::AutoUpdateSize) - .def("AddItem", &CUIPropertiesBox::AddItem_script) - .def("InitPropertiesBox", &CUIPropertiesBox::InitPropertiesBox) - ]; -}); diff --git a/src/xrUICore/ScrollView/UIScrollView.cpp b/src/xrUICore/ScrollView/UIScrollView.cpp index f84b950cf7e..372f50af973 100644 --- a/src/xrUICore/ScrollView/UIScrollView.cpp +++ b/src/xrUICore/ScrollView/UIScrollView.cpp @@ -67,7 +67,7 @@ void CUIScrollView::InitScrollView() CUIFixedScrollBar* tmp_scroll = smart_cast(m_VScrollBar); if (tmp_scroll) { - if (!tmp_scroll->InitScrollBar(Fvector2().set(GetWndSize().x, 0.0f), false, *m_scrollbar_profile)) + if (!tmp_scroll->InitScrollBar(Fvector2().set(GetWndSize().x, 0.0f), false, m_scrollbar_profile.c_str())) { Msg("! Failed to init ScrollView with FixedScrollBar, trying to init with ScrollBar"); DetachChild(m_VScrollBar); @@ -87,7 +87,7 @@ void CUIScrollView::InitScrollView() if (!!m_scrollbar_profile && !tmp_scroll) { m_VScrollBar->InitScrollBar(Fvector2().set(GetWndSize().x, 0.0f), - GetWndSize().y, false, *m_scrollbar_profile); + GetWndSize().y, false, m_scrollbar_profile.c_str()); } else { diff --git a/src/xrUICore/ScrollView/UIScrollView.h b/src/xrUICore/ScrollView/UIScrollView.h index bd9a7aa8fea..7925179e352 100644 --- a/src/xrUICore/ScrollView/UIScrollView.h +++ b/src/xrUICore/ScrollView/UIScrollView.h @@ -11,7 +11,7 @@ class XRUICORE_API CUIScrollView : public CUIWindow, public CUIWndCallback typedef CUIWindow inherited; friend class CUIXmlInitBase; // for init protected: - enum + enum : u16 { eVertFlip = (1 << 0), eNeedRecalc = (1 << 1), @@ -89,6 +89,9 @@ class XRUICORE_API CUIScrollView : public CUIWindow, public CUIWndCallback typedef fastdelegate::FastDelegate2 cmp_function; cmp_function m_sort_function; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CUIWindow); }; #define ADD_TEXT_TO_VIEW3(txt, st, view) \ diff --git a/src/xrUICore/Static/UILanimController.cpp b/src/xrUICore/Static/UILanimController.cpp index a847d080a07..dcf921131e5 100644 --- a/src/xrUICore/Static/UILanimController.cpp +++ b/src/xrUICore/Static/UILanimController.cpp @@ -2,12 +2,6 @@ #include "UILanimController.h" #include "xrEngine/LightAnimLibrary.h" -color_animation::color_animation() : m_lanim(NULL), m_lanim_start_time(-1.0f), m_lanim_delay_time(0.0f) -{ - m_lanimFlags.zero(); -} - -xform_animation::xform_animation() { m_origSize.set(0, 0); } void CUIColorAnimConrollerContainer::Update() { inherited::Update(); diff --git a/src/xrUICore/Static/UILanimController.h b/src/xrUICore/Static/UILanimController.h index 928ce51bc39..c9e66d95f17 100644 --- a/src/xrUICore/Static/UILanimController.h +++ b/src/xrUICore/Static/UILanimController.h @@ -11,20 +11,17 @@ class CLAItem; #define LA_TEXTCOLOR (1 << 2) #define LA_TEXTURECOLOR (1 << 3) -struct XRUICORE_API color_animation +struct color_animation { - color_animation(); - CLAItem* m_lanim; - float m_lanim_start_time; - float m_lanim_delay_time; - Flags8 m_lanimFlags; + CLAItem* m_lanim{}; + float m_lanim_start_time{ -1.0f }; + float m_lanim_delay_time{}; + Flags8 m_lanimFlags{}; }; struct xform_animation : public color_animation { - xform_animation(); - Fvector2 m_origSize; - void set_defaults(); + Fvector2 m_origSize{}; }; class CUILightAnimColorConroller diff --git a/src/xrUICore/Static/UIStatic.h b/src/xrUICore/Static/UIStatic.h index 53897187156..3d3654d4505 100644 --- a/src/xrUICore/Static/UIStatic.h +++ b/src/xrUICore/Static/UIStatic.h @@ -121,4 +121,7 @@ class XRUICORE_API CUIStatic : public CUIWindow, public ITextureOwner, public CU public: CUILines* TextItemControl(); shared_str m_stat_hint_text; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CUIWindow); }; diff --git a/src/xrUICore/Static/UIStaticItem.cpp b/src/xrUICore/Static/UIStaticItem.cpp index 4554547f489..46270a51b30 100644 --- a/src/xrUICore/Static/UIStaticItem.cpp +++ b/src/xrUICore/Static/UIStaticItem.cpp @@ -35,8 +35,8 @@ void CUIStaticItem::RenderInternal(const Fvector2& in_pos) UI().AlignPixel(pos.x); UI().AlignPixel(pos.y); - Fvector2 ts; - GEnv.UIRender->GetActiveTextureResolution(ts); + Fvector2 ts{}; + hShader->GetBaseTextureResolution(ts); if (!uFlags.test(flValidSize)) SetSize(ts); @@ -106,11 +106,10 @@ void CUIStaticItem::RenderInternal(const Fvector2& in_pos) void CUIStaticItem::RenderInternal(float angle) { - Fvector2 ts; - Fvector2 hp; + Fvector2 ts{}; + hShader->GetBaseTextureResolution(ts); - GEnv.UIRender->GetActiveTextureResolution(ts); - hp.set(0.5f / ts.x, 0.5f / ts.y); + const Fvector2 hp{ 0.5f / ts.x, 0.5f / ts.y }; if (!uFlags.test(flValidSize)) SetSize(ts); diff --git a/src/xrUICore/Static/UIStatic_script.cpp b/src/xrUICore/Static/UIStatic_script.cpp deleted file mode 100644 index b266c2c8f69..00000000000 --- a/src/xrUICore/Static/UIStatic_script.cpp +++ /dev/null @@ -1,130 +0,0 @@ -#include "pch.hpp" -#include "UIStatic.h" -#include "UIAnimatedStatic.h" -#include "xrScriptEngine/ScriptExporter.hpp" - -SCRIPT_EXPORT(CUILines, (), -{ - using namespace luabind; - - module(luaState) - [ - class_("CUILines") - .def("SetFont", &CUILines::SetFont) - .def("SetText", &CUILines::SetText) - .def("SetTextST", &CUILines::SetTextST) - .def("GetText", &CUILines::GetText) - .def("SetElipsis", &CUILines::SetEllipsis) - .def("SetTextColor", &CUILines::SetTextColor) - ]; -}); - -// We don't change game assets. -// This class allowes original game scripts to not specify the window name. -class CUIStaticScript final : public CUIStatic -{ -public: - CUIStaticScript() : CUIStatic("CUIStaticScript") {} - pcstr GetDebugType() override { return "CUIStaticScript"; } -}; - -SCRIPT_EXPORT(CUIStatic, (CUIWindow), -{ - using namespace luabind; - - module(luaState) - [ - class_("CUIStaticBase") - .def(constructor()) - - .def("TextControl", &CUIStatic::TextItemControl) - - .def("SetText", &CUIStatic::SetText) - .def("SetTextST", &CUIStatic::SetTextST) - - .def("GetText", &CUIStatic::GetText) - - .def("SetTextOffset", &CUIStatic::SetTextOffset) - .def("SetTextX", +[](CUIStatic* self, float x) { self->TextItemControl()->m_TextOffset.x = x; }) - .def("SetTextY", +[](CUIStatic* self, float y) { self->TextItemControl()->m_TextOffset.y = y; }) - .def("GetTextX", +[](CUIStatic* self) { return self->TextItemControl()->m_TextOffset.x; }) - .def("GetTextY", +[](CUIStatic* self) { return self->TextItemControl()->m_TextOffset.y; }) - - .def("SetColor", &CUIStatic::SetTextureColor) - .def("GetColor", &CUIStatic::GetTextureColor) - - .def("SetFont", &CUIStatic::SetFont) - .def("GetFont", &CUIStatic::GetFont) - - .def("SetTextColor", +[](CUIStatic* self, int a, int r, int g, int b) - { - self->SetTextColor(color_argb(a, r, g, b)); - }) - .def("GetTextColor", &CUIStatic::GetTextColor) - .def("SetTextComplexMode", &CUIStatic::SetTextComplexMode) - .def("SetTextAlignment", &CUIStatic::SetTextAlignment) - .def("SetVTextAlignment", &CUIStatic::SetVTextAlignment) - - .def("AdjustHeightToText", &CUIStatic::AdjustHeightToText) - .def("AdjustWidthToText", &CUIStatic::AdjustWidthToText) - - .def("Init", +[](CUIStatic* self, float x, float y, float width, float height) - { - const Frect rect { x, y, width, height }; - self->SetWndRect(rect); - }) - .def("Init", +[](CUIStatic* self, cpcstr texture, float x, float y, float width, float height) - { - const Frect rect { x, y, width, height }; - self->SetWndRect(rect); - self->InitTexture(texture); - }) - - .def("InitTexture", &CUIStatic::InitTexture) - .def("InitTexture", +[](CUIStatic* self, pcstr texture) { self->InitTexture(texture); }) - .def("InitTextureEx", &CUIStatic::InitTextureEx) - .def("InitTextureEx", +[](CUIStatic* self, pcstr texture, pcstr shader) { self->InitTextureEx(texture, shader); }) - - .def("SetTextureColor", &CUIStatic::SetTextureColor) - .def("GetTextureColor", &CUIStatic::GetTextureColor) - - .def("SetTextureOffset", &CUIStatic::SetTextureOffset) - - .def("SetTextureRect", &CUIStatic::SetTextureRect_script) - .def("GetTextureRect", &CUIStatic::GetTextureRect_script) - - .def("SetOriginalRect", &CUIStatic::SetTextureRect_script) - .def("GetOriginalRect", &CUIStatic::GetTextureRect_script) - - .def("SetStretchTexture", &CUIStatic::SetStretchTexture) - .def("GetStretchTexture", &CUIStatic::GetStretchTexture) - - .def("SetTextAlign", +[](CUIStatic* self, u32 align) - { - self->TextItemControl()->SetTextAlignment(static_cast(align)); - self->TextItemControl()->GetFont()->SetAligment(static_cast(align)); - }) - .def("GetTextAlign", +[](CUIStatic* self) -> u32 - { - return static_cast(self->TextItemControl()->GetTextAlignment()); - }) - - .def("SetHeading", &CUIStatic::SetHeading) - .def("GetHeading", &CUIStatic::GetHeading) - - //.def("ClipperOn", &CUIStatic::ClipperOn) - //.def("ClipperOff", (void(CUIStatic::*)(void))&CUIStatic::ClipperOff) - - //.def("GetClipperState", &CUIStatic::GetClipperState) - - .def("SetEllipsis", &CUIStatic::SetEllipsis) - .def("SetElipsis", &CUIStatic::SetEllipsis) - .def("SetElipsis", +[](CUIStatic* self, int mode, int indent) - { - self->SetEllipsis(mode != 0); - }), - - class_("CUIStatic") - .def(constructor<>()) - ]; -}); diff --git a/src/xrUICore/TabControl/UITabControl.h b/src/xrUICore/TabControl/UITabControl.h index adc3bd6cd94..d4bb7d1a0a5 100644 --- a/src/xrUICore/TabControl/UITabControl.h +++ b/src/xrUICore/TabControl/UITabControl.h @@ -86,4 +86,7 @@ class XRUICORE_API CUITabControl : public CUIWindow, public CUIOptionsItem bool m_bAcceleratorsEnable{ false }; // Tab control itself accelerators bool m_bButtonsAcceleratorsEnable{ true }; // Tab buttons own accelerators shared_str m_opt_backup_value; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CUIWindow); }; diff --git a/src/xrUICore/TabControl/UITabControl_script.cpp b/src/xrUICore/TabControl/UITabControl_script.cpp deleted file mode 100644 index 2965092946a..00000000000 --- a/src/xrUICore/TabControl/UITabControl_script.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "pch.hpp" -#include "UITabControl.h" -#include "UITabButton.h" -#include "xrScriptEngine/ScriptExporter.hpp" - -SCRIPT_EXPORT(CUITabControl, (CUIWindow), -{ - using namespace luabind; - using namespace luabind::policy; - - module(luaState) - [ - class_("CUITabControl") - .def(constructor<>()) - .def("AddItem", (bool (CUITabControl::*)(CUITabButton*))(&CUITabControl::AddItem), adopt<2>()) - .def("AddItem", (bool (CUITabControl::*)(pcstr, pcstr, Fvector2, Fvector2)) &CUITabControl::AddItem) - .def("AddItem", +[](CUITabControl* self, pcstr pItemName, pcstr pTexName, float x, float y, float width, float height) - { - self->AddItem(pItemName, pTexName, { x, y }, { width, height }); - }) - .def("RemoveItem", &CUITabControl::RemoveItemByIndex) - .def("RemoveItemById", &CUITabControl::RemoveItemById_script) - .def("RemoveAll", &CUITabControl::RemoveAll) - .def("GetActiveId", &CUITabControl::GetActiveId_script) - .def("GetActiveIndex", &CUITabControl::GetActiveIndex) - .def("GetTabsCount", &CUITabControl::GetTabsCount) - .def("SetActiveTab", &CUITabControl::SetActiveTab_script) - .def("SetNewActiveTab", &CUITabControl::SetActiveTabByIndex) - .def("GetButtonById", &CUITabControl::GetButtonById_script) - .def("GetButtonByIndex", &CUITabControl::GetButtonByIndex) - ]; -}); - -SCRIPT_EXPORT(CUITabButton, (CUIButton), -{ - using namespace luabind; - - module(luaState) - [ - class_("CUITabButton") - .def(constructor<>()) - ]; -}); diff --git a/src/xrUICore/Windows/UIFrameLineWnd.cpp b/src/xrUICore/Windows/UIFrameLineWnd.cpp index afdb6abec9f..1eabd201873 100644 --- a/src/xrUICore/Windows/UIFrameLineWnd.cpp +++ b/src/xrUICore/Windows/UIFrameLineWnd.cpp @@ -126,8 +126,8 @@ void CUIFrameLineWnd::DrawElements() { GEnv.UIRender->SetShader(*m_shader); - Fvector2 ts; - GEnv.UIRender->GetActiveTextureResolution(ts); + Fvector2 ts{}; + m_shader->GetBaseTextureResolution(ts); Frect rect; GetAbsoluteRect(rect); diff --git a/src/xrUICore/Windows/UIFrameLineWnd.h b/src/xrUICore/Windows/UIFrameLineWnd.h index 0b842691021..d6d7eba45b7 100644 --- a/src/xrUICore/Windows/UIFrameLineWnd.h +++ b/src/xrUICore/Windows/UIFrameLineWnd.h @@ -70,4 +70,7 @@ class XRUICORE_API CUIFrameLineWnd : public CUIWindow, public ITextureOwner Frect m_tex_rect[flMax]; ui_shader m_shader; shared_str dbg_tex_name; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CUIWindow); }; diff --git a/src/xrUICore/Windows/UIFrameWindow.cpp b/src/xrUICore/Windows/UIFrameWindow.cpp index b4cd3898781..a6758b0802c 100644 --- a/src/xrUICore/Windows/UIFrameWindow.cpp +++ b/src/xrUICore/Windows/UIFrameWindow.cpp @@ -170,8 +170,8 @@ void CUIFrameWindow::DrawElements() { GEnv.UIRender->SetShader(*m_shader); - Fvector2 ts; - GEnv.UIRender->GetActiveTextureResolution(ts); + Fvector2 ts{}; + m_shader->GetBaseTextureResolution(ts); Frect rect; GetAbsoluteRect(rect); diff --git a/src/xrUICore/Windows/UIFrameWindow.h b/src/xrUICore/Windows/UIFrameWindow.h index 6180eeae754..4bfe0ab6440 100644 --- a/src/xrUICore/Windows/UIFrameWindow.h +++ b/src/xrUICore/Windows/UIFrameWindow.h @@ -48,4 +48,7 @@ class XRUICORE_API CUIFrameWindow : public CUIWindow, public ITextureOwner bool get_points(Frect const& r, int i, Fvector2& LTp, Fvector2& RBp, Fvector2& LTt, Fvector2& RBt); void draw_tile_line(Frect rect, int i, bool b_horz, Fvector2 const& ts); void draw_tile_rect(Frect rect, int i, Fvector2 const& ts); + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(CUIWindow); }; diff --git a/src/xrUICore/Windows/UIWindow.cpp b/src/xrUICore/Windows/UIWindow.cpp index d25cfd5d41e..b027e93af35 100644 --- a/src/xrUICore/Windows/UIWindow.cpp +++ b/src/xrUICore/Windows/UIWindow.cpp @@ -3,6 +3,7 @@ #include "UIWindow.h" #include "Cursor/UICursor.h" +#include "xrEngine/editor_helper.h" CUIWindow::CUIWindow(pcstr window_name) : m_windowName(window_name) { @@ -608,14 +609,28 @@ void CUIWindow::FillDebugInfo() ImGui::DragFloat2("Position", (float*)&m_wndPos); ImGui::DragFloat2("Size", (float*)&m_wndSize); - ImGui::Checkbox("Visible", &m_bShowMe); - ImGui::Checkbox("Enabled", &m_bIsEnabled); + bool v = m_bShowMe; + if (ImGui::Checkbox("Visible", &v)) + m_bShowMe = v; + + v = m_bIsEnabled; + if (ImGui::Checkbox("Enabled", &v)) + m_bIsEnabled = v; ImGui::Separator(); ImGui::BeginDisabled(); - ImGui::Checkbox("Auto delete", &m_bAutoDelete); - ImGui::Checkbox("Cursor over window", &m_bCursorOverWindow); - ImGui::Checkbox("Custom draw", &m_bCustomDraw); + + v = m_bAutoDelete; + if (ImGui::Checkbox("Auto delete", &v)) + m_bAutoDelete = v; + + v = m_bCursorOverWindow; + if (ImGui::Checkbox("Cursor over window", &v)) + m_bCursorOverWindow = v; + + v = m_bCustomDraw; + if (ImGui::Checkbox("Custom draw", &v)) + v = m_bCustomDraw; ImGui::DragFloat2("Last cursor position", (float*)&cursor_pos); ImGui::DragScalar("Last click time", ImGuiDataType_U32, &m_dwLastClickTime); diff --git a/src/xrUICore/Windows/UIWindow.h b/src/xrUICore/Windows/UIWindow.h index ca3ebd8cbc8..3fdb39a7d9d 100644 --- a/src/xrUICore/Windows/UIWindow.h +++ b/src/xrUICore/Windows/UIWindow.h @@ -2,22 +2,144 @@ #define ui_list xr_vector -#define DEF_UILIST(N, T) \ - typedef ui_list N; \ - typedef N::iterator N##_it; - ////////////////////////////////////////////////////////////////////////// #include "xrUICore/UIMessages.h" #include "xrUICore/uiabstract.h" #include "xrUICore/ui_debug.h" -class XRUICORE_API CUIWindow : public CUISimpleWindow, public CUIDebuggable +#include "xrScriptEngine/ScriptExporter.hpp" + +class XRUICORE_API CUIWindow : public CUIDebuggable { public: CUIWindow(pcstr window_name); ~CUIWindow() override; + virtual void SetWndPos(const Fvector2& pos) + { + m_wndPos.set(pos.x, pos.y); + } + [[nodiscard]] + const Fvector2& GetWndPos() const + { + return m_wndPos; + } + + [[nodiscard]] + Fvector2 GetWndCenterPos() const + { + return { m_wndPos.x + m_wndSize.x / 2.0f, m_wndPos.y + m_wndSize.y / 2.0f, }; + } + + virtual void SetWndSize(const Fvector2& size) + { + m_wndSize = size; + } + [[nodiscard]] + const Fvector2& GetWndSize() const + { + return m_wndSize; + } + + virtual void SetWndRect(const Frect& rect) + { + m_wndPos.set(rect.lt); + rect.getsize(m_wndSize); + } + + virtual void SetHeight(float height) + { + m_wndSize.y = height; + } + [[nodiscard]] + float GetHeight() const + { + return m_wndSize.y; + } + virtual void SetWidth(float width) + { + m_wndSize.x = width; + } + [[nodiscard]] + float GetWidth() const + { + return m_wndSize.x; + } + + void SetVisible(bool vis) + { + m_bShowMe = vis; + } + [[nodiscard]] + bool GetVisible() const + { + return m_bShowMe; + } + void SetAlignment(EWindowAlignment al) + { + m_alignment = al; + } + [[nodiscard]] + EWindowAlignment GetAlignment() const + { + return m_alignment; + } + [[nodiscard]] + Frect GetWndRect() const + { + Frect r; + GetWndRect(r); + return r; + } + void GetWndRect(Frect& res) const + { + const float width = (float)Device.dwWidth * (UI_BASE_WIDTH / (float)Device.dwWidth); + const float height = (float)Device.dwHeight * (UI_BASE_HEIGHT / (float)Device.dwHeight); + + switch (m_alignment) + { + case waNone: + case waLeft: + { + res.set(m_wndPos.x, m_wndPos.y, m_wndPos.x + m_wndSize.x, m_wndPos.y + m_wndSize.y); + break; + } + case waCenter: + { + float half_w = m_wndSize.x / 2.0f; + float half_h = m_wndSize.y / 2.0f; + res.set(m_wndPos.x - half_w, m_wndPos.y - half_h, m_wndPos.x + half_w, m_wndPos.y + half_h); + break; + } + case waRight: + { + res.set(width - m_wndSize.x, m_wndPos.y, width, m_wndPos.y + m_wndSize.y); + break; + } + case waTop: + { + res.set(m_wndPos.x, 0.f, m_wndPos.x + m_wndSize.x, m_wndSize.y); + break; + } + case waBottom: + res.set(m_wndPos.x, height - m_wndSize.y, m_wndPos.x + m_wndSize.x, height); + break; + default: NODEFAULT; + } + } + + void MoveWndDelta(float dx, float dy) + { + m_wndPos.x += dx; + m_wndPos.y += dy; + } + + void MoveWndDelta(const Fvector2& d) + { + MoveWndDelta(d.x, d.y); + } + //////////////////////////////////// //работа Ñ Ð´Ð¾Ñ‡ÐµÑ€Ð½Ð¸Ð¼Ð¸ и родительÑкими окнами virtual void AttachChild(CUIWindow* pChild); @@ -28,7 +150,7 @@ class XRUICORE_API CUIWindow : public CUISimpleWindow, public CUIDebuggable virtual bool IsChild(CUIWindow* pPossibleChild) const; [[nodiscard]] - u32 GetChildNum() const { return (u32)m_ChildWndList.size(); } + auto GetChildNum() const { return m_ChildWndList.size(); } [[nodiscard]] CUIWindow* GetParent() const { return m_pParentWnd; } @@ -63,7 +185,11 @@ class XRUICORE_API CUIWindow : public CUISimpleWindow, public CUIDebuggable return this; return m_pParentWnd->GetTop(); } + + [[nodiscard]] CUIWindow* GetCurrentMouseHandler(); + + [[nodiscard]] CUIWindow* GetChildMouseHandler(); virtual bool OnKeyboardAction(int dik, EUIMessages keyboard_action); @@ -84,14 +210,20 @@ class XRUICORE_API CUIWindow : public CUISimpleWindow, public CUIDebuggable //захватить/оÑвободить мышь окном //Ñообщение поÑылаетÑÑ Ð´Ð¾Ñ‡ÐµÑ€Ð½Ð¸Ð¼ окном родительÑкому void SetCapture(CUIWindow* pChildWindow, bool capture_status); + + [[nodiscard]] CUIWindow* GetMouseCapturer() const { return m_pMouseCapturer; } //окошко, которому переÑылаютÑÑ ÑообщениÑ, //еÑли NULL, то шлем на GetParent() void SetMessageTarget(CUIWindow* pWindow) { m_pMessageTarget = pWindow; } + + [[nodiscard]] CUIWindow* GetMessageTarget(); void SetKeyboardCapture(CUIWindow* pChildWindow, bool capture_status); + + [[nodiscard]] CUIWindow* GetKeyboardCapturer() const { return m_pKeyboardCapturer; } //обработка Ñообщений не предуÑмотреных Ñтандартными обработчиками @@ -141,6 +273,7 @@ class XRUICORE_API CUIWindow : public CUISimpleWindow, public CUIDebuggable void ShowChildren(bool show); //абÑолютные координаты + [[nodiscard]] void GetAbsoluteRect(Frect& r) const; void GetAbsolutePos(Fvector2& p) const @@ -150,6 +283,7 @@ class XRUICORE_API CUIWindow : public CUISimpleWindow, public CUIDebuggable p.set(abs.x1, abs.y1); } + [[nodiscard]] Fvector2 GetAbsoluteCenterPos() const { Frect abs; @@ -159,21 +293,24 @@ class XRUICORE_API CUIWindow : public CUISimpleWindow, public CUIDebuggable return { abs.x1 + size.x, abs.y1 + size.y }; } - void SetWndRect_script(Frect rect) { CUISimpleWindow::SetWndRect(rect); } - void SetWndPos_script(Fvector2 pos) { CUISimpleWindow::SetWndPos(pos); } - void SetWndSize_script(Fvector2 size) { CUISimpleWindow::SetWndSize(size); } - //прориÑовка окна + void SetWndRect_script(Frect rect) { SetWndRect(rect); } + void SetWndPos_script(Fvector2 pos) { SetWndPos(pos); } + void SetWndSize_script(Fvector2 size) { SetWndSize(size); } + + // прориÑовка окна virtual void Draw(); virtual void Draw(float x, float y); - //обновление окна передпрориÑовкой + + // обновление окна перед прориÑовкой virtual void Update(); - //Ð´Ð»Ñ Ð¿ÐµÑ€ÐµÐ²Ð¾Ð´Ð° окна и потомков в иÑходное ÑоÑтоÑние + // Ð´Ð»Ñ Ð¿ÐµÑ€ÐµÐ²Ð¾Ð´Ð° окна и потомков в иÑходное ÑоÑтоÑние virtual void Reset(); void ResetAll(); virtual void SetFont(CGameFont* /*pFont*/) {} + [[nodiscard]] virtual CGameFont* GetFont() { if (m_pParentWnd) @@ -190,10 +327,11 @@ class XRUICORE_API CUIWindow : public CUISimpleWindow, public CUIDebuggable const WINDOW_LIST& GetChildWndList() const { return m_ChildWndList; } [[nodiscard]] - IC bool IsAutoDelete() const { return m_bAutoDelete; } - IC void SetAutoDelete(bool auto_delete) { m_bAutoDelete = auto_delete; } + bool IsAutoDelete() const { return m_bAutoDelete; } + void SetAutoDelete(bool auto_delete) { m_bAutoDelete = auto_delete; } // Name of the window + [[nodiscard]] shared_str WindowName() const { return m_windowName; } void SetWindowName(pcstr wn) { m_windowName = wn; } @@ -203,25 +341,43 @@ class XRUICORE_API CUIWindow : public CUISimpleWindow, public CUIDebuggable virtual bool IsUsingCursorRightNow() const { return false; } [[nodiscard]] - IC bool CursorOverWindow() const { return m_bCursorOverWindow; } + bool CursorOverWindow() const { return m_bCursorOverWindow; } [[nodiscard]] - IC u32 FocusReceiveTime() const { return m_dwFocusReceiveTime; } + u32 FocusReceiveTime() const { return m_dwFocusReceiveTime; } - IC bool GetCustomDraw() const { return m_bCustomDraw; } - IC void SetCustomDraw(bool b) { m_bCustomDraw = b; } + [[nodiscard]] + bool GetCustomDraw() const { return m_bCustomDraw; } + void SetCustomDraw(bool b) { m_bCustomDraw = b; } + [[nodiscard]] pcstr GetDebugType() override { return "CUIWindow"; } bool FillDebugTree(const CUIDebugState& debugState) override; void FillDebugInfo() override; protected: - IC void SafeRemoveChild(CUIWindow* child) + void SafeRemoveChild(CUIWindow* child) { auto it = std::find(m_ChildWndList.begin(), m_ChildWndList.end(), child); if (it != m_ChildWndList.end()) m_ChildWndList.erase(it); - }; + } + + bool m_bShowMe : 1 {}; + + //флаг автоматичеÑкого ÑƒÐ´Ð°Ð»ÐµÐ½Ð¸Ñ Ð²Ð¾ Ð²Ñ€ÐµÐ¼Ñ Ð²Ñ‹Ð·Ð¾Ð²Ð° деÑтруктора + bool m_bAutoDelete : 1 {}; + + // Is user input allowed + bool m_bIsEnabled : 1 { true }; + + // ЕÑли курÑор над окном + bool m_bCursorOverWindow : 1 {}; + bool m_bCustomDraw : 1 {}; + + EWindowAlignment m_alignment{}; + Fvector2 m_wndPos{}; + Fvector2 m_wndSize{}; shared_str m_windowName; @@ -248,15 +404,8 @@ class XRUICORE_API CUIWindow : public CUISimpleWindow, public CUIDebuggable u32 m_dwLastClickTime; u32 m_dwFocusReceiveTime{}; - //флаг автоматичеÑкого ÑƒÐ´Ð°Ð»ÐµÐ½Ð¸Ñ Ð²Ð¾ Ð²Ñ€ÐµÐ¼Ñ Ð²Ñ‹Ð·Ð¾Ð²Ð° деÑтруктора - bool m_bAutoDelete{}; - - // Is user input allowed - bool m_bIsEnabled; - - // ЕÑли курÑор над окном - bool m_bCursorOverWindow{}; - bool m_bCustomDraw{}; +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; XRUICORE_API bool fit_in_rect(CUIWindow* w, Frect const& vis_rect, float border = 0.0f, float dx16pos = 0.0f); diff --git a/src/xrUICore/Windows/UIWindow_script.cpp b/src/xrUICore/Windows/UIWindow_script.cpp deleted file mode 100644 index 51d9dd5c712..00000000000 --- a/src/xrUICore/Windows/UIWindow_script.cpp +++ /dev/null @@ -1,410 +0,0 @@ -#include "pch.hpp" - -#include "xrCore/XML/XMLDocument.hpp" - -#include "UIWindow.h" -#include "UIFrameWindow.h" -#include "UIFrameLineWnd.h" -#include "XML/UITextureMaster.h" -#include "ScrollView/UIScrollView.h" -#include "Hint/UIHint.h" -#include "Cursor/UICursor.h" -#include "ui_styles.h" - -#include "xrScriptEngine/ScriptExporter.hpp" - -// clang-format off -SCRIPT_EXPORT(UICore, (), -{ - using namespace luabind; - using namespace luabind::policy; - - module(luaState) - [ - def("GetARGB", +[](u16 a, u16 r, u16 g, u16 b) { return color_argb(a, r, g, b); }), - - // hud font - def("GetFontSmall", +[] { return UI().Font().pFontStat; }), - def("GetFontMedium", +[] { return UI().Font().pFontMedium; }), - def("GetFontDI", +[] { return UI().Font().pFontDI; }), - - //шрифты Ð´Ð»Ñ Ð¸Ð½Ñ‚ÐµÑ€Ñ„ÐµÐ¹Ñа - def("GetFontGraffiti19Russian", +[] { return UI().Font().pFontGraffiti19Russian; }), - def("GetFontGraffiti22Russian", +[] { return UI().Font().pFontGraffiti22Russian; }), - def("GetFontLetterica16Russian", +[] { return UI().Font().pFontLetterica16Russian; }), - def("GetFontLetterica18Russian", +[] { return UI().Font().pFontLetterica18Russian; }), - def("GetFontGraffiti32Russian", +[] { return UI().Font().pFontGraffiti32Russian; }), - def("GetFontGraffiti50Russian", +[] { return UI().Font().pFontGraffiti50Russian; }), - def("GetFontLetterica25", +[] { return UI().Font().pFontLetterica25; }), - - def("GetCursorPosition", +[] { return GetUICursor().GetCursorPosition(); }), - def("SetCursorPosition", +[](Fvector2& pos) { GetUICursor().SetUICursorPosition(pos); }), - - def("FitInRect", &fit_in_rect) - ]; -}); - -SCRIPT_EXPORT(UIStyleManager, (), -{ - using namespace luabind; - using namespace luabind::policy; - - module(luaState) - [ - def("GetDefaultUIPath", +[] { return UI_PATH_DEFAULT; }), - def("GetDefaultUIPathWithDelimiter", +[] { return UI_PATH_DEFAULT_WITH_DELIMITER; }), - def("GetUIPath", +[] { return UI_PATH; }), - def("GetUIPathWithDelimiter", +[] { return UI_PATH_WITH_DELIMITER; }), - - class_("UIStyleManager") - .def("GetAllStyles", &UIStyleManager::GetToken, return_stl_iterator()) - .def("DefaultStyleIsSet", &UIStyleManager::DefaultStyleIsSet) - .def("GetCurrentStyleId", &UIStyleManager::GetCurrentStyleId) - .def("GetCurrentStyleName", &UIStyleManager::GetCurrentStyleName) - .def("SetStyle", &UIStyleManager::SetStyle) - .def("SetupStyle", &UIStyleManager::SetupStyle) - .def("ResetUI", &UIStyleManager::Reset), - - def("GetUIStyleManager", +[] { return UIStyles; }) - ]; -}); - -SCRIPT_EXPORT(CUIFocusSystem, (), -{ - using namespace luabind; - using namespace luabind::policy; - - module(luaState) - [ - class_("FocusDirection") - .enum_("direction") - [ - value("Same", (int)FocusDirection::Same), - value("Up", (int)FocusDirection::Up), - value("Down", (int)FocusDirection::Down), - value("Left", (int)FocusDirection::Left), - value("Right", (int)FocusDirection::Right), - value("UpperLeft", (int)FocusDirection::UpperLeft), - value("UpperRight", (int)FocusDirection::UpperRight), - value("LowerLeft", (int)FocusDirection::LowerLeft), - value("LowerRight", (int)FocusDirection::LowerRight) - ], - - class_("CUIFocusSystem") - .def("RegisterFocusable", &CUIFocusSystem::RegisterFocusable) - .def("UnregisterFocusable", &CUIFocusSystem::UnregisterFocusable) - .def("IsRegistered", &CUIFocusSystem::IsRegistered) - .def("IsValuable", &CUIFocusSystem::IsValuable) - .def("IsNonValuable", &CUIFocusSystem::IsNonValuable) - .def("Update", &CUIFocusSystem::Update) - .def("LockToWindow", &CUIFocusSystem::LockToWindow) - .def("Unlock", &CUIFocusSystem::Unlock) - .def("GetLocker", &CUIFocusSystem::GetLocker) - .def("GetFocused", &CUIFocusSystem::GetFocused) - .def("SetFocused", &CUIFocusSystem::SetFocused) - .def("FindClosestFocusable", &CUIFocusSystem::FindClosestFocusable), - - def("GetUIFocusSystem", +[] { return UI().Focus(); }) - ]; -}); - -SCRIPT_EXPORT(CUITextureMaster, (), -{ - using namespace luabind; - using namespace luabind::policy; - - module(luaState) - [ - class_("TEX_INFO") - .def("get_file_name", &TEX_INFO::get_file_name) - .def("get_rect", &TEX_INFO::get_rect), - - def("GetTextureName", +[](pcstr iconName) - { - return CUITextureMaster::GetTextureFileName(iconName); - }), - - def("GetTextureRect", +[](pcstr iconName) - { - return CUITextureMaster::GetTextureRect(iconName); - }), - - def("GetTextureInfo", +[](pcstr name) - { - return CUITextureMaster::FindItem(name); - }), - - def("GetTextureInfo", +[](pcstr name, pcstr defaultName) - { - return CUITextureMaster::FindItem(name, defaultName); - }), - - def("GetTextureInfo", +[](pcstr name, TEX_INFO& outValue) - { - return CUITextureMaster::FindItem(name, outValue); - }), - - def("GetTextureInfo", +[](pcstr name, pcstr defaultName, TEX_INFO& outValue) - { - return CUITextureMaster::FindItem(name, defaultName, outValue); - }) - ]; -}); - -// We don't change game assets. -// This class allowes original game scripts to not specify the window name. -class CUIWindowScript final : public CUIWindow -{ -public: - CUIWindowScript() : CUIWindow(CUIWindowScript::GetDebugType()) {} - pcstr GetDebugType() override { return "CUIWindowScript"; } -}; - -SCRIPT_EXPORT(CUIWindow, (), -{ - using namespace luabind; - using namespace luabind::policy; - - module(luaState) - [ - class_("CUIWindowBase") - .def(constructor()) - .def("AttachChild", &CUIWindow::AttachChild, adopt<2>()) - .def("DetachChild", &CUIWindow::DetachChild) - .def("SetAutoDelete", &CUIWindow::SetAutoDelete) - .def("IsAutoDelete", &CUIWindow::IsAutoDelete) - - .def("IsCursorOverWindow", &CUIWindow::CursorOverWindow) - .def("IsUsingCursorRightNow", &CUIWindow::IsUsingCursorRightNow) - .def("FocusReceiveTime", &CUIWindow::FocusReceiveTime) - .def("GetAbsoluteRect", &CUIWindow::GetAbsoluteRect) - - .def("Init", +[](CUIWindow* self, float x, float y, float width, float height) - { - const Frect rect { x, y, width, height }; - self->SetWndRect(rect); - }) - .def("Init", (void (CUIWindow::*)(Frect))& CUIWindow::SetWndRect_script) - - .def("SetWndRect", (void (CUIWindow::*)(Frect)) & CUIWindow::SetWndRect_script) - .def("SetWndRect", +[](CUIWindow* self, float x, float y, float width, float height) - { - const Frect rect { x, y, width, height }; - self->SetWndRect(rect); - }) - - .def("SetWndSize", (void (CUIWindow::*)(Fvector2)) & CUIWindow::SetWndSize_script) - - .def("GetWndPos", +[](CUIWindow* w) -> Fvector2 { return w->GetWndPos(); }) - .def("SetWndPos", (void (CUIWindow::*)(Fvector2)) & CUIWindow::SetWndPos_script) - - .def("SetWndPos", +[](CUIWindow* self, float x, float y) - { - const Fvector2 pos { x, y }; - self->SetWndPos(pos); - }) - .def("SetWndSize", +[](CUIWindow* self, float width, float height) - { - const Fvector2 size { width, height }; - self->SetWndSize(size); - }) - - .def("GetWidth", &CUIWindow::GetWidth) - .def("SetWidth", &CUIWindow::SetWidth) - - .def("GetHeight", &CUIWindow::GetHeight) - .def("SetHeight", &CUIWindow::SetHeight) - - .def("Enable", &CUIWindow::Enable) - .def("IsEnabled", &CUIWindow::IsEnabled) - - .def("Show", &CUIWindow::Show) - .def("IsShown", &CUIWindow::IsShown) - - .def("SetFont", &CUIWindow::SetFont) - .def("GetFont", &CUIWindow::GetFont) - - .def("WindowName", +[](CUIWindow* self) -> pcstr { return self->WindowName().c_str(); }) - .def("SetWindowName", &CUIWindow::SetWindowName), - - class_("CUIWindow") - .def(constructor<>()) - ]; -}); - -SCRIPT_EXPORT(CUIFrameWindow, (CUIWindow), -{ - using namespace luabind; - using namespace luabind::policy; - - // We don't change game assets. - // This class allowes original game scripts to not specify the window name. - class CUIFrameWindowScript final : public CUIFrameWindow - { - public: - CUIFrameWindowScript() : CUIFrameWindow(CUIFrameWindowScript::GetDebugType()) {} - pcstr GetDebugType() override { return "CUIFrameWindowScript"; } - }; - - module(luaState) - [ - class_("CUIFrameWindowBase") - .def(constructor()) - .def("SetWidth", &CUIFrameWindow::SetWidth) - .def("SetHeight", &CUIFrameWindow::SetHeight) - .def("SetColor", &CUIFrameWindow::SetTextureColor) - .def("Init", +[](CUIFrameWindow* self, pcstr texture, float x, float y, float width, float height) - { - const Frect rect { x, y, width, height }; - self->SetWndRect(rect); - self->InitTexture(texture); - }), - class_("CUIFrameWindow") - .def(constructor<>()) - ]; -}); - -SCRIPT_EXPORT(CUIFrameLineWnd, (CUIWindow), -{ - using namespace luabind; - using namespace luabind::policy; - - // We don't change game assets. - // This class allowes original game scripts to not specify the window name. - class CUIFrameLineWndScript final : public CUIFrameLineWnd - { - public: - CUIFrameLineWndScript() : CUIFrameLineWnd(CUIFrameLineWndScript::GetDebugType()) {} - pcstr GetDebugType() override { return "CUIFrameLineWndScript"; } - }; - - module(luaState) - [ - class_("CUIFrameLineWndBase") - .def(constructor()) - .def("SetWidth", &CUIFrameLineWnd::SetWidth) - .def("SetHeight", &CUIFrameLineWnd::SetHeight) - .def("SetColor", &CUIFrameLineWnd::SetTextureColor) - .def("Init", +[](CUIFrameLineWnd* self, cpcstr texture, float x, float y, float width, float height, bool horizontal) - { - const Fvector2 pos { x, y }; - const Fvector2 size { width, height }; - self->InitFrameLineWnd(texture, pos, size, horizontal); - }), - class_("CUIFrameLineWnd") - .def(constructor<>()) - ]; -}); - -SCRIPT_EXPORT(UIHint, (CUIWindow), -{ - using namespace luabind; - using namespace luabind::policy; - - module(luaState) - [ - class_("UIHint") - .def(constructor<>()) - .def("SetWidth", &UIHint::SetWidth) - .def("SetHeight", &UIHint::SetHeight) - .def("SetHintText", &UIHint::set_text) - .def("GetHintText", &UIHint::get_text) - ]; -}); - -SCRIPT_EXPORT(CUIScrollView, (CUIWindow), -{ - using namespace luabind; - using namespace luabind::policy; - - module(luaState) - [ - class_("CUIScrollView") - .def(constructor<>()) - .def("AddWindow", &CUIScrollView::AddWindow) - .def("RemoveWindow", &CUIScrollView::RemoveWindow) - .def("Clear", &CUIScrollView::Clear) - .def("ScrollToBegin", &CUIScrollView::ScrollToBegin) - .def("ScrollToEnd", &CUIScrollView::ScrollToEnd) - .def("GetMinScrollPos", &CUIScrollView::GetMinScrollPos) - .def("GetMaxScrollPos", &CUIScrollView::GetMaxScrollPos) - .def("GetCurrentScrollPos", &CUIScrollView::GetCurrentScrollPos) - .def("SetFixedScrollBar", &CUIScrollView::SetFixedScrollBar) - .def("SetScrollPos", &CUIScrollView::SetScrollPos) - ]; -}); - -SCRIPT_EXPORT(EnumUIMessages, (), -{ - using namespace luabind; - using namespace luabind::policy; - - class EnumUIMessages - { - }; - module(luaState) - [ - class_("ui_events") - .enum_("events") - [ - // CUIWindow - value("WINDOW_LBUTTON_DOWN", int(WINDOW_LBUTTON_DOWN)), - value("WINDOW_RBUTTON_DOWN", int(WINDOW_RBUTTON_DOWN)), - value("WINDOW_LBUTTON_UP", int(WINDOW_LBUTTON_UP)), - value("WINDOW_RBUTTON_UP", int(WINDOW_RBUTTON_UP)), - value("WINDOW_MOUSE_MOVE", int(WINDOW_MOUSE_MOVE)), - value("WINDOW_LBUTTON_DB_CLICK", int(WINDOW_LBUTTON_DB_CLICK)), - value("WINDOW_KEY_PRESSED", int(WINDOW_KEY_PRESSED)), - value("WINDOW_KEY_RELEASED", int(WINDOW_KEY_RELEASED)), - value("WINDOW_MOUSE_CAPTURE_LOST", int(WINDOW_MOUSE_CAPTURE_LOST)), - value("WINDOW_KEYBOARD_CAPTURE_LOST", int(WINDOW_KEYBOARD_CAPTURE_LOST)), - - // Legacy SOC/CS events - value("STATIC_FOCUS_RECEIVED", int(WINDOW_FOCUS_RECEIVED)), - value("STATIC_FOCUS_LOST", int(WINDOW_FOCUS_LOST)), - - // CUIButton - value("BUTTON_CLICKED", int(BUTTON_CLICKED)), - value("BUTTON_DOWN", int(BUTTON_DOWN)), - - // CUITabControl - value("TAB_CHANGED", int(TAB_CHANGED)), - - // CUICheckButton - value("CHECK_BUTTON_SET", int(CHECK_BUTTON_SET)), - value("CHECK_BUTTON_RESET", int(CHECK_BUTTON_RESET)), - - // CUIRadioButton - value("RADIOBUTTON_SET", int(RADIOBUTTON_SET)), - - // CUIScrollBox - value("SCROLLBOX_MOVE", int(SCROLLBOX_MOVE)), - - // CUIScrollBar - value("SCROLLBAR_VSCROLL", int(SCROLLBAR_VSCROLL)), - value("SCROLLBAR_HSCROLL", int(SCROLLBAR_HSCROLL)), - - // CUIListWnd - value("LIST_ITEM_CLICKED", int(LIST_ITEM_CLICKED)), - value("LIST_ITEM_SELECT", int(LIST_ITEM_SELECT)), - value("LIST_ITEM_UNSELECT", int(LIST_ITEM_UNSELECT)), - - // UIPropertiesBox - value("PROPERTY_CLICKED", int(PROPERTY_CLICKED)), - - // CUIMessageBox - value("MESSAGE_BOX_OK_CLICKED", int(MESSAGE_BOX_OK_CLICKED)), - value("MESSAGE_BOX_YES_CLICKED", int(MESSAGE_BOX_YES_CLICKED)), - value("MESSAGE_BOX_NO_CLICKED", int(MESSAGE_BOX_NO_CLICKED)), - value("MESSAGE_BOX_CANCEL_CLICKED", int(MESSAGE_BOX_CANCEL_CLICKED)), - value("MESSAGE_BOX_COPY_CLICKED", int(MESSAGE_BOX_COPY_CLICKED)), - value("MESSAGE_BOX_QUIT_GAME_CLICKED", int(MESSAGE_BOX_QUIT_GAME_CLICKED)), - value("MESSAGE_BOX_QUIT_WIN_CLICKED", int(MESSAGE_BOX_QUIT_WIN_CLICKED)), - - value("EDIT_TEXT_COMMIT", int(EDIT_TEXT_COMMIT)), - // CMainMenu - value("MAIN_MENU_RELOADED", int(MAIN_MENU_RELOADED)) - ] - ]; -}); -// clang-format on diff --git a/src/xrUICore/XML/UITextureMaster.cpp b/src/xrUICore/XML/UITextureMaster.cpp index 3fddd4c684b..9db950de2c1 100644 --- a/src/xrUICore/XML/UITextureMaster.cpp +++ b/src/xrUICore/XML/UITextureMaster.cpp @@ -232,10 +232,8 @@ bool CUITextureMaster::ItemExist(const shared_str& texture_name) void CUITextureMaster::GetTextureShader(const shared_str& texture_name, ui_shader& sh) { - xr_map::iterator it; - it = m_textures.find(texture_name); - + const auto it = m_textures.find(texture_name); R_ASSERT3(it != m_textures.end(), "can't find texture", texture_name.c_str()); - sh->create("hud" DELIMITER "default", *((*it).second.file)); + sh->create("hud\\default", it->second.file.c_str()); } diff --git a/src/xrUICore/XML/UITextureMaster.h b/src/xrUICore/XML/UITextureMaster.h index e2548f34c2a..42cc88393ee 100644 --- a/src/xrUICore/XML/UITextureMaster.h +++ b/src/xrUICore/XML/UITextureMaster.h @@ -17,7 +17,7 @@ struct TEX_INFO { shared_str file; Frect rect; - LPCSTR get_file_name() { return *file; } + pcstr get_file_name() const { return file.c_str(); } Frect get_rect() { return rect; } }; @@ -65,4 +65,7 @@ class XRUICORE_API CUITextureMaster static xr_map m_textures; static xr_map m_shaders; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; diff --git a/src/xrUICore/XML/UIXmlInitBase.cpp b/src/xrUICore/XML/UIXmlInitBase.cpp index 322f7af26f6..1190ea87c1e 100644 --- a/src/xrUICore/XML/UIXmlInitBase.cpp +++ b/src/xrUICore/XML/UIXmlInitBase.cpp @@ -758,7 +758,7 @@ bool CUIXmlInitBase::InitTabControl(CUIXml& xml_doc, pcstr path, newButton->m_btn_id = xml_doc.ReadAttrib("button", i, "id"); if (!newButton->m_btn_id.size()) { - R_ASSERT4(defaultIdsAllowed, "Tab control tab doesn't have 'id' assigned.", xml_doc.m_xml_file_name, path); + R_ASSERT4(ShadowOfChernobylMode || defaultIdsAllowed, "Tab control tab doesn't have 'id' assigned.", xml_doc.m_xml_file_name, path); Msg("~ [%s] doesn't have `id` tag in file [%s]", xml_doc.m_xml_file_name, path); string32 temp; xr_sprintf(temp, "%d", i); @@ -811,7 +811,7 @@ bool CUIXmlInitBase::InitFrameLine(CUIXml& xml_doc, pcstr path, int index, CUIFr InitWindow(xml_doc, path, index, pWnd); - return pWnd->InitFrameLineWnd(*base_name, pos, size, !vertical, fatal); + return pWnd->InitFrameLineWnd(base_name.c_str(), pos, size, !vertical, fatal); } bool CUIXmlInitBase::InitTextFrameLine(CUIXml& xml_doc, pcstr path, int index, CUITextFrameLineWnd* pWnd, bool fatal /*= true*/) @@ -965,7 +965,7 @@ bool CUIXmlInitBase::InitMultiTexture(const CUIXml& xml_doc, pcstr path, int ind if (texture.size() > 0) { - pWnd->InitTexture(*texture); + pWnd->InitTexture(texture.c_str()); return true; } @@ -1205,7 +1205,7 @@ bool CUIXmlInitBase::InitListWnd(const CUIXml& xml_doc, pcstr path, int index, C u32 cl; const shared_str text_path = strconcat(buf, path, ":font"); - InitFont(xml_doc, *text_path, index, cl, LocalFont); + InitFont(xml_doc, text_path.c_str(), index, cl, LocalFont); if (LocalFont) { pWnd->SetFont(LocalFont); diff --git a/src/xrUICore/ui_debug.h b/src/xrUICore/ui_debug.h index 0031498b9fa..187edcf8c6d 100644 --- a/src/xrUICore/ui_debug.h +++ b/src/xrUICore/ui_debug.h @@ -10,6 +10,7 @@ class XR_NOVTABLE XRUICORE_API CUIDebuggable void RegisterDebuggable(); void UnregisterDebuggable(); + [[nodiscard]] virtual pcstr GetDebugType() = 0; virtual bool FillDebugTree(const CUIDebugState& debugState) = 0; diff --git a/src/xrUICore/ui_export_script.cpp b/src/xrUICore/ui_export_script.cpp new file mode 100644 index 00000000000..df6af70db74 --- /dev/null +++ b/src/xrUICore/ui_export_script.cpp @@ -0,0 +1,913 @@ +#include "pch.hpp" + +#include "xrCore/XML/XMLDocument.hpp" + +#include "ui_styles.h" +#include "ui_focus.h" +#include "Cursor/UICursor.h" +#include "XML/UITextureMaster.h" + +#include "Windows/UIWindow.h" +#include "Windows/UIFrameWindow.h" +#include "Windows/UIFrameLineWnd.h" +#include "ScrollView/UIScrollView.h" +#include "Hint/UIHint.h" + +#include "ListBox/UIListBox.h" +#include "ListBox/UIListBoxItem.h" +#include "ListBox/UIListBoxItemMsgChain.h" + +#include "ListWnd/UIListWnd.h" +#include "ListWnd/UIListItemEx.h" + +#include "Static/UIStatic.h" + +#include "Buttons/UIButton.h" +#include "Buttons/UI3tButton.h" +#include "Buttons/UICheckButton.h" +#include "SpinBox/UISpinNum.h" +#include "SpinBox/UISpinText.h" + +#include "TrackBar/UITrackBar.h" + +#include "TabControl/UITabControl.h" +#include "TabControl/UITabButton.h" + +#include "ComboBox/UIComboBox.h" + +#include "ProgressBar/UIProgressBar.h" + +#include "PropertiesBox/UIPropertiesBox.h" + +#include "EditBox/UIEditBox.h" + +#include "MessageBox/UIMessageBox.h" + +#include "xrScriptEngine/script_space.hpp" + +void UIStyleManager::script_register(lua_State* luaState) +{ + using namespace luabind; + using namespace luabind::policy; + + module(luaState) + [ + def("GetDefaultUIPath", +[] { return UI_PATH_DEFAULT; }), + def("GetDefaultUIPathWithDelimiter", +[] { return UI_PATH_DEFAULT_WITH_DELIMITER; }), + def("GetUIPath", +[] { return UI_PATH; }), + def("GetUIPathWithDelimiter", +[] { return UI_PATH_WITH_DELIMITER; }), + + class_("UIStyleManager") + .def("GetAllStyles", &UIStyleManager::GetToken, return_stl_iterator()) + .def("DefaultStyleIsSet", &UIStyleManager::DefaultStyleIsSet) + .def("GetCurrentStyleId", &UIStyleManager::GetCurrentStyleId) + .def("GetCurrentStyleName", &UIStyleManager::GetCurrentStyleName) + .def("SetStyle", &UIStyleManager::SetStyle) + .def("SetupStyle", &UIStyleManager::SetupStyle) + .def("ResetUI", &UIStyleManager::Reset), + + def("GetUIStyleManager", +[] { return UIStyles; }) + ]; +} + +void CUIFocusSystem::script_register(lua_State* luaState) +{ + using namespace luabind; + + module(luaState) + [ + class_("FocusDirection") + .enum_("direction") + [ + value("Same", (int)FocusDirection::Same), + value("Up", (int)FocusDirection::Up), + value("Down", (int)FocusDirection::Down), + value("Left", (int)FocusDirection::Left), + value("Right", (int)FocusDirection::Right), + value("UpperLeft", (int)FocusDirection::UpperLeft), + value("UpperRight", (int)FocusDirection::UpperRight), + value("LowerLeft", (int)FocusDirection::LowerLeft), + value("LowerRight", (int)FocusDirection::LowerRight) + ], + + class_("CUIFocusSystem") + .def("RegisterFocusable", &CUIFocusSystem::RegisterFocusable) + .def("UnregisterFocusable", &CUIFocusSystem::UnregisterFocusable) + .def("IsRegistered", &CUIFocusSystem::IsRegistered) + .def("IsValuable", &CUIFocusSystem::IsValuable) + .def("IsNonValuable", &CUIFocusSystem::IsNonValuable) + .def("Update", &CUIFocusSystem::Update) + .def("LockToWindow", &CUIFocusSystem::LockToWindow) + .def("Unlock", &CUIFocusSystem::Unlock) + .def("GetLocker", &CUIFocusSystem::GetLocker) + .def("GetFocused", &CUIFocusSystem::GetFocused) + .def("SetFocused", &CUIFocusSystem::SetFocused) + .def("FindClosestFocusable", &CUIFocusSystem::FindClosestFocusable), + + def("GetUIFocusSystem", +[] { return UI().Focus(); }) + ]; +} + +void CUITextureMaster::script_register(lua_State* luaState) +{ + using namespace luabind; + + module(luaState) + [ + class_("TEX_INFO") + .def("get_file_name", &TEX_INFO::get_file_name) + .def("get_rect", &TEX_INFO::get_rect), + + def("GetTextureName", +[](pcstr iconName) + { + return CUITextureMaster::GetTextureFileName(iconName); + }), + + def("GetTextureRect", +[](pcstr iconName) + { + return CUITextureMaster::GetTextureRect(iconName); + }), + + def("GetTextureInfo", +[](pcstr name) + { + return CUITextureMaster::FindItem(name); + }), + + def("GetTextureInfo", +[](pcstr name, pcstr defaultName) + { + return CUITextureMaster::FindItem(name, defaultName); + }), + + def("GetTextureInfo", +[](pcstr name, TEX_INFO& outValue) + { + return CUITextureMaster::FindItem(name, outValue); + }), + + def("GetTextureInfo", +[](pcstr name, pcstr defaultName, TEX_INFO& outValue) + { + return CUITextureMaster::FindItem(name, defaultName, outValue); + }) + ]; +} + +void CUIWindow::script_register(lua_State* luaState) +{ + // We don't change game assets. + // This class allowes original game scripts to not specify the window name. + class CUIWindowScript final : public CUIWindow + { + public: + CUIWindowScript() : CUIWindow(CUIWindowScript::GetDebugType()) {} + + pcstr GetDebugType() override + { + return "CUIWindowScript"; + } + }; + + class EnumUIMessages + { + }; + + using namespace luabind; + using namespace luabind::policy; + + module(luaState) + [ + def("GetARGB", +[](u16 a, u16 r, u16 g, u16 b) { return color_argb(a, r, g, b); }), + + // HUD fonts + def("GetFontSmall", +[] { return UI().Font().pFontStat; }), + def("GetFontMedium", +[] { return UI().Font().pFontMedium; }), + def("GetFontDI", +[] { return UI().Font().pFontDI; }), + + // UI fonts + def("GetFontGraffiti19Russian", +[] { return UI().Font().pFontGraffiti19Russian; }), + def("GetFontGraffiti22Russian", +[] { return UI().Font().pFontGraffiti22Russian; }), + def("GetFontLetterica16Russian", +[] { return UI().Font().pFontLetterica16Russian; }), + def("GetFontLetterica18Russian", +[] { return UI().Font().pFontLetterica18Russian; }), + def("GetFontGraffiti32Russian", +[] { return UI().Font().pFontGraffiti32Russian; }), + def("GetFontGraffiti50Russian", +[] { return UI().Font().pFontGraffiti50Russian; }), + def("GetFontLetterica25", +[] { return UI().Font().pFontLetterica25; }), + + def("GetCursorPosition", +[] { return GetUICursor().GetCursorPosition(); }), + def("SetCursorPosition", +[](const Fvector2& pos) { GetUICursor().SetUICursorPosition(pos); }), + + def("FitInRect", &fit_in_rect), + + class_("CUIWindowBase") + .def(constructor()) + .def("AttachChild", &CUIWindow::AttachChild, adopt<2>()) + .def("DetachChild", &CUIWindow::DetachChild) + .def("SetAutoDelete", &CUIWindow::SetAutoDelete) + .def("IsAutoDelete", &CUIWindow::IsAutoDelete) + + .def("IsCursorOverWindow", &CUIWindow::CursorOverWindow) + .def("IsUsingCursorRightNow", &CUIWindow::IsUsingCursorRightNow) + .def("FocusReceiveTime", &CUIWindow::FocusReceiveTime) + .def("GetAbsoluteRect", &CUIWindow::GetAbsoluteRect) + + .def("Init", +[](CUIWindow* self, float x, float y, float width, float height) + { + const Frect rect { x, y, width, height }; + self->SetWndRect(rect); + }) + .def("Init", (void (CUIWindow::*)(Frect))& CUIWindow::SetWndRect_script) + + .def("SetWndRect", (void (CUIWindow::*)(Frect)) & CUIWindow::SetWndRect_script) + .def("SetWndRect", +[](CUIWindow* self, float x, float y, float width, float height) + { + const Frect rect { x, y, width, height }; + self->SetWndRect(rect); + }) + + .def("SetWndSize", (void (CUIWindow::*)(Fvector2)) & CUIWindow::SetWndSize_script) + + .def("GetWndPos", +[](CUIWindow* w) -> Fvector2 { return w->GetWndPos(); }) + .def("SetWndPos", (void (CUIWindow::*)(Fvector2)) & CUIWindow::SetWndPos_script) + + .def("SetWndPos", +[](CUIWindow* self, float x, float y) + { + const Fvector2 pos { x, y }; + self->SetWndPos(pos); + }) + .def("SetWndSize", +[](CUIWindow* self, float width, float height) + { + const Fvector2 size { width, height }; + self->SetWndSize(size); + }) + + .def("GetWidth", &CUIWindow::GetWidth) + .def("SetWidth", &CUIWindow::SetWidth) + + .def("GetHeight", &CUIWindow::GetHeight) + .def("SetHeight", &CUIWindow::SetHeight) + + .def("Enable", &CUIWindow::Enable) + .def("IsEnabled", &CUIWindow::IsEnabled) + + .def("Show", &CUIWindow::Show) + .def("IsShown", &CUIWindow::IsShown) + + .def("SetFont", &CUIWindow::SetFont) + .def("GetFont", &CUIWindow::GetFont) + + .def("WindowName", +[](CUIWindow* self) -> pcstr { return self->WindowName().c_str(); }) + .def("SetWindowName", &CUIWindow::SetWindowName), + + class_("CUIWindow") + .def(constructor<>()), + + class_("UIHint") + .def(constructor<>()) + .def("SetWidth", &UIHint::SetWidth) + .def("SetHeight", &UIHint::SetHeight) + .def("SetHintText", &UIHint::set_text) + .def("GetHintText", &UIHint::get_text), + + class_("ui_events") + .enum_("events") + [ + // CUIWindow + value("WINDOW_LBUTTON_DOWN", int(WINDOW_LBUTTON_DOWN)), + value("WINDOW_RBUTTON_DOWN", int(WINDOW_RBUTTON_DOWN)), + value("WINDOW_LBUTTON_UP", int(WINDOW_LBUTTON_UP)), + value("WINDOW_RBUTTON_UP", int(WINDOW_RBUTTON_UP)), + value("WINDOW_MOUSE_MOVE", int(WINDOW_MOUSE_MOVE)), + value("WINDOW_LBUTTON_DB_CLICK", int(WINDOW_LBUTTON_DB_CLICK)), + value("WINDOW_KEY_PRESSED", int(WINDOW_KEY_PRESSED)), + value("WINDOW_KEY_RELEASED", int(WINDOW_KEY_RELEASED)), + value("WINDOW_MOUSE_CAPTURE_LOST", int(WINDOW_MOUSE_CAPTURE_LOST)), + value("WINDOW_KEYBOARD_CAPTURE_LOST", int(WINDOW_KEYBOARD_CAPTURE_LOST)), + + // Legacy SOC/CS events + value("STATIC_FOCUS_RECEIVED", int(WINDOW_FOCUS_RECEIVED)), + value("STATIC_FOCUS_LOST", int(WINDOW_FOCUS_LOST)), + + // CUIButton + value("BUTTON_CLICKED", int(BUTTON_CLICKED)), + value("BUTTON_DOWN", int(BUTTON_DOWN)), + + // CUITabControl + value("TAB_CHANGED", int(TAB_CHANGED)), + + // CUICheckButton + value("CHECK_BUTTON_SET", int(CHECK_BUTTON_SET)), + value("CHECK_BUTTON_RESET", int(CHECK_BUTTON_RESET)), + + // CUIRadioButton + value("RADIOBUTTON_SET", int(RADIOBUTTON_SET)), + + // CUIScrollBox + value("SCROLLBOX_MOVE", int(SCROLLBOX_MOVE)), + + // CUIScrollBar + value("SCROLLBAR_VSCROLL", int(SCROLLBAR_VSCROLL)), + value("SCROLLBAR_HSCROLL", int(SCROLLBAR_HSCROLL)), + + // CUIListWnd + value("LIST_ITEM_CLICKED", int(LIST_ITEM_CLICKED)), + value("LIST_ITEM_SELECT", int(LIST_ITEM_SELECT)), + value("LIST_ITEM_UNSELECT", int(LIST_ITEM_UNSELECT)), + + // UIPropertiesBox + value("PROPERTY_CLICKED", int(PROPERTY_CLICKED)), + + // CUIMessageBox + value("MESSAGE_BOX_OK_CLICKED", int(MESSAGE_BOX_OK_CLICKED)), + value("MESSAGE_BOX_YES_CLICKED", int(MESSAGE_BOX_YES_CLICKED)), + value("MESSAGE_BOX_NO_CLICKED", int(MESSAGE_BOX_NO_CLICKED)), + value("MESSAGE_BOX_CANCEL_CLICKED", int(MESSAGE_BOX_CANCEL_CLICKED)), + value("MESSAGE_BOX_COPY_CLICKED", int(MESSAGE_BOX_COPY_CLICKED)), + value("MESSAGE_BOX_QUIT_GAME_CLICKED", int(MESSAGE_BOX_QUIT_GAME_CLICKED)), + value("MESSAGE_BOX_QUIT_WIN_CLICKED", int(MESSAGE_BOX_QUIT_WIN_CLICKED)), + + value("EDIT_TEXT_COMMIT", int(EDIT_TEXT_COMMIT)), + + // CMainMenu + value("MAIN_MENU_RELOADED", int(MAIN_MENU_RELOADED)) + ] + ]; +} + +void CUIFrameWindow::script_register(lua_State* luaState) +{ + // We don't change game assets. + // This class allowes original game scripts to not specify the window name. + class CUIFrameWindowScript final : public CUIFrameWindow + { + public: + CUIFrameWindowScript() : CUIFrameWindow(CUIFrameWindowScript::GetDebugType()) {} + + pcstr GetDebugType() override + { + return "CUIFrameWindowScript"; + } + }; + + using namespace luabind; + + module(luaState) + [ + class_("CUIFrameWindowBase") + .def(constructor()) + .def("SetWidth", &CUIFrameWindow::SetWidth) + .def("SetHeight", &CUIFrameWindow::SetHeight) + .def("SetColor", &CUIFrameWindow::SetTextureColor) + .def("Init", +[](CUIFrameWindow* self, pcstr texture, float x, float y, float width, float height) + { + self->SetWndRect({ x, y, width, height }); + self->InitTexture(texture); + }), + + class_("CUIFrameWindow") + .def(constructor<>()) + ]; +} + +void CUIFrameLineWnd::script_register(lua_State* luaState) +{ + // We don't change game assets. + // This class allowes original game scripts to not specify the window name. + class CUIFrameLineWndScript final : public CUIFrameLineWnd + { + public: + CUIFrameLineWndScript() : CUIFrameLineWnd(CUIFrameLineWndScript::GetDebugType()) {} + + pcstr GetDebugType() override + { + return "CUIFrameLineWndScript"; + } + }; + + using namespace luabind; + + module(luaState) + [ + class_("CUIFrameLineWndBase") + .def(constructor()) + .def("SetWidth", &CUIFrameLineWnd::SetWidth) + .def("SetHeight", &CUIFrameLineWnd::SetHeight) + .def("SetColor", &CUIFrameLineWnd::SetTextureColor) + .def("Init", +[](CUIFrameLineWnd* self, cpcstr texture, float x, float y, float width, float height, bool horizontal) + { + const Fvector2 pos { x, y }; + const Fvector2 size { width, height }; + self->InitFrameLineWnd(texture, pos, size, horizontal); + }), + + class_("CUIFrameLineWnd") + .def(constructor<>()) + ]; +} + +void CUIScrollView::script_register(lua_State* luaState) +{ + using namespace luabind; + + module(luaState) + [ + class_("CUIScrollView") + .def(constructor<>()) + .def("AddWindow", &CUIScrollView::AddWindow) + .def("RemoveWindow", &CUIScrollView::RemoveWindow) + .def("Clear", &CUIScrollView::Clear) + .def("ScrollToBegin", &CUIScrollView::ScrollToBegin) + .def("ScrollToEnd", &CUIScrollView::ScrollToEnd) + .def("GetMinScrollPos", &CUIScrollView::GetMinScrollPos) + .def("GetMaxScrollPos", &CUIScrollView::GetMaxScrollPos) + .def("GetCurrentScrollPos", &CUIScrollView::GetCurrentScrollPos) + .def("SetFixedScrollBar", &CUIScrollView::SetFixedScrollBar) + .def("SetScrollPos", &CUIScrollView::SetScrollPos) + ]; +} + +void CUIListBox::script_register(lua_State* luaState) +{ + using namespace luabind; + using namespace luabind::policy; + + module(luaState) + [ + class_("CUIListBox") + .def(constructor<>()) + .def("ShowSelectedItem", &CUIListBox::Show) + .def("RemoveAll", &CUIListBox::Clear) + .def("GetSize", &CUIListBox::GetSize) + .def("GetSelectedItem", &CUIListBox::GetSelectedItem) + .def("GetSelectedIndex", &CUIListBox::GetSelectedIDX) + .def("SetSelectedIndex", &CUIListBox::SetSelectedIDX) + .def("SetItemHeight", &CUIListBox::SetItemHeight) + .def("GetItemHeight", &CUIListBox::GetItemHeight) + .def("GetItemByIndex", &CUIListBox::GetItemByIDX) + .def("GetItem", &CUIListBox::GetItem) + .def("RemoveItem", &CUIListBox::RemoveWindow) + .def("AddTextItem", &CUIListBox::AddTextItem) + .def("AddExistingItem", &CUIListBox::AddExistingItem, adopt<2>()) + ]; +} + +void CUIListBoxItem::script_register(lua_State* luaState) +{ + struct CUIListBoxItemWrapper : public CUIListBoxItem, public luabind::wrap_base + { + CUIListBoxItemWrapper(float h) : CUIListBoxItem(h) {} + pcstr GetDebugType() override { return "CUIListBoxItemScript"; } + }; + + struct CUIListBoxItemMsgChainWrapper : public CUIListBoxItemMsgChain, public luabind::wrap_base + { + CUIListBoxItemMsgChainWrapper(float h) : CUIListBoxItemMsgChain(h) {} + pcstr GetDebugType() override { return "CUIListBoxItemMsgChainScript"; } + }; + + using namespace luabind; + + module(luaState) + [ + class_("CUIListBoxItem") + .def(constructor()) + .def("GetTextItem", &CUIListBoxItem::GetTextItem) + .def("AddTextField", &CUIListBoxItem::AddTextField) + .def("AddIconField", &CUIListBoxItem::AddIconField) + .def("SetTextColor", &CUIListBoxItem::SetTextColor), + + class_("CUIListBoxItemMsgChain") + .def(constructor()) + ]; +} + +void CUIListWnd::script_register(lua_State* luaState) +{ + using namespace luabind; + using namespace luabind::policy; + + module(luaState) + [ + class_("CUIListWnd") + .def(constructor<>()) + //.def("AddText", &CUIListWnd::AddText_script) + .def("AddItem", +[](CUIListWnd* self, CUIListItem* item) + { + return self->AddItem(item, -1); + }, adopt<2>()) + .def("RemoveItem", &CUIListWnd::RemoveItem) + .def("RemoveAll", &CUIListWnd::RemoveAll) + .def("EnableScrollBar", &CUIListWnd::EnableScrollBar) + .def("IsScrollBarEnabled", &CUIListWnd::IsScrollBarEnabled) + .def("ScrollToBegin", &CUIListWnd::ScrollToBegin) + .def("ScrollToEnd", &CUIListWnd::ScrollToEnd) + .def("SetItemHeight", &CUIListWnd::SetItemHeight) + .def("GetItem", &CUIListWnd::GetItem) + .def("GetItemPos", &CUIListWnd::GetItemPos) + .def("GetSize", &CUIListWnd::GetItemsCount) + .def("ScrollToBegin", &CUIListWnd::ScrollToBegin) + .def("ScrollToEnd", &CUIListWnd::ScrollToEnd) + .def("ScrollToPos", +[](CUIListWnd* self, int position) + { + self->ScrollToPos(position, 0.0f); + }) + .def("ScrollToPos", &CUIListWnd::ScrollToPos) + .def("SetWidth", &CUIListWnd::SetWidth) + .def("SetTextColor", &CUIListWnd::SetTextColor) + .def("ActivateList", &CUIListWnd::ActivateList) + .def("IsListActive", &CUIListWnd::IsListActive) + .def("SetVertFlip", &CUIListWnd::SetVertFlip) + .def("GetVertFlip", &CUIListWnd::GetVertFlip) + .def("SetFocusedItem", &CUIListWnd::SetFocusedItem) + .def("GetFocusedItem", &CUIListWnd::GetFocusedItem) + .def("ShowSelectedItem", &CUIListWnd::ShowSelectedItem) + + .def("GetSelectedItem", &CUIListWnd::GetSelectedItem) + .def("ResetFocusCapture", &CUIListWnd::ResetFocusCapture) + ]; +} + +void CUIListItem::script_register(lua_State* luaState) +{ + struct CUIListItemWrapper final : public CUIListItem, public luabind::wrap_base + { + pcstr GetDebugType() override { return "CUIListItemScript"; } + }; + + struct CUIListItemExWrapper final : public CUIListItemEx, public luabind::wrap_base + { + pcstr GetDebugType() override { return "CUIListItemExScript"; } + }; + + using namespace luabind; + + module(luaState) + [ + class_("CUIListItem") + .def(constructor<>()), + class_("CUIListItemEx") + .def(constructor<>()) + .def("SetSelectionColor", &CUIListItemEx::SetSelectionColor) + ]; +} + +void CUIStatic::script_register(lua_State* luaState) +{ + // We don't change game assets. + // This class allowes original game scripts to not specify the window name. + class CUIStaticScript final : public CUIStatic + { + public: + CUIStaticScript() : CUIStatic("CUIStaticScript") {} + pcstr GetDebugType() override { return "CUIStaticScript"; } + }; + + using namespace luabind; + + module(luaState) + [ + class_("CUILines") + .def("SetFont", &CUILines::SetFont) + .def("SetText", &CUILines::SetText) + .def("SetTextST", &CUILines::SetTextST) + .def("GetText", &CUILines::GetText) + .def("SetElipsis", &CUILines::SetEllipsis) + .def("SetTextColor", &CUILines::SetTextColor), + + class_("CUIStaticBase") + .def(constructor()) + + .def("TextControl", &CUIStatic::TextItemControl) + + .def("SetText", &CUIStatic::SetText) + .def("SetTextST", &CUIStatic::SetTextST) + + .def("GetText", &CUIStatic::GetText) + + .def("SetTextOffset", &CUIStatic::SetTextOffset) + .def("SetTextX", +[](CUIStatic* self, float x) { self->TextItemControl()->m_TextOffset.x = x; }) + .def("SetTextY", +[](CUIStatic* self, float y) { self->TextItemControl()->m_TextOffset.y = y; }) + .def("GetTextX", +[](CUIStatic* self) { return self->TextItemControl()->m_TextOffset.x; }) + .def("GetTextY", +[](CUIStatic* self) { return self->TextItemControl()->m_TextOffset.y; }) + + .def("SetColor", &CUIStatic::SetTextureColor) + .def("GetColor", &CUIStatic::GetTextureColor) + + .def("SetFont", &CUIStatic::SetFont) + .def("GetFont", &CUIStatic::GetFont) + + .def("SetTextColor", +[](CUIStatic* self, int a, int r, int g, int b) + { + self->SetTextColor(color_argb(a, r, g, b)); + }) + .def("GetTextColor", &CUIStatic::GetTextColor) + .def("SetTextComplexMode", &CUIStatic::SetTextComplexMode) + .def("SetTextAlignment", &CUIStatic::SetTextAlignment) + .def("SetVTextAlignment", &CUIStatic::SetVTextAlignment) + + .def("AdjustHeightToText", &CUIStatic::AdjustHeightToText) + .def("AdjustWidthToText", &CUIStatic::AdjustWidthToText) + + .def("Init", +[](CUIStatic* self, float x, float y, float width, float height) + { + self->SetWndRect({ x, y, width, height }); + }) + .def("Init", +[](CUIStatic* self, cpcstr texture, float x, float y, float width, float height) + { + self->SetWndRect({ x, y, width, height }); + self->InitTexture(texture); + }) + + .def("InitTexture", &CUIStatic::InitTexture) + .def("InitTexture", +[](CUIStatic* self, pcstr texture) { self->InitTexture(texture); }) + .def("InitTextureEx", &CUIStatic::InitTextureEx) + .def("InitTextureEx", +[](CUIStatic* self, pcstr texture, pcstr shader) { self->InitTextureEx(texture, shader); }) + + .def("SetTextureColor", &CUIStatic::SetTextureColor) + .def("GetTextureColor", &CUIStatic::GetTextureColor) + + .def("SetTextureOffset", &CUIStatic::SetTextureOffset) + + .def("SetTextureRect", &CUIStatic::SetTextureRect_script) + .def("GetTextureRect", &CUIStatic::GetTextureRect_script) + + .def("SetOriginalRect", &CUIStatic::SetTextureRect_script) + .def("GetOriginalRect", &CUIStatic::GetTextureRect_script) + + .def("SetStretchTexture", &CUIStatic::SetStretchTexture) + .def("GetStretchTexture", &CUIStatic::GetStretchTexture) + + .def("SetTextAlign", +[](CUIStatic* self, u32 align) + { + self->TextItemControl()->SetTextAlignment(static_cast(align)); + self->TextItemControl()->GetFont()->SetAligment(static_cast(align)); + }) + .def("GetTextAlign", +[](CUIStatic* self) -> u32 + { + return self->TextItemControl()->GetTextAlignment(); + }) + + .def("SetHeading", &CUIStatic::SetHeading) + .def("GetHeading", &CUIStatic::GetHeading) + + //.def("ClipperOn", &CUIStatic::ClipperOn) + //.def("ClipperOff", (void(CUIStatic::*)(void))&CUIStatic::ClipperOff) + + //.def("GetClipperState", &CUIStatic::GetClipperState) + + .def("SetEllipsis", &CUIStatic::SetEllipsis) + .def("SetElipsis", &CUIStatic::SetEllipsis) + .def("SetElipsis", +[](CUIStatic* self, int mode, int indent) + { + self->SetEllipsis(mode != 0); + }), + + class_("CUIStatic") + .def(constructor<>()) + ]; +} + +void CUIButton::script_register(lua_State* luaState) +{ + using namespace luabind; + + module(luaState) + [ + class_("CUIButton") + .def("Init", +[](CUIButton* self, float x, float y, float width, float height) + { + self->SetWndRect({ x, y, width, height }); + }) + .def("Init", +[](CUIButton* self, cpcstr texture, float x, float y, float width, float height) + { + self->SetWndRect({ x, y, width, height }); + self->InitTexture(texture); + }) + .def(constructor<>()), + + class_("CUI3tButton") + .def(constructor<>()), + + class_("CUICheckButton") + .def(constructor<>()) + .def("GetCheck", &CUICheckButton::GetCheck) + .def("SetCheck", &CUICheckButton::SetCheck) + .def("SetDependControl", &CUICheckButton::SetDependControl), + + class_("CUITabButton") + .def(constructor<>()), + + class_("CUICustomSpin") + .def("Init", +[](CUICustomSpin* self, float x, float y, float width, float height) + { + const Fvector2 pos { x, y }; + const Fvector2 size { width, height }; + + self->InitSpin(pos, size); + }) + .def("GetText", &CUICustomSpin::GetText), + + class_("CUISpinNum") + .def(constructor<>()), + + class_("CUISpinFlt") + .def(constructor<>()), + + class_("CUISpinText") + .def(constructor<>()), + + class_("CUITrackBar") + .def(constructor<>()) + .def("GetCheck", &CUITrackBar::GetCheck) + .def("SetCheck", &CUITrackBar::SetCheck) + .def("GetIValue", &CUITrackBar::GetIValue) + .def("GetFValue", &CUITrackBar::GetFValue) + .def("SetOptIBounds", &CUITrackBar::SetOptIBounds) + .def("SetOptFBounds", &CUITrackBar::SetOptFBounds) + .def("SetCurrentValue", &CUITrackBar::SetCurrentOptValue) + ]; +} + +void CUITabControl::script_register(lua_State* luaState) +{ + using namespace luabind; + using namespace luabind::policy; + + module(luaState) + [ + class_("CUITabControl") + .def(constructor<>()) + .def("AddItem", (bool (CUITabControl::*)(CUITabButton*))(&CUITabControl::AddItem), adopt<2>()) + .def("AddItem", (bool (CUITabControl::*)(pcstr, pcstr, Fvector2, Fvector2)) &CUITabControl::AddItem) + .def("AddItem", +[](CUITabControl* self, pcstr pItemName, pcstr pTexName, float x, float y, float width, float height) + { + self->AddItem(pItemName, pTexName, { x, y }, { width, height }); + }) + .def("RemoveItem", &CUITabControl::RemoveItemByIndex) + .def("RemoveItemById", &CUITabControl::RemoveItemById_script) + .def("RemoveAll", &CUITabControl::RemoveAll) + .def("GetActiveId", &CUITabControl::GetActiveId_script) + .def("GetActiveIndex", &CUITabControl::GetActiveIndex) + .def("GetTabsCount", &CUITabControl::GetTabsCount) + .def("SetActiveTab", &CUITabControl::SetActiveTab_script) + .def("SetNewActiveTab", &CUITabControl::SetActiveTabByIndex) + .def("GetButtonById", &CUITabControl::GetButtonById_script) + .def("GetButtonByIndex", &CUITabControl::GetButtonByIndex) + ]; +} + +void CUIComboBox::script_register(lua_State* luaState) +{ + using namespace luabind; + + module(luaState) + [ + class_("CUIComboBox") + .def(constructor<>()) + .def("Init", +[](CUIComboBox* self, float x, float y, float width) + { + self->InitComboBox({ x, y }, width); + }) + .def("Init", +[](CUIComboBox* self, float x, float y, float width, float /*height*/) + { + self->InitComboBox({ x, y }, width); + }) + .def("SetVertScroll", &CUIComboBox::SetVertScroll) + .def("SetListLength", &CUIComboBox::SetListLength) + .def("CurrentID", &CUIComboBox::CurrentID) + .def("SetCurrentID", &CUIComboBox::SetItemIDX) + .def("disable_id", &CUIComboBox::disable_id) + .def("enable_id", &CUIComboBox::enable_id) + .def("AddItem", &CUIComboBox::AddItem_) + .def("GetText", &CUIComboBox::GetText) + .def("GetTextOf", &CUIComboBox::GetTextOf) + .def("SetText", &CUIComboBox::SetText) + .def("ClearList", &CUIComboBox::ClearList) + .def("SetCurrentValue", &CUIComboBox::SetCurrentOptValue) + .def("SetCurrentOptValue", &CUIComboBox::SetCurrentOptValue) + .def("SetCurrentIdx", &CUIComboBox::SetSelectedIDX) + .def("GetCurrentIdx", &CUIComboBox::GetSelectedIDX) + ]; +} + +void CUIProgressBar::script_register(lua_State* luaState) +{ + using namespace luabind; + + module(luaState) + [ + class_("CUIProgressBar") + .def(constructor<>()) + .def("SetProgressPos", &CUIProgressBar::SetProgressPos) + .def("GetProgressPos", &CUIProgressBar::GetProgressPos) + + .def("GetRange_min", &CUIProgressBar::GetRange_min) + .def("GetRange_max", &CUIProgressBar::GetRange_max) + ]; +} + +void CUIPropertiesBox::script_register(lua_State* luaState) +{ + using namespace luabind; + + module(luaState) + [ + class_("CUIPropertiesBox") + .def(constructor<>()) + .def("RemoveItem", &CUIPropertiesBox::RemoveItemByTAG) + .def("RemoveAll", &CUIPropertiesBox::RemoveAll) + .def("Show", (void (CUIPropertiesBox::*)(int, int)) &CUIPropertiesBox::Show) + .def("Hide", &CUIPropertiesBox::Hide) + .def("GetSelectedItem", &CUIPropertiesBox::GetClickedItem) + .def("AutoUpdateSize", &CUIPropertiesBox::AutoUpdateSize) + .def("AddItem", &CUIPropertiesBox::AddItem_script) + .def("InitPropertiesBox", &CUIPropertiesBox::InitPropertiesBox) + ]; +} + +void CUIEditBox::script_register(lua_State* luaState) +{ + using namespace luabind; + + module(luaState) + [ + class_("CUICustomEdit") + .def("SetText", &CUICustomEdit::SetText) + .def("GetText", &CUICustomEdit::GetText) + .def("CaptureFocus", &CUICustomEdit::CaptureFocus) + .def("SetNextFocusCapturer", &CUICustomEdit::SetNextFocusCapturer), + + class_("CUIEditBox") + .def(constructor<>()) + .def("InitTexture", &CUIEditBox::InitTexture) + .def("InitTexture", +[](CUIEditBox* self, pcstr texture) { self->InitTexture(texture); }) + ]; +} + +void CUIMessageBox::script_register(lua_State* luaState) +{ + using namespace luabind; + + module(luaState) + [ + class_("CUIMessageBox") + .def(constructor<>()) + .def("Init", &CUIMessageBox::InitMessageBox) + .def("InitMessageBox", &CUIMessageBox::InitMessageBox) + .def("SetText", &CUIMessageBox::SetText) + .def("GetHost", &CUIMessageBox::GetHost) + .def("GetPassword", &CUIMessageBox::GetPassword) + ]; +} + +void CUIOptionsManager::script_register(lua_State* luaState) +{ + using namespace luabind; + + class CUIOptionsManagerScript + { + public: + void SaveBackupValues(pcstr group) + { + CUIOptionsItem::GetOptionsManager()->SaveBackupValues(group); + } + void SetCurrentValues(pcstr group) + { + CUIOptionsItem::GetOptionsManager()->SetCurrentValues(group); + } + void SaveValues(pcstr group) + { + CUIOptionsItem::GetOptionsManager()->SaveValues(group); + } + void UndoGroup(pcstr group) + { + CUIOptionsItem::GetOptionsManager()->UndoGroup(group); + } + void OptionsPostAccept() + { + CUIOptionsItem::GetOptionsManager()->OptionsPostAccept(); + } + void SendMessage2Group(pcstr group, pcstr message) + { + CUIOptionsItem::GetOptionsManager()->SendMessage2Group(group, message); + } + bool NeedSystemRestart() + { + return CUIOptionsItem::GetOptionsManager()->NeedSystemRestart(); + } + bool NeedVidRestart() + { + return CUIOptionsItem::GetOptionsManager()->NeedVidRestart(); + } + }; + + module(luaState) + [ + class_("COptionsManager") + .def(constructor<>()) + .def("SaveBackupValues", &CUIOptionsManagerScript::SaveBackupValues) + .def("SetCurrentValues", &CUIOptionsManagerScript::SetCurrentValues) + .def("SaveValues", &CUIOptionsManagerScript::SaveValues) + .def("UndoGroup", &CUIOptionsManagerScript::UndoGroup) + .def("OptionsPostAccept", &CUIOptionsManagerScript::OptionsPostAccept) + .def("SendMessage2Group", &CUIOptionsManagerScript::SendMessage2Group) + .def("NeedSystemRestart", &CUIOptionsManagerScript::NeedSystemRestart) + .def("NeedVidRestart", &CUIOptionsManagerScript::NeedVidRestart) + ]; +} diff --git a/src/xrUICore/ui_focus.h b/src/xrUICore/ui_focus.h index 6268500a81d..f62685a0c2c 100644 --- a/src/xrUICore/ui_focus.h +++ b/src/xrUICore/ui_focus.h @@ -71,4 +71,7 @@ class XRUICORE_API CUIFocusSystem : public CUIDebuggable void FillDebugInfo() override; void DrawDebugInfo(const CUIWindow& from, const CUIWindow& to, u32 color, u32 textColor) const; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; diff --git a/src/xrUICore/ui_styles.cpp b/src/xrUICore/ui_styles.cpp index 94d1ca4b342..f10e93c00cb 100644 --- a/src/xrUICore/ui_styles.cpp +++ b/src/xrUICore/ui_styles.cpp @@ -86,19 +86,7 @@ void UIStyleManager::SetupStyle(u32 styleID) void UIStyleManager::Reset() { - // Hack: activate main menu to prevent crash - // I don't know why it crashes while in the game - bool shouldHideMainMenu = false; - if (g_pGamePersistent && g_pGamePersistent->m_pMainMenu) - { - shouldHideMainMenu = !g_pGamePersistent->m_pMainMenu->IsActive(); - g_pGamePersistent->m_pMainMenu->Activate(true); - } - Device.seqUIReset.Process(); - - if (shouldHideMainMenu) - g_pGamePersistent->m_pMainMenu->Activate(false); } bool UIStyleManager::SetStyle(pcstr name, bool reloadUI) diff --git a/src/xrUICore/ui_styles.h b/src/xrUICore/ui_styles.h index 76a0338b9d6..fd19933c9fd 100644 --- a/src/xrUICore/ui_styles.h +++ b/src/xrUICore/ui_styles.h @@ -37,6 +37,9 @@ class XRUICORE_API UIStyleManager : Noncopyable private: xr_vector m_token; u32 m_style_id{ DEFAULT_STYLE_ID }; + +private: + DECLARE_SCRIPT_REGISTER_FUNCTION(); }; XRUICORE_API extern UIStyleManager* UIStyles; diff --git a/src/xrUICore/uiabstract.h b/src/xrUICore/uiabstract.h index e592d692d7a..ed467082380 100644 --- a/src/xrUICore/uiabstract.h +++ b/src/xrUICore/uiabstract.h @@ -38,93 +38,6 @@ enum EWindowAlignment : u8 waCenter = 1 << 4, }; -class CUISimpleWindow : public Noncopyable -{ -public: - virtual void SetWndPos(const Fvector2& pos) { m_wndPos.set(pos.x, pos.y); } - IC const Fvector2& GetWndPos() const { return m_wndPos; } - - Fvector2 GetWndCenterPos() const - { - return { m_wndPos.x + m_wndSize.x / 2.0f, m_wndPos.y + m_wndSize.y / 2.0f, }; - } - - virtual void SetWndSize(const Fvector2& size) { m_wndSize = size; } - IC const Fvector2& GetWndSize() const { return m_wndSize; } - - virtual void SetWndRect(const Frect& rect) - { - m_wndPos.set(rect.lt); - rect.getsize(m_wndSize); - } - - virtual void SetHeight(float height) { m_wndSize.y = height; } - IC float GetHeight() const { return m_wndSize.y; } - virtual void SetWidth(float width) { m_wndSize.x = width; } - IC float GetWidth() const { return m_wndSize.x; } - - IC void SetVisible(bool vis) { m_bShowMe = vis; } - IC bool GetVisible() const { return m_bShowMe; } - IC void SetAlignment(EWindowAlignment al) { m_alignment = al; } - IC EWindowAlignment GetAlignment() const { return m_alignment; } - IC Frect GetWndRect() const - { - Frect r; - GetWndRect(r); - return r; - } - IC void GetWndRect(Frect& res) const - { - const float width = (float)Device.dwWidth * (UI_BASE_WIDTH / (float)Device.dwWidth); - const float height = (float)Device.dwHeight * (UI_BASE_HEIGHT / (float)Device.dwHeight); - - switch (m_alignment) - { - case waNone: - case waLeft: - { - res.set(m_wndPos.x, m_wndPos.y, m_wndPos.x + m_wndSize.x, m_wndPos.y + m_wndSize.y); - break; - } - case waCenter: - { - float half_w = m_wndSize.x / 2.0f; - float half_h = m_wndSize.y / 2.0f; - res.set(m_wndPos.x - half_w, m_wndPos.y - half_h, m_wndPos.x + half_w, m_wndPos.y + half_h); - break; - } - case waRight: - { - res.set(width - m_wndSize.x, m_wndPos.y, width, m_wndPos.y + m_wndSize.y); - break; - } - case waTop: - { - res.set(m_wndPos.x, 0.f, m_wndPos.x + m_wndSize.x, m_wndSize.y); - break; - } - case waBottom: - res.set(m_wndPos.x, height - m_wndSize.y, m_wndPos.x + m_wndSize.x, height); - break; - default: NODEFAULT; - } - } - - void MoveWndDelta(float dx, float dy) - { - m_wndPos.x += dx; - m_wndPos.y += dy; - } - - void MoveWndDelta(const Fvector2& d) { MoveWndDelta(d.x, d.y); } - -protected: - bool m_bShowMe{}; - EWindowAlignment m_alignment{}; - Fvector2 m_wndPos{}; - Fvector2 m_wndSize{}; -}; - class CUISelectable { protected: diff --git a/src/xrUICore/xrUICore.vcxproj b/src/xrUICore/xrUICore.vcxproj index d3b3cb07737..0b9e9b29c63 100644 --- a/src/xrUICore/xrUICore.vcxproj +++ b/src/xrUICore/xrUICore.vcxproj @@ -86,7 +86,6 @@ - @@ -126,17 +125,14 @@ - - - @@ -146,25 +142,19 @@ - - - - Create - - @@ -176,12 +166,11 @@ - - + @@ -189,7 +178,6 @@ - diff --git a/src/xrUICore/xrUICore.vcxproj.filters b/src/xrUICore/xrUICore.vcxproj.filters index 46a5f99c9ab..75b334576b2 100644 --- a/src/xrUICore/xrUICore.vcxproj.filters +++ b/src/xrUICore/xrUICore.vcxproj.filters @@ -93,9 +93,6 @@ Static - - Static - Static @@ -120,9 +117,6 @@ Buttons - - Buttons - Buttons @@ -132,9 +126,6 @@ ComboBox - - ComboBox - Options @@ -148,9 +139,6 @@ EditBox - - EditBox - EditBox @@ -172,9 +160,6 @@ ListBox - - ListBox - ListBox @@ -187,27 +172,18 @@ ProgressBar - - ProgressBar - ProgressBar PropertiesBox - - PropertiesBox - Callbacks MessageBox - - MessageBox - ScrollBar @@ -235,9 +211,6 @@ TabControl - - TabControl - TrackBar @@ -253,21 +226,12 @@ FontManager - - Windows - - - Options - ListWnd ListWnd - - ListWnd - ListWnd @@ -277,6 +241,7 @@ + @@ -436,9 +401,6 @@ FontManager - - Options - ListWnd diff --git a/src/xr_3da/CMakeLists.txt b/src/xr_3da/CMakeLists.txt index 8bef29ac1a6..4ff7d1158a7 100644 --- a/src/xr_3da/CMakeLists.txt +++ b/src/xr_3da/CMakeLists.txt @@ -3,6 +3,14 @@ add_executable(xr_3da) target_sources(xr_3da PRIVATE entry_point.cpp stdafx.h + + resource.h + resource.rc + + splash_oxr.bmp + stalker_cop.ico + stalker_cs.ico + stalker_soc.ico ) set_property( diff --git a/src/xr_3da/packages.config b/src/xr_3da/packages.config new file mode 100644 index 00000000000..1d5b5ec9817 --- /dev/null +++ b/src/xr_3da/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/xr_3da/xr_3da.vcxproj b/src/xr_3da/xr_3da.vcxproj index 01746a3e715..08f017ce890 100644 --- a/src/xr_3da/xr_3da.vcxproj +++ b/src/xr_3da/xr_3da.vcxproj @@ -13,6 +13,9 @@ + + x64 + Application @@ -38,6 +41,7 @@ $(OutDir)$(ProjectName).pdb $(xrLibDir)xr_3da.lib + as-invoker-manifest-part.xml %(AdditionalManifestFiles) @@ -83,16 +87,55 @@ - + + Document + + + Document + + + Document + + + Document + + + Document + + + Document + + Document Document + + Document + + + Document + + + + - + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/src/xr_3da/xr_3da.vcxproj.filters b/src/xr_3da/xr_3da.vcxproj.filters index c4460eb5286..75d3e20484f 100644 --- a/src/xr_3da/xr_3da.vcxproj.filters +++ b/src/xr_3da/xr_3da.vcxproj.filters @@ -14,7 +14,7 @@ {ff5edb3a-265f-46de-b360-f24cfd97703c} - + {6865aa32-039a-4a25-89fd-e1f88c548a3a} @@ -41,11 +41,38 @@ - - Dependecies + + dependencies + + + dependencies + + + dependencies + + + dependencies + + + dependencies + + + dependencies + + + dependencies - Dependecies + dependencies + + + dependencies + + + dependencies + + + \ No newline at end of file diff --git a/src/xray_build.props b/src/xray_build.props index eb850dc537b..dfe32ccbf3c 100644 --- a/src/xray_build.props +++ b/src/xray_build.props @@ -16,12 +16,8 @@ 4458 : declaration of 'x' hides class member --> 4201;4251;4275;4458 - + - LUABIND_DYNAMIC_LINK; MSVC; dSINGLE; WIN32; @@ -46,6 +42,16 @@ + + + + + LUABIND_DYNAMIC_LINK; + %(PreprocessorDefinitions) + + + + true @@ -119,6 +125,7 @@ false + XRAY_STATIC_BUILD; MASTER_GOLD; _HAS_EXCEPTIONS=0; LUABIND_NO_EXCEPTIONS; diff --git a/src/xray_project_configuration.props b/src/xray_project_configuration.props index b6e8ad594cb..f0a303e158f 100644 --- a/src/xray_project_configuration.props +++ b/src/xray_project_configuration.props @@ -2,6 +2,7 @@ DynamicLibrary + StaticLibrary MultiByte true