OpenXcom Forum

Modding => OpenXcom Extended => OXCE Builds & Ports => Topic started by: Heybeardy on December 01, 2020, 05:40:53 pm

Title: [Solved] Battlescape saves don't work (yaml-cpp issue)
Post by: Heybeardy on December 01, 2020, 05:40:53 pm
Hello folks,

First I would like to thank all those fantastic people who made the original OXC and the extended
 version of OXC possible. This isn't my first rodeo, I did the original OXC some years back and of course right back in 1994 in my student dorm room with my roomates.

Overnight, I compiled OXCE using Meridian's link:

https://openxcom.org/forum/index.php/topic,7048.0.html

I built it on linux, on my Raspberry Pi 3 B+ board. I think it took about 2 hrs to compile -though I'm not too sure about the time as I was fast asleep while RPi 3 hummed along.

It's been a while since I have done any serious package building & compiling on linux, so I couldn't exactly pin-point the problem. First of all, the game worked -everythying seems to be fine so far. Except in some instances when I save my Battlescape mission, log out and returned to my saved game, the terrain seem to be missing and I have instead my squad and AI standing around zombified in a black background --see below:

(https://i.imgur.com/tWodGdn.jpg)
(https://i.imgur.com/VfVbmNu.jpg)

Hopefully someone has an idea of what's wrong in this instance.

Regards
Heybeardy.
Title: Re: Bugs (?) with my saved games
Post by: Yankes on December 01, 2020, 06:20:03 pm
can you move around, do wall still exists? and could you add this save to your post?
Title: Re: Bugs (?) with my saved games
Post by: Heybeardy on December 01, 2020, 06:33:19 pm
can you move around, do wall still exists? and could you add this save to your post?

Thanks for the reply Yankes.

Yes, I can move around but not like in the normal fashion. Unit can only move in straight line and with no limbs movement, they can shoot but it's only single shot. AI can see my units and shoot their nasty green peas at my men. lol

I assumed you mean my saved game that you wanted me to post - I have attached the two files, hopefully this is what you wanted,

Regards,
Heybeardy.

Btw, there are no walls -- just a black background, in the first image my units are in the skyranger while in the second they're outside around the skyranger with smoke gen discarded.
Title: Re: Bugs (?) with my saved games
Post by: Heybeardy on December 01, 2020, 06:58:36 pm
Hey, sorry about it - I have attached the wrong save game files I think.

The save files for the images that I posted are from a terror mission --I have attached the right files for these particular images.
Title: Re: Bugs (?) with my saved games
Post by: Heybeardy on December 01, 2020, 07:16:11 pm
I went & check my saved games --apparently it's all of the Battlescape. The Geoscape seems to be fine.

I load the Geoscape that I saved before my skyranger landed for the terror mission --the Battlescape seems to be fine and the layout looked similar to the one in my image with black background:

(https://i.imgur.com/qyczlQP.jpg)

Regards,
Heybeardy.
Title: Re: Bugs (?) with my saved games
Post by: Yankes on December 01, 2020, 08:16:09 pm
I loaded this save and its fine, everything is where it should be. It look like your game get corrupted and stop showing some graphics.
Did you start again whole game after log back or it stay ruining during logoff?
Title: Re: Bugs (?) with my saved games
Post by: Heybeardy on December 01, 2020, 08:55:50 pm
I loaded this save and its fine, everything is where it should be. It look like your game get corrupted and stop showing some graphics.
Did you start again whole game after log back or it stay ruining during logoff?

If I stayed in the game it seems to worked fine but  when I tried it by logging out & in then this graphic problem reared its head. This is not the first time it occurred --it happened this morning as well.

So if it worked fine for you, then it must be problem relating to my RPi 3+ platform and/or installation. (?) I haven't the idea of how to fix it as I'm not too familiar with how the graphic in the game works, much less how ARM7v in RPi 3+ works.

Regards,
Heybeardy.
Title: Re: Bugs (?) with my saved games
Post by: Yankes on December 02, 2020, 12:26:36 am
If I stayed in the game it seems to worked fine but  when I tried it by logging out & in then this graphic problem reared its head. This is not the first time it occurred --it happened this morning as well.

So if it worked fine for you, then it must be problem relating to my RPi 3+ platform and/or installation. (?) I haven't the idea of how to fix it as I'm not too familiar with how the graphic in the game works, much less how ARM7v in RPi 3+ works.

Regards,
Heybeardy.
First this look like some bad interaction with OS that can't be fix from our end. I would need have exactly same machine recreate this bug to even try fix it.
Second your answer are not precise enough to see what you do, best if you describe what you do in steps what you do to recreate this bug.
E.g.:
Code: [Select]
1) boot machine
2) log in
3) run game
4) load save
5) map work
6) close game
7) log out
8) log in
9) run game
10) load save
11) have black map
Title: Re: Bugs (?) with my saved games
Post by: Heybeardy on December 02, 2020, 01:15:01 am
First this look like some bad interaction with OS that can't be fix from our end. I would need have exactly same machine recreate this bug to even try fix it.
Second your answer are not precise enough to see what you do, best if you describe what you do in steps what you do to recreate this bug.
E.g.:
Code: [Select]
1) boot machine
2) log in
3) run game
4) load save
5) map work
6) close game
7) log out
8) log in
9) run game
10) load save
11) have black map

Sorry if I wasn't clear. O.k., this is how it goes:

1. Compiled OXCE using the exact commands for Linux installation in Meridian's post. Did it last night on my Raspberry Pi 3 B+ board. Took about 2 (?) hrs to complete without any errors.

2. Played the game this morning --everything seems to worked fine.

3. Later in the morning, I reboot  into my RPi3 B+ board & logged in and attempted to start my saved Battlescape game. It turned out that all saved battlescape games are affected.

4. The sequence went like this:

   a) Boot into RPi3 B+.
   b) Logged in Raspberey Pi Os (based on Debian).
   c) Started OXCE in the terminal.
   d) Clicked on the saved Battlescape game.
   e) Game opened to black map screen with just my units & AI visible --same as the two images
        in my first post above. All saved Battlescape games are affected.
   f) Quit the Battlescape mission.
   g) Clicked on the saved Geoscape game.
   h) Game worked fine. I have one such save game where the skyranger was just about to land
       on a terror mission.
    i) Clicked on the saved Geoscape game with skyranger on way to terror mission.
    j) Game opened to normal map, did the first turn.
    k) Saved the Battlescape game and quit.
    l) Clicked on the save Battlescape game,  game opened to the same black map.

It work fine if I goes through the terror mission from start to finish, return to Geoscape & save it. But I do not have the time to play continuously, hence the need to save the game.

Regards,
Heybeardy.
Title: Re: Bugs (?) with my saved games
Post by: Yankes on December 02, 2020, 01:57:32 am
One possible fix I would see is to disable lazy loading. Because it look like it do not load all surfaces correctly when load save game, but load them when you start new mission.
What commit you used to compile this version?
Title: Re: Bugs (?) with my saved games
Post by: Heybeardy on December 02, 2020, 01:42:13 pm
One possible fix I would see is to disable lazy loading. Because it look like it do not load all surfaces correctly when load save game, but load them when you start new mission.
What commit you used to compile this version?

Excuse my ignorance, but what's 'lazy loading'?

By commit I assumed you mean the git repo that I used. I pulled from Meridian's --I believe that this is what you're referring to, the commit tag:

Quote
d30709a0bf7b4f263e4db28bbce848c8036614cd

Quote
$ git show d30709a0bf7b4f263e4db28bbce848c8036614cd
commit d30709a0bf7b4f263e4db28bbce848c8036614cd (HEAD -> oxce-plus, origin/oxce-plus, origin/HEAD)
Date:   Thu Nov 26 17:00:37 2020 +0100

    Derp

diff --git a/src/Battlescape/DebriefingState.cpp b/src/Battlescape/DebriefingState.cpp
index 0a40bf49a..61a0499b5 100644
--- a/src/Battlescape/DebriefingState.cpp
+++ b/src/Battlescape/DebriefingState.cpp
@@ -2554,7 +2554,10 @@ void DebriefingState::recoverAlien(BattleUnit *from, Base *base)
                ss << "; Status = " << from->getStatus();
                ss << "; Faction = " << from->getFaction();
                ss << "; Orig. faction = " << from->getOriginalFaction();
-               ss << "; Spawn unit = [" << from->getSpawnUnit()->getType() << "]";
+               if (from->getSpawnUnit())
+               {
+                       ss << "; Spawn unit = [" << from->getSpawnUnit()->getType() << "]";
+               }
                ss << "; isSurrendering = " << from->isSurrendering();
                throw Exception(ss.str());
        }

Earlier  this morning I copied my OXCE directories to a different micro SD card containing an older raspberry pi OS, tried the saved Battlescape game and the result was the same --black map.

I also tried the game on one of the older board specifically RPi 2+ with the same result.

I have a two PCs, however both have hardware problems. My reliable AMD64 PC while it works fine for general purpose use, is showing its age and breaks down if I attempt to do heavy lifting like compiling etc and a lot of files are corrupted. So I do not have a different machine to test the game on.
Title: Re: Bugs (?) with my saved games
Post by: Yankes on December 02, 2020, 03:20:04 pm
In game options there is switch that make that only files you need are loaded, its is way to reduce memory overhead in very big mods (that if load all assets could use over 1GiB of memory).

https://openxcom.org/forum/index.php/topic,3287.msg104264.html#msg104264
Title: Re: Bugs (?) with my saved games
Post by: Heybeardy on December 02, 2020, 03:39:15 pm
In game options there is switch that make that only files you need are loaded, its is way to reduce memory overhead in very big mods (that if load all assets could use over 1GiB of memory).

https://openxcom.org/forum/index.php/topic,3287.msg104264.html#msg104264

I figured it as much -I went to look at the config files this morning and have already set 'lazyLoadResources: false'. Didn't help as the black map still remained.

I'm going to take a look at my old AMD64 machine, just to check if it's stable enough to handle a few things before attempting a heavy workout on it. In meantime later tonight I'll probably try a new git pull & compiling of a fresh OXC and also OXCE on my RPi 3 B+ board.

Regards,
Heybeardy.
Title: Re: Bugs (?) with my saved games
Post by: Yankes on December 02, 2020, 08:41:06 pm
Can you enable path preview and when you load save show what it is showing? try imaging that whole map is still there and order unit to move.
Could you show screen shots of this paths that will be show?
Title: Re: Bugs (?) with my saved games
Post by: Heybeardy on December 02, 2020, 11:41:12 pm
Can you enable path preview and when you load save show what it is showing? try imaging that whole map is still there and order unit to move.
Could you show screen shots of this paths that will be show?

I assumed that this is what you mean?

(https://i.imgur.com/dUvY06e.jpg)

I have attached a minute of recording of this stuff on my desktop - video shows unit moving & AI reaction shooting.
Title: Re: Bugs (?) with my saved games
Post by: Yankes on December 03, 2020, 12:54:47 am
Could you try load this hacked save game?
Title: Re: Bugs (?) with my saved games
Post by: Heybeardy on December 03, 2020, 11:15:00 am
Could you try load this hacked save game?

I tried the hacked save game, while it worked fine initially the same black map cropped up. It only happened after I have saved it as new saved game & exit from the battlescape. The new saved game opened to the same black map.

Incidentally, I pulled & compiled a fresh git OXC and OXCE overnight, the black map bug still occurred.

Seem to be something up with the save game option for battlescape mission.

Fyi, OXC &compiled in just under an hour (40-50 mins)  while OXCE it was slightly longer probably 1.5 hrs in Raspberry Pi 3 B+ board.

Regards,
Heybeardy.


Title: Re: Bugs (?) with my saved games
Post by: Yankes on December 03, 2020, 11:28:16 am
Quote
I tried the hacked save game, while it worked fine initially the same black map cropped up.
This mean it loaded correctly? What you did after is irrelevant to this test.
Title: Re: Bugs (?) with my saved games
Post by: Heybeardy on December 03, 2020, 03:27:39 pm
This mean it loaded correctly? What you did after is irrelevant to this test.

Yes the hacked save game loaded correctly. The game play was fine.

It's only when I saved the (battlescape) game, exited and loaded it, I ended up with the black map.
Title: Re: Bugs (?) with my saved games
Post by: Yankes on December 03, 2020, 03:53:51 pm
What version of yaml did you use to compile your binary?
Title: Re: Bugs (?) with my saved games
Post by: Heybeardy on December 03, 2020, 06:36:37 pm
What version of yaml did you use to compile your binary?

I used the git version 0.6.3.

The one available for my RPi debian system is 0.6.2-4, though it is not installed.
Title: Re: Bugs (?) with my saved games
Post by: Yankes on December 03, 2020, 07:34:04 pm
Overall it look that somting is broken in code that load binary serialized map in your code.

Code: [Select]
diff --git a/src/Savegame/SavedBattleGame.cpp b/src/Savegame/SavedBattleGame.cpp
index 37fc2f9d2..2b950148c 100644
--- a/src/Savegame/SavedBattleGame.cpp
+++ b/src/Savegame/SavedBattleGame.cpp
@@ -505,7 +505,7 @@ YAML::Node SavedBattleGame::save() const
        {
                node["mapdatasets"].push_back((*i)->getName());
        }
-#if 0
+#if 1
        for (int i = 0; i < _mapsize_z * _mapsize_y * _mapsize_x; ++i)
        {
                if (!_tiles[i].isVoid())
diff --git a/src/Savegame/Tile.cpp b/src/Savegame/Tile.cpp
index 85a9f38f7..76ac20a41 100644
--- a/src/Savegame/Tile.cpp
+++ b/src/Savegame/Tile.cpp
@@ -167,11 +167,10 @@ YAML::Node Tile::save() const
                node["fire"] = _fire;
        if (_objectsCache[O_FLOOR].discovered || _objectsCache[O_WESTWALL].discovered || _objectsCache[O_NORTHWALL].discovered)
        {
-               throw Exception("Obsolete code");
-//             for (int i = O_FLOOR; i <= O_NORTHWALL; i++)
-//             {
-//                     node["discovered"].push_back(_objectsCache[i].discovered);
-//             }
+               for (int i = O_FLOOR; i <= O_NORTHWALL; i++)
+               {
+                       node["discovered"].push_back((bool)_objectsCache[i].discovered);
+               }
        }
        if (isUfoDoorOpen(O_WESTWALL))
        {

This diff should enable old save mechanism that look like it work for you
Title: Re: Bugs (?) with my saved games
Post by: Heybeardy on December 03, 2020, 09:45:18 pm
I'm sure that I have done it a few times but it was a while ago, how do I make change to these two files SavedBattleGame.cpp & Tile.cpp? I 'm aware of the specific parts of the code that needed to be remove & added. I assumed that I'll have to recompile OXCE with these code fixes?
Title: Re: Bugs (?) with my saved games
Post by: Yankes on December 03, 2020, 10:19:56 pm
This is part of diff, lines that start with `-` need be removed, and ones start with `+` added in same place. Of corse do not add this `+` in final file.
After you did it, you can compile it again to have new binary that you can run.
Of corse you can commit this changes to not lose them in future.
Title: Re: Bugs (?) with my saved games
Post by: Heybeardy on December 04, 2020, 11:29:09 am
Thanks for refreshing my memory about the code change Yankes. I have recompiled OXCE with the code changes.

So far the game loaded fine and the game played was fine. But the saved game still have some problems -
 a) Loaded the hacked save game.
 b) Deployed smoke grenades.
 c) Saved the hacked save game.
 d) Loaded the saved game.
 e) Map opened to units in the Skyranger and AIs in the terrain, however smoke grenade deployment are missing. Also, there are still black areas of map and the game play is similar to the pre-hacked version of save game with the black map.

I have attached a 2.3 mins recording.
Title: Re: Bugs (?) with my saved games
Post by: Yankes on December 04, 2020, 03:09:24 pm
Also, there are still black areas of map and the game play is similar to the pre-hacked version of save game with the black map.

No, there is no "black" areas any more. Game correctly loaded tiles, but only forget flags for visibility and smoke.
could you show what changes you finally did to source code?
Title: Re: Bugs (?) with my saved games
Post by: Heybeardy on December 04, 2020, 03:47:38 pm
No, there is no "black" areas any more. Game correctly loaded tiles, but only forget flags for visibility and smoke.
could you show what changes you finally did to source code?

Yes I meant the visibility  - the black area above & behind the skyranger and smoke.

I simply replaced in SavedBattleGame.cpp,

Quote
 
#if 0

with

Quote
 
#if 1

and in Tile.cpp,

Quote
               throw Exception("Obsolete code");
//             for (int i = O_FLOOR; i <= O_NORTHWALL; i++)
//             {
//                     node["discovered"].push_back(_objectsCache.discovered);
//             }

with

Quote
 
               for (int i = O_FLOOR; i <= O_NORTHWALL; i++)
               {
                       node["discovered"].push_back((bool)_objectsCache.discovered);
               }

Then recompiled.
Title: Re: Bugs (?) with my saved games
Post by: Heybeardy on December 04, 2020, 03:54:36 pm
See attached SavedBattleGame.cpp & Tile.cpp files.
Title: Re: Bugs (?) with my saved games
Post by: Yankes on December 04, 2020, 08:17:03 pm
Overall it look like your yaml-cpp have broken load of `Uint8`.

I have another possbile way to fix your code. First remove all changes you did (preferably by stashing them or putting them on another branch) then add code like this:

Code: [Select]
//YAML::Node SavedBattleGame::save() const
// old code look like:
// node["tileIndexSize"] = Tile::serializationKey.index;

node["tileIndexSize"] = (int)Tile::serializationKey.index;
node["tileTotalBytesPer"] = (int)Tile::serializationKey.totalBytes;
node["tileFireSize"] = (int)Tile::serializationKey._fire;
node["tileSmokeSize"] = (int)Tile::serializationKey._smoke;
node["tileIDSize"] = (int)Tile::serializationKey._mapDataID;
node["tileSetIDSize"] = (int)Tile::serializationKey._mapDataSetID;
node["tileBoolFieldsSize"] = (int)Tile::serializationKey.boolFields;
and
Code: [Select]
//void SavedBattleGame::load(const YAML::Node &node, Mod *mod, SavedGame* savedGame)
// old code look like
// serKey.index = node["tileIndexSize"].as<Uint8>(serKey.index);

serKey.index = node["tileIndexSize"].as<int>(serKey.index);
serKey.totalBytes = node["tileTotalBytesPer"].as<int>(serKey.totalBytes);
serKey._fire = node["tileFireSize"].as<int>(serKey._fire);
serKey._smoke = node["tileSmokeSize"].as<int>(serKey._smoke);
serKey._mapDataID = node["tileIDSize"].as<int>(serKey._mapDataID);
serKey._mapDataSetID = node["tileSetIDSize"].as<int>(serKey._mapDataSetID);
serKey.boolFields = node["tileBoolFieldsSize"].as<int>(1); // boolean flags used to be stored in an unmentioned byte (Uint8) :|
Overall it change use of `Uint8` to `int`.
Title: Re: Bugs (?) with my saved games
Post by: Heybeardy on December 05, 2020, 02:55:48 am
Yankes, after reading your comments about yaml-cpp being the culprit in most cases and especially your question about what version I used, I decided against to fix the codes per your suggestion in the last post.

What I did instead was to remove the git version of yaml-cpp (0.6.3) and install libyaml-cpp0.6:armhf  (0.6.2-4+rpi1) from the debian system. I also removed the changes in the code for the SavedBattleGame.cpp and Tile.cpp files, simply revert back to the original files. Then recompiled OXCE.

All the saved games worked. I loaded a saved game, saved it, exit, loaded it again - no more black maps and the visibility & smoke effects all are present as they should be. Phew!

The main cause seems to be the git version of yaml-cpp.

Thanks for all the helps in trying to fix the problem.
Title: Re: Bugs (?) with my saved games
Post by: Yankes on December 05, 2020, 03:08:27 am
Good to hear you managed to fix it, I was excepting that something outside of yaml-cpp break it but it look that version you had was simply broken.
Title: Re: Bugs (?) with my saved games
Post by: cptMikky on August 30, 2021, 12:59:44 am
I have probably the exact same issue - binTiles doesn't work while "old" save loads well.

Linux, yaml-cpp both v0.7.0 from packages and freshly compiled from master, various OXCE versions including latest `oxce-plus` branch (c59419b4914d350131f4c947392baff11b3ccbc6), v7.0 commit and a few random commits in between.

Tried Yankes' patch: (github)/cptMikky/OpenXcom/commit/09aab335576996930a4e914de11cd8ba25492a78

It works but only with saves created with that patch - old saves still don't load correctly, see attachments:

t1.sav - created by an unpatched build directly after loading Yankes' hacked save
t2.sav - created by patched build from the hacked save

t1 doesn't load correctly but t2 does.

I'm not yet 100 % convinced this is a yaml-cpp issue but if it is, we should maybe try to describe the bug and post it upstream.

OT: why are github issues disabled for OXCE?