pioneerspacesim / pioneer

A game of lonely space adventure
https://pioneerspacesim.net
1.62k stars 374 forks source link

After reloading a previous save, Bulletin Board is empty #5886

Open lolo101 opened 1 month ago

lolo101 commented 1 month ago

Observed behaviour

After landing at a station, I reloaded a save where I was in another system. Then I fly to the same station again and this time the Bulletin Board is empty image

Expected behaviour

The Bulletin Board should show some missions, ads and so on

Steps to reproduce

Load the attached savegame and open the station's BB

My pioneer version (and OS):

20240710 (e123a3f91) (Linux)

My output.txt (required) and game save (optional, but recommended)

output.txt lolo1.gz

lolo101 commented 1 month ago

Might be related to https://github.com/pioneerspacesim/pioneer/issues/899 but not sure since the fix was delivered more than a decade ago :slightly_smiling_face:

impaktor commented 1 month ago

Strange / new one. I'd be surprised if it has anything to do with an issue as old as 899, since populating the BBS adverts was re-written just 1-2 years ago, and the UI has been completely re-written since then as well - twice I think, since that must be OldUI (-> NewUI -> PiGui).

zonkmachine commented 1 month ago

I've seen this before and I assumed it was related to https://github.com/pioneerspacesim/pioneer/issues/5305 which I was testing at the time . When I load the save in lolo1.gz and let it run for a while, the ship market is updated as it should but there are no new ads in the BBS ever so it's properly crashed.

Since the ship market is updated and updateShipsOnSale(station) and updateAdverts(station) are called at the same time we know that call is made.

I checked the Lua console and this logwarning is firing: "SpaceStation.lua: updateAdverts called for station that hasn't been visited"

When I comment out all lines except Event.Queue("onUpdateBB", station) in updateAdverts(), the BBS starts to repopulate itself. https://github.com/pioneerspacesim/pioneer/blob/e123a3f91518ff4d0c84f90270803bf87dd2848c/data/libs/SpaceStation.lua#L901-L907

zonkmachine commented 1 month ago

Maybe updateAdverts() should look something like:

local function updateAdverts (station)
    if not SpaceStation.adverts[station] then
        logWarning("SpaceStation.lua: updateAdverts called for station that hasn't been visited")
    end
    Event.Queue("onUpdateBB", station)
end
Web-eWorks commented 3 weeks ago

If there isn't a SpaceStation.adverts[station] then the station's cached data needs to be re-created and new BBS adverts generated, yes. This is an edge-case scenario which suggests there is a deeper bug causing the station to be in an invalid / partially-valid state.

zonkmachine commented 2 weeks ago

About my fix above, From #5894,

This fix will cause the BBS to repopulate itself but only from those modules that impements onUpdateBB().

Right. If we can repopulate the BBS with onUpdateBB, can't we as well recreate it completely with onCreateBB?

 local function updateAdverts (station) 
    if not SpaceStation.adverts[station] then 
        logWarning("SpaceStation.lua: updateAdverts called for station that hasn't been visited") 
        Event.Queue("onCreateBB", station) 
    else 
        Event.Queue("onUpdateBB", station) 
    end 
 end

@Web-eWorks

Web-eWorks commented 2 weeks ago

Yes, onCreateBB should be the correct function to use if there is no bulletin board data.

zonkmachine commented 2 weeks ago

Yes, onCreateBB should be the correct function to use if there is no bulletin board data.

OK, fixed in: https://github.com/pioneerspacesim/pioneer/pull/5912