mordentral / AdvancedSessionsPlugin

Advanced Sessions Plugin for UE4
https://www.vreue4.com
MIT License
597 stars 141 forks source link

UE5.2 Compile Error (Missing arguments when getting an interface) #73

Closed Scylin232 closed 1 year ago

Scylin232 commented 1 year ago

Hello, firstly, I really appreciate your efforts, keeping such a complex project solo for 8 years is 👏

I have a problem adding a plugin to my project. My project version is 5.2, downloaded the plugin version from the website also under 5.2 (Although the .uplugin file says 5.1, I think it should be). My project doesn't want to compile (I'm using C++), the compilation error indicates a violation of the number of parameters on the engine's internal online system. I've tried: Regenerate files, Plugin Downgrade, Try to run only binaries without compiling. Seems like local error, but i can't understand why this happens.

image

Code of my examinations:

// Error Point:
IOnlineFriendsPtr Friends = Online::GetFriendsInterface();

// Official Documentation Says That It Should Be:
namespace Online { 
   static IOnlineFriendsPtr Online::GetFriendsInterface ( const FName SubsystemName ) 
}

// But rider show's me (File: OnlineSubsystemUtils.h):
IMPLEMENT_GET_INTERFACE(Friends);

// Looks Like Something Was Deleted From Cooked Unreal Engine 5.2? Should i fix it myself through editing plugin's source or that is an error? Thanks!
mordentral commented 1 year ago
/** Macro to handle the boilerplate of accessing the proper online subsystem and getting the requested interface */
#define IMPLEMENT_GET_INTERFACE(InterfaceType) \
static IOnline##InterfaceType##Ptr Get##InterfaceType##Interface(const FName SubsystemName = NAME_None) \
{ \
    IOnlineSubsystem* OSS = IOnlineSubsystem::Get(SubsystemName); \
    return (OSS == NULL) ? NULL : OSS->Get##InterfaceType##Interface(); \
} \

That macro has a default parameter of NAME_None, it should compile just fine as is. Are you trying to use the BP nodes IN c++?

Edit Ah actually I see what you mean, its using the macro as the template parameter now.

mordentral commented 1 year ago

I did check through the source though and it has been this way since 4.27, and I am testing on a 5.2.1 binary engine version and its working fine for me?

Can't just pass in a subsystem name as we don't know it (would have to have the users pass it in with every request or iterate a list to set a default).

Alternative accessor is the direct: OnlineSub = Online::GetSubsystem(InWorld, NAME_None);

Pathway, however this method has been working for many many engine versions so far and hasn't recently changed so it should still be fine?

Scylin232 commented 1 year ago

I honestly don't know why, but when I added '#include "Online.h"' to each of the files (cpp files, not headers), everything worked, I literally just checked it. It looks like the linker didn't work well in my environment. I'm pretty sure my engine is not modified since I reinstalled it before writing this post. Maybe someone else has this problem? Should I create a Pull Request with corrections or is it a vestige? Thanks a lot for your answer!

mordentral commented 1 year ago

Mmm, yeah specifying online.h may do it, compilers and UE are very fiddly.

If you want to pull request it as a fix so you can have submission credits on the plugin feel free ;p

Otherwise i'll make the same change this weekend.

Scylin232 commented 1 year ago

I want to make sure the include doesn't break anything in production, because sometimes rewriting imports can make things not work correctly. If you are sure that everything will be fine, then yes, I will create a pull-request right away, if you don't mind my testing - then please wait, just one day :) Thanks for your answers again!

Scylin232 commented 1 year ago

Hello! I made sure that everything works as it should, on the build in development / in shipping the behavior is correct, I created a pull request, you can find it here: #74

mordentral commented 1 year ago

Merged, thank you.

Helps to have the one with the compilation issues do it in the first place as I don't have to assume I caught it all.

Scylin232 commented 1 year ago

You're welcome! I am pleased to help this project, because thanks to it, a very large part of the games in Steam and not only work in principle. Even despite such minor changes. Thank you for the project again!