Commit 7fa76674 authored by Legodev's avatar Legodev

added functions to alter the object -> world link

parent 1e9281e9
......@@ -18,7 +18,7 @@
#ifndef SOURCE_CONSTANTS_HPP_
#define SOURCE_CONSTANTS_HPP_
#define DLLVERSIONSTRING "[1,0,3,8]"
#define DLLVERSIONSTRING "[1,0,3,9]"
#define CONFIG_FILE_NAME "libredex.cfg"
/*
......@@ -94,6 +94,10 @@
#define PROTOCOL_DBCALL_FUNCTION_DECLARE_OBJECT_DEATH "killObject"
#define PROTOCOL_DBCALL_FUNCTION_DUMP_OBJECTS "dumpObjects"
#define PROTOCOL_DBCALL_FUNCTION_CREATE_OBJECT_WORLD_LINK "createObjectWorldLink"
#define PROTOCOL_DBCALL_FUNCTION_UPDATE_OBJECT_WORLD_LINK "updateObjectWorldLink"
#define PROTOCOL_DBCALL_FUNCTION_DELETE_OBJECT_WORLD_LINK "deleteObjectWorldLink"
// Database Call Arguments
#define PROTOCOL_DBCALL_ARGUMENT_ACCESSCODE "accesscode"
#define PROTOCOL_DBCALL_ARGUMENT_ANIMATIONSTATE "animationstate"
......
......@@ -206,6 +206,22 @@ mysql_db_handler::mysql_db_handler(EXT_FUNCTIONS &extFunctions) {
std::make_tuple(
boost::bind(&mysql_db_handler::interdumpObjects, this, _1, _2),
ASYNC_MAGIC)));
extFunctions.insert(
std::make_pair(std::string(PROTOCOL_DBCALL_FUNCTION_CREATE_OBJECT_WORLD_LINK),
std::make_tuple(
boost::bind(&mysql_db_handler::createObjectWorldLink, this, _1, _2),
ASYNC_MAGIC)));
extFunctions.insert(
std::make_pair(std::string(PROTOCOL_DBCALL_FUNCTION_UPDATE_OBJECT_WORLD_LINK),
std::make_tuple(
boost::bind(&mysql_db_handler::updateObjectWorldLink, this, _1, _2),
ASYNC_MAGIC)));
extFunctions.insert(
std::make_pair(std::string(PROTOCOL_DBCALL_FUNCTION_DELETE_OBJECT_WORLD_LINK),
std::make_tuple(
boost::bind(&mysql_db_handler::deleteObjectWorldLink, this, _1, _2),
ASYNC_MAGIC)));
}
mysql_db_handler::~mysql_db_handler() {
......@@ -1654,6 +1670,72 @@ std::vector<object_mysql *> mysql_db_handler::dumpObjects(ext_arguments &extArgu
return objectList;
}
std::string mysql_db_handler::createObjectWorldLink(std::string &extFunction, ext_arguments &extArgument) {
std::string objectuuid = extArgument.getUUID(PROTOCOL_DBCALL_ARGUMENT_OBJECTUUID);
std::string worlduuid = this->worlduuid;
unsigned long long int rowcount;
if (extArgument.keyExists(PROTOCOL_DBCALL_ARGUMENT_WORLDUUID)) {
worlduuid = extArgument.getUUID(PROTOCOL_DBCALL_ARGUMENT_WORLDUUID);
}
std::string query = str(boost::format { "SELECT HEX(`object_uuid`) "
"FROM `world_has_objects` "
"WHERE `world_has_objects`.`object_uuid` = CAST(0x%s AS BINARY) "
"AND `world_has_objects`.`world_uuid` = CAST(0x%s AS BINARY) "
"AND `world_has_objects`.`killinfo_uuid` IS NULL" } % playeruuid % worlduuid);
this->rawquery(query, &result);
rowcount = mysql_num_rows(result);
mysql_free_result (result);
if (rowcount < 1) {
std::string query = str(boost::format { "INSERT INTO `world_has_objects` (`world_uuid`, `object_uuid`) "
"VALUES (CAST(0x%s AS BINARY), CAST(0x%s AS BINARY))" } % worlduuid % objectuuid);
this->rawquery(query);
}
return "[\"" + std::string(PROTOCOL_MESSAGE_TYPE_MESSAGE) + "\",[\"" + objectuuid + "\",\"" + worlduuid + "\"]]";
}
std::string mysql_db_handler::updateObjectWorldLink(std::string &extFunction, ext_arguments &extArgument) {
std::string objectuuid = extArgument.getUUID(PROTOCOL_DBCALL_ARGUMENT_OBJECTUUID);
std::string worlduuid = this->worlduuid;
if (extArgument.keyExists(PROTOCOL_DBCALL_ARGUMENT_WORLDUUID)) {
worlduuid = extArgument.getUUID(PROTOCOL_DBCALL_ARGUMENT_WORLDUUID);
}
std::string query = str(boost::format { "UPDATE `world_has_objects` SET `world_uuid` = CAST(0x%s AS BINARY) "
"WHERE `world_has_objects`.`object_uuid` = CAST(0x%s AS BINARY);" } % worlduuid % objectuuid);
this->rawquery(query);
return "[\"" + std::string(PROTOCOL_MESSAGE_TYPE_MESSAGE) + "\",[\"" + objectuuid + "\",\"" + worlduuid + "\"]]";
}
std::string mysql_db_handler::deleteObjectWorldLink(std::string &extFunction, ext_arguments &extArgument) {
std::string objectuuid = extArgument.getUUID(PROTOCOL_DBCALL_ARGUMENT_OBJECTUUID);
std::string worlduuid = "*";
std::string query = str(boost::format { "DELETE FROM `world_has_objects` SET "
"WHERE `world_has_objects`.`object_uuid` = CAST(0x%s AS BINARY);" } % objectuuid);
if (extArgument.keyExists(PROTOCOL_DBCALL_ARGUMENT_WORLDUUID)) {
worlduuid = extArgument.getUUID(PROTOCOL_DBCALL_ARGUMENT_WORLDUUID);
query = str(boost::format { "DELETE FROM `world_has_objects` SET "
"WHERE `world_has_objects`.`object_uuid` = CAST(0x%s AS BINARY)"
"AND `world_uuid` = CAST(0x%s AS BINARY);" } % objectuuid % worlduuid );
}
this->rawquery(query);
return "[\"" + std::string(PROTOCOL_MESSAGE_TYPE_MESSAGE) + "\",[\"" + objectuuid + "\",\"" + worlduuid + "\"]]";
}
void mysql_db_handler::test_stmt_error(MYSQL_STMT *stmt, int status) {
if (status)
{
......
......@@ -146,6 +146,10 @@ private:
std::string killObject(std::string objectuuid, std::string attackeruuid, std::string type, std::string weapon, float distance);
std::vector<object_mysql *> dumpObjects(ext_arguments &extArgument);
std::string createObjectWorldLink(std::string &extFunction, ext_arguments &extArgument);
std::string updateObjectWorldLink(std::string &extFunction, ext_arguments &extArgument);
std::string deleteObjectWorldLink(std::string &extFunction, ext_arguments &extArgument);
};
#endif /* SOURCE_MYSQL_HPP_ */
......@@ -2,8 +2,8 @@
#define PRODUCT_NAME_STR "libredex"
#define PRODUCT_DESCRIPTION "Desolation Redux Arma3 callExtension"
#define VER_VERSION 1,0,3,8
#define VER_VERSION_STR "1.0.3.8"
#define VER_VERSION 1,0,3,9
#define VER_VERSION_STR "1.0.3.9"
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