Crash with TArray of custom struct
I'm attempting to keep track of some data in my game per player in a networked instance. I have a lobby of sorts where a player can select a character, and I store that data with this struct:
My game instance class is where I'm holding an array of this struct:
My crash comes in where I'm trying to add an element to the array:
In the debugger, I'm seeing the selections array as "Invalid." Am I missing a proper initialization? I've tried CharacterSelections.Init() with and without data and I still get the same crash.
Here's the relevant portion of the callstack
I think I'm getting closer. (I only get maybe an hour a day to work on this, so going is slow heh) I've simplified the code a lot to isolate the problem.
There's a series of events involved, and I'm beginning to realize that may be the root of my problem, so here's the entire flow:
I have the following objects involved: ShipItGameInstance ShipItGameMode ShipItPlayerController
In ShipItPlayerController, I have this function which sets things off in motion. In our game, players can change their character on the fly so this event sends off a request to the server to change characters.
Game mode then tries to fulfill the character change request. This may be the wrong place to put the code, but it's what came to mind first I guess.
The crash only happens when CreateOrUpdatePlayerSelection() is called from game mode. When running the debugger, I get a break when I first run the editor, and I can see the TArray is valid and an element is added. When I hit a breakpoint as it's being called from game mode, it's listed as "invalid."
My questions thusfar
When I run a debug instance, I get a breakpoint in the constructor for gameinstance immediately. This is expected from the documentation. I can add an element to the array just fine at this point. I'm NOT getting a breakpoint when I run a new PIE instance - I am expecting to get one based on the documentation here: https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Engine/UGameInstance/index.html
Seeing as the gameinstance object code is running, and crashing, I know I have a reference to AN instance somewhere. What could be making this gameinstance's member variables invalid?
I am so ashamed.
I forgot to add my game instance class to the defaultengine.ini.
Thank you Doug for your patience and dedication to this forum. I will don my dunce cap now.
answered Jan 08 '16 at 03:24 AM
Have you tried .Add instead of .Push? I guess it won't make a difference, but you never know.
answered Dec 29 '15 at 03:43 PM
We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will offer further assistance.
answered Jan 05 '16 at 05:19 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here