From a8f7bf0beca5c200bc3396312f0caaceacd27f94 Mon Sep 17 00:00:00 2001 From: saml1er Date: Fri, 10 Apr 2020 16:44:08 +0500 Subject: CObject complete --- src/control/Pickups.cpp | 10 +- src/entities/Entity.cpp | 4 +- src/entities/Entity.h | 4 +- src/objects/Object.cpp | 291 ++++++++++++++++++++++++++++++++++++++++++-- src/objects/Object.h | 22 +++- src/peds/Ped.cpp | 4 +- src/peds/Population.cpp | 2 +- src/vehicles/Automobile.cpp | 4 +- src/vehicles/Boat.cpp | 2 +- src/vehicles/Floater.cpp | 2 +- 10 files changed, 316 insertions(+), 29 deletions(-) diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp index 774abd8c..16123c63 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -111,7 +111,7 @@ CPickup::GiveUsAPickUpObject(int32 handle) object->bUsesCollision = false; object->bIsPickup = true; - object->field_172 = m_eModelIndex == MI_PICKUP_BONUS ? m_nQuantity : 0; + object->m_nBonusValue = m_eModelIndex == MI_PICKUP_BONUS ? m_nQuantity : 0; switch (m_eType) { @@ -671,9 +671,9 @@ void CPickups::DoPickUpEffects(CEntity *entity) { if (entity->GetModelIndex() == MI_PICKUP_KILLFRENZY) - entity->m_flagD80 = CTheScripts::IsPlayerOnAMission() || CDarkel::FrenzyOnGoing() || !CGame::nastyGame; + entity->bDoNotRender = CTheScripts::IsPlayerOnAMission() || CDarkel::FrenzyOnGoing() || !CGame::nastyGame; - if (!entity->m_flagD80) { + if (!entity->bDoNotRender) { float s = Sin((float)((CTimer::GetTimeInMilliseconds() + (uintptr)entity) & 0x7FF) * DEGTORAD(360.0f / 0x800)); float modifiedSin = 0.3f * (s + 1.0f); @@ -716,7 +716,7 @@ CPickups::DoPickUpEffects(CEntity *entity) size, 65.0f, CCoronas::TYPE_RING, CCoronas::FLARE_NONE, CCoronas::REFLECTION_OFF, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, 0.0f); CObject *object = (CObject*)entity; - if (object->m_obj_flag2 || object->bOutOfStock || object->field_172) { + if (object->m_obj_flag2 || object->bOutOfStock || object->m_nBonusValue) { float dist = (TheCamera.GetPosition() - pos).Magnitude(); const float MAXDIST = 12.0f; @@ -734,7 +734,7 @@ CPickups::DoPickUpEffects(CEntity *entity) aMessages[NumMessages].m_color.blue = aWeaponBlues[colorId]; aMessages[NumMessages].m_color.alpha = (1.0f - dist / MAXDIST) * 128.0f; aMessages[NumMessages].m_bOutOfStock = object->bOutOfStock; - aMessages[NumMessages].m_quantity = object->field_172; + aMessages[NumMessages].m_quantity = object->m_nBonusValue; NumMessages++; } } diff --git a/src/entities/Entity.cpp b/src/entities/Entity.cpp index 07d70394..25e5db48 100644 --- a/src/entities/Entity.cpp +++ b/src/entities/Entity.cpp @@ -62,11 +62,11 @@ CEntity::CEntity(void) bRemoveFromWorld = false; bHasHitWall = false; bImBeingRendered = false; - m_flagD8 = false; + bTouchingWater = false; bIsSubway = false; bDrawLast = false; bNoBrightHeadLights = false; - m_flagD80 = false; + bDoNotRender = false; bDistanceFade = false; m_flagE2 = false; diff --git a/src/entities/Entity.h b/src/entities/Entity.h index 99cc7f17..17a219c3 100644 --- a/src/entities/Entity.h +++ b/src/entities/Entity.h @@ -73,11 +73,11 @@ public: uint32 bRemoveFromWorld : 1; uint32 bHasHitWall : 1; uint32 bImBeingRendered : 1; - uint32 m_flagD8 : 1; // used by cBuoyancy::ProcessBuoyancy + uint32 bTouchingWater : 1; // used by cBuoyancy::ProcessBuoyancy uint32 bIsSubway : 1; // set when subway, but maybe different meaning? uint32 bDrawLast : 1; uint32 bNoBrightHeadLights : 1; - uint32 m_flagD80 : 1; // CObject visibility? + uint32 bDoNotRender : 1; // flagsE uint32 bDistanceFade : 1; diff --git a/src/objects/Object.cpp b/src/objects/Object.cpp index aa366aa0..9d08dc72 100644 --- a/src/objects/Object.cpp +++ b/src/objects/Object.cpp @@ -6,12 +6,11 @@ #include "Radar.h" #include "Object.h" #include "DummyObject.h" - -WRAPPER void CObject::ObjectDamage(float amount) { EAXJMP(0x4BB240); } -WRAPPER void CObject::DeleteAllTempObjectInArea(CVector, float) { EAXJMP(0x4BBED0); } -WRAPPER void CObject::Init(void) { EAXJMP(0x4BAEC0); } -WRAPPER void CObject::ProcessControl(void) { EAXJMP(0x4BB040); } -WRAPPER void CObject::Teleport(CVector) { EAXJMP(0x4BBDA0); } +#include "Particle.h" +#include "General.h" +#include "ObjectData.h" +#include "World.h" +#include "Floater.h" int16 &CObject::nNoTempObjects = *(int16*)0x95CCA2; int16 &CObject::nBodyCastHealth = *(int16*)0x5F7D4C; // 1000 @@ -28,13 +27,13 @@ CObject::CObject(void) m_nCollisionDamageEffect = 0; m_nSpecialCollisionResponseCases = COLLRESPONSE_NONE; m_bCameraToAvoidThisObject = false; - ObjectCreatedBy = 0; + ObjectCreatedBy = 0; m_nEndOfLifeTime = 0; // m_nRefModelIndex = -1; // duplicate // bUseVehicleColours = false; // duplicate m_colour2 = 0; m_colour1 = m_colour2; - field_172 = 0; + m_nBonusValue = 0; bIsPickup = false; m_obj_flag2 = false; bOutOfStock = false; @@ -82,10 +81,46 @@ CObject::~CObject(void) nNoTempObjects--; } +void +CObject::ProcessControl(void) +{ + CVector point, impulse; + if (m_nCollisionDamageEffect) + ObjectDamage(m_fDamageImpulse); + CPhysical::ProcessControl(); + if (mod_Buoyancy.ProcessBuoyancy(this, m_fBuoyancy, &point, &impulse)) { + bIsInWater = true; + bIsStatic = false; + ApplyMoveForce(impulse); + ApplyTurnForce(impulse, point); + float fTimeStep = Pow(0.97f, CTimer::GetTimeStep()); + m_vecMoveSpeed *= fTimeStep; + m_vecTurnSpeed *= fTimeStep; + } + if ((MI_EXPLODINGBARREL == m_modelIndex || MI_PETROLPUMP == m_modelIndex) && bHasBeenDamaged && bIsVisible + && CGeneral::GetRandomNumberInRange(0, 31) == 10) { + bExplosionProof = true; + bIsVisible = false; + bUsesCollision = false; + bAffectedByGravity = false; + m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); + } +} + +void +CObject::Teleport(CVector vecPos) +{ + CWorld::Remove(this); + m_matrix.GetPosition() = vecPos; + m_matrix.UpdateRW(); + UpdateRwFrame(); + CWorld::Add(this); +} + void CObject::Render(void) { - if(m_flagD80) + if(bDoNotRender) return; if(m_nRefModelIndex != -1 && ObjectCreatedBy == TEMP_OBJECT && bUseVehicleColours){ @@ -117,6 +152,158 @@ CObject::RemoveLighting(bool reset) WorldReplaceScorchedLightsWithNormal(Scene.world); } +void +CObject::ObjectDamage(float amount) +{ + if (m_nCollisionDamageEffect && bUsesCollision) { + static int8_t nFrameGen = 0; + bool bBodyCastDamageEffect = false; + if (m_modelIndex == MI_BODYCAST){ + if (amount > 50.0f) + nBodyCastHealth = static_cast(nBodyCastHealth - 0.5f * amount); + if (nBodyCastHealth < 0) + nBodyCastHealth = 0; + if (nBodyCastHealth < 200) + bBodyCastDamageEffect = true; + amount = 0.0f; + } + if ((amount * m_fCollisionDamageMultiplier > 150.0f || bBodyCastDamageEffect) && m_nCollisionDamageEffect) { + if (m_nCollisionDamageEffect == COLDAMAGE_EFFECT_CHANGE_MODEL) { + bRenderDamaged = true; + return; + } + if (m_nCollisionDamageEffect != COLDAMAGE_EFFECT_SPLIT_MODEL) { + if (m_nCollisionDamageEffect == COLDAMAGE_EFFECT_SMASH_COMPLETELY) { + bIsVisible = false; + bUsesCollision = false; + bIsStatic = true; + bExplosionProof = true; + m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); + m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + return; + } + if (m_nCollisionDamageEffect != COLDAMAGE_EFFECT_CHANGE_THEN_SMASH) { + uint8 audioId = 0; + const CVector& vecPos = m_matrix.GetPosition(); + const float fDirectionZ = 0.0002f * amount; + switch (m_nCollisionDamageEffect) + { + case COLDAMAGE_EFFECT_SMASH_CARDBOX_COMPLETELY: { + bIsVisible = false; + bUsesCollision = false; + bIsStatic = true; + bExplosionProof = true; + m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); + m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + const RwRGBA color = {96, 48, 0, 255}; + for (int32_t i = 0; i < 25; i++) { + CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); + ++nFrameGen; + int32 currentFrame = nFrameGen & 3; + float fRandom = CGeneral::GetRandomNumberInRange(0.01f, 1.0f); + RwRGBA randomColor = {color.red * fRandom, color.green * fRandom , color.blue, color.alpha}; + float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); + int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); + CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, randomColor, nRotationSpeed, 0, currentFrame, 0); + } + audioId = _SCRSOUND_CARDBOARD_BOX_SMASH; + break; + } + case COLDAMAGE_EFFECT_SMASH_WOODENBOX_COMPLETELY: { + bIsVisible = false; + bUsesCollision = false; + bIsStatic = true; + bExplosionProof = true; + m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); + m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + const RwRGBA color = {128, 128, 128, 255}; + for (int32_t i = 0; i < 45; i++) { + CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); + ++nFrameGen; + int32 currentFrame = nFrameGen & 3; + float fRandom = CGeneral::GetRandomNumberInRange(0.5f, 0.5f); + RwRGBA randomColor = {color.red * fRandom, color.green * fRandom , color.blue * fRandom, color.alpha}; + float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); + int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); + CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, randomColor, nRotationSpeed, 0, currentFrame, 0); + } + audioId = _SCRSOUND_WOODEN_BOX_SMASH; + break; + } + case COLDAMAGE_EFFECT_SMASH_TRAFFICCONE_COMPLETELY: { + bIsVisible = false; + bUsesCollision = false; + bIsStatic = true; + bExplosionProof = true; + m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); + m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + const RwRGBA color1 = {200, 0, 0, 255}; + const RwRGBA color2 = {200, 200, 200, 255}; + for (int32_t i = 0; i < 10; i++) { + CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); + ++nFrameGen; + int32 currentFrame = nFrameGen & 3; + RwRGBA color = color2; + if (nFrameGen & 1) + color = color1; + float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); + int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); + CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, color, nRotationSpeed, 0, currentFrame, 0); + } + audioId = _SCRSOUND_TYRE_BUMP; + break; + } + case COLDAMAGE_EFFECT_SMASH_BARPOST_COMPLETELY: { + bIsVisible = false; + bUsesCollision = false; + bIsStatic = true; + bExplosionProof = true; + m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); + m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + const RwRGBA color1 = {200, 0, 0, 255}; + const RwRGBA color2 = {200, 200, 200, 255}; + for (int32_t i = 0; i < 32; i++) { + CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); + ++nFrameGen; + int32 currentFrame = nFrameGen & 3; + RwRGBA color = color2; + if (nFrameGen & 1) + color = color1; + float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); + int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); + CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, color, nRotationSpeed, 0, currentFrame, 0); + } + audioId = _SCRSOUND_COL_CAR; + break; + } + default: + return; + } + PlayOneShotScriptObject(audioId, vecPos); + return; + } + if (!bRenderDamaged) { + bRenderDamaged = true; + } else { + bIsVisible = false; + bUsesCollision = false; + bIsStatic = true; + bExplosionProof = true; + m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); + m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + } + } + } + } +} void CObject::RefModelInfo(int32 modelId) @@ -125,6 +312,39 @@ CObject::RefModelInfo(int32 modelId) CModelInfo::GetModelInfo(modelId)->AddRef(); } +void +CObject::Init(void) +{ + m_type = ENTITY_TYPE_OBJECT;; + CObjectData::SetObjectData(m_modelIndex, *this); + m_nEndOfLifeTime = 0; + ObjectCreatedBy = GAME_OBJECT; + bIsStatic = true; + bIsPickup = false; + m_obj_flag2 = false; + bOutOfStock = false; + bGlassCracked = false; + bGlassBroken = false; + bHasBeenDamaged = false; + bUseVehicleColours = false; + m_nRefModelIndex = -1; + m_colour1 = 0; + m_colour2 = 0; + m_nBonusValue = 0; + m_pCollidingEntity = nil; + CColPoint point; + CEntity* outEntity = nil; + const CVector& vecPos = m_matrix.GetPosition(); + if (CWorld::ProcessVerticalLine(vecPos, vecPos.z - 10.0f, point, outEntity, true, false, false, false, false, false, nil)) + m_pCurSurface = outEntity; + else + m_pCurSurface = nil; + if (m_modelIndex == MI_BODYCAST) + nBodyCastHealth = 1000; + else if (m_modelIndex == MI_BUOY) + bTouchingWater = true; +} + bool CObject::CanBeDeleted(void) { @@ -142,6 +362,45 @@ CObject::CanBeDeleted(void) } } +void +CObject::DeleteAllMissionObjects() +{ + CObjectPool* objectPool = CPools::GetObjectPool(); + for (int32_t i = 0; i < objectPool->GetSize(); i++) { + CObject* pObject = objectPool->GetSlot(i); + if (pObject && pObject->ObjectCreatedBy == MISSION_OBJECT) { + CWorld::Remove(pObject); + delete pObject; + } + } +} + +void +CObject::DeleteAllTempObjects() +{ + CObjectPool* objectPool = CPools::GetObjectPool(); + for (int32_t i = 0; i < objectPool->GetSize(); i++) { + CObject* pObject = objectPool->GetSlot(i); + if (pObject && pObject->ObjectCreatedBy == TEMP_OBJECT) { + CWorld::Remove(pObject); + delete pObject; + } + } +} + +void +CObject::DeleteAllTempObjectInArea(CVector point, float fRadius) +{ + CObjectPool *objectPool = CPools::GetObjectPool(); + for (int32_t i = 0; i < objectPool->GetSize(); i++) { + CObject *pObject = objectPool->GetSlot(i); + if (pObject && pObject->ObjectCreatedBy == TEMP_OBJECT && fRadius * fRadius > pObject->GetPosition().MagnitudeSqr()) { + CWorld::Remove(pObject); + delete pObject; + } + } +} + #include class CObject_ : public CObject @@ -152,6 +411,9 @@ public: CObject *ctor(CDummyObject *dummy) { return ::new (this) CObject(dummy); } void dtor(void) { CObject::~CObject(); } void Render_(void) { CObject::Render(); } + void ProcessControl_(void) { CObject::ProcessControl(); } + bool SetupLighting_(void) { return CObject::SetupLighting(); } + void RemoveLighting_(bool reset) { CObject::RemoveLighting(reset); } }; STARTPATCHES @@ -159,5 +421,16 @@ STARTPATCHES InjectHook(0x4BACE0, (CObject* (CObject::*)(int32, bool)) &CObject_::ctor, PATCH_JUMP); InjectHook(0x4BAD50, (CObject* (CObject::*)(CDummyObject*)) &CObject_::ctor, PATCH_JUMP); InjectHook(0x4BAE00, &CObject_::dtor, PATCH_JUMP); + InjectHook(0x4BB040, &CObject_::ProcessControl_, PATCH_JUMP); + InjectHook(0x4BBDA0, &CObject::Teleport, PATCH_JUMP); InjectHook(0x4BB1E0, &CObject_::Render_, PATCH_JUMP); + InjectHook(0x4A7C90, &CObject_::SetupLighting_, PATCH_JUMP); + InjectHook(0x4A7CD0, &CObject_::RemoveLighting_, PATCH_JUMP); + InjectHook(0x4BB240, &CObject::ObjectDamage, PATCH_JUMP); + InjectHook(0x4BBD80, &CObject::RefModelInfo, PATCH_JUMP); + InjectHook(0x4BAEC0, &CObject::Init, PATCH_JUMP); + InjectHook(0x4BB010, &CObject::CanBeDeleted, PATCH_JUMP); + InjectHook(0x4BBE60, &CObject::DeleteAllMissionObjects, PATCH_JUMP); + InjectHook(0x4BBDF0, &CObject::DeleteAllTempObjects, PATCH_JUMP); + InjectHook(0x4BBED0, &CObject::DeleteAllTempObjectInArea, PATCH_JUMP); ENDPATCHES diff --git a/src/objects/Object.h b/src/objects/Object.h index 27346e23..86fbe119 100644 --- a/src/objects/Object.h +++ b/src/objects/Object.h @@ -9,6 +9,18 @@ enum { CUTSCENE_OBJECT = 4, }; +enum { + COLDAMAGE_EFFECT_NONE = 0, + COLDAMAGE_EFFECT_CHANGE_MODEL = 1, + COLDAMAGE_EFFECT_SPLIT_MODEL = 2, + COLDAMAGE_EFFECT_SMASH_COMPLETELY = 3, + COLDAMAGE_EFFECT_CHANGE_THEN_SMASH = 4, + COLDAMAGE_EFFECT_SMASH_CARDBOX_COMPLETELY = 50, + COLDAMAGE_EFFECT_SMASH_WOODENBOX_COMPLETELY = 60, + COLDAMAGE_EFFECT_SMASH_TRAFFICCONE_COMPLETELY = 70, + COLDAMAGE_EFFECT_SMASH_BARPOST_COMPLETELY = 80, +}; + enum { COLLRESPONSE_NONE, COLLRESPONSE_CHANGE_MODEL, @@ -41,8 +53,8 @@ public: int8 bHasBeenDamaged : 1; int8 bUseVehicleColours : 1; int8 m_obj_flag80 : 1; - int8 field_172; // car for a bonus pickup? - int8 field_173; + int8 m_nBonusValue; + int8 field_173; float m_fCollisionDamageMultiplier; uint8 m_nCollisionDamageEffect; uint8 m_nSpecialCollisionResponseCases; @@ -74,7 +86,7 @@ public: ~CObject(void); void ProcessControl(void); - void Teleport(CVector); + void Teleport(CVector vecPos); void Render(void); bool SetupLighting(void); void RemoveLighting(bool reset); @@ -84,6 +96,8 @@ public: void Init(void); bool CanBeDeleted(void); - static void DeleteAllTempObjectInArea(CVector, float); + static void DeleteAllMissionObjects(); + static void DeleteAllTempObjects(); + static void DeleteAllTempObjectInArea(CVector point, float fRadius); }; static_assert(sizeof(CObject) == 0x198, "CObject: error"); diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 2cd942f9..687c9906 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -15027,7 +15027,7 @@ CPed::ProcessBuoyancy(void) #endif if (mod_Buoyancy.ProcessBuoyancy(this, GRAVITY * m_fMass * buoyancyLevel, &buoyancyPoint, &buoyancyImpulse)) { - m_flagD8 = true; + bTouchingWater = true; CEntity *entity; CColPoint point; if (CWorld::ProcessVerticalLine(GetPosition(), GetPosition().z - 3.0f, point, entity, false, true, false, false, false, false, false) @@ -15093,7 +15093,7 @@ CPed::ProcessBuoyancy(void) } else return; } else - m_flagD8 = false; + bTouchingWater = false; if (nGenerateWaterCircles && CTimer::GetTimeInMilliseconds() >= nGenerateWaterCircles) { CVector pos = GetPosition(); diff --git a/src/peds/Population.cpp b/src/peds/Population.cpp index 3bf81066..c4290bd9 100644 --- a/src/peds/Population.cpp +++ b/src/peds/Population.cpp @@ -964,7 +964,7 @@ CPopulation::ConvertToRealObject(CDummyObject *dummy) } else if (obj->m_modelIndex == MI_BUOY) { obj->bIsStatic = false; obj->m_vecMoveSpeed = CVector(0.0f, 0.0f, -0.001f); - obj->m_flagD8 = true; + obj->bTouchingWater = true; obj->AddToMovingList(); } } diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index 1c0d673e..76f06b0e 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -2814,7 +2814,7 @@ CAutomobile::ProcessBuoyancy(void) CVector impulse, point; if(mod_Buoyancy.ProcessBuoyancy(this, m_fBuoyancy, &point, &impulse)){ - m_flagD8 = true; + bTouchingWater = true; ApplyMoveForce(impulse); ApplyTurnForce(impulse, point); @@ -2899,7 +2899,7 @@ CAutomobile::ProcessBuoyancy(void) } }else{ bIsInWater = false; - m_flagD8 = false; + bTouchingWater = false; static RwRGBA splashCol = {155, 155, 185, 196}; static RwRGBA smokeCol = {255, 255, 255, 255}; diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp index 9c7cbb4f..0b3dab3d 100644 --- a/src/vehicles/Boat.cpp +++ b/src/vehicles/Boat.cpp @@ -70,7 +70,7 @@ CBoat::CBoat(int mi, uint8 owner) : CVehicle(owner) unk1 = 0.0f; m_bIsAnchored = true; field_2C4 = -9999.99f; - m_flagD8 = true; + bTouchingWater = true; field_2CC = 0.0f; field_2D0 = 0; m_nNumWakePoints = 0; diff --git a/src/vehicles/Floater.cpp b/src/vehicles/Floater.cpp index 6b8bf755..62d55925 100644 --- a/src/vehicles/Floater.cpp +++ b/src/vehicles/Floater.cpp @@ -26,7 +26,7 @@ cBuoyancy::ProcessBuoyancy(CPhysical *phys, float buoyancy, CVector *point, CVec { m_numSteps = 2.0f; - if(!CWaterLevel::GetWaterLevel(phys->GetPosition(), &m_waterlevel, phys->m_flagD8)) + if(!CWaterLevel::GetWaterLevel(phys->GetPosition(), &m_waterlevel, phys->bTouchingWater)) return false; m_matrix = phys->GetMatrix(); -- cgit v1.2.3 From bb21cff6390bbbbf81fd1a9ed0add69e2a4adc88 Mon Sep 17 00:00:00 2001 From: saml1er Date: Fri, 10 Apr 2020 17:03:02 +0500 Subject: Fix Object.h and Object.cpp indentation --- src/objects/Object.cpp | 456 ++++++++++++++++++++++++------------------------- src/objects/Object.h | 14 +- 2 files changed, 235 insertions(+), 235 deletions(-) diff --git a/src/objects/Object.cpp b/src/objects/Object.cpp index 9d08dc72..1ff71b23 100644 --- a/src/objects/Object.cpp +++ b/src/objects/Object.cpp @@ -84,37 +84,37 @@ CObject::~CObject(void) void CObject::ProcessControl(void) { - CVector point, impulse; - if (m_nCollisionDamageEffect) - ObjectDamage(m_fDamageImpulse); - CPhysical::ProcessControl(); - if (mod_Buoyancy.ProcessBuoyancy(this, m_fBuoyancy, &point, &impulse)) { - bIsInWater = true; - bIsStatic = false; - ApplyMoveForce(impulse); - ApplyTurnForce(impulse, point); - float fTimeStep = Pow(0.97f, CTimer::GetTimeStep()); - m_vecMoveSpeed *= fTimeStep; - m_vecTurnSpeed *= fTimeStep; - } - if ((MI_EXPLODINGBARREL == m_modelIndex || MI_PETROLPUMP == m_modelIndex) && bHasBeenDamaged && bIsVisible - && CGeneral::GetRandomNumberInRange(0, 31) == 10) { - bExplosionProof = true; - bIsVisible = false; - bUsesCollision = false; - bAffectedByGravity = false; - m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); - } + CVector point, impulse; + if (m_nCollisionDamageEffect) + ObjectDamage(m_fDamageImpulse); + CPhysical::ProcessControl(); + if (mod_Buoyancy.ProcessBuoyancy(this, m_fBuoyancy, &point, &impulse)) { + bIsInWater = true; + bIsStatic = false; + ApplyMoveForce(impulse); + ApplyTurnForce(impulse, point); + float fTimeStep = Pow(0.97f, CTimer::GetTimeStep()); + m_vecMoveSpeed *= fTimeStep; + m_vecTurnSpeed *= fTimeStep; + } + if ((MI_EXPLODINGBARREL == m_modelIndex || MI_PETROLPUMP == m_modelIndex) && bHasBeenDamaged && bIsVisible + && CGeneral::GetRandomNumberInRange(0, 31) == 10) { + bExplosionProof = true; + bIsVisible = false; + bUsesCollision = false; + bAffectedByGravity = false; + m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); + } } void CObject::Teleport(CVector vecPos) { - CWorld::Remove(this); - m_matrix.GetPosition() = vecPos; - m_matrix.UpdateRW(); - UpdateRwFrame(); - CWorld::Add(this); + CWorld::Remove(this); + m_matrix.GetPosition() = vecPos; + m_matrix.UpdateRW(); + UpdateRwFrame(); + CWorld::Add(this); } void @@ -156,7 +156,7 @@ void CObject::ObjectDamage(float amount) { if (m_nCollisionDamageEffect && bUsesCollision) { - static int8_t nFrameGen = 0; + static int8 nFrameGen = 0; bool bBodyCastDamageEffect = false; if (m_modelIndex == MI_BODYCAST){ if (amount > 50.0f) @@ -167,141 +167,141 @@ CObject::ObjectDamage(float amount) bBodyCastDamageEffect = true; amount = 0.0f; } - if ((amount * m_fCollisionDamageMultiplier > 150.0f || bBodyCastDamageEffect) && m_nCollisionDamageEffect) { - if (m_nCollisionDamageEffect == COLDAMAGE_EFFECT_CHANGE_MODEL) { - bRenderDamaged = true; - return; - } - if (m_nCollisionDamageEffect != COLDAMAGE_EFFECT_SPLIT_MODEL) { - if (m_nCollisionDamageEffect == COLDAMAGE_EFFECT_SMASH_COMPLETELY) { - bIsVisible = false; - bUsesCollision = false; - bIsStatic = true; - bExplosionProof = true; - m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); - m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); - return; - } - if (m_nCollisionDamageEffect != COLDAMAGE_EFFECT_CHANGE_THEN_SMASH) { - uint8 audioId = 0; - const CVector& vecPos = m_matrix.GetPosition(); - const float fDirectionZ = 0.0002f * amount; - switch (m_nCollisionDamageEffect) - { - case COLDAMAGE_EFFECT_SMASH_CARDBOX_COMPLETELY: { - bIsVisible = false; - bUsesCollision = false; - bIsStatic = true; - bExplosionProof = true; - m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); - m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); - const RwRGBA color = {96, 48, 0, 255}; - for (int32_t i = 0; i < 25; i++) { - CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), - CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), - CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); - ++nFrameGen; - int32 currentFrame = nFrameGen & 3; - float fRandom = CGeneral::GetRandomNumberInRange(0.01f, 1.0f); - RwRGBA randomColor = {color.red * fRandom, color.green * fRandom , color.blue, color.alpha}; - float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); - int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); - CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, randomColor, nRotationSpeed, 0, currentFrame, 0); - } - audioId = _SCRSOUND_CARDBOARD_BOX_SMASH; - break; - } - case COLDAMAGE_EFFECT_SMASH_WOODENBOX_COMPLETELY: { - bIsVisible = false; - bUsesCollision = false; - bIsStatic = true; - bExplosionProof = true; - m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); - m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); - const RwRGBA color = {128, 128, 128, 255}; - for (int32_t i = 0; i < 45; i++) { - CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), - CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), - CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); - ++nFrameGen; - int32 currentFrame = nFrameGen & 3; - float fRandom = CGeneral::GetRandomNumberInRange(0.5f, 0.5f); - RwRGBA randomColor = {color.red * fRandom, color.green * fRandom , color.blue * fRandom, color.alpha}; - float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); - int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); - CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, randomColor, nRotationSpeed, 0, currentFrame, 0); - } - audioId = _SCRSOUND_WOODEN_BOX_SMASH; - break; - } - case COLDAMAGE_EFFECT_SMASH_TRAFFICCONE_COMPLETELY: { - bIsVisible = false; - bUsesCollision = false; - bIsStatic = true; - bExplosionProof = true; - m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); - m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); - const RwRGBA color1 = {200, 0, 0, 255}; - const RwRGBA color2 = {200, 200, 200, 255}; - for (int32_t i = 0; i < 10; i++) { - CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), - CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), - CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); - ++nFrameGen; - int32 currentFrame = nFrameGen & 3; - RwRGBA color = color2; - if (nFrameGen & 1) - color = color1; - float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); - int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); - CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, color, nRotationSpeed, 0, currentFrame, 0); - } - audioId = _SCRSOUND_TYRE_BUMP; - break; - } - case COLDAMAGE_EFFECT_SMASH_BARPOST_COMPLETELY: { - bIsVisible = false; - bUsesCollision = false; - bIsStatic = true; - bExplosionProof = true; - m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); - m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); - const RwRGBA color1 = {200, 0, 0, 255}; - const RwRGBA color2 = {200, 200, 200, 255}; - for (int32_t i = 0; i < 32; i++) { - CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), - CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), - CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); - ++nFrameGen; - int32 currentFrame = nFrameGen & 3; - RwRGBA color = color2; - if (nFrameGen & 1) - color = color1; - float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); - int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); - CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, color, nRotationSpeed, 0, currentFrame, 0); - } - audioId = _SCRSOUND_COL_CAR; - break; - } - default: - return; - } - PlayOneShotScriptObject(audioId, vecPos); - return; - } - if (!bRenderDamaged) { - bRenderDamaged = true; - } else { - bIsVisible = false; - bUsesCollision = false; - bIsStatic = true; - bExplosionProof = true; - m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); - m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); - } - } - } + if ((amount * m_fCollisionDamageMultiplier > 150.0f || bBodyCastDamageEffect) && m_nCollisionDamageEffect) { + if (m_nCollisionDamageEffect == COLDAMAGE_EFFECT_CHANGE_MODEL) { + bRenderDamaged = true; + return; + } + if (m_nCollisionDamageEffect != COLDAMAGE_EFFECT_SPLIT_MODEL) { + if (m_nCollisionDamageEffect == COLDAMAGE_EFFECT_SMASH_COMPLETELY) { + bIsVisible = false; + bUsesCollision = false; + bIsStatic = true; + bExplosionProof = true; + m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); + m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + return; + } + if (m_nCollisionDamageEffect != COLDAMAGE_EFFECT_CHANGE_THEN_SMASH) { + uint8 audioId = 0; + const CVector& vecPos = m_matrix.GetPosition(); + const float fDirectionZ = 0.0002f * amount; + switch (m_nCollisionDamageEffect) + { + case COLDAMAGE_EFFECT_SMASH_CARDBOX_COMPLETELY: { + bIsVisible = false; + bUsesCollision = false; + bIsStatic = true; + bExplosionProof = true; + m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); + m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + const RwRGBA color = {96, 48, 0, 255}; + for (int32 i = 0; i < 25; i++) { + CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); + ++nFrameGen; + int32 currentFrame = nFrameGen & 3; + float fRandom = CGeneral::GetRandomNumberInRange(0.01f, 1.0f); + RwRGBA randomColor = {color.red * fRandom, color.green * fRandom , color.blue, color.alpha}; + float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); + int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); + CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, randomColor, nRotationSpeed, 0, currentFrame, 0); + } + audioId = _SCRSOUND_CARDBOARD_BOX_SMASH; + break; + } + case COLDAMAGE_EFFECT_SMASH_WOODENBOX_COMPLETELY: { + bIsVisible = false; + bUsesCollision = false; + bIsStatic = true; + bExplosionProof = true; + m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); + m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + const RwRGBA color = {128, 128, 128, 255}; + for (int32 i = 0; i < 45; i++) { + CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); + ++nFrameGen; + int32 currentFrame = nFrameGen & 3; + float fRandom = CGeneral::GetRandomNumberInRange(0.5f, 0.5f); + RwRGBA randomColor = {color.red * fRandom, color.green * fRandom , color.blue * fRandom, color.alpha}; + float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); + int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); + CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, randomColor, nRotationSpeed, 0, currentFrame, 0); + } + audioId = _SCRSOUND_WOODEN_BOX_SMASH; + break; + } + case COLDAMAGE_EFFECT_SMASH_TRAFFICCONE_COMPLETELY: { + bIsVisible = false; + bUsesCollision = false; + bIsStatic = true; + bExplosionProof = true; + m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); + m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + const RwRGBA color1 = {200, 0, 0, 255}; + const RwRGBA color2 = {200, 200, 200, 255}; + for (int32 i = 0; i < 10; i++) { + CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); + ++nFrameGen; + int32 currentFrame = nFrameGen & 3; + RwRGBA color = color2; + if (nFrameGen & 1) + color = color1; + float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); + int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); + CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, color, nRotationSpeed, 0, currentFrame, 0); + } + audioId = _SCRSOUND_TYRE_BUMP; + break; + } + case COLDAMAGE_EFFECT_SMASH_BARPOST_COMPLETELY: { + bIsVisible = false; + bUsesCollision = false; + bIsStatic = true; + bExplosionProof = true; + m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); + m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + const RwRGBA color1 = {200, 0, 0, 255}; + const RwRGBA color2 = {200, 200, 200, 255}; + for (int32 i = 0; i < 32; i++) { + CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); + ++nFrameGen; + int32 currentFrame = nFrameGen & 3; + RwRGBA color = color2; + if (nFrameGen & 1) + color = color1; + float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); + int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); + CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, color, nRotationSpeed, 0, currentFrame, 0); + } + audioId = _SCRSOUND_COL_CAR; + break; + } + default: + return; + } + PlayOneShotScriptObject(audioId, vecPos); + return; + } + if (!bRenderDamaged) { + bRenderDamaged = true; + } else { + bIsVisible = false; + bUsesCollision = false; + bIsStatic = true; + bExplosionProof = true; + m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); + m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + } + } + } } } @@ -315,34 +315,34 @@ CObject::RefModelInfo(int32 modelId) void CObject::Init(void) { - m_type = ENTITY_TYPE_OBJECT;; - CObjectData::SetObjectData(m_modelIndex, *this); - m_nEndOfLifeTime = 0; - ObjectCreatedBy = GAME_OBJECT; - bIsStatic = true; - bIsPickup = false; - m_obj_flag2 = false; - bOutOfStock = false; - bGlassCracked = false; - bGlassBroken = false; - bHasBeenDamaged = false; - bUseVehicleColours = false; - m_nRefModelIndex = -1; - m_colour1 = 0; - m_colour2 = 0; - m_nBonusValue = 0; - m_pCollidingEntity = nil; - CColPoint point; - CEntity* outEntity = nil; - const CVector& vecPos = m_matrix.GetPosition(); - if (CWorld::ProcessVerticalLine(vecPos, vecPos.z - 10.0f, point, outEntity, true, false, false, false, false, false, nil)) - m_pCurSurface = outEntity; - else - m_pCurSurface = nil; - if (m_modelIndex == MI_BODYCAST) - nBodyCastHealth = 1000; - else if (m_modelIndex == MI_BUOY) - bTouchingWater = true; + m_type = ENTITY_TYPE_OBJECT;; + CObjectData::SetObjectData(m_modelIndex, *this); + m_nEndOfLifeTime = 0; + ObjectCreatedBy = GAME_OBJECT; + bIsStatic = true; + bIsPickup = false; + m_obj_flag2 = false; + bOutOfStock = false; + bGlassCracked = false; + bGlassBroken = false; + bHasBeenDamaged = false; + bUseVehicleColours = false; + m_nRefModelIndex = -1; + m_colour1 = 0; + m_colour2 = 0; + m_nBonusValue = 0; + m_pCollidingEntity = nil; + CColPoint point; + CEntity* outEntity = nil; + const CVector& vecPos = m_matrix.GetPosition(); + if (CWorld::ProcessVerticalLine(vecPos, vecPos.z - 10.0f, point, outEntity, true, false, false, false, false, false, nil)) + m_pCurSurface = outEntity; + else + m_pCurSurface = nil; + if (m_modelIndex == MI_BODYCAST) + nBodyCastHealth = 1000; + else if (m_modelIndex == MI_BUOY) + bTouchingWater = true; } bool @@ -365,40 +365,40 @@ CObject::CanBeDeleted(void) void CObject::DeleteAllMissionObjects() { - CObjectPool* objectPool = CPools::GetObjectPool(); - for (int32_t i = 0; i < objectPool->GetSize(); i++) { - CObject* pObject = objectPool->GetSlot(i); - if (pObject && pObject->ObjectCreatedBy == MISSION_OBJECT) { - CWorld::Remove(pObject); - delete pObject; - } - } + CObjectPool* objectPool = CPools::GetObjectPool(); + for (int32 i = 0; i < objectPool->GetSize(); i++) { + CObject* pObject = objectPool->GetSlot(i); + if (pObject && pObject->ObjectCreatedBy == MISSION_OBJECT) { + CWorld::Remove(pObject); + delete pObject; + } + } } void CObject::DeleteAllTempObjects() { - CObjectPool* objectPool = CPools::GetObjectPool(); - for (int32_t i = 0; i < objectPool->GetSize(); i++) { - CObject* pObject = objectPool->GetSlot(i); - if (pObject && pObject->ObjectCreatedBy == TEMP_OBJECT) { - CWorld::Remove(pObject); - delete pObject; - } - } + CObjectPool* objectPool = CPools::GetObjectPool(); + for (int32 i = 0; i < objectPool->GetSize(); i++) { + CObject* pObject = objectPool->GetSlot(i); + if (pObject && pObject->ObjectCreatedBy == TEMP_OBJECT) { + CWorld::Remove(pObject); + delete pObject; + } + } } void CObject::DeleteAllTempObjectInArea(CVector point, float fRadius) { - CObjectPool *objectPool = CPools::GetObjectPool(); - for (int32_t i = 0; i < objectPool->GetSize(); i++) { - CObject *pObject = objectPool->GetSlot(i); - if (pObject && pObject->ObjectCreatedBy == TEMP_OBJECT && fRadius * fRadius > pObject->GetPosition().MagnitudeSqr()) { - CWorld::Remove(pObject); - delete pObject; - } - } + CObjectPool *objectPool = CPools::GetObjectPool(); + for (int32 i = 0; i < objectPool->GetSize(); i++) { + CObject *pObject = objectPool->GetSlot(i); + if (pObject && pObject->ObjectCreatedBy == TEMP_OBJECT && fRadius * fRadius > pObject->GetPosition().MagnitudeSqr()) { + CWorld::Remove(pObject); + delete pObject; + } + } } #include @@ -411,9 +411,9 @@ public: CObject *ctor(CDummyObject *dummy) { return ::new (this) CObject(dummy); } void dtor(void) { CObject::~CObject(); } void Render_(void) { CObject::Render(); } - void ProcessControl_(void) { CObject::ProcessControl(); } - bool SetupLighting_(void) { return CObject::SetupLighting(); } - void RemoveLighting_(bool reset) { CObject::RemoveLighting(reset); } + void ProcessControl_(void) { CObject::ProcessControl(); } + bool SetupLighting_(void) { return CObject::SetupLighting(); } + void RemoveLighting_(bool reset) { CObject::RemoveLighting(reset); } }; STARTPATCHES @@ -421,16 +421,16 @@ STARTPATCHES InjectHook(0x4BACE0, (CObject* (CObject::*)(int32, bool)) &CObject_::ctor, PATCH_JUMP); InjectHook(0x4BAD50, (CObject* (CObject::*)(CDummyObject*)) &CObject_::ctor, PATCH_JUMP); InjectHook(0x4BAE00, &CObject_::dtor, PATCH_JUMP); - InjectHook(0x4BB040, &CObject_::ProcessControl_, PATCH_JUMP); - InjectHook(0x4BBDA0, &CObject::Teleport, PATCH_JUMP); + InjectHook(0x4BB040, &CObject_::ProcessControl_, PATCH_JUMP); + InjectHook(0x4BBDA0, &CObject::Teleport, PATCH_JUMP); InjectHook(0x4BB1E0, &CObject_::Render_, PATCH_JUMP); - InjectHook(0x4A7C90, &CObject_::SetupLighting_, PATCH_JUMP); - InjectHook(0x4A7CD0, &CObject_::RemoveLighting_, PATCH_JUMP); - InjectHook(0x4BB240, &CObject::ObjectDamage, PATCH_JUMP); - InjectHook(0x4BBD80, &CObject::RefModelInfo, PATCH_JUMP); - InjectHook(0x4BAEC0, &CObject::Init, PATCH_JUMP); - InjectHook(0x4BB010, &CObject::CanBeDeleted, PATCH_JUMP); - InjectHook(0x4BBE60, &CObject::DeleteAllMissionObjects, PATCH_JUMP); - InjectHook(0x4BBDF0, &CObject::DeleteAllTempObjects, PATCH_JUMP); - InjectHook(0x4BBED0, &CObject::DeleteAllTempObjectInArea, PATCH_JUMP); + InjectHook(0x4A7C90, &CObject_::SetupLighting_, PATCH_JUMP); + InjectHook(0x4A7CD0, &CObject_::RemoveLighting_, PATCH_JUMP); + InjectHook(0x4BB240, &CObject::ObjectDamage, PATCH_JUMP); + InjectHook(0x4BBD80, &CObject::RefModelInfo, PATCH_JUMP); + InjectHook(0x4BAEC0, &CObject::Init, PATCH_JUMP); + InjectHook(0x4BB010, &CObject::CanBeDeleted, PATCH_JUMP); + InjectHook(0x4BBE60, &CObject::DeleteAllMissionObjects, PATCH_JUMP); + InjectHook(0x4BBDF0, &CObject::DeleteAllTempObjects, PATCH_JUMP); + InjectHook(0x4BBED0, &CObject::DeleteAllTempObjectInArea, PATCH_JUMP); ENDPATCHES diff --git a/src/objects/Object.h b/src/objects/Object.h index 86fbe119..d51c9f61 100644 --- a/src/objects/Object.h +++ b/src/objects/Object.h @@ -59,15 +59,15 @@ public: uint8 m_nCollisionDamageEffect; uint8 m_nSpecialCollisionResponseCases; bool m_bCameraToAvoidThisObject; - int8 field_17B; - int8 field_17C; - int8 field_17D; - int8 field_17E; - int8 field_17F; + int8 field_17B; + int8 field_17C; + int8 field_17D; + int8 field_17E; + int8 field_17F; uint32 m_nEndOfLifeTime; int16 m_nRefModelIndex; - int8 field_186; - int8 field_187; + int8 field_186; + int8 field_187; CEntity *m_pCurSurface; CEntity *m_pCollidingEntity; int8 m_colour1, m_colour2; -- cgit v1.2.3 From 5544325acb108da13a3d858b38c2096f500d0add Mon Sep 17 00:00:00 2001 From: saml1er Date: Fri, 10 Apr 2020 19:32:42 +0500 Subject: Refactor CObject::ObjectDamage --- src/objects/Object.cpp | 282 ++++++++++++++++++++++++------------------------- src/objects/Object.h | 1 + 2 files changed, 141 insertions(+), 142 deletions(-) diff --git a/src/objects/Object.cpp b/src/objects/Object.cpp index 1ff71b23..7eb56a1c 100644 --- a/src/objects/Object.cpp +++ b/src/objects/Object.cpp @@ -27,7 +27,7 @@ CObject::CObject(void) m_nCollisionDamageEffect = 0; m_nSpecialCollisionResponseCases = COLLRESPONSE_NONE; m_bCameraToAvoidThisObject = false; - ObjectCreatedBy = 0; + ObjectCreatedBy = UNKNOWN_OBJECT; m_nEndOfLifeTime = 0; // m_nRefModelIndex = -1; // duplicate // bUseVehicleColours = false; // duplicate @@ -97,7 +97,7 @@ CObject::ProcessControl(void) m_vecMoveSpeed *= fTimeStep; m_vecTurnSpeed *= fTimeStep; } - if ((MI_EXPLODINGBARREL == m_modelIndex || MI_PETROLPUMP == m_modelIndex) && bHasBeenDamaged && bIsVisible + if ((m_modelIndex == MI_EXPLODINGBARREL || m_modelIndex == MI_PETROLPUMP) && bHasBeenDamaged && bIsVisible && CGeneral::GetRandomNumberInRange(0, 31) == 10) { bExplosionProof = true; bIsVisible = false; @@ -155,152 +155,150 @@ CObject::RemoveLighting(bool reset) void CObject::ObjectDamage(float amount) { - if (m_nCollisionDamageEffect && bUsesCollision) { - static int8 nFrameGen = 0; - bool bBodyCastDamageEffect = false; - if (m_modelIndex == MI_BODYCAST){ - if (amount > 50.0f) - nBodyCastHealth = static_cast(nBodyCastHealth - 0.5f * amount); - if (nBodyCastHealth < 0) - nBodyCastHealth = 0; - if (nBodyCastHealth < 200) - bBodyCastDamageEffect = true; - amount = 0.0f; + if (!m_nCollisionDamageEffect || !bUsesCollision) + return; + static int8 nFrameGen = 0; + bool bBodyCastDamageEffect = false; + if (m_modelIndex == MI_BODYCAST){ + if (amount > 50.0f) + nBodyCastHealth = int16(nBodyCastHealth - 0.5f * amount); + if (nBodyCastHealth < 0) + nBodyCastHealth = 0; + if (nBodyCastHealth < 200) + bBodyCastDamageEffect = true; + amount = 0.0f; + } + if ((amount * m_fCollisionDamageMultiplier > 150.0f || bBodyCastDamageEffect) && m_nCollisionDamageEffect) { + if (m_nCollisionDamageEffect == COLDAMAGE_EFFECT_CHANGE_MODEL) { + bRenderDamaged = true; + return; } - if ((amount * m_fCollisionDamageMultiplier > 150.0f || bBodyCastDamageEffect) && m_nCollisionDamageEffect) { - if (m_nCollisionDamageEffect == COLDAMAGE_EFFECT_CHANGE_MODEL) { - bRenderDamaged = true; - return; - } - if (m_nCollisionDamageEffect != COLDAMAGE_EFFECT_SPLIT_MODEL) { - if (m_nCollisionDamageEffect == COLDAMAGE_EFFECT_SMASH_COMPLETELY) { - bIsVisible = false; - bUsesCollision = false; - bIsStatic = true; - bExplosionProof = true; - m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); - m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); - return; - } - if (m_nCollisionDamageEffect != COLDAMAGE_EFFECT_CHANGE_THEN_SMASH) { - uint8 audioId = 0; - const CVector& vecPos = m_matrix.GetPosition(); - const float fDirectionZ = 0.0002f * amount; - switch (m_nCollisionDamageEffect) - { - case COLDAMAGE_EFFECT_SMASH_CARDBOX_COMPLETELY: { - bIsVisible = false; - bUsesCollision = false; - bIsStatic = true; - bExplosionProof = true; - m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); - m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); - const RwRGBA color = {96, 48, 0, 255}; - for (int32 i = 0; i < 25; i++) { - CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), - CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), - CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); - ++nFrameGen; - int32 currentFrame = nFrameGen & 3; - float fRandom = CGeneral::GetRandomNumberInRange(0.01f, 1.0f); - RwRGBA randomColor = {color.red * fRandom, color.green * fRandom , color.blue, color.alpha}; - float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); - int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); - CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, randomColor, nRotationSpeed, 0, currentFrame, 0); - } - audioId = _SCRSOUND_CARDBOARD_BOX_SMASH; - break; - } - case COLDAMAGE_EFFECT_SMASH_WOODENBOX_COMPLETELY: { - bIsVisible = false; - bUsesCollision = false; - bIsStatic = true; - bExplosionProof = true; - m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); - m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); - const RwRGBA color = {128, 128, 128, 255}; - for (int32 i = 0; i < 45; i++) { - CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), - CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), - CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); - ++nFrameGen; - int32 currentFrame = nFrameGen & 3; - float fRandom = CGeneral::GetRandomNumberInRange(0.5f, 0.5f); - RwRGBA randomColor = {color.red * fRandom, color.green * fRandom , color.blue * fRandom, color.alpha}; - float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); - int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); - CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, randomColor, nRotationSpeed, 0, currentFrame, 0); - } - audioId = _SCRSOUND_WOODEN_BOX_SMASH; - break; - } - case COLDAMAGE_EFFECT_SMASH_TRAFFICCONE_COMPLETELY: { - bIsVisible = false; - bUsesCollision = false; - bIsStatic = true; - bExplosionProof = true; - m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); - m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); - const RwRGBA color1 = {200, 0, 0, 255}; - const RwRGBA color2 = {200, 200, 200, 255}; - for (int32 i = 0; i < 10; i++) { - CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), - CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), - CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); - ++nFrameGen; - int32 currentFrame = nFrameGen & 3; - RwRGBA color = color2; - if (nFrameGen & 1) - color = color1; - float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); - int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); - CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, color, nRotationSpeed, 0, currentFrame, 0); - } - audioId = _SCRSOUND_TYRE_BUMP; - break; - } - case COLDAMAGE_EFFECT_SMASH_BARPOST_COMPLETELY: { - bIsVisible = false; - bUsesCollision = false; - bIsStatic = true; - bExplosionProof = true; - m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); - m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); - const RwRGBA color1 = {200, 0, 0, 255}; - const RwRGBA color2 = {200, 200, 200, 255}; - for (int32 i = 0; i < 32; i++) { - CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + if (m_nCollisionDamageEffect == COLDAMAGE_EFFECT_SPLIT_MODEL) + return; + if (m_nCollisionDamageEffect == COLDAMAGE_EFFECT_SMASH_COMPLETELY) { + bIsVisible = false; + bUsesCollision = false; + bIsStatic = true; + bExplosionProof = true; + m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); + m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + return; + } + if (m_nCollisionDamageEffect != COLDAMAGE_EFFECT_CHANGE_THEN_SMASH) { + const CVector& vecPos = m_matrix.GetPosition(); + const float fDirectionZ = 0.0002f * amount; + switch (m_nCollisionDamageEffect) + { + case COLDAMAGE_EFFECT_SMASH_CARDBOX_COMPLETELY: { + bIsVisible = false; + bUsesCollision = false; + bIsStatic = true; + bExplosionProof = true; + m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); + m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + const RwRGBA color = {96, 48, 0, 255}; + for (int32 i = 0; i < 25; i++) { + CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); - ++nFrameGen; - int32 currentFrame = nFrameGen & 3; - RwRGBA color = color2; - if (nFrameGen & 1) - color = color1; - float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); - int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); - CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, color, nRotationSpeed, 0, currentFrame, 0); - } - audioId = _SCRSOUND_COL_CAR; - break; - } - default: - return; - } - PlayOneShotScriptObject(audioId, vecPos); - return; + ++nFrameGen; + int32 currentFrame = nFrameGen & 3; + float fRandom = CGeneral::GetRandomNumberInRange(0.01f, 1.0f); + RwRGBA randomColor = {color.red * fRandom, color.green * fRandom , color.blue, color.alpha}; + float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); + int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); + CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, randomColor, nRotationSpeed, 0, currentFrame, 0); + } + PlayOneShotScriptObject(_SCRSOUND_CARDBOARD_BOX_SMASH, vecPos); + break; + } + case COLDAMAGE_EFFECT_SMASH_WOODENBOX_COMPLETELY: { + bIsVisible = false; + bUsesCollision = false; + bIsStatic = true; + bExplosionProof = true; + m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); + m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + const RwRGBA color = {128, 128, 128, 255}; + for (int32 i = 0; i < 45; i++) { + CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); + ++nFrameGen; + int32 currentFrame = nFrameGen & 3; + float fRandom = CGeneral::GetRandomNumberInRange(0.5f, 0.5f); + RwRGBA randomColor = {color.red * fRandom, color.green * fRandom , color.blue * fRandom, color.alpha}; + float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); + int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); + CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, randomColor, nRotationSpeed, 0, currentFrame, 0); + } + PlayOneShotScriptObject(_SCRSOUND_WOODEN_BOX_SMASH, vecPos); + break; + } + case COLDAMAGE_EFFECT_SMASH_TRAFFICCONE_COMPLETELY: { + bIsVisible = false; + bUsesCollision = false; + bIsStatic = true; + bExplosionProof = true; + m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); + m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + const RwRGBA color1 = {200, 0, 0, 255}; + const RwRGBA color2 = {200, 200, 200, 255}; + for (int32 i = 0; i < 10; i++) { + CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); + ++nFrameGen; + int32 currentFrame = nFrameGen & 3; + RwRGBA color = color2; + if (nFrameGen & 1) + color = color1; + float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); + int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); + CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, color, nRotationSpeed, 0, currentFrame, 0); } - if (!bRenderDamaged) { - bRenderDamaged = true; - } else { - bIsVisible = false; - bUsesCollision = false; - bIsStatic = true; - bExplosionProof = true; - m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); - m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + PlayOneShotScriptObject(_SCRSOUND_TYRE_BUMP, vecPos); + break; + } + case COLDAMAGE_EFFECT_SMASH_BARPOST_COMPLETELY: { + bIsVisible = false; + bUsesCollision = false; + bIsStatic = true; + bExplosionProof = true; + m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); + m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + const RwRGBA color1 = {200, 0, 0, 255}; + const RwRGBA color2 = {200, 200, 200, 255}; + for (int32 i = 0; i < 32; i++) { + CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); + ++nFrameGen; + int32 currentFrame = nFrameGen & 3; + RwRGBA color = color2; + if (nFrameGen & 1) + color = color1; + float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); + int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); + CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, color, nRotationSpeed, 0, currentFrame, 0); } + PlayOneShotScriptObject(_SCRSOUND_COL_CAR, vecPos); + break; + } + default: + return; } + return; + } + if (!bRenderDamaged) { + bRenderDamaged = true; + } else { + bIsVisible = false; + bUsesCollision = false; + bIsStatic = true; + bExplosionProof = true; + m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); + m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); } } } diff --git a/src/objects/Object.h b/src/objects/Object.h index d51c9f61..6d04c78a 100644 --- a/src/objects/Object.h +++ b/src/objects/Object.h @@ -3,6 +3,7 @@ #include "Physical.h" enum { + UNKNOWN_OBJECT = 0, GAME_OBJECT = 1, MISSION_OBJECT = 2, TEMP_OBJECT = 3, -- cgit v1.2.3 From c2b00d7ad9c61a4e9e0ce99f944c57358877fc1a Mon Sep 17 00:00:00 2001 From: saml1er Date: Fri, 10 Apr 2020 19:37:09 +0500 Subject: Fix cast in CObject::ObjectDamage --- src/objects/Object.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objects/Object.cpp b/src/objects/Object.cpp index 7eb56a1c..5fe3b4b1 100644 --- a/src/objects/Object.cpp +++ b/src/objects/Object.cpp @@ -161,7 +161,7 @@ CObject::ObjectDamage(float amount) bool bBodyCastDamageEffect = false; if (m_modelIndex == MI_BODYCAST){ if (amount > 50.0f) - nBodyCastHealth = int16(nBodyCastHealth - 0.5f * amount); + nBodyCastHealth = (int16)(nBodyCastHealth - 0.5f * amount); if (nBodyCastHealth < 0) nBodyCastHealth = 0; if (nBodyCastHealth < 200) -- cgit v1.2.3 From 16360eb6df7c0febd5847d4746a04f2342c83b44 Mon Sep 17 00:00:00 2001 From: saml1er Date: Fri, 10 Apr 2020 21:52:02 +0500 Subject: Refactor CObject::ObjectDamage switch statement --- src/objects/Object.cpp | 207 ++++++++++++++++++++++++------------------------- 1 file changed, 102 insertions(+), 105 deletions(-) diff --git a/src/objects/Object.cpp b/src/objects/Object.cpp index 5fe3b4b1..aec9eba1 100644 --- a/src/objects/Object.cpp +++ b/src/objects/Object.cpp @@ -169,136 +169,133 @@ CObject::ObjectDamage(float amount) amount = 0.0f; } if ((amount * m_fCollisionDamageMultiplier > 150.0f || bBodyCastDamageEffect) && m_nCollisionDamageEffect) { - if (m_nCollisionDamageEffect == COLDAMAGE_EFFECT_CHANGE_MODEL) { + const CVector& vecPos = m_matrix.GetPosition(); + const float fDirectionZ = 0.0002f * amount; + switch (m_nCollisionDamageEffect) + { + case COLDAMAGE_EFFECT_CHANGE_MODEL: bRenderDamaged = true; - return; - } - if (m_nCollisionDamageEffect == COLDAMAGE_EFFECT_SPLIT_MODEL) - return; - if (m_nCollisionDamageEffect == COLDAMAGE_EFFECT_SMASH_COMPLETELY) { + break; + case COLDAMAGE_EFFECT_SPLIT_MODEL: + break; + case COLDAMAGE_EFFECT_SMASH_COMPLETELY: bIsVisible = false; bUsesCollision = false; bIsStatic = true; bExplosionProof = true; m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); - return; - } - if (m_nCollisionDamageEffect != COLDAMAGE_EFFECT_CHANGE_THEN_SMASH) { - const CVector& vecPos = m_matrix.GetPosition(); - const float fDirectionZ = 0.0002f * amount; - switch (m_nCollisionDamageEffect) - { - case COLDAMAGE_EFFECT_SMASH_CARDBOX_COMPLETELY: { - bIsVisible = false; - bUsesCollision = false; - bIsStatic = true; - bExplosionProof = true; - m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); - m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); - const RwRGBA color = {96, 48, 0, 255}; - for (int32 i = 0; i < 25; i++) { - CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), - CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), - CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); - ++nFrameGen; - int32 currentFrame = nFrameGen & 3; - float fRandom = CGeneral::GetRandomNumberInRange(0.01f, 1.0f); - RwRGBA randomColor = {color.red * fRandom, color.green * fRandom , color.blue, color.alpha}; - float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); - int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); - CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, randomColor, nRotationSpeed, 0, currentFrame, 0); - } - PlayOneShotScriptObject(_SCRSOUND_CARDBOARD_BOX_SMASH, vecPos); - break; + case COLDAMAGE_EFFECT_CHANGE_THEN_SMASH: + if (!bRenderDamaged) { + bRenderDamaged = true; } - case COLDAMAGE_EFFECT_SMASH_WOODENBOX_COMPLETELY: { + else { bIsVisible = false; bUsesCollision = false; bIsStatic = true; bExplosionProof = true; m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); - const RwRGBA color = {128, 128, 128, 255}; - for (int32 i = 0; i < 45; i++) { - CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), - CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), - CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); - ++nFrameGen; - int32 currentFrame = nFrameGen & 3; - float fRandom = CGeneral::GetRandomNumberInRange(0.5f, 0.5f); - RwRGBA randomColor = {color.red * fRandom, color.green * fRandom , color.blue * fRandom, color.alpha}; - float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); - int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); - CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, randomColor, nRotationSpeed, 0, currentFrame, 0); - } - PlayOneShotScriptObject(_SCRSOUND_WOODEN_BOX_SMASH, vecPos); - break; } - case COLDAMAGE_EFFECT_SMASH_TRAFFICCONE_COMPLETELY: { - bIsVisible = false; - bUsesCollision = false; - bIsStatic = true; - bExplosionProof = true; - m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); - m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); - const RwRGBA color1 = {200, 0, 0, 255}; - const RwRGBA color2 = {200, 200, 200, 255}; - for (int32 i = 0; i < 10; i++) { - CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), - CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), - CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); - ++nFrameGen; - int32 currentFrame = nFrameGen & 3; - RwRGBA color = color2; - if (nFrameGen & 1) - color = color1; - float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); - int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); - CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, color, nRotationSpeed, 0, currentFrame, 0); - } - PlayOneShotScriptObject(_SCRSOUND_TYRE_BUMP, vecPos); - break; + break; + case COLDAMAGE_EFFECT_SMASH_CARDBOX_COMPLETELY: { + bIsVisible = false; + bUsesCollision = false; + bIsStatic = true; + bExplosionProof = true; + m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); + m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + const RwRGBA color = { 96, 48, 0, 255 }; + for (int32 i = 0; i < 25; i++) { + CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); + ++nFrameGen; + int32 currentFrame = nFrameGen & 3; + float fRandom = CGeneral::GetRandomNumberInRange(0.01f, 1.0f); + RwRGBA randomColor = { color.red * fRandom, color.green * fRandom , color.blue, color.alpha }; + float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); + int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); + CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, randomColor, nRotationSpeed, 0, currentFrame, 0); } - case COLDAMAGE_EFFECT_SMASH_BARPOST_COMPLETELY: { - bIsVisible = false; - bUsesCollision = false; - bIsStatic = true; - bExplosionProof = true; - m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); - m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); - const RwRGBA color1 = {200, 0, 0, 255}; - const RwRGBA color2 = {200, 200, 200, 255}; - for (int32 i = 0; i < 32; i++) { - CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), - CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), - CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); - ++nFrameGen; - int32 currentFrame = nFrameGen & 3; - RwRGBA color = color2; - if (nFrameGen & 1) - color = color1; - float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); - int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); - CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, color, nRotationSpeed, 0, currentFrame, 0); - } - PlayOneShotScriptObject(_SCRSOUND_COL_CAR, vecPos); - break; + PlayOneShotScriptObject(_SCRSOUND_CARDBOARD_BOX_SMASH, vecPos); + break; + } + case COLDAMAGE_EFFECT_SMASH_WOODENBOX_COMPLETELY: { + bIsVisible = false; + bUsesCollision = false; + bIsStatic = true; + bExplosionProof = true; + m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); + m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + const RwRGBA color = { 128, 128, 128, 255 }; + for (int32 i = 0; i < 45; i++) { + CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); + ++nFrameGen; + int32 currentFrame = nFrameGen & 3; + float fRandom = CGeneral::GetRandomNumberInRange(0.5f, 0.5f); + RwRGBA randomColor = { color.red * fRandom, color.green * fRandom , color.blue * fRandom, color.alpha }; + float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); + int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); + CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, randomColor, nRotationSpeed, 0, currentFrame, 0); } - default: - return; + PlayOneShotScriptObject(_SCRSOUND_WOODEN_BOX_SMASH, vecPos); + break; + } + case COLDAMAGE_EFFECT_SMASH_TRAFFICCONE_COMPLETELY: { + bIsVisible = false; + bUsesCollision = false; + bIsStatic = true; + bExplosionProof = true; + m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); + m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + const RwRGBA color1 = { 200, 0, 0, 255 }; + const RwRGBA color2 = { 200, 200, 200, 255 }; + for (int32 i = 0; i < 10; i++) { + CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); + ++nFrameGen; + int32 currentFrame = nFrameGen & 3; + RwRGBA color = color2; + if (nFrameGen & 1) + color = color1; + float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); + int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); + CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, color, nRotationSpeed, 0, currentFrame, 0); } - return; + PlayOneShotScriptObject(_SCRSOUND_TYRE_BUMP, vecPos); + break; } - if (!bRenderDamaged) { - bRenderDamaged = true; - } else { + case COLDAMAGE_EFFECT_SMASH_BARPOST_COMPLETELY: { bIsVisible = false; bUsesCollision = false; bIsStatic = true; bExplosionProof = true; m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + const RwRGBA color1 = { 200, 0, 0, 255 }; + const RwRGBA color2 = { 200, 200, 200, 255 }; + for (int32 i = 0; i < 32; i++) { + CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), + CGeneral::GetRandomNumberInRange(0.1f, 0.15f) + fDirectionZ); + ++nFrameGen; + int32 currentFrame = nFrameGen & 3; + RwRGBA color = color2; + if (nFrameGen & 1) + color = color1; + float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f); + int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); + CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, color, nRotationSpeed, 0, currentFrame, 0); + } + PlayOneShotScriptObject(_SCRSOUND_COL_CAR, vecPos); + break; + } + default: + return; } } } -- cgit v1.2.3 From 4f00576a8c2ae03443848c5548cd5ad0e0e8d002 Mon Sep 17 00:00:00 2001 From: saml1er Date: Fri, 10 Apr 2020 21:59:49 +0500 Subject: Addendum to previous commit --- src/objects/Object.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/objects/Object.cpp b/src/objects/Object.cpp index aec9eba1..ca0ebf86 100644 --- a/src/objects/Object.cpp +++ b/src/objects/Object.cpp @@ -185,6 +185,7 @@ CObject::ObjectDamage(float amount) bExplosionProof = true; m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + break; case COLDAMAGE_EFFECT_CHANGE_THEN_SMASH: if (!bRenderDamaged) { bRenderDamaged = true; @@ -294,8 +295,6 @@ CObject::ObjectDamage(float amount) PlayOneShotScriptObject(_SCRSOUND_COL_CAR, vecPos); break; } - default: - return; } } } -- cgit v1.2.3 From ff16ba7801a3532e8bb982238f3d3124f6154e55 Mon Sep 17 00:00:00 2001 From: saml1er Date: Sat, 11 Apr 2020 22:31:32 +0500 Subject: CObject fixes --- src/objects/Object.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/objects/Object.cpp b/src/objects/Object.cpp index ca0ebf86..867624c7 100644 --- a/src/objects/Object.cpp +++ b/src/objects/Object.cpp @@ -98,7 +98,7 @@ CObject::ProcessControl(void) m_vecTurnSpeed *= fTimeStep; } if ((m_modelIndex == MI_EXPLODINGBARREL || m_modelIndex == MI_PETROLPUMP) && bHasBeenDamaged && bIsVisible - && CGeneral::GetRandomNumberInRange(0, 31) == 10) { + && (CGeneral::GetRandomNumber() & 0x1F) == 10) { bExplosionProof = true; bIsVisible = false; bUsesCollision = false; @@ -183,8 +183,8 @@ CObject::ObjectDamage(float amount) bUsesCollision = false; bIsStatic = true; bExplosionProof = true; - m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); - m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + SetMoveSpeed(0.0f, 0.0f, 0.0f); + SetTurnSpeed(0.0f, 0.0f, 0.0f); break; case COLDAMAGE_EFFECT_CHANGE_THEN_SMASH: if (!bRenderDamaged) { @@ -195,8 +195,8 @@ CObject::ObjectDamage(float amount) bUsesCollision = false; bIsStatic = true; bExplosionProof = true; - m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); - m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + SetMoveSpeed(0.0f, 0.0f, 0.0f); + SetTurnSpeed(0.0f, 0.0f, 0.0f); } break; case COLDAMAGE_EFFECT_SMASH_CARDBOX_COMPLETELY: { @@ -204,8 +204,8 @@ CObject::ObjectDamage(float amount) bUsesCollision = false; bIsStatic = true; bExplosionProof = true; - m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); - m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + SetMoveSpeed(0.0f, 0.0f, 0.0f); + SetTurnSpeed(0.0f, 0.0f, 0.0f); const RwRGBA color = { 96, 48, 0, 255 }; for (int32 i = 0; i < 25; i++) { CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), @@ -227,8 +227,8 @@ CObject::ObjectDamage(float amount) bUsesCollision = false; bIsStatic = true; bExplosionProof = true; - m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); - m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + SetMoveSpeed(0.0f, 0.0f, 0.0f); + SetTurnSpeed(0.0f, 0.0f, 0.0f); const RwRGBA color = { 128, 128, 128, 255 }; for (int32 i = 0; i < 45; i++) { CVector vecDir(CGeneral::GetRandomNumberInRange(-0.35f, 0.7f), @@ -250,8 +250,8 @@ CObject::ObjectDamage(float amount) bUsesCollision = false; bIsStatic = true; bExplosionProof = true; - m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); - m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + SetMoveSpeed(0.0f, 0.0f, 0.0f); + SetTurnSpeed(0.0f, 0.0f, 0.0f); const RwRGBA color1 = { 200, 0, 0, 255 }; const RwRGBA color2 = { 200, 200, 200, 255 }; for (int32 i = 0; i < 10; i++) { @@ -275,8 +275,8 @@ CObject::ObjectDamage(float amount) bUsesCollision = false; bIsStatic = true; bExplosionProof = true; - m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); - m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + SetMoveSpeed(0.0f, 0.0f, 0.0f); + SetTurnSpeed(0.0f, 0.0f, 0.0f); const RwRGBA color1 = { 200, 0, 0, 255 }; const RwRGBA color2 = { 200, 200, 200, 255 }; for (int32 i = 0; i < 32; i++) { -- cgit v1.2.3 From 38dee74a5aa6131d29147b121e78340de47f43a2 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 11 Apr 2020 21:01:39 +0300 Subject: CPools --- src/core/Pad.cpp | 2 +- src/core/Pools.cpp | 345 +++++++++++++++++++++++++++++++++++++++++- src/entities/Entity.h | 1 + src/modelinfo/BaseModelInfo.h | 4 +- src/objects/Object.cpp | 1 + src/objects/Object.h | 1 + src/vehicles/Vehicle.h | 3 +- 7 files changed, 346 insertions(+), 11 deletions(-) diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index f83998b8..973b4ef6 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -94,7 +94,7 @@ void TankCheat() if (node < 0) return; -#ifdef FIX_BUGS +#ifndef FIX_BUGS // TEMP!!! CAutomobile* tank = new CAutomobile(MI_RHINO, RANDOM_VEHICLE); #else CAutomobile *tank = new CAutomobile(MI_RHINO, MISSION_VEHICLE); diff --git a/src/core/Pools.cpp b/src/core/Pools.cpp index 75536b88..9fd3d60e 100644 --- a/src/core/Pools.cpp +++ b/src/core/Pools.cpp @@ -1,8 +1,14 @@ #include "common.h" #include "patcher.h" #include "Pools.h" -#include "World.h" + +#include "Boat.h" +#include "CarCtrl.h" +#include "Population.h" #include "ProjectileInfo.h" +#include "Streaming.h" +#include "Wanted.h" +#include "World.h" CCPtrNodePool *&CPools::ms_pPtrNodePool = *(CCPtrNodePool**)0x943044; CEntryInfoNodePool *&CPools::ms_pEntryInfoNodePool = *(CEntryInfoNodePool**)0x941448; @@ -14,13 +20,6 @@ CObjectPool *&CPools::ms_pObjectPool = *(CObjectPool**)0x880E28; CDummyPool *&CPools::ms_pDummyPool = *(CDummyPool**)0x8F2C18; CAudioScriptObjectPool *&CPools::ms_pAudioScriptObjectPool = *(CAudioScriptObjectPool**)0x8F1B6C; -WRAPPER void CPools::LoadObjectPool(uint8* buf, uint32 size) { EAXJMP(0x4a2550); } -WRAPPER void CPools::LoadPedPool(uint8* buf, uint32 size) { EAXJMP(0x4a2b50); } -WRAPPER void CPools::LoadVehiclePool(uint8* buf, uint32 size) { EAXJMP(0x4a1b40); } -WRAPPER void CPools::SaveObjectPool(uint8* buf, uint32 *size) { EAXJMP(0x4a22d0); } -WRAPPER void CPools::SavePedPool(uint8* buf, uint32 *size) { EAXJMP(0x4a29b0); } -WRAPPER void CPools::SaveVehiclePool(uint8* buf, uint32 *size) { EAXJMP(0x4a2080); } - void CPools::Initialise(void) { @@ -99,6 +98,333 @@ CPools::MakeSureSlotInObjectPoolIsEmpty(int32 slot) } } +void CPools::LoadVehiclePool(uint8* buf, uint32 size) +{ +INITSAVEBUF + int nNumCars = ReadSaveBuf(buf); + int nNumBoats = ReadSaveBuf(buf); + for (int i = 0; i < nNumCars + nNumBoats; i++) { + uint32 type = ReadSaveBuf(buf); + int16 model = ReadSaveBuf(buf); + CStreaming::RequestModel(model, STREAMFLAGS_DEPENDENCY); + CStreaming::LoadAllRequestedModels(false); + int32 slot = ReadSaveBuf(buf); + CVehicle* pVehicle; + char* vbuf = new char[max(sizeof(CAutomobile), sizeof(CBoat))]; + if (type == VEHICLE_TYPE_BOAT) { + memcpy(vbuf, buf, sizeof(CBoat)); + SkipSaveBuf(buf, sizeof(CBoat)); + CBoat* pBoat = new(slot) CBoat(model, RANDOM_VEHICLE); + pVehicle = pBoat; + --CCarCtrl::NumRandomCars; // why? + } + else if (type == VEHICLE_TYPE_CAR) { + memcpy(vbuf, buf, sizeof(CAutomobile)); + SkipSaveBuf(buf, sizeof(CAutomobile)); + CStreaming::RequestModel(model, 0); // is it needed? + CStreaming::LoadAllRequestedModels(false); + CAutomobile* pAutomobile = new(slot) CAutomobile(model, RANDOM_VEHICLE); + pVehicle = pAutomobile; + CCarCtrl::NumRandomCars--; // why? + pAutomobile->Damage = ((CAutomobile*)vbuf)->Damage; + pAutomobile->SetupDamageAfterLoad(); + } + else + assert(0); + CVehicle* pBufferVehicle = (CVehicle*)vbuf; + pVehicle->GetMatrix() = pBufferVehicle->GetMatrix(); + pVehicle->VehicleCreatedBy = pBufferVehicle->VehicleCreatedBy; + pVehicle->m_currentColour1 = pBufferVehicle->m_currentColour1; + pVehicle->m_currentColour2 = pBufferVehicle->m_currentColour2; + pVehicle->m_nAlarmState = pBufferVehicle->m_nAlarmState; + pVehicle->m_nNumMaxPassengers = pBufferVehicle->m_nNumMaxPassengers; + pVehicle->field_1D0[0] = pBufferVehicle->field_1D0[0]; + pVehicle->field_1D0[1] = pBufferVehicle->field_1D0[1]; + pVehicle->field_1D0[2] = pBufferVehicle->field_1D0[2]; + pVehicle->field_1D0[3] = pBufferVehicle->field_1D0[3]; + pVehicle->m_fSteerAngle = pBufferVehicle->m_fSteerAngle; + pVehicle->m_fGasPedal = pBufferVehicle->m_fGasPedal; + pVehicle->m_fBrakePedal = pBufferVehicle->m_fBrakePedal; + pVehicle->bIsLawEnforcer = pBufferVehicle->bIsLawEnforcer; + pVehicle->bIsLocked = pBufferVehicle->bIsLocked; + pVehicle->bEngineOn = pBufferVehicle->bEngineOn; + pVehicle->bIsHandbrakeOn = pBufferVehicle->bIsHandbrakeOn; + pVehicle->bLightsOn = pBufferVehicle->bLightsOn; + pVehicle->bFreebies = pBufferVehicle->bFreebies; + pVehicle->m_fHealth = pBufferVehicle->m_fHealth; + pVehicle->m_nCurrentGear = pBufferVehicle->m_nCurrentGear; + pVehicle->m_fChangeGearTime = pBufferVehicle->m_fChangeGearTime; + pVehicle->m_nTimeOfDeath = pBufferVehicle->m_nTimeOfDeath; +#ifdef FIX_BUGS //must be copypaste + pVehicle->m_nBombTimer = pBufferVehicle->m_nBombTimer; +#else + pVehicle->m_nTimeOfDeath = pBufferVehicle->m_nTimeOfDeath; +#endif + pVehicle->m_nDoorLock = pBufferVehicle->m_nDoorLock; + pVehicle->m_status = pBufferVehicle->m_status; + pVehicle->m_type = pBufferVehicle->m_type; + (pVehicle->GetAddressOfEntityProperties())[0] = (pBufferVehicle->GetAddressOfEntityProperties())[0]; + (pVehicle->GetAddressOfEntityProperties())[1] = (pBufferVehicle->GetAddressOfEntityProperties())[1]; + pVehicle->AutoPilot = pBufferVehicle->AutoPilot; + CWorld::Add(pVehicle); + delete[] vbuf; + } +VALIDATESAVEBUF(size) +} + +void CPools::SaveVehiclePool(uint8* buf, uint32* size) +{ +INITSAVEBUF + int nNumCars = 0; + int nNumBoats = 0; + int nPoolSize = GetVehiclePool()->GetSize(); + for (int i = 0; i < nPoolSize; i++) { + CVehicle* pVehicle = GetVehiclePool()->GetSlot(i); + if (!pVehicle) + continue; + bool bHasPassenger = false; + for (int j = 0; j < 8; j++) { + if (pVehicle->pPassengers[i]) + bHasPassenger = true; + } + if (!pVehicle->pDriver && !bHasPassenger) { + if (pVehicle->IsCar() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) + ++nNumCars; + if (pVehicle->IsBoat() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) + ++nNumBoats; + } + } + *size = nNumCars * (sizeof(uint32) + sizeof(int16) + sizeof(int32) + sizeof(CAutomobile)) + sizeof(int) + + nNumBoats * (sizeof(uint32) + sizeof(int16) + sizeof(int32) + sizeof(CBoat)) + sizeof(int); + WriteSaveBuf(buf, nNumCars); + WriteSaveBuf(buf, nNumBoats); + for (int i = 0; i < nPoolSize; i++) { + CVehicle* pVehicle = GetVehiclePool()->GetSlot(i); + if (!pVehicle) + continue; + bool bHasPassenger = false; + for (int j = 0; j < 8; j++) { + if (pVehicle->pPassengers[j]) + bHasPassenger = true; + } + if (!pVehicle->pDriver && !bHasPassenger) { + if (pVehicle->IsCar() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) { + WriteSaveBuf(buf, (uint32)pVehicle->m_vehType); + WriteSaveBuf(buf, pVehicle->m_modelIndex); + WriteSaveBuf(buf, GetVehicleRef(pVehicle)); + memcpy(buf, pVehicle, sizeof(CAutomobile)); + SkipSaveBuf(buf, sizeof(CAutomobile)); + } + if (pVehicle->IsBoat() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) { + WriteSaveBuf(buf, (uint32)pVehicle->m_vehType); + WriteSaveBuf(buf, pVehicle->m_modelIndex); + WriteSaveBuf(buf, GetVehicleRef(pVehicle)); + memcpy(buf, pVehicle, sizeof(CBoat)); + SkipSaveBuf(buf, sizeof(CBoat)); + } + } + } +VALIDATESAVEBUF(*size) +} + +void CPools::SaveObjectPool(uint8* buf, uint32* size) +{ +INITSAVEBUF + CProjectileInfo::RemoveAllProjectiles(); + CObject::DeleteAllTempObjects(); + int nObjects = 0; + int nPoolSize = GetObjectPool()->GetSize(); + for (int i = 0; i < nPoolSize; i++) { + CObject* pObject = GetObjectPool()->GetSlot(i); + if (!pObject) + continue; + if (pObject->ObjectCreatedBy == MISSION_OBJECT) + ++nObjects; + } + *size = nObjects * (sizeof(int16) + sizeof(int) + sizeof(CCompressedMatrixNotAligned) + sizeof(uint32) + + sizeof(float) + sizeof(CCompressedMatrixNotAligned) + sizeof(uint32) + sizeof(int8) + 7 * sizeof(bool) + sizeof(float) + + sizeof(int8) + sizeof(int8) + sizeof(uint32) + 2 * sizeof(uint32)) + sizeof(int); + WriteSaveBuf(buf, nObjects); + for (int i = 0; i < nPoolSize; i++) { + CObject* pObject = GetObjectPool()->GetSlot(i); + if (!pObject) + continue; + if (pObject->ObjectCreatedBy == MISSION_OBJECT) { + bool bIsPickup = pObject->bIsPickup; + bool bFlag2 = pObject->m_obj_flag2; + bool bOutOfStock = pObject->bOutOfStock; + bool bGlassCracked = pObject->bGlassCracked; + bool bGlassBroken = pObject->bGlassBroken; + bool bHasBeenDamaged = pObject->bHasBeenDamaged; + bool bUseVehicleColours = pObject->bUseVehicleColours; + CCompressedMatrixNotAligned tmp; + WriteSaveBuf(buf, pObject->m_modelIndex); + WriteSaveBuf(buf, GetObjectRef(pObject)); + tmp.CompressFromFullMatrix(pObject->GetMatrix()); + WriteSaveBuf(buf, tmp); + WriteSaveBuf(buf, (uint32)0); // game writes ununitialized data here + WriteSaveBuf(buf, pObject->m_fUprootLimit); + tmp.CompressFromFullMatrix(pObject->m_objectMatrix); + WriteSaveBuf(buf, tmp); + WriteSaveBuf(buf, (uint32)0); // same + WriteSaveBuf(buf, pObject->ObjectCreatedBy); + WriteSaveBuf(buf, bIsPickup); + WriteSaveBuf(buf, bFlag2); + WriteSaveBuf(buf, bOutOfStock); + WriteSaveBuf(buf, bGlassCracked); + WriteSaveBuf(buf, bGlassBroken); + WriteSaveBuf(buf, bHasBeenDamaged); + WriteSaveBuf(buf, bUseVehicleColours); + WriteSaveBuf(buf, pObject->m_fCollisionDamageMultiplier); + WriteSaveBuf(buf, pObject->m_nCollisionDamageEffect); + WriteSaveBuf(buf, pObject->m_nSpecialCollisionResponseCases); + WriteSaveBuf(buf, pObject->m_nEndOfLifeTime); + WriteSaveBuf(buf, (pObject->GetAddressOfEntityProperties())[0]); + WriteSaveBuf(buf, (pObject->GetAddressOfEntityProperties())[1]); + } + } +VALIDATESAVEBUF(*size) +} + +void CPools::LoadObjectPool(uint8* buf, uint32 size) +{ +INITSAVEBUF + int nObjects = ReadSaveBuf(buf); + for (int i = 0; i < nObjects; i++) { + int16 mi = ReadSaveBuf(buf); + int ref = ReadSaveBuf(buf); + char* obuf = new char[sizeof(CObject)]; + CObject* pBufferObject = (CObject*)obuf; + CCompressedMatrixNotAligned tmp; + tmp = ReadSaveBuf(buf); + tmp.DecompressIntoFullMatrix(pBufferObject->GetMatrix()); + ReadSaveBuf(buf); + pBufferObject->m_fUprootLimit = ReadSaveBuf(buf); + tmp = ReadSaveBuf(buf); + tmp.DecompressIntoFullMatrix(pBufferObject->m_objectMatrix); + ReadSaveBuf(buf); + pBufferObject->ObjectCreatedBy = ReadSaveBuf(buf); + pBufferObject->bIsPickup = ReadSaveBuf(buf); + pBufferObject->m_flagE2 = ReadSaveBuf(buf); + pBufferObject->bOutOfStock = ReadSaveBuf(buf); + pBufferObject->bGlassCracked = ReadSaveBuf(buf); + pBufferObject->bGlassBroken = ReadSaveBuf(buf); + pBufferObject->bHasBeenDamaged = ReadSaveBuf(buf); + pBufferObject->bUseVehicleColours = ReadSaveBuf(buf); + pBufferObject->m_fCollisionDamageMultiplier = ReadSaveBuf(buf); + pBufferObject->m_nCollisionDamageEffect = ReadSaveBuf(buf); + pBufferObject->m_nSpecialCollisionResponseCases = ReadSaveBuf(buf); + pBufferObject->m_nEndOfLifeTime = ReadSaveBuf(buf); + (pBufferObject->GetAddressOfEntityProperties())[0] = ReadSaveBuf(buf); + (pBufferObject->GetAddressOfEntityProperties())[1] = ReadSaveBuf(buf); + if (GetObjectPool()->GetSlot(ref >> 8)) + CPopulation::ConvertToDummyObject(GetObjectPool()->GetSlot(ref >> 8)); + CObject* pObject = new(ref) CObject(mi, false); + pObject->GetMatrix() = pBufferObject->GetMatrix(); + pObject->m_fUprootLimit = pBufferObject->m_fUprootLimit; + pObject->m_objectMatrix = pBufferObject->m_objectMatrix; + pObject->ObjectCreatedBy = pBufferObject->ObjectCreatedBy; + pObject->bIsPickup = pBufferObject->bIsPickup; + pObject->m_flagE2 = pBufferObject->m_flagE2; + pObject->bOutOfStock = pBufferObject->bOutOfStock; + pObject->bGlassCracked = pBufferObject->bGlassCracked; + pObject->bGlassBroken = pBufferObject->bGlassBroken; + pObject->bHasBeenDamaged = pBufferObject->bHasBeenDamaged; + pObject->bUseVehicleColours = pBufferObject->bUseVehicleColours; + pObject->m_fCollisionDamageMultiplier = pBufferObject->m_fCollisionDamageMultiplier; + pObject->m_nCollisionDamageEffect = pBufferObject->m_nCollisionDamageEffect; + pObject->m_nSpecialCollisionResponseCases = pBufferObject->m_nSpecialCollisionResponseCases; + pObject->m_nEndOfLifeTime = pBufferObject->m_nEndOfLifeTime; + (pObject->GetAddressOfEntityProperties())[0] = (pBufferObject->GetAddressOfEntityProperties())[0]; + (pObject->GetAddressOfEntityProperties())[1] = (pBufferObject->GetAddressOfEntityProperties())[1]; + pObject->bHasCollided = false; + CWorld::Add(pObject); + delete[] obuf; + } +VALIDATESAVEBUF(size) +} + +void CPools::SavePedPool(uint8* buf, uint32* size) +{ +INITSAVEBUF + int nNumPeds = 0; + int nPoolSize = GetPedPool()->GetSize(); + for (int i = 0; i < nPoolSize; i++) { + CPed* pPed = GetPedPool()->GetSlot(i); + if (!pPed) + continue; + if (!pPed->bInVehicle && pPed->m_nPedType == PEDTYPE_PLAYER1) + nNumPeds++; + } + *size = sizeof(int) + nNumPeds * (sizeof(uint32) + sizeof(int16) + sizeof(int) + sizeof(CPlayerPed) + + sizeof(CWanted::MaximumWantedLevel) + sizeof(CWanted::nMaximumWantedLevel) + MAX_MODEL_NAME); + WriteSaveBuf(buf, nNumPeds); + for (int i = 0; i < nPoolSize; i++) { + CPed* pPed = GetPedPool()->GetSlot(i); + if (!pPed) + continue; + if (!pPed->bInVehicle && pPed->m_nPedType == PEDTYPE_PLAYER1) { + WriteSaveBuf(buf, pPed->m_nPedType); + WriteSaveBuf(buf, pPed->m_modelIndex); + WriteSaveBuf(buf, GetPedRef(pPed)); + memcpy(buf, pPed, sizeof(CPlayerPed)); + SkipSaveBuf(buf, sizeof(CPlayerPed)); + WriteSaveBuf(buf, CWanted::MaximumWantedLevel); + WriteSaveBuf(buf, CWanted::nMaximumWantedLevel); + memcpy(buf, CModelInfo::GetModelInfo(pPed->GetModelIndex())->GetName(), MAX_MODEL_NAME); + SkipSaveBuf(buf, MAX_MODEL_NAME); + } + } +VALIDATESAVEBUF(*size); +} + +void CPools::LoadPedPool(uint8* buf, uint32 size) +{ +INITSAVEBUF + int nPeds = ReadSaveBuf(buf); + for (int i = 0; i < nPeds; i++) { + uint32 pedtype = ReadSaveBuf(buf); + int16 model = ReadSaveBuf(buf); + int ref = ReadSaveBuf(buf); + char* pbuf = new char[sizeof(CPlayerPed)]; + CPlayerPed* pBufferPlayer = (CPlayerPed*)pbuf; + CPed* pPed; + char name[MAX_MODEL_NAME]; + // the code implies that there was idea to load non-player ped + if (pedtype == PEDTYPE_PLAYER1) { // always true + memcpy(pbuf, buf, sizeof(CPlayerPed)); + SkipSaveBuf(buf, sizeof(CPlayerPed)); + CWanted::MaximumWantedLevel = ReadSaveBuf(buf); + CWanted::nMaximumWantedLevel = ReadSaveBuf(buf); + memcpy(name, buf, MAX_MODEL_NAME); + SkipSaveBuf(buf, MAX_MODEL_NAME); + } + CStreaming::RequestSpecialModel(model, name, STREAMFLAGS_DONT_REMOVE); + CStreaming::LoadAllRequestedModels(false); + if (pedtype == PEDTYPE_PLAYER1) { + CPlayerPed* pPlayerPed = new(ref) CPlayerPed(); + for (int i = 0; i < ARRAY_SIZE(pPlayerPed->m_nTargettableObjects); i++) + pPlayerPed->m_nTargettableObjects[i] = pBufferPlayer->m_nTargettableObjects[i]; + pPlayerPed->m_fMaxStamina = pBufferPlayer->m_fMaxStamina; + pPed = pPlayerPed; + } + pPed->GetPosition() = pBufferPlayer->GetPosition(); + pPed->m_fHealth = pBufferPlayer->m_fHealth; + pPed->m_fArmour = pBufferPlayer->m_fArmour; + pPed->CharCreatedBy = pBufferPlayer->CharCreatedBy; + pPed->m_currentWeapon = 0; + pPed->m_maxWeaponTypeAllowed = pBufferPlayer->m_maxWeaponTypeAllowed; + for (int i = 0; i < WEAPONTYPE_TOTAL_INVENTORY_WEAPONS; i++) + pPed->m_weapons[i] = pBufferPlayer->m_weapons[i]; + if (pedtype == PEDTYPE_PLAYER1) { + pPed->m_wepAccuracy = 100; + CWorld::Players[0].m_pPed = (CPlayerPed*)pPed; + } + CWorld::Add(pPed); + delete[] pbuf; + } +VALIDATESAVEBUF(size) +} STARTPATCHES InjectHook(0x4A1770, CPools::Initialise, PATCH_JUMP); @@ -111,4 +437,7 @@ STARTPATCHES InjectHook(0x4A1B00, CPools::GetObjectRef, PATCH_JUMP); InjectHook(0x4A1B20, CPools::GetObject, PATCH_JUMP); InjectHook(0x4A2DB0, CPools::MakeSureSlotInObjectPoolIsEmpty, PATCH_JUMP); + InjectHook(0x4A1B40, CPools::LoadVehiclePool, PATCH_JUMP); + InjectHook(0x4A2550, CPools::LoadObjectPool, PATCH_JUMP); + InjectHook(0x4A2B50, CPools::LoadPedPool, PATCH_JUMP); ENDPATCHES diff --git a/src/entities/Entity.h b/src/entities/Entity.h index 99cc7f17..e3a5333e 100644 --- a/src/entities/Entity.h +++ b/src/entities/Entity.h @@ -90,6 +90,7 @@ public: CReference *m_pFirstReference; CColModel *GetColModel(void) { return CModelInfo::GetModelInfo(m_modelIndex)->GetColModel(); } + uint32* GetAddressOfEntityProperties() { /* AWFUL */ return (uint32*)((char*)&m_rwObject + sizeof(m_rwObject)); } CEntity(void); ~CEntity(void); diff --git a/src/modelinfo/BaseModelInfo.h b/src/modelinfo/BaseModelInfo.h index a9bafb64..0c4bf934 100644 --- a/src/modelinfo/BaseModelInfo.h +++ b/src/modelinfo/BaseModelInfo.h @@ -2,6 +2,8 @@ #include "Collision.h" +#define MAX_MODEL_NAME (24) + enum ModeInfoType : uint8 { MITYPE_NA = 0, @@ -21,7 +23,7 @@ class CBaseModelInfo { protected: // TODO?: make more things protected - char m_name[24]; + char m_name[MAX_MODEL_NAME]; CColModel *m_colModel; C2dEffect *m_twodEffects; int16 m_objectId; diff --git a/src/objects/Object.cpp b/src/objects/Object.cpp index aa366aa0..ba9145a8 100644 --- a/src/objects/Object.cpp +++ b/src/objects/Object.cpp @@ -12,6 +12,7 @@ WRAPPER void CObject::DeleteAllTempObjectInArea(CVector, float) { EAXJMP(0x4BBED WRAPPER void CObject::Init(void) { EAXJMP(0x4BAEC0); } WRAPPER void CObject::ProcessControl(void) { EAXJMP(0x4BB040); } WRAPPER void CObject::Teleport(CVector) { EAXJMP(0x4BBDA0); } +WRAPPER void CObject::DeleteAllTempObjects() { EAXJMP(0x4BBDF0); } int16 &CObject::nNoTempObjects = *(int16*)0x95CCA2; int16 &CObject::nBodyCastHealth = *(int16*)0x5F7D4C; // 1000 diff --git a/src/objects/Object.h b/src/objects/Object.h index 27346e23..4adc7883 100644 --- a/src/objects/Object.h +++ b/src/objects/Object.h @@ -85,5 +85,6 @@ public: bool CanBeDeleted(void); static void DeleteAllTempObjectInArea(CVector, float); + static void DeleteAllTempObjects(); }; static_assert(sizeof(CObject) == 0x198, "CObject: error"); diff --git a/src/vehicles/Vehicle.h b/src/vehicles/Vehicle.h index c7be3674..d3664626 100644 --- a/src/vehicles/Vehicle.h +++ b/src/vehicles/Vehicle.h @@ -130,7 +130,8 @@ public: int8 m_nGettingInFlags; int8 m_nGettingOutFlags; uint8 m_nNumMaxPassengers; - char field_1CD[19]; + char field_1CD[3]; + float field_1D0[4]; CEntity *m_pCurGroundEntity; CFire *m_pCarFire; float m_fSteerAngle; -- cgit v1.2.3 From daceee593be76fe7d681e3b8c9101b02c058d186 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 11 Apr 2020 18:37:20 +0300 Subject: Link with RW libs --- premake5.lua | 22 +- src/core/NodeName.cpp | 77 ---- src/core/NodeName.h | 4 - src/core/RwClumpRead.cpp | 230 ---------- src/core/RwHelper.cpp | 374 ---------------- src/core/RwHelper.h | 40 -- src/core/RwMatFX.cpp | 213 ---------- src/core/RwTexRead.cpp | 345 --------------- src/core/TxdStore.cpp | 209 --------- src/core/TxdStore.h | 44 -- src/core/common.h | 2 + src/core/re3.cpp | 4 + src/core/rw.cpp | 415 ------------------ src/render/Lights.cpp | 333 --------------- src/render/Lights.h | 18 - src/render/VisibilityPlugins.cpp | 889 --------------------------------------- src/render/VisibilityPlugins.h | 133 ------ src/rw/ClumpRead.cpp | 230 ++++++++++ src/rw/Lights.cpp | 333 +++++++++++++++ src/rw/Lights.h | 18 + src/rw/NodeName.cpp | 77 ++++ src/rw/NodeName.h | 4 + src/rw/RwHelper.cpp | 374 ++++++++++++++++ src/rw/RwHelper.h | 40 ++ src/rw/RwMatFX.cpp | 213 ++++++++++ src/rw/TexRead.cpp | 349 +++++++++++++++ src/rw/TxdStore.cpp | 209 +++++++++ src/rw/TxdStore.h | 44 ++ src/rw/VisibilityPlugins.cpp | 889 +++++++++++++++++++++++++++++++++++++++ src/rw/VisibilityPlugins.h | 133 ++++++ src/rw/rw.cpp | 839 ++++++++++++++++++++++++++++++++++++ 31 files changed, 3779 insertions(+), 3325 deletions(-) delete mode 100644 src/core/NodeName.cpp delete mode 100644 src/core/NodeName.h delete mode 100644 src/core/RwClumpRead.cpp delete mode 100644 src/core/RwHelper.cpp delete mode 100644 src/core/RwHelper.h delete mode 100644 src/core/RwMatFX.cpp delete mode 100644 src/core/RwTexRead.cpp delete mode 100644 src/core/TxdStore.cpp delete mode 100644 src/core/TxdStore.h delete mode 100644 src/core/rw.cpp delete mode 100644 src/render/Lights.cpp delete mode 100644 src/render/Lights.h delete mode 100644 src/render/VisibilityPlugins.cpp delete mode 100644 src/render/VisibilityPlugins.h create mode 100644 src/rw/ClumpRead.cpp create mode 100644 src/rw/Lights.cpp create mode 100644 src/rw/Lights.h create mode 100644 src/rw/NodeName.cpp create mode 100644 src/rw/NodeName.h create mode 100644 src/rw/RwHelper.cpp create mode 100644 src/rw/RwHelper.h create mode 100644 src/rw/RwMatFX.cpp create mode 100644 src/rw/TexRead.cpp create mode 100644 src/rw/TxdStore.cpp create mode 100644 src/rw/TxdStore.h create mode 100644 src/rw/VisibilityPlugins.cpp create mode 100644 src/rw/VisibilityPlugins.h create mode 100644 src/rw/rw.cpp diff --git a/premake5.lua b/premake5.lua index 9e3609b6..4ec2eca1 100644 --- a/premake5.lua +++ b/premake5.lua @@ -1,5 +1,5 @@ workspace "re3" - configurations { "Debug", "Release", "ReleaseFH" } + configurations { "Debug", "Release", "ReleaseFH", "DebugRW", "ReleaseRW" } location "build" files { "src/*.*" } @@ -13,6 +13,7 @@ workspace "re3" files { "src/objects/*.*" } files { "src/peds/*.*" } files { "src/render/*.*" } + files { "src/rw/*.*" } files { "src/save/*.*" } files { "src/skel/*.*" } files { "src/skel/win/*.*" } @@ -32,6 +33,7 @@ workspace "re3" includedirs { "src/objects" } includedirs { "src/peds" } includedirs { "src/render" } + includedirs { "src/rw" } includedirs { "src/save/" } includedirs { "src/skel/" } includedirs { "src/skel/win" } @@ -47,6 +49,12 @@ workspace "re3" libdirs { "dxsdk/lib" } libdirs { "milessdk/lib" } + + filter "configurations:DebugRW or configurations:ReleaseRW" + defines { "RWLIBS" } + libdirs { "rwsdk/lib/d3d8/release" } + links { "rwcore", "rpworld", "rpmatfx", "rpskin", "rphanim", "rtbmp" } + filter {} pbcommands = { "setlocal EnableDelayedExpansion", @@ -102,3 +110,15 @@ project "re3" staticruntime "on" targetextension ".asi" setpaths("$(GTA_III_RE_DIR)/", "gta3.exe", "scripts/") + + filter "configurations:DebugRW" + defines { "DEBUG" } + staticruntime "on" + symbols "On" + setpaths("$(GTA_III_RE_DIR)/", "gta3.exe", "plugins/") + + filter "configurations:ReleaseRW" + defines { "NDEBUG" } + optimize "On" + staticruntime "on" + setpaths("$(GTA_III_RE_DIR)/", "gta3.exe", "plugins/") diff --git a/src/core/NodeName.cpp b/src/core/NodeName.cpp deleted file mode 100644 index 2aea3c83..00000000 --- a/src/core/NodeName.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include "common.h" -#include "patcher.h" -#include "NodeName.h" - -static int32 &gPluginOffset = *(int32*)0x64C610; - -enum -{ - ID_NODENAME = MAKECHUNKID(rwVENDORID_ROCKSTAR, 0xFE), -}; - -#define NODENAMEEXT(o) (RWPLUGINOFFSET(char, o, gPluginOffset)) - -void* -NodeNameConstructor(void *object, RwInt32 offsetInObject, RwInt32 sizeInObject) -{ - if(gPluginOffset > 0) - NODENAMEEXT(object)[0] = '\0'; - return object; -} - -void* -NodeNameDestructor(void *object, RwInt32 offsetInObject, RwInt32 sizeInObject) -{ - return object; -} - -void* -NodeNameCopy(void *dstObject, const void *srcObject, RwInt32 offsetInObject, RwInt32 sizeInObject) -{ - strncpy(NODENAMEEXT(dstObject), NODENAMEEXT(srcObject), 23); - return nil; -} - -RwStream* -NodeNameStreamRead(RwStream *stream, RwInt32 binaryLength, void *object, RwInt32 offsetInObject, RwInt32 sizeInObject) -{ - RwStreamRead(stream, NODENAMEEXT(object), binaryLength); - NODENAMEEXT(object)[binaryLength] = '\0'; - return stream; -} - -RwStream* -NodeNameStreamWrite(RwStream *stream, RwInt32 binaryLength, const void *object, RwInt32 offsetInObject, RwInt32 sizeInObject) -{ - RwStreamWrite(stream, NODENAMEEXT(object), binaryLength); - return stream; -} - -RwInt32 -NodeNameStreamGetSize(const void *object, RwInt32 offsetInObject, RwInt32 sizeInObject) -{ - // game checks for null pointer on node name extension but that really happen - return rwstrlen(NODENAMEEXT(object)); -} - -bool -NodeNamePluginAttach(void) -{ - gPluginOffset = RwFrameRegisterPlugin(24, ID_NODENAME, - NodeNameConstructor, - NodeNameDestructor, - NodeNameCopy); - RwFrameRegisterPluginStream(ID_NODENAME, - NodeNameStreamRead, - NodeNameStreamWrite, - NodeNameStreamGetSize); - return gPluginOffset != -1; -} - -char* -GetFrameNodeName(RwFrame *frame) -{ - if(gPluginOffset < 0) - return nil; - return NODENAMEEXT(frame); -} diff --git a/src/core/NodeName.h b/src/core/NodeName.h deleted file mode 100644 index 1a3e057b..00000000 --- a/src/core/NodeName.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -bool NodeNamePluginAttach(void); -char *GetFrameNodeName(RwFrame *frame); diff --git a/src/core/RwClumpRead.cpp b/src/core/RwClumpRead.cpp deleted file mode 100644 index c9f027e7..00000000 --- a/src/core/RwClumpRead.cpp +++ /dev/null @@ -1,230 +0,0 @@ -#include "common.h" -#include "patcher.h" - -struct rpGeometryList -{ - RpGeometry **geometries; - int32 numGeoms; -}; - -struct rpAtomicBinary -{ - RwInt32 frameIndex; - RwInt32 geomIndex; - RwInt32 flags; - RwInt32 unused; -}; - -static int32 numberGeometrys; -static int32 streamPosition; -static rpGeometryList gGeomList; -static rwFrameList gFrameList; -static RpClumpChunkInfo gClumpInfo; - -rpGeometryList* -GeometryListStreamRead1(RwStream *stream, rpGeometryList *geomlist) -{ - int i; - RwUInt32 size, version; - RwInt32 numGeoms; - - numberGeometrys = 0; - if(!RwStreamFindChunk(stream, rwID_STRUCT, &size, &version)) - return nil; - assert(size == 4); - if(RwStreamRead(stream, &numGeoms, 4) != 4) - return nil; - - numberGeometrys = numGeoms/2; - geomlist->numGeoms = numGeoms; - if(geomlist->numGeoms > 0){ - geomlist->geometries = (RpGeometry**)RwMalloc(geomlist->numGeoms * sizeof(RpGeometry*)); - if(geomlist->geometries == nil) - return nil; - memset(geomlist->geometries, 0, geomlist->numGeoms * sizeof(RpGeometry*)); - }else - geomlist->geometries = nil; - - for(i = 0; i < numberGeometrys; i++){ - if(!RwStreamFindChunk(stream, rwID_GEOMETRY, nil, &version)) - return nil; - geomlist->geometries[i] = RpGeometryStreamRead(stream); - if(geomlist->geometries[i] == nil) - return nil; - } - - return geomlist; -} - -rpGeometryList* -GeometryListStreamRead2(RwStream *stream, rpGeometryList *geomlist) -{ - int i; - RwUInt32 version; - - for(i = numberGeometrys; i < geomlist->numGeoms; i++){ - if(!RwStreamFindChunk(stream, rwID_GEOMETRY, nil, &version)) - return nil; - geomlist->geometries[i] = RpGeometryStreamRead(stream); - if(geomlist->geometries[i] == nil) - return nil; - } - - return geomlist; -} - -void -GeometryListDeinitialize(rpGeometryList *geomlist) -{ - int i; - - for(i = 0; i < geomlist->numGeoms; i++) - if(geomlist->geometries[i]) - RpGeometryDestroy(geomlist->geometries[i]); - - if(geomlist->numGeoms){ - RwFree(geomlist->geometries); - geomlist->numGeoms = 0; - } -} - -RpAtomic* -ClumpAtomicStreamRead(RwStream *stream, rwFrameList *frmList, rpGeometryList *geomList) -{ - RwUInt32 size, version; - rpAtomicBinary a; - RpAtomic *atomic; - - numberGeometrys = 0; - if(!RwStreamFindChunk(stream, rwID_STRUCT, &size, &version)) - return nil; - assert(size <= sizeof(rpAtomicBinary)); - if(RwStreamRead(stream, &a, size) != size) - return nil; - - atomic = RpAtomicCreate(); - if(atomic == nil) - return nil; - - RpAtomicSetFlags(atomic, a.flags); - - if(frmList->numFrames){ - assert(a.frameIndex < frmList->numFrames); - RpAtomicSetFrame(atomic, frmList->frames[a.frameIndex]); - } - - if(geomList->numGeoms){ - assert(a.geomIndex < geomList->numGeoms); - RpAtomicSetGeometry(atomic, geomList->geometries[a.geomIndex], 0); - }else{ - RpGeometry *geom; - if(!RwStreamFindChunk(stream, rwID_GEOMETRY, nil, &version)){ - RpAtomicDestroy(atomic); - return nil; - } - geom = RpGeometryStreamRead(stream); - if(geom == nil){ - RpAtomicDestroy(atomic); - return nil; - } - RpAtomicSetGeometry(atomic, geom, 0); - RpGeometryDestroy(geom); - } - - return atomic; -} - -bool -RpClumpGtaStreamRead1(RwStream *stream) -{ - RwUInt32 size, version; - - if(!RwStreamFindChunk(stream, rwID_STRUCT, &size, &version)) - return false; - if(version >= 0x33000){ - assert(size == 12); - if(RwStreamRead(stream, &gClumpInfo, 12) != 12) - return false; - }else{ - assert(size == 4); - if(RwStreamRead(stream, &gClumpInfo, 4) != 4) - return false; - } - - if(!RwStreamFindChunk(stream, rwID_FRAMELIST, nil, &version)) - return false; - if(_rwFrameListStreamRead(stream, &gFrameList) == nil) - return false; - - if(!RwStreamFindChunk(stream, rwID_GEOMETRYLIST, nil, &version)){ - rwFrameListDeinitialize(&gFrameList); - return false; - } - if(GeometryListStreamRead1(stream, &gGeomList) == nil){ - rwFrameListDeinitialize(&gFrameList); - return false; - } - streamPosition = stream->Type.memory.position; - return true; -} - -RpClump* -RpClumpGtaStreamRead2(RwStream *stream) -{ - int i; - RwUInt32 version; - RpAtomic *atomic; - RpClump *clump; - - clump = RpClumpCreate(); - if(clump == nil) - return nil; - - RwStreamSkip(stream, streamPosition - stream->Type.memory.position); - - if(GeometryListStreamRead2(stream, &gGeomList) == nil){ - GeometryListDeinitialize(&gGeomList); - rwFrameListDeinitialize(&gFrameList); - RpClumpDestroy(clump); - return nil; - } - - RpClumpSetFrame(clump, gFrameList.frames[0]); - - for(i = 0; i < gClumpInfo.numAtomics; i++){ - if(!RwStreamFindChunk(stream, rwID_ATOMIC, nil, &version)){ - GeometryListDeinitialize(&gGeomList); - rwFrameListDeinitialize(&gFrameList); - RpClumpDestroy(clump); - return nil; - } - - atomic = ClumpAtomicStreamRead(stream, &gFrameList, &gGeomList); - if(atomic == nil){ - GeometryListDeinitialize(&gGeomList); - rwFrameListDeinitialize(&gFrameList); - RpClumpDestroy(clump); - return nil; - } - - RpClumpAddAtomic(clump, atomic); - } - - GeometryListDeinitialize(&gGeomList); - rwFrameListDeinitialize(&gFrameList); - return clump; -} - -void -RpClumpGtaCancelStream(void) -{ - GeometryListDeinitialize(&gGeomList); - rwFrameListDeinitialize(&gFrameList); - gFrameList.numFrames = 0; -} - -STARTPATCHES - InjectHook(0x526060, RpClumpGtaStreamRead1, PATCH_JUMP); - InjectHook(0x526180, RpClumpGtaStreamRead2, PATCH_JUMP); - InjectHook(0x5262D0, RpClumpGtaCancelStream, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/RwHelper.cpp b/src/core/RwHelper.cpp deleted file mode 100644 index 44866f4f..00000000 --- a/src/core/RwHelper.cpp +++ /dev/null @@ -1,374 +0,0 @@ -#define WITHD3D -#include "common.h" -#include "patcher.h" -#include "Timecycle.h" -#include "skeleton.h" - -void * -RwMallocAlign(RwUInt32 size, RwUInt32 align) -{ - void *mem = (void *)malloc(size + align); - - ASSERT(mem != nil); - - void *addr = (void *)((((RwUInt32)mem) + align) & ~(align - 1)); - - ASSERT(addr != nil); - - *(((void **)addr) - 1) = mem; - - return addr; -} - -void -RwFreeAlign(void *mem) -{ - ASSERT(mem != nil); - - void *addr = *(((void **)mem) - 1); - - ASSERT(addr != nil); - - free(addr); -} - -void -DefinedState(void) -{ - RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void*)rwTEXTUREADDRESSWRAP); - RwRenderStateSet(rwRENDERSTATETEXTUREPERSPECTIVE, (void*)TRUE); - RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE); - RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE); - RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEGOURAUD); - RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); - RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE); - RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); - RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); - RwRenderStateSet(rwRENDERSTATEALPHAPRIMITIVEBUFFER, (void*)FALSE); - RwRenderStateSet(rwRENDERSTATEBORDERCOLOR, (void*)RWRGBALONG(0, 0, 0, 255)); - RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE); - RwRenderStateSet(rwRENDERSTATEFOGCOLOR, - (void*)RWRGBALONG(CTimeCycle::GetFogRed(), CTimeCycle::GetFogGreen(), CTimeCycle::GetFogBlue(), 255)); - RwRenderStateSet(rwRENDERSTATEFOGTYPE, (void*)rwFOGTYPELINEAR); - RwRenderStateSet(rwRENDERSTATECULLMODE, (void*)rwCULLMODECULLNONE); - - // D3D stuff - RwD3D8SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER); - RwD3D8SetRenderState(D3DRS_ALPHAREF, 2); -} - -RwFrame* -GetFirstFrameCallback(RwFrame *child, void *data) -{ - *(RwFrame**)data = child; - return nil; -} - -RwFrame* -GetFirstChild(RwFrame *frame) -{ - RwFrame *child; - - child = nil; - RwFrameForAllChildren(frame, GetFirstFrameCallback, &child); - return child; -} - -RwObject* -GetFirstObjectCallback(RwObject *object, void *data) -{ - *(RwObject**)data = object; - return nil; -} - -RwObject* -GetFirstObject(RwFrame *frame) -{ - RwObject *obj; - - obj = nil; - RwFrameForAllObjects(frame, GetFirstObjectCallback, &obj); - return obj; -} - -RpAtomic* -GetFirstAtomicCallback(RpAtomic *atm, void *data) -{ - *(RpAtomic**)data = atm; - return nil; -} - -RpAtomic* -GetFirstAtomic(RpClump *clump) -{ - RpAtomic *atm; - - atm = nil; - RpClumpForAllAtomics(clump, GetFirstAtomicCallback, &atm); - return atm; -} - -RwTexture* -GetFirstTextureCallback(RwTexture *tex, void *data) -{ - *(RwTexture**)data = tex; - return nil; -} - -RwTexture* -GetFirstTexture(RwTexDictionary *txd) -{ - RwTexture *tex; - - tex = nil; - RwTexDictionaryForAllTextures(txd, GetFirstTextureCallback, &tex); - return tex; -} - -void -CameraSize(RwCamera * camera, RwRect * rect, - RwReal viewWindow, RwReal aspectRatio) -{ - if (camera) - { - RwVideoMode videoMode; - RwRect r; - RwRect origSize = { 0, 0, 0, 0 }; // FIX just to make the compier happy - RwV2d vw; - - RwEngineGetVideoModeInfo(&videoMode, - RwEngineGetCurrentVideoMode()); - - origSize.w = RwRasterGetWidth(RwCameraGetRaster(camera)); - origSize.h = RwRasterGetHeight(RwCameraGetRaster(camera)); - - if (!rect) - { - if (videoMode.flags & rwVIDEOMODEEXCLUSIVE) - { - /* For full screen applications, resizing the camera just doesn't - * make sense, use the video mode size. - */ - - r.x = r.y = 0; - r.w = videoMode.width; - r.h = videoMode.height; - rect = &r; - } - else - { - /* - rect not specified - reuse current values - */ - r.w = RwRasterGetWidth(RwCameraGetRaster(camera)); - r.h = RwRasterGetHeight(RwCameraGetRaster(camera)); - r.x = r.y = 0; - rect = &r; - } - } - - if (( origSize.w != rect->w ) && ( origSize.h != rect->h )) - { - RwRaster *raster; - RwRaster *zRaster; - - /* - * Destroy rasters... - */ - - raster = RwCameraGetRaster(camera); - if( raster ) - { - RwRasterDestroy(raster); - } - - zRaster = RwCameraGetZRaster(camera); - if( zRaster ) - { - RwRasterDestroy(zRaster); - } - - /* - * Create new rasters... - */ - - raster = RwRasterCreate(rect->w, rect->h, 0, rwRASTERTYPECAMERA); - zRaster = RwRasterCreate(rect->w, rect->h, 0, rwRASTERTYPEZBUFFER); - - if( raster && zRaster ) - { - RwCameraSetRaster(camera, raster); - RwCameraSetZRaster(camera, zRaster); - } - else - { - if( raster ) - { - RwRasterDestroy(raster); - } - - if( zRaster ) - { - RwRasterDestroy(zRaster); - } - - rect->x = origSize.x; - rect->y = origSize.y; - rect->w = origSize.w; - rect->h = origSize.h; - - /* - * Use default values... - */ - raster = - RwRasterCreate(rect->w, rect->h, 0, rwRASTERTYPECAMERA); - - zRaster = - RwRasterCreate(rect->w, rect->h, 0, rwRASTERTYPEZBUFFER); - - RwCameraSetRaster(camera, raster); - RwCameraSetZRaster(camera, zRaster); - } - } - - /* Figure out the view window */ - if (videoMode.flags & rwVIDEOMODEEXCLUSIVE) - { - /* derive ratio from aspect ratio */ - vw.x = viewWindow; - vw.y = viewWindow / aspectRatio; - } - else - { - /* derive from pixel ratios */ - if (rect->w > rect->h) - { - vw.x = viewWindow; - vw.y = (rect->h * viewWindow) / rect->w; - } - else - { - vw.x = (rect->w * viewWindow) / rect->h; - vw.y = viewWindow; - } - } - - RwCameraSetViewWindow(camera, &vw); - - RsGlobal.width = rect->w; - RsGlobal.height = rect->h; - } - - return; -} - -void -CameraDestroy(RwCamera *camera) -{ - RwRaster *raster, *tmpRaster; - RwFrame *frame; - - if (camera) - { - frame = RwCameraGetFrame(camera); - if (frame) - { - RwFrameDestroy(frame); - } - - raster = RwCameraGetRaster(camera); - if (raster) - { - tmpRaster = RwRasterGetParent(raster); - - RwRasterDestroy(raster); - - if ((tmpRaster != nil) && (tmpRaster != raster)) - { - RwRasterDestroy(tmpRaster); - } - } - - raster = RwCameraGetZRaster(camera); - if (raster) - { - tmpRaster = RwRasterGetParent(raster); - - RwRasterDestroy(raster); - - if ((tmpRaster != nil) && (tmpRaster != raster)) - { - RwRasterDestroy(tmpRaster); - } - } - - RwCameraDestroy(camera); - } - - return; -} - -RwCamera * -CameraCreate(RwInt32 width, RwInt32 height, RwBool zBuffer) -{ - RwCamera *camera; - - camera = RwCameraCreate(); - - if (camera) - { - RwCameraSetFrame(camera, RwFrameCreate()); - RwCameraSetRaster(camera, - RwRasterCreate(0, 0, 0, rwRASTERTYPECAMERA)); - - if (zBuffer) - { - RwCameraSetZRaster(camera, - RwRasterCreate(0, 0, 0, - rwRASTERTYPEZBUFFER)); - } - - /* now check that everything is valid */ - if (RwCameraGetFrame(camera) && - RwCameraGetRaster(camera) && - RwRasterGetParent(RwCameraGetRaster(camera)) && - (!zBuffer || (RwCameraGetZRaster(camera) && - RwRasterGetParent(RwCameraGetZRaster - (camera))))) - { - /* everything OK */ - return (camera); - } - } - - /* if we're here then an error must have occurred so clean up */ - - CameraDestroy(camera); - return (nil); -} - -void CreateDebugFont() -{ - ; -} - -void DestroyDebugFont() -{ - ; -} - -void FlushObrsPrintfs() -{ - ; -} - -WRAPPER void _TexturePoolsInitialise() { EAXJMP(0x598B10); } -WRAPPER void _TexturePoolsShutdown() { EAXJMP(0x598B30); } - -STARTPATCHES - //InjectHook(0x526450, GetFirstObjectCallback, PATCH_JUMP); - InjectHook(0x526460, GetFirstObject, PATCH_JUMP); - InjectHook(0x527170, CameraSize, PATCH_JUMP); - InjectHook(0x527340, CameraDestroy, PATCH_JUMP); - InjectHook(0x5273B0, CameraCreate, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/RwHelper.h b/src/core/RwHelper.h deleted file mode 100644 index a9f0bdf4..00000000 --- a/src/core/RwHelper.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -void *RwMallocAlign(RwUInt32 size, RwUInt32 align); -void RwFreeAlign(void *mem); - -void CreateDebugFont(); -void DestroyDebugFont(); -void FlushObrsPrintfs(); -void DefinedState(void); -RwFrame *GetFirstChild(RwFrame *frame); -RwObject *GetFirstObject(RwFrame *frame); -RpAtomic *GetFirstAtomic(RpClump *clump); -RwTexture *GetFirstTexture(RwTexDictionary *txd); - -RwTexDictionary *RwTexDictionaryGtaStreamRead(RwStream *stream); -RwTexDictionary *RwTexDictionaryGtaStreamRead1(RwStream *stream); -RwTexDictionary *RwTexDictionaryGtaStreamRead2(RwStream *stream, RwTexDictionary *texDict); -void ReadVideoCardCapsFile(uint32&, uint32&, uint32&, uint32&); -bool CheckVideoCardCaps(void); -void WriteVideoCardCapsFile(void); -void ConvertingTexturesScreen(uint32, uint32, const char*); -void DealWithTxdWriteError(uint32, uint32, const char*); -bool CreateTxdImageForVideoCard(); - -bool RpClumpGtaStreamRead1(RwStream *stream); -RpClump *RpClumpGtaStreamRead2(RwStream *stream); -void RpClumpGtaCancelStream(void); - -void CameraSize(RwCamera *camera, - RwRect *rect, - RwReal viewWindow, - RwReal aspectRatio); -void CameraDestroy(RwCamera *camera); -RwCamera *CameraCreate(RwInt32 width, - RwInt32 height, - RwBool zBuffer); - - -void _TexturePoolsInitialise(); -void _TexturePoolsShutdown(); \ No newline at end of file diff --git a/src/core/RwMatFX.cpp b/src/core/RwMatFX.cpp deleted file mode 100644 index ca9a633b..00000000 --- a/src/core/RwMatFX.cpp +++ /dev/null @@ -1,213 +0,0 @@ -#define WITHD3D -#include "common.h" -#include "patcher.h" - -struct MatFXNothing { int pad[5]; int effect; }; - -struct MatFXBump -{ - RwFrame *bumpFrame; - RwTexture *bumpedTex; - RwTexture *bumpTex; - float negBumpCoefficient; - int pad; - int effect; -}; - -struct MatFXEnv -{ - RwFrame *envFrame; - RwTexture *envTex; - float envCoeff; - int envFBalpha; - int pad; - int effect; -}; - -struct MatFXDual -{ - RwTexture *dualTex; - RwInt32 srcBlend; - RwInt32 dstBlend; -}; - - -struct MatFX -{ - union { - MatFXNothing n; - MatFXBump b; - MatFXEnv e; - MatFXDual d; - } fx[2]; - int effects; -}; - -int &MatFXMaterialDataOffset = *(int*)0x66188C; -int &MatFXAtomicDataOffset = *(int*)0x66189C; - -#ifdef PS2_MATFX - -void -_rpMatFXD3D8AtomicMatFXDefaultRender(RxD3D8InstanceData *inst, int flags, RwTexture *texture) -{ - if(flags & (rpGEOMETRYTEXTURED|rpGEOMETRYTEXTURED2) && texture) - RwD3D8SetTexture(texture, 0); - else - RwD3D8SetTexture(nil, 0); - RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)(inst->vertexAlpha || inst->material->color.alpha != 0xFF)); - RwD3D8SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, inst->vertexAlpha != 0); - RwD3D8SetPixelShader(0); - RwD3D8SetVertexShader(inst->vertexShader); - RwD3D8SetStreamSource(0, inst->vertexBuffer, inst->stride); - - if(inst->indexBuffer){ - RwD3D8SetIndices(inst->indexBuffer, inst->baseIndex); - RwD3D8DrawIndexedPrimitive(inst->primType, 0, inst->numVertices, 0, inst->numIndices); - }else - RwD3D8DrawPrimitive(inst->primType, inst->baseIndex, inst->numVertices); -} - -// map [-1; -1] -> [0; 1], flip V -static RwMatrix scalenormal = { - { 0.5f, 0.0f, 0.0f }, 0, - { 0.0f, -0.5f, 0.0f }, 0, - { 0.0f, 0.0f, 1.0f }, 0, - { 0.5f, 0.5f, 0.0f }, 0, - -}; - -// flipped U for PS2 -static RwMatrix scalenormal_flipU = { - { -0.5f, 0.0f, 0.0f }, 0, - { 0.0f, -0.5f, 0.0f }, 0, - { 0.0f, 0.0f, 1.0f }, 0, - { 0.5f, 0.5f, 0.0f }, 0, - -}; - -void -ApplyEnvMapTextureMatrix(RwTexture *tex, int n, RwFrame *frame) -{ - RwD3D8SetTexture(tex, n); - RwD3D8SetTextureStageState(n, D3DRS_ALPHAREF, 2); - RwD3D8SetTextureStageState(n, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACENORMAL); - if(frame){ - RwMatrix *envframemat = RwMatrixCreate(); - RwMatrix *tmpmat = RwMatrixCreate(); - RwMatrix *envmat = RwMatrixCreate(); - - RwMatrixInvert(envframemat, RwFrameGetLTM(frame)); - // PS2 - // can this be simplified? - *tmpmat = *RwFrameGetLTM(RwCameraGetFrame((RwCamera*)RWSRCGLOBAL(curCamera))); - RwV3dNegate(&tmpmat->right, &tmpmat->right); - tmpmat->flags = 0; - tmpmat->pos.x = 0.0f; - tmpmat->pos.y = 0.0f; - tmpmat->pos.z = 0.0f; - RwMatrixMultiply(envmat, tmpmat, envframemat); - *tmpmat = *envmat; - // important because envframemat can have a translation that we don't like - tmpmat->pos.x = 0.0f; - tmpmat->pos.y = 0.0f; - tmpmat->pos.z = 0.0f; - // for some reason we flip in U as well - RwMatrixMultiply(envmat, tmpmat, &scalenormal_flipU); - - RwD3D8SetTransform(D3DTS_TEXTURE0+n, envmat); - - RwMatrixDestroy(envmat); - RwMatrixDestroy(tmpmat); - RwMatrixDestroy(envframemat); - }else - RwD3D8SetTransform(D3DTS_TEXTURE0+n, &scalenormal); -} - -void -_rpMatFXD3D8AtomicMatFXEnvRender_ps2(RxD3D8InstanceData *inst, int flags, int sel, RwTexture *texture, RwTexture *envMap) -{ - MatFX *matfx = *RWPLUGINOFFSET(MatFX*, inst->material, MatFXMaterialDataOffset); - MatFXEnv *env = &matfx->fx[sel].e; - - uint8 intens = (uint8)(env->envCoeff*255.0f); - - if(intens == 0 || envMap == nil){ - if(sel == 0) - _rpMatFXD3D8AtomicMatFXDefaultRender(inst, flags, texture); - return; - } - - RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)(inst->vertexAlpha || inst->material->color.alpha != 0xFF)); - if(flags & (rpGEOMETRYTEXTURED|rpGEOMETRYTEXTURED2) && texture) - RwD3D8SetTexture(texture, 0); - else - RwD3D8SetTexture(nil, 0); - RwD3D8SetPixelShader(0); - RwD3D8SetVertexShader(inst->vertexShader); - RwD3D8SetStreamSource(0, inst->vertexBuffer, inst->stride); - RwD3D8SetIndices(inst->indexBuffer, inst->baseIndex); - if(inst->indexBuffer) - RwD3D8DrawIndexedPrimitive(inst->primType, 0, inst->numVertices, 0, inst->numIndices); - else - RwD3D8DrawPrimitive(inst->primType, inst->baseIndex, inst->numVertices); - - // Effect pass - - ApplyEnvMapTextureMatrix(envMap, 0, env->envFrame); - RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); - RwUInt32 src, dst, lighting, zwrite, fog, fogcol; - RwRenderStateGet(rwRENDERSTATESRCBLEND, &src); - RwRenderStateGet(rwRENDERSTATEDESTBLEND, &dst); - - // This is of course not using framebuffer alpha, - // but if the diffuse texture had no alpha, the result should actually be rather the same - if(env->envFBalpha) - RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); - else - RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDONE); - RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE); - RwD3D8GetRenderState(D3DRS_LIGHTING, &lighting); - RwD3D8GetRenderState(D3DRS_ZWRITEENABLE, &zwrite); - RwD3D8GetRenderState(D3DRS_FOGENABLE, &fog); - RwD3D8SetRenderState(D3DRS_ZWRITEENABLE, FALSE); - if(fog){ - RwD3D8GetRenderState(D3DRS_FOGCOLOR, &fogcol); - RwD3D8SetRenderState(D3DRS_FOGCOLOR, 0); - } - - D3DCOLOR texfactor = D3DCOLOR_RGBA(intens, intens, intens, intens); - RwD3D8SetRenderState(D3DRS_TEXTUREFACTOR, texfactor); - RwD3D8SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE); - RwD3D8SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_CURRENT); - RwD3D8SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_TFACTOR); - // alpha unused - //RwD3D8SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); - //RwD3D8SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_CURRENT); - //RwD3D8SetTextureStageState(1, D3DTSS_ALPHAARG2, D3DTA_TFACTOR); - - if(inst->indexBuffer) - RwD3D8DrawIndexedPrimitive(inst->primType, 0, inst->numVertices, 0, inst->numIndices); - else - RwD3D8DrawPrimitive(inst->primType, inst->baseIndex, inst->numVertices); - - // Reset states - - RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE); - RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)src); - RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)dst); - RwD3D8SetRenderState(D3DRS_LIGHTING, lighting); - RwD3D8SetRenderState(D3DRS_ZWRITEENABLE, zwrite); - if(fog) - RwD3D8SetRenderState(D3DRS_FOGCOLOR, fogcol); - RwD3D8SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - RwD3D8SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - RwD3D8SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, 0); - RwD3D8SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0); -} - -STARTPATCHES - InjectHook(0x5CF6C0, _rpMatFXD3D8AtomicMatFXEnvRender_ps2, PATCH_JUMP); -ENDPATCHES - -#endif diff --git a/src/core/RwTexRead.cpp b/src/core/RwTexRead.cpp deleted file mode 100644 index 49b245dd..00000000 --- a/src/core/RwTexRead.cpp +++ /dev/null @@ -1,345 +0,0 @@ -#pragma warning( push ) -#pragma warning( disable : 4005) -#define DIRECTINPUT_VERSION 0x0800 -#include -#pragma warning( pop ) -#define WITHWINDOWS -#include "common.h" -#include "win.h" -#include "patcher.h" -#include "Timer.h" -#ifdef GTA_PC -#include "FileMgr.h" -#include "Pad.h" -#include "main.h" -#include "Directory.h" -#include "Streaming.h" -#include "TxdStore.h" -#include "CdStream.h" -#include "Font.h" -#include "Sprite2d.h" -#include "Text.h" -#include "RwHelper.h" -#endif //GTA_PC - -float &texLoadTime = *(float*)0x8F1B50; -int32 &texNumLoaded = *(int32*)0x8F252C; - -RwTexture* -RwTextureGtaStreamRead(RwStream *stream) -{ - RwUInt32 size, version; - RwTexture *tex; - - if(!RwStreamFindChunk(stream, rwID_TEXTURENATIVE, &size, &version)) - return nil; - - float preloadTime = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond(); - - if(!RWSRCGLOBAL(stdFunc[rwSTANDARDNATIVETEXTUREREAD](stream, &tex, size))) - return nil; - - if (gGameState == GS_INIT_PLAYING_GAME) { - texLoadTime = (texNumLoaded * texLoadTime + (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond() - preloadTime) / (float)(texNumLoaded+1); - texNumLoaded++; - } - return tex; -} - -RwTexture* -destroyTexture(RwTexture *texture, void *data) -{ - RwTextureDestroy(texture); - return texture; -} - -RwTexDictionary* -RwTexDictionaryGtaStreamRead(RwStream *stream) -{ - RwUInt32 size, version; - RwInt32 numTextures; - RwTexDictionary *texDict; - RwTexture *tex; - - if(!RwStreamFindChunk(stream, rwID_STRUCT, &size, &version)) - return nil; - assert(size == 4); - if(RwStreamRead(stream, &numTextures, size) != size) - return nil; - - texDict = RwTexDictionaryCreate(); - if(texDict == nil) - return nil; - - while(numTextures--){ - tex = RwTextureGtaStreamRead(stream); - if(tex == nil){ - RwTexDictionaryForAllTextures(texDict, destroyTexture, nil); - RwTexDictionaryDestroy(texDict); - return nil; - } - RwTexDictionaryAddTexture(texDict, tex); - } - - return texDict; -} - -static int32 numberTextures = -1; -static int32 streamPosition; - -RwTexDictionary* -RwTexDictionaryGtaStreamRead1(RwStream *stream) -{ - RwUInt32 size, version; - RwInt32 numTextures; - RwTexDictionary *texDict; - RwTexture *tex; - - numberTextures = 0; - if(!RwStreamFindChunk(stream, rwID_STRUCT, &size, &version)) - return nil; - assert(size == 4); - if(RwStreamRead(stream, &numTextures, size) != size) - return nil; - - texDict = RwTexDictionaryCreate(); - if(texDict == nil) - return nil; - - numberTextures = numTextures/2; - - while(numTextures > numberTextures){ - numTextures--; - - tex = RwTextureGtaStreamRead(stream); - if(tex == nil){ - RwTexDictionaryForAllTextures(texDict, destroyTexture, nil); - RwTexDictionaryDestroy(texDict); - return nil; - } - RwTexDictionaryAddTexture(texDict, tex); - } - - numberTextures = numTextures; - streamPosition = stream->Type.memory.position; - - return texDict; -} - -RwTexDictionary* -RwTexDictionaryGtaStreamRead2(RwStream *stream, RwTexDictionary *texDict) -{ - RwTexture *tex; - - RwStreamSkip(stream, streamPosition - stream->Type.memory.position); - - while(numberTextures--){ - tex = RwTextureGtaStreamRead(stream); - if(tex == nil){ - RwTexDictionaryForAllTextures(texDict, destroyTexture, nil); - RwTexDictionaryDestroy(texDict); - return nil; - } - RwTexDictionaryAddTexture(texDict, tex); - } - - return texDict; -} - -#ifdef GTA_PC -WRAPPER RwInt32 _rwD3D8FindCorrectRasterFormat(RwRasterType type, RwInt32 flags) { EAXJMP(0x59A350); } - -void -ReadVideoCardCapsFile(uint32 &cap32, uint32 &cap24, uint32 &cap16, uint32 &cap8) -{ - cap32 = UINT32_MAX; - cap24 = UINT32_MAX; - cap16 = UINT32_MAX; - cap8 = UINT32_MAX; - - int32 file = CFileMgr::OpenFile("DATA\\CAPS.DAT", "rb"); - if (file != 0) { - CFileMgr::Read(file, (char*)&cap32, 4); - CFileMgr::Read(file, (char*)&cap24, 4); - CFileMgr::Read(file, (char*)&cap16, 4); - CFileMgr::Read(file, (char*)&cap8, 4); - CFileMgr::CloseFile(file); - } -} - -bool -CheckVideoCardCaps(void) -{ - uint32 cap32 = _rwD3D8FindCorrectRasterFormat(rwRASTERTYPETEXTURE, rwRASTERFORMAT8888); - uint32 cap24 = _rwD3D8FindCorrectRasterFormat(rwRASTERTYPETEXTURE, rwRASTERFORMAT888); - uint32 cap16 = _rwD3D8FindCorrectRasterFormat(rwRASTERTYPETEXTURE, rwRASTERFORMAT1555); - uint32 cap8 = _rwD3D8FindCorrectRasterFormat(rwRASTERTYPETEXTURE, rwRASTERFORMATPAL8 | rwRASTERFORMAT8888); - uint32 fcap32, fcap24, fcap16, fcap8; - ReadVideoCardCapsFile(fcap32, fcap24, fcap16, fcap8); - return cap32 != fcap32 || cap24 != fcap24 || cap16 != fcap16 || cap8 != fcap8; -} - -void -WriteVideoCardCapsFile(void) -{ - uint32 cap32 = _rwD3D8FindCorrectRasterFormat(rwRASTERTYPETEXTURE, rwRASTERFORMAT8888); - uint32 cap24 = _rwD3D8FindCorrectRasterFormat(rwRASTERTYPETEXTURE, rwRASTERFORMAT888); - uint32 cap16 = _rwD3D8FindCorrectRasterFormat(rwRASTERTYPETEXTURE, rwRASTERFORMAT1555); - uint32 cap8 = _rwD3D8FindCorrectRasterFormat(rwRASTERTYPETEXTURE, rwRASTERFORMATPAL8 | rwRASTERFORMAT8888); - int32 file = CFileMgr::OpenFile("DATA\\CAPS.DAT", "wb"); - if (file != 0) { - CFileMgr::Write(file, (char*)&cap32, 4); - CFileMgr::Write(file, (char*)&cap24, 4); - CFileMgr::Write(file, (char*)&cap16, 4); - CFileMgr::Write(file, (char*)&cap8, 4); - CFileMgr::CloseFile(file); - } -} - -bool DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha); -void DoRWStuffEndOfFrame(void); - -void -ConvertingTexturesScreen(uint32 num, uint32 count, const char *text) -{ - HandleExit(); - - CSprite2d *splash = LoadSplash(nil); - if (!DoRWStuffStartOfFrame(0, 0, 0, 0, 0, 0, 255)) - return; - - CSprite2d::SetRecipNearClip(); - CSprite2d::InitPerFrame(); - CFont::InitPerFrame(); - DefinedState(); - - RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void*)rwTEXTUREADDRESSCLAMP); - splash->Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(255, 255, 255, 255)); - - CSprite2d::DrawRect(CRect(SCREEN_SCALE_X(200.0f), SCREEN_SCALE_Y(240.0f), SCREEN_SCALE_FROM_RIGHT(200.0f), SCREEN_SCALE_Y(248.0f)), CRGBA(64, 64, 64, 255)); - CSprite2d::DrawRect(CRect(SCREEN_SCALE_X(200.0f), SCREEN_SCALE_Y(240.0f), (SCREEN_SCALE_FROM_RIGHT(200.0f) - SCREEN_SCALE_X(200.0f)) * ((float)num / (float)count) + SCREEN_SCALE_X(200.0f), SCREEN_SCALE_Y(248.0f)), CRGBA(255, 217, 106, 255)); - CSprite2d::DrawRect(CRect(SCREEN_SCALE_X(120.0f), SCREEN_SCALE_Y(150.0f), SCREEN_SCALE_FROM_RIGHT(120.0f), SCREEN_HEIGHT - SCREEN_SCALE_Y(220.0f)), CRGBA(50, 50, 50, 210)); - - CFont::SetBackgroundOff(); - CFont::SetPropOn(); - CFont::SetScale(SCREEN_SCALE_X(0.45f), SCREEN_SCALE_Y(0.7f)); - CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(170.0f)); - CFont::SetJustifyOff(); - CFont::SetColor(CRGBA(255, 217, 106, 255)); - CFont::SetBackGroundOnlyTextOff(); - CFont::SetFontStyle(FONT_BANK); - CFont::PrintString(SCREEN_SCALE_X(170.0f), SCREEN_SCALE_Y(160.0f), TheText.Get(text)); - CFont::DrawFonts(); - DoRWStuffEndOfFrame(); -} - -void -DealWithTxdWriteError(uint32 num, uint32 count, const char *text) -{ - while (!RsGlobal.quit) { - ConvertingTexturesScreen(num, count, text); - CPad::UpdatePads(); - if (CPad::GetPad(0)->GetEscapeJustDown()) - break; - } - RsGlobal.quit = false; - LoadingScreen(nil, nil, nil); - RsGlobal.quit = true; -} - -bool -CreateTxdImageForVideoCard() -{ - uint8 *buf = new uint8[CDSTREAM_SECTOR_SIZE]; - CDirectory *pDir = new CDirectory(TXDSTORESIZE); - CDirectory::DirectoryInfo dirInfo; - - CStreaming::FlushRequestList(); - - RwFileFunctions *filesys = RwOsGetFileInterface(); - - RwStream *img = RwStreamOpen(rwSTREAMFILENAME, rwSTREAMWRITE, "models\\txd.img"); - if (img == nil) { - // original code does otherwise and it leaks - delete []buf; - delete pDir; - - if (_dwOperatingSystemVersion == OS_WINNT || _dwOperatingSystemVersion == OS_WIN2000 || _dwOperatingSystemVersion == OS_WINXP) - DealWithTxdWriteError(0, TXDSTORESIZE, "CVT_CRT"); - - return false; - } - - int32 i; - for (i = 0; i < TXDSTORESIZE; i++) { - ConvertingTexturesScreen(i, TXDSTORESIZE, "CVT_MSG"); - - if (CTxdStore::GetSlot(i) != nil && CStreaming::IsObjectInCdImage(i + STREAM_OFFSET_TXD)) { - CStreaming::RequestTxd(i, STREAMFLAGS_KEEP_IN_MEMORY); - CStreaming::RequestModelStream(0); - CStreaming::FlushChannels(); - - char filename[64]; - sprintf(filename, "%s.txd", CTxdStore::GetTxdName(i)); - - if (CTxdStore::GetSlot(i)->texDict) { - int32 pos = filesys->rwftell(img->Type.file.fpFile); - - if (RwTexDictionaryStreamWrite(CTxdStore::GetSlot(i)->texDict, img) == nil) { - DealWithTxdWriteError(i, TXDSTORESIZE, "CVT_ERR"); - RwStreamClose(img, nil); - delete []buf; - delete pDir; - CStreaming::RemoveTxd(i); - return false; - } - - int32 size = filesys->rwftell(img->Type.file.fpFile) - pos; - int32 num = size % CDSTREAM_SECTOR_SIZE; - - size /= CDSTREAM_SECTOR_SIZE; - if (num != 0) { - size++; - num = CDSTREAM_SECTOR_SIZE - num; - RwStreamWrite(img, buf, num); - } - - dirInfo.offset = pos / CDSTREAM_SECTOR_SIZE; - dirInfo.size = size; - strncpy(dirInfo.name, filename, sizeof(dirInfo.name)); - pDir->AddItem(dirInfo); - CStreaming::RemoveTxd(i); - } - CStreaming::FlushRequestList(); - } - } - - RwStreamClose(img, nil); - delete []buf; - - if (!pDir->WriteDirFile("models\\txd.dir")) { - DealWithTxdWriteError(i, TXDSTORESIZE, "CVT_ERR"); - delete pDir; - return false; - } - - delete pDir; - - WriteVideoCardCapsFile(); - return true; -} -#endif // GTA_PC - -STARTPATCHES - InjectHook(0x592380, RwTextureGtaStreamRead, PATCH_JUMP); - InjectHook(0x5924A0, RwTexDictionaryGtaStreamRead, PATCH_JUMP); - InjectHook(0x592550, RwTexDictionaryGtaStreamRead1, PATCH_JUMP); - InjectHook(0x592650, RwTexDictionaryGtaStreamRead2, PATCH_JUMP); - - InjectHook(0x5926C0, ReadVideoCardCapsFile, PATCH_JUMP); - InjectHook(0x592740, CheckVideoCardCaps, PATCH_JUMP); - InjectHook(0x5927D0, WriteVideoCardCapsFile, PATCH_JUMP); - InjectHook(0x592880, ConvertingTexturesScreen, PATCH_JUMP); - InjectHook(0x592BF0, DealWithTxdWriteError, PATCH_JUMP); - InjectHook(0x592C70, CreateTxdImageForVideoCard, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/TxdStore.cpp b/src/core/TxdStore.cpp deleted file mode 100644 index c751147d..00000000 --- a/src/core/TxdStore.cpp +++ /dev/null @@ -1,209 +0,0 @@ -#include "common.h" -#include "patcher.h" -#include "templates.h" -#include "General.h" -#include "Streaming.h" -#include "RwHelper.h" -#include "TxdStore.h" - -CPool *&CTxdStore::ms_pTxdPool = *(CPool**)0x8F5FB8; -RwTexDictionary *&CTxdStore::ms_pStoredTxd = *(RwTexDictionary**)0x9405BC; - -void -CTxdStore::Initialise(void) -{ - if(ms_pTxdPool == nil) - ms_pTxdPool = new CPool(TXDSTORESIZE); -} - -void -CTxdStore::Shutdown(void) -{ - if(ms_pTxdPool) - delete ms_pTxdPool; -} - -void -CTxdStore::GameShutdown(void) -{ - int i; - - for(i = 0; i < TXDSTORESIZE; i++){ - TxdDef *def = GetSlot(i); - if(def && GetNumRefs(i) == 0) - RemoveTxdSlot(i); - } -} - -int -CTxdStore::AddTxdSlot(const char *name) -{ - TxdDef *def = ms_pTxdPool->New(); - assert(def); - def->texDict = nil; - def->refCount = 0; - strcpy(def->name, name); - return ms_pTxdPool->GetJustIndex(def); -} - -void -CTxdStore::RemoveTxdSlot(int slot) -{ - TxdDef *def = GetSlot(slot); - if(def->texDict) - RwTexDictionaryDestroy(def->texDict); - ms_pTxdPool->Delete(def); -} - -int -CTxdStore::FindTxdSlot(const char *name) -{ - char *defname; - int size = ms_pTxdPool->GetSize(); - for(int i = 0; i < size; i++){ - defname = GetTxdName(i); - if(defname && !CGeneral::faststricmp(defname, name)) - return i; - } - return -1; -} - -char* -CTxdStore::GetTxdName(int slot) -{ - TxdDef *def = GetSlot(slot); - return def ? def->name : nil; -} - -void -CTxdStore::PushCurrentTxd(void) -{ - ms_pStoredTxd = RwTexDictionaryGetCurrent(); -} - -void -CTxdStore::PopCurrentTxd(void) -{ - RwTexDictionarySetCurrent(ms_pStoredTxd); - ms_pStoredTxd = nil; -} - -void -CTxdStore::SetCurrentTxd(int slot) -{ - TxdDef *def = GetSlot(slot); - if(def) - RwTexDictionarySetCurrent(def->texDict); -} - -void -CTxdStore::Create(int slot) -{ - GetSlot(slot)->texDict = RwTexDictionaryCreate(); -} - -int -CTxdStore::GetNumRefs(int slot) -{ - return GetSlot(slot)->refCount; -} - -void -CTxdStore::AddRef(int slot) -{ - GetSlot(slot)->refCount++; -} - -void -CTxdStore::RemoveRef(int slot) -{ - if(--GetSlot(slot)->refCount <= 0) - CStreaming::RemoveModel(slot + STREAM_OFFSET_TXD); -} - -void -CTxdStore::RemoveRefWithoutDelete(int slot) -{ - GetSlot(slot)->refCount--; -} - -bool -CTxdStore::LoadTxd(int slot, RwStream *stream) -{ - TxdDef *def = GetSlot(slot); - - if(RwStreamFindChunk(stream, rwID_TEXDICTIONARY, nil, nil)){ - def->texDict = RwTexDictionaryGtaStreamRead(stream); - return def->texDict != nil; - } - printf("Failed to load TXD\n"); - return false; -} - -bool -CTxdStore::LoadTxd(int slot, const char *filename) -{ - RwStream *stream; - bool ret; - - ret = false; - _rwD3D8TexDictionaryEnableRasterFormatConversion(true); - do - stream = RwStreamOpen(rwSTREAMFILENAME, rwSTREAMREAD, filename); - while(stream == nil); - ret = LoadTxd(slot, stream); - RwStreamClose(stream, nil); - return ret; -} - -bool -CTxdStore::StartLoadTxd(int slot, RwStream *stream) -{ - TxdDef *def = GetSlot(slot); - if(RwStreamFindChunk(stream, rwID_TEXDICTIONARY, nil, nil)){ - def->texDict = RwTexDictionaryGtaStreamRead1(stream); - return def->texDict != nil; - }else{ - printf("Failed to load TXD\n"); - return false; - } -} - -bool -CTxdStore::FinishLoadTxd(int slot, RwStream *stream) -{ - TxdDef *def = GetSlot(slot); - def->texDict = RwTexDictionaryGtaStreamRead2(stream, def->texDict); - return def->texDict != nil; -} - -void -CTxdStore::RemoveTxd(int slot) -{ - TxdDef *def = GetSlot(slot); - if(def->texDict) - RwTexDictionaryDestroy(def->texDict); - def->texDict = nil; -} - -STARTPATCHES - InjectHook(0x527440, CTxdStore::Initialise, PATCH_JUMP); - InjectHook(0x527470, CTxdStore::Shutdown, PATCH_JUMP); - InjectHook(0x527490, CTxdStore::GameShutdown, PATCH_JUMP); - InjectHook(0x5274E0, CTxdStore::AddTxdSlot, PATCH_JUMP); - InjectHook(0x5275D0, CTxdStore::FindTxdSlot, PATCH_JUMP); - InjectHook(0x527590, CTxdStore::GetTxdName, PATCH_JUMP); - InjectHook(0x527900, CTxdStore::PushCurrentTxd, PATCH_JUMP); - InjectHook(0x527910, CTxdStore::PopCurrentTxd, PATCH_JUMP); - InjectHook(0x5278C0, CTxdStore::SetCurrentTxd, PATCH_JUMP); - InjectHook(0x527830, CTxdStore::Create, PATCH_JUMP); - InjectHook(0x527A00, CTxdStore::GetNumRefs, PATCH_JUMP); - InjectHook(0x527930, CTxdStore::AddRef, PATCH_JUMP); - InjectHook(0x527970, CTxdStore::RemoveRef, PATCH_JUMP); - InjectHook(0x5279C0, CTxdStore::RemoveRefWithoutDelete, PATCH_JUMP); - InjectHook(0x527700, (bool (*)(int, RwStream*))CTxdStore::LoadTxd, PATCH_JUMP); - InjectHook(0x5276B0, (bool (*)(int, const char*))CTxdStore::LoadTxd, PATCH_JUMP); - InjectHook(0x527770, CTxdStore::StartLoadTxd, PATCH_JUMP); - InjectHook(0x5277E0, CTxdStore::FinishLoadTxd, PATCH_JUMP); - InjectHook(0x527870, CTxdStore::RemoveTxd, PATCH_JUMP); -ENDPATCHES diff --git a/src/core/TxdStore.h b/src/core/TxdStore.h deleted file mode 100644 index 12ac708f..00000000 --- a/src/core/TxdStore.h +++ /dev/null @@ -1,44 +0,0 @@ -#pragma once - -#include "templates.h" - -struct TxdDef { - RwTexDictionary *texDict; - int refCount; - char name[20]; -}; - -class CTxdStore -{ - static CPool *&ms_pTxdPool; - static RwTexDictionary *&ms_pStoredTxd; -public: - static void Initialise(void); - static void Shutdown(void); - static void GameShutdown(void); - static int AddTxdSlot(const char *name); - static void RemoveTxdSlot(int slot); - static int FindTxdSlot(const char *name); - static char *GetTxdName(int slot); - static void PushCurrentTxd(void); - static void PopCurrentTxd(void); - static void SetCurrentTxd(int slot); - static void Create(int slot); - static int GetNumRefs(int slot); - static void AddRef(int slot); - static void RemoveRef(int slot); - static void RemoveRefWithoutDelete(int slot); - static bool LoadTxd(int slot, RwStream *stream); - static bool LoadTxd(int slot, const char *filename); - static bool StartLoadTxd(int slot, RwStream *stream); - static bool FinishLoadTxd(int slot, RwStream *stream); - static void RemoveTxd(int slot); - - static TxdDef *GetSlot(int slot) { - assert(slot >= 0); - assert(ms_pTxdPool); - assert(slot < ms_pTxdPool->GetSize()); - return ms_pTxdPool->GetSlot(slot); - } - static bool isTxdLoaded(int slot); -}; diff --git a/src/core/common.h b/src/core/common.h index 6ea88f2f..7688b182 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -74,9 +74,11 @@ inline uint32 ldb(uint32 p, uint32 s, uint32 w) } +#ifndef RWLIBS // little hack extern void **rwengine; #define RwEngineInstance (*rwengine) +#endif #include "skeleton.h" #include "Draw.h" diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 11b1584a..40e44b15 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -24,7 +24,11 @@ #include +#ifndef RWLIBS void **rwengine = *(void***)0x5A10E1; +#else +extern "C" int vsprintf(char* const _Buffer, char const* const _Format, va_list _ArgList); +#endif DebugMenuAPI gDebugMenuAPI; diff --git a/src/core/rw.cpp b/src/core/rw.cpp deleted file mode 100644 index 52bcf5bb..00000000 --- a/src/core/rw.cpp +++ /dev/null @@ -1,415 +0,0 @@ -#include "common.h" -#include "patcher.h" -#include "rwcore.h" -#include "rpworld.h" -#include "rpmatfx.h" -#include "rpskin.h" -#include "rphanim.h" -#include "rtbmp.h" - -typedef RwV3d *(*rwVectorsMultFn) (RwV3d * pointsOut, - const RwV3d * pointsIn, - RwInt32 numPoints, - const RwMatrix * matrix); - - -WRAPPER void _rwObjectHasFrameSetFrame(void* object, RwFrame* frame) { EAXJMP(0x5BC950); } -WRAPPER RpAtomic* AtomicDefaultRenderCallBack(RpAtomic* atomic) { EAXJMP(0x59E690); } -WRAPPER void _rpAtomicResyncInterpolatedSphere(RpAtomic* atomic) { EAXJMP(0x59E6C0); } -WRAPPER RwSphere const* RpAtomicGetWorldBoundingSphere(RpAtomic* atomic) { EAXJMP(0x59E800); } -WRAPPER RwInt32 RpClumpGetNumAtomics(RpClump* clump) { EAXJMP(0x59ED50); } -WRAPPER RpClump* RpClumpRender(RpClump* clump) { EAXJMP(0x59ED80); } -WRAPPER RpClump* RpClumpForAllAtomics(RpClump* clump, RpAtomicCallBack callback, void* pData) { EAXJMP(0x59EDD0); } -WRAPPER RpClump* RpClumpForAllCameras(RpClump* clump, RwCameraCallBack callback, void* pData) { EAXJMP(0x59EE10); } -WRAPPER RpClump* RpClumpForAllLights(RpClump* clump, RpLightCallBack callback, void* pData) { EAXJMP(0x59EE60); } -WRAPPER RpAtomic* RpAtomicCreate() { EAXJMP(0x59EEB0); } -WRAPPER RpAtomic* RpAtomicSetGeometry(RpAtomic* atomic, RpGeometry* geometry, RwUInt32 flags) { EAXJMP(0x59EFA0); } -WRAPPER RwBool RpAtomicDestroy(RpAtomic* atomic) { EAXJMP(0x59F020); } -WRAPPER RpAtomic* RpAtomicClone(RpAtomic* atomic) { EAXJMP(0x59F0A0); } -WRAPPER RpClump* RpClumpClone(RpClump* clump) { EAXJMP(0x59F1B0); } -WRAPPER RpClump* RpClumpCreate() { EAXJMP(0x59F490); } -WRAPPER RwBool RpClumpDestroy(RpClump* clump) { EAXJMP(0x59F500); } -WRAPPER RpClump* RpClumpAddAtomic(RpClump* clump, RpAtomic* atomic) { EAXJMP(0x59F680); } -WRAPPER RpClump* RpClumpRemoveAtomic(RpClump* clump, RpAtomic* atomic) { EAXJMP(0x59F6B0); } -WRAPPER RpClump* RpClumpRemoveLight(RpClump* clump, RpLight* light) { EAXJMP(0x59F6E0); } -WRAPPER RpClump* RpClumpStreamRead(RwStream* stream) { EAXJMP(0x59FC50); } -WRAPPER RwInt32 RpAtomicRegisterPlugin(RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor ructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB) { EAXJMP(0x5A0510); } -WRAPPER RwInt32 RpClumpRegisterPlugin(RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor ructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB) { EAXJMP(0x5A0540); } -WRAPPER RwInt32 RpAtomicRegisterPluginStream(RwUInt32 pluginID, RwPluginDataChunkReadCallBack readCB, RwPluginDataChunkWriteCallBack writeCB, RwPluginDataChunkGetSizeCallBack getSizeCB) { EAXJMP(0x5A0570); } -WRAPPER RwInt32 RpAtomicSetStreamAlwaysCallBack(RwUInt32 pluginID, RwPluginDataChunkAlwaysCallBack alwaysCB) { EAXJMP(0x5A05A0); } -WRAPPER RwInt32 RpAtomicSetStreamRightsCallBack(RwUInt32 pluginID, RwPluginDataChunkRightsCallBack rightsCB) { EAXJMP(0x5A05C0); } -WRAPPER RwInt32 RpAtomicGetPluginOffset(RwUInt32 pluginID) { EAXJMP(0x5A05E0); } -WRAPPER RpAtomic* RpAtomicSetFrame(RpAtomic* atomic, RwFrame* frame) { EAXJMP(0x5A0600); } -WRAPPER RwInt32 RwEngineRegisterPlugin(RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor initCB, RwPluginObjectDestructor termCB) { EAXJMP(0x5A0DC0); } -WRAPPER RwInt32 RwEngineGetPluginOffset(RwUInt32 pluginID) { EAXJMP(0x5A0DF0); } -WRAPPER RwInt32 RwEngineGetNumSubSystems() { EAXJMP(0x5A0E10); } -WRAPPER RwSubSystemInfo* RwEngineGetSubSystemInfo(RwSubSystemInfo* subSystemInfo, RwInt32 subSystemIndex) { EAXJMP(0x5A0E40); } -WRAPPER RwInt32 RwEngineGetCurrentSubSystem() { EAXJMP(0x5A0E70); } -WRAPPER RwBool RwEngineSetSubSystem(RwInt32 subSystemIndex) { EAXJMP(0x5A0EA0); } -WRAPPER RwInt32 RwEngineGetNumVideoModes() { EAXJMP(0x5A0ED0); } -WRAPPER RwVideoMode* RwEngineGetVideoModeInfo(RwVideoMode* modeinfo, RwInt32 modeIndex) { EAXJMP(0x5A0F00); } -WRAPPER RwInt32 RwEngineGetCurrentVideoMode() { EAXJMP(0x5A0F30); } -WRAPPER RwBool RwEngineSetVideoMode(RwInt32 modeIndex) { EAXJMP(0x5A0F60); } -WRAPPER RwBool RwEngineStop() { EAXJMP(0x5A0F90); } -WRAPPER RwBool RwEngineStart() { EAXJMP(0x5A0FE0); } -WRAPPER RwBool RwEngineClose() { EAXJMP(0x5A1070); } -WRAPPER RwBool RwEngineOpen(RwEngineOpenParams* initParams) { EAXJMP(0x5A10E0); } -WRAPPER RwBool RwEngineTerm() { EAXJMP(0x5A1290); } -WRAPPER RwBool RwEngineInit(RwMemoryFunctions* memFuncs, RwUInt32 initFlags, RwUInt32 resArenaSize) { EAXJMP(0x5A12D0); } -WRAPPER void* _rwFrameOpen(void* instance, RwInt32 offset, RwInt32 size) { EAXJMP(0x5A15E0); } -WRAPPER void* _rwFrameClose(void* instance, RwInt32 offset, RwInt32 size) { EAXJMP(0x5A1650); } -WRAPPER RwFrame* _rwFrameCloneAndLinkClones(RwFrame* root) { EAXJMP(0x5A1690); } -WRAPPER RwFrame* _rwFramePurgeClone(RwFrame* root) { EAXJMP(0x5A1880); } -WRAPPER RwBool RwFrameDirty(RwFrame const* frame) { EAXJMP(0x5A1930); } -WRAPPER void _rwFrameInit(RwFrame* frame) { EAXJMP(0x5A1950); } -WRAPPER RwFrame* RwFrameCreate() { EAXJMP(0x5A1A00); } -WRAPPER RwBool RwFrameDestroy(RwFrame* frame) { EAXJMP(0x5A1A30); } -WRAPPER RwBool RwFrameDestroyHierarchy(RwFrame* frame) { EAXJMP(0x5A1BF0); } -WRAPPER RwFrame* RwFrameUpdateObjects(RwFrame* frame) { EAXJMP(0x5A1C60); } -WRAPPER RwMatrix* RwFrameGetLTM(RwFrame* frame) { EAXJMP(0x5A1CE0); } -WRAPPER RwFrame* RwFrameAddChild(RwFrame* parent, RwFrame* child) { EAXJMP(0x5A1D00); } -WRAPPER RwFrame* RwFrameRemoveChild(RwFrame* child) { EAXJMP(0x5A1ED0); } -WRAPPER RwFrame* RwFrameForAllChildren(RwFrame* frame, RwFrameCallBack callBack, void* data) { EAXJMP(0x5A1FC0); } -WRAPPER RwFrame* RwFrameTranslate(RwFrame* frame, RwV3d const* v, RwOpCombineType combine) { EAXJMP(0x5A2000); } -WRAPPER RwFrame* RwFrameScale(RwFrame* frame, RwV3d const* v, RwOpCombineType combine) { EAXJMP(0x5A20A0); } -WRAPPER RwFrame* RwFrameTransform(RwFrame* frame, RwMatrix const* m, RwOpCombineType combine) { EAXJMP(0x5A2140); } -WRAPPER RwFrame* RwFrameRotate(RwFrame* frame, RwV3d const* axis, RwReal angle, RwOpCombineType combine) { EAXJMP(0x5A21E0); } -WRAPPER RwFrame* RwFrameSetIdentity(RwFrame* frame) { EAXJMP(0x5A2280); } -WRAPPER RwFrame* RwFrameForAllObjects(RwFrame* frame, RwObjectCallBack callBack, void* data) { EAXJMP(0x5A2340); } -WRAPPER RwInt32 RwFrameRegisterPlugin(RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor ructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB) { EAXJMP(0x5A2380); } -WRAPPER RwBool _rwMatrixSetMultFn(rwMatrixMultFn multMat) { EAXJMP(0x5A23B0); } -WRAPPER RwReal _rwMatrixDeterminant(RwMatrix const* matrix) { EAXJMP(0x5A2520); } -WRAPPER RwReal _rwMatrixOrthogonalError(RwMatrix const* matrix) { EAXJMP(0x5A2570); } -WRAPPER RwReal _rwMatrixNormalError(RwMatrix const* matrix) { EAXJMP(0x5A25D0); } -WRAPPER RwReal _rwMatrixIdentityError(RwMatrix const* matrix) { EAXJMP(0x5A2660); } -WRAPPER void* _rwMatrixClose(void* instance, RwInt32 offset, RwInt32 size) { EAXJMP(0x5A2730); } -WRAPPER void* _rwMatrixOpen(void* instance, RwInt32 offset, RwInt32 size) { EAXJMP(0x5A2770); } -WRAPPER RwMatrix* RwMatrixOptimize(RwMatrix* matrix, RwMatrixTolerance const* tolerance) { EAXJMP(0x5A2820); } -WRAPPER RwMatrix* RwMatrixUpdate(RwMatrix* matrix) { EAXJMP(0x5A28E0); } -WRAPPER RwMatrix* RwMatrixMultiply(RwMatrix* matrixOut, RwMatrix const* MatrixIn1, RwMatrix const* matrixIn2) { EAXJMP(0x5A28F0); } -WRAPPER RwMatrix* RwMatrixRotateOneMinusCosineSine(RwMatrix* matrix, RwV3d const* unitAxis, RwReal oneMinusCosine, RwReal sine, RwOpCombineType combineOp) { EAXJMP(0x5A2960); } -WRAPPER RwMatrix* RwMatrixRotate(RwMatrix* matrix, RwV3d const* axis, RwReal angle, RwOpCombineType combineOp) { EAXJMP(0x5A2BF0); } -WRAPPER RwMatrix* RwMatrixInvert(RwMatrix* matrixOut, RwMatrix const* matrixIn) { EAXJMP(0x5A2C90); } -WRAPPER RwMatrix* RwMatrixScale(RwMatrix* matrix, RwV3d const* scale, RwOpCombineType combineOp) { EAXJMP(0x5A2EE0); } -WRAPPER RwMatrix* RwMatrixTranslate(RwMatrix* matrix, RwV3d const* translation, RwOpCombineType combineOp) { EAXJMP(0x5A3070); } -WRAPPER RwMatrix* RwMatrixTransform(RwMatrix* matrix, RwMatrix const* transform, RwOpCombineType combineOp) { EAXJMP(0x5A31C0); } -WRAPPER RwBool RwMatrixDestroy(RwMatrix* mpMat) { EAXJMP(0x5A3300); } -WRAPPER RwMatrix* RwMatrixCreate() { EAXJMP(0x5A3330); } -WRAPPER RwBool _rwVectorSetMultFn(rwVectorMultFn multPoint, rwVectorsMultFn multPoints, rwVectorMultFn multVector, rwVectorsMultFn multVectors) { EAXJMP(0x5A3450); } -WRAPPER RwReal _rwV3dNormalize(RwV3d* out, RwV3d const* in) { EAXJMP(0x5A3600); } -WRAPPER RwReal RwV3dLength(RwV3d const* in) { EAXJMP(0x5A36A0); } -WRAPPER RwReal _rwSqrt(RwReal const num) { EAXJMP(0x5A3710); } -WRAPPER RwReal _rwInvSqrt(RwReal const num) { EAXJMP(0x5A3770); } -WRAPPER RwV3d* RwV3dTransformPoints(RwV3d* pointsOut, RwV3d const* pointsIn, RwInt32 numPoints, RwMatrix const* matrix) { EAXJMP(0x5A37D0); } -WRAPPER RwV3d* RwV3dTransformVectors(RwV3d* vectorsOut, RwV3d const* vectorsIn, RwInt32 numPoints, RwMatrix const* matrix) { EAXJMP(0x5A37E0); } -WRAPPER void* _rwVectorClose(void* instance, RwInt32 offset, RwInt32 size) { EAXJMP(0x5A37F0); } -WRAPPER void* _rwVectorOpen(void* instance, RwInt32 offset, RwInt32 size) { EAXJMP(0x5A3860); } -WRAPPER RwUInt32 RwStreamRead(RwStream* stream, void* buffer, RwUInt32 length) { EAXJMP(0x5A3AD0); } -WRAPPER RwStream* RwStreamWrite(RwStream* stream, void const* buffer, RwUInt32 length) { EAXJMP(0x5A3C30); } -WRAPPER RwStream* RwStreamSkip(RwStream* stream, RwUInt32 offset) { EAXJMP(0x5A3DF0); } -WRAPPER RwBool RwStreamClose(RwStream* stream, void* pData) { EAXJMP(0x5A3F10); } -WRAPPER RwStream* RwStreamOpen(RwStreamType type, RwStreamAccessType accessType, void const* pData) { EAXJMP(0x5A3FE0); } -WRAPPER RwReal RwIm2DGetNearScreenZ() { EAXJMP(0x5A43A0); } -WRAPPER RwReal RwIm2DGetFarScreenZ() { EAXJMP(0x5A43B0); } -WRAPPER RwBool RwRenderStateSet(RwRenderState state, void* value) { EAXJMP(0x5A43C0); } -WRAPPER RwBool RwRenderStateGet(RwRenderState state, void* value) { EAXJMP(0x5A4410); } -WRAPPER RwBool RwIm2DRenderLine(RwIm2DVertex* vertices, RwInt32 numVertices, RwInt32 vert1, RwInt32 vert2) { EAXJMP(0x5A4420); } -WRAPPER RwBool RwIm2DRenderPrimitive(RwPrimitiveType primType, RwIm2DVertex* vertices, RwInt32 numVertices) { EAXJMP(0x5A4430); } -WRAPPER RwBool RwIm2DRenderIndexedPrimitive(RwPrimitiveType primType, RwIm2DVertex* vertices, RwInt32 numVertices, RwImVertexIndex* indices, RwInt32 numIndices) { EAXJMP(0x5A4440); } -WRAPPER RwCamera* RwCameraEndUpdate(RwCamera* camera) { EAXJMP(0x5A5020); } -WRAPPER RwCamera* RwCameraBeginUpdate(RwCamera* camera) { EAXJMP(0x5A5030); } -WRAPPER RwCamera* RwCameraSetViewOffset(RwCamera* camera, RwV2d const* offset) { EAXJMP(0x5A5040); } -WRAPPER RwCamera* RwCameraSetNearClipPlane(RwCamera* camera, RwReal nearClip) { EAXJMP(0x5A5070); } -WRAPPER RwCamera* RwCameraSetFarClipPlane(RwCamera* camera, RwReal farClip) { EAXJMP(0x5A5140); } -WRAPPER RwFrustumTestResult RwCameraFrustumTestSphere(RwCamera const* camera, RwSphere const* sphere) { EAXJMP(0x5A5170); } -WRAPPER RwCamera* RwCameraClear(RwCamera* camera, RwRGBA* colour, RwInt32 clearMode) { EAXJMP(0x5A51E0); } -WRAPPER RwCamera* RwCameraShowRaster(RwCamera* camera, void* pDev, RwUInt32 flags) { EAXJMP(0x5A5210); } -WRAPPER RwCamera* RwCameraSetProjection(RwCamera* camera, RwCameraProjection projection) { EAXJMP(0x5A5240); } -WRAPPER RwCamera* RwCameraSetViewWindow(RwCamera* camera, RwV2d const* viewWindow) { EAXJMP(0x5A52B0); } -WRAPPER RwInt32 RwCameraRegisterPlugin(RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor ructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB) { EAXJMP(0x5A52F0); } -WRAPPER RwBool RwCameraDestroy(RwCamera* camera) { EAXJMP(0x5A5320); } -WRAPPER RwCamera* RwCameraCreate() { EAXJMP(0x5A5360); } -WRAPPER RwBool RwTextureSetMipmapping(RwBool enable) { EAXJMP(0x5A7100); } -WRAPPER RwBool RwTextureGetMipmapping() { EAXJMP(0x5A7120); } -WRAPPER RwBool RwTextureSetAutoMipmapping(RwBool enable) { EAXJMP(0x5A7130); } -WRAPPER RwBool RwTextureGetAutoMipmapping() { EAXJMP(0x5A7150); } -WRAPPER RwTexDictionary* RwTexDictionaryCreate() { EAXJMP(0x5A7160); } -WRAPPER RwBool RwTexDictionaryDestroy(RwTexDictionary* dict) { EAXJMP(0x5A7200); } -WRAPPER RwTexDictionary const* RwTexDictionaryForAllTextures(RwTexDictionary const* dict, RwTextureCallBack fpCallBack, void* pData) { EAXJMP(0x5A7290); } -WRAPPER RwTexture* RwTextureCreate(RwRaster* raster) { EAXJMP(0x5A72D0); } -WRAPPER RwBool RwTextureDestroy(RwTexture* texture) { EAXJMP(0x5A7330); } -WRAPPER RwTexture* RwTextureSetName(RwTexture* texture, RwChar const* name) { EAXJMP(0x5A73B0); } -WRAPPER RwTexture* RwTextureSetMaskName(RwTexture* texture, RwChar const* maskName) { EAXJMP(0x5A7420); } -WRAPPER RwTexture* RwTexDictionaryAddTexture(RwTexDictionary* dict, RwTexture* texture) { EAXJMP(0x5A7490); } -WRAPPER RwTexture* RwTexDictionaryFindNamedTexture(RwTexDictionary* dict, RwChar const* name) { EAXJMP(0x5A74D0); } -WRAPPER RwTexDictionary* RwTexDictionarySetCurrent(RwTexDictionary* dict) { EAXJMP(0x5A7550); } -WRAPPER RwTexDictionary* RwTexDictionaryGetCurrent() { EAXJMP(0x5A7570); } -WRAPPER RwTexture* RwTextureRead(RwChar const* name, RwChar const* maskName) { EAXJMP(0x5A7580); } -WRAPPER RwBool RwTextureRasterGenerateMipmaps(RwRaster* raster, RwImage* image) { EAXJMP(0x5A7780); } -WRAPPER RwImage* RwImageCreate(RwInt32 width, RwInt32 height, RwInt32 depth) { EAXJMP(0x5A9120); } -WRAPPER RwBool RwImageDestroy(RwImage* image) { EAXJMP(0x5A9180); } -WRAPPER RwImage* RwImageAllocatePixels(RwImage* image) { EAXJMP(0x5A91E0); } -WRAPPER RwImage* RwImageFreePixels(RwImage* image) { EAXJMP(0x5A92A0); } -WRAPPER RwImage* RwImageMakeMask(RwImage* image) { EAXJMP(0x5A92D0); } -WRAPPER RwImage* RwImageApplyMask(RwImage* image, RwImage const* mask) { EAXJMP(0x5A93A0); } -WRAPPER RwChar const* RwImageSetPath(RwChar const* path) { EAXJMP(0x5A9750); } -WRAPPER RwImage* RwImageRead(RwChar const* imageName) { EAXJMP(0x5A9810); } -WRAPPER RwChar const* RwImageFindFileType(RwChar const* imageName) { EAXJMP(0x5A9B40); } -WRAPPER RwImage* RwImageReadMaskedImage(RwChar const* imageName, RwChar const* maskname) { EAXJMP(0x5A9C10); } -WRAPPER RwImage* RwImageCopy(RwImage* destImage, RwImage const* sourceImage) { EAXJMP(0x5A9F50); } -WRAPPER RwImage* RwImageGammaCorrect(RwImage* image) { EAXJMP(0x5AA130); } -WRAPPER RwBool RwImageSetGamma(RwReal gammaValue) { EAXJMP(0x5AA2C0); } -WRAPPER RwStream* _rwStreamWriteVersionedChunkHeader(RwStream* stream, RwInt32 type, RwInt32 size, RwUInt32 version, RwUInt32 buildNum) { EAXJMP(0x5AA4E0); } -WRAPPER RwBool RwStreamFindChunk(RwStream* stream, RwUInt32 type, RwUInt32* lengthOut, RwUInt32* versionOut) { EAXJMP(0x5AA540); } -WRAPPER void* RwMemLittleEndian32(void* mem, RwUInt32 size) { EAXJMP(0x5AA640); } -WRAPPER void* RwMemNative32(void* mem, RwUInt32 size) { EAXJMP(0x5AA650); } -WRAPPER void* RwMemFloat32ToReal(void* mem, RwUInt32 size) { EAXJMP(0x5AA660); } -WRAPPER RwStream* RwStreamWriteReal(RwStream* stream, RwReal const* reals, RwUInt32 numBytes) { EAXJMP(0x5AA680); } -WRAPPER RwStream* RwStreamWriteInt32(RwStream* stream, RwInt32 const* ints, RwUInt32 numBytes) { EAXJMP(0x5AA720); } -WRAPPER RwStream* RwStreamReadReal(RwStream* stream, RwReal* reals, RwUInt32 numBytes) { EAXJMP(0x5AA740); } -WRAPPER RwStream* RwStreamReadInt32(RwStream* stream, RwInt32* ints, RwUInt32 numBytes) { EAXJMP(0x5AA7B0); } -WRAPPER RwUInt32 RwTextureStreamGetSize(RwTexture const* texture) { EAXJMP(0x5AA800); } -WRAPPER RwTexture const* RwTextureStreamWrite(RwTexture const* texture, RwStream* stream) { EAXJMP(0x5AA870); } -WRAPPER RwTexture* RwTextureStreamRead(RwStream* stream) { EAXJMP(0x5AAA40); } -WRAPPER RwTexDictionary const* RwTexDictionaryStreamWrite(RwTexDictionary const* texDict, RwStream* stream) { EAXJMP(0x5AB020); } -WRAPPER RpMorphTarget const* RpMorphTargetCalcBoundingSphere(RpMorphTarget const* morphTarget, RwSphere* boundingSphere) { EAXJMP(0x5AC890); } -WRAPPER RwInt32 RpGeometryAddMorphTargets(RpGeometry* geometry, RwInt32 mtcount) { EAXJMP(0x5AC9A0); } -WRAPPER RpGeometry const* RpGeometryTriangleSetVertexIndices(RpGeometry const* geometry, RpTriangle* triangle, RwUInt16 vert1, RwUInt16 vert2, RwUInt16 vert3) { EAXJMP(0x5ACB60); } -WRAPPER RpGeometry* RpGeometryTriangleSetMaterial(RpGeometry* geometry, RpTriangle* triangle, RpMaterial* material) { EAXJMP(0x5ACB90); } -WRAPPER RpGeometry* RpGeometryForAllMaterials(RpGeometry* geometry, RpMaterialCallBack fpCallBack, void* pData) { EAXJMP(0x5ACBF0); } -WRAPPER RpGeometry* RpGeometryLock(RpGeometry* geometry, RwInt32 lockMode) { EAXJMP(0x5ACC30); } -WRAPPER RpGeometry* RpGeometryUnlock(RpGeometry* geometry) { EAXJMP(0x5ACC60); } -WRAPPER RpGeometry* RpGeometryCreate(RwInt32 numVert, RwInt32 numTriangles, RwUInt32 format) { EAXJMP(0x5ACD10); } -WRAPPER RpGeometry* _rpGeometryAddRef(RpGeometry* geometry) { EAXJMP(0x5ACF40); } -WRAPPER RwBool RpGeometryDestroy(RpGeometry* geometry) { EAXJMP(0x5ACF50); } -WRAPPER RwInt32 RpGeometryRegisterPlugin(RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor ructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB) { EAXJMP(0x5ACFF0); } -WRAPPER RwInt32 RpGeometryRegisterPluginStream(RwUInt32 pluginID, RwPluginDataChunkReadCallBack readCB, RwPluginDataChunkWriteCallBack writeCB, RwPluginDataChunkGetSizeCallBack getSizeCB) { EAXJMP(0x5AD020); } -WRAPPER RpGeometry* RpGeometryStreamRead(RwStream* stream) { EAXJMP(0x5AD050); } -WRAPPER RwRaster* RwRasterGetCurrentContext() { EAXJMP(0x5AD6D0); } -WRAPPER RwRaster* RwRasterUnlock(RwRaster* raster) { EAXJMP(0x5AD6F0); } -WRAPPER RwRaster* RwRasterRenderFast(RwRaster* raster, RwInt32 x, RwInt32 y) { EAXJMP(0x5AD710); } -WRAPPER RwRaster* RwRasterUnlockPalette(RwRaster* raster) { EAXJMP(0x5AD750); } -WRAPPER RwBool RwRasterDestroy(RwRaster* raster) { EAXJMP(0x5AD780); } -WRAPPER RwRaster* RwRasterPushContext(RwRaster* raster) { EAXJMP(0x5AD7C0); } -WRAPPER RwInt32 RwRasterRegisterPlugin(RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor ructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB) { EAXJMP(0x5AD810); } -WRAPPER RwUInt8* RwRasterLockPalette(RwRaster* raster, RwInt32 lockMode) { EAXJMP(0x5AD840); } -WRAPPER RwRaster* RwRasterPopContext() { EAXJMP(0x5AD870); } -WRAPPER RwInt32 RwRasterGetNumLevels(RwRaster* raster) { EAXJMP(0x5AD8C0); } -WRAPPER RwRaster* RwRasterShowRaster(RwRaster* raster, void* dev, RwUInt32 flags) { EAXJMP(0x5AD900); } -WRAPPER RwRaster* RwRasterCreate(RwInt32 width, RwInt32 height, RwInt32 depth, RwInt32 flags) { EAXJMP(0x5AD930); } -WRAPPER RwUInt8* RwRasterLock(RwRaster* raster, RwUInt8 level, RwInt32 lockMode) { EAXJMP(0x5AD9D0); } -WRAPPER RpMaterial* RpMaterialCreate() { EAXJMP(0x5ADC30); } -WRAPPER RwBool RpMaterialDestroy(RpMaterial* material) { EAXJMP(0x5ADCB0); } -WRAPPER RpMaterial* RpMaterialSetTexture(RpMaterial* material, RwTexture* texture) { EAXJMP(0x5ADD10); } -WRAPPER RwInt32 RpMaterialRegisterPlugin(RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor ructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB) { EAXJMP(0x5ADD40); } -WRAPPER RwInt32 RpMaterialRegisterPluginStream(RwUInt32 pluginID, RwPluginDataChunkReadCallBack readCB, RwPluginDataChunkWriteCallBack writeCB, RwPluginDataChunkGetSizeCallBack getSizeCB) { EAXJMP(0x5ADD70); } -WRAPPER RpMaterial* RpMaterialStreamRead(RwStream* stream) { EAXJMP(0x5ADDA0); } -WRAPPER RpWorldSector* _rpSectorDefaultRenderCallBack(RpWorldSector* sector) { EAXJMP(0x5AE0B0); } -WRAPPER RwBool _rpWorldForAllGlobalLights(RpLightCallBack callBack, void* pData) { EAXJMP(0x5AE100); } -WRAPPER RpWorldSector* _rpWorldSectorForAllLocalLights(RpWorldSector* sector, RpLightCallBack callBack, void* pData) { EAXJMP(0x5AE150); } -WRAPPER RpWorld* RpWorldUnlock(RpWorld* world) { EAXJMP(0x5AE190); } -WRAPPER RpWorld* RpWorldSectorGetWorld(RpWorldSector const* sector) { EAXJMP(0x5AE2B0); } -WRAPPER RwBool RpWorldDestroy(RpWorld* world) { EAXJMP(0x5AE340); } -WRAPPER RpWorld* RpWorldCreate(RwBBox* boundingBox) { EAXJMP(0x5AE6A0); } -WRAPPER RwInt32 RpWorldRegisterPlugin(RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor ructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB) { EAXJMP(0x5AEA40); } -WRAPPER RwInt32 RpWorldRegisterPluginStream(RwUInt32 pluginID, RwPluginDataChunkReadCallBack readCB, RwPluginDataChunkWriteCallBack writeCB, RwPluginDataChunkGetSizeCallBack getSizeCB) { EAXJMP(0x5AEA70); } -WRAPPER RwBool RpWorldPluginAttach() { EAXJMP(0x5AEAA0); } -WRAPPER RpWorld* RpWorldAddCamera(RpWorld* world, RwCamera* camera) { EAXJMP(0x5AFB80); } -WRAPPER RpWorld* RpWorldRemoveCamera(RpWorld* world, RwCamera* camera) { EAXJMP(0x5AFBB0); } -WRAPPER RpWorld* RpAtomicGetWorld(RpAtomic const* atomic) { EAXJMP(0x5AFC10); } -WRAPPER RpWorld* RpWorldAddClump(RpWorld* world, RpClump* clump) { EAXJMP(0x5AFC20); } -WRAPPER RpWorld* RpWorldAddLight(RpWorld* world, RpLight* light) { EAXJMP(0x5AFDA0); } -WRAPPER RpWorld* RpWorldRemoveLight(RpWorld* world, RpLight* light) { EAXJMP(0x5AFDF0); } -WRAPPER RwImage* RtBMPImageRead(RwChar const* imageName) { EAXJMP(0x5AFE70); } -WRAPPER RwBool RpSkinPluginAttach() { EAXJMP(0x5B07D0); } -WRAPPER RpAtomic* RpSkinAtomicSetHAnimHierarchy(RpAtomic* atomic, RpHAnimHierarchy* hierarchy) { EAXJMP(0x5B1050); } -WRAPPER RpHAnimHierarchy* RpSkinAtomicGetHAnimHierarchy(RpAtomic const* atomic) { EAXJMP(0x5B1070); } -WRAPPER RpSkin* RpSkinGeometryGetSkin(RpGeometry* geometry) { EAXJMP(0x5B1080); } -WRAPPER RpGeometry* RpSkinGeometrySetSkin(RpGeometry* geometry, RpSkin* skin) { EAXJMP(0x5B1090); } -WRAPPER RwMatrix const* RpSkinGetSkinToBoneMatrices(RpSkin* skin) { EAXJMP(0x5B10D0); } -WRAPPER RpHAnimHierarchy* RpHAnimHierarchyCreate(RwInt32 numNodes, RwUInt32* nodeFlags, RwInt32* nodeIDs, RpHAnimHierarchyFlag flags, RwInt32 maxKeyFrameSize) { EAXJMP(0x5B10E0); } -WRAPPER RpHAnimHierarchy* RpHAnimFrameGetHierarchy(RwFrame* frame) { EAXJMP(0x5B11F0); } -WRAPPER RwBool RpHAnimHierarchySetCurrentAnim(RpHAnimHierarchy* hierarchy, RpHAnimAnimation* anim) { EAXJMP(0x5B1200); } -WRAPPER RwBool RpHAnimHierarchySubAnimTime(RpHAnimHierarchy* hierarchy, RwReal time) { EAXJMP(0x5B12B0); } -WRAPPER RwBool RpHAnimHierarchyAddAnimTime(RpHAnimHierarchy* hierarchy, RwReal time) { EAXJMP(0x5B1480); } -WRAPPER RwBool RpHAnimHierarchyUpdateMatrices(RpHAnimHierarchy* hierarchy) { EAXJMP(0x5B1780); } -WRAPPER RpHAnimAnimation* RpHAnimAnimationStreamRead(RwStream* stream) { EAXJMP(0x5B1C10); } -WRAPPER RwBool RpHAnimPluginAttach() { EAXJMP(0x5B1D50); } -WRAPPER RwBool RpMatFXPluginAttach() { EAXJMP(0x5B2640); } -WRAPPER RpAtomic* RpMatFXAtomicEnableEffects(RpAtomic* atomic) { EAXJMP(0x5B3750); } -WRAPPER RpMaterial* RpMatFXMaterialSetEffects(RpMaterial* material, RpMatFXMaterialFlags flags) { EAXJMP(0x5B3780); } -WRAPPER RpMaterial* RpMatFXMaterialSetupEnvMap(RpMaterial* material, RwTexture* texture, RwFrame* frame, RwBool useFrameBufferAlpha, RwReal coef) { EAXJMP(0x5B38D0); } -WRAPPER RpMaterial* RpMatFXMaterialSetBumpMapTexture(RpMaterial* material, RwTexture* texture) { EAXJMP(0x5B3A40); } -WRAPPER RwBool RwD3D8SetRenderState(RwUInt32 state, RwUInt32 value) { EAXJMP(0x5B3CF0); } -WRAPPER void RwD3D8GetRenderState(RwUInt32 state, void* value) { EAXJMP(0x5B3D40); } -WRAPPER RwBool RwD3D8SetTextureStageState(RwUInt32 stage, RwUInt32 type, RwUInt32 value) { EAXJMP(0x5B3D60); } -WRAPPER RwBool RwD3D8SetTexture(RwTexture* texture, RwUInt32 stage) { EAXJMP(0x5B53A0); } -WRAPPER void* RwIm3DTransform(RwIm3DVertex* pVerts, RwUInt32 numVerts, RwMatrix* ltm, RwUInt32 flags) { EAXJMP(0x5B6720); } -WRAPPER RwBool RwIm3DEnd() { EAXJMP(0x5B67F0); } -WRAPPER RwBool RwIm3DRenderIndexedPrimitive(RwPrimitiveType primType, RwImVertexIndex* indices, RwInt32 numIndices) { EAXJMP(0x5B6820); } -WRAPPER RwBool RwIm3DRenderLine(RwInt32 vert1, RwInt32 vert2) { EAXJMP(0x5B6980); } -WRAPPER RxPipeline* RwIm3DSetTransformPipeline(RxPipeline* pipeline) { EAXJMP(0x5B6A50); } -WRAPPER RxPipeline* RwIm3DSetRenderPipeline(RxPipeline* pipeline, RwPrimitiveType primType) { EAXJMP(0x5B6AC0); } -WRAPPER void RwD3D8EngineSetRefreshRate(RwUInt32 refreshRate) { EAXJMP(0x5B95D0); } -WRAPPER RwBool RwD3D8CameraAttachWindow(void* camera, void* hwnd) { EAXJMP(0x5B9640); } -WRAPPER RwBool RwD3D8DeviceSupportsDXTTexture() { EAXJMP(0x5BAEB0); } -WRAPPER RwBool RwD3D8SetVertexShader(RwUInt32 handle) { EAXJMP(0x5BAF90); } -WRAPPER RwBool RwD3D8SetPixelShader(RwUInt32 handle) { EAXJMP(0x5BAFD0); } -WRAPPER RwBool RwD3D8SetStreamSource(RwUInt32 streamNumber, void* streamData, RwUInt32 stride) { EAXJMP(0x5BB010); } -WRAPPER RwBool RwD3D8SetIndices(void* indexData, RwUInt32 baseVertexIndex) { EAXJMP(0x5BB060); } -WRAPPER RwBool RwD3D8DrawIndexedPrimitive(RwUInt32 primitiveType, RwUInt32 minIndex, RwUInt32 numVertices, RwUInt32 startIndex, RwUInt32 numIndices) { EAXJMP(0x5BB0B0); } -WRAPPER RwBool RwD3D8DrawPrimitive(RwUInt32 primitiveType, RwUInt32 startVertex, RwUInt32 numVertices) { EAXJMP(0x5BB140); } -WRAPPER RwBool RwD3D8SetTransform(RwUInt32 state, void const* matrix) { EAXJMP(0x5BB1D0); } -WRAPPER void RwD3D8GetTransform(RwUInt32 state, void* matrix) { EAXJMP(0x5BB310); } -WRAPPER RwBool RwD3D8SetTransformWorld(RwMatrix const* matrix) { EAXJMP(0x5BB340); } -WRAPPER RwBool RwD3D8SetSurfaceProperties(RwRGBA const* color, RwSurfaceProperties const* surfaceProps, RwBool modulate) { EAXJMP(0x5BB490); } -WRAPPER RwBool RwD3D8SetLight(RwInt32 index, void const* light) { EAXJMP(0x5BB7A0); } -WRAPPER RwBool RwD3D8EnableLight(RwInt32 index, RwBool enable) { EAXJMP(0x5BB890); } -WRAPPER RwBool RwD3D8DynamicVertexBufferCreate(RwUInt32 fvf, RwUInt32 size, void** vertexBuffer) { EAXJMP(0x5BB9F0); } -WRAPPER void RwD3D8DynamicVertexBufferDestroy(void* vertexBuffer) { EAXJMP(0x5BBAE0); } -WRAPPER RwBool RwD3D8IndexBufferCreate(RwUInt32 numIndices, void** indexBuffer) { EAXJMP(0x5BBB10); } -WRAPPER RwBool RwD3D8CreatePixelShader(RwUInt32 const* function, RwUInt32* handle) { EAXJMP(0x5BBB40); } -WRAPPER void RwD3D8DeletePixelShader(RwUInt32 handle) { EAXJMP(0x5BBB90); } -WRAPPER RwBool RwD3D8SetPixelShaderConstant(RwUInt32 registerAddress, void const* antData, RwUInt32 antCount) { EAXJMP(0x5BBC00); } -WRAPPER void const* RwD3D8GetCaps() { EAXJMP(0x5BBC30); } -WRAPPER RwBool RwD3D8CameraIsSphereFullyInsideFrustum(void const* camera, void const* sphere) { EAXJMP(0x5BBC40); } -WRAPPER RwBool RwD3D8CameraIsBBoxFullyInsideFrustum(void const* camera, void const* boundingBox) { EAXJMP(0x5BBCA0); } -WRAPPER RwBool RwD3D8DynamicVertexBufferLock(RwUInt32 vertexSize, RwUInt32 numVertex, void** vertexBufferOut, void** vertexDataOut, RwUInt32* baseIndexOut) { EAXJMP(0x5BBD30); } -WRAPPER RwBool RwD3D8DynamicVertexBufferUnlock(void* vertexBuffer) { EAXJMP(0x5BBEB0); } -WRAPPER RwBool _rwIntelSSEsupported() { EAXJMP(0x5BBED0); } -WRAPPER RwImage* RwImageSetFromRaster(RwImage* image, RwRaster* raster) { EAXJMP(0x5BBF10); } -WRAPPER RwRaster* RwRasterSetFromImage(RwRaster* raster, RwImage* image) { EAXJMP(0x5BBF50); } -WRAPPER RwImage* RwImageFindRasterFormat(RwImage* ipImage, RwInt32 nRasterType, RwInt32* npWidth, RwInt32* npHeight, RwInt32* npDepth, RwInt32* npFormat) { EAXJMP(0x5BBF80); } -WRAPPER RwInt32 RwFrameRegisterPluginStream(RwUInt32 pluginID, RwPluginDataChunkReadCallBack readCB, RwPluginDataChunkWriteCallBack writeCB, RwPluginDataChunkGetSizeCallBack getSizeCB) { EAXJMP(0x5BBFF0); } -WRAPPER rwFrameList* _rwFrameListDeinitialize(rwFrameList* frameList) { EAXJMP(0x5BC020); } -WRAPPER rwFrameList* _rwFrameListStreamRead(RwStream* stream, rwFrameList* fl) { EAXJMP(0x5BC050); } -WRAPPER RpLight* RpLightSetRadius(RpLight* light, RwReal radius) { EAXJMP(0x5BC300); } -WRAPPER RpLight* RpLightSetColor(RpLight* light, RwRGBAReal const* color) { EAXJMP(0x5BC320); } -WRAPPER RwReal RpLightGetConeAngle(RpLight const* light) { EAXJMP(0x5BC370); } -WRAPPER RwInt32 RpLightRegisterPlugin(RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor ructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB) { EAXJMP(0x5BC5B0); } -WRAPPER RpLight* RpLightStreamRead(RwStream* stream) { EAXJMP(0x5BC5E0); } -WRAPPER RwBool RpLightDestroy(RpLight* light) { EAXJMP(0x5BC780); } -WRAPPER RpLight* RpLightCreate(RwInt32 type) { EAXJMP(0x5BC7C0); } -WRAPPER void _rwD3D8TexDictionaryEnableRasterFormatConversion(RwBool enable) { EAXJMP(0x5BE280); } -WRAPPER RwFileFunctions* RwOsGetFileInterface() { EAXJMP(0x5BF110); } -WRAPPER RwBool RwFreeListDestroy(RwFreeList* freelist) { EAXJMP(0x5C1720); } -WRAPPER RwFreeList* RwFreeListCreate(RwInt32 entrySize, RwInt32 entriesPerBlock, RwInt32 alignment) { EAXJMP(0x5C1790); } -WRAPPER RwInt32 RwFreeListPurge(RwFreeList* freelist) { EAXJMP(0x5C19F0); } -WRAPPER RwInt32 RwFreeListPurgeAllFreeLists() { EAXJMP(0x5C1B90); } -WRAPPER RwFreeList* RwFreeListForAllUsed(RwFreeList* freelist, RwFreeListCallBack fpCallBack, void* pData) { EAXJMP(0x5C1D40); } -WRAPPER RwBool _rxPipelineClose() { EAXJMP(0x5C2780); } -WRAPPER RwBool _rxPipelineOpen() { EAXJMP(0x5C27E0); } -WRAPPER RxHeap* RxHeapGetGlobalHeap() { EAXJMP(0x5C2AD0); } -WRAPPER RxPacket* RxPacketCreate(RxPipelineNode* node) { EAXJMP(0x5C2AE0); } -WRAPPER RxCluster* RxClusterSetExternalData(RxCluster* cluster, void* data, RwInt32 stride, RwInt32 numElements) { EAXJMP(0x5C2B10); } -WRAPPER RxCluster* RxClusterSetData(RxCluster* cluster, void* data, RwInt32 stride, RwInt32 numElements) { EAXJMP(0x5C2B70); } -WRAPPER RxCluster* RxClusterInitializeData(RxCluster* cluster, RwUInt32 numElements, RwUInt16 stride) { EAXJMP(0x5C2BD0); } -WRAPPER RxCluster* RxClusterResizeData(RxCluster* CurrentCluster, RwUInt32 NumElements) { EAXJMP(0x5C2C40); } -WRAPPER RxCluster* RxClusterLockWrite(RxPacket* packet, RwUInt32 clusterIndex, RxPipelineNode* node) { EAXJMP(0x5C2C90); } -WRAPPER RxPipeline* RxPipelineExecute(RxPipeline* pipeline, void* data, RwBool heapReset) { EAXJMP(0x5C2D60); } -WRAPPER RxPipeline* RxPipelineCreate() { EAXJMP(0x5C2E00); } -WRAPPER void _rxPipelineDestroy(RxPipeline* Pipeline) { EAXJMP(0x5C2E70); } -WRAPPER RwBool RwResourcesFreeResEntry(RwResEntry* entry) { EAXJMP(0x5C3080); } -WRAPPER void _rwResourcesPurge() { EAXJMP(0x5C30F0); } -WRAPPER RwResEntry* RwResourcesAllocateResEntry(void* owner, RwResEntry** ownerRef, RwInt32 size, RwResEntryDestroyNotify destroyNotify) { EAXJMP(0x5C3170); } -WRAPPER RwBool RwResourcesEmptyArena() { EAXJMP(0x5C3360); } -WRAPPER RwBool _rwPluginRegistryOpen() { EAXJMP(0x5C3450); } -WRAPPER RwBool _rwPluginRegistryClose() { EAXJMP(0x5C3480); } -WRAPPER RwInt32 _rwPluginRegistryGetPluginOffset(RwPluginRegistry const* reg, RwUInt32 pluginID) { EAXJMP(0x5C3590); } -WRAPPER RwInt32 _rwPluginRegistryAddPlugin(RwPluginRegistry* reg, RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor ructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB) { EAXJMP(0x5C35C0); } -WRAPPER RwPluginRegistry const* _rwPluginRegistryInitObject(RwPluginRegistry const* reg, void* object) { EAXJMP(0x5C37F0); } -WRAPPER RwPluginRegistry const* _rwPluginRegistryDeInitObject(RwPluginRegistry const* reg, void* object) { EAXJMP(0x5C3850); } -WRAPPER RwPluginRegistry const* _rwPluginRegistryCopyObject(RwPluginRegistry const* reg, void* dstObject, void const* srcObject) { EAXJMP(0x5C3880); } -WRAPPER RwError* RwErrorSet(RwError* code) { EAXJMP(0x5C3910); } -WRAPPER RwInt32 _rwerror(RwInt32 code, ...) { EAXJMP(0x5C3970); } -WRAPPER RwInt32 _rwPluginRegistryAddPluginStream(RwPluginRegistry* reg, RwUInt32 pluginID, RwPluginDataChunkReadCallBack readCB, RwPluginDataChunkWriteCallBack writeCB, RwPluginDataChunkGetSizeCallBack getSizeCB) { EAXJMP(0x5C3980); } -WRAPPER RwInt32 _rwPluginRegistryAddPlgnStrmlwysCB(RwPluginRegistry* reg, RwUInt32 pluginID, RwPluginDataChunkAlwaysCallBack alwaysCB) { EAXJMP(0x5C39C0); } -WRAPPER RwInt32 _rwPluginRegistryAddPlgnStrmRightsCB(RwPluginRegistry* reg, RwUInt32 pluginID, RwPluginDataChunkRightsCallBack rightsCB) { EAXJMP(0x5C39F0); } -WRAPPER RwPluginRegistry const* _rwPluginRegistryReadDataChunks(RwPluginRegistry const* reg, RwStream* stream, void* object) { EAXJMP(0x5C3A20); } -WRAPPER RwPluginRegistry const* _rwPluginRegistryInvokeRights(RwPluginRegistry const* reg, RwUInt32 id, void* obj, RwUInt32 extraData) { EAXJMP(0x5C3B50); } -WRAPPER RwInt32 _rwPluginRegistryGetSize(RwPluginRegistry const* reg, void const* object) { EAXJMP(0x5C3BA0); } -WRAPPER RwPluginRegistry const* _rwPluginRegistryWriteDataChunks(RwPluginRegistry const* reg, RwStream* stream, void const* object) { EAXJMP(0x5C3BE0); } -WRAPPER RwPluginRegistry const* _rwPluginRegistrySkipDataChunks(RwPluginRegistry const* reg, RwStream* stream) { EAXJMP(0x5C3CB0); } -WRAPPER RwCamera* RwCameraStreamRead(RwStream* stream) { EAXJMP(0x5C3D30); } -WRAPPER RwBBox* RwBBoxCalculate(RwBBox* boundBox, RwV3d const* verts, RwInt32 numVerts) { EAXJMP(0x5C5570); } -WRAPPER RwImage* RwImageResample(RwImage* dstImage, RwImage const* srcImage) { EAXJMP(0x5C72B0); } -WRAPPER RwImage* RwImageCreateResample(RwImage const* srcImage, RwInt32 width, RwInt32 height) { EAXJMP(0x5C7B30); } -WRAPPER RxRenderStateVector* RxRenderStateVectorSetDefaultRenderStateVector(RxRenderStateVector* rsvp) { EAXJMP(0x5D9240); } -WRAPPER RxRenderStateVector* RxRenderStateVectorCreate(RwBool current) { EAXJMP(0x5D9340); } -WRAPPER void RxRenderStateVectorDestroy(RxRenderStateVector* rsvp) { EAXJMP(0x5D9410); } -WRAPPER RxRenderStateVector* RxRenderStateVectorLoadDriverState(RxRenderStateVector* rsvp) { EAXJMP(0x5D9460); } -WRAPPER void _rxEmbeddedPacketBetweenPipelines(RxPipeline* fromPipeline, RxPipeline* toPipeline) { EAXJMP(0x5D95D0); } -WRAPPER RxPipelineNode* _rxEmbeddedPacketBetweenNodes(RxPipeline* pipeline, RxPipelineNode* nodeFrom, RwUInt32 whichOutput) { EAXJMP(0x5D9740); } -WRAPPER void _rxPacketDestroy(RxPacket* Packet) { EAXJMP(0x5D9810); } -WRAPPER RpMaterialList* _rpMaterialListDeinitialize(RpMaterialList* matList) { EAXJMP(0x5C8B10); } -WRAPPER RpMaterialList* _rpMaterialListInitialize(RpMaterialList* matList) { EAXJMP(0x5C8B70); } -WRAPPER RpMaterial* _rpMaterialListGetMaterial(RpMaterialList const* matList, RwInt32 matIndex) { EAXJMP(0x5C8B80); } -WRAPPER RwInt32 _rpMaterialListAppendMaterial(RpMaterialList* matList, RpMaterial* material) { EAXJMP(0x5C8B90); } -WRAPPER RwInt32 _rpMaterialListFindMaterialIndex(RpMaterialList const* matList, RpMaterial const* material) { EAXJMP(0x5C8C50); } -WRAPPER RpMaterialList* _rpMaterialListStreamRead(RwStream* stream, RpMaterialList* matList) { EAXJMP(0x5C8C80); } -WRAPPER RpMeshHeader* _rpMeshHeaderCreate(RwUInt32 size) { EAXJMP(0x5C8FE0); } -WRAPPER void* _rpMeshClose(void* instance, RwInt32 offset, RwInt32 size) { EAXJMP(0x5C8FF0); } -WRAPPER void* _rpMeshOpen(void* instance, RwInt32 offset, RwInt32 size) { EAXJMP(0x5C9020); } -WRAPPER RpBuildMesh* _rpBuildMeshCreate(RwUInt32 bufferSize) { EAXJMP(0x5C9140); } -WRAPPER RwBool _rpBuildMeshDestroy(RpBuildMesh* mesh) { EAXJMP(0x5C9220); } -WRAPPER RwBool _rpMeshDestroy(RpMeshHeader* mesh) { EAXJMP(0x5C9260); } -WRAPPER RpBuildMesh* _rpBuildMeshAddTriangle(RpBuildMesh* mesh, RpMaterial* material, RwInt32 vert1, RwInt32 vert2, RwInt32 vert3) { EAXJMP(0x5C92A0); } -WRAPPER RpMeshHeader* _rpMeshHeaderForAllMeshes(RpMeshHeader* meshHeader, RpMeshCallBack fpCallBack, void* pData) { EAXJMP(0x5C9380); } -WRAPPER RwStream* _rpMeshWrite(RpMeshHeader const* meshHeader, void const* object, RwStream* stream, RpMaterialList const* matList) { EAXJMP(0x5C93C0); } -WRAPPER RpMeshHeader* _rpMeshRead(RwStream* stream, void const* object, RpMaterialList const* matList) { EAXJMP(0x5C9510); } -WRAPPER RwInt32 _rpMeshSize(RpMeshHeader const* meshHeader, void const* object) { EAXJMP(0x5C96E0); } -WRAPPER RpMeshHeader* RpBuildMeshGenerateDefaultTriStrip(RpBuildMesh* buildmesh, void* data) { EAXJMP(0x5C9730); } -WRAPPER RpMeshHeader* _rpTriListMeshGenerate(RpBuildMesh* buildMesh, void* data) { EAXJMP(0x5CAE10); } -WRAPPER RpMeshHeader* _rpMeshOptimise(RpBuildMesh* buildmesh, RwUInt32 flags) { EAXJMP(0x5CB230); } -WRAPPER RwInt32 RpWorldSectorRegisterPlugin(RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor ructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB) { EAXJMP(0x5CB2B0); } -WRAPPER RwInt32 RpWorldSectorRegisterPluginStream(RwUInt32 pluginID, RwPluginDataChunkReadCallBack readCB, RwPluginDataChunkWriteCallBack writeCB, RwPluginDataChunkGetSizeCallBack getSizeCB) { EAXJMP(0x5CB2E0); } -WRAPPER RxPipeline* RpWorldSetDefaultSectorPipeline(RxPipeline* pipeline) { EAXJMP(0x5CB630); } -WRAPPER RxPipeline* RpAtomicSetDefaultPipeline(RxPipeline* pipeline) { EAXJMP(0x5CB670); } -WRAPPER void RpHAnimStdKeyFrameToMatrix(RwMatrix* matrix, void* voidIFrame) { EAXJMP(0x5CDEE0); } -WRAPPER void RpHAnimStdKeyFrameInterpolate(void* voidOut, void* voidIn1, void* voidIn2, RwReal time) { EAXJMP(0x5CE000); } -WRAPPER void RpHAnimStdKeyFrameBlend(void* voidOut, void* voidIn1, void* voidIn2, RwReal alpha) { EAXJMP(0x5CE420); } -WRAPPER RpHAnimAnimation* RpHAnimStdKeyFrameStreamRead(RwStream* stream, RpHAnimAnimation* animation) { EAXJMP(0x5CE820); } -WRAPPER RwBool RpHAnimStdKeyFrameStreamWrite(RpHAnimAnimation* animation, RwStream* stream) { EAXJMP(0x5CE8C0); } -WRAPPER RwInt32 RpHAnimStdKeyFrameStreamGetSize(RpHAnimAnimation* animation) { EAXJMP(0x5CE930); } -WRAPPER void RpHAnimStdKeyFrameMulRecip(void* voidFrame, void* voidStart) { EAXJMP(0x5CE950); } -WRAPPER void RpHAnimStdKeyFrameAdd(void* voidOut, void* voidIn1, void* voidIn2) { EAXJMP(0x5CEAB0); } -WRAPPER void RxHeapFree(RxHeap* heap, void* block) { EAXJMP(0x5D1070); } -WRAPPER void* RxHeapAlloc(RxHeap* heap, RwUInt32 size) { EAXJMP(0x5D1260); } -WRAPPER void* RxHeapRealloc(RxHeap* heap, void* block, RwUInt32 newSize, RwBool allowCopy) { EAXJMP(0x5D14D0); } -WRAPPER RwBool _rxHeapReset(RxHeap* heap) { EAXJMP(0x5D1680); } -WRAPPER void RxHeapDestroy(RxHeap* heap) { EAXJMP(0x5D16F0); } -WRAPPER RxHeap* RxHeapCreate(RwUInt32 size) { EAXJMP(0x5D1750); } -WRAPPER RxNodeOutput RxPipelineNodeFindOutputByName(RxPipelineNode* node, RwChar const* outputname) { EAXJMP(0x5D1EC0); } -WRAPPER RxNodeInput RxPipelineNodeFindInput(RxPipelineNode* node) { EAXJMP(0x5D1F20); } -WRAPPER RxPipeline* RxPipelineNodeRequestCluster(RxPipeline* pipeline, RxPipelineNode* node, RxClusterDefinition* clusterDef) { EAXJMP(0x5D1F30); } -WRAPPER RxPipeline* RxLockedPipeUnlock(RxLockedPipe* pipeline) { EAXJMP(0x5D1FA0); } -WRAPPER RxLockedPipe* RxPipelineLock(RxPipeline* pipeline) { EAXJMP(0x5D29F0); } -WRAPPER RxPipelineNode* RxPipelineFindNodeByName(RxPipeline* pipeline, RwChar const* name, RxPipelineNode* start, RwInt32* nodeIndex) { EAXJMP(0x5D2B10); } -WRAPPER RxLockedPipe* RxLockedPipeAddFragment(RxLockedPipe *pipeline, RwUInt32 *firstIndex, RxNodeDefinition *nodeDef0, ...) { EAXJMP(0x5D2BA0); } -WRAPPER RxPipeline* RxLockedPipeAddPath(RxLockedPipe* pipeline, RxNodeOutput out, RxNodeInput in) { EAXJMP(0x5D2EE0); } -WRAPPER RxNodeDefinition* RxNodeDefinitionGetImmRenderSetup() { EAXJMP(0x5D31C0); } -WRAPPER RxNodeDefinition* RxNodeDefinitionGetImmMangleTriangleIndices() { EAXJMP(0x5D35C0); } -WRAPPER RxNodeDefinition* RxNodeDefinitionGetCullTriangle() { EAXJMP(0x5D3C60); } -WRAPPER RxNodeDefinition* RxNodeDefinitionGetClipTriangle() { EAXJMP(0x5D4F80); } -WRAPPER RxNodeDefinition* RxNodeDefinitionGetSubmitTriangle() { EAXJMP(0x5D51C0); } -WRAPPER RxNodeDefinition* RxNodeDefinitionGetImmInstance() { EAXJMP(0x5D5400); } -WRAPPER RxNodeDefinition* RxNodeDefinitionGetTransform() { EAXJMP(0x5D6000); } -WRAPPER RxNodeDefinition* RxNodeDefinitionGetImmStash() { EAXJMP(0x5D61C0); } -WRAPPER RxNodeDefinition* RxNodeDefinitionGetImmMangleLineIndices() { EAXJMP(0x5D6470); } -WRAPPER RxNodeDefinition* RxNodeDefinitionGetClipLine() { EAXJMP(0x5D7230); } -WRAPPER RxNodeDefinition* RxNodeDefinitionGetSubmitLine() { EAXJMP(0x5D74C0); } -WRAPPER RwBool _rwD3D8LightsOpen() { EAXJMP(0x5D9C90); } -WRAPPER void _rwD3D8LightsClose() { EAXJMP(0x5D9EF0); } -WRAPPER RwBool _rwD3D8LightsGlobalEnable(RpLightFlag flags) { EAXJMP(0x5D9F80); } -WRAPPER RwBool _rwD3D8LightLocalEnable(RpLight* light) { EAXJMP(0x5DA210); } -WRAPPER void _rwD3D8LightsEnable(RwBool enable, RwUInt32 type) { EAXJMP(0x5DA450); } -WRAPPER RxNodeDefinition* RxNodeDefinitionGetD3D8WorldSectorAllInOne() { EAXJMP(0x5DAAC0); } -WRAPPER RxNodeDefinition* RxNodeDefinitionGetD3D8AtomicAllInOne() { EAXJMP(0x5DC500); } -WRAPPER RxNodeDefinition* RxNodeDefinitionGetWorldSectorInstance() { EAXJMP(0x5DCC50); } -WRAPPER RxNodeDefinition* RxNodeDefinitionGetWorldSectorEnumerateLights() { EAXJMP(0x5DCD80); } -WRAPPER RxNodeDefinition* RxNodeDefinitionGetAtomicInstance() { EAXJMP(0x5DD800); } -WRAPPER RxNodeDefinition* RxNodeDefinitionGetAtomicEnumerateLights() { EAXJMP(0x5DD9B0); } -WRAPPER RxNodeDefinition* RxNodeDefinitionGetMaterialScatter() { EAXJMP(0x5DDAA0); } -WRAPPER RxNodeDefinition* RxNodeDefinitionGetLight() { EAXJMP(0x5DF040); } -WRAPPER RxNodeDefinition* RxNodeDefinitionGetPostLight() { EAXJMP(0x5DF560); } -WRAPPER void RxD3D8AllInOneSetRenderCallBack(RxPipelineNode* node, RxD3D8AllInOneRenderCallBack callback) { EAXJMP(0x5DFC60); } \ No newline at end of file diff --git a/src/render/Lights.cpp b/src/render/Lights.cpp deleted file mode 100644 index cd83a898..00000000 --- a/src/render/Lights.cpp +++ /dev/null @@ -1,333 +0,0 @@ -#include "common.h" -#include -#include -#include "patcher.h" -#include "Lights.h" -#include "Timecycle.h" -#include "Coronas.h" -#include "Weather.h" -#include "ZoneCull.h" -#include "Frontend.h" - -RpLight *&pAmbient = *(RpLight**)0x885B6C; -RpLight *&pDirect = *(RpLight**)0x880F7C; -RpLight **pExtraDirectionals = (RpLight**)0x60009C; -int *LightStrengths = (int*)0x87BEF0; -int &NumExtraDirLightsInWorld = *(int*)0x64C608; - -RwRGBAReal &AmbientLightColourForFrame = *(RwRGBAReal*)0x6F46F8; -RwRGBAReal &AmbientLightColourForFrame_PedsCarsAndObjects = *(RwRGBAReal*)0x6F1D10; -RwRGBAReal &DirectionalLightColourForFrame = *(RwRGBAReal*)0x87C6B8; - -RwRGBAReal &AmbientLightColour = *(RwRGBAReal*)0x86B0F8; -RwRGBAReal &DirectionalLightColour = *(RwRGBAReal*)0x72E308; - -void -SetLightsWithTimeOfDayColour(RpWorld *) -{ - CVector vec1, vec2, vecsun; - RwMatrix mat; - - if(pAmbient){ - AmbientLightColourForFrame.red = CTimeCycle::GetAmbientRed() * CCoronas::LightsMult; - AmbientLightColourForFrame.green = CTimeCycle::GetAmbientGreen() * CCoronas::LightsMult; - AmbientLightColourForFrame.blue = CTimeCycle::GetAmbientBlue() * CCoronas::LightsMult; - if(CWeather::LightningFlash && !CCullZones::CamNoRain()){ - AmbientLightColourForFrame.red = 1.0f; - AmbientLightColourForFrame.green = 1.0f; - AmbientLightColourForFrame.blue = 1.0f; - } - AmbientLightColourForFrame_PedsCarsAndObjects.red = min(1.0f, AmbientLightColourForFrame.red*1.3f); - AmbientLightColourForFrame_PedsCarsAndObjects.green = min(1.0f, AmbientLightColourForFrame.green*1.3f); - AmbientLightColourForFrame_PedsCarsAndObjects.blue = min(1.0f, AmbientLightColourForFrame.blue*1.3f); - RpLightSetColor(pAmbient, &AmbientLightColourForFrame); - } - - if(pDirect){ - DirectionalLightColourForFrame.red = CTimeCycle::GetDirectionalRed() * CCoronas::LightsMult; - DirectionalLightColourForFrame.green = CTimeCycle::GetDirectionalGreen() * CCoronas::LightsMult; - DirectionalLightColourForFrame.blue = CTimeCycle::GetDirectionalBlue() * CCoronas::LightsMult; - RpLightSetColor(pDirect, &DirectionalLightColourForFrame); - - vecsun = CTimeCycle::m_VectorToSun[CTimeCycle::m_CurrentStoredValue]; - vec1 = CVector(0.0f, 0.0f, 1.0f); - vec2 = CrossProduct(vec1, vecsun); - vec2.Normalise(); - vec1 = CrossProduct(vec2, vecsun); - mat.at.x = -vecsun.x; - mat.at.y = -vecsun.y; - mat.at.z = -vecsun.z; - mat.right.x = vec1.x; - mat.right.y = vec1.y; - mat.right.z = vec1.z; - mat.up.x = vec2.x; - mat.up.y = vec2.y; - mat.up.z = vec2.z; - RwFrameTransform(RpLightGetFrame(pDirect), &mat, rwCOMBINEREPLACE); - } - - if(CMenuManager::m_PrefsBrightness > 256){ - float f1 = 2.0f * (CMenuManager::m_PrefsBrightness/256.0f - 1.0f) * 0.6f + 1.0f; - float f2 = 3.0f * (CMenuManager::m_PrefsBrightness/256.0f - 1.0f) * 0.6f + 1.0f; - - AmbientLightColourForFrame.red = min(1.0f, AmbientLightColourForFrame.red * f2); - AmbientLightColourForFrame.green = min(1.0f, AmbientLightColourForFrame.green * f2); - AmbientLightColourForFrame.blue = min(1.0f, AmbientLightColourForFrame.blue * f2); - AmbientLightColourForFrame_PedsCarsAndObjects.red = min(1.0f, AmbientLightColourForFrame_PedsCarsAndObjects.red * f1); - AmbientLightColourForFrame_PedsCarsAndObjects.green = min(1.0f, AmbientLightColourForFrame_PedsCarsAndObjects.green * f1); - AmbientLightColourForFrame_PedsCarsAndObjects.blue = min(1.0f, AmbientLightColourForFrame_PedsCarsAndObjects.blue * f1); -#ifdef FIX_BUGS - DirectionalLightColourForFrame.red = min(1.0f, DirectionalLightColourForFrame.red * f1); - DirectionalLightColourForFrame.green = min(1.0f, DirectionalLightColourForFrame.green * f1); - DirectionalLightColourForFrame.blue = min(1.0f, DirectionalLightColourForFrame.blue * f1); -#else - DirectionalLightColourForFrame.red = min(1.0f, AmbientLightColourForFrame.red * f1); - DirectionalLightColourForFrame.green = min(1.0f, AmbientLightColourForFrame.green * f1); - DirectionalLightColourForFrame.blue = min(1.0f, AmbientLightColourForFrame.blue * f1); -#endif - } -} - -RpWorld* -LightsCreate(RpWorld *world) -{ - int i; - RwRGBAReal color; - RwFrame *frame; - - if(world == nil) - return nil; - - pAmbient = RpLightCreate(rpLIGHTAMBIENT); - RpLightSetFlags(pAmbient, rpLIGHTLIGHTATOMICS); - color.red = 0.25f; - color.green = 0.25f; - color.blue = 0.2f; - RpLightSetColor(pAmbient, &color); - - pDirect = RpLightCreate(rpLIGHTDIRECTIONAL); - RpLightSetFlags(pDirect, rpLIGHTLIGHTATOMICS); - color.red = 1.0f; - color.green = 0.84f; - color.blue = 0.45f; - RpLightSetColor(pDirect, &color); - RpLightSetRadius(pDirect, 2.0f); - frame = RwFrameCreate(); - RpLightSetFrame(pDirect, frame); - RwV3d axis = { 1.0f, 1.0f, 0.0f }; - RwFrameRotate(frame, &axis, 160.0f, rwCOMBINEPRECONCAT); - - RpWorldAddLight(world, pAmbient); - RpWorldAddLight(world, pDirect); - - for(i = 0; i < NUMEXTRADIRECTIONALS; i++){ - pExtraDirectionals[i] = RpLightCreate(rpLIGHTDIRECTIONAL); - RpLightSetFlags(pExtraDirectionals[i], 0); - color.red = 1.0f; - color.green = 0.5f; - color.blue = 0.0f; - RpLightSetColor(pExtraDirectionals[i], &color); - RpLightSetRadius(pExtraDirectionals[i], 2.0f); - frame = RwFrameCreate(); - RpLightSetFrame(pExtraDirectionals[i], frame); - RpWorldAddLight(world, pExtraDirectionals[i]); - } - - return world; -} - -void -LightsDestroy(RpWorld *world) -{ - int i; - - if(world == nil) - return; - - if(pAmbient){ - RpWorldRemoveLight(world, pAmbient); - RpLightDestroy(pAmbient); - pAmbient = nil; - } - - if(pDirect){ - RpWorldRemoveLight(world, pDirect); - RwFrameDestroy(RpLightGetFrame(pDirect)); - RpLightDestroy(pDirect); - pDirect = nil; - } - - for(i = 0; i < NUMEXTRADIRECTIONALS; i++) - if(pExtraDirectionals[i]){ - RpWorldRemoveLight(world, pExtraDirectionals[i]); - RwFrameDestroy(RpLightGetFrame(pExtraDirectionals[i])); - RpLightDestroy(pExtraDirectionals[i]); - pExtraDirectionals[i] = nil; - } -} - -void -WorldReplaceNormalLightsWithScorched(RpWorld *world, float l) -{ - RwRGBAReal color; - color.red = l; - color.green = l; - color.blue = l; - RpLightSetColor(pAmbient, &color); - RpLightSetFlags(pDirect, 0); -} - -void -WorldReplaceScorchedLightsWithNormal(RpWorld *world) -{ - RpLightSetColor(pAmbient, &AmbientLightColourForFrame); - RpLightSetFlags(pDirect, rpLIGHTLIGHTATOMICS); -} - -void -AddAnExtraDirectionalLight(RpWorld *world, float dirx, float diry, float dirz, float red, float green, float blue) -{ - float strength; - int weakest; - int i, n; - RwRGBAReal color; - RwV3d *dir; - - strength = max(max(red, green), blue); - n = -1; - if(NumExtraDirLightsInWorld < NUMEXTRADIRECTIONALS) - n = NumExtraDirLightsInWorld; - else{ - weakest = strength; - for(i = 0; i < NUMEXTRADIRECTIONALS; i++) - if(LightStrengths[i] < weakest){ - weakest = LightStrengths[i]; - n = i; - } - } - - if(n < 0) - return; - - color.red = red; - color.green = green; - color.blue = blue; - RpLightSetColor(pExtraDirectionals[n], &color); - dir = RwMatrixGetAt(RwFrameGetMatrix(RpLightGetFrame(pExtraDirectionals[n]))); - dir->x = -dirx; - dir->y = -diry; - dir->z = -dirz; - RwMatrixUpdate(RwFrameGetMatrix(RpLightGetFrame(pExtraDirectionals[n]))); - RwFrameUpdateObjects(RpLightGetFrame(pExtraDirectionals[n])); - RpLightSetFlags(pExtraDirectionals[n], rpLIGHTLIGHTATOMICS); - LightStrengths[n] = strength; - NumExtraDirLightsInWorld = min(NumExtraDirLightsInWorld+1, NUMEXTRADIRECTIONALS); -} - -void -RemoveExtraDirectionalLights(RpWorld *world) -{ - int i; - for(i = 0; i < NumExtraDirLightsInWorld; i++) - RpLightSetFlags(pExtraDirectionals[i], 0); - NumExtraDirLightsInWorld = 0; -} - -void -SetAmbientAndDirectionalColours(float f) -{ - AmbientLightColour.red = AmbientLightColourForFrame.red * f; - AmbientLightColour.green = AmbientLightColourForFrame.green * f; - AmbientLightColour.blue = AmbientLightColourForFrame.blue * f; - - DirectionalLightColour.red = DirectionalLightColourForFrame.red * f; - DirectionalLightColour.green = DirectionalLightColourForFrame.green * f; - DirectionalLightColour.blue = DirectionalLightColourForFrame.blue * f; - - RpLightSetColor(pAmbient, &AmbientLightColour); - RpLightSetColor(pDirect, &DirectionalLightColour); -} - -void -SetBrightMarkerColours(float f) -{ - AmbientLightColour.red = 0.6f; - AmbientLightColour.green = 0.6f; - AmbientLightColour.blue = 0.6f; - - DirectionalLightColour.red = (1.0f - DirectionalLightColourForFrame.red) * 0.4f + DirectionalLightColourForFrame.red; - DirectionalLightColour.green = (1.0f - DirectionalLightColourForFrame.green) * 0.4f + DirectionalLightColourForFrame.green; - DirectionalLightColour.blue = (1.0f - DirectionalLightColourForFrame.blue) * 0.4f + DirectionalLightColourForFrame.blue; - - RpLightSetColor(pAmbient, &AmbientLightColour); - RpLightSetColor(pDirect, &DirectionalLightColour); -} - -void -ReSetAmbientAndDirectionalColours(void) -{ - RpLightSetColor(pAmbient, &AmbientLightColourForFrame); - RpLightSetColor(pDirect, &DirectionalLightColourForFrame); -} - -void -DeActivateDirectional(void) -{ - RpLightSetFlags(pDirect, 0); -} - -void -ActivateDirectional(void) -{ - RpLightSetFlags(pDirect, rpLIGHTLIGHTATOMICS); -} - -void -SetAmbientColours(void) -{ - RpLightSetColor(pAmbient, &AmbientLightColourForFrame); -} - -void -SetAmbientColoursForPedsCarsAndObjects(void) -{ - RpLightSetColor(pAmbient, &AmbientLightColourForFrame_PedsCarsAndObjects); -} - -uint8 IndicateR[] = { 0, 255, 0, 0, 255, 255, 0 }; -uint8 IndicateG[] = { 0, 0, 255, 0, 255, 0, 255 }; -uint8 IndicateB[] = { 0, 0, 0, 255, 0, 255, 255 }; - -void -SetAmbientColoursToIndicateRoadGroup(int i) -{ - AmbientLightColour.red = IndicateR[i%7]/255.0f; - AmbientLightColour.green = IndicateG[i%7]/255.0f; - AmbientLightColour.blue = IndicateB[i%7]/255.0f; - RpLightSetColor(pAmbient, &AmbientLightColour); -} - -void -SetAmbientColours(RwRGBAReal *color) -{ - RpLightSetColor(pAmbient, color); -} - - -STARTPATCHES - InjectHook(0x526510, SetLightsWithTimeOfDayColour, PATCH_JUMP); - InjectHook(0x5269A0, LightsCreate, PATCH_JUMP); - InjectHook(0x526B40, LightsDestroy, PATCH_JUMP); - InjectHook(0x526C10, WorldReplaceNormalLightsWithScorched, PATCH_JUMP); - InjectHook(0x526C50, WorldReplaceScorchedLightsWithNormal, PATCH_JUMP); - InjectHook(0x526C70, AddAnExtraDirectionalLight, PATCH_JUMP); - InjectHook(0x526DB0, RemoveExtraDirectionalLights, PATCH_JUMP); - InjectHook(0x526DE0, SetAmbientAndDirectionalColours, PATCH_JUMP); - InjectHook(0x526E60, SetBrightMarkerColours, PATCH_JUMP); - InjectHook(0x526F10, ReSetAmbientAndDirectionalColours, PATCH_JUMP); - InjectHook(0x526F40, DeActivateDirectional, PATCH_JUMP); - InjectHook(0x526F50, ActivateDirectional, PATCH_JUMP); - InjectHook(0x526F60, (void (*)(void))SetAmbientColours, PATCH_JUMP); - InjectHook(0x526F80, SetAmbientColoursForPedsCarsAndObjects, PATCH_JUMP); - InjectHook(0x526FA0, (void (*)(RwRGBAReal*))SetAmbientColours, PATCH_JUMP); -ENDPATCHES diff --git a/src/render/Lights.h b/src/render/Lights.h deleted file mode 100644 index 6fdd51de..00000000 --- a/src/render/Lights.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -void SetLightsWithTimeOfDayColour(RpWorld *); -RpWorld *LightsCreate(RpWorld *world); -void LightsDestroy(RpWorld *world); -void WorldReplaceNormalLightsWithScorched(RpWorld *world, float l); -void WorldReplaceScorchedLightsWithNormal(RpWorld *world); -void AddAnExtraDirectionalLight(RpWorld *world, float dirx, float diry, float dirz, float red, float green, float blue); -void RemoveExtraDirectionalLights(RpWorld *world); -void SetAmbientAndDirectionalColours(float f); -void SetBrightMarkerColours(float f); -void ReSetAmbientAndDirectionalColours(void); -void DeActivateDirectional(void); -void ActivateDirectional(void); -void SetAmbientColours(void); -void SetAmbientColoursForPedsCarsAndObjects(void); -void SetAmbientColoursToIndicateRoadGroup(int i); -void SetAmbientColours(RwRGBAReal *color); diff --git a/src/render/VisibilityPlugins.cpp b/src/render/VisibilityPlugins.cpp deleted file mode 100644 index f8b1f6b2..00000000 --- a/src/render/VisibilityPlugins.cpp +++ /dev/null @@ -1,889 +0,0 @@ -#include "common.h" -#include "patcher.h" -#include "templates.h" -#include "Entity.h" -#include "ModelInfo.h" -#include "Lights.h" -#include "Renderer.h" -#include "Camera.h" -#include "VisibilityPlugins.h" -#include "World.h" - -#define FADE_DISTANCE 20.0f - -/* -CLinkList CVisibilityPlugins::m_alphaList; -CLinkList CVisibilityPlugins::m_alphaEntityList; - -int32 CVisibilityPlugins::ms_atomicPluginOffset = -1; -int32 CVisibilityPlugins::ms_framePluginOffset = -1; -int32 CVisibilityPlugins::ms_clumpPluginOffset = -1; -*/ -CLinkList &CVisibilityPlugins::m_alphaList = *(CLinkList*)0x8F42E4; -CLinkList &CVisibilityPlugins::m_alphaEntityList = *(CLinkList*)0x943084; - -int32 &CVisibilityPlugins::ms_atomicPluginOffset = *(int32*)0x600124; -int32 &CVisibilityPlugins::ms_framePluginOffset = *(int32*)0x600128; -int32 &CVisibilityPlugins::ms_clumpPluginOffset = *(int32*)0x60012C; - -RwCamera *&CVisibilityPlugins::ms_pCamera = *(RwCamera**)0x8F2514; -RwV3d *&CVisibilityPlugins::ms_pCameraPosn = *(RwV3d**)0x8F6270; -float &CVisibilityPlugins::ms_cullCompsDist = *(float*)0x8F2BC4; -float &CVisibilityPlugins::ms_vehicleLod0Dist = *(float*)0x885B28; -float &CVisibilityPlugins::ms_vehicleLod1Dist = *(float*)0x885B30; -float &CVisibilityPlugins::ms_vehicleFadeDist = *(float*)0x8E28B4; -float &CVisibilityPlugins::ms_bigVehicleLod0Dist = *(float*)0x8E2A84; -float &CVisibilityPlugins::ms_bigVehicleLod1Dist = *(float*)0x8E2A8C; -float &CVisibilityPlugins::ms_pedLod0Dist = *(float*)0x8F2BD4; -float &CVisibilityPlugins::ms_pedLod1Dist = *(float*)0x8F2BD8; -float &CVisibilityPlugins::ms_pedFadeDist = *(float*)0x8E2C34; - -void -CVisibilityPlugins::Initialise(void) -{ - m_alphaList.Init(20); - m_alphaList.head.item.sort = 0.0f; - m_alphaList.tail.item.sort = 100000000.0f; - m_alphaEntityList.Init(150); - m_alphaEntityList.head.item.sort = 0.0f; - m_alphaEntityList.tail.item.sort = 100000000.0f; -} - -void -CVisibilityPlugins::Shutdown(void) -{ - m_alphaList.Shutdown(); - m_alphaEntityList.Shutdown(); -} - -void -CVisibilityPlugins::InitAlphaEntityList(void) -{ - m_alphaEntityList.Clear(); -} - -bool -CVisibilityPlugins::InsertEntityIntoSortedList(CEntity *e, float dist) -{ - AlphaObjectInfo item; - item.entity = e; - item.sort = dist; - bool ret = !!m_alphaEntityList.InsertSorted(item); -// if(!ret) -// printf("list full %d\n", m_alphaEntityList.Count()); - return ret; -} - -void -CVisibilityPlugins::InitAlphaAtomicList(void) -{ - m_alphaList.Clear(); -} - -bool -CVisibilityPlugins::InsertAtomicIntoSortedList(RpAtomic *a, float dist) -{ - AlphaObjectInfo item; - item.atomic = a; - item.sort = dist; - bool ret = !!m_alphaList.InsertSorted(item); -// if(!ret) -// printf("list full %d\n", m_alphaList.Count()); - return ret; -} - -void -CVisibilityPlugins::SetRenderWareCamera(RwCamera *camera) -{ - ms_pCamera = camera; - ms_pCameraPosn = RwMatrixGetPos(RwFrameGetMatrix(RwCameraGetFrame(camera))); - - if(TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN || - TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOP_DOWN_PED) - ms_cullCompsDist = 1000000.0f; - else - ms_cullCompsDist = sq(TheCamera.LODDistMultiplier * 20.0f); - - ms_vehicleLod0Dist = sq(70.0f * TheCamera.GenerationDistMultiplier); - ms_vehicleLod1Dist = sq(90.0f * TheCamera.GenerationDistMultiplier); - ms_vehicleFadeDist = sq(100.0f * TheCamera.GenerationDistMultiplier); - ms_bigVehicleLod0Dist = sq(60.0f * TheCamera.GenerationDistMultiplier); - ms_bigVehicleLod1Dist = sq(150.0f * TheCamera.GenerationDistMultiplier); - ms_pedLod0Dist = sq(25.0f * TheCamera.LODDistMultiplier); - ms_pedLod1Dist = sq(60.0f * TheCamera.LODDistMultiplier); - ms_pedFadeDist = sq(70.0f * TheCamera.LODDistMultiplier); -} - -RpMaterial* -SetAlphaCB(RpMaterial *material, void *data) -{ - ((RwRGBA*)RpMaterialGetColor(material))->alpha = (uint8)(uint32)data; - return material; -} - -RpMaterial* -SetTextureCB(RpMaterial *material, void *data) -{ - RpMaterialSetTexture(material, (RwTexture*)data); - return material; -} - -void -CVisibilityPlugins::RenderAlphaAtomics(void) -{ - CLink *node; - for(node = m_alphaList.tail.prev; - node != &m_alphaList.head; - node = node->prev) - AtomicDefaultRenderCallBack(node->item.atomic); -} - -void -CVisibilityPlugins::RenderFadingEntities(void) -{ - CLink *node; - CSimpleModelInfo *mi; - for(node = m_alphaEntityList.tail.prev; - node != &m_alphaEntityList.head; - node = node->prev){ - CEntity *e = node->item.entity; - if(e->m_rwObject == nil) - continue; - mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(e->m_modelIndex); - if(mi->m_noZwrite) - RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, FALSE); - - if(e->bDistanceFade){ - DeActivateDirectional(); - SetAmbientColours(); - e->bImBeingRendered = true; - RenderFadingAtomic((RpAtomic*)e->m_rwObject, node->item.sort); - e->bImBeingRendered = false; - }else - CRenderer::RenderOneNonRoad(e); - - if(mi->m_noZwrite) - RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE); - } -} - -RpAtomic* -CVisibilityPlugins::RenderWheelAtomicCB(RpAtomic *atomic) -{ - RpAtomic *lodatm; - RwMatrix *m; - RwV3d view; - float len; - CSimpleModelInfo *mi; - - mi = GetAtomicModelInfo(atomic); - m = RwFrameGetLTM(RpAtomicGetFrame(atomic)); - RwV3dSub(&view, RwMatrixGetPos(m), ms_pCameraPosn); - len = RwV3dLength(&view); - lodatm = mi->GetAtomicFromDistance(len); - if(lodatm){ - if(RpAtomicGetGeometry(lodatm) != RpAtomicGetGeometry(atomic)) - RpAtomicSetGeometry(atomic, RpAtomicGetGeometry(lodatm), rpATOMICSAMEBOUNDINGSPHERE); - AtomicDefaultRenderCallBack(atomic); - } - return atomic; -} - -RpAtomic* -CVisibilityPlugins::RenderObjNormalAtomic(RpAtomic *atomic) -{ - RwMatrix *m; - RwV3d view; - float len; - - m = RwFrameGetLTM(RpAtomicGetFrame(atomic)); - RwV3dSub(&view, RwMatrixGetPos(m), ms_pCameraPosn); - len = RwV3dLength(&view); - if(RwV3dDotProduct(&view, RwMatrixGetUp(m)) < -0.3f*len && len > 8.0f) - return atomic; - AtomicDefaultRenderCallBack(atomic); - return atomic; -} - -RpAtomic* -CVisibilityPlugins::RenderAlphaAtomic(RpAtomic *atomic, int alpha) -{ - RpGeometry *geo; - uint32 flags; - - geo = RpAtomicGetGeometry(atomic); - flags = RpGeometryGetFlags(geo); - RpGeometrySetFlags(geo, flags | rpGEOMETRYMODULATEMATERIALCOLOR); - RpGeometryForAllMaterials(geo, SetAlphaCB, (void*)alpha); - AtomicDefaultRenderCallBack(atomic); - RpGeometryForAllMaterials(geo, SetAlphaCB, (void*)255); - RpGeometrySetFlags(geo, flags); - return atomic; -} - -RpAtomic* -CVisibilityPlugins::RenderFadingAtomic(RpAtomic *atomic, float camdist) -{ - RpAtomic *lodatm; - float fadefactor; - uint8 alpha; - CSimpleModelInfo *mi; - - mi = GetAtomicModelInfo(atomic); - lodatm = mi->GetAtomicFromDistance(camdist - FADE_DISTANCE); - if(mi->m_additive){ - RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE); - AtomicDefaultRenderCallBack(atomic); - RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); - }else{ - fadefactor = (mi->GetLargestLodDistance() - (camdist - FADE_DISTANCE))/FADE_DISTANCE; - if(fadefactor > 1.0f) - fadefactor = 1.0f; - alpha = mi->m_alpha * fadefactor; - if(alpha == 255) - AtomicDefaultRenderCallBack(atomic); - else{ - RpGeometry *geo = RpAtomicGetGeometry(lodatm); - uint32 flags = RpGeometryGetFlags(geo); - RpGeometrySetFlags(geo, flags | rpGEOMETRYMODULATEMATERIALCOLOR); - RpGeometryForAllMaterials(geo, SetAlphaCB, (void*)alpha); - if(geo != RpAtomicGetGeometry(atomic)) - RpAtomicSetGeometry(atomic, geo, rpATOMICSAMEBOUNDINGSPHERE); // originally 5 (mistake?) - AtomicDefaultRenderCallBack(atomic); - RpGeometryForAllMaterials(geo, SetAlphaCB, (void*)255); - RpGeometrySetFlags(geo, flags); - } - } - return atomic; -} - - - -RpAtomic* -CVisibilityPlugins::RenderVehicleHiDetailCB(RpAtomic *atomic) -{ - RwFrame *clumpframe; - float distsq, dot; - uint32 flags; - - clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); - distsq = GetDistanceSquaredFromCamera(clumpframe); - if(distsq < ms_vehicleLod0Dist){ - flags = GetAtomicId(atomic); - if(distsq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0){ - dot = GetDotProductWithCameraVector(RwFrameGetLTM(RpAtomicGetFrame(atomic)), - RwFrameGetLTM(clumpframe), flags); - if(dot > 0.0f && ((flags & ATOMIC_FLAG_ANGLECULL) || 0.1f*distsq < dot*dot)) - return atomic; - } - AtomicDefaultRenderCallBack(atomic); - } - return atomic; -} - -RpAtomic* -CVisibilityPlugins::RenderVehicleHiDetailAlphaCB(RpAtomic *atomic) -{ - RwFrame *clumpframe; - float distsq, dot; - uint32 flags; - - clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); - distsq = GetDistanceSquaredFromCamera(clumpframe); - if(distsq < ms_vehicleLod0Dist){ - flags = GetAtomicId(atomic); - dot = GetDotProductWithCameraVector(RwFrameGetLTM(RpAtomicGetFrame(atomic)), - RwFrameGetLTM(clumpframe), flags); - if(distsq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0) - if(dot > 0.0f && ((flags & ATOMIC_FLAG_ANGLECULL) || 0.1f*distsq < dot*dot)) - return atomic; - - if(flags & ATOMIC_FLAG_DRAWLAST){ - // sort before clump - if(!InsertAtomicIntoSortedList(atomic, distsq - 0.0001f)) - AtomicDefaultRenderCallBack(atomic); - }else{ - if(!InsertAtomicIntoSortedList(atomic, distsq + dot)) - AtomicDefaultRenderCallBack(atomic); - } - } - return atomic; -} - -RpAtomic* -CVisibilityPlugins::RenderVehicleHiDetailCB_BigVehicle(RpAtomic *atomic) -{ - RwFrame *clumpframe; - float distsq, dot; - uint32 flags; - - clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); - distsq = GetDistanceSquaredFromCamera(clumpframe); - if(distsq < ms_bigVehicleLod0Dist){ - flags = GetAtomicId(atomic); - if(distsq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0){ - dot = GetDotProductWithCameraVector(RwFrameGetLTM(RpAtomicGetFrame(atomic)), - RwFrameGetLTM(clumpframe), flags); - if(dot > 0.0f) - return atomic; - } - AtomicDefaultRenderCallBack(atomic); - } - return atomic; -} - -RpAtomic* -CVisibilityPlugins::RenderVehicleHiDetailAlphaCB_BigVehicle(RpAtomic *atomic) -{ - RwFrame *clumpframe; - float distsq, dot; - uint32 flags; - - clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); - distsq = GetDistanceSquaredFromCamera(clumpframe); - if(distsq < ms_bigVehicleLod0Dist){ - flags = GetAtomicId(atomic); - dot = GetDotProductWithCameraVector(RwFrameGetLTM(RpAtomicGetFrame(atomic)), - RwFrameGetLTM(clumpframe), flags); - if(dot > 0.0f) - if(distsq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0) - return atomic; - - if(!InsertAtomicIntoSortedList(atomic, distsq + dot)) - AtomicDefaultRenderCallBack(atomic); - } - return atomic; -} - -RpAtomic* -CVisibilityPlugins::RenderVehicleHiDetailCB_Boat(RpAtomic *atomic) -{ - RwFrame *clumpframe; - float distsq; - - clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); - distsq = GetDistanceSquaredFromCamera(clumpframe); - if(distsq < ms_bigVehicleLod1Dist) - AtomicDefaultRenderCallBack(atomic); - return atomic; -} - -RpAtomic* -CVisibilityPlugins::RenderVehicleLowDetailCB_BigVehicle(RpAtomic *atomic) -{ - RwFrame *clumpframe; - float distsq, dot; - uint32 flags; - - clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); - distsq = GetDistanceSquaredFromCamera(clumpframe); - if(distsq >= ms_bigVehicleLod0Dist && - distsq < ms_bigVehicleLod1Dist){ - flags = GetAtomicId(atomic); - if(distsq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0){ - dot = GetDotProductWithCameraVector(RwFrameGetLTM(RpAtomicGetFrame(atomic)), - RwFrameGetLTM(clumpframe), flags); - if(dot > 0.0f) - return atomic; - } - AtomicDefaultRenderCallBack(atomic); - } - return atomic; -} - -RpAtomic* -CVisibilityPlugins::RenderVehicleLowDetailAlphaCB_BigVehicle(RpAtomic *atomic) -{ - RwFrame *clumpframe; - float distsq, dot; - uint32 flags; - - clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); - distsq = GetDistanceSquaredFromCamera(clumpframe); - if(distsq >= ms_bigVehicleLod0Dist && - distsq < ms_bigVehicleLod1Dist){ - flags = GetAtomicId(atomic); - dot = GetDotProductWithCameraVector(RwFrameGetLTM(RpAtomicGetFrame(atomic)), - RwFrameGetLTM(clumpframe), flags); - if(dot > 0.0f) - if(distsq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0) - return atomic; - - if(!InsertAtomicIntoSortedList(atomic, distsq + dot)) - AtomicDefaultRenderCallBack(atomic); - } - return atomic; -} - -RpAtomic* -CVisibilityPlugins::RenderVehicleReallyLowDetailCB(RpAtomic *atomic) -{ - RpClump *clump; - float dist; - int32 alpha; - - clump = RpAtomicGetClump(atomic); - dist = GetDistanceSquaredFromCamera(RpClumpGetFrame(clump)); - if(dist >= ms_vehicleLod0Dist){ - alpha = GetClumpAlpha(clump); - if(alpha == 255) - AtomicDefaultRenderCallBack(atomic); - else - RenderAlphaAtomic(atomic, alpha); - } - return atomic; - -} - -RpAtomic* -CVisibilityPlugins::RenderVehicleReallyLowDetailCB_BigVehicle(RpAtomic *atomic) -{ - RwFrame *clumpframe; - float distsq; - - clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); - distsq = GetDistanceSquaredFromCamera(clumpframe); - if(distsq >= ms_bigVehicleLod1Dist) - AtomicDefaultRenderCallBack(atomic); - return atomic; -} - -RpAtomic* -CVisibilityPlugins::RenderTrainHiDetailCB(RpAtomic *atomic) -{ - RwFrame *clumpframe; - float distsq, dot; - uint32 flags; - - clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); - distsq = GetDistanceSquaredFromCamera(clumpframe); - if(distsq < ms_bigVehicleLod1Dist){ - flags = GetAtomicId(atomic); - if(distsq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0){ - dot = GetDotProductWithCameraVector(RwFrameGetLTM(RpAtomicGetFrame(atomic)), - RwFrameGetLTM(clumpframe), flags); - if(dot > 0.0f && ((flags & ATOMIC_FLAG_ANGLECULL) || 0.1f*distsq < dot*dot)) - return atomic; - } - AtomicDefaultRenderCallBack(atomic); - } - return atomic; -} - -RpAtomic* -CVisibilityPlugins::RenderTrainHiDetailAlphaCB(RpAtomic *atomic) -{ - RwFrame *clumpframe; - float distsq, dot; - uint32 flags; - - clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); - distsq = GetDistanceSquaredFromCamera(clumpframe); - if(distsq < ms_bigVehicleLod1Dist){ - flags = GetAtomicId(atomic); - dot = GetDotProductWithCameraVector(RwFrameGetLTM(RpAtomicGetFrame(atomic)), - RwFrameGetLTM(clumpframe), flags); - if(distsq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0) - if(dot > 0.0f && ((flags & ATOMIC_FLAG_ANGLECULL) || 0.1f*distsq < dot*dot)) - return atomic; - - if(flags & ATOMIC_FLAG_DRAWLAST){ - // sort before clump - if(!InsertAtomicIntoSortedList(atomic, distsq - 0.0001f)) - AtomicDefaultRenderCallBack(atomic); - }else{ - if(!InsertAtomicIntoSortedList(atomic, distsq + dot)) - AtomicDefaultRenderCallBack(atomic); - } - } - return atomic; -} - -RpAtomic* -CVisibilityPlugins::RenderPlayerCB(RpAtomic *atomic) -{ - if(CWorld::Players[0].m_pSkinTexture) - RpGeometryForAllMaterials(RpAtomicGetGeometry(atomic), SetTextureCB, CWorld::Players[0].m_pSkinTexture); - AtomicDefaultRenderCallBack(atomic); - return atomic; -} - -RpAtomic* -CVisibilityPlugins::RenderPedLowDetailCB(RpAtomic *atomic) -{ - RpClump *clump; - float dist; - int32 alpha; - - clump = RpAtomicGetClump(atomic); - dist = GetDistanceSquaredFromCamera(RpClumpGetFrame(clump)); - if(dist >= ms_pedLod0Dist){ - alpha = GetClumpAlpha(clump); - if(alpha == 255) - AtomicDefaultRenderCallBack(atomic); - else - RenderAlphaAtomic(atomic, alpha); - } - return atomic; -} - -RpAtomic* -CVisibilityPlugins::RenderPedHiDetailCB(RpAtomic *atomic) -{ - RpClump *clump; - float dist; - int32 alpha; - - clump = RpAtomicGetClump(atomic); - dist = GetDistanceSquaredFromCamera(RpClumpGetFrame(clump)); - if(dist < ms_pedLod0Dist){ - alpha = GetClumpAlpha(clump); - if(alpha == 255) - AtomicDefaultRenderCallBack(atomic); - else - RenderAlphaAtomic(atomic, alpha); - } - return atomic; -} - -float -CVisibilityPlugins::GetDistanceSquaredFromCamera(RwFrame *frame) -{ - RwMatrix *m; - RwV3d dist; - m = RwFrameGetLTM(frame); - RwV3dSub(&dist, RwMatrixGetPos(m), ms_pCameraPosn); - return RwV3dDotProduct(&dist, &dist); -} - -float -CVisibilityPlugins::GetDotProductWithCameraVector(RwMatrix *atomicMat, RwMatrix *clumpMat, uint32 flags) -{ - RwV3d dist; - float dot, dotdoor; - - // Vehicle forward is the y axis (RwMatrix.up) - // Vehicle right is the x axis (RwMatrix.right) - - RwV3dSub(&dist, RwMatrixGetPos(atomicMat), ms_pCameraPosn); - // forward/backward facing - if(flags & (ATOMIC_FLAG_FRONT | ATOMIC_FLAG_REAR)) - dot = RwV3dDotProduct(&dist, RwMatrixGetUp(clumpMat)); - // left/right facing - else if(flags & (ATOMIC_FLAG_LEFT | ATOMIC_FLAG_RIGHT)) - dot = RwV3dDotProduct(&dist, RwMatrixGetRight(clumpMat)); - else - dot = 0.0f; - if(flags & (ATOMIC_FLAG_LEFT | ATOMIC_FLAG_REAR)) - dot = -dot; - - if(flags & (ATOMIC_FLAG_REARDOOR | ATOMIC_FLAG_FRONTDOOR)){ - if(flags & ATOMIC_FLAG_REARDOOR) - dotdoor = -RwV3dDotProduct(&dist, RwMatrixGetUp(clumpMat)); - else if(flags & ATOMIC_FLAG_FRONTDOOR) - dotdoor = RwV3dDotProduct(&dist, RwMatrixGetUp(clumpMat)); - else - dotdoor = 0.0f; - - if(dot < 0.0f && dotdoor < 0.0f) - dot += dotdoor; - if(dot > 0.0f && dotdoor > 0.0f) - dot += dotdoor; - } - - return dot; -} - -/* These are all unused */ - -bool -CVisibilityPlugins::DefaultVisibilityCB(RpClump *clump) -{ - return true; -} - -bool -CVisibilityPlugins::FrustumSphereCB(RpClump *clump) -{ - RwSphere sphere; - RwFrame *frame = RpClumpGetFrame(clump); - - CClumpModelInfo *modelInfo = (CClumpModelInfo*)GetFrameHierarchyId(frame); - sphere.radius = modelInfo->GetColModel()->boundingSphere.radius; - sphere.center.x = modelInfo->GetColModel()->boundingSphere.center.x; - sphere.center.y = modelInfo->GetColModel()->boundingSphere.center.y; - sphere.center.z = modelInfo->GetColModel()->boundingSphere.center.z; - RwV3dTransformPoints(&sphere.center, &sphere.center, 1, RwFrameGetLTM(frame)); - return RwCameraFrustumTestSphere(ms_pCamera, &sphere) != rwSPHEREOUTSIDE; -} - -bool -CVisibilityPlugins::VehicleVisibilityCB(RpClump *clump) -{ - if (GetDistanceSquaredFromCamera(RpClumpGetFrame(clump)) <= ms_vehicleLod1Dist) - return FrustumSphereCB(clump); - return false; -} - -bool -CVisibilityPlugins::VehicleVisibilityCB_BigVehicle(RpClump *clump) -{ - return FrustumSphereCB(clump); -} - - - - -// -// RW Plugins -// - -enum -{ - ID_VISIBILITYATOMIC = MAKECHUNKID(rwVENDORID_ROCKSTAR, 0x00), - ID_VISIBILITYCLUMP = MAKECHUNKID(rwVENDORID_ROCKSTAR, 0x01), - ID_VISIBILITYFRAME = MAKECHUNKID(rwVENDORID_ROCKSTAR, 0x02), -}; - -bool -CVisibilityPlugins::PluginAttach(void) -{ - ms_atomicPluginOffset = RpAtomicRegisterPlugin(sizeof(AtomicExt), - ID_VISIBILITYATOMIC, - AtomicConstructor, AtomicDestructor, AtomicCopyConstructor); - - ms_framePluginOffset = RwFrameRegisterPlugin(sizeof(FrameExt), - ID_VISIBILITYFRAME, - FrameConstructor, FrameDestructor, FrameCopyConstructor); - - ms_clumpPluginOffset = RpClumpRegisterPlugin(sizeof(ClumpExt), - ID_VISIBILITYCLUMP, - ClumpConstructor, ClumpDestructor, ClumpCopyConstructor); - return ms_atomicPluginOffset != -1 && ms_clumpPluginOffset != -1; -} - -#define ATOMICEXT(o) (RWPLUGINOFFSET(AtomicExt, o, ms_atomicPluginOffset)) -#define FRAMEEXT(o) (RWPLUGINOFFSET(FrameExt, o, ms_framePluginOffset)) -#define CLUMPEXT(o) (RWPLUGINOFFSET(ClumpExt, o, ms_clumpPluginOffset)) - -// -// Atomic -// - -void* -CVisibilityPlugins::AtomicConstructor(void *object, int32, int32) -{ - ATOMICEXT(object)->modelInfo = nil; - return object; -} - -void* -CVisibilityPlugins::AtomicDestructor(void *object, int32, int32) -{ - return object; -} - -void* -CVisibilityPlugins::AtomicCopyConstructor(void *dst, const void *src, int32, int32) -{ - *ATOMICEXT(dst) = *ATOMICEXT(src); - return dst; -} - -void -CVisibilityPlugins::SetAtomicModelInfo(RpAtomic *atomic, - CSimpleModelInfo *modelInfo) -{ - AtomicExt *ext = ATOMICEXT(atomic); - ext->modelInfo = modelInfo; - switch(modelInfo->m_type) - case MITYPE_SIMPLE: - case MITYPE_TIME: - if(modelInfo->m_normalCull) - SetAtomicRenderCallback(atomic, RenderObjNormalAtomic); -} - -CSimpleModelInfo* -CVisibilityPlugins::GetAtomicModelInfo(RpAtomic *atomic) -{ - return ATOMICEXT(atomic)->modelInfo; -} - -void -CVisibilityPlugins::SetAtomicFlag(RpAtomic *atomic, int f) -{ - ATOMICEXT(atomic)->flags |= f; -} - -void -CVisibilityPlugins::ClearAtomicFlag(RpAtomic *atomic, int f) -{ - ATOMICEXT(atomic)->flags &= ~f; -} - -int -CVisibilityPlugins::GetAtomicId(RpAtomic *atomic) -{ - return ATOMICEXT(atomic)->flags; -} - -// This is rather useless, but whatever -void -CVisibilityPlugins::SetAtomicRenderCallback(RpAtomic *atomic, RpAtomicCallBackRender cb) -{ - if(cb == nil) - cb = AtomicDefaultRenderCallBack; // not necessary - RpAtomicSetRenderCallBack(atomic, cb); -} - -// -// Frame -// - -void* -CVisibilityPlugins::FrameConstructor(void *object, int32, int32) -{ - FRAMEEXT(object)->id = 0; - return object; -} - -void* -CVisibilityPlugins::FrameDestructor(void *object, int32, int32) -{ - return object; -} - -void* -CVisibilityPlugins::FrameCopyConstructor(void *dst, const void *src, int32, int32) -{ - *FRAMEEXT(dst) = *FRAMEEXT(src); - return dst; -} - -void -CVisibilityPlugins::SetFrameHierarchyId(RwFrame *frame, int32 id) -{ - FRAMEEXT(frame)->id = id; -} - -int32 -CVisibilityPlugins::GetFrameHierarchyId(RwFrame *frame) -{ - return FRAMEEXT(frame)->id; -} - - -// -// Clump -// - -void* -CVisibilityPlugins::ClumpConstructor(void *object, int32, int32) -{ - ClumpExt *ext = CLUMPEXT(object); - ext->visibilityCB = DefaultVisibilityCB; - ext->alpha = 0xFF; - return object; -} - -void* -CVisibilityPlugins::ClumpDestructor(void *object, int32, int32) -{ - return object; -} - -void* -CVisibilityPlugins::ClumpCopyConstructor(void *dst, const void *src, int32, int32) -{ - CLUMPEXT(dst)->visibilityCB = CLUMPEXT(src)->visibilityCB; - return dst; -} - -void -CVisibilityPlugins::SetClumpModelInfo(RpClump *clump, CClumpModelInfo *modelInfo) -{ - CVehicleModelInfo *vmi; - SetFrameHierarchyId(RpClumpGetFrame(clump), (int32)modelInfo); - - // Unused - switch(modelInfo->m_type){ - // ignore MLO - case MITYPE_VEHICLE: - vmi = (CVehicleModelInfo*)modelInfo; - if(vmi->m_vehicleType == VEHICLE_TYPE_TRAIN || - vmi->m_vehicleType == VEHICLE_TYPE_HELI || - vmi->m_vehicleType == VEHICLE_TYPE_PLANE) - CLUMPEXT(clump)->visibilityCB = VehicleVisibilityCB_BigVehicle; - else - CLUMPEXT(clump)->visibilityCB = VehicleVisibilityCB; - break; - } -} - -void -CVisibilityPlugins::SetClumpAlpha(RpClump *clump, int alpha) -{ - CLUMPEXT(clump)->alpha = alpha; -} - -int -CVisibilityPlugins::GetClumpAlpha(RpClump *clump) -{ - return CLUMPEXT(clump)->alpha; -} - - -STARTPATCHES - InjectHook(0x527E50, CVisibilityPlugins::Initialise, PATCH_JUMP); - InjectHook(0x527EA0, CVisibilityPlugins::Shutdown, PATCH_JUMP); - InjectHook(0x528F90, CVisibilityPlugins::InitAlphaEntityList, PATCH_JUMP); - InjectHook(0x528FF0, CVisibilityPlugins::InsertEntityIntoSortedList, PATCH_JUMP); - InjectHook(0x528F80, CVisibilityPlugins::InitAlphaAtomicList, PATCH_JUMP); - InjectHook(0x528FA0, CVisibilityPlugins::InsertAtomicIntoSortedList, PATCH_JUMP); - InjectHook(0x528C50, CVisibilityPlugins::SetRenderWareCamera, PATCH_JUMP); - - InjectHook(0x527F60, SetAlphaCB, PATCH_JUMP); - InjectHook(0x529040, CVisibilityPlugins::RenderAlphaAtomics, PATCH_JUMP); - InjectHook(0x529070, CVisibilityPlugins::RenderFadingEntities, PATCH_JUMP); - - InjectHook(0x527F70, CVisibilityPlugins::RenderWheelAtomicCB, PATCH_JUMP); - InjectHook(0x528000, CVisibilityPlugins::RenderObjNormalAtomic, PATCH_JUMP); - InjectHook(0x5280B0, CVisibilityPlugins::RenderAlphaAtomic, PATCH_JUMP); - InjectHook(0x528100, CVisibilityPlugins::RenderFadingAtomic, PATCH_JUMP); - - InjectHook(0x5283E0, CVisibilityPlugins::RenderVehicleHiDetailCB, PATCH_JUMP); - InjectHook(0x5284B0, CVisibilityPlugins::RenderVehicleHiDetailAlphaCB, PATCH_JUMP); - InjectHook(0x5288A0, CVisibilityPlugins::RenderVehicleHiDetailCB_BigVehicle, PATCH_JUMP); - InjectHook(0x528A10, CVisibilityPlugins::RenderVehicleHiDetailAlphaCB_BigVehicle, PATCH_JUMP); - InjectHook(0x528AD0, CVisibilityPlugins::RenderVehicleHiDetailCB_Boat, PATCH_JUMP); - InjectHook(0x5287F0, CVisibilityPlugins::RenderVehicleLowDetailCB_BigVehicle, PATCH_JUMP); - InjectHook(0x528940, CVisibilityPlugins::RenderVehicleLowDetailAlphaCB_BigVehicle, PATCH_JUMP); - InjectHook(0x528240, CVisibilityPlugins::RenderVehicleReallyLowDetailCB, PATCH_JUMP); - InjectHook(0x5287B0, CVisibilityPlugins::RenderVehicleReallyLowDetailCB_BigVehicle, PATCH_JUMP); - InjectHook(0x5285D0, CVisibilityPlugins::RenderTrainHiDetailCB, PATCH_JUMP); - InjectHook(0x5286A0, CVisibilityPlugins::RenderTrainHiDetailAlphaCB, PATCH_JUMP); - - InjectHook(0x528BC0, CVisibilityPlugins::RenderPedHiDetailCB, PATCH_JUMP); - InjectHook(0x528B60, CVisibilityPlugins::RenderPedLowDetailCB, PATCH_JUMP); - - - InjectHook(0x527DC0, CVisibilityPlugins::PluginAttach, PATCH_JUMP); - - InjectHook(0x527EC0, CVisibilityPlugins::SetAtomicModelInfo, PATCH_JUMP); - InjectHook(0x527F00, CVisibilityPlugins::GetAtomicModelInfo, PATCH_JUMP); - InjectHook(0x527F10, CVisibilityPlugins::SetAtomicFlag, PATCH_JUMP); - InjectHook(0x527F30, CVisibilityPlugins::ClearAtomicFlag, PATCH_JUMP); - InjectHook(0x527F50, CVisibilityPlugins::GetAtomicId, PATCH_JUMP); - InjectHook(0x528C20, CVisibilityPlugins::SetAtomicRenderCallback, PATCH_JUMP); - - InjectHook(0x528D60, CVisibilityPlugins::SetFrameHierarchyId, PATCH_JUMP); - InjectHook(0x528D80, CVisibilityPlugins::GetFrameHierarchyId, PATCH_JUMP); - - InjectHook(0x528ED0, CVisibilityPlugins::SetClumpModelInfo, PATCH_JUMP); - InjectHook(0x528F50, CVisibilityPlugins::SetClumpAlpha, PATCH_JUMP); - InjectHook(0x528F70, CVisibilityPlugins::GetClumpAlpha, PATCH_JUMP); - - - InjectHook(0x529120, CVisibilityPlugins::GetDistanceSquaredFromCamera, PATCH_JUMP); - InjectHook(0x5282A0, CVisibilityPlugins::GetDotProductWithCameraVector, PATCH_JUMP); -ENDPATCHES diff --git a/src/render/VisibilityPlugins.h b/src/render/VisibilityPlugins.h deleted file mode 100644 index 65d2675a..00000000 --- a/src/render/VisibilityPlugins.h +++ /dev/null @@ -1,133 +0,0 @@ -#pragma once - -#include "templates.h" - -class CEntity; -class CSimpleModelInfo; -class CClumpModelInfo; - -typedef bool (*ClumpVisibilityCB)(RpClump*); - -class CVisibilityPlugins -{ -public: - struct AlphaObjectInfo - { - union { - CEntity *entity; - RpAtomic *atomic; - }; - float sort; - }; - - static CLinkList &m_alphaList; - static CLinkList &m_alphaEntityList; - static RwCamera *&ms_pCamera; - static RwV3d *&ms_pCameraPosn; - static float &ms_cullCompsDist; - static float &ms_vehicleLod0Dist; - static float &ms_vehicleLod1Dist; - static float &ms_vehicleFadeDist; - static float &ms_bigVehicleLod0Dist; - static float &ms_bigVehicleLod1Dist; - static float &ms_pedLod0Dist; - static float &ms_pedLod1Dist; - static float &ms_pedFadeDist; - - static void Initialise(void); - static void Shutdown(void); - static void InitAlphaEntityList(void); - static bool InsertEntityIntoSortedList(CEntity *e, float dist); - static void InitAlphaAtomicList(void); - static bool InsertAtomicIntoSortedList(RpAtomic *a, float dist); - - static void SetRenderWareCamera(RwCamera *camera); - - static RpAtomic *RenderWheelAtomicCB(RpAtomic *atomic); - static RpAtomic *RenderObjNormalAtomic(RpAtomic *atomic); - static RpAtomic *RenderAlphaAtomic(RpAtomic *atomic, int alpha); - static RpAtomic *RenderFadingAtomic(RpAtomic *atm, float dist); - - static RpAtomic *RenderVehicleHiDetailCB(RpAtomic *atomic); - static RpAtomic *RenderVehicleHiDetailAlphaCB(RpAtomic *atomic); - static RpAtomic *RenderVehicleHiDetailCB_BigVehicle(RpAtomic *atomic); - static RpAtomic *RenderVehicleHiDetailAlphaCB_BigVehicle(RpAtomic *atomic); - static RpAtomic *RenderVehicleHiDetailCB_Boat(RpAtomic *atomic); - static RpAtomic *RenderVehicleLowDetailCB_BigVehicle(RpAtomic *atomic); - static RpAtomic *RenderVehicleLowDetailAlphaCB_BigVehicle(RpAtomic *atomic); - static RpAtomic *RenderVehicleReallyLowDetailCB(RpAtomic *atomic); - static RpAtomic *RenderVehicleReallyLowDetailCB_BigVehicle(RpAtomic *atomic); - static RpAtomic *RenderTrainHiDetailCB(RpAtomic *atomic); - static RpAtomic *RenderTrainHiDetailAlphaCB(RpAtomic *atomic); - - static RpAtomic *RenderPlayerCB(RpAtomic *atomic); - static RpAtomic *RenderPedLowDetailCB(RpAtomic *atomic); - static RpAtomic *RenderPedHiDetailCB(RpAtomic *atomic); - - static void RenderAlphaAtomics(void); - static void RenderFadingEntities(void); - - // All actually unused - static bool DefaultVisibilityCB(RpClump *clump); - static bool FrustumSphereCB(RpClump *clump); -// static bool MloVisibilityCB(RpClump *clump); - static bool VehicleVisibilityCB(RpClump *clump); - static bool VehicleVisibilityCB_BigVehicle(RpClump *clump); - - static float GetDistanceSquaredFromCamera(RwFrame *frame); - static float GetDotProductWithCameraVector(RwMatrix *atomicMat, RwMatrix *clumpMat, uint32 flags); - - // - // RW Plugins - // - - union AtomicExt - { - CSimpleModelInfo *modelInfo; // used by SimpleModelInfo - int flags; // used by ClumpModelInfo - }; - static void SetAtomicModelInfo(RpAtomic*, CSimpleModelInfo*); - static CSimpleModelInfo *GetAtomicModelInfo(RpAtomic *atomic); - static void SetAtomicFlag(RpAtomic*, int); - static void ClearAtomicFlag(RpAtomic*, int); - static int GetAtomicId(RpAtomic *atomic); - static void SetAtomicRenderCallback(RpAtomic*, RpAtomicCallBackRender); - - static void *AtomicConstructor(void *object, int32 offset, int32 len); - static void *AtomicDestructor(void *object, int32 offset, int32 len); - static void *AtomicCopyConstructor(void *dst, const void *src, - int32 offset, int32 len); - static int32 &ms_atomicPluginOffset; - - struct FrameExt - { - // BUG: this is abused to hold a pointer by SetClumpModelInfo - int32 id; - }; - static void SetFrameHierarchyId(RwFrame *frame, int32 id); - static int32 GetFrameHierarchyId(RwFrame *frame); - - static void *FrameConstructor(void *object, int32 offset, int32 len); - static void *FrameDestructor(void *object, int32 offset, int32 len); - static void *FrameCopyConstructor(void *dst, const void *src, - int32 offset, int32 len); - static int32 &ms_framePluginOffset; - - // Not actually used - struct ClumpExt - { - ClumpVisibilityCB visibilityCB; - int alpha; - }; - static void SetClumpModelInfo(RpClump*, CClumpModelInfo*); - static void SetClumpAlpha(RpClump*, int); - static int GetClumpAlpha(RpClump*); - - static void *ClumpConstructor(void *object, int32 offset, int32 len); - static void *ClumpDestructor(void *object, int32 offset, int32 len); - static void *ClumpCopyConstructor(void *dst, const void *src, - int32 offset, int32 len); - static int32 &ms_clumpPluginOffset; - - static bool PluginAttach(void); -}; diff --git a/src/rw/ClumpRead.cpp b/src/rw/ClumpRead.cpp new file mode 100644 index 00000000..c9f027e7 --- /dev/null +++ b/src/rw/ClumpRead.cpp @@ -0,0 +1,230 @@ +#include "common.h" +#include "patcher.h" + +struct rpGeometryList +{ + RpGeometry **geometries; + int32 numGeoms; +}; + +struct rpAtomicBinary +{ + RwInt32 frameIndex; + RwInt32 geomIndex; + RwInt32 flags; + RwInt32 unused; +}; + +static int32 numberGeometrys; +static int32 streamPosition; +static rpGeometryList gGeomList; +static rwFrameList gFrameList; +static RpClumpChunkInfo gClumpInfo; + +rpGeometryList* +GeometryListStreamRead1(RwStream *stream, rpGeometryList *geomlist) +{ + int i; + RwUInt32 size, version; + RwInt32 numGeoms; + + numberGeometrys = 0; + if(!RwStreamFindChunk(stream, rwID_STRUCT, &size, &version)) + return nil; + assert(size == 4); + if(RwStreamRead(stream, &numGeoms, 4) != 4) + return nil; + + numberGeometrys = numGeoms/2; + geomlist->numGeoms = numGeoms; + if(geomlist->numGeoms > 0){ + geomlist->geometries = (RpGeometry**)RwMalloc(geomlist->numGeoms * sizeof(RpGeometry*)); + if(geomlist->geometries == nil) + return nil; + memset(geomlist->geometries, 0, geomlist->numGeoms * sizeof(RpGeometry*)); + }else + geomlist->geometries = nil; + + for(i = 0; i < numberGeometrys; i++){ + if(!RwStreamFindChunk(stream, rwID_GEOMETRY, nil, &version)) + return nil; + geomlist->geometries[i] = RpGeometryStreamRead(stream); + if(geomlist->geometries[i] == nil) + return nil; + } + + return geomlist; +} + +rpGeometryList* +GeometryListStreamRead2(RwStream *stream, rpGeometryList *geomlist) +{ + int i; + RwUInt32 version; + + for(i = numberGeometrys; i < geomlist->numGeoms; i++){ + if(!RwStreamFindChunk(stream, rwID_GEOMETRY, nil, &version)) + return nil; + geomlist->geometries[i] = RpGeometryStreamRead(stream); + if(geomlist->geometries[i] == nil) + return nil; + } + + return geomlist; +} + +void +GeometryListDeinitialize(rpGeometryList *geomlist) +{ + int i; + + for(i = 0; i < geomlist->numGeoms; i++) + if(geomlist->geometries[i]) + RpGeometryDestroy(geomlist->geometries[i]); + + if(geomlist->numGeoms){ + RwFree(geomlist->geometries); + geomlist->numGeoms = 0; + } +} + +RpAtomic* +ClumpAtomicStreamRead(RwStream *stream, rwFrameList *frmList, rpGeometryList *geomList) +{ + RwUInt32 size, version; + rpAtomicBinary a; + RpAtomic *atomic; + + numberGeometrys = 0; + if(!RwStreamFindChunk(stream, rwID_STRUCT, &size, &version)) + return nil; + assert(size <= sizeof(rpAtomicBinary)); + if(RwStreamRead(stream, &a, size) != size) + return nil; + + atomic = RpAtomicCreate(); + if(atomic == nil) + return nil; + + RpAtomicSetFlags(atomic, a.flags); + + if(frmList->numFrames){ + assert(a.frameIndex < frmList->numFrames); + RpAtomicSetFrame(atomic, frmList->frames[a.frameIndex]); + } + + if(geomList->numGeoms){ + assert(a.geomIndex < geomList->numGeoms); + RpAtomicSetGeometry(atomic, geomList->geometries[a.geomIndex], 0); + }else{ + RpGeometry *geom; + if(!RwStreamFindChunk(stream, rwID_GEOMETRY, nil, &version)){ + RpAtomicDestroy(atomic); + return nil; + } + geom = RpGeometryStreamRead(stream); + if(geom == nil){ + RpAtomicDestroy(atomic); + return nil; + } + RpAtomicSetGeometry(atomic, geom, 0); + RpGeometryDestroy(geom); + } + + return atomic; +} + +bool +RpClumpGtaStreamRead1(RwStream *stream) +{ + RwUInt32 size, version; + + if(!RwStreamFindChunk(stream, rwID_STRUCT, &size, &version)) + return false; + if(version >= 0x33000){ + assert(size == 12); + if(RwStreamRead(stream, &gClumpInfo, 12) != 12) + return false; + }else{ + assert(size == 4); + if(RwStreamRead(stream, &gClumpInfo, 4) != 4) + return false; + } + + if(!RwStreamFindChunk(stream, rwID_FRAMELIST, nil, &version)) + return false; + if(_rwFrameListStreamRead(stream, &gFrameList) == nil) + return false; + + if(!RwStreamFindChunk(stream, rwID_GEOMETRYLIST, nil, &version)){ + rwFrameListDeinitialize(&gFrameList); + return false; + } + if(GeometryListStreamRead1(stream, &gGeomList) == nil){ + rwFrameListDeinitialize(&gFrameList); + return false; + } + streamPosition = stream->Type.memory.position; + return true; +} + +RpClump* +RpClumpGtaStreamRead2(RwStream *stream) +{ + int i; + RwUInt32 version; + RpAtomic *atomic; + RpClump *clump; + + clump = RpClumpCreate(); + if(clump == nil) + return nil; + + RwStreamSkip(stream, streamPosition - stream->Type.memory.position); + + if(GeometryListStreamRead2(stream, &gGeomList) == nil){ + GeometryListDeinitialize(&gGeomList); + rwFrameListDeinitialize(&gFrameList); + RpClumpDestroy(clump); + return nil; + } + + RpClumpSetFrame(clump, gFrameList.frames[0]); + + for(i = 0; i < gClumpInfo.numAtomics; i++){ + if(!RwStreamFindChunk(stream, rwID_ATOMIC, nil, &version)){ + GeometryListDeinitialize(&gGeomList); + rwFrameListDeinitialize(&gFrameList); + RpClumpDestroy(clump); + return nil; + } + + atomic = ClumpAtomicStreamRead(stream, &gFrameList, &gGeomList); + if(atomic == nil){ + GeometryListDeinitialize(&gGeomList); + rwFrameListDeinitialize(&gFrameList); + RpClumpDestroy(clump); + return nil; + } + + RpClumpAddAtomic(clump, atomic); + } + + GeometryListDeinitialize(&gGeomList); + rwFrameListDeinitialize(&gFrameList); + return clump; +} + +void +RpClumpGtaCancelStream(void) +{ + GeometryListDeinitialize(&gGeomList); + rwFrameListDeinitialize(&gFrameList); + gFrameList.numFrames = 0; +} + +STARTPATCHES + InjectHook(0x526060, RpClumpGtaStreamRead1, PATCH_JUMP); + InjectHook(0x526180, RpClumpGtaStreamRead2, PATCH_JUMP); + InjectHook(0x5262D0, RpClumpGtaCancelStream, PATCH_JUMP); +ENDPATCHES diff --git a/src/rw/Lights.cpp b/src/rw/Lights.cpp new file mode 100644 index 00000000..cd83a898 --- /dev/null +++ b/src/rw/Lights.cpp @@ -0,0 +1,333 @@ +#include "common.h" +#include +#include +#include "patcher.h" +#include "Lights.h" +#include "Timecycle.h" +#include "Coronas.h" +#include "Weather.h" +#include "ZoneCull.h" +#include "Frontend.h" + +RpLight *&pAmbient = *(RpLight**)0x885B6C; +RpLight *&pDirect = *(RpLight**)0x880F7C; +RpLight **pExtraDirectionals = (RpLight**)0x60009C; +int *LightStrengths = (int*)0x87BEF0; +int &NumExtraDirLightsInWorld = *(int*)0x64C608; + +RwRGBAReal &AmbientLightColourForFrame = *(RwRGBAReal*)0x6F46F8; +RwRGBAReal &AmbientLightColourForFrame_PedsCarsAndObjects = *(RwRGBAReal*)0x6F1D10; +RwRGBAReal &DirectionalLightColourForFrame = *(RwRGBAReal*)0x87C6B8; + +RwRGBAReal &AmbientLightColour = *(RwRGBAReal*)0x86B0F8; +RwRGBAReal &DirectionalLightColour = *(RwRGBAReal*)0x72E308; + +void +SetLightsWithTimeOfDayColour(RpWorld *) +{ + CVector vec1, vec2, vecsun; + RwMatrix mat; + + if(pAmbient){ + AmbientLightColourForFrame.red = CTimeCycle::GetAmbientRed() * CCoronas::LightsMult; + AmbientLightColourForFrame.green = CTimeCycle::GetAmbientGreen() * CCoronas::LightsMult; + AmbientLightColourForFrame.blue = CTimeCycle::GetAmbientBlue() * CCoronas::LightsMult; + if(CWeather::LightningFlash && !CCullZones::CamNoRain()){ + AmbientLightColourForFrame.red = 1.0f; + AmbientLightColourForFrame.green = 1.0f; + AmbientLightColourForFrame.blue = 1.0f; + } + AmbientLightColourForFrame_PedsCarsAndObjects.red = min(1.0f, AmbientLightColourForFrame.red*1.3f); + AmbientLightColourForFrame_PedsCarsAndObjects.green = min(1.0f, AmbientLightColourForFrame.green*1.3f); + AmbientLightColourForFrame_PedsCarsAndObjects.blue = min(1.0f, AmbientLightColourForFrame.blue*1.3f); + RpLightSetColor(pAmbient, &AmbientLightColourForFrame); + } + + if(pDirect){ + DirectionalLightColourForFrame.red = CTimeCycle::GetDirectionalRed() * CCoronas::LightsMult; + DirectionalLightColourForFrame.green = CTimeCycle::GetDirectionalGreen() * CCoronas::LightsMult; + DirectionalLightColourForFrame.blue = CTimeCycle::GetDirectionalBlue() * CCoronas::LightsMult; + RpLightSetColor(pDirect, &DirectionalLightColourForFrame); + + vecsun = CTimeCycle::m_VectorToSun[CTimeCycle::m_CurrentStoredValue]; + vec1 = CVector(0.0f, 0.0f, 1.0f); + vec2 = CrossProduct(vec1, vecsun); + vec2.Normalise(); + vec1 = CrossProduct(vec2, vecsun); + mat.at.x = -vecsun.x; + mat.at.y = -vecsun.y; + mat.at.z = -vecsun.z; + mat.right.x = vec1.x; + mat.right.y = vec1.y; + mat.right.z = vec1.z; + mat.up.x = vec2.x; + mat.up.y = vec2.y; + mat.up.z = vec2.z; + RwFrameTransform(RpLightGetFrame(pDirect), &mat, rwCOMBINEREPLACE); + } + + if(CMenuManager::m_PrefsBrightness > 256){ + float f1 = 2.0f * (CMenuManager::m_PrefsBrightness/256.0f - 1.0f) * 0.6f + 1.0f; + float f2 = 3.0f * (CMenuManager::m_PrefsBrightness/256.0f - 1.0f) * 0.6f + 1.0f; + + AmbientLightColourForFrame.red = min(1.0f, AmbientLightColourForFrame.red * f2); + AmbientLightColourForFrame.green = min(1.0f, AmbientLightColourForFrame.green * f2); + AmbientLightColourForFrame.blue = min(1.0f, AmbientLightColourForFrame.blue * f2); + AmbientLightColourForFrame_PedsCarsAndObjects.red = min(1.0f, AmbientLightColourForFrame_PedsCarsAndObjects.red * f1); + AmbientLightColourForFrame_PedsCarsAndObjects.green = min(1.0f, AmbientLightColourForFrame_PedsCarsAndObjects.green * f1); + AmbientLightColourForFrame_PedsCarsAndObjects.blue = min(1.0f, AmbientLightColourForFrame_PedsCarsAndObjects.blue * f1); +#ifdef FIX_BUGS + DirectionalLightColourForFrame.red = min(1.0f, DirectionalLightColourForFrame.red * f1); + DirectionalLightColourForFrame.green = min(1.0f, DirectionalLightColourForFrame.green * f1); + DirectionalLightColourForFrame.blue = min(1.0f, DirectionalLightColourForFrame.blue * f1); +#else + DirectionalLightColourForFrame.red = min(1.0f, AmbientLightColourForFrame.red * f1); + DirectionalLightColourForFrame.green = min(1.0f, AmbientLightColourForFrame.green * f1); + DirectionalLightColourForFrame.blue = min(1.0f, AmbientLightColourForFrame.blue * f1); +#endif + } +} + +RpWorld* +LightsCreate(RpWorld *world) +{ + int i; + RwRGBAReal color; + RwFrame *frame; + + if(world == nil) + return nil; + + pAmbient = RpLightCreate(rpLIGHTAMBIENT); + RpLightSetFlags(pAmbient, rpLIGHTLIGHTATOMICS); + color.red = 0.25f; + color.green = 0.25f; + color.blue = 0.2f; + RpLightSetColor(pAmbient, &color); + + pDirect = RpLightCreate(rpLIGHTDIRECTIONAL); + RpLightSetFlags(pDirect, rpLIGHTLIGHTATOMICS); + color.red = 1.0f; + color.green = 0.84f; + color.blue = 0.45f; + RpLightSetColor(pDirect, &color); + RpLightSetRadius(pDirect, 2.0f); + frame = RwFrameCreate(); + RpLightSetFrame(pDirect, frame); + RwV3d axis = { 1.0f, 1.0f, 0.0f }; + RwFrameRotate(frame, &axis, 160.0f, rwCOMBINEPRECONCAT); + + RpWorldAddLight(world, pAmbient); + RpWorldAddLight(world, pDirect); + + for(i = 0; i < NUMEXTRADIRECTIONALS; i++){ + pExtraDirectionals[i] = RpLightCreate(rpLIGHTDIRECTIONAL); + RpLightSetFlags(pExtraDirectionals[i], 0); + color.red = 1.0f; + color.green = 0.5f; + color.blue = 0.0f; + RpLightSetColor(pExtraDirectionals[i], &color); + RpLightSetRadius(pExtraDirectionals[i], 2.0f); + frame = RwFrameCreate(); + RpLightSetFrame(pExtraDirectionals[i], frame); + RpWorldAddLight(world, pExtraDirectionals[i]); + } + + return world; +} + +void +LightsDestroy(RpWorld *world) +{ + int i; + + if(world == nil) + return; + + if(pAmbient){ + RpWorldRemoveLight(world, pAmbient); + RpLightDestroy(pAmbient); + pAmbient = nil; + } + + if(pDirect){ + RpWorldRemoveLight(world, pDirect); + RwFrameDestroy(RpLightGetFrame(pDirect)); + RpLightDestroy(pDirect); + pDirect = nil; + } + + for(i = 0; i < NUMEXTRADIRECTIONALS; i++) + if(pExtraDirectionals[i]){ + RpWorldRemoveLight(world, pExtraDirectionals[i]); + RwFrameDestroy(RpLightGetFrame(pExtraDirectionals[i])); + RpLightDestroy(pExtraDirectionals[i]); + pExtraDirectionals[i] = nil; + } +} + +void +WorldReplaceNormalLightsWithScorched(RpWorld *world, float l) +{ + RwRGBAReal color; + color.red = l; + color.green = l; + color.blue = l; + RpLightSetColor(pAmbient, &color); + RpLightSetFlags(pDirect, 0); +} + +void +WorldReplaceScorchedLightsWithNormal(RpWorld *world) +{ + RpLightSetColor(pAmbient, &AmbientLightColourForFrame); + RpLightSetFlags(pDirect, rpLIGHTLIGHTATOMICS); +} + +void +AddAnExtraDirectionalLight(RpWorld *world, float dirx, float diry, float dirz, float red, float green, float blue) +{ + float strength; + int weakest; + int i, n; + RwRGBAReal color; + RwV3d *dir; + + strength = max(max(red, green), blue); + n = -1; + if(NumExtraDirLightsInWorld < NUMEXTRADIRECTIONALS) + n = NumExtraDirLightsInWorld; + else{ + weakest = strength; + for(i = 0; i < NUMEXTRADIRECTIONALS; i++) + if(LightStrengths[i] < weakest){ + weakest = LightStrengths[i]; + n = i; + } + } + + if(n < 0) + return; + + color.red = red; + color.green = green; + color.blue = blue; + RpLightSetColor(pExtraDirectionals[n], &color); + dir = RwMatrixGetAt(RwFrameGetMatrix(RpLightGetFrame(pExtraDirectionals[n]))); + dir->x = -dirx; + dir->y = -diry; + dir->z = -dirz; + RwMatrixUpdate(RwFrameGetMatrix(RpLightGetFrame(pExtraDirectionals[n]))); + RwFrameUpdateObjects(RpLightGetFrame(pExtraDirectionals[n])); + RpLightSetFlags(pExtraDirectionals[n], rpLIGHTLIGHTATOMICS); + LightStrengths[n] = strength; + NumExtraDirLightsInWorld = min(NumExtraDirLightsInWorld+1, NUMEXTRADIRECTIONALS); +} + +void +RemoveExtraDirectionalLights(RpWorld *world) +{ + int i; + for(i = 0; i < NumExtraDirLightsInWorld; i++) + RpLightSetFlags(pExtraDirectionals[i], 0); + NumExtraDirLightsInWorld = 0; +} + +void +SetAmbientAndDirectionalColours(float f) +{ + AmbientLightColour.red = AmbientLightColourForFrame.red * f; + AmbientLightColour.green = AmbientLightColourForFrame.green * f; + AmbientLightColour.blue = AmbientLightColourForFrame.blue * f; + + DirectionalLightColour.red = DirectionalLightColourForFrame.red * f; + DirectionalLightColour.green = DirectionalLightColourForFrame.green * f; + DirectionalLightColour.blue = DirectionalLightColourForFrame.blue * f; + + RpLightSetColor(pAmbient, &AmbientLightColour); + RpLightSetColor(pDirect, &DirectionalLightColour); +} + +void +SetBrightMarkerColours(float f) +{ + AmbientLightColour.red = 0.6f; + AmbientLightColour.green = 0.6f; + AmbientLightColour.blue = 0.6f; + + DirectionalLightColour.red = (1.0f - DirectionalLightColourForFrame.red) * 0.4f + DirectionalLightColourForFrame.red; + DirectionalLightColour.green = (1.0f - DirectionalLightColourForFrame.green) * 0.4f + DirectionalLightColourForFrame.green; + DirectionalLightColour.blue = (1.0f - DirectionalLightColourForFrame.blue) * 0.4f + DirectionalLightColourForFrame.blue; + + RpLightSetColor(pAmbient, &AmbientLightColour); + RpLightSetColor(pDirect, &DirectionalLightColour); +} + +void +ReSetAmbientAndDirectionalColours(void) +{ + RpLightSetColor(pAmbient, &AmbientLightColourForFrame); + RpLightSetColor(pDirect, &DirectionalLightColourForFrame); +} + +void +DeActivateDirectional(void) +{ + RpLightSetFlags(pDirect, 0); +} + +void +ActivateDirectional(void) +{ + RpLightSetFlags(pDirect, rpLIGHTLIGHTATOMICS); +} + +void +SetAmbientColours(void) +{ + RpLightSetColor(pAmbient, &AmbientLightColourForFrame); +} + +void +SetAmbientColoursForPedsCarsAndObjects(void) +{ + RpLightSetColor(pAmbient, &AmbientLightColourForFrame_PedsCarsAndObjects); +} + +uint8 IndicateR[] = { 0, 255, 0, 0, 255, 255, 0 }; +uint8 IndicateG[] = { 0, 0, 255, 0, 255, 0, 255 }; +uint8 IndicateB[] = { 0, 0, 0, 255, 0, 255, 255 }; + +void +SetAmbientColoursToIndicateRoadGroup(int i) +{ + AmbientLightColour.red = IndicateR[i%7]/255.0f; + AmbientLightColour.green = IndicateG[i%7]/255.0f; + AmbientLightColour.blue = IndicateB[i%7]/255.0f; + RpLightSetColor(pAmbient, &AmbientLightColour); +} + +void +SetAmbientColours(RwRGBAReal *color) +{ + RpLightSetColor(pAmbient, color); +} + + +STARTPATCHES + InjectHook(0x526510, SetLightsWithTimeOfDayColour, PATCH_JUMP); + InjectHook(0x5269A0, LightsCreate, PATCH_JUMP); + InjectHook(0x526B40, LightsDestroy, PATCH_JUMP); + InjectHook(0x526C10, WorldReplaceNormalLightsWithScorched, PATCH_JUMP); + InjectHook(0x526C50, WorldReplaceScorchedLightsWithNormal, PATCH_JUMP); + InjectHook(0x526C70, AddAnExtraDirectionalLight, PATCH_JUMP); + InjectHook(0x526DB0, RemoveExtraDirectionalLights, PATCH_JUMP); + InjectHook(0x526DE0, SetAmbientAndDirectionalColours, PATCH_JUMP); + InjectHook(0x526E60, SetBrightMarkerColours, PATCH_JUMP); + InjectHook(0x526F10, ReSetAmbientAndDirectionalColours, PATCH_JUMP); + InjectHook(0x526F40, DeActivateDirectional, PATCH_JUMP); + InjectHook(0x526F50, ActivateDirectional, PATCH_JUMP); + InjectHook(0x526F60, (void (*)(void))SetAmbientColours, PATCH_JUMP); + InjectHook(0x526F80, SetAmbientColoursForPedsCarsAndObjects, PATCH_JUMP); + InjectHook(0x526FA0, (void (*)(RwRGBAReal*))SetAmbientColours, PATCH_JUMP); +ENDPATCHES diff --git a/src/rw/Lights.h b/src/rw/Lights.h new file mode 100644 index 00000000..6fdd51de --- /dev/null +++ b/src/rw/Lights.h @@ -0,0 +1,18 @@ +#pragma once + +void SetLightsWithTimeOfDayColour(RpWorld *); +RpWorld *LightsCreate(RpWorld *world); +void LightsDestroy(RpWorld *world); +void WorldReplaceNormalLightsWithScorched(RpWorld *world, float l); +void WorldReplaceScorchedLightsWithNormal(RpWorld *world); +void AddAnExtraDirectionalLight(RpWorld *world, float dirx, float diry, float dirz, float red, float green, float blue); +void RemoveExtraDirectionalLights(RpWorld *world); +void SetAmbientAndDirectionalColours(float f); +void SetBrightMarkerColours(float f); +void ReSetAmbientAndDirectionalColours(void); +void DeActivateDirectional(void); +void ActivateDirectional(void); +void SetAmbientColours(void); +void SetAmbientColoursForPedsCarsAndObjects(void); +void SetAmbientColoursToIndicateRoadGroup(int i); +void SetAmbientColours(RwRGBAReal *color); diff --git a/src/rw/NodeName.cpp b/src/rw/NodeName.cpp new file mode 100644 index 00000000..2aea3c83 --- /dev/null +++ b/src/rw/NodeName.cpp @@ -0,0 +1,77 @@ +#include "common.h" +#include "patcher.h" +#include "NodeName.h" + +static int32 &gPluginOffset = *(int32*)0x64C610; + +enum +{ + ID_NODENAME = MAKECHUNKID(rwVENDORID_ROCKSTAR, 0xFE), +}; + +#define NODENAMEEXT(o) (RWPLUGINOFFSET(char, o, gPluginOffset)) + +void* +NodeNameConstructor(void *object, RwInt32 offsetInObject, RwInt32 sizeInObject) +{ + if(gPluginOffset > 0) + NODENAMEEXT(object)[0] = '\0'; + return object; +} + +void* +NodeNameDestructor(void *object, RwInt32 offsetInObject, RwInt32 sizeInObject) +{ + return object; +} + +void* +NodeNameCopy(void *dstObject, const void *srcObject, RwInt32 offsetInObject, RwInt32 sizeInObject) +{ + strncpy(NODENAMEEXT(dstObject), NODENAMEEXT(srcObject), 23); + return nil; +} + +RwStream* +NodeNameStreamRead(RwStream *stream, RwInt32 binaryLength, void *object, RwInt32 offsetInObject, RwInt32 sizeInObject) +{ + RwStreamRead(stream, NODENAMEEXT(object), binaryLength); + NODENAMEEXT(object)[binaryLength] = '\0'; + return stream; +} + +RwStream* +NodeNameStreamWrite(RwStream *stream, RwInt32 binaryLength, const void *object, RwInt32 offsetInObject, RwInt32 sizeInObject) +{ + RwStreamWrite(stream, NODENAMEEXT(object), binaryLength); + return stream; +} + +RwInt32 +NodeNameStreamGetSize(const void *object, RwInt32 offsetInObject, RwInt32 sizeInObject) +{ + // game checks for null pointer on node name extension but that really happen + return rwstrlen(NODENAMEEXT(object)); +} + +bool +NodeNamePluginAttach(void) +{ + gPluginOffset = RwFrameRegisterPlugin(24, ID_NODENAME, + NodeNameConstructor, + NodeNameDestructor, + NodeNameCopy); + RwFrameRegisterPluginStream(ID_NODENAME, + NodeNameStreamRead, + NodeNameStreamWrite, + NodeNameStreamGetSize); + return gPluginOffset != -1; +} + +char* +GetFrameNodeName(RwFrame *frame) +{ + if(gPluginOffset < 0) + return nil; + return NODENAMEEXT(frame); +} diff --git a/src/rw/NodeName.h b/src/rw/NodeName.h new file mode 100644 index 00000000..1a3e057b --- /dev/null +++ b/src/rw/NodeName.h @@ -0,0 +1,4 @@ +#pragma once + +bool NodeNamePluginAttach(void); +char *GetFrameNodeName(RwFrame *frame); diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp new file mode 100644 index 00000000..44866f4f --- /dev/null +++ b/src/rw/RwHelper.cpp @@ -0,0 +1,374 @@ +#define WITHD3D +#include "common.h" +#include "patcher.h" +#include "Timecycle.h" +#include "skeleton.h" + +void * +RwMallocAlign(RwUInt32 size, RwUInt32 align) +{ + void *mem = (void *)malloc(size + align); + + ASSERT(mem != nil); + + void *addr = (void *)((((RwUInt32)mem) + align) & ~(align - 1)); + + ASSERT(addr != nil); + + *(((void **)addr) - 1) = mem; + + return addr; +} + +void +RwFreeAlign(void *mem) +{ + ASSERT(mem != nil); + + void *addr = *(((void **)mem) - 1); + + ASSERT(addr != nil); + + free(addr); +} + +void +DefinedState(void) +{ + RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void*)rwTEXTUREADDRESSWRAP); + RwRenderStateSet(rwRENDERSTATETEXTUREPERSPECTIVE, (void*)TRUE); + RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE); + RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE); + RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEGOURAUD); + RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE); + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + RwRenderStateSet(rwRENDERSTATEALPHAPRIMITIVEBUFFER, (void*)FALSE); + RwRenderStateSet(rwRENDERSTATEBORDERCOLOR, (void*)RWRGBALONG(0, 0, 0, 255)); + RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE); + RwRenderStateSet(rwRENDERSTATEFOGCOLOR, + (void*)RWRGBALONG(CTimeCycle::GetFogRed(), CTimeCycle::GetFogGreen(), CTimeCycle::GetFogBlue(), 255)); + RwRenderStateSet(rwRENDERSTATEFOGTYPE, (void*)rwFOGTYPELINEAR); + RwRenderStateSet(rwRENDERSTATECULLMODE, (void*)rwCULLMODECULLNONE); + + // D3D stuff + RwD3D8SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER); + RwD3D8SetRenderState(D3DRS_ALPHAREF, 2); +} + +RwFrame* +GetFirstFrameCallback(RwFrame *child, void *data) +{ + *(RwFrame**)data = child; + return nil; +} + +RwFrame* +GetFirstChild(RwFrame *frame) +{ + RwFrame *child; + + child = nil; + RwFrameForAllChildren(frame, GetFirstFrameCallback, &child); + return child; +} + +RwObject* +GetFirstObjectCallback(RwObject *object, void *data) +{ + *(RwObject**)data = object; + return nil; +} + +RwObject* +GetFirstObject(RwFrame *frame) +{ + RwObject *obj; + + obj = nil; + RwFrameForAllObjects(frame, GetFirstObjectCallback, &obj); + return obj; +} + +RpAtomic* +GetFirstAtomicCallback(RpAtomic *atm, void *data) +{ + *(RpAtomic**)data = atm; + return nil; +} + +RpAtomic* +GetFirstAtomic(RpClump *clump) +{ + RpAtomic *atm; + + atm = nil; + RpClumpForAllAtomics(clump, GetFirstAtomicCallback, &atm); + return atm; +} + +RwTexture* +GetFirstTextureCallback(RwTexture *tex, void *data) +{ + *(RwTexture**)data = tex; + return nil; +} + +RwTexture* +GetFirstTexture(RwTexDictionary *txd) +{ + RwTexture *tex; + + tex = nil; + RwTexDictionaryForAllTextures(txd, GetFirstTextureCallback, &tex); + return tex; +} + +void +CameraSize(RwCamera * camera, RwRect * rect, + RwReal viewWindow, RwReal aspectRatio) +{ + if (camera) + { + RwVideoMode videoMode; + RwRect r; + RwRect origSize = { 0, 0, 0, 0 }; // FIX just to make the compier happy + RwV2d vw; + + RwEngineGetVideoModeInfo(&videoMode, + RwEngineGetCurrentVideoMode()); + + origSize.w = RwRasterGetWidth(RwCameraGetRaster(camera)); + origSize.h = RwRasterGetHeight(RwCameraGetRaster(camera)); + + if (!rect) + { + if (videoMode.flags & rwVIDEOMODEEXCLUSIVE) + { + /* For full screen applications, resizing the camera just doesn't + * make sense, use the video mode size. + */ + + r.x = r.y = 0; + r.w = videoMode.width; + r.h = videoMode.height; + rect = &r; + } + else + { + /* + rect not specified - reuse current values + */ + r.w = RwRasterGetWidth(RwCameraGetRaster(camera)); + r.h = RwRasterGetHeight(RwCameraGetRaster(camera)); + r.x = r.y = 0; + rect = &r; + } + } + + if (( origSize.w != rect->w ) && ( origSize.h != rect->h )) + { + RwRaster *raster; + RwRaster *zRaster; + + /* + * Destroy rasters... + */ + + raster = RwCameraGetRaster(camera); + if( raster ) + { + RwRasterDestroy(raster); + } + + zRaster = RwCameraGetZRaster(camera); + if( zRaster ) + { + RwRasterDestroy(zRaster); + } + + /* + * Create new rasters... + */ + + raster = RwRasterCreate(rect->w, rect->h, 0, rwRASTERTYPECAMERA); + zRaster = RwRasterCreate(rect->w, rect->h, 0, rwRASTERTYPEZBUFFER); + + if( raster && zRaster ) + { + RwCameraSetRaster(camera, raster); + RwCameraSetZRaster(camera, zRaster); + } + else + { + if( raster ) + { + RwRasterDestroy(raster); + } + + if( zRaster ) + { + RwRasterDestroy(zRaster); + } + + rect->x = origSize.x; + rect->y = origSize.y; + rect->w = origSize.w; + rect->h = origSize.h; + + /* + * Use default values... + */ + raster = + RwRasterCreate(rect->w, rect->h, 0, rwRASTERTYPECAMERA); + + zRaster = + RwRasterCreate(rect->w, rect->h, 0, rwRASTERTYPEZBUFFER); + + RwCameraSetRaster(camera, raster); + RwCameraSetZRaster(camera, zRaster); + } + } + + /* Figure out the view window */ + if (videoMode.flags & rwVIDEOMODEEXCLUSIVE) + { + /* derive ratio from aspect ratio */ + vw.x = viewWindow; + vw.y = viewWindow / aspectRatio; + } + else + { + /* derive from pixel ratios */ + if (rect->w > rect->h) + { + vw.x = viewWindow; + vw.y = (rect->h * viewWindow) / rect->w; + } + else + { + vw.x = (rect->w * viewWindow) / rect->h; + vw.y = viewWindow; + } + } + + RwCameraSetViewWindow(camera, &vw); + + RsGlobal.width = rect->w; + RsGlobal.height = rect->h; + } + + return; +} + +void +CameraDestroy(RwCamera *camera) +{ + RwRaster *raster, *tmpRaster; + RwFrame *frame; + + if (camera) + { + frame = RwCameraGetFrame(camera); + if (frame) + { + RwFrameDestroy(frame); + } + + raster = RwCameraGetRaster(camera); + if (raster) + { + tmpRaster = RwRasterGetParent(raster); + + RwRasterDestroy(raster); + + if ((tmpRaster != nil) && (tmpRaster != raster)) + { + RwRasterDestroy(tmpRaster); + } + } + + raster = RwCameraGetZRaster(camera); + if (raster) + { + tmpRaster = RwRasterGetParent(raster); + + RwRasterDestroy(raster); + + if ((tmpRaster != nil) && (tmpRaster != raster)) + { + RwRasterDestroy(tmpRaster); + } + } + + RwCameraDestroy(camera); + } + + return; +} + +RwCamera * +CameraCreate(RwInt32 width, RwInt32 height, RwBool zBuffer) +{ + RwCamera *camera; + + camera = RwCameraCreate(); + + if (camera) + { + RwCameraSetFrame(camera, RwFrameCreate()); + RwCameraSetRaster(camera, + RwRasterCreate(0, 0, 0, rwRASTERTYPECAMERA)); + + if (zBuffer) + { + RwCameraSetZRaster(camera, + RwRasterCreate(0, 0, 0, + rwRASTERTYPEZBUFFER)); + } + + /* now check that everything is valid */ + if (RwCameraGetFrame(camera) && + RwCameraGetRaster(camera) && + RwRasterGetParent(RwCameraGetRaster(camera)) && + (!zBuffer || (RwCameraGetZRaster(camera) && + RwRasterGetParent(RwCameraGetZRaster + (camera))))) + { + /* everything OK */ + return (camera); + } + } + + /* if we're here then an error must have occurred so clean up */ + + CameraDestroy(camera); + return (nil); +} + +void CreateDebugFont() +{ + ; +} + +void DestroyDebugFont() +{ + ; +} + +void FlushObrsPrintfs() +{ + ; +} + +WRAPPER void _TexturePoolsInitialise() { EAXJMP(0x598B10); } +WRAPPER void _TexturePoolsShutdown() { EAXJMP(0x598B30); } + +STARTPATCHES + //InjectHook(0x526450, GetFirstObjectCallback, PATCH_JUMP); + InjectHook(0x526460, GetFirstObject, PATCH_JUMP); + InjectHook(0x527170, CameraSize, PATCH_JUMP); + InjectHook(0x527340, CameraDestroy, PATCH_JUMP); + InjectHook(0x5273B0, CameraCreate, PATCH_JUMP); +ENDPATCHES diff --git a/src/rw/RwHelper.h b/src/rw/RwHelper.h new file mode 100644 index 00000000..a9f0bdf4 --- /dev/null +++ b/src/rw/RwHelper.h @@ -0,0 +1,40 @@ +#pragma once + +void *RwMallocAlign(RwUInt32 size, RwUInt32 align); +void RwFreeAlign(void *mem); + +void CreateDebugFont(); +void DestroyDebugFont(); +void FlushObrsPrintfs(); +void DefinedState(void); +RwFrame *GetFirstChild(RwFrame *frame); +RwObject *GetFirstObject(RwFrame *frame); +RpAtomic *GetFirstAtomic(RpClump *clump); +RwTexture *GetFirstTexture(RwTexDictionary *txd); + +RwTexDictionary *RwTexDictionaryGtaStreamRead(RwStream *stream); +RwTexDictionary *RwTexDictionaryGtaStreamRead1(RwStream *stream); +RwTexDictionary *RwTexDictionaryGtaStreamRead2(RwStream *stream, RwTexDictionary *texDict); +void ReadVideoCardCapsFile(uint32&, uint32&, uint32&, uint32&); +bool CheckVideoCardCaps(void); +void WriteVideoCardCapsFile(void); +void ConvertingTexturesScreen(uint32, uint32, const char*); +void DealWithTxdWriteError(uint32, uint32, const char*); +bool CreateTxdImageForVideoCard(); + +bool RpClumpGtaStreamRead1(RwStream *stream); +RpClump *RpClumpGtaStreamRead2(RwStream *stream); +void RpClumpGtaCancelStream(void); + +void CameraSize(RwCamera *camera, + RwRect *rect, + RwReal viewWindow, + RwReal aspectRatio); +void CameraDestroy(RwCamera *camera); +RwCamera *CameraCreate(RwInt32 width, + RwInt32 height, + RwBool zBuffer); + + +void _TexturePoolsInitialise(); +void _TexturePoolsShutdown(); \ No newline at end of file diff --git a/src/rw/RwMatFX.cpp b/src/rw/RwMatFX.cpp new file mode 100644 index 00000000..ca9a633b --- /dev/null +++ b/src/rw/RwMatFX.cpp @@ -0,0 +1,213 @@ +#define WITHD3D +#include "common.h" +#include "patcher.h" + +struct MatFXNothing { int pad[5]; int effect; }; + +struct MatFXBump +{ + RwFrame *bumpFrame; + RwTexture *bumpedTex; + RwTexture *bumpTex; + float negBumpCoefficient; + int pad; + int effect; +}; + +struct MatFXEnv +{ + RwFrame *envFrame; + RwTexture *envTex; + float envCoeff; + int envFBalpha; + int pad; + int effect; +}; + +struct MatFXDual +{ + RwTexture *dualTex; + RwInt32 srcBlend; + RwInt32 dstBlend; +}; + + +struct MatFX +{ + union { + MatFXNothing n; + MatFXBump b; + MatFXEnv e; + MatFXDual d; + } fx[2]; + int effects; +}; + +int &MatFXMaterialDataOffset = *(int*)0x66188C; +int &MatFXAtomicDataOffset = *(int*)0x66189C; + +#ifdef PS2_MATFX + +void +_rpMatFXD3D8AtomicMatFXDefaultRender(RxD3D8InstanceData *inst, int flags, RwTexture *texture) +{ + if(flags & (rpGEOMETRYTEXTURED|rpGEOMETRYTEXTURED2) && texture) + RwD3D8SetTexture(texture, 0); + else + RwD3D8SetTexture(nil, 0); + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)(inst->vertexAlpha || inst->material->color.alpha != 0xFF)); + RwD3D8SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, inst->vertexAlpha != 0); + RwD3D8SetPixelShader(0); + RwD3D8SetVertexShader(inst->vertexShader); + RwD3D8SetStreamSource(0, inst->vertexBuffer, inst->stride); + + if(inst->indexBuffer){ + RwD3D8SetIndices(inst->indexBuffer, inst->baseIndex); + RwD3D8DrawIndexedPrimitive(inst->primType, 0, inst->numVertices, 0, inst->numIndices); + }else + RwD3D8DrawPrimitive(inst->primType, inst->baseIndex, inst->numVertices); +} + +// map [-1; -1] -> [0; 1], flip V +static RwMatrix scalenormal = { + { 0.5f, 0.0f, 0.0f }, 0, + { 0.0f, -0.5f, 0.0f }, 0, + { 0.0f, 0.0f, 1.0f }, 0, + { 0.5f, 0.5f, 0.0f }, 0, + +}; + +// flipped U for PS2 +static RwMatrix scalenormal_flipU = { + { -0.5f, 0.0f, 0.0f }, 0, + { 0.0f, -0.5f, 0.0f }, 0, + { 0.0f, 0.0f, 1.0f }, 0, + { 0.5f, 0.5f, 0.0f }, 0, + +}; + +void +ApplyEnvMapTextureMatrix(RwTexture *tex, int n, RwFrame *frame) +{ + RwD3D8SetTexture(tex, n); + RwD3D8SetTextureStageState(n, D3DRS_ALPHAREF, 2); + RwD3D8SetTextureStageState(n, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACENORMAL); + if(frame){ + RwMatrix *envframemat = RwMatrixCreate(); + RwMatrix *tmpmat = RwMatrixCreate(); + RwMatrix *envmat = RwMatrixCreate(); + + RwMatrixInvert(envframemat, RwFrameGetLTM(frame)); + // PS2 + // can this be simplified? + *tmpmat = *RwFrameGetLTM(RwCameraGetFrame((RwCamera*)RWSRCGLOBAL(curCamera))); + RwV3dNegate(&tmpmat->right, &tmpmat->right); + tmpmat->flags = 0; + tmpmat->pos.x = 0.0f; + tmpmat->pos.y = 0.0f; + tmpmat->pos.z = 0.0f; + RwMatrixMultiply(envmat, tmpmat, envframemat); + *tmpmat = *envmat; + // important because envframemat can have a translation that we don't like + tmpmat->pos.x = 0.0f; + tmpmat->pos.y = 0.0f; + tmpmat->pos.z = 0.0f; + // for some reason we flip in U as well + RwMatrixMultiply(envmat, tmpmat, &scalenormal_flipU); + + RwD3D8SetTransform(D3DTS_TEXTURE0+n, envmat); + + RwMatrixDestroy(envmat); + RwMatrixDestroy(tmpmat); + RwMatrixDestroy(envframemat); + }else + RwD3D8SetTransform(D3DTS_TEXTURE0+n, &scalenormal); +} + +void +_rpMatFXD3D8AtomicMatFXEnvRender_ps2(RxD3D8InstanceData *inst, int flags, int sel, RwTexture *texture, RwTexture *envMap) +{ + MatFX *matfx = *RWPLUGINOFFSET(MatFX*, inst->material, MatFXMaterialDataOffset); + MatFXEnv *env = &matfx->fx[sel].e; + + uint8 intens = (uint8)(env->envCoeff*255.0f); + + if(intens == 0 || envMap == nil){ + if(sel == 0) + _rpMatFXD3D8AtomicMatFXDefaultRender(inst, flags, texture); + return; + } + + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)(inst->vertexAlpha || inst->material->color.alpha != 0xFF)); + if(flags & (rpGEOMETRYTEXTURED|rpGEOMETRYTEXTURED2) && texture) + RwD3D8SetTexture(texture, 0); + else + RwD3D8SetTexture(nil, 0); + RwD3D8SetPixelShader(0); + RwD3D8SetVertexShader(inst->vertexShader); + RwD3D8SetStreamSource(0, inst->vertexBuffer, inst->stride); + RwD3D8SetIndices(inst->indexBuffer, inst->baseIndex); + if(inst->indexBuffer) + RwD3D8DrawIndexedPrimitive(inst->primType, 0, inst->numVertices, 0, inst->numIndices); + else + RwD3D8DrawPrimitive(inst->primType, inst->baseIndex, inst->numVertices); + + // Effect pass + + ApplyEnvMapTextureMatrix(envMap, 0, env->envFrame); + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); + RwUInt32 src, dst, lighting, zwrite, fog, fogcol; + RwRenderStateGet(rwRENDERSTATESRCBLEND, &src); + RwRenderStateGet(rwRENDERSTATEDESTBLEND, &dst); + + // This is of course not using framebuffer alpha, + // but if the diffuse texture had no alpha, the result should actually be rather the same + if(env->envFBalpha) + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + else + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDONE); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE); + RwD3D8GetRenderState(D3DRS_LIGHTING, &lighting); + RwD3D8GetRenderState(D3DRS_ZWRITEENABLE, &zwrite); + RwD3D8GetRenderState(D3DRS_FOGENABLE, &fog); + RwD3D8SetRenderState(D3DRS_ZWRITEENABLE, FALSE); + if(fog){ + RwD3D8GetRenderState(D3DRS_FOGCOLOR, &fogcol); + RwD3D8SetRenderState(D3DRS_FOGCOLOR, 0); + } + + D3DCOLOR texfactor = D3DCOLOR_RGBA(intens, intens, intens, intens); + RwD3D8SetRenderState(D3DRS_TEXTUREFACTOR, texfactor); + RwD3D8SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE); + RwD3D8SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_CURRENT); + RwD3D8SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_TFACTOR); + // alpha unused + //RwD3D8SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); + //RwD3D8SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_CURRENT); + //RwD3D8SetTextureStageState(1, D3DTSS_ALPHAARG2, D3DTA_TFACTOR); + + if(inst->indexBuffer) + RwD3D8DrawIndexedPrimitive(inst->primType, 0, inst->numVertices, 0, inst->numIndices); + else + RwD3D8DrawPrimitive(inst->primType, inst->baseIndex, inst->numVertices); + + // Reset states + + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE); + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)src); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)dst); + RwD3D8SetRenderState(D3DRS_LIGHTING, lighting); + RwD3D8SetRenderState(D3DRS_ZWRITEENABLE, zwrite); + if(fog) + RwD3D8SetRenderState(D3DRS_FOGCOLOR, fogcol); + RwD3D8SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); + RwD3D8SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + RwD3D8SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, 0); + RwD3D8SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0); +} + +STARTPATCHES + InjectHook(0x5CF6C0, _rpMatFXD3D8AtomicMatFXEnvRender_ps2, PATCH_JUMP); +ENDPATCHES + +#endif diff --git a/src/rw/TexRead.cpp b/src/rw/TexRead.cpp new file mode 100644 index 00000000..50b99d47 --- /dev/null +++ b/src/rw/TexRead.cpp @@ -0,0 +1,349 @@ +#pragma warning( push ) +#pragma warning( disable : 4005) +#define DIRECTINPUT_VERSION 0x0800 +#include +#pragma warning( pop ) +#define WITHWINDOWS +#include "common.h" +#include "win.h" +#include "patcher.h" +#include "Timer.h" +#ifdef GTA_PC +#include "FileMgr.h" +#include "Pad.h" +#include "main.h" +#include "Directory.h" +#include "Streaming.h" +#include "TxdStore.h" +#include "CdStream.h" +#include "Font.h" +#include "Sprite2d.h" +#include "Text.h" +#include "RwHelper.h" +#endif //GTA_PC + +float &texLoadTime = *(float*)0x8F1B50; +int32 &texNumLoaded = *(int32*)0x8F252C; + +RwTexture* +RwTextureGtaStreamRead(RwStream *stream) +{ + RwUInt32 size, version; + RwTexture *tex; + + if(!RwStreamFindChunk(stream, rwID_TEXTURENATIVE, &size, &version)) + return nil; + + float preloadTime = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond(); + + if(!RWSRCGLOBAL(stdFunc[rwSTANDARDNATIVETEXTUREREAD](stream, &tex, size))) + return nil; + + if (gGameState == GS_INIT_PLAYING_GAME) { + texLoadTime = (texNumLoaded * texLoadTime + (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond() - preloadTime) / (float)(texNumLoaded+1); + texNumLoaded++; + } + return tex; +} + +RwTexture* +destroyTexture(RwTexture *texture, void *data) +{ + RwTextureDestroy(texture); + return texture; +} + +RwTexDictionary* +RwTexDictionaryGtaStreamRead(RwStream *stream) +{ + RwUInt32 size, version; + RwInt32 numTextures; + RwTexDictionary *texDict; + RwTexture *tex; + + if(!RwStreamFindChunk(stream, rwID_STRUCT, &size, &version)) + return nil; + assert(size == 4); + if(RwStreamRead(stream, &numTextures, size) != size) + return nil; + + texDict = RwTexDictionaryCreate(); + if(texDict == nil) + return nil; + + while(numTextures--){ + tex = RwTextureGtaStreamRead(stream); + if(tex == nil){ + RwTexDictionaryForAllTextures(texDict, destroyTexture, nil); + RwTexDictionaryDestroy(texDict); + return nil; + } + RwTexDictionaryAddTexture(texDict, tex); + } + + return texDict; +} + +static int32 numberTextures = -1; +static int32 streamPosition; + +RwTexDictionary* +RwTexDictionaryGtaStreamRead1(RwStream *stream) +{ + RwUInt32 size, version; + RwInt32 numTextures; + RwTexDictionary *texDict; + RwTexture *tex; + + numberTextures = 0; + if(!RwStreamFindChunk(stream, rwID_STRUCT, &size, &version)) + return nil; + assert(size == 4); + if(RwStreamRead(stream, &numTextures, size) != size) + return nil; + + texDict = RwTexDictionaryCreate(); + if(texDict == nil) + return nil; + + numberTextures = numTextures/2; + + while(numTextures > numberTextures){ + numTextures--; + + tex = RwTextureGtaStreamRead(stream); + if(tex == nil){ + RwTexDictionaryForAllTextures(texDict, destroyTexture, nil); + RwTexDictionaryDestroy(texDict); + return nil; + } + RwTexDictionaryAddTexture(texDict, tex); + } + + numberTextures = numTextures; + streamPosition = stream->Type.memory.position; + + return texDict; +} + +RwTexDictionary* +RwTexDictionaryGtaStreamRead2(RwStream *stream, RwTexDictionary *texDict) +{ + RwTexture *tex; + + RwStreamSkip(stream, streamPosition - stream->Type.memory.position); + + while(numberTextures--){ + tex = RwTextureGtaStreamRead(stream); + if(tex == nil){ + RwTexDictionaryForAllTextures(texDict, destroyTexture, nil); + RwTexDictionaryDestroy(texDict); + return nil; + } + RwTexDictionaryAddTexture(texDict, tex); + } + + return texDict; +} + +#ifdef GTA_PC +#ifdef RWLIBS +extern "C" RwInt32 _rwD3D8FindCorrectRasterFormat(RwRasterType type, RwInt32 flags); +#else +WRAPPER RwInt32 _rwD3D8FindCorrectRasterFormat(RwRasterType type, RwInt32 flags) { EAXJMP(0x59A350); } +#endif + +void +ReadVideoCardCapsFile(uint32 &cap32, uint32 &cap24, uint32 &cap16, uint32 &cap8) +{ + cap32 = UINT32_MAX; + cap24 = UINT32_MAX; + cap16 = UINT32_MAX; + cap8 = UINT32_MAX; + + int32 file = CFileMgr::OpenFile("DATA\\CAPS.DAT", "rb"); + if (file != 0) { + CFileMgr::Read(file, (char*)&cap32, 4); + CFileMgr::Read(file, (char*)&cap24, 4); + CFileMgr::Read(file, (char*)&cap16, 4); + CFileMgr::Read(file, (char*)&cap8, 4); + CFileMgr::CloseFile(file); + } +} + +bool +CheckVideoCardCaps(void) +{ + uint32 cap32 = _rwD3D8FindCorrectRasterFormat(rwRASTERTYPETEXTURE, rwRASTERFORMAT8888); + uint32 cap24 = _rwD3D8FindCorrectRasterFormat(rwRASTERTYPETEXTURE, rwRASTERFORMAT888); + uint32 cap16 = _rwD3D8FindCorrectRasterFormat(rwRASTERTYPETEXTURE, rwRASTERFORMAT1555); + uint32 cap8 = _rwD3D8FindCorrectRasterFormat(rwRASTERTYPETEXTURE, rwRASTERFORMATPAL8 | rwRASTERFORMAT8888); + uint32 fcap32, fcap24, fcap16, fcap8; + ReadVideoCardCapsFile(fcap32, fcap24, fcap16, fcap8); + return cap32 != fcap32 || cap24 != fcap24 || cap16 != fcap16 || cap8 != fcap8; +} + +void +WriteVideoCardCapsFile(void) +{ + uint32 cap32 = _rwD3D8FindCorrectRasterFormat(rwRASTERTYPETEXTURE, rwRASTERFORMAT8888); + uint32 cap24 = _rwD3D8FindCorrectRasterFormat(rwRASTERTYPETEXTURE, rwRASTERFORMAT888); + uint32 cap16 = _rwD3D8FindCorrectRasterFormat(rwRASTERTYPETEXTURE, rwRASTERFORMAT1555); + uint32 cap8 = _rwD3D8FindCorrectRasterFormat(rwRASTERTYPETEXTURE, rwRASTERFORMATPAL8 | rwRASTERFORMAT8888); + int32 file = CFileMgr::OpenFile("DATA\\CAPS.DAT", "wb"); + if (file != 0) { + CFileMgr::Write(file, (char*)&cap32, 4); + CFileMgr::Write(file, (char*)&cap24, 4); + CFileMgr::Write(file, (char*)&cap16, 4); + CFileMgr::Write(file, (char*)&cap8, 4); + CFileMgr::CloseFile(file); + } +} + +bool DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha); +void DoRWStuffEndOfFrame(void); + +void +ConvertingTexturesScreen(uint32 num, uint32 count, const char *text) +{ + HandleExit(); + + CSprite2d *splash = LoadSplash(nil); + if (!DoRWStuffStartOfFrame(0, 0, 0, 0, 0, 0, 255)) + return; + + CSprite2d::SetRecipNearClip(); + CSprite2d::InitPerFrame(); + CFont::InitPerFrame(); + DefinedState(); + + RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void*)rwTEXTUREADDRESSCLAMP); + splash->Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(255, 255, 255, 255)); + + CSprite2d::DrawRect(CRect(SCREEN_SCALE_X(200.0f), SCREEN_SCALE_Y(240.0f), SCREEN_SCALE_FROM_RIGHT(200.0f), SCREEN_SCALE_Y(248.0f)), CRGBA(64, 64, 64, 255)); + CSprite2d::DrawRect(CRect(SCREEN_SCALE_X(200.0f), SCREEN_SCALE_Y(240.0f), (SCREEN_SCALE_FROM_RIGHT(200.0f) - SCREEN_SCALE_X(200.0f)) * ((float)num / (float)count) + SCREEN_SCALE_X(200.0f), SCREEN_SCALE_Y(248.0f)), CRGBA(255, 217, 106, 255)); + CSprite2d::DrawRect(CRect(SCREEN_SCALE_X(120.0f), SCREEN_SCALE_Y(150.0f), SCREEN_SCALE_FROM_RIGHT(120.0f), SCREEN_HEIGHT - SCREEN_SCALE_Y(220.0f)), CRGBA(50, 50, 50, 210)); + + CFont::SetBackgroundOff(); + CFont::SetPropOn(); + CFont::SetScale(SCREEN_SCALE_X(0.45f), SCREEN_SCALE_Y(0.7f)); + CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(170.0f)); + CFont::SetJustifyOff(); + CFont::SetColor(CRGBA(255, 217, 106, 255)); + CFont::SetBackGroundOnlyTextOff(); + CFont::SetFontStyle(FONT_BANK); + CFont::PrintString(SCREEN_SCALE_X(170.0f), SCREEN_SCALE_Y(160.0f), TheText.Get(text)); + CFont::DrawFonts(); + DoRWStuffEndOfFrame(); +} + +void +DealWithTxdWriteError(uint32 num, uint32 count, const char *text) +{ + while (!RsGlobal.quit) { + ConvertingTexturesScreen(num, count, text); + CPad::UpdatePads(); + if (CPad::GetPad(0)->GetEscapeJustDown()) + break; + } + RsGlobal.quit = false; + LoadingScreen(nil, nil, nil); + RsGlobal.quit = true; +} + +bool +CreateTxdImageForVideoCard() +{ + uint8 *buf = new uint8[CDSTREAM_SECTOR_SIZE]; + CDirectory *pDir = new CDirectory(TXDSTORESIZE); + CDirectory::DirectoryInfo dirInfo; + + CStreaming::FlushRequestList(); + + RwFileFunctions *filesys = RwOsGetFileInterface(); + + RwStream *img = RwStreamOpen(rwSTREAMFILENAME, rwSTREAMWRITE, "models\\txd.img"); + if (img == nil) { + // original code does otherwise and it leaks + delete []buf; + delete pDir; + + if (_dwOperatingSystemVersion == OS_WINNT || _dwOperatingSystemVersion == OS_WIN2000 || _dwOperatingSystemVersion == OS_WINXP) + DealWithTxdWriteError(0, TXDSTORESIZE, "CVT_CRT"); + + return false; + } + + int32 i; + for (i = 0; i < TXDSTORESIZE; i++) { + ConvertingTexturesScreen(i, TXDSTORESIZE, "CVT_MSG"); + + if (CTxdStore::GetSlot(i) != nil && CStreaming::IsObjectInCdImage(i + STREAM_OFFSET_TXD)) { + CStreaming::RequestTxd(i, STREAMFLAGS_KEEP_IN_MEMORY); + CStreaming::RequestModelStream(0); + CStreaming::FlushChannels(); + + char filename[64]; + sprintf(filename, "%s.txd", CTxdStore::GetTxdName(i)); + + if (CTxdStore::GetSlot(i)->texDict) { + int32 pos = filesys->rwftell(img->Type.file.fpFile); + + if (RwTexDictionaryStreamWrite(CTxdStore::GetSlot(i)->texDict, img) == nil) { + DealWithTxdWriteError(i, TXDSTORESIZE, "CVT_ERR"); + RwStreamClose(img, nil); + delete []buf; + delete pDir; + CStreaming::RemoveTxd(i); + return false; + } + + int32 size = filesys->rwftell(img->Type.file.fpFile) - pos; + int32 num = size % CDSTREAM_SECTOR_SIZE; + + size /= CDSTREAM_SECTOR_SIZE; + if (num != 0) { + size++; + num = CDSTREAM_SECTOR_SIZE - num; + RwStreamWrite(img, buf, num); + } + + dirInfo.offset = pos / CDSTREAM_SECTOR_SIZE; + dirInfo.size = size; + strncpy(dirInfo.name, filename, sizeof(dirInfo.name)); + pDir->AddItem(dirInfo); + CStreaming::RemoveTxd(i); + } + CStreaming::FlushRequestList(); + } + } + + RwStreamClose(img, nil); + delete []buf; + + if (!pDir->WriteDirFile("models\\txd.dir")) { + DealWithTxdWriteError(i, TXDSTORESIZE, "CVT_ERR"); + delete pDir; + return false; + } + + delete pDir; + + WriteVideoCardCapsFile(); + return true; +} +#endif // GTA_PC + +STARTPATCHES + InjectHook(0x592380, RwTextureGtaStreamRead, PATCH_JUMP); + InjectHook(0x5924A0, RwTexDictionaryGtaStreamRead, PATCH_JUMP); + InjectHook(0x592550, RwTexDictionaryGtaStreamRead1, PATCH_JUMP); + InjectHook(0x592650, RwTexDictionaryGtaStreamRead2, PATCH_JUMP); + + InjectHook(0x5926C0, ReadVideoCardCapsFile, PATCH_JUMP); + InjectHook(0x592740, CheckVideoCardCaps, PATCH_JUMP); + InjectHook(0x5927D0, WriteVideoCardCapsFile, PATCH_JUMP); + InjectHook(0x592880, ConvertingTexturesScreen, PATCH_JUMP); + InjectHook(0x592BF0, DealWithTxdWriteError, PATCH_JUMP); + InjectHook(0x592C70, CreateTxdImageForVideoCard, PATCH_JUMP); +ENDPATCHES diff --git a/src/rw/TxdStore.cpp b/src/rw/TxdStore.cpp new file mode 100644 index 00000000..c751147d --- /dev/null +++ b/src/rw/TxdStore.cpp @@ -0,0 +1,209 @@ +#include "common.h" +#include "patcher.h" +#include "templates.h" +#include "General.h" +#include "Streaming.h" +#include "RwHelper.h" +#include "TxdStore.h" + +CPool *&CTxdStore::ms_pTxdPool = *(CPool**)0x8F5FB8; +RwTexDictionary *&CTxdStore::ms_pStoredTxd = *(RwTexDictionary**)0x9405BC; + +void +CTxdStore::Initialise(void) +{ + if(ms_pTxdPool == nil) + ms_pTxdPool = new CPool(TXDSTORESIZE); +} + +void +CTxdStore::Shutdown(void) +{ + if(ms_pTxdPool) + delete ms_pTxdPool; +} + +void +CTxdStore::GameShutdown(void) +{ + int i; + + for(i = 0; i < TXDSTORESIZE; i++){ + TxdDef *def = GetSlot(i); + if(def && GetNumRefs(i) == 0) + RemoveTxdSlot(i); + } +} + +int +CTxdStore::AddTxdSlot(const char *name) +{ + TxdDef *def = ms_pTxdPool->New(); + assert(def); + def->texDict = nil; + def->refCount = 0; + strcpy(def->name, name); + return ms_pTxdPool->GetJustIndex(def); +} + +void +CTxdStore::RemoveTxdSlot(int slot) +{ + TxdDef *def = GetSlot(slot); + if(def->texDict) + RwTexDictionaryDestroy(def->texDict); + ms_pTxdPool->Delete(def); +} + +int +CTxdStore::FindTxdSlot(const char *name) +{ + char *defname; + int size = ms_pTxdPool->GetSize(); + for(int i = 0; i < size; i++){ + defname = GetTxdName(i); + if(defname && !CGeneral::faststricmp(defname, name)) + return i; + } + return -1; +} + +char* +CTxdStore::GetTxdName(int slot) +{ + TxdDef *def = GetSlot(slot); + return def ? def->name : nil; +} + +void +CTxdStore::PushCurrentTxd(void) +{ + ms_pStoredTxd = RwTexDictionaryGetCurrent(); +} + +void +CTxdStore::PopCurrentTxd(void) +{ + RwTexDictionarySetCurrent(ms_pStoredTxd); + ms_pStoredTxd = nil; +} + +void +CTxdStore::SetCurrentTxd(int slot) +{ + TxdDef *def = GetSlot(slot); + if(def) + RwTexDictionarySetCurrent(def->texDict); +} + +void +CTxdStore::Create(int slot) +{ + GetSlot(slot)->texDict = RwTexDictionaryCreate(); +} + +int +CTxdStore::GetNumRefs(int slot) +{ + return GetSlot(slot)->refCount; +} + +void +CTxdStore::AddRef(int slot) +{ + GetSlot(slot)->refCount++; +} + +void +CTxdStore::RemoveRef(int slot) +{ + if(--GetSlot(slot)->refCount <= 0) + CStreaming::RemoveModel(slot + STREAM_OFFSET_TXD); +} + +void +CTxdStore::RemoveRefWithoutDelete(int slot) +{ + GetSlot(slot)->refCount--; +} + +bool +CTxdStore::LoadTxd(int slot, RwStream *stream) +{ + TxdDef *def = GetSlot(slot); + + if(RwStreamFindChunk(stream, rwID_TEXDICTIONARY, nil, nil)){ + def->texDict = RwTexDictionaryGtaStreamRead(stream); + return def->texDict != nil; + } + printf("Failed to load TXD\n"); + return false; +} + +bool +CTxdStore::LoadTxd(int slot, const char *filename) +{ + RwStream *stream; + bool ret; + + ret = false; + _rwD3D8TexDictionaryEnableRasterFormatConversion(true); + do + stream = RwStreamOpen(rwSTREAMFILENAME, rwSTREAMREAD, filename); + while(stream == nil); + ret = LoadTxd(slot, stream); + RwStreamClose(stream, nil); + return ret; +} + +bool +CTxdStore::StartLoadTxd(int slot, RwStream *stream) +{ + TxdDef *def = GetSlot(slot); + if(RwStreamFindChunk(stream, rwID_TEXDICTIONARY, nil, nil)){ + def->texDict = RwTexDictionaryGtaStreamRead1(stream); + return def->texDict != nil; + }else{ + printf("Failed to load TXD\n"); + return false; + } +} + +bool +CTxdStore::FinishLoadTxd(int slot, RwStream *stream) +{ + TxdDef *def = GetSlot(slot); + def->texDict = RwTexDictionaryGtaStreamRead2(stream, def->texDict); + return def->texDict != nil; +} + +void +CTxdStore::RemoveTxd(int slot) +{ + TxdDef *def = GetSlot(slot); + if(def->texDict) + RwTexDictionaryDestroy(def->texDict); + def->texDict = nil; +} + +STARTPATCHES + InjectHook(0x527440, CTxdStore::Initialise, PATCH_JUMP); + InjectHook(0x527470, CTxdStore::Shutdown, PATCH_JUMP); + InjectHook(0x527490, CTxdStore::GameShutdown, PATCH_JUMP); + InjectHook(0x5274E0, CTxdStore::AddTxdSlot, PATCH_JUMP); + InjectHook(0x5275D0, CTxdStore::FindTxdSlot, PATCH_JUMP); + InjectHook(0x527590, CTxdStore::GetTxdName, PATCH_JUMP); + InjectHook(0x527900, CTxdStore::PushCurrentTxd, PATCH_JUMP); + InjectHook(0x527910, CTxdStore::PopCurrentTxd, PATCH_JUMP); + InjectHook(0x5278C0, CTxdStore::SetCurrentTxd, PATCH_JUMP); + InjectHook(0x527830, CTxdStore::Create, PATCH_JUMP); + InjectHook(0x527A00, CTxdStore::GetNumRefs, PATCH_JUMP); + InjectHook(0x527930, CTxdStore::AddRef, PATCH_JUMP); + InjectHook(0x527970, CTxdStore::RemoveRef, PATCH_JUMP); + InjectHook(0x5279C0, CTxdStore::RemoveRefWithoutDelete, PATCH_JUMP); + InjectHook(0x527700, (bool (*)(int, RwStream*))CTxdStore::LoadTxd, PATCH_JUMP); + InjectHook(0x5276B0, (bool (*)(int, const char*))CTxdStore::LoadTxd, PATCH_JUMP); + InjectHook(0x527770, CTxdStore::StartLoadTxd, PATCH_JUMP); + InjectHook(0x5277E0, CTxdStore::FinishLoadTxd, PATCH_JUMP); + InjectHook(0x527870, CTxdStore::RemoveTxd, PATCH_JUMP); +ENDPATCHES diff --git a/src/rw/TxdStore.h b/src/rw/TxdStore.h new file mode 100644 index 00000000..12ac708f --- /dev/null +++ b/src/rw/TxdStore.h @@ -0,0 +1,44 @@ +#pragma once + +#include "templates.h" + +struct TxdDef { + RwTexDictionary *texDict; + int refCount; + char name[20]; +}; + +class CTxdStore +{ + static CPool *&ms_pTxdPool; + static RwTexDictionary *&ms_pStoredTxd; +public: + static void Initialise(void); + static void Shutdown(void); + static void GameShutdown(void); + static int AddTxdSlot(const char *name); + static void RemoveTxdSlot(int slot); + static int FindTxdSlot(const char *name); + static char *GetTxdName(int slot); + static void PushCurrentTxd(void); + static void PopCurrentTxd(void); + static void SetCurrentTxd(int slot); + static void Create(int slot); + static int GetNumRefs(int slot); + static void AddRef(int slot); + static void RemoveRef(int slot); + static void RemoveRefWithoutDelete(int slot); + static bool LoadTxd(int slot, RwStream *stream); + static bool LoadTxd(int slot, const char *filename); + static bool StartLoadTxd(int slot, RwStream *stream); + static bool FinishLoadTxd(int slot, RwStream *stream); + static void RemoveTxd(int slot); + + static TxdDef *GetSlot(int slot) { + assert(slot >= 0); + assert(ms_pTxdPool); + assert(slot < ms_pTxdPool->GetSize()); + return ms_pTxdPool->GetSlot(slot); + } + static bool isTxdLoaded(int slot); +}; diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp new file mode 100644 index 00000000..f8b1f6b2 --- /dev/null +++ b/src/rw/VisibilityPlugins.cpp @@ -0,0 +1,889 @@ +#include "common.h" +#include "patcher.h" +#include "templates.h" +#include "Entity.h" +#include "ModelInfo.h" +#include "Lights.h" +#include "Renderer.h" +#include "Camera.h" +#include "VisibilityPlugins.h" +#include "World.h" + +#define FADE_DISTANCE 20.0f + +/* +CLinkList CVisibilityPlugins::m_alphaList; +CLinkList CVisibilityPlugins::m_alphaEntityList; + +int32 CVisibilityPlugins::ms_atomicPluginOffset = -1; +int32 CVisibilityPlugins::ms_framePluginOffset = -1; +int32 CVisibilityPlugins::ms_clumpPluginOffset = -1; +*/ +CLinkList &CVisibilityPlugins::m_alphaList = *(CLinkList*)0x8F42E4; +CLinkList &CVisibilityPlugins::m_alphaEntityList = *(CLinkList*)0x943084; + +int32 &CVisibilityPlugins::ms_atomicPluginOffset = *(int32*)0x600124; +int32 &CVisibilityPlugins::ms_framePluginOffset = *(int32*)0x600128; +int32 &CVisibilityPlugins::ms_clumpPluginOffset = *(int32*)0x60012C; + +RwCamera *&CVisibilityPlugins::ms_pCamera = *(RwCamera**)0x8F2514; +RwV3d *&CVisibilityPlugins::ms_pCameraPosn = *(RwV3d**)0x8F6270; +float &CVisibilityPlugins::ms_cullCompsDist = *(float*)0x8F2BC4; +float &CVisibilityPlugins::ms_vehicleLod0Dist = *(float*)0x885B28; +float &CVisibilityPlugins::ms_vehicleLod1Dist = *(float*)0x885B30; +float &CVisibilityPlugins::ms_vehicleFadeDist = *(float*)0x8E28B4; +float &CVisibilityPlugins::ms_bigVehicleLod0Dist = *(float*)0x8E2A84; +float &CVisibilityPlugins::ms_bigVehicleLod1Dist = *(float*)0x8E2A8C; +float &CVisibilityPlugins::ms_pedLod0Dist = *(float*)0x8F2BD4; +float &CVisibilityPlugins::ms_pedLod1Dist = *(float*)0x8F2BD8; +float &CVisibilityPlugins::ms_pedFadeDist = *(float*)0x8E2C34; + +void +CVisibilityPlugins::Initialise(void) +{ + m_alphaList.Init(20); + m_alphaList.head.item.sort = 0.0f; + m_alphaList.tail.item.sort = 100000000.0f; + m_alphaEntityList.Init(150); + m_alphaEntityList.head.item.sort = 0.0f; + m_alphaEntityList.tail.item.sort = 100000000.0f; +} + +void +CVisibilityPlugins::Shutdown(void) +{ + m_alphaList.Shutdown(); + m_alphaEntityList.Shutdown(); +} + +void +CVisibilityPlugins::InitAlphaEntityList(void) +{ + m_alphaEntityList.Clear(); +} + +bool +CVisibilityPlugins::InsertEntityIntoSortedList(CEntity *e, float dist) +{ + AlphaObjectInfo item; + item.entity = e; + item.sort = dist; + bool ret = !!m_alphaEntityList.InsertSorted(item); +// if(!ret) +// printf("list full %d\n", m_alphaEntityList.Count()); + return ret; +} + +void +CVisibilityPlugins::InitAlphaAtomicList(void) +{ + m_alphaList.Clear(); +} + +bool +CVisibilityPlugins::InsertAtomicIntoSortedList(RpAtomic *a, float dist) +{ + AlphaObjectInfo item; + item.atomic = a; + item.sort = dist; + bool ret = !!m_alphaList.InsertSorted(item); +// if(!ret) +// printf("list full %d\n", m_alphaList.Count()); + return ret; +} + +void +CVisibilityPlugins::SetRenderWareCamera(RwCamera *camera) +{ + ms_pCamera = camera; + ms_pCameraPosn = RwMatrixGetPos(RwFrameGetMatrix(RwCameraGetFrame(camera))); + + if(TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN || + TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOP_DOWN_PED) + ms_cullCompsDist = 1000000.0f; + else + ms_cullCompsDist = sq(TheCamera.LODDistMultiplier * 20.0f); + + ms_vehicleLod0Dist = sq(70.0f * TheCamera.GenerationDistMultiplier); + ms_vehicleLod1Dist = sq(90.0f * TheCamera.GenerationDistMultiplier); + ms_vehicleFadeDist = sq(100.0f * TheCamera.GenerationDistMultiplier); + ms_bigVehicleLod0Dist = sq(60.0f * TheCamera.GenerationDistMultiplier); + ms_bigVehicleLod1Dist = sq(150.0f * TheCamera.GenerationDistMultiplier); + ms_pedLod0Dist = sq(25.0f * TheCamera.LODDistMultiplier); + ms_pedLod1Dist = sq(60.0f * TheCamera.LODDistMultiplier); + ms_pedFadeDist = sq(70.0f * TheCamera.LODDistMultiplier); +} + +RpMaterial* +SetAlphaCB(RpMaterial *material, void *data) +{ + ((RwRGBA*)RpMaterialGetColor(material))->alpha = (uint8)(uint32)data; + return material; +} + +RpMaterial* +SetTextureCB(RpMaterial *material, void *data) +{ + RpMaterialSetTexture(material, (RwTexture*)data); + return material; +} + +void +CVisibilityPlugins::RenderAlphaAtomics(void) +{ + CLink *node; + for(node = m_alphaList.tail.prev; + node != &m_alphaList.head; + node = node->prev) + AtomicDefaultRenderCallBack(node->item.atomic); +} + +void +CVisibilityPlugins::RenderFadingEntities(void) +{ + CLink *node; + CSimpleModelInfo *mi; + for(node = m_alphaEntityList.tail.prev; + node != &m_alphaEntityList.head; + node = node->prev){ + CEntity *e = node->item.entity; + if(e->m_rwObject == nil) + continue; + mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(e->m_modelIndex); + if(mi->m_noZwrite) + RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, FALSE); + + if(e->bDistanceFade){ + DeActivateDirectional(); + SetAmbientColours(); + e->bImBeingRendered = true; + RenderFadingAtomic((RpAtomic*)e->m_rwObject, node->item.sort); + e->bImBeingRendered = false; + }else + CRenderer::RenderOneNonRoad(e); + + if(mi->m_noZwrite) + RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE); + } +} + +RpAtomic* +CVisibilityPlugins::RenderWheelAtomicCB(RpAtomic *atomic) +{ + RpAtomic *lodatm; + RwMatrix *m; + RwV3d view; + float len; + CSimpleModelInfo *mi; + + mi = GetAtomicModelInfo(atomic); + m = RwFrameGetLTM(RpAtomicGetFrame(atomic)); + RwV3dSub(&view, RwMatrixGetPos(m), ms_pCameraPosn); + len = RwV3dLength(&view); + lodatm = mi->GetAtomicFromDistance(len); + if(lodatm){ + if(RpAtomicGetGeometry(lodatm) != RpAtomicGetGeometry(atomic)) + RpAtomicSetGeometry(atomic, RpAtomicGetGeometry(lodatm), rpATOMICSAMEBOUNDINGSPHERE); + AtomicDefaultRenderCallBack(atomic); + } + return atomic; +} + +RpAtomic* +CVisibilityPlugins::RenderObjNormalAtomic(RpAtomic *atomic) +{ + RwMatrix *m; + RwV3d view; + float len; + + m = RwFrameGetLTM(RpAtomicGetFrame(atomic)); + RwV3dSub(&view, RwMatrixGetPos(m), ms_pCameraPosn); + len = RwV3dLength(&view); + if(RwV3dDotProduct(&view, RwMatrixGetUp(m)) < -0.3f*len && len > 8.0f) + return atomic; + AtomicDefaultRenderCallBack(atomic); + return atomic; +} + +RpAtomic* +CVisibilityPlugins::RenderAlphaAtomic(RpAtomic *atomic, int alpha) +{ + RpGeometry *geo; + uint32 flags; + + geo = RpAtomicGetGeometry(atomic); + flags = RpGeometryGetFlags(geo); + RpGeometrySetFlags(geo, flags | rpGEOMETRYMODULATEMATERIALCOLOR); + RpGeometryForAllMaterials(geo, SetAlphaCB, (void*)alpha); + AtomicDefaultRenderCallBack(atomic); + RpGeometryForAllMaterials(geo, SetAlphaCB, (void*)255); + RpGeometrySetFlags(geo, flags); + return atomic; +} + +RpAtomic* +CVisibilityPlugins::RenderFadingAtomic(RpAtomic *atomic, float camdist) +{ + RpAtomic *lodatm; + float fadefactor; + uint8 alpha; + CSimpleModelInfo *mi; + + mi = GetAtomicModelInfo(atomic); + lodatm = mi->GetAtomicFromDistance(camdist - FADE_DISTANCE); + if(mi->m_additive){ + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE); + AtomicDefaultRenderCallBack(atomic); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + }else{ + fadefactor = (mi->GetLargestLodDistance() - (camdist - FADE_DISTANCE))/FADE_DISTANCE; + if(fadefactor > 1.0f) + fadefactor = 1.0f; + alpha = mi->m_alpha * fadefactor; + if(alpha == 255) + AtomicDefaultRenderCallBack(atomic); + else{ + RpGeometry *geo = RpAtomicGetGeometry(lodatm); + uint32 flags = RpGeometryGetFlags(geo); + RpGeometrySetFlags(geo, flags | rpGEOMETRYMODULATEMATERIALCOLOR); + RpGeometryForAllMaterials(geo, SetAlphaCB, (void*)alpha); + if(geo != RpAtomicGetGeometry(atomic)) + RpAtomicSetGeometry(atomic, geo, rpATOMICSAMEBOUNDINGSPHERE); // originally 5 (mistake?) + AtomicDefaultRenderCallBack(atomic); + RpGeometryForAllMaterials(geo, SetAlphaCB, (void*)255); + RpGeometrySetFlags(geo, flags); + } + } + return atomic; +} + + + +RpAtomic* +CVisibilityPlugins::RenderVehicleHiDetailCB(RpAtomic *atomic) +{ + RwFrame *clumpframe; + float distsq, dot; + uint32 flags; + + clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); + distsq = GetDistanceSquaredFromCamera(clumpframe); + if(distsq < ms_vehicleLod0Dist){ + flags = GetAtomicId(atomic); + if(distsq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0){ + dot = GetDotProductWithCameraVector(RwFrameGetLTM(RpAtomicGetFrame(atomic)), + RwFrameGetLTM(clumpframe), flags); + if(dot > 0.0f && ((flags & ATOMIC_FLAG_ANGLECULL) || 0.1f*distsq < dot*dot)) + return atomic; + } + AtomicDefaultRenderCallBack(atomic); + } + return atomic; +} + +RpAtomic* +CVisibilityPlugins::RenderVehicleHiDetailAlphaCB(RpAtomic *atomic) +{ + RwFrame *clumpframe; + float distsq, dot; + uint32 flags; + + clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); + distsq = GetDistanceSquaredFromCamera(clumpframe); + if(distsq < ms_vehicleLod0Dist){ + flags = GetAtomicId(atomic); + dot = GetDotProductWithCameraVector(RwFrameGetLTM(RpAtomicGetFrame(atomic)), + RwFrameGetLTM(clumpframe), flags); + if(distsq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0) + if(dot > 0.0f && ((flags & ATOMIC_FLAG_ANGLECULL) || 0.1f*distsq < dot*dot)) + return atomic; + + if(flags & ATOMIC_FLAG_DRAWLAST){ + // sort before clump + if(!InsertAtomicIntoSortedList(atomic, distsq - 0.0001f)) + AtomicDefaultRenderCallBack(atomic); + }else{ + if(!InsertAtomicIntoSortedList(atomic, distsq + dot)) + AtomicDefaultRenderCallBack(atomic); + } + } + return atomic; +} + +RpAtomic* +CVisibilityPlugins::RenderVehicleHiDetailCB_BigVehicle(RpAtomic *atomic) +{ + RwFrame *clumpframe; + float distsq, dot; + uint32 flags; + + clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); + distsq = GetDistanceSquaredFromCamera(clumpframe); + if(distsq < ms_bigVehicleLod0Dist){ + flags = GetAtomicId(atomic); + if(distsq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0){ + dot = GetDotProductWithCameraVector(RwFrameGetLTM(RpAtomicGetFrame(atomic)), + RwFrameGetLTM(clumpframe), flags); + if(dot > 0.0f) + return atomic; + } + AtomicDefaultRenderCallBack(atomic); + } + return atomic; +} + +RpAtomic* +CVisibilityPlugins::RenderVehicleHiDetailAlphaCB_BigVehicle(RpAtomic *atomic) +{ + RwFrame *clumpframe; + float distsq, dot; + uint32 flags; + + clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); + distsq = GetDistanceSquaredFromCamera(clumpframe); + if(distsq < ms_bigVehicleLod0Dist){ + flags = GetAtomicId(atomic); + dot = GetDotProductWithCameraVector(RwFrameGetLTM(RpAtomicGetFrame(atomic)), + RwFrameGetLTM(clumpframe), flags); + if(dot > 0.0f) + if(distsq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0) + return atomic; + + if(!InsertAtomicIntoSortedList(atomic, distsq + dot)) + AtomicDefaultRenderCallBack(atomic); + } + return atomic; +} + +RpAtomic* +CVisibilityPlugins::RenderVehicleHiDetailCB_Boat(RpAtomic *atomic) +{ + RwFrame *clumpframe; + float distsq; + + clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); + distsq = GetDistanceSquaredFromCamera(clumpframe); + if(distsq < ms_bigVehicleLod1Dist) + AtomicDefaultRenderCallBack(atomic); + return atomic; +} + +RpAtomic* +CVisibilityPlugins::RenderVehicleLowDetailCB_BigVehicle(RpAtomic *atomic) +{ + RwFrame *clumpframe; + float distsq, dot; + uint32 flags; + + clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); + distsq = GetDistanceSquaredFromCamera(clumpframe); + if(distsq >= ms_bigVehicleLod0Dist && + distsq < ms_bigVehicleLod1Dist){ + flags = GetAtomicId(atomic); + if(distsq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0){ + dot = GetDotProductWithCameraVector(RwFrameGetLTM(RpAtomicGetFrame(atomic)), + RwFrameGetLTM(clumpframe), flags); + if(dot > 0.0f) + return atomic; + } + AtomicDefaultRenderCallBack(atomic); + } + return atomic; +} + +RpAtomic* +CVisibilityPlugins::RenderVehicleLowDetailAlphaCB_BigVehicle(RpAtomic *atomic) +{ + RwFrame *clumpframe; + float distsq, dot; + uint32 flags; + + clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); + distsq = GetDistanceSquaredFromCamera(clumpframe); + if(distsq >= ms_bigVehicleLod0Dist && + distsq < ms_bigVehicleLod1Dist){ + flags = GetAtomicId(atomic); + dot = GetDotProductWithCameraVector(RwFrameGetLTM(RpAtomicGetFrame(atomic)), + RwFrameGetLTM(clumpframe), flags); + if(dot > 0.0f) + if(distsq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0) + return atomic; + + if(!InsertAtomicIntoSortedList(atomic, distsq + dot)) + AtomicDefaultRenderCallBack(atomic); + } + return atomic; +} + +RpAtomic* +CVisibilityPlugins::RenderVehicleReallyLowDetailCB(RpAtomic *atomic) +{ + RpClump *clump; + float dist; + int32 alpha; + + clump = RpAtomicGetClump(atomic); + dist = GetDistanceSquaredFromCamera(RpClumpGetFrame(clump)); + if(dist >= ms_vehicleLod0Dist){ + alpha = GetClumpAlpha(clump); + if(alpha == 255) + AtomicDefaultRenderCallBack(atomic); + else + RenderAlphaAtomic(atomic, alpha); + } + return atomic; + +} + +RpAtomic* +CVisibilityPlugins::RenderVehicleReallyLowDetailCB_BigVehicle(RpAtomic *atomic) +{ + RwFrame *clumpframe; + float distsq; + + clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); + distsq = GetDistanceSquaredFromCamera(clumpframe); + if(distsq >= ms_bigVehicleLod1Dist) + AtomicDefaultRenderCallBack(atomic); + return atomic; +} + +RpAtomic* +CVisibilityPlugins::RenderTrainHiDetailCB(RpAtomic *atomic) +{ + RwFrame *clumpframe; + float distsq, dot; + uint32 flags; + + clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); + distsq = GetDistanceSquaredFromCamera(clumpframe); + if(distsq < ms_bigVehicleLod1Dist){ + flags = GetAtomicId(atomic); + if(distsq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0){ + dot = GetDotProductWithCameraVector(RwFrameGetLTM(RpAtomicGetFrame(atomic)), + RwFrameGetLTM(clumpframe), flags); + if(dot > 0.0f && ((flags & ATOMIC_FLAG_ANGLECULL) || 0.1f*distsq < dot*dot)) + return atomic; + } + AtomicDefaultRenderCallBack(atomic); + } + return atomic; +} + +RpAtomic* +CVisibilityPlugins::RenderTrainHiDetailAlphaCB(RpAtomic *atomic) +{ + RwFrame *clumpframe; + float distsq, dot; + uint32 flags; + + clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); + distsq = GetDistanceSquaredFromCamera(clumpframe); + if(distsq < ms_bigVehicleLod1Dist){ + flags = GetAtomicId(atomic); + dot = GetDotProductWithCameraVector(RwFrameGetLTM(RpAtomicGetFrame(atomic)), + RwFrameGetLTM(clumpframe), flags); + if(distsq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0) + if(dot > 0.0f && ((flags & ATOMIC_FLAG_ANGLECULL) || 0.1f*distsq < dot*dot)) + return atomic; + + if(flags & ATOMIC_FLAG_DRAWLAST){ + // sort before clump + if(!InsertAtomicIntoSortedList(atomic, distsq - 0.0001f)) + AtomicDefaultRenderCallBack(atomic); + }else{ + if(!InsertAtomicIntoSortedList(atomic, distsq + dot)) + AtomicDefaultRenderCallBack(atomic); + } + } + return atomic; +} + +RpAtomic* +CVisibilityPlugins::RenderPlayerCB(RpAtomic *atomic) +{ + if(CWorld::Players[0].m_pSkinTexture) + RpGeometryForAllMaterials(RpAtomicGetGeometry(atomic), SetTextureCB, CWorld::Players[0].m_pSkinTexture); + AtomicDefaultRenderCallBack(atomic); + return atomic; +} + +RpAtomic* +CVisibilityPlugins::RenderPedLowDetailCB(RpAtomic *atomic) +{ + RpClump *clump; + float dist; + int32 alpha; + + clump = RpAtomicGetClump(atomic); + dist = GetDistanceSquaredFromCamera(RpClumpGetFrame(clump)); + if(dist >= ms_pedLod0Dist){ + alpha = GetClumpAlpha(clump); + if(alpha == 255) + AtomicDefaultRenderCallBack(atomic); + else + RenderAlphaAtomic(atomic, alpha); + } + return atomic; +} + +RpAtomic* +CVisibilityPlugins::RenderPedHiDetailCB(RpAtomic *atomic) +{ + RpClump *clump; + float dist; + int32 alpha; + + clump = RpAtomicGetClump(atomic); + dist = GetDistanceSquaredFromCamera(RpClumpGetFrame(clump)); + if(dist < ms_pedLod0Dist){ + alpha = GetClumpAlpha(clump); + if(alpha == 255) + AtomicDefaultRenderCallBack(atomic); + else + RenderAlphaAtomic(atomic, alpha); + } + return atomic; +} + +float +CVisibilityPlugins::GetDistanceSquaredFromCamera(RwFrame *frame) +{ + RwMatrix *m; + RwV3d dist; + m = RwFrameGetLTM(frame); + RwV3dSub(&dist, RwMatrixGetPos(m), ms_pCameraPosn); + return RwV3dDotProduct(&dist, &dist); +} + +float +CVisibilityPlugins::GetDotProductWithCameraVector(RwMatrix *atomicMat, RwMatrix *clumpMat, uint32 flags) +{ + RwV3d dist; + float dot, dotdoor; + + // Vehicle forward is the y axis (RwMatrix.up) + // Vehicle right is the x axis (RwMatrix.right) + + RwV3dSub(&dist, RwMatrixGetPos(atomicMat), ms_pCameraPosn); + // forward/backward facing + if(flags & (ATOMIC_FLAG_FRONT | ATOMIC_FLAG_REAR)) + dot = RwV3dDotProduct(&dist, RwMatrixGetUp(clumpMat)); + // left/right facing + else if(flags & (ATOMIC_FLAG_LEFT | ATOMIC_FLAG_RIGHT)) + dot = RwV3dDotProduct(&dist, RwMatrixGetRight(clumpMat)); + else + dot = 0.0f; + if(flags & (ATOMIC_FLAG_LEFT | ATOMIC_FLAG_REAR)) + dot = -dot; + + if(flags & (ATOMIC_FLAG_REARDOOR | ATOMIC_FLAG_FRONTDOOR)){ + if(flags & ATOMIC_FLAG_REARDOOR) + dotdoor = -RwV3dDotProduct(&dist, RwMatrixGetUp(clumpMat)); + else if(flags & ATOMIC_FLAG_FRONTDOOR) + dotdoor = RwV3dDotProduct(&dist, RwMatrixGetUp(clumpMat)); + else + dotdoor = 0.0f; + + if(dot < 0.0f && dotdoor < 0.0f) + dot += dotdoor; + if(dot > 0.0f && dotdoor > 0.0f) + dot += dotdoor; + } + + return dot; +} + +/* These are all unused */ + +bool +CVisibilityPlugins::DefaultVisibilityCB(RpClump *clump) +{ + return true; +} + +bool +CVisibilityPlugins::FrustumSphereCB(RpClump *clump) +{ + RwSphere sphere; + RwFrame *frame = RpClumpGetFrame(clump); + + CClumpModelInfo *modelInfo = (CClumpModelInfo*)GetFrameHierarchyId(frame); + sphere.radius = modelInfo->GetColModel()->boundingSphere.radius; + sphere.center.x = modelInfo->GetColModel()->boundingSphere.center.x; + sphere.center.y = modelInfo->GetColModel()->boundingSphere.center.y; + sphere.center.z = modelInfo->GetColModel()->boundingSphere.center.z; + RwV3dTransformPoints(&sphere.center, &sphere.center, 1, RwFrameGetLTM(frame)); + return RwCameraFrustumTestSphere(ms_pCamera, &sphere) != rwSPHEREOUTSIDE; +} + +bool +CVisibilityPlugins::VehicleVisibilityCB(RpClump *clump) +{ + if (GetDistanceSquaredFromCamera(RpClumpGetFrame(clump)) <= ms_vehicleLod1Dist) + return FrustumSphereCB(clump); + return false; +} + +bool +CVisibilityPlugins::VehicleVisibilityCB_BigVehicle(RpClump *clump) +{ + return FrustumSphereCB(clump); +} + + + + +// +// RW Plugins +// + +enum +{ + ID_VISIBILITYATOMIC = MAKECHUNKID(rwVENDORID_ROCKSTAR, 0x00), + ID_VISIBILITYCLUMP = MAKECHUNKID(rwVENDORID_ROCKSTAR, 0x01), + ID_VISIBILITYFRAME = MAKECHUNKID(rwVENDORID_ROCKSTAR, 0x02), +}; + +bool +CVisibilityPlugins::PluginAttach(void) +{ + ms_atomicPluginOffset = RpAtomicRegisterPlugin(sizeof(AtomicExt), + ID_VISIBILITYATOMIC, + AtomicConstructor, AtomicDestructor, AtomicCopyConstructor); + + ms_framePluginOffset = RwFrameRegisterPlugin(sizeof(FrameExt), + ID_VISIBILITYFRAME, + FrameConstructor, FrameDestructor, FrameCopyConstructor); + + ms_clumpPluginOffset = RpClumpRegisterPlugin(sizeof(ClumpExt), + ID_VISIBILITYCLUMP, + ClumpConstructor, ClumpDestructor, ClumpCopyConstructor); + return ms_atomicPluginOffset != -1 && ms_clumpPluginOffset != -1; +} + +#define ATOMICEXT(o) (RWPLUGINOFFSET(AtomicExt, o, ms_atomicPluginOffset)) +#define FRAMEEXT(o) (RWPLUGINOFFSET(FrameExt, o, ms_framePluginOffset)) +#define CLUMPEXT(o) (RWPLUGINOFFSET(ClumpExt, o, ms_clumpPluginOffset)) + +// +// Atomic +// + +void* +CVisibilityPlugins::AtomicConstructor(void *object, int32, int32) +{ + ATOMICEXT(object)->modelInfo = nil; + return object; +} + +void* +CVisibilityPlugins::AtomicDestructor(void *object, int32, int32) +{ + return object; +} + +void* +CVisibilityPlugins::AtomicCopyConstructor(void *dst, const void *src, int32, int32) +{ + *ATOMICEXT(dst) = *ATOMICEXT(src); + return dst; +} + +void +CVisibilityPlugins::SetAtomicModelInfo(RpAtomic *atomic, + CSimpleModelInfo *modelInfo) +{ + AtomicExt *ext = ATOMICEXT(atomic); + ext->modelInfo = modelInfo; + switch(modelInfo->m_type) + case MITYPE_SIMPLE: + case MITYPE_TIME: + if(modelInfo->m_normalCull) + SetAtomicRenderCallback(atomic, RenderObjNormalAtomic); +} + +CSimpleModelInfo* +CVisibilityPlugins::GetAtomicModelInfo(RpAtomic *atomic) +{ + return ATOMICEXT(atomic)->modelInfo; +} + +void +CVisibilityPlugins::SetAtomicFlag(RpAtomic *atomic, int f) +{ + ATOMICEXT(atomic)->flags |= f; +} + +void +CVisibilityPlugins::ClearAtomicFlag(RpAtomic *atomic, int f) +{ + ATOMICEXT(atomic)->flags &= ~f; +} + +int +CVisibilityPlugins::GetAtomicId(RpAtomic *atomic) +{ + return ATOMICEXT(atomic)->flags; +} + +// This is rather useless, but whatever +void +CVisibilityPlugins::SetAtomicRenderCallback(RpAtomic *atomic, RpAtomicCallBackRender cb) +{ + if(cb == nil) + cb = AtomicDefaultRenderCallBack; // not necessary + RpAtomicSetRenderCallBack(atomic, cb); +} + +// +// Frame +// + +void* +CVisibilityPlugins::FrameConstructor(void *object, int32, int32) +{ + FRAMEEXT(object)->id = 0; + return object; +} + +void* +CVisibilityPlugins::FrameDestructor(void *object, int32, int32) +{ + return object; +} + +void* +CVisibilityPlugins::FrameCopyConstructor(void *dst, const void *src, int32, int32) +{ + *FRAMEEXT(dst) = *FRAMEEXT(src); + return dst; +} + +void +CVisibilityPlugins::SetFrameHierarchyId(RwFrame *frame, int32 id) +{ + FRAMEEXT(frame)->id = id; +} + +int32 +CVisibilityPlugins::GetFrameHierarchyId(RwFrame *frame) +{ + return FRAMEEXT(frame)->id; +} + + +// +// Clump +// + +void* +CVisibilityPlugins::ClumpConstructor(void *object, int32, int32) +{ + ClumpExt *ext = CLUMPEXT(object); + ext->visibilityCB = DefaultVisibilityCB; + ext->alpha = 0xFF; + return object; +} + +void* +CVisibilityPlugins::ClumpDestructor(void *object, int32, int32) +{ + return object; +} + +void* +CVisibilityPlugins::ClumpCopyConstructor(void *dst, const void *src, int32, int32) +{ + CLUMPEXT(dst)->visibilityCB = CLUMPEXT(src)->visibilityCB; + return dst; +} + +void +CVisibilityPlugins::SetClumpModelInfo(RpClump *clump, CClumpModelInfo *modelInfo) +{ + CVehicleModelInfo *vmi; + SetFrameHierarchyId(RpClumpGetFrame(clump), (int32)modelInfo); + + // Unused + switch(modelInfo->m_type){ + // ignore MLO + case MITYPE_VEHICLE: + vmi = (CVehicleModelInfo*)modelInfo; + if(vmi->m_vehicleType == VEHICLE_TYPE_TRAIN || + vmi->m_vehicleType == VEHICLE_TYPE_HELI || + vmi->m_vehicleType == VEHICLE_TYPE_PLANE) + CLUMPEXT(clump)->visibilityCB = VehicleVisibilityCB_BigVehicle; + else + CLUMPEXT(clump)->visibilityCB = VehicleVisibilityCB; + break; + } +} + +void +CVisibilityPlugins::SetClumpAlpha(RpClump *clump, int alpha) +{ + CLUMPEXT(clump)->alpha = alpha; +} + +int +CVisibilityPlugins::GetClumpAlpha(RpClump *clump) +{ + return CLUMPEXT(clump)->alpha; +} + + +STARTPATCHES + InjectHook(0x527E50, CVisibilityPlugins::Initialise, PATCH_JUMP); + InjectHook(0x527EA0, CVisibilityPlugins::Shutdown, PATCH_JUMP); + InjectHook(0x528F90, CVisibilityPlugins::InitAlphaEntityList, PATCH_JUMP); + InjectHook(0x528FF0, CVisibilityPlugins::InsertEntityIntoSortedList, PATCH_JUMP); + InjectHook(0x528F80, CVisibilityPlugins::InitAlphaAtomicList, PATCH_JUMP); + InjectHook(0x528FA0, CVisibilityPlugins::InsertAtomicIntoSortedList, PATCH_JUMP); + InjectHook(0x528C50, CVisibilityPlugins::SetRenderWareCamera, PATCH_JUMP); + + InjectHook(0x527F60, SetAlphaCB, PATCH_JUMP); + InjectHook(0x529040, CVisibilityPlugins::RenderAlphaAtomics, PATCH_JUMP); + InjectHook(0x529070, CVisibilityPlugins::RenderFadingEntities, PATCH_JUMP); + + InjectHook(0x527F70, CVisibilityPlugins::RenderWheelAtomicCB, PATCH_JUMP); + InjectHook(0x528000, CVisibilityPlugins::RenderObjNormalAtomic, PATCH_JUMP); + InjectHook(0x5280B0, CVisibilityPlugins::RenderAlphaAtomic, PATCH_JUMP); + InjectHook(0x528100, CVisibilityPlugins::RenderFadingAtomic, PATCH_JUMP); + + InjectHook(0x5283E0, CVisibilityPlugins::RenderVehicleHiDetailCB, PATCH_JUMP); + InjectHook(0x5284B0, CVisibilityPlugins::RenderVehicleHiDetailAlphaCB, PATCH_JUMP); + InjectHook(0x5288A0, CVisibilityPlugins::RenderVehicleHiDetailCB_BigVehicle, PATCH_JUMP); + InjectHook(0x528A10, CVisibilityPlugins::RenderVehicleHiDetailAlphaCB_BigVehicle, PATCH_JUMP); + InjectHook(0x528AD0, CVisibilityPlugins::RenderVehicleHiDetailCB_Boat, PATCH_JUMP); + InjectHook(0x5287F0, CVisibilityPlugins::RenderVehicleLowDetailCB_BigVehicle, PATCH_JUMP); + InjectHook(0x528940, CVisibilityPlugins::RenderVehicleLowDetailAlphaCB_BigVehicle, PATCH_JUMP); + InjectHook(0x528240, CVisibilityPlugins::RenderVehicleReallyLowDetailCB, PATCH_JUMP); + InjectHook(0x5287B0, CVisibilityPlugins::RenderVehicleReallyLowDetailCB_BigVehicle, PATCH_JUMP); + InjectHook(0x5285D0, CVisibilityPlugins::RenderTrainHiDetailCB, PATCH_JUMP); + InjectHook(0x5286A0, CVisibilityPlugins::RenderTrainHiDetailAlphaCB, PATCH_JUMP); + + InjectHook(0x528BC0, CVisibilityPlugins::RenderPedHiDetailCB, PATCH_JUMP); + InjectHook(0x528B60, CVisibilityPlugins::RenderPedLowDetailCB, PATCH_JUMP); + + + InjectHook(0x527DC0, CVisibilityPlugins::PluginAttach, PATCH_JUMP); + + InjectHook(0x527EC0, CVisibilityPlugins::SetAtomicModelInfo, PATCH_JUMP); + InjectHook(0x527F00, CVisibilityPlugins::GetAtomicModelInfo, PATCH_JUMP); + InjectHook(0x527F10, CVisibilityPlugins::SetAtomicFlag, PATCH_JUMP); + InjectHook(0x527F30, CVisibilityPlugins::ClearAtomicFlag, PATCH_JUMP); + InjectHook(0x527F50, CVisibilityPlugins::GetAtomicId, PATCH_JUMP); + InjectHook(0x528C20, CVisibilityPlugins::SetAtomicRenderCallback, PATCH_JUMP); + + InjectHook(0x528D60, CVisibilityPlugins::SetFrameHierarchyId, PATCH_JUMP); + InjectHook(0x528D80, CVisibilityPlugins::GetFrameHierarchyId, PATCH_JUMP); + + InjectHook(0x528ED0, CVisibilityPlugins::SetClumpModelInfo, PATCH_JUMP); + InjectHook(0x528F50, CVisibilityPlugins::SetClumpAlpha, PATCH_JUMP); + InjectHook(0x528F70, CVisibilityPlugins::GetClumpAlpha, PATCH_JUMP); + + + InjectHook(0x529120, CVisibilityPlugins::GetDistanceSquaredFromCamera, PATCH_JUMP); + InjectHook(0x5282A0, CVisibilityPlugins::GetDotProductWithCameraVector, PATCH_JUMP); +ENDPATCHES diff --git a/src/rw/VisibilityPlugins.h b/src/rw/VisibilityPlugins.h new file mode 100644 index 00000000..65d2675a --- /dev/null +++ b/src/rw/VisibilityPlugins.h @@ -0,0 +1,133 @@ +#pragma once + +#include "templates.h" + +class CEntity; +class CSimpleModelInfo; +class CClumpModelInfo; + +typedef bool (*ClumpVisibilityCB)(RpClump*); + +class CVisibilityPlugins +{ +public: + struct AlphaObjectInfo + { + union { + CEntity *entity; + RpAtomic *atomic; + }; + float sort; + }; + + static CLinkList &m_alphaList; + static CLinkList &m_alphaEntityList; + static RwCamera *&ms_pCamera; + static RwV3d *&ms_pCameraPosn; + static float &ms_cullCompsDist; + static float &ms_vehicleLod0Dist; + static float &ms_vehicleLod1Dist; + static float &ms_vehicleFadeDist; + static float &ms_bigVehicleLod0Dist; + static float &ms_bigVehicleLod1Dist; + static float &ms_pedLod0Dist; + static float &ms_pedLod1Dist; + static float &ms_pedFadeDist; + + static void Initialise(void); + static void Shutdown(void); + static void InitAlphaEntityList(void); + static bool InsertEntityIntoSortedList(CEntity *e, float dist); + static void InitAlphaAtomicList(void); + static bool InsertAtomicIntoSortedList(RpAtomic *a, float dist); + + static void SetRenderWareCamera(RwCamera *camera); + + static RpAtomic *RenderWheelAtomicCB(RpAtomic *atomic); + static RpAtomic *RenderObjNormalAtomic(RpAtomic *atomic); + static RpAtomic *RenderAlphaAtomic(RpAtomic *atomic, int alpha); + static RpAtomic *RenderFadingAtomic(RpAtomic *atm, float dist); + + static RpAtomic *RenderVehicleHiDetailCB(RpAtomic *atomic); + static RpAtomic *RenderVehicleHiDetailAlphaCB(RpAtomic *atomic); + static RpAtomic *RenderVehicleHiDetailCB_BigVehicle(RpAtomic *atomic); + static RpAtomic *RenderVehicleHiDetailAlphaCB_BigVehicle(RpAtomic *atomic); + static RpAtomic *RenderVehicleHiDetailCB_Boat(RpAtomic *atomic); + static RpAtomic *RenderVehicleLowDetailCB_BigVehicle(RpAtomic *atomic); + static RpAtomic *RenderVehicleLowDetailAlphaCB_BigVehicle(RpAtomic *atomic); + static RpAtomic *RenderVehicleReallyLowDetailCB(RpAtomic *atomic); + static RpAtomic *RenderVehicleReallyLowDetailCB_BigVehicle(RpAtomic *atomic); + static RpAtomic *RenderTrainHiDetailCB(RpAtomic *atomic); + static RpAtomic *RenderTrainHiDetailAlphaCB(RpAtomic *atomic); + + static RpAtomic *RenderPlayerCB(RpAtomic *atomic); + static RpAtomic *RenderPedLowDetailCB(RpAtomic *atomic); + static RpAtomic *RenderPedHiDetailCB(RpAtomic *atomic); + + static void RenderAlphaAtomics(void); + static void RenderFadingEntities(void); + + // All actually unused + static bool DefaultVisibilityCB(RpClump *clump); + static bool FrustumSphereCB(RpClump *clump); +// static bool MloVisibilityCB(RpClump *clump); + static bool VehicleVisibilityCB(RpClump *clump); + static bool VehicleVisibilityCB_BigVehicle(RpClump *clump); + + static float GetDistanceSquaredFromCamera(RwFrame *frame); + static float GetDotProductWithCameraVector(RwMatrix *atomicMat, RwMatrix *clumpMat, uint32 flags); + + // + // RW Plugins + // + + union AtomicExt + { + CSimpleModelInfo *modelInfo; // used by SimpleModelInfo + int flags; // used by ClumpModelInfo + }; + static void SetAtomicModelInfo(RpAtomic*, CSimpleModelInfo*); + static CSimpleModelInfo *GetAtomicModelInfo(RpAtomic *atomic); + static void SetAtomicFlag(RpAtomic*, int); + static void ClearAtomicFlag(RpAtomic*, int); + static int GetAtomicId(RpAtomic *atomic); + static void SetAtomicRenderCallback(RpAtomic*, RpAtomicCallBackRender); + + static void *AtomicConstructor(void *object, int32 offset, int32 len); + static void *AtomicDestructor(void *object, int32 offset, int32 len); + static void *AtomicCopyConstructor(void *dst, const void *src, + int32 offset, int32 len); + static int32 &ms_atomicPluginOffset; + + struct FrameExt + { + // BUG: this is abused to hold a pointer by SetClumpModelInfo + int32 id; + }; + static void SetFrameHierarchyId(RwFrame *frame, int32 id); + static int32 GetFrameHierarchyId(RwFrame *frame); + + static void *FrameConstructor(void *object, int32 offset, int32 len); + static void *FrameDestructor(void *object, int32 offset, int32 len); + static void *FrameCopyConstructor(void *dst, const void *src, + int32 offset, int32 len); + static int32 &ms_framePluginOffset; + + // Not actually used + struct ClumpExt + { + ClumpVisibilityCB visibilityCB; + int alpha; + }; + static void SetClumpModelInfo(RpClump*, CClumpModelInfo*); + static void SetClumpAlpha(RpClump*, int); + static int GetClumpAlpha(RpClump*); + + static void *ClumpConstructor(void *object, int32 offset, int32 len); + static void *ClumpDestructor(void *object, int32 offset, int32 len); + static void *ClumpCopyConstructor(void *dst, const void *src, + int32 offset, int32 len); + static int32 &ms_clumpPluginOffset; + + static bool PluginAttach(void); +}; diff --git a/src/rw/rw.cpp b/src/rw/rw.cpp new file mode 100644 index 00000000..3875f2a1 --- /dev/null +++ b/src/rw/rw.cpp @@ -0,0 +1,839 @@ +#include "common.h" +#include "patcher.h" +#include "rwcore.h" +#include "rpworld.h" +#include "rpmatfx.h" +#include "rpskin.h" +#include "rphanim.h" +#include "rtbmp.h" + +typedef RwV3d *(*rwVectorsMultFn) (RwV3d * pointsOut, + const RwV3d * pointsIn, + RwInt32 numPoints, + const RwMatrix * matrix); + +#ifndef RWLIBS + +WRAPPER void _rwObjectHasFrameSetFrame(void* object, RwFrame* frame) { EAXJMP(0x5BC950); } +WRAPPER RpAtomic* AtomicDefaultRenderCallBack(RpAtomic* atomic) { EAXJMP(0x59E690); } +WRAPPER void _rpAtomicResyncInterpolatedSphere(RpAtomic* atomic) { EAXJMP(0x59E6C0); } +WRAPPER RwSphere const* RpAtomicGetWorldBoundingSphere(RpAtomic* atomic) { EAXJMP(0x59E800); } +WRAPPER RwInt32 RpClumpGetNumAtomics(RpClump* clump) { EAXJMP(0x59ED50); } +WRAPPER RpClump* RpClumpRender(RpClump* clump) { EAXJMP(0x59ED80); } +WRAPPER RpClump* RpClumpForAllAtomics(RpClump* clump, RpAtomicCallBack callback, void* pData) { EAXJMP(0x59EDD0); } +WRAPPER RpClump* RpClumpForAllCameras(RpClump* clump, RwCameraCallBack callback, void* pData) { EAXJMP(0x59EE10); } +WRAPPER RpClump* RpClumpForAllLights(RpClump* clump, RpLightCallBack callback, void* pData) { EAXJMP(0x59EE60); } +WRAPPER RpAtomic* RpAtomicCreate() { EAXJMP(0x59EEB0); } +WRAPPER RpAtomic* RpAtomicSetGeometry(RpAtomic* atomic, RpGeometry* geometry, RwUInt32 flags) { EAXJMP(0x59EFA0); } +WRAPPER RwBool RpAtomicDestroy(RpAtomic* atomic) { EAXJMP(0x59F020); } +WRAPPER RpAtomic* RpAtomicClone(RpAtomic* atomic) { EAXJMP(0x59F0A0); } +WRAPPER RpClump* RpClumpClone(RpClump* clump) { EAXJMP(0x59F1B0); } +WRAPPER RpClump* RpClumpCreate() { EAXJMP(0x59F490); } +WRAPPER RwBool RpClumpDestroy(RpClump* clump) { EAXJMP(0x59F500); } +WRAPPER RpClump* RpClumpAddAtomic(RpClump* clump, RpAtomic* atomic) { EAXJMP(0x59F680); } +WRAPPER RpClump* RpClumpRemoveAtomic(RpClump* clump, RpAtomic* atomic) { EAXJMP(0x59F6B0); } +WRAPPER RpClump* RpClumpRemoveLight(RpClump* clump, RpLight* light) { EAXJMP(0x59F6E0); } +WRAPPER RpClump* RpClumpStreamRead(RwStream* stream) { EAXJMP(0x59FC50); } +WRAPPER RwInt32 RpAtomicRegisterPlugin(RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor ructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB) { EAXJMP(0x5A0510); } +WRAPPER RwInt32 RpClumpRegisterPlugin(RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor ructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB) { EAXJMP(0x5A0540); } +WRAPPER RwInt32 RpAtomicRegisterPluginStream(RwUInt32 pluginID, RwPluginDataChunkReadCallBack readCB, RwPluginDataChunkWriteCallBack writeCB, RwPluginDataChunkGetSizeCallBack getSizeCB) { EAXJMP(0x5A0570); } +WRAPPER RwInt32 RpAtomicSetStreamAlwaysCallBack(RwUInt32 pluginID, RwPluginDataChunkAlwaysCallBack alwaysCB) { EAXJMP(0x5A05A0); } +WRAPPER RwInt32 RpAtomicSetStreamRightsCallBack(RwUInt32 pluginID, RwPluginDataChunkRightsCallBack rightsCB) { EAXJMP(0x5A05C0); } +WRAPPER RwInt32 RpAtomicGetPluginOffset(RwUInt32 pluginID) { EAXJMP(0x5A05E0); } +WRAPPER RpAtomic* RpAtomicSetFrame(RpAtomic* atomic, RwFrame* frame) { EAXJMP(0x5A0600); } +WRAPPER RwInt32 RwEngineRegisterPlugin(RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor initCB, RwPluginObjectDestructor termCB) { EAXJMP(0x5A0DC0); } +WRAPPER RwInt32 RwEngineGetPluginOffset(RwUInt32 pluginID) { EAXJMP(0x5A0DF0); } +WRAPPER RwInt32 RwEngineGetNumSubSystems() { EAXJMP(0x5A0E10); } +WRAPPER RwSubSystemInfo* RwEngineGetSubSystemInfo(RwSubSystemInfo* subSystemInfo, RwInt32 subSystemIndex) { EAXJMP(0x5A0E40); } +WRAPPER RwInt32 RwEngineGetCurrentSubSystem() { EAXJMP(0x5A0E70); } +WRAPPER RwBool RwEngineSetSubSystem(RwInt32 subSystemIndex) { EAXJMP(0x5A0EA0); } +WRAPPER RwInt32 RwEngineGetNumVideoModes() { EAXJMP(0x5A0ED0); } +WRAPPER RwVideoMode* RwEngineGetVideoModeInfo(RwVideoMode* modeinfo, RwInt32 modeIndex) { EAXJMP(0x5A0F00); } +WRAPPER RwInt32 RwEngineGetCurrentVideoMode() { EAXJMP(0x5A0F30); } +WRAPPER RwBool RwEngineSetVideoMode(RwInt32 modeIndex) { EAXJMP(0x5A0F60); } +WRAPPER RwBool RwEngineStop() { EAXJMP(0x5A0F90); } +WRAPPER RwBool RwEngineStart() { EAXJMP(0x5A0FE0); } +WRAPPER RwBool RwEngineClose() { EAXJMP(0x5A1070); } +WRAPPER RwBool RwEngineOpen(RwEngineOpenParams* initParams) { EAXJMP(0x5A10E0); } +WRAPPER RwBool RwEngineTerm() { EAXJMP(0x5A1290); } +WRAPPER RwBool RwEngineInit(RwMemoryFunctions* memFuncs, RwUInt32 initFlags, RwUInt32 resArenaSize) { EAXJMP(0x5A12D0); } +WRAPPER void* _rwFrameOpen(void* instance, RwInt32 offset, RwInt32 size) { EAXJMP(0x5A15E0); } +WRAPPER void* _rwFrameClose(void* instance, RwInt32 offset, RwInt32 size) { EAXJMP(0x5A1650); } +WRAPPER RwFrame* _rwFrameCloneAndLinkClones(RwFrame* root) { EAXJMP(0x5A1690); } +WRAPPER RwFrame* _rwFramePurgeClone(RwFrame* root) { EAXJMP(0x5A1880); } +WRAPPER RwBool RwFrameDirty(RwFrame const* frame) { EAXJMP(0x5A1930); } +WRAPPER void _rwFrameInit(RwFrame* frame) { EAXJMP(0x5A1950); } +WRAPPER RwFrame* RwFrameCreate() { EAXJMP(0x5A1A00); } +WRAPPER RwBool RwFrameDestroy(RwFrame* frame) { EAXJMP(0x5A1A30); } +WRAPPER RwBool RwFrameDestroyHierarchy(RwFrame* frame) { EAXJMP(0x5A1BF0); } +WRAPPER RwFrame* RwFrameUpdateObjects(RwFrame* frame) { EAXJMP(0x5A1C60); } +WRAPPER RwMatrix* RwFrameGetLTM(RwFrame* frame) { EAXJMP(0x5A1CE0); } +WRAPPER RwFrame* RwFrameAddChild(RwFrame* parent, RwFrame* child) { EAXJMP(0x5A1D00); } +WRAPPER RwFrame* RwFrameRemoveChild(RwFrame* child) { EAXJMP(0x5A1ED0); } +WRAPPER RwFrame* RwFrameForAllChildren(RwFrame* frame, RwFrameCallBack callBack, void* data) { EAXJMP(0x5A1FC0); } +WRAPPER RwFrame* RwFrameTranslate(RwFrame* frame, RwV3d const* v, RwOpCombineType combine) { EAXJMP(0x5A2000); } +WRAPPER RwFrame* RwFrameScale(RwFrame* frame, RwV3d const* v, RwOpCombineType combine) { EAXJMP(0x5A20A0); } +WRAPPER RwFrame* RwFrameTransform(RwFrame* frame, RwMatrix const* m, RwOpCombineType combine) { EAXJMP(0x5A2140); } +WRAPPER RwFrame* RwFrameRotate(RwFrame* frame, RwV3d const* axis, RwReal angle, RwOpCombineType combine) { EAXJMP(0x5A21E0); } +WRAPPER RwFrame* RwFrameSetIdentity(RwFrame* frame) { EAXJMP(0x5A2280); } +WRAPPER RwFrame* RwFrameForAllObjects(RwFrame* frame, RwObjectCallBack callBack, void* data) { EAXJMP(0x5A2340); } +WRAPPER RwInt32 RwFrameRegisterPlugin(RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor ructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB) { EAXJMP(0x5A2380); } +WRAPPER RwBool _rwMatrixSetMultFn(rwMatrixMultFn multMat) { EAXJMP(0x5A23B0); } +WRAPPER RwReal _rwMatrixDeterminant(RwMatrix const* matrix) { EAXJMP(0x5A2520); } +WRAPPER RwReal _rwMatrixOrthogonalError(RwMatrix const* matrix) { EAXJMP(0x5A2570); } +WRAPPER RwReal _rwMatrixNormalError(RwMatrix const* matrix) { EAXJMP(0x5A25D0); } +WRAPPER RwReal _rwMatrixIdentityError(RwMatrix const* matrix) { EAXJMP(0x5A2660); } +WRAPPER void* _rwMatrixClose(void* instance, RwInt32 offset, RwInt32 size) { EAXJMP(0x5A2730); } +WRAPPER void* _rwMatrixOpen(void* instance, RwInt32 offset, RwInt32 size) { EAXJMP(0x5A2770); } +WRAPPER RwMatrix* RwMatrixOptimize(RwMatrix* matrix, RwMatrixTolerance const* tolerance) { EAXJMP(0x5A2820); } +WRAPPER RwMatrix* RwMatrixUpdate(RwMatrix* matrix) { EAXJMP(0x5A28E0); } +WRAPPER RwMatrix* RwMatrixMultiply(RwMatrix* matrixOut, RwMatrix const* MatrixIn1, RwMatrix const* matrixIn2) { EAXJMP(0x5A28F0); } +WRAPPER RwMatrix* RwMatrixRotateOneMinusCosineSine(RwMatrix* matrix, RwV3d const* unitAxis, RwReal oneMinusCosine, RwReal sine, RwOpCombineType combineOp) { EAXJMP(0x5A2960); } +WRAPPER RwMatrix* RwMatrixRotate(RwMatrix* matrix, RwV3d const* axis, RwReal angle, RwOpCombineType combineOp) { EAXJMP(0x5A2BF0); } +WRAPPER RwMatrix* RwMatrixInvert(RwMatrix* matrixOut, RwMatrix const* matrixIn) { EAXJMP(0x5A2C90); } +WRAPPER RwMatrix* RwMatrixScale(RwMatrix* matrix, RwV3d const* scale, RwOpCombineType combineOp) { EAXJMP(0x5A2EE0); } +WRAPPER RwMatrix* RwMatrixTranslate(RwMatrix* matrix, RwV3d const* translation, RwOpCombineType combineOp) { EAXJMP(0x5A3070); } +WRAPPER RwMatrix* RwMatrixTransform(RwMatrix* matrix, RwMatrix const* transform, RwOpCombineType combineOp) { EAXJMP(0x5A31C0); } +WRAPPER RwBool RwMatrixDestroy(RwMatrix* mpMat) { EAXJMP(0x5A3300); } +WRAPPER RwMatrix* RwMatrixCreate() { EAXJMP(0x5A3330); } +WRAPPER RwBool _rwVectorSetMultFn(rwVectorMultFn multPoint, rwVectorsMultFn multPoints, rwVectorMultFn multVector, rwVectorsMultFn multVectors) { EAXJMP(0x5A3450); } +WRAPPER RwReal _rwV3dNormalize(RwV3d* out, RwV3d const* in) { EAXJMP(0x5A3600); } +WRAPPER RwReal RwV3dLength(RwV3d const* in) { EAXJMP(0x5A36A0); } +WRAPPER RwReal _rwSqrt(RwReal const num) { EAXJMP(0x5A3710); } +WRAPPER RwReal _rwInvSqrt(RwReal const num) { EAXJMP(0x5A3770); } +WRAPPER RwV3d* RwV3dTransformPoints(RwV3d* pointsOut, RwV3d const* pointsIn, RwInt32 numPoints, RwMatrix const* matrix) { EAXJMP(0x5A37D0); } +WRAPPER RwV3d* RwV3dTransformVectors(RwV3d* vectorsOut, RwV3d const* vectorsIn, RwInt32 numPoints, RwMatrix const* matrix) { EAXJMP(0x5A37E0); } +WRAPPER void* _rwVectorClose(void* instance, RwInt32 offset, RwInt32 size) { EAXJMP(0x5A37F0); } +WRAPPER void* _rwVectorOpen(void* instance, RwInt32 offset, RwInt32 size) { EAXJMP(0x5A3860); } +WRAPPER RwUInt32 RwStreamRead(RwStream* stream, void* buffer, RwUInt32 length) { EAXJMP(0x5A3AD0); } +WRAPPER RwStream* RwStreamWrite(RwStream* stream, void const* buffer, RwUInt32 length) { EAXJMP(0x5A3C30); } +WRAPPER RwStream* RwStreamSkip(RwStream* stream, RwUInt32 offset) { EAXJMP(0x5A3DF0); } +WRAPPER RwBool RwStreamClose(RwStream* stream, void* pData) { EAXJMP(0x5A3F10); } +WRAPPER RwStream* RwStreamOpen(RwStreamType type, RwStreamAccessType accessType, void const* pData) { EAXJMP(0x5A3FE0); } +WRAPPER RwReal RwIm2DGetNearScreenZ() { EAXJMP(0x5A43A0); } +WRAPPER RwReal RwIm2DGetFarScreenZ() { EAXJMP(0x5A43B0); } +WRAPPER RwBool RwRenderStateSet(RwRenderState state, void* value) { EAXJMP(0x5A43C0); } +WRAPPER RwBool RwRenderStateGet(RwRenderState state, void* value) { EAXJMP(0x5A4410); } +WRAPPER RwBool RwIm2DRenderLine(RwIm2DVertex* vertices, RwInt32 numVertices, RwInt32 vert1, RwInt32 vert2) { EAXJMP(0x5A4420); } +WRAPPER RwBool RwIm2DRenderPrimitive(RwPrimitiveType primType, RwIm2DVertex* vertices, RwInt32 numVertices) { EAXJMP(0x5A4430); } +WRAPPER RwBool RwIm2DRenderIndexedPrimitive(RwPrimitiveType primType, RwIm2DVertex* vertices, RwInt32 numVertices, RwImVertexIndex* indices, RwInt32 numIndices) { EAXJMP(0x5A4440); } +WRAPPER RwCamera* RwCameraEndUpdate(RwCamera* camera) { EAXJMP(0x5A5020); } +WRAPPER RwCamera* RwCameraBeginUpdate(RwCamera* camera) { EAXJMP(0x5A5030); } +WRAPPER RwCamera* RwCameraSetViewOffset(RwCamera* camera, RwV2d const* offset) { EAXJMP(0x5A5040); } +WRAPPER RwCamera* RwCameraSetNearClipPlane(RwCamera* camera, RwReal nearClip) { EAXJMP(0x5A5070); } +WRAPPER RwCamera* RwCameraSetFarClipPlane(RwCamera* camera, RwReal farClip) { EAXJMP(0x5A5140); } +WRAPPER RwFrustumTestResult RwCameraFrustumTestSphere(RwCamera const* camera, RwSphere const* sphere) { EAXJMP(0x5A5170); } +WRAPPER RwCamera* RwCameraClear(RwCamera* camera, RwRGBA* colour, RwInt32 clearMode) { EAXJMP(0x5A51E0); } +WRAPPER RwCamera* RwCameraShowRaster(RwCamera* camera, void* pDev, RwUInt32 flags) { EAXJMP(0x5A5210); } +WRAPPER RwCamera* RwCameraSetProjection(RwCamera* camera, RwCameraProjection projection) { EAXJMP(0x5A5240); } +WRAPPER RwCamera* RwCameraSetViewWindow(RwCamera* camera, RwV2d const* viewWindow) { EAXJMP(0x5A52B0); } +WRAPPER RwInt32 RwCameraRegisterPlugin(RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor ructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB) { EAXJMP(0x5A52F0); } +WRAPPER RwBool RwCameraDestroy(RwCamera* camera) { EAXJMP(0x5A5320); } +WRAPPER RwCamera* RwCameraCreate() { EAXJMP(0x5A5360); } +WRAPPER RwBool RwTextureSetMipmapping(RwBool enable) { EAXJMP(0x5A7100); } +WRAPPER RwBool RwTextureGetMipmapping() { EAXJMP(0x5A7120); } +WRAPPER RwBool RwTextureSetAutoMipmapping(RwBool enable) { EAXJMP(0x5A7130); } +WRAPPER RwBool RwTextureGetAutoMipmapping() { EAXJMP(0x5A7150); } +WRAPPER RwTexDictionary* RwTexDictionaryCreate() { EAXJMP(0x5A7160); } +WRAPPER RwBool RwTexDictionaryDestroy(RwTexDictionary* dict) { EAXJMP(0x5A7200); } +WRAPPER RwTexDictionary const* RwTexDictionaryForAllTextures(RwTexDictionary const* dict, RwTextureCallBack fpCallBack, void* pData) { EAXJMP(0x5A7290); } +WRAPPER RwTexture* RwTextureCreate(RwRaster* raster) { EAXJMP(0x5A72D0); } +WRAPPER RwBool RwTextureDestroy(RwTexture* texture) { EAXJMP(0x5A7330); } +WRAPPER RwTexture* RwTextureSetName(RwTexture* texture, RwChar const* name) { EAXJMP(0x5A73B0); } +WRAPPER RwTexture* RwTextureSetMaskName(RwTexture* texture, RwChar const* maskName) { EAXJMP(0x5A7420); } +WRAPPER RwTexture* RwTexDictionaryAddTexture(RwTexDictionary* dict, RwTexture* texture) { EAXJMP(0x5A7490); } +WRAPPER RwTexture* RwTexDictionaryFindNamedTexture(RwTexDictionary* dict, RwChar const* name) { EAXJMP(0x5A74D0); } +WRAPPER RwTexDictionary* RwTexDictionarySetCurrent(RwTexDictionary* dict) { EAXJMP(0x5A7550); } +WRAPPER RwTexDictionary* RwTexDictionaryGetCurrent() { EAXJMP(0x5A7570); } +WRAPPER RwTexture* RwTextureRead(RwChar const* name, RwChar const* maskName) { EAXJMP(0x5A7580); } +WRAPPER RwBool RwTextureRasterGenerateMipmaps(RwRaster* raster, RwImage* image) { EAXJMP(0x5A7780); } +WRAPPER RwImage* RwImageCreate(RwInt32 width, RwInt32 height, RwInt32 depth) { EAXJMP(0x5A9120); } +WRAPPER RwBool RwImageDestroy(RwImage* image) { EAXJMP(0x5A9180); } +WRAPPER RwImage* RwImageAllocatePixels(RwImage* image) { EAXJMP(0x5A91E0); } +WRAPPER RwImage* RwImageFreePixels(RwImage* image) { EAXJMP(0x5A92A0); } +WRAPPER RwImage* RwImageMakeMask(RwImage* image) { EAXJMP(0x5A92D0); } +WRAPPER RwImage* RwImageApplyMask(RwImage* image, RwImage const* mask) { EAXJMP(0x5A93A0); } +WRAPPER RwChar const* RwImageSetPath(RwChar const* path) { EAXJMP(0x5A9750); } +WRAPPER RwImage* RwImageRead(RwChar const* imageName) { EAXJMP(0x5A9810); } +WRAPPER RwChar const* RwImageFindFileType(RwChar const* imageName) { EAXJMP(0x5A9B40); } +WRAPPER RwImage* RwImageReadMaskedImage(RwChar const* imageName, RwChar const* maskname) { EAXJMP(0x5A9C10); } +WRAPPER RwImage* RwImageCopy(RwImage* destImage, RwImage const* sourceImage) { EAXJMP(0x5A9F50); } +WRAPPER RwImage* RwImageGammaCorrect(RwImage* image) { EAXJMP(0x5AA130); } +WRAPPER RwBool RwImageSetGamma(RwReal gammaValue) { EAXJMP(0x5AA2C0); } +WRAPPER RwStream* _rwStreamWriteVersionedChunkHeader(RwStream* stream, RwInt32 type, RwInt32 size, RwUInt32 version, RwUInt32 buildNum) { EAXJMP(0x5AA4E0); } +WRAPPER RwBool RwStreamFindChunk(RwStream* stream, RwUInt32 type, RwUInt32* lengthOut, RwUInt32* versionOut) { EAXJMP(0x5AA540); } +WRAPPER void* RwMemLittleEndian32(void* mem, RwUInt32 size) { EAXJMP(0x5AA640); } +WRAPPER void* RwMemNative32(void* mem, RwUInt32 size) { EAXJMP(0x5AA650); } +WRAPPER void* RwMemFloat32ToReal(void* mem, RwUInt32 size) { EAXJMP(0x5AA660); } +WRAPPER RwStream* RwStreamWriteReal(RwStream* stream, RwReal const* reals, RwUInt32 numBytes) { EAXJMP(0x5AA680); } +WRAPPER RwStream* RwStreamWriteInt32(RwStream* stream, RwInt32 const* ints, RwUInt32 numBytes) { EAXJMP(0x5AA720); } +WRAPPER RwStream* RwStreamReadReal(RwStream* stream, RwReal* reals, RwUInt32 numBytes) { EAXJMP(0x5AA740); } +WRAPPER RwStream* RwStreamReadInt32(RwStream* stream, RwInt32* ints, RwUInt32 numBytes) { EAXJMP(0x5AA7B0); } +WRAPPER RwUInt32 RwTextureStreamGetSize(RwTexture const* texture) { EAXJMP(0x5AA800); } +WRAPPER RwTexture const* RwTextureStreamWrite(RwTexture const* texture, RwStream* stream) { EAXJMP(0x5AA870); } +WRAPPER RwTexture* RwTextureStreamRead(RwStream* stream) { EAXJMP(0x5AAA40); } +WRAPPER RwTexDictionary const* RwTexDictionaryStreamWrite(RwTexDictionary const* texDict, RwStream* stream) { EAXJMP(0x5AB020); } +WRAPPER RpMorphTarget const* RpMorphTargetCalcBoundingSphere(RpMorphTarget const* morphTarget, RwSphere* boundingSphere) { EAXJMP(0x5AC890); } +WRAPPER RwInt32 RpGeometryAddMorphTargets(RpGeometry* geometry, RwInt32 mtcount) { EAXJMP(0x5AC9A0); } +WRAPPER RpGeometry const* RpGeometryTriangleSetVertexIndices(RpGeometry const* geometry, RpTriangle* triangle, RwUInt16 vert1, RwUInt16 vert2, RwUInt16 vert3) { EAXJMP(0x5ACB60); } +WRAPPER RpGeometry* RpGeometryTriangleSetMaterial(RpGeometry* geometry, RpTriangle* triangle, RpMaterial* material) { EAXJMP(0x5ACB90); } +WRAPPER RpGeometry* RpGeometryForAllMaterials(RpGeometry* geometry, RpMaterialCallBack fpCallBack, void* pData) { EAXJMP(0x5ACBF0); } +WRAPPER RpGeometry* RpGeometryLock(RpGeometry* geometry, RwInt32 lockMode) { EAXJMP(0x5ACC30); } +WRAPPER RpGeometry* RpGeometryUnlock(RpGeometry* geometry) { EAXJMP(0x5ACC60); } +WRAPPER RpGeometry* RpGeometryCreate(RwInt32 numVert, RwInt32 numTriangles, RwUInt32 format) { EAXJMP(0x5ACD10); } +WRAPPER RpGeometry* _rpGeometryAddRef(RpGeometry* geometry) { EAXJMP(0x5ACF40); } +WRAPPER RwBool RpGeometryDestroy(RpGeometry* geometry) { EAXJMP(0x5ACF50); } +WRAPPER RwInt32 RpGeometryRegisterPlugin(RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor ructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB) { EAXJMP(0x5ACFF0); } +WRAPPER RwInt32 RpGeometryRegisterPluginStream(RwUInt32 pluginID, RwPluginDataChunkReadCallBack readCB, RwPluginDataChunkWriteCallBack writeCB, RwPluginDataChunkGetSizeCallBack getSizeCB) { EAXJMP(0x5AD020); } +WRAPPER RpGeometry* RpGeometryStreamRead(RwStream* stream) { EAXJMP(0x5AD050); } +WRAPPER RwRaster* RwRasterGetCurrentContext() { EAXJMP(0x5AD6D0); } +WRAPPER RwRaster* RwRasterUnlock(RwRaster* raster) { EAXJMP(0x5AD6F0); } +WRAPPER RwRaster* RwRasterRenderFast(RwRaster* raster, RwInt32 x, RwInt32 y) { EAXJMP(0x5AD710); } +WRAPPER RwRaster* RwRasterUnlockPalette(RwRaster* raster) { EAXJMP(0x5AD750); } +WRAPPER RwBool RwRasterDestroy(RwRaster* raster) { EAXJMP(0x5AD780); } +WRAPPER RwRaster* RwRasterPushContext(RwRaster* raster) { EAXJMP(0x5AD7C0); } +WRAPPER RwInt32 RwRasterRegisterPlugin(RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor ructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB) { EAXJMP(0x5AD810); } +WRAPPER RwUInt8* RwRasterLockPalette(RwRaster* raster, RwInt32 lockMode) { EAXJMP(0x5AD840); } +WRAPPER RwRaster* RwRasterPopContext() { EAXJMP(0x5AD870); } +WRAPPER RwInt32 RwRasterGetNumLevels(RwRaster* raster) { EAXJMP(0x5AD8C0); } +WRAPPER RwRaster* RwRasterShowRaster(RwRaster* raster, void* dev, RwUInt32 flags) { EAXJMP(0x5AD900); } +WRAPPER RwRaster* RwRasterCreate(RwInt32 width, RwInt32 height, RwInt32 depth, RwInt32 flags) { EAXJMP(0x5AD930); } +WRAPPER RwUInt8* RwRasterLock(RwRaster* raster, RwUInt8 level, RwInt32 lockMode) { EAXJMP(0x5AD9D0); } +WRAPPER RpMaterial* RpMaterialCreate() { EAXJMP(0x5ADC30); } +WRAPPER RwBool RpMaterialDestroy(RpMaterial* material) { EAXJMP(0x5ADCB0); } +WRAPPER RpMaterial* RpMaterialSetTexture(RpMaterial* material, RwTexture* texture) { EAXJMP(0x5ADD10); } +WRAPPER RwInt32 RpMaterialRegisterPlugin(RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor ructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB) { EAXJMP(0x5ADD40); } +WRAPPER RwInt32 RpMaterialRegisterPluginStream(RwUInt32 pluginID, RwPluginDataChunkReadCallBack readCB, RwPluginDataChunkWriteCallBack writeCB, RwPluginDataChunkGetSizeCallBack getSizeCB) { EAXJMP(0x5ADD70); } +WRAPPER RpMaterial* RpMaterialStreamRead(RwStream* stream) { EAXJMP(0x5ADDA0); } +WRAPPER RpWorldSector* _rpSectorDefaultRenderCallBack(RpWorldSector* sector) { EAXJMP(0x5AE0B0); } +WRAPPER RwBool _rpWorldForAllGlobalLights(RpLightCallBack callBack, void* pData) { EAXJMP(0x5AE100); } +WRAPPER RpWorldSector* _rpWorldSectorForAllLocalLights(RpWorldSector* sector, RpLightCallBack callBack, void* pData) { EAXJMP(0x5AE150); } +WRAPPER RpWorld* RpWorldUnlock(RpWorld* world) { EAXJMP(0x5AE190); } +WRAPPER RpWorld* RpWorldSectorGetWorld(RpWorldSector const* sector) { EAXJMP(0x5AE2B0); } +WRAPPER RwBool RpWorldDestroy(RpWorld* world) { EAXJMP(0x5AE340); } +WRAPPER RpWorld* RpWorldCreate(RwBBox* boundingBox) { EAXJMP(0x5AE6A0); } +WRAPPER RwInt32 RpWorldRegisterPlugin(RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor ructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB) { EAXJMP(0x5AEA40); } +WRAPPER RwInt32 RpWorldRegisterPluginStream(RwUInt32 pluginID, RwPluginDataChunkReadCallBack readCB, RwPluginDataChunkWriteCallBack writeCB, RwPluginDataChunkGetSizeCallBack getSizeCB) { EAXJMP(0x5AEA70); } +WRAPPER RwBool RpWorldPluginAttach() { EAXJMP(0x5AEAA0); } +WRAPPER RpWorld* RpWorldAddCamera(RpWorld* world, RwCamera* camera) { EAXJMP(0x5AFB80); } +WRAPPER RpWorld* RpWorldRemoveCamera(RpWorld* world, RwCamera* camera) { EAXJMP(0x5AFBB0); } +WRAPPER RpWorld* RpAtomicGetWorld(RpAtomic const* atomic) { EAXJMP(0x5AFC10); } +WRAPPER RpWorld* RpWorldAddClump(RpWorld* world, RpClump* clump) { EAXJMP(0x5AFC20); } +WRAPPER RpWorld* RpWorldAddLight(RpWorld* world, RpLight* light) { EAXJMP(0x5AFDA0); } +WRAPPER RpWorld* RpWorldRemoveLight(RpWorld* world, RpLight* light) { EAXJMP(0x5AFDF0); } +WRAPPER RwImage* RtBMPImageRead(RwChar const* imageName) { EAXJMP(0x5AFE70); } +WRAPPER RwBool RpSkinPluginAttach() { EAXJMP(0x5B07D0); } +WRAPPER RpAtomic* RpSkinAtomicSetHAnimHierarchy(RpAtomic* atomic, RpHAnimHierarchy* hierarchy) { EAXJMP(0x5B1050); } +WRAPPER RpHAnimHierarchy* RpSkinAtomicGetHAnimHierarchy(RpAtomic const* atomic) { EAXJMP(0x5B1070); } +WRAPPER RpSkin* RpSkinGeometryGetSkin(RpGeometry* geometry) { EAXJMP(0x5B1080); } +WRAPPER RpGeometry* RpSkinGeometrySetSkin(RpGeometry* geometry, RpSkin* skin) { EAXJMP(0x5B1090); } +WRAPPER RwMatrix const* RpSkinGetSkinToBoneMatrices(RpSkin* skin) { EAXJMP(0x5B10D0); } +WRAPPER RpHAnimHierarchy* RpHAnimHierarchyCreate(RwInt32 numNodes, RwUInt32* nodeFlags, RwInt32* nodeIDs, RpHAnimHierarchyFlag flags, RwInt32 maxKeyFrameSize) { EAXJMP(0x5B10E0); } +WRAPPER RpHAnimHierarchy* RpHAnimFrameGetHierarchy(RwFrame* frame) { EAXJMP(0x5B11F0); } +WRAPPER RwBool RpHAnimHierarchySetCurrentAnim(RpHAnimHierarchy* hierarchy, RpHAnimAnimation* anim) { EAXJMP(0x5B1200); } +WRAPPER RwBool RpHAnimHierarchySubAnimTime(RpHAnimHierarchy* hierarchy, RwReal time) { EAXJMP(0x5B12B0); } +WRAPPER RwBool RpHAnimHierarchyAddAnimTime(RpHAnimHierarchy* hierarchy, RwReal time) { EAXJMP(0x5B1480); } +WRAPPER RwBool RpHAnimHierarchyUpdateMatrices(RpHAnimHierarchy* hierarchy) { EAXJMP(0x5B1780); } +WRAPPER RpHAnimAnimation* RpHAnimAnimationStreamRead(RwStream* stream) { EAXJMP(0x5B1C10); } +WRAPPER RwBool RpHAnimPluginAttach() { EAXJMP(0x5B1D50); } +WRAPPER RwBool RpMatFXPluginAttach() { EAXJMP(0x5B2640); } +WRAPPER RpAtomic* RpMatFXAtomicEnableEffects(RpAtomic* atomic) { EAXJMP(0x5B3750); } +WRAPPER RpMaterial* RpMatFXMaterialSetEffects(RpMaterial* material, RpMatFXMaterialFlags flags) { EAXJMP(0x5B3780); } +WRAPPER RpMaterial* RpMatFXMaterialSetupEnvMap(RpMaterial* material, RwTexture* texture, RwFrame* frame, RwBool useFrameBufferAlpha, RwReal coef) { EAXJMP(0x5B38D0); } +WRAPPER RpMaterial* RpMatFXMaterialSetBumpMapTexture(RpMaterial* material, RwTexture* texture) { EAXJMP(0x5B3A40); } +WRAPPER RwBool RwD3D8SetRenderState(RwUInt32 state, RwUInt32 value) { EAXJMP(0x5B3CF0); } +WRAPPER void RwD3D8GetRenderState(RwUInt32 state, void* value) { EAXJMP(0x5B3D40); } +WRAPPER RwBool RwD3D8SetTextureStageState(RwUInt32 stage, RwUInt32 type, RwUInt32 value) { EAXJMP(0x5B3D60); } +WRAPPER RwBool RwD3D8SetTexture(RwTexture* texture, RwUInt32 stage) { EAXJMP(0x5B53A0); } +WRAPPER void* RwIm3DTransform(RwIm3DVertex* pVerts, RwUInt32 numVerts, RwMatrix* ltm, RwUInt32 flags) { EAXJMP(0x5B6720); } +WRAPPER RwBool RwIm3DEnd() { EAXJMP(0x5B67F0); } +WRAPPER RwBool RwIm3DRenderIndexedPrimitive(RwPrimitiveType primType, RwImVertexIndex* indices, RwInt32 numIndices) { EAXJMP(0x5B6820); } +WRAPPER RwBool RwIm3DRenderLine(RwInt32 vert1, RwInt32 vert2) { EAXJMP(0x5B6980); } +WRAPPER RxPipeline* RwIm3DSetTransformPipeline(RxPipeline* pipeline) { EAXJMP(0x5B6A50); } +WRAPPER RxPipeline* RwIm3DSetRenderPipeline(RxPipeline* pipeline, RwPrimitiveType primType) { EAXJMP(0x5B6AC0); } +WRAPPER void RwD3D8EngineSetRefreshRate(RwUInt32 refreshRate) { EAXJMP(0x5B95D0); } +WRAPPER RwBool RwD3D8CameraAttachWindow(void* camera, void* hwnd) { EAXJMP(0x5B9640); } +WRAPPER RwBool RwD3D8DeviceSupportsDXTTexture() { EAXJMP(0x5BAEB0); } +WRAPPER RwBool RwD3D8SetVertexShader(RwUInt32 handle) { EAXJMP(0x5BAF90); } +WRAPPER RwBool RwD3D8SetPixelShader(RwUInt32 handle) { EAXJMP(0x5BAFD0); } +WRAPPER RwBool RwD3D8SetStreamSource(RwUInt32 streamNumber, void* streamData, RwUInt32 stride) { EAXJMP(0x5BB010); } +WRAPPER RwBool RwD3D8SetIndices(void* indexData, RwUInt32 baseVertexIndex) { EAXJMP(0x5BB060); } +WRAPPER RwBool RwD3D8DrawIndexedPrimitive(RwUInt32 primitiveType, RwUInt32 minIndex, RwUInt32 numVertices, RwUInt32 startIndex, RwUInt32 numIndices) { EAXJMP(0x5BB0B0); } +WRAPPER RwBool RwD3D8DrawPrimitive(RwUInt32 primitiveType, RwUInt32 startVertex, RwUInt32 numVertices) { EAXJMP(0x5BB140); } +WRAPPER RwBool RwD3D8SetTransform(RwUInt32 state, void const* matrix) { EAXJMP(0x5BB1D0); } +WRAPPER void RwD3D8GetTransform(RwUInt32 state, void* matrix) { EAXJMP(0x5BB310); } +WRAPPER RwBool RwD3D8SetTransformWorld(RwMatrix const* matrix) { EAXJMP(0x5BB340); } +WRAPPER RwBool RwD3D8SetSurfaceProperties(RwRGBA const* color, RwSurfaceProperties const* surfaceProps, RwBool modulate) { EAXJMP(0x5BB490); } +WRAPPER RwBool RwD3D8SetLight(RwInt32 index, void const* light) { EAXJMP(0x5BB7A0); } +WRAPPER RwBool RwD3D8EnableLight(RwInt32 index, RwBool enable) { EAXJMP(0x5BB890); } +WRAPPER RwBool RwD3D8DynamicVertexBufferCreate(RwUInt32 fvf, RwUInt32 size, void** vertexBuffer) { EAXJMP(0x5BB9F0); } +WRAPPER void RwD3D8DynamicVertexBufferDestroy(void* vertexBuffer) { EAXJMP(0x5BBAE0); } +WRAPPER RwBool RwD3D8IndexBufferCreate(RwUInt32 numIndices, void** indexBuffer) { EAXJMP(0x5BBB10); } +WRAPPER RwBool RwD3D8CreatePixelShader(RwUInt32 const* function, RwUInt32* handle) { EAXJMP(0x5BBB40); } +WRAPPER void RwD3D8DeletePixelShader(RwUInt32 handle) { EAXJMP(0x5BBB90); } +WRAPPER RwBool RwD3D8SetPixelShaderConstant(RwUInt32 registerAddress, void const* antData, RwUInt32 antCount) { EAXJMP(0x5BBC00); } +WRAPPER void const* RwD3D8GetCaps() { EAXJMP(0x5BBC30); } +WRAPPER RwBool RwD3D8CameraIsSphereFullyInsideFrustum(void const* camera, void const* sphere) { EAXJMP(0x5BBC40); } +WRAPPER RwBool RwD3D8CameraIsBBoxFullyInsideFrustum(void const* camera, void const* boundingBox) { EAXJMP(0x5BBCA0); } +WRAPPER RwBool RwD3D8DynamicVertexBufferLock(RwUInt32 vertexSize, RwUInt32 numVertex, void** vertexBufferOut, void** vertexDataOut, RwUInt32* baseIndexOut) { EAXJMP(0x5BBD30); } +WRAPPER RwBool RwD3D8DynamicVertexBufferUnlock(void* vertexBuffer) { EAXJMP(0x5BBEB0); } +WRAPPER RwBool _rwIntelSSEsupported() { EAXJMP(0x5BBED0); } +WRAPPER RwImage* RwImageSetFromRaster(RwImage* image, RwRaster* raster) { EAXJMP(0x5BBF10); } +WRAPPER RwRaster* RwRasterSetFromImage(RwRaster* raster, RwImage* image) { EAXJMP(0x5BBF50); } +WRAPPER RwImage* RwImageFindRasterFormat(RwImage* ipImage, RwInt32 nRasterType, RwInt32* npWidth, RwInt32* npHeight, RwInt32* npDepth, RwInt32* npFormat) { EAXJMP(0x5BBF80); } +WRAPPER RwInt32 RwFrameRegisterPluginStream(RwUInt32 pluginID, RwPluginDataChunkReadCallBack readCB, RwPluginDataChunkWriteCallBack writeCB, RwPluginDataChunkGetSizeCallBack getSizeCB) { EAXJMP(0x5BBFF0); } +WRAPPER rwFrameList* _rwFrameListDeinitialize(rwFrameList* frameList) { EAXJMP(0x5BC020); } +WRAPPER rwFrameList* _rwFrameListStreamRead(RwStream* stream, rwFrameList* fl) { EAXJMP(0x5BC050); } +WRAPPER RpLight* RpLightSetRadius(RpLight* light, RwReal radius) { EAXJMP(0x5BC300); } +WRAPPER RpLight* RpLightSetColor(RpLight* light, RwRGBAReal const* color) { EAXJMP(0x5BC320); } +WRAPPER RwReal RpLightGetConeAngle(RpLight const* light) { EAXJMP(0x5BC370); } +WRAPPER RwInt32 RpLightRegisterPlugin(RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor ructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB) { EAXJMP(0x5BC5B0); } +WRAPPER RpLight* RpLightStreamRead(RwStream* stream) { EAXJMP(0x5BC5E0); } +WRAPPER RwBool RpLightDestroy(RpLight* light) { EAXJMP(0x5BC780); } +WRAPPER RpLight* RpLightCreate(RwInt32 type) { EAXJMP(0x5BC7C0); } +WRAPPER void _rwD3D8TexDictionaryEnableRasterFormatConversion(RwBool enable) { EAXJMP(0x5BE280); } +WRAPPER RwFileFunctions* RwOsGetFileInterface() { EAXJMP(0x5BF110); } +WRAPPER RwBool RwFreeListDestroy(RwFreeList* freelist) { EAXJMP(0x5C1720); } +WRAPPER RwFreeList* RwFreeListCreate(RwInt32 entrySize, RwInt32 entriesPerBlock, RwInt32 alignment) { EAXJMP(0x5C1790); } +WRAPPER RwInt32 RwFreeListPurge(RwFreeList* freelist) { EAXJMP(0x5C19F0); } +WRAPPER RwInt32 RwFreeListPurgeAllFreeLists() { EAXJMP(0x5C1B90); } +WRAPPER RwFreeList* RwFreeListForAllUsed(RwFreeList* freelist, RwFreeListCallBack fpCallBack, void* pData) { EAXJMP(0x5C1D40); } +WRAPPER RwBool _rxPipelineClose() { EAXJMP(0x5C2780); } +WRAPPER RwBool _rxPipelineOpen() { EAXJMP(0x5C27E0); } +WRAPPER RxHeap* RxHeapGetGlobalHeap() { EAXJMP(0x5C2AD0); } +WRAPPER RxPacket* RxPacketCreate(RxPipelineNode* node) { EAXJMP(0x5C2AE0); } +WRAPPER RxCluster* RxClusterSetExternalData(RxCluster* cluster, void* data, RwInt32 stride, RwInt32 numElements) { EAXJMP(0x5C2B10); } +WRAPPER RxCluster* RxClusterSetData(RxCluster* cluster, void* data, RwInt32 stride, RwInt32 numElements) { EAXJMP(0x5C2B70); } +WRAPPER RxCluster* RxClusterInitializeData(RxCluster* cluster, RwUInt32 numElements, RwUInt16 stride) { EAXJMP(0x5C2BD0); } +WRAPPER RxCluster* RxClusterResizeData(RxCluster* CurrentCluster, RwUInt32 NumElements) { EAXJMP(0x5C2C40); } +WRAPPER RxCluster* RxClusterLockWrite(RxPacket* packet, RwUInt32 clusterIndex, RxPipelineNode* node) { EAXJMP(0x5C2C90); } +WRAPPER RxPipeline* RxPipelineExecute(RxPipeline* pipeline, void* data, RwBool heapReset) { EAXJMP(0x5C2D60); } +WRAPPER RxPipeline* RxPipelineCreate() { EAXJMP(0x5C2E00); } +WRAPPER void _rxPipelineDestroy(RxPipeline* Pipeline) { EAXJMP(0x5C2E70); } +WRAPPER RwBool RwResourcesFreeResEntry(RwResEntry* entry) { EAXJMP(0x5C3080); } +WRAPPER void _rwResourcesPurge() { EAXJMP(0x5C30F0); } +WRAPPER RwResEntry* RwResourcesAllocateResEntry(void* owner, RwResEntry** ownerRef, RwInt32 size, RwResEntryDestroyNotify destroyNotify) { EAXJMP(0x5C3170); } +WRAPPER RwBool RwResourcesEmptyArena() { EAXJMP(0x5C3360); } +WRAPPER RwBool _rwPluginRegistryOpen() { EAXJMP(0x5C3450); } +WRAPPER RwBool _rwPluginRegistryClose() { EAXJMP(0x5C3480); } +WRAPPER RwInt32 _rwPluginRegistryGetPluginOffset(RwPluginRegistry const* reg, RwUInt32 pluginID) { EAXJMP(0x5C3590); } +WRAPPER RwInt32 _rwPluginRegistryAddPlugin(RwPluginRegistry* reg, RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor ructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB) { EAXJMP(0x5C35C0); } +WRAPPER RwPluginRegistry const* _rwPluginRegistryInitObject(RwPluginRegistry const* reg, void* object) { EAXJMP(0x5C37F0); } +WRAPPER RwPluginRegistry const* _rwPluginRegistryDeInitObject(RwPluginRegistry const* reg, void* object) { EAXJMP(0x5C3850); } +WRAPPER RwPluginRegistry const* _rwPluginRegistryCopyObject(RwPluginRegistry const* reg, void* dstObject, void const* srcObject) { EAXJMP(0x5C3880); } +WRAPPER RwError* RwErrorSet(RwError* code) { EAXJMP(0x5C3910); } +WRAPPER RwInt32 _rwerror(RwInt32 code, ...) { EAXJMP(0x5C3970); } +WRAPPER RwInt32 _rwPluginRegistryAddPluginStream(RwPluginRegistry* reg, RwUInt32 pluginID, RwPluginDataChunkReadCallBack readCB, RwPluginDataChunkWriteCallBack writeCB, RwPluginDataChunkGetSizeCallBack getSizeCB) { EAXJMP(0x5C3980); } +WRAPPER RwInt32 _rwPluginRegistryAddPlgnStrmlwysCB(RwPluginRegistry* reg, RwUInt32 pluginID, RwPluginDataChunkAlwaysCallBack alwaysCB) { EAXJMP(0x5C39C0); } +WRAPPER RwInt32 _rwPluginRegistryAddPlgnStrmRightsCB(RwPluginRegistry* reg, RwUInt32 pluginID, RwPluginDataChunkRightsCallBack rightsCB) { EAXJMP(0x5C39F0); } +WRAPPER RwPluginRegistry const* _rwPluginRegistryReadDataChunks(RwPluginRegistry const* reg, RwStream* stream, void* object) { EAXJMP(0x5C3A20); } +WRAPPER RwPluginRegistry const* _rwPluginRegistryInvokeRights(RwPluginRegistry const* reg, RwUInt32 id, void* obj, RwUInt32 extraData) { EAXJMP(0x5C3B50); } +WRAPPER RwInt32 _rwPluginRegistryGetSize(RwPluginRegistry const* reg, void const* object) { EAXJMP(0x5C3BA0); } +WRAPPER RwPluginRegistry const* _rwPluginRegistryWriteDataChunks(RwPluginRegistry const* reg, RwStream* stream, void const* object) { EAXJMP(0x5C3BE0); } +WRAPPER RwPluginRegistry const* _rwPluginRegistrySkipDataChunks(RwPluginRegistry const* reg, RwStream* stream) { EAXJMP(0x5C3CB0); } +WRAPPER RwCamera* RwCameraStreamRead(RwStream* stream) { EAXJMP(0x5C3D30); } +WRAPPER RwBBox* RwBBoxCalculate(RwBBox* boundBox, RwV3d const* verts, RwInt32 numVerts) { EAXJMP(0x5C5570); } +WRAPPER RwImage* RwImageResample(RwImage* dstImage, RwImage const* srcImage) { EAXJMP(0x5C72B0); } +WRAPPER RwImage* RwImageCreateResample(RwImage const* srcImage, RwInt32 width, RwInt32 height) { EAXJMP(0x5C7B30); } +WRAPPER RxRenderStateVector* RxRenderStateVectorSetDefaultRenderStateVector(RxRenderStateVector* rsvp) { EAXJMP(0x5D9240); } +WRAPPER RxRenderStateVector* RxRenderStateVectorCreate(RwBool current) { EAXJMP(0x5D9340); } +WRAPPER void RxRenderStateVectorDestroy(RxRenderStateVector* rsvp) { EAXJMP(0x5D9410); } +WRAPPER RxRenderStateVector* RxRenderStateVectorLoadDriverState(RxRenderStateVector* rsvp) { EAXJMP(0x5D9460); } +WRAPPER void _rxEmbeddedPacketBetweenPipelines(RxPipeline* fromPipeline, RxPipeline* toPipeline) { EAXJMP(0x5D95D0); } +WRAPPER RxPipelineNode* _rxEmbeddedPacketBetweenNodes(RxPipeline* pipeline, RxPipelineNode* nodeFrom, RwUInt32 whichOutput) { EAXJMP(0x5D9740); } +WRAPPER void _rxPacketDestroy(RxPacket* Packet) { EAXJMP(0x5D9810); } +WRAPPER RpMaterialList* _rpMaterialListDeinitialize(RpMaterialList* matList) { EAXJMP(0x5C8B10); } +WRAPPER RpMaterialList* _rpMaterialListInitialize(RpMaterialList* matList) { EAXJMP(0x5C8B70); } +WRAPPER RpMaterial* _rpMaterialListGetMaterial(RpMaterialList const* matList, RwInt32 matIndex) { EAXJMP(0x5C8B80); } +WRAPPER RwInt32 _rpMaterialListAppendMaterial(RpMaterialList* matList, RpMaterial* material) { EAXJMP(0x5C8B90); } +WRAPPER RwInt32 _rpMaterialListFindMaterialIndex(RpMaterialList const* matList, RpMaterial const* material) { EAXJMP(0x5C8C50); } +WRAPPER RpMaterialList* _rpMaterialListStreamRead(RwStream* stream, RpMaterialList* matList) { EAXJMP(0x5C8C80); } +WRAPPER RpMeshHeader* _rpMeshHeaderCreate(RwUInt32 size) { EAXJMP(0x5C8FE0); } +WRAPPER void* _rpMeshClose(void* instance, RwInt32 offset, RwInt32 size) { EAXJMP(0x5C8FF0); } +WRAPPER void* _rpMeshOpen(void* instance, RwInt32 offset, RwInt32 size) { EAXJMP(0x5C9020); } +WRAPPER RpBuildMesh* _rpBuildMeshCreate(RwUInt32 bufferSize) { EAXJMP(0x5C9140); } +WRAPPER RwBool _rpBuildMeshDestroy(RpBuildMesh* mesh) { EAXJMP(0x5C9220); } +WRAPPER RwBool _rpMeshDestroy(RpMeshHeader* mesh) { EAXJMP(0x5C9260); } +WRAPPER RpBuildMesh* _rpBuildMeshAddTriangle(RpBuildMesh* mesh, RpMaterial* material, RwInt32 vert1, RwInt32 vert2, RwInt32 vert3) { EAXJMP(0x5C92A0); } +WRAPPER RpMeshHeader* _rpMeshHeaderForAllMeshes(RpMeshHeader* meshHeader, RpMeshCallBack fpCallBack, void* pData) { EAXJMP(0x5C9380); } +WRAPPER RwStream* _rpMeshWrite(RpMeshHeader const* meshHeader, void const* object, RwStream* stream, RpMaterialList const* matList) { EAXJMP(0x5C93C0); } +WRAPPER RpMeshHeader* _rpMeshRead(RwStream* stream, void const* object, RpMaterialList const* matList) { EAXJMP(0x5C9510); } +WRAPPER RwInt32 _rpMeshSize(RpMeshHeader const* meshHeader, void const* object) { EAXJMP(0x5C96E0); } +WRAPPER RpMeshHeader* RpBuildMeshGenerateDefaultTriStrip(RpBuildMesh* buildmesh, void* data) { EAXJMP(0x5C9730); } +WRAPPER RpMeshHeader* _rpTriListMeshGenerate(RpBuildMesh* buildMesh, void* data) { EAXJMP(0x5CAE10); } +WRAPPER RpMeshHeader* _rpMeshOptimise(RpBuildMesh* buildmesh, RwUInt32 flags) { EAXJMP(0x5CB230); } +WRAPPER RwInt32 RpWorldSectorRegisterPlugin(RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor ructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB) { EAXJMP(0x5CB2B0); } +WRAPPER RwInt32 RpWorldSectorRegisterPluginStream(RwUInt32 pluginID, RwPluginDataChunkReadCallBack readCB, RwPluginDataChunkWriteCallBack writeCB, RwPluginDataChunkGetSizeCallBack getSizeCB) { EAXJMP(0x5CB2E0); } +WRAPPER RxPipeline* RpWorldSetDefaultSectorPipeline(RxPipeline* pipeline) { EAXJMP(0x5CB630); } +WRAPPER RxPipeline* RpAtomicSetDefaultPipeline(RxPipeline* pipeline) { EAXJMP(0x5CB670); } +WRAPPER void RpHAnimStdKeyFrameToMatrix(RwMatrix* matrix, void* voidIFrame) { EAXJMP(0x5CDEE0); } +WRAPPER void RpHAnimStdKeyFrameInterpolate(void* voidOut, void* voidIn1, void* voidIn2, RwReal time) { EAXJMP(0x5CE000); } +WRAPPER void RpHAnimStdKeyFrameBlend(void* voidOut, void* voidIn1, void* voidIn2, RwReal alpha) { EAXJMP(0x5CE420); } +WRAPPER RpHAnimAnimation* RpHAnimStdKeyFrameStreamRead(RwStream* stream, RpHAnimAnimation* animation) { EAXJMP(0x5CE820); } +WRAPPER RwBool RpHAnimStdKeyFrameStreamWrite(RpHAnimAnimation* animation, RwStream* stream) { EAXJMP(0x5CE8C0); } +WRAPPER RwInt32 RpHAnimStdKeyFrameStreamGetSize(RpHAnimAnimation* animation) { EAXJMP(0x5CE930); } +WRAPPER void RpHAnimStdKeyFrameMulRecip(void* voidFrame, void* voidStart) { EAXJMP(0x5CE950); } +WRAPPER void RpHAnimStdKeyFrameAdd(void* voidOut, void* voidIn1, void* voidIn2) { EAXJMP(0x5CEAB0); } +WRAPPER void RxHeapFree(RxHeap* heap, void* block) { EAXJMP(0x5D1070); } +WRAPPER void* RxHeapAlloc(RxHeap* heap, RwUInt32 size) { EAXJMP(0x5D1260); } +WRAPPER void* RxHeapRealloc(RxHeap* heap, void* block, RwUInt32 newSize, RwBool allowCopy) { EAXJMP(0x5D14D0); } +WRAPPER RwBool _rxHeapReset(RxHeap* heap) { EAXJMP(0x5D1680); } +WRAPPER void RxHeapDestroy(RxHeap* heap) { EAXJMP(0x5D16F0); } +WRAPPER RxHeap* RxHeapCreate(RwUInt32 size) { EAXJMP(0x5D1750); } +WRAPPER RxNodeOutput RxPipelineNodeFindOutputByName(RxPipelineNode* node, RwChar const* outputname) { EAXJMP(0x5D1EC0); } +WRAPPER RxNodeInput RxPipelineNodeFindInput(RxPipelineNode* node) { EAXJMP(0x5D1F20); } +WRAPPER RxPipeline* RxPipelineNodeRequestCluster(RxPipeline* pipeline, RxPipelineNode* node, RxClusterDefinition* clusterDef) { EAXJMP(0x5D1F30); } +WRAPPER RxPipeline* RxLockedPipeUnlock(RxLockedPipe* pipeline) { EAXJMP(0x5D1FA0); } +WRAPPER RxLockedPipe* RxPipelineLock(RxPipeline* pipeline) { EAXJMP(0x5D29F0); } +WRAPPER RxPipelineNode* RxPipelineFindNodeByName(RxPipeline* pipeline, RwChar const* name, RxPipelineNode* start, RwInt32* nodeIndex) { EAXJMP(0x5D2B10); } +WRAPPER RxLockedPipe* RxLockedPipeAddFragment(RxLockedPipe *pipeline, RwUInt32 *firstIndex, RxNodeDefinition *nodeDef0, ...) { EAXJMP(0x5D2BA0); } +WRAPPER RxPipeline* RxLockedPipeAddPath(RxLockedPipe* pipeline, RxNodeOutput out, RxNodeInput in) { EAXJMP(0x5D2EE0); } +WRAPPER RxNodeDefinition* RxNodeDefinitionGetImmRenderSetup() { EAXJMP(0x5D31C0); } +WRAPPER RxNodeDefinition* RxNodeDefinitionGetImmMangleTriangleIndices() { EAXJMP(0x5D35C0); } +WRAPPER RxNodeDefinition* RxNodeDefinitionGetCullTriangle() { EAXJMP(0x5D3C60); } +WRAPPER RxNodeDefinition* RxNodeDefinitionGetClipTriangle() { EAXJMP(0x5D4F80); } +WRAPPER RxNodeDefinition* RxNodeDefinitionGetSubmitTriangle() { EAXJMP(0x5D51C0); } +WRAPPER RxNodeDefinition* RxNodeDefinitionGetImmInstance() { EAXJMP(0x5D5400); } +WRAPPER RxNodeDefinition* RxNodeDefinitionGetTransform() { EAXJMP(0x5D6000); } +WRAPPER RxNodeDefinition* RxNodeDefinitionGetImmStash() { EAXJMP(0x5D61C0); } +WRAPPER RxNodeDefinition* RxNodeDefinitionGetImmMangleLineIndices() { EAXJMP(0x5D6470); } +WRAPPER RxNodeDefinition* RxNodeDefinitionGetClipLine() { EAXJMP(0x5D7230); } +WRAPPER RxNodeDefinition* RxNodeDefinitionGetSubmitLine() { EAXJMP(0x5D74C0); } +WRAPPER RwBool _rwD3D8LightsOpen() { EAXJMP(0x5D9C90); } +WRAPPER void _rwD3D8LightsClose() { EAXJMP(0x5D9EF0); } +WRAPPER RwBool _rwD3D8LightsGlobalEnable(RpLightFlag flags) { EAXJMP(0x5D9F80); } +WRAPPER RwBool _rwD3D8LightLocalEnable(RpLight* light) { EAXJMP(0x5DA210); } +WRAPPER void _rwD3D8LightsEnable(RwBool enable, RwUInt32 type) { EAXJMP(0x5DA450); } +WRAPPER RxNodeDefinition* RxNodeDefinitionGetD3D8WorldSectorAllInOne() { EAXJMP(0x5DAAC0); } +WRAPPER RxNodeDefinition* RxNodeDefinitionGetD3D8AtomicAllInOne() { EAXJMP(0x5DC500); } +WRAPPER RxNodeDefinition* RxNodeDefinitionGetWorldSectorInstance() { EAXJMP(0x5DCC50); } +WRAPPER RxNodeDefinition* RxNodeDefinitionGetWorldSectorEnumerateLights() { EAXJMP(0x5DCD80); } +WRAPPER RxNodeDefinition* RxNodeDefinitionGetAtomicInstance() { EAXJMP(0x5DD800); } +WRAPPER RxNodeDefinition* RxNodeDefinitionGetAtomicEnumerateLights() { EAXJMP(0x5DD9B0); } +WRAPPER RxNodeDefinition* RxNodeDefinitionGetMaterialScatter() { EAXJMP(0x5DDAA0); } +WRAPPER RxNodeDefinition* RxNodeDefinitionGetLight() { EAXJMP(0x5DF040); } +WRAPPER RxNodeDefinition* RxNodeDefinitionGetPostLight() { EAXJMP(0x5DF560); } +WRAPPER void RxD3D8AllInOneSetRenderCallBack(RxPipelineNode* node, RxD3D8AllInOneRenderCallBack callback) { EAXJMP(0x5DFC60); } +#else + +extern "C" +{ + void* _rwFrameOpen(void* instance, RwInt32 offset, RwInt32 size); + void* _rwFrameClose(void* instance, RwInt32 offset, RwInt32 size); + RwFrame* _rwFrameCloneAndLinkClones(RwFrame* root); + RwFrame* _rwFramePurgeClone(RwFrame* root); + RwBool RwFrameDirty(RwFrame const* frame); + void _rwFrameInit(RwFrame* frame); + RwBool _rwMatrixSetMultFn(rwMatrixMultFn multMat); + void* _rwMatrixClose(void* instance, RwInt32 offset, RwInt32 size); + void* _rwMatrixOpen(void* instance, RwInt32 offset, RwInt32 size); + RwBool _rwVectorSetMultFn(rwVectorMultFn multPoint, rwVectorsMultFn multPoints, rwVectorMultFn multVector, rwVectorsMultFn multVectors); + void* _rwVectorClose(void* instance, RwInt32 offset, RwInt32 size); + void* _rwVectorOpen(void* instance, RwInt32 offset, RwInt32 size); + RwBool _rwPluginRegistryOpen(); + RwBool _rwPluginRegistryClose(); +} + +STARTPATCHES +InjectHook(0x5BC950, &_rwObjectHasFrameSetFrame, PATCH_JUMP); +InjectHook(0x59E690, &AtomicDefaultRenderCallBack, PATCH_JUMP); +InjectHook(0x59E6C0, &_rpAtomicResyncInterpolatedSphere, PATCH_JUMP); +InjectHook(0x59E800, &RpAtomicGetWorldBoundingSphere, PATCH_JUMP); +InjectHook(0x59ED50, &RpClumpGetNumAtomics, PATCH_JUMP); +InjectHook(0x59ED80, &RpClumpRender, PATCH_JUMP); +InjectHook(0x59EDD0, &RpClumpForAllAtomics, PATCH_JUMP); +InjectHook(0x59EE10, &RpClumpForAllCameras, PATCH_JUMP); +InjectHook(0x59EE60, &RpClumpForAllLights, PATCH_JUMP); +InjectHook(0x59EEB0, &RpAtomicCreate, PATCH_JUMP); +InjectHook(0x59EFA0, &RpAtomicSetGeometry, PATCH_JUMP); +InjectHook(0x59F020, &RpAtomicDestroy, PATCH_JUMP); +InjectHook(0x59F0A0, &RpAtomicClone, PATCH_JUMP); +InjectHook(0x59F1B0, &RpClumpClone, PATCH_JUMP); +InjectHook(0x59F490, &RpClumpCreate, PATCH_JUMP); +InjectHook(0x59F500, &RpClumpDestroy, PATCH_JUMP); +InjectHook(0x59F680, &RpClumpAddAtomic, PATCH_JUMP); +InjectHook(0x59F6B0, &RpClumpRemoveAtomic, PATCH_JUMP); +InjectHook(0x59F6E0, &RpClumpRemoveLight, PATCH_JUMP); +InjectHook(0x59FC50, &RpClumpStreamRead, PATCH_JUMP); +InjectHook(0x5A0510, &RpAtomicRegisterPlugin, PATCH_JUMP); +InjectHook(0x5A0540, &RpClumpRegisterPlugin, PATCH_JUMP); +InjectHook(0x5A0570, &RpAtomicRegisterPluginStream, PATCH_JUMP); +InjectHook(0x5A05A0, &RpAtomicSetStreamAlwaysCallBack, PATCH_JUMP); +InjectHook(0x5A05C0, &RpAtomicSetStreamRightsCallBack, PATCH_JUMP); +InjectHook(0x5A05E0, &RpAtomicGetPluginOffset, PATCH_JUMP); +InjectHook(0x5A0600, &RpAtomicSetFrame, PATCH_JUMP); +InjectHook(0x5A0DC0, &RwEngineRegisterPlugin, PATCH_JUMP); +InjectHook(0x5A0DF0, &RwEngineGetPluginOffset, PATCH_JUMP); +InjectHook(0x5A0E10, &RwEngineGetNumSubSystems, PATCH_JUMP); +InjectHook(0x5A0E40, &RwEngineGetSubSystemInfo, PATCH_JUMP); +InjectHook(0x5A0E70, &RwEngineGetCurrentSubSystem, PATCH_JUMP); +InjectHook(0x5A0EA0, &RwEngineSetSubSystem, PATCH_JUMP); +InjectHook(0x5A0ED0, &RwEngineGetNumVideoModes, PATCH_JUMP); +InjectHook(0x5A0F00, &RwEngineGetVideoModeInfo, PATCH_JUMP); +InjectHook(0x5A0F30, &RwEngineGetCurrentVideoMode, PATCH_JUMP); +InjectHook(0x5A0F60, &RwEngineSetVideoMode, PATCH_JUMP); +InjectHook(0x5A0F90, &RwEngineStop, PATCH_JUMP); +InjectHook(0x5A0FE0, &RwEngineStart, PATCH_JUMP); +InjectHook(0x5A1070, &RwEngineClose, PATCH_JUMP); +InjectHook(0x5A10E0, &RwEngineOpen, PATCH_JUMP); +InjectHook(0x5A1290, &RwEngineTerm, PATCH_JUMP); +InjectHook(0x5A12D0, &RwEngineInit, PATCH_JUMP); +InjectHook(0x5A15E0, &_rwFrameOpen, PATCH_JUMP); +InjectHook(0x5A1650, &_rwFrameClose, PATCH_JUMP); +InjectHook(0x5A1690, &_rwFrameCloneAndLinkClones, PATCH_JUMP); +InjectHook(0x5A1880, &_rwFramePurgeClone, PATCH_JUMP); +InjectHook(0x5A1930, &RwFrameDirty, PATCH_JUMP); +InjectHook(0x5A1950, &_rwFrameInit, PATCH_JUMP); +InjectHook(0x5A1A00, &RwFrameCreate, PATCH_JUMP); +InjectHook(0x5A1A30, &RwFrameDestroy, PATCH_JUMP); +InjectHook(0x5A1BF0, &RwFrameDestroyHierarchy, PATCH_JUMP); +InjectHook(0x5A1C60, &RwFrameUpdateObjects, PATCH_JUMP); +InjectHook(0x5A1CE0, &RwFrameGetLTM, PATCH_JUMP); +InjectHook(0x5A1D00, &RwFrameAddChild, PATCH_JUMP); +InjectHook(0x5A1ED0, &RwFrameRemoveChild, PATCH_JUMP); +InjectHook(0x5A1FC0, &RwFrameForAllChildren, PATCH_JUMP); +InjectHook(0x5A2000, &RwFrameTranslate, PATCH_JUMP); +InjectHook(0x5A20A0, &RwFrameScale, PATCH_JUMP); +InjectHook(0x5A2140, &RwFrameTransform, PATCH_JUMP); +InjectHook(0x5A21E0, &RwFrameRotate, PATCH_JUMP); +InjectHook(0x5A2280, &RwFrameSetIdentity, PATCH_JUMP); +InjectHook(0x5A2340, &RwFrameForAllObjects, PATCH_JUMP); +InjectHook(0x5A2380, &RwFrameRegisterPlugin, PATCH_JUMP); +InjectHook(0x5A23B0, &_rwMatrixSetMultFn, PATCH_JUMP); +InjectHook(0x5A2520, &_rwMatrixDeterminant, PATCH_JUMP); +InjectHook(0x5A2570, &_rwMatrixOrthogonalError, PATCH_JUMP); +InjectHook(0x5A25D0, &_rwMatrixNormalError, PATCH_JUMP); +InjectHook(0x5A2660, &_rwMatrixIdentityError, PATCH_JUMP); +InjectHook(0x5A2730, &_rwMatrixClose, PATCH_JUMP); +InjectHook(0x5A2770, &_rwMatrixOpen, PATCH_JUMP); +InjectHook(0x5A2820, &RwMatrixOptimize, PATCH_JUMP); +InjectHook(0x5A28E0, &RwMatrixUpdate, PATCH_JUMP); +InjectHook(0x5A28F0, &RwMatrixMultiply, PATCH_JUMP); +InjectHook(0x5A2960, &RwMatrixRotateOneMinusCosineSine, PATCH_JUMP); +InjectHook(0x5A2BF0, &RwMatrixRotate, PATCH_JUMP); +InjectHook(0x5A2C90, &RwMatrixInvert, PATCH_JUMP); +InjectHook(0x5A2EE0, &RwMatrixScale, PATCH_JUMP); +InjectHook(0x5A3070, &RwMatrixTranslate, PATCH_JUMP); +InjectHook(0x5A31C0, &RwMatrixTransform, PATCH_JUMP); +InjectHook(0x5A3300, &RwMatrixDestroy, PATCH_JUMP); +InjectHook(0x5A3330, &RwMatrixCreate, PATCH_JUMP); +InjectHook(0x5A3450, &_rwVectorSetMultFn, PATCH_JUMP); +InjectHook(0x5A3600, &_rwV3dNormalize, PATCH_JUMP); +InjectHook(0x5A36A0, &RwV3dLength, PATCH_JUMP); +InjectHook(0x5A3710, &_rwSqrt, PATCH_JUMP); +InjectHook(0x5A3770, &_rwInvSqrt, PATCH_JUMP); +InjectHook(0x5A37D0, &RwV3dTransformPoints, PATCH_JUMP); +InjectHook(0x5A37E0, &RwV3dTransformVectors, PATCH_JUMP); +InjectHook(0x5A37F0, &_rwVectorClose, PATCH_JUMP); +InjectHook(0x5A3860, &_rwVectorOpen, PATCH_JUMP); +InjectHook(0x5A3AD0, &RwStreamRead, PATCH_JUMP); +InjectHook(0x5A3C30, &RwStreamWrite, PATCH_JUMP); +InjectHook(0x5A3DF0, &RwStreamSkip, PATCH_JUMP); +InjectHook(0x5A3F10, &RwStreamClose, PATCH_JUMP); +InjectHook(0x5A3FE0, &RwStreamOpen, PATCH_JUMP); +InjectHook(0x5A43A0, &RwIm2DGetNearScreenZ, PATCH_JUMP); +InjectHook(0x5A43B0, &RwIm2DGetFarScreenZ, PATCH_JUMP); +InjectHook(0x5A43C0, &RwRenderStateSet, PATCH_JUMP); +InjectHook(0x5A4410, &RwRenderStateGet, PATCH_JUMP); +InjectHook(0x5A4420, &RwIm2DRenderLine, PATCH_JUMP); +InjectHook(0x5A4430, &RwIm2DRenderPrimitive, PATCH_JUMP); +InjectHook(0x5A4440, &RwIm2DRenderIndexedPrimitive, PATCH_JUMP); +InjectHook(0x5A5020, &RwCameraEndUpdate, PATCH_JUMP); +InjectHook(0x5A5030, &RwCameraBeginUpdate, PATCH_JUMP); +InjectHook(0x5A5040, &RwCameraSetViewOffset, PATCH_JUMP); +InjectHook(0x5A5070, &RwCameraSetNearClipPlane, PATCH_JUMP); +InjectHook(0x5A5140, &RwCameraSetFarClipPlane, PATCH_JUMP); +InjectHook(0x5A5170, &RwCameraFrustumTestSphere, PATCH_JUMP); +InjectHook(0x5A51E0, &RwCameraClear, PATCH_JUMP); +InjectHook(0x5A5210, &RwCameraShowRaster, PATCH_JUMP); +InjectHook(0x5A5240, &RwCameraSetProjection, PATCH_JUMP); +InjectHook(0x5A52B0, &RwCameraSetViewWindow, PATCH_JUMP); +InjectHook(0x5A52F0, &RwCameraRegisterPlugin, PATCH_JUMP); +InjectHook(0x5A5320, &RwCameraDestroy, PATCH_JUMP); +InjectHook(0x5A5360, &RwCameraCreate, PATCH_JUMP); +InjectHook(0x5A7100, &RwTextureSetMipmapping, PATCH_JUMP); +InjectHook(0x5A7120, &RwTextureGetMipmapping, PATCH_JUMP); +InjectHook(0x5A7130, &RwTextureSetAutoMipmapping, PATCH_JUMP); +InjectHook(0x5A7150, &RwTextureGetAutoMipmapping, PATCH_JUMP); +InjectHook(0x5A7160, &RwTexDictionaryCreate, PATCH_JUMP); +InjectHook(0x5A7200, &RwTexDictionaryDestroy, PATCH_JUMP); +InjectHook(0x5A7290, &RwTexDictionaryForAllTextures, PATCH_JUMP); +InjectHook(0x5A72D0, &RwTextureCreate, PATCH_JUMP); +InjectHook(0x5A7330, &RwTextureDestroy, PATCH_JUMP); +InjectHook(0x5A73B0, &RwTextureSetName, PATCH_JUMP); +InjectHook(0x5A7420, &RwTextureSetMaskName, PATCH_JUMP); +InjectHook(0x5A7490, &RwTexDictionaryAddTexture, PATCH_JUMP); +InjectHook(0x5A74D0, &RwTexDictionaryFindNamedTexture, PATCH_JUMP); +InjectHook(0x5A7550, &RwTexDictionarySetCurrent, PATCH_JUMP); +InjectHook(0x5A7570, &RwTexDictionaryGetCurrent, PATCH_JUMP); +InjectHook(0x5A7580, &RwTextureRead, PATCH_JUMP); +InjectHook(0x5A7780, &RwTextureRasterGenerateMipmaps, PATCH_JUMP); +InjectHook(0x5A9120, &RwImageCreate, PATCH_JUMP); +InjectHook(0x5A9180, &RwImageDestroy, PATCH_JUMP); +InjectHook(0x5A91E0, &RwImageAllocatePixels, PATCH_JUMP); +InjectHook(0x5A92A0, &RwImageFreePixels, PATCH_JUMP); +InjectHook(0x5A92D0, &RwImageMakeMask, PATCH_JUMP); +InjectHook(0x5A93A0, &RwImageApplyMask, PATCH_JUMP); +InjectHook(0x5A9750, &RwImageSetPath, PATCH_JUMP); +InjectHook(0x5A9810, &RwImageRead, PATCH_JUMP); +InjectHook(0x5A9B40, &RwImageFindFileType, PATCH_JUMP); +InjectHook(0x5A9C10, &RwImageReadMaskedImage, PATCH_JUMP); +InjectHook(0x5A9F50, &RwImageCopy, PATCH_JUMP); +InjectHook(0x5AA130, &RwImageGammaCorrect, PATCH_JUMP); +InjectHook(0x5AA2C0, &RwImageSetGamma, PATCH_JUMP); +InjectHook(0x5AA4E0, &_rwStreamWriteVersionedChunkHeader, PATCH_JUMP); +InjectHook(0x5AA540, &RwStreamFindChunk, PATCH_JUMP); +InjectHook(0x5AA640, &RwMemLittleEndian32, PATCH_JUMP); +InjectHook(0x5AA650, &RwMemNative32, PATCH_JUMP); +InjectHook(0x5AA660, &RwMemFloat32ToReal, PATCH_JUMP); +InjectHook(0x5AA680, &RwStreamWriteReal, PATCH_JUMP); +InjectHook(0x5AA720, &RwStreamWriteInt32, PATCH_JUMP); +InjectHook(0x5AA740, &RwStreamReadReal, PATCH_JUMP); +InjectHook(0x5AA7B0, &RwStreamReadInt32, PATCH_JUMP); +InjectHook(0x5AA800, &RwTextureStreamGetSize, PATCH_JUMP); +InjectHook(0x5AA870, &RwTextureStreamWrite, PATCH_JUMP); +InjectHook(0x5AAA40, &RwTextureStreamRead, PATCH_JUMP); +InjectHook(0x5AB020, &RwTexDictionaryStreamWrite, PATCH_JUMP); +InjectHook(0x5AC890, &RpMorphTargetCalcBoundingSphere, PATCH_JUMP); +InjectHook(0x5AC9A0, &RpGeometryAddMorphTargets, PATCH_JUMP); +InjectHook(0x5ACB60, &RpGeometryTriangleSetVertexIndices, PATCH_JUMP); +InjectHook(0x5ACB90, &RpGeometryTriangleSetMaterial, PATCH_JUMP); +InjectHook(0x5ACBF0, &RpGeometryForAllMaterials, PATCH_JUMP); +InjectHook(0x5ACC30, &RpGeometryLock, PATCH_JUMP); +InjectHook(0x5ACC60, &RpGeometryUnlock, PATCH_JUMP); +InjectHook(0x5ACD10, &RpGeometryCreate, PATCH_JUMP); +InjectHook(0x5ACF40, &_rpGeometryAddRef, PATCH_JUMP); +InjectHook(0x5ACF50, &RpGeometryDestroy, PATCH_JUMP); +InjectHook(0x5ACFF0, &RpGeometryRegisterPlugin, PATCH_JUMP); +InjectHook(0x5AD020, &RpGeometryRegisterPluginStream, PATCH_JUMP); +InjectHook(0x5AD050, &RpGeometryStreamRead, PATCH_JUMP); +InjectHook(0x5AD6D0, &RwRasterGetCurrentContext, PATCH_JUMP); +InjectHook(0x5AD6F0, &RwRasterUnlock, PATCH_JUMP); +InjectHook(0x5AD710, &RwRasterRenderFast, PATCH_JUMP); +InjectHook(0x5AD750, &RwRasterUnlockPalette, PATCH_JUMP); +InjectHook(0x5AD780, &RwRasterDestroy, PATCH_JUMP); +InjectHook(0x5AD7C0, &RwRasterPushContext, PATCH_JUMP); +InjectHook(0x5AD810, &RwRasterRegisterPlugin, PATCH_JUMP); +InjectHook(0x5AD840, &RwRasterLockPalette, PATCH_JUMP); +InjectHook(0x5AD870, &RwRasterPopContext, PATCH_JUMP); +InjectHook(0x5AD8C0, &RwRasterGetNumLevels, PATCH_JUMP); +InjectHook(0x5AD900, &RwRasterShowRaster, PATCH_JUMP); +InjectHook(0x5AD930, &RwRasterCreate, PATCH_JUMP); +InjectHook(0x5AD9D0, &RwRasterLock, PATCH_JUMP); +InjectHook(0x5ADC30, &RpMaterialCreate, PATCH_JUMP); +InjectHook(0x5ADCB0, &RpMaterialDestroy, PATCH_JUMP); +InjectHook(0x5ADD10, &RpMaterialSetTexture, PATCH_JUMP); +InjectHook(0x5ADD40, &RpMaterialRegisterPlugin, PATCH_JUMP); +InjectHook(0x5ADD70, &RpMaterialRegisterPluginStream, PATCH_JUMP); +InjectHook(0x5ADDA0, &RpMaterialStreamRead, PATCH_JUMP); +InjectHook(0x5AE0B0, &_rpSectorDefaultRenderCallBack, PATCH_JUMP); +InjectHook(0x5AE100, &_rpWorldForAllGlobalLights, PATCH_JUMP); +InjectHook(0x5AE150, &_rpWorldSectorForAllLocalLights, PATCH_JUMP); +InjectHook(0x5AE190, &RpWorldUnlock, PATCH_JUMP); +InjectHook(0x5AE2B0, &RpWorldSectorGetWorld, PATCH_JUMP); +InjectHook(0x5AE340, &RpWorldDestroy, PATCH_JUMP); +InjectHook(0x5AE6A0, &RpWorldCreate, PATCH_JUMP); +InjectHook(0x5AEA40, &RpWorldRegisterPlugin, PATCH_JUMP); +InjectHook(0x5AEA70, &RpWorldRegisterPluginStream, PATCH_JUMP); +InjectHook(0x5AEAA0, &RpWorldPluginAttach, PATCH_JUMP); +InjectHook(0x5AFB80, &RpWorldAddCamera, PATCH_JUMP); +InjectHook(0x5AFBB0, &RpWorldRemoveCamera, PATCH_JUMP); +InjectHook(0x5AFC10, &RpAtomicGetWorld, PATCH_JUMP); +InjectHook(0x5AFC20, &RpWorldAddClump, PATCH_JUMP); +InjectHook(0x5AFDA0, &RpWorldAddLight, PATCH_JUMP); +InjectHook(0x5AFDF0, &RpWorldRemoveLight, PATCH_JUMP); +InjectHook(0x5AFE70, &RtBMPImageRead, PATCH_JUMP); +InjectHook(0x5B07D0, &RpSkinPluginAttach, PATCH_JUMP); +InjectHook(0x5B1050, &RpSkinAtomicSetHAnimHierarchy, PATCH_JUMP); +InjectHook(0x5B1070, &RpSkinAtomicGetHAnimHierarchy, PATCH_JUMP); +InjectHook(0x5B1080, &RpSkinGeometryGetSkin, PATCH_JUMP); +InjectHook(0x5B1090, &RpSkinGeometrySetSkin, PATCH_JUMP); +InjectHook(0x5B10D0, &RpSkinGetSkinToBoneMatrices, PATCH_JUMP); +InjectHook(0x5B10E0, &RpHAnimHierarchyCreate, PATCH_JUMP); +InjectHook(0x5B11F0, &RpHAnimFrameGetHierarchy, PATCH_JUMP); +InjectHook(0x5B1200, &RpHAnimHierarchySetCurrentAnim, PATCH_JUMP); +InjectHook(0x5B12B0, &RpHAnimHierarchySubAnimTime, PATCH_JUMP); +InjectHook(0x5B1480, &RpHAnimHierarchyAddAnimTime, PATCH_JUMP); +InjectHook(0x5B1780, &RpHAnimHierarchyUpdateMatrices, PATCH_JUMP); +InjectHook(0x5B1C10, &RpHAnimAnimationStreamRead, PATCH_JUMP); +InjectHook(0x5B1D50, &RpHAnimPluginAttach, PATCH_JUMP); +InjectHook(0x5B2640, &RpMatFXPluginAttach, PATCH_JUMP); +InjectHook(0x5B3750, &RpMatFXAtomicEnableEffects, PATCH_JUMP); +InjectHook(0x5B3780, &RpMatFXMaterialSetEffects, PATCH_JUMP); +InjectHook(0x5B38D0, &RpMatFXMaterialSetupEnvMap, PATCH_JUMP); +InjectHook(0x5B3A40, &RpMatFXMaterialSetBumpMapTexture, PATCH_JUMP); +InjectHook(0x5B3CF0, &RwD3D8SetRenderState, PATCH_JUMP); +InjectHook(0x5B3D40, &RwD3D8GetRenderState, PATCH_JUMP); +InjectHook(0x5B3D60, &RwD3D8SetTextureStageState, PATCH_JUMP); +InjectHook(0x5B53A0, &RwD3D8SetTexture, PATCH_JUMP); +InjectHook(0x5B6720, &RwIm3DTransform, PATCH_JUMP); +InjectHook(0x5B67F0, &RwIm3DEnd, PATCH_JUMP); +InjectHook(0x5B6820, &RwIm3DRenderIndexedPrimitive, PATCH_JUMP); +InjectHook(0x5B6980, &RwIm3DRenderLine, PATCH_JUMP); +InjectHook(0x5B6A50, &RwIm3DSetTransformPipeline, PATCH_JUMP); +InjectHook(0x5B6AC0, &RwIm3DSetRenderPipeline, PATCH_JUMP); +InjectHook(0x5B95D0, &RwD3D8EngineSetRefreshRate, PATCH_JUMP); +InjectHook(0x5B9640, &RwD3D8CameraAttachWindow, PATCH_JUMP); +InjectHook(0x5BAEB0, &RwD3D8DeviceSupportsDXTTexture, PATCH_JUMP); +InjectHook(0x5BAF90, &RwD3D8SetVertexShader, PATCH_JUMP); +InjectHook(0x5BAFD0, &RwD3D8SetPixelShader, PATCH_JUMP); +InjectHook(0x5BB010, &RwD3D8SetStreamSource, PATCH_JUMP); +InjectHook(0x5BB060, &RwD3D8SetIndices, PATCH_JUMP); +InjectHook(0x5BB0B0, &RwD3D8DrawIndexedPrimitive, PATCH_JUMP); +InjectHook(0x5BB140, &RwD3D8DrawPrimitive, PATCH_JUMP); +InjectHook(0x5BB1D0, &RwD3D8SetTransform, PATCH_JUMP); +InjectHook(0x5BB310, &RwD3D8GetTransform, PATCH_JUMP); +InjectHook(0x5BB340, &RwD3D8SetTransformWorld, PATCH_JUMP); +InjectHook(0x5BB490, &RwD3D8SetSurfaceProperties, PATCH_JUMP); +InjectHook(0x5BB7A0, &RwD3D8SetLight, PATCH_JUMP); +InjectHook(0x5BB890, &RwD3D8EnableLight, PATCH_JUMP); +InjectHook(0x5BB9F0, &RwD3D8DynamicVertexBufferCreate, PATCH_JUMP); +InjectHook(0x5BBAE0, &RwD3D8DynamicVertexBufferDestroy, PATCH_JUMP); +InjectHook(0x5BBB10, &RwD3D8IndexBufferCreate, PATCH_JUMP); +InjectHook(0x5BBB40, &RwD3D8CreatePixelShader, PATCH_JUMP); +InjectHook(0x5BBB90, &RwD3D8DeletePixelShader, PATCH_JUMP); +InjectHook(0x5BBC00, &RwD3D8SetPixelShaderConstant, PATCH_JUMP); +InjectHook(0x5BBC30, &RwD3D8GetCaps, PATCH_JUMP); +InjectHook(0x5BBC40, &RwD3D8CameraIsSphereFullyInsideFrustum, PATCH_JUMP); +InjectHook(0x5BBCA0, &RwD3D8CameraIsBBoxFullyInsideFrustum, PATCH_JUMP); +InjectHook(0x5BBD30, &RwD3D8DynamicVertexBufferLock, PATCH_JUMP); +InjectHook(0x5BBEB0, &RwD3D8DynamicVertexBufferUnlock, PATCH_JUMP); +InjectHook(0x5BBED0, &_rwIntelSSEsupported, PATCH_JUMP); +InjectHook(0x5BBF10, &RwImageSetFromRaster, PATCH_JUMP); +InjectHook(0x5BBF50, &RwRasterSetFromImage, PATCH_JUMP); +InjectHook(0x5BBF80, &RwImageFindRasterFormat, PATCH_JUMP); +InjectHook(0x5BBFF0, &RwFrameRegisterPluginStream, PATCH_JUMP); +InjectHook(0x5BC020, &_rwFrameListDeinitialize, PATCH_JUMP); +InjectHook(0x5BC050, &_rwFrameListStreamRead, PATCH_JUMP); +InjectHook(0x5BC300, &RpLightSetRadius, PATCH_JUMP); +InjectHook(0x5BC320, &RpLightSetColor, PATCH_JUMP); +InjectHook(0x5BC370, &RpLightGetConeAngle, PATCH_JUMP); +InjectHook(0x5BC5B0, &RpLightRegisterPlugin, PATCH_JUMP); +InjectHook(0x5BC5E0, &RpLightStreamRead, PATCH_JUMP); +InjectHook(0x5BC780, &RpLightDestroy, PATCH_JUMP); +InjectHook(0x5BC7C0, &RpLightCreate, PATCH_JUMP); +InjectHook(0x5BE280, &_rwD3D8TexDictionaryEnableRasterFormatConversion, PATCH_JUMP); +InjectHook(0x5BF110, &RwOsGetFileInterface, PATCH_JUMP); +InjectHook(0x5C1720, &RwFreeListDestroy, PATCH_JUMP); +InjectHook(0x5C1790, &RwFreeListCreate, PATCH_JUMP); +InjectHook(0x5C19F0, &RwFreeListPurge, PATCH_JUMP); +InjectHook(0x5C1B90, &RwFreeListPurgeAllFreeLists, PATCH_JUMP); +InjectHook(0x5C1D40, &RwFreeListForAllUsed, PATCH_JUMP); +InjectHook(0x5C2780, &_rxPipelineClose, PATCH_JUMP); +InjectHook(0x5C27E0, &_rxPipelineOpen, PATCH_JUMP); +InjectHook(0x5C2AD0, &RxHeapGetGlobalHeap, PATCH_JUMP); +InjectHook(0x5C2AE0, &RxPacketCreate, PATCH_JUMP); +InjectHook(0x5C2B10, &RxClusterSetExternalData, PATCH_JUMP); +InjectHook(0x5C2B70, &RxClusterSetData, PATCH_JUMP); +InjectHook(0x5C2BD0, &RxClusterInitializeData, PATCH_JUMP); +InjectHook(0x5C2C40, &RxClusterResizeData, PATCH_JUMP); +InjectHook(0x5C2C90, &RxClusterLockWrite, PATCH_JUMP); +InjectHook(0x5C2D60, &RxPipelineExecute, PATCH_JUMP); +InjectHook(0x5C2E00, &RxPipelineCreate, PATCH_JUMP); +InjectHook(0x5C2E70, &_rxPipelineDestroy, PATCH_JUMP); +InjectHook(0x5C3080, &RwResourcesFreeResEntry, PATCH_JUMP); +InjectHook(0x5C30F0, &_rwResourcesPurge, PATCH_JUMP); +InjectHook(0x5C3170, &RwResourcesAllocateResEntry, PATCH_JUMP); +InjectHook(0x5C3360, &RwResourcesEmptyArena, PATCH_JUMP); +InjectHook(0x5C3450, &_rwPluginRegistryOpen, PATCH_JUMP); +InjectHook(0x5C3480, &_rwPluginRegistryClose, PATCH_JUMP); +InjectHook(0x5C3590, &_rwPluginRegistryGetPluginOffset, PATCH_JUMP); +InjectHook(0x5C35C0, &_rwPluginRegistryAddPlugin, PATCH_JUMP); +InjectHook(0x5C37F0, &_rwPluginRegistryInitObject, PATCH_JUMP); +InjectHook(0x5C3850, &_rwPluginRegistryDeInitObject, PATCH_JUMP); +InjectHook(0x5C3880, &_rwPluginRegistryCopyObject, PATCH_JUMP); +InjectHook(0x5C3910, &RwErrorSet, PATCH_JUMP); +InjectHook(0x5C3970, &_rwerror, PATCH_JUMP); +InjectHook(0x5C3980, &_rwPluginRegistryAddPluginStream, PATCH_JUMP); +InjectHook(0x5C39C0, &_rwPluginRegistryAddPlgnStrmlwysCB, PATCH_JUMP); +InjectHook(0x5C39F0, &_rwPluginRegistryAddPlgnStrmRightsCB, PATCH_JUMP); +InjectHook(0x5C3A20, & _rwPluginRegistryReadDataChunks, PATCH_JUMP); +InjectHook(0x5C3B50, & _rwPluginRegistryInvokeRights, PATCH_JUMP); +InjectHook(0x5C3BA0, &_rwPluginRegistryGetSize, PATCH_JUMP); +InjectHook(0x5C3BE0, &_rwPluginRegistryWriteDataChunks, PATCH_JUMP); +InjectHook(0x5C3CB0, &_rwPluginRegistrySkipDataChunks, PATCH_JUMP); +InjectHook(0x5C3D30, &RwCameraStreamRead, PATCH_JUMP); +InjectHook(0x5C5570, &RwBBoxCalculate, PATCH_JUMP); +InjectHook(0x5C72B0, &RwImageResample, PATCH_JUMP); +InjectHook(0x5C7B30, &RwImageCreateResample, PATCH_JUMP); +InjectHook(0x5D9240, &RxRenderStateVectorSetDefaultRenderStateVector, PATCH_JUMP); +InjectHook(0x5D9340, &RxRenderStateVectorCreate, PATCH_JUMP); +InjectHook(0x5D9410, &RxRenderStateVectorDestroy, PATCH_JUMP); +InjectHook(0x5D9460, &RxRenderStateVectorLoadDriverState, PATCH_JUMP); +InjectHook(0x5D95D0, &_rxEmbeddedPacketBetweenPipelines, PATCH_JUMP); +InjectHook(0x5D9740, &_rxEmbeddedPacketBetweenNodes, PATCH_JUMP); +InjectHook(0x5D9810, &_rxPacketDestroy, PATCH_JUMP); +InjectHook(0x5C8B10, &_rpMaterialListDeinitialize, PATCH_JUMP); +InjectHook(0x5C8B70, &_rpMaterialListInitialize, PATCH_JUMP); +InjectHook(0x5C8B80, &_rpMaterialListGetMaterial, PATCH_JUMP); +InjectHook(0x5C8B90, &_rpMaterialListAppendMaterial, PATCH_JUMP); +InjectHook(0x5C8C50, &_rpMaterialListFindMaterialIndex, PATCH_JUMP); +InjectHook(0x5C8C80, &_rpMaterialListStreamRead, PATCH_JUMP); +InjectHook(0x5C8FE0, &_rpMeshHeaderCreate, PATCH_JUMP); +InjectHook(0x5C8FF0, &_rpMeshClose, PATCH_JUMP); +InjectHook(0x5C9020, &_rpMeshOpen, PATCH_JUMP); +InjectHook(0x5C9140, &_rpBuildMeshCreate, PATCH_JUMP); +InjectHook(0x5C9220, &_rpBuildMeshDestroy, PATCH_JUMP); +InjectHook(0x5C9260, &_rpMeshDestroy, PATCH_JUMP); +InjectHook(0x5C92A0, &_rpBuildMeshAddTriangle, PATCH_JUMP); +InjectHook(0x5C9380, &_rpMeshHeaderForAllMeshes, PATCH_JUMP); +InjectHook(0x5C93C0, &_rpMeshWrite, PATCH_JUMP); +InjectHook(0x5C9510, &_rpMeshRead, PATCH_JUMP); +InjectHook(0x5C96E0, &_rpMeshSize, PATCH_JUMP); +InjectHook(0x5C9730, &RpBuildMeshGenerateDefaultTriStrip, PATCH_JUMP); +InjectHook(0x5CAE10, &_rpTriListMeshGenerate, PATCH_JUMP); +InjectHook(0x5CB230, &_rpMeshOptimise, PATCH_JUMP); +InjectHook(0x5CB2B0, &RpWorldSectorRegisterPlugin, PATCH_JUMP); +InjectHook(0x5CB2E0, &RpWorldSectorRegisterPluginStream, PATCH_JUMP); +InjectHook(0x5CB630, &RpWorldSetDefaultSectorPipeline, PATCH_JUMP); +InjectHook(0x5CB670, &RpAtomicSetDefaultPipeline, PATCH_JUMP); +InjectHook(0x5CDEE0, &RpHAnimStdKeyFrameToMatrix, PATCH_JUMP); +InjectHook(0x5CE000, &RpHAnimStdKeyFrameInterpolate, PATCH_JUMP); +InjectHook(0x5CE420, &RpHAnimStdKeyFrameBlend, PATCH_JUMP); +InjectHook(0x5CE820, &RpHAnimStdKeyFrameStreamRead, PATCH_JUMP); +InjectHook(0x5CE8C0, &RpHAnimStdKeyFrameStreamWrite, PATCH_JUMP); +InjectHook(0x5CE930, &RpHAnimStdKeyFrameStreamGetSize, PATCH_JUMP); +InjectHook(0x5CE950, &RpHAnimStdKeyFrameMulRecip, PATCH_JUMP); +InjectHook(0x5CEAB0, &RpHAnimStdKeyFrameAdd, PATCH_JUMP); +InjectHook(0x5D1070, &RxHeapFree, PATCH_JUMP); +InjectHook(0x5D1260, &RxHeapAlloc, PATCH_JUMP); +InjectHook(0x5D14D0, &RxHeapRealloc, PATCH_JUMP); +InjectHook(0x5D1680, &_rxHeapReset, PATCH_JUMP); +InjectHook(0x5D16F0, &RxHeapDestroy, PATCH_JUMP); +InjectHook(0x5D1750, &RxHeapCreate, PATCH_JUMP); +InjectHook(0x5D1EC0, &RxPipelineNodeFindOutputByName, PATCH_JUMP); +InjectHook(0x5D1F20, &RxPipelineNodeFindInput, PATCH_JUMP); +InjectHook(0x5D1F30, &RxPipelineNodeRequestCluster, PATCH_JUMP); +InjectHook(0x5D1FA0, &RxLockedPipeUnlock, PATCH_JUMP); +InjectHook(0x5D29F0, &RxPipelineLock, PATCH_JUMP); +InjectHook(0x5D2B10, &RxPipelineFindNodeByName, PATCH_JUMP); +InjectHook(0x5D2BA0, &RxLockedPipeAddFragment, PATCH_JUMP); +InjectHook(0x5D2EE0, &RxLockedPipeAddPath, PATCH_JUMP); +InjectHook(0x5D31C0, &RxNodeDefinitionGetImmRenderSetup, PATCH_JUMP); +InjectHook(0x5D35C0, &RxNodeDefinitionGetImmMangleTriangleIndices, PATCH_JUMP); +InjectHook(0x5D3C60, &RxNodeDefinitionGetCullTriangle, PATCH_JUMP); +InjectHook(0x5D4F80, &RxNodeDefinitionGetClipTriangle, PATCH_JUMP); +InjectHook(0x5D51C0, &RxNodeDefinitionGetSubmitTriangle, PATCH_JUMP); +InjectHook(0x5D5400, &RxNodeDefinitionGetImmInstance, PATCH_JUMP); +InjectHook(0x5D6000, &RxNodeDefinitionGetTransform, PATCH_JUMP); +InjectHook(0x5D61C0, &RxNodeDefinitionGetImmStash, PATCH_JUMP); +InjectHook(0x5D6470, &RxNodeDefinitionGetImmMangleLineIndices, PATCH_JUMP); +InjectHook(0x5D7230, &RxNodeDefinitionGetClipLine, PATCH_JUMP); +InjectHook(0x5D74C0, &RxNodeDefinitionGetSubmitLine, PATCH_JUMP); +InjectHook(0x5D9C90, &_rwD3D8LightsOpen, PATCH_JUMP); +InjectHook(0x5D9EF0, &_rwD3D8LightsClose, PATCH_JUMP); +InjectHook(0x5D9F80, &_rwD3D8LightsGlobalEnable, PATCH_JUMP); +InjectHook(0x5DA210, &_rwD3D8LightLocalEnable, PATCH_JUMP); +InjectHook(0x5DA450, &_rwD3D8LightsEnable, PATCH_JUMP); +InjectHook(0x5DAAC0, &RxNodeDefinitionGetD3D8WorldSectorAllInOne, PATCH_JUMP); +InjectHook(0x5DC500, &RxNodeDefinitionGetD3D8AtomicAllInOne, PATCH_JUMP); +InjectHook(0x5DCC50, &RxNodeDefinitionGetWorldSectorInstance, PATCH_JUMP); +InjectHook(0x5DCD80, &RxNodeDefinitionGetWorldSectorEnumerateLights, PATCH_JUMP); +InjectHook(0x5DD800, &RxNodeDefinitionGetAtomicInstance, PATCH_JUMP); +InjectHook(0x5DD9B0, &RxNodeDefinitionGetAtomicEnumerateLights, PATCH_JUMP); +InjectHook(0x5DDAA0, &RxNodeDefinitionGetMaterialScatter, PATCH_JUMP); +InjectHook(0x5DF040, &RxNodeDefinitionGetLight, PATCH_JUMP); +InjectHook(0x5DF560, &RxNodeDefinitionGetPostLight, PATCH_JUMP); +InjectHook(0x5DFC60, &RxD3D8AllInOneSetRenderCallBack, PATCH_JUMP); +ENDPATCHES +#endif \ No newline at end of file -- cgit v1.2.3 From f2995640bd29157d28c17b4dacab93cad05eadc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Fri, 10 Apr 2020 18:06:49 +0300 Subject: CMenuManager done and CHud fixes --- README.md | 1 - gamefiles/menu.txd | Bin 10244648 -> 10244648 bytes src/core/Frontend.cpp | 1689 ++++++++++++++++++++++++++++++++-------------- src/core/Frontend.h | 94 +-- src/core/MenuScreens.h | 189 +++--- src/core/Radar.cpp | 8 +- src/core/Timer.cpp | 32 +- src/core/Timer.h | 4 + src/core/re3.cpp | 2 + src/peds/CivilianPed.cpp | 12 +- src/render/Hud.cpp | 279 ++++---- src/render/Hud.h | 73 +- 12 files changed, 1578 insertions(+), 805 deletions(-) diff --git a/README.md b/README.md index 9237e8e3..88d99dcd 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,6 @@ to reverse at the time, calling the original functions is acceptable. cAudioManager - WIP CBoat CBulletInfo -CMenuManager - WIP CObject CPacManPickups CPedPath diff --git a/gamefiles/menu.txd b/gamefiles/menu.txd index 8ca5de16..f617bcf8 100644 Binary files a/gamefiles/menu.txd and b/gamefiles/menu.txd differ diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index beebacf9..a0b70f27 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -8,6 +8,7 @@ #include "Pad.h" #include "Text.h" #include "main.h" +#include "RwHelper.h" #include "Timer.h" #include "Game.h" #include "DMAudio.h" @@ -28,14 +29,31 @@ #include "Renderer.h" #include "CdStream.h" #include "Radar.h" +#include "Stats.h" +#include "Messages.h" -#define DONT_USE_SUSPICIOUS_FUNCS 1 #define TIDY_UP_PBP // ProcessButtonPresses #define MAX_VISIBLE_LIST_ROW 30 -#define SCROLLBAR_MAX_HEIGHT 263.0f // actually it's 273. but calculating it from scrollbar drawing code gives 287. i don't know +#define SCROLLBAR_MAX_HEIGHT 263.0f // not in end result + +#ifdef USE_PRECISE_MEASUREMENT_CONVERTION +#define MILES_IN_METER 0.000621371192f +#define FEET_IN_METER 3.28084f +#else +#define MILES_IN_METER 0.00059880241f +#define FEET_IN_METER 3.33f +#endif + +#define SCROLLABLE_STATS_PAGE +#ifdef SCROLLABLE_STATS_PAGE +#define isPlainTextScreen(screen) (screen == MENUPAGE_BRIEFS) +#else +#define isPlainTextScreen(screen) (screen == MENUPAGE_BRIEFS || screen == MENUPAGE_STATS) +#endif #ifdef MENU_MAP bool CMenuManager::bMenuMapActive = false; +bool CMenuManager::bMapMouseShownOnce = false; float CMenuManager::fMapSize; float CMenuManager::fMapCenterY; float CMenuManager::fMapCenterX; @@ -63,6 +81,7 @@ int8 &CMenuManager::m_PrefsSpeakers = *(int8*)0x95CD7E; int32 &CMenuManager::m_ControlMethod = *(int32*)0x8F5F7C; int8 &CMenuManager::m_PrefsDMA = *(int8*)0x5F2F74; // 1 int32 &CMenuManager::m_PrefsLanguage = *(int32*)0x941238; +uint8 CMenuManager::m_PrefsStereoMono; // *(bool*)0x95CDB5; // unused except restore settings bool &CMenuManager::m_PrefsAllowNastyGame = *(bool*)0x5F2E64; // true bool &CMenuManager::m_bStartUpFrontEndRequested = *(bool*)0x95CCF4; @@ -80,26 +99,37 @@ char *CMenuManager::m_PrefsSkinFile = (char*)0x5F2E74; //[256] "$$\"\"" int32 &CMenuManager::m_KeyPressedCode = *(int32*)0x5F2E70; // -1 -float &CMenuManager::menuXYpadding = *(float*)0x5F355C; // don't know the original name. MENUACTION_X_MARGIN, never changes -float &CMenuManager::actionTextScaleX = *(float*)0x5F2E40; -float &CMenuManager::actionTextScaleY = *(float*)0x5F2E44; +// This is PS2 option color, they forget it here and used in PrintBriefs once(but didn't use the output anyway) +#ifdef FIX_BUGS +CRGBA TEXT_COLOR = CRGBA(235, 170, 50, 255); // PC briefs text color +#else +CRGBA TEXT_COLOR = CRGBA(150, 110, 30, 255); +#endif + +float menuXYpadding = MENUACTION_POS_Y; // *(float*)0x5F355C; // never changes. not original name +float MENU_TEXT_SIZE_X = SMALLTEXT_X_SCALE; //*(float*)0x5F2E40; +float MENU_TEXT_SIZE_Y = SMALLTEXT_Y_SCALE; //*(float*)0x5F2E44; + +bool holdingScrollBar; // *(bool*)0x628D59; // not original name +int32 CMenuManager::m_SelectedMap; // *(int32*)0x8E2880; +int32 CMenuManager::m_SelectedGameType; // *(int32*)0x942F88; -int32 &CMenuManager::sthWithButtons = *(int32*)0x8E2880; -int32 &CMenuManager::sthWithButtons2 = *(int32*)0x942F88; +// Used in a hidden menu +uint8 CMenuManager::m_PrefsPlayerRed = 255; +uint8 CMenuManager::m_PrefsPlayerGreen = 128; +uint8 CMenuManager::m_PrefsPlayerBlue; // why?? CMenuManager &FrontEndMenuManager = *(CMenuManager*)0x8F59D8; // Move this somewhere else. float &CRenderer::ms_lodDistScale = *(float*)0x5F726C; // 1.2 -// Stuff not in CMenuManager: uint32 &TimeToStopPadShaking = *(uint32*)0x628CF8; char *&pEditString = *(char**)0x628D00; int32 *&pControlEdit = *(int32**)0x628D08; bool &DisplayComboButtonErrMsg = *(bool*)0x628D14; int32 &MouseButtonJustClicked = *(int32*)0x628D0C; int32 &JoyButtonJustClicked = *(int32*)0x628D10; -bool &holdingScrollBar = *(bool*)0x628D59; //int32 *pControlTemp = 0; #ifndef MASTER @@ -204,8 +234,6 @@ ScaleAndCenterX(float x) #define MENU_Y(y) StretchY(y) #endif -#define isPlainTextScreen(screen) (screen == MENUPAGE_BRIEFS || screen == MENUPAGE_STATS) - #ifdef PS2_LIKE_MENU #define ChangeScreen(screen, option, updateDelay, withReverseAlpha) \ do { \ @@ -245,14 +273,14 @@ ScaleAndCenterX(float x) #define ProcessSlider(value, increaseAction, decreaseAction, hoverStartX, hoverEndX) \ do { \ - lastBarX = DisplaySlider(SCREEN_STRETCH_FROM_RIGHT(MENUSLIDER_X + columnWidth), MENU_Y(bitAboveNextItemY), MENU_Y(smallestSliderBar), MENU_Y(usableLineHeight), MENU_X(MENUSLIDER_UNK), value); \ + lastActiveBarX = DisplaySlider(SCREEN_STRETCH_FROM_RIGHT(MENUSLIDER_X + columnWidth), MENU_Y(bitAboveNextItemY), MENU_Y(smallestSliderBar), MENU_Y(usableLineHeight), MENU_X(MENUSLIDER_UNK), value); \ if (i != m_nCurrOption || !itemsAreSelectable) \ break; \ \ - if (CheckHover(hoverStartX, lastBarX - MENU_X(10.0f), MENU_Y(nextYToUse), MENU_Y(28.0f + nextYToUse))) \ + if (CheckHover(hoverStartX, lastActiveBarX - MENU_X(10.0f), MENU_Y(nextYToUse), MENU_Y(28.0f + nextYToUse))) \ m_nHoverOption = decreaseAction; \ \ - if (!CheckHover(MENU_X(10.0f) + lastBarX, hoverEndX, MENU_Y(nextYToUse), MENU_Y(28.0f + nextYToUse))) \ + if (!CheckHover(MENU_X(10.0f) + lastActiveBarX, hoverEndX, MENU_Y(nextYToUse), MENU_Y(28.0f + nextYToUse))) \ break; \ \ m_nHoverOption = increaseAction; \ @@ -331,6 +359,11 @@ CMenuManager::PageDownList(bool playSoundOnSuccess) inline void CMenuManager::ThingsToDoBeforeLeavingPage() { +#ifndef MASTER + if (m_nCurrScreen == MENUPAGE_NO_MEMORY_CARD || m_nCurrScreen == MENUPAGE_MEMORY_CARD_DEBUG) { + SaveSettings(); + } +#endif if ((m_nCurrScreen == MENUPAGE_SKIN_SELECT) && strcmp(m_aSkinName, m_PrefsSkinFile) != 0) { CWorld::Players[0].SetPlayerSkin(m_PrefsSkinFile); } else if (m_nCurrScreen == MENUPAGE_SOUND_SETTINGS) { @@ -356,18 +389,18 @@ CMenuManager::ThingsToDoBeforeLeavingPage() // ------ Functions not in the game/inlined ends void -CMenuManager::BuildStatLine(char *text, void *stat, uint8 aFloat, void *stat2) +CMenuManager::BuildStatLine(char *text, void *stat, bool itsFloat, void *stat2) { if (!text) return; if (stat2) { - if (aFloat) + if (itsFloat) sprintf(gString2, " %.2f %s %.2f", *(float*)stat, UnicodeToAscii(TheText.Get("FEST_OO")), *(float*)stat2); else sprintf(gString2, " %d %s %d", *(int*)stat, UnicodeToAscii(TheText.Get("FEST_OO")), *(int*)stat2); } else if (stat) { - if (aFloat) + if (itsFloat) sprintf(gString2, " %.2f", *(float*)stat); else sprintf(gString2, " %d", *(int*)stat); @@ -378,10 +411,8 @@ CMenuManager::BuildStatLine(char *text, void *stat, uint8 aFloat, void *stat2) AsciiToUnicode(gString2, gUString2); } -#if 0 -WRAPPER void CMenuManager::CentreMousePointer() { EAXJMP(0x48ACE0); } -#else -void CMenuManager::CentreMousePointer() +void +CMenuManager::CentreMousePointer() { tagPOINT Point; @@ -395,28 +426,85 @@ void CMenuManager::CentreMousePointer() PSGLOBAL(lastMousePos.y) = SCREEN_HEIGHT / 2; } } -#endif -#if 1 -WRAPPER int CMenuManager::CheckCodesForControls(int32) { EAXJMP(0x48A950); } -#else -void CMenuManager::CheckCodesForControls(int, int) +void +CMenuManager::CheckCodesForControls(int typeOfControl) { - DisplayComboButtonErrMsg = 0; + DisplayComboButtonErrMsg = false; + bool invalidKey = false; + bool escPressed = false; + eControllerType typeToSave; + // GetStartOptionsCntrlConfigScreens(); + e_ControllerAction action = (e_ControllerAction) m_CurrCntrlAction; + + if (typeOfControl == KEYBOARD) { + if (*pControlEdit == rsESC) { + escPressed = true; + } else if (*pControlEdit > rsF3 && *pControlEdit != rsF9 && *pControlEdit != rsLWIN && + *pControlEdit != rsRWIN && *pControlEdit != rsRALT) { + typeToSave = KEYBOARD; + if (ControlsManager.GetControllerKeyAssociatedWithAction(action, KEYBOARD) != rsNULL && + *pControlEdit != ControlsManager.GetControllerKeyAssociatedWithAction(action, KEYBOARD)) { + typeToSave = OPTIONAL_EXTRA; + } + } else { + invalidKey = true; + } + } else if (typeOfControl == MOUSE) { + typeToSave = MOUSE; + } else if (typeOfControl == JOYSTICK) { + typeToSave = JOYSTICK; + if (ControlsManager.GetIsActionAButtonCombo(action)) + DisplayComboButtonErrMsg = true; + } + + ControlsManager.ClearSettingsAssociatedWithAction(action, typeToSave); + if (!DisplayComboButtonErrMsg && !escPressed && !invalidKey) { + if (typeOfControl == KEYBOARD) { + ControlsManager.DeleteMatchingActionInitiators(action, *pControlEdit, KEYBOARD); + ControlsManager.DeleteMatchingActionInitiators(action, *pControlEdit, OPTIONAL_EXTRA); + } else { + if (typeOfControl == MOUSE) { + ControlsManager.DeleteMatchingActionInitiators(action, MouseButtonJustClicked, MOUSE); + } else if (typeOfControl == JOYSTICK) { + ControlsManager.DeleteMatchingActionInitiators(action, JoyButtonJustClicked, JOYSTICK); + } + } + if (typeOfControl == KEYBOARD) { + ControlsManager.SetControllerKeyAssociatedWithAction(action, *pControlEdit, typeToSave); + + } else if (typeOfControl == MOUSE) { + ControlsManager.SetControllerKeyAssociatedWithAction(action, MouseButtonJustClicked, typeToSave); + } else { + if (typeOfControl == JOYSTICK) { + ControlsManager.SetControllerKeyAssociatedWithAction(action, JoyButtonJustClicked, typeToSave); + } + } + pControlEdit = nil; + m_bWaitingForNewKeyBind = false; + m_KeyPressedCode = -1; + m_bStartWaitingForKeyBind = false; + SaveSettings(); + } + + if (escPressed) { + pControlEdit = nil; + m_bWaitingForNewKeyBind = false; + m_KeyPressedCode = -1; + m_bStartWaitingForKeyBind = false; + SaveSettings(); + } } -#endif -#if 0 -WRAPPER bool CMenuManager::CheckHover(int, int, int, int) { EAXJMP(0x48ACA0); } -#else -bool CMenuManager::CheckHover(int x1, int x2, int y1, int y2) +bool +CMenuManager::CheckHover(int x1, int x2, int y1, int y2) { return m_nMousePosX > x1 && m_nMousePosX < x2 && m_nMousePosY > y1 && m_nMousePosY < y2; } -#endif -void CMenuManager::CheckSliderMovement(int value) +void +CMenuManager::CheckSliderMovement(int value) { switch (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action) { case MENUACTION_BRIGHTNESS: @@ -452,103 +540,106 @@ void CMenuManager::CheckSliderMovement(int value) SaveSettings(); } -#if 1 -WRAPPER int CMenuManager::CostructStatLine(int) { EAXJMP(0x482800); } -#else -int CMenuManager::CostructStatLine(int) +void +CMenuManager::DisplayHelperText() { + // there was a unused static bool + static uint32 LastFlash = 0; + int32 alpha; -} -#endif + if (m_nHelperTextMsgId != 0 && m_nHelperTextMsgId != 1) { -#if DONT_USE_SUSPICIOUS_FUNCS -WRAPPER void CMenuManager::DisplayHelperText() { EAXJMP(0x48B490); } -#else -void CMenuManager::DisplayHelperText() -{ - static int32 AlphaText = 255; - static int32 Time = 0; - - if (m_nHelperTextMsgId && m_nHelperTextMsgId != 1) { - if (CTimer::GetTimeInMillisecondsPauseMode() - Time > 10) { - Time = CTimer::GetTimeInMillisecondsPauseMode(); + // FIX: High fps bug +#ifndef FIX_BUGS + if (CTimer::GetTimeInMillisecondsPauseMode() - LastFlash > 10) { + LastFlash = CTimer::GetTimeInMillisecondsPauseMode(); m_nHelperTextAlpha -= 2; + } +#else + static float fadeAlpha = 0.0f; // To keep it precisely + if (m_nHelperTextAlpha >= 255 && fadeAlpha < 250) fadeAlpha = m_nHelperTextAlpha; - if (AlphaText < 1) - ResetHelperText(); + // -2 per every 33 ms (1000.f/30.f - original frame limiter fps) + fadeAlpha -= (frameTime / 33.0f) * 2.0f; + m_nHelperTextAlpha = fadeAlpha; +#endif + if (m_nHelperTextAlpha < 1) + ResetHelperText(); - AlphaText = m_nHelperTextAlpha > 255 ? 255 : m_nHelperTextAlpha; - } + alpha = m_nHelperTextAlpha > 255 ? 255 : m_nHelperTextAlpha; } - wchar *HelperTextToPrint = nil; + CFont::SetCentreOn(); + CFont::SetScale(SCREEN_SCALE_X(SMALLESTTEXT_X_SCALE), SCREEN_SCALE_Y(SMALLESTTEXT_Y_SCALE)); + CFont::SetFontStyle(FONT_HEADING); + // TODO: name this cases? switch (m_nHelperTextMsgId) { - case 0: - HelperTextToPrint = TheText.Get("FET_MIG"); - break; - case 1: - HelperTextToPrint = TheText.Get("FET_APP"); - break; - case 2: - HelperTextToPrint = TheText.Get("FET_HRD"); - break; - case 3: - HelperTextToPrint = TheText.Get("FET_RSO"); - break; - case 4: - HelperTextToPrint = TheText.Get("FET_RSC"); - break; - default: - break; + case 0: + { + int action = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action; + if (action != MENUACTION_CHANGEMENU && action != MENUACTION_REDEFCTRL && action != MENUACTION_RESTOREDEF) { + CFont::SetColor(CRGBA(255, 255, 255, 255)); + CFont::PrintString(MENU_X_LEFT_ALIGNED(320.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f), TheText.Get("FET_MIG")); + } + break; + } + case 1: + CFont::SetColor(CRGBA(255, 255, 255, 255)); + CFont::PrintString(MENU_X_LEFT_ALIGNED(320.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f), TheText.Get("FET_APP")); + break; + case 2: + CFont::SetColor(CRGBA(255, 255, 255, alpha)); + CFont::PrintString(MENU_X_LEFT_ALIGNED(320.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f), TheText.Get("FET_HRD")); + break; + case 3: + CFont::SetColor(CRGBA(255, 255, 255, alpha)); + CFont::PrintString(MENU_X_LEFT_ALIGNED(320.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f), TheText.Get("FET_RSO")); + break; + case 4: + CFont::SetColor(CRGBA(255, 255, 255, alpha)); + CFont::PrintString(MENU_X_LEFT_ALIGNED(320.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f), TheText.Get("FET_RSC")); + break; + default: + break; } - - CFont::SetAlignment(ALIGN_CENTER); - CFont::SetScale(SCREEN_SCALE_X(0.4f), SCREEN_SCALE_Y(0.6f)); - CFont::SetFontStyle(FONT_HEADING); - CFont::SetDropColor(CRGBA(0, 0, 0, AlphaText)); - CFont::SetDropShadowPosition(MENUDROP_COLOR_SIZE); - CFont::SetColor(CRGBA(255, 255, 255, AlphaText)); - - CFont::PrintString(SCREEN_WIDTH / 2, SCREEN_SCALE_FROM_BOTTOM(120.0f), HelperTextToPrint); + CFont::SetRightJustifyOff(); } -#endif -#if DONT_USE_SUSPICIOUS_FUNCS -WRAPPER int CMenuManager::DisplaySlider(float, float, float, float, float, float) { EAXJMP(0x488420); } -#else -int CMenuManager::DisplaySlider(float x, float y, float leftSize, float rightSize, float rectSize, float progress) +int +CMenuManager::DisplaySlider(float x, float y, float mostLeftBarSize, float mostRightBarSize, float rectSize, float progress) { CRGBA color; - float sizeRange; + float maxBarHeight; - float input = 0.0f; + int lastActiveBarX = 0; + float curBarX = 0.0f; + float spacing = SCREEN_SCALE_X(10.0f); for (int i = 0; i < 16; i++) { - input = i * rectSize/16.0f + x; + curBarX = i * rectSize/16.0f + x; - if (i/16.0f + 1/32.0f < progress) + if (i / 16.0f + 1 / 32.0f < progress) { color = CRGBA(255, 217, 106, FadeIn(255)); - else + lastActiveBarX = curBarX; + } else color = CRGBA(185, 120, 0, FadeIn(255)); - sizeRange = max(leftSize, rightSize); + maxBarHeight = max(mostLeftBarSize, mostRightBarSize); - float _x = i * rectSize/16.0f + x; - float _y = y + sizeRange - ((16 - i) * leftSize + i * rightSize)/16.0f; - float _w = SCREEN_SCALE_X(10.0f) + i * rectSize/16.0f + x; - float _h = y + sizeRange; - float _s = SCREEN_SCALE_X(2.0f); - CSprite2d::DrawRect(CRect(_x + _s, _y + _s, _w + _s, _h + _s), CRGBA(0, 0, 0, FadeIn(255))); // Shadow - CSprite2d::DrawRect(CRect(i * rectSize/16.0f + x, y + sizeRange - ((16 - i) * leftSize + i * rightSize)/16.0f, SCREEN_SCALE_X(10.0f) + i * rectSize/16.0f + x, y + sizeRange), color); + float curBarFreeSpace = ((16 - i) * mostLeftBarSize + i * mostRightBarSize) / 16.0f; + float left = curBarX; + float top = y + maxBarHeight - curBarFreeSpace; + float right = spacing + curBarX; + float bottom = y + maxBarHeight; + float shadowOffset = SCREEN_SCALE_X(2.0f); + CSprite2d::DrawRect(CRect(left + shadowOffset, top + shadowOffset, right + shadowOffset, bottom + shadowOffset), CRGBA(0, 0, 0, FadeIn(200))); // Shadow + CSprite2d::DrawRect(CRect(left, top, right, bottom), color); } - return input; + return lastActiveBarX; } -#endif -#if 0 -WRAPPER void CMenuManager::DoSettingsBeforeStartingAGame() { EAXJMP(0x48AB40); } -#else -void CMenuManager::DoSettingsBeforeStartingAGame() +void +CMenuManager::DoSettingsBeforeStartingAGame() { CCamera::m_bUseMouse3rdPerson = m_ControlMethod == CONTROL_STANDARD; if (m_PrefsVsyncDisp != m_PrefsVsync) @@ -563,19 +654,16 @@ void CMenuManager::DoSettingsBeforeStartingAGame() DMAudio.SetMusicFadeVol(0); DMAudio.ResetTimers(CTimer::GetTimeInMilliseconds()); } -#endif -#if 0 -WRAPPER void CMenuManager::Draw() { EAXJMP(0x47AE00); } -#else -void CMenuManager::Draw() +void +CMenuManager::Draw() { CFont::SetBackgroundOff(); CFont::SetPropOn(); CFont::SetCentreOff(); CFont::SetJustifyOn(); CFont::SetBackGroundOnlyTextOn(); - CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(MENUACTION_X_MARGIN)); + CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(MENU_X_MARGIN)); CFont::SetRightJustifyWrap(SCREEN_SCALE_X(MENUACTION_WIDTH)); switch (m_nCurrScreen) { @@ -617,8 +705,8 @@ void CMenuManager::Draw() } CFont::SetFontStyle(FONT_BANK); - CFont::SetScale(MENU_X(MENUACTION_SCALE_MULT * actionTextScaleX), MENU_Y(MENUACTION_SCALE_MULT * actionTextScaleY)); - CFont::SetRightJustifyOff(); // AG used SetAlignment(ALIGN_LEFT); + CFont::SetScale(MENU_X(MENUACTION_SCALE_MULT * MENU_TEXT_SIZE_X), MENU_Y(MENUACTION_SCALE_MULT * MENU_TEXT_SIZE_Y)); + CFont::SetRightJustifyOff(); CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255))); // Label @@ -631,6 +719,13 @@ void CMenuManager::Draw() else str = TheText.Get(aScreens[m_nCurrScreen].m_aEntries[0].m_EntryName); break; +#ifndef MASTER + case MENUPAGE_NO_MEMORY_CARD: + case MENUPAGE_MEMORY_CARD_DEBUG: + CFont::SetColor(CRGBA(235, 170, 50, FadeIn(127))); // white in mobile, because all texts are white there + str = TheText.Get(aScreens[m_nCurrScreen].m_aEntries[0].m_EntryName); + break; +#endif case MENUPAGE_SAVE_OVERWRITE_CONFIRM: if (Slots[m_nCurrSaveSlot + 1] == SLOT_EMPTY) str = TheText.Get("FESZ_QZ"); @@ -648,12 +743,20 @@ void CMenuManager::Draw() break; } +#ifndef MASTER + if (m_nCurrScreen == MENUPAGE_NO_MEMORY_CARD || m_nCurrScreen == MENUPAGE_MEMORY_CARD_DEBUG) { + // CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(MENU_X_MARGIN)); // it's always like that on PC + CFont::PrintString(MENU_X_LEFT_ALIGNED(MENU_X_MARGIN), MENU_Y(210.0), str); + } else +#endif + { #ifdef FIX_BUGS - // Label is wrapped from right by StretchX(40)px, but wrapped from left by 40px. And this is only place R* didn't use StretchX in menu. - CFont::PrintString(MENU_X_LEFT_ALIGNED(MENUACTION_X_MARGIN), MENU_Y(menuXYpadding), str); + // Label is wrapped from right by StretchX(40)px, but wrapped from left by 40px. And this is only place R* didn't use StretchX in here. + CFont::PrintString(MENU_X_LEFT_ALIGNED(MENU_X_MARGIN), MENU_Y(menuXYpadding), str); #else - CFont::PrintString(MENUACTION_X_MARGIN, menuXYpadding, str); + CFont::PrintString(MENU_X_MARGIN, menuXYpadding, str); #endif + } } CFont::SetCentreSize(SCREEN_WIDTH); @@ -673,7 +776,7 @@ void CMenuManager::Draw() headerHeight = 240; lineHeight = 24; CFont::SetFontStyle(FONT_HEADING); - CFont::SetScale(MENU_X(actionTextScaleX = 0.75f), MENU_Y(actionTextScaleY = 0.9f)); + CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = BIGTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = BIGTEXT_Y_SCALE)); CFont::SetCentreOn(); break; case MENUPAGE_SOUND_SETTINGS: @@ -690,7 +793,7 @@ void CMenuManager::Draw() headerHeight = 0; lineHeight = 20; CFont::SetFontStyle(FONT_HEADING); - CFont::SetScale(MENU_X(actionTextScaleX = 0.55f), MENU_Y(actionTextScaleY = 0.8f)); + CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = MEDIUMTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = MEDIUMTEXT_Y_SCALE)); CFont::SetRightJustifyOff(); break; case MENUPAGE_CHOOSE_LOAD_SLOT: @@ -700,7 +803,7 @@ void CMenuManager::Draw() headerHeight = 38; lineHeight = 20; CFont::SetFontStyle(FONT_BANK); - CFont::SetScale(MENU_X(actionTextScaleX = SMALLTEXT_X_SCALE), MENU_Y(actionTextScaleY = SMALLTEXT_Y_SCALE)); + CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = SMALLTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = SMALLTEXT_Y_SCALE)); CFont::SetRightJustifyOff(); break; case MENUPAGE_NEW_GAME_RELOAD: @@ -712,7 +815,7 @@ void CMenuManager::Draw() headerHeight = 60; lineHeight = 24; CFont::SetFontStyle(FONT_HEADING); - CFont::SetScale(MENU_X(actionTextScaleX = 0.75f), MENU_Y(actionTextScaleY = 0.9f)); + CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = BIGTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = BIGTEXT_Y_SCALE)); CFont::SetCentreOn(); break; case MENUPAGE_START_MENU: @@ -720,7 +823,7 @@ void CMenuManager::Draw() headerHeight = 140; lineHeight = 24; CFont::SetFontStyle(FONT_HEADING); - CFont::SetScale(MENU_X(actionTextScaleX = 0.75f), MENU_Y(actionTextScaleY = 0.9f)); + CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = BIGTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = BIGTEXT_Y_SCALE)); CFont::SetCentreOn(); break; case MENUPAGE_PAUSE_MENU: @@ -728,7 +831,7 @@ void CMenuManager::Draw() headerHeight = 117; lineHeight = 24; CFont::SetFontStyle(FONT_HEADING); - CFont::SetScale(MENU_X(actionTextScaleX = 0.75f), MENU_Y(actionTextScaleY = 0.9f)); + CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = BIGTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = BIGTEXT_Y_SCALE)); CFont::SetCentreOn(); break; #ifdef PS2_SAVE_DIALOG @@ -737,7 +840,7 @@ void CMenuManager::Draw() headerHeight = 60; lineHeight = 24; CFont::SetFontStyle(FONT_BANK); - CFont::SetScale(MENU_X(actionTextScaleX = 0.75f), MENU_Y(actionTextScaleY = 0.9f)); + CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = BIGTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = BIGTEXT_Y_SCALE)); break; #endif default: @@ -745,7 +848,7 @@ void CMenuManager::Draw() headerHeight = 40; lineHeight = 24; CFont::SetFontStyle(FONT_HEADING); - CFont::SetScale(MENU_X(actionTextScaleX = 0.75f), MENU_Y(actionTextScaleY = 0.9f)); + CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X = BIGTEXT_X_SCALE), MENU_Y(MENU_TEXT_SIZE_Y = BIGTEXT_Y_SCALE)); CFont::SetCentreOn(); break; } @@ -759,7 +862,7 @@ void CMenuManager::Draw() if (m_bWaitingForNewKeyBind) itemsAreSelectable = false; - CMenuManager::DrawControllerScreenExtraText(nextYToUse - 8.0f, 350, lineHeight); + DrawControllerScreenExtraText(nextYToUse - 8.0f, MENU_X_LEFT_ALIGNED(350), lineHeight); break; default: break; @@ -794,7 +897,7 @@ void CMenuManager::Draw() case MENUACTION_CHANGEMENU: { switch (aScreens[m_nCurrScreen].m_aEntries[i].m_TargetMenu) { case MENUPAGE_MULTIPLAYER_MAP: - switch (sthWithButtons) { + switch (m_SelectedMap) { case 0: rightText = TheText.Get("FEM_MA0"); break; @@ -824,7 +927,7 @@ void CMenuManager::Draw() } break; case MENUPAGE_MULTIPLAYER_MODE: - switch (sthWithButtons2) { + switch (m_SelectedGameType) { case 0: rightText = TheText.Get("FEN_TY0"); break; @@ -859,7 +962,7 @@ void CMenuManager::Draw() break; } case MENUACTION_CTRLVIBRATION: - if (CMenuManager::m_PrefsUseVibration) + if (m_PrefsUseVibration) rightText = TheText.Get("FEM_ON"); else rightText = TheText.Get("FEM_OFF"); @@ -1025,23 +1128,23 @@ void CMenuManager::Draw() #endif m_nMousePosY < MENU_Y((nextYToCheck + 2) + usableLineHeight)) { - static int lastHoveringOption = -99; - static int lastScreen = m_nCurrScreen; + static int oldOption = -99; + static int oldScreen = m_nCurrScreen; m_nPrevOption = rowToCheck; if (m_nMouseOldPosX != m_nMousePosX || m_nMouseOldPosY != m_nMousePosY) { m_nCurrOption = rowToCheck; m_bShowMouse = true; } - if (lastHoveringOption != m_nCurrOption) { - if (lastScreen == m_nCurrScreen && m_bShowMouse) + if (oldOption != m_nCurrOption) { + if (oldScreen == m_nCurrScreen && m_bShowMouse) DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); - lastHoveringOption = m_nCurrOption; - lastScreen = m_nCurrScreen; + oldOption = m_nCurrOption; + oldScreen = m_nCurrScreen; } - if (lastScreen == m_nPrevScreen) - lastScreen = m_nCurrScreen; + if (oldScreen == m_nPrevScreen) + oldScreen = m_nCurrScreen; m_nHoverOption = HOVEROPTION_RANDOM_ITEM; foundTheHoveringItem = true; @@ -1124,7 +1227,7 @@ void CMenuManager::Draw() // Sliders // We stretch slider start X here(like original code), because it will always be center of screen - int lastBarX; + int lastActiveBarX; switch (aScreens[m_nCurrScreen].m_aEntries[i].m_Action) { case MENUACTION_BRIGHTNESS: ProcessSlider(m_PrefsBrightness / 512.0f, HOVEROPTION_INCREASE_BRIGHTNESS, HOVEROPTION_DECREASE_BRIGHTNESS, MENU_X_LEFT_ALIGNED(170.0f), SCREEN_WIDTH); @@ -1184,21 +1287,18 @@ void CMenuManager::Draw() if (m_nCurrScreen == MENUPAGE_CONTROLLER_SETTINGS) PrintController(); - -/* else if (m_nCurrScreen == MENUPAGE_SKIN_SELECT_OLD) { - CSprite2d::DrawRect(CRect(StretchX(180), MENU_Y(98), StretchX(230), MENU_Y(123)), CRGBA(255, 255, 255, FadeIn(255))); - CSprite2d::DrawRect(CRect(StretchX(181), MENU_Y(99), StretchX(229), MENU_Y(233)), CRGBA(Player color from PickNewPlayerColour, FadeIn(255))); + else if (m_nCurrScreen == MENUPAGE_SKIN_SELECT_OLD) { + CSprite2d::DrawRect(CRect(MENU_X_LEFT_ALIGNED(180), MENU_Y(98), MENU_X_LEFT_ALIGNED(230), MENU_Y(123)), CRGBA(255, 255, 255, FadeIn(255))); + CSprite2d::DrawRect(CRect(MENU_X_LEFT_ALIGNED(181), MENU_Y(99), MENU_X_LEFT_ALIGNED(229), MENU_Y(122)), CRGBA(m_PrefsPlayerRed, m_PrefsPlayerGreen, m_PrefsPlayerBlue, FadeIn(255))); } -*/ + } -#endif int CMenuManager::GetNumOptionsCntrlConfigScreens(void) { int number = 0; - switch (m_nCurrScreen) - { + switch (m_nCurrScreen) { case MENUPAGE_CONTROLLER_PC_OLD3: number = 2; break; @@ -1227,12 +1327,12 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8 int numOptions = GetNumOptionsCntrlConfigScreens(); int bindingMargin = MENU_X(3.0f); float rowHeight; - switch (CMenuManager::m_ControlMethod) { + switch (m_ControlMethod) { case CONTROL_STANDARD: - rowHeight = 10.7f; + rowHeight = CONTSETUP_STANDARD_ROW_HEIGHT; break; case CONTROL_CLASSIC: - rowHeight = 9.0f; + rowHeight = CONTSETUP_CLASSIC_ROW_HEIGHT; break; default: break; @@ -1302,13 +1402,13 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8 controllerAction = PED_LOOKBEHIND; break; case 23: - if (CMenuManager::m_ControlMethod == CONTROL_STANDARD) + if (m_ControlMethod == CONTROL_STANDARD) controllerAction = -1; else controllerAction = PED_1RST_PERSON_LOOK_LEFT; break; case 24: - if (CMenuManager::m_ControlMethod == CONTROL_STANDARD) + if (m_ControlMethod == CONTROL_STANDARD) controllerAction = -1; else controllerAction = PED_1RST_PERSON_LOOK_RIGHT; @@ -1415,15 +1515,19 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8 if (column == CONTSETUP_PED_COLUMN && m_nSelectedContSetupColumn == CONTSETUP_PED_COLUMN) { #ifdef FIX_BUGS if (controllerAction == -1) { - CSprite2d::DrawRect(CRect(nextX, MENU_Y(bgY), nextX + MENU_X(190.0f), MENU_Y(bgY + 10)), CRGBA(235, 170, 50, FadeIn(150))); + CSprite2d::DrawRect(CRect(nextX, MENU_Y(bgY), nextX + MENU_X(CONTSETUP_BOUND_COLUMN_WIDTH), + MENU_Y(bgY + CONTSETUP_BOUND_HIGHLIGHT_HEIGHT)), CRGBA(235, 170, 50, FadeIn(150))); } else { - CSprite2d::DrawRect(CRect(nextX, MENU_Y(bgY), nextX + MENU_X(190.0f), MENU_Y(bgY + 10)), CRGBA(255, 217, 106, FadeIn(210))); + CSprite2d::DrawRect(CRect(nextX, MENU_Y(bgY), nextX + MENU_X(CONTSETUP_BOUND_COLUMN_WIDTH), + MENU_Y(bgY + CONTSETUP_BOUND_HIGHLIGHT_HEIGHT)), CRGBA(255, 217, 106, FadeIn(210))); } #else if (controllerAction == -1) { - CSprite2d::DrawRect(CRect(MENU_X_LEFT_ALIGNED(210.0f), MENU_Y(bgY), MENU_X_LEFT_ALIGNED(400.0f), MENU_Y(bgY + 10)), CRGBA(235, 170, 50, FadeIn(150))); + CSprite2d::DrawRect(CRect(MENU_X_LEFT_ALIGNED(210.0f), MENU_Y(bgY), + MENU_X_LEFT_ALIGNED(400.0f), MENU_Y(bgY + CONTSETUP_BOUND_HIGHLIGHT_HEIGHT)), CRGBA(235, 170, 50, FadeIn(150))); } else { - CSprite2d::DrawRect(CRect(MENU_X_LEFT_ALIGNED(210.0f), MENU_Y(bgY), MENU_X_LEFT_ALIGNED(400.0f), MENU_Y(bgY + 10)), CRGBA(255, 217, 106, FadeIn(210))); + CSprite2d::DrawRect(CRect(MENU_X_LEFT_ALIGNED(210.0f), MENU_Y(bgY), + MENU_X_LEFT_ALIGNED(400.0f), MENU_Y(bgY + CONTSETUP_BOUND_HIGHLIGHT_HEIGHT)), CRGBA(255, 217, 106, FadeIn(210))); } #endif CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255))); @@ -1432,9 +1536,11 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8 } else if (column == CONTSETUP_VEHICLE_COLUMN && m_nSelectedContSetupColumn == CONTSETUP_VEHICLE_COLUMN) { #ifdef FIX_BUGS if (controllerAction == -1) { - CSprite2d::DrawRect(CRect(nextX, MENU_Y(bgY), nextX + MENU_X(190.0f), MENU_Y(bgY + 10)), CRGBA(235, 170, 50, FadeIn(150))); + CSprite2d::DrawRect(CRect(nextX, MENU_Y(bgY), nextX + MENU_X(CONTSETUP_BOUND_COLUMN_WIDTH), + MENU_Y(bgY + CONTSETUP_BOUND_HIGHLIGHT_HEIGHT)), CRGBA(235, 170, 50, FadeIn(150))); } else { - CSprite2d::DrawRect(CRect(nextX, MENU_Y(bgY), nextX + MENU_X(190.0f), MENU_Y(bgY + 10)), CRGBA(255, 217, 106, FadeIn(210))); + CSprite2d::DrawRect(CRect(nextX, MENU_Y(bgY), nextX + MENU_X(CONTSETUP_BOUND_COLUMN_WIDTH), + MENU_Y(bgY + CONTSETUP_BOUND_HIGHLIGHT_HEIGHT)), CRGBA(255, 217, 106, FadeIn(210))); } #else if (controllerAction == -1) { @@ -1553,25 +1659,273 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8 } } -#if 1 -WRAPPER void CMenuManager::DrawControllerScreenExtraText(int, int, int) { EAXJMP(0x4892F0); } -#else -void CMenuManager::DrawControllerScreenExtraText(int, int, int) +// TODO: Complete aScreens and test that +void +CMenuManager::DrawControllerScreenExtraText(int yStart, int xStart, int lineHeight) { + int extraTextStart = GetStartOptionsCntrlConfigScreens(); + int numOpts = GetNumOptionsCntrlConfigScreens(); + int spacing = MENU_X(10.0f); + for (int i = extraTextStart; i < extraTextStart + numOpts; i++) { + int numTextsPrinted = 0; + int nextX = xStart; + for (int j = 1; j < 5; j++) { + wchar *text = ControlsManager.GetControllerSettingTextWithOrderNumber((e_ControllerAction)i, (eContSetOrder)j); + if (text) + ++numTextsPrinted; + + if (text) { + // Seperator + if (numTextsPrinted > 1) { + CFont::PrintString(nextX, MENU_Y(yStart), TheText.Get("FEC_IBT")); + nextX = CFont::GetStringWidth(TheText.Get("FEC_IBT"), true) + spacing + nextX; + } + CFont::PrintString(nextX, MENU_Y(yStart), text); + } + if (text) + nextX = CFont::GetStringWidth(text, true) + spacing + nextX; + } + if (m_nCurrOption == i - extraTextStart && m_bWaitingForNewKeyBind) { + static bool waitingTextVisible = false; + // Seperator + if (numTextsPrinted > 0) { + CFont::PrintString(nextX, MENU_Y(yStart), TheText.Get("FEC_IBT")); + nextX = CFont::GetStringWidth(TheText.Get("FEC_IBT"), true) + spacing + nextX; + } + static uint32 lastStateChange = 0; + if (CTimer::GetTimeInMillisecondsPauseMode() - lastStateChange > 150) { + waitingTextVisible = !waitingTextVisible; + lastStateChange = CTimer::GetTimeInMillisecondsPauseMode(); + } + if (waitingTextVisible) { + CFont::SetColor(CRGBA(255, 255, 0, FadeIn(255))); + CFont::PrintString(nextX, MENU_Y(yStart), TheText.Get("FEC_QUE")); + CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255))); + } + } + yStart += lineHeight; + } + wchar *error = nil; + if (DisplayComboButtonErrMsg) + error = ControlsManager.GetButtonComboText((e_ControllerAction)(m_nCurrOption + extraTextStart)); + + if (error) { + CFont::SetColor(CRGBA(233, 22, 159, 255)); + CFont::PrintString(xStart, MENU_Y(yStart + 10), error); + } } + +void +CMenuManager::DrawControllerSetupScreen() +{ + float rowHeight; + switch (m_ControlMethod) { + case CONTROL_STANDARD: + rowHeight = CONTSETUP_STANDARD_ROW_HEIGHT; + break; + case CONTROL_CLASSIC: + rowHeight = CONTSETUP_CLASSIC_ROW_HEIGHT; + break; + default: + break; + } + CFont::SetBackgroundOff(); + CFont::SetScale(MENU_X(MENUACTION_SCALE_MULT), MENU_Y(MENUACTION_SCALE_MULT)); + CFont::SetPropOn(); + CFont::SetCentreOff(); + CFont::SetJustifyOn(); + CFont::SetRightJustifyOff(); + CFont::SetBackGroundOnlyTextOn(); + CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(MENU_X_MARGIN)); + CFont::SetRightJustifyWrap(SCREEN_SCALE_X(MENUACTION_WIDTH)); + + // Page header + CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255))); + CFont::SetRightJustifyOn(); + CFont::SetScale(MENU_X(MENUHEADER_WIDTH), MENU_Y(MENUHEADER_HEIGHT)); + CFont::SetFontStyle(FONT_HEADING); + switch (m_ControlMethod) { + case CONTROL_STANDARD: + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), + TheText.Get(aScreens[m_nCurrScreen].m_ScreenName)); + break; + case CONTROL_CLASSIC: + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), + TheText.Get("FET_CTI")); + break; + default: + break; + } + wchar *actionTexts[31]; + actionTexts[0] = TheText.Get("FEC_FIR"); + actionTexts[1] = TheText.Get("FEC_NWE"); + actionTexts[2] = TheText.Get("FEC_PWE"); + actionTexts[3] = TheText.Get("FEC_FOR"); + actionTexts[4] = TheText.Get("FEC_BAC"); + actionTexts[5] = TheText.Get("FEC_LEF"); + actionTexts[6] = TheText.Get("FEC_RIG"); + actionTexts[7] = TheText.Get("FEC_ZIN"); + actionTexts[8] = TheText.Get("FEC_ZOT"); + actionTexts[9] = TheText.Get("FEC_EEX"); + actionTexts[10] = TheText.Get("FEC_RAD"); + actionTexts[11] = TheText.Get("FEC_HRN"); + actionTexts[12] = TheText.Get("FEC_SUB"); + actionTexts[13] = TheText.Get("FEC_CMR"); + actionTexts[14] = TheText.Get("FEC_JMP"); + actionTexts[15] = TheText.Get("FEC_SPN"); + actionTexts[16] = TheText.Get("FEC_HND"); + actionTexts[17] = TheText.Get("FEC_TAR"); + if (m_ControlMethod == CONTROL_CLASSIC) { + actionTexts[18] = TheText.Get("FEC_TFL"); + actionTexts[19] = TheText.Get("FEC_TFR"); + actionTexts[20] = TheText.Get("FEC_TFU"); + actionTexts[21] = TheText.Get("FEC_TFD"); + actionTexts[22] = TheText.Get("FEC_LBA"); + actionTexts[23] = TheText.Get("FEC_LOL"); + actionTexts[24] = TheText.Get("FEC_LOR"); + actionTexts[25] = TheText.Get("FEC_LUD"); + actionTexts[26] = TheText.Get("FEC_LDU"); + actionTexts[27] = TheText.Get("FEC_NTR"); + actionTexts[28] = TheText.Get("FEC_PTT"); + actionTexts[29] = TheText.Get("FEC_CEN"); + actionTexts[30] = nil; + } else { + actionTexts[18] = TheText.Get("FEC_TFL"); + actionTexts[19] = TheText.Get("FEC_TFR"); + actionTexts[20] = TheText.Get("FEC_TFU"); + actionTexts[21] = TheText.Get("FEC_TFD"); + actionTexts[22] = TheText.Get("FEC_LBA"); + actionTexts[23] = TheText.Get("FEC_LOL"); + actionTexts[24] = TheText.Get("FEC_LOR"); + actionTexts[25] = nil; + } + + // Gray panel background + CSprite2d::DrawRect(CRect(MENU_X_LEFT_ALIGNED(CONTSETUP_LIST_LEFT), MENU_Y(CONTSETUP_LIST_TOP), + MENU_X_RIGHT_ALIGNED(CONTSETUP_LIST_RIGHT), SCREEN_SCALE_FROM_BOTTOM(CONTSETUP_LIST_BOTTOM)), + CRGBA(200, 200, 50, FadeIn(50))); + + if (m_nCurrExLayer == HOVEROPTION_LIST) + CFont::SetColor(CRGBA(255, 217, 106, FadeIn(255))); + else + CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255))); + + // List header + CFont::SetFontStyle(FONT_HEADING); + CFont::SetScale(MENU_X(MENUACTION_SCALE_MULT), MENU_Y(MENUACTION_SCALE_MULT)); + CFont::SetRightJustifyOff(); + CFont::PrintString(MENU_X_LEFT_ALIGNED(CONTSETUP_COLUMN_1_X), MENU_Y(CONTSETUP_LIST_TOP), TheText.Get("FET_CAC")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(CONTSETUP_COLUMN_2_X), MENU_Y(CONTSETUP_LIST_TOP), TheText.Get("FET_CFT")); + CFont::PrintString(MENU_X_LEFT_ALIGNED(CONTSETUP_COLUMN_3_X), MENU_Y(CONTSETUP_LIST_TOP), TheText.Get("FET_CCR")); + CFont::SetRightJustifyOff(); + CFont::SetScale(MENU_X_LEFT_ALIGNED(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE)); + CFont::SetFontStyle(FONT_BANK); + int yStart; + if (m_ControlMethod == CONTROL_CLASSIC) + yStart = CONTSETUP_LIST_HEADER_HEIGHT + 29; + else + yStart = CONTSETUP_LIST_HEADER_HEIGHT + 34; + + for (int i = 0; i < ARRAY_SIZE(actionTexts); ++i) { + wchar *actionText = actionTexts[i]; + if (!actionText) + break; + + if (m_nMousePosX > MENU_X_LEFT_ALIGNED(CONTSETUP_LIST_LEFT + 2.0f) && + m_nMousePosX < MENU_X_LEFT_ALIGNED(CONTSETUP_COLUMN_3_X + CONTSETUP_BOUND_COLUMN_WIDTH)) { + + float curOptY = i * rowHeight + yStart; + if (m_nMousePosY > MENU_Y(curOptY) && m_nMousePosY < MENU_Y(rowHeight + curOptY)) { + if (m_nPrevOption != i && m_nCurrExLayer == HOVEROPTION_LIST) + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + + m_nPrevOption = i; + if (m_nMouseOldPosX != m_nMousePosX || m_nMouseOldPosY != m_nMousePosY) { + m_nCurrExLayer = HOVEROPTION_LIST; + m_nSelectedListRow = i; + + // why different number for 3rd column hovering X?? this function is a mess +#ifdef FIX_BUGS + if (m_nMousePosX > MENU_X_LEFT_ALIGNED(0.0f) && m_nMousePosX < MENU_X_LEFT_ALIGNED(CONTSETUP_COLUMN_2_X + CONTSETUP_BOUND_COLUMN_WIDTH)) { +#else + if (m_nMousePosX > MENU_X_LEFT_ALIGNED(0.0f) && m_nMousePosX < MENU_X_LEFT_ALIGNED(370.0f)) { #endif + if (m_nSelectedContSetupColumn != CONTSETUP_PED_COLUMN && m_nCurrExLayer == HOVEROPTION_LIST) + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); -#if 1 -WRAPPER void CMenuManager::DrawControllerSetupScreen() { EAXJMP(0x481210); } + m_nSelectedContSetupColumn = CONTSETUP_PED_COLUMN; +#ifdef FIX_BUGS + } else if (m_nMousePosX > MENU_X_LEFT_ALIGNED(CONTSETUP_COLUMN_2_X + CONTSETUP_BOUND_COLUMN_WIDTH) && m_nMousePosX < SCREEN_WIDTH) { #else -void CMenuManager::DrawControllerSetupScreen() -{ + } else if (m_nMousePosX > MENU_X_LEFT_ALIGNED(370.0f) && m_nMousePosX < SCREEN_WIDTH) { +#endif + if (m_nSelectedContSetupColumn != CONTSETUP_VEHICLE_COLUMN && m_nCurrExLayer == HOVEROPTION_LIST) + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + + m_nSelectedContSetupColumn = CONTSETUP_VEHICLE_COLUMN; + } + } + // what?? + if (m_nHoverOption == HOVEROPTION_SKIN) { + if (i == m_nSelectedListRow) { + m_nHoverOption = HOVEROPTION_NOT_HOVERING; + m_bWaitingForNewKeyBind = true; + m_bStartWaitingForKeyBind = true; + pControlEdit = &m_KeyPressedCode; + } + } else + m_nHoverOption = HOVEROPTION_NOT_HOVERING; + } + } + if (m_nSelectedListRow != 35) + CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255))); + else if (m_nCurrExLayer == HOVEROPTION_LIST) + CFont::SetColor(CRGBA(255, 217, 106, FadeIn(255))); + + CFont::SetRightJustifyOff(); + if (m_PrefsLanguage != LANGUAGE_GERMAN || i != 20 && i != 21) + CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE)); + else + CFont::SetScale(MENU_X(0.32f), MENU_Y(SMALLESTTEXT_Y_SCALE)); + + CFont::PrintString(MENU_X_LEFT_ALIGNED(CONTSETUP_COLUMN_1_X), MENU_Y(i * rowHeight + yStart), actionText); + } + DrawControllerBound(yStart, MENU_X_LEFT_ALIGNED(CONTSETUP_COLUMN_2_X), rowHeight, CONTSETUP_PED_COLUMN); + DrawControllerBound(yStart, MENU_X_LEFT_ALIGNED(CONTSETUP_COLUMN_3_X), rowHeight, CONTSETUP_VEHICLE_COLUMN); + CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X), MENU_Y(MENU_TEXT_SIZE_Y)); + + if ((m_nMousePosX > MENU_X_RIGHT_ALIGNED(CONTSETUP_BACK_RIGHT) - CFont::GetStringWidth(TheText.Get("FEDS_TB"), true) + && m_nMousePosX < MENU_X_RIGHT_ALIGNED(CONTSETUP_BACK_RIGHT) && m_nMousePosY > SCREEN_SCALE_FROM_BOTTOM(CONTSETUP_BACK_BOTTOM) + && m_nMousePosY < SCREEN_SCALE_FROM_BOTTOM(CONTSETUP_BACK_BOTTOM - CONTSETUP_BACK_HEIGHT)) || m_nCurrExLayer == HOVEROPTION_BACK) { + m_nHoverOption = HOVEROPTION_BACK; + + } else if (m_nMousePosX > MENU_X_LEFT_ALIGNED(CONTSETUP_LIST_LEFT + 2.0f) && m_nMousePosX < MENU_X_LEFT_ALIGNED(CONTSETUP_COLUMN_3_X + CONTSETUP_BOUND_COLUMN_WIDTH) + && m_nMousePosY > MENU_Y(CONTSETUP_LIST_TOP + CONTSETUP_LIST_HEADER_HEIGHT) && m_nMousePosY < SCREEN_SCALE_FROM_BOTTOM(CONTSETUP_LIST_BOTTOM + 5.0f)) { + m_nHoverOption = HOVEROPTION_LIST; + + } else { + m_nHoverOption = HOVEROPTION_NOT_HOVERING; + } + // Back button and it's shadow + CFont::SetFontStyle(FONT_HEADING); + CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X), MENU_Y(MENU_TEXT_SIZE_Y)); + CFont::SetRightJustifyOn(); + CFont::SetColor(CRGBA(0, 0, 0, FadeIn(90))); + for (int i = 0; i < 2; i++) { + CFont::PrintString(MENU_X_RIGHT_ALIGNED(CONTSETUP_BACK_RIGHT - 2.0f - i), + SCREEN_SCALE_FROM_BOTTOM(CONTSETUP_BACK_BOTTOM - 4.0f - i), TheText.Get("FEDS_TB")); + + if (m_nHoverOption == HOVEROPTION_BACK) + CFont::SetColor(CRGBA(255, 217, 106, FadeIn(255))); + else + CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255))); + } } -#endif -void CMenuManager::DrawFrontEnd() +void +CMenuManager::DrawFrontEnd() { CFont::SetAlphaFade(255.0f); @@ -1628,7 +1982,8 @@ void CMenuManager::DrawFrontEnd() } #ifdef PS2_SAVE_DIALOG -void CMenuManager::DrawFrontEndSaveZone() +void +CMenuManager::DrawFrontEndSaveZone() { CSprite2d::InitPerFrame(); CFont::InitPerFrame(); @@ -1640,7 +1995,7 @@ void CMenuManager::DrawFrontEndSaveZone() m_nMenuFadeAlpha = 255; RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void*)rwTEXTUREADDRESSCLAMP); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE); - CMenuManager::Draw(); + Draw(); CFont::DrawFonts(); @@ -1671,7 +2026,8 @@ void CMenuManager::DrawFrontEndSaveZone() #endif #ifdef PS2_LIKE_MENU -void CMenuManager::DrawFrontEndNormal() +void +CMenuManager::DrawFrontEndNormal() { CSprite2d::InitPerFrame(); CFont::InitPerFrame(); @@ -1747,13 +2103,11 @@ void CMenuManager::DrawFrontEndNormal() reverseAlpha = false; ChangeScreen(pendingScreen, pendingOption, true, false); } else { - float timestep = CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond(); - // +20 per every 33 ms (1000.f/30.f - original frame limiter fps) if (!reverseAlpha) - fadeAlpha += (timestep * 100.f) * 20.f / 33.f; + fadeAlpha += (frameTime) * 20.f / 33.f; else - fadeAlpha = max(0.0f, fadeAlpha - (timestep * 100.f) * 30.f / 33.f); + fadeAlpha = max(0.0f, fadeAlpha - (frameTime) * 30.f / 33.f); m_nMenuFadeAlpha = fadeAlpha; } @@ -1762,8 +2116,7 @@ void CMenuManager::DrawFrontEndNormal() if (lastState == 0) fadeAlpha = 255.f; if (reverseAlpha) { - float timestep = CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond(); - fadeAlpha -= (timestep * 100.f) * 30.f / 33.f; + fadeAlpha -= (frameTime) * 30.f / 33.f; m_nMenuFadeAlpha = fadeAlpha; } @@ -1785,13 +2138,13 @@ void CMenuManager::DrawFrontEndNormal() RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE); switch (m_nCurrScreen) { case MENUPAGE_SKIN_SELECT: - CMenuManager::DrawPlayerSetupScreen(); + DrawPlayerSetupScreen(); break; case MENUPAGE_KEYBOARD_CONTROLS: - CMenuManager::DrawControllerSetupScreen(); + DrawControllerSetupScreen(); break; default: - CMenuManager::Draw(); + Draw(); break; } @@ -1865,7 +2218,8 @@ void CMenuManager::DrawFrontEndNormal() } } #else -void CMenuManager::DrawFrontEndNormal() +void +CMenuManager::DrawFrontEndNormal() { CSprite2d::InitPerFrame(); CFont::InitPerFrame(); @@ -1971,10 +2325,8 @@ void CMenuManager::DrawFrontEndNormal() static float fadeAlpha = 0.0f; if (m_nMenuFadeAlpha == 0 && fadeAlpha > 1.0f) fadeAlpha = 0.0f; - float timestep = CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond(); - // +20 per every 33 ms (1000.f/30.f - original frame limiter fps) - fadeAlpha += (timestep * 100.f) * 20.f / 33.f; + fadeAlpha += (frameTime) * 20.f / 33.f; m_nMenuFadeAlpha = fadeAlpha; #else static uint32 LastFade = 0; @@ -2019,13 +2371,13 @@ void CMenuManager::DrawFrontEndNormal() RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE); switch (m_nCurrScreen) { case MENUPAGE_SKIN_SELECT: - CMenuManager::DrawPlayerSetupScreen(); + DrawPlayerSetupScreen(); break; case MENUPAGE_KEYBOARD_CONTROLS: - CMenuManager::DrawControllerSetupScreen(); + DrawControllerSetupScreen(); break; default: - CMenuManager::Draw(); + Draw(); break; } @@ -2057,10 +2409,8 @@ void CMenuManager::DrawFrontEndNormal() } #endif -#if 0 -WRAPPER void CMenuManager::DrawPlayerSetupScreen() { EAXJMP(0x47F2B0); } -#else -void CMenuManager::DrawPlayerSetupScreen() +void +CMenuManager::DrawPlayerSetupScreen() { CFont::SetBackgroundOff(); CFont::SetScale(MENU_X(MENUACTION_SCALE_MULT), MENU_Y(MENUACTION_SCALE_MULT)); @@ -2069,7 +2419,7 @@ void CMenuManager::DrawPlayerSetupScreen() CFont::SetJustifyOn(); CFont::SetRightJustifyOff(); CFont::SetBackGroundOnlyTextOn(); - CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(MENUACTION_X_MARGIN)); + CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(MENU_X_MARGIN)); CFont::SetRightJustifyWrap(SCREEN_SCALE_X(MENUACTION_WIDTH)); CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255))); @@ -2118,7 +2468,8 @@ void CMenuManager::DrawPlayerSetupScreen() m_pSelectedSkin->skinNameOriginal[oldLength - 4] = '\0'; // Truncate to 40 bytes-39 chars, idk why. This is done in sepearate function in game. - strncpy(m_pSelectedSkin->skinNameDisplayed, m_pSelectedSkin->skinNameDisplayed, 39); + strncpy(nameTemp, m_pSelectedSkin->skinNameDisplayed, 39); // game doesn't do that, but in our day strncpy to same string is forbidden + strncpy(m_pSelectedSkin->skinNameDisplayed, nameTemp, 39); if (oldLength - 4 > 39) m_pSelectedSkin->skinNameDisplayed[39] = '\0'; @@ -2173,7 +2524,7 @@ void CMenuManager::DrawPlayerSetupScreen() CFont::SetScale(MENU_X(MENUACTION_SCALE_MULT), MENU_Y(MENUACTION_SCALE_MULT)); CFont::SetRightJustifyOn(); CFont::PrintString(MENU_X_RIGHT_ALIGNED(PLAYERSETUP_DATE_COLUMN_RIGHT), MENU_Y(PLAYERSETUP_LIST_TOP), TheText.Get("FES_DAT")); - switch (CMenuManager::m_PrefsLanguage) { + switch (m_PrefsLanguage) { case LANGUAGE_FRENCH: case LANGUAGE_SPANISH: CFont::SetScale(MENU_X(0.6f), MENU_Y(MENUACTION_SCALE_MULT)); @@ -2343,7 +2694,7 @@ void CMenuManager::DrawPlayerSetupScreen() // Big apply button if (strcmp(m_aSkinName, m_PrefsSkinFile) != 0) { CFont::SetFontStyle(FONT_HEADING); - switch (CMenuManager::m_PrefsLanguage) { + switch (m_PrefsLanguage) { case LANGUAGE_FRENCH: CFont::SetScale(MENU_X(1.1f), MENU_Y(1.9f)); break; @@ -2470,12 +2821,9 @@ void CMenuManager::DrawPlayerSetupScreen() } } -#endif -#if 0 -WRAPPER int CMenuManager::FadeIn(int alpha) { EAXJMP(0x48AC60); } -#else -int CMenuManager::FadeIn(int alpha) +int +CMenuManager::FadeIn(int alpha) { if (m_nCurrScreen == MENUPAGE_LOADING_IN_PROGRESS || m_nCurrScreen == MENUPAGE_SAVING_IN_PROGRESS || @@ -2484,27 +2832,57 @@ int CMenuManager::FadeIn(int alpha) return min(m_nMenuFadeAlpha, alpha); } -#endif -#if 1 -WRAPPER void CMenuManager::FilterOutColorMarkersFromString(uint16, CRGBA &) { EAXJMP(0x4889C0); } -#else -void CMenuManager::FilterOutColorMarkersFromString(uint16, CRGBA &) +void +CMenuManager::FilterOutColorMarkersFromString(wchar *str, CRGBA &newColor) { - + int newIdx = 0; + wchar copy[256], *c; + UnicodeStrcpy(copy, str); + + for (c = copy; *c != '\0'; c++) { + if (*c == '~') { + c++; + switch (*c) { + case 'b': newColor = CRGBA(40, 40, 255, 255); break; + case 'g': newColor = CRGBA(40, 235, 40, 255); break; + // There is no case for "h", is that a mistake? + case 'l': newColor = CRGBA(0, 0, 0, 255); break; + case 'p': newColor = CRGBA(255, 0, 255, 255); break; + case 'r': newColor = CRGBA(255, 0, 0, 255); break; + case 'w': newColor = CRGBA(255, 255, 255, 255); break; + case 'y': newColor = CRGBA(255, 255, 0, 255); break; + } + while (*c != '~') c++; + } else { + str[newIdx++] = *c; + } + } + str[newIdx] = '\0'; } -#endif -#if 1 -WRAPPER int CMenuManager::GetStartOptionsCntrlConfigScreens() { EAXJMP(0x489270); } -#else -int CMenuManager::GetStartOptionsCntrlConfigScreens() +int +CMenuManager::GetStartOptionsCntrlConfigScreens() { - + int number = 0; + switch (m_nCurrScreen) { + case MENUPAGE_CONTROLLER_PC_OLD3: + number = 34; + break; + case MENUPAGE_CONTROLLER_DEBUG: + number = 35; + break; + case MENUPAGE_KEYBOARD_CONTROLS: + number = 0; + break; + default: + break; + } + return number; } -#endif -void CMenuManager::InitialiseChangedLanguageSettings() +void +CMenuManager::InitialiseChangedLanguageSettings() { if (m_bFrontEnd_ReloadObrTxtGxt) { m_bFrontEnd_ReloadObrTxtGxt = false; @@ -2515,7 +2893,7 @@ void CMenuManager::InitialiseChangedLanguageSettings() CGame::frenchGame = false; CGame::germanGame = false; #ifdef MORE_LANGUAGES - switch (CMenuManager::m_PrefsLanguage) { + switch (m_PrefsLanguage) { case LANGUAGE_RUSSIAN: CFont::ReloadFonts(FONT_LANGSET_RUSSIAN); break; @@ -2525,7 +2903,7 @@ void CMenuManager::InitialiseChangedLanguageSettings() } #endif - switch (CMenuManager::m_PrefsLanguage) { + switch (m_PrefsLanguage) { case LANGUAGE_FRENCH: CGame::frenchGame = true; break; @@ -2543,22 +2921,23 @@ void CMenuManager::InitialiseChangedLanguageSettings() } } -void CMenuManager::LoadAllTextures() +void +CMenuManager::LoadAllTextures() { if (m_bSpritesLoaded) return; - CMenuManager::CentreMousePointer(); + CentreMousePointer(); DMAudio.ChangeMusicMode(MUSICMODE_FRONTEND); DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_STARTING, 0); m_nCurrOption = 0; m_PrefsRadioStation = DMAudio.GetRadioInCar(); if (DMAudio.IsMP3RadioChannelAvailable()) { - if (CMenuManager::m_PrefsRadioStation > USERTRACK) - CMenuManager::m_PrefsRadioStation = CGeneral::GetRandomNumber() % 10; - } else if (CMenuManager::m_PrefsRadioStation > CHATTERBOX) - CMenuManager::m_PrefsRadioStation = CGeneral::GetRandomNumber() % 9; + if (m_PrefsRadioStation > USERTRACK) + m_PrefsRadioStation = CGeneral::GetRandomNumber() % 10; + } else if (m_PrefsRadioStation > CHATTERBOX) + m_PrefsRadioStation = CGeneral::GetRandomNumber() % 9; CFileMgr::SetDir(""); //CFileMgr::SetDir(""); @@ -2607,10 +2986,9 @@ void CMenuManager::LoadAllTextures() m_bSpritesLoaded = true; CTxdStore::PopCurrentTxd(); } -#if 0 -WRAPPER void CMenuManager::LoadSettings() { EAXJMP(0x488EE0); } -#else -void CMenuManager::LoadSettings() + +void +CMenuManager::LoadSettings() { CFileMgr::SetDirMyDocuments(); int fileHandle = CFileMgr::OpenFile("gta3.set", "r"); @@ -2699,12 +3077,9 @@ void CMenuManager::LoadSettings() strcpy(m_aSkinName, "$$\"\""); } } -#endif -#if 0 -WRAPPER void CMenuManager::SaveSettings() { EAXJMP(0x488CC0); } -#else -void CMenuManager::SaveSettings() +void +CMenuManager::SaveSettings() { static char RubbishString[48] = "stuffmorestuffevenmorestuff etc"; @@ -2747,44 +3122,115 @@ void CMenuManager::SaveSettings() CFileMgr::CloseFile(fileHandle); CFileMgr::SetDir(""); } -#endif -#if 1 -WRAPPER void CMenuManager::MessageScreen(char *) { EAXJMP(0x48B7E0); } -#else -void CMenuManager::MessageScreen(char *) +bool DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha); +void DoRWStuffEndOfFrame(void); + +void +CMenuManager::MessageScreen(const char *text) { + CSprite2d *splash = LoadSplash(nil); + if (!DoRWStuffStartOfFrame(0, 0, 0, 0, 0, 0, 255)) + return; + + CSprite2d::SetRecipNearClip(); + CSprite2d::InitPerFrame(); + CFont::InitPerFrame(); + DefinedState(); + + RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void*)rwTEXTUREADDRESSCLAMP); + splash->Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), CRGBA(255, 255, 255, 255)); + CFont::SetBackgroundOff(); + CFont::SetPropOn(); + CFont::SetJustifyOn(); + CFont::SetBackGroundOnlyTextOn(); + CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(170.0f)); + CFont::SetRightJustifyWrap(SCREEN_SCALE_FROM_RIGHT(170.0f)); + CSprite2d::DrawRect(CRect(SCREEN_SCALE_X(120.0f), SCREEN_SCALE_Y(150.0f), SCREEN_SCALE_FROM_RIGHT(120.0f), SCREEN_SCALE_FROM_BOTTOM(220.0f)), CRGBA(50, 50, 50, 210)); + CFont::SetFontStyle(FONT_BANK); + CFont::SetCentreSize(SCREEN_SCALE_X(380.0f)); + CFont::SetCentreOn(); + CFont::SetColor(CRGBA(255, 217, 106, 255)); + CFont::SetScale(SCREEN_SCALE_X(SMALLTEXT_X_SCALE), SCREEN_SCALE_Y(SMALLTEXT_Y_SCALE)); + CFont::PrintString(SCREEN_SCALE_X(320.0f), SCREEN_SCALE_Y(170.0f), TheText.Get(text)); + CFont::DrawFonts(); + DoRWStuffEndOfFrame(); } -#endif -#if 1 -WRAPPER void CMenuManager::PickNewPlayerColour() { EAXJMP(0x488C40); } -#else -void CMenuManager::PickNewPlayerColour() +void +CMenuManager::PickNewPlayerColour() { - + m_PrefsPlayerRed = 0; + m_PrefsPlayerGreen = 0; + m_PrefsPlayerBlue = 0; + while (true) { + int sum = m_PrefsPlayerRed + m_PrefsPlayerGreen + m_PrefsPlayerBlue; + if (sum >= 100 && sum <= 650) + break; + m_PrefsPlayerRed = CGeneral::GetRandomNumber(); + m_PrefsPlayerGreen = CGeneral::GetRandomNumber(); + m_PrefsPlayerBlue = CGeneral::GetRandomNumber(); + } } -#endif -#if 1 -WRAPPER void CMenuManager::PrintBriefs() { EAXJMP(0x484D60); } -#else -void CMenuManager::PrintBriefs() +void +CMenuManager::PrintBriefs() { + CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255))); + CFont::SetFontStyle(FONT_BANK); + CFont::SetRightJustifyOff(); + CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X * 0.7), MENU_Y(MENU_TEXT_SIZE_Y * 0.9)); // second mulipliers are double, idk why + + float nextY = 40.0f; + CRGBA newColor; + for (int i = 4; i >= 0; i--) { + tPreviousBrief &brief = CMessages::PreviousBriefs[i]; + if (brief.m_pText) { + CMessages::InsertNumberInString(brief.m_pText, + brief.m_nNumber[0], brief.m_nNumber[1], + brief.m_nNumber[2], brief.m_nNumber[3], + brief.m_nNumber[4], brief.m_nNumber[5], gUString); + CMessages::InsertStringInString(gUString, brief.m_pString); + CMessages::InsertPlayerControlKeysInString(gUString); + newColor = TEXT_COLOR; + FilterOutColorMarkersFromString(gUString, newColor); + + // newColor wasn't used at all! let's fix this + bool rgSame = newColor.r == TEXT_COLOR.r && newColor.g == TEXT_COLOR.g; + bool bSame = rgSame && newColor.b == TEXT_COLOR.b; + bool colorNotChanged = bSame +#ifndef FIX_BUGS + && newColor.a == TEXT_COLOR.a +#endif + ; -} + if (!colorNotChanged) { + newColor.r /= 2; + newColor.g /= 2; + newColor.b /= 2; + } +#ifdef FIX_BUGS + newColor.a = FadeIn(255); + // because some colors aren't visible, due to they were made for PS2 + CFont::SetDropColor(CRGBA(0, 0, 0, FadeIn(255))); + CFont::SetDropShadowPosition(1); + CFont::SetColor(newColor); #endif + CFont::PrintString(MENU_X_LEFT_ALIGNED(50.0f), nextY, gUString); + nextY += MENU_Y(menuXYpadding); + } + } +} -#if DONT_USE_SUSPICIOUS_FUNCS -WRAPPER void CMenuManager::PrintErrorMessage() { EAXJMP(0x484F70); } -#else -void CMenuManager::PrintErrorMessage() +// Not sure about name. Not to be confused with CPad::PrintErrorMessage +void +CMenuManager::PrintErrorMessage() { if (!CPad::bDisplayNoControllerMessage && !CPad::bObsoleteControllerMessage) return; - CSprite2d::DrawRect(CRect(SCREEN_SCALE_X(20.0f), SCREEN_SCALE_Y(140.0f), SCREEN_WIDTH - SCREEN_SCALE_X(20.0f), SCREEN_HEIGHT - SCREEN_SCALE_Y(140.0f)), CRGBA(64, 16, 16, 224)); + CSprite2d::DrawRect(CRect(SCREEN_SCALE_X(20.0f), SCREEN_SCALE_Y(140.0f), SCREEN_SCALE_FROM_RIGHT(20.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f)), CRGBA(64, 16, 16, 224)); CFont::SetFontStyle(FONT_BANK); CFont::SetBackgroundOff(); CFont::SetPropOn(); @@ -2792,27 +3238,96 @@ void CMenuManager::PrintErrorMessage() CFont::SetJustifyOn(); CFont::SetRightJustifyOff(); CFont::SetBackGroundOnlyTextOn(); - CFont::SetWrapx(SCREEN_WIDTH - 40.0f); - CFont::SetColor(CRGBA(165, 165, 165, 255)); - CFont::SetScale(SCREEN_SCALE_X(0.9f), SCREEN_SCALE_Y(0.9f)); - CFont::PrintString(SCREEN_SCALE_X(40.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(60.0f), TheText.Get(CPad::bDisplayNoControllerMessage ? "NOCONT" : "WRCONT")); + CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(40.0f)); +#ifdef FIX_BUGS + CFont::PrintString(SCREEN_SCALE_X(50.0f), SCREEN_SCALE_Y(180.0f), TheText.Get(CPad::bDisplayNoControllerMessage ? "NOCONT" : "WRCONT")); +#else + CFont::PrintString(SCREEN_SCALE_X(50.0f), SCREEN_SCALE_Y(40.0f), TheText.Get(CPad::bDisplayNoControllerMessage ? "NOCONT" : "WRCONT")); +#endif CFont::DrawFonts(); } -#endif -#if 1 -WRAPPER void CMenuManager::PrintStats() { EAXJMP(0x482100); } -#else -void CMenuManager::PrintStats() +void +CMenuManager::PrintStats() { + int rowNum = ConstructStatLine(99999); + CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X * 0.7), MENU_Y(MENU_TEXT_SIZE_Y * 0.9)); // second mulipliers are double, idk why + float nextYChange, y, alphaMult; + + // Scroll stats with mouse +#ifdef SCROLLABLE_STATS_PAGE + static float scrollY = 0; + static uint32 lastChange = m_nScreenChangeDelayTimer; + if (CPad::GetPad(0)->GetLeftMouse()) { + scrollY += (m_nMouseOldPosY - m_nMousePosY); + lastChange = CTimer::GetTimeInMillisecondsPauseMode(); + } else { + scrollY += MENU_Y(STATS_SLIDE_Y_PER_SECOND) / 1000.0f * (CTimer::GetTimeInMillisecondsPauseMode() - lastChange); + lastChange = CTimer::GetTimeInMillisecondsPauseMode(); + } +#else + // MENU_Y(30.0f) per second + float scrollY = MENU_Y(STATS_SLIDE_Y_PER_SECOND) * (CTimer::GetTimeInMillisecondsPauseMode() - m_nScreenChangeDelayTimer) / 1000.0f; +#endif + + for (int row = 0; row < rowNum; ++row) { + // Put just got hidden text at the top back to the bottom, in circular fashion + for (y = MENU_Y(STATS_ROW_HEIGHT - 1) * row + SCREEN_HEIGHT - scrollY; MENU_Y(STATS_PUT_BACK_TO_BOTTOM_Y) > y; y += nextYChange) { + nextYChange = (MENU_Y(STATS_ROW_HEIGHT) + rowNum) * MENU_Y(STATS_ROW_HEIGHT - 1); + } + + // If it's still on screen + if (y > 0.0f && SCREEN_HEIGHT > y) { + ConstructStatLine(row); + + // But about to dim from top + if (y - MENU_Y(STATS_BOTTOM_MARGIN) < MENU_Y(STATS_TOP_DIMMING_AREA_LENGTH)) { + if ((y - MENU_Y(STATS_BOTTOM_MARGIN)) / MENU_Y(STATS_TOP_DIMMING_AREA_LENGTH) < 0.0f) + alphaMult = 0.0f; + else + alphaMult = (y - MENU_Y(STATS_BOTTOM_MARGIN)) / MENU_Y(STATS_TOP_DIMMING_AREA_LENGTH); + + // About to dim from bottom + } else if (y > SCREEN_SCALE_FROM_BOTTOM(STATS_TOP_DIMMING_AREA_LENGTH) - MENU_Y(STATS_BOTTOM_DIMMING_AREA_LENGTH)) { + if ((SCREEN_SCALE_FROM_BOTTOM(STATS_BOTTOM_DIMMING_AREA_LENGTH) - y) / MENU_Y(STATS_TOP_DIMMING_AREA_LENGTH) < 0.0f) + alphaMult = 0.0f; + else + alphaMult = (SCREEN_SCALE_FROM_BOTTOM(STATS_BOTTOM_DIMMING_AREA_LENGTH) - y) / MENU_Y(STATS_TOP_DIMMING_AREA_LENGTH); + } else + alphaMult = 1.0f; + CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255.0f * alphaMult))); + CFont::SetRightJustifyOff(); + CFont::PrintString(MENU_X_LEFT_ALIGNED(STATS_ROW_X_MARGIN), y - MENU_Y(STATS_BOTTOM_MARGIN - STATS_TOP_MARGIN), gUString); + CFont::SetRightJustifyOn(); + CFont::PrintString(MENU_X_RIGHT_ALIGNED(STATS_ROW_X_MARGIN), y - MENU_Y(STATS_BOTTOM_MARGIN - STATS_TOP_MARGIN), gUString2); + } + } + // Game doesn't do that, but it's better + float nextX = MENU_X_LEFT_ALIGNED(STATS_RATING_X); + + CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255))); + CFont::SetRightJustifyOff(); + CFont::PrintString(nextX, MENU_Y(STATS_RATING_Y), TheText.Get("CRIMRA")); nextX += MENU_X(10.0f) + CFont::GetStringWidth(TheText.Get("CRIMRA"), true); + UnicodeStrcpy(gUString, CStats::FindCriminalRatingString()); + CFont::PrintString(nextX, MENU_Y(STATS_RATING_Y), gUString); nextX += MENU_X(6.0f) + CFont::GetStringWidth(gUString, true); + sprintf(gString, "%d", CStats::FindCriminalRatingNumber()); + AsciiToUnicode(gString, gUString); + CFont::PrintString(nextX, MENU_Y(STATS_RATING_Y), gUString); + + // ::Draw already does that. + /* + CFont::SetColor(CRGBA(0, 0, 0, FadeIn(255))); + CFont::SetRightJustifyOn(); + CFont::SetFontStyle(FONT_HEADING); + CFont::SetScale(MENU_X(MENUHEADER_WIDTH), MENU_Y(MENUHEADER_HEIGHT)); + CFont::PrintString(MENU_X_RIGHT_ALIGNED(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get(aScreens[m_nCurrScreen].m_ScreenName)); + */ + CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X), MENU_Y(MENU_TEXT_SIZE_Y)); } -#endif -#if 0 -WRAPPER void CMenuManager::Process(void) { EAXJMP(0x485100); } -#else -void CMenuManager::Process(void) +void +CMenuManager::Process(void) { m_bMenuStateChanged = false; @@ -2888,8 +3403,8 @@ void CMenuManager::Process(void) m_bStartWaitingForKeyBind = false; else { pControlEdit = CPad::EditCodesForControls(pControlEdit, 1); - JoyButtonJustClicked = 0; - MouseButtonJustClicked = 0; + JoyButtonJustClicked = false; + MouseButtonJustClicked = false; if (CPad::GetPad(0)->GetLeftMouseJustDown()) MouseButtonJustClicked = 1; @@ -2905,13 +3420,13 @@ void CMenuManager::Process(void) JoyButtonJustClicked = ControlsManager.GetJoyButtonJustDown(); - int32 TypeOfControl = 0; + int32 TypeOfControl = KEYBOARD; if (JoyButtonJustClicked) - TypeOfControl = 3; + TypeOfControl = JOYSTICK; if (MouseButtonJustClicked) - TypeOfControl = 2; + TypeOfControl = MOUSE; if (*pControlEdit != rsNULL) - TypeOfControl = 0; + TypeOfControl = KEYBOARD; if (!m_bKeyIsOK) { DMAudio.PlayFrontEndSound(SOUND_FRONTEND_FAIL, 0); @@ -2919,14 +3434,12 @@ void CMenuManager::Process(void) m_bWaitingForNewKeyBind = false; m_KeyPressedCode = -1; m_bStartWaitingForKeyBind = false; - } - else if (!m_bKeyChangeNotProcessed) { + } else if (!m_bKeyChangeNotProcessed) { if (*pControlEdit != rsNULL || MouseButtonJustClicked || JoyButtonJustClicked) CheckCodesForControls(TypeOfControl); field_535 = true; - } - else { + } else { DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); for (int i = 0; i < 4; i++) ControlsManager.ClearSettingsAssociatedWithAction((e_ControllerAction)m_CurrCntrlAction, (eControllerType)i); @@ -2940,7 +3453,7 @@ void CMenuManager::Process(void) } } - if ((m_nCurrScreen == MENUPAGE_13 || m_nCurrScreen == MENUPAGE_16) && CTimer::GetTimeInMillisecondsPauseMode() > field_558) { + if ((m_nCurrScreen == MENUPAGE_NO_MEMORY_CARD || m_nCurrScreen == MENUPAGE_PS2_LOAD_FAILED) && CTimer::GetTimeInMillisecondsPauseMode() > field_558) { m_nCurrScreen = m_nPrevScreen; m_nCurrOption = 0; } @@ -2965,11 +3478,7 @@ void CMenuManager::Process(void) DMAudio.Service(); } } -#endif -#if 0 -WRAPPER void CMenuManager::ProcessButtonPresses() { EAXJMP(0x4856F0); } -#else void CMenuManager::ProcessButtonPresses(void) { @@ -3277,10 +3786,10 @@ CMenuManager::ProcessButtonPresses(void) #ifdef TIDY_UP_PBP if (m_nHoverOption >= HOVEROPTION_RADIO_0 && m_nHoverOption <= HOVEROPTION_RADIO_9) { DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); - CMenuManager::m_PrefsRadioStation = m_nHoverOption - HOVEROPTION_RADIO_0; + m_PrefsRadioStation = m_nHoverOption - HOVEROPTION_RADIO_0; SaveSettings(); - DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); - DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + DMAudio.SetRadioInCar(m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); OutputDebugString("FRONTEND RADIO STATION CHANGED"); } else if (m_nHoverOption == HOVEROPTION_RANDOM_ITEM && aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action != MENUACTION_RESUME) { @@ -3291,82 +3800,82 @@ CMenuManager::ProcessButtonPresses(void) switch (m_nHoverOption) { case HOVEROPTION_RADIO_0: DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); - CMenuManager::m_PrefsRadioStation = HEAD_RADIO; + m_PrefsRadioStation = HEAD_RADIO; SaveSettings(); - DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); - DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + DMAudio.SetRadioInCar(m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); OutputDebugString("FRONTEND RADIO STATION CHANGED"); break; case HOVEROPTION_RADIO_1: DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); - CMenuManager::m_PrefsRadioStation = DOUBLE_CLEF; + m_PrefsRadioStation = DOUBLE_CLEF; SaveSettings(); - DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); - DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + DMAudio.SetRadioInCar(m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); OutputDebugString("FRONTEND RADIO STATION CHANGED"); break; case HOVEROPTION_RADIO_2: DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); - CMenuManager::m_PrefsRadioStation = JAH_RADIO; + m_PrefsRadioStation = JAH_RADIO; SaveSettings(); - DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); - DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + DMAudio.SetRadioInCar(m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); OutputDebugString("FRONTEND RADIO STATION CHANGED"); break; case HOVEROPTION_RADIO_3: DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); - CMenuManager::m_PrefsRadioStation = RISE_FM; + m_PrefsRadioStation = RISE_FM; SaveSettings(); - DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); - DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + DMAudio.SetRadioInCar(m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); OutputDebugString("FRONTEND RADIO STATION CHANGED"); break; case HOVEROPTION_RADIO_4: DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); - CMenuManager::m_PrefsRadioStation = LIPS_106; + m_PrefsRadioStation = LIPS_106; SaveSettings(); - DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); - DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + DMAudio.SetRadioInCar(m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); OutputDebugString("FRONTEND RADIO STATION CHANGED"); break; case HOVEROPTION_RADIO_5: DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); - CMenuManager::m_PrefsRadioStation = GAME_FM; + m_PrefsRadioStation = GAME_FM; SaveSettings(); - DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); - DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + DMAudio.SetRadioInCar(m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); OutputDebugString("FRONTEND RADIO STATION CHANGED"); break; case HOVEROPTION_RADIO_6: DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); - CMenuManager::m_PrefsRadioStation = MSX_FM; + m_PrefsRadioStation = MSX_FM; SaveSettings(); - DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); - DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + DMAudio.SetRadioInCar(m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); OutputDebugString("FRONTEND RADIO STATION CHANGED"); break; case HOVEROPTION_RADIO_7: DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); - CMenuManager::m_PrefsRadioStation = FLASHBACK; + m_PrefsRadioStation = FLASHBACK; SaveSettings(); - DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); - DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + DMAudio.SetRadioInCar(m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); OutputDebugString("FRONTEND RADIO STATION CHANGED"); break; case HOVEROPTION_RADIO_8: DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); - CMenuManager::m_PrefsRadioStation = CHATTERBOX; + m_PrefsRadioStation = CHATTERBOX; SaveSettings(); - DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); - DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + DMAudio.SetRadioInCar(m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); OutputDebugString("FRONTEND RADIO STATION CHANGED"); break; case HOVEROPTION_RADIO_9: DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); - CMenuManager::m_PrefsRadioStation = USERTRACK; + m_PrefsRadioStation = USERTRACK; SaveSettings(); - DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); - DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + DMAudio.SetRadioInCar(m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); OutputDebugString("FRONTEND RADIO STATION CHANGED"); break; case HOVEROPTION_RANDOM_ITEM: @@ -3383,74 +3892,74 @@ CMenuManager::ProcessButtonPresses(void) #ifndef TIDY_UP_PBP switch (m_nHoverOption) { case HOVEROPTION_INCREASE_BRIGHTNESS: - CMenuManager::m_PrefsBrightness = CMenuManager::m_PrefsBrightness + 32; - if (CMenuManager::m_PrefsBrightness < 0) { - CMenuManager::m_PrefsBrightness = 0; + m_PrefsBrightness = m_PrefsBrightness + 32; + if (m_PrefsBrightness < 0) { + m_PrefsBrightness = 0; } - if (510 < CMenuManager::m_PrefsBrightness) { - CMenuManager::m_PrefsBrightness = 511; + if (510 < m_PrefsBrightness) { + m_PrefsBrightness = 511; } SaveSettings(); break; case HOVEROPTION_DECREASE_BRIGHTNESS: - CMenuManager::m_PrefsBrightness = CMenuManager::m_PrefsBrightness - 32; - if (CMenuManager::m_PrefsBrightness < 0) { - CMenuManager::m_PrefsBrightness = 0; + m_PrefsBrightness = m_PrefsBrightness - 32; + if (m_PrefsBrightness < 0) { + m_PrefsBrightness = 0; } - if (510 < CMenuManager::m_PrefsBrightness) { - CMenuManager::m_PrefsBrightness = 511; + if (510 < m_PrefsBrightness) { + m_PrefsBrightness = 511; } SaveSettings(); break; case HOVEROPTION_INCREASE_DRAWDIST: - CMenuManager::m_PrefsLOD = CMenuManager::m_PrefsLOD + (1.0f / 16); + m_PrefsLOD = m_PrefsLOD + (1.0f / 16); m_PrefsLOD = min(1.8f, m_PrefsLOD); - CRenderer::ms_lodDistScale = CMenuManager::m_PrefsLOD; + CRenderer::ms_lodDistScale = m_PrefsLOD; SaveSettings(); break; case HOVEROPTION_DECREASE_DRAWDIST: - CMenuManager::m_PrefsLOD = CMenuManager::m_PrefsLOD - (1.0f / 16); + m_PrefsLOD = m_PrefsLOD - (1.0f / 16); m_PrefsLOD = max(0.8f, m_PrefsLOD); - CRenderer::ms_lodDistScale = CMenuManager::m_PrefsLOD; + CRenderer::ms_lodDistScale = m_PrefsLOD; SaveSettings(); break; case HOVEROPTION_INCREASE_MUSICVOLUME: - CMenuManager::m_PrefsMusicVolume = CMenuManager::m_PrefsMusicVolume + 8; + m_PrefsMusicVolume = m_PrefsMusicVolume + 8; m_PrefsMusicVolume = clamp(m_PrefsMusicVolume, 0, 127); - DMAudio.SetMusicMasterVolume(uchar)(CMenuManager::m_PrefsMusicVolume); + DMAudio.SetMusicMasterVolume(uchar)(m_PrefsMusicVolume); SaveSettings(); break; case HOVEROPTION_DECREASE_MUSICVOLUME: - CMenuManager::m_PrefsMusicVolume = CMenuManager::m_PrefsMusicVolume - 8; - if (CMenuManager::m_PrefsMusicVolume < 0) { - CMenuManager::m_PrefsMusicVolume = 0; + m_PrefsMusicVolume = m_PrefsMusicVolume - 8; + if (m_PrefsMusicVolume < 0) { + m_PrefsMusicVolume = 0; } - if (126 < CMenuManager::m_PrefsMusicVolume) { - CMenuManager::m_PrefsMusicVolume = 127; + if (126 < m_PrefsMusicVolume) { + m_PrefsMusicVolume = 127; } - DMAudio.SetMusicMasterVolume(uchar)(CMenuManager::m_PrefsMusicVolume); + DMAudio.SetMusicMasterVolume(uchar)(m_PrefsMusicVolume); SaveSettings(); break; case HOVEROPTION_INCREASE_SFXVOLUME: - CMenuManager::m_PrefsSFXVolume = CMenuManager::m_PrefsSFXVolume + 8; - if (CMenuManager::m_PrefsSFXVolume < 0) { - CMenuManager::m_PrefsSFXVolume = 0; + m_PrefsSFXVolume = m_PrefsSFXVolume + 8; + if (m_PrefsSFXVolume < 0) { + m_PrefsSFXVolume = 0; } - if (126 < CMenuManager::m_PrefsSFXVolume) { - CMenuManager::m_PrefsSFXVolume = 127; + if (126 < m_PrefsSFXVolume) { + m_PrefsSFXVolume = 127; } - DMAudio.SetEffectsMasterVolume(uchar)(CMenuManager::m_PrefsSFXVolume); + DMAudio.SetEffectsMasterVolume(uchar)(m_PrefsSFXVolume); SaveSettings(); break; case HOVEROPTION_DECREASE_SFXVOLUME: - CMenuManager::m_PrefsSFXVolume = CMenuManager::m_PrefsSFXVolume - 8; - if (CMenuManager::m_PrefsSFXVolume < 0) { - CMenuManager::m_PrefsSFXVolume = 0; + m_PrefsSFXVolume = m_PrefsSFXVolume - 8; + if (m_PrefsSFXVolume < 0) { + m_PrefsSFXVolume = 0; } - if (126 < CMenuManager::m_PrefsSFXVolume) { - CMenuManager::m_PrefsSFXVolume = 127; + if (126 < m_PrefsSFXVolume) { + m_PrefsSFXVolume = 127; } - DMAudio.SetEffectsMasterVolume(uchar)(CMenuManager::m_PrefsSFXVolume); + DMAudio.SetEffectsMasterVolume(uchar)(m_PrefsSFXVolume); SaveSettings(); break; case HOVEROPTION_INCREASE_MOUSESENS: @@ -3664,7 +4173,7 @@ CMenuManager::ProcessButtonPresses(void) strcpy(m_PrefsSkinFile, m_aSkinName); CWorld::Players[0].SetPlayerSkin(m_PrefsSkinFile); m_nCurrExLayer = HOVEROPTION_BACK; - CMenuManager::SaveSettings(); + SaveSettings(); } m_nHoverOption = HOVEROPTION_NOT_HOVERING; break; @@ -3700,54 +4209,54 @@ CMenuManager::ProcessButtonPresses(void) #ifdef TIDY_UP_PBP assumeIncrease = true; #else - ++CMenuManager::m_PrefsRadioStation; + ++m_PrefsRadioStation; if (DMAudio.IsMP3RadioChannelAvailable()) { - if (CMenuManager::m_PrefsRadioStation > USERTRACK) - CMenuManager::m_PrefsRadioStation = HEAD_RADIO; - } else if (CMenuManager::m_PrefsRadioStation > CHATTERBOX) { - CMenuManager::m_PrefsRadioStation = USERTRACK; + if (m_PrefsRadioStation > USERTRACK) + m_PrefsRadioStation = HEAD_RADIO; + } else if (m_PrefsRadioStation > CHATTERBOX) { + m_PrefsRadioStation = USERTRACK; } SaveSettings(); - DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); - DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + DMAudio.SetRadioInCar(m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); OutputDebugString("FRONTEND RADIO STATION CHANGED"); #endif break; case MENUACTION_LANG_ENG: m_PrefsLanguage = LANGUAGE_AMERICAN; m_bFrontEnd_ReloadObrTxtGxt = true; - CMenuManager::InitialiseChangedLanguageSettings(); - CMenuManager::SaveSettings(); + InitialiseChangedLanguageSettings(); + SaveSettings(); break; case MENUACTION_LANG_FRE: m_PrefsLanguage = LANGUAGE_FRENCH; m_bFrontEnd_ReloadObrTxtGxt = true; - CMenuManager::InitialiseChangedLanguageSettings(); - CMenuManager::SaveSettings(); + InitialiseChangedLanguageSettings(); + SaveSettings(); break; case MENUACTION_LANG_GER: m_PrefsLanguage = LANGUAGE_GERMAN; m_bFrontEnd_ReloadObrTxtGxt = true; - CMenuManager::InitialiseChangedLanguageSettings(); - CMenuManager::SaveSettings(); + InitialiseChangedLanguageSettings(); + SaveSettings(); break; case MENUACTION_LANG_ITA: m_PrefsLanguage = LANGUAGE_ITALIAN; m_bFrontEnd_ReloadObrTxtGxt = true; - CMenuManager::InitialiseChangedLanguageSettings(); - CMenuManager::SaveSettings(); + InitialiseChangedLanguageSettings(); + SaveSettings(); break; case MENUACTION_LANG_SPA: m_PrefsLanguage = LANGUAGE_SPANISH; m_bFrontEnd_ReloadObrTxtGxt = true; - CMenuManager::InitialiseChangedLanguageSettings(); + InitialiseChangedLanguageSettings(); SaveSettings(); break; #ifdef MORE_LANGUAGES case MENUACTION_LANG_RUS: m_PrefsLanguage = LANGUAGE_RUSSIAN; m_bFrontEnd_ReloadObrTxtGxt = true; - CMenuManager::InitialiseChangedLanguageSettings(); + InitialiseChangedLanguageSettings(); SaveSettings(); break; #endif @@ -3779,7 +4288,7 @@ CMenuManager::ProcessButtonPresses(void) if (changeMenu) { if (strncmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEDS_TB", 8) == 0) { #ifndef TIDY_UP_PBP - CMenuManager::ResetHelperText(); + ResetHelperText(); if (!m_bGameNotLoaded) ChangeScreen(aScreens[m_nCurrScreen].m_PreviousPage[1], aScreens[m_nCurrScreen].m_ParentEntry[1], true, true); else @@ -3794,6 +4303,9 @@ CMenuManager::ProcessButtonPresses(void) fMapCenterX = SCREEN_WIDTH / 2; fMapCenterY = SCREEN_HEIGHT / 3; fMapSize = SCREEN_HEIGHT / CDraw::GetAspectRatio(); + bMapMouseShownOnce = false; + CPad::GetPad(0)->Clear(false); + CPad::GetPad(1)->Clear(false); } #endif @@ -3815,7 +4327,7 @@ CMenuManager::ProcessButtonPresses(void) break; } case MENUACTION_NEWGAME: - CMenuManager::DoSettingsBeforeStartingAGame(); + DoSettingsBeforeStartingAGame(); break; case MENUACTION_RELOADIDE: // TODO @@ -3830,7 +4342,7 @@ CMenuManager::ProcessButtonPresses(void) case MENUACTION_MEMCARDSAVECONFIRM: return; case MENUACTION_RESUME_FROM_SAVEZONE: - CMenuManager::RequestFrontEndShutDown(); + RequestFrontEndShutDown(); break; case MENUACTION_MPMAP_LIBERTY: case MENUACTION_MPMAP_REDLIGHT: @@ -3840,8 +4352,8 @@ CMenuManager::ProcessButtonPresses(void) case MENUACTION_MPMAP_INDUSTPARK: case MENUACTION_MPMAP_DOCKS: case MENUACTION_MPMAP_STAUNTON: - sthWithButtons = option - MENUACTION_MPMAP_LIBERTY; - CMenuManager::SaveSettings(); + m_SelectedMap = option - MENUACTION_MPMAP_LIBERTY; + SaveSettings(); ChangeScreen(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu, 0, true, true); break; case MENUACTION_MPMAP_DEATHMATCH1: @@ -3852,8 +4364,8 @@ CMenuManager::ProcessButtonPresses(void) case MENUACTION_MPMAP_CAPTURE: case MENUACTION_MPMAP_RATRACE: case MENUACTION_MPMAP_DOMINATION: - sthWithButtons2 = option - MENUACTION_MPMAP_DEATHMATCH1; - CMenuManager::SaveSettings(); + m_SelectedGameType = option - MENUACTION_MPMAP_DEATHMATCH1; + SaveSettings(); ChangeScreen(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu, 0, true, true); break; case MENUACTION_REDEFCTRL: @@ -3874,10 +4386,10 @@ CMenuManager::ProcessButtonPresses(void) break; case MENUACTION_RESUME: #ifndef TIDY_UP_PBP - if (CMenuManager::m_PrefsVsyncDisp != CMenuManager::m_PrefsVsync) { - CMenuManager::m_PrefsVsync = CMenuManager::m_PrefsVsyncDisp; + if (m_PrefsVsyncDisp != m_PrefsVsync) { + m_PrefsVsync = m_PrefsVsyncDisp; } - CMenuManager::RequestFrontEndShutDown(); + RequestFrontEndShutDown(); #else goBack = true; #endif @@ -3929,26 +4441,25 @@ CMenuManager::ProcessButtonPresses(void) break; case MENUACTION_RESTOREDEF: if (m_nCurrScreen == MENUPAGE_SOUND_SETTINGS) { - CMenuManager::m_PrefsSfxVolume = 102; + m_PrefsSfxVolume = 102; m_PrefsSpeakers = 0; - CMenuManager::m_PrefsMusicVolume = 102; - // unused - // byte_95CDB5 = 0; - CMenuManager::m_PrefsRadioStation = HEAD_RADIO; + m_PrefsMusicVolume = 102; + m_PrefsStereoMono = 0; + m_PrefsRadioStation = HEAD_RADIO; DMAudio.SetMusicMasterVolume(102); - DMAudio.SetEffectsMasterVolume(CMenuManager::m_PrefsSfxVolume); - DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); - DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + DMAudio.SetEffectsMasterVolume(m_PrefsSfxVolume); + DMAudio.SetRadioInCar(m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); SaveSettings(); } else if (m_nCurrScreen == MENUPAGE_GRAPHICS_SETTINGS) { - CMenuManager::m_PrefsFrameLimiter = true; - CMenuManager::m_PrefsBrightness = 256; - CMenuManager::m_PrefsVsyncDisp = true; - CMenuManager::m_PrefsLOD = 1.2f; - CMenuManager::m_PrefsVsync = true; + m_PrefsFrameLimiter = true; + m_PrefsBrightness = 256; + m_PrefsVsyncDisp = true; + m_PrefsLOD = 1.2f; + m_PrefsVsync = true; CRenderer::ms_lodDistScale = 1.2f; - CMenuManager::m_PrefsUseWideScreen = false; - CMenuManager::m_PrefsShowSubtitles = true; + m_PrefsUseWideScreen = false; + m_PrefsShowSubtitles = true; m_nDisplayVideoMode = m_nPrefsVideoMode; CMBlur::BlurOn = true; SaveSettings(); @@ -3962,23 +4473,23 @@ CMenuManager::ProcessButtonPresses(void) PSGLOBAL(joy1)->GetCapabilities(&devCaps); ControlsManager.InitDefaultControlConfigJoyPad(devCaps.dwButtons); } - CMenuManager::m_ControlMethod = CONTROL_STANDARD; + m_ControlMethod = CONTROL_STANDARD; MousePointerStateHelper.bInvertVertically = false; TheCamera.m_fMouseAccelHorzntl = 0.0025f; CVehicle::m_bDisableMouseSteering = true; TheCamera.m_bHeadBob = false; SaveSettings(); } - CMenuManager::SetHelperText(2); + SetHelperText(2); break; case MENUACTION_CTRLMETHOD: #ifndef TIDY_UP_PBP - if (CMenuManager::m_ControlMethod == CONTROL_CLASSIC) { + if (m_ControlMethod == CONTROL_CLASSIC) { CCamera::m_bUseMouse3rdPerson = true; - CMenuManager::m_ControlMethod = CONTROL_STANDARD; + m_ControlMethod = CONTROL_STANDARD; } else { CCamera::m_bUseMouse3rdPerson = false; - CMenuManager::m_ControlMethod = CONTROL_CLASSIC; + m_ControlMethod = CONTROL_CLASSIC; } SaveSettings(); #else @@ -3987,7 +4498,7 @@ CMenuManager::ProcessButtonPresses(void) break; case MENUACTION_LOADRADIO: ChangeScreen(MENUPAGE_SOUND_SETTINGS, 0, true, true); - DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); OutputDebugString("STARTED PLAYING FRONTEND AUDIO TRACK"); break; } @@ -3996,7 +4507,7 @@ CMenuManager::ProcessButtonPresses(void) } if (goBack) { - CMenuManager::ResetHelperText(); + ResetHelperText(); DMAudio.PlayFrontEndSound(SOUND_FRONTEND_EXIT, 0); #ifdef PS2_LIKE_MENU if (m_nCurrScreen == MENUPAGE_PAUSE_MENU || bottomBarActive) { @@ -4004,10 +4515,10 @@ CMenuManager::ProcessButtonPresses(void) if (m_nCurrScreen == MENUPAGE_PAUSE_MENU) { #endif if (!m_bGameNotLoaded && !m_bMenuStateChanged) { - if (CMenuManager::m_PrefsVsyncDisp != CMenuManager::m_PrefsVsync) { - CMenuManager::m_PrefsVsync = CMenuManager::m_PrefsVsyncDisp; + if (m_PrefsVsyncDisp != m_PrefsVsync) { + m_PrefsVsync = m_PrefsVsyncDisp; } - CMenuManager::RequestFrontEndShutDown(); + RequestFrontEndShutDown(); } // We're already resuming, we don't need further processing. @@ -4020,7 +4531,7 @@ CMenuManager::ProcessButtonPresses(void) #else else if (m_nCurrScreen == MENUPAGE_CHOOSE_SAVE_SLOT) { #endif - CMenuManager::RequestFrontEndShutDown(); + RequestFrontEndShutDown(); } // It's now in ThingsToDoBeforeLeavingPage() #ifndef TIDY_UP_PBP @@ -4068,13 +4579,13 @@ CMenuManager::ProcessButtonPresses(void) if (CPad::GetPad(0)->GetLeft() || CPad::GetPad(0)->GetPedWalkLeftRight() < 0 || CPad::GetPad(0)->GetDPadLeft()) { static uint32 lastSliderDecrease = 0; if (CTimer::GetTimeInMillisecondsPauseMode() - lastSliderDecrease > 150) { - CMenuManager::CheckSliderMovement(-1); + CheckSliderMovement(-1); lastSliderDecrease = CTimer::GetTimeInMillisecondsPauseMode(); } } else if (CPad::GetPad(0)->GetRight() || CPad::GetPad(0)->GetPedWalkLeftRight() > 0 || CPad::GetPad(0)->GetDPadRight()) { static uint32 lastSliderIncrease = 0; if (CTimer::GetTimeInMillisecondsPauseMode() - lastSliderIncrease > 150) { - CMenuManager::CheckSliderMovement(1); + CheckSliderMovement(1); lastSliderIncrease = CTimer::GetTimeInMillisecondsPauseMode(); } } @@ -4084,7 +4595,7 @@ CMenuManager::ProcessButtonPresses(void) increase = true; } else if (CPad::GetPad(0)->GetMouseWheelUpJustDown() && m_nCurrScreen != MENUPAGE_KEYBOARD_CONTROLS) { increase = true; - CMenuManager::CheckSliderMovement(1); + CheckSliderMovement(1); m_bShowMouse = true; } @@ -4092,7 +4603,7 @@ CMenuManager::ProcessButtonPresses(void) if (CPad::GetPad(0)->GetMouseWheelDownJustDown()) { if (m_nCurrScreen != MENUPAGE_KEYBOARD_CONTROLS) { decrease = true; - CMenuManager::CheckSliderMovement(-1); + CheckSliderMovement(-1); m_bShowMouse = true; } } @@ -4109,22 +4620,22 @@ CMenuManager::ProcessButtonPresses(void) if (changeValueBy != 0) { switch (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action) { case MENUACTION_RADIO: - CMenuManager::m_PrefsRadioStation += changeValueBy; + m_PrefsRadioStation += changeValueBy; DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); if (DMAudio.IsMP3RadioChannelAvailable()) { - if (CMenuManager::m_PrefsRadioStation < HEAD_RADIO) - CMenuManager::m_PrefsRadioStation = USERTRACK; - if (CMenuManager::m_PrefsRadioStation > USERTRACK) - CMenuManager::m_PrefsRadioStation = HEAD_RADIO; + if (m_PrefsRadioStation < HEAD_RADIO) + m_PrefsRadioStation = USERTRACK; + if (m_PrefsRadioStation > USERTRACK) + m_PrefsRadioStation = HEAD_RADIO; } else { - if (CMenuManager::m_PrefsRadioStation < HEAD_RADIO) - CMenuManager::m_PrefsRadioStation = CHATTERBOX; - if (CMenuManager::m_PrefsRadioStation > CHATTERBOX) - CMenuManager::m_PrefsRadioStation = HEAD_RADIO; + if (m_PrefsRadioStation < HEAD_RADIO) + m_PrefsRadioStation = CHATTERBOX; + if (m_PrefsRadioStation > CHATTERBOX) + m_PrefsRadioStation = HEAD_RADIO; } - CMenuManager::SaveSettings(); - DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); - DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + SaveSettings(); + DMAudio.SetRadioInCar(m_PrefsRadioStation); + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); OutputDebugString("FRONTEND RADIO STATION CHANGED"); break; case MENUACTION_SCREENRES: @@ -4160,15 +4671,15 @@ CMenuManager::ProcessButtonPresses(void) m_PrefsSpeakers -= changeValueBy; m_PrefsSpeakers = clamp(m_PrefsSpeakers, 0, 2); DMAudio.SetSpeakerConfig(m_PrefsSpeakers); - CMenuManager::SaveSettings(); + SaveSettings(); DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); } break; case MENUACTION_CTRLMETHOD: - CMenuManager::m_ControlMethod = !m_ControlMethod; + m_ControlMethod = !m_ControlMethod; CCamera::m_bUseMouse3rdPerson = !m_ControlMethod; DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); - CMenuManager::SaveSettings(); + SaveSettings(); break; } ProcessOnOffMenuOptions(); @@ -4182,12 +4693,9 @@ CMenuManager::ProcessButtonPresses(void) } } } -#endif -#if 0 -WRAPPER void CMenuManager::ProcessOnOffMenuOptions() { EAXJMP(0x48AE60); } -#else -void CMenuManager::ProcessOnOffMenuOptions() +void +CMenuManager::ProcessOnOffMenuOptions() { switch (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action) { case MENUACTION_CTRLVIBRATION: @@ -4265,7 +4773,9 @@ void CMenuManager::ProcessOnOffMenuOptions() DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); break; case MENUACTION_MP_PLAYERCOLOR: - assert(0 && "Not implemented"); + PickNewPlayerColour(); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + SaveSettings(); break; case MENUACTION_SHOWHEADBOB: TheCamera.m_bHeadBob = !TheCamera.m_bHeadBob; @@ -4290,34 +4800,29 @@ void CMenuManager::ProcessOnOffMenuOptions() break; } } -#endif -void CMenuManager::RequestFrontEndShutDown() +void +CMenuManager::RequestFrontEndShutDown() { m_bShutDownFrontEndRequested = true; DMAudio.ChangeMusicMode(MUSICMODE_GAME); } -#if DONT_USE_SUSPICIOUS_FUNCS -WRAPPER void CMenuManager::RequestFrontEndStartUp() { EAXJMP(0x488770); } -#else -void CMenuManager::RequestFrontEndStartUp() +void +CMenuManager::RequestFrontEndStartUp() { m_bStartUpFrontEndRequested = true; } -#endif -#if DONT_USE_SUSPICIOUS_FUNCS -WRAPPER void CMenuManager::ResetHelperText() { EAXJMP(0x48B470); } -#else -void CMenuManager::ResetHelperText() +void +CMenuManager::ResetHelperText() { m_nHelperTextMsgId = 0; m_nHelperTextAlpha = 300; } -#endif -void CMenuManager::SaveLoadFileError_SetUpErrorScreen() +void +CMenuManager::SaveLoadFileError_SetUpErrorScreen() { switch (PcSaveHelper.nErrorCode) { case SAVESTATUS_ERR_SAVE_CREATE: @@ -4341,27 +4846,22 @@ void CMenuManager::SaveLoadFileError_SetUpErrorScreen() } } -#if DONT_USE_SUSPICIOUS_FUNCS -WRAPPER void CMenuManager::SetHelperText(int text) { EAXJMP(0x48B450); } -#else -void CMenuManager::SetHelperText(int text) +void +CMenuManager::SetHelperText(int text) { m_nHelperTextMsgId = text; m_nHelperTextAlpha = 300; } -#endif -#if DONT_USE_SUSPICIOUS_FUNCS -WRAPPER void CMenuManager::ShutdownJustMenu() { EAXJMP(0x488920); } -#else -void CMenuManager::ShutdownJustMenu() +void +CMenuManager::ShutdownJustMenu() { m_bMenuActive = false; CTimer::EndUserPause(); } -#endif -float CMenuManager::StretchX(float x) +float +CMenuManager::StretchX(float x) { if (SCREEN_WIDTH == DEFAULT_SCREEN_WIDTH) return x; @@ -4379,10 +4879,8 @@ float CMenuManager::StretchY(float y) return SCREEN_STRETCH_Y(y); } -#if 0 -WRAPPER void CMenuManager::SwitchMenuOnAndOff() { EAXJMP(0x488790); } -#else -void CMenuManager::SwitchMenuOnAndOff() +void +CMenuManager::SwitchMenuOnAndOff() { bool menuWasActive = !!m_bMenuActive; @@ -4414,7 +4912,7 @@ void CMenuManager::SwitchMenuOnAndOff() m_bStartUpFrontEndRequested = false; pControlEdit = nil; m_bShutDownFrontEndRequested = false; - DisplayComboButtonErrMsg = 0; + DisplayComboButtonErrMsg = false; CPad::GetPad(0)->Clear(0); CPad::GetPad(1)->Clear(0); m_nCurrScreen = MENUPAGE_NONE; @@ -4449,12 +4947,9 @@ void CMenuManager::SwitchMenuOnAndOff() m_bStartUpFrontEndRequested = false; m_bShutDownFrontEndRequested = false; } -#endif -#if 0 -WRAPPER void CMenuManager::UnloadTextures() { EAXJMP(0x47A440); } -#else -void CMenuManager::UnloadTextures() +void +CMenuManager::UnloadTextures() { if (!m_bSpritesLoaded) return; @@ -4478,26 +4973,34 @@ void CMenuManager::UnloadTextures() m_bSpritesLoaded = false; } -#endif -#if DONT_USE_SUSPICIOUS_FUNCS -WRAPPER void CMenuManager::WaitForUserCD(void) { EAXJMP(0x48ADD0); } -#else -void CMenuManager::WaitForUserCD() +void +CMenuManager::WaitForUserCD() { - LoadSplash(0); - if (!RsGlobal.quit) { - HandleExit(); - CPad::UpdatePads(); - MessageScreen("NO_PCCD"); - - if (GetPadBack()) { - m_bQuitGameNoCD = true; - RsEventHandler(rsQUITAPP, 0); - } + CSprite2d *splash; + char *splashscreen = nil; + +#ifndef RANDOMSPLASH + if (CGame::frenchGame || CGame::germanGame || !CGame::nastyGame) + splashscreen = "mainsc2"; + else + splashscreen = "mainsc1"; +#endif + + splash = LoadSplash(splashscreen); + + if (RsGlobal.quit) + return; + + HandleExit(); + CPad::UpdatePads(); + MessageScreen("NO_PCCD"); + + if (CPad::GetPad(0)->GetEscapeJustDown()) { + m_bQuitGameNoCD = true; + RsEventHandler(rsQUITAPP, nil); } } -#endif void CMenuManager::PrintController(void) @@ -4760,7 +5263,7 @@ CMenuManager::PrintMap(void) fMapCenterX + halfTile, fMapCenterY - halfTile), CRGBA(255, 255, 255, FadeIn(255))); } - if (SCREEN_WIDTH >= fMapCenterX - halfTile || SCREEN_HEIGHT >= fMapCenterY - fMapSize) { + if (SCREEN_WIDTH >= fMapCenterX + halfTile || SCREEN_HEIGHT >= fMapCenterY - fMapSize) { m_aMapSprites[MAPTOP3].Draw(CRect(fMapCenterX + halfTile, fMapCenterY - fMapSize, fMapCenterX + fMapSize, fMapCenterY - halfTile), CRGBA(255, 255, 255, FadeIn(255))); } @@ -4775,47 +5278,55 @@ CMenuManager::PrintMap(void) fMapCenterX + halfTile, fMapCenterY + halfTile), CRGBA(255, 255, 255, FadeIn(255))); } - if (SCREEN_WIDTH >= fMapCenterX - halfTile || SCREEN_HEIGHT >= fMapCenterY - halfTile) { + if (SCREEN_WIDTH >= fMapCenterX + halfTile || SCREEN_HEIGHT >= fMapCenterY - halfTile) { m_aMapSprites[MAPMID3].Draw(CRect(fMapCenterX + halfTile, fMapCenterY - halfTile, fMapCenterX + fMapSize, fMapCenterY + halfTile), CRGBA(255, 255, 255, FadeIn(255))); } - if (SCREEN_WIDTH >= fMapCenterX - fMapSize || SCREEN_HEIGHT >= fMapCenterY - halfTile) { + if (SCREEN_WIDTH >= fMapCenterX - fMapSize || SCREEN_HEIGHT >= fMapCenterY + halfTile) { m_aMapSprites[MAPBOT1].Draw(CRect(fMapCenterX - fMapSize, fMapCenterY + halfTile, fMapCenterX - halfTile, fMapCenterY + fMapSize), CRGBA(255, 255, 255, FadeIn(255))); } - if (SCREEN_WIDTH >= fMapCenterX - halfTile || SCREEN_HEIGHT >= fMapCenterY - halfTile) { + if (SCREEN_WIDTH >= fMapCenterX - halfTile || SCREEN_HEIGHT >= fMapCenterY + halfTile) { m_aMapSprites[MAPBOT2].Draw(CRect(fMapCenterX - halfTile, fMapCenterY + halfTile, fMapCenterX + halfTile, fMapCenterY + fMapSize), CRGBA(255, 255, 255, FadeIn(255))); } - if (SCREEN_WIDTH >= fMapCenterX - halfTile || SCREEN_HEIGHT >= fMapCenterY - halfTile) { + if (SCREEN_WIDTH >= fMapCenterX + halfTile || SCREEN_HEIGHT >= fMapCenterY + halfTile) { m_aMapSprites[MAPBOT3].Draw(CRect(fMapCenterX + halfTile, fMapCenterY + halfTile, fMapCenterX + fMapSize, fMapCenterY + fMapSize), CRGBA(255, 255, 255, FadeIn(255))); } CRadar::DrawBlips(); - if (CPad::GetPad(0)->GetRightMouseJustDown()) { - if (m_nMousePosY > fMapCenterY - fMapSize && m_nMousePosY < fMapCenterY + fMapSize && - m_nMousePosX > fMapCenterX - fMapSize && m_nMousePosX < fMapCenterX + fMapSize) { + CVector2D mapPoint; + mapPoint.x = m_nMousePosX; + mapPoint.y = m_nMousePosY; - float diffX = fMapCenterX - fMapSize, diffY = fMapCenterY - fMapSize; - float x = ((m_nMousePosX - diffX) / (fMapSize * 2)) * 4000.0f - 2000.0f; - float y = 2000.0f - ((m_nMousePosY - diffY) / (fMapSize * 2)) * 4000.0f; - CRadar::ToggleTargetMarker(x, y); - } + if (m_bShowMouse) { + bMapMouseShownOnce = true; + } else if (!bMapMouseShownOnce) { + mapPoint.x = SCREEN_WIDTH / 2; + mapPoint.y = SCREEN_HEIGHT / 2; } - if (CPad::GetPad(0)->GetCrossJustDown()) { - if (SCREEN_HEIGHT / 2 > fMapCenterY - fMapSize && SCREEN_HEIGHT / 2 < fMapCenterY + fMapSize && - SCREEN_WIDTH / 2 > fMapCenterX - fMapSize && SCREEN_WIDTH / 2 < fMapCenterX + fMapSize) { + CSprite2d::DrawRect(CRect(mapPoint.x - MENU_X(1.0f), 0.0f, + mapPoint.x + MENU_X(1.0f), SCREEN_HEIGHT), + CRGBA(0, 0, 0, 150)); + CSprite2d::DrawRect(CRect(0.0f, mapPoint.y + MENU_X(1.0f), + SCREEN_WIDTH, mapPoint.y - MENU_X(1.0f)), + CRGBA(0, 0, 0, 150)); + + if (CPad::GetPad(0)->GetRightMouseJustDown() || CPad::GetPad(0)->GetCrossJustDown()) { + if (mapPoint.y > fMapCenterY - fMapSize && mapPoint.y < fMapCenterY + fMapSize && + mapPoint.x > fMapCenterX - fMapSize && mapPoint.x < fMapCenterX + fMapSize) { float diffX = fMapCenterX - fMapSize, diffY = fMapCenterY - fMapSize; - float x = ((SCREEN_WIDTH / 2 - diffX) / (fMapSize * 2)) * 4000.0f - 2000.0f; - float y = 2000.0f - ((SCREEN_HEIGHT / 2 - diffY) / (fMapSize * 2)) * 4000.0f; + float x = ((mapPoint.x - diffX) / (fMapSize * 2)) * 4000.0f - 2000.0f; + float y = 2000.0f - ((mapPoint.y - diffY) / (fMapSize * 2)) * 4000.0f; CRadar::ToggleTargetMarker(x, y); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); } } @@ -4838,14 +5349,14 @@ CMenuManager::PrintMap(void) fMapCenterY -= CPad::GetPad(0)->GetLeftStickY() / 128.0f * 20.0f; } - if (CPad::GetPad(0)->GetMouseWheelDown() || CPad::GetPad(0)->GetPageUp() || CPad::GetPad(0)->GetRightShoulder2()) { + if (CPad::GetPad(0)->GetMouseWheelDown() || CPad::GetPad(0)->GetPageDown() || CPad::GetPad(0)->GetRightShoulder2()) { if (CPad::GetPad(0)->GetMouseWheelDown()) - ZOOM(m_nMousePosX, m_nMousePosY, false); + ZOOM(mapPoint.x, mapPoint.y, false); else ZOOM(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, false); - } else if (CPad::GetPad(0)->GetMouseWheelUp() || CPad::GetPad(0)->GetPageDown() || CPad::GetPad(0)->GetRightShoulder1()) { + } else if (CPad::GetPad(0)->GetMouseWheelUp() || CPad::GetPad(0)->GetPageUp() || CPad::GetPad(0)->GetRightShoulder1()) { if (CPad::GetPad(0)->GetMouseWheelUp()) - ZOOM(m_nMousePosX, m_nMousePosY, true); + ZOOM(mapPoint.x, mapPoint.y, true); else ZOOM(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, true); } @@ -4880,11 +5391,11 @@ CMenuManager::PrintMap(void) text = TheText.Get(key); CFont::PrintString(nextX, SCREEN_SCALE_FROM_BOTTOM(nextY), text); nextX += CFont::GetStringWidth(text, true) + MENU_X(extraSpace); TEXT_PIECE("FEC_MWF", 3.0f); - TEXT_PIECE("FEC_PGD", 1.0f); + TEXT_PIECE("FEC_PGU", 1.0f); TEXT_PIECE("FEC_IBT", 1.0f); TEXT_PIECE("FEC_ZIN", 20.0f); TEXT_PIECE("FEC_MWB", 3.0f); - TEXT_PIECE("FEC_PGU", 1.0f); + TEXT_PIECE("FEC_PGD", 1.0f); TEXT_PIECE("FEC_IBT", 1.0f); CFont::PrintString(nextX, SCREEN_SCALE_FROM_BOTTOM(nextY), TheText.Get("FEC_ZOT")); nextX = MENU_X(30.0f); nextY -= 11.0f; TEXT_PIECE("FEC_UPA", 2.0f); @@ -4903,6 +5414,179 @@ CMenuManager::PrintMap(void) #undef ZOOM #endif +// rowIdx 99999 returns total numbers of rows. otherwise it returns 0. +int +CMenuManager::ConstructStatLine(int rowIdx) +{ +#define STAT_LINE(str, left, isFloat, right) \ + do { \ + if(counter == rowIdx){ \ + BuildStatLine(str, left, isFloat, right); \ + return 0; \ + } counter++; \ + } while(0) + + int counter = 0, nTemp; + + STAT_LINE("PL_STAT", nil, false, nil); + + int percentCompleted = (CStats::TotalProgressInGame == 0 ? 0 : + CStats::ProgressMade * 100.0f / (CGame::nastyGame ? CStats::TotalProgressInGame : CStats::TotalProgressInGame - 1)); + percentCompleted = min(percentCompleted, 100); + + STAT_LINE("PER_COM", &percentCompleted, false, nil); + STAT_LINE("NMISON", &CStats::MissionsGiven, false, nil); + STAT_LINE("FEST_MP", &CStats::MissionsPassed, 0, &CStats::TotalNumberMissions); + if (CGame::nastyGame) { + STAT_LINE("FEST_RP", &CStats::NumberKillFrenziesPassed, 0, &CStats::TotalNumberKillFrenzies); + } + + CPlayerInfo &player = CWorld::Players[CWorld::PlayerInFocus]; + float packagesPercent = 0.0f; + if (player.m_nTotalPackages != 0) + packagesPercent = player.m_nCollectedPackages * 100.0f / player.m_nTotalPackages; + + STAT_LINE("PERPIC", &packagesPercent, 0, &(nTemp = 100)); + STAT_LINE("NOUNIF", &CStats::TotalNumberOfUniqueJumps, 0, &CStats::NumberOfUniqueJumpsFound); + STAT_LINE("DAYSPS", &CStats::DaysPassed, false, nil); + if (CGame::nastyGame) { + STAT_LINE("PE_WAST", &CStats::PeopleKilledByPlayer, false, nil); + STAT_LINE("PE_WSOT", &CStats::PeopleKilledByOthers, false, nil); + } + STAT_LINE("CAR_EXP", &CStats::CarsExploded, false, nil); + STAT_LINE("TM_BUST", &CStats::TimesArrested, false, nil); + STAT_LINE("TM_DED", &CStats::TimesDied, false, nil); + STAT_LINE("GNG_WST", &(nTemp = CStats::PedsKilledOfThisType[PEDTYPE_GANG9] + CStats::PedsKilledOfThisType[PEDTYPE_GANG8] + + CStats::PedsKilledOfThisType[PEDTYPE_GANG7] + CStats::PedsKilledOfThisType[PEDTYPE_GANG6] + + CStats::PedsKilledOfThisType[PEDTYPE_GANG5] + CStats::PedsKilledOfThisType[PEDTYPE_GANG4] + + CStats::PedsKilledOfThisType[PEDTYPE_GANG3] + CStats::PedsKilledOfThisType[PEDTYPE_GANG2] + + CStats::PedsKilledOfThisType[PEDTYPE_GANG1]), false, nil); + STAT_LINE("DED_CRI", &(nTemp = CStats::PedsKilledOfThisType[PEDTYPE_CRIMINAL]), false, nil); + STAT_LINE("HEL_DST", &CStats::HelisDestroyed, false, nil); + STAT_LINE("KGS_EXP", &CStats::KgsOfExplosivesUsed, false, nil); + STAT_LINE("ACCURA", &(nTemp = (CStats::InstantHitsFiredByPlayer == 0 ? 0 : + CStats::InstantHitsHitByPlayer * 100.0f / CStats::InstantHitsFiredByPlayer)), false, nil); + + if (CStats::ElBurroTime > 0) { + STAT_LINE("ELBURRO", &CStats::ElBurroTime, false, nil); + } + if (CStats::Record4x4One > 0) { + STAT_LINE("FEST_R1", &CStats::Record4x4One, false, nil); + } + if (CStats::Record4x4Two > 0) { + STAT_LINE("FEST_R2", &CStats::Record4x4Two, false, nil); + } + if (CStats::Record4x4Three > 0) { + STAT_LINE("FEST_R3", &CStats::Record4x4Three, false, nil); + } + if (CStats::Record4x4Mayhem > 0) { + STAT_LINE("FEST_RM", &CStats::Record4x4Mayhem, false, nil); + } + if (CStats::LongestFlightInDodo > 0) { + STAT_LINE("FEST_LF", &CStats::LongestFlightInDodo, false, nil); + } + if (CStats::TimeTakenDefuseMission > 0) { + STAT_LINE("FEST_BD", &CStats::TimeTakenDefuseMission, false, nil); + } + STAT_LINE("CAR_CRU", &CStats::CarsCrushed, false, nil); + + if (CStats::HighestScores[0] > 0) { + STAT_LINE("FEST_BB", nil, false, nil); + STAT_LINE("FEST_H0", &CStats::HighestScores[0], false, nil); + } + if (CStats::HighestScores[4] + CStats::HighestScores[3] + CStats::HighestScores[2] + CStats::HighestScores[1] > 0) { + STAT_LINE("FEST_GC", nil, false, nil); + } + if (CStats::HighestScores[1] > 0) { + STAT_LINE("FEST_H1", &CStats::HighestScores[1], false, nil); + } + if (CStats::HighestScores[2] > 0) { + STAT_LINE("FEST_H2", &CStats::HighestScores[2], false, nil); + } + if (CStats::HighestScores[3] > 0) { + STAT_LINE("FEST_H3", &CStats::HighestScores[3], false, nil); + } + if (CStats::HighestScores[4] > 0) { + STAT_LINE("FEST_H4", &CStats::HighestScores[4], false, nil); + } + + switch (m_PrefsLanguage) { + case LANGUAGE_AMERICAN: +#ifndef USE_MEASUREMENTS_IN_METERS + float fTemp; + STAT_LINE("FEST_DF", &(fTemp = CStats::DistanceTravelledOnFoot * MILES_IN_METER), true, nil); + STAT_LINE("FEST_DC", &(fTemp = CStats::DistanceTravelledInVehicle * MILES_IN_METER), true, nil); + STAT_LINE("MMRAIN", &CStats::mmRain, false, nil); + STAT_LINE("MXCARD", &(fTemp = CStats::MaximumJumpDistance * FEET_IN_METER), true, nil); + STAT_LINE("MXCARJ", &(fTemp = CStats::MaximumJumpHeight * FEET_IN_METER), true, nil); + break; +#endif + case LANGUAGE_FRENCH: + case LANGUAGE_GERMAN: + case LANGUAGE_ITALIAN: + case LANGUAGE_SPANISH: +#ifdef MORE_LANGUAGES + case LANGUAGE_RUSSIAN: +#endif + STAT_LINE("FESTDFM", &CStats::DistanceTravelledOnFoot, true, nil); + STAT_LINE("FESTDCM", &CStats::DistanceTravelledInVehicle, true, nil); + STAT_LINE("MMRAIN", &CStats::mmRain, false, nil); + STAT_LINE("MXCARDM", &CStats::MaximumJumpDistance, true, nil); + STAT_LINE("MXCARJM", &CStats::MaximumJumpHeight, true, nil); + break; + default: + break; + } + + STAT_LINE("MXFLIP", &CStats::MaximumJumpFlips, false, nil); + STAT_LINE("MXJUMP", &CStats::MaximumJumpSpins, false, nil); + STAT_LINE("BSTSTU", nil, false, nil); + + if (counter == rowIdx) { + gUString[0] = '\0'; + switch (CStats::BestStuntJump) { + case 1: + UnicodeStrcpy(gUString2, TheText.Get("INSTUN")); + return 0; + case 2: + UnicodeStrcpy(gUString2, TheText.Get("PRINST")); + return 0; + case 3: + UnicodeStrcpy(gUString2, TheText.Get("DBINST")); + return 0; + case 4: + UnicodeStrcpy(gUString2, TheText.Get("DBPINS")); + return 0; + case 5: + UnicodeStrcpy(gUString2, TheText.Get("TRINST")); + return 0; + case 6: + UnicodeStrcpy(gUString2, TheText.Get("PRTRST")); + return 0; + case 7: + UnicodeStrcpy(gUString2, TheText.Get("QUINST")); + return 0; + case 8: + UnicodeStrcpy(gUString2, TheText.Get("PQUINS")); + return 0; + default: + UnicodeStrcpy(gUString2, TheText.Get("NOSTUC")); + return 0; + } + } + counter++; + STAT_LINE("PASDRO", &CStats::PassengersDroppedOffWithTaxi, false, nil); + STAT_LINE("MONTAX", &CStats::MoneyMadeWithTaxi, false, nil); + STAT_LINE("FEST_LS", &CStats::LivesSavedWithAmbulance, false, nil); + STAT_LINE("FEST_HA", &CStats::HighestLevelAmbulanceMission, false, nil); + STAT_LINE("FEST_CC", &CStats::CriminalsCaught, false, nil); + STAT_LINE("FEST_FE", &CStats::FiresExtinguished, false, nil); + STAT_LINE("DAYPLC", &(nTemp = CTimer::GetTimeInMilliseconds() + 100), false, nil); + return counter; + +#undef STAT_LINE +} + #if 0 uint8 CMenuManager::GetNumberOfMenuOptions() { @@ -4918,11 +5602,8 @@ uint8 CMenuManager::GetNumberOfMenuOptions() #endif STARTPATCHES -#if DONT_USE_SUSPICIOUS_FUNCS -#else for (int i = 1; i < ARRAY_SIZE(aScreens); i++) Patch(0x611930 + sizeof(CMenuScreen) * i, aScreens[i]); -#endif InjectHook(0x4856F0, &CMenuManager::ProcessButtonPresses, PATCH_JUMP); InjectHook(0x485100, &CMenuManager::Process, PATCH_JUMP); InjectHook(0x47A230, &CMenuManager::LoadAllTextures, PATCH_JUMP); diff --git a/src/core/Frontend.h b/src/core/Frontend.h index 20cf9e42..a1ee53f2 100644 --- a/src/core/Frontend.h +++ b/src/core/Frontend.h @@ -7,28 +7,11 @@ #define MENUHEADER_WIDTH 0.84f #define MENUHEADER_HEIGHT 1.6f -#define MENUACTION_X_MARGIN 40.0f +#define MENU_X_MARGIN 40.0f #define MENUACTION_POS_Y 60.0f -#define MENUACTION_WIDTH 0.38f +#define MENUACTION_WIDTH 38.0f #define MENUACTION_SCALE_MULT 0.9f -#define MENUCOLUMN_POS_X MENUHEADER_POS_X + 16.0f -#define MENUCOLUMN_MAX_Y 149.0f -#define MENUCOLUMN_MID_Y 100.0f -#define MENUCOLUMN_MIN_Y 110.0f -#define MENUCOLUMN_PAUSE_Y 25.0f -#define MENUCOLUMN_START_Y 9.0f -#define MENUCOLUMN_FEDS 139.0f - -#define MENUCOLUMN_SAVE_X 121.0f -#define MENUCOLUMN_SAVE_Y 111.0f - -#define MENUCOLUMN_SPACING_MAX 24.0f -#define MENUCOLUMN_SPACING_MIN 20.0f - -#define MENUSELECT_BOX_MAX 20.5f -#define MENUSELECT_BOX_MIN 17.0f - #ifndef ASPECT_RATIO_SCALE #define MENURADIO_ICON_X 31.5f #else @@ -38,12 +21,13 @@ #define MENURADIO_ICON_W 60.0f #define MENURADIO_ICON_H 60.0f -#define MENUDROP_COLOR_A 150 -#define MENUDROP_COLOR_SIZE -1 - #define MENUSLIDER_X 256.0f #define MENUSLIDER_UNK 256.0f +#define BIGTEXT_X_SCALE 0.75f +#define BIGTEXT_Y_SCALE 0.9f +#define MEDIUMTEXT_X_SCALE 0.55f +#define MEDIUMTEXT_Y_SCALE 0.8f #define SMALLTEXT_X_SCALE 0.45f #define SMALLTEXT_Y_SCALE 0.7f #define SMALLESTTEXT_X_SCALE 0.4f @@ -67,6 +51,33 @@ #define PLAYERSETUP_LIST_BODY_TOP 47 #define PLAYERSETUP_ROW_HEIGHT 9 +#define STATS_SLIDE_Y_PER_SECOND 30.0f +#define STATS_ROW_HEIGHT 20.0f +#define STATS_ROW_X_MARGIN 50.0f +#define STATS_BOTTOM_MARGIN 135.0f +#define STATS_TOP_MARGIN 40.0f +#define STATS_TOP_DIMMING_AREA_LENGTH (93.0f - STATS_TOP_MARGIN) +#define STATS_BOTTOM_DIMMING_AREA_LENGTH 55.0f +#define STATS_PUT_BACK_TO_BOTTOM_Y 50.0f +#define STATS_RATING_X 24.0f +#define STATS_RATING_Y 20.0f + +#define CONTSETUP_STANDARD_ROW_HEIGHT 10.7f +#define CONTSETUP_CLASSIC_ROW_HEIGHT 9.0f +#define CONTSETUP_BOUND_HIGHLIGHT_HEIGHT 10 +#define CONTSETUP_BOUND_COLUMN_WIDTH 190.0f +#define CONTSETUP_LIST_HEADER_HEIGHT 20.0f +#define CONTSETUP_LIST_TOP 28.0f +#define CONTSETUP_LIST_RIGHT 18.0f +#define CONTSETUP_LIST_BOTTOM 120.0f +#define CONTSETUP_LIST_LEFT 18.0f +#define CONTSETUP_COLUMN_1_X 40.0f +#define CONTSETUP_COLUMN_2_X 210.0f +#define CONTSETUP_COLUMN_3_X (CONTSETUP_COLUMN_2_X + CONTSETUP_BOUND_COLUMN_WIDTH + 10.0f) +#define CONTSETUP_BACK_RIGHT 35.0f +#define CONTSETUP_BACK_BOTTOM 122.0f +#define CONTSETUP_BACK_HEIGHT 25.0f + enum eLanguages { LANGUAGE_AMERICAN, @@ -185,19 +196,19 @@ enum eMenuScreen MENUPAGE_NEW_GAME_RELOAD = 10, MENUPAGE_LOAD_SLOT_CONFIRM = 11, MENUPAGE_DELETE_SLOT_CONFIRM = 12, - MENUPAGE_13 = 13, + MENUPAGE_NO_MEMORY_CARD = 13, MENUPAGE_LOADING_IN_PROGRESS = 14, MENUPAGE_DELETING_IN_PROGRESS = 15, - MENUPAGE_16 = 16, + MENUPAGE_PS2_LOAD_FAILED = 16, MENUPAGE_DELETE_FAILED = 17, MENUPAGE_DEBUG_MENU = 18, - MENUPAGE_MEMORY_CARD_1 = 19, - MENUPAGE_MEMORY_CARD_2 = 20, + MENUPAGE_MEMORY_CARD_DEBUG = 19, + MENUPAGE_MEMORY_CARD_TEST = 20, MENUPAGE_MULTIPLAYER_MAIN = 21, - MENUPAGE_SAVE_FAILED_1 = 22, - MENUPAGE_SAVE_FAILED_2 = 23, + MENUPAGE_PS2_SAVE_FAILED = 22, + MENUPAGE_PS2_SAVE_FAILED_2 = 23, MENUPAGE_SAVE = 24, - MENUPAGE_NO_MEMORY_CARD = 25, + MENUPAGE_NO_MEMORY_CARD_2 = 25, MENUPAGE_CHOOSE_SAVE_SLOT = 26, MENUPAGE_SAVE_OVERWRITE_CONFIRM = 27, MENUPAGE_MULTIPLAYER_MAP = 28, @@ -438,7 +449,7 @@ struct BottomBarOption struct CMenuScreen { char m_ScreenName[8]; - int32 unk; + int32 unk; // 2 on MENUPAGE_MULTIPLAYER_START, 1 on everywhere else int32 m_PreviousPage[2]; // eMenuScreen int32 m_ParentEntry[2]; // row @@ -544,11 +555,12 @@ public: static bool &m_bShutDownFrontEndRequested; static bool &m_PrefsAllowNastyGame; - static float &menuXYpadding; - static float &actionTextScaleX; - static float &actionTextScaleY; - static int32 &sthWithButtons; - static int32 &sthWithButtons2; + static uint8 m_PrefsStereoMono; + static int32 m_SelectedMap; + static int32 m_SelectedGameType; + static uint8 m_PrefsPlayerRed; + static uint8 m_PrefsPlayerGreen; + static uint8 m_PrefsPlayerBlue; #ifndef MASTER static bool m_PrefsMarketing; @@ -557,6 +569,7 @@ public: #ifdef MENU_MAP static bool bMenuMapActive; + static bool bMapMouseShownOnce; static float fMapSize; static float fMapCenterY; static float fMapCenterX; @@ -565,9 +578,9 @@ public: #endif public: - static void BuildStatLine(char *text, void *stat, uint8 aFloat, void *stat2); + static void BuildStatLine(char *text, void *stat, bool itsFloat, void *stat2); static void CentreMousePointer(); - int CheckCodesForControls(int32); + void CheckCodesForControls(int); bool CheckHover(int x1, int x2, int y1, int y2); void CheckSliderMovement(int); int CostructStatLine(int); @@ -585,13 +598,13 @@ public: #endif void DrawPlayerSetupScreen(); int FadeIn(int alpha); - void FilterOutColorMarkersFromString(uint16, CRGBA &); + void FilterOutColorMarkersFromString(wchar*, CRGBA &); int GetStartOptionsCntrlConfigScreens(); static void InitialiseChangedLanguageSettings(); void LoadAllTextures(); void LoadSettings(); - static void MessageScreen(char *); - static void PickNewPlayerColour(); + void MessageScreen(const char *); + void PickNewPlayerColour(); void PrintBriefs(); static void PrintErrorMessage(); void PrintStats(); @@ -612,6 +625,7 @@ public: void WaitForUserCD(); void PrintController(); int GetNumOptionsCntrlConfigScreens(); + int ConstructStatLine(int); // New (not in function or inlined in the game) void ThingsToDoBeforeLeavingPage(); diff --git a/src/core/MenuScreens.h b/src/core/MenuScreens.h index bac8f0a8..cece80c7 100644 --- a/src/core/MenuScreens.h +++ b/src/core/MenuScreens.h @@ -1,22 +1,22 @@ #pragma once -// There are some missing/wrong entries in here. +// TODO: There are some missing/wrong entries in here. const CMenuScreen aScreens[] = { // MENUPAGE_NONE = 0 - { "", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, + { "", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, - // MENUPAGE_STATS = 1 - Both PrintStats and Draw were printing the page name, so deleted the string Draw looked for. + // MENUPAGE_STATS = 1 #ifdef MENU_MAP - { ""/*"FET_STA"*/, MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 5, 3, + { "FET_STA", 1, MENUPAGE_NONE, MENUPAGE_NONE, 5, 3, #else - { ""/*"FET_STA"*/, MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 5, 2, + { "FET_STA", 1, MENUPAGE_NONE, MENUPAGE_NONE, 5, 2, #endif MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_NEW_GAME = 2 - { "FET_SGA", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 0, 1, + { "FET_SGA", 1, MENUPAGE_NONE, MENUPAGE_NONE, 0, 1, MENUACTION_CHANGEMENU, "FES_SNG", SAVESLOT_NONE, MENUPAGE_NEW_GAME_RELOAD, MENUACTION_POPULATESLOTS_CHANGEMENU, "GMLOAD", SAVESLOT_NONE, MENUPAGE_CHOOSE_LOAD_SLOT, MENUACTION_POPULATESLOTS_CHANGEMENU, "FES_DGA", SAVESLOT_NONE, MENUPAGE_CHOOSE_DELETE_SLOT, @@ -25,15 +25,15 @@ const CMenuScreen aScreens[] = { // MENUPAGE_BRIEFS = 3 #ifdef MENU_MAP - { "FET_BRE", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 6, 4, + { "FET_BRE", 1, MENUPAGE_NONE, MENUPAGE_NONE, 6, 4, #else - { "FET_BRE", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 6, 3, + { "FET_BRE", 1, MENUPAGE_NONE, MENUPAGE_NONE, 6, 3, #endif MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENU_CONTROLLER_SETTINGS = 4 - { "FET_CON", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 0, 0, + { "FET_CON", 1, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 0, 0, MENUACTION_CTRLCONFIG, "FEC_CCF", SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS, MENUACTION_CTRLDISPLAY, "FEC_CDP", SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS, MENUACTION_CTRLVIBRATION, "FEC_VIB", SAVESLOT_NONE, MENUPAGE_CONTROLLER_SETTINGS, @@ -41,7 +41,7 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_SOUND_SETTINGS = 5 - { "FET_AUD", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 1, 1, + { "FET_AUD", 1, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 1, 1, MENUACTION_MUSICVOLUME, "FEA_MUS", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, MENUACTION_SFXVOLUME, "FEA_SFX", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, MENUACTION_AUDIOHW, "FEA_3DH", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, @@ -53,7 +53,7 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_GRAPHICS_SETTINGS = 6 - { "FET_DIS", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 2, 2, + { "FET_DIS", 1, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 2, 2, MENUACTION_BRIGHTNESS, "FED_BRI", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_DRAWDIST, "FEM_LOD", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_FRAMESYNC, "FEM_VSC", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, @@ -67,7 +67,7 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_LANGUAGE_SETTINGS = 7 - { "FET_LAN", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 3, 3, + { "FET_LAN", 1, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 3, 3, MENUACTION_LANG_ENG, "FEL_ENG", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_LANG_FRE, "FEL_FRE", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_LANG_GER, "FEL_GER", SAVESLOT_NONE, MENUPAGE_NONE, @@ -80,7 +80,7 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_CHOOSE_LOAD_SLOT = 8 - { "FET_LG", MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, 1, 1, + { "FET_LG", 1, MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, 1, 1, MENUACTION_CHANGEMENU, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NEW_GAME, MENUACTION_CHECKSAVE, "FEM_SL1", SAVESLOT_1, MENUPAGE_LOAD_SLOT_CONFIRM, MENUACTION_CHECKSAVE, "FEM_SL2", SAVESLOT_2, MENUPAGE_LOAD_SLOT_CONFIRM, @@ -93,7 +93,7 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_CHOOSE_DELETE_SLOT = 9 - { "FET_DG", MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, 2, 2, + { "FET_DG", 1, MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, 2, 2, MENUACTION_CHANGEMENU, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NEW_GAME, MENUACTION_CHECKSAVE, "FEM_SL1", SAVESLOT_1, MENUPAGE_DELETE_SLOT_CONFIRM, MENUACTION_CHECKSAVE, "FEM_SL2", SAVESLOT_2, MENUPAGE_DELETE_SLOT_CONFIRM, @@ -106,104 +106,123 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_NEW_GAME_RELOAD = 10 - { "FET_NG", MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, 0, 0, + { "FET_NG", 1, MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, 0, 0, MENUACTION_LABEL, "FESZ_QR", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEM_NO", SAVESLOT_NONE, MENUPAGE_NEW_GAME, MENUACTION_NEWGAME, "FEM_YES", SAVESLOT_NONE, MENUPAGE_NEW_GAME_RELOAD, }, // MENUPAGE_LOAD_SLOT_CONFIRM = 11 - { "FET_LG", MENUPAGE_CHOOSE_LOAD_SLOT, MENUPAGE_CHOOSE_LOAD_SLOT, MENUPAGE_CHOOSE_LOAD_SLOT, 0, 0, + { "FET_LG", 1, MENUPAGE_CHOOSE_LOAD_SLOT, MENUPAGE_CHOOSE_LOAD_SLOT, 0, 0, MENUACTION_LABEL, "FESZ_QL", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEM_NO", SAVESLOT_NONE, MENUPAGE_CHOOSE_LOAD_SLOT, MENUACTION_CHANGEMENU, "FEM_YES", SAVESLOT_NONE, MENUPAGE_LOADING_IN_PROGRESS, }, // MENUPAGE_DELETE_SLOT_CONFIRM = 12 - { "FET_DG", MENUPAGE_CHOOSE_DELETE_SLOT, MENUPAGE_CHOOSE_DELETE_SLOT, MENUPAGE_CHOOSE_DELETE_SLOT, 0, 0, + { "FET_DG", 1, MENUPAGE_CHOOSE_DELETE_SLOT, MENUPAGE_CHOOSE_DELETE_SLOT, 0, 0, MENUACTION_LABEL, "FESZ_QD", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEM_NO", SAVESLOT_NONE, MENUPAGE_CHOOSE_DELETE_SLOT, MENUACTION_CHANGEMENU, "FEM_YES", SAVESLOT_NONE, MENUPAGE_DELETING, }, - // MENUPAGE_13 = 13 - { "FES_NOC", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, - + // MENUPAGE_NO_MEMORY_CARD = 13 + { "FES_NOC", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, + MENUACTION_LABEL, "FEC_OFI", SAVESLOT_NONE, MENUPAGE_NONE, // only in mobile. FEC_OFI is missing }, // MENUPAGE_LOADING_IN_PROGRESS = 14 - { "FET_LG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, + { "FET_LG", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, MENUACTION_LABEL, "FED_LDW", SAVESLOT_NONE, MENUPAGE_LOAD_SLOT_CONFIRM, }, // MENUPAGE_DELETING_IN_PROGRESS = 15 - { "FET_DG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, + { "FET_DG", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, MENUACTION_LABEL, "FEDL_WR", SAVESLOT_NONE, MENUPAGE_NONE, }, - // MENUPAGE_16 = 16 - { "FET_LG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, + // MENUPAGE_PS2_LOAD_FAILED = 16 + { "FET_LG", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, MENUACTION_LABEL, "FES_LOE", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_DELETE_FAILED = 17 - { "FET_DG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, + { "FET_DG", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, MENUACTION_LABEL, "FES_DEE", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEC_OKK", SAVESLOT_NONE, MENUPAGE_CHOOSE_DELETE_SLOT, }, // MENUPAGE_DEBUG_MENU = 18 - { "FED_DBG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, - + { "FED_DBG", 1, MENUPAGE_NONE, MENUPAGE_NONE, 4, 0, + MENUACTION_RELOADIDE, "FED_RID", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_RELOADIPL, "FED_RIP", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_SETDBGFLAG, "FED_DFL", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_SWITCHBIGWHITEDEBUGLIGHT, "FED_DLS", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_PEDROADGROUPS, "FED_SPR", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_CARROADGROUPS, "FED_SCR", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_COLLISIONPOLYS, "FED_SCP", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_PARSEHEAP, "FED_PAH", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_SHOWCULL, "FED_SCZ", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_DEBUGSTREAM, "FED_DSR", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, - // MENUPAGE_MEMORY_CARD_1 = 19 - { "FEM_MCM", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, - + // MENUPAGE_MEMORY_CARD_DEBUG = 19 + { "FEM_MCM", 1, MENUPAGE_NONE, MENUPAGE_NONE, 7, 0, + MENUACTION_REGMEMCARD1, "FEM_RMC", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_TESTFORMATMEMCARD1, "FEM_TFM", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_TESTUNFORMATMEMCARD1, "FEM_TUM", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_CREATEROOTDIR, "FEM_CRD", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_CREATELOADICONS, "FEM_CLI", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_FILLWITHGUFF, "FEM_FFF", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_SAVEONLYTHEGAME, "FEM_SOG", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_SAVEGAME, "FEM_STG", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_SAVEGAMEUNDERGTA, "FEM_STS", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_CREATECOPYPROTECTED, "FEM_CPD", SAVESLOT_NONE, MENUPAGE_NONE, }, - // MENUPAGE_MEMORY_CARD_2 = 20 - { "FEM_MC2", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, + // MENUPAGE_MEMORY_CARD_TEST = 20 + { "FEM_MC2", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_MULTIPLAYER_MAIN = 21 - { "FET_MP", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, + { "FET_MP", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, - // MENUPAGE_SAVE_FAILED_1 = 22 - { "MCDNSP", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, + // MENUPAGE_PS2_SAVE_FAILED = 22 + { "MCDNSP", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, MENUACTION_MEMCARDSAVECONFIRM, "JAILB_U", SAVESLOT_NONE, MENUPAGE_NONE, }, - // MENUPAGE_SAVE_FAILED_2 = 23 - { "MCGNSP", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, + // MENUPAGE_PS2_SAVE_FAILED_2 = 23 + { "MCGNSP", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, MENUACTION_MEMCARDSAVECONFIRM, "JAILB_U", SAVESLOT_NONE, MENUPAGE_NONE, }, // Unused in PC but anyway // MENUPAGE_SAVE = 24 #ifdef PS2_SAVE_DIALOG - { "FET_SG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, + { "FET_SG", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, MENUACTION_CHANGEMENU, "FESZ_SA", SAVESLOT_NONE, MENUPAGE_CHOOSE_SAVE_SLOT, MENUACTION_RESUME_FROM_SAVEZONE, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NONE, }, #else - { "FET_SG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, + { "FET_SG", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, MENUACTION_LABEL, "FES_SCG", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_POPULATESLOTS_CHANGEMENU, "GMSAVE", SAVESLOT_NONE, MENUPAGE_CHOOSE_SAVE_SLOT, MENUACTION_RESUME_FROM_SAVEZONE, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NONE, }, #endif - // MENUPAGE_NO_MEMORY_CARD = 25 - { "FES_NOC", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, - + // MENUPAGE_NO_MEMORY_CARD_2 = 25 + { "FES_NOC", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, + MENUACTION_CHANGEMENU, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_CHOOSE_SAVE_SLOT = 26 - { "FET_SG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, + { "FET_SG", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, MENUACTION_RESUME_FROM_SAVEZONE, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEM_SL1", SAVESLOT_1, MENUPAGE_SAVE_OVERWRITE_CONFIRM, MENUACTION_CHANGEMENU, "FEM_SL2", SAVESLOT_2, MENUPAGE_SAVE_OVERWRITE_CONFIRM, @@ -216,49 +235,49 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_SAVE_OVERWRITE_CONFIRM = 27 - { "FET_SG", MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, 0, 0, + { "FET_SG", 1, MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, 0, 0, MENUACTION_LABEL, "FESZ_QO", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEM_YES", SAVESLOT_NONE, MENUPAGE_SAVING_IN_PROGRESS, MENUACTION_CHANGEMENU, "FEM_NO", SAVESLOT_NONE, MENUPAGE_CHOOSE_SAVE_SLOT, }, // MENUPAGE_MULTIPLAYER_MAP = 28 - { "FET_MAP", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, + { "FET_MAP", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_MULTIPLAYER_CONNECTION = 29 - { "FET_CON", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, + { "FET_CON", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_MULTIPLAYER_FIND_GAME = 30 - { "FET_FG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, + { "FET_FG", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_MULTIPLAYER_MODE = 31 - { "FET_GT", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, + { "FET_GT", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_MULTIPLAYER_CREATE = 32 - { "FET_HG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, + { "FET_HG", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_MULTIPLAYER_START = 33 - { "FEN_STA", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, + { "FEN_STA", 2, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_SKIN_SELECT_OLD = 34 - { "FET_PS", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, + { "FET_PS", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_CONTROLLER_PC = 35 - { "FET_CTL", MENUPAGE_DISABLED, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 0, 0, + { "FET_CTL", 1, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 0, 0, MENUACTION_CTRLMETHOD, "FET_CME", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, MENUACTION_CHANGEMENU, "FET_RDK", SAVESLOT_NONE, MENUPAGE_KEYBOARD_CONTROLS, MENUACTION_CHANGEMENU, "FET_AMS", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS, @@ -268,7 +287,7 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_CONTROLLER_PC_OLD1 = 36 - { "FET_CTL", MENUPAGE_DISABLED, MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, 0, 0, + { "FET_CTL", 1, MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, 0, 0, MENUACTION_GETKEY, "FEC_PLB", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC_OLD1, MENUACTION_GETKEY, "FEC_CWL", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC_OLD1, MENUACTION_GETKEY, "FEC_CWR", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC_OLD1, @@ -282,12 +301,12 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_CONTROLLER_PC_OLD2 = 37 - { "FET_CTL", MENUPAGE_DISABLED, MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, 1, 1, + { "FET_CTL", 1, MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, 1, 1, }, // MENUPAGE_CONTROLLER_PC_OLD3 = 38 - { "FET_CTL", MENUPAGE_DISABLED, MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, 2, 2, + { "FET_CTL", 1, MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, 2, 2, MENUACTION_GETKEY, "FEC_LUP", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC_OLD3, MENUACTION_GETKEY, "FEC_LDN", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC_OLD3, MENUACTION_GETKEY, "FEC_SMS", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC_OLD3, @@ -296,20 +315,24 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_CONTROLLER_PC_OLD4 = 39 - { "FET_CTL", MENUPAGE_DISABLED, MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, 3, 3, + { "FET_CTL", 1, MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, 3, 3, }, // MENUPAGE_CONTROLLER_DEBUG = 40 - { "FEC_DBG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, - + { "FEC_DBG", 1, MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, 3, 3, + MENUACTION_GETKEY, "FEC_TGD", SAVESLOT_NONE, MENUPAGE_CONTROLLER_DEBUG, + MENUACTION_GETKEY, "FEC_TDO", SAVESLOT_NONE, MENUPAGE_CONTROLLER_DEBUG, + MENUACTION_GETKEY, "FEC_TSS", SAVESLOT_NONE, MENUPAGE_CONTROLLER_DEBUG, + MENUACTION_GETKEY, "FEC_SMS", SAVESLOT_NONE, MENUPAGE_CONTROLLER_DEBUG, + MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_OPTIONS = 41 #ifdef MENU_MAP - { "FET_OPT", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 1, 5, + { "FET_OPT", 1, MENUPAGE_NONE, MENUPAGE_NONE, 1, 5, #else - { "FET_OPT", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 1, 4, + { "FET_OPT", 1, MENUPAGE_NONE, MENUPAGE_NONE, 1, 4, #endif MENUACTION_CHANGEMENU, "FET_CTL", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, MENUACTION_LOADRADIO, "FET_AUD", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, @@ -321,9 +344,9 @@ const CMenuScreen aScreens[] = { // MENUPAGE_EXIT = 42 #ifdef MENU_MAP - { "FET_QG", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 2, 6, + { "FET_QG", 1, MENUPAGE_NONE, MENUPAGE_NONE, 2, 6, #else - { "FET_QG", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 2, 5, + { "FET_QG", 1, MENUPAGE_NONE, MENUPAGE_NONE, 2, 5, #endif MENUACTION_LABEL, "FEQ_SRE", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEM_NO", SAVESLOT_NONE, MENUPAGE_NONE, @@ -331,58 +354,58 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_SAVING_IN_PROGRESS = 43 - { "", MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, 0, 0, + { "", 1, MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, 0, 0, MENUACTION_LABEL, "FES_WAR", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_SAVE_SUCCESSFUL = 44 - { "FET_SG", MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, 0, 0, + { "FET_SG", 1, MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, 0, 0, MENUACTION_LABEL, "FES_SSC", SAVESLOT_LABEL, MENUPAGE_NONE, MENUACTION_RESUME_FROM_SAVEZONE, "FEC_OKK", SAVESLOT_NONE, MENUPAGE_CHOOSE_SAVE_SLOT, }, // MENUPAGE_DELETING = 45 - { "FET_DG", MENUPAGE_CHOOSE_DELETE_SLOT, MENUPAGE_CHOOSE_DELETE_SLOT, MENUPAGE_CHOOSE_DELETE_SLOT, 0, 0, + { "FET_DG", 1, MENUPAGE_CHOOSE_DELETE_SLOT, MENUPAGE_CHOOSE_DELETE_SLOT, 0, 0, MENUACTION_LABEL, "FED_DLW", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_DELETE_SUCCESS = 46 - { "FET_DG", MENUPAGE_CHOOSE_DELETE_SLOT, MENUPAGE_CHOOSE_DELETE_SLOT, MENUPAGE_CHOOSE_DELETE_SLOT, 0, 0, + { "FET_DG", 1, MENUPAGE_CHOOSE_DELETE_SLOT, MENUPAGE_CHOOSE_DELETE_SLOT, 0, 0, MENUACTION_LABEL, "DEL_FNM", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEC_OKK", SAVESLOT_NONE, MENUPAGE_CHOOSE_DELETE_SLOT, }, // MENUPAGE_SAVE_FAILED = 47 - { "FET_SG", MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, 0, 0, + { "FET_SG", 1, MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, 0, 0, MENUACTION_LABEL, "FEC_SVU", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEC_OKK", SAVESLOT_NONE, MENUPAGE_CHOOSE_SAVE_SLOT, }, // MENUPAGE_LOAD_FAILED = 48 - { "FET_SG", MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, 0, 0, + { "FET_SG", 1, MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, 0, 0, MENUACTION_LABEL, "FEC_SVU", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_LOAD_FAILED_2 = 49 - { "FET_LG", MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, 0, 0, + { "FET_LG", 1, MENUPAGE_CHOOSE_SAVE_SLOT, MENUPAGE_CHOOSE_SAVE_SLOT, 0, 0, MENUACTION_LABEL, "FEC_LUN", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_CHOOSE_LOAD_SLOT, }, // MENUPAGE_FILTER_GAME = 50 - { "FIL_FLT", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, + { "FIL_FLT", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_START_MENU = 51 - { "FEM_MM", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, + { "FEM_MM", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, MENUACTION_CHANGEMENU, "FEN_STA", SAVESLOT_NONE, MENUPAGE_NEW_GAME, MENUACTION_CHANGEMENU, "FET_OPT", SAVESLOT_NONE, MENUPAGE_OPTIONS, MENUACTION_CHANGEMENU, "FEM_QT", SAVESLOT_NONE, MENUPAGE_EXIT, }, // MENUPAGE_PAUSE_MENU = 52 - { "FET_PAU", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, + { "FET_PAU", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, MENUACTION_RESUME, "FEM_RES", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEN_STA", SAVESLOT_NONE, MENUPAGE_NEW_GAME, #ifdef MENU_MAP @@ -395,22 +418,24 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_CHOOSE_MODE = 53 - { "FEN_STA", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, - + { "FEN_STA", 1, MENUPAGE_NONE, MENUPAGE_NONE, 0, 1, + MENUACTION_CHANGEMENU, "FET_SP", SAVESLOT_NONE, MENUPAGE_NEW_GAME, + MENUACTION_INITMP, "FET_MP", SAVESLOT_NONE, MENUPAGE_MULTIPLAYER_MAIN, + MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_SKIN_SELECT = 54 - { "FET_PSU", MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 4, 4, - MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_MULTIPLAYER_MAIN, + { "FET_PSU", 1, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 4, 4, + MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_MULTIPLAYER_MAIN, }, // MENUPAGE_KEYBOARD_CONTROLS = 55 - { "FET_STI", MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, 1, 1, - MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, + { "FET_STI", 1, MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, 1, 1, + MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, }, // MENUPAGE_MOUSE_CONTROLS = 56 - { "FET_MTI", MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, 2, 2, + { "FET_MTI", 1, MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, 2, 2, MENUACTION_MOUSESENS, "FEC_MSH", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS, MENUACTION_INVVERT, "FEC_IVV", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS, MENUACTION_MOUSESTEER, "FET_MST", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS, @@ -418,18 +443,18 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_57 = 57 - { "", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, + { "", 0, MENUPAGE_NONE, MENUPAGE_NONE, 0, 0, }, // MENUPAGE_58 = 58 - { "", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, + { "", 0, MENUPAGE_NONE, MENUPAGE_NONE, 0, 0, }, #ifdef MENU_MAP // MENUPAGE_MAP = 59 - { "FEG_MAP", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 5, 2, + { "FEG_MAP", 1, MENUPAGE_NONE, MENUPAGE_NONE, 5, 2, }, #endif }; diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index 994c94ca..154e7e9a 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -1412,8 +1412,8 @@ CRadar::DrawYouAreHereSprite(float x, float y) } } else { if (CTimer::GetTimeInMillisecondsPauseMode() - lastChange > 200) { - lastChange = CTimer::GetTimeInMillisecondsPauseMode(); - show = !show; + lastChange = CTimer::GetTimeInMillisecondsPauseMode(); + show = !show; } } @@ -1422,7 +1422,7 @@ CRadar::DrawYouAreHereSprite(float x, float y) float top = y - SCREEN_SCALE_Y(2.0f); float right = SCREEN_SCALE_X(12.0) + x; float bottom = y - SCREEN_SCALE_Y(26.0f); - CentreSprite.Draw(CRect(left, top, right, bottom), CRGBA(255, 217, 106, 255)); + CentreSprite.Draw(CRect(left, top, right, bottom), CRGBA(255, 255, 255, 255)); } MapLegendList[MapLegendCounter++] = RADAR_SPRITE_CENTRE; } @@ -1503,4 +1503,4 @@ STARTPATCHES InjectHook(0x4A6F30, CRadar::LoadAllRadarBlips, PATCH_JUMP); //InjectHook(0x4A7000, `global constructor keyed to'Radar.cpp, PATCH_JUMP); //InjectHook(0x4A7260, sRadarTrace::sRadarTrace, PATCH_JUMP); -ENDPATCHES +ENDPATCHES \ No newline at end of file diff --git a/src/core/Timer.cpp b/src/core/Timer.cpp index 18d6b6a3..b5e031ed 100644 --- a/src/core/Timer.cpp +++ b/src/core/Timer.cpp @@ -34,6 +34,10 @@ LARGE_INTEGER &perfSuspendCounter = *(LARGE_INTEGER*)0x62A318; //UInt32 suspendDepth; uint32 &suspendDepth = *(uint32*)0x62A320; +#ifdef FIX_BUGS +double frameTime; +#endif + void CTimer::Initialise(void) { debug("Initialising CTimer...\n"); @@ -90,17 +94,21 @@ void CTimer::Update(void) float updInCyclesScaled = updInCycles * ms_fTimeScale; - double upd = updInCyclesScaled / (double)_nCyclesPerMS; + // We need that real frame time to fix transparent menu bug. +#ifndef FIX_BUGS + double +#endif + frameTime = updInCyclesScaled / (double)_nCyclesPerMS; - m_snTimeInMillisecondsPauseMode = m_snTimeInMillisecondsPauseMode + upd; + m_snTimeInMillisecondsPauseMode = m_snTimeInMillisecondsPauseMode + frameTime; if ( GetIsPaused() ) ms_fTimeStep = 0.0f; else { - m_snTimeInMilliseconds = m_snTimeInMilliseconds + upd; - m_snTimeInMillisecondsNonClipped = m_snTimeInMillisecondsNonClipped + upd; - ms_fTimeStep = updInCyclesScaled / (double)_nCyclesPerMS / 20.0f; + m_snTimeInMilliseconds = m_snTimeInMilliseconds + frameTime; + m_snTimeInMillisecondsNonClipped = m_snTimeInMillisecondsNonClipped + frameTime; + ms_fTimeStep = frameTime / 1000.0f * 50.0f; } } else @@ -109,19 +117,23 @@ void CTimer::Update(void) uint32 updInMs = timer - oldPcTimer; - double upd = (double)updInMs * ms_fTimeScale; + // We need that real frame time to fix transparent menu bug. +#ifndef FIX_BUGS + double +#endif + frameTime = (double)updInMs * ms_fTimeScale; oldPcTimer = timer; - m_snTimeInMillisecondsPauseMode = m_snTimeInMillisecondsPauseMode + upd; + m_snTimeInMillisecondsPauseMode = m_snTimeInMillisecondsPauseMode + frameTime; if ( GetIsPaused() ) ms_fTimeStep = 0.0f; else { - m_snTimeInMilliseconds = m_snTimeInMilliseconds + upd; - m_snTimeInMillisecondsNonClipped = m_snTimeInMillisecondsNonClipped + upd; - ms_fTimeStep = upd / 1000.0f * 50.0f; + m_snTimeInMilliseconds = m_snTimeInMilliseconds + frameTime; + m_snTimeInMillisecondsNonClipped = m_snTimeInMillisecondsNonClipped + frameTime; + ms_fTimeStep = frameTime / 1000.0f * 50.0f; } } diff --git a/src/core/Timer.h b/src/core/Timer.h index 2498ec8a..7b35f79a 100644 --- a/src/core/Timer.h +++ b/src/core/Timer.h @@ -53,3 +53,7 @@ public: static void StartUserPause(void); static void EndUserPause(void); }; + +#ifdef FIX_BUGS +extern double frameTime; +#endif diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 6eae8685..a35a9fd9 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -21,6 +21,7 @@ #include "Particle.h" #include "Console.h" #include "Debug.h" +#include "Hud.h" #include @@ -338,6 +339,7 @@ DebugMenuPopulate(void) DebugMenuAddCmd("Spawn", "Spawn Rhino", [](){ SpawnCar(MI_RHINO); }); DebugMenuAddCmd("Spawn", "Spawn Firetruck", [](){ SpawnCar(MI_FIRETRUCK); }); + DebugMenuAddVarBool8("Debug", "Draw hud", (int8*)&CHud::m_Wants_To_Draw_Hud, nil); DebugMenuAddVar("Debug", "Engine Status", &engineStatus, nil, 1, 0, 226, nil); DebugMenuAddCmd("Debug", "Set Engine Status", SetEngineStatus); DebugMenuAddCmd("Debug", "Fix Car", FixCar); diff --git a/src/peds/CivilianPed.cpp b/src/peds/CivilianPed.cpp index 533d7c98..a9e0580e 100644 --- a/src/peds/CivilianPed.cpp +++ b/src/peds/CivilianPed.cpp @@ -28,10 +28,8 @@ CCivilianPed::CivilianAI(void) return; if (m_objective == OBJECTIVE_KILL_CHAR_ON_FOOT || m_objective == OBJECTIVE_KILL_CHAR_ANY_MEANS) { - if (m_pedInObjective) { - if (m_pedInObjective->IsPlayer()) - return; - } + if (m_pedInObjective && m_pedInObjective->IsPlayer()) + return; } if (CTimer::GetTimeInMilliseconds() <= m_lookTimer) return; @@ -75,7 +73,7 @@ CCivilianPed::CivilianAI(void) } else { SetMoveState(PEDMOVE_WALK); } - } else if (threatPed->IsPlayer() && FindPlayerPed()->m_pWanted->m_CurrentCops) { + } else if (threatPed->IsPlayer() && FindPlayerPed()->m_pWanted->m_CurrentCops != 0) { SetFindPathAndFlee(m_threatEntity, 5000); if (threatDistSqr < sq(10.0f)) { SetMoveState(PEDMOVE_RUN); @@ -170,8 +168,8 @@ CCivilianPed::CivilianAI(void) if (m_threatEntity && m_threatEntity->IsPed()) { CPed *threatPed = (CPed*)m_threatEntity; if (m_pedStats->m_fear <= 100 - threatPed->m_pedStats->m_temper && threatPed->m_nPedType != PEDTYPE_COP) { - if (threatPed->GetWeapon()->IsTypeMelee() || !GetWeapon()->IsTypeMelee()) { - if (threatPed->IsPlayer() && FindPlayerPed()->m_pWanted->m_CurrentCops) { + if (threatPed->GetWeapon(m_currentWeapon).IsTypeMelee() || !GetWeapon()->IsTypeMelee()) { + if (threatPed->IsPlayer() && FindPlayerPed()->m_pWanted->m_CurrentCops != 0) { if (m_objective == OBJECTIVE_KILL_CHAR_ON_FOOT || m_objective == OBJECTIVE_KILL_CHAR_ANY_MEANS) { SetFindPathAndFlee(m_threatEntity, 10000); } diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 80d7fe47..f8b86bd2 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -21,54 +21,52 @@ #include "User.h" #include "World.h" -wchar *CHud::m_HelpMessage = (wchar*)0x86B888; -wchar *CHud::m_LastHelpMessage = (wchar*)0x6E8F28; -int32 &CHud::m_HelpMessageState = *(int32*)0x880E1C; -int32 &CHud::m_HelpMessageTimer = *(int32*)0x880FA4; -int32 &CHud::m_HelpMessageFadeTimer = *(int32*)0x8F6258; -wchar *CHud::m_HelpMessageToPrint = (wchar*)0x664480; -float &CHud::m_HelpMessageDisplayTime = *(float*)0x8E2C28; -float &CHud::m_fTextBoxNumLines = *(float*)0x8E2C28; -float &CHud::m_fHelpMessageTime = *(float *)0x8E2C28; -bool &CHud::m_HelpMessageQuick = *(bool *)0x95CCF7; -int32 CHud::m_ZoneState = *(int32*)0x8F29AC; +wchar CHud::m_HelpMessage[256]; // = (wchar*)0x86B888; +wchar CHud::m_LastHelpMessage[256]; // = (wchar*)0x6E8F28; +uint32 CHud::m_HelpMessageState; // = *(int32*)0x880E1C; +uint32 CHud::m_HelpMessageTimer; // = *(int32*)0x880FA4; +int32 CHud::m_HelpMessageFadeTimer; // = *(int32*)0x8F6258; +wchar CHud::m_HelpMessageToPrint[256]; // = (wchar*)0x664480; +float CHud::m_fHelpMessageTime; // *(float *)0x8E2C28; +bool CHud::m_HelpMessageQuick; // = *(bool*)0x95CCF7; +uint32 CHud::m_ZoneState; // = *(int32*)0x8F29AC; int32 CHud::m_ZoneFadeTimer; -int32 CHud::m_ZoneNameTimer = *(int32*)0x8F1A50; -wchar *&CHud::m_pZoneName = *(wchar **)0x8E2C2C; -wchar *CHud::m_pLastZoneName = (wchar*)0x8F432C; +uint32 CHud::m_ZoneNameTimer; // = *(int32*)0x8F1A50; +wchar *CHud::m_pZoneName; // = *(wchar**)0x8E2C2C; +wchar *CHud::m_pLastZoneName; // = (wchar*)0x8F432C; wchar *CHud::m_ZoneToPrint; -int32 CHud::m_VehicleState = *(int32*)0x940560; +uint32 CHud::m_VehicleState; // = *(int32*)0x940560; int32 CHud::m_VehicleFadeTimer; -int32 CHud::m_VehicleNameTimer = *(int32*)0x8F2A14; -wchar *&CHud::m_VehicleName = *(wchar **)0x942FB4; -wchar *CHud::m_pLastVehicleName = *(wchar **)0x8E2DD8; +uint32 CHud::m_VehicleNameTimer; // = *(int32*)0x8F2A14; +wchar *CHud::m_VehicleName; // = *(wchar**)0x942FB4; +wchar *CHud::m_pLastVehicleName; // = *(wchar**)0x8E2DD8; wchar *CHud::m_pVehicleNameToPrint; -wchar *CHud::m_Message = (wchar*)0x72E318; -wchar *CHud::m_PagerMessage = (wchar*)0x878840; -bool &CHud::m_Wants_To_Draw_Hud = *(bool*)0x95CD89; -bool &CHud::m_Wants_To_Draw_3dMarkers = *(bool*)0x95CD62; -wchar(&CHud::m_BigMessage)[6][128] = *(wchar(*)[6][128])*(uintptr*)0x664CE0; -int16 &CHud::m_ItemToFlash = *(int16*)0x95CC82; +wchar CHud::m_Message[256];// = (wchar*)0x72E318; +wchar CHud::m_PagerMessage[256]; // = (wchar*)0x878840; +bool CHud::m_Wants_To_Draw_Hud; // (bool*)0x95CD89; +bool CHud::m_Wants_To_Draw_3dMarkers; // = *(bool*)0x95CD62; +wchar CHud::m_BigMessage[6][128]; // = *(wchar(*)[6][128]) * (uintptr*)0x664CE0; +int16 CHud::m_ItemToFlash; // = *(int16*)0x95CC82; // These aren't really in CHud float CHud::BigMessageInUse[6]; float CHud::BigMessageAlpha[6]; float CHud::BigMessageX[6]; -float &CHud::OddJob2OffTimer = *(float*)0x942FA0; -int8 &CHud::CounterOnLastFrame = *(int8*)0x95CD67; -float &CHud::OddJob2XOffset = *(float*)0x8F1B5C; -int16 &CHud::CounterFlashTimer = *(int16*)0x95CC20; -int16 &CHud::OddJob2Timer = *(int16*)0x95CC52; -int8 &CHud::TimerOnLastFrame = *(int8*)0x95CDA7; -int16 &CHud::OddJob2On = *(int16*)0x95CC78; -int16 &CHud::TimerFlashTimer = *(int16*)0x95CC6C; -int16 &CHud::PagerSoundPlayed = *(int16*)0x95CC4A; -int32 &CHud::SpriteBrightness = *(int32*)0x95CC54; -float &CHud::PagerXOffset = *(float*)0x941590; -int16 &CHud::PagerTimer = *(int16*)0x95CC3A; -int16 &CHud::PagerOn = *(int16*)0x95CCA0; - -CSprite2d *CHud::Sprites = (CSprite2d*)0x95CB9C; +float CHud::OddJob2OffTimer; // = *(float*)0x942FA0; +bool CHud::CounterOnLastFrame; // = *(int8*)0x95CD67; +float CHud::OddJob2XOffset; // = *(float*)0x8F1B5C; +uint16 CHud::CounterFlashTimer; // = *(int16*)0x95CC20; +uint16 CHud::OddJob2Timer; // = *(int16*)0x95CC52; +bool CHud::TimerOnLastFrame; //= *(int8*)0x95CDA7; +int16 CHud::OddJob2On; //= *(int16*)0x95CC78; +uint16 CHud::TimerFlashTimer; //= *(int16*)0x95CC6C; +int16 CHud::PagerSoundPlayed; //= *(int16*)0x95CC4A; +int32 CHud::SpriteBrightness; //= *(int32*)0x95CC54; +float CHud::PagerXOffset; //= *(float*)0x941590; +int16 CHud::PagerTimer; //= *(int16*)0x95CC3A; +int16 CHud::PagerOn; //= *(int16*)0x95CCA0; + +CSprite2d CHud::Sprites[NUM_HUD_SPRITES]; // = (CSprite2d*)0x95CB9C; struct { @@ -90,14 +88,14 @@ struct {"detonator", "detonator_mask"}, {"", ""}, {"", ""}, - {"radardisc", "radardiscm"}, + {"radardisc", "radardisc"}, {"pager", "pagerm"}, {"", ""}, {"", ""}, {"bleeder", ""}, {"sitesniper", "sitesniperm"}, {"siteM16", "siteM16m"}, - {"siterocket", "siterocketm"} + {"siterocket", "siterocket"} }; RwTexture *&gpSniperSightTex = *(RwTexture**)0x8F5834; @@ -415,7 +413,7 @@ void CHud::Draw() DrawZoneName */ if (m_pZoneName) { - float fZoneAlpha = 0.0f; + float fZoneAlpha = 255.0f; if (m_pZoneName != m_pLastZoneName) { switch (m_ZoneState) { @@ -429,7 +427,7 @@ void CHud::Draw() case 2: case 3: case 4: - m_ZoneNameTimer = 0; + m_ZoneNameTimer = 5; m_ZoneState = 4; break; default: @@ -441,6 +439,7 @@ void CHud::Draw() if (m_ZoneState) { switch (m_ZoneState) { case 1: + m_ZoneFadeTimer = 1000; if (m_ZoneNameTimer > 10000) { m_ZoneFadeTimer = 1000; m_ZoneState = 3; @@ -468,7 +467,6 @@ void CHud::Draw() if (m_ZoneFadeTimer < 0) { m_ZoneFadeTimer = 0; m_ZoneToPrint = m_pLastZoneName; - m_ZoneNameTimer = 0; m_ZoneState = 2; } fZoneAlpha = m_ZoneFadeTimer * 0.001f * 255.0f; @@ -500,12 +498,6 @@ void CHud::Draw() } } } - /*else { - m_pLastZoneName = nil; - m_ZoneState = 0; - m_ZoneFadeTimer = 0; - m_ZoneNameTimer = 0; - }*/ /* DrawVehicleName @@ -633,9 +625,9 @@ void CHud::Draw() wchar sTimer[16]; if (!CUserDisplay::OnscnTimer.m_sEntries[0].m_bTimerProcessed) - TimerOnLastFrame = 0; + TimerOnLastFrame = false; if (!CUserDisplay::OnscnTimer.m_sEntries[0].m_bCounterProcessed) - CounterOnLastFrame = 0; + CounterOnLastFrame = false; #ifdef FIX_BUGS #define TIMER_RIGHT_OFFSET 34.0f // Taken from VC frenzy timer @@ -647,7 +639,7 @@ void CHud::Draw() if (!TimerOnLastFrame) TimerFlashTimer = 1; - TimerOnLastFrame = 1; + TimerOnLastFrame = true; if (TimerFlashTimer) { if (++TimerFlashTimer > 50) @@ -685,7 +677,7 @@ void CHud::Draw() if (!CounterOnLastFrame) CounterFlashTimer = 1; - CounterOnLastFrame = 1; + CounterOnLastFrame = true; if (CounterFlashTimer) { if (++CounterFlashTimer > 50) @@ -739,11 +731,9 @@ void CHud::Draw() /* DrawPager */ - if (!m_PagerMessage[0]) { - if (PagerOn == 1) { - PagerSoundPlayed = false; - PagerOn = 2; - } + if (!m_PagerMessage[0] && PagerOn == 1) { + PagerSoundPlayed = false; + PagerOn = 2; } if (m_PagerMessage[0] || PagerOn == 2) { if (!PagerOn) { @@ -752,7 +742,7 @@ void CHud::Draw() } if (PagerOn == 1) { if (PagerXOffset > 0.0f) { - float fStep = PagerXOffset * 0.05f; + float fStep = PagerXOffset * 0.1f; if (fStep > 10.0f) fStep = 10.0f; PagerXOffset -= fStep * CTimer::GetTimeStep(); @@ -763,10 +753,10 @@ void CHud::Draw() } } else if (PagerOn == 2) { - float fStep = PagerXOffset * 0.05f; + float fStep = PagerXOffset * 0.1f; if (fStep < 2.0f) fStep = 2.0f; - PagerXOffset += fStep * CTimer::GetTimeStep(); + PagerXOffset += fStep; if (PagerXOffset > 150.0f) { PagerXOffset = 150.0f; PagerOn = 0; @@ -815,9 +805,7 @@ void CHud::Draw() DrawScriptText */ if (!CTimer::GetIsUserPaused()) { - intro_text_line* IntroText = CTheScripts::IntroTextLines; - - for (int i = 0; i < MAX_NUM_INTRO_TEXT_LINES; i++) { + for (int i = 0; i < ARRAY_SIZE(CTheScripts::IntroTextLines); i++) { if (CTheScripts::IntroTextLines[i].m_Text[0] && CTheScripts::IntroTextLines[i].m_bTextBeforeFade) { CFont::SetScale(SCREEN_SCALE_X(CTheScripts::IntroTextLines[i].m_fScaleX), SCREEN_SCALE_Y(CTheScripts::IntroTextLines[i].m_fScaleY * 0.5f)); CFont::SetColor(CTheScripts::IntroTextLines[i].m_sColor); @@ -858,31 +846,31 @@ void CHud::Draw() CFont::SetPropOff(); CFont::SetFontStyle(CTheScripts::IntroTextLines[i].m_nFont); - CFont::PrintString(SCREEN_SCALE_X(640.0f - CTheScripts::IntroTextLines[i].m_fAtX), SCREEN_SCALE_Y(448.0f - CTheScripts::IntroTextLines[i].m_fAtY), IntroText->m_Text); + CFont::PrintString(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - CTheScripts::IntroTextLines[i].m_fAtX), SCREEN_SCALE_Y(DEFAULT_SCREEN_HEIGHT - CTheScripts::IntroTextLines[i].m_fAtY), CTheScripts::IntroTextLines[i].m_Text); } } + for (int i = 0; i < ARRAY_SIZE(CTheScripts::IntroRectangles); i++) { + intro_script_rectangle &IntroRect = CTheScripts::IntroRectangles[i]; - intro_script_rectangle* IntroRect = CTheScripts::IntroRectangles; - - for (int i = 0; i < 16; i++) { - if (CTheScripts::IntroRectangles[i].m_bIsUsed && CTheScripts::IntroRectangles[i].m_bBeforeFade) { - if (CTheScripts::IntroRectangles[i].m_nTextureId >= 0) { + // Yeah, top and bottom changed place. R* vision + if (IntroRect.m_bIsUsed && IntroRect.m_bBeforeFade) { + if (IntroRect.m_nTextureId >= 0) { CRect rect = { - CTheScripts::IntroRectangles[i].m_sRect.left, - CTheScripts::IntroRectangles[i].m_sRect.bottom, - CTheScripts::IntroRectangles[i].m_sRect.right, - CTheScripts::IntroRectangles[i].m_sRect.bottom }; + IntroRect.m_sRect.left, + IntroRect.m_sRect.top, + IntroRect.m_sRect.right, + IntroRect.m_sRect.bottom }; - CTheScripts::ScriptSprites[CTheScripts::IntroRectangles[i].m_nTextureId].Draw(rect, IntroRect->m_sColor); + CTheScripts::ScriptSprites[IntroRect.m_nTextureId].Draw(rect, IntroRect.m_sColor); } else { CRect rect = { - CTheScripts::IntroRectangles[i].m_sRect.left, - CTheScripts::IntroRectangles[i].m_sRect.bottom, - CTheScripts::IntroRectangles[i].m_sRect.right, - CTheScripts::IntroRectangles[i].m_sRect.bottom }; + IntroRect.m_sRect.left, + IntroRect.m_sRect.top, + IntroRect.m_sRect.right, + IntroRect.m_sRect.bottom }; - CSprite2d::DrawRect(rect, IntroRect->m_sColor); + CSprite2d::DrawRect(rect, IntroRect.m_sColor); } } } @@ -928,7 +916,7 @@ void CHud::Draw() CFont::SetCentreSize(SCREEN_SCALE_X(615.0f)); CFont::SetFontStyle(FONT_HEADING); - if (BigMessageX[0] >= (SCREEN_WIDTH - 20)) { + if (BigMessageX[0] >= SCREEN_SCALE_FROM_RIGHT(20.0f)) { BigMessageInUse[0] += CTimer::GetTimeStep(); if (BigMessageInUse[0] >= 120.0f) { @@ -945,7 +933,7 @@ void CHud::Draw() BigMessageX[0] += (CTimer::GetTimeStepInMilliseconds() * 0.3f); BigMessageAlpha[0] += (CTimer::GetTimeStepInMilliseconds() * 0.3f); - if (BigMessageAlpha[0] >= 255.0f) + if (BigMessageAlpha[0] > 255.0f) BigMessageAlpha[0] = 255.0f; } @@ -989,7 +977,7 @@ void CHud::Draw() CFont::SetFontStyle(FONT_HEADING); CFont::SetColor(CRGBA(0, 0, 0, BigMessageAlpha[2])); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f + 4.0f), SCREEN_SCALE_FROM_BOTTOM(78.0f), m_BigMessage[2]); + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f - 4.0f), SCREEN_SCALE_FROM_BOTTOM(78.0f), m_BigMessage[2]); CFont::SetColor(CRGBA(170, 123, 87, BigMessageAlpha[2])); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f), SCREEN_SCALE_FROM_BOTTOM(82.0f), m_BigMessage[2]); @@ -1018,7 +1006,7 @@ void CHud::DrawAfterFade() m_HelpMessageState = 2; m_HelpMessageTimer = 0; CMessages::WideStringCopy(m_HelpMessageToPrint, m_HelpMessage, 256); - m_HelpMessageDisplayTime = CMessages::GetWideStringLength(m_HelpMessage) * 0.05f + 3.0f; + m_fHelpMessageTime = CMessages::GetWideStringLength(m_HelpMessage) * 0.05f + 3.0f; if (TheCamera.m_ScreenReductionPercentage == 0.0f) DMAudio.PlayFrontEndSound(SOUND_A0, 0); @@ -1036,14 +1024,14 @@ void CHud::DrawAfterFade() CMessages::WideStringCopy(m_LastHelpMessage, m_HelpMessage, 256); } - float fAlpha = 255.0f; + float fAlpha = 225.0f; - if (m_HelpMessageState) { + if (m_HelpMessageState != 0) { switch (m_HelpMessageState) { case 1: - fAlpha = 255.0f; + fAlpha = 225.0f; m_HelpMessageFadeTimer = 600; - if (m_HelpMessageTimer > m_fHelpMessageTime * 1000 || m_HelpMessageQuick && m_HelpMessageTimer > 1500) { + if (m_HelpMessageTimer > m_fHelpMessageTime * 1000.0f || m_HelpMessageQuick && m_HelpMessageTimer > 1500.0f) { m_HelpMessageFadeTimer = 600; m_HelpMessageState = 3; } @@ -1054,24 +1042,24 @@ void CHud::DrawAfterFade() m_HelpMessageState = 1; m_HelpMessageFadeTimer = 0; } - fAlpha = m_HelpMessageFadeTimer * 0.001f * 255.0f; + fAlpha = m_HelpMessageFadeTimer * 0.001f * 225.0f; break; case 3: m_HelpMessageFadeTimer -= 2 * CTimer::GetTimeStepInMilliseconds(); - if (m_HelpMessageFadeTimer >= 0) { + if (m_HelpMessageFadeTimer < 0) { m_HelpMessageState = 0; m_HelpMessageFadeTimer = 0; } - fAlpha = m_HelpMessageFadeTimer * 0.001f * 255.0f; + fAlpha = m_HelpMessageFadeTimer * 0.001f * 225.0f; break; case 4: m_HelpMessageFadeTimer -= 2 * CTimer::GetTimeStepInMilliseconds(); - if (m_HelpMessageFadeTimer >= 0) { + if (m_HelpMessageFadeTimer < 0) { m_HelpMessageState = 2; m_HelpMessageFadeTimer = 0; - CMessages::WideStringCopy(m_HelpMessageToPrint, m_LastHelpMessage, 400); + CMessages::WideStringCopy(m_HelpMessageToPrint, m_LastHelpMessage, 256); } - fAlpha = m_HelpMessageFadeTimer * 0.001f * 255.0f; + fAlpha = m_HelpMessageFadeTimer * 0.001f * 225.0f; break; default: break; @@ -1088,19 +1076,75 @@ void CHud::DrawAfterFade() else CFont::SetScale(SCREEN_SCALE_X(0.52f), SCREEN_SCALE_Y(1.1f)); + CFont::SetColor(CRGBA(175, 175, 175, 255)); CFont::SetJustifyOff(); CFont::SetWrapx(SCREEN_SCALE_X(200.0f + 26.0f - 4.0f)); CFont::SetFontStyle(FONT_BANK); CFont::SetBackgroundOn(); CFont::SetBackGroundOnlyTextOff(); - CFont::SetBackgroundColor(CRGBA(0, 0, 0, fAlpha * 0.8f)); - CFont::SetColor(CRGBA(175, 175, 175, 255)); + CFont::SetBackgroundColor(CRGBA(0, 0, 0, fAlpha * 0.9f)); CFont::PrintString(SCREEN_SCALE_X(26.0f), SCREEN_SCALE_Y(28.0f + (150.0f - PagerXOffset) * 0.6f), CHud::m_HelpMessageToPrint); CFont::SetAlphaFade(255.0f); } } - else - m_HelpMessageState = 0; + + for (int i = 0; i < ARRAY_SIZE(CTheScripts::IntroTextLines); i++) { + intro_text_line &line = CTheScripts::IntroTextLines[i]; + if (line.m_Text[0] != '\0' && !line.m_bTextBeforeFade) { + CFont::SetScale(SCREEN_SCALE_X(line.m_fScaleX), SCREEN_SCALE_Y(line.m_fScaleY) / 2); + + CFont::SetColor(line.m_sColor); + if (line.m_bJustify) + CFont::SetJustifyOn(); + else + CFont::SetJustifyOff(); + + if (line.m_bRightJustify) + CFont::SetRightJustifyOn(); + else + CFont::SetRightJustifyOff(); + + if (line.m_bCentered) + CFont::SetCentreOn(); + else + CFont::SetCentreOff(); + + CFont::SetWrapx(SCREEN_SCALE_X(line.m_fWrapX)); + CFont::SetCentreSize(SCREEN_SCALE_X(line.m_fCenterSize)); + if (line.m_bBackground) + CFont::SetBackgroundOn(); + else + CFont::SetBackgroundOff(); + + CFont::SetBackgroundColor(line.m_sBackgroundColor); + if (line.m_bBackgroundOnly) + CFont::SetBackGroundOnlyTextOn(); + else + CFont::SetBackGroundOnlyTextOff(); + + if (line.m_bTextProportional) + CFont::SetPropOn(); + else + CFont::SetPropOff(); + + CFont::SetFontStyle(line.m_nFont); + CFont::PrintString(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - line.m_fAtX), SCREEN_SCALE_Y(DEFAULT_SCREEN_HEIGHT - line.m_fAtY), line.m_Text); + } + } + for (int i = 0; i < ARRAY_SIZE(CTheScripts::IntroRectangles); i++) { + intro_script_rectangle &rectangle = CTheScripts::IntroRectangles[i]; + if (rectangle.m_bIsUsed && !rectangle.m_bBeforeFade) { + + // Yeah, top and bottom changed place. R* vision + if (rectangle.m_nTextureId >= 0) { + CTheScripts::ScriptSprites[rectangle.m_nTextureId].Draw(CRect(rectangle.m_sRect.left, rectangle.m_sRect.bottom, + rectangle.m_sRect.right, rectangle.m_sRect.top), rectangle.m_sColor); + } else { + CSprite2d::DrawRect(CRect(rectangle.m_sRect.left, rectangle.m_sRect.bottom, + rectangle.m_sRect.right, rectangle.m_sRect.top), rectangle.m_sColor); + } + } + } /* DrawBigMessage2 @@ -1142,10 +1186,9 @@ void CHud::DrawAfterFade() if (OddJob2OffTimer > 0) OddJob2OffTimer -= CTimer::GetTimeStepInMilliseconds(); - static float fStep; + float fStep; if (m_BigMessage[5][0] && OddJob2OffTimer <= 0.0f) { - if (OddJob2On <= 3) { - switch (OddJob2On) { + switch (OddJob2On) { case 0: OddJob2On = 1; OddJob2XOffset = 380.0f; @@ -1156,9 +1199,7 @@ void CHud::DrawAfterFade() OddJob2On = 2; } else { - fStep = 40.0f; - if ((OddJob2XOffset / 6.0f) <= 40.0f) - fStep = OddJob2XOffset / 6.0f; + fStep = min(40.0f, OddJob2XOffset / 6.0f); OddJob2XOffset = OddJob2XOffset - fStep; } break; @@ -1169,9 +1210,7 @@ void CHud::DrawAfterFade() } break; case 3: - fStep = 30.0f; - if ((OddJob2XOffset / 5.0f) >= 30.0f) - fStep = OddJob2XOffset / 5.0f; + fStep = max(30.0f, OddJob2XOffset / 5.0f); OddJob2XOffset = OddJob2XOffset - fStep; @@ -1182,7 +1221,6 @@ void CHud::DrawAfterFade() break; default: break; - } } if (!m_BigMessage[1][0]) { @@ -1216,10 +1254,10 @@ void CHud::DrawAfterFade() CFont::SetScale(SCREEN_SCALE_X(1.04f), SCREEN_SCALE_Y(1.6f)); CFont::SetPropOn(); - CFont::SetRightJustifyWrap(-500.0f); + CFont::SetRightJustifyWrap(SCREEN_SCALE_X(-500.0f)); CFont::SetRightJustifyOn(); CFont::SetFontStyle(FONT_HEADING); - if (BigMessageX[1] >= (SCREEN_WIDTH - 20)) { + if (BigMessageX[1] >= SCREEN_SCALE_FROM_RIGHT(20.0f)) { BigMessageInUse[1] += CTimer::GetTimeStep(); if (BigMessageInUse[1] >= 120.0f) { @@ -1230,12 +1268,11 @@ void CHud::DrawAfterFade() m_BigMessage[1][0] = 0; BigMessageAlpha[1] = 0.0f; } - } - else { + } else { BigMessageX[1] += (CTimer::GetTimeStepInMilliseconds() * 0.3f); BigMessageAlpha[1] += (CTimer::GetTimeStepInMilliseconds() * 0.3f); - if (BigMessageAlpha[1] >= 255.0f) + if (BigMessageAlpha[1] > 255.0f) BigMessageAlpha[1] = 255.0f; } @@ -1273,7 +1310,7 @@ void CHud::GetRidOfAllHudMessages() m_HelpMessageFadeTimer = 0; m_HelpMessageState = 0; m_HelpMessageQuick = 0; - m_HelpMessageDisplayTime = 1.0f; + m_fHelpMessageTime = 1.0f; m_VehicleName = nil; m_pLastVehicleName = nil; m_pVehicleNameToPrint = nil; @@ -1303,7 +1340,7 @@ void CHud::Initialise() CTxdStore::PopCurrentTxd(); CTxdStore::SetCurrentTxd(HudTXD); - for (int i = 0; i < ARRAY_SIZE(WeaponFilenames); i++) { + for (int i = 0; i < NUM_HUD_SPRITES; i++) { Sprites[i].SetTexture(WeaponFilenames[i].name, WeaponFilenames[i].mask); } @@ -1314,14 +1351,14 @@ void CHud::Initialise() if (gpRocketSightTex == nil) gpRocketSightTex = RwTextureRead("siterocket", nil); - CounterOnLastFrame = 0; + CounterOnLastFrame = false; m_ItemToFlash = ITEM_NONE; OddJob2Timer = 0; OddJob2OffTimer = 0.0f; OddJob2On = 0; OddJob2XOffset = 0.0f; CounterFlashTimer = 0; - TimerOnLastFrame = 0; + TimerOnLastFrame = false; TimerFlashTimer = 0; SpriteBrightness = 0; PagerOn = 0; @@ -1338,14 +1375,14 @@ void CHud::ReInitialise() { GetRidOfAllHudMessages(); - CounterOnLastFrame = 0; + CounterOnLastFrame = false; m_ItemToFlash = ITEM_NONE; OddJob2Timer = 0; OddJob2OffTimer = 0.0f; OddJob2On = 0; OddJob2XOffset = 0.0f; CounterFlashTimer = 0; - TimerOnLastFrame = 0; + TimerOnLastFrame = false; TimerFlashTimer = 0; SpriteBrightness = 0; PagerOn = 0; @@ -1435,7 +1472,7 @@ void CHud::SetZoneName(wchar *name) void CHud::Shutdown() { - for (int i = 0; i < ARRAY_SIZE(WeaponFilenames); ++i) { + for (int i = 0; i < NUM_HUD_SPRITES; ++i) { Sprites[i].Delete(); } diff --git a/src/render/Hud.h b/src/render/Hud.h index d3482ae6..701e47e2 100644 --- a/src/render/Hud.h +++ b/src/render/Hud.h @@ -27,59 +27,60 @@ enum eSprites HUD_RADARDISC = 15, HUD_PAGER = 16, HUD_SITESNIPER = 20, - HUD_SITEM16 = 21 + HUD_SITEM16, + HUD_SITEROCKET, + NUM_HUD_SPRITES, }; class CHud { public: - static CSprite2d *Sprites; - static int32 &SpriteBrightness; - static wchar *m_HelpMessage; - static wchar *m_LastHelpMessage; - static int32 &m_HelpMessageState; - static int32 &m_HelpMessageTimer; - static int32 &m_HelpMessageFadeTimer; - static wchar *m_HelpMessageToPrint; + static CSprite2d Sprites[NUM_HUD_SPRITES]; + static wchar m_HelpMessage[256]; + static wchar m_LastHelpMessage[256]; + static uint32 m_HelpMessageState; + static uint32 m_HelpMessageTimer; + static int32 m_HelpMessageFadeTimer; + static wchar m_HelpMessageToPrint[256]; static float &m_HelpMessageDisplayTime; - static float &m_fTextBoxNumLines; - static float &m_fHelpMessageTime; - static bool &m_HelpMessageQuick; - static int32 m_ZoneState; + static float m_fHelpMessageTime; + static bool m_HelpMessageQuick; + static uint32 m_ZoneState; static int32 m_ZoneFadeTimer; - static int32 m_ZoneNameTimer; - static wchar *&m_pZoneName; + static uint32 m_ZoneNameTimer; + static wchar *m_pZoneName; static wchar *m_pLastZoneName; static wchar *m_ZoneToPrint; - static wchar *&m_VehicleName; + static wchar *m_VehicleName; static wchar *m_pLastVehicleName; static wchar *m_pVehicleNameToPrint; - static int32 m_VehicleState; + static uint32 m_VehicleState; static int32 m_VehicleFadeTimer; - static int32 m_VehicleNameTimer; - static wchar *m_Message; - static wchar *m_PagerMessage; - static bool &m_Wants_To_Draw_Hud; - static bool &m_Wants_To_Draw_3dMarkers; - static wchar(&m_BigMessage)[6][128]; - static int16 &m_ItemToFlash; + static uint32 m_VehicleNameTimer; + static wchar m_Message[256]; + static wchar m_PagerMessage[256]; + static bool m_Wants_To_Draw_Hud; + static bool m_Wants_To_Draw_3dMarkers; + static wchar m_BigMessage[6][128]; + static int16 m_ItemToFlash; // These aren't really in CHud static float BigMessageInUse[6]; static float BigMessageAlpha[6]; static float BigMessageX[6]; - static float &OddJob2OffTimer; - static int8 &CounterOnLastFrame; - static float &OddJob2XOffset; - static int16 &CounterFlashTimer; - static int16 &OddJob2Timer; - static int8 &TimerOnLastFrame; - static int16 &OddJob2On; - static int16 &TimerFlashTimer; - static int16 &PagerSoundPlayed; - static float &PagerXOffset; - static int16 &PagerTimer; - static int16 &PagerOn; + static float OddJob2OffTimer; + static bool CounterOnLastFrame; + static float OddJob2XOffset; + static uint16 CounterFlashTimer; + static uint16 OddJob2Timer; + static bool TimerOnLastFrame; + static int16 OddJob2On; + static uint16 TimerFlashTimer; + static int16 PagerSoundPlayed; + static int32 SpriteBrightness; + static float PagerXOffset; + static int16 PagerTimer; + static int16 PagerOn; public: static void Draw(); -- cgit v1.2.3 From 1932d98482e3622501f7467a9162f4a3ba7cce19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Sun, 12 Apr 2020 01:33:04 +0300 Subject: CDebug fix --- src/core/Debug.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/Debug.cpp b/src/core/Debug.cpp index 2b713198..917c99ab 100644 --- a/src/core/Debug.cpp +++ b/src/core/Debug.cpp @@ -24,7 +24,7 @@ CDebug::DebugAddText(const char *str) { int32 i = 0; if (*str != '\0') { - while (i < MAX_STR_LEN) { + while (i < MAX_STR_LEN - 1) { ms_aTextBuffer[ms_nCurrentTextLine][i++] = *(str++); if (*str == '\0') break; -- cgit v1.2.3 From 7d137d8f2d3effa96593cae34e7259e0ab025e4d Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Sun, 12 Apr 2020 02:39:27 +0200 Subject: Cleanup audio code --- src/audio/AudioCollision.cpp | 8 +- src/audio/AudioManager.cpp | 473 +++++++++++++++++++++++-------------------- src/audio/AudioManager.h | 12 +- src/audio/PoliceRadio.cpp | 19 +- 4 files changed, 270 insertions(+), 242 deletions(-) diff --git a/src/audio/AudioCollision.cpp b/src/audio/AudioCollision.cpp index 4039bd75..99c87a6a 100644 --- a/src/audio/AudioCollision.cpp +++ b/src/audio/AudioCollision.cpp @@ -151,7 +151,7 @@ cAudioManager::SetUpLoopingCollisionSound(cAudioCollision *col, uint8 counter) m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, CollisionSoundIntensity, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = counter; + m_sQueueSample.m_nCounter = counter; m_sQueueSample.m_vecPos = col->m_vecPosition; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; @@ -164,7 +164,7 @@ cAudioManager::SetUpLoopingCollisionSound(cAudioCollision *col, uint8 counter) SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = CollisionSoundIntensity; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 5; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; @@ -270,7 +270,7 @@ cAudioManager::SetUpOneShotCollisionSound(cAudioCollision *col) break; } m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); - m_sQueueSample.m_counter = counter++; + m_sQueueSample.m_nCounter = counter++; if(counter >= 255) counter = 28; m_sQueueSample.m_vecPos = col->m_vecPosition; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; @@ -282,7 +282,7 @@ cAudioManager::SetUpOneShotCollisionSound(cAudioCollision *col) m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = CollisionSoundIntensity; - m_sQueueSample.m_bReleasingSoundFlag = 1; + m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index b73cf3ca..2453e066 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -216,7 +216,9 @@ cPedComments::Add(tPedComment *com) } } - if(i < index) memmove(&m_nIndexMap[m_nActiveBank][i + 1], &m_nIndexMap[m_nActiveBank][i], NUM_PED_COMMENTS_SLOTS -1 - i); + if(i < index) + memmove(&m_nIndexMap[m_nActiveBank][i + 1], &m_nIndexMap[m_nActiveBank][i], + NUM_PED_COMMENTS_SLOTS - 1 - i); } m_nIndexMap[m_nActiveBank][i] = index; @@ -239,7 +241,7 @@ cPedComments::Process() AudioManager.m_sQueueSample.m_nEntityIndex = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nEntityIndex; - AudioManager.m_sQueueSample.m_counter = 0; + AudioManager.m_sQueueSample.m_nCounter = 0; AudioManager.m_sQueueSample.m_nSampleIndex = sampleIndex; AudioManager.m_sQueueSample.m_bBankIndex = SAMPLEBANK_PED; AudioManager.m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -260,7 +262,7 @@ cPedComments::Process() break; default: AudioManager.m_sQueueSample.m_fSoundIntensity = defaultIntensity; break; } - AudioManager.m_sQueueSample.m_bReleasingSoundFlag = 1; + AudioManager.m_sQueueSample.m_bReleasingSoundFlag = true; AudioManager.m_sQueueSample.m_vecPos = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_vecPos; @@ -326,7 +328,7 @@ cAudioManager::AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sampl { m_sQueueSample.m_bVolume = ComputeVolume(emittingVolume, 50.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = counter; + m_sQueueSample.m_nCounter = counter; m_sQueueSample.m_nSampleIndex = sample; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; @@ -343,7 +345,7 @@ cAudioManager::AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sampl m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; m_sQueueSample.m_fSoundIntensity = 50.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); @@ -368,7 +370,7 @@ cAudioManager::AddReflectionsToRequestedQueue() m_sQueueSample.m_bVolume = ComputeVolume( emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume > emittingVolume >> 4) { - m_sQueueSample.m_counter += ((i + 1) << 8); + m_sQueueSample.m_nCounter += ((i + 1) << 8); if(m_sQueueSample.m_nLoopCount) { noise = RandomDisplacement(m_sQueueSample.m_nFrequency >> 5); if(noise <= 0) @@ -402,15 +404,15 @@ cAudioManager::AddReleasingSounds() m_asSamples[m_bActiveSampleQueue] [m_abSampleQueueIndexTable[m_bActiveSampleQueue][j]] .m_nEntityIndex && - sample.m_counter == m_asSamples[m_bActiveSampleQueue] + sample.m_nCounter == m_asSamples[m_bActiveSampleQueue] [m_abSampleQueueIndexTable[m_bActiveSampleQueue][j]] - .m_counter) { + .m_nCounter) { toProcess[i] = true; break; } } if(!toProcess[i]) { - if(sample.m_counter <= 255 || !sample.m_bLoopsRemaining) { + if(sample.m_nCounter <= 255 || !sample.m_bLoopsRemaining) { if(!sample.m_nReleasingVolumeDivider) continue; if(!sample.m_nLoopCount) { if(sample.m_nVolumeChange == -1) { @@ -453,7 +455,7 @@ cAudioManager::AddSampleToRequestedQueue() ++m_bSampleRequestQueuesStatus[m_bActiveSampleQueue]; } m_sQueueSample.calculatedVolume = calculatedVolume; - m_sQueueSample.m_bLoopEnded = 0; + m_sQueueSample.m_bLoopEnded = false; if(m_sQueueSample.m_bIs2D) { m_sQueueSample.m_bRequireReflection = false; m_sQueueSample.m_bLoopsRemaining = 0; @@ -495,7 +497,7 @@ cAudioManager::ClearActiveSamples() { for(int32 i = 0; i < m_bActiveSamples; i++) { m_asActiveSamples[i].m_nEntityIndex = AEHANDLE_NONE; - m_asActiveSamples[i].m_counter = 0; + m_asActiveSamples[i].m_nCounter = 0; m_asActiveSamples[i].m_nSampleIndex = NO_SAMPLE; m_asActiveSamples[i].m_bBankIndex = SAMPLEBANK_INVALID; m_asActiveSamples[i].m_bIs2D = false; @@ -504,8 +506,8 @@ cAudioManager::ClearActiveSamples() m_asActiveSamples[i].m_bVolume = 0; m_asActiveSamples[i].m_bEmittingVolume = 0; m_asActiveSamples[i].m_fDistance = 0.0f; - m_asActiveSamples[i].m_bIsProcessed = 0; - m_asActiveSamples[i].m_bLoopEnded = 0; + m_asActiveSamples[i].m_bIsProcessed = false; + m_asActiveSamples[i].m_bLoopEnded = false; m_asActiveSamples[i].m_nLoopCount = 1; m_asActiveSamples[i].m_nLoopStart = 0; m_asActiveSamples[i].m_nLoopEnd = -1; @@ -532,8 +534,8 @@ cAudioManager::ClearMissionAudio() m_sMissionAudio.m_bPlayStatus = PLAY_STATUS_STOPPED; m_sMissionAudio.field_22 = 0; m_sMissionAudio.m_bIsPlayed = false; - m_sMissionAudio.field_12 = 1; - m_sMissionAudio.field_24 = 0; + m_sMissionAudio.m_bPredefinedProperties = 1; + m_sMissionAudio.m_nMissionAudioCounter = 0; } } @@ -554,7 +556,7 @@ cAudioManager::ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, if(!TheCamera.Get_Just_Switched_Status() && speedMultiplier != 0.0f) { float dist = position2 - position1; if(dist != 0.0f) { - float speedOfSource = (dist / field_19192) * speedMultiplier; + float speedOfSource = (dist / m_bTimeSpent) * speedMultiplier; if(m_fSpeedOfSound > Abs(speedOfSource)) { if(speedOfSource < 0.0f) { speedOfSource = max(speedOfSource, -1.5f); @@ -654,7 +656,7 @@ cAudioManager::DestroyEntity(int32 id) if(id == m_anAudioEntityIndices[i]) { if(i < totalAudioEntitiesSlots - 1) memmove(&m_anAudioEntityIndices[i], &m_anAudioEntityIndices[i + 1], - 4 * (m_nAudioEntitiesTotal - (i + 1))); + NUM_AUDIOENTITY_EVENTS * (m_nAudioEntitiesTotal - (i + 1))); m_anAudioEntityIndices[--m_nAudioEntitiesTotal] = totalAudioEntitiesSlots; return; } @@ -720,7 +722,7 @@ cAudioManager::GetSwatTalkSfx(int16 sound) GetPhrase(&sfx, &lastSfx, SFX_SWAT_VOICE_1_CHASE_1, 6); } - return (SFX_SWAT_VOICE_2_CHASE_1 - SFX_SWAT_VOICE_1_CHASE_1) * (m_sQueueSample.m_nEntityIndex % 3) + sfx; + return (SFX_SWAT_VOICE_2_CHASE_1 - SFX_SWAT_VOICE_1_CHASE_1) * (m_sQueueSample.m_nEntityIndex % 4) + sfx; } uint32 @@ -2164,7 +2166,13 @@ cAudioManager::GetSecurityGuardTalkSfx(int16 sound) case SOUND_PED_CAR_JACKED: case SOUND_PED_CAR_COLLISION: GetPhrase(&sfx, &lastSfx, SFX_SECURITY_GUARD_VOICE_1_DRIVER_ABUSE_1, 6); break; case SOUND_PED_ATTACK: GetPhrase(&sfx, &lastSfx, SFX_SECURITY_GUARD_VOICE_1_FIGHT_1, 2); break; - case SOUND_PED_FLEE_RUN: GetPhrase(&sfx, &lastSfx, SFX_SECURITY_GUARD_VOICE_1_DRIVER_ABUSE_1, 12); break; + case SOUND_PED_FLEE_RUN: +#ifdef FIX_BUGS + sfx = SFX_SECURITY_GUARD_VOICE_1_RUN_FROM_FIGHT_1; +#else + GetPhrase(&sfx, &lastSfx, SFX_SECURITY_GUARD_VOICE_1_DRIVER_ABUSE_1, 12); +#endif + break; default: return GetGenericMaleTalkSfx(sound); } return sfx; @@ -2560,11 +2568,15 @@ cAudioManager::PlayOneShot(int32 index, int16 sound, float vol) break; ++i; } - if(i < 3) { + if(i < NUM_AUDIOENTITY_EVENTS - 1) { memmove(&entity.m_awAudioEvent[i + 1], - &entity.m_awAudioEvent[i], (3 - i) * 2); - memmove(&entity.m_afVolume[i + 1], &entity.m_afVolume[i], - (3 - i) * 4); + &entity.m_awAudioEvent[i], + (NUM_AUDIOENTITY_EVENTS - 1 - i) * + NUM_AUDIOENTITY_EVENTS / 2); + memmove(&entity.m_afVolume[i + 1], + &entity.m_afVolume[i], + (NUM_AUDIOENTITY_EVENTS - 1 - i) * + NUM_AUDIOENTITY_EVENTS); } entity.m_awAudioEvent[i] = sound; entity.m_afVolume[i] = vol; @@ -2617,8 +2629,8 @@ cAudioManager::PostInitialiseGameSpecificSetup() m_sMissionAudio.m_bPlayStatus = PLAY_STATUS_STOPPED; m_sMissionAudio.field_22 = 0; m_sMissionAudio.m_bIsPlayed = false; - m_sMissionAudio.field_12 = 1; - m_sMissionAudio.field_24 = 0; + m_sMissionAudio.m_bPredefinedProperties = 1; + m_sMissionAudio.m_nMissionAudioCounter = 0; ResetAudioLogicTimers(CTimer::GetTimeInMilliseconds()); } @@ -2713,11 +2725,11 @@ cAudioManager::PreloadMissionAudio(const char *name) m_sMissionAudio.m_bLoadingStatus = LOADING_STATUS_NOT_LOADED; m_sMissionAudio.m_bPlayStatus = PLAY_STATUS_STOPPED; m_sMissionAudio.field_22 = 0; - m_sMissionAudio.field_24 = - field_19192 * SampleManager.GetStreamedFileLength(missionAudioSfx) / 1000; - m_sMissionAudio.field_24 *= 4; + m_sMissionAudio.m_nMissionAudioCounter = + m_bTimeSpent * SampleManager.GetStreamedFileLength(missionAudioSfx) / 1000; + m_sMissionAudio.m_nMissionAudioCounter *= 4; m_sMissionAudio.m_bIsPlayed = false; - m_sMissionAudio.field_12 = 1; + m_sMissionAudio.m_bPredefinedProperties = 1; g_bMissionAudioLoadFailed = 0; } } @@ -2775,8 +2787,8 @@ cAudioManager::ProcessActiveQueues() CVector position; for (int32 i = 0; i < m_bActiveSamples; i++) { - m_asSamples[m_bActiveSampleQueue][i].m_bIsProcessed = 0; - m_asActiveSamples[i].m_bIsProcessed = 0; + m_asSamples[m_bActiveSampleQueue][i].m_bIsProcessed = false; + m_asActiveSamples[i].m_bIsProcessed = false; } for (int32 i = 0; i < m_bSampleRequestQueuesStatus[m_bActiveSampleQueue]; ++i) { @@ -2784,7 +2796,7 @@ cAudioManager::ProcessActiveQueues() if (sample.m_nSampleIndex != NO_SAMPLE) { for (int32 j = 0; j < m_bActiveSamples; ++j) { if (sample.m_nEntityIndex == m_asActiveSamples[j].m_nEntityIndex && - sample.m_counter == m_asActiveSamples[j].m_counter && + sample.m_nCounter == m_asActiveSamples[j].m_nCounter && sample.m_nSampleIndex == m_asActiveSamples[j].m_nSampleIndex) { if (sample.m_nLoopCount) { if (m_FrameCounter & 1) { @@ -2794,15 +2806,15 @@ cAudioManager::ProcessActiveQueues() flag = !(j & 1); } if (flag && !SampleManager.GetChannelUsedFlag(j)) { - sample.m_bLoopEnded = 1; - m_asActiveSamples[j].m_bLoopEnded = 1; + sample.m_bLoopEnded = true; + m_asActiveSamples[j].m_bLoopEnded = true; m_asActiveSamples[j].m_nSampleIndex = NO_SAMPLE; m_asActiveSamples[j].m_nEntityIndex = AEHANDLE_NONE; continue; } } - sample.m_bIsProcessed = 1; - m_asActiveSamples[j].m_bIsProcessed = 1; + sample.m_bIsProcessed = true; + m_asActiveSamples[j].m_bIsProcessed = true; sample.m_nVolumeChange = -1; if (!sample.m_bReleasingSoundFlag) { if (sample.m_bIs2D) { @@ -2872,8 +2884,8 @@ cAudioManager::ProcessActiveQueues() SampleManager.SetChannelReverbFlag(j, sample.m_bReverbFlag); continue; } - sample.m_bIsProcessed = 0; - m_asActiveSamples[j].m_bIsProcessed = 0; + sample.m_bIsProcessed = false; + m_asActiveSamples[j].m_bIsProcessed = false; break; } } @@ -2890,7 +2902,7 @@ cAudioManager::ProcessActiveQueues() tSound& sample = m_asSamples[m_bActiveSampleQueue][m_abSampleQueueIndexTable[m_bActiveSampleQueue][i]]; if (!sample.m_bIsProcessed && !sample.m_bLoopEnded && m_asAudioEntities[sample.m_nEntityIndex].m_bIsUsed && sample.m_nSampleIndex < NO_SAMPLE) { - if (sample.m_counter > 255 && sample.m_nLoopCount && sample.m_bLoopsRemaining) { + if (sample.m_nCounter > 255 && sample.m_nLoopCount && sample.m_bLoopsRemaining) { --sample.m_bLoopsRemaining; sample.m_nReleasingVolumeDivider = 1; } @@ -2898,7 +2910,7 @@ cAudioManager::ProcessActiveQueues() for (int32 j = 0; j < m_bActiveSamples; ++j) { if (!m_asActiveSamples[j].m_bIsProcessed) { if (sample.m_nLoopCount) { - v28 = sample.m_nFrequency / field_19192; + v28 = sample.m_nFrequency / m_bTimeSpent; v29 = sample.m_nLoopCount * SampleManager.GetSampleLength(sample.m_nSampleIndex); if (v28 == 0) continue; @@ -2954,8 +2966,8 @@ cAudioManager::ProcessActiveQueues() 0.25f * m_asActiveSamples[j].m_fSoundIntensity); SampleManager.StartChannel(j); } - m_asActiveSamples[j].m_bIsProcessed = 1; - sample.m_bIsProcessed = 1; + m_asActiveSamples[j].m_bIsProcessed = true; + sample.m_bIsProcessed = true; sample.m_nVolumeChange = -1; break; } @@ -2983,7 +2995,7 @@ cAudioManager::ProcessAirBrakes(cVehicleParams *params) rand = m_anRandomTable[0] % 10 + 70; m_sQueueSample.m_bVolume = ComputeVolume(rand, 30.0f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 13; + m_sQueueSample.m_nCounter = 13; m_sQueueSample.m_nSampleIndex = SFX_AIR_BRAKES; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_AIR_BRAKES); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 4); @@ -2996,7 +3008,7 @@ cAudioManager::ProcessAirBrakes(cVehicleParams *params) m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_fSoundIntensity = 30.0f; - m_sQueueSample.m_bReleasingSoundFlag = 1; + m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); @@ -3031,10 +3043,10 @@ cAudioManager::ProcessAirportScriptObject(uint8 sound) m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_counter = counter++; + m_sQueueSample.m_nCounter = counter++; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = 1; + m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_bEmittingVolume = 110; @@ -3070,7 +3082,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params) CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_bVolume = ComputeVolume(80, 50.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 39; + m_sQueueSample.m_nCounter = 39; m_sQueueSample.m_nSampleIndex = SFX_FISHING_BOAT_IDLE; m_sQueueSample.m_nFrequency = 10386; m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex << 16) % 1000; @@ -3085,7 +3097,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params) SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = intensity; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 7; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; @@ -3115,7 +3127,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params) } m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 50.f, m_sQueueSample.m_fDistance); if(!m_sQueueSample.m_bVolume) return 1; - m_sQueueSample.m_counter = 40; + m_sQueueSample.m_nCounter = 40; m_sQueueSample.m_nSampleIndex = SFX_POLICE_BOAT_ACCEL; m_sQueueSample.m_nFrequency += (m_sQueueSample.m_nEntityIndex << 16) % 1000; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; @@ -3128,7 +3140,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = intensity; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 7; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; @@ -3141,7 +3153,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params) if(padAccelerate <= 20) { emittingVol = 45 - 45 * padAccelerate / 40; m_sQueueSample.m_nFrequency = 100 * padAccelerate + 11025; - m_sQueueSample.m_counter = 39; + m_sQueueSample.m_nCounter = 39; m_sQueueSample.m_nSampleIndex = SFX_POLICE_BOAT_IDLE; if(LastAccel > 20) { oneShotVol = LastVol; @@ -3152,7 +3164,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params) m_sQueueSample.m_nFrequency = 4000 * padAccelerate / 255 + 8000; if(!boat->m_bIsAnchored) m_sQueueSample.m_nFrequency = 11 * m_sQueueSample.m_nFrequency / 10; - m_sQueueSample.m_counter = 40; + m_sQueueSample.m_nCounter = 40; m_sQueueSample.m_nSampleIndex = SFX_POLICE_BOAT_ACCEL; } LastVol = emittingVol; @@ -3162,14 +3174,14 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params) if(gasPedal > 0.0f) { m_sQueueSample.m_nFrequency = 11025; emittingVol = 45; - m_sQueueSample.m_counter = 39; + m_sQueueSample.m_nCounter = 39; m_sQueueSample.m_nSampleIndex = SFX_POLICE_BOAT_IDLE; } else { emittingVol = (105.f * gasPedal) + 15; m_sQueueSample.m_nFrequency = (4000.f * gasPedal) + 8000; if(!boat->m_bIsAnchored) m_sQueueSample.m_nFrequency = 11 * m_sQueueSample.m_nFrequency / 10; - m_sQueueSample.m_counter = 40; + m_sQueueSample.m_nCounter = 40; m_sQueueSample.m_nSampleIndex = SFX_POLICE_BOAT_ACCEL; } } @@ -3187,7 +3199,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = intensity; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 7; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; @@ -3216,7 +3228,7 @@ cAudioManager::ProcessBoatMovingOverWater(cVehicleParams *params) vol = (30.f * multiplier); m_sQueueSample.m_bVolume = ComputeVolume(vol, 50.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 38; + m_sQueueSample.m_nCounter = 38; m_sQueueSample.m_nSampleIndex = SFX_BOAT_WATER_LOOP; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; @@ -3228,7 +3240,7 @@ cAudioManager::ProcessBoatMovingOverWater(cVehicleParams *params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = 50.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; @@ -3271,7 +3283,7 @@ cAudioManager::ProcessBridgeMotor() if(m_sQueueSample.m_fDistance < bridgeIntensity) { m_sQueueSample.m_bVolume = ComputeVolume(maxVolume, bridgeIntensity, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 1; + m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_nSampleIndex = SFX_FISHING_BOAT_IDLE; // todo check sfx name m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; @@ -3284,7 +3296,7 @@ cAudioManager::ProcessBridgeMotor() m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = bridgeIntensity; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = false; AddSampleToRequestedQueue(); @@ -3316,7 +3328,7 @@ cAudioManager::ProcessBridgeOneShots() if(m_sQueueSample.m_fDistance < bridgeIntensity) { m_sQueueSample.m_bVolume = ComputeVolume(maxVolume, bridgeIntensity, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 2; + m_sQueueSample.m_nCounter = 2; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; @@ -3328,7 +3340,7 @@ cAudioManager::ProcessBridgeOneShots() m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = bridgeIntensity; - m_sQueueSample.m_bReleasingSoundFlag = 1; + m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_bReverbFlag = false; m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); @@ -3342,7 +3354,7 @@ cAudioManager::ProcessBridgeWarning() if(CStats::CommercialPassed && m_sQueueSample.m_fDistance < 450.f) { m_sQueueSample.m_bVolume = ComputeVolume(100, 450.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 0; + m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nSampleIndex = SFX_BRIDGE_OPEN_WARNING; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; @@ -3355,7 +3367,7 @@ cAudioManager::ProcessBridgeWarning() m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = 450.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 8; m_sQueueSample.m_bReverbFlag = false; m_sQueueSample.m_bRequireReflection = false; @@ -3375,7 +3387,7 @@ cAudioManager::ProcessCarBombTick(cVehicleParams *params) CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_bVolume = ComputeVolume(60, 40.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 35; + m_sQueueSample.m_nCounter = 35; m_sQueueSample.m_nSampleIndex = SFX_COUNTDOWN; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; @@ -3388,7 +3400,7 @@ cAudioManager::ProcessCarBombTick(cVehicleParams *params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = 40.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; @@ -3422,7 +3434,7 @@ cAudioManager::ProcessCesna(cVehicleParams *params) CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_bVolume = ComputeVolume(80, 200.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 52; + m_sQueueSample.m_nCounter = 52; m_sQueueSample.m_nSampleIndex = SFX_CESNA_IDLE; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; @@ -3436,7 +3448,7 @@ cAudioManager::ProcessCesna(cVehicleParams *params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 8.0f; m_sQueueSample.m_fSoundIntensity = 200.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); @@ -3444,7 +3456,7 @@ cAudioManager::ProcessCesna(cVehicleParams *params) if(params->m_fDistance < 8100.f) { m_sQueueSample.m_bVolume = ComputeVolume(80, 90.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 2; + m_sQueueSample.m_nCounter = 2; m_sQueueSample.m_nSampleIndex = SFX_CESNA_REV; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; @@ -3459,7 +3471,7 @@ cAudioManager::ProcessCesna(cVehicleParams *params) SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 8.0f; m_sQueueSample.m_fSoundIntensity = 90.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); @@ -3498,10 +3510,10 @@ cAudioManager::ProcessCinemaScriptObject(uint8 sound) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 4); - m_sQueueSample.m_counter = counter++; + m_sQueueSample.m_nCounter = counter++; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = 1; + m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_bEmittingVolume = rand; @@ -3533,7 +3545,7 @@ cAudioManager::ProcessCrane() CalculateDistance(distCalculated, distSquared); m_sQueueSample.m_bVolume = ComputeVolume(100, 80.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 0; + m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nSampleIndex = SFX_CRANE_MAGNET; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; @@ -3547,19 +3559,19 @@ cAudioManager::ProcessCrane() SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = intensity; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); } if(m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents) { - m_sQueueSample.m_counter = 1; + m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_nSampleIndex = SFX_COL_CAR_2; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_COL_CAR_2); m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = 1; + m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = true; AddSampleToRequestedQueue(); @@ -3601,10 +3613,10 @@ cAudioManager::ProcessDocksScriptObject(uint8 sound) m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_DOCKS_FOGHORN); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 3); - m_sQueueSample.m_counter = counter++; + m_sQueueSample.m_nCounter = counter++; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = 1; + m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_bEmittingVolume = rand; @@ -3645,7 +3657,7 @@ cAudioManager::ProcessEngineDamage(cVehicleParams *params) CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_bVolume = ComputeVolume(emittingVolume, engineDamageIntensity, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 28; + m_sQueueSample.m_nCounter = 28; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 0; @@ -3655,7 +3667,7 @@ cAudioManager::ProcessEngineDamage(cVehicleParams *params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = engineDamageIntensity; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; @@ -3798,11 +3810,11 @@ cAudioManager::ProcessExplosions(int32 explosion) m_sQueueSample.m_bVolume = ComputeVolume(maxVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = i; + m_sQueueSample.m_nCounter = i; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = 1; + m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bEmittingVolume = maxVolume; m_sQueueSample.m_nLoopStart = 0; @@ -3829,7 +3841,7 @@ cAudioManager::ProcessFireHydrant() CalculateDistance(distCalculated, distSquared); m_sQueueSample.m_bVolume = ComputeVolume(40, 35.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 0; + m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; @@ -3842,7 +3854,7 @@ cAudioManager::ProcessFireHydrant() m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_fSoundIntensity = intensity; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; @@ -3904,13 +3916,13 @@ void cAudioManager::ProcessFires(int32) m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = i; + m_sQueueSample.m_nCounter = i; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nReleasingVolumeDivider = 10; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_bEmittingVolume = emittingVol; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); @@ -4059,9 +4071,9 @@ cAudioManager::ProcessFrontEnd() SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); } m_sQueueSample.m_bVolume = 110; - m_sQueueSample.m_counter = counter++; + m_sQueueSample.m_nCounter = counter++; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = 1; + m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_bIs2D = true; @@ -4077,7 +4089,7 @@ cAudioManager::ProcessFrontEnd() AddSampleToRequestedQueue(); if(stereo) { ++m_sQueueSample.m_nSampleIndex; - m_sQueueSample.m_counter = counter++; + m_sQueueSample.m_nCounter = counter++; m_sQueueSample.m_bOffset = maxVolume - m_sQueueSample.m_bOffset; AddSampleToRequestedQueue(); } @@ -4096,48 +4108,53 @@ cAudioManager::ProcessGarages() static uint8 iSound = 32; -#define LOOP_HELPER \ - for(j = 0; j < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents; ++j) { \ - switch(m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[j]) { \ - case SOUND_GARAGE_DOOR_CLOSED: \ - case SOUND_GARAGE_DOOR_OPENED: \ - if(distSquared < 6400.f) { \ - CalculateDistance(distCalculated, distSquared); \ - m_sQueueSample.m_bVolume = ComputeVolume(60, 80.f, m_sQueueSample.m_fDistance); \ - if(m_sQueueSample.m_bVolume) { \ - if(CGarages::aGarages[i].m_eGarageType == GARAGE_CRUSHER) { \ - m_sQueueSample.m_nSampleIndex = SFX_COL_CAR_PANEL_2; \ - m_sQueueSample.m_nFrequency = 6735; \ - } else if(m_asAudioEntities[m_sQueueSample.m_nEntityIndex] \ - .m_awAudioEvent[j] == 69) { \ - m_sQueueSample.m_nSampleIndex = SFX_COL_CAR_PANEL_2; \ - m_sQueueSample.m_nFrequency = 22000; \ - } else { \ - m_sQueueSample.m_nSampleIndex = SFX_COL_GARAGE_DOOR_1; \ - m_sQueueSample.m_nFrequency = 18000; \ - } \ - m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; \ - m_sQueueSample.m_nReleasingVolumeModificator = 4; \ - m_sQueueSample.m_bEmittingVolume = 60; \ - m_sQueueSample.m_fSpeedMultiplier = 0.0f; \ - m_sQueueSample.m_fSoundIntensity = 80.0f; \ - /*m_sQueueSample.m_nReleasingVolumeModificator = 4;*/ \ - m_sQueueSample.m_bReverbFlag = true; \ - /*m_sQueueSample.m_bReverbFlag = true;*/ \ - m_sQueueSample.m_bIs2D = false; \ - m_sQueueSample.m_bReleasingSoundFlag = 1; \ - m_sQueueSample.m_nLoopCount = 1; \ - m_sQueueSample.m_nLoopStart = 0; \ - m_sQueueSample.m_nLoopEnd = -1; \ - m_sQueueSample.m_counter = iSound++; \ - if(iSound < 32) iSound = 32; \ - m_sQueueSample.m_bRequireReflection = true; \ - AddSampleToRequestedQueue(); \ - } \ - } \ - break; \ - default: continue; \ - } \ +#define LOOP_HELPER \ + for(j = 0; j < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents; ++j) { \ + switch(m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[j]) { \ + case SOUND_GARAGE_DOOR_CLOSED: \ + case SOUND_GARAGE_DOOR_OPENED: \ + if(distSquared < 6400.f) { \ + CalculateDistance(distCalculated, distSquared); \ + m_sQueueSample.m_bVolume = \ + ComputeVolume(60, 80.f, m_sQueueSample.m_fDistance); \ + if(m_sQueueSample.m_bVolume) { \ + if(CGarages::aGarages[i].m_eGarageType == \ + GARAGE_CRUSHER) { \ + m_sQueueSample.m_nSampleIndex = \ + SFX_COL_CAR_PANEL_2; \ + m_sQueueSample.m_nFrequency = 6735; \ + } else if(m_asAudioEntities[m_sQueueSample.m_nEntityIndex] \ + .m_awAudioEvent[j] == 69) { \ + m_sQueueSample.m_nSampleIndex = \ + SFX_COL_CAR_PANEL_2; \ + m_sQueueSample.m_nFrequency = 22000; \ + } else { \ + m_sQueueSample.m_nSampleIndex = \ + SFX_COL_GARAGE_DOOR_1; \ + m_sQueueSample.m_nFrequency = 18000; \ + } \ + m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; \ + m_sQueueSample.m_nReleasingVolumeModificator = 4; \ + m_sQueueSample.m_bEmittingVolume = 60; \ + m_sQueueSample.m_fSpeedMultiplier = 0.0f; \ + m_sQueueSample.m_fSoundIntensity = 80.0f; \ + /*m_sQueueSample.m_nReleasingVolumeModificator = 4;*/ \ + m_sQueueSample.m_bReverbFlag = true; \ + /*m_sQueueSample.m_bReverbFlag = true;*/ \ + m_sQueueSample.m_bIs2D = false; \ + m_sQueueSample.m_bReleasingSoundFlag = true; \ + m_sQueueSample.m_nLoopCount = 1; \ + m_sQueueSample.m_nLoopStart = 0; \ + m_sQueueSample.m_nLoopEnd = -1; \ + m_sQueueSample.m_nCounter = iSound++; \ + if(iSound < 32) iSound = 32; \ + m_sQueueSample.m_bRequireReflection = true; \ + AddSampleToRequestedQueue(); \ + } \ + } \ + break; \ + default: continue; \ + } \ } for(uint32 i = 0; i < CGarages::NumGarages; ++i) { @@ -4173,8 +4190,8 @@ cAudioManager::ProcessGarages() m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 4); m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = 1; - m_sQueueSample.m_counter = iSound++; + m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_nCounter = iSound++; if(iSound < 32) iSound = 32; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; @@ -4200,10 +4217,10 @@ cAudioManager::ProcessGarages() m_sQueueSample.m_nSampleIndex = SFX_GARAGE_DOOR_LOOP; m_sQueueSample.m_nFrequency = 13961; } - m_sQueueSample.m_counter = i; + m_sQueueSample.m_nCounter = i; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -4259,7 +4276,7 @@ cAudioManager::ProcessHelicopter(cVehicleParams *params) m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, gHeliSfxRanges[i].m_fMaxDistance, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = i + 65; + m_sQueueSample.m_nCounter = i + 65; m_sQueueSample.m_nSampleIndex = i + SFX_HELI_1; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; @@ -4273,7 +4290,7 @@ cAudioManager::ProcessHelicopter(cVehicleParams *params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; m_sQueueSample.m_fSoundIntensity = gHeliSfxRanges[i].m_fMaxDistance; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; @@ -4315,10 +4332,10 @@ cAudioManager::ProcessHomeScriptObject(uint8 sound) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); - m_sQueueSample.m_counter = counter++; + m_sQueueSample.m_nCounter = counter++; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = 1; + m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bEmittingVolume = rand; @@ -4461,10 +4478,10 @@ cAudioManager::ProcessLaunderetteScriptObject(uint8 sound) m_sQueueSample.m_nSampleIndex = SFX_LAUNDERETTE_LOOP; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_LAUNDERETTE_LOOP); - m_sQueueSample.m_counter = 0; + m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeModificator = 5; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_bEmittingVolume = 45; @@ -4481,10 +4498,10 @@ cAudioManager::ProcessLaunderetteScriptObject(uint8 sound) m_sQueueSample.m_nSampleIndex = SFX_LAUNDERETTE_SONG_LOOP; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_LAUNDERETTE_SONG_LOOP); - m_sQueueSample.m_counter = 1; + m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_bEmittingVolume = 110; @@ -5072,10 +5089,10 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) m_sQueueSample.m_bVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 0; + m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bEmittingVolume = emittingVolume; m_sQueueSample.m_nLoopStart = @@ -5140,12 +5157,12 @@ cAudioManager::ProcessMissionAudio() --nCheckPlayingDelay; } else if(GetMissionScriptPoliceAudioPlayingStatus() == PLAY_STATUS_FINISHED || - m_sMissionAudio.field_24-- == 0) { + m_sMissionAudio.m_nMissionAudioCounter-- == 0) { m_sMissionAudio.m_bPlayStatus = PLAY_STATUS_FINISHED; m_sMissionAudio.m_nSampleIndex = NO_SAMPLE; SampleManager.StopStreamedFile(1); - m_sMissionAudio.field_24 = 0; + m_sMissionAudio.m_nMissionAudioCounter = 0; } } } else if(m_sMissionAudio.field_22) { @@ -5159,7 +5176,7 @@ cAudioManager::ProcessMissionAudio() m_sMissionAudio.m_bPlayStatus = PLAY_STATUS_FINISHED; m_sMissionAudio.m_nSampleIndex = NO_SAMPLE; SampleManager.StopStreamedFile(1); - m_sMissionAudio.field_24 = 0; + m_sMissionAudio.m_nMissionAudioCounter = 0; } } else { if(m_bUserPause) return; @@ -5175,7 +5192,7 @@ cAudioManager::ProcessMissionAudio() SetMissionScriptPoliceAudio(m_sMissionAudio.m_nSampleIndex); } else { if(m_bUserPause) SampleManager.PauseStream(1, 1); - if(m_sMissionAudio.field_12) { + if(m_sMissionAudio.m_bPredefinedProperties) { SampleManager.SetStreamedVolumeAndPan(80, 63, 1, 1); } else { distSquared = @@ -5243,7 +5260,7 @@ cAudioManager::ProcessModelCarEngine(cVehicleParams *params) m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 30.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 2; + m_sQueueSample.m_nCounter = 2; m_sQueueSample.m_nSampleIndex = SFX_REMOTE_CONTROLLED_CAR; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; @@ -5259,7 +5276,7 @@ cAudioManager::ProcessModelCarEngine(cVehicleParams *params) SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 3.0f; m_sQueueSample.m_fSoundIntensity = 30.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; @@ -5463,9 +5480,9 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) ComputeVolume(emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = iSound++; + m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = 1; + m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_bEmittingVolume = emittingVolume; m_sQueueSample.m_nLoopStart = 0; m_sQueueSample.m_nLoopEnd = -1; @@ -5506,9 +5523,9 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_bVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = iSound++; + m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = 1; + m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_bEmittingVolume = emittingVolume; m_sQueueSample.m_nLoopStart = 0; m_sQueueSample.m_nLoopEnd = -1; @@ -5564,7 +5581,7 @@ cAudioManager::ProcessPedHeadphones(cPedParams *params) m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 7.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 64; + m_sQueueSample.m_nCounter = 64; m_sQueueSample.m_nSampleIndex = SFX_HEADPHONES; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; @@ -5579,7 +5596,7 @@ cAudioManager::ProcessPedHeadphones(cPedParams *params) SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = 7.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 5; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; @@ -6795,10 +6812,10 @@ cAudioManager::ProcessPoliceCellBeatingScriptObject(uint8 sound) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); - m_sQueueSample.m_counter = counter++; + m_sQueueSample.m_nCounter = counter++; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = 1; + m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_bEmittingVolume = emittingVol; @@ -6876,10 +6893,10 @@ cAudioManager::ProcessPornCinema(uint8 sound) if(m_sQueueSample.m_bVolume) { m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_counter = 0; + m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_bEmittingVolume = maxVolume; @@ -6903,10 +6920,10 @@ cAudioManager::ProcessPornCinema(uint8 sound) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency >> 4); - m_sQueueSample.m_counter = rand + 1; + m_sQueueSample.m_nCounter = rand + 1; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = 1; + m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_nReleasingVolumeModificator = 6; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_nLoopStart = 0; @@ -6957,7 +6974,7 @@ cAudioManager::ProcessProjectiles() m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = i; + m_sQueueSample.m_nCounter = i; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_bEmittingVolume = emittingVol; @@ -6965,7 +6982,7 @@ cAudioManager::ProcessProjectiles() SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); @@ -6992,7 +7009,7 @@ cAudioManager::ProcessRainOnVehicle(cVehicleParams *params) m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, rainOnVehicleIntensity, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = veh->m_bRainSamplesCounter++; + m_sQueueSample.m_nCounter = veh->m_bRainSamplesCounter++; veh = params->m_pVehicle; if(veh->m_bRainSamplesCounter > 4) veh->m_bRainSamplesCounter = 68; m_sQueueSample.m_nSampleIndex = (m_anRandomTable[1] & 3) + SFX_CAR_RAIN_1; @@ -7006,7 +7023,7 @@ cAudioManager::ProcessRainOnVehicle(cVehicleParams *params) m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_fSpeedMultiplier = 0.0f; m_sQueueSample.m_fSoundIntensity = rainOnVehicleIntensity; - m_sQueueSample.m_bReleasingSoundFlag = 1; + m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_bReverbFlag = false; m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); @@ -7019,8 +7036,16 @@ void cAudioManager::ProcessReverb() const { if(SampleManager.UpdateReverb() && m_bDynamicAcousticModelingStatus) { - for(uint32 i = 0; i < channels; i++) { // bug? - if(m_asActiveSamples[i].m_bReverbFlag) SampleManager.SetChannelReverbFlag(i, 1); + for(uint32 i = 0; i < +#ifdef FIX_BUGS + channels +#else + 28 +#endif + ; + i++) { + if(m_asActiveSamples[i].m_bReverbFlag) + SampleManager.SetChannelReverbFlag(i, 1); } } } @@ -7050,10 +7075,10 @@ cAudioManager::ProcessReverseGear(cVehicleParams *params) m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, reverseGearIntensity, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { if(params->m_pVehicle->m_fGasPedal >= 0.0f) { - m_sQueueSample.m_counter = 62; + m_sQueueSample.m_nCounter = 62; m_sQueueSample.m_nSampleIndex = SFX_REVERSE_GEAR_2; } else { - m_sQueueSample.m_counter = 61; + m_sQueueSample.m_nCounter = 61; m_sQueueSample.m_nSampleIndex = SFX_REVERSE_GEAR; } m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; @@ -7067,7 +7092,7 @@ cAudioManager::ProcessReverseGear(cVehicleParams *params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 3.0f; m_sQueueSample.m_fSoundIntensity = reverseGearIntensity; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 5; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; @@ -7099,10 +7124,10 @@ cAudioManager::ProcessSawMillScriptObject(uint8 sound) m_sQueueSample.m_nSampleIndex = SFX_SAWMILL_LOOP; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SAWMILL_LOOP); - m_sQueueSample.m_counter = 0; + m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeModificator = 5; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_bEmittingVolume = 30; @@ -7122,10 +7147,10 @@ cAudioManager::ProcessSawMillScriptObject(uint8 sound) m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_counter = 1; + m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = 1; + m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nLoopStart = 0; @@ -7175,10 +7200,10 @@ cAudioManager::ProcessShopScriptObject(uint8 sound) m_sQueueSample.m_nSampleIndex = SFX_SHOP_LOOP; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SHOP_LOOP); - m_sQueueSample.m_counter = 0; + m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeModificator = 5; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_bEmittingVolume = 30; @@ -7199,10 +7224,10 @@ cAudioManager::ProcessShopScriptObject(uint8 sound) m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_counter = rand + 1; + m_sQueueSample.m_nCounter = rand + 1; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = 1; + m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_bEmittingVolume = 70; @@ -7257,7 +7282,7 @@ cAudioManager::ProcessTrainNoise(cVehicleParams *params) if(train->m_fWagonPosition == 0.0f) { m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 300.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 32; + m_sQueueSample.m_nCounter = 32; m_sQueueSample.m_nSampleIndex = SFX_TRAIN_FAR; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; @@ -7272,7 +7297,7 @@ cAudioManager::ProcessTrainNoise(cVehicleParams *params) SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 3.0f; m_sQueueSample.m_fSoundIntensity = 300.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; @@ -7282,7 +7307,7 @@ cAudioManager::ProcessTrainNoise(cVehicleParams *params) if(params->m_fDistance < 4900.f) { m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 70.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 33; + m_sQueueSample.m_nCounter = 33; m_sQueueSample.m_nSampleIndex = SFX_TRAIN_NEAR; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; @@ -7296,7 +7321,7 @@ cAudioManager::ProcessTrainNoise(cVehicleParams *params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; m_sQueueSample.m_fSoundIntensity = 70.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; @@ -7419,7 +7444,7 @@ cAudioManager::ProcessVehicleDoors(cVehicleParams *params) m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 40.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = i + 6; + m_sQueueSample.m_nCounter = i + 6; m_sQueueSample.m_nSampleIndex = m_anRandomTable[1] % 6 + SFX_COL_CAR_PANEL_1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency( @@ -7434,7 +7459,7 @@ cAudioManager::ProcessVehicleDoors(cVehicleParams *params) m_sQueueSample.m_nLoopEnd = -1; m_sQueueSample.m_fSpeedMultiplier = 1.0f; m_sQueueSample.m_fSoundIntensity = 40.0f; - m_sQueueSample.m_bReleasingSoundFlag = 1; + m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = true; AddSampleToRequestedQueue(); @@ -7580,7 +7605,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams* params) m_sQueueSample.m_nSampleIndex = CarSounds[params->m_nIndex].m_bEngineSoundType + SFX_CAR_REV_10; freq = 10000.f * modificator + 22050; - m_sQueueSample.m_counter = 52; + m_sQueueSample.m_nCounter = 52; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_bIs2D = 0; m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7597,7 +7622,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams* params) SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; m_sQueueSample.m_fSoundIntensity = 50.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 8; m_sQueueSample.m_bReverbFlag = 1; m_sQueueSample.m_bRequireReflection = 0; @@ -7612,7 +7637,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams* params) CarSounds[params->m_nIndex].m_bEngineSoundType + SFX_CAR_REV_10; // to recheck idle sounds start 1 postion later freq = 10000.f * modificator + 22050; - m_sQueueSample.m_counter = 52; + m_sQueueSample.m_nCounter = 52; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_bIs2D = 0; m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7629,7 +7654,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams* params) SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; m_sQueueSample.m_fSoundIntensity = 50.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 8; m_sQueueSample.m_bReverbFlag = 1; m_sQueueSample.m_bRequireReflection = 0; @@ -7639,7 +7664,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams* params) accelerationSample = CarSounds[params->m_nIndex].m_nAccelerationSampleIndex; } m_sQueueSample.m_nSampleIndex = accelerationSample; - m_sQueueSample.m_counter = 2; + m_sQueueSample.m_nCounter = 2; m_sQueueSample.m_bBankIndex = 0; m_sQueueSample.m_bIs2D = 0; m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7655,7 +7680,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams* params) SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; m_sQueueSample.m_fSoundIntensity = 50.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 8; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; @@ -7687,7 +7712,7 @@ cAudioManager::ProcessVehicleHorn(cVehicleParams *params) CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_bVolume = ComputeVolume(80, 40.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 4; + m_sQueueSample.m_nCounter = 4; m_sQueueSample.m_nSampleIndex = CarSounds[params->m_nIndex].m_nHornSample; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; @@ -7701,7 +7726,7 @@ cAudioManager::ProcessVehicleHorn(cVehicleParams *params) SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 5.0f; m_sQueueSample.m_fSoundIntensity = 40.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; @@ -7730,7 +7755,7 @@ cAudioManager::ProcessVehicleReverseWarning(cVehicleParams *params) CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_bVolume = ComputeVolume(60, 50.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 12; + m_sQueueSample.m_nCounter = 12; m_sQueueSample.m_nSampleIndex = SFX_REVERSE_WARNING; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; @@ -7745,7 +7770,7 @@ cAudioManager::ProcessVehicleReverseWarning(cVehicleParams *params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 3.0f; m_sQueueSample.m_fSoundIntensity = 50.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; @@ -7774,7 +7799,7 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params) 30.f * min(1.f, velocity / (0.5f * params->m_pTransmission->fMaxVelocity)); m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 95.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 0; + m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7797,7 +7822,7 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params) SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; m_sQueueSample.m_fSoundIntensity = 95.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 4; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; @@ -7819,7 +7844,7 @@ cAudioManager::ProcessVehicleSirenOrAlarm(cVehicleParams *params) CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_bVolume = ComputeVolume(80, 110.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 5; + m_sQueueSample.m_nCounter = 5; if(UsesSiren(params->m_nIndex)) { if(params->m_pVehicle->m_status == STATUS_ABANDONED) return; if(veh->m_nCarHornTimer && params->m_nIndex != FIRETRUK) { @@ -7829,7 +7854,7 @@ cAudioManager::ProcessVehicleSirenOrAlarm(cVehicleParams *params) else m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SIREN_FAST); - m_sQueueSample.m_counter = 60; + m_sQueueSample.m_nCounter = 60; } else { m_sQueueSample.m_nSampleIndex = CarSounds[params->m_nIndex].m_nSirenOrAlarmSample; @@ -7850,7 +7875,7 @@ cAudioManager::ProcessVehicleSirenOrAlarm(cVehicleParams *params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 7.0f; m_sQueueSample.m_fSoundIntensity = 110.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 5; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; @@ -7913,7 +7938,7 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams *params) emittingVol = 50.f * skidVal; m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 40.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 3; + m_sQueueSample.m_nCounter = 3; switch(params->m_pVehicle->m_nSurfaceTouched) { case SURFACE_GRASS: case SURFACE_HEDGE: @@ -7946,7 +7971,7 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams *params) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 3.0f; m_sQueueSample.m_fSoundIntensity = 40.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 3; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; @@ -7971,12 +7996,12 @@ void cAudioManager::ProcessWaterCannon(int32) m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_nFrequency = 15591; m_sQueueSample.m_nReleasingVolumeModificator = 5; - m_sQueueSample.m_counter = i; + m_sQueueSample.m_nCounter = i; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_nReleasingVolumeDivider = 8; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_bEmittingVolume = 50; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); @@ -8012,12 +8037,12 @@ cAudioManager::ProcessWeather(int32 id) m_sQueueSample.m_bVolume = vol; if(TheCamera.SoundDistUp < 20.f) m_sQueueSample.m_bVolume >>= 1; if(counter == 4) counter = 0; - m_sQueueSample.m_counter = counter++; + m_sQueueSample.m_nCounter = counter++; m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_bOffset = (m_anRandomTable[2] & 15) + 55; m_sQueueSample.m_bIs2D = true; m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = 1; + m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_bEmittingVolume = m_sQueueSample.m_bVolume; m_sQueueSample.m_nLoopStart = 0; m_sQueueSample.m_nLoopEnd = -1; @@ -8030,13 +8055,13 @@ cAudioManager::ProcessWeather(int32 id) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RAIN); m_sQueueSample.m_bVolume = (int32)(25.f * CWeather::Rain); - m_sQueueSample.m_counter = 4; + m_sQueueSample.m_nCounter = 4; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_bOffset = 63; m_sQueueSample.m_bIs2D = true; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 30; m_sQueueSample.m_bReverbFlag = false; m_sQueueSample.m_bEmittingVolume = m_sQueueSample.m_bVolume; @@ -8067,7 +8092,7 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams *params) emittingVol = 23.0f * relativeVelocity * CWeather::WetRoads; m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 30.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 1; + m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_nSampleIndex = SFX_ROAD_NOISE; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; @@ -8083,7 +8108,7 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams *params) SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 6.0f; m_sQueueSample.m_fSoundIntensity = 30.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 4; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; @@ -8116,10 +8141,10 @@ cAudioManager::ProcessWorkShopScriptObject(uint8 sound) m_sQueueSample.m_nSampleIndex = SFX_WORKSHOP_1; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_WORKSHOP_1); - m_sQueueSample.m_counter = 0; + m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeModificator = 5; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_bEmittingVolume = 30; @@ -8325,7 +8350,7 @@ void cAudioManager::SetMissionAudioLocation(float x, float y, float z) { if(m_bIsInitialised) { - m_sMissionAudio.field_12 = 0; + m_sMissionAudio.m_bPredefinedProperties = 0; m_sMissionAudio.m_vecPos = {x, y, z}; } } @@ -8356,7 +8381,7 @@ cAudioManager::SetupJumboEngineSound(uint8 vol, int32 freq) uint8 emittingVol = vol - gJumboVolOffsetPercentage / 100; m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 180.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 3; + m_sQueueSample.m_nCounter = 3; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_ENGINE; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; @@ -8368,7 +8393,7 @@ cAudioManager::SetupJumboEngineSound(uint8 vol, int32 freq) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = 180.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 4; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; @@ -8386,7 +8411,7 @@ cAudioManager::SetupJumboFlySound(uint8 emittingVol) m_sQueueSample.m_bVolume = vol; if(m_sQueueSample.m_bVolume) { m_sQueueSample.m_nSampleIndex = SFX_JUMBO_DIST_FLY; - m_sQueueSample.m_counter = 0; + m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; @@ -8395,7 +8420,7 @@ cAudioManager::SetupJumboFlySound(uint8 emittingVol) m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_JUMBO_DIST_FLY); m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSoundIntensity = 440.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_nReleasingVolumeDivider = 5; @@ -8413,7 +8438,7 @@ cAudioManager::SetupJumboRumbleSound(uint8 emittingVol) m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 240.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 5; + m_sQueueSample.m_nCounter = 5; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_RUMBLE; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = true; @@ -8425,13 +8450,13 @@ cAudioManager::SetupJumboRumbleSound(uint8 emittingVol) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = 240.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 12; m_sQueueSample.m_bOffset = 0; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); - m_sQueueSample.m_counter = 6; + m_sQueueSample.m_nCounter = 6; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_RUMBLE; m_sQueueSample.m_nFrequency += 200; m_sQueueSample.m_bOffset = maxVolume; @@ -8451,7 +8476,7 @@ cAudioManager::SetupJumboTaxiSound(uint8 vol) m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 180.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 1; + m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; @@ -8463,7 +8488,7 @@ cAudioManager::SetupJumboTaxiSound(uint8 vol) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = 180.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 4; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; @@ -8480,7 +8505,7 @@ cAudioManager::SetupJumboWhineSound(uint8 emittingVol, int32 freq) m_sQueueSample.m_bVolume = ComputeVolume(emittingVol, 170.f, m_sQueueSample.m_fDistance); if(m_sQueueSample.m_bVolume) { - m_sQueueSample.m_counter = 2; + m_sQueueSample.m_nCounter = 2; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_WHINE; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; @@ -8492,7 +8517,7 @@ cAudioManager::SetupJumboWhineSound(uint8 emittingVol, int32 freq) m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 4.0f; m_sQueueSample.m_fSoundIntensity = 170.0f; - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_nReleasingVolumeDivider = 4; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 910ffcaf..c5350e10 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -138,7 +138,7 @@ class tSound { public: int32 m_nEntityIndex; - int32 m_counter; + int32 m_nCounter; int32 m_nSampleIndex; uint8 m_bBankIndex; bool m_bIs2D; @@ -170,8 +170,8 @@ public: bool m_bRequireReflection; // Used for oneshots uint8 m_bOffset; int32 m_nReleasingVolumeDivider; - uint8 m_bIsProcessed; - uint8 m_bLoopEnded; + bool m_bIsProcessed; + bool m_bLoopEnded; uint8 field_82; uint8 field_83; int32 calculatedVolume; @@ -244,14 +244,14 @@ class cMissionAudio { public: CVector m_vecPos; - uint8 field_12; + bool m_bPredefinedProperties; uint8 gap_13[3]; int m_nSampleIndex; uint8 m_bLoadingStatus; uint8 m_bPlayStatus; uint8 field_22; uint8 field_23; - int field_24; + int32 m_nMissionAudioCounter; bool m_bIsPlayed; uint8 field_29; uint8 field_30; @@ -328,7 +328,7 @@ public: int32 m_nBridgeEntity; cMissionAudio m_sMissionAudio; int32 m_anRandomTable[5]; - uint8 field_19192; // time? + uint8 m_bTimeSpent; uint8 m_bUserPause; uint8 m_bPreviousUserPause; uint8 field_19195; // unused diff --git a/src/audio/PoliceRadio.cpp b/src/audio/PoliceRadio.cpp index 3ba16ef3..255d7026 100644 --- a/src/audio/PoliceRadio.cpp +++ b/src/audio/PoliceRadio.cpp @@ -125,7 +125,7 @@ void cAudioManager::DoPoliceRadioCrackle() { m_sQueueSample.m_nEntityIndex = m_nPoliceChannelEntity; - m_sQueueSample.m_counter = 0; + m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nSampleIndex = SFX_POLICE_RADIO_CRACKLE; m_sQueueSample.m_bBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = true; @@ -136,7 +136,7 @@ cAudioManager::DoPoliceRadioCrackle() m_sQueueSample.m_bEmittingVolume = m_sQueueSample.m_bVolume; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_POLICE_RADIO_CRACKLE); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_POLICE_RADIO_CRACKLE); - m_sQueueSample.m_bReleasingSoundFlag = 0; + m_sQueueSample.m_bReleasingSoundFlag = false; m_sQueueSample.m_bReverbFlag = false; m_sQueueSample.m_bOffset = 63; m_sQueueSample.m_nReleasingVolumeDivider = 3; @@ -147,17 +147,20 @@ cAudioManager::DoPoliceRadioCrackle() void cAudioManager::ServicePoliceRadio() { - int32 wantedLevel = 0; // bug?; + int32 wantedLevel = 0; // uninitialized variable static uint32 nLastSeen = 300; - if (!m_bIsInitialised) return; + if(!m_bIsInitialised) return; - if (!m_bUserPause) { + if(!m_bUserPause) { bool crimeReport = SetupCrimeReport(); +#ifdef FIX_BUGS // Crash at 0x5fe6ef + if(!FindPlayerPed() || !FindPlayerPed()->m_pWanted) return; +#endif wantedLevel = FindPlayerPed()->m_pWanted->m_nWantedLevel; - if (!crimeReport) { - if (wantedLevel) { - if (nLastSeen) { + if(!crimeReport) { + if(wantedLevel) { + if(nLastSeen) { --nLastSeen; } else { nLastSeen = m_anRandomTable[1] % 1000 + 2000; -- cgit v1.2.3 From 9593a2c000c8fed4a83e26995acdba27074d5f5a Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sun, 12 Apr 2020 11:36:51 +0300 Subject: fixed cranes bug --- src/control/Cranes.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/control/Cranes.cpp b/src/control/Cranes.cpp index 021a5c19..33385dae 100644 --- a/src/control/Cranes.cpp +++ b/src/control/Cranes.cpp @@ -410,6 +410,8 @@ void CCrane::FindCarInSectorList(CPtrList* pList) if (pVehicle->GetPosition().x < m_fPickupX1 || pVehicle->GetPosition().x > m_fPickupX2 || pVehicle->GetPosition().y < m_fPickupY1 || pVehicle->GetPosition().y > m_fPickupY2) continue; + if (pVehicle->pDriver) + continue; if (Abs(pVehicle->GetMoveSpeed().x) >= CAR_MOVING_SPEED_THRESHOLD || Abs(pVehicle->GetMoveSpeed().y) >= CAR_MOVING_SPEED_THRESHOLD || Abs(pVehicle->GetMoveSpeed().z) >= CAR_MOVING_SPEED_THRESHOLD) @@ -674,4 +676,4 @@ void CranesLoad(uint8* buf, uint32 size) STARTPATCHES InjectHook(0x5454D0, CranesLoad, PATCH_JUMP); // GenericLoad -ENDPATCHES \ No newline at end of file +ENDPATCHES -- cgit v1.2.3 From 1732f9b5c66ed661e4874de7c32212274b0b1ec0 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sun, 12 Apr 2020 12:10:25 +0300 Subject: obviously forgot about it --- src/core/Pad.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index 973b4ef6..f83998b8 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -94,7 +94,7 @@ void TankCheat() if (node < 0) return; -#ifndef FIX_BUGS // TEMP!!! +#ifdef FIX_BUGS CAutomobile* tank = new CAutomobile(MI_RHINO, RANDOM_VEHICLE); #else CAutomobile *tank = new CAutomobile(MI_RHINO, MISSION_VEHICLE); -- cgit v1.2.3