mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-08-03 11:17:05 -04:00
Apply suggestions from code review
This commit is contained in:
parent
67261a4060
commit
43cc33d483
@ -594,7 +594,7 @@ pub const ServerWorld = struct { // MARK: ServerWorld
|
||||
std.log.debug("Item #{}: {} x {s}", .{i, stack.amount, if(stack.item) |item| item.id() else "null"});
|
||||
}
|
||||
|
||||
const base64Data = savePlayerInventory(temp, main.stackAllocator);
|
||||
const base64Data = savePlayerInventory(main.stackAllocator, temp);
|
||||
const old = playerData.object.fetchPut(key, .{.stringOwned = base64Data}) catch unreachable orelse unreachable;
|
||||
old.value.deinit(main.stackAllocator);
|
||||
},
|
||||
@ -965,7 +965,7 @@ pub const ServerWorld = struct { // MARK: ServerWorld
|
||||
return main.items.Inventory.Sync.ServerSide.createExternallyManagedInventory(size, .normal, source, &reader);
|
||||
}
|
||||
|
||||
fn savePlayerInventory(inv: main.items.Inventory, allocator: NeverFailingAllocator) []const u8 {
|
||||
fn savePlayerInventory(allocator: NeverFailingAllocator, inv: main.items.Inventory) []const u8 {
|
||||
var writer = main.utils.BinaryWriter.init(main.stackAllocator);
|
||||
defer writer.deinit();
|
||||
|
||||
@ -1000,11 +1000,11 @@ pub const ServerWorld = struct { // MARK: ServerWorld
|
||||
main.items.Inventory.Sync.ServerSide.mutex.lock();
|
||||
defer main.items.Inventory.Sync.ServerSide.mutex.unlock();
|
||||
if(main.items.Inventory.Sync.ServerSide.getInventoryFromSource(.{.playerInventory = user.id})) |inv| {
|
||||
playerZon.put("playerInventory", ZonElement{.stringOwned = savePlayerInventory(inv, main.stackAllocator)});
|
||||
playerZon.put("playerInventory", ZonElement{.stringOwned = savePlayerInventory(main.stackAllocator, inv)});
|
||||
} else @panic("The player inventory wasn't found. Cannot save player data.");
|
||||
|
||||
if(main.items.Inventory.Sync.ServerSide.getInventoryFromSource(.{.hand = user.id})) |inv| {
|
||||
playerZon.put("hand", ZonElement{.stringOwned = savePlayerInventory(inv, main.stackAllocator)});
|
||||
playerZon.put("hand", ZonElement{.stringOwned = savePlayerInventory(main.stackAllocator, inv)});
|
||||
} else @panic("The player hand inventory wasn't found. Cannot save player data.");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user