Exemple #1
0
void BESendSequencePacket (tSequencePacket seq, ubyte *server, ubyte *node, ubyte *netAddress)
{
	int nmBufI = 0;

nmBufP = nmDataBuf;
#if DBG
memset (nmBufP, 0, IPX_DATALIMIT);	//this takes time and shouldn't be necessary
#endif
BE_SET_BYTE (seq.nType);                                       
BE_SET_INT (seq.nSecurity);                           
nmBufI += 3;
BE_SET_BYTES (seq.player.callsign, CALLSIGN_LEN + 1);
BE_SET_BYTES (seq.player.network.ipx.server, 4);   
BE_SET_BYTES (seq.player.network.ipx.node, 6);     
BE_SET_BYTE (seq.player.versionMajor);                     
BE_SET_BYTE (seq.player.versionMinor);                     
BE_SET_BYTE (seq.player.computerType);                     
BE_SET_BYTE (seq.player.connected);                         
BE_SET_SHORT (seq.player.socket);                           
BE_SET_BYTE (seq.player.rank);                                
if (netAddress)
	IPXSendPacketData (nmBufP, nmBufI, server, node, netAddress);
else if (!server && !node)
	IPXSendBroadcastData (nmBufP, nmBufI);
else
	IPXSendInternetPacketData (nmBufP, nmBufI, server, node);
}
Exemple #2
0
void NetworkSendNakedPacket (char *buf, short len, int who)
{
if (!(gameData.app.nGameMode & GM_NETWORK)) 
	return;
if (nakedData.nLength == 0) {
	nakedData.buf [0] = PID_NAKED_PDATA;
	nakedData.buf [1] = gameData.multiplayer.nLocalPlayer;
	nakedData.nLength = 2;
	}
if (len + nakedData.nLength>networkData.nMaxXDataSize) {
	if (gameStates.multi.nGameType >= IPX_GAME)
		IPXSendPacketData (
			(ubyte *) nakedData.buf, 
			nakedData.nLength, 
			netPlayers.players [who].network.ipx.server, 
			netPlayers.players [who].network.ipx.node, gameData.multiplayer.players [who].netAddress);
	nakedData.nLength=2;
	memcpy (&nakedData.buf [nakedData.nLength], buf, len);     
	nakedData.nLength+=len;
	nakedData.nDestPlayer=who;
	}
else {
	memcpy (&nakedData.buf [nakedData.nLength], buf, len);     
	nakedData.nLength+=len;
	nakedData.nDestPlayer=who;
	}
 }
void NetworkSendEndLevelSub (int nPlayer)
{
	CEndLevelInfo end;
	int i;

	// Send an endlevel packet for a CPlayerData
*end.Type () = PID_ENDLEVEL;
*end.Player () = nPlayer;
*end.Connected () = gameData.multiplayer.players [nPlayer].connected;
*end.Kills () = INTEL_SHORT (gameData.multiplayer.players [nPlayer].netKillsTotal);
*end.Killed () = INTEL_SHORT (gameData.multiplayer.players [nPlayer].netKilledTotal);
memcpy (end.ScoreMatrix (), gameData.multigame.kills.matrix [nPlayer], MAX_NUM_NET_PLAYERS * sizeof (short));
#if defined (WORDS_BIGENDIAN) || defined (__BIG_ENDIAN__)
for (i = 0; i < MAX_PLAYERS; i++)
	for (int j = 0; j < MAX_PLAYERS; j++)
		*end.ScoreMatrix (i, j) = INTEL_SHORT (*end.ScoreMatrix (i, j));
#endif
if (gameData.multiplayer.players [nPlayer].connected == 1) {// Still playing
	Assert (gameData.reactor.bDestroyed);
	*end.SecondsLeft () = gameData.reactor.countdown.nSecsLeft;
	}
for (i = 0; i < gameData.multiplayer.nPlayers; i++) {       
	if ((i != gameData.multiplayer.nLocalPlayer) && 
		 (i != nPlayer) && 
		 (gameData.multiplayer.players [i].connected)) {
		if (gameData.multiplayer.players [i].connected == 1)
			NetworkSendEndLevelShortSub (nPlayer, i);
		else if (gameStates.multi.nGameType >= IPX_GAME)
			IPXSendPacketData (
				reinterpret_cast<ubyte*> (&end), sizeof (tEndLevelInfo), 
				netPlayers.m_info.players [i].network.ipx.server, 
				netPlayers.m_info.players [i].network.ipx.node, gameData.multiplayer.players [i].netAddress);
		}
	}
}
Exemple #4
0
void NetworkPing (ubyte flag, int nPlayer)
{
	ubyte mybuf [2];

mybuf [0]=flag;
mybuf [1]=gameData.multiplayer.nLocalPlayer;
if (gameStates.multi.nGameType >= IPX_GAME)
	IPXSendPacketData (
			reinterpret_cast<ubyte*> (mybuf), 2, 
		netPlayers.players [nPlayer].network.ipx.server, 
		netPlayers.players [nPlayer].network.ipx.node, 
		gameData.multiplayer.players [nPlayer].netAddress);
}
Exemple #5
0
void BESendMissingObjFrames(ubyte *server, ubyte *node, ubyte *netAddress)
{
	int	i;

memcpy (nmDataBuf, &networkData.sync [0].objs.missingFrames, sizeof (networkData.sync [0].objs.missingFrames));
((tMissingObjFrames *) &nmDataBuf [0])->nFrame = INTEL_SHORT (networkData.sync [0].objs.missingFrames.nFrame);
i = 2 * sizeof (ubyte) + sizeof (ushort);
if (netAddress != NULL)
	IPXSendPacketData(nmDataBuf, i, server, node, netAddress);
else if ((server == NULL) && (node == NULL))
	IPXSendBroadcastData(nmDataBuf, i);
else
	IPXSendInternetPacketData(nmDataBuf, i, server, node);
}
Exemple #6
0
void BESendExtraGameInfo(ubyte *server, ubyte *node, ubyte *net_address)
{
memcpy (out_buffer, &extraGameInfo [1], sizeof (extra_gameinfo));
EGI_INTEL_SHORT_2BUF (entropy.nMaxVirusCapacity);
EGI_INTEL_SHORT_2BUF (entropy.nEnergyFillRate);
EGI_INTEL_SHORT_2BUF (entropy.nShieldFillRate);
EGI_INTEL_SHORT_2BUF (entropy.nShieldDamageRate);
EGI_INTEL_INT_2BUF (nSpawnDelay);
if (net_address != NULL)
	IPXSendPacketData(out_buffer, sizeof (extra_gameinfo), server, node, net_address);
else if ((server == NULL) && (node == NULL))
	IPXSendBroadcastData(out_buffer, sizeof (extra_gameinfo));
else
	IPXSendInternetPacketData(out_buffer, sizeof (extra_gameinfo), server, node);
}
Exemple #7
0
void BESendExtraGameInfo (ubyte *server, ubyte *node, ubyte *netAddress)
{
nmBufP = nmDataBuf;
memcpy (nmBufP, &extraGameInfo [1], sizeof (extraGameInfo [0]));
EGI_INTEL_SHORT_2BUF (entropy.nMaxVirusCapacity);
EGI_INTEL_SHORT_2BUF (entropy.nEnergyFillRate);
EGI_INTEL_SHORT_2BUF (entropy.nShieldFillRate);
EGI_INTEL_SHORT_2BUF (entropy.nShieldDamageRate);
EGI_INTEL_INT_2BUF (nSpawnDelay);
if (netAddress)
	IPXSendPacketData (nmBufP, sizeof (extraGameInfo [0]), server, node, netAddress);
else if (!server && !node)
	IPXSendBroadcastData (nmBufP, sizeof (extraGameInfo [0]));
else
	IPXSendInternetPacketData (nmBufP, sizeof (extraGameInfo [0]), server, node);
}
Exemple #8
0
void BESendSequencePacket(sequence_packet seq, ubyte *server, ubyte *node, ubyte *net_address)
{
	short tmps;
	int loc, tmpi;

	loc = 0;
	memset(out_buffer, 0, sizeof(out_buffer));
	out_buffer[0] = seq.type;                                       
	loc++;
	tmpi = INTEL_INT(seq.Security);
	memcpy(out_buffer + loc, &tmpi, 4);                           
	loc += 4;       
	loc += 3;
	memcpy(out_buffer + loc, seq.player.callsign, CALLSIGN_LEN+1);
	loc += CALLSIGN_LEN+1;
	memcpy(out_buffer + loc, seq.player.network.ipx.server, 4);   
	loc += 4;
	memcpy(out_buffer + loc, seq.player.network.ipx.node, 6);     
	loc += 6;
	out_buffer[loc] = seq.player.version_major;                     
	loc++;
	out_buffer[loc] = seq.player.version_minor;                     
	loc++;
	out_buffer[loc] = seq.player.computer_type;                     
	loc++;
	out_buffer[loc] = seq.player.connected;                         
	loc++;
	tmps = INTEL_SHORT(seq.player.socket);
	memcpy(out_buffer + loc, &tmps, 2);                           
	loc += 2;
	out_buffer[loc]=seq.player.rank;                                
	loc++;      // for pad byte
	if (net_address != NULL)
		IPXSendPacketData(out_buffer, loc, server, node, net_address);
	else if (!server && !node)
		IPXSendBroadcastData(out_buffer, loc);
	else
		IPXSendInternetPacketData(out_buffer, loc, server, node);
}
Exemple #9
0
/* Send an endlevel packet for a tPlayer */
void NetworkSendEndLevelShortSub (int from_player_num, int to_player)
{
	tEndLevelInfoShort end;

end.nType = PID_ENDLEVEL_SHORT;
end.nPlayer = from_player_num;
end.connected = gameData.multiplayer.players [from_player_num].connected;
end.seconds_left = gameData.reactor.countdown.nSecsLeft;

if (gameData.multiplayer.players [from_player_num].connected == 1) {// Still playing
	Assert (gameData.reactor.bDestroyed);
	}
if ((to_player != gameData.multiplayer.nLocalPlayer) && 
	 (to_player != from_player_num) && 
	 (gameData.multiplayer.players [to_player].connected)) {
	if (gameStates.multi.nGameType >= IPX_GAME)
		IPXSendPacketData (
		 (ubyte *)&end, sizeof (tEndLevelInfoShort), 
		netPlayers.players [to_player].network.ipx.server, 
		netPlayers.players [to_player].network.ipx.node, gameData.multiplayer.players [to_player].netAddress);
	}
}
/* Send an endlevel packet for a CPlayerData */
void NetworkSendEndLevelShortSub (int nSrcPlayer, int nDestPlayer)
{
	tEndLevelInfoShort eli;

eli.nType = PID_ENDLEVEL_SHORT;
eli.nPlayer = nSrcPlayer;
eli.connected = gameData.multiplayer.players [nSrcPlayer].connected;
eli.secondsLeft = gameData.reactor.countdown.nSecsLeft;

if (gameData.multiplayer.players [nSrcPlayer].connected == 1) {// Still playing
	Assert (gameData.reactor.bDestroyed);
	}
if ((nDestPlayer != gameData.multiplayer.nLocalPlayer) && 
	 (nDestPlayer != nSrcPlayer) && 
	 (gameData.multiplayer.players [nDestPlayer].connected)) {
	if (gameStates.multi.nGameType >= IPX_GAME)
		IPXSendPacketData (
			reinterpret_cast<ubyte*> (&eli), sizeof (tEndLevelInfoShort), 
			netPlayers.m_info.players [nDestPlayer].network.ipx.server, 
			netPlayers.m_info.players [nDestPlayer].network.ipx.node, gameData.multiplayer.players [nDestPlayer].netAddress);
	}
}
Exemple #11
0
void NetworkSendEndLevelSub (int nPlayer)
{
	tEndLevelInfo end;
	int i, j = 0;

	// Send an endlevel packet for a tPlayer
end.nType       = PID_ENDLEVEL;
end.nPlayer = nPlayer;
end.connected  = gameData.multiplayer.players [nPlayer].connected;
end.kills      = INTEL_SHORT (gameData.multiplayer.players [nPlayer].netKillsTotal);
end.killed     = INTEL_SHORT (gameData.multiplayer.players [nPlayer].netKilledTotal);
memcpy (end.killMatrix, gameData.multigame.kills.matrix [nPlayer], MAX_PLAYERS*sizeof (short));
#if defined (WORDS_BIGENDIAN) || defined (__BIG_ENDIAN__)
for (i = 0; i < MAX_PLAYERS; i++)
	for (j = 0; j < MAX_PLAYERS; j++)
		end.killMatrix [i][j] = INTEL_SHORT (end.killMatrix [i][j]);
#else
j = j;          // to satisfy compiler
#endif
if (gameData.multiplayer.players [nPlayer].connected == 1) {// Still playing
	Assert (gameData.reactor.bDestroyed);
	end.seconds_left = gameData.reactor.countdown.nSecsLeft;
	}
for (i = 0; i < gameData.multiplayer.nPlayers; i++) {       
	if ((i != gameData.multiplayer.nLocalPlayer) && 
		 (i != nPlayer) && 
		 (gameData.multiplayer.players [i].connected)) {
		if (gameData.multiplayer.players [i].connected == 1)
			NetworkSendEndLevelShortSub (nPlayer, i);
		else if (gameStates.multi.nGameType >= IPX_GAME)
			IPXSendPacketData (
				(ubyte *)&end, sizeof (tEndLevelInfo), 
			netPlayers.players [i].network.ipx.server, 
			netPlayers.players [i].network.ipx.node, gameData.multiplayer.players [i].netAddress);
		}
	}
}
Exemple #12
0
void NetworkDoFrame (int bForce, int bListen)
{
	tFrameInfoShort shortSyncPack;
	static fix xLastEndlevel = 0;
	int i;

if (!(gameData.app.nGameMode & GM_NETWORK)) 
	return;
if ((networkData.nStatus == NETSTAT_PLAYING) && !gameStates.app.bEndLevelSequence) { // Don't send postion during escape sequence...
	if (nakedData.nLength) {
		Assert (nakedData.nDestPlayer >- 1);
		if (gameStates.multi.nGameType >= IPX_GAME) 
			IPXSendPacketData (reinterpret_cast<ubyte*> (nakedData.buf), nakedData.nLength, 
									netPlayers.players [nakedData.nDestPlayer].network.ipx.server, 
									netPlayers.players [nakedData.nDestPlayer].network.ipx.node, 
									gameData.multiplayer.players [nakedData.nDestPlayer].netAddress);
		nakedData.nLength = 0;
		nakedData.nDestPlayer = -1;
		}
	if (networkData.refuse.bWaitForAnswer && TimerGetApproxSeconds ()> (networkData.refuse.xTimeLimit+ (I2X (12))))
		networkData.refuse.bWaitForAnswer=0;
	networkData.xLastSendTime += gameData.time.xFrame;
	networkData.xLastTimeoutCheck += gameData.time.xFrame;

	// Send out packet PacksPerSec times per second maximum... unless they fire, then send more often...
	if ((networkData.xLastSendTime > I2X (1) / PacketsPerSec ()) || 
		(gameData.multigame.laser.bFired) || bForce || networkData.bPacketUrgent) {        
		if (LOCALPLAYER.connected) {
			int nObject = LOCALPLAYER.nObject;
			networkData.bPacketUrgent = 0;
			if (bListen) {
				MultiSendRobotFrame (0);
				MultiSendFire ();              // Do firing if needed..
				}
			networkData.xLastSendTime = 0;
			if (netGame.bShortPackets) {
#if defined (WORDS_BIGENDIAN) || defined (__BIG_ENDIAN__)
				ubyte send_data [MAX_PACKETSIZE];
#endif
				memset (&shortSyncPack, 0, sizeof (shortSyncPack));
				CreateShortPos (&shortSyncPack.objPos, OBJECTS+nObject, 0);
				shortSyncPack.nType = PID_PDATA;
				shortSyncPack.nPlayer = gameData.multiplayer.nLocalPlayer;
				shortSyncPack.objRenderType = OBJECTS [nObject].info.renderType;
				shortSyncPack.nLevel = gameData.missions.nCurrentLevel;
				shortSyncPack.dataSize = networkData.syncPack.dataSize;
				memcpy (shortSyncPack.data, networkData.syncPack.data, networkData.syncPack.dataSize);
				networkData.syncPack.nPackets = INTEL_INT (gameData.multiplayer.players [0].nPacketsSent++);
				shortSyncPack.nPackets = networkData.syncPack.nPackets;
#if !(defined (WORDS_BIGENDIAN) || defined (__BIG_ENDIAN__))
				IpxSendGamePacket (
					reinterpret_cast<ubyte*> (&shortSyncPack), 
					sizeof (tFrameInfoShort) - networkData.nMaxXDataSize + networkData.syncPack.dataSize);
#else
				SquishShortFrameInfo (shortSyncPack, send_data);
				IpxSendGamePacket (
					reinterpret_cast<ubyte*> (send_data), 
					IPX_SHORT_INFO_SIZE-networkData.nMaxXDataSize+networkData.syncPack.dataSize);
#endif
				}
			else {// If long packets
					int send_dataSize;

				networkData.syncPack.nType = PID_PDATA;
				networkData.syncPack.nPlayer = gameData.multiplayer.nLocalPlayer;
				networkData.syncPack.objRenderType = OBJECTS [nObject].info.renderType;
				networkData.syncPack.nLevel = gameData.missions.nCurrentLevel;
				networkData.syncPack.nObjSeg = OBJECTS [nObject].info.nSegment;
				networkData.syncPack.objPos = OBJECTS [nObject].info.position.vPos;
				networkData.syncPack.objOrient = OBJECTS [nObject].info.position.mOrient;
				networkData.syncPack.physVelocity = OBJECTS [nObject].mType.physInfo.velocity;
				networkData.syncPack.physRotVel = OBJECTS [nObject].mType.physInfo.rotVel;
				send_dataSize = networkData.syncPack.dataSize;                  // do this so correct size data is sent
#if defined (WORDS_BIGENDIAN) || defined (__BIG_ENDIAN__)                        // do the swap stuff
				if (gameStates.multi.nGameType >= IPX_GAME) {
					networkData.syncPack.nObjSeg = INTEL_SHORT (networkData.syncPack.nObjSeg);
					INTEL_VECTOR (networkData.syncPack.objPos);
					INTEL_MATRIX (networkData.syncPack.objOrient);
					INTEL_VECTOR (networkData.syncPack.physVelocity);
					INTEL_VECTOR (networkData.syncPack.physRotVel);
					networkData.syncPack.dataSize = INTEL_SHORT (networkData.syncPack.dataSize);
					}
#endif
				networkData.syncPack.nPackets = INTEL_INT (gameData.multiplayer.players [0].nPacketsSent++);
				IpxSendGamePacket (
					reinterpret_cast<ubyte*> (&networkData.syncPack), 
					sizeof (tFrameInfo) - networkData.nMaxXDataSize + send_dataSize);
				}
			networkData.syncPack.dataSize = 0;               // Start data over at 0 length.
			networkData.bD2XData = 0;
			if (gameData.reactor.bDestroyed) {
				if (gameStates.app.bPlayerIsDead)
					LOCALPLAYER.connected=3;
				if (TimerGetApproxSeconds () > (xLastEndlevel+ (I2X (1)/2))) {
					NetworkSendEndLevelPacket ();
					xLastEndlevel = TimerGetApproxSeconds ();
					}
				}
			}
		}

	if (!bListen)
		return;

	if ((networkData.xLastTimeoutCheck > I2X (1)) && !gameData.reactor.bDestroyed) {
		fix t = (fix) SDL_GetTicks ();
	// Check for CPlayerData timeouts
		for (i = 0; i < gameData.multiplayer.nPlayers; i++) {
			if ((i != gameData.multiplayer.nLocalPlayer) && 
				((gameData.multiplayer.players [i].connected == 1) || downloadManager.Downloading (i))) {
				if ((networkData.nLastPacketTime [i] == 0) || (networkData.nLastPacketTime [i] + downloadManager.GetTimeoutSecs () * 1000 > t)) {
					ResetPlayerTimeout (i, t);
					continue;
					}
#if 1//!DBG
				if (gameOpts->multi.bTimeoutPlayers && (t - networkData.nLastPacketTime [i] > 15000))
					NetworkTimeoutPlayer (i);
#endif
				}
			}
		networkData.xLastTimeoutCheck = 0;
		}
	}

if (!bListen) {
	networkData.syncPack.dataSize = 0;
	return;
	}
NetworkListen ();
#if 0
if ((networkData.sync.nPlayer != -1) && !(gameData.app.nFrameCount & 63))
	ResendSyncDueToPacketLoss (); // This will resend to network_player_rejoining
#endif
NetworkDoSyncFrame ();
if (NetworkIAmMaster ())
	tracker.AddServer ();
}
Exemple #13
0
void BESendNetGamePacket(ubyte *server, ubyte *node, ubyte *net_address, int lite_flag)     // lite says shorter netgame packets
{
	uint tmpi;
	ushort tmps; // p;
	int i, j;
	int loc = 0;

	memset(out_buffer, 0, IPX_MAX_DATA_SIZE);
	memcpy(out_buffer + loc, &(netGame.type), 1);                 
	loc++;
	tmpi = INTEL_INT(netGame.Security);
	memcpy(out_buffer + loc, &tmpi, 4);                           
	loc += 4;
	memcpy(out_buffer + loc, netGame.game_name, NETGAME_NAME_LEN+1);  
	loc += (NETGAME_NAME_LEN+1);
	memcpy(out_buffer + loc, netGame.mission_title, MISSION_NAME_LEN+1);  
	loc += (MISSION_NAME_LEN+1);
	memcpy(out_buffer + loc, netGame.mission_name, 9);            
	loc += 9;
	tmpi = INTEL_INT(netGame.levelnum);
	memcpy(out_buffer + loc, &tmpi, 4);                           
	loc += 4;
	memcpy(out_buffer + loc, &(netGame.gamemode), 1);             
	loc++;
	memcpy(out_buffer + loc, &(netGame.RefusePlayers), 1);        
	loc++;
	memcpy(out_buffer + loc, &(netGame.difficulty), 1);           
	loc++;
	memcpy(out_buffer + loc, &(netGame.game_status), 1);          
	loc++;
	memcpy(out_buffer + loc, &(netGame.numplayers), 1);           
	loc++;
	memcpy(out_buffer + loc, &(netGame.max_numplayers), 1);       
	loc++;
	memcpy(out_buffer + loc, &(netGame.numconnected), 1);         
	loc++;
	memcpy(out_buffer + loc, &(netGame.game_flags), 1);           
	loc++;
	memcpy(out_buffer + loc, &(netGame.protocol_version), 1);     
	loc++;
	memcpy(out_buffer + loc, &(netGame.version_major), 1);        
	loc++;
	memcpy(out_buffer + loc, &(netGame.version_minor), 1);        
	loc++;
	memcpy(out_buffer + loc, &(netGame.team_vector), 1);          
	loc++;

	if (lite_flag)
		goto do_send;

// will this work -- damn bitfields -- totally bogus when trying to do
// this type of stuff
// Watcom makes bitfields from left to right.  CW7 on the mac goes
// from right to left.  then they are endian swapped

	tmps = *(ushort *)((ubyte *)(&netGame.team_vector) + 1);    // get the values for the first short bitfield
	tmps = INTEL_SHORT(tmps);
	memcpy(out_buffer + loc, &tmps, 2);                           
	loc += 2;

	tmps = *(ushort *)((ubyte *)(&netGame.team_vector) + 3);    // get the values for the second short bitfield
	tmps = INTEL_SHORT(tmps);
	memcpy(out_buffer + loc, &tmps, 2);                           
	loc += 2;

#if 0       // removed since I reordered bitfields on mac
	p = *(ushort *)((ubyte *)(&netGame.team_vector) + 1);       // get the values for the first short bitfield
	tmps = 0;
	for (i = 15; i >= 0; i--) {
		if (p & (1 << i))
			tmps |= (1 << (15 - i);
	}
	tmps = INTEL_SHORT(tmps);
	memcpy(out_buffer + loc, &tmps, 2);                           
	loc += 2;
	p = *(ushort *)((ubyte *)(&netGame.team_vector) + 3);       // get the values for the second short bitfield
	tmps = 0;
	for (i = 15; i >= 0; i--) {
		if (p & (1 << i))
			tmps |= (1 << (15 - i);
	}
	tmps = INTEL_SHORT(tmps);
	memcpy(out_buffer + loc, &tmps, 2);                           
	loc += 2;
#endif

	memcpy(out_buffer + loc, netGame.team_name, 2*(CALLSIGN_LEN+1)); loc += 2*(CALLSIGN_LEN+1);
	for (i = 0; i < MAX_PLAYERS; i++) {
		tmpi = INTEL_INT(netGame.locations[i]);
		memcpy(out_buffer + loc, &tmpi, 4);       
		loc += 4;   // SWAP HERE!!!
	}

	for (i = 0; i < MAX_PLAYERS; i++) {
		for (j = 0; j < MAX_PLAYERS; j++) {
			tmps = INTEL_SHORT(netGame.kills[i][j]);
			memcpy(out_buffer + loc, &tmps, 2);   
			loc += 2;   // SWAP HERE!!!
		}
	}

	tmps = INTEL_SHORT(netGame.segments_checksum);
	memcpy(out_buffer + loc, &tmps, 2);           
	loc += 2;   // SWAP_HERE
	tmps = INTEL_SHORT(netGame.team_kills[0]);
	memcpy(out_buffer + loc, &tmps, 2);           
	loc += 2;   // SWAP_HERE
	tmps = INTEL_SHORT(netGame.team_kills[1]);
	memcpy(out_buffer + loc, &tmps, 2);           
	loc += 2;   // SWAP_HERE
	for (i = 0; i < MAX_PLAYERS; i++) {
		tmps = INTEL_SHORT(netGame.killed[i]);
		memcpy(out_buffer + loc, &tmps, 2);       
		loc += 2;   // SWAP HERE!!!
	}
	for (i = 0; i < MAX_PLAYERS; i++) {
		tmps = INTEL_SHORT(netGame.player_kills[i]);
		memcpy(out_buffer + loc, &tmps, 2);       
		loc += 2;   // SWAP HERE!!!
	}

	tmpi = INTEL_INT(netGame.KillGoal);
	memcpy(out_buffer + loc, &tmpi, 4);           
	loc += 4;   // SWAP_HERE
	tmpi = INTEL_INT(netGame.PlayTimeAllowed);
	memcpy(out_buffer + loc, &tmpi, 4);           
	loc += 4;   // SWAP_HERE
	tmpi = INTEL_INT(netGame.level_time);
	memcpy(out_buffer + loc, &tmpi, 4);           
	loc += 4;   // SWAP_HERE
	tmpi = INTEL_INT(netGame.control_invul_time);
	memcpy(out_buffer + loc, &tmpi, 4);           
	loc += 4;   // SWAP_HERE
	tmpi = INTEL_INT(netGame.monitor_vector);
	memcpy(out_buffer + loc, &tmpi, 4);           
	loc += 4;   // SWAP_HERE
	for (i = 0; i < MAX_PLAYERS; i++) {
		tmpi = INTEL_INT(netGame.player_score[i]);
		memcpy(out_buffer + loc, &tmpi, 4);       
		loc += 4;   // SWAP_HERE
	}
	for (i = 0; i < MAX_PLAYERS; i++) {
		memcpy(out_buffer + loc, &(netGame.player_flags[i]), 1); loc++;
	}
	tmps = INTEL_SHORT(netGame.nPacketsPerSec);
	memcpy(out_buffer + loc, &tmps, 2);                   
	loc += 2;
	memcpy(out_buffer + loc, &(netGame.bShortPackets), 1); 
	loc++;

do_send:
	if (net_address != NULL)
		IPXSendPacketData(out_buffer, loc, server, node, net_address);
	else if ((server == NULL) && (node == NULL))
		IPXSendBroadcastData(out_buffer, loc);
	else
		IPXSendInternetPacketData(out_buffer, loc, server, node);
}
Exemple #14
0
void BESendNetGamePacket (ubyte *server, ubyte *node, ubyte *netAddress, int bLiteData)
{
	int	i;
	short	h;
	int	nmBufI = 0;

nmBufP = nmDataBuf;
#if DBG
memset (nmBufP, 0, MAX_PACKETSIZE);	//this takes time and shouldn't be necessary
#endif
BE_SET_BYTE (netGame.nType);                 
BE_SET_INT (netGame.nSecurity);                           
BE_SET_BYTES (netGame.szGameName, NETGAME_NAME_LEN + 1);  
BE_SET_BYTES (netGame.szMissionTitle, MISSION_NAME_LEN + 1);  
BE_SET_BYTES (netGame.szMissionName, 9);            
BE_SET_INT (netGame.nLevel);
BE_SET_BYTE (netGame.gameMode);             
BE_SET_BYTE (netGame.bRefusePlayers);        
BE_SET_BYTE (netGame.difficulty);           
BE_SET_BYTE (netGame.gameStatus);          
BE_SET_BYTE (netGame.nNumPlayers);           
BE_SET_BYTE (netGame.nMaxPlayers);       
BE_SET_BYTE (netGame.nConnected);         
BE_SET_BYTE (netGame.gameFlags);           
BE_SET_BYTE (netGame.protocolVersion);     
BE_SET_BYTE (netGame.versionMajor);        
BE_SET_BYTE (netGame.versionMinor);        
BE_SET_BYTE (netGame.teamVector);          
if (bLiteData)
	goto do_send;
h = *((ushort *) (&netGame.teamVector + 1));
BE_SET_SHORT (h);    // get the values for the first short bitfield
h = *((ushort *) (&netGame.teamVector + 3));
BE_SET_SHORT (h);    // get the values for the first short bitfield
BE_SET_BYTES (netGame.szTeamName, 2 * (CALLSIGN_LEN + 1)); 
for (i = 0; i < MAX_PLAYERS; i++) {
	BE_SET_INT (netGame.locations [i]);
	}
int j;
for (i = 0; i < MAX_PLAYERS; i++) {
	for (j = 0; j < MAX_PLAYERS; j++) {
		BE_SET_SHORT (netGame.kills [i][j]);
		}
	}
BE_SET_SHORT (netGame.nSegmentCheckSum);
BE_SET_SHORT (netGame.teamKills [0]);
BE_SET_SHORT (netGame.teamKills [1]);
for (i = 0; i < MAX_PLAYERS; i++) {
	BE_SET_SHORT (netGame.killed [i]);
	}
for (i = 0; i < MAX_PLAYERS; i++) {
	BE_SET_SHORT (netGame.playerKills [i]);
	}
BE_SET_INT (netGame.KillGoal);
BE_SET_INT (netGame.xPlayTimeAllowed);
BE_SET_INT (netGame.xLevelTime);
BE_SET_INT (netGame.controlInvulTime);
BE_SET_INT (netGame.monitorVector);
for (i = 0; i < MAX_PLAYERS; i++) {
	BE_SET_INT (netGame.playerScore[i]);
	}
BE_SET_BYTES (netGame.playerFlags, MAX_PLAYERS);
BE_SET_SHORT (PacketsPerSec ());
BE_SET_BYTE (netGame.bShortPackets); 

do_send:

if (netAddress)
	IPXSendPacketData(nmBufP, nmBufI, server, node, netAddress);
else if (!server && !node)
	IPXSendBroadcastData(nmBufP, nmBufI);
else
	IPXSendInternetPacketData(nmBufP, nmBufI, server, node);
}