示例#1
0
int GamePlayersHandler (ubyte *dataP, int nLength)
{
if (NetworkIAmMaster () && 
	 !NetworkBadSecurity (THEIR->nSecurity, "PID_GAME_PLAYERS"))
	NetworkSendPlayerNames (THEIR);
return 1;
}
示例#2
0
文件: network.cpp 项目: paud/d2x-xl
void NetworkLeaveGame (void)
{ 
   int nsave;
	
NetworkDoFrame (1, 1);
#ifdef NETPROFILING
fclose (SendLogFile);
	fclose (ReceiveLogFile);
#endif
if ((NetworkIAmMaster ())) {
	while (networkData.nSyncExtras && (networkData.nPlayerJoiningExtras != -1))
		NetworkSyncExtras ();

	netGame.nNumPlayers = 0;
	nsave=gameData.multiplayer.nPlayers;
	gameData.multiplayer.nPlayers=0;
	NetworkSendGameInfo (NULL);
	gameData.multiplayer.nPlayers=nsave;
	}
LOCALPLAYER.connected = 0;
NetworkSendEndLevelPacket ();
ChangePlayerNumTo (0);
gameData.app.nGameMode = GM_GAME_OVER;
WritePlayerFile ();
ipx_handle_leave_game ();
NetworkFlush ();
}
示例#3
0
文件: network.cpp 项目: paud/d2x-xl
void NetworkLeaveGame (void)
{ 
   int nsave;
	
NetworkDoFrame (1, 1);
#ifdef NETPROFILING
fclose (SendLogFile);
	fclose (ReceiveLogFile);
#endif
if ((NetworkIAmMaster ())) {
	bool bSyncExtras = true;

	while (bSyncExtras) {
		bSyncExtras = false;
		for (short i = 0; i < networkData.nJoining; i++)
			if (networkData.sync [i].nExtras && (networkData.sync [i].nExtrasPlayer != -1)) {
				NetworkSyncExtras (networkData.sync + i);
				bSyncExtras  = true;
				}
		}

	netGame.nNumPlayers = 0;
	nsave = gameData.multiplayer.nPlayers;
	gameData.multiplayer.nPlayers = 0;
	NetworkSendGameInfo (NULL);
	gameData.multiplayer.nPlayers = nsave;
	}
LOCALPLAYER.connected = 0;
NetworkSendEndLevelPacket ();
ChangePlayerNumTo (0);
gameData.app.nGameMode = GM_GAME_OVER;
SavePlayerProfile ();
IpxHandleLeaveGame ();
NetworkFlush ();
}
示例#4
0
文件: network.cpp 项目: paud/d2x-xl
int NetworkListen (void)
{
	int size;
	ubyte packet [MAX_PACKETSIZE];
	int i, t, nPackets = 0, nMaxLoops = 999;

downloadManager.CleanUp ();
if (NetworkIAmMaster ())
	tracker.AddServer ();
if ((networkData.nStatus == NETSTAT_PLAYING) && netGame.bShortPackets && !networkData.nJoining)
	nMaxLoops = gameData.multiplayer.nPlayers * PacketsPerSec ();

if (gameStates.multi.nGameType >= IPX_GAME)
	if (!networkData.bActive) 
		return -1;
#if 1			
if (!(gameData.app.nGameMode & GM_NETWORK) && (gameStates.app.nFunctionMode == FMODE_GAME))
	console.printf (CON_DBG, "Calling NetworkListen () when not in net game.\n");
#endif
networkData.bWaitingForPlayerInfo = 1;
networkData.nSecurityFlag = NETSECURITY_OFF;

t = SDL_GetTicks ();
if (gameStates.multi.nGameType >= IPX_GAME) {
	for (i = nPackets = 0; (i < nMaxLoops) && (SDL_GetTicks () - t < 50); i++) {
		size = IpxGetPacketData (packet);
		if (size <= 0)
			break;
		if (NetworkProcessPacket (packet, size))
			nPackets++;
		}
	}
return nPackets;
}
示例#5
0
int MovePlayer (void)
{
	int	i;

if ((gameData.app.nGameMode & GM_NETWORK) && (gameData.app.nGameMode & GM_TEAM)) {
	int name_index = 5;
	if (strlen (gameData.multigame.msg.szMsg) > 5)
		while (gameData.multigame.msg.szMsg [name_index] == ' ')
			name_index++;

	if (!NetworkIAmMaster ()) {
		HUDInitMessage (TXT_MOVE_RIGHTS, gameData.multiplayer.players [NetworkWhoIsMaster ()].callsign);
		return 1;
		}
	if (strlen (gameData.multigame.msg.szMsg) <= (size_t) name_index) {
		HUDInitMessage (TXT_MOVE_NAME);
		return 1;
		}
	for (i = 0; i < gameData.multiplayer.nPlayers; i++)
		if ((!strnicmp (gameData.multiplayer.players [i].callsign, &gameData.multigame.msg.szMsg [name_index], strlen (gameData.multigame.msg.szMsg)-name_index)) && (gameData.multiplayer.players [i].connected)) {
			if ((gameData.app.nGameMode & GM_CAPTURE) && (gameData.multiplayer.players [i].flags & PLAYER_FLAGS_FLAG)) {
				HUDInitMessage (TXT_MOVE_FLAG);
				return 1;
				}
			SetTeam (i, -1);
			break;
		}
	}
return 0;
}
示例#6
0
int KickPlayer (int bBan)
{
	int i, name_index = 5 - bBan;
	const char *pszKick = GT (589 + bBan);

if (strlen (gameData.multigame.msg.szMsg) > 5)
	while (gameData.multigame.msg.szMsg [name_index] == ' ')
		name_index++;

if (!NetworkIAmMaster ()) {
	HUDInitMessage (TXT_KICK_RIGHTS, gameData.multiplayer.players [NetworkWhoIsMaster ()].callsign, pszKick);
	MultiSendMsgQuit ();
	return 1;
	}
if (strlen (gameData.multigame.msg.szMsg) <= (size_t) name_index) {
	HUDInitMessage (TXT_KICK_NAME, pszKick);
	MultiSendMsgQuit ();
	return 1;
	}

if (gameData.multigame.msg.szMsg [name_index] == '#' && ::isdigit (gameData.multigame.msg.szMsg [name_index+1])) {
	int players [MAX_PLAYERS];
	int listpos = gameData.multigame.msg.szMsg [name_index+1] - '0';

	if (gameData.multigame.kills.bShowList == 1 || gameData.multigame.kills.bShowList == 2) {
		if (listpos == 0 || listpos  >= gameData.multiplayer.nPlayers) {
			HUDInitMessage (TXT_KICK_PLR, pszKick);
			MultiSendMsgQuit ();
			return 1;
			}
		MultiGetKillList (players);
		i = players [listpos];
		if ((i != gameData.multiplayer.nLocalPlayer) && (gameData.multiplayer.players [i].connected))
			goto kick_player;
		}
	else 
		HUDInitMessage (TXT_KICK_NUMBER, pszKick);
	MultiSendMsgQuit ();
	return 1;
	}

for (i = 0; i < gameData.multiplayer.nPlayers; i++)
	if ((!strnicmp (gameData.multiplayer.players [i].callsign, &gameData.multigame.msg.szMsg [name_index], strlen (gameData.multigame.msg.szMsg)-name_index)) && (i != gameData.multiplayer.nLocalPlayer) && (gameData.multiplayer.players [i].connected)) {
kick_player:;
		if (gameStates.multi.nGameType  >= IPX_GAME)
			NetworkDumpPlayer (
				netPlayers.m_info.players [i].network.ipx.server, 
				netPlayers.m_info.players [i].network.ipx.node, 
				7);

		HUDInitMessage (TXT_DUMPING, gameData.multiplayer.players [i].callsign);
		if (bBan)
			banList.Add (gameData.multiplayer.players [i].callsign);
		MultiSendMsgQuit ();
		return 1;
		}
return 0;
}
示例#7
0
int GameListHandler (ubyte *dataP, int nLength)
{
if (banList.Find (THEIR->player.callsign))
	return 0;
if (!NetworkIAmMaster ())
	return 0;
NetworkSendLiteInfo (THEIR);
return 1;
}
示例#8
0
int AllGameInfoHandler (ubyte *dataP, int nLength)
{
if (NetworkBadSecurity (THEIR->nSecurity, "PID_SEND_ALL_GAMEINFO"))
	return 0;
if (!NetworkIAmMaster ())
	return 0;
NetworkSendGameInfo (THEIR);
return 1;
}
示例#9
0
文件: multimsg.c 项目: paud/d2x-xl
int MovePlayer (void)
{
	int	i;

if ((gameData.app.nGameMode & GM_NETWORK) && (gameData.app.nGameMode & GM_TEAM)) {
	int name_index = 5;
	if (strlen (gameData.multigame.msg.szMsg) > 5)
		while (gameData.multigame.msg.szMsg [name_index] == ' ')
			name_index++;

	if (!NetworkIAmMaster ()) {
		HUDInitMessage (TXT_MOVE_RIGHTS, gameData.multiplayer.players [NetworkWhoIsMaster ()].callsign);
		return 1;
		}
	if (strlen (gameData.multigame.msg.szMsg) <= (size_t) name_index) {
		HUDInitMessage (TXT_MOVE_NAME);
		return 1;
		}
	for (i = 0; i < gameData.multiplayer.nPlayers; i++)
		if ((!strnicmp (gameData.multiplayer.players [i].callsign, &gameData.multigame.msg.szMsg [name_index], strlen (gameData.multigame.msg.szMsg)-name_index)) && (gameData.multiplayer.players [i].connected)) {
			if ((gameData.app.nGameMode & GM_CAPTURE) && (gameData.multiplayer.players [i].flags & PLAYER_FLAGS_FLAG)) {
				HUDInitMessage (TXT_MOVE_FLAG);
				return 1;
				}
#if 1
			SetTeam (i, -1);
#else
#if 0
			if (netGame.teamVector & (1<<i))
				netGame.teamVector&= (~ (1<<i));
			else
				netGame.teamVector|= (1<<i);
#else
				netGame.teamVector ^= (1<<i);
#endif
			for (t = 0;t<gameData.multiplayer.nPlayers;t++)
				if (gameData.multiplayer.players [t].connected)
					MultiResetObjectTexture (gameData.objs.objects + gameData.multiplayer.players [t].nObject);

			NetworkSendNetgameUpdate ();
			sprintf (gameData.multigame.msg.szMsg, TXT_TEAMCHANGE3, gameData.multiplayer.players [i].callsign);
			if (i == gameData.multiplayer.nLocalPlayer) {
				HUDInitMessage (TXT_TEAMCHANGE1);
				ResetCockpit ();
				}
			else
				HUDInitMessage (TXT_TEAMCHANGE2, gameData.multiplayer.players [i].callsign);
#endif
			break;
		}
	}
return 0;
}
示例#10
0
void NetworkSyncExtras (tNetworkSyncData *syncP)
{
Assert (syncP->nExtrasPlayer > -1);
if (!NetworkIAmMaster ()) {
#if 1			
  con_printf (CONDBG, "Hey! I'm not the master and I was gonna send info!\n");
#endif
	}
if (syncP->nExtras == 1)
	NetworkSendFlyThruTriggers (syncP->nExtrasPlayer);
else if (syncP->nExtras == 2)
	NetworkSendDoorUpdates (syncP->nExtrasPlayer);
else if (syncP->nExtras == 3)
	NetworkSendMarkers ();
else if (syncP->nExtras == 4) {
	if (gameData.app.nGameMode & GM_MULTI_ROBOTS)
		MultiSendStolenItems ();
	}
else if (syncP->nExtras == 5) {
	if (netGame.xPlayTimeAllowed || netGame.KillGoal)
		MultiSendKillGoalCounts ();
	}
else if (syncP->nExtras == 6)
	NetworkSendSmashedLights (syncP->nExtrasPlayer);
else if (syncP->nExtras == 7)
	NetworkSendPlayerFlags ();    
else if (syncP->nExtras == 8)
	MultiSendPowerupUpdate ();  
else {
	syncP->nExtras = 0;
	syncP->nState = 0;
	syncP->nExtrasPlayer = -1;
	memset (&syncP->player [1], 0, sizeof (syncP->player [1]));
	return;
	}
syncP->nExtras++;
}
示例#11
0
/* Do required syncing after each level, before starting new one */
int NetworkLevelSync (void)
{
	int result;
	networkData.bSyncPackInited = 0;

//networkData.nSegmentCheckSum = NetMiscCalcCheckSum (gameData.segs.segments, sizeof (tSegment)* (gameData.segs.nLastSegment+1);
NetworkFlush (); // Flush any old packets
if (!gameData.multiplayer.nPlayers)
	result = NetworkWaitForSync ();
else if (NetworkIAmMaster ()) {
	NetworkWaitForRequests ();
	NetworkSendSync ();
	result = (gameData.multiplayer.nLocalPlayer < 0) ? -1 : 0;
	}
else
	result = NetworkWaitForSync ();
if (result < 0) {
	LOCALPLAYER.connected = 0;
	NetworkSendEndLevelPacket ();
	longjmp (gameExitPoint, 0);
	}
NetworkCountPowerupsInMine ();
return result;
}
示例#12
0
文件: monsterball.c 项目: paud/d2x-xl
int FindMonsterball (void)
{
	short		i;
	tObject	*objP;

gameData.hoard.monsterballP = NULL;
gameData.hoard.nMonsterballSeg = -1;
gameData.hoard.nLastHitter = -1;
for (i = 0, objP = gameData.objs.objects; i < gameData.objs.nObjects; i++, objP++)
	if ((objP->nType == OBJ_MONSTERBALL) || 
		 ((objP->nType == OBJ_POWERUP) && (objP->id == POW_MONSTERBALL))) {
		if (gameData.hoard.nMonsterballSeg < 0)
			gameData.hoard.nMonsterballSeg = objP->nSegment;
		ReleaseObject (i);
		}
#ifndef _DEBUG
if (!(NetworkIAmMaster () && IsMultiGame && (gameData.app.nGameMode & GM_MONSTERBALL)))
	return 0;
#endif
if (!CreateMonsterball ())
	return 0;
MultiSendMonsterball (1, 1);
return 1;
}
示例#13
0
文件: network.cpp 项目: paud/d2x-xl
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 ();
}
示例#14
0
int UploadHandler (ubyte *dataP, int nLength)
{
if (NetworkIAmMaster ())
	NetworkUpload (dataP);
return 1;
}
示例#15
0
int UploadHandler (ubyte *dataP, int nLength)
{
if (NetworkIAmMaster ())
	downloadManager.Upload (dataP);
return 1;
}
示例#16
0
文件: reactor.cpp 项目: paud/d2x-xl
void DoCountdownFrame (void)
{
	fix	oldTime;
	int	fc, h, xScale;

	static fix cdtFrameTime;

if (!gameData.reactor.bDestroyed) {
	cdtFrameTime = 0;
	return;
	}
cdtFrameTime += gameData.time.xRealFrame;
if (gameStates.limitFPS.bCountDown && !gameStates.app.tick40fps.bTick)
	return;
if (!IS_D2_OEM && !IS_MAC_SHARE && !IS_SHAREWARE) {  // get countdown in OEM and SHAREWARE only
	// On last level, we don't want a countdown.
	if ((gameData.missions.nCurrentMission == gameData.missions.nBuiltinMission) && 
		 (gameData.missions.nCurrentLevel == gameData.missions.nLastLevel)) {
		if (!IsMultiGame)
			return;
		if (gameData.app.nGameMode & GM_MULTI_ROBOTS)
			return;
		}
	}

//	Control center destroyed, rock the CPlayerData's ship.
fc = gameData.reactor.countdown.nSecsLeft;
if (fc > 16)
	fc = 16;
//	At Trainee, decrease rocking of ship by 4x.
xScale = 1;
if (gameStates.app.nDifficultyLevel == 0)
	xScale = 4;
h = I2X (3) / 16 + (I2X (16 - fc)) / 32;
gameData.objs.consoleP->mType.physInfo.rotVel [X] += (FixMul (d_rand () - 16384, h)) / xScale;
gameData.objs.consoleP->mType.physInfo.rotVel [Z] += (FixMul (d_rand () - 16384, h)) / xScale;
//	Hook in the rumble sound effect here.
oldTime = gameData.reactor.countdown.nTimer;
if (!TimeStopped ())
	gameData.reactor.countdown.nTimer -= cdtFrameTime;
if (IsMultiGame &&  NetworkIAmMaster ())
	MultiSendCountdown ();
cdtFrameTime = 0;
gameData.reactor.countdown.nSecsLeft = X2I (gameData.reactor.countdown.nTimer + I2X (7) / 8);
if ((oldTime > COUNTDOWN_VOICE_TIME) && (gameData.reactor.countdown.nTimer <= COUNTDOWN_VOICE_TIME)) 
	audio.PlaySound (SOUND_COUNTDOWN_13_SECS, SOUNDCLASS_GENERIC, I2X (3));
if (X2I (oldTime + I2X (7) / 8) != gameData.reactor.countdown.nSecsLeft) {
	if ((gameData.reactor.countdown.nSecsLeft >= 0) && (gameData.reactor.countdown.nSecsLeft < 10))
		audio.PlaySound ((short) (SOUND_COUNTDOWN_0_SECS + gameData.reactor.countdown.nSecsLeft), SOUNDCLASS_GENERIC, I2X (3));
	if (gameData.reactor.countdown.nSecsLeft == gameData.reactor.countdown.nTotalTime - 1)
		audio.PlaySound (SOUND_COUNTDOWN_29_SECS, SOUNDCLASS_GENERIC, I2X (3));
	}					
if (gameData.reactor.countdown.nTimer > 0) {
	fix size = (I2X (gameData.reactor.countdown.nTotalTime) - gameData.reactor.countdown.nTimer) / F2X (0.65);
	fix oldSize = (I2X (gameData.reactor.countdown.nTotalTime) - oldTime) / F2X (0.65);
	if ((size != oldSize) && (gameData.reactor.countdown.nSecsLeft < gameData.reactor.countdown.nTotalTime - 5))	// Every 2 seconds!
		audio.PlaySound (SOUND_CONTROL_CENTER_WARNING_SIREN, SOUNDCLASS_GENERIC, I2X (3));
	}
else {
	int flashValue = X2I (-gameData.reactor.countdown.nTimer * (64 / 4));	// 4 seconds to total whiteness
	if (oldTime > 0)
		audio.PlaySound (SOUND_MINE_BLEW_UP);
	paletteManager.SetEffect (flashValue, flashValue, flashValue);
	if (paletteManager.BlueEffect () >= 64) {
		CCanvas::SetCurrent (NULL);
		CCanvas::Current ()->Clear (RGBA_PAL2 (31,31,31));	//make screen all white to match palette effect
		paletteManager.ResetEffect ();	//restore palette for death message
		DoPlayerDead ();		//kill_player ();
		}																			
	}
}
示例#17
0
void NetworkReadSyncPacket (tNetgameInfo * sp, int rsinit)
{
    int				i, j;
    char				szLocalCallSign [CALLSIGN_LEN+1];
    tNetPlayerInfo	*playerP;
#if defined (WORDS_BIGENDIAN) || defined (__BIG_ENDIAN__)
    tNetgameInfo	tmp_info;

    if ((gameStates.multi.nGameType >= IPX_GAME) && (sp != &netGame)) { // for macintosh -- get the values unpacked to our structure format
        ReceiveFullNetGamePacket (reinterpret_cast<ubyte*> (sp), &tmp_info);
        sp = &tmp_info;
    }
#endif

    if (rsinit)
        playerInfoP = &netPlayers;
    // This function is now called by all people entering the netgame.
    if (sp != &netGame) {
        char *p = reinterpret_cast<char*> (sp);
        ushort h;
        int i, s;
        for (i = 0, h = -1; i < (int) sizeof (tNetgameInfo) - 1; i++, p++) {
            s = *reinterpret_cast<ushort*> (p);
            if (s == networkData.nSegmentCheckSum) {
                h = i;
                break;
            }
            else if (((s / 256) + (s % 256) * 256) == networkData.nSegmentCheckSum) {
                h = i;
                break;
            }
        }
        memcpy (&netGame, sp, sizeof (tNetgameInfo));
        memcpy (&netPlayers, playerInfoP, sizeof (tAllNetPlayersInfo));
    }
    gameData.multiplayer.nPlayers = sp->nNumPlayers;
    gameStates.app.nDifficultyLevel = sp->difficulty;
    networkData.nStatus = sp->gameStatus;
//Assert (gameStates.app.nFunctionMode != FMODE_GAME);
// New code, 11/27
#if 1
    console.printf (1, "netGame.checksum = %d, calculated checksum = %d.\n",
                    netGame.nSegmentCheckSum, networkData.nSegmentCheckSum);
#endif
    if (netGame.nSegmentCheckSum != networkData.nSegmentCheckSum) {
        if (extraGameInfo [0].bAutoDownload)
            networkData.nStatus = NETSTAT_AUTODL;
        else {
            short nInMenu = gameStates.menus.nInMenu;
            gameStates.menus.nInMenu = 0;
            networkData.nStatus = NETSTAT_MENU;
            MsgBox (TXT_ERROR, NULL, 1, TXT_OK, TXT_NETLEVEL_MISMATCH);
            gameStates.menus.nInMenu = nInMenu;
        }
#if 1//!DBG
        return;
#endif
    }
// Discover my CPlayerData number
    memcpy (szLocalCallSign, LOCALPLAYER.callsign, CALLSIGN_LEN+1);
    gameData.multiplayer.nLocalPlayer = -1;
    for (i = 0; i < MAX_NUM_NET_PLAYERS; i++)
        gameData.multiplayer.players [i].netKillsTotal = 0;

    for (i = 0, playerP = playerInfoP->players; i < gameData.multiplayer.nPlayers; i++, playerP++) {
        if (!CmpLocalPlayer (&playerP->network, playerP->callsign, szLocalCallSign)) {
            if (gameData.multiplayer.nLocalPlayer != -1) {
                Int3 (); // Hey, we've found ourselves twice
                MsgBox (TXT_ERROR, NULL, 1, TXT_OK, TXT_DUPLICATE_PLAYERS);
                console.printf (CON_DBG, TXT_FOUND_TWICE);
                networkData.nStatus = NETSTAT_MENU;
                return;
            }
            ChangePlayerNumTo (i);
        }
        memcpy (gameData.multiplayer.players [i].callsign, playerP->callsign, CALLSIGN_LEN+1);
        if (gameStates.multi.nGameType >= IPX_GAME) {
#ifdef WORDS_NEED_ALIGNMENT
            uint server;
            memcpy (&server, playerP->network.ipx.server, 4);
            if (server != 0)
                IpxGetLocalTarget (
                    reinterpret_cast<ubyte*> (&server),
                    playerInfoP->players [i].network.ipx.node,
                    gameData.multiplayer.players [i].netAddress);
#else // WORDS_NEED_ALIGNMENT
            if (*reinterpret_cast<uint*> (playerInfoP->players [i].network.ipx.server) != 0)
                IpxGetLocalTarget (
                    playerInfoP->players [i].network.ipx.server,
                    playerInfoP->players [i].network.ipx.node,
                    gameData.multiplayer.players [i].netAddress);
#endif // WORDS_NEED_ALIGNMENT
            else
                memcpy (gameData.multiplayer.players [i].netAddress, playerInfoP->players [i].network.ipx.node, 6);
        }
        gameData.multiplayer.players [i].nPacketsGot = 0;                             // How many packets we got from them
        gameData.multiplayer.players [i].nPacketsSent = 0;                            // How many packets we sent to them
        gameData.multiplayer.players [i].connected = playerP->connected;
        gameData.multiplayer.players [i].netKillsTotal = sp->playerKills [i];
        gameData.multiplayer.players [i].netKilledTotal = sp->killed [i];
        if (networkData.nJoinState || (i != gameData.multiplayer.nLocalPlayer))
            gameData.multiplayer.players [i].score = sp->playerScore [i];
        for (j = 0; j < MAX_NUM_NET_PLAYERS; j++)
            gameData.multigame.kills.matrix [i][j] = sp->kills [i][j];
    }

    if (gameData.multiplayer.nLocalPlayer < 0) {
        MsgBox (TXT_ERROR, NULL, 1, TXT_OK, TXT_PLAYER_REJECTED);
        networkData.nStatus = NETSTAT_MENU;
        return;
    }
    if (networkData.nJoinState) {
        for (i = 0; i < gameData.multiplayer.nPlayers; i++)
            gameData.multiplayer.players [i].netKilledTotal = sp->killed [i];
        NetworkProcessMonitorVector (sp->monitorVector);
        LOCALPLAYER.timeLevel = sp->xLevelTime;
    }
    gameData.multigame.kills.nTeam [0] = sp->teamKills [0];
    gameData.multigame.kills.nTeam [1] = sp->teamKills [1];
    LOCALPLAYER.connected = 1;
    netPlayers.players [gameData.multiplayer.nLocalPlayer].connected = 1;
    netPlayers.players [gameData.multiplayer.nLocalPlayer].rank = GetMyNetRanking ();
    if (!networkData.nJoinState) {
        int	j, bGotTeamSpawnPos = (IsTeamGame) && GotTeamSpawnPos ();
        for (i = 0; i < gameData.multiplayer.nPlayerPositions; i++) {
            if (bGotTeamSpawnPos) {
                j = TeamSpawnPos (i);
                if (j < 0)
                    j = netGame.locations [i];
            }
            else
                j = netGame.locations [i];
            GetPlayerSpawn (j, OBJECTS + gameData.multiplayer.players [i].nObject);
        }
    }
    OBJECTS [LOCALPLAYER.nObject].SetType (OBJ_PLAYER);
    networkData.nStatus = (NetworkIAmMaster () || (networkData.nJoinState >= 4)) ? NETSTAT_PLAYING : NETSTAT_WAITING;
    SetFunctionMode (FMODE_GAME);
    networkData.bHaveSync = 1;
    MultiSortKillList ();
}