SCS hooked component on PlayerState no longer saving correctly
seems like FreeSamples is broken now for dedicated server clients, not certain exactly when this happened, guessing 1.0?
I'm saving data via a component added via SCS hooks on PlayerState. and I can confirm it's saving something, but it seems like after my player disconnects from the server, a new blank data component spawns for them and overwrites their old one before the save actually takes place, see logs in below message

38 Replies
this log is from right before the player leaves
this log is from when the save loads:
What is the owner of the rogue component?
my parent is
messages display the owner
which is a player state object with a different id#, so I wonder if a whole new player state is getting spawned?
@Rex [they/them] if I recall correctly you set up Flashlight Settings also does saving on player state without this issue?grammar 👮

pushed some extra logging if you decide to clone
for comparison, here is saving in singleplayer:
and the new player state creation doesn't happen during singleplayer world exit
here is loading in singleplayer:
I don't know if this will be helpful but I looked at this in the first log
[980]LogNet: - Result=ControlChannelClose, ErrorContext="ControlChannelClose"
, and google-fu'd it and came up with this QA post from Sept 10th with a nearly identical log and similar scenario.
Apparently an issue when someone connected to the server via localhost disconnects?
https://questions.satisfactorygame.com/post/66e0b26d772a987f4a8aa1d8hmmm, it's true that I am connecting on localhost, but I'm not sure it would make a difference here. I can test on my unraid server but it will be annoyingly slow sadly
I couldn't remember for sure if that's how you tested but it tripped a bell when I saw it, and it was a QA post
I don't think I've checked that because I only need to persist stuff while the player is connected
can confirm it also happens on my unraid (not localhost)
might be worth adding a per-player saved value to examplemod as a demo and to further test this...
the spawning of new components after player leave is happening for examplemod as well, it's not just something in freesamples
pushed to the
examplemod-per-player-data
branch
@Archengius do you have any insights as to what could be causing this? if I recall correctly, SCS hooked component on player state was your suggested method for storing per-player saved data. small scale code to reproduce it is on examplemod-per-player-data
branch, if the log messages and description above are not enough detailHave you hooked OverridePlayerState to copy your data from old player state to a new one?
Nope, didn't know that was a step that had to happen, and discord search says your message here is the only mention of it. I can look into it this evening, but it sounds like that will have to be hooked in C++... Not ideal, that means we can't have it in examplemod until we have a hybrid example mod
Hmmm, would it make sense to provide something (delegate?) in the FG player state for BPs to work with?
Yes
it looks like OverridePlayerState is on UE's GameMode and FG does not override it anywhere?
so the task here would be hook this function (on
BP_GameMode
, in c++ because the function is implemented in c++ and not blueprint as far as I can tell), and then when it's called, get the component on the passed old player state and copy its data to the component being used on the player state of the passed player controller?function might have a different name
it's on AFGPlayerState
might be called CopyPlayerState
?

here we go
yeah it's CopyProperties
looks like bp has an event, not sure of Bind on BP Function can do events, I might be able to look into that this evening

ah nevermind, Bind on BPFunction doesn't get function arguments, still has to be c++
eh, bp hooking it succeeds but the hook never seems to fire anyways


it sounds like it might be
OverrideWith
/ReceiveOverrideWith
?
and the fact that the action function name is ReceiveCopyProperties
might be why my bp hook wasn't firing...
maybe I'll need both

I imagine a long-term solution would be to provide a delegate or something in
AFGPlayerState
and call it from CopyProperties
Looks like there's a pattern to call both C++ and BP implementations
Okay, cursed idea time: get player state components by class/interface, and for each of them call their CopyProperties
/ OverrideWith
functions or somethingI would like to get this working before the long term solution comes out in 1.1 assuming it doesn't drive me insane
although it looks like it may drive me insane
not sure how to hook a protected function in engine code (APlayerState) since access transformers can't affect engine stuff
I can hook
AFGPlayerState::CopyProperties
since it's in fg code, but not OverrideWith
, which sounds like the one I actually care about
here's what I have thus far (fails to build because can't subscribe APlayerState)
Consider hooking these instead:
I am blind, those ones are public, yup
I thought you were Robb
incorrect

yup this seems to be the way. both functions are called, Override on join and Copy on leave before save, and my hooks seem to be working
traveling this weekend though, so further testing will have to wait
what I currently have
The issue has been addressed for 1.1