Ill do you one better.
NULL is actually typically defined as Zero (meaning the number 0). It is only a convention to be more clear when you see tests like :
if (pMyActor == NULL)
You can actually write them as
if (pMyActor)
and get just as far, in most compilers. If you happen to be in a non standard environment you can get in trouble with this, but since we are all windows, mac and linux users ... =D
Announcement
Collapse
No announcement yet.
Can someone please explain this statement?
Collapse
X
-
eblade repliedOriginally posted by WCode View PostThank you for the explination its a clever expresion
Cheers!
Leave a comment:
-
Tom Looman repliedIt sets bMatchIsOver to TRUE if MyGameState is not a NULL pointer AND bMatchIsOver from MyGameState is TRUE, otherwise it sets bMatchIsOver to FALSE.
It must first check that MyGameState is not null or it cannot access bMatchIsOver (since it would be pointing to nothing)
Leave a comment:
-
WCode started a topic Can someone please explain this statement?Can someone please explain this statement?
Hello i was just wondering.
Can anyone please explain this statement for me?
Code:const bool bMatchIsOver = MyGameState && MyGameState->bMatchIsOver;
MyGameState is a class and then a bool type the use is totaly new to me.
The full code looks like this.
Code:/** Accept or reject a player attempting to join the server. * Fails login if you set the ErrorMessage to a non-empty string. */ void AShooterGameMode::PreLogin(const FString& Options, const FString& Address, const TSharedPtr<FUniqueNetId>& UniqueId, FString& ErrorMessage) { Super::PreLogin(Options, Address, UniqueId, ErrorMessage); AShooterGameState* const MyGameState = Cast<AShooterGameState>(GameState); const bool bMatchIsOver = MyGameState && MyGameState->bMatchIsOver; const FString EndGameError = TEXT("Match is over!"); ErrorMessage = bMatchIsOver ? *EndGameError : GameSession->ApproveLogin(Options); }
Thanks for any explination.Last edited by WCode; 04-15-2014, 11:11 AM.Tags: None
Leave a comment: