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
This commit is contained in:
PabstMirror 2019-09-28 16:03:55 -05:00 committed by jonpas
parent b8c45c0a57
commit c426103f23
23 changed files with 178 additions and 115 deletions

View File

@ -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:

View File

@ -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;
};
};

View File

@ -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

View File

@ -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);

View File

@ -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"));
};
///////////////

View File

@ -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 {

View File

@ -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;
};
};

View File

@ -19,5 +19,7 @@ class CfgPatches {
#include "CfgEventHandlers.hpp"
class ACE_Extensions {
extensions[] += {"ace_medical"};
class ace_medical {
// Not yet used
};
};

View File

@ -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

View File

@ -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 {

View File

@ -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.

View File

@ -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.

View File

@ -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")

View File

@ -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<double> 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();
}

View File

@ -64,9 +64,9 @@ std::string addLineBreaks(const std::vector<std::string> &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();
}

View File

@ -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

View File

@ -20,6 +20,8 @@
#include "ace_version.hpp"
#include <algorithm>
#include <cctype> //std::isspace
#include <cstring>
#include <istream>
#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)

View File

@ -25,12 +25,12 @@ namespace ace {
template<typename T>
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<T> & operator= (const XMFLOAT3& Float3) { _x = Float3.x; _y = Float3.y; _z = Float3.z; return *this; }
#endif
@ -56,38 +56,38 @@ namespace ace {
vector3<T> & 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; }

View File

@ -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<std::string> 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();
}

View File

@ -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();
}

View File

@ -33,7 +33,7 @@ std::vector<std::string> 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);
}
}

View File

@ -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();
}

View File

@ -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")