Exemplo n.º 1
0
void NetworkSendRejoinSync (int nPlayer)
{
	int i, j;

gameData.multiplayer.players [nPlayer].connected = 1; // connect the new guy
ResetPlayerTimeout (nPlayer, -1);
if (gameStates.app.bEndLevelSequence || gameData.reactor.bDestroyed) {
	// Endlevel started before we finished sending the goods, we'll
	// have to stop and try again after the level.

	if (gameStates.multi.nGameType >= IPX_GAME)
		NetworkDumpPlayer (
			networkData.playerRejoining.player.network.ipx.server, 
			networkData.playerRejoining.player.network.ipx.node, 
			DUMP_ENDLEVEL);
	networkData.nSyncState = 0; 
	networkData.nSyncExtras = 0;
	return;
	}
if (networkData.bPlayerAdded) {
	networkData.playerRejoining.nType = PID_ADDPLAYER;
	networkData.playerRejoining.player.connected = nPlayer;
	NetworkNewPlayer (&networkData.playerRejoining);

	for (i = 0; i < gameData.multiplayer.nPlayers; i++) {
		if ((i != nPlayer) && 
			 (i != gameData.multiplayer.nLocalPlayer) && 
			 (gameData.multiplayer.players [i].connected))
			if (gameStates.multi.nGameType >= IPX_GAME) {
				SendSequencePacket (
					networkData.playerRejoining, 
					netPlayers.players [i].network.ipx.server, 
					netPlayers.players [i].network.ipx.node, 
					gameData.multiplayer.players [i].netAddress);
			}
		}
	}       
// Send sync packet to the new guy
NetworkUpdateNetGame ();

// Fill in the kill list
for (j = 0; j < MAX_PLAYERS; j++) {
	for (i = 0; i < MAX_PLAYERS; i++)
		netGame.kills [j][i] = gameData.multigame.kills.matrix [j][i];
	netGame.killed [j] = gameData.multiplayer.players [j].netKilledTotal;
	netGame.playerKills [j] = gameData.multiplayer.players [j].netKillsTotal;
	netGame.player_score [j] = gameData.multiplayer.players [j].score;
	}       
netGame.xLevelTime = LOCALPLAYER.timeLevel;
netGame.monitor_vector = NetworkCreateMonitorVector ();
if (gameStates.multi.nGameType >= IPX_GAME) {
	SendInternetFullNetGamePacket (
		networkData.playerRejoining.player.network.ipx.server, 
		networkData.playerRejoining.player.network.ipx.node);
	SendNetPlayersPacket (
		networkData.playerRejoining.player.network.ipx.server, 
		networkData.playerRejoining.player.network.ipx.node);
	}
return;
}
Exemplo n.º 2
0
void NetworkSendRejoinSync (int nPlayer, tNetworkSyncData *syncP)
{
	int i, j;

gameData.multiplayer.players [nPlayer].connected = 1; // connect the new guy
ResetPlayerTimeout (nPlayer, -1);
if (gameStates.app.bEndLevelSequence || gameData.reactor.bDestroyed) {
	// Endlevel started before we finished sending the goods, we'll
	// have to stop and try again after the level.

	if (gameStates.multi.nGameType >= IPX_GAME)
		NetworkDumpPlayer (
			syncP->player [1].player.network.ipx.server, 
			syncP->player [1].player.network.ipx.node, 
			DUMP_ENDLEVEL);
	syncP->nState = 0; 
	syncP->nExtras = 0;
	return;
	}
if (networkData.bPlayerAdded) {
	syncP->player [1].nType = PID_ADDPLAYER;
	syncP->player [1].player.connected = nPlayer;
	NetworkNewPlayer (&syncP->player [1]);

	for (i = 0; i < gameData.multiplayer.nPlayers; i++) {
		if ((i != nPlayer) && 
			 (i != gameData.multiplayer.nLocalPlayer) && 
			 gameData.multiplayer.players [i].connected &&
			 (gameStates.multi.nGameType >= IPX_GAME)) {
			SendSequencePacket (
				syncP->player [1], 
				netPlayers.m_info.players [i].network.ipx.server, 
				netPlayers.m_info.players [i].network.ipx.node, 
				gameData.multiplayer.players [i].netAddress);
			}
		}       
	}
// Send sync packet to the new guy
NetworkUpdateNetGame ();

// Fill in the kill list
for (j = 0; j < MAX_PLAYERS; j++) {
	for (i = 0; i < MAX_PLAYERS; i++)
		*netGame.Kills (j, i) = gameData.multigame.kills.matrix [j][i];
	*netGame.Killed (j) = gameData.multiplayer.players [j].netKilledTotal;
	*netGame.PlayerKills (j) = gameData.multiplayer.players [j].netKillsTotal;
	*netGame.PlayerScore (j) = gameData.multiplayer.players [j].score;
	}       
netGame.SetLevelTime (LOCALPLAYER.timeLevel);
netGame.SetMonitorVector (NetworkCreateMonitorVector ());
if (gameStates.multi.nGameType >= IPX_GAME) {
	SendInternetFullNetGamePacket (syncP->player [1].player.network.ipx.server, syncP->player [1].player.network.ipx.node);
	SendNetPlayersPacket (syncP->player [1].player.network.ipx.server, syncP->player [1].player.network.ipx.node);
	MultiSendMonsterball (1, 1);
	}
}
Exemplo n.º 3
0
void NetworkSendSync (void)
{
	int i, j, np;

	// Randomize their starting locations...
d_srand (TimerGetFixedSeconds ());
for (i = 0; i < gameData.multiplayer.nPlayerPositions; i++) {
	if (gameData.multiplayer.players [i].connected)
		gameData.multiplayer.players [i].connected = 1; // Get rid of endlevel connect statuses
	if (IsCoopGame)
		netGame.locations [i] = i;
	else {
		do {
			np = d_rand () % gameData.multiplayer.nPlayerPositions;
			for (j = 0; j < i; j++) {
				if (netGame.locations [j] == np) {
					np = -1;
					break;
					}
				}
			} while (np < 0);
		// np is a location that is not used anywhere else..
		netGame.locations [i] = np;
		}
	}
// Push current data into the sync packet
NetworkUpdateNetGame ();
netGame.gameStatus = NETSTAT_PLAYING;
netGame.nType = PID_SYNC;
netGame.nSegmentCheckSum = networkData.nSegmentCheckSum;
for (i = 0; i < gameData.multiplayer.nPlayers; i++) {
	if ((!gameData.multiplayer.players [i].connected) || (i == gameData.multiplayer.nLocalPlayer))
		continue;
	if (gameStates.multi.nGameType >= IPX_GAME) {
	// Send several times, extras will be ignored
		SendInternetFullNetGamePacket (
			netPlayers.players [i].network.ipx.server, 
			netPlayers.players [i].network.ipx.node);
		SendNetPlayersPacket (
			netPlayers.players [i].network.ipx.server, 
			netPlayers.players [i].network.ipx.node);
		}
	}
NetworkReadSyncPacket (&netGame, 1); // Read it myself, as if I had sent it
}
Exemplo n.º 4
0
void NetworkSendGameInfo (tSequencePacket *their)
{
	// Send game info to someone who requested it

	char oldType, old_status;
   fix timevar;
   int i;

NetworkUpdateNetGame (); // Update the values in the netgame struct
oldType = netGame.nType;
old_status = netGame.gameStatus;
netGame.nType = PID_GAME_INFO;
netPlayers.nType = PID_PLAYERSINFO;
netPlayers.nSecurity = netGame.nSecurity;
netGame.versionMajor = D2X_MAJOR;
netGame.versionMinor = D2X_MINOR;
if (gameStates.app.bEndLevelSequence || gameData.reactor.bDestroyed)
	netGame.gameStatus = NETSTAT_ENDLEVEL;
if (netGame.xPlayTimeAllowed) {
	timevar = i2f (netGame.xPlayTimeAllowed * 5 * 60);
	i = f2i (timevar - gameStates.app.xThisLevelTime);
	if (i < 30)
		netGame.gameStatus = NETSTAT_ENDLEVEL;
	}       
if (!their) {
	if (gameStates.multi.nGameType >= IPX_GAME) {
		SendBroadcastFullNetGamePacket ();
		SendBroadcastNetPlayersPacket ();
		}
	}
else if (gameStates.multi.nGameType >= IPX_GAME) {
	SendInternetFullNetGamePacket (
		their->player.network.ipx.server, 
		their->player.network.ipx.node);
	SendNetPlayersPacket (
		their->player.network.ipx.server, 
		their->player.network.ipx.node);
	}
netGame.nType = oldType;
netGame.gameStatus = old_status;
//	if ((gameData.app.nGameMode & GM_ENTROPY) || extraGameInfo [0].bEnhancedCTF)
//make half-way sure the client gets this data ...
NetworkSendExtraGameInfo (their);
MultiSendMonsterball (1, 1);
}       
Exemplo n.º 5
0
void NetworkSendSync (void)
{
	int i;

d_srand (gameStates.app.nRandSeed = TimerGetFixedSeconds ());
	// Randomize their starting locations...
for (i = 0; i < gameData.multiplayer.nPlayerPositions; i++)
	if (gameData.multiplayer.players [i].connected)
		gameData.multiplayer.players [i].connected = 1; // Get rid of endlevel connect statuses
if (IsCoopGame) {
	for (i = 0; i < gameData.multiplayer.nPlayerPositions; i++)
		*netGame.Locations (i) = i;
	}
else {	// randomize player positions
	int h, j = gameData.multiplayer.nPlayerPositions, posTable [MAX_PLAYERS] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,13, 14, 15};

	for (i = 0; i < gameData.multiplayer.nPlayerPositions; i++) {
		h = d_rand () % j;	// compute random table index
		*netGame.Locations (i) = posTable [h];	// pick position using random index
		if (h < --j)
			posTable [h] = posTable [j];	// remove picked position from position table
		}
	}
// Push current data into the sync packet
NetworkUpdateNetGame ();
netGame.m_info.gameStatus = NETSTAT_PLAYING;
netGame.m_info.nType = PID_SYNC;
netGame.SetSegmentCheckSum (networkData.nSegmentCheckSum);
for (i = 0; i < gameData.multiplayer.nPlayers; i++) {
	if ((!gameData.multiplayer.players [i].connected) || (i == gameData.multiplayer.nLocalPlayer))
		continue;
	if (gameStates.multi.nGameType >= IPX_GAME) {
	// Send several times, extras will be ignored
		SendInternetFullNetGamePacket (netPlayers.m_info.players [i].network.ipx.server, netPlayers.m_info.players [i].network.ipx.node);
		SendNetPlayersPacket (netPlayers.m_info.players [i].network.ipx.server, netPlayers.m_info.players [i].network.ipx.node);
		}
	}
NetworkProcessSyncPacket (&netGame, 1); // Read it myself, as if I had sent it
}
Exemplo n.º 6
0
void ResendSyncDueToPacketLossForAllender ()
{
   int i, j;

NetworkUpdateNetGame ();
// Fill in the kill list
for (j = 0; j < MAX_PLAYERS; j++) {
	for (i = 0; i < MAX_PLAYERS; i++)
		netGame.kills [j][i] = gameData.multigame.kills.matrix [j][i];
	netGame.killed [j] = gameData.multiplayer.players [j].netKilledTotal;
	netGame.playerKills [j] = gameData.multiplayer.players [j].netKillsTotal;
	netGame.player_score [j] = gameData.multiplayer.players [j].score;
	}       
netGame.xLevelTime = LOCALPLAYER.timeLevel;
netGame.monitor_vector = NetworkCreateMonitorVector ();
if (gameStates.multi.nGameType >= IPX_GAME) {
	SendInternetFullNetGamePacket (
		networkData.playerRejoining.player.network.ipx.server, 
		networkData.playerRejoining.player.network.ipx.node);
	SendNetPlayersPacket (
		networkData.playerRejoining.player.network.ipx.server, 
		networkData.playerRejoining.player.network.ipx.node);
	}
}
Exemplo n.º 7
0
void ResendSyncDueToPacketLoss (void)
{
   int i, j;

NetworkUpdateNetGame ();
// Fill in the kill list
for (j = 0; j < MAX_PLAYERS; j++) {
	for (i = 0; i < MAX_PLAYERS; i++)
		*netGame.Kills () [j][i] = gameData.multigame.kills.matrix [j][i];
	*netGame.Killed () [j] = gameData.multiplayer.players [j].netKilledTotal;
	*netGame.PlayerKills () [j] = gameData.multiplayer.players [j].netKillsTotal;
	*netGame.PlayerScore () [j] = gameData.multiplayer.players [j].score;
	}       
netGame.LevelTime () = LOCALPLAYER.timeLevel;
netGame.MonitorVector () = NetworkCreateMonitorVector ();
if (gameStates.multi.nGameType >= IPX_GAME) {
	SendInternetFullNetGamePacket (
		networkData.sync.player [1].player.network.ipx.server, 
		networkData.sync.player [1].player.network.ipx.node);
	SendNetPlayersPacket (
		networkData.sync.player [1].player.network.ipx.server, 
		networkData.sync.player [1].player.network.ipx.node);
	}
}