cxong / cdogs-sdl

Classic overhead run-and-gun game
https://cxong.github.io/cdogs-sdl/
GNU General Public License v2.0
891 stars 114 forks source link

Problems with saving and loading campaigns in editor #333

Closed Wuzzy2 closed 9 years ago

Wuzzy2 commented 9 years ago

I have problems with saving and loading campaigns in the editor.

When I load a campaign, the console has this message: “failed to open. Reason: [No such file or directory].”

But the campaign opens anyways in the editor.

When I try to save the file under the same name as I loaded the file, there is no error message. But when I load the file again, the changes are gone. It seems the changes have never been actually save.

When I try to save the file under a non-existant name, the console has an error message complaining about some “invalid relative path”:

Cannot resolve relative path /home/wuzzy/src/cdogs-sdl/cdogs-sdl/missions/Wuzzy/gungame2.cdogscpn

It does not matter if I change it to an actual relative path, so this:

../missions/Wuzzy/gungame2.cdogscpn

does not work either. I get this message:

Cannot resolve relative path ../missions/Wuzzy/gungame2.cdogscpn
Failed to make dir. reason: Insecure filename.

Notes:

Something seems to be really weird with saving and loading right now.

Version: e686f9931cd32c110261849a678cb7a508a43931, self-compiled. OS: GNU/Linux

cxong commented 9 years ago

The first error message you mention is normal; the game will attempt to load files inside the campaigns, which may not be there (e.g. the campaign doesn't have custom weapons). I've hidden that message behind a debug statement.

The key problem is this line:

Cannot resolve relative path ../missions/Wuzzy/gungame2.cdogscpn

Which means for some reason, realpath is returning null when attempting to resolve that relative path. I see nothing wrong with that path, so I've added logging for the system error in 9b2581c0af6084ef0ef20f0faba1992156ed0568; please try and let me know what the error message is now.

Wuzzy2 commented 9 years ago

Saving my campaign under the same name only yields this message:

Saved to /home/wuzzy/src/cdogs-sdl/git/missions/Wuzzy/gungame.cdogscpn

But when I reload the mission from “../missions/Wuzzy/gungame.cdogscpn”, the changes are not stored.

When I try to save the same campaign under a different name, I get this:

Cannot resolve relative path /home/wuzzy/src/cdogs-sdl/git/missions/Wuzzy/gungame3.cdogscpn: Datei oder Verzeichnis nicht gefunden
Saved to /home/wuzzy/src/cdogs-sdl/git/missions/Wuzzy/gungame3.cdogscpn

(“Datei oder Verzeichnis nicht gefunden” is German for “File or directory not found”.) Another test with a relative path:

Cannot resolve relative path ../missions/Wuzzy/gungame2.cdogscpn: Datei oder Verzeichnis nicht gefunden
Failed to make dir. reason: Insecure filename.
Saved to ../missions/Wuzzy/gungame2.cdogscpn

However, I noticed something very funny. As I looked into the missions directory, I found a directory named “home”! And yeah, this directory hold the entire path tree. I get crazy paths like:

/home/wuzzy/src/cdogs-sdl/git/missions/home/wuzzy/src/cdogs-sdl/git/missions/Wuzzy/gungame.cdogscpn

However, this is outdated. I saved a fresh copy (apparently) to /home/wuzzy/src/cdogs-sdl/git/missions/Wuzzy/gungame.cdogscpn and a “home” directory got directly created into my working directory (that is, in src, where the editor lies).

And there is actually a folder with the name “gungame.cdogscpn”. But it seems the editor only saved a partial copy, there are only the files campaign.json, missions.json and characters.json. The following files were missing bullets.json, guns.json and the sounds directory which contained the gun sounds.

I hope this helps fixing the bug. :)

cxong commented 9 years ago

Fixed; please give this a try

Wuzzy2 commented 9 years ago

It seems OK now.