本文整理汇总了C++中FUniqueNetIdRepl类的典型用法代码示例。如果您正苦于以下问题:C++ FUniqueNetIdRepl类的具体用法?C++ FUniqueNetIdRepl怎么用?C++ FUniqueNetIdRepl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FUniqueNetIdRepl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetPartyLeader
bool UPartyBeaconState::GetPartyLeader(const FUniqueNetIdRepl& InPartyMemberId, FUniqueNetIdRepl& OutPartyLeaderId) const
{
bool bFoundReservation = false;
if (InPartyMemberId.IsValid())
{
for (int32 ResIdx = 0; ResIdx < Reservations.Num() && !bFoundReservation; ResIdx++)
{
const FPartyReservation& ReservationEntry = Reservations[ResIdx];
const FPlayerReservation* PlayerRes = ReservationEntry.PartyMembers.FindByPredicate(
[InPartyMemberId](const FPlayerReservation& ExistingPlayerRes)
{
return InPartyMemberId == ExistingPlayerRes.UniqueId;
});
if (PlayerRes)
{
UE_LOG(LogBeacon, Display, TEXT("Found party leader for member %s."), *InPartyMemberId.ToString());
OutPartyLeaderId = ReservationEntry.PartyLeader;
bFoundReservation = true;
break;
}
}
if (!bFoundReservation)
{
UE_LOG(LogBeacon, Warning, TEXT("Found no reservation for player %s, while looking for party leader."), *InPartyMemberId.ToString());
}
}
return bFoundReservation;
}
示例2: UpdatePartyLeader
void UPartyBeaconState::UpdatePartyLeader(const FUniqueNetIdRepl& InPartyMemberId, const FUniqueNetIdRepl& NewPartyLeaderId)
{
if (InPartyMemberId.IsValid() && NewPartyLeaderId.IsValid())
{
bool bFoundReservation = false;
for (int32 ResIdx = 0; ResIdx < Reservations.Num() && !bFoundReservation; ResIdx++)
{
FPartyReservation& ReservationEntry = Reservations[ResIdx];
FPlayerReservation* PlayerRes = ReservationEntry.PartyMembers.FindByPredicate(
[InPartyMemberId](const FPlayerReservation& ExistingPlayerRes)
{
return InPartyMemberId == ExistingPlayerRes.UniqueId;
});
if (PlayerRes)
{
UE_LOG(LogBeacon, Display, TEXT("Updating party leader to %s from member %s."), *NewPartyLeaderId.ToString(), *InPartyMemberId.ToString());
ReservationEntry.PartyLeader = NewPartyLeaderId;
bFoundReservation = true;
break;
}
}
if (!bFoundReservation)
{
UE_LOG(LogBeacon, Warning, TEXT("Found no reservation for player %s, while updating party leader."), *InPartyMemberId.ToString());
}
}
}
示例3: DumpReservations
void APartyBeaconHost::DumpReservations() const
{
FUniqueNetIdRepl NetId;
FPlayerReservation PlayerRes;
UE_LOG(LogBeacon, Display, TEXT("Debug info for Beacon: %s"), *BeaconName);
UE_LOG(LogBeacon, Display, TEXT("Session that reservations are for: %s"), *SessionName.ToString());
UE_LOG(LogBeacon, Display, TEXT("Number of teams: %d"), NumTeams);
UE_LOG(LogBeacon, Display, TEXT("Number players per team: %d"), NumPlayersPerTeam);
UE_LOG(LogBeacon, Display, TEXT("Number total reservations: %d"), MaxReservations);
UE_LOG(LogBeacon, Display, TEXT("Number consumed reservations: %d"), NumConsumedReservations);
UE_LOG(LogBeacon, Display, TEXT("Number of party reservations: %d"), Reservations.Num());
// Log each party that has a reservation
for (int32 PartyIndex = 0; PartyIndex < Reservations.Num(); PartyIndex++)
{
NetId = Reservations[PartyIndex].PartyLeader;
UE_LOG(LogBeacon, Display, TEXT(" Party leader: %s"), *NetId->ToString());
UE_LOG(LogBeacon, Display, TEXT(" Party team: %d"), Reservations[PartyIndex].TeamNum);
UE_LOG(LogBeacon, Display, TEXT(" Party size: %d"), Reservations[PartyIndex].PartyMembers.Num());
// Log each member of the party
for (int32 MemberIndex = 0; MemberIndex < Reservations[PartyIndex].PartyMembers.Num(); MemberIndex++)
{
PlayerRes = Reservations[PartyIndex].PartyMembers[MemberIndex];
UE_LOG(LogBeacon, Display, TEXT(" Party member: %s"), *PlayerRes.UniqueId->ToString());
}
}
UE_LOG(LogBeacon, Display, TEXT(""));
}
示例4: UnregisterPlayer
void AGameSession::UnregisterPlayer(FName InSessionName, const FUniqueNetIdRepl& UniqueId)
{
UWorld* World = GetWorld();
if (GetNetMode() != NM_Standalone &&
UniqueId.IsValid() &&
UniqueId->IsValid())
{
// Remove the player from the session
UOnlineEngineInterface::Get()->UnregisterPlayer(World, InSessionName, *UniqueId);
}
}
示例5: ProcessCancelReservationRequest
void APartyBeaconHost::ProcessCancelReservationRequest(APartyBeaconClient* Client, const FUniqueNetIdRepl& PartyLeader)
{
UE_LOG(LogBeacon, Verbose, TEXT("ProcessCancelReservationRequest %s PartyLeader: %s from (%s)"),
Client ? *Client->GetName() : TEXT("NULL"),
PartyLeader.IsValid() ? *PartyLeader->ToString() : TEXT("INVALID"),
Client ? *Client->GetNetConnection()->LowLevelDescribe() : TEXT("NULL"));
if (Client)
{
RemovePartyReservation(PartyLeader);
}
}
示例6: InitNewPlayer
FString AGameModeBase::InitNewPlayer(APlayerController* NewPlayerController, const FUniqueNetIdRepl& UniqueId, const FString& Options, const FString& Portal)
{
PRAGMA_DISABLE_DEPRECATION_WARNINGS
// Try calling deprecated version first
FString DeprecatedError = InitNewPlayer(NewPlayerController, UniqueId.GetUniqueNetId(), Options, Portal);
if (DeprecatedError != TEXT("DEPRECATED"))
{
// This means it was implemented in subclass
return DeprecatedError;
}
PRAGMA_ENABLE_DEPRECATION_WARNINGS
check(NewPlayerController);
FString ErrorMessage;
// Register the player with the session
GameSession->RegisterPlayer(NewPlayerController, UniqueId.GetUniqueNetId(), UGameplayStatics::HasOption(Options, TEXT("bIsFromInvite")));
// Find a starting spot
AActor* const StartSpot = FindPlayerStart(NewPlayerController, Portal);
if (StartSpot != nullptr)
{
// Set the player controller / camera in this new location
FRotator InitialControllerRot = StartSpot->GetActorRotation();
InitialControllerRot.Roll = 0.f;
NewPlayerController->SetInitialLocationAndRotation(StartSpot->GetActorLocation(), InitialControllerRot);
NewPlayerController->StartSpot = StartSpot;
}
else
{
ErrorMessage = FString::Printf(TEXT("Failed to find PlayerStart"));
}
// Set up spectating
bool bSpectator = FCString::Stricmp(*UGameplayStatics::ParseOption(Options, TEXT("SpectatorOnly")), TEXT("1")) == 0;
if (bSpectator || MustSpectate(NewPlayerController))
{
NewPlayerController->StartSpectatingOnly();
}
// Init player's name
FString InName = UGameplayStatics::ParseOption(Options, TEXT("Name")).Left(20);
if (InName.IsEmpty())
{
InName = FString::Printf(TEXT("%s%i"), *DefaultPlayerName.ToString(), NewPlayerController->PlayerState->PlayerId);
}
ChangeName(NewPlayerController, InName, false);
return ErrorMessage;
}
示例7: HandlePlayerLogout
void APartyBeaconHost::HandlePlayerLogout(const FUniqueNetIdRepl& PlayerId)
{
if (PlayerId.IsValid())
{
UE_LOG(LogBeacon, Verbose, TEXT("HandlePlayerLogout %s"), *PlayerId->ToDebugString());
if (State)
{
if (State->RemovePlayer(PlayerId))
{
ReservationChanged.ExecuteIfBound();
}
}
}
}
示例8: ServerMutePlayer
void FPlayerMuteList::ServerMutePlayer(APlayerController* OwningPC, const FUniqueNetIdRepl& MuteId)
{
UWorld* World = OwningPC->GetWorld();
const TSharedPtr<const FUniqueNetId>& PlayerIdToMute = MuteId.GetUniqueNetId();
// Don't reprocess if they are already muted
AddIdToMuteList(VoiceMuteList, PlayerIdToMute);
// Add them to the packet filter list if not already on it
AddIdToMuteList(VoicePacketFilter, PlayerIdToMute);
// Replicate mute state to client
OwningPC->ClientMutePlayer(MuteId);
// Find the muted player's player controller so it can be notified
APlayerController* OtherPC = GetPlayerControllerFromNetId(World, *PlayerIdToMute);
if (OtherPC != NULL)
{
// Update their packet filter list too
OtherPC->MuteList.ClientMutePlayer(OtherPC, OwningPC->PlayerState->UniqueId);
// Tell the other PC to mute this one
OtherPC->ClientMutePlayer(OwningPC->PlayerState->UniqueId);
}
}
示例9: GameplayUnmutePlayer
void FPlayerMuteList::GameplayUnmutePlayer(APlayerController* OwningPC, const FUniqueNetIdRepl& UnmuteId)
{
UWorld* World = OwningPC->GetWorld();
const TSharedPtr<const FUniqueNetId>& PlayerIdToUnmute = UnmuteId.GetUniqueNetId();
// Remove from the gameplay mute list
RemoveIdFromMuteList(GameplayVoiceMuteList, PlayerIdToUnmute);
// Find the muted player's player controller so it can be notified
APlayerController* OtherPC = GetPlayerControllerFromNetId(World, *PlayerIdToUnmute);
if (OtherPC != NULL)
{
FUniqueNetIdMatcher PlayerIdToUnmuteMatch(*PlayerIdToUnmute);
FUniqueNetIdMatcher OwningPlayerIdMatch(*OwningPC->PlayerState->UniqueId);
// Make sure this player isn't explicitly muted
if (VoiceMuteList.IndexOfByPredicate(PlayerIdToUnmuteMatch) == INDEX_NONE &&
// And make sure they didn't mute us
OtherPC->MuteList.VoiceMuteList.IndexOfByPredicate(OwningPlayerIdMatch) == INDEX_NONE)
{
RemoveIdFromMuteList(VoicePacketFilter, PlayerIdToUnmute);
// Now process on the client
OwningPC->ClientUnmutePlayer(UnmuteId);
}
}
}
示例10: HandlePlayerLogout
void APartyBeaconHost::HandlePlayerLogout(const FUniqueNetIdRepl& PlayerId)
{
if (PlayerId.IsValid())
{
UE_LOG(LogBeacon, Verbose, TEXT("HandlePlayerLogout %s"), *PlayerId->ToDebugString());
if (State)
{
if (State->RemovePlayer(PlayerId))
{
SendReservationUpdates();
NotifyReservationEventNextFrame(ReservationChanged);
}
}
}
}
示例11: RemovePlayer
bool UPartyBeaconState::RemovePlayer(const FUniqueNetIdRepl& PlayerId)
{
bool bWasRemoved = false;
for (int32 ResIdx = 0; ResIdx < Reservations.Num() && !bWasRemoved; ResIdx++)
{
FPartyReservation& Reservation = Reservations[ResIdx];
if (Reservation.PartyLeader == PlayerId)
{
UE_LOG(LogBeacon, Display, TEXT("Party leader has left the party"), *PlayerId.ToString());
// Maintain existing members of party reservation that lost its leader
for (int32 PlayerIdx = 0; PlayerIdx < Reservation.PartyMembers.Num(); PlayerIdx++)
{
FPlayerReservation& PlayerEntry = Reservation.PartyMembers[PlayerIdx];
if (PlayerEntry.UniqueId != Reservation.PartyLeader && PlayerEntry.UniqueId.IsValid())
{
// Promote to party leader (for now)
Reservation.PartyLeader = PlayerEntry.UniqueId;
break;
}
}
}
// find the player in an existing reservation slot
for (int32 PlayerIdx = 0; PlayerIdx < Reservation.PartyMembers.Num(); PlayerIdx++)
{
FPlayerReservation& PlayerEntry = Reservation.PartyMembers[PlayerIdx];
if (PlayerEntry.UniqueId == PlayerId)
{
// player removed
Reservation.PartyMembers.RemoveAtSwap(PlayerIdx--);
bWasRemoved = true;
// free up a consumed entry
NumConsumedReservations--;
}
}
// remove the entire party reservation slot if no more party members
if (Reservation.PartyMembers.Num() == 0)
{
Reservations.RemoveAtSwap(ResIdx--);
}
}
if (bWasRemoved)
{
// Reshuffle existing teams so that beacon can accommodate biggest open slots
BestFitTeamAssignmentJiggle();
}
return bWasRemoved;
}
示例12: HandlePlayerLogout
void APartyBeaconHost::HandlePlayerLogout(const FUniqueNetIdRepl& PlayerId)
{
if (PlayerId.IsValid())
{
bool bWasRemoved = false;
UE_LOG(LogBeacon, Verbose, TEXT("HandlePlayerLogout %s"), *PlayerId->ToDebugString());
for (int32 ResIdx=0; ResIdx < Reservations.Num(); ResIdx++)
{
FPartyReservation& Reservation = Reservations[ResIdx];
// find the player in an existing reservation slot
for (int32 PlayerIdx=0; PlayerIdx < Reservation.PartyMembers.Num(); PlayerIdx++)
{
FPlayerReservation& PlayerEntry = Reservation.PartyMembers[PlayerIdx];
if (PlayerEntry.UniqueId == PlayerId)
{
// player removed
Reservation.PartyMembers.RemoveAtSwap(PlayerIdx--);
bWasRemoved = true;
// free up a consumed entry
NumConsumedReservations--;
}
}
// remove the entire party reservation slot if no more party members
if (Reservation.PartyMembers.Num() == 0)
{
Reservations.RemoveAtSwap(ResIdx--);
}
if (bWasRemoved)
{
ReservationChanged.ExecuteIfBound();
break;
}
}
}
}
示例13: GameplayMutePlayer
void FPlayerMuteList::GameplayMutePlayer(APlayerController* OwningPC, const FUniqueNetIdRepl& MuteId)
{
const TSharedPtr<const FUniqueNetId>& PlayerIdToMute = MuteId.GetUniqueNetId();
// Don't add if already muted
AddIdToMuteList(GameplayVoiceMuteList, PlayerIdToMute);
// Add to the filter list, if missing
AddIdToMuteList(VoicePacketFilter, PlayerIdToMute);
// Now process on the client
OwningPC->ClientMutePlayer(MuteId);
}
示例14: PreLogin
void AGameModeBase::PreLogin(const FString& Options, const FString& Address, const FUniqueNetIdRepl& UniqueId, FString& ErrorMessage)
{
PRAGMA_DISABLE_DEPRECATION_WARNINGS
// Try calling deprecated version first
PreLogin(Options, Address, UniqueId.GetUniqueNetId(), ErrorMessage);
if (!ErrorMessage.IsEmpty())
{
return;
}
PRAGMA_ENABLE_DEPRECATION_WARNINGS
ErrorMessage = GameSession->ApproveLogin(Options);
}
示例15: RegisterAuthTicket
void UPartyBeaconState::RegisterAuthTicket(const FUniqueNetIdRepl& InPartyMemberId, const FString& InAuthTicket)
{
if (InPartyMemberId.IsValid() && !InAuthTicket.IsEmpty())
{
bool bFoundReservation = false;
for (int32 ResIdx = 0; ResIdx < Reservations.Num() && !bFoundReservation; ResIdx++)
{
FPartyReservation& ReservationEntry = Reservations[ResIdx];
FPlayerReservation* PlayerRes = ReservationEntry.PartyMembers.FindByPredicate(
[InPartyMemberId](const FPlayerReservation& ExistingPlayerRes)
{
return InPartyMemberId == ExistingPlayerRes.UniqueId;
});
if (PlayerRes)
{
UE_LOG(LogBeacon, Display, TEXT("Updating auth ticket for member %s."), *InPartyMemberId.ToString());
if (!PlayerRes->ValidationStr.IsEmpty() && PlayerRes->ValidationStr != InAuthTicket)
{
UE_LOG(LogBeacon, Display, TEXT("Auth ticket changing for member %s."), *InPartyMemberId.ToString());
}
PlayerRes->ValidationStr = InAuthTicket;
bFoundReservation = true;
break;
}
}
if (!bFoundReservation)
{
UE_LOG(LogBeacon, Warning, TEXT("Found no reservation for player %s, while registering auth ticket."), *InPartyMemberId.ToString());
}
}
}