OLS/Source/ols/Private/OLSLog.cpp
2025-01-16 13:54:02 -07:00

36 lines
769 B
C++

// © 2024 Long Ly. All rights reserved. Any unauthorized use, reproduction, or distribution of this trademark is strictly prohibited and may result in legal action.
#include "OLSLog.h"
FString GetClientServerContextString(UObject* contextObject)
{
ENetRole role = ROLE_None;
if (AActor* actor = Cast<AActor>(contextObject))
{
role = actor->GetLocalRole();
}
else if (UActorComponent* component = Cast<UActorComponent>(contextObject))
{
role = component->GetOwnerRole();
}
if (role != ROLE_None)
{
return (role == ROLE_Authority) ? TEXT("Server") : TEXT("Client");
}
else
{
#if WITH_EDITOR
if (GIsEditor)
{
extern ENGINE_API FString GPlayInEditorContextString;
return GPlayInEditorContextString;
}
#endif
}
return TEXT("[]");
}