summaryrefslogtreecommitdiffstats
path: root/src/control
diff options
context:
space:
mode:
Diffstat (limited to 'src/control')
-rw-r--r--src/control/AccidentManager.cpp16
-rw-r--r--src/control/AccidentManager.h1
-rw-r--r--src/control/PathFind.cpp2
-rw-r--r--src/control/PathFind.h2
-rw-r--r--src/control/Phones.cpp205
-rw-r--r--src/control/Phones.h45
-rw-r--r--src/control/Replay.cpp2
-rw-r--r--src/control/Script.cpp64
8 files changed, 255 insertions, 82 deletions
diff --git a/src/control/AccidentManager.cpp b/src/control/AccidentManager.cpp
index 46d254fc..a42280b7 100644
--- a/src/control/AccidentManager.cpp
+++ b/src/control/AccidentManager.cpp
@@ -8,7 +8,8 @@ CAccidentManager& gAccidentManager = *(CAccidentManager*)0x87FD10;
WRAPPER void CAccidentManager::Update(void) { EAXJMP(0x456710); }
-uint16 CAccidentManager::CountActiveAccidents()
+uint16
+CAccidentManager::CountActiveAccidents()
{
uint16 accidents = 0;
for (int i = 0; i < NUM_ACCIDENTS; i++){
@@ -18,7 +19,8 @@ uint16 CAccidentManager::CountActiveAccidents()
return accidents;
}
-CAccident* CAccidentManager::FindNearestAccident(CVector vecPos, float* pDistance)
+CAccident*
+CAccidentManager::FindNearestAccident(CVector vecPos, float* pDistance)
{
for (int i = 0; i < MAX_MEDICS_TO_ATTEND_ACCIDENT; i++){
int accidentId = -1;
@@ -44,4 +46,14 @@ CAccident* CAccidentManager::FindNearestAccident(CVector vecPos, float* pDistanc
return &m_aAccidents[accidentId];
}
return nil;
+}
+
+bool
+CAccidentManager::UnattendedAccidents(void)
+{
+ for (int i = 0; i < NUM_ACCIDENTS; i++) {
+ if (m_aAccidents[i].m_pVictim && m_aAccidents[i].m_nMedicsAttending == 0)
+ return true;
+ }
+ return false;
} \ No newline at end of file
diff --git a/src/control/AccidentManager.h b/src/control/AccidentManager.h
index 6d7f25c8..6a3088e7 100644
--- a/src/control/AccidentManager.h
+++ b/src/control/AccidentManager.h
@@ -21,6 +21,7 @@ class CAccidentManager
};
public:
uint16 CountActiveAccidents();
+ bool UnattendedAccidents();
CAccident* FindNearestAccident(CVector, float*);
void Update(void);
};
diff --git a/src/control/PathFind.cpp b/src/control/PathFind.cpp
index 3c16202b..dad879b1 100644
--- a/src/control/PathFind.cpp
+++ b/src/control/PathFind.cpp
@@ -309,7 +309,7 @@ CPathFind::CountFloodFillGroups(uint8 type)
if(m_pathNodes[l].group == 0){
m_pathNodes[l].group = n;
if(m_pathNodes[l].group == 0)
- m_pathNodes[l].group = 0x80; // ???
+ m_pathNodes[l].group = INT8_MIN;
m_pathNodes[l].next = node;
node = &m_pathNodes[l];
}
diff --git a/src/control/PathFind.h b/src/control/PathFind.h
index 0b20ea5a..70b431f6 100644
--- a/src/control/PathFind.h
+++ b/src/control/PathFind.h
@@ -36,7 +36,7 @@ struct CPathNode
uint8 bDisabled : 1;
uint8 bBetweenLevels : 1;
- uint8 group;
+ int8 group;
/* For reference VC:
int16 prevIndex;
int16 nextIndex;
diff --git a/src/control/Phones.cpp b/src/control/Phones.cpp
index ef978868..f3b3a8db 100644
--- a/src/control/Phones.cpp
+++ b/src/control/Phones.cpp
@@ -6,16 +6,146 @@
#include "Ped.h"
#include "Pad.h"
#include "Messages.h"
+#include "Camera.h"
+#include "World.h"
+#include "General.h"
+#include "AudioScriptObject.h"
+#include "RpAnimBlend.h"
CPhoneInfo &gPhoneInfo = *(CPhoneInfo*)0x732A20;
-bool &CPhoneInfo::isPhonePickedUp = *(bool*)0x6283AC;
-uint32 &CPhoneInfo::phoneMessagesTimer = *(uint32*)0x6283A8;
-CPhone *&CPhoneInfo::pickedUpPhone = *(CPhone**)0x6283B0;
-bool &CPhoneInfo::isPhoneBeingPickedUp = *(bool*)0x6283B4;
-CPed *&CPhoneInfo::pedWhoPickingUpPhone = *(CPed**)0x6283B8;
+bool &CPhoneInfo::bDisplayingPhoneMessage = *(bool*)0x6283AC; // is phone picked up
+uint32 &CPhoneInfo::PhoneEnableControlsTimer = *(uint32*)0x6283A8;
+CPhone *&CPhoneInfo::pPhoneDisplayingMessages = *(CPhone**)0x6283B0;
+bool &CPhoneInfo::bPickingUpPhone = *(bool*)0x6283B4;
+CPed *&CPhoneInfo::pCallBackPed = *(CPed**)0x6283B8; // ped who picking up the phone (reset after pickup cb)
-WRAPPER void CPhoneInfo::Update(void) { EAXJMP(0x42F7A0); }
+/*
+ Entering phonebooth cutscene, showing messages and triggering these things
+ by checking coordinates happens in here - blue mission marker is cosmetic.
+
+ Repeated message means after the script set the messages for a particular phone,
+ player can pick the phone again with the same messages appearing,
+ after 60 seconds of last phone pick-up.
+*/
+
+#ifdef TOGGLEABLE_BETA_FEATURES
+CPed* crimeReporters[NUMPHONES] = {};
+bool
+isPhoneAvailable(int m_phoneId)
+{
+ return gPhoneInfo.m_aPhones[m_phoneId].m_nState == PHONE_STATE_FREE &&
+ (crimeReporters[m_phoneId] == nil || !crimeReporters[m_phoneId]->IsPointerValid() || !crimeReporters[m_phoneId]->bRunningToPhone || crimeReporters[m_phoneId]->m_objective > OBJECTIVE_IDLE ||
+ crimeReporters[m_phoneId]->m_nLastPedState != PED_SEEK_POS &&
+ (crimeReporters[m_phoneId]->m_nPedState != PED_MAKE_CALL && crimeReporters[m_phoneId]->m_nPedState != PED_FACE_PHONE && crimeReporters[m_phoneId]->m_nPedState != PED_SEEK_POS));
+}
+#endif
+
+void
+CPhoneInfo::Update(void)
+{
+ CPlayerPed *player = FindPlayerPed();
+ CPlayerInfo *playerInfo = &CWorld::Players[CWorld::PlayerInFocus];
+ if (bDisplayingPhoneMessage && CTimer::GetTimeInMilliseconds() > PhoneEnableControlsTimer) {
+ playerInfo->MakePlayerSafe(false);
+ TheCamera.SetWideScreenOff();
+ pPhoneDisplayingMessages = nil;
+ bDisplayingPhoneMessage = false;
+ CAnimBlendAssociation *talkAssoc = RpAnimBlendClumpGetAssociation(player->GetClump(), ANIM_PHONE_TALK);
+ if (talkAssoc && talkAssoc->blendAmount > 0.5f) {
+ CAnimBlendAssociation *endAssoc = CAnimManager::BlendAnimation(player->GetClump(), ASSOCGRP_STD, ANIM_PHONE_OUT, 8.0f);
+ endAssoc->flags &= ~ASSOC_DELETEFADEDOUT;
+ endAssoc->SetFinishCallback(PhonePutDownCB, player);
+ } else {
+ CPad::GetPad(0)->DisablePlayerControls &= ~PLAYERCONTROL_DISABLED_40;
+ if (player->m_nPedState == PED_MAKE_CALL)
+ player->m_nPedState = PED_IDLE;
+ }
+ }
+ bool notInCar;
+ CVector playerPos;
+ if (FindPlayerVehicle()) {
+ notInCar = false;
+ playerPos = FindPlayerVehicle()->GetPosition();
+ } else {
+ notInCar = true;
+ playerPos = player->GetPosition();
+ }
+ bool phoneRings = false;
+ bool scratchTheCabinet;
+ for(int phoneId = 0; phoneId < m_nScriptPhonesMax; phoneId++) {
+ if (m_aPhones[phoneId].m_visibleToCam) {
+ switch (m_aPhones[phoneId].m_nState) {
+ case PHONE_STATE_ONETIME_MESSAGE_SET:
+ case PHONE_STATE_REPEATED_MESSAGE_SET:
+ case PHONE_STATE_REPEATED_MESSAGE_SHOWN_ONCE:
+ if (bPickingUpPhone) {
+ scratchTheCabinet = false;
+ phoneRings = false;
+ } else {
+ scratchTheCabinet = (CTimer::GetTimeInMilliseconds() / 1880) % 2 == 1;
+ phoneRings = (CTimer::GetPreviousTimeInMilliseconds() / 1880) % 2 == 1;
+ }
+ if (scratchTheCabinet) {
+ m_aPhones[phoneId].m_pEntity->GetUp().z = (CGeneral::GetRandomNumber() % 1024) / 16000.0f + 1.0f;
+ if (!phoneRings)
+ PlayOneShotScriptObject(_SCRSOUND_PHONE_RING, m_aPhones[phoneId].m_pEntity->GetPosition());
+ } else {
+ m_aPhones[phoneId].m_pEntity->GetUp().z = 1.0f;
+ }
+ m_aPhones[phoneId].m_pEntity->GetMatrix().UpdateRW();
+ m_aPhones[phoneId].m_pEntity->UpdateRwFrame();
+ if (notInCar && !bPickingUpPhone && player->IsPedInControl()) {
+ CVector2D distToPhone = playerPos - m_aPhones[phoneId].m_vecPos;
+ if (Abs(distToPhone.x) < 1.0f && Abs(distToPhone.y) < 1.0f) {
+ if (DotProduct2D(distToPhone, m_aPhones[phoneId].m_pEntity->GetForward()) / distToPhone.Magnitude() < -0.85f) {
+ CVector2D distToPhoneObj = playerPos - m_aPhones[phoneId].m_pEntity->GetPosition();
+ float angleToFace = CGeneral::GetATanOfXY(distToPhoneObj.x, distToPhoneObj.y) + HALFPI;
+ if (angleToFace > TWOPI)
+ angleToFace = angleToFace - TWOPI;
+ player->m_fRotationCur = angleToFace;
+ player->m_fRotationDest = angleToFace;
+ player->SetHeading(angleToFace);
+ player->m_nPedState = PED_MAKE_CALL;
+ CPad::GetPad(0)->DisablePlayerControls |= PLAYERCONTROL_DISABLED_40;
+ TheCamera.SetWideScreenOn();
+ playerInfo->MakePlayerSafe(true);
+ CAnimBlendAssociation *phonePickAssoc = CAnimManager::BlendAnimation(player->GetClump(), ASSOCGRP_STD, ANIM_PHONE_IN, 4.0f);
+ phonePickAssoc->SetFinishCallback(PhonePickUpCB, &m_aPhones[phoneId]);
+ bPickingUpPhone = true;
+ pCallBackPed = player;
+ }
+ }
+ }
+ break;
+ case PHONE_STATE_REPEATED_MESSAGE_STARTED:
+ if (CTimer::GetTimeInMilliseconds() - m_aPhones[phoneId].m_repeatedMessagePickupStart > 60000)
+ m_aPhones[phoneId].m_nState = PHONE_STATE_REPEATED_MESSAGE_SHOWN_ONCE;
+ break;
+ case PHONE_STATE_9:
+ scratchTheCabinet = (CTimer::GetTimeInMilliseconds() / 1880) % 2 == 1;
+ phoneRings = (CTimer::GetPreviousTimeInMilliseconds() / 1880) % 2 == 1;
+ if (scratchTheCabinet) {
+ m_aPhones[phoneId].m_pEntity->GetUp().z = (CGeneral::GetRandomNumber() % 1024) / 16000.0f + 1.0f;
+ if (!phoneRings)
+ PlayOneShotScriptObject(_SCRSOUND_PHONE_RING, m_aPhones[phoneId].m_pEntity->GetPosition());
+ } else {
+ m_aPhones[phoneId].m_pEntity->GetUp().z = 1.0f;
+ }
+ m_aPhones[phoneId].m_pEntity->GetMatrix().UpdateRW();
+ m_aPhones[phoneId].m_pEntity->UpdateRwFrame();
+ break;
+ default:
+ break;
+ }
+ if (CVector2D(TheCamera.GetPosition() - m_aPhones[phoneId].m_vecPos).MagnitudeSqr() > sq(100.0f))
+ m_aPhones[phoneId].m_visibleToCam = false;
+ } else if (!((CTimer::GetFrameCounter() + m_aPhones[phoneId].m_pEntity->m_randomSeed) % 16)) {
+ if (CVector2D(TheCamera.GetPosition() - m_aPhones[phoneId].m_vecPos).MagnitudeSqr() < sq(60.0f))
+ m_aPhones[phoneId].m_visibleToCam = true;
+ }
+ }
+}
int
CPhoneInfo::FindNearestFreePhone(CVector *pos)
@@ -25,7 +155,11 @@ CPhoneInfo::FindNearestFreePhone(CVector *pos)
for (int phoneId = 0; phoneId < m_nMax; phoneId++) {
- if (gPhoneInfo.m_aPhones[phoneId].m_nState == PHONE_STATE_FREE) {
+ if (gPhoneInfo.m_aPhones[phoneId].m_nState == PHONE_STATE_FREE
+#ifdef TOGGLEABLE_BETA_FEATURES
+ && isPhoneAvailable(phoneId)
+#endif
+ ) {
float phoneDist = (m_aPhones[phoneId].m_vecPos - *pos).Magnitude2D();
if (phoneDist < nearestPhoneDist) {
@@ -50,20 +184,20 @@ CPhoneInfo::PhoneAtThisPosition(CVector pos)
bool
CPhoneInfo::HasMessageBeenDisplayed(int phoneId)
{
- if (isPhonePickedUp)
+ if (bDisplayingPhoneMessage)
return false;
int state = m_aPhones[phoneId].m_nState;
return state == PHONE_STATE_REPEATED_MESSAGE_SHOWN_ONCE ||
- state == PHONE_STATE_ONETIME_MESSAGE_SHOWN ||
- state == PHONE_STATE_REPEATED_MESSAGE_SHOWN;
+ state == PHONE_STATE_ONETIME_MESSAGE_STARTED ||
+ state == PHONE_STATE_REPEATED_MESSAGE_STARTED;
}
bool
CPhoneInfo::IsMessageBeingDisplayed(int phoneId)
{
- return pickedUpPhone == &m_aPhones[phoneId];
+ return pPhoneDisplayingMessages == &m_aPhones[phoneId];
}
void
@@ -71,8 +205,8 @@ CPhoneInfo::Load(uint8 *buf, uint32 size)
{
INITSAVEBUF
m_nMax = ReadSaveBuf<int32>(buf);
- m_nNum = ReadSaveBuf<int32>(buf);
- for (int i = 0; i < 50; i++) {
+ m_nScriptPhonesMax = ReadSaveBuf<int32>(buf);
+ for (int i = 0; i < NUMPHONES; i++) {
m_aPhones[i] = ReadSaveBuf<CPhone>(buf);
// It's saved as building pool index in save file, convert it to true entity
if (m_aPhones[i].m_pEntity) {
@@ -127,7 +261,7 @@ CPhoneInfo::GrabPhone(float xPos, float yPos)
CVector pos(xPos, yPos, 0.0f);
float nearestPhoneDist = 100.0f;
- for (int phoneId = m_nNum; phoneId < m_nMax; phoneId++) {
+ for (int phoneId = m_nScriptPhonesMax; phoneId < m_nMax; phoneId++) {
float phoneDistance = (m_aPhones[phoneId].m_vecPos - pos).Magnitude2D();
if (phoneDistance < nearestPhoneDist) {
nearestPhoneDist = phoneDistance;
@@ -136,23 +270,23 @@ CPhoneInfo::GrabPhone(float xPos, float yPos)
}
m_aPhones[nearestPhoneId].m_nState = PHONE_STATE_MESSAGE_REMOVED;
- CPhone oldFirstPhone = m_aPhones[m_nNum];
- m_aPhones[m_nNum] = m_aPhones[nearestPhoneId];
+ CPhone oldFirstPhone = m_aPhones[m_nScriptPhonesMax];
+ m_aPhones[m_nScriptPhonesMax] = m_aPhones[nearestPhoneId];
m_aPhones[nearestPhoneId] = oldFirstPhone;
- m_nNum++;
- return m_nNum - 1;
+ m_nScriptPhonesMax++;
+ return m_nScriptPhonesMax - 1;
}
void
CPhoneInfo::Initialise(void)
{
CBuildingPool *pool = CPools::GetBuildingPool();
- pedWhoPickingUpPhone = nil;
- isPhonePickedUp = false;
- isPhoneBeingPickedUp = false;
- pickedUpPhone = nil;
+ pCallBackPed = nil;
+ bDisplayingPhoneMessage = false;
+ bPickingUpPhone = false;
+ pPhoneDisplayingMessages = nil;
m_nMax = 0;
- m_nNum = 0;
+ m_nScriptPhonesMax = 0;
for (int i = pool->GetSize() - 1; i >= 0; i--) {
CBuilding *building = pool->GetSlot(i);
if (building) {
@@ -173,8 +307,8 @@ CPhoneInfo::Save(uint8 *buf, uint32 *size)
*size = sizeof(CPhoneInfo);
INITSAVEBUF
WriteSaveBuf(buf, m_nMax);
- WriteSaveBuf(buf, m_nNum);
- for(int phoneId = 0; phoneId < 50; phoneId++) {
+ WriteSaveBuf(buf, m_nScriptPhonesMax);
+ for(int phoneId = 0; phoneId < NUMPHONES; phoneId++) {
CPhone* phone = WriteSaveBuf(buf, m_aPhones[phoneId]);
// Convert entity pointer to building pool index while saving
@@ -189,7 +323,7 @@ void
CPhoneInfo::Shutdown(void)
{
m_nMax = 0;
- m_nNum = 0;
+ m_nScriptPhonesMax = 0;
}
void
@@ -221,26 +355,26 @@ PhonePickUpCB(CAnimBlendAssociation *assoc, void *arg)
}
}
- CPhoneInfo::isPhoneBeingPickedUp = false;
- CPhoneInfo::isPhonePickedUp = true;
- CPhoneInfo::pickedUpPhone = phone;
- CPhoneInfo::phoneMessagesTimer = CTimer::GetTimeInMilliseconds() + messagesDisplayTime;
+ CPhoneInfo::bPickingUpPhone = false;
+ CPhoneInfo::bDisplayingPhoneMessage = true;
+ CPhoneInfo::pPhoneDisplayingMessages = phone;
+ CPhoneInfo::PhoneEnableControlsTimer = CTimer::GetTimeInMilliseconds() + messagesDisplayTime;
if (phone->m_nState == PHONE_STATE_ONETIME_MESSAGE_SET) {
- phone->m_nState = PHONE_STATE_ONETIME_MESSAGE_SHOWN;
+ phone->m_nState = PHONE_STATE_ONETIME_MESSAGE_STARTED;
} else {
- phone->m_nState = PHONE_STATE_REPEATED_MESSAGE_SHOWN;
- phone->m_lastTimeRepeatedMsgShown = CTimer::GetTimeInMilliseconds();
+ phone->m_nState = PHONE_STATE_REPEATED_MESSAGE_STARTED;
+ phone->m_repeatedMessagePickupStart = CTimer::GetTimeInMilliseconds();
}
- CPed *ped = CPhoneInfo::pedWhoPickingUpPhone;
+ CPed *ped = CPhoneInfo::pCallBackPed;
ped->m_nMoveState = PEDMOVE_STILL;
CAnimManager::BlendAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_IDLE_STANCE, 8.0f);
if (assoc->blendAmount > 0.5f && ped)
CAnimManager::BlendAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_PHONE_TALK, 8.0f);
- CPhoneInfo::pedWhoPickingUpPhone = nil;
+ CPhoneInfo::pCallBackPed = nil;
}
STARTPATCHES
@@ -255,6 +389,7 @@ STARTPATCHES
InjectHook(0x42F710, &CPhoneInfo::Shutdown, PATCH_JUMP);
InjectHook(0x42F640, &CPhoneInfo::Initialise, PATCH_JUMP);
InjectHook(0x42FDB0, &CPhoneInfo::GrabPhone, PATCH_JUMP);
+ InjectHook(0x42F7A0, &CPhoneInfo::Update, PATCH_JUMP);
InjectHook(0x42F570, &PhonePutDownCB, PATCH_JUMP);
InjectHook(0x42F470, &PhonePickUpCB, PATCH_JUMP);
ENDPATCHES \ No newline at end of file
diff --git a/src/control/Phones.h b/src/control/Phones.h
index 99ec520c..e7e3c9a7 100644
--- a/src/control/Phones.h
+++ b/src/control/Phones.h
@@ -5,42 +5,46 @@
class CPed;
class CAnimBlendAssociation;
-enum {
+enum PhoneState {
PHONE_STATE_FREE,
- PHONE_STATE_1,
+ PHONE_STATE_REPORTING_CRIME, // CCivilianPed::ProcessControl sets it but unused
PHONE_STATE_2,
PHONE_STATE_MESSAGE_REMOVED,
PHONE_STATE_ONETIME_MESSAGE_SET,
PHONE_STATE_REPEATED_MESSAGE_SET,
PHONE_STATE_REPEATED_MESSAGE_SHOWN_ONCE,
- PHONE_STATE_ONETIME_MESSAGE_SHOWN,
- PHONE_STATE_REPEATED_MESSAGE_SHOWN,
- PHONE_STATE_9
+ PHONE_STATE_ONETIME_MESSAGE_STARTED,
+ PHONE_STATE_REPEATED_MESSAGE_STARTED,
+ PHONE_STATE_9 // just rings, picking being handled via script. most of the time game uses this
};
-struct CPhone
+class CPhone
{
+public:
CVector m_vecPos;
wchar *m_apMessages[6];
- uint32 m_lastTimeRepeatedMsgShown;
- CEntity *m_pEntity; // it's building pool index in save files
- int32 m_nState;
- uint8 field_30;
+ uint32 m_repeatedMessagePickupStart;
+ CEntity *m_pEntity; // stored as building pool index in save files
+ PhoneState m_nState;
+ bool m_visibleToCam;
+
+ CPhone() { }
+ ~CPhone() { }
};
static_assert(sizeof(CPhone) == 0x34, "CPhone: error");
class CPhoneInfo {
public:
- static bool &isPhonePickedUp;
- static uint32 &phoneMessagesTimer;
- static CPhone *&pickedUpPhone;
- static bool &isPhoneBeingPickedUp;
- static CPed *&pedWhoPickingUpPhone;
+ static bool &bDisplayingPhoneMessage;
+ static uint32 &PhoneEnableControlsTimer;
+ static CPhone *&pPhoneDisplayingMessages;
+ static bool &bPickingUpPhone;
+ static CPed *&pCallBackPed;
int32 m_nMax;
- int32 m_nNum;
- CPhone m_aPhones[50];
+ int32 m_nScriptPhonesMax;
+ CPhone m_aPhones[NUMPHONES];
CPhoneInfo() { }
~CPhoneInfo() { }
@@ -62,4 +66,9 @@ public:
extern CPhoneInfo &gPhoneInfo;
void PhonePutDownCB(CAnimBlendAssociation *assoc, void *arg);
-void PhonePickUpCB(CAnimBlendAssociation *assoc, void *arg); \ No newline at end of file
+void PhonePickUpCB(CAnimBlendAssociation *assoc, void *arg);
+
+#ifdef TOGGLEABLE_BETA_FEATURES
+extern CPed *crimeReporters[NUMPHONES];
+bool isPhoneAvailable(int);
+#endif \ No newline at end of file
diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp
index 1bd1bf4b..ea305778 100644
--- a/src/control/Replay.cpp
+++ b/src/control/Replay.cpp
@@ -346,7 +346,7 @@ void CReplay::StorePedUpdate(CPed *ped, int id)
pp->matrix.CompressFromFullMatrix(ped->GetMatrix());
pp->assoc_group_id = ped->m_animGroup;
/* Would be more sane to use GetJustIndex(ped->m_pMyVehicle) in following assignment */
- if (ped->bInVehicle && ped->m_pMyVehicle)
+ if (ped->InVehicle())
pp->vehicle_index = (CPools::GetVehiclePool()->GetIndex(ped->m_pMyVehicle) >> 8) + 1;
else
pp->vehicle_index = 0;
diff --git a/src/control/Script.cpp b/src/control/Script.cpp
index 6d0c596d..c08eefe2 100644
--- a/src/control/Script.cpp
+++ b/src/control/Script.cpp
@@ -204,7 +204,7 @@ void CUpsideDownCarCheck::Init()
{
for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){
m_sCars[i].m_nVehicleIndex = -1;
- m_sCars[i].m_nVehicleIndex = 0;
+ m_sCars[i].m_nUpsideDownTimer = 0;
}
}
@@ -220,6 +220,10 @@ void CUpsideDownCarCheck::UpdateTimers()
{
uint32 timeStep = CTimer::GetTimeStepInMilliseconds();
for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){
+#ifdef FIX_BUGS
+ if (m_sCars[i].m_nVehicleIndex == -1)
+ continue;
+#endif
CVehicle* v = CPools::GetVehiclePool()->GetAt(m_sCars[i].m_nVehicleIndex);
if (v){
if (IsCarUpsideDown(m_sCars[i].m_nVehicleIndex))
@@ -1744,7 +1748,7 @@ int8 CRunningScript::ProcessCommandsFrom100To199(int32 command)
CollectParameters(&m_nIp, 1);
CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]);
if (ped) {
- if (ped->bInVehicle && ped->m_pMyVehicle) {
+ if (ped->InVehicle()) {
if (ped->m_pMyVehicle->pDriver == ped) {
ped->m_pMyVehicle->RemoveDriver();
ped->m_pMyVehicle->m_status = STATUS_ABANDONED;
@@ -2317,17 +2321,23 @@ int8 CRunningScript::ProcessCommandsFrom200To299(int32 command)
assert(pCurrent); // GetIndex(0) doesn't look good
int handle = CPools::GetVehiclePool()->GetIndex(pCurrent);
if (handle != CTheScripts::StoreVehicleIndex && m_bIsMissionScript){
- CVehicle* pOld = CPools::GetVehiclePool()->GetAt(CTheScripts::StoreVehicleIndex);
- if (pOld){
- CCarCtrl::RemoveFromInterestingVehicleList(pOld);
- if (pOld->VehicleCreatedBy == MISSION_VEHICLE && CTheScripts::StoreVehicleWasRandom){
- pOld->VehicleCreatedBy = RANDOM_VEHICLE;
- pOld->bIsLocked = false;
- CCarCtrl::NumRandomCars++;
- CCarCtrl::NumMissionCars--;
- CTheScripts::MissionCleanup.RemoveEntityFromList(CTheScripts::StoreVehicleIndex, CLEANUP_CAR);
+#ifdef FIX_BUGS
+ if (CTheScripts::StoreVehicleIndex != -1)
+#endif
+ {
+ CVehicle* pOld = CPools::GetVehiclePool()->GetAt(CTheScripts::StoreVehicleIndex);
+ if (pOld){
+ CCarCtrl::RemoveFromInterestingVehicleList(pOld);
+ if (pOld->VehicleCreatedBy == MISSION_VEHICLE && CTheScripts::StoreVehicleWasRandom){
+ pOld->VehicleCreatedBy = RANDOM_VEHICLE;
+ pOld->bIsLocked = false;
+ CCarCtrl::NumRandomCars++;
+ CCarCtrl::NumMissionCars--;
+ CTheScripts::MissionCleanup.RemoveEntityFromList(CTheScripts::StoreVehicleIndex, CLEANUP_CAR);
+ }
}
}
+
CTheScripts::StoreVehicleIndex = handle;
switch (pCurrent->VehicleCreatedBy){
case RANDOM_VEHICLE:
@@ -2367,17 +2377,23 @@ int8 CRunningScript::ProcessCommandsFrom200To299(int32 command)
assert(pCurrent); // Here pCurrent shouldn't be NULL anyway
int handle = CPools::GetVehiclePool()->GetIndex(pCurrent);
if (handle != CTheScripts::StoreVehicleIndex && m_bIsMissionScript) {
- CVehicle* pOld = CPools::GetVehiclePool()->GetAt(CTheScripts::StoreVehicleIndex);
- if (pOld) {
- CCarCtrl::RemoveFromInterestingVehicleList(pOld);
- if (pOld->VehicleCreatedBy == MISSION_VEHICLE && CTheScripts::StoreVehicleWasRandom) {
- pOld->VehicleCreatedBy = RANDOM_VEHICLE;
- pOld->bIsLocked = false;
- CCarCtrl::NumRandomCars++;
- CCarCtrl::NumMissionCars--;
- CTheScripts::MissionCleanup.RemoveEntityFromList(CTheScripts::StoreVehicleIndex, CLEANUP_CAR);
+#ifdef FIX_BUGS
+ if (CTheScripts::StoreVehicleIndex != -1)
+#endif
+ {
+ CVehicle* pOld = CPools::GetVehiclePool()->GetAt(CTheScripts::StoreVehicleIndex);
+ if (pOld){
+ CCarCtrl::RemoveFromInterestingVehicleList(pOld);
+ if (pOld->VehicleCreatedBy == MISSION_VEHICLE && CTheScripts::StoreVehicleWasRandom){
+ pOld->VehicleCreatedBy = RANDOM_VEHICLE;
+ pOld->bIsLocked = false;
+ CCarCtrl::NumRandomCars++;
+ CCarCtrl::NumMissionCars--;
+ CTheScripts::MissionCleanup.RemoveEntityFromList(CTheScripts::StoreVehicleIndex, CLEANUP_CAR);
+ }
}
}
+
CTheScripts::StoreVehicleIndex = handle;
switch (pCurrent->VehicleCreatedBy) {
case RANDOM_VEHICLE:
@@ -3438,7 +3454,7 @@ int8 CRunningScript::ProcessCommandsFrom300To399(int32 command)
assert(pPed);
// Useless call.
CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp));
- int handle = CRadar::SetEntityBlip(BLIP_CHAR, ScriptParams[0], 0, BLIP_DISPLAY_BOTH);
+ int handle = CRadar::SetEntityBlip(BLIP_CHAR, ScriptParams[0], 1, BLIP_DISPLAY_BOTH);
CRadar::ChangeBlipScale(handle, 3);
ScriptParams[0] = handle;
StoreParameters(&m_nIp, 1);
@@ -3451,7 +3467,7 @@ int8 CRunningScript::ProcessCommandsFrom300To399(int32 command)
assert(pObject);
// Useless call.
CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp));
- int handle = CRadar::SetEntityBlip(BLIP_OBJECT, ScriptParams[0], 0, BLIP_DISPLAY_BOTH);
+ int handle = CRadar::SetEntityBlip(BLIP_OBJECT, ScriptParams[0], 6, BLIP_DISPLAY_BOTH);
CRadar::ChangeBlipScale(handle, 3);
ScriptParams[0] = handle;
StoreParameters(&m_nIp, 1);
@@ -4948,7 +4964,7 @@ int8 CRunningScript::ProcessCommandsFrom500To599(int32 command)
assert(pPed);
CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[1]);
bool isTouching = false;
- if (pPed->bInVehicle && pPed->m_pMyVehicle)
+ if (pPed->InVehicle())
isTouching = false;
else if (pPed->GetHasCollidedWith(pObject))
isTouching = true;
@@ -5089,7 +5105,7 @@ int8 CRunningScript::ProcessCommandsFrom500To599(int32 command)
case COMMAND_HAS_PHONE_DISPLAYED_MESSAGE:
{
CollectParameters(&m_nIp, 1);
- gPhoneInfo.HasMessageBeenDisplayed(ScriptParams[0]);
+ UpdateCompareFlag(gPhoneInfo.HasMessageBeenDisplayed(ScriptParams[0]));
return 0;
}
case COMMAND_TURN_PHONE_OFF: