trdwll / SteamBridge

An Unreal Engine implementation of the Steamworks API.
https://trdwll.com/experiments/steambridge/
MIT License
134 stars 20 forks source link

Crashing in USteamFriends::GetFriendMessage #10

Open Drakynfly opened 3 years ago

Drakynfly commented 3 years ago

I have discovered that the function USteamFriends::GetFriendMessage seems to always crash. After some poking around I figured out that changing the uses of MAX_int32 to a much smaller number fixes this crash. It seems to me that it should not have been trying to allocate an array of that size anyway. This is the relevant lines from your version:

    TmpMessage.SetNum(MAX_int32);
    int32 res = SteamFriends()->GetFriendMessage(SteamIDFriend, MessageIndex, TmpMessage.GetData(), MAX_int32, &TmpEntryType);

And this is after my change:

    const int32 MaxMessageLength = 2048;
    TmpMessage.SetNum(MaxMessageLength);
    int32 res = SteamFriends()->GetFriendMessage(SteamIDFriend, MessageIndex, TmpMessage.GetData(), MaxMessageLength, &TmpEntryType);

But before I make a pull request about this, I was wondering if you have a better number to use. I used 2048 in my local repo and that worked fine. (I actually tested by messaging a steam friend in an in-game chat window and displayed their messages back.) If there is a defined max length to messages that steam allows that would be ideal.