mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 22:58:34 +00:00
[Fix] Fixes for corpses not properly saving some item instance data correctly. (#3123)
* Convert ZoneDb::LoadCharacterCorpseData to use a cleaner api that has a better layout. * Update corpse save methods to use a new cleaner api. * Add item to corpse will use a few new fields that don't yet save. * Fix for some issues moving data to corpses. * Make CreateItem more explicit to avoid overlooking places it's used and add more arguments. * DB changes * Revert of the changes to the database.CreateItem api change. * Missed one. * Fixes for mr Krab * Small formatting --------- Co-authored-by: KimLS <KimLS@peqtgc.com> Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
@@ -5522,7 +5522,11 @@ struct ServerLootItem_Struct {
|
||||
uint32 aug_4; // uint32 aug_4;
|
||||
uint32 aug_5; // uint32 aug_5;
|
||||
uint32 aug_6; // uint32 aug_5;
|
||||
uint8 attuned;
|
||||
bool attuned;
|
||||
std::string custom_data;
|
||||
uint32 ornamenticon;
|
||||
uint32 ornamentidfile;
|
||||
uint32 ornament_hero_model;
|
||||
uint16 trivial_min_level;
|
||||
uint16 trivial_max_level;
|
||||
uint16 npc_min_level;
|
||||
|
||||
@@ -203,12 +203,12 @@ namespace EQ
|
||||
void dumpBankItems();
|
||||
void dumpSharedBankItems();
|
||||
|
||||
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, std::string value);
|
||||
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, int value);
|
||||
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, float value);
|
||||
void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, bool value);
|
||||
std::string GetCustomItemData(int16 slot_id, std::string identifier);
|
||||
static const int GetItemStatValue(uint32 item_id, std::string identifier);
|
||||
void SetCustomItemData(uint32 character_id, int16 slot_id, const std::string &identifier, const std::string& value);
|
||||
void SetCustomItemData(uint32 character_id, int16 slot_id, const std::string &identifier, int value);
|
||||
void SetCustomItemData(uint32 character_id, int16 slot_id, const std::string &identifier, float value);
|
||||
void SetCustomItemData(uint32 character_id, int16 slot_id, const std::string &identifier, bool value);
|
||||
std::string GetCustomItemData(int16 slot_id, const std::string& identifier);
|
||||
static const int GetItemStatValue(uint32 item_id, const std::string& identifier);
|
||||
protected:
|
||||
///////////////////////////////
|
||||
// Protected Methods
|
||||
|
||||
@@ -840,7 +840,20 @@ std::string EQ::ItemInstance::GetCustomDataString() const {
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
std::string EQ::ItemInstance::GetCustomData(std::string identifier) {
|
||||
void EQ::ItemInstance::SetCustomDataString(const std::string& str)
|
||||
{
|
||||
auto components = Strings::Split(str, "^");
|
||||
auto value_count = components.size() / 2;
|
||||
|
||||
for (auto i = 0; i < value_count; i++) {
|
||||
auto identifier = components[i * 2];
|
||||
auto value = components[(i * 2) + 1];
|
||||
|
||||
SetCustomData(identifier, value);
|
||||
}
|
||||
}
|
||||
|
||||
std::string EQ::ItemInstance::GetCustomData(const std::string& identifier) {
|
||||
std::map<std::string, std::string>::const_iterator iter = m_custom_data.find(identifier);
|
||||
if (iter != m_custom_data.end()) {
|
||||
return iter->second;
|
||||
@@ -849,33 +862,33 @@ std::string EQ::ItemInstance::GetCustomData(std::string identifier) {
|
||||
return "";
|
||||
}
|
||||
|
||||
void EQ::ItemInstance::SetCustomData(std::string identifier, std::string value) {
|
||||
void EQ::ItemInstance::SetCustomData(const std::string& identifier, const std::string& value) {
|
||||
DeleteCustomData(identifier);
|
||||
m_custom_data[identifier] = value;
|
||||
}
|
||||
|
||||
void EQ::ItemInstance::SetCustomData(std::string identifier, int value) {
|
||||
void EQ::ItemInstance::SetCustomData(const std::string& identifier, int value) {
|
||||
DeleteCustomData(identifier);
|
||||
std::stringstream ss;
|
||||
ss << value;
|
||||
m_custom_data[identifier] = ss.str();
|
||||
}
|
||||
|
||||
void EQ::ItemInstance::SetCustomData(std::string identifier, float value) {
|
||||
void EQ::ItemInstance::SetCustomData(const std::string& identifier, float value) {
|
||||
DeleteCustomData(identifier);
|
||||
std::stringstream ss;
|
||||
ss << value;
|
||||
m_custom_data[identifier] = ss.str();
|
||||
}
|
||||
|
||||
void EQ::ItemInstance::SetCustomData(std::string identifier, bool value) {
|
||||
void EQ::ItemInstance::SetCustomData(const std::string& identifier, bool value) {
|
||||
DeleteCustomData(identifier);
|
||||
std::stringstream ss;
|
||||
ss << value;
|
||||
m_custom_data[identifier] = ss.str();
|
||||
}
|
||||
|
||||
void EQ::ItemInstance::DeleteCustomData(std::string identifier) {
|
||||
void EQ::ItemInstance::DeleteCustomData(const std::string& identifier) {
|
||||
auto iter = m_custom_data.find(identifier);
|
||||
if (iter != m_custom_data.end()) {
|
||||
m_custom_data.erase(iter);
|
||||
|
||||
@@ -175,12 +175,13 @@ namespace EQ
|
||||
void SetAttuned(bool flag) { m_attuned = flag; }
|
||||
|
||||
std::string GetCustomDataString() const;
|
||||
std::string GetCustomData(std::string identifier);
|
||||
void SetCustomData(std::string identifier, std::string value);
|
||||
void SetCustomData(std::string identifier, int value);
|
||||
void SetCustomData(std::string identifier, float value);
|
||||
void SetCustomData(std::string identifier, bool value);
|
||||
void DeleteCustomData(std::string identifier);
|
||||
std::string GetCustomData(const std::string &identifier);
|
||||
void SetCustomDataString(const std::string& str);
|
||||
void SetCustomData(const std::string &identifier, const std::string& value);
|
||||
void SetCustomData(const std::string &identifier, int value);
|
||||
void SetCustomData(const std::string &identifier, float value);
|
||||
void SetCustomData(const std::string &identifier, bool value);
|
||||
void DeleteCustomData(const std::string& identifier);
|
||||
|
||||
// Allows treatment of this object as though it were a pointer to m_item
|
||||
operator bool() const { return (m_item != nullptr); }
|
||||
|
||||
+21
-67
@@ -548,27 +548,7 @@ bool SharedDatabase::GetSharedBank(uint32 id, EQ::InventoryProfile *inv, bool is
|
||||
|
||||
if (inst && row[9]) {
|
||||
std::string data_str(row[9]);
|
||||
std::string idAsString;
|
||||
std::string value;
|
||||
bool use_id = true;
|
||||
|
||||
for (int i = 0; i < data_str.length(); ++i) {
|
||||
if (data_str[i] == '^') {
|
||||
if (!use_id) {
|
||||
inst->SetCustomData(idAsString, value);
|
||||
idAsString.clear();
|
||||
value.clear();
|
||||
}
|
||||
use_id = !use_id;
|
||||
continue;
|
||||
}
|
||||
|
||||
const char v = data_str[i];
|
||||
if (use_id)
|
||||
idAsString.push_back(v);
|
||||
else
|
||||
value.push_back(v);
|
||||
}
|
||||
inst->SetCustomDataString(data_str);
|
||||
}
|
||||
|
||||
// theoretically inst can be nullptr ... this would be very bad ...
|
||||
@@ -679,28 +659,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, EQ::InventoryProfile *inv)
|
||||
|
||||
if (row[11]) {
|
||||
std::string data_str(row[11]);
|
||||
std::string idAsString;
|
||||
std::string value;
|
||||
bool use_id = true;
|
||||
|
||||
for (int i = 0; i < data_str.length(); ++i) {
|
||||
if (data_str[i] == '^') {
|
||||
if (!use_id) {
|
||||
inst->SetCustomData(idAsString, value);
|
||||
idAsString.clear();
|
||||
value.clear();
|
||||
}
|
||||
|
||||
use_id = !use_id;
|
||||
continue;
|
||||
}
|
||||
|
||||
const char v = data_str[i];
|
||||
if (use_id)
|
||||
idAsString.push_back(v);
|
||||
else
|
||||
value.push_back(v);
|
||||
}
|
||||
inst->SetCustomDataString(data_str);
|
||||
}
|
||||
|
||||
inst->SetOrnamentIcon(ornament_icon);
|
||||
@@ -825,28 +784,7 @@ bool SharedDatabase::GetInventory(uint32 account_id, char *name, EQ::InventoryPr
|
||||
|
||||
if (row[11]) {
|
||||
std::string data_str(row[11]);
|
||||
std::string idAsString;
|
||||
std::string value;
|
||||
bool use_id = true;
|
||||
|
||||
for (int i = 0; i < data_str.length(); ++i) {
|
||||
if (data_str[i] == '^') {
|
||||
if (!use_id) {
|
||||
inst->SetCustomData(idAsString, value);
|
||||
idAsString.clear();
|
||||
value.clear();
|
||||
}
|
||||
|
||||
use_id = !use_id;
|
||||
continue;
|
||||
}
|
||||
|
||||
const char v = data_str[i];
|
||||
if (use_id)
|
||||
idAsString.push_back(v);
|
||||
else
|
||||
value.push_back(v);
|
||||
}
|
||||
inst->SetCustomDataString(data_str);
|
||||
}
|
||||
|
||||
inst->SetOrnamentIcon(ornament_icon);
|
||||
@@ -1544,7 +1482,11 @@ EQ::ItemInstance* SharedDatabase::CreateItem(
|
||||
uint32 aug4,
|
||||
uint32 aug5,
|
||||
uint32 aug6,
|
||||
bool attuned
|
||||
bool attuned,
|
||||
const std::string& custom_data,
|
||||
uint32 ornamenticon,
|
||||
uint32 ornamentidfile,
|
||||
uint32 ornament_hero_model
|
||||
) {
|
||||
EQ::ItemInstance* inst = nullptr;
|
||||
|
||||
@@ -1565,6 +1507,10 @@ EQ::ItemInstance* SharedDatabase::CreateItem(
|
||||
inst->PutAugment(this, 4, aug5);
|
||||
inst->PutAugment(this, 5, aug6);
|
||||
inst->SetAttuned(attuned);
|
||||
inst->SetCustomDataString(custom_data);
|
||||
inst->SetOrnamentIcon(ornamenticon);
|
||||
inst->SetOrnamentationIDFile(ornamentidfile);
|
||||
inst->SetOrnamentHeroModel(ornament_hero_model);
|
||||
}
|
||||
|
||||
return inst;
|
||||
@@ -1581,7 +1527,11 @@ EQ::ItemInstance* SharedDatabase::CreateItem(
|
||||
uint32 aug4,
|
||||
uint32 aug5,
|
||||
uint32 aug6,
|
||||
bool attuned
|
||||
bool attuned,
|
||||
const std::string& custom_data,
|
||||
uint32 ornamenticon,
|
||||
uint32 ornamentidfile,
|
||||
uint32 ornament_hero_model
|
||||
) {
|
||||
EQ::ItemInstance* inst = nullptr;
|
||||
if (item) {
|
||||
@@ -1600,6 +1550,10 @@ EQ::ItemInstance* SharedDatabase::CreateItem(
|
||||
inst->PutAugment(this, 4, aug5);
|
||||
inst->PutAugment(this, 5, aug6);
|
||||
inst->SetAttuned(attuned);
|
||||
inst->SetCustomDataString(custom_data);
|
||||
inst->SetOrnamentIcon(ornamenticon);
|
||||
inst->SetOrnamentationIDFile(ornamentidfile);
|
||||
inst->SetOrnamentHeroModel(ornament_hero_model);
|
||||
}
|
||||
|
||||
return inst;
|
||||
|
||||
+10
-2
@@ -126,7 +126,11 @@ public:
|
||||
uint32 aug4 = 0,
|
||||
uint32 aug5 = 0,
|
||||
uint32 aug6 = 0,
|
||||
bool attuned = 0
|
||||
bool attuned = false,
|
||||
const std::string& custom_data = "",
|
||||
uint32 ornamenticon = 0,
|
||||
uint32 ornamentidfile = 0,
|
||||
uint32 ornament_hero_model = 0
|
||||
);
|
||||
EQ::ItemInstance *CreateItem(
|
||||
const EQ::ItemData *item,
|
||||
@@ -137,7 +141,11 @@ public:
|
||||
uint32 aug4 = 0,
|
||||
uint32 aug5 = 0,
|
||||
uint32 aug6 = 0,
|
||||
bool attuned = 0
|
||||
bool attuned = false,
|
||||
const std::string &custom_data = "",
|
||||
uint32 ornamenticon = 0,
|
||||
uint32 ornamentidfile = 0,
|
||||
uint32 ornament_hero_model = 0
|
||||
);
|
||||
EQ::ItemInstance *CreateBaseItem(const EQ::ItemData *item, int16 charges = 0);
|
||||
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@
|
||||
* Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt
|
||||
*/
|
||||
|
||||
#define CURRENT_BINARY_DATABASE_VERSION 9225
|
||||
#define CURRENT_BINARY_DATABASE_VERSION 9226
|
||||
|
||||
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9038
|
||||
|
||||
|
||||
Reference in New Issue
Block a user