Try / OpenGothic

Reimplementation of Gothic 2 Notr
MIT License
1.17k stars 85 forks source link

Can't load savegame #478

Closed DocKDE closed 1 year ago

DocKDE commented 1 year ago

Hi, I've tried this project for the first time and it's awesome! However, I've noticed that I can't load savegames in G2 or G1.

I built the executable from commit 8fa4c41 with Ubuntu 20.04 as per the instructions (I used a docker container for this). I installed Gothic from GOG using Lutris and run OpenGothic with the following command for Gothic 2:

gothic2% ./Gothic2Notr.sh -g2 -g ~/Games/gothic-2/drive_c/GOG\ Games/Gothic\ 2\ Gold/
OpenGothic v1.0 dev
MESA-INTEL: warning: Performance support disabled, consider sysctl dev.i915.perf_stream_paranoid=0

no *.ini file in path - using default settings
GPU = Intel(R) Graphics (ADL GT2)
Depth format = Depth32F Shadow format = Depth16
[ALSOFT] (EE) mmap commit error: Broken pipe
swapchain is outdated - reset renderer
[phoenix] world: parsing object [MeshAndBsp % 0 0]
[phoenix] bsp_tree: parsing chunk c000
[phoenix] bsp_tree: parsing chunk c010
[phoenix] bsp_tree: parsing chunk c040
[phoenix] bsp_tree: parsing chunk c045
[phoenix] bsp_tree: parsing chunk c050
[phoenix] bsp_tree: parsing chunk c0ff
[phoenix] mesh: 1 bytes remaining in section b020
[phoenix] world: parsing object [VobTree % 0 0]
[phoenix] world: parsing object [WayNet % 0 0]
[phoenix] world: parsing object [EndMarker % 0 0]
../src/intel/isl/isl.c:2105: FINISHME: ../src/intel/isl/isl.c:isl_surf_supports_ccs: CCS for 3D textures is disabled, but a workaround is available.
invalid particle system: "INVISIBLE_VOBBOX.3DS"
unable to load sound fx: ENV_NIGHT_TONSOFINSECTS
unable to load sound fx: OW_BIRD11
[phoenix] model_script: unexpected value for event_tag_type: "      "
[phoenix] model_script: 4 bytes remaining in section f5a3
loading error: unable to read save-game file

As can be seen the savegame cannot be read.

For Gothic an error also occurs, although a different one:

gothic2% ./Gothic2Notr.sh -g1 -g ~/Games/gothic/drive_c/GOG\ Games/Gothic/           
OpenGothic v1.0 dev
MESA-INTEL: warning: Performance support disabled, consider sysctl dev.i915.perf_stream_paranoid=0

no *.ini file in path - using default settings
GPU = Intel(R) Graphics (ADL GT2)
Depth format = Depth32F Shadow format = Depth16
unable to open Zen-file: "newworld.zen"
loading error: Cannot init VLK_587_GARP_EXIT: parent class is not registered or is registered to a different instance class

Any idea what's wrong here? Could it be an issue with missing dependencies or some such? I'd be happy to provide more info as needed.

Try commented 1 year ago

Hi, @DocKDE and thanks for reporting ! Can you attach a save game file to investigate?

DocKDE commented 1 year ago

You know, I'd love to but it seems there aren't any. For Gothic I there is a folder called Saves but it's empty and for Gothic II there isn't a savegame folder at all. I'm assuming OpenGothic normally puts savegames in the game root folder under Saves, yes?

If so, the question would be why there are no savegame files.

Try commented 1 year ago

I'm assuming OpenGothic normally puts savegames in the game root folder under Saves, yes?

OpenGothic uses current working directory for save-games. Also save-file format is not compatible with vanilla game(note https://github.com/Try/OpenGothic/issues/410) Currently expected workflow is to have OpenGothic and original gothic is separate directories, that way OpenGothic can work nicely inside it's own directory, and original files are staying intact.

loading error: unable to read save-game file

This line suggest, that there was at least some attempt of loading

DocKDE commented 1 year ago

I see. I've taken another look and here is the savegame created for Gothic I: save_slot_1.zip Log: log.txt. crash log: crash.log

Try commented 1 year ago

While I wasn't able to reproduce issue: save_slot_1.zip is from G1 version that is not compatible with the one I have installed, and save-load work for me, still manage to find suspicious place in code. Hopefully 93bb4b4 will fix your issue.

DocKDE commented 1 year ago

The latest build didn't change anyting, unfortunately. Which version do you have installed? Maybe I can try if that one works for me.

Try commented 1 year ago

Which version do you have installed?

Steam, English version

DocKDE commented 1 year ago

I tried the Steam version of Gothic 2 since it's the only one I own but that produced the same error.

Try commented 1 year ago

I'm tend to think that there is some bug in here resulting in undefined behavior of sort..

I tried the Steam version of Gothic 2 since it's the only one I own but that produced the same error.

Can you please attach gothic2-save file, please?

Nindaleth commented 1 year ago

I see. I've taken another look and here is the savegame created for Gothic I: save_slot_1.zip

I can see from the paths that you seem to use GOG Gothic, so I've tried that save with ce4b78d4 on my GOG Gothic 1 (English) and cannot load it either:

./Gothic2Notr.sh -g ~/Games/gothic-i/drive_c/GOG\ Games/Gothic/ -g1 -save 1
OpenGothic v1.0 dev
no *.ini file in path - using default settings
GPU = AMD Radeon RX 6700 XT (RADV NAVI22)
Depth format = Depth32F Shadow format = Depth16
[phoenix] world: parsing object [MeshAndBsp % 0 0]
[phoenix] bsp_tree: parsing chunk c000
[phoenix] bsp_tree: parsing chunk c010
[phoenix] bsp_tree: parsing chunk c040
[phoenix] bsp_tree: parsing chunk c045
[phoenix] bsp_tree: parsing chunk c050
[phoenix] bsp_tree: parsing chunk c0ff
[phoenix] world: parsing object [VobTree % 0 0]
[phoenix] world: parsing object [WayNet % 0 0]
[phoenix] world: parsing object [EndMarker % 0 0]
[phoenix] model_script: detected invalid use of keyword aniin "Model" block. Ignoring rest of script.
unable to load sound fx: WOOD_NIGHT2
loading error: Cannot init SET_ORCSHAMAN_VISUALS: not an instance
DocKDE commented 1 year ago

Here is a G2 savegame from Steam (English version) that also won't load: save_slot_1.zip

lmichaelis commented 1 year ago

Here is a G2 savegame from Steam (English version) that also won't load: save_slot_1.zip

I can reproduce this issue on ArchLinux with the latest patch (625c0456).

Backtrace:

#0  __cxxabiv1::__cxa_throw (obj=0x7fff004fd060, tinfo=0x5555566d9ae0 <typeinfo for std::runtime_error@GLIBCXX_3.4>, dest=0x7ffff76c8320 <std::runtime_error::~runtime_error()>) at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/eh_throw.cc:80
#1  0x0000555555d3d106 in Serialize::readBytes (this=0x7fff2cdfcb00, buf=0x7ffef3fff010, sz=201326592) at /mnt/projects/GitHub/OpenGothic/game/game/serialize.cpp:177
#2  0x0000555555d3d258 in Serialize::implRead (this=0x7fff2cdfcb00, s="\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"...) at /mnt/projects/GitHub/OpenGothic/game/game/serialize.cpp:193
#3  0x0000555555ede5b3 in Serialize::read<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, Npc*, bool, unsigned char> (this=0x7fff2cdfcb00) at /mnt/projects/GitHub/OpenGothic/game/game/serialize.h:75
#4  0x0000555555ed89b6 in Interactive::load (this=0x7fff2bce4960, fin=...) at /mnt/projects/GitHub/OpenGothic/game/world/objects/interactive.cpp:126
#5  0x0000555555f0a7b8 in Vob::loadVobTree (this=0x7fff2bce4960, fin=...) at /mnt/projects/GitHub/OpenGothic/game/world/objects/vob.cpp:260
#6  0x0000555555f0a75c in Vob::loadVobTree (this=0x7fff10b242d0, fin=...) at /mnt/projects/GitHub/OpenGothic/game/world/objects/vob.cpp:258
#7  0x0000555555f3606a in WorldObjects::load (this=0x7fff298641d8, fin=...) at /mnt/projects/GitHub/OpenGothic/game/world/worldobjects.cpp:95
#8  0x0000555555f2b962 in World::load (this=0x7fff29864030, fin=...) at /mnt/projects/GitHub/OpenGothic/game/world/world.cpp:171
#9  0x0000555555d10420 in GameSession::GameSession (this=0x7fff28314770, fin=...) at /mnt/projects/GitHub/OpenGothic/game/game/gamesession.cpp:134
#10 0x0000555555e4771b in operator() (__closure=0x555558034790, game=...) at /mnt/projects/GitHub/OpenGothic/game/mainwindow.cpp:958
#11 0x0000555555e4980d in std::__invoke_impl<std::unique_ptr<GameSession>, MainWindow::loadGame(std::string_view)::<lambda(std::unique_ptr<GameSession>&&)>&, std::unique_ptr<GameSession, std::default_delete<GameSession> > >(std::__invoke_other, struct {...} &) (__f=...) at /usr/include/c++/13.1.1/bits/invoke.h:61
#12 0x0000555555e4935a in std::__invoke_r<std::unique_ptr<GameSession>, MainWindow::loadGame(std::string_view)::<lambda(std::unique_ptr<GameSession>&&)>&, std::unique_ptr<GameSession, std::default_delete<GameSession> > >(struct {...} &) (__fn=...) at /usr/include/c++/13.1.1/bits/invoke.h:116
#13 0x0000555555e48ee3 in std::_Function_handler<std::unique_ptr<GameSession, std::default_delete<GameSession> >(std::unique_ptr<GameSession, std::default_delete<GameSession> >&&), MainWindow::loadGame(std::string_view)::<lambda(std::unique_ptr<GameSession, std::default_delete<GameSession> >&&)> >::_M_invoke(const std::_Any_data &, std::unique_ptr<GameSession, std::default_delete<GameSession> > &&) (__functor=..., __args#0=...) at /usr/include/c++/13.1.1/bits/std_function.h:291
#14 0x0000555555d56ce2 in std::function<std::unique_ptr<GameSession, std::default_delete<GameSession> > (std::unique_ptr<GameSession, std::default_delete<GameSession> >&&)>::operator()(std::unique_ptr<GameSession, std::default_delete<GameSession> >&&) const (this=0x5555580314b0, __args#0=...) at /usr/include/c++/13.1.1/bits/std_function.h:591
#15 0x0000555555d46605 in operator() (__closure=0x5555580314a8) at /mnt/projects/GitHub/OpenGothic/game/gothic.cpp:447
#16 0x0000555555d54156 in std::__invoke_impl<void, Gothic::implStartLoadSave(std::string_view, bool, std::function<std::unique_ptr<GameSession>(std::unique_ptr<GameSession>&&)>)::<lambda()> >(std::__invoke_other, struct {...} &&) (__f=...) at /usr/include/c++/13.1.1/bits/invoke.h:61
#17 0x0000555555d54119 in std::__invoke<Gothic::implStartLoadSave(std::string_view, bool, std::function<std::unique_ptr<GameSession>(std::unique_ptr<GameSession>&&)>)::<lambda()> >(struct {...} &&) (__fn=...) at /usr/include/c++/13.1.1/bits/invoke.h:96
#18 0x0000555555d540c6 in std::thread::_Invoker<std::tuple<Gothic::implStartLoadSave(std::string_view, bool, std::function<std::unique_ptr<GameSession>(std::unique_ptr<GameSession>&&)>)::<lambda()> > >::_M_invoke<0>(std::_Index_tuple<0>) (this=0x5555580314a8) at /usr/include/c++/13.1.1/bits/std_thread.h:292
#19 0x0000555555d5409a in std::thread::_Invoker<std::tuple<Gothic::implStartLoadSave(std::string_view, bool, std::function<std::unique_ptr<GameSession>(std::unique_ptr<GameSession>&&)>)::<lambda()> > >::operator()(void) (this=0x5555580314a8) at /usr/include/c++/13.1.1/bits/std_thread.h:299
warning: RTTI symbol not found for class 'std::thread::_State_impl<std::thread::_Invoker<std::tuple<Gothic::implStartLoadSave(std::basic_string_view<char, std::char_traits<char> >, bool, std::function<std::unique_ptr<GameSession, std::default_delete<GameSession> > (std::unique_ptr<GameSession, std::default_delete<GameSession> >&&)>)::{lambda()#1}> > >'
#20 0x0000555555d5407e in std::thread::_State_impl<std::thread::_Invoker<std::tuple<Gothic::implStartLoadSave(std::string_view, bool, std::function<std::unique_ptr<GameSession>(std::unique_ptr<GameSession>&&)>)::<lambda()> > > >::_M_run(void) (this=0x5555580314a0) at /usr/include/c++/13.1.1/bits/std_thread.h:244
#21 0x00007ffff76e1943 in std::execute_native_thread_routine (__p=0x5555580314a0) at /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/thread.cc:104
#22 0x00007ffff749d44b in ?? () from /usr/lib/libc.so.6
#23 0x00007ffff7520e40 in ?? () from /usr/lib/libc.so.6

In https://github.com/Try/OpenGothic/blob/625c045644ea5736c695df610f9132434abcfc14/game/world/objects/interactive.cpp#L126

-> this= bilde

-> calling Serialize::implRead: bilde

-> where sz=0xc000000

Conclusion: Corrupt save game.

Try commented 1 year ago

@lmichaelis thanks for looking into that !

Apparently there is extra data in block worlds\newworld.zen\mobsi\427: there are extra 3 bytes, after first array element of attPos.

Most likely compiler bug: added explicit cast to workaround it.

DocKDE commented 1 year ago

Fixed after rebuilding with latest commit. Thanks for your work! I'm looking forward to playing one of my favorite games ever without the hassle of setting it up with Wine and the like.