mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Hash value now stored as a blob instead of a json string.
This commit is contained in:
parent
903c57b862
commit
8feb9fb67b
@ -42,13 +42,13 @@ CREATE TABLE _skill_group
|
|||||||
earned_exp INTEGER NOT NULL,
|
earned_exp INTEGER NOT NULL,
|
||||||
spent_exp INTEGER NOT NULL,
|
spent_exp INTEGER NOT NULL,
|
||||||
skills TEXT NOT NULL,
|
skills TEXT NOT NULL,
|
||||||
hash_val TEXT NOT NULL,
|
hash_val BLOB NOT NULL,
|
||||||
FOREIGN KEY(entity_id) REFERENCES entity(entity_id),
|
FOREIGN KEY(entity_id) REFERENCES entity(entity_id),
|
||||||
PRIMARY KEY(entity_id,skill_group_kind)
|
PRIMARY KEY(entity_id,skill_group_kind)
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO _skill_group
|
INSERT INTO _skill_group
|
||||||
SELECT sg.entity_id, sg.skill_group_kind, sg.exp, 0, "", ""
|
SELECT sg.entity_id, sg.skill_group_kind, sg.exp, 0, "", x'0000000000000000000000000000000000000000000000000000000000000000'
|
||||||
FROM skill_group sg;
|
FROM skill_group sg;
|
||||||
|
|
||||||
-- Skills now tracked in skill_group table, can ust drop
|
-- Skills now tracked in skill_group table, can ust drop
|
||||||
|
@ -552,10 +552,7 @@ fn convert_skill_groups_from_database(
|
|||||||
// hash of the skill group, don't invalidate skills; otherwise invalidate the
|
// hash of the skill group, don't invalidate skills; otherwise invalidate the
|
||||||
// skills in this skill_group.
|
// skills in this skill_group.
|
||||||
if skill_group.spent_exp as u32 == new_skill_group.spent_exp
|
if skill_group.spent_exp as u32 == new_skill_group.spent_exp
|
||||||
&& serde_json::from_str::<Vec<u8>>(&skill_group.hash_val)
|
&& Some(&skill_group.hash_val) == skillset::SKILL_GROUP_HASHES.get(&skill_group_kind)
|
||||||
.ok()
|
|
||||||
.as_ref()
|
|
||||||
== skillset::SKILL_GROUP_HASHES.get(&skill_group_kind)
|
|
||||||
{
|
{
|
||||||
let mut new_skills =
|
let mut new_skills =
|
||||||
serde_json::from_str::<Vec<skills::Skill>>(&skill_group.skills).unwrap_or_default();
|
serde_json::from_str::<Vec<skills::Skill>>(&skill_group.skills).unwrap_or_default();
|
||||||
@ -580,10 +577,10 @@ pub fn convert_skill_groups_to_database(
|
|||||||
spent_exp: sg.spent_exp as i32,
|
spent_exp: sg.spent_exp as i32,
|
||||||
// If fails to convert, just forces a respec on next login
|
// If fails to convert, just forces a respec on next login
|
||||||
skills: serde_json::to_string(&sg.ordered_skills).unwrap_or_else(|_| "".to_string()),
|
skills: serde_json::to_string(&sg.ordered_skills).unwrap_or_else(|_| "".to_string()),
|
||||||
hash_val: serde_json::to_string(
|
hash_val: skillset::SKILL_GROUP_HASHES
|
||||||
&skillset::SKILL_GROUP_HASHES.get(&sg.skill_group_kind),
|
.get(&sg.skill_group_kind)
|
||||||
)
|
.cloned()
|
||||||
.unwrap_or_else(|_| "".to_string()),
|
.unwrap_or_default(),
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ pub struct SkillGroup {
|
|||||||
pub earned_exp: i32,
|
pub earned_exp: i32,
|
||||||
pub spent_exp: i32,
|
pub spent_exp: i32,
|
||||||
pub skills: String,
|
pub skills: String,
|
||||||
pub hash_val: String,
|
pub hash_val: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Pet {
|
pub struct Pet {
|
||||||
|
Loading…
Reference in New Issue
Block a user