Reset the client-side inventory sync after leaving a world.

should fix #1461
This commit is contained in:
IntegratedQuantum 2025-05-18 13:05:34 +02:00
parent 6596835cf3
commit f5fd3356d9
2 changed files with 8 additions and 3 deletions

View File

@ -36,6 +36,13 @@ pub const Sync = struct { // MARK: Sync
}
pub fn deinit() void {
reset();
commands.deinit();
freeIdList.deinit();
serverToClientMap.deinit();
}
pub fn reset() void {
mutex.lock();
while(commands.dequeue()) |cmd| {
var reader = utils.BinaryReader.init(&.{});
@ -44,10 +51,7 @@ pub const Sync = struct { // MARK: Sync
};
}
mutex.unlock();
commands.deinit();
std.debug.assert(freeIdList.items.len == maxId); // leak
freeIdList.deinit();
serverToClientMap.deinit();
}
pub fn executeCommand(payload: Command.Payload) void {

View File

@ -686,6 +686,7 @@ pub const World = struct { // MARK: World
main.gui.deinit();
main.gui.init();
Player.inventory.deinit(main.globalAllocator);
main.items.Inventory.Sync.ClientSide.reset();
main.threadPool.clear();
self.itemDrops.deinit();