feat: loading entities (WIP)

This commit is contained in:
MihailRis
2024-07-05 22:51:03 +03:00
parent 08cc78289d
commit c8666910ce
16 changed files with 129 additions and 38 deletions
+7 -10
View File
@@ -251,10 +251,9 @@ void Player::deserialize(dynamic::Map *src) {
src->flag("flight", flight);
src->flag("noclip", noclip);
setChosenSlot(src->get("chosen-slot", getChosenSlot()));
auto invmap = src->map("inventory");
if (invmap) {
getInventory()->deserialize(invmap);
if (auto invmap = src->map("inventory")) {
getInventory()->deserialize(invmap.get());
}
}
@@ -264,16 +263,14 @@ void Player::convert(dynamic::Map* data, const ContentLUT* lut) {
if (players) {
for (uint i = 0; i < players->size(); i++) {
auto playerData = players->map(i);
auto inventory = playerData->map("inventory");
if (inventory) {
Inventory::convert(inventory, lut);
if (auto inventory = playerData->map("inventory")) {
Inventory::convert(inventory.get(), lut);
}
}
} else {
auto inventory = data->map("inventory");
if (inventory) {
Inventory::convert(inventory, lut);
if (auto inventory = data->map("inventory")) {
Inventory::convert(inventory.get(), lut);
}
}
}