I am still getting the same results after multiple ways of handling my arrays differently.
//header
void UpdateArray(TArray<bool>& ArrayToUpdate, TArray<bool> NewValues)
//implementation
{
ArrayToUpdate.Empty();
for(int i = 0; i < NewValues.Num() - 1; i++)
{
ArrayToUpdate.Add(NewValues*);
UE_LOG(LogTemp, Warning, TEXT("Value is %s at %i"), ArrayToUpdate* ? TEXT("true") : TEXT("false"), i);
}
UE_LOG(LogTemp, Warning, TEXT("New Array length is %i"), ArrayToUpdate.Num());
}
I now think it is an issue with how I am loading the game. The code below are changes I have made to my original code to handle using the UpdateArray function (I really need to remove those logs, so much spam but it all looks like it works until I load the data)
DDGameInstance.h
void UDDGameInstance::LoadGame()
{
UDDSaveGame* LoadedGame = Cast<UDDSaveGame>(UGameplayStatics::CreateSaveGameObject(UDDSaveGame::StaticClass()));
if (LoadedGame = Cast<UDDSaveGame>(UGameplayStatics::LoadGameFromSlot(TEXT("SaveGame"), 0)))
{
TArray<bool> TempChest, TempLegs, TempFace, TempHands, TempHair, TempBeard, TempEyebrows;
// The operation was successful, so LoadedGame now contains the data we saved earlier.
LoadedGame->LoadGame(TempChest, TempLegs, TempFace, TempHands, TempHair, TempBeard, TempEyebrows, bMaleCharacter, CurrentCoins, SelectedChest, SelectedLegs, SelectedFace, SelectedHands, SelectedHair, SelectedBeard, SelectedEyebrows, SelectedGameMusic, SelectedMenuMusic);
UpdateArray(bHasChest, TempChest);
UpdateArray(bHasLegs, TempLegs);
UpdateArray(bHasFace, TempFace);
UpdateArray(bHasHands, TempHands);
UpdateArray(bHasHair, TempHair);
UpdateArray(bHasBeard, TempBeard);
UpdateArray(bHasEyebrows, TempEyebrows);
UE_LOG(LogTemp, Warning, TEXT("GAME LOADED FROM GAME INSTANCE! Lenght of hair bool array is %i"), bHasHair.Num());
}
}
DDSaveGame.cpp
void UDDSaveGame::FullSave(TArray<bool> Chests, TArray<bool> Legs, TArray<bool> Faces, TArray<bool> Hands, TArray<bool> Hairs, TArray<bool> Beards, TArray<bool> Eyebrows, bool MaleCharacter, int Coins, int Chest, int Leg, int Face, int Hand, int Hair, int Beard, int Eyebrow, int GameMusic, int MenuMusic)
{
UpdateArray(SavedChests, Chests);
UpdateArray(SavedLegs, Legs);
UpdateArray(SavedFaces, Faces);
UpdateArray(SavedHands, Hands);
UpdateArray(SavedHairs, Hairs);
UpdateArray(SavedBeards, Beards);
UpdateArray(SavedEyebrows, Eyebrows);
bSaveMaleCharacter = MaleCharacter;
CurrentCoins = Coins;
SelectedChest = Chest;
SelectedLegs = Leg;
SelectedFace = Face;
SelectedHands = Hand;
SelectedHair = Hair;
SelectedBeard = Beard;
SelectedEyebrows = Eyebrow;
SelectedGameMusic = GameMusic;
SelectedMenuMusic = MenuMusic;
UE_LOG(LogTemp, Warning, TEXT("Game Saved from GameSave"));
}
void UDDSaveGame::LoadGame(TArray<bool>& ChestsOUT, TArray<bool>& LegsOUT, TArray<bool>& FacesOUT, TArray<bool>& HandsOUT, TArray<bool>& HairsOUT, TArray<bool>& BeardsOUT, TArray<bool>& EyebrowsOUT, bool& MaleCharacterOUT, int& CoinsOUT, int& ChestOUT, int& LegOUT, int& FaceOUT, int& HandOUT, int& HairOUT, int& BeardOUT, int& EyebrowOUT, int& GameMusicOUT, int& MenuMusicOUT)
{
UpdateArray(ChestsOUT, SavedChests);
UpdateArray(LegsOUT, SavedLegs);
UpdateArray(FacesOUT, SavedFaces);
UpdateArray(HandsOUT, SavedHands);
UpdateArray(HairsOUT, SavedHairs);
UpdateArray(BeardsOUT, SavedBeards);
UpdateArray(EyebrowsOUT, SavedEyebrows);
MaleCharacterOUT = bSaveMaleCharacter;
CoinsOUT = CurrentCoins;
ChestOUT = SelectedChest;
LegOUT = SelectedLegs;
FaceOUT = SelectedFace;
HandOUT = SelectedHands;
HairOUT = SelectedHair;
BeardOUT = SelectedBeard;
EyebrowOUT = SelectedEyebrows;
GameMusicOUT = SelectedGameMusic;
MenuMusicOUT = SelectedMenuMusic;
UE_LOG(LogTemp, Warning, TEXT("GameMusic Value is %i and should be 3"), SelectedGameMusic);
}
I definitely am not saving/loading the game correctly since GameMusic is defaulting to 0 or whatever I have the defaults set to in DDSaveGame…