OpenClonk Bugtracker - OpenClonk
View Issue Details
0001379OpenClonkEnginepublic2015-09-04 23:022019-05-07 16:04
ReporterRandrian 
Assigned To 
PrioritynormalSeveritycrashReproducibilityalways
StatusfeedbackResolutionopen 
PlatformGNU G++OSLinuxOS Version 
Product Version 
Target Version8.1Fixed in Version 
Summary0001379: Loading Sections has issues
DescriptionI tried to reimplement quick saving/loading as in the old Harkon game. It worked by switching to another section and saving the section Landscape/Objects/Effects. I attached a Test Szenario. When I call my function SaveGame() the game either crashes or shows a transparent landscape (I tried with different game versions) and the objects are also resetted and not saved, so I think there is something broken with section saving.
TagsNo tags attached.
Attached Fileszip TestSave.ocs.zip (62,485) 2015-09-04 23:02
https://bugs.openclonk.org/file_download.php?file_id=501&type=bug

Notes
(0003795)
Caesar   
2015-09-12 02:50   
(Last edited: 2015-09-12 03:34)
For me it crashes on non-high-res landscape with

#0 C4Pattern::PatternClr (this=0xac0, iX=iX@entry=0, iY=iY@entry=399) at ../src/graphics/C4Draw.cpp:167
#1 0x00000000006c6cc8 in C4LandscapeRenderClassic::Update (this=0x754bf20, To=..., pSource=0xc2b680 <Landscape>) at ../src/landscape/C4LandscapeRenderClassic.cpp:117
#2 0x00000000006c4071 in C4Landscape::Init (this=0xc2b680 <Landscape>, hGroup=..., fOverloadCurrent=fOverloadCurrent@entry=true, fLoadSky=fLoadSky@entry=false, rfLoaded=@0x7ffffffcd92f: true, rfLoaded@entry=@0x7ffffffcd92f: false,
    fSavegame=<optimized out>) at ../src/landscape/C4Landscape.cpp:1526
0000003 0x00000000005c47d2 in C4Game::InitGame (this=this@entry=0xbc4ec0 <Game>, hGroup=..., fLoadSection=fLoadSection@entry=true, fLoadSky=fLoadSky@entry=false, numbers=numbers@entry=0x7ffffffcda30) at ../src/game/C4Game.cpp:2226
#4 0x00000000005c534a in C4Game::LoadScenarioSection (this=0xbc4ec0 <Game>, szSection=<optimized out>, dwFlags=<optimized out>) at ../src/game/C4Game.cpp:3523
0000005 0x00000000005e4536 in FnLoadScenarioSection (_this=<optimized out>, pstrSection=<optimized out>, dwFlags=<optimized out>) at ../src/gamescript/C4GameScript.cpp:2160
0000006 0x00000000005f1d74 in C4AulDefFunc2<long, C4String*, long>::Exec (this=<optimized out>, _this=<optimized out>, pPars=<optimized out>, fPassErrors=<optimized out>) at ../src/script/C4AulDefFunc.h:324
0000007 0x0000000000826782 in C4AulExec::Call (this=this@entry=0xc54100 <AulExec>, pFunc=pFunc@entry=0x2257c90, pReturn=0xc5b268 <AulExec+29032>, pPars=0xc5b268 <AulExec+29032>, pContext=0xc73f70, pContext@entry=0x0)
    at ../src/script/C4AulExec.cpp:891
0000008 0x0000000000828d53 in C4AulExec::Exec (this=this@entry=0xc54100 <AulExec>, pCPos=0x7443740, fPassErrors=fPassErrors@entry=true) at ../src/script/C4AulExec.cpp:673
0000009 0x000000000082dabd in C4AulExec::Exec (this=this@entry=0xc54100 <AulExec>, pSFunc=<optimized out>, p=0xc73f70, pnPars=<optimized out>, fPassErrors=<optimized out>) at ../src/script/C4AulExec.cpp:166
#10 0x000000000082ddab in C4AulScriptFunc::Exec (this=<optimized out>, p=<optimized out>, pPars=<optimized out>, fPassErrors=<optimized out>) at ../src/script/C4AulExec.cpp:1030
0000011 0x000000000084722c in C4AulFunc::Exec (fPassErrors=true, pPars=0x7fffffffc7d0, p=0xc73f70, this=0x6a237b0) at ../src/script/C4AulFunc.h:82
#12 FnCall (_this=0xc73f70, Pars=0xc5b178 <AulExec+28792>) at ../src/script/C4Script.cpp:353
0000013 0x00000000008400f7 in C4AulDefFunc::Exec (this=<optimized out>, p=<optimized out>, pPars=<optimized out>, fPassErrors=<optimized out>) at ../src/script/C4Script.cpp:151
0000014 0x0000000000826782 in C4AulExec::Call (this=this@entry=0xc54100 <AulExec>, pFunc=pFunc@entry=0x1b0da80, pReturn=0xc5b178 <AulExec+28792>, pPars=0xc5b178 <AulExec+28792>, pContext=pContext@entry=0x0) at ../src/script/C4AulExec.cpp:891
0000015 0x0000000000828d53 in C4AulExec::Exec (this=this@entry=0xc54100 <AulExec>, pCPos=0x6b495e0, fPassErrors=fPassErrors@entry=false) at ../src/script/C4AulExec.cpp:673
0000016 0x000000000082dabd in C4AulExec::Exec (this=this@entry=0xc54100 <AulExec>, pSFunc=<optimized out>, p=0x0, pnPars=<optimized out>, fPassErrors=<optimized out>) at ../src/script/C4AulExec.cpp:166
0000017 0x000000000082ddab in C4AulScriptFunc::Exec (this=<optimized out>, p=<optimized out>, pPars=<optimized out>, fPassErrors=<optimized out>) at ../src/script/C4AulExec.cpp:1030
0000018 0x00000000005d55b1 in C4AulFunc::Exec (fPassErrors=false, pPars=0x7fffffffd370, p=<optimized out>, this=<optimized out>) at ../src/script/C4AulFunc.h:82
0000019 C4Effect::Execute (this=<optimized out>, pObj=pObj@entry=0x0) at ../src/gamescript/C4Effect.cpp:303
0000020 0x00000000005c2214 in C4Game::Execute (this=0xbc4ec0 <Game>) at ../src/game/C4Game.cpp:730
0000021 0x00000000005b2912 in C4Application::GameTick (this=0xc00880 <Application>) at ../src/game/C4Application.cpp:707
0000022 0x00000000005b2ae7 in C4ApplicationGameTimer::Execute (this=0x11d1b30, iTimeout=<optimized out>) at ../src/game/C4Application.cpp:903
0000023 0x000000000087cb27 in StdScheduler::DoScheduleProcs (this=0xc00880 <Application>, iTimeout=27) at ../src/platform/StdSchedulerPoll.cpp:175
0000024 0x000000000087b8e8 in StdScheduler::ScheduleProcs (this=this@entry=0xc00880 <Application>, iTimeout=iTimeout@entry=27) at ../src/platform/StdScheduler.cpp:153
#25 0x000000000080199d in C4AbstractApp::Run (this=0xc00880 <Application>) at ../src/platform/C4App.cpp:25
0000026 0x0000000000531e9f in main (argc=2, argv=0x7fffffffd8b8) at ../src/game/ClonkMain.cpp:237

and gives an empty landscape with high-res.

Let's see if I can do something about this.

Edit: Crash happens during second LoadScenarioSection()

(0003796)
Caesar   
2015-09-12 05:24   
I think I fixed the issue with the landscape drawing. Would you mind CC-ing your TestSave.ocs, so I can commit a minimized version as a testcase? (I.e. like done in the forums http://forum.openclonk.org/topic_show.pl?pid=27948#pid27948 )
(0003797)
Randrian   
2015-09-12 06:41   
I hereby license the attached file TestSave.ocs under the CC-BY license.

Fell free to commit it. Thank you for fixing the bug.
(0003798)
Caesar   
2015-09-12 06:48   
Heh. I thought I fixed it with https://bpaste.net/show/d440a899932f.
Further testing revealed that it was only a symptomatic fix.
(0003802)
Sven2   
2015-09-15 04:16   
I've fixed a bug in landscape reinitialization (pushed to repos). Haven't looked at the objects yet.
(0003803)
Caesar   
2015-09-15 14:58   
(Last edited: 2015-09-15 15:00)
Sven: Heh, you got the same patch as I just made on my flight… (Minus two asserts.)
There is something else though: Sky doesn't get handled properly. I think ck borked that with https://git.openclonk.org/openclonk.git/commitdiff/20eb0615 in C4Sky::Init, because the resulting calls through C4Shader::Create don't go through.

(0003804)
Sven2   
2015-09-15 15:43   
We should probably split C4Sky initialization and deinitialization to not re-init shaders on section change.
(0003805)
Clonk-Karl   
2015-09-15 17:15   
The sky shaders have to be re-initialized if the sky changes from fade-sky to bitmap-sky or vice versa. Alternatively, both shaders could be kept around all the time, but given that section change is not very frequent I'd prefer to just re-init the shaders.
(0004436)
Randrian   
2016-01-02 10:33   
Is someone still working on this? I still need this feature for Harkon.
(0004437)
Clonkonaut   
2016-01-02 11:58   

Reminder sent to: Sven2

Sven2 said he might fix this before the release.
(0004493)
Sven2   
2016-01-08 03:29   
I tested again and couldn't see any problems in the test scenario.

The clonk is not reset because it's in the deactivated list. So it looks like that is intended. Landscape and other objects are saved and loaded.

I would also recommend either carrying over the GUI or deleting and reinitializing it.
(0006260)
Foaly   
2019-05-07 16:04   
I can reproduce the crash on git master.
I also have a small fix for it, but objects are still not saved.

About the crash:
It seems that in C4Landscape.cpp:Init, in line 1582 the landscape is cleared, but in InitBorderPix it is assumed that p->Map is non-null.
I fixed that by scaling Surface8 down and putting it in Map.

Issue History
2015-09-04 23:02RandrianNew Issue
2015-09-04 23:02RandrianFile Added: TestSave.ocs.zip
2015-09-12 02:50CaesarNote Added: 0003795
2015-09-12 03:34CaesarNote Edited: 0003795bug_revision_view_page.php?bugnote_id=3795#r923
2015-09-12 05:24CaesarNote Added: 0003796
2015-09-12 06:41RandrianNote Added: 0003797
2015-09-12 06:48CaesarNote Added: 0003798
2015-09-15 03:48Sven2Assigned To => Sven2
2015-09-15 03:48Sven2Statusnew => assigned
2015-09-15 04:16Sven2Note Added: 0003802
2015-09-15 14:58CaesarNote Added: 0003803
2015-09-15 15:00CaesarNote Edited: 0003803bug_revision_view_page.php?bugnote_id=3803#r925
2015-09-15 15:43Sven2Note Added: 0003804
2015-09-15 17:15Clonk-KarlNote Added: 0003805
2015-10-16 00:33Sven2Target Version => 7.0
2016-01-02 10:33RandrianNote Added: 0004436
2016-01-02 11:58ClonkonautNote Added: 0004437
2016-01-08 03:27Sven2Assigned ToSven2 => Randrian
2016-01-08 03:29Sven2Note Added: 0004493
2016-01-08 03:29Sven2Statusassigned => feedback
2016-01-09 20:16Sven2Target Version7.0 => 7.1 (Bugfix update)
2017-08-05 09:06MaikelTarget Version7.1 (Bugfix update) => 8.0
2017-08-20 11:43ZapperAssigned ToRandrian =>
2017-08-20 11:43ZapperTarget Version8.0 => 8.1
2019-05-07 16:04FoalyNote Added: 0006260