SColor CVehicleColor::GetRGBFromPaletteIndex ( uchar ucColor ) { ucColor = Min < uchar > ( ucColor, static_cast < uint > ( NUMELMS( paletteColorTable8 ) / 4 ) ); uchar r = paletteColorTable8[ ucColor * 4 ]; uchar g = paletteColorTable8[ ucColor * 4 + 1 ]; uchar b = paletteColorTable8[ ucColor * 4 + 2 ]; return SColorRGBA ( r, g, b, 0 ); }
CClient3DMarker::CClient3DMarker(CClientMarker* pThis) { // Init m_pThis = pThis; m_bMarkerStreamedIn = false; m_bVisible = true; m_Color = SColorRGBA(255, 0, 0, 128); m_fSize = 4.0f; m_dwType = MARKER3D_CYLINDER2; m_pMarker = NULL; m_ulIdentifier = (DWORD)this; }
CRadarArea::CRadarArea ( CRadarAreaManager* pRadarAreaManager, CElement* pParent, CXMLNode* pNode ) : CPerPlayerEntity ( pParent, pNode ) { // Init m_iType = CElement::RADAR_AREA; SetTypeName ( "radararea" ); m_pRadarAreaManager = pRadarAreaManager; m_Color = SColorRGBA ( 255, 255, 255, 255 ); m_bIsFlashing = false; // Pop an id for us and add us to the manger's list pRadarAreaManager->AddToList ( this ); }
bool CRadarArea::ReadSpecialData ( void ) { // Grab the "posX" data if ( !GetCustomDataFloat ( "posX", m_vecPosition.fX, true ) ) { CLogger::ErrorPrintf ( "Bad/missing 'posX' attribute in <radararea> (line %u)\n", m_uiLine ); return false; } // Grab the "posY" data if ( !GetCustomDataFloat ( "posY", m_vecPosition.fY, true ) ) { CLogger::ErrorPrintf ( "Bad/missing 'posY' attribute in <radararea> (line %u)\n", m_uiLine ); return false; } // Grab the "sizeX" data if ( !GetCustomDataFloat ( "sizeX", m_vecSize.fX, true ) ) { CLogger::ErrorPrintf ( "Bad/missing 'sizeX' attribute in <radararea> (line %u)\n", m_uiLine ); return false; } // Grab the "sizeY" data if ( !GetCustomDataFloat ( "sizeY", m_vecSize.fY, true ) ) { CLogger::ErrorPrintf ( "Bad/missing 'sizeY' attribute in <radararea> (line %u)\n", m_uiLine ); return false; } // Grab the "color" data char szColor [64]; if ( GetCustomDataString ( "color", szColor, 64, true ) ) { // Convert it to RGBA if ( !XMLColorToInt ( szColor, m_Color.R, m_Color.G, m_Color.B, m_Color.A ) ) { CLogger::ErrorPrintf ( "Bad 'color' value specified in <radararea> (line %u)\n", m_uiLine ); return false; } } else { m_Color = SColorRGBA ( 255, 0, 0, 255 ); } int iTemp; if ( GetCustomDataInt ( "dimension", iTemp, true ) ) m_usDimension = static_cast < unsigned short > ( iTemp ); return true; }
CClientCheckpoint::CClientCheckpoint ( CClientMarker * pThis ) { // Init m_pThis = pThis; m_pCheckpoint = NULL; m_bStreamedIn = false; m_bVisible = true; m_uiIcon = CClientCheckpoint::ICON_NONE; m_Color = SColorRGBA ( 255, 0, 0, 255 ); m_fSize = 4.0f; m_dwType = CHECKPOINT_EMPTYTUBE; m_vecDirection.fX = 1.0f; m_bHasTarget = false; }
CClientCorona::CClientCorona ( CClientMarker * pThis ) { CClientEntityRefManager::AddEntityRefs ( ENTITY_REF_DEBUG ( this, "CClientCorona" ), &m_pThis, NULL ); // Init m_pThis = pThis; m_bStreamedIn = false; m_bVisible = true; m_Color = SColorRGBA ( 255, 0, 0, 255 ); m_fSize = 4.0f; m_pCoronas = g_pGame->GetCoronas (); // Pick an unique identifier static unsigned long ulIdentifier = 0xFFFFFFFF; m_ulIdentifier = --ulIdentifier; }
CClientCheckpoint::CClientCheckpoint ( CClientMarker * pThis ) { CClientEntityRefManager::AddEntityRefs ( ENTITY_REF_DEBUG ( this, "CClientCheckpoint" ), &m_pThis, NULL ); // Init m_pThis = pThis; m_pCheckpoint = NULL; m_bStreamedIn = false; m_bVisible = true; m_uiIcon = CClientCheckpoint::ICON_NONE; m_Color = SColorRGBA ( 255, 0, 0, 255 ); m_fSize = 4.0f; m_dwType = CHECKPOINT_EMPTYTUBE; m_vecDirection.fX = 1.0f; m_bHasTarget = false; }
CClientRadarArea::CClientRadarArea ( class CClientManager* pManager, ElementID ID ) : ClassInit ( this ), CClientEntity ( ID ) { // Init m_pManager = pManager; m_pRadarAreaManager = pManager->GetRadarAreaManager (); m_Color = SColorRGBA ( 255, 255, 255, 255 ); m_bFlashing = false; m_ulFlashCycleStart = 0; m_bStreamedIn = true; SetTypeName ( "radararea" ); // Make sure we're visible/invisible according to our dimension RelateDimension ( m_pRadarAreaManager->GetDimension () ); // Add us to the manager's list m_pRadarAreaManager->AddToList ( this ); }
/////////////////////////////////////////////////////////////// // // CGraphStats::Draw // // // /////////////////////////////////////////////////////////////// void CGraphStats::Draw(void) { if (!m_bEnabled) return; CGraphicsInterface* pGraphics = g_pCore->GetGraphics(); uint uiViewportHeight = pGraphics->GetViewportHeight(); uint uiOriginX = 10; uint uiOriginY = std::min<int>(500, uiViewportHeight - 10); uint uiSizeX = GRAPHSTAT_HISTORY_SIZE; uint uiSizeY = 150; uint uiRangeY = 100; // 100ms float fLineScale = 1 / 1000.f / uiRangeY * uiSizeY; float fHalfLineHeight = pGraphics->GetDXFontHeight() / 2; // Backgroung box pGraphics->DrawRectQueued(uiOriginX, uiOriginY - uiSizeY, uiSizeX, uiSizeY, SColorRGBA(0, 0, 0, 128), true); // Draw data line. for (const auto& dataLine : m_LineList) { const SGraphStatLine& line = dataLine.second; int iDataPos = line.iDataPos; int iDataPosPrev = iDataPos; for (int i = uiSizeX - 1; i > 0; i--) { float fY0 = line.dataHistory[iDataPos] * fLineScale; float fY1 = line.dataHistory[iDataPosPrev] * fLineScale; iDataPosPrev = iDataPos; iDataPos--; if (iDataPos == -1) iDataPos = GRAPHSTAT_HISTORY_SIZE - 1; pGraphics->DrawLineQueued(uiOriginX + i - 1, uiOriginY - fY0, uiOriginX + i, uiOriginY - fY1, 1, line.color, true); } float fX = uiOriginX + uiSizeX + 2; float fY = uiOriginY - line.dataHistory[line.iDataPos] * fLineScale - fHalfLineHeight; pGraphics->DrawStringQueued(fX, fY, fX, fY, line.color, line.strName.c_str(), 1.0f, 1.0f, DT_NOCLIP, nullptr, true); } }
/////////////////////////////////////////////////////////////// // // CGraphStats::Draw // // // /////////////////////////////////////////////////////////////// void CGraphStats::Draw ( void ) { if ( !m_bEnabled ) return; CGraphicsInterface* pGraphics = g_pCore->GetGraphics(); uint uiViewportHeight = pGraphics->GetViewportHeight(); uint uiOriginX = 10; uint uiOriginY = Min < int > ( 500, uiViewportHeight - 10 ); uint uiSizeX = GRAPHSTAT_HISTORY_SIZE; uint uiSizeY = 150; uint uiRangeY = 100; // 100ms float fLineScale = 1/1000.f / uiRangeY * uiSizeY; // Backgrounf box pGraphics->DrawRectQueued( uiOriginX, uiOriginY - uiSizeY, uiSizeX, uiSizeY, SColorRGBA( 0, 0, 0, 128 ), true ); // Draw data line. for ( std::map < SString, SGraphStatLine >::iterator iter = m_LineList.begin() ; iter != m_LineList.end() ; ++iter ) { SGraphStatLine& line = iter->second; int iDataPos = line.iDataPos; int iDataPosPrev = iDataPos; if ( iDataPos == -1 ) iDataPos = GRAPHSTAT_HISTORY_SIZE - 1; for ( int i = uiSizeX - 1 ; i > 0 ; i-- ) { float fY0 = line.dataHistory[ iDataPos ] * fLineScale; float fY1 = line.dataHistory[ iDataPosPrev ] * fLineScale; iDataPosPrev = iDataPos; iDataPos--; if ( iDataPos == -1 ) iDataPos = GRAPHSTAT_HISTORY_SIZE - 1; pGraphics->DrawLineQueued( uiOriginX + i - 1, uiOriginY - fY0, uiOriginX + i, uiOriginY - fY1, 1, line.color, true ); } } }
CMarker::CMarker ( CMarkerManager* pMarkerManager, CColManager* pColManager, CElement* pParent, CXMLNode* pNode ) : CPerPlayerEntity ( pParent, pNode ) { // Init m_pMarkerManager = pMarkerManager; m_pColManager = pColManager; m_iType = CElement::MARKER; SetTypeName ( "marker" ); m_ucType = TYPE_CHECKPOINT; m_fSize = 4.0f; m_Color = SColorRGBA ( 255, 255, 255, 255 ); m_bHasTarget = false; m_ucIcon = ICON_NONE; // Create our collision object m_pCollision = new CColCircle ( pColManager, NULL, m_vecPosition, m_fSize, NULL, true ); m_pCollision->SetCallback ( this ); m_pCollision->SetAutoCallEvent ( false ); // Add us to the marker manager pMarkerManager->AddToList ( this ); UpdateSpatialData (); }
CVehicle::CVehicle ( CVehicleManager* pVehicleManager, CElement* pParent, CXMLNode* pNode, unsigned short usModel ) : CElement ( pParent, pNode ) { // Init m_pVehicleManager = pVehicleManager; m_usModel = usModel; m_pUpgrades = new CVehicleUpgrades ( this ); m_iType = CElement::VEHICLE; SetTypeName ( "vehicle" ); m_eVehicleType = CVehicleManager::GetVehicleType ( m_usModel ); m_fHealth = DEFAULT_VEHICLE_HEALTH; m_ulHealthChangeTime = 0; m_ulBlowTime = 0; m_ulIdleTime = GetTickCount (); m_fTurretPositionX = 0; m_fTurretPositionY = 0; m_bSirenActive = false; m_bLandingGearDown = true; m_usAdjustableProperty = 0; m_bIsFrozen = false; m_bUnoccupiedSyncable = true; m_pSyncer = NULL; GetInitialDoorStates ( m_ucDoorStates ); memset ( m_ucWheelStates, 0, sizeof ( m_ucWheelStates ) ); memset ( m_ucPanelStates, 0, sizeof ( m_ucPanelStates ) ); memset ( m_ucLightStates, 0, sizeof ( m_ucLightStates ) ); m_ucOverrideLights = 0; m_pTowedVehicle = NULL; m_pTowedByVehicle = NULL; m_ucPaintjob = 3; m_ucMaxPassengersOverride = VEHICLE_PASSENGERS_UNDEFINED; m_bRespawnInfoChanged = false; m_fRespawnHealth = DEFAULT_VEHICLE_HEALTH; m_bRespawnEnabled = false; m_ulRespawnTime = 10000; m_ulIdleRespawnTime = 60000; m_bEngineOn = false; m_bLocked = false; m_bDoorsUndamageable = false; m_bDamageProof = false; m_bGunsEnabled = false; m_bFuelTankExplodable = false; m_bOnGround = true; m_bSmokeTrail = false; m_ucAlpha = 255; m_pJackingPlayer = NULL; m_bInWater = false; m_bDerailed = false; m_bIsDerailable = true; m_bTaxiLightState = false; m_bTrainDirection = true; m_HeadLightColor = SColorRGBA ( 255, 255, 255, 255 ); m_bHeliSearchLightVisible = false; // Initialize the occupied Players for ( int i = 0; i < MAX_VEHICLE_SEATS; i++ ) { m_pOccupants [i] = NULL; } // Add us to the vehicle manager pVehicleManager->AddToList ( this ); // Randomize our color RandomizeColor (); // Generate a random reg plate GenerateRegPlate (); }
/////////////////////////////////////////////////////////////// // // CGraphStats::AddTimingPoint // // // /////////////////////////////////////////////////////////////// void CGraphStats::AddTimingPoint(const char* szName) { if (!IsEnabled()) return; // Start of next frame? if (szName[0] == 0) { TIMEUS endTime = GetTimeUs(); TIMEUS frameTime = endTime - m_StartTime; m_StartTime = endTime; // Duplicate data points to make up for missed time int Dups = frameTime / 33000; if (Dups > 0) { Dups = std::min(100, Dups); for (std::map<SString, SGraphStatLine>::iterator iter = m_LineList.begin(); iter != m_LineList.end(); ++iter) { SGraphStatLine* pLine = &iter->second; float Data = pLine->dataHistory[pLine->iDataPos]; for (int i = 0; i < Dups; i++) { pLine->iDataPos++; if (pLine->iDataPos > GRAPHSTAT_HISTORY_SIZE - 1) pLine->iDataPos = 0; pLine->dataHistory[pLine->iDataPos] = Data; } } } return; } if (m_StartTime == 0) return; // Find existing line SGraphStatLine* pLine = MapFind(m_LineList, szName); if (!pLine) { // Add new line MapSet(m_LineList, szName, SGraphStatLine()); pLine = MapFind(m_LineList, szName); pLine->dataHistory.resize(GRAPHSTAT_HISTORY_SIZE); memset(&pLine->dataHistory[0], 0, pLine->dataHistory.size()); pLine->iDataPos = 0; pLine->prevData = 0; pLine->strName = szName; // Random color based on line name MD5 md5; CMD5Hasher().Calculate(szName, strlen(szName), md5); uchar* p = md5.data; while (p[0] + p[1] + p[2] < 128) { int f = rand() % NUMELMS(md5.data); int t = rand() % 3; p[t] = std::min(255, p[t] + p[f] + 1); } pLine->color = SColorRGBA(p[0], p[1], p[2], 255); } // Calc timing averaged with previous frame TIMEUS NewData = GetTimeUs() - m_StartTime; TIMEUS AvgData = (NewData + pLine->prevData) / 2; pLine->prevData = NewData; // Inc position pLine->iDataPos++; if (pLine->iDataPos > GRAPHSTAT_HISTORY_SIZE - 1) pLine->iDataPos = 0; // Insert data point pLine->dataHistory[pLine->iDataPos] = AvgData; }
CVehicle::CVehicle ( CVehicleManager* pVehicleManager, CElement* pParent, CXMLNode* pNode, unsigned short usModel, unsigned char ucVariant, unsigned char ucVariant2 ) : CElement ( pParent, pNode ) { CElementRefManager::AddElementRefs ( ELEMENT_REF_DEBUG ( this, "CVehicle" ), &m_pTowedVehicle, &m_pTowedByVehicle, &m_pSyncer, &m_pJackingPlayer, NULL ); // Init m_pVehicleManager = pVehicleManager; m_usModel = usModel; m_pUpgrades = new CVehicleUpgrades ( this ); m_iType = CElement::VEHICLE; SetTypeName ( "vehicle" ); m_eVehicleType = CVehicleManager::GetVehicleType ( m_usModel ); m_fHealth = DEFAULT_VEHICLE_HEALTH; m_fLastSyncedHealthHealth = DEFAULT_VEHICLE_HEALTH; m_ulHealthChangeTime = 0; m_llIdleTime = CTickCount::Now (); m_fTurretPositionX = 0; m_fTurretPositionY = 0; m_bSirenActive = false; m_bLandingGearDown = true; m_usAdjustableProperty = 0; m_bIsFrozen = false; m_bUnoccupiedSyncable = true; m_pSyncer = NULL; GetInitialDoorStates ( m_ucDoorStates ); memset ( &m_ucWheelStates[0], 0, sizeof ( m_ucWheelStates ) ); memset ( &m_ucPanelStates[0], 0, sizeof ( m_ucPanelStates ) ); memset ( &m_ucLightStates[0], 0, sizeof ( m_ucLightStates ) ); m_ucOverrideLights = 0; m_pTowedVehicle = NULL; m_pTowedByVehicle = NULL; m_ucPaintjob = 3; m_ucMaxPassengersOverride = VEHICLE_PASSENGERS_UNDEFINED; m_pHandlingEntry = NULL; m_fRespawnHealth = DEFAULT_VEHICLE_HEALTH; m_bRespawnEnabled = false; m_ulBlowRespawnInterval = 10000; m_ulIdleRespawnInterval = 60000; m_bEngineOn = false; for ( unsigned int i = 0; i < 6; ++i ) m_fDoorOpenRatio [ i ] = 0.0f; m_bLocked = false; m_bDoorsUndamageable = false; m_bDamageProof = false; m_bGunsEnabled = false; m_bFuelTankExplodable = false; m_bOnGround = true; m_bSmokeTrail = false; m_ucAlpha = 255; m_pJackingPlayer = NULL; m_bInWater = false; m_bDerailed = false; m_bIsDerailable = true; m_fTrainSpeed = 0.0f; m_fTrainPosition = 0.0f; m_ucTrackID = 0; m_bTaxiLightState = false; m_bTrainDirection = false; m_HeadLightColor = SColorRGBA ( 255, 255, 255, 255 ); m_bHeliSearchLightVisible = false; m_bCollisionsEnabled = true; m_bHandlingChanged = false; m_ucVariant = ucVariant; m_ucVariant2 = ucVariant2; // Initialize the occupied Players for ( int i = 0; i < MAX_VEHICLE_SEATS; i++ ) { m_pOccupants [i] = NULL; } // Add us to the vehicle manager pVehicleManager->AddToList ( this ); // Randomize our color RandomizeColor (); // Generate a random reg plate GenerateRegPlate (); // Generate the handling data GenerateHandlingData (); // Prepare the sirens RemoveVehicleSirens(); m_tSirenBeaconInfo.m_bOverrideSirens = false; }
bool CMarker::ReadSpecialData ( void ) { // Grab the "posX" data if ( !GetCustomDataFloat ( "posX", m_vecPosition.fX, true ) ) { CLogger::ErrorPrintf ( "Bad/missing 'posX' attribute in <marker> (line %u)\n", m_uiLine ); return false; } // Grab the "posY" data if ( !GetCustomDataFloat ( "posY", m_vecPosition.fY, true ) ) { CLogger::ErrorPrintf ( "Bad/missing 'posY' attribute in <marker> (line %u)\n", m_uiLine ); return false; } // Grab the "posZ" data if ( !GetCustomDataFloat ( "posZ", m_vecPosition.fZ, true ) ) { CLogger::ErrorPrintf ( "Bad/missing 'posZ' attribute in <marker> (line %u)\n", m_uiLine ); return false; } // Set the position in the col object if ( m_pCollision ) m_pCollision->SetPosition ( m_vecPosition ); // Grab the "type" data char szBuffer [128]; unsigned char ucType; if ( GetCustomDataString ( "type", szBuffer, 128, true ) ) { // Convert it to a type ucType = static_cast < unsigned char > ( CMarkerManager::StringToType ( szBuffer ) ); if ( ucType == CMarker::TYPE_INVALID ) { CLogger::LogPrintf ( "WARNING: Unknown 'type' value specified in <marker>; defaulting to \"default\" (line %u)\n", m_uiLine ); ucType = CMarker::TYPE_CHECKPOINT; } } else { ucType = CMarker::TYPE_CHECKPOINT; } SetMarkerType(ucType); // Grab the "color" data if ( GetCustomDataString ( "color", szBuffer, 128, true ) ) { // Convert the HTML-style color to RGB if ( !XMLColorToInt ( szBuffer, m_Color.R, m_Color.G, m_Color.B, m_Color.A ) ) { CLogger::ErrorPrintf ( "Bad 'color' specified in <marker> (line %u)\n", m_uiLine ); return false; } } else { SetColor ( SColorRGBA( 255, 0, 0, 255 ) ); } float fSize; if ( GetCustomDataFloat ( "size", fSize, true ) ) m_fSize = fSize; int iTemp; if ( GetCustomDataInt ( "dimension", iTemp, true ) ) m_usDimension = static_cast < unsigned short > ( iTemp ); if ( GetCustomDataInt ( "interior", iTemp, true ) ) m_ucInterior = static_cast < unsigned char > ( iTemp ); // Success return true; }
void CClientWeapon::DoGunShells ( CVector vecOrigin, CVector vecDirection ) { float fShellSize = 0.0f; switch( m_Type ) { case(WEAPONTYPE_MINIGUN): case(WEAPONTYPE_M4): case(WEAPONTYPE_AK47): { if ( m_ucCounter == 0) { fShellSize = 0.25f; m_ucCounter = 1; } else { m_ucCounter = 0; } break; } break; case(WEAPONTYPE_MICRO_UZI): case(WEAPONTYPE_MP5): case(WEAPONTYPE_TEC9): fShellSize = 0.3f; break; case(WEAPONTYPE_SNIPERRIFLE): case(WEAPONTYPE_PISTOL): case(WEAPONTYPE_PISTOL_SILENCED): case(WEAPONTYPE_DESERT_EAGLE): fShellSize = 0.25f; break; case(WEAPONTYPE_SHOTGUN): case(WEAPONTYPE_SAWNOFF_SHOTGUN): case(WEAPONTYPE_SPAS12_SHOTGUN): fShellSize = 0.45f; break; } if(fShellSize > 0.0f) { if ( !m_weaponConfig.bDisableWeaponModel ) { g_pGame->GetPointLights ()->AddLight ( PLTYPE_POINTLIGHT, vecOrigin, CVector (), 3.0f, SColorRGBA ( 220, 255, 0, 0 ), 0, 0, 0 ); // Note: Nozzle flare lags behind attached object if it is moving, but we can't set attached entity here as it will crash if not a ped g_pGame->GetFx ()->TriggerGunshot ( NULL, vecOrigin, vecDirection, true ); m_pWeapon->AddGunshell ( m_pObject, &vecOrigin, &CVector2D ( 0, -1 ), fShellSize ); } if ( m_Type != WEAPONTYPE_MINIGUN ) { g_pGame->GetAudioEngine ()->ReportWeaponEvent ( WEAPON_EVENT_FIRE, m_Type, m_pObject ); } } }
bool CVehicle::ReadSpecialData ( void ) { // Grab the "posX" data if ( !GetCustomDataFloat ( "posX", m_vecPosition.fX, true ) ) { CLogger::ErrorPrintf ( "Bad/missing 'posX' attribute in <vehicle> (line %u)\n", m_uiLine ); return false; } // Grab the "posY" data if ( !GetCustomDataFloat ( "posY", m_vecPosition.fY, true ) ) { CLogger::ErrorPrintf ( "Bad/missing 'posY' attribute in <vehicle> (line %u)\n", m_uiLine ); return false; } // Grab the "posZ" data if ( !GetCustomDataFloat ( "posZ", m_vecPosition.fZ, true ) ) { CLogger::ErrorPrintf ( "Bad/missing 'posZ' attribute in <vehicle> (line %u)\n", m_uiLine ); return false; } // Grab the "rotX", "rotY" and "rotZ" data GetCustomDataFloat ( "rotX", m_vecRotationDegrees.fX, true ); GetCustomDataFloat ( "rotY", m_vecRotationDegrees.fY, true ); GetCustomDataFloat ( "rotZ", m_vecRotationDegrees.fZ, true ); // Wrap them around 360 m_vecRotationDegrees.fX = WrapAround ( m_vecRotationDegrees.fX, 360.0f ); m_vecRotationDegrees.fY = WrapAround ( m_vecRotationDegrees.fY, 360.0f ); m_vecRotationDegrees.fZ = WrapAround ( m_vecRotationDegrees.fZ, 360.0f ); // Set the respawn matrix SetRespawnPosition ( m_vecPosition ); SetRespawnRotationDegrees ( m_vecRotationDegrees ); // Grab the "model" data int iTemp; if ( GetCustomDataInt ( "model", iTemp, true ) ) { // Is it valid? if ( CVehicleManager::IsValidModel ( iTemp ) ) { // Remember it and generate a new random color SetModel ( static_cast < unsigned short > ( iTemp ) ); m_usAdjustableProperty = 0; } else { CLogger::ErrorPrintf ( "Bad 'model'(%d) id specified in <vehicle> (line %u)\n", iTemp, m_uiLine ); return false; } } else { CLogger::ErrorPrintf ( "Bad/missing 'model' attribute in <vehicle> (line %u)\n", m_uiLine ); return false; } // Grab the variant data if ( GetCustomDataInt ( "variant1", iTemp, true ) ) { m_ucVariant = static_cast < unsigned char > ( iTemp ); } if ( GetCustomDataInt ( "variant2", iTemp, true ) ) { m_ucVariant2 = static_cast < unsigned char > ( iTemp ); } if ( m_ucVariant == 254 && m_ucVariant2 == 254 ) CVehicleManager::GetRandomVariation ( m_usModel, m_ucVariant, m_ucVariant2 ); // Grab the "turretX" data if ( GetCustomDataFloat ( "turretX", m_fTurretPositionX, true ) ) { m_fTurretPositionX = ConvertDegreesToRadians ( m_fTurretPositionX ); } // Grab the "turretY" data if ( GetCustomDataFloat ( "turretY", m_fTurretPositionY, true ) ) { m_fTurretPositionY = ConvertDegreesToRadians ( m_fTurretPositionY ); } // Grab the "health" data if ( GetCustomDataFloat ( "health", m_fHealth, true ) ) { if ( m_fHealth < 0.0f ) m_fHealth = 0.0f; } // Grab the "Sirens" data if ( !GetCustomDataBool ( "sirens", m_bSirenActive, true ) ) { m_bSirenActive = false; } // Grab the "landingGearDown" data if ( !GetCustomDataBool ( "landingGearDown", m_bLandingGearDown, true ) ) { m_bLandingGearDown = true; } if ( !GetCustomDataBool ( "locked", m_bLocked, true ) ) { m_bLocked = false; } // Grab the "specialState" data if ( GetCustomDataInt ( "specialState", iTemp, true ) ) { m_usAdjustableProperty = static_cast < unsigned short > ( iTemp ); } else { m_usAdjustableProperty = 0; } // Grab the "color" data char szTemp [ 256 ]; if ( GetCustomDataString ( "color", szTemp, 256, true ) ) { uchar ucValues[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; char* sz1 = strtok ( szTemp, ", " ); if ( sz1 ) ucValues[0] = atoi ( sz1 ); int i; for ( i = 1 ; i < 12 ; i++ ) { char* szn = strtok ( NULL, ", " ); if ( !szn ) break; ucValues[i] = atoi ( szn ); } if ( i == 3 || i == 6 || i == 9 || i == 12 ) { m_Color.SetRGBColors ( SColorRGBA ( ucValues[0], ucValues[1], ucValues[2], 0 ), SColorRGBA ( ucValues[3], ucValues[4], ucValues[5], 0 ), SColorRGBA ( ucValues[6], ucValues[7], ucValues[8], 0 ), SColorRGBA ( ucValues[9], ucValues[10], ucValues[11], 0 ) ); } else { m_Color.SetPaletteColors ( ucValues[0], ucValues[1], ucValues[2], ucValues[3] ); } } if ( GetCustomDataInt ( "paintjob", iTemp, true ) ) m_ucPaintjob = static_cast < unsigned char > ( iTemp ); if ( GetCustomDataString ( "upgrades", szTemp, 256, true ) ) { if ( m_pUpgrades ) { if ( strcmp ( szTemp, "all" ) == 0 ) { m_pUpgrades->AddAllUpgrades (); } else { bool bTemp = true; while ( char* token = strtok ( ( bTemp ) ? szTemp : NULL, ", " ) ) { bTemp = false; unsigned short usUpgrade = static_cast < unsigned short > ( atoi ( token ) ); if ( CVehicleUpgrades::IsValidUpgrade ( usUpgrade ) ) { m_pUpgrades->AddUpgrade ( usUpgrade ); } } } } } if ( GetCustomDataString ( "plate", szTemp, 9, true ) ) SetRegPlate ( szTemp ); if ( GetCustomDataInt ( "interior", iTemp, true ) ) m_ucInterior = static_cast < unsigned char > ( iTemp ); if ( GetCustomDataInt ( "dimension", iTemp, true ) ) m_usDimension = static_cast < unsigned short > ( iTemp ); if ( !GetCustomDataBool ( "collisions", m_bCollisionsEnabled, true ) ) m_bCollisionsEnabled = true; if ( GetCustomDataInt ( "alpha", iTemp, true ) ) m_ucAlpha = static_cast < unsigned char > ( iTemp ); bool bFrozen; if ( GetCustomDataBool ( "frozen", bFrozen, true ) ) m_bIsFrozen = bFrozen; return true; }
#define CORE_MTA_HIDDEN_ALPHA 0.0f #define CORE_MTA_DISABLED_ALPHA 0.4f #define CORE_MTA_ENABLED_ALPHA 1.0f #define CORE_MTA_ANIMATION_TIME 200 #define CORE_MTA_MOVE_ANIM_TIME 600 #define CORE_MTA_STATIC_BG "cgui\\images\\background.png" #define CORE_MTA_LOGO "cgui\\images\\background_logo.png" #define CORE_MTA_FILLER "cgui\\images\\mta_filler.png" #define CORE_MTA_VERSION "cgui\\images\\version.png" #define CORE_MTA_LATEST_NEWS "cgui\\images\\latest_news.png" static int WaitForMenu = 0; static const SColor headlineColors[] = {SColorRGBA(233, 234, 106, 255), SColorRGBA(233 / 6 * 4, 234 / 6 * 4, 106 / 6 * 4, 255), SColorRGBA(233 / 7 * 3, 234 / 7 * 3, 106 / 7 * 3, 255)}; // Improve alignment with magical mystery values! static const int BODGE_FACTOR_1 = -5; static const int BODGE_FACTOR_2 = 5; static const int BODGE_FACTOR_3 = -5; static const int BODGE_FACTOR_4 = 5; static const CVector2D BODGE_FACTOR_5(0, -50); static const CVector2D BODGE_FACTOR_6(0, 100); CMainMenu::CMainMenu(CGUI* pManager) { m_pNewsBrowser = new CNewsBrowser(); ulPreviousTick = GetTickCount32();