From ae8986e788e11975867408d055166f7bd4be41be Mon Sep 17 00:00:00 2001 From: Jon Booth Date: Thu, 5 Oct 2023 21:41:13 +1300 Subject: [PATCH] Don't add a docking flight log when the player starts the game in a station. --- data/libs/FlightLog.lua | 16 ++++++++++++++++ data/pigui/modules/new-game-window/class.lua | 1 + 2 files changed, 17 insertions(+) diff --git a/data/libs/FlightLog.lua b/data/libs/FlightLog.lua index b981ec7e61d..bb994155179 100644 --- a/data/libs/FlightLog.lua +++ b/data/libs/FlightLog.lua @@ -23,6 +23,10 @@ local Lang = require 'Lang' local l = Lang.GetResource("ui-core") -- end of formating / localisation stuff +---@type boolean|nil If true then we've just started a game so don't record the first docking callback +local skip_first_docking = nil + + -- default values (private) ---@type integer local MaxTotalDefaultElements = 3000 @@ -474,6 +478,11 @@ FlightLog = { } + + +function FlightLog.SkipFirstDocking() + skip_first_docking = true +end -- -- Method: GetLogEntries -- @@ -616,6 +625,13 @@ end local AddStationToLog = function (ship, station) if not ship:IsPlayer() then return end + -- could check the game time and see if it's the same as the last custom event + -- and there is nothing else in the list and avoud the phantom 'first docking' + -- that way too. + if skip_first_docking then + skip_first_docking = nil + return + end table.insert( FlightLogData, 1, StationLogEntry.New( station.path, Game.time, Game.player:GetMoney(), nil ) ); TrimLogSize() end diff --git a/data/pigui/modules/new-game-window/class.lua b/data/pigui/modules/new-game-window/class.lua index efdcbe31889..01d65a2be3c 100644 --- a/data/pigui/modules/new-game-window/class.lua +++ b/data/pigui/modules/new-game-window/class.lua @@ -170,6 +170,7 @@ local function startGame(gameParams) -- XXX horrible hack here to avoid paying a spawn-in docking fee player:setprop("is_first_spawn", true) + FlightLog.SkipFirstDocking() FlightLog.MakeCustomEntry(gameParams.player.log) if gameParams.autoExec then