mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-11-23 15:11:19 +00:00
Merge branch 'main' into guild_temp
This commit is contained in:
@@ -23,6 +23,9 @@
|
||||
#include "IActivityLog.h"
|
||||
#include "IGuilds.h"
|
||||
#include "IGuildMembers.h"
|
||||
#include "IIgnoreList.h"
|
||||
#include "IAccountsRewardCodes.h"
|
||||
|
||||
namespace sql {
|
||||
class Statement;
|
||||
class PreparedStatement;
|
||||
@@ -39,7 +42,9 @@ class GameDatabase :
|
||||
public IMail, public ICommandLog, public IPlayerCheatDetections, public IBugReports,
|
||||
public IPropertyContents, public IProperty, public IPetNames, public ICharXml,
|
||||
public IMigrationHistory, public IUgc, public IFriends, public ICharInfo,
|
||||
public IAccounts, public IActivityLog, public IGuilds, public IGuildMembers {
|
||||
public IAccounts, public IActivityLog, public IAccountsRewardCodes, public IIgnoreList,
|
||||
public IGuilds, public IGuildMembers {
|
||||
|
||||
public:
|
||||
virtual ~GameDatabase() = default;
|
||||
// TODO: These should be made private.
|
||||
|
||||
13
dDatabase/GameDatabase/ITables/IAccountsRewardCodes.h
Normal file
13
dDatabase/GameDatabase/ITables/IAccountsRewardCodes.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef __IACCOUNTSREWARDCODES__H__
|
||||
#define __IACCOUNTSREWARDCODES__H__
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
class IAccountsRewardCodes {
|
||||
public:
|
||||
virtual void InsertRewardCode(const uint32_t account_id, const uint32_t reward_code) = 0;
|
||||
virtual std::vector<uint32_t> GetRewardCodesByAccountID(const uint32_t account_id) = 0;
|
||||
};
|
||||
|
||||
#endif //!__IACCOUNTSREWARDCODES__H__
|
||||
20
dDatabase/GameDatabase/ITables/IIgnoreList.h
Normal file
20
dDatabase/GameDatabase/ITables/IIgnoreList.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef __IIGNORELIST__H__
|
||||
#define __IIGNORELIST__H__
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class IIgnoreList {
|
||||
public:
|
||||
struct Info {
|
||||
std::string name;
|
||||
uint32_t id;
|
||||
};
|
||||
|
||||
virtual std::vector<Info> GetIgnoreList(const uint32_t playerId) = 0;
|
||||
virtual void AddIgnore(const uint32_t playerId, const uint32_t ignoredPlayerId) = 0;
|
||||
virtual void RemoveIgnore(const uint32_t playerId, const uint32_t ignoredPlayerId) = 0;
|
||||
};
|
||||
|
||||
#endif //!__IIGNORELIST__H__
|
||||
@@ -103,6 +103,11 @@ public:
|
||||
std::optional<uint32_t> GetDonationTotal(const uint32_t activityId) override;
|
||||
std::optional<bool> IsPlaykeyActive(const int32_t playkeyId) override;
|
||||
std::vector<IUgc::Model> GetUgcModels(const LWOOBJID& propertyId) override;
|
||||
void AddIgnore(const uint32_t playerId, const uint32_t ignoredPlayerId) override;
|
||||
void RemoveIgnore(const uint32_t playerId, const uint32_t ignoredPlayerId) override;
|
||||
std::vector<IIgnoreList::Info> GetIgnoreList(const uint32_t playerId) override;
|
||||
void InsertRewardCode(const uint32_t account_id, const uint32_t reward_code) override;
|
||||
std::vector<uint32_t> GetRewardCodesByAccountID(const uint32_t account_id) override;
|
||||
std::optional<IGuilds::Guild> CreateGuild(const std::string_view name, const int32_t owner_id, const uint64_t reputation) override;
|
||||
std::optional<IGuilds::Guild> GetGuild(const uint32_t guild_id) override;
|
||||
std::optional<IGuilds::Guild> GetGuildByName(const std::string_view name) override;
|
||||
|
||||
17
dDatabase/GameDatabase/MySQL/Tables/AccountsRewardCodes.cpp
Normal file
17
dDatabase/GameDatabase/MySQL/Tables/AccountsRewardCodes.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include "MySQLDatabase.h"
|
||||
|
||||
void MySQLDatabase::InsertRewardCode(const uint32_t account_id, const uint32_t reward_code) {
|
||||
ExecuteInsert("INSERT IGNORE INTO accounts_rewardcodes (account_id, rewardcode) VALUES (?, ?);", account_id, reward_code);
|
||||
}
|
||||
|
||||
std::vector<uint32_t> MySQLDatabase::GetRewardCodesByAccountID(const uint32_t account_id) {
|
||||
auto result = ExecuteSelect("SELECT rewardcode FROM accounts_rewardcodes WHERE account_id = ?;", account_id);
|
||||
|
||||
std::vector<uint32_t> toReturn;
|
||||
toReturn.reserve(result->rowsCount());
|
||||
while (result->next()) {
|
||||
toReturn.push_back(result->getUInt("rewardcode"));
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
set(DDATABASES_DATABASES_MYSQL_TABLES_SOURCES
|
||||
"Accounts.cpp"
|
||||
"AccountsRewardCodes.cpp"
|
||||
"ActivityLog.cpp"
|
||||
"BugReports.cpp"
|
||||
"CharInfo.cpp"
|
||||
@@ -8,6 +9,7 @@ set(DDATABASES_DATABASES_MYSQL_TABLES_SOURCES
|
||||
"Friends.cpp"
|
||||
"Guilds.cpp"
|
||||
"GuildMembers.cpp"
|
||||
"IgnoreList.cpp"
|
||||
"Leaderboard.cpp"
|
||||
"Mail.cpp"
|
||||
"MigrationHistory.cpp"
|
||||
|
||||
22
dDatabase/GameDatabase/MySQL/Tables/IgnoreList.cpp
Normal file
22
dDatabase/GameDatabase/MySQL/Tables/IgnoreList.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "MySQLDatabase.h"
|
||||
|
||||
std::vector<IIgnoreList::Info> MySQLDatabase::GetIgnoreList(const uint32_t playerId) {
|
||||
auto result = ExecuteSelect("SELECT ci.name AS name, il.ignored_player_id AS ignore_id FROM ignore_list AS il JOIN charinfo AS ci ON il.ignored_player_id = ci.id WHERE il.player_id = ?", playerId);
|
||||
|
||||
std::vector<IIgnoreList::Info> ignoreList;
|
||||
|
||||
ignoreList.reserve(result->rowsCount());
|
||||
while (result->next()) {
|
||||
ignoreList.push_back(IIgnoreList::Info{ result->getString("name").c_str(), result->getUInt("ignore_id") });
|
||||
}
|
||||
|
||||
return ignoreList;
|
||||
}
|
||||
|
||||
void MySQLDatabase::AddIgnore(const uint32_t playerId, const uint32_t ignoredPlayerId) {
|
||||
ExecuteInsert("INSERT IGNORE INTO ignore_list (player_id, ignored_player_id) VALUES (?, ?)", playerId, ignoredPlayerId);
|
||||
}
|
||||
|
||||
void MySQLDatabase::RemoveIgnore(const uint32_t playerId, const uint32_t ignoredPlayerId) {
|
||||
ExecuteDelete("DELETE FROM ignore_list WHERE player_id = ? AND ignored_player_id = ?", playerId, ignoredPlayerId);
|
||||
}
|
||||
Reference in New Issue
Block a user