mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
commit
b16f444795
@ -88,6 +88,7 @@ Kllrt <kllrtik@gmail.com>
|
||||
legman <juicemelon@msn.com>
|
||||
Legolasindar "Viper" <legolasindar@gmail.com>
|
||||
licht-im-Norden87 <lichtimnorden87@gmail.com>
|
||||
looter <looter222@gmail.com>
|
||||
Macusercom <macusercom@gmail.com>
|
||||
MarcBook
|
||||
meat <p.humberdroz@gmail.com>
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "shared.hpp"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
@ -238,7 +239,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
|
||||
ZERO_OUTPUT();
|
||||
std::stringstream outputStr;
|
||||
if (!strcmp(function, "version")) {
|
||||
strncpy(output, ACE_FULL_VERSION_STR, outputSize);
|
||||
strncpy_s(output, outputSize, ACE_FULL_VERSION_STR, _TRUNCATE);
|
||||
EXTENSION_RETURN();
|
||||
}
|
||||
|
||||
@ -261,7 +262,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
|
||||
// int n = sprintf(output, "%f", retard);
|
||||
|
||||
outputStr << retard;
|
||||
strncpy(output, outputStr.str().c_str(), outputSize);
|
||||
strncpy_s(output, outputSize, outputStr.str().c_str(), _TRUNCATE);
|
||||
|
||||
EXTENSION_RETURN();
|
||||
} else if (!strcmp(mode, "atmosphericCorrection")) {
|
||||
@ -280,7 +281,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(output, outputStr.str().c_str(), outputSize);
|
||||
strncpy_s(output, outputSize, outputStr.str().c_str(), _TRUNCATE);
|
||||
EXTENSION_RETURN();
|
||||
} else if (!strcmp(mode, "new")) {
|
||||
unsigned int index = 0;
|
||||
@ -375,7 +376,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
|
||||
bulletDatabase[index].frames = 0.0;
|
||||
bulletDatabase[index].randSeed = 0;
|
||||
|
||||
strncpy(output, "", outputSize);
|
||||
strncpy_s(output, outputSize, "", _TRUNCATE);
|
||||
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
|
||||
@ -594,7 +595,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
|
||||
};
|
||||
|
||||
outputStr << "_bullet setVelocity (_bulletVelocity vectorAdd [" << velocityOffset[0] << "," << velocityOffset[1] << "," << velocityOffset[2] << "]); _bullet setPosASL (_bulletPosition vectorAdd [" << positionOffset[0] << "," << positionOffset[1] << "," << positionOffset[2] << "]);";
|
||||
strncpy(output, outputStr.str().c_str(), outputSize);
|
||||
strncpy_s(output, outputSize, outputStr.str().c_str(), _TRUNCATE);
|
||||
EXTENSION_RETURN();
|
||||
} else if (!strcmp(mode, "set")) {
|
||||
int height = 0;
|
||||
@ -609,7 +610,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
|
||||
map->gridBuildingNums.push_back(numObjects);
|
||||
map->gridSurfaceIsWater.push_back(surfaceIsWater);
|
||||
|
||||
strncpy(output, outputStr.str().c_str(), outputSize);
|
||||
strncpy_s(output, outputSize, outputStr.str().c_str(), _TRUNCATE);
|
||||
EXTENSION_RETURN();
|
||||
} else if (!strcmp(mode, "init")) {
|
||||
int mapSize = 0;
|
||||
@ -625,7 +626,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
|
||||
map = &mapDatabase[worldName];
|
||||
if (map->gridHeights.size() == gridCells) {
|
||||
outputStr << "Terrain already initialized";
|
||||
strncpy(output, outputStr.str().c_str(), outputSize);
|
||||
strncpy_s(output, outputSize, outputStr.str().c_str(), _TRUNCATE);
|
||||
EXTENSION_RETURN();
|
||||
}
|
||||
|
||||
@ -638,9 +639,9 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function)
|
||||
map->gridBuildingNums.reserve(gridCells);
|
||||
map->gridSurfaceIsWater.reserve(gridCells);
|
||||
|
||||
strncpy(output, outputStr.str().c_str(), outputSize);
|
||||
strncpy_s(output, outputSize, outputStr.str().c_str(), _TRUNCATE);
|
||||
EXTENSION_RETURN();
|
||||
}
|
||||
strncpy(output, outputStr.str().c_str(), outputSize);
|
||||
strncpy_s(output, outputSize, outputStr.str().c_str(), _TRUNCATE);
|
||||
EXTENSION_RETURN();
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include "shared.hpp"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
@ -60,19 +61,12 @@ std::string addLineBreaks(const std::vector<std::string> &words) {
|
||||
return sstream.str();
|
||||
}
|
||||
|
||||
// i like to live dangerously. jk, fix strncpy sometime pls.
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4996 )
|
||||
|
||||
void __stdcall RVExtension(char *output, int outputSize, const char *function) {
|
||||
ZERO_OUTPUT();
|
||||
if (!strcmp(function, "version")) {
|
||||
strncpy(output, ACE_FULL_VERSION_STR, outputSize);
|
||||
strncpy_s(output, outputSize, ACE_FULL_VERSION_STR, _TRUNCATE);
|
||||
} else {
|
||||
strncpy(output, addLineBreaks(splitString(function)).c_str(), outputSize);
|
||||
output[outputSize - 1] = '\0';
|
||||
strncpy_s(output, outputSize, addLineBreaks(splitString(function)).c_str(), _TRUNCATE);
|
||||
}
|
||||
EXTENSION_RETURN();
|
||||
}
|
||||
|
||||
#pragma warning( pop )
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* ace_clipboard.cpp
|
||||
*
|
||||
* Takes a string and copies it to the clipboard; bypasses arma 8k clippy limit.
|
||||
* Takes a string and copies it to the clipboard; bypasses arma 8k clippy limit. Windows only.
|
||||
*
|
||||
* Takes:
|
||||
* Localized string as string
|
||||
@ -9,7 +9,10 @@
|
||||
* Returns:
|
||||
* None
|
||||
*/
|
||||
|
||||
#include "shared.hpp"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
@ -30,61 +33,49 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) {
|
||||
}
|
||||
|
||||
if (!strcmp(function, "version")) {
|
||||
strncpy(output, ACE_FULL_VERSION_STR, outputSize);
|
||||
strncpy_s(output, outputSize, ACE_FULL_VERSION_STR, _TRUNCATE);
|
||||
EXTENSION_RETURN();
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
if (!strcmp(function, "--COMPLETE--")) {
|
||||
HGLOBAL hClipboardData = GlobalAlloc(GMEM_FIXED, gClipboardData.length() + 1);
|
||||
if (!hClipboardData) {
|
||||
if (OpenClipboard(NULL) == 0) {
|
||||
result = "OpenClipboard() failed, GetLastError=" + GetLastError();
|
||||
} else {
|
||||
if (EmptyClipboard() == 0) {
|
||||
result = "EmptyClipboard() failed, GetLastError=" + GetLastError();
|
||||
} else {
|
||||
// GPTR = GMEM_FIXED + GMEM_ZEROINIT, returns a ptr, no need for GlobalLock/GlobalUnlock
|
||||
char *pClipboardData = (char *)GlobalAlloc(GPTR, gClipboardData.length());
|
||||
|
||||
if (pClipboardData == NULL) {
|
||||
result = "GlobalAlloc() failed, GetLastError=" + GetLastError();
|
||||
gClipboardData = "";
|
||||
EXTENSION_RETURN();
|
||||
}
|
||||
strncpy_s(pClipboardData, gClipboardData.length(), gClipboardData.c_str(), _TRUNCATE);
|
||||
|
||||
char *pClipboardData = (char *)GlobalLock(hClipboardData);
|
||||
if (!pClipboardData) {
|
||||
result = "GlobalLock() failed, GetLastError=" + GetLastError();
|
||||
gClipboardData = "";
|
||||
EXTENSION_RETURN();
|
||||
}
|
||||
memcpy(pClipboardData, gClipboardData.c_str(), gClipboardData.length());
|
||||
pClipboardData[gClipboardData.length() + 1] = 0x00;
|
||||
|
||||
GlobalUnlock(hClipboardData);
|
||||
|
||||
if (!OpenClipboard(NULL)) {
|
||||
result = "OpenClipboard() failed, GetLastError=" + GetLastError();
|
||||
}
|
||||
else {
|
||||
if (!EmptyClipboard()) {
|
||||
result = "OpenClipboard() failed, GetLastError=" + GetLastError();
|
||||
}
|
||||
else {
|
||||
if (!SetClipboardData(CF_TEXT, hClipboardData)) {
|
||||
// if success, system owns the memory, if fail, free it from the heap
|
||||
if (SetClipboardData(CF_TEXT, pClipboardData) == NULL) {
|
||||
result = "SetClipboardData() failed, GetLastError=" + GetLastError();
|
||||
}
|
||||
else {
|
||||
if (!CloseClipboard()) {
|
||||
GlobalFree(pClipboardData);
|
||||
} else {
|
||||
if (CloseClipboard() == 0) {
|
||||
result = "CloseClipboard() failed, GetLastError=" + GetLastError();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gClipboardData = "";
|
||||
} else {
|
||||
gClipboardData = gClipboardData + cur_input;
|
||||
}
|
||||
|
||||
end:
|
||||
if(result.length() > 1)
|
||||
memcpy(output, result.c_str(), result.length()+1);
|
||||
if (result.length() > 1) {
|
||||
strncpy_s(output, outputSize, result.c_str(), _TRUNCATE);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
EXTENSION_RETURN();
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
@ -96,15 +97,10 @@ double getSolution(double initSpeed, double airFriction, double angleTarget, dou
|
||||
return a2 - angleTarget;
|
||||
}
|
||||
|
||||
// i like to live dangerously. jk, fix strncpy sometime pls.
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4996 )
|
||||
|
||||
void __stdcall RVExtension(char *output, int outputSize, const char *function) {
|
||||
ZERO_OUTPUT();
|
||||
|
||||
if (!strcmp(function, "version")) {
|
||||
strncpy(output, ACE_FULL_VERSION_STR, outputSize);
|
||||
strncpy_s(output, outputSize, ACE_FULL_VERSION_STR, _TRUNCATE);
|
||||
} else {
|
||||
std::vector<std::string> argStrings = splitString(function);
|
||||
double initSpeed = std::stod(argStrings[0]);
|
||||
@ -117,10 +113,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) {
|
||||
std::stringstream sstream;
|
||||
sstream << result;
|
||||
|
||||
strcpy(output, sstream.str().c_str());
|
||||
output[outputSize - 1] = '\0';
|
||||
strncpy_s(output, outputSize, sstream.str().c_str(), _TRUNCATE);
|
||||
}
|
||||
EXTENSION_RETURN();
|
||||
}
|
||||
|
||||
#pragma warning( pop )
|
||||
|
@ -6,6 +6,8 @@
|
||||
*/
|
||||
|
||||
#include "shared.hpp"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
@ -31,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(output, ACE_FULL_VERSION_STR, outputSize);
|
||||
strncpy_s(output, outputSize, ACE_FULL_VERSION_STR, _TRUNCATE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -82,8 +84,7 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) {
|
||||
returnValue = debugreturn.str();
|
||||
}
|
||||
}
|
||||
strncpy(output, returnValue.c_str(), outputSize);
|
||||
output[outputSize - 1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
strncpy_s(output, outputSize, returnValue.c_str(), _TRUNCATE);
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include "shared.hpp"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
@ -36,18 +37,12 @@ std::string getImagePathFromStructuredText(const std::string & input) {
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4996 )
|
||||
|
||||
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);
|
||||
} else {
|
||||
strncpy_s(output, outputSize, getImagePathFromStructuredText(function).c_str(), _TRUNCATE);
|
||||
output[outputSize - 1] = '\0';
|
||||
}
|
||||
EXTENSION_RETURN();
|
||||
}
|
||||
|
||||
#pragma warning( pop )
|
||||
|
Loading…
Reference in New Issue
Block a user