Announcement

Collapse
No announcement yet.

Need help with binary saving

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Need help with binary saving

    Hey everyone!
    I mainly work in blueprints but I do some things like algorithms in c++. My main base classes are also in c++.

    I try to create a binary save system following Rama's tutorial but I'm stuck at the operator << overloads
    When I try to save my data it crashes when trying to save a struct. When I comment out the line for the struct it works and the function saves the vector2d and the fstring.

    Code:
    //This is my custom struct
    USTRUCT(BlueprintType)
    struct FBattleMapTileData
    {
    	GENERATED_BODY()
    
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Battle Map Data")
    		TSubclassOf<AMapTile> TileType;
    
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Battle Map Data")
    		FTransform TileTransform;
    };
    Now the struct is used in an array and this is how my overload looks like:
    Code:
    FORCEINLINE FArchive& operator<<(FArchive &Ar, FBattleMapTileData TileData)
    {
    	Ar << TileData.TileType;
    	Ar << TileData.TileTransform;
    
    	return Ar;
    }
    And finally, this is the conversion function:
    Code:
    //SaveLoadData
    void ABattleMapCreator::SaveLoadData(FArchive& Ar, TArray<ABattleMapData*> BattleMapData)
    {
    	UE_LOG(BattleMapCreator, Log, TEXT("Attempting binary conversion."));
    
    	for (ABattleMapData* map : BattleMapData)
    	{
    		Ar << map->MapSize;
    		Ar << map->MapName;
    		//Ar << map->MapData;
    		for (FBattleMapTileData tile : map->MapData)
    		{
    			Ar << tile;
    		}
    		
    	}
    
    	UE_LOG(BattleMapCreator, Log, TEXT("Converted to binary!"));
    }
    I hope someone can help me! Thanks!

    EDIT: Ok, apparently there is a problem with saving a TSubclassOf type. Is there a way do this?
    Last edited by FloreV; 06-19-2016, 08:32 AM.
    Project Shinrin | Portfolio

    #2
    hi, I know this is an old thread but have you found any solutions to it? I'm kinda guessing that you can't save classes that do not define the << operator.

    Comment

    Working...
    X