Skip to content

Persist vehicles and tents on the game server - #11

Merged
Personed merged 2 commits into
Personed:mainfrom
Arthurnashh:sourcedayz/persist-world-objects
Nov 24, 2026
Merged

Personed merged 2 commits into
Personed:mainfrom
Arthurnashh:sourcedayz/persist-world-objects

Conversation

@Arthurnashh

@Arthurnashh Arthurnashh commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Persistencia de veiculos e tendas no servidor.

  • Novos comandos de engine: dbWorldAdd, dbWorldSave, dbWorldRemove, dbWorldList e dbWorldSpawn.
  • Estado salvo: matriz de posicao, direcao, damage, fuel, variaveis e cargo.
  • Restore automatico no boot e autosave a cada 10s via dz_worldPersist.sqf.
  • Servico local de persistencia (DayZLocalPersistence.ps1) com endpoints /world/add|update|remove|get|list.
  • Testado no servidor: 2 helicopteros + 2 tendas restaurados apos restart.

Somente codigo-fonte; sem builds, PBOs, DLLs ou backups.


Devin Review

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 5 potential issues.

1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

dbInitServer;

// Persistent world objects (vehicles / tents)
call compile preprocessFileLineNumbers "dz_worldPersist.sqf";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread lib/gameStateExt.cpp
Comment on lines +18323 to +18329
GWorld->AddOutVehicle(item);
int index = supply->GetItemsCargo().CanAddItem(item);
if (index >= 0)
{
item->SetMoveOutDone(veh);
supply->GetItemsCargo().AddItem(veh, item, index);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread lib/gameStateExt.cpp
Comment on lines +18323 to +18328
GWorld->AddOutVehicle(item);
int index = supply->GetItemsCargo().CanAddItem(item);
if (index >= 0)
{
item->SetMoveOutDone(veh);
supply->GetItemsCargo().AddItem(veh, item, index);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +80 to +81
if ((damage _obj) >= 0.95) then {
dbWorldRemove _id;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 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.

Suggested change
if ((damage _obj) >= 0.95) then {
dbWorldRemove _id;
if (!alive _obj) then {
dbWorldRemove _id;

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +272 to +275
$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 }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟥 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@Personed
Personed merged commit 19b67bc into Personed:main Nov 24, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants