From d3b11c2b8cc6668d1e92f4575318e91e6c49302c Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Fri, 1 Jan 2021 20:53:25 +0100 Subject: [PATCH 01/10] Encode files to UTF-8 --- src/extras/ini_parser.hpp | 2 +- src/render/WaterLevel.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/extras/ini_parser.hpp b/src/extras/ini_parser.hpp index 99acf1ee..8e88bc29 100644 --- a/src/extras/ini_parser.hpp +++ b/src/extras/ini_parser.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2015 Denilson das Mercęs Amorim + * Copyright (c) 2013-2015 Denilson das MercÊs Amorim * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages diff --git a/src/render/WaterLevel.cpp b/src/render/WaterLevel.cpp index a0c7ae31..7aa01f5a 100644 --- a/src/render/WaterLevel.cpp +++ b/src/render/WaterLevel.cpp @@ -37,7 +37,7 @@ bool CWaterLevel::WavesCalculatedThisFrame; RpAtomic *CWaterLevel::ms_pWavyAtomic; RpGeometry *CWaterLevel::apGeomArray[8]; int16 CWaterLevel::nGeomUsed; -//"Custom" Donīt Render Water Toggle +//"Custom" Don't Render Water Toggle bool gbDontRenderWater; //RwTexture *gpWaterTex; @@ -638,7 +638,7 @@ SectorRadius(float fSize) void CWaterLevel::RenderWater() { -//"Custom" Donīt Render Water Toggle +//"Custom" Don't Render Water Toggle #ifndef MASTER if (gbDontRenderWater) return; -- 2.45.2 From 716e322246f8e75b08d1bf50943d84079b6deb8d Mon Sep 17 00:00:00 2001 From: aap Date: Fri, 1 Jan 2021 23:33:25 +0100 Subject: [PATCH 02/10] increase screen droplet splash dist --- src/extras/screendroplets.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extras/screendroplets.cpp b/src/extras/screendroplets.cpp index 6ea72f09..ac3a17b2 100644 --- a/src/extras/screendroplets.cpp +++ b/src/extras/screendroplets.cpp @@ -391,7 +391,7 @@ void ScreenDroplets::RegisterSplash(CParticleObject *pobj) { CVector dist = pobj->GetPosition() - ms_prevCamPos; - if(dist.MagnitudeSqr() < 20.0f){ + if(dist.MagnitudeSqr() < 50.0f){ // 20 originally ms_splashDuration = 14; ms_splashObject = pobj; } -- 2.45.2 From c587203ebe3db110b8bf00531794cd195010d93d Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 2 Jan 2021 13:28:10 +0200 Subject: [PATCH 03/10] Pad2 fix --- src/core/Pad.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index 7dc9aba0..ac195fc9 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -1109,14 +1109,11 @@ void CPad::UpdatePads(void) bUpdate = false; if ( bUpdate ) - { GetPad(0)->Update(0); -#ifndef SQUEEZE_PERFORMANCE - GetPad(1)->Update(0); -#endif - } -#if defined(MASTER) && !defined(XINPUT) +#ifndef MASTER + GetPad(1)->Update(0); +#else GetPad(1)->NewState.Clear(); GetPad(1)->OldState.Clear(); #endif -- 2.45.2 From 38bca2332d6e4fc2a5d73f7c5909ab0b2ddc4985 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 2 Jan 2021 13:42:27 +0200 Subject: [PATCH 04/10] Fix arg --- src/core/Pad.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index ac195fc9..fd48ba97 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -1112,7 +1112,7 @@ void CPad::UpdatePads(void) GetPad(0)->Update(0); #ifndef MASTER - GetPad(1)->Update(0); + GetPad(1)->Update(1); #else GetPad(1)->NewState.Clear(); GetPad(1)->OldState.Clear(); -- 2.45.2 From 482ff4562f2ed4806c0e51f96b656a7ad80445c7 Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 2 Jan 2021 18:27:11 +0300 Subject: [PATCH 05/10] Vehicle: Automobile: fixes and style things --- src/vehicles/Automobile.cpp | 4 ++++ src/vehicles/HandlingMgr.cpp | 2 +- src/vehicles/Transmission.cpp | 2 +- src/vehicles/Vehicle.cpp | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index 79d3f6af..e66865da 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -216,6 +216,8 @@ CAutomobile::SetModelIndex(uint32 id) CVector vecDAMAGE_ENGINE_POS_SMALL(-0.1f, -0.1f, 0.0f); CVector vecDAMAGE_ENGINE_POS_BIG(-0.5f, -0.3f, 0.0f); +#pragma optimize("", off) // that's what R* did + void CAutomobile::ProcessControl(void) { @@ -1214,6 +1216,8 @@ CAutomobile::ProcessControl(void) } } +#pragma optimize("", on) + void CAutomobile::Teleport(CVector pos) { diff --git a/src/vehicles/HandlingMgr.cpp b/src/vehicles/HandlingMgr.cpp index 3ac6f057..be8150fb 100644 --- a/src/vehicles/HandlingMgr.cpp +++ b/src/vehicles/HandlingMgr.cpp @@ -143,7 +143,7 @@ cHandlingDataMgr::LoadHandlingData(void) case 11: handling->fTractionBias = strtod(word, nil); break; case 12: handling->Transmission.nNumberOfGears = atoi(word); break; case 13: handling->Transmission.fMaxVelocity = strtod(word, nil); break; - case 14: handling->Transmission.fEngineAcceleration = strtod(word, nil) * 0.4f; break; + case 14: handling->Transmission.fEngineAcceleration = strtod(word, nil) * 0.4; break; case 15: handling->Transmission.nDriveType = word[0]; break; case 16: handling->Transmission.nEngineType = word[0]; break; case 17: handling->fBrakeDeceleration = strtod(word, nil); break; diff --git a/src/vehicles/Transmission.cpp b/src/vehicles/Transmission.cpp index 5287055d..109847a5 100644 --- a/src/vehicles/Transmission.cpp +++ b/src/vehicles/Transmission.cpp @@ -128,7 +128,7 @@ cTransmission::CalculateDriveAcceleration(const float &gasPedal, uint8 &gear, fl else fCheat = 1.0f; float targetVelocity = Gears[gear].fMaxVelocity*speedMul*fCheat; - float accel = fEngineAcceleration*accelMul * (targetVelocity - fVelocity)/Abs(targetVelocity); + float accel = (targetVelocity - fVelocity) * (fEngineAcceleration*accelMul) / Abs(targetVelocity); if(Abs(fVelocity) < Abs(Gears[gear].fMaxVelocity*fCheat)) fAcceleration = gasPedal * accel * CTimer::GetTimeStep(); else diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index ba9348f0..eba9c596 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -531,9 +531,9 @@ CVehicle::ProcessWheel(CVector &wheelFwd, CVector &wheelRight, CVector &wheelCon if(!bBraking){ if(m_fGasPedal < 0.01f){ if(GetModelIndex() == MI_RCBANDIT) - brake = 0.2f * mod_HandlingManager.fWheelFriction / m_fMass; + brake = 0.2f * mod_HandlingManager.fWheelFriction / pHandling->m_fMass; else - brake = mod_HandlingManager.fWheelFriction / m_fMass; + brake = mod_HandlingManager.fWheelFriction / pHandling->m_fMass; #ifdef FIX_BUGS brake *= CTimer::GetTimeStepFix(); #endif -- 2.45.2 From cdb65e9ced68f344df6b586012042550eda5bb39 Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 2 Jan 2021 18:30:00 +0300 Subject: [PATCH 06/10] fix fix --- src/vehicles/Vehicle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index eba9c596..b02d1152 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -531,9 +531,9 @@ CVehicle::ProcessWheel(CVector &wheelFwd, CVector &wheelRight, CVector &wheelCon if(!bBraking){ if(m_fGasPedal < 0.01f){ if(GetModelIndex() == MI_RCBANDIT) - brake = 0.2f * mod_HandlingManager.fWheelFriction / pHandling->m_fMass; + brake = 0.2f * mod_HandlingManager.fWheelFriction / pHandling->fMass; else - brake = mod_HandlingManager.fWheelFriction / pHandling->m_fMass; + brake = mod_HandlingManager.fWheelFriction / pHandling->fMass; #ifdef FIX_BUGS brake *= CTimer::GetTimeStepFix(); #endif -- 2.45.2 From 78fed0dfe73fa3abf2e9feebfda35256fe38d930 Mon Sep 17 00:00:00 2001 From: aap Date: Sat, 2 Jan 2021 20:15:01 +0100 Subject: [PATCH 07/10] "clarification" of handling code --- src/vehicles/HandlingMgr.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/vehicles/HandlingMgr.cpp b/src/vehicles/HandlingMgr.cpp index be8150fb..7b60acf2 100644 --- a/src/vehicles/HandlingMgr.cpp +++ b/src/vehicles/HandlingMgr.cpp @@ -202,15 +202,21 @@ cHandlingDataMgr::ConvertDataToGameUnits(tHandlingData *handling) handling->fInvMass = 1.0f/handling->fMass; handling->fBuoyancy = 100.0f/handling->nPercentSubmerged * GRAVITY*handling->fMass; - // What the hell is going on here? - specificVolume = handling->Dimension.x*handling->Dimension.z*0.5f / handling->fMass; // ? + // Don't quite understand this. What seems to be going on is that + // we calculate a drag (air resistance) deceleration for a given velocity and + // find the intersection between that and the max engine acceleration. + // at that point the car cannot accelerate any further and we've found the max velocity. a = 0.0f; b = 100.0f; velocity = handling->Transmission.fMaxVelocity; while(a < b && velocity > 0.0f){ velocity -= 0.01f; + // what's the 1/6? a = handling->Transmission.fEngineAcceleration/6.0f; - b = -velocity * (1.0f/(specificVolume * sq(velocity) + 1.0f) - 1.0f); + // no density or drag coefficient here... + float a_drag = 0.5f*SQR(velocity) * handling->Dimension.x*handling->Dimension.z / handling->fMass; + // can't make sense of this... maybe v - v/(drag + 1) ? but that doesn't make so much sense either + b = -velocity * (1.0f/(a_drag + 1.0f) - 1.0f); } if(handling->nIdentifier == HANDLING_RCBANDIT){ -- 2.45.2 From 0d05be4e31a40d7ed84f5f0d59b7aee7cd40dfaf Mon Sep 17 00:00:00 2001 From: aap Date: Sat, 2 Jan 2021 20:30:12 +0100 Subject: [PATCH 08/10] slightly better variable name --- src/control/Script.cpp | 4 ++-- src/peds/PedAI.cpp | 6 +++--- src/vehicles/HandlingMgr.cpp | 4 ++-- src/vehicles/Transmission.h | 2 +- src/vehicles/Vehicle.cpp | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/control/Script.cpp b/src/control/Script.cpp index 9856a8aa..63f1f2e1 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -3582,9 +3582,9 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) car->AutoPilot.m_nCruiseSpeed = *(float*)&ScriptParams[1]; if (missionRetryScriptIndex == 40 && car->GetModelIndex() == MI_CHEETAH) // Turismo car->AutoPilot.m_nCruiseSpeed = 8 * car->AutoPilot.m_nCruiseSpeed / 10; - car->AutoPilot.m_nCruiseSpeed = Min(car->AutoPilot.m_nCruiseSpeed, 60.0f * car->pHandling->Transmission.fUnkMaxVelocity); + car->AutoPilot.m_nCruiseSpeed = Min(car->AutoPilot.m_nCruiseSpeed, 60.0f * car->pHandling->Transmission.fMaxCruiseVelocity); #else - car->AutoPilot.m_nCruiseSpeed = Min(*(float*)&ScriptParams[1], 60.0f * car->pHandling->Transmission.fUnkMaxVelocity); + car->AutoPilot.m_nCruiseSpeed = Min(*(float*)&ScriptParams[1], 60.0f * car->pHandling->Transmission.fMaxCruiseVelocity); #endif return 0; } diff --git a/src/peds/PedAI.cpp b/src/peds/PedAI.cpp index a747c684..cc27992c 100644 --- a/src/peds/PedAI.cpp +++ b/src/peds/PedAI.cpp @@ -832,10 +832,10 @@ CPed::ProcessObjective(void) m_pMyVehicle->SetStatus(STATUS_PHYSICS); m_pMyVehicle->AutoPilot.m_nPrevRouteNode = 0; if (m_nPedType == PEDTYPE_COP) { - m_pMyVehicle->AutoPilot.m_nCruiseSpeed = (FindPlayerPed()->m_pWanted->m_nWantedLevel * 0.1f + 0.6f) * (GAME_SPEED_TO_CARAI_SPEED * m_pMyVehicle->pHandling->Transmission.fUnkMaxVelocity); + m_pMyVehicle->AutoPilot.m_nCruiseSpeed = (FindPlayerPed()->m_pWanted->m_nWantedLevel * 0.1f + 0.6f) * (GAME_SPEED_TO_CARAI_SPEED * m_pMyVehicle->pHandling->Transmission.fMaxCruiseVelocity); m_pMyVehicle->AutoPilot.m_nCarMission = CCarAI::FindPoliceCarMissionForWantedLevel(); } else { - m_pMyVehicle->AutoPilot.m_nCruiseSpeed = GAME_SPEED_TO_CARAI_SPEED * m_pMyVehicle->pHandling->Transmission.fUnkMaxVelocity * 0.8f; + m_pMyVehicle->AutoPilot.m_nCruiseSpeed = GAME_SPEED_TO_CARAI_SPEED * m_pMyVehicle->pHandling->Transmission.fMaxCruiseVelocity * 0.8f; m_pMyVehicle->AutoPilot.m_nCarMission = MISSION_RAMPLAYER_FARAWAY; } m_pMyVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS; @@ -4775,7 +4775,7 @@ CPed::RegisterThreatWithGangPeds(CEntity *attacker) if (nearVehDriver && nearVehDriver != this && nearVehDriver->m_nPedType == m_nPedType) { if (nearVeh->IsVehicleNormal() && nearVeh->IsCar()) { - nearVeh->AutoPilot.m_nCruiseSpeed = GAME_SPEED_TO_CARAI_SPEED * nearVeh->pHandling->Transmission.fUnkMaxVelocity * 0.8f; + nearVeh->AutoPilot.m_nCruiseSpeed = GAME_SPEED_TO_CARAI_SPEED * nearVeh->pHandling->Transmission.fMaxCruiseVelocity * 0.8f; nearVeh->AutoPilot.m_nCarMission = MISSION_RAMPLAYER_FARAWAY; nearVeh->SetStatus(STATUS_PHYSICS); nearVeh->AutoPilot.m_nTempAction = TEMPACT_NONE; diff --git a/src/vehicles/HandlingMgr.cpp b/src/vehicles/HandlingMgr.cpp index 7b60acf2..fde280e8 100644 --- a/src/vehicles/HandlingMgr.cpp +++ b/src/vehicles/HandlingMgr.cpp @@ -220,9 +220,9 @@ cHandlingDataMgr::ConvertDataToGameUnits(tHandlingData *handling) } if(handling->nIdentifier == HANDLING_RCBANDIT){ - handling->Transmission.fUnkMaxVelocity = handling->Transmission.fMaxVelocity; + handling->Transmission.fMaxCruiseVelocity = handling->Transmission.fMaxVelocity; }else{ - handling->Transmission.fUnkMaxVelocity = velocity; + handling->Transmission.fMaxCruiseVelocity = velocity; handling->Transmission.fMaxVelocity = velocity * 1.2f; } handling->Transmission.fMaxReverseVelocity = -0.2f; diff --git a/src/vehicles/Transmission.h b/src/vehicles/Transmission.h index 8eeef1e8..a3d15513 100644 --- a/src/vehicles/Transmission.h +++ b/src/vehicles/Transmission.h @@ -18,7 +18,7 @@ public: uint8 Flags; float fEngineAcceleration; float fMaxVelocity; - float fUnkMaxVelocity; + float fMaxCruiseVelocity; float fMaxReverseVelocity; float fCurVelocity; diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index b02d1152..465d9a9e 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -659,7 +659,7 @@ CVehicle::InflictDamage(CEntity* damagedBy, eWeaponType weaponType, float damage if (m_randomSeed < DAMAGE_FLEE_IN_CAR_PROBABILITY_VALUE) { CCarCtrl::SwitchVehicleToRealPhysics(this); AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS; - AutoPilot.m_nCruiseSpeed = GAME_SPEED_TO_CARAI_SPEED * pHandling->Transmission.fUnkMaxVelocity; + AutoPilot.m_nCruiseSpeed = GAME_SPEED_TO_CARAI_SPEED * pHandling->Transmission.fMaxCruiseVelocity; SetStatus(STATUS_PHYSICS); } } -- 2.45.2 From e49ee14ed0038758dff70486b159da2c3aac53a5 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Sun, 3 Jan 2021 00:38:51 +0100 Subject: [PATCH 09/10] Add option to redirect output to file --- src/core/config.h | 1 + src/skel/glfw/glfw.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/core/config.h b/src/core/config.h index 9f4ccd1f..fcfe980f 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -235,6 +235,7 @@ enum Config { #ifdef DEBUGMENU #define MISSION_SWITCHER // from debug menu #endif +//#define LOG_TO_FILE // Rendering/display //#define EXTRA_MODEL_FLAGS // from mobile to optimize rendering diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 93bfde5a..dcd2b23f 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -1488,6 +1488,10 @@ WinMain(HINSTANCE instance, int main(int argc, char *argv[]) { +#ifdef LOG_TO_FILE + freopen("re3_log.txt", "w", stdout); + freopen("re3_errors.txt", "w", stderr); +#endif #endif RwV2d pos; RwInt32 i; -- 2.45.2 From 0d581f2f8b794aca872ff80960624b61b70dff1d Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Sat, 30 Jan 2021 23:46:16 +0100 Subject: [PATCH 10/10] Fix --- src/skel/glfw/glfw.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index dcd2b23f..99b1e380 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -1488,10 +1488,10 @@ WinMain(HINSTANCE instance, int main(int argc, char *argv[]) { +#endif #ifdef LOG_TO_FILE freopen("re3_log.txt", "w", stdout); freopen("re3_errors.txt", "w", stderr); -#endif #endif RwV2d pos; RwInt32 i; -- 2.45.2