Esempio n. 1
0
////////////////////////////////
// at the end of every game.
bool multiGameShutdown(void)
{
	PLAYERSTATS	st;
	uint32_t        time;

	debug(LOG_NET, "%s is shutting down.", getPlayerName(selectedPlayer));

	sendLeavingMsg();							// say goodbye
	updateMultiStatsGames();					// update games played.

	st = getMultiStats(selectedPlayer);	// save stats

	saveMultiStats(getPlayerName(selectedPlayer), getPlayerName(selectedPlayer), &st);

	// if we terminate the socket too quickly, then, it is possible not to get the leave message
	time = wzGetTicks();
	while (wzGetTicks() - time < 1000)
	{
		wzYieldCurrentThread();  // TODO Make a wzDelay() function?
	}
	// close game
	NETclose();
	NETremRedirects();

	if (ingame.numStructureLimits)
	{
		ingame.numStructureLimits = 0;
		free(ingame.pStructureLimits);
		ingame.pStructureLimits = NULL;
	}
	ingame.flags = 0;

	ingame.localJoiningInProgress = false; // Clean up
	ingame.localOptionsReceived = false;
	ingame.bHostSetup = false;	// Dont attempt a host
	ingame.TimeEveryoneIsInGame = 0;
	ingame.startTime = 0;
	NetPlay.isHost					= false;
	bMultiPlayer					= false;	// Back to single player mode
	bMultiMessages					= false;
	selectedPlayer					= 0;		// Back to use player 0 (single player friendly)

	return true;
}
////////////////////////////////
// at the end of every game.
BOOL multiGameShutdown(void)
{
    PLAYERSTATS	st;

    debug(LOG_NET,"%s is shutting down.",getPlayerName(selectedPlayer));

    sendLeavingMsg();							// say goodbye
    updateMultiStatsGames();					// update games played.

    st = getMultiStats(selectedPlayer);	// save stats

    saveMultiStats(getPlayerName(selectedPlayer), getPlayerName(selectedPlayer), &st);

    // if we terminate the socket too quickly, then, it is possible not to get the leave message
    SDL_Delay(1000);
    // close game
    NETclose();
    NETremRedirects();

    if (ingame.numStructureLimits)
    {
        ingame.numStructureLimits = 0;
        free(ingame.pStructureLimits);
        ingame.pStructureLimits = NULL;
    }

    ingame.localJoiningInProgress = false; // Clean up
    ingame.localOptionsReceived = false;
    ingame.bHostSetup = false;	// Dont attempt a host
    NetPlay.isHost					= false;
    bMultiPlayer					= false;	// Back to single player mode
    bMultiMessages					= false;
    selectedPlayer					= 0;		// Back to use player 0 (single player friendly)

    return true;
}