Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
veloren
veloren
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 303
    • Issues 303
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 27
    • Merge Requests 27
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Veloren
  • velorenveloren
  • Merge Requests
  • !1342

Merged
Opened Aug 29, 2020 by Ben Wallis@xvar🦊Maintainer5 of 5 tasks completed5/5 tasks

Persistence overhaul

  • Overview 204
  • Commits 77
  • Pipelines 48
  • Changes 442
  • By opening this merge request, you agree to release your code and all other changes under the GPL 3 license and to abide by the terms set by this license.
  • Migrations have been added if applicable ...oh yes, yes they have.
  • Significant changes of this merge request have been added to the changelog.

TODO:

  • Ensure the migration is updated if there have been any new item assets added at the point this MR is merged
  • A play test using a clone of the live server database must be undertaken before this MR is merged

Summary

This MR is an overhaul of persistence, the key changes being:

  • Items are no longer stored as JSON in loadouts or inventories
  • Items are now stored individually as records in a new item table
  • Items now have a unique item_id once they have been persisted
  • Structs from the main game engine are no longer directly persisted as serialized JSON and now pass through a conversion layer (conversions.rs)
  • The concept of pesudo-container items has been introduced in order to allow items to belong to a specific player's inventory or loadout, without the need for separate inventory and loadout tables (see below for further description of containers).
  • The inventory and loadout tables have been removed as they are no longer necessary.
  • Item assets are no longer directly loaded via the asset system and are now created with Item::new_from_asset, Item::new_from_asset_expect or Item::new_from_asset_glob
  • Added additional all_items option to the item data export tool
  • Moved migrations to run earlier in server startup
  • Moved character loading and updating code out of character.rs into character_loader.rs and character_updater.rs

Migrations

A full migration from the previous schema is included - there should be no discernible difference for players after this change.

Items / Containers

The new item table supports infinitely nested containers, with each item having a parent_container_item_id which represents the container it exists within. To support this hierarchy, the concept of pseudo-containers has been introduced. These are "pseudo" items that are automatically created for characters - the following types currently exist:

  • World - This is created by the migration added by this MR, and acts as the root container of all items in the database.
  • Character - Created for each character created - uses the Character ID as its item_id and exists to provide a parent for the Inventory and Loadout pseudo-containers
  • Inventory - Created for each character created, the player's inventory items are contained within this pseudo-container
  • Loadout - Created for each character created, the player's loadout items are contained within this pseudo-container
[World]-+
 +--[Character]
 |  +--[Inventory]
 |  |  +--[Bag]
 |  |  |  +--Some Item
 |  |  |  +--[Another Bag]
 |  |  |     +--Cheese        
 |  |  +--Health Potion
 |  +--[Loadout]	
 |     +--Helm Item
 |     +--Boots Item

Although Veloren does not currently support actual containers within a player's inventory such as extra bags etc, this MR lays the foundation for such support to be added with relative ease.

Closes #678 (closed)

Edited Sep 17, 2020 by Joshua Yanovski
Assignee
Assign to
Reviewer
Request review from
None
Milestone
None
Assign milestone
Time tracking
Reference: veloren/veloren!1342
Source branch: xvar/item-persistence

Revert this merge request

This will create a new commit in order to revert the existing changes.

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.

Cherry-pick this merge request

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.