summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2020-12-18 13:50:37 +0100
committeraap <aap@papnet.eu>2020-12-18 13:50:37 +0100
commit55cf1a37cbce81db5b32264cfb4ebfa0a9793017 (patch)
tree9273d77a5fdffc4bc70cf7439fedb7935da024d6 /src/core
parentlittle cleanup and synch on templates and config (diff)
parentMerge pull request #889 from aap/miami (diff)
downloadre3-55cf1a37cbce81db5b32264cfb4ebfa0a9793017.tar
re3-55cf1a37cbce81db5b32264cfb4ebfa0a9793017.tar.gz
re3-55cf1a37cbce81db5b32264cfb4ebfa0a9793017.tar.bz2
re3-55cf1a37cbce81db5b32264cfb4ebfa0a9793017.tar.lz
re3-55cf1a37cbce81db5b32264cfb4ebfa0a9793017.tar.xz
re3-55cf1a37cbce81db5b32264cfb4ebfa0a9793017.tar.zst
re3-55cf1a37cbce81db5b32264cfb4ebfa0a9793017.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/Cam.cpp2
-rw-r--r--src/core/PlayerInfo.cpp626
-rw-r--r--src/core/PlayerInfo.h21
-rw-r--r--src/core/World.cpp96
-rw-r--r--src/core/World.h12
5 files changed, 373 insertions, 384 deletions
diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp
index 8aecf577..b2bbdb33 100644
--- a/src/core/Cam.cpp
+++ b/src/core/Cam.cpp
@@ -2705,7 +2705,7 @@ CCam::Process_1rstPersonPedOnPC(const CVector&, float TargetOrientation, float,
RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(CamTargetEntity->GetClump());
int32 idx = RpHAnimIDGetIndex(hier, ConvertPedNode2BoneTag(PED_HEAD));
RwMatrix *mats = RpHAnimHierarchyGetMatrixArray(hier);
- RwV3dTransformPoints((RwV3d*)&HeadPos, (RwV3d*)&HeadPos, 1, &mats[idx]);
+ RwV3dTransformPoints(&HeadPos, &HeadPos, 1, &mats[idx]);
RwV3d scl = { 0.0f, 0.0f, 0.0f };
RwMatrixScale(&mats[idx], &scl, rwCOMBINEPRECONCAT);
diff --git a/src/core/PlayerInfo.cpp b/src/core/PlayerInfo.cpp
index 61e2f67a..8cb9c49e 100644
--- a/src/core/PlayerInfo.cpp
+++ b/src/core/PlayerInfo.cpp
@@ -3,6 +3,7 @@
#include "Automobile.h"
#include "Bridge.h"
#include "Camera.h"
+#include "CarCtrl.h"
#include "Cranes.h"
#include "Darkel.h"
#include "Explosion.h"
@@ -34,93 +35,10 @@
#include "Automobile.h"
#include "GameLogic.h"
-CVector lastPlayerPos;
-
-// --MIAMI: Done
-void
-CPlayerInfo::SetPlayerSkin(char *skin)
-{
- strncpy(m_aSkinName, skin, 32);
- LoadPlayerSkin();
-}
-
-// --MIAMI: Done
-const CVector &
-CPlayerInfo::GetPos()
-{
-#ifdef FIX_BUGS
- if (!m_pPed)
- return TheCamera.GetPosition();
-#endif
- if (m_pPed->InVehicle())
- return m_pPed->m_pMyVehicle->GetPosition();
- return m_pPed->GetPosition();
-}
-
-// --MIAMI: Done
-void
-CPlayerInfo::LoadPlayerSkin()
-{
- DeletePlayerSkin();
-
- m_pSkinTexture = CPlayerSkin::GetSkinTexture(m_aSkinName);
-}
-
-// --MIAMI: Done
-void
-CPlayerInfo::DeletePlayerSkin()
-{
- if (m_pSkinTexture) {
- RwTextureDestroy(m_pSkinTexture);
- m_pSkinTexture = nil;
- }
-}
-
-// --MIAMI: Done
-void
-CPlayerInfo::KillPlayer()
-{
- if (m_WBState != WBSTATE_PLAYING) return;
-
- m_WBState = WBSTATE_WASTED;
- m_nWBTime = CTimer::GetTimeInMilliseconds();
- CDarkel::ResetOnPlayerDeath();
- CMessages::AddBigMessage(TheText.Get("DEAD"), 4000, 2);
- CStats::TimesDied++;
-}
-
-// --MIAMI: Done
-void
-CPlayerInfo::ArrestPlayer()
-{
- if (m_WBState != WBSTATE_PLAYING) return;
+// --MIAMI: File done
- m_WBState = WBSTATE_BUSTED;
- m_nWBTime = CTimer::GetTimeInMilliseconds();
- m_nBustedAudioStatus = BUSTEDAUDIO_NONE;
- CDarkel::ResetOnPlayerDeath();
- CMessages::AddBigMessage(TheText.Get("BUSTED"), 5000, 2);
- CStats::TimesArrested++;
-}
-
-// --MIAMI: Done
-bool
-CPlayerInfo::IsPlayerInRemoteMode()
-{
- return m_pRemoteVehicle || m_bInRemoteMode;
-}
-
-void
-CPlayerInfo::PlayerFailedCriticalMission()
-{
- if (m_WBState != WBSTATE_PLAYING)
- return;
- m_WBState = WBSTATE_FAILED_CRITICAL_MISSION;
- m_nWBTime = CTimer::GetTimeInMilliseconds();
- CDarkel::ResetOnPlayerDeath();
-}
+CVector lastPlayerPos;
-// --MIAMI: Done
void
CPlayerInfo::Clear(void)
{
@@ -181,192 +99,6 @@ CPlayerInfo::Clear(void)
m_nBustedAudioStatus = BUSTEDAUDIO_NONE;
}
-// --MIAMI: Done
-void
-CPlayerInfo::BlowUpRCBuggy(bool actually)
-{
- if (!m_pRemoteVehicle || m_pRemoteVehicle->bRemoveFromWorld)
- return;
-
- CRemote::TakeRemoteControlledCarFromPlayer(actually);
- if (actually)
- m_pRemoteVehicle->BlowUpCar(FindPlayerPed());
-}
-
-// --MIAMI: Done
-void
-CPlayerInfo::CancelPlayerEnteringCars(CVehicle *car)
-{
- if (!car || car == m_pPed->m_pMyVehicle) {
- if (m_pPed->EnteringCar())
- m_pPed->QuitEnteringCar();
- }
- if (m_pPed->m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER || m_pPed->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER)
- m_pPed->ClearObjective();
-}
-
-// --MIAMI: Done
-void
-CPlayerInfo::MakePlayerSafe(bool toggle)
-{
- if (toggle) {
- m_pPed->m_pWanted->m_bIgnoredByEveryone = true;
- CWorld::StopAllLawEnforcersInTheirTracks();
- CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_PLAYERINFO);
- CPad::StopPadsShaking();
- m_pPed->bBulletProof = true;
- m_pPed->bFireProof = true;
- m_pPed->bCollisionProof = true;
- m_pPed->bMeleeProof = true;
- m_pPed->bOnlyDamagedByPlayer = true;
- m_pPed->bExplosionProof = true;
- m_pPed->m_bCanBeDamaged = false;
- ((CPlayerPed*)m_pPed)->ClearAdrenaline();
- CancelPlayerEnteringCars(nil);
- gFireManager.ExtinguishPoint(GetPos(), 4000.0f);
- CExplosion::RemoveAllExplosionsInArea(GetPos(), 4000.0f);
- CProjectileInfo::RemoveAllProjectiles();
- CWorld::SetAllCarsCanBeDamaged(false);
- CWorld::ExtinguishAllCarFiresInArea(GetPos(), 4000.0f);
- CReplay::DisableReplays();
-
- } else {
- m_pPed->m_pWanted->m_bIgnoredByEveryone = false;
- CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_PLAYERINFO);
- m_pPed->bBulletProof = false;
- m_pPed->bFireProof = false;
- m_pPed->bCollisionProof = false;
- m_pPed->bMeleeProof = false;
- m_pPed->bOnlyDamagedByPlayer = false;
- m_pPed->bExplosionProof = false;
- m_pPed->m_bCanBeDamaged = true;
- CWorld::SetAllCarsCanBeDamaged(true);
- CReplay::EnableReplays();
- }
-}
-
-// --MIAMI: Done
-bool
-CPlayerInfo::IsRestartingAfterDeath()
-{
- return m_WBState == WBSTATE_WASTED;
-}
-
-// --MIAMI: Done
-bool
-CPlayerInfo::IsRestartingAfterArrest()
-{
- return m_WBState == WBSTATE_BUSTED;
-}
-
-// --MIAMI: Done
-// lastCloseness is passed to other calls of this function
-void
-CPlayerInfo::EvaluateCarPosition(CEntity *carToTest, CPed *player, float carBoundCentrePedDist, float *lastCloseness, CVehicle **closestCarOutput)
-{
- // This dist used for determining the angle to face
- CVector2D dist(carToTest->GetPosition() - player->GetPosition());
- float neededTurn = CGeneral::GetATanOfXY(player->GetForward().x, player->GetForward().y) - CGeneral::GetATanOfXY(dist.x, dist.y);
- while (neededTurn >= PI) {
- neededTurn -= 2 * PI;
- }
-
- while (neededTurn < -PI) {
- neededTurn += 2 * PI;
- }
-
- // This dist used for evaluating cars' distances, weird...
- // Accounts inverted needed turn (or needed turn in long way) and car dist.
- float closeness = (1.0f - Abs(neededTurn) / TWOPI) * (10.0f - carBoundCentrePedDist);
- if (closeness > *lastCloseness) {
- *lastCloseness = closeness;
- *closestCarOutput = (CVehicle*)carToTest;
- }
-}
-
-// --MIAMI: Done
-void
-CPlayerInfo::SavePlayerInfo(uint8 *buf, uint32 *size)
-{
- // Interesting
- *size = sizeof(CPlayerInfo);
-
-#define CopyToBuf(buf, data) memcpy(buf, &data, sizeof(data)); buf += sizeof(data);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nMoney);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_WBState);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nWBTime);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nTrafficMultiplier);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_fRoadDensity);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nCollectedPackages);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nTotalPackages);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bInfiniteSprint);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bFastReload);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bFireproof);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nMaxHealth);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nMaxArmour);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfJailFree);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfHospitalFree);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bDriveByAllowed);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_aPlayerName);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nBustedAudioStatus);
- CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nCurrentBustedAudio);
-#undef CopyToBuf
-}
-
-// --MIAMI: Done
-void
-CPlayerInfo::LoadPlayerInfo(uint8 *buf, uint32 size)
-{
-#define CopyFromBuf(buf, data) memcpy(&data, buf, sizeof(data)); buf += sizeof(data);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nMoney);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_WBState);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nWBTime);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nTrafficMultiplier);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_fRoadDensity);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nCollectedPackages);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nTotalPackages);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bInfiniteSprint);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bFastReload);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bFireproof);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nMaxHealth);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nMaxArmour);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfJailFree);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfHospitalFree);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bDriveByAllowed);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_aPlayerName);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nBustedAudioStatus);
- CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nCurrentBustedAudio)
-#undef CopyFromBuf
-}
-
-// --MIAMI: Done
-void
-CPlayerInfo::FindClosestCarSectorList(CPtrList& carList, CPed* ped, float unk1, float unk2, float unk3, float unk4, float* lastCloseness, CVehicle** closestCarOutput)
-{
- for (CPtrNode* node = carList.first; node; node = node->next) {
- CVehicle *car = (CVehicle*)node->item;
- if(car->m_scanCode != CWorld::GetCurrentScanCode()) {
- if (!car->bUsesCollision || !car->IsVehicle())
- continue;
-
- car->m_scanCode = CWorld::GetCurrentScanCode();
- if (car->GetStatus() != STATUS_WRECKED && car->GetStatus() != STATUS_TRAIN_MOVING
- && (car->GetUp().z > 0.3f || (car->IsVehicle() && ((CVehicle*)car)->m_vehType == VEHICLE_TYPE_BIKE))) {
- CVector carCentre = car->GetBoundCentre();
-
- if (Abs(ped->GetPosition().z - carCentre.z) < 2.0f || car->IsCar() && carCentre.z < ped->GetPosition().z && ped->GetPosition().z - 4.f < carCentre.z) {
- float dist = (ped->GetPosition() - carCentre).Magnitude2D();
- if (dist <= 10.0f && !CCranes::IsThisCarBeingCarriedByAnyCrane(car)) {
- EvaluateCarPosition(car, ped, dist, lastCloseness, closestCarOutput);
- }
- }
- }
- }
- }
-}
-
void
CPlayerInfo::Process(void)
{
@@ -796,3 +528,355 @@ CPlayerInfo::Process(void)
m_nMoney = Min(999999999, m_nMoney);
m_nVisibleMoney = Min(999999999, m_nVisibleMoney);
}
+
+bool
+CPlayerInfo::IsPlayerInRemoteMode()
+{
+ return m_pRemoteVehicle || m_bInRemoteMode;
+}
+
+void
+CPlayerInfo::SavePlayerInfo(uint8 *buf, uint32 *size)
+{
+ // Interesting
+ *size = sizeof(CPlayerInfo);
+
+#define CopyToBuf(buf, data) memcpy(buf, &data, sizeof(data)); buf += sizeof(data);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nMoney);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_WBState);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nWBTime);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nTrafficMultiplier);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_fRoadDensity);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nCollectedPackages);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nTotalPackages);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bInfiniteSprint);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bFastReload);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bFireproof);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nMaxHealth);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nMaxArmour);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfJailFree);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfHospitalFree);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bDriveByAllowed);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_aPlayerName);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nBustedAudioStatus);
+ CopyToBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nCurrentBustedAudio);
+#undef CopyToBuf
+}
+
+void
+CPlayerInfo::LoadPlayerInfo(uint8 *buf, uint32 size)
+{
+#define CopyFromBuf(buf, data) memcpy(&data, buf, sizeof(data)); buf += sizeof(data);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nMoney);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_WBState);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nWBTime);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nTrafficMultiplier);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_fRoadDensity);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nCollectedPackages);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nTotalPackages);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bInfiniteSprint);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bFastReload);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bFireproof);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nMaxHealth);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nMaxArmour);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfJailFree);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bGetOutOfHospitalFree);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_bDriveByAllowed);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_aPlayerName);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nBustedAudioStatus);
+ CopyFromBuf(buf, CWorld::Players[CWorld::PlayerInFocus].m_nCurrentBustedAudio)
+#undef CopyFromBuf
+}
+
+void
+CPlayerInfo::FindClosestCarSectorList(CPtrList& carList, CPed* ped, float unk1, float unk2, float unk3, float unk4, float* lastCloseness, CVehicle** closestCarOutput)
+{
+ for (CPtrNode* node = carList.first; node; node = node->next) {
+ CVehicle *car = (CVehicle*)node->item;
+ if(car->m_scanCode != CWorld::GetCurrentScanCode()) {
+ if (!car->bUsesCollision || !car->IsVehicle())
+ continue;
+
+ car->m_scanCode = CWorld::GetCurrentScanCode();
+ if (car->GetStatus() != STATUS_WRECKED && car->GetStatus() != STATUS_TRAIN_MOVING
+ && (car->GetUp().z > 0.3f || (car->IsVehicle() && ((CVehicle*)car)->m_vehType == VEHICLE_TYPE_BIKE))) {
+ CVector carCentre = car->GetBoundCentre();
+
+ if (Abs(ped->GetPosition().z - carCentre.z) < 2.0f || car->IsCar() && carCentre.z < ped->GetPosition().z && ped->GetPosition().z - 4.f < carCentre.z) {
+ float dist = (ped->GetPosition() - carCentre).Magnitude2D();
+ if (dist <= 10.0f && !CCranes::IsThisCarBeingCarriedByAnyCrane(car)) {
+ EvaluateCarPosition(car, ped, dist, lastCloseness, closestCarOutput);
+ }
+ }
+ }
+ }
+ }
+}
+
+// lastCloseness is passed to other calls of this function
+void
+CPlayerInfo::EvaluateCarPosition(CEntity *carToTest, CPed *player, float carBoundCentrePedDist, float *lastCloseness, CVehicle **closestCarOutput)
+{
+ // This dist used for determining the angle to face
+ CVector2D dist(carToTest->GetPosition() - player->GetPosition());
+ float neededTurn = CGeneral::GetATanOfXY(player->GetForward().x, player->GetForward().y) - CGeneral::GetATanOfXY(dist.x, dist.y);
+ while (neededTurn >= PI) {
+ neededTurn -= 2 * PI;
+ }
+
+ while (neededTurn < -PI) {
+ neededTurn += 2 * PI;
+ }
+
+ // This dist used for evaluating cars' distances, weird...
+ // Accounts inverted needed turn (or needed turn in long way) and car dist.
+ float closeness = (1.0f - Abs(neededTurn) / TWOPI) * (10.0f - carBoundCentrePedDist);
+ if (closeness > *lastCloseness) {
+ *lastCloseness = closeness;
+ *closestCarOutput = (CVehicle*)carToTest;
+ }
+}
+
+const CVector &
+CPlayerInfo::GetPos()
+{
+#ifdef FIX_BUGS
+ if (!m_pPed)
+ return TheCamera.GetPosition();
+#endif
+ if (m_pPed->InVehicle())
+ return m_pPed->m_pMyVehicle->GetPosition();
+ return m_pPed->GetPosition();
+}
+
+CVector
+FindPlayerCoors(void)
+{
+#ifdef FIX_BUGS
+ if (CReplay::IsPlayingBack())
+ return TheCamera.GetPosition();
+#endif
+ CPlayerPed *ped = FindPlayerPed();
+ if(ped->InVehicle())
+ return ped->m_pMyVehicle->GetPosition();
+ else
+ return ped->GetPosition();
+}
+
+const CVector &
+FindPlayerSpeed(void)
+{
+#ifdef FIX_BUGS
+ static CVector vecTmpVector(0.0f, 0.0f, 0.0f);
+ if (CReplay::IsPlayingBack())
+ return vecTmpVector;
+#endif
+ CPlayerPed *ped = FindPlayerPed();
+ if(ped->InVehicle())
+ return ped->m_pMyVehicle->m_vecMoveSpeed;
+ else
+ return ped->m_vecMoveSpeed;
+}
+
+CVehicle *
+FindPlayerVehicle(void)
+{
+ CPlayerPed *ped = FindPlayerPed();
+ if(ped && ped->InVehicle()) return ped->m_pMyVehicle;
+ return nil;
+}
+
+CEntity *
+FindPlayerEntity(void)
+{
+ CPlayerPed *ped = FindPlayerPed();
+ if(ped->InVehicle())
+ return ped->m_pMyVehicle;
+ else
+ return ped;
+}
+
+CVehicle *
+FindPlayerTrain(void)
+{
+ if(FindPlayerVehicle() && FindPlayerVehicle()->IsTrain())
+ return FindPlayerVehicle();
+ else
+ return nil;
+}
+
+CPlayerPed *
+FindPlayerPed(void)
+{
+ return CWorld::Players[CWorld::PlayerInFocus].m_pPed;
+}
+
+const CVector &
+FindPlayerCentreOfWorld(int32 player)
+{
+#ifdef FIX_BUGS
+ if(CReplay::IsPlayingBack()) return TheCamera.GetPosition();
+#endif
+ if(CCarCtrl::bCarsGeneratedAroundCamera) return TheCamera.GetPosition();
+ if(CWorld::Players[player].m_pRemoteVehicle) return CWorld::Players[player].m_pRemoteVehicle->GetPosition();
+ if(FindPlayerVehicle()) return FindPlayerVehicle()->GetPosition();
+ return CWorld::Players[player].m_pPed->GetPosition();
+}
+
+const CVector &
+FindPlayerCentreOfWorld_NoSniperShift(void)
+{
+#ifdef FIX_BUGS
+ if (CReplay::IsPlayingBack()) return TheCamera.GetPosition();
+#endif
+ if(CCarCtrl::bCarsGeneratedAroundCamera) return TheCamera.GetPosition();
+ if(CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle)
+ return CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->GetPosition();
+ if(FindPlayerVehicle()) return FindPlayerVehicle()->GetPosition();
+ return FindPlayerPed()->GetPosition();
+}
+
+float
+FindPlayerHeading(void)
+{
+ if(CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle)
+ return CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->GetForward().Heading();
+ if(FindPlayerVehicle()) return FindPlayerVehicle()->GetForward().Heading();
+ return FindPlayerPed()->GetForward().Heading();
+}
+
+bool
+CPlayerInfo::IsRestartingAfterDeath()
+{
+ return m_WBState == WBSTATE_WASTED;
+}
+
+bool
+CPlayerInfo::IsRestartingAfterArrest()
+{
+ return m_WBState == WBSTATE_BUSTED;
+}
+
+void
+CPlayerInfo::KillPlayer()
+{
+ if (m_WBState != WBSTATE_PLAYING) return;
+
+ m_WBState = WBSTATE_WASTED;
+ m_nWBTime = CTimer::GetTimeInMilliseconds();
+ CDarkel::ResetOnPlayerDeath();
+ CMessages::AddBigMessage(TheText.Get("DEAD"), 4000, 2);
+ CStats::TimesDied++;
+}
+
+void
+CPlayerInfo::ArrestPlayer()
+{
+ if (m_WBState != WBSTATE_PLAYING) return;
+
+ m_WBState = WBSTATE_BUSTED;
+ m_nWBTime = CTimer::GetTimeInMilliseconds();
+ m_nBustedAudioStatus = BUSTEDAUDIO_NONE;
+ CDarkel::ResetOnPlayerDeath();
+ CMessages::AddBigMessage(TheText.Get("BUSTED"), 5000, 2);
+ CStats::TimesArrested++;
+}
+
+void
+CPlayerInfo::PlayerFailedCriticalMission()
+{
+ if (m_WBState != WBSTATE_PLAYING)
+ return;
+ m_WBState = WBSTATE_FAILED_CRITICAL_MISSION;
+ m_nWBTime = CTimer::GetTimeInMilliseconds();
+ CDarkel::ResetOnPlayerDeath();
+}
+
+void
+CPlayerInfo::CancelPlayerEnteringCars(CVehicle *car)
+{
+ if (!car || car == m_pPed->m_pMyVehicle) {
+ if (m_pPed->EnteringCar())
+ m_pPed->QuitEnteringCar();
+ }
+ if (m_pPed->m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER || m_pPed->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER)
+ m_pPed->ClearObjective();
+}
+
+void
+CPlayerInfo::MakePlayerSafe(bool toggle)
+{
+ if (toggle) {
+ m_pPed->m_pWanted->m_bIgnoredByEveryone = true;
+ CWorld::StopAllLawEnforcersInTheirTracks();
+ CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_PLAYERINFO);
+ CPad::StopPadsShaking();
+ m_pPed->bBulletProof = true;
+ m_pPed->bFireProof = true;
+ m_pPed->bCollisionProof = true;
+ m_pPed->bMeleeProof = true;
+ m_pPed->bOnlyDamagedByPlayer = true;
+ m_pPed->bExplosionProof = true;
+ m_pPed->m_bCanBeDamaged = false;
+ ((CPlayerPed*)m_pPed)->ClearAdrenaline();
+ CancelPlayerEnteringCars(nil);
+ gFireManager.ExtinguishPoint(GetPos(), 4000.0f);
+ CExplosion::RemoveAllExplosionsInArea(GetPos(), 4000.0f);
+ CProjectileInfo::RemoveAllProjectiles();
+ CWorld::SetAllCarsCanBeDamaged(false);
+ CWorld::ExtinguishAllCarFiresInArea(GetPos(), 4000.0f);
+ CReplay::DisableReplays();
+
+ } else {
+ m_pPed->m_pWanted->m_bIgnoredByEveryone = false;
+ CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_PLAYERINFO);
+ m_pPed->bBulletProof = false;
+ m_pPed->bFireProof = false;
+ m_pPed->bCollisionProof = false;
+ m_pPed->bMeleeProof = false;
+ m_pPed->bOnlyDamagedByPlayer = false;
+ m_pPed->bExplosionProof = false;
+ m_pPed->m_bCanBeDamaged = true;
+ CWorld::SetAllCarsCanBeDamaged(true);
+ CReplay::EnableReplays();
+ }
+}
+
+void
+CPlayerInfo::BlowUpRCBuggy(bool actually)
+{
+ if (!m_pRemoteVehicle || m_pRemoteVehicle->bRemoveFromWorld)
+ return;
+
+ CRemote::TakeRemoteControlledCarFromPlayer(actually);
+ if (actually)
+ m_pRemoteVehicle->BlowUpCar(FindPlayerPed());
+}
+
+#ifdef GTA_PC
+void
+CPlayerInfo::SetPlayerSkin(const char *skin)
+{
+ strncpy(m_aSkinName, skin, 32);
+ LoadPlayerSkin();
+}
+
+void
+CPlayerInfo::LoadPlayerSkin()
+{
+ DeletePlayerSkin();
+
+ m_pSkinTexture = CPlayerSkin::GetSkinTexture(m_aSkinName);
+}
+
+void
+CPlayerInfo::DeletePlayerSkin()
+{
+ if (m_pSkinTexture) {
+ RwTextureDestroy(m_pSkinTexture);
+ m_pSkinTexture = nil;
+ }
+}
+#endif
diff --git a/src/core/PlayerInfo.h b/src/core/PlayerInfo.h
index 68a50c82..a3896ebb 100644
--- a/src/core/PlayerInfo.h
+++ b/src/core/PlayerInfo.h
@@ -84,13 +84,12 @@ public:
bool m_bDriveByAllowed;
uint8 m_nBustedAudioStatus;
int16 m_nCurrentBustedAudio;
+#ifdef GTA_PC
char m_aSkinName[32];
RwTexture *m_pSkinTexture;
+#endif
void MakePlayerSafe(bool);
- void LoadPlayerSkin();
- void DeletePlayerSkin();
- void SetPlayerSkin(char* skin);
const CVector &GetPos();
void Process(void);
void KillPlayer(void);
@@ -107,5 +106,19 @@ public:
void SavePlayerInfo(uint8 *buf, uint32* size);
void FindClosestCarSectorList(CPtrList&, CPed*, float, float, float, float, float*, CVehicle**);
- ~CPlayerInfo() { };
+#ifdef GTA_PC
+ void LoadPlayerSkin();
+ void SetPlayerSkin(const char *skin);
+ void DeletePlayerSkin();
+#endif
};
+
+CPlayerPed *FindPlayerPed(void);
+CVehicle *FindPlayerVehicle(void);
+CVehicle *FindPlayerTrain(void);
+CEntity *FindPlayerEntity(void);
+CVector FindPlayerCoors(void);
+const CVector &FindPlayerSpeed(void);
+const CVector &FindPlayerCentreOfWorld(int32 player);
+const CVector &FindPlayerCentreOfWorld_NoSniperShift(void);
+float FindPlayerHeading(void); \ No newline at end of file
diff --git a/src/core/World.cpp b/src/core/World.cpp
index a75d17eb..7d5f89b8 100644
--- a/src/core/World.cpp
+++ b/src/core/World.cpp
@@ -1399,102 +1399,6 @@ CWorld::FindMissionEntitiesIntersectingCubeSectorList(CPtrList &list, const CVec
}
}
-CPlayerPed *
-FindPlayerPed(void)
-{
- return CWorld::Players[CWorld::PlayerInFocus].m_pPed;
-}
-
-CVehicle *
-FindPlayerVehicle(void)
-{
- CPlayerPed *ped = FindPlayerPed();
- if(ped && ped->InVehicle()) return ped->m_pMyVehicle;
- return nil;
-}
-
-CVehicle *
-FindPlayerTrain(void)
-{
- if(FindPlayerVehicle() && FindPlayerVehicle()->IsTrain())
- return FindPlayerVehicle();
- else
- return nil;
-}
-
-CEntity *
-FindPlayerEntity(void)
-{
- CPlayerPed *ped = FindPlayerPed();
- if(ped->InVehicle())
- return ped->m_pMyVehicle;
- else
- return ped;
-}
-
-CVector
-FindPlayerCoors(void)
-{
-#ifdef FIX_BUGS
- if (CReplay::IsPlayingBack())
- return TheCamera.GetPosition();
-#endif
- CPlayerPed *ped = FindPlayerPed();
- if(ped->InVehicle())
- return ped->m_pMyVehicle->GetPosition();
- else
- return ped->GetPosition();
-}
-
-CVector &
-FindPlayerSpeed(void)
-{
-#ifdef FIX_BUGS
- static CVector vecTmpVector(0.0f, 0.0f, 0.0f);
- if (CReplay::IsPlayingBack())
- return vecTmpVector;
-#endif
- CPlayerPed *ped = FindPlayerPed();
- if(ped->InVehicle())
- return ped->m_pMyVehicle->m_vecMoveSpeed;
- else
- return ped->m_vecMoveSpeed;
-}
-
-const CVector &
-FindPlayerCentreOfWorld(int32 player)
-{
-#ifdef FIX_BUGS
- if(CReplay::IsPlayingBack()) return TheCamera.GetPosition();
-#endif
- if(CCarCtrl::bCarsGeneratedAroundCamera) return TheCamera.GetPosition();
- if(CWorld::Players[player].m_pRemoteVehicle) return CWorld::Players[player].m_pRemoteVehicle->GetPosition();
- if(FindPlayerVehicle()) return FindPlayerVehicle()->GetPosition();
- return CWorld::Players[player].m_pPed->GetPosition();
-}
-
-const CVector &
-FindPlayerCentreOfWorld_NoSniperShift(void)
-{
-#ifdef FIX_BUGS
- if (CReplay::IsPlayingBack()) return TheCamera.GetPosition();
-#endif
- if(CCarCtrl::bCarsGeneratedAroundCamera) return TheCamera.GetPosition();
- if(CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle)
- return CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->GetPosition();
- if(FindPlayerVehicle()) return FindPlayerVehicle()->GetPosition();
- return FindPlayerPed()->GetPosition();
-}
-
-float
-FindPlayerHeading(void)
-{
- if(CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle)
- return CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->GetForward().Heading();
- if(FindPlayerVehicle()) return FindPlayerVehicle()->GetForward().Heading();
- return FindPlayerPed()->GetForward().Heading();
-}
-
void
CWorld::ClearCarsFromArea(float x1, float y1, float z1, float x2, float y2, float z2)
{
diff --git a/src/core/World.h b/src/core/World.h
index 74ee4d8a..59bf634c 100644
--- a/src/core/World.h
+++ b/src/core/World.h
@@ -178,15 +178,3 @@ public:
};
extern CColPoint gaTempSphereColPoints[MAX_COLLISION_POINTS];
-
-class CPlayerPed;
-class CVehicle;
-CPlayerPed *FindPlayerPed(void);
-CVehicle *FindPlayerVehicle(void);
-CVehicle *FindPlayerTrain(void);
-CEntity *FindPlayerEntity(void);
-CVector FindPlayerCoors(void);
-CVector &FindPlayerSpeed(void);
-const CVector &FindPlayerCentreOfWorld(int32 player);
-const CVector &FindPlayerCentreOfWorld_NoSniperShift(void);
-float FindPlayerHeading(void);