Repository navigation
Persist vehicles and tents on the game server - #11
Conversation
There was a problem hiding this comment.
Devin Review found 5 potential issues.
1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
| dbInitServer; | ||
|
|
||
| // Persistent world objects (vehicles / tents) | ||
| call compile preprocessFileLineNumbers "dz_worldPersist.sqf"; |
There was a problem hiding this comment.
🔴 Missing persistence service startup
On a clean install, dz_worldPersist runs before any persistence service has started. The documented launch starts only the game server. Vehicles and tents never save across restarts.
Learn more
Vehicle and tent saves go through the engine's world endpoint, which defaults to loopback port 28100. The PowerShell listener only opens that port when separately launched with a server root. The documented server startup does not start or wait for it. With no listener, GetResponse reports a failure and world registration leaves the object untracked.
Example: An operator extracts a fresh server package, launches the executable with -config=serverDZ.cfg, and moves one of the initial helicopters. No record is created, so the next launch creates fresh starter objects instead of restoring the helicopter at its saved location.
Recommended fix: Ship a supported startup entry point that starts the listener with the correct root, checks readiness, and only then launches the game server. Document and smoke-test that path against a clean package.
Was this helpful? React with 👍 or 👎 to provide feedback.
| GWorld->AddOutVehicle(item); | ||
| int index = supply->GetItemsCargo().CanAddItem(item); | ||
| if (index >= 0) | ||
| { | ||
| item->SetMoveOutDone(veh); | ||
| supply->GetItemsCargo().AddItem(veh, item, index); | ||
| } |
There was a problem hiding this comment.
🔴 Restored cargo invisible to players
On restart, DBWorldLoadState adds cargo only on the server after CreateVehicle publishes the container. Cargo updates send object references, but the restored items never get network IDs. Players cannot retrieve them.
Learn more
The restore path creates the networked container first. NetworkClient::CreateVehicle registers the entity and then creates its existing subobjects; none of the saved cargo has been loaded at that point. AddOutVehicle only puts each restored item on a server-side list. ResourceSupply::TransferMsg replicates cargo as references rather than creating the referenced items. The normal InventoryStorage::CreateItem path also explicitly registers the cargo item with the network.
Example: A player puts a magazine in a supported container and waits for autosave. After a restart, the server reconstructs the magazine, but a multiplayer client opening the container does not receive a usable magazine.
Recommended fix: Restore cargo before network publication and ensure the container's creation path publishes the entire restored cargo tree, including for transports whose CreateSubobjects override does not call the cargo implementation. Alternatively, explicitly publish each successfully attached top-level item and its subobjects, then synchronize the container. Verify with a remote client opening the inventory and moving a restored item.
Was this helpful? React with 👍 or 👎 to provide feedback.
| GWorld->AddOutVehicle(item); | ||
| int index = supply->GetItemsCargo().CanAddItem(item); | ||
| if (index >= 0) | ||
| { | ||
| item->SetMoveOutDone(veh); | ||
| supply->GetItemsCargo().AddItem(veh, item, index); |
There was a problem hiding this comment.
🔴 Cargo loss during grid repacking
On restart, DBWorldLoadState repacks cargo without its original slots or rotation. Items that no longer fit stay outside the container. The next autosave drops them from the save.
Learn more
Cargo uses a rectangular grid, and InventoryStorage::RemoveItem leaves holes instead of moving the remaining items. DBWorldSaveState records items in grid order without recording their cells. Restore calls CanAddItem without an index, so FitsInto uses the first free rectangle. Item rotation also affects dimensions but is not in InventoryItem::JSONSave. A rejected item stays on the world's out-of-scene list and does not appear in the container's next snapshot.
Example: In a three-by-two grid, add two one-cell items, a vertical two-cell item, then a horizontal two-cell item. Remove the first one-cell item and save. On restore, the remaining one-cell item moves to the first column and the vertical item moves from the third column to the second. No two adjacent cells remain for the horizontal item.
Recommended fix: Persist each item's grid index and rotation and restore both before checking the exact slot. Keep an explicit fallback for older records without grid metadata, and do not register rejected items in the world or silently overwrite a save with incomplete cargo. Cover nested inventories as well.
Was this helpful? React with 👍 or 👎 to provide feedback.
| if ((damage _obj) >= 0.95) then { | ||
| dbWorldRemove _id; |
There was a problem hiding this comment.
🔴 Live vehicles dropped from saves
At 95% damage, dz_fnc_worldSaveAll deletes the record even if the vehicle is still alive. Repairing it never restores tracking, so it and its cargo disappear on restart.
| if ((damage _obj) >= 0.95) then { | |
| dbWorldRemove _id; | |
| if (!alive _obj) then { | |
| dbWorldRemove _id; |
Was this helpful? React with 👍 or 👎 to provide feedback.
| $route = $context.Request.Url.AbsolutePath.Trim('/') | ||
| if ($route -eq 'health') { Send-Response $context 200 '{"status":"ready"}'; continue } | ||
| if ($route -eq 'lud0' -or $route.StartsWith('lud0/')) { Handle-Character $context $route; continue } | ||
| if ($route -eq 'world' -or $route.StartsWith('world/')) { Handle-World $context $route; continue } |
There was a problem hiding this comment.
🟥 Unauthenticated access to local game saves
Handle-Character and Handle-World accept requests from any local process without authenticating it. The listener uses its own file permissions, letting other local accounts read or alter saves they cannot access directly.
Was this helpful? React with 👍 or 👎 to provide feedback.
Persistencia de veiculos e tendas no servidor.
dbWorldAdd,dbWorldSave,dbWorldRemove,dbWorldListedbWorldSpawn.dz_worldPersist.sqf.DayZLocalPersistence.ps1) com endpoints/world/add|update|remove|get|list.Somente codigo-fonte; sem builds, PBOs, DLLs ou backups.