ReadyToStartMatch() error

I want to report a bug in version 4.12.5 (Source Build).

I am currently working on a dedicated server build and there is a bug in the AGameMode class.
When I try to override the ReadyToStartMatch() function like so (MaxNumberOfPlayers is my variable)

bool ALobbyGameMode::ReadyToStartMatch_Implementation() {
	return (Super::ReadyToStartMatch() && NumPlayers == MaxNumberOfPlayers);
}

the DedicatedServer.exe crashes with critical error and the logs say: “the thread used up its stack”.

However I looked into the source and tried to copy the code like so (I modified the second if to fit my needs)

bool ALobbyGameMode::ReadyToStartMatch_Implementation() {
	if (GetMatchState() == MatchState::WaitingToStart)
	{
		if (NumPlayers == MaxNumberOfPlayers)
		{
			return true;
		}
	}
	return false;
}

and it works.

I don’t know whats the problem or if someone else has experienced that but it took me a little to figure out what the problem was.

Hey Denozone,

Because ReadyToStartMatch( ) in AGameMode is not virtual, you cannot override and call the super on it without getting the stack overflow error.

My recommendation is to do something like:

[.h]

bool MyReadyToStartMatch( );

[.cpp]

bool AAH452514GameMode::MyReadyToStartMatch()
{
	return ( ReadyToStartMatch( ) && NumPlayers == MaxNumberOfPlayers );
}

This should work as you can call the parent class ReadyToStartMatch( ) but not as a super.

I’m also searching for how to override this, because the documentation and code tells you to do so…

/** @return True if ready to Start Match. Games should override this */
UFUNCTION(BlueprintNativeEvent, Category="Game")
bool ReadyToStartMatch();

/** @return true if ready to End Match. Games should override this */
UFUNCTION(BlueprintNativeEvent, Category="Game")
bool ReadyToEndMatch();

also

/** Transition from WaitingToStart to InProgress. You can call this manually, will also get called if ReadyToStartMatch returns true */
UFUNCTION(BlueprintCallable, Category="Game")
virtual void StartMatch();

so how can we delay StartMatch (until all players have joined) if we cant override?

Hey HyperToxic,

I wouldn’t imagine that you’d need to override it, although you are able to override it in blueprints since it is a BlueprintNativeEvent as far as I’m aware.

However, if you’re looking to delay StartMatch, you can try changing the value of bDelayedStart:

/** Whether the game should immediately start when the first player logs in. Affects the default behavior of ReadyToStartMatch */
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GameMode")
	uint32 bDelayedStart : 1;

Then ReadyToStartMatch() will not be called, and you should be able to call StartMatch after whatever condition you’d like. Give that a shot and let me know if that works out or not.

bool AGameMode::ReadyToStartMatch_Implementation()
{
	// If bDelayed Start is set, wait for a manual match start
	if (bDelayedStart)
	{
		return false;
	}

	// By default start when we have > 0 players
	if (GetMatchState() == MatchState::WaitingToStart)
	{
		if (NumPlayers + NumBots > 0)
		{
			return true;
		}
	}
	return false;
}

Page16

1 Like