mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-06-14 02:34:20 +00:00
Migrate more members
This commit is contained in:
@@ -31,5 +31,5 @@ struct EquippedItem
|
||||
/**
|
||||
* The configuration of the item with any extra data
|
||||
*/
|
||||
std::vector<LDFBaseData*> config = {};
|
||||
LwoNameValue config = {};
|
||||
};
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "CDObjectSkillsTable.h"
|
||||
#include "CDComponentsRegistryTable.h"
|
||||
#include "CDPackageComponentTable.h"
|
||||
#include <ranges>
|
||||
|
||||
namespace {
|
||||
const std::map<std::string, std::string> ExtraSettingAbbreviations = {
|
||||
@@ -46,7 +47,7 @@ namespace {
|
||||
};
|
||||
}
|
||||
|
||||
Item::Item(const LWOOBJID id, const LOT lot, Inventory* inventory, const uint32_t slot, const uint32_t count, const bool bound, const std::vector<LDFBaseData*>& config, const LWOOBJID parent, LWOOBJID subKey, eLootSourceType lootSourceType) {
|
||||
Item::Item(const LWOOBJID id, const LOT lot, Inventory* inventory, const uint32_t slot, const uint32_t count, const bool bound, const LwoNameValue& config, const LWOOBJID parent, LWOOBJID subKey, eLootSourceType lootSourceType) {
|
||||
if (!Inventory::IsValidItem(lot)) {
|
||||
return;
|
||||
}
|
||||
@@ -71,7 +72,7 @@ Item::Item(
|
||||
Inventory* inventory,
|
||||
const uint32_t slot,
|
||||
const uint32_t count,
|
||||
const std::vector<LDFBaseData*>& config,
|
||||
const LwoNameValue& config,
|
||||
const LWOOBJID parent,
|
||||
bool showFlyingLoot,
|
||||
bool isModMoveAndEquip,
|
||||
@@ -131,11 +132,11 @@ uint32_t Item::GetSlot() const {
|
||||
return slot;
|
||||
}
|
||||
|
||||
std::vector<LDFBaseData*> Item::GetConfig() const {
|
||||
const LwoNameValue& Item::GetConfig() const {
|
||||
return config;
|
||||
}
|
||||
|
||||
std::vector<LDFBaseData*>& Item::GetConfig() {
|
||||
LwoNameValue& Item::GetConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -379,7 +380,7 @@ void Item::UseNonEquip(Item* item) {
|
||||
}
|
||||
|
||||
void Item::Disassemble(const eInventoryType inventoryType) {
|
||||
for (auto* data : config) {
|
||||
for (const auto& data : config.values | std::views::values) {
|
||||
if (data->GetKey() == u"assemblyPartLOTs") {
|
||||
auto modStr = data->GetValueAsString();
|
||||
|
||||
@@ -530,18 +531,12 @@ void Item::RemoveFromInventory() {
|
||||
|
||||
Item::~Item() {
|
||||
delete preconditions;
|
||||
|
||||
for (auto* value : config) {
|
||||
delete value;
|
||||
}
|
||||
|
||||
config.clear();
|
||||
}
|
||||
|
||||
void Item::SaveConfigXml(tinyxml2::XMLElement& i) const {
|
||||
tinyxml2::XMLElement* x = nullptr;
|
||||
|
||||
for (const auto* config : this->config) {
|
||||
for (const auto& config : config.values | std::views::values) {
|
||||
const auto& key = GeneralUtils::UTF16ToWTF8(config->GetKey());
|
||||
const auto saveKey = ExtraSettingAbbreviations.find(key);
|
||||
if (saveKey == ExtraSettingAbbreviations.end()) {
|
||||
@@ -561,12 +556,12 @@ void Item::LoadConfigXml(const tinyxml2::XMLElement& i) {
|
||||
const auto* x = i.FirstChildElement("x");
|
||||
if (!x) return;
|
||||
|
||||
for (const auto& pair : ExtraSettingAbbreviations) {
|
||||
const auto* data = x->Attribute(pair.second.c_str());
|
||||
for (const auto& [fullName, abbreviation] : ExtraSettingAbbreviations) {
|
||||
const auto* data = x->Attribute(abbreviation.c_str());
|
||||
if (!data) continue;
|
||||
|
||||
const auto value = pair.first + "=" + data;
|
||||
config.push_back(LDFBaseData::DataFromString(value));
|
||||
auto* const newPtr = LDFBaseData::DataFromString(fullName + "=" + data);
|
||||
config.values.insert_or_assign(newPtr->GetKey(), std::unique_ptr<LDFBaseData>(newPtr));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
uint32_t slot,
|
||||
uint32_t count,
|
||||
bool bound,
|
||||
const std::vector<LDFBaseData*>& config,
|
||||
const LwoNameValue& config,
|
||||
LWOOBJID parent,
|
||||
LWOOBJID subKey,
|
||||
eLootSourceType lootSourceType = eLootSourceType::NONE
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
Inventory* inventory,
|
||||
uint32_t slot = 0,
|
||||
uint32_t count = 1,
|
||||
const std::vector<LDFBaseData*>& config = {},
|
||||
const LwoNameValue& config = {},
|
||||
LWOOBJID parent = LWOOBJID_EMPTY,
|
||||
bool showFlyingLoot = true,
|
||||
bool isModMoveAndEquip = false,
|
||||
@@ -118,13 +118,13 @@ public:
|
||||
* Returns current config info for this item, e.g. for rockets
|
||||
* @return current config info for this item
|
||||
*/
|
||||
std::vector<LDFBaseData*>& GetConfig();
|
||||
LwoNameValue& GetConfig();
|
||||
|
||||
/**
|
||||
* Returns current config info for this item, e.g. for rockets
|
||||
* @return current config info for this item
|
||||
*/
|
||||
std::vector<LDFBaseData*> GetConfig() const;
|
||||
const LwoNameValue& GetConfig() const;
|
||||
|
||||
/**
|
||||
* Returns the database info for this item
|
||||
@@ -269,7 +269,7 @@ private:
|
||||
/**
|
||||
* Config data for this item, e.g. for rocket parts and car parts
|
||||
*/
|
||||
std::vector<LDFBaseData*> config;
|
||||
LwoNameValue config;
|
||||
|
||||
/**
|
||||
* The inventory this item belongs to
|
||||
|
||||
Reference in New Issue
Block a user