Skip to content
Snippets Groups Projects
Commit 57f7d5eb authored by cos-erm's avatar cos-erm
Browse files

Revert "Raw to unique pointer - allows for newer and older dll versions"

This reverts commit 16aebf1d.
parent 16aebf1d
No related branches found
No related tags found
No related merge requests found
...@@ -59,8 +59,8 @@ bool FVAPlugin::bUseVA = true; ...@@ -59,8 +59,8 @@ bool FVAPlugin::bUseVA = true;
bool FVAPlugin::bDebugMode = true; bool FVAPlugin::bDebugMode = true;
// Interface Classes to Server // Interface Classes to Server
std::unique_ptr<IVANetClient> FVAPlugin::VANetClient; IVANetClient* FVAPlugin::VANetClient;
std::unique_ptr<IVAInterface> FVAPlugin::VAServer; IVAInterface* FVAPlugin::VAServer;
// Link to the current receiver actor // Link to the current receiver actor
AVAReceiverActor* FVAPlugin::ReceiverActor = nullptr; AVAReceiverActor* FVAPlugin::ReceiverActor = nullptr;
...@@ -293,16 +293,7 @@ bool FVAPlugin::ConnectServer(const FString HostF, const int Port) ...@@ -293,16 +293,7 @@ bool FVAPlugin::ConnectServer(const FString HostF, const int Port)
FVAUtils::LogStuff("[FVAPlugin::ConnectServer()]: Connecting to VAServer. Be sure to have it switched on", false); FVAUtils::LogStuff("[FVAPlugin::ConnectServer()]: Connecting to VAServer. Be sure to have it switched on", false);
try try
{ {
VANetClient = []() { VANetClient = IVANetClient::Create();
if constexpr (std::is_same_v<decltype(IVANetClient::Create()),std::unique_ptr<IVANetClient>>) {
// New dll (>= 2025) with unique pointer
return IVANetClient::Create();
}
else {
// Old dll with raw pointer -> convert to unique pointer
return std::unique_ptr<IVANetClient>{IVANetClient::Create()};
}
}();
const std::string HostS(TCHAR_TO_UTF8(*HostF)); const std::string HostS(TCHAR_TO_UTF8(*HostF));
VANetClient->Initialize(HostS, Port); VANetClient->Initialize(HostS, Port);
...@@ -313,22 +304,7 @@ bool FVAPlugin::ConnectServer(const FString HostF, const int Port) ...@@ -313,22 +304,7 @@ bool FVAPlugin::ConnectServer(const FString HostF, const int Port)
return false; return false;
} }
VAServer = []() -> std::unique_ptr<IVAInterface> { VAServer = VANetClient->GetCoreInstance();
using IVANetInstance = decltype(std::declval<IVANetClient>());
if constexpr (std::is_same_v<
decltype(std::declval<IVANetInstance>().GetCoreInstance()),
std::unique_ptr<IVAInterface>
>) {
// New dll (>= 2025)
return std::move(VANetClient->GetCoreInstance());
}
else {
// Old dll
return std::unique_ptr<IVAInterface>{VANetClient->GetCoreInstance()};
}
}();
VAServer->Reset(); VAServer->Reset();
} }
catch (CVAException& e) catch (CVAException& e)
......
...@@ -179,8 +179,8 @@ protected: ...@@ -179,8 +179,8 @@ protected:
static bool bDebugMode; // bool if is in Debug Mode static bool bDebugMode; // bool if is in Debug Mode
// Interface Classes to Server // Interface Classes to Server
static std::unique_ptr<IVANetClient> VANetClient; // VA Net Client static IVANetClient* VANetClient; // VA Net Client
static std::unique_ptr<IVAInterface> VAServer; // VA Server Interface static IVAInterface* VAServer; // VA Server Interface
// Link to the current receiver actor // Link to the current receiver actor
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment