예제 #1
0
파일: Turret.cpp 프로젝트: Arc0re/lithtech
void Turret::Activate( HOBJECT hSender )
{
	if( IsInUse( ) || m_Damage.IsDead( ))
		return;

	if( m_swtDestroyedDeactivationDelay.IsStarted( ))
	{
		g_pLTServer->CPrint( "Activated with deactivation delay" );
	}

	// Activating turret...
	m_hOperatingObject = hSender;

	CreateSpecialFX( true );

	if( IsPlayer( m_hOperatingObject ))
	{
		// Change the players weapon to the turret weapon...
		CPlayerObj *pPlayer = dynamic_cast<CPlayerObj*>(g_pLTServer->HandleToObject( m_hOperatingObject ));
		pPlayer->SetOperatingTurret( *this, true );
	}

	// Process any activation command we may have...
	if( !m_sActivateCommand.empty( ))
	{
		g_pCmdMgr->QueueCommand( m_sActivateCommand.c_str( ), hSender, m_hObject );
	}

	SetNextUpdate( UPDATE_NEXT_FRAME );
}
예제 #2
0
bool CServerMissionMgr::SendExitLevelMessage( )
{
	// Tell the players to prepare to exit a level.
	CPlayerObj::PlayerObjList::const_iterator iter = CPlayerObj::GetPlayerObjList( ).begin( );
	while( iter != CPlayerObj::GetPlayerObjList( ).end( ))
	{
		CPlayerObj* pPlayerObj = *iter;
		pPlayerObj->HandlePreExit();
		g_pGameServerShell->SendPlayerInfoMsgToClients(NULL,pPlayerObj,MID_PI_UPDATE);
		iter++;
	}

	CTeamMgr::Instance().UpdateClient();

	// See if we have already visited the level we are going to.
	CString sLoadGameFile = g_pServerSaveLoadMgr->GetWorldSaveFile( m_sCurrentWorldName );
	bool bRestoringLevel = !!CWinUtil::FileExist( sLoadGameFile );

	// Tell client's we're exiting.  Wait for their response.
	CAutoMessage cMsg;
	cMsg.Writeuint8( MID_EXIT_LEVEL );
	cMsg.WriteString( m_sCurrentWorldName );
	cMsg.Writebool( m_bNewMission );
	cMsg.Writebool( bRestoringLevel );
	cMsg.Writebool( true );
	g_pLTServer->SendToClient(cMsg.Read(), LTNULL, MESSAGE_GUARANTEED);

	return true;
}
예제 #3
0
CAISensorBerserker::~CAISensorBerserker()
{
	// Verify that the AI is not still mounted.  If they are, clean it up,
	// as we don't want to leave the player 

	AIASSERT( m_pAI, NULL, "CAISensorBerserker::~CAISensorBerserker: No AI." );
	AIASSERT( m_pAI->GetAIWorkingMemory(), NULL, "CAISensorBerserker::~CAISensorBerserker: No AIWorkingMemory." );
	if ( m_pAI && m_pAI->GetAIWorkingMemory() )
	{
		CAIWMFact queryFact;
		queryFact.SetFactType( kFact_Knowledge );
		queryFact.SetKnowledgeType( kKnowledge_BerserkerAttachedPlayer );
		CAIWMFact* pFact = m_pAI->GetAIWorkingMemory()->FindWMFact( queryFact );
		if ( pFact )
		{
			// Release the player.

			CPlayerObj* pPlayer = CPlayerObj::DynamicCast( pFact->GetTargetObject() );
			if ( pPlayer )
			{
				pPlayer->BerserkerAbort( m_pAI->GetHOBJECT() );
			}

			// Perform cleanup to keep everything in sync. (?? Do we need to 
			// reset UsingObject as well?)

			m_pAI->GetAIWorkingMemory()->ClearWMFact( pFact );
			m_pAI->GetAIWorldState()->SetWSProp( kWSK_MountedObject, NULL, kWST_bool, false ); 
		}
	}
}
예제 #4
0
bool CDeathMatchMissionMgr::FinishExitLevel( )
{
	TRACE( "CDeathMatchMissionMgr::FinishExitLevel:\n" );

	// No longer waiting for exitlevel messages back from client.
	m_bExitingLevel = false;

	// Clear out the playertracker.
	m_PlayerTracker.Term( );

	// Tell the players to handle an exit level.
	CPlayerObj::PlayerObjList::const_iterator iter = CPlayerObj::GetPlayerObjList( ).begin( );
	while( iter != CPlayerObj::GetPlayerObjList( ).end( ))
	{
		CPlayerObj* pPlayerObj = *iter;
		pPlayerObj->HandleExit( true );
		iter++;
	}

	// Load new level with no restoring of keepalives or save games.
	if( !g_pServerSaveLoadMgr->LoadNewLevel( m_sCurrentWorldName ))
		return false;

	// Unpause the server now that we're done switching levels.
	g_pGameServerShell->PauseGame( LTFALSE );	


	return true;
}
예제 #5
0
bool CServerMissionMgr::FinishExitLevel( )
{
	TRACE( "CServerMissionMgr::FinishExitLevel:\n" );

	// No longer waiting for exitlevel messages back from client.
	m_bExitingLevel = false;

	// Clear out the playertracker.
	m_PlayerTracker.Term( );

	// Tell the players to handle an exit level.
	CPlayerObj::PlayerObjList::const_iterator iter = CPlayerObj::GetPlayerObjList( ).begin( );
	while( iter != CPlayerObj::GetPlayerObjList( ).end( ))
	{
		CPlayerObj* pPlayerObj = *iter;
		pPlayerObj->HandleExit( m_bNewMission );
		iter++;
	}

	// Save the keepalives between levels.
	bool bSaveKeepAlives = true;
	
	if( m_bNewMission )
	{
		// Clear out our objectives...
		g_pGameServerShell->ResetObjectives();

		// Clear working save dir since we're starting fresh.
		g_pServerSaveLoadMgr->ClearWorkingDir( );

		// If this is mp, then consider this to be a new game.  Saves between
		// missions is only available in sp which allows skills to be saved.
		if( IsMultiplayerGame( ))
		{
			// Tell the gameservershell it's a new game.
			g_pGameServerShell->SetLGFlags( LOAD_NEW_GAME );
			bSaveKeepAlives = false;
		}
	}

	// Default to failure.
	bool bRet = false;

	// Do transition.
	if( m_bTransitionLevels )
	{
		m_bTransitionLevels = false;
		bRet = g_pServerSaveLoadMgr->TransitionLevels( m_sCurrentWorldName );
	}
	// Do switch.
	else
	{
		bRet = g_pServerSaveLoadMgr->SwitchLevels( m_sCurrentWorldName, bSaveKeepAlives );
	}

	// Unpause the server now that we're done switching levels.
	g_pGameServerShell->PauseGame( LTFALSE );	

	return bRet;
}
예제 #6
0
LTBOOL ExitTrigger::Activate()
{
    if (!Trigger::Activate()) return LTFALSE;

	// Tell all the players to remove any bodies they are carrying and any vehicles they are riding...

	CPlayerObj::PlayerObjList::const_iterator iter = CPlayerObj::GetPlayerObjList( ).begin( );
	while( iter != CPlayerObj::GetPlayerObjList( ).end( ))
	{
		CPlayerObj* pPlayerObj = *iter;

		// Send the message if this is not the active player.
		if( pPlayerObj )
		{
			pPlayerObj->SetCarriedObject( LTNULL );
			pPlayerObj->RemoveVehicleModel();
		}

		iter++;
	}


	if( m_bExitMission )
	{
		if( !g_pServerMissionMgr->NextMission( ))
			return LTFALSE;
	}
	else
	{
		if( !g_pServerMissionMgr->ExitLevelSwitch( ))
			return LTFALSE;
	}

    return LTTRUE;
}
예제 #7
0
파일: Camera.cpp 프로젝트: Arc0re/lithtech
void Camera::Update()
{
	LTVector vPos;
	g_pLTServer->GetObjectPos(m_hObject, &vPos);

	ObjArray <HOBJECT, MAX_OBJECT_ARRAY_SIZE> objArray;
    g_pLTServer->FindNamedObjects(DEFAULT_PLAYERNAME,objArray);

	int numObjects = objArray.NumObjects();

	for (int i = 0; i < numObjects; i++ )
	{
        CPlayerObj* pPlayer = (CPlayerObj*) g_pLTServer->HandleToObject(objArray.GetObject(i));
		if (pPlayer)
		{
			HCLIENT hClient = pPlayer->GetClient();
			if (hClient)
			{
                g_pLTServer->SetClientViewPos(hClient, &vPos);
			}
		}
	}

    if (m_fActiveTime > 0.0f && g_pLTServer->GetTime() > m_fTurnOffTime)
	{
		TurnOff();
	}
	else
	{
        SetNextUpdate(UPDATE_NEXT_FRAME);
	}
}
void CProjectile::AddSpecialFX()
{
	if (!g_pWeaponMgr) return;

	// If this is a player object, get the client id...

    uint8 nShooterId = -1;
	if (IsPlayer(m_hFiredFrom))
	{
        CPlayerObj* pPlayer = (CPlayerObj*) g_pLTServer->HandleToObject(m_hFiredFrom);
		if (pPlayer)
		{
            nShooterId = (uint8) g_pLTServer->GetClientID(pPlayer->GetClient());
		}
	}


	// Create a special fx...

    HMESSAGEWRITE hMessage = g_pLTServer->StartSpecialEffectMessage(this);
    g_pLTServer->WriteToMessageByte(hMessage, SFX_PROJECTILE_ID);
    g_pLTServer->WriteToMessageByte(hMessage, m_pWeaponData->nId);
    g_pLTServer->WriteToMessageByte(hMessage, m_pAmmoData->nId);
    g_pLTServer->WriteToMessageByte(hMessage, nShooterId);
    g_pLTServer->EndMessage(hMessage);
}
예제 #9
0
void GearItem::PickedUp(ILTMessage_Read *pMsg)
{
	// Did we really pick it up?

	bool bPickedUp = (pMsg ? pMsg->Readbool() : true);

	// If we were touched by a player, our m_hPlayerObj data member will be
	// set.  Send a message to that player's client letting it know that an
	// item has been picked up...

	if (m_hPlayerObj)
	{
        CPlayerObj* pPlayer = (CPlayerObj*) g_pLTServer->HandleToObject(m_hPlayerObj);
		if (pPlayer && !pPlayer->IsDead())
		{
			HCLIENT hClient = pPlayer->GetClient();
			if (hClient)
			{
				CAutoMessage cMsg;
				cMsg.Writeuint8(MID_GEAR_PICKEDUP);
				cMsg.Writeuint8((uint8)m_nGearId);
				cMsg.Writebool(bPickedUp);
				g_pLTServer->SendToClient(cMsg.Read(), hClient, MESSAGE_GUARANTEED);
			}
		}
	}

	if (bPickedUp)
	{
		PickupItem::PickedUp(pMsg);
		
		if( m_bRespawn )
		{
			GEAR const *pGear = g_pWeaponMgr->GetGear( m_nGearId );
			if( !pGear )
				return;

			// Change the skins and renderstyles to the waiting to respawn files...

			ObjectCreateStruct ocs;

			pGear->blrRespawnWaitSkins.CopyList( 0, ocs.m_SkinNames[0], MAX_CS_FILENAME_LEN + 1 );
			pGear->blrRespawnWaitRenderStyles.CopyList( 0, ocs.m_RenderStyleNames[0], MAX_CS_FILENAME_LEN + 1 );

			if( pGear->blrRespawnWaitRenderStyles.GetNumItems() < 1 )
				LTStrCpy( ocs.m_RenderStyleNames[0], s_szDefaultRS, ARRAY_LEN( s_szDefaultRS ));
			
			g_pCommonLT->SetObjectFilenames( m_hObject, &ocs );

			// Stop playing PowerupFX and play RespawnWaitFX...
		
			SetClientFX( pGear->szRespawnWaitFX );

			// Set our visibility...

			g_pCommonLT->SetObjectFlags( m_hObject, OFT_Flags, pGear->bRespawnWaitVisible ? FLAG_VISIBLE : 0, FLAG_VISIBLE );
			g_pCommonLT->SetObjectFlags( m_hObject, OFT_Flags2, pGear->bRespawnWaitTranslucent ? FLAG2_FORCETRANSLUCENT : 0, FLAG2_FORCETRANSLUCENT );
		}
	}
}
LTBOOL CAnimatorPlayer::SetDims(HMODELANIM hAni)
{
    LTVector vDims;
    LTRESULT dResult = g_pLTServer->GetModelAnimUserDims(m_hObject, &vDims, hAni);
    _ASSERT(dResult == LT_OK);

    CPlayerObj* pPlayer = (CPlayerObj*)g_pLTServer->HandleToObject(m_hObject);

	pPlayer->ForceDuck(LTFALSE);

	// If we could update the dims, or we're forcing the animation, set it

    if ( pPlayer->SetDims(&vDims, LTFALSE) /*|| IS DEATH ANI*/)
	{
        return LTTRUE;
	}
	else
	{
		// If we were ducking, and we tried to stand but couldn't, make us continue to duck

		if ((m_eLastMovement == eCrouching) && !(m_eMovement == eCrouching))
		{
			m_eMovement = eCrouching;
			pPlayer->ForceDuck(LTTRUE);
		}
		else
		{
		}

        return LTFALSE;
	}
}
예제 #11
0
LTBOOL PlayerTrigger::Activate()
{
	if (g_pGameServerShell->IsPaused())
	{
		return LTFALSE;
	}

	// Find all the objects within the trigger...

	LTVector vDims;
	g_pPhysicsLT->GetObjectDims( m_hObject, &vDims );

	LTVector vPos;
	g_pLTServer->GetObjectPos( m_hObject, &vPos );

	LTVector vMin = vPos - vDims;
	LTVector vMax = vPos + vDims;

	ObjectList *pObjList = g_pLTServer->GetBoxIntersecters( &vMin, &vMax );
	if( !pObjList )
		return LTFALSE;

	// Count the number of players in the trigger and activate only if
	// ALL players in the game are within the trigger...

	HOBJECT hObj;
	uint32	nPlayersInGame = CPlayerObj::GetNumberPlayersWithClients( );

	// Don't trigger if there are no players in the game.
	if( nPlayersInGame == 0 )
		return LTFALSE;

	uint32	nPlayersInTrigger = 0;

	ObjectLink *pLink = pObjList->m_pFirstLink;
	while( pLink )
	{
		hObj = pLink->m_hObject;
		CPlayerObj* pPlayerObj = dynamic_cast< CPlayerObj* >( g_pLTServer->HandleToObject( hObj ));

		// Only count live players with loaded clients.
		if( pPlayerObj && !pPlayerObj->IsDead( ) && pPlayerObj->IsClientLoaded( ))
		{
			++nPlayersInTrigger;
		}
	
		pLink = pLink->m_pNext;
	}
	
	g_pLTServer->RelinquishList( pObjList );

	if( nPlayersInTrigger != nPlayersInGame )
		return LTFALSE;

	// Ok! All the players are acounted for.
	// Let the base Trigger object activate.

	return Trigger::Activate();
}
예제 #12
0
파일: Scanner.cpp 프로젝트: Arc0re/lithtech
LTBOOL CScanner::CanSeeObject(ObjectFilterFn ofn, HOBJECT hObject)
{
	_ASSERT(hObject);
    if (!hObject) return LTFALSE;

	if (g_pGameServerShell->GetGameType() == COOPERATIVE_ASSAULT && m_nPlayerTeamFilter && IsPlayer(hObject))
	{
		CPlayerObj* pPlayer = (CPlayerObj*)g_pLTServer->HandleToObject(hObject);
		if (pPlayer->GetTeamID() != m_nPlayerTeamFilter)
			return LTFALSE;
	}


    LTVector vPos;
    g_pLTServer->GetObjectPos(hObject, &vPos);

    LTVector vDir;
	vDir = vPos - GetScanPosition();

	if (VEC_MAGSQR(vDir) >= m_fVisualRange)
	{
        return LTFALSE;
	}

	vDir.Norm();

    LTRotation rRot = GetScanRotation();

    LTVector vUp, vRight, vForward;
    g_pLTServer->GetRotationVectors(&rRot, &vUp, &vRight, &vForward);

    LTFLOAT fDp = vDir.Dot(vForward);

	if (fDp < m_fFOV)
	{
        return LTFALSE;
	}

	// See if we can see the position in question

	IntersectQuery IQuery;
	IntersectInfo IInfo;

	VEC_COPY(IQuery.m_From, GetScanPosition());
	VEC_COPY(IQuery.m_To, vPos);
	IQuery.m_Flags	  = INTERSECT_OBJECTS | IGNORE_NONSOLID;
	IQuery.m_FilterFn = ofn;

    if (g_pLTServer->IntersectSegment(&IQuery, &IInfo))
	{
		if (IInfo.m_hObject == hObject)
		{
            return LTTRUE;
		}
	}

    return LTFALSE;
}
예제 #13
0
void ScreenShake::Update()
{
	if (--m_nNumShakes > 0)
	{
        SetNextUpdate(m_hObject, m_fFrequency);
	}

    LTVector vMyPos;
    g_pLTServer->GetObjectPos(m_hObject, &vMyPos);

	// Play sound...

	if (m_hstrSound)
	{
        char* pSound = g_pLTServer->GetStringData(m_hstrSound);
		g_pServerSoundMgr->PlaySoundFromPos(vMyPos, pSound, m_fSoundRadius, SOUNDPRIORITY_MISC_LOW);
	}

	// Time to shake.  Get all the players in the area of effect...

	ObjArray <HOBJECT, MAX_OBJECT_ARRAY_SIZE> objArray;
    g_pLTServer->FindNamedObjects(DEFAULT_PLAYERNAME, objArray);
	int numObjects = objArray.NumObjects();

	if (!numObjects) return;

	for (int i = 0; i < numObjects; i++)
	{
		HOBJECT hObject = objArray.GetObject(i);

		if (hObject && IsPlayer(hObject))
		{
			// Make sure object is in area of effect...

            LTVector vPlayerPos;
            g_pLTServer->GetObjectPos(hObject, &vPlayerPos);

			if (m_fAreaOfEffect == c_fENTIRE_LEVEL ||
				VEC_DIST(vPlayerPos, vMyPos) <= m_fAreaOfEffect)
			{
                CPlayerObj* pPlayer = (CPlayerObj*)g_pLTServer->HandleToObject(hObject);
				if (pPlayer)
				{
					HCLIENT hClient = pPlayer->GetClient();
					if (hClient)
					{
                        HMESSAGEWRITE hMessage = g_pLTServer->StartMessage(hClient, MID_SHAKE_SCREEN);
                        g_pLTServer->WriteToMessageVector(hMessage, &m_vAmount);
                        g_pLTServer->EndMessage(hMessage);
					}
				}
			}
		}
	}
}
예제 #14
0
uint8 GetPlayerTeamId( HOBJECT hPlayer )
{
	if (!GameModeMgr::Instance( ).m_grbUseTeams)
		return INVALID_TEAM;

	CPlayerObj *pPlayer = CPlayerObj::DynamicCast( hPlayer );
	if( !pPlayer )
		return INVALID_TEAM;

	return pPlayer->GetTeamID();
}
예제 #15
0
DBOOL CDestructable::IsPlayerToPlayerDamageOk(HOBJECT hDamager, HOBJECT hOwner)
{
	// Sanity checks...

	if (m_hObject == hDamager) return(DTRUE);
	if (m_hObject == hOwner) return(DTRUE);


	// Check if we are playing a multiplayer game that has the right options set...

	if (!g_pBloodServerShell->IsMultiplayerTeamBasedGame()) return(DTRUE);
	if (g_pBloodServerShell->GetNetGameInfo()->m_bFriendlyFire) return(DTRUE);


	// Make sure we're a player...

	if (!IsPlayer(m_hObject)) return(DTRUE);


	// Get the attacker player for this damager or projectile...

	HOBJECT hHitter = DNULL;

	if (IsPlayer(hDamager))
	{
		hHitter = hDamager;
	}
	else if (IsPlayer(hOwner))
	{
		hHitter = hOwner;
	}

	if (!hHitter) return(DTRUE);


	// Get the player pointers...

	CPlayerObj* pVictim = (CPlayerObj*)g_pServerDE->HandleToObject(m_hObject);
	if (!pVictim) return(DTRUE);

	CPlayerObj* pDamager = (CPlayerObj*)g_pServerDE->HandleToObject(hHitter);
	if (!pDamager) return(DTRUE);


	// Check if these players are on the same team...

	if (pVictim->GetTeamID() == pDamager->GetTeamID()) return(DFALSE);


	// If we get here, it's ok to do the damage...

	return(DTRUE);
}
예제 #16
0
// --------------------------------------------------------------------------- //
//
//	ROUTINE:	TeamBalancer::PlaygroundSort
//
//	PURPOSE:	sort the players onto teams that are roughly equal given their scoring history
//					the first will go onto team 0, 2nd and 3rd to Team 1, 4th and 5th to Team 0, etc.
//
// --------------------------------------------------------------------------- //
void TeamBalancer::PlaygroundSort()
{
	uint32 nTeamSizes[2] = {0,0};

	//sort the player score list from highest to lowest
	std::sort(m_vecPlayerScores.begin(),m_vecPlayerScores.end(),PlayerScoreHistoryCompare());

	uint8 nTargetTeam = INVALID_TEAM;
	uint8 nOtherTeam = INVALID_TEAM;

	//step through the list of players, sorting them onto the teams
	PlayerScoreHistoryArray::iterator scoreIter = m_vecPlayerScores.begin();
	while (scoreIter != m_vecPlayerScores.end())
	{
		uint32 nID = scoreIter->first;
		GameClientData* pGameClientData = ServerConnectionMgr::Instance().GetGameClientDataByClientId(nID);
		if (pGameClientData)
		{
			//we want to leave the highest scoring player on his own team
			//  so if we haven't set the target yet, set it to the team of the highest scoring player
			if (nTargetTeam == INVALID_TEAM)
			{
				nTargetTeam = pGameClientData->GetLastTeamId();
				if (nTargetTeam == INVALID_TEAM)
				{
					nTargetTeam = 0;
				}
				nOtherTeam = (nTargetTeam + 1) % MAX_TEAMS;
			}

			//move the player to the current team
			pGameClientData->SetRequestedTeam(nTargetTeam);
			CPlayerObj* pPlayer = (CPlayerObj*)g_pLTServer->HandleToObject(pGameClientData->GetPlayer());
			if (pPlayer)
			{
				pPlayer->HandleTeamSwitchRequest();
			}
			//increment the team count
			nTeamSizes[nTargetTeam]++;

			//if the team we're adding to is larger, start adding to the other team
			if (nTeamSizes[nTargetTeam] > nTeamSizes[nOtherTeam])
			{
				nTargetTeam = nOtherTeam;
				nOtherTeam = (nTargetTeam + 1) % MAX_TEAMS;
			}

		}
		scoreIter++;
	}

}
예제 #17
0
bool PickupItem::OnTrigger(HOBJECT hSender, const CParsedMsg &cMsg)
{
	static CParsedMsg::CToken s_cTok_Activate("ACTIVATE");
	static CParsedMsg::CToken s_cTok_Team( "TEAM" );

	if( cMsg.GetArg(0) == s_cTok_Activate )
	{
		// Can't activate before we've respawned.
		if( m_bWasPickedUp )
			return true;

		// If the object is dead, it can't pick up stuff...

		if (IsPlayer(hSender))
		{
			CPlayerObj* pPlayer = (CPlayerObj*)g_pLTServer->HandleToObject(hSender);

			if (!pPlayer || pPlayer->IsDead()) return true;

			SetPlayerObj(hSender);

			ObjectTouch(hSender);
		}
		else
		{
			SetPlayerObj(LTNULL);
			return true;
		}
	}
	else if (cMsg.GetArg(0) == s_cTok_Team)
	{
		if( cMsg.GetArgCount( ) > 1 )
		{
			uint32 nTeamId = atoi( cMsg.GetArg( 1 ));
			if( nTeamId < MAX_TEAMS )
			{
				SetTeamId( nTeamId );
			}
			else
			{
				SetTeamId( INVALID_TEAM );
			}

			return true;
		}
	}
	else
		return GameBase::OnTrigger(hSender, cMsg);

	return true;
}
예제 #18
0
bool ScmdServer_Impl::HandleListClients( HCLIENT hClient, ILTMessage_Read& msg )
{
	float fPing = 0.0f;
    uint16 nClientID = 0;
	uint8 aClientIP[4];
	uint16 nPort;
	std::string sPlayerHandle = "";

	// Write out the message header.
	CAutoMessage cMsg;
	cMsg.Writeuint8( MID_SCMD );
	cMsg.Writeuint8( kScmdCommandListClients );
	cMsg.Writeuint8( kScmdCommandStatusOk );

	// Iterate over all the clients and put their id, ping, ip and name in the message.
    HCLIENT hIterClient = g_pLTServer->GetNextClient( NULL );
    while( hIterClient )
	{
        nClientID = ( uint16 )g_pLTServer->GetClientID( hIterClient );
        g_pLTServer->GetClientPing( hIterClient, fPing );
		g_pLTServer->GetClientAddr( hIterClient, aClientIP, &nPort );

		cMsg.Writeuint16(( uint16 )nClientID );
		cMsg.Writeuint16(( uint16 )( fPing + 0.5f ));
		cMsg.Writeuint8( aClientIP[0] );
		cMsg.Writeuint8( aClientIP[1] );
		cMsg.Writeuint8( aClientIP[2] );
		cMsg.Writeuint8( aClientIP[3] );

		// Get the player for this client.  If there is none,
		// then we can't determine the name.
		CPlayerObj* pPlayerObj = ( CPlayerObj* )g_pLTServer->GetClientUserData( hIterClient );
		if( !pPlayerObj )
		{
			sPlayerHandle = "";
		}
		else
		{
			sPlayerHandle = pPlayerObj->GetNetUniqueName( );
		}
		cMsg.WriteString( sPlayerHandle.c_str( ));

	    hIterClient = g_pLTServer->GetNextClient( hIterClient );
	}

	// Write out the the list terminator.
	cMsg.Writeuint16(0xFFFF);
	SendMessage( hClient, *cMsg );

	return true;
}
예제 #19
0
static bool BootClient( bool bById, uint16 nBootClientId, char const* pszBootName )
{
    uint32 nClientId = 0;
	std::string sPlayerHandle = "";
	bool bBooted = false;

	// Iterate over all the clients and put their id, ping, ip and name in the message.
    HCLIENT hIterClient = NULL;
    for( hIterClient = g_pLTServer->GetNextClient( NULL ); hIterClient; 
		hIterClient = g_pLTServer->GetNextClient( hIterClient ))
	{
        nClientId = g_pLTServer->GetClientID( hIterClient );

		// Check if we're booting by ID.
		if( bById )
		{
			if( nClientId == nBootClientId )
			{
				g_pLTServer->KickClient( hIterClient );
				bBooted = true;
				break;
			}
		}
		else
		{
			// Get the player for this client.  If there is none,
			// then we can't determine the name.
			CPlayerObj* pPlayerObj = ( CPlayerObj* )g_pLTServer->GetClientUserData( hIterClient );
			if( !pPlayerObj )
			{
				continue;
			}
			else
			{
				sPlayerHandle = pPlayerObj->GetNetUniqueName( );
			}

			// See if this matches the name we want to boot.
			if( stricmp( pszBootName, sPlayerHandle.c_str( )) == 0 )
			{
				bBooted = ( g_pLTServer->KickClient( hIterClient ) == LT_OK );
				break;
			}
		}
	}

	return bBooted;
}
예제 #20
0
void PlayerVehicle::DoActivate(HOBJECT hSender)
{
	// Make sure we're visible (i.e., spawned in)...

    uint32 dwFlags = g_pLTServer->GetObjectFlags(m_hObject);
	if ( !(dwFlags & FLAG_VISIBLE) || !hSender || !IsPlayer(hSender)) return;


	// Tell the player to hop aboard...

    CPlayerObj* pPlayer = (CPlayerObj*)g_pLTServer->HandleToObject(hSender);
	if (pPlayer)
	{
		pPlayer->RideVehicle(this);
	}
}
예제 #21
0
bool CDoomsDayMissionMgr::CanRespawn( CPlayerObj const& player ) const
{
	// Once the device starts, the other teams can't respawn.
	if( m_nActivatingTeam != INVALID_TEAM && player.GetTeamID( ) != m_nActivatingTeam )
		return false;

	return true;
}
예제 #22
0
void PlayerVehicle::DoActivate(HOBJECT hSender)
{
	// Check if vehicle already being ridden.
	if( m_bRidden )
		return;

	// Make sure we're visible (i.e., spawned in)...

    uint32 dwFlags;
	g_pCommonLT->GetObjectFlags(m_hObject, OFT_Flags, dwFlags);
	if ( !(dwFlags & FLAG_VISIBLE) || !hSender || !IsPlayer(hSender)) return;

	
	if( m_bLocked )
	{
		// Check to see if the player has the correct keys to operate a vehicle...

		if( !g_pKeyMgr->CanCharacterControlObject( hSender, m_hObject ))
		{
			// Send a command if we have one...

			if( m_hstrLockedCommand )
			{
				const char	*pCmd = g_pLTServer->GetStringData( m_hstrLockedCommand );

				if( pCmd && g_pCmdMgr->IsValidCmd( pCmd ))
				{
					g_pCmdMgr->Process( pCmd, m_hObject, hSender );
				}
			}

			// No keys? No vehicle! 
		
			return;
		}
	}

	// Tell the player to hop aboard...

    CPlayerObj* pPlayer = (CPlayerObj*)g_pLTServer->HandleToObject(hSender);
	if (pPlayer)
	{
		pPlayer->RideVehicle(this);
	}
}
void GearItem::ObjectTouch(HOBJECT hObject)
{
	if (!hObject) return;

	// If we hit non-player objects, just ignore them...

	if (IsPlayer(hObject))
	{
        CPlayerObj* pPlayer = (CPlayerObj*)g_pLTServer->HandleToObject(hObject);

		if (pPlayer && !pPlayer->IsDead())
		{
            HMESSAGEWRITE hMessage = g_pLTServer->StartMessageToObject(this, hObject, MID_ADDGEAR);
            g_pLTServer->WriteToMessageByte(hMessage, m_nGearId);
            g_pLTServer->EndMessage(hMessage);
		}
	}
}
예제 #24
0
파일: InvItem.cpp 프로젝트: Arc0re/lithtech
void CInvItem::SendActionMessage()
{
	HMESSAGEWRITE hWrite;
	HCLIENT hClient;
	CPlayerObj *pObj;
	DBYTE nVal;

	if( IsPlayer( m_hOwner ))
	{
		pObj = ( CPlayerObj * )g_pServerDE->HandleToObject(m_hOwner);
		hClient = pObj->GetClient( );
		hWrite = g_pServerDE->StartMessage( hClient, SMSG_INVITEMACTION );
		nVal = GetType( );
		if( m_bIsActive )
			nVal |= 0x80;
		g_pServerDE->WriteToMessageByte( hWrite, nVal );
		g_pServerDE->EndMessage2( hWrite, MESSAGE_GUARANTEED | MESSAGE_NAGGLE );
	}
}
예제 #25
0
bool CSinglePlayerMissionMgr::EndGame( )
{
	// Call base.
	if( !CServerMissionMgr::EndGame( ))
		return false;

	// Tell the players to prepare to exit a level.
	CPlayerObj::PlayerObjList::const_iterator iter = CPlayerObj::GetPlayerObjList( ).begin( );
	while( iter != CPlayerObj::GetPlayerObjList( ).end( ))
	{
		CPlayerObj* pPlayerObj = *iter;
		pPlayerObj->HandlePreExit();
		iter++;
	}

	// Tell the client the game is over.
	SendEmptyClientMsg( MID_END_GAME, NULL, MESSAGE_GUARANTEED );

	return true;
}
예제 #26
0
void ModItem::ObjectTouch(HOBJECT hObject, bool bForcePickup/*=false*/)
{
    if (!hObject) return;

    // If we hit non-player objects, just ignore them...

    if (IsPlayer(hObject))
    {
        CPlayerObj* pPlayer = (CPlayerObj*)g_pLTServer->HandleToObject(hObject);

        if (pPlayer && !pPlayer->IsDead())
        {
            SetPlayerObj(hObject);

            CAutoMessage cMsg;
            cMsg.Writeuint32(MID_ADDMOD);
            cMsg.Writeuint8((uint8)m_nModId);
            g_pLTServer->SendToObject(cMsg.Read(), m_hObject, hObject, MESSAGE_GUARANTEED);
        }
    }
}
예제 #27
0
void CDeathMatchMissionMgr::Update( )
{
	//check for end of level...

	//check score limit
	if ( m_ServerSettings.m_nScoreLimit > 0 && m_fStartTime >= 0.0f )
	{
		CPlayerObj::PlayerObjList::const_iterator iter = CPlayerObj::GetPlayerObjList( ).begin( );
		while( iter != CPlayerObj::GetPlayerObjList( ).end( ))
		{
			CPlayerObj* pPlayerObj = *iter;
			if (pPlayerObj->GetPlayerScore()->GetScore() >= m_ServerSettings.m_nScoreLimit)
			{
				g_pLTServer->CPrint("ScoreLimit reached.");
				NextRound();
			}
			iter++;
		}
	}

	CServerMissionMgr::Update( );
}
BOOL CMyGameSpyMgr::OnPlayersQuery()
{
	// Sanity checks...

	if (!g_pGameServerShell) return(FALSE);


	// Send the info for each player...

	int count = 0;

	CPlayerObj* pPlr = g_pGameServerShell->GetFirstNetPlayer();

	while (pPlr)
	{
		char sPlayer[32];
		sprintf(sPlayer, "player_%i", count);
		SendResponseInfo(sPlayer, pPlr->GetNetName());

		char sFrags[32];
		sprintf(sFrags, "frags_%i", count);
		SendResponseInfo(sFrags, pPlr->GetFragCount());

		char sPing[32];
		sprintf(sPing, "ping_%i", count);
		int nPing = g_pGameServerShell->GetPlayerPing(pPlr);
		if (nPing <= 0) nPing = 1;
		SendResponseInfo(sPing, nPing);

		count++;
		pPlr = g_pGameServerShell->GetNextNetPlayer();
	}


	// All done...

	return(TRUE);
}
예제 #29
0
파일: Turret.cpp 프로젝트: Arc0re/lithtech
void Turret::Deactivate( )
{
	if( !IsInUse( ))
	{
		DebugCPrint(1, "Deactivation failed!");
		return;
	}

	CAutoMessage cMsg;
	cMsg.Writeuint8( MID_SFX_MESSAGE );
	cMsg.Writeuint8( SFX_TURRET_ID );
	cMsg.WriteObject( m_hObject );
	cMsg.Writeuint8( kTurretFXMsg_Deactivate );
	g_pLTServer->SendToClient( cMsg.Read( ), NULL, MESSAGE_GUARANTEED );

	if( IsPlayer( m_hOperatingObject ))
	{
		// Change the players weapon to the turret weapon...
		CPlayerObj *pPlayer = dynamic_cast<CPlayerObj*>(g_pLTServer->HandleToObject( m_hOperatingObject ));
		pPlayer->SetOperatingTurret( *this, false );
	}

	// Process any deactivation command we may have...
	if( !m_sDeactivateCommand.empty( ))
	{
		g_pCmdMgr->QueueCommand( m_sDeactivateCommand.c_str( ), m_hOperatingObject, m_hObject );
	}

	m_hOperatingObject = NULL;

	CreateSpecialFX( false );

	// [RP] NOTE: We still need to continually update to manually keep accurate positions.
	//		Using attachments was causing issues of not being able to activate.  Need to look
	//		further into this.  Once this issue is resolved we should not need to update if 
	//		the turret is deactivates.
	SetNextUpdate( /*UPDATE_NEVER*/ UPDATE_NEXT_FRAME );
}
예제 #30
0
bool DoomsDayDevice::Fire( CPlayerObj& playerObj )
{
	// Make sure it's from someone on our team.
	if( playerObj.GetTeamID( ) != m_nOwningTeamID )
		return false;

	// Send a message letting the players know the device has been activated.
	CAutoMessage cMsg;
	cMsg.Writeuint8( MID_DOOMSDAY_MESSAGE );
	cMsg.Writeuint8( MID_DOOMSDAY_DEVICE_COMPLETED );
	cMsg.Writeuint8( m_nOwningTeamID );
	g_pLTServer->SendToClient( cMsg.Read(), LTNULL, MESSAGE_GUARANTEED );

	// Give the activating player a bunch of points.
	ServerGameOptions& sgo = g_pGameServerShell->GetServerGameOptions( );
	uint32 nBonus = sgo.GetDoomsday( ).m_nDeviceCompletedScore;
	playerObj.GetPlayerScore()->AddBonus( nBonus );

	if( !BeginFire( ))
		return false;

	return true;
}