Commit 99ba7fbe authored by Legodev's avatar Legodev

ADDED: function to (un)whitelist

parent b53c5e1c
......@@ -18,7 +18,7 @@
#ifndef SOURCE_CONSTANTS_HPP_
#define SOURCE_CONSTANTS_HPP_
#define DLLVERSIONSTRING "[1,0,3,7]"
#define DLLVERSIONSTRING "[1,0,3,8]"
#define CONFIG_FILE_NAME "libredex.cfg"
/*
......@@ -75,6 +75,8 @@
#define PROTOCOL_DBCALL_FUNCTION_LOAD_PLAYER "loadPlayer"
#define PROTOCOL_DBCALL_FUNCTION_LOAD_PLAYER_GROUPS "loadPlayerGroups"
#define PROTOCOL_DBCALL_FUNCTION_WHITELIST_PLAYER "whitelistPlayer"
#define PROTOCOL_DBCALL_FUNCTION_UNWHITELIST_PLAYER "unwhitelistPlayer"
#define PROTOCOL_DBCALL_FUNCTION_AV_CHARS "loadAvChars"
#define PROTOCOL_DBCALL_FUNCTION_LINK_CHARS "linkChars"
#define PROTOCOL_DBCALL_FUNCTION_LOAD_CHAR "loadChar"
......
......@@ -106,11 +106,23 @@ mysql_db_handler::mysql_db_handler(EXT_FUNCTIONS &extFunctions) {
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)));
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_WHITELIST_PLAYER),
std::make_tuple(
boost::bind(&mysql_db_handler::whitelistPlayer, this, _1, _2),
ASYNC_MAGIC)));
extFunctions.insert(
std::make_pair(
std::string(PROTOCOL_DBCALL_FUNCTION_UNWHITELIST_PLAYER),
std::make_tuple(
boost::bind(&mysql_db_handler::unwhitelistPlayer, this, _1, _2),
ASYNC_MAGIC)));
extFunctions.insert(
std::make_pair(
std::string(PROTOCOL_DBCALL_FUNCTION_AV_CHARS),
......@@ -855,6 +867,86 @@ std::string mysql_db_handler::loadPlayerGroups(std::string playeruuid) {
return groupinfo;
}
std::string mysql_db_handler::whitelistPlayer(std::string &extFunction, ext_arguments &extArgument) {
MYSQL_RES *result;
MYSQL_ROW row;
unsigned int fieldcount;
unsigned long long int rowcount;
std::string extplayeruuid = extArgument.getUUID(PROTOCOL_DBCALL_ARGUMENT_PLAYER_UUID);
std::string playeruuid = "";
std::string queryplayerinfo = str(boost::format { "SELECT HEX(`player`.`uuid`), "
"FROM `player` "
"WHERE `player`.`uuid` = CAST(0x%s AS BINARY) " } % worlduuid % extplayeruuid);
this->rawquery(queryplayerinfo, &result);
rowcount = mysql_num_rows(result);
if (rowcount > 0) {
row = mysql_fetch_row(result);
if (row[0] != NULL) {
playeruuid = row[0];
}
}
mysql_free_result(result);
if (playeruuid != "") {
std::string querywhitelist = str(boost::format { "INSER INTO `whitelist` (`world_uuid`, `player_uuid`)"
"VALUES (CAST(0x%s AS BINARY), CAST(0x%s AS BINARY))" } % worlduuid % playeruuid);
this->rawquery(querywhitelist);
} else {
return "[\"" + std::string(PROTOCOL_MESSAGE_TYPE_MESSAGE) + "\",\"player does not exist!\"]";
}
return "[\"" + std::string(PROTOCOL_MESSAGE_TYPE_MESSAGE) + "\",\"DONE\"]";
}
std::string mysql_db_handler::unwhitelistPlayer(std::string &extFunction, ext_arguments &extArgument) {
MYSQL_RES *result;
MYSQL_ROW row;
unsigned int fieldcount;
unsigned long long int rowcount;
std::string extplayeruuid = extArgument.getUUID(PROTOCOL_DBCALL_ARGUMENT_PLAYER_UUID);
std::string playeruuid = "";
std::string queryplayerinfo = str(boost::format { "SELECT HEX(`player`.`uuid`), "
"FROM `player` "
"WHERE `player`.`uuid` = CAST(0x%s AS BINARY) " } % worlduuid % extplayeruuid);
this->rawquery(queryplayerinfo, &result);
rowcount = mysql_num_rows(result);
if (rowcount > 0) {
row = mysql_fetch_row(result);
if (row[0] != NULL) {
playeruuid = row[0];
}
}
mysql_free_result(result);
if (playeruuid != "") {
std::string querywhitelist =
str(boost::format{"DELETE FROM `whitelist` "
"WHERE `whitelist`.`world_uuid` = CAST(0x%s AS BINARY) "
" AND `whitelist`.`player_uuid` = CAST(0x%s AS BINARY) "} % worlduuid % playeruuid);
this->rawquery(querywhitelist);
} else {
return "[\"" + std::string(PROTOCOL_MESSAGE_TYPE_MESSAGE) + "\",\"player does not exist!\"]";
}
return "[\"" + std::string(PROTOCOL_MESSAGE_TYPE_MESSAGE) + "\",\"DONE\"]";
}
std::string mysql_db_handler::loadAvChars(std::string playeruuid) {
MYSQL_RES *result;
MYSQL_ROW row;
......
......@@ -96,6 +96,8 @@ private:
std::string interloadPlayer(std::string &extFunction, ext_arguments &extArgument);
std::string interloadPlayerGroups(std::string &extFunction, ext_arguments &extArgument);
std::string whitelistPlayer(std::string &extFunction, ext_arguments &extArgument);
std::string unwhitelistPlayer(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);
......
......@@ -2,8 +2,8 @@
#define PRODUCT_NAME_STR "libredex"
#define PRODUCT_DESCRIPTION "Desolation Redux Arma3 callExtension"
#define VER_VERSION 1,0,3,7
#define VER_VERSION_STR "1.0.3.7"
#define VER_VERSION 1,0,3,8
#define VER_VERSION_STR "1.0.3.8"
VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_VERSION
......
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