Commit d1f7cc3f authored by Legodev's avatar Legodev

Merge branch 'v1.0.3.6' into 'master'

V1.0.3.6

See merge request DesolationREDUX/Arma_3_Extensions!4
parents 6c25f9bd f9822bd8
......@@ -38,7 +38,7 @@ SET(BOOST_LIBRARYDIR /usr/lib${BITVALUE})
SET(MYSQL_INCLUDE_DIR /usr/include/mysql)
SET(MYSQL_LIBRARY /usr/lib${BITVALUE})
SET(MYSQL_LIBRARY ssl dl z crypto mysqlclient.a)
SET(MYSQL_LIBRARY ssl dl z crypto mysqlclient)
FIND_PACKAGE(Threads REQUIRED)
ENDIF(WIN32)
......
......@@ -133,15 +133,23 @@ out= instance.ExecuteAndPrint("getDateTimeArray", [])
print(out)
#out= instance.ExecuteAndPrint("initdb", ["worlduuid", "11e71379043c8906833008626681de3d"])
#print(out)
#sleep(1)
out= instance.ExecuteAndPrint("initdb", ["worlduuid", "11e71379043c8906833008626681de3d"])
print(out)
sleep(1)
#print("\n\n")
#out= instance.ExecuteAndPrint("loadPlayer", [
#"nickname", "Lego",
#"steamid", "76561198025362180"])
#print(out)
print("\n\n")
out= instance.ExecuteAndPrint("loadPlayerGroups", ["playeruuid", "11E7F2F32EFABF60B1F44A9292F0AA59"])
print(out)
print("\n\n")
out= instance.ExecuteAndPrint("loadPlayerGroups", ["playeruuid", "11E7E4CF9D536DE097E04A9292F0AA59"])
print(out)
#compiledout = ast.literal_eval(out.replace('false', '"false"').replace('true', '"true"'))
#playeruuid = compiledout[1][0]
......@@ -297,7 +305,7 @@ print(out)
#out= instance.ExecuteAndPrint("createObject", [
#"classname", stringgenerator(8),
#"priority", "2"])
print(out)
#print(out)
#compiledout = ast.literal_eval(out)
#objectuuid = compiledout[1]
#print(objectuuid)
......
......@@ -18,7 +18,7 @@
#ifndef SOURCE_CONSTANTS_HPP_
#define SOURCE_CONSTANTS_HPP_
#define DLLVERSIONSTRING "[1,0,3,5]"
#define DLLVERSIONSTRING "[1,0,3,6]"
#define CONFIG_FILE_NAME "libredex.cfg"
/*
......@@ -74,6 +74,7 @@
#define PROTOCOL_DBCALL_FUNCTION_RETURN_ASYNC_SATE "chkasmsg"
#define PROTOCOL_DBCALL_FUNCTION_LOAD_PLAYER "loadPlayer"
#define PROTOCOL_DBCALL_FUNCTION_LOAD_PLAYER_GROUPS "loadPlayerGroups"
#define PROTOCOL_DBCALL_FUNCTION_AV_CHARS "loadAvChars"
#define PROTOCOL_DBCALL_FUNCTION_LINK_CHARS "linkChars"
#define PROTOCOL_DBCALL_FUNCTION_LOAD_CHAR "loadChar"
......
......@@ -58,11 +58,10 @@ fileio::fileio(EXT_FUNCTIONS &extFunctions) {
boost::bind(&fileio::GetCfgFile, this, _1, _2),
SYNC_MAGIC)));
boost::property_tree::ptree configtree;
boost::property_tree::json_parser::read_json(CONFIG_FILE_NAME, configtree);
boost::property_tree::ptree configtree;
boost::property_tree::json_parser::read_json(CONFIG_FILE_NAME, configtree);
for (auto& item : configtree.get_child("fileio.readonce")) {
for (auto& item : configtree.get_child("fileio.readonce")) {
readlist.insert(std::make_pair(item.second.get_value<std::string>(), 1));
}
......@@ -81,51 +80,30 @@ fileio::~fileio() {
return;
}
#if defined(__linux__)
boost::filesystem::path fileio::ToLowerIfNeeded(boost::filesystem::path Path) {
boost::filesystem::path loweredPath = boost::algorithm::to_lower_copy(Path.string());
if (boost::filesystem::exists(loweredPath)) {
return loweredPath;
}
return Path;
}
#endif
boost::filesystem::path fileio::GetConfigPath() {
boost::filesystem::path configPath = "@DesolationServer";
configPath /= "Config";
return configPath;
#if defined(__linux__)
configPath = ToLowerIfNeeded(configPath);
#endif
if (boost::filesystem::is_directory(configPath)) {
return configPath;
}
boost::filesystem::path fileio::GetConfigPath(std::string filename, bool useAsStartPath) {
const std::string toFind = boost::algorithm::to_lower_copy(filename);
configPath = "Config";
#if defined(__linux__)
configPath = ToLowerIfNeeded(configPath);
#endif
auto begin = boost::filesystem::recursive_directory_iterator(this->configPath);
const auto end = boost::filesystem::recursive_directory_iterator();
if (boost::filesystem::is_directory(configPath)) {
return configPath;
for (; begin != end; ++begin) {
const std::string path = boost::algorithm::to_lower_copy(begin->path().string());
if (path.find(toFind) != std::string::npos) {
if (!boost::filesystem::is_directory(path)) {
if (useAsStartPath) {
// speedup future search by starting on the last searched directory
this->configPath = begin->path().parent_path();
}
return begin->path();
}
}
}
throw std::runtime_error("could not find the config path try to lower all names and check the dll location");
throw std::runtime_error("could not find the configs path, i started searching on path: " + this->configPath.string());
}
std::string fileio::GetInitOrder(std::string &extFunction, ext_arguments &extArguments) {
boost::filesystem::path configPath = GetConfigPath();
configPath /= "PluginList.cfg";
#if defined(__linux__)
configPath = ToLowerIfNeeded(configPath);
#endif
boost::filesystem::path configPath = GetConfigPath("PluginList.cfg", true);
if (boost::filesystem::exists(configPath)) {
int charpos, linenum;
......@@ -135,7 +113,9 @@ std::string fileio::GetInitOrder(std::string &extFunction, ext_arguments &extArg
linenum = 0;
while (std::getline(infile, line)) {
std::istringstream iss(line);
line.erase(std::remove(line.begin(), line.end(), '\r'), line.end());
//std::istringstream iss(line);
int i = 0;
while ((i = line.find("\"", i)) != std::string::npos) {
......@@ -181,22 +161,15 @@ std::string fileio::GetInitOrder(std::string &extFunction, ext_arguments &extArg
}
std::string fileio::GetCfgFile(std::string &extFunction, ext_arguments &extArguments) {
boost::filesystem::path configPath = GetConfigPath();
std::string returnString = "[";
int filenum = 0;
int itemnum = 0;
for (std::string& filename : extArguments.get_simplelist<std::string>("configfiles")) {
boost::regex dirupexpression("\\.\\.");
filename = boost::regex_replace(filename, dirupexpression, "", boost::match_default | boost::format_all);
boost::filesystem::path filepath = configPath / (filename + ".cfg");
#if defined(__linux__)
filepath = ToLowerIfNeeded(filepath);
#endif
boost::filesystem::path filepath = GetConfigPath(filename + ".cfg");
if (filenum != 0) {
returnString += ",";
......@@ -209,8 +182,8 @@ std::string fileio::GetCfgFile(std::string &extFunction, ext_arguments &extArgum
itemnum = 0;
BOOST_FOREACH(boost::property_tree::ptree::value_type &val, configtree) {
// val.first is the name of the child.
// val.second is the child tree.
// val.first is the name of the child.
// val.second is the child tree.
std::string key = val.first;
std::string value = val.second.get_value<std::string>();
int i = 0;
......@@ -267,7 +240,7 @@ std::string fileio::readFile(std::string &extFunction, ext_arguments &extArgumen
linenum = 0;
while (std::getline(infile, line)) {
std::istringstream iss(line);
//std::istringstream iss(line);
// add second " to get the string after call compile to concatinate with the remaining parts
charpos = 0;
......@@ -287,8 +260,8 @@ std::string fileio::readFile(std::string &extFunction, ext_arguments &extArgumen
returnString += "]";
} else {
throw std::runtime_error("cannot read file: " + filename);
}
throw std::runtime_error("cannot read file: " + filename);
}
return "[\"" + std::string(PROTOCOL_MESSAGE_TYPE_MESSAGE) + "\"," + filename + "]";
}
......
......@@ -40,6 +40,8 @@ private:
typedef std::map<std::string, int> FILE_IO_MAP;
FILE_IO_MAP readlist;
FILE_IO_MAP writelist;
boost::filesystem::path configPath = ".";
std::string readFile(std::string &extFunction, ext_arguments &extArguments);
std::string writeFile(std::string &extFunction, ext_arguments &extArguments);
......@@ -47,10 +49,7 @@ private:
std::string GetInitOrder(std::string &extFunction, ext_arguments &extArguments);
std::string GetCfgFile(std::string &extFunction, ext_arguments &extArguments);
boost::filesystem::path GetConfigPath();
#if defined(__linux__)
boost::filesystem::path ToLowerIfNeeded(boost::filesystem::path configPath);
#endif
boost::filesystem::path GetConfigPath(std::string filename, bool useAsStartPath = false);
};
......
......@@ -17,22 +17,34 @@
#include "main.hpp"
extern "C"
{
void RVExtensionVersion(char *output, int outputSize)
{
char version[] = DLLVERSIONSTRING;
//--- max outputSize is 32 bytes
strncpy(output, version, outputSize);
output[outputSize - 1] = '\0';
}
}
extern "C"
{
void RVExtension(char *output, int outputSize, const char *function)
{
#ifdef DEBUG
std::time_t result = std::time(nullptr);
testfile << std::put_time(std::localtime(&result), "%F %T") << "\t\t ARMAIO-REQUEST " << function << std::endl;
testfile << std::localtime(&result) << "\t\t ARMAIO-REQUEST " << function << std::endl;
testfile.flush();
#endif
std::string errstr = "[\"" + std::string(PROTOCOL_MESSAGE_TYPE_ERROR) + "\", \"";
errstr += "Sorry RVExtension is not supported anymore";
errstr += "\"]";
strncpy(output, errstr.c_str(), outputSize);
output[outputSize - 1] = '\0';
#ifdef DEBUG
result = std::time(nullptr);
testfile << std::put_time(std::localtime(&result), "%F %T") << "\t\t ARMAIO-ERROR " << errstr << std::endl;
testfile << std::localtime(&result) << "\t\t ARMAIO-ERROR " << errstr << std::endl;
testfile.flush();
#endif
}
......@@ -48,18 +60,18 @@ extern "C"
try {
#ifdef DEBUG
result = std::time(nullptr);
testfile << std::put_time(std::localtime(&result), "%F %T") << "\t\t ARMAIO-REQUEST " << function << std::endl;
testfile << std::localtime(&result) << "\t\t ARMAIO-REQUEST " << function << std::endl;
testfile.flush();
for (int i = 0; i < argsCnt; i++) {
result = std::time(nullptr);
testfile << std::put_time(std::localtime(&result), "%F %T") << "\t\t ARMAIO-Argument " << i << ": " << args[i] << std::endl;
testfile << std::localtime(&result) << "\t\t ARMAIO-Argument " << i << ": " << args[i] << std::endl;
testfile.flush();
}
#endif
std::string returnString = extension->processCallExtension(function, args, argsCnt, outputSize);
#ifdef DEBUG
result = std::time(nullptr);
testfile << std::put_time(std::localtime(&result), "%F %T") << "\t\t ARMAIO-RETURN " << returnString << std::endl;
testfile << std::localtime(&result) << "\t\t ARMAIO-RETURN " << returnString << std::endl;
testfile.flush();
#endif
strncpy(output, returnString.c_str(), outputSize);
......@@ -76,9 +88,10 @@ extern "C"
errstr += error;
errstr += "\"]";
strncpy(output, errstr.c_str(), outputSize);
output[outputSize - 1] = '\0';
#ifdef DEBUG
result = std::time(nullptr);
testfile << std::put_time(std::localtime(&result), "%F %T") << "\t\t ARMAIO-ERROR " << errstr << std::endl;
testfile << std::localtime(&result) << "\t\t ARMAIO-ERROR " << errstr << std::endl;
testfile.flush();
#endif
}
......
......@@ -20,14 +20,17 @@
#ifdef __MINGW32__
#if _WIN64
#define RVExtensionVersion __stdcall RVExtensionVersion
#define RVExtension __stdcall RVExtension
#define RVExtensionArgs __stdcall RVExtensionArgs
#else
#define RVExtensionVersion __stdcall RVExtensionVersion
#define RVExtension __stdcall _RVExtension
#define RVExtensionArgs __stdcall _RVExtensionArgs
#endif
#endif
#ifdef _MSC_VER
#define RVExtensionVersion __stdcall RVExtensionVersion
#define RVExtension __stdcall RVExtension
#define RVExtensionArgs __stdcall RVExtensionArgs
#endif
......@@ -145,7 +148,7 @@ static void destroy(void)
#ifdef __cplusplus
extern "C" {
#endif
__declspec (dllexport) void RVExtensionVersion(char *output, int outputSize);
__declspec (dllexport) void RVExtension(char *output, int outputSize, const char *function);
__declspec (dllexport) void RVExtensionArgs(char *output, int outputSize, const char *function, const char **args, int argsCnt);
......
......@@ -105,6 +105,12 @@ mysql_db_handler::mysql_db_handler(EXT_FUNCTIONS &extFunctions) {
std::make_tuple(
boost::bind(&mysql_db_handler::interloadPlayer, this, _1, _2),
ASYNC_MAGIC)));
extFunctions.insert(
std::make_pair(
std::string(PROTOCOL_DBCALL_FUNCTION_LOAD_PLAYER_GROUPS),
std::make_tuple(
boost::bind(&mysql_db_handler::interloadPlayerGroups, this, _1, _2),
ASYNC_MAGIC)));
extFunctions.insert(
std::make_pair(
std::string(PROTOCOL_DBCALL_FUNCTION_AV_CHARS),
......@@ -519,6 +525,13 @@ std::string mysql_db_handler::interloadPlayer(std::string &extFunction, ext_argu
return "[\"" + std::string(PROTOCOL_MESSAGE_TYPE_MESSAGE) + "\"," + playerinfo + "]";
}
std::string mysql_db_handler::interloadPlayerGroups(std::string &extFunction, ext_arguments &extArgument) {
std::string playeruuid = extArgument.getUUID(PROTOCOL_DBCALL_ARGUMENT_PLAYER_UUID);
std::string result = loadPlayerGroups(playeruuid);
return "[\"" + std::string(PROTOCOL_MESSAGE_TYPE_MESSAGE) + "\"," + result + "]";
}
std::string mysql_db_handler::interloadAvChars(std::string &extFunction, ext_arguments &extArgument) {
std::string playeruuid = extArgument.getUUID(PROTOCOL_DBCALL_ARGUMENT_PLAYER_UUID);
std::string result = loadAvChars(playeruuid);
......@@ -735,6 +748,113 @@ std::string mysql_db_handler::loadPlayer(std::string nickname, std::string steam
return "[\"" + playeruuid + "\",\"" + persistent_variables_uuid + "\",\"" + mainclanuuid + "\",[" + banned + ",\"" + banreason +"\"]]";
}
std::string mysql_db_handler::loadPlayerGroups(std::string playeruuid) {
MYSQL_RES *result;
MYSQL_ROW row;
unsigned int fieldcount;
unsigned long long int rowcount;
bool printcommaone = false;
bool printcommatwo = false;
// char info
std::string groupinfo = "";
std::string querygroupinfo =
str(
boost::format {
"SELECT HEX(`clan`.`uuid`) AS 'clan_uuid', HEX(`founder`.`uuid`) AS 'founder_uuid', `founder`.`steamid` AS 'founder_steamid', "
"`founder`.`lastnick` AS 'founder_nick', GROUP_CONCAT("
"DISTINCT CONCAT('[\"', HEX(`player`.`uuid`), '\",\"' , `player`.`steamid`, '\",\"' , `player`.`lastnick`, '\",', "
"`clan_member`.`rank`, ',\"', `clan_member`.`comment`, '\"]') "
"SEPARATOR ','"
") AS 'clan_member_list'"
"FROM `clan` LEFT JOIN `player` AS `founder` ON `clan`.`founder_uuid` = `founder`.`uuid` "
"LEFT JOIN `clan_member` ON `clan`.`uuid` = `clan_member`.`clan_uuid` "
"LEFT JOIN `player` ON `clan_member`.`player_uuid` = `player`.`uuid`"
"WHERE `clan`.`uuid` IN ("
"SELECT `clan_member`.`clan_uuid` "
"FROM `clan_member` "
"WHERE `clan_member`.`player_uuid` = CAST(0x%s AS BINARY)"
")"
"GROUP BY `clan`.`uuid`" }
% playeruuid);
char typearray[] = {
1, // HEX(`clan`.`uuid`)
1, // HEX(`founder`.`uuid`)
1, // `founder`.`steamid`
1, // `founder`.`lastnick`
3, // 'clan_member'
};
this->rawquery(querygroupinfo, &result);
fieldcount = mysql_num_fields(result);
rowcount = mysql_num_rows(result);
groupinfo = "[";
for (int rowpos = 0; rowpos < rowcount; rowpos++) {
row = mysql_fetch_row(result);
if (printcommaone) {
groupinfo += ",";
printcommaone = false;
printcommatwo = false;
}
groupinfo += "[";
for (int fieldpos = 0; fieldpos < fieldcount; fieldpos++) {
if (printcommatwo) {
groupinfo += ",";
printcommatwo = false;
}
switch (typearray[fieldpos]) {
case 1:
groupinfo += "\"";
break;
case 2:
groupinfo += "[";
if (row[fieldpos] != NULL)
groupinfo += "\"";
break;
case 3:
groupinfo += "[";
break;
default:
groupinfo += "";
}
if (row[fieldpos] != NULL) {
groupinfo += row[fieldpos];
} else {
groupinfo += "";
}
switch (typearray[fieldpos]) {
case 1:
groupinfo += "\"";
break;
case 2:
if (row[fieldpos] != NULL)
groupinfo += "\"";
groupinfo += "]";
break;
case 3:
groupinfo += "]";
break;
}
printcommatwo = true;
}
groupinfo += "]";
printcommaone = true;
}
groupinfo += "]";
return groupinfo;
}
std::string mysql_db_handler::loadAvChars(std::string playeruuid) {
MYSQL_RES *result;
MYSQL_ROW row;
......@@ -779,14 +899,18 @@ std::string mysql_db_handler::loadAvChars(std::string playeruuid) {
for (int rowpos = 0; rowpos < rowcount; rowpos++) {
row = mysql_fetch_row(result);
charinfo += "[";
if (printcommaone) {
charinfo += ",";
printcommaone = false;
printcommatwo = false;
}
charinfo += "[";
for (int fieldpos = 0; fieldpos < fieldcount; fieldpos++) {
if (printcommatwo) {
charinfo += ",";
printcommatwo = false;
}
switch (typearray[fieldpos]) {
case 1:
......
......@@ -95,6 +95,7 @@ private:
std::string interdbVersion(std::string &extFunction, ext_arguments &extArgument);
std::string interloadPlayer(std::string &extFunction, ext_arguments &extArgument);
std::string interloadPlayerGroups(std::string &extFunction, ext_arguments &extArgument);
std::string interloadAvChars(std::string &extFunction, ext_arguments &extArgument);
std::string interlinkChars(std::string &extFunction, ext_arguments &extArgument);
std::string interloadChar(std::string &extFunction, ext_arguments &extArgument);
......@@ -129,6 +130,7 @@ private:
void checkWorldUUID();
std::string loadPlayer(std::string nickname, std::string steamid);
std::string loadPlayerGroups(std::string playeruuid);
std::string loadAvChars(std::string playeruuid);
std::string linkChars(std::string playeruuid, std::string variabuuid);
std::string loadChar(std::string playeruuid);
......
......@@ -2,8 +2,8 @@
#define PRODUCT_NAME_STR "libredex"
#define PRODUCT_DESCRIPTION "Desolation Redux Arma3 callExtension"
#define VER_VERSION 1,0,3,5
#define VER_VERSION_STR "1.0.3.5"
#define VER_VERSION 1,0,3,6
#define VER_VERSION_STR "1.0.3.6"
VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_VERSION
......
#!/usr/bin/env bash
rm -rf Binaries/*so
mkdir -p build
cd build
####
mkdir -p 64bit-linux-debian-strech-release
cd 64bit-linux-debian-strech-release
cmake ../../ -DBITVALUE=64 -DCMAKE_BUILD_TYPE=Release
make
cd ..
####
cd ../Binaries
mkdir -p Linux_Debian_Stretch/Release/
mv libredex*.so Linux_Debian_Stretch/Release/
####
cd ../build
####
mkdir -p 64bit-linux-debian-strech-debug
cd 64bit-linux-debian-strech-debug
cmake ../../ -DBITVALUE=64 -DCMAKE_BUILD_TYPE=Debug
make
cd ..
####
cd ../Binaries
mkdir -p Linux_Debian_Stretch/Debug/
mv libredex*.so Linux_Debian_Stretch/Debug/
#!/usr/bin/env bash
rm -rf Binaries/*so
mkdir -p build
cd build
####
mkdir -p 32bit-linux-debian-strech-release
cd 32bit-linux-debian-strech-release
cmake ../../ -DBITVALUE=32 -DCMAKE_BUILD_TYPE=Release
make
cd ..
####
cd ../Binaries
mkdir -p Linux_Debian_Stretch/Release/
mv libredex*.so Linux_Debian_Stretch/Release/
####
cd ../build
####
mkdir -p 32bit-linux-debian-strech-debug
cd 32bit-linux-debian-strech-debug
cmake ../../ -DBITVALUE=32 -DCMAKE_BUILD_TYPE=Debug
make
cd ..
####
cd ../Binaries
mkdir -p Linux_Debian_Stretch/Debug/
mv libredex*.so Linux_Debian_Stretch/Debug/
#!/usr/bin/env bash
rm -rf build
find Binaries/ -mindepth 1 -maxdepth 1 -type d -exec rm -rf {} \;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment