Ejemplo n.º 1
0
void LightGroup::UpdateClients()
{
	// Calculate our current color
	LTVector vColor = (m_bOn) ? m_vColor : LTVector(0.0f, 0.0f, 0.0f);

	{
		// Set up the update message
		CAutoMessage cMsg;
		cMsg.Writeuint8(MID_SFX_MESSAGE);
		cMsg.Writeuint8(SFX_LIGHTGROUP_ID);
		cMsg.WriteObject(m_hObject);
		cMsg.Writeuint32(m_nID);
		cMsg.WriteLTVector(vColor);

		// Send the message to all connected clients
		g_pLTServer->SendToClient(cMsg.Read(), LTNULL, MESSAGE_GUARANTEED);
	}
	
	{
		CAutoMessage cMsg;
		cMsg.Writeuint8(SFX_LIGHTGROUP_ID);

		cMsg.Writeuint32(m_nID);
		cMsg.WriteLTVector(vColor);

		// Make sure new clients will get the message
		g_pLTServer->SetObjectSFXMessage(m_hObject, cMsg.Read());
	}

	m_bClientNeedsUpdate = false;
}
Ejemplo n.º 2
0
void TextureFX::UpdateClients()
{
	{
		// Set up the update message
		CAutoMessage cMsg;
		cMsg.Writeuint8(MID_SFX_MESSAGE);
		cMsg.Writeuint8(SFX_TEXTUREFX_ID);
		cMsg.WriteObject(m_hObject);
		WriteStageInfo(cMsg);

		// Send the message to all connected clients
		g_pLTServer->SendToClient(cMsg.Read(), LTNULL, MESSAGE_GUARANTEED);
	}
	
	{
		CAutoMessage cMsg;
		cMsg.Writeuint8(SFX_TEXTUREFX_ID);
		WriteStageInfo(cMsg);

		// Make sure new clients will get the message
		g_pLTServer->SetObjectSFXMessage(m_hObject, cMsg.Read());
	}

	m_bClientNeedsUpdate = false;
}
Ejemplo n.º 3
0
void DisplayTimer::UpdateClients()
{
	// Send message to clients telling them about the DisplayTimer...

	float fGameTimeEnd = g_pLTServer->GetTime( ) + m_Timer.GetCountdownTime( );

	{
		// Set up the update message
		CAutoMessage cMsg;
		cMsg.Writeuint8(MID_SFX_MESSAGE);
		cMsg.Writeuint8(SFX_DISPLAYTIMER_ID);
		cMsg.WriteObject(m_hObject);
		cMsg.Writefloat(fGameTimeEnd);
		cMsg.Writeuint8((uint8)m_Timer.Paused());
		cMsg.Writeuint8( m_nTeamId );

		// Send the message to all connected clients
		g_pLTServer->SendToClient(cMsg.Read(), LTNULL, MESSAGE_GUARANTEED);
	}
	
	{
		CAutoMessage cMsg;
		cMsg.Writeuint8(SFX_DISPLAYTIMER_ID);
		cMsg.Writefloat( fGameTimeEnd );
		cMsg.Writeuint8((uint8)m_Timer.Paused());
		cMsg.Writeuint8( m_nTeamId );

		// Make sure new clients will get the message
		g_pLTServer->SetObjectSFXMessage(m_hObject, cMsg.Read());
	}


}
Ejemplo n.º 4
0
void Turret::CreateSpecialFX( bool bUpdateClients )
{
	CWeapon *pWeapon = m_Arsenal.GetCurWeapon( );

	TURRETCREATESTRUCT csTurret;
	csTurret.m_hTurret = m_hTurret;
	csTurret.m_hOperatingObject = m_hOperatingObject;
	csTurret.m_hTurretWeapon = (pWeapon ? pWeapon->GetModelObject( ) : NULL );
	csTurret.m_bRemoteActivation = false;
	csTurret.m_nDamageState = m_nCurDamageState;	
	
	// Give derived classes a chance at updating the client data...
	PreCreateSpecialFX( csTurret );

	{
		CAutoMessage cMsg;
		cMsg.Writeuint8( SFX_TURRET_ID );
		csTurret.Write( cMsg );
		g_pLTServer->SetObjectSFXMessage( m_hObject, cMsg.Read( ));
	}
	

	if( bUpdateClients )
	{
		CAutoMessage cMsg;
		cMsg.Writeuint8( MID_SFX_MESSAGE );
		cMsg.Writeuint8( SFX_TURRET_ID );
		cMsg.WriteObject( m_hObject );
		cMsg.Writeuint8( kTurretFXMsg_All );
		csTurret.Write( cMsg );
		g_pLTServer->SendToClient( cMsg.Read( ), NULL, MESSAGE_GUARANTEED );
	}
}
Ejemplo n.º 5
0
void CTronPlayerObj::HandleDamage(const DamageStruct& damage)
{
	if ( WMGR_INVALID_ID != damage.nAmmoId )
	{
		// hit by a weapon of some sort
		if ( IsDefending() )
		{
			// send a message to the player detailing a successful block
			CAutoMessage cMsg;
			LTRESULT ltResult;

			cMsg.Writeuint8( MID_PROJECTILE );

			// write the projectile message subtype
			cMsg.Writeuint8( MPROJ_BLOCKED );

			// write the defense type
			cMsg.Writeuint8( m_cDefendType );

			// write the defense percentage
			cMsg.Writefloat( GetDefensePercentage( &damage.vDir ) );

			ltResult = g_pLTServer->SendToClient( cMsg.Read(), m_hClient, MESSAGE_GUARANTEED );
			ASSERT( LT_OK == ltResult );
		}
	}

	CPlayerObj::HandleDamage( damage );
}
Ejemplo n.º 6
0
void PlayerVehicle::CreateSFXMsg()
{
	CAutoMessage cMsg;
	cMsg.Writeuint8(SFX_PLAYERVEHICLE_ID);
    m_PlayerVehicleStruct.Write(cMsg);
	g_pLTServer->SetObjectSFXMessage(m_hObject, cMsg.Read());
}
Ejemplo n.º 7
0
void CLeanMgr::BeginLean( eLeanDirection kDir )
{
	m_kLeanDir = kDir;

	m_fMaxLeanAngle = DEG2RAD( g_vtLeanAngle.GetFloat() );
	m_fLeanFromAngle = m_fLastLeanAngle;

	m_fStartTime = 0.0f;
	m_fEndTime = g_vtLeanOutTime.GetFloat();

	if( m_bLeanedOut )
	{
		// Send a message to the server to remove the original stimulus.

		CAutoMessage cMsg;
		cMsg.Writeuint8( MID_PLAYER_CLIENTMSG );
		cMsg.Writeuint8( CP_PLAYER_LEAN );
		cMsg.Writeuint8( PL_CENTER );
		cMsg.WriteLTVector( LTVector( 0, 0, 0) );
		g_pLTClient->SendToServer( cMsg.Read(), MESSAGE_GUARANTEED );
	}

	// If we are just begining to lean then we are not leaned out...

	m_bLeanedOut = false;
}
Ejemplo n.º 8
0
void Door::UpdateSector( bool bSectorActive )
{
	for(uint32 nCurrSector = 0; nCurrSector < knNumSectors; nCurrSector++)
	{
		// Do nothing if we don't have a sector
		if( m_sSectorName[nCurrSector].empty() )
			return;

		// Just in case we get in here before we expect to, update the sector ID..
		if( !m_nSectorID[nCurrSector] )
		{
			if( g_pLTServer->GetSectorID( m_sSectorName[nCurrSector].c_str(), &m_nSectorID[nCurrSector] ) != LT_OK )
			{
				// If we can't find the sector, dump a warning and forget...
				char aNameBuff[256];
				g_pLTServer->GetObjectName( m_hObject, aNameBuff, LTARRAYSIZE(aNameBuff) );
				g_pLTServer->CPrint( "Invalid sector specified in door %s: %s", aNameBuff, m_sSectorName[nCurrSector].c_str() );
				m_sSectorName[nCurrSector].clear();
				return;
			}
		}

		m_bSectorsActive = bSectorActive;

		// Send the dynamic sector message to all connected clients...
		// This is temporary until we get the new networking architecture in place.
		// We can't do it with an FX object because activeworldmodels already have an FX object...
		CAutoMessage cMsg;
		cMsg.Writeuint8( MID_DYNAMIC_SECTOR );
		cMsg.Writeuint32( m_nSectorID[nCurrSector] );
		cMsg.Writebool( bSectorActive );

		g_pLTServer->SendToClient( cMsg.Read(), NULL, MESSAGE_GUARANTEED);
	}
}
Ejemplo n.º 9
0
void ScatterVolume::InitialUpdate( void )
{
	CAutoMessage cMsg;
	cMsg.Writeuint8( SFX_SCATTER_ID );
	WriteScatterInfo( cMsg );
	g_pLTServer->SetObjectSFXMessage( m_hObject, cMsg.Read() );
}
Ejemplo n.º 10
0
void Camera::HandleFOVMsg( HOBJECT hSender, const CParsedMsg &crParsedMsg )
{
	if( crParsedMsg.GetArgCount() >= 3 )
	{
		m_fFovY = (float)atof( crParsedMsg.GetArg(1) );
		m_fFovAspectScale = (float)atof( crParsedMsg.GetArg(2) );

		float fT = 0.0f;

		if( crParsedMsg.GetArgCount() >= 4 )
		{
			fT = (float)atof( crParsedMsg.GetArg(3) );
		}

		CAutoMessage cMsg;
		cMsg.Writeuint8(MID_SFX_MESSAGE);
		cMsg.Writeuint8(SFX_CAMERA_ID);
		cMsg.WriteObject(m_hObject);
		cMsg.Writeuint8(CAMFX_FOV);
		cMsg.Writefloat(m_fFovY);
		cMsg.Writefloat(m_fFovAspectScale);
		cMsg.Writefloat(fT);

		// Send the message to all connected clients
		g_pLTServer->SendToClient(cMsg.Read(), NULL, MESSAGE_GUARANTEED);

		// Update the SpecialFX Message...

		CreateSFXMsg();
	}
}
Ejemplo n.º 11
0
void DecisionObject::Show(bool bShow, bool bForceShow)
{
	if( m_bLock )
		return;

	// Send message to clients telling them about the DecisionObject...

	CAutoMessage cMsg;

	cMsg.Writeuint8(MID_DECISION);

	m_bVisible = bShow;


	if (bShow)
	{
		cMsg.Writeuint8(LTTRUE);
		cMsg.Writeuint8( (bForceShow ? LTTRUE : LTFALSE) );
		for (int i=0; i < MAX_DECISION_CHOICES; i++)
		{
			cMsg.Writeuint32(m_ChoiceData[i].nStringID);
		}
		cMsg.WriteObject(m_hObject);
		cMsg.Writefloat(m_fRadius);
	}
	else
	{
		cMsg.Writeuint8(LTFALSE);
		cMsg.WriteObject(m_hObject);
	}
	g_pLTServer->SendToClient(cMsg.Read(), LTNULL, MESSAGE_GUARANTEED);
}
Ejemplo n.º 12
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;
}
Ejemplo n.º 13
0
void Fire::InitialUpdate(int nInfo)
{
	if (nInfo == INITIALUPDATE_SAVEGAME) return;

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

    g_pCommonLT->SetObjectFlags(m_hObject, OFT_User, m_bOn ? USRFLG_VISIBLE : 0, FLAGMASK_ALL);

	// Tell the clients about the Fire...

	CAutoMessage cMsg;
	cMsg.Writeuint8(SFX_FIRE_ID);
	cMsg.Writefloat(m_fRadius);
    cMsg.Writefloat(m_fSoundRadius);
    cMsg.Writefloat(m_fLightRadius);
    cMsg.Writefloat(m_fLightPhase);
    cMsg.Writefloat(m_fLightFreq);
    cMsg.WriteLTVector(m_vLightOffset);
    cMsg.WriteLTVector(m_vLightColor);
    cMsg.Writeuint8(m_bSmoke);
    cMsg.Writeuint8(m_bLight);
    cMsg.Writeuint8(m_bSparks);
    cMsg.Writeuint8(m_bSound);
    cMsg.Writeuint8(m_bBlackSmoke);
    cMsg.Writeuint8(m_bSmokeOnly);
	g_pLTServer->SetObjectSFXMessage(m_hObject, cMsg.Read());
}
Ejemplo n.º 14
0
void CMusicMgr::DoEvent(Event eEvent)
{
	if ( !m_bEnabled ) return;

	if ( m_bLockedEvent ) return;

	if ( m_acEvents[eEvent] != 0 && (m_afEventChances[eEvent] > GetRandom(0.0, 1.0f)) )
	{
		char szMusic[128];
		uint32 iEvent = GetRandom(0, m_acEvents[eEvent]-1);
		sprintf(szMusic, "MUSIC PM %s %s Beat", m_szTheme, m_aaszEvents[eEvent][iEvent]);

#ifndef _FINAL
		if ( g_ShowMusicTrack.GetFloat() > 0 )
		{
			g_pLTServer->CPrint("Server sending client Music Message: (%s)", szMusic);
		}
#endif

		HSTRING hMusic = g_pLTServer->CreateString(szMusic);
		CAutoMessage cMsg;
		cMsg.Writeuint8(MID_MUSIC);
		cMsg.WriteHString(hMusic);
		g_pLTServer->SendToClient(cMsg.Read(), LTNULL, MESSAGE_GUARANTEED);
		FREE_HSTRING(hMusic);
	}
}
Ejemplo n.º 15
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 );
		}
	}
}
Ejemplo n.º 16
0
void ServerVoteMgr::CheckVoteStatus( )
{
	//check to see if this requires a unanimous vote
	bool bUnanimous = m_CurrentVote.m_nVotesNeeded >= m_lstEligibleVoter.size();

	if (m_CurrentVote.m_nYesVotes >= m_CurrentVote.m_nVotesNeeded)
	{
		HandleVotePass();
	}
	else if (m_CurrentVote.m_nNoVotes >= m_CurrentVote.m_nVotesNeeded )
	{
		HandleVoteFail();
	}
	else if (bUnanimous && m_CurrentVote.m_nNoVotes > 0)
	{
		HandleVoteFail();
	}
	else
	{
		//Update clients
		CAutoMessage cMsg;
		cMsg.Writeuint8( MID_VOTE );
		cMsg.WriteBits( eVote_Cast, FNumBitsExclusive<kNumVoteActions>::k_nValue );
		cMsg.Writeuint8( m_CurrentVote.m_nVoteID );
		cMsg.Writeuint8( m_CurrentVote.m_nYesVotes );
		cMsg.Writeuint8( m_CurrentVote.m_nNoVotes );
		cMsg.Writeuint8( m_CurrentVote.m_nVotesNeeded );
		// Send the vote status info to the eligible voters.
		SendToEligibleVoters( *cMsg.Read( ));
	}
}
void CClientMeleeCollisionController::HandleBlocked(HOBJECT hTarget, const LTVector& vPos, const LTVector& vDir)
{
	// Get the proper weapon record...
	CClientWeapon* pClientWeapon = g_pClientWeaponMgr->GetCurrentClientWeapon();
	HWEAPON hWeapon = pClientWeapon ? pClientWeapon->GetWeaponRecord() : NULL;	//!!ARL: Use Attacker's weapon instead?  (will need to be sent from server - probably along with block info)
	HWEAPONDATA hWeaponData = g_pWeaponDB->GetWeaponData(hWeapon, !USE_AI_DATA);

	// Spawn a block effect for it...
	const char* pszBlockFX = g_pWeaponDB->GetString(hWeaponData, "BlockFX");
	CLIENTFX_CREATESTRUCT fxcs(pszBlockFX, 0, LTRigidTransform(vPos, LTRotation(vDir, LTVector(0,1,0))));
	g_pGameClientShell->GetSimulationTimeClientFXMgr().CreateClientFX(NULL, fxcs, true);

	// Let the server objects know they've blocked / been blocked.
	CAutoMessage cMsg;
	cMsg.Writeuint8(MID_OBJECT_MESSAGE);
	cMsg.WriteObject(m_hObject);
	cMsg.Writeuint32(MID_MELEEBLOCK);
	cMsg.WriteObject(hTarget);
	g_pLTClient->SendToServer(cMsg.Read(), MESSAGE_GUARANTEED);

	// Disable attacker's collision (i.e. stop attacking).
	DisableCollisions();

	// For local player attackers, send a BlockRecoil stimulus so a proper animation can be played.
	if (m_hObject == g_pPlayerMgr->GetMoveMgr()->GetObject())
	{
		CPlayerBodyMgr::Instance().HandleAnimationStimulus("CS_RecoilFromBlock");
	}
}
Ejemplo n.º 18
0
static void SendCancelNotEnoughPlayers( HCLIENT hTarget )
{
	// Tell the player why their vote didn't start
	CAutoMessage cMsg;
	cMsg.Writeuint8( MID_VOTE );
	cMsg.WriteBits( eVote_Cancel_Players, FNumBitsExclusive<kNumVoteActions>::k_nValue );
	g_pLTServer->SendToClient( cMsg.Read(), hTarget, MESSAGE_GUARANTEED );
}
Ejemplo n.º 19
0
uint32 SpecialMove::OnAllObjectsCreated()
{
	CAutoMessage cMsg;
	WriteSFXMsg(cMsg);
	g_pLTServer->SetObjectSFXMessage(m_hObject, cMsg.Read());

	return GameBase::OnAllObjectsCreated();
}
Ejemplo n.º 20
0
void CScreenJoin::ReadCurServerList()
{
	m_nSelectedServer = 0;

	IServerDirectory *pServerDir = g_pClientMultiplayerMgr->GetServerDir();
	IServerDirectory::TPeerList cPeers = pServerDir->GetPeerList();
	m_cServerList.resize(cPeers.size());
	IServerDirectory::TPeerList::const_iterator iCurPeer = cPeers.begin();
	TServerList::iterator iCurServer = m_cServerList.begin();
	for (; iCurPeer != cPeers.end(); ++iCurPeer, ++iCurServer)
	{
		// Indicate that the server's an invalid entry until we get everything..
		iCurServer->m_sAddress.clear();

		char aStringBuffer[256];
	
		// Point at this server
		if (!pServerDir->SetActivePeer(iCurPeer->c_str()))
			continue;

		// Read the name
		CAutoMessage cMsg;
		if (!pServerDir->GetActivePeerInfo(IServerDirectory::ePeerInfo_Name, cMsg))
			continue;
		{
			CLTMsgRef_Read cRead(cMsg.Read());
			cRead->ReadString(aStringBuffer, sizeof(aStringBuffer));
		}
		iCurServer->m_sName = aStringBuffer;

		// Read the summary
		if (!pServerDir->GetActivePeerInfo(IServerDirectory::ePeerInfo_Summary, cMsg))
			continue;
		{
			CLTMsgRef_Read cRead(cMsg.Read());
			cRead->ReadString(aStringBuffer, sizeof(aStringBuffer));
			iCurServer->m_sMap = aStringBuffer;
			iCurServer->m_nNumPlayers = cRead->Readuint8();
			iCurServer->m_nMaxPlayers = cRead->Readuint8();
		}

		// Ok, this one's valid
		iCurServer->m_sAddress = *iCurPeer;
	}
}
Ejemplo n.º 21
0
void CCheatMgr::SendCheatMessageHRecord( CheatCode nCheatCode, HRECORD hRecord )
{
	// Send the Message to the server
	CAutoMessage cMsg;
	cMsg.Writeuint8(MID_PLAYER_CHEAT);
	cMsg.Writeuint8((uint8)nCheatCode);
	cMsg.WriteDatabaseRecord( g_pLTDatabase, hRecord );
	g_pLTClient->SendToServer(cMsg.Read(), MESSAGE_GUARANTEED);
}
Ejemplo n.º 22
0
// --------------------------------------------------------------------------- //
//
//	ROUTINE:	TeamBalancer::BalanceTeamScore
//
//	PURPOSE:	balance teams by using playground sorting based on player scores
//
// --------------------------------------------------------------------------- //
bool TeamBalancer::BalanceTeamScore()
{

	m_nRoundsSinceScoreBalance = 0;

	bool bDoSort = false;


	//figure out the score difference
	int32 nDiff = LTDIFF(m_nTeamScores[0],m_nTeamScores[1]);
	if (nDiff > 0)
	{
		ServerConnectionMgr::GameClientDataList& gameClientDataList = ServerConnectionMgr::Instance( ).GetGameClientDataList( );
		//for 2 or fewer players don't bother doing a complicated sort, just balance the team sizes if needed
//		if (gameClientDataList.size() <= 2)
//		{
//			BalanceTeamSize();
//		}
//		else
		{
			int32 nLower = LTMIN(m_nTeamScores[0],m_nTeamScores[1]);

			//if the lower score is 0, treat it as one for these calculations to avoid divide by 0 errors
			if (nLower == 0)
			{
				nLower = 1;
			}

			//how much did the winners win by? This formula 1+(diff/lower) is used instead of
			//	(high/low) in order to handle 0 and negative high score more cleanly
			float fRatio = 1.0f + (float)nDiff/ (float)LTAbs(nLower);
			
			//see if the margin was wide enough to trigger a shuffle
			bDoSort = (fRatio >= GameModeMgr::Instance().m_grfTeamScoreBalancingPercent);
		}

	}

	if (bDoSort)
	{
		PlaygroundSort();

		CAutoMessage cClientMsg;
		cClientMsg.Writeuint8(MID_PLAYER_EVENT);
		cClientMsg.Writeuint8(kPEAutobalance);
		cClientMsg.Writebool( true ); //did score balancing
		g_pLTServer->SendToClient(cClientMsg.Read(), NULL, MESSAGE_GUARANTEED);

	}

	//chear the history, whether or not we actually sorted
	m_nTeamScores[0] = 0;
	m_nTeamScores[1] = 0;
	m_vecPlayerScores.clear();

	return bDoSort;
}
Ejemplo n.º 23
0
void CCheatMgr::SendCheatMessage( CheatCode nCheatCode, uint32 nData )
{
	// Send the Message to the server
	CAutoMessage cMsg;
	cMsg.Writeuint8(MID_PLAYER_CHEAT);
	cMsg.Writeuint8((uint8)nCheatCode);
	cMsg.Writeuint32(nData);
	g_pLTClient->SendToServer(cMsg.Read(), MESSAGE_GUARANTEED);
}
Ejemplo n.º 24
0
void SpecialMove::HandleActivateMsg( HOBJECT hSender, const CParsedMsg &crParsedMsg  )
{
	CAutoMessage cMsg;
	cMsg.Writeuint8( MID_SFX_MESSAGE );
	cMsg.Writeuint8( GetSFXID() );
	cMsg.WriteObject( m_hObject );
	cMsg.Writeuint8( SPECIALMOVEFX_ACTIVATE );
	g_pLTServer->SendToClient( cMsg.Read(), NULL, MESSAGE_GUARANTEED );
}
Ejemplo n.º 25
0
void SpecialMove::SetEnabled(bool bOn)
{
	CAutoMessage cMsg;
	cMsg.Writeuint8( MID_SFX_MESSAGE );
	cMsg.Writeuint8( GetSFXID() );
	cMsg.WriteObject( m_hObject );
	cMsg.Writeuint8( bOn ? SPECIALMOVEFX_ON : SPECIALMOVEFX_OFF );
	g_pLTServer->SendToClient( cMsg.Read(), NULL, MESSAGE_GUARANTEED );
}
Ejemplo n.º 26
0
// --------------------------------------------------------------------------- //
//
//	ROUTINE:	CTronPlayerObj::AcquireProcedural
//
//	PURPOSE:	A message came telling us to acquire this
//
// --------------------------------------------------------------------------- //
bool CTronPlayerObj::AcquireProcedural(char const* pName)
{
	// Send a message to the client
	CAutoMessage cMsg;
	cMsg.Writeuint8(MID_PROCEDURAL_OBTAINED);
	cMsg.WriteString(pName);
	g_pLTServer->SendToClient(cMsg.Read(), GetClient(), MESSAGE_GUARANTEED);
	return true;
}
Ejemplo n.º 27
0
void BuildLensFlareSFXMessage(LENSFLARE & lensProps, LPBASECLASS pClass)
{
	if (!pClass) return;

	CAutoMessage cMsg;
	cMsg.Writeuint8(SFX_LENSFLARE_ID);
	::AddLensFlareInfoToMessage(lensProps, cMsg);
	g_pLTServer->SetObjectSFXMessage(pClass->m_hObject, cMsg.Read());
}
Ejemplo n.º 28
0
LTRESULT CTO2GameServerShell::OnServerInitialized()
{
	LTRESULT nResult = CGameServerShell::OnServerInitialized();

	// Don't do anything special if we're playing single-player
	if (!IsMultiplayerGame( ))
	{
		SetServerDir(0);
		return nResult;
	}

	IServerDirectory *pServerDir = Factory_Create_IServerDirectory_Titan( false, *g_pLTServer, NULL );
	if( !pServerDir )
	{	
		ASSERT( !"ServerDir is NULL!" );
		return LT_ERROR;
	}
	SetServerDir(pServerDir);

	// Set the game's name
	pServerDir->SetGameName(g_pVersionMgr->GetNetGameName());
	// Set the version
	pServerDir->SetVersion(g_pVersionMgr->GetNetVersion());
	pServerDir->SetRegion(g_pVersionMgr->GetNetRegion());
	// Set up the network messaging header
	CAutoMessage cMsg;
	cMsg.Writeuint8(0xD); // SMSG_MESSAGE
	cMsg.Writeuint8(MID_MULTIPLAYER_SERVERDIR);
	pServerDir->SetNetHeader(*cMsg.Read());

	StartupInfo_Titan startupInfo;
	startupInfo.m_sGameSpyName = "nolf2";
	// Obfuscate the secret key a little.
	startupInfo.m_sGameSpySecretKey = "g";
	startupInfo.m_sGameSpySecretKey += "3";
	startupInfo.m_sGameSpySecretKey += "F";
	startupInfo.m_sGameSpySecretKey += "o";
	startupInfo.m_sGameSpySecretKey += "6";
	startupInfo.m_sGameSpySecretKey += "x";
	cMsg.Writeuint32(( uint32 )&startupInfo );
	pServerDir->SetStartupInfo( *cMsg.Read( ));

	return nResult;
}
Ejemplo n.º 29
0
bool CServerMissionMgr::ExitLevelToSavedGame( char const* pszNewLevel )
{
	TRACE( "CServerMissionMgr::ExitLevelToSavedGame\n" );

	// Check if we're already exiting a level.
	if( m_bExitingLevel )
		return true;

	// Verify inputs.
	if( !pszNewLevel )
	{
		ASSERT( !"CServerMissionMgr::ExitLevelToSavedGame: Invalid inputs." );
		return false;
	}

	// Default to this not being a mission change.
	m_bNewMission = false;

	// Check if the new level is a new mission.
	int nCurMission = m_nCurrentMission;
	if( !SetMissionBasedOnLevel( pszNewLevel ))
		return false;

	// If we switch to a custom level, then consider it a new mission.
	if( m_bCustomLevel )
	{
		m_bNewMission = true;
		m_nCurCampaignIndex = -1;
	}
	// If it's not a custom world, check if our mission changed.
	else
	{
		m_bNewMission = ( nCurMission != m_nCurrentMission );

		// If we had a mission switch, advance our campaign index.
		if( m_bNewMission )
		{
			// See if we can find the campaign index from our previous position.
			m_nCurCampaignIndex = FindNextCampaignIndex( m_nCurCampaignIndex, m_nCurrentMission );
		}
	}

	if (IsMultiplayerGame())
	{
		// Tell clients we're exiting. Don't wait for their response.
		CAutoMessage cMsg;
		cMsg.Writeuint8( MID_EXIT_LEVEL );
		cMsg.WriteString( m_sCurrentWorldName );
		cMsg.Writebool( m_bNewMission );
		cMsg.Writebool( false );
		cMsg.Writebool( false );
		g_pLTServer->SendToClient(cMsg.Read(), LTNULL, MESSAGE_GUARANTEED);
	}

	return true;
}
Ejemplo n.º 30
0
void Sprinkles::OnInitialUpdate()
{
	CAutoMessage cMsg;

	cMsg.Writeuint8(SFX_SPRINKLES_ID);

	m_SprinkleStruct.Write(cMsg);

    g_pLTServer->SetObjectSFXMessage(m_hObject, cMsg.Read());
}