Repository navigation
Conversation
A file or folder added to [RESOURCES], or a new file in the main scripts folder, was indexed by the resync but never read: opening it in AddResourceFile already stored its size and date, so ReSync() saw neither a first check nor a change and skipped it. Files indexed for the first time by a resync are now loaded with LoadResources(), like at startup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Problem.
RESYNCdoesn't load script files that were added since the last load. If you add a file or a folder to[RESOURCES]inspheretables.scp, or drop a new.scpinto the main scripts folder, the resync indexes it but never reads it. Its definitions stay missing until the server is restarted. Changes to files that were already loaded are resynced normally.Cause. During the resync, the
[RESOURCES]section of the changedspheretables.scpis parsed again, andAddResourceFile()adds the new files tom_ResourceFiles. It opens each one throughCResourceScript::Open(), which callsCheckForChange(). On a first check that call only stores the file's size and date. Later in the same resync,CServerConfig::Load(true)callsReSync()on every file, andReSync()returns unless the file is on its first check or has changed. The new file is neither anymore, so its content is never loaded.At startup this doesn't happen, because every file is loaded unconditionally with
LoadResources().ReSync()does have a branch for a file that was never checked, so the intent clearly was to load new files, but the open inAddResourceFile()defeats it. The behaviour is the same in the 0.56b sources.Change (
src/game/CServerConfig.cpp,CServerConfig::Load):LoadResources(), the same call startup uses. The other files still go throughReSync(), which reloads them only if they changed.What is still not covered: a new file inside a folder that is already listed in
[RESOURCES]is found only whenspheretables.scpchanged too, because only then are the listed folders read again. The main scripts folder is read on every resync, so new files there are always found.Type of Change
Related Issues
No existing issue.
Testing
I tested on a clean instance with the latest Scripts-X pack (663d1c7), using a Debug build (MSVC 2022, Windows x64). The server ran a test-only function from
f_onserver_timer(TimerCall 1 s) that:SERV.RESYNCat tick 8;Between tick 3 and the resync, while the server was running, the test:
rt_new/(a new folder holding one file) andrt_extra/rt_single.scp(a new single file) to[RESOURCES];rt_root.scp(a new file in the main scripts folder);rt_existing.scp, a file that was already loaded.spheretables.scpnot changedWith the fix, the log shows
Loading .../rt_new/rt_dir.scp,Loading .../rt_extra/rt_single.scpandLoading .../rt_root.scpduring the resync, followed byResync complete!. No new errors or warnings appear.The test scripts were local only and are not part of this PR.
Checklist
Additional Notes
A file loaded this way is processed exactly as it is at startup. So, as at startup, it can redefine things that already exist; the usual "Replacing existing ..." warnings are logged.