mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-06 11:57:13 +00:00
Deleting an item now follows the item's DeletionRestrictions row (ItemComponent.delResIndex), as the client's LWOInventoryComponent_Common::CanRemoveFromInventory (0x00ce0d20) and CheckDeletionRestrictionIndex (0x00c94c20) do: an item the player is driving or riding can't be deleted, an operator can delete anything, and otherwise the row decides: - LOTS_INCLUDED: only while the player has another item of any of the LOTs (the last rocket can't be deleted) - LOTS_EXCLUDED: only while the player has other items of all of the LOTs - ANY_RESTRICTION / ALL_RESTRICTIONS: any / all of the listed rows allow it (a row that names itself again allows it) - ZONE: only in the listed zones - ALWAYS_RESTRICTED: never A missing, unrestricted or bad row (no valid ids, unknown check type) allows it. The client checks first and shows the row's failure reason; the server checks again and ignores a client's forceDeletion. Refs issue 960 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
33 lines
1.3 KiB
C++
33 lines
1.3 KiB
C++
#include "CDDeletionRestrictionsTable.h"
|
|
#include "GeneralUtils.h"
|
|
#include "eDeletionRestrictionsCheckType.h"
|
|
|
|
void CDDeletionRestrictionsTable::LoadValuesFromDatabase() {
|
|
auto& entries = GetEntriesMutable();
|
|
|
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM DeletionRestrictions");
|
|
while (!tableData.eof()) {
|
|
CDDeletionRestriction entry;
|
|
entry.id = tableData.getIntField("id", 0);
|
|
entry.restricted = tableData.getIntField("restricted", 0) != 0;
|
|
for (auto id : GeneralUtils::SplitString(tableData.getStringField("ids", ""), ',')) {
|
|
// The ids are written with spaces around them
|
|
id.erase(0, id.find_first_not_of(" \t"));
|
|
id.erase(id.find_last_not_of(" \t") + 1);
|
|
const auto parsed = GeneralUtils::TryParse<uint32_t>(id);
|
|
if (parsed) entry.ids.push_back(*parsed);
|
|
}
|
|
entry.checkType = static_cast<eDeletionRestrictionsCheckType>(tableData.getIntField("checkType", static_cast<int>(eDeletionRestrictionsCheckType::MAX)));
|
|
|
|
entries.insert_or_assign(entry.id, entry);
|
|
tableData.nextRow();
|
|
}
|
|
}
|
|
|
|
std::optional<CDDeletionRestriction> CDDeletionRestrictionsTable::GetByID(const uint32_t id) const {
|
|
const auto& entries = GetEntries();
|
|
const auto it = entries.find(id);
|
|
if (it == entries.end()) return std::nullopt;
|
|
return it->second;
|
|
}
|