int CLuaPlayerDefs::GetPlayerNametagColor(lua_State* luaVM) { // int, int, int getPlayerNametagColor ( player thePlayer ) CClientPlayer* pPlayer; CScriptArgReader argStream(luaVM); argStream.ReadUserData(pPlayer); if (!argStream.HasErrors()) { // Grab his nametag color and return it unsigned char ucR, ucG, ucB; pPlayer->GetNametagColor(ucR, ucG, ucB); lua_pushnumber(luaVM, ucR); lua_pushnumber(luaVM, ucG); lua_pushnumber(luaVM, ucB); return 3; } else m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage()); // Failed lua_pushboolean(luaVM, false); return 1; }
int CLuaPlayerDefs::GetPlayerNametagText(lua_State* luaVM) { // string getPlayerNametagText ( player thePlayer ) CClientPlayer* pPlayer; CScriptArgReader argStream(luaVM); argStream.ReadUserData(pPlayer); if (!argStream.HasErrors()) { // Grab his nametag text and return it const char* szName = pPlayer->GetNametagText(); if (szName) { lua_pushstring(luaVM, szName); return 1; } } else m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage()); // Failed lua_pushboolean(luaVM, false); return 1; }
void CCameraRPCs::SetCameraTarget ( NetBitStreamInterface& bitStream ) { ElementID targetID; if ( bitStream.Read ( targetID ) ) { CClientEntity * pEntity = CElementIDs::GetElement ( targetID ); if ( pEntity ) { // Save our current target for later CClientEntity * pPreviousTarget = m_pCamera->GetTargetEntity (); switch ( pEntity->GetType () ) { case CCLIENTPLAYER: { CClientPlayer* pPlayer = static_cast < CClientPlayer* > ( pEntity ); if ( pPlayer->IsLocalPlayer () ) { // Return the focus to the local player m_pCamera->SetFocusToLocalPlayer (); } else { // Put the focus on that player m_pCamera->SetFocus ( pPlayer, MODE_BEHINDCAR, false ); } break; } default: return; } } } }
void CClientPacketRecorder::ReadLocalData(FILE* pFile) { // Grab the local player CClientPlayer* pPlayer = m_pManager->GetPlayerManager()->GetLocalPlayer(); if (pPlayer) { // Grab the vehicle CClientVehicle* pVehicle = pPlayer->GetOccupiedVehicle(); if (pVehicle) { // Temp vars CMatrix matVehicle; CVector vecMoveSpeed; CVector vecTurnSpeed; float fHealth; // Read it out fread(&matVehicle.vRight.fX, sizeof(float), 1, pFile); fread(&matVehicle.vRight.fY, sizeof(float), 1, pFile); fread(&matVehicle.vRight.fZ, sizeof(float), 1, pFile); fread(&matVehicle.vFront.fX, sizeof(float), 1, pFile); fread(&matVehicle.vFront.fY, sizeof(float), 1, pFile); fread(&matVehicle.vFront.fZ, sizeof(float), 1, pFile); fread(&matVehicle.vUp.fX, sizeof(float), 1, pFile); fread(&matVehicle.vUp.fY, sizeof(float), 1, pFile); fread(&matVehicle.vUp.fZ, sizeof(float), 1, pFile); fread(&matVehicle.vPos.fX, sizeof(float), 1, pFile); fread(&matVehicle.vPos.fY, sizeof(float), 1, pFile); fread(&matVehicle.vPos.fZ, sizeof(float), 1, pFile); fread(&vecMoveSpeed.fX, sizeof(float), 1, pFile); fread(&vecMoveSpeed.fY, sizeof(float), 1, pFile); fread(&vecMoveSpeed.fZ, sizeof(float), 1, pFile); fread(&vecTurnSpeed.fX, sizeof(float), 1, pFile); fread(&vecTurnSpeed.fY, sizeof(float), 1, pFile); fread(&vecTurnSpeed.fZ, sizeof(float), 1, pFile); fread(&fHealth, sizeof(float), 1, pFile); CControllerState cs; fread(&cs, sizeof(CControllerState), 1, pFile); // Set the data pVehicle->SetMatrix(matVehicle); pVehicle->SetMoveSpeed(vecMoveSpeed); pVehicle->SetTurnSpeed(vecTurnSpeed); pVehicle->SetHealth(fHealth); // Set the controller state CControllerState csLast; g_pGame->GetPad()->Disable(true); g_pGame->GetPad()->GetCurrentControllerState(&csLast); g_pGame->GetPad()->SetLastControllerState(&csLast); g_pGame->GetPad()->SetCurrentControllerState(&cs); } } }
int CLuaTeamDefs::GetPlayersInTeam ( lua_State* luaVM ) { CClientTeam* pTeam = NULL; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pTeam ); if ( !argStream.HasErrors () ) { lua_newtable ( luaVM ); unsigned int uiIndex = 0; list < CClientPlayer* > ::const_iterator iter = pTeam->IterBegin (); for ( ; iter != pTeam->IterEnd (); iter++ ) { CClientPlayer* pPlayer = *iter; if ( !pPlayer->IsBeingDeleted () ) { lua_pushnumber ( luaVM, ++uiIndex ); lua_pushelement ( luaVM, pPlayer ); lua_settable ( luaVM, -3 ); } } return 1; } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); lua_pushboolean ( luaVM, false ); return 1; }
void CClientCamera::ToggleCameraFixedMode ( bool bEnabled ) { if ( bEnabled ) { CClientPlayer* pLocalPlayer = m_pManager->GetPlayerManager()->GetLocalPlayer (); CClientVehicle* pLocalVehicle = NULL; // Get the local vehicle, if any if ( pLocalPlayer ) pLocalVehicle = pLocalPlayer->GetOccupiedVehicle (); // Use the local vehicle, otherwise use the local player if ( pLocalVehicle ) SetFocus ( pLocalVehicle, MODE_FIXED, false ); else SetFocus ( pLocalPlayer, MODE_FIXED, false ); // Set the target position SetFocus ( &m_vecFixedPosition, false ); } else { g_pMultiplayer->SetCenterOfWorld ( NULL, NULL, NULL ); SetFocusToLocalPlayer(); m_fRoll = 0.0f; m_fFOV = 70.0f; } }
int CLuaPlayerDefs::GetPlayerTeam(lua_State* luaVM) { // team getPlayerTeam ( player thePlayer ) CClientPlayer* pPlayer; CScriptArgReader argStream(luaVM); argStream.ReadUserData(pPlayer); if (!argStream.HasErrors()) { // Grab his team and return it CClientTeam* pTeam = pPlayer->GetTeam(); if (pTeam) { lua_pushelement(luaVM, pTeam); return 1; } } else m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage()); // Failed lua_pushboolean(luaVM, false); return 1; }
void CFoo::DoPulse ( void ) { CClientManager* pManager = g_pClientGame->GetManager (); if ( pManager->IsGameLoaded () ) { CClientPlayerManager* pPlayerManager = pManager->GetPlayerManager (); CClientPlayer* pLocal = pManager->GetPlayerManager ()->GetLocalPlayer (); if ( !pLocal ) return; CVector vecLocal; pLocal->GetPosition ( vecLocal ); CClientCamera* pCamera = pManager->GetCamera (); /* CClientVehicle* pVehicle = pLocal->GetOccupiedVehicle (); if ( pVehicle ) { unsigned char ucGear = pVehicle->GetGameVehicle ()->GetCurrentGear (); g_pCore->GetGraphics ()->DrawText ( 200, 200, 0xFFFFFFFF, 1.0f, "Gear = %u", ucGear ); } */ // ChrML: Reproduces issue #2741 if ( bFoo_PlayerLimitCrash ) { static CClientPed* pPed = NULL; if ( !pPed ) { pPed = new CClientPlayer ( pManager, 50 ); CVector vecLocal; pPlayerManager->GetLocalPlayer ()->GetPosition ( vecLocal ); vecLocal.fX += 10; pPed->SetPosition ( vecLocal ); } static unsigned long ulTestTime = 0; if ( ulTestTime == 0 ) { ulTestTime = CClientTime::GetTime () + 50; } if ( CClientTime::GetTime () > ulTestTime ) { ulTestTime = CClientTime::GetTime () + 50; static unsigned int uiIndex = 0; ++uiIndex; pPed->SetModel ( uiIndex ); if ( uiIndex > 290 ) uiIndex = 0; } } } }
void CElementRPCs::SetElementPosition ( NetBitStreamInterface& bitStream ) { // Read out the entity id and the position ElementID ID; CVector vecPosition; unsigned char ucTimeContext; if ( bitStream.Read ( ID ) && bitStream.Read ( vecPosition.fX ) && bitStream.Read ( vecPosition.fY ) && bitStream.Read ( vecPosition.fZ ) && bitStream.Read ( ucTimeContext ) ) { // Grab the entity CClientEntity* pEntity = CElementIDs::GetElement ( ID ); if ( pEntity ) { // Update the sync context to the new one pEntity->SetSyncTimeContext ( ucTimeContext ); // If it's a player, use Teleport if ( pEntity->GetType () == CCLIENTPLAYER ) { unsigned char ucWarp = 1; bitStream.Read ( ucWarp ); CClientPlayer* pPlayer = static_cast < CClientPlayer* > ( pEntity ); if ( ucWarp ) { pPlayer->Teleport ( vecPosition ); pPlayer->ResetInterpolation (); } else { pPlayer->SetPosition ( vecPosition ); } // If local player, reset return position (so we can't warp back if connection fails) if ( pPlayer->IsLocalPlayer () ) { m_pClientGame->GetNetAPI ()->ResetReturnPosition (); } } else if ( pEntity->GetType () == CCLIENTVEHICLE ) { CClientVehicle* pVehicle = static_cast < CClientVehicle* > ( pEntity ); pVehicle->RemoveTargetPosition (); pVehicle->SetPosition ( vecPosition ); } else { // Set its position pEntity->SetPosition ( vecPosition ); } } } }
void CPlayerRPCs::SetPlayerNametagColor(CClientEntity* pSource, NetBitStreamInterface& bitStream) { unsigned char ucR, ucG, ucB; if (bitStream.Read(ucR) && bitStream.Read(ucG) && bitStream.Read(ucB)) { CClientPlayer* pPlayer = m_pPlayerManager->Get(pSource->GetID()); if (pPlayer) pPlayer->SetNametagOverrideColor(ucR, ucG, ucB); } }
void COMMAND_RadioPrevious ( const char* szCmdLine ) { if ( g_pClientGame ) { CClientPlayer* pPlayer = g_pClientGame->GetPlayerManager ()->GetLocalPlayer (); if ( pPlayer ) { pPlayer->PreviousRadioChannel (); } } }
void CPlayerRPCs::SetPlayerNametagShowing ( CClientEntity* pSource, NetBitStreamInterface& bitStream ) { unsigned char ucShowing; if ( bitStream.Read ( ucShowing ) ) { CClientPlayer* pPlayer = m_pPlayerManager->Get ( pSource->GetID () ); if ( pPlayer ) { pPlayer->SetNametagShowing ( ( ucShowing == 1 ) ); } } }
void CClientPlayerManager::ResetAll ( void ) { vector < CClientPlayer* > ::const_iterator iter = m_Players.begin (); for ( ; iter != m_Players.end (); iter++ ) { CClientPlayer * pPlayer = *iter; if ( pPlayer ) { pPlayer->Reset (); } } }
int CLuaFunctionDefs::GetSoundEffects ( lua_State* luaVM ) { CClientPlayer* pPlayer = NULL; CClientSound* pSound = NULL; CScriptArgReader argStream ( luaVM ); if ( argStream.NextIsUserDataOfType < CClientSound > ( ) ) { argStream.ReadUserData ( pSound ); } else if ( argStream.NextIsUserDataOfType < CClientPlayer > ( ) ) { argStream.ReadUserData ( pPlayer ); } else { m_pScriptDebugging->LogBadPointer ( luaVM, "sound/player", 1 ); lua_pushboolean ( luaVM, false ); return false; } if ( !argStream.HasErrors() ) { if ( pSound ) { std::map < std::string, int > iFxEffects = m_pManager->GetSoundManager()->GetFxEffects(); lua_newtable ( luaVM ); for ( std::map < std::string, int >::const_iterator iter = iFxEffects.begin(); iter != iFxEffects.end(); ++iter ) { lua_pushboolean ( luaVM, pSound->IsFxEffectEnabled ( (*iter).second ) ); lua_setfield ( luaVM, -2, (*iter).first.c_str () ); } return 1; } else if ( pPlayer ) { CClientPlayerVoice * pPlayerVoice = pPlayer->GetVoice ( ); std::map < std::string, int > iFxEffects = m_pManager->GetSoundManager()->GetFxEffects(); lua_newtable ( luaVM ); for ( std::map < std::string, int >::const_iterator iter = iFxEffects.begin(); iter != iFxEffects.end(); ++iter ) { lua_pushboolean ( luaVM, pPlayerVoice->IsFxEffectEnabled ( (*iter).second ) ); lua_setfield ( luaVM, -2, (*iter).first.c_str () ); } return 1; } } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() ); lua_pushboolean ( luaVM, false ); return 1; }
void CPlayerRPCs::SetPlayerTeam ( CClientEntity* pSource, NetBitStreamInterface& bitStream ) { ElementID TeamID; if ( bitStream.Read ( TeamID ) ) { CClientTeam* pTeam = m_pTeamManager->GetTeam ( TeamID ); CClientPlayer* pPlayer = m_pPlayerManager->Get ( pSource->GetID () ); if ( pPlayer ) { pPlayer->SetTeam ( pTeam, true ); } } }
bool CClientProjectileManager::Hook_ProjectileAllow ( CEntity * pGameCreator, eWeaponType weaponType, CVector * origin, float fForce, CVector * target, CEntity * targetEntity ) { // Called before projectile creation, we need to decide to allow or cancel it here // Is this a local projectile? CClientPlayer * pLocalPlayer = m_pManager->GetPlayerManager ()->GetLocalPlayer (); // Store the creator/local variables for the next stage m_pCreator = m_pManager->FindEntity ( pGameCreator, true ); m_bIsLocal = ( m_pCreator == pLocalPlayer || ( pLocalPlayer->GetOccupiedVehicleSeat () == 0 && m_pCreator == pLocalPlayer->GetOccupiedVehicle () ) ); return ( m_bCreating || m_bIsLocal ); }
void CClient::GetPlayerNames(std::vector<SString>& vPlayerNames) { if (g_pClientGame) { vPlayerNames.clear(); for (std::vector<CClientPlayer*>::const_iterator iter = g_pClientGame->GetPlayerManager()->IterBegin(); iter != g_pClientGame->GetPlayerManager()->IterEnd(); ++iter) { CClientPlayer* pClient = *iter; SString strPlayerName = pClient->GetNametagText(); vPlayerNames.push_back(strPlayerName); } } }
void COMMAND_MessageTarget ( const char* szCmdLine ) { if ( !(szCmdLine || szCmdLine[0]) ) return; CClientPlayer* pTarget = g_pClientGame->GetTargetedPlayer (); if ( pTarget ) { const char * szNick = pTarget->GetNick (); if ( !szNick ) return; SString strParameters ( "%s %s", pTarget->GetNick (), szCmdLine ); g_pCore->GetCommands ()->Execute ( "msg", strParameters ); } else g_pCore->ChatEchoColor ( "Error: no player target found", 255, 168, 0 ); }
CPed* CClientTask::GetParameterPed ( const char* szKey ) { // Grab the parameter, is it userdata? CLuaArgument* pArgument = GetParameter ( szKey ); if ( pArgument && pArgument->GetType () == LUA_TLIGHTUSERDATA ) { // Grab the player and verify it CClientPlayer* pPlayer = reinterpret_cast < CClientPlayer* > ( pArgument->GetLightUserData () ); if ( VERIFY_PLAYER ( pPlayer ) ) { // Return his game player return pPlayer->GetGamePlayer (); } } // Non-existing return NULL; }
CClientPlayer * CStreamer::GetPlayerFromGamePlayerPed(IVPlayerPed * pGamePlayerPed) { // Get the streamed in players list std::list <CStreamableEntity *> * m_streamedVehicles = &m_streamedElements[ENTITY_TYPE_PLAYER]; // Loop through the streamed in players list for(std::list<CStreamableEntity *>::iterator iter = m_streamedVehicles->begin(); iter != m_streamedVehicles->end(); iter++) { // Get the player pointer CClientPlayer * pTestPlayer = reinterpret_cast<CClientPlayer *>(*iter); // Is this the player we are looking for? if(pTestPlayer->GetGamePlayerPed()->GetPlayerPed() == pGamePlayerPed) return pTestPlayer; } // No player found return NULL; }
void CElementRPCs::SetElementDimension ( NetBitStreamInterface& bitStream ) { ElementID ID; unsigned short usDimension; if ( bitStream.Read ( ID ) && bitStream.Read ( usDimension ) ) { CClientEntity* pEntity = CElementIDs::GetElement ( ID ); if ( pEntity ) { if ( pEntity->GetType () == CCLIENTTEAM ) { CClientTeam* pTeam = static_cast < CClientTeam* > ( pEntity ); list < CClientPlayer* > ::const_iterator iter = pTeam->IterBegin (); for ( ; iter != pTeam->IterEnd () ; iter++ ) { CClientPlayer* pPlayer = *iter; if ( pPlayer->IsLocalPlayer () ) { // Update all of our streamers/managers to the local player's dimension m_pClientGame->SetAllDimensions ( usDimension ); } pPlayer->SetDimension ( usDimension ); } } else { if ( pEntity->GetType () == CCLIENTPLAYER ) { CClientPlayer* pPlayer = static_cast < CClientPlayer* > ( pEntity ); if ( pPlayer->IsLocalPlayer () ) { // Update all of our streamers/managers to the local player's dimension m_pClientGame->SetAllDimensions ( usDimension ); } } pEntity->SetDimension ( usDimension ); } } } }
int CLuaPlayerDefs::IsPlayerNametagShowing(lua_State* luaVM) { // bool isPlayerNametagShowing ( player thePlayer ) CClientPlayer* pPlayer; CScriptArgReader argStream(luaVM); argStream.ReadUserData(pPlayer); if (!argStream.HasErrors()) { bool bIsNametagShowing = pPlayer->IsNametagShowing(); lua_pushboolean(luaVM, bIsNametagShowing); return 1; } else m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage()); lua_pushboolean(luaVM, false); return 1; }
void COMMAND_EnterPassenger ( const char* szCmdLine ) { // HACK: we don't want them to enter a vehicle if they're in cursor mode if ( g_pClientGame && !g_pCore->IsCursorForcedVisible() ) { // Disable passenger entry while reloading so it doesen't abort the animation CClientPlayer* pPlayer = g_pClientGame->GetPlayerManager ()->GetLocalPlayer (); if ( pPlayer ) { CWeapon* pWeapon = pPlayer->GetWeapon (); if ( pWeapon ) { if ( pWeapon->GetState() != WEAPONSTATE_RELOADING ) { g_pClientGame->ProcessVehicleInOutKey ( true ); } } } } }
int CLuaPlayerDefs::GetPlayerPing(lua_State* luaVM) { // int getPlayerPing ( player thePlayer ) CClientPlayer* pPlayer; CScriptArgReader argStream(luaVM); argStream.ReadUserData(pPlayer); if (!argStream.HasErrors()) { // Grab his ping unsigned int uiPing = pPlayer->GetPing(); lua_pushnumber(luaVM, uiPing); return 1; } else m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage()); // Failed lua_pushboolean(luaVM, false); return 1; }
void CPlayerRPCs::SetPlayerNametagText ( CClientEntity* pSource, NetBitStreamInterface& bitStream ) { unsigned short usTextLength; if ( bitStream.Read ( usTextLength ) ) { CClientPlayer* pPlayer = m_pPlayerManager->Get ( pSource->GetID () ); if ( pPlayer ) { char* szText = NULL; if ( usTextLength > 0 ) { szText = new char [ usTextLength + 1 ]; szText [ usTextLength ] = NULL; if ( bitStream.Read ( szText, usTextLength ) ) { pPlayer->SetNametagText ( szText ); } delete [] szText; } else pPlayer->SetNametagText ( NULL ); } } }
void CFoo::Test ( const char* szString ) { CClientManager* pManager = g_pClientGame->GetManager (); CClientPlayer* pLocal = pManager->GetPlayerManager ()->GetLocalPlayer (); CClientVehicleManager* pVehicleManager = pManager->GetVehicleManager (); CVector vecLocal; pLocal->GetPosition ( vecLocal ); CClientCamera* pCamera = pManager->GetCamera (); // ChrML: Trying to reproduce mantis issue #2760 if ( stricmp ( szString, "2760" ) == 0 ) { vecLocal = CVector ( 0.0f, 0.0f, 5.0f ); for ( int i = 0; i < 20; i++ ) { vecLocal.fX += 5.0f; CClientPlayer* pPlayer = new CClientPlayer ( pManager, i + 50 ); pPlayer->SetDeadOnNetwork ( false ); pPlayer->SetModel ( 168 + i ); pPlayer->AttachTo ( NULL ); pPlayer->SetFrozen ( false ); pPlayer->RemoveAllWeapons (); pPlayer->Teleport ( vecLocal ); pPlayer->SetCameraRotation ( 0 ); pPlayer->ResetInterpolation (); pPlayer->SetMoveSpeed ( CVector () ); pPlayer->SetHealth ( 100.0f ); pPlayer->SetArmor ( 0 ); pPlayer->SetCurrentRotation ( 0 ); pPlayer->SetInterior ( 0 ); pPlayer->SetDimension ( 0 ); } pLocal->SetDeadOnNetwork ( false ); pLocal->SetModel ( 145 ); pLocal->AttachTo ( NULL ); pLocal->SetFrozen ( false ); pLocal->RemoveAllWeapons (); pLocal->Teleport ( vecLocal ); pLocal->SetCameraRotation ( 0 ); pLocal->ResetInterpolation (); pLocal->SetMoveSpeed ( CVector () ); pLocal->SetHealth ( 100.0f ); pLocal->SetArmor ( 0 ); pLocal->SetCurrentRotation ( 0 ); pLocal->SetInterior ( 0 ); pLocal->SetDimension ( 0 ); g_pClientGame->SetAllDimensions ( 0 ); // Reset return position so we can't warp back to where we were if local player g_pClientGame->GetNetAPI ()->ResetReturnPosition (); // Make sure the camera is normal pCamera->SetFocusToLocalPlayer (); pCamera->FadeIn ( 0.0f ); } // Player load crash else if ( stricmp ( szString, "2741" ) == 0 ) { bFoo_PlayerLimitCrash = true; } // else if ( strnicmp ( szString, "interp", 6 ) == 0 ) { if ( pVehicleManager->Count () > 0 ) { CClientVehicle* pVehicle = *pVehicleManager->IterBegin (); float fdelta = atof ( szString + 7 ); CVector vecT; pVehicle->GetPosition ( vecT ); vecT.fZ = fdelta; pVehicle->SetTargetPosition ( vecT, TICK_RATE ); g_pCore->ChatPrintf ( "Done %f", false, fdelta ); static_cast < CDeathmatchVehicle* > ( pVehicle )->SetIsSyncing ( false ); } } // else if ( strnicmp ( szString, "interr", 6 ) == 0 ) { if ( pVehicleManager->Count () > 0 ) { CClientVehicle* pVehicle = *pVehicleManager->IterBegin (); CVector vecT; pVehicle->GetRotationDegrees ( vecT ); vecT.fZ = atof ( szString + 7 ); pVehicle->SetTargetRotation ( vecT, TICK_RATE ); g_pCore->ChatPrintf ( "Done %f", false, atof ( szString + 7 ) ); static_cast < CDeathmatchVehicle* > ( pVehicle )->SetIsSyncing ( false ); } } else if ( stricmp ( szString, "choke" ) == 0 ) { g_pClientGame->GetLocalPlayer ()->SetChoking ( true ); } // else if ( strnicmp ( szString, "static", 6 ) == 0 ) { if ( pVehicleManager->Count () > 0 ) { CClientVehicle* pVehicle = *pVehicleManager->IterBegin (); pVehicle->GetGameVehicle ()->SetRemap ( atoi ( szString + 7 ) ); g_pCore->ChatPrintf ( "Set %i", false, atoi ( szString + 7 ) ); } } // else if ( strnicmp ( szString, "getmass", 7 ) == 0 ) { CClientVehicle* pVehicle = pLocal->GetOccupiedVehicle (); if ( pVehicle ) { g_pCore->ChatPrintf ( "Mass == %f", false, pVehicle->GetGameVehicle ()->GetMass () ); } } else if ( strnicmp ( szString, "setmass", 7 ) == 0 ) { CClientVehicle* pVehicle = pLocal->GetOccupiedVehicle (); if ( pVehicle ) { pVehicle->GetGameVehicle ()->SetMass ( atof ( szString + 8 ) ); g_pCore->ChatPrintf ( "Set mass to %f", false, pVehicle->GetGameVehicle ()->GetMass () ); } } // /* else if ( strnicmp ( szString, "setmm", 5 ) == 0 ) { CClientVehicle* pVehicle = pLocal->GetOccupiedVehicle (); if ( pVehicle ) { float fVal = atof ( szString + 6); szString += 4; float* fMass = (float*) atoi ( szString + 6 ); *fMass = fVal; g_pCore->ChatPrintf ( "Set %X to %f", false, fMass, fVal ); } } */ /* else if ( stricmp ( szString, "getmm" ) == 0 ) { CClientVehicle* pVehicle = pLocal->GetOccupiedVehicle (); if ( pVehicle ) { float* fMass = (float*) atoi ( szString ); g_pCore->ChatPrintf ( "Get %f", false, *fMass ); } } */ /* else if ( stricmp ( szString, "dump" ) == 0 ) { FILE* poo = fopen ( "vehs.txt", "w+" ); if ( poo ) { tHandlingData* pHandling = (tHandlingData*) 0xC2B9E0; unsigned int uiIndex = 0; for ( ; uiIndex < 219; uiIndex++ ) { fprintf ( poo, "\n\n\n\n####### VEHICLE ID %u #######\n", uiIndex ); fprintf ( poo, "fMass = %f\n", pHandling->fMass ); fprintf ( poo, "fUnknown1 = %f\n", pHandling->fUnknown1 ); fprintf ( poo, "fTurnMass = %f\n", pHandling->fTurnMass ); fprintf ( poo, "fDragCoeff = %f\n", pHandling->fDragCoeff ); fprintf ( poo, "vecCenterOfMass = %f, %f, %f\n", pHandling->vecCenterOfMass.fX, pHandling->vecCenterOfMass.fY, pHandling->vecCenterOfMass.fZ ); fprintf ( poo, "uiPercentSubmerged = %u\n", pHandling->uiPercentSubmerged ); fprintf ( poo, "fUnknown2 = %f\n", pHandling->fUnknown2 ); fprintf ( poo, "fTractionMultiplier = %f\n", pHandling->fTractionMultiplier ); fprintf ( poo, "Transmission.fUnknown [0] = %f\n", pHandling->Transmission.fUnknown [0] ); fprintf ( poo, "Transmission.fUnknown [1] = %f\n", pHandling->Transmission.fUnknown [1] ); fprintf ( poo, "Transmission.fUnknown [2] = %f\n", pHandling->Transmission.fUnknown [2] ); fprintf ( poo, "Transmission.fUnknown [3] = %f\n", pHandling->Transmission.fUnknown [3] ); fprintf ( poo, "Transmission.fUnknown [4] = %f\n", pHandling->Transmission.fUnknown [4] ); fprintf ( poo, "Transmission.fUnknown [5] = %f\n", pHandling->Transmission.fUnknown [5] ); fprintf ( poo, "Transmission.fUnknown [6] = %f\n", pHandling->Transmission.fUnknown [6] ); fprintf ( poo, "Transmission.fUnknown [7] = %f\n", pHandling->Transmission.fUnknown [7] ); fprintf ( poo, "Transmission.fUnknown [8] = %f\n", pHandling->Transmission.fUnknown [8] ); fprintf ( poo, "Transmission.fUnknown [9] = %f\n", pHandling->Transmission.fUnknown [9] ); fprintf ( poo, "Transmission.fUnknown [10] = %f\n", pHandling->Transmission.fUnknown [10] ); fprintf ( poo, "Transmission.fUnknown [11] = %f\n", pHandling->Transmission.fUnknown [11] ); fprintf ( poo, "Transmission.fUnknown [12] = %f\n", pHandling->Transmission.fUnknown [12] ); fprintf ( poo, "Transmission.fUnknown [13] = %f\n", pHandling->Transmission.fUnknown [13] ); fprintf ( poo, "Transmission.fUnknown [14] = %f\n", pHandling->Transmission.fUnknown [14] ); fprintf ( poo, "Transmission.fUnknown [15] = %f\n", pHandling->Transmission.fUnknown [15] ); fprintf ( poo, "Transmission.fUnknown [16] = %f\n", pHandling->Transmission.fUnknown [16] ); fprintf ( poo, "Transmission.fUnknown [17] = %f\n", pHandling->Transmission.fUnknown [17] ); fprintf ( poo, "Transmission.ucDriveType = %c\n", pHandling->Transmission.ucDriveType ); fprintf ( poo, "Transmission.ucEngineType = %c\n", pHandling->Transmission.ucEngineType ); fprintf ( poo, "Transmission.ucNumberOfGears = %u\n", pHandling->Transmission.ucNumberOfGears ); fprintf ( poo, "Transmission.ucUnknown = %u\n", pHandling->Transmission.ucUnknown ); fprintf ( poo, "Transmission.uiHandlingFlags = 0x%X\n", pHandling->Transmission.uiHandlingFlags ); fprintf ( poo, "Transmission.fEngineAccelleration = %f\n", pHandling->Transmission.fEngineAccelleration ); fprintf ( poo, "Transmission.fEngineInertia = %f\n", pHandling->Transmission.fEngineInertia ); fprintf ( poo, "Transmission.fMaxVelocity = %f\n", pHandling->Transmission.fMaxVelocity ); fprintf ( poo, "Transmission.fUnknown2 [0] = %f\n", pHandling->Transmission.fUnknown2 [0] ); fprintf ( poo, "Transmission.fUnknown2 [1] = %f\n", pHandling->Transmission.fUnknown2 [1] ); fprintf ( poo, "Transmission.fUnknown2 [2] = %f\n", pHandling->Transmission.fUnknown2 [2] ); fprintf ( poo, "fBrakeDecelleration = %f\n", pHandling->fBrakeDecelleration ); fprintf ( poo, "fBrakeBias = %f\n", pHandling->fBrakeBias ); fprintf ( poo, "bABS = %u\n", pHandling->bABS ); fprintf ( poo, "fSteeringLock = %f\n", pHandling->fSteeringLock ); fprintf ( poo, "fTractionLoss = %f\n", pHandling->fTractionLoss ); fprintf ( poo, "fTractionBias = %f\n", pHandling->fTractionBias ); fprintf ( poo, "fSuspensionForceLevel = %f\n", pHandling->fSuspensionForceLevel ); fprintf ( poo, "fSuspensionDamping = %f\n", pHandling->fSuspensionDamping ); fprintf ( poo, "fSuspensionHighSpdDamping = %f\n", pHandling->fSuspensionHighSpdDamping ); fprintf ( poo, "fSuspensionUpperLimit = %f\n", pHandling->fSuspensionUpperLimit ); fprintf ( poo, "fSuspensionLowerLimit = %f\n", pHandling->fSuspensionLowerLimit ); fprintf ( poo, "fSuspensionFrontRearBias = %f\n", pHandling->fSuspensionFrontRearBias ); fprintf ( poo, "fSuspensionAntidiveMultiplier = %f\n", pHandling->fSuspensionAntidiveMultiplier ); fprintf ( poo, "fCollisionDamageMultiplier = %f\n", pHandling->fCollisionDamageMultiplier ); fprintf ( poo, "uiModelFlags = %X\n", pHandling->uiModelFlags ); fprintf ( poo, "uiHandlingFlags = %X\n", pHandling->uiHandlingFlags ); fprintf ( poo, "fSeatOffsetDistance = %f\n", pHandling->fSeatOffsetDistance ); fprintf ( poo, "uiMonetary = %u\n", pHandling->uiMonetary ); fprintf ( poo, "ucHeadLight = 0x%X\n", pHandling->ucHeadLight ); fprintf ( poo, "ucTailLight = 0x%X\n", pHandling->ucTailLight ); fprintf ( poo, "ucAnimGroup = 0x%X\n", pHandling->ucAnimGroup ); fprintf ( poo, "ucUnused = 0x%X\n", pHandling->ucUnused ); fprintf ( poo, "iUnknown7 = %f, %X\n", pHandling->iUnknown7, pHandling->iUnknown7 ); pHandling += 1; } g_pCore->ChatPrintf ( "Dumped", false ); fclose ( poo ); } } */ else if ( strnicmp ( szString, "moveug", 6 ) == 0 ) { if ( pVehicleManager->Count () > 0 ) { CClientVehicle* pVehicle = *pVehicleManager->IterBegin (); /* CClientPed* pModel = pVehicle->GetOccupant ( 0 ); if ( !pModel ) { CClientPlayer* pPlayer = new CClientPlayer ( g_pClientGame->GetManager (), 50 ); pModel = pPlayer->LoadModel ( 0 ); pModel->WarpIntoVehicle ( pVehicle ); } */ pVehicle->RemoveTargetPosition (); pVehicle->RemoveTargetRotation (); CVector vecT; pVehicle->GetPosition ( vecT ); vecT.fZ = atof ( szString + 7 ); pVehicle->SetPosition ( vecT ); g_pCore->ChatPrintf ( "Done", false ); } } else if ( strnicmp ( szString, "nocol", 5 ) == 0 ) { if ( pVehicleManager->Count () > 0 ) { CClientVehicle* pVehicle = *pVehicleManager->IterBegin (); pVehicle->SetCollisionEnabled ( false ); g_pCore->ChatPrintf ( "Done", false ); } } else if ( stricmp ( szString, "resetdamage" ) == 0 ) { g_pClientGame->GetPlayerManager ()->GetLocalPlayer ()->GetGamePlayer ()->ResetLastDamage (); } else if ( strnicmp ( szString, "fuckveh", 7 ) == 0 ) { CClientVehicle* pVehicle = pLocal->GetOccupiedVehicle (); if ( pVehicle ) { pVehicle->SetTargetPosition ( CVector ( 0, 0, 0 ), TICK_RATE ); pVehicle->SetTargetRotation ( CVector ( 0, 0, 0 ), TICK_RATE ); g_pCore->ChatPrintf ( "Done", false ); } } else if ( stricmp ( szString, "ped" ) == 0 ) { CClientPed* pPed = new CClientPed ( g_pClientGame->GetManager (), INVALID_ELEMENT_ID, 9 ); vecLocal.fX += 5.0f; pPed->SetPosition ( vecLocal ); } else if ( strnicmp ( szString, "callit", 6 ) == 0 ) { FILE* pFile = fopen ( "C:/dump.txt", "w+" ); for ( int i = 0; i < 400; i++ ) { int iIndex = i; const char* szName = NULL; _asm { mov eax, 0x4D3A30 push iIndex call eax mov szName, eax add esp, 4 } fprintf ( pFile, "%i: %s\n", iIndex, szName ); } fclose ( pFile ); } else if ( strnicmp ( szString, "veh", 3 ) == 0 ) { int i = 600; FILE* p = fopen ( "C:/dump.txt", "w+" ); for ( int a = 0; a < 13; a++ ) { g_pGame->GetModelInfo ( i )->AddRef ( true ); CVehicle* pVehicle = g_pGame->GetPools ()->AddVehicle ( (eVehicleTypes)i ); DWORD* dw2 = (DWORD*)(((DWORD)pVehicle->GetVehicleInterface ()) + 0xE1 * 4 ); DWORD dw = *dw2; dw = dw + 4; dw = dw - 0xC2B9E0; dw = dw / 224; fprintf ( p, "Array [%u] = %u;\n", i, dw ); g_pGame->GetPools ()->RemoveVehicle ( pVehicle ); fflush ( p ); g_pGame->GetModelInfo ( i )->RemoveRef ( ); i++; } fclose ( p ); } else if ( strnicmp ( szString, "groups", 6 ) == 0 ) { FILE* pFile = fopen ( "C:/dump.txt", "w+" ); int i = 0; for ( ; i < 139; i++ ) { fprintf ( pFile, "==%s [%s] (%i)==\n", pGroups [i].szGroupName, pGroups [i].szSomething, i ); int i2 = 0; for ( ; i2 < pGroups [i].ulAnimCount; i2++ ) { const char* szAnimName = pGroups [i].pAnimNames [i2]; if ( szAnimName [0] ) { fprintf ( pFile, "''%i'': %s<br>\n", i2, szAnimName ); } } fprintf ( pFile, "\n" ); } fclose ( pFile ); } else if ( strnicmp ( szString, "getshot", 7 ) == 0 ) { if ( pLocal->GetGamePlayer ()->GetCanBeShotInVehicle () ) { g_pCore->ChatEcho ( "true" ); } else { g_pCore->ChatEcho ( "false" ); } } else if ( strnicmp ( szString, "gettest", 7 ) == 0 ) { if ( pLocal->GetGamePlayer ()->GetTestForShotInVehicle () ) { g_pCore->ChatEcho ( "true" ); } else { g_pCore->ChatEcho ( "false" ); } } else if ( strnicmp ( szString, "setshot", 7 ) == 0 ) { pLocal->GetGamePlayer ()->SetCanBeShotInVehicle ( true ); } else if ( strnicmp ( szString, "settest", 8 ) == 0 ) { pLocal->GetGamePlayer ()->SetTestForShotInVehicle ( true ); } else if ( stricmp ( szString, "applytest" ) == 0 ) { DWORD oldProt, oldProt2; VirtualProtect((LPVOID)0x5E8FFB,6,PAGE_EXECUTE_READWRITE,&oldProt); *(unsigned char*) (0x5E8FFB ) = 0x90; *(unsigned char*) (0x5E8FFC ) = 0x90; *(unsigned char*) (0x5E8FFD ) = 0x90; *(unsigned char*) (0x5E8FFE ) = 0x90; *(unsigned char*) (0x5E8FFF ) = 0x90; *(unsigned char*) (0x5E9000 ) = 0x90; VirtualProtect((LPVOID)0x5E8FFB,6,oldProt,&oldProt2); } }
void CClientStreamer::Restream ( bool bMovedFar ) { // Limit distance stream in/out rate // Vehicles might have to ignore this to reduce blocking loads elsewhere. int iMaxOut = 6; int iMaxIn = 6; if ( bMovedFar ) { iMaxOut = 1000; iMaxIn = 1000; } // Do we have any elements waiting to be streamed out? while ( !m_ToStreamOut.empty () ) { CClientStreamElement* pElement = m_ToStreamOut.front (); // Make sure we have no stream-references if ( pElement->GetTotalStreamReferences () == 0 ) { // Stream out 1 of them per frame pElement->InternalStreamOut (); iMaxOut--; } m_ToStreamOut.remove ( pElement ); if ( iMaxOut <= 0 ) break; } static std::vector < CClientStreamElement* > ClosestStreamedOutList; static std::vector < CClientStreamElement* > FurthestStreamedInList; ClosestStreamedOutList.clear(); FurthestStreamedInList.clear(); bool bReachedLimit = ReachedLimit (); // Loop through our active elements list (they should be ordered closest to furthest) list < CClientStreamElement* > ::iterator iter = m_ActiveElements.begin (); for ( ; iter != m_ActiveElements.end (); iter++ ) { CClientStreamElement* pElement = *iter; float fElementDistanceExp = pElement->GetExpDistance (); // Is this element streamed in? if ( pElement->IsStreamedIn () ) { if ( IS_VEHICLE ( pElement ) ) { CClientVehicle* pVehicle = DynamicCast < CClientVehicle > ( pElement ); if ( pVehicle ) { if ( pVehicle->GetOccupant ( ) && IS_PLAYER ( pVehicle->GetOccupant ( ) ) ) { CClientPlayer* pPlayer = DynamicCast < CClientPlayer > ( pVehicle->GetOccupant ( ) ); if ( pPlayer->GetLastPuresyncType ( ) == PURESYNC_TYPE_LIGHTSYNC ) { // if the last packet was ls he shouldn't be streamed in m_ToStreamOut.push_back ( pElement ); } } // Is this a trailer? if ( pVehicle->GetTowedByVehicle ( ) != NULL ) { // Don't stream it out (this is handled by the towing vehicle) continue; } } } if ( IS_PLAYER ( pElement ) ) { CClientPlayer* pPlayer = DynamicCast < CClientPlayer > ( pElement ); if ( pPlayer->GetLastPuresyncType ( ) == PURESYNC_TYPE_LIGHTSYNC ) { // if the last packet was ls he isn't/shouldn't be streamed in m_ToStreamOut.push_back ( pElement ); } } // Too far away? Use the threshold so we won't flicker load it if it's on the border moving. if ( fElementDistanceExp > m_fMaxDistanceThreshold ) { // Unstream it now? if ( iMaxOut > 0 ) { // Make sure we have no stream-references if ( pElement->GetTotalStreamReferences () == 0 ) { // Stream out now pElement->InternalStreamOut (); iMaxOut--; } m_ToStreamOut.remove ( pElement ); } else { // or later m_ToStreamOut.push_back ( pElement ); } } else { FurthestStreamedInList.push_back( pElement ); } } else { // Same dimension as us? if ( pElement->GetDimension () == m_usDimension ) { // Too far away? Stop here. if ( fElementDistanceExp > m_fMaxDistanceExp ) continue; if ( IS_VEHICLE ( pElement ) ) { CClientVehicle* pVehicle = DynamicCast < CClientVehicle > ( pElement ); if ( pVehicle && pVehicle->GetOccupant ( ) && IS_PLAYER ( pVehicle->GetOccupant ( ) )) { CClientPlayer* pPlayer = DynamicCast < CClientPlayer > ( pVehicle->GetOccupant ( ) ); if ( pPlayer->GetLastPuresyncType ( ) == PURESYNC_TYPE_LIGHTSYNC ) { // if the last packet was ls he isn't streaming in soon. continue; } } if ( pVehicle && pVehicle->GetTowedByVehicle ( ) ) { // Streaming in of towed vehicles is done in CClientVehicle::StreamIn by the towing vehicle continue; } } if ( IS_PLAYER ( pElement ) ) { CClientPlayer* pPlayer = DynamicCast < CClientPlayer > ( pElement ); if ( pPlayer->GetLastPuresyncType ( ) == PURESYNC_TYPE_LIGHTSYNC ) { // if the last packet was ls he isn't streaming in soon. continue; } } // If attached and attached-to is streamed out, don't consider for streaming in CClientStreamElement* pAttachedTo = DynamicCast< CClientStreamElement >( pElement->GetAttachedTo() ); if ( pAttachedTo && !pAttachedTo->IsStreamedIn() ) { // ...unless attached to low LOD version CClientObject* pAttachedToObject = DynamicCast < CClientObject > ( pAttachedTo ); CClientObject* pObject = DynamicCast < CClientObject > ( pElement ); if ( !pObject || !pAttachedToObject || pObject->IsLowLod () == pAttachedToObject->IsLowLod () ) continue; } // Not room to stream in more elements? if ( bReachedLimit ) { // Add to the list that might be streamed in during the final phase if ( (int)ClosestStreamedOutList.size() < iMaxIn ) // (only add if there is a chance it will be used) ClosestStreamedOutList.push_back( pElement ); } else { // Stream in the new element. Don't do it instantly unless moved from far away. pElement->InternalStreamIn ( bMovedFar ); bReachedLimit = ReachedLimit (); if ( !bReachedLimit ) { iMaxIn--; if ( iMaxIn <= 0 ) break; } } } } } // Complex code of doom: // ClosestStreamedOutList is {nearest to furthest} list of streamed out elements within streaming distance // FurthestStreamedInList is {nearest to furthest} list of streamed in elements if ( bReachedLimit ) { // Check 'furthest streamed in' against 'closest streamed out' to see if the state can be swapped int iFurthestStreamedInIndex = FurthestStreamedInList.size() - 1; uint uiClosestStreamedOutIndex = 0; for( uint i = 0 ; i < 10 ; i++ ) { // Check limits for this frame if ( iMaxIn <= 0 || iMaxOut <= 0 ) break; // Check indicies are valid if ( iFurthestStreamedInIndex < 0 ) break; if ( uiClosestStreamedOutIndex >= ClosestStreamedOutList.size() ) break; // See if ClosestStreamedOut is nearer than FurthestStreamedIn CClientStreamElement* pFurthestStreamedIn = FurthestStreamedInList[ iFurthestStreamedInIndex ]; CClientStreamElement* pClosestStreamedOut = ClosestStreamedOutList[ uiClosestStreamedOutIndex ]; if ( pClosestStreamedOut->GetExpDistance () >= pFurthestStreamedIn->GetExpDistance () ) break; // Stream out FurthestStreamedIn candidate if possible if ( pFurthestStreamedIn->GetTotalStreamReferences () == 0 ) { // Stream out now pFurthestStreamedIn->InternalStreamOut (); iMaxOut--; } m_ToStreamOut.remove ( pFurthestStreamedIn ); iFurthestStreamedInIndex--; // Always advance to the next candidate // Stream in ClosestStreamedOut candidate if possible if ( !ReachedLimit () ) { // Stream in the new element. No need to do it instantly unless moved from far away. pClosestStreamedOut->InternalStreamIn ( bMovedFar ); iMaxIn--; uiClosestStreamedOutIndex++; } } } }
CClientPlayer::CClientPlayer ( CClientManager* pManager, ElementID ID, bool bIsLocalPlayer ) : ClassInit ( this ), CClientPed ( pManager, 0, ID, bIsLocalPlayer ) { // Initialize m_pManager = pManager; m_bIsLocalPlayer = bIsLocalPlayer; SetTypeName ( "player" ); m_bNametagColorOverridden = false; m_uiPing = 0; m_usLatency = 0; m_uiPlayerSyncCount = 0; m_uiKeySyncCount = 0; m_uiVehicleSyncCount = 0; m_ulLastPuresyncTime = 0; m_bHasConnectionTrouble = false; m_bForce = false; m_bDoExtrapolatingAim = false; m_bNetworkDead = false; m_voice = NULL; // If it's the local player, add the model if ( m_bIsLocalPlayer ) { // Set us as the local player in the player manager if ( !pManager->GetPlayerManager ()->GetLocalPlayer () ) { pManager->GetPlayerManager ()->SetLocalPlayer ( this ); } CClientPlayer * pLocalPlayer = this; // Enable voice playback for local player if ( pLocalPlayer->GetVoice() == NULL ) { //If voice is enabled CClientPlayerVoice * pVoice = new CClientPlayerVoice ( this, g_pClientGame->GetVoiceRecorder() ); pLocalPlayer->SetPlayerVoice ( pVoice ); } } else { // Enable weapon processing for players m_remoteDataStorage->SetProcessPlayerWeapon ( true ); // Enable voice playback for remote players if ( g_pClientGame->GetVoiceRecorder()->IsEnabled() ) //If voice is enabled m_voice = new CClientPlayerVoice ( this, g_pClientGame->GetVoiceRecorder() ); } // Set all our default stats m_pTeam = NULL; m_bNametagShowing = true; m_ucNametagColorR = 255; m_ucNametagColorG = 255; m_ucNametagColorB = 255; m_ulLastNametagShow = 0; SetNametagText ( m_strNick ); // Add us to the player list m_pManager->GetPlayerManager ()->AddToList ( this ); #ifdef MTA_DEBUG m_bShowingWepdata = false; #endif m_LastPuresyncType = PURESYNC_TYPE_NONE; }
bool CClientExplosionManager::Hook_ExplosionCreation ( CEntity* pGameExplodingEntity, CEntity* pGameCreator, const CVector& vecPosition, eExplosionType explosionType ) { CClientPlayer * pLocalPlayer = m_pManager->GetPlayerManager ()->GetLocalPlayer (); // Grab the entity responsible CClientEntity * pResponsible = NULL; CEntity* pResponsibleGameEntity = ( pGameExplodingEntity ) ? pGameExplodingEntity : pGameCreator; if ( pResponsibleGameEntity ) pResponsible = m_pManager->FindEntity ( pResponsibleGameEntity, false ); eWeaponType explosionWeaponType; switch ( explosionType ) { case EXP_TYPE_GRENADE: { // Grenade type explosions from vehicles should only be freefall bombs // TODO: need a way to check if its a freefall bomb if creator is a ped if ( pGameCreator && pGameCreator->GetEntityType () == ENTITY_TYPE_VEHICLE ) explosionWeaponType = WEAPONTYPE_FREEFALL_BOMB; else explosionWeaponType = WEAPONTYPE_GRENADE; break; } case EXP_TYPE_MOLOTOV: explosionWeaponType = WEAPONTYPE_MOLOTOV; break; case EXP_TYPE_ROCKET: case EXP_TYPE_ROCKET_WEAK: explosionWeaponType = WEAPONTYPE_ROCKET; break; case EXP_TYPE_TANK_GRENADE: explosionWeaponType = WEAPONTYPE_TANK_GRENADE; break; default: explosionWeaponType = WEAPONTYPE_EXPLOSION; break; } // Got a responsible entity? if ( pResponsible ) { // Is the local player responsible for this? bool bLocal = ( ( pResponsible == pLocalPlayer ) || ( pResponsible == pLocalPlayer->GetOccupiedVehicle () ) || ( g_pClientGame->GetUnoccupiedVehicleSync ()->Exists ( static_cast < CDeathmatchVehicle * > ( pResponsible ) ) ) ); if ( bLocal ) { CClientEntity * pOriginSource = NULL; // Is this an exploding vehicle? if ( pGameExplodingEntity && pGameExplodingEntity->GetEntityType () == ENTITY_TYPE_VEHICLE ) { // Set our origin-source to the vehicle pOriginSource = m_pManager->FindEntity ( pGameExplodingEntity, false ); } // If theres other players, sync it relative to the closest (lag compensation) else if ( m_pManager->GetPlayerManager ()->Count () > 1 ) { switch ( explosionWeaponType ) { case WEAPONTYPE_ROCKET: case WEAPONTYPE_ROCKET_HS: { CClientPlayer * pPlayer = g_pClientGame->GetClosestRemotePlayer ( vecPosition, 200.0f ); if ( pPlayer ) { pOriginSource = pPlayer; } break; } } } // Request a new explosion g_pClientGame->SendExplosionSync ( vecPosition, explosionType, pOriginSource ); } } // All explosions are handled server side return false; }
void CPlayerRPCs::RemovePlayerNametagColor ( CClientEntity* pSource, NetBitStreamInterface& bitStream ) { CClientPlayer* pPlayer = m_pPlayerManager->Get ( pSource->GetID () ); if ( pPlayer ) pPlayer->RemoveNametagOverrideColor (); }