summaryrefslogtreecommitdiffstats
path: root/src/control
diff options
context:
space:
mode:
authorRoman Masanin <36927roma@gmail.com>2020-11-01 21:39:21 +0100
committerRoman Masanin <36927roma@gmail.com>2020-11-01 21:39:21 +0100
commit076fc24e862873ab76269ebb3b00c3ef23e77ae3 (patch)
tree7b717c37a5929163717551d4d5bb6a67b6a16221 /src/control
parentmark original bugs (diff)
parentFix the goddamn spaces for tabs master race (diff)
downloadre3-076fc24e862873ab76269ebb3b00c3ef23e77ae3.tar
re3-076fc24e862873ab76269ebb3b00c3ef23e77ae3.tar.gz
re3-076fc24e862873ab76269ebb3b00c3ef23e77ae3.tar.bz2
re3-076fc24e862873ab76269ebb3b00c3ef23e77ae3.tar.lz
re3-076fc24e862873ab76269ebb3b00c3ef23e77ae3.tar.xz
re3-076fc24e862873ab76269ebb3b00c3ef23e77ae3.tar.zst
re3-076fc24e862873ab76269ebb3b00c3ef23e77ae3.zip
Diffstat (limited to 'src/control')
-rw-r--r--src/control/Darkel.cpp4
-rw-r--r--src/control/Garages.cpp2
-rw-r--r--src/control/Pickups.cpp67
-rw-r--r--src/control/Pickups.h5
-rw-r--r--src/control/RoadBlocks.cpp2
-rw-r--r--src/control/Script.cpp14
6 files changed, 54 insertions, 40 deletions
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/control/Pickups.cpp b/src/control/Pickups.cpp
index 9215b57e..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
@@ -628,7 +640,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 +656,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 +726,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 +757,7 @@ void
CPickups::DoMineEffects(CEntity *entity)
{
const CVector &pos = entity->GetPosition();
- float dist = (TheCamera.GetPosition() - pos).Magnitude();
+ float dist = Distance(pos, TheCamera.GetPosition());
const float MAXDIST = 20.0f;
if (dist < MAXDIST) {
@@ -765,7 +776,7 @@ void
CPickups::DoMoneyEffects(CEntity *entity)
{
const CVector &pos = entity->GetPosition();
- float dist = (TheCamera.GetPosition() - pos).Magnitude();
+ float dist = Distance(pos, TheCamera.GetPosition());
const float MAXDIST = 20.0f;
if (dist < MAXDIST) {
@@ -784,7 +795,7 @@ void
CPickups::DoCollectableEffects(CEntity *entity)
{
const CVector &pos = entity->GetPosition();
- float dist = (TheCamera.GetPosition() - pos).Magnitude();
+ float dist = Distance(pos, TheCamera.GetPosition());
const float MAXDIST = 14.0f;
if (dist < MAXDIST) {
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);
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 650e11a7..86595bbd 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;
@@ -2694,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;
@@ -3575,7 +3579,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);
@@ -8331,11 +8335,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;
@@ -9183,13 +9187,13 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
script_assert(pObject);
if (ScriptParams[1]) {
if (pObject->bIsStatic) {
- pObject->bIsStatic = false;
+ pObject->SetIsStatic(false);
pObject->AddToMovingList();
}
}
else {
if (!pObject->bIsStatic) {
- pObject->bIsStatic = true;
+ pObject->SetIsStatic(true);
pObject->RemoveFromMovingList();
}
}