Announcement

Collapse
No announcement yet.

typedef support for Unreal Header Tool

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

  • replied
    This was years ago so I'm not sure, but now I just use structs for this kind of thing and wrap with USTRUCT(), then create operator overloads if I need to.

    A struct doesn't cost anything more than the sum of it's types in terms of memory and replication cost etc. If anything you can benefit from using a USTRUCT() because you can write your own network serialization code via NetSerialize() etc.

    Leave a comment:


  • replied
    I'm curious, what approach did you end up taking TheJamsh? I'm doing some periodic calculations necessary for the Vision system in an RTS game, so I opted for Bit field operations. I wanted to use replication though, and that's when I hit the wall of `typedef uint32 PlayersMask` not supported by UHT.

    Should I do something similar to your alternative?
    Code:
    struct FPlayersMask
    Is there a better approach suggested? I'm concerned about the performance cost of introducing a whole struct where I really want speed (hence the Bitwise operations in the first place)

    Leave a comment:


  • replied
    Yeah, at the time I vastly underestimated just how difficult this is. I don't think this will ever be supported.

    Leave a comment:


  • replied
    It isn't easy to do this unfortunately and I doubt they Epic will add this ever. `#define` will never be added to UHT as it is way to complex due to you being able to include `#define` instead `#define`.

    Leave a comment:


  • replied
    I'm just going to bump this since it still does not work at least on my end.

    Leave a comment:


  • typedef support for Unreal Header Tool

    Simple request, this won't compile because UHT doesn't recognise the type.

    Code:
    typedef uint8 TeamID;
    
    UPROPERTY()
    TeamID MyTeam;
    
    UFUNCTION(BlueprintCallable)
    void MyFunction(TeamID InTeam);
    There's not really any logical reason why this shouldn't work, and surely it should be fairly trivial to allow UHT to check if a typedef is a supported type for reflection?

    You can't use #define either, as it turns out

    Code:
    #define TeamID uint8
    
    UPROPERTY()
    TeamID MyTeam;
    
    UFUNCTION(BlueprintCallable)
    void MyFunction(TeamID InTeam);
    Instead, I have to use a struct. This seems overly complex:
    Code:
    USTRUCT(BlueprintType)
    struct FTeamID
    {
    	GENERATED_BODY()
    
    public:
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Team")
    	uint8 TeamID;
    
    	FTeamID()
    		: TeamID(0)
    	{}
    
    	FTeamID(const uint8 InTeamID)
    		: TeamID(InTeamID)
    	{}
    
    	FORCEINLINE bool operator==(const FTeamID& Other) const
    	{
    		return TeamID == Other.TeamID;
    	}
    
    	FORCEINLINE bool operator!=(const FTeamID& Other) const
    	{
    		return TeamID != Other.TeamID;
    	}
    
    	FORCEINLINE bool operator>=(const FTeamID& Other) const
    	{
    		return TeamID >= Other.TeamID;
    	}
    
    	FORCEINLINE bool operator>(const FTeamID& Other) const
    	{
    		return TeamID > Other.TeamID;
    	}
    
    	FORCEINLINE bool operator<=(const FTeamID& Other) const
    	{
    		return TeamID <= Other.TeamID;
    	}
    
    	FORCEINLINE bool operator<(const FTeamID& Other) const
    	{
    		return TeamID < Other.TeamID;
    	}
    };
    
    UPROPERTY()
    TeamID MyTeam;
    
    UFUNCTION(BlueprintCallable)
    void MyFunction(TeamID InTeam);
    Last edited by TheJamsh; 05-03-2017, 09:27 AM.
Working...
X