From 1f36b78c205202b605797e6e29ba045124066705 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 17 Oct 2020 13:48:08 +0300 Subject: [PATCH 01/60] Pickup fixes --- src/control/Pickups.cpp | 13 ++++++------- src/math/Vector.h | 8 ++++++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp index 9215b57e..83b31f6b 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -628,7 +628,7 @@ CPickups::Update() #ifdef CAMERA_PICKUP if ( bPickUpcamActivated ) // taken from PS2 { - float dist = (FindPlayerCoors() - StaticCamCoors).Magnitude2D(); + float dist = Distance2D(StaticCamCoors, FindPlayerCoors()); float mult; if ( dist < 10.0f ) mult = 1.0f - (dist / 10.0f ); @@ -644,8 +644,7 @@ CPickups::Update() TheCamera.TakeControl(FindPlayerVehicle(), CCam::MODE_FIXED, JUMP_CUT, CAMCONTROL_SCRIPT); } - if ( FindPlayerVehicle() != pPlayerVehicle - || (FindPlayerCoors() - StaticCamCoors).Magnitude() > 40.0f + if ( FindPlayerVehicle() != pPlayerVehicle || Distance(StaticCamCoors, FindPlayerCoors()) > 40.0f || ((CTimer::GetTimeInMilliseconds() - StaticCamStartTime) > 60000) ) { TheCamera.RestoreWithJumpCut(); @@ -715,7 +714,7 @@ CPickups::DoPickUpEffects(CEntity *entity) CObject *object = (CObject*)entity; if (object->bPickupObjWithMessage || object->bOutOfStock || object->m_nBonusValue) { - float dist = (TheCamera.GetPosition() - pos).Magnitude(); + float dist = Distance2D(pos, TheCamera.GetPosition()); const float MAXDIST = 12.0f; if (dist < MAXDIST && NumMessages < NUMPICKUPMESSAGES) { @@ -746,7 +745,7 @@ void CPickups::DoMineEffects(CEntity *entity) { const CVector &pos = entity->GetPosition(); - float dist = (TheCamera.GetPosition() - pos).Magnitude(); + float dist = Distance2D(pos, TheCamera.GetPosition()); const float MAXDIST = 20.0f; if (dist < MAXDIST) { @@ -765,7 +764,7 @@ void CPickups::DoMoneyEffects(CEntity *entity) { const CVector &pos = entity->GetPosition(); - float dist = (TheCamera.GetPosition() - pos).Magnitude(); + float dist = Distance2D(pos, TheCamera.GetPosition()); const float MAXDIST = 20.0f; if (dist < MAXDIST) { @@ -784,7 +783,7 @@ void CPickups::DoCollectableEffects(CEntity *entity) { const CVector &pos = entity->GetPosition(); - float dist = (TheCamera.GetPosition() - pos).Magnitude(); + float dist = Distance2D(pos, TheCamera.GetPosition()); const float MAXDIST = 14.0f; if (dist < MAXDIST) { diff --git a/src/math/Vector.h b/src/math/Vector.h index 7ee01149..badc40e3 100644 --- a/src/math/Vector.h +++ b/src/math/Vector.h @@ -115,6 +115,14 @@ Distance(const CVector &v1, const CVector &v2) return (v2 - v1).Magnitude(); } +inline float +Distance2D(const CVector &v1, const CVector &v2) +{ + float x = v2.x - v1.x; + float y = v2.y - v1.y; + return Sqrt(sq(x) + sq(y)); +} + class CMatrix; CVector Multiply3x3(const CMatrix &mat, const CVector &vec); From ca64a49af11c8d3cca79587641e5ad464cb276f3 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 17 Oct 2020 14:23:31 +0300 Subject: [PATCH 02/60] fix build --- src/math/Vector.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/math/Vector.h b/src/math/Vector.h index badc40e3..082b296f 100644 --- a/src/math/Vector.h +++ b/src/math/Vector.h @@ -120,7 +120,7 @@ Distance2D(const CVector &v1, const CVector &v2) { float x = v2.x - v1.x; float y = v2.y - v1.y; - return Sqrt(sq(x) + sq(y)); + return Sqrt(x*x + y*y); } class CMatrix; From 516a02d2da990317fd59f5620487a289b373fe88 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 17 Oct 2020 15:33:22 +0300 Subject: [PATCH 03/60] Fix pickup fix :P --- src/control/Pickups.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp index 83b31f6b..78084624 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -745,7 +745,7 @@ void CPickups::DoMineEffects(CEntity *entity) { const CVector &pos = entity->GetPosition(); - float dist = Distance2D(pos, TheCamera.GetPosition()); + float dist = Distance(pos, TheCamera.GetPosition()); const float MAXDIST = 20.0f; if (dist < MAXDIST) { @@ -764,7 +764,7 @@ void CPickups::DoMoneyEffects(CEntity *entity) { const CVector &pos = entity->GetPosition(); - float dist = Distance2D(pos, TheCamera.GetPosition()); + float dist = Distance(pos, TheCamera.GetPosition()); const float MAXDIST = 20.0f; if (dist < MAXDIST) { @@ -783,7 +783,7 @@ void CPickups::DoCollectableEffects(CEntity *entity) { const CVector &pos = entity->GetPosition(); - float dist = Distance2D(pos, TheCamera.GetPosition()); + float dist = Distance(pos, TheCamera.GetPosition()); const float MAXDIST = 14.0f; if (dist < MAXDIST) { From b84dc2bc9b972eed6a76d86ed14b50a6ed3d7808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Sat, 17 Oct 2020 18:07:20 +0300 Subject: [PATCH 04/60] Fix management issue --- src/skel/glfw/glfw.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 118ed950..cdb73992 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -847,7 +847,8 @@ bool IsThisJoystickBlacklisted(int i) const char* joyname = glfwGetJoystickName(i); - if (strncmp(joyname, gSelectedJoystickName, strlen(gSelectedJoystickName)) == 0) + if (gSelectedJoystickName[0] != '\0' && + strncmp(joyname, gSelectedJoystickName, strlen(gSelectedJoystickName)) == 0) return false; return true; From 9cf38634b9ae5751bcec1ceb0ad5a6feaf9c6f98 Mon Sep 17 00:00:00 2001 From: Roman Masanin <52833910+theR4K@users.noreply.github.com> Date: Sat, 17 Oct 2020 21:56:42 +0300 Subject: [PATCH 05/60] ProcessWaterCannon bug and refractoring (#773) * fix audio bug and some refractoring * mark original bugs --- src/audio/AudioLogic.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 174bd5fa..5d72f099 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -813,7 +813,7 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params) int32 emittingVol; uint32 freq; - float modificator; + float multiplier; int sampleFreq; float velocity; @@ -836,9 +836,9 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params) freq = 6050 * emittingVol / 30 + 16000; } else { m_sQueueSample.m_nSampleIndex = SFX_ROAD_NOISE; - modificator = m_sQueueSample.m_fDistance / 190.f; + multiplier = (m_sQueueSample.m_fDistance / SOUND_INTENSITY) * 0.5f; sampleFreq = SampleManager.GetSampleBaseFrequency(SFX_ROAD_NOISE); - freq = (sampleFreq * modificator) + ((3 * sampleFreq) / 4); + freq = (sampleFreq * multiplier) + ((3 * sampleFreq) / 4); } m_sQueueSample.m_nFrequency = freq; m_sQueueSample.m_nLoopCount = 0; @@ -866,7 +866,7 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams *params) float relativeVelocity; int32 emittingVol; - float modificator; + float multiplier; int freq; float velChange; @@ -886,9 +886,13 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams *params) m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; - modificator = m_sQueueSample.m_fDistance / 6.f; +#ifdef FIX_BUGS + multiplier = (m_sQueueSample.m_fDistance / SOUND_INTENSITY) * 0.5f; +#else + multiplier = (m_sQueueSample.m_fDistance / 3.0f) * 0.5f; +#endif freq = SampleManager.GetSampleBaseFrequency(SFX_ROAD_NOISE); - m_sQueueSample.m_nFrequency = freq + freq * modificator; + m_sQueueSample.m_nFrequency = freq + freq * multiplier; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); @@ -6488,17 +6492,25 @@ cAudioManager::ProcessFires(int32) void cAudioManager::ProcessWaterCannon(int32) { - const float SOUND_INTENSITY = 900.0f; + const float SOUND_INTENSITY = 30.0f; for (int32 i = 0; i < NUM_WATERCANNONS; i++) { if (CWaterCannons::aCannons[i].m_nId) { m_sQueueSample.m_vecPos = CWaterCannons::aCannons[0].m_avecPos[CWaterCannons::aCannons[i].m_nCur]; float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); - if (distSquared < SOUND_INTENSITY) { + if (distSquared < SQR(SOUND_INTENSITY)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); +#ifdef FIX_BUGS + m_sQueueSample.m_nVolume = ComputeVolume(50, SOUND_INTENSITY, m_sQueueSample.m_fDistance); +#else m_sQueueSample.m_nVolume = ComputeVolume(50, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); +#endif if (m_sQueueSample.m_nVolume != 0) { +#ifdef FIX_BUGS m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; +#else + m_sQueueSample.m_fSoundIntensity = SQR(SOUND_INTENSITY); +#endif m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI; m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nFrequency = 15591; From 82f54b946fa37f9c92be2a2f2883f8f37655f3ed Mon Sep 17 00:00:00 2001 From: shfil Date: Sun, 18 Oct 2020 00:54:27 +0200 Subject: [PATCH 06/60] Script.cpp missing breaks --- src/control/Script.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/control/Script.cpp b/src/control/Script.cpp index 650e11a7..5dceacb7 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -2002,9 +2002,11 @@ void CTheScripts::Process() case 4: AllowMissionReplay = 5; RetryMission(0, 0); + break; case 6: AllowMissionReplay = 7; TimeToWaitTill = CTimer::GetTimeInMilliseconds() + 500; + break; case 7: if (TimeToWaitTill < CTimer::GetTimeInMilliseconds()) { AllowMissionReplay = 0; From 3594b35fbb02a7eae9bd9f7d2aebe4af4e52c3a7 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Sun, 18 Oct 2020 15:13:43 +0200 Subject: [PATCH 07/60] Add missing breaks in AudioLogic.cpp --- src/audio/AudioLogic.cpp | 75 ++++++++++++---------------------------- 1 file changed, 23 insertions(+), 52 deletions(-) diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 174bd5fa..d0e426ab 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -1,4 +1,4 @@ -#include "common.h" +#include "common.h" #include "AudioManager.h" #include "audio_enums.h" @@ -4103,14 +4103,13 @@ cAudioManager::GetArmyTalkSfx(int16 sound) PedState pedState; static uint32 lastSfx = NO_SAMPLE; - switch (sound) { + switch(sound) { case SOUND_PED_PURSUIT_ARMY: pedState = FindPlayerPed()->m_nPedState; - if (pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE) - return NO_SAMPLE; + if(pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE) return NO_SAMPLE; GetPhrase(&sfx, &lastSfx, SFX_ARMY_VOICE_1_CHASE_1, 15); - default: - return GetGenericMaleTalkSfx(sound); + break; + default: return GetGenericMaleTalkSfx(sound); } return (SFX_ARMY_VOICE_2_CHASE_1 - SFX_ARMY_VOICE_1_CHASE_1) * (m_sQueueSample.m_nEntityIndex % 2) + sfx; @@ -4598,32 +4597,16 @@ cAudioManager::GetBlackProjectMaleTalkSfx(int16 sound, int32 model) uint32 sfx; static uint32 lastSfx = NO_SAMPLE; - switch (sound) { - case SOUND_PED_HANDS_UP: - GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_GUN_COOL_1, 3); - break; - case SOUND_PED_CAR_JACKED: - GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_CARJACKED_1, 2); - break; - case SOUND_PED_ROBBED: - GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_MUGGED_1, 2); - break; - case SOUND_PED_ATTACK: - GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_FIGHT_1, 6); - break; - case SOUND_PED_EVADE: - GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_DODGE_1, 5); - break; - case SOUND_PED_ANNOYED_DRIVER: - GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_DRIVER_ABUSE_1, 7); - break; - case SOUND_PED_CHAT_SEXY: - GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_EYING_1, 3); - break; - case SOUND_PED_CHAT: - GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_CHAT_1, 6); - default: - return GetGenericMaleTalkSfx(sound); + switch(sound) { + case SOUND_PED_HANDS_UP: GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_GUN_COOL_1, 3); break; + case SOUND_PED_CAR_JACKED: GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_CARJACKED_1, 2); break; + case SOUND_PED_ROBBED: GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_MUGGED_1, 2); break; + case SOUND_PED_ATTACK: GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_FIGHT_1, 6); break; + case SOUND_PED_EVADE: GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_DODGE_1, 5); break; + case SOUND_PED_ANNOYED_DRIVER: GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_DRIVER_ABUSE_1, 7); break; + case SOUND_PED_CHAT_SEXY: GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_EYING_1, 3); break; + case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_BLACK_PROJECT_MALE_VOICE_1_CHAT_1, 6); break; + default: return GetGenericMaleTalkSfx(sound); } if (model == MI_P_MAN2) @@ -4637,26 +4620,14 @@ cAudioManager::GetWhiteFatMaleTalkSfx(int16 sound) uint32 sfx; static uint32 lastSfx = NO_SAMPLE; - switch (sound) { - case SOUND_PED_CAR_JACKED: - GetPhrase(&sfx, &lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_CARJACKED_1, 3); - break; - case SOUND_PED_ROBBED: - GetPhrase(&sfx, &lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_MUGGED_1, 3); - break; - case SOUND_PED_EVADE: - GetPhrase(&sfx, &lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_DODGE_1, 9); - break; - case SOUND_PED_ANNOYED_DRIVER: - GetPhrase(&sfx, &lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_DRIVER_ABUSE_1, 9); - break; - case SOUND_PED_WAIT_DOUBLEBACK: - GetPhrase(&sfx, &lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_LOST_1, 2); - break; - case SOUND_PED_CHAT: - GetPhrase(&sfx, &lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_CHAT_1, 9); - default: - return GetGenericMaleTalkSfx(sound); + switch(sound) { + case SOUND_PED_CAR_JACKED: GetPhrase(&sfx, &lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_CARJACKED_1, 3); break; + case SOUND_PED_ROBBED: GetPhrase(&sfx, &lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_MUGGED_1, 3); break; + case SOUND_PED_EVADE: GetPhrase(&sfx, &lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_DODGE_1, 9); break; + case SOUND_PED_ANNOYED_DRIVER: GetPhrase(&sfx, &lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_DRIVER_ABUSE_1, 9); break; + case SOUND_PED_WAIT_DOUBLEBACK: GetPhrase(&sfx, &lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_LOST_1, 2); break; + case SOUND_PED_CHAT: GetPhrase(&sfx, &lastSfx, SFX_WHITE_FAT_MALE_VOICE_1_CHAT_1, 9); break; + default: return GetGenericMaleTalkSfx(sound); } return sfx; } From 23220d799c0a44b75f6863848124852cc98b559e Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Sun, 18 Oct 2020 15:26:20 +0200 Subject: [PATCH 08/60] Cleanup breaks CAutomobile::ProcessOpenDoor --- src/vehicles/Automobile.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index 66452477..fa92bbbe 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -1,4 +1,4 @@ -#include "common.h" +#include "common.h" #include "main.h" #include "General.h" @@ -3746,7 +3746,6 @@ CAutomobile::ProcessOpenDoor(uint32 component, uint32 anim, float time) case ANIM_CAR_ROLLDOOR_LOW: ProcessDoorOpenCloseAnimation(this, component, door, time, 0.1f, 0.6f, 0.95f); break; - break; case ANIM_CAR_GETOUT_LHS: case ANIM_CAR_GETOUT_LOW_LHS: case ANIM_CAR_GETOUT_RHS: @@ -3760,6 +3759,7 @@ CAutomobile::ProcessOpenDoor(uint32 component, uint32 anim, float time) case ANIM_CAR_PULLOUT_RHS: case ANIM_CAR_PULLOUT_LOW_RHS: OpenDoor(component, door, 1.0f); + break; case ANIM_COACH_OPEN_L: case ANIM_COACH_OPEN_R: ProcessDoorOpenAnimation(this, component, door, time, 0.66f, 0.8f); From b91f6a45501634b55f6ef2c08d57c5293d5fd3a0 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 18 Oct 2020 16:40:06 +0300 Subject: [PATCH 09/60] Setter for bIsStatic (became virtual in SA) --- src/control/RoadBlocks.cpp | 2 +- src/control/Script.cpp | 10 +++++----- src/core/World.cpp | 18 +++++++++--------- src/entities/Entity.h | 3 ++- src/entities/Physical.cpp | 26 +++++++++++++------------- src/objects/Object.cpp | 16 ++++++++-------- src/peds/Ped.cpp | 8 ++++---- src/peds/Population.cpp | 2 +- src/render/Renderer.cpp | 2 +- src/vehicles/Automobile.cpp | 6 +++--- src/vehicles/Boat.cpp | 2 +- src/vehicles/CarGen.cpp | 4 ++-- src/vehicles/Heli.cpp | 2 +- src/weapons/BulletInfo.cpp | 6 +++--- src/weapons/Weapon.cpp | 16 ++++++++-------- 15 files changed, 62 insertions(+), 61 deletions(-) diff --git a/src/control/RoadBlocks.cpp b/src/control/RoadBlocks.cpp index 86b4caf1..1496b307 100644 --- a/src/control/RoadBlocks.cpp +++ b/src/control/RoadBlocks.cpp @@ -165,7 +165,7 @@ CRoadBlocks::GenerateRoadBlocks(void) vehicleMatrix.GetPosition().z += fModelRadius - 0.6f; pVehicle->m_matrix = vehicleMatrix; pVehicle->PlaceOnRoadProperly(); - pVehicle->bIsStatic = false; + pVehicle->SetIsStatic(false); pVehicle->m_matrix.UpdateRW(); pVehicle->m_nDoorLock = CARLOCK_UNLOCKED; CCarCtrl::JoinCarWithRoadSystem(pVehicle); diff --git a/src/control/Script.cpp b/src/control/Script.cpp index 5dceacb7..efd17f25 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -3577,7 +3577,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); pos.z += car->GetDistanceFromCentreOfMassToBaseOfModel(); - car->bIsStatic = false; + car->SetIsStatic(false); /* Again weird usage of virtual functions. */ if (car->IsBoat()) { car->Teleport(pos); @@ -9184,14 +9184,14 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); script_assert(pObject); if (ScriptParams[1]) { - if (pObject->bIsStatic) { - pObject->bIsStatic = false; + if (pObject->GetIsStatic()) { + pObject->SetIsStatic(false); pObject->AddToMovingList(); } } else { - if (!pObject->bIsStatic) { - pObject->bIsStatic = true; + if (!pObject->GetIsStatic()) { + pObject->SetIsStatic(true); pObject->RemoveFromMovingList(); } } diff --git a/src/core/World.cpp b/src/core/World.cpp index 7f8d8994..d65d57dd 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -75,7 +75,7 @@ CWorld::Add(CEntity *ent) if(ent->IsBuilding() || ent->IsDummy()) return; - if(!ent->IsStatic()) ((CPhysical *)ent)->AddToMovingList(); + if(!ent->GetIsStatic()) ((CPhysical *)ent)->AddToMovingList(); } void @@ -90,7 +90,7 @@ CWorld::Remove(CEntity *ent) if(ent->IsBuilding() || ent->IsDummy()) return; - if(!ent->IsStatic()) ((CPhysical *)ent)->RemoveFromMovingList(); + if(!ent->GetIsStatic()) ((CPhysical *)ent)->RemoveFromMovingList(); } void @@ -1960,7 +1960,7 @@ CWorld::Process(void) RemoveEntityInsteadOfProcessingIt(movingEnt); } else { movingEnt->ProcessControl(); - if(movingEnt->IsStatic()) { movingEnt->RemoveFromMovingList(); } + if(movingEnt->GetIsStatic()) { movingEnt->RemoveFromMovingList(); } } } bForceProcessControl = true; @@ -1971,7 +1971,7 @@ CWorld::Process(void) RemoveEntityInsteadOfProcessingIt(movingEnt); } else { movingEnt->ProcessControl(); - if(movingEnt->IsStatic()) { movingEnt->RemoveFromMovingList(); } + if(movingEnt->GetIsStatic()) { movingEnt->RemoveFromMovingList(); } } } } @@ -2124,13 +2124,13 @@ CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, floa CObject *pObject = (CObject *)pEntity; CVehicle *pVehicle = (CVehicle *)pEntity; if(!pEntity->bExplosionProof && (!pEntity->IsPed() || !pPed->bInVehicle)) { - if(pEntity->IsStatic()) { + if(pEntity->GetIsStatic()) { if(pEntity->IsObject()) { if (fPower > pObject->m_fUprootLimit || IsFence(pObject->GetModelIndex())) { if (IsGlass(pObject->GetModelIndex())) { CGlass::WindowRespondsToExplosion(pObject, position); } else { - pObject->bIsStatic = false; + pObject->SetIsStatic(false); pObject->AddToMovingList(); int16 modelId = pEntity->GetModelIndex(); if(modelId != MI_FIRE_HYDRANT || @@ -2148,18 +2148,18 @@ CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, floa } } } - if(pEntity->IsStatic()) { + if(pEntity->GetIsStatic()) { float fDamageMultiplier = (fRadius - fMagnitude) * 2.0f / fRadius; float fDamage = 300.0f * Min(fDamageMultiplier, 1.0f); pObject->ObjectDamage(fDamage); } } else { - pEntity->bIsStatic = false; + pEntity->SetIsStatic(false); pEntity->AddToMovingList(); } } - if(!pEntity->IsStatic()) { + if(!pEntity->GetIsStatic()) { float fDamageMultiplier = Min((fRadius - fMagnitude) * 2.0f / fRadius, 1.0f); CVector vecForceDir = vecDistance * (fPower * pEntity->m_fMass * 0.00071429f * fDamageMultiplier / diff --git a/src/entities/Entity.h b/src/entities/Entity.h index eca462cd..ba4f7ab0 100644 --- a/src/entities/Entity.h +++ b/src/entities/Entity.h @@ -97,7 +97,8 @@ public: eEntityStatus GetStatus() const { return (eEntityStatus)m_status; } void SetStatus(eEntityStatus status) { m_status = status; } CColModel *GetColModel(void) { return CModelInfo::GetModelInfo(m_modelIndex)->GetColModel(); } - bool IsStatic(void) { return bIsStatic; } + bool GetIsStatic(void) const { return bIsStatic; } + void SetIsStatic(bool state) { bIsStatic = state; } #ifdef COMPATIBLE_SAVES void SaveEntityFlags(uint8*& buf); void LoadEntityFlags(uint8*& buf); diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp index 49060fe7..a08e68f8 100644 --- a/src/entities/Physical.cpp +++ b/src/entities/Physical.cpp @@ -341,7 +341,7 @@ CPhysical::ProcessEntityCollision(CEntity *ent, CColPoint *colpoints) AddCollisionRecord(ent); if(!ent->IsBuilding()) // Can't this catch dummies too? ((CPhysical*)ent)->AddCollisionRecord(this); - if(ent->IsBuilding() || ent->IsStatic()) + if(ent->IsBuilding() || ent->GetIsStatic()) this->bHasHitWall = true; } return numSpheres; @@ -377,7 +377,7 @@ CPhysical::ProcessControl(void) m_nStaticFrames++; if(m_nStaticFrames > 10){ m_nStaticFrames = 10; - bIsStatic = true; + SetIsStatic(true); m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); m_vecMoveFriction = m_vecMoveSpeed; @@ -556,7 +556,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl massFactorB = B->bIsHeavy ? 2.0f : 1.0f; float speedA, speedB; - if(B->IsStatic()){ + if(B->GetIsStatic()){ if(A->bPedPhysics){ speedA = DotProduct(A->m_vecMoveSpeed, colpoint.normal); if(speedA < 0.0f){ @@ -567,7 +567,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl if(IsGlass(B->GetModelIndex())) CGlass::WindowRespondsToCollision(B, impulseA, A->m_vecMoveSpeed, colpoint.point, false); else if(!B->bInfiniteMass) - B->bIsStatic = false; + B->SetIsStatic(false); }else{ if(IsGlass(B->GetModelIndex())) CGlass::WindowRespondsToSoftCollision(B, impulseA); @@ -576,7 +576,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl return true; } }else if(!B->bInfiniteMass) - B->bIsStatic = false; + B->SetIsStatic(false); if(B->bInfiniteMass){ impulseA = -speedA * A->m_fMass; @@ -614,7 +614,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl if(IsGlass(B->GetModelIndex())) CGlass::WindowRespondsToCollision(B, impulseA, A->m_vecMoveSpeed, colpoint.point, false); else - B->bIsStatic = false; + B->SetIsStatic(false); int16 model = B->GetModelIndex(); if(model == MI_FIRE_HYDRANT && !Bobj->bHasBeenDamaged){ CParticleObject::AddObject(POBJECT_FIRE_HYDRANT, B->GetPosition() - CVector(0.0f, 0.0f, 0.5f), true); @@ -635,11 +635,11 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl return true; } }else if(!B->bInfiniteMass) - B->bIsStatic = false; + B->SetIsStatic(false); } } - if(B->IsStatic()) + if(B->GetIsStatic()) return false; if(!B->bInfiniteMass) B->AddToMovingList(); @@ -1074,7 +1074,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists) canshift = true; else canshift = A->IsPed() && - B->IsObject() && B->bIsStatic && !Bobj->bHasBeenDamaged; + B->IsObject() && B->GetIsStatic() && !Bobj->bHasBeenDamaged; if(B == A || B->m_scanCode == CWorld::GetCurrentScanCode() || !B->bUsesCollision || @@ -1098,7 +1098,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists) CObject *Aobj = (CObject*)A; if(Aobj->ObjectCreatedBy != TEMP_OBJECT && !Aobj->bHasBeenDamaged && - Aobj->IsStatic()){ + Aobj->GetIsStatic()){ if(Aobj->m_pCollidingEntity == B) Aobj->m_pCollidingEntity = nil; }else if(Aobj->m_pCollidingEntity != B){ @@ -1115,7 +1115,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists) CObject *Bobj = (CObject*)B; if(Bobj->ObjectCreatedBy != TEMP_OBJECT && !Bobj->bHasBeenDamaged && - Bobj->IsStatic()){ + Bobj->GetIsStatic()){ if(Bobj->m_pCollidingEntity == A) Bobj->m_pCollidingEntity = nil; }else if(Bobj->m_pCollidingEntity != A){ @@ -1433,7 +1433,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists) skipCollision = true; else if(Aobj->ObjectCreatedBy == TEMP_OBJECT || Aobj->bHasBeenDamaged || - !Aobj->IsStatic()){ + !Aobj->GetIsStatic()){ if(Aobj->m_pCollidingEntity == B) skipCollision = true; else{ @@ -1452,7 +1452,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists) skipCollision = true; else if(Bobj->ObjectCreatedBy == TEMP_OBJECT || Bobj->bHasBeenDamaged || - !Bobj->IsStatic()){ + !Bobj->GetIsStatic()){ if(Bobj->m_pCollidingEntity == A) skipCollision = true; else{ diff --git a/src/objects/Object.cpp b/src/objects/Object.cpp index c5f73987..d91a0f13 100644 --- a/src/objects/Object.cpp +++ b/src/objects/Object.cpp @@ -91,7 +91,7 @@ CObject::ProcessControl(void) CPhysical::ProcessControl(); if (mod_Buoyancy.ProcessBuoyancy(this, m_fBuoyancy, &point, &impulse)) { bIsInWater = true; - bIsStatic = false; + SetIsStatic(false); ApplyMoveForce(impulse); ApplyTurnForce(impulse, point); float fTimeStep = Pow(0.97f, CTimer::GetTimeStep()); @@ -182,7 +182,7 @@ CObject::ObjectDamage(float amount) case DAMAGE_EFFECT_SMASH_COMPLETELY: bIsVisible = false; bUsesCollision = false; - bIsStatic = true; + SetIsStatic(true); bExplosionProof = true; SetMoveSpeed(0.0f, 0.0f, 0.0f); SetTurnSpeed(0.0f, 0.0f, 0.0f); @@ -194,7 +194,7 @@ CObject::ObjectDamage(float amount) else { bIsVisible = false; bUsesCollision = false; - bIsStatic = true; + SetIsStatic(true); bExplosionProof = true; SetMoveSpeed(0.0f, 0.0f, 0.0f); SetTurnSpeed(0.0f, 0.0f, 0.0f); @@ -203,7 +203,7 @@ CObject::ObjectDamage(float amount) case DAMAGE_EFFECT_SMASH_CARDBOARD_COMPLETELY: { bIsVisible = false; bUsesCollision = false; - bIsStatic = true; + SetIsStatic(true); bExplosionProof = true; SetMoveSpeed(0.0f, 0.0f, 0.0f); SetTurnSpeed(0.0f, 0.0f, 0.0f); @@ -226,7 +226,7 @@ CObject::ObjectDamage(float amount) case DAMAGE_EFFECT_SMASH_WOODENBOX_COMPLETELY: { bIsVisible = false; bUsesCollision = false; - bIsStatic = true; + SetIsStatic(true); bExplosionProof = true; SetMoveSpeed(0.0f, 0.0f, 0.0f); SetTurnSpeed(0.0f, 0.0f, 0.0f); @@ -249,7 +249,7 @@ CObject::ObjectDamage(float amount) case DAMAGE_EFFECT_SMASH_TRAFFICCONE_COMPLETELY: { bIsVisible = false; bUsesCollision = false; - bIsStatic = true; + SetIsStatic(true); bExplosionProof = true; SetMoveSpeed(0.0f, 0.0f, 0.0f); SetTurnSpeed(0.0f, 0.0f, 0.0f); @@ -274,7 +274,7 @@ CObject::ObjectDamage(float amount) case DAMAGE_EFFECT_SMASH_BARPOST_COMPLETELY: { bIsVisible = false; bUsesCollision = false; - bIsStatic = true; + SetIsStatic(true); bExplosionProof = true; SetMoveSpeed(0.0f, 0.0f, 0.0f); SetTurnSpeed(0.0f, 0.0f, 0.0f); @@ -314,7 +314,7 @@ CObject::Init(void) CObjectData::SetObjectData(GetModelIndex(), *this); m_nEndOfLifeTime = 0; ObjectCreatedBy = GAME_OBJECT; - bIsStatic = true; + SetIsStatic(true); bIsPickup = false; bPickupObjWithMessage = false; bOutOfStock = false; diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 0c469942..7c9b78f4 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -14606,11 +14606,11 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints) if (!collidingEnt->IsBuilding()) ((CPhysical*)collidingEnt)->AddCollisionRecord(this); - if (ourCollidedSpheres > 0 && (collidingEnt->IsBuilding() || collidingEnt->IsStatic())) { + if (ourCollidedSpheres > 0 && (collidingEnt->IsBuilding() || collidingEnt->GetIsStatic())) { bHasHitWall = true; } } - if (collidingEnt->IsBuilding() || collidingEnt->IsStatic()) { + if (collidingEnt->IsBuilding() || collidingEnt->GetIsStatic()) { if (bWasStanding) { CVector sphereNormal; @@ -15956,7 +15956,7 @@ CPed::SeekCar(void) } else { m_fRotationCur = m_fRotationDest; if (!bVehEnterDoorIsBlocked) { - vehToSeek->bIsStatic = false; + vehToSeek->SetIsStatic(false); if (m_objective == OBJECTIVE_SOLICIT_VEHICLE) { SetSolicit(1000); } else if (m_objective == OBJECTIVE_BUY_ICE_CREAM) { @@ -16637,7 +16637,7 @@ CPed::SpawnFlyingComponent(int pedNode, int8 direction) obj->m_fElasticity = 0.03f; obj->m_fBuoyancy = m_fMass*GRAVITY/0.75f; obj->ObjectCreatedBy = TEMP_OBJECT; - obj->bIsStatic = false; + obj->SetIsStatic(false); obj->bIsPickup = false; obj->m_nSpecialCollisionResponseCases = COLLRESPONSE_SMALLBOX; diff --git a/src/peds/Population.cpp b/src/peds/Population.cpp index a1bde005..b3eaf471 100644 --- a/src/peds/Population.cpp +++ b/src/peds/Population.cpp @@ -972,7 +972,7 @@ CPopulation::ConvertToRealObject(CDummyObject *dummy) if (IsGlass(obj->GetModelIndex())) { obj->bIsVisible = false; } else if (obj->GetModelIndex() == MI_BUOY) { - obj->bIsStatic = false; + obj->SetIsStatic(false); obj->m_vecMoveSpeed = CVector(0.0f, 0.0f, -0.001f); obj->bTouchingWater = true; obj->AddToMovingList(); diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 7a688ce8..8c194067 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -1208,7 +1208,7 @@ CRenderer::IsEntityCullZoneVisible(CEntity *ent) return !(ped->m_pCurSurface && ped->m_pCurSurface->bZoneCulled2); case ENTITY_TYPE_OBJECT: obj = (CObject*)ent; - if(!obj->IsStatic()) + if(!obj->GetIsStatic()) return true; return !(obj->m_pCurSurface && obj->m_pCurSurface->bZoneCulled2); default: break; diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index fa92bbbe..95a68769 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -2192,8 +2192,8 @@ CAutomobile::ProcessEntityCollision(CEntity *ent, CColPoint *colpoints) } // move body cast - if(phys->IsStatic()){ - phys->bIsStatic = false; + if(phys->GetIsStatic()){ + phys->SetIsStatic(false); phys->m_nStaticFrames = 0; phys->ApplyMoveForce(m_vecMoveSpeed / Sqrt(speed)); phys->AddToMovingList(); @@ -4385,7 +4385,7 @@ CAutomobile::SpawnFlyingComponent(int32 component, uint32 type) obj->m_fElasticity = 0.1f; obj->m_fBuoyancy = obj->m_fMass*GRAVITY/0.75f; obj->ObjectCreatedBy = TEMP_OBJECT; - obj->bIsStatic = false; + obj->SetIsStatic(false); obj->bIsPickup = false; obj->bUseVehicleColours = true; obj->m_colour1 = m_currentColour1; diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp index c248b54c..dfe9d1d9 100644 --- a/src/vehicles/Boat.cpp +++ b/src/vehicles/Boat.cpp @@ -664,7 +664,7 @@ CBoat::BlowUpCar(CEntity *culprit) obj->m_fElasticity = 0.1f; obj->m_fBuoyancy = obj->m_fMass*GRAVITY/0.75f; obj->ObjectCreatedBy = TEMP_OBJECT; - obj->bIsStatic = false; + obj->SetIsStatic(false); obj->bIsPickup = false; // life time diff --git a/src/vehicles/CarGen.cpp b/src/vehicles/CarGen.cpp index 9bab9640..7524444b 100644 --- a/src/vehicles/CarGen.cpp +++ b/src/vehicles/CarGen.cpp @@ -58,7 +58,7 @@ void CCarGenerator::DoInternalProcessing() return; if (CModelInfo::IsBoatModel(m_nModelIndex)){ CBoat* pBoat = new CBoat(m_nModelIndex, PARKED_VEHICLE); - pBoat->bIsStatic = false; + pBoat->SetIsStatic(false); pBoat->bEngineOn = false; CVector pos = m_vecPos; if (pos.z <= -100.0f) @@ -101,7 +101,7 @@ void CCarGenerator::DoInternalProcessing() if (((CVehicleModelInfo*)CModelInfo::GetModelInfo(m_nModelIndex))->m_vehicleType != VEHICLE_TYPE_BIKE) pCar = new CAutomobile(m_nModelIndex, PARKED_VEHICLE); - pCar->bIsStatic = false; + pCar->SetIsStatic(false); pCar->bEngineOn = false; pos.z += pCar->GetDistanceFromCentreOfMassToBaseOfModel(); pCar->SetPosition(pos); diff --git a/src/vehicles/Heli.cpp b/src/vehicles/Heli.cpp index 2316cbef..e1f662d8 100644 --- a/src/vehicles/Heli.cpp +++ b/src/vehicles/Heli.cpp @@ -726,7 +726,7 @@ CHeli::SpawnFlyingComponent(int32 component) obj->m_fElasticity = 0.1f; obj->m_fBuoyancy = obj->m_fMass*GRAVITY/0.75f; obj->ObjectCreatedBy = TEMP_OBJECT; - obj->bIsStatic = false; + obj->SetIsStatic(false); obj->bIsPickup = false; // life time diff --git a/src/weapons/BulletInfo.cpp b/src/weapons/BulletInfo.cpp index 15dde011..e87a7407 100644 --- a/src/weapons/BulletInfo.cpp +++ b/src/weapons/BulletInfo.cpp @@ -185,11 +185,11 @@ void CBulletInfo::Update(void) if (pHitEntity->IsObject()) { CObject* pObject = (CObject*)pHitEntity; if (!pObject->bInfiniteMass) { - if (pObject->IsStatic() && pObject->m_fUprootLimit <= 0.0f) { - pObject->bIsStatic = false; + if (pObject->GetIsStatic() && pObject->m_fUprootLimit <= 0.0f) { + pObject->SetIsStatic(false); pObject->AddToMovingList(); } - if (!pObject->IsStatic()) + if (!pObject->GetIsStatic()) pObject->ApplyMoveForce(-BULLET_HIT_FORCE * point.normal); } } diff --git a/src/weapons/Weapon.cpp b/src/weapons/Weapon.cpp index 37f59c95..85f0bc15 100644 --- a/src/weapons/Weapon.cpp +++ b/src/weapons/Weapon.cpp @@ -1057,13 +1057,13 @@ CWeapon::DoBulletImpact(CEntity *shooter, CEntity *victim, if ( !victimObject->bInfiniteMass ) { - if ( victimObject->IsStatic() && victimObject->m_fUprootLimit <= 0.0f ) + if ( victimObject->GetIsStatic() && victimObject->m_fUprootLimit <= 0.0f ) { - victimObject->bIsStatic = false; + victimObject->SetIsStatic(false); victimObject->AddToMovingList(); } - if ( !victimObject->IsStatic()) + if ( !victimObject->GetIsStatic()) { CVector moveForce = point->normal*-4.0f; victimObject->ApplyMoveForce(moveForce.x, moveForce.y, moveForce.z); @@ -1316,13 +1316,13 @@ CWeapon::FireShotgun(CEntity *shooter, CVector *fireSource) if ( !victimObject->bInfiniteMass ) { - if ( victimObject->IsStatic() && victimObject->m_fUprootLimit <= 0.0f ) + if ( victimObject->GetIsStatic() && victimObject->m_fUprootLimit <= 0.0f ) { - victimObject->bIsStatic = false; + victimObject->SetIsStatic(false); victimObject->AddToMovingList(); } - if ( !victimObject->IsStatic()) + if ( !victimObject->GetIsStatic()) { CVector moveForce = point.normal*-5.0f; victimObject->ApplyMoveForce(moveForce.x, moveForce.y, moveForce.z); @@ -2258,9 +2258,9 @@ CWeapon::BlowUpExplosiveThings(CEntity *thing) object->m_vecMoveSpeed.x += float((CGeneral::GetRandomNumber()&255) - 128) * 0.0002f; object->m_vecMoveSpeed.y += float((CGeneral::GetRandomNumber()&255) - 128) * 0.0002f; - if ( object->IsStatic()) + if ( object->GetIsStatic()) { - object->bIsStatic = false; + object->SetIsStatic(false); object->AddToMovingList(); } } From cc0ae516319a028cd1ef1b317a26d58ef17ee6d0 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 18 Oct 2020 16:55:11 +0300 Subject: [PATCH 10/60] lil fix --- src/control/Script.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/control/Script.cpp b/src/control/Script.cpp index efd17f25..50e89ecc 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -9184,13 +9184,13 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); script_assert(pObject); if (ScriptParams[1]) { - if (pObject->GetIsStatic()) { + if (pObject->bIsStatic) { pObject->SetIsStatic(false); pObject->AddToMovingList(); } } else { - if (!pObject->GetIsStatic()) { + if (!pObject->bIsStatic) { pObject->SetIsStatic(true); pObject->RemoveFromMovingList(); } From 4c305fd48bda02eabf56ca948bdab02ed9867362 Mon Sep 17 00:00:00 2001 From: shfil Date: Sun, 18 Oct 2020 16:54:47 +0200 Subject: [PATCH 11/60] Upload to bintray when creating tags --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index 1cf0c676..8d1d4e9d 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -47,7 +47,7 @@ deploy: publish: true on: branch: master - APPVEYOR_REPO_TAG: false + APPVEYOR_REPO_TAG: true cache: - "%GLEW_FILE%" From a6aa782d6d5fa9a2165dafec5794a2e2cfbc653f Mon Sep 17 00:00:00 2001 From: erorcun Date: Sun, 18 Oct 2020 19:16:37 +0300 Subject: [PATCH 12/60] Fixes and style changes from miami --- premake5.lua | 4 +- src/audio/AudioManager.cpp | 5 + src/audio/DMAudio.cpp | 7 +- src/audio/oal/stream.cpp | 18 +- src/audio/sampman.h | 4 + src/audio/sampman_miles.cpp | 3 +- src/audio/sampman_oal.cpp | 777 ++++++++++++++++++++++++++++++++---- src/core/Pad.cpp | 4 +- src/core/Radar.cpp | 100 ++--- src/core/Radar.h | 16 +- src/peds/Ped.cpp | 70 ++-- src/render/Hud.cpp | 36 +- src/render/Hud.h | 13 +- src/render/Particle.cpp | 4 +- src/render/WaterCannon.cpp | 4 +- src/rw/RwHelper.cpp | 11 +- src/skel/glfw/glfw.cpp | 15 +- src/skel/win/win.cpp | 18 +- 18 files changed, 861 insertions(+), 248 deletions(-) diff --git a/premake5.lua b/premake5.lua index 49be07c3..9d9243db 100644 --- a/premake5.lua +++ b/premake5.lua @@ -330,14 +330,12 @@ project "re3" links { "rw" } filter "platforms:*d3d9*" + defines { "USE_D3D9" } links { "d3d9" } filter "platforms:*x86*d3d*" includedirs { "sdk/dx8sdk/include" } libdirs { "sdk/dx8sdk/lib" } - - filter "platforms:*amd64*d3d9*" - defines { "USE_D3D9" } filter "platforms:win-x86*gl3_glfw*" libdirs { path.join(_OPTIONS["glewdir"], "lib/Release/Win32") } diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index a42aa16f..d8054181 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -321,8 +321,13 @@ cAudioManager::Get3DProviderName(uint8 id) const { if (!m_bIsInitialised) return nil; +#ifdef AUDIO_OAL + id = clamp(id, 0, SampleManager.GetNum3DProvidersAvailable() - 1); +#else + // We don't want that either since it will crash the game, but skipping for now if (id >= SampleManager.GetNum3DProvidersAvailable()) return nil; +#endif return SampleManager.Get3DProviderName(id); } diff --git a/src/audio/DMAudio.cpp b/src/audio/DMAudio.cpp index 7174c23c..17963cc9 100644 --- a/src/audio/DMAudio.cpp +++ b/src/audio/DMAudio.cpp @@ -118,7 +118,12 @@ int8 cDMAudio::AutoDetect3DProviders(void) for ( int32 i = 0; i < GetNum3DProvidersAvailable(); i++ ) { wchar buff[64]; - + +#ifdef AUDIO_OAL + if (defaultProvider >= 0 && defaultProvider < GetNum3DProvidersAvailable()) { + return i; + } +#endif char *name = Get3DProviderName(i); AsciiToUnicode(name, buff); char *providername = UnicodeToAscii(buff); diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index c4f1b67c..3af50ea8 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -323,8 +323,8 @@ CStream::CStream(char *filename, ALuint &source, ALuint (&buffers)[NUM_STREAMBUF #endif else m_pSoundFile = nil; - ASSERT(m_pSoundFile != nil); - if (m_pSoundFile && m_pSoundFile->IsOpened() ) + + if ( IsOpened() ) { m_pBuffer = malloc(m_pSoundFile->GetBufferSize()); ASSERT(m_pBuffer!=nil); @@ -371,14 +371,14 @@ bool CStream::HasSource() bool CStream::IsOpened() { - return m_pSoundFile->IsOpened(); + return m_pSoundFile && m_pSoundFile->IsOpened(); } bool CStream::IsPlaying() { if ( !HasSource() || !IsOpened() ) return false; - if ( m_pSoundFile->IsOpened() && !m_bPaused ) + if ( !m_bPaused ) { ALint sourceState; alGetSourcei(m_alSource, AL_SOURCE_STATE, &sourceState); @@ -446,7 +446,7 @@ void CStream::SetPan(uint8 nPan) void CStream::SetPosMS(uint32 nPos) { - if ( !m_pSoundFile->IsOpened() ) return; + if ( !IsOpened() ) return; m_pSoundFile->Seek(nPos); ClearBuffers(); } @@ -454,7 +454,7 @@ void CStream::SetPosMS(uint32 nPos) uint32 CStream::GetPosMS() { if ( !HasSource() ) return 0; - if ( !m_pSoundFile->IsOpened() ) return 0; + if ( !IsOpened() ) return 0; ALint offset; //alGetSourcei(m_alSource, AL_SAMPLE_OFFSET, &offset); @@ -467,7 +467,7 @@ uint32 CStream::GetPosMS() uint32 CStream::GetLengthMS() { - if ( !m_pSoundFile->IsOpened() ) return 0; + if ( !IsOpened() ) return 0; return m_pSoundFile->GetLength(); } @@ -475,7 +475,7 @@ bool CStream::FillBuffer(ALuint alBuffer) { if ( !HasSource() ) return false; - if ( !m_pSoundFile->IsOpened() ) + if ( !IsOpened() ) return false; if ( !(alBuffer != AL_NONE && alIsBuffer(alBuffer)) ) return false; @@ -517,7 +517,7 @@ void CStream::ClearBuffers() bool CStream::Setup() { - if ( m_pSoundFile->IsOpened() ) + if ( IsOpened() ) { m_pSoundFile->Seek(0); alSourcei(m_alSource, AL_SOURCE_RELATIVE, AL_TRUE); diff --git a/src/audio/sampman.h b/src/audio/sampman.h index d4b2621a..aec61144 100644 --- a/src/audio/sampman.h +++ b/src/audio/sampman.h @@ -218,6 +218,10 @@ public: extern cSampleManager SampleManager; extern uint32 BankStartOffset[MAX_SFX_BANKS]; +#ifdef AUDIO_OAL +extern int defaultProvider; +#endif + #ifdef AUDIO_OPUS static char StreamedNameTable[][25] = { "AUDIO\\HEAD.OPUS", "AUDIO\\CLASS.OPUS", "AUDIO\\KJAH.OPUS", "AUDIO\\RISE.OPUS", "AUDIO\\LIPS.OPUS", "AUDIO\\GAME.OPUS", diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp index 70ea942e..392bface 100644 --- a/src/audio/sampman_miles.cpp +++ b/src/audio/sampman_miles.cpp @@ -2176,7 +2176,8 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) if ( mp3Stream[nStream] ) { AIL_set_stream_loop_count(mp3Stream[nStream], 1); - AIL_set_stream_ms_position(mp3Stream[nStream], position); + AIL_set_stream_loop_count(mp3Stream[nStream], nStreamLoopedFlag[nStream] ? 0 : 1); + nStreamLoopedFlag[nStream] = true; AIL_pause_stream(mp3Stream[nStream], 0); return true; } diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 9f3156cb..720849f8 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -1,4 +1,3 @@ -#include "common.h" //#define JUICY_OAL #ifdef AUDIO_OAL @@ -9,6 +8,10 @@ #include "eax.h" #include "eax-util.h" +#define WITHWINDOWS +#include "common.h" +#include "crossplatform.h" + #ifdef _WIN32 #include #include @@ -27,20 +30,27 @@ #include "MusicManager.h" #include "Frontend.h" #include "Timer.h" -#include "crossplatform.h" #ifdef AUDIO_OPUS #include #endif //TODO: fix eax3 reverb -//TODO: max channals +//TODO: max channels //TODO: loop count -//TODO: mp3 player #ifdef _WIN32 #pragma comment( lib, "OpenAL32.lib" ) #endif +// for user MP3s +#ifdef _WIN32 +#include +#include +#include +#else +#define _getcwd getcwd +#endif + cSampleManager SampleManager; bool _bSampmanInitialised = false; @@ -128,11 +138,27 @@ struct } }ALBuffers[SAMPLEBANK_MAX]; -uint32 nNumMP3s; +struct tMP3Entry +{ + char aFilename[MAX_PATH]; + + uint32 nTrackLength; + uint32 nTrackStreamPos; + + tMP3Entry* pNext; + char* pLinkPath; +}; + +uint32 nNumMP3s; +tMP3Entry* _pMP3List; +char _mp3DirectoryPath[MAX_PATH]; CStream *aStream[MAX_STREAMS]; uint8 nStreamPan [MAX_STREAMS]; uint8 nStreamVolume[MAX_STREAMS]; - +uint8 nStreamLoopedFlag[MAX_STREAMS]; +uint32 _CurMP3Index; +int32 _CurMP3Pos; +bool _bIsMp3Active; /////////////////////////////////////////////////////////////// // Env Size Diffus Room RoomHF RoomLF DecTm DcHF DcLF Refl RefDel Ref Pan Revb RevDel Rev Pan EchTm EchDp ModTm ModDp AirAbs HFRef LFRef RRlOff FLAGS EAXLISTENERPROPERTIES StartEAX3 = @@ -451,24 +477,421 @@ int8 cSampleManager::GetCurrent3DProviderIndex(void) int8 cSampleManager::SetCurrent3DProvider(uint8 nProvider) { - if (nProvider >= m_nNumberOfProviders) - nProvider = 0; - ASSERT( nProvider < m_nNumberOfProviders ); int savedprovider = curprovider; - - if ( nProvider < m_nNumberOfProviders ) - { - if ( set_new_provider(nProvider) ) - return curprovider; - else if ( savedprovider != -1 && savedprovider < m_nNumberOfProviders && set_new_provider(savedprovider) ) - return curprovider; - else - return -1; - } + + nProvider = clamp(nProvider, 0, m_nNumberOfProviders - 1); + + if ( set_new_provider(nProvider) ) + return curprovider; + else if ( savedprovider != -1 && savedprovider < m_nNumberOfProviders && set_new_provider(savedprovider) ) + return curprovider; else return curprovider; } +static bool +_ResolveLink(char const *path, char *out) +{ +#ifdef _WIN32 + size_t len = strlen(path); + if (len < 4 || strcmp(&path[len - 4], ".lnk") != 0) + return false; + + IShellLink* psl; + WIN32_FIND_DATA fd; + char filepath[MAX_PATH]; + + CoInitialize(NULL); + + if (SUCCEEDED( CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl ) )) + { + IPersistFile *ppf; + + if (SUCCEEDED(psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf))) + { + WCHAR wpath[MAX_PATH]; + + MultiByteToWideChar(CP_ACP, 0, path, -1, wpath, MAX_PATH); + + if (SUCCEEDED(ppf->Load(wpath, STGM_READ))) + { + /* Resolve the link */ + if (SUCCEEDED(psl->Resolve(NULL, SLR_ANY_MATCH|SLR_NO_UI|SLR_NOSEARCH))) + { + strcpy(filepath, path); + + if (SUCCEEDED(psl->GetPath(filepath, MAX_PATH, &fd, SLGP_UNCPRIORITY))) + { + OutputDebugString(fd.cFileName); + + strcpy(out, filepath); + // FIX: Release the objects. Taken from SA. +#ifdef FIX_BUGS + ppf->Release(); + psl->Release(); +#endif + return true; + } + } + } + + ppf->Release(); + } + psl->Release(); + } + + return false; +#else + struct stat sb; + + if (lstat(path, &sb) == -1) { + perror("lstat: "); + return false; + } + + if (S_ISLNK(sb.st_mode)) { + char* linkname = (char*)alloca(sb.st_size + 1); + if (linkname == NULL) { + fprintf(stderr, "insufficient memory\n"); + return false; + } + + if (readlink(path, linkname, sb.st_size + 1) < 0) { + perror("readlink: "); + return false; + } + linkname[sb.st_size] = '\0'; + strcpy(out, linkname); + return true; + } else { + return false; + } +#endif +} + +static void +_FindMP3s(void) +{ + tMP3Entry *pList; + bool bShortcut; + bool bInitFirstEntry; + HANDLE hFind; + char path[MAX_PATH]; + char filepath[MAX_PATH*2]; + int total_ms; + WIN32_FIND_DATA fd; + + if (getcwd(_mp3DirectoryPath, MAX_PATH) == NULL) { + perror("getcwd: "); + return; + } + + OutputDebugString("Finding MP3s..."); + strcpy(path, _mp3DirectoryPath); + strcat(path, "\\MP3\\"); + + strcpy(_mp3DirectoryPath, path); + OutputDebugString(_mp3DirectoryPath); + + strcat(path, "*"); + + hFind = FindFirstFile(path, &fd); + + if ( hFind == INVALID_HANDLE_VALUE ) + { + return; + } + + strcpy(filepath, _mp3DirectoryPath); + strcat(filepath, fd.cFileName); + + size_t filepathlen = strlen(filepath); + + if ( filepathlen <= 0) + { + FindClose(hFind); + return; + } + + if ( _ResolveLink(filepath, filepath) ) + { + OutputDebugString("Resolving Link"); + OutputDebugString(filepath); + bShortcut = true; + } else + bShortcut = false; + + aStream[0] = new CStream(filepath, ALStreamSources[0], ALStreamBuffers[0]); + + if (aStream[0] && aStream[0]->IsOpened()) + { + total_ms = aStream[0]->GetLengthMS(); + delete aStream[0]; + aStream[0] = NULL; + + OutputDebugString(fd.cFileName); + + _pMP3List = new tMP3Entry; + + if ( _pMP3List == NULL ) + { + FindClose(hFind); + return; + } + + nNumMP3s = 1; + + strcpy(_pMP3List->aFilename, fd.cFileName); + + _pMP3List->nTrackLength = total_ms; + + _pMP3List->pNext = NULL; + + pList = _pMP3List; + + if ( bShortcut ) + { + _pMP3List->pLinkPath = new char[MAX_PATH*2]; + strcpy(_pMP3List->pLinkPath, filepath); + } + else + { + _pMP3List->pLinkPath = NULL; + } + + bInitFirstEntry = false; + } + else + { + strcat(filepath, " - NOT A VALID MP3"); + + OutputDebugString(filepath); + + bInitFirstEntry = true; + } + + while ( true ) + { + if ( !FindNextFile(hFind, &fd) ) + break; + + if ( bInitFirstEntry ) + { + strcpy(filepath, _mp3DirectoryPath); + strcat(filepath, fd.cFileName); + + size_t filepathlen = strlen(filepath); + + if ( filepathlen > 0 ) + { + if ( _ResolveLink(filepath, filepath) ) + { + OutputDebugString("Resolving Link"); + OutputDebugString(filepath); + bShortcut = true; + } else { + bShortcut = false; + if (filepathlen > MAX_PATH) { + continue; + } + } + aStream[0] = new CStream(filepath, ALStreamSources[0], ALStreamBuffers[0]); + + if (aStream[0] && aStream[0]->IsOpened()) + { + total_ms = aStream[0]->GetLengthMS(); + delete aStream[0]; + aStream[0] = NULL; + + OutputDebugString(fd.cFileName); + + _pMP3List = new tMP3Entry; + + if ( _pMP3List == NULL) + break; + + nNumMP3s = 1; + + strcpy(_pMP3List->aFilename, fd.cFileName); + + _pMP3List->nTrackLength = total_ms; + _pMP3List->pNext = NULL; + + if ( bShortcut ) + { + _pMP3List->pLinkPath = new char [MAX_PATH*2]; + strcpy(_pMP3List->pLinkPath, filepath); + } + else + { + _pMP3List->pLinkPath = NULL; + } + + pList = _pMP3List; + + bInitFirstEntry = false; + } + else + { + strcat(filepath, " - NOT A VALID MP3"); + OutputDebugString(filepath); + } + } + } + else + { + strcpy(filepath, _mp3DirectoryPath); + strcat(filepath, fd.cFileName); + + size_t filepathlen = strlen(filepath); + + if ( filepathlen > 0 ) + { + if ( _ResolveLink(filepath, filepath) ) + { + OutputDebugString("Resolving Link"); + OutputDebugString(filepath); + bShortcut = true; + } else + bShortcut = false; + + aStream[0] = new CStream(filepath, ALStreamSources[0], ALStreamBuffers[0]); + + if (aStream[0] && aStream[0]->IsOpened()) + { + total_ms = aStream[0]->GetLengthMS(); + delete aStream[0]; + aStream[0] = NULL; + + OutputDebugString(fd.cFileName); + + pList->pNext = new tMP3Entry; + + tMP3Entry *e = pList->pNext; + + if ( e == NULL ) + break; + + pList = pList->pNext; + + strcpy(e->aFilename, fd.cFileName); + e->nTrackLength = total_ms; + e->pNext = NULL; + + if ( bShortcut ) + { + e->pLinkPath = new char [MAX_PATH*2]; + strcpy(e->pLinkPath, filepath); + } + else + { + e->pLinkPath = NULL; + } + + nNumMP3s++; + + OutputDebugString(fd.cFileName); + } + else + { + strcat(filepath, " - NOT A VALID MP3"); + OutputDebugString(filepath); + } + } + } + } + + FindClose(hFind); +} + +static void +_DeleteMP3Entries(void) +{ + tMP3Entry *e = _pMP3List; + + while ( e != NULL ) + { + tMP3Entry *next = e->pNext; + + if ( next == NULL ) + next = NULL; + + if ( e->pLinkPath != NULL ) + { +#ifndef FIX_BUGS + delete e->pLinkPath; // BUG: should be delete [] +#else + delete[] e->pLinkPath; +#endif + e->pLinkPath = NULL; + } + + delete e; + + if ( next ) + e = next; + else + e = NULL; + + nNumMP3s--; + } + + + if ( nNumMP3s != 0 ) + { + OutputDebugString("Not all MP3 entries were deleted"); + nNumMP3s = 0; + } + + _pMP3List = NULL; +} + +static tMP3Entry * +_GetMP3EntryByIndex(uint32 idx) +{ + uint32 n = ( idx < nNumMP3s ) ? idx : 0; + + if ( _pMP3List != NULL ) + { + tMP3Entry *e = _pMP3List; + + for ( uint32 i = 0; i < n; i++ ) + e = e->pNext; + + return e; + + } + + return NULL; +} + +static inline bool +_GetMP3PosFromStreamPos(uint32 *pPosition, tMP3Entry **pEntry) +{ + _CurMP3Index = 0; + + for ( *pEntry = _pMP3List; *pEntry != NULL; *pEntry = (*pEntry)->pNext ) + { + if ( *pPosition >= (*pEntry)->nTrackStreamPos + && *pPosition < (*pEntry)->nTrackLength + (*pEntry)->nTrackStreamPos ) + { + *pPosition -= (*pEntry)->nTrackStreamPos; + _CurMP3Pos = *pPosition; + + return true; + } + + _CurMP3Index++; + } + + *pPosition = 0; + *pEntry = _pMP3List; + _CurMP3Pos = 0; + _CurMP3Index = 0; + + return false; +} + bool cSampleManager::IsMP3RadioChannelAvailable(void) { @@ -566,56 +989,15 @@ cSampleManager::Initialise(void) nChannelVolume[i] = 0; } - { - for ( int32 i = 0; i < MAX_STREAMS; i++ ) - { - aStream[i] = NULL; - nStreamVolume[i] = 100; - nStreamPan[i] = 63; - } - + { for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) nStreamLength[i] = 0; } - { add_providers(); - - if ( !InitialiseSampleBanks() ) - { - Terminate(); - return false; - } - - nSampleBankMemoryStartAddress[SFX_BANK_0] = (uintptr)malloc(nSampleBankSize[SFX_BANK_0]); - ASSERT(nSampleBankMemoryStartAddress[SFX_BANK_0] != 0); - - if ( nSampleBankMemoryStartAddress[SFX_BANK_0] == 0 ) - { - Terminate(); - return false; - } - - nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (uintptr)malloc(PED_BLOCKSIZE*MAX_PEDSFX); - ASSERT(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0); - } - - - { - _bSampmanInitialised = true; - - if ( 0 >= defaultProvider && defaultProvider < m_nNumberOfProviders ) - { - set_new_provider(defaultProvider); - } - else - { - Terminate(); - return false; - } - } + #ifdef AUDIO_CACHE - FILE *cacheFile = fopen("audio\\sound.cache", "rb"); + FILE *cacheFile = fcaseopen("audio\\sound.cache", "rb"); if (cacheFile) { fread(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); fclose(cacheFile); @@ -639,13 +1021,116 @@ cSampleManager::Initialise(void) USERERROR("Can't open '%s'\n", StreamedNameTable[i]); } #ifdef AUDIO_CACHE - cacheFile = fopen("audio\\sound.cache", "wb"); + cacheFile = fcaseopen("audio\\sound.cache", "wb"); fwrite(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); fclose(cacheFile); #endif } + + { + if ( !InitialiseSampleBanks() ) + { + Terminate(); + return false; + } - LoadSampleBank(SFX_BANK_0); + nSampleBankMemoryStartAddress[SFX_BANK_0] = (uintptr)malloc(nSampleBankSize[SFX_BANK_0]); + ASSERT(nSampleBankMemoryStartAddress[SFX_BANK_0] != 0); + + if ( nSampleBankMemoryStartAddress[SFX_BANK_0] == 0 ) + { + Terminate(); + return false; + } + + nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (uintptr)malloc(PED_BLOCKSIZE*MAX_PEDSFX); + ASSERT(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0); + + LoadSampleBank(SFX_BANK_0); + } + + { + for ( int32 i = 0; i < MAX_STREAMS; i++ ) + { + aStream[i] = NULL; + nStreamVolume[i] = 100; + nStreamPan[i] = 63; + } + } + + { + _bSampmanInitialised = true; + + if ( defaultProvider >= 0 && defaultProvider < m_nNumberOfProviders ) + { + set_new_provider(defaultProvider); + } + else + { + Terminate(); + return false; + } + } + + { + nNumMP3s = 0; + + _pMP3List = NULL; + + _FindMP3s(); + + if ( nNumMP3s != 0 ) + { + nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] = 0; + + for ( tMP3Entry *e = _pMP3List; e != NULL; e = e->pNext ) + { + e->nTrackStreamPos = nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER]; + nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] += e->nTrackLength; + } + + time_t t = time(NULL); + tm *localtm; + bool bUseRandomTable; + + if ( t == -1 ) + bUseRandomTable = true; + else + { + bUseRandomTable = false; + localtm = localtime(&t); + } + + int32 randval; + if ( bUseRandomTable ) + randval = AudioManager.GetRandomNumber(1); + else + randval = localtm->tm_sec * localtm->tm_min; + + _CurMP3Index = randval % nNumMP3s; + + tMP3Entry *randmp3 = _pMP3List; + for ( int32 i = randval % nNumMP3s; i > 0; --i) + randmp3 = randmp3->pNext; + + if ( bUseRandomTable ) + _CurMP3Pos = AudioManager.GetRandomNumber(0) % randmp3->nTrackLength; + else + { + if ( localtm->tm_sec > 0 ) + { + int32 s = localtm->tm_sec; + _CurMP3Pos = s*s*s*s*s*s*s*s % randmp3->nTrackLength; + } + else + _CurMP3Pos = AudioManager.GetRandomNumber(0) % randmp3->nTrackLength; + } + } + else + _CurMP3Pos = 0; + + _bIsMp3Active = false; + } return true; } @@ -653,8 +1138,6 @@ cSampleManager::Initialise(void) void cSampleManager::Terminate(void) { - release_existing(); - for (int32 i = 0; i < MAX_STREAMS; i++) { CStream *stream = aStream[i]; @@ -665,6 +1148,10 @@ cSampleManager::Terminate(void) } } + release_existing(); + + _DeleteMP3Entries(); + CStream::Terminate(); if ( nSampleBankMemoryStartAddress[SFX_BANK_0] != 0 ) @@ -752,7 +1239,7 @@ cSampleManager::SetMonoMode(uint8 nMode) bool cSampleManager::LoadSampleBank(uint8 nBank) { - ASSERT( nBank < MAX_SFX_BANKS ); + ASSERT( nBank < MAX_SFX_BANKS); if ( CTimer::GetIsCodePaused() ) return false; @@ -793,7 +1280,7 @@ cSampleManager::LoadSampleBank(uint8 nBank) void cSampleManager::UnloadSampleBank(uint8 nBank) { - ASSERT( nBank < MAX_SFX_BANKS ); + ASSERT( nBank < MAX_SFX_BANKS); bSampleBankLoaded[nBank] = false; } @@ -801,7 +1288,7 @@ cSampleManager::UnloadSampleBank(uint8 nBank) bool cSampleManager::IsSampleBankLoaded(uint8 nBank) { - ASSERT( nBank < MAX_SFX_BANKS ); + ASSERT( nBank < MAX_SFX_BANKS); return bSampleBankLoaded[nBank]; } @@ -1225,7 +1712,7 @@ cSampleManager::StopChannel(uint32 nChannel) void cSampleManager::PreloadStreamedFile(uint8 nFile, uint8 nStream) { - char filename[256]; + char filename[MAX_PATH]; ASSERT( nStream < MAX_STREAMS ); @@ -1283,6 +1770,7 @@ cSampleManager::StartPreloadedStreamedFile(uint8 nStream) bool cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) { + uint32 position = nPos; char filename[256]; ASSERT( nStream < MAX_STREAMS ); @@ -1295,6 +1783,135 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) aStream[nStream] = NULL; } + if ( nFile == STREAMED_SOUND_RADIO_MP3_PLAYER ) + { + uint32 i = 0; + do { + if(i != 0 || _bIsMp3Active) { + if(++_CurMP3Index >= nNumMP3s) _CurMP3Index = 0; + + _CurMP3Pos = 0; + + tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index); + + if(mp3) { + mp3 = _pMP3List; + if(mp3 == NULL) { + _bIsMp3Active = false; + nFile = 0; + strcat(filename, StreamedNameTable[nFile]); + + CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]); + ASSERT(stream != NULL); + + aStream[nStream] = stream; + + if (stream->IsOpened()) { + if (stream->Setup()) { + if (position != 0) + stream->SetPosMS(position); + + stream->Start(); + } + + return true; + } else { + delete stream; + aStream[nStream] = NULL; + } + + return false; + } + } + + if (mp3->pLinkPath != NULL) + aStream[nStream] = new CStream(mp3->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream]); + else { + strcpy(filename, _mp3DirectoryPath); + strcat(filename, mp3->aFilename); + + aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]); + } + + if (aStream[nStream]->IsOpened()) { + if (aStream[nStream]->Setup()) { + aStream[nStream]->Start(); + } + + return true; + } else { + delete aStream[nStream]; + aStream[nStream] = NULL; + } + + _bIsMp3Active = false; + continue; + } + if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] ) + position = 0; + + tMP3Entry *e; + if ( !_GetMP3PosFromStreamPos(&position, &e) ) + { + if ( e == NULL ) + { + nFile = 0; + strcat(filename, StreamedNameTable[nFile]); + CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]); + ASSERT(stream != NULL); + + aStream[nStream] = stream; + + if (stream->IsOpened()) { + if (stream->Setup()) { + if (position != 0) + stream->SetPosMS(position); + + stream->Start(); + } + + return true; + } else { + delete stream; + aStream[nStream] = NULL; + } + + return false; + } + } + + if (e->pLinkPath != NULL) + aStream[nStream] = new CStream(e->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream]); + else { + strcpy(filename, _mp3DirectoryPath); + strcat(filename, e->aFilename); + + aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]); + } + + if (aStream[nStream]->IsOpened()) { + if (aStream[nStream]->Setup()) { + if (position != 0) + aStream[nStream]->SetPosMS(position); + + aStream[nStream]->Start(); + } + + _bIsMp3Active = true; + return true; + } else { + delete aStream[nStream]; + aStream[nStream] = NULL; + } + + _bIsMp3Active = false; + + } while(++i < nNumMP3s); + + position = 0; + nFile = 0; + } + strcpy(filename, StreamedNameTable[nFile]); CStream *stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]); @@ -1302,21 +1919,16 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) aStream[nStream] = stream; - if ( stream->IsOpened() ) - { - nStreamLength[nFile] = stream->GetLengthMS(); - if ( stream->Setup() ) - { - if ( nPos != 0 ) - stream->SetPosMS(nPos); - + if ( stream->IsOpened() ) { + if ( stream->Setup() ) { + if (position != 0) + stream->SetPosMS(position); + stream->Start(); } return true; - } - else - { + } else { delete stream; aStream[nStream] = NULL; } @@ -1468,5 +2080,4 @@ cSampleManager::InitialiseSampleBanks(void) return true; } - #endif diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index 3b46a110..e2f90a7c 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -2399,7 +2399,7 @@ bool CPad::GetAnaloguePadLeftJustUp(void) if ( X == 0 && oldfStickX < 0 ) { - oldfStickX = X; + oldfStickX = 0; return true; } @@ -2419,7 +2419,7 @@ bool CPad::GetAnaloguePadRightJustUp(void) if ( X == 0 && oldfStickX > 0 ) { - oldfStickX = X; + oldfStickX = 0; return true; } diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index af28aae7..816da6b9 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -84,10 +84,6 @@ static_assert(RADAR_TILE_SIZE == (RADAR_SIZE_Y / RADAR_NUM_TILES), "CRadar: not #define RADAR_MAX_SPEED (0.9f) #ifdef MENU_MAP -CRGBA CRadar::ArrowBlipColour1; -CRGBA CRadar::ArrowBlipColour2; -uint16 CRadar::MapLegendCounter; -uint16 CRadar::MapLegendList[NUM_MAP_LEGENDS]; int CRadar::TargetMarkerId = -1; CVector CRadar::TargetMarkerPos; #endif @@ -116,7 +112,7 @@ void RequestMapSection(int32 x, int32 y) void RemoveMapSection(int32 x, int32 y) { - if (x >= 0 && x <= 7 && y >= 0 && y <= 7) + if (x >= 0 && x <= RADAR_NUM_TILES - 1 && y >= 0 && y <= RADAR_NUM_TILES - 1) CStreaming::RemoveTxd(gRadarTxdIds[x + RADAR_NUM_TILES * y]); } @@ -709,6 +705,7 @@ void CRadar::DrawBlips() if (CMenuManager::bMenuMapActive) { CVector2D in, out; TransformRealWorldPointToRadarSpace(in, FindPlayerCentreOfWorld_NoSniperShift()); + LimitRadarPoint(in); TransformRadarPointToScreenSpace(out, in); DrawYouAreHereSprite(out.x, out.y); } @@ -782,14 +779,20 @@ void CRadar::DrawRadarMask() }; RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void*)FALSE); - RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDZERO); - RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE); RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEFLAT); RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); +#if !defined(GTA_PS2_STUFF) && defined(RWLIBS) + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + RwD3D8SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_ALWAYS); +#else + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDZERO); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE); +#endif CVector2D out[8]; CVector2D in; @@ -810,7 +813,10 @@ void CRadar::DrawRadarMask() CSprite2d::SetMaskVertices(8, (float *)out); RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::GetVertices(), 8); - }; + } +#if !defined(GTA_PS2_STUFF) && defined(RWLIBS) + RwD3D8SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER); +#endif } void CRadar::DrawRadarSection(int32 x, int32 y) @@ -860,46 +866,22 @@ void CRadar::DrawRadarSection(int32 x, int32 y) void CRadar::DrawRadarSprite(uint16 sprite, float x, float y, uint8 alpha) { RadarSprites[sprite]->Draw(CRect(x - SCREEN_SCALE_X(8.0f), y - SCREEN_SCALE_Y(8.0f), x + SCREEN_SCALE_X(8.0f), y + SCREEN_SCALE_Y(8.0f)), CRGBA(255, 255, 255, alpha)); -#ifdef MENU_MAP - if (CMenuManager::bMenuMapActive) { - bool alreadyThere = false; - for (int i = 0; i < NUM_MAP_LEGENDS; i++) { - if (MapLegendList[i] == sprite) - alreadyThere = true; - } - if (!alreadyThere) { - MapLegendList[MapLegendCounter] = sprite; - MapLegendCounter++; - } - } -#endif } void CRadar::DrawRotatingRadarSprite(CSprite2d* sprite, float x, float y, float angle, int32 alpha) { CVector curPosn[4]; - CVector oldPosn[4]; - - curPosn[0].x = x - SCREEN_SCALE_X(5.6f); - curPosn[0].y = y + SCREEN_SCALE_Y(5.6f); - - curPosn[1].x = x + SCREEN_SCALE_X(5.6f); - curPosn[1].y = y + SCREEN_SCALE_Y(5.6f); - - curPosn[2].x = x - SCREEN_SCALE_X(5.6f); - curPosn[2].y = y - SCREEN_SCALE_Y(5.6f); - - curPosn[3].x = x + SCREEN_SCALE_X(5.6f); - curPosn[3].y = y - SCREEN_SCALE_Y(5.6f); + const float sizeX = SCREEN_SCALE_X(8.0f); + const float correctedAngle = angle - PI / 4.f; + const float sizeY = SCREEN_SCALE_Y(8.0f); for (uint32 i = 0; i < 4; i++) { - oldPosn[i] = curPosn[i]; - - curPosn[i].x = x + (oldPosn[i].x - x) * Cos(angle) + (oldPosn[i].y - y) * Sin(angle); - curPosn[i].y = y - (oldPosn[i].x - x) * Sin(angle) + (oldPosn[i].y - y) * Cos(angle); + const float cornerAngle = i * HALFPI + correctedAngle; + curPosn[i].x = x + (0.0f * Cos(cornerAngle) + 1.0f * Sin(cornerAngle)) * sizeX; + curPosn[i].y = y - (0.0f * Sin(cornerAngle) - 1.0f * Cos(cornerAngle)) * sizeY; } - sprite->Draw(curPosn[2].x, curPosn[2].y, curPosn[3].x, curPosn[3].y, curPosn[0].x, curPosn[0].y, curPosn[1].x, curPosn[1].y, CRGBA(255, 255, 255, alpha)); + sprite->Draw(curPosn[3].x, curPosn[3].y, curPosn[2].x, curPosn[2].y, curPosn[0].x, curPosn[0].y, curPosn[1].x, curPosn[1].y, CRGBA(255, 255, 255, alpha)); } int32 CRadar::GetActualBlipArrayIndex(int32 i) @@ -925,43 +907,43 @@ uint32 CRadar::GetRadarTraceColour(uint32 color, bool bright) { int32 c; switch (color) { - case 0: + case RADAR_TRACE_RED: if (bright) c = 0x712B49FF; else c = 0x7F0000FF; break; - case 1: + case RADAR_TRACE_GREEN: if (bright) c = 0x5FA06AFF; else c = 0x007F00FF; break; - case 2: + case RADAR_TRACE_LIGHT_BLUE: if (bright) c = 0x80A7F3FF; else c = 0x00007FFF; break; - case 3: + case RADAR_TRACE_GRAY: if (bright) c = 0xE1E1E1FF; else c = 0x7F7F7FFF; break; - case 4: + case RADAR_TRACE_YELLOW: if (bright) c = 0xFFFF00FF; else c = 0x7F7F00FF; break; - case 5: + case RADAR_TRACE_MAGENTA: if (bright) c = 0xFF00FFFF; else c = 0x7F007FFF; break; - case 6: + case RADAR_TRACE_CYAN: if (bright) c = 0x00FFFFFF; else @@ -1215,21 +1197,6 @@ void CRadar::ShowRadarTraceWithHeight(float x, float y, uint32 size, uint8 red, CSprite2d::DrawRect(CRect(x - SCREEN_SCALE_X(size), y - SCREEN_SCALE_Y(size), SCREEN_SCALE_X(size) + x, SCREEN_SCALE_Y(size) + y), CRGBA(red, green, blue, alpha)); break; } -#ifdef MENU_MAP - // VC uses -1 for coords and -2 for entities but meh, I don't want to edit DrawBlips - if (CMenuManager::bMenuMapActive) { - bool alreadyThere = false; - for (int i = 0; i < NUM_MAP_LEGENDS; i++) { - if (MapLegendList[i] == -1) - alreadyThere = true; - } - if (!alreadyThere) { - MapLegendList[MapLegendCounter] = -1; - MapLegendCounter++; - ArrowBlipColour1 = CRGBA(red, green, blue, alpha); - } - } -#endif } void CRadar::Shutdown() @@ -1415,12 +1382,6 @@ CRadar::InitFrontEndMap() vec2DRadarOrigin.x = 0.0f; vec2DRadarOrigin.y = 0.0f; m_radarRange = 1000.0f; // doesn't mean anything, just affects the calculation in TransformRadarPointToScreenSpace - for (int i = 0; i < NUM_MAP_LEGENDS; i++) { - MapLegendList[i] = RADAR_SPRITE_NONE; - } - MapLegendCounter = 0; - ArrowBlipColour1 = CRGBA(0, 0, 0, 0); - ArrowBlipColour2 = CRGBA(0, 0, 0, 0); } void @@ -1448,7 +1409,6 @@ CRadar::DrawYouAreHereSprite(float x, float y) float bottom = y - SCREEN_SCALE_Y(24.0f); CentreSprite.Draw(CRect(left, top, right, bottom), CRGBA(255, 255, 255, 255)); } - MapLegendList[MapLegendCounter++] = RADAR_SPRITE_CENTRE; } void @@ -1465,8 +1425,8 @@ CRadar::ToggleTargetMarker(float x, float y) return; #endif ms_RadarTrace[nextBlip].m_eBlipType = BLIP_COORD; - ms_RadarTrace[nextBlip].m_nColor = 0x333333FF; - ms_RadarTrace[nextBlip].m_bDim = 1; + ms_RadarTrace[nextBlip].m_nColor = RADAR_TRACE_GRAY; + ms_RadarTrace[nextBlip].m_bDim = 0; ms_RadarTrace[nextBlip].m_bInUse = 1; ms_RadarTrace[nextBlip].m_Radius = 1.0f; CVector pos(x, y, CWorld::FindGroundZForCoord(x,y)); diff --git a/src/core/Radar.h b/src/core/Radar.h index ec2bacd0..793d62b0 100644 --- a/src/core/Radar.h +++ b/src/core/Radar.h @@ -49,6 +49,17 @@ enum eRadarSprite RADAR_SPRITE_COUNT }; +enum +{ + RADAR_TRACE_RED, + RADAR_TRACE_GREEN, + RADAR_TRACE_LIGHT_BLUE, + RADAR_TRACE_GRAY, + RADAR_TRACE_YELLOW, + RADAR_TRACE_MAGENTA, + RADAR_TRACE_CYAN +}; + enum { BLIP_MODE_TRIANGULAR_UP = 0, @@ -108,11 +119,6 @@ public: static float cachedCos; static float cachedSin; #ifdef MENU_MAP -#define NUM_MAP_LEGENDS 75 - static CRGBA ArrowBlipColour1; - static CRGBA ArrowBlipColour2; - static uint16 MapLegendList[NUM_MAP_LEGENDS]; - static uint16 MapLegendCounter; static int TargetMarkerId; static CVector TargetMarkerPos; diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 7c9b78f4..fcfd9bce 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -631,7 +631,7 @@ CPed::ApplyHeadShot(eWeaponType weaponType, CVector pos, bool evenOnPlayer) // BUG: This condition will always return true. Even fixing it won't work, because these states are unused. // if (m_nPedState != PED_PASSENGER || m_nPedState != PED_TAXI_PASSENGER) { - CPed::SetDie(ANIM_KO_SHOT_FRONT1, 4.0f, 0.0f); + SetDie(ANIM_KO_SHOT_FRONT1, 4.0f, 0.0f); // } bBodyPartJustCameOff = true; @@ -814,15 +814,15 @@ CPed::Avoid(void) // Get distance to ped we want to avoid CVector2D distToPed = CVector2D(nearestPed->GetPosition()) - testPosition; - if (distToPed.Magnitude() <= 1.0f && CPed::OurPedCanSeeThisOne((CEntity*)nearestPed)) { + if (distToPed.Magnitude() <= 1.0f && OurPedCanSeeThisOne((CEntity*)nearestPed)) { m_nPedStateTimer = CTimer::GetTimeInMilliseconds() + 500 + (m_randomSeed + 3 * CTimer::GetFrameCounter()) % 1000 / 5; m_fRotationDest += DEGTORAD(45.0f); if (!bIsLooking) { - CPed::SetLookFlag(nearestPed, false); - CPed::SetLookTimer(CGeneral::GetRandomNumberInRange(500, 800)); + SetLookFlag(nearestPed, false); + SetLookTimer(CGeneral::GetRandomNumberInRange(500, 800)); } } } @@ -861,8 +861,7 @@ CPed::ClearLookFlag(void) { m_lookTimer = CTimer::GetTimeInMilliseconds() + 4000; if (m_nPedState == PED_LOOK_HEADING || m_nPedState == PED_LOOK_ENTITY) { - RestorePreviousState(); - ClearLookFlag(); + ClearLook(); } } } @@ -985,7 +984,7 @@ CPed::Attack(void) weaponAnimAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ourWeapon->m_Anim2ToPlay, 8.0f); } - weaponAnimAssoc->SetFinishCallback(CPed::FinishedAttackCB, this); + weaponAnimAssoc->SetFinishCallback(FinishedAttackCB, this); weaponAnimAssoc->SetRun(); if (weaponAnimAssoc->currentTime == weaponAnimAssoc->hierarchy->totalLength) @@ -2900,7 +2899,7 @@ CPed::ReactToAttack(CEntity *attacker) #ifdef VC_PED_PORTS if (m_nPedState == PED_DRIVING && InVehicle() - && (m_pMyVehicle->pDriver == this || m_pMyVehicle->pDriver && m_pMyVehicle->pDriver->m_nPedState == PED_DRIVING)) { + && (m_pMyVehicle->pDriver == this || m_pMyVehicle->pDriver && m_pMyVehicle->pDriver->m_nPedState == PED_DRIVING && m_pMyVehicle->pDriver->m_objective != OBJECTIVE_LEAVE_CAR_AND_DIE)) { if (m_pMyVehicle->VehicleCreatedBy == RANDOM_VEHICLE && (m_pMyVehicle->GetStatus() == STATUS_SIMPLE || m_pMyVehicle->GetStatus() == STATUS_PHYSICS) @@ -4435,11 +4434,11 @@ CPed::SetEvasiveStep(CEntity *reason, uint8 animType) bool vehPressedHorn = false; if (neededTurn > PI) - neededTurn = 2 * PI - neededTurn; + neededTurn = TWOPI - neededTurn; CVehicle *veh = (CVehicle*)reason; if (reason->IsVehicle() && veh->m_vehType == VEHICLE_TYPE_CAR) { - if (veh->m_nCarHornTimer) { + if (veh->m_nCarHornTimer != 0) { vehPressedHorn = true; if (!IsPlayer()) animType = 1; @@ -4459,7 +4458,7 @@ CPed::SetEvasiveStep(CEntity *reason, uint8 animType) angleToFace += PI; if (angleToFace > PI) - angleToFace -= 2*PI; + angleToFace -= TWOPI; // We don't want to run towards car's direction float dangerZone = angleToFace - vehDirection; @@ -4467,16 +4466,15 @@ CPed::SetEvasiveStep(CEntity *reason, uint8 animType) // So, add or subtract 90deg (jump to left/right) according to that if (dangerZone <= 0.0f) - angleToFace = 0.5f*PI + vehDirection; + angleToFace = HALFPI + vehDirection; else - angleToFace = vehDirection - 0.5f*PI; + angleToFace = vehDirection - HALFPI; - if (animType == 2) - stepAnim = ANIM_HANDSCOWER; - else if (animType < 2) + stepAnim = NUM_ANIMS; + if (animType == 0 || animType == 1) stepAnim = ANIM_EV_STEP; - else - stepAnim = NUM_ANIMS; + else if (animType == 2) + stepAnim = ANIM_HANDSCOWER; } if (!RpAnimBlendClumpGetAssociation(GetClump(), stepAnim)) { CAnimBlendAssociation *stepAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, stepAnim, 8.0f); @@ -4506,7 +4504,7 @@ CPed::SetEvasiveDive(CPhysical *reason, uint8 onlyRandomJump) angleToFace = m_fRotationCur; CVehicle *veh = (CVehicle*) reason; - if (reason->IsVehicle() && veh->m_vehType == VEHICLE_TYPE_CAR && veh->m_nCarHornTimer && !IsPlayer()) { + if (reason->IsVehicle() && veh->m_vehType == VEHICLE_TYPE_CAR && veh->m_nCarHornTimer != 0 && !IsPlayer()) { onlyRandomJump = true; } @@ -8341,7 +8339,7 @@ CPed::KillPedWithCar(CVehicle *car, float impulse) CPad::GetPad(0)->StartShake(40000 / shakeFreq, shakeFreq); } bIsStanding = false; - damageDir = CPed::GetLocalDirection(-m_vecMoveSpeed); + damageDir = GetLocalDirection(-m_vecMoveSpeed); vehModel = (CVehicleModelInfo *)CModelInfo::GetModelInfo(car->GetModelIndex()); vehColModel = vehModel->GetColModel(); float carRightAndDistDotProd = DotProduct(distVec, car->GetRight()); @@ -8477,7 +8475,7 @@ CPed::KillPedWithCar(CVehicle *car, float impulse) pieceToDamage = PEDPIECE_MID; break; } - CPed::InflictDamage(car, killMethod, 1000.0f, pieceToDamage, damageDir); + InflictDamage(car, killMethod, 1000.0f, pieceToDamage, damageDir); if (DyingOrDead() && bIsPedDieAnimPlaying && !m_pCollidingEntity) { @@ -8507,8 +8505,8 @@ CPed::KillPedWithCar(CVehicle *car, float impulse) else damage = 30.0f; - CPed::InflictDamage(car, WEAPONTYPE_RAMMEDBYCAR, damage, PEDPIECE_TORSO, fallDirection); - CPed::SetFall(1000, (AnimationId)(fallDirection + ANIM_KO_SKID_FRONT), true); + InflictDamage(car, WEAPONTYPE_RAMMEDBYCAR, damage, PEDPIECE_TORSO, fallDirection); + SetFall(1000, (AnimationId)(fallDirection + ANIM_KO_SKID_FRONT), true); if (OnGround() && !m_pCollidingEntity && (!IsPlayer() || bHasHitWall || car->GetModelIndex() == MI_TRAIN || m_vecDamageNormal.z < -0.8f)) { @@ -9680,7 +9678,7 @@ CPed::ProcessControl(void) } else if (CTimer::GetTimeInMilliseconds() >= CWorld::Players[CWorld::PlayerInFocus].m_nLastBumpPlayerCarTimer || m_nPedStateTimer >= CTimer::GetTimeInMilliseconds()) { - CPed::SetDirectionToWalkAroundObject(collidingVeh); + SetDirectionToWalkAroundObject(collidingVeh); CWorld::Players[CWorld::PlayerInFocus].m_nLastBumpPlayerCarTimer = m_nPedStateTimer; } else if (m_fleeFrom != collidingVeh) { @@ -9906,7 +9904,7 @@ CPed::ProcessControl(void) SetHeading(m_fRotationCur); if (m_nPedState != PED_FALL && !bIsPedDieAnimPlaying) { - CPed::SetFall(1000, ANIM_KO_SKID_BACK, true); + SetFall(1000, ANIM_KO_SKID_BACK, true); } bIsInTheAir = false; } else if (m_vecDamageNormal.z > 0.4f) { @@ -10217,19 +10215,19 @@ CPed::ProcessControl(void) Flee(); break; case PED_FOLLOW_PATH: - CPed::FollowPath(); + FollowPath(); break; case PED_PAUSE: - CPed::Pause(); + Pause(); break; case PED_ATTACK: - CPed::Attack(); + Attack(); break; case PED_FIGHT: - CPed::Fight(); + Fight(); break; case PED_CHAT: - CPed::Chat(); + Chat(); break; case PED_AIM_GUN: if (m_pPointGunAt && m_pPointGunAt->IsPed() @@ -15982,7 +15980,7 @@ CPed::SeekCar(void) if (m_vehEnterType == CAR_DOOR_RF && vehToSeek->pPassengers[0]) { if (vehToSeek->pPassengers[0]->bDontDragMeOutCar) { if (IsPlayer()) - CPed::SetEnterCar(vehToSeek, m_vehEnterType); + SetEnterCar(vehToSeek, m_vehEnterType); } else { SetCarJack(vehToSeek); } @@ -16152,15 +16150,15 @@ CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk) case HITLEVEL_LOW: #ifndef VC_PED_PORTS if (direction == 2) { - CPed::SetFall(1000, ANIM_KO_SKID_BACK, false); + SetFall(1000, ANIM_KO_SKID_BACK, false); return; } #else if (direction == 2 && (!IsPlayer() || ((CGeneral::GetRandomNumber() & 1) && m_fHealth < 30.0f))) { - CPed::SetFall(1000, ANIM_KO_SKID_BACK, false); + SetFall(1000, ANIM_KO_SKID_BACK, false); return; } else if (direction != 2 && !IsPlayer() && (CGeneral::GetRandomNumber() & 1) && m_fHealth < 30.0f) { - CPed::SetFall(1000, ANIM_KO_SHOT_STOM, false); + SetFall(1000, ANIM_KO_SHOT_STOM, false); return; } #endif @@ -17366,12 +17364,12 @@ CPed::SetExitBoat(CVehicle *boat) CAnimManager::BlendAnimation(GetClump(), m_animGroup, ANIM_IDLE_STANCE, 100.0f); if (boat->GetModelIndex() == MI_SPEEDER && boat->IsUpsideDown()) { m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_CRAWLOUT_RHS, 8.0f); - m_pVehicleAnim->SetFinishCallback(CPed::PedSetOutCarCB, this); + m_pVehicleAnim->SetFinishCallback(PedSetOutCarCB, this); m_vehEnterType = CAR_DOOR_RF; m_nPedState = PED_EXIT_CAR; } else { m_vehEnterType = CAR_DOOR_RF; - CPed::PedSetOutCarCB(nil, this); + PedSetOutCarCB(nil, this); bIsStanding = true; m_pCurSurface = boat; m_pCurSurface->RegisterReference((CEntity**)&m_pCurSurface); diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 63bf0b06..a6e6bccf 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -41,13 +41,13 @@ CRGBA ODDJOB_COLOR(89, 115, 150, 255); CRGBA ODDJOB2_COLOR(156, 91, 40, 255); CRGBA MISSIONTITLE_COLOR(220, 172, 2, 255); -wchar CHud::m_HelpMessage[256]; -wchar CHud::m_LastHelpMessage[256]; +wchar CHud::m_HelpMessage[HELP_MSG_LENGTH]; +wchar CHud::m_LastHelpMessage[HELP_MSG_LENGTH]; uint32 CHud::m_HelpMessageState; uint32 CHud::m_HelpMessageTimer; int32 CHud::m_HelpMessageFadeTimer; -wchar CHud::m_HelpMessageToPrint[256]; -float CHud::m_fHelpMessageTime; +wchar CHud::m_HelpMessageToPrint[HELP_MSG_LENGTH]; +float CHud::m_HelpMessageDisplayTime; bool CHud::m_HelpMessageQuick; uint32 CHud::m_ZoneState; int32 CHud::m_ZoneFadeTimer; @@ -1047,14 +1047,14 @@ void CHud::DrawAfterFade() return; if (m_HelpMessage[0]) { - if (!CMessages::WideStringCompare(m_HelpMessage, m_LastHelpMessage, 256)) { + if (!CMessages::WideStringCompare(m_HelpMessage, m_LastHelpMessage, HELP_MSG_LENGTH)) { switch (m_HelpMessageState) { case 0: m_HelpMessageFadeTimer = 0; m_HelpMessageState = 2; m_HelpMessageTimer = 0; - CMessages::WideStringCopy(m_HelpMessageToPrint, m_HelpMessage, 256); - m_fHelpMessageTime = CMessages::GetWideStringLength(m_HelpMessage) * 0.05f + 3.0f; + CMessages::WideStringCopy(m_HelpMessageToPrint, m_HelpMessage, HELP_MSG_LENGTH); + m_HelpMessageDisplayTime = CMessages::GetWideStringLength(m_HelpMessage) * 0.05f + 3.0f; if (TheCamera.m_ScreenReductionPercentage == 0.0f) DMAudio.PlayFrontEndSound(SOUND_HUD, 0); @@ -1069,7 +1069,7 @@ void CHud::DrawAfterFade() default: break; } - CMessages::WideStringCopy(m_LastHelpMessage, m_HelpMessage, 256); + CMessages::WideStringCopy(m_LastHelpMessage, m_HelpMessage, HELP_MSG_LENGTH); } float fAlpha = 225.0f; @@ -1079,7 +1079,7 @@ void CHud::DrawAfterFade() case 1: fAlpha = 225.0f; m_HelpMessageFadeTimer = 600; - if (m_HelpMessageTimer > m_fHelpMessageTime * 1000.0f || m_HelpMessageQuick && m_HelpMessageTimer > 1500.0f) { + if (m_HelpMessageTimer > m_HelpMessageDisplayTime * 1000.0f || m_HelpMessageQuick && m_HelpMessageTimer > 1500.0f) { m_HelpMessageFadeTimer = 600; m_HelpMessageState = 3; } @@ -1105,7 +1105,7 @@ void CHud::DrawAfterFade() if (m_HelpMessageFadeTimer < 0) { m_HelpMessageState = 2; m_HelpMessageFadeTimer = 0; - CMessages::WideStringCopy(m_HelpMessageToPrint, m_LastHelpMessage, 256); + CMessages::WideStringCopy(m_HelpMessageToPrint, m_LastHelpMessage, HELP_MSG_LENGTH); } fAlpha = m_HelpMessageFadeTimer * 0.001f * 225.0f; break; @@ -1371,7 +1371,7 @@ void CHud::GetRidOfAllHudMessages() m_ZoneNameTimer = 0; m_pZoneName = nil; - for (int i = 0; i < 256; i++) { + for (int i = 0; i < HELP_MSG_LENGTH; i++) { m_HelpMessage[i] = 0; m_LastHelpMessage[i] = 0; m_HelpMessageToPrint[i] = 0; @@ -1381,7 +1381,7 @@ void CHud::GetRidOfAllHudMessages() m_HelpMessageFadeTimer = 0; m_HelpMessageState = 0; m_HelpMessageQuick = 0; - m_fHelpMessageTime = 1.0f; + m_HelpMessageDisplayTime = 1.0f; m_VehicleName = nil; m_pLastVehicleName = nil; m_pVehicleNameToPrint = nil; @@ -1389,7 +1389,7 @@ void CHud::GetRidOfAllHudMessages() m_VehicleFadeTimer = 0; m_VehicleState = 0; - for (int i = 0; i < 256; i++) + for (int i = 0; i < ARRAY_SIZE(m_Message); i++) m_Message[i] = 0; for (int i = 0; i < 6; i++) { @@ -1464,7 +1464,7 @@ void CHud::ReInitialise() { wchar LastBigMessage[6][128]; -void CHud::SetBigMessage(wchar *message, int16 style) +void CHud::SetBigMessage(wchar *message, uint16 style) { int i = 0; @@ -1495,10 +1495,10 @@ void CHud::SetBigMessage(wchar *message, int16 style) void CHud::SetHelpMessage(wchar *message, bool quick) { if (!CReplay::IsPlayingBack()) { - CMessages::WideStringCopy(m_HelpMessage, message, 256); + CMessages::WideStringCopy(m_HelpMessage, message, HELP_MSG_LENGTH); CMessages::InsertPlayerControlKeysInString(m_HelpMessage); - for (int i = 0; i < 256; i++) { + for (int i = 0; i < HELP_MSG_LENGTH; i++) { m_LastHelpMessage[i] = 0; } @@ -1510,7 +1510,7 @@ void CHud::SetHelpMessage(wchar *message, bool quick) void CHud::SetMessage(wchar *message) { int i = 0; - for (i = 0; i < 256; i++) { + for (i = 0; i < ARRAY_SIZE(m_Message); i++) { if (message[i] == 0) break; @@ -1522,7 +1522,7 @@ void CHud::SetMessage(wchar *message) void CHud::SetPagerMessage(wchar *message) { int i = 0; - for (i = 0; i < 256; i++) { + for (i = 0; i < ARRAY_SIZE(m_PagerMessage); i++) { if (message[i] == 0) break; diff --git a/src/render/Hud.h b/src/render/Hud.h index 701e47e2..bef73cc2 100644 --- a/src/render/Hud.h +++ b/src/render/Hud.h @@ -1,6 +1,8 @@ #pragma once #include "Sprite2d.h" +#define HELP_MSG_LENGTH 256 + enum eItems { ITEM_NONE = -1, @@ -36,14 +38,13 @@ class CHud { public: static CSprite2d Sprites[NUM_HUD_SPRITES]; - static wchar m_HelpMessage[256]; - static wchar m_LastHelpMessage[256]; + static wchar m_HelpMessage[HELP_MSG_LENGTH]; + static wchar m_LastHelpMessage[HELP_MSG_LENGTH]; static uint32 m_HelpMessageState; static uint32 m_HelpMessageTimer; static int32 m_HelpMessageFadeTimer; - static wchar m_HelpMessageToPrint[256]; - static float &m_HelpMessageDisplayTime; - static float m_fHelpMessageTime; + static wchar m_HelpMessageToPrint[HELP_MSG_LENGTH]; + static float m_HelpMessageDisplayTime; static bool m_HelpMessageQuick; static uint32 m_ZoneState; static int32 m_ZoneFadeTimer; @@ -88,7 +89,7 @@ public: static void GetRidOfAllHudMessages(); static void Initialise(); static void ReInitialise(); - static void SetBigMessage(wchar *message, int16 style); + static void SetBigMessage(wchar *message, uint16 style); static void SetHelpMessage(wchar *message, bool quick); static void SetMessage(wchar *message); static void SetPagerMessage(wchar *message); diff --git a/src/render/Particle.cpp b/src/render/Particle.cpp index a867ae13..acce946b 100644 --- a/src/render/Particle.cpp +++ b/src/render/Particle.cpp @@ -302,8 +302,8 @@ void CParticle::Initialise() { float angle = DEGTORAD(float(i) * float(360.0f / SIN_COS_TABLE_SIZE)); - m_SinTable[i] = Sin(angle); - m_CosTable[i] = Cos(angle); + m_SinTable[i] = ::Sin(angle); + m_CosTable[i] = ::Cos(angle); } int32 slot = CTxdStore::FindTxdSlot("particle"); diff --git a/src/render/WaterCannon.cpp b/src/render/WaterCannon.cpp index 2b34db37..f54b31b9 100644 --- a/src/render/WaterCannon.cpp +++ b/src/render/WaterCannon.cpp @@ -64,7 +64,7 @@ void CWaterCannon::Update_OncePerFrame(int16 index) if (CTimer::GetTimeInMilliseconds() > m_nTimeCreated + WATERCANNON_LIFETIME ) { - m_nCur = (m_nCur + 1) % -NUM_SEGMENTPOINTS; + m_nCur = (m_nCur + 1) % NUM_SEGMENTPOINTS; m_abUsed[m_nCur] = false; } @@ -124,7 +124,7 @@ void CWaterCannon::Render(void) RwIm3DVertexSetV(&WaterCannonVertices[2], v); RwIm3DVertexSetV(&WaterCannonVertices[3], v); - int16 pointA = m_nCur % -NUM_SEGMENTPOINTS; + int16 pointA = m_nCur % NUM_SEGMENTPOINTS; int16 pointB = pointA - 1; if ( (pointA - 1) < 0 ) diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp index f568532a..fca5b4a4 100644 --- a/src/rw/RwHelper.cpp +++ b/src/rw/RwHelper.cpp @@ -431,11 +431,13 @@ CameraSize(RwCamera * camera, RwRect * rect, } } - if (( origSize.w != rect->w ) && ( origSize.h != rect->h )) + if (( origSize.w != rect->w ) || ( origSize.h != rect->h )) { RwRaster *raster; RwRaster *zRaster; + // BUG: game just changes camera raster's sizes, but this is a hack +#ifdef FIX_BUGS /* * Destroy rasters... */ @@ -493,6 +495,13 @@ CameraSize(RwCamera * camera, RwRect * rect, RwCameraSetRaster(camera, raster); RwCameraSetZRaster(camera, zRaster); } +#else + raster = RwCameraGetRaster(camera); + zRaster = RwCameraGetZRaster(camera); + + raster->width = zRaster->width = rect->w; + raster->height = zRaster->height = rect->h; +#endif } /* Figure out the view window */ diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index cdb73992..4d41a900 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -418,7 +418,7 @@ psInitialize(void) } else if ( verInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) { - if ( verInfo.dwMajorVersion > 4 || verInfo.dwMajorVersion == 4 && verInfo.dwMinorVersion == 1 ) + if ( verInfo.dwMajorVersion > 4 || verInfo.dwMajorVersion == 4 && verInfo.dwMinorVersion != 0 ) { debug("Operating System is Win98\n"); _dwOperatingSystemVersion = OS_WIN98; @@ -1220,14 +1220,17 @@ void resizeCB(GLFWwindow* window, int width, int height) { * memory things don't work. */ /* redraw window */ - if (RwInitialised && (gGameState == GS_PLAYING_GAME #ifndef MASTER - || gGameState == GS_ANIMVIEWER -#endif - )) + if (RwInitialised && (gGameState == GS_PLAYING_GAME || gGameState == GS_ANIMVIEWER)) { - RsEventHandler((gGameState == GS_PLAYING_GAME ? rsIDLE : rsANIMVIEWER), (void*)TRUE); + RsEventHandler((gGameState == GS_PLAYING_GAME ? rsIDLE : rsANIMVIEWER), (void *)TRUE); } +#else + if (RwInitialised && gGameState == GS_PLAYING_GAME) + { + RsEventHandler(rsIDLE, (void *)TRUE); + } +#endif if (RwInitialised && height > 0 && width > 0) { RwRect r; diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp index ac46d23a..9effaa31 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -684,7 +684,7 @@ psInitialize(void) } else if ( verInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) { - if ( verInfo.dwMajorVersion > 4 || verInfo.dwMajorVersion == 4 && verInfo.dwMinorVersion == 1 ) + if ( verInfo.dwMajorVersion > 4 || verInfo.dwMajorVersion == 4 && verInfo.dwMinorVersion != 0 ) { debug("Operating System is Win98\n"); _dwOperatingSystemVersion = OS_WIN98; @@ -1012,11 +1012,17 @@ MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) RECT rect; /* redraw window */ +#ifndef MASTER if (RwInitialised && (gGameState == GS_PLAYING_GAME || gGameState == GS_ANIMVIEWER)) { RsEventHandler((gGameState == GS_PLAYING_GAME ? rsIDLE : rsANIMVIEWER), (void *)TRUE); } - +#else + if (RwInitialised && gGameState == GS_PLAYING_GAME) + { + RsEventHandler(rsIDLE, (void *)TRUE); + } +#endif /* Manually resize window */ rect.left = rect.top = 0; rect.bottom = newPos->bottom - newPos->top; @@ -1369,14 +1375,20 @@ UINT GetBestRefreshRate(UINT width, UINT height, UINT depth) #endif if ( mode.Width == width && mode.Height == height && mode.Format == format ) { - if ( mode.RefreshRate == 0 ) + if ( mode.RefreshRate == 0 ) { + // From VC +#ifdef FIX_BUGS + d3d->Release(); +#endif return 0; + } if ( mode.RefreshRate < refreshRate && mode.RefreshRate >= 60 ) refreshRate = mode.RefreshRate; } } + // From VC #ifdef FIX_BUGS d3d->Release(); #endif From 0eb4aca1d64c16bcbf2c48dfeae05ac9adf39d73 Mon Sep 17 00:00:00 2001 From: erorcun Date: Sun, 18 Oct 2020 20:09:55 +0300 Subject: [PATCH 13/60] Fix build --- src/audio/sampman_miles.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp index 392bface..185e08d6 100644 --- a/src/audio/sampman_miles.cpp +++ b/src/audio/sampman_miles.cpp @@ -2176,8 +2176,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) if ( mp3Stream[nStream] ) { AIL_set_stream_loop_count(mp3Stream[nStream], 1); - AIL_set_stream_loop_count(mp3Stream[nStream], nStreamLoopedFlag[nStream] ? 0 : 1); - nStreamLoopedFlag[nStream] = true; + AIL_set_stream_ms_position(mp3Stream[nStream], position); AIL_pause_stream(mp3Stream[nStream], 0); return true; } @@ -2332,4 +2331,4 @@ cSampleManager::InitialiseSampleBanks(void) return true; } -#endif \ No newline at end of file +#endif From 7ae25761d5f60c78631bfafa3fc10ac7199f3039 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Sun, 18 Oct 2020 19:57:39 +0200 Subject: [PATCH 14/60] Tweak comparison in CFallingGlassPane::Render --- src/render/Glass.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/render/Glass.cpp b/src/render/Glass.cpp index aabb6e52..0b25525e 100644 --- a/src/render/Glass.cpp +++ b/src/render/Glass.cpp @@ -1,4 +1,4 @@ -#include "common.h" +#include "common.h" #include "Glass.h" #include "Timer.h" @@ -138,7 +138,11 @@ CFallingGlassPane::Render(void) fwdNorm.Normalise(); uint8 alpha = CGlass::CalcAlphaWithNormal(&fwdNorm); - int32 time = clamp(CTimer::GetTimeInMilliseconds() - m_nTimer, 0, 500); +#ifdef FIX_BUGS + uint16 time = clamp(CTimer::GetTimeInMilliseconds() > m_nTimer ? CTimer::GetTimeInMilliseconds() - m_nTimer : 0u, 0u, 500u); +#else + uint16 time = clamp(CTimer::GetTimeInMilliseconds() - m_nTimer, 0, 500); +#endif uint8 color = int32( float(alpha) * (float(time) / 500) ); From af53267b74c4e831787761ae12472a98ada110b0 Mon Sep 17 00:00:00 2001 From: erorcun Date: Wed, 21 Oct 2020 03:11:10 +0300 Subject: [PATCH 15/60] Text and cross-platform fix --- src/skel/crossplatform.cpp | 41 +++++++++++++++++++++----------------- src/text/Messages.cpp | 38 ++++++++++++++++++----------------- 2 files changed, 43 insertions(+), 36 deletions(-) diff --git a/src/skel/crossplatform.cpp b/src/skel/crossplatform.cpp index ac4bbe85..626403f8 100644 --- a/src/skel/crossplatform.cpp +++ b/src/skel/crossplatform.cpp @@ -26,34 +26,39 @@ void GetLocalTime_CP(SYSTEMTIME *out) { // Compatible with Linux/POSIX and MinGW on Windows #ifndef _WIN32 HANDLE FindFirstFile(const char* pathname, WIN32_FIND_DATA* firstfile) { - char newpathname[32]; + char pathCopy[32]; - strncpy(newpathname, pathname, 32); - char* path = strtok(newpathname, "*"); + strncpy(pathCopy, pathname, 32); + char* folder = strtok(pathCopy, "*"); // Case-sensitivity and backslashes... - char *real = casepath(path); - if (real) { - real[strlen(real)] = '*'; - char *extension = strtok(NULL, "*"); - if (extension) - strcat(real, extension); + char *realFolder = casepath(folder); + char *extension = nil; + if (realFolder) { + realFolder[strlen(realFolder)] = '*'; + extension = strtok(NULL, "*"); + if (extension) { + strcat(realFolder, extension); + } - strncpy(newpathname, real, 32); - free(real); - path = strtok(newpathname, "*"); + strncpy(pathCopy, realFolder, 32); + free(realFolder); + folder = strtok(pathCopy, "*"); + } else { + // Wildcard (*) + if (strlen(folder) + 1 != strlen(pathname)) + extension = strtok(NULL, "*"); } - strncpy(firstfile->folder, path, sizeof(firstfile->folder)); + strncpy(firstfile->folder, folder, sizeof(firstfile->folder)); - // Both w/ extension and w/o extension is ok - if (strlen(path) + 1 != strlen(pathname)) - strncpy(firstfile->extension, strtok(NULL, "*"), sizeof(firstfile->extension)); + if (extension) + strncpy(firstfile->extension, extension, sizeof(firstfile->extension)); else - strncpy(firstfile->extension, "", sizeof(firstfile->extension)); + firstfile->extension[0] = '\0'; HANDLE d; - if ((d = (HANDLE)opendir(path)) == NULL || !FindNextFile(d, firstfile)) + if ((d = (HANDLE)opendir(folder)) == NULL || !FindNextFile(d, firstfile)) return NULL; return d; diff --git a/src/text/Messages.cpp b/src/text/Messages.cpp index 82ab294c..2e0323eb 100644 --- a/src/text/Messages.cpp +++ b/src/text/Messages.cpp @@ -69,10 +69,7 @@ CMessages::WideStringCompare(wchar *str1, wchar *str2, uint16 size) if (len1 != len2 && (len1 < size || len2 < size)) return false; - for (int32 i = 0; i < size; i++) { - if (FixupChar(str1[i]) == '\0') - break; - + for (int32 i = 0; FixupChar(str1[i]) != '\0' && i < size; i++) { if (FixupChar(str1[i]) != FixupChar(str2[i])) return false; } @@ -328,9 +325,7 @@ void CMessages::AddToPreviousBriefArray(wchar *text, int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6, wchar *string) { int32 i = 0; - while (i < NUMPREVIOUSBRIEFS) { - if (PreviousBriefs[i].m_pText == nil) - break; + for (i = 0; PreviousBriefs[i].m_pText && i < NUMPREVIOUSBRIEFS; i++) { if (PreviousBriefs[i].m_nNumber[0] == n1 && PreviousBriefs[i].m_nNumber[1] == n2 && PreviousBriefs[i].m_nNumber[2] == n3 @@ -340,8 +335,6 @@ CMessages::AddToPreviousBriefArray(wchar *text, int32 n1, int32 n2, int32 n3, in && PreviousBriefs[i].m_pText == text && PreviousBriefs[i].m_pString == string) return; - - i++; } if (i != 0) { @@ -374,6 +367,14 @@ CMessages::InsertNumberInString(wchar *str, int32 n1, int32 n2, int32 n3, int32 return; } + sprintf(numStr, "%d", n1); + size_t outLen = strlen(numStr); + AsciiToUnicode(numStr, wNumStr); + if (str[0] == 0) { + *outstr = '\0'; + return; + } + int32 size = GetWideStringLength(str); int32 i = 0; @@ -385,6 +386,11 @@ CMessages::InsertNumberInString(wchar *str, int32 n1, int32 n2, int32 n3, int32 #else if (str[c] == '~' && str[c + 1] == '1' && str[c + 2] == '~') { #endif + c += 3; + for (int j = 0; j < outLen; j++) + *(outstr++) = wNumStr[j++]; + + i++; switch (i) { case 0: sprintf(numStr, "%d", n1); break; case 1: sprintf(numStr, "%d", n2); break; @@ -393,14 +399,8 @@ CMessages::InsertNumberInString(wchar *str, int32 n1, int32 n2, int32 n3, int32 case 4: sprintf(numStr, "%d", n5); break; case 5: sprintf(numStr, "%d", n6); break; } - i++; + outLen = strlen(numStr); AsciiToUnicode(numStr, wNumStr); - - int j = 0; - while (wNumStr[j] != '\0') - *(outstr++) = wNumStr[j++]; - - c += 3; } else { *(outstr++) = str[c++]; } @@ -466,10 +466,12 @@ CMessages::InsertPlayerControlKeysInString(wchar *str) if (str[i] == '~' && str[i + 1] == 'k' && str[i + 2] == '~') { #endif i += 4; - for (int32 cont = 0; cont < MAX_CONTROLLERACTIONS; cont++) { + bool done = false; + for (int32 cont = 0; cont < MAX_CONTROLLERACTIONS && !done; cont++) { uint16 contSize = GetWideStringLength(ControlsManager.m_aActionNames[cont]); if (contSize != 0) { if (WideStringCompare(&str[i], ControlsManager.m_aActionNames[cont], contSize)) { + done = true; ControlsManager.GetWideStringOfCommandKeys(cont, keybuf, 256); uint16 keybuf_size = GetWideStringLength(keybuf); for (uint16 j = 0; j < keybuf_size; j++) { @@ -751,7 +753,7 @@ CMessages::ClearThisPrint(wchar *str) } BriefMessages[i].m_pText = nil; BriefMessages[0].m_nStartTime = CTimer::GetTimeInMilliseconds(); - if (BriefMessages[0].m_pText == nil) + if (BriefMessages[0].m_pText != nil) AddToPreviousBriefArray( BriefMessages[0].m_pText, BriefMessages[0].m_nNumber[0], From 632569cff3e109d2de69e5cd5df2c25d3a657a8d Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Wed, 21 Oct 2020 19:48:13 +0300 Subject: [PATCH 16/60] Pickup fixes --- src/control/Pickups.cpp | 54 +++++++++++++++++++++++++---------------- src/control/Pickups.h | 5 ++-- 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp index 78084624..6fea43fb 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -54,20 +54,15 @@ uint8 aWeaponGreens[] = { 0, 255, 128, 255, 0, 255, 128, 255, 0, 255, 255, 0, 25 uint8 aWeaponBlues[] = { 0, 0, 255, 0, 255, 255, 0, 128, 255, 0, 255, 0, 128, 255, 0, 0 }; float aWeaponScale[] = { 1.0f, 2.0f, 1.5f, 1.0f, 1.0f, 1.5f, 1.0f, 2.0f, 1.0f, 2.0f, 2.5f, 1.0f, 1.0f, 1.0f, 1.0f }; -void -CPickup::RemoveKeepType() + +inline void +CPickup::Remove() { CWorld::Remove(m_pObject); delete m_pObject; m_bRemoved = true; m_pObject = nil; -} - -void -CPickup::Remove() -{ - RemoveKeepType(); m_eType = PICKUP_NONE; } @@ -131,7 +126,6 @@ CPickup::GiveUsAPickUpObject(int32 handle) bool CPickup::CanBePickedUp(CPlayerPed *player) { - assert(m_pObject != nil); bool cannotBePickedUp = (m_pObject->GetModelIndex() == MI_PICKUP_BODYARMOUR && player->m_fArmour > 99.5f) || (m_pObject->GetModelIndex() == MI_PICKUP_HEALTH && player->m_fHealth > 99.5f) @@ -144,6 +138,7 @@ bool CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId) { float waterLevel; + bool result = false; if (m_bRemoved) { if (CTimer::GetTimeInMilliseconds() > m_nTimer) { @@ -204,9 +199,12 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId) player->m_nSelectedWepSlot = player->GetWeaponSlot(CPickups::WeaponForModel(m_pObject->GetModelIndex())); DMAudio.PlayFrontEndSound(SOUND_PICKUP_WEAPON_BOUGHT, m_pObject->GetModelIndex() - MI_GRENADE); } - RemoveKeepType(); + result = true; + CWorld::Remove(m_pObject); + delete m_pObject; + m_pObject = nil; m_nTimer = CTimer::GetTimeInMilliseconds() + 5000; - return true; + m_bRemoved = true; } break; case PICKUP_ON_STREET: @@ -235,8 +233,12 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId) m_nTimer = CTimer::GetTimeInMilliseconds() + 720000; } - RemoveKeepType(); - return true; + result = true; + CWorld::Remove(m_pObject); + delete m_pObject; + m_pObject = nil; + m_bRemoved = true; + break; case PICKUP_ONCE: case PICKUP_ONCE_TIMEOUT: if (!CPickups::GivePlayerGoodiesWithPickUpMI(m_pObject->GetModelIndex(), playerId)) { @@ -247,8 +249,9 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId) } DMAudio.PlayFrontEndSound(SOUND_PICKUP_WEAPON, m_pObject->GetModelIndex() - MI_GRENADE); } + result = true; Remove(); - return true; + break; case PICKUP_COLLECTABLE1: CWorld::Players[playerId].m_nCollectedPackages++; CWorld::Players[playerId].m_nMoney += 1000; @@ -260,18 +263,20 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId) } else CGarages::TriggerMessage("CO_ONE", CWorld::Players[CWorld::PlayerInFocus].m_nCollectedPackages, 5000, CWorld::Players[CWorld::PlayerInFocus].m_nTotalPackages); + result = true; Remove(); DMAudio.PlayFrontEndSound(SOUND_PICKUP_HIDDEN_PACKAGE, 0); - return true; + break; case PICKUP_MONEY: CWorld::Players[playerId].m_nMoney += m_nQuantity; sprintf(gString, "$%d", m_nQuantity); #ifdef MONEY_MESSAGES CMoneyMessages::RegisterOne(m_vecPos + CVector(0.0f, 0.0f, 1.0f), gString, 0, 255, 0, 0.5f, 0.5f); #endif + result = true; Remove(); DMAudio.PlayFrontEndSound(SOUND_PICKUP_MONEY, 0); - return true; + break; default: break; } @@ -298,7 +303,9 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId) CVehicle *vehicle = CPools::GetVehiclePool()->GetSlot(i); if (vehicle != nil && vehicle->IsSphereTouchingVehicle(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z, 1.5f)) { touched = true; - break; // added break here +#ifdef FIX_BUGS + break; +#endif } } @@ -320,12 +327,17 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId) bool explode = false; if (CTimer::GetTimeInMilliseconds() > m_nTimer) explode = true; - else {// added else here since vehicle lookup is useless +#ifdef FIX_BUGS + else// added else here since vehicle lookup is useless +#endif + { for (int32 i = CPools::GetVehiclePool()->GetSize()-1; i >= 0; i--) { CVehicle *vehicle = CPools::GetVehiclePool()->GetSlot(i); if (vehicle != nil && vehicle->IsSphereTouchingVehicle(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z, 1.5f)) { explode = true; - break; // added break here +#ifdef FIX_BUGS + break; +#endif } } } @@ -352,8 +364,8 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId) m_pObject->UpdateRwFrame(); if (vehicle != nil && vehicle->IsSphereTouchingVehicle(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z, 2.0f)) { Remove(); + result = true; DMAudio.PlayFrontEndSound(SOUND_PICKUP_FLOAT_PACKAGE, 0); - return true; } break; default: break; @@ -361,7 +373,7 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId) } if (!m_bRemoved && (m_eType == PICKUP_ONCE_TIMEOUT || m_eType == PICKUP_MONEY) && CTimer::GetTimeInMilliseconds() > m_nTimer) Remove(); - return false; + return result; } void diff --git a/src/control/Pickups.h b/src/control/Pickups.h index b05f5db7..95eb6fbf 100644 --- a/src/control/Pickups.h +++ b/src/control/Pickups.h @@ -41,10 +41,9 @@ public: CObject *GiveUsAPickUpObject(int32 handle); bool Update(CPlayerPed *player, CVehicle *vehicle, int playerId); private: - bool IsMine() { return m_eType >= PICKUP_MINE_INACTIVE && m_eType <= PICKUP_FLOATINGPACKAGE_FLOATING; } + inline bool IsMine() { return m_eType >= PICKUP_MINE_INACTIVE && m_eType <= PICKUP_FLOATINGPACKAGE_FLOATING; } inline bool CanBePickedUp(CPlayerPed *player); - void RemoveKeepType(); - void Remove(); + inline void Remove(); }; VALIDATE_SIZE(CPickup, 0x1C); From bd8d8b53a3c724daf2e4bd2be24243aebd6b9e35 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Wed, 21 Oct 2020 21:26:10 +0300 Subject: [PATCH 17/60] CTempColModels small fix --- src/core/TempColModels.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/TempColModels.cpp b/src/core/TempColModels.cpp index ab73631d..f6796909 100644 --- a/src/core/TempColModels.cpp +++ b/src/core/TempColModels.cpp @@ -21,7 +21,11 @@ CColModel CTempColModels::ms_colModelBonnet1; CColSphere s_aPedSpheres[3]; CColSphere s_aPed2Spheres[3]; CColSphere s_aPedGSpheres[4]; +#ifdef FIX_BUGS +CColSphere s_aDoorSpheres[3]; +#else CColSphere s_aDoorSpheres[4]; +#endif CColSphere s_aBumperSpheres[4]; CColSphere s_aPanelSpheres[4]; CColSphere s_aBonnetSpheres[4]; @@ -129,7 +133,11 @@ CTempColModels::Initialise(void) s_aDoorSpheres[1].center = CVector(0.0f, -0.95f, -0.35f); s_aDoorSpheres[2].center = CVector(0.0f, -0.6f, 0.25f); +#ifdef FIX_BUGS for (i = 0; i < ARRAY_SIZE(s_aDoorSpheres); i++) { +#else + for (i = 0; i < ARRAY_SIZE(s_aPed2Spheres); i++) { +#endif s_aDoorSpheres[i].surface = SURFACE_CAR_PANEL; s_aDoorSpheres[i].piece = 0; } From 70f625d2116ac43615647e103dc5d000e276e4c8 Mon Sep 17 00:00:00 2001 From: erorcun Date: Wed, 21 Oct 2020 21:39:57 +0300 Subject: [PATCH 18/60] Message fix --- src/text/Messages.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/text/Messages.cpp b/src/text/Messages.cpp index 2e0323eb..e6216f5b 100644 --- a/src/text/Messages.cpp +++ b/src/text/Messages.cpp @@ -387,12 +387,11 @@ CMessages::InsertNumberInString(wchar *str, int32 n1, int32 n2, int32 n3, int32 if (str[c] == '~' && str[c + 1] == '1' && str[c + 2] == '~') { #endif c += 3; - for (int j = 0; j < outLen; j++) + for (int j = 0; j < outLen; ) *(outstr++) = wNumStr[j++]; i++; switch (i) { - case 0: sprintf(numStr, "%d", n1); break; case 1: sprintf(numStr, "%d", n2); break; case 2: sprintf(numStr, "%d", n3); break; case 3: sprintf(numStr, "%d", n4); break; From 94f0ecfa21ed4d260552b2717bff481f539422cb Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 22 Oct 2020 12:35:38 +0300 Subject: [PATCH 19/60] Police Radio fixes --- src/audio/AudioManager.h | 2 +- src/audio/DMAudio.cpp | 2 +- src/audio/PoliceRadio.cpp | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index a1aa96f5..46c099c4 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -432,7 +432,7 @@ public: void ReleaseDigitalHandle() const; void ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface1, uint8 surface2, float collisionPower, float intensity2); - void ReportCrime(int32 crime, const CVector *pos); + void ReportCrime(eCrimeType crime, const CVector &pos); void ResetAudioLogicTimers(uint32 timer); void ResetPoliceRadio(); void ResetTimers(uint32 time); diff --git a/src/audio/DMAudio.cpp b/src/audio/DMAudio.cpp index 17963cc9..74968e0d 100644 --- a/src/audio/DMAudio.cpp +++ b/src/audio/DMAudio.cpp @@ -203,7 +203,7 @@ cDMAudio::IsAudioInitialised(void) void cDMAudio::ReportCrime(eCrimeType crime, const CVector &pos) { - AudioManager.ReportCrime(crime, &pos); + AudioManager.ReportCrime(crime, pos); } int32 diff --git a/src/audio/PoliceRadio.cpp b/src/audio/PoliceRadio.cpp index 4d0f8909..673a3fcd 100644 --- a/src/audio/PoliceRadio.cpp +++ b/src/audio/PoliceRadio.cpp @@ -91,7 +91,7 @@ cAudioManager::InitialisePoliceRadio() m_sPoliceRadioQueue.policeChannelTimerSeconds = 0; m_sPoliceRadioQueue.policeChannelCounterSeconds = 0; for (int32 i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) - m_sPoliceRadioQueue.crimes[i].type = 0; + m_sPoliceRadioQueue.crimes[i].type = CRIME_NONE; SampleManager.SetChannelReverbFlag(policeChannel, 0); gSpecialSuspectLastSeenReport = false; @@ -154,7 +154,7 @@ cAudioManager::ServicePoliceRadio() if(!m_bIsInitialised) return; - if(!m_nUserPause) { + if(m_nUserPause == 0) { bool crimeReport = SetupCrimeReport(); #ifdef FIX_BUGS // Crash at 0x5fe6ef if(CReplay::IsPlayingBack() || !FindPlayerPed() || !FindPlayerPed()->m_pWanted) @@ -162,8 +162,8 @@ cAudioManager::ServicePoliceRadio() #endif wantedLevel = FindPlayerPed()->m_pWanted->m_nWantedLevel; if(!crimeReport) { - if(wantedLevel) { - if(nLastSeen) { + if(wantedLevel != 0) { + if(nLastSeen != 0) { --nLastSeen; } else { nLastSeen = m_anRandomTable[1] % 1000 + 2000; @@ -189,7 +189,7 @@ cAudioManager::ServicePoliceRadioChannel(int32 wantedLevel) if (!m_bIsInitialised) return; - if (m_nUserPause) { + if (m_nUserPause != 0) { if (SampleManager.GetChannelUsedFlag(policeChannel)) SampleManager.StopChannel(policeChannel); if (g_nMissionAudioSfx != TOTAL_AUDIO_SAMPLES && bMissionAudioPhysicalPlayingStatus == 1 && SampleManager.IsStreamPlaying(1)) { @@ -241,7 +241,7 @@ cAudioManager::ServicePoliceRadioChannel(int32 wantedLevel) } else { sample = TOTAL_AUDIO_SAMPLES; } - if (!wantedLevel) { + if (wantedLevel == 0) { if (gSpecialSuspectLastSeenReport) { gSpecialSuspectLastSeenReport = 0; } else if (((sample >= SFX_POLICE_RADIO_MESSAGE_NOISE_1) && (sample <= SFX_POLICE_RADIO_MESSAGE_NOISE_3)) || sample == TOTAL_AUDIO_SAMPLES) { @@ -675,7 +675,7 @@ cAudioManager::SetupSuspectLastSeenReport() void -cAudioManager::ReportCrime(int32 type, const CVector *pos) +cAudioManager::ReportCrime(eCrimeType type, const CVector &pos) { int32 lastCrime = ARRAY_SIZE(m_sPoliceRadioQueue.crimes); if (m_bIsInitialised && MusicManager.m_nMusicMode != MUSICMODE_CUTSCENE && FindPlayerPed()->m_pWanted->m_nWantedLevel > 0 && @@ -683,7 +683,7 @@ cAudioManager::ReportCrime(int32 type, const CVector *pos) for (int32 i = 0; i < ARRAY_SIZE(m_sPoliceRadioQueue.crimes); i++) { if (m_sPoliceRadioQueue.crimes[i].type) { if (m_sPoliceRadioQueue.crimes[i].type == type) { - m_sPoliceRadioQueue.crimes[i].position = *pos; + m_sPoliceRadioQueue.crimes[i].position = pos; m_sPoliceRadioQueue.crimes[i].timer = 0; return; } @@ -694,7 +694,7 @@ cAudioManager::ReportCrime(int32 type, const CVector *pos) if (lastCrime < ARRAY_SIZE(m_sPoliceRadioQueue.crimes)) { m_sPoliceRadioQueue.crimes[lastCrime].type = type; - m_sPoliceRadioQueue.crimes[lastCrime].position = *pos; + m_sPoliceRadioQueue.crimes[lastCrime].position = pos; m_sPoliceRadioQueue.crimes[lastCrime].timer = 0; gMinTimeToNextReport[type] = m_FrameCounter + 500; } From 86a7d4415bfa1467d11f2d9ad62d846366a9bc39 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 22 Oct 2020 22:03:27 +0300 Subject: [PATCH 20/60] Fix argument type --- src/audio/AudioManager.h | 2 +- src/audio/PoliceRadio.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 46c099c4..40a2d056 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -440,7 +440,7 @@ public: void Service(); void ServiceCollisions(); void ServicePoliceRadio(); - void ServicePoliceRadioChannel(int32 wantedLevel); + void ServicePoliceRadioChannel(uint8 wantedLevel); void ServiceSoundEffects(); int8 SetCurrent3DProvider(uint8 which); void SetDynamicAcousticModelingStatus(uint8 status); diff --git a/src/audio/PoliceRadio.cpp b/src/audio/PoliceRadio.cpp index 673a3fcd..665494a3 100644 --- a/src/audio/PoliceRadio.cpp +++ b/src/audio/PoliceRadio.cpp @@ -176,7 +176,7 @@ cAudioManager::ServicePoliceRadio() } void -cAudioManager::ServicePoliceRadioChannel(int32 wantedLevel) +cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel) { bool processed = false; uint32 sample; From bedc066cfd888226100c431886ef3c923a9a9950 Mon Sep 17 00:00:00 2001 From: erorcun Date: Fri, 23 Oct 2020 01:56:32 +0300 Subject: [PATCH 21/60] mr.casepath --- src/skel/crossplatform.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/skel/crossplatform.cpp b/src/skel/crossplatform.cpp index 626403f8..65cfde45 100644 --- a/src/skel/crossplatform.cpp +++ b/src/skel/crossplatform.cpp @@ -27,23 +27,24 @@ void GetLocalTime_CP(SYSTEMTIME *out) { #ifndef _WIN32 HANDLE FindFirstFile(const char* pathname, WIN32_FIND_DATA* firstfile) { char pathCopy[32]; + char constructedPath[32]; strncpy(pathCopy, pathname, 32); char* folder = strtok(pathCopy, "*"); - + // Case-sensitivity and backslashes... char *realFolder = casepath(folder); char *extension = nil; if (realFolder) { - realFolder[strlen(realFolder)] = '*'; + sprintf(constructedPath, "%s*", realFolder); extension = strtok(NULL, "*"); if (extension) { - strcat(realFolder, extension); + strcat(constructedPath, extension); } - - strncpy(pathCopy, realFolder, 32); + free(realFolder); - folder = strtok(pathCopy, "*"); + folder = strtok(constructedPath, "*"); + extension = strtok(NULL, "*"); } else { // Wildcard (*) if (strlen(folder) + 1 != strlen(pathname)) From 067200dd7eae890d6b0bfa98fc90fa80ca494a74 Mon Sep 17 00:00:00 2001 From: erorcun Date: Fri, 23 Oct 2020 04:37:01 +0300 Subject: [PATCH 22/60] mr.casepath 2 --- src/skel/crossplatform.cpp | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/src/skel/crossplatform.cpp b/src/skel/crossplatform.cpp index 65cfde45..f2f9d5ee 100644 --- a/src/skel/crossplatform.cpp +++ b/src/skel/crossplatform.cpp @@ -26,31 +26,23 @@ void GetLocalTime_CP(SYSTEMTIME *out) { // Compatible with Linux/POSIX and MinGW on Windows #ifndef _WIN32 HANDLE FindFirstFile(const char* pathname, WIN32_FIND_DATA* firstfile) { - char pathCopy[32]; - char constructedPath[32]; - - strncpy(pathCopy, pathname, 32); - char* folder = strtok(pathCopy, "*"); + char pathCopy[MAX_PATH]; + strcpy(pathCopy, pathname); + char *folder = strtok(pathCopy, "*"); + char *extension = strtok(NULL, "*"); + + // because strtok doesn't return NULL for last delimiter + if (extension - folder == strlen(pathname)) + extension = nil; + // Case-sensitivity and backslashes... + // Will be freed at the bottom char *realFolder = casepath(folder); - char *extension = nil; if (realFolder) { - sprintf(constructedPath, "%s*", realFolder); - extension = strtok(NULL, "*"); - if (extension) { - strcat(constructedPath, extension); - } - - free(realFolder); - folder = strtok(constructedPath, "*"); - extension = strtok(NULL, "*"); - } else { - // Wildcard (*) - if (strlen(folder) + 1 != strlen(pathname)) - extension = strtok(NULL, "*"); + folder = realFolder; } - + strncpy(firstfile->folder, folder, sizeof(firstfile->folder)); if (extension) @@ -58,8 +50,11 @@ HANDLE FindFirstFile(const char* pathname, WIN32_FIND_DATA* firstfile) { else firstfile->extension[0] = '\0'; + if (realFolder) + free(realFolder); + HANDLE d; - if ((d = (HANDLE)opendir(folder)) == NULL || !FindNextFile(d, firstfile)) + if ((d = (HANDLE)opendir(firstfile->folder)) == NULL || !FindNextFile(d, firstfile)) return NULL; return d; From f8a7f47fdeb4c99b745567dbe1d1cc37c4dd6bda Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 23 Oct 2020 13:06:40 +0300 Subject: [PATCH 23/60] Small CPedModelInfo fixes --- src/modelinfo/PedModelInfo.cpp | 46 +++++++++++----------------------- 1 file changed, 14 insertions(+), 32 deletions(-) diff --git a/src/modelinfo/PedModelInfo.cpp b/src/modelinfo/PedModelInfo.cpp index 117fd378..b77cccda 100644 --- a/src/modelinfo/PedModelInfo.cpp +++ b/src/modelinfo/PedModelInfo.cpp @@ -218,7 +218,6 @@ CPedModelInfo::CreateHitColModel(void) { RwObjectNameAssociation nameAssoc; RwObjectIdAssociation idAssoc; - CVector center; RwFrame *nodeFrame; CColModel *colmodel = new CColModel; CColSphere *spheres = (CColSphere*)RwMalloc(NUMPEDINFONODES*sizeof(CColSphere)); @@ -251,23 +250,17 @@ CPedModelInfo::CreateHitColModel(void) if(RwFrameGetParent(nodeFrame) == root) break; } - center.x = mat->pos.x + m_pColNodeInfos[i].x; - center.y = mat->pos.y + 0.0f; - center.z = mat->pos.z + m_pColNodeInfos[i].z; - spheres[i].Set(radius, center, SURFACE_PED, m_pColNodeInfos[i].pieceType); + spheres[i].center = mat->pos + CVector(m_pColNodeInfos[i].x, 0.0f, m_pColNodeInfos[i].z); + spheres[i].radius = radius; + spheres[i].surface = SURFACE_PED; + spheres[i].piece = m_pColNodeInfos[i].pieceType; } } RwMatrixDestroy(mat); colmodel->spheres = spheres; colmodel->numSpheres = NUMPEDINFONODES; - center.x = center.y = center.z = 0.0f; - colmodel->boundingSphere.Set(2.0f, center, 0, 0); - CVector min, max; - min.x = min.y = -0.5f; - min.z = -1.2f; - max.x = max.y = 0.5f; - max.z = 1.2f; - colmodel->boundingBox.Set(min, max, 0, 0); + colmodel->boundingSphere.Set(2.0f, CVector(0.0f, 0.0f, 0.0f), SURFACE_DEFAULT, 0); + colmodel->boundingBox.Set(CVector(-0.5f, -0.5f, -1.2f), CVector(0.5f, 0.5f, 1.2f), SURFACE_DEFAULT, 0); colmodel->level = LEVEL_GENERIC; m_hitColModel = colmodel; } @@ -303,9 +296,7 @@ CPedModelInfo::AnimatePedColModel(CColModel* colmodel, RwFrame* frame) break; } - spheres[i].center.x = mat->pos.x + m_pColNodeInfos[i].x; - spheres[i].center.y = mat->pos.y + 0.0f; - spheres[i].center.z = mat->pos.z + m_pColNodeInfos[i].z; + spheres[i].center = mat->pos + CVector(m_pColNodeInfos[i].x, 0.0f, m_pColNodeInfos[i].z); } } @@ -316,7 +307,6 @@ CPedModelInfo::AnimatePedColModel(CColModel* colmodel, RwFrame* frame) void CPedModelInfo::CreateHitColModelSkinned(RpClump *clump) { - CVector center; RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(clump); CColModel *colmodel = new CColModel; CColSphere *spheres = (CColSphere*)RwMalloc(NUMPEDINFONODES*sizeof(CColSphere)); @@ -335,23 +325,17 @@ CPedModelInfo::CreateHitColModelSkinned(RpClump *clump) RwV3d pos = { 0.0f, 0.0f, 0.0f }; RwV3dTransformPoints(&pos, &pos, 1, mat); - center.x = pos.x + m_pColNodeInfos[i].x; - center.y = pos.y + 0.0f; - center.z = pos.z + m_pColNodeInfos[i].z; - spheres[i].Set(m_pColNodeInfos[i].radius, center, SURFACE_PED, m_pColNodeInfos[i].pieceType); + spheres[i].center = pos + CVector(m_pColNodeInfos[i].x, 0.0f, m_pColNodeInfos[i].z); + spheres[i].radius = m_pColNodeInfos[i].radius; + spheres[i].surface = SURFACE_PED; + spheres[i].piece = m_pColNodeInfos[i].pieceType; } RwMatrixDestroy(invmat); RwMatrixDestroy(mat); colmodel->spheres = spheres; colmodel->numSpheres = NUMPEDINFONODES; - center.x = center.y = center.z = 0.0f; - colmodel->boundingSphere.Set(2.0f, center, 0, 0); - CVector min, max; - min.x = min.y = -0.5f; - min.z = -1.2f; - max.x = max.y = 0.5f; - max.z = 1.2f; - colmodel->boundingBox.Set(min, max, 0, 0); + colmodel->boundingSphere.Set(2.0f, CVector(0.0f, 0.0f, 0.0f), SURFACE_DEFAULT, 0); + colmodel->boundingBox.Set(CVector(-0.5f, -0.5f, -1.2f), CVector(0.5f, 0.5f, 1.2f), SURFACE_DEFAULT, 0); colmodel->level = LEVEL_GENERIC; m_hitColModel = colmodel; } @@ -379,9 +363,7 @@ CPedModelInfo::AnimatePedColModelSkinned(RpClump *clump) RwV3d pos = { 0.0f, 0.0f, 0.0f }; RwV3dTransformPoints(&pos, &pos, 1, mat); - spheres[i].center.x = pos.x + m_pColNodeInfos[i].x; - spheres[i].center.y = pos.y + 0.0f; - spheres[i].center.z = pos.z + m_pColNodeInfos[i].z; + spheres[i].center = pos + CVector(m_pColNodeInfos[i].x, 0.0f, m_pColNodeInfos[i].z); } RwMatrixDestroy(invmat); RwMatrixDestroy(mat); From 9f692ea3abd325495c084d1d3a5618987b7be401 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 23 Oct 2020 13:23:05 +0300 Subject: [PATCH 24/60] Missed nil --- src/text/Messages.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/text/Messages.cpp b/src/text/Messages.cpp index e6216f5b..c446a770 100644 --- a/src/text/Messages.cpp +++ b/src/text/Messages.cpp @@ -802,7 +802,7 @@ CMessages::ClearThisBigPrint(wchar *str) } BIGMessages[style].m_Stack[i].m_pText = nil; } else { - BIGMessages[style].m_Stack[0].m_pText = 0; + BIGMessages[style].m_Stack[0].m_pText = nil; i = 0; while (i < 3) { if (BIGMessages[style].m_Stack[i + 1].m_pText == nil) From d7b9884f9d4f6e516c9b72360414fede04884e95 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 23 Oct 2020 16:18:46 +0300 Subject: [PATCH 25/60] Use audio enum --- src/control/Script.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/control/Script.cpp b/src/control/Script.cpp index 50e89ecc..6bde6b87 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -8333,11 +8333,11 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) } case COMMAND_INDUSTRIAL_PASSED: CStats::IndustrialPassed = true; - DMAudio.PlayRadioAnnouncement(13); //TODO: enum? + DMAudio.PlayRadioAnnouncement(STREAMED_SOUND_ANNOUNCE_COMMERCIAL_OPEN); return 0; case COMMAND_COMMERCIAL_PASSED: CStats::CommercialPassed = true; - DMAudio.PlayRadioAnnouncement(14); //TODO: enum? + DMAudio.PlayRadioAnnouncement(STREAMED_SOUND_ANNOUNCE_SUBURBAN_OPEN); return 0; case COMMAND_SUBURBAN_PASSED: CStats::SuburbanPassed = true; From a492f8ba0d7bf4a740ed91ccd7820a3afd9a111b Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 24 Oct 2020 16:37:14 +0300 Subject: [PATCH 26/60] Fix playback of vanilla opus --- src/audio/oal/stream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index 3af50ea8..3adb702a 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -195,7 +195,7 @@ public: if (m_FileH) { m_nChannels = op_head(m_FileH, 0)->channel_count; - m_nRate = op_head(m_FileH, 0)->input_sample_rate; + m_nRate = 48000; const OpusTags *tags = op_tags(m_FileH, 0); for (int i = 0; i < tags->comments; i++) { if (strncmp(tags->user_comments[i], "SAMPLERATE", sizeof("SAMPLERATE")-1) == 0) From a32c390a954287e5918e5ea6297f6df7b75c1752 Mon Sep 17 00:00:00 2001 From: Adrian Graber Date: Sat, 24 Oct 2020 16:12:10 +0200 Subject: [PATCH 27/60] Join CdStream threads to wait for them to exit --- src/core/CdStreamPosix.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/CdStreamPosix.cpp b/src/core/CdStreamPosix.cpp index fdc63a05..5c8d1b16 100644 --- a/src/core/CdStreamPosix.cpp +++ b/src/core/CdStreamPosix.cpp @@ -216,10 +216,12 @@ CdStreamShutdown(void) #ifndef ONE_THREAD_PER_CHANNEL gCdStreamThreadStatus = 2; sem_post(gCdStreamSema); + pthread_join(_gCdStreamThread, nil); #else for ( int32 i = 0; i < gNumChannels; i++ ) { gpReadInfo[i].nThreadStatus = 2; sem_post(gpReadInfo[i].pStartSemaphore); + pthread_join(gpReadInfo[i].pChannelThread, nil); } #endif } From 92ae468e008438d4563c0ee005bba1977099abd6 Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 24 Oct 2020 21:56:04 +0300 Subject: [PATCH 28/60] Messages and CameraSize fix --- src/rw/RwHelper.cpp | 6 ++++-- src/text/Messages.cpp | 33 +++++++++------------------------ 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp index fca5b4a4..1c6c434c 100644 --- a/src/rw/RwHelper.cpp +++ b/src/rw/RwHelper.cpp @@ -437,7 +437,7 @@ CameraSize(RwCamera * camera, RwRect * rect, RwRaster *zRaster; // BUG: game just changes camera raster's sizes, but this is a hack -#ifdef FIX_BUGS +#if 0//def FIX_BUGS /* * Destroy rasters... */ @@ -446,12 +446,14 @@ CameraSize(RwCamera * camera, RwRect * rect, if( raster ) { RwRasterDestroy(raster); + camera->frameBuffer = nil; } zRaster = RwCameraGetZRaster(camera); if( zRaster ) { RwRasterDestroy(zRaster); + camera->zBuffer = nil; } /* @@ -657,4 +659,4 @@ RestoreAlphaTest() RwD3D8SetRenderState(D3DRS_ALPHAREF, saved_alpharef); #endif } -#endif \ No newline at end of file +#endif diff --git a/src/text/Messages.cpp b/src/text/Messages.cpp index c446a770..b68f918d 100644 --- a/src/text/Messages.cpp +++ b/src/text/Messages.cpp @@ -69,7 +69,7 @@ CMessages::WideStringCompare(wchar *str1, wchar *str2, uint16 size) if (len1 != len2 && (len1 < size || len2 < size)) return false; - for (int32 i = 0; FixupChar(str1[i]) != '\0' && i < size; i++) { + for (int32 i = 0; i < size && FixupChar(str1[i]) != '\0'; i++) { if (FixupChar(str1[i]) != FixupChar(str2[i])) return false; } @@ -97,13 +97,9 @@ CMessages::Process() if (BriefMessages[0].m_pText != nil && CTimer::GetTimeInMilliseconds() > BriefMessages[0].m_nTime + BriefMessages[0].m_nStartTime) { BriefMessages[0].m_pText = nil; - int32 i = 0; - while (i < NUMBRIEFMESSAGES-1) { - if (BriefMessages[i + 1].m_pText == nil) - break; - + int32 i; + for (i = 0; i < NUMBRIEFMESSAGES-1 && BriefMessages[i + 1].m_pText != nil; i++) { BriefMessages[i] = BriefMessages[i + 1]; - i++; } CMessages::BriefMessages[i].m_pText = nil; CMessages::BriefMessages[0].m_nStartTime = CTimer::GetTimeInMilliseconds(); @@ -325,7 +321,7 @@ void CMessages::AddToPreviousBriefArray(wchar *text, int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6, wchar *string) { int32 i = 0; - for (i = 0; PreviousBriefs[i].m_pText && i < NUMPREVIOUSBRIEFS; i++) { + for (i = 0; i < NUMPREVIOUSBRIEFS && PreviousBriefs[i].m_pText != nil; i++) { if (PreviousBriefs[i].m_nNumber[0] == n1 && PreviousBriefs[i].m_nNumber[1] == n2 && PreviousBriefs[i].m_nNumber[2] == n3 @@ -503,7 +499,7 @@ CMessages::AddMessageWithNumber(wchar *str, uint32 time, uint16 flag, int32 n1, GetWideStringLength(outstr); uint16 i = 0; - while (i < NUMBRIEFMESSAGES && BriefMessages[i].m_pText) + while (i < NUMBRIEFMESSAGES && BriefMessages[i].m_pText != nil) i++; if (i >= NUMBRIEFMESSAGES) return; @@ -720,35 +716,24 @@ CMessages::ClearThisPrint(wchar *str) do { equal = false; - uint16 i = 0; - while (i < NUMBRIEFMESSAGES) { - if (BriefMessages[i].m_pText == nil) - break; - + uint16 i; + for (i = 0; i < NUMBRIEFMESSAGES && BriefMessages[i].m_pText != nil; i++) { equal = FastWideStringComparison(str, BriefMessages[i].m_pText); if (equal) break; - i++; } if (equal) { if (i != 0) { BriefMessages[i].m_pText = nil; - while (i < NUMBRIEFMESSAGES-1) { - if (BriefMessages[i + 1].m_pText == nil) - break; - + for (; i < NUMBRIEFMESSAGES-1 && BriefMessages[i+1].m_pText != nil; i++) { BriefMessages[i] = BriefMessages[i + 1]; - i++; } BriefMessages[i].m_pText = nil; } else { BriefMessages[0].m_pText = nil; - while (i < NUMBRIEFMESSAGES-1) { - if (BriefMessages[i + 1].m_pText == nil) - break; + for (; i < NUMBRIEFMESSAGES-1 && BriefMessages[i+1].m_pText != nil; i++) { BriefMessages[i] = BriefMessages[i + 1]; - i++; } BriefMessages[i].m_pText = nil; BriefMessages[0].m_nStartTime = CTimer::GetTimeInMilliseconds(); From d0e80e8c97e14ef73d3acaf7ac992fe71b4e0fc9 Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 24 Oct 2020 23:56:21 +0300 Subject: [PATCH 29/60] librw update --- src/rw/RwHelper.cpp | 2 +- vendor/librw | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp index 1c6c434c..4b598e9b 100644 --- a/src/rw/RwHelper.cpp +++ b/src/rw/RwHelper.cpp @@ -437,7 +437,7 @@ CameraSize(RwCamera * camera, RwRect * rect, RwRaster *zRaster; // BUG: game just changes camera raster's sizes, but this is a hack -#if 0//def FIX_BUGS +#ifdef FIX_BUGS /* * Destroy rasters... */ diff --git a/vendor/librw b/vendor/librw index edc77742..ee2a32e1 160000 --- a/vendor/librw +++ b/vendor/librw @@ -1 +1 @@ -Subproject commit edc77742c512b85ad35544b2cfbe3f359dc75805 +Subproject commit ee2a32e142fa2d2a1bb6c4fed0c25c2f1e5a1129 From 5e5854b914d3b72855f872575adb13f7decca8b8 Mon Sep 17 00:00:00 2001 From: erorcun Date: Sun, 25 Oct 2020 01:05:07 +0300 Subject: [PATCH 30/60] Fix bindings not loaded on Linux --- src/core/re3.cpp | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 069320ec..98201d5a 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -32,6 +32,8 @@ #include "MBlur.h" #include "postfx.h" #include "custompipes.h" +#include "FileMgr.h" +#include "ControllerConfig.h" #ifndef _WIN32 #include "assert.h" @@ -275,7 +277,7 @@ wchar* DetectJoystickDraw(bool* disabled, bool userHovering) { const char *joyname; if (userHovering) { for (int i = 0; i <= GLFW_JOYSTICK_LAST; i++) { - if (joyname = glfwGetJoystickName(i)) { + if ((joyname = glfwGetJoystickName(i))) { const uint8* buttons = glfwGetJoystickButtons(i, &numButtons); for (int j = 0; j < numButtons; j++) { if (buttons[j]) { @@ -455,8 +457,34 @@ void LoadINISettings() char defaultStr[4]; #ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS + // Written by assuming the codes below will run after _InputInitialiseJoys(). strcpy(gSelectedJoystickName, cfg.get("DetectJoystick", "JoystickName", "").c_str()); - _InputInitialiseJoys(); + + if(gSelectedJoystickName[0] != '\0') { + for (int i = 0; i <= GLFW_JOYSTICK_LAST; i++) { + if (glfwJoystickPresent(i) && strncmp(gSelectedJoystickName, glfwGetJoystickName(i), strlen(gSelectedJoystickName)) == 0) { + if (PSGLOBAL(joy1id) != -1) { + PSGLOBAL(joy2id) = PSGLOBAL(joy1id); + } + PSGLOBAL(joy1id) = i; + int count; + glfwGetJoystickButtons(PSGLOBAL(joy1id), &count); + + // We need to init and reload bindings, because; + // 1-joypad button number may differ with saved/prvly connected one + // 2-bindings are not init'ed if there is no joypad at the start + ControlsManager.InitDefaultControlConfigJoyPad(count); + CFileMgr::SetDirMyDocuments(); + int32 gta3set = CFileMgr::OpenFile("gta3.set", "r"); + if (gta3set) { + ControlsManager.LoadSettings(gta3set); + CFileMgr::CloseFile(gta3set); + } + CFileMgr::SetDir(""); + break; + } + } + } #endif #ifdef CUSTOM_FRONTEND_OPTIONS From aac0c3fb679401eab584cf91c07bd4353022c91c Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 25 Oct 2020 09:39:04 +0200 Subject: [PATCH 31/60] DMAudio fixes --- src/audio/DMAudio.cpp | 29 +---------------------------- src/audio/DMAudio.h | 4 +--- src/core/Game.cpp | 29 ++++++++++++++++++++++++----- 3 files changed, 26 insertions(+), 36 deletions(-) diff --git a/src/audio/DMAudio.cpp b/src/audio/DMAudio.cpp index 74968e0d..b0d5745c 100644 --- a/src/audio/DMAudio.cpp +++ b/src/audio/DMAudio.cpp @@ -113,33 +113,6 @@ cDMAudio::Get3DProviderName(uint8 id) return AudioManager.Get3DProviderName(id); } -int8 cDMAudio::AutoDetect3DProviders(void) -{ - for ( int32 i = 0; i < GetNum3DProvidersAvailable(); i++ ) - { - wchar buff[64]; - -#ifdef AUDIO_OAL - if (defaultProvider >= 0 && defaultProvider < GetNum3DProvidersAvailable()) { - return i; - } -#endif - char *name = Get3DProviderName(i); - AsciiToUnicode(name, buff); - char *providername = UnicodeToAscii(buff); - strupr(providername); -#if defined(AUDIO_MSS) - if ( !strcmp(providername, "MILES FAST 2D POSITIONAL AUDIO") ) - return i; -#elif defined(AUDIO_OAL) - if ( !strcmp(providername, "OPENAL SOFT") ) - return i; -#endif - } - - return -1; -} - int8 cDMAudio::GetCurrent3DProviderIndex(void) { @@ -350,7 +323,7 @@ cDMAudio::SetRadioInCar(uint32 radio) } void -cDMAudio::SetRadioChannel(int8 radio, int32 pos) +cDMAudio::SetRadioChannel(uint8 radio, int32 pos) { MusicManager.SetRadioChannelByScript(radio, pos); } diff --git a/src/audio/DMAudio.h b/src/audio/DMAudio.h index bb95f303..3e6d5603 100644 --- a/src/audio/DMAudio.h +++ b/src/audio/DMAudio.h @@ -35,8 +35,6 @@ public: uint8 GetNum3DProvidersAvailable(void); char *Get3DProviderName(uint8 id); - int8 AutoDetect3DProviders(void); - int8 GetCurrent3DProviderIndex(void); int8 SetCurrent3DProvider(uint8 which); @@ -86,6 +84,6 @@ public: uint8 GetRadioInCar(void); void SetRadioInCar(uint32 radio); - void SetRadioChannel(int8 radio, int32 pos); + void SetRadioChannel(uint8 radio, int32 pos); }; extern cDMAudio DMAudio; diff --git a/src/core/Game.cpp b/src/core/Game.cpp index 93f0d1b0..1be62611 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -277,12 +277,31 @@ bool CGame::InitialiseOnceAfterRW(void) if ( DMAudio.GetNum3DProvidersAvailable() == 0 ) FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = -1; - if ( FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -99 || FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -2 ) - { + if ( FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -99 || FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -2 ) { CMenuManager::m_PrefsSpeakers = 0; - int8 provider = DMAudio.AutoDetect3DProviders(); - if ( provider != -1 ) - FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = provider; + int32 i; + for (i = 0; i < DMAudio.GetNum3DProvidersAvailable(); i++) { + wchar buff[64]; + +#ifdef AUDIO_OAL + extern int defaultProvider; + if (defaultProvider >= 0 && defaultProvider < DMAudio.GetNum3DProvidersAvailable()) + break; +#endif + char *name = DMAudio.Get3DProviderName(i); + AsciiToUnicode(name, buff); + char *providername = UnicodeToAscii(buff); + strupr(providername); +#if defined(AUDIO_MSS) + if (strcmp(providername, "MILES FAST 2D POSITIONAL AUDIO") == 0) + break; +#elif defined(AUDIO_OAL) + if (strcmp(providername, "OPENAL SOFT") == 0) + break; +#endif + } + + FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = i; } DMAudio.SetCurrent3DProvider(FrontEndMenuManager.m_nPrefsAudio3DProviderIndex); From 6634410aee114e125a9c0564b2c7dd67619df5fc Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 25 Oct 2020 09:50:17 +0200 Subject: [PATCH 32/60] Fix build --- src/core/re3.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 98201d5a..d5a8099d 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -32,8 +32,11 @@ #include "MBlur.h" #include "postfx.h" #include "custompipes.h" + +#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS #include "FileMgr.h" #include "ControllerConfig.h" +#endif #ifndef _WIN32 #include "assert.h" From e0394e6e69f90c87e57c4d6ba3451dd085e06bcf Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 25 Oct 2020 12:38:08 +0200 Subject: [PATCH 33/60] Possible fix of linux build --- src/audio/DMAudio.cpp | 1 - src/core/Game.cpp | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/DMAudio.cpp b/src/audio/DMAudio.cpp index b0d5745c..44c22610 100644 --- a/src/audio/DMAudio.cpp +++ b/src/audio/DMAudio.cpp @@ -7,7 +7,6 @@ #include "sampman.h" #include "Font.h" #include "Text.h" -#include "crossplatform.h" cDMAudio DMAudio; diff --git a/src/core/Game.cpp b/src/core/Game.cpp index 1be62611..e47543b3 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -89,6 +89,7 @@ #include "frontendoption.h" #include "postfx.h" #include "custompipes.h" +#include "crossplatform.h" eLevelName CGame::currLevel; bool CGame::bDemoMode = true; From 83947e6958bf822f01e7b9de48021ab8ea776182 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 25 Oct 2020 13:07:44 +0200 Subject: [PATCH 34/60] Remove redundant includes --- src/audio/DMAudio.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/audio/DMAudio.cpp b/src/audio/DMAudio.cpp index 44c22610..1027a084 100644 --- a/src/audio/DMAudio.cpp +++ b/src/audio/DMAudio.cpp @@ -5,8 +5,6 @@ #include "AudioManager.h" #include "AudioScriptObject.h" #include "sampman.h" -#include "Font.h" -#include "Text.h" cDMAudio DMAudio; From e3a1041a471aaaa3d906caeb23d1d334071978b2 Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 25 Oct 2020 16:17:30 +0100 Subject: [PATCH 35/60] clean up timebar ifdefs --- src/core/main.cpp | 51 +++++++-------------------------------------- src/core/main.h | 2 ++ src/core/timebars.h | 9 +++++++- 3 files changed, 18 insertions(+), 44 deletions(-) diff --git a/src/core/main.cpp b/src/core/main.cpp index 5fea9c4b..b6a32b55 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -1008,9 +1008,7 @@ Idle(void *arg) CTimer::Update(); -#ifdef TIMEBARS tbInit(); -#endif CSprite2d::InitPerFrame(); CFont::InitPerFrame(); @@ -1026,39 +1024,27 @@ Idle(void *arg) FrontEndMenuManager.Process(); } else { CPointLights::InitPerFrame(); -#ifdef TIMEBARS tbStartTimer(0, "CGame::Process"); -#endif CGame::Process(); -#ifdef TIMEBARS tbEndTimer("CGame::Process"); tbStartTimer(0, "DMAudio.Service"); -#endif DMAudio.Service(); -#ifdef TIMEBARS tbEndTimer("DMAudio.Service"); -#endif } if (RsGlobal.quit) return; #else CPointLights::InitPerFrame(); -#ifdef TIMEBARS + tbStartTimer(0, "CGame::Process"); -#endif CGame::Process(); -#ifdef TIMEBARS tbEndTimer("CGame::Process"); + tbStartTimer(0, "DMAudio.Service"); -#endif - DMAudio.Service(); - -#ifdef TIMEBARS tbEndTimer("DMAudio.Service"); -#endif #endif if(CGame::bDemoMode && CTimer::GetTimeInMilliseconds() > (3*60 + 30)*1000 && !CCutsceneMgr::IsCutsceneProcessing()){ @@ -1098,18 +1084,13 @@ Idle(void *arg) RsMouseSetPos(&pos); } #endif -#ifdef TIMEBARS tbStartTimer(0, "CnstrRenderList"); -#endif CRenderer::ConstructRenderList(); -#ifdef TIMEBARS tbEndTimer("CnstrRenderList"); + tbStartTimer(0, "PreRender"); -#endif CRenderer::PreRender(); -#ifdef TIMEBARS tbEndTimer("PreRender"); -#endif #ifdef FIX_BUGS RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void *)FALSE); // TODO: temp? this fixes OpenGL render but there should be a better place for this @@ -1135,13 +1116,9 @@ Idle(void *arg) RwCameraSetFogDistance(Scene.camera, CTimeCycle::GetFogStart()); #endif -#ifdef TIMEBARS tbStartTimer(0, "RenderScene"); -#endif RenderScene(); -#ifdef TIMEBARS tbEndTimer("RenderScene"); -#endif #ifdef EXTENDED_PIPELINES CustomPipes::EnvMapRender(); @@ -1150,21 +1127,16 @@ Idle(void *arg) RenderDebugShit(); RenderEffects(); -#ifdef TIMEBARS tbStartTimer(0, "RenderMotionBlur"); -#endif if((TheCamera.m_BlurType == MOTION_BLUR_NONE || TheCamera.m_BlurType == MOTION_BLUR_LIGHT_SCENE) && TheCamera.m_ScreenReductionPercentage > 0.0f) TheCamera.SetMotionBlurAlpha(150); TheCamera.RenderMotionBlur(); -#ifdef TIMEBARS tbEndTimer("RenderMotionBlur"); + tbStartTimer(0, "Render2dStuff"); -#endif Render2dStuff(); -#ifdef TIMEBARS tbEndTimer("Render2dStuff"); -#endif }else{ #ifdef ASPECT_RATIO_SCALE CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, SCREEN_ASPECT_RATIO); @@ -1181,35 +1153,28 @@ Idle(void *arg) if (FrontEndMenuManager.m_bMenuActive) DefinedState(); #endif -#ifdef TIMEBARS tbStartTimer(0, "RenderMenus"); -#endif RenderMenus(); -#ifdef TIMEBARS tbEndTimer("RenderMenus"); - tbStartTimer(0, "DoFade"); -#endif #ifdef PS2_MENU if ( TheMemoryCard.m_bWantToLoad ) return; #endif + + tbStartTimer(0, "DoFade"); DoFade(); -#ifdef TIMEBARS tbEndTimer("DoFade"); + tbStartTimer(0, "Render2dStuff-Fade"); -#endif Render2dStuffAfterFade(); -#ifdef TIMEBARS tbEndTimer("Render2dStuff-Fade"); -#endif + CCredits::Render(); -#ifdef TIMEBARS if (gbShowTimebars) tbDisplay(); -#endif DoRWStuffEndOfFrame(); diff --git a/src/core/main.h b/src/core/main.h index 7eb080cb..13fff447 100644 --- a/src/core/main.h +++ b/src/core/main.h @@ -16,6 +16,8 @@ extern bool gbPrintShite; extern bool gbModelViewer; #ifdef TIMEBARS extern bool gbShowTimebars; +#else +#define gbShowTimebars false #endif class CSprite2d; diff --git a/src/core/timebars.h b/src/core/timebars.h index 3871b61c..c4939802 100644 --- a/src/core/timebars.h +++ b/src/core/timebars.h @@ -1,6 +1,13 @@ #pragma once +#ifdef TIMEBARS void tbInit(); void tbStartTimer(int32, Const char*); void tbEndTimer(Const char*); -void tbDisplay(); \ No newline at end of file +void tbDisplay(); +#else +#define tbInit() +#define tbStartTimer(a, b) +#define tbEndTimer(a) +#define tbDisplay() +#endif From 6729de49b16da9a1be3c95b146ba053bf214c91c Mon Sep 17 00:00:00 2001 From: erorcun Date: Sun, 25 Oct 2020 20:51:27 +0300 Subject: [PATCH 36/60] Font: Fix text dimensions --- src/audio/MusicManager.cpp | 2 +- src/control/Darkel.cpp | 4 ++-- src/control/Garages.cpp | 2 +- src/core/Frontend.cpp | 10 +++++----- src/core/Game.cpp | 8 ++++---- src/core/Pad.cpp | 4 ++-- src/core/main.cpp | 2 +- src/render/Credits.cpp | 4 ++-- src/render/Hud.cpp | 24 ++++++++++++------------ src/render/SpecialFX.cpp | 2 +- 10 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp index 5519d899..10862cdc 100644 --- a/src/audio/MusicManager.cpp +++ b/src/audio/MusicManager.cpp @@ -161,7 +161,7 @@ cMusicManager::DisplayRadioStationName() CFont::SetPropOn(); CFont::SetFontStyle(FONT_HEADING); CFont::SetCentreOn(); - CFont::SetCentreSize(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH)); + CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)); CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(22.0f) + SCREEN_SCALE_Y(2.0f), pCurrentStation); diff --git a/src/control/Darkel.cpp b/src/control/Darkel.cpp index 793bec36..afdfcb82 100644 --- a/src/control/Darkel.cpp +++ b/src/control/Darkel.cpp @@ -72,7 +72,7 @@ CDarkel::DrawMessages() { CFont::SetJustifyOff(); CFont::SetBackgroundOff(); - CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(30.0f)); + CFont::SetCentreSize(SCREEN_SCALE_X(610.0f)); CFont::SetCentreOn(); CFont::SetPropOn(); uint32 timePassedSinceStart = CTimer::GetTimeInMilliseconds() - CDarkel::TimeOfFrenzyStart; @@ -132,7 +132,7 @@ CDarkel::DrawMessages() uint32 timePassedSinceStart = CTimer::GetTimeInMilliseconds() - CDarkel::TimeOfFrenzyStart; if (CTimer::GetTimeInMilliseconds() - CDarkel::TimeOfFrenzyStart < 5000) { CFont::SetBackgroundOff(); - CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(20.0f)); + CFont::SetCentreSize(SCREEN_SCALE_X(620.0f)); CFont::SetCentreOn(); CFont::SetScale(SCREEN_SCALE_X(1.5f), SCREEN_SCALE_Y(1.5f)); CFont::SetJustifyOff(); diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp index 61c1a850..5a04285f 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -1400,7 +1400,7 @@ void CGarages::PrintMessages() CFont::SetPropOn(); CFont::SetJustifyOff(); CFont::SetBackgroundOff(); - CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(50.0f)); + CFont::SetCentreSize(SCREEN_SCALE_X(590.0f)); CFont::SetCentreOn(); CFont::SetFontStyle(FONT_LOCALE(FONT_BANK)); CFont::SetColor(CRGBA(0, 0, 0, 255)); diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index db3774a7..89b5ba3d 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -787,7 +787,7 @@ CMenuManager::Draw() CFont::SetRightJustifyOn(); CFont::SetFontStyle(FONT_HEADING); CFont::SetScale(MENU_X(0.7f), MENU_Y(0.5f)); - CFont::SetWrapx(SCREEN_WIDTH); + CFont::SetWrapx(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)); CFont::SetRightJustifyWrap(0.0f); strcpy(gString, "V1.1"); AsciiToUnicode(gString, gUString); @@ -873,7 +873,7 @@ CMenuManager::Draw() #endif } - CFont::SetCentreSize(SCREEN_WIDTH); + CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)); #ifdef PS2_LIKE_MENU bool itemsAreSelectable = !bottomBarActive; @@ -3575,11 +3575,11 @@ CMenuManager::MessageScreen(const char *text) CFont::SetPropOn(); CFont::SetJustifyOn(); CFont::SetBackGroundOnlyTextOn(); - CFont::SetWrapx(SCREEN_WIDTH - StretchX(170.0f)); - CFont::SetRightJustifyWrap(SCREEN_WIDTH - StretchX(170.0f)); + CFont::SetWrapx(SCREEN_WIDTH - StretchX(170.0f)); // not used + CFont::SetRightJustifyWrap(SCREEN_WIDTH - StretchX(170.0f)); // not used CSprite2d::DrawRect(CRect(StretchX(120.0f), StretchY(150.0f), SCREEN_WIDTH - StretchX(120.0f), SCREEN_HEIGHT - StretchY(220.0f)), CRGBA(50, 50, 50, 210)); CFont::SetFontStyle(FONT_LOCALE(FONT_BANK)); - CFont::SetCentreSize(SCREEN_STRETCH_X(380.0f)); + 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)); diff --git a/src/core/Game.cpp b/src/core/Game.cpp index e47543b3..ef4800c5 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -129,10 +129,10 @@ void MessageScreen(char *msg) CFont::SetFontStyle(FONT_BANK); CFont::SetBackgroundOff(); - CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(190.0f)); // 450.0f + CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(190.0f)); // 450.0f // unused CFont::SetScale(SCREEN_SCALE_X(1.0f), SCREEN_SCALE_Y(1.0f)); CFont::SetCentreOn(); - CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(190.0f)); // 450.0f + CFont::SetCentreSize(SCREEN_SCALE_X(450.0f)); // 450.0f CFont::SetJustifyOff(); CFont::SetColor(CRGBA(255, 255, 255, 255)); CFont::SetDropColor(CRGBA(32, 32, 32, 255)); @@ -745,10 +745,10 @@ void CGame::InitialiseWhenRestarting(void) //CFont::SetFontStyle(?); CFont::SetBackgroundOff(); - CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(160.0f)); // 480.0f + CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(160.0f)); // 480.0f // unused CFont::SetScale(SCREEN_SCALE_X(1.0f), SCREEN_SCALE_Y(1.0f)); CFont::SetCentreOn(); - CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(160.0f)); // 480.0f + CFont::SetCentreSize(SCREEN_SCALE_X(480.0f)); // 480.0f CFont::SetJustifyOff(); CFont::SetColor(CRGBA(255, 255, 255, 255)); CFont::SetBackGroundOnlyTextOff(); diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index e2f90a7c..0e2f06a6 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -2593,7 +2593,7 @@ void CPad::PrintErrorMessage(void) CFont::SetScale(0.85f, 1.0f); CFont::SetJustifyOff(); CFont::SetBackgroundOff(); - CFont::SetCentreSize(SCREEN_WIDTH - 20); + CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - 20)); CFont::SetCentreOn(); CFont::SetPropOn(); CFont::SetColor(CRGBA(255, 255, 200, 200)); @@ -2610,7 +2610,7 @@ void CPad::PrintErrorMessage(void) CFont::SetScale(0.85f, 1.0f); CFont::SetJustifyOff(); CFont::SetBackgroundOff(); - CFont::SetCentreSize(SCREEN_WIDTH - 20); + CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - 20)); CFont::SetCentreOn(); CFont::SetPropOn(); CFont::SetColor(CRGBA(255, 255, 200, 200)); diff --git a/src/core/main.cpp b/src/core/main.cpp index b6a32b55..18ee2dc5 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -841,7 +841,7 @@ DisplayGameDebugText() CFont::SetRightJustifyOff(); CFont::SetJustifyOff(); CFont::SetBackGroundOnlyTextOff(); - CFont::SetWrapx(640.0f); + CFont::SetWrapx(SCREEN_WIDTH); CFont::SetFontStyle(FONT_HEADING); CFont::SetColor(CRGBA(0, 0, 0, 255)); diff --git a/src/render/Credits.cpp b/src/render/Credits.cpp index 6b28ff04..2c8a9952 100644 --- a/src/render/Credits.cpp +++ b/src/render/Credits.cpp @@ -62,7 +62,7 @@ CCredits::Render(void) scrolloffset = (CTimer::GetTimeInMilliseconds() - CreditsStartTime) / 24.0f; CFont::SetJustifyOff(); CFont::SetBackgroundOff(); - CFont::SetCentreSize(SCALE_AND_CENTER_X(DEFAULT_SCREEN_WIDTH - 20)); + CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - 20)); CFont::SetCentreOn(); CFont::SetPropOn(); CFont::SetColor(CRGBA(220, 220, 220, 220)); @@ -496,4 +496,4 @@ CCredits::Render(void) bool CCredits::AreCreditsDone(void) { return !bCreditsGoing; -} \ No newline at end of file +} diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index a6e6bccf..83c493bb 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -336,7 +336,7 @@ void CHud::Draw() CFont::SetScale(SCREEN_SCALE_X(0.4f), SCREEN_SCALE_Y(0.6f)); CFont::SetJustifyOff(); CFont::SetCentreOn(); - CFont::SetCentreSize(SCREEN_WIDTH); + CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)); CFont::SetPropOn(); CFont::SetFontStyle(FONT_BANK); @@ -740,7 +740,7 @@ void CHud::Draw() CFont::SetRightJustifyWrap(0.0f); CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING)); CFont::SetColor(CRGBA(244, 20, 20, 255)); - CFont::SetWrapx(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH)); + CFont::SetWrapx(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)); CFont::SetPropOff(); CFont::SetBackGroundOnlyTextOn(); @@ -869,8 +869,8 @@ void CHud::Draw() else CFont::SetCentreOff(); - CFont::SetWrapx(SCALE_AND_CENTER_X(CTheScripts::IntroTextLines[i].m_fWrapX)); - CFont::SetCentreSize(SCALE_AND_CENTER_X(CTheScripts::IntroTextLines[i].m_fCenterSize)); + CFont::SetWrapx(SCREEN_SCALE_X(CTheScripts::IntroTextLines[i].m_fWrapX)); + CFont::SetCentreSize(SCREEN_SCALE_X(CTheScripts::IntroTextLines[i].m_fCenterSize)); if (CTheScripts::IntroTextLines[i].m_bBackground) CFont::SetBackgroundOn(); @@ -957,12 +957,12 @@ void CHud::Draw() CFont::SetScale(SCREEN_SCALE_X(1.8f), SCREEN_SCALE_Y(1.8f)); CFont::SetPropOn(); CFont::SetCentreOn(); - CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(25.0f)); + CFont::SetCentreSize(SCREEN_SCALE_X(590.0f)); CFont::SetFontStyle(FONT_HEADING); // Appearently sliding text in here was abandoned very early, since this text is centered now. - if (BigMessageX[0] >= SCREEN_SCALE_FROM_RIGHT(20.0f)) { + if (BigMessageX[0] >= SCALE_AND_CENTER_X(620.0f)) { BigMessageInUse[0] += CTimer::GetTimeStep(); if (BigMessageInUse[0] >= 120.0f) { @@ -997,7 +997,7 @@ void CHud::Draw() } else { BigMessageAlpha[0] = 0.0f; - BigMessageX[0] = SCREEN_SCALE_FROM_RIGHT(DEFAULT_SCREEN_WIDTH + 60.0f); + BigMessageX[0] = SCALE_AND_CENTER_X(-60.0f); BigMessageInUse[0] = 1.0f; } } @@ -1166,8 +1166,8 @@ void CHud::DrawAfterFade() else CFont::SetCentreOff(); - CFont::SetWrapx(SCALE_AND_CENTER_X(line.m_fWrapX)); - CFont::SetCentreSize(SCALE_AND_CENTER_X(line.m_fCenterSize)); + CFont::SetWrapx(SCREEN_SCALE_X(line.m_fWrapX)); + CFont::SetCentreSize(SCREEN_SCALE_X(line.m_fCenterSize)); if (line.m_bBackground) CFont::SetBackgroundOn(); else @@ -1213,7 +1213,7 @@ void CHud::DrawAfterFade() CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.5f)); CFont::SetCentreOn(); CFont::SetPropOn(); - CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(40.0f)); + CFont::SetCentreSize(SCREEN_SCALE_X(600.0f)); CFont::SetFontStyle(FONT_LOCALE(FONT_BANK)); CFont::SetColor(CRGBA(0, 0, 0, 255)); @@ -1229,7 +1229,7 @@ void CHud::DrawAfterFade() CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.5f)); CFont::SetCentreOn(); CFont::SetPropOn(); - CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(20.0f)); + CFont::SetCentreSize(SCREEN_SCALE_X(620.0f)); CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::SetFontStyle(FONT_LOCALE(FONT_BANK)); @@ -1286,7 +1286,7 @@ void CHud::DrawAfterFade() CFont::SetScale(SCREEN_SCALE_X(1.0f), SCREEN_SCALE_Y(1.2f)); CFont::SetCentreOn(); CFont::SetPropOn(); - CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(20.0f)); + CFont::SetCentreSize(SCREEN_SCALE_X(620.0f)); CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::SetFontStyle(FONT_LOCALE(FONT_BANK)); diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp index 34423d83..89043752 100644 --- a/src/render/SpecialFX.cpp +++ b/src/render/SpecialFX.cpp @@ -1058,7 +1058,7 @@ CMoneyMessage::Render() CFont::SetScale(fScaleX, fScaleY); // maybe use SCREEN_SCALE_X and SCREEN_SCALE_Y here? CFont::SetCentreOn(); - CFont::SetCentreSize(SCREEN_WIDTH); + CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)); CFont::SetJustifyOff(); CFont::SetColor(CRGBA(m_Colour.r, m_Colour.g, m_Colour.b, (255.0f - 255.0f * fLifeTime) * m_fOpacity)); CFont::SetBackGroundOnlyTextOff(); From 19cc6fafe04b3a0b80c76f857eb68f2390525ea0 Mon Sep 17 00:00:00 2001 From: erorcun Date: Mon, 26 Oct 2020 12:35:24 +0300 Subject: [PATCH 37/60] (TEST) Try to fix OAL audio problems --- src/audio/oal/stream.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index 3adb702a..6c6abf1a 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -67,13 +67,13 @@ public: void Seek(uint32 milliseconds) { if ( !IsOpened() ) return; - sf_seek(m_pfSound, ms2samples(milliseconds), SF_SEEK_SET); + sf_seek(m_pfSound, ms2samples(milliseconds) * (float)GetChannels(), SF_SEEK_SET); } uint32 Tell() { if ( !IsOpened() ) return 0; - return samples2ms(sf_seek(m_pfSound, 0, SF_SEEK_CUR)); + return samples2ms(sf_seek(m_pfSound, 0, SF_SEEK_CUR)) / (float)GetChannels(); } uint32 Decode(void *buffer) From f144a782b79271c5836481d1f2767a5cb43a6003 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Mon, 26 Oct 2020 17:29:42 +0100 Subject: [PATCH 38/60] Add option to enable asan --- premake5.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/premake5.lua b/premake5.lua index 9d9243db..b5b885b3 100644 --- a/premake5.lua +++ b/premake5.lua @@ -19,6 +19,11 @@ newoption { default = "vendor/glfw-3.3.2.bin.WIN32", } +newoption { + trigger = "with-asan", + description = "Build with address sanitizer" +} + newoption { trigger = "with-librw", description = "Build and use librw from this solution" @@ -60,6 +65,11 @@ workspace "re3" symbols "Full" staticruntime "off" + if _OPTIONS["with-asan"] then + buildoptions { "-fsanitize=address -g3 -fno-omit-frame-pointer" } + linkoptions { "-fsanitize=address" } + end + filter { "system:windows" } platforms { "win-x86-RW33_d3d8-mss", From d94b36c20261851105e0745134b1fb7f2b6558aa Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Mon, 26 Oct 2020 20:13:50 +0200 Subject: [PATCH 39/60] Fixes to OpenAL --- src/audio/sampman_oal.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 720849f8..ad6961b0 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -109,9 +109,9 @@ ALuint ALStreamBuffers[MAX_STREAMS][NUM_STREAMBUFFERS]; struct { ALuint buffer; - ALuint timer; + ALint timer; - bool IsEmpty() { return timer == 0; } + bool IsEmpty() { return buffer == 0; } void Set(ALuint buf) { buffer = buf; } void Wait() { timer = 10000; } void Init() @@ -121,19 +121,32 @@ struct } void Term() { - if ( buffer != 0 && alIsBuffer(buffer) ) + if (buffer != 0 && alIsBuffer(buffer)) { alDeleteBuffers(1, &buffer); + assert(alGetError() == AL_NO_ERROR); + } timer = 0; + buffer = 0; } void Update() { if ( !(timer > 0) ) return; - timer -= ALuint(CTimer::GetTimeStepInMilliseconds()); + timer -= ALint(CTimer::GetTimeStepInMilliseconds()); if ( timer > 0 ) return; - if ( buffer != 0 && alIsBuffer(buffer) ) + timer = 0; + if ( buffer != 0 ) { + if (!alIsBuffer(buffer)) + { + buffer = 0; + return; + } alDeleteBuffers(1, &buffer); - timer = ( alGetError() == AL_NO_ERROR ) ? 0 : 10000; + ALenum error = alGetError(); + if (error != AL_NO_ERROR) + timer = 10000; + else + buffer = 0; } } }ALBuffers[SAMPLEBANK_MAX]; From ba0c96c39ca0711a574b19d437548fcf6303e785 Mon Sep 17 00:00:00 2001 From: erorcun Date: Tue, 27 Oct 2020 00:40:12 +0300 Subject: [PATCH 40/60] Revert "(TEST) Try to fix OAL audio problems" This reverts commit 19cc6fafe04b3a0b80c76f857eb68f2390525ea0. --- src/audio/oal/stream.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index 6c6abf1a..3adb702a 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -67,13 +67,13 @@ public: void Seek(uint32 milliseconds) { if ( !IsOpened() ) return; - sf_seek(m_pfSound, ms2samples(milliseconds) * (float)GetChannels(), SF_SEEK_SET); + sf_seek(m_pfSound, ms2samples(milliseconds), SF_SEEK_SET); } uint32 Tell() { if ( !IsOpened() ) return 0; - return samples2ms(sf_seek(m_pfSound, 0, SF_SEEK_CUR)) / (float)GetChannels(); + return samples2ms(sf_seek(m_pfSound, 0, SF_SEEK_CUR)); } uint32 Decode(void *buffer) From 4cfb3b0984c1de2820691b4b5f1c63cd19c498fb Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Tue, 27 Oct 2020 09:35:09 +0200 Subject: [PATCH 41/60] OpenAL channels now use their own sound buffers --- src/audio/oal/channel.cpp | 134 +++++++++++++++++++++----------------- src/audio/oal/channel.h | 18 ++--- src/audio/sampman.h | 6 +- src/audio/sampman_oal.cpp | 117 ++++----------------------------- 4 files changed, 96 insertions(+), 179 deletions(-) diff --git a/src/audio/oal/channel.cpp b/src/audio/oal/channel.cpp index 731e3581..673a4aed 100644 --- a/src/audio/oal/channel.cpp +++ b/src/audio/oal/channel.cpp @@ -10,17 +10,49 @@ extern bool IsFXSupported(); +ALuint alSources[MAXCHANNELS+MAX2DCHANNELS]; +ALuint alFilters[MAXCHANNELS+MAX2DCHANNELS]; +ALuint alBuffers[MAXCHANNELS+MAX2DCHANNELS]; +bool bChannelsCreated = false; + +void +CChannel::InitChannels() +{ + alGenSources(MAXCHANNELS+MAX2DCHANNELS, alSources); + alGenBuffers(MAXCHANNELS+MAX2DCHANNELS, alBuffers); + if (IsFXSupported()) + alGenFilters(MAXCHANNELS + MAX2DCHANNELS, alFilters); + bChannelsCreated = true; +} + +void +CChannel::DestroyChannels() +{ + if (bChannelsCreated) + { + alDeleteSources(MAXCHANNELS + MAX2DCHANNELS, alSources); + memset(alSources, 0, sizeof(alSources)); + alDeleteBuffers(MAXCHANNELS + MAX2DCHANNELS, alBuffers); + memset(alBuffers, 0, sizeof(alBuffers)); + if (IsFXSupported()) + { + alDeleteFilters(MAXCHANNELS + MAX2DCHANNELS, alFilters); + memset(alFilters, 0, sizeof(alFilters)); + } + bChannelsCreated = false; + } +} + + CChannel::CChannel() { - alSource = AL_NONE; - alFilter = AL_FILTER_NULL; + Data = nil; + DataSize = 0; SetDefault(); } void CChannel::SetDefault() { - alBuffer = AL_NONE; - Pitch = 1.0f; Gain = 1.0f; Mix = 0.0f; @@ -39,25 +71,19 @@ void CChannel::Reset() SetDefault(); } -void CChannel::Init(bool Is2D) +void CChannel::Init(uint32 _id, bool Is2D) { - ASSERT(!HasSource()); - alGenSources(1, &alSource); + id = _id; if ( HasSource() ) { - alSourcei(alSource, AL_SOURCE_RELATIVE, AL_TRUE); + alSourcei(alSources[id], AL_SOURCE_RELATIVE, AL_TRUE); if ( IsFXSupported() ) - alSource3i(alSource, AL_AUXILIARY_SEND_FILTER, AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL); + alSource3i(alSources[id], AL_AUXILIARY_SEND_FILTER, AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL); if ( Is2D ) { - alSource3f(alSource, AL_POSITION, 0.0f, 0.0f, 0.0f); - alSourcef (alSource, AL_GAIN, 1.0f); - } - else - { - if ( IsFXSupported() ) - alGenFilters(1,&alFilter); + alSource3f(alSources[id], AL_POSITION, 0.0f, 0.0f, 0.0f); + alSourcef(alSources[id], AL_GAIN, 1.0f); } } } @@ -69,39 +95,34 @@ void CChannel::Term() { if ( IsFXSupported() ) { - alSource3i(alSource, AL_AUXILIARY_SEND_FILTER, AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL); - - if(alFilter != AL_FILTER_NULL) - alDeleteFilters(1,&alFilter); + alSource3i(alSources[id], AL_AUXILIARY_SEND_FILTER, AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL); } - - alDeleteSources(1, &alSource); } - alSource = AL_NONE; - alFilter = AL_FILTER_NULL; } void CChannel::Start() { if ( !HasSource() ) return; - + if ( !Data ) return; + + alBufferData(alBuffers[id], AL_FORMAT_MONO16, Data, DataSize, Frequency); if ( LoopPoints[0] != 0 && LoopPoints[0] != -1 ) - alBufferiv(alBuffer, AL_LOOP_POINTS_SOFT, LoopPoints); - alSourcei (alSource, AL_BUFFER, alBuffer); - alSourcePlay(alSource); + alBufferiv(alBuffers[id], AL_LOOP_POINTS_SOFT, LoopPoints); + alSourcei(alSources[id], AL_BUFFER, alBuffers[id]); + alSourcePlay(alSources[id]); } void CChannel::Stop() { if ( HasSource() ) - alSourceStop(alSource); + alSourceStop(alSources[id]); Reset(); } bool CChannel::HasSource() { - return alSource != AL_NONE; + return alSources[id] != AL_NONE; } bool CChannel::IsUsed() @@ -109,7 +130,7 @@ bool CChannel::IsUsed() if ( HasSource() ) { ALint sourceState; - alGetSourcei(alSource, AL_SOURCE_STATE, &sourceState); + alGetSourcei(alSources[id], AL_SOURCE_STATE, &sourceState); return sourceState == AL_PLAYING; } return false; @@ -118,27 +139,24 @@ bool CChannel::IsUsed() void CChannel::SetPitch(float pitch) { if ( !HasSource() ) return; - alSourcef(alSource, AL_PITCH, pitch); + alSourcef(alSources[id], AL_PITCH, pitch); } void CChannel::SetGain(float gain) { if ( !HasSource() ) return; - alSourcef(alSource, AL_GAIN, gain); + alSourcef(alSources[id], AL_GAIN, gain); } void CChannel::SetVolume(int32 vol) { SetGain(ALfloat(vol) / MAX_VOLUME); } - -void CChannel::SetSampleID(uint32 nSfx) -{ - Sample = nSfx; -} - -void CChannel::SetFreq(int32 freq) + +void CChannel::SetSampleData(void *_data, size_t _DataSize, int32 freq) { + Data = _data; + DataSize = _DataSize; Frequency = freq; } @@ -150,7 +168,7 @@ void CChannel::SetCurrentFreq(uint32 freq) void CChannel::SetLoopCount(int32 loopCount) // fake. TODO: { if ( !HasSource() ) return; - alSourcei(alSource, AL_LOOPING, loopCount == 1 ? AL_FALSE : AL_TRUE); + alSourcei(alSources[id], AL_LOOPING, loopCount == 1 ? AL_FALSE : AL_TRUE); } void CChannel::SetLoopPoints(ALint start, ALint end) @@ -162,53 +180,49 @@ void CChannel::SetLoopPoints(ALint start, ALint end) void CChannel::SetPosition(float x, float y, float z) { if ( !HasSource() ) return; - alSource3f(alSource, AL_POSITION, x, y, z); + alSource3f(alSources[id], AL_POSITION, x, y, z); } void CChannel::SetDistances(float max, float min) { if ( !HasSource() ) return; - alSourcef (alSource, AL_MAX_DISTANCE, max); - alSourcef (alSource, AL_REFERENCE_DISTANCE, min); - alSourcef (alSource, AL_MAX_GAIN, 1.0f); - alSourcef (alSource, AL_ROLLOFF_FACTOR, 1.0f); + alSourcef (alSources[id], AL_MAX_DISTANCE, max); + alSourcef (alSources[id], AL_REFERENCE_DISTANCE, min); + alSourcef (alSources[id], AL_MAX_GAIN, 1.0f); + alSourcef (alSources[id], AL_ROLLOFF_FACTOR, 1.0f); } -void CChannel::SetPan(uint32 pan) +void CChannel::SetPan(int32 pan) { SetPosition((pan-63)/64.0f, 0.0f, Sqrt(1.0f-SQR((pan-63)/64.0f))); } -void CChannel::SetBuffer(ALuint buffer) -{ - alBuffer = buffer; -} - void CChannel::ClearBuffer() { if ( !HasSource() ) return; - SetBuffer(AL_NONE); - alSourcei(alSource, AL_BUFFER, AL_NONE); + alSourcei(alSources[id], AL_BUFFER, AL_NONE); + Data = nil; + DataSize = 0; } void CChannel::SetReverbMix(ALuint slot, float mix) { if ( !IsFXSupported() ) return; if ( !HasSource() ) return; - if ( alFilter == AL_FILTER_NULL ) return; + if ( alFilters[id] == AL_FILTER_NULL ) return; Mix = mix; - EAX3_SetReverbMix(alFilter, mix); - alSource3i(alSource, AL_AUXILIARY_SEND_FILTER, slot, 0, alFilter); + EAX3_SetReverbMix(alFilters[id], mix); + alSource3i(alSources[id], AL_AUXILIARY_SEND_FILTER, slot, 0, alFilters[id]); } void CChannel::UpdateReverb(ALuint slot) { if ( !IsFXSupported() ) return; if ( !HasSource() ) return; - if ( alFilter == AL_FILTER_NULL ) return; - EAX3_SetReverbMix(alFilter, Mix); - alSource3i(alSource, AL_AUXILIARY_SEND_FILTER, slot, 0, alFilter); + if ( alFilters[id] == AL_FILTER_NULL ) return; + EAX3_SetReverbMix(alFilters[id], Mix); + alSource3i(alSources[id], AL_AUXILIARY_SEND_FILTER, slot, 0, alFilters[id]); } #endif diff --git a/src/audio/oal/channel.h b/src/audio/oal/channel.h index 0c86bdc6..81817a32 100644 --- a/src/audio/oal/channel.h +++ b/src/audio/oal/channel.h @@ -9,22 +9,24 @@ class CChannel { - ALuint alSource; - ALuint alFilter; - ALuint alBuffer; + uint32 id; float Pitch, Gain; float Mix; + void *Data; + size_t DataSize; int32 Frequency; float Position[3]; float Distances[2]; int32 LoopCount; ALint LoopPoints[2]; - uint32 Sample; public: + static void InitChannels(); + static void DestroyChannels(); + CChannel(); void SetDefault(); void Reset(); - void Init(bool Is2D = false); + void Init(uint32 _id, bool Is2D = false); void Term(); void Start(); void Stop(); @@ -33,15 +35,13 @@ public: void SetPitch(float pitch); void SetGain(float gain); void SetVolume(int32 vol); - void SetSampleID(uint32 nSfx); - void SetFreq(int32 freq); + void SetSampleData(void *_data, size_t _DataSize, int32 freq); void SetCurrentFreq(uint32 freq); void SetLoopCount(int32 loopCount); // fake void SetLoopPoints(ALint start, ALint end); void SetPosition(float x, float y, float z); void SetDistances(float max, float min); - void SetPan(uint32 pan); - void SetBuffer(ALuint buffer); + void SetPan(int32 pan); void ClearBuffer(); void SetReverbMix(ALuint slot, float mix); void UpdateReverb(ALuint slot); diff --git a/src/audio/sampman.h b/src/audio/sampman.h index aec61144..2284d385 100644 --- a/src/audio/sampman.h +++ b/src/audio/sampman.h @@ -153,11 +153,7 @@ public: bool Initialise(void); void Terminate (void); - -#ifdef AUDIO_OAL - void UpdateSoundBuffers(void); -#endif - + bool CheckForAnAudioFileOnCD(void); char GetCDAudioDriveLetter (void); diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index ad6961b0..eec5ca5f 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -98,58 +98,12 @@ int32 nPedSlotSfx [MAX_PEDSFX]; int32 nPedSlotSfxAddr[MAX_PEDSFX]; uint8 nCurrentPedSlot; -ALuint pedBuffers[MAX_PEDSFX]; - CChannel aChannel[MAXCHANNELS+MAX2DCHANNELS]; uint8 nChannelVolume[MAXCHANNELS+MAX2DCHANNELS]; uint32 nStreamLength[TOTAL_STREAMED_SOUNDS]; ALuint ALStreamSources[MAX_STREAMS]; ALuint ALStreamBuffers[MAX_STREAMS][NUM_STREAMBUFFERS]; -struct -{ - ALuint buffer; - ALint timer; - - bool IsEmpty() { return buffer == 0; } - void Set(ALuint buf) { buffer = buf; } - void Wait() { timer = 10000; } - void Init() - { - buffer = 0; - timer = 0; - } - void Term() - { - if (buffer != 0 && alIsBuffer(buffer)) { - alDeleteBuffers(1, &buffer); - assert(alGetError() == AL_NO_ERROR); - } - timer = 0; - buffer = 0; - } - void Update() - { - if ( !(timer > 0) ) return; - timer -= ALint(CTimer::GetTimeStepInMilliseconds()); - if ( timer > 0 ) return; - timer = 0; - if ( buffer != 0 ) - { - if (!alIsBuffer(buffer)) - { - buffer = 0; - return; - } - alDeleteBuffers(1, &buffer); - ALenum error = alGetError(); - if (error != AL_NO_ERROR) - timer = 10000; - else - buffer = 0; - } - } -}ALBuffers[SAMPLEBANK_MAX]; struct tMP3Entry { @@ -295,12 +249,7 @@ release_existing() alDeleteBuffers(NUM_STREAMBUFFERS, ALStreamBuffers[i]); } - alDeleteBuffers(MAX_PEDSFX, pedBuffers); - - for ( int32 i = 0; i < SAMPLEBANK_MAX; i++ ) - { - ALBuffers[i].Term(); - } + CChannel::DestroyChannels(); if ( ALContext ) { @@ -381,13 +330,6 @@ set_new_provider(int index) stream->ProviderInit(); } - for ( int32 i = 0; i < SAMPLEBANK_MAX; i++ ) - { - ALBuffers[i].Init(); - } - - alGenBuffers(MAX_PEDSFX, pedBuffers); - usingEAX = 0; usingEAX3 = 0; _usingEFX = false; @@ -419,10 +361,12 @@ set_new_provider(int index) } //SampleManager.SetSpeakerConfig(speaker_type); - + + CChannel::InitChannels(); + for ( int32 i = 0; i < MAXCHANNELS; i++ ) - aChannel[i].Init(); - aChannel[CHANNEL2D].Init(true); + aChannel[i].Init(i); + aChannel[CHANNEL2D].Init(CHANNEL2D, true); if ( IsFXSupported() ) { @@ -1166,7 +1110,7 @@ cSampleManager::Terminate(void) _DeleteMP3Entries(); CStream::Terminate(); - + if ( nSampleBankMemoryStartAddress[SFX_BANK_0] != 0 ) { free((void *)nSampleBankMemoryStartAddress[SFX_BANK_0]); @@ -1182,15 +1126,6 @@ cSampleManager::Terminate(void) _bSampmanInitialised = false; } -void -cSampleManager::UpdateSoundBuffers(void) -{ - for ( int32 i = 0; i < SAMPLEBANK_MAX; i++ ) - { - ALBuffers[i].Update(); - } -} - bool cSampleManager::CheckForAnAudioFileOnCD(void) { return true; @@ -1399,13 +1334,7 @@ cSampleManager::LoadPedComment(uint32 nComment) #endif nPedSlotSfx[nCurrentPedSlot] = nComment; - - alBufferData(pedBuffers[nCurrentPedSlot], - AL_FORMAT_MONO16, - (void *)(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE*nCurrentPedSlot), - m_aSamples[nComment].nSize, - m_aSamples[nComment].nFrequency); - + if ( ++nCurrentPedSlot >= MAX_PEDSFX ) nCurrentPedSlot = 0; @@ -1541,25 +1470,14 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) { ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); - ALuint buffer; + uintptr addr; if ( nSfx < SAMPLEBANK_MAX ) { if ( !IsSampleBankLoaded(nBank) ) return false; - uintptr addr = nSampleBankMemoryStartAddress[nBank] + m_aSamples[nSfx].nOffset - m_aSamples[BankStartOffset[nBank]].nOffset; - - if ( ALBuffers[nSfx].IsEmpty() ) - { - ALuint buf; - alGenBuffers(1, &buf); - alBufferData(buf, AL_FORMAT_MONO16, (void *)addr, m_aSamples[nSfx].nSize, m_aSamples[nSfx].nFrequency); - ALBuffers[nSfx].Set(buf); - } - ALBuffers[nSfx].Wait(); - - buffer = ALBuffers[nSfx].buffer; + addr = nSampleBankMemoryStartAddress[nBank] + m_aSamples[nSfx].nOffset - m_aSamples[BankStartOffset[nBank]].nOffset; } else { @@ -1567,14 +1485,7 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) return false; int32 slot = _GetPedCommentSlot(nSfx); - - buffer = pedBuffers[slot]; - } - - if ( buffer == 0 ) - { - TRACE("No buffer to play id %d", nSfx); - return false; + addr = (nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE * slot); } if ( GetChannelUsedFlag(nChannel) ) @@ -1586,10 +1497,8 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) aChannel[nChannel].Reset(); if ( aChannel[nChannel].HasSource() ) { - aChannel[nChannel].SetSampleID (nSfx); - aChannel[nChannel].SetFreq (m_aSamples[nSfx].nFrequency); + aChannel[nChannel].SetSampleData ((void*)addr, m_aSamples[nSfx].nSize, m_aSamples[nSfx].nFrequency); aChannel[nChannel].SetLoopPoints (0, -1); - aChannel[nChannel].SetBuffer (buffer); aChannel[nChannel].SetPitch (1.0f); return true; } @@ -2040,8 +1949,6 @@ cSampleManager::Service(void) if ( stream ) stream->Update(); } - - UpdateSoundBuffers(); } bool From 78ac22ee2cfa12c1e8c93cca956f1aa1f93c76dc Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 27 Oct 2020 15:55:07 +0100 Subject: [PATCH 42/60] boolean for extended pipelines --- src/core/re3.cpp | 9 ++++++--- src/extras/custompipes.cpp | 3 +++ src/extras/custompipes.h | 3 +++ src/extras/custompipes_d3d9.cpp | 18 ++++++++++++++++++ src/extras/custompipes_gl.cpp | 17 +++++++++++++++++ 5 files changed, 47 insertions(+), 3 deletions(-) diff --git a/src/core/re3.cpp b/src/core/re3.cpp index d5a8099d..a06762f5 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -849,9 +849,12 @@ DebugMenuPopulate(void) DebugMenuEntrySetWrap(e, true); DebugMenuAddVar("Render", "Neo Vehicle Shininess", &CustomPipes::VehicleShininess, nil, 0.1f, 0, 1.0f); DebugMenuAddVar("Render", "Neo Vehicle Specularity", &CustomPipes::VehicleSpecularity, nil, 0.1f, 0, 1.0f); - DebugMenuAddVar("Render", "Neo Ped Rim light", &CustomPipes::RimlightMult, nil, 0.1f, 0, 1.0f); - DebugMenuAddVar("Render", "Neo World Lightmaps", &CustomPipes::LightmapMult, nil, 0.1f, 0, 1.0f); - DebugMenuAddVar("Render", "Neo Road Gloss", &CustomPipes::GlossMult, nil, 0.1f, 0, 1.0f); + DebugMenuAddVarBool8("Render", "Neo Ped Rim light enable", &CustomPipes::RimlightEnable, nil); + DebugMenuAddVar("Render", "Mult", &CustomPipes::RimlightMult, nil, 0.1f, 0, 1.0f); + DebugMenuAddVarBool8("Render", "Neo World Lightmaps enable", &CustomPipes::LightmapEnable, nil); + DebugMenuAddVar("Render", "Mult", &CustomPipes::LightmapMult, nil, 0.1f, 0, 1.0f); + DebugMenuAddVarBool8("Render", "Neo Road Gloss enable", &CustomPipes::GlossEnable, nil); + DebugMenuAddVar("Render", "Mult", &CustomPipes::GlossMult, nil, 0.1f, 0, 1.0f); #endif DebugMenuAddVarBool8("Render", "Show Ped Paths", &gbShowPedPaths, nil); DebugMenuAddVarBool8("Render", "Show Car Paths", &gbShowCarPaths, nil); diff --git a/src/extras/custompipes.cpp b/src/extras/custompipes.cpp index 79254eb4..b545b4d8 100644 --- a/src/extras/custompipes.cpp +++ b/src/extras/custompipes.cpp @@ -365,6 +365,7 @@ AttachVehiclePipe(rw::Clump *clump) * Neo World pipe */ +bool LightmapEnable; float LightmapMult = 1.0f; InterpolatedFloat WorldLightmapBlend(1.0f); rw::ObjPipeline *worldPipe; @@ -389,6 +390,7 @@ AttachWorldPipe(rw::Clump *clump) * Neo Gloss pipe */ +bool GlossEnable; float GlossMult = 1.0f; rw::ObjPipeline *glossPipe; @@ -427,6 +429,7 @@ AttachGlossPipe(rw::Clump *clump) * Neo Rim pipes */ +bool RimlightEnable; float RimlightMult = 1.0f; InterpolatedColor RampStart(Color(0.0f, 0.0f, 0.0f, 1.0f)); InterpolatedColor RampEnd(Color(1.0f, 1.0f, 1.0f, 1.0f)); diff --git a/src/extras/custompipes.h b/src/extras/custompipes.h index 4ebe586f..6e9c6517 100644 --- a/src/extras/custompipes.h +++ b/src/extras/custompipes.h @@ -98,6 +98,7 @@ void DestroyVehiclePipe(void); void AttachVehiclePipe(rw::Atomic *atomic); void AttachVehiclePipe(rw::Clump *clump); +extern bool LightmapEnable; extern float LightmapMult; extern InterpolatedFloat WorldLightmapBlend; extern rw::ObjPipeline *worldPipe; @@ -106,6 +107,7 @@ void DestroyWorldPipe(void); void AttachWorldPipe(rw::Atomic *atomic); void AttachWorldPipe(rw::Clump *clump); +extern bool GlossEnable; extern float GlossMult; extern rw::ObjPipeline *glossPipe; void CreateGlossPipe(void); @@ -114,6 +116,7 @@ void AttachGlossPipe(rw::Atomic *atomic); void AttachGlossPipe(rw::Clump *clump); rw::Texture *GetGlossTex(rw::Material *mat); +extern bool RimlightEnable; extern float RimlightMult; extern InterpolatedColor RampStart; extern InterpolatedColor RampEnd; diff --git a/src/extras/custompipes_d3d9.cpp b/src/extras/custompipes_d3d9.cpp index bfc744a3..852f2df8 100644 --- a/src/extras/custompipes_d3d9.cpp +++ b/src/extras/custompipes_d3d9.cpp @@ -190,6 +190,11 @@ worldRenderCB(rw::Atomic *atomic, rw::d3d9::InstanceDataHeader *header) using namespace rw::d3d; using namespace rw::d3d9; + if(!LightmapEnable){ + defaultRenderCB_Shader(atomic, header); + return; + } + int vsBits; setStreamSource(0, header->vertexStream[0].vertexBuffer, 0, header->vertexStream[0].stride); setIndices(header->indexBuffer); @@ -297,6 +302,9 @@ glossRenderCB(rw::Atomic *atomic, rw::d3d9::InstanceDataHeader *header) using namespace rw::d3d; using namespace rw::d3d9; + if(!GlossEnable) + return; + setVertexShader(neoGloss_VS); setPixelShader(neoGloss_PS); @@ -395,6 +403,11 @@ rimRenderCB(rw::Atomic *atomic, rw::d3d9::InstanceDataHeader *header) using namespace rw::d3d; using namespace rw::d3d9; + if(!RimlightEnable){ + defaultRenderCB_Shader(atomic, header); + return; + } + int vsBits; setStreamSource(0, header->vertexStream[0].vertexBuffer, 0, header->vertexStream[0].stride); setIndices(header->indexBuffer); @@ -433,6 +446,11 @@ rimSkinRenderCB(rw::Atomic *atomic, rw::d3d9::InstanceDataHeader *header) using namespace rw::d3d; using namespace rw::d3d9; + if(!RimlightEnable){ + rimSkinRenderCB(atomic, header); + return; + } + int vsBits; setStreamSource(0, (IDirect3DVertexBuffer9*)header->vertexStream[0].vertexBuffer, diff --git a/src/extras/custompipes_gl.cpp b/src/extras/custompipes_gl.cpp index 5717c83b..01663df5 100644 --- a/src/extras/custompipes_gl.cpp +++ b/src/extras/custompipes_gl.cpp @@ -203,6 +203,11 @@ worldRenderCB(rw::Atomic *atomic, rw::gl3::InstanceDataHeader *header) using namespace rw; using namespace rw::gl3; + if(!LightmapEnable){ + gl3::defaultRenderCB(atomic, header); + return; + } + Material *m; setWorldMatrix(atomic->getFrame()->getLTM()); @@ -315,6 +320,8 @@ glossRenderCB(rw::Atomic *atomic, rw::gl3::InstanceDataHeader *header) using namespace rw::gl3; worldRenderCB(atomic, header); + if(!GlossEnable) + return; Material *m; @@ -442,6 +449,11 @@ rimSkinRenderCB(rw::Atomic *atomic, rw::gl3::InstanceDataHeader *header) using namespace rw; using namespace rw::gl3; + if(!RimlightEnable){ + gl3::skinRenderCB(atomic, header); + return; + } + Material *m; setWorldMatrix(atomic->getFrame()->getLTM()); @@ -487,6 +499,11 @@ rimRenderCB(rw::Atomic *atomic, rw::gl3::InstanceDataHeader *header) using namespace rw; using namespace rw::gl3; + if(!RimlightEnable){ + gl3::defaultRenderCB(atomic, header); + return; + } + Material *m; setWorldMatrix(atomic->getFrame()->getLTM()); From ee222d03849b1ccac92c54378a74535b2bd68609 Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 27 Oct 2020 16:15:30 +0100 Subject: [PATCH 43/60] stupid bug; update librw --- src/extras/custompipes_d3d9.cpp | 2 +- vendor/librw | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/extras/custompipes_d3d9.cpp b/src/extras/custompipes_d3d9.cpp index 852f2df8..93973fec 100644 --- a/src/extras/custompipes_d3d9.cpp +++ b/src/extras/custompipes_d3d9.cpp @@ -447,7 +447,7 @@ rimSkinRenderCB(rw::Atomic *atomic, rw::d3d9::InstanceDataHeader *header) using namespace rw::d3d9; if(!RimlightEnable){ - rimSkinRenderCB(atomic, header); + skinRenderCB(atomic, header); return; } diff --git a/vendor/librw b/vendor/librw index ee2a32e1..4e8396af 160000 --- a/vendor/librw +++ b/vendor/librw @@ -1 +1 @@ -Subproject commit ee2a32e142fa2d2a1bb6c4fed0c25c2f1e5a1129 +Subproject commit 4e8396af2656a0aec5d5092a3128d9df3dcaf4c6 From e2dc1ba10242dfd94faab1a59d27862de92bcf37 Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Tue, 27 Oct 2020 18:55:28 +0300 Subject: [PATCH 44/60] fix rainraindrop --- src/render/Weather.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/render/Weather.cpp b/src/render/Weather.cpp index 2c0b27d2..f16467b6 100644 --- a/src/render/Weather.cpp +++ b/src/render/Weather.cpp @@ -346,7 +346,7 @@ void CWeather::AddRain() pos.y = CGeneral::GetRandomNumberInRange(DROPLETS_TOP_OFFSET, screen_height - DROPLETS_TOP_OFFSET); pos.z = 0.0f; CParticle::AddParticle(PARTICLE_RAINDROP_2D, pos, CVector(0.0f, 0.0f, 0.0f), nil, CGeneral::GetRandomNumberInRange(0.5f, 0.9f), - colour, CGeneral::GetRandomNumberInRange(-10, 10), 360 - rain_angle + CGeneral::GetRandomNumberInRange(-30, 30), cur_frame, 0); + colour, CGeneral::GetRandomNumberInRange(-10, 10), 360 - rain_angle + CGeneral::GetRandomNumberInRange(-30, 30), cur_frame, 50); } int num_splash_attempts = (int)(3 * Rain) + 1; int num_splashes = (int)(3 * Rain) + 4; From f7b1ba4049006fa772d9e16db96ce326dbde4aa8 Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Wed, 28 Oct 2020 03:10:53 +0300 Subject: [PATCH 45/60] fix FireShotgun missing normalise --- src/weapons/Weapon.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/weapons/Weapon.cpp b/src/weapons/Weapon.cpp index 85f0bc15..9494c745 100644 --- a/src/weapons/Weapon.cpp +++ b/src/weapons/Weapon.cpp @@ -108,10 +108,17 @@ CWeapon::Fire(CEntity *shooter, CVector *fireSource) CVector fireOffset(0.0f, 0.0f, 0.6f); CVector *source = fireSource; - if (!fireSource) { + if (!fireSource) + { + fireOffset = shooter->GetMatrix() * fireOffset; +#ifdef FIX_BUGS static CVector tmp; - tmp = shooter->GetMatrix() * fireOffset; + tmp = fireOffset; source = &tmp; +#else + source = &fireOffset; +#endif + } if ( m_bAddRotOffset ) { @@ -1166,6 +1173,7 @@ CWeapon::FireShotgun(CEntity *shooter, CVector *fireSource) { float shootAngle = DEGTORAD(7.5f*i + shooterAngle - 15.0f); CVector2D shootRot(-Sin(shootAngle), Cos(shootAngle)); + shootRot.Normalise(); CVector source, target; CColPoint point; From a5447306c4e53da45f389967e2f43fd6ca80d215 Mon Sep 17 00:00:00 2001 From: aap Date: Wed, 28 Oct 2020 10:33:27 +0100 Subject: [PATCH 46/60] fixed skin on player head --- src/modelinfo/ClumpModelInfo.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/modelinfo/ClumpModelInfo.cpp b/src/modelinfo/ClumpModelInfo.cpp index 49198437..1ae936a7 100644 --- a/src/modelinfo/ClumpModelInfo.cpp +++ b/src/modelinfo/ClumpModelInfo.cpp @@ -5,6 +5,7 @@ #include "NodeName.h" #include "VisibilityPlugins.h" #include "ModelInfo.h" +#include "ModelIndices.h" void CClumpModelInfo::DeleteRwObject(void) @@ -110,12 +111,18 @@ CClumpModelInfo::SetClump(RpClump *clump) weights->w3 /= sum; } RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS)); - }else -#endif - // do not set on skinned clip because cutscene head is not compatible with player head - if(strncmp(GetName(), "playerh", 8) == 0) + } + if(strncmp(GetName(), "playerh", 8) == 0){ + // playerh is incompatible with the xbox player skin + // so check if player model is skinned and only apply skin to head if it isn't + CPedModelInfo *body = (CPedModelInfo*)CModelInfo::GetModelInfo(MI_PLAYER); + if(!(body->m_clump && IsClumpSkinned(body->m_clump))) RpClumpForAllAtomics(clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB); - + } +#else + if(strncmp(GetName(), "playerh", 8) == 0){ + RpClumpForAllAtomics(clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB); +#endif } void From 795c5bbb85b1b591e8463b1150b750f669201bb8 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Wed, 28 Oct 2020 18:07:11 +0200 Subject: [PATCH 47/60] New GXT lines --- gamefiles/TEXT/american.gxt | Bin 219620 -> 220024 bytes utils/gxt/american.txt | 39 ++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/gamefiles/TEXT/american.gxt b/gamefiles/TEXT/american.gxt index b4d7bc6c6b3ac938c5d1396ca935765f6be197af..e7f714b27978eb83ebbc88fa46da4c58abf74b74 100644 GIT binary patch delta 512 zcmXw!u}i~16vkfzokCa9tsvsq*mf40Hc5kbxg&{fnx#%U=_qt43J!{E{tFk8fDR6B zj)FK9T3j5QUF@WOcRk7Q-tT?y``+cFtS#?r)pXArecn|c8}@u|k?-}!UFH{0jY+V+ zSTT1Q<^R2((bvq(LrI5b9(jU()+*XBJAJw_Su*B@a5n5`!*RfhBjQhKvV(985(Mxm;H9{p#Jt#3I991a+JSnu81a(NM z0p@}de1t5aX&-u>eC#u9dmy4Av>2>BNSc@^ju@%U91AHd0_W@GVoAjiG<9Br)uSRE fqg)K6Jgz>YG&N0eHq(0^H1!h+HBmF{39bAAWXX4t delta 106 zcmeydjrYlBUe*wA*GQj@th@CmpV6-n|8$dy!Ohhr-q$mL;hz{Im>uBgF}d47a`Fa) z9PWg35czP=;LY}i7nvr@n5azl0pc1HgULHgZfu@o8sWjzai{rPZTq)c#_iu~nY!)( E04QH6RR910 diff --git a/utils/gxt/american.txt b/utils/gxt/american.txt index 70a266bb..c428a570 100644 --- a/utils/gxt/american.txt +++ b/utils/gxt/american.txt @@ -8022,6 +8022,45 @@ REPLAY MISSION [FESZ_RM] RETRY? +[FED_VPL] +VEHICLE PIPELINE + +[FED_PRM] +PED RIM LIGHT + +[FED_RGL] +ROAD GLOSS + +[FED_CLF] +COLOUR FILTER + +[FED_WLM] +WORLD LIGHTMAPS + +[FED_MBL] +MOTION BLUR + +[FEM_SIM] +SIMPLE + +[FEM_NRM] +NORMAL + +[FEM_MOB] +MOBILE + +[FED_MFX] +MATFX + +[FED_NEO] +NEO + +[FEM_PS2] +PS2 + +[FEM_XBX] +XBOX + { end of file } [DUMMY] From e97366c023ee81d0feefa131ed38c77131d29f40 Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 29 Oct 2020 19:11:47 +0100 Subject: [PATCH 48/60] implemented extra model flags for backface culling and alpha test from mobile --- src/core/FileLoader.cpp | 344 ++++++++++++++++++++++++++++++++++ src/core/config.h | 3 + src/extras/custompipes.cpp | 2 +- src/modelinfo/BaseModelInfo.h | 8 + src/render/Renderer.cpp | 29 +++ src/rw/RwHelper.cpp | 24 ++- src/rw/RwHelper.h | 2 + src/rw/VisibilityPlugins.cpp | 9 + 8 files changed, 418 insertions(+), 3 deletions(-) diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp index ff50575f..aadafc29 100644 --- a/src/core/FileLoader.cpp +++ b/src/core/FileLoader.cpp @@ -1,6 +1,7 @@ #include "common.h" #include "main.h" +#include "General.h" #include "Quaternion.h" #include "ModelInfo.h" #include "ModelIndices.h" @@ -449,6 +450,334 @@ CFileLoader::LoadAtomicFile(RwStream *stream, uint32 id) return true; } +#ifdef HARDCODED_MODEL_FLAGS +char *DoubleSidedNames[] = { + "chnabankdoor", + "Security_Hut", + "Hospital_Sub", + "phonebooth1", + "trafficlight1", + "sub_roadbarrier", + "redlightbuild09", + "doublestreetlght1", + "doc_shedbig31", + "com_land_128", + "garage7", + "proj_garage01", + "buildingground2", + "buildingground3", + "ch_roof_kb", + "overpassind", + "casino", + "ind_land100", + "fuckedup_skewlbus", + "Police_Station_ind", + "flagsitaly", + "sidebarrier_gaz1", + "bar_barrier12", + "bar_barrier10b", + "sidebarrier_gaz2", + "doc_shedbig3", + "doc_shedbig4", + "verticalift_bridge", + "verticalift_bridg2", + "usdcrdlrbuild01", + "apairporthanger", + "apairporthangerA", + "porthangerclosed", + "redlightbuild13", + "doc_rave", + "const_woodfence", + "const_woodfence2", + "const_woodfence3", + "subfraightback01", + "subfraightback02", + "subfraightback03", + "subfraightback04", + "subind_build03", + "chinabanner1", + "chinabanner2", + "chinabanner3", + "chinabanner4", + "Pumpfirescape", + "Pumphouse", + "amcounder", + "barrel1", + "barrel2", + "barrel3", + "barrel4", + "com_1way50", + "com_1way20", + "overpasscom01", + "overpasscom02", + "overpasscom03", + "overpasscom04", + "overpass_comse", + "newdockbuilding", + "newdockbuilding2", + "newdockbuilding", + "policeballhall", + "fuzballdoor", + "ind_land106", + "PoliceBallSigns", + "amcoudet", + "rustship_structure", + "impexpgrgesub", + "ind_land128", + "fshfctry_dstryd", + "railtrax_bentl", + "railtrax_lo4b", + "railtrax_straight", + "railtrax_bentrb", + "railtrax_skew", + "newtrackaaa", + "railtrax_skew5", + // these they forgot: + "railtrax_skewp", + "railtrax_ske2b", + "railtrax_strtshort", + "railtrax_2b", + "railtrax_straightss", + "railtrax_bentr", + "" +}; +char *TreeNames[] = { + "coast_treepatch", + "comparknewtrees", + "comtreepatchprk", + "condotree01", + "condotree1", + "indatree03", + "indtreepatch5", + "indtreepatch06f", + "new_carprktrees", + "new_carprktrees4", + "newcoasttrees1", + "newcoasttrees2", + "newcoasttrees3", + "newtreepatch_sub", + "newtrees1_sub", + "newunitrepatch", + "pinetree_narrow", + "pinetree_wide", + "treencom2", + "treepatch", + "treepatch01_sub", + "treepatch02_sub", + "treepatch2", + "treepatch2b", + "treepatch03", + "treepatch03_sub", + "treepatch04_sub", + "treepatch05_sub", + "treepatch06_sub", + "treepatch07_sub", + "treepatch08_sub", + "treepatch09_sub", + "treepatch10_sub", + "treepatch11_sub", + "treepatch12_sub", + "treepatch13_sub", + "treepatch14_sub", + "treepatch15_sub", + "treepatch16_sub", + "treepatch17_sub", + "treepatch18_sub", + "treepatch19_sub", + "treepatch20_sub", + "treepatch21_sub", + "treepatch22_sub", + "treepatch23_sub", + "treepatch24_sub", + "treepatch25_sub", + "treepatch26_sub", + "treepatch27_sub", + "treepatch28_sub", + "treepatch29_sub", + "treepatch30_sub", + "treepatch31_sub", + "treepatch32_sub", + "treepatch33_sub", + "treepatch34_sub", + "treepatch35_sub", + "treepatch69", + "treepatch152_sub", + "treepatch153_sub", + "treepatch171_sub", + "treepatch172_sub", + "treepatch173_sub", + "treepatch212_sub", + "treepatch213_sub", + "treepatch214_sub", + "treepatcha", + "treepatchb", + "treepatchcomtop1", + "treepatchd", + "treepatche", + "treepatchh", + "treepatchindaa2", + "treepatchindnew", + "treepatchindnew2", + "treepatchk", + "treepatchkb4", + "treepatchkb5", + "treepatchkb6", + "treepatchkb7", + "treepatchkb9", + "treepatchl", + "treepatchm", + "treepatchnew_sub", + "treepatchttwrs", + "treesuni1", + "trepatchindaa1", + "veg_bush2", + "veg_bush14", + "veg_tree1", + "veg_tree3", + "veg_treea1", + "veg_treea3", + "veg_treeb1", + "veg_treenew01", + "veg_treenew03", + "veg_treenew05", + "veg_treenew06", + "veg_treenew08", + "veg_treenew09", + "veg_treenew10", + "veg_treenew16", + "veg_treenew17", + "vegclubtree01", + "vegclubtree02", + "vegclubtree03", + "vegpathtree", + "" +}; +char *OptimizedNames[] = { + "coast_treepatch", + "comparknewtrees", + "comtreepatchprk", + "indtreepatch5", + "indtreepatch06f", + "new_carprktrees", + "new_carprktrees4", + "newcoasttrees1", + "newcoasttrees2", + "newcoasttrees3", + "newtreepatch_sub", + "newtrees1_sub", + "newunitrepatch", + "treepatch", + "treepatch01_sub", + "treepatch02_sub", + "treepatch2", + "treepatch2b", + "treepatch03", + "treepatch03_sub", + "treepatch04_sub", + "treepatch05_sub", + "treepatch06_sub", + "treepatch07_sub", + "treepatch08_sub", + "treepatch09_sub", + "treepatch10_sub", + "treepatch11_sub", + "treepatch12_sub", + "treepatch13_sub", + "treepatch14_sub", + "treepatch15_sub", + "treepatch16_sub", + "treepatch17_sub", + "treepatch18_sub", + "treepatch19_sub", + "treepatch20_sub", + "treepatch21_sub", + "treepatch22_sub", + "treepatch23_sub", + "treepatch24_sub", + "treepatch25_sub", + "treepatch26_sub", + "treepatch27_sub", + "treepatch28_sub", + "treepatch29_sub", + "treepatch30_sub", + "treepatch31_sub", + "treepatch32_sub", + "treepatch33_sub", + "treepatch34_sub", + "treepatch35_sub", + "treepatch69", + "treepatch152_sub", + "treepatch153_sub", + "treepatch171_sub", + "treepatch172_sub", + "treepatch173_sub", + "treepatch212_sub", + "treepatch213_sub", + "treepatch214_sub", + "treepatcha", + "treepatchb", + "treepatchcomtop1", + "treepatchd", + "treepatche", + "treepatchh", + "treepatchindaa2", + "treepatchindnew", + "treepatchindnew2", + "treepatchk", + "treepatchkb4", + "treepatchkb5", + "treepatchkb6", + "treepatchkb7", + "treepatchkb9", + "treepatchl", + "treepatchm", + "treepatchnew_sub", + "treepatchttwrs", + "treesuni1", + "trepatchindaa1", + "combtm_treeshad01", + "combtm_treeshad02", + "combtm_treeshad03", + "combtm_treeshad04", + "combtm_treeshad05", + "combtm_treeshad06", + "comtop_tshad", + "comtop_tshad2", + "comtop_tshad3", + "comtop_tshad4", + "comtop_tshad5", + "comtop_tshad6", + "se_treeshad01", + "se_treeshad02", + "se_treeshad03", + "se_treeshad04", + "se_treeshad05", + "se_treeshad06", + "treeshads01", + "treeshads02", + "treeshads03", + "treeshads04", + "treeshads05", + "" +}; +// not from mobile +static bool +MatchModelName(char *name, char **list) +{ + int i; + char *s; + for(i = 0; *list[i] != '\0'; i++) + if(strncmp(name, "LOD", 3) == 0){ + if(!CGeneral::faststricmp(name+3, list[i]+3)) + return true; + }else{ + if(!CGeneral::faststricmp(name, list[i])) + return true; + } + return false; +} +#endif + RpAtomic* CFileLoader::SetRelatedModelInfoCB(RpAtomic *atomic, void *data) { @@ -600,6 +929,21 @@ SetModelInfoFlags(CSimpleModelInfo *mi, uint32 flags) mi->m_isSubway = !!(flags & 0x10); mi->m_ignoreLight = !!(flags & 0x20); mi->m_noZwrite = !!(flags & 0x40); +#ifdef EXTRA_MODEL_FLAGS + // same flag values as SA + mi->m_bIsTree = !!(flags & 0x2000); + mi->m_bIsDoubleSided = !!(flags & 0x200000); + // new value otherwise unused + mi->m_bCanBeIgnored = !!(flags & 0x10000); + +#ifdef HARDCODED_MODEL_FLAGS + // mobile sets these flags in CFileLoader::SetRelatedModelInfoCB, but that's stupid + if(MatchModelName(mi->GetName(), DoubleSidedNames)) mi->m_bIsDoubleSided = true; + if(MatchModelName(mi->GetName(), TreeNames)) mi->m_bIsTree = true; + if(MatchModelName(mi->GetName(), OptimizedNames)) mi->m_bCanBeIgnored = true; +#endif + +#endif } void diff --git a/src/core/config.h b/src/core/config.h index 171c6be9..fd89391b 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -201,6 +201,9 @@ enum Config { #define LOAD_INI_SETTINGS // Rendering/display +#define EXTRA_MODEL_FLAGS // from mobile to optimize rendering +# define HARDCODED_MODEL_FLAGS // sets the flags enabled above from hardcoded model names. + // NB: keep this enabled unless your map IDEs have these flags baked in #define ASPECT_RATIO_SCALE // Not just makes everything scale with aspect ratio, also adds support for all aspect ratios #define DEFAULT_NATIVE_RESOLUTION // Set default video mode to your native resolution (fixes Windows 10 launch) #define USE_TXD_CDIMAGE // generate and load textures from txd.img diff --git a/src/extras/custompipes.cpp b/src/extras/custompipes.cpp index b545b4d8..8c2b6916 100644 --- a/src/extras/custompipes.cpp +++ b/src/extras/custompipes.cpp @@ -337,7 +337,7 @@ ReadTweakValueTable(char *fp, InterpolatedValue &interp) * Neo Vehicle pipe */ -int32 VehiclePipeSwitch = VEHICLEPIPE_NEO; +int32 VehiclePipeSwitch = VEHICLEPIPE_MATFX; float VehicleShininess = 0.7f; // the default is a bit extreme float VehicleSpecularity = 1.0f; InterpolatedFloat Fresnel(0.4f); diff --git a/src/modelinfo/BaseModelInfo.h b/src/modelinfo/BaseModelInfo.h index 783f871f..2505967b 100644 --- a/src/modelinfo/BaseModelInfo.h +++ b/src/modelinfo/BaseModelInfo.h @@ -31,6 +31,14 @@ protected: ModelInfoType m_type; uint8 m_num2dEffects; bool m_bOwnsColModel; +#ifdef EXTRA_MODEL_FLAGS +public: + // from mobile + bool m_bIsDoubleSided; + bool m_bIsTree; + bool m_bCanBeIgnored; // for low-end devices + bool RenderDoubleSided(void) { return m_bIsDoubleSided || m_bIsTree; } +#endif public: CBaseModelInfo(ModelInfoType type); diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 8c194067..4ad1d3b9 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -53,6 +53,14 @@ CVehicle *CRenderer::m_pFirstPersonVehicle; bool CRenderer::m_loadingPriority; float CRenderer::ms_lodDistScale = 1.2f; +#ifdef EXTRA_MODEL_FLAGS +#define BACKFACE_CULLING_ON SetCullMode(rwCULLMODECULLBACK) +#define BACKFACE_CULLING_OFF SetCullMode(rwCULLMODECULLNONE) +#else +#define BACKFACE_CULLING_ON +#define BACKFACE_CULLING_OFF +#endif + void CRenderer::Init(void) { @@ -101,6 +109,13 @@ CRenderer::RenderOneRoad(CEntity *e) else{ #ifdef EXTENDED_PIPELINES CustomPipes::AttachGlossPipe(e->GetAtomic()); +#endif +#ifdef EXTRA_MODEL_FLAGS + if(CModelInfo::GetModelInfo(e->GetModelIndex())->RenderDoubleSided()){ + BACKFACE_CULLING_OFF; + e->Render(); + BACKFACE_CULLING_ON; + }else #endif e->Render(); } @@ -163,13 +178,22 @@ CRenderer::RenderOneNonRoad(CEntity *e) for(i = 0; i < 8; i++) if(veh->pPassengers[i] && veh->pPassengers[i]->m_nPedState == PED_DRIVING) veh->pPassengers[i]->Render(); + BACKFACE_CULLING_OFF; } +#ifdef EXTRA_MODEL_FLAGS + if(CModelInfo::GetModelInfo(e->GetModelIndex())->RenderDoubleSided()){ + BACKFACE_CULLING_OFF; + e->Render(); + BACKFACE_CULLING_ON; + }else +#endif e->Render(); if(e->IsVehicle()){ e->bImBeingRendered = true; CVisibilityPlugins::RenderAlphaAtomics(); e->bImBeingRendered = false; + BACKFACE_CULLING_ON; } e->RemoveLighting(resetLights); @@ -197,6 +221,7 @@ CRenderer::RenderRoads(void) CTreadable *t; RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE); + BACKFACE_CULLING_ON; DeActivateDirectional(); SetAmbientColours(); @@ -230,6 +255,7 @@ CRenderer::RenderEverythingBarRoads(void) CVector dist; EntityInfo ei; + BACKFACE_CULLING_ON; gSortedVehiclesAndPeds.Clear(); for(i = 0; i < ms_nNoOfVisibleEntities; i++){ @@ -284,6 +310,8 @@ CRenderer::RenderBoats(void) { CLink *node; + BACKFACE_CULLING_ON; + for(node = gSortedVehiclesAndPeds.tail.prev; node != &gSortedVehiclesAndPeds.head; node = node->prev){ @@ -298,6 +326,7 @@ void CRenderer::RenderFadingInEntities(void) { RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE); + BACKFACE_CULLING_ON; DeActivateDirectional(); SetAmbientColours(); CVisibilityPlugins::RenderFadingEntities(); diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp index 4b598e9b..6a7010e2 100644 --- a/src/rw/RwHelper.cpp +++ b/src/rw/RwHelper.cpp @@ -3,6 +3,7 @@ #endif #include "common.h" +#include "RwHelper.h" #include "Timecycle.h" #include "skeleton.h" #include "Debug.h" @@ -16,6 +17,7 @@ bool gPS2alphaTest = true; #else bool gPS2alphaTest = false; #endif +bool gBackfaceCulling = true; #ifndef FINAL static bool charsetOpen; @@ -121,14 +123,32 @@ DefinedState(void) #ifdef LIBRW rw::SetRenderState(rw::ALPHATESTFUNC, rw::ALPHAGREATEREQUAL); - rw::SetRenderState(rw::ALPHATESTREF, 3); rw::SetRenderState(rw::GSALPHATEST, gPS2alphaTest); #else // D3D stuff RwD3D8SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER); - RwD3D8SetRenderState(D3DRS_ALPHAREF, 2); #endif + SetAlphaRef(2); +} + +void +SetAlphaRef(int ref) +{ +#ifdef LIBRW + rw::SetRenderState(rw::ALPHATESTREF, ref+1); +#else + RwD3D8SetRenderState(D3DRS_ALPHAREF, ref); +#endif +} + +void +SetCullMode(uint32 mode) +{ + if(gBackfaceCulling) + RwRenderStateSet(rwRENDERSTATECULLMODE, (void*)mode); + else + RwRenderStateSet(rwRENDERSTATECULLMODE, (void*)rwCULLMODECULLNONE); } RwFrame* diff --git a/src/rw/RwHelper.h b/src/rw/RwHelper.h index eceaee07..130eb636 100644 --- a/src/rw/RwHelper.h +++ b/src/rw/RwHelper.h @@ -11,6 +11,8 @@ void DestroyDebugFont(); void ObrsPrintfString(const char *str, short x, short y); void FlushObrsPrintfs(); void DefinedState(void); +void SetAlphaRef(int ref); +void SetCullMode(uint32 mode); RwFrame *GetFirstChild(RwFrame *frame); RwObject *GetFirstObject(RwFrame *frame); RpAtomic *GetFirstAtomic(RpClump *clump); diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp index b2e252a0..c47cedca 100644 --- a/src/rw/VisibilityPlugins.cpp +++ b/src/rw/VisibilityPlugins.cpp @@ -1,5 +1,6 @@ #include "common.h" +#include "RwHelper.h" #include "templates.h" #include "Entity.h" #include "ModelInfo.h" @@ -158,6 +159,10 @@ CVisibilityPlugins::RenderFadingEntities(void) if(mi->m_noZwrite) #endif RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, FALSE); +#ifdef EXTRA_MODEL_FLAGS + if(mi->m_bIsTree) + SetAlphaRef(128); +#endif if(e->bDistanceFade){ DeActivateDirectional(); @@ -168,6 +173,10 @@ CVisibilityPlugins::RenderFadingEntities(void) }else CRenderer::RenderOneNonRoad(e); +#ifdef EXTRA_MODEL_FLAGS + if(mi->m_bIsTree) + SetAlphaRef(2); +#endif #ifdef FIX_BUGS if(mi->GetModelType() == MITYPE_SIMPLE && mi->m_noZwrite) #else From e95516032f4e44ea35b7358f60c464c0faa1df91 Mon Sep 17 00:00:00 2001 From: withmorten Date: Thu, 29 Oct 2020 19:01:09 +0100 Subject: [PATCH 49/60] fix FINAL build, add DEBUGMENU and other simple qol defines to FINAL, add extra defines for menu and game version text --- src/core/Frontend.cpp | 2 ++ src/core/config.h | 24 ++++++++++++++++++++---- src/core/main.cpp | 3 +++ src/rw/RwHelper.cpp | 6 ++++-- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 89b5ba3d..5c65aed5 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -789,9 +789,11 @@ CMenuManager::Draw() CFont::SetScale(MENU_X(0.7f), MENU_Y(0.5f)); CFont::SetWrapx(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)); CFont::SetRightJustifyWrap(0.0f); +#ifdef DRAW_MENU_VERSION_TEXT strcpy(gString, "V1.1"); AsciiToUnicode(gString, gUString); CFont::PrintString(SCREEN_WIDTH / 10, SCREEN_HEIGHT / 45, gUString); +#endif #endif CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(MENU_X_MARGIN)); CFont::SetRightJustifyWrap(SCREEN_SCALE_X(MENUACTION_WIDTH)); diff --git a/src/core/config.h b/src/core/config.h index 171c6be9..92c0511f 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -156,6 +156,25 @@ enum Config { // any debug stuff that is only left in mobile, is not in MASTER //#define MASTER +// once and for all: +// pc: FINAL & MASTER +// mobile: FINAL + +// MASTER builds must be FINAL +#ifdef MASTER +#define FINAL +#endif + +// quality of life fixes that should also be in FINAL +#define NASTY_GAME // nasty game for all languages +#define NO_MOVIES // disable intro videos +#define NO_CDCHECK +#define DEBUGMENU + +// those infamous texts +#define DRAW_GAME_VERSION_TEXT +#define DRAW_MENU_VERSION_TEXT + #if defined GTA_PS2 # define GTA_PS2_STUFF # define RANDOMSPLASH @@ -177,6 +196,7 @@ enum Config { #ifdef MASTER // only in master builds + #undef DRAW_GAME_VERSION_TEXT #else // not in master builds #define VALIDATE_SAVE_SIZE @@ -187,11 +207,7 @@ enum Config { # define USE_MY_DOCUMENTS // use my documents directory for user files #else // not in any game -# define NASTY_GAME // nasty game for all languages -# define NO_MOVIES // disable intro videos -# define NO_CDCHECK # define CHATTYSPLASH // print what the game is loading -# define DEBUGMENU # define TIMEBARS // print debug timers #endif diff --git a/src/core/main.cpp b/src/core/main.cpp index 18ee2dc5..1aa0a953 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -768,6 +768,8 @@ DisplayGameDebugText() char str[200]; wchar ustr[200]; + +#ifdef DRAW_GAME_VERSION_TEXT wchar ver[200]; AsciiToUnicode(version_name, ver); @@ -783,6 +785,7 @@ DisplayGameDebugText() CFont::SetBackGroundOnlyTextOff(); CFont::SetColor(CRGBA(255, 108, 0, 255)); CFont::PrintString(SCREEN_SCALE_X(10.0f), SCREEN_SCALE_Y(10.0f), ver); +#endif FrameSamples++; FramesPerSecondCounter += 1000.0f / (CTimer::GetTimeStepNonClippedInSeconds() * 1000.0f); diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp index 4b598e9b..dbadae6a 100644 --- a/src/rw/RwHelper.cpp +++ b/src/rw/RwHelper.cpp @@ -6,8 +6,10 @@ #include "Timecycle.h" #include "skeleton.h" #include "Debug.h" -#ifndef FINAL +#if !defined(FINAL) || defined(DEBUGMENU) #include "rtcharse.h" +#endif +#ifndef FINAL RtCharset *debugCharset; #endif @@ -17,7 +19,7 @@ bool gPS2alphaTest = true; bool gPS2alphaTest = false; #endif -#ifndef FINAL +#if !defined(FINAL) || defined(DEBUGMENU) static bool charsetOpen; void OpenCharsetSafe() { From 317393d763097af07bb56b1eeac2b70e91cceb98 Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 29 Oct 2020 19:21:16 +0100 Subject: [PATCH 50/60] few more fixes to last commit --- src/core/config.h | 4 ++-- src/rw/VisibilityPlugins.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/config.h b/src/core/config.h index fd89391b..a7de3a8a 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -201,8 +201,8 @@ enum Config { #define LOAD_INI_SETTINGS // Rendering/display -#define EXTRA_MODEL_FLAGS // from mobile to optimize rendering -# define HARDCODED_MODEL_FLAGS // sets the flags enabled above from hardcoded model names. +//#define EXTRA_MODEL_FLAGS // from mobile to optimize rendering +//# define HARDCODED_MODEL_FLAGS // sets the flags enabled above from hardcoded model names. // NB: keep this enabled unless your map IDEs have these flags baked in #define ASPECT_RATIO_SCALE // Not just makes everything scale with aspect ratio, also adds support for all aspect ratios #define DEFAULT_NATIVE_RESOLUTION // Set default video mode to your native resolution (fixes Windows 10 launch) diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp index c47cedca..8878a26a 100644 --- a/src/rw/VisibilityPlugins.cpp +++ b/src/rw/VisibilityPlugins.cpp @@ -160,7 +160,7 @@ CVisibilityPlugins::RenderFadingEntities(void) #endif RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, FALSE); #ifdef EXTRA_MODEL_FLAGS - if(mi->m_bIsTree) + else if(mi->m_bIsTree) SetAlphaRef(128); #endif From 57b01ac4769b0ac83150f2284f5bad87f2f166a3 Mon Sep 17 00:00:00 2001 From: withmorten Date: Thu, 29 Oct 2020 19:23:59 +0100 Subject: [PATCH 51/60] NO_MOVIES and DEBUGMENU not for MASTER --- src/core/config.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/config.h b/src/core/config.h index 92c0511f..019ff659 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -167,9 +167,7 @@ enum Config { // quality of life fixes that should also be in FINAL #define NASTY_GAME // nasty game for all languages -#define NO_MOVIES // disable intro videos #define NO_CDCHECK -#define DEBUGMENU // those infamous texts #define DRAW_GAME_VERSION_TEXT @@ -200,6 +198,9 @@ enum Config { #else // not in master builds #define VALIDATE_SAVE_SIZE + + #define NO_MOVIES // disable intro videos + #define DEBUGMENU #endif #ifdef FINAL From d34d591ed36557d88d2d0485965e7f7337ed25de Mon Sep 17 00:00:00 2001 From: withmorten Date: Thu, 29 Oct 2020 19:53:23 +0100 Subject: [PATCH 52/60] fix draw menu version text ifdef location --- src/core/Frontend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 5c65aed5..dca9685e 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -783,13 +783,13 @@ CMenuManager::Draw() CFont::SetJustifyOn(); CFont::SetBackGroundOnlyTextOn(); #ifdef GTA3_1_1_PATCH +#ifdef DRAW_MENU_VERSION_TEXT CFont::SetColor(CRGBA(235, 170, 50, FadeIn(255))); CFont::SetRightJustifyOn(); CFont::SetFontStyle(FONT_HEADING); CFont::SetScale(MENU_X(0.7f), MENU_Y(0.5f)); CFont::SetWrapx(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)); CFont::SetRightJustifyWrap(0.0f); -#ifdef DRAW_MENU_VERSION_TEXT strcpy(gString, "V1.1"); AsciiToUnicode(gString, gUString); CFont::PrintString(SCREEN_WIDTH / 10, SCREEN_HEIGHT / 45, gUString); From 0fbf6246238129a90f63a1cc38725dbff80b5eab Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Fri, 30 Oct 2020 16:45:13 +0100 Subject: [PATCH 53/60] Update librw --- vendor/librw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/librw b/vendor/librw index 4e8396af..e68ef137 160000 --- a/vendor/librw +++ b/vendor/librw @@ -1 +1 @@ -Subproject commit 4e8396af2656a0aec5d5092a3128d9df3dcaf4c6 +Subproject commit e68ef1374d20071887348e9031f5fa38a2e4f7ed From 30c0f26f171b96443b9f897c816450a281cf216c Mon Sep 17 00:00:00 2001 From: aap Date: Sat, 31 Oct 2020 22:09:43 +0100 Subject: [PATCH 54/60] fix sniper crosshair --- src/render/Hud.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 83c493bb..3d6e59f6 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -247,7 +247,7 @@ void CHud::Draw() rect.right = SCREEN_WIDTH/2 + SCREEN_SCALE_X(210.0f); rect.bottom = SCREEN_HEIGHT/2 + SCREEN_SCALE_Y(210.0f); Sprites[HUD_SITESNIPER].Draw(CRect(rect), CRGBA(255, 255, 255, 255), - 0.99f, 0.99f, 0.01f, 0.99f, 0.99f, 0.01f, 0.1f, 0.01f); + 0.99f, 0.99f, 0.01f, 0.99f, 0.99f, 0.01f, 0.01f, 0.01f); } } RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void *)rwFILTERLINEAR); From 3c4f166a82d5760849e0f8a02c28a46d734a6c6d Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 1 Nov 2020 09:20:37 +0200 Subject: [PATCH 55/60] Fix virtual SetModelIndex call in CBoat ctor --- src/vehicles/Boat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp index dfe9d1d9..a33b9770 100644 --- a/src/vehicles/Boat.cpp +++ b/src/vehicles/Boat.cpp @@ -48,7 +48,7 @@ CBoat::CBoat(int mi, uint8 owner) : CVehicle(owner) m_fSteeringLeftRight = 0.0f; m_nPadID = 0; m_fMovingRotation = 0.0f; - SetModelIndex(mi); + CBoat::SetModelIndex(mi); pHandling = mod_HandlingManager.GetHandlingData((eHandlingId)minfo->m_handlingId); minfo->ChooseVehicleColour(m_currentColour1, m_currentColour2); From 5711251b0fcf3333c2f96b48dd784fe4c6e1ba25 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 1 Nov 2020 09:46:02 +0200 Subject: [PATCH 56/60] Also fix SetModelIndex in CAutomobile and CTrain ctors --- src/vehicles/Automobile.cpp | 2 +- src/vehicles/Train.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index 95a68769..a1c38d21 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -73,7 +73,7 @@ CAutomobile::CAutomobile(int32 id, uint8 CreatedBy) bBigWheels = false; bWaterTight = false; - SetModelIndex(id); + CAutomobile::SetModelIndex(id); pHandling = mod_HandlingManager.GetHandlingData((eHandlingId)mi->m_handlingId); diff --git a/src/vehicles/Train.cpp b/src/vehicles/Train.cpp index 26d0dee7..98d522a7 100644 --- a/src/vehicles/Train.cpp +++ b/src/vehicles/Train.cpp @@ -44,7 +44,7 @@ CTrain::CTrain(int32 id, uint8 CreatedBy) CVehicleModelInfo *mi = (CVehicleModelInfo*)CModelInfo::GetModelInfo(id); m_vehType = VEHICLE_TYPE_TRAIN; pHandling = mod_HandlingManager.GetHandlingData((eHandlingId)mi->m_handlingId); - SetModelIndex(id); + CTrain::SetModelIndex(id); Doors[0].Init(0.8f, 0.0f, 1, 0); Doors[1].Init(-0.8f, 0.0f, 0, 0); From f21cfef8fb92a0923c6ddfa26124cf6da1fa883c Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sun, 1 Nov 2020 12:33:16 +0300 Subject: [PATCH 57/60] remove autosave at end of mission under MISSION_REPLAY --- src/control/Script.cpp | 2 ++ vendor/ogg | 2 +- vendor/opusfile | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/control/Script.cpp b/src/control/Script.cpp index 6bde6b87..86595bbd 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -2696,8 +2696,10 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) #ifdef MISSION_REPLAY if (m_bMissionFlag) { CPlayerInfo* pPlayerInfo = &CWorld::Players[CWorld::PlayerInFocus]; +#if 0 // makeing autosave is pointless and is a bit buggy if (pPlayerInfo->m_pPed->GetPedState() != PED_DEAD && pPlayerInfo->m_WBState == WBSTATE_PLAYING && !m_bDeatharrestExecuted) SaveGameForPause(1); +#endif oldTargetX = oldTargetY = 0.0f; if (AllowMissionReplay == 1) AllowMissionReplay = 2; diff --git a/vendor/ogg b/vendor/ogg index 684c7377..36f969bb 160000 --- a/vendor/ogg +++ b/vendor/ogg @@ -1 +1 @@ -Subproject commit 684c73773e7e2683245ffd6aa75f04115b51123a +Subproject commit 36f969bb37559345ee03796ed625a9abd42c6db9 diff --git a/vendor/opusfile b/vendor/opusfile index f94a1764..4174c26e 160000 --- a/vendor/opusfile +++ b/vendor/opusfile @@ -1 +1 @@ -Subproject commit f94a1764b0dcdd84ee8c13c040de9f4c1a67e4df +Subproject commit 4174c26e0aaab19d01afdea0a46f7f95fdc6b3e6 From 1f5a6dab67d37af7e3686e29fc81d0f8e5bb5597 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 1 Nov 2020 12:30:23 +0200 Subject: [PATCH 58/60] Revert --- src/vehicles/Automobile.cpp | 2 +- src/vehicles/Boat.cpp | 2 +- src/vehicles/Train.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index a1c38d21..95a68769 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -73,7 +73,7 @@ CAutomobile::CAutomobile(int32 id, uint8 CreatedBy) bBigWheels = false; bWaterTight = false; - CAutomobile::SetModelIndex(id); + SetModelIndex(id); pHandling = mod_HandlingManager.GetHandlingData((eHandlingId)mi->m_handlingId); diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp index a33b9770..dfe9d1d9 100644 --- a/src/vehicles/Boat.cpp +++ b/src/vehicles/Boat.cpp @@ -48,7 +48,7 @@ CBoat::CBoat(int mi, uint8 owner) : CVehicle(owner) m_fSteeringLeftRight = 0.0f; m_nPadID = 0; m_fMovingRotation = 0.0f; - CBoat::SetModelIndex(mi); + SetModelIndex(mi); pHandling = mod_HandlingManager.GetHandlingData((eHandlingId)minfo->m_handlingId); minfo->ChooseVehicleColour(m_currentColour1, m_currentColour2); diff --git a/src/vehicles/Train.cpp b/src/vehicles/Train.cpp index 98d522a7..26d0dee7 100644 --- a/src/vehicles/Train.cpp +++ b/src/vehicles/Train.cpp @@ -44,7 +44,7 @@ CTrain::CTrain(int32 id, uint8 CreatedBy) CVehicleModelInfo *mi = (CVehicleModelInfo*)CModelInfo::GetModelInfo(id); m_vehType = VEHICLE_TYPE_TRAIN; pHandling = mod_HandlingManager.GetHandlingData((eHandlingId)mi->m_handlingId); - CTrain::SetModelIndex(id); + SetModelIndex(id); Doors[0].Init(0.8f, 0.0f, 1, 0); Doors[1].Init(-0.8f, 0.0f, 0, 0); From 37943a87cbafcc0a0ad0a4a5b05a20e48ddf72de Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 1 Nov 2020 13:42:02 +0200 Subject: [PATCH 59/60] Show Xbox buttons when playing with a controller --- src/core/ControllerConfig.cpp | 408 ++++++++++++++++++++++++++++++++++ 1 file changed, 408 insertions(+) diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index 576a58b1..1af29a85 100644 --- a/src/core/ControllerConfig.cpp +++ b/src/core/ControllerConfig.cpp @@ -2316,8 +2316,416 @@ int32 CControllerConfigManager::GetNumOfSettingsForAction(e_ControllerAction act return num; } +const char *XboxButtons[][MAX_CONTROLLERACTIONS] = +{ + { + "B", // PED_FIREWEAPON + "RT", // PED_CYCLE_WEAPON_RIGHT + "LT", // PED_CYCLE_WEAPON_LEFT + nil, // GO_FORWARD + nil, // GO_BACK + nil, // GO_LEFT + nil, // GO_RIGHT + "X", // PED_SNIPER_ZOOM_IN + "A", // PED_SNIPER_ZOOM_OUT + "Y", // VEHICLE_ENTER_EXIT + "BACK", // CAMERA_CHANGE_VIEW_ALL_SITUATIONS + "X", // PED_JUMPING + "A", // PED_SPRINT + "RS", // PED_LOOKBEHIND +#ifdef BIND_VEHICLE_FIREWEAPON + "B", // VEHICLE_FIREWEAPON +#endif + "A", // VEHICLE_ACCELERATE + "X", // VEHICLE_BRAKE + "LB", // VEHICLE_CHANGE_RADIO_STATION + "LS", // VEHICLE_HORN + "RS", // TOGGLE_SUBMISSIONS + "RB", // VEHICLE_HANDBRAKE + nil, // PED_1RST_PERSON_LOOK_LEFT + nil, // PED_1RST_PERSON_LOOK_RIGHT + "LT", // VEHICLE_LOOKLEFT + "RT", // VEHICLE_LOOKRIGHT + nil, // VEHICLE_LOOKBEHIND + nil, // VEHICLE_TURRETLEFT + nil, // VEHICLE_TURRETRIGHT + nil, // VEHICLE_TURRETUP + nil, // VEHICLE_TURRETDOWN + "LT", // PED_CYCLE_TARGET_LEFT + "RT", // PED_CYCLE_TARGET_RIGHT + "LB", // PED_CENTER_CAMERA_BEHIND_PLAYER + "RB", // PED_LOCK_TARGET + nil, // NETWORK_TALK + nil, // PED_1RST_PERSON_LOOK_UP + nil, // PED_1RST_PERSON_LOOK_DOWN + nil, // _CONTROLLERACTION_36 + nil, // TOGGLE_DPAD + nil, // SWITCH_DEBUG_CAM_ON + nil, // TAKE_SCREEN_SHOT + nil, // SHOW_MOUSE_POINTER_TOGGLE + }, + { + "B", // PED_FIREWEAPON + "RT", // PED_CYCLE_WEAPON_RIGHT + "LT", // PED_CYCLE_WEAPON_LEFT + nil, // GO_FORWARD + nil, // GO_BACK + nil, // GO_LEFT + nil, // GO_RIGHT + "X", // PED_SNIPER_ZOOM_IN + "A", // PED_SNIPER_ZOOM_OUT + "Y", // VEHICLE_ENTER_EXIT + "BACK", // CAMERA_CHANGE_VIEW_ALL_SITUATIONS + "X", // PED_JUMPING + "A", // PED_SPRINT + "RS", // PED_LOOKBEHIND +#ifdef BIND_VEHICLE_FIREWEAPON + "B", // VEHICLE_FIREWEAPON +#endif + "A", // VEHICLE_ACCELERATE + "X", // VEHICLE_BRAKE + "BACK", // VEHICLE_CHANGE_RADIO_STATION + "LB", // VEHICLE_HORN + "RS", // TOGGLE_SUBMISSIONS + "RB", // VEHICLE_HANDBRAKE + nil, // PED_1RST_PERSON_LOOK_LEFT + nil, // PED_1RST_PERSON_LOOK_RIGHT + "LT", // VEHICLE_LOOKLEFT + "RT", // VEHICLE_LOOKRIGHT + nil, // VEHICLE_LOOKBEHIND + nil, // VEHICLE_TURRETLEFT + nil, // VEHICLE_TURRETRIGHT + nil, // VEHICLE_TURRETUP + nil, // VEHICLE_TURRETDOWN + "LT", // PED_CYCLE_TARGET_LEFT + "RT", // PED_CYCLE_TARGET_RIGHT + "LB", // PED_CENTER_CAMERA_BEHIND_PLAYER + "RB", // PED_LOCK_TARGET + nil, // NETWORK_TALK + nil, // PED_1RST_PERSON_LOOK_UP + nil, // PED_1RST_PERSON_LOOK_DOWN + nil, // _CONTROLLERACTION_36 + nil, // TOGGLE_DPAD + nil, // SWITCH_DEBUG_CAM_ON + nil, // TAKE_SCREEN_SHOT + nil, // SHOW_MOUSE_POINTER_TOGGLE + }, + { + "A", // PED_FIREWEAPON + "RT", // PED_CYCLE_WEAPON_RIGHT + "LT", // PED_CYCLE_WEAPON_LEFT + nil, // GO_FORWARD + nil, // GO_BACK + nil, // GO_LEFT + nil, // GO_RIGHT + "Y", // PED_SNIPER_ZOOM_IN + "X", // PED_SNIPER_ZOOM_OUT + "LB", // VEHICLE_ENTER_EXIT + "BACK", // CAMERA_CHANGE_VIEW_ALL_SITUATIONS + "X", // PED_JUMPING + "B", // PED_SPRINT + "RS", // PED_LOOKBEHIND +#ifdef BIND_VEHICLE_FIREWEAPON + "B", // VEHICLE_FIREWEAPON +#endif + "A", // VEHICLE_ACCELERATE + "X", // VEHICLE_BRAKE + "LS", // VEHICLE_CHANGE_RADIO_STATION + "RB", // VEHICLE_HORN + "RS", // TOGGLE_SUBMISSIONS + "Y", // VEHICLE_HANDBRAKE + nil, // PED_1RST_PERSON_LOOK_LEFT + nil, // PED_1RST_PERSON_LOOK_RIGHT + "LT", // VEHICLE_LOOKLEFT + "RT", // VEHICLE_LOOKRIGHT + nil, // VEHICLE_LOOKBEHIND + nil, // VEHICLE_TURRETLEFT + nil, // VEHICLE_TURRETRIGHT + nil, // VEHICLE_TURRETUP + nil, // VEHICLE_TURRETDOWN + "LT", // PED_CYCLE_TARGET_LEFT + "RT", // PED_CYCLE_TARGET_RIGHT + "Y", // PED_CENTER_CAMERA_BEHIND_PLAYER + "RB", // PED_LOCK_TARGET + nil, // NETWORK_TALK + nil, // PED_1RST_PERSON_LOOK_UP + nil, // PED_1RST_PERSON_LOOK_DOWN + nil, // _CONTROLLERACTION_36 + nil, // TOGGLE_DPAD + nil, // SWITCH_DEBUG_CAM_ON + nil, // TAKE_SCREEN_SHOT + nil, // SHOW_MOUSE_POINTER_TOGGLE + }, + { + "RB", // PED_FIREWEAPON + "RT", // PED_CYCLE_WEAPON_RIGHT + "LT", // PED_CYCLE_WEAPON_LEFT + nil, // GO_FORWARD + nil, // GO_BACK + nil, // GO_LEFT + nil, // GO_RIGHT + "X", // PED_SNIPER_ZOOM_IN + "A", // PED_SNIPER_ZOOM_OUT + "Y", // VEHICLE_ENTER_EXIT + "BACK", // CAMERA_CHANGE_VIEW_ALL_SITUATIONS + "X", // PED_JUMPING + "A", // PED_SPRINT + "RS", // PED_LOOKBEHIND +#ifdef BIND_VEHICLE_FIREWEAPON + "RB", // VEHICLE_FIREWEAPON +#endif + nil, // VEHICLE_ACCELERATE + nil, // VEHICLE_BRAKE + "B", // VEHICLE_CHANGE_RADIO_STATION + "LS", // VEHICLE_HORN + "X", // TOGGLE_SUBMISSIONS + "LB", // VEHICLE_HANDBRAKE + nil, // PED_1RST_PERSON_LOOK_LEFT + nil, // PED_1RST_PERSON_LOOK_RIGHT + "LT", // VEHICLE_LOOKLEFT + "RT", // VEHICLE_LOOKRIGHT + nil, // VEHICLE_LOOKBEHIND + nil, // VEHICLE_TURRETLEFT + nil, // VEHICLE_TURRETRIGHT + nil, // VEHICLE_TURRETUP + nil, // VEHICLE_TURRETDOWN + "LT", // PED_CYCLE_TARGET_LEFT + "RT", // PED_CYCLE_TARGET_RIGHT + "B", // PED_CENTER_CAMERA_BEHIND_PLAYER + "LB", // PED_LOCK_TARGET + nil, // NETWORK_TALK + nil, // PED_1RST_PERSON_LOOK_UP + nil, // PED_1RST_PERSON_LOOK_DOWN + nil, // _CONTROLLERACTION_36 + nil, // TOGGLE_DPAD + nil, // SWITCH_DEBUG_CAM_ON + nil, // TAKE_SCREEN_SHOT + nil, // SHOW_MOUSE_POINTER_TOGGLE + } +}; + +#if 0 // set 1 for ps2 fonts +#define PS2_TRIANGLE "\"" +#define PS2_CIRCLE "|" +#define PS2_CROSS "/" +#define PS2_SQUARE "^" +#else +#define PS2_TRIANGLE "TRIANGLE" +#define PS2_CIRCLE "CIRCLE" +#define PS2_CROSS "CROSS" +#define PS2_SQUARE "SQUARE" +#endif + +const char *PlayStationButtons[][MAX_CONTROLLERACTIONS] = +{ + { + PS2_CIRCLE, // PED_FIREWEAPON + "R2", // PED_CYCLE_WEAPON_RIGHT + "L2", // PED_CYCLE_WEAPON_LEFT + nil, // GO_FORWARD + nil, // GO_BACK + nil, // GO_LEFT + nil, // GO_RIGHT + PS2_SQUARE, // PED_SNIPER_ZOOM_IN + PS2_CROSS, // PED_SNIPER_ZOOM_OUT + PS2_TRIANGLE, // VEHICLE_ENTER_EXIT + "SELECT", // CAMERA_CHANGE_VIEW_ALL_SITUATIONS + PS2_SQUARE, // PED_JUMPING + PS2_CROSS, // PED_SPRINT + "R3", // PED_LOOKBEHIND +#ifdef BIND_VEHICLE_FIREWEAPON + PS2_CIRCLE, // VEHICLE_FIREWEAPON +#endif + PS2_CROSS, // VEHICLE_ACCELERATE + PS2_SQUARE, // VEHICLE_BRAKE + "L1", // VEHICLE_CHANGE_RADIO_STATION + "L3", // VEHICLE_HORN + "R3", // TOGGLE_SUBMISSIONS + "R1", // VEHICLE_HANDBRAKE + nil, // PED_1RST_PERSON_LOOK_LEFT + nil, // PED_1RST_PERSON_LOOK_RIGHT + "L2", // VEHICLE_LOOKLEFT + "R2", // VEHICLE_LOOKRIGHT + nil, // VEHICLE_LOOKBEHIND + nil, // VEHICLE_TURRETLEFT + nil, // VEHICLE_TURRETRIGHT + nil, // VEHICLE_TURRETUP + nil, // VEHICLE_TURRETDOWN + "L2", // PED_CYCLE_TARGET_LEFT + "R2", // PED_CYCLE_TARGET_RIGHT + "L1", // PED_CENTER_CAMERA_BEHIND_PLAYER + "R1", // PED_LOCK_TARGET + nil, // NETWORK_TALK + nil, // PED_1RST_PERSON_LOOK_UP + nil, // PED_1RST_PERSON_LOOK_DOWN + nil, // _CONTROLLERACTION_36 + nil, // TOGGLE_DPAD + nil, // SWITCH_DEBUG_CAM_ON + nil, // TAKE_SCREEN_SHOT + nil, // SHOW_MOUSE_POINTER_TOGGLE + }, + { + PS2_CIRCLE, // PED_FIREWEAPON + "R2", // PED_CYCLE_WEAPON_RIGHT + "L2", // PED_CYCLE_WEAPON_LEFT + nil, // GO_FORWARD + nil, // GO_BACK + nil, // GO_LEFT + nil, // GO_RIGHT + PS2_SQUARE, // PED_SNIPER_ZOOM_IN + PS2_CROSS, // PED_SNIPER_ZOOM_OUT + PS2_TRIANGLE, // VEHICLE_ENTER_EXIT + "SELECT", // CAMERA_CHANGE_VIEW_ALL_SITUATIONS + PS2_SQUARE, // PED_JUMPING + PS2_CROSS, // PED_SPRINT + "R3", // PED_LOOKBEHIND +#ifdef BIND_VEHICLE_FIREWEAPON + PS2_CIRCLE, // VEHICLE_FIREWEAPON +#endif + PS2_CROSS, // VEHICLE_ACCELERATE + PS2_SQUARE, // VEHICLE_BRAKE + "BACK", // VEHICLE_CHANGE_RADIO_STATION + "L1", // VEHICLE_HORN + "R3", // TOGGLE_SUBMISSIONS + "R1", // VEHICLE_HANDBRAKE + nil, // PED_1RST_PERSON_LOOK_LEFT + nil, // PED_1RST_PERSON_LOOK_RIGHT + "L2", // VEHICLE_LOOKLEFT + "R2", // VEHICLE_LOOKRIGHT + nil, // VEHICLE_LOOKBEHIND + nil, // VEHICLE_TURRETLEFT + nil, // VEHICLE_TURRETRIGHT + nil, // VEHICLE_TURRETUP + nil, // VEHICLE_TURRETDOWN + "L2", // PED_CYCLE_TARGET_LEFT + "R2", // PED_CYCLE_TARGET_RIGHT + "L1", // PED_CENTER_CAMERA_BEHIND_PLAYER + "R1", // PED_LOCK_TARGET + nil, // NETWORK_TALK + nil, // PED_1RST_PERSON_LOOK_UP + nil, // PED_1RST_PERSON_LOOK_DOWN + nil, // _CONTROLLERACTION_36 + nil, // TOGGLE_DPAD + nil, // SWITCH_DEBUG_CAM_ON + nil, // TAKE_SCREEN_SHOT + nil, // SHOW_MOUSE_POINTER_TOGGLE + }, + { + PS2_CROSS, // PED_FIREWEAPON + "R2", // PED_CYCLE_WEAPON_RIGHT + "L2", // PED_CYCLE_WEAPON_LEFT + nil, // GO_FORWARD + nil, // GO_BACK + nil, // GO_LEFT + nil, // GO_RIGHT + PS2_TRIANGLE, // PED_SNIPER_ZOOM_IN + PS2_SQUARE, // PED_SNIPER_ZOOM_OUT + "L1", // VEHICLE_ENTER_EXIT + "BACK", // CAMERA_CHANGE_VIEW_ALL_SITUATIONS + PS2_SQUARE, // PED_JUMPING + PS2_CIRCLE, // PED_SPRINT + "R3", // PED_LOOKBEHIND +#ifdef BIND_VEHICLE_FIREWEAPON + PS2_CIRCLE, // VEHICLE_FIREWEAPON +#endif + PS2_CROSS, // VEHICLE_ACCELERATE + PS2_SQUARE, // VEHICLE_BRAKE + "L3", // VEHICLE_CHANGE_RADIO_STATION + "R1", // VEHICLE_HORN + "R3", // TOGGLE_SUBMISSIONS + PS2_TRIANGLE, // VEHICLE_HANDBRAKE + nil, // PED_1RST_PERSON_LOOK_LEFT + nil, // PED_1RST_PERSON_LOOK_RIGHT + "L2", // VEHICLE_LOOKLEFT + "R2", // VEHICLE_LOOKRIGHT + nil, // VEHICLE_LOOKBEHIND + nil, // VEHICLE_TURRETLEFT + nil, // VEHICLE_TURRETRIGHT + nil, // VEHICLE_TURRETUP + nil, // VEHICLE_TURRETDOWN + "L2", // PED_CYCLE_TARGET_LEFT + "R2", // PED_CYCLE_TARGET_RIGHT + PS2_TRIANGLE, // PED_CENTER_CAMERA_BEHIND_PLAYER + "R1", // PED_LOCK_TARGET + nil, // NETWORK_TALK + nil, // PED_1RST_PERSON_LOOK_UP + nil, // PED_1RST_PERSON_LOOK_DOWN + nil, // _CONTROLLERACTION_36 + nil, // TOGGLE_DPAD + nil, // SWITCH_DEBUG_CAM_ON + nil, // TAKE_SCREEN_SHOT + nil, // SHOW_MOUSE_POINTER_TOGGLE + }, + { + "R1", // PED_FIREWEAPON + "R2", // PED_CYCLE_WEAPON_RIGHT + "L2", // PED_CYCLE_WEAPON_LEFT + nil, // GO_FORWARD + nil, // GO_BACK + nil, // GO_LEFT + nil, // GO_RIGHT + PS2_SQUARE, // PED_SNIPER_ZOOM_IN + PS2_CROSS, // PED_SNIPER_ZOOM_OUT + PS2_TRIANGLE, // VEHICLE_ENTER_EXIT + "SELECT", // CAMERA_CHANGE_VIEW_ALL_SITUATIONS + PS2_SQUARE, // PED_JUMPING + PS2_CROSS, // PED_SPRINT + "R3", // PED_LOOKBEHIND +#ifdef BIND_VEHICLE_FIREWEAPON + "R1", // VEHICLE_FIREWEAPON +#endif + nil, // VEHICLE_ACCELERATE + nil, // VEHICLE_BRAKE + PS2_CIRCLE, // VEHICLE_CHANGE_RADIO_STATION + "L3", // VEHICLE_HORN + PS2_SQUARE, // TOGGLE_SUBMISSIONS + "L1", // VEHICLE_HANDBRAKE + nil, // PED_1RST_PERSON_LOOK_LEFT + nil, // PED_1RST_PERSON_LOOK_RIGHT + "L2", // VEHICLE_LOOKLEFT + "R2", // VEHICLE_LOOKRIGHT + nil, // VEHICLE_LOOKBEHIND + nil, // VEHICLE_TURRETLEFT + nil, // VEHICLE_TURRETRIGHT + nil, // VEHICLE_TURRETUP + nil, // VEHICLE_TURRETDOWN + "L2", // PED_CYCLE_TARGET_LEFT + "R2", // PED_CYCLE_TARGET_RIGHT + PS2_CIRCLE, // PED_CENTER_CAMERA_BEHIND_PLAYER + "L1", // PED_LOCK_TARGET + nil, // NETWORK_TALK + nil, // PED_1RST_PERSON_LOOK_UP + nil, // PED_1RST_PERSON_LOOK_DOWN + nil, // _CONTROLLERACTION_36 + nil, // TOGGLE_DPAD + nil, // SWITCH_DEBUG_CAM_ON + nil, // TAKE_SCREEN_SHOT + nil, // SHOW_MOUSE_POINTER_TOGGLE + } +}; + +#undef PS2_TRIANGLE +#undef PS2_CIRCLE +#undef PS2_CROSS +#undef PS2_SQUARE + void CControllerConfigManager::GetWideStringOfCommandKeys(uint16 action, wchar *text, uint16 leight) { +#ifdef DETECT_PAD_INPUT_SWITCH + if (CPad::GetPad(0)->IsAffectedByController) { + wchar wstr[16]; + + // TODO: INI and/or menu setting for Xbox/PS switch + const char *(*Buttons)[MAX_CONTROLLERACTIONS] = XboxButtons; + + assert(Buttons[CPad::GetPad(0)->Mode][action] != nil); // we cannot use these + AsciiToUnicode(Buttons[CPad::GetPad(0)->Mode][action], wstr); + + CMessages::WideStringCopy(text, wstr, leight); + return; + } +#endif + int32 nums = GetNumOfSettingsForAction((e_ControllerAction)action); int32 sets = 0; From 30d1cbfecd6e9fb477a0b5672d830b871be9722d Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 1 Nov 2020 13:46:12 +0200 Subject: [PATCH 60/60] Fix the goddamn spaces for tabs master race --- src/core/ControllerConfig.cpp | 568 +++++++++++++++++----------------- 1 file changed, 284 insertions(+), 284 deletions(-) diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index 1af29a85..dcc294c8 100644 --- a/src/core/ControllerConfig.cpp +++ b/src/core/ControllerConfig.cpp @@ -2318,161 +2318,161 @@ int32 CControllerConfigManager::GetNumOfSettingsForAction(e_ControllerAction act const char *XboxButtons[][MAX_CONTROLLERACTIONS] = { - { - "B", // PED_FIREWEAPON - "RT", // PED_CYCLE_WEAPON_RIGHT - "LT", // PED_CYCLE_WEAPON_LEFT - nil, // GO_FORWARD - nil, // GO_BACK - nil, // GO_LEFT - nil, // GO_RIGHT - "X", // PED_SNIPER_ZOOM_IN - "A", // PED_SNIPER_ZOOM_OUT - "Y", // VEHICLE_ENTER_EXIT - "BACK", // CAMERA_CHANGE_VIEW_ALL_SITUATIONS - "X", // PED_JUMPING - "A", // PED_SPRINT - "RS", // PED_LOOKBEHIND + { + "B", // PED_FIREWEAPON + "RT", // PED_CYCLE_WEAPON_RIGHT + "LT", // PED_CYCLE_WEAPON_LEFT + nil, // GO_FORWARD + nil, // GO_BACK + nil, // GO_LEFT + nil, // GO_RIGHT + "X", // PED_SNIPER_ZOOM_IN + "A", // PED_SNIPER_ZOOM_OUT + "Y", // VEHICLE_ENTER_EXIT + "BACK", // CAMERA_CHANGE_VIEW_ALL_SITUATIONS + "X", // PED_JUMPING + "A", // PED_SPRINT + "RS", // PED_LOOKBEHIND #ifdef BIND_VEHICLE_FIREWEAPON - "B", // VEHICLE_FIREWEAPON + "B", // VEHICLE_FIREWEAPON #endif - "A", // VEHICLE_ACCELERATE - "X", // VEHICLE_BRAKE - "LB", // VEHICLE_CHANGE_RADIO_STATION - "LS", // VEHICLE_HORN - "RS", // TOGGLE_SUBMISSIONS - "RB", // VEHICLE_HANDBRAKE - nil, // PED_1RST_PERSON_LOOK_LEFT - nil, // PED_1RST_PERSON_LOOK_RIGHT - "LT", // VEHICLE_LOOKLEFT - "RT", // VEHICLE_LOOKRIGHT - nil, // VEHICLE_LOOKBEHIND - nil, // VEHICLE_TURRETLEFT - nil, // VEHICLE_TURRETRIGHT - nil, // VEHICLE_TURRETUP - nil, // VEHICLE_TURRETDOWN - "LT", // PED_CYCLE_TARGET_LEFT - "RT", // PED_CYCLE_TARGET_RIGHT - "LB", // PED_CENTER_CAMERA_BEHIND_PLAYER - "RB", // PED_LOCK_TARGET - nil, // NETWORK_TALK - nil, // PED_1RST_PERSON_LOOK_UP - nil, // PED_1RST_PERSON_LOOK_DOWN - nil, // _CONTROLLERACTION_36 - nil, // TOGGLE_DPAD - nil, // SWITCH_DEBUG_CAM_ON - nil, // TAKE_SCREEN_SHOT - nil, // SHOW_MOUSE_POINTER_TOGGLE + "A", // VEHICLE_ACCELERATE + "X", // VEHICLE_BRAKE + "LB", // VEHICLE_CHANGE_RADIO_STATION + "LS", // VEHICLE_HORN + "RS", // TOGGLE_SUBMISSIONS + "RB", // VEHICLE_HANDBRAKE + nil, // PED_1RST_PERSON_LOOK_LEFT + nil, // PED_1RST_PERSON_LOOK_RIGHT + "LT", // VEHICLE_LOOKLEFT + "RT", // VEHICLE_LOOKRIGHT + nil, // VEHICLE_LOOKBEHIND + nil, // VEHICLE_TURRETLEFT + nil, // VEHICLE_TURRETRIGHT + nil, // VEHICLE_TURRETUP + nil, // VEHICLE_TURRETDOWN + "LT", // PED_CYCLE_TARGET_LEFT + "RT", // PED_CYCLE_TARGET_RIGHT + "LB", // PED_CENTER_CAMERA_BEHIND_PLAYER + "RB", // PED_LOCK_TARGET + nil, // NETWORK_TALK + nil, // PED_1RST_PERSON_LOOK_UP + nil, // PED_1RST_PERSON_LOOK_DOWN + nil, // _CONTROLLERACTION_36 + nil, // TOGGLE_DPAD + nil, // SWITCH_DEBUG_CAM_ON + nil, // TAKE_SCREEN_SHOT + nil, // SHOW_MOUSE_POINTER_TOGGLE }, { - "B", // PED_FIREWEAPON - "RT", // PED_CYCLE_WEAPON_RIGHT - "LT", // PED_CYCLE_WEAPON_LEFT - nil, // GO_FORWARD - nil, // GO_BACK - nil, // GO_LEFT - nil, // GO_RIGHT - "X", // PED_SNIPER_ZOOM_IN - "A", // PED_SNIPER_ZOOM_OUT - "Y", // VEHICLE_ENTER_EXIT - "BACK", // CAMERA_CHANGE_VIEW_ALL_SITUATIONS - "X", // PED_JUMPING - "A", // PED_SPRINT - "RS", // PED_LOOKBEHIND + "B", // PED_FIREWEAPON + "RT", // PED_CYCLE_WEAPON_RIGHT + "LT", // PED_CYCLE_WEAPON_LEFT + nil, // GO_FORWARD + nil, // GO_BACK + nil, // GO_LEFT + nil, // GO_RIGHT + "X", // PED_SNIPER_ZOOM_IN + "A", // PED_SNIPER_ZOOM_OUT + "Y", // VEHICLE_ENTER_EXIT + "BACK", // CAMERA_CHANGE_VIEW_ALL_SITUATIONS + "X", // PED_JUMPING + "A", // PED_SPRINT + "RS", // PED_LOOKBEHIND #ifdef BIND_VEHICLE_FIREWEAPON - "B", // VEHICLE_FIREWEAPON + "B", // VEHICLE_FIREWEAPON #endif - "A", // VEHICLE_ACCELERATE - "X", // VEHICLE_BRAKE - "BACK", // VEHICLE_CHANGE_RADIO_STATION - "LB", // VEHICLE_HORN - "RS", // TOGGLE_SUBMISSIONS - "RB", // VEHICLE_HANDBRAKE - nil, // PED_1RST_PERSON_LOOK_LEFT - nil, // PED_1RST_PERSON_LOOK_RIGHT - "LT", // VEHICLE_LOOKLEFT - "RT", // VEHICLE_LOOKRIGHT - nil, // VEHICLE_LOOKBEHIND - nil, // VEHICLE_TURRETLEFT - nil, // VEHICLE_TURRETRIGHT - nil, // VEHICLE_TURRETUP - nil, // VEHICLE_TURRETDOWN - "LT", // PED_CYCLE_TARGET_LEFT - "RT", // PED_CYCLE_TARGET_RIGHT - "LB", // PED_CENTER_CAMERA_BEHIND_PLAYER - "RB", // PED_LOCK_TARGET - nil, // NETWORK_TALK - nil, // PED_1RST_PERSON_LOOK_UP - nil, // PED_1RST_PERSON_LOOK_DOWN - nil, // _CONTROLLERACTION_36 - nil, // TOGGLE_DPAD - nil, // SWITCH_DEBUG_CAM_ON - nil, // TAKE_SCREEN_SHOT - nil, // SHOW_MOUSE_POINTER_TOGGLE + "A", // VEHICLE_ACCELERATE + "X", // VEHICLE_BRAKE + "BACK", // VEHICLE_CHANGE_RADIO_STATION + "LB", // VEHICLE_HORN + "RS", // TOGGLE_SUBMISSIONS + "RB", // VEHICLE_HANDBRAKE + nil, // PED_1RST_PERSON_LOOK_LEFT + nil, // PED_1RST_PERSON_LOOK_RIGHT + "LT", // VEHICLE_LOOKLEFT + "RT", // VEHICLE_LOOKRIGHT + nil, // VEHICLE_LOOKBEHIND + nil, // VEHICLE_TURRETLEFT + nil, // VEHICLE_TURRETRIGHT + nil, // VEHICLE_TURRETUP + nil, // VEHICLE_TURRETDOWN + "LT", // PED_CYCLE_TARGET_LEFT + "RT", // PED_CYCLE_TARGET_RIGHT + "LB", // PED_CENTER_CAMERA_BEHIND_PLAYER + "RB", // PED_LOCK_TARGET + nil, // NETWORK_TALK + nil, // PED_1RST_PERSON_LOOK_UP + nil, // PED_1RST_PERSON_LOOK_DOWN + nil, // _CONTROLLERACTION_36 + nil, // TOGGLE_DPAD + nil, // SWITCH_DEBUG_CAM_ON + nil, // TAKE_SCREEN_SHOT + nil, // SHOW_MOUSE_POINTER_TOGGLE }, { - "A", // PED_FIREWEAPON - "RT", // PED_CYCLE_WEAPON_RIGHT - "LT", // PED_CYCLE_WEAPON_LEFT - nil, // GO_FORWARD - nil, // GO_BACK - nil, // GO_LEFT - nil, // GO_RIGHT - "Y", // PED_SNIPER_ZOOM_IN - "X", // PED_SNIPER_ZOOM_OUT - "LB", // VEHICLE_ENTER_EXIT - "BACK", // CAMERA_CHANGE_VIEW_ALL_SITUATIONS - "X", // PED_JUMPING - "B", // PED_SPRINT - "RS", // PED_LOOKBEHIND + "A", // PED_FIREWEAPON + "RT", // PED_CYCLE_WEAPON_RIGHT + "LT", // PED_CYCLE_WEAPON_LEFT + nil, // GO_FORWARD + nil, // GO_BACK + nil, // GO_LEFT + nil, // GO_RIGHT + "Y", // PED_SNIPER_ZOOM_IN + "X", // PED_SNIPER_ZOOM_OUT + "LB", // VEHICLE_ENTER_EXIT + "BACK", // CAMERA_CHANGE_VIEW_ALL_SITUATIONS + "X", // PED_JUMPING + "B", // PED_SPRINT + "RS", // PED_LOOKBEHIND #ifdef BIND_VEHICLE_FIREWEAPON - "B", // VEHICLE_FIREWEAPON + "B", // VEHICLE_FIREWEAPON #endif - "A", // VEHICLE_ACCELERATE - "X", // VEHICLE_BRAKE - "LS", // VEHICLE_CHANGE_RADIO_STATION - "RB", // VEHICLE_HORN - "RS", // TOGGLE_SUBMISSIONS - "Y", // VEHICLE_HANDBRAKE - nil, // PED_1RST_PERSON_LOOK_LEFT - nil, // PED_1RST_PERSON_LOOK_RIGHT - "LT", // VEHICLE_LOOKLEFT - "RT", // VEHICLE_LOOKRIGHT - nil, // VEHICLE_LOOKBEHIND - nil, // VEHICLE_TURRETLEFT - nil, // VEHICLE_TURRETRIGHT - nil, // VEHICLE_TURRETUP - nil, // VEHICLE_TURRETDOWN - "LT", // PED_CYCLE_TARGET_LEFT - "RT", // PED_CYCLE_TARGET_RIGHT - "Y", // PED_CENTER_CAMERA_BEHIND_PLAYER - "RB", // PED_LOCK_TARGET - nil, // NETWORK_TALK - nil, // PED_1RST_PERSON_LOOK_UP - nil, // PED_1RST_PERSON_LOOK_DOWN - nil, // _CONTROLLERACTION_36 - nil, // TOGGLE_DPAD - nil, // SWITCH_DEBUG_CAM_ON - nil, // TAKE_SCREEN_SHOT - nil, // SHOW_MOUSE_POINTER_TOGGLE + "A", // VEHICLE_ACCELERATE + "X", // VEHICLE_BRAKE + "LS", // VEHICLE_CHANGE_RADIO_STATION + "RB", // VEHICLE_HORN + "RS", // TOGGLE_SUBMISSIONS + "Y", // VEHICLE_HANDBRAKE + nil, // PED_1RST_PERSON_LOOK_LEFT + nil, // PED_1RST_PERSON_LOOK_RIGHT + "LT", // VEHICLE_LOOKLEFT + "RT", // VEHICLE_LOOKRIGHT + nil, // VEHICLE_LOOKBEHIND + nil, // VEHICLE_TURRETLEFT + nil, // VEHICLE_TURRETRIGHT + nil, // VEHICLE_TURRETUP + nil, // VEHICLE_TURRETDOWN + "LT", // PED_CYCLE_TARGET_LEFT + "RT", // PED_CYCLE_TARGET_RIGHT + "Y", // PED_CENTER_CAMERA_BEHIND_PLAYER + "RB", // PED_LOCK_TARGET + nil, // NETWORK_TALK + nil, // PED_1RST_PERSON_LOOK_UP + nil, // PED_1RST_PERSON_LOOK_DOWN + nil, // _CONTROLLERACTION_36 + nil, // TOGGLE_DPAD + nil, // SWITCH_DEBUG_CAM_ON + nil, // TAKE_SCREEN_SHOT + nil, // SHOW_MOUSE_POINTER_TOGGLE }, { - "RB", // PED_FIREWEAPON - "RT", // PED_CYCLE_WEAPON_RIGHT - "LT", // PED_CYCLE_WEAPON_LEFT - nil, // GO_FORWARD - nil, // GO_BACK - nil, // GO_LEFT - nil, // GO_RIGHT - "X", // PED_SNIPER_ZOOM_IN - "A", // PED_SNIPER_ZOOM_OUT - "Y", // VEHICLE_ENTER_EXIT - "BACK", // CAMERA_CHANGE_VIEW_ALL_SITUATIONS - "X", // PED_JUMPING - "A", // PED_SPRINT - "RS", // PED_LOOKBEHIND + "RB", // PED_FIREWEAPON + "RT", // PED_CYCLE_WEAPON_RIGHT + "LT", // PED_CYCLE_WEAPON_LEFT + nil, // GO_FORWARD + nil, // GO_BACK + nil, // GO_LEFT + nil, // GO_RIGHT + "X", // PED_SNIPER_ZOOM_IN + "A", // PED_SNIPER_ZOOM_OUT + "Y", // VEHICLE_ENTER_EXIT + "BACK", // CAMERA_CHANGE_VIEW_ALL_SITUATIONS + "X", // PED_JUMPING + "A", // PED_SPRINT + "RS", // PED_LOOKBEHIND #ifdef BIND_VEHICLE_FIREWEAPON - "RB", // VEHICLE_FIREWEAPON + "RB", // VEHICLE_FIREWEAPON #endif nil, // VEHICLE_ACCELERATE nil, // VEHICLE_BRAKE @@ -2518,161 +2518,161 @@ const char *XboxButtons[][MAX_CONTROLLERACTIONS] = const char *PlayStationButtons[][MAX_CONTROLLERACTIONS] = { - { - PS2_CIRCLE, // PED_FIREWEAPON - "R2", // PED_CYCLE_WEAPON_RIGHT - "L2", // PED_CYCLE_WEAPON_LEFT - nil, // GO_FORWARD - nil, // GO_BACK - nil, // GO_LEFT - nil, // GO_RIGHT - PS2_SQUARE, // PED_SNIPER_ZOOM_IN - PS2_CROSS, // PED_SNIPER_ZOOM_OUT - PS2_TRIANGLE, // VEHICLE_ENTER_EXIT - "SELECT", // CAMERA_CHANGE_VIEW_ALL_SITUATIONS - PS2_SQUARE, // PED_JUMPING - PS2_CROSS, // PED_SPRINT - "R3", // PED_LOOKBEHIND + { + PS2_CIRCLE, // PED_FIREWEAPON + "R2", // PED_CYCLE_WEAPON_RIGHT + "L2", // PED_CYCLE_WEAPON_LEFT + nil, // GO_FORWARD + nil, // GO_BACK + nil, // GO_LEFT + nil, // GO_RIGHT + PS2_SQUARE, // PED_SNIPER_ZOOM_IN + PS2_CROSS, // PED_SNIPER_ZOOM_OUT + PS2_TRIANGLE, // VEHICLE_ENTER_EXIT + "SELECT", // CAMERA_CHANGE_VIEW_ALL_SITUATIONS + PS2_SQUARE, // PED_JUMPING + PS2_CROSS, // PED_SPRINT + "R3", // PED_LOOKBEHIND #ifdef BIND_VEHICLE_FIREWEAPON - PS2_CIRCLE, // VEHICLE_FIREWEAPON + PS2_CIRCLE, // VEHICLE_FIREWEAPON #endif - PS2_CROSS, // VEHICLE_ACCELERATE - PS2_SQUARE, // VEHICLE_BRAKE - "L1", // VEHICLE_CHANGE_RADIO_STATION - "L3", // VEHICLE_HORN - "R3", // TOGGLE_SUBMISSIONS - "R1", // VEHICLE_HANDBRAKE - nil, // PED_1RST_PERSON_LOOK_LEFT - nil, // PED_1RST_PERSON_LOOK_RIGHT - "L2", // VEHICLE_LOOKLEFT - "R2", // VEHICLE_LOOKRIGHT - nil, // VEHICLE_LOOKBEHIND - nil, // VEHICLE_TURRETLEFT - nil, // VEHICLE_TURRETRIGHT - nil, // VEHICLE_TURRETUP - nil, // VEHICLE_TURRETDOWN - "L2", // PED_CYCLE_TARGET_LEFT - "R2", // PED_CYCLE_TARGET_RIGHT - "L1", // PED_CENTER_CAMERA_BEHIND_PLAYER - "R1", // PED_LOCK_TARGET - nil, // NETWORK_TALK - nil, // PED_1RST_PERSON_LOOK_UP - nil, // PED_1RST_PERSON_LOOK_DOWN - nil, // _CONTROLLERACTION_36 - nil, // TOGGLE_DPAD - nil, // SWITCH_DEBUG_CAM_ON - nil, // TAKE_SCREEN_SHOT - nil, // SHOW_MOUSE_POINTER_TOGGLE + PS2_CROSS, // VEHICLE_ACCELERATE + PS2_SQUARE, // VEHICLE_BRAKE + "L1", // VEHICLE_CHANGE_RADIO_STATION + "L3", // VEHICLE_HORN + "R3", // TOGGLE_SUBMISSIONS + "R1", // VEHICLE_HANDBRAKE + nil, // PED_1RST_PERSON_LOOK_LEFT + nil, // PED_1RST_PERSON_LOOK_RIGHT + "L2", // VEHICLE_LOOKLEFT + "R2", // VEHICLE_LOOKRIGHT + nil, // VEHICLE_LOOKBEHIND + nil, // VEHICLE_TURRETLEFT + nil, // VEHICLE_TURRETRIGHT + nil, // VEHICLE_TURRETUP + nil, // VEHICLE_TURRETDOWN + "L2", // PED_CYCLE_TARGET_LEFT + "R2", // PED_CYCLE_TARGET_RIGHT + "L1", // PED_CENTER_CAMERA_BEHIND_PLAYER + "R1", // PED_LOCK_TARGET + nil, // NETWORK_TALK + nil, // PED_1RST_PERSON_LOOK_UP + nil, // PED_1RST_PERSON_LOOK_DOWN + nil, // _CONTROLLERACTION_36 + nil, // TOGGLE_DPAD + nil, // SWITCH_DEBUG_CAM_ON + nil, // TAKE_SCREEN_SHOT + nil, // SHOW_MOUSE_POINTER_TOGGLE }, { - PS2_CIRCLE, // PED_FIREWEAPON - "R2", // PED_CYCLE_WEAPON_RIGHT - "L2", // PED_CYCLE_WEAPON_LEFT - nil, // GO_FORWARD - nil, // GO_BACK - nil, // GO_LEFT - nil, // GO_RIGHT - PS2_SQUARE, // PED_SNIPER_ZOOM_IN - PS2_CROSS, // PED_SNIPER_ZOOM_OUT - PS2_TRIANGLE, // VEHICLE_ENTER_EXIT - "SELECT", // CAMERA_CHANGE_VIEW_ALL_SITUATIONS - PS2_SQUARE, // PED_JUMPING - PS2_CROSS, // PED_SPRINT - "R3", // PED_LOOKBEHIND + PS2_CIRCLE, // PED_FIREWEAPON + "R2", // PED_CYCLE_WEAPON_RIGHT + "L2", // PED_CYCLE_WEAPON_LEFT + nil, // GO_FORWARD + nil, // GO_BACK + nil, // GO_LEFT + nil, // GO_RIGHT + PS2_SQUARE, // PED_SNIPER_ZOOM_IN + PS2_CROSS, // PED_SNIPER_ZOOM_OUT + PS2_TRIANGLE, // VEHICLE_ENTER_EXIT + "SELECT", // CAMERA_CHANGE_VIEW_ALL_SITUATIONS + PS2_SQUARE, // PED_JUMPING + PS2_CROSS, // PED_SPRINT + "R3", // PED_LOOKBEHIND #ifdef BIND_VEHICLE_FIREWEAPON - PS2_CIRCLE, // VEHICLE_FIREWEAPON + PS2_CIRCLE, // VEHICLE_FIREWEAPON #endif - PS2_CROSS, // VEHICLE_ACCELERATE - PS2_SQUARE, // VEHICLE_BRAKE - "BACK", // VEHICLE_CHANGE_RADIO_STATION - "L1", // VEHICLE_HORN - "R3", // TOGGLE_SUBMISSIONS - "R1", // VEHICLE_HANDBRAKE - nil, // PED_1RST_PERSON_LOOK_LEFT - nil, // PED_1RST_PERSON_LOOK_RIGHT - "L2", // VEHICLE_LOOKLEFT - "R2", // VEHICLE_LOOKRIGHT - nil, // VEHICLE_LOOKBEHIND - nil, // VEHICLE_TURRETLEFT - nil, // VEHICLE_TURRETRIGHT - nil, // VEHICLE_TURRETUP - nil, // VEHICLE_TURRETDOWN - "L2", // PED_CYCLE_TARGET_LEFT - "R2", // PED_CYCLE_TARGET_RIGHT - "L1", // PED_CENTER_CAMERA_BEHIND_PLAYER - "R1", // PED_LOCK_TARGET - nil, // NETWORK_TALK - nil, // PED_1RST_PERSON_LOOK_UP - nil, // PED_1RST_PERSON_LOOK_DOWN - nil, // _CONTROLLERACTION_36 - nil, // TOGGLE_DPAD - nil, // SWITCH_DEBUG_CAM_ON - nil, // TAKE_SCREEN_SHOT - nil, // SHOW_MOUSE_POINTER_TOGGLE + PS2_CROSS, // VEHICLE_ACCELERATE + PS2_SQUARE, // VEHICLE_BRAKE + "BACK", // VEHICLE_CHANGE_RADIO_STATION + "L1", // VEHICLE_HORN + "R3", // TOGGLE_SUBMISSIONS + "R1", // VEHICLE_HANDBRAKE + nil, // PED_1RST_PERSON_LOOK_LEFT + nil, // PED_1RST_PERSON_LOOK_RIGHT + "L2", // VEHICLE_LOOKLEFT + "R2", // VEHICLE_LOOKRIGHT + nil, // VEHICLE_LOOKBEHIND + nil, // VEHICLE_TURRETLEFT + nil, // VEHICLE_TURRETRIGHT + nil, // VEHICLE_TURRETUP + nil, // VEHICLE_TURRETDOWN + "L2", // PED_CYCLE_TARGET_LEFT + "R2", // PED_CYCLE_TARGET_RIGHT + "L1", // PED_CENTER_CAMERA_BEHIND_PLAYER + "R1", // PED_LOCK_TARGET + nil, // NETWORK_TALK + nil, // PED_1RST_PERSON_LOOK_UP + nil, // PED_1RST_PERSON_LOOK_DOWN + nil, // _CONTROLLERACTION_36 + nil, // TOGGLE_DPAD + nil, // SWITCH_DEBUG_CAM_ON + nil, // TAKE_SCREEN_SHOT + nil, // SHOW_MOUSE_POINTER_TOGGLE }, { - PS2_CROSS, // PED_FIREWEAPON - "R2", // PED_CYCLE_WEAPON_RIGHT - "L2", // PED_CYCLE_WEAPON_LEFT - nil, // GO_FORWARD - nil, // GO_BACK - nil, // GO_LEFT - nil, // GO_RIGHT - PS2_TRIANGLE, // PED_SNIPER_ZOOM_IN - PS2_SQUARE, // PED_SNIPER_ZOOM_OUT - "L1", // VEHICLE_ENTER_EXIT - "BACK", // CAMERA_CHANGE_VIEW_ALL_SITUATIONS - PS2_SQUARE, // PED_JUMPING - PS2_CIRCLE, // PED_SPRINT - "R3", // PED_LOOKBEHIND + PS2_CROSS, // PED_FIREWEAPON + "R2", // PED_CYCLE_WEAPON_RIGHT + "L2", // PED_CYCLE_WEAPON_LEFT + nil, // GO_FORWARD + nil, // GO_BACK + nil, // GO_LEFT + nil, // GO_RIGHT + PS2_TRIANGLE, // PED_SNIPER_ZOOM_IN + PS2_SQUARE, // PED_SNIPER_ZOOM_OUT + "L1", // VEHICLE_ENTER_EXIT + "BACK", // CAMERA_CHANGE_VIEW_ALL_SITUATIONS + PS2_SQUARE, // PED_JUMPING + PS2_CIRCLE, // PED_SPRINT + "R3", // PED_LOOKBEHIND #ifdef BIND_VEHICLE_FIREWEAPON - PS2_CIRCLE, // VEHICLE_FIREWEAPON + PS2_CIRCLE, // VEHICLE_FIREWEAPON #endif - PS2_CROSS, // VEHICLE_ACCELERATE - PS2_SQUARE, // VEHICLE_BRAKE - "L3", // VEHICLE_CHANGE_RADIO_STATION - "R1", // VEHICLE_HORN - "R3", // TOGGLE_SUBMISSIONS - PS2_TRIANGLE, // VEHICLE_HANDBRAKE - nil, // PED_1RST_PERSON_LOOK_LEFT - nil, // PED_1RST_PERSON_LOOK_RIGHT - "L2", // VEHICLE_LOOKLEFT - "R2", // VEHICLE_LOOKRIGHT - nil, // VEHICLE_LOOKBEHIND - nil, // VEHICLE_TURRETLEFT - nil, // VEHICLE_TURRETRIGHT - nil, // VEHICLE_TURRETUP - nil, // VEHICLE_TURRETDOWN - "L2", // PED_CYCLE_TARGET_LEFT - "R2", // PED_CYCLE_TARGET_RIGHT - PS2_TRIANGLE, // PED_CENTER_CAMERA_BEHIND_PLAYER - "R1", // PED_LOCK_TARGET - nil, // NETWORK_TALK - nil, // PED_1RST_PERSON_LOOK_UP - nil, // PED_1RST_PERSON_LOOK_DOWN - nil, // _CONTROLLERACTION_36 - nil, // TOGGLE_DPAD - nil, // SWITCH_DEBUG_CAM_ON - nil, // TAKE_SCREEN_SHOT - nil, // SHOW_MOUSE_POINTER_TOGGLE + PS2_CROSS, // VEHICLE_ACCELERATE + PS2_SQUARE, // VEHICLE_BRAKE + "L3", // VEHICLE_CHANGE_RADIO_STATION + "R1", // VEHICLE_HORN + "R3", // TOGGLE_SUBMISSIONS + PS2_TRIANGLE, // VEHICLE_HANDBRAKE + nil, // PED_1RST_PERSON_LOOK_LEFT + nil, // PED_1RST_PERSON_LOOK_RIGHT + "L2", // VEHICLE_LOOKLEFT + "R2", // VEHICLE_LOOKRIGHT + nil, // VEHICLE_LOOKBEHIND + nil, // VEHICLE_TURRETLEFT + nil, // VEHICLE_TURRETRIGHT + nil, // VEHICLE_TURRETUP + nil, // VEHICLE_TURRETDOWN + "L2", // PED_CYCLE_TARGET_LEFT + "R2", // PED_CYCLE_TARGET_RIGHT + PS2_TRIANGLE, // PED_CENTER_CAMERA_BEHIND_PLAYER + "R1", // PED_LOCK_TARGET + nil, // NETWORK_TALK + nil, // PED_1RST_PERSON_LOOK_UP + nil, // PED_1RST_PERSON_LOOK_DOWN + nil, // _CONTROLLERACTION_36 + nil, // TOGGLE_DPAD + nil, // SWITCH_DEBUG_CAM_ON + nil, // TAKE_SCREEN_SHOT + nil, // SHOW_MOUSE_POINTER_TOGGLE }, { - "R1", // PED_FIREWEAPON - "R2", // PED_CYCLE_WEAPON_RIGHT - "L2", // PED_CYCLE_WEAPON_LEFT - nil, // GO_FORWARD - nil, // GO_BACK - nil, // GO_LEFT - nil, // GO_RIGHT - PS2_SQUARE, // PED_SNIPER_ZOOM_IN - PS2_CROSS, // PED_SNIPER_ZOOM_OUT - PS2_TRIANGLE, // VEHICLE_ENTER_EXIT - "SELECT", // CAMERA_CHANGE_VIEW_ALL_SITUATIONS - PS2_SQUARE, // PED_JUMPING - PS2_CROSS, // PED_SPRINT - "R3", // PED_LOOKBEHIND + "R1", // PED_FIREWEAPON + "R2", // PED_CYCLE_WEAPON_RIGHT + "L2", // PED_CYCLE_WEAPON_LEFT + nil, // GO_FORWARD + nil, // GO_BACK + nil, // GO_LEFT + nil, // GO_RIGHT + PS2_SQUARE, // PED_SNIPER_ZOOM_IN + PS2_CROSS, // PED_SNIPER_ZOOM_OUT + PS2_TRIANGLE, // VEHICLE_ENTER_EXIT + "SELECT", // CAMERA_CHANGE_VIEW_ALL_SITUATIONS + PS2_SQUARE, // PED_JUMPING + PS2_CROSS, // PED_SPRINT + "R3", // PED_LOOKBEHIND #ifdef BIND_VEHICLE_FIREWEAPON - "R1", // VEHICLE_FIREWEAPON + "R1", // VEHICLE_FIREWEAPON #endif nil, // VEHICLE_ACCELERATE nil, // VEHICLE_BRAKE