review fixes

This commit is contained in:
Nikolay Korolev 2020-04-01 00:07:09 +03:00
parent e2ed468018
commit e34631adce
2 changed files with 68 additions and 117 deletions

View File

@ -119,7 +119,7 @@ int32(&CGarages::CarTypesCollected)[TOTAL_COLLECTCARS_GARAGES] = *(int32(*)[TOTA
int32& CGarages::CrushedCarId = *(int32*)0x943060; int32& CGarages::CrushedCarId = *(int32*)0x943060;
uint32& CGarages::LastTimeHelpMessage = *(uint32*)0x8F1B58; uint32& CGarages::LastTimeHelpMessage = *(uint32*)0x8F1B58;
int32& CGarages::MessageNumberInString = *(int32*)0x885BA8; int32& CGarages::MessageNumberInString = *(int32*)0x885BA8;
char(&CGarages::MessageIDString)[8] = *(char(*)[8]) * (uintptr*)0x878358; char(&CGarages::MessageIDString)[MESSAGE_LENGTH] = *(char(*)[MESSAGE_LENGTH]) * (uintptr*)0x878358;
int32& CGarages::MessageNumberInString2 = *(int32*)0x8E2C14; int32& CGarages::MessageNumberInString2 = *(int32*)0x8E2C14;
uint32& CGarages::MessageStartTime = *(uint32*)0x8F2530; uint32& CGarages::MessageStartTime = *(uint32*)0x8F2530;
uint32& CGarages::MessageEndTime = *(uint32*)0x8F597C; uint32& CGarages::MessageEndTime = *(uint32*)0x8F597C;
@ -467,8 +467,8 @@ void CGarage::Update()
if (IsPlayerOutsideGarage()) if (IsPlayerOutsideGarage())
m_eGarageState = GS_OPENED; m_eGarageState = GS_OPENED;
break; break;
//case GS_CLOSEDCONTAINSCAR: //case GS_CLOSEDCONTAINSCAR:
//case GS_AFTERDROPOFF: //case GS_AFTERDROPOFF:
default: default:
break; break;
} }
@ -571,8 +571,8 @@ void CGarage::Update()
if (IsPlayerOutsideGarage()) if (IsPlayerOutsideGarage())
m_eGarageState = GS_OPENED; m_eGarageState = GS_OPENED;
break; break;
//case GS_CLOSEDCONTAINSCAR: //case GS_CLOSEDCONTAINSCAR:
//case GS_AFTERDROPOFF: //case GS_AFTERDROPOFF:
default: default:
break; break;
} }
@ -631,9 +631,9 @@ void CGarage::Update()
} }
UpdateDoorsHeight(); UpdateDoorsHeight();
break; break;
//case GS_OPENEDCONTAINSCAR: //case GS_OPENEDCONTAINSCAR:
//case GS_CLOSEDCONTAINSCAR: //case GS_CLOSEDCONTAINSCAR:
//case GS_AFTERDROPOFF: //case GS_AFTERDROPOFF:
default: default:
break; break;
} }
@ -715,9 +715,9 @@ void CGarage::Update()
} }
UpdateDoorsHeight(); UpdateDoorsHeight();
break; break;
//case GS_OPENEDCONTAINSCAR: //case GS_OPENEDCONTAINSCAR:
//case GS_CLOSEDCONTAINSCAR: //case GS_CLOSEDCONTAINSCAR:
//case GS_AFTERDROPOFF: //case GS_AFTERDROPOFF:
default: default:
break; break;
} }
@ -754,7 +754,7 @@ void CGarage::Update()
TheCamera.SetCameraDirectlyBehindForFollowPed_CamOnAString(); TheCamera.SetCameraDirectlyBehindForFollowPed_CamOnAString();
} }
} }
} }
break; break;
case GS_CLOSING: case GS_CLOSING:
m_fDoorPos = max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep()); m_fDoorPos = max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
@ -804,12 +804,12 @@ void CGarage::Update()
} }
UpdateDoorsHeight(); UpdateDoorsHeight();
break; break;
//case GS_OPENEDCONTAINSCAR: //case GS_OPENEDCONTAINSCAR:
//case GS_CLOSEDCONTAINSCAR: //case GS_CLOSEDCONTAINSCAR:
//case GS_AFTERDROPOFF: //case GS_AFTERDROPOFF:
default: default:
break; break;
} }
break; break;
case GARAGE_FORCARTOCOMEOUTOF: case GARAGE_FORCARTOCOMEOUTOF:
switch (m_eGarageState) { switch (m_eGarageState) {
@ -836,9 +836,9 @@ void CGarage::Update()
} }
UpdateDoorsHeight(); UpdateDoorsHeight();
break; break;
//case GS_OPENEDCONTAINSCAR: //case GS_OPENEDCONTAINSCAR:
//case GS_CLOSEDCONTAINSCAR: //case GS_CLOSEDCONTAINSCAR:
//case GS_AFTERDROPOFF: //case GS_AFTERDROPOFF:
default: default:
break; break;
} }
@ -905,10 +905,9 @@ void CGarage::Update()
} }
UpdateCrusherAngle(); UpdateCrusherAngle();
break; break;
//case GS_FULLYCLOSED: //case GS_FULLYCLOSED:
//case GS_CLOSEDCONTAINSCAR: //case GS_CLOSEDCONTAINSCAR:
//case GS_OPENEDCONTAINSCAR: //case GS_OPENEDCONTAINSCAR:
default: default:
break; break;
} }
@ -971,8 +970,8 @@ void CGarage::Update()
if (m_eGarageType == GARAGE_MISSION_KEEPCAR && CTimer::GetTimeInMilliseconds() > m_nTimeToStartAction) if (m_eGarageType == GARAGE_MISSION_KEEPCAR && CTimer::GetTimeInMilliseconds() > m_nTimeToStartAction)
m_eGarageState = GS_OPENING; m_eGarageState = GS_OPENING;
break; break;
//case GS_OPENEDCONTAINSCAR: //case GS_OPENEDCONTAINSCAR:
//case GS_AFTERDROPOFF: //case GS_AFTERDROPOFF:
default: default:
break; break;
} }
@ -987,12 +986,12 @@ void CGarage::Update()
} }
UpdateDoorsHeight(); UpdateDoorsHeight();
break; break;
//case GS_OPENED: //case GS_OPENED:
//case GS_CLOSING: //case GS_CLOSING:
//case GS_FULLYCLOSED: //case GS_FULLYCLOSED:
//case GS_OPENEDCONTAINSCAR: //case GS_OPENEDCONTAINSCAR:
//case GS_CLOSEDCONTAINSCAR: //case GS_CLOSEDCONTAINSCAR:
//case GS_AFTERDROPOFF: //case GS_AFTERDROPOFF:
default: default:
break; break;
} }
@ -1015,16 +1014,15 @@ void CGarage::Update()
} }
UpdateDoorsHeight(); UpdateDoorsHeight();
break; break;
//case GS_OPENED: //case GS_OPENED:
//case GS_FULLYCLOSED: //case GS_FULLYCLOSED:
//case GS_OPENEDCONTAINSCAR: //case GS_OPENEDCONTAINSCAR:
//case GS_CLOSEDCONTAINSCAR: //case GS_CLOSEDCONTAINSCAR:
//case GS_AFTERDROPOFF: //case GS_AFTERDROPOFF:
default: default:
break; break;
} }
break; break;
case GARAGE_HIDEOUT_ONE: case GARAGE_HIDEOUT_ONE:
case GARAGE_HIDEOUT_TWO: case GARAGE_HIDEOUT_TWO:
case GARAGE_HIDEOUT_THREE: case GARAGE_HIDEOUT_THREE:
@ -1103,9 +1101,9 @@ void CGarage::Update()
} }
UpdateDoorsHeight(); UpdateDoorsHeight();
break; break;
//case GS_OPENEDCONTAINSCAR: //case GS_OPENEDCONTAINSCAR:
//case GS_CLOSEDCONTAINSCAR: //case GS_CLOSEDCONTAINSCAR:
//case GS_AFTERDROPOFF: //case GS_AFTERDROPOFF:
default: default:
break; break;
} }
@ -1144,9 +1142,9 @@ void CGarage::Update()
} }
UpdateDoorsHeight(); UpdateDoorsHeight();
break; break;
//case GS_OPENEDCONTAINSCAR: //case GS_OPENEDCONTAINSCAR:
//case GS_CLOSEDCONTAINSCAR: //case GS_CLOSEDCONTAINSCAR:
//case GS_AFTERDROPOFF: //case GS_AFTERDROPOFF:
default: default:
break; break;
} }
@ -1155,9 +1153,8 @@ void CGarage::Update()
//case GARAGE_60SECONDS: //case GARAGE_60SECONDS:
default: default:
break; break;
} }
}
}
bool CGarage::IsStaticPlayerCarEntirelyInside() bool CGarage::IsStaticPlayerCarEntirelyInside()
{ {
@ -1170,19 +1167,12 @@ bool CGarage::IsStaticPlayerCarEntirelyInside()
if (FindPlayerPed()->m_objective == OBJECTIVE_LEAVE_VEHICLE) if (FindPlayerPed()->m_objective == OBJECTIVE_LEAVE_VEHICLE)
return false; return false;
CVehicle* pVehicle = FindPlayerVehicle(); CVehicle* pVehicle = FindPlayerVehicle();
if (pVehicle->GetPosition().x < m_fX1) if (pVehicle->GetPosition().x < m_fX1 || pVehicle->GetPosition().x > m_fX2 ||
pVehicle->GetPosition().y < m_fY1 || pVehicle->GetPosition().y > m_fY2)
return false; return false;
if (pVehicle->GetPosition().x > m_fX2) if (Abs(pVehicle->GetSpeed().x) > 0.01f ||
return false; Abs(pVehicle->GetSpeed().y) > 0.01f ||
if (pVehicle->GetPosition().y < m_fY1) Abs(pVehicle->GetSpeed().z) > 0.01f)
return false;
if (pVehicle->GetPosition().y > m_fY2)
return false;
if (Abs(pVehicle->GetSpeed().x) > 0.01f)
return false;
if (Abs(pVehicle->GetSpeed().y) > 0.01f)
return false;
if (Abs(pVehicle->GetSpeed().z) > 0.01f)
return false; return false;
if (pVehicle->GetSpeed().MagnitudeSqr() > SQR(0.01f)) if (pVehicle->GetSpeed().MagnitudeSqr() > SQR(0.01f))
return false; return false;
@ -1191,25 +1181,15 @@ bool CGarage::IsStaticPlayerCarEntirelyInside()
bool CGarage::IsEntityEntirelyInside(CEntity * pEntity) bool CGarage::IsEntityEntirelyInside(CEntity * pEntity)
{ {
if (pEntity->GetPosition().x < m_fX1) if (pEntity->GetPosition().x < m_fX1 || pEntity->GetPosition().x > m_fX2 ||
return false; pEntity->GetPosition().y < m_fY1 || pEntity->GetPosition().y > m_fY2)
if (pEntity->GetPosition().x > m_fX2)
return false;
if (pEntity->GetPosition().y < m_fY1)
return false;
if (pEntity->GetPosition().y > m_fY2)
return false; return false;
CColModel* pColModel = CModelInfo::GetModelInfo(pEntity->GetModelIndex())->GetColModel(); CColModel* pColModel = CModelInfo::GetModelInfo(pEntity->GetModelIndex())->GetColModel();
for (int i = 0; i < pColModel->numSpheres; i++) { for (int i = 0; i < pColModel->numSpheres; i++) {
CVector pos = pEntity->GetMatrix() * pColModel->spheres[i].center; CVector pos = pEntity->GetMatrix() * pColModel->spheres[i].center;
float radius = pColModel->spheres[i].radius; float radius = pColModel->spheres[i].radius;
if (pos.x - radius < m_fX1) if (pos.x - radius < m_fX1 || pos.x + radius > m_fX2 ||
return false; pos.y - radius < m_fY1 || pos.y + radius > m_fY2)
if (pos.x + radius > m_fX2)
return false;
if (pos.y - radius < m_fY1)
return false;
if (pos.y + radius > m_fY2)
return false; return false;
} }
return true; return true;
@ -1217,33 +1197,17 @@ bool CGarage::IsEntityEntirelyInside(CEntity * pEntity)
bool CGarage::IsEntityEntirelyInside3D(CEntity * pEntity, float fMargin) bool CGarage::IsEntityEntirelyInside3D(CEntity * pEntity, float fMargin)
{ {
if (pEntity->GetPosition().x < m_fX1 - fMargin) if (pEntity->GetPosition().x < m_fX1 - fMargin || pEntity->GetPosition().x > m_fX2 + fMargin ||
return false; pEntity->GetPosition().y < m_fY1 - fMargin || pEntity->GetPosition().y > m_fY2 + fMargin ||
if (pEntity->GetPosition().x > m_fX2 + fMargin) pEntity->GetPosition().z < m_fZ1 - fMargin || pEntity->GetPosition().z > m_fZ2 + fMargin)
return false;
if (pEntity->GetPosition().y < m_fY1 - fMargin)
return false;
if (pEntity->GetPosition().y > m_fY2 + fMargin)
return false;
if (pEntity->GetPosition().z < m_fZ1 - fMargin)
return false;
if (pEntity->GetPosition().z > m_fZ2 + fMargin)
return false; return false;
CColModel* pColModel = CModelInfo::GetModelInfo(pEntity->GetModelIndex())->GetColModel(); CColModel* pColModel = CModelInfo::GetModelInfo(pEntity->GetModelIndex())->GetColModel();
for (int i = 0; i < pColModel->numSpheres; i++) { for (int i = 0; i < pColModel->numSpheres; i++) {
CVector pos = pEntity->GetMatrix() * pColModel->spheres[i].center; CVector pos = pEntity->GetMatrix() * pColModel->spheres[i].center;
float radius = pColModel->spheres[i].radius; float radius = pColModel->spheres[i].radius;
if (pos.x + radius < m_fX1 - fMargin) if (pos.x + radius < m_fX1 - fMargin || pos.x - radius > m_fX2 + fMargin ||
return false; pos.y + radius < m_fY1 - fMargin || pos.y - radius > m_fY2 + fMargin ||
if (pos.x - radius > m_fX2 + fMargin) pos.z + radius < m_fZ1 - fMargin || pos.z - radius > m_fZ2 + fMargin)
return false;
if (pos.y + radius < m_fY1 - fMargin)
return false;
if (pos.y - radius > m_fY2 + fMargin)
return false;
if (pos.z + radius < m_fZ1 - fMargin)
return false;
if (pos.z - radius > m_fZ2 + fMargin)
return false; return false;
} }
return true; return true;
@ -1282,17 +1246,9 @@ bool CGarage::IsPlayerOutsideGarage()
bool CGarage::IsEntityTouching3D(CEntity * pEntity) bool CGarage::IsEntityTouching3D(CEntity * pEntity)
{ {
float radius = pEntity->GetBoundRadius(); float radius = pEntity->GetBoundRadius();
if (pEntity->GetPosition().x - radius < m_fX1) if (pEntity->GetPosition().x - radius < m_fX1 || pEntity->GetPosition().x + radius > m_fX2 ||
return false; pEntity->GetPosition().y - radius < m_fY1 || pEntity->GetPosition().y + radius > m_fY2 ||
if (pEntity->GetPosition().x + radius > m_fX2) pEntity->GetPosition().z - radius < m_fZ1 || pEntity->GetPosition().z + radius > m_fZ2)
return false;
if (pEntity->GetPosition().y - radius < m_fY1)
return false;
if (pEntity->GetPosition().y + radius > m_fY2)
return false;
if (pEntity->GetPosition().z - radius < m_fZ1)
return false;
if (pEntity->GetPosition().z + radius > m_fZ2)
return false; return false;
CColModel* pColModel = CModelInfo::GetModelInfo(pEntity->GetModelIndex())->GetColModel(); CColModel* pColModel = CModelInfo::GetModelInfo(pEntity->GetModelIndex())->GetColModel();
for (int i = 0; i < pColModel->numSpheres; i++) { for (int i = 0; i < pColModel->numSpheres; i++) {
@ -1312,17 +1268,9 @@ bool CGarage::EntityHasASphereWayOutsideGarage(CEntity * pEntity, float fMargin)
for (int i = 0; i < pColModel->numSpheres; i++) { for (int i = 0; i < pColModel->numSpheres; i++) {
CVector pos = pEntity->GetMatrix() * pColModel->spheres[i].center; CVector pos = pEntity->GetMatrix() * pColModel->spheres[i].center;
float radius = pColModel->spheres[i].radius; float radius = pColModel->spheres[i].radius;
if (pos.x + radius + fMargin < m_fX1) if (pos.x + radius + fMargin < m_fX1 || pos.x - radius - fMargin > m_fX2 ||
return true; pos.y + radius + fMargin < m_fY1 || pos.y - radius - fMargin > m_fY2 ||
if (pos.x - radius - fMargin > m_fX2) pos.z + radius + fMargin < m_fZ1 || pos.z - radius - fMargin > m_fZ2)
return true;
if (pos.y + radius + fMargin < m_fY1)
return true;
if (pos.y - radius - fMargin > m_fY2)
return true;
if (pos.z + radius + fMargin < m_fZ1)
return true;
if (pos.z - radius - fMargin > m_fZ2)
return true; return true;
} }
return false; return false;

View File

@ -174,6 +174,9 @@ static_assert(sizeof(CGarage) == 140, "CGarage");
class CGarages class CGarages
{ {
enum {
MESSAGE_LENGTH = 8
};
static int32 &BankVansCollected; static int32 &BankVansCollected;
static bool &BombsAreFree; static bool &BombsAreFree;
static bool &RespraysAreFree; static bool &RespraysAreFree;
@ -182,7 +185,7 @@ class CGarages
static int32 &CrushedCarId; static int32 &CrushedCarId;
static uint32 &LastTimeHelpMessage; static uint32 &LastTimeHelpMessage;
static int32 &MessageNumberInString; static int32 &MessageNumberInString;
static char(&MessageIDString)[8]; static char(&MessageIDString)[MESSAGE_LENGTH];
static int32 &MessageNumberInString2; static int32 &MessageNumberInString2;
static uint32 &MessageStartTime; static uint32 &MessageStartTime;
static uint32 &MessageEndTime; static uint32 &MessageEndTime;