Skip to content

History rework - #162

Open
tiennou wants to merge 2 commits into
screeps:masterfrom
tiennou:fix/history-post-tick-saving
Open

History rework#162
tiennou wants to merge 2 commits into
screeps:masterfrom
tiennou:fix/history-post-tick-saving

Conversation

@tiennou

@tiennou tiennou commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

The first commit moves per-tick history saving at the start of the next tick instead of during the room processing; this fixes issues with global intents not appearing properly (inter room movement being the most visible), and also completely hides the temporary object id issues from bulk insertion, because now we only get actual database objects.

The second commit fixes an issue where only active rooms get to process, thus save their previous tick data, which makes a deactivating room miss its last active tick in the history. The other issue is related to rooms that stop ticking in the middle of a chunk and don't get to "upload" their chunk by the time the history chunk period ends (since, once again, it's linked to processRoom). That second commit requires driver changes from screeps/driver#59.

The idea is to side-step two issues:
- mid-tick changes like ruins and resources have a temporary numeric
`_id` assigned to them that leads to issues with some object overwriting
others.
- anything related to global intents, notably inter-room movement,
appears different in replays than it does in real-time, since replays
grab the position of the creep on an exit tile, while real-time has them
on the destination instead.
This adds two phases to the main loop;
- flushHistory takes care of uploading room chunks for rooms that aren't
active by the time the chunk size cutoff comes.
- saveDeactivatedRoomHistory handles saving the last tick data for rooms
that don't stay active the following tick.

Depends on a driver change.
@tiennou
tiennou force-pushed the fix/history-post-tick-saving branch 2 times, most recently from 63a5333 to 7dc98b0 Compare September 7, 2026 08:13
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.

1 participant