OLS/Source/ols/Private/OLSLog.cpp

36 lines
769 B
C++
Raw Normal View History

2025-01-16 18:09:31 +00:00
// © 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"
2025-01-16 20:54:02 +00:00
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("[]");
}