mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Slight optimization to persistence
This commit is contained in:
@ -1098,6 +1098,13 @@ impl Item {
|
|||||||
|
|
||||||
pub fn item_hash(&self) -> u64 { self.hash }
|
pub fn item_hash(&self) -> u64 { self.hash }
|
||||||
|
|
||||||
|
pub fn persistence_item_id(&self) -> &str {
|
||||||
|
match &self.item_base {
|
||||||
|
ItemBase::Simple(item_def) => &item_def.item_definition_id,
|
||||||
|
ItemBase::Modular(mod_base) => mod_base.pseudo_item_id(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub fn create_test_item_from_kind(kind: ItemKind) -> Self {
|
pub fn create_test_item_from_kind(kind: ItemKind) -> Self {
|
||||||
let ability_map = &AbilityMap::load().read();
|
let ability_map = &AbilityMap::load().read();
|
||||||
|
@ -11,7 +11,7 @@ use common::{
|
|||||||
character::CharacterId,
|
character::CharacterId,
|
||||||
comp::{
|
comp::{
|
||||||
inventory::{
|
inventory::{
|
||||||
item::{tool::AbilityMap, Item as VelorenItem, ItemDefinitionId, MaterialStatManifest},
|
item::{tool::AbilityMap, Item as VelorenItem, MaterialStatManifest},
|
||||||
loadout::{Loadout, LoadoutError},
|
loadout::{Loadout, LoadoutError},
|
||||||
loadout_builder::LoadoutBuilder,
|
loadout_builder::LoadoutBuilder,
|
||||||
slot::InvSlotId,
|
slot::InvSlotId,
|
||||||
@ -165,15 +165,9 @@ pub fn convert_items_to_database_items(
|
|||||||
bfs_queue.push_back((format!("component_{}", i), Some(component), item_id));
|
bfs_queue.push_back((format!("component_{}", i), Some(component), item_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
let persistence_item_id = match item.item_definition_id() {
|
|
||||||
ItemDefinitionId::Simple(id) => id.to_owned(),
|
|
||||||
ItemDefinitionId::Compound { simple_base, .. } => simple_base.to_owned(),
|
|
||||||
ItemDefinitionId::Modular { pseudo_base, .. } => pseudo_base.to_owned(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let upsert = ItemModelPair {
|
let upsert = ItemModelPair {
|
||||||
model: Item {
|
model: Item {
|
||||||
item_definition_id: persistence_item_id,
|
item_definition_id: String::from(item.persistence_item_id()),
|
||||||
position,
|
position,
|
||||||
parent_container_item_id,
|
parent_container_item_id,
|
||||||
item_id,
|
item_id,
|
||||||
|
Reference in New Issue
Block a user