Compare commits

...

9 Commits

Author SHA1 Message Date
bf58cf85cc us static cast and enum 2024-06-07 15:07:37 -05:00
f6f3cdc3c0 fix compiling 2024-06-07 09:31:54 -05:00
66cf96af1a whoops
Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com>
2024-06-06 21:34:29 -05:00
0e6cb8ab19 implict bool
Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com>
2024-06-06 21:34:10 -05:00
42cf2b6377 remove unused code
Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com>
2024-06-06 21:33:42 -05:00
3cfbc9d3df Document what needs to be done
May not do the recursive restriction cause they aren't used in the live game
2024-06-06 21:11:43 -05:00
5ba37ff7d6 fix compiling 2024-06-06 08:50:00 -05:00
8f00f1601c Merge branch 'main' into issue-960 2024-06-06 08:23:41 -05:00
5e3c869141 WIP 2024-06-05 02:39:36 -05:00
9 changed files with 192 additions and 2 deletions

View File

@@ -0,0 +1,55 @@
#ifndef __ECSRCOMMAND__H__
#define __ECSRCOMMAND__H__
#include <cstdint>
enum class eCSRCommand : uint32_t {
QUERY_SERVER_STATUS = 0,
QUERY_CHARACTER_LOCATION,
QUERY_CHARACTER_ONLINE_STATUS,
INVENTORY_ADD_ITEM,
INVENTORY_DELETE_ITEM,
MODERATE_MUTE_ACCOUNT,
MODERATE_BAN_ACCOUNT,
MODERATE_EDUCATE_CHARACTER,
MODERATE_KICK_CHARACTER,
MODERATE_WARN_CHARACTER,
MODERATE_RENAME_CHARACTER,
MODERATE_DELETE_CHARACTER_FRIEND,
MODERATE_KILL_CHARACTER,
UPDATE_CHARACTER_HEALTH,
UPDATE_CHARACTER_ARMOR,
UPDATE_CHARACTER_IMAGINATION,
UPDATE_CHARACTER_MAX_HEALTH,
UPDATE_CHARACTER_MAX_ARMOR,
UPDATE_CHARACTER_MAX_IMAGINATION,
UPDATE_CHARACTER_CURRENCY,
UPDATE_CHARACTER_REPUTATION,
UPDATE_CHARACTER_LEGO_SCORE,
UPDATE_CHARACTER_EMOTES,
UPDATE_CHARACTER_ADD_ACHIEVEMENT,
UPDATE_CHARACTER_COMPLETE_ACHIEVEMENT,
UPDATE_CHARACTER_REMOVE_ACHIEVEMENT,
UPDATE_CHARACTER_POSITION_OFFLINE,
UPDATE_CHARACTER_INV_SLOT_AMOUNT,
UTILITY_SAVE_CHARACTER,
UTILITY_SEND_MAIL,
UTILITY_GIVE_ITEM_TO_ALL_PLAYERS_ONLINE,
METRICS_CONFIGURE,
DISABLE_ZONE,
INIT_DONATION_AMOUNT,
KILL_SERVERS_COUNTDOWN,
DISABLE_FAQ,
THROTTLEQUEUE,
GATEGM_ACCESS,
RECONNECT_CRISP,
MODERATE_KICK_ACCOUNT,
TOGGLE_CRISP_SERVER,
QUICK_DRAIN_SERVER,
QUICK_DRAIN_SERVER_RENEW,
REPLICATE_CHARACTER,
GET_SERVER_STATUS,
RELOAD_SERVER_INIS
};
#endif //!__ECSRCOMMAND__H__

View File

@@ -0,0 +1,16 @@
#ifndef __EDELETIONRESTRICTIONSCHECKTYPE__H__
#define __EDELETIONRESTRICTIONSCHECKTYPE__H__
#include <cstdint>
enum class eDeletionRestrictionsCheckType : uint32_t {
INCLUDE_LOTS,
EXCLUDE_LOTS,
ANY_OF_THESE,
ALL_OF_THESE,
WHILE_IN_ZONE,
ALWAYS_RESTRICTED,
MAX
};
#endif //!__EDELETIONRESTRICTIONSCHECKTYPE__H__

View File

@@ -41,6 +41,7 @@
#include "CDRailActivatorComponent.h"
#include "CDRewardCodesTable.h"
#include "CDPetComponentTable.h"
#include "CDDeletionRestrictionsTable.h"
#ifndef CDCLIENT_CACHE_ALL
// Uncomment this to cache the full cdclient database into memory. This will make the server load faster, but will use more memory.
@@ -103,6 +104,7 @@ DEFINE_TABLE_STORAGE(CDSkillBehaviorTable);
DEFINE_TABLE_STORAGE(CDTamingBuildPuzzleTable);
DEFINE_TABLE_STORAGE(CDVendorComponentTable);
DEFINE_TABLE_STORAGE(CDZoneTableTable);
DEFINE_TABLE_STORAGE(CDDeletionRestrictionsTable)
void CDClientManager::LoadValuesFromDatabase() {
if (!CDClientDatabase::isConnected) {
@@ -150,6 +152,7 @@ void CDClientManager::LoadValuesFromDatabase() {
CDTamingBuildPuzzleTable::Instance().LoadValuesFromDatabase();
CDVendorComponentTable::Instance().LoadValuesFromDatabase();
CDZoneTableTable::Instance().LoadValuesFromDatabase();
CDDeletionRestrictionsTable::Instance().LoadValuesFromDatabase();
}
void CDClientManager::LoadValuesFromDefaults() {

View File

@@ -0,0 +1,45 @@
#include "CDDeletionRestrictionsTable.h"
#include "GeneralUtils.h"
#include "eDeletionRestrictionsCheckType.h"
CDDeletionRestriction CDDeletionRestrictionsTable::Default = {
.id = 0,
.restricted = false,
.ids = {},
.checkType = eDeletionRestrictionsCheckType::MAX
};
void CDDeletionRestrictionsTable::LoadValuesFromDatabase() {
auto& entries = GetEntriesMutable();
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM DeletionRestrictions");
while (!tableData.eof()) {
CDDeletionRestriction entry;
entry.id = tableData.getIntField("id", -1);
if (entry.id == -1) continue;
entry.restricted = tableData.getIntField("restricted", -1);
const std::string raw_ids = tableData.getStringField("ids", "");
if (!raw_ids.empty()) {
for (const auto& idstr : GeneralUtils::SplitString(raw_ids, ',')) {
if (!idstr.empty()) {
const auto id = GeneralUtils::TryParse<int32_t>(idstr);
if (id) entry.ids.push_back(id.value());
}
}
}
entry.checkType = static_cast<eDeletionRestrictionsCheckType>(tableData.getIntField("checkType", static_cast<int>(eDeletionRestrictionsCheckType::MAX)));
entries.insert(std::make_pair(entry.id, entry));
tableData.nextRow();
}
}
const CDDeletionRestriction& CDDeletionRestrictionsTable::GetByID(uint32_t id) {
auto& entries = GetEntries();
const auto& it = entries.find(id);
if (it != entries.end()) {
return it->second;
}
return Default;
}

View File

@@ -0,0 +1,20 @@
#pragma once
#include "CDTable.h"
enum class eDeletionRestrictionsCheckType : uint32_t;
struct CDDeletionRestriction {
uint32_t id;
bool restricted;
std::vector<uint32_t> ids;
eDeletionRestrictionsCheckType checkType;
};
class CDDeletionRestrictionsTable : public CDTable<CDDeletionRestrictionsTable, std::map<uint32_t, CDDeletionRestriction>> {
public:
void LoadValuesFromDatabase();
const CDDeletionRestriction& GetByID(uint32_t id);
static CDDeletionRestriction Default;
};

View File

@@ -33,7 +33,7 @@ struct CDItemComponent {
uint32_t itemRating; //!< ???
bool isTwoHanded; //!< Whether or not the item is double handed
uint32_t minNumRequired; //!< Maybe the minimum number required for a mission, or to own this object?
uint32_t delResIndex; //!< ???
uint32_t delResIndex; //!< Relates to DeletionRestrictions Table
uint32_t currencyLOT; //!< ???
uint32_t altCurrencyCost; //!< ???
std::string subItems; //!< A comma seperate string of sub items (maybe for multi-itemed things like faction test gear set)

View File

@@ -38,4 +38,6 @@ set(DDATABASE_CDCLIENTDATABASE_CDCLIENTTABLES_SOURCES "CDActivitiesTable.cpp"
"CDSkillBehaviorTable.cpp"
"CDTamingBuildPuzzleTable.cpp"
"CDVendorComponentTable.cpp"
"CDZoneTableTable.cpp" PARENT_SCOPE)
"CDZoneTableTable.cpp"
"CDDeletionRestrictionsTable.cpp"
PARENT_SCOPE)

View File

@@ -21,11 +21,13 @@
#include "eUseItemResponse.h"
#include "dZoneManager.h"
#include "ChatPackets.h"
#include "eDeletionRestrictionsCheckType.h"
#include "CDBrickIDTableTable.h"
#include "CDObjectSkillsTable.h"
#include "CDComponentsRegistryTable.h"
#include "CDPackageComponentTable.h"
#include "CDDeletionRestrictionsTable.h"
namespace {
const std::map<std::string, std::string> ExtraSettingAbbreviations = {
@@ -568,3 +570,43 @@ void Item::LoadConfigXml(const tinyxml2::XMLElement& i) {
config.push_back(LDFBaseData::DataFromString(value));
}
}
bool Item::CanDeleteItem(Item* item) {
if (!item) return false;
// TODO:
// Check if item is being possessed
// Check if the owner is mounting item? (how is this different than the above)
// Allow GM 9 to freely delete
// Finally, check Deletion Restriction
const auto& itemComponent = item->inventory->FindItemComponent(item->lot);
if (itemComponent.delResIndex == -1) return true;
return CheckDeletionRestriction(itemComponent.delResIndex, item->lot);
}
bool Item::CheckDeletionRestriction(uint32_t delResIndex, LOT item) {
auto* delresTable = CDClientManager::GetTable<CDDeletionRestrictionsTable>();
const auto restriction = delresTable->GetByID(delResIndex);
switch(restriction.checkType) {
case eDeletionRestrictionsCheckType::INCLUDE_LOTS:
if (std::ranges::find(restriction.ids, item) != restriction.ids.end()) return false;
else return true;
case eDeletionRestrictionsCheckType::EXCLUDE_LOTS:
if (std::ranges::find(restriction.ids, item) != restriction.ids.end()) return true;
else return false;
case eDeletionRestrictionsCheckType::ANY_OF_THESE:
// TODO: Implement
return true;
case eDeletionRestrictionsCheckType::ALL_OF_THESE:
// TODO: Implement
return true;
case eDeletionRestrictionsCheckType::WHILE_IN_ZONE:
if (std::ranges::find(restriction.ids, Game::zoneManager->GetZoneID().GetMapID()) != restriction.ids.end()) return false;
else return true;
case eDeletionRestrictionsCheckType::ALWAYS_RESTRICTED:
return false;
case eDeletionRestrictionsCheckType::MAX:
default:
return true;
}
}

View File

@@ -228,6 +228,13 @@ public:
void LoadConfigXml(const tinyxml2::XMLElement& i);
bool CanDeleteItem(Item* item);
bool CheckDeletionRestriction(uint32_t delResIndex, LOT item);
bool CheckDeletionRestrictionRecursion(std::set<uint32_t>& delResIndexs, uint32_t delResIndex);
private:
/**
* The object ID of this item