Ejemplo n.º 1
0
void NetworkNewPlayer (tSequencePacket *their)
{
	int	nObject;
	int	nPlayer;

nPlayer = their->player.connected;
Assert (nPlayer >= 0);
Assert (nPlayer < gameData.multiplayer.nMaxPlayers);        
nObject = gameData.multiplayer.players [nPlayer].nObject;
if (gameData.demo.nState == ND_STATE_RECORDING)
	NDRecordMultiConnect (nPlayer, nPlayer == gameData.multiplayer.nPlayers, their->player.callsign);
memcpy (gameData.multiplayer.players [nPlayer].callsign, their->player.callsign, CALLSIGN_LEN+1);
memcpy (netPlayers.players [nPlayer].callsign, their->player.callsign, CALLSIGN_LEN+1);
ClipRank ((char *) &their->player.rank);
netPlayers.players [nPlayer].rank = their->player.rank;
netPlayers.players [nPlayer].versionMajor = their->player.versionMajor;
netPlayers.players [nPlayer].versionMinor = their->player.versionMinor;
NetworkCheckForOldVersion ((char) nPlayer);

if (gameStates.multi.nGameType >= IPX_GAME) {
	if ((* (uint *)their->player.network.ipx.server) != 0)
		IpxGetLocalTarget (
			their->player.network.ipx.server, 
			their->player.network.ipx.node, 
			gameData.multiplayer.players [nPlayer].netAddress);
	else
		memcpy (gameData.multiplayer.players [nPlayer].netAddress, their->player.network.ipx.node, 6);
	}
memcpy (&netPlayers.players [nPlayer].network, &their->player.network, sizeof (tNetworkInfo));
gameData.multiplayer.players [nPlayer].nPacketsGot = 0;
gameData.multiplayer.players [nPlayer].connected = 1;
gameData.multiplayer.players [nPlayer].netKillsTotal = 0;
gameData.multiplayer.players [nPlayer].netKilledTotal = 0;
memset (gameData.multigame.kills.matrix [nPlayer], 0, MAX_PLAYERS * sizeof (short)); 
gameData.multiplayer.players [nPlayer].score = 0;
gameData.multiplayer.players [nPlayer].flags = 0;
gameData.multiplayer.players [nPlayer].nKillGoalCount = 0;
if (nPlayer == gameData.multiplayer.nPlayers) {
	gameData.multiplayer.nPlayers++;
	netGame.nNumPlayers = gameData.multiplayer.nPlayers;
	}
DigiPlaySample (SOUND_HUD_MESSAGE, F1_0);
ClipRank ((char *) &their->player.rank);
if (gameOpts->multi.bNoRankings)
	HUDInitMessage ("'%s' %s\n", their->player.callsign, TXT_JOINING);
else   
   HUDInitMessage ("%s'%s' %s\n", pszRankStrings [their->player.rank], their->player.callsign, TXT_JOINING);
MultiMakeGhostPlayer (nPlayer);
GetPlayerSpawn (GetRandomPlayerPosition (), OBJECTS + gameData.multiplayer.players [nPlayer].nObject);
MultiSendScore ();
MultiSortKillList ();
//      CreatePlayerAppearanceEffect (&OBJECTS [nObject]);
}
Ejemplo n.º 2
0
static char FindPartner( void )
{
    static BYTE segdata[128];
    BYTE        moresegs;
    BYTE        flags;
    WORD        connection;

    if( NWGetPrimaryConnectionID( &connection ) != 0 ) return( 0 );
    if( NWReadPropertyValue( connection, &SAPHead.name, DBG_SERVER_TYPE,
        "NET_ADDRESS", 1, segdata, &moresegs, &flags ) != 0 ) return( 0 );
    memcpy( &ServHead.destNet, segdata, 12 );
    if( IpxGetLocalTarget( (PUCHAR)&ServHead.destNet,
                           &ServECB, (PULONG)segdata ) != 0 ) return( 0 );
    IpxSend( IPXSocket, &ServECB );
    RespECB.fragList[1].fragAddress = &PartnerSPXSocket;
    if( IpxReceive( IPXSocket, 55*MAX_PARTNER_WAIT, &RespECB ) != 0 )
        return( 0 );
    _IPX_ASSIGNADDR( SendHead.dest, RespHead.source );
    SendHead.destSocket = PartnerSPXSocket;
    AssignArray( SendECB.immediateAddress, RespECB.immediateAddress );
    return( 1 );
}
Ejemplo n.º 3
0
void NetworkWelcomePlayer (tSequencePacket *player)
{
	int					nPlayer;
	ubyte					newAddress [6];
	tNetworkSyncData	*syncP;

networkData.refuse.bWaitForAnswer = 0;
if (FindArg ("-NoMatrixCheat")) {
	if ((player->player.versionMinor & 0x0F) < 3) {
		NetworkDumpPlayer (
			player->player.network.ipx.server, 
			player->player.network.ipx.node, 
			DUMP_DORK);
		return;
		}
	}
if (HoardEquipped ()) {
// If hoard game, and this guy isn't D2 Christmas (v1.2), dump him
	if ((gameData.app.nGameMode & GM_HOARD) && ((player->player.versionMinor & 0x0F) < 2)) {
		if (gameStates.multi.nGameType >= IPX_GAME)
			NetworkDumpPlayer (
				player->player.network.ipx.server, 
				player->player.network.ipx.node, 
				DUMP_DORK);
		return;
		}
	}
if (!(syncP = AcceptJoinRequest (player)))
	return;
memset (&syncP->player [1], 0, sizeof (tSequencePacket));
networkData.bPlayerAdded = 0;
if (gameStates.multi.nGameType >= IPX_GAME) {
	if ((*(uint *) player->player.network.ipx.server) != 0)
		IpxGetLocalTarget (
			player->player.network.ipx.server, 
			player->player.network.ipx.node, 
			newAddress);
	else
		memcpy (newAddress, player->player.network.ipx.node, 6);
	}
if (0 > (nPlayer = FindNetworkPlayer (player, newAddress))) {
	// Player is new to this game
	if (0 > (nPlayer = FindPlayerSlot (player))) {
		DeleteSyncData (syncP - networkData.sync);
		return;
		}
	}
else {
	// Player is reconnecting
	if (gameData.demo.nState == ND_STATE_RECORDING)
		NDRecordMultiReconnect (nPlayer);
	networkData.bPlayerAdded = 0;
	DigiPlaySample (SOUND_HUD_MESSAGE, F1_0);
	if (gameOpts->multi.bNoRankings)
		HUDInitMessage ("'%s' %s", gameData.multiplayer.players [nPlayer].callsign, TXT_REJOIN);
	else
		HUDInitMessage ("%s'%s' %s", pszRankStrings [netPlayers.players [nPlayer].rank], 
							 gameData.multiplayer.players [nPlayer].callsign, TXT_REJOIN);
	}
if (IsTeamGame)
	ChoseTeam (nPlayer);
gameData.multiplayer.players [nPlayer].nKillGoalCount = 0;
gameData.multiplayer.players [nPlayer].connected = 0;
// Send updated OBJECTS data to the new/returning tPlayer
syncP->player [0] = *player;
syncP->player [1] = *player;
syncP->player [1].player.connected = nPlayer;
syncP->bExtraGameInfo = 0;
syncP->nState = 1;
syncP->objs.nCurrent = -1;
syncP->nExtras = 0;
syncP->timeout = 0;
syncP->tLastJoined = gameStates.app.nSDLTicks;
NetworkDoSyncFrame ();
}
Ejemplo n.º 4
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 ();
}