mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 11:01:49 +00:00
inventory reindexing
This commit is contained in:
parent
1409df4b86
commit
51ffb93230
12 changed files with 174 additions and 51 deletions
|
|
@ -1,5 +1,7 @@
|
|||
#include "Inventory.h"
|
||||
|
||||
#include "../content/ContentLUT.h"
|
||||
|
||||
Inventory::Inventory(size_t size) : slots(size) {
|
||||
}
|
||||
|
||||
|
|
@ -71,4 +73,13 @@ std::unique_ptr<dynamic::Map> Inventory::write() const {
|
|||
return map;
|
||||
}
|
||||
|
||||
void Inventory::convert(dynamic::Map* data, const ContentLUT* lut) {
|
||||
auto slotsarr = data->list("slots");
|
||||
for (size_t i = 0; i < slotsarr->size(); i++) {
|
||||
auto item = slotsarr->map(i);
|
||||
itemid_t id = item->getInt("id", ITEM_EMPTY);
|
||||
item->put("id", lut->getItemId(id));
|
||||
}
|
||||
}
|
||||
|
||||
const size_t Inventory::npos = -1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue