From c426103f2374db0f8421db81ba827028248019e5 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sat, 28 Sep 2019 16:03:55 -0500 Subject: [PATCH] Extension changes for Medical Rewrite and Linux compilation (#6909) * Fix Medical HandleDamageWounds memory leak (#6809) * Use strncpy and disable MSVC unsafe warnings (#7171) * Set 64-bit correctly from generator string, Disable SSE2 flag on 64-bit (non-existent) * Tweaks for Linux extensions (#5762) * Tweak CMakeLists for Linux compilation * Conform SQF extensions check for Linux server extensions support * Add *.so to tools * Split extension check into Windows and Linux * Disable Medical extension loading for now * Add client/server separation to extension loading * Add Arma config documentation on extension creation --- Makefile | 2 +- addons/advanced_ballistics/config.cpp | 5 +- .../fnc_initializeTerrainExtension.sqf | 2 +- addons/common/config.cpp | 4 +- addons/common/functions/fnc_checkFiles.sqf | 55 ++++++++-------- addons/fcs/config.cpp | 5 +- addons/interact_menu/config.cpp | 9 ++- addons/medical_damage/config.cpp | 4 +- .../functions/fnc_woundsHandler.sqf | 5 +- addons/optionsmenu/config.cpp | 5 +- docs/wiki/development/extension-guidelines.md | 33 ++++++++++ docs/wiki/user/information-center.md | 2 +- extensions/CMakeLists.txt | 30 ++++++--- .../AdvancedBallistics.cpp | 30 ++++----- extensions/break_line/ace_break_line.cpp | 4 +- extensions/clipboard/ace_clipboard.cpp | 6 +- extensions/common/shared.hpp | 8 ++- extensions/common/vector.hpp | 62 +++++++++---------- extensions/fcs/ace_fcs.cpp | 4 +- extensions/medical/handleDamage.cpp | 6 +- extensions/medical/medical.cpp | 4 +- .../parse_imagepath/ace_parse_imagepath.cpp | 4 +- tools/make.py | 4 +- 23 files changed, 178 insertions(+), 115 deletions(-) diff --git a/Makefile b/Makefile index 736994ecb4..f0b0810e3e 100644 --- a/Makefile +++ b/Makefile @@ -82,7 +82,7 @@ push: commit release: clean version commit @"$(MAKE)" $(MAKEFLAGS) signatures @echo " ZIP $(ZIP)_$(VERSION_S).zip" - @cp *.dll mod.cpp README.md docs/README_DE.md docs/README_PL.md AUTHORS.txt LICENSE logo_ace3_ca.paa meta.cpp $(BIN) + @cp *.dll *.so mod.cpp README.md docs/README_DE.md docs/README_PL.md AUTHORS.txt LICENSE logo_ace3_ca.paa meta.cpp $(BIN) @zip -qr $(ZIP)_$(VERSION_S).zip $(BIN) clean: diff --git a/addons/advanced_ballistics/config.cpp b/addons/advanced_ballistics/config.cpp index 488b812fc6..17647d0647 100644 --- a/addons/advanced_ballistics/config.cpp +++ b/addons/advanced_ballistics/config.cpp @@ -20,5 +20,8 @@ class CfgPatches { #include "ACE_Settings.hpp" class ACE_Extensions { - extensions[] += {"ace_advanced_ballistics"}; + class ace_advanced_ballistics { + windows = 1; + client = 1; + }; }; diff --git a/addons/advanced_ballistics/functions/fnc_initializeTerrainExtension.sqf b/addons/advanced_ballistics/functions/fnc_initializeTerrainExtension.sqf index 5c634cadff..8ff8052745 100644 --- a/addons/advanced_ballistics/functions/fnc_initializeTerrainExtension.sqf +++ b/addons/advanced_ballistics/functions/fnc_initializeTerrainExtension.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: Ruthberg - * Initializes the advanced ballistics dll extension with terrain data + * Initializes the advanced ballistics extension with terrain data * * Arguments: * None diff --git a/addons/common/config.cpp b/addons/common/config.cpp index cde1cea68f..557b45b732 100644 --- a/addons/common/config.cpp +++ b/addons/common/config.cpp @@ -67,9 +67,7 @@ class ACE_Rsc_Control_Base { #include "CompassControl.hpp" #include "CfgUIGrids.hpp" -class ACE_Extensions { - extensions[] = {}; -}; +class ACE_Extensions {}; class ACE_Tests { vehicleTransportInventory = QPATHTOF(dev\test_vehicleInventory.sqf); diff --git a/addons/common/functions/fnc_checkFiles.sqf b/addons/common/functions/fnc_checkFiles.sqf index dee144c40e..3d5adc101c 100644 --- a/addons/common/functions/fnc_checkFiles.sqf +++ b/addons/common/functions/fnc_checkFiles.sqf @@ -67,38 +67,43 @@ if (!(_oldCompats isEqualTo [])) then { }; /////////////// -// check dlls +// check extensions /////////////// -if (toLower (productVersion select 6) in ["linux", "osx"]) then { - INFO("Operating system does not support DLL file format"); +private _platform = toLower (productVersion select 6); +if (!isServer && {_platform in ["linux", "osx"]}) then { + // Linux and OSX client ports do not support extensions at all + INFO("Operating system does not support extensions"); } else { { - private _versionEx = _x callExtension "version"; + private _extension = configName _x; + private _isWindows = _platform == "windows" && {getNumber (_x >> "windows") == 1}; + private _isLinux = _platform == "linux" && {getNumber (_x >> "linux") == 1}; + private _isClient = hasInterface && {getNumber (_x >> "client") == 1}; + private _isServer = !hasInterface && {getNumber (_x >> "server") == 1}; - if (_versionEx == "") then { - private _extension = ".dll"; + if ((_isWindows || _isLinux) && {_isClient || _isServer}) then { + private _versionEx = _extension callExtension "version"; + if (_versionEx == "") then { + private _extensionFile = _extension; + if (productVersion select 7 == "x64") then { + _extensionFile = format ["%1_x64", _extensionFile]; + }; - if (productVersion select 7 == "x64") then { - _extension = "_x64.dll"; + private _platformExt = [".dll", ".so"] select (_platform == "linux"); + _extensionFile = format ["%1%2", _extensionFile, _platformExt]; + + private _errorMsg = format ["Extension %1 not found.", _extensionFile]; + ERROR(_errorMsg); + + if (hasInterface) then { + ["[ACE] ERROR", _errorMsg, {findDisplay 46 closeDisplay 0}] call FUNC(errorMessage); + }; + } else { + // Print the current extension version + INFO_2("Extension version: %1: %2",_extension,_versionEx); }; - - if (productVersion select 6 == "Linux") then { - _extension = ".so"; - }; - - private _errorMsg = format ["Extension %1%2 not found.", _x, _extension]; - - ERROR(_errorMsg); - - if (hasInterface) then { - ["[ACE] ERROR", _errorMsg, {findDisplay 46 closeDisplay 0}] call FUNC(errorMessage); - }; - } else { - // Print the current extension version - INFO_2("Extension version: %1: %2",_x,_versionEx); }; - false - } count getArray (configFile >> "ACE_Extensions" >> "extensions"); + } forEach ("true" configClasses (configFile >> "ACE_Extensions")); }; /////////////// diff --git a/addons/fcs/config.cpp b/addons/fcs/config.cpp index df849ec346..88e803d0ca 100644 --- a/addons/fcs/config.cpp +++ b/addons/fcs/config.cpp @@ -28,7 +28,10 @@ class CfgPatches { #include "CfgOptics.hpp" class ACE_Extensions { - extensions[] += {"ace_fcs"}; + class ace_fcs { + windows = 1; + client = 1; + }; }; class ACE_Tests { diff --git a/addons/interact_menu/config.cpp b/addons/interact_menu/config.cpp index 687d644924..ff29cfc850 100644 --- a/addons/interact_menu/config.cpp +++ b/addons/interact_menu/config.cpp @@ -23,5 +23,12 @@ class CfgPatches { #include "ACE_Settings.hpp" class ACE_Extensions { - extensions[] += {"ace_break_line", "ace_parse_imagepath"}; + class ace_break_line { + windows = 1; + client = 1; + }; + class ace_parse_imagepath { + windows = 1; + client = 1; + }; }; diff --git a/addons/medical_damage/config.cpp b/addons/medical_damage/config.cpp index 5e420a173e..bd0bcf9fd3 100644 --- a/addons/medical_damage/config.cpp +++ b/addons/medical_damage/config.cpp @@ -19,5 +19,7 @@ class CfgPatches { #include "CfgEventHandlers.hpp" class ACE_Extensions { - extensions[] += {"ace_medical"}; + class ace_medical { + // Not yet used + }; }; diff --git a/addons/medical_damage/functions/fnc_woundsHandler.sqf b/addons/medical_damage/functions/fnc_woundsHandler.sqf index 630f387fa5..049437fdf5 100644 --- a/addons/medical_damage/functions/fnc_woundsHandler.sqf +++ b/addons/medical_damage/functions/fnc_woundsHandler.sqf @@ -40,10 +40,7 @@ private _extensionOutput = "ace_medical" callExtension format ["HandleDamageWoun TRACE_1("",_extensionOutput); // these are default values and modified by _extensionOutput -private _painToAdd = 0; -private _woundsCreated = []; - -call compile _extensionOutput; +(parseSimpleArray _extensionOutput) params ["_woundsCreated", "_painToAdd"]; // todo: Make the pain and bleeding calculations part of the extension again private _woundDamage = _damage / ((count _woundsCreated) max 1); // If the damage creates multiple wounds diff --git a/addons/optionsmenu/config.cpp b/addons/optionsmenu/config.cpp index b17fe12cc3..5661753579 100644 --- a/addons/optionsmenu/config.cpp +++ b/addons/optionsmenu/config.cpp @@ -30,7 +30,10 @@ class CfgAddons { #include "gui\pauseMenu.hpp" class ACE_Extensions { - extensions[] += {"ace_clipboard"}; + class ace_clipboard { + windows = 1; + client = 1; + }; }; class CfgCommands { diff --git a/docs/wiki/development/extension-guidelines.md b/docs/wiki/development/extension-guidelines.md index f4dc6e40bd..d7f4fe08a6 100644 --- a/docs/wiki/development/extension-guidelines.md +++ b/docs/wiki/development/extension-guidelines.md @@ -58,3 +58,36 @@ extensions\ ``` ### 2.2 Creating a new Extension + +#### 2.2.1 Arma Config + +ACE3 loads extensions defined in `ACE_Extensions` root config class and supports the following entries: + +```cpp +// Platform +windows = 1; // Load on Windows +linux = 1; // Load on Linux + +// Type +client = 1; // Load on Client +server = 1; // Load on Server +``` + +```cpp +class ACE_Extensions { + // Windows Client only extension + class tag_extension { + windows = 1; + client = 1; + }; + + // Any platform Server extension + class tag_extension2 { + windows = 1; + linux = 1; + server = 1; + }; +}; +``` + +Combining platform and client/server values is possible to get all combinations currently supported by the game and more. diff --git a/docs/wiki/user/information-center.md b/docs/wiki/user/information-center.md index fa6077ee3e..8f828c6980 100644 --- a/docs/wiki/user/information-center.md +++ b/docs/wiki/user/information-center.md @@ -30,7 +30,7 @@ Downloaded ACE3 and have no idea where to start? This page serves as a starting ### 1.2 Issues -**Q:** Experiencing DLL errors. +**Q:** Experiencing extension errors. **A:** Start the game once with the Arma 3 Launcher, close it, then start the game with your usual launcher (ArmA3Sync, Play withSix, etc …). >The simple explanation is that the BattlEye process wasn't ended properly and is unable to start again properly, launching it with the Arma 3 Launcher is the only known solution to fix it. diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index ef6d8f8ded..0ac2fa5061 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -8,8 +8,8 @@ add_definitions(/DWINVER=0x0600 /D_WIN32_WINNT=0x0600) endif() if (NOT CMAKE_BUILD_TYPE AND CMAKE_COMPILER_IS_GNUCXX) - message(STATUS "No build type selected, default to Debug") - set(CMAKE_BUILD_TYPE "Debug") + message(STATUS "No build type selected, default to Debug") + set(CMAKE_BUILD_TYPE "Debug") endif() option(DEVEL "DEVEL" OFF) @@ -18,19 +18,29 @@ option(USE_DIRECTX "USE_DIRECTX" OFF) option(USE_64BIT_BUILD "USE_64BIT_BUILD" OFF) option(USE_STATIC_LINKING "USE_STATIC_LINKING" ON) +if(CMAKE_GENERATOR_PLATFORM MATCHES "x64") + set(USE_64BIT_BUILD ON) +endif() if(CMAKE_COMPILER_IS_GNUCXX) - SET(CMAKE_CXX_FLAGS "-std=c++11 -pedantic -pedantic-errors -march=i686 -m32 -O2 -s -fPIC -fpermissive") - set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") - set(CMAKE_SHARED_LINKER_FLAGS "-static-libgcc -static-libstdc++") + SET(CMAKE_CXX_FLAGS "-std=c++11 -pedantic -pedantic-errors -march=i686 -m32 -O2 -s -fPIC -fpermissive") + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") + set(CMAKE_SHARED_LINKER_FLAGS "-static-libgcc -static-libstdc++") elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") message(ERROR "SUPPORT NOT COMPLETE") elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /arch:SSE2 /Qpar-report:2") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} /D _DEBUG /MTd /Zi /Ob0 /Od /RTC1") - set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} /MT /O1 /Ob1 /D NDEBUG") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} /MT /O2 /Ob2 /D NDEBUG") - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} /MT /Zi /O2 /Ob1 /D NDEBUG") + add_definitions(-D_CRT_SECURE_NO_WARNINGS) # Disable MSVC *_s function warnings + + if(USE_64BIT_BUILD) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /Qpar-report:2") # Default SSE2 + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /arch:SSE2 /Qpar-report:2") + endif() + + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} /D _DEBUG /MTd /Zi /Ob0 /Od /RTC1") + set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} /MT /O1 /Ob1 /D NDEBUG") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} /MT /O2 /Ob2 /D NDEBUG") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} /MT /Zi /O2 /Ob1 /D NDEBUG") endif() include_directories("common") diff --git a/extensions/advanced_ballistics/AdvancedBallistics.cpp b/extensions/advanced_ballistics/AdvancedBallistics.cpp index b77c412b35..6ea8d1fdea 100644 --- a/extensions/advanced_ballistics/AdvancedBallistics.cpp +++ b/extensions/advanced_ballistics/AdvancedBallistics.cpp @@ -254,7 +254,7 @@ double calculateAdvancedZero(double zeroRange, double muzzleVelocity, double bor double v = 0.0f; while (tof < 8.0f && px < zeroRange) { - lx = px; + lx = px; ly = py; v = std::sqrt(vx*vx + vy*vy); @@ -295,7 +295,7 @@ extern "C" void __stdcall RVExtensionVersion(char *output, int outputSize) { - strncpy_s(output, outputSize, ACE_FULL_VERSION_STR, _TRUNCATE); + strncpy(output, ACE_FULL_VERSION_STR, outputSize); } void __stdcall RVExtension(char *output, int outputSize, const char *function) @@ -303,7 +303,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) ZERO_OUTPUT(); std::stringstream outputStr; if (!strcmp(function, "version")) { - strncpy_s(output, outputSize, ACE_FULL_VERSION_STR, _TRUNCATE); + strncpy(output, ACE_FULL_VERSION_STR, outputSize); EXTENSION_RETURN(); } @@ -328,7 +328,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) // int n = sprintf(output, "%f", retard); outputStr << retard; - strncpy_s(output, outputSize, outputStr.str().c_str(), _TRUNCATE); + strncpy(output, outputStr.str().c_str(), outputSize); EXTENSION_RETURN(); } else if (!strcmp(mode, "atmosphericCorrection")) { @@ -347,7 +347,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) ballisticCoefficient = calculateAtmosphericCorrection(ballisticCoefficient, temperature, pressure, humidity, atmosphereModel); //int n = sprintf(output, "%f", ballisticCoefficient); outputStr << ballisticCoefficient; - strncpy_s(output, outputSize, outputStr.str().c_str(), _TRUNCATE); + strncpy(output, outputStr.str().c_str(), outputSize); EXTENSION_RETURN(); } else if (!strcmp(mode, "new")) { unsigned int index = 0; @@ -453,7 +453,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) bulletDatabase[index].randGenerator.seed(bulletDatabase[index].randSeed); } - strncpy_s(output, outputSize, "", _TRUNCATE); + strncpy(output, "", outputSize); EXTENSION_RETURN(); } else if (!strcmp(mode, "simulate")) { // simulate:0:[-0.109985,542.529,-3.98301]:[3751.57,5332.23,214.252]:[0.598153,2.38829,0]:28.6:0:0.481542:0:215.16 @@ -567,7 +567,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) ace::vector3 offset(distribution(bulletDatabase[index].randGenerator), distribution(bulletDatabase[index].randGenerator), distribution(bulletDatabase[index].randGenerator)); double coef = 1.0f - bulletDatabase[index].transonicStabilityCoef; - double trueSpeed = trueVelocity.magnitude(); + double trueSpeed = trueVelocity.magnitude(); trueVelocity += offset * coef; trueVelocity = trueVelocity.normalize() * trueSpeed; }; @@ -622,7 +622,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) bulletDatabase[index].bulletVelocityPreviousFrame = bulletVelocityCurrentFrame + velocityOffset; outputStr << "[" << velocityOffset.x() << "," << velocityOffset.y() << "," << velocityOffset.z() << "]"; - strncpy_s(output, outputSize, outputStr.str().c_str(), _TRUNCATE); + strncpy(output, outputStr.str().c_str(), outputSize); EXTENSION_RETURN(); } else if (!strcmp(mode, "set")) { int height = 0; @@ -637,7 +637,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) map->gridBuildingNums.push_back(numObjects); map->gridSurfaceIsWater.push_back(surfaceIsWater); - strncpy_s(output, outputSize, outputStr.str().c_str(), _TRUNCATE); + strncpy(output, outputStr.str().c_str(), outputSize); EXTENSION_RETURN(); } else if (!strcmp(mode, "init")) { int mapSize = 0; @@ -653,7 +653,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) map = &mapDatabase[worldName]; if (map->gridHeights.size() == gridCells) { outputStr << "Terrain already initialized"; - strncpy_s(output, outputSize, outputStr.str().c_str(), _TRUNCATE); + strncpy(output, outputStr.str().c_str(), outputSize); EXTENSION_RETURN(); } @@ -666,7 +666,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) map->gridBuildingNums.reserve(gridCells); map->gridSurfaceIsWater.reserve(gridCells); - strncpy_s(output, outputSize, outputStr.str().c_str(), _TRUNCATE); + strncpy(output, outputStr.str().c_str(), outputSize); EXTENSION_RETURN(); } else if (!strcmp(mode, "replicateVanillaZero")) { float zeroRange = strtof(strtok_s(NULL, ":", &next_token), NULL); @@ -676,7 +676,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) float zeroAngle = replicateVanillaZero(zeroRange, initSpeed, airFriction); outputStr << DEGREES(zeroAngle); - strncpy_s(output, outputSize, outputStr.str().c_str(), _TRUNCATE); + strncpy(output, outputStr.str().c_str(), outputSize); EXTENSION_RETURN(); } else if (!strcmp(mode, "calcZero")) { double zeroRange = strtod(strtok_s(NULL, ":", &next_token), NULL); @@ -687,7 +687,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) double zeroAngle = calculateVanillaZero(zeroRange, initSpeed, airFriction, boreHeight); outputStr << DEGREES(zeroAngle); - strncpy_s(output, outputSize, outputStr.str().c_str(), _TRUNCATE); + strncpy(output, outputStr.str().c_str(), outputSize); EXTENSION_RETURN(); } else if (!strcmp(mode, "calcZeroAB")) { double zeroRange = strtod(strtok_s(NULL, ":", &next_token), NULL); @@ -703,9 +703,9 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) double zeroAngle = calculateAdvancedZero(zeroRange, muzzleVelocity, boreHeight, temperature, pressure, humidity, ballisticCoefficient, dragModel, atmosphereModel); outputStr << DEGREES(zeroAngle); - strncpy_s(output, outputSize, outputStr.str().c_str(), _TRUNCATE); + strncpy(output, outputStr.str().c_str(), outputSize); EXTENSION_RETURN(); } - strncpy_s(output, outputSize, outputStr.str().c_str(), _TRUNCATE); + strncpy(output, outputStr.str().c_str(), outputSize); EXTENSION_RETURN(); } diff --git a/extensions/break_line/ace_break_line.cpp b/extensions/break_line/ace_break_line.cpp index c408ceab5c..1ac9b9009d 100644 --- a/extensions/break_line/ace_break_line.cpp +++ b/extensions/break_line/ace_break_line.cpp @@ -64,9 +64,9 @@ std::string addLineBreaks(const std::vector &words) { void __stdcall RVExtension(char *output, int outputSize, const char *function) { ZERO_OUTPUT(); if (!strcmp(function, "version")) { - strncpy_s(output, outputSize, ACE_FULL_VERSION_STR, _TRUNCATE); + strncpy(output, ACE_FULL_VERSION_STR, outputSize); } else { - strncpy_s(output, outputSize, addLineBreaks(splitString(function)).c_str(), _TRUNCATE); + strncpy(output, addLineBreaks(splitString(function)).c_str(), outputSize); } EXTENSION_RETURN(); } diff --git a/extensions/clipboard/ace_clipboard.cpp b/extensions/clipboard/ace_clipboard.cpp index 0b3d965ad5..9b5cf09d55 100644 --- a/extensions/clipboard/ace_clipboard.cpp +++ b/extensions/clipboard/ace_clipboard.cpp @@ -33,7 +33,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) { } if (!strcmp(function, "version")) { - strncpy_s(output, outputSize, ACE_FULL_VERSION_STR, _TRUNCATE); + std::strncpy(output, ACE_FULL_VERSION_STR, outputSize); EXTENSION_RETURN(); } @@ -53,7 +53,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) { result = "GlobalAlloc() failed, GetLastError=" + GetLastError(); EXTENSION_RETURN(); } - strncpy_s(pClipboardData, gClipboardData.length(), gClipboardData.c_str(), _TRUNCATE); + strncpy(pClipboardData, gClipboardData.c_str(), gClipboardData.length()); // if success, system owns the memory, if fail, free it from the heap if (SetClipboardData(CF_TEXT, pClipboardData) == NULL) { @@ -72,7 +72,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) { } if (result.length() > 1) { - strncpy_s(output, outputSize, result.c_str(), _TRUNCATE); + strncpy(output, result.c_str(), outputSize); } #endif diff --git a/extensions/common/shared.hpp b/extensions/common/shared.hpp index a3cf1d154f..c7c8c61403 100644 --- a/extensions/common/shared.hpp +++ b/extensions/common/shared.hpp @@ -20,6 +20,8 @@ #include "ace_version.hpp" #include #include //std::isspace +#include +#include #ifdef _DEBUG #define ZERO_OUTPUT() { memset(output, 0x00, outputSize); } @@ -73,7 +75,7 @@ namespace ace { struct exception { exception(const uint32_t code_, const std::string & text_) : code(code_), text(text_) {} - + exception & operator= (const exception& other) { code = other.code; text = other.text; return *this; } bool operator == (const exception &r) const { return ( code == r.code ); } @@ -83,11 +85,11 @@ namespace ace { } #ifndef _WIN32 -#define __stdcall +#define __stdcall #endif #if defined(_MSC_VER) - // Microsoft + // Microsoft #define EXPORT __declspec(dllexport) #define IMPORT __declspec(dllimport) #elif defined(_GCC) diff --git a/extensions/common/vector.hpp b/extensions/common/vector.hpp index 4830e18ba5..101ee0746d 100644 --- a/extensions/common/vector.hpp +++ b/extensions/common/vector.hpp @@ -25,12 +25,12 @@ namespace ace { template class vector3 { public: - constexpr vector3() : + vector3() : _x(0), _y(0), _z(0) { } - constexpr vector3(const T x_, const T y_, const T z_) noexcept : + vector3(const T x_, const T y_, const T z_) : _x(x_), _y(y_), _z(z_) { @@ -47,7 +47,7 @@ namespace ace { _z = buffer[2]; } - constexpr vector3& operator= (const vector3& other) noexcept { _x = other.x(); _y = other.y(); _z = other.z(); return *this; } + vector3& operator= (const vector3& other) { _x = other.x(); _y = other.y(); _z = other.z(); return *this; } /*#ifdef _WIN32 && _DIRECTX vector3 & operator= (const XMFLOAT3& Float3) { _x = Float3.x; _y = Float3.y; _z = Float3.z; return *this; } #endif @@ -56,38 +56,38 @@ namespace ace { vector3 & operator= (const btVector3& bt_vec) { _x = bt_vec.x(); _y = bt_vec.y(); _z = bt_vec.z(); return *this; } #endif */ - constexpr vector3 operator * (const T& val) const { return vector3(_x * val, _y * val, _z * val); } - constexpr vector3 operator / (const T& val) const { T invVal = T(1) / val; return vector3(_x * invVal, _y * invVal, _z * invVal); } - constexpr vector3 operator + (const vector3& v) const { return vector3(_x + v.x(), _y + v.y(), _z + v.z()); } - constexpr vector3 operator / (const vector3& v) const { return vector3(_x / v.x(), _y / v.y(), _z / v.z()); } - constexpr vector3 operator * (const vector3& v) const { return vector3(_x * v.x(), _y * v.y(), _z * v.z()); } - constexpr vector3 operator - (const vector3& v) const { return vector3(_x - v.x(), _y - v.y(), _z - v.z()); } - constexpr vector3 operator - () const { return vector3(-_x, -_y, -_z); } + vector3 operator * (const T& val) const { return vector3(_x * val, _y * val, _z * val); } + vector3 operator / (const T& val) const { T invVal = T(1) / val; return vector3(_x * invVal, _y * invVal, _z * invVal); } + vector3 operator + (const vector3& v) const { return vector3(_x + v.x(), _y + v.y(), _z + v.z()); } + vector3 operator / (const vector3& v) const { return vector3(_x / v.x(), _y / v.y(), _z / v.z()); } + vector3 operator * (const vector3& v) const { return vector3(_x * v.x(), _y * v.y(), _z * v.z()); } + vector3 operator - (const vector3& v) const { return vector3(_x - v.x(), _y - v.y(), _z - v.z()); } + vector3 operator - () const { return vector3(-_x, -_y, -_z); } - constexpr vector3& operator *=(const vector3& v) noexcept { _x *= v._x; _y *= v._y; _z *= v._z; return *this; } - constexpr vector3& operator *=(T mag) noexcept { _x *= mag; _y *= mag; _z *= mag; return *this; } - constexpr vector3& operator /=(const vector3& v) noexcept { _x /= v._x; _y /= v._y; _z /= v._z; return *this; } - constexpr vector3& operator /=(T mag) noexcept { _x /= mag; _y /= mag; _y /= mag; return *this; } - constexpr vector3& operator +=(const vector3& v) noexcept { _x += v._x; _y += v._y; _z += v._z; return *this; } - constexpr vector3& operator -=(const vector3& v) noexcept { _x -= v._x; _y -= v._y; _z -= v._z; return *this; } + vector3& operator *=(const vector3& v) { _x *= v._x; _y *= v._y; _z *= v._z; return *this; } + vector3& operator *=(T mag) { _x *= mag; _y *= mag; _z *= mag; return *this; } + vector3& operator /=(const vector3& v) { _x /= v._x; _y /= v._y; _z /= v._z; return *this; } + vector3& operator /=(T mag) { _x /= mag; _y /= mag; _y /= mag; return *this; } + vector3& operator +=(const vector3& v) { _x += v._x; _y += v._y; _z += v._z; return *this; } + vector3& operator -=(const vector3& v) { _x -= v._x; _y -= v._y; _z -= v._z; return *this; } - bool operator == (const vector3 &r) const noexcept { return (_x == r.x() && _y == r.y() && _z == r.z()); } + bool operator == (const vector3 &r) const { return (_x == r.x() && _y == r.y() && _z == r.z()); } - constexpr T magnitude() const noexcept { return sqrt(_x * _x + _y * _y + _z * _z); } - constexpr T magnitude_squared() const noexcept { return _x * _x + _y * _y + _z * _z; } - constexpr T dot(const vector3& v) const noexcept { return (_x * v.x() + _y * v.y() + _z * v.z()); } - constexpr T distance(const vector3& v) const noexcept { vector3 dist = (*this - v); dist = dist * dist; return sqrt(dist.x() + dist.y() + dist.z()); } - constexpr vector3 cross(const vector3& v) const noexcept { return vector3(_y * v.z() - _z * v.y(), _z * v.x() - _x * v.z(), _x * v.y() - _y * v.x()); } - constexpr vector3 normalize() const noexcept { return (*this / abs(magnitude())); }; - constexpr bool zero_distance() const noexcept { return ((_x == 0.0f && _y == 0.0f && _z == 0.0f) ? true : false ); } + T magnitude() const { return sqrt(_x * _x + _y * _y + _z * _z); } + T magnitude_squared() const { return _x * _x + _y * _y + _z * _z; } + T dot(const vector3& v) const { return (_x * v.x() + _y * v.y() + _z * v.z()); } + T distance(const vector3& v) const { vector3 dist = (*this - v); dist = dist * dist; return sqrt(dist.x() + dist.y() + dist.z()); } + vector3 cross(const vector3& v) const { return vector3(_y * v.z() - _z * v.y(), _z * v.x() - _x * v.z(), _x * v.y() - _y * v.x()); } + vector3 normalize() const { return (*this / abs(magnitude())); }; + bool zero_distance() const { return ((_x == 0.0f && _y == 0.0f && _z == 0.0f) ? true : false ); } static float clamp(T x, T a, T b) { return x < a ? a : (x > b ? b : x); } - static vector3 lerp(const vector3& A, const vector3& B, const T t) noexcept { return A*t + B*(1.f - t); } - constexpr vector3 lerp(const vector3& B, const T t) const noexcept { return vector3::lerp(*this, B, t); } + static vector3 lerp(const vector3& A, const vector3& B, const T t) { return A*t + B*(1.f - t); } + vector3 lerp(const vector3& B, const T t) const { return vector3::lerp(*this, B, t); } - static vector3 slerp(vector3 start, vector3 end, T percent) noexcept { + static vector3 slerp(vector3 start, vector3 end, T percent) { T dot = start.dot(end); dot = vector3::clamp(dot, -1.0f, 1.0f); @@ -96,13 +96,13 @@ namespace ace { relative.normalize(); return ((start * cos(theta)) + (relative*sin(theta))); } - constexpr vector3 slerp(const vector3& B, const T p) const noexcept { + vector3 slerp(const vector3& B, const T p) const { return vector3::slerp(*this, B, p); } - const T& x() const noexcept { return _x; } - const T& y() const noexcept { return _y; } - const T& z() const noexcept { return _z; } + const T& x() const { return _x; } + const T& y() const { return _y; } + const T& z() const { return _z; } void x(const T val) { _x = val; } void y(const T val) { _y = val; } diff --git a/extensions/fcs/ace_fcs.cpp b/extensions/fcs/ace_fcs.cpp index 8ab57a1c77..1c00212c27 100644 --- a/extensions/fcs/ace_fcs.cpp +++ b/extensions/fcs/ace_fcs.cpp @@ -96,7 +96,7 @@ double getSolution(double initSpeed, double airFriction, double angleTarget, dou void __stdcall RVExtension(char *output, int outputSize, const char *function) { ZERO_OUTPUT(); if (!strcmp(function, "version")) { - strncpy_s(output, outputSize, ACE_FULL_VERSION_STR, _TRUNCATE); + strncpy(output, ACE_FULL_VERSION_STR, outputSize); } else { std::vector argStrings = splitString(function); double initSpeed = std::stod(argStrings[0]); @@ -109,7 +109,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) { std::stringstream sstream; sstream << result; - strncpy_s(output, outputSize, sstream.str().c_str(), _TRUNCATE); + strncpy(output, sstream.str().c_str(), outputSize); } EXTENSION_RETURN(); } diff --git a/extensions/medical/handleDamage.cpp b/extensions/medical/handleDamage.cpp index 001877a2cd..9b0e5e78ef 100644 --- a/extensions/medical/handleDamage.cpp +++ b/extensions/medical/handleDamage.cpp @@ -34,7 +34,7 @@ namespace ace { double painToAdd = 0; wounds = GetInjuryInfoFor(typeOfDamage, amountOfDamage, selectionN, woundID); - stream << "_woundsCreated = ["; + stream << "[["; for (int i = 0; i < wounds.size(); ++i) { stream << wounds.at(i).AsString(); @@ -45,9 +45,9 @@ namespace ace { painToAdd += wounds.at(i).pain; } - stream << "];"; + stream << "],"; - stream << "_painToAdd = " << painToAdd << ";"; + stream << painToAdd << "]"; return stream.str(); } diff --git a/extensions/medical/medical.cpp b/extensions/medical/medical.cpp index aca062e205..ef6c00fde9 100644 --- a/extensions/medical/medical.cpp +++ b/extensions/medical/medical.cpp @@ -33,7 +33,7 @@ std::vector parseExtensionInput(const std::string& input) void __stdcall RVExtension(char *output, int outputSize, const char *function) { if (!strcmp(function, "version")) { - strncpy_s(output, outputSize, ACE_FULL_VERSION_STR, _TRUNCATE); + strncpy(output, ACE_FULL_VERSION_STR, outputSize); } else { @@ -85,6 +85,6 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) { } } - strncpy_s(output, outputSize, returnValue.c_str(), _TRUNCATE); + strncpy(output, returnValue.c_str(), outputSize); } } diff --git a/extensions/parse_imagepath/ace_parse_imagepath.cpp b/extensions/parse_imagepath/ace_parse_imagepath.cpp index 110cb904cc..8f52a1e4bc 100644 --- a/extensions/parse_imagepath/ace_parse_imagepath.cpp +++ b/extensions/parse_imagepath/ace_parse_imagepath.cpp @@ -40,9 +40,9 @@ std::string getImagePathFromStructuredText(const std::string & input) { void __stdcall RVExtension(char *output, int outputSize, const char *function) { ZERO_OUTPUT(); if (!strcmp(function, "version")) { - strncpy_s(output, outputSize, ACE_FULL_VERSION_STR, _TRUNCATE); + strncpy(output, ACE_FULL_VERSION_STR, outputSize); } else { - strncpy_s(output, outputSize, getImagePathFromStructuredText(function).c_str(), _TRUNCATE); + strncpy(output, getImagePathFromStructuredText(function).c_str(), outputSize); } EXTENSION_RETURN(); } diff --git a/tools/make.py b/tools/make.py index 8e4509e162..ccb9d75d92 100644 --- a/tools/make.py +++ b/tools/make.py @@ -334,11 +334,11 @@ def copy_important_files(source_dir,destination_dir): print_error("COPYING IMPORTANT FILES.") raise - # Copy all extension DLL's + # Copy all extensions try: os.chdir(os.path.join(source_dir)) print_blue("\nSearching for DLLs in {}".format(os.getcwd())) - filenames = glob.glob("*.dll") + filenames = glob.glob("*.dll") + glob.glob("*.so") if not filenames: print ("Empty SET")