Problems with game data files changing

Good day! I have a little problem with files in the data folder.
Sometimes, when I change some sprite to another, old sprite returns. Or, when I change folders names, files inside mixes…
Can I fix this thing?

Hm, none of what you describe should happen :slight_smile: Once a new sprite has been loaded, new one should not return. Note that we have hot-reloading in editor by default (but not in game), so new sprite should be even loaded automatically. Although we have a cache that may sometimes interfere, but it doesn’t explain any of the 2 things you report.

Can you provide a reproduction, I would certainly like to fix it?

  • Either a project with data to reproduce, and exact steps (and do you see problems in editor or at runtime).
  • Or a video recording your project, when do the sprite return – this may be good enough here too, as I will see the steps you do and possibly guess the reason.

Thank you!


This is a little weird thing :upside_down_face:

Maybe problem not with CGE settings, but I can’t remember this bug/feature in another scenarios.

(I use Linux Mint Debian Edition distro)

(In this video I just trying to fix mistake with sprites naming)

From a quick look at the video, the files change many times, due to copy+rename. What you observe may be a consequence of Linux-specific bug with our auto-refreshing, see

https://github.com/castle-engine/castle-engine/blob/c0c45159e9b4aa1284f33393c1288ffdc99fab43/tools/castle-editor/code/formproject.pas#L1301

procedure TProjectForm.ApplicationProperties1Activate(Sender: TObject);
begin
  { TODO: At least on Linux, GTK2 backend, this is *not* reliably
    run always when we switch back to CGE editor with Alt+Tab.
    This in turn means we don't always auto-reload scenes, images etc.
    when their content changed.
  WritelnLog('TProjectForm.ApplicationProperties1Activate ' + FormatDateTime('yyyy"-"mm"-"dd" "tt', Now));
  }

  { Refresh contents of selected dir, and tree of subdirectories,
    in case user created some files/directories in other applications. }
  RefreshFiles(rfEverything);
  FileMonitor.CheckChanges;
end;

To be clear, I understand that once you Alt+Tab to the Castle Game Engine editor, it shows the wrong version of the file?

Give me a few days, I’ll see whether we can solve it better :slight_smile:

1 Like

For now I work only from IDE, without editor. So, project just upload “wrong” files in runtime. It may help, if I will try to change them from CGE editor.

After all, this behavior really seems more as OS problem…

Oh! Hm, if you’re not using editor, then I misdiagnosed the problem. What exactly happens, do we load wrong file versions at runtime? Can you record a larger movie that shows the whole process with the bug – so when you play with renaming/copying data files, then build and run the game, and the game (as I understand) loads wrong files?

This is weird because such bugs should be impossible:) We don’t do anything fancy at runtime – we just load the files from your data as they exist on your disk, period. We also use cache for them, but this is build at runtime in memory, not depending on anything preprocessed. So if your files are saved with given state, and then you run the game → it’s really guaranteed we load such files.

And I didn’t observe disk / OS bugs that would even change it:) I mean, even disk errors would likely exhibit different problem, crashes at reading etc. It is weird is your file manager shows one thing, and our engine loads another.

So, I likely still don’t understand the problem, sorry! :slight_smile: Please record a longer movie (and/or post detailed explain how to reproduce), I should be able then to help better.

Oh, no, I think I confused you a little :upside_down_face: Sprites changes to the another into the folder, but it happens before I compile and run project.

  1. I want to change the sprite (for example, the current image is quite ugly)
  2. I delete old name.png
  3. And add new name.png
  4. I left and back to the folder and see old name.png on his own place and new is lost. Or, if I immediately run project, old file was loaded anyway (I think, he don’t leave his place really :slight_smile: )

So, maybe this is a sign from above it’s finally time to start use sprite atlas…

I will try testing this in different ways in the near time.

Huh. That’s weird, and indicates to some “shenanigans” indeed at OS or file manager level.

Do you maybe have some anti-virus running and moving files around there? Can you disable it?

Do you maybe have some auto-synchronization of disk folders? Like this is a network drive, or it’s auto-synchronized using applications like Dropbox, Nextcloud, Proton Drive? Naturally they should not do anything such weird (and I used personally Proton Drive and Nextcloud and they rock!), but at least that would be something I would look into, and try if disabling them → solves the issue.

1 Like

I remembered I install Lazarus into the local environment (because 4.0.0 from official site has some problems with apt upgrade). And I think it can was a reason of the my problems.
I uninstall and clear all, and install Lazarus 2.2.6 from the Debian repository. For now it’s ok and project folder is stable. If problem will happen again I will say.

So, at 99% it’s was a problem with Lazarus 4.0.0 installed into local environment… And 99% anybody else never will face this problem again :upside_down_face:

1 Like