コード例 #1
0
ファイル: multijoin.cpp プロジェクト: JCDG/warzone2100
// ////////////////////////////////////////////////////////////////////////////
// A remote player has left the game
bool MultiPlayerLeave(UDWORD playerIndex)
{
	char	buf[255];

	if (playerIndex >= MAX_PLAYERS)
	{
		ASSERT(false, "Bad player number");
		return false;
	}

	NETlogEntry("Player leaving game", SYNC_FLAG, playerIndex);
	debug(LOG_NET,"** Player %u [%s], has left the game at game time %u.", playerIndex, getPlayerName(playerIndex), gameTime);

	ssprintf(buf, _("%s has Left the Game"), getPlayerName(playerIndex));

	if (ingame.localJoiningInProgress)
	{
		clearPlayer(playerIndex, false);
	}
	else if (NetPlay.isHost)  // If hosting, and game has started (not in pre-game lobby screen, that is).
	{
		sendPlayerLeft(playerIndex);
	}
	game.skDiff[playerIndex] = 0;

	addConsoleMessage(buf, DEFAULT_JUSTIFY, SYSTEM_MESSAGE);

	if (NetPlay.players[playerIndex].wzFile.isSending)
	{
		char buf[256];

		ssprintf(buf, _("File transfer has been aborted for %d.") , playerIndex);
		addConsoleMessage(buf, DEFAULT_JUSTIFY, SYSTEM_MESSAGE);
		debug(LOG_INFO, "=== File has been aborted for %d ===", playerIndex);
		NetPlay.players[playerIndex].wzFile.isSending = false;
		NetPlay.players[playerIndex].needFile = false;
	}
	NetPlay.players[playerIndex].kick = true;  // Don't wait for GAME_GAME_TIME messages from them.

	if (widgGetFromID(psWScreen, IDRET_FORM))
	{
		audio_QueueTrack(ID_CLAN_EXIT);
	}

	// fire script callback to reassign skirmish players.
	CBPlayerLeft = playerIndex;
	eventFireCallbackTrigger((TRIGGER_TYPE)CALL_PLAYERLEFT);

	netPlayersUpdated = true;
	return true;
}
コード例 #2
0
ファイル: Room.cpp プロジェクト: antgar/rtype_cpp
void	Room::deletePlayer(Client *client)
{
  int playerID = _clientManager->getClientPosition(client) + 1;
  _clientManager->deleteClient(client);
   sendPlayerLeft(playerID);
}